Bug 1380118 - Update aom library. draft
authorRalph Giles <giles@mozilla.com>
Mon, 10 Jul 2017 23:12:08 -0700
changeset 609093 45850bb3235ed599d45612cc8d0c5d9f998bee54
parent 609092 b8c1d35c02f1ab9f99f76b6c97a744e3595cbff5
child 609094 1410914318fabd0c21a1a236d76219561ce77404
push id68501
push userbmo:giles@thaumas.net
push dateFri, 14 Jul 2017 19:38:57 +0000
bugs1380118
milestone56.0a1
Bug 1380118 - Update aom library. Update to git commit ebc9c9ef76c23b57b5583081416b5ee839e1be0a to pick up recent changes. This commit also disables some expensive features to speed up encode time and test the xiph rate-control pointed from daala. This commit is from https://github.com/mozilla/aom MozReview-Commit-ID: 20Pno026LS6
dom/media/platforms/agnostic/AOMDecoder.cpp
media/libaom/README_MOZILLA
media/libaom/config/generic/aom_config.asm
media/libaom/config/generic/aom_config.h
media/libaom/config/generic/aom_dsp_rtcd.h
media/libaom/config/generic/av1_rtcd.h
media/libaom/config/linux/arm/aom_config.asm
media/libaom/config/linux/arm/aom_config.h
media/libaom/config/linux/arm/aom_dsp_rtcd.h
media/libaom/config/linux/arm/av1_rtcd.h
media/libaom/config/linux/ia32/aom_config.asm
media/libaom/config/linux/ia32/aom_config.h
media/libaom/config/linux/ia32/aom_dsp_rtcd.h
media/libaom/config/linux/ia32/av1_rtcd.h
media/libaom/config/linux/x64/aom_config.asm
media/libaom/config/linux/x64/aom_config.h
media/libaom/config/linux/x64/aom_dsp_rtcd.h
media/libaom/config/linux/x64/av1_rtcd.h
media/libaom/config/mac/x64/aom_config.asm
media/libaom/config/mac/x64/aom_config.h
media/libaom/config/mac/x64/aom_dsp_rtcd.h
media/libaom/config/mac/x64/av1_rtcd.h
media/libaom/config/win/ia32/aom_config.asm
media/libaom/config/win/ia32/aom_config.h
media/libaom/config/win/ia32/aom_dsp_rtcd.h
media/libaom/config/win/ia32/av1_rtcd.h
media/libaom/config/win/mingw32/aom_config.asm
media/libaom/config/win/mingw32/aom_config.c
media/libaom/config/win/mingw32/aom_config.h
media/libaom/config/win/mingw32/aom_dsp_rtcd.h
media/libaom/config/win/mingw32/aom_scale_rtcd.h
media/libaom/config/win/mingw32/av1_rtcd.h
media/libaom/config/win/x64/aom_config.asm
media/libaom/config/win/x64/aom_config.h
media/libaom/config/win/x64/aom_dsp_rtcd.h
media/libaom/config/win/x64/av1_rtcd.h
media/libaom/sources.mozbuild
third_party/aom/CMakeLists.txt
third_party/aom/README
third_party/aom/README.md
third_party/aom/aom/aom_decoder.h
third_party/aom/aom/aom_encoder.h
third_party/aom/aom/aom_image.h
third_party/aom/aom/aomcx.h
third_party/aom/aom_dsp/aom_convolve.c
third_party/aom/aom_dsp/aom_dsp.cmake
third_party/aom/aom_dsp/aom_dsp.mk
third_party/aom/aom_dsp/aom_dsp_common.h
third_party/aom/aom_dsp/aom_dsp_rtcd_defs.pl
third_party/aom/aom_dsp/aom_filter.h
third_party/aom/aom_dsp/fwd_txfm.c
third_party/aom/aom_dsp/fwd_txfm.h
third_party/aom/aom_dsp/intrapred.c
third_party/aom/aom_dsp/inv_txfm.c
third_party/aom/aom_dsp/inv_txfm.h
third_party/aom/aom_dsp/mips/fwd_dct32x32_msa.c
third_party/aom/aom_dsp/mips/fwd_txfm_msa.c
third_party/aom/aom_dsp/quantize.c
third_party/aom/aom_dsp/simd/v256_intrinsics_v128.h
third_party/aom/aom_dsp/txfm_common.h
third_party/aom/aom_dsp/variance.c
third_party/aom/aom_dsp/x86/fwd_txfm_sse2.c
third_party/aom/aom_dsp/x86/highbd_quantize_intrin_avx2.c
third_party/aom/aom_dsp/x86/highbd_quantize_intrin_sse2.c
third_party/aom/aom_dsp/x86/highbd_variance_sse2.c
third_party/aom/aom_dsp/x86/inv_txfm_sse2.c
third_party/aom/aom_dsp/x86/sad_highbd_avx2.c
third_party/aom/aom_dsp/x86/variance_sse2.c
third_party/aom/aom_mem/aom_mem.cmake
third_party/aom/aom_ports/aom_ports.cmake
third_party/aom/aom_scale/aom_scale.cmake
third_party/aom/aom_scale/yv12config.h
third_party/aom/aom_util/aom_util.cmake
third_party/aom/aomdec.c
third_party/aom/aomenc.c
third_party/aom/av1/av1.cmake
third_party/aom/av1/av1_common.mk
third_party/aom/av1/av1_cx.mk
third_party/aom/av1/av1_cx_iface.c
third_party/aom/av1/av1_dx_iface.c
third_party/aom/av1/av1_iface_common.h
third_party/aom/av1/common/alloccommon.c
third_party/aom/av1/common/arm/neon/iht4x4_add_neon.c
third_party/aom/av1/common/arm/neon/iht8x8_add_neon.c
third_party/aom/av1/common/av1_fwd_txfm1d_cfg.h
third_party/aom/av1/common/av1_fwd_txfm2d.c
third_party/aom/av1/common/av1_inv_txfm1d_cfg.h
third_party/aom/av1/common/av1_inv_txfm2d.c
third_party/aom/av1/common/av1_loopfilter.c
third_party/aom/av1/common/av1_rtcd_defs.pl
third_party/aom/av1/common/av1_txfm.h
third_party/aom/av1/common/blockd.c
third_party/aom/av1/common/blockd.h
third_party/aom/av1/common/cdef.c
third_party/aom/av1/common/cdef.h
third_party/aom/av1/common/cfl.c
third_party/aom/av1/common/cfl.h
third_party/aom/av1/common/common_data.h
third_party/aom/av1/common/convolve.c
third_party/aom/av1/common/convolve.h
third_party/aom/av1/common/entropy.c
third_party/aom/av1/common/entropymode.c
third_party/aom/av1/common/entropymode.h
third_party/aom/av1/common/entropymv.c
third_party/aom/av1/common/entropymv.h
third_party/aom/av1/common/enums.h
third_party/aom/av1/common/idct.c
third_party/aom/av1/common/idct.h
third_party/aom/av1/common/mips/dspr2/av1_itrans16_dspr2.c
third_party/aom/av1/common/mips/dspr2/av1_itrans4_dspr2.c
third_party/aom/av1/common/mips/dspr2/av1_itrans8_dspr2.c
third_party/aom/av1/common/mips/msa/av1_idct16x16_msa.c
third_party/aom/av1/common/mips/msa/av1_idct4x4_msa.c
third_party/aom/av1/common/mips/msa/av1_idct8x8_msa.c
third_party/aom/av1/common/mv.h
third_party/aom/av1/common/mvref_common.c
third_party/aom/av1/common/mvref_common.h
third_party/aom/av1/common/onyxc_int.h
third_party/aom/av1/common/pred_common.c
third_party/aom/av1/common/pred_common.h
third_party/aom/av1/common/quant_common.c
third_party/aom/av1/common/reconinter.c
third_party/aom/av1/common/reconinter.h
third_party/aom/av1/common/reconintra.c
third_party/aom/av1/common/reconintra.h
third_party/aom/av1/common/resize.c
third_party/aom/av1/common/resize.h
third_party/aom/av1/common/restoration.c
third_party/aom/av1/common/scale.c
third_party/aom/av1/common/scale.h
third_party/aom/av1/common/scan.h
third_party/aom/av1/common/tile_common.c
third_party/aom/av1/common/txb_common.h
third_party/aom/av1/common/warped_motion.c
third_party/aom/av1/common/warped_motion.h
third_party/aom/av1/common/x86/av1_convolve_ssse3.c
third_party/aom/av1/common/x86/av1_fwd_txfm2d_sse4.c
third_party/aom/av1/common/x86/av1_txfm1d_sse4.h
third_party/aom/av1/common/x86/convolve_2d_sse2.c
third_party/aom/av1/common/x86/highbd_convolve_2d_ssse3.c
third_party/aom/av1/common/x86/highbd_warp_plane_ssse3.c
third_party/aom/av1/common/x86/hybrid_inv_txfm_avx2.c
third_party/aom/av1/common/x86/idct_intrin_sse2.c
third_party/aom/av1/common/x86/selfguided_sse4.c
third_party/aom/av1/common/x86/warp_plane_sse2.c
third_party/aom/av1/common/x86/warp_plane_ssse3.c
third_party/aom/av1/decoder/decodeframe.c
third_party/aom/av1/decoder/decodemv.c
third_party/aom/av1/decoder/decodemv.h
third_party/aom/av1/decoder/decoder.c
third_party/aom/av1/decoder/decoder.h
third_party/aom/av1/decoder/decodetxb.c
third_party/aom/av1/decoder/decodetxb.h
third_party/aom/av1/decoder/detokenize.c
third_party/aom/av1/encoder/aq_cyclicrefresh.c
third_party/aom/av1/encoder/av1_quantize.c
third_party/aom/av1/encoder/av1_quantize.h
third_party/aom/av1/encoder/bgsprite.c
third_party/aom/av1/encoder/bgsprite.h
third_party/aom/av1/encoder/bitstream.c
third_party/aom/av1/encoder/bitstream.h
third_party/aom/av1/encoder/block.h
third_party/aom/av1/encoder/context_tree.c
third_party/aom/av1/encoder/context_tree.h
third_party/aom/av1/encoder/cost.c
third_party/aom/av1/encoder/cost.h
third_party/aom/av1/encoder/dct.c
third_party/aom/av1/encoder/encodeframe.c
third_party/aom/av1/encoder/encodemb.c
third_party/aom/av1/encoder/encodemb.h
third_party/aom/av1/encoder/encodemv.c
third_party/aom/av1/encoder/encodemv.h
third_party/aom/av1/encoder/encoder.c
third_party/aom/av1/encoder/encoder.h
third_party/aom/av1/encoder/encodetxb.c
third_party/aom/av1/encoder/encodetxb.h
third_party/aom/av1/encoder/ethread.c
third_party/aom/av1/encoder/firstpass.c
third_party/aom/av1/encoder/firstpass.h
third_party/aom/av1/encoder/global_motion.c
third_party/aom/av1/encoder/global_motion.h
third_party/aom/av1/encoder/hybrid_fwd_txfm.c
third_party/aom/av1/encoder/hybrid_fwd_txfm.h
third_party/aom/av1/encoder/mcomp.c
third_party/aom/av1/encoder/mcomp.h
third_party/aom/av1/encoder/pickcdef.c
third_party/aom/av1/encoder/picklpf.c
third_party/aom/av1/encoder/pickrst.c
third_party/aom/av1/encoder/ransac.c
third_party/aom/av1/encoder/ratectrl.c
third_party/aom/av1/encoder/ratectrl.h
third_party/aom/av1/encoder/rd.c
third_party/aom/av1/encoder/rd.h
third_party/aom/av1/encoder/rdopt.c
third_party/aom/av1/encoder/rdopt.h
third_party/aom/av1/encoder/speed_features.c
third_party/aom/av1/encoder/speed_features.h
third_party/aom/av1/encoder/temporal_filter.c
third_party/aom/av1/encoder/tokenize.c
third_party/aom/av1/encoder/x86/av1_highbd_quantize_avx2.c
third_party/aom/av1/encoder/x86/av1_highbd_quantize_sse4.c
third_party/aom/av1/encoder/x86/av1_quantize_avx2.c
third_party/aom/av1/encoder/x86/dct_intrin_sse2.c
third_party/aom/av1/encoder/x86/error_intrin_avx2.c
third_party/aom/av1/encoder/x86/highbd_fwd_txfm_sse4.c
third_party/aom/av1/encoder/x86/hybrid_fwd_txfm_avx2.c
third_party/aom/build/cmake/aom_config_defaults.cmake
third_party/aom/build/cmake/aom_configure.cmake
third_party/aom/build/cmake/aom_optimization.cmake
third_party/aom/build/cmake/compiler_flags.cmake
third_party/aom/build/cmake/exports.cmake
third_party/aom/build/cmake/exports_sources.cmake
third_party/aom/build/cmake/generate_exports.cmake
third_party/aom/build/cmake/toolchains/arm-ios-common.cmake
third_party/aom/build/cmake/toolchains/arm64-linux-gcc.cmake
third_party/aom/build/cmake/toolchains/armv7-ios.cmake
third_party/aom/build/cmake/toolchains/armv7-linux-gcc.cmake
third_party/aom/build/cmake/toolchains/armv7s-ios.cmake
third_party/aom/build/cmake/toolchains/mips32-linux-gcc.cmake
third_party/aom/build/cmake/toolchains/mips64-linux-gcc.cmake
third_party/aom/build/cmake/toolchains/x86-ios-simulator.cmake
third_party/aom/build/cmake/toolchains/x86-macos.cmake
third_party/aom/build/cmake/util.cmake
third_party/aom/build/make/gen_msvs_sln.sh
third_party/aom/build/make/gen_msvs_vcxproj.sh
third_party/aom/configure
third_party/aom/docs.cmake
third_party/aom/examples/analyzer.cc
third_party/aom/examples/inspect.c
third_party/aom/test/active_map_refresh_test.cc
third_party/aom/test/active_map_test.cc
third_party/aom/test/altref_test.cc
third_party/aom/test/ans_codec_test.cc
third_party/aom/test/aq_segment_test.cc
third_party/aom/test/arf_freq_test.cc
third_party/aom/test/av1_convolve_2d_test.cc
third_party/aom/test/av1_convolve_2d_test_util.cc
third_party/aom/test/av1_convolve_2d_test_util.h
third_party/aom/test/av1_convolve_optimz_test.cc
third_party/aom/test/av1_convolve_test.cc
third_party/aom/test/av1_ext_tile_test.cc
third_party/aom/test/av1_fht16x16_test.cc
third_party/aom/test/av1_fht16x32_test.cc
third_party/aom/test/av1_fht16x8_test.cc
third_party/aom/test/av1_fht32x16_test.cc
third_party/aom/test/av1_fht32x32_test.cc
third_party/aom/test/av1_fht4x4_test.cc
third_party/aom/test/av1_fht4x8_test.cc
third_party/aom/test/av1_fht64x64_test.cc
third_party/aom/test/av1_fht8x16_test.cc
third_party/aom/test/av1_fht8x4_test.cc
third_party/aom/test/av1_fht8x8_test.cc
third_party/aom/test/av1_fwd_txfm1d_test.cc
third_party/aom/test/av1_inv_txfm1d_test.cc
third_party/aom/test/av1_inv_txfm2d_test.cc
third_party/aom/test/av1_inv_txfm_test.cc
third_party/aom/test/block_error_test.cc
third_party/aom/test/borders_test.cc
third_party/aom/test/cpu_speed_test.cc
third_party/aom/test/datarate_test.cc
third_party/aom/test/dct16x16_test.cc
third_party/aom/test/dct32x32_test.cc
third_party/aom/test/decode_perf_test.cc
third_party/aom/test/encode_perf_test.cc
third_party/aom/test/encode_test_driver.cc
third_party/aom/test/encode_test_driver.h
third_party/aom/test/encoder_parms_get_to_decoder.cc
third_party/aom/test/end_to_end_test.cc
third_party/aom/test/error_resilience_test.cc
third_party/aom/test/ethread_test.cc
third_party/aom/test/fdct4x4_test.cc
third_party/aom/test/fdct8x8_test.cc
third_party/aom/test/frame_size_tests.cc
third_party/aom/test/hiprec_convolve_test_util.cc
third_party/aom/test/level_test.cc
third_party/aom/test/lossless_test.cc
third_party/aom/test/lpf_8_test.cc
third_party/aom/test/masked_sad_test.cc
third_party/aom/test/masked_variance_test.cc
third_party/aom/test/motion_vector_test.cc
third_party/aom/test/partial_idct_test.cc
third_party/aom/test/quantize_func_test.cc
third_party/aom/test/realtime_test.cc
third_party/aom/test/resize_test.cc
third_party/aom/test/sad_test.cc
third_party/aom/test/simd_cmp_impl.h
third_party/aom/test/subtract_test.cc
third_party/aom/test/superframe_test.cc
third_party/aom/test/test.cmake
third_party/aom/test/test.mk
third_party/aom/test/tile_independence_test.cc
third_party/aom/test/tools_common.sh
third_party/aom/test/transform_test_base.h
third_party/aom/test/user_priv_test.cc
third_party/aom/test/util.h
third_party/aom/test/variance_test.cc
third_party/aom/test/warp_filter_test.cc
third_party/aom/test/warp_filter_test_util.cc
third_party/aom/test/warp_filter_test_util.h
third_party/aom/third_party/libwebm/README.libaom
third_party/aom/third_party/libwebm/common/file_util.cc
third_party/aom/third_party/libwebm/common/hdr_util.cc
third_party/aom/third_party/libwebm/common/hdr_util.h
third_party/aom/third_party/libwebm/common/webmids.h
third_party/aom/third_party/libwebm/mkvmuxer/mkvmuxer.cc
third_party/aom/third_party/libwebm/mkvmuxer/mkvmuxer.h
third_party/aom/third_party/libwebm/mkvmuxer/mkvmuxerutil.cc
third_party/aom/third_party/libwebm/mkvmuxer/mkvmuxerutil.h
third_party/aom/third_party/libwebm/mkvmuxer/mkvwriter.cc
third_party/aom/third_party/libwebm/mkvparser/mkvparser.cc
third_party/aom/third_party/libwebm/mkvparser/mkvparser.h
third_party/aom/third_party/libwebm/mkvparser/mkvreader.cc
third_party/aom/tools.mk
third_party/aom/tools/aom_entropy_optimizer.c
third_party/aom/tools/build_inspector.sh
--- a/dom/media/platforms/agnostic/AOMDecoder.cpp
+++ b/dom/media/platforms/agnostic/AOMDecoder.cpp
@@ -222,17 +222,17 @@ AOMDecoder::IsAV1(const nsACString& aMim
 /* static */
 bool
 AOMDecoder::IsSupportedCodec(const nsAString& aCodecType)
 {
   // While AV1 is under development, we describe support
   // for a specific aom commit hash so sites can check
   // compatibility.
   auto version = NS_ConvertASCIItoUTF16("av1.experimental.");
-  version.AppendLiteral("aadbb0251996c8ebb8310567bea330ab7ae9abe4");
+  version.AppendLiteral("ebc9c9ef76c23b57b5583081416b5ee839e1be0a");
   return aCodecType.EqualsLiteral("av1") ||
          aCodecType.Equals(version);
 }
 
 /* static */
 bool
 AOMDecoder::IsKeyframe(Span<const uint8_t> aBuffer) {
   aom_codec_stream_info_t info;
--- a/media/libaom/README_MOZILLA
+++ b/media/libaom/README_MOZILLA
@@ -13,9 +13,9 @@ To update the library source and build c
 To update to a specific upstream git tag or commit, use
 
   ./mach vendor aom -r <commit>
 
 The upstream aom git repository is:
 
     https://aomedia.googlesource.com/aom
 
-The git commit ID used was aadbb0251996c8ebb8310567bea330ab7ae9abe4 (Fri Jun 02 22:24:14 2017 +0000).
+The git commit ID used was ebc9c9ef76c23b57b5583081416b5ee839e1be0a (2017-07-10T21:08:55Z).
--- a/media/libaom/config/generic/aom_config.asm
+++ b/media/libaom/config/generic/aom_config.asm
@@ -63,60 +63,63 @@
 .equ CONFIG_INSPECTION ,  0
 .equ CONFIG_DECODE_PERF_TESTS ,  0
 .equ CONFIG_ENCODE_PERF_TESTS ,  0
 .equ CONFIG_COEFFICIENT_RANGE_CHECKING ,  0
 .equ CONFIG_LOWBITDEPTH ,  1
 .equ CONFIG_HIGHBITDEPTH ,  1
 .equ CONFIG_EXPERIMENTAL ,  0
 .equ CONFIG_SIZE_LIMIT ,  1
+.equ CONFIG_COLORSPACE_HEADERS ,  0
 .equ CONFIG_FP_MB_STATS ,  0
 .equ CONFIG_CDEF ,  1
 .equ CONFIG_VAR_TX ,  1
 .equ CONFIG_RECT_TX ,  1
 .equ CONFIG_RECT_TX_EXT ,  0
 .equ CONFIG_TPL_MV ,  0
-.equ CONFIG_DUAL_FILTER ,  1
+.equ CONFIG_DUAL_FILTER ,  0
 .equ CONFIG_CONVOLVE_ROUND ,  0
 .equ CONFIG_COMPOUND_ROUND ,  0
-.equ CONFIG_EXT_TX ,  1
+.equ CONFIG_EXT_TX ,  0
 .equ CONFIG_DPCM_INTRA ,  0
 .equ CONFIG_TX64X64 ,  0
 .equ CONFIG_EXT_INTRA ,  1
 .equ CONFIG_INTRA_INTERP ,  0
 .equ CONFIG_FILTER_INTRA ,  0
 .equ CONFIG_INTRA_EDGE ,  0
 .equ CONFIG_INTRABC ,  0
-.equ CONFIG_EXT_INTER ,  1
-.equ CONFIG_INTERINTRA ,  1
-.equ CONFIG_WEDGE ,  1
-.equ CONFIG_COMPOUND_SEGMENT ,  1
-.equ CONFIG_EXT_REFS ,  1
-.equ CONFIG_GLOBAL_MOTION ,  1
+.equ CONFIG_EXT_INTER ,  0
+.equ CONFIG_INTERINTRA ,  0
+.equ CONFIG_WEDGE ,  0
+.equ CONFIG_COMPOUND_SEGMENT ,  0
+.equ CONFIG_EXT_REFS ,  0
+.equ CONFIG_SPEED_REFS ,  0
+.equ CONFIG_GF_GROUPS ,  0
+.equ CONFIG_GLOBAL_MOTION ,  0
 .equ CONFIG_NEW_QUANT ,  0
 .equ CONFIG_SUPERTX ,  0
 .equ CONFIG_ANS ,  0
 .equ CONFIG_LOOP_RESTORATION ,  0
 .equ CONFIG_EXT_PARTITION ,  0
 .equ CONFIG_EXT_PARTITION_TYPES ,  0
 .equ CONFIG_UNPOISON_PARTITION_CTX ,  0
 .equ CONFIG_EXT_TILE ,  0
 .equ CONFIG_MOTION_VAR ,  1
 .equ CONFIG_NCOBMC ,  0
-.equ CONFIG_WARPED_MOTION ,  1
+.equ CONFIG_WARPED_MOTION ,  0
 .equ CONFIG_Q_ADAPT_PROBS ,  0
 .equ CONFIG_BITSTREAM_DEBUG ,  0
 .equ CONFIG_ALT_INTRA ,  1
 .equ CONFIG_PALETTE ,  1
 .equ CONFIG_PALETTE_DELTA_ENCODING ,  0
 .equ CONFIG_RAWBITS ,  0
 .equ CONFIG_EC_SMALLMUL ,  1
 .equ CONFIG_PVQ ,  0
 .equ CONFIG_CFL ,  0
-.equ CONFIG_XIPHRC ,  0
+.equ CONFIG_XIPHRC ,  1
 .equ CONFIG_CB4X4 ,  1
 .equ CONFIG_CHROMA_2X2 ,  0
 .equ CONFIG_CHROMA_SUB8X8 ,  1
 .equ CONFIG_FRAME_SIZE ,  0
 .equ CONFIG_DELTA_Q ,  1
 .equ CONFIG_EXT_DELTA_Q ,  1
 .equ CONFIG_ADAPT_SCAN ,  0
 .equ CONFIG_FILTER_7BIT ,  1
@@ -139,12 +142,19 @@
 .equ CONFIG_LV_MAP ,  0
 .equ CONFIG_TXK_SEL ,  0
 .equ CONFIG_MV_COMPRESS ,  1
 .equ CONFIG_FRAME_SUPERRES ,  0
 .equ CONFIG_NEW_MULTISYMBOL ,  0
 .equ CONFIG_COMPOUND_SINGLEREF ,  0
 .equ CONFIG_AOM_QM ,  0
 .equ CONFIG_ONE_SIDED_COMPOUND ,  1
-.equ CONFIG_SMOOTH_HV ,  0
+.equ CONFIG_EXT_COMP_REFS ,  0
+.equ CONFIG_SMOOTH_HV ,  1
 .equ CONFIG_VAR_REFS ,  0
+.equ CONFIG_RECT_INTRA_PRED ,  0
+.equ CONFIG_LGT ,  0
+.equ CONFIG_SBL_SYMBOL ,  0
+.equ CONFIG_NCOBMC_ADAPT_WEIGHT ,  0
+.equ CONFIG_BGSPRITE ,  0
+.equ CONFIG_VAR_TX_NO_TX_MODE ,  0
 .equ CONFIG_ANALYZER ,  0
 	.section	.note.GNU-stack,"",%progbits
--- a/media/libaom/config/generic/aom_config.h
+++ b/media/libaom/config/generic/aom_config.h
@@ -4,17 +4,17 @@
 /* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License */
 /* was not distributed with this source code in the LICENSE file, you can */
 /* obtain it at www.aomedia.org/license/software. If the Alliance for Open */
 /* Media Patent License 1.0 was not distributed with this source code in the */
 /* PATENTS file, you can obtain it at www.aomedia.org/license/patent. */
 /* This file automatically generated by configure. Do not edit! */
 #ifndef AOM_CONFIG_H
 #define AOM_CONFIG_H
-#define RESTRICT
+#define RESTRICT    
 #define INLINE      inline
 #define ARCH_ARM 0
 #define ARCH_MIPS 0
 #define ARCH_X86 0
 #define ARCH_X86_64 0
 #define HAVE_NEON 0
 #define HAVE_NEON_ASM 0
 #define HAVE_MIPS32 0
@@ -73,60 +73,63 @@
 #define CONFIG_INSPECTION 0
 #define CONFIG_DECODE_PERF_TESTS 0
 #define CONFIG_ENCODE_PERF_TESTS 0
 #define CONFIG_COEFFICIENT_RANGE_CHECKING 0
 #define CONFIG_LOWBITDEPTH 1
 #define CONFIG_HIGHBITDEPTH 1
 #define CONFIG_EXPERIMENTAL 0
 #define CONFIG_SIZE_LIMIT 1
+#define CONFIG_COLORSPACE_HEADERS 0
 #define CONFIG_FP_MB_STATS 0
 #define CONFIG_CDEF 1
 #define CONFIG_VAR_TX 1
 #define CONFIG_RECT_TX 1
 #define CONFIG_RECT_TX_EXT 0
 #define CONFIG_TPL_MV 0
-#define CONFIG_DUAL_FILTER 1
+#define CONFIG_DUAL_FILTER 0
 #define CONFIG_CONVOLVE_ROUND 0
 #define CONFIG_COMPOUND_ROUND 0
-#define CONFIG_EXT_TX 1
+#define CONFIG_EXT_TX 0
 #define CONFIG_DPCM_INTRA 0
 #define CONFIG_TX64X64 0
 #define CONFIG_EXT_INTRA 1
 #define CONFIG_INTRA_INTERP 0
 #define CONFIG_FILTER_INTRA 0
 #define CONFIG_INTRA_EDGE 0
 #define CONFIG_INTRABC 0
-#define CONFIG_EXT_INTER 1
-#define CONFIG_INTERINTRA 1
-#define CONFIG_WEDGE 1
-#define CONFIG_COMPOUND_SEGMENT 1
-#define CONFIG_EXT_REFS 1
-#define CONFIG_GLOBAL_MOTION 1
+#define CONFIG_EXT_INTER 0
+#define CONFIG_INTERINTRA 0
+#define CONFIG_WEDGE 0
+#define CONFIG_COMPOUND_SEGMENT 0
+#define CONFIG_EXT_REFS 0
+#define CONFIG_SPEED_REFS 0
+#define CONFIG_GF_GROUPS 0
+#define CONFIG_GLOBAL_MOTION 0
 #define CONFIG_NEW_QUANT 0
 #define CONFIG_SUPERTX 0
 #define CONFIG_ANS 0
 #define CONFIG_LOOP_RESTORATION 0
 #define CONFIG_EXT_PARTITION 0
 #define CONFIG_EXT_PARTITION_TYPES 0
 #define CONFIG_UNPOISON_PARTITION_CTX 0
 #define CONFIG_EXT_TILE 0
 #define CONFIG_MOTION_VAR 1
 #define CONFIG_NCOBMC 0
-#define CONFIG_WARPED_MOTION 1
+#define CONFIG_WARPED_MOTION 0
 #define CONFIG_Q_ADAPT_PROBS 0
 #define CONFIG_BITSTREAM_DEBUG 0
 #define CONFIG_ALT_INTRA 1
 #define CONFIG_PALETTE 1
 #define CONFIG_PALETTE_DELTA_ENCODING 0
 #define CONFIG_RAWBITS 0
 #define CONFIG_EC_SMALLMUL 1
 #define CONFIG_PVQ 0
 #define CONFIG_CFL 0
-#define CONFIG_XIPHRC 0
+#define CONFIG_XIPHRC 1
 #define CONFIG_CB4X4 1
 #define CONFIG_CHROMA_2X2 0
 #define CONFIG_CHROMA_SUB8X8 1
 #define CONFIG_FRAME_SIZE 0
 #define CONFIG_DELTA_Q 1
 #define CONFIG_EXT_DELTA_Q 1
 #define CONFIG_ADAPT_SCAN 0
 #define CONFIG_FILTER_7BIT 1
@@ -149,14 +152,21 @@
 #define CONFIG_LV_MAP 0
 #define CONFIG_TXK_SEL 0
 #define CONFIG_MV_COMPRESS 1
 #define CONFIG_FRAME_SUPERRES 0
 #define CONFIG_NEW_MULTISYMBOL 0
 #define CONFIG_COMPOUND_SINGLEREF 0
 #define CONFIG_AOM_QM 0
 #define CONFIG_ONE_SIDED_COMPOUND 1
-#define CONFIG_SMOOTH_HV 0
+#define CONFIG_EXT_COMP_REFS 0
+#define CONFIG_SMOOTH_HV 1
 #define CONFIG_VAR_REFS 0
+#define CONFIG_RECT_INTRA_PRED 0
+#define CONFIG_LGT 0
+#define CONFIG_SBL_SYMBOL 0
+#define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+#define CONFIG_BGSPRITE 0
+#define CONFIG_VAR_TX_NO_TX_MODE 0
 #define CONFIG_ANALYZER 0
 #define DECODE_WIDTH_LIMIT 8192
 #define DECODE_HEIGHT_LIMIT 4608
 #endif /* AOM_CONFIG_H */
--- a/media/libaom/config/generic/aom_dsp_rtcd.h
+++ b/media/libaom/config/generic/aom_dsp_rtcd.h
@@ -27,304 +27,466 @@ void aom_blend_a64_mask_c(uint8_t *dst, 
 #define aom_blend_a64_mask aom_blend_a64_mask_c
 
 void aom_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 #define aom_blend_a64_vmask aom_blend_a64_vmask_c
 
 void aom_comp_avg_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
 #define aom_comp_avg_pred aom_comp_avg_pred_c
 
-void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
+void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 #define aom_comp_avg_upsampled_pred aom_comp_avg_upsampled_pred_c
 
-void aom_comp_mask_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_pred aom_comp_mask_pred_c
-
-void aom_comp_mask_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_upsampled_pred aom_comp_mask_upsampled_pred_c
-
 void aom_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve8 aom_convolve8_c
 
 void aom_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve8_avg aom_convolve8_avg_c
 
 void aom_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve8_avg_horiz aom_convolve8_avg_horiz_c
 
+void aom_convolve8_avg_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_horiz_scale aom_convolve8_avg_horiz_scale_c
+
+void aom_convolve8_avg_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_scale aom_convolve8_avg_scale_c
+
 void aom_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve8_avg_vert aom_convolve8_avg_vert_c
 
+void aom_convolve8_avg_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_vert_scale aom_convolve8_avg_vert_scale_c
+
 void aom_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve8_horiz aom_convolve8_horiz_c
 
+void aom_convolve8_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_horiz_scale aom_convolve8_horiz_scale_c
+
+void aom_convolve8_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_scale aom_convolve8_scale_c
+
 void aom_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve8_vert aom_convolve8_vert_c
 
+void aom_convolve8_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_vert_scale aom_convolve8_vert_scale_c
+
 void aom_convolve_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve_avg aom_convolve_avg_c
 
 void aom_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve_copy aom_convolve_copy_c
 
 void aom_d117_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_16x16 aom_d117_predictor_16x16_c
 
+void aom_d117_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x32 aom_d117_predictor_16x32_c
+
+void aom_d117_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x8 aom_d117_predictor_16x8_c
+
 void aom_d117_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_2x2 aom_d117_predictor_2x2_c
 
+void aom_d117_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_32x16 aom_d117_predictor_32x16_c
+
 void aom_d117_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_32x32 aom_d117_predictor_32x32_c
 
 void aom_d117_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_4x4 aom_d117_predictor_4x4_c
 
+void aom_d117_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_4x8 aom_d117_predictor_4x8_c
+
+void aom_d117_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x16 aom_d117_predictor_8x16_c
+
+void aom_d117_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x4 aom_d117_predictor_8x4_c
+
 void aom_d117_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_8x8 aom_d117_predictor_8x8_c
 
 void aom_d135_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_16x16 aom_d135_predictor_16x16_c
 
+void aom_d135_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x32 aom_d135_predictor_16x32_c
+
+void aom_d135_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x8 aom_d135_predictor_16x8_c
+
 void aom_d135_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_2x2 aom_d135_predictor_2x2_c
 
+void aom_d135_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_32x16 aom_d135_predictor_32x16_c
+
 void aom_d135_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_32x32 aom_d135_predictor_32x32_c
 
 void aom_d135_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_4x4 aom_d135_predictor_4x4_c
 
+void aom_d135_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_4x8 aom_d135_predictor_4x8_c
+
+void aom_d135_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x16 aom_d135_predictor_8x16_c
+
+void aom_d135_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x4 aom_d135_predictor_8x4_c
+
 void aom_d135_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_8x8 aom_d135_predictor_8x8_c
 
 void aom_d153_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_16x16 aom_d153_predictor_16x16_c
 
+void aom_d153_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x32 aom_d153_predictor_16x32_c
+
+void aom_d153_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x8 aom_d153_predictor_16x8_c
+
 void aom_d153_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_2x2 aom_d153_predictor_2x2_c
 
+void aom_d153_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_32x16 aom_d153_predictor_32x16_c
+
 void aom_d153_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_32x32 aom_d153_predictor_32x32_c
 
 void aom_d153_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_4x4 aom_d153_predictor_4x4_c
 
+void aom_d153_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_4x8 aom_d153_predictor_4x8_c
+
+void aom_d153_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x16 aom_d153_predictor_8x16_c
+
+void aom_d153_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x4 aom_d153_predictor_8x4_c
+
 void aom_d153_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_8x8 aom_d153_predictor_8x8_c
 
 void aom_d207e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_16x16 aom_d207e_predictor_16x16_c
 
+void aom_d207e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x32 aom_d207e_predictor_16x32_c
+
+void aom_d207e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x8 aom_d207e_predictor_16x8_c
+
 void aom_d207e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_2x2 aom_d207e_predictor_2x2_c
 
+void aom_d207e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_32x16 aom_d207e_predictor_32x16_c
+
 void aom_d207e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_32x32 aom_d207e_predictor_32x32_c
 
 void aom_d207e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_4x4 aom_d207e_predictor_4x4_c
 
+void aom_d207e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_4x8 aom_d207e_predictor_4x8_c
+
+void aom_d207e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x16 aom_d207e_predictor_8x16_c
+
+void aom_d207e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x4 aom_d207e_predictor_8x4_c
+
 void aom_d207e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_8x8 aom_d207e_predictor_8x8_c
 
 void aom_d45e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_16x16 aom_d45e_predictor_16x16_c
 
+void aom_d45e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x32 aom_d45e_predictor_16x32_c
+
+void aom_d45e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x8 aom_d45e_predictor_16x8_c
+
 void aom_d45e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_2x2 aom_d45e_predictor_2x2_c
 
+void aom_d45e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_32x16 aom_d45e_predictor_32x16_c
+
 void aom_d45e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_32x32 aom_d45e_predictor_32x32_c
 
 void aom_d45e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_4x4 aom_d45e_predictor_4x4_c
 
+void aom_d45e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_4x8 aom_d45e_predictor_4x8_c
+
+void aom_d45e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x16 aom_d45e_predictor_8x16_c
+
+void aom_d45e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x4 aom_d45e_predictor_8x4_c
+
 void aom_d45e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_8x8 aom_d45e_predictor_8x8_c
 
 void aom_d63e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_16x16 aom_d63e_predictor_16x16_c
 
+void aom_d63e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x32 aom_d63e_predictor_16x32_c
+
+void aom_d63e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x8 aom_d63e_predictor_16x8_c
+
 void aom_d63e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_2x2 aom_d63e_predictor_2x2_c
 
+void aom_d63e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_32x16 aom_d63e_predictor_32x16_c
+
 void aom_d63e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_32x32 aom_d63e_predictor_32x32_c
 
 void aom_d63e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_4x4 aom_d63e_predictor_4x4_c
 
+void aom_d63e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_4x8 aom_d63e_predictor_4x8_c
+
+void aom_d63e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x16 aom_d63e_predictor_8x16_c
+
+void aom_d63e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x4 aom_d63e_predictor_8x4_c
+
 void aom_d63e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_8x8 aom_d63e_predictor_8x8_c
 
 void aom_dc_128_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_16x16 aom_dc_128_predictor_16x16_c
 
+void aom_dc_128_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x32 aom_dc_128_predictor_16x32_c
+
+void aom_dc_128_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x8 aom_dc_128_predictor_16x8_c
+
 void aom_dc_128_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_2x2 aom_dc_128_predictor_2x2_c
 
+void aom_dc_128_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_32x16 aom_dc_128_predictor_32x16_c
+
 void aom_dc_128_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_32x32 aom_dc_128_predictor_32x32_c
 
 void aom_dc_128_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_4x4 aom_dc_128_predictor_4x4_c
 
+void aom_dc_128_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_4x8 aom_dc_128_predictor_4x8_c
+
+void aom_dc_128_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x16 aom_dc_128_predictor_8x16_c
+
+void aom_dc_128_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x4 aom_dc_128_predictor_8x4_c
+
 void aom_dc_128_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_8x8 aom_dc_128_predictor_8x8_c
 
 void aom_dc_left_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_16x16 aom_dc_left_predictor_16x16_c
 
+void aom_dc_left_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x32 aom_dc_left_predictor_16x32_c
+
+void aom_dc_left_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x8 aom_dc_left_predictor_16x8_c
+
 void aom_dc_left_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_2x2 aom_dc_left_predictor_2x2_c
 
+void aom_dc_left_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_32x16 aom_dc_left_predictor_32x16_c
+
 void aom_dc_left_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_32x32 aom_dc_left_predictor_32x32_c
 
 void aom_dc_left_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_4x4 aom_dc_left_predictor_4x4_c
 
+void aom_dc_left_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_4x8 aom_dc_left_predictor_4x8_c
+
+void aom_dc_left_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x16 aom_dc_left_predictor_8x16_c
+
+void aom_dc_left_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x4 aom_dc_left_predictor_8x4_c
+
 void aom_dc_left_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_8x8 aom_dc_left_predictor_8x8_c
 
 void aom_dc_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_16x16 aom_dc_predictor_16x16_c
 
+void aom_dc_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x32 aom_dc_predictor_16x32_c
+
+void aom_dc_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x8 aom_dc_predictor_16x8_c
+
 void aom_dc_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_2x2 aom_dc_predictor_2x2_c
 
+void aom_dc_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_32x16 aom_dc_predictor_32x16_c
+
 void aom_dc_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_32x32 aom_dc_predictor_32x32_c
 
 void aom_dc_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_4x4 aom_dc_predictor_4x4_c
 
+void aom_dc_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_4x8 aom_dc_predictor_4x8_c
+
+void aom_dc_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x16 aom_dc_predictor_8x16_c
+
+void aom_dc_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x4 aom_dc_predictor_8x4_c
+
 void aom_dc_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_8x8 aom_dc_predictor_8x8_c
 
 void aom_dc_top_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_16x16 aom_dc_top_predictor_16x16_c
 
+void aom_dc_top_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x32 aom_dc_top_predictor_16x32_c
+
+void aom_dc_top_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x8 aom_dc_top_predictor_16x8_c
+
 void aom_dc_top_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_2x2 aom_dc_top_predictor_2x2_c
 
+void aom_dc_top_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_32x16 aom_dc_top_predictor_32x16_c
+
 void aom_dc_top_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_32x32 aom_dc_top_predictor_32x32_c
 
 void aom_dc_top_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_4x4 aom_dc_top_predictor_4x4_c
 
+void aom_dc_top_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_4x8 aom_dc_top_predictor_4x8_c
+
+void aom_dc_top_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x16 aom_dc_top_predictor_8x16_c
+
+void aom_dc_top_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x4 aom_dc_top_predictor_8x4_c
+
 void aom_dc_top_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_8x8 aom_dc_top_predictor_8x8_c
 
 void aom_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct16x16 aom_fdct16x16_c
 
-void aom_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_fdct16x16_1 aom_fdct16x16_1_c
-
 void aom_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct32x32 aom_fdct32x32_c
 
-void aom_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_fdct32x32_1 aom_fdct32x32_1_c
-
 void aom_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct32x32_rd aom_fdct32x32_rd_c
 
 void aom_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct4x4 aom_fdct4x4_c
 
 void aom_fdct4x4_1_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct4x4_1 aom_fdct4x4_1_c
 
 void aom_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct8x8 aom_fdct8x8_c
 
-void aom_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_fdct8x8_1 aom_fdct8x8_1_c
-
 void aom_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_get16x16var aom_get16x16var_c
 
 unsigned int aom_get4x4sse_cs_c(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int ref_stride);
 #define aom_get4x4sse_cs aom_get4x4sse_cs_c
 
 void aom_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_get8x8var aom_get8x8var_c
 
 unsigned int aom_get_mb_ss_c(const int16_t *);
 #define aom_get_mb_ss aom_get_mb_ss_c
 
 void aom_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_16x16 aom_h_predictor_16x16_c
 
+void aom_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x32 aom_h_predictor_16x32_c
+
+void aom_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x8 aom_h_predictor_16x8_c
+
 void aom_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_2x2 aom_h_predictor_2x2_c
 
+void aom_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_32x16 aom_h_predictor_32x16_c
+
 void aom_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_32x32 aom_h_predictor_32x32_c
 
 void aom_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_4x4 aom_h_predictor_4x4_c
 
+void aom_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_4x8 aom_h_predictor_4x8_c
+
+void aom_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x16 aom_h_predictor_8x16_c
+
+void aom_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x4 aom_h_predictor_8x4_c
+
 void aom_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_8x8 aom_h_predictor_8x8_c
 
 void aom_hadamard_16x16_c(const int16_t *src_diff, int src_stride, int16_t *coeff);
 #define aom_hadamard_16x16 aom_hadamard_16x16_c
 
 void aom_hadamard_8x8_c(const int16_t *src_diff, int src_stride, int16_t *coeff);
 #define aom_hadamard_8x8 aom_hadamard_8x8_c
 
 void aom_highbd_10_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get16x16var aom_highbd_10_get16x16var_c
 
 void aom_highbd_10_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get8x8var aom_highbd_10_get8x8var_c
 
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance16x16 aom_highbd_10_masked_sub_pixel_variance16x16_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance16x32 aom_highbd_10_masked_sub_pixel_variance16x32_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance16x8 aom_highbd_10_masked_sub_pixel_variance16x8_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance32x16 aom_highbd_10_masked_sub_pixel_variance32x16_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance32x32 aom_highbd_10_masked_sub_pixel_variance32x32_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance32x64 aom_highbd_10_masked_sub_pixel_variance32x64_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance4x4 aom_highbd_10_masked_sub_pixel_variance4x4_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance4x8 aom_highbd_10_masked_sub_pixel_variance4x8_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance64x32 aom_highbd_10_masked_sub_pixel_variance64x32_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance64x64 aom_highbd_10_masked_sub_pixel_variance64x64_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance8x16 aom_highbd_10_masked_sub_pixel_variance8x16_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance8x4 aom_highbd_10_masked_sub_pixel_variance8x4_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance8x8 aom_highbd_10_masked_sub_pixel_variance8x8_c
-
 unsigned int aom_highbd_10_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse16x16 aom_highbd_10_mse16x16_c
 
 unsigned int aom_highbd_10_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse16x8 aom_highbd_10_mse16x8_c
 
 unsigned int aom_highbd_10_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse8x16 aom_highbd_10_mse8x16_c
@@ -537,55 +699,16 @@ unsigned int aom_highbd_10_variance8x8_c
 #define aom_highbd_10_variance8x8 aom_highbd_10_variance8x8_c
 
 void aom_highbd_12_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get16x16var aom_highbd_12_get16x16var_c
 
 void aom_highbd_12_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get8x8var aom_highbd_12_get8x8var_c
 
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance16x16 aom_highbd_12_masked_sub_pixel_variance16x16_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance16x32 aom_highbd_12_masked_sub_pixel_variance16x32_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance16x8 aom_highbd_12_masked_sub_pixel_variance16x8_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance32x16 aom_highbd_12_masked_sub_pixel_variance32x16_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance32x32 aom_highbd_12_masked_sub_pixel_variance32x32_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance32x64 aom_highbd_12_masked_sub_pixel_variance32x64_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance4x4 aom_highbd_12_masked_sub_pixel_variance4x4_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance4x8 aom_highbd_12_masked_sub_pixel_variance4x8_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance64x32 aom_highbd_12_masked_sub_pixel_variance64x32_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance64x64 aom_highbd_12_masked_sub_pixel_variance64x64_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance8x16 aom_highbd_12_masked_sub_pixel_variance8x16_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance8x4 aom_highbd_12_masked_sub_pixel_variance8x4_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance8x8 aom_highbd_12_masked_sub_pixel_variance8x8_c
-
 unsigned int aom_highbd_12_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse16x16 aom_highbd_12_mse16x16_c
 
 unsigned int aom_highbd_12_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse16x8 aom_highbd_12_mse16x8_c
 
 unsigned int aom_highbd_12_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse8x16 aom_highbd_12_mse8x16_c
@@ -798,55 +921,16 @@ unsigned int aom_highbd_12_variance8x8_c
 #define aom_highbd_12_variance8x8 aom_highbd_12_variance8x8_c
 
 void aom_highbd_8_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get16x16var aom_highbd_8_get16x16var_c
 
 void aom_highbd_8_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get8x8var aom_highbd_8_get8x8var_c
 
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance16x16 aom_highbd_8_masked_sub_pixel_variance16x16_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance16x32 aom_highbd_8_masked_sub_pixel_variance16x32_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance16x8 aom_highbd_8_masked_sub_pixel_variance16x8_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance32x16 aom_highbd_8_masked_sub_pixel_variance32x16_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance32x32 aom_highbd_8_masked_sub_pixel_variance32x32_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance32x64 aom_highbd_8_masked_sub_pixel_variance32x64_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance4x4 aom_highbd_8_masked_sub_pixel_variance4x4_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance4x8 aom_highbd_8_masked_sub_pixel_variance4x8_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance64x32 aom_highbd_8_masked_sub_pixel_variance64x32_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance64x64 aom_highbd_8_masked_sub_pixel_variance64x64_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance8x16 aom_highbd_8_masked_sub_pixel_variance8x16_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance8x4 aom_highbd_8_masked_sub_pixel_variance8x4_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance8x8 aom_highbd_8_masked_sub_pixel_variance8x8_c
-
 unsigned int aom_highbd_8_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse16x16 aom_highbd_8_mse16x16_c
 
 unsigned int aom_highbd_8_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse16x8 aom_highbd_8_mse16x8_c
 
 unsigned int aom_highbd_8_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse8x16 aom_highbd_8_mse8x16_c
@@ -987,25 +1071,19 @@ void aom_highbd_blend_a64_mask_c(uint8_t
 #define aom_highbd_blend_a64_mask aom_highbd_blend_a64_mask_c
 
 void aom_highbd_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 #define aom_highbd_blend_a64_vmask aom_highbd_blend_a64_vmask_c
 
 void aom_highbd_comp_avg_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
 #define aom_highbd_comp_avg_pred aom_highbd_comp_avg_pred_c
 
-void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
+void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 #define aom_highbd_comp_avg_upsampled_pred aom_highbd_comp_avg_upsampled_pred_c
 
-void aom_highbd_comp_mask_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_pred aom_highbd_comp_mask_pred_c
-
-void aom_highbd_comp_mask_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_upsampled_pred aom_highbd_comp_mask_upsampled_pred_c
-
 void aom_highbd_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 #define aom_highbd_convolve8 aom_highbd_convolve8_c
 
 void aom_highbd_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 #define aom_highbd_convolve8_avg aom_highbd_convolve8_avg_c
 
 void aom_highbd_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 #define aom_highbd_convolve8_avg_horiz aom_highbd_convolve8_avg_horiz_c
@@ -1023,223 +1101,391 @@ void aom_highbd_convolve_avg_c(const uin
 #define aom_highbd_convolve_avg aom_highbd_convolve_avg_c
 
 void aom_highbd_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 #define aom_highbd_convolve_copy aom_highbd_convolve_copy_c
 
 void aom_highbd_d117_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_16x16 aom_highbd_d117_predictor_16x16_c
 
+void aom_highbd_d117_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x32 aom_highbd_d117_predictor_16x32_c
+
+void aom_highbd_d117_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x8 aom_highbd_d117_predictor_16x8_c
+
 void aom_highbd_d117_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_2x2 aom_highbd_d117_predictor_2x2_c
 
+void aom_highbd_d117_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_32x16 aom_highbd_d117_predictor_32x16_c
+
 void aom_highbd_d117_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_32x32 aom_highbd_d117_predictor_32x32_c
 
 void aom_highbd_d117_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_4x4 aom_highbd_d117_predictor_4x4_c
 
+void aom_highbd_d117_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_4x8 aom_highbd_d117_predictor_4x8_c
+
+void aom_highbd_d117_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x16 aom_highbd_d117_predictor_8x16_c
+
+void aom_highbd_d117_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x4 aom_highbd_d117_predictor_8x4_c
+
 void aom_highbd_d117_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_8x8 aom_highbd_d117_predictor_8x8_c
 
 void aom_highbd_d135_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_16x16 aom_highbd_d135_predictor_16x16_c
 
+void aom_highbd_d135_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x32 aom_highbd_d135_predictor_16x32_c
+
+void aom_highbd_d135_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x8 aom_highbd_d135_predictor_16x8_c
+
 void aom_highbd_d135_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_2x2 aom_highbd_d135_predictor_2x2_c
 
+void aom_highbd_d135_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_32x16 aom_highbd_d135_predictor_32x16_c
+
 void aom_highbd_d135_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_32x32 aom_highbd_d135_predictor_32x32_c
 
 void aom_highbd_d135_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_4x4 aom_highbd_d135_predictor_4x4_c
 
+void aom_highbd_d135_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_4x8 aom_highbd_d135_predictor_4x8_c
+
+void aom_highbd_d135_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x16 aom_highbd_d135_predictor_8x16_c
+
+void aom_highbd_d135_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x4 aom_highbd_d135_predictor_8x4_c
+
 void aom_highbd_d135_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_8x8 aom_highbd_d135_predictor_8x8_c
 
 void aom_highbd_d153_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_16x16 aom_highbd_d153_predictor_16x16_c
 
+void aom_highbd_d153_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x32 aom_highbd_d153_predictor_16x32_c
+
+void aom_highbd_d153_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x8 aom_highbd_d153_predictor_16x8_c
+
 void aom_highbd_d153_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_2x2 aom_highbd_d153_predictor_2x2_c
 
+void aom_highbd_d153_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_32x16 aom_highbd_d153_predictor_32x16_c
+
 void aom_highbd_d153_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_32x32 aom_highbd_d153_predictor_32x32_c
 
 void aom_highbd_d153_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_4x4 aom_highbd_d153_predictor_4x4_c
 
+void aom_highbd_d153_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_4x8 aom_highbd_d153_predictor_4x8_c
+
+void aom_highbd_d153_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x16 aom_highbd_d153_predictor_8x16_c
+
+void aom_highbd_d153_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x4 aom_highbd_d153_predictor_8x4_c
+
 void aom_highbd_d153_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_8x8 aom_highbd_d153_predictor_8x8_c
 
 void aom_highbd_d207e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_16x16 aom_highbd_d207e_predictor_16x16_c
 
+void aom_highbd_d207e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x32 aom_highbd_d207e_predictor_16x32_c
+
+void aom_highbd_d207e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x8 aom_highbd_d207e_predictor_16x8_c
+
 void aom_highbd_d207e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_2x2 aom_highbd_d207e_predictor_2x2_c
 
+void aom_highbd_d207e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_32x16 aom_highbd_d207e_predictor_32x16_c
+
 void aom_highbd_d207e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_32x32 aom_highbd_d207e_predictor_32x32_c
 
 void aom_highbd_d207e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_4x4 aom_highbd_d207e_predictor_4x4_c
 
+void aom_highbd_d207e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_4x8 aom_highbd_d207e_predictor_4x8_c
+
+void aom_highbd_d207e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x16 aom_highbd_d207e_predictor_8x16_c
+
+void aom_highbd_d207e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x4 aom_highbd_d207e_predictor_8x4_c
+
 void aom_highbd_d207e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_8x8 aom_highbd_d207e_predictor_8x8_c
 
 void aom_highbd_d45e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_16x16 aom_highbd_d45e_predictor_16x16_c
 
+void aom_highbd_d45e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x32 aom_highbd_d45e_predictor_16x32_c
+
+void aom_highbd_d45e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x8 aom_highbd_d45e_predictor_16x8_c
+
 void aom_highbd_d45e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_2x2 aom_highbd_d45e_predictor_2x2_c
 
+void aom_highbd_d45e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_32x16 aom_highbd_d45e_predictor_32x16_c
+
 void aom_highbd_d45e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_32x32 aom_highbd_d45e_predictor_32x32_c
 
 void aom_highbd_d45e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_4x4 aom_highbd_d45e_predictor_4x4_c
 
+void aom_highbd_d45e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_4x8 aom_highbd_d45e_predictor_4x8_c
+
+void aom_highbd_d45e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x16 aom_highbd_d45e_predictor_8x16_c
+
+void aom_highbd_d45e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x4 aom_highbd_d45e_predictor_8x4_c
+
 void aom_highbd_d45e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_8x8 aom_highbd_d45e_predictor_8x8_c
 
 void aom_highbd_d63e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_16x16 aom_highbd_d63e_predictor_16x16_c
 
+void aom_highbd_d63e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x32 aom_highbd_d63e_predictor_16x32_c
+
+void aom_highbd_d63e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x8 aom_highbd_d63e_predictor_16x8_c
+
 void aom_highbd_d63e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_2x2 aom_highbd_d63e_predictor_2x2_c
 
+void aom_highbd_d63e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_32x16 aom_highbd_d63e_predictor_32x16_c
+
 void aom_highbd_d63e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_32x32 aom_highbd_d63e_predictor_32x32_c
 
 void aom_highbd_d63e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_4x4 aom_highbd_d63e_predictor_4x4_c
 
+void aom_highbd_d63e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_4x8 aom_highbd_d63e_predictor_4x8_c
+
+void aom_highbd_d63e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x16 aom_highbd_d63e_predictor_8x16_c
+
+void aom_highbd_d63e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x4 aom_highbd_d63e_predictor_8x4_c
+
 void aom_highbd_d63e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_8x8 aom_highbd_d63e_predictor_8x8_c
 
 void aom_highbd_dc_128_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_16x16 aom_highbd_dc_128_predictor_16x16_c
 
+void aom_highbd_dc_128_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x32 aom_highbd_dc_128_predictor_16x32_c
+
+void aom_highbd_dc_128_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x8 aom_highbd_dc_128_predictor_16x8_c
+
 void aom_highbd_dc_128_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_2x2 aom_highbd_dc_128_predictor_2x2_c
 
+void aom_highbd_dc_128_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_32x16 aom_highbd_dc_128_predictor_32x16_c
+
 void aom_highbd_dc_128_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_32x32 aom_highbd_dc_128_predictor_32x32_c
 
 void aom_highbd_dc_128_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_4x4 aom_highbd_dc_128_predictor_4x4_c
 
+void aom_highbd_dc_128_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_4x8 aom_highbd_dc_128_predictor_4x8_c
+
+void aom_highbd_dc_128_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x16 aom_highbd_dc_128_predictor_8x16_c
+
+void aom_highbd_dc_128_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x4 aom_highbd_dc_128_predictor_8x4_c
+
 void aom_highbd_dc_128_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_8x8 aom_highbd_dc_128_predictor_8x8_c
 
 void aom_highbd_dc_left_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_16x16 aom_highbd_dc_left_predictor_16x16_c
 
+void aom_highbd_dc_left_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x32 aom_highbd_dc_left_predictor_16x32_c
+
+void aom_highbd_dc_left_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x8 aom_highbd_dc_left_predictor_16x8_c
+
 void aom_highbd_dc_left_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_2x2 aom_highbd_dc_left_predictor_2x2_c
 
+void aom_highbd_dc_left_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_32x16 aom_highbd_dc_left_predictor_32x16_c
+
 void aom_highbd_dc_left_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_32x32 aom_highbd_dc_left_predictor_32x32_c
 
 void aom_highbd_dc_left_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_4x4 aom_highbd_dc_left_predictor_4x4_c
 
+void aom_highbd_dc_left_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_4x8 aom_highbd_dc_left_predictor_4x8_c
+
+void aom_highbd_dc_left_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x16 aom_highbd_dc_left_predictor_8x16_c
+
+void aom_highbd_dc_left_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x4 aom_highbd_dc_left_predictor_8x4_c
+
 void aom_highbd_dc_left_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_8x8 aom_highbd_dc_left_predictor_8x8_c
 
 void aom_highbd_dc_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_16x16 aom_highbd_dc_predictor_16x16_c
 
+void aom_highbd_dc_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x32 aom_highbd_dc_predictor_16x32_c
+
+void aom_highbd_dc_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x8 aom_highbd_dc_predictor_16x8_c
+
 void aom_highbd_dc_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_2x2 aom_highbd_dc_predictor_2x2_c
 
+void aom_highbd_dc_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_32x16 aom_highbd_dc_predictor_32x16_c
+
 void aom_highbd_dc_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_32x32 aom_highbd_dc_predictor_32x32_c
 
 void aom_highbd_dc_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_4x4 aom_highbd_dc_predictor_4x4_c
 
+void aom_highbd_dc_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_4x8 aom_highbd_dc_predictor_4x8_c
+
+void aom_highbd_dc_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x16 aom_highbd_dc_predictor_8x16_c
+
+void aom_highbd_dc_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x4 aom_highbd_dc_predictor_8x4_c
+
 void aom_highbd_dc_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_8x8 aom_highbd_dc_predictor_8x8_c
 
 void aom_highbd_dc_top_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_16x16 aom_highbd_dc_top_predictor_16x16_c
 
+void aom_highbd_dc_top_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x32 aom_highbd_dc_top_predictor_16x32_c
+
+void aom_highbd_dc_top_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x8 aom_highbd_dc_top_predictor_16x8_c
+
 void aom_highbd_dc_top_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_2x2 aom_highbd_dc_top_predictor_2x2_c
 
+void aom_highbd_dc_top_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_32x16 aom_highbd_dc_top_predictor_32x16_c
+
 void aom_highbd_dc_top_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_32x32 aom_highbd_dc_top_predictor_32x32_c
 
 void aom_highbd_dc_top_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_4x4 aom_highbd_dc_top_predictor_4x4_c
 
+void aom_highbd_dc_top_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_4x8 aom_highbd_dc_top_predictor_4x8_c
+
+void aom_highbd_dc_top_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x16 aom_highbd_dc_top_predictor_8x16_c
+
+void aom_highbd_dc_top_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x4 aom_highbd_dc_top_predictor_8x4_c
+
 void aom_highbd_dc_top_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_8x8 aom_highbd_dc_top_predictor_8x8_c
 
 void aom_highbd_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct16x16 aom_highbd_fdct16x16_c
 
-void aom_highbd_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct16x16_1 aom_highbd_fdct16x16_1_c
-
 void aom_highbd_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct32x32 aom_highbd_fdct32x32_c
 
-void aom_highbd_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct32x32_1 aom_highbd_fdct32x32_1_c
-
 void aom_highbd_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct32x32_rd aom_highbd_fdct32x32_rd_c
 
 void aom_highbd_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct4x4 aom_highbd_fdct4x4_c
 
 void aom_highbd_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct8x8 aom_highbd_fdct8x8_c
 
-void aom_highbd_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct8x8_1 aom_highbd_fdct8x8_1_c
-
 void aom_highbd_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_16x16 aom_highbd_h_predictor_16x16_c
 
+void aom_highbd_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x32 aom_highbd_h_predictor_16x32_c
+
+void aom_highbd_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x8 aom_highbd_h_predictor_16x8_c
+
 void aom_highbd_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_2x2 aom_highbd_h_predictor_2x2_c
 
+void aom_highbd_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_32x16 aom_highbd_h_predictor_32x16_c
+
 void aom_highbd_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_32x32 aom_highbd_h_predictor_32x32_c
 
 void aom_highbd_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_4x4 aom_highbd_h_predictor_4x4_c
 
+void aom_highbd_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_4x8 aom_highbd_h_predictor_4x8_c
+
+void aom_highbd_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x16 aom_highbd_h_predictor_8x16_c
+
+void aom_highbd_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x4 aom_highbd_h_predictor_8x4_c
+
 void aom_highbd_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_8x8 aom_highbd_h_predictor_8x8_c
 
-void aom_highbd_idct16x16_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct16x16_1_add aom_highbd_idct16x16_1_add_c
-
-void aom_highbd_idct32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1024_add aom_highbd_idct32x32_1024_add_c
-
-void aom_highbd_idct32x32_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1_add aom_highbd_idct32x32_1_add_c
-
-void aom_highbd_idct32x32_34_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_34_add aom_highbd_idct32x32_34_add_c
-
-void aom_highbd_idct4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct4x4_16_add aom_highbd_idct4x4_16_add_c
-
-void aom_highbd_idct4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct4x4_1_add aom_highbd_idct4x4_1_add_c
-
-void aom_highbd_idct8x8_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct8x8_1_add aom_highbd_idct8x8_1_add_c
-
 void aom_highbd_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_16_add aom_highbd_iwht4x4_16_add_c
 
 void aom_highbd_iwht4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_1_add aom_highbd_iwht4x4_1_add_c
 
 void aom_highbd_lpf_horizontal_4_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 #define aom_highbd_lpf_horizontal_4 aom_highbd_lpf_horizontal_4_c
@@ -1272,55 +1518,16 @@ void aom_highbd_lpf_vertical_4_dual_c(ui
 #define aom_highbd_lpf_vertical_4_dual aom_highbd_lpf_vertical_4_dual_c
 
 void aom_highbd_lpf_vertical_8_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 #define aom_highbd_lpf_vertical_8 aom_highbd_lpf_vertical_8_c
 
 void aom_highbd_lpf_vertical_8_dual_c(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 #define aom_highbd_lpf_vertical_8_dual aom_highbd_lpf_vertical_8_dual_c
 
-unsigned int aom_highbd_masked_sad16x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad16x16 aom_highbd_masked_sad16x16_c
-
-unsigned int aom_highbd_masked_sad16x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad16x32 aom_highbd_masked_sad16x32_c
-
-unsigned int aom_highbd_masked_sad16x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad16x8 aom_highbd_masked_sad16x8_c
-
-unsigned int aom_highbd_masked_sad32x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad32x16 aom_highbd_masked_sad32x16_c
-
-unsigned int aom_highbd_masked_sad32x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad32x32 aom_highbd_masked_sad32x32_c
-
-unsigned int aom_highbd_masked_sad32x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad32x64 aom_highbd_masked_sad32x64_c
-
-unsigned int aom_highbd_masked_sad4x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad4x4 aom_highbd_masked_sad4x4_c
-
-unsigned int aom_highbd_masked_sad4x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad4x8 aom_highbd_masked_sad4x8_c
-
-unsigned int aom_highbd_masked_sad64x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad64x32 aom_highbd_masked_sad64x32_c
-
-unsigned int aom_highbd_masked_sad64x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad64x64 aom_highbd_masked_sad64x64_c
-
-unsigned int aom_highbd_masked_sad8x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad8x16 aom_highbd_masked_sad8x16_c
-
-unsigned int aom_highbd_masked_sad8x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad8x4 aom_highbd_masked_sad8x4_c
-
-unsigned int aom_highbd_masked_sad8x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad8x8 aom_highbd_masked_sad8x8_c
-
 void aom_highbd_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 #define aom_highbd_minmax_8x8 aom_highbd_minmax_8x8_c
 
 unsigned int aom_highbd_obmc_sad16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 #define aom_highbd_obmc_sad16x16 aom_highbd_obmc_sad16x16_c
 
 unsigned int aom_highbd_obmc_sad16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 #define aom_highbd_obmc_sad16x32 aom_highbd_obmc_sad16x32_c
@@ -1434,25 +1641,43 @@ unsigned int aom_highbd_obmc_variance8x4
 #define aom_highbd_obmc_variance8x4 aom_highbd_obmc_variance8x4_c
 
 unsigned int aom_highbd_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 #define aom_highbd_obmc_variance8x8 aom_highbd_obmc_variance8x8_c
 
 void aom_highbd_paeth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_16x16 aom_highbd_paeth_predictor_16x16_c
 
+void aom_highbd_paeth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x32 aom_highbd_paeth_predictor_16x32_c
+
+void aom_highbd_paeth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x8 aom_highbd_paeth_predictor_16x8_c
+
 void aom_highbd_paeth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_2x2 aom_highbd_paeth_predictor_2x2_c
 
+void aom_highbd_paeth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_32x16 aom_highbd_paeth_predictor_32x16_c
+
 void aom_highbd_paeth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_32x32 aom_highbd_paeth_predictor_32x32_c
 
 void aom_highbd_paeth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_4x4 aom_highbd_paeth_predictor_4x4_c
 
+void aom_highbd_paeth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_4x8 aom_highbd_paeth_predictor_4x8_c
+
+void aom_highbd_paeth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x16 aom_highbd_paeth_predictor_8x16_c
+
+void aom_highbd_paeth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x4 aom_highbd_paeth_predictor_8x4_c
+
 void aom_highbd_paeth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_8x8 aom_highbd_paeth_predictor_8x8_c
 
 void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_highbd_quantize_b aom_highbd_quantize_b_c
 
 void aom_highbd_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_highbd_quantize_b_32x32 aom_highbd_quantize_b_32x32_c
@@ -1620,49 +1845,151 @@ void aom_highbd_sad8x8x3_c(const uint8_t
 #define aom_highbd_sad8x8x3 aom_highbd_sad8x8x3_c
 
 void aom_highbd_sad8x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 #define aom_highbd_sad8x8x4d aom_highbd_sad8x8x4d_c
 
 void aom_highbd_sad8x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
 #define aom_highbd_sad8x8x8 aom_highbd_sad8x8x8_c
 
+void aom_highbd_smooth_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x16 aom_highbd_smooth_h_predictor_16x16_c
+
+void aom_highbd_smooth_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x32 aom_highbd_smooth_h_predictor_16x32_c
+
+void aom_highbd_smooth_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x8 aom_highbd_smooth_h_predictor_16x8_c
+
+void aom_highbd_smooth_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_2x2 aom_highbd_smooth_h_predictor_2x2_c
+
+void aom_highbd_smooth_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x16 aom_highbd_smooth_h_predictor_32x16_c
+
+void aom_highbd_smooth_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x32 aom_highbd_smooth_h_predictor_32x32_c
+
+void aom_highbd_smooth_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x4 aom_highbd_smooth_h_predictor_4x4_c
+
+void aom_highbd_smooth_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x8 aom_highbd_smooth_h_predictor_4x8_c
+
+void aom_highbd_smooth_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x16 aom_highbd_smooth_h_predictor_8x16_c
+
+void aom_highbd_smooth_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x4 aom_highbd_smooth_h_predictor_8x4_c
+
+void aom_highbd_smooth_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x8 aom_highbd_smooth_h_predictor_8x8_c
+
 void aom_highbd_smooth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_16x16 aom_highbd_smooth_predictor_16x16_c
 
+void aom_highbd_smooth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x32 aom_highbd_smooth_predictor_16x32_c
+
+void aom_highbd_smooth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x8 aom_highbd_smooth_predictor_16x8_c
+
 void aom_highbd_smooth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_2x2 aom_highbd_smooth_predictor_2x2_c
 
+void aom_highbd_smooth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_32x16 aom_highbd_smooth_predictor_32x16_c
+
 void aom_highbd_smooth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_32x32 aom_highbd_smooth_predictor_32x32_c
 
 void aom_highbd_smooth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_4x4 aom_highbd_smooth_predictor_4x4_c
 
+void aom_highbd_smooth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_4x8 aom_highbd_smooth_predictor_4x8_c
+
+void aom_highbd_smooth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x16 aom_highbd_smooth_predictor_8x16_c
+
+void aom_highbd_smooth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x4 aom_highbd_smooth_predictor_8x4_c
+
 void aom_highbd_smooth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_8x8 aom_highbd_smooth_predictor_8x8_c
 
+void aom_highbd_smooth_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x16 aom_highbd_smooth_v_predictor_16x16_c
+
+void aom_highbd_smooth_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x32 aom_highbd_smooth_v_predictor_16x32_c
+
+void aom_highbd_smooth_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x8 aom_highbd_smooth_v_predictor_16x8_c
+
+void aom_highbd_smooth_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_2x2 aom_highbd_smooth_v_predictor_2x2_c
+
+void aom_highbd_smooth_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x16 aom_highbd_smooth_v_predictor_32x16_c
+
+void aom_highbd_smooth_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x32 aom_highbd_smooth_v_predictor_32x32_c
+
+void aom_highbd_smooth_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x4 aom_highbd_smooth_v_predictor_4x4_c
+
+void aom_highbd_smooth_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x8 aom_highbd_smooth_v_predictor_4x8_c
+
+void aom_highbd_smooth_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x16 aom_highbd_smooth_v_predictor_8x16_c
+
+void aom_highbd_smooth_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x4 aom_highbd_smooth_v_predictor_8x4_c
+
+void aom_highbd_smooth_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x8 aom_highbd_smooth_v_predictor_8x8_c
+
 void aom_highbd_subtract_block_c(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 #define aom_highbd_subtract_block aom_highbd_subtract_block_c
 
-void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
+void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 #define aom_highbd_upsampled_pred aom_highbd_upsampled_pred_c
 
 void aom_highbd_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_16x16 aom_highbd_v_predictor_16x16_c
 
+void aom_highbd_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x32 aom_highbd_v_predictor_16x32_c
+
+void aom_highbd_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x8 aom_highbd_v_predictor_16x8_c
+
 void aom_highbd_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_2x2 aom_highbd_v_predictor_2x2_c
 
+void aom_highbd_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_32x16 aom_highbd_v_predictor_32x16_c
+
 void aom_highbd_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_32x32 aom_highbd_v_predictor_32x32_c
 
 void aom_highbd_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_4x4 aom_highbd_v_predictor_4x4_c
 
+void aom_highbd_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_4x8 aom_highbd_v_predictor_4x8_c
+
+void aom_highbd_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x16 aom_highbd_v_predictor_8x16_c
+
+void aom_highbd_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x4 aom_highbd_v_predictor_8x4_c
+
 void aom_highbd_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_8x8 aom_highbd_v_predictor_8x8_c
 
 void aom_idct16x16_10_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
 #define aom_idct16x16_10_add aom_idct16x16_10_add_c
 
 void aom_idct16x16_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
 #define aom_idct16x16_1_add aom_idct16x16_1_add_c
@@ -1743,94 +2070,16 @@ void aom_lpf_vertical_4_dual_c(uint8_t *
 #define aom_lpf_vertical_4_dual aom_lpf_vertical_4_dual_c
 
 void aom_lpf_vertical_8_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 #define aom_lpf_vertical_8 aom_lpf_vertical_8_c
 
 void aom_lpf_vertical_8_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 #define aom_lpf_vertical_8_dual aom_lpf_vertical_8_dual_c
 
-unsigned int aom_masked_sad16x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad16x16 aom_masked_sad16x16_c
-
-unsigned int aom_masked_sad16x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad16x32 aom_masked_sad16x32_c
-
-unsigned int aom_masked_sad16x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad16x8 aom_masked_sad16x8_c
-
-unsigned int aom_masked_sad32x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad32x16 aom_masked_sad32x16_c
-
-unsigned int aom_masked_sad32x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad32x32 aom_masked_sad32x32_c
-
-unsigned int aom_masked_sad32x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad32x64 aom_masked_sad32x64_c
-
-unsigned int aom_masked_sad4x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad4x4 aom_masked_sad4x4_c
-
-unsigned int aom_masked_sad4x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad4x8 aom_masked_sad4x8_c
-
-unsigned int aom_masked_sad64x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad64x32 aom_masked_sad64x32_c
-
-unsigned int aom_masked_sad64x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad64x64 aom_masked_sad64x64_c
-
-unsigned int aom_masked_sad8x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad8x16 aom_masked_sad8x16_c
-
-unsigned int aom_masked_sad8x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad8x4 aom_masked_sad8x4_c
-
-unsigned int aom_masked_sad8x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad8x8 aom_masked_sad8x8_c
-
-unsigned int aom_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance16x16 aom_masked_sub_pixel_variance16x16_c
-
-unsigned int aom_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance16x32 aom_masked_sub_pixel_variance16x32_c
-
-unsigned int aom_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance16x8 aom_masked_sub_pixel_variance16x8_c
-
-unsigned int aom_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance32x16 aom_masked_sub_pixel_variance32x16_c
-
-unsigned int aom_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance32x32 aom_masked_sub_pixel_variance32x32_c
-
-unsigned int aom_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance32x64 aom_masked_sub_pixel_variance32x64_c
-
-unsigned int aom_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance4x4 aom_masked_sub_pixel_variance4x4_c
-
-unsigned int aom_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance4x8 aom_masked_sub_pixel_variance4x8_c
-
-unsigned int aom_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance64x32 aom_masked_sub_pixel_variance64x32_c
-
-unsigned int aom_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance64x64 aom_masked_sub_pixel_variance64x64_c
-
-unsigned int aom_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance8x16 aom_masked_sub_pixel_variance8x16_c
-
-unsigned int aom_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance8x4 aom_masked_sub_pixel_variance8x4_c
-
-unsigned int aom_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance8x8 aom_masked_sub_pixel_variance8x8_c
-
 void aom_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 #define aom_minmax_8x8 aom_minmax_8x8_c
 
 unsigned int aom_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_mse16x16 aom_mse16x16_c
 
 unsigned int aom_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_mse16x8 aom_mse16x8_c
@@ -1956,25 +2205,43 @@ unsigned int aom_obmc_variance8x4_c(cons
 #define aom_obmc_variance8x4 aom_obmc_variance8x4_c
 
 unsigned int aom_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 #define aom_obmc_variance8x8 aom_obmc_variance8x8_c
 
 void aom_paeth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_16x16 aom_paeth_predictor_16x16_c
 
+void aom_paeth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x32 aom_paeth_predictor_16x32_c
+
+void aom_paeth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x8 aom_paeth_predictor_16x8_c
+
 void aom_paeth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_2x2 aom_paeth_predictor_2x2_c
 
+void aom_paeth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_32x16 aom_paeth_predictor_32x16_c
+
 void aom_paeth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_32x32 aom_paeth_predictor_32x32_c
 
 void aom_paeth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_4x4 aom_paeth_predictor_4x4_c
 
+void aom_paeth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_4x8 aom_paeth_predictor_4x8_c
+
+void aom_paeth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x16 aom_paeth_predictor_8x16_c
+
+void aom_paeth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x4 aom_paeth_predictor_8x4_c
+
 void aom_paeth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_8x8 aom_paeth_predictor_8x8_c
 
 void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_quantize_b aom_quantize_b_c
 
 void aom_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_quantize_b_32x32 aom_quantize_b_32x32_c
@@ -2163,31 +2430,115 @@ void aom_scaled_avg_vert_c(const uint8_t
 #define aom_scaled_avg_vert aom_scaled_avg_vert_c
 
 void aom_scaled_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_horiz aom_scaled_horiz_c
 
 void aom_scaled_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_vert aom_scaled_vert_c
 
+void aom_smooth_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x16 aom_smooth_h_predictor_16x16_c
+
+void aom_smooth_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x32 aom_smooth_h_predictor_16x32_c
+
+void aom_smooth_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x8 aom_smooth_h_predictor_16x8_c
+
+void aom_smooth_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_2x2 aom_smooth_h_predictor_2x2_c
+
+void aom_smooth_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x16 aom_smooth_h_predictor_32x16_c
+
+void aom_smooth_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x32 aom_smooth_h_predictor_32x32_c
+
+void aom_smooth_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x4 aom_smooth_h_predictor_4x4_c
+
+void aom_smooth_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x8 aom_smooth_h_predictor_4x8_c
+
+void aom_smooth_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x16 aom_smooth_h_predictor_8x16_c
+
+void aom_smooth_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x4 aom_smooth_h_predictor_8x4_c
+
+void aom_smooth_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x8 aom_smooth_h_predictor_8x8_c
+
 void aom_smooth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_16x16 aom_smooth_predictor_16x16_c
 
+void aom_smooth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x32 aom_smooth_predictor_16x32_c
+
+void aom_smooth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x8 aom_smooth_predictor_16x8_c
+
 void aom_smooth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_2x2 aom_smooth_predictor_2x2_c
 
+void aom_smooth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_32x16 aom_smooth_predictor_32x16_c
+
 void aom_smooth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_32x32 aom_smooth_predictor_32x32_c
 
 void aom_smooth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_4x4 aom_smooth_predictor_4x4_c
 
+void aom_smooth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_4x8 aom_smooth_predictor_4x8_c
+
+void aom_smooth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x16 aom_smooth_predictor_8x16_c
+
+void aom_smooth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x4 aom_smooth_predictor_8x4_c
+
 void aom_smooth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_8x8 aom_smooth_predictor_8x8_c
 
+void aom_smooth_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x16 aom_smooth_v_predictor_16x16_c
+
+void aom_smooth_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x32 aom_smooth_v_predictor_16x32_c
+
+void aom_smooth_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x8 aom_smooth_v_predictor_16x8_c
+
+void aom_smooth_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_2x2 aom_smooth_v_predictor_2x2_c
+
+void aom_smooth_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x16 aom_smooth_v_predictor_32x16_c
+
+void aom_smooth_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x32 aom_smooth_v_predictor_32x32_c
+
+void aom_smooth_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x4 aom_smooth_v_predictor_4x4_c
+
+void aom_smooth_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x8 aom_smooth_v_predictor_4x8_c
+
+void aom_smooth_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x16 aom_smooth_v_predictor_8x16_c
+
+void aom_smooth_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x4 aom_smooth_v_predictor_8x4_c
+
+void aom_smooth_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x8 aom_smooth_v_predictor_8x8_c
+
 uint32_t aom_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 #define aom_sub_pixel_avg_variance16x16 aom_sub_pixel_avg_variance16x16_c
 
 uint32_t aom_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 #define aom_sub_pixel_avg_variance16x32 aom_sub_pixel_avg_variance16x32_c
 
 uint32_t aom_sub_pixel_avg_variance16x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 #define aom_sub_pixel_avg_variance16x8 aom_sub_pixel_avg_variance16x8_c
@@ -2265,31 +2616,49 @@ void aom_subtract_block_c(int rows, int 
 #define aom_subtract_block aom_subtract_block_c
 
 uint64_t aom_sum_squares_2d_i16_c(const int16_t *src, int stride, int width, int height);
 #define aom_sum_squares_2d_i16 aom_sum_squares_2d_i16_c
 
 uint64_t aom_sum_squares_i16_c(const int16_t *src, uint32_t N);
 #define aom_sum_squares_i16 aom_sum_squares_i16_c
 
-void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 #define aom_upsampled_pred aom_upsampled_pred_c
 
 void aom_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_16x16 aom_v_predictor_16x16_c
 
+void aom_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x32 aom_v_predictor_16x32_c
+
+void aom_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x8 aom_v_predictor_16x8_c
+
 void aom_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_2x2 aom_v_predictor_2x2_c
 
+void aom_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_32x16 aom_v_predictor_32x16_c
+
 void aom_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_32x32 aom_v_predictor_32x32_c
 
 void aom_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_4x4 aom_v_predictor_4x4_c
 
+void aom_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_4x8 aom_v_predictor_4x8_c
+
+void aom_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x16 aom_v_predictor_8x16_c
+
+void aom_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x4 aom_v_predictor_8x4_c
+
 void aom_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_8x8 aom_v_predictor_8x8_c
 
 unsigned int aom_variance16x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 #define aom_variance16x16 aom_variance16x16_c
 
 unsigned int aom_variance16x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 #define aom_variance16x32 aom_variance16x32_c
--- a/media/libaom/config/generic/av1_rtcd.h
+++ b/media/libaom/config/generic/av1_rtcd.h
@@ -13,22 +13,25 @@
 
 #include "aom/aom_integer.h"
 #include "av1/common/common.h"
 #include "av1/common/enums.h"
 #include "av1/common/quant_common.h"
 #include "av1/common/filter.h"
 #include "av1/common/convolve.h"
 #include "av1/common/av1_txfm.h"
+#include "av1/common/idct.h"
 #include "av1/common/odintrin.h"
 
 struct macroblockd;
 
 /* Encoder forward decls */
 struct macroblock;
+struct fwd_txfm_param;
+struct inv_txfm_param;
 struct aom_variance_vtable;
 struct search_site_config;
 struct mv;
 union int_mv;
 struct yv12_buffer_config;
 typedef uint16_t od_dering_in;
 
 #ifdef __cplusplus
@@ -57,79 +60,97 @@ void av1_convolve_vert_c(const uint8_t *
 #define av1_convolve_vert av1_convolve_vert_c
 
 int av1_diamond_search_sad_c(struct macroblock *x, const struct search_site_config *cfg,  struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_diamond_search_sad av1_diamond_search_sad_c
 
 void av1_fdct8x8_quant_c(const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define av1_fdct8x8_quant av1_fdct8x8_quant_c
 
-void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x16 av1_fht16x16_c
 
-void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x32 av1_fht16x32_c
 
-void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x4 av1_fht16x4_c
 
-void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x8 av1_fht16x8_c
 
-void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x16 av1_fht32x16_c
 
-void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x32 av1_fht32x32_c
 
-void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x8 av1_fht32x8_c
 
-void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x16 av1_fht4x16_c
 
-void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x4 av1_fht4x4_c
 
-void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x8 av1_fht4x8_c
 
-void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x16 av1_fht8x16_c
 
-void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x32 av1_fht8x32_c
 
-void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x4 av1_fht8x4_c
 
-void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x8 av1_fht8x8_c
 
 int av1_full_range_search_c(const struct macroblock *x, const struct search_site_config *cfg, struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_full_range_search av1_full_range_search_c
 
 int av1_full_search_sad_c(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 #define av1_full_search_sad av1_full_search_sad_c
 
 void av1_fwd_idtx_c(const int16_t *src_diff, tran_low_t *coeff, int stride, int bs, int tx_type);
 #define av1_fwd_idtx av1_fwd_idtx_c
 
 void av1_fwd_txfm2d_16x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 #define av1_fwd_txfm2d_16x16 av1_fwd_txfm2d_16x16_c
 
+void av1_fwd_txfm2d_16x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x32 av1_fwd_txfm2d_16x32_c
+
+void av1_fwd_txfm2d_16x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x8 av1_fwd_txfm2d_16x8_c
+
+void av1_fwd_txfm2d_32x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_32x16 av1_fwd_txfm2d_32x16_c
+
 void av1_fwd_txfm2d_32x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 #define av1_fwd_txfm2d_32x32 av1_fwd_txfm2d_32x32_c
 
 void av1_fwd_txfm2d_4x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 #define av1_fwd_txfm2d_4x4 av1_fwd_txfm2d_4x4_c
 
+void av1_fwd_txfm2d_4x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_4x8 av1_fwd_txfm2d_4x8_c
+
 void av1_fwd_txfm2d_64x64_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 #define av1_fwd_txfm2d_64x64 av1_fwd_txfm2d_64x64_c
 
+void av1_fwd_txfm2d_8x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x16 av1_fwd_txfm2d_8x16_c
+
+void av1_fwd_txfm2d_8x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x4 av1_fwd_txfm2d_8x4_c
+
 void av1_fwd_txfm2d_8x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 #define av1_fwd_txfm2d_8x8 av1_fwd_txfm2d_8x8_c
 
 void av1_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_fwht4x4 av1_fwht4x4_c
 
 int64_t av1_highbd_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd);
 #define av1_highbd_block_error av1_highbd_block_error_c
@@ -162,166 +183,139 @@ void av1_highbd_convolve_horiz_c(const u
 #define av1_highbd_convolve_horiz av1_highbd_convolve_horiz_c
 
 void av1_highbd_convolve_init_c(void);
 #define av1_highbd_convolve_init av1_highbd_convolve_init_c
 
 void av1_highbd_convolve_vert_c(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 #define av1_highbd_convolve_vert av1_highbd_convolve_vert_c
 
-void av1_highbd_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x16 av1_highbd_fht16x16_c
-
-void av1_highbd_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x32 av1_highbd_fht16x32_c
-
-void av1_highbd_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x4 av1_highbd_fht16x4_c
-
-void av1_highbd_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x8 av1_highbd_fht16x8_c
-
-void av1_highbd_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x16 av1_highbd_fht32x16_c
-
-void av1_highbd_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x32 av1_highbd_fht32x32_c
-
-void av1_highbd_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x8 av1_highbd_fht32x8_c
-
-void av1_highbd_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x16 av1_highbd_fht4x16_c
-
-void av1_highbd_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x4 av1_highbd_fht4x4_c
-
-void av1_highbd_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x8 av1_highbd_fht4x8_c
-
-void av1_highbd_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x16 av1_highbd_fht8x16_c
-
-void av1_highbd_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x32 av1_highbd_fht8x32_c
-
-void av1_highbd_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x4 av1_highbd_fht8x4_c
-
-void av1_highbd_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x8 av1_highbd_fht8x8_c
-
 void av1_highbd_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_highbd_fwht4x4 av1_highbd_fwht4x4_c
 
-void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type, int bd);
+void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x16_256_add av1_highbd_iht16x16_256_add_c
 
-void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x32_512_add av1_highbd_iht16x32_512_add_c
 
-void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x4_64_add av1_highbd_iht16x4_64_add_c
 
-void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x8_128_add av1_highbd_iht16x8_128_add_c
 
-void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x16_512_add av1_highbd_iht32x16_512_add_c
 
-void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x8_256_add av1_highbd_iht32x8_256_add_c
 
-void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x16_64_add av1_highbd_iht4x16_64_add_c
 
-void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x4_16_add av1_highbd_iht4x4_16_add_c
 
-void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x8_32_add av1_highbd_iht4x8_32_add_c
 
-void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x16_128_add av1_highbd_iht8x16_128_add_c
 
-void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x32_256_add av1_highbd_iht8x32_256_add_c
 
-void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x4_32_add av1_highbd_iht8x4_32_add_c
 
-void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x8_64_add av1_highbd_iht8x8_64_add_c
 
 void av1_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_highbd_quantize_b av1_highbd_quantize_b_c
 
 void av1_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_highbd_quantize_fp av1_highbd_quantize_fp_c
 
 void av1_highbd_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 #define av1_highbd_temporal_filter_apply av1_highbd_temporal_filter_apply_c
 
-void av1_highbd_warp_affine_c(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-#define av1_highbd_warp_affine av1_highbd_warp_affine_c
-
-void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
+void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_iht16x16_256_add av1_iht16x16_256_add_c
 
-void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x32_512_add av1_iht16x32_512_add_c
 
-void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x4_64_add av1_iht16x4_64_add_c
 
-void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x8_128_add av1_iht16x8_128_add_c
 
-void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht32x16_512_add av1_iht32x16_512_add_c
 
-void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
+void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_iht32x32_1024_add av1_iht32x32_1024_add_c
 
-void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht32x8_256_add av1_iht32x8_256_add_c
 
-void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x16_64_add av1_iht4x16_64_add_c
 
-void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x4_16_add av1_iht4x4_16_add_c
 
-void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x8_32_add av1_iht4x8_32_add_c
 
-void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x16_128_add av1_iht8x16_128_add_c
 
-void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x32_256_add av1_iht8x32_256_add_c
 
-void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x4_32_add av1_iht8x4_32_add_c
 
-void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x8_64_add av1_iht8x8_64_add_c
 
 void av1_inv_txfm2d_add_16x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_16x16 av1_inv_txfm2d_add_16x16_c
 
+void av1_inv_txfm2d_add_16x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x32 av1_inv_txfm2d_add_16x32_c
+
+void av1_inv_txfm2d_add_16x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x8 av1_inv_txfm2d_add_16x8_c
+
+void av1_inv_txfm2d_add_32x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_32x16 av1_inv_txfm2d_add_32x16_c
+
 void av1_inv_txfm2d_add_32x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_32x32 av1_inv_txfm2d_add_32x32_c
 
 void av1_inv_txfm2d_add_4x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_4x4 av1_inv_txfm2d_add_4x4_c
 
+void av1_inv_txfm2d_add_4x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_4x8 av1_inv_txfm2d_add_4x8_c
+
 void av1_inv_txfm2d_add_64x64_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_64x64 av1_inv_txfm2d_add_64x64_c
 
+void av1_inv_txfm2d_add_8x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x16 av1_inv_txfm2d_add_8x16_c
+
+void av1_inv_txfm2d_add_8x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x4 av1_inv_txfm2d_add_8x4_c
+
 void av1_inv_txfm2d_add_8x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_8x8 av1_inv_txfm2d_add_8x8_c
 
 void av1_lowbd_convolve_init_c(void);
 #define av1_lowbd_convolve_init av1_lowbd_convolve_init_c
 
 void av1_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_quantize_b av1_quantize_b_c
@@ -330,31 +324,16 @@ void av1_quantize_fp_c(const tran_low_t 
 #define av1_quantize_fp av1_quantize_fp_c
 
 void av1_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define av1_quantize_fp_32x32 av1_quantize_fp_32x32_c
 
 void av1_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 #define av1_temporal_filter_apply av1_temporal_filter_apply_c
 
-void av1_warp_affine_c(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-#define av1_warp_affine av1_warp_affine_c
-
-void av1_wedge_compute_delta_squares_c(int16_t *d, const int16_t *a, const int16_t *b, int N);
-#define av1_wedge_compute_delta_squares av1_wedge_compute_delta_squares_c
-
-int av1_wedge_sign_from_residuals_c(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-#define av1_wedge_sign_from_residuals av1_wedge_sign_from_residuals_c
-
-uint64_t av1_wedge_sse_from_residuals_c(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-#define av1_wedge_sse_from_residuals av1_wedge_sse_from_residuals_c
-
-double compute_cross_correlation_c(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-#define compute_cross_correlation compute_cross_correlation_c
-
 void copy_4x4_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 #define copy_4x4_16bit_to_16bit copy_4x4_16bit_to_16bit_c
 
 void copy_4x4_16bit_to_8bit_c(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
 #define copy_4x4_16bit_to_8bit copy_4x4_16bit_to_8bit_c
 
 void copy_8x8_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 #define copy_8x8_16bit_to_16bit copy_8x8_16bit_to_16bit_c
--- a/media/libaom/config/linux/arm/aom_config.asm
+++ b/media/libaom/config/linux/arm/aom_config.asm
@@ -63,60 +63,63 @@
 .equ CONFIG_INSPECTION ,  0
 .equ CONFIG_DECODE_PERF_TESTS ,  0
 .equ CONFIG_ENCODE_PERF_TESTS ,  0
 .equ CONFIG_COEFFICIENT_RANGE_CHECKING ,  0
 .equ CONFIG_LOWBITDEPTH ,  1
 .equ CONFIG_HIGHBITDEPTH ,  1
 .equ CONFIG_EXPERIMENTAL ,  0
 .equ CONFIG_SIZE_LIMIT ,  1
+.equ CONFIG_COLORSPACE_HEADERS ,  0
 .equ CONFIG_FP_MB_STATS ,  0
 .equ CONFIG_CDEF ,  1
 .equ CONFIG_VAR_TX ,  1
 .equ CONFIG_RECT_TX ,  1
 .equ CONFIG_RECT_TX_EXT ,  0
 .equ CONFIG_TPL_MV ,  0
-.equ CONFIG_DUAL_FILTER ,  1
+.equ CONFIG_DUAL_FILTER ,  0
 .equ CONFIG_CONVOLVE_ROUND ,  0
 .equ CONFIG_COMPOUND_ROUND ,  0
-.equ CONFIG_EXT_TX ,  1
+.equ CONFIG_EXT_TX ,  0
 .equ CONFIG_DPCM_INTRA ,  0
 .equ CONFIG_TX64X64 ,  0
 .equ CONFIG_EXT_INTRA ,  1
 .equ CONFIG_INTRA_INTERP ,  0
 .equ CONFIG_FILTER_INTRA ,  0
 .equ CONFIG_INTRA_EDGE ,  0
 .equ CONFIG_INTRABC ,  0
-.equ CONFIG_EXT_INTER ,  1
-.equ CONFIG_INTERINTRA ,  1
-.equ CONFIG_WEDGE ,  1
-.equ CONFIG_COMPOUND_SEGMENT ,  1
-.equ CONFIG_EXT_REFS ,  1
-.equ CONFIG_GLOBAL_MOTION ,  1
+.equ CONFIG_EXT_INTER ,  0
+.equ CONFIG_INTERINTRA ,  0
+.equ CONFIG_WEDGE ,  0
+.equ CONFIG_COMPOUND_SEGMENT ,  0
+.equ CONFIG_EXT_REFS ,  0
+.equ CONFIG_SPEED_REFS ,  0
+.equ CONFIG_GF_GROUPS ,  0
+.equ CONFIG_GLOBAL_MOTION ,  0
 .equ CONFIG_NEW_QUANT ,  0
 .equ CONFIG_SUPERTX ,  0
 .equ CONFIG_ANS ,  0
 .equ CONFIG_LOOP_RESTORATION ,  0
 .equ CONFIG_EXT_PARTITION ,  0
 .equ CONFIG_EXT_PARTITION_TYPES ,  0
 .equ CONFIG_UNPOISON_PARTITION_CTX ,  0
 .equ CONFIG_EXT_TILE ,  0
 .equ CONFIG_MOTION_VAR ,  1
 .equ CONFIG_NCOBMC ,  0
-.equ CONFIG_WARPED_MOTION ,  1
+.equ CONFIG_WARPED_MOTION ,  0
 .equ CONFIG_Q_ADAPT_PROBS ,  0
 .equ CONFIG_BITSTREAM_DEBUG ,  0
 .equ CONFIG_ALT_INTRA ,  1
 .equ CONFIG_PALETTE ,  1
 .equ CONFIG_PALETTE_DELTA_ENCODING ,  0
 .equ CONFIG_RAWBITS ,  0
 .equ CONFIG_EC_SMALLMUL ,  1
 .equ CONFIG_PVQ ,  0
 .equ CONFIG_CFL ,  0
-.equ CONFIG_XIPHRC ,  0
+.equ CONFIG_XIPHRC ,  1
 .equ CONFIG_CB4X4 ,  1
 .equ CONFIG_CHROMA_2X2 ,  0
 .equ CONFIG_CHROMA_SUB8X8 ,  1
 .equ CONFIG_FRAME_SIZE ,  0
 .equ CONFIG_DELTA_Q ,  1
 .equ CONFIG_EXT_DELTA_Q ,  1
 .equ CONFIG_ADAPT_SCAN ,  0
 .equ CONFIG_FILTER_7BIT ,  1
@@ -139,12 +142,19 @@
 .equ CONFIG_LV_MAP ,  0
 .equ CONFIG_TXK_SEL ,  0
 .equ CONFIG_MV_COMPRESS ,  1
 .equ CONFIG_FRAME_SUPERRES ,  0
 .equ CONFIG_NEW_MULTISYMBOL ,  0
 .equ CONFIG_COMPOUND_SINGLEREF ,  0
 .equ CONFIG_AOM_QM ,  0
 .equ CONFIG_ONE_SIDED_COMPOUND ,  1
-.equ CONFIG_SMOOTH_HV ,  0
+.equ CONFIG_EXT_COMP_REFS ,  0
+.equ CONFIG_SMOOTH_HV ,  1
 .equ CONFIG_VAR_REFS ,  0
+.equ CONFIG_RECT_INTRA_PRED ,  0
+.equ CONFIG_LGT ,  0
+.equ CONFIG_SBL_SYMBOL ,  0
+.equ CONFIG_NCOBMC_ADAPT_WEIGHT ,  0
+.equ CONFIG_BGSPRITE ,  0
+.equ CONFIG_VAR_TX_NO_TX_MODE ,  0
 .equ CONFIG_ANALYZER ,  0
 	.section	.note.GNU-stack,"",%progbits
--- a/media/libaom/config/linux/arm/aom_config.h
+++ b/media/libaom/config/linux/arm/aom_config.h
@@ -4,17 +4,17 @@
 /* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License */
 /* was not distributed with this source code in the LICENSE file, you can */
 /* obtain it at www.aomedia.org/license/software. If the Alliance for Open */
 /* Media Patent License 1.0 was not distributed with this source code in the */
 /* PATENTS file, you can obtain it at www.aomedia.org/license/patent. */
 /* This file automatically generated by configure. Do not edit! */
 #ifndef AOM_CONFIG_H
 #define AOM_CONFIG_H
-#define RESTRICT
+#define RESTRICT    
 #define INLINE      inline
 #define ARCH_ARM 1
 #define ARCH_MIPS 0
 #define ARCH_X86 0
 #define ARCH_X86_64 0
 #define HAVE_NEON 1
 #define HAVE_NEON_ASM 1
 #define HAVE_MIPS32 0
@@ -73,60 +73,63 @@
 #define CONFIG_INSPECTION 0
 #define CONFIG_DECODE_PERF_TESTS 0
 #define CONFIG_ENCODE_PERF_TESTS 0
 #define CONFIG_COEFFICIENT_RANGE_CHECKING 0
 #define CONFIG_LOWBITDEPTH 1
 #define CONFIG_HIGHBITDEPTH 1
 #define CONFIG_EXPERIMENTAL 0
 #define CONFIG_SIZE_LIMIT 1
+#define CONFIG_COLORSPACE_HEADERS 0
 #define CONFIG_FP_MB_STATS 0
 #define CONFIG_CDEF 1
 #define CONFIG_VAR_TX 1
 #define CONFIG_RECT_TX 1
 #define CONFIG_RECT_TX_EXT 0
 #define CONFIG_TPL_MV 0
-#define CONFIG_DUAL_FILTER 1
+#define CONFIG_DUAL_FILTER 0
 #define CONFIG_CONVOLVE_ROUND 0
 #define CONFIG_COMPOUND_ROUND 0
-#define CONFIG_EXT_TX 1
+#define CONFIG_EXT_TX 0
 #define CONFIG_DPCM_INTRA 0
 #define CONFIG_TX64X64 0
 #define CONFIG_EXT_INTRA 1
 #define CONFIG_INTRA_INTERP 0
 #define CONFIG_FILTER_INTRA 0
 #define CONFIG_INTRA_EDGE 0
 #define CONFIG_INTRABC 0
-#define CONFIG_EXT_INTER 1
-#define CONFIG_INTERINTRA 1
-#define CONFIG_WEDGE 1
-#define CONFIG_COMPOUND_SEGMENT 1
-#define CONFIG_EXT_REFS 1
-#define CONFIG_GLOBAL_MOTION 1
+#define CONFIG_EXT_INTER 0
+#define CONFIG_INTERINTRA 0
+#define CONFIG_WEDGE 0
+#define CONFIG_COMPOUND_SEGMENT 0
+#define CONFIG_EXT_REFS 0
+#define CONFIG_SPEED_REFS 0
+#define CONFIG_GF_GROUPS 0
+#define CONFIG_GLOBAL_MOTION 0
 #define CONFIG_NEW_QUANT 0
 #define CONFIG_SUPERTX 0
 #define CONFIG_ANS 0
 #define CONFIG_LOOP_RESTORATION 0
 #define CONFIG_EXT_PARTITION 0
 #define CONFIG_EXT_PARTITION_TYPES 0
 #define CONFIG_UNPOISON_PARTITION_CTX 0
 #define CONFIG_EXT_TILE 0
 #define CONFIG_MOTION_VAR 1
 #define CONFIG_NCOBMC 0
-#define CONFIG_WARPED_MOTION 1
+#define CONFIG_WARPED_MOTION 0
 #define CONFIG_Q_ADAPT_PROBS 0
 #define CONFIG_BITSTREAM_DEBUG 0
 #define CONFIG_ALT_INTRA 1
 #define CONFIG_PALETTE 1
 #define CONFIG_PALETTE_DELTA_ENCODING 0
 #define CONFIG_RAWBITS 0
 #define CONFIG_EC_SMALLMUL 1
 #define CONFIG_PVQ 0
 #define CONFIG_CFL 0
-#define CONFIG_XIPHRC 0
+#define CONFIG_XIPHRC 1
 #define CONFIG_CB4X4 1
 #define CONFIG_CHROMA_2X2 0
 #define CONFIG_CHROMA_SUB8X8 1
 #define CONFIG_FRAME_SIZE 0
 #define CONFIG_DELTA_Q 1
 #define CONFIG_EXT_DELTA_Q 1
 #define CONFIG_ADAPT_SCAN 0
 #define CONFIG_FILTER_7BIT 1
@@ -149,14 +152,21 @@
 #define CONFIG_LV_MAP 0
 #define CONFIG_TXK_SEL 0
 #define CONFIG_MV_COMPRESS 1
 #define CONFIG_FRAME_SUPERRES 0
 #define CONFIG_NEW_MULTISYMBOL 0
 #define CONFIG_COMPOUND_SINGLEREF 0
 #define CONFIG_AOM_QM 0
 #define CONFIG_ONE_SIDED_COMPOUND 1
-#define CONFIG_SMOOTH_HV 0
+#define CONFIG_EXT_COMP_REFS 0
+#define CONFIG_SMOOTH_HV 1
 #define CONFIG_VAR_REFS 0
+#define CONFIG_RECT_INTRA_PRED 0
+#define CONFIG_LGT 0
+#define CONFIG_SBL_SYMBOL 0
+#define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+#define CONFIG_BGSPRITE 0
+#define CONFIG_VAR_TX_NO_TX_MODE 0
 #define CONFIG_ANALYZER 0
 #define DECODE_WIDTH_LIMIT 8192
 #define DECODE_HEIGHT_LIMIT 4608
 #endif /* AOM_CONFIG_H */
--- a/media/libaom/config/linux/arm/aom_dsp_rtcd.h
+++ b/media/libaom/config/linux/arm/aom_dsp_rtcd.h
@@ -27,251 +27,434 @@ void aom_blend_a64_mask_c(uint8_t *dst, 
 #define aom_blend_a64_mask aom_blend_a64_mask_c
 
 void aom_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 #define aom_blend_a64_vmask aom_blend_a64_vmask_c
 
 void aom_comp_avg_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
 #define aom_comp_avg_pred aom_comp_avg_pred_c
 
-void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
+void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 #define aom_comp_avg_upsampled_pred aom_comp_avg_upsampled_pred_c
 
-void aom_comp_mask_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_pred aom_comp_mask_pred_c
-
-void aom_comp_mask_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_upsampled_pred aom_comp_mask_upsampled_pred_c
-
 void aom_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_neon(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_neon(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_horiz_neon(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_avg_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_horiz_scale aom_convolve8_avg_horiz_scale_c
+
+void aom_convolve8_avg_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_scale aom_convolve8_avg_scale_c
+
 void aom_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_vert_neon(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_avg_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_vert_scale aom_convolve8_avg_vert_scale_c
+
 void aom_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_neon(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_horiz_scale aom_convolve8_horiz_scale_c
+
+void aom_convolve8_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_scale aom_convolve8_scale_c
+
 void aom_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_neon(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_vert_scale aom_convolve8_vert_scale_c
+
 void aom_convolve_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve_avg_neon(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve_copy_neon(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve_copy)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_d117_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_16x16 aom_d117_predictor_16x16_c
 
+void aom_d117_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x32 aom_d117_predictor_16x32_c
+
+void aom_d117_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x8 aom_d117_predictor_16x8_c
+
 void aom_d117_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_2x2 aom_d117_predictor_2x2_c
 
+void aom_d117_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_32x16 aom_d117_predictor_32x16_c
+
 void aom_d117_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_32x32 aom_d117_predictor_32x32_c
 
 void aom_d117_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_4x4 aom_d117_predictor_4x4_c
 
+void aom_d117_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_4x8 aom_d117_predictor_4x8_c
+
+void aom_d117_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x16 aom_d117_predictor_8x16_c
+
+void aom_d117_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x4 aom_d117_predictor_8x4_c
+
 void aom_d117_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_8x8 aom_d117_predictor_8x8_c
 
 void aom_d135_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_16x16 aom_d135_predictor_16x16_c
 
+void aom_d135_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x32 aom_d135_predictor_16x32_c
+
+void aom_d135_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x8 aom_d135_predictor_16x8_c
+
 void aom_d135_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_2x2 aom_d135_predictor_2x2_c
 
+void aom_d135_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_32x16 aom_d135_predictor_32x16_c
+
 void aom_d135_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_32x32 aom_d135_predictor_32x32_c
 
 void aom_d135_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d135_predictor_4x4_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d135_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d135_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_4x8 aom_d135_predictor_4x8_c
+
+void aom_d135_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x16 aom_d135_predictor_8x16_c
+
+void aom_d135_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x4 aom_d135_predictor_8x4_c
+
 void aom_d135_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_8x8 aom_d135_predictor_8x8_c
 
 void aom_d153_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_16x16 aom_d153_predictor_16x16_c
 
+void aom_d153_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x32 aom_d153_predictor_16x32_c
+
+void aom_d153_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x8 aom_d153_predictor_16x8_c
+
 void aom_d153_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_2x2 aom_d153_predictor_2x2_c
 
+void aom_d153_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_32x16 aom_d153_predictor_32x16_c
+
 void aom_d153_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_32x32 aom_d153_predictor_32x32_c
 
 void aom_d153_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_4x4 aom_d153_predictor_4x4_c
 
+void aom_d153_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_4x8 aom_d153_predictor_4x8_c
+
+void aom_d153_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x16 aom_d153_predictor_8x16_c
+
+void aom_d153_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x4 aom_d153_predictor_8x4_c
+
 void aom_d153_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_8x8 aom_d153_predictor_8x8_c
 
 void aom_d207e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_16x16 aom_d207e_predictor_16x16_c
 
+void aom_d207e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x32 aom_d207e_predictor_16x32_c
+
+void aom_d207e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x8 aom_d207e_predictor_16x8_c
+
 void aom_d207e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_2x2 aom_d207e_predictor_2x2_c
 
+void aom_d207e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_32x16 aom_d207e_predictor_32x16_c
+
 void aom_d207e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_32x32 aom_d207e_predictor_32x32_c
 
 void aom_d207e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_4x4 aom_d207e_predictor_4x4_c
 
+void aom_d207e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_4x8 aom_d207e_predictor_4x8_c
+
+void aom_d207e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x16 aom_d207e_predictor_8x16_c
+
+void aom_d207e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x4 aom_d207e_predictor_8x4_c
+
 void aom_d207e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_8x8 aom_d207e_predictor_8x8_c
 
 void aom_d45e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_16x16 aom_d45e_predictor_16x16_c
 
+void aom_d45e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x32 aom_d45e_predictor_16x32_c
+
+void aom_d45e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x8 aom_d45e_predictor_16x8_c
+
 void aom_d45e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_2x2 aom_d45e_predictor_2x2_c
 
+void aom_d45e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_32x16 aom_d45e_predictor_32x16_c
+
 void aom_d45e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_32x32 aom_d45e_predictor_32x32_c
 
 void aom_d45e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_4x4 aom_d45e_predictor_4x4_c
 
+void aom_d45e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_4x8 aom_d45e_predictor_4x8_c
+
+void aom_d45e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x16 aom_d45e_predictor_8x16_c
+
+void aom_d45e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x4 aom_d45e_predictor_8x4_c
+
 void aom_d45e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_8x8 aom_d45e_predictor_8x8_c
 
 void aom_d63e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_16x16 aom_d63e_predictor_16x16_c
 
+void aom_d63e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x32 aom_d63e_predictor_16x32_c
+
+void aom_d63e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x8 aom_d63e_predictor_16x8_c
+
 void aom_d63e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_2x2 aom_d63e_predictor_2x2_c
 
+void aom_d63e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_32x16 aom_d63e_predictor_32x16_c
+
 void aom_d63e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_32x32 aom_d63e_predictor_32x32_c
 
 void aom_d63e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_4x4 aom_d63e_predictor_4x4_c
 
+void aom_d63e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_4x8 aom_d63e_predictor_4x8_c
+
+void aom_d63e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x16 aom_d63e_predictor_8x16_c
+
+void aom_d63e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x4 aom_d63e_predictor_8x4_c
+
 void aom_d63e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_8x8 aom_d63e_predictor_8x8_c
 
 void aom_dc_128_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_16x16_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_128_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_128_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x32 aom_dc_128_predictor_16x32_c
+
+void aom_dc_128_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x8 aom_dc_128_predictor_16x8_c
+
 void aom_dc_128_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_2x2 aom_dc_128_predictor_2x2_c
 
+void aom_dc_128_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_32x16 aom_dc_128_predictor_32x16_c
+
 void aom_dc_128_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_32x32_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_128_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_128_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_4x4_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_128_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_128_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_4x8 aom_dc_128_predictor_4x8_c
+
+void aom_dc_128_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x16 aom_dc_128_predictor_8x16_c
+
+void aom_dc_128_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x4 aom_dc_128_predictor_8x4_c
+
 void aom_dc_128_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_8x8_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_128_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_left_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_16x16_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_left_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_left_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x32 aom_dc_left_predictor_16x32_c
+
+void aom_dc_left_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x8 aom_dc_left_predictor_16x8_c
+
 void aom_dc_left_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_2x2 aom_dc_left_predictor_2x2_c
 
+void aom_dc_left_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_32x16 aom_dc_left_predictor_32x16_c
+
 void aom_dc_left_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_32x32_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_left_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_left_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_4x4_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_left_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_left_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_4x8 aom_dc_left_predictor_4x8_c
+
+void aom_dc_left_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x16 aom_dc_left_predictor_8x16_c
+
+void aom_dc_left_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x4 aom_dc_left_predictor_8x4_c
+
 void aom_dc_left_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_8x8_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_left_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_16x16_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x32 aom_dc_predictor_16x32_c
+
+void aom_dc_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x8 aom_dc_predictor_16x8_c
+
 void aom_dc_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_2x2 aom_dc_predictor_2x2_c
 
+void aom_dc_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_32x16 aom_dc_predictor_32x16_c
+
 void aom_dc_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_32x32_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_4x4_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_4x8 aom_dc_predictor_4x8_c
+
+void aom_dc_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x16 aom_dc_predictor_8x16_c
+
+void aom_dc_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x4 aom_dc_predictor_8x4_c
+
 void aom_dc_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_8x8_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_top_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_16x16_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_top_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_top_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x32 aom_dc_top_predictor_16x32_c
+
+void aom_dc_top_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x8 aom_dc_top_predictor_16x8_c
+
 void aom_dc_top_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_2x2 aom_dc_top_predictor_2x2_c
 
+void aom_dc_top_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_32x16 aom_dc_top_predictor_32x16_c
+
 void aom_dc_top_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_32x32_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_top_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_top_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_4x4_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_top_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_top_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_4x8 aom_dc_top_predictor_4x8_c
+
+void aom_dc_top_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x16 aom_dc_top_predictor_8x16_c
+
+void aom_dc_top_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x4 aom_dc_top_predictor_8x4_c
+
 void aom_dc_top_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_8x8_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_top_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct16x16 aom_fdct16x16_c
 
-void aom_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_fdct16x16_1 aom_fdct16x16_1_c
-
 void aom_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct32x32 aom_fdct32x32_c
 
-void aom_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_fdct32x32_1 aom_fdct32x32_1_c
-
 void aom_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct32x32_rd aom_fdct32x32_rd_c
 
 void aom_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct4x4 aom_fdct4x4_c
 
 void aom_fdct4x4_1_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct4x4_1 aom_fdct4x4_1_c
 
 void aom_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct8x8 aom_fdct8x8_c
 
-void aom_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_fdct8x8_1 aom_fdct8x8_1_c
-
 void aom_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 void aom_get16x16var_neon(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 RTCD_EXTERN void (*aom_get16x16var)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 
 unsigned int aom_get4x4sse_cs_c(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int ref_stride);
 unsigned int aom_get4x4sse_cs_neon(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int ref_stride);
 RTCD_EXTERN unsigned int (*aom_get4x4sse_cs)(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int ref_stride);
 
@@ -281,27 +464,45 @@ RTCD_EXTERN void (*aom_get8x8var)(const 
 
 unsigned int aom_get_mb_ss_c(const int16_t *);
 #define aom_get_mb_ss aom_get_mb_ss_c
 
 void aom_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_16x16_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_h_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x32 aom_h_predictor_16x32_c
+
+void aom_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x8 aom_h_predictor_16x8_c
+
 void aom_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_2x2 aom_h_predictor_2x2_c
 
+void aom_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_32x16 aom_h_predictor_32x16_c
+
 void aom_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_32x32_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_h_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_4x4_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_h_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_4x8 aom_h_predictor_4x8_c
+
+void aom_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x16 aom_h_predictor_8x16_c
+
+void aom_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x4 aom_h_predictor_8x4_c
+
 void aom_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_8x8_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_h_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_hadamard_16x16_c(const int16_t *src_diff, int src_stride, int16_t *coeff);
 void aom_hadamard_16x16_neon(const int16_t *src_diff, int src_stride, int16_t *coeff);
 RTCD_EXTERN void (*aom_hadamard_16x16)(const int16_t *src_diff, int src_stride, int16_t *coeff);
 
@@ -310,55 +511,16 @@ void aom_hadamard_8x8_neon(const int16_t
 RTCD_EXTERN void (*aom_hadamard_8x8)(const int16_t *src_diff, int src_stride, int16_t *coeff);
 
 void aom_highbd_10_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get16x16var aom_highbd_10_get16x16var_c
 
 void aom_highbd_10_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get8x8var aom_highbd_10_get8x8var_c
 
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance16x16 aom_highbd_10_masked_sub_pixel_variance16x16_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance16x32 aom_highbd_10_masked_sub_pixel_variance16x32_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance16x8 aom_highbd_10_masked_sub_pixel_variance16x8_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance32x16 aom_highbd_10_masked_sub_pixel_variance32x16_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance32x32 aom_highbd_10_masked_sub_pixel_variance32x32_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance32x64 aom_highbd_10_masked_sub_pixel_variance32x64_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance4x4 aom_highbd_10_masked_sub_pixel_variance4x4_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance4x8 aom_highbd_10_masked_sub_pixel_variance4x8_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance64x32 aom_highbd_10_masked_sub_pixel_variance64x32_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance64x64 aom_highbd_10_masked_sub_pixel_variance64x64_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance8x16 aom_highbd_10_masked_sub_pixel_variance8x16_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance8x4 aom_highbd_10_masked_sub_pixel_variance8x4_c
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_10_masked_sub_pixel_variance8x8 aom_highbd_10_masked_sub_pixel_variance8x8_c
-
 unsigned int aom_highbd_10_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse16x16 aom_highbd_10_mse16x16_c
 
 unsigned int aom_highbd_10_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse16x8 aom_highbd_10_mse16x8_c
 
 unsigned int aom_highbd_10_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse8x16 aom_highbd_10_mse8x16_c
@@ -571,55 +733,16 @@ unsigned int aom_highbd_10_variance8x8_c
 #define aom_highbd_10_variance8x8 aom_highbd_10_variance8x8_c
 
 void aom_highbd_12_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get16x16var aom_highbd_12_get16x16var_c
 
 void aom_highbd_12_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get8x8var aom_highbd_12_get8x8var_c
 
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance16x16 aom_highbd_12_masked_sub_pixel_variance16x16_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance16x32 aom_highbd_12_masked_sub_pixel_variance16x32_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance16x8 aom_highbd_12_masked_sub_pixel_variance16x8_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance32x16 aom_highbd_12_masked_sub_pixel_variance32x16_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance32x32 aom_highbd_12_masked_sub_pixel_variance32x32_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance32x64 aom_highbd_12_masked_sub_pixel_variance32x64_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance4x4 aom_highbd_12_masked_sub_pixel_variance4x4_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance4x8 aom_highbd_12_masked_sub_pixel_variance4x8_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance64x32 aom_highbd_12_masked_sub_pixel_variance64x32_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance64x64 aom_highbd_12_masked_sub_pixel_variance64x64_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance8x16 aom_highbd_12_masked_sub_pixel_variance8x16_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance8x4 aom_highbd_12_masked_sub_pixel_variance8x4_c
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_12_masked_sub_pixel_variance8x8 aom_highbd_12_masked_sub_pixel_variance8x8_c
-
 unsigned int aom_highbd_12_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse16x16 aom_highbd_12_mse16x16_c
 
 unsigned int aom_highbd_12_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse16x8 aom_highbd_12_mse16x8_c
 
 unsigned int aom_highbd_12_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse8x16 aom_highbd_12_mse8x16_c
@@ -832,55 +955,16 @@ unsigned int aom_highbd_12_variance8x8_c
 #define aom_highbd_12_variance8x8 aom_highbd_12_variance8x8_c
 
 void aom_highbd_8_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get16x16var aom_highbd_8_get16x16var_c
 
 void aom_highbd_8_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get8x8var aom_highbd_8_get8x8var_c
 
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance16x16 aom_highbd_8_masked_sub_pixel_variance16x16_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance16x32 aom_highbd_8_masked_sub_pixel_variance16x32_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance16x8 aom_highbd_8_masked_sub_pixel_variance16x8_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance32x16 aom_highbd_8_masked_sub_pixel_variance32x16_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance32x32 aom_highbd_8_masked_sub_pixel_variance32x32_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance32x64 aom_highbd_8_masked_sub_pixel_variance32x64_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance4x4 aom_highbd_8_masked_sub_pixel_variance4x4_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance4x8 aom_highbd_8_masked_sub_pixel_variance4x8_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance64x32 aom_highbd_8_masked_sub_pixel_variance64x32_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance64x64 aom_highbd_8_masked_sub_pixel_variance64x64_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance8x16 aom_highbd_8_masked_sub_pixel_variance8x16_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance8x4 aom_highbd_8_masked_sub_pixel_variance8x4_c
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_highbd_8_masked_sub_pixel_variance8x8 aom_highbd_8_masked_sub_pixel_variance8x8_c
-
 unsigned int aom_highbd_8_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse16x16 aom_highbd_8_mse16x16_c
 
 unsigned int aom_highbd_8_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse16x8 aom_highbd_8_mse16x8_c
 
 unsigned int aom_highbd_8_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse8x16 aom_highbd_8_mse8x16_c
@@ -1021,25 +1105,19 @@ void aom_highbd_blend_a64_mask_c(uint8_t
 #define aom_highbd_blend_a64_mask aom_highbd_blend_a64_mask_c
 
 void aom_highbd_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 #define aom_highbd_blend_a64_vmask aom_highbd_blend_a64_vmask_c
 
 void aom_highbd_comp_avg_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
 #define aom_highbd_comp_avg_pred aom_highbd_comp_avg_pred_c
 
-void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
+void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 #define aom_highbd_comp_avg_upsampled_pred aom_highbd_comp_avg_upsampled_pred_c
 
-void aom_highbd_comp_mask_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_pred aom_highbd_comp_mask_pred_c
-
-void aom_highbd_comp_mask_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_upsampled_pred aom_highbd_comp_mask_upsampled_pred_c
-
 void aom_highbd_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 #define aom_highbd_convolve8 aom_highbd_convolve8_c
 
 void aom_highbd_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 #define aom_highbd_convolve8_avg aom_highbd_convolve8_avg_c
 
 void aom_highbd_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 #define aom_highbd_convolve8_avg_horiz aom_highbd_convolve8_avg_horiz_c
@@ -1057,223 +1135,391 @@ void aom_highbd_convolve_avg_c(const uin
 #define aom_highbd_convolve_avg aom_highbd_convolve_avg_c
 
 void aom_highbd_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 #define aom_highbd_convolve_copy aom_highbd_convolve_copy_c
 
 void aom_highbd_d117_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_16x16 aom_highbd_d117_predictor_16x16_c
 
+void aom_highbd_d117_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x32 aom_highbd_d117_predictor_16x32_c
+
+void aom_highbd_d117_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x8 aom_highbd_d117_predictor_16x8_c
+
 void aom_highbd_d117_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_2x2 aom_highbd_d117_predictor_2x2_c
 
+void aom_highbd_d117_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_32x16 aom_highbd_d117_predictor_32x16_c
+
 void aom_highbd_d117_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_32x32 aom_highbd_d117_predictor_32x32_c
 
 void aom_highbd_d117_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_4x4 aom_highbd_d117_predictor_4x4_c
 
+void aom_highbd_d117_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_4x8 aom_highbd_d117_predictor_4x8_c
+
+void aom_highbd_d117_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x16 aom_highbd_d117_predictor_8x16_c
+
+void aom_highbd_d117_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x4 aom_highbd_d117_predictor_8x4_c
+
 void aom_highbd_d117_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_8x8 aom_highbd_d117_predictor_8x8_c
 
 void aom_highbd_d135_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_16x16 aom_highbd_d135_predictor_16x16_c
 
+void aom_highbd_d135_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x32 aom_highbd_d135_predictor_16x32_c
+
+void aom_highbd_d135_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x8 aom_highbd_d135_predictor_16x8_c
+
 void aom_highbd_d135_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_2x2 aom_highbd_d135_predictor_2x2_c
 
+void aom_highbd_d135_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_32x16 aom_highbd_d135_predictor_32x16_c
+
 void aom_highbd_d135_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_32x32 aom_highbd_d135_predictor_32x32_c
 
 void aom_highbd_d135_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_4x4 aom_highbd_d135_predictor_4x4_c
 
+void aom_highbd_d135_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_4x8 aom_highbd_d135_predictor_4x8_c
+
+void aom_highbd_d135_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x16 aom_highbd_d135_predictor_8x16_c
+
+void aom_highbd_d135_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x4 aom_highbd_d135_predictor_8x4_c
+
 void aom_highbd_d135_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_8x8 aom_highbd_d135_predictor_8x8_c
 
 void aom_highbd_d153_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_16x16 aom_highbd_d153_predictor_16x16_c
 
+void aom_highbd_d153_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x32 aom_highbd_d153_predictor_16x32_c
+
+void aom_highbd_d153_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x8 aom_highbd_d153_predictor_16x8_c
+
 void aom_highbd_d153_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_2x2 aom_highbd_d153_predictor_2x2_c
 
+void aom_highbd_d153_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_32x16 aom_highbd_d153_predictor_32x16_c
+
 void aom_highbd_d153_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_32x32 aom_highbd_d153_predictor_32x32_c
 
 void aom_highbd_d153_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_4x4 aom_highbd_d153_predictor_4x4_c
 
+void aom_highbd_d153_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_4x8 aom_highbd_d153_predictor_4x8_c
+
+void aom_highbd_d153_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x16 aom_highbd_d153_predictor_8x16_c
+
+void aom_highbd_d153_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x4 aom_highbd_d153_predictor_8x4_c
+
 void aom_highbd_d153_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_8x8 aom_highbd_d153_predictor_8x8_c
 
 void aom_highbd_d207e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_16x16 aom_highbd_d207e_predictor_16x16_c
 
+void aom_highbd_d207e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x32 aom_highbd_d207e_predictor_16x32_c
+
+void aom_highbd_d207e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x8 aom_highbd_d207e_predictor_16x8_c
+
 void aom_highbd_d207e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_2x2 aom_highbd_d207e_predictor_2x2_c
 
+void aom_highbd_d207e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_32x16 aom_highbd_d207e_predictor_32x16_c
+
 void aom_highbd_d207e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_32x32 aom_highbd_d207e_predictor_32x32_c
 
 void aom_highbd_d207e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_4x4 aom_highbd_d207e_predictor_4x4_c
 
+void aom_highbd_d207e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_4x8 aom_highbd_d207e_predictor_4x8_c
+
+void aom_highbd_d207e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x16 aom_highbd_d207e_predictor_8x16_c
+
+void aom_highbd_d207e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x4 aom_highbd_d207e_predictor_8x4_c
+
 void aom_highbd_d207e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_8x8 aom_highbd_d207e_predictor_8x8_c
 
 void aom_highbd_d45e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_16x16 aom_highbd_d45e_predictor_16x16_c
 
+void aom_highbd_d45e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x32 aom_highbd_d45e_predictor_16x32_c
+
+void aom_highbd_d45e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x8 aom_highbd_d45e_predictor_16x8_c
+
 void aom_highbd_d45e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_2x2 aom_highbd_d45e_predictor_2x2_c
 
+void aom_highbd_d45e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_32x16 aom_highbd_d45e_predictor_32x16_c
+
 void aom_highbd_d45e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_32x32 aom_highbd_d45e_predictor_32x32_c
 
 void aom_highbd_d45e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_4x4 aom_highbd_d45e_predictor_4x4_c
 
+void aom_highbd_d45e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_4x8 aom_highbd_d45e_predictor_4x8_c
+
+void aom_highbd_d45e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x16 aom_highbd_d45e_predictor_8x16_c
+
+void aom_highbd_d45e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x4 aom_highbd_d45e_predictor_8x4_c
+
 void aom_highbd_d45e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_8x8 aom_highbd_d45e_predictor_8x8_c
 
 void aom_highbd_d63e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_16x16 aom_highbd_d63e_predictor_16x16_c
 
+void aom_highbd_d63e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x32 aom_highbd_d63e_predictor_16x32_c
+
+void aom_highbd_d63e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x8 aom_highbd_d63e_predictor_16x8_c
+
 void aom_highbd_d63e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_2x2 aom_highbd_d63e_predictor_2x2_c
 
+void aom_highbd_d63e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_32x16 aom_highbd_d63e_predictor_32x16_c
+
 void aom_highbd_d63e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_32x32 aom_highbd_d63e_predictor_32x32_c
 
 void aom_highbd_d63e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_4x4 aom_highbd_d63e_predictor_4x4_c
 
+void aom_highbd_d63e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_4x8 aom_highbd_d63e_predictor_4x8_c
+
+void aom_highbd_d63e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x16 aom_highbd_d63e_predictor_8x16_c
+
+void aom_highbd_d63e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x4 aom_highbd_d63e_predictor_8x4_c
+
 void aom_highbd_d63e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_8x8 aom_highbd_d63e_predictor_8x8_c
 
 void aom_highbd_dc_128_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_16x16 aom_highbd_dc_128_predictor_16x16_c
 
+void aom_highbd_dc_128_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x32 aom_highbd_dc_128_predictor_16x32_c
+
+void aom_highbd_dc_128_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x8 aom_highbd_dc_128_predictor_16x8_c
+
 void aom_highbd_dc_128_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_2x2 aom_highbd_dc_128_predictor_2x2_c
 
+void aom_highbd_dc_128_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_32x16 aom_highbd_dc_128_predictor_32x16_c
+
 void aom_highbd_dc_128_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_32x32 aom_highbd_dc_128_predictor_32x32_c
 
 void aom_highbd_dc_128_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_4x4 aom_highbd_dc_128_predictor_4x4_c
 
+void aom_highbd_dc_128_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_4x8 aom_highbd_dc_128_predictor_4x8_c
+
+void aom_highbd_dc_128_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x16 aom_highbd_dc_128_predictor_8x16_c
+
+void aom_highbd_dc_128_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x4 aom_highbd_dc_128_predictor_8x4_c
+
 void aom_highbd_dc_128_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_8x8 aom_highbd_dc_128_predictor_8x8_c
 
 void aom_highbd_dc_left_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_16x16 aom_highbd_dc_left_predictor_16x16_c
 
+void aom_highbd_dc_left_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x32 aom_highbd_dc_left_predictor_16x32_c
+
+void aom_highbd_dc_left_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x8 aom_highbd_dc_left_predictor_16x8_c
+
 void aom_highbd_dc_left_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_2x2 aom_highbd_dc_left_predictor_2x2_c
 
+void aom_highbd_dc_left_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_32x16 aom_highbd_dc_left_predictor_32x16_c
+
 void aom_highbd_dc_left_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_32x32 aom_highbd_dc_left_predictor_32x32_c
 
 void aom_highbd_dc_left_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_4x4 aom_highbd_dc_left_predictor_4x4_c
 
+void aom_highbd_dc_left_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_4x8 aom_highbd_dc_left_predictor_4x8_c
+
+void aom_highbd_dc_left_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x16 aom_highbd_dc_left_predictor_8x16_c
+
+void aom_highbd_dc_left_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x4 aom_highbd_dc_left_predictor_8x4_c
+
 void aom_highbd_dc_left_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_8x8 aom_highbd_dc_left_predictor_8x8_c
 
 void aom_highbd_dc_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_16x16 aom_highbd_dc_predictor_16x16_c
 
+void aom_highbd_dc_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x32 aom_highbd_dc_predictor_16x32_c
+
+void aom_highbd_dc_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x8 aom_highbd_dc_predictor_16x8_c
+
 void aom_highbd_dc_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_2x2 aom_highbd_dc_predictor_2x2_c
 
+void aom_highbd_dc_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_32x16 aom_highbd_dc_predictor_32x16_c
+
 void aom_highbd_dc_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_32x32 aom_highbd_dc_predictor_32x32_c
 
 void aom_highbd_dc_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_4x4 aom_highbd_dc_predictor_4x4_c
 
+void aom_highbd_dc_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_4x8 aom_highbd_dc_predictor_4x8_c
+
+void aom_highbd_dc_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x16 aom_highbd_dc_predictor_8x16_c
+
+void aom_highbd_dc_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x4 aom_highbd_dc_predictor_8x4_c
+
 void aom_highbd_dc_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_8x8 aom_highbd_dc_predictor_8x8_c
 
 void aom_highbd_dc_top_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_16x16 aom_highbd_dc_top_predictor_16x16_c
 
+void aom_highbd_dc_top_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x32 aom_highbd_dc_top_predictor_16x32_c
+
+void aom_highbd_dc_top_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x8 aom_highbd_dc_top_predictor_16x8_c
+
 void aom_highbd_dc_top_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_2x2 aom_highbd_dc_top_predictor_2x2_c
 
+void aom_highbd_dc_top_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_32x16 aom_highbd_dc_top_predictor_32x16_c
+
 void aom_highbd_dc_top_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_32x32 aom_highbd_dc_top_predictor_32x32_c
 
 void aom_highbd_dc_top_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_4x4 aom_highbd_dc_top_predictor_4x4_c
 
+void aom_highbd_dc_top_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_4x8 aom_highbd_dc_top_predictor_4x8_c
+
+void aom_highbd_dc_top_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x16 aom_highbd_dc_top_predictor_8x16_c
+
+void aom_highbd_dc_top_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x4 aom_highbd_dc_top_predictor_8x4_c
+
 void aom_highbd_dc_top_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_8x8 aom_highbd_dc_top_predictor_8x8_c
 
 void aom_highbd_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct16x16 aom_highbd_fdct16x16_c
 
-void aom_highbd_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct16x16_1 aom_highbd_fdct16x16_1_c
-
 void aom_highbd_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct32x32 aom_highbd_fdct32x32_c
 
-void aom_highbd_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct32x32_1 aom_highbd_fdct32x32_1_c
-
 void aom_highbd_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct32x32_rd aom_highbd_fdct32x32_rd_c
 
 void aom_highbd_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct4x4 aom_highbd_fdct4x4_c
 
 void aom_highbd_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct8x8 aom_highbd_fdct8x8_c
 
-void aom_highbd_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct8x8_1 aom_highbd_fdct8x8_1_c
-
 void aom_highbd_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_16x16 aom_highbd_h_predictor_16x16_c
 
+void aom_highbd_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x32 aom_highbd_h_predictor_16x32_c
+
+void aom_highbd_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x8 aom_highbd_h_predictor_16x8_c
+
 void aom_highbd_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_2x2 aom_highbd_h_predictor_2x2_c
 
+void aom_highbd_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_32x16 aom_highbd_h_predictor_32x16_c
+
 void aom_highbd_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_32x32 aom_highbd_h_predictor_32x32_c
 
 void aom_highbd_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_4x4 aom_highbd_h_predictor_4x4_c
 
+void aom_highbd_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_4x8 aom_highbd_h_predictor_4x8_c
+
+void aom_highbd_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x16 aom_highbd_h_predictor_8x16_c
+
+void aom_highbd_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x4 aom_highbd_h_predictor_8x4_c
+
 void aom_highbd_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_8x8 aom_highbd_h_predictor_8x8_c
 
-void aom_highbd_idct16x16_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct16x16_1_add aom_highbd_idct16x16_1_add_c
-
-void aom_highbd_idct32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1024_add aom_highbd_idct32x32_1024_add_c
-
-void aom_highbd_idct32x32_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1_add aom_highbd_idct32x32_1_add_c
-
-void aom_highbd_idct32x32_34_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_34_add aom_highbd_idct32x32_34_add_c
-
-void aom_highbd_idct4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct4x4_16_add aom_highbd_idct4x4_16_add_c
-
-void aom_highbd_idct4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct4x4_1_add aom_highbd_idct4x4_1_add_c
-
-void aom_highbd_idct8x8_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct8x8_1_add aom_highbd_idct8x8_1_add_c
-
 void aom_highbd_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_16_add aom_highbd_iwht4x4_16_add_c
 
 void aom_highbd_iwht4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_1_add aom_highbd_iwht4x4_1_add_c
 
 void aom_highbd_lpf_horizontal_4_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 #define aom_highbd_lpf_horizontal_4 aom_highbd_lpf_horizontal_4_c
@@ -1306,55 +1552,16 @@ void aom_highbd_lpf_vertical_4_dual_c(ui
 #define aom_highbd_lpf_vertical_4_dual aom_highbd_lpf_vertical_4_dual_c
 
 void aom_highbd_lpf_vertical_8_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 #define aom_highbd_lpf_vertical_8 aom_highbd_lpf_vertical_8_c
 
 void aom_highbd_lpf_vertical_8_dual_c(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 #define aom_highbd_lpf_vertical_8_dual aom_highbd_lpf_vertical_8_dual_c
 
-unsigned int aom_highbd_masked_sad16x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad16x16 aom_highbd_masked_sad16x16_c
-
-unsigned int aom_highbd_masked_sad16x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad16x32 aom_highbd_masked_sad16x32_c
-
-unsigned int aom_highbd_masked_sad16x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad16x8 aom_highbd_masked_sad16x8_c
-
-unsigned int aom_highbd_masked_sad32x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad32x16 aom_highbd_masked_sad32x16_c
-
-unsigned int aom_highbd_masked_sad32x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad32x32 aom_highbd_masked_sad32x32_c
-
-unsigned int aom_highbd_masked_sad32x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad32x64 aom_highbd_masked_sad32x64_c
-
-unsigned int aom_highbd_masked_sad4x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad4x4 aom_highbd_masked_sad4x4_c
-
-unsigned int aom_highbd_masked_sad4x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad4x8 aom_highbd_masked_sad4x8_c
-
-unsigned int aom_highbd_masked_sad64x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad64x32 aom_highbd_masked_sad64x32_c
-
-unsigned int aom_highbd_masked_sad64x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad64x64 aom_highbd_masked_sad64x64_c
-
-unsigned int aom_highbd_masked_sad8x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad8x16 aom_highbd_masked_sad8x16_c
-
-unsigned int aom_highbd_masked_sad8x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad8x4 aom_highbd_masked_sad8x4_c
-
-unsigned int aom_highbd_masked_sad8x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_highbd_masked_sad8x8 aom_highbd_masked_sad8x8_c
-
 void aom_highbd_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 #define aom_highbd_minmax_8x8 aom_highbd_minmax_8x8_c
 
 unsigned int aom_highbd_obmc_sad16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 #define aom_highbd_obmc_sad16x16 aom_highbd_obmc_sad16x16_c
 
 unsigned int aom_highbd_obmc_sad16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 #define aom_highbd_obmc_sad16x32 aom_highbd_obmc_sad16x32_c
@@ -1468,25 +1675,43 @@ unsigned int aom_highbd_obmc_variance8x4
 #define aom_highbd_obmc_variance8x4 aom_highbd_obmc_variance8x4_c
 
 unsigned int aom_highbd_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 #define aom_highbd_obmc_variance8x8 aom_highbd_obmc_variance8x8_c
 
 void aom_highbd_paeth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_16x16 aom_highbd_paeth_predictor_16x16_c
 
+void aom_highbd_paeth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x32 aom_highbd_paeth_predictor_16x32_c
+
+void aom_highbd_paeth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x8 aom_highbd_paeth_predictor_16x8_c
+
 void aom_highbd_paeth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_2x2 aom_highbd_paeth_predictor_2x2_c
 
+void aom_highbd_paeth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_32x16 aom_highbd_paeth_predictor_32x16_c
+
 void aom_highbd_paeth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_32x32 aom_highbd_paeth_predictor_32x32_c
 
 void aom_highbd_paeth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_4x4 aom_highbd_paeth_predictor_4x4_c
 
+void aom_highbd_paeth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_4x8 aom_highbd_paeth_predictor_4x8_c
+
+void aom_highbd_paeth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x16 aom_highbd_paeth_predictor_8x16_c
+
+void aom_highbd_paeth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x4 aom_highbd_paeth_predictor_8x4_c
+
 void aom_highbd_paeth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_8x8 aom_highbd_paeth_predictor_8x8_c
 
 void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_highbd_quantize_b aom_highbd_quantize_b_c
 
 void aom_highbd_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_highbd_quantize_b_32x32 aom_highbd_quantize_b_32x32_c
@@ -1654,49 +1879,151 @@ void aom_highbd_sad8x8x3_c(const uint8_t
 #define aom_highbd_sad8x8x3 aom_highbd_sad8x8x3_c
 
 void aom_highbd_sad8x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 #define aom_highbd_sad8x8x4d aom_highbd_sad8x8x4d_c
 
 void aom_highbd_sad8x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
 #define aom_highbd_sad8x8x8 aom_highbd_sad8x8x8_c
 
+void aom_highbd_smooth_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x16 aom_highbd_smooth_h_predictor_16x16_c
+
+void aom_highbd_smooth_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x32 aom_highbd_smooth_h_predictor_16x32_c
+
+void aom_highbd_smooth_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x8 aom_highbd_smooth_h_predictor_16x8_c
+
+void aom_highbd_smooth_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_2x2 aom_highbd_smooth_h_predictor_2x2_c
+
+void aom_highbd_smooth_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x16 aom_highbd_smooth_h_predictor_32x16_c
+
+void aom_highbd_smooth_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x32 aom_highbd_smooth_h_predictor_32x32_c
+
+void aom_highbd_smooth_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x4 aom_highbd_smooth_h_predictor_4x4_c
+
+void aom_highbd_smooth_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x8 aom_highbd_smooth_h_predictor_4x8_c
+
+void aom_highbd_smooth_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x16 aom_highbd_smooth_h_predictor_8x16_c
+
+void aom_highbd_smooth_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x4 aom_highbd_smooth_h_predictor_8x4_c
+
+void aom_highbd_smooth_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x8 aom_highbd_smooth_h_predictor_8x8_c
+
 void aom_highbd_smooth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_16x16 aom_highbd_smooth_predictor_16x16_c
 
+void aom_highbd_smooth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x32 aom_highbd_smooth_predictor_16x32_c
+
+void aom_highbd_smooth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x8 aom_highbd_smooth_predictor_16x8_c
+
 void aom_highbd_smooth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_2x2 aom_highbd_smooth_predictor_2x2_c
 
+void aom_highbd_smooth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_32x16 aom_highbd_smooth_predictor_32x16_c
+
 void aom_highbd_smooth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_32x32 aom_highbd_smooth_predictor_32x32_c
 
 void aom_highbd_smooth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_4x4 aom_highbd_smooth_predictor_4x4_c
 
+void aom_highbd_smooth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_4x8 aom_highbd_smooth_predictor_4x8_c
+
+void aom_highbd_smooth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x16 aom_highbd_smooth_predictor_8x16_c
+
+void aom_highbd_smooth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x4 aom_highbd_smooth_predictor_8x4_c
+
 void aom_highbd_smooth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_8x8 aom_highbd_smooth_predictor_8x8_c
 
+void aom_highbd_smooth_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x16 aom_highbd_smooth_v_predictor_16x16_c
+
+void aom_highbd_smooth_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x32 aom_highbd_smooth_v_predictor_16x32_c
+
+void aom_highbd_smooth_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x8 aom_highbd_smooth_v_predictor_16x8_c
+
+void aom_highbd_smooth_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_2x2 aom_highbd_smooth_v_predictor_2x2_c
+
+void aom_highbd_smooth_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x16 aom_highbd_smooth_v_predictor_32x16_c
+
+void aom_highbd_smooth_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x32 aom_highbd_smooth_v_predictor_32x32_c
+
+void aom_highbd_smooth_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x4 aom_highbd_smooth_v_predictor_4x4_c
+
+void aom_highbd_smooth_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x8 aom_highbd_smooth_v_predictor_4x8_c
+
+void aom_highbd_smooth_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x16 aom_highbd_smooth_v_predictor_8x16_c
+
+void aom_highbd_smooth_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x4 aom_highbd_smooth_v_predictor_8x4_c
+
+void aom_highbd_smooth_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x8 aom_highbd_smooth_v_predictor_8x8_c
+
 void aom_highbd_subtract_block_c(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 #define aom_highbd_subtract_block aom_highbd_subtract_block_c
 
-void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
+void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 #define aom_highbd_upsampled_pred aom_highbd_upsampled_pred_c
 
 void aom_highbd_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_16x16 aom_highbd_v_predictor_16x16_c
 
+void aom_highbd_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x32 aom_highbd_v_predictor_16x32_c
+
+void aom_highbd_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x8 aom_highbd_v_predictor_16x8_c
+
 void aom_highbd_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_2x2 aom_highbd_v_predictor_2x2_c
 
+void aom_highbd_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_32x16 aom_highbd_v_predictor_32x16_c
+
 void aom_highbd_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_32x32 aom_highbd_v_predictor_32x32_c
 
 void aom_highbd_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_4x4 aom_highbd_v_predictor_4x4_c
 
+void aom_highbd_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_4x8 aom_highbd_v_predictor_4x8_c
+
+void aom_highbd_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x16 aom_highbd_v_predictor_8x16_c
+
+void aom_highbd_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x4 aom_highbd_v_predictor_8x4_c
+
 void aom_highbd_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_8x8 aom_highbd_v_predictor_8x8_c
 
 void aom_idct16x16_10_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
 #define aom_idct16x16_10_add aom_idct16x16_10_add_c
 
 void aom_idct16x16_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
 #define aom_idct16x16_1_add aom_idct16x16_1_add_c
@@ -1791,94 +2118,16 @@ RTCD_EXTERN void (*aom_lpf_vertical_4_du
 void aom_lpf_vertical_8_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 void aom_lpf_vertical_8_neon(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 RTCD_EXTERN void (*aom_lpf_vertical_8)(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 
 void aom_lpf_vertical_8_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 void aom_lpf_vertical_8_dual_neon(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 RTCD_EXTERN void (*aom_lpf_vertical_8_dual)(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 
-unsigned int aom_masked_sad16x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad16x16 aom_masked_sad16x16_c
-
-unsigned int aom_masked_sad16x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad16x32 aom_masked_sad16x32_c
-
-unsigned int aom_masked_sad16x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad16x8 aom_masked_sad16x8_c
-
-unsigned int aom_masked_sad32x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad32x16 aom_masked_sad32x16_c
-
-unsigned int aom_masked_sad32x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad32x32 aom_masked_sad32x32_c
-
-unsigned int aom_masked_sad32x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad32x64 aom_masked_sad32x64_c
-
-unsigned int aom_masked_sad4x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad4x4 aom_masked_sad4x4_c
-
-unsigned int aom_masked_sad4x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad4x8 aom_masked_sad4x8_c
-
-unsigned int aom_masked_sad64x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad64x32 aom_masked_sad64x32_c
-
-unsigned int aom_masked_sad64x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad64x64 aom_masked_sad64x64_c
-
-unsigned int aom_masked_sad8x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad8x16 aom_masked_sad8x16_c
-
-unsigned int aom_masked_sad8x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad8x4 aom_masked_sad8x4_c
-
-unsigned int aom_masked_sad8x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-#define aom_masked_sad8x8 aom_masked_sad8x8_c
-
-unsigned int aom_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance16x16 aom_masked_sub_pixel_variance16x16_c
-
-unsigned int aom_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance16x32 aom_masked_sub_pixel_variance16x32_c
-
-unsigned int aom_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance16x8 aom_masked_sub_pixel_variance16x8_c
-
-unsigned int aom_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance32x16 aom_masked_sub_pixel_variance32x16_c
-
-unsigned int aom_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance32x32 aom_masked_sub_pixel_variance32x32_c
-
-unsigned int aom_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance32x64 aom_masked_sub_pixel_variance32x64_c
-
-unsigned int aom_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance4x4 aom_masked_sub_pixel_variance4x4_c
-
-unsigned int aom_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance4x8 aom_masked_sub_pixel_variance4x8_c
-
-unsigned int aom_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance64x32 aom_masked_sub_pixel_variance64x32_c
-
-unsigned int aom_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance64x64 aom_masked_sub_pixel_variance64x64_c
-
-unsigned int aom_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance8x16 aom_masked_sub_pixel_variance8x16_c
-
-unsigned int aom_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance8x4 aom_masked_sub_pixel_variance8x4_c
-
-unsigned int aom_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-#define aom_masked_sub_pixel_variance8x8 aom_masked_sub_pixel_variance8x8_c
-
 void aom_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 void aom_minmax_8x8_neon(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 RTCD_EXTERN void (*aom_minmax_8x8)(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 
 unsigned int aom_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_mse16x16_neon(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 
@@ -2006,25 +2255,43 @@ unsigned int aom_obmc_variance8x4_c(cons
 #define aom_obmc_variance8x4 aom_obmc_variance8x4_c
 
 unsigned int aom_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 #define aom_obmc_variance8x8 aom_obmc_variance8x8_c
 
 void aom_paeth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_16x16 aom_paeth_predictor_16x16_c
 
+void aom_paeth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x32 aom_paeth_predictor_16x32_c
+
+void aom_paeth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x8 aom_paeth_predictor_16x8_c
+
 void aom_paeth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_2x2 aom_paeth_predictor_2x2_c
 
+void aom_paeth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_32x16 aom_paeth_predictor_32x16_c
+
 void aom_paeth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_32x32 aom_paeth_predictor_32x32_c
 
 void aom_paeth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_4x4 aom_paeth_predictor_4x4_c
 
+void aom_paeth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_4x8 aom_paeth_predictor_4x8_c
+
+void aom_paeth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x16 aom_paeth_predictor_8x16_c
+
+void aom_paeth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x4 aom_paeth_predictor_8x4_c
+
 void aom_paeth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_8x8 aom_paeth_predictor_8x8_c
 
 void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_quantize_b aom_quantize_b_c
 
 void aom_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_quantize_b_32x32 aom_quantize_b_32x32_c
@@ -2224,31 +2491,115 @@ void aom_scaled_avg_vert_c(const uint8_t
 #define aom_scaled_avg_vert aom_scaled_avg_vert_c
 
 void aom_scaled_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_horiz aom_scaled_horiz_c
 
 void aom_scaled_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_vert aom_scaled_vert_c
 
+void aom_smooth_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x16 aom_smooth_h_predictor_16x16_c
+
+void aom_smooth_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x32 aom_smooth_h_predictor_16x32_c
+
+void aom_smooth_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x8 aom_smooth_h_predictor_16x8_c
+
+void aom_smooth_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_2x2 aom_smooth_h_predictor_2x2_c
+
+void aom_smooth_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x16 aom_smooth_h_predictor_32x16_c
+
+void aom_smooth_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x32 aom_smooth_h_predictor_32x32_c
+
+void aom_smooth_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x4 aom_smooth_h_predictor_4x4_c
+
+void aom_smooth_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x8 aom_smooth_h_predictor_4x8_c
+
+void aom_smooth_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x16 aom_smooth_h_predictor_8x16_c
+
+void aom_smooth_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x4 aom_smooth_h_predictor_8x4_c
+
+void aom_smooth_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x8 aom_smooth_h_predictor_8x8_c
+
 void aom_smooth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_16x16 aom_smooth_predictor_16x16_c
 
+void aom_smooth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x32 aom_smooth_predictor_16x32_c
+
+void aom_smooth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x8 aom_smooth_predictor_16x8_c
+
 void aom_smooth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_2x2 aom_smooth_predictor_2x2_c
 
+void aom_smooth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_32x16 aom_smooth_predictor_32x16_c
+
 void aom_smooth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_32x32 aom_smooth_predictor_32x32_c
 
 void aom_smooth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_4x4 aom_smooth_predictor_4x4_c
 
+void aom_smooth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_4x8 aom_smooth_predictor_4x8_c
+
+void aom_smooth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x16 aom_smooth_predictor_8x16_c
+
+void aom_smooth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x4 aom_smooth_predictor_8x4_c
+
 void aom_smooth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_8x8 aom_smooth_predictor_8x8_c
 
+void aom_smooth_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x16 aom_smooth_v_predictor_16x16_c
+
+void aom_smooth_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x32 aom_smooth_v_predictor_16x32_c
+
+void aom_smooth_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x8 aom_smooth_v_predictor_16x8_c
+
+void aom_smooth_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_2x2 aom_smooth_v_predictor_2x2_c
+
+void aom_smooth_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x16 aom_smooth_v_predictor_32x16_c
+
+void aom_smooth_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x32 aom_smooth_v_predictor_32x32_c
+
+void aom_smooth_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x4 aom_smooth_v_predictor_4x4_c
+
+void aom_smooth_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x8 aom_smooth_v_predictor_4x8_c
+
+void aom_smooth_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x16 aom_smooth_v_predictor_8x16_c
+
+void aom_smooth_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x4 aom_smooth_v_predictor_8x4_c
+
+void aom_smooth_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x8 aom_smooth_v_predictor_8x8_c
+
 uint32_t aom_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 #define aom_sub_pixel_avg_variance16x16 aom_sub_pixel_avg_variance16x16_c
 
 uint32_t aom_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 #define aom_sub_pixel_avg_variance16x32 aom_sub_pixel_avg_variance16x32_c
 
 uint32_t aom_sub_pixel_avg_variance16x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 #define aom_sub_pixel_avg_variance16x8 aom_sub_pixel_avg_variance16x8_c
@@ -2331,34 +2682,52 @@ void aom_subtract_block_neon(int rows, i
 RTCD_EXTERN void (*aom_subtract_block)(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride);
 
 uint64_t aom_sum_squares_2d_i16_c(const int16_t *src, int stride, int width, int height);
 #define aom_sum_squares_2d_i16 aom_sum_squares_2d_i16_c
 
 uint64_t aom_sum_squares_i16_c(const int16_t *src, uint32_t N);
 #define aom_sum_squares_i16 aom_sum_squares_i16_c
 
-void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 #define aom_upsampled_pred aom_upsampled_pred_c
 
 void aom_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_16x16_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_v_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x32 aom_v_predictor_16x32_c
+
+void aom_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x8 aom_v_predictor_16x8_c
+
 void aom_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_2x2 aom_v_predictor_2x2_c
 
+void aom_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_32x16 aom_v_predictor_32x16_c
+
 void aom_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_32x32_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_v_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_4x4_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_v_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_4x8 aom_v_predictor_4x8_c
+
+void aom_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x16 aom_v_predictor_8x16_c
+
+void aom_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x4 aom_v_predictor_8x4_c
+
 void aom_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_8x8_neon(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_v_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 unsigned int aom_variance16x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 unsigned int aom_variance16x16_neon(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_variance16x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 
--- a/media/libaom/config/linux/arm/av1_rtcd.h
+++ b/media/libaom/config/linux/arm/av1_rtcd.h
@@ -13,22 +13,25 @@
 
 #include "aom/aom_integer.h"
 #include "av1/common/common.h"
 #include "av1/common/enums.h"
 #include "av1/common/quant_common.h"
 #include "av1/common/filter.h"
 #include "av1/common/convolve.h"
 #include "av1/common/av1_txfm.h"
+#include "av1/common/idct.h"
 #include "av1/common/odintrin.h"
 
 struct macroblockd;
 
 /* Encoder forward decls */
 struct macroblock;
+struct fwd_txfm_param;
+struct inv_txfm_param;
 struct aom_variance_vtable;
 struct search_site_config;
 struct mv;
 union int_mv;
 struct yv12_buffer_config;
 typedef uint16_t od_dering_in;
 
 #ifdef __cplusplus
@@ -61,79 +64,97 @@ void av1_convolve_vert_c(const uint8_t *
 #define av1_convolve_vert av1_convolve_vert_c
 
 int av1_diamond_search_sad_c(struct macroblock *x, const struct search_site_config *cfg,  struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_diamond_search_sad av1_diamond_search_sad_c
 
 void av1_fdct8x8_quant_c(const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define av1_fdct8x8_quant av1_fdct8x8_quant_c
 
-void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x16 av1_fht16x16_c
 
-void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x32 av1_fht16x32_c
 
-void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x4 av1_fht16x4_c
 
-void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x8 av1_fht16x8_c
 
-void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x16 av1_fht32x16_c
 
-void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x32 av1_fht32x32_c
 
-void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x8 av1_fht32x8_c
 
-void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x16 av1_fht4x16_c
 
-void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x4 av1_fht4x4_c
 
-void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x8 av1_fht4x8_c
 
-void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x16 av1_fht8x16_c
 
-void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x32 av1_fht8x32_c
 
-void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x4 av1_fht8x4_c
 
-void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x8 av1_fht8x8_c
 
 int av1_full_range_search_c(const struct macroblock *x, const struct search_site_config *cfg, struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_full_range_search av1_full_range_search_c
 
 int av1_full_search_sad_c(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 #define av1_full_search_sad av1_full_search_sad_c
 
 void av1_fwd_idtx_c(const int16_t *src_diff, tran_low_t *coeff, int stride, int bs, int tx_type);
 #define av1_fwd_idtx av1_fwd_idtx_c
 
 void av1_fwd_txfm2d_16x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 #define av1_fwd_txfm2d_16x16 av1_fwd_txfm2d_16x16_c
 
+void av1_fwd_txfm2d_16x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x32 av1_fwd_txfm2d_16x32_c
+
+void av1_fwd_txfm2d_16x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x8 av1_fwd_txfm2d_16x8_c
+
+void av1_fwd_txfm2d_32x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_32x16 av1_fwd_txfm2d_32x16_c
+
 void av1_fwd_txfm2d_32x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 #define av1_fwd_txfm2d_32x32 av1_fwd_txfm2d_32x32_c
 
 void av1_fwd_txfm2d_4x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 #define av1_fwd_txfm2d_4x4 av1_fwd_txfm2d_4x4_c
 
+void av1_fwd_txfm2d_4x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_4x8 av1_fwd_txfm2d_4x8_c
+
 void av1_fwd_txfm2d_64x64_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 #define av1_fwd_txfm2d_64x64 av1_fwd_txfm2d_64x64_c
 
+void av1_fwd_txfm2d_8x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x16 av1_fwd_txfm2d_8x16_c
+
+void av1_fwd_txfm2d_8x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x4 av1_fwd_txfm2d_8x4_c
+
 void av1_fwd_txfm2d_8x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 #define av1_fwd_txfm2d_8x8 av1_fwd_txfm2d_8x8_c
 
 void av1_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_fwht4x4 av1_fwht4x4_c
 
 int64_t av1_highbd_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd);
 #define av1_highbd_block_error av1_highbd_block_error_c
@@ -166,166 +187,139 @@ void av1_highbd_convolve_horiz_c(const u
 #define av1_highbd_convolve_horiz av1_highbd_convolve_horiz_c
 
 void av1_highbd_convolve_init_c(void);
 #define av1_highbd_convolve_init av1_highbd_convolve_init_c
 
 void av1_highbd_convolve_vert_c(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 #define av1_highbd_convolve_vert av1_highbd_convolve_vert_c
 
-void av1_highbd_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x16 av1_highbd_fht16x16_c
-
-void av1_highbd_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x32 av1_highbd_fht16x32_c
-
-void av1_highbd_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x4 av1_highbd_fht16x4_c
-
-void av1_highbd_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x8 av1_highbd_fht16x8_c
-
-void av1_highbd_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x16 av1_highbd_fht32x16_c
-
-void av1_highbd_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x32 av1_highbd_fht32x32_c
-
-void av1_highbd_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x8 av1_highbd_fht32x8_c
-
-void av1_highbd_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x16 av1_highbd_fht4x16_c
-
-void av1_highbd_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x4 av1_highbd_fht4x4_c
-
-void av1_highbd_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x8 av1_highbd_fht4x8_c
-
-void av1_highbd_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x16 av1_highbd_fht8x16_c
-
-void av1_highbd_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x32 av1_highbd_fht8x32_c
-
-void av1_highbd_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x4 av1_highbd_fht8x4_c
-
-void av1_highbd_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x8 av1_highbd_fht8x8_c
-
 void av1_highbd_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_highbd_fwht4x4 av1_highbd_fwht4x4_c
 
-void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type, int bd);
+void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x16_256_add av1_highbd_iht16x16_256_add_c
 
-void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x32_512_add av1_highbd_iht16x32_512_add_c
 
-void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x4_64_add av1_highbd_iht16x4_64_add_c
 
-void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x8_128_add av1_highbd_iht16x8_128_add_c
 
-void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x16_512_add av1_highbd_iht32x16_512_add_c
 
-void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x8_256_add av1_highbd_iht32x8_256_add_c
 
-void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x16_64_add av1_highbd_iht4x16_64_add_c
 
-void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x4_16_add av1_highbd_iht4x4_16_add_c
 
-void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x8_32_add av1_highbd_iht4x8_32_add_c
 
-void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x16_128_add av1_highbd_iht8x16_128_add_c
 
-void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x32_256_add av1_highbd_iht8x32_256_add_c
 
-void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x4_32_add av1_highbd_iht8x4_32_add_c
 
-void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x8_64_add av1_highbd_iht8x8_64_add_c
 
 void av1_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_highbd_quantize_b av1_highbd_quantize_b_c
 
 void av1_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_highbd_quantize_fp av1_highbd_quantize_fp_c
 
 void av1_highbd_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 #define av1_highbd_temporal_filter_apply av1_highbd_temporal_filter_apply_c
 
-void av1_highbd_warp_affine_c(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-#define av1_highbd_warp_affine av1_highbd_warp_affine_c
-
-void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
+void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_iht16x16_256_add av1_iht16x16_256_add_c
 
-void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x32_512_add av1_iht16x32_512_add_c
 
-void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x4_64_add av1_iht16x4_64_add_c
 
-void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x8_128_add av1_iht16x8_128_add_c
 
-void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht32x16_512_add av1_iht32x16_512_add_c
 
-void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
+void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_iht32x32_1024_add av1_iht32x32_1024_add_c
 
-void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht32x8_256_add av1_iht32x8_256_add_c
 
-void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x16_64_add av1_iht4x16_64_add_c
 
-void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x4_16_add av1_iht4x4_16_add_c
 
-void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x8_32_add av1_iht4x8_32_add_c
 
-void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x16_128_add av1_iht8x16_128_add_c
 
-void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x32_256_add av1_iht8x32_256_add_c
 
-void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x4_32_add av1_iht8x4_32_add_c
 
-void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x8_64_add av1_iht8x8_64_add_c
 
 void av1_inv_txfm2d_add_16x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_16x16 av1_inv_txfm2d_add_16x16_c
 
+void av1_inv_txfm2d_add_16x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x32 av1_inv_txfm2d_add_16x32_c
+
+void av1_inv_txfm2d_add_16x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x8 av1_inv_txfm2d_add_16x8_c
+
+void av1_inv_txfm2d_add_32x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_32x16 av1_inv_txfm2d_add_32x16_c
+
 void av1_inv_txfm2d_add_32x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_32x32 av1_inv_txfm2d_add_32x32_c
 
 void av1_inv_txfm2d_add_4x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_4x4 av1_inv_txfm2d_add_4x4_c
 
+void av1_inv_txfm2d_add_4x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_4x8 av1_inv_txfm2d_add_4x8_c
+
 void av1_inv_txfm2d_add_64x64_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_64x64 av1_inv_txfm2d_add_64x64_c
 
+void av1_inv_txfm2d_add_8x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x16 av1_inv_txfm2d_add_8x16_c
+
+void av1_inv_txfm2d_add_8x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x4 av1_inv_txfm2d_add_8x4_c
+
 void av1_inv_txfm2d_add_8x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_8x8 av1_inv_txfm2d_add_8x8_c
 
 void av1_lowbd_convolve_init_c(void);
 #define av1_lowbd_convolve_init av1_lowbd_convolve_init_c
 
 void av1_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_quantize_b av1_quantize_b_c
@@ -334,31 +328,16 @@ void av1_quantize_fp_c(const tran_low_t 
 #define av1_quantize_fp av1_quantize_fp_c
 
 void av1_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define av1_quantize_fp_32x32 av1_quantize_fp_32x32_c
 
 void av1_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 #define av1_temporal_filter_apply av1_temporal_filter_apply_c
 
-void av1_warp_affine_c(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-#define av1_warp_affine av1_warp_affine_c
-
-void av1_wedge_compute_delta_squares_c(int16_t *d, const int16_t *a, const int16_t *b, int N);
-#define av1_wedge_compute_delta_squares av1_wedge_compute_delta_squares_c
-
-int av1_wedge_sign_from_residuals_c(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-#define av1_wedge_sign_from_residuals av1_wedge_sign_from_residuals_c
-
-uint64_t av1_wedge_sse_from_residuals_c(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-#define av1_wedge_sse_from_residuals av1_wedge_sse_from_residuals_c
-
-double compute_cross_correlation_c(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-#define compute_cross_correlation compute_cross_correlation_c
-
 void copy_4x4_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_neon(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 RTCD_EXTERN void (*copy_4x4_16bit_to_16bit)(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 
 void copy_4x4_16bit_to_8bit_c(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_8bit_neon(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
 RTCD_EXTERN void (*copy_4x4_16bit_to_8bit)(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
 
--- a/media/libaom/config/linux/ia32/aom_config.asm
+++ b/media/libaom/config/linux/ia32/aom_config.asm
@@ -60,60 +60,63 @@
 %define CONFIG_INSPECTION 0
 %define CONFIG_DECODE_PERF_TESTS 0
 %define CONFIG_ENCODE_PERF_TESTS 0
 %define CONFIG_COEFFICIENT_RANGE_CHECKING 0
 %define CONFIG_LOWBITDEPTH 1
 %define CONFIG_HIGHBITDEPTH 1
 %define CONFIG_EXPERIMENTAL 0
 %define CONFIG_SIZE_LIMIT 1
+%define CONFIG_COLORSPACE_HEADERS 0
 %define CONFIG_FP_MB_STATS 0
 %define CONFIG_CDEF 1
 %define CONFIG_VAR_TX 1
 %define CONFIG_RECT_TX 1
 %define CONFIG_RECT_TX_EXT 0
 %define CONFIG_TPL_MV 0
-%define CONFIG_DUAL_FILTER 1
+%define CONFIG_DUAL_FILTER 0
 %define CONFIG_CONVOLVE_ROUND 0
 %define CONFIG_COMPOUND_ROUND 0
-%define CONFIG_EXT_TX 1
+%define CONFIG_EXT_TX 0
 %define CONFIG_DPCM_INTRA 0
 %define CONFIG_TX64X64 0
 %define CONFIG_EXT_INTRA 1
 %define CONFIG_INTRA_INTERP 0
 %define CONFIG_FILTER_INTRA 0
 %define CONFIG_INTRA_EDGE 0
 %define CONFIG_INTRABC 0
-%define CONFIG_EXT_INTER 1
-%define CONFIG_INTERINTRA 1
-%define CONFIG_WEDGE 1
-%define CONFIG_COMPOUND_SEGMENT 1
-%define CONFIG_EXT_REFS 1
-%define CONFIG_GLOBAL_MOTION 1
+%define CONFIG_EXT_INTER 0
+%define CONFIG_INTERINTRA 0
+%define CONFIG_WEDGE 0
+%define CONFIG_COMPOUND_SEGMENT 0
+%define CONFIG_EXT_REFS 0
+%define CONFIG_SPEED_REFS 0
+%define CONFIG_GF_GROUPS 0
+%define CONFIG_GLOBAL_MOTION 0
 %define CONFIG_NEW_QUANT 0
 %define CONFIG_SUPERTX 0
 %define CONFIG_ANS 0
 %define CONFIG_LOOP_RESTORATION 0
 %define CONFIG_EXT_PARTITION 0
 %define CONFIG_EXT_PARTITION_TYPES 0
 %define CONFIG_UNPOISON_PARTITION_CTX 0
 %define CONFIG_EXT_TILE 0
 %define CONFIG_MOTION_VAR 1
 %define CONFIG_NCOBMC 0
-%define CONFIG_WARPED_MOTION 1
+%define CONFIG_WARPED_MOTION 0
 %define CONFIG_Q_ADAPT_PROBS 0
 %define CONFIG_BITSTREAM_DEBUG 0
 %define CONFIG_ALT_INTRA 1
 %define CONFIG_PALETTE 1
 %define CONFIG_PALETTE_DELTA_ENCODING 0
 %define CONFIG_RAWBITS 0
 %define CONFIG_EC_SMALLMUL 1
 %define CONFIG_PVQ 0
 %define CONFIG_CFL 0
-%define CONFIG_XIPHRC 0
+%define CONFIG_XIPHRC 1
 %define CONFIG_CB4X4 1
 %define CONFIG_CHROMA_2X2 0
 %define CONFIG_CHROMA_SUB8X8 1
 %define CONFIG_FRAME_SIZE 0
 %define CONFIG_DELTA_Q 1
 %define CONFIG_EXT_DELTA_Q 1
 %define CONFIG_ADAPT_SCAN 0
 %define CONFIG_FILTER_7BIT 1
@@ -136,11 +139,18 @@
 %define CONFIG_LV_MAP 0
 %define CONFIG_TXK_SEL 0
 %define CONFIG_MV_COMPRESS 1
 %define CONFIG_FRAME_SUPERRES 0
 %define CONFIG_NEW_MULTISYMBOL 0
 %define CONFIG_COMPOUND_SINGLEREF 0
 %define CONFIG_AOM_QM 0
 %define CONFIG_ONE_SIDED_COMPOUND 1
-%define CONFIG_SMOOTH_HV 0
+%define CONFIG_EXT_COMP_REFS 0
+%define CONFIG_SMOOTH_HV 1
 %define CONFIG_VAR_REFS 0
+%define CONFIG_RECT_INTRA_PRED 0
+%define CONFIG_LGT 0
+%define CONFIG_SBL_SYMBOL 0
+%define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+%define CONFIG_BGSPRITE 0
+%define CONFIG_VAR_TX_NO_TX_MODE 0
 %define CONFIG_ANALYZER 0
--- a/media/libaom/config/linux/ia32/aom_config.h
+++ b/media/libaom/config/linux/ia32/aom_config.h
@@ -4,17 +4,17 @@
 /* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License */
 /* was not distributed with this source code in the LICENSE file, you can */
 /* obtain it at www.aomedia.org/license/software. If the Alliance for Open */
 /* Media Patent License 1.0 was not distributed with this source code in the */
 /* PATENTS file, you can obtain it at www.aomedia.org/license/patent. */
 /* This file automatically generated by configure. Do not edit! */
 #ifndef AOM_CONFIG_H
 #define AOM_CONFIG_H
-#define RESTRICT
+#define RESTRICT    
 #define INLINE      inline
 #define ARCH_ARM 0
 #define ARCH_MIPS 0
 #define ARCH_X86 1
 #define ARCH_X86_64 0
 #define HAVE_NEON 0
 #define HAVE_NEON_ASM 0
 #define HAVE_MIPS32 0
@@ -73,60 +73,63 @@
 #define CONFIG_INSPECTION 0
 #define CONFIG_DECODE_PERF_TESTS 0
 #define CONFIG_ENCODE_PERF_TESTS 0
 #define CONFIG_COEFFICIENT_RANGE_CHECKING 0
 #define CONFIG_LOWBITDEPTH 1
 #define CONFIG_HIGHBITDEPTH 1
 #define CONFIG_EXPERIMENTAL 0
 #define CONFIG_SIZE_LIMIT 1
+#define CONFIG_COLORSPACE_HEADERS 0
 #define CONFIG_FP_MB_STATS 0
 #define CONFIG_CDEF 1
 #define CONFIG_VAR_TX 1
 #define CONFIG_RECT_TX 1
 #define CONFIG_RECT_TX_EXT 0
 #define CONFIG_TPL_MV 0
-#define CONFIG_DUAL_FILTER 1
+#define CONFIG_DUAL_FILTER 0
 #define CONFIG_CONVOLVE_ROUND 0
 #define CONFIG_COMPOUND_ROUND 0
-#define CONFIG_EXT_TX 1
+#define CONFIG_EXT_TX 0
 #define CONFIG_DPCM_INTRA 0
 #define CONFIG_TX64X64 0
 #define CONFIG_EXT_INTRA 1
 #define CONFIG_INTRA_INTERP 0
 #define CONFIG_FILTER_INTRA 0
 #define CONFIG_INTRA_EDGE 0
 #define CONFIG_INTRABC 0
-#define CONFIG_EXT_INTER 1
-#define CONFIG_INTERINTRA 1
-#define CONFIG_WEDGE 1
-#define CONFIG_COMPOUND_SEGMENT 1
-#define CONFIG_EXT_REFS 1
-#define CONFIG_GLOBAL_MOTION 1
+#define CONFIG_EXT_INTER 0
+#define CONFIG_INTERINTRA 0
+#define CONFIG_WEDGE 0
+#define CONFIG_COMPOUND_SEGMENT 0
+#define CONFIG_EXT_REFS 0
+#define CONFIG_SPEED_REFS 0
+#define CONFIG_GF_GROUPS 0
+#define CONFIG_GLOBAL_MOTION 0
 #define CONFIG_NEW_QUANT 0
 #define CONFIG_SUPERTX 0
 #define CONFIG_ANS 0
 #define CONFIG_LOOP_RESTORATION 0
 #define CONFIG_EXT_PARTITION 0
 #define CONFIG_EXT_PARTITION_TYPES 0
 #define CONFIG_UNPOISON_PARTITION_CTX 0
 #define CONFIG_EXT_TILE 0
 #define CONFIG_MOTION_VAR 1
 #define CONFIG_NCOBMC 0
-#define CONFIG_WARPED_MOTION 1
+#define CONFIG_WARPED_MOTION 0
 #define CONFIG_Q_ADAPT_PROBS 0
 #define CONFIG_BITSTREAM_DEBUG 0
 #define CONFIG_ALT_INTRA 1
 #define CONFIG_PALETTE 1
 #define CONFIG_PALETTE_DELTA_ENCODING 0
 #define CONFIG_RAWBITS 0
 #define CONFIG_EC_SMALLMUL 1
 #define CONFIG_PVQ 0
 #define CONFIG_CFL 0
-#define CONFIG_XIPHRC 0
+#define CONFIG_XIPHRC 1
 #define CONFIG_CB4X4 1
 #define CONFIG_CHROMA_2X2 0
 #define CONFIG_CHROMA_SUB8X8 1
 #define CONFIG_FRAME_SIZE 0
 #define CONFIG_DELTA_Q 1
 #define CONFIG_EXT_DELTA_Q 1
 #define CONFIG_ADAPT_SCAN 0
 #define CONFIG_FILTER_7BIT 1
@@ -149,14 +152,21 @@
 #define CONFIG_LV_MAP 0
 #define CONFIG_TXK_SEL 0
 #define CONFIG_MV_COMPRESS 1
 #define CONFIG_FRAME_SUPERRES 0
 #define CONFIG_NEW_MULTISYMBOL 0
 #define CONFIG_COMPOUND_SINGLEREF 0
 #define CONFIG_AOM_QM 0
 #define CONFIG_ONE_SIDED_COMPOUND 1
-#define CONFIG_SMOOTH_HV 0
+#define CONFIG_EXT_COMP_REFS 0
+#define CONFIG_SMOOTH_HV 1
 #define CONFIG_VAR_REFS 0
+#define CONFIG_RECT_INTRA_PRED 0
+#define CONFIG_LGT 0
+#define CONFIG_SBL_SYMBOL 0
+#define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+#define CONFIG_BGSPRITE 0
+#define CONFIG_VAR_TX_NO_TX_MODE 0
 #define CONFIG_ANALYZER 0
 #define DECODE_WIDTH_LIMIT 8192
 #define DECODE_HEIGHT_LIMIT 4608
 #endif /* AOM_CONFIG_H */
--- a/media/libaom/config/linux/ia32/aom_dsp_rtcd.h
+++ b/media/libaom/config/linux/ia32/aom_dsp_rtcd.h
@@ -30,25 +30,19 @@ RTCD_EXTERN void (*aom_blend_a64_mask)(u
 
 void aom_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 void aom_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 RTCD_EXTERN void (*aom_blend_a64_vmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 
 void aom_comp_avg_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
 #define aom_comp_avg_pred aom_comp_avg_pred_c
 
-void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
-void aom_comp_avg_upsampled_pred_sse2(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
-RTCD_EXTERN void (*aom_comp_avg_upsampled_pred)(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
-
-void aom_comp_mask_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_pred aom_comp_mask_pred_c
-
-void aom_comp_mask_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_upsampled_pred aom_comp_mask_upsampled_pred_c
+void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+void aom_comp_avg_upsampled_pred_sse2(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+RTCD_EXTERN void (*aom_comp_avg_upsampled_pred)(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 
 void aom_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
@@ -56,231 +50,419 @@ void aom_convolve8_avg_sse2(const uint8_
 void aom_convolve8_avg_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_horiz_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_horiz_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_avg_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_horiz_scale aom_convolve8_avg_horiz_scale_c
+
+void aom_convolve8_avg_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_scale aom_convolve8_avg_scale_c
+
 void aom_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_vert_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_vert_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_avg_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_vert_scale aom_convolve8_avg_vert_scale_c
+
 void aom_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_horiz_scale aom_convolve8_horiz_scale_c
+
+void aom_convolve8_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_scale aom_convolve8_scale_c
+
 void aom_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_vert_scale aom_convolve8_vert_scale_c
+
 void aom_convolve_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve_copy_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve_copy)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_d117_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_16x16 aom_d117_predictor_16x16_c
 
+void aom_d117_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x32 aom_d117_predictor_16x32_c
+
+void aom_d117_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x8 aom_d117_predictor_16x8_c
+
 void aom_d117_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_2x2 aom_d117_predictor_2x2_c
 
+void aom_d117_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_32x16 aom_d117_predictor_32x16_c
+
 void aom_d117_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_32x32 aom_d117_predictor_32x32_c
 
 void aom_d117_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_4x4 aom_d117_predictor_4x4_c
 
+void aom_d117_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_4x8 aom_d117_predictor_4x8_c
+
+void aom_d117_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x16 aom_d117_predictor_8x16_c
+
+void aom_d117_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x4 aom_d117_predictor_8x4_c
+
 void aom_d117_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_8x8 aom_d117_predictor_8x8_c
 
 void aom_d135_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_16x16 aom_d135_predictor_16x16_c
 
+void aom_d135_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x32 aom_d135_predictor_16x32_c
+
+void aom_d135_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x8 aom_d135_predictor_16x8_c
+
 void aom_d135_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_2x2 aom_d135_predictor_2x2_c
 
+void aom_d135_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_32x16 aom_d135_predictor_32x16_c
+
 void aom_d135_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_32x32 aom_d135_predictor_32x32_c
 
 void aom_d135_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_4x4 aom_d135_predictor_4x4_c
 
+void aom_d135_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_4x8 aom_d135_predictor_4x8_c
+
+void aom_d135_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x16 aom_d135_predictor_8x16_c
+
+void aom_d135_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x4 aom_d135_predictor_8x4_c
+
 void aom_d135_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_8x8 aom_d135_predictor_8x8_c
 
 void aom_d153_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_16x16_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d153_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x32 aom_d153_predictor_16x32_c
+
+void aom_d153_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x8 aom_d153_predictor_16x8_c
+
 void aom_d153_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_2x2 aom_d153_predictor_2x2_c
 
+void aom_d153_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_32x16 aom_d153_predictor_32x16_c
+
 void aom_d153_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_32x32_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_d153_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d153_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_4x8 aom_d153_predictor_4x8_c
+
+void aom_d153_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x16 aom_d153_predictor_8x16_c
+
+void aom_d153_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x4 aom_d153_predictor_8x4_c
+
 void aom_d153_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_8x8_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_d207e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_16x16 aom_d207e_predictor_16x16_c
 
+void aom_d207e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x32 aom_d207e_predictor_16x32_c
+
+void aom_d207e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x8 aom_d207e_predictor_16x8_c
+
 void aom_d207e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_2x2 aom_d207e_predictor_2x2_c
 
+void aom_d207e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_32x16 aom_d207e_predictor_32x16_c
+
 void aom_d207e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_32x32 aom_d207e_predictor_32x32_c
 
 void aom_d207e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_4x4 aom_d207e_predictor_4x4_c
 
+void aom_d207e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_4x8 aom_d207e_predictor_4x8_c
+
+void aom_d207e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x16 aom_d207e_predictor_8x16_c
+
+void aom_d207e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x4 aom_d207e_predictor_8x4_c
+
 void aom_d207e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_8x8 aom_d207e_predictor_8x8_c
 
 void aom_d45e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_16x16 aom_d45e_predictor_16x16_c
 
+void aom_d45e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x32 aom_d45e_predictor_16x32_c
+
+void aom_d45e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x8 aom_d45e_predictor_16x8_c
+
 void aom_d45e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_2x2 aom_d45e_predictor_2x2_c
 
+void aom_d45e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_32x16 aom_d45e_predictor_32x16_c
+
 void aom_d45e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_32x32 aom_d45e_predictor_32x32_c
 
 void aom_d45e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_4x4 aom_d45e_predictor_4x4_c
 
+void aom_d45e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_4x8 aom_d45e_predictor_4x8_c
+
+void aom_d45e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x16 aom_d45e_predictor_8x16_c
+
+void aom_d45e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x4 aom_d45e_predictor_8x4_c
+
 void aom_d45e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_8x8 aom_d45e_predictor_8x8_c
 
 void aom_d63e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_16x16 aom_d63e_predictor_16x16_c
 
+void aom_d63e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x32 aom_d63e_predictor_16x32_c
+
+void aom_d63e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x8 aom_d63e_predictor_16x8_c
+
 void aom_d63e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_2x2 aom_d63e_predictor_2x2_c
 
+void aom_d63e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_32x16 aom_d63e_predictor_32x16_c
+
 void aom_d63e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_32x32 aom_d63e_predictor_32x32_c
 
 void aom_d63e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d63e_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d63e_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d63e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_4x8 aom_d63e_predictor_4x8_c
+
+void aom_d63e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x16 aom_d63e_predictor_8x16_c
+
+void aom_d63e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x4 aom_d63e_predictor_8x4_c
+
 void aom_d63e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_8x8 aom_d63e_predictor_8x8_c
 
 void aom_dc_128_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_128_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_128_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x32 aom_dc_128_predictor_16x32_c
+
+void aom_dc_128_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x8 aom_dc_128_predictor_16x8_c
+
 void aom_dc_128_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_2x2 aom_dc_128_predictor_2x2_c
 
+void aom_dc_128_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_32x16 aom_dc_128_predictor_32x16_c
+
 void aom_dc_128_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_128_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_128_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_128_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_128_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_4x8 aom_dc_128_predictor_4x8_c
+
+void aom_dc_128_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x16 aom_dc_128_predictor_8x16_c
+
+void aom_dc_128_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x4 aom_dc_128_predictor_8x4_c
+
 void aom_dc_128_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_128_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_left_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_left_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_left_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x32 aom_dc_left_predictor_16x32_c
+
+void aom_dc_left_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x8 aom_dc_left_predictor_16x8_c
+
 void aom_dc_left_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_2x2 aom_dc_left_predictor_2x2_c
 
+void aom_dc_left_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_32x16 aom_dc_left_predictor_32x16_c
+
 void aom_dc_left_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_left_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_left_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_left_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_left_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_4x8 aom_dc_left_predictor_4x8_c
+
+void aom_dc_left_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x16 aom_dc_left_predictor_8x16_c
+
+void aom_dc_left_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x4 aom_dc_left_predictor_8x4_c
+
 void aom_dc_left_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_left_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x32 aom_dc_predictor_16x32_c
+
+void aom_dc_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x8 aom_dc_predictor_16x8_c
+
 void aom_dc_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_2x2 aom_dc_predictor_2x2_c
 
+void aom_dc_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_32x16 aom_dc_predictor_32x16_c
+
 void aom_dc_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_4x8 aom_dc_predictor_4x8_c
+
+void aom_dc_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x16 aom_dc_predictor_8x16_c
+
+void aom_dc_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x4 aom_dc_predictor_8x4_c
+
 void aom_dc_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_top_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_top_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_top_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x32 aom_dc_top_predictor_16x32_c
+
+void aom_dc_top_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x8 aom_dc_top_predictor_16x8_c
+
 void aom_dc_top_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_2x2 aom_dc_top_predictor_2x2_c
 
+void aom_dc_top_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_32x16 aom_dc_top_predictor_32x16_c
+
 void aom_dc_top_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_top_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_top_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_top_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_top_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_4x8 aom_dc_top_predictor_4x8_c
+
+void aom_dc_top_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x16 aom_dc_top_predictor_8x16_c
+
+void aom_dc_top_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x4 aom_dc_top_predictor_8x4_c
+
 void aom_dc_top_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_top_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct16x16_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct16x16)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct16x16_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct16x16_1_avx2(const int16_t *input, tran_low_t *output, int stride);
-RTCD_EXTERN void (*aom_fdct16x16_1)(const int16_t *input, tran_low_t *output, int stride);
-
 void aom_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_avx2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct32x32)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct32x32_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct32x32_1_avx2(const int16_t *input, tran_low_t *output, int stride);
-RTCD_EXTERN void (*aom_fdct32x32_1)(const int16_t *input, tran_low_t *output, int stride);
-
 void aom_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_rd_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_rd_avx2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct32x32_rd)(const int16_t *input, tran_low_t *output, int stride);
 
 void aom_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct4x4_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct4x4)(const int16_t *input, tran_low_t *output, int stride);
@@ -288,20 +470,16 @@ RTCD_EXTERN void (*aom_fdct4x4)(const in
 void aom_fdct4x4_1_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct4x4_1_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct4x4_1)(const int16_t *input, tran_low_t *output, int stride);
 
 void aom_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct8x8_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct8x8)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct8x8_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-RTCD_EXTERN void (*aom_fdct8x8_1)(const int16_t *input, tran_low_t *output, int stride);
-
 void aom_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 void aom_get16x16var_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 void aom_get16x16var_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 RTCD_EXTERN void (*aom_get16x16var)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 
 unsigned int aom_get4x4sse_cs_c(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int ref_stride);
 #define aom_get4x4sse_cs aom_get4x4sse_cs_c
 
@@ -312,27 +490,45 @@ RTCD_EXTERN void (*aom_get8x8var)(const 
 unsigned int aom_get_mb_ss_c(const int16_t *);
 unsigned int aom_get_mb_ss_sse2(const int16_t *);
 RTCD_EXTERN unsigned int (*aom_get_mb_ss)(const int16_t *);
 
 void aom_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_h_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x32 aom_h_predictor_16x32_c
+
+void aom_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x8 aom_h_predictor_16x8_c
+
 void aom_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_2x2 aom_h_predictor_2x2_c
 
+void aom_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_32x16 aom_h_predictor_32x16_c
+
 void aom_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_h_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_h_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_4x8 aom_h_predictor_4x8_c
+
+void aom_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x16 aom_h_predictor_8x16_c
+
+void aom_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x4 aom_h_predictor_8x4_c
+
 void aom_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_h_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_hadamard_16x16_c(const int16_t *src_diff, int src_stride, int16_t *coeff);
 void aom_hadamard_16x16_sse2(const int16_t *src_diff, int src_stride, int16_t *coeff);
 RTCD_EXTERN void (*aom_hadamard_16x16)(const int16_t *src_diff, int src_stride, int16_t *coeff);
 
@@ -341,68 +537,16 @@ void aom_hadamard_8x8_sse2(const int16_t
 RTCD_EXTERN void (*aom_hadamard_8x8)(const int16_t *src_diff, int src_stride, int16_t *coeff);
 
 void aom_highbd_10_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get16x16var aom_highbd_10_get16x16var_c
 
 void aom_highbd_10_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get8x8var aom_highbd_10_get8x8var_c
 
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_10_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_10_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_highbd_10_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 
 unsigned int aom_highbd_10_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse16x8 aom_highbd_10_mse16x8_c
 
 unsigned int aom_highbd_10_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -665,68 +809,16 @@ unsigned int aom_highbd_10_variance8x8_s
 RTCD_EXTERN unsigned int (*aom_highbd_10_variance8x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 
 void aom_highbd_12_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get16x16var aom_highbd_12_get16x16var_c
 
 void aom_highbd_12_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get8x8var aom_highbd_12_get8x8var_c
 
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_12_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_12_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_highbd_12_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 
 unsigned int aom_highbd_12_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse16x8 aom_highbd_12_mse16x8_c
 
 unsigned int aom_highbd_12_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -989,68 +1081,16 @@ unsigned int aom_highbd_12_variance8x8_s
 RTCD_EXTERN unsigned int (*aom_highbd_12_variance8x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 
 void aom_highbd_8_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get16x16var aom_highbd_8_get16x16var_c
 
 void aom_highbd_8_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get8x8var aom_highbd_8_get8x8var_c
 
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_8_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_8_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_highbd_8_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 
 unsigned int aom_highbd_8_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse16x8 aom_highbd_8_mse16x8_c
 
 unsigned int aom_highbd_8_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -1231,25 +1271,19 @@ RTCD_EXTERN void (*aom_highbd_blend_a64_
 
 void aom_highbd_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 void aom_highbd_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 RTCD_EXTERN void (*aom_highbd_blend_a64_vmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 
 void aom_highbd_comp_avg_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
 #define aom_highbd_comp_avg_pred aom_highbd_comp_avg_pred_c
 
-void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
-void aom_highbd_comp_avg_upsampled_pred_sse2(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
-RTCD_EXTERN void (*aom_highbd_comp_avg_upsampled_pred)(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
-
-void aom_highbd_comp_mask_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_pred aom_highbd_comp_mask_pred_c
-
-void aom_highbd_comp_mask_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_upsampled_pred aom_highbd_comp_mask_upsampled_pred_c
+void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+void aom_highbd_comp_avg_upsampled_pred_sse2(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+RTCD_EXTERN void (*aom_highbd_comp_avg_upsampled_pred)(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 
 void aom_highbd_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 RTCD_EXTERN void (*aom_highbd_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 
 void aom_highbd_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avg_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 RTCD_EXTERN void (*aom_highbd_convolve8_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
@@ -1278,233 +1312,400 @@ RTCD_EXTERN void (*aom_highbd_convolve_a
 void aom_highbd_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve_copy_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve_copy_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 RTCD_EXTERN void (*aom_highbd_convolve_copy)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 
 void aom_highbd_d117_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_16x16 aom_highbd_d117_predictor_16x16_c
 
+void aom_highbd_d117_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x32 aom_highbd_d117_predictor_16x32_c
+
+void aom_highbd_d117_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x8 aom_highbd_d117_predictor_16x8_c
+
 void aom_highbd_d117_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_2x2 aom_highbd_d117_predictor_2x2_c
 
+void aom_highbd_d117_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_32x16 aom_highbd_d117_predictor_32x16_c
+
 void aom_highbd_d117_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_32x32 aom_highbd_d117_predictor_32x32_c
 
 void aom_highbd_d117_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_4x4 aom_highbd_d117_predictor_4x4_c
 
+void aom_highbd_d117_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_4x8 aom_highbd_d117_predictor_4x8_c
+
+void aom_highbd_d117_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x16 aom_highbd_d117_predictor_8x16_c
+
+void aom_highbd_d117_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x4 aom_highbd_d117_predictor_8x4_c
+
 void aom_highbd_d117_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_8x8 aom_highbd_d117_predictor_8x8_c
 
 void aom_highbd_d135_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_16x16 aom_highbd_d135_predictor_16x16_c
 
+void aom_highbd_d135_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x32 aom_highbd_d135_predictor_16x32_c
+
+void aom_highbd_d135_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x8 aom_highbd_d135_predictor_16x8_c
+
 void aom_highbd_d135_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_2x2 aom_highbd_d135_predictor_2x2_c
 
+void aom_highbd_d135_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_32x16 aom_highbd_d135_predictor_32x16_c
+
 void aom_highbd_d135_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_32x32 aom_highbd_d135_predictor_32x32_c
 
 void aom_highbd_d135_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_4x4 aom_highbd_d135_predictor_4x4_c
 
+void aom_highbd_d135_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_4x8 aom_highbd_d135_predictor_4x8_c
+
+void aom_highbd_d135_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x16 aom_highbd_d135_predictor_8x16_c
+
+void aom_highbd_d135_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x4 aom_highbd_d135_predictor_8x4_c
+
 void aom_highbd_d135_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_8x8 aom_highbd_d135_predictor_8x8_c
 
 void aom_highbd_d153_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_16x16 aom_highbd_d153_predictor_16x16_c
 
+void aom_highbd_d153_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x32 aom_highbd_d153_predictor_16x32_c
+
+void aom_highbd_d153_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x8 aom_highbd_d153_predictor_16x8_c
+
 void aom_highbd_d153_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_2x2 aom_highbd_d153_predictor_2x2_c
 
+void aom_highbd_d153_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_32x16 aom_highbd_d153_predictor_32x16_c
+
 void aom_highbd_d153_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_32x32 aom_highbd_d153_predictor_32x32_c
 
 void aom_highbd_d153_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_4x4 aom_highbd_d153_predictor_4x4_c
 
+void aom_highbd_d153_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_4x8 aom_highbd_d153_predictor_4x8_c
+
+void aom_highbd_d153_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x16 aom_highbd_d153_predictor_8x16_c
+
+void aom_highbd_d153_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x4 aom_highbd_d153_predictor_8x4_c
+
 void aom_highbd_d153_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_8x8 aom_highbd_d153_predictor_8x8_c
 
 void aom_highbd_d207e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_16x16 aom_highbd_d207e_predictor_16x16_c
 
+void aom_highbd_d207e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x32 aom_highbd_d207e_predictor_16x32_c
+
+void aom_highbd_d207e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x8 aom_highbd_d207e_predictor_16x8_c
+
 void aom_highbd_d207e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_2x2 aom_highbd_d207e_predictor_2x2_c
 
+void aom_highbd_d207e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_32x16 aom_highbd_d207e_predictor_32x16_c
+
 void aom_highbd_d207e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_32x32 aom_highbd_d207e_predictor_32x32_c
 
 void aom_highbd_d207e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_4x4 aom_highbd_d207e_predictor_4x4_c
 
+void aom_highbd_d207e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_4x8 aom_highbd_d207e_predictor_4x8_c
+
+void aom_highbd_d207e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x16 aom_highbd_d207e_predictor_8x16_c
+
+void aom_highbd_d207e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x4 aom_highbd_d207e_predictor_8x4_c
+
 void aom_highbd_d207e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_8x8 aom_highbd_d207e_predictor_8x8_c
 
 void aom_highbd_d45e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_16x16 aom_highbd_d45e_predictor_16x16_c
 
+void aom_highbd_d45e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x32 aom_highbd_d45e_predictor_16x32_c
+
+void aom_highbd_d45e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x8 aom_highbd_d45e_predictor_16x8_c
+
 void aom_highbd_d45e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_2x2 aom_highbd_d45e_predictor_2x2_c
 
+void aom_highbd_d45e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_32x16 aom_highbd_d45e_predictor_32x16_c
+
 void aom_highbd_d45e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_32x32 aom_highbd_d45e_predictor_32x32_c
 
 void aom_highbd_d45e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_4x4 aom_highbd_d45e_predictor_4x4_c
 
+void aom_highbd_d45e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_4x8 aom_highbd_d45e_predictor_4x8_c
+
+void aom_highbd_d45e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x16 aom_highbd_d45e_predictor_8x16_c
+
+void aom_highbd_d45e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x4 aom_highbd_d45e_predictor_8x4_c
+
 void aom_highbd_d45e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_8x8 aom_highbd_d45e_predictor_8x8_c
 
 void aom_highbd_d63e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_16x16 aom_highbd_d63e_predictor_16x16_c
 
+void aom_highbd_d63e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x32 aom_highbd_d63e_predictor_16x32_c
+
+void aom_highbd_d63e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x8 aom_highbd_d63e_predictor_16x8_c
+
 void aom_highbd_d63e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_2x2 aom_highbd_d63e_predictor_2x2_c
 
+void aom_highbd_d63e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_32x16 aom_highbd_d63e_predictor_32x16_c
+
 void aom_highbd_d63e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_32x32 aom_highbd_d63e_predictor_32x32_c
 
 void aom_highbd_d63e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_4x4 aom_highbd_d63e_predictor_4x4_c
 
+void aom_highbd_d63e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_4x8 aom_highbd_d63e_predictor_4x8_c
+
+void aom_highbd_d63e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x16 aom_highbd_d63e_predictor_8x16_c
+
+void aom_highbd_d63e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x4 aom_highbd_d63e_predictor_8x4_c
+
 void aom_highbd_d63e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_8x8 aom_highbd_d63e_predictor_8x8_c
 
 void aom_highbd_dc_128_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_16x16 aom_highbd_dc_128_predictor_16x16_c
 
+void aom_highbd_dc_128_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x32 aom_highbd_dc_128_predictor_16x32_c
+
+void aom_highbd_dc_128_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x8 aom_highbd_dc_128_predictor_16x8_c
+
 void aom_highbd_dc_128_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_2x2 aom_highbd_dc_128_predictor_2x2_c
 
+void aom_highbd_dc_128_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_32x16 aom_highbd_dc_128_predictor_32x16_c
+
 void aom_highbd_dc_128_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_32x32 aom_highbd_dc_128_predictor_32x32_c
 
 void aom_highbd_dc_128_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_4x4 aom_highbd_dc_128_predictor_4x4_c
 
+void aom_highbd_dc_128_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_4x8 aom_highbd_dc_128_predictor_4x8_c
+
+void aom_highbd_dc_128_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x16 aom_highbd_dc_128_predictor_8x16_c
+
+void aom_highbd_dc_128_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x4 aom_highbd_dc_128_predictor_8x4_c
+
 void aom_highbd_dc_128_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_8x8 aom_highbd_dc_128_predictor_8x8_c
 
 void aom_highbd_dc_left_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_16x16 aom_highbd_dc_left_predictor_16x16_c
 
+void aom_highbd_dc_left_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x32 aom_highbd_dc_left_predictor_16x32_c
+
+void aom_highbd_dc_left_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x8 aom_highbd_dc_left_predictor_16x8_c
+
 void aom_highbd_dc_left_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_2x2 aom_highbd_dc_left_predictor_2x2_c
 
+void aom_highbd_dc_left_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_32x16 aom_highbd_dc_left_predictor_32x16_c
+
 void aom_highbd_dc_left_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_32x32 aom_highbd_dc_left_predictor_32x32_c
 
 void aom_highbd_dc_left_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_4x4 aom_highbd_dc_left_predictor_4x4_c
 
+void aom_highbd_dc_left_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_4x8 aom_highbd_dc_left_predictor_4x8_c
+
+void aom_highbd_dc_left_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x16 aom_highbd_dc_left_predictor_8x16_c
+
+void aom_highbd_dc_left_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x4 aom_highbd_dc_left_predictor_8x4_c
+
 void aom_highbd_dc_left_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_8x8 aom_highbd_dc_left_predictor_8x8_c
 
 void aom_highbd_dc_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_16x16_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_dc_predictor_16x16)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
+void aom_highbd_dc_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x32 aom_highbd_dc_predictor_16x32_c
+
+void aom_highbd_dc_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x8 aom_highbd_dc_predictor_16x8_c
+
 void aom_highbd_dc_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_2x2 aom_highbd_dc_predictor_2x2_c
 
+void aom_highbd_dc_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_32x16 aom_highbd_dc_predictor_32x16_c
+
 void aom_highbd_dc_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_32x32_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_dc_predictor_32x32)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
 void aom_highbd_dc_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_4x4_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_dc_predictor_4x4)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
+void aom_highbd_dc_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_4x8 aom_highbd_dc_predictor_4x8_c
+
+void aom_highbd_dc_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x16 aom_highbd_dc_predictor_8x16_c
+
+void aom_highbd_dc_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x4 aom_highbd_dc_predictor_8x4_c
+
 void aom_highbd_dc_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_8x8_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_dc_predictor_8x8)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
 void aom_highbd_dc_top_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_16x16 aom_highbd_dc_top_predictor_16x16_c
 
+void aom_highbd_dc_top_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x32 aom_highbd_dc_top_predictor_16x32_c
+
+void aom_highbd_dc_top_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x8 aom_highbd_dc_top_predictor_16x8_c
+
 void aom_highbd_dc_top_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_2x2 aom_highbd_dc_top_predictor_2x2_c
 
+void aom_highbd_dc_top_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_32x16 aom_highbd_dc_top_predictor_32x16_c
+
 void aom_highbd_dc_top_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_32x32 aom_highbd_dc_top_predictor_32x32_c
 
 void aom_highbd_dc_top_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_4x4 aom_highbd_dc_top_predictor_4x4_c
 
+void aom_highbd_dc_top_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_4x8 aom_highbd_dc_top_predictor_4x8_c
+
+void aom_highbd_dc_top_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x16 aom_highbd_dc_top_predictor_8x16_c
+
+void aom_highbd_dc_top_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x4 aom_highbd_dc_top_predictor_8x4_c
+
 void aom_highbd_dc_top_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_8x8 aom_highbd_dc_top_predictor_8x8_c
 
 void aom_highbd_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct16x16_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_highbd_fdct16x16)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_highbd_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct16x16_1 aom_highbd_fdct16x16_1_c
-
 void aom_highbd_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct32x32_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_highbd_fdct32x32)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_highbd_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct32x32_1 aom_highbd_fdct32x32_1_c
-
 void aom_highbd_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct32x32_rd_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_highbd_fdct32x32_rd)(const int16_t *input, tran_low_t *output, int stride);
 
 void aom_highbd_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct4x4_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_highbd_fdct4x4)(const int16_t *input, tran_low_t *output, int stride);
 
 void aom_highbd_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct8x8_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_highbd_fdct8x8)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_highbd_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct8x8_1 aom_highbd_fdct8x8_1_c
-
 void aom_highbd_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_16x16 aom_highbd_h_predictor_16x16_c
 
+void aom_highbd_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x32 aom_highbd_h_predictor_16x32_c
+
+void aom_highbd_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x8 aom_highbd_h_predictor_16x8_c
+
 void aom_highbd_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_2x2 aom_highbd_h_predictor_2x2_c
 
+void aom_highbd_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_32x16 aom_highbd_h_predictor_32x16_c
+
 void aom_highbd_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_32x32 aom_highbd_h_predictor_32x32_c
 
 void aom_highbd_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_4x4 aom_highbd_h_predictor_4x4_c
 
+void aom_highbd_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_4x8 aom_highbd_h_predictor_4x8_c
+
+void aom_highbd_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x16 aom_highbd_h_predictor_8x16_c
+
+void aom_highbd_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x4 aom_highbd_h_predictor_8x4_c
+
 void aom_highbd_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_8x8 aom_highbd_h_predictor_8x8_c
 
-void aom_highbd_idct16x16_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct16x16_1_add aom_highbd_idct16x16_1_add_c
-
-void aom_highbd_idct32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1024_add aom_highbd_idct32x32_1024_add_c
-
-void aom_highbd_idct32x32_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1_add aom_highbd_idct32x32_1_add_c
-
-void aom_highbd_idct32x32_34_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_34_add aom_highbd_idct32x32_34_add_c
-
-void aom_highbd_idct4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-void aom_highbd_idct4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-RTCD_EXTERN void (*aom_highbd_idct4x4_16_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-
-void aom_highbd_idct4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct4x4_1_add aom_highbd_idct4x4_1_add_c
-
-void aom_highbd_idct8x8_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct8x8_1_add aom_highbd_idct8x8_1_add_c
-
 void aom_highbd_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_16_add aom_highbd_iwht4x4_16_add_c
 
 void aom_highbd_iwht4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_1_add aom_highbd_iwht4x4_1_add_c
 
 void aom_highbd_lpf_horizontal_4_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 void aom_highbd_lpf_horizontal_4_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
@@ -1549,68 +1750,16 @@ RTCD_EXTERN void (*aom_highbd_lpf_vertic
 void aom_highbd_lpf_vertical_8_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 void aom_highbd_lpf_vertical_8_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 RTCD_EXTERN void (*aom_highbd_lpf_vertical_8)(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 
 void aom_highbd_lpf_vertical_8_dual_c(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 void aom_highbd_lpf_vertical_8_dual_sse2(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 RTCD_EXTERN void (*aom_highbd_lpf_vertical_8_dual)(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 
-unsigned int aom_highbd_masked_sad16x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad16x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad16x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x64_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x64)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad4x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad4x4_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad4x4)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad4x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad4x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad4x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad64x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad64x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad64x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad64x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad64x64_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad64x64)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x4_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x4)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
 void aom_highbd_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 #define aom_highbd_minmax_8x8 aom_highbd_minmax_8x8_c
 
 unsigned int aom_highbd_obmc_sad16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 unsigned int aom_highbd_obmc_sad16x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad16x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 
 unsigned int aom_highbd_obmc_sad16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
@@ -1750,30 +1899,49 @@ RTCD_EXTERN unsigned int (*aom_highbd_ob
 
 unsigned int aom_highbd_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 unsigned int aom_highbd_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 
 void aom_highbd_paeth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_16x16 aom_highbd_paeth_predictor_16x16_c
 
+void aom_highbd_paeth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x32 aom_highbd_paeth_predictor_16x32_c
+
+void aom_highbd_paeth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x8 aom_highbd_paeth_predictor_16x8_c
+
 void aom_highbd_paeth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_2x2 aom_highbd_paeth_predictor_2x2_c
 
+void aom_highbd_paeth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_32x16 aom_highbd_paeth_predictor_32x16_c
+
 void aom_highbd_paeth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_32x32 aom_highbd_paeth_predictor_32x32_c
 
 void aom_highbd_paeth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_4x4 aom_highbd_paeth_predictor_4x4_c
 
+void aom_highbd_paeth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_4x8 aom_highbd_paeth_predictor_4x8_c
+
+void aom_highbd_paeth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x16 aom_highbd_paeth_predictor_8x16_c
+
+void aom_highbd_paeth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x4 aom_highbd_paeth_predictor_8x4_c
+
 void aom_highbd_paeth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_8x8 aom_highbd_paeth_predictor_8x8_c
 
 void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_highbd_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+void aom_highbd_quantize_b_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 RTCD_EXTERN void (*aom_highbd_quantize_b)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void aom_highbd_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_highbd_quantize_b_32x32_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 RTCD_EXTERN void (*aom_highbd_quantize_b_32x32)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void aom_highbd_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_highbd_quantize_b_64x64 aom_highbd_quantize_b_64x64_c
@@ -1997,54 +2165,156 @@ void aom_highbd_sad8x8x3_c(const uint8_t
 
 void aom_highbd_sad8x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 void aom_highbd_sad8x8x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 RTCD_EXTERN void (*aom_highbd_sad8x8x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 
 void aom_highbd_sad8x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
 #define aom_highbd_sad8x8x8 aom_highbd_sad8x8x8_c
 
+void aom_highbd_smooth_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x16 aom_highbd_smooth_h_predictor_16x16_c
+
+void aom_highbd_smooth_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x32 aom_highbd_smooth_h_predictor_16x32_c
+
+void aom_highbd_smooth_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x8 aom_highbd_smooth_h_predictor_16x8_c
+
+void aom_highbd_smooth_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_2x2 aom_highbd_smooth_h_predictor_2x2_c
+
+void aom_highbd_smooth_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x16 aom_highbd_smooth_h_predictor_32x16_c
+
+void aom_highbd_smooth_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x32 aom_highbd_smooth_h_predictor_32x32_c
+
+void aom_highbd_smooth_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x4 aom_highbd_smooth_h_predictor_4x4_c
+
+void aom_highbd_smooth_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x8 aom_highbd_smooth_h_predictor_4x8_c
+
+void aom_highbd_smooth_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x16 aom_highbd_smooth_h_predictor_8x16_c
+
+void aom_highbd_smooth_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x4 aom_highbd_smooth_h_predictor_8x4_c
+
+void aom_highbd_smooth_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x8 aom_highbd_smooth_h_predictor_8x8_c
+
 void aom_highbd_smooth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_16x16 aom_highbd_smooth_predictor_16x16_c
 
+void aom_highbd_smooth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x32 aom_highbd_smooth_predictor_16x32_c
+
+void aom_highbd_smooth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x8 aom_highbd_smooth_predictor_16x8_c
+
 void aom_highbd_smooth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_2x2 aom_highbd_smooth_predictor_2x2_c
 
+void aom_highbd_smooth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_32x16 aom_highbd_smooth_predictor_32x16_c
+
 void aom_highbd_smooth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_32x32 aom_highbd_smooth_predictor_32x32_c
 
 void aom_highbd_smooth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_4x4 aom_highbd_smooth_predictor_4x4_c
 
+void aom_highbd_smooth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_4x8 aom_highbd_smooth_predictor_4x8_c
+
+void aom_highbd_smooth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x16 aom_highbd_smooth_predictor_8x16_c
+
+void aom_highbd_smooth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x4 aom_highbd_smooth_predictor_8x4_c
+
 void aom_highbd_smooth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_8x8 aom_highbd_smooth_predictor_8x8_c
 
+void aom_highbd_smooth_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x16 aom_highbd_smooth_v_predictor_16x16_c
+
+void aom_highbd_smooth_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x32 aom_highbd_smooth_v_predictor_16x32_c
+
+void aom_highbd_smooth_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x8 aom_highbd_smooth_v_predictor_16x8_c
+
+void aom_highbd_smooth_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_2x2 aom_highbd_smooth_v_predictor_2x2_c
+
+void aom_highbd_smooth_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x16 aom_highbd_smooth_v_predictor_32x16_c
+
+void aom_highbd_smooth_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x32 aom_highbd_smooth_v_predictor_32x32_c
+
+void aom_highbd_smooth_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x4 aom_highbd_smooth_v_predictor_4x4_c
+
+void aom_highbd_smooth_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x8 aom_highbd_smooth_v_predictor_4x8_c
+
+void aom_highbd_smooth_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x16 aom_highbd_smooth_v_predictor_8x16_c
+
+void aom_highbd_smooth_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x4 aom_highbd_smooth_v_predictor_8x4_c
+
+void aom_highbd_smooth_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x8 aom_highbd_smooth_v_predictor_8x8_c
+
 void aom_highbd_subtract_block_c(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 void aom_highbd_subtract_block_sse2(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 RTCD_EXTERN void (*aom_highbd_subtract_block)(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 
-void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
-void aom_highbd_upsampled_pred_sse2(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
-RTCD_EXTERN void (*aom_highbd_upsampled_pred)(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
+void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+void aom_highbd_upsampled_pred_sse2(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+RTCD_EXTERN void (*aom_highbd_upsampled_pred)(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 
 void aom_highbd_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_16x16_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_v_predictor_16x16)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
+void aom_highbd_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x32 aom_highbd_v_predictor_16x32_c
+
+void aom_highbd_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x8 aom_highbd_v_predictor_16x8_c
+
 void aom_highbd_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_2x2 aom_highbd_v_predictor_2x2_c
 
+void aom_highbd_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_32x16 aom_highbd_v_predictor_32x16_c
+
 void aom_highbd_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_32x32_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_v_predictor_32x32)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
 void aom_highbd_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_4x4_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_v_predictor_4x4)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
+void aom_highbd_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_4x8 aom_highbd_v_predictor_4x8_c
+
+void aom_highbd_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x16 aom_highbd_v_predictor_8x16_c
+
+void aom_highbd_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x4 aom_highbd_v_predictor_8x4_c
+
 void aom_highbd_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_8x8_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_v_predictor_8x8)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
 void aom_idct16x16_10_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
 void aom_idct16x16_10_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
 void aom_idct16x16_10_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
 RTCD_EXTERN void (*aom_idct16x16_10_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
@@ -2168,120 +2438,16 @@ RTCD_EXTERN void (*aom_lpf_vertical_4_du
 void aom_lpf_vertical_8_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 void aom_lpf_vertical_8_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 RTCD_EXTERN void (*aom_lpf_vertical_8)(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 
 void aom_lpf_vertical_8_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 void aom_lpf_vertical_8_dual_sse2(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 RTCD_EXTERN void (*aom_lpf_vertical_8_dual)(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 
-unsigned int aom_masked_sad16x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad16x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad16x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x64_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x64)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad4x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad4x4_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad4x4)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad4x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad4x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad4x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad64x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad64x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad64x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad64x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad64x64_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad64x64)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x4_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x4)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 void aom_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 void aom_minmax_8x8_sse2(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 RTCD_EXTERN void (*aom_minmax_8x8)(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 
 unsigned int aom_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_mse16x16_avx2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -2439,25 +2605,43 @@ RTCD_EXTERN unsigned int (*aom_obmc_vari
 
 unsigned int aom_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 unsigned int aom_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 
 void aom_paeth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_16x16 aom_paeth_predictor_16x16_c
 
+void aom_paeth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x32 aom_paeth_predictor_16x32_c
+
+void aom_paeth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x8 aom_paeth_predictor_16x8_c
+
 void aom_paeth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_2x2 aom_paeth_predictor_2x2_c
 
+void aom_paeth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_32x16 aom_paeth_predictor_32x16_c
+
 void aom_paeth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_32x32 aom_paeth_predictor_32x32_c
 
 void aom_paeth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_4x4 aom_paeth_predictor_4x4_c
 
+void aom_paeth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_4x8 aom_paeth_predictor_4x8_c
+
+void aom_paeth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x16 aom_paeth_predictor_8x16_c
+
+void aom_paeth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x4 aom_paeth_predictor_8x4_c
+
 void aom_paeth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_8x8 aom_paeth_predictor_8x8_c
 
 void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 RTCD_EXTERN void (*aom_quantize_b)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void aom_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
@@ -2714,31 +2898,115 @@ void aom_scaled_avg_vert_c(const uint8_t
 #define aom_scaled_avg_vert aom_scaled_avg_vert_c
 
 void aom_scaled_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_horiz aom_scaled_horiz_c
 
 void aom_scaled_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_vert aom_scaled_vert_c
 
+void aom_smooth_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x16 aom_smooth_h_predictor_16x16_c
+
+void aom_smooth_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x32 aom_smooth_h_predictor_16x32_c
+
+void aom_smooth_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x8 aom_smooth_h_predictor_16x8_c
+
+void aom_smooth_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_2x2 aom_smooth_h_predictor_2x2_c
+
+void aom_smooth_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x16 aom_smooth_h_predictor_32x16_c
+
+void aom_smooth_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x32 aom_smooth_h_predictor_32x32_c
+
+void aom_smooth_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x4 aom_smooth_h_predictor_4x4_c
+
+void aom_smooth_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x8 aom_smooth_h_predictor_4x8_c
+
+void aom_smooth_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x16 aom_smooth_h_predictor_8x16_c
+
+void aom_smooth_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x4 aom_smooth_h_predictor_8x4_c
+
+void aom_smooth_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x8 aom_smooth_h_predictor_8x8_c
+
 void aom_smooth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_16x16 aom_smooth_predictor_16x16_c
 
+void aom_smooth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x32 aom_smooth_predictor_16x32_c
+
+void aom_smooth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x8 aom_smooth_predictor_16x8_c
+
 void aom_smooth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_2x2 aom_smooth_predictor_2x2_c
 
+void aom_smooth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_32x16 aom_smooth_predictor_32x16_c
+
 void aom_smooth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_32x32 aom_smooth_predictor_32x32_c
 
 void aom_smooth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_4x4 aom_smooth_predictor_4x4_c
 
+void aom_smooth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_4x8 aom_smooth_predictor_4x8_c
+
+void aom_smooth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x16 aom_smooth_predictor_8x16_c
+
+void aom_smooth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x4 aom_smooth_predictor_8x4_c
+
 void aom_smooth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_8x8 aom_smooth_predictor_8x8_c
 
+void aom_smooth_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x16 aom_smooth_v_predictor_16x16_c
+
+void aom_smooth_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x32 aom_smooth_v_predictor_16x32_c
+
+void aom_smooth_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x8 aom_smooth_v_predictor_16x8_c
+
+void aom_smooth_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_2x2 aom_smooth_v_predictor_2x2_c
+
+void aom_smooth_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x16 aom_smooth_v_predictor_32x16_c
+
+void aom_smooth_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x32 aom_smooth_v_predictor_32x32_c
+
+void aom_smooth_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x4 aom_smooth_v_predictor_4x4_c
+
+void aom_smooth_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x8 aom_smooth_v_predictor_4x8_c
+
+void aom_smooth_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x16 aom_smooth_v_predictor_8x16_c
+
+void aom_smooth_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x4 aom_smooth_v_predictor_8x4_c
+
+void aom_smooth_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x8 aom_smooth_v_predictor_8x8_c
+
 uint32_t aom_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x16_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 
 uint32_t aom_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x32_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
@@ -2875,35 +3143,53 @@ RTCD_EXTERN void (*aom_subtract_block)(i
 uint64_t aom_sum_squares_2d_i16_c(const int16_t *src, int stride, int width, int height);
 uint64_t aom_sum_squares_2d_i16_sse2(const int16_t *src, int stride, int width, int height);
 RTCD_EXTERN uint64_t (*aom_sum_squares_2d_i16)(const int16_t *src, int stride, int width, int height);
 
 uint64_t aom_sum_squares_i16_c(const int16_t *src, uint32_t N);
 uint64_t aom_sum_squares_i16_sse2(const int16_t *src, uint32_t N);
 RTCD_EXTERN uint64_t (*aom_sum_squares_i16)(const int16_t *src, uint32_t N);
 
-void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
-void aom_upsampled_pred_sse2(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
-RTCD_EXTERN void (*aom_upsampled_pred)(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_sse2(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+RTCD_EXTERN void (*aom_upsampled_pred)(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 
 void aom_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_v_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x32 aom_v_predictor_16x32_c
+
+void aom_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x8 aom_v_predictor_16x8_c
+
 void aom_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_2x2 aom_v_predictor_2x2_c
 
+void aom_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_32x16 aom_v_predictor_32x16_c
+
 void aom_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_v_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_v_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_4x8 aom_v_predictor_4x8_c
+
+void aom_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x16 aom_v_predictor_8x16_c
+
+void aom_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x4 aom_v_predictor_8x4_c
+
 void aom_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_v_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 unsigned int aom_variance16x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 unsigned int aom_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 unsigned int aom_variance16x16_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_variance16x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
@@ -3067,36 +3353,28 @@ static void setup_rtcd_internal(void)
     aom_dc_top_predictor_32x32 = aom_dc_top_predictor_32x32_c;
     if (flags & HAS_SSE2) aom_dc_top_predictor_32x32 = aom_dc_top_predictor_32x32_sse2;
     aom_dc_top_predictor_4x4 = aom_dc_top_predictor_4x4_c;
     if (flags & HAS_SSE2) aom_dc_top_predictor_4x4 = aom_dc_top_predictor_4x4_sse2;
     aom_dc_top_predictor_8x8 = aom_dc_top_predictor_8x8_c;
     if (flags & HAS_SSE2) aom_dc_top_predictor_8x8 = aom_dc_top_predictor_8x8_sse2;
     aom_fdct16x16 = aom_fdct16x16_c;
     if (flags & HAS_SSE2) aom_fdct16x16 = aom_fdct16x16_sse2;
-    aom_fdct16x16_1 = aom_fdct16x16_1_c;
-    if (flags & HAS_SSE2) aom_fdct16x16_1 = aom_fdct16x16_1_sse2;
-    if (flags & HAS_AVX2) aom_fdct16x16_1 = aom_fdct16x16_1_avx2;
     aom_fdct32x32 = aom_fdct32x32_c;
     if (flags & HAS_SSE2) aom_fdct32x32 = aom_fdct32x32_sse2;
     if (flags & HAS_AVX2) aom_fdct32x32 = aom_fdct32x32_avx2;
-    aom_fdct32x32_1 = aom_fdct32x32_1_c;
-    if (flags & HAS_SSE2) aom_fdct32x32_1 = aom_fdct32x32_1_sse2;
-    if (flags & HAS_AVX2) aom_fdct32x32_1 = aom_fdct32x32_1_avx2;
     aom_fdct32x32_rd = aom_fdct32x32_rd_c;
     if (flags & HAS_SSE2) aom_fdct32x32_rd = aom_fdct32x32_rd_sse2;
     if (flags & HAS_AVX2) aom_fdct32x32_rd = aom_fdct32x32_rd_avx2;
     aom_fdct4x4 = aom_fdct4x4_c;
     if (flags & HAS_SSE2) aom_fdct4x4 = aom_fdct4x4_sse2;
     aom_fdct4x4_1 = aom_fdct4x4_1_c;
     if (flags & HAS_SSE2) aom_fdct4x4_1 = aom_fdct4x4_1_sse2;
     aom_fdct8x8 = aom_fdct8x8_c;
     if (flags & HAS_SSE2) aom_fdct8x8 = aom_fdct8x8_sse2;
-    aom_fdct8x8_1 = aom_fdct8x8_1_c;
-    if (flags & HAS_SSE2) aom_fdct8x8_1 = aom_fdct8x8_1_sse2;
     aom_get16x16var = aom_get16x16var_c;
     if (flags & HAS_SSE2) aom_get16x16var = aom_get16x16var_sse2;
     if (flags & HAS_AVX2) aom_get16x16var = aom_get16x16var_avx2;
     aom_get8x8var = aom_get8x8var_c;
     if (flags & HAS_SSE2) aom_get8x8var = aom_get8x8var_sse2;
     aom_get_mb_ss = aom_get_mb_ss_c;
     if (flags & HAS_SSE2) aom_get_mb_ss = aom_get_mb_ss_sse2;
     aom_h_predictor_16x16 = aom_h_predictor_16x16_c;
@@ -3106,42 +3384,16 @@ static void setup_rtcd_internal(void)
     aom_h_predictor_4x4 = aom_h_predictor_4x4_c;
     if (flags & HAS_SSE2) aom_h_predictor_4x4 = aom_h_predictor_4x4_sse2;
     aom_h_predictor_8x8 = aom_h_predictor_8x8_c;
     if (flags & HAS_SSE2) aom_h_predictor_8x8 = aom_h_predictor_8x8_sse2;
     aom_hadamard_16x16 = aom_hadamard_16x16_c;
     if (flags & HAS_SSE2) aom_hadamard_16x16 = aom_hadamard_16x16_sse2;
     aom_hadamard_8x8 = aom_hadamard_8x8_c;
     if (flags & HAS_SSE2) aom_hadamard_8x8 = aom_hadamard_8x8_sse2;
-    aom_highbd_10_masked_sub_pixel_variance16x16 = aom_highbd_10_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x16 = aom_highbd_10_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x32 = aom_highbd_10_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x32 = aom_highbd_10_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x8 = aom_highbd_10_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x8 = aom_highbd_10_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x16 = aom_highbd_10_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x16 = aom_highbd_10_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x32 = aom_highbd_10_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x32 = aom_highbd_10_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x64 = aom_highbd_10_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x64 = aom_highbd_10_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance4x4 = aom_highbd_10_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance4x4 = aom_highbd_10_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance4x8 = aom_highbd_10_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance4x8 = aom_highbd_10_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance64x32 = aom_highbd_10_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance64x32 = aom_highbd_10_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance64x64 = aom_highbd_10_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance64x64 = aom_highbd_10_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x16 = aom_highbd_10_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x16 = aom_highbd_10_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x4 = aom_highbd_10_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x4 = aom_highbd_10_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x8 = aom_highbd_10_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x8 = aom_highbd_10_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_10_mse16x16 = aom_highbd_10_mse16x16_c;
     if (flags & HAS_SSE2) aom_highbd_10_mse16x16 = aom_highbd_10_mse16x16_sse2;
     aom_highbd_10_mse8x8 = aom_highbd_10_mse8x8_c;
     if (flags & HAS_SSE2) aom_highbd_10_mse8x8 = aom_highbd_10_mse8x8_sse2;
     aom_highbd_10_obmc_variance16x16 = aom_highbd_10_obmc_variance16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x16 = aom_highbd_10_obmc_variance16x16_sse4_1;
     aom_highbd_10_obmc_variance16x32 = aom_highbd_10_obmc_variance16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x32 = aom_highbd_10_obmc_variance16x32_sse4_1;
@@ -3232,42 +3484,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_10_variance64x32 = aom_highbd_10_variance64x32_c;
     if (flags & HAS_SSE2) aom_highbd_10_variance64x32 = aom_highbd_10_variance64x32_sse2;
     aom_highbd_10_variance64x64 = aom_highbd_10_variance64x64_c;
     if (flags & HAS_SSE2) aom_highbd_10_variance64x64 = aom_highbd_10_variance64x64_sse2;
     aom_highbd_10_variance8x16 = aom_highbd_10_variance8x16_c;
     if (flags & HAS_SSE2) aom_highbd_10_variance8x16 = aom_highbd_10_variance8x16_sse2;
     aom_highbd_10_variance8x8 = aom_highbd_10_variance8x8_c;
     if (flags & HAS_SSE2) aom_highbd_10_variance8x8 = aom_highbd_10_variance8x8_sse2;
-    aom_highbd_12_masked_sub_pixel_variance16x16 = aom_highbd_12_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x16 = aom_highbd_12_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance16x32 = aom_highbd_12_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x32 = aom_highbd_12_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance16x8 = aom_highbd_12_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x8 = aom_highbd_12_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x16 = aom_highbd_12_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x16 = aom_highbd_12_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x32 = aom_highbd_12_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x32 = aom_highbd_12_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x64 = aom_highbd_12_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x64 = aom_highbd_12_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance4x4 = aom_highbd_12_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance4x4 = aom_highbd_12_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance4x8 = aom_highbd_12_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance4x8 = aom_highbd_12_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance64x32 = aom_highbd_12_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance64x32 = aom_highbd_12_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance64x64 = aom_highbd_12_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance64x64 = aom_highbd_12_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x16 = aom_highbd_12_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x16 = aom_highbd_12_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x4 = aom_highbd_12_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x4 = aom_highbd_12_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x8 = aom_highbd_12_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x8 = aom_highbd_12_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_12_mse16x16 = aom_highbd_12_mse16x16_c;
     if (flags & HAS_SSE2) aom_highbd_12_mse16x16 = aom_highbd_12_mse16x16_sse2;
     aom_highbd_12_mse8x8 = aom_highbd_12_mse8x8_c;
     if (flags & HAS_SSE2) aom_highbd_12_mse8x8 = aom_highbd_12_mse8x8_sse2;
     aom_highbd_12_obmc_variance16x16 = aom_highbd_12_obmc_variance16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x16 = aom_highbd_12_obmc_variance16x16_sse4_1;
     aom_highbd_12_obmc_variance16x32 = aom_highbd_12_obmc_variance16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x32 = aom_highbd_12_obmc_variance16x32_sse4_1;
@@ -3358,42 +3584,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_12_variance64x32 = aom_highbd_12_variance64x32_c;
     if (flags & HAS_SSE2) aom_highbd_12_variance64x32 = aom_highbd_12_variance64x32_sse2;
     aom_highbd_12_variance64x64 = aom_highbd_12_variance64x64_c;
     if (flags & HAS_SSE2) aom_highbd_12_variance64x64 = aom_highbd_12_variance64x64_sse2;
     aom_highbd_12_variance8x16 = aom_highbd_12_variance8x16_c;
     if (flags & HAS_SSE2) aom_highbd_12_variance8x16 = aom_highbd_12_variance8x16_sse2;
     aom_highbd_12_variance8x8 = aom_highbd_12_variance8x8_c;
     if (flags & HAS_SSE2) aom_highbd_12_variance8x8 = aom_highbd_12_variance8x8_sse2;
-    aom_highbd_8_masked_sub_pixel_variance16x16 = aom_highbd_8_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x16 = aom_highbd_8_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance16x32 = aom_highbd_8_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x32 = aom_highbd_8_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance16x8 = aom_highbd_8_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x8 = aom_highbd_8_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x16 = aom_highbd_8_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x16 = aom_highbd_8_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x32 = aom_highbd_8_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x32 = aom_highbd_8_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x64 = aom_highbd_8_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x64 = aom_highbd_8_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance4x4 = aom_highbd_8_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance4x4 = aom_highbd_8_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance4x8 = aom_highbd_8_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance4x8 = aom_highbd_8_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance64x32 = aom_highbd_8_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance64x32 = aom_highbd_8_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance64x64 = aom_highbd_8_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance64x64 = aom_highbd_8_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x16 = aom_highbd_8_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x16 = aom_highbd_8_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x4 = aom_highbd_8_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x4 = aom_highbd_8_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x8 = aom_highbd_8_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x8 = aom_highbd_8_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_8_mse16x16 = aom_highbd_8_mse16x16_c;
     if (flags & HAS_SSE2) aom_highbd_8_mse16x16 = aom_highbd_8_mse16x16_sse2;
     aom_highbd_8_mse8x8 = aom_highbd_8_mse8x8_c;
     if (flags & HAS_SSE2) aom_highbd_8_mse8x8 = aom_highbd_8_mse8x8_sse2;
     aom_highbd_8_sub_pixel_avg_variance16x16 = aom_highbd_8_sub_pixel_avg_variance16x16_c;
     if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance16x16 = aom_highbd_8_sub_pixel_avg_variance16x16_sse2;
     aom_highbd_8_sub_pixel_avg_variance16x32 = aom_highbd_8_sub_pixel_avg_variance16x32_c;
     if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance16x32 = aom_highbd_8_sub_pixel_avg_variance16x32_sse2;
@@ -3502,18 +3702,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_fdct32x32 = aom_highbd_fdct32x32_c;
     if (flags & HAS_SSE2) aom_highbd_fdct32x32 = aom_highbd_fdct32x32_sse2;
     aom_highbd_fdct32x32_rd = aom_highbd_fdct32x32_rd_c;
     if (flags & HAS_SSE2) aom_highbd_fdct32x32_rd = aom_highbd_fdct32x32_rd_sse2;
     aom_highbd_fdct4x4 = aom_highbd_fdct4x4_c;
     if (flags & HAS_SSE2) aom_highbd_fdct4x4 = aom_highbd_fdct4x4_sse2;
     aom_highbd_fdct8x8 = aom_highbd_fdct8x8_c;
     if (flags & HAS_SSE2) aom_highbd_fdct8x8 = aom_highbd_fdct8x8_sse2;
-    aom_highbd_idct4x4_16_add = aom_highbd_idct4x4_16_add_c;
-    if (flags & HAS_SSE2) aom_highbd_idct4x4_16_add = aom_highbd_idct4x4_16_add_sse2;
     aom_highbd_lpf_horizontal_4 = aom_highbd_lpf_horizontal_4_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_4 = aom_highbd_lpf_horizontal_4_sse2;
     aom_highbd_lpf_horizontal_4_dual = aom_highbd_lpf_horizontal_4_dual_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_4_dual = aom_highbd_lpf_horizontal_4_dual_sse2;
     aom_highbd_lpf_horizontal_8 = aom_highbd_lpf_horizontal_8_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_8 = aom_highbd_lpf_horizontal_8_sse2;
     aom_highbd_lpf_horizontal_8_dual = aom_highbd_lpf_horizontal_8_dual_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_8_dual = aom_highbd_lpf_horizontal_8_dual_sse2;
@@ -3528,42 +3726,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_lpf_vertical_4 = aom_highbd_lpf_vertical_4_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_vertical_4 = aom_highbd_lpf_vertical_4_sse2;
     aom_highbd_lpf_vertical_4_dual = aom_highbd_lpf_vertical_4_dual_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_vertical_4_dual = aom_highbd_lpf_vertical_4_dual_sse2;
     aom_highbd_lpf_vertical_8 = aom_highbd_lpf_vertical_8_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_vertical_8 = aom_highbd_lpf_vertical_8_sse2;
     aom_highbd_lpf_vertical_8_dual = aom_highbd_lpf_vertical_8_dual_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_vertical_8_dual = aom_highbd_lpf_vertical_8_dual_sse2;
-    aom_highbd_masked_sad16x16 = aom_highbd_masked_sad16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x16 = aom_highbd_masked_sad16x16_ssse3;
-    aom_highbd_masked_sad16x32 = aom_highbd_masked_sad16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x32 = aom_highbd_masked_sad16x32_ssse3;
-    aom_highbd_masked_sad16x8 = aom_highbd_masked_sad16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x8 = aom_highbd_masked_sad16x8_ssse3;
-    aom_highbd_masked_sad32x16 = aom_highbd_masked_sad32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x16 = aom_highbd_masked_sad32x16_ssse3;
-    aom_highbd_masked_sad32x32 = aom_highbd_masked_sad32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x32 = aom_highbd_masked_sad32x32_ssse3;
-    aom_highbd_masked_sad32x64 = aom_highbd_masked_sad32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x64 = aom_highbd_masked_sad32x64_ssse3;
-    aom_highbd_masked_sad4x4 = aom_highbd_masked_sad4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad4x4 = aom_highbd_masked_sad4x4_ssse3;
-    aom_highbd_masked_sad4x8 = aom_highbd_masked_sad4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad4x8 = aom_highbd_masked_sad4x8_ssse3;
-    aom_highbd_masked_sad64x32 = aom_highbd_masked_sad64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad64x32 = aom_highbd_masked_sad64x32_ssse3;
-    aom_highbd_masked_sad64x64 = aom_highbd_masked_sad64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad64x64 = aom_highbd_masked_sad64x64_ssse3;
-    aom_highbd_masked_sad8x16 = aom_highbd_masked_sad8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x16 = aom_highbd_masked_sad8x16_ssse3;
-    aom_highbd_masked_sad8x4 = aom_highbd_masked_sad8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x4 = aom_highbd_masked_sad8x4_ssse3;
-    aom_highbd_masked_sad8x8 = aom_highbd_masked_sad8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x8 = aom_highbd_masked_sad8x8_ssse3;
     aom_highbd_obmc_sad16x16 = aom_highbd_obmc_sad16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x16 = aom_highbd_obmc_sad16x16_sse4_1;
     aom_highbd_obmc_sad16x32 = aom_highbd_obmc_sad16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x32 = aom_highbd_obmc_sad16x32_sse4_1;
     aom_highbd_obmc_sad16x8 = aom_highbd_obmc_sad16x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x8 = aom_highbd_obmc_sad16x8_sse4_1;
     aom_highbd_obmc_sad32x16 = aom_highbd_obmc_sad32x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad32x16 = aom_highbd_obmc_sad32x16_sse4_1;
@@ -3608,16 +3780,17 @@ static void setup_rtcd_internal(void)
     aom_highbd_obmc_variance8x16 = aom_highbd_obmc_variance8x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x16 = aom_highbd_obmc_variance8x16_sse4_1;
     aom_highbd_obmc_variance8x4 = aom_highbd_obmc_variance8x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x4 = aom_highbd_obmc_variance8x4_sse4_1;
     aom_highbd_obmc_variance8x8 = aom_highbd_obmc_variance8x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x8 = aom_highbd_obmc_variance8x8_sse4_1;
     aom_highbd_quantize_b = aom_highbd_quantize_b_c;
     if (flags & HAS_SSE2) aom_highbd_quantize_b = aom_highbd_quantize_b_sse2;
+    if (flags & HAS_AVX2) aom_highbd_quantize_b = aom_highbd_quantize_b_avx2;
     aom_highbd_quantize_b_32x32 = aom_highbd_quantize_b_32x32_c;
     if (flags & HAS_SSE2) aom_highbd_quantize_b_32x32 = aom_highbd_quantize_b_32x32_sse2;
     aom_highbd_sad16x16 = aom_highbd_sad16x16_c;
     if (flags & HAS_SSE2) aom_highbd_sad16x16 = aom_highbd_sad16x16_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16 = aom_highbd_sad16x16_avx2;
     aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_c;
     if (flags & HAS_SSE2) aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_avx2;
@@ -3786,68 +3959,16 @@ static void setup_rtcd_internal(void)
     aom_lpf_vertical_4 = aom_lpf_vertical_4_c;
     if (flags & HAS_SSE2) aom_lpf_vertical_4 = aom_lpf_vertical_4_sse2;
     aom_lpf_vertical_4_dual = aom_lpf_vertical_4_dual_c;
     if (flags & HAS_SSE2) aom_lpf_vertical_4_dual = aom_lpf_vertical_4_dual_sse2;
     aom_lpf_vertical_8 = aom_lpf_vertical_8_c;
     if (flags & HAS_SSE2) aom_lpf_vertical_8 = aom_lpf_vertical_8_sse2;
     aom_lpf_vertical_8_dual = aom_lpf_vertical_8_dual_c;
     if (flags & HAS_SSE2) aom_lpf_vertical_8_dual = aom_lpf_vertical_8_dual_sse2;
-    aom_masked_sad16x16 = aom_masked_sad16x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x16 = aom_masked_sad16x16_ssse3;
-    aom_masked_sad16x32 = aom_masked_sad16x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x32 = aom_masked_sad16x32_ssse3;
-    aom_masked_sad16x8 = aom_masked_sad16x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x8 = aom_masked_sad16x8_ssse3;
-    aom_masked_sad32x16 = aom_masked_sad32x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x16 = aom_masked_sad32x16_ssse3;
-    aom_masked_sad32x32 = aom_masked_sad32x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x32 = aom_masked_sad32x32_ssse3;
-    aom_masked_sad32x64 = aom_masked_sad32x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x64 = aom_masked_sad32x64_ssse3;
-    aom_masked_sad4x4 = aom_masked_sad4x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sad4x4 = aom_masked_sad4x4_ssse3;
-    aom_masked_sad4x8 = aom_masked_sad4x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad4x8 = aom_masked_sad4x8_ssse3;
-    aom_masked_sad64x32 = aom_masked_sad64x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad64x32 = aom_masked_sad64x32_ssse3;
-    aom_masked_sad64x64 = aom_masked_sad64x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sad64x64 = aom_masked_sad64x64_ssse3;
-    aom_masked_sad8x16 = aom_masked_sad8x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x16 = aom_masked_sad8x16_ssse3;
-    aom_masked_sad8x4 = aom_masked_sad8x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x4 = aom_masked_sad8x4_ssse3;
-    aom_masked_sad8x8 = aom_masked_sad8x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x8 = aom_masked_sad8x8_ssse3;
-    aom_masked_sub_pixel_variance16x16 = aom_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x16 = aom_masked_sub_pixel_variance16x16_ssse3;
-    aom_masked_sub_pixel_variance16x32 = aom_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x32 = aom_masked_sub_pixel_variance16x32_ssse3;
-    aom_masked_sub_pixel_variance16x8 = aom_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x8 = aom_masked_sub_pixel_variance16x8_ssse3;
-    aom_masked_sub_pixel_variance32x16 = aom_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x16 = aom_masked_sub_pixel_variance32x16_ssse3;
-    aom_masked_sub_pixel_variance32x32 = aom_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x32 = aom_masked_sub_pixel_variance32x32_ssse3;
-    aom_masked_sub_pixel_variance32x64 = aom_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x64 = aom_masked_sub_pixel_variance32x64_ssse3;
-    aom_masked_sub_pixel_variance4x4 = aom_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance4x4 = aom_masked_sub_pixel_variance4x4_ssse3;
-    aom_masked_sub_pixel_variance4x8 = aom_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance4x8 = aom_masked_sub_pixel_variance4x8_ssse3;
-    aom_masked_sub_pixel_variance64x32 = aom_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance64x32 = aom_masked_sub_pixel_variance64x32_ssse3;
-    aom_masked_sub_pixel_variance64x64 = aom_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance64x64 = aom_masked_sub_pixel_variance64x64_ssse3;
-    aom_masked_sub_pixel_variance8x16 = aom_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x16 = aom_masked_sub_pixel_variance8x16_ssse3;
-    aom_masked_sub_pixel_variance8x4 = aom_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x4 = aom_masked_sub_pixel_variance8x4_ssse3;
-    aom_masked_sub_pixel_variance8x8 = aom_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x8 = aom_masked_sub_pixel_variance8x8_ssse3;
     aom_minmax_8x8 = aom_minmax_8x8_c;
     if (flags & HAS_SSE2) aom_minmax_8x8 = aom_minmax_8x8_sse2;
     aom_mse16x16 = aom_mse16x16_c;
     if (flags & HAS_SSE2) aom_mse16x16 = aom_mse16x16_sse2;
     if (flags & HAS_AVX2) aom_mse16x16 = aom_mse16x16_avx2;
     aom_mse16x8 = aom_mse16x8_c;
     if (flags & HAS_SSE2) aom_mse16x8 = aom_mse16x8_sse2;
     aom_mse8x16 = aom_mse8x16_c;
--- a/media/libaom/config/linux/ia32/av1_rtcd.h
+++ b/media/libaom/config/linux/ia32/av1_rtcd.h
@@ -13,22 +13,25 @@
 
 #include "aom/aom_integer.h"
 #include "av1/common/common.h"
 #include "av1/common/enums.h"
 #include "av1/common/quant_common.h"
 #include "av1/common/filter.h"
 #include "av1/common/convolve.h"
 #include "av1/common/av1_txfm.h"
+#include "av1/common/idct.h"
 #include "av1/common/odintrin.h"
 
 struct macroblockd;
 
 /* Encoder forward decls */
 struct macroblock;
+struct fwd_txfm_param;
+struct inv_txfm_param;
 struct aom_variance_vtable;
 struct search_site_config;
 struct mv;
 union int_mv;
 struct yv12_buffer_config;
 typedef uint16_t od_dering_in;
 
 #ifdef __cplusplus
@@ -55,113 +58,132 @@ RTCD_EXTERN void (*aom_clpf_hblock)(uint
 
 void aom_clpf_hblock_hbd_c(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_sse2(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_ssse3(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_sse4_1(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 RTCD_EXTERN void (*aom_clpf_hblock_hbd)(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 
 int64_t av1_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
-#define av1_block_error av1_block_error_c
+int64_t av1_block_error_avx2(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
+RTCD_EXTERN int64_t (*av1_block_error)(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
 
 void av1_convolve_horiz_c(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 void av1_convolve_horiz_ssse3(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 RTCD_EXTERN void (*av1_convolve_horiz)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 
 void av1_convolve_vert_c(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 void av1_convolve_vert_ssse3(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 RTCD_EXTERN void (*av1_convolve_vert)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 
 int av1_diamond_search_sad_c(struct macroblock *x, const struct search_site_config *cfg,  struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_diamond_search_sad av1_diamond_search_sad_c
 
 void av1_fdct8x8_quant_c(const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define av1_fdct8x8_quant av1_fdct8x8_quant_c
 
-void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x16_avx2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht16x16)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x16_avx2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht16x16)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x32_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht16x32)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x32_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht16x32)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x4 av1_fht16x4_c
 
-void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht16x8)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht16x8)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht32x16)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht32x16)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x32_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x32_avx2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht32x32)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x32_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x32_avx2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht32x32)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x8 av1_fht32x8_c
 
-void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x16 av1_fht4x16_c
 
-void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht4x4)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht4x4)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht4x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht4x8)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht4x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht4x8)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht8x16)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht8x16)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x32 av1_fht8x32_c
 
-void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x4_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht8x4)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x4_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht8x4)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht8x8)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht8x8)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
 int av1_full_range_search_c(const struct macroblock *x, const struct search_site_config *cfg, struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_full_range_search av1_full_range_search_c
 
 int av1_full_search_sad_c(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 int av1_full_search_sadx3(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 int av1_full_search_sadx8(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 RTCD_EXTERN int (*av1_full_search_sad)(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 
 void av1_fwd_idtx_c(const int16_t *src_diff, tran_low_t *coeff, int stride, int bs, int tx_type);
 #define av1_fwd_idtx av1_fwd_idtx_c
 
 void av1_fwd_txfm2d_16x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_16x16_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_16x16)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_16x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x32 av1_fwd_txfm2d_16x32_c
+
+void av1_fwd_txfm2d_16x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x8 av1_fwd_txfm2d_16x8_c
+
+void av1_fwd_txfm2d_32x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_32x16 av1_fwd_txfm2d_32x16_c
+
 void av1_fwd_txfm2d_32x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_32x32_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_32x32)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
 void av1_fwd_txfm2d_4x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_4x4_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_4x4)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_4x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_4x8 av1_fwd_txfm2d_4x8_c
+
 void av1_fwd_txfm2d_64x64_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_64x64_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_64x64)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_8x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x16 av1_fwd_txfm2d_8x16_c
+
+void av1_fwd_txfm2d_8x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x4 av1_fwd_txfm2d_8x4_c
+
 void av1_fwd_txfm2d_8x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_8x8_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_8x8)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
 void av1_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_fwht4x4 av1_fwht4x4_c
 
 int64_t av1_highbd_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd);
@@ -199,225 +221,178 @@ RTCD_EXTERN void (*av1_highbd_convolve_h
 void av1_highbd_convolve_init_c(void);
 void av1_highbd_convolve_init_sse4_1(void);
 RTCD_EXTERN void (*av1_highbd_convolve_init)(void);
 
 void av1_highbd_convolve_vert_c(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 void av1_highbd_convolve_vert_sse4_1(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 RTCD_EXTERN void (*av1_highbd_convolve_vert)(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 
-void av1_highbd_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x16 av1_highbd_fht16x16_c
-
-void av1_highbd_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x32 av1_highbd_fht16x32_c
-
-void av1_highbd_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x4 av1_highbd_fht16x4_c
-
-void av1_highbd_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x8 av1_highbd_fht16x8_c
-
-void av1_highbd_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x16 av1_highbd_fht32x16_c
-
-void av1_highbd_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x32 av1_highbd_fht32x32_c
-
-void av1_highbd_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x8 av1_highbd_fht32x8_c
-
-void av1_highbd_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x16 av1_highbd_fht4x16_c
-
-void av1_highbd_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_highbd_fht4x4_sse4_1(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_highbd_fht4x4)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-
-void av1_highbd_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x8 av1_highbd_fht4x8_c
-
-void av1_highbd_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x16 av1_highbd_fht8x16_c
-
-void av1_highbd_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x32 av1_highbd_fht8x32_c
-
-void av1_highbd_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x4 av1_highbd_fht8x4_c
-
-void av1_highbd_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x8 av1_highbd_fht8x8_c
-
 void av1_highbd_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_highbd_fwht4x4 av1_highbd_fwht4x4_c
 
-void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type, int bd);
+void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x16_256_add av1_highbd_iht16x16_256_add_c
 
-void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x32_512_add av1_highbd_iht16x32_512_add_c
 
-void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x4_64_add av1_highbd_iht16x4_64_add_c
 
-void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x8_128_add av1_highbd_iht16x8_128_add_c
 
-void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x16_512_add av1_highbd_iht32x16_512_add_c
 
-void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x8_256_add av1_highbd_iht32x8_256_add_c
 
-void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x16_64_add av1_highbd_iht4x16_64_add_c
 
-void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x4_16_add av1_highbd_iht4x4_16_add_c
 
-void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x8_32_add av1_highbd_iht4x8_32_add_c
 
-void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x16_128_add av1_highbd_iht8x16_128_add_c
 
-void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x32_256_add av1_highbd_iht8x32_256_add_c
 
-void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x4_32_add av1_highbd_iht8x4_32_add_c
 
-void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x8_64_add av1_highbd_iht8x8_64_add_c
 
 void av1_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_highbd_quantize_b av1_highbd_quantize_b_c
 
 void av1_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 void av1_highbd_quantize_fp_sse4_1(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
+void av1_highbd_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 RTCD_EXTERN void (*av1_highbd_quantize_fp)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 
 void av1_highbd_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 #define av1_highbd_temporal_filter_apply av1_highbd_temporal_filter_apply_c
 
-void av1_highbd_warp_affine_c(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_highbd_warp_affine_ssse3(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-RTCD_EXTERN void (*av1_highbd_warp_affine)(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
+void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+void av1_iht16x16_256_add_sse2(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+void av1_iht16x16_256_add_avx2(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht16x16_256_add)(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 
-void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-void av1_iht16x16_256_add_sse2(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-void av1_iht16x16_256_add_avx2(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-RTCD_EXTERN void (*av1_iht16x16_256_add)(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
+void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht16x32_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht16x32_512_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht16x32_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht16x32_512_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-
-void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x4_64_add av1_iht16x4_64_add_c
 
-void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht16x8_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht16x8_128_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht16x8_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht16x8_128_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht32x16_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht32x16_512_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht32x16_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht32x16_512_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
+void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_iht32x32_1024_add av1_iht32x32_1024_add_c
 
-void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht32x8_256_add av1_iht32x8_256_add_c
 
-void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x16_64_add av1_iht4x16_64_add_c
 
-void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht4x4_16_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht4x4_16_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht4x8_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht4x8_32_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht4x8_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht4x8_32_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x16_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht8x16_128_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x16_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht8x16_128_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x32_256_add av1_iht8x32_256_add_c
 
-void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x4_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht8x4_32_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x4_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht8x4_32_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht8x8_64_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht8x8_64_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
 void av1_inv_txfm2d_add_16x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_16x16_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_16x16)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
+void av1_inv_txfm2d_add_16x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x32 av1_inv_txfm2d_add_16x32_c
+
+void av1_inv_txfm2d_add_16x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x8 av1_inv_txfm2d_add_16x8_c
+
+void av1_inv_txfm2d_add_32x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_32x16 av1_inv_txfm2d_add_32x16_c
+
 void av1_inv_txfm2d_add_32x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_32x32_avx2(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_32x32)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
 void av1_inv_txfm2d_add_4x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_4x4_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_4x4)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
+void av1_inv_txfm2d_add_4x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_4x8 av1_inv_txfm2d_add_4x8_c
+
 void av1_inv_txfm2d_add_64x64_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_64x64 av1_inv_txfm2d_add_64x64_c
 
+void av1_inv_txfm2d_add_8x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x16 av1_inv_txfm2d_add_8x16_c
+
+void av1_inv_txfm2d_add_8x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x4 av1_inv_txfm2d_add_8x4_c
+
 void av1_inv_txfm2d_add_8x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_8x8_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_8x8)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
 void av1_lowbd_convolve_init_c(void);
 void av1_lowbd_convolve_init_ssse3(void);
 RTCD_EXTERN void (*av1_lowbd_convolve_init)(void);
 
 void av1_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_quantize_b av1_quantize_b_c
 
 void av1_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void av1_quantize_fp_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+void av1_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 RTCD_EXTERN void (*av1_quantize_fp)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void av1_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
-#define av1_quantize_fp_32x32 av1_quantize_fp_32x32_c
+void av1_quantize_fp_32x32_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*av1_quantize_fp_32x32)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void av1_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 void av1_temporal_filter_apply_sse2(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 RTCD_EXTERN void (*av1_temporal_filter_apply)(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 
-void av1_warp_affine_c(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_warp_affine_sse2(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_warp_affine_ssse3(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-RTCD_EXTERN void (*av1_warp_affine)(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-
-void av1_wedge_compute_delta_squares_c(int16_t *d, const int16_t *a, const int16_t *b, int N);
-void av1_wedge_compute_delta_squares_sse2(int16_t *d, const int16_t *a, const int16_t *b, int N);
-RTCD_EXTERN void (*av1_wedge_compute_delta_squares)(int16_t *d, const int16_t *a, const int16_t *b, int N);
-
-int av1_wedge_sign_from_residuals_c(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-int av1_wedge_sign_from_residuals_sse2(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-RTCD_EXTERN int (*av1_wedge_sign_from_residuals)(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-
-uint64_t av1_wedge_sse_from_residuals_c(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-uint64_t av1_wedge_sse_from_residuals_sse2(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-RTCD_EXTERN uint64_t (*av1_wedge_sse_from_residuals)(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-
-double compute_cross_correlation_c(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-double compute_cross_correlation_sse4_1(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-RTCD_EXTERN double (*compute_cross_correlation)(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-
 void copy_4x4_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_sse2(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_ssse3(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_sse4_1(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 RTCD_EXTERN void (*copy_4x4_16bit_to_16bit)(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 
 void copy_4x4_16bit_to_8bit_c(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_8bit_sse2(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
@@ -488,16 +463,18 @@ static void setup_rtcd_internal(void)
     aom_clpf_hblock = aom_clpf_hblock_c;
     if (flags & HAS_SSE2) aom_clpf_hblock = aom_clpf_hblock_sse2;
     if (flags & HAS_SSSE3) aom_clpf_hblock = aom_clpf_hblock_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_hblock = aom_clpf_hblock_sse4_1;
     aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_c;
     if (flags & HAS_SSE2) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_sse2;
     if (flags & HAS_SSSE3) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_sse4_1;
+    av1_block_error = av1_block_error_c;
+    if (flags & HAS_AVX2) av1_block_error = av1_block_error_avx2;
     av1_convolve_horiz = av1_convolve_horiz_c;
     if (flags & HAS_SSSE3) av1_convolve_horiz = av1_convolve_horiz_ssse3;
     av1_convolve_vert = av1_convolve_vert_c;
     if (flags & HAS_SSSE3) av1_convolve_vert = av1_convolve_vert_ssse3;
     av1_fht16x16 = av1_fht16x16_c;
     if (flags & HAS_SSE2) av1_fht16x16 = av1_fht16x16_sse2;
     if (flags & HAS_AVX2) av1_fht16x16 = av1_fht16x16_avx2;
     av1_fht16x32 = av1_fht16x32_c;
@@ -535,22 +512,19 @@ static void setup_rtcd_internal(void)
     av1_highbd_block_error = av1_highbd_block_error_c;
     if (flags & HAS_SSE2) av1_highbd_block_error = av1_highbd_block_error_sse2;
     av1_highbd_convolve_horiz = av1_highbd_convolve_horiz_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_horiz = av1_highbd_convolve_horiz_sse4_1;
     av1_highbd_convolve_init = av1_highbd_convolve_init_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_init = av1_highbd_convolve_init_sse4_1;
     av1_highbd_convolve_vert = av1_highbd_convolve_vert_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_vert = av1_highbd_convolve_vert_sse4_1;
-    av1_highbd_fht4x4 = av1_highbd_fht4x4_c;
-    if (flags & HAS_SSE4_1) av1_highbd_fht4x4 = av1_highbd_fht4x4_sse4_1;
     av1_highbd_quantize_fp = av1_highbd_quantize_fp_c;
     if (flags & HAS_SSE4_1) av1_highbd_quantize_fp = av1_highbd_quantize_fp_sse4_1;
-    av1_highbd_warp_affine = av1_highbd_warp_affine_c;
-    if (flags & HAS_SSSE3) av1_highbd_warp_affine = av1_highbd_warp_affine_ssse3;
+    if (flags & HAS_AVX2) av1_highbd_quantize_fp = av1_highbd_quantize_fp_avx2;
     av1_iht16x16_256_add = av1_iht16x16_256_add_c;
     if (flags & HAS_SSE2) av1_iht16x16_256_add = av1_iht16x16_256_add_sse2;
     if (flags & HAS_AVX2) av1_iht16x16_256_add = av1_iht16x16_256_add_avx2;
     av1_iht16x32_512_add = av1_iht16x32_512_add_c;
     if (flags & HAS_SSE2) av1_iht16x32_512_add = av1_iht16x32_512_add_sse2;
     av1_iht16x8_128_add = av1_iht16x8_128_add_c;
     if (flags & HAS_SSE2) av1_iht16x8_128_add = av1_iht16x8_128_add_sse2;
     av1_iht32x16_512_add = av1_iht32x16_512_add_c;
@@ -572,29 +546,21 @@ static void setup_rtcd_internal(void)
     av1_inv_txfm2d_add_4x4 = av1_inv_txfm2d_add_4x4_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_4x4 = av1_inv_txfm2d_add_4x4_sse4_1;
     av1_inv_txfm2d_add_8x8 = av1_inv_txfm2d_add_8x8_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_8x8 = av1_inv_txfm2d_add_8x8_sse4_1;
     av1_lowbd_convolve_init = av1_lowbd_convolve_init_c;
     if (flags & HAS_SSSE3) av1_lowbd_convolve_init = av1_lowbd_convolve_init_ssse3;
     av1_quantize_fp = av1_quantize_fp_c;
     if (flags & HAS_SSE2) av1_quantize_fp = av1_quantize_fp_sse2;
+    if (flags & HAS_AVX2) av1_quantize_fp = av1_quantize_fp_avx2;
+    av1_quantize_fp_32x32 = av1_quantize_fp_32x32_c;
+    if (flags & HAS_AVX2) av1_quantize_fp_32x32 = av1_quantize_fp_32x32_avx2;
     av1_temporal_filter_apply = av1_temporal_filter_apply_c;
     if (flags & HAS_SSE2) av1_temporal_filter_apply = av1_temporal_filter_apply_sse2;
-    av1_warp_affine = av1_warp_affine_c;
-    if (flags & HAS_SSE2) av1_warp_affine = av1_warp_affine_sse2;
-    if (flags & HAS_SSSE3) av1_warp_affine = av1_warp_affine_ssse3;
-    av1_wedge_compute_delta_squares = av1_wedge_compute_delta_squares_c;
-    if (flags & HAS_SSE2) av1_wedge_compute_delta_squares = av1_wedge_compute_delta_squares_sse2;
-    av1_wedge_sign_from_residuals = av1_wedge_sign_from_residuals_c;
-    if (flags & HAS_SSE2) av1_wedge_sign_from_residuals = av1_wedge_sign_from_residuals_sse2;
-    av1_wedge_sse_from_residuals = av1_wedge_sse_from_residuals_c;
-    if (flags & HAS_SSE2) av1_wedge_sse_from_residuals = av1_wedge_sse_from_residuals_sse2;
-    compute_cross_correlation = compute_cross_correlation_c;
-    if (flags & HAS_SSE4_1) compute_cross_correlation = compute_cross_correlation_sse4_1;
     copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_c;
     if (flags & HAS_SSE2) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_sse2;
     if (flags & HAS_SSSE3) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_ssse3;
     if (flags & HAS_SSE4_1) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_sse4_1;
     copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_c;
     if (flags & HAS_SSE2) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_sse2;
     if (flags & HAS_SSSE3) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_ssse3;
     if (flags & HAS_SSE4_1) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_sse4_1;
--- a/media/libaom/config/linux/x64/aom_config.asm
+++ b/media/libaom/config/linux/x64/aom_config.asm
@@ -60,60 +60,63 @@
 %define CONFIG_INSPECTION 0
 %define CONFIG_DECODE_PERF_TESTS 0
 %define CONFIG_ENCODE_PERF_TESTS 0
 %define CONFIG_COEFFICIENT_RANGE_CHECKING 0
 %define CONFIG_LOWBITDEPTH 1
 %define CONFIG_HIGHBITDEPTH 1
 %define CONFIG_EXPERIMENTAL 0
 %define CONFIG_SIZE_LIMIT 1
+%define CONFIG_COLORSPACE_HEADERS 0
 %define CONFIG_FP_MB_STATS 0
 %define CONFIG_CDEF 1
 %define CONFIG_VAR_TX 1
 %define CONFIG_RECT_TX 1
 %define CONFIG_RECT_TX_EXT 0
 %define CONFIG_TPL_MV 0
-%define CONFIG_DUAL_FILTER 1
+%define CONFIG_DUAL_FILTER 0
 %define CONFIG_CONVOLVE_ROUND 0
 %define CONFIG_COMPOUND_ROUND 0
-%define CONFIG_EXT_TX 1
+%define CONFIG_EXT_TX 0
 %define CONFIG_DPCM_INTRA 0
 %define CONFIG_TX64X64 0
 %define CONFIG_EXT_INTRA 1
 %define CONFIG_INTRA_INTERP 0
 %define CONFIG_FILTER_INTRA 0
 %define CONFIG_INTRA_EDGE 0
 %define CONFIG_INTRABC 0
-%define CONFIG_EXT_INTER 1
-%define CONFIG_INTERINTRA 1
-%define CONFIG_WEDGE 1
-%define CONFIG_COMPOUND_SEGMENT 1
-%define CONFIG_EXT_REFS 1
-%define CONFIG_GLOBAL_MOTION 1
+%define CONFIG_EXT_INTER 0
+%define CONFIG_INTERINTRA 0
+%define CONFIG_WEDGE 0
+%define CONFIG_COMPOUND_SEGMENT 0
+%define CONFIG_EXT_REFS 0
+%define CONFIG_SPEED_REFS 0
+%define CONFIG_GF_GROUPS 0
+%define CONFIG_GLOBAL_MOTION 0
 %define CONFIG_NEW_QUANT 0
 %define CONFIG_SUPERTX 0
 %define CONFIG_ANS 0
 %define CONFIG_LOOP_RESTORATION 0
 %define CONFIG_EXT_PARTITION 0
 %define CONFIG_EXT_PARTITION_TYPES 0
 %define CONFIG_UNPOISON_PARTITION_CTX 0
 %define CONFIG_EXT_TILE 0
 %define CONFIG_MOTION_VAR 1
 %define CONFIG_NCOBMC 0
-%define CONFIG_WARPED_MOTION 1
+%define CONFIG_WARPED_MOTION 0
 %define CONFIG_Q_ADAPT_PROBS 0
 %define CONFIG_BITSTREAM_DEBUG 0
 %define CONFIG_ALT_INTRA 1
 %define CONFIG_PALETTE 1
 %define CONFIG_PALETTE_DELTA_ENCODING 0
 %define CONFIG_RAWBITS 0
 %define CONFIG_EC_SMALLMUL 1
 %define CONFIG_PVQ 0
 %define CONFIG_CFL 0
-%define CONFIG_XIPHRC 0
+%define CONFIG_XIPHRC 1
 %define CONFIG_CB4X4 1
 %define CONFIG_CHROMA_2X2 0
 %define CONFIG_CHROMA_SUB8X8 1
 %define CONFIG_FRAME_SIZE 0
 %define CONFIG_DELTA_Q 1
 %define CONFIG_EXT_DELTA_Q 1
 %define CONFIG_ADAPT_SCAN 0
 %define CONFIG_FILTER_7BIT 1
@@ -136,11 +139,18 @@
 %define CONFIG_LV_MAP 0
 %define CONFIG_TXK_SEL 0
 %define CONFIG_MV_COMPRESS 1
 %define CONFIG_FRAME_SUPERRES 0
 %define CONFIG_NEW_MULTISYMBOL 0
 %define CONFIG_COMPOUND_SINGLEREF 0
 %define CONFIG_AOM_QM 0
 %define CONFIG_ONE_SIDED_COMPOUND 1
-%define CONFIG_SMOOTH_HV 0
+%define CONFIG_EXT_COMP_REFS 0
+%define CONFIG_SMOOTH_HV 1
 %define CONFIG_VAR_REFS 0
+%define CONFIG_RECT_INTRA_PRED 0
+%define CONFIG_LGT 0
+%define CONFIG_SBL_SYMBOL 0
+%define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+%define CONFIG_BGSPRITE 0
+%define CONFIG_VAR_TX_NO_TX_MODE 0
 %define CONFIG_ANALYZER 0
--- a/media/libaom/config/linux/x64/aom_config.h
+++ b/media/libaom/config/linux/x64/aom_config.h
@@ -4,17 +4,17 @@
 /* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License */
 /* was not distributed with this source code in the LICENSE file, you can */
 /* obtain it at www.aomedia.org/license/software. If the Alliance for Open */
 /* Media Patent License 1.0 was not distributed with this source code in the */
 /* PATENTS file, you can obtain it at www.aomedia.org/license/patent. */
 /* This file automatically generated by configure. Do not edit! */
 #ifndef AOM_CONFIG_H
 #define AOM_CONFIG_H
-#define RESTRICT
+#define RESTRICT    
 #define INLINE      inline
 #define ARCH_ARM 0
 #define ARCH_MIPS 0
 #define ARCH_X86 0
 #define ARCH_X86_64 1
 #define HAVE_NEON 0
 #define HAVE_NEON_ASM 0
 #define HAVE_MIPS32 0
@@ -73,60 +73,63 @@
 #define CONFIG_INSPECTION 0
 #define CONFIG_DECODE_PERF_TESTS 0
 #define CONFIG_ENCODE_PERF_TESTS 0
 #define CONFIG_COEFFICIENT_RANGE_CHECKING 0
 #define CONFIG_LOWBITDEPTH 1
 #define CONFIG_HIGHBITDEPTH 1
 #define CONFIG_EXPERIMENTAL 0
 #define CONFIG_SIZE_LIMIT 1
+#define CONFIG_COLORSPACE_HEADERS 0
 #define CONFIG_FP_MB_STATS 0
 #define CONFIG_CDEF 1
 #define CONFIG_VAR_TX 1
 #define CONFIG_RECT_TX 1
 #define CONFIG_RECT_TX_EXT 0
 #define CONFIG_TPL_MV 0
-#define CONFIG_DUAL_FILTER 1
+#define CONFIG_DUAL_FILTER 0
 #define CONFIG_CONVOLVE_ROUND 0
 #define CONFIG_COMPOUND_ROUND 0
-#define CONFIG_EXT_TX 1
+#define CONFIG_EXT_TX 0
 #define CONFIG_DPCM_INTRA 0
 #define CONFIG_TX64X64 0
 #define CONFIG_EXT_INTRA 1
 #define CONFIG_INTRA_INTERP 0
 #define CONFIG_FILTER_INTRA 0
 #define CONFIG_INTRA_EDGE 0
 #define CONFIG_INTRABC 0
-#define CONFIG_EXT_INTER 1
-#define CONFIG_INTERINTRA 1
-#define CONFIG_WEDGE 1
-#define CONFIG_COMPOUND_SEGMENT 1
-#define CONFIG_EXT_REFS 1
-#define CONFIG_GLOBAL_MOTION 1
+#define CONFIG_EXT_INTER 0
+#define CONFIG_INTERINTRA 0
+#define CONFIG_WEDGE 0
+#define CONFIG_COMPOUND_SEGMENT 0
+#define CONFIG_EXT_REFS 0
+#define CONFIG_SPEED_REFS 0
+#define CONFIG_GF_GROUPS 0
+#define CONFIG_GLOBAL_MOTION 0
 #define CONFIG_NEW_QUANT 0
 #define CONFIG_SUPERTX 0
 #define CONFIG_ANS 0
 #define CONFIG_LOOP_RESTORATION 0
 #define CONFIG_EXT_PARTITION 0
 #define CONFIG_EXT_PARTITION_TYPES 0
 #define CONFIG_UNPOISON_PARTITION_CTX 0
 #define CONFIG_EXT_TILE 0
 #define CONFIG_MOTION_VAR 1
 #define CONFIG_NCOBMC 0
-#define CONFIG_WARPED_MOTION 1
+#define CONFIG_WARPED_MOTION 0
 #define CONFIG_Q_ADAPT_PROBS 0
 #define CONFIG_BITSTREAM_DEBUG 0
 #define CONFIG_ALT_INTRA 1
 #define CONFIG_PALETTE 1
 #define CONFIG_PALETTE_DELTA_ENCODING 0
 #define CONFIG_RAWBITS 0
 #define CONFIG_EC_SMALLMUL 1
 #define CONFIG_PVQ 0
 #define CONFIG_CFL 0
-#define CONFIG_XIPHRC 0
+#define CONFIG_XIPHRC 1
 #define CONFIG_CB4X4 1
 #define CONFIG_CHROMA_2X2 0
 #define CONFIG_CHROMA_SUB8X8 1
 #define CONFIG_FRAME_SIZE 0
 #define CONFIG_DELTA_Q 1
 #define CONFIG_EXT_DELTA_Q 1
 #define CONFIG_ADAPT_SCAN 0
 #define CONFIG_FILTER_7BIT 1
@@ -149,14 +152,21 @@
 #define CONFIG_LV_MAP 0
 #define CONFIG_TXK_SEL 0
 #define CONFIG_MV_COMPRESS 1
 #define CONFIG_FRAME_SUPERRES 0
 #define CONFIG_NEW_MULTISYMBOL 0
 #define CONFIG_COMPOUND_SINGLEREF 0
 #define CONFIG_AOM_QM 0
 #define CONFIG_ONE_SIDED_COMPOUND 1
-#define CONFIG_SMOOTH_HV 0
+#define CONFIG_EXT_COMP_REFS 0
+#define CONFIG_SMOOTH_HV 1
 #define CONFIG_VAR_REFS 0
+#define CONFIG_RECT_INTRA_PRED 0
+#define CONFIG_LGT 0
+#define CONFIG_SBL_SYMBOL 0
+#define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+#define CONFIG_BGSPRITE 0
+#define CONFIG_VAR_TX_NO_TX_MODE 0
 #define CONFIG_ANALYZER 0
 #define DECODE_WIDTH_LIMIT 8192
 #define DECODE_HEIGHT_LIMIT 4608
 #endif /* AOM_CONFIG_H */
--- a/media/libaom/config/linux/x64/aom_dsp_rtcd.h
+++ b/media/libaom/config/linux/x64/aom_dsp_rtcd.h
@@ -30,257 +30,439 @@ RTCD_EXTERN void (*aom_blend_a64_mask)(u
 
 void aom_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 void aom_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 RTCD_EXTERN void (*aom_blend_a64_vmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 
 void aom_comp_avg_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
 #define aom_comp_avg_pred aom_comp_avg_pred_c
 
-void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
-void aom_comp_avg_upsampled_pred_sse2(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
+void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+void aom_comp_avg_upsampled_pred_sse2(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 #define aom_comp_avg_upsampled_pred aom_comp_avg_upsampled_pred_sse2
 
-void aom_comp_mask_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_pred aom_comp_mask_pred_c
-
-void aom_comp_mask_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_upsampled_pred aom_comp_mask_upsampled_pred_c
-
 void aom_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_horiz_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_horiz_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_avg_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_horiz_scale aom_convolve8_avg_horiz_scale_c
+
+void aom_convolve8_avg_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_scale aom_convolve8_avg_scale_c
+
 void aom_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_vert_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_vert_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_avg_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_vert_scale aom_convolve8_avg_vert_scale_c
+
 void aom_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_horiz_scale aom_convolve8_horiz_scale_c
+
+void aom_convolve8_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_scale aom_convolve8_scale_c
+
 void aom_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_vert_scale aom_convolve8_vert_scale_c
+
 void aom_convolve_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve_avg aom_convolve_avg_sse2
 
 void aom_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve_copy_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve_copy aom_convolve_copy_sse2
 
 void aom_d117_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_16x16 aom_d117_predictor_16x16_c
 
+void aom_d117_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x32 aom_d117_predictor_16x32_c
+
+void aom_d117_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x8 aom_d117_predictor_16x8_c
+
 void aom_d117_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_2x2 aom_d117_predictor_2x2_c
 
+void aom_d117_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_32x16 aom_d117_predictor_32x16_c
+
 void aom_d117_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_32x32 aom_d117_predictor_32x32_c
 
 void aom_d117_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_4x4 aom_d117_predictor_4x4_c
 
+void aom_d117_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_4x8 aom_d117_predictor_4x8_c
+
+void aom_d117_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x16 aom_d117_predictor_8x16_c
+
+void aom_d117_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x4 aom_d117_predictor_8x4_c
+
 void aom_d117_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_8x8 aom_d117_predictor_8x8_c
 
 void aom_d135_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_16x16 aom_d135_predictor_16x16_c
 
+void aom_d135_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x32 aom_d135_predictor_16x32_c
+
+void aom_d135_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x8 aom_d135_predictor_16x8_c
+
 void aom_d135_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_2x2 aom_d135_predictor_2x2_c
 
+void aom_d135_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_32x16 aom_d135_predictor_32x16_c
+
 void aom_d135_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_32x32 aom_d135_predictor_32x32_c
 
 void aom_d135_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_4x4 aom_d135_predictor_4x4_c
 
+void aom_d135_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_4x8 aom_d135_predictor_4x8_c
+
+void aom_d135_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x16 aom_d135_predictor_8x16_c
+
+void aom_d135_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x4 aom_d135_predictor_8x4_c
+
 void aom_d135_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_8x8 aom_d135_predictor_8x8_c
 
 void aom_d153_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_16x16_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d153_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x32 aom_d153_predictor_16x32_c
+
+void aom_d153_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x8 aom_d153_predictor_16x8_c
+
 void aom_d153_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_2x2 aom_d153_predictor_2x2_c
 
+void aom_d153_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_32x16 aom_d153_predictor_32x16_c
+
 void aom_d153_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_32x32_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_d153_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d153_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_4x8 aom_d153_predictor_4x8_c
+
+void aom_d153_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x16 aom_d153_predictor_8x16_c
+
+void aom_d153_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x4 aom_d153_predictor_8x4_c
+
 void aom_d153_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_8x8_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_d207e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_16x16 aom_d207e_predictor_16x16_c
 
+void aom_d207e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x32 aom_d207e_predictor_16x32_c
+
+void aom_d207e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x8 aom_d207e_predictor_16x8_c
+
 void aom_d207e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_2x2 aom_d207e_predictor_2x2_c
 
+void aom_d207e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_32x16 aom_d207e_predictor_32x16_c
+
 void aom_d207e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_32x32 aom_d207e_predictor_32x32_c
 
 void aom_d207e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_4x4 aom_d207e_predictor_4x4_c
 
+void aom_d207e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_4x8 aom_d207e_predictor_4x8_c
+
+void aom_d207e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x16 aom_d207e_predictor_8x16_c
+
+void aom_d207e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x4 aom_d207e_predictor_8x4_c
+
 void aom_d207e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_8x8 aom_d207e_predictor_8x8_c
 
 void aom_d45e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_16x16 aom_d45e_predictor_16x16_c
 
+void aom_d45e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x32 aom_d45e_predictor_16x32_c
+
+void aom_d45e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x8 aom_d45e_predictor_16x8_c
+
 void aom_d45e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_2x2 aom_d45e_predictor_2x2_c
 
+void aom_d45e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_32x16 aom_d45e_predictor_32x16_c
+
 void aom_d45e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_32x32 aom_d45e_predictor_32x32_c
 
 void aom_d45e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_4x4 aom_d45e_predictor_4x4_c
 
+void aom_d45e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_4x8 aom_d45e_predictor_4x8_c
+
+void aom_d45e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x16 aom_d45e_predictor_8x16_c
+
+void aom_d45e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x4 aom_d45e_predictor_8x4_c
+
 void aom_d45e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_8x8 aom_d45e_predictor_8x8_c
 
 void aom_d63e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_16x16 aom_d63e_predictor_16x16_c
 
+void aom_d63e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x32 aom_d63e_predictor_16x32_c
+
+void aom_d63e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x8 aom_d63e_predictor_16x8_c
+
 void aom_d63e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_2x2 aom_d63e_predictor_2x2_c
 
+void aom_d63e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_32x16 aom_d63e_predictor_32x16_c
+
 void aom_d63e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_32x32 aom_d63e_predictor_32x32_c
 
 void aom_d63e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d63e_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d63e_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d63e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_4x8 aom_d63e_predictor_4x8_c
+
+void aom_d63e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x16 aom_d63e_predictor_8x16_c
+
+void aom_d63e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x4 aom_d63e_predictor_8x4_c
+
 void aom_d63e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_8x8 aom_d63e_predictor_8x8_c
 
 void aom_dc_128_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_16x16 aom_dc_128_predictor_16x16_sse2
 
+void aom_dc_128_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x32 aom_dc_128_predictor_16x32_c
+
+void aom_dc_128_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x8 aom_dc_128_predictor_16x8_c
+
 void aom_dc_128_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_2x2 aom_dc_128_predictor_2x2_c
 
+void aom_dc_128_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_32x16 aom_dc_128_predictor_32x16_c
+
 void aom_dc_128_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_32x32 aom_dc_128_predictor_32x32_sse2
 
 void aom_dc_128_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_4x4 aom_dc_128_predictor_4x4_sse2
 
+void aom_dc_128_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_4x8 aom_dc_128_predictor_4x8_c
+
+void aom_dc_128_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x16 aom_dc_128_predictor_8x16_c
+
+void aom_dc_128_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x4 aom_dc_128_predictor_8x4_c
+
 void aom_dc_128_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_8x8 aom_dc_128_predictor_8x8_sse2
 
 void aom_dc_left_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_16x16 aom_dc_left_predictor_16x16_sse2
 
+void aom_dc_left_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x32 aom_dc_left_predictor_16x32_c
+
+void aom_dc_left_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x8 aom_dc_left_predictor_16x8_c
+
 void aom_dc_left_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_2x2 aom_dc_left_predictor_2x2_c
 
+void aom_dc_left_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_32x16 aom_dc_left_predictor_32x16_c
+
 void aom_dc_left_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_32x32 aom_dc_left_predictor_32x32_sse2
 
 void aom_dc_left_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_4x4 aom_dc_left_predictor_4x4_sse2
 
+void aom_dc_left_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_4x8 aom_dc_left_predictor_4x8_c
+
+void aom_dc_left_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x16 aom_dc_left_predictor_8x16_c
+
+void aom_dc_left_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x4 aom_dc_left_predictor_8x4_c
+
 void aom_dc_left_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_8x8 aom_dc_left_predictor_8x8_sse2
 
 void aom_dc_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_16x16 aom_dc_predictor_16x16_sse2
 
+void aom_dc_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x32 aom_dc_predictor_16x32_c
+
+void aom_dc_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x8 aom_dc_predictor_16x8_c
+
 void aom_dc_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_2x2 aom_dc_predictor_2x2_c
 
+void aom_dc_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_32x16 aom_dc_predictor_32x16_c
+
 void aom_dc_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_32x32 aom_dc_predictor_32x32_sse2
 
 void aom_dc_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_4x4 aom_dc_predictor_4x4_sse2
 
+void aom_dc_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_4x8 aom_dc_predictor_4x8_c
+
+void aom_dc_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x16 aom_dc_predictor_8x16_c
+
+void aom_dc_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x4 aom_dc_predictor_8x4_c
+
 void aom_dc_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_8x8 aom_dc_predictor_8x8_sse2
 
 void aom_dc_top_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_16x16 aom_dc_top_predictor_16x16_sse2
 
+void aom_dc_top_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x32 aom_dc_top_predictor_16x32_c
+
+void aom_dc_top_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x8 aom_dc_top_predictor_16x8_c
+
 void aom_dc_top_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_2x2 aom_dc_top_predictor_2x2_c
 
+void aom_dc_top_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_32x16 aom_dc_top_predictor_32x16_c
+
 void aom_dc_top_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_32x32 aom_dc_top_predictor_32x32_sse2
 
 void aom_dc_top_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_4x4 aom_dc_top_predictor_4x4_sse2
 
+void aom_dc_top_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_4x8 aom_dc_top_predictor_4x8_c
+
+void aom_dc_top_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x16 aom_dc_top_predictor_8x16_c
+
+void aom_dc_top_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x4 aom_dc_top_predictor_8x4_c
+
 void aom_dc_top_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_8x8 aom_dc_top_predictor_8x8_sse2
 
 void aom_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct16x16_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct16x16 aom_fdct16x16_sse2
 
-void aom_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct16x16_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct16x16_1_avx2(const int16_t *input, tran_low_t *output, int stride);
-RTCD_EXTERN void (*aom_fdct16x16_1)(const int16_t *input, tran_low_t *output, int stride);
-
 void aom_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_avx2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct32x32)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct32x32_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct32x32_1_avx2(const int16_t *input, tran_low_t *output, int stride);
-RTCD_EXTERN void (*aom_fdct32x32_1)(const int16_t *input, tran_low_t *output, int stride);
-
 void aom_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_rd_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_rd_avx2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct32x32_rd)(const int16_t *input, tran_low_t *output, int stride);
 
 void aom_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct4x4_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct4x4 aom_fdct4x4_sse2
@@ -289,20 +471,16 @@ void aom_fdct4x4_1_c(const int16_t *inpu
 void aom_fdct4x4_1_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct4x4_1 aom_fdct4x4_1_sse2
 
 void aom_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct8x8_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct8x8_ssse3(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct8x8)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct8x8_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-#define aom_fdct8x8_1 aom_fdct8x8_1_sse2
-
 void aom_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 void aom_get16x16var_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 void aom_get16x16var_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 RTCD_EXTERN void (*aom_get16x16var)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 
 unsigned int aom_get4x4sse_cs_c(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int ref_stride);
 #define aom_get4x4sse_cs aom_get4x4sse_cs_c
 
@@ -313,27 +491,45 @@ void aom_get8x8var_sse2(const uint8_t *s
 unsigned int aom_get_mb_ss_c(const int16_t *);
 unsigned int aom_get_mb_ss_sse2(const int16_t *);
 #define aom_get_mb_ss aom_get_mb_ss_sse2
 
 void aom_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_16x16 aom_h_predictor_16x16_sse2
 
+void aom_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x32 aom_h_predictor_16x32_c
+
+void aom_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x8 aom_h_predictor_16x8_c
+
 void aom_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_2x2 aom_h_predictor_2x2_c
 
+void aom_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_32x16 aom_h_predictor_32x16_c
+
 void aom_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_32x32 aom_h_predictor_32x32_sse2
 
 void aom_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_4x4 aom_h_predictor_4x4_sse2
 
+void aom_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_4x8 aom_h_predictor_4x8_c
+
+void aom_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x16 aom_h_predictor_8x16_c
+
+void aom_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x4 aom_h_predictor_8x4_c
+
 void aom_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_8x8 aom_h_predictor_8x8_sse2
 
 void aom_hadamard_16x16_c(const int16_t *src_diff, int src_stride, int16_t *coeff);
 void aom_hadamard_16x16_sse2(const int16_t *src_diff, int src_stride, int16_t *coeff);
 #define aom_hadamard_16x16 aom_hadamard_16x16_sse2
 
@@ -343,68 +539,16 @@ void aom_hadamard_8x8_ssse3(const int16_
 RTCD_EXTERN void (*aom_hadamard_8x8)(const int16_t *src_diff, int src_stride, int16_t *coeff);
 
 void aom_highbd_10_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get16x16var aom_highbd_10_get16x16var_c
 
 void aom_highbd_10_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get8x8var aom_highbd_10_get8x8var_c
 
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_10_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_10_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse16x16 aom_highbd_10_mse16x16_sse2
 
 unsigned int aom_highbd_10_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse16x8 aom_highbd_10_mse16x8_c
 
 unsigned int aom_highbd_10_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -667,68 +811,16 @@ unsigned int aom_highbd_10_variance8x8_s
 #define aom_highbd_10_variance8x8 aom_highbd_10_variance8x8_sse2
 
 void aom_highbd_12_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get16x16var aom_highbd_12_get16x16var_c
 
 void aom_highbd_12_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get8x8var aom_highbd_12_get8x8var_c
 
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_12_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_12_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse16x16 aom_highbd_12_mse16x16_sse2
 
 unsigned int aom_highbd_12_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse16x8 aom_highbd_12_mse16x8_c
 
 unsigned int aom_highbd_12_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -991,68 +1083,16 @@ unsigned int aom_highbd_12_variance8x8_s
 #define aom_highbd_12_variance8x8 aom_highbd_12_variance8x8_sse2
 
 void aom_highbd_8_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get16x16var aom_highbd_8_get16x16var_c
 
 void aom_highbd_8_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get8x8var aom_highbd_8_get8x8var_c
 
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_8_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_8_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse16x16 aom_highbd_8_mse16x16_sse2
 
 unsigned int aom_highbd_8_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse16x8 aom_highbd_8_mse16x8_c
 
 unsigned int aom_highbd_8_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -1233,26 +1273,20 @@ RTCD_EXTERN void (*aom_highbd_blend_a64_
 
 void aom_highbd_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 void aom_highbd_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 RTCD_EXTERN void (*aom_highbd_blend_a64_vmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 
 void aom_highbd_comp_avg_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
 #define aom_highbd_comp_avg_pred aom_highbd_comp_avg_pred_c
 
-void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
-void aom_highbd_comp_avg_upsampled_pred_sse2(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
+void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+void aom_highbd_comp_avg_upsampled_pred_sse2(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 #define aom_highbd_comp_avg_upsampled_pred aom_highbd_comp_avg_upsampled_pred_sse2
 
-void aom_highbd_comp_mask_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_pred aom_highbd_comp_mask_pred_c
-
-void aom_highbd_comp_mask_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_upsampled_pred aom_highbd_comp_mask_upsampled_pred_c
-
 void aom_highbd_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 RTCD_EXTERN void (*aom_highbd_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 
 void aom_highbd_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avg_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
@@ -1286,233 +1320,400 @@ RTCD_EXTERN void (*aom_highbd_convolve_a
 void aom_highbd_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve_copy_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve_copy_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 RTCD_EXTERN void (*aom_highbd_convolve_copy)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 
 void aom_highbd_d117_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_16x16 aom_highbd_d117_predictor_16x16_c
 
+void aom_highbd_d117_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x32 aom_highbd_d117_predictor_16x32_c
+
+void aom_highbd_d117_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x8 aom_highbd_d117_predictor_16x8_c
+
 void aom_highbd_d117_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_2x2 aom_highbd_d117_predictor_2x2_c
 
+void aom_highbd_d117_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_32x16 aom_highbd_d117_predictor_32x16_c
+
 void aom_highbd_d117_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_32x32 aom_highbd_d117_predictor_32x32_c
 
 void aom_highbd_d117_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_4x4 aom_highbd_d117_predictor_4x4_c
 
+void aom_highbd_d117_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_4x8 aom_highbd_d117_predictor_4x8_c
+
+void aom_highbd_d117_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x16 aom_highbd_d117_predictor_8x16_c
+
+void aom_highbd_d117_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x4 aom_highbd_d117_predictor_8x4_c
+
 void aom_highbd_d117_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_8x8 aom_highbd_d117_predictor_8x8_c
 
 void aom_highbd_d135_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_16x16 aom_highbd_d135_predictor_16x16_c
 
+void aom_highbd_d135_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x32 aom_highbd_d135_predictor_16x32_c
+
+void aom_highbd_d135_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x8 aom_highbd_d135_predictor_16x8_c
+
 void aom_highbd_d135_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_2x2 aom_highbd_d135_predictor_2x2_c
 
+void aom_highbd_d135_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_32x16 aom_highbd_d135_predictor_32x16_c
+
 void aom_highbd_d135_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_32x32 aom_highbd_d135_predictor_32x32_c
 
 void aom_highbd_d135_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_4x4 aom_highbd_d135_predictor_4x4_c
 
+void aom_highbd_d135_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_4x8 aom_highbd_d135_predictor_4x8_c
+
+void aom_highbd_d135_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x16 aom_highbd_d135_predictor_8x16_c
+
+void aom_highbd_d135_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x4 aom_highbd_d135_predictor_8x4_c
+
 void aom_highbd_d135_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_8x8 aom_highbd_d135_predictor_8x8_c
 
 void aom_highbd_d153_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_16x16 aom_highbd_d153_predictor_16x16_c
 
+void aom_highbd_d153_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x32 aom_highbd_d153_predictor_16x32_c
+
+void aom_highbd_d153_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x8 aom_highbd_d153_predictor_16x8_c
+
 void aom_highbd_d153_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_2x2 aom_highbd_d153_predictor_2x2_c
 
+void aom_highbd_d153_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_32x16 aom_highbd_d153_predictor_32x16_c
+
 void aom_highbd_d153_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_32x32 aom_highbd_d153_predictor_32x32_c
 
 void aom_highbd_d153_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_4x4 aom_highbd_d153_predictor_4x4_c
 
+void aom_highbd_d153_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_4x8 aom_highbd_d153_predictor_4x8_c
+
+void aom_highbd_d153_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x16 aom_highbd_d153_predictor_8x16_c
+
+void aom_highbd_d153_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x4 aom_highbd_d153_predictor_8x4_c
+
 void aom_highbd_d153_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_8x8 aom_highbd_d153_predictor_8x8_c
 
 void aom_highbd_d207e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_16x16 aom_highbd_d207e_predictor_16x16_c
 
+void aom_highbd_d207e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x32 aom_highbd_d207e_predictor_16x32_c
+
+void aom_highbd_d207e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x8 aom_highbd_d207e_predictor_16x8_c
+
 void aom_highbd_d207e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_2x2 aom_highbd_d207e_predictor_2x2_c
 
+void aom_highbd_d207e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_32x16 aom_highbd_d207e_predictor_32x16_c
+
 void aom_highbd_d207e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_32x32 aom_highbd_d207e_predictor_32x32_c
 
 void aom_highbd_d207e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_4x4 aom_highbd_d207e_predictor_4x4_c
 
+void aom_highbd_d207e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_4x8 aom_highbd_d207e_predictor_4x8_c
+
+void aom_highbd_d207e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x16 aom_highbd_d207e_predictor_8x16_c
+
+void aom_highbd_d207e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x4 aom_highbd_d207e_predictor_8x4_c
+
 void aom_highbd_d207e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_8x8 aom_highbd_d207e_predictor_8x8_c
 
 void aom_highbd_d45e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_16x16 aom_highbd_d45e_predictor_16x16_c
 
+void aom_highbd_d45e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x32 aom_highbd_d45e_predictor_16x32_c
+
+void aom_highbd_d45e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x8 aom_highbd_d45e_predictor_16x8_c
+
 void aom_highbd_d45e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_2x2 aom_highbd_d45e_predictor_2x2_c
 
+void aom_highbd_d45e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_32x16 aom_highbd_d45e_predictor_32x16_c
+
 void aom_highbd_d45e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_32x32 aom_highbd_d45e_predictor_32x32_c
 
 void aom_highbd_d45e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_4x4 aom_highbd_d45e_predictor_4x4_c
 
+void aom_highbd_d45e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_4x8 aom_highbd_d45e_predictor_4x8_c
+
+void aom_highbd_d45e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x16 aom_highbd_d45e_predictor_8x16_c
+
+void aom_highbd_d45e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x4 aom_highbd_d45e_predictor_8x4_c
+
 void aom_highbd_d45e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_8x8 aom_highbd_d45e_predictor_8x8_c
 
 void aom_highbd_d63e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_16x16 aom_highbd_d63e_predictor_16x16_c
 
+void aom_highbd_d63e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x32 aom_highbd_d63e_predictor_16x32_c
+
+void aom_highbd_d63e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x8 aom_highbd_d63e_predictor_16x8_c
+
 void aom_highbd_d63e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_2x2 aom_highbd_d63e_predictor_2x2_c
 
+void aom_highbd_d63e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_32x16 aom_highbd_d63e_predictor_32x16_c
+
 void aom_highbd_d63e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_32x32 aom_highbd_d63e_predictor_32x32_c
 
 void aom_highbd_d63e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_4x4 aom_highbd_d63e_predictor_4x4_c
 
+void aom_highbd_d63e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_4x8 aom_highbd_d63e_predictor_4x8_c
+
+void aom_highbd_d63e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x16 aom_highbd_d63e_predictor_8x16_c
+
+void aom_highbd_d63e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x4 aom_highbd_d63e_predictor_8x4_c
+
 void aom_highbd_d63e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_8x8 aom_highbd_d63e_predictor_8x8_c
 
 void aom_highbd_dc_128_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_16x16 aom_highbd_dc_128_predictor_16x16_c
 
+void aom_highbd_dc_128_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x32 aom_highbd_dc_128_predictor_16x32_c
+
+void aom_highbd_dc_128_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x8 aom_highbd_dc_128_predictor_16x8_c
+
 void aom_highbd_dc_128_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_2x2 aom_highbd_dc_128_predictor_2x2_c
 
+void aom_highbd_dc_128_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_32x16 aom_highbd_dc_128_predictor_32x16_c
+
 void aom_highbd_dc_128_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_32x32 aom_highbd_dc_128_predictor_32x32_c
 
 void aom_highbd_dc_128_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_4x4 aom_highbd_dc_128_predictor_4x4_c
 
+void aom_highbd_dc_128_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_4x8 aom_highbd_dc_128_predictor_4x8_c
+
+void aom_highbd_dc_128_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x16 aom_highbd_dc_128_predictor_8x16_c
+
+void aom_highbd_dc_128_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x4 aom_highbd_dc_128_predictor_8x4_c
+
 void aom_highbd_dc_128_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_8x8 aom_highbd_dc_128_predictor_8x8_c
 
 void aom_highbd_dc_left_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_16x16 aom_highbd_dc_left_predictor_16x16_c
 
+void aom_highbd_dc_left_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x32 aom_highbd_dc_left_predictor_16x32_c
+
+void aom_highbd_dc_left_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x8 aom_highbd_dc_left_predictor_16x8_c
+
 void aom_highbd_dc_left_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_2x2 aom_highbd_dc_left_predictor_2x2_c
 
+void aom_highbd_dc_left_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_32x16 aom_highbd_dc_left_predictor_32x16_c
+
 void aom_highbd_dc_left_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_32x32 aom_highbd_dc_left_predictor_32x32_c
 
 void aom_highbd_dc_left_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_4x4 aom_highbd_dc_left_predictor_4x4_c
 
+void aom_highbd_dc_left_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_4x8 aom_highbd_dc_left_predictor_4x8_c
+
+void aom_highbd_dc_left_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x16 aom_highbd_dc_left_predictor_8x16_c
+
+void aom_highbd_dc_left_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x4 aom_highbd_dc_left_predictor_8x4_c
+
 void aom_highbd_dc_left_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_8x8 aom_highbd_dc_left_predictor_8x8_c
 
 void aom_highbd_dc_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_16x16_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_16x16 aom_highbd_dc_predictor_16x16_sse2
 
+void aom_highbd_dc_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x32 aom_highbd_dc_predictor_16x32_c
+
+void aom_highbd_dc_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x8 aom_highbd_dc_predictor_16x8_c
+
 void aom_highbd_dc_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_2x2 aom_highbd_dc_predictor_2x2_c
 
+void aom_highbd_dc_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_32x16 aom_highbd_dc_predictor_32x16_c
+
 void aom_highbd_dc_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_32x32_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_32x32 aom_highbd_dc_predictor_32x32_sse2
 
 void aom_highbd_dc_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_4x4_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_4x4 aom_highbd_dc_predictor_4x4_sse2
 
+void aom_highbd_dc_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_4x8 aom_highbd_dc_predictor_4x8_c
+
+void aom_highbd_dc_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x16 aom_highbd_dc_predictor_8x16_c
+
+void aom_highbd_dc_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x4 aom_highbd_dc_predictor_8x4_c
+
 void aom_highbd_dc_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_8x8_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_8x8 aom_highbd_dc_predictor_8x8_sse2
 
 void aom_highbd_dc_top_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_16x16 aom_highbd_dc_top_predictor_16x16_c
 
+void aom_highbd_dc_top_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x32 aom_highbd_dc_top_predictor_16x32_c
+
+void aom_highbd_dc_top_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x8 aom_highbd_dc_top_predictor_16x8_c
+
 void aom_highbd_dc_top_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_2x2 aom_highbd_dc_top_predictor_2x2_c
 
+void aom_highbd_dc_top_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_32x16 aom_highbd_dc_top_predictor_32x16_c
+
 void aom_highbd_dc_top_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_32x32 aom_highbd_dc_top_predictor_32x32_c
 
 void aom_highbd_dc_top_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_4x4 aom_highbd_dc_top_predictor_4x4_c
 
+void aom_highbd_dc_top_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_4x8 aom_highbd_dc_top_predictor_4x8_c
+
+void aom_highbd_dc_top_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x16 aom_highbd_dc_top_predictor_8x16_c
+
+void aom_highbd_dc_top_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x4 aom_highbd_dc_top_predictor_8x4_c
+
 void aom_highbd_dc_top_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_8x8 aom_highbd_dc_top_predictor_8x8_c
 
 void aom_highbd_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct16x16_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct16x16 aom_highbd_fdct16x16_sse2
 
-void aom_highbd_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct16x16_1 aom_highbd_fdct16x16_1_c
-
 void aom_highbd_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct32x32_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct32x32 aom_highbd_fdct32x32_sse2
 
-void aom_highbd_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct32x32_1 aom_highbd_fdct32x32_1_c
-
 void aom_highbd_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct32x32_rd_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct32x32_rd aom_highbd_fdct32x32_rd_sse2
 
 void aom_highbd_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct4x4_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct4x4 aom_highbd_fdct4x4_sse2
 
 void aom_highbd_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct8x8_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct8x8 aom_highbd_fdct8x8_sse2
 
-void aom_highbd_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct8x8_1 aom_highbd_fdct8x8_1_c
-
 void aom_highbd_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_16x16 aom_highbd_h_predictor_16x16_c
 
+void aom_highbd_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x32 aom_highbd_h_predictor_16x32_c
+
+void aom_highbd_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x8 aom_highbd_h_predictor_16x8_c
+
 void aom_highbd_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_2x2 aom_highbd_h_predictor_2x2_c
 
+void aom_highbd_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_32x16 aom_highbd_h_predictor_32x16_c
+
 void aom_highbd_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_32x32 aom_highbd_h_predictor_32x32_c
 
 void aom_highbd_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_4x4 aom_highbd_h_predictor_4x4_c
 
+void aom_highbd_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_4x8 aom_highbd_h_predictor_4x8_c
+
+void aom_highbd_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x16 aom_highbd_h_predictor_8x16_c
+
+void aom_highbd_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x4 aom_highbd_h_predictor_8x4_c
+
 void aom_highbd_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_8x8 aom_highbd_h_predictor_8x8_c
 
-void aom_highbd_idct16x16_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct16x16_1_add aom_highbd_idct16x16_1_add_c
-
-void aom_highbd_idct32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1024_add aom_highbd_idct32x32_1024_add_c
-
-void aom_highbd_idct32x32_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1_add aom_highbd_idct32x32_1_add_c
-
-void aom_highbd_idct32x32_34_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_34_add aom_highbd_idct32x32_34_add_c
-
-void aom_highbd_idct4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-void aom_highbd_idct4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct4x4_16_add aom_highbd_idct4x4_16_add_sse2
-
-void aom_highbd_idct4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct4x4_1_add aom_highbd_idct4x4_1_add_c
-
-void aom_highbd_idct8x8_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct8x8_1_add aom_highbd_idct8x8_1_add_c
-
 void aom_highbd_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_16_add aom_highbd_iwht4x4_16_add_c
 
 void aom_highbd_iwht4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_1_add aom_highbd_iwht4x4_1_add_c
 
 void aom_highbd_lpf_horizontal_4_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 void aom_highbd_lpf_horizontal_4_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
@@ -1557,68 +1758,16 @@ void aom_highbd_lpf_vertical_4_dual_sse2
 void aom_highbd_lpf_vertical_8_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 void aom_highbd_lpf_vertical_8_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 #define aom_highbd_lpf_vertical_8 aom_highbd_lpf_vertical_8_sse2
 
 void aom_highbd_lpf_vertical_8_dual_c(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 void aom_highbd_lpf_vertical_8_dual_sse2(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 #define aom_highbd_lpf_vertical_8_dual aom_highbd_lpf_vertical_8_dual_sse2
 
-unsigned int aom_highbd_masked_sad16x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad16x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad16x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x64_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x64)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad4x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad4x4_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad4x4)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad4x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad4x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad4x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad64x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad64x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad64x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad64x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad64x64_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad64x64)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x4_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x4)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
 void aom_highbd_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 #define aom_highbd_minmax_8x8 aom_highbd_minmax_8x8_c
 
 unsigned int aom_highbd_obmc_sad16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 unsigned int aom_highbd_obmc_sad16x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad16x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 
 unsigned int aom_highbd_obmc_sad16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
@@ -1758,31 +1907,50 @@ RTCD_EXTERN unsigned int (*aom_highbd_ob
 
 unsigned int aom_highbd_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 unsigned int aom_highbd_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 
 void aom_highbd_paeth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_16x16 aom_highbd_paeth_predictor_16x16_c
 
+void aom_highbd_paeth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x32 aom_highbd_paeth_predictor_16x32_c
+
+void aom_highbd_paeth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x8 aom_highbd_paeth_predictor_16x8_c
+
 void aom_highbd_paeth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_2x2 aom_highbd_paeth_predictor_2x2_c
 
+void aom_highbd_paeth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_32x16 aom_highbd_paeth_predictor_32x16_c
+
 void aom_highbd_paeth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_32x32 aom_highbd_paeth_predictor_32x32_c
 
 void aom_highbd_paeth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_4x4 aom_highbd_paeth_predictor_4x4_c
 
+void aom_highbd_paeth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_4x8 aom_highbd_paeth_predictor_4x8_c
+
+void aom_highbd_paeth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x16 aom_highbd_paeth_predictor_8x16_c
+
+void aom_highbd_paeth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x4 aom_highbd_paeth_predictor_8x4_c
+
 void aom_highbd_paeth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_8x8 aom_highbd_paeth_predictor_8x8_c
 
 void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_highbd_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
-#define aom_highbd_quantize_b aom_highbd_quantize_b_sse2
+void aom_highbd_quantize_b_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*aom_highbd_quantize_b)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void aom_highbd_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_highbd_quantize_b_32x32_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_highbd_quantize_b_32x32 aom_highbd_quantize_b_32x32_sse2
 
 void aom_highbd_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_highbd_quantize_b_64x64 aom_highbd_quantize_b_64x64_c
 
@@ -2005,54 +2173,156 @@ void aom_highbd_sad8x8x3_c(const uint8_t
 
 void aom_highbd_sad8x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 void aom_highbd_sad8x8x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 #define aom_highbd_sad8x8x4d aom_highbd_sad8x8x4d_sse2
 
 void aom_highbd_sad8x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
 #define aom_highbd_sad8x8x8 aom_highbd_sad8x8x8_c
 
+void aom_highbd_smooth_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x16 aom_highbd_smooth_h_predictor_16x16_c
+
+void aom_highbd_smooth_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x32 aom_highbd_smooth_h_predictor_16x32_c
+
+void aom_highbd_smooth_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x8 aom_highbd_smooth_h_predictor_16x8_c
+
+void aom_highbd_smooth_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_2x2 aom_highbd_smooth_h_predictor_2x2_c
+
+void aom_highbd_smooth_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x16 aom_highbd_smooth_h_predictor_32x16_c
+
+void aom_highbd_smooth_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x32 aom_highbd_smooth_h_predictor_32x32_c
+
+void aom_highbd_smooth_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x4 aom_highbd_smooth_h_predictor_4x4_c
+
+void aom_highbd_smooth_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x8 aom_highbd_smooth_h_predictor_4x8_c
+
+void aom_highbd_smooth_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x16 aom_highbd_smooth_h_predictor_8x16_c
+
+void aom_highbd_smooth_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x4 aom_highbd_smooth_h_predictor_8x4_c
+
+void aom_highbd_smooth_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x8 aom_highbd_smooth_h_predictor_8x8_c
+
 void aom_highbd_smooth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_16x16 aom_highbd_smooth_predictor_16x16_c
 
+void aom_highbd_smooth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x32 aom_highbd_smooth_predictor_16x32_c
+
+void aom_highbd_smooth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x8 aom_highbd_smooth_predictor_16x8_c
+
 void aom_highbd_smooth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_2x2 aom_highbd_smooth_predictor_2x2_c
 
+void aom_highbd_smooth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_32x16 aom_highbd_smooth_predictor_32x16_c
+
 void aom_highbd_smooth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_32x32 aom_highbd_smooth_predictor_32x32_c
 
 void aom_highbd_smooth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_4x4 aom_highbd_smooth_predictor_4x4_c
 
+void aom_highbd_smooth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_4x8 aom_highbd_smooth_predictor_4x8_c
+
+void aom_highbd_smooth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x16 aom_highbd_smooth_predictor_8x16_c
+
+void aom_highbd_smooth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x4 aom_highbd_smooth_predictor_8x4_c
+
 void aom_highbd_smooth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_8x8 aom_highbd_smooth_predictor_8x8_c
 
+void aom_highbd_smooth_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x16 aom_highbd_smooth_v_predictor_16x16_c
+
+void aom_highbd_smooth_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x32 aom_highbd_smooth_v_predictor_16x32_c
+
+void aom_highbd_smooth_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x8 aom_highbd_smooth_v_predictor_16x8_c
+
+void aom_highbd_smooth_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_2x2 aom_highbd_smooth_v_predictor_2x2_c
+
+void aom_highbd_smooth_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x16 aom_highbd_smooth_v_predictor_32x16_c
+
+void aom_highbd_smooth_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x32 aom_highbd_smooth_v_predictor_32x32_c
+
+void aom_highbd_smooth_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x4 aom_highbd_smooth_v_predictor_4x4_c
+
+void aom_highbd_smooth_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x8 aom_highbd_smooth_v_predictor_4x8_c
+
+void aom_highbd_smooth_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x16 aom_highbd_smooth_v_predictor_8x16_c
+
+void aom_highbd_smooth_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x4 aom_highbd_smooth_v_predictor_8x4_c
+
+void aom_highbd_smooth_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x8 aom_highbd_smooth_v_predictor_8x8_c
+
 void aom_highbd_subtract_block_c(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 void aom_highbd_subtract_block_sse2(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 #define aom_highbd_subtract_block aom_highbd_subtract_block_sse2
 
-void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
-void aom_highbd_upsampled_pred_sse2(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
+void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+void aom_highbd_upsampled_pred_sse2(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 #define aom_highbd_upsampled_pred aom_highbd_upsampled_pred_sse2
 
 void aom_highbd_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_16x16_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_16x16 aom_highbd_v_predictor_16x16_sse2
 
+void aom_highbd_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x32 aom_highbd_v_predictor_16x32_c
+
+void aom_highbd_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x8 aom_highbd_v_predictor_16x8_c
+
 void aom_highbd_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_2x2 aom_highbd_v_predictor_2x2_c
 
+void aom_highbd_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_32x16 aom_highbd_v_predictor_32x16_c
+
 void aom_highbd_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_32x32_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_32x32 aom_highbd_v_predictor_32x32_sse2
 
 void aom_highbd_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_4x4_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_4x4 aom_highbd_v_predictor_4x4_sse2
 
+void aom_highbd_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_4x8 aom_highbd_v_predictor_4x8_c
+
+void aom_highbd_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x16 aom_highbd_v_predictor_8x16_c
+
+void aom_highbd_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x4 aom_highbd_v_predictor_8x4_c
+
 void aom_highbd_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_8x8_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_8x8 aom_highbd_v_predictor_8x8_sse2
 
 void aom_idct16x16_10_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
 void aom_idct16x16_10_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
 void aom_idct16x16_10_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
 RTCD_EXTERN void (*aom_idct16x16_10_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
@@ -2176,120 +2446,16 @@ void aom_lpf_vertical_4_dual_sse2(uint8_
 void aom_lpf_vertical_8_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 void aom_lpf_vertical_8_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 #define aom_lpf_vertical_8 aom_lpf_vertical_8_sse2
 
 void aom_lpf_vertical_8_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 void aom_lpf_vertical_8_dual_sse2(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 #define aom_lpf_vertical_8_dual aom_lpf_vertical_8_dual_sse2
 
-unsigned int aom_masked_sad16x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad16x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad16x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x64_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x64)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad4x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad4x4_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad4x4)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad4x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad4x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad4x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad64x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad64x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad64x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad64x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad64x64_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad64x64)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x4_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x4)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 void aom_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 void aom_minmax_8x8_sse2(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 #define aom_minmax_8x8 aom_minmax_8x8_sse2
 
 unsigned int aom_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_mse16x16_avx2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -2447,25 +2613,43 @@ RTCD_EXTERN unsigned int (*aom_obmc_vari
 
 unsigned int aom_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 unsigned int aom_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 
 void aom_paeth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_16x16 aom_paeth_predictor_16x16_c
 
+void aom_paeth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x32 aom_paeth_predictor_16x32_c
+
+void aom_paeth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x8 aom_paeth_predictor_16x8_c
+
 void aom_paeth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_2x2 aom_paeth_predictor_2x2_c
 
+void aom_paeth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_32x16 aom_paeth_predictor_32x16_c
+
 void aom_paeth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_32x32 aom_paeth_predictor_32x32_c
 
 void aom_paeth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_4x4 aom_paeth_predictor_4x4_c
 
+void aom_paeth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_4x8 aom_paeth_predictor_4x8_c
+
+void aom_paeth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x16 aom_paeth_predictor_8x16_c
+
+void aom_paeth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x4 aom_paeth_predictor_8x4_c
+
 void aom_paeth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_8x8 aom_paeth_predictor_8x8_c
 
 void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_quantize_b_ssse3(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_quantize_b_avx(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 RTCD_EXTERN void (*aom_quantize_b)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
@@ -2726,31 +2910,115 @@ void aom_scaled_avg_vert_c(const uint8_t
 #define aom_scaled_avg_vert aom_scaled_avg_vert_c
 
 void aom_scaled_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_horiz aom_scaled_horiz_c
 
 void aom_scaled_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_vert aom_scaled_vert_c
 
+void aom_smooth_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x16 aom_smooth_h_predictor_16x16_c
+
+void aom_smooth_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x32 aom_smooth_h_predictor_16x32_c
+
+void aom_smooth_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x8 aom_smooth_h_predictor_16x8_c
+
+void aom_smooth_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_2x2 aom_smooth_h_predictor_2x2_c
+
+void aom_smooth_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x16 aom_smooth_h_predictor_32x16_c
+
+void aom_smooth_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x32 aom_smooth_h_predictor_32x32_c
+
+void aom_smooth_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x4 aom_smooth_h_predictor_4x4_c
+
+void aom_smooth_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x8 aom_smooth_h_predictor_4x8_c
+
+void aom_smooth_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x16 aom_smooth_h_predictor_8x16_c
+
+void aom_smooth_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x4 aom_smooth_h_predictor_8x4_c
+
+void aom_smooth_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x8 aom_smooth_h_predictor_8x8_c
+
 void aom_smooth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_16x16 aom_smooth_predictor_16x16_c
 
+void aom_smooth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x32 aom_smooth_predictor_16x32_c
+
+void aom_smooth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x8 aom_smooth_predictor_16x8_c
+
 void aom_smooth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_2x2 aom_smooth_predictor_2x2_c
 
+void aom_smooth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_32x16 aom_smooth_predictor_32x16_c
+
 void aom_smooth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_32x32 aom_smooth_predictor_32x32_c
 
 void aom_smooth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_4x4 aom_smooth_predictor_4x4_c
 
+void aom_smooth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_4x8 aom_smooth_predictor_4x8_c
+
+void aom_smooth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x16 aom_smooth_predictor_8x16_c
+
+void aom_smooth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x4 aom_smooth_predictor_8x4_c
+
 void aom_smooth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_8x8 aom_smooth_predictor_8x8_c
 
+void aom_smooth_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x16 aom_smooth_v_predictor_16x16_c
+
+void aom_smooth_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x32 aom_smooth_v_predictor_16x32_c
+
+void aom_smooth_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x8 aom_smooth_v_predictor_16x8_c
+
+void aom_smooth_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_2x2 aom_smooth_v_predictor_2x2_c
+
+void aom_smooth_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x16 aom_smooth_v_predictor_32x16_c
+
+void aom_smooth_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x32 aom_smooth_v_predictor_32x32_c
+
+void aom_smooth_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x4 aom_smooth_v_predictor_4x4_c
+
+void aom_smooth_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x8 aom_smooth_v_predictor_4x8_c
+
+void aom_smooth_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x16 aom_smooth_v_predictor_8x16_c
+
+void aom_smooth_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x4 aom_smooth_v_predictor_8x4_c
+
+void aom_smooth_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x8 aom_smooth_v_predictor_8x8_c
+
 uint32_t aom_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x16_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 
 uint32_t aom_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x32_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
@@ -2887,35 +3155,53 @@ void aom_subtract_block_sse2(int rows, i
 uint64_t aom_sum_squares_2d_i16_c(const int16_t *src, int stride, int width, int height);
 uint64_t aom_sum_squares_2d_i16_sse2(const int16_t *src, int stride, int width, int height);
 #define aom_sum_squares_2d_i16 aom_sum_squares_2d_i16_sse2
 
 uint64_t aom_sum_squares_i16_c(const int16_t *src, uint32_t N);
 uint64_t aom_sum_squares_i16_sse2(const int16_t *src, uint32_t N);
 #define aom_sum_squares_i16 aom_sum_squares_i16_sse2
 
-void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
-void aom_upsampled_pred_sse2(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_sse2(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 #define aom_upsampled_pred aom_upsampled_pred_sse2
 
 void aom_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_16x16 aom_v_predictor_16x16_sse2
 
+void aom_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x32 aom_v_predictor_16x32_c
+
+void aom_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x8 aom_v_predictor_16x8_c
+
 void aom_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_2x2 aom_v_predictor_2x2_c
 
+void aom_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_32x16 aom_v_predictor_32x16_c
+
 void aom_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_32x32 aom_v_predictor_32x32_sse2
 
 void aom_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_4x4 aom_v_predictor_4x4_sse2
 
+void aom_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_4x8 aom_v_predictor_4x8_c
+
+void aom_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x16 aom_v_predictor_8x16_c
+
+void aom_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x4 aom_v_predictor_8x4_c
+
 void aom_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_8x8 aom_v_predictor_8x8_sse2
 
 unsigned int aom_variance16x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 unsigned int aom_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 unsigned int aom_variance16x16_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_variance16x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
@@ -3033,56 +3319,26 @@ static void setup_rtcd_internal(void)
     aom_d153_predictor_32x32 = aom_d153_predictor_32x32_c;
     if (flags & HAS_SSSE3) aom_d153_predictor_32x32 = aom_d153_predictor_32x32_ssse3;
     aom_d153_predictor_4x4 = aom_d153_predictor_4x4_c;
     if (flags & HAS_SSSE3) aom_d153_predictor_4x4 = aom_d153_predictor_4x4_ssse3;
     aom_d153_predictor_8x8 = aom_d153_predictor_8x8_c;
     if (flags & HAS_SSSE3) aom_d153_predictor_8x8 = aom_d153_predictor_8x8_ssse3;
     aom_d63e_predictor_4x4 = aom_d63e_predictor_4x4_c;
     if (flags & HAS_SSSE3) aom_d63e_predictor_4x4 = aom_d63e_predictor_4x4_ssse3;
-    aom_fdct16x16_1 = aom_fdct16x16_1_sse2;
-    if (flags & HAS_AVX2) aom_fdct16x16_1 = aom_fdct16x16_1_avx2;
     aom_fdct32x32 = aom_fdct32x32_sse2;
     if (flags & HAS_AVX2) aom_fdct32x32 = aom_fdct32x32_avx2;
-    aom_fdct32x32_1 = aom_fdct32x32_1_sse2;
-    if (flags & HAS_AVX2) aom_fdct32x32_1 = aom_fdct32x32_1_avx2;
     aom_fdct32x32_rd = aom_fdct32x32_rd_sse2;
     if (flags & HAS_AVX2) aom_fdct32x32_rd = aom_fdct32x32_rd_avx2;
     aom_fdct8x8 = aom_fdct8x8_sse2;
     if (flags & HAS_SSSE3) aom_fdct8x8 = aom_fdct8x8_ssse3;
     aom_get16x16var = aom_get16x16var_sse2;
     if (flags & HAS_AVX2) aom_get16x16var = aom_get16x16var_avx2;
     aom_hadamard_8x8 = aom_hadamard_8x8_sse2;
     if (flags & HAS_SSSE3) aom_hadamard_8x8 = aom_hadamard_8x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x16 = aom_highbd_10_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x16 = aom_highbd_10_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x32 = aom_highbd_10_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x32 = aom_highbd_10_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x8 = aom_highbd_10_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x8 = aom_highbd_10_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x16 = aom_highbd_10_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x16 = aom_highbd_10_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x32 = aom_highbd_10_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x32 = aom_highbd_10_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x64 = aom_highbd_10_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x64 = aom_highbd_10_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance4x4 = aom_highbd_10_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance4x4 = aom_highbd_10_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance4x8 = aom_highbd_10_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance4x8 = aom_highbd_10_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance64x32 = aom_highbd_10_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance64x32 = aom_highbd_10_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance64x64 = aom_highbd_10_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance64x64 = aom_highbd_10_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x16 = aom_highbd_10_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x16 = aom_highbd_10_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x4 = aom_highbd_10_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x4 = aom_highbd_10_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x8 = aom_highbd_10_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x8 = aom_highbd_10_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_10_obmc_variance16x16 = aom_highbd_10_obmc_variance16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x16 = aom_highbd_10_obmc_variance16x16_sse4_1;
     aom_highbd_10_obmc_variance16x32 = aom_highbd_10_obmc_variance16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x32 = aom_highbd_10_obmc_variance16x32_sse4_1;
     aom_highbd_10_obmc_variance16x8 = aom_highbd_10_obmc_variance16x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x8 = aom_highbd_10_obmc_variance16x8_sse4_1;
     aom_highbd_10_obmc_variance32x16 = aom_highbd_10_obmc_variance32x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance32x16 = aom_highbd_10_obmc_variance32x16_sse4_1;
@@ -3105,42 +3361,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_10_obmc_variance8x8 = aom_highbd_10_obmc_variance8x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance8x8 = aom_highbd_10_obmc_variance8x8_sse4_1;
     aom_highbd_10_sub_pixel_avg_variance4x4 = aom_highbd_10_sub_pixel_avg_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_sub_pixel_avg_variance4x4 = aom_highbd_10_sub_pixel_avg_variance4x4_sse4_1;
     aom_highbd_10_sub_pixel_variance4x4 = aom_highbd_10_sub_pixel_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_sub_pixel_variance4x4 = aom_highbd_10_sub_pixel_variance4x4_sse4_1;
     aom_highbd_10_variance4x4 = aom_highbd_10_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_variance4x4 = aom_highbd_10_variance4x4_sse4_1;
-    aom_highbd_12_masked_sub_pixel_variance16x16 = aom_highbd_12_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x16 = aom_highbd_12_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance16x32 = aom_highbd_12_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x32 = aom_highbd_12_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance16x8 = aom_highbd_12_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x8 = aom_highbd_12_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x16 = aom_highbd_12_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x16 = aom_highbd_12_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x32 = aom_highbd_12_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x32 = aom_highbd_12_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x64 = aom_highbd_12_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x64 = aom_highbd_12_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance4x4 = aom_highbd_12_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance4x4 = aom_highbd_12_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance4x8 = aom_highbd_12_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance4x8 = aom_highbd_12_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance64x32 = aom_highbd_12_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance64x32 = aom_highbd_12_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance64x64 = aom_highbd_12_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance64x64 = aom_highbd_12_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x16 = aom_highbd_12_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x16 = aom_highbd_12_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x4 = aom_highbd_12_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x4 = aom_highbd_12_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x8 = aom_highbd_12_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x8 = aom_highbd_12_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_12_obmc_variance16x16 = aom_highbd_12_obmc_variance16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x16 = aom_highbd_12_obmc_variance16x16_sse4_1;
     aom_highbd_12_obmc_variance16x32 = aom_highbd_12_obmc_variance16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x32 = aom_highbd_12_obmc_variance16x32_sse4_1;
     aom_highbd_12_obmc_variance16x8 = aom_highbd_12_obmc_variance16x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x8 = aom_highbd_12_obmc_variance16x8_sse4_1;
     aom_highbd_12_obmc_variance32x16 = aom_highbd_12_obmc_variance32x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance32x16 = aom_highbd_12_obmc_variance32x16_sse4_1;
@@ -3163,42 +3393,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_12_obmc_variance8x8 = aom_highbd_12_obmc_variance8x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance8x8 = aom_highbd_12_obmc_variance8x8_sse4_1;
     aom_highbd_12_sub_pixel_avg_variance4x4 = aom_highbd_12_sub_pixel_avg_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_sub_pixel_avg_variance4x4 = aom_highbd_12_sub_pixel_avg_variance4x4_sse4_1;
     aom_highbd_12_sub_pixel_variance4x4 = aom_highbd_12_sub_pixel_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_sub_pixel_variance4x4 = aom_highbd_12_sub_pixel_variance4x4_sse4_1;
     aom_highbd_12_variance4x4 = aom_highbd_12_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_variance4x4 = aom_highbd_12_variance4x4_sse4_1;
-    aom_highbd_8_masked_sub_pixel_variance16x16 = aom_highbd_8_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x16 = aom_highbd_8_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance16x32 = aom_highbd_8_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x32 = aom_highbd_8_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance16x8 = aom_highbd_8_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x8 = aom_highbd_8_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x16 = aom_highbd_8_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x16 = aom_highbd_8_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x32 = aom_highbd_8_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x32 = aom_highbd_8_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x64 = aom_highbd_8_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x64 = aom_highbd_8_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance4x4 = aom_highbd_8_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance4x4 = aom_highbd_8_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance4x8 = aom_highbd_8_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance4x8 = aom_highbd_8_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance64x32 = aom_highbd_8_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance64x32 = aom_highbd_8_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance64x64 = aom_highbd_8_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance64x64 = aom_highbd_8_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x16 = aom_highbd_8_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x16 = aom_highbd_8_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x4 = aom_highbd_8_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x4 = aom_highbd_8_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x8 = aom_highbd_8_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x8 = aom_highbd_8_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_8_sub_pixel_avg_variance4x4 = aom_highbd_8_sub_pixel_avg_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_8_sub_pixel_avg_variance4x4 = aom_highbd_8_sub_pixel_avg_variance4x4_sse4_1;
     aom_highbd_8_sub_pixel_variance4x4 = aom_highbd_8_sub_pixel_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_8_sub_pixel_variance4x4 = aom_highbd_8_sub_pixel_variance4x4_sse4_1;
     aom_highbd_8_variance4x4 = aom_highbd_8_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_8_variance4x4 = aom_highbd_8_variance4x4_sse4_1;
     aom_highbd_blend_a64_hmask = aom_highbd_blend_a64_hmask_c;
     if (flags & HAS_SSE4_1) aom_highbd_blend_a64_hmask = aom_highbd_blend_a64_hmask_sse4_1;
@@ -3217,42 +3421,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_convolve8_horiz = aom_highbd_convolve8_horiz_sse2;
     if (flags & HAS_AVX2) aom_highbd_convolve8_horiz = aom_highbd_convolve8_horiz_avx2;
     aom_highbd_convolve8_vert = aom_highbd_convolve8_vert_sse2;
     if (flags & HAS_AVX2) aom_highbd_convolve8_vert = aom_highbd_convolve8_vert_avx2;
     aom_highbd_convolve_avg = aom_highbd_convolve_avg_sse2;
     if (flags & HAS_AVX2) aom_highbd_convolve_avg = aom_highbd_convolve_avg_avx2;
     aom_highbd_convolve_copy = aom_highbd_convolve_copy_sse2;
     if (flags & HAS_AVX2) aom_highbd_convolve_copy = aom_highbd_convolve_copy_avx2;
-    aom_highbd_masked_sad16x16 = aom_highbd_masked_sad16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x16 = aom_highbd_masked_sad16x16_ssse3;
-    aom_highbd_masked_sad16x32 = aom_highbd_masked_sad16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x32 = aom_highbd_masked_sad16x32_ssse3;
-    aom_highbd_masked_sad16x8 = aom_highbd_masked_sad16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x8 = aom_highbd_masked_sad16x8_ssse3;
-    aom_highbd_masked_sad32x16 = aom_highbd_masked_sad32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x16 = aom_highbd_masked_sad32x16_ssse3;
-    aom_highbd_masked_sad32x32 = aom_highbd_masked_sad32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x32 = aom_highbd_masked_sad32x32_ssse3;
-    aom_highbd_masked_sad32x64 = aom_highbd_masked_sad32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x64 = aom_highbd_masked_sad32x64_ssse3;
-    aom_highbd_masked_sad4x4 = aom_highbd_masked_sad4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad4x4 = aom_highbd_masked_sad4x4_ssse3;
-    aom_highbd_masked_sad4x8 = aom_highbd_masked_sad4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad4x8 = aom_highbd_masked_sad4x8_ssse3;
-    aom_highbd_masked_sad64x32 = aom_highbd_masked_sad64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad64x32 = aom_highbd_masked_sad64x32_ssse3;
-    aom_highbd_masked_sad64x64 = aom_highbd_masked_sad64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad64x64 = aom_highbd_masked_sad64x64_ssse3;
-    aom_highbd_masked_sad8x16 = aom_highbd_masked_sad8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x16 = aom_highbd_masked_sad8x16_ssse3;
-    aom_highbd_masked_sad8x4 = aom_highbd_masked_sad8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x4 = aom_highbd_masked_sad8x4_ssse3;
-    aom_highbd_masked_sad8x8 = aom_highbd_masked_sad8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x8 = aom_highbd_masked_sad8x8_ssse3;
     aom_highbd_obmc_sad16x16 = aom_highbd_obmc_sad16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x16 = aom_highbd_obmc_sad16x16_sse4_1;
     aom_highbd_obmc_sad16x32 = aom_highbd_obmc_sad16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x32 = aom_highbd_obmc_sad16x32_sse4_1;
     aom_highbd_obmc_sad16x8 = aom_highbd_obmc_sad16x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x8 = aom_highbd_obmc_sad16x8_sse4_1;
     aom_highbd_obmc_sad32x16 = aom_highbd_obmc_sad32x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad32x16 = aom_highbd_obmc_sad32x16_sse4_1;
@@ -3295,16 +3473,18 @@ static void setup_rtcd_internal(void)
     aom_highbd_obmc_variance64x64 = aom_highbd_obmc_variance64x64_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance64x64 = aom_highbd_obmc_variance64x64_sse4_1;
     aom_highbd_obmc_variance8x16 = aom_highbd_obmc_variance8x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x16 = aom_highbd_obmc_variance8x16_sse4_1;
     aom_highbd_obmc_variance8x4 = aom_highbd_obmc_variance8x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x4 = aom_highbd_obmc_variance8x4_sse4_1;
     aom_highbd_obmc_variance8x8 = aom_highbd_obmc_variance8x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x8 = aom_highbd_obmc_variance8x8_sse4_1;
+    aom_highbd_quantize_b = aom_highbd_quantize_b_sse2;
+    if (flags & HAS_AVX2) aom_highbd_quantize_b = aom_highbd_quantize_b_avx2;
     aom_highbd_sad16x16 = aom_highbd_sad16x16_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16 = aom_highbd_sad16x16_avx2;
     aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_avx2;
     aom_highbd_sad16x16x4d = aom_highbd_sad16x16x4d_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16x4d = aom_highbd_sad16x16x4d_avx2;
     aom_highbd_sad16x32 = aom_highbd_sad16x32_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x32 = aom_highbd_sad16x32_avx2;
@@ -3370,68 +3550,16 @@ static void setup_rtcd_internal(void)
     aom_idct8x8_12_add = aom_idct8x8_12_add_sse2;
     if (flags & HAS_SSSE3) aom_idct8x8_12_add = aom_idct8x8_12_add_ssse3;
     aom_idct8x8_64_add = aom_idct8x8_64_add_sse2;
     if (flags & HAS_SSSE3) aom_idct8x8_64_add = aom_idct8x8_64_add_ssse3;
     aom_lpf_horizontal_edge_16 = aom_lpf_horizontal_edge_16_sse2;
     if (flags & HAS_AVX2) aom_lpf_horizontal_edge_16 = aom_lpf_horizontal_edge_16_avx2;
     aom_lpf_horizontal_edge_8 = aom_lpf_horizontal_edge_8_sse2;
     if (flags & HAS_AVX2) aom_lpf_horizontal_edge_8 = aom_lpf_horizontal_edge_8_avx2;
-    aom_masked_sad16x16 = aom_masked_sad16x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x16 = aom_masked_sad16x16_ssse3;
-    aom_masked_sad16x32 = aom_masked_sad16x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x32 = aom_masked_sad16x32_ssse3;
-    aom_masked_sad16x8 = aom_masked_sad16x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x8 = aom_masked_sad16x8_ssse3;
-    aom_masked_sad32x16 = aom_masked_sad32x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x16 = aom_masked_sad32x16_ssse3;
-    aom_masked_sad32x32 = aom_masked_sad32x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x32 = aom_masked_sad32x32_ssse3;
-    aom_masked_sad32x64 = aom_masked_sad32x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x64 = aom_masked_sad32x64_ssse3;
-    aom_masked_sad4x4 = aom_masked_sad4x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sad4x4 = aom_masked_sad4x4_ssse3;
-    aom_masked_sad4x8 = aom_masked_sad4x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad4x8 = aom_masked_sad4x8_ssse3;
-    aom_masked_sad64x32 = aom_masked_sad64x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad64x32 = aom_masked_sad64x32_ssse3;
-    aom_masked_sad64x64 = aom_masked_sad64x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sad64x64 = aom_masked_sad64x64_ssse3;
-    aom_masked_sad8x16 = aom_masked_sad8x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x16 = aom_masked_sad8x16_ssse3;
-    aom_masked_sad8x4 = aom_masked_sad8x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x4 = aom_masked_sad8x4_ssse3;
-    aom_masked_sad8x8 = aom_masked_sad8x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x8 = aom_masked_sad8x8_ssse3;
-    aom_masked_sub_pixel_variance16x16 = aom_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x16 = aom_masked_sub_pixel_variance16x16_ssse3;
-    aom_masked_sub_pixel_variance16x32 = aom_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x32 = aom_masked_sub_pixel_variance16x32_ssse3;
-    aom_masked_sub_pixel_variance16x8 = aom_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x8 = aom_masked_sub_pixel_variance16x8_ssse3;
-    aom_masked_sub_pixel_variance32x16 = aom_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x16 = aom_masked_sub_pixel_variance32x16_ssse3;
-    aom_masked_sub_pixel_variance32x32 = aom_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x32 = aom_masked_sub_pixel_variance32x32_ssse3;
-    aom_masked_sub_pixel_variance32x64 = aom_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x64 = aom_masked_sub_pixel_variance32x64_ssse3;
-    aom_masked_sub_pixel_variance4x4 = aom_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance4x4 = aom_masked_sub_pixel_variance4x4_ssse3;
-    aom_masked_sub_pixel_variance4x8 = aom_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance4x8 = aom_masked_sub_pixel_variance4x8_ssse3;
-    aom_masked_sub_pixel_variance64x32 = aom_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance64x32 = aom_masked_sub_pixel_variance64x32_ssse3;
-    aom_masked_sub_pixel_variance64x64 = aom_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance64x64 = aom_masked_sub_pixel_variance64x64_ssse3;
-    aom_masked_sub_pixel_variance8x16 = aom_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x16 = aom_masked_sub_pixel_variance8x16_ssse3;
-    aom_masked_sub_pixel_variance8x4 = aom_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x4 = aom_masked_sub_pixel_variance8x4_ssse3;
-    aom_masked_sub_pixel_variance8x8 = aom_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x8 = aom_masked_sub_pixel_variance8x8_ssse3;
     aom_mse16x16 = aom_mse16x16_sse2;
     if (flags & HAS_AVX2) aom_mse16x16 = aom_mse16x16_avx2;
     aom_obmc_sad16x16 = aom_obmc_sad16x16_c;
     if (flags & HAS_SSE4_1) aom_obmc_sad16x16 = aom_obmc_sad16x16_sse4_1;
     aom_obmc_sad16x32 = aom_obmc_sad16x32_c;
     if (flags & HAS_SSE4_1) aom_obmc_sad16x32 = aom_obmc_sad16x32_sse4_1;
     aom_obmc_sad16x8 = aom_obmc_sad16x8_c;
     if (flags & HAS_SSE4_1) aom_obmc_sad16x8 = aom_obmc_sad16x8_sse4_1;
--- a/media/libaom/config/linux/x64/av1_rtcd.h
+++ b/media/libaom/config/linux/x64/av1_rtcd.h
@@ -13,22 +13,25 @@
 
 #include "aom/aom_integer.h"
 #include "av1/common/common.h"
 #include "av1/common/enums.h"
 #include "av1/common/quant_common.h"
 #include "av1/common/filter.h"
 #include "av1/common/convolve.h"
 #include "av1/common/av1_txfm.h"
+#include "av1/common/idct.h"
 #include "av1/common/odintrin.h"
 
 struct macroblockd;
 
 /* Encoder forward decls */
 struct macroblock;
+struct fwd_txfm_param;
+struct inv_txfm_param;
 struct aom_variance_vtable;
 struct search_site_config;
 struct mv;
 union int_mv;
 struct yv12_buffer_config;
 typedef uint16_t od_dering_in;
 
 #ifdef __cplusplus
@@ -55,84 +58,85 @@ RTCD_EXTERN void (*aom_clpf_hblock)(uint
 
 void aom_clpf_hblock_hbd_c(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_sse2(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_ssse3(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_sse4_1(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 RTCD_EXTERN void (*aom_clpf_hblock_hbd)(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 
 int64_t av1_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
-#define av1_block_error av1_block_error_c
+int64_t av1_block_error_avx2(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
+RTCD_EXTERN int64_t (*av1_block_error)(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
 
 void av1_convolve_horiz_c(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 void av1_convolve_horiz_ssse3(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 RTCD_EXTERN void (*av1_convolve_horiz)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 
 void av1_convolve_vert_c(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 void av1_convolve_vert_ssse3(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 RTCD_EXTERN void (*av1_convolve_vert)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 
 int av1_diamond_search_sad_c(struct macroblock *x, const struct search_site_config *cfg,  struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_diamond_search_sad av1_diamond_search_sad_c
 
 void av1_fdct8x8_quant_c(const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define av1_fdct8x8_quant av1_fdct8x8_quant_c
 
-void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x16_avx2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht16x16)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x16_avx2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht16x16)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x32_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x32_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x32 av1_fht16x32_sse2
 
-void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x4 av1_fht16x4_c
 
-void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x8 av1_fht16x8_sse2
 
-void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x16 av1_fht32x16_sse2
 
-void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x32_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x32_avx2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht32x32)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x32_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x32_avx2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht32x32)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x8 av1_fht32x8_c
 
-void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x16 av1_fht4x16_c
 
-void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x4 av1_fht4x4_sse2
 
-void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht4x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht4x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x8 av1_fht4x8_sse2
 
-void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x16 av1_fht8x16_sse2
 
-void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x32 av1_fht8x32_c
 
-void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x4_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x4_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x4 av1_fht8x4_sse2
 
-void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x8 av1_fht8x8_sse2
 
 int av1_full_range_search_c(const struct macroblock *x, const struct search_site_config *cfg, struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_full_range_search av1_full_range_search_c
 
 int av1_full_search_sad_c(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 int av1_full_search_sadx3(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 int av1_full_search_sadx8(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
@@ -140,28 +144,46 @@ RTCD_EXTERN int (*av1_full_search_sad)(c
 
 void av1_fwd_idtx_c(const int16_t *src_diff, tran_low_t *coeff, int stride, int bs, int tx_type);
 #define av1_fwd_idtx av1_fwd_idtx_c
 
 void av1_fwd_txfm2d_16x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_16x16_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_16x16)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_16x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x32 av1_fwd_txfm2d_16x32_c
+
+void av1_fwd_txfm2d_16x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x8 av1_fwd_txfm2d_16x8_c
+
+void av1_fwd_txfm2d_32x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_32x16 av1_fwd_txfm2d_32x16_c
+
 void av1_fwd_txfm2d_32x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_32x32_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_32x32)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
 void av1_fwd_txfm2d_4x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_4x4_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_4x4)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_4x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_4x8 av1_fwd_txfm2d_4x8_c
+
 void av1_fwd_txfm2d_64x64_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_64x64_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_64x64)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_8x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x16 av1_fwd_txfm2d_8x16_c
+
+void av1_fwd_txfm2d_8x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x4 av1_fwd_txfm2d_8x4_c
+
 void av1_fwd_txfm2d_8x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_8x8_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_8x8)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
 void av1_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_fwht4x4 av1_fwht4x4_c
 
 int64_t av1_highbd_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd);
@@ -205,225 +227,178 @@ RTCD_EXTERN void (*av1_highbd_convolve_h
 void av1_highbd_convolve_init_c(void);
 void av1_highbd_convolve_init_sse4_1(void);
 RTCD_EXTERN void (*av1_highbd_convolve_init)(void);
 
 void av1_highbd_convolve_vert_c(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 void av1_highbd_convolve_vert_sse4_1(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 RTCD_EXTERN void (*av1_highbd_convolve_vert)(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 
-void av1_highbd_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x16 av1_highbd_fht16x16_c
-
-void av1_highbd_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x32 av1_highbd_fht16x32_c
-
-void av1_highbd_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x4 av1_highbd_fht16x4_c
-
-void av1_highbd_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x8 av1_highbd_fht16x8_c
-
-void av1_highbd_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x16 av1_highbd_fht32x16_c
-
-void av1_highbd_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x32 av1_highbd_fht32x32_c
-
-void av1_highbd_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x8 av1_highbd_fht32x8_c
-
-void av1_highbd_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x16 av1_highbd_fht4x16_c
-
-void av1_highbd_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_highbd_fht4x4_sse4_1(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_highbd_fht4x4)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-
-void av1_highbd_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x8 av1_highbd_fht4x8_c
-
-void av1_highbd_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x16 av1_highbd_fht8x16_c
-
-void av1_highbd_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x32 av1_highbd_fht8x32_c
-
-void av1_highbd_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x4 av1_highbd_fht8x4_c
-
-void av1_highbd_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x8 av1_highbd_fht8x8_c
-
 void av1_highbd_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_highbd_fwht4x4 av1_highbd_fwht4x4_c
 
-void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type, int bd);
+void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x16_256_add av1_highbd_iht16x16_256_add_c
 
-void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x32_512_add av1_highbd_iht16x32_512_add_c
 
-void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x4_64_add av1_highbd_iht16x4_64_add_c
 
-void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x8_128_add av1_highbd_iht16x8_128_add_c
 
-void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x16_512_add av1_highbd_iht32x16_512_add_c
 
-void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x8_256_add av1_highbd_iht32x8_256_add_c
 
-void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x16_64_add av1_highbd_iht4x16_64_add_c
 
-void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x4_16_add av1_highbd_iht4x4_16_add_c
 
-void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x8_32_add av1_highbd_iht4x8_32_add_c
 
-void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x16_128_add av1_highbd_iht8x16_128_add_c
 
-void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x32_256_add av1_highbd_iht8x32_256_add_c
 
-void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x4_32_add av1_highbd_iht8x4_32_add_c
 
-void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x8_64_add av1_highbd_iht8x8_64_add_c
 
 void av1_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_highbd_quantize_b av1_highbd_quantize_b_c
 
 void av1_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 void av1_highbd_quantize_fp_sse4_1(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
+void av1_highbd_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 RTCD_EXTERN void (*av1_highbd_quantize_fp)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 
 void av1_highbd_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 #define av1_highbd_temporal_filter_apply av1_highbd_temporal_filter_apply_c
 
-void av1_highbd_warp_affine_c(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_highbd_warp_affine_ssse3(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-RTCD_EXTERN void (*av1_highbd_warp_affine)(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
+void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+void av1_iht16x16_256_add_sse2(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+void av1_iht16x16_256_add_avx2(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht16x16_256_add)(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 
-void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-void av1_iht16x16_256_add_sse2(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-void av1_iht16x16_256_add_avx2(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-RTCD_EXTERN void (*av1_iht16x16_256_add)(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-
-void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht16x32_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht16x32_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x32_512_add av1_iht16x32_512_add_sse2
 
-void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x4_64_add av1_iht16x4_64_add_c
 
-void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht16x8_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht16x8_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x8_128_add av1_iht16x8_128_add_sse2
 
-void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht32x16_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht32x16_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht32x16_512_add av1_iht32x16_512_add_sse2
 
-void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
+void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_iht32x32_1024_add av1_iht32x32_1024_add_c
 
-void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht32x8_256_add av1_iht32x8_256_add_c
 
-void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x16_64_add av1_iht4x16_64_add_c
 
-void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x4_16_add av1_iht4x4_16_add_sse2
 
-void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht4x8_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht4x8_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x8_32_add av1_iht4x8_32_add_sse2
 
-void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x16_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x16_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x16_128_add av1_iht8x16_128_add_sse2
 
-void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x32_256_add av1_iht8x32_256_add_c
 
-void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x4_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x4_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x4_32_add av1_iht8x4_32_add_sse2
 
-void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x8_64_add av1_iht8x8_64_add_sse2
 
 void av1_inv_txfm2d_add_16x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_16x16_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_16x16)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
+void av1_inv_txfm2d_add_16x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x32 av1_inv_txfm2d_add_16x32_c
+
+void av1_inv_txfm2d_add_16x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x8 av1_inv_txfm2d_add_16x8_c
+
+void av1_inv_txfm2d_add_32x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_32x16 av1_inv_txfm2d_add_32x16_c
+
 void av1_inv_txfm2d_add_32x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_32x32_avx2(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_32x32)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
 void av1_inv_txfm2d_add_4x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_4x4_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_4x4)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
+void av1_inv_txfm2d_add_4x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_4x8 av1_inv_txfm2d_add_4x8_c
+
 void av1_inv_txfm2d_add_64x64_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_64x64 av1_inv_txfm2d_add_64x64_c
 
+void av1_inv_txfm2d_add_8x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x16 av1_inv_txfm2d_add_8x16_c
+
+void av1_inv_txfm2d_add_8x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x4 av1_inv_txfm2d_add_8x4_c
+
 void av1_inv_txfm2d_add_8x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_8x8_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_8x8)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
 void av1_lowbd_convolve_init_c(void);
 void av1_lowbd_convolve_init_ssse3(void);
 RTCD_EXTERN void (*av1_lowbd_convolve_init)(void);
 
 void av1_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_quantize_b av1_quantize_b_c
 
 void av1_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void av1_quantize_fp_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
-#define av1_quantize_fp av1_quantize_fp_sse2
+void av1_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*av1_quantize_fp)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void av1_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
-#define av1_quantize_fp_32x32 av1_quantize_fp_32x32_c
+void av1_quantize_fp_32x32_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*av1_quantize_fp_32x32)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void av1_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 void av1_temporal_filter_apply_sse2(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 #define av1_temporal_filter_apply av1_temporal_filter_apply_sse2
 
-void av1_warp_affine_c(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_warp_affine_sse2(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_warp_affine_ssse3(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-RTCD_EXTERN void (*av1_warp_affine)(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-
-void av1_wedge_compute_delta_squares_c(int16_t *d, const int16_t *a, const int16_t *b, int N);
-void av1_wedge_compute_delta_squares_sse2(int16_t *d, const int16_t *a, const int16_t *b, int N);
-#define av1_wedge_compute_delta_squares av1_wedge_compute_delta_squares_sse2
-
-int av1_wedge_sign_from_residuals_c(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-int av1_wedge_sign_from_residuals_sse2(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-#define av1_wedge_sign_from_residuals av1_wedge_sign_from_residuals_sse2
-
-uint64_t av1_wedge_sse_from_residuals_c(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-uint64_t av1_wedge_sse_from_residuals_sse2(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-#define av1_wedge_sse_from_residuals av1_wedge_sse_from_residuals_sse2
-
-double compute_cross_correlation_c(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-double compute_cross_correlation_sse4_1(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-RTCD_EXTERN double (*compute_cross_correlation)(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-
 void copy_4x4_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_sse2(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_ssse3(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_sse4_1(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 RTCD_EXTERN void (*copy_4x4_16bit_to_16bit)(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 
 void copy_4x4_16bit_to_8bit_c(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_8bit_sse2(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
@@ -490,16 +465,18 @@ static void setup_rtcd_internal(void)
     if (flags & HAS_SSSE3) aom_clpf_block_hbd = aom_clpf_block_hbd_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_block_hbd = aom_clpf_block_hbd_sse4_1;
     aom_clpf_hblock = aom_clpf_hblock_sse2;
     if (flags & HAS_SSSE3) aom_clpf_hblock = aom_clpf_hblock_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_hblock = aom_clpf_hblock_sse4_1;
     aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_sse2;
     if (flags & HAS_SSSE3) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_sse4_1;
+    av1_block_error = av1_block_error_c;
+    if (flags & HAS_AVX2) av1_block_error = av1_block_error_avx2;
     av1_convolve_horiz = av1_convolve_horiz_c;
     if (flags & HAS_SSSE3) av1_convolve_horiz = av1_convolve_horiz_ssse3;
     av1_convolve_vert = av1_convolve_vert_c;
     if (flags & HAS_SSSE3) av1_convolve_vert = av1_convolve_vert_ssse3;
     av1_fht16x16 = av1_fht16x16_sse2;
     if (flags & HAS_AVX2) av1_fht16x16 = av1_fht16x16_avx2;
     av1_fht32x32 = av1_fht32x32_sse2;
     if (flags & HAS_AVX2) av1_fht32x32 = av1_fht32x32_avx2;
@@ -517,38 +494,35 @@ static void setup_rtcd_internal(void)
     av1_fwd_txfm2d_8x8 = av1_fwd_txfm2d_8x8_c;
     if (flags & HAS_SSE4_1) av1_fwd_txfm2d_8x8 = av1_fwd_txfm2d_8x8_sse4_1;
     av1_highbd_convolve_horiz = av1_highbd_convolve_horiz_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_horiz = av1_highbd_convolve_horiz_sse4_1;
     av1_highbd_convolve_init = av1_highbd_convolve_init_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_init = av1_highbd_convolve_init_sse4_1;
     av1_highbd_convolve_vert = av1_highbd_convolve_vert_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_vert = av1_highbd_convolve_vert_sse4_1;
-    av1_highbd_fht4x4 = av1_highbd_fht4x4_c;
-    if (flags & HAS_SSE4_1) av1_highbd_fht4x4 = av1_highbd_fht4x4_sse4_1;
     av1_highbd_quantize_fp = av1_highbd_quantize_fp_c;
     if (flags & HAS_SSE4_1) av1_highbd_quantize_fp = av1_highbd_quantize_fp_sse4_1;
-    av1_highbd_warp_affine = av1_highbd_warp_affine_c;
-    if (flags & HAS_SSSE3) av1_highbd_warp_affine = av1_highbd_warp_affine_ssse3;
+    if (flags & HAS_AVX2) av1_highbd_quantize_fp = av1_highbd_quantize_fp_avx2;
     av1_iht16x16_256_add = av1_iht16x16_256_add_sse2;
     if (flags & HAS_AVX2) av1_iht16x16_256_add = av1_iht16x16_256_add_avx2;
     av1_inv_txfm2d_add_16x16 = av1_inv_txfm2d_add_16x16_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_16x16 = av1_inv_txfm2d_add_16x16_sse4_1;
     av1_inv_txfm2d_add_32x32 = av1_inv_txfm2d_add_32x32_c;
     if (flags & HAS_AVX2) av1_inv_txfm2d_add_32x32 = av1_inv_txfm2d_add_32x32_avx2;
     av1_inv_txfm2d_add_4x4 = av1_inv_txfm2d_add_4x4_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_4x4 = av1_inv_txfm2d_add_4x4_sse4_1;
     av1_inv_txfm2d_add_8x8 = av1_inv_txfm2d_add_8x8_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_8x8 = av1_inv_txfm2d_add_8x8_sse4_1;
     av1_lowbd_convolve_init = av1_lowbd_convolve_init_c;
     if (flags & HAS_SSSE3) av1_lowbd_convolve_init = av1_lowbd_convolve_init_ssse3;
-    av1_warp_affine = av1_warp_affine_sse2;
-    if (flags & HAS_SSSE3) av1_warp_affine = av1_warp_affine_ssse3;
-    compute_cross_correlation = compute_cross_correlation_c;
-    if (flags & HAS_SSE4_1) compute_cross_correlation = compute_cross_correlation_sse4_1;
+    av1_quantize_fp = av1_quantize_fp_sse2;
+    if (flags & HAS_AVX2) av1_quantize_fp = av1_quantize_fp_avx2;
+    av1_quantize_fp_32x32 = av1_quantize_fp_32x32_c;
+    if (flags & HAS_AVX2) av1_quantize_fp_32x32 = av1_quantize_fp_32x32_avx2;
     copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_sse2;
     if (flags & HAS_SSSE3) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_ssse3;
     if (flags & HAS_SSE4_1) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_sse4_1;
     copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_sse2;
     if (flags & HAS_SSSE3) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_ssse3;
     if (flags & HAS_SSE4_1) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_sse4_1;
     copy_8x8_16bit_to_16bit = copy_8x8_16bit_to_16bit_sse2;
     if (flags & HAS_SSSE3) copy_8x8_16bit_to_16bit = copy_8x8_16bit_to_16bit_ssse3;
--- a/media/libaom/config/mac/x64/aom_config.asm
+++ b/media/libaom/config/mac/x64/aom_config.asm
@@ -60,60 +60,63 @@
 %define CONFIG_INSPECTION 0
 %define CONFIG_DECODE_PERF_TESTS 0
 %define CONFIG_ENCODE_PERF_TESTS 0
 %define CONFIG_COEFFICIENT_RANGE_CHECKING 0
 %define CONFIG_LOWBITDEPTH 1
 %define CONFIG_HIGHBITDEPTH 1
 %define CONFIG_EXPERIMENTAL 0
 %define CONFIG_SIZE_LIMIT 1
+%define CONFIG_COLORSPACE_HEADERS 0
 %define CONFIG_FP_MB_STATS 0
 %define CONFIG_CDEF 1
 %define CONFIG_VAR_TX 1
 %define CONFIG_RECT_TX 1
 %define CONFIG_RECT_TX_EXT 0
 %define CONFIG_TPL_MV 0
-%define CONFIG_DUAL_FILTER 1
+%define CONFIG_DUAL_FILTER 0
 %define CONFIG_CONVOLVE_ROUND 0
 %define CONFIG_COMPOUND_ROUND 0
-%define CONFIG_EXT_TX 1
+%define CONFIG_EXT_TX 0
 %define CONFIG_DPCM_INTRA 0
 %define CONFIG_TX64X64 0
 %define CONFIG_EXT_INTRA 1
 %define CONFIG_INTRA_INTERP 0
 %define CONFIG_FILTER_INTRA 0
 %define CONFIG_INTRA_EDGE 0
 %define CONFIG_INTRABC 0
-%define CONFIG_EXT_INTER 1
-%define CONFIG_INTERINTRA 1
-%define CONFIG_WEDGE 1
-%define CONFIG_COMPOUND_SEGMENT 1
-%define CONFIG_EXT_REFS 1
-%define CONFIG_GLOBAL_MOTION 1
+%define CONFIG_EXT_INTER 0
+%define CONFIG_INTERINTRA 0
+%define CONFIG_WEDGE 0
+%define CONFIG_COMPOUND_SEGMENT 0
+%define CONFIG_EXT_REFS 0
+%define CONFIG_SPEED_REFS 0
+%define CONFIG_GF_GROUPS 0
+%define CONFIG_GLOBAL_MOTION 0
 %define CONFIG_NEW_QUANT 0
 %define CONFIG_SUPERTX 0
 %define CONFIG_ANS 0
 %define CONFIG_LOOP_RESTORATION 0
 %define CONFIG_EXT_PARTITION 0
 %define CONFIG_EXT_PARTITION_TYPES 0
 %define CONFIG_UNPOISON_PARTITION_CTX 0
 %define CONFIG_EXT_TILE 0
 %define CONFIG_MOTION_VAR 1
 %define CONFIG_NCOBMC 0
-%define CONFIG_WARPED_MOTION 1
+%define CONFIG_WARPED_MOTION 0
 %define CONFIG_Q_ADAPT_PROBS 0
 %define CONFIG_BITSTREAM_DEBUG 0
 %define CONFIG_ALT_INTRA 1
 %define CONFIG_PALETTE 1
 %define CONFIG_PALETTE_DELTA_ENCODING 0
 %define CONFIG_RAWBITS 0
 %define CONFIG_EC_SMALLMUL 1
 %define CONFIG_PVQ 0
 %define CONFIG_CFL 0
-%define CONFIG_XIPHRC 0
+%define CONFIG_XIPHRC 1
 %define CONFIG_CB4X4 1
 %define CONFIG_CHROMA_2X2 0
 %define CONFIG_CHROMA_SUB8X8 1
 %define CONFIG_FRAME_SIZE 0
 %define CONFIG_DELTA_Q 1
 %define CONFIG_EXT_DELTA_Q 1
 %define CONFIG_ADAPT_SCAN 0
 %define CONFIG_FILTER_7BIT 1
@@ -136,11 +139,18 @@
 %define CONFIG_LV_MAP 0
 %define CONFIG_TXK_SEL 0
 %define CONFIG_MV_COMPRESS 1
 %define CONFIG_FRAME_SUPERRES 0
 %define CONFIG_NEW_MULTISYMBOL 0
 %define CONFIG_COMPOUND_SINGLEREF 0
 %define CONFIG_AOM_QM 0
 %define CONFIG_ONE_SIDED_COMPOUND 1
-%define CONFIG_SMOOTH_HV 0
+%define CONFIG_EXT_COMP_REFS 0
+%define CONFIG_SMOOTH_HV 1
 %define CONFIG_VAR_REFS 0
+%define CONFIG_RECT_INTRA_PRED 0
+%define CONFIG_LGT 0
+%define CONFIG_SBL_SYMBOL 0
+%define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+%define CONFIG_BGSPRITE 0
+%define CONFIG_VAR_TX_NO_TX_MODE 0
 %define CONFIG_ANALYZER 0
--- a/media/libaom/config/mac/x64/aom_config.h
+++ b/media/libaom/config/mac/x64/aom_config.h
@@ -4,17 +4,17 @@
 /* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License */
 /* was not distributed with this source code in the LICENSE file, you can */
 /* obtain it at www.aomedia.org/license/software. If the Alliance for Open */
 /* Media Patent License 1.0 was not distributed with this source code in the */
 /* PATENTS file, you can obtain it at www.aomedia.org/license/patent. */
 /* This file automatically generated by configure. Do not edit! */
 #ifndef AOM_CONFIG_H
 #define AOM_CONFIG_H
-#define RESTRICT
+#define RESTRICT    
 #define INLINE      inline
 #define ARCH_ARM 0
 #define ARCH_MIPS 0
 #define ARCH_X86 0
 #define ARCH_X86_64 1
 #define HAVE_NEON 0
 #define HAVE_NEON_ASM 0
 #define HAVE_MIPS32 0
@@ -73,60 +73,63 @@
 #define CONFIG_INSPECTION 0
 #define CONFIG_DECODE_PERF_TESTS 0
 #define CONFIG_ENCODE_PERF_TESTS 0
 #define CONFIG_COEFFICIENT_RANGE_CHECKING 0
 #define CONFIG_LOWBITDEPTH 1
 #define CONFIG_HIGHBITDEPTH 1
 #define CONFIG_EXPERIMENTAL 0
 #define CONFIG_SIZE_LIMIT 1
+#define CONFIG_COLORSPACE_HEADERS 0
 #define CONFIG_FP_MB_STATS 0
 #define CONFIG_CDEF 1
 #define CONFIG_VAR_TX 1
 #define CONFIG_RECT_TX 1
 #define CONFIG_RECT_TX_EXT 0
 #define CONFIG_TPL_MV 0
-#define CONFIG_DUAL_FILTER 1
+#define CONFIG_DUAL_FILTER 0
 #define CONFIG_CONVOLVE_ROUND 0
 #define CONFIG_COMPOUND_ROUND 0
-#define CONFIG_EXT_TX 1
+#define CONFIG_EXT_TX 0
 #define CONFIG_DPCM_INTRA 0
 #define CONFIG_TX64X64 0
 #define CONFIG_EXT_INTRA 1
 #define CONFIG_INTRA_INTERP 0
 #define CONFIG_FILTER_INTRA 0
 #define CONFIG_INTRA_EDGE 0
 #define CONFIG_INTRABC 0
-#define CONFIG_EXT_INTER 1
-#define CONFIG_INTERINTRA 1
-#define CONFIG_WEDGE 1
-#define CONFIG_COMPOUND_SEGMENT 1
-#define CONFIG_EXT_REFS 1
-#define CONFIG_GLOBAL_MOTION 1
+#define CONFIG_EXT_INTER 0
+#define CONFIG_INTERINTRA 0
+#define CONFIG_WEDGE 0
+#define CONFIG_COMPOUND_SEGMENT 0
+#define CONFIG_EXT_REFS 0
+#define CONFIG_SPEED_REFS 0
+#define CONFIG_GF_GROUPS 0
+#define CONFIG_GLOBAL_MOTION 0
 #define CONFIG_NEW_QUANT 0
 #define CONFIG_SUPERTX 0
 #define CONFIG_ANS 0
 #define CONFIG_LOOP_RESTORATION 0
 #define CONFIG_EXT_PARTITION 0
 #define CONFIG_EXT_PARTITION_TYPES 0
 #define CONFIG_UNPOISON_PARTITION_CTX 0
 #define CONFIG_EXT_TILE 0
 #define CONFIG_MOTION_VAR 1
 #define CONFIG_NCOBMC 0
-#define CONFIG_WARPED_MOTION 1
+#define CONFIG_WARPED_MOTION 0
 #define CONFIG_Q_ADAPT_PROBS 0
 #define CONFIG_BITSTREAM_DEBUG 0
 #define CONFIG_ALT_INTRA 1
 #define CONFIG_PALETTE 1
 #define CONFIG_PALETTE_DELTA_ENCODING 0
 #define CONFIG_RAWBITS 0
 #define CONFIG_EC_SMALLMUL 1
 #define CONFIG_PVQ 0
 #define CONFIG_CFL 0
-#define CONFIG_XIPHRC 0
+#define CONFIG_XIPHRC 1
 #define CONFIG_CB4X4 1
 #define CONFIG_CHROMA_2X2 0
 #define CONFIG_CHROMA_SUB8X8 1
 #define CONFIG_FRAME_SIZE 0
 #define CONFIG_DELTA_Q 1
 #define CONFIG_EXT_DELTA_Q 1
 #define CONFIG_ADAPT_SCAN 0
 #define CONFIG_FILTER_7BIT 1
@@ -149,14 +152,21 @@
 #define CONFIG_LV_MAP 0
 #define CONFIG_TXK_SEL 0
 #define CONFIG_MV_COMPRESS 1
 #define CONFIG_FRAME_SUPERRES 0
 #define CONFIG_NEW_MULTISYMBOL 0
 #define CONFIG_COMPOUND_SINGLEREF 0
 #define CONFIG_AOM_QM 0
 #define CONFIG_ONE_SIDED_COMPOUND 1
-#define CONFIG_SMOOTH_HV 0
+#define CONFIG_EXT_COMP_REFS 0
+#define CONFIG_SMOOTH_HV 1
 #define CONFIG_VAR_REFS 0
+#define CONFIG_RECT_INTRA_PRED 0
+#define CONFIG_LGT 0
+#define CONFIG_SBL_SYMBOL 0
+#define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+#define CONFIG_BGSPRITE 0
+#define CONFIG_VAR_TX_NO_TX_MODE 0
 #define CONFIG_ANALYZER 0
 #define DECODE_WIDTH_LIMIT 8192
 #define DECODE_HEIGHT_LIMIT 4608
 #endif /* AOM_CONFIG_H */
--- a/media/libaom/config/mac/x64/aom_dsp_rtcd.h
+++ b/media/libaom/config/mac/x64/aom_dsp_rtcd.h
@@ -30,257 +30,439 @@ RTCD_EXTERN void (*aom_blend_a64_mask)(u
 
 void aom_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 void aom_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 RTCD_EXTERN void (*aom_blend_a64_vmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 
 void aom_comp_avg_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
 #define aom_comp_avg_pred aom_comp_avg_pred_c
 
-void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
-void aom_comp_avg_upsampled_pred_sse2(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
+void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+void aom_comp_avg_upsampled_pred_sse2(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 #define aom_comp_avg_upsampled_pred aom_comp_avg_upsampled_pred_sse2
 
-void aom_comp_mask_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_pred aom_comp_mask_pred_c
-
-void aom_comp_mask_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_upsampled_pred aom_comp_mask_upsampled_pred_c
-
 void aom_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_horiz_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_horiz_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_avg_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_horiz_scale aom_convolve8_avg_horiz_scale_c
+
+void aom_convolve8_avg_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_scale aom_convolve8_avg_scale_c
+
 void aom_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_vert_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_vert_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_avg_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_vert_scale aom_convolve8_avg_vert_scale_c
+
 void aom_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_horiz_scale aom_convolve8_horiz_scale_c
+
+void aom_convolve8_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_scale aom_convolve8_scale_c
+
 void aom_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_vert_scale aom_convolve8_vert_scale_c
+
 void aom_convolve_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve_avg aom_convolve_avg_sse2
 
 void aom_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve_copy_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve_copy aom_convolve_copy_sse2
 
 void aom_d117_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_16x16 aom_d117_predictor_16x16_c
 
+void aom_d117_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x32 aom_d117_predictor_16x32_c
+
+void aom_d117_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x8 aom_d117_predictor_16x8_c
+
 void aom_d117_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_2x2 aom_d117_predictor_2x2_c
 
+void aom_d117_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_32x16 aom_d117_predictor_32x16_c
+
 void aom_d117_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_32x32 aom_d117_predictor_32x32_c
 
 void aom_d117_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_4x4 aom_d117_predictor_4x4_c
 
+void aom_d117_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_4x8 aom_d117_predictor_4x8_c
+
+void aom_d117_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x16 aom_d117_predictor_8x16_c
+
+void aom_d117_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x4 aom_d117_predictor_8x4_c
+
 void aom_d117_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_8x8 aom_d117_predictor_8x8_c
 
 void aom_d135_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_16x16 aom_d135_predictor_16x16_c
 
+void aom_d135_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x32 aom_d135_predictor_16x32_c
+
+void aom_d135_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x8 aom_d135_predictor_16x8_c
+
 void aom_d135_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_2x2 aom_d135_predictor_2x2_c
 
+void aom_d135_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_32x16 aom_d135_predictor_32x16_c
+
 void aom_d135_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_32x32 aom_d135_predictor_32x32_c
 
 void aom_d135_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_4x4 aom_d135_predictor_4x4_c
 
+void aom_d135_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_4x8 aom_d135_predictor_4x8_c
+
+void aom_d135_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x16 aom_d135_predictor_8x16_c
+
+void aom_d135_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x4 aom_d135_predictor_8x4_c
+
 void aom_d135_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_8x8 aom_d135_predictor_8x8_c
 
 void aom_d153_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_16x16_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d153_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x32 aom_d153_predictor_16x32_c
+
+void aom_d153_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x8 aom_d153_predictor_16x8_c
+
 void aom_d153_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_2x2 aom_d153_predictor_2x2_c
 
+void aom_d153_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_32x16 aom_d153_predictor_32x16_c
+
 void aom_d153_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_32x32_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_d153_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d153_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_4x8 aom_d153_predictor_4x8_c
+
+void aom_d153_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x16 aom_d153_predictor_8x16_c
+
+void aom_d153_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x4 aom_d153_predictor_8x4_c
+
 void aom_d153_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_8x8_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_d207e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_16x16 aom_d207e_predictor_16x16_c
 
+void aom_d207e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x32 aom_d207e_predictor_16x32_c
+
+void aom_d207e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x8 aom_d207e_predictor_16x8_c
+
 void aom_d207e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_2x2 aom_d207e_predictor_2x2_c
 
+void aom_d207e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_32x16 aom_d207e_predictor_32x16_c
+
 void aom_d207e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_32x32 aom_d207e_predictor_32x32_c
 
 void aom_d207e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_4x4 aom_d207e_predictor_4x4_c
 
+void aom_d207e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_4x8 aom_d207e_predictor_4x8_c
+
+void aom_d207e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x16 aom_d207e_predictor_8x16_c
+
+void aom_d207e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x4 aom_d207e_predictor_8x4_c
+
 void aom_d207e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_8x8 aom_d207e_predictor_8x8_c
 
 void aom_d45e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_16x16 aom_d45e_predictor_16x16_c
 
+void aom_d45e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x32 aom_d45e_predictor_16x32_c
+
+void aom_d45e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x8 aom_d45e_predictor_16x8_c
+
 void aom_d45e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_2x2 aom_d45e_predictor_2x2_c
 
+void aom_d45e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_32x16 aom_d45e_predictor_32x16_c
+
 void aom_d45e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_32x32 aom_d45e_predictor_32x32_c
 
 void aom_d45e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_4x4 aom_d45e_predictor_4x4_c
 
+void aom_d45e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_4x8 aom_d45e_predictor_4x8_c
+
+void aom_d45e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x16 aom_d45e_predictor_8x16_c
+
+void aom_d45e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x4 aom_d45e_predictor_8x4_c
+
 void aom_d45e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_8x8 aom_d45e_predictor_8x8_c
 
 void aom_d63e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_16x16 aom_d63e_predictor_16x16_c
 
+void aom_d63e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x32 aom_d63e_predictor_16x32_c
+
+void aom_d63e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x8 aom_d63e_predictor_16x8_c
+
 void aom_d63e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_2x2 aom_d63e_predictor_2x2_c
 
+void aom_d63e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_32x16 aom_d63e_predictor_32x16_c
+
 void aom_d63e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_32x32 aom_d63e_predictor_32x32_c
 
 void aom_d63e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d63e_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d63e_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d63e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_4x8 aom_d63e_predictor_4x8_c
+
+void aom_d63e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x16 aom_d63e_predictor_8x16_c
+
+void aom_d63e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x4 aom_d63e_predictor_8x4_c
+
 void aom_d63e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_8x8 aom_d63e_predictor_8x8_c
 
 void aom_dc_128_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_16x16 aom_dc_128_predictor_16x16_sse2
 
+void aom_dc_128_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x32 aom_dc_128_predictor_16x32_c
+
+void aom_dc_128_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x8 aom_dc_128_predictor_16x8_c
+
 void aom_dc_128_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_2x2 aom_dc_128_predictor_2x2_c
 
+void aom_dc_128_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_32x16 aom_dc_128_predictor_32x16_c
+
 void aom_dc_128_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_32x32 aom_dc_128_predictor_32x32_sse2
 
 void aom_dc_128_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_4x4 aom_dc_128_predictor_4x4_sse2
 
+void aom_dc_128_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_4x8 aom_dc_128_predictor_4x8_c
+
+void aom_dc_128_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x16 aom_dc_128_predictor_8x16_c
+
+void aom_dc_128_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x4 aom_dc_128_predictor_8x4_c
+
 void aom_dc_128_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_8x8 aom_dc_128_predictor_8x8_sse2
 
 void aom_dc_left_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_16x16 aom_dc_left_predictor_16x16_sse2
 
+void aom_dc_left_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x32 aom_dc_left_predictor_16x32_c
+
+void aom_dc_left_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x8 aom_dc_left_predictor_16x8_c
+
 void aom_dc_left_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_2x2 aom_dc_left_predictor_2x2_c
 
+void aom_dc_left_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_32x16 aom_dc_left_predictor_32x16_c
+
 void aom_dc_left_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_32x32 aom_dc_left_predictor_32x32_sse2
 
 void aom_dc_left_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_4x4 aom_dc_left_predictor_4x4_sse2
 
+void aom_dc_left_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_4x8 aom_dc_left_predictor_4x8_c
+
+void aom_dc_left_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x16 aom_dc_left_predictor_8x16_c
+
+void aom_dc_left_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x4 aom_dc_left_predictor_8x4_c
+
 void aom_dc_left_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_8x8 aom_dc_left_predictor_8x8_sse2
 
 void aom_dc_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_16x16 aom_dc_predictor_16x16_sse2
 
+void aom_dc_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x32 aom_dc_predictor_16x32_c
+
+void aom_dc_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x8 aom_dc_predictor_16x8_c
+
 void aom_dc_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_2x2 aom_dc_predictor_2x2_c
 
+void aom_dc_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_32x16 aom_dc_predictor_32x16_c
+
 void aom_dc_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_32x32 aom_dc_predictor_32x32_sse2
 
 void aom_dc_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_4x4 aom_dc_predictor_4x4_sse2
 
+void aom_dc_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_4x8 aom_dc_predictor_4x8_c
+
+void aom_dc_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x16 aom_dc_predictor_8x16_c
+
+void aom_dc_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x4 aom_dc_predictor_8x4_c
+
 void aom_dc_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_8x8 aom_dc_predictor_8x8_sse2
 
 void aom_dc_top_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_16x16 aom_dc_top_predictor_16x16_sse2
 
+void aom_dc_top_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x32 aom_dc_top_predictor_16x32_c
+
+void aom_dc_top_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x8 aom_dc_top_predictor_16x8_c
+
 void aom_dc_top_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_2x2 aom_dc_top_predictor_2x2_c
 
+void aom_dc_top_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_32x16 aom_dc_top_predictor_32x16_c
+
 void aom_dc_top_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_32x32 aom_dc_top_predictor_32x32_sse2
 
 void aom_dc_top_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_4x4 aom_dc_top_predictor_4x4_sse2
 
+void aom_dc_top_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_4x8 aom_dc_top_predictor_4x8_c
+
+void aom_dc_top_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x16 aom_dc_top_predictor_8x16_c
+
+void aom_dc_top_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x4 aom_dc_top_predictor_8x4_c
+
 void aom_dc_top_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_8x8 aom_dc_top_predictor_8x8_sse2
 
 void aom_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct16x16_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct16x16 aom_fdct16x16_sse2
 
-void aom_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct16x16_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct16x16_1_avx2(const int16_t *input, tran_low_t *output, int stride);
-RTCD_EXTERN void (*aom_fdct16x16_1)(const int16_t *input, tran_low_t *output, int stride);
-
 void aom_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_avx2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct32x32)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct32x32_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct32x32_1_avx2(const int16_t *input, tran_low_t *output, int stride);
-RTCD_EXTERN void (*aom_fdct32x32_1)(const int16_t *input, tran_low_t *output, int stride);
-
 void aom_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_rd_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_rd_avx2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct32x32_rd)(const int16_t *input, tran_low_t *output, int stride);
 
 void aom_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct4x4_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct4x4 aom_fdct4x4_sse2
@@ -289,20 +471,16 @@ void aom_fdct4x4_1_c(const int16_t *inpu
 void aom_fdct4x4_1_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct4x4_1 aom_fdct4x4_1_sse2
 
 void aom_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct8x8_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct8x8_ssse3(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct8x8)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct8x8_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-#define aom_fdct8x8_1 aom_fdct8x8_1_sse2
-
 void aom_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 void aom_get16x16var_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 void aom_get16x16var_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 RTCD_EXTERN void (*aom_get16x16var)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 
 unsigned int aom_get4x4sse_cs_c(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int ref_stride);
 #define aom_get4x4sse_cs aom_get4x4sse_cs_c
 
@@ -313,27 +491,45 @@ void aom_get8x8var_sse2(const uint8_t *s
 unsigned int aom_get_mb_ss_c(const int16_t *);
 unsigned int aom_get_mb_ss_sse2(const int16_t *);
 #define aom_get_mb_ss aom_get_mb_ss_sse2
 
 void aom_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_16x16 aom_h_predictor_16x16_sse2
 
+void aom_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x32 aom_h_predictor_16x32_c
+
+void aom_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x8 aom_h_predictor_16x8_c
+
 void aom_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_2x2 aom_h_predictor_2x2_c
 
+void aom_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_32x16 aom_h_predictor_32x16_c
+
 void aom_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_32x32 aom_h_predictor_32x32_sse2
 
 void aom_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_4x4 aom_h_predictor_4x4_sse2
 
+void aom_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_4x8 aom_h_predictor_4x8_c
+
+void aom_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x16 aom_h_predictor_8x16_c
+
+void aom_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x4 aom_h_predictor_8x4_c
+
 void aom_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_8x8 aom_h_predictor_8x8_sse2
 
 void aom_hadamard_16x16_c(const int16_t *src_diff, int src_stride, int16_t *coeff);
 void aom_hadamard_16x16_sse2(const int16_t *src_diff, int src_stride, int16_t *coeff);
 #define aom_hadamard_16x16 aom_hadamard_16x16_sse2
 
@@ -343,68 +539,16 @@ void aom_hadamard_8x8_ssse3(const int16_
 RTCD_EXTERN void (*aom_hadamard_8x8)(const int16_t *src_diff, int src_stride, int16_t *coeff);
 
 void aom_highbd_10_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get16x16var aom_highbd_10_get16x16var_c
 
 void aom_highbd_10_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get8x8var aom_highbd_10_get8x8var_c
 
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_10_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_10_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse16x16 aom_highbd_10_mse16x16_sse2
 
 unsigned int aom_highbd_10_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse16x8 aom_highbd_10_mse16x8_c
 
 unsigned int aom_highbd_10_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -667,68 +811,16 @@ unsigned int aom_highbd_10_variance8x8_s
 #define aom_highbd_10_variance8x8 aom_highbd_10_variance8x8_sse2
 
 void aom_highbd_12_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get16x16var aom_highbd_12_get16x16var_c
 
 void aom_highbd_12_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get8x8var aom_highbd_12_get8x8var_c
 
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_12_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_12_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse16x16 aom_highbd_12_mse16x16_sse2
 
 unsigned int aom_highbd_12_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse16x8 aom_highbd_12_mse16x8_c
 
 unsigned int aom_highbd_12_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -991,68 +1083,16 @@ unsigned int aom_highbd_12_variance8x8_s
 #define aom_highbd_12_variance8x8 aom_highbd_12_variance8x8_sse2
 
 void aom_highbd_8_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get16x16var aom_highbd_8_get16x16var_c
 
 void aom_highbd_8_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get8x8var aom_highbd_8_get8x8var_c
 
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_8_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_8_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse16x16 aom_highbd_8_mse16x16_sse2
 
 unsigned int aom_highbd_8_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse16x8 aom_highbd_8_mse16x8_c
 
 unsigned int aom_highbd_8_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -1233,26 +1273,20 @@ RTCD_EXTERN void (*aom_highbd_blend_a64_
 
 void aom_highbd_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 void aom_highbd_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 RTCD_EXTERN void (*aom_highbd_blend_a64_vmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 
 void aom_highbd_comp_avg_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
 #define aom_highbd_comp_avg_pred aom_highbd_comp_avg_pred_c
 
-void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
-void aom_highbd_comp_avg_upsampled_pred_sse2(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
+void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+void aom_highbd_comp_avg_upsampled_pred_sse2(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 #define aom_highbd_comp_avg_upsampled_pred aom_highbd_comp_avg_upsampled_pred_sse2
 
-void aom_highbd_comp_mask_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_pred aom_highbd_comp_mask_pred_c
-
-void aom_highbd_comp_mask_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_upsampled_pred aom_highbd_comp_mask_upsampled_pred_c
-
 void aom_highbd_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 RTCD_EXTERN void (*aom_highbd_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 
 void aom_highbd_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avg_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
@@ -1286,233 +1320,400 @@ RTCD_EXTERN void (*aom_highbd_convolve_a
 void aom_highbd_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve_copy_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve_copy_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 RTCD_EXTERN void (*aom_highbd_convolve_copy)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 
 void aom_highbd_d117_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_16x16 aom_highbd_d117_predictor_16x16_c
 
+void aom_highbd_d117_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x32 aom_highbd_d117_predictor_16x32_c
+
+void aom_highbd_d117_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x8 aom_highbd_d117_predictor_16x8_c
+
 void aom_highbd_d117_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_2x2 aom_highbd_d117_predictor_2x2_c
 
+void aom_highbd_d117_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_32x16 aom_highbd_d117_predictor_32x16_c
+
 void aom_highbd_d117_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_32x32 aom_highbd_d117_predictor_32x32_c
 
 void aom_highbd_d117_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_4x4 aom_highbd_d117_predictor_4x4_c
 
+void aom_highbd_d117_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_4x8 aom_highbd_d117_predictor_4x8_c
+
+void aom_highbd_d117_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x16 aom_highbd_d117_predictor_8x16_c
+
+void aom_highbd_d117_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x4 aom_highbd_d117_predictor_8x4_c
+
 void aom_highbd_d117_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_8x8 aom_highbd_d117_predictor_8x8_c
 
 void aom_highbd_d135_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_16x16 aom_highbd_d135_predictor_16x16_c
 
+void aom_highbd_d135_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x32 aom_highbd_d135_predictor_16x32_c
+
+void aom_highbd_d135_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x8 aom_highbd_d135_predictor_16x8_c
+
 void aom_highbd_d135_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_2x2 aom_highbd_d135_predictor_2x2_c
 
+void aom_highbd_d135_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_32x16 aom_highbd_d135_predictor_32x16_c
+
 void aom_highbd_d135_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_32x32 aom_highbd_d135_predictor_32x32_c
 
 void aom_highbd_d135_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_4x4 aom_highbd_d135_predictor_4x4_c
 
+void aom_highbd_d135_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_4x8 aom_highbd_d135_predictor_4x8_c
+
+void aom_highbd_d135_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x16 aom_highbd_d135_predictor_8x16_c
+
+void aom_highbd_d135_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x4 aom_highbd_d135_predictor_8x4_c
+
 void aom_highbd_d135_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_8x8 aom_highbd_d135_predictor_8x8_c
 
 void aom_highbd_d153_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_16x16 aom_highbd_d153_predictor_16x16_c
 
+void aom_highbd_d153_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x32 aom_highbd_d153_predictor_16x32_c
+
+void aom_highbd_d153_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x8 aom_highbd_d153_predictor_16x8_c
+
 void aom_highbd_d153_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_2x2 aom_highbd_d153_predictor_2x2_c
 
+void aom_highbd_d153_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_32x16 aom_highbd_d153_predictor_32x16_c
+
 void aom_highbd_d153_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_32x32 aom_highbd_d153_predictor_32x32_c
 
 void aom_highbd_d153_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_4x4 aom_highbd_d153_predictor_4x4_c
 
+void aom_highbd_d153_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_4x8 aom_highbd_d153_predictor_4x8_c
+
+void aom_highbd_d153_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x16 aom_highbd_d153_predictor_8x16_c
+
+void aom_highbd_d153_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x4 aom_highbd_d153_predictor_8x4_c
+
 void aom_highbd_d153_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_8x8 aom_highbd_d153_predictor_8x8_c
 
 void aom_highbd_d207e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_16x16 aom_highbd_d207e_predictor_16x16_c
 
+void aom_highbd_d207e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x32 aom_highbd_d207e_predictor_16x32_c
+
+void aom_highbd_d207e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x8 aom_highbd_d207e_predictor_16x8_c
+
 void aom_highbd_d207e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_2x2 aom_highbd_d207e_predictor_2x2_c
 
+void aom_highbd_d207e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_32x16 aom_highbd_d207e_predictor_32x16_c
+
 void aom_highbd_d207e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_32x32 aom_highbd_d207e_predictor_32x32_c
 
 void aom_highbd_d207e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_4x4 aom_highbd_d207e_predictor_4x4_c
 
+void aom_highbd_d207e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_4x8 aom_highbd_d207e_predictor_4x8_c
+
+void aom_highbd_d207e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x16 aom_highbd_d207e_predictor_8x16_c
+
+void aom_highbd_d207e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x4 aom_highbd_d207e_predictor_8x4_c
+
 void aom_highbd_d207e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_8x8 aom_highbd_d207e_predictor_8x8_c
 
 void aom_highbd_d45e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_16x16 aom_highbd_d45e_predictor_16x16_c
 
+void aom_highbd_d45e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x32 aom_highbd_d45e_predictor_16x32_c
+
+void aom_highbd_d45e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x8 aom_highbd_d45e_predictor_16x8_c
+
 void aom_highbd_d45e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_2x2 aom_highbd_d45e_predictor_2x2_c
 
+void aom_highbd_d45e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_32x16 aom_highbd_d45e_predictor_32x16_c
+
 void aom_highbd_d45e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_32x32 aom_highbd_d45e_predictor_32x32_c
 
 void aom_highbd_d45e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_4x4 aom_highbd_d45e_predictor_4x4_c
 
+void aom_highbd_d45e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_4x8 aom_highbd_d45e_predictor_4x8_c
+
+void aom_highbd_d45e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x16 aom_highbd_d45e_predictor_8x16_c
+
+void aom_highbd_d45e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x4 aom_highbd_d45e_predictor_8x4_c
+
 void aom_highbd_d45e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_8x8 aom_highbd_d45e_predictor_8x8_c
 
 void aom_highbd_d63e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_16x16 aom_highbd_d63e_predictor_16x16_c
 
+void aom_highbd_d63e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x32 aom_highbd_d63e_predictor_16x32_c
+
+void aom_highbd_d63e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x8 aom_highbd_d63e_predictor_16x8_c
+
 void aom_highbd_d63e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_2x2 aom_highbd_d63e_predictor_2x2_c
 
+void aom_highbd_d63e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_32x16 aom_highbd_d63e_predictor_32x16_c
+
 void aom_highbd_d63e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_32x32 aom_highbd_d63e_predictor_32x32_c
 
 void aom_highbd_d63e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_4x4 aom_highbd_d63e_predictor_4x4_c
 
+void aom_highbd_d63e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_4x8 aom_highbd_d63e_predictor_4x8_c
+
+void aom_highbd_d63e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x16 aom_highbd_d63e_predictor_8x16_c
+
+void aom_highbd_d63e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x4 aom_highbd_d63e_predictor_8x4_c
+
 void aom_highbd_d63e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_8x8 aom_highbd_d63e_predictor_8x8_c
 
 void aom_highbd_dc_128_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_16x16 aom_highbd_dc_128_predictor_16x16_c
 
+void aom_highbd_dc_128_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x32 aom_highbd_dc_128_predictor_16x32_c
+
+void aom_highbd_dc_128_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x8 aom_highbd_dc_128_predictor_16x8_c
+
 void aom_highbd_dc_128_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_2x2 aom_highbd_dc_128_predictor_2x2_c
 
+void aom_highbd_dc_128_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_32x16 aom_highbd_dc_128_predictor_32x16_c
+
 void aom_highbd_dc_128_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_32x32 aom_highbd_dc_128_predictor_32x32_c
 
 void aom_highbd_dc_128_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_4x4 aom_highbd_dc_128_predictor_4x4_c
 
+void aom_highbd_dc_128_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_4x8 aom_highbd_dc_128_predictor_4x8_c
+
+void aom_highbd_dc_128_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x16 aom_highbd_dc_128_predictor_8x16_c
+
+void aom_highbd_dc_128_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x4 aom_highbd_dc_128_predictor_8x4_c
+
 void aom_highbd_dc_128_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_8x8 aom_highbd_dc_128_predictor_8x8_c
 
 void aom_highbd_dc_left_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_16x16 aom_highbd_dc_left_predictor_16x16_c
 
+void aom_highbd_dc_left_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x32 aom_highbd_dc_left_predictor_16x32_c
+
+void aom_highbd_dc_left_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x8 aom_highbd_dc_left_predictor_16x8_c
+
 void aom_highbd_dc_left_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_2x2 aom_highbd_dc_left_predictor_2x2_c
 
+void aom_highbd_dc_left_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_32x16 aom_highbd_dc_left_predictor_32x16_c
+
 void aom_highbd_dc_left_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_32x32 aom_highbd_dc_left_predictor_32x32_c
 
 void aom_highbd_dc_left_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_4x4 aom_highbd_dc_left_predictor_4x4_c
 
+void aom_highbd_dc_left_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_4x8 aom_highbd_dc_left_predictor_4x8_c
+
+void aom_highbd_dc_left_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x16 aom_highbd_dc_left_predictor_8x16_c
+
+void aom_highbd_dc_left_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x4 aom_highbd_dc_left_predictor_8x4_c
+
 void aom_highbd_dc_left_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_8x8 aom_highbd_dc_left_predictor_8x8_c
 
 void aom_highbd_dc_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_16x16_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_16x16 aom_highbd_dc_predictor_16x16_sse2
 
+void aom_highbd_dc_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x32 aom_highbd_dc_predictor_16x32_c
+
+void aom_highbd_dc_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x8 aom_highbd_dc_predictor_16x8_c
+
 void aom_highbd_dc_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_2x2 aom_highbd_dc_predictor_2x2_c
 
+void aom_highbd_dc_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_32x16 aom_highbd_dc_predictor_32x16_c
+
 void aom_highbd_dc_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_32x32_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_32x32 aom_highbd_dc_predictor_32x32_sse2
 
 void aom_highbd_dc_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_4x4_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_4x4 aom_highbd_dc_predictor_4x4_sse2
 
+void aom_highbd_dc_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_4x8 aom_highbd_dc_predictor_4x8_c
+
+void aom_highbd_dc_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x16 aom_highbd_dc_predictor_8x16_c
+
+void aom_highbd_dc_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x4 aom_highbd_dc_predictor_8x4_c
+
 void aom_highbd_dc_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_8x8_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_8x8 aom_highbd_dc_predictor_8x8_sse2
 
 void aom_highbd_dc_top_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_16x16 aom_highbd_dc_top_predictor_16x16_c
 
+void aom_highbd_dc_top_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x32 aom_highbd_dc_top_predictor_16x32_c
+
+void aom_highbd_dc_top_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x8 aom_highbd_dc_top_predictor_16x8_c
+
 void aom_highbd_dc_top_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_2x2 aom_highbd_dc_top_predictor_2x2_c
 
+void aom_highbd_dc_top_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_32x16 aom_highbd_dc_top_predictor_32x16_c
+
 void aom_highbd_dc_top_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_32x32 aom_highbd_dc_top_predictor_32x32_c
 
 void aom_highbd_dc_top_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_4x4 aom_highbd_dc_top_predictor_4x4_c
 
+void aom_highbd_dc_top_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_4x8 aom_highbd_dc_top_predictor_4x8_c
+
+void aom_highbd_dc_top_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x16 aom_highbd_dc_top_predictor_8x16_c
+
+void aom_highbd_dc_top_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x4 aom_highbd_dc_top_predictor_8x4_c
+
 void aom_highbd_dc_top_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_8x8 aom_highbd_dc_top_predictor_8x8_c
 
 void aom_highbd_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct16x16_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct16x16 aom_highbd_fdct16x16_sse2
 
-void aom_highbd_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct16x16_1 aom_highbd_fdct16x16_1_c
-
 void aom_highbd_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct32x32_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct32x32 aom_highbd_fdct32x32_sse2
 
-void aom_highbd_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct32x32_1 aom_highbd_fdct32x32_1_c
-
 void aom_highbd_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct32x32_rd_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct32x32_rd aom_highbd_fdct32x32_rd_sse2
 
 void aom_highbd_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct4x4_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct4x4 aom_highbd_fdct4x4_sse2
 
 void aom_highbd_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct8x8_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct8x8 aom_highbd_fdct8x8_sse2
 
-void aom_highbd_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct8x8_1 aom_highbd_fdct8x8_1_c
-
 void aom_highbd_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_16x16 aom_highbd_h_predictor_16x16_c
 
+void aom_highbd_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x32 aom_highbd_h_predictor_16x32_c
+
+void aom_highbd_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x8 aom_highbd_h_predictor_16x8_c
+
 void aom_highbd_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_2x2 aom_highbd_h_predictor_2x2_c
 
+void aom_highbd_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_32x16 aom_highbd_h_predictor_32x16_c
+
 void aom_highbd_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_32x32 aom_highbd_h_predictor_32x32_c
 
 void aom_highbd_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_4x4 aom_highbd_h_predictor_4x4_c
 
+void aom_highbd_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_4x8 aom_highbd_h_predictor_4x8_c
+
+void aom_highbd_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x16 aom_highbd_h_predictor_8x16_c
+
+void aom_highbd_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x4 aom_highbd_h_predictor_8x4_c
+
 void aom_highbd_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_8x8 aom_highbd_h_predictor_8x8_c
 
-void aom_highbd_idct16x16_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct16x16_1_add aom_highbd_idct16x16_1_add_c
-
-void aom_highbd_idct32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1024_add aom_highbd_idct32x32_1024_add_c
-
-void aom_highbd_idct32x32_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1_add aom_highbd_idct32x32_1_add_c
-
-void aom_highbd_idct32x32_34_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_34_add aom_highbd_idct32x32_34_add_c
-
-void aom_highbd_idct4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-void aom_highbd_idct4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct4x4_16_add aom_highbd_idct4x4_16_add_sse2
-
-void aom_highbd_idct4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct4x4_1_add aom_highbd_idct4x4_1_add_c
-
-void aom_highbd_idct8x8_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct8x8_1_add aom_highbd_idct8x8_1_add_c
-
 void aom_highbd_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_16_add aom_highbd_iwht4x4_16_add_c
 
 void aom_highbd_iwht4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_1_add aom_highbd_iwht4x4_1_add_c
 
 void aom_highbd_lpf_horizontal_4_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 void aom_highbd_lpf_horizontal_4_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
@@ -1557,68 +1758,16 @@ void aom_highbd_lpf_vertical_4_dual_sse2
 void aom_highbd_lpf_vertical_8_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 void aom_highbd_lpf_vertical_8_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 #define aom_highbd_lpf_vertical_8 aom_highbd_lpf_vertical_8_sse2
 
 void aom_highbd_lpf_vertical_8_dual_c(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 void aom_highbd_lpf_vertical_8_dual_sse2(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 #define aom_highbd_lpf_vertical_8_dual aom_highbd_lpf_vertical_8_dual_sse2
 
-unsigned int aom_highbd_masked_sad16x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad16x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad16x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x64_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x64)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad4x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad4x4_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad4x4)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad4x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad4x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad4x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad64x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad64x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad64x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad64x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad64x64_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad64x64)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x4_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x4)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
 void aom_highbd_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 #define aom_highbd_minmax_8x8 aom_highbd_minmax_8x8_c
 
 unsigned int aom_highbd_obmc_sad16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 unsigned int aom_highbd_obmc_sad16x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad16x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 
 unsigned int aom_highbd_obmc_sad16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
@@ -1758,31 +1907,50 @@ RTCD_EXTERN unsigned int (*aom_highbd_ob
 
 unsigned int aom_highbd_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 unsigned int aom_highbd_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 
 void aom_highbd_paeth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_16x16 aom_highbd_paeth_predictor_16x16_c
 
+void aom_highbd_paeth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x32 aom_highbd_paeth_predictor_16x32_c
+
+void aom_highbd_paeth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x8 aom_highbd_paeth_predictor_16x8_c
+
 void aom_highbd_paeth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_2x2 aom_highbd_paeth_predictor_2x2_c
 
+void aom_highbd_paeth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_32x16 aom_highbd_paeth_predictor_32x16_c
+
 void aom_highbd_paeth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_32x32 aom_highbd_paeth_predictor_32x32_c
 
 void aom_highbd_paeth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_4x4 aom_highbd_paeth_predictor_4x4_c
 
+void aom_highbd_paeth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_4x8 aom_highbd_paeth_predictor_4x8_c
+
+void aom_highbd_paeth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x16 aom_highbd_paeth_predictor_8x16_c
+
+void aom_highbd_paeth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x4 aom_highbd_paeth_predictor_8x4_c
+
 void aom_highbd_paeth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_8x8 aom_highbd_paeth_predictor_8x8_c
 
 void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_highbd_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
-#define aom_highbd_quantize_b aom_highbd_quantize_b_sse2
+void aom_highbd_quantize_b_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*aom_highbd_quantize_b)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void aom_highbd_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_highbd_quantize_b_32x32_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_highbd_quantize_b_32x32 aom_highbd_quantize_b_32x32_sse2
 
 void aom_highbd_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_highbd_quantize_b_64x64 aom_highbd_quantize_b_64x64_c
 
@@ -2005,54 +2173,156 @@ void aom_highbd_sad8x8x3_c(const uint8_t
 
 void aom_highbd_sad8x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 void aom_highbd_sad8x8x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 #define aom_highbd_sad8x8x4d aom_highbd_sad8x8x4d_sse2
 
 void aom_highbd_sad8x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
 #define aom_highbd_sad8x8x8 aom_highbd_sad8x8x8_c
 
+void aom_highbd_smooth_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x16 aom_highbd_smooth_h_predictor_16x16_c
+
+void aom_highbd_smooth_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x32 aom_highbd_smooth_h_predictor_16x32_c
+
+void aom_highbd_smooth_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x8 aom_highbd_smooth_h_predictor_16x8_c
+
+void aom_highbd_smooth_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_2x2 aom_highbd_smooth_h_predictor_2x2_c
+
+void aom_highbd_smooth_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x16 aom_highbd_smooth_h_predictor_32x16_c
+
+void aom_highbd_smooth_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x32 aom_highbd_smooth_h_predictor_32x32_c
+
+void aom_highbd_smooth_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x4 aom_highbd_smooth_h_predictor_4x4_c
+
+void aom_highbd_smooth_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x8 aom_highbd_smooth_h_predictor_4x8_c
+
+void aom_highbd_smooth_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x16 aom_highbd_smooth_h_predictor_8x16_c
+
+void aom_highbd_smooth_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x4 aom_highbd_smooth_h_predictor_8x4_c
+
+void aom_highbd_smooth_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x8 aom_highbd_smooth_h_predictor_8x8_c
+
 void aom_highbd_smooth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_16x16 aom_highbd_smooth_predictor_16x16_c
 
+void aom_highbd_smooth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x32 aom_highbd_smooth_predictor_16x32_c
+
+void aom_highbd_smooth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x8 aom_highbd_smooth_predictor_16x8_c
+
 void aom_highbd_smooth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_2x2 aom_highbd_smooth_predictor_2x2_c
 
+void aom_highbd_smooth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_32x16 aom_highbd_smooth_predictor_32x16_c
+
 void aom_highbd_smooth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_32x32 aom_highbd_smooth_predictor_32x32_c
 
 void aom_highbd_smooth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_4x4 aom_highbd_smooth_predictor_4x4_c
 
+void aom_highbd_smooth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_4x8 aom_highbd_smooth_predictor_4x8_c
+
+void aom_highbd_smooth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x16 aom_highbd_smooth_predictor_8x16_c
+
+void aom_highbd_smooth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x4 aom_highbd_smooth_predictor_8x4_c
+
 void aom_highbd_smooth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_8x8 aom_highbd_smooth_predictor_8x8_c
 
+void aom_highbd_smooth_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x16 aom_highbd_smooth_v_predictor_16x16_c
+
+void aom_highbd_smooth_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x32 aom_highbd_smooth_v_predictor_16x32_c
+
+void aom_highbd_smooth_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x8 aom_highbd_smooth_v_predictor_16x8_c
+
+void aom_highbd_smooth_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_2x2 aom_highbd_smooth_v_predictor_2x2_c
+
+void aom_highbd_smooth_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x16 aom_highbd_smooth_v_predictor_32x16_c
+
+void aom_highbd_smooth_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x32 aom_highbd_smooth_v_predictor_32x32_c
+
+void aom_highbd_smooth_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x4 aom_highbd_smooth_v_predictor_4x4_c
+
+void aom_highbd_smooth_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x8 aom_highbd_smooth_v_predictor_4x8_c
+
+void aom_highbd_smooth_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x16 aom_highbd_smooth_v_predictor_8x16_c
+
+void aom_highbd_smooth_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x4 aom_highbd_smooth_v_predictor_8x4_c
+
+void aom_highbd_smooth_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x8 aom_highbd_smooth_v_predictor_8x8_c
+
 void aom_highbd_subtract_block_c(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 void aom_highbd_subtract_block_sse2(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 #define aom_highbd_subtract_block aom_highbd_subtract_block_sse2
 
-void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
-void aom_highbd_upsampled_pred_sse2(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
+void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+void aom_highbd_upsampled_pred_sse2(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 #define aom_highbd_upsampled_pred aom_highbd_upsampled_pred_sse2
 
 void aom_highbd_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_16x16_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_16x16 aom_highbd_v_predictor_16x16_sse2
 
+void aom_highbd_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x32 aom_highbd_v_predictor_16x32_c
+
+void aom_highbd_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x8 aom_highbd_v_predictor_16x8_c
+
 void aom_highbd_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_2x2 aom_highbd_v_predictor_2x2_c
 
+void aom_highbd_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_32x16 aom_highbd_v_predictor_32x16_c
+
 void aom_highbd_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_32x32_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_32x32 aom_highbd_v_predictor_32x32_sse2
 
 void aom_highbd_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_4x4_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_4x4 aom_highbd_v_predictor_4x4_sse2
 
+void aom_highbd_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_4x8 aom_highbd_v_predictor_4x8_c
+
+void aom_highbd_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x16 aom_highbd_v_predictor_8x16_c
+
+void aom_highbd_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x4 aom_highbd_v_predictor_8x4_c
+
 void aom_highbd_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_8x8_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_8x8 aom_highbd_v_predictor_8x8_sse2
 
 void aom_idct16x16_10_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
 void aom_idct16x16_10_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
 void aom_idct16x16_10_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
 RTCD_EXTERN void (*aom_idct16x16_10_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
@@ -2176,120 +2446,16 @@ void aom_lpf_vertical_4_dual_sse2(uint8_
 void aom_lpf_vertical_8_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 void aom_lpf_vertical_8_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 #define aom_lpf_vertical_8 aom_lpf_vertical_8_sse2
 
 void aom_lpf_vertical_8_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 void aom_lpf_vertical_8_dual_sse2(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 #define aom_lpf_vertical_8_dual aom_lpf_vertical_8_dual_sse2
 
-unsigned int aom_masked_sad16x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad16x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad16x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x64_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x64)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad4x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad4x4_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad4x4)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad4x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad4x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad4x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad64x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad64x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad64x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad64x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad64x64_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad64x64)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x4_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x4)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 void aom_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 void aom_minmax_8x8_sse2(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 #define aom_minmax_8x8 aom_minmax_8x8_sse2
 
 unsigned int aom_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_mse16x16_avx2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -2447,25 +2613,43 @@ RTCD_EXTERN unsigned int (*aom_obmc_vari
 
 unsigned int aom_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 unsigned int aom_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 
 void aom_paeth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_16x16 aom_paeth_predictor_16x16_c
 
+void aom_paeth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x32 aom_paeth_predictor_16x32_c
+
+void aom_paeth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x8 aom_paeth_predictor_16x8_c
+
 void aom_paeth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_2x2 aom_paeth_predictor_2x2_c
 
+void aom_paeth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_32x16 aom_paeth_predictor_32x16_c
+
 void aom_paeth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_32x32 aom_paeth_predictor_32x32_c
 
 void aom_paeth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_4x4 aom_paeth_predictor_4x4_c
 
+void aom_paeth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_4x8 aom_paeth_predictor_4x8_c
+
+void aom_paeth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x16 aom_paeth_predictor_8x16_c
+
+void aom_paeth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x4 aom_paeth_predictor_8x4_c
+
 void aom_paeth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_8x8 aom_paeth_predictor_8x8_c
 
 void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_quantize_b_ssse3(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_quantize_b_avx(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 RTCD_EXTERN void (*aom_quantize_b)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
@@ -2726,31 +2910,115 @@ void aom_scaled_avg_vert_c(const uint8_t
 #define aom_scaled_avg_vert aom_scaled_avg_vert_c
 
 void aom_scaled_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_horiz aom_scaled_horiz_c
 
 void aom_scaled_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_vert aom_scaled_vert_c
 
+void aom_smooth_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x16 aom_smooth_h_predictor_16x16_c
+
+void aom_smooth_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x32 aom_smooth_h_predictor_16x32_c
+
+void aom_smooth_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x8 aom_smooth_h_predictor_16x8_c
+
+void aom_smooth_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_2x2 aom_smooth_h_predictor_2x2_c
+
+void aom_smooth_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x16 aom_smooth_h_predictor_32x16_c
+
+void aom_smooth_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x32 aom_smooth_h_predictor_32x32_c
+
+void aom_smooth_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x4 aom_smooth_h_predictor_4x4_c
+
+void aom_smooth_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x8 aom_smooth_h_predictor_4x8_c
+
+void aom_smooth_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x16 aom_smooth_h_predictor_8x16_c
+
+void aom_smooth_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x4 aom_smooth_h_predictor_8x4_c
+
+void aom_smooth_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x8 aom_smooth_h_predictor_8x8_c
+
 void aom_smooth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_16x16 aom_smooth_predictor_16x16_c
 
+void aom_smooth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x32 aom_smooth_predictor_16x32_c
+
+void aom_smooth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x8 aom_smooth_predictor_16x8_c
+
 void aom_smooth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_2x2 aom_smooth_predictor_2x2_c
 
+void aom_smooth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_32x16 aom_smooth_predictor_32x16_c
+
 void aom_smooth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_32x32 aom_smooth_predictor_32x32_c
 
 void aom_smooth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_4x4 aom_smooth_predictor_4x4_c
 
+void aom_smooth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_4x8 aom_smooth_predictor_4x8_c
+
+void aom_smooth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x16 aom_smooth_predictor_8x16_c
+
+void aom_smooth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x4 aom_smooth_predictor_8x4_c
+
 void aom_smooth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_8x8 aom_smooth_predictor_8x8_c
 
+void aom_smooth_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x16 aom_smooth_v_predictor_16x16_c
+
+void aom_smooth_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x32 aom_smooth_v_predictor_16x32_c
+
+void aom_smooth_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x8 aom_smooth_v_predictor_16x8_c
+
+void aom_smooth_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_2x2 aom_smooth_v_predictor_2x2_c
+
+void aom_smooth_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x16 aom_smooth_v_predictor_32x16_c
+
+void aom_smooth_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x32 aom_smooth_v_predictor_32x32_c
+
+void aom_smooth_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x4 aom_smooth_v_predictor_4x4_c
+
+void aom_smooth_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x8 aom_smooth_v_predictor_4x8_c
+
+void aom_smooth_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x16 aom_smooth_v_predictor_8x16_c
+
+void aom_smooth_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x4 aom_smooth_v_predictor_8x4_c
+
+void aom_smooth_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x8 aom_smooth_v_predictor_8x8_c
+
 uint32_t aom_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x16_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 
 uint32_t aom_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x32_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
@@ -2887,35 +3155,53 @@ void aom_subtract_block_sse2(int rows, i
 uint64_t aom_sum_squares_2d_i16_c(const int16_t *src, int stride, int width, int height);
 uint64_t aom_sum_squares_2d_i16_sse2(const int16_t *src, int stride, int width, int height);
 #define aom_sum_squares_2d_i16 aom_sum_squares_2d_i16_sse2
 
 uint64_t aom_sum_squares_i16_c(const int16_t *src, uint32_t N);
 uint64_t aom_sum_squares_i16_sse2(const int16_t *src, uint32_t N);
 #define aom_sum_squares_i16 aom_sum_squares_i16_sse2
 
-void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
-void aom_upsampled_pred_sse2(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_sse2(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 #define aom_upsampled_pred aom_upsampled_pred_sse2
 
 void aom_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_16x16 aom_v_predictor_16x16_sse2
 
+void aom_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x32 aom_v_predictor_16x32_c
+
+void aom_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x8 aom_v_predictor_16x8_c
+
 void aom_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_2x2 aom_v_predictor_2x2_c
 
+void aom_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_32x16 aom_v_predictor_32x16_c
+
 void aom_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_32x32 aom_v_predictor_32x32_sse2
 
 void aom_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_4x4 aom_v_predictor_4x4_sse2
 
+void aom_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_4x8 aom_v_predictor_4x8_c
+
+void aom_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x16 aom_v_predictor_8x16_c
+
+void aom_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x4 aom_v_predictor_8x4_c
+
 void aom_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_8x8 aom_v_predictor_8x8_sse2
 
 unsigned int aom_variance16x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 unsigned int aom_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 unsigned int aom_variance16x16_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_variance16x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
@@ -3033,56 +3319,26 @@ static void setup_rtcd_internal(void)
     aom_d153_predictor_32x32 = aom_d153_predictor_32x32_c;
     if (flags & HAS_SSSE3) aom_d153_predictor_32x32 = aom_d153_predictor_32x32_ssse3;
     aom_d153_predictor_4x4 = aom_d153_predictor_4x4_c;
     if (flags & HAS_SSSE3) aom_d153_predictor_4x4 = aom_d153_predictor_4x4_ssse3;
     aom_d153_predictor_8x8 = aom_d153_predictor_8x8_c;
     if (flags & HAS_SSSE3) aom_d153_predictor_8x8 = aom_d153_predictor_8x8_ssse3;
     aom_d63e_predictor_4x4 = aom_d63e_predictor_4x4_c;
     if (flags & HAS_SSSE3) aom_d63e_predictor_4x4 = aom_d63e_predictor_4x4_ssse3;
-    aom_fdct16x16_1 = aom_fdct16x16_1_sse2;
-    if (flags & HAS_AVX2) aom_fdct16x16_1 = aom_fdct16x16_1_avx2;
     aom_fdct32x32 = aom_fdct32x32_sse2;
     if (flags & HAS_AVX2) aom_fdct32x32 = aom_fdct32x32_avx2;
-    aom_fdct32x32_1 = aom_fdct32x32_1_sse2;
-    if (flags & HAS_AVX2) aom_fdct32x32_1 = aom_fdct32x32_1_avx2;
     aom_fdct32x32_rd = aom_fdct32x32_rd_sse2;
     if (flags & HAS_AVX2) aom_fdct32x32_rd = aom_fdct32x32_rd_avx2;
     aom_fdct8x8 = aom_fdct8x8_sse2;
     if (flags & HAS_SSSE3) aom_fdct8x8 = aom_fdct8x8_ssse3;
     aom_get16x16var = aom_get16x16var_sse2;
     if (flags & HAS_AVX2) aom_get16x16var = aom_get16x16var_avx2;
     aom_hadamard_8x8 = aom_hadamard_8x8_sse2;
     if (flags & HAS_SSSE3) aom_hadamard_8x8 = aom_hadamard_8x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x16 = aom_highbd_10_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x16 = aom_highbd_10_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x32 = aom_highbd_10_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x32 = aom_highbd_10_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x8 = aom_highbd_10_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x8 = aom_highbd_10_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x16 = aom_highbd_10_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x16 = aom_highbd_10_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x32 = aom_highbd_10_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x32 = aom_highbd_10_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x64 = aom_highbd_10_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x64 = aom_highbd_10_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance4x4 = aom_highbd_10_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance4x4 = aom_highbd_10_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance4x8 = aom_highbd_10_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance4x8 = aom_highbd_10_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance64x32 = aom_highbd_10_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance64x32 = aom_highbd_10_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance64x64 = aom_highbd_10_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance64x64 = aom_highbd_10_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x16 = aom_highbd_10_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x16 = aom_highbd_10_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x4 = aom_highbd_10_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x4 = aom_highbd_10_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x8 = aom_highbd_10_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x8 = aom_highbd_10_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_10_obmc_variance16x16 = aom_highbd_10_obmc_variance16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x16 = aom_highbd_10_obmc_variance16x16_sse4_1;
     aom_highbd_10_obmc_variance16x32 = aom_highbd_10_obmc_variance16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x32 = aom_highbd_10_obmc_variance16x32_sse4_1;
     aom_highbd_10_obmc_variance16x8 = aom_highbd_10_obmc_variance16x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x8 = aom_highbd_10_obmc_variance16x8_sse4_1;
     aom_highbd_10_obmc_variance32x16 = aom_highbd_10_obmc_variance32x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance32x16 = aom_highbd_10_obmc_variance32x16_sse4_1;
@@ -3105,42 +3361,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_10_obmc_variance8x8 = aom_highbd_10_obmc_variance8x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance8x8 = aom_highbd_10_obmc_variance8x8_sse4_1;
     aom_highbd_10_sub_pixel_avg_variance4x4 = aom_highbd_10_sub_pixel_avg_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_sub_pixel_avg_variance4x4 = aom_highbd_10_sub_pixel_avg_variance4x4_sse4_1;
     aom_highbd_10_sub_pixel_variance4x4 = aom_highbd_10_sub_pixel_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_sub_pixel_variance4x4 = aom_highbd_10_sub_pixel_variance4x4_sse4_1;
     aom_highbd_10_variance4x4 = aom_highbd_10_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_variance4x4 = aom_highbd_10_variance4x4_sse4_1;
-    aom_highbd_12_masked_sub_pixel_variance16x16 = aom_highbd_12_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x16 = aom_highbd_12_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance16x32 = aom_highbd_12_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x32 = aom_highbd_12_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance16x8 = aom_highbd_12_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x8 = aom_highbd_12_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x16 = aom_highbd_12_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x16 = aom_highbd_12_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x32 = aom_highbd_12_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x32 = aom_highbd_12_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x64 = aom_highbd_12_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x64 = aom_highbd_12_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance4x4 = aom_highbd_12_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance4x4 = aom_highbd_12_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance4x8 = aom_highbd_12_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance4x8 = aom_highbd_12_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance64x32 = aom_highbd_12_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance64x32 = aom_highbd_12_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance64x64 = aom_highbd_12_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance64x64 = aom_highbd_12_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x16 = aom_highbd_12_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x16 = aom_highbd_12_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x4 = aom_highbd_12_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x4 = aom_highbd_12_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x8 = aom_highbd_12_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x8 = aom_highbd_12_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_12_obmc_variance16x16 = aom_highbd_12_obmc_variance16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x16 = aom_highbd_12_obmc_variance16x16_sse4_1;
     aom_highbd_12_obmc_variance16x32 = aom_highbd_12_obmc_variance16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x32 = aom_highbd_12_obmc_variance16x32_sse4_1;
     aom_highbd_12_obmc_variance16x8 = aom_highbd_12_obmc_variance16x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x8 = aom_highbd_12_obmc_variance16x8_sse4_1;
     aom_highbd_12_obmc_variance32x16 = aom_highbd_12_obmc_variance32x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance32x16 = aom_highbd_12_obmc_variance32x16_sse4_1;
@@ -3163,42 +3393,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_12_obmc_variance8x8 = aom_highbd_12_obmc_variance8x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance8x8 = aom_highbd_12_obmc_variance8x8_sse4_1;
     aom_highbd_12_sub_pixel_avg_variance4x4 = aom_highbd_12_sub_pixel_avg_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_sub_pixel_avg_variance4x4 = aom_highbd_12_sub_pixel_avg_variance4x4_sse4_1;
     aom_highbd_12_sub_pixel_variance4x4 = aom_highbd_12_sub_pixel_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_sub_pixel_variance4x4 = aom_highbd_12_sub_pixel_variance4x4_sse4_1;
     aom_highbd_12_variance4x4 = aom_highbd_12_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_variance4x4 = aom_highbd_12_variance4x4_sse4_1;
-    aom_highbd_8_masked_sub_pixel_variance16x16 = aom_highbd_8_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x16 = aom_highbd_8_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance16x32 = aom_highbd_8_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x32 = aom_highbd_8_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance16x8 = aom_highbd_8_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x8 = aom_highbd_8_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x16 = aom_highbd_8_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x16 = aom_highbd_8_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x32 = aom_highbd_8_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x32 = aom_highbd_8_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x64 = aom_highbd_8_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x64 = aom_highbd_8_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance4x4 = aom_highbd_8_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance4x4 = aom_highbd_8_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance4x8 = aom_highbd_8_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance4x8 = aom_highbd_8_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance64x32 = aom_highbd_8_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance64x32 = aom_highbd_8_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance64x64 = aom_highbd_8_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance64x64 = aom_highbd_8_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x16 = aom_highbd_8_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x16 = aom_highbd_8_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x4 = aom_highbd_8_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x4 = aom_highbd_8_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x8 = aom_highbd_8_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x8 = aom_highbd_8_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_8_sub_pixel_avg_variance4x4 = aom_highbd_8_sub_pixel_avg_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_8_sub_pixel_avg_variance4x4 = aom_highbd_8_sub_pixel_avg_variance4x4_sse4_1;
     aom_highbd_8_sub_pixel_variance4x4 = aom_highbd_8_sub_pixel_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_8_sub_pixel_variance4x4 = aom_highbd_8_sub_pixel_variance4x4_sse4_1;
     aom_highbd_8_variance4x4 = aom_highbd_8_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_8_variance4x4 = aom_highbd_8_variance4x4_sse4_1;
     aom_highbd_blend_a64_hmask = aom_highbd_blend_a64_hmask_c;
     if (flags & HAS_SSE4_1) aom_highbd_blend_a64_hmask = aom_highbd_blend_a64_hmask_sse4_1;
@@ -3217,42 +3421,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_convolve8_horiz = aom_highbd_convolve8_horiz_sse2;
     if (flags & HAS_AVX2) aom_highbd_convolve8_horiz = aom_highbd_convolve8_horiz_avx2;
     aom_highbd_convolve8_vert = aom_highbd_convolve8_vert_sse2;
     if (flags & HAS_AVX2) aom_highbd_convolve8_vert = aom_highbd_convolve8_vert_avx2;
     aom_highbd_convolve_avg = aom_highbd_convolve_avg_sse2;
     if (flags & HAS_AVX2) aom_highbd_convolve_avg = aom_highbd_convolve_avg_avx2;
     aom_highbd_convolve_copy = aom_highbd_convolve_copy_sse2;
     if (flags & HAS_AVX2) aom_highbd_convolve_copy = aom_highbd_convolve_copy_avx2;
-    aom_highbd_masked_sad16x16 = aom_highbd_masked_sad16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x16 = aom_highbd_masked_sad16x16_ssse3;
-    aom_highbd_masked_sad16x32 = aom_highbd_masked_sad16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x32 = aom_highbd_masked_sad16x32_ssse3;
-    aom_highbd_masked_sad16x8 = aom_highbd_masked_sad16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x8 = aom_highbd_masked_sad16x8_ssse3;
-    aom_highbd_masked_sad32x16 = aom_highbd_masked_sad32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x16 = aom_highbd_masked_sad32x16_ssse3;
-    aom_highbd_masked_sad32x32 = aom_highbd_masked_sad32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x32 = aom_highbd_masked_sad32x32_ssse3;
-    aom_highbd_masked_sad32x64 = aom_highbd_masked_sad32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x64 = aom_highbd_masked_sad32x64_ssse3;
-    aom_highbd_masked_sad4x4 = aom_highbd_masked_sad4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad4x4 = aom_highbd_masked_sad4x4_ssse3;
-    aom_highbd_masked_sad4x8 = aom_highbd_masked_sad4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad4x8 = aom_highbd_masked_sad4x8_ssse3;
-    aom_highbd_masked_sad64x32 = aom_highbd_masked_sad64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad64x32 = aom_highbd_masked_sad64x32_ssse3;
-    aom_highbd_masked_sad64x64 = aom_highbd_masked_sad64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad64x64 = aom_highbd_masked_sad64x64_ssse3;
-    aom_highbd_masked_sad8x16 = aom_highbd_masked_sad8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x16 = aom_highbd_masked_sad8x16_ssse3;
-    aom_highbd_masked_sad8x4 = aom_highbd_masked_sad8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x4 = aom_highbd_masked_sad8x4_ssse3;
-    aom_highbd_masked_sad8x8 = aom_highbd_masked_sad8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x8 = aom_highbd_masked_sad8x8_ssse3;
     aom_highbd_obmc_sad16x16 = aom_highbd_obmc_sad16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x16 = aom_highbd_obmc_sad16x16_sse4_1;
     aom_highbd_obmc_sad16x32 = aom_highbd_obmc_sad16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x32 = aom_highbd_obmc_sad16x32_sse4_1;
     aom_highbd_obmc_sad16x8 = aom_highbd_obmc_sad16x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x8 = aom_highbd_obmc_sad16x8_sse4_1;
     aom_highbd_obmc_sad32x16 = aom_highbd_obmc_sad32x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad32x16 = aom_highbd_obmc_sad32x16_sse4_1;
@@ -3295,16 +3473,18 @@ static void setup_rtcd_internal(void)
     aom_highbd_obmc_variance64x64 = aom_highbd_obmc_variance64x64_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance64x64 = aom_highbd_obmc_variance64x64_sse4_1;
     aom_highbd_obmc_variance8x16 = aom_highbd_obmc_variance8x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x16 = aom_highbd_obmc_variance8x16_sse4_1;
     aom_highbd_obmc_variance8x4 = aom_highbd_obmc_variance8x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x4 = aom_highbd_obmc_variance8x4_sse4_1;
     aom_highbd_obmc_variance8x8 = aom_highbd_obmc_variance8x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x8 = aom_highbd_obmc_variance8x8_sse4_1;
+    aom_highbd_quantize_b = aom_highbd_quantize_b_sse2;
+    if (flags & HAS_AVX2) aom_highbd_quantize_b = aom_highbd_quantize_b_avx2;
     aom_highbd_sad16x16 = aom_highbd_sad16x16_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16 = aom_highbd_sad16x16_avx2;
     aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_avx2;
     aom_highbd_sad16x16x4d = aom_highbd_sad16x16x4d_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16x4d = aom_highbd_sad16x16x4d_avx2;
     aom_highbd_sad16x32 = aom_highbd_sad16x32_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x32 = aom_highbd_sad16x32_avx2;
@@ -3370,68 +3550,16 @@ static void setup_rtcd_internal(void)
     aom_idct8x8_12_add = aom_idct8x8_12_add_sse2;
     if (flags & HAS_SSSE3) aom_idct8x8_12_add = aom_idct8x8_12_add_ssse3;
     aom_idct8x8_64_add = aom_idct8x8_64_add_sse2;
     if (flags & HAS_SSSE3) aom_idct8x8_64_add = aom_idct8x8_64_add_ssse3;
     aom_lpf_horizontal_edge_16 = aom_lpf_horizontal_edge_16_sse2;
     if (flags & HAS_AVX2) aom_lpf_horizontal_edge_16 = aom_lpf_horizontal_edge_16_avx2;
     aom_lpf_horizontal_edge_8 = aom_lpf_horizontal_edge_8_sse2;
     if (flags & HAS_AVX2) aom_lpf_horizontal_edge_8 = aom_lpf_horizontal_edge_8_avx2;
-    aom_masked_sad16x16 = aom_masked_sad16x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x16 = aom_masked_sad16x16_ssse3;
-    aom_masked_sad16x32 = aom_masked_sad16x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x32 = aom_masked_sad16x32_ssse3;
-    aom_masked_sad16x8 = aom_masked_sad16x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x8 = aom_masked_sad16x8_ssse3;
-    aom_masked_sad32x16 = aom_masked_sad32x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x16 = aom_masked_sad32x16_ssse3;
-    aom_masked_sad32x32 = aom_masked_sad32x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x32 = aom_masked_sad32x32_ssse3;
-    aom_masked_sad32x64 = aom_masked_sad32x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x64 = aom_masked_sad32x64_ssse3;
-    aom_masked_sad4x4 = aom_masked_sad4x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sad4x4 = aom_masked_sad4x4_ssse3;
-    aom_masked_sad4x8 = aom_masked_sad4x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad4x8 = aom_masked_sad4x8_ssse3;
-    aom_masked_sad64x32 = aom_masked_sad64x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad64x32 = aom_masked_sad64x32_ssse3;
-    aom_masked_sad64x64 = aom_masked_sad64x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sad64x64 = aom_masked_sad64x64_ssse3;
-    aom_masked_sad8x16 = aom_masked_sad8x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x16 = aom_masked_sad8x16_ssse3;
-    aom_masked_sad8x4 = aom_masked_sad8x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x4 = aom_masked_sad8x4_ssse3;
-    aom_masked_sad8x8 = aom_masked_sad8x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x8 = aom_masked_sad8x8_ssse3;
-    aom_masked_sub_pixel_variance16x16 = aom_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x16 = aom_masked_sub_pixel_variance16x16_ssse3;
-    aom_masked_sub_pixel_variance16x32 = aom_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x32 = aom_masked_sub_pixel_variance16x32_ssse3;
-    aom_masked_sub_pixel_variance16x8 = aom_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x8 = aom_masked_sub_pixel_variance16x8_ssse3;
-    aom_masked_sub_pixel_variance32x16 = aom_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x16 = aom_masked_sub_pixel_variance32x16_ssse3;
-    aom_masked_sub_pixel_variance32x32 = aom_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x32 = aom_masked_sub_pixel_variance32x32_ssse3;
-    aom_masked_sub_pixel_variance32x64 = aom_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x64 = aom_masked_sub_pixel_variance32x64_ssse3;
-    aom_masked_sub_pixel_variance4x4 = aom_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance4x4 = aom_masked_sub_pixel_variance4x4_ssse3;
-    aom_masked_sub_pixel_variance4x8 = aom_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance4x8 = aom_masked_sub_pixel_variance4x8_ssse3;
-    aom_masked_sub_pixel_variance64x32 = aom_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance64x32 = aom_masked_sub_pixel_variance64x32_ssse3;
-    aom_masked_sub_pixel_variance64x64 = aom_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance64x64 = aom_masked_sub_pixel_variance64x64_ssse3;
-    aom_masked_sub_pixel_variance8x16 = aom_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x16 = aom_masked_sub_pixel_variance8x16_ssse3;
-    aom_masked_sub_pixel_variance8x4 = aom_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x4 = aom_masked_sub_pixel_variance8x4_ssse3;
-    aom_masked_sub_pixel_variance8x8 = aom_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x8 = aom_masked_sub_pixel_variance8x8_ssse3;
     aom_mse16x16 = aom_mse16x16_sse2;
     if (flags & HAS_AVX2) aom_mse16x16 = aom_mse16x16_avx2;
     aom_obmc_sad16x16 = aom_obmc_sad16x16_c;
     if (flags & HAS_SSE4_1) aom_obmc_sad16x16 = aom_obmc_sad16x16_sse4_1;
     aom_obmc_sad16x32 = aom_obmc_sad16x32_c;
     if (flags & HAS_SSE4_1) aom_obmc_sad16x32 = aom_obmc_sad16x32_sse4_1;
     aom_obmc_sad16x8 = aom_obmc_sad16x8_c;
     if (flags & HAS_SSE4_1) aom_obmc_sad16x8 = aom_obmc_sad16x8_sse4_1;
--- a/media/libaom/config/mac/x64/av1_rtcd.h
+++ b/media/libaom/config/mac/x64/av1_rtcd.h
@@ -13,22 +13,25 @@
 
 #include "aom/aom_integer.h"
 #include "av1/common/common.h"
 #include "av1/common/enums.h"
 #include "av1/common/quant_common.h"
 #include "av1/common/filter.h"
 #include "av1/common/convolve.h"
 #include "av1/common/av1_txfm.h"
+#include "av1/common/idct.h"
 #include "av1/common/odintrin.h"
 
 struct macroblockd;
 
 /* Encoder forward decls */
 struct macroblock;
+struct fwd_txfm_param;
+struct inv_txfm_param;
 struct aom_variance_vtable;
 struct search_site_config;
 struct mv;
 union int_mv;
 struct yv12_buffer_config;
 typedef uint16_t od_dering_in;
 
 #ifdef __cplusplus
@@ -55,84 +58,85 @@ RTCD_EXTERN void (*aom_clpf_hblock)(uint
 
 void aom_clpf_hblock_hbd_c(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_sse2(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_ssse3(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_sse4_1(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 RTCD_EXTERN void (*aom_clpf_hblock_hbd)(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 
 int64_t av1_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
-#define av1_block_error av1_block_error_c
+int64_t av1_block_error_avx2(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
+RTCD_EXTERN int64_t (*av1_block_error)(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
 
 void av1_convolve_horiz_c(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 void av1_convolve_horiz_ssse3(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 RTCD_EXTERN void (*av1_convolve_horiz)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 
 void av1_convolve_vert_c(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 void av1_convolve_vert_ssse3(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 RTCD_EXTERN void (*av1_convolve_vert)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 
 int av1_diamond_search_sad_c(struct macroblock *x, const struct search_site_config *cfg,  struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_diamond_search_sad av1_diamond_search_sad_c
 
 void av1_fdct8x8_quant_c(const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define av1_fdct8x8_quant av1_fdct8x8_quant_c
 
-void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x16_avx2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht16x16)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x16_avx2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht16x16)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x32_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x32_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x32 av1_fht16x32_sse2
 
-void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x4 av1_fht16x4_c
 
-void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x8 av1_fht16x8_sse2
 
-void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x16 av1_fht32x16_sse2
 
-void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x32_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x32_avx2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht32x32)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x32_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x32_avx2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht32x32)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x8 av1_fht32x8_c
 
-void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x16 av1_fht4x16_c
 
-void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x4 av1_fht4x4_sse2
 
-void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht4x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht4x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x8 av1_fht4x8_sse2
 
-void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x16 av1_fht8x16_sse2
 
-void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x32 av1_fht8x32_c
 
-void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x4_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x4_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x4 av1_fht8x4_sse2
 
-void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x8 av1_fht8x8_sse2
 
 int av1_full_range_search_c(const struct macroblock *x, const struct search_site_config *cfg, struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_full_range_search av1_full_range_search_c
 
 int av1_full_search_sad_c(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 int av1_full_search_sadx3(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 int av1_full_search_sadx8(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
@@ -140,28 +144,46 @@ RTCD_EXTERN int (*av1_full_search_sad)(c
 
 void av1_fwd_idtx_c(const int16_t *src_diff, tran_low_t *coeff, int stride, int bs, int tx_type);
 #define av1_fwd_idtx av1_fwd_idtx_c
 
 void av1_fwd_txfm2d_16x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_16x16_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_16x16)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_16x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x32 av1_fwd_txfm2d_16x32_c
+
+void av1_fwd_txfm2d_16x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x8 av1_fwd_txfm2d_16x8_c
+
+void av1_fwd_txfm2d_32x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_32x16 av1_fwd_txfm2d_32x16_c
+
 void av1_fwd_txfm2d_32x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_32x32_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_32x32)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
 void av1_fwd_txfm2d_4x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_4x4_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_4x4)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_4x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_4x8 av1_fwd_txfm2d_4x8_c
+
 void av1_fwd_txfm2d_64x64_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_64x64_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_64x64)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_8x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x16 av1_fwd_txfm2d_8x16_c
+
+void av1_fwd_txfm2d_8x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x4 av1_fwd_txfm2d_8x4_c
+
 void av1_fwd_txfm2d_8x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_8x8_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_8x8)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
 void av1_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_fwht4x4 av1_fwht4x4_c
 
 int64_t av1_highbd_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd);
@@ -205,225 +227,178 @@ RTCD_EXTERN void (*av1_highbd_convolve_h
 void av1_highbd_convolve_init_c(void);
 void av1_highbd_convolve_init_sse4_1(void);
 RTCD_EXTERN void (*av1_highbd_convolve_init)(void);
 
 void av1_highbd_convolve_vert_c(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 void av1_highbd_convolve_vert_sse4_1(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 RTCD_EXTERN void (*av1_highbd_convolve_vert)(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 
-void av1_highbd_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x16 av1_highbd_fht16x16_c
-
-void av1_highbd_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x32 av1_highbd_fht16x32_c
-
-void av1_highbd_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x4 av1_highbd_fht16x4_c
-
-void av1_highbd_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x8 av1_highbd_fht16x8_c
-
-void av1_highbd_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x16 av1_highbd_fht32x16_c
-
-void av1_highbd_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x32 av1_highbd_fht32x32_c
-
-void av1_highbd_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x8 av1_highbd_fht32x8_c
-
-void av1_highbd_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x16 av1_highbd_fht4x16_c
-
-void av1_highbd_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_highbd_fht4x4_sse4_1(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_highbd_fht4x4)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-
-void av1_highbd_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x8 av1_highbd_fht4x8_c
-
-void av1_highbd_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x16 av1_highbd_fht8x16_c
-
-void av1_highbd_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x32 av1_highbd_fht8x32_c
-
-void av1_highbd_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x4 av1_highbd_fht8x4_c
-
-void av1_highbd_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x8 av1_highbd_fht8x8_c
-
 void av1_highbd_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_highbd_fwht4x4 av1_highbd_fwht4x4_c
 
-void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type, int bd);
+void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x16_256_add av1_highbd_iht16x16_256_add_c
 
-void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x32_512_add av1_highbd_iht16x32_512_add_c
 
-void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x4_64_add av1_highbd_iht16x4_64_add_c
 
-void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x8_128_add av1_highbd_iht16x8_128_add_c
 
-void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x16_512_add av1_highbd_iht32x16_512_add_c
 
-void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x8_256_add av1_highbd_iht32x8_256_add_c
 
-void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x16_64_add av1_highbd_iht4x16_64_add_c
 
-void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x4_16_add av1_highbd_iht4x4_16_add_c
 
-void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x8_32_add av1_highbd_iht4x8_32_add_c
 
-void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x16_128_add av1_highbd_iht8x16_128_add_c
 
-void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x32_256_add av1_highbd_iht8x32_256_add_c
 
-void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x4_32_add av1_highbd_iht8x4_32_add_c
 
-void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x8_64_add av1_highbd_iht8x8_64_add_c
 
 void av1_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_highbd_quantize_b av1_highbd_quantize_b_c
 
 void av1_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 void av1_highbd_quantize_fp_sse4_1(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
+void av1_highbd_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 RTCD_EXTERN void (*av1_highbd_quantize_fp)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 
 void av1_highbd_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 #define av1_highbd_temporal_filter_apply av1_highbd_temporal_filter_apply_c
 
-void av1_highbd_warp_affine_c(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_highbd_warp_affine_ssse3(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-RTCD_EXTERN void (*av1_highbd_warp_affine)(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
+void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+void av1_iht16x16_256_add_sse2(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+void av1_iht16x16_256_add_avx2(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht16x16_256_add)(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 
-void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-void av1_iht16x16_256_add_sse2(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-void av1_iht16x16_256_add_avx2(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-RTCD_EXTERN void (*av1_iht16x16_256_add)(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-
-void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht16x32_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht16x32_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x32_512_add av1_iht16x32_512_add_sse2
 
-void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x4_64_add av1_iht16x4_64_add_c
 
-void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht16x8_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht16x8_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x8_128_add av1_iht16x8_128_add_sse2
 
-void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht32x16_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht32x16_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht32x16_512_add av1_iht32x16_512_add_sse2
 
-void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
+void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_iht32x32_1024_add av1_iht32x32_1024_add_c
 
-void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht32x8_256_add av1_iht32x8_256_add_c
 
-void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x16_64_add av1_iht4x16_64_add_c
 
-void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x4_16_add av1_iht4x4_16_add_sse2
 
-void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht4x8_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht4x8_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x8_32_add av1_iht4x8_32_add_sse2
 
-void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x16_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x16_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x16_128_add av1_iht8x16_128_add_sse2
 
-void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x32_256_add av1_iht8x32_256_add_c
 
-void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x4_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x4_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x4_32_add av1_iht8x4_32_add_sse2
 
-void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x8_64_add av1_iht8x8_64_add_sse2
 
 void av1_inv_txfm2d_add_16x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_16x16_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_16x16)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
+void av1_inv_txfm2d_add_16x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x32 av1_inv_txfm2d_add_16x32_c
+
+void av1_inv_txfm2d_add_16x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x8 av1_inv_txfm2d_add_16x8_c
+
+void av1_inv_txfm2d_add_32x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_32x16 av1_inv_txfm2d_add_32x16_c
+
 void av1_inv_txfm2d_add_32x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_32x32_avx2(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_32x32)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
 void av1_inv_txfm2d_add_4x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_4x4_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_4x4)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
+void av1_inv_txfm2d_add_4x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_4x8 av1_inv_txfm2d_add_4x8_c
+
 void av1_inv_txfm2d_add_64x64_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_64x64 av1_inv_txfm2d_add_64x64_c
 
+void av1_inv_txfm2d_add_8x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x16 av1_inv_txfm2d_add_8x16_c
+
+void av1_inv_txfm2d_add_8x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x4 av1_inv_txfm2d_add_8x4_c
+
 void av1_inv_txfm2d_add_8x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_8x8_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_8x8)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
 void av1_lowbd_convolve_init_c(void);
 void av1_lowbd_convolve_init_ssse3(void);
 RTCD_EXTERN void (*av1_lowbd_convolve_init)(void);
 
 void av1_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_quantize_b av1_quantize_b_c
 
 void av1_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void av1_quantize_fp_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
-#define av1_quantize_fp av1_quantize_fp_sse2
+void av1_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*av1_quantize_fp)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void av1_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
-#define av1_quantize_fp_32x32 av1_quantize_fp_32x32_c
+void av1_quantize_fp_32x32_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*av1_quantize_fp_32x32)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void av1_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 void av1_temporal_filter_apply_sse2(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 #define av1_temporal_filter_apply av1_temporal_filter_apply_sse2
 
-void av1_warp_affine_c(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_warp_affine_sse2(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_warp_affine_ssse3(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-RTCD_EXTERN void (*av1_warp_affine)(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-
-void av1_wedge_compute_delta_squares_c(int16_t *d, const int16_t *a, const int16_t *b, int N);
-void av1_wedge_compute_delta_squares_sse2(int16_t *d, const int16_t *a, const int16_t *b, int N);
-#define av1_wedge_compute_delta_squares av1_wedge_compute_delta_squares_sse2
-
-int av1_wedge_sign_from_residuals_c(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-int av1_wedge_sign_from_residuals_sse2(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-#define av1_wedge_sign_from_residuals av1_wedge_sign_from_residuals_sse2
-
-uint64_t av1_wedge_sse_from_residuals_c(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-uint64_t av1_wedge_sse_from_residuals_sse2(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-#define av1_wedge_sse_from_residuals av1_wedge_sse_from_residuals_sse2
-
-double compute_cross_correlation_c(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-double compute_cross_correlation_sse4_1(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-RTCD_EXTERN double (*compute_cross_correlation)(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-
 void copy_4x4_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_sse2(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_ssse3(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_sse4_1(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 RTCD_EXTERN void (*copy_4x4_16bit_to_16bit)(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 
 void copy_4x4_16bit_to_8bit_c(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_8bit_sse2(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
@@ -490,16 +465,18 @@ static void setup_rtcd_internal(void)
     if (flags & HAS_SSSE3) aom_clpf_block_hbd = aom_clpf_block_hbd_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_block_hbd = aom_clpf_block_hbd_sse4_1;
     aom_clpf_hblock = aom_clpf_hblock_sse2;
     if (flags & HAS_SSSE3) aom_clpf_hblock = aom_clpf_hblock_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_hblock = aom_clpf_hblock_sse4_1;
     aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_sse2;
     if (flags & HAS_SSSE3) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_sse4_1;
+    av1_block_error = av1_block_error_c;
+    if (flags & HAS_AVX2) av1_block_error = av1_block_error_avx2;
     av1_convolve_horiz = av1_convolve_horiz_c;
     if (flags & HAS_SSSE3) av1_convolve_horiz = av1_convolve_horiz_ssse3;
     av1_convolve_vert = av1_convolve_vert_c;
     if (flags & HAS_SSSE3) av1_convolve_vert = av1_convolve_vert_ssse3;
     av1_fht16x16 = av1_fht16x16_sse2;
     if (flags & HAS_AVX2) av1_fht16x16 = av1_fht16x16_avx2;
     av1_fht32x32 = av1_fht32x32_sse2;
     if (flags & HAS_AVX2) av1_fht32x32 = av1_fht32x32_avx2;
@@ -517,38 +494,35 @@ static void setup_rtcd_internal(void)
     av1_fwd_txfm2d_8x8 = av1_fwd_txfm2d_8x8_c;
     if (flags & HAS_SSE4_1) av1_fwd_txfm2d_8x8 = av1_fwd_txfm2d_8x8_sse4_1;
     av1_highbd_convolve_horiz = av1_highbd_convolve_horiz_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_horiz = av1_highbd_convolve_horiz_sse4_1;
     av1_highbd_convolve_init = av1_highbd_convolve_init_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_init = av1_highbd_convolve_init_sse4_1;
     av1_highbd_convolve_vert = av1_highbd_convolve_vert_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_vert = av1_highbd_convolve_vert_sse4_1;
-    av1_highbd_fht4x4 = av1_highbd_fht4x4_c;
-    if (flags & HAS_SSE4_1) av1_highbd_fht4x4 = av1_highbd_fht4x4_sse4_1;
     av1_highbd_quantize_fp = av1_highbd_quantize_fp_c;
     if (flags & HAS_SSE4_1) av1_highbd_quantize_fp = av1_highbd_quantize_fp_sse4_1;
-    av1_highbd_warp_affine = av1_highbd_warp_affine_c;
-    if (flags & HAS_SSSE3) av1_highbd_warp_affine = av1_highbd_warp_affine_ssse3;
+    if (flags & HAS_AVX2) av1_highbd_quantize_fp = av1_highbd_quantize_fp_avx2;
     av1_iht16x16_256_add = av1_iht16x16_256_add_sse2;
     if (flags & HAS_AVX2) av1_iht16x16_256_add = av1_iht16x16_256_add_avx2;
     av1_inv_txfm2d_add_16x16 = av1_inv_txfm2d_add_16x16_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_16x16 = av1_inv_txfm2d_add_16x16_sse4_1;
     av1_inv_txfm2d_add_32x32 = av1_inv_txfm2d_add_32x32_c;
     if (flags & HAS_AVX2) av1_inv_txfm2d_add_32x32 = av1_inv_txfm2d_add_32x32_avx2;
     av1_inv_txfm2d_add_4x4 = av1_inv_txfm2d_add_4x4_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_4x4 = av1_inv_txfm2d_add_4x4_sse4_1;
     av1_inv_txfm2d_add_8x8 = av1_inv_txfm2d_add_8x8_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_8x8 = av1_inv_txfm2d_add_8x8_sse4_1;
     av1_lowbd_convolve_init = av1_lowbd_convolve_init_c;
     if (flags & HAS_SSSE3) av1_lowbd_convolve_init = av1_lowbd_convolve_init_ssse3;
-    av1_warp_affine = av1_warp_affine_sse2;
-    if (flags & HAS_SSSE3) av1_warp_affine = av1_warp_affine_ssse3;
-    compute_cross_correlation = compute_cross_correlation_c;
-    if (flags & HAS_SSE4_1) compute_cross_correlation = compute_cross_correlation_sse4_1;
+    av1_quantize_fp = av1_quantize_fp_sse2;
+    if (flags & HAS_AVX2) av1_quantize_fp = av1_quantize_fp_avx2;
+    av1_quantize_fp_32x32 = av1_quantize_fp_32x32_c;
+    if (flags & HAS_AVX2) av1_quantize_fp_32x32 = av1_quantize_fp_32x32_avx2;
     copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_sse2;
     if (flags & HAS_SSSE3) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_ssse3;
     if (flags & HAS_SSE4_1) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_sse4_1;
     copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_sse2;
     if (flags & HAS_SSSE3) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_ssse3;
     if (flags & HAS_SSE4_1) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_sse4_1;
     copy_8x8_16bit_to_16bit = copy_8x8_16bit_to_16bit_sse2;
     if (flags & HAS_SSSE3) copy_8x8_16bit_to_16bit = copy_8x8_16bit_to_16bit_ssse3;
--- a/media/libaom/config/win/ia32/aom_config.asm
+++ b/media/libaom/config/win/ia32/aom_config.asm
@@ -60,60 +60,63 @@
 %define CONFIG_INSPECTION 0
 %define CONFIG_DECODE_PERF_TESTS 0
 %define CONFIG_ENCODE_PERF_TESTS 0
 %define CONFIG_COEFFICIENT_RANGE_CHECKING 0
 %define CONFIG_LOWBITDEPTH 1
 %define CONFIG_HIGHBITDEPTH 1
 %define CONFIG_EXPERIMENTAL 0
 %define CONFIG_SIZE_LIMIT 1
+%define CONFIG_COLORSPACE_HEADERS 0
 %define CONFIG_FP_MB_STATS 0
 %define CONFIG_CDEF 1
 %define CONFIG_VAR_TX 1
 %define CONFIG_RECT_TX 1
 %define CONFIG_RECT_TX_EXT 0
 %define CONFIG_TPL_MV 0
-%define CONFIG_DUAL_FILTER 1
+%define CONFIG_DUAL_FILTER 0
 %define CONFIG_CONVOLVE_ROUND 0
 %define CONFIG_COMPOUND_ROUND 0
-%define CONFIG_EXT_TX 1
+%define CONFIG_EXT_TX 0
 %define CONFIG_DPCM_INTRA 0
 %define CONFIG_TX64X64 0
 %define CONFIG_EXT_INTRA 1
 %define CONFIG_INTRA_INTERP 0
 %define CONFIG_FILTER_INTRA 0
 %define CONFIG_INTRA_EDGE 0
 %define CONFIG_INTRABC 0
-%define CONFIG_EXT_INTER 1
-%define CONFIG_INTERINTRA 1
-%define CONFIG_WEDGE 1
-%define CONFIG_COMPOUND_SEGMENT 1
-%define CONFIG_EXT_REFS 1
-%define CONFIG_GLOBAL_MOTION 1
+%define CONFIG_EXT_INTER 0
+%define CONFIG_INTERINTRA 0
+%define CONFIG_WEDGE 0
+%define CONFIG_COMPOUND_SEGMENT 0
+%define CONFIG_EXT_REFS 0
+%define CONFIG_SPEED_REFS 0
+%define CONFIG_GF_GROUPS 0
+%define CONFIG_GLOBAL_MOTION 0
 %define CONFIG_NEW_QUANT 0
 %define CONFIG_SUPERTX 0
 %define CONFIG_ANS 0
 %define CONFIG_LOOP_RESTORATION 0
 %define CONFIG_EXT_PARTITION 0
 %define CONFIG_EXT_PARTITION_TYPES 0
 %define CONFIG_UNPOISON_PARTITION_CTX 0
 %define CONFIG_EXT_TILE 0
 %define CONFIG_MOTION_VAR 1
 %define CONFIG_NCOBMC 0
-%define CONFIG_WARPED_MOTION 1
+%define CONFIG_WARPED_MOTION 0
 %define CONFIG_Q_ADAPT_PROBS 0
 %define CONFIG_BITSTREAM_DEBUG 0
 %define CONFIG_ALT_INTRA 1
 %define CONFIG_PALETTE 1
 %define CONFIG_PALETTE_DELTA_ENCODING 0
 %define CONFIG_RAWBITS 0
 %define CONFIG_EC_SMALLMUL 1
 %define CONFIG_PVQ 0
 %define CONFIG_CFL 0
-%define CONFIG_XIPHRC 0
+%define CONFIG_XIPHRC 1
 %define CONFIG_CB4X4 1
 %define CONFIG_CHROMA_2X2 0
 %define CONFIG_CHROMA_SUB8X8 1
 %define CONFIG_FRAME_SIZE 0
 %define CONFIG_DELTA_Q 1
 %define CONFIG_EXT_DELTA_Q 1
 %define CONFIG_ADAPT_SCAN 0
 %define CONFIG_FILTER_7BIT 1
@@ -136,11 +139,18 @@
 %define CONFIG_LV_MAP 0
 %define CONFIG_TXK_SEL 0
 %define CONFIG_MV_COMPRESS 1
 %define CONFIG_FRAME_SUPERRES 0
 %define CONFIG_NEW_MULTISYMBOL 0
 %define CONFIG_COMPOUND_SINGLEREF 0
 %define CONFIG_AOM_QM 0
 %define CONFIG_ONE_SIDED_COMPOUND 1
-%define CONFIG_SMOOTH_HV 0
+%define CONFIG_EXT_COMP_REFS 0
+%define CONFIG_SMOOTH_HV 1
 %define CONFIG_VAR_REFS 0
+%define CONFIG_RECT_INTRA_PRED 0
+%define CONFIG_LGT 0
+%define CONFIG_SBL_SYMBOL 0
+%define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+%define CONFIG_BGSPRITE 0
+%define CONFIG_VAR_TX_NO_TX_MODE 0
 %define CONFIG_ANALYZER 0
--- a/media/libaom/config/win/ia32/aom_config.h
+++ b/media/libaom/config/win/ia32/aom_config.h
@@ -4,17 +4,17 @@
 /* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License */
 /* was not distributed with this source code in the LICENSE file, you can */
 /* obtain it at www.aomedia.org/license/software. If the Alliance for Open */
 /* Media Patent License 1.0 was not distributed with this source code in the */
 /* PATENTS file, you can obtain it at www.aomedia.org/license/patent. */
 /* This file automatically generated by configure. Do not edit! */
 #ifndef AOM_CONFIG_H
 #define AOM_CONFIG_H
-#define RESTRICT
+#define RESTRICT    
 #define INLINE      __forceinline
 #define ARCH_ARM 0
 #define ARCH_MIPS 0
 #define ARCH_X86 1
 #define ARCH_X86_64 0
 #define HAVE_NEON 0
 #define HAVE_NEON_ASM 0
 #define HAVE_MIPS32 0
@@ -73,60 +73,63 @@
 #define CONFIG_INSPECTION 0
 #define CONFIG_DECODE_PERF_TESTS 0
 #define CONFIG_ENCODE_PERF_TESTS 0
 #define CONFIG_COEFFICIENT_RANGE_CHECKING 0
 #define CONFIG_LOWBITDEPTH 1
 #define CONFIG_HIGHBITDEPTH 1
 #define CONFIG_EXPERIMENTAL 0
 #define CONFIG_SIZE_LIMIT 1
+#define CONFIG_COLORSPACE_HEADERS 0
 #define CONFIG_FP_MB_STATS 0
 #define CONFIG_CDEF 1
 #define CONFIG_VAR_TX 1
 #define CONFIG_RECT_TX 1
 #define CONFIG_RECT_TX_EXT 0
 #define CONFIG_TPL_MV 0
-#define CONFIG_DUAL_FILTER 1
+#define CONFIG_DUAL_FILTER 0
 #define CONFIG_CONVOLVE_ROUND 0
 #define CONFIG_COMPOUND_ROUND 0
-#define CONFIG_EXT_TX 1
+#define CONFIG_EXT_TX 0
 #define CONFIG_DPCM_INTRA 0
 #define CONFIG_TX64X64 0
 #define CONFIG_EXT_INTRA 1
 #define CONFIG_INTRA_INTERP 0
 #define CONFIG_FILTER_INTRA 0
 #define CONFIG_INTRA_EDGE 0
 #define CONFIG_INTRABC 0
-#define CONFIG_EXT_INTER 1
-#define CONFIG_INTERINTRA 1
-#define CONFIG_WEDGE 1
-#define CONFIG_COMPOUND_SEGMENT 1
-#define CONFIG_EXT_REFS 1
-#define CONFIG_GLOBAL_MOTION 1
+#define CONFIG_EXT_INTER 0
+#define CONFIG_INTERINTRA 0
+#define CONFIG_WEDGE 0
+#define CONFIG_COMPOUND_SEGMENT 0
+#define CONFIG_EXT_REFS 0
+#define CONFIG_SPEED_REFS 0
+#define CONFIG_GF_GROUPS 0
+#define CONFIG_GLOBAL_MOTION 0
 #define CONFIG_NEW_QUANT 0
 #define CONFIG_SUPERTX 0
 #define CONFIG_ANS 0
 #define CONFIG_LOOP_RESTORATION 0
 #define CONFIG_EXT_PARTITION 0
 #define CONFIG_EXT_PARTITION_TYPES 0
 #define CONFIG_UNPOISON_PARTITION_CTX 0
 #define CONFIG_EXT_TILE 0
 #define CONFIG_MOTION_VAR 1
 #define CONFIG_NCOBMC 0
-#define CONFIG_WARPED_MOTION 1
+#define CONFIG_WARPED_MOTION 0
 #define CONFIG_Q_ADAPT_PROBS 0
 #define CONFIG_BITSTREAM_DEBUG 0
 #define CONFIG_ALT_INTRA 1
 #define CONFIG_PALETTE 1
 #define CONFIG_PALETTE_DELTA_ENCODING 0
 #define CONFIG_RAWBITS 0
 #define CONFIG_EC_SMALLMUL 1
 #define CONFIG_PVQ 0
 #define CONFIG_CFL 0
-#define CONFIG_XIPHRC 0
+#define CONFIG_XIPHRC 1
 #define CONFIG_CB4X4 1
 #define CONFIG_CHROMA_2X2 0
 #define CONFIG_CHROMA_SUB8X8 1
 #define CONFIG_FRAME_SIZE 0
 #define CONFIG_DELTA_Q 1
 #define CONFIG_EXT_DELTA_Q 1
 #define CONFIG_ADAPT_SCAN 0
 #define CONFIG_FILTER_7BIT 1
@@ -149,14 +152,21 @@
 #define CONFIG_LV_MAP 0
 #define CONFIG_TXK_SEL 0
 #define CONFIG_MV_COMPRESS 1
 #define CONFIG_FRAME_SUPERRES 0
 #define CONFIG_NEW_MULTISYMBOL 0
 #define CONFIG_COMPOUND_SINGLEREF 0
 #define CONFIG_AOM_QM 0
 #define CONFIG_ONE_SIDED_COMPOUND 1
-#define CONFIG_SMOOTH_HV 0
+#define CONFIG_EXT_COMP_REFS 0
+#define CONFIG_SMOOTH_HV 1
 #define CONFIG_VAR_REFS 0
+#define CONFIG_RECT_INTRA_PRED 0
+#define CONFIG_LGT 0
+#define CONFIG_SBL_SYMBOL 0
+#define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+#define CONFIG_BGSPRITE 0
+#define CONFIG_VAR_TX_NO_TX_MODE 0
 #define CONFIG_ANALYZER 0
 #define DECODE_WIDTH_LIMIT 8192
 #define DECODE_HEIGHT_LIMIT 4608
 #endif /* AOM_CONFIG_H */
--- a/media/libaom/config/win/ia32/aom_dsp_rtcd.h
+++ b/media/libaom/config/win/ia32/aom_dsp_rtcd.h
@@ -30,25 +30,19 @@ RTCD_EXTERN void (*aom_blend_a64_mask)(u
 
 void aom_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 void aom_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 RTCD_EXTERN void (*aom_blend_a64_vmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 
 void aom_comp_avg_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
 #define aom_comp_avg_pred aom_comp_avg_pred_c
 
-void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
-void aom_comp_avg_upsampled_pred_sse2(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
-RTCD_EXTERN void (*aom_comp_avg_upsampled_pred)(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
-
-void aom_comp_mask_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_pred aom_comp_mask_pred_c
-
-void aom_comp_mask_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_upsampled_pred aom_comp_mask_upsampled_pred_c
+void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+void aom_comp_avg_upsampled_pred_sse2(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+RTCD_EXTERN void (*aom_comp_avg_upsampled_pred)(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 
 void aom_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
@@ -56,231 +50,419 @@ void aom_convolve8_avg_sse2(const uint8_
 void aom_convolve8_avg_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_horiz_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_horiz_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_avg_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_horiz_scale aom_convolve8_avg_horiz_scale_c
+
+void aom_convolve8_avg_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_scale aom_convolve8_avg_scale_c
+
 void aom_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_vert_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_vert_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_avg_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_vert_scale aom_convolve8_avg_vert_scale_c
+
 void aom_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_horiz_scale aom_convolve8_horiz_scale_c
+
+void aom_convolve8_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_scale aom_convolve8_scale_c
+
 void aom_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_vert_scale aom_convolve8_vert_scale_c
+
 void aom_convolve_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve_copy_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve_copy)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_d117_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_16x16 aom_d117_predictor_16x16_c
 
+void aom_d117_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x32 aom_d117_predictor_16x32_c
+
+void aom_d117_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x8 aom_d117_predictor_16x8_c
+
 void aom_d117_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_2x2 aom_d117_predictor_2x2_c
 
+void aom_d117_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_32x16 aom_d117_predictor_32x16_c
+
 void aom_d117_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_32x32 aom_d117_predictor_32x32_c
 
 void aom_d117_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_4x4 aom_d117_predictor_4x4_c
 
+void aom_d117_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_4x8 aom_d117_predictor_4x8_c
+
+void aom_d117_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x16 aom_d117_predictor_8x16_c
+
+void aom_d117_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x4 aom_d117_predictor_8x4_c
+
 void aom_d117_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_8x8 aom_d117_predictor_8x8_c
 
 void aom_d135_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_16x16 aom_d135_predictor_16x16_c
 
+void aom_d135_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x32 aom_d135_predictor_16x32_c
+
+void aom_d135_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x8 aom_d135_predictor_16x8_c
+
 void aom_d135_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_2x2 aom_d135_predictor_2x2_c
 
+void aom_d135_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_32x16 aom_d135_predictor_32x16_c
+
 void aom_d135_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_32x32 aom_d135_predictor_32x32_c
 
 void aom_d135_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_4x4 aom_d135_predictor_4x4_c
 
+void aom_d135_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_4x8 aom_d135_predictor_4x8_c
+
+void aom_d135_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x16 aom_d135_predictor_8x16_c
+
+void aom_d135_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x4 aom_d135_predictor_8x4_c
+
 void aom_d135_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_8x8 aom_d135_predictor_8x8_c
 
 void aom_d153_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_16x16_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d153_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x32 aom_d153_predictor_16x32_c
+
+void aom_d153_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x8 aom_d153_predictor_16x8_c
+
 void aom_d153_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_2x2 aom_d153_predictor_2x2_c
 
+void aom_d153_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_32x16 aom_d153_predictor_32x16_c
+
 void aom_d153_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_32x32_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_d153_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d153_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_4x8 aom_d153_predictor_4x8_c
+
+void aom_d153_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x16 aom_d153_predictor_8x16_c
+
+void aom_d153_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x4 aom_d153_predictor_8x4_c
+
 void aom_d153_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_8x8_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_d207e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_16x16 aom_d207e_predictor_16x16_c
 
+void aom_d207e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x32 aom_d207e_predictor_16x32_c
+
+void aom_d207e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x8 aom_d207e_predictor_16x8_c
+
 void aom_d207e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_2x2 aom_d207e_predictor_2x2_c
 
+void aom_d207e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_32x16 aom_d207e_predictor_32x16_c
+
 void aom_d207e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_32x32 aom_d207e_predictor_32x32_c
 
 void aom_d207e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_4x4 aom_d207e_predictor_4x4_c
 
+void aom_d207e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_4x8 aom_d207e_predictor_4x8_c
+
+void aom_d207e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x16 aom_d207e_predictor_8x16_c
+
+void aom_d207e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x4 aom_d207e_predictor_8x4_c
+
 void aom_d207e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_8x8 aom_d207e_predictor_8x8_c
 
 void aom_d45e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_16x16 aom_d45e_predictor_16x16_c
 
+void aom_d45e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x32 aom_d45e_predictor_16x32_c
+
+void aom_d45e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x8 aom_d45e_predictor_16x8_c
+
 void aom_d45e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_2x2 aom_d45e_predictor_2x2_c
 
+void aom_d45e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_32x16 aom_d45e_predictor_32x16_c
+
 void aom_d45e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_32x32 aom_d45e_predictor_32x32_c
 
 void aom_d45e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_4x4 aom_d45e_predictor_4x4_c
 
+void aom_d45e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_4x8 aom_d45e_predictor_4x8_c
+
+void aom_d45e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x16 aom_d45e_predictor_8x16_c
+
+void aom_d45e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x4 aom_d45e_predictor_8x4_c
+
 void aom_d45e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_8x8 aom_d45e_predictor_8x8_c
 
 void aom_d63e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_16x16 aom_d63e_predictor_16x16_c
 
+void aom_d63e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x32 aom_d63e_predictor_16x32_c
+
+void aom_d63e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x8 aom_d63e_predictor_16x8_c
+
 void aom_d63e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_2x2 aom_d63e_predictor_2x2_c
 
+void aom_d63e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_32x16 aom_d63e_predictor_32x16_c
+
 void aom_d63e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_32x32 aom_d63e_predictor_32x32_c
 
 void aom_d63e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d63e_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d63e_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d63e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_4x8 aom_d63e_predictor_4x8_c
+
+void aom_d63e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x16 aom_d63e_predictor_8x16_c
+
+void aom_d63e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x4 aom_d63e_predictor_8x4_c
+
 void aom_d63e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_8x8 aom_d63e_predictor_8x8_c
 
 void aom_dc_128_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_128_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_128_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x32 aom_dc_128_predictor_16x32_c
+
+void aom_dc_128_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x8 aom_dc_128_predictor_16x8_c
+
 void aom_dc_128_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_2x2 aom_dc_128_predictor_2x2_c
 
+void aom_dc_128_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_32x16 aom_dc_128_predictor_32x16_c
+
 void aom_dc_128_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_128_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_128_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_128_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_128_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_4x8 aom_dc_128_predictor_4x8_c
+
+void aom_dc_128_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x16 aom_dc_128_predictor_8x16_c
+
+void aom_dc_128_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x4 aom_dc_128_predictor_8x4_c
+
 void aom_dc_128_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_128_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_left_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_left_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_left_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x32 aom_dc_left_predictor_16x32_c
+
+void aom_dc_left_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x8 aom_dc_left_predictor_16x8_c
+
 void aom_dc_left_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_2x2 aom_dc_left_predictor_2x2_c
 
+void aom_dc_left_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_32x16 aom_dc_left_predictor_32x16_c
+
 void aom_dc_left_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_left_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_left_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_left_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_left_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_4x8 aom_dc_left_predictor_4x8_c
+
+void aom_dc_left_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x16 aom_dc_left_predictor_8x16_c
+
+void aom_dc_left_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x4 aom_dc_left_predictor_8x4_c
+
 void aom_dc_left_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_left_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x32 aom_dc_predictor_16x32_c
+
+void aom_dc_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x8 aom_dc_predictor_16x8_c
+
 void aom_dc_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_2x2 aom_dc_predictor_2x2_c
 
+void aom_dc_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_32x16 aom_dc_predictor_32x16_c
+
 void aom_dc_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_4x8 aom_dc_predictor_4x8_c
+
+void aom_dc_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x16 aom_dc_predictor_8x16_c
+
+void aom_dc_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x4 aom_dc_predictor_8x4_c
+
 void aom_dc_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_top_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_top_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_top_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x32 aom_dc_top_predictor_16x32_c
+
+void aom_dc_top_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x8 aom_dc_top_predictor_16x8_c
+
 void aom_dc_top_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_2x2 aom_dc_top_predictor_2x2_c
 
+void aom_dc_top_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_32x16 aom_dc_top_predictor_32x16_c
+
 void aom_dc_top_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_top_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_dc_top_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_top_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_dc_top_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_4x8 aom_dc_top_predictor_4x8_c
+
+void aom_dc_top_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x16 aom_dc_top_predictor_8x16_c
+
+void aom_dc_top_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x4 aom_dc_top_predictor_8x4_c
+
 void aom_dc_top_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_dc_top_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct16x16_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct16x16)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct16x16_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct16x16_1_avx2(const int16_t *input, tran_low_t *output, int stride);
-RTCD_EXTERN void (*aom_fdct16x16_1)(const int16_t *input, tran_low_t *output, int stride);
-
 void aom_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_avx2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct32x32)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct32x32_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct32x32_1_avx2(const int16_t *input, tran_low_t *output, int stride);
-RTCD_EXTERN void (*aom_fdct32x32_1)(const int16_t *input, tran_low_t *output, int stride);
-
 void aom_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_rd_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_rd_avx2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct32x32_rd)(const int16_t *input, tran_low_t *output, int stride);
 
 void aom_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct4x4_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct4x4)(const int16_t *input, tran_low_t *output, int stride);
@@ -288,20 +470,16 @@ RTCD_EXTERN void (*aom_fdct4x4)(const in
 void aom_fdct4x4_1_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct4x4_1_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct4x4_1)(const int16_t *input, tran_low_t *output, int stride);
 
 void aom_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct8x8_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct8x8)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct8x8_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-RTCD_EXTERN void (*aom_fdct8x8_1)(const int16_t *input, tran_low_t *output, int stride);
-
 void aom_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 void aom_get16x16var_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 void aom_get16x16var_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 RTCD_EXTERN void (*aom_get16x16var)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 
 unsigned int aom_get4x4sse_cs_c(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int ref_stride);
 #define aom_get4x4sse_cs aom_get4x4sse_cs_c
 
@@ -312,27 +490,45 @@ RTCD_EXTERN void (*aom_get8x8var)(const 
 unsigned int aom_get_mb_ss_c(const int16_t *);
 unsigned int aom_get_mb_ss_sse2(const int16_t *);
 RTCD_EXTERN unsigned int (*aom_get_mb_ss)(const int16_t *);
 
 void aom_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_h_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x32 aom_h_predictor_16x32_c
+
+void aom_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x8 aom_h_predictor_16x8_c
+
 void aom_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_2x2 aom_h_predictor_2x2_c
 
+void aom_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_32x16 aom_h_predictor_32x16_c
+
 void aom_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_h_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_h_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_4x8 aom_h_predictor_4x8_c
+
+void aom_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x16 aom_h_predictor_8x16_c
+
+void aom_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x4 aom_h_predictor_8x4_c
+
 void aom_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_h_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_hadamard_16x16_c(const int16_t *src_diff, int src_stride, int16_t *coeff);
 void aom_hadamard_16x16_sse2(const int16_t *src_diff, int src_stride, int16_t *coeff);
 RTCD_EXTERN void (*aom_hadamard_16x16)(const int16_t *src_diff, int src_stride, int16_t *coeff);
 
@@ -341,68 +537,16 @@ void aom_hadamard_8x8_sse2(const int16_t
 RTCD_EXTERN void (*aom_hadamard_8x8)(const int16_t *src_diff, int src_stride, int16_t *coeff);
 
 void aom_highbd_10_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get16x16var aom_highbd_10_get16x16var_c
 
 void aom_highbd_10_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get8x8var aom_highbd_10_get8x8var_c
 
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_10_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_10_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_highbd_10_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 
 unsigned int aom_highbd_10_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse16x8 aom_highbd_10_mse16x8_c
 
 unsigned int aom_highbd_10_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -665,68 +809,16 @@ unsigned int aom_highbd_10_variance8x8_s
 RTCD_EXTERN unsigned int (*aom_highbd_10_variance8x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 
 void aom_highbd_12_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get16x16var aom_highbd_12_get16x16var_c
 
 void aom_highbd_12_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get8x8var aom_highbd_12_get8x8var_c
 
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_12_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_12_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_highbd_12_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 
 unsigned int aom_highbd_12_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse16x8 aom_highbd_12_mse16x8_c
 
 unsigned int aom_highbd_12_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -989,68 +1081,16 @@ unsigned int aom_highbd_12_variance8x8_s
 RTCD_EXTERN unsigned int (*aom_highbd_12_variance8x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 
 void aom_highbd_8_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get16x16var aom_highbd_8_get16x16var_c
 
 void aom_highbd_8_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get8x8var aom_highbd_8_get8x8var_c
 
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_8_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_8_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_highbd_8_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 
 unsigned int aom_highbd_8_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse16x8 aom_highbd_8_mse16x8_c
 
 unsigned int aom_highbd_8_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -1231,25 +1271,19 @@ RTCD_EXTERN void (*aom_highbd_blend_a64_
 
 void aom_highbd_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 void aom_highbd_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 RTCD_EXTERN void (*aom_highbd_blend_a64_vmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 
 void aom_highbd_comp_avg_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
 #define aom_highbd_comp_avg_pred aom_highbd_comp_avg_pred_c
 
-void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
-void aom_highbd_comp_avg_upsampled_pred_sse2(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
-RTCD_EXTERN void (*aom_highbd_comp_avg_upsampled_pred)(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
-
-void aom_highbd_comp_mask_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_pred aom_highbd_comp_mask_pred_c
-
-void aom_highbd_comp_mask_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_upsampled_pred aom_highbd_comp_mask_upsampled_pred_c
+void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+void aom_highbd_comp_avg_upsampled_pred_sse2(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+RTCD_EXTERN void (*aom_highbd_comp_avg_upsampled_pred)(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 
 void aom_highbd_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 RTCD_EXTERN void (*aom_highbd_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 
 void aom_highbd_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avg_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 RTCD_EXTERN void (*aom_highbd_convolve8_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
@@ -1278,233 +1312,400 @@ RTCD_EXTERN void (*aom_highbd_convolve_a
 void aom_highbd_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve_copy_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve_copy_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 RTCD_EXTERN void (*aom_highbd_convolve_copy)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 
 void aom_highbd_d117_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_16x16 aom_highbd_d117_predictor_16x16_c
 
+void aom_highbd_d117_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x32 aom_highbd_d117_predictor_16x32_c
+
+void aom_highbd_d117_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x8 aom_highbd_d117_predictor_16x8_c
+
 void aom_highbd_d117_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_2x2 aom_highbd_d117_predictor_2x2_c
 
+void aom_highbd_d117_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_32x16 aom_highbd_d117_predictor_32x16_c
+
 void aom_highbd_d117_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_32x32 aom_highbd_d117_predictor_32x32_c
 
 void aom_highbd_d117_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_4x4 aom_highbd_d117_predictor_4x4_c
 
+void aom_highbd_d117_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_4x8 aom_highbd_d117_predictor_4x8_c
+
+void aom_highbd_d117_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x16 aom_highbd_d117_predictor_8x16_c
+
+void aom_highbd_d117_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x4 aom_highbd_d117_predictor_8x4_c
+
 void aom_highbd_d117_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_8x8 aom_highbd_d117_predictor_8x8_c
 
 void aom_highbd_d135_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_16x16 aom_highbd_d135_predictor_16x16_c
 
+void aom_highbd_d135_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x32 aom_highbd_d135_predictor_16x32_c
+
+void aom_highbd_d135_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x8 aom_highbd_d135_predictor_16x8_c
+
 void aom_highbd_d135_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_2x2 aom_highbd_d135_predictor_2x2_c
 
+void aom_highbd_d135_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_32x16 aom_highbd_d135_predictor_32x16_c
+
 void aom_highbd_d135_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_32x32 aom_highbd_d135_predictor_32x32_c
 
 void aom_highbd_d135_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_4x4 aom_highbd_d135_predictor_4x4_c
 
+void aom_highbd_d135_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_4x8 aom_highbd_d135_predictor_4x8_c
+
+void aom_highbd_d135_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x16 aom_highbd_d135_predictor_8x16_c
+
+void aom_highbd_d135_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x4 aom_highbd_d135_predictor_8x4_c
+
 void aom_highbd_d135_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_8x8 aom_highbd_d135_predictor_8x8_c
 
 void aom_highbd_d153_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_16x16 aom_highbd_d153_predictor_16x16_c
 
+void aom_highbd_d153_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x32 aom_highbd_d153_predictor_16x32_c
+
+void aom_highbd_d153_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x8 aom_highbd_d153_predictor_16x8_c
+
 void aom_highbd_d153_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_2x2 aom_highbd_d153_predictor_2x2_c
 
+void aom_highbd_d153_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_32x16 aom_highbd_d153_predictor_32x16_c
+
 void aom_highbd_d153_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_32x32 aom_highbd_d153_predictor_32x32_c
 
 void aom_highbd_d153_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_4x4 aom_highbd_d153_predictor_4x4_c
 
+void aom_highbd_d153_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_4x8 aom_highbd_d153_predictor_4x8_c
+
+void aom_highbd_d153_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x16 aom_highbd_d153_predictor_8x16_c
+
+void aom_highbd_d153_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x4 aom_highbd_d153_predictor_8x4_c
+
 void aom_highbd_d153_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_8x8 aom_highbd_d153_predictor_8x8_c
 
 void aom_highbd_d207e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_16x16 aom_highbd_d207e_predictor_16x16_c
 
+void aom_highbd_d207e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x32 aom_highbd_d207e_predictor_16x32_c
+
+void aom_highbd_d207e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x8 aom_highbd_d207e_predictor_16x8_c
+
 void aom_highbd_d207e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_2x2 aom_highbd_d207e_predictor_2x2_c
 
+void aom_highbd_d207e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_32x16 aom_highbd_d207e_predictor_32x16_c
+
 void aom_highbd_d207e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_32x32 aom_highbd_d207e_predictor_32x32_c
 
 void aom_highbd_d207e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_4x4 aom_highbd_d207e_predictor_4x4_c
 
+void aom_highbd_d207e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_4x8 aom_highbd_d207e_predictor_4x8_c
+
+void aom_highbd_d207e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x16 aom_highbd_d207e_predictor_8x16_c
+
+void aom_highbd_d207e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x4 aom_highbd_d207e_predictor_8x4_c
+
 void aom_highbd_d207e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_8x8 aom_highbd_d207e_predictor_8x8_c
 
 void aom_highbd_d45e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_16x16 aom_highbd_d45e_predictor_16x16_c
 
+void aom_highbd_d45e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x32 aom_highbd_d45e_predictor_16x32_c
+
+void aom_highbd_d45e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x8 aom_highbd_d45e_predictor_16x8_c
+
 void aom_highbd_d45e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_2x2 aom_highbd_d45e_predictor_2x2_c
 
+void aom_highbd_d45e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_32x16 aom_highbd_d45e_predictor_32x16_c
+
 void aom_highbd_d45e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_32x32 aom_highbd_d45e_predictor_32x32_c
 
 void aom_highbd_d45e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_4x4 aom_highbd_d45e_predictor_4x4_c
 
+void aom_highbd_d45e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_4x8 aom_highbd_d45e_predictor_4x8_c
+
+void aom_highbd_d45e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x16 aom_highbd_d45e_predictor_8x16_c
+
+void aom_highbd_d45e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x4 aom_highbd_d45e_predictor_8x4_c
+
 void aom_highbd_d45e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_8x8 aom_highbd_d45e_predictor_8x8_c
 
 void aom_highbd_d63e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_16x16 aom_highbd_d63e_predictor_16x16_c
 
+void aom_highbd_d63e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x32 aom_highbd_d63e_predictor_16x32_c
+
+void aom_highbd_d63e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x8 aom_highbd_d63e_predictor_16x8_c
+
 void aom_highbd_d63e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_2x2 aom_highbd_d63e_predictor_2x2_c
 
+void aom_highbd_d63e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_32x16 aom_highbd_d63e_predictor_32x16_c
+
 void aom_highbd_d63e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_32x32 aom_highbd_d63e_predictor_32x32_c
 
 void aom_highbd_d63e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_4x4 aom_highbd_d63e_predictor_4x4_c
 
+void aom_highbd_d63e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_4x8 aom_highbd_d63e_predictor_4x8_c
+
+void aom_highbd_d63e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x16 aom_highbd_d63e_predictor_8x16_c
+
+void aom_highbd_d63e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x4 aom_highbd_d63e_predictor_8x4_c
+
 void aom_highbd_d63e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_8x8 aom_highbd_d63e_predictor_8x8_c
 
 void aom_highbd_dc_128_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_16x16 aom_highbd_dc_128_predictor_16x16_c
 
+void aom_highbd_dc_128_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x32 aom_highbd_dc_128_predictor_16x32_c
+
+void aom_highbd_dc_128_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x8 aom_highbd_dc_128_predictor_16x8_c
+
 void aom_highbd_dc_128_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_2x2 aom_highbd_dc_128_predictor_2x2_c
 
+void aom_highbd_dc_128_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_32x16 aom_highbd_dc_128_predictor_32x16_c
+
 void aom_highbd_dc_128_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_32x32 aom_highbd_dc_128_predictor_32x32_c
 
 void aom_highbd_dc_128_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_4x4 aom_highbd_dc_128_predictor_4x4_c
 
+void aom_highbd_dc_128_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_4x8 aom_highbd_dc_128_predictor_4x8_c
+
+void aom_highbd_dc_128_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x16 aom_highbd_dc_128_predictor_8x16_c
+
+void aom_highbd_dc_128_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x4 aom_highbd_dc_128_predictor_8x4_c
+
 void aom_highbd_dc_128_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_8x8 aom_highbd_dc_128_predictor_8x8_c
 
 void aom_highbd_dc_left_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_16x16 aom_highbd_dc_left_predictor_16x16_c
 
+void aom_highbd_dc_left_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x32 aom_highbd_dc_left_predictor_16x32_c
+
+void aom_highbd_dc_left_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x8 aom_highbd_dc_left_predictor_16x8_c
+
 void aom_highbd_dc_left_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_2x2 aom_highbd_dc_left_predictor_2x2_c
 
+void aom_highbd_dc_left_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_32x16 aom_highbd_dc_left_predictor_32x16_c
+
 void aom_highbd_dc_left_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_32x32 aom_highbd_dc_left_predictor_32x32_c
 
 void aom_highbd_dc_left_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_4x4 aom_highbd_dc_left_predictor_4x4_c
 
+void aom_highbd_dc_left_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_4x8 aom_highbd_dc_left_predictor_4x8_c
+
+void aom_highbd_dc_left_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x16 aom_highbd_dc_left_predictor_8x16_c
+
+void aom_highbd_dc_left_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x4 aom_highbd_dc_left_predictor_8x4_c
+
 void aom_highbd_dc_left_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_8x8 aom_highbd_dc_left_predictor_8x8_c
 
 void aom_highbd_dc_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_16x16_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_dc_predictor_16x16)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
+void aom_highbd_dc_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x32 aom_highbd_dc_predictor_16x32_c
+
+void aom_highbd_dc_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x8 aom_highbd_dc_predictor_16x8_c
+
 void aom_highbd_dc_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_2x2 aom_highbd_dc_predictor_2x2_c
 
+void aom_highbd_dc_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_32x16 aom_highbd_dc_predictor_32x16_c
+
 void aom_highbd_dc_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_32x32_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_dc_predictor_32x32)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
 void aom_highbd_dc_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_4x4_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_dc_predictor_4x4)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
+void aom_highbd_dc_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_4x8 aom_highbd_dc_predictor_4x8_c
+
+void aom_highbd_dc_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x16 aom_highbd_dc_predictor_8x16_c
+
+void aom_highbd_dc_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x4 aom_highbd_dc_predictor_8x4_c
+
 void aom_highbd_dc_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_8x8_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_dc_predictor_8x8)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
 void aom_highbd_dc_top_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_16x16 aom_highbd_dc_top_predictor_16x16_c
 
+void aom_highbd_dc_top_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x32 aom_highbd_dc_top_predictor_16x32_c
+
+void aom_highbd_dc_top_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x8 aom_highbd_dc_top_predictor_16x8_c
+
 void aom_highbd_dc_top_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_2x2 aom_highbd_dc_top_predictor_2x2_c
 
+void aom_highbd_dc_top_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_32x16 aom_highbd_dc_top_predictor_32x16_c
+
 void aom_highbd_dc_top_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_32x32 aom_highbd_dc_top_predictor_32x32_c
 
 void aom_highbd_dc_top_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_4x4 aom_highbd_dc_top_predictor_4x4_c
 
+void aom_highbd_dc_top_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_4x8 aom_highbd_dc_top_predictor_4x8_c
+
+void aom_highbd_dc_top_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x16 aom_highbd_dc_top_predictor_8x16_c
+
+void aom_highbd_dc_top_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x4 aom_highbd_dc_top_predictor_8x4_c
+
 void aom_highbd_dc_top_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_8x8 aom_highbd_dc_top_predictor_8x8_c
 
 void aom_highbd_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct16x16_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_highbd_fdct16x16)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_highbd_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct16x16_1 aom_highbd_fdct16x16_1_c
-
 void aom_highbd_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct32x32_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_highbd_fdct32x32)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_highbd_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct32x32_1 aom_highbd_fdct32x32_1_c
-
 void aom_highbd_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct32x32_rd_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_highbd_fdct32x32_rd)(const int16_t *input, tran_low_t *output, int stride);
 
 void aom_highbd_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct4x4_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_highbd_fdct4x4)(const int16_t *input, tran_low_t *output, int stride);
 
 void aom_highbd_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct8x8_sse2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_highbd_fdct8x8)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_highbd_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct8x8_1 aom_highbd_fdct8x8_1_c
-
 void aom_highbd_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_16x16 aom_highbd_h_predictor_16x16_c
 
+void aom_highbd_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x32 aom_highbd_h_predictor_16x32_c
+
+void aom_highbd_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x8 aom_highbd_h_predictor_16x8_c
+
 void aom_highbd_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_2x2 aom_highbd_h_predictor_2x2_c
 
+void aom_highbd_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_32x16 aom_highbd_h_predictor_32x16_c
+
 void aom_highbd_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_32x32 aom_highbd_h_predictor_32x32_c
 
 void aom_highbd_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_4x4 aom_highbd_h_predictor_4x4_c
 
+void aom_highbd_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_4x8 aom_highbd_h_predictor_4x8_c
+
+void aom_highbd_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x16 aom_highbd_h_predictor_8x16_c
+
+void aom_highbd_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x4 aom_highbd_h_predictor_8x4_c
+
 void aom_highbd_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_8x8 aom_highbd_h_predictor_8x8_c
 
-void aom_highbd_idct16x16_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct16x16_1_add aom_highbd_idct16x16_1_add_c
-
-void aom_highbd_idct32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1024_add aom_highbd_idct32x32_1024_add_c
-
-void aom_highbd_idct32x32_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1_add aom_highbd_idct32x32_1_add_c
-
-void aom_highbd_idct32x32_34_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_34_add aom_highbd_idct32x32_34_add_c
-
-void aom_highbd_idct4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-void aom_highbd_idct4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-RTCD_EXTERN void (*aom_highbd_idct4x4_16_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-
-void aom_highbd_idct4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct4x4_1_add aom_highbd_idct4x4_1_add_c
-
-void aom_highbd_idct8x8_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct8x8_1_add aom_highbd_idct8x8_1_add_c
-
 void aom_highbd_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_16_add aom_highbd_iwht4x4_16_add_c
 
 void aom_highbd_iwht4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_1_add aom_highbd_iwht4x4_1_add_c
 
 void aom_highbd_lpf_horizontal_4_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 void aom_highbd_lpf_horizontal_4_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
@@ -1549,68 +1750,16 @@ RTCD_EXTERN void (*aom_highbd_lpf_vertic
 void aom_highbd_lpf_vertical_8_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 void aom_highbd_lpf_vertical_8_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 RTCD_EXTERN void (*aom_highbd_lpf_vertical_8)(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 
 void aom_highbd_lpf_vertical_8_dual_c(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 void aom_highbd_lpf_vertical_8_dual_sse2(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 RTCD_EXTERN void (*aom_highbd_lpf_vertical_8_dual)(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 
-unsigned int aom_highbd_masked_sad16x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad16x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad16x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x64_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x64)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad4x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad4x4_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad4x4)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad4x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad4x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad4x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad64x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad64x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad64x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad64x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad64x64_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad64x64)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x4_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x4)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
 void aom_highbd_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 #define aom_highbd_minmax_8x8 aom_highbd_minmax_8x8_c
 
 unsigned int aom_highbd_obmc_sad16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 unsigned int aom_highbd_obmc_sad16x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad16x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 
 unsigned int aom_highbd_obmc_sad16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
@@ -1750,30 +1899,49 @@ RTCD_EXTERN unsigned int (*aom_highbd_ob
 
 unsigned int aom_highbd_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 unsigned int aom_highbd_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 
 void aom_highbd_paeth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_16x16 aom_highbd_paeth_predictor_16x16_c
 
+void aom_highbd_paeth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x32 aom_highbd_paeth_predictor_16x32_c
+
+void aom_highbd_paeth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x8 aom_highbd_paeth_predictor_16x8_c
+
 void aom_highbd_paeth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_2x2 aom_highbd_paeth_predictor_2x2_c
 
+void aom_highbd_paeth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_32x16 aom_highbd_paeth_predictor_32x16_c
+
 void aom_highbd_paeth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_32x32 aom_highbd_paeth_predictor_32x32_c
 
 void aom_highbd_paeth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_4x4 aom_highbd_paeth_predictor_4x4_c
 
+void aom_highbd_paeth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_4x8 aom_highbd_paeth_predictor_4x8_c
+
+void aom_highbd_paeth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x16 aom_highbd_paeth_predictor_8x16_c
+
+void aom_highbd_paeth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x4 aom_highbd_paeth_predictor_8x4_c
+
 void aom_highbd_paeth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_8x8 aom_highbd_paeth_predictor_8x8_c
 
 void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_highbd_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+void aom_highbd_quantize_b_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 RTCD_EXTERN void (*aom_highbd_quantize_b)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void aom_highbd_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_highbd_quantize_b_32x32_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 RTCD_EXTERN void (*aom_highbd_quantize_b_32x32)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void aom_highbd_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_highbd_quantize_b_64x64 aom_highbd_quantize_b_64x64_c
@@ -1997,54 +2165,156 @@ void aom_highbd_sad8x8x3_c(const uint8_t
 
 void aom_highbd_sad8x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 void aom_highbd_sad8x8x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 RTCD_EXTERN void (*aom_highbd_sad8x8x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 
 void aom_highbd_sad8x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
 #define aom_highbd_sad8x8x8 aom_highbd_sad8x8x8_c
 
+void aom_highbd_smooth_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x16 aom_highbd_smooth_h_predictor_16x16_c
+
+void aom_highbd_smooth_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x32 aom_highbd_smooth_h_predictor_16x32_c
+
+void aom_highbd_smooth_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x8 aom_highbd_smooth_h_predictor_16x8_c
+
+void aom_highbd_smooth_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_2x2 aom_highbd_smooth_h_predictor_2x2_c
+
+void aom_highbd_smooth_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x16 aom_highbd_smooth_h_predictor_32x16_c
+
+void aom_highbd_smooth_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x32 aom_highbd_smooth_h_predictor_32x32_c
+
+void aom_highbd_smooth_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x4 aom_highbd_smooth_h_predictor_4x4_c
+
+void aom_highbd_smooth_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x8 aom_highbd_smooth_h_predictor_4x8_c
+
+void aom_highbd_smooth_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x16 aom_highbd_smooth_h_predictor_8x16_c
+
+void aom_highbd_smooth_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x4 aom_highbd_smooth_h_predictor_8x4_c
+
+void aom_highbd_smooth_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x8 aom_highbd_smooth_h_predictor_8x8_c
+
 void aom_highbd_smooth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_16x16 aom_highbd_smooth_predictor_16x16_c
 
+void aom_highbd_smooth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x32 aom_highbd_smooth_predictor_16x32_c
+
+void aom_highbd_smooth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x8 aom_highbd_smooth_predictor_16x8_c
+
 void aom_highbd_smooth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_2x2 aom_highbd_smooth_predictor_2x2_c
 
+void aom_highbd_smooth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_32x16 aom_highbd_smooth_predictor_32x16_c
+
 void aom_highbd_smooth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_32x32 aom_highbd_smooth_predictor_32x32_c
 
 void aom_highbd_smooth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_4x4 aom_highbd_smooth_predictor_4x4_c
 
+void aom_highbd_smooth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_4x8 aom_highbd_smooth_predictor_4x8_c
+
+void aom_highbd_smooth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x16 aom_highbd_smooth_predictor_8x16_c
+
+void aom_highbd_smooth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x4 aom_highbd_smooth_predictor_8x4_c
+
 void aom_highbd_smooth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_8x8 aom_highbd_smooth_predictor_8x8_c
 
+void aom_highbd_smooth_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x16 aom_highbd_smooth_v_predictor_16x16_c
+
+void aom_highbd_smooth_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x32 aom_highbd_smooth_v_predictor_16x32_c
+
+void aom_highbd_smooth_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x8 aom_highbd_smooth_v_predictor_16x8_c
+
+void aom_highbd_smooth_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_2x2 aom_highbd_smooth_v_predictor_2x2_c
+
+void aom_highbd_smooth_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x16 aom_highbd_smooth_v_predictor_32x16_c
+
+void aom_highbd_smooth_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x32 aom_highbd_smooth_v_predictor_32x32_c
+
+void aom_highbd_smooth_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x4 aom_highbd_smooth_v_predictor_4x4_c
+
+void aom_highbd_smooth_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x8 aom_highbd_smooth_v_predictor_4x8_c
+
+void aom_highbd_smooth_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x16 aom_highbd_smooth_v_predictor_8x16_c
+
+void aom_highbd_smooth_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x4 aom_highbd_smooth_v_predictor_8x4_c
+
+void aom_highbd_smooth_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x8 aom_highbd_smooth_v_predictor_8x8_c
+
 void aom_highbd_subtract_block_c(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 void aom_highbd_subtract_block_sse2(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 RTCD_EXTERN void (*aom_highbd_subtract_block)(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 
-void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
-void aom_highbd_upsampled_pred_sse2(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
-RTCD_EXTERN void (*aom_highbd_upsampled_pred)(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
+void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+void aom_highbd_upsampled_pred_sse2(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+RTCD_EXTERN void (*aom_highbd_upsampled_pred)(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 
 void aom_highbd_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_16x16_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_v_predictor_16x16)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
+void aom_highbd_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x32 aom_highbd_v_predictor_16x32_c
+
+void aom_highbd_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x8 aom_highbd_v_predictor_16x8_c
+
 void aom_highbd_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_2x2 aom_highbd_v_predictor_2x2_c
 
+void aom_highbd_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_32x16 aom_highbd_v_predictor_32x16_c
+
 void aom_highbd_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_32x32_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_v_predictor_32x32)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
 void aom_highbd_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_4x4_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_v_predictor_4x4)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
+void aom_highbd_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_4x8 aom_highbd_v_predictor_4x8_c
+
+void aom_highbd_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x16 aom_highbd_v_predictor_8x16_c
+
+void aom_highbd_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x4 aom_highbd_v_predictor_8x4_c
+
 void aom_highbd_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_8x8_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 RTCD_EXTERN void (*aom_highbd_v_predictor_8x8)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 
 void aom_idct16x16_10_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
 void aom_idct16x16_10_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
 void aom_idct16x16_10_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
 RTCD_EXTERN void (*aom_idct16x16_10_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
@@ -2168,120 +2438,16 @@ RTCD_EXTERN void (*aom_lpf_vertical_4_du
 void aom_lpf_vertical_8_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 void aom_lpf_vertical_8_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 RTCD_EXTERN void (*aom_lpf_vertical_8)(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 
 void aom_lpf_vertical_8_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 void aom_lpf_vertical_8_dual_sse2(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 RTCD_EXTERN void (*aom_lpf_vertical_8_dual)(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 
-unsigned int aom_masked_sad16x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad16x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad16x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x64_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x64)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad4x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad4x4_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad4x4)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad4x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad4x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad4x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad64x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad64x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad64x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad64x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad64x64_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad64x64)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x4_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x4)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 void aom_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 void aom_minmax_8x8_sse2(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 RTCD_EXTERN void (*aom_minmax_8x8)(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 
 unsigned int aom_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_mse16x16_avx2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -2439,25 +2605,43 @@ RTCD_EXTERN unsigned int (*aom_obmc_vari
 
 unsigned int aom_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 unsigned int aom_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 
 void aom_paeth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_16x16 aom_paeth_predictor_16x16_c
 
+void aom_paeth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x32 aom_paeth_predictor_16x32_c
+
+void aom_paeth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x8 aom_paeth_predictor_16x8_c
+
 void aom_paeth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_2x2 aom_paeth_predictor_2x2_c
 
+void aom_paeth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_32x16 aom_paeth_predictor_32x16_c
+
 void aom_paeth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_32x32 aom_paeth_predictor_32x32_c
 
 void aom_paeth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_4x4 aom_paeth_predictor_4x4_c
 
+void aom_paeth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_4x8 aom_paeth_predictor_4x8_c
+
+void aom_paeth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x16 aom_paeth_predictor_8x16_c
+
+void aom_paeth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x4 aom_paeth_predictor_8x4_c
+
 void aom_paeth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_8x8 aom_paeth_predictor_8x8_c
 
 void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 RTCD_EXTERN void (*aom_quantize_b)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void aom_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
@@ -2714,31 +2898,115 @@ void aom_scaled_avg_vert_c(const uint8_t
 #define aom_scaled_avg_vert aom_scaled_avg_vert_c
 
 void aom_scaled_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_horiz aom_scaled_horiz_c
 
 void aom_scaled_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_vert aom_scaled_vert_c
 
+void aom_smooth_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x16 aom_smooth_h_predictor_16x16_c
+
+void aom_smooth_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x32 aom_smooth_h_predictor_16x32_c
+
+void aom_smooth_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x8 aom_smooth_h_predictor_16x8_c
+
+void aom_smooth_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_2x2 aom_smooth_h_predictor_2x2_c
+
+void aom_smooth_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x16 aom_smooth_h_predictor_32x16_c
+
+void aom_smooth_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x32 aom_smooth_h_predictor_32x32_c
+
+void aom_smooth_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x4 aom_smooth_h_predictor_4x4_c
+
+void aom_smooth_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x8 aom_smooth_h_predictor_4x8_c
+
+void aom_smooth_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x16 aom_smooth_h_predictor_8x16_c
+
+void aom_smooth_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x4 aom_smooth_h_predictor_8x4_c
+
+void aom_smooth_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x8 aom_smooth_h_predictor_8x8_c
+
 void aom_smooth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_16x16 aom_smooth_predictor_16x16_c
 
+void aom_smooth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x32 aom_smooth_predictor_16x32_c
+
+void aom_smooth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x8 aom_smooth_predictor_16x8_c
+
 void aom_smooth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_2x2 aom_smooth_predictor_2x2_c
 
+void aom_smooth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_32x16 aom_smooth_predictor_32x16_c
+
 void aom_smooth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_32x32 aom_smooth_predictor_32x32_c
 
 void aom_smooth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_4x4 aom_smooth_predictor_4x4_c
 
+void aom_smooth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_4x8 aom_smooth_predictor_4x8_c
+
+void aom_smooth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x16 aom_smooth_predictor_8x16_c
+
+void aom_smooth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x4 aom_smooth_predictor_8x4_c
+
 void aom_smooth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_8x8 aom_smooth_predictor_8x8_c
 
+void aom_smooth_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x16 aom_smooth_v_predictor_16x16_c
+
+void aom_smooth_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x32 aom_smooth_v_predictor_16x32_c
+
+void aom_smooth_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x8 aom_smooth_v_predictor_16x8_c
+
+void aom_smooth_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_2x2 aom_smooth_v_predictor_2x2_c
+
+void aom_smooth_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x16 aom_smooth_v_predictor_32x16_c
+
+void aom_smooth_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x32 aom_smooth_v_predictor_32x32_c
+
+void aom_smooth_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x4 aom_smooth_v_predictor_4x4_c
+
+void aom_smooth_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x8 aom_smooth_v_predictor_4x8_c
+
+void aom_smooth_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x16 aom_smooth_v_predictor_8x16_c
+
+void aom_smooth_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x4 aom_smooth_v_predictor_8x4_c
+
+void aom_smooth_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x8 aom_smooth_v_predictor_8x8_c
+
 uint32_t aom_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x16_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 
 uint32_t aom_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x32_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
@@ -2875,35 +3143,53 @@ RTCD_EXTERN void (*aom_subtract_block)(i
 uint64_t aom_sum_squares_2d_i16_c(const int16_t *src, int stride, int width, int height);
 uint64_t aom_sum_squares_2d_i16_sse2(const int16_t *src, int stride, int width, int height);
 RTCD_EXTERN uint64_t (*aom_sum_squares_2d_i16)(const int16_t *src, int stride, int width, int height);
 
 uint64_t aom_sum_squares_i16_c(const int16_t *src, uint32_t N);
 uint64_t aom_sum_squares_i16_sse2(const int16_t *src, uint32_t N);
 RTCD_EXTERN uint64_t (*aom_sum_squares_i16)(const int16_t *src, uint32_t N);
 
-void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
-void aom_upsampled_pred_sse2(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
-RTCD_EXTERN void (*aom_upsampled_pred)(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_sse2(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+RTCD_EXTERN void (*aom_upsampled_pred)(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 
 void aom_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_v_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x32 aom_v_predictor_16x32_c
+
+void aom_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x8 aom_v_predictor_16x8_c
+
 void aom_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_2x2 aom_v_predictor_2x2_c
 
+void aom_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_32x16 aom_v_predictor_32x16_c
+
 void aom_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_v_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_v_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_4x8 aom_v_predictor_4x8_c
+
+void aom_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x16 aom_v_predictor_8x16_c
+
+void aom_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x4 aom_v_predictor_8x4_c
+
 void aom_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_v_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 unsigned int aom_variance16x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 unsigned int aom_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 unsigned int aom_variance16x16_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_variance16x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
@@ -3067,36 +3353,28 @@ static void setup_rtcd_internal(void)
     aom_dc_top_predictor_32x32 = aom_dc_top_predictor_32x32_c;
     if (flags & HAS_SSE2) aom_dc_top_predictor_32x32 = aom_dc_top_predictor_32x32_sse2;
     aom_dc_top_predictor_4x4 = aom_dc_top_predictor_4x4_c;
     if (flags & HAS_SSE2) aom_dc_top_predictor_4x4 = aom_dc_top_predictor_4x4_sse2;
     aom_dc_top_predictor_8x8 = aom_dc_top_predictor_8x8_c;
     if (flags & HAS_SSE2) aom_dc_top_predictor_8x8 = aom_dc_top_predictor_8x8_sse2;
     aom_fdct16x16 = aom_fdct16x16_c;
     if (flags & HAS_SSE2) aom_fdct16x16 = aom_fdct16x16_sse2;
-    aom_fdct16x16_1 = aom_fdct16x16_1_c;
-    if (flags & HAS_SSE2) aom_fdct16x16_1 = aom_fdct16x16_1_sse2;
-    if (flags & HAS_AVX2) aom_fdct16x16_1 = aom_fdct16x16_1_avx2;
     aom_fdct32x32 = aom_fdct32x32_c;
     if (flags & HAS_SSE2) aom_fdct32x32 = aom_fdct32x32_sse2;
     if (flags & HAS_AVX2) aom_fdct32x32 = aom_fdct32x32_avx2;
-    aom_fdct32x32_1 = aom_fdct32x32_1_c;
-    if (flags & HAS_SSE2) aom_fdct32x32_1 = aom_fdct32x32_1_sse2;
-    if (flags & HAS_AVX2) aom_fdct32x32_1 = aom_fdct32x32_1_avx2;
     aom_fdct32x32_rd = aom_fdct32x32_rd_c;
     if (flags & HAS_SSE2) aom_fdct32x32_rd = aom_fdct32x32_rd_sse2;
     if (flags & HAS_AVX2) aom_fdct32x32_rd = aom_fdct32x32_rd_avx2;
     aom_fdct4x4 = aom_fdct4x4_c;
     if (flags & HAS_SSE2) aom_fdct4x4 = aom_fdct4x4_sse2;
     aom_fdct4x4_1 = aom_fdct4x4_1_c;
     if (flags & HAS_SSE2) aom_fdct4x4_1 = aom_fdct4x4_1_sse2;
     aom_fdct8x8 = aom_fdct8x8_c;
     if (flags & HAS_SSE2) aom_fdct8x8 = aom_fdct8x8_sse2;
-    aom_fdct8x8_1 = aom_fdct8x8_1_c;
-    if (flags & HAS_SSE2) aom_fdct8x8_1 = aom_fdct8x8_1_sse2;
     aom_get16x16var = aom_get16x16var_c;
     if (flags & HAS_SSE2) aom_get16x16var = aom_get16x16var_sse2;
     if (flags & HAS_AVX2) aom_get16x16var = aom_get16x16var_avx2;
     aom_get8x8var = aom_get8x8var_c;
     if (flags & HAS_SSE2) aom_get8x8var = aom_get8x8var_sse2;
     aom_get_mb_ss = aom_get_mb_ss_c;
     if (flags & HAS_SSE2) aom_get_mb_ss = aom_get_mb_ss_sse2;
     aom_h_predictor_16x16 = aom_h_predictor_16x16_c;
@@ -3106,42 +3384,16 @@ static void setup_rtcd_internal(void)
     aom_h_predictor_4x4 = aom_h_predictor_4x4_c;
     if (flags & HAS_SSE2) aom_h_predictor_4x4 = aom_h_predictor_4x4_sse2;
     aom_h_predictor_8x8 = aom_h_predictor_8x8_c;
     if (flags & HAS_SSE2) aom_h_predictor_8x8 = aom_h_predictor_8x8_sse2;
     aom_hadamard_16x16 = aom_hadamard_16x16_c;
     if (flags & HAS_SSE2) aom_hadamard_16x16 = aom_hadamard_16x16_sse2;
     aom_hadamard_8x8 = aom_hadamard_8x8_c;
     if (flags & HAS_SSE2) aom_hadamard_8x8 = aom_hadamard_8x8_sse2;
-    aom_highbd_10_masked_sub_pixel_variance16x16 = aom_highbd_10_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x16 = aom_highbd_10_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x32 = aom_highbd_10_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x32 = aom_highbd_10_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x8 = aom_highbd_10_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x8 = aom_highbd_10_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x16 = aom_highbd_10_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x16 = aom_highbd_10_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x32 = aom_highbd_10_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x32 = aom_highbd_10_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x64 = aom_highbd_10_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x64 = aom_highbd_10_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance4x4 = aom_highbd_10_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance4x4 = aom_highbd_10_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance4x8 = aom_highbd_10_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance4x8 = aom_highbd_10_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance64x32 = aom_highbd_10_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance64x32 = aom_highbd_10_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance64x64 = aom_highbd_10_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance64x64 = aom_highbd_10_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x16 = aom_highbd_10_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x16 = aom_highbd_10_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x4 = aom_highbd_10_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x4 = aom_highbd_10_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x8 = aom_highbd_10_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x8 = aom_highbd_10_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_10_mse16x16 = aom_highbd_10_mse16x16_c;
     if (flags & HAS_SSE2) aom_highbd_10_mse16x16 = aom_highbd_10_mse16x16_sse2;
     aom_highbd_10_mse8x8 = aom_highbd_10_mse8x8_c;
     if (flags & HAS_SSE2) aom_highbd_10_mse8x8 = aom_highbd_10_mse8x8_sse2;
     aom_highbd_10_obmc_variance16x16 = aom_highbd_10_obmc_variance16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x16 = aom_highbd_10_obmc_variance16x16_sse4_1;
     aom_highbd_10_obmc_variance16x32 = aom_highbd_10_obmc_variance16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x32 = aom_highbd_10_obmc_variance16x32_sse4_1;
@@ -3232,42 +3484,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_10_variance64x32 = aom_highbd_10_variance64x32_c;
     if (flags & HAS_SSE2) aom_highbd_10_variance64x32 = aom_highbd_10_variance64x32_sse2;
     aom_highbd_10_variance64x64 = aom_highbd_10_variance64x64_c;
     if (flags & HAS_SSE2) aom_highbd_10_variance64x64 = aom_highbd_10_variance64x64_sse2;
     aom_highbd_10_variance8x16 = aom_highbd_10_variance8x16_c;
     if (flags & HAS_SSE2) aom_highbd_10_variance8x16 = aom_highbd_10_variance8x16_sse2;
     aom_highbd_10_variance8x8 = aom_highbd_10_variance8x8_c;
     if (flags & HAS_SSE2) aom_highbd_10_variance8x8 = aom_highbd_10_variance8x8_sse2;
-    aom_highbd_12_masked_sub_pixel_variance16x16 = aom_highbd_12_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x16 = aom_highbd_12_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance16x32 = aom_highbd_12_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x32 = aom_highbd_12_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance16x8 = aom_highbd_12_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x8 = aom_highbd_12_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x16 = aom_highbd_12_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x16 = aom_highbd_12_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x32 = aom_highbd_12_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x32 = aom_highbd_12_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x64 = aom_highbd_12_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x64 = aom_highbd_12_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance4x4 = aom_highbd_12_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance4x4 = aom_highbd_12_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance4x8 = aom_highbd_12_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance4x8 = aom_highbd_12_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance64x32 = aom_highbd_12_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance64x32 = aom_highbd_12_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance64x64 = aom_highbd_12_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance64x64 = aom_highbd_12_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x16 = aom_highbd_12_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x16 = aom_highbd_12_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x4 = aom_highbd_12_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x4 = aom_highbd_12_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x8 = aom_highbd_12_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x8 = aom_highbd_12_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_12_mse16x16 = aom_highbd_12_mse16x16_c;
     if (flags & HAS_SSE2) aom_highbd_12_mse16x16 = aom_highbd_12_mse16x16_sse2;
     aom_highbd_12_mse8x8 = aom_highbd_12_mse8x8_c;
     if (flags & HAS_SSE2) aom_highbd_12_mse8x8 = aom_highbd_12_mse8x8_sse2;
     aom_highbd_12_obmc_variance16x16 = aom_highbd_12_obmc_variance16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x16 = aom_highbd_12_obmc_variance16x16_sse4_1;
     aom_highbd_12_obmc_variance16x32 = aom_highbd_12_obmc_variance16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x32 = aom_highbd_12_obmc_variance16x32_sse4_1;
@@ -3358,42 +3584,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_12_variance64x32 = aom_highbd_12_variance64x32_c;
     if (flags & HAS_SSE2) aom_highbd_12_variance64x32 = aom_highbd_12_variance64x32_sse2;
     aom_highbd_12_variance64x64 = aom_highbd_12_variance64x64_c;
     if (flags & HAS_SSE2) aom_highbd_12_variance64x64 = aom_highbd_12_variance64x64_sse2;
     aom_highbd_12_variance8x16 = aom_highbd_12_variance8x16_c;
     if (flags & HAS_SSE2) aom_highbd_12_variance8x16 = aom_highbd_12_variance8x16_sse2;
     aom_highbd_12_variance8x8 = aom_highbd_12_variance8x8_c;
     if (flags & HAS_SSE2) aom_highbd_12_variance8x8 = aom_highbd_12_variance8x8_sse2;
-    aom_highbd_8_masked_sub_pixel_variance16x16 = aom_highbd_8_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x16 = aom_highbd_8_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance16x32 = aom_highbd_8_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x32 = aom_highbd_8_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance16x8 = aom_highbd_8_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x8 = aom_highbd_8_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x16 = aom_highbd_8_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x16 = aom_highbd_8_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x32 = aom_highbd_8_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x32 = aom_highbd_8_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x64 = aom_highbd_8_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x64 = aom_highbd_8_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance4x4 = aom_highbd_8_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance4x4 = aom_highbd_8_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance4x8 = aom_highbd_8_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance4x8 = aom_highbd_8_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance64x32 = aom_highbd_8_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance64x32 = aom_highbd_8_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance64x64 = aom_highbd_8_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance64x64 = aom_highbd_8_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x16 = aom_highbd_8_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x16 = aom_highbd_8_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x4 = aom_highbd_8_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x4 = aom_highbd_8_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x8 = aom_highbd_8_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x8 = aom_highbd_8_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_8_mse16x16 = aom_highbd_8_mse16x16_c;
     if (flags & HAS_SSE2) aom_highbd_8_mse16x16 = aom_highbd_8_mse16x16_sse2;
     aom_highbd_8_mse8x8 = aom_highbd_8_mse8x8_c;
     if (flags & HAS_SSE2) aom_highbd_8_mse8x8 = aom_highbd_8_mse8x8_sse2;
     aom_highbd_8_sub_pixel_avg_variance16x16 = aom_highbd_8_sub_pixel_avg_variance16x16_c;
     if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance16x16 = aom_highbd_8_sub_pixel_avg_variance16x16_sse2;
     aom_highbd_8_sub_pixel_avg_variance16x32 = aom_highbd_8_sub_pixel_avg_variance16x32_c;
     if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance16x32 = aom_highbd_8_sub_pixel_avg_variance16x32_sse2;
@@ -3502,18 +3702,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_fdct32x32 = aom_highbd_fdct32x32_c;
     if (flags & HAS_SSE2) aom_highbd_fdct32x32 = aom_highbd_fdct32x32_sse2;
     aom_highbd_fdct32x32_rd = aom_highbd_fdct32x32_rd_c;
     if (flags & HAS_SSE2) aom_highbd_fdct32x32_rd = aom_highbd_fdct32x32_rd_sse2;
     aom_highbd_fdct4x4 = aom_highbd_fdct4x4_c;
     if (flags & HAS_SSE2) aom_highbd_fdct4x4 = aom_highbd_fdct4x4_sse2;
     aom_highbd_fdct8x8 = aom_highbd_fdct8x8_c;
     if (flags & HAS_SSE2) aom_highbd_fdct8x8 = aom_highbd_fdct8x8_sse2;
-    aom_highbd_idct4x4_16_add = aom_highbd_idct4x4_16_add_c;
-    if (flags & HAS_SSE2) aom_highbd_idct4x4_16_add = aom_highbd_idct4x4_16_add_sse2;
     aom_highbd_lpf_horizontal_4 = aom_highbd_lpf_horizontal_4_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_4 = aom_highbd_lpf_horizontal_4_sse2;
     aom_highbd_lpf_horizontal_4_dual = aom_highbd_lpf_horizontal_4_dual_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_4_dual = aom_highbd_lpf_horizontal_4_dual_sse2;
     aom_highbd_lpf_horizontal_8 = aom_highbd_lpf_horizontal_8_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_8 = aom_highbd_lpf_horizontal_8_sse2;
     aom_highbd_lpf_horizontal_8_dual = aom_highbd_lpf_horizontal_8_dual_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_8_dual = aom_highbd_lpf_horizontal_8_dual_sse2;
@@ -3528,42 +3726,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_lpf_vertical_4 = aom_highbd_lpf_vertical_4_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_vertical_4 = aom_highbd_lpf_vertical_4_sse2;
     aom_highbd_lpf_vertical_4_dual = aom_highbd_lpf_vertical_4_dual_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_vertical_4_dual = aom_highbd_lpf_vertical_4_dual_sse2;
     aom_highbd_lpf_vertical_8 = aom_highbd_lpf_vertical_8_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_vertical_8 = aom_highbd_lpf_vertical_8_sse2;
     aom_highbd_lpf_vertical_8_dual = aom_highbd_lpf_vertical_8_dual_c;
     if (flags & HAS_SSE2) aom_highbd_lpf_vertical_8_dual = aom_highbd_lpf_vertical_8_dual_sse2;
-    aom_highbd_masked_sad16x16 = aom_highbd_masked_sad16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x16 = aom_highbd_masked_sad16x16_ssse3;
-    aom_highbd_masked_sad16x32 = aom_highbd_masked_sad16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x32 = aom_highbd_masked_sad16x32_ssse3;
-    aom_highbd_masked_sad16x8 = aom_highbd_masked_sad16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x8 = aom_highbd_masked_sad16x8_ssse3;
-    aom_highbd_masked_sad32x16 = aom_highbd_masked_sad32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x16 = aom_highbd_masked_sad32x16_ssse3;
-    aom_highbd_masked_sad32x32 = aom_highbd_masked_sad32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x32 = aom_highbd_masked_sad32x32_ssse3;
-    aom_highbd_masked_sad32x64 = aom_highbd_masked_sad32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x64 = aom_highbd_masked_sad32x64_ssse3;
-    aom_highbd_masked_sad4x4 = aom_highbd_masked_sad4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad4x4 = aom_highbd_masked_sad4x4_ssse3;
-    aom_highbd_masked_sad4x8 = aom_highbd_masked_sad4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad4x8 = aom_highbd_masked_sad4x8_ssse3;
-    aom_highbd_masked_sad64x32 = aom_highbd_masked_sad64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad64x32 = aom_highbd_masked_sad64x32_ssse3;
-    aom_highbd_masked_sad64x64 = aom_highbd_masked_sad64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad64x64 = aom_highbd_masked_sad64x64_ssse3;
-    aom_highbd_masked_sad8x16 = aom_highbd_masked_sad8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x16 = aom_highbd_masked_sad8x16_ssse3;
-    aom_highbd_masked_sad8x4 = aom_highbd_masked_sad8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x4 = aom_highbd_masked_sad8x4_ssse3;
-    aom_highbd_masked_sad8x8 = aom_highbd_masked_sad8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x8 = aom_highbd_masked_sad8x8_ssse3;
     aom_highbd_obmc_sad16x16 = aom_highbd_obmc_sad16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x16 = aom_highbd_obmc_sad16x16_sse4_1;
     aom_highbd_obmc_sad16x32 = aom_highbd_obmc_sad16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x32 = aom_highbd_obmc_sad16x32_sse4_1;
     aom_highbd_obmc_sad16x8 = aom_highbd_obmc_sad16x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x8 = aom_highbd_obmc_sad16x8_sse4_1;
     aom_highbd_obmc_sad32x16 = aom_highbd_obmc_sad32x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad32x16 = aom_highbd_obmc_sad32x16_sse4_1;
@@ -3608,16 +3780,17 @@ static void setup_rtcd_internal(void)
     aom_highbd_obmc_variance8x16 = aom_highbd_obmc_variance8x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x16 = aom_highbd_obmc_variance8x16_sse4_1;
     aom_highbd_obmc_variance8x4 = aom_highbd_obmc_variance8x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x4 = aom_highbd_obmc_variance8x4_sse4_1;
     aom_highbd_obmc_variance8x8 = aom_highbd_obmc_variance8x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x8 = aom_highbd_obmc_variance8x8_sse4_1;
     aom_highbd_quantize_b = aom_highbd_quantize_b_c;
     if (flags & HAS_SSE2) aom_highbd_quantize_b = aom_highbd_quantize_b_sse2;
+    if (flags & HAS_AVX2) aom_highbd_quantize_b = aom_highbd_quantize_b_avx2;
     aom_highbd_quantize_b_32x32 = aom_highbd_quantize_b_32x32_c;
     if (flags & HAS_SSE2) aom_highbd_quantize_b_32x32 = aom_highbd_quantize_b_32x32_sse2;
     aom_highbd_sad16x16 = aom_highbd_sad16x16_c;
     if (flags & HAS_SSE2) aom_highbd_sad16x16 = aom_highbd_sad16x16_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16 = aom_highbd_sad16x16_avx2;
     aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_c;
     if (flags & HAS_SSE2) aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_avx2;
@@ -3786,68 +3959,16 @@ static void setup_rtcd_internal(void)
     aom_lpf_vertical_4 = aom_lpf_vertical_4_c;
     if (flags & HAS_SSE2) aom_lpf_vertical_4 = aom_lpf_vertical_4_sse2;
     aom_lpf_vertical_4_dual = aom_lpf_vertical_4_dual_c;
     if (flags & HAS_SSE2) aom_lpf_vertical_4_dual = aom_lpf_vertical_4_dual_sse2;
     aom_lpf_vertical_8 = aom_lpf_vertical_8_c;
     if (flags & HAS_SSE2) aom_lpf_vertical_8 = aom_lpf_vertical_8_sse2;
     aom_lpf_vertical_8_dual = aom_lpf_vertical_8_dual_c;
     if (flags & HAS_SSE2) aom_lpf_vertical_8_dual = aom_lpf_vertical_8_dual_sse2;
-    aom_masked_sad16x16 = aom_masked_sad16x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x16 = aom_masked_sad16x16_ssse3;
-    aom_masked_sad16x32 = aom_masked_sad16x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x32 = aom_masked_sad16x32_ssse3;
-    aom_masked_sad16x8 = aom_masked_sad16x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x8 = aom_masked_sad16x8_ssse3;
-    aom_masked_sad32x16 = aom_masked_sad32x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x16 = aom_masked_sad32x16_ssse3;
-    aom_masked_sad32x32 = aom_masked_sad32x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x32 = aom_masked_sad32x32_ssse3;
-    aom_masked_sad32x64 = aom_masked_sad32x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x64 = aom_masked_sad32x64_ssse3;
-    aom_masked_sad4x4 = aom_masked_sad4x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sad4x4 = aom_masked_sad4x4_ssse3;
-    aom_masked_sad4x8 = aom_masked_sad4x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad4x8 = aom_masked_sad4x8_ssse3;
-    aom_masked_sad64x32 = aom_masked_sad64x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad64x32 = aom_masked_sad64x32_ssse3;
-    aom_masked_sad64x64 = aom_masked_sad64x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sad64x64 = aom_masked_sad64x64_ssse3;
-    aom_masked_sad8x16 = aom_masked_sad8x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x16 = aom_masked_sad8x16_ssse3;
-    aom_masked_sad8x4 = aom_masked_sad8x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x4 = aom_masked_sad8x4_ssse3;
-    aom_masked_sad8x8 = aom_masked_sad8x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x8 = aom_masked_sad8x8_ssse3;
-    aom_masked_sub_pixel_variance16x16 = aom_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x16 = aom_masked_sub_pixel_variance16x16_ssse3;
-    aom_masked_sub_pixel_variance16x32 = aom_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x32 = aom_masked_sub_pixel_variance16x32_ssse3;
-    aom_masked_sub_pixel_variance16x8 = aom_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x8 = aom_masked_sub_pixel_variance16x8_ssse3;
-    aom_masked_sub_pixel_variance32x16 = aom_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x16 = aom_masked_sub_pixel_variance32x16_ssse3;
-    aom_masked_sub_pixel_variance32x32 = aom_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x32 = aom_masked_sub_pixel_variance32x32_ssse3;
-    aom_masked_sub_pixel_variance32x64 = aom_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x64 = aom_masked_sub_pixel_variance32x64_ssse3;
-    aom_masked_sub_pixel_variance4x4 = aom_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance4x4 = aom_masked_sub_pixel_variance4x4_ssse3;
-    aom_masked_sub_pixel_variance4x8 = aom_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance4x8 = aom_masked_sub_pixel_variance4x8_ssse3;
-    aom_masked_sub_pixel_variance64x32 = aom_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance64x32 = aom_masked_sub_pixel_variance64x32_ssse3;
-    aom_masked_sub_pixel_variance64x64 = aom_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance64x64 = aom_masked_sub_pixel_variance64x64_ssse3;
-    aom_masked_sub_pixel_variance8x16 = aom_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x16 = aom_masked_sub_pixel_variance8x16_ssse3;
-    aom_masked_sub_pixel_variance8x4 = aom_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x4 = aom_masked_sub_pixel_variance8x4_ssse3;
-    aom_masked_sub_pixel_variance8x8 = aom_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x8 = aom_masked_sub_pixel_variance8x8_ssse3;
     aom_minmax_8x8 = aom_minmax_8x8_c;
     if (flags & HAS_SSE2) aom_minmax_8x8 = aom_minmax_8x8_sse2;
     aom_mse16x16 = aom_mse16x16_c;
     if (flags & HAS_SSE2) aom_mse16x16 = aom_mse16x16_sse2;
     if (flags & HAS_AVX2) aom_mse16x16 = aom_mse16x16_avx2;
     aom_mse16x8 = aom_mse16x8_c;
     if (flags & HAS_SSE2) aom_mse16x8 = aom_mse16x8_sse2;
     aom_mse8x16 = aom_mse8x16_c;
--- a/media/libaom/config/win/ia32/av1_rtcd.h
+++ b/media/libaom/config/win/ia32/av1_rtcd.h
@@ -13,22 +13,25 @@
 
 #include "aom/aom_integer.h"
 #include "av1/common/common.h"
 #include "av1/common/enums.h"
 #include "av1/common/quant_common.h"
 #include "av1/common/filter.h"
 #include "av1/common/convolve.h"
 #include "av1/common/av1_txfm.h"
+#include "av1/common/idct.h"
 #include "av1/common/odintrin.h"
 
 struct macroblockd;
 
 /* Encoder forward decls */
 struct macroblock;
+struct fwd_txfm_param;
+struct inv_txfm_param;
 struct aom_variance_vtable;
 struct search_site_config;
 struct mv;
 union int_mv;
 struct yv12_buffer_config;
 typedef uint16_t od_dering_in;
 
 #ifdef __cplusplus
@@ -55,113 +58,132 @@ RTCD_EXTERN void (*aom_clpf_hblock)(uint
 
 void aom_clpf_hblock_hbd_c(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_sse2(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_ssse3(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_sse4_1(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 RTCD_EXTERN void (*aom_clpf_hblock_hbd)(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 
 int64_t av1_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
-#define av1_block_error av1_block_error_c
+int64_t av1_block_error_avx2(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
+RTCD_EXTERN int64_t (*av1_block_error)(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
 
 void av1_convolve_horiz_c(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 void av1_convolve_horiz_ssse3(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 RTCD_EXTERN void (*av1_convolve_horiz)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 
 void av1_convolve_vert_c(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 void av1_convolve_vert_ssse3(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 RTCD_EXTERN void (*av1_convolve_vert)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 
 int av1_diamond_search_sad_c(struct macroblock *x, const struct search_site_config *cfg,  struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_diamond_search_sad av1_diamond_search_sad_c
 
 void av1_fdct8x8_quant_c(const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define av1_fdct8x8_quant av1_fdct8x8_quant_c
 
-void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x16_avx2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht16x16)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x16_avx2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht16x16)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x32_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht16x32)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x32_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht16x32)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x4 av1_fht16x4_c
 
-void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht16x8)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht16x8)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht32x16)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht32x16)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x32_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x32_avx2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht32x32)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x32_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x32_avx2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht32x32)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x8 av1_fht32x8_c
 
-void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x16 av1_fht4x16_c
 
-void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht4x4)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht4x4)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht4x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht4x8)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht4x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht4x8)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht8x16)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht8x16)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x32 av1_fht8x32_c
 
-void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x4_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht8x4)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x4_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht8x4)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht8x8)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht8x8)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
 int av1_full_range_search_c(const struct macroblock *x, const struct search_site_config *cfg, struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_full_range_search av1_full_range_search_c
 
 int av1_full_search_sad_c(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 int av1_full_search_sadx3(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 int av1_full_search_sadx8(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 RTCD_EXTERN int (*av1_full_search_sad)(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 
 void av1_fwd_idtx_c(const int16_t *src_diff, tran_low_t *coeff, int stride, int bs, int tx_type);
 #define av1_fwd_idtx av1_fwd_idtx_c
 
 void av1_fwd_txfm2d_16x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_16x16_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_16x16)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_16x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x32 av1_fwd_txfm2d_16x32_c
+
+void av1_fwd_txfm2d_16x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x8 av1_fwd_txfm2d_16x8_c
+
+void av1_fwd_txfm2d_32x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_32x16 av1_fwd_txfm2d_32x16_c
+
 void av1_fwd_txfm2d_32x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_32x32_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_32x32)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
 void av1_fwd_txfm2d_4x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_4x4_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_4x4)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_4x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_4x8 av1_fwd_txfm2d_4x8_c
+
 void av1_fwd_txfm2d_64x64_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_64x64_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_64x64)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_8x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x16 av1_fwd_txfm2d_8x16_c
+
+void av1_fwd_txfm2d_8x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x4 av1_fwd_txfm2d_8x4_c
+
 void av1_fwd_txfm2d_8x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_8x8_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_8x8)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
 void av1_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_fwht4x4 av1_fwht4x4_c
 
 int64_t av1_highbd_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd);
@@ -199,225 +221,178 @@ RTCD_EXTERN void (*av1_highbd_convolve_h
 void av1_highbd_convolve_init_c(void);
 void av1_highbd_convolve_init_sse4_1(void);
 RTCD_EXTERN void (*av1_highbd_convolve_init)(void);
 
 void av1_highbd_convolve_vert_c(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 void av1_highbd_convolve_vert_sse4_1(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 RTCD_EXTERN void (*av1_highbd_convolve_vert)(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 
-void av1_highbd_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x16 av1_highbd_fht16x16_c
-
-void av1_highbd_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x32 av1_highbd_fht16x32_c
-
-void av1_highbd_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x4 av1_highbd_fht16x4_c
-
-void av1_highbd_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x8 av1_highbd_fht16x8_c
-
-void av1_highbd_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x16 av1_highbd_fht32x16_c
-
-void av1_highbd_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x32 av1_highbd_fht32x32_c
-
-void av1_highbd_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x8 av1_highbd_fht32x8_c
-
-void av1_highbd_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x16 av1_highbd_fht4x16_c
-
-void av1_highbd_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_highbd_fht4x4_sse4_1(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_highbd_fht4x4)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-
-void av1_highbd_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x8 av1_highbd_fht4x8_c
-
-void av1_highbd_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x16 av1_highbd_fht8x16_c
-
-void av1_highbd_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x32 av1_highbd_fht8x32_c
-
-void av1_highbd_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x4 av1_highbd_fht8x4_c
-
-void av1_highbd_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x8 av1_highbd_fht8x8_c
-
 void av1_highbd_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_highbd_fwht4x4 av1_highbd_fwht4x4_c
 
-void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type, int bd);
+void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x16_256_add av1_highbd_iht16x16_256_add_c
 
-void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x32_512_add av1_highbd_iht16x32_512_add_c
 
-void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x4_64_add av1_highbd_iht16x4_64_add_c
 
-void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x8_128_add av1_highbd_iht16x8_128_add_c
 
-void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x16_512_add av1_highbd_iht32x16_512_add_c
 
-void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x8_256_add av1_highbd_iht32x8_256_add_c
 
-void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x16_64_add av1_highbd_iht4x16_64_add_c
 
-void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x4_16_add av1_highbd_iht4x4_16_add_c
 
-void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x8_32_add av1_highbd_iht4x8_32_add_c
 
-void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x16_128_add av1_highbd_iht8x16_128_add_c
 
-void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x32_256_add av1_highbd_iht8x32_256_add_c
 
-void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x4_32_add av1_highbd_iht8x4_32_add_c
 
-void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x8_64_add av1_highbd_iht8x8_64_add_c
 
 void av1_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_highbd_quantize_b av1_highbd_quantize_b_c
 
 void av1_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 void av1_highbd_quantize_fp_sse4_1(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
+void av1_highbd_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 RTCD_EXTERN void (*av1_highbd_quantize_fp)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 
 void av1_highbd_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 #define av1_highbd_temporal_filter_apply av1_highbd_temporal_filter_apply_c
 
-void av1_highbd_warp_affine_c(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_highbd_warp_affine_ssse3(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-RTCD_EXTERN void (*av1_highbd_warp_affine)(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
+void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+void av1_iht16x16_256_add_sse2(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+void av1_iht16x16_256_add_avx2(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht16x16_256_add)(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 
-void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-void av1_iht16x16_256_add_sse2(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-void av1_iht16x16_256_add_avx2(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-RTCD_EXTERN void (*av1_iht16x16_256_add)(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
+void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht16x32_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht16x32_512_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht16x32_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht16x32_512_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-
-void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x4_64_add av1_iht16x4_64_add_c
 
-void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht16x8_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht16x8_128_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht16x8_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht16x8_128_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht32x16_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht32x16_512_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht32x16_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht32x16_512_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
+void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_iht32x32_1024_add av1_iht32x32_1024_add_c
 
-void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht32x8_256_add av1_iht32x8_256_add_c
 
-void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x16_64_add av1_iht4x16_64_add_c
 
-void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht4x4_16_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht4x4_16_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht4x8_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht4x8_32_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht4x8_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht4x8_32_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x16_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht8x16_128_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x16_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht8x16_128_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x32_256_add av1_iht8x32_256_add_c
 
-void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x4_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht8x4_32_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x4_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht8x4_32_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
-void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-RTCD_EXTERN void (*av1_iht8x8_64_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht8x8_64_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 
 void av1_inv_txfm2d_add_16x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_16x16_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_16x16)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
+void av1_inv_txfm2d_add_16x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x32 av1_inv_txfm2d_add_16x32_c
+
+void av1_inv_txfm2d_add_16x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x8 av1_inv_txfm2d_add_16x8_c
+
+void av1_inv_txfm2d_add_32x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_32x16 av1_inv_txfm2d_add_32x16_c
+
 void av1_inv_txfm2d_add_32x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_32x32_avx2(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_32x32)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
 void av1_inv_txfm2d_add_4x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_4x4_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_4x4)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
+void av1_inv_txfm2d_add_4x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_4x8 av1_inv_txfm2d_add_4x8_c
+
 void av1_inv_txfm2d_add_64x64_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_64x64 av1_inv_txfm2d_add_64x64_c
 
+void av1_inv_txfm2d_add_8x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x16 av1_inv_txfm2d_add_8x16_c
+
+void av1_inv_txfm2d_add_8x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x4 av1_inv_txfm2d_add_8x4_c
+
 void av1_inv_txfm2d_add_8x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_8x8_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_8x8)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
 void av1_lowbd_convolve_init_c(void);
 void av1_lowbd_convolve_init_ssse3(void);
 RTCD_EXTERN void (*av1_lowbd_convolve_init)(void);
 
 void av1_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_quantize_b av1_quantize_b_c
 
 void av1_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void av1_quantize_fp_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+void av1_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 RTCD_EXTERN void (*av1_quantize_fp)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void av1_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
-#define av1_quantize_fp_32x32 av1_quantize_fp_32x32_c
+void av1_quantize_fp_32x32_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*av1_quantize_fp_32x32)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void av1_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 void av1_temporal_filter_apply_sse2(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 RTCD_EXTERN void (*av1_temporal_filter_apply)(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 
-void av1_warp_affine_c(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_warp_affine_sse2(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_warp_affine_ssse3(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-RTCD_EXTERN void (*av1_warp_affine)(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-
-void av1_wedge_compute_delta_squares_c(int16_t *d, const int16_t *a, const int16_t *b, int N);
-void av1_wedge_compute_delta_squares_sse2(int16_t *d, const int16_t *a, const int16_t *b, int N);
-RTCD_EXTERN void (*av1_wedge_compute_delta_squares)(int16_t *d, const int16_t *a, const int16_t *b, int N);
-
-int av1_wedge_sign_from_residuals_c(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-int av1_wedge_sign_from_residuals_sse2(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-RTCD_EXTERN int (*av1_wedge_sign_from_residuals)(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-
-uint64_t av1_wedge_sse_from_residuals_c(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-uint64_t av1_wedge_sse_from_residuals_sse2(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-RTCD_EXTERN uint64_t (*av1_wedge_sse_from_residuals)(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-
-double compute_cross_correlation_c(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-double compute_cross_correlation_sse4_1(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-RTCD_EXTERN double (*compute_cross_correlation)(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-
 void copy_4x4_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_sse2(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_ssse3(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_sse4_1(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 RTCD_EXTERN void (*copy_4x4_16bit_to_16bit)(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 
 void copy_4x4_16bit_to_8bit_c(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_8bit_sse2(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
@@ -488,16 +463,18 @@ static void setup_rtcd_internal(void)
     aom_clpf_hblock = aom_clpf_hblock_c;
     if (flags & HAS_SSE2) aom_clpf_hblock = aom_clpf_hblock_sse2;
     if (flags & HAS_SSSE3) aom_clpf_hblock = aom_clpf_hblock_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_hblock = aom_clpf_hblock_sse4_1;
     aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_c;
     if (flags & HAS_SSE2) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_sse2;
     if (flags & HAS_SSSE3) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_sse4_1;
+    av1_block_error = av1_block_error_c;
+    if (flags & HAS_AVX2) av1_block_error = av1_block_error_avx2;
     av1_convolve_horiz = av1_convolve_horiz_c;
     if (flags & HAS_SSSE3) av1_convolve_horiz = av1_convolve_horiz_ssse3;
     av1_convolve_vert = av1_convolve_vert_c;
     if (flags & HAS_SSSE3) av1_convolve_vert = av1_convolve_vert_ssse3;
     av1_fht16x16 = av1_fht16x16_c;
     if (flags & HAS_SSE2) av1_fht16x16 = av1_fht16x16_sse2;
     if (flags & HAS_AVX2) av1_fht16x16 = av1_fht16x16_avx2;
     av1_fht16x32 = av1_fht16x32_c;
@@ -535,22 +512,19 @@ static void setup_rtcd_internal(void)
     av1_highbd_block_error = av1_highbd_block_error_c;
     if (flags & HAS_SSE2) av1_highbd_block_error = av1_highbd_block_error_sse2;
     av1_highbd_convolve_horiz = av1_highbd_convolve_horiz_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_horiz = av1_highbd_convolve_horiz_sse4_1;
     av1_highbd_convolve_init = av1_highbd_convolve_init_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_init = av1_highbd_convolve_init_sse4_1;
     av1_highbd_convolve_vert = av1_highbd_convolve_vert_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_vert = av1_highbd_convolve_vert_sse4_1;
-    av1_highbd_fht4x4 = av1_highbd_fht4x4_c;
-    if (flags & HAS_SSE4_1) av1_highbd_fht4x4 = av1_highbd_fht4x4_sse4_1;
     av1_highbd_quantize_fp = av1_highbd_quantize_fp_c;
     if (flags & HAS_SSE4_1) av1_highbd_quantize_fp = av1_highbd_quantize_fp_sse4_1;
-    av1_highbd_warp_affine = av1_highbd_warp_affine_c;
-    if (flags & HAS_SSSE3) av1_highbd_warp_affine = av1_highbd_warp_affine_ssse3;
+    if (flags & HAS_AVX2) av1_highbd_quantize_fp = av1_highbd_quantize_fp_avx2;
     av1_iht16x16_256_add = av1_iht16x16_256_add_c;
     if (flags & HAS_SSE2) av1_iht16x16_256_add = av1_iht16x16_256_add_sse2;
     if (flags & HAS_AVX2) av1_iht16x16_256_add = av1_iht16x16_256_add_avx2;
     av1_iht16x32_512_add = av1_iht16x32_512_add_c;
     if (flags & HAS_SSE2) av1_iht16x32_512_add = av1_iht16x32_512_add_sse2;
     av1_iht16x8_128_add = av1_iht16x8_128_add_c;
     if (flags & HAS_SSE2) av1_iht16x8_128_add = av1_iht16x8_128_add_sse2;
     av1_iht32x16_512_add = av1_iht32x16_512_add_c;
@@ -572,29 +546,21 @@ static void setup_rtcd_internal(void)
     av1_inv_txfm2d_add_4x4 = av1_inv_txfm2d_add_4x4_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_4x4 = av1_inv_txfm2d_add_4x4_sse4_1;
     av1_inv_txfm2d_add_8x8 = av1_inv_txfm2d_add_8x8_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_8x8 = av1_inv_txfm2d_add_8x8_sse4_1;
     av1_lowbd_convolve_init = av1_lowbd_convolve_init_c;
     if (flags & HAS_SSSE3) av1_lowbd_convolve_init = av1_lowbd_convolve_init_ssse3;
     av1_quantize_fp = av1_quantize_fp_c;
     if (flags & HAS_SSE2) av1_quantize_fp = av1_quantize_fp_sse2;
+    if (flags & HAS_AVX2) av1_quantize_fp = av1_quantize_fp_avx2;
+    av1_quantize_fp_32x32 = av1_quantize_fp_32x32_c;
+    if (flags & HAS_AVX2) av1_quantize_fp_32x32 = av1_quantize_fp_32x32_avx2;
     av1_temporal_filter_apply = av1_temporal_filter_apply_c;
     if (flags & HAS_SSE2) av1_temporal_filter_apply = av1_temporal_filter_apply_sse2;
-    av1_warp_affine = av1_warp_affine_c;
-    if (flags & HAS_SSE2) av1_warp_affine = av1_warp_affine_sse2;
-    if (flags & HAS_SSSE3) av1_warp_affine = av1_warp_affine_ssse3;
-    av1_wedge_compute_delta_squares = av1_wedge_compute_delta_squares_c;
-    if (flags & HAS_SSE2) av1_wedge_compute_delta_squares = av1_wedge_compute_delta_squares_sse2;
-    av1_wedge_sign_from_residuals = av1_wedge_sign_from_residuals_c;
-    if (flags & HAS_SSE2) av1_wedge_sign_from_residuals = av1_wedge_sign_from_residuals_sse2;
-    av1_wedge_sse_from_residuals = av1_wedge_sse_from_residuals_c;
-    if (flags & HAS_SSE2) av1_wedge_sse_from_residuals = av1_wedge_sse_from_residuals_sse2;
-    compute_cross_correlation = compute_cross_correlation_c;
-    if (flags & HAS_SSE4_1) compute_cross_correlation = compute_cross_correlation_sse4_1;
     copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_c;
     if (flags & HAS_SSE2) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_sse2;
     if (flags & HAS_SSSE3) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_ssse3;
     if (flags & HAS_SSE4_1) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_sse4_1;
     copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_c;
     if (flags & HAS_SSE2) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_sse2;
     if (flags & HAS_SSSE3) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_ssse3;
     if (flags & HAS_SSE4_1) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_sse4_1;
new file mode 100644
--- /dev/null
+++ b/media/libaom/config/win/mingw32/aom_config.asm
@@ -0,0 +1,160 @@
+@ This file was created from a .asm file
+@  using the ads2gas.pl script.
+	.equ DO1STROUNDING, 0
+.equ ARCH_ARM ,  0
+.equ ARCH_MIPS ,  0
+.equ ARCH_X86 ,  1
+.equ ARCH_X86_64 ,  0
+.equ HAVE_NEON ,  0
+.equ HAVE_NEON_ASM ,  0
+.equ HAVE_MIPS32 ,  0
+.equ HAVE_DSPR2 ,  0
+.equ HAVE_MSA ,  0
+.equ HAVE_MIPS64 ,  0
+.equ HAVE_MMX ,  1
+.equ HAVE_SSE ,  1
+.equ HAVE_SSE2 ,  1
+.equ HAVE_SSE3 ,  1
+.equ HAVE_SSSE3 ,  1
+.equ HAVE_SSE4_1 ,  1
+.equ HAVE_AVX ,  1
+.equ HAVE_AVX2 ,  1
+.equ HAVE_AOM_PORTS ,  1
+.equ HAVE_FEXCEPT ,  1
+.equ HAVE_PTHREAD_H ,  0
+.equ HAVE_WXWIDGETS ,  0
+.equ CONFIG_DEPENDENCY_TRACKING ,  1
+.equ CONFIG_EXTERNAL_BUILD ,  1
+.equ CONFIG_INSTALL_DOCS ,  1
+.equ CONFIG_INSTALL_BINS ,  1
+.equ CONFIG_INSTALL_LIBS ,  1
+.equ CONFIG_INSTALL_SRCS ,  0
+.equ CONFIG_DEBUG ,  0
+.equ CONFIG_GPROF ,  0
+.equ CONFIG_GCOV ,  0
+.equ CONFIG_RVCT ,  0
+.equ CONFIG_GCC ,  1
+.equ CONFIG_MSVS ,  0
+.equ CONFIG_PIC ,  1
+.equ CONFIG_BIG_ENDIAN ,  0
+.equ CONFIG_CODEC_SRCS ,  0
+.equ CONFIG_DEBUG_LIBS ,  0
+.equ CONFIG_RUNTIME_CPU_DETECT ,  1
+.equ CONFIG_POSTPROC ,  1
+.equ CONFIG_MULTITHREAD ,  1
+.equ CONFIG_INTERNAL_STATS ,  0
+.equ CONFIG_AV1_ENCODER ,  1
+.equ CONFIG_AV1_DECODER ,  1
+.equ CONFIG_AV1 ,  1
+.equ CONFIG_STATIC_MSVCRT ,  0
+.equ CONFIG_SPATIAL_RESAMPLING ,  1
+.equ CONFIG_REALTIME_ONLY ,  0
+.equ CONFIG_ONTHEFLY_BITPACKING ,  0
+.equ CONFIG_ERROR_CONCEALMENT ,  0
+.equ CONFIG_SHARED ,  0
+.equ CONFIG_STATIC ,  1
+.equ CONFIG_SMALL ,  0
+.equ CONFIG_POSTPROC_VISUALIZER ,  0
+.equ CONFIG_OS_SUPPORT ,  1
+.equ CONFIG_UNIT_TESTS ,  0
+.equ CONFIG_WEBM_IO ,  1
+.equ CONFIG_LIBYUV ,  1
+.equ CONFIG_ACCOUNTING ,  0
+.equ CONFIG_INSPECTION ,  0
+.equ CONFIG_DECODE_PERF_TESTS ,  0
+.equ CONFIG_ENCODE_PERF_TESTS ,  0
+.equ CONFIG_COEFFICIENT_RANGE_CHECKING ,  0
+.equ CONFIG_LOWBITDEPTH ,  1
+.equ CONFIG_HIGHBITDEPTH ,  1
+.equ CONFIG_EXPERIMENTAL ,  0
+.equ CONFIG_SIZE_LIMIT ,  1
+.equ CONFIG_COLORSPACE_HEADERS ,  0
+.equ CONFIG_FP_MB_STATS ,  0
+.equ CONFIG_CDEF ,  1
+.equ CONFIG_VAR_TX ,  1
+.equ CONFIG_RECT_TX ,  1
+.equ CONFIG_RECT_TX_EXT ,  0
+.equ CONFIG_TPL_MV ,  0
+.equ CONFIG_DUAL_FILTER ,  0
+.equ CONFIG_CONVOLVE_ROUND ,  0
+.equ CONFIG_COMPOUND_ROUND ,  0
+.equ CONFIG_EXT_TX ,  0
+.equ CONFIG_DPCM_INTRA ,  0
+.equ CONFIG_TX64X64 ,  0
+.equ CONFIG_EXT_INTRA ,  1
+.equ CONFIG_INTRA_INTERP ,  0
+.equ CONFIG_FILTER_INTRA ,  0
+.equ CONFIG_INTRA_EDGE ,  0
+.equ CONFIG_INTRABC ,  0
+.equ CONFIG_EXT_INTER ,  0
+.equ CONFIG_INTERINTRA ,  0
+.equ CONFIG_WEDGE ,  0
+.equ CONFIG_COMPOUND_SEGMENT ,  0
+.equ CONFIG_EXT_REFS ,  0
+.equ CONFIG_SPEED_REFS ,  0
+.equ CONFIG_GF_GROUPS ,  0
+.equ CONFIG_GLOBAL_MOTION ,  0
+.equ CONFIG_NEW_QUANT ,  0
+.equ CONFIG_SUPERTX ,  0
+.equ CONFIG_ANS ,  0
+.equ CONFIG_LOOP_RESTORATION ,  0
+.equ CONFIG_EXT_PARTITION ,  0
+.equ CONFIG_EXT_PARTITION_TYPES ,  0
+.equ CONFIG_UNPOISON_PARTITION_CTX ,  0
+.equ CONFIG_EXT_TILE ,  0
+.equ CONFIG_MOTION_VAR ,  1
+.equ CONFIG_NCOBMC ,  0
+.equ CONFIG_WARPED_MOTION ,  0
+.equ CONFIG_Q_ADAPT_PROBS ,  0
+.equ CONFIG_BITSTREAM_DEBUG ,  0
+.equ CONFIG_ALT_INTRA ,  1
+.equ CONFIG_PALETTE ,  1
+.equ CONFIG_PALETTE_DELTA_ENCODING ,  0
+.equ CONFIG_RAWBITS ,  0
+.equ CONFIG_EC_SMALLMUL ,  1
+.equ CONFIG_PVQ ,  0
+.equ CONFIG_CFL ,  0
+.equ CONFIG_XIPHRC ,  1
+.equ CONFIG_CB4X4 ,  1
+.equ CONFIG_CHROMA_2X2 ,  0
+.equ CONFIG_CHROMA_SUB8X8 ,  1
+.equ CONFIG_FRAME_SIZE ,  0
+.equ CONFIG_DELTA_Q ,  1
+.equ CONFIG_EXT_DELTA_Q ,  1
+.equ CONFIG_ADAPT_SCAN ,  0
+.equ CONFIG_FILTER_7BIT ,  1
+.equ CONFIG_PARALLEL_DEBLOCKING ,  0
+.equ CONFIG_PARALLEL_DEBLOCKING_15TAP ,  0
+.equ CONFIG_LOOPFILTERING_ACROSS_TILES ,  1
+.equ CONFIG_TILE_GROUPS ,  1
+.equ CONFIG_EC_ADAPT ,  1
+.equ CONFIG_TEMPMV_SIGNALING ,  1
+.equ CONFIG_RD_DEBUG ,  0
+.equ CONFIG_REFERENCE_BUFFER ,  1
+.equ CONFIG_COEF_INTERLEAVE ,  0
+.equ CONFIG_ENTROPY_STATS ,  0
+.equ CONFIG_MASKED_TX ,  0
+.equ CONFIG_DEPENDENT_HORZTILES ,  0
+.equ CONFIG_DAALA_DIST ,  0
+.equ CONFIG_TRIPRED ,  0
+.equ CONFIG_PALETTE_THROUGHPUT ,  1
+.equ CONFIG_REF_ADAPT ,  0
+.equ CONFIG_LV_MAP ,  0
+.equ CONFIG_TXK_SEL ,  0
+.equ CONFIG_MV_COMPRESS ,  1
+.equ CONFIG_FRAME_SUPERRES ,  0
+.equ CONFIG_NEW_MULTISYMBOL ,  0
+.equ CONFIG_COMPOUND_SINGLEREF ,  0
+.equ CONFIG_AOM_QM ,  0
+.equ CONFIG_ONE_SIDED_COMPOUND ,  1
+.equ CONFIG_EXT_COMP_REFS ,  0
+.equ CONFIG_SMOOTH_HV ,  1
+.equ CONFIG_VAR_REFS ,  0
+.equ CONFIG_RECT_INTRA_PRED ,  0
+.equ CONFIG_LGT ,  0
+.equ CONFIG_SBL_SYMBOL ,  0
+.equ CONFIG_NCOBMC_ADAPT_WEIGHT ,  0
+.equ CONFIG_BGSPRITE ,  0
+.equ CONFIG_VAR_TX_NO_TX_MODE ,  0
+.equ CONFIG_ANALYZER ,  0
+	.section	.note.GNU-stack,"",%progbits
new file mode 100644
--- /dev/null
+++ b/media/libaom/config/win/mingw32/aom_config.c
@@ -0,0 +1,11 @@
+/* Copyright (c) 2016, Alliance for Open Media. All rights reserved. */
+/*  */
+/* This source code is subject to the terms of the BSD 2 Clause License and */
+/* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License */
+/* was not distributed with this source code in the LICENSE file, you can */
+/* obtain it at www.aomedia.org/license/software. If the Alliance for Open */
+/* Media Patent License 1.0 was not distributed with this source code in the */
+/* PATENTS file, you can obtain it at www.aomedia.org/license/patent. */
+#include "aom/aom_codec.h"
+static const char* const cfg = "--target=x86-win32-gcc --enable-external-build --disable-examples --disable-docs --disable-unit-tests --size-limit=8192x4608 --enable-pic --enable-postproc --as=yasm";
+const char *aom_codec_build_config(void) {return cfg;}
new file mode 100644
--- /dev/null
+++ b/media/libaom/config/win/mingw32/aom_config.h
@@ -0,0 +1,172 @@
+/* Copyright (c) 2016, Alliance for Open Media. All rights reserved. */
+/*  */
+/* This source code is subject to the terms of the BSD 2 Clause License and */
+/* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License */
+/* was not distributed with this source code in the LICENSE file, you can */
+/* obtain it at www.aomedia.org/license/software. If the Alliance for Open */
+/* Media Patent License 1.0 was not distributed with this source code in the */
+/* PATENTS file, you can obtain it at www.aomedia.org/license/patent. */
+/* This file automatically generated by configure. Do not edit! */
+#ifndef AOM_CONFIG_H
+#define AOM_CONFIG_H
+#define RESTRICT    
+#define INLINE      inline
+#define ARCH_ARM 0
+#define ARCH_MIPS 0
+#define ARCH_X86 1
+#define ARCH_X86_64 0
+#define HAVE_NEON 0
+#define HAVE_NEON_ASM 0
+#define HAVE_MIPS32 0
+#define HAVE_DSPR2 0
+#define HAVE_MSA 0
+#define HAVE_MIPS64 0
+#define HAVE_MMX 1
+#define HAVE_SSE 1
+#define HAVE_SSE2 1
+#define HAVE_SSE3 1
+#define HAVE_SSSE3 1
+#define HAVE_SSE4_1 1
+#define HAVE_AVX 1
+#define HAVE_AVX2 1
+#define HAVE_AOM_PORTS 1
+#define HAVE_FEXCEPT 1
+#define HAVE_PTHREAD_H 0
+#define HAVE_WXWIDGETS 0
+#define CONFIG_DEPENDENCY_TRACKING 1
+#define CONFIG_EXTERNAL_BUILD 1
+#define CONFIG_INSTALL_DOCS 1
+#define CONFIG_INSTALL_BINS 1
+#define CONFIG_INSTALL_LIBS 1
+#define CONFIG_INSTALL_SRCS 0
+#define CONFIG_DEBUG 0
+#define CONFIG_GPROF 0
+#define CONFIG_GCOV 0
+#define CONFIG_RVCT 0
+#define CONFIG_GCC 1
+#define CONFIG_MSVS 0
+#define CONFIG_PIC 1
+#define CONFIG_BIG_ENDIAN 0
+#define CONFIG_CODEC_SRCS 0
+#define CONFIG_DEBUG_LIBS 0
+#define CONFIG_RUNTIME_CPU_DETECT 1
+#define CONFIG_POSTPROC 1
+#define CONFIG_MULTITHREAD 1
+#define CONFIG_INTERNAL_STATS 0
+#define CONFIG_AV1_ENCODER 1
+#define CONFIG_AV1_DECODER 1
+#define CONFIG_AV1 1
+#define CONFIG_STATIC_MSVCRT 0
+#define CONFIG_SPATIAL_RESAMPLING 1
+#define CONFIG_REALTIME_ONLY 0
+#define CONFIG_ONTHEFLY_BITPACKING 0
+#define CONFIG_ERROR_CONCEALMENT 0
+#define CONFIG_SHARED 0
+#define CONFIG_STATIC 1
+#define CONFIG_SMALL 0
+#define CONFIG_POSTPROC_VISUALIZER 0
+#define CONFIG_OS_SUPPORT 1
+#define CONFIG_UNIT_TESTS 0
+#define CONFIG_WEBM_IO 1
+#define CONFIG_LIBYUV 1
+#define CONFIG_ACCOUNTING 0
+#define CONFIG_INSPECTION 0
+#define CONFIG_DECODE_PERF_TESTS 0
+#define CONFIG_ENCODE_PERF_TESTS 0
+#define CONFIG_COEFFICIENT_RANGE_CHECKING 0
+#define CONFIG_LOWBITDEPTH 1
+#define CONFIG_HIGHBITDEPTH 1
+#define CONFIG_EXPERIMENTAL 0
+#define CONFIG_SIZE_LIMIT 1
+#define CONFIG_COLORSPACE_HEADERS 0
+#define CONFIG_FP_MB_STATS 0
+#define CONFIG_CDEF 1
+#define CONFIG_VAR_TX 1
+#define CONFIG_RECT_TX 1
+#define CONFIG_RECT_TX_EXT 0
+#define CONFIG_TPL_MV 0
+#define CONFIG_DUAL_FILTER 0
+#define CONFIG_CONVOLVE_ROUND 0
+#define CONFIG_COMPOUND_ROUND 0
+#define CONFIG_EXT_TX 0
+#define CONFIG_DPCM_INTRA 0
+#define CONFIG_TX64X64 0
+#define CONFIG_EXT_INTRA 1
+#define CONFIG_INTRA_INTERP 0
+#define CONFIG_FILTER_INTRA 0
+#define CONFIG_INTRA_EDGE 0
+#define CONFIG_INTRABC 0
+#define CONFIG_EXT_INTER 0
+#define CONFIG_INTERINTRA 0
+#define CONFIG_WEDGE 0
+#define CONFIG_COMPOUND_SEGMENT 0
+#define CONFIG_EXT_REFS 0
+#define CONFIG_SPEED_REFS 0
+#define CONFIG_GF_GROUPS 0
+#define CONFIG_GLOBAL_MOTION 0
+#define CONFIG_NEW_QUANT 0
+#define CONFIG_SUPERTX 0
+#define CONFIG_ANS 0
+#define CONFIG_LOOP_RESTORATION 0
+#define CONFIG_EXT_PARTITION 0
+#define CONFIG_EXT_PARTITION_TYPES 0
+#define CONFIG_UNPOISON_PARTITION_CTX 0
+#define CONFIG_EXT_TILE 0
+#define CONFIG_MOTION_VAR 1
+#define CONFIG_NCOBMC 0
+#define CONFIG_WARPED_MOTION 0
+#define CONFIG_Q_ADAPT_PROBS 0
+#define CONFIG_BITSTREAM_DEBUG 0
+#define CONFIG_ALT_INTRA 1
+#define CONFIG_PALETTE 1
+#define CONFIG_PALETTE_DELTA_ENCODING 0
+#define CONFIG_RAWBITS 0
+#define CONFIG_EC_SMALLMUL 1
+#define CONFIG_PVQ 0
+#define CONFIG_CFL 0
+#define CONFIG_XIPHRC 1
+#define CONFIG_CB4X4 1
+#define CONFIG_CHROMA_2X2 0
+#define CONFIG_CHROMA_SUB8X8 1
+#define CONFIG_FRAME_SIZE 0
+#define CONFIG_DELTA_Q 1
+#define CONFIG_EXT_DELTA_Q 1
+#define CONFIG_ADAPT_SCAN 0
+#define CONFIG_FILTER_7BIT 1
+#define CONFIG_PARALLEL_DEBLOCKING 0
+#define CONFIG_PARALLEL_DEBLOCKING_15TAP 0
+#define CONFIG_LOOPFILTERING_ACROSS_TILES 1
+#define CONFIG_TILE_GROUPS 1
+#define CONFIG_EC_ADAPT 1
+#define CONFIG_TEMPMV_SIGNALING 1
+#define CONFIG_RD_DEBUG 0
+#define CONFIG_REFERENCE_BUFFER 1
+#define CONFIG_COEF_INTERLEAVE 0
+#define CONFIG_ENTROPY_STATS 0
+#define CONFIG_MASKED_TX 0
+#define CONFIG_DEPENDENT_HORZTILES 0
+#define CONFIG_DAALA_DIST 0
+#define CONFIG_TRIPRED 0
+#define CONFIG_PALETTE_THROUGHPUT 1
+#define CONFIG_REF_ADAPT 0
+#define CONFIG_LV_MAP 0
+#define CONFIG_TXK_SEL 0
+#define CONFIG_MV_COMPRESS 1
+#define CONFIG_FRAME_SUPERRES 0
+#define CONFIG_NEW_MULTISYMBOL 0
+#define CONFIG_COMPOUND_SINGLEREF 0
+#define CONFIG_AOM_QM 0
+#define CONFIG_ONE_SIDED_COMPOUND 1
+#define CONFIG_EXT_COMP_REFS 0
+#define CONFIG_SMOOTH_HV 1
+#define CONFIG_VAR_REFS 0
+#define CONFIG_RECT_INTRA_PRED 0
+#define CONFIG_LGT 0
+#define CONFIG_SBL_SYMBOL 0
+#define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+#define CONFIG_BGSPRITE 0
+#define CONFIG_VAR_TX_NO_TX_MODE 0
+#define CONFIG_ANALYZER 0
+#define DECODE_WIDTH_LIMIT 8192
+#define DECODE_HEIGHT_LIMIT 4608
+#endif /* AOM_CONFIG_H */
new file mode 100644
--- /dev/null
+++ b/media/libaom/config/win/mingw32/aom_dsp_rtcd.h
@@ -0,0 +1,4294 @@
+#ifndef AOM_DSP_RTCD_H_
+#define AOM_DSP_RTCD_H_
+
+#ifdef RTCD_C
+#define RTCD_EXTERN
+#else
+#define RTCD_EXTERN extern
+#endif
+
+/*
+ * DSP
+ */
+
+#include "aom/aom_integer.h"
+#include "aom_dsp/aom_dsp_common.h"
+#include "av1/common/enums.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void aom_blend_a64_hmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
+void aom_blend_a64_hmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
+RTCD_EXTERN void (*aom_blend_a64_hmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
+
+void aom_blend_a64_mask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, uint32_t mask_stride, int h, int w, int suby, int subx);
+void aom_blend_a64_mask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, uint32_t mask_stride, int h, int w, int suby, int subx);
+RTCD_EXTERN void (*aom_blend_a64_mask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, uint32_t mask_stride, int h, int w, int suby, int subx);
+
+void aom_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
+void aom_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
+RTCD_EXTERN void (*aom_blend_a64_vmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
+
+void aom_comp_avg_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
+#define aom_comp_avg_pred aom_comp_avg_pred_c
+
+void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+void aom_comp_avg_upsampled_pred_sse2(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+RTCD_EXTERN void (*aom_comp_avg_upsampled_pred)(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+
+void aom_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+RTCD_EXTERN void (*aom_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+
+void aom_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_avg_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+RTCD_EXTERN void (*aom_convolve8_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+
+void aom_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_avg_horiz_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_avg_horiz_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+RTCD_EXTERN void (*aom_convolve8_avg_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+
+void aom_convolve8_avg_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_horiz_scale aom_convolve8_avg_horiz_scale_c
+
+void aom_convolve8_avg_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_scale aom_convolve8_avg_scale_c
+
+void aom_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_avg_vert_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_avg_vert_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+RTCD_EXTERN void (*aom_convolve8_avg_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+
+void aom_convolve8_avg_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_vert_scale aom_convolve8_avg_vert_scale_c
+
+void aom_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_horiz_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_horiz_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_horiz_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+RTCD_EXTERN void (*aom_convolve8_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+
+void aom_convolve8_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_horiz_scale aom_convolve8_horiz_scale_c
+
+void aom_convolve8_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_scale aom_convolve8_scale_c
+
+void aom_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_vert_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_vert_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve8_vert_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+RTCD_EXTERN void (*aom_convolve8_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+
+void aom_convolve8_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_vert_scale aom_convolve8_vert_scale_c
+
+void aom_convolve_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+RTCD_EXTERN void (*aom_convolve_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+
+void aom_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_convolve_copy_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+RTCD_EXTERN void (*aom_convolve_copy)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+
+void aom_d117_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x16 aom_d117_predictor_16x16_c
+
+void aom_d117_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x32 aom_d117_predictor_16x32_c
+
+void aom_d117_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x8 aom_d117_predictor_16x8_c
+
+void aom_d117_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_2x2 aom_d117_predictor_2x2_c
+
+void aom_d117_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_32x16 aom_d117_predictor_32x16_c
+
+void aom_d117_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_32x32 aom_d117_predictor_32x32_c
+
+void aom_d117_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_4x4 aom_d117_predictor_4x4_c
+
+void aom_d117_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_4x8 aom_d117_predictor_4x8_c
+
+void aom_d117_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x16 aom_d117_predictor_8x16_c
+
+void aom_d117_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x4 aom_d117_predictor_8x4_c
+
+void aom_d117_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x8 aom_d117_predictor_8x8_c
+
+void aom_d135_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x16 aom_d135_predictor_16x16_c
+
+void aom_d135_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x32 aom_d135_predictor_16x32_c
+
+void aom_d135_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x8 aom_d135_predictor_16x8_c
+
+void aom_d135_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_2x2 aom_d135_predictor_2x2_c
+
+void aom_d135_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_32x16 aom_d135_predictor_32x16_c
+
+void aom_d135_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_32x32 aom_d135_predictor_32x32_c
+
+void aom_d135_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_4x4 aom_d135_predictor_4x4_c
+
+void aom_d135_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_4x8 aom_d135_predictor_4x8_c
+
+void aom_d135_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x16 aom_d135_predictor_8x16_c
+
+void aom_d135_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x4 aom_d135_predictor_8x4_c
+
+void aom_d135_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x8 aom_d135_predictor_8x8_c
+
+void aom_d153_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_d153_predictor_16x16_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_d153_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_d153_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x32 aom_d153_predictor_16x32_c
+
+void aom_d153_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x8 aom_d153_predictor_16x8_c
+
+void aom_d153_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_2x2 aom_d153_predictor_2x2_c
+
+void aom_d153_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_32x16 aom_d153_predictor_32x16_c
+
+void aom_d153_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_d153_predictor_32x32_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_d153_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_d153_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_d153_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_d153_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_d153_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_4x8 aom_d153_predictor_4x8_c
+
+void aom_d153_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x16 aom_d153_predictor_8x16_c
+
+void aom_d153_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x4 aom_d153_predictor_8x4_c
+
+void aom_d153_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_d153_predictor_8x8_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_d153_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_d207e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x16 aom_d207e_predictor_16x16_c
+
+void aom_d207e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x32 aom_d207e_predictor_16x32_c
+
+void aom_d207e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x8 aom_d207e_predictor_16x8_c
+
+void aom_d207e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_2x2 aom_d207e_predictor_2x2_c
+
+void aom_d207e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_32x16 aom_d207e_predictor_32x16_c
+
+void aom_d207e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_32x32 aom_d207e_predictor_32x32_c
+
+void aom_d207e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_4x4 aom_d207e_predictor_4x4_c
+
+void aom_d207e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_4x8 aom_d207e_predictor_4x8_c
+
+void aom_d207e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x16 aom_d207e_predictor_8x16_c
+
+void aom_d207e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x4 aom_d207e_predictor_8x4_c
+
+void aom_d207e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x8 aom_d207e_predictor_8x8_c
+
+void aom_d45e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x16 aom_d45e_predictor_16x16_c
+
+void aom_d45e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x32 aom_d45e_predictor_16x32_c
+
+void aom_d45e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x8 aom_d45e_predictor_16x8_c
+
+void aom_d45e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_2x2 aom_d45e_predictor_2x2_c
+
+void aom_d45e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_32x16 aom_d45e_predictor_32x16_c
+
+void aom_d45e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_32x32 aom_d45e_predictor_32x32_c
+
+void aom_d45e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_4x4 aom_d45e_predictor_4x4_c
+
+void aom_d45e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_4x8 aom_d45e_predictor_4x8_c
+
+void aom_d45e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x16 aom_d45e_predictor_8x16_c
+
+void aom_d45e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x4 aom_d45e_predictor_8x4_c
+
+void aom_d45e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x8 aom_d45e_predictor_8x8_c
+
+void aom_d63e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x16 aom_d63e_predictor_16x16_c
+
+void aom_d63e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x32 aom_d63e_predictor_16x32_c
+
+void aom_d63e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x8 aom_d63e_predictor_16x8_c
+
+void aom_d63e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_2x2 aom_d63e_predictor_2x2_c
+
+void aom_d63e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_32x16 aom_d63e_predictor_32x16_c
+
+void aom_d63e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_32x32 aom_d63e_predictor_32x32_c
+
+void aom_d63e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_d63e_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_d63e_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_d63e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_4x8 aom_d63e_predictor_4x8_c
+
+void aom_d63e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x16 aom_d63e_predictor_8x16_c
+
+void aom_d63e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x4 aom_d63e_predictor_8x4_c
+
+void aom_d63e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x8 aom_d63e_predictor_8x8_c
+
+void aom_dc_128_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_128_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_128_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_128_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x32 aom_dc_128_predictor_16x32_c
+
+void aom_dc_128_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x8 aom_dc_128_predictor_16x8_c
+
+void aom_dc_128_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_2x2 aom_dc_128_predictor_2x2_c
+
+void aom_dc_128_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_32x16 aom_dc_128_predictor_32x16_c
+
+void aom_dc_128_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_128_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_128_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_128_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_128_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_128_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_128_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_4x8 aom_dc_128_predictor_4x8_c
+
+void aom_dc_128_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x16 aom_dc_128_predictor_8x16_c
+
+void aom_dc_128_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x4 aom_dc_128_predictor_8x4_c
+
+void aom_dc_128_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_128_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_128_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_left_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_left_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_left_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_left_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x32 aom_dc_left_predictor_16x32_c
+
+void aom_dc_left_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x8 aom_dc_left_predictor_16x8_c
+
+void aom_dc_left_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_2x2 aom_dc_left_predictor_2x2_c
+
+void aom_dc_left_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_32x16 aom_dc_left_predictor_32x16_c
+
+void aom_dc_left_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_left_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_left_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_left_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_left_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_left_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_left_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_4x8 aom_dc_left_predictor_4x8_c
+
+void aom_dc_left_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x16 aom_dc_left_predictor_8x16_c
+
+void aom_dc_left_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x4 aom_dc_left_predictor_8x4_c
+
+void aom_dc_left_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_left_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_left_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x32 aom_dc_predictor_16x32_c
+
+void aom_dc_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x8 aom_dc_predictor_16x8_c
+
+void aom_dc_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_2x2 aom_dc_predictor_2x2_c
+
+void aom_dc_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_32x16 aom_dc_predictor_32x16_c
+
+void aom_dc_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_4x8 aom_dc_predictor_4x8_c
+
+void aom_dc_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x16 aom_dc_predictor_8x16_c
+
+void aom_dc_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x4 aom_dc_predictor_8x4_c
+
+void aom_dc_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_top_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_top_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_top_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_top_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x32 aom_dc_top_predictor_16x32_c
+
+void aom_dc_top_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x8 aom_dc_top_predictor_16x8_c
+
+void aom_dc_top_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_2x2 aom_dc_top_predictor_2x2_c
+
+void aom_dc_top_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_32x16 aom_dc_top_predictor_32x16_c
+
+void aom_dc_top_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_top_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_top_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_top_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_top_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_top_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_dc_top_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_4x8 aom_dc_top_predictor_4x8_c
+
+void aom_dc_top_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x16 aom_dc_top_predictor_8x16_c
+
+void aom_dc_top_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x4 aom_dc_top_predictor_8x4_c
+
+void aom_dc_top_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_dc_top_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_dc_top_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
+void aom_fdct16x16_sse2(const int16_t *input, tran_low_t *output, int stride);
+RTCD_EXTERN void (*aom_fdct16x16)(const int16_t *input, tran_low_t *output, int stride);
+
+void aom_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
+void aom_fdct32x32_sse2(const int16_t *input, tran_low_t *output, int stride);
+void aom_fdct32x32_avx2(const int16_t *input, tran_low_t *output, int stride);
+RTCD_EXTERN void (*aom_fdct32x32)(const int16_t *input, tran_low_t *output, int stride);
+
+void aom_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
+void aom_fdct32x32_rd_sse2(const int16_t *input, tran_low_t *output, int stride);
+void aom_fdct32x32_rd_avx2(const int16_t *input, tran_low_t *output, int stride);
+RTCD_EXTERN void (*aom_fdct32x32_rd)(const int16_t *input, tran_low_t *output, int stride);
+
+void aom_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
+void aom_fdct4x4_sse2(const int16_t *input, tran_low_t *output, int stride);
+RTCD_EXTERN void (*aom_fdct4x4)(const int16_t *input, tran_low_t *output, int stride);
+
+void aom_fdct4x4_1_c(const int16_t *input, tran_low_t *output, int stride);
+void aom_fdct4x4_1_sse2(const int16_t *input, tran_low_t *output, int stride);
+RTCD_EXTERN void (*aom_fdct4x4_1)(const int16_t *input, tran_low_t *output, int stride);
+
+void aom_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
+void aom_fdct8x8_sse2(const int16_t *input, tran_low_t *output, int stride);
+RTCD_EXTERN void (*aom_fdct8x8)(const int16_t *input, tran_low_t *output, int stride);
+
+void aom_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+void aom_get16x16var_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+void aom_get16x16var_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+RTCD_EXTERN void (*aom_get16x16var)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+
+unsigned int aom_get4x4sse_cs_c(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int ref_stride);
+#define aom_get4x4sse_cs aom_get4x4sse_cs_c
+
+void aom_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+void aom_get8x8var_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+RTCD_EXTERN void (*aom_get8x8var)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+
+unsigned int aom_get_mb_ss_c(const int16_t *);
+unsigned int aom_get_mb_ss_sse2(const int16_t *);
+RTCD_EXTERN unsigned int (*aom_get_mb_ss)(const int16_t *);
+
+void aom_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_h_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_h_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x32 aom_h_predictor_16x32_c
+
+void aom_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x8 aom_h_predictor_16x8_c
+
+void aom_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_2x2 aom_h_predictor_2x2_c
+
+void aom_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_32x16 aom_h_predictor_32x16_c
+
+void aom_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_h_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_h_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_h_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_h_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_4x8 aom_h_predictor_4x8_c
+
+void aom_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x16 aom_h_predictor_8x16_c
+
+void aom_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x4 aom_h_predictor_8x4_c
+
+void aom_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_h_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_h_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_hadamard_16x16_c(const int16_t *src_diff, int src_stride, int16_t *coeff);
+void aom_hadamard_16x16_sse2(const int16_t *src_diff, int src_stride, int16_t *coeff);
+RTCD_EXTERN void (*aom_hadamard_16x16)(const int16_t *src_diff, int src_stride, int16_t *coeff);
+
+void aom_hadamard_8x8_c(const int16_t *src_diff, int src_stride, int16_t *coeff);
+void aom_hadamard_8x8_sse2(const int16_t *src_diff, int src_stride, int16_t *coeff);
+RTCD_EXTERN void (*aom_hadamard_8x8)(const int16_t *src_diff, int src_stride, int16_t *coeff);
+
+void aom_highbd_10_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+#define aom_highbd_10_get16x16var aom_highbd_10_get16x16var_c
+
+void aom_highbd_10_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+#define aom_highbd_10_get8x8var aom_highbd_10_get8x8var_c
+
+unsigned int aom_highbd_10_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+unsigned int aom_highbd_10_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+
+unsigned int aom_highbd_10_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+#define aom_highbd_10_mse16x8 aom_highbd_10_mse16x8_c
+
+unsigned int aom_highbd_10_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+#define aom_highbd_10_mse8x16 aom_highbd_10_mse8x16_c
+
+unsigned int aom_highbd_10_mse8x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+unsigned int aom_highbd_10_mse8x8_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_mse8x8)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance16x16_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance16x16 aom_highbd_10_obmc_sub_pixel_variance16x16_c
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance16x32_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance16x32 aom_highbd_10_obmc_sub_pixel_variance16x32_c
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance16x8_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance16x8 aom_highbd_10_obmc_sub_pixel_variance16x8_c
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance32x16_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance32x16 aom_highbd_10_obmc_sub_pixel_variance32x16_c
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance32x32_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance32x32 aom_highbd_10_obmc_sub_pixel_variance32x32_c
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance32x64_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance32x64 aom_highbd_10_obmc_sub_pixel_variance32x64_c
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance4x4_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance4x4 aom_highbd_10_obmc_sub_pixel_variance4x4_c
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance4x8_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance4x8 aom_highbd_10_obmc_sub_pixel_variance4x8_c
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance64x32_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance64x32 aom_highbd_10_obmc_sub_pixel_variance64x32_c
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance64x64_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance64x64 aom_highbd_10_obmc_sub_pixel_variance64x64_c
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance8x16_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance8x16 aom_highbd_10_obmc_sub_pixel_variance8x16_c
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance8x4_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance8x4 aom_highbd_10_obmc_sub_pixel_variance8x4_c
+
+unsigned int aom_highbd_10_obmc_sub_pixel_variance8x8_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_10_obmc_sub_pixel_variance8x8 aom_highbd_10_obmc_sub_pixel_variance8x8_c
+
+unsigned int aom_highbd_10_obmc_variance16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance16x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance16x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_variance16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance16x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance16x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_variance16x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance16x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance16x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_variance32x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance32x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance32x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_variance32x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance32x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance32x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_variance32x64_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance32x64_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance32x64)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_variance4x4_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance4x4_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance4x4)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_variance4x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance4x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance4x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_variance64x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance64x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance64x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_variance64x64_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance64x64_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance64x64)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_variance8x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance8x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance8x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_variance8x4_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance8x4_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance8x4)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_10_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_10_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_10_sub_pixel_avg_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_avg_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_10_sub_pixel_avg_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_avg_variance16x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance16x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_10_sub_pixel_avg_variance16x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_avg_variance16x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance32x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_10_sub_pixel_avg_variance32x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_avg_variance32x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance32x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_10_sub_pixel_avg_variance32x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_avg_variance32x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance32x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_10_sub_pixel_avg_variance32x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_avg_variance32x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance4x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_10_sub_pixel_avg_variance4x4_sse4_1(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_avg_variance4x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance4x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+#define aom_highbd_10_sub_pixel_avg_variance4x8 aom_highbd_10_sub_pixel_avg_variance4x8_c
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance64x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_10_sub_pixel_avg_variance64x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_avg_variance64x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance64x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_10_sub_pixel_avg_variance64x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_avg_variance64x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance8x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_10_sub_pixel_avg_variance8x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_avg_variance8x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance8x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_10_sub_pixel_avg_variance8x4_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_avg_variance8x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_10_sub_pixel_avg_variance8x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_10_sub_pixel_avg_variance8x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_avg_variance8x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_10_sub_pixel_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_10_sub_pixel_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_10_sub_pixel_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_10_sub_pixel_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_variance16x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_10_sub_pixel_variance16x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_10_sub_pixel_variance16x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_variance16x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_10_sub_pixel_variance32x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_10_sub_pixel_variance32x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_variance32x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_10_sub_pixel_variance32x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_10_sub_pixel_variance32x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_variance32x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_10_sub_pixel_variance32x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_10_sub_pixel_variance32x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_variance32x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_10_sub_pixel_variance4x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_10_sub_pixel_variance4x4_sse4_1(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_variance4x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_10_sub_pixel_variance4x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+#define aom_highbd_10_sub_pixel_variance4x8 aom_highbd_10_sub_pixel_variance4x8_c
+
+uint32_t aom_highbd_10_sub_pixel_variance64x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_10_sub_pixel_variance64x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_variance64x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_10_sub_pixel_variance64x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_10_sub_pixel_variance64x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_variance64x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_10_sub_pixel_variance8x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_10_sub_pixel_variance8x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_variance8x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_10_sub_pixel_variance8x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_10_sub_pixel_variance8x4_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_variance8x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_10_sub_pixel_variance8x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_10_sub_pixel_variance8x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_10_sub_pixel_variance8x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+unsigned int aom_highbd_10_variance16x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_10_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_variance16x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_10_variance16x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_10_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_variance16x32)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_10_variance16x8_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_10_variance16x8_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_variance16x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_10_variance2x2_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_10_variance2x2 aom_highbd_10_variance2x2_c
+
+unsigned int aom_highbd_10_variance2x4_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_10_variance2x4 aom_highbd_10_variance2x4_c
+
+unsigned int aom_highbd_10_variance32x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_10_variance32x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_variance32x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_10_variance32x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_10_variance32x32_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_variance32x32)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_10_variance32x64_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_10_variance32x64_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_variance32x64)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_10_variance4x2_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_10_variance4x2 aom_highbd_10_variance4x2_c
+
+unsigned int aom_highbd_10_variance4x4_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_10_variance4x4_sse4_1(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_variance4x4)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_10_variance4x8_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_10_variance4x8 aom_highbd_10_variance4x8_c
+
+unsigned int aom_highbd_10_variance64x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_10_variance64x32_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_variance64x32)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_10_variance64x64_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_10_variance64x64_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_variance64x64)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_10_variance8x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_10_variance8x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_variance8x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_10_variance8x4_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_10_variance8x4 aom_highbd_10_variance8x4_c
+
+unsigned int aom_highbd_10_variance8x8_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_10_variance8x8_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_10_variance8x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+void aom_highbd_12_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+#define aom_highbd_12_get16x16var aom_highbd_12_get16x16var_c
+
+void aom_highbd_12_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+#define aom_highbd_12_get8x8var aom_highbd_12_get8x8var_c
+
+unsigned int aom_highbd_12_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+unsigned int aom_highbd_12_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+
+unsigned int aom_highbd_12_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+#define aom_highbd_12_mse16x8 aom_highbd_12_mse16x8_c
+
+unsigned int aom_highbd_12_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+#define aom_highbd_12_mse8x16 aom_highbd_12_mse8x16_c
+
+unsigned int aom_highbd_12_mse8x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+unsigned int aom_highbd_12_mse8x8_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_mse8x8)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance16x16_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance16x16 aom_highbd_12_obmc_sub_pixel_variance16x16_c
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance16x32_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance16x32 aom_highbd_12_obmc_sub_pixel_variance16x32_c
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance16x8_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance16x8 aom_highbd_12_obmc_sub_pixel_variance16x8_c
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance32x16_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance32x16 aom_highbd_12_obmc_sub_pixel_variance32x16_c
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance32x32_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance32x32 aom_highbd_12_obmc_sub_pixel_variance32x32_c
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance32x64_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance32x64 aom_highbd_12_obmc_sub_pixel_variance32x64_c
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance4x4_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance4x4 aom_highbd_12_obmc_sub_pixel_variance4x4_c
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance4x8_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance4x8 aom_highbd_12_obmc_sub_pixel_variance4x8_c
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance64x32_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance64x32 aom_highbd_12_obmc_sub_pixel_variance64x32_c
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance64x64_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance64x64 aom_highbd_12_obmc_sub_pixel_variance64x64_c
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance8x16_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance8x16 aom_highbd_12_obmc_sub_pixel_variance8x16_c
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance8x4_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance8x4 aom_highbd_12_obmc_sub_pixel_variance8x4_c
+
+unsigned int aom_highbd_12_obmc_sub_pixel_variance8x8_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_12_obmc_sub_pixel_variance8x8 aom_highbd_12_obmc_sub_pixel_variance8x8_c
+
+unsigned int aom_highbd_12_obmc_variance16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance16x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance16x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_variance16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance16x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance16x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_variance16x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance16x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance16x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_variance32x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance32x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance32x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_variance32x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance32x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance32x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_variance32x64_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance32x64_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance32x64)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_variance4x4_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance4x4_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance4x4)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_variance4x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance4x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance4x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_variance64x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance64x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance64x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_variance64x64_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance64x64_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance64x64)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_variance8x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance8x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance8x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_variance8x4_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance8x4_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance8x4)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_12_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_12_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_12_sub_pixel_avg_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_avg_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_12_sub_pixel_avg_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_avg_variance16x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance16x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_12_sub_pixel_avg_variance16x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_avg_variance16x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance32x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_12_sub_pixel_avg_variance32x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_avg_variance32x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance32x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_12_sub_pixel_avg_variance32x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_avg_variance32x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance32x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_12_sub_pixel_avg_variance32x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_avg_variance32x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance4x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_12_sub_pixel_avg_variance4x4_sse4_1(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_avg_variance4x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance4x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+#define aom_highbd_12_sub_pixel_avg_variance4x8 aom_highbd_12_sub_pixel_avg_variance4x8_c
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance64x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_12_sub_pixel_avg_variance64x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_avg_variance64x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance64x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_12_sub_pixel_avg_variance64x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_avg_variance64x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance8x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_12_sub_pixel_avg_variance8x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_avg_variance8x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance8x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_12_sub_pixel_avg_variance8x4_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_avg_variance8x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_12_sub_pixel_avg_variance8x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_12_sub_pixel_avg_variance8x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_avg_variance8x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_12_sub_pixel_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_12_sub_pixel_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_12_sub_pixel_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_12_sub_pixel_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_variance16x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_12_sub_pixel_variance16x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_12_sub_pixel_variance16x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_variance16x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_12_sub_pixel_variance32x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_12_sub_pixel_variance32x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_variance32x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_12_sub_pixel_variance32x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_12_sub_pixel_variance32x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_variance32x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_12_sub_pixel_variance32x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_12_sub_pixel_variance32x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_variance32x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_12_sub_pixel_variance4x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_12_sub_pixel_variance4x4_sse4_1(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_variance4x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_12_sub_pixel_variance4x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+#define aom_highbd_12_sub_pixel_variance4x8 aom_highbd_12_sub_pixel_variance4x8_c
+
+uint32_t aom_highbd_12_sub_pixel_variance64x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_12_sub_pixel_variance64x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_variance64x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_12_sub_pixel_variance64x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_12_sub_pixel_variance64x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_variance64x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_12_sub_pixel_variance8x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_12_sub_pixel_variance8x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_variance8x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_12_sub_pixel_variance8x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_12_sub_pixel_variance8x4_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_variance8x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_12_sub_pixel_variance8x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_12_sub_pixel_variance8x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_12_sub_pixel_variance8x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+unsigned int aom_highbd_12_variance16x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_12_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_variance16x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_12_variance16x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_12_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_variance16x32)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_12_variance16x8_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_12_variance16x8_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_variance16x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_12_variance2x2_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_12_variance2x2 aom_highbd_12_variance2x2_c
+
+unsigned int aom_highbd_12_variance2x4_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_12_variance2x4 aom_highbd_12_variance2x4_c
+
+unsigned int aom_highbd_12_variance32x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_12_variance32x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_variance32x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_12_variance32x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_12_variance32x32_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_variance32x32)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_12_variance32x64_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_12_variance32x64_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_variance32x64)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_12_variance4x2_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_12_variance4x2 aom_highbd_12_variance4x2_c
+
+unsigned int aom_highbd_12_variance4x4_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_12_variance4x4_sse4_1(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_variance4x4)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_12_variance4x8_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_12_variance4x8 aom_highbd_12_variance4x8_c
+
+unsigned int aom_highbd_12_variance64x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_12_variance64x32_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_variance64x32)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_12_variance64x64_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_12_variance64x64_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_variance64x64)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_12_variance8x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_12_variance8x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_variance8x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_12_variance8x4_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_12_variance8x4 aom_highbd_12_variance8x4_c
+
+unsigned int aom_highbd_12_variance8x8_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_12_variance8x8_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_12_variance8x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+void aom_highbd_8_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+#define aom_highbd_8_get16x16var aom_highbd_8_get16x16var_c
+
+void aom_highbd_8_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
+#define aom_highbd_8_get8x8var aom_highbd_8_get8x8var_c
+
+unsigned int aom_highbd_8_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+unsigned int aom_highbd_8_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+
+unsigned int aom_highbd_8_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+#define aom_highbd_8_mse16x8 aom_highbd_8_mse16x8_c
+
+unsigned int aom_highbd_8_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+#define aom_highbd_8_mse8x16 aom_highbd_8_mse8x16_c
+
+unsigned int aom_highbd_8_mse8x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+unsigned int aom_highbd_8_mse8x8_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_mse8x8)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_8_sub_pixel_avg_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_avg_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_8_sub_pixel_avg_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_avg_variance16x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance16x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_8_sub_pixel_avg_variance16x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_avg_variance16x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance32x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_8_sub_pixel_avg_variance32x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_avg_variance32x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance32x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_8_sub_pixel_avg_variance32x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_avg_variance32x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance32x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_8_sub_pixel_avg_variance32x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_avg_variance32x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance4x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_8_sub_pixel_avg_variance4x4_sse4_1(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_avg_variance4x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance4x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+#define aom_highbd_8_sub_pixel_avg_variance4x8 aom_highbd_8_sub_pixel_avg_variance4x8_c
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance64x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_8_sub_pixel_avg_variance64x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_avg_variance64x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance64x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_8_sub_pixel_avg_variance64x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_avg_variance64x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance8x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_8_sub_pixel_avg_variance8x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_avg_variance8x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance8x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_8_sub_pixel_avg_variance8x4_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_avg_variance8x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_8_sub_pixel_avg_variance8x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_highbd_8_sub_pixel_avg_variance8x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_avg_variance8x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_highbd_8_sub_pixel_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_8_sub_pixel_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_8_sub_pixel_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_8_sub_pixel_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_variance16x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_8_sub_pixel_variance16x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_8_sub_pixel_variance16x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_variance16x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_8_sub_pixel_variance32x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_8_sub_pixel_variance32x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_variance32x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_8_sub_pixel_variance32x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_8_sub_pixel_variance32x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_variance32x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_8_sub_pixel_variance32x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_8_sub_pixel_variance32x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_variance32x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_8_sub_pixel_variance4x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_8_sub_pixel_variance4x4_sse4_1(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_variance4x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_8_sub_pixel_variance4x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+#define aom_highbd_8_sub_pixel_variance4x8 aom_highbd_8_sub_pixel_variance4x8_c
+
+uint32_t aom_highbd_8_sub_pixel_variance64x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_8_sub_pixel_variance64x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_variance64x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_8_sub_pixel_variance64x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_8_sub_pixel_variance64x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_variance64x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_8_sub_pixel_variance8x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_8_sub_pixel_variance8x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_variance8x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_8_sub_pixel_variance8x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_8_sub_pixel_variance8x4_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_variance8x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_highbd_8_sub_pixel_variance8x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_highbd_8_sub_pixel_variance8x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_highbd_8_sub_pixel_variance8x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+unsigned int aom_highbd_8_variance16x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_8_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_variance16x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_8_variance16x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_8_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_variance16x32)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_8_variance16x8_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_8_variance16x8_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_variance16x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_8_variance2x2_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_8_variance2x2 aom_highbd_8_variance2x2_c
+
+unsigned int aom_highbd_8_variance2x4_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_8_variance2x4 aom_highbd_8_variance2x4_c
+
+unsigned int aom_highbd_8_variance32x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_8_variance32x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_variance32x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_8_variance32x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_8_variance32x32_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_variance32x32)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_8_variance32x64_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_8_variance32x64_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_variance32x64)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_8_variance4x2_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_8_variance4x2 aom_highbd_8_variance4x2_c
+
+unsigned int aom_highbd_8_variance4x4_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_8_variance4x4_sse4_1(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_variance4x4)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_8_variance4x8_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_8_variance4x8 aom_highbd_8_variance4x8_c
+
+unsigned int aom_highbd_8_variance64x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_8_variance64x32_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_variance64x32)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_8_variance64x64_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_8_variance64x64_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_variance64x64)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_8_variance8x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_8_variance8x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_variance8x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_highbd_8_variance8x4_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_highbd_8_variance8x4 aom_highbd_8_variance8x4_c
+
+unsigned int aom_highbd_8_variance8x8_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_highbd_8_variance8x8_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_8_variance8x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+void aom_highbd_blend_a64_hmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
+void aom_highbd_blend_a64_hmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
+RTCD_EXTERN void (*aom_highbd_blend_a64_hmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
+
+void aom_highbd_blend_a64_mask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, uint32_t mask_stride, int h, int w, int suby, int subx, int bd);
+void aom_highbd_blend_a64_mask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, uint32_t mask_stride, int h, int w, int suby, int subx, int bd);
+RTCD_EXTERN void (*aom_highbd_blend_a64_mask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, uint32_t mask_stride, int h, int w, int suby, int subx, int bd);
+
+void aom_highbd_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
+void aom_highbd_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
+RTCD_EXTERN void (*aom_highbd_blend_a64_vmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
+
+void aom_highbd_comp_avg_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
+#define aom_highbd_comp_avg_pred aom_highbd_comp_avg_pred_c
+
+void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+void aom_highbd_comp_avg_upsampled_pred_sse2(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+RTCD_EXTERN void (*aom_highbd_comp_avg_upsampled_pred)(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+
+void aom_highbd_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+void aom_highbd_convolve8_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+RTCD_EXTERN void (*aom_highbd_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+
+void aom_highbd_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+void aom_highbd_convolve8_avg_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+RTCD_EXTERN void (*aom_highbd_convolve8_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+
+void aom_highbd_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+void aom_highbd_convolve8_avg_horiz_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+RTCD_EXTERN void (*aom_highbd_convolve8_avg_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+
+void aom_highbd_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+void aom_highbd_convolve8_avg_vert_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+RTCD_EXTERN void (*aom_highbd_convolve8_avg_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+
+void aom_highbd_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+void aom_highbd_convolve8_horiz_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+RTCD_EXTERN void (*aom_highbd_convolve8_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+
+void aom_highbd_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+void aom_highbd_convolve8_vert_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+RTCD_EXTERN void (*aom_highbd_convolve8_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+
+void aom_highbd_convolve_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+void aom_highbd_convolve_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+void aom_highbd_convolve_avg_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+RTCD_EXTERN void (*aom_highbd_convolve_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+
+void aom_highbd_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+void aom_highbd_convolve_copy_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+void aom_highbd_convolve_copy_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+RTCD_EXTERN void (*aom_highbd_convolve_copy)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+
+void aom_highbd_d117_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x16 aom_highbd_d117_predictor_16x16_c
+
+void aom_highbd_d117_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x32 aom_highbd_d117_predictor_16x32_c
+
+void aom_highbd_d117_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x8 aom_highbd_d117_predictor_16x8_c
+
+void aom_highbd_d117_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_2x2 aom_highbd_d117_predictor_2x2_c
+
+void aom_highbd_d117_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_32x16 aom_highbd_d117_predictor_32x16_c
+
+void aom_highbd_d117_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_32x32 aom_highbd_d117_predictor_32x32_c
+
+void aom_highbd_d117_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_4x4 aom_highbd_d117_predictor_4x4_c
+
+void aom_highbd_d117_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_4x8 aom_highbd_d117_predictor_4x8_c
+
+void aom_highbd_d117_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x16 aom_highbd_d117_predictor_8x16_c
+
+void aom_highbd_d117_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x4 aom_highbd_d117_predictor_8x4_c
+
+void aom_highbd_d117_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x8 aom_highbd_d117_predictor_8x8_c
+
+void aom_highbd_d135_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x16 aom_highbd_d135_predictor_16x16_c
+
+void aom_highbd_d135_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x32 aom_highbd_d135_predictor_16x32_c
+
+void aom_highbd_d135_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x8 aom_highbd_d135_predictor_16x8_c
+
+void aom_highbd_d135_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_2x2 aom_highbd_d135_predictor_2x2_c
+
+void aom_highbd_d135_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_32x16 aom_highbd_d135_predictor_32x16_c
+
+void aom_highbd_d135_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_32x32 aom_highbd_d135_predictor_32x32_c
+
+void aom_highbd_d135_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_4x4 aom_highbd_d135_predictor_4x4_c
+
+void aom_highbd_d135_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_4x8 aom_highbd_d135_predictor_4x8_c
+
+void aom_highbd_d135_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x16 aom_highbd_d135_predictor_8x16_c
+
+void aom_highbd_d135_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x4 aom_highbd_d135_predictor_8x4_c
+
+void aom_highbd_d135_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x8 aom_highbd_d135_predictor_8x8_c
+
+void aom_highbd_d153_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x16 aom_highbd_d153_predictor_16x16_c
+
+void aom_highbd_d153_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x32 aom_highbd_d153_predictor_16x32_c
+
+void aom_highbd_d153_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x8 aom_highbd_d153_predictor_16x8_c
+
+void aom_highbd_d153_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_2x2 aom_highbd_d153_predictor_2x2_c
+
+void aom_highbd_d153_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_32x16 aom_highbd_d153_predictor_32x16_c
+
+void aom_highbd_d153_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_32x32 aom_highbd_d153_predictor_32x32_c
+
+void aom_highbd_d153_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_4x4 aom_highbd_d153_predictor_4x4_c
+
+void aom_highbd_d153_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_4x8 aom_highbd_d153_predictor_4x8_c
+
+void aom_highbd_d153_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x16 aom_highbd_d153_predictor_8x16_c
+
+void aom_highbd_d153_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x4 aom_highbd_d153_predictor_8x4_c
+
+void aom_highbd_d153_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x8 aom_highbd_d153_predictor_8x8_c
+
+void aom_highbd_d207e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x16 aom_highbd_d207e_predictor_16x16_c
+
+void aom_highbd_d207e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x32 aom_highbd_d207e_predictor_16x32_c
+
+void aom_highbd_d207e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x8 aom_highbd_d207e_predictor_16x8_c
+
+void aom_highbd_d207e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_2x2 aom_highbd_d207e_predictor_2x2_c
+
+void aom_highbd_d207e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_32x16 aom_highbd_d207e_predictor_32x16_c
+
+void aom_highbd_d207e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_32x32 aom_highbd_d207e_predictor_32x32_c
+
+void aom_highbd_d207e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_4x4 aom_highbd_d207e_predictor_4x4_c
+
+void aom_highbd_d207e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_4x8 aom_highbd_d207e_predictor_4x8_c
+
+void aom_highbd_d207e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x16 aom_highbd_d207e_predictor_8x16_c
+
+void aom_highbd_d207e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x4 aom_highbd_d207e_predictor_8x4_c
+
+void aom_highbd_d207e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x8 aom_highbd_d207e_predictor_8x8_c
+
+void aom_highbd_d45e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x16 aom_highbd_d45e_predictor_16x16_c
+
+void aom_highbd_d45e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x32 aom_highbd_d45e_predictor_16x32_c
+
+void aom_highbd_d45e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x8 aom_highbd_d45e_predictor_16x8_c
+
+void aom_highbd_d45e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_2x2 aom_highbd_d45e_predictor_2x2_c
+
+void aom_highbd_d45e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_32x16 aom_highbd_d45e_predictor_32x16_c
+
+void aom_highbd_d45e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_32x32 aom_highbd_d45e_predictor_32x32_c
+
+void aom_highbd_d45e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_4x4 aom_highbd_d45e_predictor_4x4_c
+
+void aom_highbd_d45e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_4x8 aom_highbd_d45e_predictor_4x8_c
+
+void aom_highbd_d45e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x16 aom_highbd_d45e_predictor_8x16_c
+
+void aom_highbd_d45e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x4 aom_highbd_d45e_predictor_8x4_c
+
+void aom_highbd_d45e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x8 aom_highbd_d45e_predictor_8x8_c
+
+void aom_highbd_d63e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x16 aom_highbd_d63e_predictor_16x16_c
+
+void aom_highbd_d63e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x32 aom_highbd_d63e_predictor_16x32_c
+
+void aom_highbd_d63e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x8 aom_highbd_d63e_predictor_16x8_c
+
+void aom_highbd_d63e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_2x2 aom_highbd_d63e_predictor_2x2_c
+
+void aom_highbd_d63e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_32x16 aom_highbd_d63e_predictor_32x16_c
+
+void aom_highbd_d63e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_32x32 aom_highbd_d63e_predictor_32x32_c
+
+void aom_highbd_d63e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_4x4 aom_highbd_d63e_predictor_4x4_c
+
+void aom_highbd_d63e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_4x8 aom_highbd_d63e_predictor_4x8_c
+
+void aom_highbd_d63e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x16 aom_highbd_d63e_predictor_8x16_c
+
+void aom_highbd_d63e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x4 aom_highbd_d63e_predictor_8x4_c
+
+void aom_highbd_d63e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x8 aom_highbd_d63e_predictor_8x8_c
+
+void aom_highbd_dc_128_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x16 aom_highbd_dc_128_predictor_16x16_c
+
+void aom_highbd_dc_128_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x32 aom_highbd_dc_128_predictor_16x32_c
+
+void aom_highbd_dc_128_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x8 aom_highbd_dc_128_predictor_16x8_c
+
+void aom_highbd_dc_128_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_2x2 aom_highbd_dc_128_predictor_2x2_c
+
+void aom_highbd_dc_128_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_32x16 aom_highbd_dc_128_predictor_32x16_c
+
+void aom_highbd_dc_128_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_32x32 aom_highbd_dc_128_predictor_32x32_c
+
+void aom_highbd_dc_128_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_4x4 aom_highbd_dc_128_predictor_4x4_c
+
+void aom_highbd_dc_128_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_4x8 aom_highbd_dc_128_predictor_4x8_c
+
+void aom_highbd_dc_128_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x16 aom_highbd_dc_128_predictor_8x16_c
+
+void aom_highbd_dc_128_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x4 aom_highbd_dc_128_predictor_8x4_c
+
+void aom_highbd_dc_128_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x8 aom_highbd_dc_128_predictor_8x8_c
+
+void aom_highbd_dc_left_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x16 aom_highbd_dc_left_predictor_16x16_c
+
+void aom_highbd_dc_left_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x32 aom_highbd_dc_left_predictor_16x32_c
+
+void aom_highbd_dc_left_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x8 aom_highbd_dc_left_predictor_16x8_c
+
+void aom_highbd_dc_left_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_2x2 aom_highbd_dc_left_predictor_2x2_c
+
+void aom_highbd_dc_left_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_32x16 aom_highbd_dc_left_predictor_32x16_c
+
+void aom_highbd_dc_left_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_32x32 aom_highbd_dc_left_predictor_32x32_c
+
+void aom_highbd_dc_left_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_4x4 aom_highbd_dc_left_predictor_4x4_c
+
+void aom_highbd_dc_left_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_4x8 aom_highbd_dc_left_predictor_4x8_c
+
+void aom_highbd_dc_left_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x16 aom_highbd_dc_left_predictor_8x16_c
+
+void aom_highbd_dc_left_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x4 aom_highbd_dc_left_predictor_8x4_c
+
+void aom_highbd_dc_left_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x8 aom_highbd_dc_left_predictor_8x8_c
+
+void aom_highbd_dc_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+void aom_highbd_dc_predictor_16x16_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+RTCD_EXTERN void (*aom_highbd_dc_predictor_16x16)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+
+void aom_highbd_dc_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x32 aom_highbd_dc_predictor_16x32_c
+
+void aom_highbd_dc_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x8 aom_highbd_dc_predictor_16x8_c
+
+void aom_highbd_dc_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_2x2 aom_highbd_dc_predictor_2x2_c
+
+void aom_highbd_dc_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_32x16 aom_highbd_dc_predictor_32x16_c
+
+void aom_highbd_dc_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+void aom_highbd_dc_predictor_32x32_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+RTCD_EXTERN void (*aom_highbd_dc_predictor_32x32)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+
+void aom_highbd_dc_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+void aom_highbd_dc_predictor_4x4_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+RTCD_EXTERN void (*aom_highbd_dc_predictor_4x4)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+
+void aom_highbd_dc_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_4x8 aom_highbd_dc_predictor_4x8_c
+
+void aom_highbd_dc_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x16 aom_highbd_dc_predictor_8x16_c
+
+void aom_highbd_dc_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x4 aom_highbd_dc_predictor_8x4_c
+
+void aom_highbd_dc_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+void aom_highbd_dc_predictor_8x8_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+RTCD_EXTERN void (*aom_highbd_dc_predictor_8x8)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+
+void aom_highbd_dc_top_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x16 aom_highbd_dc_top_predictor_16x16_c
+
+void aom_highbd_dc_top_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x32 aom_highbd_dc_top_predictor_16x32_c
+
+void aom_highbd_dc_top_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x8 aom_highbd_dc_top_predictor_16x8_c
+
+void aom_highbd_dc_top_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_2x2 aom_highbd_dc_top_predictor_2x2_c
+
+void aom_highbd_dc_top_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_32x16 aom_highbd_dc_top_predictor_32x16_c
+
+void aom_highbd_dc_top_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_32x32 aom_highbd_dc_top_predictor_32x32_c
+
+void aom_highbd_dc_top_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_4x4 aom_highbd_dc_top_predictor_4x4_c
+
+void aom_highbd_dc_top_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_4x8 aom_highbd_dc_top_predictor_4x8_c
+
+void aom_highbd_dc_top_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x16 aom_highbd_dc_top_predictor_8x16_c
+
+void aom_highbd_dc_top_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x4 aom_highbd_dc_top_predictor_8x4_c
+
+void aom_highbd_dc_top_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x8 aom_highbd_dc_top_predictor_8x8_c
+
+void aom_highbd_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
+void aom_highbd_fdct16x16_sse2(const int16_t *input, tran_low_t *output, int stride);
+RTCD_EXTERN void (*aom_highbd_fdct16x16)(const int16_t *input, tran_low_t *output, int stride);
+
+void aom_highbd_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
+void aom_highbd_fdct32x32_sse2(const int16_t *input, tran_low_t *output, int stride);
+RTCD_EXTERN void (*aom_highbd_fdct32x32)(const int16_t *input, tran_low_t *output, int stride);
+
+void aom_highbd_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
+void aom_highbd_fdct32x32_rd_sse2(const int16_t *input, tran_low_t *output, int stride);
+RTCD_EXTERN void (*aom_highbd_fdct32x32_rd)(const int16_t *input, tran_low_t *output, int stride);
+
+void aom_highbd_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
+void aom_highbd_fdct4x4_sse2(const int16_t *input, tran_low_t *output, int stride);
+RTCD_EXTERN void (*aom_highbd_fdct4x4)(const int16_t *input, tran_low_t *output, int stride);
+
+void aom_highbd_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
+void aom_highbd_fdct8x8_sse2(const int16_t *input, tran_low_t *output, int stride);
+RTCD_EXTERN void (*aom_highbd_fdct8x8)(const int16_t *input, tran_low_t *output, int stride);
+
+void aom_highbd_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x16 aom_highbd_h_predictor_16x16_c
+
+void aom_highbd_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x32 aom_highbd_h_predictor_16x32_c
+
+void aom_highbd_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x8 aom_highbd_h_predictor_16x8_c
+
+void aom_highbd_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_2x2 aom_highbd_h_predictor_2x2_c
+
+void aom_highbd_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_32x16 aom_highbd_h_predictor_32x16_c
+
+void aom_highbd_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_32x32 aom_highbd_h_predictor_32x32_c
+
+void aom_highbd_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_4x4 aom_highbd_h_predictor_4x4_c
+
+void aom_highbd_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_4x8 aom_highbd_h_predictor_4x8_c
+
+void aom_highbd_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x16 aom_highbd_h_predictor_8x16_c
+
+void aom_highbd_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x4 aom_highbd_h_predictor_8x4_c
+
+void aom_highbd_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x8 aom_highbd_h_predictor_8x8_c
+
+void aom_highbd_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
+#define aom_highbd_iwht4x4_16_add aom_highbd_iwht4x4_16_add_c
+
+void aom_highbd_iwht4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
+#define aom_highbd_iwht4x4_1_add aom_highbd_iwht4x4_1_add_c
+
+void aom_highbd_lpf_horizontal_4_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+void aom_highbd_lpf_horizontal_4_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+RTCD_EXTERN void (*aom_highbd_lpf_horizontal_4)(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+
+void aom_highbd_lpf_horizontal_4_dual_c(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
+void aom_highbd_lpf_horizontal_4_dual_sse2(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
+RTCD_EXTERN void (*aom_highbd_lpf_horizontal_4_dual)(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
+
+void aom_highbd_lpf_horizontal_8_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+void aom_highbd_lpf_horizontal_8_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+RTCD_EXTERN void (*aom_highbd_lpf_horizontal_8)(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+
+void aom_highbd_lpf_horizontal_8_dual_c(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
+void aom_highbd_lpf_horizontal_8_dual_sse2(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
+RTCD_EXTERN void (*aom_highbd_lpf_horizontal_8_dual)(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
+
+void aom_highbd_lpf_horizontal_edge_16_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+void aom_highbd_lpf_horizontal_edge_16_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+RTCD_EXTERN void (*aom_highbd_lpf_horizontal_edge_16)(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+
+void aom_highbd_lpf_horizontal_edge_8_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+void aom_highbd_lpf_horizontal_edge_8_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+RTCD_EXTERN void (*aom_highbd_lpf_horizontal_edge_8)(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+
+void aom_highbd_lpf_vertical_16_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+void aom_highbd_lpf_vertical_16_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+RTCD_EXTERN void (*aom_highbd_lpf_vertical_16)(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+
+void aom_highbd_lpf_vertical_16_dual_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+void aom_highbd_lpf_vertical_16_dual_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+RTCD_EXTERN void (*aom_highbd_lpf_vertical_16_dual)(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+
+void aom_highbd_lpf_vertical_4_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+void aom_highbd_lpf_vertical_4_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+RTCD_EXTERN void (*aom_highbd_lpf_vertical_4)(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+
+void aom_highbd_lpf_vertical_4_dual_c(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
+void aom_highbd_lpf_vertical_4_dual_sse2(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
+RTCD_EXTERN void (*aom_highbd_lpf_vertical_4_dual)(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
+
+void aom_highbd_lpf_vertical_8_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+void aom_highbd_lpf_vertical_8_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+RTCD_EXTERN void (*aom_highbd_lpf_vertical_8)(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
+
+void aom_highbd_lpf_vertical_8_dual_c(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
+void aom_highbd_lpf_vertical_8_dual_sse2(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
+RTCD_EXTERN void (*aom_highbd_lpf_vertical_8_dual)(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
+
+void aom_highbd_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
+#define aom_highbd_minmax_8x8 aom_highbd_minmax_8x8_c
+
+unsigned int aom_highbd_obmc_sad16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad16x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad16x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sad16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad16x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad16x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sad16x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad16x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad16x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sad32x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad32x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad32x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sad32x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad32x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad32x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sad32x64_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad32x64_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad32x64)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sad4x4_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad4x4_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad4x4)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sad4x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad4x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad4x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sad64x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad64x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad64x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sad64x64_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad64x64_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad64x64)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sad8x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad8x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad8x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sad8x4_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad8x4_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad8x4)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sad8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_highbd_obmc_sad8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_highbd_obmc_sub_pixel_variance16x16_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance16x16 aom_highbd_obmc_sub_pixel_variance16x16_c
+
+unsigned int aom_highbd_obmc_sub_pixel_variance16x32_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance16x32 aom_highbd_obmc_sub_pixel_variance16x32_c
+
+unsigned int aom_highbd_obmc_sub_pixel_variance16x8_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance16x8 aom_highbd_obmc_sub_pixel_variance16x8_c
+
+unsigned int aom_highbd_obmc_sub_pixel_variance32x16_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance32x16 aom_highbd_obmc_sub_pixel_variance32x16_c
+
+unsigned int aom_highbd_obmc_sub_pixel_variance32x32_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance32x32 aom_highbd_obmc_sub_pixel_variance32x32_c
+
+unsigned int aom_highbd_obmc_sub_pixel_variance32x64_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance32x64 aom_highbd_obmc_sub_pixel_variance32x64_c
+
+unsigned int aom_highbd_obmc_sub_pixel_variance4x4_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance4x4 aom_highbd_obmc_sub_pixel_variance4x4_c
+
+unsigned int aom_highbd_obmc_sub_pixel_variance4x8_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance4x8 aom_highbd_obmc_sub_pixel_variance4x8_c
+
+unsigned int aom_highbd_obmc_sub_pixel_variance64x32_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance64x32 aom_highbd_obmc_sub_pixel_variance64x32_c
+
+unsigned int aom_highbd_obmc_sub_pixel_variance64x64_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance64x64 aom_highbd_obmc_sub_pixel_variance64x64_c
+
+unsigned int aom_highbd_obmc_sub_pixel_variance8x16_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance8x16 aom_highbd_obmc_sub_pixel_variance8x16_c
+
+unsigned int aom_highbd_obmc_sub_pixel_variance8x4_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance8x4 aom_highbd_obmc_sub_pixel_variance8x4_c
+
+unsigned int aom_highbd_obmc_sub_pixel_variance8x8_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_highbd_obmc_sub_pixel_variance8x8 aom_highbd_obmc_sub_pixel_variance8x8_c
+
+unsigned int aom_highbd_obmc_variance16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance16x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance16x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_obmc_variance16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance16x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance16x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_obmc_variance16x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance16x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance16x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_obmc_variance32x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance32x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance32x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_obmc_variance32x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance32x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance32x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_obmc_variance32x64_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance32x64_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance32x64)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_obmc_variance4x4_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance4x4_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance4x4)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_obmc_variance4x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance4x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance4x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_obmc_variance64x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance64x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance64x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_obmc_variance64x64_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance64x64_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance64x64)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_obmc_variance8x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance8x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance8x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_obmc_variance8x4_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance8x4_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance8x4)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_highbd_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_highbd_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+void aom_highbd_paeth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x16 aom_highbd_paeth_predictor_16x16_c
+
+void aom_highbd_paeth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x32 aom_highbd_paeth_predictor_16x32_c
+
+void aom_highbd_paeth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x8 aom_highbd_paeth_predictor_16x8_c
+
+void aom_highbd_paeth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_2x2 aom_highbd_paeth_predictor_2x2_c
+
+void aom_highbd_paeth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_32x16 aom_highbd_paeth_predictor_32x16_c
+
+void aom_highbd_paeth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_32x32 aom_highbd_paeth_predictor_32x32_c
+
+void aom_highbd_paeth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_4x4 aom_highbd_paeth_predictor_4x4_c
+
+void aom_highbd_paeth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_4x8 aom_highbd_paeth_predictor_4x8_c
+
+void aom_highbd_paeth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x16 aom_highbd_paeth_predictor_8x16_c
+
+void aom_highbd_paeth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x4 aom_highbd_paeth_predictor_8x4_c
+
+void aom_highbd_paeth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x8 aom_highbd_paeth_predictor_8x8_c
+
+void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+void aom_highbd_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+void aom_highbd_quantize_b_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*aom_highbd_quantize_b)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+
+void aom_highbd_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+void aom_highbd_quantize_b_32x32_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*aom_highbd_quantize_b_32x32)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+
+void aom_highbd_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+#define aom_highbd_quantize_b_64x64 aom_highbd_quantize_b_64x64_c
+
+unsigned int aom_highbd_sad16x16_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad16x16_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad16x16_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_highbd_sad16x16)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_highbd_sad16x16_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad16x16_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad16x16_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_highbd_sad16x16_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_highbd_sad16x16x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad16x16x3 aom_highbd_sad16x16x3_c
+
+void aom_highbd_sad16x16x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad16x16x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad16x16x4d_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad16x16x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_highbd_sad16x16x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad16x16x8 aom_highbd_sad16x16x8_c
+
+unsigned int aom_highbd_sad16x32_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad16x32_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad16x32_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_highbd_sad16x32)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_highbd_sad16x32_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad16x32_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad16x32_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_highbd_sad16x32_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_highbd_sad16x32x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad16x32x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad16x32x4d_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad16x32x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+unsigned int aom_highbd_sad16x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad16x8_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad16x8_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_highbd_sad16x8)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_highbd_sad16x8_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad16x8_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad16x8_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_highbd_sad16x8_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_highbd_sad16x8x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad16x8x3 aom_highbd_sad16x8x3_c
+
+void aom_highbd_sad16x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad16x8x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad16x8x4d_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad16x8x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_highbd_sad16x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad16x8x8 aom_highbd_sad16x8x8_c
+
+unsigned int aom_highbd_sad32x16_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad32x16_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad32x16_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_highbd_sad32x16)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_highbd_sad32x16_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad32x16_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad32x16_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_highbd_sad32x16_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_highbd_sad32x16x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad32x16x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad32x16x4d_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad32x16x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+unsigned int aom_highbd_sad32x32_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad32x32_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad32x32_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_highbd_sad32x32)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_highbd_sad32x32_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad32x32_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad32x32_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_highbd_sad32x32_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_highbd_sad32x32x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad32x32x3 aom_highbd_sad32x32x3_c
+
+void aom_highbd_sad32x32x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad32x32x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad32x32x4d_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad32x32x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_highbd_sad32x32x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad32x32x8 aom_highbd_sad32x32x8_c
+
+unsigned int aom_highbd_sad32x64_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad32x64_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad32x64_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_highbd_sad32x64)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_highbd_sad32x64_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad32x64_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad32x64_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_highbd_sad32x64_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_highbd_sad32x64x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad32x64x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad32x64x4d_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad32x64x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+unsigned int aom_highbd_sad4x4_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+#define aom_highbd_sad4x4 aom_highbd_sad4x4_c
+
+unsigned int aom_highbd_sad4x4_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+#define aom_highbd_sad4x4_avg aom_highbd_sad4x4_avg_c
+
+void aom_highbd_sad4x4x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad4x4x3 aom_highbd_sad4x4x3_c
+
+void aom_highbd_sad4x4x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad4x4x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad4x4x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_highbd_sad4x4x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad4x4x8 aom_highbd_sad4x4x8_c
+
+unsigned int aom_highbd_sad4x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+#define aom_highbd_sad4x8 aom_highbd_sad4x8_c
+
+unsigned int aom_highbd_sad4x8_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+#define aom_highbd_sad4x8_avg aom_highbd_sad4x8_avg_c
+
+void aom_highbd_sad4x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad4x8x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad4x8x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_highbd_sad4x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad4x8x8 aom_highbd_sad4x8x8_c
+
+unsigned int aom_highbd_sad64x32_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad64x32_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad64x32_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_highbd_sad64x32)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_highbd_sad64x32_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad64x32_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad64x32_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_highbd_sad64x32_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_highbd_sad64x32x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad64x32x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad64x32x4d_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad64x32x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+unsigned int aom_highbd_sad64x64_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad64x64_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad64x64_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_highbd_sad64x64)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_highbd_sad64x64_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad64x64_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad64x64_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_highbd_sad64x64_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_highbd_sad64x64x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad64x64x3 aom_highbd_sad64x64x3_c
+
+void aom_highbd_sad64x64x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad64x64x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad64x64x4d_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad64x64x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_highbd_sad64x64x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad64x64x8 aom_highbd_sad64x64x8_c
+
+unsigned int aom_highbd_sad8x16_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad8x16_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_highbd_sad8x16)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_highbd_sad8x16_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad8x16_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_highbd_sad8x16_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_highbd_sad8x16x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad8x16x3 aom_highbd_sad8x16x3_c
+
+void aom_highbd_sad8x16x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad8x16x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad8x16x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_highbd_sad8x16x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad8x16x8 aom_highbd_sad8x16x8_c
+
+unsigned int aom_highbd_sad8x4_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad8x4_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_highbd_sad8x4)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_highbd_sad8x4_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad8x4_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_highbd_sad8x4_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_highbd_sad8x4x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad8x4x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad8x4x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_highbd_sad8x4x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad8x4x8 aom_highbd_sad8x4x8_c
+
+unsigned int aom_highbd_sad8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_highbd_sad8x8_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_highbd_sad8x8)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_highbd_sad8x8_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_highbd_sad8x8_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_highbd_sad8x8_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_highbd_sad8x8x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad8x8x3 aom_highbd_sad8x8x3_c
+
+void aom_highbd_sad8x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_highbd_sad8x8x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_highbd_sad8x8x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_highbd_sad8x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_highbd_sad8x8x8 aom_highbd_sad8x8x8_c
+
+void aom_highbd_smooth_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x16 aom_highbd_smooth_h_predictor_16x16_c
+
+void aom_highbd_smooth_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x32 aom_highbd_smooth_h_predictor_16x32_c
+
+void aom_highbd_smooth_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x8 aom_highbd_smooth_h_predictor_16x8_c
+
+void aom_highbd_smooth_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_2x2 aom_highbd_smooth_h_predictor_2x2_c
+
+void aom_highbd_smooth_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x16 aom_highbd_smooth_h_predictor_32x16_c
+
+void aom_highbd_smooth_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x32 aom_highbd_smooth_h_predictor_32x32_c
+
+void aom_highbd_smooth_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x4 aom_highbd_smooth_h_predictor_4x4_c
+
+void aom_highbd_smooth_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x8 aom_highbd_smooth_h_predictor_4x8_c
+
+void aom_highbd_smooth_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x16 aom_highbd_smooth_h_predictor_8x16_c
+
+void aom_highbd_smooth_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x4 aom_highbd_smooth_h_predictor_8x4_c
+
+void aom_highbd_smooth_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x8 aom_highbd_smooth_h_predictor_8x8_c
+
+void aom_highbd_smooth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x16 aom_highbd_smooth_predictor_16x16_c
+
+void aom_highbd_smooth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x32 aom_highbd_smooth_predictor_16x32_c
+
+void aom_highbd_smooth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x8 aom_highbd_smooth_predictor_16x8_c
+
+void aom_highbd_smooth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_2x2 aom_highbd_smooth_predictor_2x2_c
+
+void aom_highbd_smooth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_32x16 aom_highbd_smooth_predictor_32x16_c
+
+void aom_highbd_smooth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_32x32 aom_highbd_smooth_predictor_32x32_c
+
+void aom_highbd_smooth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_4x4 aom_highbd_smooth_predictor_4x4_c
+
+void aom_highbd_smooth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_4x8 aom_highbd_smooth_predictor_4x8_c
+
+void aom_highbd_smooth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x16 aom_highbd_smooth_predictor_8x16_c
+
+void aom_highbd_smooth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x4 aom_highbd_smooth_predictor_8x4_c
+
+void aom_highbd_smooth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x8 aom_highbd_smooth_predictor_8x8_c
+
+void aom_highbd_smooth_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x16 aom_highbd_smooth_v_predictor_16x16_c
+
+void aom_highbd_smooth_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x32 aom_highbd_smooth_v_predictor_16x32_c
+
+void aom_highbd_smooth_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x8 aom_highbd_smooth_v_predictor_16x8_c
+
+void aom_highbd_smooth_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_2x2 aom_highbd_smooth_v_predictor_2x2_c
+
+void aom_highbd_smooth_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x16 aom_highbd_smooth_v_predictor_32x16_c
+
+void aom_highbd_smooth_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x32 aom_highbd_smooth_v_predictor_32x32_c
+
+void aom_highbd_smooth_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x4 aom_highbd_smooth_v_predictor_4x4_c
+
+void aom_highbd_smooth_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x8 aom_highbd_smooth_v_predictor_4x8_c
+
+void aom_highbd_smooth_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x16 aom_highbd_smooth_v_predictor_8x16_c
+
+void aom_highbd_smooth_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x4 aom_highbd_smooth_v_predictor_8x4_c
+
+void aom_highbd_smooth_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x8 aom_highbd_smooth_v_predictor_8x8_c
+
+void aom_highbd_subtract_block_c(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
+void aom_highbd_subtract_block_sse2(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
+RTCD_EXTERN void (*aom_highbd_subtract_block)(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
+
+void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+void aom_highbd_upsampled_pred_sse2(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+RTCD_EXTERN void (*aom_highbd_upsampled_pred)(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+
+void aom_highbd_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+void aom_highbd_v_predictor_16x16_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+RTCD_EXTERN void (*aom_highbd_v_predictor_16x16)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+
+void aom_highbd_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x32 aom_highbd_v_predictor_16x32_c
+
+void aom_highbd_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x8 aom_highbd_v_predictor_16x8_c
+
+void aom_highbd_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_2x2 aom_highbd_v_predictor_2x2_c
+
+void aom_highbd_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_32x16 aom_highbd_v_predictor_32x16_c
+
+void aom_highbd_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+void aom_highbd_v_predictor_32x32_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+RTCD_EXTERN void (*aom_highbd_v_predictor_32x32)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+
+void aom_highbd_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+void aom_highbd_v_predictor_4x4_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+RTCD_EXTERN void (*aom_highbd_v_predictor_4x4)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+
+void aom_highbd_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_4x8 aom_highbd_v_predictor_4x8_c
+
+void aom_highbd_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x16 aom_highbd_v_predictor_8x16_c
+
+void aom_highbd_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x4 aom_highbd_v_predictor_8x4_c
+
+void aom_highbd_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+void aom_highbd_v_predictor_8x8_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+RTCD_EXTERN void (*aom_highbd_v_predictor_8x8)(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+
+void aom_idct16x16_10_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct16x16_10_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct16x16_10_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct16x16_10_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_idct16x16_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct16x16_1_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct16x16_1_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct16x16_1_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_idct16x16_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct16x16_256_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct16x16_256_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct16x16_256_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_idct16x16_38_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct16x16_38_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct16x16_38_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_idct32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct32x32_1024_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct32x32_1024_add_ssse3(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct32x32_1024_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct32x32_1024_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_idct32x32_135_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct32x32_1024_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct32x32_135_add_ssse3(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct32x32_135_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct32x32_135_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_idct32x32_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct32x32_1_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct32x32_1_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct32x32_1_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_idct32x32_34_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct32x32_34_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct32x32_34_add_ssse3(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct32x32_34_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct32x32_34_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_idct4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct4x4_16_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_idct4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct4x4_1_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct4x4_1_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_idct8x8_12_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct8x8_12_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct8x8_12_add_ssse3(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct8x8_12_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_idct8x8_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct8x8_1_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct8x8_1_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_idct8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_idct8x8_64_add_ssse3(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_idct8x8_64_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+int16_t aom_int_pro_col_c(const uint8_t *ref, int width);
+int16_t aom_int_pro_col_sse2(const uint8_t *ref, int width);
+RTCD_EXTERN int16_t (*aom_int_pro_col)(const uint8_t *ref, int width);
+
+void aom_int_pro_row_c(int16_t *hbuf, const uint8_t *ref, int ref_stride, int height);
+void aom_int_pro_row_sse2(int16_t *hbuf, const uint8_t *ref, int ref_stride, int height);
+RTCD_EXTERN void (*aom_int_pro_row)(int16_t *hbuf, const uint8_t *ref, int ref_stride, int height);
+
+void aom_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+void aom_iwht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
+RTCD_EXTERN void (*aom_iwht4x4_16_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
+
+void aom_iwht4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
+#define aom_iwht4x4_1_add aom_iwht4x4_1_add_c
+
+void aom_lpf_horizontal_4_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+void aom_lpf_horizontal_4_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+RTCD_EXTERN void (*aom_lpf_horizontal_4)(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+
+void aom_lpf_horizontal_4_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
+void aom_lpf_horizontal_4_dual_sse2(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
+RTCD_EXTERN void (*aom_lpf_horizontal_4_dual)(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
+
+void aom_lpf_horizontal_8_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+void aom_lpf_horizontal_8_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+RTCD_EXTERN void (*aom_lpf_horizontal_8)(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+
+void aom_lpf_horizontal_8_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
+void aom_lpf_horizontal_8_dual_sse2(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
+RTCD_EXTERN void (*aom_lpf_horizontal_8_dual)(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
+
+void aom_lpf_horizontal_edge_16_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+void aom_lpf_horizontal_edge_16_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+void aom_lpf_horizontal_edge_16_avx2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+RTCD_EXTERN void (*aom_lpf_horizontal_edge_16)(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+
+void aom_lpf_horizontal_edge_8_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+void aom_lpf_horizontal_edge_8_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+void aom_lpf_horizontal_edge_8_avx2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+RTCD_EXTERN void (*aom_lpf_horizontal_edge_8)(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+
+void aom_lpf_vertical_16_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+void aom_lpf_vertical_16_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+RTCD_EXTERN void (*aom_lpf_vertical_16)(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+
+void aom_lpf_vertical_16_dual_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+void aom_lpf_vertical_16_dual_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+RTCD_EXTERN void (*aom_lpf_vertical_16_dual)(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+
+void aom_lpf_vertical_4_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+void aom_lpf_vertical_4_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+RTCD_EXTERN void (*aom_lpf_vertical_4)(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+
+void aom_lpf_vertical_4_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
+void aom_lpf_vertical_4_dual_sse2(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
+RTCD_EXTERN void (*aom_lpf_vertical_4_dual)(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
+
+void aom_lpf_vertical_8_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+void aom_lpf_vertical_8_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+RTCD_EXTERN void (*aom_lpf_vertical_8)(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
+
+void aom_lpf_vertical_8_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
+void aom_lpf_vertical_8_dual_sse2(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
+RTCD_EXTERN void (*aom_lpf_vertical_8_dual)(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
+
+void aom_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
+void aom_minmax_8x8_sse2(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
+RTCD_EXTERN void (*aom_minmax_8x8)(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
+
+unsigned int aom_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+unsigned int aom_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+unsigned int aom_mse16x16_avx2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+
+unsigned int aom_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+unsigned int aom_mse16x8_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_mse16x8)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+
+unsigned int aom_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+unsigned int aom_mse8x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_mse8x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+
+unsigned int aom_mse8x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+unsigned int aom_mse8x8_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_mse8x8)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
+
+unsigned int aom_obmc_sad16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad16x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad16x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sad16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad16x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad16x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sad16x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad16x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad16x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sad32x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad32x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad32x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sad32x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad32x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad32x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sad32x64_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad32x64_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad32x64)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sad4x4_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad4x4_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad4x4)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sad4x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad4x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad4x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sad64x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad64x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad64x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sad64x64_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad64x64_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad64x64)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sad8x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad8x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad8x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sad8x4_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad8x4_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad8x4)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sad8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+unsigned int aom_obmc_sad8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+RTCD_EXTERN unsigned int (*aom_obmc_sad8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
+
+unsigned int aom_obmc_sub_pixel_variance16x16_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance16x16 aom_obmc_sub_pixel_variance16x16_c
+
+unsigned int aom_obmc_sub_pixel_variance16x32_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance16x32 aom_obmc_sub_pixel_variance16x32_c
+
+unsigned int aom_obmc_sub_pixel_variance16x8_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance16x8 aom_obmc_sub_pixel_variance16x8_c
+
+unsigned int aom_obmc_sub_pixel_variance32x16_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance32x16 aom_obmc_sub_pixel_variance32x16_c
+
+unsigned int aom_obmc_sub_pixel_variance32x32_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance32x32 aom_obmc_sub_pixel_variance32x32_c
+
+unsigned int aom_obmc_sub_pixel_variance32x64_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance32x64 aom_obmc_sub_pixel_variance32x64_c
+
+unsigned int aom_obmc_sub_pixel_variance4x4_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance4x4 aom_obmc_sub_pixel_variance4x4_c
+
+unsigned int aom_obmc_sub_pixel_variance4x8_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance4x8 aom_obmc_sub_pixel_variance4x8_c
+
+unsigned int aom_obmc_sub_pixel_variance64x32_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance64x32 aom_obmc_sub_pixel_variance64x32_c
+
+unsigned int aom_obmc_sub_pixel_variance64x64_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance64x64 aom_obmc_sub_pixel_variance64x64_c
+
+unsigned int aom_obmc_sub_pixel_variance8x16_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance8x16 aom_obmc_sub_pixel_variance8x16_c
+
+unsigned int aom_obmc_sub_pixel_variance8x4_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance8x4 aom_obmc_sub_pixel_variance8x4_c
+
+unsigned int aom_obmc_sub_pixel_variance8x8_c(const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+#define aom_obmc_sub_pixel_variance8x8 aom_obmc_sub_pixel_variance8x8_c
+
+unsigned int aom_obmc_variance16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance16x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance16x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_obmc_variance16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance16x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance16x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_obmc_variance16x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance16x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance16x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_obmc_variance32x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance32x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance32x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_obmc_variance32x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance32x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance32x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_obmc_variance32x64_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance32x64_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance32x64)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_obmc_variance4x4_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance4x4_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance4x4)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_obmc_variance4x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance4x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance4x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_obmc_variance64x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance64x32_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance64x32)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_obmc_variance64x64_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance64x64_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance64x64)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_obmc_variance8x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance8x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance8x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_obmc_variance8x4_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance8x4_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance8x4)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+unsigned int aom_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+unsigned int aom_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
+
+void aom_paeth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x16 aom_paeth_predictor_16x16_c
+
+void aom_paeth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x32 aom_paeth_predictor_16x32_c
+
+void aom_paeth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x8 aom_paeth_predictor_16x8_c
+
+void aom_paeth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_2x2 aom_paeth_predictor_2x2_c
+
+void aom_paeth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_32x16 aom_paeth_predictor_32x16_c
+
+void aom_paeth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_32x32 aom_paeth_predictor_32x32_c
+
+void aom_paeth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_4x4 aom_paeth_predictor_4x4_c
+
+void aom_paeth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_4x8 aom_paeth_predictor_4x8_c
+
+void aom_paeth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x16 aom_paeth_predictor_8x16_c
+
+void aom_paeth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x4 aom_paeth_predictor_8x4_c
+
+void aom_paeth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x8 aom_paeth_predictor_8x8_c
+
+void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+void aom_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*aom_quantize_b)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+
+void aom_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+#define aom_quantize_b_32x32 aom_quantize_b_32x32_c
+
+void aom_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+#define aom_quantize_b_64x64 aom_quantize_b_64x64_c
+
+unsigned int aom_sad16x16_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad16x16_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad16x16)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad16x16_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad16x16_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad16x16_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad16x16x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+void aom_sad16x16x3_sse3(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+void aom_sad16x16x3_ssse3(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad16x16x3)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+
+void aom_sad16x16x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad16x16x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad16x16x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_sad16x16x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+void aom_sad16x16x8_sse4_1(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad16x16x8)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+
+unsigned int aom_sad16x32_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad16x32_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad16x32)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad16x32_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad16x32_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad16x32_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad16x32x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad16x32x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad16x32x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+unsigned int aom_sad16x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad16x8_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad16x8)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad16x8_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad16x8_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad16x8_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad16x8x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+void aom_sad16x8x3_sse3(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+void aom_sad16x8x3_ssse3(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad16x8x3)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+
+void aom_sad16x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad16x8x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad16x8x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_sad16x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+void aom_sad16x8x8_sse4_1(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad16x8x8)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+
+unsigned int aom_sad32x16_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad32x16_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad32x16_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad32x16)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad32x16_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad32x16_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad32x16_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad32x16_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad32x16x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad32x16x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad32x16x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+unsigned int aom_sad32x32_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad32x32_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad32x32_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad32x32)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad32x32_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad32x32_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad32x32_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad32x32_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad32x32x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_sad32x32x3 aom_sad32x32x3_c
+
+void aom_sad32x32x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad32x32x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad32x32x4d_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad32x32x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_sad32x32x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_sad32x32x8 aom_sad32x32x8_c
+
+unsigned int aom_sad32x64_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad32x64_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad32x64_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad32x64)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad32x64_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad32x64_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad32x64_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad32x64_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad32x64x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad32x64x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad32x64x4d_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad32x64x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+unsigned int aom_sad4x4_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad4x4_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad4x4)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad4x4_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad4x4_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad4x4_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad4x4x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+void aom_sad4x4x3_sse3(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad4x4x3)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+
+void aom_sad4x4x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad4x4x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad4x4x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_sad4x4x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+void aom_sad4x4x8_sse4_1(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad4x4x8)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+
+unsigned int aom_sad4x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad4x8_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad4x8)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad4x8_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad4x8_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad4x8_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad4x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad4x8x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad4x8x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_sad4x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_sad4x8x8 aom_sad4x8x8_c
+
+unsigned int aom_sad64x32_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad64x32_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad64x32_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad64x32)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad64x32_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad64x32_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad64x32_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad64x32_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad64x32x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad64x32x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad64x32x4d_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad64x32x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+unsigned int aom_sad64x64_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad64x64_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad64x64_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad64x64)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad64x64_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad64x64_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad64x64_avg_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad64x64_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad64x64x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_sad64x64x3 aom_sad64x64x3_c
+
+void aom_sad64x64x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad64x64x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad64x64x4d_avx2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad64x64x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_sad64x64x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_sad64x64x8 aom_sad64x64x8_c
+
+unsigned int aom_sad8x16_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad8x16_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad8x16)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad8x16_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad8x16_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad8x16_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad8x16x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+void aom_sad8x16x3_sse3(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad8x16x3)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+
+void aom_sad8x16x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad8x16x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad8x16x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_sad8x16x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+void aom_sad8x16x8_sse4_1(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad8x16x8)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+
+unsigned int aom_sad8x4_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad8x4_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad8x4)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad8x4_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad8x4_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad8x4_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad8x4x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad8x4x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad8x4x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_sad8x4x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+#define aom_sad8x4x8 aom_sad8x4x8_c
+
+unsigned int aom_sad8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+unsigned int aom_sad8x8_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+RTCD_EXTERN unsigned int (*aom_sad8x8)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride);
+
+unsigned int aom_sad8x8_avg_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+unsigned int aom_sad8x8_avg_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+RTCD_EXTERN unsigned int (*aom_sad8x8_avg)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred);
+
+void aom_sad8x8x3_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+void aom_sad8x8x3_sse3(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad8x8x3)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+
+void aom_sad8x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+void aom_sad8x8x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad8x8x4d)(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
+
+void aom_sad8x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+void aom_sad8x8x8_sse4_1(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+RTCD_EXTERN void (*aom_sad8x8x8)(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
+
+int aom_satd_c(const int16_t *coeff, int length);
+int aom_satd_sse2(const int16_t *coeff, int length);
+RTCD_EXTERN int (*aom_satd)(const int16_t *coeff, int length);
+
+void aom_scaled_2d_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+void aom_scaled_2d_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+RTCD_EXTERN void (*aom_scaled_2d)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+
+void aom_scaled_avg_2d_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+#define aom_scaled_avg_2d aom_scaled_avg_2d_c
+
+void aom_scaled_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+#define aom_scaled_avg_horiz aom_scaled_avg_horiz_c
+
+void aom_scaled_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+#define aom_scaled_avg_vert aom_scaled_avg_vert_c
+
+void aom_scaled_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+#define aom_scaled_horiz aom_scaled_horiz_c
+
+void aom_scaled_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
+#define aom_scaled_vert aom_scaled_vert_c
+
+void aom_smooth_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x16 aom_smooth_h_predictor_16x16_c
+
+void aom_smooth_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x32 aom_smooth_h_predictor_16x32_c
+
+void aom_smooth_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x8 aom_smooth_h_predictor_16x8_c
+
+void aom_smooth_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_2x2 aom_smooth_h_predictor_2x2_c
+
+void aom_smooth_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x16 aom_smooth_h_predictor_32x16_c
+
+void aom_smooth_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x32 aom_smooth_h_predictor_32x32_c
+
+void aom_smooth_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x4 aom_smooth_h_predictor_4x4_c
+
+void aom_smooth_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x8 aom_smooth_h_predictor_4x8_c
+
+void aom_smooth_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x16 aom_smooth_h_predictor_8x16_c
+
+void aom_smooth_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x4 aom_smooth_h_predictor_8x4_c
+
+void aom_smooth_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x8 aom_smooth_h_predictor_8x8_c
+
+void aom_smooth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x16 aom_smooth_predictor_16x16_c
+
+void aom_smooth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x32 aom_smooth_predictor_16x32_c
+
+void aom_smooth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x8 aom_smooth_predictor_16x8_c
+
+void aom_smooth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_2x2 aom_smooth_predictor_2x2_c
+
+void aom_smooth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_32x16 aom_smooth_predictor_32x16_c
+
+void aom_smooth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_32x32 aom_smooth_predictor_32x32_c
+
+void aom_smooth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_4x4 aom_smooth_predictor_4x4_c
+
+void aom_smooth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_4x8 aom_smooth_predictor_4x8_c
+
+void aom_smooth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x16 aom_smooth_predictor_8x16_c
+
+void aom_smooth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x4 aom_smooth_predictor_8x4_c
+
+void aom_smooth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x8 aom_smooth_predictor_8x8_c
+
+void aom_smooth_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x16 aom_smooth_v_predictor_16x16_c
+
+void aom_smooth_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x32 aom_smooth_v_predictor_16x32_c
+
+void aom_smooth_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x8 aom_smooth_v_predictor_16x8_c
+
+void aom_smooth_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_2x2 aom_smooth_v_predictor_2x2_c
+
+void aom_smooth_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x16 aom_smooth_v_predictor_32x16_c
+
+void aom_smooth_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x32 aom_smooth_v_predictor_32x32_c
+
+void aom_smooth_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x4 aom_smooth_v_predictor_4x4_c
+
+void aom_smooth_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x8 aom_smooth_v_predictor_4x8_c
+
+void aom_smooth_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x16 aom_smooth_v_predictor_8x16_c
+
+void aom_smooth_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x4 aom_smooth_v_predictor_8x4_c
+
+void aom_smooth_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x8 aom_smooth_v_predictor_8x8_c
+
+uint32_t aom_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance16x16_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance16x32_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance16x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_avg_variance16x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance16x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance16x8_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance16x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_avg_variance32x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance32x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance32x16_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance32x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_avg_variance32x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance32x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance32x32_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance32x32_avx2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance32x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_avg_variance32x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance32x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance32x64_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance32x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_avg_variance4x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance4x4_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance4x4_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance4x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_avg_variance4x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance4x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance4x8_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance4x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_avg_variance64x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance64x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance64x32_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance64x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_avg_variance64x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance64x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance64x64_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance64x64_avx2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance64x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_avg_variance8x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance8x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance8x16_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance8x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_avg_variance8x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance8x4_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance8x4_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance8x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_avg_variance8x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance8x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+uint32_t aom_sub_pixel_avg_variance8x8_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance8x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
+
+uint32_t aom_sub_pixel_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance16x16_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_sub_pixel_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance16x32_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance16x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_sub_pixel_variance16x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance16x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance16x8_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance16x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_sub_pixel_variance32x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance32x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance32x16_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance32x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_sub_pixel_variance32x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance32x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance32x32_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance32x32_avx2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance32x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_sub_pixel_variance32x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance32x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance32x64_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance32x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_sub_pixel_variance4x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance4x4_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance4x4_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance4x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_sub_pixel_variance4x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance4x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance4x8_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance4x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_sub_pixel_variance64x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance64x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance64x32_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance64x32)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_sub_pixel_variance64x64_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance64x64_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance64x64_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance64x64_avx2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance64x64)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_sub_pixel_variance8x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance8x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance8x16_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance8x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_sub_pixel_variance8x4_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance8x4_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance8x4_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance8x4)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+uint32_t aom_sub_pixel_variance8x8_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance8x8_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+uint32_t aom_sub_pixel_variance8x8_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_sub_pixel_variance8x8)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse);
+
+void aom_subtract_block_c(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride);
+void aom_subtract_block_sse2(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride);
+RTCD_EXTERN void (*aom_subtract_block)(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride);
+
+uint64_t aom_sum_squares_2d_i16_c(const int16_t *src, int stride, int width, int height);
+uint64_t aom_sum_squares_2d_i16_sse2(const int16_t *src, int stride, int width, int height);
+RTCD_EXTERN uint64_t (*aom_sum_squares_2d_i16)(const int16_t *src, int stride, int width, int height);
+
+uint64_t aom_sum_squares_i16_c(const int16_t *src, uint32_t N);
+uint64_t aom_sum_squares_i16_sse2(const int16_t *src, uint32_t N);
+RTCD_EXTERN uint64_t (*aom_sum_squares_i16)(const int16_t *src, uint32_t N);
+
+void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_sse2(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+RTCD_EXTERN void (*aom_upsampled_pred)(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+
+void aom_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_v_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_v_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x32 aom_v_predictor_16x32_c
+
+void aom_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x8 aom_v_predictor_16x8_c
+
+void aom_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_2x2 aom_v_predictor_2x2_c
+
+void aom_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_32x16 aom_v_predictor_32x16_c
+
+void aom_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_v_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_v_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_v_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_v_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+void aom_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_4x8 aom_v_predictor_4x8_c
+
+void aom_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x16 aom_v_predictor_8x16_c
+
+void aom_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x4 aom_v_predictor_8x4_c
+
+void aom_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+void aom_v_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+RTCD_EXTERN void (*aom_v_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+
+unsigned int aom_variance16x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance16x16_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance16x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_variance16x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance16x32)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_variance16x8_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance16x8_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance16x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_variance2x2_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_variance2x2 aom_variance2x2_c
+
+unsigned int aom_variance2x4_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_variance2x4 aom_variance2x4_c
+
+unsigned int aom_variance32x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance32x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance32x16_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance32x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_variance32x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance32x32_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance32x32_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance32x32)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_variance32x64_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance32x64_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance32x64)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_variance4x2_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+#define aom_variance4x2 aom_variance4x2_c
+
+unsigned int aom_variance4x4_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance4x4_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance4x4)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_variance4x8_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance4x8_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance4x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_variance64x32_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance64x32_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance64x32_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance64x32)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_variance64x64_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance64x64_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance64x64_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance64x64)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_variance8x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance8x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance8x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_variance8x4_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance8x4_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance8x4)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+unsigned int aom_variance8x8_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+unsigned int aom_variance8x8_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+RTCD_EXTERN unsigned int (*aom_variance8x8)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
+
+uint32_t aom_variance_halfpixvar16x16_h_c(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int  ref_stride, uint32_t *sse);
+uint32_t aom_variance_halfpixvar16x16_h_sse2(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int  ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_variance_halfpixvar16x16_h)(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int  ref_stride, uint32_t *sse);
+
+uint32_t aom_variance_halfpixvar16x16_hv_c(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int  ref_stride, uint32_t *sse);
+uint32_t aom_variance_halfpixvar16x16_hv_sse2(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int  ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_variance_halfpixvar16x16_hv)(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int  ref_stride, uint32_t *sse);
+
+uint32_t aom_variance_halfpixvar16x16_v_c(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int  ref_stride, uint32_t *sse);
+uint32_t aom_variance_halfpixvar16x16_v_sse2(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int  ref_stride, uint32_t *sse);
+RTCD_EXTERN uint32_t (*aom_variance_halfpixvar16x16_v)(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int  ref_stride, uint32_t *sse);
+
+int aom_vector_var_c(const int16_t *ref, const int16_t *src, int bwl);
+int aom_vector_var_sse2(const int16_t *ref, const int16_t *src, int bwl);
+RTCD_EXTERN int (*aom_vector_var)(const int16_t *ref, const int16_t *src, int bwl);
+
+void aom_dsp_rtcd(void);
+
+#ifdef RTCD_C
+#include "aom_ports/x86.h"
+static void setup_rtcd_internal(void)
+{
+    int flags = x86_simd_caps();
+
+    (void)flags;
+
+    aom_blend_a64_hmask = aom_blend_a64_hmask_c;
+    if (flags & HAS_SSE4_1) aom_blend_a64_hmask = aom_blend_a64_hmask_sse4_1;
+    aom_blend_a64_mask = aom_blend_a64_mask_c;
+    if (flags & HAS_SSE4_1) aom_blend_a64_mask = aom_blend_a64_mask_sse4_1;
+    aom_blend_a64_vmask = aom_blend_a64_vmask_c;
+    if (flags & HAS_SSE4_1) aom_blend_a64_vmask = aom_blend_a64_vmask_sse4_1;
+    aom_comp_avg_upsampled_pred = aom_comp_avg_upsampled_pred_c;
+    if (flags & HAS_SSE2) aom_comp_avg_upsampled_pred = aom_comp_avg_upsampled_pred_sse2;
+    aom_convolve8 = aom_convolve8_c;
+    if (flags & HAS_SSE2) aom_convolve8 = aom_convolve8_sse2;
+    if (flags & HAS_SSSE3) aom_convolve8 = aom_convolve8_ssse3;
+    if (flags & HAS_AVX2) aom_convolve8 = aom_convolve8_avx2;
+    aom_convolve8_avg = aom_convolve8_avg_c;
+    if (flags & HAS_SSE2) aom_convolve8_avg = aom_convolve8_avg_sse2;
+    if (flags & HAS_SSSE3) aom_convolve8_avg = aom_convolve8_avg_ssse3;
+    aom_convolve8_avg_horiz = aom_convolve8_avg_horiz_c;
+    if (flags & HAS_SSE2) aom_convolve8_avg_horiz = aom_convolve8_avg_horiz_sse2;
+    if (flags & HAS_SSSE3) aom_convolve8_avg_horiz = aom_convolve8_avg_horiz_ssse3;
+    aom_convolve8_avg_vert = aom_convolve8_avg_vert_c;
+    if (flags & HAS_SSE2) aom_convolve8_avg_vert = aom_convolve8_avg_vert_sse2;
+    if (flags & HAS_SSSE3) aom_convolve8_avg_vert = aom_convolve8_avg_vert_ssse3;
+    aom_convolve8_horiz = aom_convolve8_horiz_c;
+    if (flags & HAS_SSE2) aom_convolve8_horiz = aom_convolve8_horiz_sse2;
+    if (flags & HAS_SSSE3) aom_convolve8_horiz = aom_convolve8_horiz_ssse3;
+    if (flags & HAS_AVX2) aom_convolve8_horiz = aom_convolve8_horiz_avx2;
+    aom_convolve8_vert = aom_convolve8_vert_c;
+    if (flags & HAS_SSE2) aom_convolve8_vert = aom_convolve8_vert_sse2;
+    if (flags & HAS_SSSE3) aom_convolve8_vert = aom_convolve8_vert_ssse3;
+    if (flags & HAS_AVX2) aom_convolve8_vert = aom_convolve8_vert_avx2;
+    aom_convolve_avg = aom_convolve_avg_c;
+    if (flags & HAS_SSE2) aom_convolve_avg = aom_convolve_avg_sse2;
+    aom_convolve_copy = aom_convolve_copy_c;
+    if (flags & HAS_SSE2) aom_convolve_copy = aom_convolve_copy_sse2;
+    aom_d153_predictor_16x16 = aom_d153_predictor_16x16_c;
+    if (flags & HAS_SSSE3) aom_d153_predictor_16x16 = aom_d153_predictor_16x16_ssse3;
+    aom_d153_predictor_32x32 = aom_d153_predictor_32x32_c;
+    if (flags & HAS_SSSE3) aom_d153_predictor_32x32 = aom_d153_predictor_32x32_ssse3;
+    aom_d153_predictor_4x4 = aom_d153_predictor_4x4_c;
+    if (flags & HAS_SSSE3) aom_d153_predictor_4x4 = aom_d153_predictor_4x4_ssse3;
+    aom_d153_predictor_8x8 = aom_d153_predictor_8x8_c;
+    if (flags & HAS_SSSE3) aom_d153_predictor_8x8 = aom_d153_predictor_8x8_ssse3;
+    aom_d63e_predictor_4x4 = aom_d63e_predictor_4x4_c;
+    if (flags & HAS_SSSE3) aom_d63e_predictor_4x4 = aom_d63e_predictor_4x4_ssse3;
+    aom_dc_128_predictor_16x16 = aom_dc_128_predictor_16x16_c;
+    if (flags & HAS_SSE2) aom_dc_128_predictor_16x16 = aom_dc_128_predictor_16x16_sse2;
+    aom_dc_128_predictor_32x32 = aom_dc_128_predictor_32x32_c;
+    if (flags & HAS_SSE2) aom_dc_128_predictor_32x32 = aom_dc_128_predictor_32x32_sse2;
+    aom_dc_128_predictor_4x4 = aom_dc_128_predictor_4x4_c;
+    if (flags & HAS_SSE2) aom_dc_128_predictor_4x4 = aom_dc_128_predictor_4x4_sse2;
+    aom_dc_128_predictor_8x8 = aom_dc_128_predictor_8x8_c;
+    if (flags & HAS_SSE2) aom_dc_128_predictor_8x8 = aom_dc_128_predictor_8x8_sse2;
+    aom_dc_left_predictor_16x16 = aom_dc_left_predictor_16x16_c;
+    if (flags & HAS_SSE2) aom_dc_left_predictor_16x16 = aom_dc_left_predictor_16x16_sse2;
+    aom_dc_left_predictor_32x32 = aom_dc_left_predictor_32x32_c;
+    if (flags & HAS_SSE2) aom_dc_left_predictor_32x32 = aom_dc_left_predictor_32x32_sse2;
+    aom_dc_left_predictor_4x4 = aom_dc_left_predictor_4x4_c;
+    if (flags & HAS_SSE2) aom_dc_left_predictor_4x4 = aom_dc_left_predictor_4x4_sse2;
+    aom_dc_left_predictor_8x8 = aom_dc_left_predictor_8x8_c;
+    if (flags & HAS_SSE2) aom_dc_left_predictor_8x8 = aom_dc_left_predictor_8x8_sse2;
+    aom_dc_predictor_16x16 = aom_dc_predictor_16x16_c;
+    if (flags & HAS_SSE2) aom_dc_predictor_16x16 = aom_dc_predictor_16x16_sse2;
+    aom_dc_predictor_32x32 = aom_dc_predictor_32x32_c;
+    if (flags & HAS_SSE2) aom_dc_predictor_32x32 = aom_dc_predictor_32x32_sse2;
+    aom_dc_predictor_4x4 = aom_dc_predictor_4x4_c;
+    if (flags & HAS_SSE2) aom_dc_predictor_4x4 = aom_dc_predictor_4x4_sse2;
+    aom_dc_predictor_8x8 = aom_dc_predictor_8x8_c;
+    if (flags & HAS_SSE2) aom_dc_predictor_8x8 = aom_dc_predictor_8x8_sse2;
+    aom_dc_top_predictor_16x16 = aom_dc_top_predictor_16x16_c;
+    if (flags & HAS_SSE2) aom_dc_top_predictor_16x16 = aom_dc_top_predictor_16x16_sse2;
+    aom_dc_top_predictor_32x32 = aom_dc_top_predictor_32x32_c;
+    if (flags & HAS_SSE2) aom_dc_top_predictor_32x32 = aom_dc_top_predictor_32x32_sse2;
+    aom_dc_top_predictor_4x4 = aom_dc_top_predictor_4x4_c;
+    if (flags & HAS_SSE2) aom_dc_top_predictor_4x4 = aom_dc_top_predictor_4x4_sse2;
+    aom_dc_top_predictor_8x8 = aom_dc_top_predictor_8x8_c;
+    if (flags & HAS_SSE2) aom_dc_top_predictor_8x8 = aom_dc_top_predictor_8x8_sse2;
+    aom_fdct16x16 = aom_fdct16x16_c;
+    if (flags & HAS_SSE2) aom_fdct16x16 = aom_fdct16x16_sse2;
+    aom_fdct32x32 = aom_fdct32x32_c;
+    if (flags & HAS_SSE2) aom_fdct32x32 = aom_fdct32x32_sse2;
+    if (flags & HAS_AVX2) aom_fdct32x32 = aom_fdct32x32_avx2;
+    aom_fdct32x32_rd = aom_fdct32x32_rd_c;
+    if (flags & HAS_SSE2) aom_fdct32x32_rd = aom_fdct32x32_rd_sse2;
+    if (flags & HAS_AVX2) aom_fdct32x32_rd = aom_fdct32x32_rd_avx2;
+    aom_fdct4x4 = aom_fdct4x4_c;
+    if (flags & HAS_SSE2) aom_fdct4x4 = aom_fdct4x4_sse2;
+    aom_fdct4x4_1 = aom_fdct4x4_1_c;
+    if (flags & HAS_SSE2) aom_fdct4x4_1 = aom_fdct4x4_1_sse2;
+    aom_fdct8x8 = aom_fdct8x8_c;
+    if (flags & HAS_SSE2) aom_fdct8x8 = aom_fdct8x8_sse2;
+    aom_get16x16var = aom_get16x16var_c;
+    if (flags & HAS_SSE2) aom_get16x16var = aom_get16x16var_sse2;
+    if (flags & HAS_AVX2) aom_get16x16var = aom_get16x16var_avx2;
+    aom_get8x8var = aom_get8x8var_c;
+    if (flags & HAS_SSE2) aom_get8x8var = aom_get8x8var_sse2;
+    aom_get_mb_ss = aom_get_mb_ss_c;
+    if (flags & HAS_SSE2) aom_get_mb_ss = aom_get_mb_ss_sse2;
+    aom_h_predictor_16x16 = aom_h_predictor_16x16_c;
+    if (flags & HAS_SSE2) aom_h_predictor_16x16 = aom_h_predictor_16x16_sse2;
+    aom_h_predictor_32x32 = aom_h_predictor_32x32_c;
+    if (flags & HAS_SSE2) aom_h_predictor_32x32 = aom_h_predictor_32x32_sse2;
+    aom_h_predictor_4x4 = aom_h_predictor_4x4_c;
+    if (flags & HAS_SSE2) aom_h_predictor_4x4 = aom_h_predictor_4x4_sse2;
+    aom_h_predictor_8x8 = aom_h_predictor_8x8_c;
+    if (flags & HAS_SSE2) aom_h_predictor_8x8 = aom_h_predictor_8x8_sse2;
+    aom_hadamard_16x16 = aom_hadamard_16x16_c;
+    if (flags & HAS_SSE2) aom_hadamard_16x16 = aom_hadamard_16x16_sse2;
+    aom_hadamard_8x8 = aom_hadamard_8x8_c;
+    if (flags & HAS_SSE2) aom_hadamard_8x8 = aom_hadamard_8x8_sse2;
+    aom_highbd_10_mse16x16 = aom_highbd_10_mse16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_10_mse16x16 = aom_highbd_10_mse16x16_sse2;
+    aom_highbd_10_mse8x8 = aom_highbd_10_mse8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_10_mse8x8 = aom_highbd_10_mse8x8_sse2;
+    aom_highbd_10_obmc_variance16x16 = aom_highbd_10_obmc_variance16x16_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x16 = aom_highbd_10_obmc_variance16x16_sse4_1;
+    aom_highbd_10_obmc_variance16x32 = aom_highbd_10_obmc_variance16x32_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x32 = aom_highbd_10_obmc_variance16x32_sse4_1;
+    aom_highbd_10_obmc_variance16x8 = aom_highbd_10_obmc_variance16x8_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x8 = aom_highbd_10_obmc_variance16x8_sse4_1;
+    aom_highbd_10_obmc_variance32x16 = aom_highbd_10_obmc_variance32x16_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance32x16 = aom_highbd_10_obmc_variance32x16_sse4_1;
+    aom_highbd_10_obmc_variance32x32 = aom_highbd_10_obmc_variance32x32_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance32x32 = aom_highbd_10_obmc_variance32x32_sse4_1;
+    aom_highbd_10_obmc_variance32x64 = aom_highbd_10_obmc_variance32x64_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance32x64 = aom_highbd_10_obmc_variance32x64_sse4_1;
+    aom_highbd_10_obmc_variance4x4 = aom_highbd_10_obmc_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance4x4 = aom_highbd_10_obmc_variance4x4_sse4_1;
+    aom_highbd_10_obmc_variance4x8 = aom_highbd_10_obmc_variance4x8_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance4x8 = aom_highbd_10_obmc_variance4x8_sse4_1;
+    aom_highbd_10_obmc_variance64x32 = aom_highbd_10_obmc_variance64x32_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance64x32 = aom_highbd_10_obmc_variance64x32_sse4_1;
+    aom_highbd_10_obmc_variance64x64 = aom_highbd_10_obmc_variance64x64_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance64x64 = aom_highbd_10_obmc_variance64x64_sse4_1;
+    aom_highbd_10_obmc_variance8x16 = aom_highbd_10_obmc_variance8x16_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance8x16 = aom_highbd_10_obmc_variance8x16_sse4_1;
+    aom_highbd_10_obmc_variance8x4 = aom_highbd_10_obmc_variance8x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance8x4 = aom_highbd_10_obmc_variance8x4_sse4_1;
+    aom_highbd_10_obmc_variance8x8 = aom_highbd_10_obmc_variance8x8_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance8x8 = aom_highbd_10_obmc_variance8x8_sse4_1;
+    aom_highbd_10_sub_pixel_avg_variance16x16 = aom_highbd_10_sub_pixel_avg_variance16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_avg_variance16x16 = aom_highbd_10_sub_pixel_avg_variance16x16_sse2;
+    aom_highbd_10_sub_pixel_avg_variance16x32 = aom_highbd_10_sub_pixel_avg_variance16x32_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_avg_variance16x32 = aom_highbd_10_sub_pixel_avg_variance16x32_sse2;
+    aom_highbd_10_sub_pixel_avg_variance16x8 = aom_highbd_10_sub_pixel_avg_variance16x8_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_avg_variance16x8 = aom_highbd_10_sub_pixel_avg_variance16x8_sse2;
+    aom_highbd_10_sub_pixel_avg_variance32x16 = aom_highbd_10_sub_pixel_avg_variance32x16_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_avg_variance32x16 = aom_highbd_10_sub_pixel_avg_variance32x16_sse2;
+    aom_highbd_10_sub_pixel_avg_variance32x32 = aom_highbd_10_sub_pixel_avg_variance32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_avg_variance32x32 = aom_highbd_10_sub_pixel_avg_variance32x32_sse2;
+    aom_highbd_10_sub_pixel_avg_variance32x64 = aom_highbd_10_sub_pixel_avg_variance32x64_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_avg_variance32x64 = aom_highbd_10_sub_pixel_avg_variance32x64_sse2;
+    aom_highbd_10_sub_pixel_avg_variance4x4 = aom_highbd_10_sub_pixel_avg_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_sub_pixel_avg_variance4x4 = aom_highbd_10_sub_pixel_avg_variance4x4_sse4_1;
+    aom_highbd_10_sub_pixel_avg_variance64x32 = aom_highbd_10_sub_pixel_avg_variance64x32_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_avg_variance64x32 = aom_highbd_10_sub_pixel_avg_variance64x32_sse2;
+    aom_highbd_10_sub_pixel_avg_variance64x64 = aom_highbd_10_sub_pixel_avg_variance64x64_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_avg_variance64x64 = aom_highbd_10_sub_pixel_avg_variance64x64_sse2;
+    aom_highbd_10_sub_pixel_avg_variance8x16 = aom_highbd_10_sub_pixel_avg_variance8x16_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_avg_variance8x16 = aom_highbd_10_sub_pixel_avg_variance8x16_sse2;
+    aom_highbd_10_sub_pixel_avg_variance8x4 = aom_highbd_10_sub_pixel_avg_variance8x4_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_avg_variance8x4 = aom_highbd_10_sub_pixel_avg_variance8x4_sse2;
+    aom_highbd_10_sub_pixel_avg_variance8x8 = aom_highbd_10_sub_pixel_avg_variance8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_avg_variance8x8 = aom_highbd_10_sub_pixel_avg_variance8x8_sse2;
+    aom_highbd_10_sub_pixel_variance16x16 = aom_highbd_10_sub_pixel_variance16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_variance16x16 = aom_highbd_10_sub_pixel_variance16x16_sse2;
+    aom_highbd_10_sub_pixel_variance16x32 = aom_highbd_10_sub_pixel_variance16x32_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_variance16x32 = aom_highbd_10_sub_pixel_variance16x32_sse2;
+    aom_highbd_10_sub_pixel_variance16x8 = aom_highbd_10_sub_pixel_variance16x8_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_variance16x8 = aom_highbd_10_sub_pixel_variance16x8_sse2;
+    aom_highbd_10_sub_pixel_variance32x16 = aom_highbd_10_sub_pixel_variance32x16_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_variance32x16 = aom_highbd_10_sub_pixel_variance32x16_sse2;
+    aom_highbd_10_sub_pixel_variance32x32 = aom_highbd_10_sub_pixel_variance32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_variance32x32 = aom_highbd_10_sub_pixel_variance32x32_sse2;
+    aom_highbd_10_sub_pixel_variance32x64 = aom_highbd_10_sub_pixel_variance32x64_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_variance32x64 = aom_highbd_10_sub_pixel_variance32x64_sse2;
+    aom_highbd_10_sub_pixel_variance4x4 = aom_highbd_10_sub_pixel_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_sub_pixel_variance4x4 = aom_highbd_10_sub_pixel_variance4x4_sse4_1;
+    aom_highbd_10_sub_pixel_variance64x32 = aom_highbd_10_sub_pixel_variance64x32_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_variance64x32 = aom_highbd_10_sub_pixel_variance64x32_sse2;
+    aom_highbd_10_sub_pixel_variance64x64 = aom_highbd_10_sub_pixel_variance64x64_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_variance64x64 = aom_highbd_10_sub_pixel_variance64x64_sse2;
+    aom_highbd_10_sub_pixel_variance8x16 = aom_highbd_10_sub_pixel_variance8x16_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_variance8x16 = aom_highbd_10_sub_pixel_variance8x16_sse2;
+    aom_highbd_10_sub_pixel_variance8x4 = aom_highbd_10_sub_pixel_variance8x4_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_variance8x4 = aom_highbd_10_sub_pixel_variance8x4_sse2;
+    aom_highbd_10_sub_pixel_variance8x8 = aom_highbd_10_sub_pixel_variance8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_10_sub_pixel_variance8x8 = aom_highbd_10_sub_pixel_variance8x8_sse2;
+    aom_highbd_10_variance16x16 = aom_highbd_10_variance16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_10_variance16x16 = aom_highbd_10_variance16x16_sse2;
+    aom_highbd_10_variance16x32 = aom_highbd_10_variance16x32_c;
+    if (flags & HAS_SSE2) aom_highbd_10_variance16x32 = aom_highbd_10_variance16x32_sse2;
+    aom_highbd_10_variance16x8 = aom_highbd_10_variance16x8_c;
+    if (flags & HAS_SSE2) aom_highbd_10_variance16x8 = aom_highbd_10_variance16x8_sse2;
+    aom_highbd_10_variance32x16 = aom_highbd_10_variance32x16_c;
+    if (flags & HAS_SSE2) aom_highbd_10_variance32x16 = aom_highbd_10_variance32x16_sse2;
+    aom_highbd_10_variance32x32 = aom_highbd_10_variance32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_10_variance32x32 = aom_highbd_10_variance32x32_sse2;
+    aom_highbd_10_variance32x64 = aom_highbd_10_variance32x64_c;
+    if (flags & HAS_SSE2) aom_highbd_10_variance32x64 = aom_highbd_10_variance32x64_sse2;
+    aom_highbd_10_variance4x4 = aom_highbd_10_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_10_variance4x4 = aom_highbd_10_variance4x4_sse4_1;
+    aom_highbd_10_variance64x32 = aom_highbd_10_variance64x32_c;
+    if (flags & HAS_SSE2) aom_highbd_10_variance64x32 = aom_highbd_10_variance64x32_sse2;
+    aom_highbd_10_variance64x64 = aom_highbd_10_variance64x64_c;
+    if (flags & HAS_SSE2) aom_highbd_10_variance64x64 = aom_highbd_10_variance64x64_sse2;
+    aom_highbd_10_variance8x16 = aom_highbd_10_variance8x16_c;
+    if (flags & HAS_SSE2) aom_highbd_10_variance8x16 = aom_highbd_10_variance8x16_sse2;
+    aom_highbd_10_variance8x8 = aom_highbd_10_variance8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_10_variance8x8 = aom_highbd_10_variance8x8_sse2;
+    aom_highbd_12_mse16x16 = aom_highbd_12_mse16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_12_mse16x16 = aom_highbd_12_mse16x16_sse2;
+    aom_highbd_12_mse8x8 = aom_highbd_12_mse8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_12_mse8x8 = aom_highbd_12_mse8x8_sse2;
+    aom_highbd_12_obmc_variance16x16 = aom_highbd_12_obmc_variance16x16_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x16 = aom_highbd_12_obmc_variance16x16_sse4_1;
+    aom_highbd_12_obmc_variance16x32 = aom_highbd_12_obmc_variance16x32_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x32 = aom_highbd_12_obmc_variance16x32_sse4_1;
+    aom_highbd_12_obmc_variance16x8 = aom_highbd_12_obmc_variance16x8_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x8 = aom_highbd_12_obmc_variance16x8_sse4_1;
+    aom_highbd_12_obmc_variance32x16 = aom_highbd_12_obmc_variance32x16_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance32x16 = aom_highbd_12_obmc_variance32x16_sse4_1;
+    aom_highbd_12_obmc_variance32x32 = aom_highbd_12_obmc_variance32x32_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance32x32 = aom_highbd_12_obmc_variance32x32_sse4_1;
+    aom_highbd_12_obmc_variance32x64 = aom_highbd_12_obmc_variance32x64_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance32x64 = aom_highbd_12_obmc_variance32x64_sse4_1;
+    aom_highbd_12_obmc_variance4x4 = aom_highbd_12_obmc_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance4x4 = aom_highbd_12_obmc_variance4x4_sse4_1;
+    aom_highbd_12_obmc_variance4x8 = aom_highbd_12_obmc_variance4x8_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance4x8 = aom_highbd_12_obmc_variance4x8_sse4_1;
+    aom_highbd_12_obmc_variance64x32 = aom_highbd_12_obmc_variance64x32_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance64x32 = aom_highbd_12_obmc_variance64x32_sse4_1;
+    aom_highbd_12_obmc_variance64x64 = aom_highbd_12_obmc_variance64x64_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance64x64 = aom_highbd_12_obmc_variance64x64_sse4_1;
+    aom_highbd_12_obmc_variance8x16 = aom_highbd_12_obmc_variance8x16_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance8x16 = aom_highbd_12_obmc_variance8x16_sse4_1;
+    aom_highbd_12_obmc_variance8x4 = aom_highbd_12_obmc_variance8x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance8x4 = aom_highbd_12_obmc_variance8x4_sse4_1;
+    aom_highbd_12_obmc_variance8x8 = aom_highbd_12_obmc_variance8x8_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance8x8 = aom_highbd_12_obmc_variance8x8_sse4_1;
+    aom_highbd_12_sub_pixel_avg_variance16x16 = aom_highbd_12_sub_pixel_avg_variance16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_avg_variance16x16 = aom_highbd_12_sub_pixel_avg_variance16x16_sse2;
+    aom_highbd_12_sub_pixel_avg_variance16x32 = aom_highbd_12_sub_pixel_avg_variance16x32_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_avg_variance16x32 = aom_highbd_12_sub_pixel_avg_variance16x32_sse2;
+    aom_highbd_12_sub_pixel_avg_variance16x8 = aom_highbd_12_sub_pixel_avg_variance16x8_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_avg_variance16x8 = aom_highbd_12_sub_pixel_avg_variance16x8_sse2;
+    aom_highbd_12_sub_pixel_avg_variance32x16 = aom_highbd_12_sub_pixel_avg_variance32x16_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_avg_variance32x16 = aom_highbd_12_sub_pixel_avg_variance32x16_sse2;
+    aom_highbd_12_sub_pixel_avg_variance32x32 = aom_highbd_12_sub_pixel_avg_variance32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_avg_variance32x32 = aom_highbd_12_sub_pixel_avg_variance32x32_sse2;
+    aom_highbd_12_sub_pixel_avg_variance32x64 = aom_highbd_12_sub_pixel_avg_variance32x64_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_avg_variance32x64 = aom_highbd_12_sub_pixel_avg_variance32x64_sse2;
+    aom_highbd_12_sub_pixel_avg_variance4x4 = aom_highbd_12_sub_pixel_avg_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_sub_pixel_avg_variance4x4 = aom_highbd_12_sub_pixel_avg_variance4x4_sse4_1;
+    aom_highbd_12_sub_pixel_avg_variance64x32 = aom_highbd_12_sub_pixel_avg_variance64x32_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_avg_variance64x32 = aom_highbd_12_sub_pixel_avg_variance64x32_sse2;
+    aom_highbd_12_sub_pixel_avg_variance64x64 = aom_highbd_12_sub_pixel_avg_variance64x64_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_avg_variance64x64 = aom_highbd_12_sub_pixel_avg_variance64x64_sse2;
+    aom_highbd_12_sub_pixel_avg_variance8x16 = aom_highbd_12_sub_pixel_avg_variance8x16_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_avg_variance8x16 = aom_highbd_12_sub_pixel_avg_variance8x16_sse2;
+    aom_highbd_12_sub_pixel_avg_variance8x4 = aom_highbd_12_sub_pixel_avg_variance8x4_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_avg_variance8x4 = aom_highbd_12_sub_pixel_avg_variance8x4_sse2;
+    aom_highbd_12_sub_pixel_avg_variance8x8 = aom_highbd_12_sub_pixel_avg_variance8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_avg_variance8x8 = aom_highbd_12_sub_pixel_avg_variance8x8_sse2;
+    aom_highbd_12_sub_pixel_variance16x16 = aom_highbd_12_sub_pixel_variance16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_variance16x16 = aom_highbd_12_sub_pixel_variance16x16_sse2;
+    aom_highbd_12_sub_pixel_variance16x32 = aom_highbd_12_sub_pixel_variance16x32_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_variance16x32 = aom_highbd_12_sub_pixel_variance16x32_sse2;
+    aom_highbd_12_sub_pixel_variance16x8 = aom_highbd_12_sub_pixel_variance16x8_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_variance16x8 = aom_highbd_12_sub_pixel_variance16x8_sse2;
+    aom_highbd_12_sub_pixel_variance32x16 = aom_highbd_12_sub_pixel_variance32x16_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_variance32x16 = aom_highbd_12_sub_pixel_variance32x16_sse2;
+    aom_highbd_12_sub_pixel_variance32x32 = aom_highbd_12_sub_pixel_variance32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_variance32x32 = aom_highbd_12_sub_pixel_variance32x32_sse2;
+    aom_highbd_12_sub_pixel_variance32x64 = aom_highbd_12_sub_pixel_variance32x64_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_variance32x64 = aom_highbd_12_sub_pixel_variance32x64_sse2;
+    aom_highbd_12_sub_pixel_variance4x4 = aom_highbd_12_sub_pixel_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_sub_pixel_variance4x4 = aom_highbd_12_sub_pixel_variance4x4_sse4_1;
+    aom_highbd_12_sub_pixel_variance64x32 = aom_highbd_12_sub_pixel_variance64x32_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_variance64x32 = aom_highbd_12_sub_pixel_variance64x32_sse2;
+    aom_highbd_12_sub_pixel_variance64x64 = aom_highbd_12_sub_pixel_variance64x64_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_variance64x64 = aom_highbd_12_sub_pixel_variance64x64_sse2;
+    aom_highbd_12_sub_pixel_variance8x16 = aom_highbd_12_sub_pixel_variance8x16_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_variance8x16 = aom_highbd_12_sub_pixel_variance8x16_sse2;
+    aom_highbd_12_sub_pixel_variance8x4 = aom_highbd_12_sub_pixel_variance8x4_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_variance8x4 = aom_highbd_12_sub_pixel_variance8x4_sse2;
+    aom_highbd_12_sub_pixel_variance8x8 = aom_highbd_12_sub_pixel_variance8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_12_sub_pixel_variance8x8 = aom_highbd_12_sub_pixel_variance8x8_sse2;
+    aom_highbd_12_variance16x16 = aom_highbd_12_variance16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_12_variance16x16 = aom_highbd_12_variance16x16_sse2;
+    aom_highbd_12_variance16x32 = aom_highbd_12_variance16x32_c;
+    if (flags & HAS_SSE2) aom_highbd_12_variance16x32 = aom_highbd_12_variance16x32_sse2;
+    aom_highbd_12_variance16x8 = aom_highbd_12_variance16x8_c;
+    if (flags & HAS_SSE2) aom_highbd_12_variance16x8 = aom_highbd_12_variance16x8_sse2;
+    aom_highbd_12_variance32x16 = aom_highbd_12_variance32x16_c;
+    if (flags & HAS_SSE2) aom_highbd_12_variance32x16 = aom_highbd_12_variance32x16_sse2;
+    aom_highbd_12_variance32x32 = aom_highbd_12_variance32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_12_variance32x32 = aom_highbd_12_variance32x32_sse2;
+    aom_highbd_12_variance32x64 = aom_highbd_12_variance32x64_c;
+    if (flags & HAS_SSE2) aom_highbd_12_variance32x64 = aom_highbd_12_variance32x64_sse2;
+    aom_highbd_12_variance4x4 = aom_highbd_12_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_12_variance4x4 = aom_highbd_12_variance4x4_sse4_1;
+    aom_highbd_12_variance64x32 = aom_highbd_12_variance64x32_c;
+    if (flags & HAS_SSE2) aom_highbd_12_variance64x32 = aom_highbd_12_variance64x32_sse2;
+    aom_highbd_12_variance64x64 = aom_highbd_12_variance64x64_c;
+    if (flags & HAS_SSE2) aom_highbd_12_variance64x64 = aom_highbd_12_variance64x64_sse2;
+    aom_highbd_12_variance8x16 = aom_highbd_12_variance8x16_c;
+    if (flags & HAS_SSE2) aom_highbd_12_variance8x16 = aom_highbd_12_variance8x16_sse2;
+    aom_highbd_12_variance8x8 = aom_highbd_12_variance8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_12_variance8x8 = aom_highbd_12_variance8x8_sse2;
+    aom_highbd_8_mse16x16 = aom_highbd_8_mse16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_8_mse16x16 = aom_highbd_8_mse16x16_sse2;
+    aom_highbd_8_mse8x8 = aom_highbd_8_mse8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_8_mse8x8 = aom_highbd_8_mse8x8_sse2;
+    aom_highbd_8_sub_pixel_avg_variance16x16 = aom_highbd_8_sub_pixel_avg_variance16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance16x16 = aom_highbd_8_sub_pixel_avg_variance16x16_sse2;
+    aom_highbd_8_sub_pixel_avg_variance16x32 = aom_highbd_8_sub_pixel_avg_variance16x32_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance16x32 = aom_highbd_8_sub_pixel_avg_variance16x32_sse2;
+    aom_highbd_8_sub_pixel_avg_variance16x8 = aom_highbd_8_sub_pixel_avg_variance16x8_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance16x8 = aom_highbd_8_sub_pixel_avg_variance16x8_sse2;
+    aom_highbd_8_sub_pixel_avg_variance32x16 = aom_highbd_8_sub_pixel_avg_variance32x16_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance32x16 = aom_highbd_8_sub_pixel_avg_variance32x16_sse2;
+    aom_highbd_8_sub_pixel_avg_variance32x32 = aom_highbd_8_sub_pixel_avg_variance32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance32x32 = aom_highbd_8_sub_pixel_avg_variance32x32_sse2;
+    aom_highbd_8_sub_pixel_avg_variance32x64 = aom_highbd_8_sub_pixel_avg_variance32x64_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance32x64 = aom_highbd_8_sub_pixel_avg_variance32x64_sse2;
+    aom_highbd_8_sub_pixel_avg_variance4x4 = aom_highbd_8_sub_pixel_avg_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_8_sub_pixel_avg_variance4x4 = aom_highbd_8_sub_pixel_avg_variance4x4_sse4_1;
+    aom_highbd_8_sub_pixel_avg_variance64x32 = aom_highbd_8_sub_pixel_avg_variance64x32_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance64x32 = aom_highbd_8_sub_pixel_avg_variance64x32_sse2;
+    aom_highbd_8_sub_pixel_avg_variance64x64 = aom_highbd_8_sub_pixel_avg_variance64x64_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance64x64 = aom_highbd_8_sub_pixel_avg_variance64x64_sse2;
+    aom_highbd_8_sub_pixel_avg_variance8x16 = aom_highbd_8_sub_pixel_avg_variance8x16_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance8x16 = aom_highbd_8_sub_pixel_avg_variance8x16_sse2;
+    aom_highbd_8_sub_pixel_avg_variance8x4 = aom_highbd_8_sub_pixel_avg_variance8x4_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance8x4 = aom_highbd_8_sub_pixel_avg_variance8x4_sse2;
+    aom_highbd_8_sub_pixel_avg_variance8x8 = aom_highbd_8_sub_pixel_avg_variance8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_avg_variance8x8 = aom_highbd_8_sub_pixel_avg_variance8x8_sse2;
+    aom_highbd_8_sub_pixel_variance16x16 = aom_highbd_8_sub_pixel_variance16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_variance16x16 = aom_highbd_8_sub_pixel_variance16x16_sse2;
+    aom_highbd_8_sub_pixel_variance16x32 = aom_highbd_8_sub_pixel_variance16x32_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_variance16x32 = aom_highbd_8_sub_pixel_variance16x32_sse2;
+    aom_highbd_8_sub_pixel_variance16x8 = aom_highbd_8_sub_pixel_variance16x8_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_variance16x8 = aom_highbd_8_sub_pixel_variance16x8_sse2;
+    aom_highbd_8_sub_pixel_variance32x16 = aom_highbd_8_sub_pixel_variance32x16_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_variance32x16 = aom_highbd_8_sub_pixel_variance32x16_sse2;
+    aom_highbd_8_sub_pixel_variance32x32 = aom_highbd_8_sub_pixel_variance32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_variance32x32 = aom_highbd_8_sub_pixel_variance32x32_sse2;
+    aom_highbd_8_sub_pixel_variance32x64 = aom_highbd_8_sub_pixel_variance32x64_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_variance32x64 = aom_highbd_8_sub_pixel_variance32x64_sse2;
+    aom_highbd_8_sub_pixel_variance4x4 = aom_highbd_8_sub_pixel_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_8_sub_pixel_variance4x4 = aom_highbd_8_sub_pixel_variance4x4_sse4_1;
+    aom_highbd_8_sub_pixel_variance64x32 = aom_highbd_8_sub_pixel_variance64x32_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_variance64x32 = aom_highbd_8_sub_pixel_variance64x32_sse2;
+    aom_highbd_8_sub_pixel_variance64x64 = aom_highbd_8_sub_pixel_variance64x64_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_variance64x64 = aom_highbd_8_sub_pixel_variance64x64_sse2;
+    aom_highbd_8_sub_pixel_variance8x16 = aom_highbd_8_sub_pixel_variance8x16_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_variance8x16 = aom_highbd_8_sub_pixel_variance8x16_sse2;
+    aom_highbd_8_sub_pixel_variance8x4 = aom_highbd_8_sub_pixel_variance8x4_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_variance8x4 = aom_highbd_8_sub_pixel_variance8x4_sse2;
+    aom_highbd_8_sub_pixel_variance8x8 = aom_highbd_8_sub_pixel_variance8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_8_sub_pixel_variance8x8 = aom_highbd_8_sub_pixel_variance8x8_sse2;
+    aom_highbd_8_variance16x16 = aom_highbd_8_variance16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_8_variance16x16 = aom_highbd_8_variance16x16_sse2;
+    aom_highbd_8_variance16x32 = aom_highbd_8_variance16x32_c;
+    if (flags & HAS_SSE2) aom_highbd_8_variance16x32 = aom_highbd_8_variance16x32_sse2;
+    aom_highbd_8_variance16x8 = aom_highbd_8_variance16x8_c;
+    if (flags & HAS_SSE2) aom_highbd_8_variance16x8 = aom_highbd_8_variance16x8_sse2;
+    aom_highbd_8_variance32x16 = aom_highbd_8_variance32x16_c;
+    if (flags & HAS_SSE2) aom_highbd_8_variance32x16 = aom_highbd_8_variance32x16_sse2;
+    aom_highbd_8_variance32x32 = aom_highbd_8_variance32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_8_variance32x32 = aom_highbd_8_variance32x32_sse2;
+    aom_highbd_8_variance32x64 = aom_highbd_8_variance32x64_c;
+    if (flags & HAS_SSE2) aom_highbd_8_variance32x64 = aom_highbd_8_variance32x64_sse2;
+    aom_highbd_8_variance4x4 = aom_highbd_8_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_8_variance4x4 = aom_highbd_8_variance4x4_sse4_1;
+    aom_highbd_8_variance64x32 = aom_highbd_8_variance64x32_c;
+    if (flags & HAS_SSE2) aom_highbd_8_variance64x32 = aom_highbd_8_variance64x32_sse2;
+    aom_highbd_8_variance64x64 = aom_highbd_8_variance64x64_c;
+    if (flags & HAS_SSE2) aom_highbd_8_variance64x64 = aom_highbd_8_variance64x64_sse2;
+    aom_highbd_8_variance8x16 = aom_highbd_8_variance8x16_c;
+    if (flags & HAS_SSE2) aom_highbd_8_variance8x16 = aom_highbd_8_variance8x16_sse2;
+    aom_highbd_8_variance8x8 = aom_highbd_8_variance8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_8_variance8x8 = aom_highbd_8_variance8x8_sse2;
+    aom_highbd_blend_a64_hmask = aom_highbd_blend_a64_hmask_c;
+    if (flags & HAS_SSE4_1) aom_highbd_blend_a64_hmask = aom_highbd_blend_a64_hmask_sse4_1;
+    aom_highbd_blend_a64_mask = aom_highbd_blend_a64_mask_c;
+    if (flags & HAS_SSE4_1) aom_highbd_blend_a64_mask = aom_highbd_blend_a64_mask_sse4_1;
+    aom_highbd_blend_a64_vmask = aom_highbd_blend_a64_vmask_c;
+    if (flags & HAS_SSE4_1) aom_highbd_blend_a64_vmask = aom_highbd_blend_a64_vmask_sse4_1;
+    aom_highbd_comp_avg_upsampled_pred = aom_highbd_comp_avg_upsampled_pred_c;
+    if (flags & HAS_SSE2) aom_highbd_comp_avg_upsampled_pred = aom_highbd_comp_avg_upsampled_pred_sse2;
+    aom_highbd_convolve8 = aom_highbd_convolve8_c;
+    if (flags & HAS_AVX2) aom_highbd_convolve8 = aom_highbd_convolve8_avx2;
+    aom_highbd_convolve8_avg = aom_highbd_convolve8_avg_c;
+    if (flags & HAS_AVX2) aom_highbd_convolve8_avg = aom_highbd_convolve8_avg_avx2;
+    aom_highbd_convolve8_avg_horiz = aom_highbd_convolve8_avg_horiz_c;
+    if (flags & HAS_AVX2) aom_highbd_convolve8_avg_horiz = aom_highbd_convolve8_avg_horiz_avx2;
+    aom_highbd_convolve8_avg_vert = aom_highbd_convolve8_avg_vert_c;
+    if (flags & HAS_AVX2) aom_highbd_convolve8_avg_vert = aom_highbd_convolve8_avg_vert_avx2;
+    aom_highbd_convolve8_horiz = aom_highbd_convolve8_horiz_c;
+    if (flags & HAS_AVX2) aom_highbd_convolve8_horiz = aom_highbd_convolve8_horiz_avx2;
+    aom_highbd_convolve8_vert = aom_highbd_convolve8_vert_c;
+    if (flags & HAS_AVX2) aom_highbd_convolve8_vert = aom_highbd_convolve8_vert_avx2;
+    aom_highbd_convolve_avg = aom_highbd_convolve_avg_c;
+    if (flags & HAS_SSE2) aom_highbd_convolve_avg = aom_highbd_convolve_avg_sse2;
+    if (flags & HAS_AVX2) aom_highbd_convolve_avg = aom_highbd_convolve_avg_avx2;
+    aom_highbd_convolve_copy = aom_highbd_convolve_copy_c;
+    if (flags & HAS_SSE2) aom_highbd_convolve_copy = aom_highbd_convolve_copy_sse2;
+    if (flags & HAS_AVX2) aom_highbd_convolve_copy = aom_highbd_convolve_copy_avx2;
+    aom_highbd_dc_predictor_16x16 = aom_highbd_dc_predictor_16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_dc_predictor_16x16 = aom_highbd_dc_predictor_16x16_sse2;
+    aom_highbd_dc_predictor_32x32 = aom_highbd_dc_predictor_32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_dc_predictor_32x32 = aom_highbd_dc_predictor_32x32_sse2;
+    aom_highbd_dc_predictor_4x4 = aom_highbd_dc_predictor_4x4_c;
+    if (flags & HAS_SSE2) aom_highbd_dc_predictor_4x4 = aom_highbd_dc_predictor_4x4_sse2;
+    aom_highbd_dc_predictor_8x8 = aom_highbd_dc_predictor_8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_dc_predictor_8x8 = aom_highbd_dc_predictor_8x8_sse2;
+    aom_highbd_fdct16x16 = aom_highbd_fdct16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_fdct16x16 = aom_highbd_fdct16x16_sse2;
+    aom_highbd_fdct32x32 = aom_highbd_fdct32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_fdct32x32 = aom_highbd_fdct32x32_sse2;
+    aom_highbd_fdct32x32_rd = aom_highbd_fdct32x32_rd_c;
+    if (flags & HAS_SSE2) aom_highbd_fdct32x32_rd = aom_highbd_fdct32x32_rd_sse2;
+    aom_highbd_fdct4x4 = aom_highbd_fdct4x4_c;
+    if (flags & HAS_SSE2) aom_highbd_fdct4x4 = aom_highbd_fdct4x4_sse2;
+    aom_highbd_fdct8x8 = aom_highbd_fdct8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_fdct8x8 = aom_highbd_fdct8x8_sse2;
+    aom_highbd_lpf_horizontal_4 = aom_highbd_lpf_horizontal_4_c;
+    if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_4 = aom_highbd_lpf_horizontal_4_sse2;
+    aom_highbd_lpf_horizontal_4_dual = aom_highbd_lpf_horizontal_4_dual_c;
+    if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_4_dual = aom_highbd_lpf_horizontal_4_dual_sse2;
+    aom_highbd_lpf_horizontal_8 = aom_highbd_lpf_horizontal_8_c;
+    if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_8 = aom_highbd_lpf_horizontal_8_sse2;
+    aom_highbd_lpf_horizontal_8_dual = aom_highbd_lpf_horizontal_8_dual_c;
+    if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_8_dual = aom_highbd_lpf_horizontal_8_dual_sse2;
+    aom_highbd_lpf_horizontal_edge_16 = aom_highbd_lpf_horizontal_edge_16_c;
+    if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_edge_16 = aom_highbd_lpf_horizontal_edge_16_sse2;
+    aom_highbd_lpf_horizontal_edge_8 = aom_highbd_lpf_horizontal_edge_8_c;
+    if (flags & HAS_SSE2) aom_highbd_lpf_horizontal_edge_8 = aom_highbd_lpf_horizontal_edge_8_sse2;
+    aom_highbd_lpf_vertical_16 = aom_highbd_lpf_vertical_16_c;
+    if (flags & HAS_SSE2) aom_highbd_lpf_vertical_16 = aom_highbd_lpf_vertical_16_sse2;
+    aom_highbd_lpf_vertical_16_dual = aom_highbd_lpf_vertical_16_dual_c;
+    if (flags & HAS_SSE2) aom_highbd_lpf_vertical_16_dual = aom_highbd_lpf_vertical_16_dual_sse2;
+    aom_highbd_lpf_vertical_4 = aom_highbd_lpf_vertical_4_c;
+    if (flags & HAS_SSE2) aom_highbd_lpf_vertical_4 = aom_highbd_lpf_vertical_4_sse2;
+    aom_highbd_lpf_vertical_4_dual = aom_highbd_lpf_vertical_4_dual_c;
+    if (flags & HAS_SSE2) aom_highbd_lpf_vertical_4_dual = aom_highbd_lpf_vertical_4_dual_sse2;
+    aom_highbd_lpf_vertical_8 = aom_highbd_lpf_vertical_8_c;
+    if (flags & HAS_SSE2) aom_highbd_lpf_vertical_8 = aom_highbd_lpf_vertical_8_sse2;
+    aom_highbd_lpf_vertical_8_dual = aom_highbd_lpf_vertical_8_dual_c;
+    if (flags & HAS_SSE2) aom_highbd_lpf_vertical_8_dual = aom_highbd_lpf_vertical_8_dual_sse2;
+    aom_highbd_obmc_sad16x16 = aom_highbd_obmc_sad16x16_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x16 = aom_highbd_obmc_sad16x16_sse4_1;
+    aom_highbd_obmc_sad16x32 = aom_highbd_obmc_sad16x32_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x32 = aom_highbd_obmc_sad16x32_sse4_1;
+    aom_highbd_obmc_sad16x8 = aom_highbd_obmc_sad16x8_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x8 = aom_highbd_obmc_sad16x8_sse4_1;
+    aom_highbd_obmc_sad32x16 = aom_highbd_obmc_sad32x16_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad32x16 = aom_highbd_obmc_sad32x16_sse4_1;
+    aom_highbd_obmc_sad32x32 = aom_highbd_obmc_sad32x32_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad32x32 = aom_highbd_obmc_sad32x32_sse4_1;
+    aom_highbd_obmc_sad32x64 = aom_highbd_obmc_sad32x64_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad32x64 = aom_highbd_obmc_sad32x64_sse4_1;
+    aom_highbd_obmc_sad4x4 = aom_highbd_obmc_sad4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad4x4 = aom_highbd_obmc_sad4x4_sse4_1;
+    aom_highbd_obmc_sad4x8 = aom_highbd_obmc_sad4x8_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad4x8 = aom_highbd_obmc_sad4x8_sse4_1;
+    aom_highbd_obmc_sad64x32 = aom_highbd_obmc_sad64x32_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad64x32 = aom_highbd_obmc_sad64x32_sse4_1;
+    aom_highbd_obmc_sad64x64 = aom_highbd_obmc_sad64x64_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad64x64 = aom_highbd_obmc_sad64x64_sse4_1;
+    aom_highbd_obmc_sad8x16 = aom_highbd_obmc_sad8x16_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad8x16 = aom_highbd_obmc_sad8x16_sse4_1;
+    aom_highbd_obmc_sad8x4 = aom_highbd_obmc_sad8x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad8x4 = aom_highbd_obmc_sad8x4_sse4_1;
+    aom_highbd_obmc_sad8x8 = aom_highbd_obmc_sad8x8_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_sad8x8 = aom_highbd_obmc_sad8x8_sse4_1;
+    aom_highbd_obmc_variance16x16 = aom_highbd_obmc_variance16x16_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance16x16 = aom_highbd_obmc_variance16x16_sse4_1;
+    aom_highbd_obmc_variance16x32 = aom_highbd_obmc_variance16x32_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance16x32 = aom_highbd_obmc_variance16x32_sse4_1;
+    aom_highbd_obmc_variance16x8 = aom_highbd_obmc_variance16x8_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance16x8 = aom_highbd_obmc_variance16x8_sse4_1;
+    aom_highbd_obmc_variance32x16 = aom_highbd_obmc_variance32x16_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance32x16 = aom_highbd_obmc_variance32x16_sse4_1;
+    aom_highbd_obmc_variance32x32 = aom_highbd_obmc_variance32x32_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance32x32 = aom_highbd_obmc_variance32x32_sse4_1;
+    aom_highbd_obmc_variance32x64 = aom_highbd_obmc_variance32x64_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance32x64 = aom_highbd_obmc_variance32x64_sse4_1;
+    aom_highbd_obmc_variance4x4 = aom_highbd_obmc_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance4x4 = aom_highbd_obmc_variance4x4_sse4_1;
+    aom_highbd_obmc_variance4x8 = aom_highbd_obmc_variance4x8_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance4x8 = aom_highbd_obmc_variance4x8_sse4_1;
+    aom_highbd_obmc_variance64x32 = aom_highbd_obmc_variance64x32_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance64x32 = aom_highbd_obmc_variance64x32_sse4_1;
+    aom_highbd_obmc_variance64x64 = aom_highbd_obmc_variance64x64_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance64x64 = aom_highbd_obmc_variance64x64_sse4_1;
+    aom_highbd_obmc_variance8x16 = aom_highbd_obmc_variance8x16_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x16 = aom_highbd_obmc_variance8x16_sse4_1;
+    aom_highbd_obmc_variance8x4 = aom_highbd_obmc_variance8x4_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x4 = aom_highbd_obmc_variance8x4_sse4_1;
+    aom_highbd_obmc_variance8x8 = aom_highbd_obmc_variance8x8_c;
+    if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x8 = aom_highbd_obmc_variance8x8_sse4_1;
+    aom_highbd_quantize_b = aom_highbd_quantize_b_c;
+    if (flags & HAS_SSE2) aom_highbd_quantize_b = aom_highbd_quantize_b_sse2;
+    if (flags & HAS_AVX2) aom_highbd_quantize_b = aom_highbd_quantize_b_avx2;
+    aom_highbd_quantize_b_32x32 = aom_highbd_quantize_b_32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_quantize_b_32x32 = aom_highbd_quantize_b_32x32_sse2;
+    aom_highbd_sad16x16 = aom_highbd_sad16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_sad16x16 = aom_highbd_sad16x16_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad16x16 = aom_highbd_sad16x16_avx2;
+    aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_c;
+    if (flags & HAS_SSE2) aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_avx2;
+    aom_highbd_sad16x16x4d = aom_highbd_sad16x16x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad16x16x4d = aom_highbd_sad16x16x4d_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad16x16x4d = aom_highbd_sad16x16x4d_avx2;
+    aom_highbd_sad16x32 = aom_highbd_sad16x32_c;
+    if (flags & HAS_SSE2) aom_highbd_sad16x32 = aom_highbd_sad16x32_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad16x32 = aom_highbd_sad16x32_avx2;
+    aom_highbd_sad16x32_avg = aom_highbd_sad16x32_avg_c;
+    if (flags & HAS_SSE2) aom_highbd_sad16x32_avg = aom_highbd_sad16x32_avg_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad16x32_avg = aom_highbd_sad16x32_avg_avx2;
+    aom_highbd_sad16x32x4d = aom_highbd_sad16x32x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad16x32x4d = aom_highbd_sad16x32x4d_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad16x32x4d = aom_highbd_sad16x32x4d_avx2;
+    aom_highbd_sad16x8 = aom_highbd_sad16x8_c;
+    if (flags & HAS_SSE2) aom_highbd_sad16x8 = aom_highbd_sad16x8_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad16x8 = aom_highbd_sad16x8_avx2;
+    aom_highbd_sad16x8_avg = aom_highbd_sad16x8_avg_c;
+    if (flags & HAS_SSE2) aom_highbd_sad16x8_avg = aom_highbd_sad16x8_avg_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad16x8_avg = aom_highbd_sad16x8_avg_avx2;
+    aom_highbd_sad16x8x4d = aom_highbd_sad16x8x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad16x8x4d = aom_highbd_sad16x8x4d_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad16x8x4d = aom_highbd_sad16x8x4d_avx2;
+    aom_highbd_sad32x16 = aom_highbd_sad32x16_c;
+    if (flags & HAS_SSE2) aom_highbd_sad32x16 = aom_highbd_sad32x16_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad32x16 = aom_highbd_sad32x16_avx2;
+    aom_highbd_sad32x16_avg = aom_highbd_sad32x16_avg_c;
+    if (flags & HAS_SSE2) aom_highbd_sad32x16_avg = aom_highbd_sad32x16_avg_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad32x16_avg = aom_highbd_sad32x16_avg_avx2;
+    aom_highbd_sad32x16x4d = aom_highbd_sad32x16x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad32x16x4d = aom_highbd_sad32x16x4d_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad32x16x4d = aom_highbd_sad32x16x4d_avx2;
+    aom_highbd_sad32x32 = aom_highbd_sad32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_sad32x32 = aom_highbd_sad32x32_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad32x32 = aom_highbd_sad32x32_avx2;
+    aom_highbd_sad32x32_avg = aom_highbd_sad32x32_avg_c;
+    if (flags & HAS_SSE2) aom_highbd_sad32x32_avg = aom_highbd_sad32x32_avg_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad32x32_avg = aom_highbd_sad32x32_avg_avx2;
+    aom_highbd_sad32x32x4d = aom_highbd_sad32x32x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad32x32x4d = aom_highbd_sad32x32x4d_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad32x32x4d = aom_highbd_sad32x32x4d_avx2;
+    aom_highbd_sad32x64 = aom_highbd_sad32x64_c;
+    if (flags & HAS_SSE2) aom_highbd_sad32x64 = aom_highbd_sad32x64_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad32x64 = aom_highbd_sad32x64_avx2;
+    aom_highbd_sad32x64_avg = aom_highbd_sad32x64_avg_c;
+    if (flags & HAS_SSE2) aom_highbd_sad32x64_avg = aom_highbd_sad32x64_avg_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad32x64_avg = aom_highbd_sad32x64_avg_avx2;
+    aom_highbd_sad32x64x4d = aom_highbd_sad32x64x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad32x64x4d = aom_highbd_sad32x64x4d_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad32x64x4d = aom_highbd_sad32x64x4d_avx2;
+    aom_highbd_sad4x4x4d = aom_highbd_sad4x4x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad4x4x4d = aom_highbd_sad4x4x4d_sse2;
+    aom_highbd_sad4x8x4d = aom_highbd_sad4x8x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad4x8x4d = aom_highbd_sad4x8x4d_sse2;
+    aom_highbd_sad64x32 = aom_highbd_sad64x32_c;
+    if (flags & HAS_SSE2) aom_highbd_sad64x32 = aom_highbd_sad64x32_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad64x32 = aom_highbd_sad64x32_avx2;
+    aom_highbd_sad64x32_avg = aom_highbd_sad64x32_avg_c;
+    if (flags & HAS_SSE2) aom_highbd_sad64x32_avg = aom_highbd_sad64x32_avg_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad64x32_avg = aom_highbd_sad64x32_avg_avx2;
+    aom_highbd_sad64x32x4d = aom_highbd_sad64x32x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad64x32x4d = aom_highbd_sad64x32x4d_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad64x32x4d = aom_highbd_sad64x32x4d_avx2;
+    aom_highbd_sad64x64 = aom_highbd_sad64x64_c;
+    if (flags & HAS_SSE2) aom_highbd_sad64x64 = aom_highbd_sad64x64_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad64x64 = aom_highbd_sad64x64_avx2;
+    aom_highbd_sad64x64_avg = aom_highbd_sad64x64_avg_c;
+    if (flags & HAS_SSE2) aom_highbd_sad64x64_avg = aom_highbd_sad64x64_avg_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad64x64_avg = aom_highbd_sad64x64_avg_avx2;
+    aom_highbd_sad64x64x4d = aom_highbd_sad64x64x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad64x64x4d = aom_highbd_sad64x64x4d_sse2;
+    if (flags & HAS_AVX2) aom_highbd_sad64x64x4d = aom_highbd_sad64x64x4d_avx2;
+    aom_highbd_sad8x16 = aom_highbd_sad8x16_c;
+    if (flags & HAS_SSE2) aom_highbd_sad8x16 = aom_highbd_sad8x16_sse2;
+    aom_highbd_sad8x16_avg = aom_highbd_sad8x16_avg_c;
+    if (flags & HAS_SSE2) aom_highbd_sad8x16_avg = aom_highbd_sad8x16_avg_sse2;
+    aom_highbd_sad8x16x4d = aom_highbd_sad8x16x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad8x16x4d = aom_highbd_sad8x16x4d_sse2;
+    aom_highbd_sad8x4 = aom_highbd_sad8x4_c;
+    if (flags & HAS_SSE2) aom_highbd_sad8x4 = aom_highbd_sad8x4_sse2;
+    aom_highbd_sad8x4_avg = aom_highbd_sad8x4_avg_c;
+    if (flags & HAS_SSE2) aom_highbd_sad8x4_avg = aom_highbd_sad8x4_avg_sse2;
+    aom_highbd_sad8x4x4d = aom_highbd_sad8x4x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad8x4x4d = aom_highbd_sad8x4x4d_sse2;
+    aom_highbd_sad8x8 = aom_highbd_sad8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_sad8x8 = aom_highbd_sad8x8_sse2;
+    aom_highbd_sad8x8_avg = aom_highbd_sad8x8_avg_c;
+    if (flags & HAS_SSE2) aom_highbd_sad8x8_avg = aom_highbd_sad8x8_avg_sse2;
+    aom_highbd_sad8x8x4d = aom_highbd_sad8x8x4d_c;
+    if (flags & HAS_SSE2) aom_highbd_sad8x8x4d = aom_highbd_sad8x8x4d_sse2;
+    aom_highbd_subtract_block = aom_highbd_subtract_block_c;
+    if (flags & HAS_SSE2) aom_highbd_subtract_block = aom_highbd_subtract_block_sse2;
+    aom_highbd_upsampled_pred = aom_highbd_upsampled_pred_c;
+    if (flags & HAS_SSE2) aom_highbd_upsampled_pred = aom_highbd_upsampled_pred_sse2;
+    aom_highbd_v_predictor_16x16 = aom_highbd_v_predictor_16x16_c;
+    if (flags & HAS_SSE2) aom_highbd_v_predictor_16x16 = aom_highbd_v_predictor_16x16_sse2;
+    aom_highbd_v_predictor_32x32 = aom_highbd_v_predictor_32x32_c;
+    if (flags & HAS_SSE2) aom_highbd_v_predictor_32x32 = aom_highbd_v_predictor_32x32_sse2;
+    aom_highbd_v_predictor_4x4 = aom_highbd_v_predictor_4x4_c;
+    if (flags & HAS_SSE2) aom_highbd_v_predictor_4x4 = aom_highbd_v_predictor_4x4_sse2;
+    aom_highbd_v_predictor_8x8 = aom_highbd_v_predictor_8x8_c;
+    if (flags & HAS_SSE2) aom_highbd_v_predictor_8x8 = aom_highbd_v_predictor_8x8_sse2;
+    aom_idct16x16_10_add = aom_idct16x16_10_add_c;
+    if (flags & HAS_SSE2) aom_idct16x16_10_add = aom_idct16x16_10_add_sse2;
+    if (flags & HAS_AVX2) aom_idct16x16_10_add = aom_idct16x16_10_add_avx2;
+    aom_idct16x16_1_add = aom_idct16x16_1_add_c;
+    if (flags & HAS_SSE2) aom_idct16x16_1_add = aom_idct16x16_1_add_sse2;
+    if (flags & HAS_AVX2) aom_idct16x16_1_add = aom_idct16x16_1_add_avx2;
+    aom_idct16x16_256_add = aom_idct16x16_256_add_c;
+    if (flags & HAS_SSE2) aom_idct16x16_256_add = aom_idct16x16_256_add_sse2;
+    if (flags & HAS_AVX2) aom_idct16x16_256_add = aom_idct16x16_256_add_avx2;
+    aom_idct16x16_38_add = aom_idct16x16_38_add_c;
+    if (flags & HAS_AVX2) aom_idct16x16_38_add = aom_idct16x16_38_add_avx2;
+    aom_idct32x32_1024_add = aom_idct32x32_1024_add_c;
+    if (flags & HAS_SSE2) aom_idct32x32_1024_add = aom_idct32x32_1024_add_sse2;
+    if (flags & HAS_SSSE3) aom_idct32x32_1024_add = aom_idct32x32_1024_add_ssse3;
+    if (flags & HAS_AVX2) aom_idct32x32_1024_add = aom_idct32x32_1024_add_avx2;
+    aom_idct32x32_135_add = aom_idct32x32_135_add_c;
+    if (flags & HAS_SSE2) aom_idct32x32_135_add = aom_idct32x32_1024_add_sse2;
+    if (flags & HAS_SSSE3) aom_idct32x32_135_add = aom_idct32x32_135_add_ssse3;
+    if (flags & HAS_AVX2) aom_idct32x32_135_add = aom_idct32x32_135_add_avx2;
+    aom_idct32x32_1_add = aom_idct32x32_1_add_c;
+    if (flags & HAS_SSE2) aom_idct32x32_1_add = aom_idct32x32_1_add_sse2;
+    if (flags & HAS_AVX2) aom_idct32x32_1_add = aom_idct32x32_1_add_avx2;
+    aom_idct32x32_34_add = aom_idct32x32_34_add_c;
+    if (flags & HAS_SSE2) aom_idct32x32_34_add = aom_idct32x32_34_add_sse2;
+    if (flags & HAS_SSSE3) aom_idct32x32_34_add = aom_idct32x32_34_add_ssse3;
+    if (flags & HAS_AVX2) aom_idct32x32_34_add = aom_idct32x32_34_add_avx2;
+    aom_idct4x4_16_add = aom_idct4x4_16_add_c;
+    if (flags & HAS_SSE2) aom_idct4x4_16_add = aom_idct4x4_16_add_sse2;
+    aom_idct4x4_1_add = aom_idct4x4_1_add_c;
+    if (flags & HAS_SSE2) aom_idct4x4_1_add = aom_idct4x4_1_add_sse2;
+    aom_idct8x8_12_add = aom_idct8x8_12_add_c;
+    if (flags & HAS_SSE2) aom_idct8x8_12_add = aom_idct8x8_12_add_sse2;
+    if (flags & HAS_SSSE3) aom_idct8x8_12_add = aom_idct8x8_12_add_ssse3;
+    aom_idct8x8_1_add = aom_idct8x8_1_add_c;
+    if (flags & HAS_SSE2) aom_idct8x8_1_add = aom_idct8x8_1_add_sse2;
+    aom_idct8x8_64_add = aom_idct8x8_64_add_c;
+    if (flags & HAS_SSE2) aom_idct8x8_64_add = aom_idct8x8_64_add_sse2;
+    if (flags & HAS_SSSE3) aom_idct8x8_64_add = aom_idct8x8_64_add_ssse3;
+    aom_int_pro_col = aom_int_pro_col_c;
+    if (flags & HAS_SSE2) aom_int_pro_col = aom_int_pro_col_sse2;
+    aom_int_pro_row = aom_int_pro_row_c;
+    if (flags & HAS_SSE2) aom_int_pro_row = aom_int_pro_row_sse2;
+    aom_iwht4x4_16_add = aom_iwht4x4_16_add_c;
+    if (flags & HAS_SSE2) aom_iwht4x4_16_add = aom_iwht4x4_16_add_sse2;
+    aom_lpf_horizontal_4 = aom_lpf_horizontal_4_c;
+    if (flags & HAS_SSE2) aom_lpf_horizontal_4 = aom_lpf_horizontal_4_sse2;
+    aom_lpf_horizontal_4_dual = aom_lpf_horizontal_4_dual_c;
+    if (flags & HAS_SSE2) aom_lpf_horizontal_4_dual = aom_lpf_horizontal_4_dual_sse2;
+    aom_lpf_horizontal_8 = aom_lpf_horizontal_8_c;
+    if (flags & HAS_SSE2) aom_lpf_horizontal_8 = aom_lpf_horizontal_8_sse2;
+    aom_lpf_horizontal_8_dual = aom_lpf_horizontal_8_dual_c;
+    if (flags & HAS_SSE2) aom_lpf_horizontal_8_dual = aom_lpf_horizontal_8_dual_sse2;
+    aom_lpf_horizontal_edge_16 = aom_lpf_horizontal_edge_16_c;
+    if (flags & HAS_SSE2) aom_lpf_horizontal_edge_16 = aom_lpf_horizontal_edge_16_sse2;
+    if (flags & HAS_AVX2) aom_lpf_horizontal_edge_16 = aom_lpf_horizontal_edge_16_avx2;
+    aom_lpf_horizontal_edge_8 = aom_lpf_horizontal_edge_8_c;
+    if (flags & HAS_SSE2) aom_lpf_horizontal_edge_8 = aom_lpf_horizontal_edge_8_sse2;
+    if (flags & HAS_AVX2) aom_lpf_horizontal_edge_8 = aom_lpf_horizontal_edge_8_avx2;
+    aom_lpf_vertical_16 = aom_lpf_vertical_16_c;
+    if (flags & HAS_SSE2) aom_lpf_vertical_16 = aom_lpf_vertical_16_sse2;
+    aom_lpf_vertical_16_dual = aom_lpf_vertical_16_dual_c;
+    if (flags & HAS_SSE2) aom_lpf_vertical_16_dual = aom_lpf_vertical_16_dual_sse2;
+    aom_lpf_vertical_4 = aom_lpf_vertical_4_c;
+    if (flags & HAS_SSE2) aom_lpf_vertical_4 = aom_lpf_vertical_4_sse2;
+    aom_lpf_vertical_4_dual = aom_lpf_vertical_4_dual_c;
+    if (flags & HAS_SSE2) aom_lpf_vertical_4_dual = aom_lpf_vertical_4_dual_sse2;
+    aom_lpf_vertical_8 = aom_lpf_vertical_8_c;
+    if (flags & HAS_SSE2) aom_lpf_vertical_8 = aom_lpf_vertical_8_sse2;
+    aom_lpf_vertical_8_dual = aom_lpf_vertical_8_dual_c;
+    if (flags & HAS_SSE2) aom_lpf_vertical_8_dual = aom_lpf_vertical_8_dual_sse2;
+    aom_minmax_8x8 = aom_minmax_8x8_c;
+    if (flags & HAS_SSE2) aom_minmax_8x8 = aom_minmax_8x8_sse2;
+    aom_mse16x16 = aom_mse16x16_c;
+    if (flags & HAS_SSE2) aom_mse16x16 = aom_mse16x16_sse2;
+    if (flags & HAS_AVX2) aom_mse16x16 = aom_mse16x16_avx2;
+    aom_mse16x8 = aom_mse16x8_c;
+    if (flags & HAS_SSE2) aom_mse16x8 = aom_mse16x8_sse2;
+    aom_mse8x16 = aom_mse8x16_c;
+    if (flags & HAS_SSE2) aom_mse8x16 = aom_mse8x16_sse2;
+    aom_mse8x8 = aom_mse8x8_c;
+    if (flags & HAS_SSE2) aom_mse8x8 = aom_mse8x8_sse2;
+    aom_obmc_sad16x16 = aom_obmc_sad16x16_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad16x16 = aom_obmc_sad16x16_sse4_1;
+    aom_obmc_sad16x32 = aom_obmc_sad16x32_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad16x32 = aom_obmc_sad16x32_sse4_1;
+    aom_obmc_sad16x8 = aom_obmc_sad16x8_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad16x8 = aom_obmc_sad16x8_sse4_1;
+    aom_obmc_sad32x16 = aom_obmc_sad32x16_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad32x16 = aom_obmc_sad32x16_sse4_1;
+    aom_obmc_sad32x32 = aom_obmc_sad32x32_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad32x32 = aom_obmc_sad32x32_sse4_1;
+    aom_obmc_sad32x64 = aom_obmc_sad32x64_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad32x64 = aom_obmc_sad32x64_sse4_1;
+    aom_obmc_sad4x4 = aom_obmc_sad4x4_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad4x4 = aom_obmc_sad4x4_sse4_1;
+    aom_obmc_sad4x8 = aom_obmc_sad4x8_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad4x8 = aom_obmc_sad4x8_sse4_1;
+    aom_obmc_sad64x32 = aom_obmc_sad64x32_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad64x32 = aom_obmc_sad64x32_sse4_1;
+    aom_obmc_sad64x64 = aom_obmc_sad64x64_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad64x64 = aom_obmc_sad64x64_sse4_1;
+    aom_obmc_sad8x16 = aom_obmc_sad8x16_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad8x16 = aom_obmc_sad8x16_sse4_1;
+    aom_obmc_sad8x4 = aom_obmc_sad8x4_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad8x4 = aom_obmc_sad8x4_sse4_1;
+    aom_obmc_sad8x8 = aom_obmc_sad8x8_c;
+    if (flags & HAS_SSE4_1) aom_obmc_sad8x8 = aom_obmc_sad8x8_sse4_1;
+    aom_obmc_variance16x16 = aom_obmc_variance16x16_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance16x16 = aom_obmc_variance16x16_sse4_1;
+    aom_obmc_variance16x32 = aom_obmc_variance16x32_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance16x32 = aom_obmc_variance16x32_sse4_1;
+    aom_obmc_variance16x8 = aom_obmc_variance16x8_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance16x8 = aom_obmc_variance16x8_sse4_1;
+    aom_obmc_variance32x16 = aom_obmc_variance32x16_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance32x16 = aom_obmc_variance32x16_sse4_1;
+    aom_obmc_variance32x32 = aom_obmc_variance32x32_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance32x32 = aom_obmc_variance32x32_sse4_1;
+    aom_obmc_variance32x64 = aom_obmc_variance32x64_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance32x64 = aom_obmc_variance32x64_sse4_1;
+    aom_obmc_variance4x4 = aom_obmc_variance4x4_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance4x4 = aom_obmc_variance4x4_sse4_1;
+    aom_obmc_variance4x8 = aom_obmc_variance4x8_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance4x8 = aom_obmc_variance4x8_sse4_1;
+    aom_obmc_variance64x32 = aom_obmc_variance64x32_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance64x32 = aom_obmc_variance64x32_sse4_1;
+    aom_obmc_variance64x64 = aom_obmc_variance64x64_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance64x64 = aom_obmc_variance64x64_sse4_1;
+    aom_obmc_variance8x16 = aom_obmc_variance8x16_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance8x16 = aom_obmc_variance8x16_sse4_1;
+    aom_obmc_variance8x4 = aom_obmc_variance8x4_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance8x4 = aom_obmc_variance8x4_sse4_1;
+    aom_obmc_variance8x8 = aom_obmc_variance8x8_c;
+    if (flags & HAS_SSE4_1) aom_obmc_variance8x8 = aom_obmc_variance8x8_sse4_1;
+    aom_quantize_b = aom_quantize_b_c;
+    if (flags & HAS_SSE2) aom_quantize_b = aom_quantize_b_sse2;
+    aom_sad16x16 = aom_sad16x16_c;
+    if (flags & HAS_SSE2) aom_sad16x16 = aom_sad16x16_sse2;
+    aom_sad16x16_avg = aom_sad16x16_avg_c;
+    if (flags & HAS_SSE2) aom_sad16x16_avg = aom_sad16x16_avg_sse2;
+    aom_sad16x16x3 = aom_sad16x16x3_c;
+    if (flags & HAS_SSE3) aom_sad16x16x3 = aom_sad16x16x3_sse3;
+    if (flags & HAS_SSSE3) aom_sad16x16x3 = aom_sad16x16x3_ssse3;
+    aom_sad16x16x4d = aom_sad16x16x4d_c;
+    if (flags & HAS_SSE2) aom_sad16x16x4d = aom_sad16x16x4d_sse2;
+    aom_sad16x16x8 = aom_sad16x16x8_c;
+    if (flags & HAS_SSE4_1) aom_sad16x16x8 = aom_sad16x16x8_sse4_1;
+    aom_sad16x32 = aom_sad16x32_c;
+    if (flags & HAS_SSE2) aom_sad16x32 = aom_sad16x32_sse2;
+    aom_sad16x32_avg = aom_sad16x32_avg_c;
+    if (flags & HAS_SSE2) aom_sad16x32_avg = aom_sad16x32_avg_sse2;
+    aom_sad16x32x4d = aom_sad16x32x4d_c;
+    if (flags & HAS_SSE2) aom_sad16x32x4d = aom_sad16x32x4d_sse2;
+    aom_sad16x8 = aom_sad16x8_c;
+    if (flags & HAS_SSE2) aom_sad16x8 = aom_sad16x8_sse2;
+    aom_sad16x8_avg = aom_sad16x8_avg_c;
+    if (flags & HAS_SSE2) aom_sad16x8_avg = aom_sad16x8_avg_sse2;
+    aom_sad16x8x3 = aom_sad16x8x3_c;
+    if (flags & HAS_SSE3) aom_sad16x8x3 = aom_sad16x8x3_sse3;
+    if (flags & HAS_SSSE3) aom_sad16x8x3 = aom_sad16x8x3_ssse3;
+    aom_sad16x8x4d = aom_sad16x8x4d_c;
+    if (flags & HAS_SSE2) aom_sad16x8x4d = aom_sad16x8x4d_sse2;
+    aom_sad16x8x8 = aom_sad16x8x8_c;
+    if (flags & HAS_SSE4_1) aom_sad16x8x8 = aom_sad16x8x8_sse4_1;
+    aom_sad32x16 = aom_sad32x16_c;
+    if (flags & HAS_SSE2) aom_sad32x16 = aom_sad32x16_sse2;
+    if (flags & HAS_AVX2) aom_sad32x16 = aom_sad32x16_avx2;
+    aom_sad32x16_avg = aom_sad32x16_avg_c;
+    if (flags & HAS_SSE2) aom_sad32x16_avg = aom_sad32x16_avg_sse2;
+    if (flags & HAS_AVX2) aom_sad32x16_avg = aom_sad32x16_avg_avx2;
+    aom_sad32x16x4d = aom_sad32x16x4d_c;
+    if (flags & HAS_SSE2) aom_sad32x16x4d = aom_sad32x16x4d_sse2;
+    aom_sad32x32 = aom_sad32x32_c;
+    if (flags & HAS_SSE2) aom_sad32x32 = aom_sad32x32_sse2;
+    if (flags & HAS_AVX2) aom_sad32x32 = aom_sad32x32_avx2;
+    aom_sad32x32_avg = aom_sad32x32_avg_c;
+    if (flags & HAS_SSE2) aom_sad32x32_avg = aom_sad32x32_avg_sse2;
+    if (flags & HAS_AVX2) aom_sad32x32_avg = aom_sad32x32_avg_avx2;
+    aom_sad32x32x4d = aom_sad32x32x4d_c;
+    if (flags & HAS_SSE2) aom_sad32x32x4d = aom_sad32x32x4d_sse2;
+    if (flags & HAS_AVX2) aom_sad32x32x4d = aom_sad32x32x4d_avx2;
+    aom_sad32x64 = aom_sad32x64_c;
+    if (flags & HAS_SSE2) aom_sad32x64 = aom_sad32x64_sse2;
+    if (flags & HAS_AVX2) aom_sad32x64 = aom_sad32x64_avx2;
+    aom_sad32x64_avg = aom_sad32x64_avg_c;
+    if (flags & HAS_SSE2) aom_sad32x64_avg = aom_sad32x64_avg_sse2;
+    if (flags & HAS_AVX2) aom_sad32x64_avg = aom_sad32x64_avg_avx2;
+    aom_sad32x64x4d = aom_sad32x64x4d_c;
+    if (flags & HAS_SSE2) aom_sad32x64x4d = aom_sad32x64x4d_sse2;
+    if (flags & HAS_AVX2) aom_sad32x64x4d = aom_sad32x64x4d_avx2;
+    aom_sad4x4 = aom_sad4x4_c;
+    if (flags & HAS_SSE2) aom_sad4x4 = aom_sad4x4_sse2;
+    aom_sad4x4_avg = aom_sad4x4_avg_c;
+    if (flags & HAS_SSE2) aom_sad4x4_avg = aom_sad4x4_avg_sse2;
+    aom_sad4x4x3 = aom_sad4x4x3_c;
+    if (flags & HAS_SSE3) aom_sad4x4x3 = aom_sad4x4x3_sse3;
+    aom_sad4x4x4d = aom_sad4x4x4d_c;
+    if (flags & HAS_SSE2) aom_sad4x4x4d = aom_sad4x4x4d_sse2;
+    aom_sad4x4x8 = aom_sad4x4x8_c;
+    if (flags & HAS_SSE4_1) aom_sad4x4x8 = aom_sad4x4x8_sse4_1;
+    aom_sad4x8 = aom_sad4x8_c;
+    if (flags & HAS_SSE2) aom_sad4x8 = aom_sad4x8_sse2;
+    aom_sad4x8_avg = aom_sad4x8_avg_c;
+    if (flags & HAS_SSE2) aom_sad4x8_avg = aom_sad4x8_avg_sse2;
+    aom_sad4x8x4d = aom_sad4x8x4d_c;
+    if (flags & HAS_SSE2) aom_sad4x8x4d = aom_sad4x8x4d_sse2;
+    aom_sad64x32 = aom_sad64x32_c;
+    if (flags & HAS_SSE2) aom_sad64x32 = aom_sad64x32_sse2;
+    if (flags & HAS_AVX2) aom_sad64x32 = aom_sad64x32_avx2;
+    aom_sad64x32_avg = aom_sad64x32_avg_c;
+    if (flags & HAS_SSE2) aom_sad64x32_avg = aom_sad64x32_avg_sse2;
+    if (flags & HAS_AVX2) aom_sad64x32_avg = aom_sad64x32_avg_avx2;
+    aom_sad64x32x4d = aom_sad64x32x4d_c;
+    if (flags & HAS_SSE2) aom_sad64x32x4d = aom_sad64x32x4d_sse2;
+    if (flags & HAS_AVX2) aom_sad64x32x4d = aom_sad64x32x4d_avx2;
+    aom_sad64x64 = aom_sad64x64_c;
+    if (flags & HAS_SSE2) aom_sad64x64 = aom_sad64x64_sse2;
+    if (flags & HAS_AVX2) aom_sad64x64 = aom_sad64x64_avx2;
+    aom_sad64x64_avg = aom_sad64x64_avg_c;
+    if (flags & HAS_SSE2) aom_sad64x64_avg = aom_sad64x64_avg_sse2;
+    if (flags & HAS_AVX2) aom_sad64x64_avg = aom_sad64x64_avg_avx2;
+    aom_sad64x64x4d = aom_sad64x64x4d_c;
+    if (flags & HAS_SSE2) aom_sad64x64x4d = aom_sad64x64x4d_sse2;
+    if (flags & HAS_AVX2) aom_sad64x64x4d = aom_sad64x64x4d_avx2;
+    aom_sad8x16 = aom_sad8x16_c;
+    if (flags & HAS_SSE2) aom_sad8x16 = aom_sad8x16_sse2;
+    aom_sad8x16_avg = aom_sad8x16_avg_c;
+    if (flags & HAS_SSE2) aom_sad8x16_avg = aom_sad8x16_avg_sse2;
+    aom_sad8x16x3 = aom_sad8x16x3_c;
+    if (flags & HAS_SSE3) aom_sad8x16x3 = aom_sad8x16x3_sse3;
+    aom_sad8x16x4d = aom_sad8x16x4d_c;
+    if (flags & HAS_SSE2) aom_sad8x16x4d = aom_sad8x16x4d_sse2;
+    aom_sad8x16x8 = aom_sad8x16x8_c;
+    if (flags & HAS_SSE4_1) aom_sad8x16x8 = aom_sad8x16x8_sse4_1;
+    aom_sad8x4 = aom_sad8x4_c;
+    if (flags & HAS_SSE2) aom_sad8x4 = aom_sad8x4_sse2;
+    aom_sad8x4_avg = aom_sad8x4_avg_c;
+    if (flags & HAS_SSE2) aom_sad8x4_avg = aom_sad8x4_avg_sse2;
+    aom_sad8x4x4d = aom_sad8x4x4d_c;
+    if (flags & HAS_SSE2) aom_sad8x4x4d = aom_sad8x4x4d_sse2;
+    aom_sad8x8 = aom_sad8x8_c;
+    if (flags & HAS_SSE2) aom_sad8x8 = aom_sad8x8_sse2;
+    aom_sad8x8_avg = aom_sad8x8_avg_c;
+    if (flags & HAS_SSE2) aom_sad8x8_avg = aom_sad8x8_avg_sse2;
+    aom_sad8x8x3 = aom_sad8x8x3_c;
+    if (flags & HAS_SSE3) aom_sad8x8x3 = aom_sad8x8x3_sse3;
+    aom_sad8x8x4d = aom_sad8x8x4d_c;
+    if (flags & HAS_SSE2) aom_sad8x8x4d = aom_sad8x8x4d_sse2;
+    aom_sad8x8x8 = aom_sad8x8x8_c;
+    if (flags & HAS_SSE4_1) aom_sad8x8x8 = aom_sad8x8x8_sse4_1;
+    aom_satd = aom_satd_c;
+    if (flags & HAS_SSE2) aom_satd = aom_satd_sse2;
+    aom_scaled_2d = aom_scaled_2d_c;
+    if (flags & HAS_SSSE3) aom_scaled_2d = aom_scaled_2d_ssse3;
+    aom_sub_pixel_avg_variance16x16 = aom_sub_pixel_avg_variance16x16_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance16x16 = aom_sub_pixel_avg_variance16x16_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance16x16 = aom_sub_pixel_avg_variance16x16_ssse3;
+    aom_sub_pixel_avg_variance16x32 = aom_sub_pixel_avg_variance16x32_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance16x32 = aom_sub_pixel_avg_variance16x32_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance16x32 = aom_sub_pixel_avg_variance16x32_ssse3;
+    aom_sub_pixel_avg_variance16x8 = aom_sub_pixel_avg_variance16x8_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance16x8 = aom_sub_pixel_avg_variance16x8_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance16x8 = aom_sub_pixel_avg_variance16x8_ssse3;
+    aom_sub_pixel_avg_variance32x16 = aom_sub_pixel_avg_variance32x16_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance32x16 = aom_sub_pixel_avg_variance32x16_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance32x16 = aom_sub_pixel_avg_variance32x16_ssse3;
+    aom_sub_pixel_avg_variance32x32 = aom_sub_pixel_avg_variance32x32_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance32x32 = aom_sub_pixel_avg_variance32x32_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance32x32 = aom_sub_pixel_avg_variance32x32_ssse3;
+    if (flags & HAS_AVX2) aom_sub_pixel_avg_variance32x32 = aom_sub_pixel_avg_variance32x32_avx2;
+    aom_sub_pixel_avg_variance32x64 = aom_sub_pixel_avg_variance32x64_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance32x64 = aom_sub_pixel_avg_variance32x64_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance32x64 = aom_sub_pixel_avg_variance32x64_ssse3;
+    aom_sub_pixel_avg_variance4x4 = aom_sub_pixel_avg_variance4x4_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance4x4 = aom_sub_pixel_avg_variance4x4_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance4x4 = aom_sub_pixel_avg_variance4x4_ssse3;
+    aom_sub_pixel_avg_variance4x8 = aom_sub_pixel_avg_variance4x8_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance4x8 = aom_sub_pixel_avg_variance4x8_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance4x8 = aom_sub_pixel_avg_variance4x8_ssse3;
+    aom_sub_pixel_avg_variance64x32 = aom_sub_pixel_avg_variance64x32_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance64x32 = aom_sub_pixel_avg_variance64x32_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance64x32 = aom_sub_pixel_avg_variance64x32_ssse3;
+    aom_sub_pixel_avg_variance64x64 = aom_sub_pixel_avg_variance64x64_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance64x64 = aom_sub_pixel_avg_variance64x64_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance64x64 = aom_sub_pixel_avg_variance64x64_ssse3;
+    if (flags & HAS_AVX2) aom_sub_pixel_avg_variance64x64 = aom_sub_pixel_avg_variance64x64_avx2;
+    aom_sub_pixel_avg_variance8x16 = aom_sub_pixel_avg_variance8x16_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance8x16 = aom_sub_pixel_avg_variance8x16_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance8x16 = aom_sub_pixel_avg_variance8x16_ssse3;
+    aom_sub_pixel_avg_variance8x4 = aom_sub_pixel_avg_variance8x4_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance8x4 = aom_sub_pixel_avg_variance8x4_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance8x4 = aom_sub_pixel_avg_variance8x4_ssse3;
+    aom_sub_pixel_avg_variance8x8 = aom_sub_pixel_avg_variance8x8_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_avg_variance8x8 = aom_sub_pixel_avg_variance8x8_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_avg_variance8x8 = aom_sub_pixel_avg_variance8x8_ssse3;
+    aom_sub_pixel_variance16x16 = aom_sub_pixel_variance16x16_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance16x16 = aom_sub_pixel_variance16x16_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance16x16 = aom_sub_pixel_variance16x16_ssse3;
+    aom_sub_pixel_variance16x32 = aom_sub_pixel_variance16x32_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance16x32 = aom_sub_pixel_variance16x32_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance16x32 = aom_sub_pixel_variance16x32_ssse3;
+    aom_sub_pixel_variance16x8 = aom_sub_pixel_variance16x8_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance16x8 = aom_sub_pixel_variance16x8_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance16x8 = aom_sub_pixel_variance16x8_ssse3;
+    aom_sub_pixel_variance32x16 = aom_sub_pixel_variance32x16_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance32x16 = aom_sub_pixel_variance32x16_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance32x16 = aom_sub_pixel_variance32x16_ssse3;
+    aom_sub_pixel_variance32x32 = aom_sub_pixel_variance32x32_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance32x32 = aom_sub_pixel_variance32x32_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance32x32 = aom_sub_pixel_variance32x32_ssse3;
+    if (flags & HAS_AVX2) aom_sub_pixel_variance32x32 = aom_sub_pixel_variance32x32_avx2;
+    aom_sub_pixel_variance32x64 = aom_sub_pixel_variance32x64_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance32x64 = aom_sub_pixel_variance32x64_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance32x64 = aom_sub_pixel_variance32x64_ssse3;
+    aom_sub_pixel_variance4x4 = aom_sub_pixel_variance4x4_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance4x4 = aom_sub_pixel_variance4x4_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance4x4 = aom_sub_pixel_variance4x4_ssse3;
+    aom_sub_pixel_variance4x8 = aom_sub_pixel_variance4x8_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance4x8 = aom_sub_pixel_variance4x8_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance4x8 = aom_sub_pixel_variance4x8_ssse3;
+    aom_sub_pixel_variance64x32 = aom_sub_pixel_variance64x32_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance64x32 = aom_sub_pixel_variance64x32_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance64x32 = aom_sub_pixel_variance64x32_ssse3;
+    aom_sub_pixel_variance64x64 = aom_sub_pixel_variance64x64_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance64x64 = aom_sub_pixel_variance64x64_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance64x64 = aom_sub_pixel_variance64x64_ssse3;
+    if (flags & HAS_AVX2) aom_sub_pixel_variance64x64 = aom_sub_pixel_variance64x64_avx2;
+    aom_sub_pixel_variance8x16 = aom_sub_pixel_variance8x16_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance8x16 = aom_sub_pixel_variance8x16_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance8x16 = aom_sub_pixel_variance8x16_ssse3;
+    aom_sub_pixel_variance8x4 = aom_sub_pixel_variance8x4_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance8x4 = aom_sub_pixel_variance8x4_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance8x4 = aom_sub_pixel_variance8x4_ssse3;
+    aom_sub_pixel_variance8x8 = aom_sub_pixel_variance8x8_c;
+    if (flags & HAS_SSE2) aom_sub_pixel_variance8x8 = aom_sub_pixel_variance8x8_sse2;
+    if (flags & HAS_SSSE3) aom_sub_pixel_variance8x8 = aom_sub_pixel_variance8x8_ssse3;
+    aom_subtract_block = aom_subtract_block_c;
+    if (flags & HAS_SSE2) aom_subtract_block = aom_subtract_block_sse2;
+    aom_sum_squares_2d_i16 = aom_sum_squares_2d_i16_c;
+    if (flags & HAS_SSE2) aom_sum_squares_2d_i16 = aom_sum_squares_2d_i16_sse2;
+    aom_sum_squares_i16 = aom_sum_squares_i16_c;
+    if (flags & HAS_SSE2) aom_sum_squares_i16 = aom_sum_squares_i16_sse2;
+    aom_upsampled_pred = aom_upsampled_pred_c;
+    if (flags & HAS_SSE2) aom_upsampled_pred = aom_upsampled_pred_sse2;
+    aom_v_predictor_16x16 = aom_v_predictor_16x16_c;
+    if (flags & HAS_SSE2) aom_v_predictor_16x16 = aom_v_predictor_16x16_sse2;
+    aom_v_predictor_32x32 = aom_v_predictor_32x32_c;
+    if (flags & HAS_SSE2) aom_v_predictor_32x32 = aom_v_predictor_32x32_sse2;
+    aom_v_predictor_4x4 = aom_v_predictor_4x4_c;
+    if (flags & HAS_SSE2) aom_v_predictor_4x4 = aom_v_predictor_4x4_sse2;
+    aom_v_predictor_8x8 = aom_v_predictor_8x8_c;
+    if (flags & HAS_SSE2) aom_v_predictor_8x8 = aom_v_predictor_8x8_sse2;
+    aom_variance16x16 = aom_variance16x16_c;
+    if (flags & HAS_SSE2) aom_variance16x16 = aom_variance16x16_sse2;
+    if (flags & HAS_AVX2) aom_variance16x16 = aom_variance16x16_avx2;
+    aom_variance16x32 = aom_variance16x32_c;
+    if (flags & HAS_SSE2) aom_variance16x32 = aom_variance16x32_sse2;
+    aom_variance16x8 = aom_variance16x8_c;
+    if (flags & HAS_SSE2) aom_variance16x8 = aom_variance16x8_sse2;
+    aom_variance32x16 = aom_variance32x16_c;
+    if (flags & HAS_SSE2) aom_variance32x16 = aom_variance32x16_sse2;
+    if (flags & HAS_AVX2) aom_variance32x16 = aom_variance32x16_avx2;
+    aom_variance32x32 = aom_variance32x32_c;
+    if (flags & HAS_SSE2) aom_variance32x32 = aom_variance32x32_sse2;
+    if (flags & HAS_AVX2) aom_variance32x32 = aom_variance32x32_avx2;
+    aom_variance32x64 = aom_variance32x64_c;
+    if (flags & HAS_SSE2) aom_variance32x64 = aom_variance32x64_sse2;
+    aom_variance4x4 = aom_variance4x4_c;
+    if (flags & HAS_SSE2) aom_variance4x4 = aom_variance4x4_sse2;
+    aom_variance4x8 = aom_variance4x8_c;
+    if (flags & HAS_SSE2) aom_variance4x8 = aom_variance4x8_sse2;
+    aom_variance64x32 = aom_variance64x32_c;
+    if (flags & HAS_SSE2) aom_variance64x32 = aom_variance64x32_sse2;
+    if (flags & HAS_AVX2) aom_variance64x32 = aom_variance64x32_avx2;
+    aom_variance64x64 = aom_variance64x64_c;
+    if (flags & HAS_SSE2) aom_variance64x64 = aom_variance64x64_sse2;
+    if (flags & HAS_AVX2) aom_variance64x64 = aom_variance64x64_avx2;
+    aom_variance8x16 = aom_variance8x16_c;
+    if (flags & HAS_SSE2) aom_variance8x16 = aom_variance8x16_sse2;
+    aom_variance8x4 = aom_variance8x4_c;
+    if (flags & HAS_SSE2) aom_variance8x4 = aom_variance8x4_sse2;
+    aom_variance8x8 = aom_variance8x8_c;
+    if (flags & HAS_SSE2) aom_variance8x8 = aom_variance8x8_sse2;
+    aom_variance_halfpixvar16x16_h = aom_variance_halfpixvar16x16_h_c;
+    if (flags & HAS_SSE2) aom_variance_halfpixvar16x16_h = aom_variance_halfpixvar16x16_h_sse2;
+    aom_variance_halfpixvar16x16_hv = aom_variance_halfpixvar16x16_hv_c;
+    if (flags & HAS_SSE2) aom_variance_halfpixvar16x16_hv = aom_variance_halfpixvar16x16_hv_sse2;
+    aom_variance_halfpixvar16x16_v = aom_variance_halfpixvar16x16_v_c;
+    if (flags & HAS_SSE2) aom_variance_halfpixvar16x16_v = aom_variance_halfpixvar16x16_v_sse2;
+    aom_vector_var = aom_vector_var_c;
+    if (flags & HAS_SSE2) aom_vector_var = aom_vector_var_sse2;
+}
+#endif
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libaom/config/win/mingw32/aom_scale_rtcd.h
@@ -0,0 +1,78 @@
+#ifndef AOM_SCALE_RTCD_H_
+#define AOM_SCALE_RTCD_H_
+
+#ifdef RTCD_C
+#define RTCD_EXTERN
+#else
+#define RTCD_EXTERN extern
+#endif
+
+struct yv12_buffer_config;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void aom_extend_frame_borders_c(struct yv12_buffer_config *ybf);
+#define aom_extend_frame_borders aom_extend_frame_borders_c
+
+void aom_extend_frame_borders_y_c(struct yv12_buffer_config *ybf);
+#define aom_extend_frame_borders_y aom_extend_frame_borders_y_c
+
+void aom_extend_frame_inner_borders_c(struct yv12_buffer_config *ybf);
+#define aom_extend_frame_inner_borders aom_extend_frame_inner_borders_c
+
+void aom_horizontal_line_2_1_scale_c(const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width);
+#define aom_horizontal_line_2_1_scale aom_horizontal_line_2_1_scale_c
+
+void aom_horizontal_line_5_3_scale_c(const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width);
+#define aom_horizontal_line_5_3_scale aom_horizontal_line_5_3_scale_c
+
+void aom_horizontal_line_5_4_scale_c(const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width);
+#define aom_horizontal_line_5_4_scale aom_horizontal_line_5_4_scale_c
+
+void aom_vertical_band_2_1_scale_c(unsigned char *source, int src_pitch, unsigned char *dest, int dest_pitch, unsigned int dest_width);
+#define aom_vertical_band_2_1_scale aom_vertical_band_2_1_scale_c
+
+void aom_vertical_band_2_1_scale_i_c(unsigned char *source, int src_pitch, unsigned char *dest, int dest_pitch, unsigned int dest_width);
+#define aom_vertical_band_2_1_scale_i aom_vertical_band_2_1_scale_i_c
+
+void aom_vertical_band_5_3_scale_c(unsigned char *source, int src_pitch, unsigned char *dest, int dest_pitch, unsigned int dest_width);
+#define aom_vertical_band_5_3_scale aom_vertical_band_5_3_scale_c
+
+void aom_vertical_band_5_4_scale_c(unsigned char *source, int src_pitch, unsigned char *dest, int dest_pitch, unsigned int dest_width);
+#define aom_vertical_band_5_4_scale aom_vertical_band_5_4_scale_c
+
+void aom_yv12_copy_frame_c(const struct yv12_buffer_config *src_bc, struct yv12_buffer_config *dst_bc);
+#define aom_yv12_copy_frame aom_yv12_copy_frame_c
+
+void aom_yv12_copy_u_c(const struct yv12_buffer_config *src_bc, struct yv12_buffer_config *dst_bc);
+#define aom_yv12_copy_u aom_yv12_copy_u_c
+
+void aom_yv12_copy_v_c(const struct yv12_buffer_config *src_bc, struct yv12_buffer_config *dst_bc);
+#define aom_yv12_copy_v aom_yv12_copy_v_c
+
+void aom_yv12_copy_y_c(const struct yv12_buffer_config *src_ybc, struct yv12_buffer_config *dst_ybc);
+#define aom_yv12_copy_y aom_yv12_copy_y_c
+
+void aom_yv12_extend_frame_borders_c(struct yv12_buffer_config *ybf);
+#define aom_yv12_extend_frame_borders aom_yv12_extend_frame_borders_c
+
+void aom_scale_rtcd(void);
+
+#ifdef RTCD_C
+#include "aom_ports/x86.h"
+static void setup_rtcd_internal(void)
+{
+    int flags = x86_simd_caps();
+
+    (void)flags;
+
+}
+#endif
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libaom/config/win/mingw32/av1_rtcd.h
@@ -0,0 +1,602 @@
+#ifndef AOM_RTCD_H_
+#define AOM_RTCD_H_
+
+#ifdef RTCD_C
+#define RTCD_EXTERN
+#else
+#define RTCD_EXTERN extern
+#endif
+
+/*
+ * AV1
+ */
+
+#include "aom/aom_integer.h"
+#include "av1/common/common.h"
+#include "av1/common/enums.h"
+#include "av1/common/quant_common.h"
+#include "av1/common/filter.h"
+#include "av1/common/convolve.h"
+#include "av1/common/av1_txfm.h"
+#include "av1/common/idct.h"
+#include "av1/common/odintrin.h"
+
+struct macroblockd;
+
+/* Encoder forward decls */
+struct macroblock;
+struct fwd_txfm_param;
+struct inv_txfm_param;
+struct aom_variance_vtable;
+struct search_site_config;
+struct mv;
+union int_mv;
+struct yv12_buffer_config;
+typedef uint16_t od_dering_in;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void aom_clpf_block_c(uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+void aom_clpf_block_sse2(uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+void aom_clpf_block_ssse3(uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+void aom_clpf_block_sse4_1(uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+RTCD_EXTERN void (*aom_clpf_block)(uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+
+void aom_clpf_block_hbd_c(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+void aom_clpf_block_hbd_sse2(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+void aom_clpf_block_hbd_ssse3(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+void aom_clpf_block_hbd_sse4_1(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+RTCD_EXTERN void (*aom_clpf_block_hbd)(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+
+void aom_clpf_hblock_c(uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+void aom_clpf_hblock_sse2(uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+void aom_clpf_hblock_ssse3(uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+void aom_clpf_hblock_sse4_1(uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+RTCD_EXTERN void (*aom_clpf_hblock)(uint8_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+
+void aom_clpf_hblock_hbd_c(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+void aom_clpf_hblock_hbd_sse2(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+void aom_clpf_hblock_hbd_ssse3(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+void aom_clpf_hblock_hbd_sse4_1(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+RTCD_EXTERN void (*aom_clpf_hblock_hbd)(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
+
+int64_t av1_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
+int64_t av1_block_error_avx2(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
+RTCD_EXTERN int64_t (*av1_block_error)(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
+
+void av1_convolve_horiz_c(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
+void av1_convolve_horiz_ssse3(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
+RTCD_EXTERN void (*av1_convolve_horiz)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
+
+void av1_convolve_vert_c(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
+void av1_convolve_vert_ssse3(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
+RTCD_EXTERN void (*av1_convolve_vert)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
+
+int av1_diamond_search_sad_c(struct macroblock *x, const struct search_site_config *cfg,  struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
+#define av1_diamond_search_sad av1_diamond_search_sad_c
+
+void av1_fdct8x8_quant_c(const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+#define av1_fdct8x8_quant av1_fdct8x8_quant_c
+
+void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x16_avx2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht16x16)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+
+void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x32_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht16x32)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+
+void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+#define av1_fht16x4 av1_fht16x4_c
+
+void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht16x8)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+
+void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht32x16)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+
+void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x32_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x32_avx2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht32x32)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+
+void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+#define av1_fht32x8 av1_fht32x8_c
+
+void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+#define av1_fht4x16 av1_fht4x16_c
+
+void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht4x4)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+
+void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht4x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht4x8)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+
+void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht8x16)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+
+void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+#define av1_fht8x32 av1_fht8x32_c
+
+void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x4_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht8x4)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+
+void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht8x8)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+
+int av1_full_range_search_c(const struct macroblock *x, const struct search_site_config *cfg, struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
+#define av1_full_range_search av1_full_range_search_c
+
+int av1_full_search_sad_c(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
+int av1_full_search_sadx3(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
+int av1_full_search_sadx8(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
+RTCD_EXTERN int (*av1_full_search_sad)(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
+
+void av1_fwd_idtx_c(const int16_t *src_diff, tran_low_t *coeff, int stride, int bs, int tx_type);
+#define av1_fwd_idtx av1_fwd_idtx_c
+
+void av1_fwd_txfm2d_16x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+void av1_fwd_txfm2d_16x16_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+RTCD_EXTERN void (*av1_fwd_txfm2d_16x16)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+
+void av1_fwd_txfm2d_16x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x32 av1_fwd_txfm2d_16x32_c
+
+void av1_fwd_txfm2d_16x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x8 av1_fwd_txfm2d_16x8_c
+
+void av1_fwd_txfm2d_32x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_32x16 av1_fwd_txfm2d_32x16_c
+
+void av1_fwd_txfm2d_32x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+void av1_fwd_txfm2d_32x32_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+RTCD_EXTERN void (*av1_fwd_txfm2d_32x32)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+
+void av1_fwd_txfm2d_4x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+void av1_fwd_txfm2d_4x4_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+RTCD_EXTERN void (*av1_fwd_txfm2d_4x4)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+
+void av1_fwd_txfm2d_4x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_4x8 av1_fwd_txfm2d_4x8_c
+
+void av1_fwd_txfm2d_64x64_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+void av1_fwd_txfm2d_64x64_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+RTCD_EXTERN void (*av1_fwd_txfm2d_64x64)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+
+void av1_fwd_txfm2d_8x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x16 av1_fwd_txfm2d_8x16_c
+
+void av1_fwd_txfm2d_8x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x4 av1_fwd_txfm2d_8x4_c
+
+void av1_fwd_txfm2d_8x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+void av1_fwd_txfm2d_8x8_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+RTCD_EXTERN void (*av1_fwd_txfm2d_8x8)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+
+void av1_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
+#define av1_fwht4x4 av1_fwht4x4_c
+
+int64_t av1_highbd_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd);
+int64_t av1_highbd_block_error_sse2(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd);
+RTCD_EXTERN int64_t (*av1_highbd_block_error)(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd);
+
+void av1_highbd_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+#define av1_highbd_convolve8 av1_highbd_convolve8_c
+
+void av1_highbd_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+#define av1_highbd_convolve8_avg av1_highbd_convolve8_avg_c
+
+void av1_highbd_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+#define av1_highbd_convolve8_avg_horiz av1_highbd_convolve8_avg_horiz_c
+
+void av1_highbd_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+#define av1_highbd_convolve8_avg_vert av1_highbd_convolve8_avg_vert_c
+
+void av1_highbd_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+#define av1_highbd_convolve8_horiz av1_highbd_convolve8_horiz_c
+
+void av1_highbd_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+#define av1_highbd_convolve8_vert av1_highbd_convolve8_vert_c
+
+void av1_highbd_convolve_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+#define av1_highbd_convolve_avg av1_highbd_convolve_avg_c
+
+void av1_highbd_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
+#define av1_highbd_convolve_copy av1_highbd_convolve_copy_c
+
+void av1_highbd_convolve_horiz_c(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
+void av1_highbd_convolve_horiz_sse4_1(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
+RTCD_EXTERN void (*av1_highbd_convolve_horiz)(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
+
+void av1_highbd_convolve_init_c(void);
+void av1_highbd_convolve_init_sse4_1(void);
+RTCD_EXTERN void (*av1_highbd_convolve_init)(void);
+
+void av1_highbd_convolve_vert_c(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
+void av1_highbd_convolve_vert_sse4_1(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
+RTCD_EXTERN void (*av1_highbd_convolve_vert)(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
+
+void av1_highbd_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
+#define av1_highbd_fwht4x4 av1_highbd_fwht4x4_c
+
+void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+#define av1_highbd_iht16x16_256_add av1_highbd_iht16x16_256_add_c
+
+void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_highbd_iht16x32_512_add av1_highbd_iht16x32_512_add_c
+
+void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_highbd_iht16x4_64_add av1_highbd_iht16x4_64_add_c
+
+void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_highbd_iht16x8_128_add av1_highbd_iht16x8_128_add_c
+
+void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_highbd_iht32x16_512_add av1_highbd_iht32x16_512_add_c
+
+void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_highbd_iht32x8_256_add av1_highbd_iht32x8_256_add_c
+
+void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_highbd_iht4x16_64_add av1_highbd_iht4x16_64_add_c
+
+void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_highbd_iht4x4_16_add av1_highbd_iht4x4_16_add_c
+
+void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_highbd_iht4x8_32_add av1_highbd_iht4x8_32_add_c
+
+void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_highbd_iht8x16_128_add av1_highbd_iht8x16_128_add_c
+
+void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_highbd_iht8x32_256_add av1_highbd_iht8x32_256_add_c
+
+void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_highbd_iht8x4_32_add av1_highbd_iht8x4_32_add_c
+
+void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_highbd_iht8x8_64_add av1_highbd_iht8x8_64_add_c
+
+void av1_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
+#define av1_highbd_quantize_b av1_highbd_quantize_b_c
+
+void av1_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
+void av1_highbd_quantize_fp_sse4_1(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
+void av1_highbd_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
+RTCD_EXTERN void (*av1_highbd_quantize_fp)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
+
+void av1_highbd_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
+#define av1_highbd_temporal_filter_apply av1_highbd_temporal_filter_apply_c
+
+void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+void av1_iht16x16_256_add_sse2(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+void av1_iht16x16_256_add_avx2(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht16x16_256_add)(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+
+void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht16x32_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht16x32_512_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+
+void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_iht16x4_64_add av1_iht16x4_64_add_c
+
+void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht16x8_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht16x8_128_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+
+void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht32x16_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht32x16_512_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+
+void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+#define av1_iht32x32_1024_add av1_iht32x32_1024_add_c
+
+void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_iht32x8_256_add av1_iht32x8_256_add_c
+
+void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_iht4x16_64_add av1_iht4x16_64_add_c
+
+void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht4x4_16_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+
+void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht4x8_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht4x8_32_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+
+void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x16_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht8x16_128_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+
+void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+#define av1_iht8x32_256_add av1_iht8x32_256_add_c
+
+void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x4_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht8x4_32_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+
+void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht8x8_64_add)(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+
+void av1_inv_txfm2d_add_16x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+void av1_inv_txfm2d_add_16x16_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+RTCD_EXTERN void (*av1_inv_txfm2d_add_16x16)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+
+void av1_inv_txfm2d_add_16x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x32 av1_inv_txfm2d_add_16x32_c
+
+void av1_inv_txfm2d_add_16x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x8 av1_inv_txfm2d_add_16x8_c
+
+void av1_inv_txfm2d_add_32x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_32x16 av1_inv_txfm2d_add_32x16_c
+
+void av1_inv_txfm2d_add_32x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+void av1_inv_txfm2d_add_32x32_avx2(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+RTCD_EXTERN void (*av1_inv_txfm2d_add_32x32)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+
+void av1_inv_txfm2d_add_4x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+void av1_inv_txfm2d_add_4x4_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+RTCD_EXTERN void (*av1_inv_txfm2d_add_4x4)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+
+void av1_inv_txfm2d_add_4x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_4x8 av1_inv_txfm2d_add_4x8_c
+
+void av1_inv_txfm2d_add_64x64_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_64x64 av1_inv_txfm2d_add_64x64_c
+
+void av1_inv_txfm2d_add_8x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x16 av1_inv_txfm2d_add_8x16_c
+
+void av1_inv_txfm2d_add_8x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x4 av1_inv_txfm2d_add_8x4_c
+
+void av1_inv_txfm2d_add_8x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+void av1_inv_txfm2d_add_8x8_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+RTCD_EXTERN void (*av1_inv_txfm2d_add_8x8)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+
+void av1_lowbd_convolve_init_c(void);
+void av1_lowbd_convolve_init_ssse3(void);
+RTCD_EXTERN void (*av1_lowbd_convolve_init)(void);
+
+void av1_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
+#define av1_quantize_b av1_quantize_b_c
+
+void av1_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+void av1_quantize_fp_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+void av1_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*av1_quantize_fp)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+
+void av1_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+void av1_quantize_fp_32x32_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*av1_quantize_fp_32x32)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+
+void av1_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
+void av1_temporal_filter_apply_sse2(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
+RTCD_EXTERN void (*av1_temporal_filter_apply)(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
+
+void copy_4x4_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
+void copy_4x4_16bit_to_16bit_sse2(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
+void copy_4x4_16bit_to_16bit_ssse3(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
+void copy_4x4_16bit_to_16bit_sse4_1(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
+RTCD_EXTERN void (*copy_4x4_16bit_to_16bit)(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
+
+void copy_4x4_16bit_to_8bit_c(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
+void copy_4x4_16bit_to_8bit_sse2(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
+void copy_4x4_16bit_to_8bit_ssse3(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
+void copy_4x4_16bit_to_8bit_sse4_1(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
+RTCD_EXTERN void (*copy_4x4_16bit_to_8bit)(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
+
+void copy_8x8_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
+void copy_8x8_16bit_to_16bit_sse2(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
+void copy_8x8_16bit_to_16bit_ssse3(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
+void copy_8x8_16bit_to_16bit_sse4_1(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
+RTCD_EXTERN void (*copy_8x8_16bit_to_16bit)(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
+
+void copy_8x8_16bit_to_8bit_c(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
+void copy_8x8_16bit_to_8bit_sse2(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
+void copy_8x8_16bit_to_8bit_ssse3(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
+void copy_8x8_16bit_to_8bit_sse4_1(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
+RTCD_EXTERN void (*copy_8x8_16bit_to_8bit)(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
+
+void copy_rect8_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, int sstride, int v, int h);
+void copy_rect8_16bit_to_16bit_sse2(uint16_t *dst, int dstride, const uint16_t *src, int sstride, int v, int h);
+void copy_rect8_16bit_to_16bit_ssse3(uint16_t *dst, int dstride, const uint16_t *src, int sstride, int v, int h);
+void copy_rect8_16bit_to_16bit_sse4_1(uint16_t *dst, int dstride, const uint16_t *src, int sstride, int v, int h);
+RTCD_EXTERN void (*copy_rect8_16bit_to_16bit)(uint16_t *dst, int dstride, const uint16_t *src, int sstride, int v, int h);
+
+void copy_rect8_8bit_to_16bit_c(uint16_t *dst, int dstride, const uint8_t *src, int sstride, int v, int h);
+void copy_rect8_8bit_to_16bit_sse2(uint16_t *dst, int dstride, const uint8_t *src, int sstride, int v, int h);
+void copy_rect8_8bit_to_16bit_ssse3(uint16_t *dst, int dstride, const uint8_t *src, int sstride, int v, int h);
+void copy_rect8_8bit_to_16bit_sse4_1(uint16_t *dst, int dstride, const uint8_t *src, int sstride, int v, int h);
+RTCD_EXTERN void (*copy_rect8_8bit_to_16bit)(uint16_t *dst, int dstride, const uint8_t *src, int sstride, int v, int h);
+
+int od_dir_find8_c(const od_dering_in *img, int stride, int32_t *var, int coeff_shift);
+int od_dir_find8_sse2(const od_dering_in *img, int stride, int32_t *var, int coeff_shift);
+int od_dir_find8_ssse3(const od_dering_in *img, int stride, int32_t *var, int coeff_shift);
+int od_dir_find8_sse4_1(const od_dering_in *img, int stride, int32_t *var, int coeff_shift);
+RTCD_EXTERN int (*od_dir_find8)(const od_dering_in *img, int stride, int32_t *var, int coeff_shift);
+
+void od_filter_dering_direction_4x4_c(uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping);
+void od_filter_dering_direction_4x4_sse2(uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping);
+void od_filter_dering_direction_4x4_ssse3(uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping);
+void od_filter_dering_direction_4x4_sse4_1(uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping);
+RTCD_EXTERN void (*od_filter_dering_direction_4x4)(uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping);
+
+void od_filter_dering_direction_8x8_c(uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping);
+void od_filter_dering_direction_8x8_sse2(uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping);
+void od_filter_dering_direction_8x8_ssse3(uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping);
+void od_filter_dering_direction_8x8_sse4_1(uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping);
+RTCD_EXTERN void (*od_filter_dering_direction_8x8)(uint16_t *y, int ystride, const uint16_t *in, int threshold, int dir, int damping);
+
+void aom_rtcd(void);
+
+#ifdef RTCD_C
+#include "aom_ports/x86.h"
+static void setup_rtcd_internal(void)
+{
+    int flags = x86_simd_caps();
+
+    (void)flags;
+
+    aom_clpf_block = aom_clpf_block_c;
+    if (flags & HAS_SSE2) aom_clpf_block = aom_clpf_block_sse2;
+    if (flags & HAS_SSSE3) aom_clpf_block = aom_clpf_block_ssse3;
+    if (flags & HAS_SSE4_1) aom_clpf_block = aom_clpf_block_sse4_1;
+    aom_clpf_block_hbd = aom_clpf_block_hbd_c;
+    if (flags & HAS_SSE2) aom_clpf_block_hbd = aom_clpf_block_hbd_sse2;
+    if (flags & HAS_SSSE3) aom_clpf_block_hbd = aom_clpf_block_hbd_ssse3;
+    if (flags & HAS_SSE4_1) aom_clpf_block_hbd = aom_clpf_block_hbd_sse4_1;
+    aom_clpf_hblock = aom_clpf_hblock_c;
+    if (flags & HAS_SSE2) aom_clpf_hblock = aom_clpf_hblock_sse2;
+    if (flags & HAS_SSSE3) aom_clpf_hblock = aom_clpf_hblock_ssse3;
+    if (flags & HAS_SSE4_1) aom_clpf_hblock = aom_clpf_hblock_sse4_1;
+    aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_c;
+    if (flags & HAS_SSE2) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_sse2;
+    if (flags & HAS_SSSE3) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_ssse3;
+    if (flags & HAS_SSE4_1) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_sse4_1;
+    av1_block_error = av1_block_error_c;
+    if (flags & HAS_AVX2) av1_block_error = av1_block_error_avx2;
+    av1_convolve_horiz = av1_convolve_horiz_c;
+    if (flags & HAS_SSSE3) av1_convolve_horiz = av1_convolve_horiz_ssse3;
+    av1_convolve_vert = av1_convolve_vert_c;
+    if (flags & HAS_SSSE3) av1_convolve_vert = av1_convolve_vert_ssse3;
+    av1_fht16x16 = av1_fht16x16_c;
+    if (flags & HAS_SSE2) av1_fht16x16 = av1_fht16x16_sse2;
+    if (flags & HAS_AVX2) av1_fht16x16 = av1_fht16x16_avx2;
+    av1_fht16x32 = av1_fht16x32_c;
+    if (flags & HAS_SSE2) av1_fht16x32 = av1_fht16x32_sse2;
+    av1_fht16x8 = av1_fht16x8_c;
+    if (flags & HAS_SSE2) av1_fht16x8 = av1_fht16x8_sse2;
+    av1_fht32x16 = av1_fht32x16_c;
+    if (flags & HAS_SSE2) av1_fht32x16 = av1_fht32x16_sse2;
+    av1_fht32x32 = av1_fht32x32_c;
+    if (flags & HAS_SSE2) av1_fht32x32 = av1_fht32x32_sse2;
+    if (flags & HAS_AVX2) av1_fht32x32 = av1_fht32x32_avx2;
+    av1_fht4x4 = av1_fht4x4_c;
+    if (flags & HAS_SSE2) av1_fht4x4 = av1_fht4x4_sse2;
+    av1_fht4x8 = av1_fht4x8_c;
+    if (flags & HAS_SSE2) av1_fht4x8 = av1_fht4x8_sse2;
+    av1_fht8x16 = av1_fht8x16_c;
+    if (flags & HAS_SSE2) av1_fht8x16 = av1_fht8x16_sse2;
+    av1_fht8x4 = av1_fht8x4_c;
+    if (flags & HAS_SSE2) av1_fht8x4 = av1_fht8x4_sse2;
+    av1_fht8x8 = av1_fht8x8_c;
+    if (flags & HAS_SSE2) av1_fht8x8 = av1_fht8x8_sse2;
+    av1_full_search_sad = av1_full_search_sad_c;
+    if (flags & HAS_SSE3) av1_full_search_sad = av1_full_search_sadx3;
+    if (flags & HAS_SSE4_1) av1_full_search_sad = av1_full_search_sadx8;
+    av1_fwd_txfm2d_16x16 = av1_fwd_txfm2d_16x16_c;
+    if (flags & HAS_SSE4_1) av1_fwd_txfm2d_16x16 = av1_fwd_txfm2d_16x16_sse4_1;
+    av1_fwd_txfm2d_32x32 = av1_fwd_txfm2d_32x32_c;
+    if (flags & HAS_SSE4_1) av1_fwd_txfm2d_32x32 = av1_fwd_txfm2d_32x32_sse4_1;
+    av1_fwd_txfm2d_4x4 = av1_fwd_txfm2d_4x4_c;
+    if (flags & HAS_SSE4_1) av1_fwd_txfm2d_4x4 = av1_fwd_txfm2d_4x4_sse4_1;
+    av1_fwd_txfm2d_64x64 = av1_fwd_txfm2d_64x64_c;
+    if (flags & HAS_SSE4_1) av1_fwd_txfm2d_64x64 = av1_fwd_txfm2d_64x64_sse4_1;
+    av1_fwd_txfm2d_8x8 = av1_fwd_txfm2d_8x8_c;
+    if (flags & HAS_SSE4_1) av1_fwd_txfm2d_8x8 = av1_fwd_txfm2d_8x8_sse4_1;
+    av1_highbd_block_error = av1_highbd_block_error_c;
+    if (flags & HAS_SSE2) av1_highbd_block_error = av1_highbd_block_error_sse2;
+    av1_highbd_convolve_horiz = av1_highbd_convolve_horiz_c;
+    if (flags & HAS_SSE4_1) av1_highbd_convolve_horiz = av1_highbd_convolve_horiz_sse4_1;
+    av1_highbd_convolve_init = av1_highbd_convolve_init_c;
+    if (flags & HAS_SSE4_1) av1_highbd_convolve_init = av1_highbd_convolve_init_sse4_1;
+    av1_highbd_convolve_vert = av1_highbd_convolve_vert_c;
+    if (flags & HAS_SSE4_1) av1_highbd_convolve_vert = av1_highbd_convolve_vert_sse4_1;
+    av1_highbd_quantize_fp = av1_highbd_quantize_fp_c;
+    if (flags & HAS_SSE4_1) av1_highbd_quantize_fp = av1_highbd_quantize_fp_sse4_1;
+    if (flags & HAS_AVX2) av1_highbd_quantize_fp = av1_highbd_quantize_fp_avx2;
+    av1_iht16x16_256_add = av1_iht16x16_256_add_c;
+    if (flags & HAS_SSE2) av1_iht16x16_256_add = av1_iht16x16_256_add_sse2;
+    if (flags & HAS_AVX2) av1_iht16x16_256_add = av1_iht16x16_256_add_avx2;
+    av1_iht16x32_512_add = av1_iht16x32_512_add_c;
+    if (flags & HAS_SSE2) av1_iht16x32_512_add = av1_iht16x32_512_add_sse2;
+    av1_iht16x8_128_add = av1_iht16x8_128_add_c;
+    if (flags & HAS_SSE2) av1_iht16x8_128_add = av1_iht16x8_128_add_sse2;
+    av1_iht32x16_512_add = av1_iht32x16_512_add_c;
+    if (flags & HAS_SSE2) av1_iht32x16_512_add = av1_iht32x16_512_add_sse2;
+    av1_iht4x4_16_add = av1_iht4x4_16_add_c;
+    if (flags & HAS_SSE2) av1_iht4x4_16_add = av1_iht4x4_16_add_sse2;
+    av1_iht4x8_32_add = av1_iht4x8_32_add_c;
+    if (flags & HAS_SSE2) av1_iht4x8_32_add = av1_iht4x8_32_add_sse2;
+    av1_iht8x16_128_add = av1_iht8x16_128_add_c;
+    if (flags & HAS_SSE2) av1_iht8x16_128_add = av1_iht8x16_128_add_sse2;
+    av1_iht8x4_32_add = av1_iht8x4_32_add_c;
+    if (flags & HAS_SSE2) av1_iht8x4_32_add = av1_iht8x4_32_add_sse2;
+    av1_iht8x8_64_add = av1_iht8x8_64_add_c;
+    if (flags & HAS_SSE2) av1_iht8x8_64_add = av1_iht8x8_64_add_sse2;
+    av1_inv_txfm2d_add_16x16 = av1_inv_txfm2d_add_16x16_c;
+    if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_16x16 = av1_inv_txfm2d_add_16x16_sse4_1;
+    av1_inv_txfm2d_add_32x32 = av1_inv_txfm2d_add_32x32_c;
+    if (flags & HAS_AVX2) av1_inv_txfm2d_add_32x32 = av1_inv_txfm2d_add_32x32_avx2;
+    av1_inv_txfm2d_add_4x4 = av1_inv_txfm2d_add_4x4_c;
+    if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_4x4 = av1_inv_txfm2d_add_4x4_sse4_1;
+    av1_inv_txfm2d_add_8x8 = av1_inv_txfm2d_add_8x8_c;
+    if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_8x8 = av1_inv_txfm2d_add_8x8_sse4_1;
+    av1_lowbd_convolve_init = av1_lowbd_convolve_init_c;
+    if (flags & HAS_SSSE3) av1_lowbd_convolve_init = av1_lowbd_convolve_init_ssse3;
+    av1_quantize_fp = av1_quantize_fp_c;
+    if (flags & HAS_SSE2) av1_quantize_fp = av1_quantize_fp_sse2;
+    if (flags & HAS_AVX2) av1_quantize_fp = av1_quantize_fp_avx2;
+    av1_quantize_fp_32x32 = av1_quantize_fp_32x32_c;
+    if (flags & HAS_AVX2) av1_quantize_fp_32x32 = av1_quantize_fp_32x32_avx2;
+    av1_temporal_filter_apply = av1_temporal_filter_apply_c;
+    if (flags & HAS_SSE2) av1_temporal_filter_apply = av1_temporal_filter_apply_sse2;
+    copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_c;
+    if (flags & HAS_SSE2) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_sse2;
+    if (flags & HAS_SSSE3) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_ssse3;
+    if (flags & HAS_SSE4_1) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_sse4_1;
+    copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_c;
+    if (flags & HAS_SSE2) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_sse2;
+    if (flags & HAS_SSSE3) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_ssse3;
+    if (flags & HAS_SSE4_1) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_sse4_1;
+    copy_8x8_16bit_to_16bit = copy_8x8_16bit_to_16bit_c;
+    if (flags & HAS_SSE2) copy_8x8_16bit_to_16bit = copy_8x8_16bit_to_16bit_sse2;
+    if (flags & HAS_SSSE3) copy_8x8_16bit_to_16bit = copy_8x8_16bit_to_16bit_ssse3;
+    if (flags & HAS_SSE4_1) copy_8x8_16bit_to_16bit = copy_8x8_16bit_to_16bit_sse4_1;
+    copy_8x8_16bit_to_8bit = copy_8x8_16bit_to_8bit_c;
+    if (flags & HAS_SSE2) copy_8x8_16bit_to_8bit = copy_8x8_16bit_to_8bit_sse2;
+    if (flags & HAS_SSSE3) copy_8x8_16bit_to_8bit = copy_8x8_16bit_to_8bit_ssse3;
+    if (flags & HAS_SSE4_1) copy_8x8_16bit_to_8bit = copy_8x8_16bit_to_8bit_sse4_1;
+    copy_rect8_16bit_to_16bit = copy_rect8_16bit_to_16bit_c;
+    if (flags & HAS_SSE2) copy_rect8_16bit_to_16bit = copy_rect8_16bit_to_16bit_sse2;
+    if (flags & HAS_SSSE3) copy_rect8_16bit_to_16bit = copy_rect8_16bit_to_16bit_ssse3;
+    if (flags & HAS_SSE4_1) copy_rect8_16bit_to_16bit = copy_rect8_16bit_to_16bit_sse4_1;
+    copy_rect8_8bit_to_16bit = copy_rect8_8bit_to_16bit_c;
+    if (flags & HAS_SSE2) copy_rect8_8bit_to_16bit = copy_rect8_8bit_to_16bit_sse2;
+    if (flags & HAS_SSSE3) copy_rect8_8bit_to_16bit = copy_rect8_8bit_to_16bit_ssse3;
+    if (flags & HAS_SSE4_1) copy_rect8_8bit_to_16bit = copy_rect8_8bit_to_16bit_sse4_1;
+    od_dir_find8 = od_dir_find8_c;
+    if (flags & HAS_SSE2) od_dir_find8 = od_dir_find8_sse2;
+    if (flags & HAS_SSSE3) od_dir_find8 = od_dir_find8_ssse3;
+    if (flags & HAS_SSE4_1) od_dir_find8 = od_dir_find8_sse4_1;
+    od_filter_dering_direction_4x4 = od_filter_dering_direction_4x4_c;
+    if (flags & HAS_SSE2) od_filter_dering_direction_4x4 = od_filter_dering_direction_4x4_sse2;
+    if (flags & HAS_SSSE3) od_filter_dering_direction_4x4 = od_filter_dering_direction_4x4_ssse3;
+    if (flags & HAS_SSE4_1) od_filter_dering_direction_4x4 = od_filter_dering_direction_4x4_sse4_1;
+    od_filter_dering_direction_8x8 = od_filter_dering_direction_8x8_c;
+    if (flags & HAS_SSE2) od_filter_dering_direction_8x8 = od_filter_dering_direction_8x8_sse2;
+    if (flags & HAS_SSSE3) od_filter_dering_direction_8x8 = od_filter_dering_direction_8x8_ssse3;
+    if (flags & HAS_SSE4_1) od_filter_dering_direction_8x8 = od_filter_dering_direction_8x8_sse4_1;
+}
+#endif
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#endif
--- a/media/libaom/config/win/x64/aom_config.asm
+++ b/media/libaom/config/win/x64/aom_config.asm
@@ -60,60 +60,63 @@
 %define CONFIG_INSPECTION 0
 %define CONFIG_DECODE_PERF_TESTS 0
 %define CONFIG_ENCODE_PERF_TESTS 0
 %define CONFIG_COEFFICIENT_RANGE_CHECKING 0
 %define CONFIG_LOWBITDEPTH 1
 %define CONFIG_HIGHBITDEPTH 1
 %define CONFIG_EXPERIMENTAL 0
 %define CONFIG_SIZE_LIMIT 1
+%define CONFIG_COLORSPACE_HEADERS 0
 %define CONFIG_FP_MB_STATS 0
 %define CONFIG_CDEF 1
 %define CONFIG_VAR_TX 1
 %define CONFIG_RECT_TX 1
 %define CONFIG_RECT_TX_EXT 0
 %define CONFIG_TPL_MV 0
-%define CONFIG_DUAL_FILTER 1
+%define CONFIG_DUAL_FILTER 0
 %define CONFIG_CONVOLVE_ROUND 0
 %define CONFIG_COMPOUND_ROUND 0
-%define CONFIG_EXT_TX 1
+%define CONFIG_EXT_TX 0
 %define CONFIG_DPCM_INTRA 0
 %define CONFIG_TX64X64 0
 %define CONFIG_EXT_INTRA 1
 %define CONFIG_INTRA_INTERP 0
 %define CONFIG_FILTER_INTRA 0
 %define CONFIG_INTRA_EDGE 0
 %define CONFIG_INTRABC 0
-%define CONFIG_EXT_INTER 1
-%define CONFIG_INTERINTRA 1
-%define CONFIG_WEDGE 1
-%define CONFIG_COMPOUND_SEGMENT 1
-%define CONFIG_EXT_REFS 1
-%define CONFIG_GLOBAL_MOTION 1
+%define CONFIG_EXT_INTER 0
+%define CONFIG_INTERINTRA 0
+%define CONFIG_WEDGE 0
+%define CONFIG_COMPOUND_SEGMENT 0
+%define CONFIG_EXT_REFS 0
+%define CONFIG_SPEED_REFS 0
+%define CONFIG_GF_GROUPS 0
+%define CONFIG_GLOBAL_MOTION 0
 %define CONFIG_NEW_QUANT 0
 %define CONFIG_SUPERTX 0
 %define CONFIG_ANS 0
 %define CONFIG_LOOP_RESTORATION 0
 %define CONFIG_EXT_PARTITION 0
 %define CONFIG_EXT_PARTITION_TYPES 0
 %define CONFIG_UNPOISON_PARTITION_CTX 0
 %define CONFIG_EXT_TILE 0
 %define CONFIG_MOTION_VAR 1
 %define CONFIG_NCOBMC 0
-%define CONFIG_WARPED_MOTION 1
+%define CONFIG_WARPED_MOTION 0
 %define CONFIG_Q_ADAPT_PROBS 0
 %define CONFIG_BITSTREAM_DEBUG 0
 %define CONFIG_ALT_INTRA 1
 %define CONFIG_PALETTE 1
 %define CONFIG_PALETTE_DELTA_ENCODING 0
 %define CONFIG_RAWBITS 0
 %define CONFIG_EC_SMALLMUL 1
 %define CONFIG_PVQ 0
 %define CONFIG_CFL 0
-%define CONFIG_XIPHRC 0
+%define CONFIG_XIPHRC 1
 %define CONFIG_CB4X4 1
 %define CONFIG_CHROMA_2X2 0
 %define CONFIG_CHROMA_SUB8X8 1
 %define CONFIG_FRAME_SIZE 0
 %define CONFIG_DELTA_Q 1
 %define CONFIG_EXT_DELTA_Q 1
 %define CONFIG_ADAPT_SCAN 0
 %define CONFIG_FILTER_7BIT 1
@@ -136,11 +139,18 @@
 %define CONFIG_LV_MAP 0
 %define CONFIG_TXK_SEL 0
 %define CONFIG_MV_COMPRESS 1
 %define CONFIG_FRAME_SUPERRES 0
 %define CONFIG_NEW_MULTISYMBOL 0
 %define CONFIG_COMPOUND_SINGLEREF 0
 %define CONFIG_AOM_QM 0
 %define CONFIG_ONE_SIDED_COMPOUND 1
-%define CONFIG_SMOOTH_HV 0
+%define CONFIG_EXT_COMP_REFS 0
+%define CONFIG_SMOOTH_HV 1
 %define CONFIG_VAR_REFS 0
+%define CONFIG_RECT_INTRA_PRED 0
+%define CONFIG_LGT 0
+%define CONFIG_SBL_SYMBOL 0
+%define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+%define CONFIG_BGSPRITE 0
+%define CONFIG_VAR_TX_NO_TX_MODE 0
 %define CONFIG_ANALYZER 0
--- a/media/libaom/config/win/x64/aom_config.h
+++ b/media/libaom/config/win/x64/aom_config.h
@@ -4,17 +4,17 @@
 /* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License */
 /* was not distributed with this source code in the LICENSE file, you can */
 /* obtain it at www.aomedia.org/license/software. If the Alliance for Open */
 /* Media Patent License 1.0 was not distributed with this source code in the */
 /* PATENTS file, you can obtain it at www.aomedia.org/license/patent. */
 /* This file automatically generated by configure. Do not edit! */
 #ifndef AOM_CONFIG_H
 #define AOM_CONFIG_H
-#define RESTRICT
+#define RESTRICT    
 #define INLINE      __forceinline
 #define ARCH_ARM 0
 #define ARCH_MIPS 0
 #define ARCH_X86 0
 #define ARCH_X86_64 1
 #define HAVE_NEON 0
 #define HAVE_NEON_ASM 0
 #define HAVE_MIPS32 0
@@ -73,60 +73,63 @@
 #define CONFIG_INSPECTION 0
 #define CONFIG_DECODE_PERF_TESTS 0
 #define CONFIG_ENCODE_PERF_TESTS 0
 #define CONFIG_COEFFICIENT_RANGE_CHECKING 0
 #define CONFIG_LOWBITDEPTH 1
 #define CONFIG_HIGHBITDEPTH 1
 #define CONFIG_EXPERIMENTAL 0
 #define CONFIG_SIZE_LIMIT 1
+#define CONFIG_COLORSPACE_HEADERS 0
 #define CONFIG_FP_MB_STATS 0
 #define CONFIG_CDEF 1
 #define CONFIG_VAR_TX 1
 #define CONFIG_RECT_TX 1
 #define CONFIG_RECT_TX_EXT 0
 #define CONFIG_TPL_MV 0
-#define CONFIG_DUAL_FILTER 1
+#define CONFIG_DUAL_FILTER 0
 #define CONFIG_CONVOLVE_ROUND 0
 #define CONFIG_COMPOUND_ROUND 0
-#define CONFIG_EXT_TX 1
+#define CONFIG_EXT_TX 0
 #define CONFIG_DPCM_INTRA 0
 #define CONFIG_TX64X64 0
 #define CONFIG_EXT_INTRA 1
 #define CONFIG_INTRA_INTERP 0
 #define CONFIG_FILTER_INTRA 0
 #define CONFIG_INTRA_EDGE 0
 #define CONFIG_INTRABC 0
-#define CONFIG_EXT_INTER 1
-#define CONFIG_INTERINTRA 1
-#define CONFIG_WEDGE 1
-#define CONFIG_COMPOUND_SEGMENT 1
-#define CONFIG_EXT_REFS 1
-#define CONFIG_GLOBAL_MOTION 1
+#define CONFIG_EXT_INTER 0
+#define CONFIG_INTERINTRA 0
+#define CONFIG_WEDGE 0
+#define CONFIG_COMPOUND_SEGMENT 0
+#define CONFIG_EXT_REFS 0
+#define CONFIG_SPEED_REFS 0
+#define CONFIG_GF_GROUPS 0
+#define CONFIG_GLOBAL_MOTION 0
 #define CONFIG_NEW_QUANT 0
 #define CONFIG_SUPERTX 0
 #define CONFIG_ANS 0
 #define CONFIG_LOOP_RESTORATION 0
 #define CONFIG_EXT_PARTITION 0
 #define CONFIG_EXT_PARTITION_TYPES 0
 #define CONFIG_UNPOISON_PARTITION_CTX 0
 #define CONFIG_EXT_TILE 0
 #define CONFIG_MOTION_VAR 1
 #define CONFIG_NCOBMC 0
-#define CONFIG_WARPED_MOTION 1
+#define CONFIG_WARPED_MOTION 0
 #define CONFIG_Q_ADAPT_PROBS 0
 #define CONFIG_BITSTREAM_DEBUG 0
 #define CONFIG_ALT_INTRA 1
 #define CONFIG_PALETTE 1
 #define CONFIG_PALETTE_DELTA_ENCODING 0
 #define CONFIG_RAWBITS 0
 #define CONFIG_EC_SMALLMUL 1
 #define CONFIG_PVQ 0
 #define CONFIG_CFL 0
-#define CONFIG_XIPHRC 0
+#define CONFIG_XIPHRC 1
 #define CONFIG_CB4X4 1
 #define CONFIG_CHROMA_2X2 0
 #define CONFIG_CHROMA_SUB8X8 1
 #define CONFIG_FRAME_SIZE 0
 #define CONFIG_DELTA_Q 1
 #define CONFIG_EXT_DELTA_Q 1
 #define CONFIG_ADAPT_SCAN 0
 #define CONFIG_FILTER_7BIT 1
@@ -149,14 +152,21 @@
 #define CONFIG_LV_MAP 0
 #define CONFIG_TXK_SEL 0
 #define CONFIG_MV_COMPRESS 1
 #define CONFIG_FRAME_SUPERRES 0
 #define CONFIG_NEW_MULTISYMBOL 0
 #define CONFIG_COMPOUND_SINGLEREF 0
 #define CONFIG_AOM_QM 0
 #define CONFIG_ONE_SIDED_COMPOUND 1
-#define CONFIG_SMOOTH_HV 0
+#define CONFIG_EXT_COMP_REFS 0
+#define CONFIG_SMOOTH_HV 1
 #define CONFIG_VAR_REFS 0
+#define CONFIG_RECT_INTRA_PRED 0
+#define CONFIG_LGT 0
+#define CONFIG_SBL_SYMBOL 0
+#define CONFIG_NCOBMC_ADAPT_WEIGHT 0
+#define CONFIG_BGSPRITE 0
+#define CONFIG_VAR_TX_NO_TX_MODE 0
 #define CONFIG_ANALYZER 0
 #define DECODE_WIDTH_LIMIT 8192
 #define DECODE_HEIGHT_LIMIT 4608
 #endif /* AOM_CONFIG_H */
--- a/media/libaom/config/win/x64/aom_dsp_rtcd.h
+++ b/media/libaom/config/win/x64/aom_dsp_rtcd.h
@@ -30,257 +30,439 @@ RTCD_EXTERN void (*aom_blend_a64_mask)(u
 
 void aom_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 void aom_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 RTCD_EXTERN void (*aom_blend_a64_vmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w);
 
 void aom_comp_avg_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
 #define aom_comp_avg_pred aom_comp_avg_pred_c
 
-void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
-void aom_comp_avg_upsampled_pred_sse2(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride);
+void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+void aom_comp_avg_upsampled_pred_sse2(uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 #define aom_comp_avg_upsampled_pred aom_comp_avg_upsampled_pred_sse2
 
-void aom_comp_mask_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_pred aom_comp_mask_pred_c
-
-void aom_comp_mask_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_comp_mask_upsampled_pred aom_comp_mask_upsampled_pred_c
-
 void aom_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
 void aom_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_horiz_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_horiz_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_avg_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_horiz_scale aom_convolve8_avg_horiz_scale_c
+
+void aom_convolve8_avg_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_scale aom_convolve8_avg_scale_c
+
 void aom_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_vert_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_avg_vert_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_avg_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_avg_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_avg_vert_scale aom_convolve8_avg_vert_scale_c
+
 void aom_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_horiz_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_horiz)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_horiz_scale aom_convolve8_horiz_scale_c
+
+void aom_convolve8_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_scale aom_convolve8_scale_c
+
 void aom_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_ssse3(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve8_vert_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 RTCD_EXTERN void (*aom_convolve8_vert)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 
+void aom_convolve8_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h);
+#define aom_convolve8_vert_scale aom_convolve8_vert_scale_c
+
 void aom_convolve_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve_avg aom_convolve_avg_sse2
 
 void aom_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 void aom_convolve_copy_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_convolve_copy aom_convolve_copy_sse2
 
 void aom_d117_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_16x16 aom_d117_predictor_16x16_c
 
+void aom_d117_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x32 aom_d117_predictor_16x32_c
+
+void aom_d117_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_16x8 aom_d117_predictor_16x8_c
+
 void aom_d117_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_2x2 aom_d117_predictor_2x2_c
 
+void aom_d117_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_32x16 aom_d117_predictor_32x16_c
+
 void aom_d117_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_32x32 aom_d117_predictor_32x32_c
 
 void aom_d117_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_4x4 aom_d117_predictor_4x4_c
 
+void aom_d117_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_4x8 aom_d117_predictor_4x8_c
+
+void aom_d117_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x16 aom_d117_predictor_8x16_c
+
+void aom_d117_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d117_predictor_8x4 aom_d117_predictor_8x4_c
+
 void aom_d117_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d117_predictor_8x8 aom_d117_predictor_8x8_c
 
 void aom_d135_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_16x16 aom_d135_predictor_16x16_c
 
+void aom_d135_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x32 aom_d135_predictor_16x32_c
+
+void aom_d135_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_16x8 aom_d135_predictor_16x8_c
+
 void aom_d135_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_2x2 aom_d135_predictor_2x2_c
 
+void aom_d135_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_32x16 aom_d135_predictor_32x16_c
+
 void aom_d135_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_32x32 aom_d135_predictor_32x32_c
 
 void aom_d135_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_4x4 aom_d135_predictor_4x4_c
 
+void aom_d135_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_4x8 aom_d135_predictor_4x8_c
+
+void aom_d135_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x16 aom_d135_predictor_8x16_c
+
+void aom_d135_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d135_predictor_8x4 aom_d135_predictor_8x4_c
+
 void aom_d135_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d135_predictor_8x8 aom_d135_predictor_8x8_c
 
 void aom_d153_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_16x16_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_16x16)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d153_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x32 aom_d153_predictor_16x32_c
+
+void aom_d153_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_16x8 aom_d153_predictor_16x8_c
+
 void aom_d153_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d153_predictor_2x2 aom_d153_predictor_2x2_c
 
+void aom_d153_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_32x16 aom_d153_predictor_32x16_c
+
 void aom_d153_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_32x32_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_32x32)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_d153_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d153_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_4x8 aom_d153_predictor_4x8_c
+
+void aom_d153_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x16 aom_d153_predictor_8x16_c
+
+void aom_d153_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d153_predictor_8x4 aom_d153_predictor_8x4_c
+
 void aom_d153_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d153_predictor_8x8_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d153_predictor_8x8)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
 void aom_d207e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_16x16 aom_d207e_predictor_16x16_c
 
+void aom_d207e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x32 aom_d207e_predictor_16x32_c
+
+void aom_d207e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_16x8 aom_d207e_predictor_16x8_c
+
 void aom_d207e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_2x2 aom_d207e_predictor_2x2_c
 
+void aom_d207e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_32x16 aom_d207e_predictor_32x16_c
+
 void aom_d207e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_32x32 aom_d207e_predictor_32x32_c
 
 void aom_d207e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_4x4 aom_d207e_predictor_4x4_c
 
+void aom_d207e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_4x8 aom_d207e_predictor_4x8_c
+
+void aom_d207e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x16 aom_d207e_predictor_8x16_c
+
+void aom_d207e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d207e_predictor_8x4 aom_d207e_predictor_8x4_c
+
 void aom_d207e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d207e_predictor_8x8 aom_d207e_predictor_8x8_c
 
 void aom_d45e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_16x16 aom_d45e_predictor_16x16_c
 
+void aom_d45e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x32 aom_d45e_predictor_16x32_c
+
+void aom_d45e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_16x8 aom_d45e_predictor_16x8_c
+
 void aom_d45e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_2x2 aom_d45e_predictor_2x2_c
 
+void aom_d45e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_32x16 aom_d45e_predictor_32x16_c
+
 void aom_d45e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_32x32 aom_d45e_predictor_32x32_c
 
 void aom_d45e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_4x4 aom_d45e_predictor_4x4_c
 
+void aom_d45e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_4x8 aom_d45e_predictor_4x8_c
+
+void aom_d45e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x16 aom_d45e_predictor_8x16_c
+
+void aom_d45e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d45e_predictor_8x4 aom_d45e_predictor_8x4_c
+
 void aom_d45e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d45e_predictor_8x8 aom_d45e_predictor_8x8_c
 
 void aom_d63e_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_16x16 aom_d63e_predictor_16x16_c
 
+void aom_d63e_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x32 aom_d63e_predictor_16x32_c
+
+void aom_d63e_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_16x8 aom_d63e_predictor_16x8_c
+
 void aom_d63e_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_2x2 aom_d63e_predictor_2x2_c
 
+void aom_d63e_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_32x16 aom_d63e_predictor_32x16_c
+
 void aom_d63e_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_32x32 aom_d63e_predictor_32x32_c
 
 void aom_d63e_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_d63e_predictor_4x4_ssse3(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 RTCD_EXTERN void (*aom_d63e_predictor_4x4)(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 
+void aom_d63e_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_4x8 aom_d63e_predictor_4x8_c
+
+void aom_d63e_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x16 aom_d63e_predictor_8x16_c
+
+void aom_d63e_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_d63e_predictor_8x4 aom_d63e_predictor_8x4_c
+
 void aom_d63e_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_d63e_predictor_8x8 aom_d63e_predictor_8x8_c
 
 void aom_dc_128_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_16x16 aom_dc_128_predictor_16x16_sse2
 
+void aom_dc_128_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x32 aom_dc_128_predictor_16x32_c
+
+void aom_dc_128_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_16x8 aom_dc_128_predictor_16x8_c
+
 void aom_dc_128_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_2x2 aom_dc_128_predictor_2x2_c
 
+void aom_dc_128_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_32x16 aom_dc_128_predictor_32x16_c
+
 void aom_dc_128_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_32x32 aom_dc_128_predictor_32x32_sse2
 
 void aom_dc_128_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_4x4 aom_dc_128_predictor_4x4_sse2
 
+void aom_dc_128_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_4x8 aom_dc_128_predictor_4x8_c
+
+void aom_dc_128_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x16 aom_dc_128_predictor_8x16_c
+
+void aom_dc_128_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_128_predictor_8x4 aom_dc_128_predictor_8x4_c
+
 void aom_dc_128_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_128_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_128_predictor_8x8 aom_dc_128_predictor_8x8_sse2
 
 void aom_dc_left_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_16x16 aom_dc_left_predictor_16x16_sse2
 
+void aom_dc_left_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x32 aom_dc_left_predictor_16x32_c
+
+void aom_dc_left_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_16x8 aom_dc_left_predictor_16x8_c
+
 void aom_dc_left_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_2x2 aom_dc_left_predictor_2x2_c
 
+void aom_dc_left_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_32x16 aom_dc_left_predictor_32x16_c
+
 void aom_dc_left_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_32x32 aom_dc_left_predictor_32x32_sse2
 
 void aom_dc_left_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_4x4 aom_dc_left_predictor_4x4_sse2
 
+void aom_dc_left_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_4x8 aom_dc_left_predictor_4x8_c
+
+void aom_dc_left_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x16 aom_dc_left_predictor_8x16_c
+
+void aom_dc_left_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_left_predictor_8x4 aom_dc_left_predictor_8x4_c
+
 void aom_dc_left_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_left_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_left_predictor_8x8 aom_dc_left_predictor_8x8_sse2
 
 void aom_dc_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_16x16 aom_dc_predictor_16x16_sse2
 
+void aom_dc_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x32 aom_dc_predictor_16x32_c
+
+void aom_dc_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_16x8 aom_dc_predictor_16x8_c
+
 void aom_dc_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_2x2 aom_dc_predictor_2x2_c
 
+void aom_dc_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_32x16 aom_dc_predictor_32x16_c
+
 void aom_dc_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_32x32 aom_dc_predictor_32x32_sse2
 
 void aom_dc_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_4x4 aom_dc_predictor_4x4_sse2
 
+void aom_dc_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_4x8 aom_dc_predictor_4x8_c
+
+void aom_dc_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x16 aom_dc_predictor_8x16_c
+
+void aom_dc_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_predictor_8x4 aom_dc_predictor_8x4_c
+
 void aom_dc_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_predictor_8x8 aom_dc_predictor_8x8_sse2
 
 void aom_dc_top_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_16x16 aom_dc_top_predictor_16x16_sse2
 
+void aom_dc_top_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x32 aom_dc_top_predictor_16x32_c
+
+void aom_dc_top_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_16x8 aom_dc_top_predictor_16x8_c
+
 void aom_dc_top_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_2x2 aom_dc_top_predictor_2x2_c
 
+void aom_dc_top_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_32x16 aom_dc_top_predictor_32x16_c
+
 void aom_dc_top_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_32x32 aom_dc_top_predictor_32x32_sse2
 
 void aom_dc_top_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_4x4 aom_dc_top_predictor_4x4_sse2
 
+void aom_dc_top_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_4x8 aom_dc_top_predictor_4x8_c
+
+void aom_dc_top_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x16 aom_dc_top_predictor_8x16_c
+
+void aom_dc_top_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_dc_top_predictor_8x4 aom_dc_top_predictor_8x4_c
+
 void aom_dc_top_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_dc_top_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_dc_top_predictor_8x8 aom_dc_top_predictor_8x8_sse2
 
 void aom_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct16x16_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct16x16 aom_fdct16x16_sse2
 
-void aom_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct16x16_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct16x16_1_avx2(const int16_t *input, tran_low_t *output, int stride);
-RTCD_EXTERN void (*aom_fdct16x16_1)(const int16_t *input, tran_low_t *output, int stride);
-
 void aom_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_avx2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct32x32)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct32x32_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct32x32_1_avx2(const int16_t *input, tran_low_t *output, int stride);
-RTCD_EXTERN void (*aom_fdct32x32_1)(const int16_t *input, tran_low_t *output, int stride);
-
 void aom_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_rd_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct32x32_rd_avx2(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct32x32_rd)(const int16_t *input, tran_low_t *output, int stride);
 
 void aom_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct4x4_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct4x4 aom_fdct4x4_sse2
@@ -289,20 +471,16 @@ void aom_fdct4x4_1_c(const int16_t *inpu
 void aom_fdct4x4_1_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_fdct4x4_1 aom_fdct4x4_1_sse2
 
 void aom_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct8x8_sse2(const int16_t *input, tran_low_t *output, int stride);
 void aom_fdct8x8_ssse3(const int16_t *input, tran_low_t *output, int stride);
 RTCD_EXTERN void (*aom_fdct8x8)(const int16_t *input, tran_low_t *output, int stride);
 
-void aom_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-void aom_fdct8x8_1_sse2(const int16_t *input, tran_low_t *output, int stride);
-#define aom_fdct8x8_1 aom_fdct8x8_1_sse2
-
 void aom_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 void aom_get16x16var_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 void aom_get16x16var_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 RTCD_EXTERN void (*aom_get16x16var)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 
 unsigned int aom_get4x4sse_cs_c(const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int ref_stride);
 #define aom_get4x4sse_cs aom_get4x4sse_cs_c
 
@@ -313,27 +491,45 @@ void aom_get8x8var_sse2(const uint8_t *s
 unsigned int aom_get_mb_ss_c(const int16_t *);
 unsigned int aom_get_mb_ss_sse2(const int16_t *);
 #define aom_get_mb_ss aom_get_mb_ss_sse2
 
 void aom_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_16x16 aom_h_predictor_16x16_sse2
 
+void aom_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x32 aom_h_predictor_16x32_c
+
+void aom_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_16x8 aom_h_predictor_16x8_c
+
 void aom_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_2x2 aom_h_predictor_2x2_c
 
+void aom_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_32x16 aom_h_predictor_32x16_c
+
 void aom_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_32x32 aom_h_predictor_32x32_sse2
 
 void aom_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_4x4 aom_h_predictor_4x4_sse2
 
+void aom_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_4x8 aom_h_predictor_4x8_c
+
+void aom_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x16 aom_h_predictor_8x16_c
+
+void aom_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_h_predictor_8x4 aom_h_predictor_8x4_c
+
 void aom_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_h_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_h_predictor_8x8 aom_h_predictor_8x8_sse2
 
 void aom_hadamard_16x16_c(const int16_t *src_diff, int src_stride, int16_t *coeff);
 void aom_hadamard_16x16_sse2(const int16_t *src_diff, int src_stride, int16_t *coeff);
 #define aom_hadamard_16x16 aom_hadamard_16x16_sse2
 
@@ -343,68 +539,16 @@ void aom_hadamard_8x8_ssse3(const int16_
 RTCD_EXTERN void (*aom_hadamard_8x8)(const int16_t *src_diff, int src_stride, int16_t *coeff);
 
 void aom_highbd_10_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get16x16var aom_highbd_10_get16x16var_c
 
 void aom_highbd_10_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_10_get8x8var aom_highbd_10_get8x8var_c
 
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_10_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_10_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_10_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_10_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse16x16 aom_highbd_10_mse16x16_sse2
 
 unsigned int aom_highbd_10_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_10_mse16x8 aom_highbd_10_mse16x8_c
 
 unsigned int aom_highbd_10_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -667,68 +811,16 @@ unsigned int aom_highbd_10_variance8x8_s
 #define aom_highbd_10_variance8x8 aom_highbd_10_variance8x8_sse2
 
 void aom_highbd_12_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get16x16var aom_highbd_12_get16x16var_c
 
 void aom_highbd_12_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_12_get8x8var aom_highbd_12_get8x8var_c
 
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_12_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_12_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_12_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_12_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse16x16 aom_highbd_12_mse16x16_sse2
 
 unsigned int aom_highbd_12_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_12_mse16x8 aom_highbd_12_mse16x8_c
 
 unsigned int aom_highbd_12_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -991,68 +1083,16 @@ unsigned int aom_highbd_12_variance8x8_s
 #define aom_highbd_12_variance8x8 aom_highbd_12_variance8x8_sse2
 
 void aom_highbd_8_get16x16var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get16x16var aom_highbd_8_get16x16var_c
 
 void aom_highbd_8_get8x8var_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum);
 #define aom_highbd_8_get8x8var aom_highbd_8_get8x8var_c
 
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_highbd_8_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_highbd_8_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 unsigned int aom_highbd_8_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_highbd_8_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse16x16 aom_highbd_8_mse16x16_sse2
 
 unsigned int aom_highbd_8_mse16x8_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 #define aom_highbd_8_mse16x8 aom_highbd_8_mse16x8_c
 
 unsigned int aom_highbd_8_mse8x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -1233,26 +1273,20 @@ RTCD_EXTERN void (*aom_highbd_blend_a64_
 
 void aom_highbd_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 void aom_highbd_blend_a64_vmask_sse4_1(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 RTCD_EXTERN void (*aom_highbd_blend_a64_vmask)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w, int bd);
 
 void aom_highbd_comp_avg_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
 #define aom_highbd_comp_avg_pred aom_highbd_comp_avg_pred_c
 
-void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
-void aom_highbd_comp_avg_upsampled_pred_sse2(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride);
+void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+void aom_highbd_comp_avg_upsampled_pred_sse2(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 #define aom_highbd_comp_avg_upsampled_pred aom_highbd_comp_avg_upsampled_pred_sse2
 
-void aom_highbd_comp_mask_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_pred aom_highbd_comp_mask_pred_c
-
-void aom_highbd_comp_mask_upsampled_pred_c(uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask);
-#define aom_highbd_comp_mask_upsampled_pred aom_highbd_comp_mask_upsampled_pred_c
-
 void aom_highbd_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 RTCD_EXTERN void (*aom_highbd_convolve8)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 
 void aom_highbd_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avg_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve8_avg_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
@@ -1286,233 +1320,400 @@ RTCD_EXTERN void (*aom_highbd_convolve_a
 void aom_highbd_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve_copy_sse2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 void aom_highbd_convolve_copy_avx2(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 RTCD_EXTERN void (*aom_highbd_convolve_copy)(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps);
 
 void aom_highbd_d117_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_16x16 aom_highbd_d117_predictor_16x16_c
 
+void aom_highbd_d117_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x32 aom_highbd_d117_predictor_16x32_c
+
+void aom_highbd_d117_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_16x8 aom_highbd_d117_predictor_16x8_c
+
 void aom_highbd_d117_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_2x2 aom_highbd_d117_predictor_2x2_c
 
+void aom_highbd_d117_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_32x16 aom_highbd_d117_predictor_32x16_c
+
 void aom_highbd_d117_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_32x32 aom_highbd_d117_predictor_32x32_c
 
 void aom_highbd_d117_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_4x4 aom_highbd_d117_predictor_4x4_c
 
+void aom_highbd_d117_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_4x8 aom_highbd_d117_predictor_4x8_c
+
+void aom_highbd_d117_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x16 aom_highbd_d117_predictor_8x16_c
+
+void aom_highbd_d117_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d117_predictor_8x4 aom_highbd_d117_predictor_8x4_c
+
 void aom_highbd_d117_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d117_predictor_8x8 aom_highbd_d117_predictor_8x8_c
 
 void aom_highbd_d135_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_16x16 aom_highbd_d135_predictor_16x16_c
 
+void aom_highbd_d135_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x32 aom_highbd_d135_predictor_16x32_c
+
+void aom_highbd_d135_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_16x8 aom_highbd_d135_predictor_16x8_c
+
 void aom_highbd_d135_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_2x2 aom_highbd_d135_predictor_2x2_c
 
+void aom_highbd_d135_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_32x16 aom_highbd_d135_predictor_32x16_c
+
 void aom_highbd_d135_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_32x32 aom_highbd_d135_predictor_32x32_c
 
 void aom_highbd_d135_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_4x4 aom_highbd_d135_predictor_4x4_c
 
+void aom_highbd_d135_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_4x8 aom_highbd_d135_predictor_4x8_c
+
+void aom_highbd_d135_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x16 aom_highbd_d135_predictor_8x16_c
+
+void aom_highbd_d135_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d135_predictor_8x4 aom_highbd_d135_predictor_8x4_c
+
 void aom_highbd_d135_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d135_predictor_8x8 aom_highbd_d135_predictor_8x8_c
 
 void aom_highbd_d153_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_16x16 aom_highbd_d153_predictor_16x16_c
 
+void aom_highbd_d153_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x32 aom_highbd_d153_predictor_16x32_c
+
+void aom_highbd_d153_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_16x8 aom_highbd_d153_predictor_16x8_c
+
 void aom_highbd_d153_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_2x2 aom_highbd_d153_predictor_2x2_c
 
+void aom_highbd_d153_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_32x16 aom_highbd_d153_predictor_32x16_c
+
 void aom_highbd_d153_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_32x32 aom_highbd_d153_predictor_32x32_c
 
 void aom_highbd_d153_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_4x4 aom_highbd_d153_predictor_4x4_c
 
+void aom_highbd_d153_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_4x8 aom_highbd_d153_predictor_4x8_c
+
+void aom_highbd_d153_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x16 aom_highbd_d153_predictor_8x16_c
+
+void aom_highbd_d153_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d153_predictor_8x4 aom_highbd_d153_predictor_8x4_c
+
 void aom_highbd_d153_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d153_predictor_8x8 aom_highbd_d153_predictor_8x8_c
 
 void aom_highbd_d207e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_16x16 aom_highbd_d207e_predictor_16x16_c
 
+void aom_highbd_d207e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x32 aom_highbd_d207e_predictor_16x32_c
+
+void aom_highbd_d207e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_16x8 aom_highbd_d207e_predictor_16x8_c
+
 void aom_highbd_d207e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_2x2 aom_highbd_d207e_predictor_2x2_c
 
+void aom_highbd_d207e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_32x16 aom_highbd_d207e_predictor_32x16_c
+
 void aom_highbd_d207e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_32x32 aom_highbd_d207e_predictor_32x32_c
 
 void aom_highbd_d207e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_4x4 aom_highbd_d207e_predictor_4x4_c
 
+void aom_highbd_d207e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_4x8 aom_highbd_d207e_predictor_4x8_c
+
+void aom_highbd_d207e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x16 aom_highbd_d207e_predictor_8x16_c
+
+void aom_highbd_d207e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d207e_predictor_8x4 aom_highbd_d207e_predictor_8x4_c
+
 void aom_highbd_d207e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d207e_predictor_8x8 aom_highbd_d207e_predictor_8x8_c
 
 void aom_highbd_d45e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_16x16 aom_highbd_d45e_predictor_16x16_c
 
+void aom_highbd_d45e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x32 aom_highbd_d45e_predictor_16x32_c
+
+void aom_highbd_d45e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_16x8 aom_highbd_d45e_predictor_16x8_c
+
 void aom_highbd_d45e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_2x2 aom_highbd_d45e_predictor_2x2_c
 
+void aom_highbd_d45e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_32x16 aom_highbd_d45e_predictor_32x16_c
+
 void aom_highbd_d45e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_32x32 aom_highbd_d45e_predictor_32x32_c
 
 void aom_highbd_d45e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_4x4 aom_highbd_d45e_predictor_4x4_c
 
+void aom_highbd_d45e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_4x8 aom_highbd_d45e_predictor_4x8_c
+
+void aom_highbd_d45e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x16 aom_highbd_d45e_predictor_8x16_c
+
+void aom_highbd_d45e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d45e_predictor_8x4 aom_highbd_d45e_predictor_8x4_c
+
 void aom_highbd_d45e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d45e_predictor_8x8 aom_highbd_d45e_predictor_8x8_c
 
 void aom_highbd_d63e_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_16x16 aom_highbd_d63e_predictor_16x16_c
 
+void aom_highbd_d63e_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x32 aom_highbd_d63e_predictor_16x32_c
+
+void aom_highbd_d63e_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_16x8 aom_highbd_d63e_predictor_16x8_c
+
 void aom_highbd_d63e_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_2x2 aom_highbd_d63e_predictor_2x2_c
 
+void aom_highbd_d63e_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_32x16 aom_highbd_d63e_predictor_32x16_c
+
 void aom_highbd_d63e_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_32x32 aom_highbd_d63e_predictor_32x32_c
 
 void aom_highbd_d63e_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_4x4 aom_highbd_d63e_predictor_4x4_c
 
+void aom_highbd_d63e_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_4x8 aom_highbd_d63e_predictor_4x8_c
+
+void aom_highbd_d63e_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x16 aom_highbd_d63e_predictor_8x16_c
+
+void aom_highbd_d63e_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_d63e_predictor_8x4 aom_highbd_d63e_predictor_8x4_c
+
 void aom_highbd_d63e_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_d63e_predictor_8x8 aom_highbd_d63e_predictor_8x8_c
 
 void aom_highbd_dc_128_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_16x16 aom_highbd_dc_128_predictor_16x16_c
 
+void aom_highbd_dc_128_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x32 aom_highbd_dc_128_predictor_16x32_c
+
+void aom_highbd_dc_128_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_16x8 aom_highbd_dc_128_predictor_16x8_c
+
 void aom_highbd_dc_128_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_2x2 aom_highbd_dc_128_predictor_2x2_c
 
+void aom_highbd_dc_128_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_32x16 aom_highbd_dc_128_predictor_32x16_c
+
 void aom_highbd_dc_128_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_32x32 aom_highbd_dc_128_predictor_32x32_c
 
 void aom_highbd_dc_128_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_4x4 aom_highbd_dc_128_predictor_4x4_c
 
+void aom_highbd_dc_128_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_4x8 aom_highbd_dc_128_predictor_4x8_c
+
+void aom_highbd_dc_128_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x16 aom_highbd_dc_128_predictor_8x16_c
+
+void aom_highbd_dc_128_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_128_predictor_8x4 aom_highbd_dc_128_predictor_8x4_c
+
 void aom_highbd_dc_128_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_128_predictor_8x8 aom_highbd_dc_128_predictor_8x8_c
 
 void aom_highbd_dc_left_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_16x16 aom_highbd_dc_left_predictor_16x16_c
 
+void aom_highbd_dc_left_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x32 aom_highbd_dc_left_predictor_16x32_c
+
+void aom_highbd_dc_left_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_16x8 aom_highbd_dc_left_predictor_16x8_c
+
 void aom_highbd_dc_left_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_2x2 aom_highbd_dc_left_predictor_2x2_c
 
+void aom_highbd_dc_left_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_32x16 aom_highbd_dc_left_predictor_32x16_c
+
 void aom_highbd_dc_left_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_32x32 aom_highbd_dc_left_predictor_32x32_c
 
 void aom_highbd_dc_left_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_4x4 aom_highbd_dc_left_predictor_4x4_c
 
+void aom_highbd_dc_left_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_4x8 aom_highbd_dc_left_predictor_4x8_c
+
+void aom_highbd_dc_left_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x16 aom_highbd_dc_left_predictor_8x16_c
+
+void aom_highbd_dc_left_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_left_predictor_8x4 aom_highbd_dc_left_predictor_8x4_c
+
 void aom_highbd_dc_left_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_left_predictor_8x8 aom_highbd_dc_left_predictor_8x8_c
 
 void aom_highbd_dc_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_16x16_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_16x16 aom_highbd_dc_predictor_16x16_sse2
 
+void aom_highbd_dc_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x32 aom_highbd_dc_predictor_16x32_c
+
+void aom_highbd_dc_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_16x8 aom_highbd_dc_predictor_16x8_c
+
 void aom_highbd_dc_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_2x2 aom_highbd_dc_predictor_2x2_c
 
+void aom_highbd_dc_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_32x16 aom_highbd_dc_predictor_32x16_c
+
 void aom_highbd_dc_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_32x32_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_32x32 aom_highbd_dc_predictor_32x32_sse2
 
 void aom_highbd_dc_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_4x4_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_4x4 aom_highbd_dc_predictor_4x4_sse2
 
+void aom_highbd_dc_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_4x8 aom_highbd_dc_predictor_4x8_c
+
+void aom_highbd_dc_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x16 aom_highbd_dc_predictor_8x16_c
+
+void aom_highbd_dc_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_predictor_8x4 aom_highbd_dc_predictor_8x4_c
+
 void aom_highbd_dc_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_dc_predictor_8x8_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_predictor_8x8 aom_highbd_dc_predictor_8x8_sse2
 
 void aom_highbd_dc_top_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_16x16 aom_highbd_dc_top_predictor_16x16_c
 
+void aom_highbd_dc_top_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x32 aom_highbd_dc_top_predictor_16x32_c
+
+void aom_highbd_dc_top_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_16x8 aom_highbd_dc_top_predictor_16x8_c
+
 void aom_highbd_dc_top_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_2x2 aom_highbd_dc_top_predictor_2x2_c
 
+void aom_highbd_dc_top_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_32x16 aom_highbd_dc_top_predictor_32x16_c
+
 void aom_highbd_dc_top_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_32x32 aom_highbd_dc_top_predictor_32x32_c
 
 void aom_highbd_dc_top_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_4x4 aom_highbd_dc_top_predictor_4x4_c
 
+void aom_highbd_dc_top_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_4x8 aom_highbd_dc_top_predictor_4x8_c
+
+void aom_highbd_dc_top_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x16 aom_highbd_dc_top_predictor_8x16_c
+
+void aom_highbd_dc_top_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_dc_top_predictor_8x4 aom_highbd_dc_top_predictor_8x4_c
+
 void aom_highbd_dc_top_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_dc_top_predictor_8x8 aom_highbd_dc_top_predictor_8x8_c
 
 void aom_highbd_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct16x16_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct16x16 aom_highbd_fdct16x16_sse2
 
-void aom_highbd_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct16x16_1 aom_highbd_fdct16x16_1_c
-
 void aom_highbd_fdct32x32_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct32x32_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct32x32 aom_highbd_fdct32x32_sse2
 
-void aom_highbd_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct32x32_1 aom_highbd_fdct32x32_1_c
-
 void aom_highbd_fdct32x32_rd_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct32x32_rd_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct32x32_rd aom_highbd_fdct32x32_rd_sse2
 
 void aom_highbd_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct4x4_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct4x4 aom_highbd_fdct4x4_sse2
 
 void aom_highbd_fdct8x8_c(const int16_t *input, tran_low_t *output, int stride);
 void aom_highbd_fdct8x8_sse2(const int16_t *input, tran_low_t *output, int stride);
 #define aom_highbd_fdct8x8 aom_highbd_fdct8x8_sse2
 
-void aom_highbd_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride);
-#define aom_highbd_fdct8x8_1 aom_highbd_fdct8x8_1_c
-
 void aom_highbd_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_16x16 aom_highbd_h_predictor_16x16_c
 
+void aom_highbd_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x32 aom_highbd_h_predictor_16x32_c
+
+void aom_highbd_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_16x8 aom_highbd_h_predictor_16x8_c
+
 void aom_highbd_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_2x2 aom_highbd_h_predictor_2x2_c
 
+void aom_highbd_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_32x16 aom_highbd_h_predictor_32x16_c
+
 void aom_highbd_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_32x32 aom_highbd_h_predictor_32x32_c
 
 void aom_highbd_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_4x4 aom_highbd_h_predictor_4x4_c
 
+void aom_highbd_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_4x8 aom_highbd_h_predictor_4x8_c
+
+void aom_highbd_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x16 aom_highbd_h_predictor_8x16_c
+
+void aom_highbd_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_h_predictor_8x4 aom_highbd_h_predictor_8x4_c
+
 void aom_highbd_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_h_predictor_8x8 aom_highbd_h_predictor_8x8_c
 
-void aom_highbd_idct16x16_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct16x16_1_add aom_highbd_idct16x16_1_add_c
-
-void aom_highbd_idct32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1024_add aom_highbd_idct32x32_1024_add_c
-
-void aom_highbd_idct32x32_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_1_add aom_highbd_idct32x32_1_add_c
-
-void aom_highbd_idct32x32_34_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct32x32_34_add aom_highbd_idct32x32_34_add_c
-
-void aom_highbd_idct4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-void aom_highbd_idct4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct4x4_16_add aom_highbd_idct4x4_16_add_sse2
-
-void aom_highbd_idct4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct4x4_1_add aom_highbd_idct4x4_1_add_c
-
-void aom_highbd_idct8x8_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
-#define aom_highbd_idct8x8_1_add aom_highbd_idct8x8_1_add_c
-
 void aom_highbd_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_16_add aom_highbd_iwht4x4_16_add_c
 
 void aom_highbd_iwht4x4_1_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int bd);
 #define aom_highbd_iwht4x4_1_add aom_highbd_iwht4x4_1_add_c
 
 void aom_highbd_lpf_horizontal_4_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 void aom_highbd_lpf_horizontal_4_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
@@ -1557,68 +1758,16 @@ void aom_highbd_lpf_vertical_4_dual_sse2
 void aom_highbd_lpf_vertical_8_c(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 void aom_highbd_lpf_vertical_8_sse2(uint16_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh, int bd);
 #define aom_highbd_lpf_vertical_8 aom_highbd_lpf_vertical_8_sse2
 
 void aom_highbd_lpf_vertical_8_dual_c(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 void aom_highbd_lpf_vertical_8_dual_sse2(uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1, int bd);
 #define aom_highbd_lpf_vertical_8_dual aom_highbd_lpf_vertical_8_dual_sse2
 
-unsigned int aom_highbd_masked_sad16x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad16x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad16x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad16x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad16x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad32x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad32x64_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad32x64)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad4x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad4x4_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad4x4)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad4x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad4x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad4x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad64x32_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad64x32_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad64x32)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad64x64_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad64x64_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad64x64)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x16_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x16_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x16)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x4_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x4_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x4)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_highbd_masked_sad8x8_c(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_highbd_masked_sad8x8_ssse3(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_highbd_masked_sad8x8)(const uint8_t *src8, int src_stride, const uint8_t *ref8, int ref_stride, const uint8_t *second_pred8, const uint8_t *msk, int msk_stride, int invert_mask);
-
 void aom_highbd_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 #define aom_highbd_minmax_8x8 aom_highbd_minmax_8x8_c
 
 unsigned int aom_highbd_obmc_sad16x16_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 unsigned int aom_highbd_obmc_sad16x16_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 RTCD_EXTERN unsigned int (*aom_highbd_obmc_sad16x16)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
 
 unsigned int aom_highbd_obmc_sad16x32_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask);
@@ -1758,31 +1907,50 @@ RTCD_EXTERN unsigned int (*aom_highbd_ob
 
 unsigned int aom_highbd_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 unsigned int aom_highbd_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_highbd_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 
 void aom_highbd_paeth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_16x16 aom_highbd_paeth_predictor_16x16_c
 
+void aom_highbd_paeth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x32 aom_highbd_paeth_predictor_16x32_c
+
+void aom_highbd_paeth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_16x8 aom_highbd_paeth_predictor_16x8_c
+
 void aom_highbd_paeth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_2x2 aom_highbd_paeth_predictor_2x2_c
 
+void aom_highbd_paeth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_32x16 aom_highbd_paeth_predictor_32x16_c
+
 void aom_highbd_paeth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_32x32 aom_highbd_paeth_predictor_32x32_c
 
 void aom_highbd_paeth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_4x4 aom_highbd_paeth_predictor_4x4_c
 
+void aom_highbd_paeth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_4x8 aom_highbd_paeth_predictor_4x8_c
+
+void aom_highbd_paeth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x16 aom_highbd_paeth_predictor_8x16_c
+
+void aom_highbd_paeth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_paeth_predictor_8x4 aom_highbd_paeth_predictor_8x4_c
+
 void aom_highbd_paeth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_paeth_predictor_8x8 aom_highbd_paeth_predictor_8x8_c
 
 void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_highbd_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
-#define aom_highbd_quantize_b aom_highbd_quantize_b_sse2
+void aom_highbd_quantize_b_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*aom_highbd_quantize_b)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void aom_highbd_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_highbd_quantize_b_32x32_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_highbd_quantize_b_32x32 aom_highbd_quantize_b_32x32_sse2
 
 void aom_highbd_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define aom_highbd_quantize_b_64x64 aom_highbd_quantize_b_64x64_c
 
@@ -2005,54 +2173,156 @@ void aom_highbd_sad8x8x3_c(const uint8_t
 
 void aom_highbd_sad8x8x4d_c(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 void aom_highbd_sad8x8x4d_sse2(const uint8_t *src_ptr, int src_stride, const uint8_t * const ref_ptr[], int ref_stride, uint32_t *sad_array);
 #define aom_highbd_sad8x8x4d aom_highbd_sad8x8x4d_sse2
 
 void aom_highbd_sad8x8x8_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, uint32_t *sad_array);
 #define aom_highbd_sad8x8x8 aom_highbd_sad8x8x8_c
 
+void aom_highbd_smooth_h_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x16 aom_highbd_smooth_h_predictor_16x16_c
+
+void aom_highbd_smooth_h_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x32 aom_highbd_smooth_h_predictor_16x32_c
+
+void aom_highbd_smooth_h_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_16x8 aom_highbd_smooth_h_predictor_16x8_c
+
+void aom_highbd_smooth_h_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_2x2 aom_highbd_smooth_h_predictor_2x2_c
+
+void aom_highbd_smooth_h_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x16 aom_highbd_smooth_h_predictor_32x16_c
+
+void aom_highbd_smooth_h_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_32x32 aom_highbd_smooth_h_predictor_32x32_c
+
+void aom_highbd_smooth_h_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x4 aom_highbd_smooth_h_predictor_4x4_c
+
+void aom_highbd_smooth_h_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_4x8 aom_highbd_smooth_h_predictor_4x8_c
+
+void aom_highbd_smooth_h_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x16 aom_highbd_smooth_h_predictor_8x16_c
+
+void aom_highbd_smooth_h_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x4 aom_highbd_smooth_h_predictor_8x4_c
+
+void aom_highbd_smooth_h_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_h_predictor_8x8 aom_highbd_smooth_h_predictor_8x8_c
+
 void aom_highbd_smooth_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_16x16 aom_highbd_smooth_predictor_16x16_c
 
+void aom_highbd_smooth_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x32 aom_highbd_smooth_predictor_16x32_c
+
+void aom_highbd_smooth_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_16x8 aom_highbd_smooth_predictor_16x8_c
+
 void aom_highbd_smooth_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_2x2 aom_highbd_smooth_predictor_2x2_c
 
+void aom_highbd_smooth_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_32x16 aom_highbd_smooth_predictor_32x16_c
+
 void aom_highbd_smooth_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_32x32 aom_highbd_smooth_predictor_32x32_c
 
 void aom_highbd_smooth_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_4x4 aom_highbd_smooth_predictor_4x4_c
 
+void aom_highbd_smooth_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_4x8 aom_highbd_smooth_predictor_4x8_c
+
+void aom_highbd_smooth_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x16 aom_highbd_smooth_predictor_8x16_c
+
+void aom_highbd_smooth_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_predictor_8x4 aom_highbd_smooth_predictor_8x4_c
+
 void aom_highbd_smooth_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_smooth_predictor_8x8 aom_highbd_smooth_predictor_8x8_c
 
+void aom_highbd_smooth_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x16 aom_highbd_smooth_v_predictor_16x16_c
+
+void aom_highbd_smooth_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x32 aom_highbd_smooth_v_predictor_16x32_c
+
+void aom_highbd_smooth_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_16x8 aom_highbd_smooth_v_predictor_16x8_c
+
+void aom_highbd_smooth_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_2x2 aom_highbd_smooth_v_predictor_2x2_c
+
+void aom_highbd_smooth_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x16 aom_highbd_smooth_v_predictor_32x16_c
+
+void aom_highbd_smooth_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_32x32 aom_highbd_smooth_v_predictor_32x32_c
+
+void aom_highbd_smooth_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x4 aom_highbd_smooth_v_predictor_4x4_c
+
+void aom_highbd_smooth_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_4x8 aom_highbd_smooth_v_predictor_4x8_c
+
+void aom_highbd_smooth_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x16 aom_highbd_smooth_v_predictor_8x16_c
+
+void aom_highbd_smooth_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x4 aom_highbd_smooth_v_predictor_8x4_c
+
+void aom_highbd_smooth_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_smooth_v_predictor_8x8 aom_highbd_smooth_v_predictor_8x8_c
+
 void aom_highbd_subtract_block_c(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 void aom_highbd_subtract_block_sse2(int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd);
 #define aom_highbd_subtract_block aom_highbd_subtract_block_sse2
 
-void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
-void aom_highbd_upsampled_pred_sse2(uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride);
+void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
+void aom_highbd_upsampled_pred_sse2(uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd);
 #define aom_highbd_upsampled_pred aom_highbd_upsampled_pred_sse2
 
 void aom_highbd_v_predictor_16x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_16x16_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_16x16 aom_highbd_v_predictor_16x16_sse2
 
+void aom_highbd_v_predictor_16x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x32 aom_highbd_v_predictor_16x32_c
+
+void aom_highbd_v_predictor_16x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_16x8 aom_highbd_v_predictor_16x8_c
+
 void aom_highbd_v_predictor_2x2_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_2x2 aom_highbd_v_predictor_2x2_c
 
+void aom_highbd_v_predictor_32x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_32x16 aom_highbd_v_predictor_32x16_c
+
 void aom_highbd_v_predictor_32x32_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_32x32_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_32x32 aom_highbd_v_predictor_32x32_sse2
 
 void aom_highbd_v_predictor_4x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_4x4_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_4x4 aom_highbd_v_predictor_4x4_sse2
 
+void aom_highbd_v_predictor_4x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_4x8 aom_highbd_v_predictor_4x8_c
+
+void aom_highbd_v_predictor_8x16_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x16 aom_highbd_v_predictor_8x16_c
+
+void aom_highbd_v_predictor_8x4_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
+#define aom_highbd_v_predictor_8x4 aom_highbd_v_predictor_8x4_c
+
 void aom_highbd_v_predictor_8x8_c(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 void aom_highbd_v_predictor_8x8_sse2(uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd);
 #define aom_highbd_v_predictor_8x8 aom_highbd_v_predictor_8x8_sse2
 
 void aom_idct16x16_10_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride);
 void aom_idct16x16_10_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride);
 void aom_idct16x16_10_add_avx2(const tran_low_t *input, uint8_t *dest, int dest_stride);
 RTCD_EXTERN void (*aom_idct16x16_10_add)(const tran_low_t *input, uint8_t *dest, int dest_stride);
@@ -2176,120 +2446,16 @@ void aom_lpf_vertical_4_dual_sse2(uint8_
 void aom_lpf_vertical_8_c(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 void aom_lpf_vertical_8_sse2(uint8_t *s, int pitch, const uint8_t *blimit, const uint8_t *limit, const uint8_t *thresh);
 #define aom_lpf_vertical_8 aom_lpf_vertical_8_sse2
 
 void aom_lpf_vertical_8_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 void aom_lpf_vertical_8_dual_sse2(uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1);
 #define aom_lpf_vertical_8_dual aom_lpf_vertical_8_dual_sse2
 
-unsigned int aom_masked_sad16x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad16x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad16x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad16x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad16x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad32x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad32x64_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad32x64)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad4x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad4x4_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad4x4)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad4x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad4x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad4x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad64x32_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad64x32_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad64x32)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad64x64_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad64x64_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad64x64)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x16_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x16_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x16)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x4_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x4_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x4)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sad8x8_c(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-unsigned int aom_masked_sad8x8_ssse3(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-RTCD_EXTERN unsigned int (*aom_masked_sad8x8)(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask);
-
-unsigned int aom_masked_sub_pixel_variance16x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance16x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance16x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance16x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance16x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance32x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance32x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance32x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance4x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance4x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance4x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance4x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance4x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance4x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance64x32_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance64x32_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance64x32)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance64x64_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance64x64_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance64x64)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x16_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x16_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x16)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x4_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x4_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x4)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
-unsigned int aom_masked_sub_pixel_variance8x8_c(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-unsigned int aom_masked_sub_pixel_variance8x8_ssse3(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-RTCD_EXTERN unsigned int (*aom_masked_sub_pixel_variance8x8)(const uint8_t *src, int src_stride, int xoffset, int yoffset, const uint8_t *ref, int ref_stride, const uint8_t *second_pred, const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
-
 void aom_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 void aom_minmax_8x8_sse2(const uint8_t *s, int p, const uint8_t *d, int dp, int *min, int *max);
 #define aom_minmax_8x8 aom_minmax_8x8_sse2
 
 unsigned int aom_mse16x16_c(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_mse16x16_sse2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 unsigned int aom_mse16x16_avx2(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_mse16x16)(const uint8_t *src_ptr, int  source_stride, const uint8_t *ref_ptr, int  recon_stride, unsigned int *sse);
@@ -2447,25 +2613,43 @@ RTCD_EXTERN unsigned int (*aom_obmc_vari
 
 unsigned int aom_obmc_variance8x8_c(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 unsigned int aom_obmc_variance8x8_sse4_1(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_obmc_variance8x8)(const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse);
 
 void aom_paeth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_16x16 aom_paeth_predictor_16x16_c
 
+void aom_paeth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x32 aom_paeth_predictor_16x32_c
+
+void aom_paeth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_16x8 aom_paeth_predictor_16x8_c
+
 void aom_paeth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_2x2 aom_paeth_predictor_2x2_c
 
+void aom_paeth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_32x16 aom_paeth_predictor_32x16_c
+
 void aom_paeth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_32x32 aom_paeth_predictor_32x32_c
 
 void aom_paeth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_4x4 aom_paeth_predictor_4x4_c
 
+void aom_paeth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_4x8 aom_paeth_predictor_4x8_c
+
+void aom_paeth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x16 aom_paeth_predictor_8x16_c
+
+void aom_paeth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_paeth_predictor_8x4 aom_paeth_predictor_8x4_c
+
 void aom_paeth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_paeth_predictor_8x8 aom_paeth_predictor_8x8_c
 
 void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_quantize_b_ssse3(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void aom_quantize_b_avx(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 RTCD_EXTERN void (*aom_quantize_b)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
@@ -2726,31 +2910,115 @@ void aom_scaled_avg_vert_c(const uint8_t
 #define aom_scaled_avg_vert aom_scaled_avg_vert_c
 
 void aom_scaled_horiz_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_horiz aom_scaled_horiz_c
 
 void aom_scaled_vert_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h);
 #define aom_scaled_vert aom_scaled_vert_c
 
+void aom_smooth_h_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x16 aom_smooth_h_predictor_16x16_c
+
+void aom_smooth_h_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x32 aom_smooth_h_predictor_16x32_c
+
+void aom_smooth_h_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_16x8 aom_smooth_h_predictor_16x8_c
+
+void aom_smooth_h_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_2x2 aom_smooth_h_predictor_2x2_c
+
+void aom_smooth_h_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x16 aom_smooth_h_predictor_32x16_c
+
+void aom_smooth_h_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_32x32 aom_smooth_h_predictor_32x32_c
+
+void aom_smooth_h_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x4 aom_smooth_h_predictor_4x4_c
+
+void aom_smooth_h_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_4x8 aom_smooth_h_predictor_4x8_c
+
+void aom_smooth_h_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x16 aom_smooth_h_predictor_8x16_c
+
+void aom_smooth_h_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x4 aom_smooth_h_predictor_8x4_c
+
+void aom_smooth_h_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_h_predictor_8x8 aom_smooth_h_predictor_8x8_c
+
 void aom_smooth_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_16x16 aom_smooth_predictor_16x16_c
 
+void aom_smooth_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x32 aom_smooth_predictor_16x32_c
+
+void aom_smooth_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_16x8 aom_smooth_predictor_16x8_c
+
 void aom_smooth_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_2x2 aom_smooth_predictor_2x2_c
 
+void aom_smooth_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_32x16 aom_smooth_predictor_32x16_c
+
 void aom_smooth_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_32x32 aom_smooth_predictor_32x32_c
 
 void aom_smooth_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_4x4 aom_smooth_predictor_4x4_c
 
+void aom_smooth_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_4x8 aom_smooth_predictor_4x8_c
+
+void aom_smooth_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x16 aom_smooth_predictor_8x16_c
+
+void aom_smooth_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_predictor_8x4 aom_smooth_predictor_8x4_c
+
 void aom_smooth_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_smooth_predictor_8x8 aom_smooth_predictor_8x8_c
 
+void aom_smooth_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x16 aom_smooth_v_predictor_16x16_c
+
+void aom_smooth_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x32 aom_smooth_v_predictor_16x32_c
+
+void aom_smooth_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_16x8 aom_smooth_v_predictor_16x8_c
+
+void aom_smooth_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_2x2 aom_smooth_v_predictor_2x2_c
+
+void aom_smooth_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x16 aom_smooth_v_predictor_32x16_c
+
+void aom_smooth_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_32x32 aom_smooth_v_predictor_32x32_c
+
+void aom_smooth_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x4 aom_smooth_v_predictor_4x4_c
+
+void aom_smooth_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_4x8 aom_smooth_v_predictor_4x8_c
+
+void aom_smooth_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x16 aom_smooth_v_predictor_8x16_c
+
+void aom_smooth_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x4 aom_smooth_v_predictor_8x4_c
+
+void aom_smooth_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_smooth_v_predictor_8x8 aom_smooth_v_predictor_8x8_c
+
 uint32_t aom_sub_pixel_avg_variance16x16_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x16_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 RTCD_EXTERN uint32_t (*aom_sub_pixel_avg_variance16x16)(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 
 uint32_t aom_sub_pixel_avg_variance16x32_c(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x32_sse2(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
 uint32_t aom_sub_pixel_avg_variance16x32_ssse3(const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred);
@@ -2887,35 +3155,53 @@ void aom_subtract_block_sse2(int rows, i
 uint64_t aom_sum_squares_2d_i16_c(const int16_t *src, int stride, int width, int height);
 uint64_t aom_sum_squares_2d_i16_sse2(const int16_t *src, int stride, int width, int height);
 #define aom_sum_squares_2d_i16 aom_sum_squares_2d_i16_sse2
 
 uint64_t aom_sum_squares_i16_c(const int16_t *src, uint32_t N);
 uint64_t aom_sum_squares_i16_sse2(const int16_t *src, uint32_t N);
 #define aom_sum_squares_i16 aom_sum_squares_i16_sse2
 
-void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
-void aom_upsampled_pred_sse2(uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
+void aom_upsampled_pred_sse2(uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride);
 #define aom_upsampled_pred aom_upsampled_pred_sse2
 
 void aom_v_predictor_16x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_16x16_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_16x16 aom_v_predictor_16x16_sse2
 
+void aom_v_predictor_16x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x32 aom_v_predictor_16x32_c
+
+void aom_v_predictor_16x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_16x8 aom_v_predictor_16x8_c
+
 void aom_v_predictor_2x2_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_2x2 aom_v_predictor_2x2_c
 
+void aom_v_predictor_32x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_32x16 aom_v_predictor_32x16_c
+
 void aom_v_predictor_32x32_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_32x32_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_32x32 aom_v_predictor_32x32_sse2
 
 void aom_v_predictor_4x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_4x4_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_4x4 aom_v_predictor_4x4_sse2
 
+void aom_v_predictor_4x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_4x8 aom_v_predictor_4x8_c
+
+void aom_v_predictor_8x16_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x16 aom_v_predictor_8x16_c
+
+void aom_v_predictor_8x4_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
+#define aom_v_predictor_8x4 aom_v_predictor_8x4_c
+
 void aom_v_predictor_8x8_c(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 void aom_v_predictor_8x8_sse2(uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left);
 #define aom_v_predictor_8x8 aom_v_predictor_8x8_sse2
 
 unsigned int aom_variance16x16_c(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 unsigned int aom_variance16x16_sse2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 unsigned int aom_variance16x16_avx2(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
 RTCD_EXTERN unsigned int (*aom_variance16x16)(const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse);
@@ -3033,56 +3319,26 @@ static void setup_rtcd_internal(void)
     aom_d153_predictor_32x32 = aom_d153_predictor_32x32_c;
     if (flags & HAS_SSSE3) aom_d153_predictor_32x32 = aom_d153_predictor_32x32_ssse3;
     aom_d153_predictor_4x4 = aom_d153_predictor_4x4_c;
     if (flags & HAS_SSSE3) aom_d153_predictor_4x4 = aom_d153_predictor_4x4_ssse3;
     aom_d153_predictor_8x8 = aom_d153_predictor_8x8_c;
     if (flags & HAS_SSSE3) aom_d153_predictor_8x8 = aom_d153_predictor_8x8_ssse3;
     aom_d63e_predictor_4x4 = aom_d63e_predictor_4x4_c;
     if (flags & HAS_SSSE3) aom_d63e_predictor_4x4 = aom_d63e_predictor_4x4_ssse3;
-    aom_fdct16x16_1 = aom_fdct16x16_1_sse2;
-    if (flags & HAS_AVX2) aom_fdct16x16_1 = aom_fdct16x16_1_avx2;
     aom_fdct32x32 = aom_fdct32x32_sse2;
     if (flags & HAS_AVX2) aom_fdct32x32 = aom_fdct32x32_avx2;
-    aom_fdct32x32_1 = aom_fdct32x32_1_sse2;
-    if (flags & HAS_AVX2) aom_fdct32x32_1 = aom_fdct32x32_1_avx2;
     aom_fdct32x32_rd = aom_fdct32x32_rd_sse2;
     if (flags & HAS_AVX2) aom_fdct32x32_rd = aom_fdct32x32_rd_avx2;
     aom_fdct8x8 = aom_fdct8x8_sse2;
     if (flags & HAS_SSSE3) aom_fdct8x8 = aom_fdct8x8_ssse3;
     aom_get16x16var = aom_get16x16var_sse2;
     if (flags & HAS_AVX2) aom_get16x16var = aom_get16x16var_avx2;
     aom_hadamard_8x8 = aom_hadamard_8x8_sse2;
     if (flags & HAS_SSSE3) aom_hadamard_8x8 = aom_hadamard_8x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x16 = aom_highbd_10_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x16 = aom_highbd_10_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x32 = aom_highbd_10_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x32 = aom_highbd_10_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance16x8 = aom_highbd_10_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance16x8 = aom_highbd_10_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x16 = aom_highbd_10_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x16 = aom_highbd_10_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x32 = aom_highbd_10_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x32 = aom_highbd_10_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance32x64 = aom_highbd_10_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance32x64 = aom_highbd_10_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance4x4 = aom_highbd_10_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance4x4 = aom_highbd_10_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance4x8 = aom_highbd_10_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance4x8 = aom_highbd_10_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance64x32 = aom_highbd_10_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance64x32 = aom_highbd_10_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance64x64 = aom_highbd_10_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance64x64 = aom_highbd_10_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x16 = aom_highbd_10_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x16 = aom_highbd_10_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x4 = aom_highbd_10_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x4 = aom_highbd_10_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_10_masked_sub_pixel_variance8x8 = aom_highbd_10_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_10_masked_sub_pixel_variance8x8 = aom_highbd_10_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_10_obmc_variance16x16 = aom_highbd_10_obmc_variance16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x16 = aom_highbd_10_obmc_variance16x16_sse4_1;
     aom_highbd_10_obmc_variance16x32 = aom_highbd_10_obmc_variance16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x32 = aom_highbd_10_obmc_variance16x32_sse4_1;
     aom_highbd_10_obmc_variance16x8 = aom_highbd_10_obmc_variance16x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance16x8 = aom_highbd_10_obmc_variance16x8_sse4_1;
     aom_highbd_10_obmc_variance32x16 = aom_highbd_10_obmc_variance32x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance32x16 = aom_highbd_10_obmc_variance32x16_sse4_1;
@@ -3105,42 +3361,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_10_obmc_variance8x8 = aom_highbd_10_obmc_variance8x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_obmc_variance8x8 = aom_highbd_10_obmc_variance8x8_sse4_1;
     aom_highbd_10_sub_pixel_avg_variance4x4 = aom_highbd_10_sub_pixel_avg_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_sub_pixel_avg_variance4x4 = aom_highbd_10_sub_pixel_avg_variance4x4_sse4_1;
     aom_highbd_10_sub_pixel_variance4x4 = aom_highbd_10_sub_pixel_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_sub_pixel_variance4x4 = aom_highbd_10_sub_pixel_variance4x4_sse4_1;
     aom_highbd_10_variance4x4 = aom_highbd_10_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_10_variance4x4 = aom_highbd_10_variance4x4_sse4_1;
-    aom_highbd_12_masked_sub_pixel_variance16x16 = aom_highbd_12_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x16 = aom_highbd_12_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance16x32 = aom_highbd_12_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x32 = aom_highbd_12_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance16x8 = aom_highbd_12_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance16x8 = aom_highbd_12_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x16 = aom_highbd_12_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x16 = aom_highbd_12_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x32 = aom_highbd_12_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x32 = aom_highbd_12_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance32x64 = aom_highbd_12_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance32x64 = aom_highbd_12_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance4x4 = aom_highbd_12_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance4x4 = aom_highbd_12_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance4x8 = aom_highbd_12_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance4x8 = aom_highbd_12_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance64x32 = aom_highbd_12_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance64x32 = aom_highbd_12_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance64x64 = aom_highbd_12_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance64x64 = aom_highbd_12_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x16 = aom_highbd_12_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x16 = aom_highbd_12_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x4 = aom_highbd_12_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x4 = aom_highbd_12_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_12_masked_sub_pixel_variance8x8 = aom_highbd_12_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_12_masked_sub_pixel_variance8x8 = aom_highbd_12_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_12_obmc_variance16x16 = aom_highbd_12_obmc_variance16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x16 = aom_highbd_12_obmc_variance16x16_sse4_1;
     aom_highbd_12_obmc_variance16x32 = aom_highbd_12_obmc_variance16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x32 = aom_highbd_12_obmc_variance16x32_sse4_1;
     aom_highbd_12_obmc_variance16x8 = aom_highbd_12_obmc_variance16x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance16x8 = aom_highbd_12_obmc_variance16x8_sse4_1;
     aom_highbd_12_obmc_variance32x16 = aom_highbd_12_obmc_variance32x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance32x16 = aom_highbd_12_obmc_variance32x16_sse4_1;
@@ -3163,42 +3393,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_12_obmc_variance8x8 = aom_highbd_12_obmc_variance8x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_obmc_variance8x8 = aom_highbd_12_obmc_variance8x8_sse4_1;
     aom_highbd_12_sub_pixel_avg_variance4x4 = aom_highbd_12_sub_pixel_avg_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_sub_pixel_avg_variance4x4 = aom_highbd_12_sub_pixel_avg_variance4x4_sse4_1;
     aom_highbd_12_sub_pixel_variance4x4 = aom_highbd_12_sub_pixel_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_sub_pixel_variance4x4 = aom_highbd_12_sub_pixel_variance4x4_sse4_1;
     aom_highbd_12_variance4x4 = aom_highbd_12_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_12_variance4x4 = aom_highbd_12_variance4x4_sse4_1;
-    aom_highbd_8_masked_sub_pixel_variance16x16 = aom_highbd_8_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x16 = aom_highbd_8_masked_sub_pixel_variance16x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance16x32 = aom_highbd_8_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x32 = aom_highbd_8_masked_sub_pixel_variance16x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance16x8 = aom_highbd_8_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance16x8 = aom_highbd_8_masked_sub_pixel_variance16x8_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x16 = aom_highbd_8_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x16 = aom_highbd_8_masked_sub_pixel_variance32x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x32 = aom_highbd_8_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x32 = aom_highbd_8_masked_sub_pixel_variance32x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance32x64 = aom_highbd_8_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance32x64 = aom_highbd_8_masked_sub_pixel_variance32x64_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance4x4 = aom_highbd_8_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance4x4 = aom_highbd_8_masked_sub_pixel_variance4x4_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance4x8 = aom_highbd_8_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance4x8 = aom_highbd_8_masked_sub_pixel_variance4x8_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance64x32 = aom_highbd_8_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance64x32 = aom_highbd_8_masked_sub_pixel_variance64x32_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance64x64 = aom_highbd_8_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance64x64 = aom_highbd_8_masked_sub_pixel_variance64x64_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x16 = aom_highbd_8_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x16 = aom_highbd_8_masked_sub_pixel_variance8x16_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x4 = aom_highbd_8_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x4 = aom_highbd_8_masked_sub_pixel_variance8x4_ssse3;
-    aom_highbd_8_masked_sub_pixel_variance8x8 = aom_highbd_8_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_8_masked_sub_pixel_variance8x8 = aom_highbd_8_masked_sub_pixel_variance8x8_ssse3;
     aom_highbd_8_sub_pixel_avg_variance4x4 = aom_highbd_8_sub_pixel_avg_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_8_sub_pixel_avg_variance4x4 = aom_highbd_8_sub_pixel_avg_variance4x4_sse4_1;
     aom_highbd_8_sub_pixel_variance4x4 = aom_highbd_8_sub_pixel_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_8_sub_pixel_variance4x4 = aom_highbd_8_sub_pixel_variance4x4_sse4_1;
     aom_highbd_8_variance4x4 = aom_highbd_8_variance4x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_8_variance4x4 = aom_highbd_8_variance4x4_sse4_1;
     aom_highbd_blend_a64_hmask = aom_highbd_blend_a64_hmask_c;
     if (flags & HAS_SSE4_1) aom_highbd_blend_a64_hmask = aom_highbd_blend_a64_hmask_sse4_1;
@@ -3217,42 +3421,16 @@ static void setup_rtcd_internal(void)
     aom_highbd_convolve8_horiz = aom_highbd_convolve8_horiz_sse2;
     if (flags & HAS_AVX2) aom_highbd_convolve8_horiz = aom_highbd_convolve8_horiz_avx2;
     aom_highbd_convolve8_vert = aom_highbd_convolve8_vert_sse2;
     if (flags & HAS_AVX2) aom_highbd_convolve8_vert = aom_highbd_convolve8_vert_avx2;
     aom_highbd_convolve_avg = aom_highbd_convolve_avg_sse2;
     if (flags & HAS_AVX2) aom_highbd_convolve_avg = aom_highbd_convolve_avg_avx2;
     aom_highbd_convolve_copy = aom_highbd_convolve_copy_sse2;
     if (flags & HAS_AVX2) aom_highbd_convolve_copy = aom_highbd_convolve_copy_avx2;
-    aom_highbd_masked_sad16x16 = aom_highbd_masked_sad16x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x16 = aom_highbd_masked_sad16x16_ssse3;
-    aom_highbd_masked_sad16x32 = aom_highbd_masked_sad16x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x32 = aom_highbd_masked_sad16x32_ssse3;
-    aom_highbd_masked_sad16x8 = aom_highbd_masked_sad16x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad16x8 = aom_highbd_masked_sad16x8_ssse3;
-    aom_highbd_masked_sad32x16 = aom_highbd_masked_sad32x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x16 = aom_highbd_masked_sad32x16_ssse3;
-    aom_highbd_masked_sad32x32 = aom_highbd_masked_sad32x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x32 = aom_highbd_masked_sad32x32_ssse3;
-    aom_highbd_masked_sad32x64 = aom_highbd_masked_sad32x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad32x64 = aom_highbd_masked_sad32x64_ssse3;
-    aom_highbd_masked_sad4x4 = aom_highbd_masked_sad4x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad4x4 = aom_highbd_masked_sad4x4_ssse3;
-    aom_highbd_masked_sad4x8 = aom_highbd_masked_sad4x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad4x8 = aom_highbd_masked_sad4x8_ssse3;
-    aom_highbd_masked_sad64x32 = aom_highbd_masked_sad64x32_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad64x32 = aom_highbd_masked_sad64x32_ssse3;
-    aom_highbd_masked_sad64x64 = aom_highbd_masked_sad64x64_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad64x64 = aom_highbd_masked_sad64x64_ssse3;
-    aom_highbd_masked_sad8x16 = aom_highbd_masked_sad8x16_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x16 = aom_highbd_masked_sad8x16_ssse3;
-    aom_highbd_masked_sad8x4 = aom_highbd_masked_sad8x4_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x4 = aom_highbd_masked_sad8x4_ssse3;
-    aom_highbd_masked_sad8x8 = aom_highbd_masked_sad8x8_c;
-    if (flags & HAS_SSSE3) aom_highbd_masked_sad8x8 = aom_highbd_masked_sad8x8_ssse3;
     aom_highbd_obmc_sad16x16 = aom_highbd_obmc_sad16x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x16 = aom_highbd_obmc_sad16x16_sse4_1;
     aom_highbd_obmc_sad16x32 = aom_highbd_obmc_sad16x32_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x32 = aom_highbd_obmc_sad16x32_sse4_1;
     aom_highbd_obmc_sad16x8 = aom_highbd_obmc_sad16x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad16x8 = aom_highbd_obmc_sad16x8_sse4_1;
     aom_highbd_obmc_sad32x16 = aom_highbd_obmc_sad32x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_sad32x16 = aom_highbd_obmc_sad32x16_sse4_1;
@@ -3295,16 +3473,18 @@ static void setup_rtcd_internal(void)
     aom_highbd_obmc_variance64x64 = aom_highbd_obmc_variance64x64_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance64x64 = aom_highbd_obmc_variance64x64_sse4_1;
     aom_highbd_obmc_variance8x16 = aom_highbd_obmc_variance8x16_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x16 = aom_highbd_obmc_variance8x16_sse4_1;
     aom_highbd_obmc_variance8x4 = aom_highbd_obmc_variance8x4_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x4 = aom_highbd_obmc_variance8x4_sse4_1;
     aom_highbd_obmc_variance8x8 = aom_highbd_obmc_variance8x8_c;
     if (flags & HAS_SSE4_1) aom_highbd_obmc_variance8x8 = aom_highbd_obmc_variance8x8_sse4_1;
+    aom_highbd_quantize_b = aom_highbd_quantize_b_sse2;
+    if (flags & HAS_AVX2) aom_highbd_quantize_b = aom_highbd_quantize_b_avx2;
     aom_highbd_sad16x16 = aom_highbd_sad16x16_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16 = aom_highbd_sad16x16_avx2;
     aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16_avg = aom_highbd_sad16x16_avg_avx2;
     aom_highbd_sad16x16x4d = aom_highbd_sad16x16x4d_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x16x4d = aom_highbd_sad16x16x4d_avx2;
     aom_highbd_sad16x32 = aom_highbd_sad16x32_sse2;
     if (flags & HAS_AVX2) aom_highbd_sad16x32 = aom_highbd_sad16x32_avx2;
@@ -3370,68 +3550,16 @@ static void setup_rtcd_internal(void)
     aom_idct8x8_12_add = aom_idct8x8_12_add_sse2;
     if (flags & HAS_SSSE3) aom_idct8x8_12_add = aom_idct8x8_12_add_ssse3;
     aom_idct8x8_64_add = aom_idct8x8_64_add_sse2;
     if (flags & HAS_SSSE3) aom_idct8x8_64_add = aom_idct8x8_64_add_ssse3;
     aom_lpf_horizontal_edge_16 = aom_lpf_horizontal_edge_16_sse2;
     if (flags & HAS_AVX2) aom_lpf_horizontal_edge_16 = aom_lpf_horizontal_edge_16_avx2;
     aom_lpf_horizontal_edge_8 = aom_lpf_horizontal_edge_8_sse2;
     if (flags & HAS_AVX2) aom_lpf_horizontal_edge_8 = aom_lpf_horizontal_edge_8_avx2;
-    aom_masked_sad16x16 = aom_masked_sad16x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x16 = aom_masked_sad16x16_ssse3;
-    aom_masked_sad16x32 = aom_masked_sad16x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x32 = aom_masked_sad16x32_ssse3;
-    aom_masked_sad16x8 = aom_masked_sad16x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad16x8 = aom_masked_sad16x8_ssse3;
-    aom_masked_sad32x16 = aom_masked_sad32x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x16 = aom_masked_sad32x16_ssse3;
-    aom_masked_sad32x32 = aom_masked_sad32x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x32 = aom_masked_sad32x32_ssse3;
-    aom_masked_sad32x64 = aom_masked_sad32x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sad32x64 = aom_masked_sad32x64_ssse3;
-    aom_masked_sad4x4 = aom_masked_sad4x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sad4x4 = aom_masked_sad4x4_ssse3;
-    aom_masked_sad4x8 = aom_masked_sad4x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad4x8 = aom_masked_sad4x8_ssse3;
-    aom_masked_sad64x32 = aom_masked_sad64x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sad64x32 = aom_masked_sad64x32_ssse3;
-    aom_masked_sad64x64 = aom_masked_sad64x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sad64x64 = aom_masked_sad64x64_ssse3;
-    aom_masked_sad8x16 = aom_masked_sad8x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x16 = aom_masked_sad8x16_ssse3;
-    aom_masked_sad8x4 = aom_masked_sad8x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x4 = aom_masked_sad8x4_ssse3;
-    aom_masked_sad8x8 = aom_masked_sad8x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sad8x8 = aom_masked_sad8x8_ssse3;
-    aom_masked_sub_pixel_variance16x16 = aom_masked_sub_pixel_variance16x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x16 = aom_masked_sub_pixel_variance16x16_ssse3;
-    aom_masked_sub_pixel_variance16x32 = aom_masked_sub_pixel_variance16x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x32 = aom_masked_sub_pixel_variance16x32_ssse3;
-    aom_masked_sub_pixel_variance16x8 = aom_masked_sub_pixel_variance16x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance16x8 = aom_masked_sub_pixel_variance16x8_ssse3;
-    aom_masked_sub_pixel_variance32x16 = aom_masked_sub_pixel_variance32x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x16 = aom_masked_sub_pixel_variance32x16_ssse3;
-    aom_masked_sub_pixel_variance32x32 = aom_masked_sub_pixel_variance32x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x32 = aom_masked_sub_pixel_variance32x32_ssse3;
-    aom_masked_sub_pixel_variance32x64 = aom_masked_sub_pixel_variance32x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance32x64 = aom_masked_sub_pixel_variance32x64_ssse3;
-    aom_masked_sub_pixel_variance4x4 = aom_masked_sub_pixel_variance4x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance4x4 = aom_masked_sub_pixel_variance4x4_ssse3;
-    aom_masked_sub_pixel_variance4x8 = aom_masked_sub_pixel_variance4x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance4x8 = aom_masked_sub_pixel_variance4x8_ssse3;
-    aom_masked_sub_pixel_variance64x32 = aom_masked_sub_pixel_variance64x32_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance64x32 = aom_masked_sub_pixel_variance64x32_ssse3;
-    aom_masked_sub_pixel_variance64x64 = aom_masked_sub_pixel_variance64x64_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance64x64 = aom_masked_sub_pixel_variance64x64_ssse3;
-    aom_masked_sub_pixel_variance8x16 = aom_masked_sub_pixel_variance8x16_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x16 = aom_masked_sub_pixel_variance8x16_ssse3;
-    aom_masked_sub_pixel_variance8x4 = aom_masked_sub_pixel_variance8x4_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x4 = aom_masked_sub_pixel_variance8x4_ssse3;
-    aom_masked_sub_pixel_variance8x8 = aom_masked_sub_pixel_variance8x8_c;
-    if (flags & HAS_SSSE3) aom_masked_sub_pixel_variance8x8 = aom_masked_sub_pixel_variance8x8_ssse3;
     aom_mse16x16 = aom_mse16x16_sse2;
     if (flags & HAS_AVX2) aom_mse16x16 = aom_mse16x16_avx2;
     aom_obmc_sad16x16 = aom_obmc_sad16x16_c;
     if (flags & HAS_SSE4_1) aom_obmc_sad16x16 = aom_obmc_sad16x16_sse4_1;
     aom_obmc_sad16x32 = aom_obmc_sad16x32_c;
     if (flags & HAS_SSE4_1) aom_obmc_sad16x32 = aom_obmc_sad16x32_sse4_1;
     aom_obmc_sad16x8 = aom_obmc_sad16x8_c;
     if (flags & HAS_SSE4_1) aom_obmc_sad16x8 = aom_obmc_sad16x8_sse4_1;
--- a/media/libaom/config/win/x64/av1_rtcd.h
+++ b/media/libaom/config/win/x64/av1_rtcd.h
@@ -13,22 +13,25 @@
 
 #include "aom/aom_integer.h"
 #include "av1/common/common.h"
 #include "av1/common/enums.h"
 #include "av1/common/quant_common.h"
 #include "av1/common/filter.h"
 #include "av1/common/convolve.h"
 #include "av1/common/av1_txfm.h"
+#include "av1/common/idct.h"
 #include "av1/common/odintrin.h"
 
 struct macroblockd;
 
 /* Encoder forward decls */
 struct macroblock;
+struct fwd_txfm_param;
+struct inv_txfm_param;
 struct aom_variance_vtable;
 struct search_site_config;
 struct mv;
 union int_mv;
 struct yv12_buffer_config;
 typedef uint16_t od_dering_in;
 
 #ifdef __cplusplus
@@ -55,84 +58,85 @@ RTCD_EXTERN void (*aom_clpf_hblock)(uint
 
 void aom_clpf_hblock_hbd_c(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_sse2(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_ssse3(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 void aom_clpf_hblock_hbd_sse4_1(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 RTCD_EXTERN void (*aom_clpf_hblock_hbd)(uint16_t *dst, const uint16_t *src, int dstride, int sstride, int sizex, int sizey, unsigned int strength, unsigned int bd);
 
 int64_t av1_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
-#define av1_block_error av1_block_error_c
+int64_t av1_block_error_avx2(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
+RTCD_EXTERN int64_t (*av1_block_error)(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz);
 
 void av1_convolve_horiz_c(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 void av1_convolve_horiz_ssse3(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 RTCD_EXTERN void (*av1_convolve_horiz)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 
 void av1_convolve_vert_c(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 void av1_convolve_vert_ssse3(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 RTCD_EXTERN void (*av1_convolve_vert)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params);
 
 int av1_diamond_search_sad_c(struct macroblock *x, const struct search_site_config *cfg,  struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_diamond_search_sad av1_diamond_search_sad_c
 
 void av1_fdct8x8_quant_c(const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 #define av1_fdct8x8_quant av1_fdct8x8_quant_c
 
-void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x16_avx2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht16x16)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x16_avx2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht16x16)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x32_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x32_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x32 av1_fht16x32_sse2
 
-void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x4 av1_fht16x4_c
 
-void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht16x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht16x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht16x8 av1_fht16x8_sse2
 
-void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x16 av1_fht32x16_sse2
 
-void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x32_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht32x32_avx2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_fht32x32)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x32_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht32x32_avx2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+RTCD_EXTERN void (*av1_fht32x32)(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 
-void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht32x8 av1_fht32x8_c
 
-void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x16 av1_fht4x16_c
 
-void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x4 av1_fht4x4_sse2
 
-void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht4x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht4x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht4x8 av1_fht4x8_sse2
 
-void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x16_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x16_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x16 av1_fht8x16_sse2
 
-void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x32 av1_fht8x32_c
 
-void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x4_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x4_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x4 av1_fht8x4_sse2
 
-void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride, int tx_type);
+void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
+void av1_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param);
 #define av1_fht8x8 av1_fht8x8_sse2
 
 int av1_full_range_search_c(const struct macroblock *x, const struct search_site_config *cfg, struct mv *ref_mv, struct mv *best_mv, int search_param, int sad_per_bit, int *num00, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv);
 #define av1_full_range_search av1_full_range_search_c
 
 int av1_full_search_sad_c(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 int av1_full_search_sadx3(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
 int av1_full_search_sadx8(const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv);
@@ -140,28 +144,46 @@ RTCD_EXTERN int (*av1_full_search_sad)(c
 
 void av1_fwd_idtx_c(const int16_t *src_diff, tran_low_t *coeff, int stride, int bs, int tx_type);
 #define av1_fwd_idtx av1_fwd_idtx_c
 
 void av1_fwd_txfm2d_16x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_16x16_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_16x16)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_16x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x32 av1_fwd_txfm2d_16x32_c
+
+void av1_fwd_txfm2d_16x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_16x8 av1_fwd_txfm2d_16x8_c
+
+void av1_fwd_txfm2d_32x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_32x16 av1_fwd_txfm2d_32x16_c
+
 void av1_fwd_txfm2d_32x32_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_32x32_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_32x32)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
 void av1_fwd_txfm2d_4x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_4x4_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_4x4)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_4x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_4x8 av1_fwd_txfm2d_4x8_c
+
 void av1_fwd_txfm2d_64x64_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_64x64_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_64x64)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
+void av1_fwd_txfm2d_8x16_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x16 av1_fwd_txfm2d_8x16_c
+
+void av1_fwd_txfm2d_8x4_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
+#define av1_fwd_txfm2d_8x4 av1_fwd_txfm2d_8x4_c
+
 void av1_fwd_txfm2d_8x8_c(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 void av1_fwd_txfm2d_8x8_sse4_1(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_fwd_txfm2d_8x8)(const int16_t *input, int32_t *output, int stride, int tx_type, int bd);
 
 void av1_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_fwht4x4 av1_fwht4x4_c
 
 int64_t av1_highbd_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd);
@@ -205,225 +227,178 @@ RTCD_EXTERN void (*av1_highbd_convolve_h
 void av1_highbd_convolve_init_c(void);
 void av1_highbd_convolve_init_sse4_1(void);
 RTCD_EXTERN void (*av1_highbd_convolve_init)(void);
 
 void av1_highbd_convolve_vert_c(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 void av1_highbd_convolve_vert_sse4_1(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 RTCD_EXTERN void (*av1_highbd_convolve_vert)(const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, int avg, int bd);
 
-void av1_highbd_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x16 av1_highbd_fht16x16_c
-
-void av1_highbd_fht16x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x32 av1_highbd_fht16x32_c
-
-void av1_highbd_fht16x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x4 av1_highbd_fht16x4_c
-
-void av1_highbd_fht16x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht16x8 av1_highbd_fht16x8_c
-
-void av1_highbd_fht32x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x16 av1_highbd_fht32x16_c
-
-void av1_highbd_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x32 av1_highbd_fht32x32_c
-
-void av1_highbd_fht32x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht32x8 av1_highbd_fht32x8_c
-
-void av1_highbd_fht4x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x16 av1_highbd_fht4x16_c
-
-void av1_highbd_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-void av1_highbd_fht4x4_sse4_1(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-RTCD_EXTERN void (*av1_highbd_fht4x4)(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-
-void av1_highbd_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht4x8 av1_highbd_fht4x8_c
-
-void av1_highbd_fht8x16_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x16 av1_highbd_fht8x16_c
-
-void av1_highbd_fht8x32_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x32 av1_highbd_fht8x32_c
-
-void av1_highbd_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x4 av1_highbd_fht8x4_c
-
-void av1_highbd_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, int tx_type);
-#define av1_highbd_fht8x8 av1_highbd_fht8x8_c
-
 void av1_highbd_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride);
 #define av1_highbd_fwht4x4 av1_highbd_fwht4x4_c
 
-void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type, int bd);
+void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x16_256_add av1_highbd_iht16x16_256_add_c
 
-void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x32_512_add av1_highbd_iht16x32_512_add_c
 
-void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x4_64_add av1_highbd_iht16x4_64_add_c
 
-void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht16x8_128_add av1_highbd_iht16x8_128_add_c
 
-void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x16_512_add av1_highbd_iht32x16_512_add_c
 
-void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht32x8_256_add av1_highbd_iht32x8_256_add_c
 
-void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x16_64_add av1_highbd_iht4x16_64_add_c
 
-void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x4_16_add av1_highbd_iht4x4_16_add_c
 
-void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht4x8_32_add av1_highbd_iht4x8_32_add_c
 
-void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x16_128_add av1_highbd_iht8x16_128_add_c
 
-void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x32_256_add av1_highbd_iht8x32_256_add_c
 
-void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x4_32_add av1_highbd_iht8x4_32_add_c
 
-void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd);
+void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_highbd_iht8x8_64_add av1_highbd_iht8x8_64_add_c
 
 void av1_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_highbd_quantize_b av1_highbd_quantize_b_c
 
 void av1_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 void av1_highbd_quantize_fp_sse4_1(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
+void av1_highbd_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 RTCD_EXTERN void (*av1_highbd_quantize_fp)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 
 void av1_highbd_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 #define av1_highbd_temporal_filter_apply av1_highbd_temporal_filter_apply_c
 
-void av1_highbd_warp_affine_c(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_highbd_warp_affine_ssse3(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-RTCD_EXTERN void (*av1_highbd_warp_affine)(const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
+void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+void av1_iht16x16_256_add_sse2(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+void av1_iht16x16_256_add_avx2(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
+RTCD_EXTERN void (*av1_iht16x16_256_add)(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 
-void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-void av1_iht16x16_256_add_sse2(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-void av1_iht16x16_256_add_avx2(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-RTCD_EXTERN void (*av1_iht16x16_256_add)(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
-
-void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht16x32_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht16x32_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x32_512_add av1_iht16x32_512_add_sse2
 
-void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x4_64_add av1_iht16x4_64_add_c
 
-void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht16x8_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht16x8_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht16x8_128_add av1_iht16x8_128_add_sse2
 
-void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht32x16_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht32x16_512_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht32x16_512_add av1_iht32x16_512_add_sse2
 
-void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, int tx_type);
+void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param);
 #define av1_iht32x32_1024_add av1_iht32x32_1024_add_c
 
-void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht32x8_256_add av1_iht32x8_256_add_c
 
-void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x16_64_add av1_iht4x16_64_add_c
 
-void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x4_16_add av1_iht4x4_16_add_sse2
 
-void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht4x8_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht4x8_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht4x8_32_add av1_iht4x8_32_add_sse2
 
-void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x16_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x16_128_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x16_128_add av1_iht8x16_128_add_sse2
 
-void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x32_256_add av1_iht8x32_256_add_c
 
-void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x4_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x4_32_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x4_32_add av1_iht8x4_32_add_sse2
 
-void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
-void av1_iht8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type);
+void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
+void av1_iht8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param);
 #define av1_iht8x8_64_add av1_iht8x8_64_add_sse2
 
 void av1_inv_txfm2d_add_16x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_16x16_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_16x16)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
+void av1_inv_txfm2d_add_16x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x32 av1_inv_txfm2d_add_16x32_c
+
+void av1_inv_txfm2d_add_16x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_16x8 av1_inv_txfm2d_add_16x8_c
+
+void av1_inv_txfm2d_add_32x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_32x16 av1_inv_txfm2d_add_32x16_c
+
 void av1_inv_txfm2d_add_32x32_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_32x32_avx2(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_32x32)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
 void av1_inv_txfm2d_add_4x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_4x4_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_4x4)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
+void av1_inv_txfm2d_add_4x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_4x8 av1_inv_txfm2d_add_4x8_c
+
 void av1_inv_txfm2d_add_64x64_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 #define av1_inv_txfm2d_add_64x64 av1_inv_txfm2d_add_64x64_c
 
+void av1_inv_txfm2d_add_8x16_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x16 av1_inv_txfm2d_add_8x16_c
+
+void av1_inv_txfm2d_add_8x4_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
+#define av1_inv_txfm2d_add_8x4 av1_inv_txfm2d_add_8x4_c
+
 void av1_inv_txfm2d_add_8x8_c(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 void av1_inv_txfm2d_add_8x8_sse4_1(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 RTCD_EXTERN void (*av1_inv_txfm2d_add_8x8)(const int32_t *input, uint16_t *output, int stride, int tx_type, int bd);
 
 void av1_lowbd_convolve_init_c(void);
 void av1_lowbd_convolve_init_ssse3(void);
 RTCD_EXTERN void (*av1_lowbd_convolve_init)(void);
 
 void av1_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale);
 #define av1_quantize_b av1_quantize_b_c
 
 void av1_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 void av1_quantize_fp_sse2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
-#define av1_quantize_fp av1_quantize_fp_sse2
+void av1_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*av1_quantize_fp)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void av1_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
-#define av1_quantize_fp_32x32 av1_quantize_fp_32x32_c
+void av1_quantize_fp_32x32_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
+RTCD_EXTERN void (*av1_quantize_fp_32x32)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan);
 
 void av1_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 void av1_temporal_filter_apply_sse2(uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count);
 #define av1_temporal_filter_apply av1_temporal_filter_apply_sse2
 
-void av1_warp_affine_c(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_warp_affine_sse2(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-void av1_warp_affine_ssse3(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-RTCD_EXTERN void (*av1_warp_affine)(const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
-
-void av1_wedge_compute_delta_squares_c(int16_t *d, const int16_t *a, const int16_t *b, int N);
-void av1_wedge_compute_delta_squares_sse2(int16_t *d, const int16_t *a, const int16_t *b, int N);
-#define av1_wedge_compute_delta_squares av1_wedge_compute_delta_squares_sse2
-
-int av1_wedge_sign_from_residuals_c(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-int av1_wedge_sign_from_residuals_sse2(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
-#define av1_wedge_sign_from_residuals av1_wedge_sign_from_residuals_sse2
-
-uint64_t av1_wedge_sse_from_residuals_c(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-uint64_t av1_wedge_sse_from_residuals_sse2(const int16_t *r1, const int16_t *d, const uint8_t *m, int N);
-#define av1_wedge_sse_from_residuals av1_wedge_sse_from_residuals_sse2
-
-double compute_cross_correlation_c(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-double compute_cross_correlation_sse4_1(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-RTCD_EXTERN double (*compute_cross_correlation)(unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2);
-
 void copy_4x4_16bit_to_16bit_c(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_sse2(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_ssse3(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_16bit_sse4_1(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 RTCD_EXTERN void (*copy_4x4_16bit_to_16bit)(uint16_t *dst, int dstride, const uint16_t *src, int sstride);
 
 void copy_4x4_16bit_to_8bit_c(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
 void copy_4x4_16bit_to_8bit_sse2(uint8_t *dst, int dstride, const uint16_t *src, int sstride);
@@ -490,16 +465,18 @@ static void setup_rtcd_internal(void)
     if (flags & HAS_SSSE3) aom_clpf_block_hbd = aom_clpf_block_hbd_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_block_hbd = aom_clpf_block_hbd_sse4_1;
     aom_clpf_hblock = aom_clpf_hblock_sse2;
     if (flags & HAS_SSSE3) aom_clpf_hblock = aom_clpf_hblock_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_hblock = aom_clpf_hblock_sse4_1;
     aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_sse2;
     if (flags & HAS_SSSE3) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_ssse3;
     if (flags & HAS_SSE4_1) aom_clpf_hblock_hbd = aom_clpf_hblock_hbd_sse4_1;
+    av1_block_error = av1_block_error_c;
+    if (flags & HAS_AVX2) av1_block_error = av1_block_error_avx2;
     av1_convolve_horiz = av1_convolve_horiz_c;
     if (flags & HAS_SSSE3) av1_convolve_horiz = av1_convolve_horiz_ssse3;
     av1_convolve_vert = av1_convolve_vert_c;
     if (flags & HAS_SSSE3) av1_convolve_vert = av1_convolve_vert_ssse3;
     av1_fht16x16 = av1_fht16x16_sse2;
     if (flags & HAS_AVX2) av1_fht16x16 = av1_fht16x16_avx2;
     av1_fht32x32 = av1_fht32x32_sse2;
     if (flags & HAS_AVX2) av1_fht32x32 = av1_fht32x32_avx2;
@@ -517,38 +494,35 @@ static void setup_rtcd_internal(void)
     av1_fwd_txfm2d_8x8 = av1_fwd_txfm2d_8x8_c;
     if (flags & HAS_SSE4_1) av1_fwd_txfm2d_8x8 = av1_fwd_txfm2d_8x8_sse4_1;
     av1_highbd_convolve_horiz = av1_highbd_convolve_horiz_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_horiz = av1_highbd_convolve_horiz_sse4_1;
     av1_highbd_convolve_init = av1_highbd_convolve_init_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_init = av1_highbd_convolve_init_sse4_1;
     av1_highbd_convolve_vert = av1_highbd_convolve_vert_c;
     if (flags & HAS_SSE4_1) av1_highbd_convolve_vert = av1_highbd_convolve_vert_sse4_1;
-    av1_highbd_fht4x4 = av1_highbd_fht4x4_c;
-    if (flags & HAS_SSE4_1) av1_highbd_fht4x4 = av1_highbd_fht4x4_sse4_1;
     av1_highbd_quantize_fp = av1_highbd_quantize_fp_c;
     if (flags & HAS_SSE4_1) av1_highbd_quantize_fp = av1_highbd_quantize_fp_sse4_1;
-    av1_highbd_warp_affine = av1_highbd_warp_affine_c;
-    if (flags & HAS_SSSE3) av1_highbd_warp_affine = av1_highbd_warp_affine_ssse3;
+    if (flags & HAS_AVX2) av1_highbd_quantize_fp = av1_highbd_quantize_fp_avx2;
     av1_iht16x16_256_add = av1_iht16x16_256_add_sse2;
     if (flags & HAS_AVX2) av1_iht16x16_256_add = av1_iht16x16_256_add_avx2;
     av1_inv_txfm2d_add_16x16 = av1_inv_txfm2d_add_16x16_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_16x16 = av1_inv_txfm2d_add_16x16_sse4_1;
     av1_inv_txfm2d_add_32x32 = av1_inv_txfm2d_add_32x32_c;
     if (flags & HAS_AVX2) av1_inv_txfm2d_add_32x32 = av1_inv_txfm2d_add_32x32_avx2;
     av1_inv_txfm2d_add_4x4 = av1_inv_txfm2d_add_4x4_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_4x4 = av1_inv_txfm2d_add_4x4_sse4_1;
     av1_inv_txfm2d_add_8x8 = av1_inv_txfm2d_add_8x8_c;
     if (flags & HAS_SSE4_1) av1_inv_txfm2d_add_8x8 = av1_inv_txfm2d_add_8x8_sse4_1;
     av1_lowbd_convolve_init = av1_lowbd_convolve_init_c;
     if (flags & HAS_SSSE3) av1_lowbd_convolve_init = av1_lowbd_convolve_init_ssse3;
-    av1_warp_affine = av1_warp_affine_sse2;
-    if (flags & HAS_SSSE3) av1_warp_affine = av1_warp_affine_ssse3;
-    compute_cross_correlation = compute_cross_correlation_c;
-    if (flags & HAS_SSE4_1) compute_cross_correlation = compute_cross_correlation_sse4_1;
+    av1_quantize_fp = av1_quantize_fp_sse2;
+    if (flags & HAS_AVX2) av1_quantize_fp = av1_quantize_fp_avx2;
+    av1_quantize_fp_32x32 = av1_quantize_fp_32x32_c;
+    if (flags & HAS_AVX2) av1_quantize_fp_32x32 = av1_quantize_fp_32x32_avx2;
     copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_sse2;
     if (flags & HAS_SSSE3) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_ssse3;
     if (flags & HAS_SSE4_1) copy_4x4_16bit_to_16bit = copy_4x4_16bit_to_16bit_sse4_1;
     copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_sse2;
     if (flags & HAS_SSSE3) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_ssse3;
     if (flags & HAS_SSE4_1) copy_4x4_16bit_to_8bit = copy_4x4_16bit_to_8bit_sse4_1;
     copy_8x8_16bit_to_16bit = copy_8x8_16bit_to_16bit_sse2;
     if (flags & HAS_SSSE3) copy_8x8_16bit_to_16bit = copy_8x8_16bit_to_16bit_ssse3;
--- a/media/libaom/sources.mozbuild
+++ b/media/libaom/sources.mozbuild
@@ -71,34 +71,33 @@ files = {
     '../../third_party/aom/aom_dsp/x86/fwd_txfm_avx2.c',
     '../../third_party/aom/aom_dsp/x86/fwd_txfm_sse2.c',
     '../../third_party/aom/aom_dsp/x86/fwd_txfm_ssse3_x86_64.asm',
     '../../third_party/aom/aom_dsp/x86/halfpix_variance_impl_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/halfpix_variance_sse2.c',
     '../../third_party/aom/aom_dsp/x86/highbd_convolve_avx2.c',
     '../../third_party/aom/aom_dsp/x86/highbd_intrapred_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/highbd_loopfilter_sse2.c',
+    '../../third_party/aom/aom_dsp/x86/highbd_quantize_intrin_avx2.c',
     '../../third_party/aom/aom_dsp/x86/highbd_quantize_intrin_sse2.c',
     '../../third_party/aom/aom_dsp/x86/highbd_sad4d_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/highbd_sad_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/highbd_subpel_variance_impl_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/highbd_subtract_sse2.c',
     '../../third_party/aom/aom_dsp/x86/highbd_variance_impl_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/highbd_variance_sse2.c',
     '../../third_party/aom/aom_dsp/x86/highbd_variance_sse4.c',
     '../../third_party/aom/aom_dsp/x86/intrapred_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/intrapred_ssse3.asm',
     '../../third_party/aom/aom_dsp/x86/inv_txfm_avx2.c',
     '../../third_party/aom/aom_dsp/x86/inv_txfm_sse2.c',
     '../../third_party/aom/aom_dsp/x86/inv_txfm_ssse3.c',
     '../../third_party/aom/aom_dsp/x86/inv_wht_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/loopfilter_avx2.c',
     '../../third_party/aom/aom_dsp/x86/loopfilter_sse2.c',
-    '../../third_party/aom/aom_dsp/x86/masked_sad_intrin_ssse3.c',
-    '../../third_party/aom/aom_dsp/x86/masked_variance_intrin_ssse3.c',
     '../../third_party/aom/aom_dsp/x86/obmc_sad_sse4.c',
     '../../third_party/aom/aom_dsp/x86/obmc_variance_sse4.c',
     '../../third_party/aom/aom_dsp/x86/quantize_avx_x86_64.asm',
     '../../third_party/aom/aom_dsp/x86/quantize_sse2.c',
     '../../third_party/aom/aom_dsp/x86/quantize_ssse3_x86_64.asm',
     '../../third_party/aom/aom_dsp/x86/sad4d_avx2.c',
     '../../third_party/aom/aom_dsp/x86/sad4d_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/sad_avx2.c',
@@ -118,19 +117,16 @@ files = {
     '../../third_party/aom/aom_ports/emms.asm',
     '../../third_party/aom/aom_ports/x86_abi_support.asm',
     '../../third_party/aom/aom_scale/aom_scale_rtcd.c',
     '../../third_party/aom/aom_scale/generic/aom_scale.c',
     '../../third_party/aom/aom_scale/generic/gen_scalers.c',
     '../../third_party/aom/aom_scale/generic/yv12config.c',
     '../../third_party/aom/aom_scale/generic/yv12extend.c',
     '../../third_party/aom/aom_util/aom_thread.c',
-    '../../third_party/aom/av1/../third_party/fastfeat/fast.c',
-    '../../third_party/aom/av1/../third_party/fastfeat/fast_9.c',
-    '../../third_party/aom/av1/../third_party/fastfeat/nonmax.c',
     '../../third_party/aom/av1/av1_cx_iface.c',
     '../../third_party/aom/av1/av1_dx_iface.c',
     '../../third_party/aom/av1/common/alloccommon.c',
     '../../third_party/aom/av1/common/av1_fwd_txfm1d.c',
     '../../third_party/aom/av1/common/av1_fwd_txfm2d.c',
     '../../third_party/aom/av1/common/av1_inv_txfm1d.c',
     '../../third_party/aom/av1/common/av1_inv_txfm2d.c',
     '../../third_party/aom/av1/common/av1_loopfilter.c',
@@ -160,84 +156,76 @@ files = {
     '../../third_party/aom/av1/common/reconinter.c',
     '../../third_party/aom/av1/common/reconintra.c',
     '../../third_party/aom/av1/common/resize.c',
     '../../third_party/aom/av1/common/scale.c',
     '../../third_party/aom/av1/common/scan.c',
     '../../third_party/aom/av1/common/seg_common.c',
     '../../third_party/aom/av1/common/thread_common.c',
     '../../third_party/aom/av1/common/tile_common.c',
-    '../../third_party/aom/av1/common/warped_motion.c',
     '../../third_party/aom/av1/common/x86/av1_convolve_ssse3.c',
     '../../third_party/aom/av1/common/x86/av1_fwd_txfm1d_sse4.c',
     '../../third_party/aom/av1/common/x86/av1_fwd_txfm2d_sse4.c',
     '../../third_party/aom/av1/common/x86/av1_highbd_convolve_sse4.c',
     '../../third_party/aom/av1/common/x86/highbd_inv_txfm_avx2.c',
     '../../third_party/aom/av1/common/x86/highbd_inv_txfm_sse4.c',
-    '../../third_party/aom/av1/common/x86/highbd_warp_plane_ssse3.c',
     '../../third_party/aom/av1/common/x86/hybrid_inv_txfm_avx2.c',
     '../../third_party/aom/av1/common/x86/idct_intrin_sse2.c',
-    '../../third_party/aom/av1/common/x86/warp_plane_sse2.c',
-    '../../third_party/aom/av1/common/x86/warp_plane_ssse3.c',
     '../../third_party/aom/av1/decoder/decodeframe.c',
     '../../third_party/aom/av1/decoder/decodemv.c',
     '../../third_party/aom/av1/decoder/decoder.c',
     '../../third_party/aom/av1/decoder/detokenize.c',
     '../../third_party/aom/av1/decoder/dsubexp.c',
     '../../third_party/aom/av1/decoder/dthread.c',
     '../../third_party/aom/av1/encoder/aq_complexity.c',
     '../../third_party/aom/av1/encoder/aq_cyclicrefresh.c',
     '../../third_party/aom/av1/encoder/aq_variance.c',
     '../../third_party/aom/av1/encoder/av1_quantize.c',
     '../../third_party/aom/av1/encoder/bitstream.c',
     '../../third_party/aom/av1/encoder/context_tree.c',
-    '../../third_party/aom/av1/encoder/corner_detect.c',
-    '../../third_party/aom/av1/encoder/corner_match.c',
     '../../third_party/aom/av1/encoder/cost.c',
     '../../third_party/aom/av1/encoder/dct.c',
     '../../third_party/aom/av1/encoder/encodeframe.c',
     '../../third_party/aom/av1/encoder/encodemb.c',
     '../../third_party/aom/av1/encoder/encodemv.c',
     '../../third_party/aom/av1/encoder/encoder.c',
     '../../third_party/aom/av1/encoder/ethread.c',
     '../../third_party/aom/av1/encoder/extend.c',
     '../../third_party/aom/av1/encoder/firstpass.c',
-    '../../third_party/aom/av1/encoder/global_motion.c',
     '../../third_party/aom/av1/encoder/hybrid_fwd_txfm.c',
     '../../third_party/aom/av1/encoder/lookahead.c',
     '../../third_party/aom/av1/encoder/mbgraph.c',
     '../../third_party/aom/av1/encoder/mcomp.c',
     '../../third_party/aom/av1/encoder/palette.c',
     '../../third_party/aom/av1/encoder/pickcdef.c',
     '../../third_party/aom/av1/encoder/picklpf.c',
-    '../../third_party/aom/av1/encoder/ransac.c',
     '../../third_party/aom/av1/encoder/ratectrl.c',
+    '../../third_party/aom/av1/encoder/ratectrl_xiph.c',
     '../../third_party/aom/av1/encoder/rd.c',
     '../../third_party/aom/av1/encoder/rdopt.c',
     '../../third_party/aom/av1/encoder/segmentation.c',
     '../../third_party/aom/av1/encoder/speed_features.c',
     '../../third_party/aom/av1/encoder/subexp.c',
     '../../third_party/aom/av1/encoder/temporal_filter.c',
     '../../third_party/aom/av1/encoder/tokenize.c',
     '../../third_party/aom/av1/encoder/treewriter.c',
-    '../../third_party/aom/av1/encoder/wedge_utils.c',
+    '../../third_party/aom/av1/encoder/x86/av1_highbd_quantize_avx2.c',
     '../../third_party/aom/av1/encoder/x86/av1_highbd_quantize_sse4.c',
+    '../../third_party/aom/av1/encoder/x86/av1_quantize_avx2.c',
     '../../third_party/aom/av1/encoder/x86/av1_quantize_sse2.c',
     '../../third_party/aom/av1/encoder/x86/av1_quantize_ssse3_x86_64.asm',
-    '../../third_party/aom/av1/encoder/x86/corner_match_sse4.c',
     '../../third_party/aom/av1/encoder/x86/dct_intrin_sse2.c',
     '../../third_party/aom/av1/encoder/x86/dct_sse2.asm',
     '../../third_party/aom/av1/encoder/x86/dct_ssse3.c',
     '../../third_party/aom/av1/encoder/x86/error_intrin_avx2.c',
     '../../third_party/aom/av1/encoder/x86/error_sse2.asm',
     '../../third_party/aom/av1/encoder/x86/highbd_block_error_intrin_sse2.c',
     '../../third_party/aom/av1/encoder/x86/highbd_fwd_txfm_sse4.c',
     '../../third_party/aom/av1/encoder/x86/hybrid_fwd_txfm_avx2.c',
     '../../third_party/aom/av1/encoder/x86/temporal_filter_apply_sse2.asm',
-    '../../third_party/aom/av1/encoder/x86/wedge_utils_sse2.c',
 ],
   'IA32_EXPORTS': [
     '../../third_party/aom/aom/aom.h',
     '../../third_party/aom/aom/aom_codec.h',
     '../../third_party/aom/aom/aom_decoder.h',
     '../../third_party/aom/aom/aom_encoder.h',
     '../../third_party/aom/aom/aom_frame_buffer.h',
     '../../third_party/aom/aom/aom_image.h',
@@ -302,34 +290,33 @@ files = {
     '../../third_party/aom/aom_dsp/x86/fwd_dct32_8cols_sse2.c',
     '../../third_party/aom/aom_dsp/x86/fwd_txfm_avx2.c',
     '../../third_party/aom/aom_dsp/x86/fwd_txfm_sse2.c',
     '../../third_party/aom/aom_dsp/x86/halfpix_variance_impl_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/halfpix_variance_sse2.c',
     '../../third_party/aom/aom_dsp/x86/highbd_convolve_avx2.c',
     '../../third_party/aom/aom_dsp/x86/highbd_intrapred_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/highbd_loopfilter_sse2.c',
+    '../../third_party/aom/aom_dsp/x86/highbd_quantize_intrin_avx2.c',
     '../../third_party/aom/aom_dsp/x86/highbd_quantize_intrin_sse2.c',
     '../../third_party/aom/aom_dsp/x86/highbd_sad4d_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/highbd_sad_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/highbd_subpel_variance_impl_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/highbd_subtract_sse2.c',
     '../../third_party/aom/aom_dsp/x86/highbd_variance_impl_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/highbd_variance_sse2.c',
     '../../third_party/aom/aom_dsp/x86/highbd_variance_sse4.c',
     '../../third_party/aom/aom_dsp/x86/intrapred_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/intrapred_ssse3.asm',
     '../../third_party/aom/aom_dsp/x86/inv_txfm_avx2.c',
     '../../third_party/aom/aom_dsp/x86/inv_txfm_sse2.c',
     '../../third_party/aom/aom_dsp/x86/inv_txfm_ssse3.c',
     '../../third_party/aom/aom_dsp/x86/inv_wht_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/loopfilter_avx2.c',
     '../../third_party/aom/aom_dsp/x86/loopfilter_sse2.c',
-    '../../third_party/aom/aom_dsp/x86/masked_sad_intrin_ssse3.c',
-    '../../third_party/aom/aom_dsp/x86/masked_variance_intrin_ssse3.c',
     '../../third_party/aom/aom_dsp/x86/obmc_sad_sse4.c',
     '../../third_party/aom/aom_dsp/x86/obmc_variance_sse4.c',
     '../../third_party/aom/aom_dsp/x86/quantize_sse2.c',
     '../../third_party/aom/aom_dsp/x86/sad4d_avx2.c',
     '../../third_party/aom/aom_dsp/x86/sad4d_sse2.asm',
     '../../third_party/aom/aom_dsp/x86/sad_avx2.c',
     '../../third_party/aom/aom_dsp/x86/sad_highbd_avx2.c',
     '../../third_party/aom/aom_dsp/x86/sad_sse2.asm',
@@ -346,19 +333,16 @@ files = {
     '../../third_party/aom/aom_ports/emms.asm',
     '../../third_party/aom/aom_ports/x86_abi_support.asm',
     '../../third_party/aom/aom_scale/aom_scale_rtcd.c',
     '../../third_party/aom/aom_scale/generic/aom_scale.c',
     '../../third_party/aom/aom_scale/generic/gen_scalers.c',
     '../../third_party/aom/aom_scale/generic/yv12config.c',
     '../../third_party/aom/aom_scale/generic/yv12extend.c',
     '../../third_party/aom/aom_util/aom_thread.c',
-    '../../third_party/aom/av1/../third_party/fastfeat/fast.c',
-    '../../third_party/aom/av1/../third_party/fastfeat/fast_9.c',
-    '../../third_party/aom/av1/../third_party/fastfeat/nonmax.c',
     '../../third_party/aom/av1/av1_cx_iface.c',
     '../../third_party/aom/av1/av1_dx_iface.c',
     '../../third_party/aom/av1/common/alloccommon.c',
     '../../third_party/aom/av1/common/av1_fwd_txfm1d.c',
     '../../third_party/aom/av1/common/av1_fwd_txfm2d.c',
     '../../third_party/aom/av1/common/av1_inv_txfm1d.c',
     '../../third_party/aom/av1/common/av1_inv_txfm2d.c',
     '../../third_party/aom/av1/common/av1_loopfilter.c',
@@ -388,83 +372,75 @@ files = {
     '../../third_party/aom/av1/common/reconinter.c',
     '../../third_party/aom/av1/common/reconintra.c',
     '../../third_party/aom/av1/common/resize.c',
     '../../third_party/aom/av1/common/scale.c',
     '../../third_party/aom/av1/common/scan.c',
     '../../third_party/aom/av1/common/seg_common.c',
     '../../third_party/aom/av1/common/thread_common.c',
     '../../third_party/aom/av1/common/tile_common.c',
-    '../../third_party/aom/av1/common/warped_motion.c',
     '../../third_party/aom/av1/common/x86/av1_convolve_ssse3.c',
     '../../third_party/aom/av1/common/x86/av1_fwd_txfm1d_sse4.c',
     '../../third_party/aom/av1/common/x86/av1_fwd_txfm2d_sse4.c',
     '../../third_party/aom/av1/common/x86/av1_highbd_convolve_sse4.c',
     '../../third_party/aom/av1/common/x86/highbd_inv_txfm_avx2.c',
     '../../third_party/aom/av1/common/x86/highbd_inv_txfm_sse4.c',
-    '../../third_party/aom/av1/common/x86/highbd_warp_plane_ssse3.c',
     '../../third_party/aom/av1/common/x86/hybrid_inv_txfm_avx2.c',
     '../../third_party/aom/av1/common/x86/idct_intrin_sse2.c',
-    '../../third_party/aom/av1/common/x86/warp_plane_sse2.c',
-    '../../third_party/aom/av1/common/x86/warp_plane_ssse3.c',
     '../../third_party/aom/av1/decoder/decodeframe.c',
     '../../third_party/aom/av1/decoder/decodemv.c',
     '../../third_party/aom/av1/decoder/decoder.c',
     '../../third_party/aom/av1/decoder/detokenize.c',
     '../../third_party/aom/av1/decoder/dsubexp.c',
     '../../third_party/aom/av1/decoder/dthread.c',
     '../../third_party/aom/av1/encoder/aq_complexity.c',
     '../../third_party/aom/av1/encoder/aq_cyclicrefresh.c',
     '../../third_party/aom/av1/encoder/aq_variance.c',
     '../../third_party/aom/av1/encoder/av1_quantize.c',
     '../../third_party/aom/av1/encoder/bitstream.c',
     '../../third_party/aom/av1/encoder/context_tree.c',
-    '../../third_party/aom/av1/encoder/corner_detect.c',
-    '../../third_party/aom/av1/encoder/corner_match.c',
     '../../third_party/aom/av1/encoder/cost.c',
     '../../third_party/aom/av1/encoder/dct.c',
     '../../third_party/aom/av1/encoder/encodeframe.c',
     '../../third_party/aom/av1/encoder/encodemb.c',
     '../../third_party/aom/av1/encoder/encodemv.c',
     '../../third_party/aom/av1/encoder/encoder.c',
     '../../third_party/aom/av1/encoder/ethread.c',
     '../../third_party/aom/av1/encoder/extend.c',
     '../../third_party/aom/av1/encoder/firstpass.c',
-    '../../third_party/aom/av1/encoder/global_motion.c',
     '../../third_party/aom/av1/encoder/hybrid_fwd_txfm.c',
     '../../third_party/aom/av1/encoder/lookahead.c',
     '../../third_party/aom/av1/encoder/mbgraph.c',
     '../../third_party/aom/av1/encoder/mcomp.c',
     '../../third_party/aom/av1/encoder/palette.c',
     '../../third_party/aom/av1/encoder/pickcdef.c',
     '../../third_party/aom/av1/encoder/picklpf.c',
-    '../../third_party/aom/av1/encoder/ransac.c',
     '../../third_party/aom/av1/encoder/ratectrl.c',
+    '../../third_party/aom/av1/encoder/ratectrl_xiph.c',
     '../../third_party/aom/av1/encoder/rd.c',
     '../../third_party/aom/av1/encoder/rdopt.c',
     '../../third_party/aom/av1/encoder/segmentation.c',
     '../../third_party/aom/av1/encoder/speed_features.c',
     '../../third_party/aom/av1/encoder/subexp.c',
     '../../third_party/aom/av1/encoder/temporal_filter.c',
     '../../third_party/aom/av1/encoder/tokenize.c',
     '../../third_party/aom/av1/encoder/treewriter.c',
-    '../../third_party/aom/av1/encoder/wedge_utils.c',
+    '../../third_party/aom/av1/encoder/x86/av1_highbd_quantize_avx2.c',
     '../../third_party/aom/av1/encoder/x86/av1_highbd_quantize_sse4.c',
+    '../../third_party/aom/av1/encoder/x86/av1_quantize_avx2.c',
     '../../third_party/aom/av1/encoder/x86/av1_quantize_sse2.c',
-    '../../third_party/aom/av1/encoder/x86/corner_match_sse4.c',
     '../../third_party/aom/av1/encoder/x86/dct_intrin_sse2.c',
     '../../third_party/aom/av1/encoder/x86/dct_sse2.asm',
     '../../third_party/aom/av1/encoder/x86/dct_ssse3.c',
     '../../third_party/aom/av1/encoder/x86/error_intrin_avx2.c',
     '../../third_party/aom/av1/encoder/x86/error_sse2.asm',
     '../../third_party/aom/av1/encoder/x86/highbd_block_error_intrin_sse2.c',
     '../../third_party/aom/av1/encoder/x86/highbd_fwd_txfm_sse4.c',
     '../../third_party/aom/av1/encoder/x86/hybrid_fwd_txfm_avx2.c',
     '../../third_party/aom/av1/encoder/x86/temporal_filter_apply_sse2.asm',
-    '../../third_party/aom/av1/encoder/x86/wedge_utils_sse2.c',
 ],
   'ARM_EXPORTS': [
     '../../third_party/aom/aom/aom.h',
     '../../third_party/aom/aom/aom_codec.h',
     '../../third_party/aom/aom/aom_decoder.h',
     '../../third_party/aom/aom/aom_encoder.h',
     '../../third_party/aom/aom/aom_frame_buffer.h',
     '../../third_party/aom/aom/aom_image.h',
@@ -545,19 +521,16 @@ files = {
     '../../third_party/aom/aom_mem/aom_mem.c',
     '../../third_party/aom/aom_ports/arm_cpudetect.c',
     '../../third_party/aom/aom_scale/aom_scale_rtcd.c',
     '../../third_party/aom/aom_scale/generic/aom_scale.c',
     '../../third_party/aom/aom_scale/generic/gen_scalers.c',
     '../../third_party/aom/aom_scale/generic/yv12config.c',
     '../../third_party/aom/aom_scale/generic/yv12extend.c',
     '../../third_party/aom/aom_util/aom_thread.c',
-    '../../third_party/aom/av1/../third_party/fastfeat/fast.c',
-    '../../third_party/aom/av1/../third_party/fastfeat/fast_9.c',
-    '../../third_party/aom/av1/../third_party/fastfeat/nonmax.c',
     '../../third_party/aom/av1/av1_cx_iface.c',
     '../../third_party/aom/av1/av1_dx_iface.c',
     '../../third_party/aom/av1/common/alloccommon.c',
     '../../third_party/aom/av1/common/av1_fwd_txfm1d.c',
     '../../third_party/aom/av1/common/av1_fwd_txfm2d.c',
     '../../third_party/aom/av1/common/av1_inv_txfm1d.c',
     '../../third_party/aom/av1/common/av1_inv_txfm2d.c',
     '../../third_party/aom/av1/common/av1_loopfilter.c',
@@ -583,60 +556,55 @@ files = {
     '../../third_party/aom/av1/common/reconinter.c',
     '../../third_party/aom/av1/common/reconintra.c',
     '../../third_party/aom/av1/common/resize.c',
     '../../third_party/aom/av1/common/scale.c',
     '../../third_party/aom/av1/common/scan.c',
     '../../third_party/aom/av1/common/seg_common.c',
     '../../third_party/aom/av1/common/thread_common.c',
     '../../third_party/aom/av1/common/tile_common.c',
-    '../../third_party/aom/av1/common/warped_motion.c',
     '../../third_party/aom/av1/decoder/decodeframe.c',
     '../../third_party/aom/av1/decoder/decodemv.c',
     '../../third_party/aom/av1/decoder/decoder.c',
     '../../third_party/aom/av1/decoder/detokenize.c',
     '../../third_party/aom/av1/decoder/dsubexp.c',
     '../../third_party/aom/av1/decoder/dthread.c',
     '../../third_party/aom/av1/encoder/aq_complexity.c',
     '../../third_party/aom/av1/encoder/aq_cyclicrefresh.c',
     '../../third_party/aom/av1/encoder/aq_variance.c',
     '../../third_party/aom/av1/encoder/arm/neon/quantize_neon.c',
     '../../third_party/aom/av1/encoder/av1_quantize.c',
     '../../third_party/aom/av1/encoder/bitstream.c',
     '../../third_party/aom/av1/encoder/context_tree.c',
-    '../../third_party/aom/av1/encoder/corner_detect.c',
-    '../../third_party/aom/av1/encoder/corner_match.c',
     '../../third_party/aom/av1/encoder/cost.c',
     '../../third_party/aom/av1/encoder/dct.c',
     '../../third_party/aom/av1/encoder/encodeframe.c',
     '../../third_party/aom/av1/encoder/encodemb.c',
     '../../third_party/aom/av1/encoder/encodemv.c',
     '../../third_party/aom/av1/encoder/encoder.c',
     '../../third_party/aom/av1/encoder/ethread.c',
     '../../third_party/aom/av1/encoder/extend.c',
     '../../third_party/aom/av1/encoder/firstpass.c',
-    '../../third_party/aom/av1/encoder/global_motion.c',
     '../../third_party/aom/av1/encoder/hybrid_fwd_txfm.c',
     '../../third_party/aom/av1/encoder/lookahead.c',
     '../../third_party/aom/av1/encoder/mbgraph.c',
     '../../third_party/aom/av1/encoder/mcomp.c',
     '../../third_party/aom/av1/encoder/palette.c',
     '../../third_party/aom/av1/encoder/pickcdef.c',
     '../../third_party/aom/av1/encoder/picklpf.c',
-    '../../third_party/aom/av1/encoder/ransac.c',
     '../../third_party/aom/av1/encoder/ratectrl.c',
+    '../../third_party/aom/av1/encoder/ratectrl_xiph.c',
     '../../third_party/aom/av1/encoder/rd.c',
     '../../third_party/aom/av1/encoder/rdopt.c',
     '../../third_party/aom/av1/encoder/segmentation.c',
     '../../third_party/aom/av1/encoder/speed_features.c',
     '../../third_party/aom/av1/encoder/subexp.c',
     '../../third_party/aom/av1/encoder/temporal_filter.c',
     '../../third_party/aom/av1/encoder/tokenize.c',
     '../../third_party/aom/av1/encoder/treewriter.c',
-    '../../third_party/aom/av1/encoder/wedge_utils.c',
 ],
   'GENERIC_EXPORTS': [
     '../../third_party/aom/aom/aom.h',
     '../../third_party/aom/aom/aom_codec.h',
     '../../third_party/aom/aom/aom_decoder.h',
     '../../third_party/aom/aom/aom_encoder.h',
     '../../third_party/aom/aom/aom_frame_buffer.h',
     '../../third_party/aom/aom/aom_image.h',
@@ -685,19 +653,16 @@ files = {
     '../../third_party/aom/aom_dsp/variance.c',
     '../../third_party/aom/aom_mem/aom_mem.c',
     '../../third_party/aom/aom_scale/aom_scale_rtcd.c',
     '../../third_party/aom/aom_scale/generic/aom_scale.c',
     '../../third_party/aom/aom_scale/generic/gen_scalers.c',
     '../../third_party/aom/aom_scale/generic/yv12config.c',
     '../../third_party/aom/aom_scale/generic/yv12extend.c',
     '../../third_party/aom/aom_util/aom_thread.c',
-    '../../third_party/aom/av1/../third_party/fastfeat/fast.c',
-    '../../third_party/aom/av1/../third_party/fastfeat/fast_9.c',
-    '../../third_party/aom/av1/../third_party/fastfeat/nonmax.c',
     '../../third_party/aom/av1/av1_cx_iface.c',
     '../../third_party/aom/av1/av1_dx_iface.c',
     '../../third_party/aom/av1/common/alloccommon.c',
     '../../third_party/aom/av1/common/av1_fwd_txfm1d.c',
     '../../third_party/aom/av1/common/av1_fwd_txfm2d.c',
     '../../third_party/aom/av1/common/av1_inv_txfm1d.c',
     '../../third_party/aom/av1/common/av1_inv_txfm2d.c',
     '../../third_party/aom/av1/common/av1_loopfilter.c',
@@ -721,53 +686,48 @@ files = {
     '../../third_party/aom/av1/common/reconinter.c',
     '../../third_party/aom/av1/common/reconintra.c',
     '../../third_party/aom/av1/common/resize.c',
     '../../third_party/aom/av1/common/scale.c',
     '../../third_party/aom/av1/common/scan.c',
     '../../third_party/aom/av1/common/seg_common.c',
     '../../third_party/aom/av1/common/thread_common.c',
     '../../third_party/aom/av1/common/tile_common.c',
-    '../../third_party/aom/av1/common/warped_motion.c',
     '../../third_party/aom/av1/decoder/decodeframe.c',
     '../../third_party/aom/av1/decoder/decodemv.c',
     '../../third_party/aom/av1/decoder/decoder.c',
     '../../third_party/aom/av1/decoder/detokenize.c',
     '../../third_party/aom/av1/decoder/dsubexp.c',
     '../../third_party/aom/av1/decoder/dthread.c',
     '../../third_party/aom/av1/encoder/aq_complexity.c',
     '../../third_party/aom/av1/encoder/aq_cyclicrefresh.c',
     '../../third_party/aom/av1/encoder/aq_variance.c',
     '../../third_party/aom/av1/encoder/av1_quantize.c',
     '../../third_party/aom/av1/encoder/bitstream.c',
     '../../third_party/aom/av1/encoder/context_tree.c',
-    '../../third_party/aom/av1/encoder/corner_detect.c',
-    '../../third_party/aom/av1/encoder/corner_match.c',
     '../../third_party/aom/av1/encoder/cost.c',
     '../../third_party/aom/av1/encoder/dct.c',
     '../../third_party/aom/av1/encoder/encodeframe.c',
     '../../third_party/aom/av1/encoder/encodemb.c',
     '../../third_party/aom/av1/encoder/encodemv.c',
     '../../third_party/aom/av1/encoder/encoder.c',
     '../../third_party/aom/av1/encoder/ethread.c',
     '../../third_party/aom/av1/encoder/extend.c',
     '../../third_party/aom/av1/encoder/firstpass.c',
-    '../../third_party/aom/av1/encoder/global_motion.c',
     '../../third_party/aom/av1/encoder/hybrid_fwd_txfm.c',
     '../../third_party/aom/av1/encoder/lookahead.c',
     '../../third_party/aom/av1/encoder/mbgraph.c',
     '../../third_party/aom/av1/encoder/mcomp.c',
     '../../third_party/aom/av1/encoder/palette.c',
     '../../third_party/aom/av1/encoder/pickcdef.c',
     '../../third_party/aom/av1/encoder/picklpf.c',
-    '../../third_party/aom/av1/encoder/ransac.c',
     '../../third_party/aom/av1/encoder/ratectrl.c',
+    '../../third_party/aom/av1/encoder/ratectrl_xiph.c',
     '../../third_party/aom/av1/encoder/rd.c',
     '../../third_party/aom/av1/encoder/rdopt.c',
     '../../third_party/aom/av1/encoder/segmentation.c',
     '../../third_party/aom/av1/encoder/speed_features.c',
     '../../third_party/aom/av1/encoder/subexp.c',
     '../../third_party/aom/av1/encoder/temporal_filter.c',
     '../../third_party/aom/av1/encoder/tokenize.c',
     '../../third_party/aom/av1/encoder/treewriter.c',
-    '../../third_party/aom/av1/encoder/wedge_utils.c',
 ],
 }
--- a/third_party/aom/CMakeLists.txt
+++ b/third_party/aom/CMakeLists.txt
@@ -6,47 +6,53 @@
 ## was not distributed with this source code in the LICENSE file, you can
 ## obtain it at www.aomedia.org/license/software. If the Alliance for Open
 ## Media Patent License 1.0 was not distributed with this source code in the
 ## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 ##
 cmake_minimum_required(VERSION 3.5)
 
 if (NOT EMSCRIPTEN)
-  if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
-    set(CMAKE_BUILD_TYPE "RelWithDebInfo")
+  if (NOT CMAKE_BUILD_TYPE)
+    set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE
+      "Build type: Debug, Release, RelWithDebInfo or MinSizeRel" STRING FORCE)
   endif ()
 endif ()
 
 option(ENABLE_CCACHE "Enable ccache support." OFF)
 option(ENABLE_DISTCC "Enable distcc support." OFF)
 option(ENABLE_DOCS "Enable documentation generation (doxygen required)." ON)
 option(ENABLE_NASM "Use nasm instead of yasm for x86 assembly." OFF)
+option(ENABLE_IDE_TEST_HOSTING
+       "Enables running tests within IDEs like Visual Studio and Xcode." OFF)
+
+# $BUILD_SHARED_LIBS is a CMake built-in-- it's listed here for visibility.
+option(BUILD_SHARED_LIBS "CMake should generate a shared library build." OFF)
 
 project(AOM C CXX)
 
 set(AOM_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
 set(AOM_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
 
 if ("${AOM_ROOT}" STREQUAL "${AOM_CONFIG_DIR}")
   message(FATAL_ERROR
           "Building from within the aom source tree is not supported.\n"
           "Hint: mkdir -p ../aom_build && cd ../aom_build\n"
           "Run cmake from there.")
 endif ()
 
 include("${AOM_ROOT}/build/cmake/aom_configure.cmake")
-include("${AOM_ROOT}/build/cmake/aom_optimization.cmake")
 include("${AOM_ROOT}/aom_dsp/aom_dsp.cmake")
 include("${AOM_ROOT}/aom_mem/aom_mem.cmake")
 include("${AOM_ROOT}/aom_ports/aom_ports.cmake")
 include("${AOM_ROOT}/aom_scale/aom_scale.cmake")
 include("${AOM_ROOT}/aom_util/aom_util.cmake")
 include("${AOM_ROOT}/av1/av1.cmake")
 include("${AOM_ROOT}/test/test.cmake")
+include("${AOM_ROOT}/build/cmake/util.cmake")
 
 set(AOM_RTCD_SOURCES
     "${AOM_CONFIG_DIR}/aom_dsp_rtcd.h"
     "${AOM_CONFIG_DIR}/aom_scale_rtcd.h"
     "${AOM_CONFIG_DIR}/av1_rtcd.h"
     "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd_defs.pl"
     "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd.c"
     "${AOM_ROOT}/aom_scale/aom_scale_rtcd.pl"
@@ -207,27 +213,28 @@ endforeach ()
 # Application and application support targets.
 #
 add_library(aom_common_app_util OBJECT ${AOM_COMMON_APP_UTIL_SOURCES})
 
 
 if (CONFIG_AV1_DECODER)
   add_library(aom_decoder_app_util OBJECT ${AOM_DECODER_APP_UTIL_SOURCES})
   add_executable(aomdec
-               "${AOM_ROOT}/aomdec.c"
-               $<TARGET_OBJECTS:aom_common_app_util>
-               $<TARGET_OBJECTS:aom_decoder_app_util>)
+                 "${AOM_ROOT}/aomdec.c"
+                 $<TARGET_OBJECTS:aom_common_app_util>
+                 $<TARGET_OBJECTS:aom_decoder_app_util>)
 
   if (CONFIG_ANALYZER)
     add_executable(analyzer
                    "${AOM_ROOT}/examples/analyzer.cc"
                    $<TARGET_OBJECTS:aom_common_app_util>
                    $<TARGET_OBJECTS:aom_decoder_app_util>)
     target_link_libraries(analyzer ${AOM_LIB_LINK_TYPE} ${wxWidgets_LIBRARIES})
     set(AOM_APP_TARGETS ${AOM_APP_TARGETS} analyzer)
+    set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS} analyzer)
   endif ()
 
   add_executable(decode_to_md5
                  "${AOM_ROOT}/examples/decode_to_md5.c"
                  $<TARGET_OBJECTS:aom_common_app_util>
                  $<TARGET_OBJECTS:aom_decoder_app_util>)
   add_executable(decode_with_drops
                  "${AOM_ROOT}/examples/decode_with_drops.c"
@@ -242,24 +249,27 @@ if (CONFIG_AV1_DECODER)
     add_executable(inspect
                    "${AOM_ROOT}/examples/inspect.c"
                    $<TARGET_OBJECTS:aom_common_app_util>
                    $<TARGET_OBJECTS:aom_decoder_app_util>)
     set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS} inspect)
 
     if (EMSCRIPTEN)
       add_preproc_definition(_POSIX_SOURCE)
-      add_compiler_flag_if_supported("-s TOTAL_MEMORY=134217728")
-      add_compiler_flag_if_supported("-s MODULARIZE=1")
-      add_compiler_flag_if_supported("-s EXPORT_NAME=\"\'DecoderModule\'\"")
-      add_compiler_flag_if_supported("--memory-init-file 0")
+      append_link_flag_to_target("inspect" "-s TOTAL_MEMORY=134217728")
+      append_link_flag_to_target("inspect" "-s MODULARIZE=1")
+      append_link_flag_to_target("inspect"
+                                 "-s EXPORT_NAME=\"\'DecoderModule\'\"")
+      append_link_flag_to_target("inspect" "--memory-init-file 0")
+
       if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
         # Default to -O3 when no build type specified.
-        add_compiler_flag_if_supported("-O3")
+        append_compiler_flag("-O3")
       endif ()
+
       em_link_post_js(inspect "${AOM_ROOT}/tools/inspect-post.js")
     endif ()
   endif ()
 
   # Maintain lists of example and app targets.
   set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS}
       decode_to_md5 decode_with_drops simple_decoder)
   set(AOM_APP_TARGETS ${AOM_APP_TARGETS} aomdec ${AOM_DECODER_EXAMPLE_TARGETS})
@@ -319,40 +329,40 @@ if (CONFIG_LIBYUV)
   add_library(yuv OBJECT ${AOM_LIBYUV_SOURCES})
   if (NOT MSVC)
     target_compile_options(yuv PRIVATE -Wno-unused-parameter)
   endif ()
   include_directories("${AOM_ROOT}/third_party/libyuv/include")
 
   # Add to existing targets.
   foreach (aom_app ${AOM_APP_TARGETS})
-    target_sources(${aom_app} PUBLIC $<TARGET_OBJECTS:yuv>)
+    target_sources(${aom_app} PRIVATE $<TARGET_OBJECTS:yuv>)
     set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX)
   endforeach ()
 endif ()
 
 if (CONFIG_WEBM_IO)
   add_library(webm OBJECT ${AOM_LIBWEBM_SOURCES})
   include_directories("${AOM_ROOT}/third_party/libwebm")
 
   if (NOT MSVC)
     target_compile_options(webm PRIVATE -Wno-shadow)
   endif ()
 
   # Add to existing targets.
   if (CONFIG_AV1_DECODER)
-    target_sources(aom_decoder_app_util PUBLIC ${AOM_WEBM_DECODER_SOURCES})
+    target_sources(aom_decoder_app_util PRIVATE ${AOM_WEBM_DECODER_SOURCES})
   endif ()
 
   if (CONFIG_AV1_ENCODER)
-    target_sources(aom_encoder_app_util PUBLIC ${AOM_WEBM_ENCODER_SOURCES})
+    target_sources(aom_encoder_app_util PRIVATE ${AOM_WEBM_ENCODER_SOURCES})
   endif ()
 
   foreach (aom_app ${AOM_APP_TARGETS})
-    target_sources(${aom_app} PUBLIC $<TARGET_OBJECTS:webm>)
+    target_sources(${aom_app} PRIVATE $<TARGET_OBJECTS:webm>)
     set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX)
    endforeach ()
 endif ()
 
 if (CONFIG_UNIT_TESTS)
   # Create test_libaom target and the targets it depends on.
   setup_aom_test_targets()
 endif ()
@@ -369,33 +379,35 @@ if (XCODE)
     # The Xcode generator does not obey LINKER_LANGUAGE. Because of the issue
     # what looks like a C++ file needs to be in any target that Xcode will link
     # when the target contains a C++ dependency.
     # Without this Xcode will try to link with the C linker, which always ends
     # badly when a dependency actually includes C++.
     # Note: LINKER_LANGUAGE is explicitly set to C++ for all targets touched
     # here, it really is the Xcode generator's fault, or just a deficiency in
     # Xcode itself.
-    set(XCODE_DUMMY_CXX_FILE "${AOM_CONFIG_DIR}/dummy.cc")
-    file(WRITE "${XCODE_DUMMY_CXX_FILE}"
-         "// Xcode needs a C++ file to link, ignore this file.")
     foreach (aom_app ${AOM_APP_TARGETS})
-      target_sources(${aom_app} PUBLIC "${XCODE_DUMMY_CXX_FILE}")
+      add_dummy_source_file_to_target("${aom_app}" "cc")
     endforeach ()
   endif ()
 endif ()
 
 if ("${CMAKE_GENERATOR}" MATCHES "Makefiles$" )
   # Users of the configure build expect the example targets to be built in the
   # examples sub directory of the configured build directory after running make.
   file(MAKE_DIRECTORY "${AOM_CONFIG_DIR}/examples")
   set_target_properties(${AOM_EXAMPLE_TARGETS} PROPERTIES
                         RUNTIME_OUTPUT_DIRECTORY "${AOM_CONFIG_DIR}/examples")
 endif ()
 
+if (BUILD_SHARED_LIBS)
+  include("${AOM_ROOT}/build/cmake/exports.cmake")
+  setup_exports_target()
+endif ()
+
 # Aomedia documentation rule.
 if (ENABLE_DOCS)
   include(FindDoxygen)
   if (DOXYGEN_FOUND)
     include("${AOM_ROOT}/docs.cmake")
     setup_documentation_targets()
   else ()
     message("--- Cannot find doxygen, ENABLE_DOCS turned off.")
--- a/third_party/aom/README
+++ b/third_party/aom/README
@@ -1,10 +1,14 @@
 README - 9 March 2017
 
+***************************
+DEPRECATED -- SEE README.md
+***************************
+
 Welcome to the AV1 Codec SDK!
 
 COMPILING THE APPLICATIONS/LIBRARIES:
   The build system used is similar to autotools. Building generally consists of
   "configuring" with your desired build options, then using GNU make to build
   the application.
 
   1. Prerequisites
@@ -50,16 +54,17 @@ COMPILING THE APPLICATIONS/LIBRARIES:
     arm64-darwin-gcc
     armv7-android-gcc
     armv7-darwin-gcc
     armv7-linux-rvct
     armv7-linux-gcc
     armv7-none-rvct
     armv7-win32-vs12
     armv7-win32-vs14
+    armv7-win32-vs15
     armv7s-darwin-gcc
     mips32-linux-gcc
     mips64-linux-gcc
     sparc-solaris-gcc
     x86-android-gcc
     x86-darwin8-gcc
     x86-darwin8-icc
     x86-darwin9-gcc
@@ -74,32 +79,34 @@ COMPILING THE APPLICATIONS/LIBRARIES:
     x86-iphonesimulator-gcc
     x86-linux-gcc
     x86-linux-icc
     x86-os2-gcc
     x86-solaris-gcc
     x86-win32-gcc
     x86-win32-vs12
     x86-win32-vs14
+    x86-win32-vs15
     x86_64-android-gcc
     x86_64-darwin9-gcc
     x86_64-darwin10-gcc
     x86_64-darwin11-gcc
     x86_64-darwin12-gcc
     x86_64-darwin13-gcc
     x86_64-darwin14-gcc
     x86_64-darwin15-gcc
     x86_64-darwin16-gcc
     x86_64-iphonesimulator-gcc
     x86_64-linux-gcc
     x86_64-linux-icc
     x86_64-solaris-gcc
     x86_64-win64-gcc
     x86_64-win64-vs12
     x86_64-win64-vs14
+    x86_64-win64-vs15
     generic-gnu
 
   The generic-gnu target, in conjunction with the CROSS environment variable,
   can be used to cross compile architectures that aren't explicitly listed, if
   the toolchain is a cross GNU (gcc/binutils) toolchain. Other POSIX toolchains
   will likely work as well. For instance, to build using the mipsel-linux-uclibc
   toolchain, the following command could be used (note, POSIX SH syntax, adapt
   to your shell as necessary):
new file mode 100644
--- /dev/null
+++ b/third_party/aom/README.md
@@ -0,0 +1,246 @@
+# AV1 Codec Library
+
+## Building the library and applications
+
+### Prerequisites
+
+ 1. [CMake](https://cmake.org) version 3.5 or higher.
+ 2. [Git](https://git-scm.com/).
+ 3. [Perl](https://www.perl.org/).
+ 4. For x86 targets, [yasm](http://yasm.tortall.net/), which is preferred, or a
+    recent version of [nasm](http://www.nasm.us/).
+ 5. Building the documentation requires [doxygen](http://doxygen.org).
+ 6. Building the unit tests requires [Python](https://www.python.org/).
+ 7. Emscripten builds require the portable
+   [EMSDK](https://kripken.github.io/emscripten-site/index.html).
+
+### Basic build
+
+CMake replaces the configure step typical of many projects. Running CMake will
+produce configuration and build files for the currently selected CMake
+generator. For most systems the default generator is Unix Makefiles. The basic
+form of a makefile build is the following:
+
+    $ cmake path/to/aom
+    $ make
+
+The above will generate a makefile build that produces the AV1 library and
+applications for the current host system after the make step completes
+successfully. The compiler chosen varies by host platform, but a general rule
+applies: On systems where cc and c++ are present in $PATH at the time CMake is
+run the generated build will use cc and c++ by default.
+
+### Configuration options
+
+The AV1 codec library has a great many configuration options. These come in two
+varieties:
+
+ 1. Build system configuration options. These have the form `ENABLE_FEATURE`.
+ 2. AV1 codec configuration options. These have the form `CONFIG_FEATURE`.
+
+Both types of options are set at the time CMake is run. The following example
+enables ccache and disables high bit depth:
+
+    $ cmake path/to/aom -DENABLE_CCACHE=1 -DCONFIG_HIGHBITDEPTH=0
+    $ make
+
+The available configuration options are too numerous to list here. Build system
+configuration options can be found at the top of the CMakeLists.txt file found
+in the root of the AV1 repository, and AV1 codec configuration options can
+currently be found in the file `build/cmake/aom_config_defaults.cmake`.
+
+### Dylib builds
+
+A dylib (shared object) build of the AV1 codec library can be enabled via the
+CMake built in variable BUILD\_SHARED\_LIBS:
+
+    $ cmake path/to/aom -D BUILD_SHARED_LIBS=1
+    $ make
+
+This is currently only supported on non-Windows targets.
+
+### Cross compiling
+
+For the purposes of building the AV1 codec and applications and relative to the
+scope of this guide, all builds for architectures differing from the native host
+architecture will be considered cross compiles. The AV1 CMake build handles
+cross compiling via the use of toolchain files included in the AV1 repository.
+The toolchain files available at the time of this writing are:
+
+ - arm64-ios.cmake
+ - arm64-linux-gcc.cmake
+ - armv7-ios.cmake
+ - armv7-linux-gcc.cmake
+ - armv7s-ios.cmake
+ - mips32-linux-gcc.cmake
+ - mips64-linux-gcc.cmake
+ - x86-ios-simulator.cmake
+ - x86-linux.cmake
+ - x86-macos.cmake
+ - x86\_64-ios-simulator.cmake
+
+The following example demonstrates use of the x86-macos.cmake toolchain file on
+a x86\_64 MacOS host:
+
+    $ cmake path/to/aom \
+      -DCMAKE_TOOLCHAIN_FILE=path/to/aom/build/cmake/toolchains/x86-macos.cmake
+    $ make
+
+To build for an unlisted target creation of a new toolchain file is the best
+solution. The existing toolchain files can be used a starting point for a new
+toolchain file since each one exposes the basic requirements for toolchain files
+as used in the AV1 codec build.
+
+As a temporary work around an unoptimized AV1 configuration that builds only C
+and C++ sources can be produced using the following commands:
+
+    $ cmake path/to/aom -DAOM_TARGET_CPU=generic
+    $ make
+
+In addition to the above it's important to note that the toolchain files
+suffixed with gcc behave differently than the others. These toolchain files
+attempt to obey the $CROSS environment variable.
+
+### Microsoft Visual Studio builds
+
+Building the AV1 codec library in Microsoft Visual Studio is supported. The
+following example demonstrates generating projects and a solution for the
+Microsoft IDE:
+
+    # This does not require a bash shell; command.exe is fine.
+    $ cmake path/to/aom -G "Visual Studio 15 2017"
+
+### Xcode builds
+
+Building the AV1 codec library in Xcode is supported. The following example
+demonstrates generating an Xcode project:
+
+    $ cmake path/to/aom -G Xcode
+
+### Emscripten builds
+
+Building the AV1 codec library with Emscripten is supported. Typically this is
+used to hook into the AOMAnalyzer GUI application. These instructions focus on
+using the inspector with AOMAnalyzer, but all tools can be built with
+Emscripten.
+
+It is assumed here that you have already downloaded and installed the EMSDK,
+installed and activated at least one toolchain, and setup your environment
+appropriately using the emsdk\_env script.
+
+1. Download [AOMAnalyzer](https://people.xiph.org/~mbebenita/analyzer/).
+
+2. Configure the build:
+
+~~~
+    $ cmake path/to/aom \
+        -DENABLE_CCACHE=1 \
+        -DAOM_TARGET_CPU=generic \
+        -DENABLE_DOCS=0 \
+        -DCONFIG_ACCOUNTING=1 \
+        -DCONFIG_INSPECTION=1 \
+        -DCONFIG_MULTITHREAD=0 \
+        -DCONFIG_RUNTIME_CPU_DETECT=0 \
+        -DCONFIG_UNIT_TESTS=0 \
+        -DCONFIG_WEBM_IO=0 \
+        -DCMAKE_TOOLCHAIN_FILE=path/to/emsdk-portable/.../Emscripten.cmake
+~~~
+
+3. Build it: run make if that's your generator of choice:
+
+~~~
+    $ make inspect
+~~~
+
+4. Run the analyzer:
+
+~~~
+    # inspect.js is in the examples sub directory of the directory in which you
+    # executed cmake.
+    $ path/to/AOMAnalyzer path/to/examples/inspect.js path/to/av1/input/file
+~~~
+
+
+## Testing the AV1 codec
+
+### Testing basics
+
+Currently there are two types of tests in the AV1 codec repository:
+
+ 1. Unit tests.
+ 2. Example tests.
+
+The unit tests can be run at build time:
+
+    # Before running the make command the LIBAOM_TEST_DATA_PATH environment
+    # variable should be set to avoid downloading the test files to the
+    # cmake build configuration directory.
+    $ cmake path/to/aom
+    # Note: The AV1 CMake build creates many test targets. Running make
+    # with multiple jobs will speed up the test run significantly.
+    $ make runtests
+
+The example tests require a bash shell and can be run in the following manner:
+
+    # See the note above about LIBAOM_TEST_DATA_PATH above.
+    $ cmake path/to/aom
+    $ make
+    # It's best to build the testdata target using many make jobs.
+    # Running it like this will verify and download (if necessary)
+    # one at a time, which takes a while.
+    $ make testdata
+    $ path/to/aom/test/examples.sh --bin-path examples
+
+### IDE hosted tests
+
+By default the generated projects files created by CMake will not include the
+runtests and testdata rules when generating for IDEs like Microsoft Visual
+Studio and Xcode. This is done to avoid intolerably long build cycles in the
+IDEs-- IDE behavior is to build all targets when selecting the build project
+options in MSVS and Xcode. To enable the test rules in IDEs the
+`ENABLE_IDE_TEST_HOSTING` variable must be enabled at CMake generation time:
+
+    # This example uses Xcode. To get a list of the generators
+    # available, run cmake with the -G argument missing its
+    # value.
+    $ cmake path/to/aom -DENABLE_IDE_TEST_HOSTING=1 -G Xcode
+
+### Downloading the test data
+
+The fastest and easiest way to obtain the test data is to use CMake to generate
+a build using the Unix Makefiles generator, and then to build only the testdata
+rule:
+
+    $ cmake path/to/aom -G "Unix Makefiles"
+    # 28 is used because there are 28 test files as of this writing.
+    $ make -j28 testdata
+
+The above make command will only download and verify the test data.
+
+
+## Coding style
+
+The coding style used by this project is enforced with clang-format using the
+configuration contained in the .clang-format file in the root of the repository.
+
+Before pushing changes for review you can format your code with:
+
+    # Apply clang-format to modified .c, .h and .cc files
+    $ clang-format -i --style=file \
+      $(git diff --name-only --diff-filter=ACMR '*.[hc]' '*.cc')
+
+Check the .clang-format file for the version used to generate it if there is any
+difference between your local formatting and the review system.
+
+See also: http://clang.llvm.org/docs/ClangFormat.html
+
+## Support
+
+This library is an open source project supported by its community. Please
+please email aomediacodec@jointdevelopment.kavi.com for help.
+
+## Bug reports
+
+Bug reports can be filed in the Alliance for Open Media
+[issue tracker](https://bugs.chromium.org/p/aomedia/issues/list).
+
--- a/third_party/aom/aom/aom_decoder.h
+++ b/third_party/aom/aom/aom_decoder.h
@@ -102,17 +102,18 @@ typedef struct aom_codec_stream_info {
  *
  * This structure is used to pass init time configuration options to the
  * decoder.
  */
 typedef struct aom_codec_dec_cfg {
   unsigned int threads; /**< Maximum number of threads to use, default 1 */
   unsigned int w;       /**< Width */
   unsigned int h;       /**< Height */
-} aom_codec_dec_cfg_t;  /**< alias for struct aom_codec_dec_cfg */
+  unsigned int allow_lowbitdepth; /**< Allow use of low-bitdepth coding path */
+} aom_codec_dec_cfg_t;            /**< alias for struct aom_codec_dec_cfg */
 
 /*!\brief Initialize a decoder instance
  *
  * Initializes a decoder context using the given interface. Applications
  * should call the aom_codec_dec_init convenience macro instead of this
  * function directly, to ensure that the ABI version number parameter
  * is properly initialized.
  *
--- a/third_party/aom/aom/aom_encoder.h
+++ b/third_party/aom/aom/aom_encoder.h
@@ -358,54 +358,73 @@ typedef struct aom_codec_enc_cfg {
    *
    * This threshold is described as a percentage of the target data buffer.
    * When the data buffer falls below this percentage of fullness, a
    * dropped frame is indicated. Set the threshold to zero (0) to disable
    * this feature.
    */
   unsigned int rc_dropframe_thresh;
 
-  /*!\brief Enable/disable spatial resampling, if supported by the codec.
+  /*!\brief Mode for spatial resampling, if supported by the codec.
    *
    * Spatial resampling allows the codec to compress a lower resolution
-   * version of the frame, which is then upscaled by the encoder to the
+   * version of the frame, which is then upscaled by the decoder to the
    * correct presentation resolution. This increases visual quality at
    * low data rates, at the expense of CPU time on the encoder/decoder.
    */
-  unsigned int rc_resize_allowed;
+  unsigned int rc_resize_mode;
 
-  /*!\brief Internal coded frame width.
+  /*!\brief Frame resize numerator.
    *
-   * If spatial resampling is enabled this specifies the width of the
-   * encoded frame.
+   * The numerator for resize to use, assuming 16 as the denominator.
+   *
+   * Valid numerators are  8 - 16 for now.
    */
-  unsigned int rc_scaled_width;
+  unsigned int rc_resize_numerator;
 
-  /*!\brief Internal coded frame height.
+  /*!\brief Keyframe resize numerator.
    *
-   * If spatial resampling is enabled this specifies the height of the
-   * encoded frame.
+   * The numerator for resize to use, assuming 16 as the denominator.
+   *
+   * Valid numerators are  8 - 16 for now.
    */
-  unsigned int rc_scaled_height;
+  unsigned int rc_resize_kf_numerator;
 
-  /*!\brief Spatial resampling up watermark.
+  /*!\brief Frame super-resolution scaling mode.
    *
-   * This threshold is described as a percentage of the target data buffer.
-   * When the data buffer rises above this percentage of fullness, the
-   * encoder will step up to a higher resolution version of the frame.
+   * Similar to spatial resampling, frame super-resolution integrates
+   * upscaling after the encode/decode process. Taking control of upscaling and
+   * using restoration filters should allow it to outperform normal resizing.
+   *
+   * Mode 0 is SUPERRES_NONE, mode 1 is SUPERRES_FIXED, and mode 2 is
+   * SUPERRES_DYNAMIC.
    */
-  unsigned int rc_resize_up_thresh;
+  unsigned int rc_superres_mode;
 
-  /*!\brief Spatial resampling down watermark.
+  /*!\brief Frame super-resolution numerator.
+   *
+   * The numerator for superres to use. If fixed it will only change if the
+   * cumulative scale change over resizing and superres is greater than 1/2;
+   * this forces superres to reduce scaling.
+   *
+   * Valid numerators are 8 to 16.
    *
-   * This threshold is described as a percentage of the target data buffer.
-   * When the data buffer falls below this percentage of fullness, the
-   * encoder will step down to a lower resolution version of the frame.
+   * Ignored by SUPERRES_DYNAMIC.
    */
-  unsigned int rc_resize_down_thresh;
+  unsigned int rc_superres_numerator;
+
+  /*!\brief Keyframe super-resolution numerator.
+   *
+   * The numerator for superres to use. If fixed it will only change if the
+   * cumulative scale change over resizing and superres is greater than 1/2;
+   * this forces superres to reduce scaling.
+   *
+   * Valid numerators are 8 - 16 for now.
+   */
+  unsigned int rc_superres_kf_numerator;
 
   /*!\brief Rate control algorithm to use.
    *
    * Indicates whether the end usage of this stream is to be streamed over
    * a bandwidth constrained link, indicating that Constant Bit Rate (CBR)
    * mode should be used, or whether it will be played back on a high
    * bandwidth link, as from a local disk, where higher variations in
    * bitrate are acceptable.
--- a/third_party/aom/aom/aom_image.h
+++ b/third_party/aom/aom/aom_image.h
@@ -30,16 +30,18 @@ extern "C" {
  */
 #define AOM_IMAGE_ABI_VERSION (4) /**<\hideinitializer*/
 
 #define AOM_IMG_FMT_PLANAR 0x100       /**< Image is a planar format. */
 #define AOM_IMG_FMT_UV_FLIP 0x200      /**< V plane precedes U in memory. */
 #define AOM_IMG_FMT_HAS_ALPHA 0x400    /**< Image has an alpha channel. */
 #define AOM_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
 
+#include "./aom_config.h"
+
 /*!\brief List of supported image formats */
 typedef enum aom_img_fmt {
   AOM_IMG_FMT_NONE,
   AOM_IMG_FMT_RGB24,     /**< 24 bit per pixel packed RGB */
   AOM_IMG_FMT_RGB32,     /**< 32 bit per pixel packed 0RGB */
   AOM_IMG_FMT_RGB565,    /**< 16 bit per pixel, 565 */
   AOM_IMG_FMT_RGB555,    /**< 16 bit per pixel, 555 */
   AOM_IMG_FMT_UYVY,      /**< UYVY packed YUV */
@@ -69,31 +71,63 @@ typedef enum aom_img_fmt {
 
 /*!\brief List of supported color spaces */
 typedef enum aom_color_space {
   AOM_CS_UNKNOWN = 0,   /**< Unknown */
   AOM_CS_BT_601 = 1,    /**< BT.601 */
   AOM_CS_BT_709 = 2,    /**< BT.709 */
   AOM_CS_SMPTE_170 = 3, /**< SMPTE.170 */
   AOM_CS_SMPTE_240 = 4, /**< SMPTE.240 */
-  AOM_CS_BT_2020 = 5,   /**< BT.2020 */
-  AOM_CS_RESERVED = 6,  /**< Reserved */
-  AOM_CS_SRGB = 7       /**< sRGB */
-} aom_color_space_t;    /**< alias for enum aom_color_space */
+#if CONFIG_COLORSPACE_HEADERS
+  AOM_CS_BT_2020_NCL = 5, /**< BT.2020 non-constant luminance (BT.2100) */
+  AOM_CS_BT_2020_CL = 6,  /**< BT.2020 constant luminance */
+  AOM_CS_SRGB = 7,        /**< sRGB */
+  AOM_CS_ICTCP = 8,       /**< ICtCp, ITU-R BT.2100 */
+  AOM_CS_RESERVED = 9     /**< Values 9..31 are reserved */
+#else
+  AOM_CS_BT_2020 = 5,  /**< BT.2020 */
+  AOM_CS_RESERVED = 6, /**< Reserved */
+  AOM_CS_SRGB = 7      /**< sRGB */
+#endif
+} aom_color_space_t; /**< alias for enum aom_color_space */
+
+#if CONFIG_COLORSPACE_HEADERS
+typedef enum aom_transfer_function {
+  AOM_TF_UNKNOWN = 0,      /**< Unknown */
+  AOM_TF_BT_709 = 1,       /**< BT.709 */
+  AOM_TF_PQ = 2,           /**< PQ TF BT.2100 / ST.2084 */
+  AOM_TF_HLG = 3,          /**< Hybrid Log-Gamma */
+  AOM_TF_RESERVED = 4      /**< Values 4..31 are reserved */
+} aom_transfer_function_t; /**< alias for enum aom_transfer_function */
+#endif
 
 /*!\brief List of supported color range */
 typedef enum aom_color_range {
   AOM_CR_STUDIO_RANGE = 0, /**< Y [16..235], UV [16..240] */
   AOM_CR_FULL_RANGE = 1    /**< YUV/RGB [0..255] */
 } aom_color_range_t;       /**< alias for enum aom_color_range */
 
+#if CONFIG_COLORSPACE_HEADERS
+typedef enum aom_chroma_sample_position {
+  AOM_CSP_UNKNOWN = 0,          /**< Unknown */
+  AOM_CSP_VERTICAL = 1,         /**< Horizontally co-located with luma(0, 0)*/
+                                /**< sample, between two vertical samples */
+  AOM_CSP_COLOCATED = 2,        /**< Co-located with luma(0, 0) sample */
+  AOM_CSP_RESERVED = 3          /**< Reserved value */
+} aom_chroma_sample_position_t; /**< alias for enum aom_transfer_function */
+#endif
+
 /**\brief Image Descriptor */
 typedef struct aom_image {
-  aom_img_fmt_t fmt;       /**< Image Format */
-  aom_color_space_t cs;    /**< Color Space */
+  aom_img_fmt_t fmt;    /**< Image Format */
+  aom_color_space_t cs; /**< Color Space */
+#if CONFIG_COLORSPACE_HEADERS
+  aom_transfer_function_t tf;       /**< transfer function */
+  aom_chroma_sample_position_t csp; /**< chroma sample position */
+#endif
   aom_color_range_t range; /**< Color Range */
 
   /* Image storage dimensions */
   unsigned int w;         /**< Stored image width */
   unsigned int h;         /**< Stored image height */
   unsigned int bit_depth; /**< Stored image bit-depth */
 
   /* Image display dimensions */
--- a/third_party/aom/aom/aomcx.h
+++ b/third_party/aom/aom/aomcx.h
@@ -322,28 +322,51 @@ enum aome_enc_control_id {
   /*!\brief Codec control function to set content type.
    * \note Valid parameter range:
    *              AOM_CONTENT_DEFAULT = Regular video content (Default)
    *              AOM_CONTENT_SCREEN  = Screen capture content
    */
   AV1E_SET_TUNE_CONTENT,
 
   /*!\brief Codec control function to set color space info.
-   * \note Valid ranges: 0..7, default is "UNKNOWN".
+   * \note Valid ranges: 0..9, default is "UNKNOWN".
    *                     0 = UNKNOWN,
    *                     1 = BT_601
    *                     2 = BT_709
    *                     3 = SMPTE_170
    *                     4 = SMPTE_240
-   *                     5 = BT_2020
-   *                     6 = RESERVED
+   *                     5 = BT_2020_NCL
+   *                     6 = BT_2020_CL
    *                     7 = SRGB
+   *                     8 = ICtCp
+   *                     9 = RESERVED
    */
   AV1E_SET_COLOR_SPACE,
 
+#if CONFIG_COLORSPACE_HEADERS
+  /*!\brief Codec control function to set transfer function info.
+   * \note Valid ranges: 0..4, default is "UNKNOWN".
+   *                     0 = UNKNOWN,
+   *                     1 = BT_709
+   *                     2 = PQ
+   *                     3 = HLG
+   *                     4 = RESERVED
+   */
+  AV1E_SET_TRANSFER_FUNCTION,
+
+  /*!\brief Codec control function to set chroma 4:2:0 sample position info.
+   * \note Valid ranges: 0..3, default is "UNKNOWN".
+   *                     0 = UNKNOWN,
+   *                     1 = VERTICAL
+   *                     2 = COLOCATED
+   *                     3 = RESERVED
+   */
+  AV1E_SET_CHROMA_SAMPLE_POSITION,
+#endif
+
   /*!\brief Codec control function to set minimum interval between GF/ARF frames
    *
    * By default the value is set as 4.
    */
   AV1E_SET_MIN_GF_INTERVAL,
 
   /*!\brief Codec control function to set minimum interval between GF/ARF frames
    *
@@ -699,16 +722,24 @@ AOM_CTRL_USE_TYPE(AV1E_SET_NOISE_SENSITI
 #define AOM_CTRL_AV1E_SET_NOISE_SENSITIVITY
 
 AOM_CTRL_USE_TYPE(AV1E_SET_TUNE_CONTENT, int) /* aom_tune_content */
 #define AOM_CTRL_AV1E_SET_TUNE_CONTENT
 
 AOM_CTRL_USE_TYPE(AV1E_SET_COLOR_SPACE, int)
 #define AOM_CTRL_AV1E_SET_COLOR_SPACE
 
+#if CONFIG_COLORSPACE_HEADERS
+AOM_CTRL_USE_TYPE(AV1E_SET_TRANSFER_FUNCTION, int)
+#define AOM_CTRL_AV1E_SET_TRANSFER_FUNCTION
+
+AOM_CTRL_USE_TYPE(AV1E_SET_CHROMA_SAMPLE_POSITION, int)
+#define AOM_CTRL_AV1E_SET_CHROMA_SAMPLE_POSITION
+#endif
+
 AOM_CTRL_USE_TYPE(AV1E_SET_MIN_GF_INTERVAL, unsigned int)
 #define AOM_CTRL_AV1E_SET_MIN_GF_INTERVAL
 
 AOM_CTRL_USE_TYPE(AV1E_SET_MAX_GF_INTERVAL, unsigned int)
 #define AOM_CTRL_AV1E_SET_MAX_GF_INTERVAL
 
 AOM_CTRL_USE_TYPE(AV1E_GET_ACTIVEMAP, aom_active_map_t *)
 #define AOM_CTRL_AV1E_GET_ACTIVEMAP
--- a/third_party/aom/aom_dsp/aom_convolve.c
+++ b/third_party/aom/aom_dsp/aom_convolve.c
@@ -36,16 +36,39 @@ static void convolve_horiz(const uint8_t
       dst[x] = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
       x_q4 += x_step_q4;
     }
     src += src_stride;
     dst += dst_stride;
   }
 }
 
+static void convolve_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                                   uint8_t *dst, ptrdiff_t dst_stride,
+                                   const InterpKernel *x_filters, int x0_qn,
+                                   int x_step_qn, int w, int h) {
+  int x, y;
+  src -= SUBPEL_TAPS / 2 - 1;
+  for (y = 0; y < h; ++y) {
+    int x_qn = x0_qn;
+    for (x = 0; x < w; ++x) {
+      const uint8_t *const src_x = &src[x_qn >> SCALE_SUBPEL_BITS];  // q8
+      const int x_filter_idx = (x_qn & SCALE_SUBPEL_MASK) >> SCALE_EXTRA_BITS;
+      assert(x_filter_idx < SUBPEL_SHIFTS);
+      const int16_t *const x_filter = x_filters[x_filter_idx];
+      int k, sum = 0;
+      for (k = 0; k < SUBPEL_TAPS; ++k) sum += src_x[k] * x_filter[k];
+      dst[x] = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
+      x_qn += x_step_qn;
+    }
+    src += src_stride;
+    dst += dst_stride;
+  }
+}
+
 static void convolve_avg_horiz(const uint8_t *src, ptrdiff_t src_stride,
                                uint8_t *dst, ptrdiff_t dst_stride,
                                const InterpKernel *x_filters, int x0_q4,
                                int x_step_q4, int w, int h) {
   int x, y;
   src -= SUBPEL_TAPS / 2 - 1;
   for (y = 0; y < h; ++y) {
     int x_q4 = x0_q4;
@@ -58,16 +81,40 @@ static void convolve_avg_horiz(const uin
           dst[x] + clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS)), 1);
       x_q4 += x_step_q4;
     }
     src += src_stride;
     dst += dst_stride;
   }
 }
 
+static void convolve_avg_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                                       uint8_t *dst, ptrdiff_t dst_stride,
+                                       const InterpKernel *x_filters, int x0_qn,
+                                       int x_step_qn, int w, int h) {
+  int x, y;
+  src -= SUBPEL_TAPS / 2 - 1;
+  for (y = 0; y < h; ++y) {
+    int x_qn = x0_qn;
+    for (x = 0; x < w; ++x) {
+      const uint8_t *const src_x = &src[x_qn >> SCALE_SUBPEL_BITS];
+      const int x_filter_idx = (x_qn & SCALE_SUBPEL_MASK) >> SCALE_EXTRA_BITS;
+      assert(x_filter_idx < SUBPEL_SHIFTS);
+      const int16_t *const x_filter = x_filters[x_filter_idx];
+      int k, sum = 0;
+      for (k = 0; k < SUBPEL_TAPS; ++k) sum += src_x[k] * x_filter[k];
+      dst[x] = ROUND_POWER_OF_TWO(
+          dst[x] + clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS)), 1);
+      x_qn += x_step_qn;
+    }
+    src += src_stride;
+    dst += dst_stride;
+  }
+}
+
 static void convolve_vert(const uint8_t *src, ptrdiff_t src_stride,
                           uint8_t *dst, ptrdiff_t dst_stride,
                           const InterpKernel *y_filters, int y0_q4,
                           int y_step_q4, int w, int h) {
   int x, y;
   src -= src_stride * (SUBPEL_TAPS / 2 - 1);
 
   for (x = 0; x < w; ++x) {
@@ -81,16 +128,41 @@ static void convolve_vert(const uint8_t 
       dst[y * dst_stride] = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
       y_q4 += y_step_q4;
     }
     ++src;
     ++dst;
   }
 }
 
+static void convolve_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                                  uint8_t *dst, ptrdiff_t dst_stride,
+                                  const InterpKernel *y_filters, int y0_qn,
+                                  int y_step_qn, int w, int h) {
+  int x, y;
+  src -= src_stride * (SUBPEL_TAPS / 2 - 1);
+
+  for (x = 0; x < w; ++x) {
+    int y_qn = y0_qn;
+    for (y = 0; y < h; ++y) {
+      const unsigned char *src_y =
+          &src[(y_qn >> SCALE_SUBPEL_BITS) * src_stride];
+      const int16_t *const y_filter =
+          y_filters[(y_qn & SCALE_SUBPEL_MASK) >> SCALE_EXTRA_BITS];
+      int k, sum = 0;
+      for (k = 0; k < SUBPEL_TAPS; ++k)
+        sum += src_y[k * src_stride] * y_filter[k];
+      dst[y * dst_stride] = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
+      y_qn += y_step_qn;
+    }
+    ++src;
+    ++dst;
+  }
+}
+
 static void convolve_avg_vert(const uint8_t *src, ptrdiff_t src_stride,
                               uint8_t *dst, ptrdiff_t dst_stride,
                               const InterpKernel *y_filters, int y0_q4,
                               int y_step_q4, int w, int h) {
   int x, y;
   src -= src_stride * (SUBPEL_TAPS / 2 - 1);
 
   for (x = 0; x < w; ++x) {
@@ -107,16 +179,44 @@ static void convolve_avg_vert(const uint
           1);
       y_q4 += y_step_q4;
     }
     ++src;
     ++dst;
   }
 }
 
+static void convolve_avg_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                                      uint8_t *dst, ptrdiff_t dst_stride,
+                                      const InterpKernel *y_filters, int y0_qn,
+                                      int y_step_qn, int w, int h) {
+  int x, y;
+  src -= src_stride * (SUBPEL_TAPS / 2 - 1);
+
+  for (x = 0; x < w; ++x) {
+    int y_qn = y0_qn;
+    for (y = 0; y < h; ++y) {
+      const unsigned char *src_y =
+          &src[(y_qn >> SCALE_SUBPEL_BITS) * src_stride];
+      const int16_t *const y_filter =
+          y_filters[(y_qn & SCALE_SUBPEL_MASK) >> SCALE_EXTRA_BITS];
+      int k, sum = 0;
+      for (k = 0; k < SUBPEL_TAPS; ++k)
+        sum += src_y[k * src_stride] * y_filter[k];
+      dst[y * dst_stride] = ROUND_POWER_OF_TWO(
+          dst[y * dst_stride] +
+              clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS)),
+          1);
+      y_qn += y_step_qn;
+    }
+    ++src;
+    ++dst;
+  }
+}
+
 static void convolve(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
                      ptrdiff_t dst_stride, const InterpKernel *const x_filters,
                      int x0_q4, int x_step_q4,
                      const InterpKernel *const y_filters, int y0_q4,
                      int y_step_q4, int w, int h) {
   // Note: Fixed size intermediate buffer, temp, places limits on parameters.
   // 2d filtering proceeds in 2 steps:
   //   (1) Interpolate horizontally into an intermediate buffer, temp.
@@ -141,16 +241,51 @@ static void convolve(const uint8_t *src,
 
   convolve_horiz(src - src_stride * (SUBPEL_TAPS / 2 - 1), src_stride, temp,
                  MAX_SB_SIZE, x_filters, x0_q4, x_step_q4, w,
                  intermediate_height);
   convolve_vert(temp + MAX_SB_SIZE * (SUBPEL_TAPS / 2 - 1), MAX_SB_SIZE, dst,
                 dst_stride, y_filters, y0_q4, y_step_q4, w, h);
 }
 
+static void convolve_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                             uint8_t *dst, ptrdiff_t dst_stride,
+                             const InterpKernel *const x_filters, int x0_qn,
+                             int x_step_qn, const InterpKernel *const y_filters,
+                             int y0_qn, int y_step_qn, int w, int h) {
+  // TODO(afergs): Update comment here
+  // Note: Fixed size intermediate buffer, temp, places limits on parameters.
+  // 2d filtering proceeds in 2 steps:
+  //   (1) Interpolate horizontally into an intermediate buffer, temp.
+  //   (2) Interpolate temp vertically to derive the sub-pixel result.
+  // Deriving the maximum number of rows in the temp buffer (135):
+  // --Smallest scaling factor is x1/2 ==> y_step_qn = 32 (Normative).
+  // --Largest block size is 64x64 pixels.
+  // --64 rows in the downscaled frame span a distance of (64 - 1) * 32 in the
+  //   original frame (in 1/16th pixel units).
+  // --Must round-up because block may be located at sub-pixel position.
+  // --Require an additional SUBPEL_TAPS rows for the 8-tap filter tails.
+  // --((64 - 1) * 32 + 15) >> 4 + 8 = 135.
+  uint8_t temp[MAX_EXT_SIZE * MAX_SB_SIZE];
+  int intermediate_height =
+      (((h - 1) * y_step_qn + y0_qn) >> SCALE_SUBPEL_BITS) + SUBPEL_TAPS;
+
+  assert(w <= MAX_SB_SIZE);
+  assert(h <= MAX_SB_SIZE);
+
+  assert(y_step_qn <= SCALE_SUBPEL_BITS * 2);
+  assert(x_step_qn <= SCALE_SUBPEL_BITS * 2);
+
+  convolve_horiz_scale_c(src - src_stride * (SUBPEL_TAPS / 2 - 1), src_stride,
+                         temp, MAX_SB_SIZE, x_filters, x0_qn, x_step_qn, w,
+                         intermediate_height);
+  convolve_vert_scale_c(temp + MAX_SB_SIZE * (SUBPEL_TAPS / 2 - 1), MAX_SB_SIZE,
+                        dst, dst_stride, y_filters, y0_qn, y_step_qn, w, h);
+}
+
 static const InterpKernel *get_filter_base(const int16_t *filter) {
   // NOTE: This assumes that the filter table is 256-byte aligned.
   // TODO(agrange) Modify to make independent of table alignment.
   return (const InterpKernel *)(((intptr_t)filter) & ~((intptr_t)0xFF));
 }
 
 static int get_filter_offset(const int16_t *f, const InterpKernel *base) {
   return (int)((const InterpKernel *)(intptr_t)f - base);
@@ -166,90 +301,180 @@ void aom_convolve8_horiz_c(const uint8_t
 
   (void)filter_y;
   (void)y_step_q4;
 
   convolve_horiz(src, src_stride, dst, dst_stride, filters_x, x0_q4, x_step_q4,
                  w, h);
 }
 
+void aom_convolve8_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                                 uint8_t *dst, ptrdiff_t dst_stride,
+                                 const int16_t *filter_x, int subpel_x,
+                                 int x_step_qn, const int16_t *filter_y,
+                                 int subpel_y, int y_step_qn, int w, int h) {
+  const InterpKernel *const filters_x = get_filter_base(filter_x);
+
+  (void)subpel_y;
+  (void)filter_y;
+  (void)y_step_qn;
+
+  convolve_horiz_scale_c(src, src_stride, dst, dst_stride, filters_x, subpel_x,
+                         x_step_qn, w, h);
+}
+
 void aom_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride,
                                uint8_t *dst, ptrdiff_t dst_stride,
                                const int16_t *filter_x, int x_step_q4,
                                const int16_t *filter_y, int y_step_q4, int w,
                                int h) {
   const InterpKernel *const filters_x = get_filter_base(filter_x);
   const int x0_q4 = get_filter_offset(filter_x, filters_x);
 
   (void)filter_y;
   (void)y_step_q4;
 
   convolve_avg_horiz(src, src_stride, dst, dst_stride, filters_x, x0_q4,
                      x_step_q4, w, h);
 }
 
+void aom_convolve8_avg_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                                     uint8_t *dst, ptrdiff_t dst_stride,
+                                     const int16_t *filter_x, int subpel_x,
+                                     int x_step_qn, const int16_t *filter_y,
+                                     int subpel_y, int y_step_qn, int w,
+                                     int h) {
+  const InterpKernel *const filters_x = get_filter_base(filter_x);
+
+  (void)subpel_y;
+  (void)filter_y;
+  (void)y_step_qn;
+
+  convolve_avg_horiz_scale_c(src, src_stride, dst, dst_stride, filters_x,
+                             subpel_x, x_step_qn, w, h);
+}
+
 void aom_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride,
                           uint8_t *dst, ptrdiff_t dst_stride,
                           const int16_t *filter_x, int x_step_q4,
                           const int16_t *filter_y, int y_step_q4, int w,
                           int h) {
   const InterpKernel *const filters_y = get_filter_base(filter_y);
   const int y0_q4 = get_filter_offset(filter_y, filters_y);
 
   (void)filter_x;
   (void)x_step_q4;
 
   convolve_vert(src, src_stride, dst, dst_stride, filters_y, y0_q4, y_step_q4,
                 w, h);
 }
 
+void aom_convolve8_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                                uint8_t *dst, ptrdiff_t dst_stride,
+                                const int16_t *filter_x, int subpel_x,
+                                int x_step_qn, const int16_t *filter_y,
+                                int subpel_y, int y_step_qn, int w, int h) {
+  const InterpKernel *const filters_y = get_filter_base(filter_y);
+
+  (void)subpel_x;
+  (void)filter_x;
+  (void)x_step_qn;
+
+  convolve_vert_scale_c(src, src_stride, dst, dst_stride, filters_y, subpel_y,
+                        y_step_qn, w, h);
+}
+
 void aom_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride,
                               uint8_t *dst, ptrdiff_t dst_stride,
                               const int16_t *filter_x, int x_step_q4,
                               const int16_t *filter_y, int y_step_q4, int w,
                               int h) {
   const InterpKernel *const filters_y = get_filter_base(filter_y);
   const int y0_q4 = get_filter_offset(filter_y, filters_y);
 
   (void)filter_x;
   (void)x_step_q4;
 
   convolve_avg_vert(src, src_stride, dst, dst_stride, filters_y, y0_q4,
                     y_step_q4, w, h);
 }
 
+void aom_convolve8_avg_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                                    uint8_t *dst, ptrdiff_t dst_stride,
+                                    const int16_t *filter_x, int subpel_x,
+                                    int x_step_qn, const int16_t *filter_y,
+                                    int subpel_y, int y_step_qn, int w, int h) {
+  const InterpKernel *const filters_y = get_filter_base(filter_y);
+
+  (void)subpel_x;
+  (void)filter_x;
+  (void)x_step_qn;
+
+  convolve_avg_vert_scale_c(src, src_stride, dst, dst_stride, filters_y,
+                            subpel_y, y_step_qn, w, h);
+}
+
 void aom_convolve8_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
                      ptrdiff_t dst_stride, const int16_t *filter_x,
                      int x_step_q4, const int16_t *filter_y, int y_step_q4,
                      int w, int h) {
   const InterpKernel *const filters_x = get_filter_base(filter_x);
   const int x0_q4 = get_filter_offset(filter_x, filters_x);
 
   const InterpKernel *const filters_y = get_filter_base(filter_y);
   const int y0_q4 = get_filter_offset(filter_y, filters_y);
 
   convolve(src, src_stride, dst, dst_stride, filters_x, x0_q4, x_step_q4,
            filters_y, y0_q4, y_step_q4, w, h);
 }
 
+void aom_convolve8_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                           uint8_t *dst, ptrdiff_t dst_stride,
+                           const int16_t *filter_x, int subpel_x, int x_step_qn,
+                           const int16_t *filter_y, int subpel_y, int y_step_qn,
+                           int w, int h) {
+  const InterpKernel *const filters_x = get_filter_base(filter_x);
+
+  const InterpKernel *const filters_y = get_filter_base(filter_y);
+
+  convolve_scale_c(src, src_stride, dst, dst_stride, filters_x, subpel_x,
+                   x_step_qn, filters_y, subpel_y, y_step_qn, w, h);
+}
+
 void aom_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
                          ptrdiff_t dst_stride, const int16_t *filter_x,
                          int x_step_q4, const int16_t *filter_y, int y_step_q4,
                          int w, int h) {
   /* Fixed size intermediate buffer places limits on parameters. */
   DECLARE_ALIGNED(16, uint8_t, temp[MAX_SB_SIZE * MAX_SB_SIZE]);
   assert(w <= MAX_SB_SIZE);
   assert(h <= MAX_SB_SIZE);
 
   aom_convolve8_c(src, src_stride, temp, MAX_SB_SIZE, filter_x, x_step_q4,
                   filter_y, y_step_q4, w, h);
   aom_convolve_avg_c(temp, MAX_SB_SIZE, dst, dst_stride, NULL, 0, NULL, 0, w,
                      h);
 }
 
+void aom_convolve8_avg_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                               uint8_t *dst, ptrdiff_t dst_stride,
+                               const int16_t *filter_x, int subpel_x,
+                               int x_step_qn, const int16_t *filter_y,
+                               int subpel_y, int y_step_qn, int w, int h) {
+  /* Fixed size intermediate buffer places limits on parameters. */
+  DECLARE_ALIGNED(16, uint8_t, temp[MAX_SB_SIZE * MAX_SB_SIZE]);
+  assert(w <= MAX_SB_SIZE);
+  assert(h <= MAX_SB_SIZE);
+
+  aom_convolve8_scale_c(src, src_stride, temp, MAX_SB_SIZE, filter_x, subpel_x,
+                        x_step_qn, filter_y, subpel_y, y_step_qn, w, h);
+  aom_convolve_avg_c(temp, MAX_SB_SIZE, dst, dst_stride, NULL, 0, NULL, 0, w,
+                     h);
+}
+
 void aom_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
                          ptrdiff_t dst_stride, const int16_t *filter_x,
                          int filter_x_stride, const int16_t *filter_y,
                          int filter_y_stride, int w, int h) {
   int r;
 
   (void)filter_x;
   (void)filter_x_stride;
@@ -327,16 +552,73 @@ void aom_scaled_avg_vert_c(const uint8_t
 void aom_scaled_avg_2d_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
                          ptrdiff_t dst_stride, const int16_t *filter_x,
                          int x_step_q4, const int16_t *filter_y, int y_step_q4,
                          int w, int h) {
   aom_convolve8_avg_c(src, src_stride, dst, dst_stride, filter_x, x_step_q4,
                       filter_y, y_step_q4, w, h);
 }
 
+/*
+void aom_scaled_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                              uint8_t *dst, ptrdiff_t dst_stride,
+                              const int16_t *filter_x, int x_step_qn,
+                              const int16_t *filter_y, int y_step_qn, int w,
+                              int h) {
+  aom_convolve8_horiz_scale_c(src, src_stride, dst, dst_stride, filter_x,
+                              x_step_qn, filter_y, y_step_qn, w, h);
+}
+
+void aom_scaled_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                             uint8_t *dst, ptrdiff_t dst_stride,
+                             const int16_t *filter_x, int x_step_qn,
+                             const int16_t *filter_y, int y_step_qn, int w,
+                             int h) {
+  aom_convolve8_vert_scale_c(src, src_stride, dst, dst_stride, filter_x,
+                             x_step_qn, filter_y, y_step_qn, w, h);
+}
+
+void aom_scaled_2d_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                           uint8_t *dst, ptrdiff_t dst_stride,
+                           const int16_t *filter_x, int x_step_qn,
+                           const int16_t *filter_y, int y_step_qn, int w,
+                           int h) {
+  aom_convolve8_scale_c(src, src_stride, dst, dst_stride, filter_x, x_step_qn,
+                        filter_y, y_step_qn, w, h);
+}
+
+void aom_scaled_avg_horiz_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                                  uint8_t *dst, ptrdiff_t dst_stride,
+                                  const int16_t *filter_x, int x_step_qn,
+                                  const int16_t *filter_y, int y_step_qn, int w,
+                                  int h) {
+  aom_convolve8_avg_horiz_scale_c(src, src_stride, dst, dst_stride, filter_x,
+                                  x_step_qn, filter_y, y_step_qn, w, h);
+}
+
+void aom_scaled_avg_vert_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                                 uint8_t *dst, ptrdiff_t dst_stride,
+                                 const int16_t *filter_x, int x_step_qn,
+                                 const int16_t *filter_y, int y_step_qn, int w,
+                                 int h) {
+  aom_convolve8_avg_vert_scale_c(src, src_stride, dst, dst_stride, filter_x,
+                                 x_step_qn, filter_y, y_step_qn, w, h);
+}
+
+void aom_scaled_avg_2d_scale_c(const uint8_t *src, ptrdiff_t src_stride,
+                               uint8_t *dst, ptrdiff_t dst_stride,
+                               const int16_t *filter_x, int x_step_qn,
+                               const int16_t *filter_y, int y_step_qn, int w,
+                               int h) {
+  aom_convolve8_avg_scale_c(src, src_stride, dst, dst_stride, filter_x,
+                            x_step_qn, filter_y, y_step_qn, w, h);
+}
+*/
+
+// TODO(afergs): Make sure this works too
 #if CONFIG_LOOP_RESTORATION
 static void convolve_add_src_horiz(const uint8_t *src, ptrdiff_t src_stride,
                                    uint8_t *dst, ptrdiff_t dst_stride,
                                    const InterpKernel *x_filters, int x0_q4,
                                    int x_step_q4, int w, int h) {
   int x, y, k;
   src -= SUBPEL_TAPS / 2 - 1;
   for (y = 0; y < h; ++y) {
@@ -564,16 +846,17 @@ void aom_convolve8_add_src_hip_c(const u
   const InterpKernel *const filters_y = get_filter_base(filter_y);
   const int y0_q4 = get_filter_offset(filter_y, filters_y);
 
   convolve_add_src_hip(src, src_stride, dst, dst_stride, filters_x, x0_q4,
                        x_step_q4, filters_y, y0_q4, y_step_q4, w, h);
 }
 #endif  // CONFIG_LOOP_RESTORATION
 
+// TODO(afergs): Make sure this works too
 #if CONFIG_HIGHBITDEPTH
 static void highbd_convolve_horiz(const uint8_t *src8, ptrdiff_t src_stride,
                                   uint8_t *dst8, ptrdiff_t dst_stride,
                                   const InterpKernel *x_filters, int x0_q4,
                                   int x_step_q4, int w, int h, int bd) {
   int x, y;
   uint16_t *src = CONVERT_TO_SHORTPTR(src8);
   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
--- a/third_party/aom/aom_dsp/aom_dsp.cmake
+++ b/third_party/aom/aom_dsp/aom_dsp.cmake
@@ -325,16 +325,23 @@ if (CONFIG_AV1_ENCODER)
         "${AOM_ROOT}/aom_dsp/x86/quantize_avx_x86_64.asm")
 
     set(AOM_DSP_ENCODER_INTRIN_MSA
         "${AOM_ROOT}/aom_dsp/mips/sad_msa.c"
         "${AOM_ROOT}/aom_dsp/mips/subtract_msa.c"
         "${AOM_ROOT}/aom_dsp/mips/variance_msa.c"
         "${AOM_ROOT}/aom_dsp/mips/sub_pixel_variance_msa.c")
 
+    if (CONFIG_EXT_INTER)
+      set(AOM_DSP_ENCODER_INTRIN_SSSE3
+          ${AOM_DSP_ENCODER_INTRIN_SSSE3}
+          "${AOM_ROOT}/aom_dsp/x86/masked_sad_intrin_ssse3.c"
+          "${AOM_ROOT}/aom_dsp/x86/masked_variance_intrin_ssse3.c")
+    endif ()
+
     if (CONFIG_HIGHBITDEPTH)
       set(AOM_DSP_ENCODER_INTRIN_SSE2
           ${AOM_DSP_ENCODER_INTRIN_SSE2}
           "${AOM_ROOT}/aom_dsp/x86/highbd_quantize_intrin_sse2.c"
           "${AOM_ROOT}/aom_dsp/x86/highbd_subtract_sse2.c")
     endif ()
   endif ()
 
@@ -351,16 +358,17 @@ if (CONFIG_AV1_ENCODER)
         "${AOM_ROOT}/aom_dsp/x86/highbd_variance_sse2.c")
 
     set(AOM_DSP_ENCODER_INTRIN_SSE4_1
         ${AOM_DSP_ENCODER_INTRIN_SSE4_1}
         "${AOM_ROOT}/aom_dsp/x86/highbd_variance_sse4.c")
 
     set(AOM_DSP_ENCODER_INTRIN_AVX2
         ${AOM_DSP_ENCODER_INTRIN_AVX2}
+        "${AOM_ROOT}/aom_dsp/x86/highbd_quantize_intrin_avx2.c"
         "${AOM_ROOT}/aom_dsp/x86/sad_highbd_avx2.c")
   endif ()
 
   if (CONFIG_ANS)
     set(AOM_DSP_ENCODER_SOURCES
         ${AOM_DSP_ENCODER_SOURCES}
         "${AOM_ROOT}/aom_dsp/answriter.h"
         "${AOM_ROOT}/aom_dsp/buf_ans.c"
@@ -402,113 +410,127 @@ if (CONFIG_MOTION_VAR)
       "${AOM_ROOT}/aom_dsp/x86/obmc_sad_sse4.c"
       "${AOM_ROOT}/aom_dsp/x86/obmc_variance_sse4.c")
 endif ()
 
 # Creates aom_dsp build targets. Must not be called until after libaom target
 # has been created.
 function (setup_aom_dsp_targets)
   add_library(aom_dsp_common OBJECT ${AOM_DSP_COMMON_SOURCES})
-  set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_dsp_common)
-  target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_dsp_common>)
+  list(APPEND AOM_LIB_TARGETS aom_dsp_common)
+  create_dummy_source_file("aom_av1" "c" "dummy_source_file")
+  add_library(aom_dsp OBJECT "${dummy_source_file}")
+  target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_dsp_common>)
+  list(APPEND AOM_LIB_TARGETS aom_dsp)
+
+  # Not all generators support libraries consisting only of object files. Add a
+  # dummy source file to the aom_dsp target.
+  add_dummy_source_file_to_target("aom_dsp" "c")
 
   if (CONFIG_AV1_DECODER)
     add_library(aom_dsp_decoder OBJECT ${AOM_DSP_DECODER_SOURCES})
     set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_dsp_decoder)
-    target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_dsp_decoder>)
+    target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_dsp_decoder>)
   endif ()
 
   if (CONFIG_AV1_ENCODER)
     add_library(aom_dsp_encoder OBJECT ${AOM_DSP_ENCODER_SOURCES})
     set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_dsp_encoder)
-    target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_dsp_encoder>)
+    target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_dsp_encoder>)
   endif ()
 
   if (HAVE_SSE2)
     add_asm_library("aom_dsp_common_sse2" "AOM_DSP_COMMON_ASM_SSE2" "aom")
     add_intrinsics_object_library("-msse2" "sse2" "aom_dsp_common"
-                                  "AOM_DSP_COMMON_INTRIN_SSE2")
+                                   "AOM_DSP_COMMON_INTRIN_SSE2" "aom")
+
     if (CONFIG_AV1_ENCODER)
-      add_asm_library("aom_dsp_encoder_sse2" "AOM_DSP_ENCODER_ASM_SSE2" "aom")
+      add_asm_library("aom_dsp_encoder_sse2" "AOM_DSP_ENCODER_ASM_SSE2"
+                      "aom")
       add_intrinsics_object_library("-msse2" "sse2" "aom_dsp_encoder"
-                                    "AOM_DSP_ENCODER_INTRIN_SSE2")
+                                    "AOM_DSP_ENCODER_INTRIN_SSE2" "aom")
     endif()
   endif ()
 
   if (HAVE_SSE3 AND CONFIG_AV1_ENCODER)
     add_asm_library("aom_dsp_encoder_sse3" "AOM_DSP_ENCODER_INTRIN_SSE3" "aom")
   endif ()
 
   if (HAVE_SSSE3)
     add_asm_library("aom_dsp_common_ssse3" "AOM_DSP_COMMON_ASM_SSSE3" "aom")
     add_intrinsics_object_library("-mssse3" "ssse3" "aom_dsp_common"
-                                  "AOM_DSP_COMMON_INTRIN_SSSE3")
+                                  "AOM_DSP_COMMON_INTRIN_SSSE3" "aom")
 
     if (CONFIG_AV1_ENCODER)
       if ("${AOM_TARGET_CPU}" STREQUAL "x86_64")
         list(APPEND AOM_DSP_ENCODER_ASM_SSSE3
              ${AOM_DSP_ENCODER_ASM_SSSE3_X86_64})
       endif ()
       add_asm_library("aom_dsp_encoder_ssse3" "AOM_DSP_ENCODER_ASM_SSSE3" "aom")
+      if (AOM_DSP_ENCODER_INTRIN_SSSE3)
+        add_intrinsics_object_library("-mssse3" "ssse3" "aom_dsp_encoder"
+                                      "AOM_DSP_ENCODER_INTRIN_SSSE3" "aom")
+      endif ()
     endif ()
   endif ()
 
   if (HAVE_SSE4_1)
     add_intrinsics_object_library("-msse4.1" "sse4_1" "aom_dsp_common"
-                                  "AOM_DSP_COMMON_INTRIN_SSE4_1")
+                                  "AOM_DSP_COMMON_INTRIN_SSE4_1" "aom")
     if (CONFIG_AV1_ENCODER)
       if (AOM_DSP_ENCODER_INTRIN_SSE4_1)
         add_intrinsics_object_library("-msse4.1" "sse4_1" "aom_dsp_encoder"
-                                      "AOM_DSP_ENCODER_INTRIN_SSE4_1")
+                                      "AOM_DSP_ENCODER_INTRIN_SSE4_1" "aom")
       endif ()
       add_asm_library("aom_dsp_encoder_sse4_1" "AOM_DSP_ENCODER_ASM_SSE4_1"
                       "aom")
     endif ()
   endif ()
 
   if (HAVE_AVX AND "${AOM_TARGET_CPU}" STREQUAL "x86_64")
     if (CONFIG_AV1_ENCODER)
       add_asm_library("aom_dsp_encoder_avx" "AOM_DSP_ENCODER_AVX_ASM_X86_64"
                       "aom")
     endif ()
   endif ()
 
   if (HAVE_AVX2)
     add_intrinsics_object_library("-mavx2" "avx2" "aom_dsp_common"
-                                  "AOM_DSP_COMMON_INTRIN_AVX2")
+                                  "AOM_DSP_COMMON_INTRIN_AVX2" "aom")
     if (CONFIG_AV1_ENCODER)
       add_intrinsics_object_library("-mavx2" "avx2" "aom_dsp_encoder"
-                                    "AOM_DSP_ENCODER_INTRIN_AVX2")
+                                    "AOM_DSP_ENCODER_INTRIN_AVX2" "aom")
     endif ()
   endif ()
 
   if (HAVE_NEON_ASM)
     if (AOM_ADS2GAS_REQUIRED)
       add_gas_asm_library("aom_dsp_common_neon" "AOM_DSP_COMMON_ASM_NEON" "aom")
     else ()
       add_asm_library("aom_dsp_common_neon" "AOM_DSP_COMMON_ASM_NEON" "aom")
     endif ()
   endif ()
 
   if (HAVE_NEON)
     add_intrinsics_object_library("${AOM_NEON_INTRIN_FLAG}" "neon"
-                                  "aom_dsp_common" "AOM_DSP_COMMON_INTRIN_NEON")
+                                  "aom_dsp_common" "AOM_DSP_COMMON_INTRIN_NEON"
+                                  "aom")
   endif ()
 
   if (HAVE_DSPR2)
     add_intrinsics_object_library("" "dspr2" "aom_dsp_common"
-                                  "AOM_DSP_COMMON_INTRIN_DSPR2")
+                                  "AOM_DSP_COMMON_INTRIN_DSPR2" "aom")
   endif ()
 
   if (HAVE_MSA)
     add_intrinsics_object_library("" "msa" "aom_dsp_common"
-                                  "AOM_DSP_COMMON_INTRIN_MSA")
+                                  "AOM_DSP_COMMON_INTRIN_MSA" "aom")
     if (CONFIG_AV1_ENCODER)
       add_intrinsics_object_library("" "msa" "aom_dsp_encoder"
-                                    "AOM_DSP_ENCODER_INTRIN_MSA")
+                                    "AOM_DSP_ENCODER_INTRIN_MSA" "aom")
     endif ()
   endif ()
 
   # Pass the new lib targets up to the parent scope instance of
   # $AOM_LIB_TARGETS.
   set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
 endfunction ()
 
--- a/third_party/aom/aom_dsp/aom_dsp.mk
+++ b/third_party/aom/aom_dsp/aom_dsp.mk
@@ -285,19 +285,20 @@ endif  # CONFIG_LOOP_RESTORATION
 endif  # CONFIG_AV1
 
 # quantization
 ifneq ($(filter yes,$(CONFIG_AV1_ENCODER)),)
 DSP_SRCS-yes            += quantize.c
 DSP_SRCS-yes            += quantize.h
 
 DSP_SRCS-$(HAVE_SSE2)   += x86/quantize_sse2.c
-ifeq ($(CONFIG_HIGHBITDEPTH),yes)
+
 DSP_SRCS-$(HAVE_SSE2)   += x86/highbd_quantize_intrin_sse2.c
-endif
+DSP_SRCS-$(HAVE_AVX2)   += x86/highbd_quantize_intrin_avx2.c
+
 ifeq ($(ARCH_X86_64),yes)
 DSP_SRCS-$(HAVE_SSSE3)  += x86/quantize_ssse3_x86_64.asm
 DSP_SRCS-$(HAVE_AVX)    += x86/quantize_avx_x86_64.asm
 endif
 
 # avg
 DSP_SRCS-yes           += avg.c
 DSP_SRCS-$(HAVE_SSE2)  += x86/avg_intrin_sse2.c
--- a/third_party/aom/aom_dsp/aom_dsp_common.h
+++ b/third_party/aom/aom_dsp/aom_dsp_common.h
@@ -49,26 +49,19 @@ extern "C" {
 #ifdef __GNUC__
 #define LIKELY(v) __builtin_expect(v, 1)
 #define UNLIKELY(v) __builtin_expect(v, 0)
 #else
 #define LIKELY(v) (v)
 #define UNLIKELY(v) (v)
 #endif
 
-#define AOM_SWAP(type, a, b) \
-  do {                       \
-    type c = (b);            \
-    b = a;                   \
-    a = c;                   \
-  } while (0)
-
 #if CONFIG_AOM_QM
 typedef uint16_t qm_val_t;
-#define AOM_QM_BITS 6
+#define AOM_QM_BITS 5
 #endif
 #if CONFIG_HIGHBITDEPTH
 // Note:
 // tran_low_t  is the datatype used for final transform coefficients.
 // tran_high_t is the datatype used for intermediate transform stages.
 typedef int64_t tran_high_t;
 typedef int32_t tran_low_t;
 #else
@@ -82,28 +75,30 @@ typedef int16_t tran_low_t;
 static INLINE uint8_t clip_pixel(int val) {
   return (val > 255) ? 255 : (val < 0) ? 0 : val;
 }
 
 static INLINE int clamp(int value, int low, int high) {
   return value < low ? low : (value > high ? high : value);
 }
 
+static INLINE int64_t clamp64(int64_t value, int64_t low, int64_t high) {
+  return value < low ? low : (value > high ? high : value);
+}
+
 static INLINE double fclamp(double value, double low, double high) {
   return value < low ? low : (value > high ? high : value);
 }
 
-#if CONFIG_HIGHBITDEPTH
 static INLINE uint16_t clip_pixel_highbd(int val, int bd) {
   switch (bd) {
     case 8:
     default: return (uint16_t)clamp(val, 0, 255);
     case 10: return (uint16_t)clamp(val, 0, 1023);
     case 12: return (uint16_t)clamp(val, 0, 4095);
   }
 }
-#endif  // CONFIG_HIGHBITDEPTH
 
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
 #endif  // AOM_DSP_AOM_DSP_COMMON_H_
--- a/third_party/aom/aom_dsp/aom_dsp_rtcd_defs.pl
+++ b/third_party/aom/aom_dsp/aom_dsp_rtcd_defs.pl
@@ -41,33 +41,40 @@ foreach $w (@block_widths) {
   }
 }
 
 @tx_dims = (2, 4, 8, 16, 32);
 if (aom_config("CONFIG_TX64X64") eq "yes") {
   push @tx_dims, '64';
 }
 
+@tx_sizes = ();
+foreach $w (@tx_dims) {
+  push @tx_sizes, [$w, $w];
+  foreach $h (@tx_dims) {
+    push @tx_sizes, [$w, $h] if ($w >=4 && $h >=4 && ($w == 2*$h || $h == 2*$w));
+  }
+}
+
 @pred_names = qw/dc dc_top dc_left dc_128 v h d207e d63e d45e d117 d135 d153/;
 if (aom_config("CONFIG_ALT_INTRA") eq "yes") {
   push @pred_names, qw/paeth smooth/;
   if (aom_config("CONFIG_SMOOTH_HV") eq "yes") {
     push @pred_names, qw/smooth_v smooth_h/;
   }
 } else {
   push @pred_names, 'tm';
 }
 
 #
 # Intra prediction
 #
 
-foreach $dim (@tx_dims) {
-  $w = ${dim};
-  $h = ${dim};
+foreach (@tx_sizes) {
+  ($w, $h) = @$_;
   foreach $pred_name (@pred_names) {
     add_proto "void", "aom_${pred_name}_predictor_${w}x${h}",
               "uint8_t *dst, ptrdiff_t y_stride, const uint8_t *above, const uint8_t *left";
     if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
       add_proto "void", "aom_highbd_${pred_name}_predictor_${w}x${h}",
                 "uint16_t *dst, ptrdiff_t y_stride, const uint16_t *above, const uint16_t *left, int bd";
     }
   }
@@ -137,30 +144,37 @@ if (aom_config("CONFIG_HIGHBITDEPTH") eq
     specialize qw/aom_highbd_tm_predictor_32x32 sse2/;
   }  # CONFIG_ALT_INTRA
   specialize qw/aom_highbd_dc_predictor_32x32 sse2/;
 }  # CONFIG_HIGHBITDEPTH
 
 #
 # Sub Pixel Filters
 #
-add_proto qw/void aom_convolve_copy/,       "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_convolve_avg/,        "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_convolve8/,           "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_convolve8_horiz/,     "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_convolve8_vert/,      "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_convolve8_avg/,       "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_convolve8_avg_horiz/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_convolve8_avg_vert/,  "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_scaled_2d/,           "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_scaled_horiz/,        "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_scaled_vert/,         "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_scaled_avg_2d/,       "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_scaled_avg_horiz/,    "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
-add_proto qw/void aom_scaled_avg_vert/,     "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve_copy/,             "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve_avg/,              "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve8/,                 "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve8_horiz/,           "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve8_vert/,            "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve8_avg/,             "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve8_avg_horiz/,       "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve8_avg_vert/,        "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_scaled_2d/,                 "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_scaled_horiz/,              "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_scaled_vert/,               "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_scaled_avg_2d/,             "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_scaled_avg_horiz/,          "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_scaled_avg_vert/,           "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h";
+
+add_proto qw/void aom_convolve8_horiz_scale/,     "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve8_vert_scale/,      "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve8_avg_horiz_scale/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve8_avg_vert_scale/,  "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve8_scale/,           "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h";
+add_proto qw/void aom_convolve8_avg_scale/,       "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int subpel_x, int x_step_q4, const int16_t *filter_y, int subpel_y, int y_step_q4, int w, int h";
 
 specialize qw/aom_convolve_copy       sse2      /;
 specialize qw/aom_convolve_avg        sse2      /;
 specialize qw/aom_convolve8           sse2 ssse3/, "$avx2_ssse3";
 specialize qw/aom_convolve8_horiz     sse2 ssse3/, "$avx2_ssse3";
 specialize qw/aom_convolve8_vert      sse2 ssse3/, "$avx2_ssse3";
 specialize qw/aom_convolve8_avg       sse2 ssse3/;
 specialize qw/aom_convolve8_avg_horiz sse2 ssse3/;
@@ -329,106 +343,70 @@ if ((aom_config("CONFIG_AV1_ENCODER") eq
     specialize qw/aom_fdct4x4 sse2/;
 
     add_proto qw/void aom_fdct4x4_1/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_fdct4x4_1 sse2/;
 
     add_proto qw/void aom_fdct8x8/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_fdct8x8 sse2/, "$ssse3_x86_64";
 
-    add_proto qw/void aom_fdct8x8_1/, "const int16_t *input, tran_low_t *output, int stride";
-    specialize qw/aom_fdct8x8_1 sse2/;
-
     add_proto qw/void aom_fdct16x16/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_fdct16x16 sse2/;
 
-    add_proto qw/void aom_fdct16x16_1/, "const int16_t *input, tran_low_t *output, int stride";
-    specialize qw/aom_fdct16x16_1 sse2 avx2/;
-
     add_proto qw/void aom_fdct32x32/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_fdct32x32 sse2 avx2/;
 
     add_proto qw/void aom_fdct32x32_rd/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_fdct32x32_rd sse2 avx2/;
 
-    add_proto qw/void aom_fdct32x32_1/, "const int16_t *input, tran_low_t *output, int stride";
-    specialize qw/aom_fdct32x32_1 sse2 avx2/;
-
     # High bit depth
     add_proto qw/void aom_highbd_fdct4x4/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_highbd_fdct4x4 sse2/;
 
     add_proto qw/void aom_highbd_fdct8x8/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_highbd_fdct8x8 sse2/;
 
-    add_proto qw/void aom_highbd_fdct8x8_1/, "const int16_t *input, tran_low_t *output, int stride";
-
     add_proto qw/void aom_highbd_fdct16x16/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_highbd_fdct16x16 sse2/;
 
-    add_proto qw/void aom_highbd_fdct16x16_1/, "const int16_t *input, tran_low_t *output, int stride";
-
     add_proto qw/void aom_highbd_fdct32x32/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_highbd_fdct32x32 sse2/;
 
     add_proto qw/void aom_highbd_fdct32x32_rd/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_highbd_fdct32x32_rd sse2/;
 
-    add_proto qw/void aom_highbd_fdct32x32_1/, "const int16_t *input, tran_low_t *output, int stride";
   } else {
     add_proto qw/void aom_fdct4x4/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_fdct4x4 sse2 msa/;
 
     add_proto qw/void aom_fdct4x4_1/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_fdct4x4_1 sse2/;
 
     add_proto qw/void aom_fdct8x8/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_fdct8x8 sse2 neon msa/, "$ssse3_x86_64";
 
-    add_proto qw/void aom_fdct8x8_1/, "const int16_t *input, tran_low_t *output, int stride";
-    specialize qw/aom_fdct8x8_1 sse2 neon msa/;
-
     add_proto qw/void aom_fdct16x16/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_fdct16x16 sse2 msa/;
 
-    add_proto qw/void aom_fdct16x16_1/, "const int16_t *input, tran_low_t *output, int stride";
-    specialize qw/aom_fdct16x16_1 sse2 avx2 msa/;
-
     add_proto qw/void aom_fdct32x32/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_fdct32x32 sse2 avx2 msa/;
 
     add_proto qw/void aom_fdct32x32_rd/, "const int16_t *input, tran_low_t *output, int stride";
     specialize qw/aom_fdct32x32_rd sse2 avx2 msa/;
-
-    add_proto qw/void aom_fdct32x32_1/, "const int16_t *input, tran_low_t *output, int stride";
-    specialize qw/aom_fdct32x32_1 sse2 avx2 msa/;
   }  # CONFIG_HIGHBITDEPTH
 }  # CONFIG_AV1_ENCODER
 
 #
 # Inverse transform
 if (aom_config("CONFIG_AV1") eq "yes") {
-if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
   add_proto qw/void aom_iwht4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
 
   add_proto qw/void aom_iwht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
   specialize qw/aom_iwht4x4_16_add sse2/;
 
-  add_proto qw/void aom_highbd_idct4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd";
-
-  add_proto qw/void aom_highbd_idct8x8_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd";
-
-  add_proto qw/void aom_highbd_idct16x16_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd";
-
-  add_proto qw/void aom_highbd_idct32x32_1024_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd";
-
-  add_proto qw/void aom_highbd_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd";
-
-  add_proto qw/void aom_highbd_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd";
-
   add_proto qw/void aom_highbd_iwht4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd";
 
   add_proto qw/void aom_highbd_iwht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd";
 
   {
     add_proto qw/void aom_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
     specialize qw/aom_idct4x4_16_add sse2/;
 
@@ -464,20 +442,18 @@ if (aom_config("CONFIG_HIGHBITDEPTH") eq
     # Need to add 135 eob idct32x32 implementations.
     $aom_idct32x32_135_add_sse2=aom_idct32x32_1024_add_sse2;
 
     add_proto qw/void aom_idct32x32_34_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
     specialize qw/aom_idct32x32_34_add sse2 ssse3 avx2/;
 
     add_proto qw/void aom_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
     specialize qw/aom_idct32x32_1_add sse2 avx2/;
-
-    add_proto qw/void aom_highbd_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd";
-    specialize qw/aom_highbd_idct4x4_16_add sse2/;
   }
+if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
 } else {
   {
     add_proto qw/void aom_idct4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
     specialize qw/aom_idct4x4_1_add sse2 neon dspr2 msa/;
 
     add_proto qw/void aom_idct4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride";
     specialize qw/aom_idct4x4_16_add sse2 neon dspr2 msa/;
 
@@ -536,43 +512,41 @@ if (aom_config("CONFIG_HIGHBITDEPTH") eq
 if (aom_config("CONFIG_AOM_QM") eq "yes") {
   if (aom_config("CONFIG_AV1_ENCODER") eq "yes") {
     add_proto qw/void aom_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr";
 
     add_proto qw/void aom_quantize_b_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr";
 
     add_proto qw/void aom_quantize_b_64x64/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr";
 
-    if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
-      add_proto qw/void aom_highbd_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr";
+    add_proto qw/void aom_highbd_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr";
 
-      add_proto qw/void aom_highbd_quantize_b_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr";
+    add_proto qw/void aom_highbd_quantize_b_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr";
 
-      add_proto qw/void aom_highbd_quantize_b_64x64/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr";
-    }  # CONFIG_HIGHBITDEPTH
+    add_proto qw/void aom_highbd_quantize_b_64x64/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr";
+
   }  # CONFIG_AV1_ENCODER
 } else {
   if (aom_config("CONFIG_AV1_ENCODER") eq "yes") {
     add_proto qw/void aom_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
     specialize qw/aom_quantize_b sse2/, "$ssse3_x86_64", "$avx_x86_64";
 
     add_proto qw/void aom_quantize_b_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
     specialize qw/aom_quantize_b_32x32/, "$ssse3_x86_64", "$avx_x86_64";
 
     add_proto qw/void aom_quantize_b_64x64/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
 
-    if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
-      add_proto qw/void aom_highbd_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
-      specialize qw/aom_highbd_quantize_b sse2/;
+    add_proto qw/void aom_highbd_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
+    specialize qw/aom_highbd_quantize_b sse2 avx2/;
 
-      add_proto qw/void aom_highbd_quantize_b_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
-      specialize qw/aom_highbd_quantize_b_32x32 sse2/;
+    add_proto qw/void aom_highbd_quantize_b_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
+    specialize qw/aom_highbd_quantize_b_32x32 sse2/;
 
-      add_proto qw/void aom_highbd_quantize_b_64x64/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
-    }  # CONFIG_HIGHBITDEPTH
+    add_proto qw/void aom_highbd_quantize_b_64x64/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
+
   }  # CONFIG_AV1_ENCODER
 } # CONFIG_AOM_QM
 if (aom_config("CONFIG_AV1") eq "yes") {
   #
   # Alpha blending with mask
   #
   add_proto qw/void aom_blend_a64_mask/, "uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, uint32_t mask_stride, int h, int w, int suby, int subx";
   add_proto qw/void aom_blend_a64_hmask/, "uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, int h, int w";
@@ -922,25 +896,25 @@ if (aom_config("CONFIG_HIGHBITDEPTH") eq
     specialize "aom_highbd_${bd}_mse16x16", qw/sse2/;
     specialize "aom_highbd_${bd}_mse8x8", qw/sse2/;
   }
 }
 
 #
 # ...
 #
-add_proto qw/void aom_upsampled_pred/, "uint8_t *comp_pred, int width, int height, const uint8_t *ref, int ref_stride";
+add_proto qw/void aom_upsampled_pred/, "uint8_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride";
 specialize qw/aom_upsampled_pred sse2/;
-add_proto qw/void aom_comp_avg_upsampled_pred/, "uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride";
+add_proto qw/void aom_comp_avg_upsampled_pred/, "uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride";
 specialize qw/aom_comp_avg_upsampled_pred sse2/;
 
 if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
-  add_proto qw/void aom_highbd_upsampled_pred/, "uint16_t *comp_pred, int width, int height, const uint8_t *ref8, int ref_stride";
+  add_proto qw/void aom_highbd_upsampled_pred/, "uint16_t *comp_pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd";
   specialize qw/aom_highbd_upsampled_pred sse2/;
-  add_proto qw/void aom_highbd_comp_avg_upsampled_pred/, "uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride";
+  add_proto qw/void aom_highbd_comp_avg_upsampled_pred/, "uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, int bd";
   specialize qw/aom_highbd_comp_avg_upsampled_pred sse2/;
 }
 
 #
 # ...
 #
 add_proto qw/unsigned int aom_get_mb_ss/, "const int16_t *";
 add_proto qw/unsigned int aom_get4x4sse_cs/, "const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int ref_stride";
@@ -1491,18 +1465,18 @@ if (aom_config("CONFIG_HIGHBITDEPTH") eq
 
   add_proto qw/uint32_t aom_highbd_8_sub_pixel_avg_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
   add_proto qw/uint32_t aom_highbd_8_sub_pixel_avg_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int  yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
 
 }  # CONFIG_HIGHBITDEPTH
 
 if (aom_config("CONFIG_EXT_INTER") eq "yes") {
   add_proto qw/void aom_comp_mask_pred/, "uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask";
-  add_proto qw/void aom_comp_mask_upsampled_pred/, "uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask";
+  add_proto qw/void aom_comp_mask_upsampled_pred/, "uint8_t *comp_pred, const uint8_t *pred, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask";
   if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
     add_proto qw/void aom_highbd_comp_mask_pred/, "uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask";
-    add_proto qw/void aom_highbd_comp_mask_upsampled_pred/, "uint16_t *comp_pred, const uint8_t *pred8, int width, int height, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask";
+    add_proto qw/void aom_highbd_comp_mask_upsampled_pred/, "uint16_t *comp_pred, const uint8_t *pred8, int width, int height, int subsample_x_q3, int subsample_y_q3, const uint8_t *ref8, int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask, int bd";
   }
 }
 
 }  # CONFIG_AV1_ENCODER
 
 1;
--- a/third_party/aom/aom_dsp/aom_filter.h
+++ b/third_party/aom/aom_dsp/aom_filter.h
@@ -20,16 +20,22 @@ extern "C" {
 
 #define FILTER_BITS 7
 
 #define SUBPEL_BITS 4
 #define SUBPEL_MASK ((1 << SUBPEL_BITS) - 1)
 #define SUBPEL_SHIFTS (1 << SUBPEL_BITS)
 #define SUBPEL_TAPS 8
 
+#define SCALE_SUBPEL_BITS 10
+#define SCALE_SUBPEL_SHIFTS (1 << SCALE_SUBPEL_BITS)
+#define SCALE_SUBPEL_MASK (SCALE_SUBPEL_SHIFTS - 1)
+#define SCALE_EXTRA_BITS (SCALE_SUBPEL_BITS - SUBPEL_BITS)
+#define SCALE_EXTRA_OFF ((1 << SCALE_EXTRA_BITS) / 2)
+
 typedef int16_t InterpKernel[SUBPEL_TAPS];
 
 #define BIL_SUBPEL_BITS 3
 #define BIL_SUBPEL_SHIFTS (1 << BIL_SUBPEL_BITS)
 
 // 2 tap bilinear filters
 static const uint8_t bilinear_filters_2t[BIL_SUBPEL_SHIFTS][2] = {
   { 128, 0 }, { 112, 16 }, { 96, 32 }, { 80, 48 },
--- a/third_party/aom/aom_dsp/fwd_txfm.c
+++ b/third_party/aom/aom_dsp/fwd_txfm.c
@@ -167,25 +167,16 @@ void aom_fdct8x8_c(const int16_t *input,
   }
 
   // Rows
   for (i = 0; i < 8; ++i) {
     for (j = 0; j < 8; ++j) final_output[j + i * 8] /= 2;
   }
 }
 
-void aom_fdct8x8_1_c(const int16_t *input, tran_low_t *output, int stride) {
-  int r, c;
-  tran_low_t sum = 0;
-  for (r = 0; r < 8; ++r)
-    for (c = 0; c < 8; ++c) sum += input[r * stride + c];
-
-  output[0] = sum;
-}
-
 void aom_fdct16x16_c(const int16_t *input, tran_low_t *output, int stride) {
   // The 2D transform is done with two passes which are actually pretty
   // similar. In the first one, we transform the columns and transpose
   // the results. In the second one, we transform the rows. To achieve that,
   // as the first pass results are transposed, we transpose the columns (that
   // is the transposed rows) and transpose the results (so that it goes back
   // in normal/row positions).
   int pass;
@@ -356,25 +347,16 @@ void aom_fdct16x16_c(const int16_t *inpu
       out += 16;
     }
     // Setup in/out for next pass.
     in_low = intermediate;
     out = output;
   }
 }
 
-void aom_fdct16x16_1_c(const int16_t *input, tran_low_t *output, int stride) {
-  int r, c;
-  int sum = 0;
-  for (r = 0; r < 16; ++r)
-    for (c = 0; c < 16; ++c) sum += input[r * stride + c];
-
-  output[0] = (tran_low_t)(sum >> 1);
-}
-
 static INLINE tran_high_t dct_32_round(tran_high_t input) {
   tran_high_t rv = ROUND_POWER_OF_TWO(input, DCT_CONST_BITS);
   // TODO(debargha, peter.derivaz): Find new bounds for this assert,
   // and make the bounds consts.
   // assert(-131072 <= rv && rv <= 131071);
   return rv;
 }
 
@@ -753,57 +735,33 @@ void aom_fdct32x32_rd_c(const int16_t *i
   for (i = 0; i < 32; ++i) {
     tran_high_t temp_in[32], temp_out[32];
     for (j = 0; j < 32; ++j) temp_in[j] = output[j + i * 32];
     aom_fdct32(temp_in, temp_out, 1);
     for (j = 0; j < 32; ++j) out[j + i * 32] = (tran_low_t)temp_out[j];
   }
 }
 
-void aom_fdct32x32_1_c(const int16_t *input, tran_low_t *output, int stride) {
-  int r, c;
-  int sum = 0;
-  for (r = 0; r < 32; ++r)
-    for (c = 0; c < 32; ++c) sum += input[r * stride + c];
-
-  output[0] = (tran_low_t)(sum >> 3);
-}
-
 #if CONFIG_HIGHBITDEPTH
 void aom_highbd_fdct4x4_c(const int16_t *input, tran_low_t *output,
                           int stride) {
   aom_fdct4x4_c(input, output, stride);
 }
 
 void aom_highbd_fdct8x8_c(const int16_t *input, tran_low_t *final_output,
                           int stride) {
   aom_fdct8x8_c(input, final_output, stride);
 }
 
-void aom_highbd_fdct8x8_1_c(const int16_t *input, tran_low_t *final_output,
-                            int stride) {
-  aom_fdct8x8_1_c(input, final_output, stride);
-}
-
 void aom_highbd_fdct16x16_c(const int16_t *input, tran_low_t *output,
                             int stride) {
   aom_fdct16x16_c(input, output, stride);
 }
 
-void aom_highbd_fdct16x16_1_c(const int16_t *input, tran_low_t *output,
-                              int stride) {
-  aom_fdct16x16_1_c(input, output, stride);
-}
-
 void aom_highbd_fdct32x32_c(const int16_t *input, tran_low_t *out, int stride) {
   aom_fdct32x32_c(input, out, stride);
 }
-
 void aom_highbd_fdct32x32_rd_c(const int16_t *input, tran_low_t *out,
                                int stride) {
   aom_fdct32x32_rd_c(input, out, stride);
 }
 
-void aom_highbd_fdct32x32_1_c(const int16_t *input, tran_low_t *out,
-                              int stride) {
-  aom_fdct32x32_1_c(input, out, stride);
-}
 #endif  // CONFIG_HIGHBITDEPTH
--- a/third_party/aom/aom_dsp/fwd_txfm.h
+++ b/third_party/aom/aom_dsp/fwd_txfm.h
@@ -15,15 +15,10 @@
 #include "aom_dsp/txfm_common.h"
 
 static INLINE tran_high_t saturate_int16(tran_high_t value) {
   tran_high_t result;
   result = value > INT16_MAX ? INT16_MAX : value;
   return result < INT16_MIN ? INT16_MIN : result;
 }
 
-static INLINE tran_high_t fdct_round_shift(tran_high_t input) {
-  tran_high_t rv = ROUND_POWER_OF_TWO(input, DCT_CONST_BITS);
-  return rv;
-}
-
 void aom_fdct32(const tran_high_t *input, tran_high_t *output, int round);
 #endif  // AOM_DSP_FWD_TXFM_H_
--- a/third_party/aom/aom_dsp/intrapred.c
+++ b/third_party/aom/aom_dsp/intrapred.c
@@ -18,85 +18,90 @@
 #include "aom_dsp/aom_dsp_common.h"
 #include "aom_mem/aom_mem.h"
 #include "aom_ports/bitops.h"
 
 #define DST(x, y) dst[(x) + (y)*stride]
 #define AVG3(a, b, c) (((a) + 2 * (b) + (c) + 2) >> 2)
 #define AVG2(a, b) (((a) + (b) + 1) >> 1)
 
-static INLINE void d207e_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                   const uint8_t *above, const uint8_t *left) {
+static INLINE void d207e_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                   int bh, const uint8_t *above,
+                                   const uint8_t *left) {
   int r, c;
   (void)above;
 
-  for (r = 0; r < bs; ++r) {
-    for (c = 0; c < bs; ++c) {
+  for (r = 0; r < bh; ++r) {
+    for (c = 0; c < bw; ++c) {
       dst[c] = c & 1 ? AVG3(left[(c >> 1) + r], left[(c >> 1) + r + 1],
                             left[(c >> 1) + r + 2])
                      : AVG2(left[(c >> 1) + r], left[(c >> 1) + r + 1]);
     }
     dst += stride;
   }
 }
 
-static INLINE void d63e_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                  const uint8_t *above, const uint8_t *left) {
+static INLINE void d63e_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                  int bh, const uint8_t *above,
+                                  const uint8_t *left) {
   int r, c;
   (void)left;
-  for (r = 0; r < bs; ++r) {
-    for (c = 0; c < bs; ++c) {
+  for (r = 0; r < bh; ++r) {
+    for (c = 0; c < bw; ++c) {
       dst[c] = r & 1 ? AVG3(above[(r >> 1) + c], above[(r >> 1) + c + 1],
                             above[(r >> 1) + c + 2])
                      : AVG2(above[(r >> 1) + c], above[(r >> 1) + c + 1]);
     }
     dst += stride;
   }
 }
 
-static INLINE void d45e_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                  const uint8_t *above, const uint8_t *left) {
+static INLINE void d45e_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                  int bh, const uint8_t *above,
+                                  const uint8_t *left) {
   int r, c;
   (void)left;
-  for (r = 0; r < bs; ++r) {
-    for (c = 0; c < bs; ++c) {
+  for (r = 0; r < bh; ++r) {
+    for (c = 0; c < bw; ++c) {
       dst[c] = AVG3(above[r + c], above[r + c + 1],
-                    above[r + c + 1 + (r + c + 2 < bs * 2)]);
+                    above[r + c + 1 + (r + c + 2 < bw + bh)]);
     }
     dst += stride;
   }
 }
 
-static INLINE void d117_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                  const uint8_t *above, const uint8_t *left) {
+static INLINE void d117_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                  int bh, const uint8_t *above,
+                                  const uint8_t *left) {
   int r, c;
 
   // first row
-  for (c = 0; c < bs; c++) dst[c] = AVG2(above[c - 1], above[c]);
+  for (c = 0; c < bw; c++) dst[c] = AVG2(above[c - 1], above[c]);
   dst += stride;
 
   // second row
   dst[0] = AVG3(left[0], above[-1], above[0]);
-  for (c = 1; c < bs; c++) dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
+  for (c = 1; c < bw; c++) dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
   dst += stride;
 
   // the rest of first col
   dst[0] = AVG3(above[-1], left[0], left[1]);
-  for (r = 3; r < bs; ++r)
+  for (r = 3; r < bh; ++r)
     dst[(r - 2) * stride] = AVG3(left[r - 3], left[r - 2], left[r - 1]);
 
   // the rest of the block
-  for (r = 2; r < bs; ++r) {
-    for (c = 1; c < bs; c++) dst[c] = dst[-2 * stride + c - 1];
+  for (r = 2; r < bh; ++r) {
+    for (c = 1; c < bw; c++) dst[c] = dst[-2 * stride + c - 1];
     dst += stride;
   }
 }
 
-static INLINE void d135_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                  const uint8_t *above, const uint8_t *left) {
+static INLINE void d135_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                  int bh, const uint8_t *above,
+                                  const uint8_t *left) {
   int i;
 #if CONFIG_TX64X64
 #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ > 7
   // silence a spurious -Warray-bounds warning, possibly related to:
   // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
   uint8_t border[133];
 #else
   uint8_t border[64 + 64 - 1];  // outer border from bottom-left to top-right
@@ -106,74 +111,75 @@ static INLINE void d135_predictor(uint8_
   // silence a spurious -Warray-bounds warning, possibly related to:
   // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
   uint8_t border[69];
 #else
   uint8_t border[32 + 32 - 1];  // outer border from bottom-left to top-right
 #endif
 #endif  // CONFIG_TX64X64
 
-  // dst(bs, bs - 2)[0], i.e., border starting at bottom-left
-  for (i = 0; i < bs - 2; ++i) {
-    border[i] = AVG3(left[bs - 3 - i], left[bs - 2 - i], left[bs - 1 - i]);
+  // dst(bh, bh - 2)[0], i.e., border starting at bottom-left
+  for (i = 0; i < bh - 2; ++i) {
+    border[i] = AVG3(left[bh - 3 - i], left[bh - 2 - i], left[bh - 1 - i]);
   }
-  border[bs - 2] = AVG3(above[-1], left[0], left[1]);
-  border[bs - 1] = AVG3(left[0], above[-1], above[0]);
-  border[bs - 0] = AVG3(above[-1], above[0], above[1]);
+  border[bh - 2] = AVG3(above[-1], left[0], left[1]);
+  border[bh - 1] = AVG3(left[0], above[-1], above[0]);
+  border[bh - 0] = AVG3(above[-1], above[0], above[1]);
   // dst[0][2, size), i.e., remaining top border ascending
-  for (i = 0; i < bs - 2; ++i) {
-    border[bs + 1 + i] = AVG3(above[i], above[i + 1], above[i + 2]);
+  for (i = 0; i < bw - 2; ++i) {
+    border[bh + 1 + i] = AVG3(above[i], above[i + 1], above[i + 2]);
   }
 
-  for (i = 0; i < bs; ++i) {
-    memcpy(dst + i * stride, border + bs - 1 - i, bs);
+  for (i = 0; i < bh; ++i) {
+    memcpy(dst + i * stride, border + bh - 1 - i, bw);
   }
 }
 
-static INLINE void d153_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                  const uint8_t *above, const uint8_t *left) {
+static INLINE void d153_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                  int bh, const uint8_t *above,
+                                  const uint8_t *left) {
   int r, c;
   dst[0] = AVG2(above[-1], left[0]);
-  for (r = 1; r < bs; r++) dst[r * stride] = AVG2(left[r - 1], left[r]);
+  for (r = 1; r < bh; r++) dst[r * stride] = AVG2(left[r - 1], left[r]);
   dst++;
 
   dst[0] = AVG3(left[0], above[-1], above[0]);
   dst[stride] = AVG3(above[-1], left[0], left[1]);
-  for (r = 2; r < bs; r++)
+  for (r = 2; r < bh; r++)
     dst[r * stride] = AVG3(left[r - 2], left[r - 1], left[r]);
   dst++;
 
-  for (c = 0; c < bs - 2; c++)
+  for (c = 0; c < bw - 2; c++)
     dst[c] = AVG3(above[c - 1], above[c], above[c + 1]);
   dst += stride;
 
-  for (r = 1; r < bs; ++r) {
-    for (c = 0; c < bs - 2; c++) dst[c] = dst[-stride + c - 2];
+  for (r = 1; r < bh; ++r) {
+    for (c = 0; c < bw - 2; c++) dst[c] = dst[-stride + c - 2];
     dst += stride;
   }
 }
 
-static INLINE void v_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
+static INLINE void v_predictor(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
                                const uint8_t *above, const uint8_t *left) {
   int r;
   (void)left;
 
-  for (r = 0; r < bs; r++) {
-    memcpy(dst, above, bs);
+  for (r = 0; r < bh; r++) {
+    memcpy(dst, above, bw);
     dst += stride;
   }
 }
 
-static INLINE void h_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
+static INLINE void h_predictor(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
                                const uint8_t *above, const uint8_t *left) {
   int r;
   (void)above;
 
-  for (r = 0; r < bs; r++) {
-    memset(dst, left[r], bs);
+  for (r = 0; r < bh; r++) {
+    memset(dst, left[r], bw);
     dst += stride;
   }
 }
 
 #if CONFIG_ALT_INTRA
 static INLINE int abs_diff(int a, int b) { return (a > b) ? a - b : b - a; }
 
 static INLINE uint16_t paeth_predictor_single(uint16_t left, uint16_t top,
@@ -184,23 +190,24 @@ static INLINE uint16_t paeth_predictor_s
   const int p_top_left = abs_diff(base, top_left);
 
   // Return nearest to base of left, top and top_left.
   return (p_left <= p_top && p_left <= p_top_left)
              ? left
              : (p_top <= p_top_left) ? top : top_left;
 }
 
-static INLINE void paeth_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                   const uint8_t *above, const uint8_t *left) {
+static INLINE void paeth_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                   int bh, const uint8_t *above,
+                                   const uint8_t *left) {
   int r, c;
   const uint8_t ytop_left = above[-1];
 
-  for (r = 0; r < bs; r++) {
-    for (c = 0; c < bs; c++)
+  for (r = 0; r < bh; r++) {
+    for (c = 0; c < bw; c++)
       dst[c] = (uint8_t)paeth_predictor_single(left[r], above[c], ytop_left);
     dst += stride;
   }
 }
 
 // Weights are quadratic from '1' to '1 / block_size', scaled by
 // 2^sm_weight_log2_scale.
 static const int sm_weight_log2_scale = 8;
@@ -231,94 +238,102 @@ static const uint8_t sm_weight_arrays[2 
   255, 248, 240, 233, 225, 218, 210, 203, 196, 189, 182, 176, 169, 163, 156,
   150, 144, 138, 133, 127, 121, 116, 111, 106, 101, 96, 91, 86, 82, 77, 73, 69,
   65, 61, 57, 54, 50, 47, 44, 41, 38, 35, 32, 29, 27, 25, 22, 20, 18, 16, 15,
   13, 12, 10, 9, 8, 7, 6, 6, 5, 5, 4, 4, 4,
 #endif  // CONFIG_TX64X64
 };
 
 // Some basic checks on weights for smooth predictor.
-#define sm_weights_sanity_checks(weights, weights_scale, pred_scale) \
-  assert(weights[0] < weights_scale);                                \
-  assert(weights_scale - weights[bs - 1] < weights_scale);           \
+#define sm_weights_sanity_checks(weights_w, weights_h, weights_scale, \
+                                 pred_scale)                          \
+  assert(weights_w[0] < weights_scale);                               \
+  assert(weights_h[0] < weights_scale);                               \
+  assert(weights_scale - weights_w[bw - 1] < weights_scale);          \
+  assert(weights_scale - weights_h[bh - 1] < weights_scale);          \
   assert(pred_scale < 31)  // ensures no overflow when calculating predictor.
 
 #define divide_round(value, bits) (((value) + (1 << ((bits)-1))) >> (bits))
 
-static INLINE void smooth_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                    const uint8_t *above, const uint8_t *left) {
-  const uint8_t below_pred = left[bs - 1];   // estimated by bottom-left pixel
-  const uint8_t right_pred = above[bs - 1];  // estimated by top-right pixel
-  const uint8_t *const sm_weights = sm_weight_arrays + bs;
+static INLINE void smooth_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                    int bh, const uint8_t *above,
+                                    const uint8_t *left) {
+  const uint8_t below_pred = left[bh - 1];   // estimated by bottom-left pixel
+  const uint8_t right_pred = above[bw - 1];  // estimated by top-right pixel
+  const uint8_t *const sm_weights_w = sm_weight_arrays + bw;
+  const uint8_t *const sm_weights_h = sm_weight_arrays + bh;
   // scale = 2 * 2^sm_weight_log2_scale
   const int log2_scale = 1 + sm_weight_log2_scale;
   const uint16_t scale = (1 << sm_weight_log2_scale);
-  sm_weights_sanity_checks(sm_weights, scale, log2_scale + sizeof(*dst));
+  sm_weights_sanity_checks(sm_weights_w, sm_weights_h, scale,
+                           log2_scale + sizeof(*dst));
   int r;
-  for (r = 0; r < bs; ++r) {
+  for (r = 0; r < bh; ++r) {
     int c;
-    for (c = 0; c < bs; ++c) {
+    for (c = 0; c < bw; ++c) {
       const uint8_t pixels[] = { above[c], below_pred, left[r], right_pred };
-      const uint8_t weights[] = { sm_weights[r], scale - sm_weights[r],
-                                  sm_weights[c], scale - sm_weights[c] };
+      const uint8_t weights[] = { sm_weights_h[r], scale - sm_weights_h[r],
+                                  sm_weights_w[c], scale - sm_weights_w[c] };
       uint32_t this_pred = 0;
       int i;
-      assert(scale >= sm_weights[r] && scale >= sm_weights[c]);
+      assert(scale >= sm_weights_h[r] && scale >= sm_weights_w[c]);
       for (i = 0; i < 4; ++i) {
         this_pred += weights[i] * pixels[i];
       }
       dst[c] = clip_pixel(divide_round(this_pred, log2_scale));
     }
     dst += stride;
   }
 }
 
 #if CONFIG_SMOOTH_HV
-static INLINE void smooth_v_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                      const uint8_t *above,
+static INLINE void smooth_v_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                      int bh, const uint8_t *above,
                                       const uint8_t *left) {
-  const uint8_t below_pred = left[bs - 1];  // estimated by bottom-left pixel
-  const uint8_t *const sm_weights = sm_weight_arrays + bs;
+  const uint8_t below_pred = left[bh - 1];  // estimated by bottom-left pixel
+  const uint8_t *const sm_weights = sm_weight_arrays + bh;
   // scale = 2^sm_weight_log2_scale
   const int log2_scale = sm_weight_log2_scale;
   const uint16_t scale = (1 << sm_weight_log2_scale);
-  sm_weights_sanity_checks(sm_weights, scale, log2_scale + sizeof(*dst));
+  sm_weights_sanity_checks(sm_weights, sm_weights, scale,
+                           log2_scale + sizeof(*dst));
 
   int r;
-  for (r = 0; r < bs; r++) {
+  for (r = 0; r < bh; r++) {
     int c;
-    for (c = 0; c < bs; ++c) {
+    for (c = 0; c < bw; ++c) {
       const uint8_t pixels[] = { above[c], below_pred };
       const uint8_t weights[] = { sm_weights[r], scale - sm_weights[r] };
       uint32_t this_pred = 0;
       assert(scale >= sm_weights[r]);
       int i;
       for (i = 0; i < 2; ++i) {
         this_pred += weights[i] * pixels[i];
       }
       dst[c] = clip_pixel(divide_round(this_pred, log2_scale));
     }
     dst += stride;
   }
 }
 
-static INLINE void smooth_h_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                      const uint8_t *above,
+static INLINE void smooth_h_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                      int bh, const uint8_t *above,
                                       const uint8_t *left) {
-  const uint8_t right_pred = above[bs - 1];  // estimated by top-right pixel
-  const uint8_t *const sm_weights = sm_weight_arrays + bs;
+  const uint8_t right_pred = above[bw - 1];  // estimated by top-right pixel
+  const uint8_t *const sm_weights = sm_weight_arrays + bw;
   // scale = 2^sm_weight_log2_scale
   const int log2_scale = sm_weight_log2_scale;
   const uint16_t scale = (1 << sm_weight_log2_scale);
-  sm_weights_sanity_checks(sm_weights, scale, log2_scale + sizeof(*dst));
+  sm_weights_sanity_checks(sm_weights, sm_weights, scale,
+                           log2_scale + sizeof(*dst));
 
   int r;
-  for (r = 0; r < bs; r++) {
+  for (r = 0; r < bh; r++) {
     int c;
-    for (c = 0; c < bs; ++c) {
+    for (c = 0; c < bw; ++c) {
       const uint8_t pixels[] = { left[r], right_pred };
       const uint8_t weights[] = { sm_weights[c], scale - sm_weights[c] };
       uint32_t this_pred = 0;
       assert(scale >= sm_weights[c]);
       int i;
       for (i = 0; i < 2; ++i) {
         this_pred += weights[i] * pixels[i];
       }
@@ -326,84 +341,88 @@ static INLINE void smooth_h_predictor(ui
     }
     dst += stride;
   }
 }
 #endif  // CONFIG_SMOOTH_HV
 
 #else
 
-static INLINE void tm_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
+static INLINE void tm_predictor(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
                                 const uint8_t *above, const uint8_t *left) {
   int r, c;
   int ytop_left = above[-1];
 
-  for (r = 0; r < bs; r++) {
-    for (c = 0; c < bs; c++)
+  for (r = 0; r < bh; r++) {
+    for (c = 0; c < bw; c++)
       dst[c] = clip_pixel(left[r] + above[c] - ytop_left);
     dst += stride;
   }
 }
 #endif  // CONFIG_ALT_INTRA
 
-static INLINE void dc_128_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                    const uint8_t *above, const uint8_t *left) {
+static INLINE void dc_128_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                    int bh, const uint8_t *above,
+                                    const uint8_t *left) {
   int r;
   (void)above;
   (void)left;
 
-  for (r = 0; r < bs; r++) {
-    memset(dst, 128, bs);
+  for (r = 0; r < bh; r++) {
+    memset(dst, 128, bw);
     dst += stride;
   }
 }
 
-static INLINE void dc_left_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                     const uint8_t *above,
+static INLINE void dc_left_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                     int bh, const uint8_t *above,
                                      const uint8_t *left) {
   int i, r, expected_dc, sum = 0;
   (void)above;
 
-  for (i = 0; i < bs; i++) sum += left[i];
-  expected_dc = (sum + (bs >> 1)) / bs;
+  for (i = 0; i < bh; i++) sum += left[i];
+  expected_dc = (sum + (bh >> 1)) / bh;
 
-  for (r = 0; r < bs; r++) {
-    memset(dst, expected_dc, bs);
+  for (r = 0; r < bh; r++) {
+    memset(dst, expected_dc, bw);
     dst += stride;
   }
 }
 
-static INLINE void dc_top_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
-                                    const uint8_t *above, const uint8_t *left) {
+static INLINE void dc_top_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
+                                    int bh, const uint8_t *above,
+                                    const uint8_t *left) {
   int i, r, expected_dc, sum = 0;
   (void)left;
 
-  for (i = 0; i < bs; i++) sum += above[i];
-  expected_dc = (sum + (bs >> 1)) / bs;
+  for (i = 0; i < bw; i++) sum += above[i];
+  expected_dc = (sum + (bw >> 1)) / bw;
 
-  for (r = 0; r < bs; r++) {
-    memset(dst, expected_dc, bs);
+  for (r = 0; r < bh; r++) {
+    memset(dst, expected_dc, bw);
     dst += stride;
   }
 }
 
-static INLINE void dc_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
+static INLINE void dc_predictor(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
                                 const uint8_t *above, const uint8_t *left) {
   int i, r, expected_dc, sum = 0;
-  const int count = 2 * bs;
+  const int count = bw + bh;
 
-  for (i = 0; i < bs; i++) {
+  for (i = 0; i < bw; i++) {
     sum += above[i];
+  }
+  for (i = 0; i < bh; i++) {
     sum += left[i];
   }
 
   expected_dc = (sum + (count >> 1)) / count;
 
-  for (r = 0; r < bs; r++) {
-    memset(dst, expected_dc, bs);
+  for (r = 0; r < bh; r++) {
+    memset(dst, expected_dc, bw);
     dst += stride;
   }
 }
 
 void aom_d45e_predictor_2x2_c(uint8_t *dst, ptrdiff_t stride,
                               const uint8_t *above, const uint8_t *left) {
   const int A = above[0];
   const int B = above[1];
@@ -541,154 +560,154 @@ void aom_d153_predictor_4x4_c(uint8_t *d
   DST(1, 0) = DST(3, 1) = AVG3(I, X, A);
   DST(1, 1) = DST(3, 2) = AVG3(J, I, X);
   DST(1, 2) = DST(3, 3) = AVG3(K, J, I);
   DST(1, 3) = AVG3(L, K, J);
 }
 
 #if CONFIG_HIGHBITDEPTH
 static INLINE void highbd_d207e_predictor(uint16_t *dst, ptrdiff_t stride,
-                                          int bs, const uint16_t *above,
+                                          int bw, int bh, const uint16_t *above,
                                           const uint16_t *left, int bd) {
   int r, c;
   (void)above;
   (void)bd;
 
-  for (r = 0; r < bs; ++r) {
-    for (c = 0; c < bs; ++c) {
+  for (r = 0; r < bh; ++r) {
+    for (c = 0; c < bw; ++c) {
       dst[c] = c & 1 ? AVG3(left[(c >> 1) + r], left[(c >> 1) + r + 1],
                             left[(c >> 1) + r + 2])
                      : AVG2(left[(c >> 1) + r], left[(c >> 1) + r + 1]);
     }
     dst += stride;
   }
 }
 
 static INLINE void highbd_d63e_predictor(uint16_t *dst, ptrdiff_t stride,
-                                         int bs, const uint16_t *above,
+                                         int bw, int bh, const uint16_t *above,
                                          const uint16_t *left, int bd) {
   int r, c;
   (void)left;
   (void)bd;
-  for (r = 0; r < bs; ++r) {
-    for (c = 0; c < bs; ++c) {
+  for (r = 0; r < bh; ++r) {
+    for (c = 0; c < bw; ++c) {
       dst[c] = r & 1 ? AVG3(above[(r >> 1) + c], above[(r >> 1) + c + 1],
                             above[(r >> 1) + c + 2])
                      : AVG2(above[(r >> 1) + c], above[(r >> 1) + c + 1]);
     }
     dst += stride;
   }
 }
 
 static INLINE void highbd_d45e_predictor(uint16_t *dst, ptrdiff_t stride,
-                                         int bs, const uint16_t *above,
+                                         int bw, int bh, const uint16_t *above,
                                          const uint16_t *left, int bd) {
   int r, c;
   (void)left;
   (void)bd;
-  for (r = 0; r < bs; ++r) {
-    for (c = 0; c < bs; ++c) {
+  for (r = 0; r < bh; ++r) {
+    for (c = 0; c < bw; ++c) {
       dst[c] = AVG3(above[r + c], above[r + c + 1],
-                    above[r + c + 1 + (r + c + 2 < bs * 2)]);
+                    above[r + c + 1 + (r + c + 2 < bw + bh)]);
     }
     dst += stride;
   }
 }
 
 static INLINE void highbd_d117_predictor(uint16_t *dst, ptrdiff_t stride,
-                                         int bs, const uint16_t *above,
+                                         int bw, int bh, const uint16_t *above,
                                          const uint16_t *left, int bd) {
   int r, c;
   (void)bd;
 
   // first row
-  for (c = 0; c < bs; c++) dst[c] = AVG2(above[c - 1], above[c]);
+  for (c = 0; c < bw; c++) dst[c] = AVG2(above[c - 1], above[c]);
   dst += stride;
 
   // second row
   dst[0] = AVG3(left[0], above[-1], above[0]);
-  for (c = 1; c < bs; c++) dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
+  for (c = 1; c < bw; c++) dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
   dst += stride;
 
   // the rest of first col
   dst[0] = AVG3(above[-1], left[0], left[1]);
-  for (r = 3; r < bs; ++r)
+  for (r = 3; r < bh; ++r)
     dst[(r - 2) * stride] = AVG3(left[r - 3], left[r - 2], left[r - 1]);
 
   // the rest of the block
-  for (r = 2; r < bs; ++r) {
-    for (c = 1; c < bs; c++) dst[c] = dst[-2 * stride + c - 1];
+  for (r = 2; r < bh; ++r) {
+    for (c = 1; c < bw; c++) dst[c] = dst[-2 * stride + c - 1];
     dst += stride;
   }
 }
 
 static INLINE void highbd_d135_predictor(uint16_t *dst, ptrdiff_t stride,
-                                         int bs, const uint16_t *above,
+                                         int bw, int bh, const uint16_t *above,
                                          const uint16_t *left, int bd) {
   int r, c;
   (void)bd;
   dst[0] = AVG3(left[0], above[-1], above[0]);
-  for (c = 1; c < bs; c++) dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
+  for (c = 1; c < bw; c++) dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
 
   dst[stride] = AVG3(above[-1], left[0], left[1]);
-  for (r = 2; r < bs; ++r)
+  for (r = 2; r < bh; ++r)
     dst[r * stride] = AVG3(left[r - 2], left[r - 1], left[r]);
 
   dst += stride;
-  for (r = 1; r < bs; ++r) {
-    for (c = 1; c < bs; c++) dst[c] = dst[-stride + c - 1];
+  for (r = 1; r < bh; ++r) {
+    for (c = 1; c < bw; c++) dst[c] = dst[-stride + c - 1];
     dst += stride;
   }
 }
 
 static INLINE void highbd_d153_predictor(uint16_t *dst, ptrdiff_t stride,
-                                         int bs, const uint16_t *above,
+                                         int bw, int bh, const uint16_t *above,
                                          const uint16_t *left, int bd) {
   int r, c;
   (void)bd;
   dst[0] = AVG2(above[-1], left[0]);
-  for (r = 1; r < bs; r++) dst[r * stride] = AVG2(left[r - 1], left[r]);
+  for (r = 1; r < bh; r++) dst[r * stride] = AVG2(left[r - 1], left[r]);
   dst++;
 
   dst[0] = AVG3(left[0], above[-1], above[0]);
   dst[stride] = AVG3(above[-1], left[0], left[1]);
-  for (r = 2; r < bs; r++)
+  for (r = 2; r < bh; r++)
     dst[r * stride] = AVG3(left[r - 2], left[r - 1], left[r]);
   dst++;
 
-  for (c = 0; c < bs - 2; c++)
+  for (c = 0; c < bw - 2; c++)
     dst[c] = AVG3(above[c - 1], above[c], above[c + 1]);
   dst += stride;
 
-  for (r = 1; r < bs; ++r) {
-    for (c = 0; c < bs - 2; c++) dst[c] = dst[-stride + c - 2];
+  for (r = 1; r < bh; ++r) {
+    for (c = 0; c < bw - 2; c++) dst[c] = dst[-stride + c - 2];
     dst += stride;
   }
 }
 
-static INLINE void highbd_v_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
-                                      const uint16_t *above,
+static INLINE void highbd_v_predictor(uint16_t *dst, ptrdiff_t stride, int bw,
+                                      int bh, const uint16_t *above,
                                       const uint16_t *left, int bd) {
   int r;
   (void)left;
   (void)bd;
-  for (r = 0; r < bs; r++) {
-    memcpy(dst, above, bs * sizeof(uint16_t));
+  for (r = 0; r < bh; r++) {
+    memcpy(dst, above, bw * sizeof(uint16_t));
     dst += stride;
   }
 }
 
-static INLINE void highbd_h_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
-                                      const uint16_t *above,
+static INLINE void highbd_h_predictor(uint16_t *dst, ptrdiff_t stride, int bw,
+                                      int bh, const uint16_t *above,
                                       const uint16_t *left, int bd) {
   int r;
   (void)above;
   (void)bd;
-  for (r = 0; r < bs; r++) {
-    aom_memset16(dst, left[r], bs);
+  for (r = 0; r < bh; r++) {
+    aom_memset16(dst, left[r], bw);
     dst += stride;
   }
 }
 
 void aom_highbd_d207_predictor_2x2_c(uint16_t *dst, ptrdiff_t stride,
                                      const uint16_t *above,
                                      const uint16_t *left, int bd) {
   const int I = left[0];
@@ -772,294 +791,328 @@ void aom_highbd_d153_predictor_2x2_c(uin
   DST(0, 0) = AVG2(I, X);
   DST(0, 1) = AVG2(J, I);
   DST(1, 0) = AVG3(I, X, A);
   DST(1, 1) = AVG3(J, I, X);
 }
 
 #if CONFIG_ALT_INTRA
 static INLINE void highbd_paeth_predictor(uint16_t *dst, ptrdiff_t stride,
-                                          int bs, const uint16_t *above,
+                                          int bw, int bh, const uint16_t *above,
                                           const uint16_t *left, int bd) {
   int r, c;
   const uint16_t ytop_left = above[-1];
   (void)bd;
 
-  for (r = 0; r < bs; r++) {
-    for (c = 0; c < bs; c++)
+  for (r = 0; r < bh; r++) {
+    for (c = 0; c < bw; c++)
       dst[c] = paeth_predictor_single(left[r], above[c], ytop_left);
     dst += stride;
   }
 }
 
 static INLINE void highbd_smooth_predictor(uint16_t *dst, ptrdiff_t stride,
-                                           int bs, const uint16_t *above,
+                                           int bw, int bh,
+                                           const uint16_t *above,
                                            const uint16_t *left, int bd) {
-  const uint16_t below_pred = left[bs - 1];   // estimated by bottom-left pixel
-  const uint16_t right_pred = above[bs - 1];  // estimated by top-right pixel
-  const uint8_t *const sm_weights = sm_weight_arrays + bs;
+  const uint16_t below_pred = left[bh - 1];   // estimated by bottom-left pixel
+  const uint16_t right_pred = above[bw - 1];  // estimated by top-right pixel
+  const uint8_t *const sm_weights_w = sm_weight_arrays + bw;
+  const uint8_t *const sm_weights_h = sm_weight_arrays + bh;
   // scale = 2 * 2^sm_weight_log2_scale
   const int log2_scale = 1 + sm_weight_log2_scale;
   const uint16_t scale = (1 << sm_weight_log2_scale);
-  sm_weights_sanity_checks(sm_weights, scale, log2_scale + sizeof(*dst));
+  sm_weights_sanity_checks(sm_weights_w, sm_weights_h, scale,
+                           log2_scale + sizeof(*dst));
   int r;
-  for (r = 0; r < bs; ++r) {
+  for (r = 0; r < bh; ++r) {
     int c;
-    for (c = 0; c < bs; ++c) {
+    for (c = 0; c < bw; ++c) {
       const uint16_t pixels[] = { above[c], below_pred, left[r], right_pred };
-      const uint8_t weights[] = { sm_weights[r], scale - sm_weights[r],
-                                  sm_weights[c], scale - sm_weights[c] };
+      const uint8_t weights[] = { sm_weights_h[r], scale - sm_weights_h[r],
+                                  sm_weights_w[c], scale - sm_weights_w[c] };
       uint32_t this_pred = 0;
       int i;
-      assert(scale >= sm_weights[r] && scale >= sm_weights[c]);
+      assert(scale >= sm_weights_h[r] && scale >= sm_weights_w[c]);
       for (i = 0; i < 4; ++i) {
         this_pred += weights[i] * pixels[i];
       }
       dst[c] = clip_pixel_highbd(divide_round(this_pred, log2_scale), bd);
     }
     dst += stride;
   }
 }
 
 #if CONFIG_SMOOTH_HV
 static INLINE void highbd_smooth_v_predictor(uint16_t *dst, ptrdiff_t stride,
-                                             int bs, const uint16_t *above,
+                                             int bw, int bh,
+                                             const uint16_t *above,
                                              const uint16_t *left, int bd) {
-  const uint16_t below_pred = left[bs - 1];  // estimated by bottom-left pixel
-  const uint8_t *const sm_weights = sm_weight_arrays + bs;
+  const uint16_t below_pred = left[bh - 1];  // estimated by bottom-left pixel
+  const uint8_t *const sm_weights = sm_weight_arrays + bh;
   // scale = 2^sm_weight_log2_scale
   const int log2_scale = sm_weight_log2_scale;
   const uint16_t scale = (1 << sm_weight_log2_scale);
-  sm_weights_sanity_checks(sm_weights, scale, log2_scale + sizeof(*dst));
+  sm_weights_sanity_checks(sm_weights, sm_weights, scale,
+                           log2_scale + sizeof(*dst));
 
   int r;
-  for (r = 0; r < bs; r++) {
+  for (r = 0; r < bh; r++) {
     int c;
-    for (c = 0; c < bs; ++c) {
+    for (c = 0; c < bw; ++c) {
       const uint16_t pixels[] = { above[c], below_pred };
       const uint8_t weights[] = { sm_weights[r], scale - sm_weights[r] };
       uint32_t this_pred = 0;
       assert(scale >= sm_weights[r]);
       int i;
       for (i = 0; i < 2; ++i) {
         this_pred += weights[i] * pixels[i];
       }
       dst[c] = clip_pixel_highbd(divide_round(this_pred, log2_scale), bd);
     }
     dst += stride;
   }
 }
 
 static INLINE void highbd_smooth_h_predictor(uint16_t *dst, ptrdiff_t stride,
-                                             int bs, const uint16_t *above,
+                                             int bw, int bh,
+                                             const uint16_t *above,
                                              const uint16_t *left, int bd) {
-  const uint16_t right_pred = above[bs - 1];  // estimated by top-right pixel
-  const uint8_t *const sm_weights = sm_weight_arrays + bs;
+  const uint16_t right_pred = above[bw - 1];  // estimated by top-right pixel
+  const uint8_t *const sm_weights = sm_weight_arrays + bw;
   // scale = 2^sm_weight_log2_scale
   const int log2_scale = sm_weight_log2_scale;
   const uint16_t scale = (1 << sm_weight_log2_scale);
-  sm_weights_sanity_checks(sm_weights, scale, log2_scale + sizeof(*dst));
+  sm_weights_sanity_checks(sm_weights, sm_weights, scale,
+                           log2_scale + sizeof(*dst));
 
   int r;
-  for (r = 0; r < bs; r++) {
+  for (r = 0; r < bh; r++) {
     int c;
-    for (c = 0; c < bs; ++c) {
+    for (c = 0; c < bw; ++c) {
       const uint16_t pixels[] = { left[r], right_pred };
       const uint8_t weights[] = { sm_weights[c], scale - sm_weights[c] };
       uint32_t this_pred = 0;
       assert(scale >= sm_weights[c]);
       int i;
       for (i = 0; i < 2; ++i) {
         this_pred += weights[i] * pixels[i];
       }
       dst[c] = clip_pixel_highbd(divide_round(this_pred, log2_scale), bd);
     }
     dst += stride;
   }
 }
 #endif
 
 #else
-static INLINE void highbd_tm_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
-                                       const uint16_t *above,
+static INLINE void highbd_tm_predictor(uint16_t *dst, ptrdiff_t stride, int bw,
+                                       int bh, const uint16_t *above,
                                        const uint16_t *left, int bd) {
   int r, c;
   int ytop_left = above[-1];
   (void)bd;
 
-  for (r = 0; r < bs; r++) {
-    for (c = 0; c < bs; c++)
+  for (r = 0; r < bh; r++) {
+    for (c = 0; c < bw; c++)
       dst[c] = clip_pixel_highbd(left[r] + above[c] - ytop_left, bd);
     dst += stride;
   }
 }
 #endif  // CONFIG_ALT_INTRA
 
 static INLINE void highbd_dc_128_predictor(uint16_t *dst, ptrdiff_t stride,
-                                           int bs, const uint16_t *above,
+                                           int bw, int bh,
+                                           const uint16_t *above,
                                            const uint16_t *left, int bd) {
   int r;
   (void)above;
   (void)left;
 
-  for (r = 0; r < bs; r++) {
-    aom_memset16(dst, 128 << (bd - 8), bs);
+  for (r = 0; r < bh; r++) {
+    aom_memset16(dst, 128 << (bd - 8), bw);
     dst += stride;
   }
 }
 
 static INLINE void highbd_dc_left_predictor(uint16_t *dst, ptrdiff_t stride,
-                                            int bs, const uint16_t *above,
+                                            int bw, int bh,
+                                            const uint16_t *above,
                                             const uint16_t *left, int bd) {
   int i, r, expected_dc, sum = 0;
   (void)above;
   (void)bd;
 
-  for (i = 0; i < bs; i++) sum += left[i];
-  expected_dc = (sum + (bs >> 1)) / bs;
+  for (i = 0; i < bh; i++) sum += left[i];
+  expected_dc = (sum + (bh >> 1)) / bh;
 
-  for (r = 0; r < bs; r++) {
-    aom_memset16(dst, expected_dc, bs);
+  for (r = 0; r < bh; r++) {
+    aom_memset16(dst, expected_dc, bw);
     dst += stride;
   }
 }
 
 static INLINE void highbd_dc_top_predictor(uint16_t *dst, ptrdiff_t stride,
-                                           int bs, const uint16_t *above,
+                                           int bw, int bh,
+                                           const uint16_t *above,
                                            const uint16_t *left, int bd) {
   int i, r, expected_dc, sum = 0;
   (void)left;
   (void)bd;
 
-  for (i = 0; i < bs; i++) sum += above[i];
-  expected_dc = (sum + (bs >> 1)) / bs;
+  for (i = 0; i < bw; i++) sum += above[i];
+  expected_dc = (sum + (bw >> 1)) / bw;
 
-  for (r = 0; r < bs; r++) {
-    aom_memset16(dst, expected_dc, bs);
+  for (r = 0; r < bh; r++) {
+    aom_memset16(dst, expected_dc, bw);
     dst += stride;
   }
 }
 
-static INLINE void highbd_dc_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
-                                       const uint16_t *above,
+static INLINE void highbd_dc_predictor(uint16_t *dst, ptrdiff_t stride, int bw,
+                                       int bh, const uint16_t *above,
                                        const uint16_t *left, int bd) {
   int i, r, expected_dc, sum = 0;
-  const int count = 2 * bs;
+  const int count = bw + bh;
   (void)bd;
 
-  for (i = 0; i < bs; i++) {
+  for (i = 0; i < bw; i++) {
     sum += above[i];
+  }
+  for (i = 0; i < bh; i++) {
     sum += left[i];
   }
 
   expected_dc = (sum + (count >> 1)) / count;
 
-  for (r = 0; r < bs; r++) {
-    aom_memset16(dst, expected_dc, bs);
+  for (r = 0; r < bh; r++) {
+    aom_memset16(dst, expected_dc, bw);
     dst += stride;
   }
 }
 #endif  // CONFIG_HIGHBITDEPTH
 
 // This serves as a wrapper function, so that all the prediction functions
 // can be unified and accessed as a pointer array. Note that the boundary
 // above and left are not necessarily used all the time.
-#define intra_pred_sized(type, size)                        \
-  void aom_##type##_predictor_##size##x##size##_c(          \
-      uint8_t *dst, ptrdiff_t stride, const uint8_t *above, \
-      const uint8_t *left) {                                \
-    type##_predictor(dst, stride, size, above, left);       \
+#define intra_pred_sized(type, width, height)                  \
+  void aom_##type##_predictor_##width##x##height##_c(          \
+      uint8_t *dst, ptrdiff_t stride, const uint8_t *above,    \
+      const uint8_t *left) {                                   \
+    type##_predictor(dst, stride, width, height, above, left); \
   }
 
 #if CONFIG_HIGHBITDEPTH
-#define intra_pred_highbd_sized(type, size)                        \
-  void aom_highbd_##type##_predictor_##size##x##size##_c(          \
-      uint16_t *dst, ptrdiff_t stride, const uint16_t *above,      \
-      const uint16_t *left, int bd) {                              \
-    highbd_##type##_predictor(dst, stride, size, above, left, bd); \
+#define intra_pred_highbd_sized(type, width, height)                        \
+  void aom_highbd_##type##_predictor_##width##x##height##_c(                \
+      uint16_t *dst, ptrdiff_t stride, const uint16_t *above,               \
+      const uint16_t *left, int bd) {                                       \
+    highbd_##type##_predictor(dst, stride, width, height, above, left, bd); \
   }
 
 /* clang-format off */
 #if CONFIG_TX64X64
-#define intra_pred_allsizes(type) \
-  intra_pred_sized(type, 2) \
-  intra_pred_sized(type, 4) \
-  intra_pred_sized(type, 8) \
-  intra_pred_sized(type, 16) \
-  intra_pred_sized(type, 32) \
-  intra_pred_sized(type, 64) \
-  intra_pred_highbd_sized(type, 2) \
-  intra_pred_highbd_sized(type, 4) \
-  intra_pred_highbd_sized(type, 8) \
-  intra_pred_highbd_sized(type, 16) \
-  intra_pred_highbd_sized(type, 32) \
-  intra_pred_highbd_sized(type, 64)
-
+#define intra_pred_rectangular(type) \
+  intra_pred_sized(type, 4, 8) \
+  intra_pred_sized(type, 8, 4) \
+  intra_pred_sized(type, 8, 16) \
+  intra_pred_sized(type, 16, 8) \
+  intra_pred_sized(type, 16, 32) \
+  intra_pred_sized(type, 32, 16) \
+  intra_pred_highbd_sized(type, 4, 8) \
+  intra_pred_highbd_sized(type, 8, 4) \
+  intra_pred_highbd_sized(type, 8, 16) \
+  intra_pred_highbd_sized(type, 16, 8) \
+  intra_pred_highbd_sized(type, 16, 32) \
+  intra_pred_highbd_sized(type, 32, 16)
 #define intra_pred_above_4x4(type) \
-  intra_pred_sized(type, 8) \
-  intra_pred_sized(type, 16) \
-  intra_pred_sized(type, 32) \
-  intra_pred_sized(type, 64) \
-  intra_pred_highbd_sized(type, 4) \
-  intra_pred_highbd_sized(type, 8) \
-  intra_pred_highbd_sized(type, 16) \
-  intra_pred_highbd_sized(type, 32) \
-  intra_pred_highbd_sized(type, 64)
-#else  // CONFIG_TX64X64
+  intra_pred_sized(type, 8, 8) \
+  intra_pred_sized(type, 16, 16) \
+  intra_pred_sized(type, 32, 32) \
+  intra_pred_sized(type, 64, 64) \
+  intra_pred_highbd_sized(type, 4, 4) \
+  intra_pred_highbd_sized(type, 8, 8) \
+  intra_pred_highbd_sized(type, 16, 16) \
+  intra_pred_highbd_sized(type, 32, 32) \
+  intra_pred_highbd_sized(type, 64, 64) \
+  intra_pred_rectangular(type)
 #define intra_pred_allsizes(type) \
-  intra_pred_sized(type, 2) \
-  intra_pred_sized(type, 4) \
-  intra_pred_sized(type, 8) \
-  intra_pred_sized(type, 16) \
-  intra_pred_sized(type, 32) \
-  intra_pred_highbd_sized(type, 2) \
-  intra_pred_highbd_sized(type, 4) \
-  intra_pred_highbd_sized(type, 8) \
-  intra_pred_highbd_sized(type, 16) \
-  intra_pred_highbd_sized(type, 32)
-
+  intra_pred_sized(type, 2, 2) \
+  intra_pred_sized(type, 4, 4) \
+  intra_pred_highbd_sized(type, 2, 2) \
+  intra_pred_above_4x4(type)
+#else  // CONFIG_TX64X64
+#define intra_pred_rectangular(type) \
+  intra_pred_sized(type, 4, 8) \
+  intra_pred_sized(type, 8, 4) \
+  intra_pred_sized(type, 8, 16) \
+  intra_pred_sized(type, 16, 8) \
+  intra_pred_sized(type, 16, 32) \
+  intra_pred_sized(type, 32, 16) \
+  intra_pred_highbd_sized(type, 4, 8) \
+  intra_pred_highbd_sized(type, 8, 4) \
+  intra_pred_highbd_sized(type, 8, 16) \
+  intra_pred_highbd_sized(type, 16, 8) \
+  intra_pred_highbd_sized(type, 16, 32) \
+  intra_pred_highbd_sized(type, 32, 16)
 #define intra_pred_above_4x4(type) \
-  intra_pred_sized(type, 8) \
-  intra_pred_sized(type, 16) \
-  intra_pred_sized(type, 32) \
-  intra_pred_highbd_sized(type, 4) \
-  intra_pred_highbd_sized(type, 8) \
-  intra_pred_highbd_sized(type, 16) \
-  intra_pred_highbd_sized(type, 32)
+  intra_pred_sized(type, 8, 8) \
+  intra_pred_sized(type, 16, 16) \
+  intra_pred_sized(type, 32, 32) \
+  intra_pred_highbd_sized(type, 4, 4) \
+  intra_pred_highbd_sized(type, 8, 8) \
+  intra_pred_highbd_sized(type, 16, 16) \
+  intra_pred_highbd_sized(type, 32, 32) \
+  intra_pred_rectangular(type)
+#define intra_pred_allsizes(type) \
+  intra_pred_sized(type, 2, 2) \
+  intra_pred_sized(type, 4, 4) \
+  intra_pred_highbd_sized(type, 2, 2) \
+  intra_pred_above_4x4(type)
 #endif  // CONFIG_TX64X64
 
 #else
 
 #if CONFIG_TX64X64
-#define intra_pred_allsizes(type) \
-  intra_pred_sized(type, 2) \
-  intra_pred_sized(type, 4) \
-  intra_pred_sized(type, 8) \
-  intra_pred_sized(type, 16) \
-  intra_pred_sized(type, 32) \
-  intra_pred_sized(type, 64)
-
+#define intra_pred_rectangular(type) \
+  intra_pred_sized(type, 4, 8) \
+  intra_pred_sized(type, 8, 4) \
+  intra_pred_sized(type, 8, 16) \
+  intra_pred_sized(type, 16, 8) \
+  intra_pred_sized(type, 16, 32) \
+  intra_pred_sized(type, 32, 16)
 #define intra_pred_above_4x4(type) \
-  intra_pred_sized(type, 8) \
-  intra_pred_sized(type, 16) \
-  intra_pred_sized(type, 32) \
-  intra_pred_sized(type, 64)
-#else  // CONFIG_TX64X64
+  intra_pred_sized(type, 8, 8) \
+  intra_pred_sized(type, 16, 16) \
+  intra_pred_sized(type, 32, 32) \
+  intra_pred_sized(type, 64, 64) \
+  intra_pred_rectangular(type)
 #define intra_pred_allsizes(type) \
-  intra_pred_sized(type, 2) \
-  intra_pred_sized(type, 4) \
-  intra_pred_sized(type, 8) \
-  intra_pred_sized(type, 16) \
-  intra_pred_sized(type, 32)
+  intra_pred_sized(type, 2, 2) \
+  intra_pred_sized(type, 4, 4) \
+  intra_pred_above_4x4(type)
+#else  // CONFIG_TX64X64
+#define intra_pred_rectangular(type) \
+  intra_pred_sized(type, 4, 8) \
+  intra_pred_sized(type, 8, 4) \
+  intra_pred_sized(type, 8, 16) \
+  intra_pred_sized(type, 16, 8) \
+  intra_pred_sized(type, 16, 32) \
+  intra_pred_sized(type, 32, 16)
+#define intra_pred_above_4x4(type) \
+  intra_pred_sized(type, 8, 8) \
+  intra_pred_sized(type, 16, 16) \
+  intra_pred_sized(type, 32, 32) \
+  intra_pred_rectangular(type)
+#define intra_pred_allsizes(type) \
+  intra_pred_sized(type, 2, 2) \
+  intra_pred_sized(type, 4, 4) \
+  intra_pred_above_4x4(type)
+#endif  // CONFIG_TX64X64
 
-#define intra_pred_above_4x4(type) \
-  intra_pred_sized(type, 8) \
-  intra_pred_sized(type, 16) \
-  intra_pred_sized(type, 32)
-#endif  // CONFIG_TX64X64
 #endif  // CONFIG_HIGHBITDEPTH
 
 intra_pred_allsizes(d207e)
 intra_pred_allsizes(d63e)
 intra_pred_above_4x4(d45e)
 intra_pred_above_4x4(d117)
 intra_pred_above_4x4(d135)
 intra_pred_above_4x4(d153)
--- a/third_party/aom/aom_dsp/inv_txfm.c
+++ b/third_party/aom/aom_dsp/inv_txfm.c
@@ -1278,17 +1278,16 @@ void aom_idct32x32_1_add_c(const tran_lo
   if (a1 == 0) return;
 
   for (j = 0; j < 32; ++j) {
     for (i = 0; i < 32; ++i) dest[i] = clip_pixel_add(dest[i], a1);
     dest += stride;
   }
 }
 
-#if CONFIG_HIGHBITDEPTH
 void aom_highbd_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest8,
                                  int stride, int bd) {
   /* 4-point reversible, orthonormal inverse Walsh-Hadamard in 3.5 adds,
      0.5 shifts per pixel. */
   int i;
   tran_low_t output[16];
   tran_high_t a1, b1, c1, d1, e1;
   const tran_low_t *ip = input;
@@ -1369,941 +1368,8 @@ void aom_highbd_iwht4x4_1_add_c(const tr
     dest[dest_stride * 2] =
         highbd_clip_pixel_add(dest[dest_stride * 2], e1, bd);
     dest[dest_stride * 3] =
         highbd_clip_pixel_add(dest[dest_stride * 3], e1, bd);
     ip++;
     dest++;
   }
 }
-
-void aom_highbd_idct4_c(const tran_low_t *input, tran_low_t *output, int bd) {
-  tran_low_t step[4];
-  tran_high_t temp1, temp2;
-  (void)bd;
-  // stage 1
-  temp1 = (input[0] + input[2]) * cospi_16_64;
-  temp2 = (input[0] - input[2]) * cospi_16_64;
-  step[0] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step[1] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = input[1] * cospi_24_64 - input[3] * cospi_8_64;
-  temp2 = input[1] * cospi_8_64 + input[3] * cospi_24_64;
-  step[2] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step[3] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  // stage 2
-  output[0] = HIGHBD_WRAPLOW(step[0] + step[3], bd);
-  output[1] = HIGHBD_WRAPLOW(step[1] + step[2], bd);
-  output[2] = HIGHBD_WRAPLOW(step[1] - step[2], bd);
-  output[3] = HIGHBD_WRAPLOW(step[0] - step[3], bd);
-}
-
-void aom_highbd_idct4x4_16_add_c(const tran_low_t *input, uint8_t *dest8,
-                                 int stride, int bd) {
-  tran_low_t out[4 * 4];
-  tran_low_t *outptr = out;
-  int i, j;
-  tran_low_t temp_in[4], temp_out[4];
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  // Rows
-  for (i = 0; i < 4; ++i) {
-    aom_highbd_idct4_c(input, outptr, bd);
-    input += 4;
-    outptr += 4;
-  }
-
-  // Columns
-  for (i = 0; i < 4; ++i) {
-    for (j = 0; j < 4; ++j) temp_in[j] = out[j * 4 + i];
-    aom_highbd_idct4_c(temp_in, temp_out, bd);
-    for (j = 0; j < 4; ++j) {
-      dest[j * stride + i] = highbd_clip_pixel_add(
-          dest[j * stride + i], ROUND_POWER_OF_TWO(temp_out[j], 4), bd);
-    }
-  }
-}
-
-void aom_highbd_idct4x4_1_add_c(const tran_low_t *input, uint8_t *dest8,
-                                int dest_stride, int bd) {
-  int i;
-  tran_high_t a1;
-  tran_low_t out =
-      HIGHBD_WRAPLOW(dct_const_round_shift(input[0] * cospi_16_64), bd);
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  out = HIGHBD_WRAPLOW(dct_const_round_shift(out * cospi_16_64), bd);
-  a1 = ROUND_POWER_OF_TWO(out, 4);
-
-  for (i = 0; i < 4; i++) {
-    dest[0] = highbd_clip_pixel_add(dest[0], a1, bd);
-    dest[1] = highbd_clip_pixel_add(dest[1], a1, bd);
-    dest[2] = highbd_clip_pixel_add(dest[2], a1, bd);
-    dest[3] = highbd_clip_pixel_add(dest[3], a1, bd);
-    dest += dest_stride;
-  }
-}
-
-void aom_highbd_idct8_c(const tran_low_t *input, tran_low_t *output, int bd) {
-  tran_low_t step1[8], step2[8];
-  tran_high_t temp1, temp2;
-  // stage 1
-  step1[0] = input[0];
-  step1[2] = input[4];
-  step1[1] = input[2];
-  step1[3] = input[6];
-  temp1 = input[1] * cospi_28_64 - input[7] * cospi_4_64;
-  temp2 = input[1] * cospi_4_64 + input[7] * cospi_28_64;
-  step1[4] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[7] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = input[5] * cospi_12_64 - input[3] * cospi_20_64;
-  temp2 = input[5] * cospi_20_64 + input[3] * cospi_12_64;
-  step1[5] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[6] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  // stage 2 & stage 3 - even half
-  aom_highbd_idct4_c(step1, step1, bd);
-
-  // stage 2 - odd half
-  step2[4] = HIGHBD_WRAPLOW(step1[4] + step1[5], bd);
-  step2[5] = HIGHBD_WRAPLOW(step1[4] - step1[5], bd);
-  step2[6] = HIGHBD_WRAPLOW(-step1[6] + step1[7], bd);
-  step2[7] = HIGHBD_WRAPLOW(step1[6] + step1[7], bd);
-
-  // stage 3 - odd half
-  step1[4] = step2[4];
-  temp1 = (step2[6] - step2[5]) * cospi_16_64;
-  temp2 = (step2[5] + step2[6]) * cospi_16_64;
-  step1[5] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[6] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step1[7] = step2[7];
-
-  // stage 4
-  output[0] = HIGHBD_WRAPLOW(step1[0] + step1[7], bd);
-  output[1] = HIGHBD_WRAPLOW(step1[1] + step1[6], bd);
-  output[2] = HIGHBD_WRAPLOW(step1[2] + step1[5], bd);
-  output[3] = HIGHBD_WRAPLOW(step1[3] + step1[4], bd);
-  output[4] = HIGHBD_WRAPLOW(step1[3] - step1[4], bd);
-  output[5] = HIGHBD_WRAPLOW(step1[2] - step1[5], bd);
-  output[6] = HIGHBD_WRAPLOW(step1[1] - step1[6], bd);
-  output[7] = HIGHBD_WRAPLOW(step1[0] - step1[7], bd);
-}
-
-void aom_highbd_iadst4_c(const tran_low_t *input, tran_low_t *output, int bd) {
-  tran_high_t s0, s1, s2, s3, s4, s5, s6, s7;
-
-  tran_low_t x0 = input[0];
-  tran_low_t x1 = input[1];
-  tran_low_t x2 = input[2];
-  tran_low_t x3 = input[3];
-  (void)bd;
-
-  if (!(x0 | x1 | x2 | x3)) {
-    memset(output, 0, 4 * sizeof(*output));
-    return;
-  }
-
-  s0 = sinpi_1_9 * x0;
-  s1 = sinpi_2_9 * x0;
-  s2 = sinpi_3_9 * x1;
-  s3 = sinpi_4_9 * x2;
-  s4 = sinpi_1_9 * x2;
-  s5 = sinpi_2_9 * x3;
-  s6 = sinpi_4_9 * x3;
-  s7 = (tran_high_t)HIGHBD_WRAPLOW(x0 - x2 + x3, bd);
-
-  s0 = s0 + s3 + s5;
-  s1 = s1 - s4 - s6;
-  s3 = s2;
-  s2 = sinpi_3_9 * s7;
-
-  // 1-D transform scaling factor is sqrt(2).
-  // The overall dynamic range is 14b (input) + 14b (multiplication scaling)
-  // + 1b (addition) = 29b.
-  // Hence the output bit depth is 15b.
-  output[0] = HIGHBD_WRAPLOW(dct_const_round_shift(s0 + s3), bd);
-  output[1] = HIGHBD_WRAPLOW(dct_const_round_shift(s1 + s3), bd);
-  output[2] = HIGHBD_WRAPLOW(dct_const_round_shift(s2), bd);
-  output[3] = HIGHBD_WRAPLOW(dct_const_round_shift(s0 + s1 - s3), bd);
-}
-
-void aom_highbd_iadst8_c(const tran_low_t *input, tran_low_t *output, int bd) {
-  tran_high_t s0, s1, s2, s3, s4, s5, s6, s7;
-
-  tran_low_t x0 = input[7];
-  tran_low_t x1 = input[0];
-  tran_low_t x2 = input[5];
-  tran_low_t x3 = input[2];
-  tran_low_t x4 = input[3];
-  tran_low_t x5 = input[4];
-  tran_low_t x6 = input[1];
-  tran_low_t x7 = input[6];
-  (void)bd;
-
-  if (!(x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7)) {
-    memset(output, 0, 8 * sizeof(*output));
-    return;
-  }
-
-  // stage 1
-  s0 = cospi_2_64 * x0 + cospi_30_64 * x1;
-  s1 = cospi_30_64 * x0 - cospi_2_64 * x1;
-  s2 = cospi_10_64 * x2 + cospi_22_64 * x3;
-  s3 = cospi_22_64 * x2 - cospi_10_64 * x3;
-  s4 = cospi_18_64 * x4 + cospi_14_64 * x5;
-  s5 = cospi_14_64 * x4 - cospi_18_64 * x5;
-  s6 = cospi_26_64 * x6 + cospi_6_64 * x7;
-  s7 = cospi_6_64 * x6 - cospi_26_64 * x7;
-
-  x0 = HIGHBD_WRAPLOW(dct_const_round_shift(s0 + s4), bd);
-  x1 = HIGHBD_WRAPLOW(dct_const_round_shift(s1 + s5), bd);
-  x2 = HIGHBD_WRAPLOW(dct_const_round_shift(s2 + s6), bd);
-  x3 = HIGHBD_WRAPLOW(dct_const_round_shift(s3 + s7), bd);
-  x4 = HIGHBD_WRAPLOW(dct_const_round_shift(s0 - s4), bd);
-  x5 = HIGHBD_WRAPLOW(dct_const_round_shift(s1 - s5), bd);
-  x6 = HIGHBD_WRAPLOW(dct_const_round_shift(s2 - s6), bd);
-  x7 = HIGHBD_WRAPLOW(dct_const_round_shift(s3 - s7), bd);
-
-  // stage 2
-  s0 = x0;
-  s1 = x1;
-  s2 = x2;
-  s3 = x3;
-  s4 = cospi_8_64 * x4 + cospi_24_64 * x5;
-  s5 = cospi_24_64 * x4 - cospi_8_64 * x5;
-  s6 = -cospi_24_64 * x6 + cospi_8_64 * x7;
-  s7 = cospi_8_64 * x6 + cospi_24_64 * x7;
-
-  x0 = HIGHBD_WRAPLOW(s0 + s2, bd);
-  x1 = HIGHBD_WRAPLOW(s1 + s3, bd);
-  x2 = HIGHBD_WRAPLOW(s0 - s2, bd);
-  x3 = HIGHBD_WRAPLOW(s1 - s3, bd);
-  x4 = HIGHBD_WRAPLOW(dct_const_round_shift(s4 + s6), bd);
-  x5 = HIGHBD_WRAPLOW(dct_const_round_shift(s5 + s7), bd);
-  x6 = HIGHBD_WRAPLOW(dct_const_round_shift(s4 - s6), bd);
-  x7 = HIGHBD_WRAPLOW(dct_const_round_shift(s5 - s7), bd);
-
-  // stage 3
-  s2 = cospi_16_64 * (x2 + x3);
-  s3 = cospi_16_64 * (x2 - x3);
-  s6 = cospi_16_64 * (x6 + x7);
-  s7 = cospi_16_64 * (x6 - x7);
-
-  x2 = HIGHBD_WRAPLOW(dct_const_round_shift(s2), bd);
-  x3 = HIGHBD_WRAPLOW(dct_const_round_shift(s3), bd);
-  x6 = HIGHBD_WRAPLOW(dct_const_round_shift(s6), bd);
-  x7 = HIGHBD_WRAPLOW(dct_const_round_shift(s7), bd);
-
-  output[0] = HIGHBD_WRAPLOW(x0, bd);
-  output[1] = HIGHBD_WRAPLOW(-x4, bd);
-  output[2] = HIGHBD_WRAPLOW(x6, bd);
-  output[3] = HIGHBD_WRAPLOW(-x2, bd);
-  output[4] = HIGHBD_WRAPLOW(x3, bd);
-  output[5] = HIGHBD_WRAPLOW(-x7, bd);
-  output[6] = HIGHBD_WRAPLOW(x5, bd);
-  output[7] = HIGHBD_WRAPLOW(-x1, bd);
-}
-
-void aom_highbd_idct16_c(const tran_low_t *input, tran_low_t *output, int bd) {
-  tran_low_t step1[16], step2[16];
-  tran_high_t temp1, temp2;
-  (void)bd;
-
-  // stage 1
-  step1[0] = input[0 / 2];
-  step1[1] = input[16 / 2];
-  step1[2] = input[8 / 2];
-  step1[3] = input[24 / 2];
-  step1[4] = input[4 / 2];
-  step1[5] = input[20 / 2];
-  step1[6] = input[12 / 2];
-  step1[7] = input[28 / 2];
-  step1[8] = input[2 / 2];
-  step1[9] = input[18 / 2];
-  step1[10] = input[10 / 2];
-  step1[11] = input[26 / 2];
-  step1[12] = input[6 / 2];
-  step1[13] = input[22 / 2];
-  step1[14] = input[14 / 2];
-  step1[15] = input[30 / 2];
-
-  // stage 2
-  step2[0] = step1[0];
-  step2[1] = step1[1];
-  step2[2] = step1[2];
-  step2[3] = step1[3];
-  step2[4] = step1[4];
-  step2[5] = step1[5];
-  step2[6] = step1[6];
-  step2[7] = step1[7];
-
-  temp1 = step1[8] * cospi_30_64 - step1[15] * cospi_2_64;
-  temp2 = step1[8] * cospi_2_64 + step1[15] * cospi_30_64;
-  step2[8] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[15] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = step1[9] * cospi_14_64 - step1[14] * cospi_18_64;
-  temp2 = step1[9] * cospi_18_64 + step1[14] * cospi_14_64;
-  step2[9] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[14] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = step1[10] * cospi_22_64 - step1[13] * cospi_10_64;
-  temp2 = step1[10] * cospi_10_64 + step1[13] * cospi_22_64;
-  step2[10] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[13] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = step1[11] * cospi_6_64 - step1[12] * cospi_26_64;
-  temp2 = step1[11] * cospi_26_64 + step1[12] * cospi_6_64;
-  step2[11] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[12] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  // stage 3
-  step1[0] = step2[0];
-  step1[1] = step2[1];
-  step1[2] = step2[2];
-  step1[3] = step2[3];
-
-  temp1 = step2[4] * cospi_28_64 - step2[7] * cospi_4_64;
-  temp2 = step2[4] * cospi_4_64 + step2[7] * cospi_28_64;
-  step1[4] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[7] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = step2[5] * cospi_12_64 - step2[6] * cospi_20_64;
-  temp2 = step2[5] * cospi_20_64 + step2[6] * cospi_12_64;
-  step1[5] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[6] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  step1[8] = HIGHBD_WRAPLOW(step2[8] + step2[9], bd);
-  step1[9] = HIGHBD_WRAPLOW(step2[8] - step2[9], bd);
-  step1[10] = HIGHBD_WRAPLOW(-step2[10] + step2[11], bd);
-  step1[11] = HIGHBD_WRAPLOW(step2[10] + step2[11], bd);
-  step1[12] = HIGHBD_WRAPLOW(step2[12] + step2[13], bd);
-  step1[13] = HIGHBD_WRAPLOW(step2[12] - step2[13], bd);
-  step1[14] = HIGHBD_WRAPLOW(-step2[14] + step2[15], bd);
-  step1[15] = HIGHBD_WRAPLOW(step2[14] + step2[15], bd);
-
-  // stage 4
-  temp1 = (step1[0] + step1[1]) * cospi_16_64;
-  temp2 = (step1[0] - step1[1]) * cospi_16_64;
-  step2[0] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[1] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = step1[2] * cospi_24_64 - step1[3] * cospi_8_64;
-  temp2 = step1[2] * cospi_8_64 + step1[3] * cospi_24_64;
-  step2[2] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[3] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step2[4] = HIGHBD_WRAPLOW(step1[4] + step1[5], bd);
-  step2[5] = HIGHBD_WRAPLOW(step1[4] - step1[5], bd);
-  step2[6] = HIGHBD_WRAPLOW(-step1[6] + step1[7], bd);
-  step2[7] = HIGHBD_WRAPLOW(step1[6] + step1[7], bd);
-
-  step2[8] = step1[8];
-  step2[15] = step1[15];
-  temp1 = -step1[9] * cospi_8_64 + step1[14] * cospi_24_64;
-  temp2 = step1[9] * cospi_24_64 + step1[14] * cospi_8_64;
-  step2[9] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[14] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = -step1[10] * cospi_24_64 - step1[13] * cospi_8_64;
-  temp2 = -step1[10] * cospi_8_64 + step1[13] * cospi_24_64;
-  step2[10] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[13] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step2[11] = step1[11];
-  step2[12] = step1[12];
-
-  // stage 5
-  step1[0] = HIGHBD_WRAPLOW(step2[0] + step2[3], bd);
-  step1[1] = HIGHBD_WRAPLOW(step2[1] + step2[2], bd);
-  step1[2] = HIGHBD_WRAPLOW(step2[1] - step2[2], bd);
-  step1[3] = HIGHBD_WRAPLOW(step2[0] - step2[3], bd);
-  step1[4] = step2[4];
-  temp1 = (step2[6] - step2[5]) * cospi_16_64;
-  temp2 = (step2[5] + step2[6]) * cospi_16_64;
-  step1[5] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[6] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step1[7] = step2[7];
-
-  step1[8] = HIGHBD_WRAPLOW(step2[8] + step2[11], bd);
-  step1[9] = HIGHBD_WRAPLOW(step2[9] + step2[10], bd);
-  step1[10] = HIGHBD_WRAPLOW(step2[9] - step2[10], bd);
-  step1[11] = HIGHBD_WRAPLOW(step2[8] - step2[11], bd);
-  step1[12] = HIGHBD_WRAPLOW(-step2[12] + step2[15], bd);
-  step1[13] = HIGHBD_WRAPLOW(-step2[13] + step2[14], bd);
-  step1[14] = HIGHBD_WRAPLOW(step2[13] + step2[14], bd);
-  step1[15] = HIGHBD_WRAPLOW(step2[12] + step2[15], bd);
-
-  // stage 6
-  step2[0] = HIGHBD_WRAPLOW(step1[0] + step1[7], bd);
-  step2[1] = HIGHBD_WRAPLOW(step1[1] + step1[6], bd);
-  step2[2] = HIGHBD_WRAPLOW(step1[2] + step1[5], bd);
-  step2[3] = HIGHBD_WRAPLOW(step1[3] + step1[4], bd);
-  step2[4] = HIGHBD_WRAPLOW(step1[3] - step1[4], bd);
-  step2[5] = HIGHBD_WRAPLOW(step1[2] - step1[5], bd);
-  step2[6] = HIGHBD_WRAPLOW(step1[1] - step1[6], bd);
-  step2[7] = HIGHBD_WRAPLOW(step1[0] - step1[7], bd);
-  step2[8] = step1[8];
-  step2[9] = step1[9];
-  temp1 = (-step1[10] + step1[13]) * cospi_16_64;
-  temp2 = (step1[10] + step1[13]) * cospi_16_64;
-  step2[10] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[13] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = (-step1[11] + step1[12]) * cospi_16_64;
-  temp2 = (step1[11] + step1[12]) * cospi_16_64;
-  step2[11] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[12] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step2[14] = step1[14];
-  step2[15] = step1[15];
-
-  // stage 7
-  output[0] = HIGHBD_WRAPLOW(step2[0] + step2[15], bd);
-  output[1] = HIGHBD_WRAPLOW(step2[1] + step2[14], bd);
-  output[2] = HIGHBD_WRAPLOW(step2[2] + step2[13], bd);
-  output[3] = HIGHBD_WRAPLOW(step2[3] + step2[12], bd);
-  output[4] = HIGHBD_WRAPLOW(step2[4] + step2[11], bd);
-  output[5] = HIGHBD_WRAPLOW(step2[5] + step2[10], bd);
-  output[6] = HIGHBD_WRAPLOW(step2[6] + step2[9], bd);
-  output[7] = HIGHBD_WRAPLOW(step2[7] + step2[8], bd);
-  output[8] = HIGHBD_WRAPLOW(step2[7] - step2[8], bd);
-  output[9] = HIGHBD_WRAPLOW(step2[6] - step2[9], bd);
-  output[10] = HIGHBD_WRAPLOW(step2[5] - step2[10], bd);
-  output[11] = HIGHBD_WRAPLOW(step2[4] - step2[11], bd);
-  output[12] = HIGHBD_WRAPLOW(step2[3] - step2[12], bd);
-  output[13] = HIGHBD_WRAPLOW(step2[2] - step2[13], bd);
-  output[14] = HIGHBD_WRAPLOW(step2[1] - step2[14], bd);
-  output[15] = HIGHBD_WRAPLOW(step2[0] - step2[15], bd);
-}
-
-void aom_highbd_iadst16_c(const tran_low_t *input, tran_low_t *output, int bd) {
-  tran_high_t s0, s1, s2, s3, s4, s5, s6, s7, s8;
-  tran_high_t s9, s10, s11, s12, s13, s14, s15;
-
-  tran_low_t x0 = input[15];
-  tran_low_t x1 = input[0];
-  tran_low_t x2 = input[13];
-  tran_low_t x3 = input[2];
-  tran_low_t x4 = input[11];
-  tran_low_t x5 = input[4];
-  tran_low_t x6 = input[9];
-  tran_low_t x7 = input[6];
-  tran_low_t x8 = input[7];
-  tran_low_t x9 = input[8];
-  tran_low_t x10 = input[5];
-  tran_low_t x11 = input[10];
-  tran_low_t x12 = input[3];
-  tran_low_t x13 = input[12];
-  tran_low_t x14 = input[1];
-  tran_low_t x15 = input[14];
-  (void)bd;
-
-  if (!(x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 |
-        x13 | x14 | x15)) {
-    memset(output, 0, 16 * sizeof(*output));
-    return;
-  }
-
-  // stage 1
-  s0 = x0 * cospi_1_64 + x1 * cospi_31_64;
-  s1 = x0 * cospi_31_64 - x1 * cospi_1_64;
-  s2 = x2 * cospi_5_64 + x3 * cospi_27_64;
-  s3 = x2 * cospi_27_64 - x3 * cospi_5_64;
-  s4 = x4 * cospi_9_64 + x5 * cospi_23_64;
-  s5 = x4 * cospi_23_64 - x5 * cospi_9_64;
-  s6 = x6 * cospi_13_64 + x7 * cospi_19_64;
-  s7 = x6 * cospi_19_64 - x7 * cospi_13_64;
-  s8 = x8 * cospi_17_64 + x9 * cospi_15_64;
-  s9 = x8 * cospi_15_64 - x9 * cospi_17_64;
-  s10 = x10 * cospi_21_64 + x11 * cospi_11_64;
-  s11 = x10 * cospi_11_64 - x11 * cospi_21_64;
-  s12 = x12 * cospi_25_64 + x13 * cospi_7_64;
-  s13 = x12 * cospi_7_64 - x13 * cospi_25_64;
-  s14 = x14 * cospi_29_64 + x15 * cospi_3_64;
-  s15 = x14 * cospi_3_64 - x15 * cospi_29_64;
-
-  x0 = HIGHBD_WRAPLOW(dct_const_round_shift(s0 + s8), bd);
-  x1 = HIGHBD_WRAPLOW(dct_const_round_shift(s1 + s9), bd);
-  x2 = HIGHBD_WRAPLOW(dct_const_round_shift(s2 + s10), bd);
-  x3 = HIGHBD_WRAPLOW(dct_const_round_shift(s3 + s11), bd);
-  x4 = HIGHBD_WRAPLOW(dct_const_round_shift(s4 + s12), bd);
-  x5 = HIGHBD_WRAPLOW(dct_const_round_shift(s5 + s13), bd);
-  x6 = HIGHBD_WRAPLOW(dct_const_round_shift(s6 + s14), bd);
-  x7 = HIGHBD_WRAPLOW(dct_const_round_shift(s7 + s15), bd);
-  x8 = HIGHBD_WRAPLOW(dct_const_round_shift(s0 - s8), bd);
-  x9 = HIGHBD_WRAPLOW(dct_const_round_shift(s1 - s9), bd);
-  x10 = HIGHBD_WRAPLOW(dct_const_round_shift(s2 - s10), bd);
-  x11 = HIGHBD_WRAPLOW(dct_const_round_shift(s3 - s11), bd);
-  x12 = HIGHBD_WRAPLOW(dct_const_round_shift(s4 - s12), bd);
-  x13 = HIGHBD_WRAPLOW(dct_const_round_shift(s5 - s13), bd);
-  x14 = HIGHBD_WRAPLOW(dct_const_round_shift(s6 - s14), bd);
-  x15 = HIGHBD_WRAPLOW(dct_const_round_shift(s7 - s15), bd);
-
-  // stage 2
-  s0 = x0;
-  s1 = x1;
-  s2 = x2;
-  s3 = x3;
-  s4 = x4;
-  s5 = x5;
-  s6 = x6;
-  s7 = x7;
-  s8 = x8 * cospi_4_64 + x9 * cospi_28_64;
-  s9 = x8 * cospi_28_64 - x9 * cospi_4_64;
-  s10 = x10 * cospi_20_64 + x11 * cospi_12_64;
-  s11 = x10 * cospi_12_64 - x11 * cospi_20_64;
-  s12 = -x12 * cospi_28_64 + x13 * cospi_4_64;
-  s13 = x12 * cospi_4_64 + x13 * cospi_28_64;
-  s14 = -x14 * cospi_12_64 + x15 * cospi_20_64;
-  s15 = x14 * cospi_20_64 + x15 * cospi_12_64;
-
-  x0 = HIGHBD_WRAPLOW(s0 + s4, bd);
-  x1 = HIGHBD_WRAPLOW(s1 + s5, bd);
-  x2 = HIGHBD_WRAPLOW(s2 + s6, bd);
-  x3 = HIGHBD_WRAPLOW(s3 + s7, bd);
-  x4 = HIGHBD_WRAPLOW(s0 - s4, bd);
-  x5 = HIGHBD_WRAPLOW(s1 - s5, bd);
-  x6 = HIGHBD_WRAPLOW(s2 - s6, bd);
-  x7 = HIGHBD_WRAPLOW(s3 - s7, bd);
-  x8 = HIGHBD_WRAPLOW(dct_const_round_shift(s8 + s12), bd);
-  x9 = HIGHBD_WRAPLOW(dct_const_round_shift(s9 + s13), bd);
-  x10 = HIGHBD_WRAPLOW(dct_const_round_shift(s10 + s14), bd);
-  x11 = HIGHBD_WRAPLOW(dct_const_round_shift(s11 + s15), bd);
-  x12 = HIGHBD_WRAPLOW(dct_const_round_shift(s8 - s12), bd);
-  x13 = HIGHBD_WRAPLOW(dct_const_round_shift(s9 - s13), bd);
-  x14 = HIGHBD_WRAPLOW(dct_const_round_shift(s10 - s14), bd);
-  x15 = HIGHBD_WRAPLOW(dct_const_round_shift(s11 - s15), bd);
-
-  // stage 3
-  s0 = x0;
-  s1 = x1;
-  s2 = x2;
-  s3 = x3;
-  s4 = x4 * cospi_8_64 + x5 * cospi_24_64;
-  s5 = x4 * cospi_24_64 - x5 * cospi_8_64;
-  s6 = -x6 * cospi_24_64 + x7 * cospi_8_64;
-  s7 = x6 * cospi_8_64 + x7 * cospi_24_64;
-  s8 = x8;
-  s9 = x9;
-  s10 = x10;
-  s11 = x11;
-  s12 = x12 * cospi_8_64 + x13 * cospi_24_64;
-  s13 = x12 * cospi_24_64 - x13 * cospi_8_64;
-  s14 = -x14 * cospi_24_64 + x15 * cospi_8_64;
-  s15 = x14 * cospi_8_64 + x15 * cospi_24_64;
-
-  x0 = HIGHBD_WRAPLOW(s0 + s2, bd);
-  x1 = HIGHBD_WRAPLOW(s1 + s3, bd);
-  x2 = HIGHBD_WRAPLOW(s0 - s2, bd);
-  x3 = HIGHBD_WRAPLOW(s1 - s3, bd);
-  x4 = HIGHBD_WRAPLOW(dct_const_round_shift(s4 + s6), bd);
-  x5 = HIGHBD_WRAPLOW(dct_const_round_shift(s5 + s7), bd);
-  x6 = HIGHBD_WRAPLOW(dct_const_round_shift(s4 - s6), bd);
-  x7 = HIGHBD_WRAPLOW(dct_const_round_shift(s5 - s7), bd);
-  x8 = HIGHBD_WRAPLOW(s8 + s10, bd);
-  x9 = HIGHBD_WRAPLOW(s9 + s11, bd);
-  x10 = HIGHBD_WRAPLOW(s8 - s10, bd);
-  x11 = HIGHBD_WRAPLOW(s9 - s11, bd);
-  x12 = HIGHBD_WRAPLOW(dct_const_round_shift(s12 + s14), bd);
-  x13 = HIGHBD_WRAPLOW(dct_const_round_shift(s13 + s15), bd);
-  x14 = HIGHBD_WRAPLOW(dct_const_round_shift(s12 - s14), bd);
-  x15 = HIGHBD_WRAPLOW(dct_const_round_shift(s13 - s15), bd);
-
-  // stage 4
-  s2 = (-cospi_16_64) * (x2 + x3);
-  s3 = cospi_16_64 * (x2 - x3);
-  s6 = cospi_16_64 * (x6 + x7);
-  s7 = cospi_16_64 * (-x6 + x7);
-  s10 = cospi_16_64 * (x10 + x11);
-  s11 = cospi_16_64 * (-x10 + x11);
-  s14 = (-cospi_16_64) * (x14 + x15);
-  s15 = cospi_16_64 * (x14 - x15);
-
-  x2 = HIGHBD_WRAPLOW(dct_const_round_shift(s2), bd);
-  x3 = HIGHBD_WRAPLOW(dct_const_round_shift(s3), bd);
-  x6 = HIGHBD_WRAPLOW(dct_const_round_shift(s6), bd);
-  x7 = HIGHBD_WRAPLOW(dct_const_round_shift(s7), bd);
-  x10 = HIGHBD_WRAPLOW(dct_const_round_shift(s10), bd);
-  x11 = HIGHBD_WRAPLOW(dct_const_round_shift(s11), bd);
-  x14 = HIGHBD_WRAPLOW(dct_const_round_shift(s14), bd);
-  x15 = HIGHBD_WRAPLOW(dct_const_round_shift(s15), bd);
-
-  output[0] = HIGHBD_WRAPLOW(x0, bd);
-  output[1] = HIGHBD_WRAPLOW(-x8, bd);
-  output[2] = HIGHBD_WRAPLOW(x12, bd);
-  output[3] = HIGHBD_WRAPLOW(-x4, bd);
-  output[4] = HIGHBD_WRAPLOW(x6, bd);
-  output[5] = HIGHBD_WRAPLOW(x14, bd);
-  output[6] = HIGHBD_WRAPLOW(x10, bd);
-  output[7] = HIGHBD_WRAPLOW(x2, bd);
-  output[8] = HIGHBD_WRAPLOW(x3, bd);
-  output[9] = HIGHBD_WRAPLOW(x11, bd);
-  output[10] = HIGHBD_WRAPLOW(x15, bd);
-  output[11] = HIGHBD_WRAPLOW(x7, bd);
-  output[12] = HIGHBD_WRAPLOW(x5, bd);
-  output[13] = HIGHBD_WRAPLOW(-x13, bd);
-  output[14] = HIGHBD_WRAPLOW(x9, bd);
-  output[15] = HIGHBD_WRAPLOW(-x1, bd);
-}
-
-void aom_highbd_idct32_c(const tran_low_t *input, tran_low_t *output, int bd) {
-  tran_low_t step1[32], step2[32];
-  tran_high_t temp1, temp2;
-  (void)bd;
-
-  // stage 1
-  step1[0] = input[0];
-  step1[1] = input[16];
-  step1[2] = input[8];
-  step1[3] = input[24];
-  step1[4] = input[4];
-  step1[5] = input[20];
-  step1[6] = input[12];
-  step1[7] = input[28];
-  step1[8] = input[2];
-  step1[9] = input[18];
-  step1[10] = input[10];
-  step1[11] = input[26];
-  step1[12] = input[6];
-  step1[13] = input[22];
-  step1[14] = input[14];
-  step1[15] = input[30];
-
-  temp1 = input[1] * cospi_31_64 - input[31] * cospi_1_64;
-  temp2 = input[1] * cospi_1_64 + input[31] * cospi_31_64;
-  step1[16] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[31] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = input[17] * cospi_15_64 - input[15] * cospi_17_64;
-  temp2 = input[17] * cospi_17_64 + input[15] * cospi_15_64;
-  step1[17] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[30] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = input[9] * cospi_23_64 - input[23] * cospi_9_64;
-  temp2 = input[9] * cospi_9_64 + input[23] * cospi_23_64;
-  step1[18] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[29] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = input[25] * cospi_7_64 - input[7] * cospi_25_64;
-  temp2 = input[25] * cospi_25_64 + input[7] * cospi_7_64;
-  step1[19] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[28] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = input[5] * cospi_27_64 - input[27] * cospi_5_64;
-  temp2 = input[5] * cospi_5_64 + input[27] * cospi_27_64;
-  step1[20] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[27] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = input[21] * cospi_11_64 - input[11] * cospi_21_64;
-  temp2 = input[21] * cospi_21_64 + input[11] * cospi_11_64;
-  step1[21] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[26] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = input[13] * cospi_19_64 - input[19] * cospi_13_64;
-  temp2 = input[13] * cospi_13_64 + input[19] * cospi_19_64;
-  step1[22] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[25] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = input[29] * cospi_3_64 - input[3] * cospi_29_64;
-  temp2 = input[29] * cospi_29_64 + input[3] * cospi_3_64;
-  step1[23] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[24] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  // stage 2
-  step2[0] = step1[0];
-  step2[1] = step1[1];
-  step2[2] = step1[2];
-  step2[3] = step1[3];
-  step2[4] = step1[4];
-  step2[5] = step1[5];
-  step2[6] = step1[6];
-  step2[7] = step1[7];
-
-  temp1 = step1[8] * cospi_30_64 - step1[15] * cospi_2_64;
-  temp2 = step1[8] * cospi_2_64 + step1[15] * cospi_30_64;
-  step2[8] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[15] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = step1[9] * cospi_14_64 - step1[14] * cospi_18_64;
-  temp2 = step1[9] * cospi_18_64 + step1[14] * cospi_14_64;
-  step2[9] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[14] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = step1[10] * cospi_22_64 - step1[13] * cospi_10_64;
-  temp2 = step1[10] * cospi_10_64 + step1[13] * cospi_22_64;
-  step2[10] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[13] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  temp1 = step1[11] * cospi_6_64 - step1[12] * cospi_26_64;
-  temp2 = step1[11] * cospi_26_64 + step1[12] * cospi_6_64;
-  step2[11] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[12] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  step2[16] = HIGHBD_WRAPLOW(step1[16] + step1[17], bd);
-  step2[17] = HIGHBD_WRAPLOW(step1[16] - step1[17], bd);
-  step2[18] = HIGHBD_WRAPLOW(-step1[18] + step1[19], bd);
-  step2[19] = HIGHBD_WRAPLOW(step1[18] + step1[19], bd);
-  step2[20] = HIGHBD_WRAPLOW(step1[20] + step1[21], bd);
-  step2[21] = HIGHBD_WRAPLOW(step1[20] - step1[21], bd);
-  step2[22] = HIGHBD_WRAPLOW(-step1[22] + step1[23], bd);
-  step2[23] = HIGHBD_WRAPLOW(step1[22] + step1[23], bd);
-  step2[24] = HIGHBD_WRAPLOW(step1[24] + step1[25], bd);
-  step2[25] = HIGHBD_WRAPLOW(step1[24] - step1[25], bd);
-  step2[26] = HIGHBD_WRAPLOW(-step1[26] + step1[27], bd);
-  step2[27] = HIGHBD_WRAPLOW(step1[26] + step1[27], bd);
-  step2[28] = HIGHBD_WRAPLOW(step1[28] + step1[29], bd);
-  step2[29] = HIGHBD_WRAPLOW(step1[28] - step1[29], bd);
-  step2[30] = HIGHBD_WRAPLOW(-step1[30] + step1[31], bd);
-  step2[31] = HIGHBD_WRAPLOW(step1[30] + step1[31], bd);
-
-  // stage 3
-  step1[0] = step2[0];
-  step1[1] = step2[1];
-  step1[2] = step2[2];
-  step1[3] = step2[3];
-
-  temp1 = step2[4] * cospi_28_64 - step2[7] * cospi_4_64;
-  temp2 = step2[4] * cospi_4_64 + step2[7] * cospi_28_64;
-  step1[4] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[7] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = step2[5] * cospi_12_64 - step2[6] * cospi_20_64;
-  temp2 = step2[5] * cospi_20_64 + step2[6] * cospi_12_64;
-  step1[5] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[6] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-
-  step1[8] = HIGHBD_WRAPLOW(step2[8] + step2[9], bd);
-  step1[9] = HIGHBD_WRAPLOW(step2[8] - step2[9], bd);
-  step1[10] = HIGHBD_WRAPLOW(-step2[10] + step2[11], bd);
-  step1[11] = HIGHBD_WRAPLOW(step2[10] + step2[11], bd);
-  step1[12] = HIGHBD_WRAPLOW(step2[12] + step2[13], bd);
-  step1[13] = HIGHBD_WRAPLOW(step2[12] - step2[13], bd);
-  step1[14] = HIGHBD_WRAPLOW(-step2[14] + step2[15], bd);
-  step1[15] = HIGHBD_WRAPLOW(step2[14] + step2[15], bd);
-
-  step1[16] = step2[16];
-  step1[31] = step2[31];
-  temp1 = -step2[17] * cospi_4_64 + step2[30] * cospi_28_64;
-  temp2 = step2[17] * cospi_28_64 + step2[30] * cospi_4_64;
-  step1[17] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[30] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = -step2[18] * cospi_28_64 - step2[29] * cospi_4_64;
-  temp2 = -step2[18] * cospi_4_64 + step2[29] * cospi_28_64;
-  step1[18] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[29] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step1[19] = step2[19];
-  step1[20] = step2[20];
-  temp1 = -step2[21] * cospi_20_64 + step2[26] * cospi_12_64;
-  temp2 = step2[21] * cospi_12_64 + step2[26] * cospi_20_64;
-  step1[21] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[26] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = -step2[22] * cospi_12_64 - step2[25] * cospi_20_64;
-  temp2 = -step2[22] * cospi_20_64 + step2[25] * cospi_12_64;
-  step1[22] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[25] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step1[23] = step2[23];
-  step1[24] = step2[24];
-  step1[27] = step2[27];
-  step1[28] = step2[28];
-
-  // stage 4
-  temp1 = (step1[0] + step1[1]) * cospi_16_64;
-  temp2 = (step1[0] - step1[1]) * cospi_16_64;
-  step2[0] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[1] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = step1[2] * cospi_24_64 - step1[3] * cospi_8_64;
-  temp2 = step1[2] * cospi_8_64 + step1[3] * cospi_24_64;
-  step2[2] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[3] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step2[4] = HIGHBD_WRAPLOW(step1[4] + step1[5], bd);
-  step2[5] = HIGHBD_WRAPLOW(step1[4] - step1[5], bd);
-  step2[6] = HIGHBD_WRAPLOW(-step1[6] + step1[7], bd);
-  step2[7] = HIGHBD_WRAPLOW(step1[6] + step1[7], bd);
-
-  step2[8] = step1[8];
-  step2[15] = step1[15];
-  temp1 = -step1[9] * cospi_8_64 + step1[14] * cospi_24_64;
-  temp2 = step1[9] * cospi_24_64 + step1[14] * cospi_8_64;
-  step2[9] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[14] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = -step1[10] * cospi_24_64 - step1[13] * cospi_8_64;
-  temp2 = -step1[10] * cospi_8_64 + step1[13] * cospi_24_64;
-  step2[10] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[13] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step2[11] = step1[11];
-  step2[12] = step1[12];
-
-  step2[16] = HIGHBD_WRAPLOW(step1[16] + step1[19], bd);
-  step2[17] = HIGHBD_WRAPLOW(step1[17] + step1[18], bd);
-  step2[18] = HIGHBD_WRAPLOW(step1[17] - step1[18], bd);
-  step2[19] = HIGHBD_WRAPLOW(step1[16] - step1[19], bd);
-  step2[20] = HIGHBD_WRAPLOW(-step1[20] + step1[23], bd);
-  step2[21] = HIGHBD_WRAPLOW(-step1[21] + step1[22], bd);
-  step2[22] = HIGHBD_WRAPLOW(step1[21] + step1[22], bd);
-  step2[23] = HIGHBD_WRAPLOW(step1[20] + step1[23], bd);
-
-  step2[24] = HIGHBD_WRAPLOW(step1[24] + step1[27], bd);
-  step2[25] = HIGHBD_WRAPLOW(step1[25] + step1[26], bd);
-  step2[26] = HIGHBD_WRAPLOW(step1[25] - step1[26], bd);
-  step2[27] = HIGHBD_WRAPLOW(step1[24] - step1[27], bd);
-  step2[28] = HIGHBD_WRAPLOW(-step1[28] + step1[31], bd);
-  step2[29] = HIGHBD_WRAPLOW(-step1[29] + step1[30], bd);
-  step2[30] = HIGHBD_WRAPLOW(step1[29] + step1[30], bd);
-  step2[31] = HIGHBD_WRAPLOW(step1[28] + step1[31], bd);
-
-  // stage 5
-  step1[0] = HIGHBD_WRAPLOW(step2[0] + step2[3], bd);
-  step1[1] = HIGHBD_WRAPLOW(step2[1] + step2[2], bd);
-  step1[2] = HIGHBD_WRAPLOW(step2[1] - step2[2], bd);
-  step1[3] = HIGHBD_WRAPLOW(step2[0] - step2[3], bd);
-  step1[4] = step2[4];
-  temp1 = (step2[6] - step2[5]) * cospi_16_64;
-  temp2 = (step2[5] + step2[6]) * cospi_16_64;
-  step1[5] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[6] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step1[7] = step2[7];
-
-  step1[8] = HIGHBD_WRAPLOW(step2[8] + step2[11], bd);
-  step1[9] = HIGHBD_WRAPLOW(step2[9] + step2[10], bd);
-  step1[10] = HIGHBD_WRAPLOW(step2[9] - step2[10], bd);
-  step1[11] = HIGHBD_WRAPLOW(step2[8] - step2[11], bd);
-  step1[12] = HIGHBD_WRAPLOW(-step2[12] + step2[15], bd);
-  step1[13] = HIGHBD_WRAPLOW(-step2[13] + step2[14], bd);
-  step1[14] = HIGHBD_WRAPLOW(step2[13] + step2[14], bd);
-  step1[15] = HIGHBD_WRAPLOW(step2[12] + step2[15], bd);
-
-  step1[16] = step2[16];
-  step1[17] = step2[17];
-  temp1 = -step2[18] * cospi_8_64 + step2[29] * cospi_24_64;
-  temp2 = step2[18] * cospi_24_64 + step2[29] * cospi_8_64;
-  step1[18] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[29] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = -step2[19] * cospi_8_64 + step2[28] * cospi_24_64;
-  temp2 = step2[19] * cospi_24_64 + step2[28] * cospi_8_64;
-  step1[19] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[28] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = -step2[20] * cospi_24_64 - step2[27] * cospi_8_64;
-  temp2 = -step2[20] * cospi_8_64 + step2[27] * cospi_24_64;
-  step1[20] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[27] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = -step2[21] * cospi_24_64 - step2[26] * cospi_8_64;
-  temp2 = -step2[21] * cospi_8_64 + step2[26] * cospi_24_64;
-  step1[21] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[26] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step1[22] = step2[22];
-  step1[23] = step2[23];
-  step1[24] = step2[24];
-  step1[25] = step2[25];
-  step1[30] = step2[30];
-  step1[31] = step2[31];
-
-  // stage 6
-  step2[0] = HIGHBD_WRAPLOW(step1[0] + step1[7], bd);
-  step2[1] = HIGHBD_WRAPLOW(step1[1] + step1[6], bd);
-  step2[2] = HIGHBD_WRAPLOW(step1[2] + step1[5], bd);
-  step2[3] = HIGHBD_WRAPLOW(step1[3] + step1[4], bd);
-  step2[4] = HIGHBD_WRAPLOW(step1[3] - step1[4], bd);
-  step2[5] = HIGHBD_WRAPLOW(step1[2] - step1[5], bd);
-  step2[6] = HIGHBD_WRAPLOW(step1[1] - step1[6], bd);
-  step2[7] = HIGHBD_WRAPLOW(step1[0] - step1[7], bd);
-  step2[8] = step1[8];
-  step2[9] = step1[9];
-  temp1 = (-step1[10] + step1[13]) * cospi_16_64;
-  temp2 = (step1[10] + step1[13]) * cospi_16_64;
-  step2[10] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[13] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = (-step1[11] + step1[12]) * cospi_16_64;
-  temp2 = (step1[11] + step1[12]) * cospi_16_64;
-  step2[11] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step2[12] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step2[14] = step1[14];
-  step2[15] = step1[15];
-
-  step2[16] = HIGHBD_WRAPLOW(step1[16] + step1[23], bd);
-  step2[17] = HIGHBD_WRAPLOW(step1[17] + step1[22], bd);
-  step2[18] = HIGHBD_WRAPLOW(step1[18] + step1[21], bd);
-  step2[19] = HIGHBD_WRAPLOW(step1[19] + step1[20], bd);
-  step2[20] = HIGHBD_WRAPLOW(step1[19] - step1[20], bd);
-  step2[21] = HIGHBD_WRAPLOW(step1[18] - step1[21], bd);
-  step2[22] = HIGHBD_WRAPLOW(step1[17] - step1[22], bd);
-  step2[23] = HIGHBD_WRAPLOW(step1[16] - step1[23], bd);
-
-  step2[24] = HIGHBD_WRAPLOW(-step1[24] + step1[31], bd);
-  step2[25] = HIGHBD_WRAPLOW(-step1[25] + step1[30], bd);
-  step2[26] = HIGHBD_WRAPLOW(-step1[26] + step1[29], bd);
-  step2[27] = HIGHBD_WRAPLOW(-step1[27] + step1[28], bd);
-  step2[28] = HIGHBD_WRAPLOW(step1[27] + step1[28], bd);
-  step2[29] = HIGHBD_WRAPLOW(step1[26] + step1[29], bd);
-  step2[30] = HIGHBD_WRAPLOW(step1[25] + step1[30], bd);
-  step2[31] = HIGHBD_WRAPLOW(step1[24] + step1[31], bd);
-
-  // stage 7
-  step1[0] = HIGHBD_WRAPLOW(step2[0] + step2[15], bd);
-  step1[1] = HIGHBD_WRAPLOW(step2[1] + step2[14], bd);
-  step1[2] = HIGHBD_WRAPLOW(step2[2] + step2[13], bd);
-  step1[3] = HIGHBD_WRAPLOW(step2[3] + step2[12], bd);
-  step1[4] = HIGHBD_WRAPLOW(step2[4] + step2[11], bd);
-  step1[5] = HIGHBD_WRAPLOW(step2[5] + step2[10], bd);
-  step1[6] = HIGHBD_WRAPLOW(step2[6] + step2[9], bd);
-  step1[7] = HIGHBD_WRAPLOW(step2[7] + step2[8], bd);
-  step1[8] = HIGHBD_WRAPLOW(step2[7] - step2[8], bd);
-  step1[9] = HIGHBD_WRAPLOW(step2[6] - step2[9], bd);
-  step1[10] = HIGHBD_WRAPLOW(step2[5] - step2[10], bd);
-  step1[11] = HIGHBD_WRAPLOW(step2[4] - step2[11], bd);
-  step1[12] = HIGHBD_WRAPLOW(step2[3] - step2[12], bd);
-  step1[13] = HIGHBD_WRAPLOW(step2[2] - step2[13], bd);
-  step1[14] = HIGHBD_WRAPLOW(step2[1] - step2[14], bd);
-  step1[15] = HIGHBD_WRAPLOW(step2[0] - step2[15], bd);
-
-  step1[16] = step2[16];
-  step1[17] = step2[17];
-  step1[18] = step2[18];
-  step1[19] = step2[19];
-  temp1 = (-step2[20] + step2[27]) * cospi_16_64;
-  temp2 = (step2[20] + step2[27]) * cospi_16_64;
-  step1[20] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[27] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = (-step2[21] + step2[26]) * cospi_16_64;
-  temp2 = (step2[21] + step2[26]) * cospi_16_64;
-  step1[21] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[26] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = (-step2[22] + step2[25]) * cospi_16_64;
-  temp2 = (step2[22] + step2[25]) * cospi_16_64;
-  step1[22] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[25] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  temp1 = (-step2[23] + step2[24]) * cospi_16_64;
-  temp2 = (step2[23] + step2[24]) * cospi_16_64;
-  step1[23] = HIGHBD_WRAPLOW(dct_const_round_shift(temp1), bd);
-  step1[24] = HIGHBD_WRAPLOW(dct_const_round_shift(temp2), bd);
-  step1[28] = step2[28];
-  step1[29] = step2[29];
-  step1[30] = step2[30];
-  step1[31] = step2[31];
-
-  // final stage
-  output[0] = HIGHBD_WRAPLOW(step1[0] + step1[31], bd);
-  output[1] = HIGHBD_WRAPLOW(step1[1] + step1[30], bd);
-  output[2] = HIGHBD_WRAPLOW(step1[2] + step1[29], bd);
-  output[3] = HIGHBD_WRAPLOW(step1[3] + step1[28], bd);
-  output[4] = HIGHBD_WRAPLOW(step1[4] + step1[27], bd);
-  output[5] = HIGHBD_WRAPLOW(step1[5] + step1[26], bd);
-  output[6] = HIGHBD_WRAPLOW(step1[6] + step1[25], bd);
-  output[7] = HIGHBD_WRAPLOW(step1[7] + step1[24], bd);
-  output[8] = HIGHBD_WRAPLOW(step1[8] + step1[23], bd);
-  output[9] = HIGHBD_WRAPLOW(step1[9] + step1[22], bd);
-  output[10] = HIGHBD_WRAPLOW(step1[10] + step1[21], bd);
-  output[11] = HIGHBD_WRAPLOW(step1[11] + step1[20], bd);
-  output[12] = HIGHBD_WRAPLOW(step1[12] + step1[19], bd);
-  output[13] = HIGHBD_WRAPLOW(step1[13] + step1[18], bd);
-  output[14] = HIGHBD_WRAPLOW(step1[14] + step1[17], bd);
-  output[15] = HIGHBD_WRAPLOW(step1[15] + step1[16], bd);
-  output[16] = HIGHBD_WRAPLOW(step1[15] - step1[16], bd);
-  output[17] = HIGHBD_WRAPLOW(step1[14] - step1[17], bd);
-  output[18] = HIGHBD_WRAPLOW(step1[13] - step1[18], bd);
-  output[19] = HIGHBD_WRAPLOW(step1[12] - step1[19], bd);
-  output[20] = HIGHBD_WRAPLOW(step1[11] - step1[20], bd);
-  output[21] = HIGHBD_WRAPLOW(step1[10] - step1[21], bd);
-  output[22] = HIGHBD_WRAPLOW(step1[9] - step1[22], bd);
-  output[23] = HIGHBD_WRAPLOW(step1[8] - step1[23], bd);
-  output[24] = HIGHBD_WRAPLOW(step1[7] - step1[24], bd);
-  output[25] = HIGHBD_WRAPLOW(step1[6] - step1[25], bd);
-  output[26] = HIGHBD_WRAPLOW(step1[5] - step1[26], bd);
-  output[27] = HIGHBD_WRAPLOW(step1[4] - step1[27], bd);
-  output[28] = HIGHBD_WRAPLOW(step1[3] - step1[28], bd);
-  output[29] = HIGHBD_WRAPLOW(step1[2] - step1[29], bd);
-  output[30] = HIGHBD_WRAPLOW(step1[1] - step1[30], bd);
-  output[31] = HIGHBD_WRAPLOW(step1[0] - step1[31], bd);
-}
-
-#endif  // CONFIG_HIGHBITDEPTH
--- a/third_party/aom/aom_dsp/inv_txfm.h
+++ b/third_party/aom/aom_dsp/inv_txfm.h
@@ -18,18 +18,17 @@
 #include "aom_dsp/txfm_common.h"
 #include "aom_ports/mem.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 static INLINE tran_high_t dct_const_round_shift(tran_high_t input) {
-  tran_high_t rv = ROUND_POWER_OF_TWO(input, DCT_CONST_BITS);
-  return rv;
+  return ROUND_POWER_OF_TWO(input, DCT_CONST_BITS);
 }
 
 static INLINE tran_high_t check_range(tran_high_t input, int bd) {
 #if CONFIG_COEFFICIENT_RANGE_CHECKING
   // For valid AV1 input streams, intermediate stage coefficients should always
   // stay within the range of a signed 16 bit integer. Coefficients can go out
   // of this range for invalid/corrupt AV1 streams. However, strictly checking
   // this range for every intermediate coefficient can burdensome for a decoder,
@@ -46,44 +45,40 @@ static INLINE tran_high_t check_range(tr
   assert(input <= int_max);
   (void)int_min;
 #endif  // CONFIG_COEFFICIENT_RANGE_CHECKING
   (void)bd;
   return input;
 }
 
 #define WRAPLOW(x) ((int32_t)check_range(x, 8))
-#if CONFIG_HIGHBITDEPTH
 #define HIGHBD_WRAPLOW(x, bd) ((int32_t)check_range((x), bd))
-#endif  // CONFIG_HIGHBITDEPTH
 
 void aom_idct4_c(const tran_low_t *input, tran_low_t *output);
 void aom_idct8_c(const tran_low_t *input, tran_low_t *output);
 void aom_idct16_c(const tran_low_t *input, tran_low_t *output);
 void aom_idct32_c(const tran_low_t *input, tran_low_t *output);
 void aom_iadst4_c(const tran_low_t *input, tran_low_t *output);
 void aom_iadst8_c(const tran_low_t *input, tran_low_t *output);
 void aom_iadst16_c(const tran_low_t *input, tran_low_t *output);
 
-#if CONFIG_HIGHBITDEPTH
 void aom_highbd_idct4_c(const tran_low_t *input, tran_low_t *output, int bd);
 void aom_highbd_idct8_c(const tran_low_t *input, tran_low_t *output, int bd);
 void aom_highbd_idct16_c(const tran_low_t *input, tran_low_t *output, int bd);
 void aom_highbd_idct32_c(const tran_low_t *input, tran_low_t *output, int bd);
 
 void aom_highbd_iadst4_c(const tran_low_t *input, tran_low_t *output, int bd);
 void aom_highbd_iadst8_c(const tran_low_t *input, tran_low_t *output, int bd);
 void aom_highbd_iadst16_c(const tran_low_t *input, tran_low_t *output, int bd);
 
 static INLINE uint16_t highbd_clip_pixel_add(uint16_t dest, tran_high_t trans,
                                              int bd) {
   trans = HIGHBD_WRAPLOW(trans, bd);
   return clip_pixel_highbd(dest + (int)trans, bd);
 }
-#endif
 
 static INLINE uint8_t clip_pixel_add(uint8_t dest, tran_high_t trans) {
   trans = WRAPLOW(trans);
   return clip_pixel(dest + (int)trans);
 }
 #ifdef __cplusplus
 }  // extern "C"
 #endif
--- a/third_party/aom/aom_dsp/mips/fwd_dct32x32_msa.c
+++ b/third_party/aom/aom_dsp/mips/fwd_dct32x32_msa.c
@@ -921,28 +921,8 @@ void aom_fdct32x32_rd_msa(const int16_t 
   }
 
   /* row transform */
   for (i = 0; i < 4; ++i) {
     fdct32x8_1d_row_rd(&tmp_buf_big[0] + (8 * i * 32), &tmp_buf[0],
                        out + (8 * i * 32));
   }
 }
-
-void aom_fdct32x32_1_msa(const int16_t *input, int16_t *out, int32_t stride) {
-  int sum = LD_HADD(input, stride);
-  sum += LD_HADD(input + 8, stride);
-  sum += LD_HADD(input + 16, stride);
-  sum += LD_HADD(input + 24, stride);
-  sum += LD_HADD(input + 32 * 8, stride);
-  sum += LD_HADD(input + 32 * 8 + 8, stride);
-  sum += LD_HADD(input + 32 * 8 + 16, stride);
-  sum += LD_HADD(input + 32 * 8 + 24, stride);
-  sum += LD_HADD(input + 32 * 16, stride);
-  sum += LD_HADD(input + 32 * 16 + 8, stride);
-  sum += LD_HADD(input + 32 * 16 + 16, stride);
-  sum += LD_HADD(input + 32 * 16 + 24, stride);
-  sum += LD_HADD(input + 32 * 24, stride);
-  sum += LD_HADD(input + 32 * 24 + 8, stride);
-  sum += LD_HADD(input + 32 * 24 + 16, stride);
-  sum += LD_HADD(input + 32 * 24 + 24, stride);
-  out[0] = (int16_t)(sum >> 3);
-}
--- a/third_party/aom/aom_dsp/mips/fwd_txfm_msa.c
+++ b/third_party/aom/aom_dsp/mips/fwd_txfm_msa.c
@@ -231,16 +231,8 @@ void aom_fdct16x16_msa(const int16_t *in
     fdct8x16_1d_column((input + 8 * i), (&tmp_buf[0] + 8 * i), src_stride);
   }
 
   /* row transform */
   for (i = 0; i < 2; ++i) {
     fdct16x8_1d_row((&tmp_buf[0] + (128 * i)), (output + (128 * i)));
   }
 }
-
-void aom_fdct16x16_1_msa(const int16_t *input, int16_t *out, int32_t stride) {
-  int sum = LD_HADD(input, stride);
-  sum += LD_HADD(input + 8, stride);
-  sum += LD_HADD(input + 16 * 8, stride);
-  sum += LD_HADD(input + 16 * 8 + 8, stride);
-  out[0] = (int16_t)(sum >> 1);
-}
--- a/third_party/aom/aom_dsp/quantize.c
+++ b/third_party/aom/aom_dsp/quantize.c
@@ -251,17 +251,16 @@ void aom_quantize_dc_64x64(const tran_lo
         (dequant_ptr * iqm_ptr[rc] + (1 << (AOM_QM_BITS - 1))) >> AOM_QM_BITS;
     dqcoeff_ptr[rc] = (qcoeff_ptr[rc] * dequant) / 4;
     if (tmp32) eob = 0;
   }
   *eob_ptr = eob + 1;
 }
 #endif  // CONFIG_TX64X64
 
-#if CONFIG_HIGHBITDEPTH
 void aom_highbd_quantize_dc(const tran_low_t *coeff_ptr, int n_coeffs,
                             int skip_block, const int16_t *round_ptr,
                             const int16_t quant, tran_low_t *qcoeff_ptr,
                             tran_low_t *dqcoeff_ptr, const int16_t dequant_ptr,
                             uint16_t *eob_ptr, const qm_val_t *qm_ptr,
                             const qm_val_t *iqm_ptr) {
   int eob = -1;
   int dequant =
@@ -518,17 +517,16 @@ void aom_highbd_quantize_b_64x64_c(
           AOM_QM_BITS;
       dqcoeff_ptr[rc] = (qcoeff_ptr[rc] * dequant) / 4;
       if (abs_qcoeff) eob = idx_arr[i];
     }
   }
   *eob_ptr = eob + 1;
 }
 #endif  // CONFIG_TX64X64
-#endif  // CONFIG_HIGHBITDEPTH
 
 #else  // CONFIG_AOM_QM
 
 void aom_quantize_dc(const tran_low_t *coeff_ptr, int n_coeffs, int skip_block,
                      const int16_t *round_ptr, const int16_t quant,
                      tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
                      const int16_t dequant_ptr, uint16_t *eob_ptr) {
   const int rc = 0;
@@ -597,17 +595,16 @@ void aom_quantize_dc_64x64(const tran_lo
     qcoeff_ptr[rc] = (tmp ^ coeff_sign) - coeff_sign;
     dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr / 4;
     if (tmp) eob = 0;
   }
   *eob_ptr = eob + 1;
 }
 #endif  // CONFIG_TX64X64
 
-#if CONFIG_HIGHBITDEPTH
 void aom_highbd_quantize_dc(const tran_low_t *coeff_ptr, int n_coeffs,
                             int skip_block, const int16_t *round_ptr,
                             const int16_t quant, tran_low_t *qcoeff_ptr,
                             tran_low_t *dqcoeff_ptr, const int16_t dequant_ptr,
                             uint16_t *eob_ptr) {
   int eob = -1;
 
   memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
@@ -711,18 +708,17 @@ void aom_highbd_quantize_b_c(const tran_
       const int rc = scan[i];
       const int coeff = coeff_ptr[rc];
       const int coeff_sign = (coeff >> 31);
       const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
 
       if (abs_coeff >= zbins[rc != 0]) {
         const int64_t tmp1 = abs_coeff + round_ptr[rc != 0];
         const int64_t tmp2 = ((tmp1 * quant_ptr[rc != 0]) >> 16) + tmp1;
-        const uint32_t abs_qcoeff =
-            (uint32_t)((tmp2 * quant_shift_ptr[rc != 0]) >> 16);
+        const int abs_qcoeff = (int)((tmp2 * quant_shift_ptr[rc != 0]) >> 16);
         qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
         dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0];
         if (abs_qcoeff) eob = i;
       }
     }
   }
   *eob_ptr = eob + 1;
 }
@@ -762,18 +758,17 @@ void aom_highbd_quantize_b_32x32_c(
     for (i = 0; i < idx; i++) {
       const int rc = scan[idx_arr[i]];
       const int coeff = coeff_ptr[rc];
       const int coeff_sign = (coeff >> 31);
       const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
       const int64_t tmp1 =
           abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], 1);
       const int64_t tmp2 = ((tmp1 * quant_ptr[rc != 0]) >> 16) + tmp1;
-      const uint32_t abs_qcoeff =
-          (uint32_t)((tmp2 * quant_shift_ptr[rc != 0]) >> 15);
+      const int abs_qcoeff = (int)((tmp2 * quant_shift_ptr[rc != 0]) >> 15);
       qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
       dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / 2;
       if (abs_qcoeff) eob = idx_arr[i];
     }
   }
   *eob_ptr = eob + 1;
 }
 
@@ -813,20 +808,18 @@ void aom_highbd_quantize_b_64x64_c(
     for (i = 0; i < idx; i++) {
       const int rc = scan[idx_arr[i]];
       const int coeff = coeff_ptr[rc];
       const int coeff_sign = (coeff >> 31);
       const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
       const int64_t tmp1 =
           abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], 2);
       const int64_t tmp2 = ((tmp1 * quant_ptr[rc != 0]) >> 16) + tmp1;
-      const uint32_t abs_qcoeff =
-          (uint32_t)((tmp2 * quant_shift_ptr[rc != 0]) >> 14);
+      const int abs_qcoeff = (int)((tmp2 * quant_shift_ptr[rc != 0]) >> 14);
       qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
       dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / 4;
       if (abs_qcoeff) eob = idx_arr[i];
     }
   }
   *eob_ptr = eob + 1;
 }
 #endif  // CONFIG_TX64X64
-#endif  // CONFIG_HIGHBITDEPTH
 #endif  // CONFIG_AOM_QM
--- a/third_party/aom/aom_dsp/simd/v256_intrinsics_v128.h
+++ b/third_party/aom/aom_dsp/simd/v256_intrinsics_v128.h
@@ -503,27 +503,29 @@ SIMD_INLINE v256 v256_shr_u32(v256 a, un
 SIMD_INLINE v256 v256_shr_s32(v256 a, unsigned int c) {
   return v256_from_v128(v128_shr_s32(a.hi, c), v128_shr_s32(a.lo, c));
 }
 
 /* These intrinsics require immediate values, so we must use #defines
    to enforce that. */
 #define v256_shl_n_byte(a, n)                                                 \
   ((n) < 16 ? v256_from_v128(v128_or(v128_shl_n_byte(a.hi, n),                \
-                                     v128_shr_n_byte(a.lo, 16 - (n))),        \
+                                     v128_shr_n_byte(a.lo, (16 - (n)) & 31)), \
                              v128_shl_n_byte(a.lo, (n)))                      \
-            : v256_from_v128((n) > 16 ? v128_shl_n_byte(a.lo, (n)-16) : a.lo, \
-                             v128_zero()))
+            : v256_from_v128(                                                 \
+                  (n) > 16 ? v128_shl_n_byte(a.lo, ((n)-16) & 31) : a.lo,     \
+                  v128_zero()))
 
-#define v256_shr_n_byte(a, n)                                          \
-  ((n) < 16 ? v256_from_v128(v128_shr_n_byte(a.hi, n),                 \
-                             v128_or(v128_shr_n_byte(a.lo, n),         \
-                                     v128_shl_n_byte(a.hi, 16 - (n)))) \
-            : v256_from_v128(v128_zero(),                              \
-                             (n) > 16 ? v128_shr_n_byte(a.hi, (n)-16) : a.hi))
+#define v256_shr_n_byte(a, n)                                                 \
+  ((n) < 16 ? v256_from_v128(v128_shr_n_byte(a.hi, n),                        \
+                             v128_or(v128_shr_n_byte(a.lo, n),                \
+                                     v128_shl_n_byte(a.hi, (16 - (n)) & 31))) \
+            : v256_from_v128(                                                 \
+                  v128_zero(),                                                \
+                  (n) > 16 ? v128_shr_n_byte(a.hi, ((n)-16) & 31) : a.hi))
 
 #define v256_align(a, b, c) \
   ((c) ? v256_or(v256_shr_n_byte(b, c), v256_shl_n_byte(a, 32 - (c))) : b)
 
 #define v256_shl_n_8(a, n) \
   v256_from_v128(v128_shl_n_8(a.hi, n), v128_shl_n_8(a.lo, n))
 #define v256_shl_n_16(a, n) \
   v256_from_v128(v128_shl_n_16(a.hi, n), v128_shl_n_16(a.lo, n))
--- a/third_party/aom/aom_dsp/txfm_common.h
+++ b/third_party/aom/aom_dsp/txfm_common.h
@@ -62,9 +62,67 @@ static const tran_high_t cospi_31_64 = 8
 static const tran_high_t sinpi_1_9 = 5283;
 static const tran_high_t sinpi_2_9 = 9929;
 static const tran_high_t sinpi_3_9 = 13377;
 static const tran_high_t sinpi_4_9 = 15212;
 
 // 16384 * sqrt(2)
 static const tran_high_t Sqrt2 = 23170;
 
+static INLINE tran_high_t fdct_round_shift(tran_high_t input) {
+  tran_high_t rv = ROUND_POWER_OF_TWO(input, DCT_CONST_BITS);
+  return rv;
+}
+
+#if CONFIG_LGT
+// The Line Graph Transforms (LGTs) matrices are written as follows.
+// Each 2D array is 16384 times an LGT matrix, which is the matrix of
+// eigenvectors of the graph Laplacian matrices for the line graph.
+
+// LGT4 name: lgt4_140
+// Self loops: 1.400, 0.000, 0.000, 0.000
+// Edges: 1.000, 1.000, 1.000
+static const tran_high_t lgt4_140[4][4] = {
+  { 4206, 9518, 13524, 15674 },
+  { 11552, 14833, 1560, -13453 },
+  { 15391, -1906, -14393, 9445 },
+  { 12201, -14921, 12016, -4581 },
+};
+
+// LGT4 name: lgt4_170
+// Self loops: 1.700, 0.000, 0.000, 0.000
+// Edges: 1.000, 1.000, 1.000
+static const tran_high_t lgt4_170[4][4] = {
+  { 3636, 9287, 13584, 15902 },
+  { 10255, 15563, 2470, -13543 },
+  { 14786, 711, -15249, 9231 },
+  { 14138, -14420, 10663, -3920 },
+};
+
+// LGT8 name: lgt8_150
+// Self loops: 1.500, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000
+// Edges: 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000
+static const tran_high_t lgt8_150[8][8] = {
+  { 2075, 5110, 7958, 10511, 12677, 14376, 15544, 16140 },
+  { 6114, 13307, 16196, 13845, 7015, -2084, -10509, -15534 },
+  { 9816, 16163, 8717, -6168, -15790, -11936, 2104, 14348 },
+  { 12928, 12326, -7340, -15653, 242, 15763, 6905, -12632 },
+  { 15124, 3038, -16033, 1758, 15507, -6397, -13593, 10463 },
+  { 15895, -7947, -7947, 15895, -7947, -7947, 15895, -7947 },
+  { 14325, -15057, 9030, 1050, -10659, 15483, -13358, 5236 },
+  { 9054, -12580, 14714, -15220, 14043, -11312, 7330, -2537 },
+};
+
+// LGT8 name: lgt8_170
+// Self loops: 1.700, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000
+// Edges: 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000
+static const tran_high_t lgt8_170[8][8] = {
+  { 1858, 4947, 7850, 10458, 12672, 14411, 15607, 16217 },
+  { 5494, 13022, 16256, 14129, 7343, -1864, -10456, -15601 },
+  { 8887, 16266, 9500, -5529, -15749, -12273, 1876, 14394 },
+  { 11870, 13351, -6199, -15984, -590, 15733, 7273, -12644 },
+  { 14248, 5137, -15991, 291, 15893, -5685, -13963, 10425 },
+  { 15716, -5450, -10010, 15929, -6665, -8952, 16036, -7835 },
+  { 15533, -13869, 6559, 3421, -12009, 15707, -13011, 5018 },
+  { 11357, -13726, 14841, -14600, 13025, -10259, 6556, -2254 },
+};
+#endif  // CONFIG_LGT
 #endif  // AOM_DSP_TXFM_COMMON_H_
--- a/third_party/aom/aom_dsp/variance.c
+++ b/third_party/aom/aom_dsp/variance.c
@@ -4,27 +4,32 @@
  * This source code is subject to the terms of the BSD 2 Clause License and
  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
  * was not distributed with this source code in the LICENSE file, you can
  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 #include <stdlib.h>
+#include <string.h>
+#include <assert.h>
 
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
 
 #include "aom_ports/mem.h"
 #include "aom/aom_integer.h"
 
 #include "aom_dsp/variance.h"
 #include "aom_dsp/aom_filter.h"
 #include "aom_dsp/blend.h"
 
+#include "./av1_rtcd.h"
+#include "av1/common/filter.h"
+
 uint32_t aom_get4x4sse_cs_c(const uint8_t *a, int a_stride, const uint8_t *b,
                             int b_stride) {
   int distortion = 0;
   int r, c;
 
   for (r = 0; r < 4; ++r) {
     for (c = 0; c < 4; ++c) {
       int diff = a[c] - b[c];
@@ -266,43 +271,76 @@ void aom_comp_avg_pred_c(uint8_t *comp_p
     comp_pred += width;
     pred += width;
     ref += ref_stride;
   }
 }
 
 // Get pred block from up-sampled reference.
 void aom_upsampled_pred_c(uint8_t *comp_pred, int width, int height,
-                          const uint8_t *ref, int ref_stride) {
-  int i, j, k;
-  int stride = ref_stride << 3;
-
-  for (i = 0; i < height; i++) {
-    for (j = 0, k = 0; j < width; j++, k += 8) {
-      comp_pred[j] = ref[k];
+                          int subpel_x_q3, int subpel_y_q3, const uint8_t *ref,
+                          int ref_stride) {
+  if (!subpel_x_q3 && !subpel_y_q3) {
+    int i;
+    for (i = 0; i < height; i++) {
+      memcpy(comp_pred, ref, width * sizeof(*comp_pred));
+      comp_pred += width;
+      ref += ref_stride;
     }
-    comp_pred += width;
-    ref += stride;
+  } else {
+    InterpFilterParams filter;
+    filter = av1_get_interp_filter_params(EIGHTTAP_REGULAR);
+    if (!subpel_y_q3) {
+      const int16_t *kernel;
+      kernel = av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
+      /*Directly call C version to allow this to work for small (2x2) sizes.*/
+      aom_convolve8_horiz_c(ref, ref_stride, comp_pred, width, kernel, 16, NULL,
+                            -1, width, height);
+    } else if (!subpel_x_q3) {
+      const int16_t *kernel;
+      kernel = av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
+      /*Directly call C version to allow this to work for small (2x2) sizes.*/
+      aom_convolve8_vert_c(ref, ref_stride, comp_pred, width, NULL, -1, kernel,
+                           16, width, height);
+    } else {
+      DECLARE_ALIGNED(16, uint8_t,
+                      temp[((MAX_SB_SIZE * 2 + 16) + 16) * MAX_SB_SIZE]);
+      const int16_t *kernel_x;
+      const int16_t *kernel_y;
+      int intermediate_height;
+      kernel_x = av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
+      kernel_y = av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
+      intermediate_height =
+          (((height - 1) * 8 + subpel_y_q3) >> 3) + filter.taps;
+      assert(intermediate_height <= (MAX_SB_SIZE * 2 + 16) + 16);
+      /*Directly call C versions to allow this to work for small (2x2) sizes.*/
+      aom_convolve8_horiz_c(ref - ref_stride * ((filter.taps >> 1) - 1),
+                            ref_stride, temp, MAX_SB_SIZE, kernel_x, 16, NULL,
+                            -1, width, intermediate_height);
+      aom_convolve8_vert_c(temp + MAX_SB_SIZE * ((filter.taps >> 1) - 1),
+                           MAX_SB_SIZE, comp_pred, width, NULL, -1, kernel_y,
+                           16, width, height);
+    }
   }
 }
 
 void aom_comp_avg_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred,
-                                   int width, int height, const uint8_t *ref,
+                                   int width, int height, int subpel_x_q3,
+                                   int subpel_y_q3, const uint8_t *ref,
                                    int ref_stride) {
   int i, j;
-  int stride = ref_stride << 3;
 
+  aom_upsampled_pred(comp_pred, width, height, subpel_x_q3, subpel_y_q3, ref,
+                     ref_stride);
   for (i = 0; i < height; i++) {
     for (j = 0; j < width; j++) {
-      const int tmp = ref[(j << 3)] + pred[j];
-      comp_pred[j] = ROUND_POWER_OF_TWO(tmp, 1);
+      comp_pred[j] = ROUND_POWER_OF_TWO(comp_pred[j] + pred[j], 1);
     }
     comp_pred += width;
     pred += width;
-    ref += stride;
   }
 }
 
 #if CONFIG_HIGHBITDEPTH
 static void highbd_variance64(const uint8_t *a8, int a_stride,
                               const uint8_t *b8, int b_stride, int w, int h,
                               uint64_t *sse, int64_t *sum) {
   int i, j;
@@ -632,47 +670,86 @@ void aom_highbd_comp_avg_pred_c(uint16_t
     }
     comp_pred += width;
     pred += width;
     ref += ref_stride;
   }
 }
 
 void aom_highbd_upsampled_pred_c(uint16_t *comp_pred, int width, int height,
-                                 const uint8_t *ref8, int ref_stride) {
-  int i, j;
-  int stride = ref_stride << 3;
-
-  uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
-  for (i = 0; i < height; ++i) {
-    for (j = 0; j < width; ++j) {
-      comp_pred[j] = ref[(j << 3)];
+                                 int subpel_x_q3, int subpel_y_q3,
+                                 const uint8_t *ref8, int ref_stride, int bd) {
+  if (!subpel_x_q3 && !subpel_y_q3) {
+    const uint16_t *ref;
+    int i;
+    ref = CONVERT_TO_SHORTPTR(ref8);
+    for (i = 0; i < height; i++) {
+      memcpy(comp_pred, ref, width * sizeof(*comp_pred));
+      comp_pred += width;
+      ref += ref_stride;
     }
-    comp_pred += width;
-    ref += stride;
+  } else {
+    InterpFilterParams filter;
+    filter = av1_get_interp_filter_params(EIGHTTAP_REGULAR);
+    if (!subpel_y_q3) {
+      const int16_t *kernel;
+      kernel = av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
+      /*Directly call C version to allow this to work for small (2x2) sizes.*/
+      aom_highbd_convolve8_horiz_c(ref8, ref_stride,
+                                   CONVERT_TO_BYTEPTR(comp_pred), width, kernel,
+                                   16, NULL, -1, width, height, bd);
+    } else if (!subpel_x_q3) {
+      const int16_t *kernel;
+      kernel = av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
+      /*Directly call C version to allow this to work for small (2x2) sizes.*/
+      aom_highbd_convolve8_vert_c(ref8, ref_stride,
+                                  CONVERT_TO_BYTEPTR(comp_pred), width, NULL,
+                                  -1, kernel, 16, width, height, bd);
+    } else {
+      DECLARE_ALIGNED(16, uint8_t,
+                      temp[((MAX_SB_SIZE * 2 + 16) + 16) * MAX_SB_SIZE]);
+      const uint16_t *ref;
+      const int16_t *kernel_x;
+      const int16_t *kernel_y;
+      int intermediate_height;
+      ref = CONVERT_TO_SHORTPTR(ref8);
+      kernel_x = av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
+      kernel_y = av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
+      intermediate_height =
+          (((height - 1) * 8 + subpel_y_q3) >> 3) + filter.taps;
+      assert(intermediate_height <= (MAX_SB_SIZE * 2 + 16) + 16);
+      /*Directly call C versions to allow this to work for small (2x2) sizes.*/
+      aom_highbd_convolve8_horiz_c(
+          CONVERT_TO_BYTEPTR(ref - ref_stride * ((filter.taps >> 1) - 1)),
+          ref_stride, CONVERT_TO_BYTEPTR(temp), MAX_SB_SIZE, kernel_x, 16, NULL,
+          -1, width, intermediate_height, bd);
+      aom_highbd_convolve8_vert_c(
+          CONVERT_TO_BYTEPTR(temp + MAX_SB_SIZE * ((filter.taps >> 1) - 1)),
+          MAX_SB_SIZE, CONVERT_TO_BYTEPTR(comp_pred), width, NULL, -1, kernel_y,
+          16, width, height, bd);
+    }
   }
 }
 
 void aom_highbd_comp_avg_upsampled_pred_c(uint16_t *comp_pred,
                                           const uint8_t *pred8, int width,
-                                          int height, const uint8_t *ref8,
-                                          int ref_stride) {
+                                          int height, int subpel_x_q3,
+                                          int subpel_y_q3, const uint8_t *ref8,
+                                          int ref_stride, int bd) {
   int i, j;
-  int stride = ref_stride << 3;
 
-  uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
-  uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
+  const uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
+  aom_highbd_upsampled_pred(comp_pred, width, height, subpel_x_q3, subpel_y_q3,
+                            ref8, ref_stride, bd);
   for (i = 0; i < height; ++i) {
     for (j = 0; j < width; ++j) {
-      const int tmp = pred[j] + ref[(j << 3)];
-      comp_pred[j] = ROUND_POWER_OF_TWO(tmp, 1);
+      comp_pred[j] = ROUND_POWER_OF_TWO(pred[j] + comp_pred[j], 1);
     }
     comp_pred += width;
     pred += width;
-    ref += stride;
   }
 }
 #endif  // CONFIG_HIGHBITDEPTH
 
 #if CONFIG_AV1 && CONFIG_EXT_INTER
 void aom_comp_mask_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width,
                           int height, const uint8_t *ref, int ref_stride,
                           const uint8_t *mask, int mask_stride,
@@ -689,32 +766,33 @@ void aom_comp_mask_pred_c(uint8_t *comp_
     comp_pred += width;
     pred += width;
     ref += ref_stride;
     mask += mask_stride;
   }
 }
 
 void aom_comp_mask_upsampled_pred_c(uint8_t *comp_pred, const uint8_t *pred,
-                                    int width, int height, const uint8_t *ref,
+                                    int width, int height, int subpel_x_q3,
+                                    int subpel_y_q3, const uint8_t *ref,
                                     int ref_stride, const uint8_t *mask,
                                     int mask_stride, int invert_mask) {
   int i, j;
-  int stride = ref_stride << 3;
 
+  aom_upsampled_pred(comp_pred, width, height, subpel_x_q3, subpel_y_q3, ref,
+                     ref_stride);
   for (i = 0; i < height; i++) {
     for (j = 0; j < width; j++) {
       if (!invert_mask)
-        comp_pred[j] = AOM_BLEND_A64(mask[j], ref[(j << 3)], pred[j]);
+        comp_pred[j] = AOM_BLEND_A64(mask[j], comp_pred[j], pred[j]);
       else
-        comp_pred[j] = AOM_BLEND_A64(mask[j], pred[j], ref[(j << 3)]);
+        comp_pred[j] = AOM_BLEND_A64(mask[j], pred[j], comp_pred[j]);
     }
     comp_pred += width;
     pred += width;
-    ref += stride;
     mask += mask_stride;
   }
 }
 
 #define MASK_SUBPIX_VAR(W, H)                                                 \
   unsigned int aom_masked_sub_pixel_variance##W##x##H##_c(                    \
       const uint8_t *src, int src_stride, int xoffset, int yoffset,           \
       const uint8_t *ref, int ref_stride, const uint8_t *second_pred,         \
@@ -770,36 +848,34 @@ void aom_highbd_comp_mask_pred_c(uint16_
     }
     comp_pred += width;
     pred += width;
     ref += ref_stride;
     mask += mask_stride;
   }
 }
 
-void aom_highbd_comp_mask_upsampled_pred_c(uint16_t *comp_pred,
-                                           const uint8_t *pred8, int width,
-                                           int height, const uint8_t *ref8,
-                                           int ref_stride, const uint8_t *mask,
-                                           int mask_stride, int invert_mask) {
+void aom_highbd_comp_mask_upsampled_pred_c(
+    uint16_t *comp_pred, const uint8_t *pred8, int width, int height,
+    int subpel_x_q3, int subpel_y_q3, const uint8_t *ref8, int ref_stride,
+    const uint8_t *mask, int mask_stride, int invert_mask, int bd) {
   int i, j;
-  int stride = ref_stride << 3;
 
   uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
-  uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
+  aom_highbd_upsampled_pred(comp_pred, width, height, subpel_x_q3, subpel_y_q3,
+                            ref8, ref_stride, bd);
   for (i = 0; i < height; ++i) {
     for (j = 0; j < width; ++j) {
       if (!invert_mask)
-        comp_pred[j] = AOM_BLEND_A64(mask[j], ref[j << 3], pred[j]);
+        comp_pred[j] = AOM_BLEND_A64(mask[j], comp_pred[j], pred[j]);
       else
-        comp_pred[j] = AOM_BLEND_A64(mask[j], pred[j], ref[j << 3]);
+        comp_pred[j] = AOM_BLEND_A64(mask[j], pred[j], comp_pred[j]);
     }
     comp_pred += width;
     pred += width;
-    ref += stride;
     mask += mask_stride;
   }
 }
 
 #define HIGHBD_MASK_SUBPIX_VAR(W, H)                                           \
   unsigned int aom_highbd_8_masked_sub_pixel_variance##W##x##H##_c(            \
       const uint8_t *src, int src_stride, int xoffset, int yoffset,            \
       const uint8_t *ref, int ref_stride, const uint8_t *second_pred,          \
--- a/third_party/aom/aom_dsp/x86/fwd_txfm_sse2.c
+++ b/third_party/aom/aom_dsp/x86/fwd_txfm_sse2.c
@@ -80,157 +80,16 @@ void aom_fdct8x8_1_sse2(const int16_t *i
 
   sum = _mm_add_epi32(in0, in1);
   in0 = _mm_srli_si128(sum, 8);
 
   in1 = _mm_add_epi32(sum, in0);
   output[0] = (tran_low_t)_mm_cvtsi128_si32(in1);
 }
 
-void aom_fdct16x16_1_sse2(const int16_t *input, tran_low_t *output,
-                          int stride) {
-  __m128i in0, in1, in2, in3;
-  __m128i u0, u1;
-  __m128i sum = _mm_setzero_si128();
-  int i;
-
-  for (i = 0; i < 2; ++i) {
-    in0 = _mm_load_si128((const __m128i *)(input + 0 * stride + 0));
-    in1 = _mm_load_si128((const __m128i *)(input + 0 * stride + 8));
-    in2 = _mm_load_si128((const __m128i *)(input + 1 * stride + 0));
-    in3 = _mm_load_si128((const __m128i *)(input + 1 * stride + 8));
-
-    u0 = _mm_add_epi16(in0, in1);
-    u1 = _mm_add_epi16(in2, in3);
-    sum = _mm_add_epi16(sum, u0);
-
-    in0 = _mm_load_si128((const __m128i *)(input + 2 * stride + 0));
-    in1 = _mm_load_si128((const __m128i *)(input + 2 * stride + 8));
-    in2 = _mm_load_si128((const __m128i *)(input + 3 * stride + 0));
-    in3 = _mm_load_si128((const __m128i *)(input + 3 * stride + 8));
-
-    sum = _mm_add_epi16(sum, u1);
-    u0 = _mm_add_epi16(in0, in1);
-    u1 = _mm_add_epi16(in2, in3);
-    sum = _mm_add_epi16(sum, u0);
-
-    in0 = _mm_load_si128((const __m128i *)(input + 4 * stride + 0));
-    in1 = _mm_load_si128((const __m128i *)(input + 4 * stride + 8));
-    in2 = _mm_load_si128((const __m128i *)(input + 5 * stride + 0));
-    in3 = _mm_load_si128((const __m128i *)(input + 5 * stride + 8));
-
-    sum = _mm_add_epi16(sum, u1);
-    u0 = _mm_add_epi16(in0, in1);
-    u1 = _mm_add_epi16(in2, in3);
-    sum = _mm_add_epi16(sum, u0);
-
-    in0 = _mm_load_si128((const __m128i *)(input + 6 * stride + 0));
-    in1 = _mm_load_si128((const __m128i *)(input + 6 * stride + 8));
-    in2 = _mm_load_si128((const __m128i *)(input + 7 * stride + 0));
-    in3 = _mm_load_si128((const __m128i *)(input + 7 * stride + 8));
-
-    sum = _mm_add_epi16(sum, u1);
-    u0 = _mm_add_epi16(in0, in1);
-    u1 = _mm_add_epi16(in2, in3);
-    sum = _mm_add_epi16(sum, u0);
-
-    sum = _mm_add_epi16(sum, u1);
-    input += 8 * stride;
-  }
-
-  u0 = _mm_setzero_si128();
-  in0 = _mm_unpacklo_epi16(u0, sum);
-  in1 = _mm_unpackhi_epi16(u0, sum);
-  in0 = _mm_srai_epi32(in0, 16);
-  in1 = _mm_srai_epi32(in1, 16);
-
-  sum = _mm_add_epi32(in0, in1);
-  in0 = _mm_unpacklo_epi32(sum, u0);
-  in1 = _mm_unpackhi_epi32(sum, u0);
-
-  sum = _mm_add_epi32(in0, in1);
-  in0 = _mm_srli_si128(sum, 8);
-
-  in1 = _mm_add_epi32(sum, in0);
-  in1 = _mm_srai_epi32(in1, 1);
-  output[0] = (tran_low_t)_mm_cvtsi128_si32(in1);
-}
-
-void aom_fdct32x32_1_sse2(const int16_t *input, tran_low_t *output,
-                          int stride) {
-  __m128i in0, in1, in2, in3;
-  __m128i u0, u1;
-  __m128i sum = _mm_setzero_si128();
-  int i;
-
-  for (i = 0; i < 8; ++i) {
-    in0 = _mm_load_si128((const __m128i *)(input + 0));
-    in1 = _mm_load_si128((const __m128i *)(input + 8));
-    in2 = _mm_load_si128((const __m128i *)(input + 16));
-    in3 = _mm_load_si128((const __m128i *)(input + 24));
-
-    input += stride;
-    u0 = _mm_add_epi16(in0, in1);
-    u1 = _mm_add_epi16(in2, in3);
-    sum = _mm_add_epi16(sum, u0);
-
-    in0 = _mm_load_si128((const __m128i *)(input + 0));
-    in1 = _mm_load_si128((const __m128i *)(input + 8));
-    in2 = _mm_load_si128((const __m128i *)(input + 16));
-    in3 = _mm_load_si128((const __m128i *)(input + 24));
-
-    input += stride;
-    sum = _mm_add_epi16(sum, u1);
-    u0 = _mm_add_epi16(in0, in1);
-    u1 = _mm_add_epi16(in2, in3);
-    sum = _mm_add_epi16(sum, u0);
-
-    in0 = _mm_load_si128((const __m128i *)(input + 0));
-    in1 = _mm_load_si128((const __m128i *)(input + 8));
-    in2 = _mm_load_si128((const __m128i *)(input + 16));
-    in3 = _mm_load_si128((const __m128i *)(input + 24));
-
-    input += stride;
-    sum = _mm_add_epi16(sum, u1);
-    u0 = _mm_add_epi16(in0, in1);
-    u1 = _mm_add_epi16(in2, in3);
-    sum = _mm_add_epi16(sum, u0);
-
-    in0 = _mm_load_si128((const __m128i *)(input + 0));
-    in1 = _mm_load_si128((const __m128i *)(input + 8));
-    in2 = _mm_load_si128((const __m128i *)(input + 16));
-    in3 = _mm_load_si128((const __m128i *)(input + 24));
-
-    input += stride;
-    sum = _mm_add_epi16(sum, u1);
-    u0 = _mm_add_epi16(in0, in1);
-    u1 = _mm_add_epi16(in2, in3);
-    sum = _mm_add_epi16(sum, u0);
-
-    sum = _mm_add_epi16(sum, u1);
-  }
-
-  u0 = _mm_setzero_si128();
-  in0 = _mm_unpacklo_epi16(u0, sum);
-  in1 = _mm_unpackhi_epi16(u0, sum);
-  in0 = _mm_srai_epi32(in0, 16);
-  in1 = _mm_srai_epi32(in1, 16);
-
-  sum = _mm_add_epi32(in0, in1);
-  in0 = _mm_unpacklo_epi32(sum, u0);
-  in1 = _mm_unpackhi_epi32(sum, u0);
-
-  sum = _mm_add_epi32(in0, in1);
-  in0 = _mm_srli_si128(sum, 8);
-
-  in1 = _mm_add_epi32(sum, in0);
-  in1 = _mm_srai_epi32(in1, 3);
-  output[0] = (tran_low_t)_mm_cvtsi128_si32(in1);
-}
-
 #define DCT_HIGH_BIT_DEPTH 0
 #define FDCT4x4_2D aom_fdct4x4_sse2
 #define FDCT8x8_2D aom_fdct8x8_sse2
 #define FDCT16x16_2D aom_fdct16x16_sse2
 #include "aom_dsp/x86/fwd_txfm_impl_sse2.h"
 #undef FDCT4x4_2D
 #undef FDCT8x8_2D
 #undef FDCT16x16_2D
new file mode 100644
--- /dev/null
+++ b/third_party/aom/aom_dsp/x86/highbd_quantize_intrin_avx2.c
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2017, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+#include <immintrin.h>
+
+#include "./aom_dsp_rtcd.h"
+#include "aom/aom_integer.h"
+
+static INLINE void init_one_qp(const __m128i *p, __m256i *qp) {
+  const __m128i sign = _mm_srai_epi16(*p, 15);
+  const __m128i dc = _mm_unpacklo_epi16(*p, sign);
+  const __m128i ac = _mm_unpackhi_epi16(*p, sign);
+  *qp = _mm256_insertf128_si256(_mm256_castsi128_si256(dc), ac, 1);
+}
+
+static INLINE void update_qp(__m256i *qp) {
+  int i;
+  for (i = 0; i < 5; ++i) {
+    qp[i] = _mm256_permute2x128_si256(qp[i], qp[i], 0x11);
+  }
+}
+
+static INLINE void init_qp(const int16_t *zbin_ptr, const int16_t *round_ptr,
+                           const int16_t *quant_ptr, const int16_t *dequant_ptr,
+                           const int16_t *quant_shift_ptr, __m256i *qp) {
+  const __m128i zbin = _mm_loadu_si128((const __m128i *)zbin_ptr);
+  const __m128i round = _mm_loadu_si128((const __m128i *)round_ptr);
+  const __m128i quant = _mm_loadu_si128((const __m128i *)quant_ptr);
+  const __m128i dequant = _mm_loadu_si128((const __m128i *)dequant_ptr);
+  const __m128i quant_shift = _mm_loadu_si128((const __m128i *)quant_shift_ptr);
+  init_one_qp(&zbin, &qp[0]);
+  init_one_qp(&round, &qp[1]);
+  init_one_qp(&quant, &qp[2]);
+  init_one_qp(&dequant, &qp[3]);
+  init_one_qp(&quant_shift, &qp[4]);
+}
+
+// Note:
+// *x is vector multiplied by *y which is 16 int32_t parallel multiplication
+// and right shift 16.  The output, 16 int32_t is save in *p.
+static INLINE void mm256_mul_shift_epi32(const __m256i *x, const __m256i *y,
+                                         __m256i *p) {
+  __m256i prod_lo = _mm256_mul_epi32(*x, *y);
+  __m256i prod_hi = _mm256_srli_epi64(*x, 32);
+  const __m256i mult_hi = _mm256_srli_epi64(*y, 32);
+  prod_hi = _mm256_mul_epi32(prod_hi, mult_hi);
+
+  prod_lo = _mm256_srli_epi64(prod_lo, 16);
+  const __m256i mask = _mm256_set_epi32(0, -1, 0, -1, 0, -1, 0, -1);
+  prod_lo = _mm256_and_si256(prod_lo, mask);
+  prod_hi = _mm256_srli_epi64(prod_hi, 16);
+
+  prod_hi = _mm256_slli_epi64(prod_hi, 32);
+  *p = _mm256_or_si256(prod_lo, prod_hi);
+}
+
+static INLINE void quantize(const __m256i *qp, __m256i *c,
+                            const int16_t *iscan_ptr, tran_low_t *qcoeff,
+                            tran_low_t *dqcoeff, __m256i *eob) {
+  const __m256i abs = _mm256_abs_epi32(*c);
+  const __m256i flag1 = _mm256_cmpgt_epi32(abs, qp[0]);
+  __m256i flag2 = _mm256_cmpeq_epi32(abs, qp[0]);
+  flag2 = _mm256_or_si256(flag1, flag2);
+  const int32_t nzflag = _mm256_movemask_epi8(flag2);
+
+  if (LIKELY(nzflag)) {
+    __m256i q = _mm256_add_epi32(abs, qp[1]);
+    __m256i tmp;
+    mm256_mul_shift_epi32(&q, &qp[2], &tmp);
+    q = _mm256_add_epi32(tmp, q);
+
+    mm256_mul_shift_epi32(&q, &qp[4], &q);
+    __m256i dq = _mm256_mullo_epi32(q, qp[3]);
+
+    q = _mm256_sign_epi32(q, *c);
+    dq = _mm256_sign_epi32(dq, *c);
+    q = _mm256_and_si256(q, flag2);
+    dq = _mm256_and_si256(dq, flag2);
+
+    _mm256_storeu_si256((__m256i *)qcoeff, q);
+    _mm256_storeu_si256((__m256i *)dqcoeff, dq);
+
+    const __m128i isc = _mm_loadu_si128((const __m128i *)iscan_ptr);
+    const __m128i zr = _mm_setzero_si128();
+    const __m128i lo = _mm_unpacklo_epi16(isc, zr);
+    const __m128i hi = _mm_unpackhi_epi16(isc, zr);
+    const __m256i iscan =
+        _mm256_insertf128_si256(_mm256_castsi128_si256(lo), hi, 1);
+
+    const __m256i zero = _mm256_setzero_si256();
+    const __m256i zc = _mm256_cmpeq_epi32(dq, zero);
+    const __m256i nz = _mm256_cmpeq_epi32(zc, zero);
+    __m256i cur_eob = _mm256_sub_epi32(iscan, nz);
+    cur_eob = _mm256_and_si256(cur_eob, nz);
+    *eob = _mm256_max_epi32(cur_eob, *eob);
+  } else {
+    const __m256i zero = _mm256_setzero_si256();
+    _mm256_storeu_si256((__m256i *)qcoeff, zero);
+    _mm256_storeu_si256((__m256i *)dqcoeff, zero);
+  }
+}
+
+void aom_highbd_quantize_b_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
+                                int skip_block, const int16_t *zbin_ptr,
+                                const int16_t *round_ptr,
+                                const int16_t *quant_ptr,
+                                const int16_t *quant_shift_ptr,
+                                tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
+                                const int16_t *dequant_ptr, uint16_t *eob_ptr,
+                                const int16_t *scan, const int16_t *iscan) {
+  (void)scan;
+  const unsigned int step = 8;
+
+  if (LIKELY(!skip_block)) {
+    __m256i qp[5], coeff;
+    init_qp(zbin_ptr, round_ptr, quant_ptr, dequant_ptr, quant_shift_ptr, qp);
+    coeff = _mm256_loadu_si256((const __m256i *)coeff_ptr);
+
+    __m256i eob = _mm256_setzero_si256();
+    quantize(qp, &coeff, iscan, qcoeff_ptr, dqcoeff_ptr, &eob);
+
+    coeff_ptr += step;
+    qcoeff_ptr += step;
+    dqcoeff_ptr += step;
+    iscan += step;
+    n_coeffs -= step;
+
+    update_qp(qp);
+
+    while (n_coeffs > 0) {
+      coeff = _mm256_loadu_si256((const __m256i *)coeff_ptr);
+      quantize(qp, &coeff, iscan, qcoeff_ptr, dqcoeff_ptr, &eob);
+
+      coeff_ptr += step;
+      qcoeff_ptr += step;
+      dqcoeff_ptr += step;
+      iscan += step;
+      n_coeffs -= step;
+    }
+    {
+      __m256i eob_s;
+      eob_s = _mm256_shuffle_epi32(eob, 0xe);
+      eob = _mm256_max_epi16(eob, eob_s);
+      eob_s = _mm256_shufflelo_epi16(eob, 0xe);
+      eob = _mm256_max_epi16(eob, eob_s);
+      eob_s = _mm256_shufflelo_epi16(eob, 1);
+      eob = _mm256_max_epi16(eob, eob_s);
+      const __m128i final_eob = _mm_max_epi16(_mm256_castsi256_si128(eob),
+                                              _mm256_extractf128_si256(eob, 1));
+      *eob_ptr = _mm_extract_epi16(final_eob, 0);
+    }
+  } else {
+    do {
+      const __m256i zero = _mm256_setzero_si256();
+      _mm256_storeu_si256((__m256i *)qcoeff_ptr, zero);
+      _mm256_storeu_si256((__m256i *)dqcoeff_ptr, zero);
+      qcoeff_ptr += step;
+      dqcoeff_ptr += step;
+      n_coeffs -= step;
+    } while (n_coeffs > 0);
+    *eob_ptr = 0;
+  }
+}
--- a/third_party/aom/aom_dsp/x86/highbd_quantize_intrin_sse2.c
+++ b/third_party/aom/aom_dsp/x86/highbd_quantize_intrin_sse2.c
@@ -10,17 +10,16 @@
  */
 
 #include <emmintrin.h>
 
 #include "aom_dsp/aom_dsp_common.h"
 #include "aom_mem/aom_mem.h"
 #include "aom_ports/mem.h"
 
-#if CONFIG_HIGHBITDEPTH
 void aom_highbd_quantize_b_sse2(const tran_low_t *coeff_ptr, intptr_t count,
                                 int skip_block, const int16_t *zbin_ptr,
                                 const int16_t *round_ptr,
                                 const int16_t *quant_ptr,
                                 const int16_t *quant_shift_ptr,
                                 tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
                                 const int16_t *dequant_ptr, uint16_t *eob_ptr,
                                 const int16_t *scan, const int16_t *iscan) {
@@ -147,9 +146,8 @@ void aom_highbd_quantize_b_32x32_sse2(
           (uint32_t)((tmp2 * quant_shift_ptr[rc != 0]) >> 15);
       qcoeff_ptr[rc] = (int)(abs_qcoeff ^ coeff_sign) - coeff_sign;
       dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / 2;
       if (abs_qcoeff) eob = iscan[idx_arr[i]] > eob ? iscan[idx_arr[i]] : eob;
     }
   }
   *eob_ptr = eob + 1;
 }
-#endif
--- a/third_party/aom/aom_dsp/x86/highbd_variance_sse2.c
+++ b/third_party/aom/aom_dsp/x86/highbd_variance_sse2.c
@@ -4,23 +4,27 @@
  * This source code is subject to the terms of the BSD 2 Clause License and
  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
  * was not distributed with this source code in the LICENSE file, you can
  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
+#include <assert.h>
 #include <emmintrin.h>  // SSE2
 
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
 
 #include "aom_ports/mem.h"
 
+#include "./av1_rtcd.h"
+#include "av1/common/filter.h"
+
 typedef uint32_t (*high_variance_fn_t)(const uint16_t *src, int src_stride,
                                        const uint16_t *ref, int ref_stride,
                                        uint32_t *sse, int *sum);
 
 uint32_t aom_highbd_calc8x8var_sse2(const uint16_t *src, int src_stride,
                                     const uint16_t *ref, int ref_stride,
                                     uint32_t *sse, int *sum);
 
@@ -407,19 +411,19 @@ FNS(sse2);
 
 // The 2 unused parameters are place holders for PIC enabled build.
 #define DECL(w, opt)                                                         \
   int aom_highbd_sub_pixel_avg_variance##w##xh_##opt(                        \
       const uint16_t *src, ptrdiff_t src_stride, int x_offset, int y_offset, \
       const uint16_t *dst, ptrdiff_t dst_stride, const uint16_t *sec,        \
       ptrdiff_t sec_stride, int height, unsigned int *sse, void *unused0,    \
       void *unused);
-#define DECLS(opt1) \
-  DECL(16, opt1)    \
-  DECL(8, opt1)
+#define DECLS(opt) \
+  DECL(16, opt)    \
+  DECL(8, opt)
 
 DECLS(sse2);
 #undef DECL
 #undef DECLS
 
 #define FN(w, h, wf, wlog2, hlog2, opt, cast)                                  \
   uint32_t aom_highbd_8_sub_pixel_avg_variance##w##x##h##_##opt(               \
       const uint8_t *src8, int src_stride, int x_offset, int y_offset,         \
@@ -541,155 +545,120 @@ DECLS(sse2);
     }                                                                          \
     se = ROUND_POWER_OF_TWO(se, 4);                                            \
     sse = (uint32_t)ROUND_POWER_OF_TWO(long_sse, 8);                           \
     *sse_ptr = sse;                                                            \
     var = (int64_t)(sse) - ((cast se * se) >> (wlog2 + hlog2));                \
     return (var >= 0) ? (uint32_t)var : 0;                                     \
   }
 
-#define FNS(opt1)                        \
-  FN(64, 64, 16, 6, 6, opt1, (int64_t)); \
-  FN(64, 32, 16, 6, 5, opt1, (int64_t)); \
-  FN(32, 64, 16, 5, 6, opt1, (int64_t)); \
-  FN(32, 32, 16, 5, 5, opt1, (int64_t)); \
-  FN(32, 16, 16, 5, 4, opt1, (int64_t)); \
-  FN(16, 32, 16, 4, 5, opt1, (int64_t)); \
-  FN(16, 16, 16, 4, 4, opt1, (int64_t)); \
-  FN(16, 8, 16, 4, 3, opt1, (int64_t));  \
-  FN(8, 16, 8, 4, 3, opt1, (int64_t));   \
-  FN(8, 8, 8, 3, 3, opt1, (int64_t));    \
-  FN(8, 4, 8, 3, 2, opt1, (int64_t));
+#define FNS(opt)                        \
+  FN(64, 64, 16, 6, 6, opt, (int64_t)); \
+  FN(64, 32, 16, 6, 5, opt, (int64_t)); \
+  FN(32, 64, 16, 5, 6, opt, (int64_t)); \
+  FN(32, 32, 16, 5, 5, opt, (int64_t)); \
+  FN(32, 16, 16, 5, 4, opt, (int64_t)); \
+  FN(16, 32, 16, 4, 5, opt, (int64_t)); \
+  FN(16, 16, 16, 4, 4, opt, (int64_t)); \
+  FN(16, 8, 16, 4, 3, opt, (int64_t));  \
+  FN(8, 16, 8, 3, 4, opt, (int64_t));   \
+  FN(8, 8, 8, 3, 3, opt, (int64_t));    \
+  FN(8, 4, 8, 3, 2, opt, (int64_t));
 
 FNS(sse2);
 
 #undef FNS
 #undef FN
 
 void aom_highbd_upsampled_pred_sse2(uint16_t *comp_pred, int width, int height,
-                                    const uint8_t *ref8, int ref_stride) {
-  int i, j;
-  int stride = ref_stride << 3;
-  uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
-
-  if (width >= 8) {
-    // read 8 points at one time
-    for (i = 0; i < height; i++) {
-      for (j = 0; j < width; j += 8) {
-        __m128i s0 = _mm_cvtsi32_si128(*(const uint32_t *)ref);
-        __m128i s1 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 8));
-        __m128i s2 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 16));
-        __m128i s3 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 24));
-        __m128i s4 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 32));
-        __m128i s5 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 40));
-        __m128i s6 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 48));
-        __m128i s7 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 56));
-        __m128i t0, t1, t2, t3;
-
-        t0 = _mm_unpacklo_epi16(s0, s1);
-        t1 = _mm_unpacklo_epi16(s2, s3);
-        t2 = _mm_unpacklo_epi16(s4, s5);
-        t3 = _mm_unpacklo_epi16(s6, s7);
-        t0 = _mm_unpacklo_epi32(t0, t1);
-        t2 = _mm_unpacklo_epi32(t2, t3);
-        t0 = _mm_unpacklo_epi64(t0, t2);
-
-        _mm_storeu_si128((__m128i *)(comp_pred), t0);
+                                    int subpel_x_q3, int subpel_y_q3,
+                                    const uint8_t *ref8, int ref_stride,
+                                    int bd) {
+  if (!subpel_x_q3 && !subpel_y_q3) {
+    uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
+    if (width >= 8) {
+      int i;
+      assert(!(width & 7));
+      /*Read 8 pixels one row at a time.*/
+      for (i = 0; i < height; i++) {
+        int j;
+        for (j = 0; j < width; j += 8) {
+          __m128i s0 = _mm_loadu_si128((const __m128i *)ref);
+          _mm_storeu_si128((__m128i *)comp_pred, s0);
+          comp_pred += 8;
+          ref += 8;
+        }
+        ref += ref_stride - width;
+      }
+    } else {
+      int i;
+      assert(!(width & 3));
+      /*Read 4 pixels two rows at a time.*/
+      for (i = 0; i < height; i += 2) {
+        __m128i s0 = _mm_loadl_epi64((const __m128i *)ref);
+        __m128i s1 = _mm_loadl_epi64((const __m128i *)(ref + ref_stride));
+        __m128i t0 = _mm_unpacklo_epi64(s0, s1);
+        _mm_storeu_si128((__m128i *)comp_pred, t0);
         comp_pred += 8;
-        ref += 64;  // 8 * 8;
+        ref += 2 * ref_stride;
       }
-      ref += stride - (width << 3);
     }
   } else {
-    // read 4 points at one time
-    for (i = 0; i < height; i++) {
-      for (j = 0; j < width; j += 4) {
-        __m128i s0 = _mm_cvtsi32_si128(*(const uint32_t *)ref);
-        __m128i s1 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 8));
-        __m128i s2 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 16));
-        __m128i s3 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 24));
-        __m128i t0, t1;
-
-        t0 = _mm_unpacklo_epi16(s0, s1);
-        t1 = _mm_unpacklo_epi16(s2, s3);
-        t0 = _mm_unpacklo_epi32(t0, t1);
-
-        _mm_storel_epi64((__m128i *)(comp_pred), t0);
-        comp_pred += 4;
-        ref += 4 * 8;
-      }
-      ref += stride - (width << 3);
+    InterpFilterParams filter;
+    filter = av1_get_interp_filter_params(EIGHTTAP_REGULAR);
+    if (!subpel_y_q3) {
+      const int16_t *kernel;
+      kernel = av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
+      aom_highbd_convolve8_horiz(ref8, ref_stride,
+                                 CONVERT_TO_BYTEPTR(comp_pred), width, kernel,
+                                 16, NULL, -1, width, height, bd);
+    } else if (!subpel_x_q3) {
+      const int16_t *kernel;
+      kernel = av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
+      aom_highbd_convolve8_vert(ref8, ref_stride, CONVERT_TO_BYTEPTR(comp_pred),
+                                width, NULL, -1, kernel, 16, width, height, bd);
+    } else {
+      DECLARE_ALIGNED(16, uint16_t,
+                      temp[((MAX_SB_SIZE * 2 + 16) + 16) * MAX_SB_SIZE]);
+      const uint16_t *ref;
+      const int16_t *kernel_x;
+      const int16_t *kernel_y;
+      int intermediate_height;
+      ref = CONVERT_TO_SHORTPTR(ref8);
+      kernel_x = av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
+      kernel_y = av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
+      intermediate_height =
+          (((height - 1) * 8 + subpel_y_q3) >> 3) + filter.taps;
+      assert(intermediate_height <= (MAX_SB_SIZE * 2 + 16) + 16);
+      aom_highbd_convolve8_horiz(
+          CONVERT_TO_BYTEPTR(ref - ref_stride * ((filter.taps >> 1) - 1)),
+          ref_stride, CONVERT_TO_BYTEPTR(temp), MAX_SB_SIZE, kernel_x, 16, NULL,
+          -1, width, intermediate_height, bd);
+      aom_highbd_convolve8_vert(
+          CONVERT_TO_BYTEPTR(temp + MAX_SB_SIZE * ((filter.taps >> 1) - 1)),
+          MAX_SB_SIZE, CONVERT_TO_BYTEPTR(comp_pred), width, NULL, -1, kernel_y,
+          16, width, height, bd);
     }
   }
 }
 
 void aom_highbd_comp_avg_upsampled_pred_sse2(uint16_t *comp_pred,
                                              const uint8_t *pred8, int width,
-                                             int height, const uint8_t *ref8,
-                                             int ref_stride) {
-  const __m128i one = _mm_set1_epi16(1);
-  int i, j;
-  int stride = ref_stride << 3;
+                                             int height, int subpel_x_q3,
+                                             int subpel_y_q3,
+                                             const uint8_t *ref8,
+                                             int ref_stride, int bd) {
   uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
-  uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
-
-  if (width >= 8) {
-    // read 8 points at one time
-    for (i = 0; i < height; i++) {
-      for (j = 0; j < width; j += 8) {
-        __m128i s0 = _mm_cvtsi32_si128(*(const uint32_t *)ref);
-        __m128i s1 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 8));
-        __m128i s2 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 16));
-        __m128i s3 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 24));
-        __m128i s4 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 32));
-        __m128i s5 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 40));
-        __m128i s6 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 48));
-        __m128i s7 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 56));
-        __m128i p0 = _mm_loadu_si128((const __m128i *)pred);
-        __m128i t0, t1, t2, t3;
-
-        t0 = _mm_unpacklo_epi16(s0, s1);
-        t1 = _mm_unpacklo_epi16(s2, s3);
-        t2 = _mm_unpacklo_epi16(s4, s5);
-        t3 = _mm_unpacklo_epi16(s6, s7);
-        t0 = _mm_unpacklo_epi32(t0, t1);
-        t2 = _mm_unpacklo_epi32(t2, t3);
-        t0 = _mm_unpacklo_epi64(t0, t2);
-
-        p0 = _mm_adds_epu16(t0, p0);
-        p0 = _mm_adds_epu16(p0, one);
-        p0 = _mm_srli_epi16(p0, 1);
-
-        _mm_storeu_si128((__m128i *)(comp_pred), p0);
-        comp_pred += 8;
-        pred += 8;
-        ref += 8 * 8;
-      }
-      ref += stride - (width << 3);
-    }
-  } else {
-    // read 4 points at one time
-    for (i = 0; i < height; i++) {
-      for (j = 0; j < width; j += 4) {
-        __m128i s0 = _mm_cvtsi32_si128(*(const uint32_t *)ref);
-        __m128i s1 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 8));
-        __m128i s2 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 16));
-        __m128i s3 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + 24));
-        __m128i p0 = _mm_loadl_epi64((const __m128i *)pred);
-        __m128i t0, t1;
-
-        t0 = _mm_unpacklo_epi16(s0, s1);
-        t1 = _mm_unpacklo_epi16(s2, s3);
-        t0 = _mm_unpacklo_epi32(t0, t1);
-
-        p0 = _mm_adds_epu16(t0, p0);
-        p0 = _mm_adds_epu16(p0, one);
-        p0 = _mm_srli_epi16(p0, 1);
-
-        _mm_storel_epi64((__m128i *)(comp_pred), p0);
-        comp_pred += 4;
-        pred += 4;
-        ref += 4 * 8;
-      }
-      ref += stride - (width << 3);
-    }
+  int n;
+  int i;
+  aom_highbd_upsampled_pred(comp_pred, width, height, subpel_x_q3, subpel_y_q3,
+                            ref8, ref_stride, bd);
+  /*The total number of pixels must be a multiple of 8 (e.g., 4x4).*/
+  assert(!(width * height & 7));
+  n = width * height >> 3;
+  for (i = 0; i < n; i++) {
+    __m128i s0 = _mm_loadu_si128((const __m128i *)comp_pred);
+    __m128i p0 = _mm_loadu_si128((const __m128i *)pred);
+    _mm_storeu_si128((__m128i *)comp_pred, _mm_avg_epu16(s0, p0));
+    comp_pred += 8;
+    pred += 8;
   }
 }
--- a/third_party/aom/aom_dsp/x86/inv_txfm_sse2.c
+++ b/third_party/aom/aom_dsp/x86/inv_txfm_sse2.c
@@ -3493,242 +3493,8 @@ void idct32_8col(__m128i *in0, __m128i *
   in1[9] = _mm_sub_epi16(stp1_6, stp1_25);
   in1[10] = _mm_sub_epi16(stp1_5, stp1_26);
   in1[11] = _mm_sub_epi16(stp1_4, stp1_27);
   in1[12] = _mm_sub_epi16(stp1_3, stp1_28);
   in1[13] = _mm_sub_epi16(stp1_2, stp1_29);
   in1[14] = _mm_sub_epi16(stp1_1, stp1_30);
   in1[15] = _mm_sub_epi16(stp1_0, stp1_31);
 }
-
-#if CONFIG_HIGHBITDEPTH
-static INLINE __m128i clamp_high_sse2(__m128i value, int bd) {
-  __m128i ubounded, retval;
-  const __m128i zero = _mm_set1_epi16(0);
-  const __m128i one = _mm_set1_epi16(1);
-  const __m128i max = _mm_subs_epi16(_mm_slli_epi16(one, bd), one);
-  ubounded = _mm_cmpgt_epi16(value, max);
-  retval = _mm_andnot_si128(ubounded, value);
-  ubounded = _mm_and_si128(ubounded, max);
-  retval = _mm_or_si128(retval, ubounded);
-  retval = _mm_and_si128(retval, _mm_cmpgt_epi16(retval, zero));
-  return retval;
-}
-
-void aom_highbd_idct4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest8,
-                                    int stride, int bd) {
-  tran_low_t out[4 * 4];
-  tran_low_t *outptr = out;
-  int i, j;
-  __m128i inptr[4];
-  __m128i sign_bits[2];
-  __m128i temp_mm, min_input, max_input;
-  int test;
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-  int optimised_cols = 0;
-  const __m128i zero = _mm_set1_epi16(0);
-  const __m128i eight = _mm_set1_epi16(8);
-  const __m128i max = _mm_set1_epi16(12043);
-  const __m128i min = _mm_set1_epi16(-12043);
-  // Load input into __m128i
-  inptr[0] = _mm_loadu_si128((const __m128i *)input);
-  inptr[1] = _mm_loadu_si128((const __m128i *)(input + 4));
-  inptr[2] = _mm_loadu_si128((const __m128i *)(input + 8));
-  inptr[3] = _mm_loadu_si128((const __m128i *)(input + 12));
-
-  // Pack to 16 bits
-  inptr[0] = _mm_packs_epi32(inptr[0], inptr[1]);
-  inptr[1] = _mm_packs_epi32(inptr[2], inptr[3]);
-
-  max_input = _mm_max_epi16(inptr[0], inptr[1]);
-  min_input = _mm_min_epi16(inptr[0], inptr[1]);
-  max_input = _mm_cmpgt_epi16(max_input, max);
-  min_input = _mm_cmplt_epi16(min_input, min);
-  temp_mm = _mm_or_si128(max_input, min_input);
-  test = _mm_movemask_epi8(temp_mm);
-
-  if (!test) {
-    // Do the row transform
-    aom_idct4_sse2(inptr);
-
-    // Check the min & max values
-    max_input = _mm_max_epi16(inptr[0], inptr[1]);
-    min_input = _mm_min_epi16(inptr[0], inptr[1]);
-    max_input = _mm_cmpgt_epi16(max_input, max);
-    min_input = _mm_cmplt_epi16(min_input, min);
-    temp_mm = _mm_or_si128(max_input, min_input);
-    test = _mm_movemask_epi8(temp_mm);
-
-    if (test) {
-      array_transpose_4x4(inptr);
-      sign_bits[0] = _mm_cmplt_epi16(inptr[0], zero);
-      sign_bits[1] = _mm_cmplt_epi16(inptr[1], zero);
-      inptr[3] = _mm_unpackhi_epi16(inptr[1], sign_bits[1]);
-      inptr[2] = _mm_unpacklo_epi16(inptr[1], sign_bits[1]);
-      inptr[1] = _mm_unpackhi_epi16(inptr[0], sign_bits[0]);
-      inptr[0] = _mm_unpacklo_epi16(inptr[0], sign_bits[0]);
-      _mm_storeu_si128((__m128i *)outptr, inptr[0]);
-      _mm_storeu_si128((__m128i *)(outptr + 4), inptr[1]);
-      _mm_storeu_si128((__m128i *)(outptr + 8), inptr[2]);
-      _mm_storeu_si128((__m128i *)(outptr + 12), inptr[3]);
-    } else {
-      // Set to use the optimised transform for the column
-      optimised_cols = 1;
-    }
-  } else {
-    // Run the un-optimised row transform
-    for (i = 0; i < 4; ++i) {
-      aom_highbd_idct4_c(input, outptr, bd);
-      input += 4;
-      outptr += 4;
-    }
-  }
-
-  if (optimised_cols) {
-    aom_idct4_sse2(inptr);
-
-    // Final round and shift
-    inptr[0] = _mm_add_epi16(inptr[0], eight);
-    inptr[1] = _mm_add_epi16(inptr[1], eight);
-
-    inptr[0] = _mm_srai_epi16(inptr[0], 4);
-    inptr[1] = _mm_srai_epi16(inptr[1], 4);
-
-    // Reconstruction and Store
-    {
-      __m128i d0 = _mm_loadl_epi64((const __m128i *)dest);
-      __m128i d2 = _mm_loadl_epi64((const __m128i *)(dest + stride * 2));
-      d0 = _mm_unpacklo_epi64(
-          d0, _mm_loadl_epi64((const __m128i *)(dest + stride)));
-      d2 = _mm_unpacklo_epi64(
-          d2, _mm_loadl_epi64((const __m128i *)(dest + stride * 3)));
-      d0 = clamp_high_sse2(_mm_adds_epi16(d0, inptr[0]), bd);
-      d2 = clamp_high_sse2(_mm_adds_epi16(d2, inptr[1]), bd);
-      // store input0
-      _mm_storel_epi64((__m128i *)dest, d0);
-      // store input1
-      d0 = _mm_srli_si128(d0, 8);
-      _mm_storel_epi64((__m128i *)(dest + stride), d0);
-      // store input2
-      _mm_storel_epi64((__m128i *)(dest + stride * 2), d2);
-      // store input3
-      d2 = _mm_srli_si128(d2, 8);
-      _mm_storel_epi64((__m128i *)(dest + stride * 3), d2);
-    }
-  } else {
-    // Run the un-optimised column transform
-    tran_low_t temp_in[4], temp_out[4];
-    // Columns
-    for (i = 0; i < 4; ++i) {
-      for (j = 0; j < 4; ++j) temp_in[j] = out[j * 4 + i];
-      aom_highbd_idct4_c(temp_in, temp_out, bd);
-      for (j = 0; j < 4; ++j) {
-        dest[j * stride + i] = highbd_clip_pixel_add(
-            dest[j * stride + i], ROUND_POWER_OF_TWO(temp_out[j], 4), bd);
-      }
-    }
-  }
-}
-
-void aom_highbd_idct8x8_10_add_sse2(const tran_low_t *input, uint8_t *dest8,
-                                    int stride, int bd) {
-  tran_low_t out[8 * 8] = { 0 };
-  tran_low_t *outptr = out;
-  int i, j, test;
-  __m128i inptr[8];
-  __m128i min_input, max_input, temp1, temp2, sign_bits;
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-  const __m128i zero = _mm_set1_epi16(0);
-  const __m128i sixteen = _mm_set1_epi16(16);
-  const __m128i max = _mm_set1_epi16(6201);
-  const __m128i min = _mm_set1_epi16(-6201);
-  int optimised_cols = 0;
-
-  // Load input into __m128i & pack to 16 bits
-  for (i = 0; i < 8; i++) {
-    temp1 = _mm_loadu_si128((const __m128i *)(input + 8 * i));
-    temp2 = _mm_loadu_si128((const __m128i *)(input + 8 * i + 4));
-    inptr[i] = _mm_packs_epi32(temp1, temp2);
-  }
-
-  // Find the min & max for the row transform
-  // only first 4 row has non-zero coefs
-  max_input = _mm_max_epi16(inptr[0], inptr[1]);
-  min_input = _mm_min_epi16(inptr[0], inptr[1]);
-  for (i = 2; i < 4; i++) {
-    max_input = _mm_max_epi16(max_input, inptr[i]);
-    min_input = _mm_min_epi16(min_input, inptr[i]);
-  }
-  max_input = _mm_cmpgt_epi16(max_input, max);
-  min_input = _mm_cmplt_epi16(min_input, min);
-  temp1 = _mm_or_si128(max_input, min_input);
-  test = _mm_movemask_epi8(temp1);
-
-  if (!test) {
-    // Do the row transform
-    aom_idct8_sse2(inptr);
-
-    // Find the min & max for the column transform
-    // N.B. Only first 4 cols contain non-zero coeffs
-    max_input = _mm_max_epi16(inptr[0], inptr[1]);
-    min_input = _mm_min_epi16(inptr[0], inptr[1]);
-    for (i = 2; i < 8; i++) {
-      max_input = _mm_max_epi16(max_input, inptr[i]);
-      min_input = _mm_min_epi16(min_input, inptr[i]);
-    }
-    max_input = _mm_cmpgt_epi16(max_input, max);
-    min_input = _mm_cmplt_epi16(min_input, min);
-    temp1 = _mm_or_si128(max_input, min_input);
-    test = _mm_movemask_epi8(temp1);
-
-    if (test) {
-      // Use fact only first 4 rows contain non-zero coeffs
-      array_transpose_4X8(inptr, inptr);
-      for (i = 0; i < 4; i++) {
-        sign_bits = _mm_cmplt_epi16(inptr[i], zero);
-        temp1 = _mm_unpackhi_epi16(inptr[i], sign_bits);
-        temp2 = _mm_unpacklo_epi16(inptr[i], sign_bits);
-        _mm_storeu_si128((__m128i *)(outptr + 4 * (2 * i + 1)), temp1);
-        _mm_storeu_si128((__m128i *)(outptr + 4 * (2 * i)), temp2);
-      }
-    } else {
-      // Set to use the optimised transform for the column
-      optimised_cols = 1;
-    }
-  } else {
-    // Run the un-optimised row transform
-    for (i = 0; i < 4; ++i) {
-      aom_highbd_idct8_c(input, outptr, bd);
-      input += 8;
-      outptr += 8;
-    }
-  }
-
-  if (optimised_cols) {
-    aom_idct8_sse2(inptr);
-
-    // Final round & shift and Reconstruction and Store
-    {
-      __m128i d[8];
-      for (i = 0; i < 8; i++) {
-        inptr[i] = _mm_add_epi16(inptr[i], sixteen);
-        d[i] = _mm_loadu_si128((const __m128i *)(dest + stride * i));
-        inptr[i] = _mm_srai_epi16(inptr[i], 5);
-        d[i] = clamp_high_sse2(_mm_adds_epi16(d[i], inptr[i]), bd);
-        // Store
-        _mm_storeu_si128((__m128i *)(dest + stride * i), d[i]);
-      }
-    }
-  } else {
-    // Run the un-optimised column transform
-    tran_low_t temp_in[8], temp_out[8];
-    for (i = 0; i < 8; ++i) {
-      for (j = 0; j < 8; ++j) temp_in[j] = out[j * 8 + i];
-      aom_highbd_idct8_c(temp_in, temp_out, bd);
-      for (j = 0; j < 8; ++j) {
-        dest[j * stride + i] = highbd_clip_pixel_add(
-            dest[j * stride + i], ROUND_POWER_OF_TWO(temp_out[j], 5), bd);
-      }
-    }
-  }
-}
-
-#endif  // CONFIG_HIGHBITDEPTH
--- a/third_party/aom/aom_dsp/x86/sad_highbd_avx2.c
+++ b/third_party/aom/aom_dsp/x86/sad_highbd_avx2.c
@@ -699,17 +699,22 @@ unsigned int aom_highbd_sad128x128_avg_a
 }
 #endif  // CONFIG_EXT_PARTITION
 
 // SAD 4D
 // Combine 4 __m256i vectors to uint32_t result[4]
 static INLINE void get_4d_sad_from_mm256_epi32(const __m256i *v,
                                                uint32_t *res) {
   __m256i u0, u1, u2, u3;
+#if defined(_MSC_VER) && defined(_M_IX86) && _MSC_VER < 1900
+  const __m256i mask = _mm256_setr_epi32(UINT32_MAX, 0, UINT32_MAX, 0,
+                                         UINT32_MAX, 0, UINT32_MAX, 0);
+#else
   const __m256i mask = _mm256_set1_epi64x(UINT32_MAX);
+#endif
   __m128i sad;
 
   // 8 32-bit summation
   u0 = _mm256_srli_si256(v[0], 4);
   u1 = _mm256_srli_si256(v[1], 4);
   u2 = _mm256_srli_si256(v[2], 4);
   u3 = _mm256_srli_si256(v[3], 4);
 
--- a/third_party/aom/aom_dsp/x86/variance_sse2.c
+++ b/third_party/aom/aom_dsp/x86/variance_sse2.c
@@ -12,16 +12,19 @@
 #include <assert.h>
 #include <emmintrin.h>  // SSE2
 
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
 
 #include "aom_ports/mem.h"
 
+#include "./av1_rtcd.h"
+#include "av1/common/filter.h"
+
 typedef void (*getNxMvar_fn_t)(const unsigned char *src, int src_stride,
                                const unsigned char *ref, int ref_stride,
                                unsigned int *sse, int *sum);
 
 unsigned int aom_get_mb_ss_sse2(const int16_t *src) {
   __m128i vsum = _mm_setzero_si128();
   int i;
 
@@ -337,23 +340,23 @@ unsigned int aom_mse16x16_sse2(const uin
 
 // The 2 unused parameters are place holders for PIC enabled build.
 // These definitions are for functions defined in subpel_variance.asm
 #define DECL(w, opt)                                                           \
   int aom_sub_pixel_variance##w##xh_##opt(                                     \
       const uint8_t *src, ptrdiff_t src_stride, int x_offset, int y_offset,    \
       const uint8_t *dst, ptrdiff_t dst_stride, int height, unsigned int *sse, \
       void *unused0, void *unused)
-#define DECLS(opt1, opt2) \
-  DECL(4, opt1);          \
-  DECL(8, opt1);          \
-  DECL(16, opt1)
+#define DECLS(opt) \
+  DECL(4, opt);    \
+  DECL(8, opt);    \
+  DECL(16, opt)
 
-DECLS(sse2, sse2);
-DECLS(ssse3, ssse3);
+DECLS(sse2);
+DECLS(ssse3);
 #undef DECLS
 #undef DECL
 
 #define FN(w, h, wf, wlog2, hlog2, opt, cast_prod, cast)                       \
   unsigned int aom_sub_pixel_variance##w##x##h##_##opt(                        \
       const uint8_t *src, int src_stride, int x_offset, int y_offset,          \
       const uint8_t *dst, int dst_stride, unsigned int *sse_ptr) {             \
     unsigned int sse;                                                          \
@@ -379,51 +382,51 @@ DECLS(ssse3, ssse3);
         se += se2;                                                             \
         sse += sse2;                                                           \
       }                                                                        \
     }                                                                          \
     *sse_ptr = sse;                                                            \
     return sse - (unsigned int)(cast_prod(cast se * se) >> (wlog2 + hlog2));   \
   }
 
-#define FNS(opt1, opt2)                              \
-  FN(64, 64, 16, 6, 6, opt1, (int64_t), (int64_t));  \
-  FN(64, 32, 16, 6, 5, opt1, (int64_t), (int64_t));  \
-  FN(32, 64, 16, 5, 6, opt1, (int64_t), (int64_t));  \
-  FN(32, 32, 16, 5, 5, opt1, (int64_t), (int64_t));  \
-  FN(32, 16, 16, 5, 4, opt1, (int64_t), (int64_t));  \
-  FN(16, 32, 16, 4, 5, opt1, (int64_t), (int64_t));  \
-  FN(16, 16, 16, 4, 4, opt1, (uint32_t), (int64_t)); \
-  FN(16, 8, 16, 4, 3, opt1, (int32_t), (int32_t));   \
-  FN(8, 16, 8, 3, 4, opt1, (int32_t), (int32_t));    \
-  FN(8, 8, 8, 3, 3, opt1, (int32_t), (int32_t));     \
-  FN(8, 4, 8, 3, 2, opt1, (int32_t), (int32_t));     \
-  FN(4, 8, 4, 2, 3, opt1, (int32_t), (int32_t));     \
-  FN(4, 4, 4, 2, 2, opt1, (int32_t), (int32_t))
+#define FNS(opt)                                    \
+  FN(64, 64, 16, 6, 6, opt, (int64_t), (int64_t));  \
+  FN(64, 32, 16, 6, 5, opt, (int64_t), (int64_t));  \
+  FN(32, 64, 16, 5, 6, opt, (int64_t), (int64_t));  \
+  FN(32, 32, 16, 5, 5, opt, (int64_t), (int64_t));  \
+  FN(32, 16, 16, 5, 4, opt, (int64_t), (int64_t));  \
+  FN(16, 32, 16, 4, 5, opt, (int64_t), (int64_t));  \
+  FN(16, 16, 16, 4, 4, opt, (uint32_t), (int64_t)); \
+  FN(16, 8, 16, 4, 3, opt, (int32_t), (int32_t));   \
+  FN(8, 16, 8, 3, 4, opt, (int32_t), (int32_t));    \
+  FN(8, 8, 8, 3, 3, opt, (int32_t), (int32_t));     \
+  FN(8, 4, 8, 3, 2, opt, (int32_t), (int32_t));     \
+  FN(4, 8, 4, 2, 3, opt, (int32_t), (int32_t));     \
+  FN(4, 4, 4, 2, 2, opt, (int32_t), (int32_t))
 
-FNS(sse2, sse2);
-FNS(ssse3, ssse3);
+FNS(sse2);
+FNS(ssse3);
 
 #undef FNS
 #undef FN
 
 // The 2 unused parameters are place holders for PIC enabled build.
 #define DECL(w, opt)                                                        \
   int aom_sub_pixel_avg_variance##w##xh_##opt(                              \
       const uint8_t *src, ptrdiff_t src_stride, int x_offset, int y_offset, \
       const uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *sec,         \
       ptrdiff_t sec_stride, int height, unsigned int *sse, void *unused0,   \
       void *unused)
-#define DECLS(opt1, opt2) \
-  DECL(4, opt1);          \
-  DECL(8, opt1);          \
-  DECL(16, opt1)
+#define DECLS(opt) \
+  DECL(4, opt);    \
+  DECL(8, opt);    \
+  DECL(16, opt)
 
-DECLS(sse2, sse2);
-DECLS(ssse3, ssse3);
+DECLS(sse2);
+DECLS(ssse3);
 #undef DECL
 #undef DECLS
 
 #define FN(w, h, wf, wlog2, hlog2, opt, cast_prod, cast)                       \
   unsigned int aom_sub_pixel_avg_variance##w##x##h##_##opt(                    \
       const uint8_t *src, int src_stride, int x_offset, int y_offset,          \
       const uint8_t *dst, int dst_stride, unsigned int *sseptr,                \
       const uint8_t *sec) {                                                    \
@@ -450,241 +453,133 @@ DECLS(ssse3, ssse3);
         se += se2;                                                             \
         sse += sse2;                                                           \
       }                                                                        \
     }                                                                          \
     *sseptr = sse;                                                             \
     return sse - (unsigned int)(cast_prod(cast se * se) >> (wlog2 + hlog2));   \
   }
 
-#define FNS(opt1, opt2)                              \
-  FN(64, 64, 16, 6, 6, opt1, (int64_t), (int64_t));  \
-  FN(64, 32, 16, 6, 5, opt1, (int64_t), (int64_t));  \
-  FN(32, 64, 16, 5, 6, opt1, (int64_t), (int64_t));  \
-  FN(32, 32, 16, 5, 5, opt1, (int64_t), (int64_t));  \
-  FN(32, 16, 16, 5, 4, opt1, (int64_t), (int64_t));  \
-  FN(16, 32, 16, 4, 5, opt1, (int64_t), (int64_t));  \
-  FN(16, 16, 16, 4, 4, opt1, (uint32_t), (int64_t)); \
-  FN(16, 8, 16, 4, 3, opt1, (uint32_t), (int32_t));  \
-  FN(8, 16, 8, 3, 4, opt1, (uint32_t), (int32_t));   \
-  FN(8, 8, 8, 3, 3, opt1, (uint32_t), (int32_t));    \
-  FN(8, 4, 8, 3, 2, opt1, (uint32_t), (int32_t));    \
-  FN(4, 8, 4, 2, 3, opt1, (uint32_t), (int32_t));    \
-  FN(4, 4, 4, 2, 2, opt1, (uint32_t), (int32_t))
+#define FNS(opt)                                    \
+  FN(64, 64, 16, 6, 6, opt, (int64_t), (int64_t));  \
+  FN(64, 32, 16, 6, 5, opt, (int64_t), (int64_t));  \
+  FN(32, 64, 16, 5, 6, opt, (int64_t), (int64_t));  \
+  FN(32, 32, 16, 5, 5, opt, (int64_t), (int64_t));  \
+  FN(32, 16, 16, 5, 4, opt, (int64_t), (int64_t));  \
+  FN(16, 32, 16, 4, 5, opt, (int64_t), (int64_t));  \
+  FN(16, 16, 16, 4, 4, opt, (uint32_t), (int64_t)); \
+  FN(16, 8, 16, 4, 3, opt, (uint32_t), (int32_t));  \
+  FN(8, 16, 8, 3, 4, opt, (uint32_t), (int32_t));   \
+  FN(8, 8, 8, 3, 3, opt, (uint32_t), (int32_t));    \
+  FN(8, 4, 8, 3, 2, opt, (uint32_t), (int32_t));    \
+  FN(4, 8, 4, 2, 3, opt, (uint32_t), (int32_t));    \
+  FN(4, 4, 4, 2, 2, opt, (uint32_t), (int32_t))
 
-FNS(sse2, sse);
-FNS(ssse3, ssse3);
+FNS(sse2);
+FNS(ssse3);
 
 #undef FNS
 #undef FN
 
 void aom_upsampled_pred_sse2(uint8_t *comp_pred, int width, int height,
+                             int subpel_x_q3, int subpel_y_q3,
                              const uint8_t *ref, int ref_stride) {
-  int i, j;
-  int stride = ref_stride << 3;
-
-  if (width >= 16) {
-    // read 16 points at one time
-    for (i = 0; i < height; i++) {
-      for (j = 0; j < width; j += 16) {
-        __m128i s0 = _mm_loadu_si128((const __m128i *)ref);
-        __m128i s1 = _mm_loadu_si128((const __m128i *)(ref + 16));
-        __m128i s2 = _mm_loadu_si128((const __m128i *)(ref + 32));
-        __m128i s3 = _mm_loadu_si128((const __m128i *)(ref + 48));
-        __m128i s4 = _mm_loadu_si128((const __m128i *)(ref + 64));
-        __m128i s5 = _mm_loadu_si128((const __m128i *)(ref + 80));
-        __m128i s6 = _mm_loadu_si128((const __m128i *)(ref + 96));
-        __m128i s7 = _mm_loadu_si128((const __m128i *)(ref + 112));
-        __m128i t0, t1, t2, t3;
-
-        t0 = _mm_unpacklo_epi8(s0, s1);
-        s1 = _mm_unpackhi_epi8(s0, s1);
-        t1 = _mm_unpacklo_epi8(s2, s3);
-        s3 = _mm_unpackhi_epi8(s2, s3);
-        t2 = _mm_unpacklo_epi8(s4, s5);
-        s5 = _mm_unpackhi_epi8(s4, s5);
-        t3 = _mm_unpacklo_epi8(s6, s7);
-        s7 = _mm_unpackhi_epi8(s6, s7);
-
-        s0 = _mm_unpacklo_epi8(t0, s1);
-        s2 = _mm_unpacklo_epi8(t1, s3);
-        s4 = _mm_unpacklo_epi8(t2, s5);
-        s6 = _mm_unpacklo_epi8(t3, s7);
-        s0 = _mm_unpacklo_epi32(s0, s2);
-        s4 = _mm_unpacklo_epi32(s4, s6);
-        s0 = _mm_unpacklo_epi64(s0, s4);
-
-        _mm_storeu_si128((__m128i *)(comp_pred), s0);
+  if (!subpel_x_q3 && !subpel_y_q3) {
+    if (width >= 16) {
+      int i;
+      assert(!(width & 15));
+      /*Read 16 pixels one row at a time.*/
+      for (i = 0; i < height; i++) {
+        int j;
+        for (j = 0; j < width; j += 16) {
+          __m128i s0 = _mm_loadu_si128((const __m128i *)ref);
+          _mm_storeu_si128((__m128i *)comp_pred, s0);
+          comp_pred += 16;
+          ref += 16;
+        }
+        ref += ref_stride - width;
+      }
+    } else if (width >= 8) {
+      int i;
+      assert(!(width & 7));
+      assert(!(height & 1));
+      /*Read 8 pixels two rows at a time.*/
+      for (i = 0; i < height; i += 2) {
+        __m128i s0 = _mm_loadl_epi64((const __m128i *)ref);
+        __m128i s1 = _mm_loadl_epi64((const __m128i *)(ref + ref_stride));
+        __m128i t0 = _mm_unpacklo_epi64(s0, s1);
+        _mm_storeu_si128((__m128i *)comp_pred, t0);
         comp_pred += 16;
-        ref += 16 * 8;
+        ref += 2 * ref_stride;
       }
-      ref += stride - (width << 3);
-    }
-  } else if (width >= 8) {
-    // read 8 points at one time
-    for (i = 0; i < height; i++) {
-      for (j = 0; j < width; j += 8) {
-        __m128i s0 = _mm_loadu_si128((const __m128i *)ref);
-        __m128i s1 = _mm_loadu_si128((const __m128i *)(ref + 16));
-        __m128i s2 = _mm_loadu_si128((const __m128i *)(ref + 32));
-        __m128i s3 = _mm_loadu_si128((const __m128i *)(ref + 48));
-        __m128i t0, t1;
-
-        t0 = _mm_unpacklo_epi8(s0, s1);
-        s1 = _mm_unpackhi_epi8(s0, s1);
-        t1 = _mm_unpacklo_epi8(s2, s3);
-        s3 = _mm_unpackhi_epi8(s2, s3);
-
-        s0 = _mm_unpacklo_epi8(t0, s1);
-        s2 = _mm_unpacklo_epi8(t1, s3);
-        s0 = _mm_unpacklo_epi32(s0, s2);
-
-        _mm_storel_epi64((__m128i *)(comp_pred), s0);
-        comp_pred += 8;
-        ref += 8 * 8;
+    } else {
+      int i;
+      assert(!(width & 3));
+      assert(!(height & 3));
+      /*Read 4 pixels four rows at a time.*/
+      for (i = 0; i < height; i++) {
+        __m128i s0 = _mm_cvtsi32_si128(*(const uint32_t *)ref);
+        __m128i s1 = _mm_cvtsi32_si128(*(const uint32_t *)(ref + ref_stride));
+        __m128i s2 =
+            _mm_cvtsi32_si128(*(const uint32_t *)(ref + 2 * ref_stride));
+        __m128i s3 =
+            _mm_cvtsi32_si128(*(const uint32_t *)(ref + 3 * ref_stride));
+        __m128i t0 = _mm_unpacklo_epi32(s0, s1);
+        __m128i t1 = _mm_unpacklo_epi32(s2, s3);
+        __m128i u0 = _mm_unpacklo_epi64(t0, t1);
+        _mm_storeu_si128((__m128i *)comp_pred, u0);
+        comp_pred += 16;
+        ref += 4 * ref_stride;
       }
-      ref += stride - (width << 3);
     }
   } else {
-    // read 4 points at one time
-    for (i = 0; i < height; i++) {
-      for (j = 0; j < width; j += 4) {
-        __m128i s0 = _mm_loadu_si128((const __m128i *)ref);
-        __m128i s1 = _mm_loadu_si128((const __m128i *)(ref + 16));
-        __m128i t0;
-
-        t0 = _mm_unpacklo_epi8(s0, s1);
-        s1 = _mm_unpackhi_epi8(s0, s1);
-        s0 = _mm_unpacklo_epi8(t0, s1);
-
-        *(int *)comp_pred = _mm_cvtsi128_si32(s0);
-        comp_pred += 4;
-        ref += 4 * 8;
-      }
-      ref += stride - (width << 3);
+    InterpFilterParams filter;
+    filter = av1_get_interp_filter_params(EIGHTTAP_REGULAR);
+    if (!subpel_y_q3) {
+      const int16_t *kernel;
+      kernel = av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
+      aom_convolve8_horiz(ref, ref_stride, comp_pred, width, kernel, 16, NULL,
+                          -1, width, height);
+    } else if (!subpel_x_q3) {
+      const int16_t *kernel;
+      kernel = av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
+      aom_convolve8_vert(ref, ref_stride, comp_pred, width, NULL, -1, kernel,
+                         16, width, height);
+    } else {
+      DECLARE_ALIGNED(16, uint8_t,
+                      temp[((MAX_SB_SIZE * 2 + 16) + 16) * MAX_SB_SIZE]);
+      const int16_t *kernel_x;
+      const int16_t *kernel_y;
+      int intermediate_height;
+      kernel_x = av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
+      kernel_y = av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
+      intermediate_height =
+          (((height - 1) * 8 + subpel_y_q3) >> 3) + filter.taps;
+      assert(intermediate_height <= (MAX_SB_SIZE * 2 + 16) + 16);
+      aom_convolve8_horiz(ref - ref_stride * ((filter.taps >> 1) - 1),
+                          ref_stride, temp, MAX_SB_SIZE, kernel_x, 16, NULL, -1,
+                          width, intermediate_height);
+      aom_convolve8_vert(temp + MAX_SB_SIZE * ((filter.taps >> 1) - 1),
+                         MAX_SB_SIZE, comp_pred, width, NULL, -1, kernel_y, 16,
+                         width, height);
     }
   }
 }
 
 void aom_comp_avg_upsampled_pred_sse2(uint8_t *comp_pred, const uint8_t *pred,
-                                      int width, int height, const uint8_t *ref,
+                                      int width, int height, int subpel_x_q3,
+                                      int subpel_y_q3, const uint8_t *ref,
                                       int ref_stride) {
-  const __m128i zero = _mm_set1_epi16(0);
-  const __m128i one = _mm_set1_epi16(1);
-  int i, j;
-  int stride = ref_stride << 3;
-
-  if (width >= 16) {
-    // read 16 points at one time
-    for (i = 0; i < height; i++) {
-      for (j = 0; j < width; j += 16) {
-        __m128i s0 = _mm_loadu_si128((const __m128i *)ref);
-        __m128i s1 = _mm_loadu_si128((const __m128i *)(ref + 16));
-        __m128i s2 = _mm_loadu_si128((const __m128i *)(ref + 32));
-        __m128i s3 = _mm_loadu_si128((const __m128i *)(ref + 48));
-        __m128i s4 = _mm_loadu_si128((const __m128i *)(ref + 64));
-        __m128i s5 = _mm_loadu_si128((const __m128i *)(ref + 80));
-        __m128i s6 = _mm_loadu_si128((const __m128i *)(ref + 96));
-        __m128i s7 = _mm_loadu_si128((const __m128i *)(ref + 112));
-        __m128i p0 = _mm_loadu_si128((const __m128i *)pred);
-        __m128i p1;
-        __m128i t0, t1, t2, t3;
-
-        t0 = _mm_unpacklo_epi8(s0, s1);
-        s1 = _mm_unpackhi_epi8(s0, s1);
-        t1 = _mm_unpacklo_epi8(s2, s3);
-        s3 = _mm_unpackhi_epi8(s2, s3);
-        t2 = _mm_unpacklo_epi8(s4, s5);
-        s5 = _mm_unpackhi_epi8(s4, s5);
-        t3 = _mm_unpacklo_epi8(s6, s7);
-        s7 = _mm_unpackhi_epi8(s6, s7);
-
-        s0 = _mm_unpacklo_epi8(t0, s1);
-        s2 = _mm_unpacklo_epi8(t1, s3);
-        s4 = _mm_unpacklo_epi8(t2, s5);
-        s6 = _mm_unpacklo_epi8(t3, s7);
-
-        s0 = _mm_unpacklo_epi32(s0, s2);
-        s4 = _mm_unpacklo_epi32(s4, s6);
-        s0 = _mm_unpacklo_epi8(s0, zero);
-        s4 = _mm_unpacklo_epi8(s4, zero);
-
-        p1 = _mm_unpackhi_epi8(p0, zero);
-        p0 = _mm_unpacklo_epi8(p0, zero);
-        p0 = _mm_adds_epu16(s0, p0);
-        p1 = _mm_adds_epu16(s4, p1);
-        p0 = _mm_adds_epu16(p0, one);
-        p1 = _mm_adds_epu16(p1, one);
-
-        p0 = _mm_srli_epi16(p0, 1);
-        p1 = _mm_srli_epi16(p1, 1);
-        p0 = _mm_packus_epi16(p0, p1);
-
-        _mm_storeu_si128((__m128i *)(comp_pred), p0);
-        comp_pred += 16;
-        pred += 16;
-        ref += 16 * 8;
-      }
-      ref += stride - (width << 3);
-    }
-  } else if (width >= 8) {
-    // read 8 points at one time
-    for (i = 0; i < height; i++) {
-      for (j = 0; j < width; j += 8) {
-        __m128i s0 = _mm_loadu_si128((const __m128i *)ref);
-        __m128i s1 = _mm_loadu_si128((const __m128i *)(ref + 16));
-        __m128i s2 = _mm_loadu_si128((const __m128i *)(ref + 32));
-        __m128i s3 = _mm_loadu_si128((const __m128i *)(ref + 48));
-        __m128i p0 = _mm_loadl_epi64((const __m128i *)pred);
-        __m128i t0, t1;
-
-        t0 = _mm_unpacklo_epi8(s0, s1);
-        s1 = _mm_unpackhi_epi8(s0, s1);
-        t1 = _mm_unpacklo_epi8(s2, s3);
-        s3 = _mm_unpackhi_epi8(s2, s3);
-
-        s0 = _mm_unpacklo_epi8(t0, s1);
-        s2 = _mm_unpacklo_epi8(t1, s3);
-        s0 = _mm_unpacklo_epi32(s0, s2);
-        s0 = _mm_unpacklo_epi8(s0, zero);
-
-        p0 = _mm_unpacklo_epi8(p0, zero);
-        p0 = _mm_adds_epu16(s0, p0);
-        p0 = _mm_adds_epu16(p0, one);
-        p0 = _mm_srli_epi16(p0, 1);
-        p0 = _mm_packus_epi16(p0, zero);
-
-        _mm_storel_epi64((__m128i *)(comp_pred), p0);
-        comp_pred += 8;
-        pred += 8;
-        ref += 8 * 8;
-      }
-      ref += stride - (width << 3);
-    }
-  } else {
-    // read 4 points at one time
-    for (i = 0; i < height; i++) {
-      for (j = 0; j < width; j += 4) {
-        __m128i s0 = _mm_loadu_si128((const __m128i *)ref);
-        __m128i s1 = _mm_loadu_si128((const __m128i *)(ref + 16));
-        __m128i p0 = _mm_cvtsi32_si128(*(const uint32_t *)pred);
-        __m128i t0;
-
-        t0 = _mm_unpacklo_epi8(s0, s1);
-        s1 = _mm_unpackhi_epi8(s0, s1);
-        s0 = _mm_unpacklo_epi8(t0, s1);
-        s0 = _mm_unpacklo_epi8(s0, zero);
-
-        p0 = _mm_unpacklo_epi8(p0, zero);
-        p0 = _mm_adds_epu16(s0, p0);
-        p0 = _mm_adds_epu16(p0, one);
-        p0 = _mm_srli_epi16(p0, 1);
-        p0 = _mm_packus_epi16(p0, zero);
-
-        *(int *)comp_pred = _mm_cvtsi128_si32(p0);
-        comp_pred += 4;
-        pred += 4;
-        ref += 4 * 8;
-      }
-      ref += stride - (width << 3);
-    }
+  int n;
+  int i;
+  aom_upsampled_pred(comp_pred, width, height, subpel_x_q3, subpel_y_q3, ref,
+                     ref_stride);
+  /*The total number of pixels must be a multiple of 16 (e.g., 4x4).*/
+  assert(!(width * height & 15));
+  n = width * height >> 4;
+  for (i = 0; i < n; i++) {
+    __m128i s0 = _mm_loadu_si128((const __m128i *)comp_pred);
+    __m128i p0 = _mm_loadu_si128((const __m128i *)pred);
+    _mm_storeu_si128((__m128i *)comp_pred, _mm_avg_epu8(s0, p0));
+    comp_pred += 16;
+    pred += 16;
   }
 }
--- a/third_party/aom/aom_mem/aom_mem.cmake
+++ b/third_party/aom/aom_mem/aom_mem.cmake
@@ -16,12 +16,12 @@ set(AOM_MEM_SOURCES
     "${AOM_ROOT}/aom_mem/aom_mem.h"
     "${AOM_ROOT}/aom_mem/include/aom_mem_intrnl.h")
 
 # Creates the aom_mem build target and makes libaom depend on it. The libaom
 # target must exist before this function is called.
 function (setup_aom_mem_targets)
   add_library(aom_mem OBJECT ${AOM_MEM_SOURCES})
   set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_mem PARENT_SCOPE)
-  target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_mem>)
+  target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_mem>)
 endfunction ()
 
 endif ()  # AOM_AOM_MEM_AOM_MEM_CMAKE_
--- a/third_party/aom/aom_ports/aom_ports.cmake
+++ b/third_party/aom/aom_ports/aom_ports.cmake
@@ -40,32 +40,31 @@ set(AOM_PORTS_SOURCES_ARM
 #   The libaom target must exist before this function is called.
 function (setup_aom_ports_targets)
   if (HAVE_MMX)
     add_asm_library("aom_ports" "AOM_PORTS_ASM_MMX" "aom")
     set(aom_ports_has_symbols 1)
   elseif ("${AOM_TARGET_CPU}" MATCHES "arm")
     add_library(aom_ports OBJECT ${AOM_PORTS_SOURCES_ARM})
     set(aom_ports_has_symbols 1)
-    list(APPEND AOM_LIB_TARGETS aom_ports)
     target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_ports>)
   endif ()
 
   if (aom_ports_has_symbols)
-    target_sources(aom_ports PUBLIC ${AOM_PORTS_INCLUDES})
+    target_sources(aom_ports PRIVATE ${AOM_PORTS_INCLUDES})
 
     if ("${AOM_TARGET_CPU}" STREQUAL "x86" OR
         "${AOM_TARGET_CPU}" STREQUAL "x86_64")
-      target_sources(aom_ports PUBLIC ${AOM_PORTS_INCLUDES_X86})
+      target_sources(aom_ports PRIVATE ${AOM_PORTS_INCLUDES_X86})
     endif ()
 
     set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
   else ()
-    target_sources(aom PUBLIC ${AOM_PORTS_INCLUDES})
+    target_sources(aom PRIVATE ${AOM_PORTS_INCLUDES})
 
     if ("${AOM_TARGET_CPU}" STREQUAL "x86" OR
         "${AOM_TARGET_CPU}" STREQUAL "x86_64")
-      target_sources(aom PUBLIC ${AOM_PORTS_INCLUDES_X86})
+      target_sources(aom PRIVATE ${AOM_PORTS_INCLUDES_X86})
     endif ()
   endif ()
 endfunction ()
 
 endif ()  # AOM_AOM_PORTS_AOM_PORTS_CMAKE_
--- a/third_party/aom/aom_scale/aom_scale.cmake
+++ b/third_party/aom/aom_scale/aom_scale.cmake
@@ -21,19 +21,19 @@ set(AOM_SCALE_SOURCES
 
 set(AOM_SCALE_INTRIN_DSPR2
     "${AOM_ROOT}/aom_scale/mips/dspr2/yv12extend_dspr2.c")
 
 # Creates the aom_scale build target and makes libaom depend on it. The libaom
 # target must exist before this function is called.
 function (setup_aom_scale_targets)
   add_library(aom_scale OBJECT ${AOM_SCALE_SOURCES})
-  target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_scale>)
+  target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_scale>)
 
   if (HAVE_DSPR2)
     add_intrinsics_object_library("" "dspr2" "aom_scale"
-                                  "AOM_SCALE_INTRIN_DSPR2")
+                                  "AOM_SCALE_INTRIN_DSPR2" "aom_scale")
   endif ()
 
   set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_scale PARENT_SCOPE)
 endfunction ()
 
 endif ()  # AOM_AOM_SCALE_AOM_SCALE_CMAKE_
--- a/third_party/aom/aom_scale/yv12config.h
+++ b/third_party/aom/aom_scale/yv12config.h
@@ -64,16 +64,20 @@ typedef struct yv12_buffer_config {
   uint8_t *buffer_alloc;
   size_t buffer_alloc_sz;
   int border;
   size_t frame_size;
   int subsampling_x;
   int subsampling_y;
   unsigned int bit_depth;
   aom_color_space_t color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  aom_transfer_function_t transfer_function;
+  aom_chroma_sample_position_t chroma_sample_position;
+#endif
   aom_color_range_t color_range;
   int render_width;
   int render_height;
 
   int corrupted;
   int flags;
 } YV12_BUFFER_CONFIG;
 
--- a/third_party/aom/aom_util/aom_util.cmake
+++ b/third_party/aom/aom_util/aom_util.cmake
@@ -23,12 +23,12 @@ if (CONFIG_BITSTREAM_DEBUG)
       "${AOM_ROOT}/aom_util/debug_util.h")
 endif ()
 
 # Creates the aom_util build target and makes libaom depend on it. The libaom
 # target must exist before this function is called.
 function (setup_aom_util_targets)
   add_library(aom_util OBJECT ${AOM_UTIL_SOURCES})
   set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_util PARENT_SCOPE)
-  target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_util>)
+  target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_util>)
 endfunction ()
 
 endif ()  # AOM_AOM_UTIL_AOM_UTIL_CMAKE_
--- a/third_party/aom/aomdec.c
+++ b/third_party/aom/aomdec.c
@@ -514,17 +514,17 @@ static int main_loop(int argc, const cha
   uint64_t dx_time = 0;
   struct arg arg;
   char **argv, **argi, **argj;
 
   int single_file;
   int use_y4m = 1;
   int opt_yv12 = 0;
   int opt_i420 = 0;
-  aom_codec_dec_cfg_t cfg = { 0, 0, 0 };
+  aom_codec_dec_cfg_t cfg = { 0, 0, 0, CONFIG_LOWBITDEPTH };
 #if CONFIG_HIGHBITDEPTH
   unsigned int output_bit_depth = 0;
 #endif
 #if CONFIG_EXT_TILE
   int tile_row = -1;
   int tile_col = -1;
 #endif  // CONFIG_EXT_TILE
   int frames_corrupted = 0;
--- a/third_party/aom/aomenc.c
+++ b/third_party/aom/aomenc.c
@@ -189,19 +189,16 @@ static const arg_def_t rate_hist_n =
 static const arg_def_t disable_warnings =
     ARG_DEF(NULL, "disable-warnings", 0,
             "Disable warnings about potentially incorrect encode settings.");
 static const arg_def_t disable_warning_prompt =
     ARG_DEF("y", "disable-warning-prompt", 0,
             "Display warnings, but do not prompt user to continue.");
 
 #if CONFIG_HIGHBITDEPTH
-static const arg_def_t test16bitinternalarg = ARG_DEF(
-    NULL, "test-16bit-internal", 0, "Force use of 16 bit internal buffer");
-
 static const struct arg_enum_list bitdepth_enum[] = {
   { "8", AOM_BITS_8 }, { "10", AOM_BITS_10 }, { "12", AOM_BITS_12 }, { NULL, 0 }
 };
 
 static const arg_def_t bitdeptharg = ARG_DEF_ENUM(
     "b", "bit-depth", 1,
     "Bit depth for codec (8 for version <=1, 10 or 12 for version 2)",
     bitdepth_enum);
@@ -254,51 +251,46 @@ static const arg_def_t stereo_mode = ARG
 #endif
 static const arg_def_t timebase = ARG_DEF(
     NULL, "timebase", 1, "Output timestamp precision (fractional seconds)");
 static const arg_def_t error_resilient =
     ARG_DEF(NULL, "error-resilient", 1, "Enable error resiliency features");
 static const arg_def_t lag_in_frames =
     ARG_DEF(NULL, "lag-in-frames", 1, "Max number of frames to lag");
 
-static const arg_def_t *global_args[] = { &use_yv12,
-                                          &use_i420,
-                                          &use_i422,
-                                          &use_i444,
-                                          &use_i440,
-                                          &usage,
-                                          &threads,
-                                          &profile,
-                                          &width,
-                                          &height,
+static const arg_def_t *global_args[] = {
+  &use_yv12,      &use_i420,  &use_i422,        &use_i444, &use_i440,
+  &usage,         &threads,   &profile,         &width,    &height,
 #if CONFIG_WEBM_IO
-                                          &stereo_mode,
+  &stereo_mode,
 #endif
-                                          &timebase,
-                                          &framerate,
-                                          &error_resilient,
+  &timebase,      &framerate, &error_resilient,
 #if CONFIG_HIGHBITDEPTH
-                                          &test16bitinternalarg,
-                                          &bitdeptharg,
+  &bitdeptharg,
 #endif
-                                          &lag_in_frames,
-                                          NULL };
+  &lag_in_frames, NULL
+};
 
 static const arg_def_t dropframe_thresh =
     ARG_DEF(NULL, "drop-frame", 1, "Temporal resampling threshold (buf %)");
-static const arg_def_t resize_allowed =
-    ARG_DEF(NULL, "resize-allowed", 1, "Spatial resampling enabled (bool)");
-static const arg_def_t resize_width =
-    ARG_DEF(NULL, "resize-width", 1, "Width of encoded frame");
-static const arg_def_t resize_height =
-    ARG_DEF(NULL, "resize-height", 1, "Height of encoded frame");
-static const arg_def_t resize_up_thresh =
-    ARG_DEF(NULL, "resize-up", 1, "Upscale threshold (buf %)");
-static const arg_def_t resize_down_thresh =
-    ARG_DEF(NULL, "resize-down", 1, "Downscale threshold (buf %)");
+static const arg_def_t resize_mode =
+    ARG_DEF(NULL, "resize-mode", 1, "Frame resize mode");
+static const arg_def_t resize_numerator =
+    ARG_DEF(NULL, "resize-numerator", 1, "Frame resize numerator");
+static const arg_def_t resize_kf_numerator =
+    ARG_DEF(NULL, "resize-kf-numerator", 1, "Frame resize keyframe numerator");
+#if CONFIG_FRAME_SUPERRES
+static const arg_def_t superres_mode =
+    ARG_DEF(NULL, "superres-mode", 1, "Frame super-resolution mode");
+static const arg_def_t superres_numerator =
+    ARG_DEF(NULL, "superres-numerator", 1, "Frame super-resolution numerator");
+static const arg_def_t superres_kf_numerator =
+    ARG_DEF(NULL, "superres-kf-numerator", 1,
+            "Frame super-resolution keyframe numerator");
+#endif  // CONFIG_FRAME_SUPERRES
 static const struct arg_enum_list end_usage_enum[] = { { "vbr", AOM_VBR },
                                                        { "cbr", AOM_CBR },
                                                        { "cq", AOM_CQ },
                                                        { "q", AOM_Q },
                                                        { NULL, 0 } };
 static const arg_def_t end_usage =
     ARG_DEF_ENUM(NULL, "end-usage", 1, "Rate control mode", end_usage_enum);
 static const arg_def_t target_bitrate =
@@ -312,22 +304,35 @@ static const arg_def_t undershoot_pct =
 static const arg_def_t overshoot_pct =
     ARG_DEF(NULL, "overshoot-pct", 1, "Datarate overshoot (max) target (%)");
 static const arg_def_t buf_sz =
     ARG_DEF(NULL, "buf-sz", 1, "Client buffer size (ms)");
 static const arg_def_t buf_initial_sz =
     ARG_DEF(NULL, "buf-initial-sz", 1, "Client initial buffer size (ms)");
 static const arg_def_t buf_optimal_sz =
     ARG_DEF(NULL, "buf-optimal-sz", 1, "Client optimal buffer size (ms)");
-static const arg_def_t *rc_args[] = {
-  &dropframe_thresh, &resize_allowed,     &resize_width,   &resize_height,
-  &resize_up_thresh, &resize_down_thresh, &end_usage,      &target_bitrate,
-  &min_quantizer,    &max_quantizer,      &undershoot_pct, &overshoot_pct,
-  &buf_sz,           &buf_initial_sz,     &buf_optimal_sz, NULL
-};
+static const arg_def_t *rc_args[] = { &dropframe_thresh,
+                                      &resize_mode,
+                                      &resize_numerator,
+                                      &resize_kf_numerator,
+#if CONFIG_FRAME_SUPERRES
+                                      &superres_mode,
+                                      &superres_numerator,
+                                      &superres_kf_numerator,
+#endif  // CONFIG_FRAME_SUPERRES
+                                      &end_usage,
+                                      &target_bitrate,
+                                      &min_quantizer,
+                                      &max_quantizer,
+                                      &undershoot_pct,
+                                      &overshoot_pct,
+                                      &buf_sz,
+                                      &buf_initial_sz,
+                                      &buf_optimal_sz,
+                                      NULL };
 
 static const arg_def_t bias_pct =
     ARG_DEF(NULL, "bias-pct", 1, "CBR/VBR bias (0=CBR, 100=VBR)");
 static const arg_def_t minsection_pct =
     ARG_DEF(NULL, "minsection-pct", 1, "GOP min bitrate (% of target)");
 static const arg_def_t maxsection_pct =
     ARG_DEF(NULL, "maxsection-pct", 1, "GOP max bitrate (% of target)");
 static const arg_def_t *rc_twopass_args[] = { &bias_pct, &minsection_pct,
@@ -444,26 +449,59 @@ static const arg_def_t max_gf_interval =
     "max gf/arf frame interval (default 0, indicating in-built behavior)");
 
 static const struct arg_enum_list color_space_enum[] = {
   { "unknown", AOM_CS_UNKNOWN },
   { "bt601", AOM_CS_BT_601 },
   { "bt709", AOM_CS_BT_709 },
   { "smpte170", AOM_CS_SMPTE_170 },
   { "smpte240", AOM_CS_SMPTE_240 },
+#if CONFIG_COLORSPACE_HEADERS
+  { "bt2020ncl", AOM_CS_BT_2020_NCL },
+  { "bt2020cl", AOM_CS_BT_2020_CL },
+  { "sRGB", AOM_CS_SRGB },
+  { "ICtCp", AOM_CS_ICTCP },
+#else
   { "bt2020", AOM_CS_BT_2020 },
   { "reserved", AOM_CS_RESERVED },
   { "sRGB", AOM_CS_SRGB },
+#endif
   { NULL, 0 }
 };
 
 static const arg_def_t input_color_space =
     ARG_DEF_ENUM(NULL, "color-space", 1, "The color space of input content:",
                  color_space_enum);
 
+#if CONFIG_COLORSPACE_HEADERS
+static const struct arg_enum_list transfer_function_enum[] = {
+  { "unknown", AOM_TF_UNKNOWN },
+  { "bt709", AOM_TF_BT_709 },
+  { "pq", AOM_TF_PQ },
+  { "hlg", AOM_TF_HLG },
+  { NULL, 0 }
+};
+
+static const arg_def_t input_transfer_function = ARG_DEF_ENUM(
+    NULL, "transfer-function", 1, "The transfer function of input content:",
+    transfer_function_enum);
+
+static const struct arg_enum_list chroma_sample_position_enum[] = {
+  { "unknown", AOM_CSP_UNKNOWN },
+  { "vertical", AOM_CSP_VERTICAL },
+  { "colocated", AOM_CSP_COLOCATED },
+  { NULL, 0 }
+};
+
+static const arg_def_t input_chroma_sample_position =
+    ARG_DEF_ENUM(NULL, "chroma-sample-position", 1,
+                 "The chroma sample position when chroma 4:2:0 is signaled:",
+                 chroma_sample_position_enum);
+#endif
+
 static const struct arg_enum_list tune_content_enum[] = {
   { "default", AOM_CONTENT_DEFAULT },
   { "screen", AOM_CONTENT_SCREEN },
   { NULL, 0 }
 };
 
 static const arg_def_t tune_content = ARG_DEF_ENUM(
     NULL, "tune-content", 1, "Tune content type", tune_content_enum);
@@ -513,16 +551,20 @@ static const arg_def_t *av1_args[] = { &
                                        &aq_mode,
 #if CONFIG_EXT_DELTA_Q
                                        &deltaq_mode,
 #endif
                                        &frame_periodic_boost,
                                        &noise_sens,
                                        &tune_content,
                                        &input_color_space,
+#if CONFIG_COLORSPACE_HEADERS
+                                       &input_transfer_function,
+                                       &input_chroma_sample_position,
+#endif
                                        &min_gf_interval,
                                        &max_gf_interval,
 #if CONFIG_EXT_PARTITION
                                        &superblock_size,
 #endif  // CONFIG_EXT_PARTITION
 #if CONFIG_TILE_GROUPS
                                        &num_tg,
                                        &mtu_size,
@@ -567,16 +609,20 @@ static const int av1_arg_ctrl_map[] = { 
                                         AV1E_SET_AQ_MODE,
 #if CONFIG_EXT_DELTA_Q
                                         AV1E_SET_DELTAQ_MODE,
 #endif
                                         AV1E_SET_FRAME_PERIODIC_BOOST,
                                         AV1E_SET_NOISE_SENSITIVITY,
                                         AV1E_SET_TUNE_CONTENT,
                                         AV1E_SET_COLOR_SPACE,
+#if CONFIG_COLORSPACE_HEADERS
+                                        AV1E_SET_TRANSFER_FUNCTION,
+                                        AV1E_SET_CHROMA_SAMPLE_POSITION,
+#endif
                                         AV1E_SET_MIN_GF_INTERVAL,
                                         AV1E_SET_MAX_GF_INTERVAL,
 #if CONFIG_EXT_PARTITION
                                         AV1E_SET_SUPERBLOCK_SIZE,
 #endif  // CONFIG_EXT_PARTITION
 #if CONFIG_TILE_GROUPS
                                         AV1E_SET_NUM_TG,
                                         AV1E_SET_MTU,
@@ -646,20 +692,18 @@ struct stream_config {
   const char *stats_fn;
 #if CONFIG_FP_MB_STATS
   const char *fpmb_stats_fn;
 #endif
   stereo_format_t stereo_fmt;
   int arg_ctrls[ARG_CTRL_CNT_MAX][2];
   int arg_ctrl_cnt;
   int write_webm;
-#if CONFIG_HIGHBITDEPTH
   // whether to use 16bit internal buffers
   int use_16bit_internal;
-#endif
 };
 
 struct stream_state {
   int index;
   struct stream_state *next;
   struct stream_config config;
   FILE *file;
   struct rate_hist *rate_hist;
@@ -901,19 +945,16 @@ static struct stream_state *new_stream(s
 static int parse_stream_params(struct AvxEncoderConfig *global,
                                struct stream_state *stream, char **argv) {
   char **argi, **argj;
   struct arg arg;
   static const arg_def_t **ctrl_args = no_args;
   static const int *ctrl_args_map = NULL;
   struct stream_config *config = &stream->config;
   int eos_mark_found = 0;
-#if CONFIG_HIGHBITDEPTH
-  int test_16bit_internal = 0;
-#endif
 
   // Handle codec specific options
   if (0) {
 #if CONFIG_AV1_ENCODER
   } else if (strcmp(global->codec->name, "av1") == 0) {
     // TODO(jingning): Reuse AV1 specific encoder configuration parameters.
     // Consider to expand this set for AV1 encoder control.
     ctrl_args = av1_args;
@@ -973,26 +1014,30 @@ static int parse_stream_params(struct Av
       config->cfg.g_timebase = arg_parse_rational(&arg);
       validate_positive_rational(arg.name, &config->cfg.g_timebase);
     } else if (arg_match(&arg, &error_resilient, argi)) {
       config->cfg.g_error_resilient = arg_parse_uint(&arg);
     } else if (arg_match(&arg, &lag_in_frames, argi)) {
       config->cfg.g_lag_in_frames = arg_parse_uint(&arg);
     } else if (arg_match(&arg, &dropframe_thresh, argi)) {
       config->cfg.rc_dropframe_thresh = arg_parse_uint(&arg);
-    } else if (arg_match(&arg, &resize_allowed, argi)) {
-      config->cfg.rc_resize_allowed = arg_parse_uint(&arg);
-    } else if (arg_match(&arg, &resize_width, argi)) {
-      config->cfg.rc_scaled_width = arg_parse_uint(&arg);
-    } else if (arg_match(&arg, &resize_height, argi)) {
-      config->cfg.rc_scaled_height = arg_parse_uint(&arg);
-    } else if (arg_match(&arg, &resize_up_thresh, argi)) {
-      config->cfg.rc_resize_up_thresh = arg_parse_uint(&arg);
-    } else if (arg_match(&arg, &resize_down_thresh, argi)) {
-      config->cfg.rc_resize_down_thresh = arg_parse_uint(&arg);
+    } else if (arg_match(&arg, &resize_mode, argi)) {
+      config->cfg.rc_resize_mode = arg_parse_uint(&arg);
+    } else if (arg_match(&arg, &resize_numerator, argi)) {
+      config->cfg.rc_resize_numerator = arg_parse_uint(&arg);
+    } else if (arg_match(&arg, &resize_kf_numerator, argi)) {
+      config->cfg.rc_resize_kf_numerator = arg_parse_uint(&arg);
+#if CONFIG_FRAME_SUPERRES
+    } else if (arg_match(&arg, &superres_mode, argi)) {
+      config->cfg.rc_superres_mode = arg_parse_uint(&arg);
+    } else if (arg_match(&arg, &superres_numerator, argi)) {
+      config->cfg.rc_superres_numerator = arg_parse_uint(&arg);
+    } else if (arg_match(&arg, &superres_kf_numerator, argi)) {
+      config->cfg.rc_superres_kf_numerator = arg_parse_uint(&arg);
+#endif  // CONFIG_FRAME_SUPERRES
     } else if (arg_match(&arg, &end_usage, argi)) {
       config->cfg.rc_end_usage = arg_parse_enum_or_int(&arg);
     } else if (arg_match(&arg, &target_bitrate, argi)) {
       config->cfg.rc_target_bitrate = arg_parse_uint(&arg);
     } else if (arg_match(&arg, &min_quantizer, argi)) {
       config->cfg.rc_min_quantizer = arg_parse_uint(&arg);
     } else if (arg_match(&arg, &max_quantizer, argi)) {
       config->cfg.rc_max_quantizer = arg_parse_uint(&arg);
@@ -1021,23 +1066,16 @@ static int parse_stream_params(struct Av
       if (global->passes < 2)
         warn("option %s ignored in one-pass mode.\n", arg.name);
     } else if (arg_match(&arg, &kf_min_dist, argi)) {
       config->cfg.kf_min_dist = arg_parse_uint(&arg);
     } else if (arg_match(&arg, &kf_max_dist, argi)) {
       config->cfg.kf_max_dist = arg_parse_uint(&arg);
     } else if (arg_match(&arg, &kf_disabled, argi)) {
       config->cfg.kf_mode = AOM_KF_DISABLED;
-#if CONFIG_HIGHBITDEPTH
-    } else if (arg_match(&arg, &test16bitinternalarg, argi)) {
-      if (strcmp(global->codec->name, "av1") == 0 ||
-          strcmp(global->codec->name, "av1") == 0) {
-        test_16bit_internal = 1;
-      }
-#endif
     } else {
       int i, match = 0;
       for (i = 0; ctrl_args[i]; i++) {
         if (arg_match(&arg, ctrl_args[i], argi)) {
           int j;
           match = 1;
 
           /* Point either to the next free element or the first
@@ -1057,28 +1095,24 @@ static int parse_stream_params(struct Av
           }
         }
       }
       if (!match) argj++;
     }
   }
 #if CONFIG_HIGHBITDEPTH
   config->use_16bit_internal =
-      test_16bit_internal || (config->cfg.g_profile > 1) || !CONFIG_LOWBITDEPTH;
+      config->cfg.g_bit_depth > AOM_BITS_8 || !CONFIG_LOWBITDEPTH;
 #endif
   return eos_mark_found;
 }
 
-#define FOREACH_STREAM(func)                                \
-  do {                                                      \
-    struct stream_state *stream;                            \
-    for (stream = streams; stream; stream = stream->next) { \
-      func;                                                 \
-    }                                                       \
-  } while (0)
+#define FOREACH_STREAM(iterator, list)                 \
+  for (struct stream_state *iterator = list; iterator; \
+       iterator = iterator->next)
 
 static void validate_stream_config(const struct stream_state *stream,
                                    const struct AvxEncoderConfig *global) {
   const struct stream_state *streami;
   (void)global;
 
   if (!stream->config.cfg.g_w || !stream->config.cfg.g_h)
     fatal(
@@ -1178,36 +1212,41 @@ static void show_stream_config(struct st
             aom_codec_iface_name(global->codec->codec_interface()));
     fprintf(stderr, "Source file: %s File Type: %s Format: %s\n",
             input->filename, file_type_to_string(input->file_type),
             image_format_to_string(input->fmt));
   }
   if (stream->next || stream->index)
     fprintf(stderr, "\nStream Index: %d\n", stream->index);
   fprintf(stderr, "Destination file: %s\n", stream->config.out_fn);
+  fprintf(stderr, "Coding path: %s\n",
+          stream->config.use_16bit_internal ? "HBD" : "LBD");
   fprintf(stderr, "Encoder parameters:\n");
 
   SHOW(g_usage);
   SHOW(g_threads);
   SHOW(g_profile);
   SHOW(g_w);
   SHOW(g_h);
   SHOW(g_bit_depth);
   SHOW(g_input_bit_depth);
   SHOW(g_timebase.num);
   SHOW(g_timebase.den);
   SHOW(g_error_resilient);
   SHOW(g_pass);
   SHOW(g_lag_in_frames);
   SHOW(rc_dropframe_thresh);
-  SHOW(rc_resize_allowed);
-  SHOW(rc_scaled_width);
-  SHOW(rc_scaled_height);
-  SHOW(rc_resize_up_thresh);
-  SHOW(rc_resize_down_thresh);
+  SHOW(rc_resize_mode);
+  SHOW(rc_resize_numerator);
+  SHOW(rc_resize_kf_numerator);
+#if CONFIG_FRAME_SUPERRES
+  SHOW(rc_superres_mode);
+  SHOW(rc_superres_numerator);
+  SHOW(rc_superres_kf_numerator);
+#endif  // CONFIG_FRAME_SUPERRES
   SHOW(rc_end_usage);
   SHOW(rc_target_bitrate);
   SHOW(rc_min_quantizer);
   SHOW(rc_max_quantizer);
   SHOW(rc_undershoot_pct);
   SHOW(rc_overshoot_pct);
   SHOW(rc_buf_sz);
   SHOW(rc_buf_initial_sz);
@@ -1335,17 +1374,17 @@ static void initialize_encoder(struct st
       fprintf(stderr, "Error: Tried to set control %d = %d\n", ctrl, value);
 
     ctx_exit_on_error(&stream->encoder, "Failed to control codec");
   }
 
 #if CONFIG_AV1_DECODER
   if (global->test_decode != TEST_DECODE_OFF) {
     const AvxInterface *decoder = get_aom_decoder_by_name(global->codec->name);
-    aom_codec_dec_cfg_t cfg = { 0, 0, 0 };
+    aom_codec_dec_cfg_t cfg = { 0, 0, 0, CONFIG_LOWBITDEPTH };
     aom_codec_dec_init(&stream->decoder, decoder->codec_interface(), &cfg, 0);
 
 #if CONFIG_EXT_TILE
     if (strcmp(global->codec->name, "av1") == 0) {
       aom_codec_control(&stream->decoder, AV1_SET_DECODE_TILE_ROW, -1);
       ctx_exit_on_error(&stream->decoder, "Failed to set decode_tile_row");
 
       aom_codec_control(&stream->decoder, AV1_SET_DECODE_TILE_COL, -1);
@@ -1725,18 +1764,20 @@ int main(int argc, const char **argv_) {
     } while (parse_stream_params(&global, stream, argv));
   }
 
   /* Check for unrecognized options */
   for (argi = argv; *argi; argi++)
     if (argi[0][0] == '-' && argi[0][1])
       die("Error: Unrecognized option %s\n", *argi);
 
-  FOREACH_STREAM(check_encoder_config(global.disable_warning_prompt, &global,
-                                      &stream->config.cfg););
+  FOREACH_STREAM(stream, streams) {
+    check_encoder_config(global.disable_warning_prompt, &global,
+                         &stream->config.cfg);
+  }
 
   /* Handle non-option arguments */
   input.filename = argv[0];
 
   if (!input.filename) usage_exit();
 
   /* Decide if other chroma subsamplings than 4:2:0 are supported */
   if (global.codec->fourcc == AV1_FOURCC) input.only_i420 = 0;
@@ -1748,52 +1789,52 @@ int main(int argc, const char **argv_) {
     int64_t lagged_count = 0;
 
     open_input_file(&input);
 
     /* If the input file doesn't specify its w/h (raw files), try to get
      * the data from the first stream's configuration.
      */
     if (!input.width || !input.height) {
-      FOREACH_STREAM({
+      FOREACH_STREAM(stream, streams) {
         if (stream->config.cfg.g_w && stream->config.cfg.g_h) {
           input.width = stream->config.cfg.g_w;
           input.height = stream->config.cfg.g_h;
           break;
         }
-      });
+      };
     }
 
     /* Update stream configurations from the input file's parameters */
     if (!input.width || !input.height)
       fatal(
           "Specify stream dimensions with --width (-w) "
           " and --height (-h)");
 
     /* If input file does not specify bit-depth but input-bit-depth parameter
      * exists, assume that to be the input bit-depth. However, if the
      * input-bit-depth paramter does not exist, assume the input bit-depth
      * to be the same as the codec bit-depth.
      */
     if (!input.bit_depth) {
-      FOREACH_STREAM({
+      FOREACH_STREAM(stream, streams) {
         if (stream->config.cfg.g_input_bit_depth)
           input.bit_depth = stream->config.cfg.g_input_bit_depth;
         else
           input.bit_depth = stream->config.cfg.g_input_bit_depth =
               (int)stream->config.cfg.g_bit_depth;
-      });
+      }
       if (input.bit_depth > 8) input.fmt |= AOM_IMG_FMT_HIGHBITDEPTH;
     } else {
-      FOREACH_STREAM(
-          { stream->config.cfg.g_input_bit_depth = input.bit_depth; });
+      FOREACH_STREAM(stream, streams) {
+        stream->config.cfg.g_input_bit_depth = input.bit_depth;
+      }
     }
 
-#if CONFIG_HIGHBITDEPTH
-    FOREACH_STREAM({
+    FOREACH_STREAM(stream, streams) {
       if (input.fmt != AOM_IMG_FMT_I420 && input.fmt != AOM_IMG_FMT_I42016) {
         /* Automatically upgrade if input is non-4:2:0 but a 4:2:0 profile
            was selected. */
         switch (stream->config.cfg.g_profile) {
           case 0:
             stream->config.cfg.g_profile = 1;
             profile_updated = 1;
             break;
@@ -1819,125 +1860,112 @@ int main(int argc, const char **argv_) {
           case 1:
             stream->config.cfg.g_profile = 3;
             profile_updated = 1;
             break;
           default: break;
         }
       }
       if (stream->config.cfg.g_profile > 1) {
+        if (!CONFIG_HIGHBITDEPTH) fatal("Unsupported profile.");
         stream->config.use_16bit_internal = 1;
       }
       if (profile_updated && !global.quiet) {
         fprintf(stderr,
                 "Warning: automatically upgrading to profile %d to "
                 "match input format.\n",
                 stream->config.cfg.g_profile);
       }
-    });
-#else
-    FOREACH_STREAM({
-      if (input.fmt != AOM_IMG_FMT_I420 && input.fmt != AOM_IMG_FMT_I42016) {
-        /* Automatically upgrade if input is non-4:2:0 but a 4:2:0 profile
-           was selected. */
-        switch (stream->config.cfg.g_profile) {
-          case 0:
-            stream->config.cfg.g_profile = 1;
-            profile_updated = 1;
-            break;
-          case 2:
-            stream->config.cfg.g_profile = 3;
-            profile_updated = 1;
-            break;
-          default: break;
-        }
-      }
-      if (profile_updated && !global.quiet) {
-        fprintf(stderr,
-                "Warning: automatically upgrading to profile %d to "
-                "match input format.\n",
-                stream->config.cfg.g_profile);
-      }
-    });
-#endif
+    }
 
-    FOREACH_STREAM(set_stream_dimensions(stream, input.width, input.height));
-    FOREACH_STREAM(validate_stream_config(stream, &global));
+    FOREACH_STREAM(stream, streams) {
+      set_stream_dimensions(stream, input.width, input.height);
+    }
+    FOREACH_STREAM(stream, streams) { validate_stream_config(stream, &global); }
 
     /* Ensure that --passes and --pass are consistent. If --pass is set and
      * --passes=2, ensure --fpf was set.
      */
-    if (global.pass && global.passes == 2)
-      FOREACH_STREAM({
+    if (global.pass && global.passes == 2) {
+      FOREACH_STREAM(stream, streams) {
         if (!stream->config.stats_fn)
           die("Stream %d: Must specify --fpf when --pass=%d"
               " and --passes=2\n",
               stream->index, global.pass);
-      });
+      }
+    }
 
 #if !CONFIG_WEBM_IO
-    FOREACH_STREAM({
+    FOREACH_STREAM(stream, streams) {
       if (stream->config.write_webm) {
         stream->config.write_webm = 0;
         warn(
             "aomenc was compiled without WebM container support."
             "Producing IVF output");
       }
-    });
+    }
 #endif
 
     /* Use the frame rate from the file only if none was specified
      * on the command-line.
      */
     if (!global.have_framerate) {
       global.framerate.num = input.framerate.numerator;
       global.framerate.den = input.framerate.denominator;
-      FOREACH_STREAM(stream->config.cfg.g_timebase.den = global.framerate.num;
-                     stream->config.cfg.g_timebase.num = global.framerate.den);
+      FOREACH_STREAM(stream, streams) {
+        stream->config.cfg.g_timebase.den = global.framerate.num;
+        stream->config.cfg.g_timebase.num = global.framerate.den;
+      }
     }
 
     /* Show configuration */
-    if (global.verbose && pass == 0)
-      FOREACH_STREAM(show_stream_config(stream, &global, &input));
+    if (global.verbose && pass == 0) {
+      FOREACH_STREAM(stream, streams) {
+        show_stream_config(stream, &global, &input);
+      }
+    }
 
     if (pass == (global.pass ? global.pass - 1 : 0)) {
       if (input.file_type == FILE_TYPE_Y4M)
         /*The Y4M reader does its own allocation.
           Just initialize this here to avoid problems if we never read any
-           frames.*/
+          frames.*/
         memset(&raw, 0, sizeof(raw));
       else
         aom_img_alloc(&raw, input.fmt, input.width, input.height, 32);
 
-      FOREACH_STREAM(stream->rate_hist = init_rate_histogram(
-                         &stream->config.cfg, &global.framerate));
+      FOREACH_STREAM(stream, streams) {
+        stream->rate_hist =
+            init_rate_histogram(&stream->config.cfg, &global.framerate);
+      }
     }
 
-    FOREACH_STREAM(setup_pass(stream, &global, pass));
-    FOREACH_STREAM(
-        open_output_file(stream, &global, &input.pixel_aspect_ratio));
-    FOREACH_STREAM(initialize_encoder(stream, &global));
+    FOREACH_STREAM(stream, streams) { setup_pass(stream, &global, pass); }
+    FOREACH_STREAM(stream, streams) {
+      open_output_file(stream, &global, &input.pixel_aspect_ratio);
+    }
+    FOREACH_STREAM(stream, streams) { initialize_encoder(stream, &global); }
 
 #if CONFIG_HIGHBITDEPTH
     if (strcmp(global.codec->name, "av1") == 0 ||
         strcmp(global.codec->name, "av1") == 0) {
       // Check to see if at least one stream uses 16 bit internal.
       // Currently assume that the bit_depths for all streams using
       // highbitdepth are the same.
-      FOREACH_STREAM({
+      FOREACH_STREAM(stream, streams) {
         if (stream->config.use_16bit_internal) {
           use_16bit_internal = 1;
         }
         if (stream->config.cfg.g_profile == 0) {
           input_shift = 0;
         } else {
           input_shift = (int)stream->config.cfg.g_bit_depth -
                         stream->config.cfg.g_input_bit_depth;
         }
-      });
+      };
     }
 #endif
 
     frame_avail = 1;
     got_data = 0;
 
     while (frame_avail || got_data) {
       struct aom_usec_timer timer;
@@ -1985,41 +2013,45 @@ int main(int argc, const char **argv_) {
           aom_img_upshift(&raw_shift, &raw, input_shift);
           frame_to_encode = &raw_shift;
         } else {
           frame_to_encode = &raw;
         }
         aom_usec_timer_start(&timer);
         if (use_16bit_internal) {
           assert(frame_to_encode->fmt & AOM_IMG_FMT_HIGHBITDEPTH);
-          FOREACH_STREAM({
+          FOREACH_STREAM(stream, streams) {
             if (stream->config.use_16bit_internal)
               encode_frame(stream, &global,
                            frame_avail ? frame_to_encode : NULL, frames_in);
             else
               assert(0);
-          });
+          };
         } else {
           assert((frame_to_encode->fmt & AOM_IMG_FMT_HIGHBITDEPTH) == 0);
-          FOREACH_STREAM(encode_frame(stream, &global,
-                                      frame_avail ? frame_to_encode : NULL,
-                                      frames_in));
+          FOREACH_STREAM(stream, streams) {
+            encode_frame(stream, &global, frame_avail ? frame_to_encode : NULL,
+                         frames_in);
+          }
         }
 #else
         aom_usec_timer_start(&timer);
-        FOREACH_STREAM(encode_frame(stream, &global, frame_avail ? &raw : NULL,
-                                    frames_in));
+        FOREACH_STREAM(stream, streams) {
+          encode_frame(stream, &global, frame_avail ? &raw : NULL, frames_in);
+        }
 #endif
         aom_usec_timer_mark(&timer);
         cx_time += aom_usec_timer_elapsed(&timer);
 
-        FOREACH_STREAM(update_quantizer_histogram(stream));
+        FOREACH_STREAM(stream, streams) { update_quantizer_histogram(stream); }
 
         got_data = 0;
-        FOREACH_STREAM(get_cx_data(stream, &global, &got_data));
+        FOREACH_STREAM(stream, streams) {
+          get_cx_data(stream, &global, &got_data);
+        }
 
         if (!got_data && input.length && streams != NULL &&
             !streams->frames_out) {
           lagged_count = global.limit ? seen_frames : ftello(input.file);
         } else if (input.length) {
           int64_t remaining;
           int64_t rate;
 
@@ -2038,98 +2070,118 @@ int main(int argc, const char **argv_) {
             remaining = input_limit - input_pos + lagged_count;
           }
 
           average_rate =
               (average_rate <= 0) ? rate : (average_rate * 7 + rate) / 8;
           estimated_time_left = average_rate ? remaining / average_rate : -1;
         }
 
-        if (got_data && global.test_decode != TEST_DECODE_OFF)
-          FOREACH_STREAM(test_decode(stream, global.test_decode, global.codec));
+        if (got_data && global.test_decode != TEST_DECODE_OFF) {
+          FOREACH_STREAM(stream, streams) {
+            test_decode(stream, global.test_decode, global.codec);
+          }
+        }
       }
 
       fflush(stdout);
       if (!global.quiet) fprintf(stderr, "\033[K");
     }
 
     if (stream_cnt > 1) fprintf(stderr, "\n");
 
     if (!global.quiet) {
-      FOREACH_STREAM(fprintf(
-          stderr, "\rPass %d/%d frame %4d/%-4d %7" PRId64 "B %7" PRId64
-                  "b/f %7" PRId64 "b/s"
-                  " %7" PRId64 " %s (%.2f fps)\033[K\n",
-          pass + 1, global.passes, frames_in, stream->frames_out,
-          (int64_t)stream->nbytes,
-          seen_frames ? (int64_t)(stream->nbytes * 8 / seen_frames) : 0,
-          seen_frames
-              ? (int64_t)stream->nbytes * 8 * (int64_t)global.framerate.num /
-                    global.framerate.den / seen_frames
-              : 0,
-          stream->cx_time > 9999999 ? stream->cx_time / 1000 : stream->cx_time,
-          stream->cx_time > 9999999 ? "ms" : "us",
-          usec_to_fps(stream->cx_time, seen_frames)));
+      FOREACH_STREAM(stream, streams) {
+        fprintf(stderr, "\rPass %d/%d frame %4d/%-4d %7" PRId64 "B %7" PRId64
+                        "b/f %7" PRId64
+                        "b/s"
+                        " %7" PRId64 " %s (%.2f fps)\033[K\n",
+                pass + 1, global.passes, frames_in, stream->frames_out,
+                (int64_t)stream->nbytes,
+                seen_frames ? (int64_t)(stream->nbytes * 8 / seen_frames) : 0,
+                seen_frames
+                    ? (int64_t)stream->nbytes * 8 *
+                          (int64_t)global.framerate.num / global.framerate.den /
+                          seen_frames
+                    : 0,
+                stream->cx_time > 9999999 ? stream->cx_time / 1000
+                                          : stream->cx_time,
+                stream->cx_time > 9999999 ? "ms" : "us",
+                usec_to_fps(stream->cx_time, seen_frames));
+      }
     }
 
     if (global.show_psnr) {
       if (global.codec->fourcc == AV1_FOURCC) {
-        FOREACH_STREAM(
-            show_psnr(stream, (1 << stream->config.cfg.g_input_bit_depth) - 1));
+        FOREACH_STREAM(stream, streams) {
+          show_psnr(stream, (1 << stream->config.cfg.g_input_bit_depth) - 1);
+        }
       } else {
-        FOREACH_STREAM(show_psnr(stream, 255.0));
+        FOREACH_STREAM(stream, streams) { show_psnr(stream, 255.0); }
       }
     }
 
-    FOREACH_STREAM(aom_codec_destroy(&stream->encoder));
+    FOREACH_STREAM(stream, streams) { aom_codec_destroy(&stream->encoder); }
 
     if (global.test_decode != TEST_DECODE_OFF) {
-      FOREACH_STREAM(aom_codec_destroy(&stream->decoder));
+      FOREACH_STREAM(stream, streams) { aom_codec_destroy(&stream->decoder); }
     }
 
     close_input_file(&input);
 
     if (global.test_decode == TEST_DECODE_FATAL) {
-      FOREACH_STREAM(res |= stream->mismatch_seen);
+      FOREACH_STREAM(stream, streams) { res |= stream->mismatch_seen; }
+    }
+    FOREACH_STREAM(stream, streams) {
+      close_output_file(stream, global.codec->fourcc);
     }
-    FOREACH_STREAM(close_output_file(stream, global.codec->fourcc));
 
-    FOREACH_STREAM(stats_close(&stream->stats, global.passes - 1));
+    FOREACH_STREAM(stream, streams) {
+      stats_close(&stream->stats, global.passes - 1);
+    }
 
 #if CONFIG_FP_MB_STATS
-    FOREACH_STREAM(stats_close(&stream->fpmb_stats, global.passes - 1));
+    FOREACH_STREAM(stream, streams) {
+      stats_close(&stream->fpmb_stats, global.passes - 1);
+    }
 #endif
 
     if (global.pass) break;
   }
 
-  if (global.show_q_hist_buckets)
-    FOREACH_STREAM(
-        show_q_histogram(stream->counts, global.show_q_hist_buckets));
+  if (global.show_q_hist_buckets) {
+    FOREACH_STREAM(stream, streams) {
+      show_q_histogram(stream->counts, global.show_q_hist_buckets);
+    }
+  }
 
-  if (global.show_rate_hist_buckets)
-    FOREACH_STREAM(show_rate_histogram(stream->rate_hist, &stream->config.cfg,
-                                       global.show_rate_hist_buckets));
-  FOREACH_STREAM(destroy_rate_histogram(stream->rate_hist));
+  if (global.show_rate_hist_buckets) {
+    FOREACH_STREAM(stream, streams) {
+      show_rate_histogram(stream->rate_hist, &stream->config.cfg,
+                          global.show_rate_hist_buckets);
+    }
+  }
+  FOREACH_STREAM(stream, streams) { destroy_rate_histogram(stream->rate_hist); }
 
 #if CONFIG_INTERNAL_STATS
   /* TODO(jkoleszar): This doesn't belong in this executable. Do it for now,
    * to match some existing utilities.
    */
-  if (!(global.pass == 1 && global.passes == 2))
-    FOREACH_STREAM({
+  if (!(global.pass == 1 && global.passes == 2)) {
+    FOREACH_STREAM(stream, streams) {
       FILE *f = fopen("opsnr.stt", "a");
       if (stream->mismatch_seen) {
         fprintf(f, "First mismatch occurred in frame %d\n",
                 stream->mismatch_seen);
       } else {
         fprintf(f, "No mismatch detected in recon buffers\n");
       }
       fclose(f);
-    });
+    }
+  }
 #endif
 
 #if CONFIG_HIGHBITDEPTH
   if (allocated_raw_shift) aom_img_free(&raw_shift);
 #endif
   aom_img_free(&raw);
   free(argv);
   free(streams);
--- a/third_party/aom/av1/av1.cmake
+++ b/third_party/aom/av1/av1.cmake
@@ -185,19 +185,19 @@ set(AOM_AV1_ENCODER_INTRIN_SSE2
 
 set(AOM_AV1_ENCODER_ASM_SSSE3_X86_64
     "${AOM_ROOT}/av1/encoder/x86/av1_quantize_ssse3_x86_64.asm")
 
 set(AOM_AV1_ENCODER_INTRIN_SSSE3
     "${AOM_ROOT}/av1/encoder/x86/dct_ssse3.c")
 
 set(AOM_AV1_ENCODER_INTRIN_AVX2
+    "${AOM_ROOT}/av1/encoder/x86/av1_quantize_avx2.c"
     "${AOM_ROOT}/av1/encoder/x86/error_intrin_avx2.c"
     "${AOM_ROOT}/av1/encoder/x86/hybrid_fwd_txfm_avx2.c")
-
 set(AOM_AV1_ENCODER_INTRIN_NEON
     "${AOM_ROOT}/av1/encoder/arm/neon/quantize_neon.c")
 
 set(AOM_AV1_ENCODER_INTRIN_MSA
     "${AOM_ROOT}/av1/encoder/mips/msa/error_msa.c"
     "${AOM_ROOT}/av1/encoder/mips/msa/fdct16x16_msa.c"
     "${AOM_ROOT}/av1/encoder/mips/msa/fdct4x4_msa.c"
     "${AOM_ROOT}/av1/encoder/mips/msa/fdct8x8_msa.c"
@@ -213,16 +213,20 @@ if (CONFIG_HIGHBITDEPTH)
   set(AOM_AV1_COMMON_INTRIN_AVX2
       ${AOM_AV1_COMMON_INTRIN_AVX2}
       "${AOM_ROOT}/av1/common/x86/highbd_inv_txfm_avx2.c")
 
   set(AOM_AV1_ENCODER_INTRIN_SSE4_1
       ${AOM_AV1_ENCODER_INTRIN_SSE4_1}
       "${AOM_ROOT}/av1/encoder/x86/av1_highbd_quantize_sse4.c"
       "${AOM_ROOT}/av1/encoder/x86/highbd_fwd_txfm_sse4.c")
+
+  set(AOM_AV1_ENCODER_INTRIN_AVX2
+      ${AOM_AV1_ENCODER_INTRIN_AVX2}
+      "${AOM_ROOT}/av1/encoder/x86/av1_highbd_quantize_avx2.c")
 else ()
   set(AOM_AV1_COMMON_INTRIN_NEON
       ${AOM_AV1_COMMON_INTRIN_NEON}
       "${AOM_ROOT}/av1/encoder/arm/neon/dct_neon.c"
       "${AOM_ROOT}/av1/common/arm/neon/iht4x4_add_neon.c"
       "${AOM_ROOT}/av1/common/arm/neon/iht8x8_add_neon.c")
 
   set(AOM_AV1_ENCODER_INTRIN_NEON
@@ -437,128 +441,139 @@ if (CONFIG_WARPED_MOTION OR CONFIG_GLOBA
         "${AOM_ROOT}/av1/common/x86/highbd_warp_plane_ssse3.c")
   endif ()
 endif ()
 
 # Setup AV1 common/decoder/encoder targets. The libaom target must exist before
 # this function is called.
 function (setup_av1_targets)
   add_library(aom_av1_common OBJECT ${AOM_AV1_COMMON_SOURCES})
-  set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_av1_common)
-  target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_av1_common>)
+  list(APPEND AOM_LIB_TARGETS aom_av1_common)
+
+  create_dummy_source_file("aom_av1" "c" "dummy_source_file")
+  add_library(aom_av1 OBJECT "${dummy_source_file}")
+  target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_av1_common>)
+  list(APPEND AOM_LIB_TARGETS aom_av1)
+
+  # Not all generators support libraries consisting only of object files. Add a
+  # dummy source file to the aom_av1 target.
+  add_dummy_source_file_to_target("aom_av1" "c")
 
   if (CONFIG_AV1_DECODER)
     add_library(aom_av1_decoder OBJECT ${AOM_AV1_DECODER_SOURCES})
     set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_av1_decoder)
-    target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_av1_decoder>)
+    target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_av1_decoder>)
   endif ()
 
   if (CONFIG_AV1_ENCODER)
     add_library(aom_av1_encoder OBJECT ${AOM_AV1_ENCODER_SOURCES})
     set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_av1_encoder)
-    target_sources(aom PUBLIC $<TARGET_OBJECTS:aom_av1_encoder>)
+    target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_av1_encoder>)
   endif ()
 
   if (HAVE_SSE2)
     require_flag_nomsvc("-msse2" NO)
     add_intrinsics_object_library("-msse2" "sse2" "aom_av1_common"
-                                  "AOM_AV1_COMMON_INTRIN_SSE2")
+                                  "AOM_AV1_COMMON_INTRIN_SSE2" "aom")
     if (CONFIG_AV1_DECODER)
       if (AOM_AV1_DECODER_ASM_SSE2)
         add_asm_library("aom_av1_decoder_sse2" "AOM_AV1_DECODER_ASM_SSE2" "aom")
       endif ()
 
       if (AOM_AV1_DECODER_INTRIN_SSE2)
         add_intrinsics_object_library("-msse2" "sse2" "aom_av1_decoder"
-                                      "AOM_AV1_DECODER_INTRIN_SSE2")
+                                      "AOM_AV1_DECODER_INTRIN_SSE2" "aom")
       endif ()
     endif ()
 
     if (CONFIG_AV1_ENCODER)
       add_asm_library("aom_av1_encoder_sse2" "AOM_AV1_ENCODER_ASM_SSE2" "aom")
       add_intrinsics_object_library("-msse2" "sse2" "aom_av1_encoder"
-                                    "AOM_AV1_ENCODER_INTRIN_SSE2")
+                                    "AOM_AV1_ENCODER_INTRIN_SSE2" "aom")
     endif ()
   endif ()
 
   if (HAVE_SSSE3)
     require_flag_nomsvc("-mssse3" NO)
     add_intrinsics_object_library("-mssse3" "ssse3" "aom_av1_common"
-                                  "AOM_AV1_COMMON_INTRIN_SSSE3")
+                                  "AOM_AV1_COMMON_INTRIN_SSSE3" "aom")
 
     if (CONFIG_AV1_DECODER)
       if (AOM_AV1_DECODER_INTRIN_SSSE3)
         add_intrinsics_object_library("-mssse3" "ssse3" "aom_av1_decoder"
-                                      "AOM_AV1_DECODER_INTRIN_SSSE3")
+                                      "AOM_AV1_DECODER_INTRIN_SSSE3" "aom")
       endif ()
     endif ()
 
     if (CONFIG_AV1_ENCODER)
       add_intrinsics_object_library("-mssse3" "ssse3" "aom_av1_encoder"
-                                    "AOM_AV1_ENCODER_INTRIN_SSSE3")
+                                    "AOM_AV1_ENCODER_INTRIN_SSSE3" "aom")
     endif ()
   endif ()
 
   if (HAVE_SSE4_1)
     require_flag_nomsvc("-msse4.1" NO)
     add_intrinsics_object_library("-msse4.1" "sse4" "aom_av1_common"
-                                  "AOM_AV1_COMMON_INTRIN_SSE4_1")
+                                  "AOM_AV1_COMMON_INTRIN_SSE4_1" "aom")
 
     if (CONFIG_AV1_ENCODER)
       if ("${AOM_TARGET_CPU}" STREQUAL "x86_64")
         add_asm_library("aom_av1_encoder_ssse3"
                         "AOM_AV1_ENCODER_ASM_SSSE3_X86_64" "aom")
       endif ()
 
       if (AOM_AV1_ENCODER_INTRIN_SSE4_1)
         add_intrinsics_object_library("-msse4.1" "sse4" "aom_av1_encoder"
-                                      "AOM_AV1_ENCODER_INTRIN_SSE4_1")
+                                      "AOM_AV1_ENCODER_INTRIN_SSE4_1" "aom")
       endif ()
     endif ()
   endif ()
 
   if (HAVE_AVX2)
     require_flag_nomsvc("-mavx2" NO)
     add_intrinsics_object_library("-mavx2" "avx2" "aom_av1_common"
-                                  "AOM_AV1_COMMON_INTRIN_AVX2")
+                                  "AOM_AV1_COMMON_INTRIN_AVX2" "aom")
 
     if (CONFIG_AV1_ENCODER)
       add_intrinsics_object_library("-mavx2" "avx2" "aom_av1_encoder"
-                                    "AOM_AV1_ENCODER_INTRIN_AVX2")
+                                    "AOM_AV1_ENCODER_INTRIN_AVX2" "aom")
     endif ()
   endif ()
 
   if (HAVE_NEON)
     if (AOM_AV1_COMMON_INTRIN_NEON)
       add_intrinsics_object_library("${AOM_INTRIN_NEON_FLAG}"
                                     "neon"
                                     "aom_av1_common"
-                                    "AOM_AV1_COMMON_INTRIN_NEON")
+                                    "AOM_AV1_COMMON_INTRIN_NEON" "aom")
     endif ()
 
     if (AOM_AV1_ENCODER_INTRIN_NEON)
       add_intrinsics_object_library("${AOM_INTRIN_NEON_FLAG}"
                                     "neon"
                                     "aom_av1_encoder"
-                                    "AOM_AV1_ENCODER_INTRIN_NEON")
+                                    "AOM_AV1_ENCODER_INTRIN_NEON" "aom")
     endif ()
   endif ()
 
   if (HAVE_DSPR2)
     add_intrinsics_object_library("" "dspr2" "aom_av1_common"
-                                  "AOM_AV1_COMMON_INTRIN_DSPR2")
+                                  "AOM_AV1_COMMON_INTRIN_DSPR2" "aom")
   endif ()
 
   if (HAVE_MSA)
     add_intrinsics_object_library("" "msa" "aom_av1_common"
-                                  "AOM_AV1_COMMON_INTRIN_MSA")
+                                  "AOM_AV1_COMMON_INTRIN_MSA" "aom")
     add_intrinsics_object_library("" "msa" "aom_av1_encoder"
-                                  "AOM_AV1_ENCODER_INTRIN_MSA")
+                                  "AOM_AV1_ENCODER_INTRIN_MSA" "aom")
   endif ()
 
+  target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_dsp>)
+  target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_scale>)
+
   # Pass the new lib targets up to the parent scope instance of
   # $AOM_LIB_TARGETS.
   set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
 endfunction ()
 
 function (setup_av1_test_targets)
 endfunction ()
 
--- a/third_party/aom/av1/av1_common.mk
+++ b/third_party/aom/av1/av1_common.mk
@@ -149,21 +149,20 @@ AV1_COMMON_SRCS-$(HAVE_MSA) += common/mi
 AV1_COMMON_SRCS-$(HAVE_SSE2) += common/x86/idct_intrin_sse2.c
 AV1_COMMON_SRCS-$(HAVE_AVX2) += common/x86/hybrid_inv_txfm_avx2.c
 
 ifeq ($(CONFIG_AV1_ENCODER),yes)
 AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/x86/av1_txfm1d_sse4.h
 AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/x86/av1_fwd_txfm1d_sse4.c
 AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/x86/av1_fwd_txfm2d_sse4.c
 endif
-ifeq ($(CONFIG_HIGHBITDEPTH),yes)
+
 AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/x86/highbd_txfm_utility_sse4.h
 AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/x86/highbd_inv_txfm_sse4.c
 AV1_COMMON_SRCS-$(HAVE_AVX2) += common/x86/highbd_inv_txfm_avx2.c
-endif
 
 ifneq ($(CONFIG_HIGHBITDEPTH),yes)
 AV1_COMMON_SRCS-$(HAVE_NEON) += common/arm/neon/iht4x4_add_neon.c
 AV1_COMMON_SRCS-$(HAVE_NEON) += common/arm/neon/iht8x8_add_neon.c
 endif
 
 ifeq ($(CONFIG_FILTER_INTRA),yes)
 AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/x86/filterintra_sse4.c
@@ -172,9 +171,16 @@ endif
 ifneq ($(findstring yes,$(CONFIG_GLOBAL_MOTION) $(CONFIG_WARPED_MOTION)),)
 AV1_COMMON_SRCS-$(HAVE_SSE2) += common/x86/warp_plane_sse2.c
 AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/x86/warp_plane_ssse3.c
 ifeq ($(CONFIG_HIGHBITDEPTH),yes)
 AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/x86/highbd_warp_plane_ssse3.c
 endif
 endif
 
+ifeq ($(CONFIG_CONVOLVE_ROUND),yes)
+AV1_COMMON_SRCS-$(HAVE_SSE2) += common/x86/convolve_2d_sse2.c
+ifeq ($(CONFIG_HIGHBITDEPTH),yes)
+AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/x86/highbd_convolve_2d_ssse3.c
+endif
+endif
+
 $(eval $(call rtcd_h_template,av1_rtcd,av1/common/av1_rtcd_defs.pl))
--- a/third_party/aom/av1/av1_cx.mk
+++ b/third_party/aom/av1/av1_cx.mk
@@ -16,16 +16,18 @@ AV1_CX_SRCS-no  += $(AV1_COMMON_SRCS-no)
 AV1_CX_SRCS_REMOVE-yes += $(AV1_COMMON_SRCS_REMOVE-yes)
 AV1_CX_SRCS_REMOVE-no  += $(AV1_COMMON_SRCS_REMOVE-no)
 
 AV1_CX_SRCS-yes += av1_cx_iface.c
 
 AV1_CX_SRCS-yes += encoder/av1_quantize.c
 AV1_CX_SRCS-yes += encoder/av1_quantize.h
 AV1_CX_SRCS-yes += encoder/bitstream.c
+AV1_CX_SRCS-$(CONFIG_BGSPRITE) += encoder/bgsprite.c
+AV1_CX_SRCS-$(CONFIG_BGSPRITE) += encoder/bgsprite.h
 AV1_CX_SRCS-yes += encoder/context_tree.c
 AV1_CX_SRCS-yes += encoder/context_tree.h
 AV1_CX_SRCS-yes += encoder/cost.h
 AV1_CX_SRCS-yes += encoder/cost.c
 AV1_CX_SRCS-yes += encoder/dct.c
 AV1_CX_SRCS-yes += encoder/hybrid_fwd_txfm.c
 AV1_CX_SRCS-yes += encoder/hybrid_fwd_txfm.h
 AV1_CX_SRCS-yes += encoder/encodeframe.c
@@ -116,35 +118,37 @@ AV1_CX_SRCS-yes += encoder/pvq_encoder.h
 AV1_CX_SRCS-yes += encoder/generic_encoder.c
 AV1_CX_SRCS-yes += encoder/laplace_encoder.c
 endif
 ifneq ($(findstring yes,$(CONFIG_XIPHRC)$(CONFIG_PVQ)),)
 AV1_CX_SRCS-yes += encoder/encint.h
 endif
 
 AV1_CX_SRCS-$(HAVE_SSE2) += encoder/x86/av1_quantize_sse2.c
+AV1_CX_SRCS-$(HAVE_AVX2) += encoder/x86/av1_quantize_avx2.c
 AV1_CX_SRCS-$(HAVE_SSE2) += encoder/x86/temporal_filter_apply_sse2.asm
-ifeq ($(CONFIG_HIGHBITDEPTH),yes)
+
 AV1_CX_SRCS-$(HAVE_SSE2) += encoder/x86/highbd_block_error_intrin_sse2.c
-endif
+AV1_CX_SRCS-$(HAVE_AVX2) += encoder/x86/av1_highbd_quantize_avx2.c
+
 
 AV1_CX_SRCS-$(HAVE_SSE2) += encoder/x86/dct_sse2.asm
 AV1_CX_SRCS-$(HAVE_SSE2) += encoder/x86/error_sse2.asm
 
 ifeq ($(ARCH_X86_64),yes)
 AV1_CX_SRCS-$(HAVE_SSSE3) += encoder/x86/av1_quantize_ssse3_x86_64.asm
 endif
 
 AV1_CX_SRCS-$(HAVE_SSE2) += encoder/x86/dct_intrin_sse2.c
 AV1_CX_SRCS-$(HAVE_SSSE3) += encoder/x86/dct_ssse3.c
 AV1_CX_SRCS-$(HAVE_AVX2) += encoder/x86/hybrid_fwd_txfm_avx2.c
-ifeq ($(CONFIG_HIGHBITDEPTH),yes)
+
 AV1_CX_SRCS-$(HAVE_SSE4_1) += encoder/x86/av1_highbd_quantize_sse4.c
+
 AV1_CX_SRCS-$(HAVE_SSE4_1) += encoder/x86/highbd_fwd_txfm_sse4.c
-endif
 
 ifeq ($(CONFIG_EXT_INTER),yes)
 AV1_CX_SRCS-yes += encoder/wedge_utils.c
 AV1_CX_SRCS-$(HAVE_SSE2) += encoder/x86/wedge_utils_sse2.c
 endif
 
 AV1_CX_SRCS-$(HAVE_AVX2) += encoder/x86/error_intrin_avx2.c
 
--- a/third_party/aom/av1/av1_cx_iface.c
+++ b/third_party/aom/av1/av1_cx_iface.c
@@ -66,16 +66,20 @@ struct av1_extracfg {
   AQ_MODE aq_mode;
 #if CONFIG_EXT_DELTA_Q
   DELTAQ_MODE deltaq_mode;
 #endif
   unsigned int frame_periodic_boost;
   aom_bit_depth_t bit_depth;
   aom_tune_content content;
   aom_color_space_t color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  aom_transfer_function_t transfer_function;
+  aom_chroma_sample_position_t chroma_sample_position;
+#endif
   int color_range;
   int render_width;
   int render_height;
   aom_superblock_size_t superblock_size;
 #if CONFIG_ANS && ANS_MAX_SYMBOLS
   int ans_window_size_log2;
 #endif
 #if CONFIG_EXT_TILE
@@ -97,17 +101,17 @@ static struct av1_extracfg default_extra
 #if CONFIG_EXT_TILE
   UINT_MAX,  // tile_columns
   UINT_MAX,  // tile_rows
 #else
   0,  // tile_columns
   0,  // tile_rows
 #endif  // CONFIG_EXT_TILE
 #if CONFIG_DEPENDENT_HORZTILES
-  0,  // Depdendent Horizontal tiles
+  0,  // Dependent Horizontal tiles
 #endif
 #if CONFIG_LOOPFILTERING_ACROSS_TILES
   1,              // loop_filter_across_tiles_enabled
 #endif            // CONFIG_LOOPFILTERING_ACROSS_TILES
   7,              // arnr_max_frames
   5,              // arnr_strength
   0,              // min_gf_interval; 0 -> default decision
   0,              // max_gf_interval; 0 -> default decision
@@ -129,20 +133,24 @@ static struct av1_extracfg default_extra
 #if CONFIG_TEMPMV_SIGNALING
   0,  // disable temporal mv prediction
 #endif
   1,      // frame_parallel_decoding_mode
   NO_AQ,  // aq_mode
 #if CONFIG_EXT_DELTA_Q
   NO_DELTA_Q,  // deltaq_mode
 #endif
-  CONFIG_XIPHRC,                // frame_periodic_delta_q
-  AOM_BITS_8,                   // Bit depth
-  AOM_CONTENT_DEFAULT,          // content
-  AOM_CS_UNKNOWN,               // color space
+  CONFIG_XIPHRC,        // frame_periodic_delta_q
+  AOM_BITS_8,           // Bit depth
+  AOM_CONTENT_DEFAULT,  // content
+  AOM_CS_UNKNOWN,       // color space
+#if CONFIG_COLORSPACE_HEADERS
+  AOM_TF_UNKNOWN,   // transfer function
+  AOM_CSP_UNKNOWN,  // chroma sample position
+#endif
   0,                            // color range
   0,                            // render width
   0,                            // render height
   AOM_SUPERBLOCK_SIZE_DYNAMIC,  // superblock_size
 #if CONFIG_ANS && ANS_MAX_SYMBOLS
   23,  // ans_window_size_log2
 #endif
 #if CONFIG_EXT_TILE
@@ -230,35 +238,40 @@ static aom_codec_err_t validate_config(a
   RANGE_CHECK_HI(extra_cfg, frame_periodic_boost, 1);
   RANGE_CHECK_HI(cfg, g_threads, 64);
   RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS);
   RANGE_CHECK(cfg, rc_end_usage, AOM_VBR, AOM_Q);
   RANGE_CHECK_HI(cfg, rc_undershoot_pct, 100);
   RANGE_CHECK_HI(cfg, rc_overshoot_pct, 100);
   RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100);
   RANGE_CHECK(cfg, kf_mode, AOM_KF_DISABLED, AOM_KF_AUTO);
-  RANGE_CHECK_BOOL(cfg, rc_resize_allowed);
   RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100);
-  RANGE_CHECK_HI(cfg, rc_resize_up_thresh, 100);
-  RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100);
   RANGE_CHECK(cfg, g_pass, AOM_RC_ONE_PASS, AOM_RC_LAST_PASS);
   RANGE_CHECK_HI(extra_cfg, min_gf_interval, MAX_LAG_BUFFERS - 1);
   RANGE_CHECK_HI(extra_cfg, max_gf_interval, MAX_LAG_BUFFERS - 1);
   if (extra_cfg->max_gf_interval > 0) {
     RANGE_CHECK(extra_cfg, max_gf_interval, 2, (MAX_LAG_BUFFERS - 1));
   }
   if (extra_cfg->min_gf_interval > 0 && extra_cfg->max_gf_interval > 0) {
     RANGE_CHECK(extra_cfg, max_gf_interval, extra_cfg->min_gf_interval,
                 (MAX_LAG_BUFFERS - 1));
   }
 
-  if (cfg->rc_resize_allowed == 1) {
-    RANGE_CHECK_HI(cfg, rc_scaled_width, cfg->g_w);
-    RANGE_CHECK_HI(cfg, rc_scaled_height, cfg->g_h);
-  }
+  RANGE_CHECK_HI(cfg, rc_resize_mode, RESIZE_DYNAMIC);
+  RANGE_CHECK(cfg, rc_resize_numerator, SCALE_DENOMINATOR / 2,
+              SCALE_DENOMINATOR);
+  RANGE_CHECK(cfg, rc_resize_kf_numerator, SCALE_DENOMINATOR / 2,
+              SCALE_DENOMINATOR);
+#if CONFIG_FRAME_SUPERRES
+  RANGE_CHECK_HI(cfg, rc_superres_mode, SUPERRES_DYNAMIC);
+  RANGE_CHECK(cfg, rc_superres_numerator, SCALE_DENOMINATOR / 2,
+              SCALE_DENOMINATOR);
+  RANGE_CHECK(cfg, rc_superres_kf_numerator, SCALE_DENOMINATOR / 2,
+              SCALE_DENOMINATOR);
+#endif  // CONFIG_FRAME_SUPERRES
 
   // AV1 does not support a lower bound on the keyframe interval in
   // automatic keyframe placement mode.
   if (cfg->kf_mode != AOM_KF_DISABLED && cfg->kf_min_dist != cfg->kf_max_dist &&
       cfg->kf_min_dist > 0)
     ERROR(
         "kf_min_dist not supported in auto mode, use 0 "
         "or kf_max_dist instead.");
@@ -349,17 +362,24 @@ static aom_codec_err_t validate_config(a
   }
   if (cfg->g_profile <= (unsigned int)PROFILE_1 && cfg->g_input_bit_depth > 8) {
     ERROR("Source high bit-depth not supported in profile < 2");
   }
   if (cfg->g_profile > (unsigned int)PROFILE_1 &&
       cfg->g_bit_depth == AOM_BITS_8) {
     ERROR("Codec bit-depth 8 not supported in profile > 1");
   }
+#if CONFIG_COLORSPACE_HEADERS
+  RANGE_CHECK(extra_cfg, color_space, AOM_CS_UNKNOWN, AOM_CS_ICTCP);
+  RANGE_CHECK(extra_cfg, transfer_function, AOM_TF_UNKNOWN, AOM_TF_HLG);
+  RANGE_CHECK(extra_cfg, chroma_sample_position, AOM_CSP_UNKNOWN,
+              AOM_CSP_COLOCATED);
+#else
   RANGE_CHECK(extra_cfg, color_space, AOM_CS_UNKNOWN, AOM_CS_SRGB);
+#endif
   RANGE_CHECK(extra_cfg, color_range, 0, 1);
 #if CONFIG_ANS && ANS_MAX_SYMBOLS
   RANGE_CHECK(extra_cfg, ans_window_size_log2, 8, 23);
 #endif
   return AOM_CODEC_OK;
 }
 
 static aom_codec_err_t validate_img(aom_codec_alg_priv_t *ctx,
@@ -467,36 +487,33 @@ static aom_codec_err_t set_encoder_confi
 #endif
 
 #if CONFIG_TEMPMV_SIGNALING
   oxcf->disable_tempmv = extra_cfg->disable_tempmv;
 #endif
   oxcf->under_shoot_pct = cfg->rc_undershoot_pct;
   oxcf->over_shoot_pct = cfg->rc_overshoot_pct;
 
-  oxcf->scaled_frame_width = cfg->rc_scaled_width;
-  oxcf->scaled_frame_height = cfg->rc_scaled_height;
-  if (cfg->rc_resize_allowed == 1) {
-    oxcf->resize_mode =
-        (oxcf->scaled_frame_width == 0 || oxcf->scaled_frame_height == 0)
-            ? RESIZE_DYNAMIC
-            : RESIZE_FIXED;
-  } else {
+  oxcf->resize_mode = (RESIZE_MODE)cfg->rc_resize_mode;
+  oxcf->resize_scale_numerator = (uint8_t)cfg->rc_resize_numerator;
+  oxcf->resize_kf_scale_numerator = (uint8_t)cfg->rc_resize_kf_numerator;
+  if (oxcf->resize_mode == RESIZE_FIXED &&
+      oxcf->resize_scale_numerator == SCALE_DENOMINATOR &&
+      oxcf->resize_kf_scale_numerator == SCALE_DENOMINATOR)
     oxcf->resize_mode = RESIZE_NONE;
-  }
-
-  // Initialize to input resolution if not specified.
-  if (oxcf->resize_mode != RESIZE_FIXED) {
-    oxcf->scaled_frame_width = oxcf->width;
-    oxcf->scaled_frame_height = oxcf->height;
-  }
 
 #if CONFIG_FRAME_SUPERRES
-  oxcf->superres_enabled = 1;  // TODO(afergs): Check the config
-#endif                         // CONFIG_FRAME_SUPERRES
+  oxcf->superres_mode = (SUPERRES_MODE)cfg->rc_superres_mode;
+  oxcf->superres_scale_numerator = (uint8_t)cfg->rc_superres_numerator;
+  oxcf->superres_kf_scale_numerator = (uint8_t)cfg->rc_superres_kf_numerator;
+  if (oxcf->superres_mode == SUPERRES_FIXED &&
+      oxcf->superres_scale_numerator == SCALE_DENOMINATOR &&
+      oxcf->superres_kf_scale_numerator == SCALE_DENOMINATOR)
+    oxcf->superres_mode = SUPERRES_NONE;
+#endif  // CONFIG_FRAME_SUPERRES
 
   oxcf->maximum_buffer_size_ms = is_vbr ? 240000 : cfg->rc_buf_sz;
   oxcf->starting_buffer_level_ms = is_vbr ? 60000 : cfg->rc_buf_initial_sz;
   oxcf->optimal_buffer_level_ms = is_vbr ? 60000 : cfg->rc_buf_optimal_sz;
 
   oxcf->drop_frames_water_mark = cfg->rc_dropframe_thresh;
 
   oxcf->two_pass_vbrbias = cfg->rc_2pass_vbr_bias_pct;
@@ -518,16 +535,20 @@ static aom_codec_err_t set_encoder_confi
 
   oxcf->two_pass_stats_in = cfg->rc_twopass_stats_in;
 
 #if CONFIG_FP_MB_STATS
   oxcf->firstpass_mb_stats_in = cfg->rc_firstpass_mb_stats_in;
 #endif
 
   oxcf->color_space = extra_cfg->color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  oxcf->transfer_function = extra_cfg->transfer_function;
+  oxcf->chroma_sample_position = extra_cfg->chroma_sample_position;
+#endif
   oxcf->color_range = extra_cfg->color_range;
   oxcf->render_width = extra_cfg->render_width;
   oxcf->render_height = extra_cfg->render_height;
   oxcf->arnr_max_frames = extra_cfg->arnr_max_frames;
   oxcf->arnr_strength = extra_cfg->arnr_strength;
   oxcf->min_gf_interval = extra_cfg->min_gf_interval;
   oxcf->max_gf_interval = extra_cfg->max_gf_interval;
 
@@ -987,80 +1008,80 @@ static void pick_quickcompress_mode(aom_
 
   if (ctx->oxcf.mode != new_mode) {
     ctx->oxcf.mode = new_mode;
     av1_change_config(ctx->cpi, &ctx->oxcf);
   }
 }
 
 // Turn on to test if supplemental superframe data breaks decoding
-// #define TEST_SUPPLEMENTAL_SUPERFRAME_DATA
+#define TEST_SUPPLEMENTAL_SUPERFRAME_DATA 0
+
 static int write_superframe_index(aom_codec_alg_priv_t *ctx) {
   uint8_t marker = 0xc0;
-  unsigned int mask;
-  int mag, index_sz;
-  int i;
   size_t max_frame_sz = 0;
 
   assert(ctx->pending_frame_count);
   assert(ctx->pending_frame_count <= 8);
 
   // Add the number of frames to the marker byte
   marker |= ctx->pending_frame_count - 1;
-  for (i = 0; i < ctx->pending_frame_count - 1; i++) {
-    const size_t frame_sz = (unsigned int)ctx->pending_frame_sizes[i] - 1;
-    max_frame_sz = frame_sz > max_frame_sz ? frame_sz : max_frame_sz;
+  for (int i = 0; i < ctx->pending_frame_count - 1; i++) {
+    const size_t frame_sz = ctx->pending_frame_sizes[i] - 1;
+    max_frame_sz = AOMMAX(frame_sz, max_frame_sz);
   }
 
   // Choose the magnitude
+  int mag;
+  unsigned int mask;
   for (mag = 0, mask = 0xff; mag < 4; mag++) {
     if (max_frame_sz <= mask) break;
     mask <<= 8;
     mask |= 0xff;
   }
   marker |= mag << 3;
 
   // Write the index
-  index_sz = 2 + (mag + 1) * (ctx->pending_frame_count - 1);
-  if (ctx->pending_cx_data_sz + index_sz < ctx->cx_data_sz) {
-    uint8_t *x = ctx->pending_cx_data + ctx->pending_cx_data_sz;
-#ifdef TEST_SUPPLEMENTAL_SUPERFRAME_DATA
+  uint8_t buffer[256];
+  uint8_t *x = buffer;
+
+  if (TEST_SUPPLEMENTAL_SUPERFRAME_DATA) {
     uint8_t marker_test = 0xc0;
     int mag_test = 2;     // 1 - 4
     int frames_test = 4;  // 1 - 8
-    int index_sz_test = 2 + mag_test * frames_test;
     marker_test |= frames_test - 1;
     marker_test |= (mag_test - 1) << 3;
     *x++ = marker_test;
-    for (i = 0; i < mag_test * frames_test; ++i)
+    for (int i = 0; i < mag_test * frames_test; ++i)
       *x++ = 0;  // fill up with arbitrary data
     *x++ = marker_test;
-    ctx->pending_cx_data_sz += index_sz_test;
     printf("Added supplemental superframe data\n");
-#endif
-
-    *x++ = marker;
-    for (i = 0; i < ctx->pending_frame_count - 1; i++) {
-      unsigned int this_sz;
-      int j;
+  }
 
-      assert(ctx->pending_frame_sizes[i] > 0);
-      this_sz = (unsigned int)ctx->pending_frame_sizes[i] - 1;
-      for (j = 0; j <= mag; j++) {
-        *x++ = this_sz & 0xff;
-        this_sz >>= 8;
-      }
+  *x++ = marker;
+  for (int i = 0; i < ctx->pending_frame_count - 1; i++) {
+    assert(ctx->pending_frame_sizes[i] > 0);
+    unsigned int this_sz = (unsigned int)ctx->pending_frame_sizes[i] - 1;
+    for (int j = 0; j <= mag; j++) {
+      *x++ = this_sz & 0xff;
+      this_sz >>= 8;
     }
-    *x++ = marker;
-    ctx->pending_cx_data_sz += index_sz;
-#ifdef TEST_SUPPLEMENTAL_SUPERFRAME_DATA
-    index_sz += index_sz_test;
-#endif
   }
-  return index_sz;
+  *x++ = marker;
+
+  const size_t index_sz = x - buffer;
+  assert(ctx->pending_cx_data_sz + index_sz < ctx->cx_data_sz);
+
+  // move the frame to make room for the index
+  memmove(ctx->pending_cx_data + index_sz, ctx->pending_cx_data,
+          ctx->pending_cx_data_sz);
+  memcpy(ctx->pending_cx_data, buffer, index_sz);
+  ctx->pending_cx_data_sz += index_sz;
+
+  return (int)index_sz;
 }
 
 // av1 uses 10,000,000 ticks/second as time stamp
 #define TICKS_PER_SEC 10000000LL
 
 static int64_t timebase_units_to_ticks(const aom_rational_t *timebase,
                                        int64_t n) {
   return n * TICKS_PER_SEC * timebase->num / timebase->den;
@@ -1086,53 +1107,54 @@ static aom_codec_frame_flags_t get_frame
 static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx,
                                       const aom_image_t *img,
                                       aom_codec_pts_t pts,
                                       unsigned long duration,
                                       aom_enc_frame_flags_t enc_flags,
                                       unsigned long deadline) {
   const size_t kMinCompressedSize = 8192;
   volatile aom_codec_err_t res = AOM_CODEC_OK;
-  volatile aom_enc_frame_flags_t flags = enc_flags;
   AV1_COMP *const cpi = ctx->cpi;
   const aom_rational_t *const timebase = &ctx->cfg.g_timebase;
-  size_t data_sz;
 
   if (cpi == NULL) return AOM_CODEC_INVALID_PARAM;
 
   if (img != NULL) {
     res = validate_img(ctx, img);
     // TODO(jzern) the checks related to cpi's validity should be treated as a
     // failure condition, encoder setup is done fully in init() currently.
     if (res == AOM_CODEC_OK) {
 #if CONFIG_EXT_REFS
-      data_sz = ALIGN_POWER_OF_TWO(ctx->cfg.g_w, 5) *
-                ALIGN_POWER_OF_TWO(ctx->cfg.g_h, 5) * get_image_bps(img);
+      size_t data_sz = ALIGN_POWER_OF_TWO(ctx->cfg.g_w, 5) *
+                       ALIGN_POWER_OF_TWO(ctx->cfg.g_h, 5) * get_image_bps(img);
 #else
       // There's no codec control for multiple alt-refs so check the encoder
       // instance for its status to determine the compressed data size.
-      data_sz = ALIGN_POWER_OF_TWO(ctx->cfg.g_w, 5) *
-                ALIGN_POWER_OF_TWO(ctx->cfg.g_h, 5) * get_image_bps(img) / 8 *
-                (cpi->multi_arf_allowed ? 8 : 2);
+      size_t data_sz = ALIGN_POWER_OF_TWO(ctx->cfg.g_w, 5) *
+                       ALIGN_POWER_OF_TWO(ctx->cfg.g_h, 5) *
+                       get_image_bps(img) / 8 *
+                       (cpi->multi_arf_allowed ? 8 : 2);
 #endif  // CONFIG_EXT_REFS
       if (data_sz < kMinCompressedSize) data_sz = kMinCompressedSize;
       if (ctx->cx_data == NULL || ctx->cx_data_sz < data_sz) {
         ctx->cx_data_sz = data_sz;
         free(ctx->cx_data);
         ctx->cx_data = (unsigned char *)malloc(ctx->cx_data_sz);
         if (ctx->cx_data == NULL) {
           return AOM_CODEC_MEM_ERROR;
         }
       }
     }
   }
 
   pick_quickcompress_mode(ctx, deadline);
   aom_codec_pkt_list_init(&ctx->pkt_list);
 
+  volatile aom_enc_frame_flags_t flags = enc_flags;
+
   // Handle Flags
   if (((flags & AOM_EFLAG_NO_UPD_GF) && (flags & AOM_EFLAG_FORCE_GF)) ||
       ((flags & AOM_EFLAG_NO_UPD_ARF) && (flags & AOM_EFLAG_FORCE_ARF))) {
     ctx->base.err_detail = "Conflicting flags.";
     return AOM_CODEC_INVALID_PARAM;
   }
 
   if (setjmp(cpi->common.error.jmp)) {
@@ -1150,41 +1172,38 @@ static aom_codec_err_t encoder_encode(ao
       ctx->cfg.kf_min_dist == ctx->cfg.kf_max_dist) {
     if (++ctx->fixed_kf_cntr > ctx->cfg.kf_min_dist) {
       flags |= AOM_EFLAG_FORCE_KF;
       ctx->fixed_kf_cntr = 1;
     }
   }
 
   if (res == AOM_CODEC_OK) {
-    unsigned int lib_flags = 0;
-    YV12_BUFFER_CONFIG sd;
     int64_t dst_time_stamp = timebase_units_to_ticks(timebase, pts);
     int64_t dst_end_time_stamp =
         timebase_units_to_ticks(timebase, pts + duration);
-    size_t size, cx_data_sz;
-    unsigned char *cx_data;
 
     // Set up internal flags
     if (ctx->base.init_flags & AOM_CODEC_USE_PSNR) cpi->b_calculate_psnr = 1;
 
     if (img != NULL) {
+      YV12_BUFFER_CONFIG sd;
       res = image2yuvconfig(img, &sd);
 
       // Store the original flags in to the frame buffer. Will extract the
       // key frame flag when we actually encode this frame.
       if (av1_receive_raw_frame(cpi, flags | ctx->next_frame_flags, &sd,
                                 dst_time_stamp, dst_end_time_stamp)) {
         res = update_error_state(ctx, &cpi->common.error);
       }
       ctx->next_frame_flags = 0;
     }
 
-    cx_data = ctx->cx_data;
-    cx_data_sz = ctx->cx_data_sz;
+    unsigned char *cx_data = ctx->cx_data;
+    size_t cx_data_sz = ctx->cx_data_sz;
 
     /* Any pending invisible frames? */
     if (ctx->pending_cx_data) {
       memmove(cx_data, ctx->pending_cx_data, ctx->pending_cx_data_sz);
       ctx->pending_cx_data = cx_data;
       cx_data += ctx->pending_cx_data_sz;
       cx_data_sz -= ctx->pending_cx_data_sz;
 
@@ -1193,67 +1212,67 @@ static aom_codec_err_t encoder_encode(ao
        */
       if (cx_data_sz < ctx->cx_data_sz / 2) {
         aom_internal_error(&cpi->common.error, AOM_CODEC_ERROR,
                            "Compressed data buffer too small");
         return AOM_CODEC_ERROR;
       }
     }
 
+    size_t frame_size;
+    unsigned int lib_flags = 0;
     while (cx_data_sz >= ctx->cx_data_sz / 2 &&
-           -1 != av1_get_compressed_data(cpi, &lib_flags, &size, cx_data,
+           -1 != av1_get_compressed_data(cpi, &lib_flags, &frame_size, cx_data,
                                          &dst_time_stamp, &dst_end_time_stamp,
                                          !img)) {
 #if CONFIG_REFERENCE_BUFFER
       if (cpi->common.invalid_delta_frame_id_minus1) {
         ctx->base.err_detail = "Invalid delta_frame_id_minus1";
         return AOM_CODEC_ERROR;
       }
 #endif
-      if (size) {
-        aom_codec_cx_pkt_t pkt;
+      if (!frame_size) continue;
+
+      if (ctx->pending_cx_data == 0) ctx->pending_cx_data = cx_data;
+
+      ctx->pending_frame_sizes[ctx->pending_frame_count++] = frame_size;
+      ctx->pending_cx_data_sz += frame_size;
+
+      cx_data += frame_size;
+      cx_data_sz -= frame_size;
 
-        // Pack invisible frames with the next visible frame
-        if (!cpi->common.show_frame) {
-          if (ctx->pending_cx_data == 0) ctx->pending_cx_data = cx_data;
-          ctx->pending_cx_data_sz += size;
-          ctx->pending_frame_sizes[ctx->pending_frame_count++] = size;
-          cx_data += size;
-          cx_data_sz -= size;
+      // invisible frames get packed with the next visible frame
+      if (!cpi->common.show_frame) continue;
 
-          continue;
-        }
-
-        // Add the frame packet to the list of returned packets.
-        pkt.kind = AOM_CODEC_CX_FRAME_PKT;
-        pkt.data.frame.pts = ticks_to_timebase_units(timebase, dst_time_stamp);
-        pkt.data.frame.duration = (unsigned long)ticks_to_timebase_units(
-            timebase, dst_end_time_stamp - dst_time_stamp);
-        pkt.data.frame.flags = get_frame_pkt_flags(cpi, lib_flags);
+      // insert superframe index if needed
+      if (ctx->pending_frame_count > 1) {
+        const size_t index_size = write_superframe_index(ctx);
+        cx_data += index_size;
+        cx_data_sz -= index_size;
+      }
 
-        if (ctx->pending_cx_data) {
-          ctx->pending_frame_sizes[ctx->pending_frame_count++] = size;
-          ctx->pending_cx_data_sz += size;
-          size += write_superframe_index(ctx);
-          pkt.data.frame.buf = ctx->pending_cx_data;
-          pkt.data.frame.sz = ctx->pending_cx_data_sz;
-          ctx->pending_cx_data = NULL;
-          ctx->pending_cx_data_sz = 0;
-          ctx->pending_frame_count = 0;
-        } else {
-          pkt.data.frame.buf = cx_data;
-          pkt.data.frame.sz = size;
-        }
-        pkt.data.frame.partition_id = -1;
+      // Add the frame packet to the list of returned packets.
+      aom_codec_cx_pkt_t pkt;
+
+      pkt.kind = AOM_CODEC_CX_FRAME_PKT;
+
+      pkt.data.frame.buf = ctx->pending_cx_data;
+      pkt.data.frame.sz = ctx->pending_cx_data_sz;
+      pkt.data.frame.partition_id = -1;
 
-        aom_codec_pkt_list_add(&ctx->pkt_list.head, &pkt);
+      pkt.data.frame.pts = ticks_to_timebase_units(timebase, dst_time_stamp);
+      pkt.data.frame.flags = get_frame_pkt_flags(cpi, lib_flags);
+      pkt.data.frame.duration = (uint32_t)ticks_to_timebase_units(
+          timebase, dst_end_time_stamp - dst_time_stamp);
 
-        cx_data += size;
-        cx_data_sz -= size;
-      }
+      aom_codec_pkt_list_add(&ctx->pkt_list.head, &pkt);
+
+      ctx->pending_cx_data = NULL;
+      ctx->pending_cx_data_sz = 0;
+      ctx->pending_frame_count = 0;
     }
   }
 
   cpi->common.error.setjmp = 0;
   return res;
 }
 
 static const aom_codec_cx_pkt_t *encoder_get_cxdata(aom_codec_alg_priv_t *ctx,
@@ -1414,16 +1433,33 @@ static aom_codec_err_t ctrl_set_tune_con
 
 static aom_codec_err_t ctrl_set_color_space(aom_codec_alg_priv_t *ctx,
                                             va_list args) {
   struct av1_extracfg extra_cfg = ctx->extra_cfg;
   extra_cfg.color_space = CAST(AV1E_SET_COLOR_SPACE, args);
   return update_extra_cfg(ctx, &extra_cfg);
 }
 
+#if CONFIG_COLORSPACE_HEADERS
+static aom_codec_err_t ctrl_set_transfer_function(aom_codec_alg_priv_t *ctx,
+                                                  va_list args) {
+  struct av1_extracfg extra_cfg = ctx->extra_cfg;
+  extra_cfg.transfer_function = CAST(AV1E_SET_TRANSFER_FUNCTION, args);
+  return update_extra_cfg(ctx, &extra_cfg);
+}
+
+static aom_codec_err_t ctrl_set_chroma_sample_position(
+    aom_codec_alg_priv_t *ctx, va_list args) {
+  struct av1_extracfg extra_cfg = ctx->extra_cfg;
+  extra_cfg.chroma_sample_position =
+      CAST(AV1E_SET_CHROMA_SAMPLE_POSITION, args);
+  return update_extra_cfg(ctx, &extra_cfg);
+}
+#endif
+
 static aom_codec_err_t ctrl_set_color_range(aom_codec_alg_priv_t *ctx,
                                             va_list args) {
   struct av1_extracfg extra_cfg = ctx->extra_cfg;
   extra_cfg.color_range = CAST(AV1E_SET_COLOR_RANGE, args);
   return update_extra_cfg(ctx, &extra_cfg);
 }
 
 static aom_codec_err_t ctrl_set_render_size(aom_codec_alg_priv_t *ctx,
@@ -1499,16 +1535,20 @@ static aom_codec_ctrl_fn_map_t encoder_c
   { AV1E_SET_FRAME_PARALLEL_DECODING, ctrl_set_frame_parallel_decoding_mode },
   { AV1E_SET_AQ_MODE, ctrl_set_aq_mode },
 #if CONFIG_EXT_DELTA_Q
   { AV1E_SET_DELTAQ_MODE, ctrl_set_deltaq_mode },
 #endif
   { AV1E_SET_FRAME_PERIODIC_BOOST, ctrl_set_frame_periodic_boost },
   { AV1E_SET_TUNE_CONTENT, ctrl_set_tune_content },
   { AV1E_SET_COLOR_SPACE, ctrl_set_color_space },
+#if CONFIG_COLORSPACE_HEADERS
+  { AV1E_SET_TRANSFER_FUNCTION, ctrl_set_transfer_function },
+  { AV1E_SET_CHROMA_SAMPLE_POSITION, ctrl_set_chroma_sample_position },
+#endif
   { AV1E_SET_COLOR_RANGE, ctrl_set_color_range },
   { AV1E_SET_NOISE_SENSITIVITY, ctrl_set_noise_sensitivity },
   { AV1E_SET_MIN_GF_INTERVAL, ctrl_set_min_gf_interval },
   { AV1E_SET_MAX_GF_INTERVAL, ctrl_set_max_gf_interval },
   { AV1E_SET_RENDER_SIZE, ctrl_set_render_size },
   { AV1E_SET_SUPERBLOCK_SIZE, ctrl_set_superblock_size },
 #if CONFIG_ANS && ANS_MAX_SYMBOLS
   { AV1E_SET_ANS_WINDOW_SIZE_LOG2, ctrl_set_ans_window_size_log2 },
@@ -1544,22 +1584,24 @@ static aom_codec_enc_cfg_map_t encoder_u
         { 1, 30 },  // g_timebase
 
         0,  // g_error_resilient
 
         AOM_RC_ONE_PASS,  // g_pass
 
         25,  // g_lag_in_frames
 
-        0,   // rc_dropframe_thresh
-        0,   // rc_resize_allowed
-        0,   // rc_scaled_width
-        0,   // rc_scaled_height
-        60,  // rc_resize_down_thresold
-        30,  // rc_resize_up_thresold
+        0,                  // rc_dropframe_thresh
+        RESIZE_NONE,        // rc_resize_mode
+        SCALE_DENOMINATOR,  // rc_resize_numerator
+        SCALE_DENOMINATOR,  // rc_resize_kf_numerator
+
+        0,                  // rc_superres_mode
+        SCALE_DENOMINATOR,  // rc_superres_numerator
+        SCALE_DENOMINATOR,  // rc_superres_kf_numerator
 
         AOM_VBR,      // rc_end_usage
         { NULL, 0 },  // rc_twopass_stats_in
         { NULL, 0 },  // rc_firstpass_mb_stats_in
         256,          // rc_target_bandwidth
         0,            // rc_min_quantizer
         63,           // rc_max_quantizer
         25,           // rc_undershoot_pct
--- a/third_party/aom/av1/av1_dx_iface.c
+++ b/third_party/aom/av1/av1_dx_iface.c
@@ -149,24 +149,50 @@ static aom_codec_err_t decoder_destroy(a
   aom_free(ctx->buffer_pool);
   aom_free(ctx);
   return AOM_CODEC_OK;
 }
 
 static int parse_bitdepth_colorspace_sampling(BITSTREAM_PROFILE profile,
                                               struct aom_read_bit_buffer *rb) {
   aom_color_space_t color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  int subsampling_x = 0;
+  int subsampling_y = 0;
+#endif
+
   if (profile >= PROFILE_2) rb->bit_offset += 1;  // Bit-depth 10 or 12.
+#if CONFIG_COLORSPACE_HEADERS
+  color_space = (aom_color_space_t)aom_rb_read_literal(rb, 5);
+  rb->bit_offset += 5;  // Transfer function
+#else
   color_space = (aom_color_space_t)aom_rb_read_literal(rb, 3);
+#endif
   if (color_space != AOM_CS_SRGB) {
     rb->bit_offset += 1;  // [16,235] (including xvycc) vs [0,255] range.
+
     if (profile == PROFILE_1 || profile == PROFILE_3) {
+#if CONFIG_COLORSPACE_HEADERS
+      subsampling_x = aom_rb_read_bit(rb);
+      subsampling_y = aom_rb_read_bit(rb);
+#else
       rb->bit_offset += 2;  // subsampling x/y.
+#endif
       rb->bit_offset += 1;  // unused.
+#if CONFIG_COLORSPACE_HEADERS
+    } else {
+      subsampling_x = 1;
+      subsampling_y = 1;
     }
+    if (subsampling_x == 1 && subsampling_y == 1) {
+      rb->bit_offset += 2;
+    }
+#else
+    }
+#endif
   } else {
     if (profile == PROFILE_1 || profile == PROFILE_3) {
       rb->bit_offset += 1;  // unused
     } else {
       // RGB is only available in version 1.
       return 0;
     }
   }
@@ -412,16 +438,18 @@ static aom_codec_err_t init_decoder(aom_
       return AOM_CODEC_MEM_ERROR;
     }
 
     if (pthread_cond_init(&frame_worker_data->stats_cond, NULL)) {
       set_error_detail(ctx, "Failed to allocate frame_worker_data cond");
       return AOM_CODEC_MEM_ERROR;
     }
 #endif
+    frame_worker_data->pbi->allow_lowbitdepth = ctx->cfg.allow_lowbitdepth;
+
     // If decoding in serial mode, FrameWorker thread could create tile worker
     // thread or loopfilter thread.
     frame_worker_data->pbi->max_threads =
         (ctx->frame_parallel_decode == 0) ? ctx->cfg.threads : 0;
 
     frame_worker_data->pbi->inv_tile_order = ctx->invert_tile_order;
     frame_worker_data->pbi->common.frame_parallel_decode =
         ctx->frame_parallel_decode;
@@ -592,20 +620,24 @@ static aom_codec_err_t decoder_decode(ao
   ctx->flushed = 0;
 
   // Initialize the decoder workers on the first frame.
   if (ctx->frame_workers == NULL) {
     res = init_decoder(ctx);
     if (res != AOM_CODEC_OK) return res;
   }
 
+  int index_size = 0;
   res = av1_parse_superframe_index(data, data_sz, frame_sizes, &frame_count,
-                                   ctx->decrypt_cb, ctx->decrypt_state);
+                                   &index_size, ctx->decrypt_cb,
+                                   ctx->decrypt_state);
   if (res != AOM_CODEC_OK) return res;
 
+  data_start += index_size;
+
   if (ctx->frame_parallel_decode) {
     // Decode in frame parallel mode. When decoding in this mode, the frame
     // passed to the decoder must be either a normal frame or a superframe with
     // superframe index so the decoder could get each frame's start position
     // in the superframe.
     if (frame_count > 0) {
       int i;
 
--- a/third_party/aom/av1/av1_iface_common.h
+++ b/third_party/aom/av1/av1_iface_common.h
@@ -33,16 +33,20 @@ static void yuvconfig2image(aom_image_t 
       img->fmt = AOM_IMG_FMT_I440;
       bps = 16;
     } else {
       img->fmt = AOM_IMG_FMT_I420;
       bps = 12;
     }
   }
   img->cs = yv12->color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  img->tf = yv12->transfer_function;
+  img->csp = yv12->chroma_sample_position;
+#endif
   img->range = yv12->color_range;
   img->bit_depth = 8;
   img->w = yv12->y_stride;
   img->h = ALIGN_POWER_OF_TWO(yv12->y_height + 2 * AOM_BORDER_IN_PIXELS, 3);
   img->d_w = yv12->y_crop_width;
   img->d_h = yv12->y_crop_height;
   img->r_w = yv12->render_width;
   img->r_h = yv12->render_height;
@@ -97,16 +101,20 @@ static aom_codec_err_t image2yuvconfig(c
   yv12->uv_height =
       img->y_chroma_shift == 1 ? (1 + yv12->y_height) / 2 : yv12->y_height;
   yv12->uv_crop_width = yv12->uv_width;
   yv12->uv_crop_height = yv12->uv_height;
 
   yv12->y_stride = img->stride[AOM_PLANE_Y];
   yv12->uv_stride = img->stride[AOM_PLANE_U];
   yv12->color_space = img->cs;
+#if CONFIG_COLORSPACE_HEADERS
+  yv12->transfer_function = img->tf;
+  yv12->chroma_sample_position = img->csp;
+#endif
   yv12->color_range = img->range;
 
 #if CONFIG_HIGHBITDEPTH
   if (img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) {
     // In aom_image_t
     //     planes point to uint8 address of start of data
     //     stride counts uint8s to reach next row
     // In YV12_BUFFER_CONFIG
--- a/third_party/aom/av1/common/alloccommon.c
+++ b/third_party/aom/av1/common/alloccommon.c
@@ -88,21 +88,28 @@ void av1_free_ref_frame_buffers(BufferPo
     aom_free_frame_buffer(&pool->frame_bufs[i].buf);
   }
 }
 
 #if CONFIG_LOOP_RESTORATION
 // Assumes cm->rst_info[p].restoration_tilesize is already initialized
 void av1_alloc_restoration_buffers(AV1_COMMON *cm) {
   int p;
-  av1_alloc_restoration_struct(cm, &cm->rst_info[0], cm->width, cm->height);
+#if CONFIG_FRAME_SUPERRES
+  int width = cm->superres_upscaled_width;
+  int height = cm->superres_upscaled_height;
+#else
+  int width = cm->width;
+  int height = cm->height;
+#endif  // CONFIG_FRAME_SUPERRES
+  av1_alloc_restoration_struct(cm, &cm->rst_info[0], width, height);
   for (p = 1; p < MAX_MB_PLANE; ++p)
-    av1_alloc_restoration_struct(
-        cm, &cm->rst_info[p], ROUND_POWER_OF_TWO(cm->width, cm->subsampling_x),
-        ROUND_POWER_OF_TWO(cm->height, cm->subsampling_y));
+    av1_alloc_restoration_struct(cm, &cm->rst_info[p],
+                                 ROUND_POWER_OF_TWO(width, cm->subsampling_x),
+                                 ROUND_POWER_OF_TWO(height, cm->subsampling_y));
   aom_free(cm->rst_internal.tmpbuf);
   CHECK_MEM_ERROR(cm, cm->rst_internal.tmpbuf,
                   (int32_t *)aom_memalign(16, RESTORATION_TMPBUF_SIZE));
 }
 
 void av1_free_restoration_buffers(AV1_COMMON *cm) {
   int p;
   for (p = 0; p < MAX_MB_PLANE; ++p)
--- a/third_party/aom/av1/common/arm/neon/iht4x4_add_neon.c
+++ b/third_party/aom/av1/common/arm/neon/iht4x4_add_neon.c
@@ -11,16 +11,17 @@
 
 #include <arm_neon.h>
 #include <assert.h>
 
 #include "./aom_config.h"
 #include "./av1_rtcd.h"
 #include "aom_dsp/txfm_common.h"
 #include "av1/common/common.h"
+#include "av1/common/idct.h"
 
 static INLINE void TRANSPOSE4X4(int16x8_t *q8s16, int16x8_t *q9s16) {
   int32x4_t q8s32, q9s32;
   int16x4x2_t d0x2s16, d1x2s16;
   int32x4x2_t q0x2s32;
 
   d0x2s16 = vtrn_s16(vget_low_s16(*q8s16), vget_high_s16(*q8s16));
   d1x2s16 = vtrn_s16(vget_low_s16(*q9s16), vget_high_s16(*q9s16));
@@ -129,33 +130,34 @@ static INLINE void IADST4x4_1D(int16x4_t
   d19s16 = vqrshrn_n_s32(q10s32, 14);
 
   *q8s16 = vcombine_s16(d16s16, d17s16);
   *q9s16 = vcombine_s16(d18s16, d19s16);
   return;
 }
 
 void av1_iht4x4_16_add_neon(const tran_low_t *input, uint8_t *dest,
-                            int dest_stride, int tx_type) {
+                            int dest_stride, const INV_TXFM_PARAM *param) {
   uint8x8_t d26u8, d27u8;
   int16x4_t d0s16, d1s16, d2s16, d3s16, d4s16, d5s16;
   uint32x2_t d26u32, d27u32;
   int16x8_t q3s16, q8s16, q9s16;
   uint16x8_t q8u16, q9u16;
 
   d26u32 = d27u32 = vdup_n_u32(0);
 
   q8s16 = vld1q_s16(input);
   q9s16 = vld1q_s16(input + 8);
 
   TRANSPOSE4X4(&q8s16, &q9s16);
 
+  int tx_type = param->tx_type;
   switch (tx_type) {
     case 0:  // idct_idct is not supported. Fall back to C
-      av1_iht4x4_16_add_c(input, dest, dest_stride, tx_type);
+      av1_iht4x4_16_add_c(input, dest, dest_stride, param);
       return;
       break;
     case 1:  // iadst_idct
       // generate constants
       GENERATE_COSINE_CONSTANTS(&d0s16, &d1s16, &d2s16);
       GENERATE_SINE_CONSTANTS(&d3s16, &d4s16, &d5s16, &q3s16);
 
       // first transform rows
--- a/third_party/aom/av1/common/arm/neon/iht8x8_add_neon.c
+++ b/third_party/aom/av1/common/arm/neon/iht8x8_add_neon.c
@@ -11,16 +11,17 @@
 
 #include <arm_neon.h>
 #include <assert.h>
 
 #include "./aom_config.h"
 #include "./av1_rtcd.h"
 #include "aom_dsp/txfm_common.h"
 #include "av1/common/common.h"
+#include "av1/common/idct.h"
 
 static INLINE void TRANSPOSE8X8(int16x8_t *q8s16, int16x8_t *q9s16,
                                 int16x8_t *q10s16, int16x8_t *q11s16,
                                 int16x8_t *q12s16, int16x8_t *q13s16,
                                 int16x8_t *q14s16, int16x8_t *q15s16) {
   int16x4_t d16s16, d17s16, d18s16, d19s16, d20s16, d21s16, d22s16, d23s16;
   int16x4_t d24s16, d25s16, d26s16, d27s16, d28s16, d29s16, d30s16, d31s16;
   int32x4x2_t q0x2s32, q1x2s32, q2x2s32, q3x2s32;
@@ -453,17 +454,17 @@ static INLINE void IADST8X8_1D(int16x8_t
   *q9s16 = vsubq_s16(q5s16, *q9s16);
   *q11s16 = vsubq_s16(q5s16, q2s16);
   *q13s16 = vsubq_s16(q5s16, q6s16);
   *q15s16 = vsubq_s16(q5s16, q4s16);
   return;
 }
 
 void av1_iht8x8_64_add_neon(const tran_low_t *input, uint8_t *dest,
-                            int dest_stride, int tx_type) {
+                            int dest_stride, const INV_TXFM_PARAM *param) {
   int i;
   uint8_t *d1, *d2;
   uint8x8_t d0u8, d1u8, d2u8, d3u8;
   uint64x1_t d0u64, d1u64, d2u64, d3u64;
   int16x8_t q8s16, q9s16, q10s16, q11s16, q12s16, q13s16, q14s16, q15s16;
   uint16x8_t q8u16, q9u16, q10u16, q11u16;
 
   q8s16 = vld1q_s16(input);
@@ -473,19 +474,20 @@ void av1_iht8x8_64_add_neon(const tran_l
   q12s16 = vld1q_s16(input + 8 * 4);
   q13s16 = vld1q_s16(input + 8 * 5);
   q14s16 = vld1q_s16(input + 8 * 6);
   q15s16 = vld1q_s16(input + 8 * 7);
 
   TRANSPOSE8X8(&q8s16, &q9s16, &q10s16, &q11s16, &q12s16, &q13s16, &q14s16,
                &q15s16);
 
+  int tx_type = param->tx_type;
   switch (tx_type) {
     case 0:  // idct_idct is not supported. Fall back to C
-      av1_iht8x8_64_add_c(input, dest, dest_stride, tx_type);
+      av1_iht8x8_64_add_c(input, dest, dest_stride, param);
       return;
       break;
     case 1:  // iadst_idct
       // generate IDCT constants
       // GENERATE_IDCT_CONSTANTS
 
       // first transform rows
       IDCT8x8_1D(&q8s16, &q9s16, &q10s16, &q11s16, &q12s16, &q13s16, &q14s16,
--- a/third_party/aom/av1/common/av1_fwd_txfm1d_cfg.h
+++ b/third_party/aom/av1/common/av1_fwd_txfm1d_cfg.h
@@ -8,28 +8,28 @@
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #ifndef AV1_FWD_TXFM2D_CFG_H_
 #define AV1_FWD_TXFM2D_CFG_H_
 #include "av1/common/enums.h"
 #include "av1/common/av1_fwd_txfm1d.h"
-// Identity will always use max bitdepth regardless of size
-static const int8_t fwd_stage_range_identity[1] = { 12 };
 
 //  ---------------- 4x4 1D constants -----------------------
 // shift
 static const int8_t fwd_shift_4[3] = { 2, 0, 0 };
 
 // stage range
 static const int8_t fwd_stage_range_col_dct_4[4] = { 15, 16, 17, 17 };
 static const int8_t fwd_stage_range_row_dct_4[4] = { 17, 18, 18, 18 };
 static const int8_t fwd_stage_range_col_adst_4[6] = { 15, 15, 16, 17, 17, 17 };
 static const int8_t fwd_stage_range_row_adst_4[6] = { 17, 17, 17, 18, 18, 18 };
+static const int8_t fwd_stage_range_idx_4[1] = { 18 };
+
 // cos bit
 static const int8_t fwd_cos_bit_col_dct_4[4] = { 13, 13, 13, 13 };
 static const int8_t fwd_cos_bit_row_dct_4[4] = { 13, 13, 13, 13 };
 static const int8_t fwd_cos_bit_col_adst_4[6] = { 13, 13, 13, 13, 13, 13 };
 static const int8_t fwd_cos_bit_row_adst_4[6] = { 13, 13, 13, 13, 13, 13 };
 
 //  ---------------- 8x8 1D constants -----------------------
 // shift
@@ -37,16 +37,17 @@ static const int8_t fwd_shift_8[3] = { 2
 
 // stage range
 static const int8_t fwd_stage_range_col_dct_8[6] = { 15, 16, 17, 18, 18, 18 };
 static const int8_t fwd_stage_range_row_dct_8[6] = { 17, 18, 19, 19, 19, 19 };
 static const int8_t fwd_stage_range_col_adst_8[8] = { 15, 15, 16, 17,
                                                       17, 18, 18, 18 };
 static const int8_t fwd_stage_range_row_adst_8[8] = { 17, 17, 17, 18,
                                                       18, 19, 19, 19 };
+static const int8_t fwd_stage_range_idx_8[1] = { 19 };
 
 // cos bit
 static const int8_t fwd_cos_bit_col_dct_8[6] = { 13, 13, 13, 13, 13, 13 };
 static const int8_t fwd_cos_bit_row_dct_8[6] = { 13, 13, 13, 13, 13, 13 };
 static const int8_t fwd_cos_bit_col_adst_8[8] = {
   13, 13, 13, 13, 13, 13, 13, 13
 };
 static const int8_t fwd_cos_bit_row_adst_8[8] = {
@@ -61,16 +62,17 @@ static const int8_t fwd_shift_16[3] = { 
 static const int8_t fwd_stage_range_col_dct_16[8] = { 15, 16, 17, 18,
                                                       19, 19, 19, 19 };
 static const int8_t fwd_stage_range_row_dct_16[8] = { 17, 18, 19, 20,
                                                       20, 20, 20, 20 };
 static const int8_t fwd_stage_range_col_adst_16[10] = { 15, 15, 16, 17, 17,
                                                         18, 18, 19, 19, 19 };
 static const int8_t fwd_stage_range_row_adst_16[10] = { 17, 17, 17, 18, 18,
                                                         19, 19, 20, 20, 20 };
+static const int8_t fwd_stage_range_idx_16[1] = { 20 };
 
 // cos bit
 static const int8_t fwd_cos_bit_col_dct_16[8] = {
   13, 13, 13, 13, 13, 13, 13, 13
 };
 static const int8_t fwd_cos_bit_row_dct_16[8] = {
   12, 12, 12, 12, 12, 12, 12, 12
 };
@@ -89,16 +91,17 @@ static const int8_t fwd_stage_range_col_
 static const int8_t fwd_stage_range_row_dct_32[10] = { 16, 17, 18, 19, 20,
                                                        20, 20, 20, 20, 20 };
 static const int8_t fwd_stage_range_col_adst_32[12] = {
   15, 15, 16, 17, 17, 18, 18, 19, 19, 20, 20, 20
 };
 static const int8_t fwd_stage_range_row_adst_32[12] = {
   16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 20
 };
+static const int8_t fwd_stage_range_idx_32[1] = { 20 };
 
 // cos bit
 static const int8_t fwd_cos_bit_col_dct_32[10] = { 12, 12, 12, 12, 12,
                                                    12, 12, 12, 12, 12 };
 static const int8_t fwd_cos_bit_row_dct_32[10] = { 12, 12, 12, 12, 12,
                                                    12, 12, 12, 12, 12 };
 static const int8_t fwd_cos_bit_col_adst_32[12] = { 12, 12, 12, 12, 12, 12,
                                                     12, 12, 12, 12, 12, 12 };
@@ -109,16 +112,17 @@ static const int8_t fwd_cos_bit_row_adst
 // shift
 static const int8_t fwd_shift_64[3] = { 0, -2, -2 };
 
 // stage range
 static const int8_t fwd_stage_range_col_dct_64[12] = { 13, 14, 15, 16, 17, 18,
                                                        19, 19, 19, 19, 19, 19 };
 static const int8_t fwd_stage_range_row_dct_64[12] = { 17, 18, 19, 20, 21, 22,
                                                        22, 22, 22, 22, 22, 22 };
+static const int8_t fwd_stage_range_idx_64[1] = { 22 };
 
 // cos bit
 static const int8_t fwd_cos_bit_col_dct_64[12] = { 15, 15, 15, 15, 15, 14,
                                                    13, 13, 13, 13, 13, 13 };
 static const int8_t fwd_cos_bit_row_dct_64[12] = { 15, 14, 13, 12, 11, 10,
                                                    10, 10, 10, 10, 10, 10 };
 
 //  ---------------- row config fwd_dct_4 ----------------
@@ -317,48 +321,48 @@ static const TXFM_1D_CFG fwd_txfm_1d_col
 
 #if CONFIG_EXT_TX
 // identity does not need to differentiate between row and col
 //  ---------------- row/col config fwd_identity_4 ----------
 static const TXFM_1D_CFG fwd_txfm_1d_cfg_identity_4 = {
   4,  // .txfm_size
   1,  // .stage_num
   // 0,  // .log_scale
-  fwd_shift_4,               // .shift
-  fwd_stage_range_identity,  // .stage_range
-  NULL,                      // .cos_bit
-  TXFM_TYPE_IDENTITY4,       // .txfm_type
+  fwd_shift_4,            // .shift
+  fwd_stage_range_idx_4,  // .stage_range
+  NULL,                   // .cos_bit
+  TXFM_TYPE_IDENTITY4,    // .txfm_type
 };
 
 //  ---------------- row/col config fwd_identity_8 ----------------
 static const TXFM_1D_CFG fwd_txfm_1d_cfg_identity_8 = {
   8,  // .txfm_size
   1,  // .stage_num
   // 0,  // .log_scale
-  fwd_shift_8,               // .shift
-  fwd_stage_range_identity,  // .stage_range
-  NULL,                      // .cos_bit
-  TXFM_TYPE_IDENTITY8,       // .txfm_type
+  fwd_shift_8,            // .shift
+  fwd_stage_range_idx_8,  // .stage_range
+  NULL,                   // .cos_bit
+  TXFM_TYPE_IDENTITY8,    // .txfm_type
 };
 
 //  ---------------- row/col config fwd_identity_16 ----------------
 static const TXFM_1D_CFG fwd_txfm_1d_cfg_identity_16 = {
   16,  // .txfm_size
   1,   // .stage_num
   // 0,  // .log_scale
-  fwd_shift_16,              // .shift
-  fwd_stage_range_identity,  // .stage_range
-  NULL,                      // .cos_bit
-  TXFM_TYPE_IDENTITY16,      // .txfm_type
+  fwd_shift_16,            // .shift
+  fwd_stage_range_idx_16,  // .stage_range
+  NULL,                    // .cos_bit
+  TXFM_TYPE_IDENTITY16,    // .txfm_type
 };
 
 //  ---------------- row/col config fwd_identity_32 ----------------
 static const TXFM_1D_CFG fwd_txfm_1d_cfg_identity_32 = {
   32,  // .txfm_size
   1,   // .stage_num
   // 1,  // .log_scale
-  fwd_shift_32,              // .shift
-  fwd_stage_range_identity,  // .stage_range
-  NULL,                      // .cos_bit
-  TXFM_TYPE_IDENTITY32,      // .txfm_type
+  fwd_shift_32,            // .shift
+  fwd_stage_range_idx_32,  // .stage_range
+  NULL,                    // .cos_bit
+  TXFM_TYPE_IDENTITY32,    // .txfm_type
 };
 #endif  // CONFIG_EXT_TX
 #endif  // AV1_FWD_TXFM2D_CFG_H_
--- a/third_party/aom/av1/common/av1_fwd_txfm2d.c
+++ b/third_party/aom/av1/common/av1_fwd_txfm2d.c
@@ -7,16 +7,17 @@
  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #include <assert.h>
 
 #include "./av1_rtcd.h"
+#include "aom_dsp/txfm_common.h"
 #include "av1/common/enums.h"
 #include "av1/common/av1_fwd_txfm1d.h"
 #include "av1/common/av1_fwd_txfm1d_cfg.h"
 #include "av1/common/av1_txfm.h"
 
 static INLINE TxfmFunc fwd_txfm_type_to_func(TXFM_TYPE txfm_type) {
   switch (txfm_type) {
     case TXFM_TYPE_DCT4: return av1_fdct4_new;
@@ -36,59 +37,129 @@ static INLINE TxfmFunc fwd_txfm_type_to_
     default: assert(0); return NULL;
   }
 }
 
 static INLINE void fwd_txfm2d_c(const int16_t *input, int32_t *output,
                                 const int stride, const TXFM_2D_FLIP_CFG *cfg,
                                 int32_t *buf) {
   int c, r;
-  // TODO(sarahparker) must correct for rectangular transforms in follow up
-  const int txfm_size = cfg->row_cfg->txfm_size;
-  const int8_t *shift = cfg->row_cfg->shift;
+  // Note when assigning txfm_size_col, we use the txfm_size from the
+  // row configuration and vice versa. This is intentionally done to
+  // accurately perform rectangular transforms. When the transform is
+  // rectangular, the number of columns will be the same as the
+  // txfm_size stored in the row cfg struct. It will make no difference
+  // for square transforms.
+  const int txfm_size_col = cfg->row_cfg->txfm_size;
+  const int txfm_size_row = cfg->col_cfg->txfm_size;
+  // Take the shift from the larger dimension in the rectangular case.
+  const int8_t *shift = (txfm_size_col > txfm_size_row) ? cfg->row_cfg->shift
+                                                        : cfg->col_cfg->shift;
   const int8_t *stage_range_col = cfg->col_cfg->stage_range;
   const int8_t *stage_range_row = cfg->row_cfg->stage_range;
   const int8_t *cos_bit_col = cfg->col_cfg->cos_bit;
   const int8_t *cos_bit_row = cfg->row_cfg->cos_bit;
   const TxfmFunc txfm_func_col = fwd_txfm_type_to_func(cfg->col_cfg->txfm_type);
   const TxfmFunc txfm_func_row = fwd_txfm_type_to_func(cfg->row_cfg->txfm_type);
 
   // use output buffer as temp buffer
   int32_t *temp_in = output;
-  int32_t *temp_out = output + txfm_size;
+  int32_t *temp_out = output + txfm_size_row;
 
   // Columns
-  for (c = 0; c < txfm_size; ++c) {
+  for (c = 0; c < txfm_size_col; ++c) {
     if (cfg->ud_flip == 0) {
-      for (r = 0; r < txfm_size; ++r) temp_in[r] = input[r * stride + c];
+      for (r = 0; r < txfm_size_row; ++r) temp_in[r] = input[r * stride + c];
     } else {
-      for (r = 0; r < txfm_size; ++r)
+      for (r = 0; r < txfm_size_row; ++r)
         // flip upside down
-        temp_in[r] = input[(txfm_size - r - 1) * stride + c];
+        temp_in[r] = input[(txfm_size_row - r - 1) * stride + c];
     }
-    round_shift_array(temp_in, txfm_size, -shift[0]);
+    round_shift_array(temp_in, txfm_size_row, -shift[0]);
+    // Multiply everything by Sqrt2 on the larger dimension if the
+    // transform is rectangular
+    if (txfm_size_col > txfm_size_row) {
+      for (r = 0; r < txfm_size_row; ++r)
+        temp_in[r] = (int32_t)fdct_round_shift(temp_in[r] * Sqrt2);
+    }
     txfm_func_col(temp_in, temp_out, cos_bit_col, stage_range_col);
-    round_shift_array(temp_out, txfm_size, -shift[1]);
+    round_shift_array(temp_out, txfm_size_row, -shift[1]);
     if (cfg->lr_flip == 0) {
-      for (r = 0; r < txfm_size; ++r) buf[r * txfm_size + c] = temp_out[r];
+      for (r = 0; r < txfm_size_row; ++r)
+        buf[r * txfm_size_col + c] = temp_out[r];
     } else {
-      for (r = 0; r < txfm_size; ++r)
+      for (r = 0; r < txfm_size_row; ++r)
         // flip from left to right
-        buf[r * txfm_size + (txfm_size - c - 1)] = temp_out[r];
+        buf[r * txfm_size_col + (txfm_size_col - c - 1)] = temp_out[r];
     }
   }
 
   // Rows
-  for (r = 0; r < txfm_size; ++r) {
-    txfm_func_row(buf + r * txfm_size, output + r * txfm_size, cos_bit_row,
-                  stage_range_row);
-    round_shift_array(output + r * txfm_size, txfm_size, -shift[2]);
+  for (r = 0; r < txfm_size_row; ++r) {
+    // Multiply everything by Sqrt2 on the larger dimension if the
+    // transform is rectangular
+    if (txfm_size_row > txfm_size_col) {
+      for (c = 0; c < txfm_size_col; ++c)
+        buf[r * txfm_size_col + c] =
+            (int32_t)fdct_round_shift(buf[r * txfm_size_col + c] * Sqrt2);
+    }
+    txfm_func_row(buf + r * txfm_size_col, output + r * txfm_size_col,
+                  cos_bit_row, stage_range_row);
+    round_shift_array(output + r * txfm_size_col, txfm_size_col, -shift[2]);
   }
 }
 
+void av1_fwd_txfm2d_4x8_c(const int16_t *input, int32_t *output, int stride,
+                          int tx_type, int bd) {
+  int32_t txfm_buf[4 * 8];
+  TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_cfg(tx_type, TX_4X8);
+  (void)bd;
+  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf);
+}
+
+void av1_fwd_txfm2d_8x4_c(const int16_t *input, int32_t *output, int stride,
+                          int tx_type, int bd) {
+  int32_t txfm_buf[8 * 4];
+  TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_cfg(tx_type, TX_8X4);
+  (void)bd;
+  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf);
+}
+
+void av1_fwd_txfm2d_8x16_c(const int16_t *input, int32_t *output, int stride,
+                           int tx_type, int bd) {
+  int32_t txfm_buf[8 * 16];
+  TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_cfg(tx_type, TX_8X16);
+  (void)bd;
+  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf);
+}
+
+void av1_fwd_txfm2d_16x8_c(const int16_t *input, int32_t *output, int stride,
+                           int tx_type, int bd) {
+  int32_t txfm_buf[16 * 8];
+  TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_cfg(tx_type, TX_16X8);
+  (void)bd;
+  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf);
+}
+
+void av1_fwd_txfm2d_16x32_c(const int16_t *input, int32_t *output, int stride,
+                            int tx_type, int bd) {
+  int32_t txfm_buf[16 * 32];
+  TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_cfg(tx_type, TX_16X32);
+  (void)bd;
+  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf);
+}
+
+void av1_fwd_txfm2d_32x16_c(const int16_t *input, int32_t *output, int stride,
+                            int tx_type, int bd) {
+  int32_t txfm_buf[32 * 16];
+  TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_cfg(tx_type, TX_32X16);
+  (void)bd;
+  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf);
+}
+
 void av1_fwd_txfm2d_4x4_c(const int16_t *input, int32_t *output, int stride,
                           int tx_type, int bd) {
   int32_t txfm_buf[4 * 4];
   TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_cfg(tx_type, TX_4X4);
   (void)bd;
   fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf);
 }
 
@@ -188,20 +259,22 @@ static const TXFM_1D_CFG *fwd_txfm_row_c
       &fwd_txfm_1d_cfg_identity_4, &fwd_txfm_1d_cfg_identity_8,
       &fwd_txfm_1d_cfg_identity_16, &fwd_txfm_1d_cfg_identity_32 },
 #endif  // CONFIG_EXT_TX
 };
 
 TXFM_2D_FLIP_CFG av1_get_fwd_txfm_cfg(int tx_type, int tx_size) {
   TXFM_2D_FLIP_CFG cfg;
   set_flip_cfg(tx_type, &cfg);
-  int tx_type_col = vtx_tab[tx_type];
-  int tx_type_row = htx_tab[tx_type];
-  cfg.col_cfg = fwd_txfm_col_cfg_ls[tx_type_col][tx_size];
-  cfg.row_cfg = fwd_txfm_row_cfg_ls[tx_type_row][tx_size];
+  const int tx_type_col = vtx_tab[tx_type];
+  const int tx_type_row = htx_tab[tx_type];
+  const int tx_size_col = txsize_vert_map[tx_size];
+  const int tx_size_row = txsize_horz_map[tx_size];
+  cfg.col_cfg = fwd_txfm_col_cfg_ls[tx_type_col][tx_size_col];
+  cfg.row_cfg = fwd_txfm_row_cfg_ls[tx_type_row][tx_size_row];
   return cfg;
 }
 
 TXFM_2D_FLIP_CFG av1_get_fwd_txfm_64x64_cfg(int tx_type) {
   TXFM_2D_FLIP_CFG cfg;
   switch (tx_type) {
     case DCT_DCT:
       cfg.col_cfg = &fwd_txfm_1d_col_cfg_dct_64;
--- a/third_party/aom/av1/common/av1_inv_txfm1d_cfg.h
+++ b/third_party/aom/av1/common/av1_inv_txfm1d_cfg.h
@@ -7,28 +7,28 @@
  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #ifndef AV1_INV_TXFM2D_CFG_H_
 #define AV1_INV_TXFM2D_CFG_H_
 #include "av1/common/av1_inv_txfm1d.h"
-// Identity will always use max bitdepth regardless of size
-static const int8_t inv_stage_range_identity[1] = { 12 };
 
 //  ---------------- 4x4 1D config -----------------------
 // shift
 static const int8_t inv_shift_4[2] = { 0, -4 };
 
 // stage range
 static const int8_t inv_stage_range_col_dct_4[4] = { 18, 18, 17, 17 };
 static const int8_t inv_stage_range_row_dct_4[4] = { 18, 18, 18, 18 };
 static const int8_t inv_stage_range_col_adst_4[6] = { 18, 18, 18, 18, 17, 17 };
 static const int8_t inv_stage_range_row_adst_4[6] = { 18, 18, 18, 18, 18, 18 };
+static const int8_t inv_stage_range_idx_4[1] = { 18 };
+
 // cos bit
 static const int8_t inv_cos_bit_col_dct_4[4] = { 13, 13, 13, 13 };
 static const int8_t inv_cos_bit_row_dct_4[4] = { 13, 13, 13, 13 };
 static const int8_t inv_cos_bit_col_adst_4[6] = { 13, 13, 13, 13, 13, 13 };
 static const int8_t inv_cos_bit_row_adst_4[6] = { 13, 13, 13, 13, 13, 13 };
 
 //  ---------------- 8x8 1D constants -----------------------
 // shift
@@ -36,16 +36,18 @@ static const int8_t inv_shift_8[2] = { 0
 
 // stage range
 static const int8_t inv_stage_range_col_dct_8[6] = { 19, 19, 19, 19, 18, 18 };
 static const int8_t inv_stage_range_row_dct_8[6] = { 19, 19, 19, 19, 19, 19 };
 static const int8_t inv_stage_range_col_adst_8[8] = { 19, 19, 19, 19,
                                                       19, 19, 18, 18 };
 static const int8_t inv_stage_range_row_adst_8[8] = { 19, 19, 19, 19,
                                                       19, 19, 19, 19 };
+static const int8_t inv_stage_range_idx_8[1] = { 19 };
+
 // cos bit
 static const int8_t inv_cos_bit_col_dct_8[6] = { 13, 13, 13, 13, 13, 13 };
 static const int8_t inv_cos_bit_row_dct_8[6] = { 13, 13, 13, 13, 13, 13 };
 static const int8_t inv_cos_bit_col_adst_8[8] = {
   13, 13, 13, 13, 13, 13, 13, 13
 };
 static const int8_t inv_cos_bit_row_adst_8[8] = {
   13, 13, 13, 13, 13, 13, 13, 13
@@ -59,16 +61,17 @@ static const int8_t inv_shift_16[2] = { 
 static const int8_t inv_stage_range_col_dct_16[8] = { 19, 19, 19, 19,
                                                       19, 19, 18, 18 };
 static const int8_t inv_stage_range_row_dct_16[8] = { 20, 20, 20, 20,
                                                       20, 20, 20, 20 };
 static const int8_t inv_stage_range_col_adst_16[10] = { 19, 19, 19, 19, 19,
                                                         19, 19, 19, 18, 18 };
 static const int8_t inv_stage_range_row_adst_16[10] = { 20, 20, 20, 20, 20,
                                                         20, 20, 20, 20, 20 };
+static const int8_t inv_stage_range_idx_16[1] = { 20 };
 
 // cos bit
 static const int8_t inv_cos_bit_col_dct_16[8] = {
   13, 13, 13, 13, 13, 13, 13, 13
 };
 static const int8_t inv_cos_bit_row_dct_16[8] = {
   12, 12, 12, 12, 12, 12, 12, 12
 };
@@ -87,16 +90,17 @@ static const int8_t inv_stage_range_col_
 static const int8_t inv_stage_range_row_dct_32[10] = { 20, 20, 20, 20, 20,
                                                        20, 20, 20, 20, 20 };
 static const int8_t inv_stage_range_col_adst_32[12] = {
   19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18
 };
 static const int8_t inv_stage_range_row_adst_32[12] = {
   20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20
 };
+static const int8_t inv_stage_range_idx_32[1] = { 20 };
 
 // cos bit
 static const int8_t inv_cos_bit_col_dct_32[10] = { 13, 13, 13, 13, 13,
                                                    13, 13, 13, 13, 13 };
 static const int8_t inv_cos_bit_row_dct_32[10] = { 12, 12, 12, 12, 12,
                                                    12, 12, 12, 12, 12 };
 static const int8_t inv_cos_bit_col_adst_32[12] = { 13, 13, 13, 13, 13, 13,
                                                     13, 13, 13, 13, 13, 13 };
@@ -107,16 +111,17 @@ static const int8_t inv_cos_bit_row_adst
 // shift
 static const int8_t inv_shift_64[2] = { -1, -7 };
 
 // stage range
 static const int8_t inv_stage_range_col_dct_64[12] = { 19, 19, 19, 19, 19, 19,
                                                        19, 19, 19, 19, 18, 18 };
 static const int8_t inv_stage_range_row_dct_64[12] = { 20, 20, 20, 20, 20, 20,
                                                        20, 20, 20, 20, 20, 20 };
+static const int8_t inv_stage_range_idx_64[1] = { 20 };
 
 // cos bit
 static const int8_t inv_cos_bit_col_dct_64[12] = { 13, 13, 13, 13, 13, 13,
                                                    13, 13, 13, 13, 13, 13 };
 static const int8_t inv_cos_bit_row_dct_64[12] = { 12, 12, 12, 12, 12, 12,
                                                    12, 12, 12, 12, 12, 12 };
 
 //  ---------------- row config inv_dct_4 ----------------
@@ -315,48 +320,48 @@ static const TXFM_1D_CFG inv_txfm_1d_col
 
 #if CONFIG_EXT_TX
 // identity does not need to differentiate between row and col
 //  ---------------- row/col config inv_identity_4 ----------
 static const TXFM_1D_CFG inv_txfm_1d_cfg_identity_4 = {
   4,  // .txfm_size
   1,  // .stage_num
   // 0,  // .log_scale
-  inv_shift_4,               // .shift
-  inv_stage_range_identity,  // .stage_range
-  NULL,                      // .cos_bit
-  TXFM_TYPE_IDENTITY4,       // .txfm_type
+  inv_shift_4,            // .shift
+  inv_stage_range_idx_4,  // .stage_range
+  NULL,                   // .cos_bit
+  TXFM_TYPE_IDENTITY4,    // .txfm_type
 };
 
 //  ---------------- row/col config inv_identity_8 ----------------
 static const TXFM_1D_CFG inv_txfm_1d_cfg_identity_8 = {
   8,  // .txfm_size
   1,  // .stage_num
   // 0,  // .log_scale
-  inv_shift_8,               // .shift
-  inv_stage_range_identity,  // .stage_range
-  NULL,                      // .cos_bit
-  TXFM_TYPE_IDENTITY8,       // .txfm_type
+  inv_shift_8,            // .shift
+  inv_stage_range_idx_8,  // .stage_range
+  NULL,                   // .cos_bit
+  TXFM_TYPE_IDENTITY8,    // .txfm_type
 };
 
 //  ---------------- row/col config inv_identity_16 ----------------
 static const TXFM_1D_CFG inv_txfm_1d_cfg_identity_16 = {
   16,  // .txfm_size
   1,   // .stage_num
   // 0,  // .log_scale
-  inv_shift_16,              // .shift
-  inv_stage_range_identity,  // .stage_range
-  NULL,                      // .cos_bit
-  TXFM_TYPE_IDENTITY16,      // .txfm_type
+  inv_shift_16,            // .shift
+  inv_stage_range_idx_16,  // .stage_range
+  NULL,                    // .cos_bit
+  TXFM_TYPE_IDENTITY16,    // .txfm_type
 };
 
 //  ---------------- row/col config inv_identity_32 ----------------
 static const TXFM_1D_CFG inv_txfm_1d_cfg_identity_32 = {
   32,  // .txfm_size
   1,   // .stage_num
   // 1,  // .log_scale
-  inv_shift_32,              // .shift
-  inv_stage_range_identity,  // .stage_range
-  NULL,                      // .cos_bit
-  TXFM_TYPE_IDENTITY32,      // .txfm_type
+  inv_shift_32,            // .shift
+  inv_stage_range_idx_32,  // .stage_range
+  NULL,                    // .cos_bit
+  TXFM_TYPE_IDENTITY32,    // .txfm_type
 };
 #endif  // CONFIG_EXT_TX
 #endif  // AV1_INV_TXFM2D_CFG_H_
--- a/third_party/aom/av1/common/av1_inv_txfm2d.c
+++ b/third_party/aom/av1/common/av1_inv_txfm2d.c
@@ -5,16 +5,17 @@
  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
  * was not distributed with this source code in the LICENSE file, you can
  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #include "./av1_rtcd.h"
+#include "aom_dsp/inv_txfm.h"
 #include "av1/common/enums.h"
 #include "av1/common/av1_txfm.h"
 #include "av1/common/av1_inv_txfm1d.h"
 #include "av1/common/av1_inv_txfm1d_cfg.h"
 
 static INLINE TxfmFunc inv_txfm_type_to_func(TXFM_TYPE txfm_type) {
   switch (txfm_type) {
     case TXFM_TYPE_DCT4: return av1_idct4_new;
@@ -99,102 +100,148 @@ static const TXFM_1D_CFG *inv_txfm_row_c
       &inv_txfm_1d_cfg_identity_4, &inv_txfm_1d_cfg_identity_8,
       &inv_txfm_1d_cfg_identity_16, &inv_txfm_1d_cfg_identity_32 },
 #endif  // CONFIG_EXT_TX
 };
 
 TXFM_2D_FLIP_CFG av1_get_inv_txfm_cfg(int tx_type, int tx_size) {
   TXFM_2D_FLIP_CFG cfg;
   set_flip_cfg(tx_type, &cfg);
-  int tx_type_col = vtx_tab[tx_type];
-  int tx_type_row = htx_tab[tx_type];
-  // TODO(sarahparker) this is currently only implemented for
-  // square transforms
-  cfg.col_cfg = inv_txfm_col_cfg_ls[tx_type_col][tx_size];
-  cfg.row_cfg = inv_txfm_row_cfg_ls[tx_type_row][tx_size];
+  const int tx_type_col = vtx_tab[tx_type];
+  const int tx_type_row = htx_tab[tx_type];
+  const int tx_size_col = txsize_vert_map[tx_size];
+  const int tx_size_row = txsize_horz_map[tx_size];
+  cfg.col_cfg = inv_txfm_col_cfg_ls[tx_type_col][tx_size_col];
+  cfg.row_cfg = inv_txfm_row_cfg_ls[tx_type_row][tx_size_row];
   return cfg;
 }
 
 TXFM_2D_FLIP_CFG av1_get_inv_txfm_64x64_cfg(int tx_type) {
   TXFM_2D_FLIP_CFG cfg = { 0, 0, NULL, NULL };
   switch (tx_type) {
     case DCT_DCT:
       cfg.col_cfg = &inv_txfm_1d_col_cfg_dct_64;
       cfg.row_cfg = &inv_txfm_1d_row_cfg_dct_64;
       set_flip_cfg(tx_type, &cfg);
       break;
     default: assert(0);
   }
   return cfg;
 }
 
-static INLINE void inv_txfm2d_add_c(const int32_t *input, int16_t *output,
+static INLINE void inv_txfm2d_add_c(const int32_t *input, uint16_t *output,
                                     int stride, TXFM_2D_FLIP_CFG *cfg,
-                                    int32_t *txfm_buf) {
-  // TODO(sarahparker) must correct for rectangular transforms in follow up
-  const int txfm_size = cfg->row_cfg->txfm_size;
-  const int8_t *shift = cfg->row_cfg->shift;
+                                    int32_t *txfm_buf, int bd) {
+  // Note when assigning txfm_size_col, we use the txfm_size from the
+  // row configuration and vice versa. This is intentionally done to
+  // accurately perform rectangular transforms. When the transform is
+  // rectangular, the number of columns will be the same as the
+  // txfm_size stored in the row cfg struct. It will make no difference
+  // for square transforms.
+  const int txfm_size_col = cfg->row_cfg->txfm_size;
+  const int txfm_size_row = cfg->col_cfg->txfm_size;
+  // Take the shift from the larger dimension in the rectangular case.
+  const int8_t *shift = (txfm_size_col > txfm_size_row) ? cfg->row_cfg->shift
+                                                        : cfg->col_cfg->shift;
   const int8_t *stage_range_col = cfg->col_cfg->stage_range;
   const int8_t *stage_range_row = cfg->row_cfg->stage_range;
   const int8_t *cos_bit_col = cfg->col_cfg->cos_bit;
   const int8_t *cos_bit_row = cfg->row_cfg->cos_bit;
   const TxfmFunc txfm_func_col = inv_txfm_type_to_func(cfg->col_cfg->txfm_type);
   const TxfmFunc txfm_func_row = inv_txfm_type_to_func(cfg->row_cfg->txfm_type);
 
-  // txfm_buf's length is  txfm_size * txfm_size + 2 * txfm_size
+  // txfm_buf's length is  txfm_size_row * txfm_size_col + 2 * txfm_size_row
   // it is used for intermediate data buffering
   int32_t *temp_in = txfm_buf;
-  int32_t *temp_out = temp_in + txfm_size;
-  int32_t *buf = temp_out + txfm_size;
+  int32_t *temp_out = temp_in + txfm_size_row;
+  int32_t *buf = temp_out + txfm_size_row;
   int32_t *buf_ptr = buf;
   int c, r;
 
   // Rows
-  for (r = 0; r < txfm_size; ++r) {
+  for (r = 0; r < txfm_size_row; ++r) {
     txfm_func_row(input, buf_ptr, cos_bit_row, stage_range_row);
-    round_shift_array(buf_ptr, txfm_size, -shift[0]);
-    input += txfm_size;
-    buf_ptr += txfm_size;
+    round_shift_array(buf_ptr, txfm_size_col, -shift[0]);
+    // Multiply everything by Sqrt2 if the transform is rectangular
+    if (txfm_size_row != txfm_size_col) {
+      for (c = 0; c < txfm_size_col; ++c)
+        buf_ptr[c] = (int32_t)dct_const_round_shift(buf_ptr[c] * Sqrt2);
+    }
+    input += txfm_size_col;
+    buf_ptr += txfm_size_col;
   }
 
   // Columns
-  for (c = 0; c < txfm_size; ++c) {
+  for (c = 0; c < txfm_size_col; ++c) {
     if (cfg->lr_flip == 0) {
-      for (r = 0; r < txfm_size; ++r) temp_in[r] = buf[r * txfm_size + c];
+      for (r = 0; r < txfm_size_row; ++r)
+        temp_in[r] = buf[r * txfm_size_col + c];
     } else {
       // flip left right
-      for (r = 0; r < txfm_size; ++r)
-        temp_in[r] = buf[r * txfm_size + (txfm_size - c - 1)];
+      for (r = 0; r < txfm_size_row; ++r)
+        temp_in[r] = buf[r * txfm_size_col + (txfm_size_col - c - 1)];
     }
     txfm_func_col(temp_in, temp_out, cos_bit_col, stage_range_col);
-    round_shift_array(temp_out, txfm_size, -shift[1]);
+    round_shift_array(temp_out, txfm_size_row, -shift[1]);
     if (cfg->ud_flip == 0) {
-      for (r = 0; r < txfm_size; ++r) output[r * stride + c] += temp_out[r];
+      for (r = 0; r < txfm_size_row; ++r) {
+        output[r * stride + c] =
+            highbd_clip_pixel_add(output[r * stride + c], temp_out[r], bd);
+      }
     } else {
       // flip upside down
-      for (r = 0; r < txfm_size; ++r)
-        output[r * stride + c] += temp_out[txfm_size - r - 1];
+      for (r = 0; r < txfm_size_row; ++r) {
+        output[r * stride + c] = highbd_clip_pixel_add(
+            output[r * stride + c], temp_out[txfm_size_row - r - 1], bd);
+      }
     }
   }
 }
 
 static INLINE void inv_txfm2d_add_facade(const int32_t *input, uint16_t *output,
                                          int stride, int32_t *txfm_buf,
                                          int tx_type, int tx_size, int bd) {
-  // output contains the prediction signal which is always positive and smaller
-  // than (1 << bd) - 1
-  // since bd < 16-1, therefore we can treat the uint16_t* output buffer as an
-  // int16_t*
   TXFM_2D_FLIP_CFG cfg = av1_get_inv_txfm_cfg(tx_type, tx_size);
-  inv_txfm2d_add_c(input, (int16_t *)output, stride, &cfg, txfm_buf);
-  // TODO(sarahparker) just using the cfg_row->txfm_size for now because
-  // we are assumint this is only used for square transforms. This will
-  // be adjusted in a follow up
-  clamp_block((int16_t *)output, cfg.row_cfg->txfm_size, stride, 0,
-              (1 << bd) - 1);
+  inv_txfm2d_add_c(input, output, stride, &cfg, txfm_buf, bd);
+}
+
+void av1_inv_txfm2d_add_4x8_c(const int32_t *input, uint16_t *output,
+                              int stride, int tx_type, int bd) {
+  int txfm_buf[4 * 8 + 8 + 8];
+  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_4X8, bd);
+}
+
+void av1_inv_txfm2d_add_8x4_c(const int32_t *input, uint16_t *output,
+                              int stride, int tx_type, int bd) {
+  int txfm_buf[8 * 4 + 4 + 4];
+  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_8X4, bd);
+}
+
+void av1_inv_txfm2d_add_8x16_c(const int32_t *input, uint16_t *output,
+                               int stride, int tx_type, int bd) {
+  int txfm_buf[8 * 16 + 16 + 16];
+  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_8X16, bd);
+}
+
+void av1_inv_txfm2d_add_16x8_c(const int32_t *input, uint16_t *output,
+                               int stride, int tx_type, int bd) {
+  int txfm_buf[16 * 8 + 8 + 8];
+  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_16X8, bd);
+}
+
+void av1_inv_txfm2d_add_16x32_c(const int32_t *input, uint16_t *output,
+                                int stride, int tx_type, int bd) {
+  int txfm_buf[16 * 32 + 32 + 32];
+  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_16X32, bd);
+}
+
+void av1_inv_txfm2d_add_32x16_c(const int32_t *input, uint16_t *output,
+                                int stride, int tx_type, int bd) {
+  int txfm_buf[32 * 16 + 16 + 16];
+  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_32X16, bd);
 }
 
 void av1_inv_txfm2d_add_4x4_c(const int32_t *input, uint16_t *output,
                               int stride, int tx_type, int bd) {
   int txfm_buf[4 * 4 + 4 + 4];
   inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_4X4, bd);
 }
 
@@ -214,16 +261,11 @@ void av1_inv_txfm2d_add_32x32_c(const in
                                 int stride, int tx_type, int bd) {
   int txfm_buf[32 * 32 + 32 + 32];
   inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_32X32, bd);
 }
 
 void av1_inv_txfm2d_add_64x64_c(const int32_t *input, uint16_t *output,
                                 int stride, int tx_type, int bd) {
   int txfm_buf[64 * 64 + 64 + 64];
-  // output contains the prediction signal which is always positive and smaller
-  // than (1 << bd) - 1
-  // since bd < 16-1, therefore we can treat the uint16_t* output buffer as an
-  // int16_t*
   TXFM_2D_FLIP_CFG cfg = av1_get_inv_txfm_64x64_cfg(tx_type);
-  inv_txfm2d_add_c(input, (int16_t *)output, stride, &cfg, txfm_buf);
-  clamp_block((int16_t *)output, 64, stride, 0, (1 << bd) - 1);
+  inv_txfm2d_add_c(input, output, stride, &cfg, txfm_buf, bd);
 }
--- a/third_party/aom/av1/common/av1_loopfilter.c
+++ b/third_party/aom/av1/common/av1_loopfilter.c
@@ -95,17 +95,17 @@ static const uint64_t above_64x64_txform
 //  10000000
 //  10000000
 //  10000000
 //  00000000
 //  00000000
 //  00000000
 //  00000000
 static const uint64_t left_prediction_mask[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   0x0000000000000001ULL,  // BLOCK_2X2,
   0x0000000000000001ULL,  // BLOCK_2X4,
   0x0000000000000001ULL,  // BLOCK_4X2,
 #endif
   0x0000000000000001ULL,  // BLOCK_4X4,
   0x0000000000000001ULL,  // BLOCK_4X8,
   0x0000000000000001ULL,  // BLOCK_8X4,
   0x0000000000000001ULL,  // BLOCK_8X8,
@@ -117,17 +117,17 @@ static const uint64_t left_prediction_ma
   0x0000000001010101ULL,  // BLOCK_32X32,
   0x0101010101010101ULL,  // BLOCK_32X64,
   0x0000000001010101ULL,  // BLOCK_64X32,
   0x0101010101010101ULL,  // BLOCK_64X64
 };
 
 // 64 bit mask to shift and set for each prediction size.
 static const uint64_t above_prediction_mask[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   0x0000000000000001ULL,  // BLOCK_2X2
   0x0000000000000001ULL,  // BLOCK_2X4
   0x0000000000000001ULL,  // BLOCK_4X2
 #endif
   0x0000000000000001ULL,  // BLOCK_4X4
   0x0000000000000001ULL,  // BLOCK_4X8
   0x0000000000000001ULL,  // BLOCK_8X4
   0x0000000000000001ULL,  // BLOCK_8X8
@@ -140,17 +140,17 @@ static const uint64_t above_prediction_m
   0x000000000000000fULL,  // BLOCK_32X64,
   0x00000000000000ffULL,  // BLOCK_64X32,
   0x00000000000000ffULL,  // BLOCK_64X64
 };
 // 64 bit mask to shift and set for each prediction size. A bit is set for
 // each 8x8 block that would be in the left most block of the given block
 // size in the 64x64 block.
 static const uint64_t size_mask[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   0x0000000000000001ULL,  // BLOCK_2X2
   0x0000000000000001ULL,  // BLOCK_2X4
   0x0000000000000001ULL,  // BLOCK_4X2
 #endif
   0x0000000000000001ULL,  // BLOCK_4X4
   0x0000000000000001ULL,  // BLOCK_4X8
   0x0000000000000001ULL,  // BLOCK_8X4
   0x0000000000000001ULL,  // BLOCK_8X8
@@ -193,17 +193,17 @@ static const uint16_t above_64x64_txform
   0x000f,  // TX_32x32
 #if CONFIG_TX64X64
   0x0003,  // TX_64x64, never used
 #endif     // CONFIG_TX64X64
 };
 
 // 16 bit left mask to shift and set for each uv prediction size.
 static const uint16_t left_prediction_mask_uv[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   0x0001,  // BLOCK_2X2,
   0x0001,  // BLOCK_2X4,
   0x0001,  // BLOCK_4X2,
 #endif
   0x0001,  // BLOCK_4X4,
   0x0001,  // BLOCK_4X8,
   0x0001,  // BLOCK_8X4,
   0x0001,  // BLOCK_8X8,
@@ -214,17 +214,17 @@ static const uint16_t left_prediction_ma
   0x0001,  // BLOCK_32X16,
   0x0011,  // BLOCK_32X32,
   0x1111,  // BLOCK_32X64
   0x0011,  // BLOCK_64X32,
   0x1111,  // BLOCK_64X64
 };
 // 16 bit above mask to shift and set for uv each prediction size.
 static const uint16_t above_prediction_mask_uv[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   0x0001,  // BLOCK_2X2
   0x0001,  // BLOCK_2X4
   0x0001,  // BLOCK_4X2
 #endif
   0x0001,  // BLOCK_4X4
   0x0001,  // BLOCK_4X8
   0x0001,  // BLOCK_8X4
   0x0001,  // BLOCK_8X8
@@ -236,17 +236,17 @@ static const uint16_t above_prediction_m
   0x0003,  // BLOCK_32X32,
   0x0003,  // BLOCK_32X64,
   0x000f,  // BLOCK_64X32,
   0x000f,  // BLOCK_64X64
 };
 
 // 64 bit mask to shift and set for each uv prediction size
 static const uint16_t size_mask_uv[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   0x0001,  // BLOCK_2X2
   0x0001,  // BLOCK_2X4
   0x0001,  // BLOCK_4X2
 #endif
   0x0001,  // BLOCK_4X4
   0x0001,  // BLOCK_4X8
   0x0001,  // BLOCK_8X4
   0x0001,  // BLOCK_8X8
@@ -268,16 +268,21 @@ static const int mode_lf_lut[] = {
 #if CONFIG_ALT_INTRA
   0,
 #if CONFIG_SMOOTH_HV
   0, 0,
 #endif         // CONFIG_SMOOTH_HV
 #endif         // CONFIG_ALT_INTRA
   1, 1, 0, 1,  // INTER_MODES (ZEROMV == 0)
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+  // 1, 1, 1, 1, 1,       // INTER_SINGLEREF_COMP_MODES
+  // NOTE(zoeliu): Remove SR_NEAREST_NEWMV
+  1, 1, 1, 1,             // INTER_SINGLEREF_COMP_MODES
+#endif                    // CONFIG_COMPOUND_SINGLEREF
   1, 1, 1, 1, 1, 1, 0, 1  // INTER_COMPOUND_MODES (ZERO_ZEROMV == 0)
 #endif                    // CONFIG_EXT_INTER
 };
 
 static void update_sharpness(loop_filter_info_n *lfi, int sharpness_lvl) {
   int lvl;
 
   // For each possible value for the loop filter fill out limits
@@ -1415,128 +1420,162 @@ static void get_filter_level_and_masks_n
     const int col_mask = 1 << c_step;
 
 #if CONFIG_VAR_TX
     if (is_inter_block(mbmi) && !mbmi->skip) {
       const int tx_row_idx =
           (blk_row * mi_size_high[BLOCK_8X8] << TX_UNIT_HIGH_LOG2) >> 1;
       const int tx_col_idx =
           (blk_col * mi_size_wide[BLOCK_8X8] << TX_UNIT_WIDE_LOG2) >> 1;
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
       const BLOCK_SIZE bsize =
           AOMMAX(BLOCK_4X4, get_plane_block_size(mbmi->sb_type, plane));
+#else
+      const BLOCK_SIZE bsize = get_plane_block_size(mbmi->sb_type, plane);
+#endif
       const TX_SIZE mb_tx_size = mbmi->inter_tx_size[tx_row_idx][tx_col_idx];
       tx_size = (plane->plane_type == PLANE_TYPE_UV)
                     ? uv_txsize_lookup[bsize][mb_tx_size][0][0]
                     : mb_tx_size;
     }
 #endif
 
 // Filter level can vary per MI
 #if CONFIG_EXT_DELTA_Q
     if (!(lfl_r[c_step] = get_filter_level(cm, &cm->lf_info, mbmi))) continue;
 #else
     if (!(lfl_r[c_step] = get_filter_level(&cm->lf_info, mbmi))) continue;
 #endif
 
 #if CONFIG_VAR_TX
-    TX_SIZE tx_size_r, tx_size_c;
+    TX_SIZE tx_size_horz_edge, tx_size_vert_edge;
 
-    const int tx_wide =
-        AOMMIN(tx_size_wide[tx_size],
-               tx_size_wide[cm->top_txfm_context[pl][(mi_col + idx_c)
-                                                     << TX_UNIT_WIDE_LOG2]]);
-    const int tx_high = AOMMIN(
-        tx_size_high[tx_size],
-        tx_size_high[cm->left_txfm_context[pl][((mi_row + idx_r) & MAX_MIB_MASK)
+    // filt_len_vert_edge is the length of deblocking filter for a vertical edge
+    // The filter direction of a vertical edge is horizontal.
+    // Thus, filt_len_vert_edge is determined as the minimum width of the two
+    // transform block sizes on the left and right (current block) side of edge
+    const int filt_len_vert_edge = AOMMIN(
+        tx_size_wide[tx_size],
+        tx_size_wide[cm->left_txfm_context[pl][((mi_row + idx_r) & MAX_MIB_MASK)
                                                << TX_UNIT_HIGH_LOG2]]);
 
-    tx_size_c = get_sqr_tx_size(tx_wide);
-    tx_size_r = get_sqr_tx_size(tx_high);
+    // filt_len_horz_edge is the len of deblocking filter for a horizontal edge
+    // The filter direction of a horizontal edge is vertical.
+    // Thus, filt_len_horz_edge is determined as the minimum height of the two
+    // transform block sizes on the top and bottom (current block) side of edge
+    const int filt_len_horz_edge =
+        AOMMIN(tx_size_high[tx_size],
+               tx_size_high[cm->top_txfm_context[pl][(mi_col + idx_c)
+                                                     << TX_UNIT_WIDE_LOG2]]);
+
+    // transform width/height of current block
+    const int tx_wide_cur = tx_size_wide[tx_size];
+    const int tx_high_cur = tx_size_high[tx_size];
+
+    // tx_size_vert_edge is square transform size for a vertical deblocking edge
+    // It determines the type of filter applied to the vertical edge
+    // Similarly, tx_size_horz_edge is for a horizontal deblocking edge
+    tx_size_vert_edge = get_sqr_tx_size(filt_len_vert_edge);
+    tx_size_horz_edge = get_sqr_tx_size(filt_len_horz_edge);
 
     memset(cm->top_txfm_context[pl] + ((mi_col + idx_c) << TX_UNIT_WIDE_LOG2),
            tx_size, mi_size_wide[BLOCK_8X8] << TX_UNIT_WIDE_LOG2);
     memset(cm->left_txfm_context[pl] +
                (((mi_row + idx_r) & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2),
            tx_size, mi_size_high[BLOCK_8X8] << TX_UNIT_HIGH_LOG2);
 #else
-    TX_SIZE tx_size_c = txsize_horz_map[tx_size];
-    TX_SIZE tx_size_r = txsize_vert_map[tx_size];
+    // The length (or equally the square tx size) of deblocking filter is only
+    // determined by
+    // a) current block's width for a vertical deblocking edge
+    // b) current block's height for a horizontal deblocking edge
+    TX_SIZE tx_size_vert_edge = txsize_horz_map[tx_size];
+    TX_SIZE tx_size_horz_edge = txsize_vert_map[tx_size];
     (void)pl;
 #endif  // CONFIG_VAR_TX
 
-    if (tx_size_c == TX_32X32)
+    if (tx_size_vert_edge == TX_32X32)
       tx_size_mask = 3;
-    else if (tx_size_c == TX_16X16)
+    else if (tx_size_vert_edge == TX_16X16)
       tx_size_mask = 1;
     else
       tx_size_mask = 0;
 
     // Build masks based on the transform size of each block
     // handle vertical mask
-    if (tx_size_c == TX_32X32) {
+    if (tx_size_vert_edge == TX_32X32) {
       if (!skip_this_c && (c_step & tx_size_mask) == 0) {
         if (!skip_border_4x4_c)
           col_masks.m16x16 |= col_mask;
         else
           col_masks.m8x8 |= col_mask;
       }
-    } else if (tx_size_c == TX_16X16) {
+    } else if (tx_size_vert_edge == TX_16X16) {
       if (!skip_this_c && (c_step & tx_size_mask) == 0) {
         if (!skip_border_4x4_c)
           col_masks.m16x16 |= col_mask;
         else
           col_masks.m8x8 |= col_mask;
       }
     } else {
       // force 8x8 filtering on 32x32 boundaries
       if (!skip_this_c && (c_step & tx_size_mask) == 0) {
-        if (tx_size_c == TX_8X8 || ((c >> ss_x) & 3) == 0)
+        if (tx_size_vert_edge == TX_8X8 || (c_step & 3) == 0)
           col_masks.m8x8 |= col_mask;
         else
           col_masks.m4x4 |= col_mask;
       }
 
-      if (!skip_this && tx_size_c < TX_8X8 && !skip_border_4x4_c &&
+#if CONFIG_VAR_TX
+      if (!skip_this && tx_wide_cur < 8 && !skip_border_4x4_c &&
           (c_step & tx_size_mask) == 0)
+#else
+      if (!skip_this && tx_size_vert_edge < TX_8X8 && !skip_border_4x4_c &&
+          (c_step & tx_size_mask) == 0)
+#endif  // CONFIG_VAR_TX
         mask_4x4_int_c |= col_mask;
     }
 
-    if (tx_size_r == TX_32X32)
+    if (tx_size_horz_edge == TX_32X32)
       tx_size_mask = 3;
-    else if (tx_size_r == TX_16X16)
+    else if (tx_size_horz_edge == TX_16X16)
       tx_size_mask = 1;
     else
       tx_size_mask = 0;
 
     // set horizontal mask
-    if (tx_size_r == TX_32X32) {
+    if (tx_size_horz_edge == TX_32X32) {
       if (!skip_this_r && (r_step & tx_size_mask) == 0) {
         if (!skip_border_4x4_r)
           row_masks.m16x16 |= col_mask;
         else
           row_masks.m8x8 |= col_mask;
       }
-    } else if (tx_size_r == TX_16X16) {
+    } else if (tx_size_horz_edge == TX_16X16) {
       if (!skip_this_r && (r_step & tx_size_mask) == 0) {
         if (!skip_border_4x4_r)
           row_masks.m16x16 |= col_mask;
         else
           row_masks.m8x8 |= col_mask;
       }
     } else {
       // force 8x8 filtering on 32x32 boundaries
       if (!skip_this_r && (r_step & tx_size_mask) == 0) {
-        if (tx_size_r == TX_8X8 || (r_step & 3) == 0)
+        if (tx_size_horz_edge == TX_8X8 || (r_step & 3) == 0)
           row_masks.m8x8 |= col_mask;
         else
           row_masks.m4x4 |= col_mask;
       }
 
-      if (!skip_this && tx_size_r < TX_8X8 && !skip_border_4x4_r &&
-          ((r >> ss_y) & tx_size_mask) == 0)
+#if CONFIG_VAR_TX
+      if (!skip_this && tx_high_cur < 8 && !skip_border_4x4_r &&
+          (r_step & tx_size_mask) == 0)
+#else
+      if (!skip_this && tx_size_horz_edge < TX_8X8 && !skip_border_4x4_r &&
+          (r_step & tx_size_mask) == 0)
+#endif  // CONFIG_VAR_TX
         mask_4x4_int_r |= col_mask;
     }
   }
 
   if (row_masks_ptr) *row_masks_ptr = row_masks;
   if (col_masks_ptr) *col_masks_ptr = col_masks;
   if (mask_4x4_int_c_ptr) *mask_4x4_int_c_ptr = mask_4x4_int_c;
   if (mask_4x4_int_r_ptr) *mask_4x4_int_r_ptr = mask_4x4_int_r;
@@ -1560,18 +1599,19 @@ void av1_filter_block_plane_non420_ver(A
     const int r = idx_r >> mi_height_log2_lookup[BLOCK_8X8];
     get_filter_level_and_masks_non420(cm, plane, pl, mib, mi_row, mi_col, idx_r,
                                       &lfl[r][0], NULL, &mask_4x4_int, NULL,
                                       &col_masks);
 
     // Disable filtering on the leftmost column or tile boundary
     unsigned int border_mask = ~(mi_col == 0);
 #if CONFIG_LOOPFILTERING_ACROSS_TILES
+    MODE_INFO *const mi = cm->mi + (mi_row + idx_r) * cm->mi_stride + mi_col;
     if (av1_disable_loopfilter_on_tile_boundary(cm) &&
-        ((mib[0]->mbmi.boundary_info & TILE_LEFT_BOUNDARY) != 0)) {
+        ((mi->mbmi.boundary_info & TILE_LEFT_BOUNDARY) != 0)) {
       border_mask = 0xfffffffe;
     }
 #endif  // CONFIG_LOOPFILTERING_ACROSS_TILES
 
 #if CONFIG_HIGHBITDEPTH
     if (cm->use_highbitdepth)
       highbd_filter_selectively_vert(
           CONVERT_TO_SHORTPTR(dst->buf), dst->stride,
@@ -1594,56 +1634,49 @@ void av1_filter_block_plane_non420_ver(A
 void av1_filter_block_plane_non420_hor(AV1_COMMON *const cm,
                                        struct macroblockd_plane *plane,
                                        MODE_INFO **mib, int mi_row, int mi_col,
                                        int pl) {
   const int ss_y = plane->subsampling_y;
   const int row_step = mi_size_high[BLOCK_8X8] << ss_y;
   struct buf_2d *const dst = &plane->dst;
   uint8_t *const dst0 = dst->buf;
-  FilterMasks row_masks_array[MAX_MIB_SIZE];
-  unsigned int mask_4x4_int[MAX_MIB_SIZE] = { 0 };
   uint8_t lfl[MAX_MIB_SIZE][MAX_MIB_SIZE] = { { 0 } };
+
   int idx_r;
   for (idx_r = 0; idx_r < cm->mib_size && mi_row + idx_r < cm->mi_rows;
        idx_r += row_step) {
+    unsigned int mask_4x4_int;
+    FilterMasks row_masks;
     const int r = idx_r >> mi_height_log2_lookup[BLOCK_8X8];
     get_filter_level_and_masks_non420(cm, plane, pl, mib, mi_row, mi_col, idx_r,
-                                      &lfl[r][0], mask_4x4_int + r, NULL,
-                                      row_masks_array + r, NULL);
-  }
-  for (idx_r = 0; idx_r < cm->mib_size && mi_row + idx_r < cm->mi_rows;
-       idx_r += row_step) {
-    const int r = idx_r >> mi_width_log2_lookup[BLOCK_8X8];
-    FilterMasks row_masks;
+                                      &lfl[r][0], &mask_4x4_int, NULL,
+                                      &row_masks, NULL);
 
 #if CONFIG_LOOPFILTERING_ACROSS_TILES
     // Disable filtering on the abovemost row or tile boundary
-    const MODE_INFO *mi = cm->mi + (mi_row + r) * cm->mi_stride;
+    const MODE_INFO *mi = cm->mi + (mi_row + idx_r) * cm->mi_stride + mi_col;
     if ((av1_disable_loopfilter_on_tile_boundary(cm) &&
          (mi->mbmi.boundary_info & TILE_ABOVE_BOUNDARY)) ||
-        (mi_row + idx_r == 0)) {
+        (mi_row + idx_r == 0))
       memset(&row_masks, 0, sizeof(row_masks));
 #else
-    if (mi_row + idx_r == 0) {
-      memset(&row_masks, 0, sizeof(row_masks));
+    if (mi_row + idx_r == 0) memset(&row_masks, 0, sizeof(row_masks));
 #endif  // CONFIG_LOOPFILTERING_ACROSS_TILES
-    } else {
-      memcpy(&row_masks, row_masks_array + r, sizeof(row_masks));
-    }
+
 #if CONFIG_HIGHBITDEPTH
     if (cm->use_highbitdepth)
       highbd_filter_selectively_horiz(
           CONVERT_TO_SHORTPTR(dst->buf), dst->stride, row_masks.m16x16,
-          row_masks.m8x8, row_masks.m4x4, mask_4x4_int[r], &cm->lf_info,
+          row_masks.m8x8, row_masks.m4x4, mask_4x4_int, &cm->lf_info,
           &lfl[r][0], (int)cm->bit_depth);
     else
 #endif  // CONFIG_HIGHBITDEPTH
       filter_selectively_horiz(dst->buf, dst->stride, row_masks.m16x16,
-                               row_masks.m8x8, row_masks.m4x4, mask_4x4_int[r],
+                               row_masks.m8x8, row_masks.m4x4, mask_4x4_int,
                                &cm->lf_info, &lfl[r][0]);
     dst->buf += 8 * dst->stride;
   }
   dst->buf = dst0;
 }
 
 void av1_filter_block_plane_ss00_ver(AV1_COMMON *const cm,
                                      struct macroblockd_plane *const plane,
@@ -1857,21 +1890,21 @@ void av1_filter_block_plane_ss11_hor(AV1
   dst->buf = dst0;
 }
 
 #if CONFIG_PARALLEL_DEBLOCKING
 typedef enum EDGE_DIR { VERT_EDGE = 0, HORZ_EDGE = 1, NUM_EDGE_DIRS } EDGE_DIR;
 static const uint32_t av1_prediction_masks[NUM_EDGE_DIRS][BLOCK_SIZES] = {
   // mask for vertical edges filtering
   {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
       2 - 1,   // BLOCK_2X2
       2 - 1,   // BLOCK_2X4
       4 - 1,   // BLOCK_4X2
-#endif         // CONFIG_CB4X4
+#endif         // CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
       4 - 1,   // BLOCK_4X4
       4 - 1,   // BLOCK_4X8
       8 - 1,   // BLOCK_8X4
       8 - 1,   // BLOCK_8X8
       8 - 1,   // BLOCK_8X16
       16 - 1,  // BLOCK_16X8
       16 - 1,  // BLOCK_16X16
       16 - 1,  // BLOCK_16X32
@@ -1883,21 +1916,21 @@ static const uint32_t av1_prediction_mas
 #if CONFIG_EXT_PARTITION
       64 - 1,   // BLOCK_64X128
       128 - 1,  // BLOCK_128X64
       128 - 1   // BLOCK_128X128
 #endif          // CONFIG_EXT_PARTITION
   },
   // mask for horizontal edges filtering
   {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
       2 - 1,   // BLOCK_2X2
       4 - 1,   // BLOCK_2X4
       2 - 1,   // BLOCK_4X2
-#endif         // CONFIG_CB4X4
+#endif         // CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
       4 - 1,   // BLOCK_4X4
       8 - 1,   // BLOCK_4X8
       4 - 1,   // BLOCK_8X4
       8 - 1,   // BLOCK_8X8
       16 - 1,  // BLOCK_8X16
       8 - 1,   // BLOCK_16X8
       16 - 1,  // BLOCK_16X16
       32 - 1,  // BLOCK_16X32
@@ -1957,106 +1990,166 @@ static const uint32_t av1_transform_mask
       16 - 1,  // TX_4X16
       4 - 1,   // TX_16X4
       32 - 1,  // TX_8X32
       8 - 1    // TX_32X8
   }
 };
 
 static TX_SIZE av1_get_transform_size(const MODE_INFO *const pCurr,
-                                      const EDGE_DIR edgeDir,
+                                      const EDGE_DIR edgeDir, const int mi_row,
+                                      const int mi_col, const int plane,
                                       const uint32_t scaleHorz,
                                       const uint32_t scaleVert) {
-  const BLOCK_SIZE bs = pCurr->mbmi.sb_type;
-  TX_SIZE txSize;
+  const MB_MODE_INFO *mbmi = &pCurr->mbmi;
+  const BLOCK_SIZE sb_type = pCurr->mbmi.sb_type;
+  TX_SIZE tx_size = mbmi->tx_size;
+
+  if (plane == PLANE_TYPE_Y) {
+    tx_size = mbmi->tx_size;
+  } else {
+#if CONFIG_CHROMA_2X2
+    assert(mbmi->tx_size > TX_2X2);
+#endif
+
+#if CONFIG_SUPERTX
+    if (supertx_enabled(mbmi))
+      tx_size = uvsupertx_size_lookup[txsize_sqr_map[mbmi->tx_size]][scaleHorz]
+                                     [scaleVert];
+    else
+#endif  // CONFIG_SUPERTX
+      tx_size = uv_txsize_lookup[sb_type][mbmi->tx_size][scaleHorz][scaleVert];
+  }
+
+  assert(tx_size < TX_SIZES_ALL);
+
+#if CONFIG_VAR_TX
+  // mi_row and mi_col is the absolute position of the MI block.
+  // idx_c and idx_r is the relative offset of the MI within the super block
+  // c and r is the relative offset of the 8x8 block within the supert block
+  // blk_row and block_col is the relative offset of the current 8x8 block
+  // within the current partition.
+  const int idx_c = mi_col & MAX_MIB_MASK;
+  const int idx_r = mi_row & MAX_MIB_MASK;
+  const int c = idx_c >> mi_width_log2_lookup[BLOCK_8X8];
+  const int r = idx_r >> mi_height_log2_lookup[BLOCK_8X8];
+  const int blk_row = r & (num_8x8_blocks_high_lookup[sb_type] - 1);
+  const int blk_col = c & (num_8x8_blocks_wide_lookup[sb_type] - 1);
+
+  if (is_inter_block(mbmi) && !mbmi->skip) {
+    const int tx_row_idx =
+        (blk_row * mi_size_high[BLOCK_8X8] << TX_UNIT_HIGH_LOG2) >> 1;
+    const int tx_col_idx =
+        (blk_col * mi_size_wide[BLOCK_8X8] << TX_UNIT_WIDE_LOG2) >> 1;
+
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+    const BLOCK_SIZE bsize =
+        AOMMAX(BLOCK_4X4, ss_size_lookup[sb_type][scaleHorz][scaleVert]);
+#else
+    const BLOCK_SIZE bsize = ss_size_lookup[sb_type][scaleHorz][scaleVert];
+#endif
+    const TX_SIZE mb_tx_size = mbmi->inter_tx_size[tx_row_idx][tx_col_idx];
+
+    assert(mb_tx_size < TX_SIZES_ALL);
+
+    tx_size = (plane == PLANE_TYPE_UV)
+                  ? uv_txsize_lookup[bsize][mb_tx_size][0][0]
+                  : mb_tx_size;
+    assert(tx_size < TX_SIZES_ALL);
+  }
+#endif
   // since in case of chrominance or non-square transorm need to convert
   // transform size into transform size in particular direction.
-  txSize = uv_txsize_lookup[bs][pCurr->mbmi.tx_size][scaleHorz][scaleVert];
-  if (VERT_EDGE == edgeDir) {
-    txSize = txsize_horz_map[txSize];
-  } else {
-    txSize = txsize_vert_map[txSize];
-  }
-  return txSize;
+  // for vertical edge, filter direction is horizontal, for horizontal
+  // edge, filter direction is vertical.
+  tx_size = (VERT_EDGE == edgeDir) ? txsize_horz_map[tx_size]
+                                   : txsize_vert_map[tx_size];
+  return tx_size;
 }
 
 typedef struct AV1_DEBLOCKING_PARAMETERS {
   // length of the filter applied to the outer edge
   uint32_t filterLength;
   // length of the filter applied to the inner edge
   uint32_t filterLengthInternal;
   // deblocking limits
   const uint8_t *lim;
   const uint8_t *mblim;
   const uint8_t *hev_thr;
 } AV1_DEBLOCKING_PARAMETERS;
 
-static void set_lpf_parameters(AV1_DEBLOCKING_PARAMETERS *const pParams,
-                               const MODE_INFO **const ppCurr,
-                               const ptrdiff_t modeStep,
-                               const AV1_COMMON *const cm,
-                               const EDGE_DIR edgeDir, const uint32_t x,
-                               const uint32_t y, const uint32_t width,
-                               const uint32_t height, const uint32_t scaleHorz,
-                               const uint32_t scaleVert) {
+static void set_lpf_parameters(
+    AV1_DEBLOCKING_PARAMETERS *const pParams, const MODE_INFO **const ppCurr,
+    const ptrdiff_t modeStep, const AV1_COMMON *const cm,
+    const EDGE_DIR edgeDir, const uint32_t x, const uint32_t y,
+    const uint32_t width, const uint32_t height, const int plane,
+    const uint32_t scaleHorz, const uint32_t scaleVert) {
   // reset to initial values
   pParams->filterLength = 0;
   pParams->filterLengthInternal = 0;
   // no deblocking is required
   if ((width <= x) || (height <= y)) {
     return;
   }
 #if CONFIG_EXT_PARTITION
   // not sure if changes are required.
   assert(0 && "Not yet updated");
 #endif  // CONFIG_EXT_PARTITION
+  const int mi_row = (y << scaleVert) >> MI_SIZE_LOG2;
+  const int mi_col = (x << scaleHorz) >> MI_SIZE_LOG2;
+  const MB_MODE_INFO *mbmi = &ppCurr[0]->mbmi;
 
   {
-    const TX_SIZE ts =
-        av1_get_transform_size(ppCurr[0], edgeDir, scaleHorz, scaleVert);
+    const TX_SIZE ts = av1_get_transform_size(
+        ppCurr[0], edgeDir, mi_row, mi_col, plane, scaleHorz, scaleVert);
+
 #if CONFIG_EXT_DELTA_Q
-    const uint32_t currLevel =
-        get_filter_level(cm, &cm->lf_info, &ppCurr[0]->mbmi);
+    const uint32_t currLevel = get_filter_level(cm, &cm->lf_info, mbmi);
 #else
-    const uint32_t currLevel = get_filter_level(&cm->lf_info, &ppCurr[0]->mbmi);
+    const uint32_t currLevel = get_filter_level(&cm->lf_info, mbmi);
 #endif  // CONFIG_EXT_DELTA_Q
 
-    const int currSkipped =
-        ppCurr[0]->mbmi.skip && is_inter_block(&ppCurr[0]->mbmi);
+    const int currSkipped = mbmi->skip && is_inter_block(mbmi);
     const uint32_t coord = (VERT_EDGE == edgeDir) ? (x) : (y);
     uint32_t level = currLevel;
     // prepare outer edge parameters. deblock the edge if it's an edge of a TU
     if (coord) {
 #if CONFIG_LOOPFILTERING_ACROSS_TILES
+      MODE_INFO *const mi = cm->mi + mi_row * cm->mi_stride + mi_col;
       if (!av1_disable_loopfilter_on_tile_boundary(cm) ||
           ((VERT_EDGE == edgeDir) &&
-           (0 == (ppCurr[0]->mbmi.boundary_info & TILE_LEFT_BOUNDARY))) ||
+           (0 == (mi->mbmi.boundary_info & TILE_LEFT_BOUNDARY))) ||
           ((HORZ_EDGE == edgeDir) &&
-           (0 == (ppCurr[0]->mbmi.boundary_info & TILE_ABOVE_BOUNDARY))))
+           (0 == (mi->mbmi.boundary_info & TILE_ABOVE_BOUNDARY))))
 #endif  // CONFIG_LOOPFILTERING_ACROSS_TILES
       {
         const int32_t tuEdge =
             (coord & av1_transform_masks[edgeDir][ts]) ? (0) : (1);
         if (tuEdge) {
           const MODE_INFO *const pPrev = *(ppCurr - modeStep);
-          const TX_SIZE pvTs =
-              av1_get_transform_size(pPrev, edgeDir, scaleHorz, scaleVert);
+          const int pvRow =
+              (VERT_EDGE == edgeDir) ? (mi_row) : (mi_row - (1 << scaleVert));
+          const int pvCol =
+              (VERT_EDGE == edgeDir) ? (mi_col - (1 << scaleHorz)) : (mi_col);
+          const TX_SIZE pvTs = av1_get_transform_size(
+              pPrev, edgeDir, pvRow, pvCol, plane, scaleHorz, scaleVert);
+
 #if CONFIG_EXT_DELTA_Q
           const uint32_t pvLvl =
               get_filter_level(cm, &cm->lf_info, &pPrev->mbmi);
 #else
           const uint32_t pvLvl = get_filter_level(&cm->lf_info, &pPrev->mbmi);
 #endif  // CONFIG_EXT_DELTA_Q
 
           const int pvSkip = pPrev->mbmi.skip && is_inter_block(&pPrev->mbmi);
           const int32_t puEdge =
               (coord &
                av1_prediction_masks[edgeDir]
-                                   [ss_size_lookup[ppCurr[0]->mbmi.sb_type]
-                                                  [scaleHorz][scaleVert]])
+                                   [ss_size_lookup[mbmi->sb_type][scaleHorz]
+                                                  [scaleVert]])
                   ? (0)
                   : (1);
           // if the current and the previous blocks are skipped,
           // deblock the edge if the edge belongs to a PU's edge only.
           if ((currLevel || pvLvl) && (!pvSkip || !currSkipped || puEdge)) {
 #if CONFIG_PARALLEL_DEBLOCKING_15TAP || PARALLEL_DEBLOCKING_15TAPLUMAONLY
             const TX_SIZE minTs = AOMMIN(ts, pvTs);
             if (TX_4X4 >= minTs) {
@@ -2098,19 +2191,19 @@ static void set_lpf_parameters(AV1_DEBLO
         pParams->mblim = limits->mblim;
         pParams->hev_thr = limits->hev_thr;
       }
     }
   }
 }
 
 static void av1_filter_block_plane_vert(const AV1_COMMON *const cm,
+                                        const int plane,
                                         const MACROBLOCKD_PLANE *const pPlane,
                                         const MODE_INFO **ppModeInfo,
-                                        const ptrdiff_t modeStride,
                                         const uint32_t cuX,
                                         const uint32_t cuY) {
   const int col_step = MI_SIZE >> MI_SIZE_LOG2;
   const int row_step = MI_SIZE >> MI_SIZE_LOG2;
   const uint32_t scaleHorz = pPlane->subsampling_x;
   const uint32_t scaleVert = pPlane->subsampling_y;
   const uint32_t width = pPlane->dst.width;
   const uint32_t height = pPlane->dst.height;
@@ -2119,22 +2212,24 @@ static void av1_filter_block_plane_vert(
   for (int y = 0; y < (MAX_MIB_SIZE >> scaleVert); y += row_step) {
     uint8_t *p = pDst + y * MI_SIZE * dstStride;
     for (int x = 0; x < (MAX_MIB_SIZE >> scaleHorz); x += col_step) {
       // inner loop always filter vertical edges in a MI block. If MI size
       // is 8x8, it will filter the vertical edge aligned with a 8x8 block.
       // If 4x4 trasnform is used, it will then filter the internal edge
       //  aligned with a 4x4 block
       const MODE_INFO **const pCurr =
-          ppModeInfo + (y << scaleVert) * modeStride + (x << scaleHorz);
+          ppModeInfo + (y << scaleVert) * cm->mi_stride + (x << scaleHorz);
       AV1_DEBLOCKING_PARAMETERS params;
       memset(&params, 0, sizeof(params));
+
       set_lpf_parameters(&params, pCurr, ((ptrdiff_t)1 << scaleHorz), cm,
                          VERT_EDGE, cuX + x * MI_SIZE, cuY + y * MI_SIZE, width,
-                         height, scaleHorz, scaleVert);
+                         height, plane, scaleHorz, scaleVert);
+
       switch (params.filterLength) {
         // apply 4-tap filtering
         case 4:
 #if CONFIG_HIGHBITDEPTH
           if (cm->use_highbitdepth)
             aom_highbd_lpf_vertical_4_c(CONVERT_TO_SHORTPTR(p), dstStride,
                                         params.mblim, params.lim,
                                         params.hev_thr, cm->bit_depth);
@@ -2186,19 +2281,19 @@ static void av1_filter_block_plane_vert(
       }
       // advance the destination pointer
       p += MI_SIZE;
     }
   }
 }
 
 static void av1_filter_block_plane_horz(const AV1_COMMON *const cm,
+                                        const int plane,
                                         const MACROBLOCKD_PLANE *const pPlane,
                                         const MODE_INFO **ppModeInfo,
-                                        const ptrdiff_t modeStride,
                                         const uint32_t cuX,
                                         const uint32_t cuY) {
   const int col_step = MI_SIZE >> MI_SIZE_LOG2;
   const int row_step = MI_SIZE >> MI_SIZE_LOG2;
   const uint32_t scaleHorz = pPlane->subsampling_x;
   const uint32_t scaleVert = pPlane->subsampling_y;
   const uint32_t width = pPlane->dst.width;
   const uint32_t height = pPlane->dst.height;
@@ -2207,22 +2302,22 @@ static void av1_filter_block_plane_horz(
   for (int y = 0; y < (MAX_MIB_SIZE >> scaleVert); y += row_step) {
     uint8_t *p = pDst + y * MI_SIZE * dstStride;
     for (int x = 0; x < (MAX_MIB_SIZE >> scaleHorz); x += col_step) {
       // inner loop always filter vertical edges in a MI block. If MI size
       // is 8x8, it will first filter the vertical edge aligned with a 8x8
       // block. If 4x4 trasnform is used, it will then filter the internal
       // edge aligned with a 4x4 block
       const MODE_INFO **const pCurr =
-          ppModeInfo + (y << scaleVert) * modeStride + (x << scaleHorz);
+          ppModeInfo + (y << scaleVert) * cm->mi_stride + (x << scaleHorz);
       AV1_DEBLOCKING_PARAMETERS params;
       memset(&params, 0, sizeof(params));
-      set_lpf_parameters(&params, pCurr, (modeStride << scaleVert), cm,
+      set_lpf_parameters(&params, pCurr, (cm->mi_stride << scaleVert), cm,
                          HORZ_EDGE, cuX + x * MI_SIZE, cuY + y * MI_SIZE, width,
-                         height, scaleHorz, scaleVert);
+                         height, plane, scaleHorz, scaleVert);
       switch (params.filterLength) {
         // apply 4-tap filtering
         case 4:
 #if CONFIG_HIGHBITDEPTH
           if (cm->use_highbitdepth)
             aom_highbd_lpf_horizontal_4_c(CONVERT_TO_SHORTPTR(p), dstStride,
                                           params.mblim, params.lim,
                                           params.hev_thr, cm->bit_depth);
@@ -2293,64 +2388,63 @@ void av1_loop_filter_rows(YV12_BUFFER_CO
   for (int i = 0; i < MAX_MB_PLANE; ++i)
     memset(cm->top_txfm_context[i], TX_32X32, cm->mi_cols << TX_UNIT_WIDE_LOG2);
 #endif  // CONFIG_VAR_TX
   for (mi_row = start; mi_row < stop; mi_row += cm->mib_size) {
     MODE_INFO **mi = cm->mi_grid_visible + mi_row * cm->mi_stride;
 #if CONFIG_VAR_TX
     for (int i = 0; i < MAX_MB_PLANE; ++i)
       memset(cm->left_txfm_context[i], TX_32X32, MAX_MIB_SIZE
-                                                     << TX_UNIT_WIDE_LOG2);
+                                                     << TX_UNIT_HIGH_LOG2);
 #endif  // CONFIG_VAR_TX
     for (mi_col = 0; mi_col < cm->mi_cols; mi_col += cm->mib_size) {
       int plane;
 
       av1_setup_dst_planes(planes, cm->sb_size, frame_buffer, mi_row, mi_col);
 
       for (plane = 0; plane < num_planes; ++plane) {
         av1_filter_block_plane_non420_ver(cm, &planes[plane], mi + mi_col,
                                           mi_row, mi_col, plane);
         av1_filter_block_plane_non420_hor(cm, &planes[plane], mi + mi_col,
                                           mi_row, mi_col, plane);
       }
     }
   }
 #else
 
-#if CONFIG_VAR_TX || CONFIG_EXT_PARTITION || CONFIG_EXT_PARTITION_TYPES
+#if CONFIG_EXT_PARTITION || CONFIG_EXT_PARTITION_TYPES
   assert(0 && "Not yet updated. ToDo as next steps");
-#endif  // CONFIG_VAR_TX || CONFIG_EXT_PARTITION || CONFIG_EXT_PARTITION_TYPES
+#endif  // CONFIG_EXT_PARTITION || CONFIG_EXT_PARTITION_TYPES
 
+  // filter all vertical edges in every 64x64 super block
   for (mi_row = start; mi_row < stop; mi_row += MAX_MIB_SIZE) {
     MODE_INFO **mi = cm->mi_grid_visible + mi_row * cm->mi_stride;
     for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
       av1_setup_dst_planes(planes, cm->sb_size, frame_buffer, mi_row, mi_col);
-      // filter all vertical edges in every 64x64 super block
       for (int planeIdx = 0; planeIdx < num_planes; planeIdx += 1) {
         const int32_t scaleHorz = planes[planeIdx].subsampling_x;
         const int32_t scaleVert = planes[planeIdx].subsampling_y;
         av1_filter_block_plane_vert(
-            cm, planes + planeIdx, (const MODE_INFO **)(mi + mi_col),
-            cm->mi_stride, (mi_col * MI_SIZE) >> scaleHorz,
-            (mi_row * MI_SIZE) >> scaleVert);
+            cm, planeIdx, &planes[planeIdx], (const MODE_INFO **)(mi + mi_col),
+            (mi_col * MI_SIZE) >> scaleHorz, (mi_row * MI_SIZE) >> scaleVert);
       }
     }
   }
+
+  // filter all horizontal edges in every 64x64 super block
   for (mi_row = start; mi_row < stop; mi_row += MAX_MIB_SIZE) {
     MODE_INFO **mi = cm->mi_grid_visible + mi_row * cm->mi_stride;
     for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
       av1_setup_dst_planes(planes, cm->sb_size, frame_buffer, mi_row, mi_col);
-      // filter all horizontal edges in every 64x64 super block
       for (int planeIdx = 0; planeIdx < num_planes; planeIdx += 1) {
         const int32_t scaleHorz = planes[planeIdx].subsampling_x;
         const int32_t scaleVert = planes[planeIdx].subsampling_y;
         av1_filter_block_plane_horz(
-            cm, planes + planeIdx, (const MODE_INFO **)(mi + mi_col),
-            cm->mi_stride, (mi_col * MI_SIZE) >> scaleHorz,
-            (mi_row * MI_SIZE) >> scaleVert);
+            cm, planeIdx, &planes[planeIdx], (const MODE_INFO **)(mi + mi_col),
+            (mi_col * MI_SIZE) >> scaleHorz, (mi_row * MI_SIZE) >> scaleVert);
       }
     }
   }
 #endif  // CONFIG_PARALLEL_DEBLOCKING
 
 #else  // CONFIG_VAR_TX || CONFIG_EXT_PARTITION || CONFIG_EXT_PARTITION_TYPES
 
 #if CONFIG_PARALLEL_DEBLOCKING
@@ -2358,34 +2452,32 @@ void av1_loop_filter_rows(YV12_BUFFER_CO
     MODE_INFO **mi = cm->mi_grid_visible + mi_row * cm->mi_stride;
     for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
       av1_setup_dst_planes(planes, cm->sb_size, frame_buffer, mi_row, mi_col);
       // filter all vertical edges in every 64x64 super block
       for (int planeIdx = 0; planeIdx < num_planes; planeIdx += 1) {
         const int32_t scaleHorz = planes[planeIdx].subsampling_x;
         const int32_t scaleVert = planes[planeIdx].subsampling_y;
         av1_filter_block_plane_vert(
-            cm, planes + planeIdx, (const MODE_INFO **)(mi + mi_col),
-            cm->mi_stride, (mi_col * MI_SIZE) >> scaleHorz,
-            (mi_row * MI_SIZE) >> scaleVert);
+            cm, planeIdx, planes + planeIdx, (const MODE_INFO **)(mi + mi_col),
+            (mi_col * MI_SIZE) >> scaleHorz, (mi_row * MI_SIZE) >> scaleVert);
       }
     }
   }
   for (mi_row = start; mi_row < stop; mi_row += MAX_MIB_SIZE) {
     MODE_INFO **mi = cm->mi_grid_visible + mi_row * cm->mi_stride;
     for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
       av1_setup_dst_planes(planes, cm->sb_size, frame_buffer, mi_row, mi_col);
       // filter all horizontal edges in every 64x64 super block
       for (int planeIdx = 0; planeIdx < num_planes; planeIdx += 1) {
         const int32_t scaleHorz = planes[planeIdx].subsampling_x;
         const int32_t scaleVert = planes[planeIdx].subsampling_y;
         av1_filter_block_plane_horz(
-            cm, planes + planeIdx, (const MODE_INFO **)(mi + mi_col),
-            cm->mi_stride, (mi_col * MI_SIZE) >> scaleHorz,
-            (mi_row * MI_SIZE) >> scaleVert);
+            cm, planeIdx, planes + planeIdx, (const MODE_INFO **)(mi + mi_col),
+            (mi_col * MI_SIZE) >> scaleHorz, (mi_row * MI_SIZE) >> scaleVert);
       }
     }
   }
 #else   // CONFIG_PARALLEL_DEBLOCKING
   enum lf_path path;
   LOOP_FILTER_MASK lfm;
 
   if (y_only)
--- a/third_party/aom/av1/common/av1_rtcd_defs.pl
+++ b/third_party/aom/av1/common/av1_rtcd_defs.pl
@@ -6,22 +6,25 @@ print <<EOF
 
 #include "aom/aom_integer.h"
 #include "av1/common/common.h"
 #include "av1/common/enums.h"
 #include "av1/common/quant_common.h"
 #include "av1/common/filter.h"
 #include "av1/common/convolve.h"
 #include "av1/common/av1_txfm.h"
+#include "av1/common/idct.h"
 #include "av1/common/odintrin.h"
 
 struct macroblockd;
 
 /* Encoder forward decls */
 struct macroblock;
+struct fwd_txfm_param;
+struct inv_txfm_param;
 struct aom_variance_vtable;
 struct search_site_config;
 struct mv;
 union int_mv;
 struct yv12_buffer_config;
 typedef uint16_t od_dering_in;
 EOF
 }
@@ -58,104 +61,104 @@ if (aom_config("CONFIG_HIGHBITDEPTH") eq
   specialize qw/av1_highbd_convolve_vert sse4_1/;
 }
 
 #
 # Inverse dct
 #
 if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
   {
-    add_proto qw/void av1_iht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht4x4_16_add sse2/;
 
-    add_proto qw/void av1_iht4x8_32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht4x8_32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht4x8_32_add sse2/;
 
-    add_proto qw/void av1_iht8x4_32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht8x4_32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht8x4_32_add sse2/;
 
-    add_proto qw/void av1_iht8x16_128_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht8x16_128_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht8x16_128_add sse2/;
 
-    add_proto qw/void av1_iht16x8_128_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht16x8_128_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht16x8_128_add sse2/;
 
-    add_proto qw/void av1_iht16x32_512_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht16x32_512_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht16x32_512_add sse2/;
 
-    add_proto qw/void av1_iht32x16_512_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht32x16_512_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht32x16_512_add sse2/;
 
-    add_proto qw/void av1_iht4x16_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht4x16_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-    add_proto qw/void av1_iht16x4_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht16x4_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-    add_proto qw/void av1_iht8x32_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht8x32_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-    add_proto qw/void av1_iht32x8_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht32x8_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-    add_proto qw/void av1_iht8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht8x8_64_add sse2/;
 
-    add_proto qw/void av1_iht16x16_256_add/, "const tran_low_t *input, uint8_t *output, int pitch, int tx_type";
+    add_proto qw/void av1_iht16x16_256_add/, "const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param";
       specialize qw/av1_iht16x16_256_add sse2 avx2/;
 
-    add_proto qw/void av1_iht32x32_1024_add/, "const tran_low_t *input, uint8_t *output, int pitch, int tx_type";
+    add_proto qw/void av1_iht32x32_1024_add/, "const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param";
   }
 } else {
   {
-    add_proto qw/void av1_iht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
     specialize qw/av1_iht4x4_16_add sse2 neon dspr2/;
 
-    add_proto qw/void av1_iht4x8_32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht4x8_32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht4x8_32_add sse2/;
 
-    add_proto qw/void av1_iht8x4_32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht8x4_32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht8x4_32_add sse2/;
 
-    add_proto qw/void av1_iht8x16_128_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht8x16_128_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht8x16_128_add sse2/;
 
-    add_proto qw/void av1_iht16x8_128_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht16x8_128_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht16x8_128_add sse2/;
 
-    add_proto qw/void av1_iht16x32_512_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht16x32_512_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht16x32_512_add sse2/;
 
-    add_proto qw/void av1_iht32x16_512_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht32x16_512_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht32x16_512_add sse2/;
 
-    add_proto qw/void av1_iht4x16_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht4x16_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-    add_proto qw/void av1_iht16x4_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht16x4_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-    add_proto qw/void av1_iht8x32_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht8x32_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-    add_proto qw/void av1_iht32x8_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht32x8_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-    add_proto qw/void av1_iht8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type";
+    add_proto qw/void av1_iht8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
       specialize qw/av1_iht8x8_64_add sse2 neon dspr2/;
 
-    add_proto qw/void av1_iht16x16_256_add/, "const tran_low_t *input, uint8_t *output, int pitch, int tx_type";
+    add_proto qw/void av1_iht16x16_256_add/, "const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param";
       specialize qw/av1_iht16x16_256_add sse2 avx2 dspr2/;
 
-    add_proto qw/void av1_iht32x32_1024_add/, "const tran_low_t *input, uint8_t *output, int pitch, int tx_type";
+    add_proto qw/void av1_iht32x32_1024_add/, "const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param";
 
     if (aom_config("CONFIG_EXT_TX") ne "yes") {
       specialize qw/av1_iht4x4_16_add msa/;
       specialize qw/av1_iht8x8_64_add msa/;
       specialize qw/av1_iht16x16_256_add msa/;
     }
   }
 }
 
-add_proto qw/void av1_iht32x32_1024_add/, "const tran_low_t *input, uint8_t *output, int pitch, int tx_type";
+add_proto qw/void av1_iht32x32_1024_add/, "const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param";
 
 if (aom_config("CONFIG_TX64X64") eq "yes") {
-  add_proto qw/void av1_iht64x64_4096_add/, "const tran_low_t *input, uint8_t *output, int pitch, int tx_type";
+  add_proto qw/void av1_iht64x64_4096_add/, "const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param";
 }
 
 if (aom_config("CONFIG_NEW_QUANT") eq "yes") {
   add_proto qw/void quantize_nuq/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, const int16_t *dequant_ptr, const cuml_bins_type_nuq *cuml_bins_ptr, const dequant_val_type_nuq *dequant_val, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const int16_t *scan, const uint8_t *band";
 
   add_proto qw/void quantize_fp_nuq/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *quant_ptr, const int16_t *dequant_ptr, const cuml_bins_type_nuq *cuml_bins_ptr, const dequant_val_type_nuq *dequant_val, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const int16_t *scan, const uint8_t *band";
 
   add_proto qw/void quantize_32x32_nuq/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, const int16_t *dequant_ptr, const cuml_bins_type_nuq *cuml_bins_ptr, const dequant_val_type_nuq *dequant_val, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const int16_t *scan, const uint8_t *band";
@@ -221,68 +224,73 @@ if (aom_config("CONFIG_HIGHBITDEPTH") eq
   specialize qw/av1_highbd_convolve8_avg_horiz/, "$sse2_x86_64";
 
   add_proto qw/void av1_highbd_convolve8_avg_vert/, "const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst, ptrdiff_t dst_stride, const int16_t *filter_x, int x_step_q4, const int16_t *filter_y, int y_step_q4, int w, int h, int bps";
   specialize qw/av1_highbd_convolve8_avg_vert/, "$sse2_x86_64";
 
   #
   # dct
   #
-  add_proto qw/void av1_highbd_iht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht4x4_16_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-  add_proto qw/void av1_highbd_iht4x8_32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht4x8_32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-  add_proto qw/void av1_highbd_iht8x4_32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht8x4_32_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-  add_proto qw/void av1_highbd_iht8x16_128_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht8x16_128_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-  add_proto qw/void av1_highbd_iht16x8_128_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht16x8_128_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-  add_proto qw/void av1_highbd_iht16x32_512_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht16x32_512_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-  add_proto qw/void av1_highbd_iht32x16_512_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht32x16_512_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-  add_proto qw/void av1_highbd_iht4x16_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht4x16_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-  add_proto qw/void av1_highbd_iht16x4_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht16x4_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-  add_proto qw/void av1_highbd_iht8x32_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht8x32_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-  add_proto qw/void av1_highbd_iht32x8_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht32x8_256_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-  add_proto qw/void av1_highbd_iht8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht8x8_64_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, const struct inv_txfm_param *param";
 
-  add_proto qw/void av1_highbd_iht16x16_256_add/, "const tran_low_t *input, uint8_t *output, int pitch, int tx_type, int bd";
+  add_proto qw/void av1_highbd_iht16x16_256_add/, "const tran_low_t *input, uint8_t *output, int pitch, const struct inv_txfm_param *param";
 }
 
-if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
-  #inv txfm
-  add_proto qw/void av1_inv_txfm2d_add_4x4/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
-  specialize qw/av1_inv_txfm2d_add_4x4 sse4_1/;
-  add_proto qw/void av1_inv_txfm2d_add_8x8/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
-  specialize qw/av1_inv_txfm2d_add_8x8 sse4_1/;
-  add_proto qw/void av1_inv_txfm2d_add_16x16/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
-  specialize qw/av1_inv_txfm2d_add_16x16 sse4_1/;
-  add_proto qw/void av1_inv_txfm2d_add_32x32/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
-  specialize qw/av1_inv_txfm2d_add_32x32 avx2/;
-  add_proto qw/void av1_inv_txfm2d_add_64x64/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
-}
+#inv txfm
+add_proto qw/void av1_inv_txfm2d_add_4x8/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+add_proto qw/void av1_inv_txfm2d_add_8x4/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+add_proto qw/void av1_inv_txfm2d_add_8x16/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+add_proto qw/void av1_inv_txfm2d_add_16x8/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+add_proto qw/void av1_inv_txfm2d_add_16x32/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+add_proto qw/void av1_inv_txfm2d_add_32x16/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+add_proto qw/void av1_inv_txfm2d_add_4x4/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+specialize qw/av1_inv_txfm2d_add_4x4 sse4_1/;
+add_proto qw/void av1_inv_txfm2d_add_8x8/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+specialize qw/av1_inv_txfm2d_add_8x8 sse4_1/;
+add_proto qw/void av1_inv_txfm2d_add_16x16/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+specialize qw/av1_inv_txfm2d_add_16x16 sse4_1/;
+add_proto qw/void av1_inv_txfm2d_add_32x32/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
+specialize qw/av1_inv_txfm2d_add_32x32 avx2/;
+add_proto qw/void av1_inv_txfm2d_add_64x64/, "const int32_t *input, uint16_t *output, int stride, int tx_type, int bd";
 
 #
 # Encoder functions below this point.
 #
 if (aom_config("CONFIG_AV1_ENCODER") eq "yes") {
 
 # ENCODEMB INVOKE
 
 if (aom_config("CONFIG_AOM_QM") eq "yes") {
   if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
     # the transform coefficients are held in 32-bit
     # values, so the assembler code for  av1_block_error can no longer be used.
     add_proto qw/int64_t av1_block_error/, "const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz";
+    specialize qw/av1_block_error avx2/;
 
     add_proto qw/void av1_quantize_fp/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t *iqm_ptr";
 
     add_proto qw/void av1_quantize_fp_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t *iqm_ptr";
 
     if (aom_config("CONFIG_TX64X64") eq "yes") {
       add_proto qw/void av1_quantize_fp_64x64/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t *iqm_ptr";
     }
@@ -305,126 +313,135 @@ if (aom_config("CONFIG_AOM_QM") eq "yes"
 
     add_proto qw/void av1_fdct8x8_quant/, "const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t *iqm_ptr";
   }
 } else {
   if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
     # the transform coefficients are held in 32-bit
     # values, so the assembler code for  av1_block_error can no longer be used.
     add_proto qw/int64_t av1_block_error/, "const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz";
+    specialize qw/av1_block_error avx2/;
 
     add_proto qw/void av1_quantize_fp/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
-    specialize qw/av1_quantize_fp sse2/;
+    specialize qw/av1_quantize_fp sse2 avx2/;
 
     add_proto qw/void av1_quantize_fp_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
+    specialize qw/av1_quantize_fp_32x32 avx2/;
 
     if (aom_config("CONFIG_TX64X64") eq "yes") {
       add_proto qw/void av1_quantize_fp_64x64/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
     }
 
     add_proto qw/void av1_fdct8x8_quant/, "const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
   } else {
     add_proto qw/int64_t av1_block_error/, "const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz";
     specialize qw/av1_block_error sse2 avx2 msa/;
 
     add_proto qw/int64_t av1_block_error_fp/, "const int16_t *coeff, const int16_t *dqcoeff, int block_size";
     specialize qw/av1_block_error_fp neon sse2/;
 
     add_proto qw/void av1_quantize_fp/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
-    specialize qw/av1_quantize_fp neon sse2/, "$ssse3_x86_64";
+    specialize qw/av1_quantize_fp neon sse2 avx2/, "$ssse3_x86_64";
 
     add_proto qw/void av1_quantize_fp_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
-    specialize qw/av1_quantize_fp_32x32/, "$ssse3_x86_64";
+    specialize qw/av1_quantize_fp_32x32 avx2/, "$ssse3_x86_64";
 
     if (aom_config("CONFIG_TX64X64") eq "yes") {
       add_proto qw/void av1_quantize_fp_64x64/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
     }
 
     add_proto qw/void av1_fdct8x8_quant/, "const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
     specialize qw/av1_fdct8x8_quant sse2 ssse3 neon/;
   }
 
 }
 
 # fdct functions
 
-add_proto qw/void av1_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 specialize qw/av1_fht4x4 sse2/;
 
 add_proto qw/void av1_fwht4x4/, "const int16_t *input, tran_low_t *output, int stride";
 
-add_proto qw/void av1_fht8x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht8x8/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 specialize qw/av1_fht8x8 sse2/;
 
-add_proto qw/void av1_fht16x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht16x16/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 specialize qw/av1_fht16x16 sse2 avx2/;
 
-add_proto qw/void av1_fht32x32/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht32x32/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 specialize qw/av1_fht32x32 sse2 avx2/;
 
 if (aom_config("CONFIG_TX64X64") eq "yes") {
-  add_proto qw/void av1_fht64x64/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+  add_proto qw/void av1_fht64x64/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 }
 
-add_proto qw/void av1_fht4x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht4x8/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 specialize qw/av1_fht4x8 sse2/;
 
-add_proto qw/void av1_fht8x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht8x4/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 specialize qw/av1_fht8x4 sse2/;
 
-add_proto qw/void av1_fht8x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht8x16/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 specialize qw/av1_fht8x16 sse2/;
 
-add_proto qw/void av1_fht16x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht16x8/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 specialize qw/av1_fht16x8 sse2/;
 
-add_proto qw/void av1_fht16x32/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht16x32/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 specialize qw/av1_fht16x32 sse2/;
 
-add_proto qw/void av1_fht32x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht32x16/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 specialize qw/av1_fht32x16 sse2/;
 
-add_proto qw/void av1_fht4x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht4x16/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 
-add_proto qw/void av1_fht16x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht16x4/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 
-add_proto qw/void av1_fht8x32/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht8x32/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 
-add_proto qw/void av1_fht32x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+add_proto qw/void av1_fht32x8/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
 
 if (aom_config("CONFIG_HIGHBITDEPTH") ne "yes") {
   if (aom_config("CONFIG_EXT_TX") ne "yes") {
     specialize qw/av1_fht4x4 msa/;
     specialize qw/av1_fht8x8 msa/;
     specialize qw/av1_fht16x16 msa/;
   }
 }
 
 add_proto qw/void av1_fwd_idtx/, "const int16_t *src_diff, tran_low_t *coeff, int stride, int bs, int tx_type";
 
 if (aom_config("CONFIG_DPCM_INTRA") eq "yes") {
   @sizes = (4, 8, 16, 32);
   foreach $size (@sizes) {
+    if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
+      add_proto "void", "av1_hbd_dpcm_ft$size", "const int16_t *input, int stride, TX_TYPE_1D tx_type, tran_low_t *output, int dir";
+    }
     add_proto "void", "av1_dpcm_ft$size", "const int16_t *input, int stride, TX_TYPE_1D tx_type, tran_low_t *output";
   }
 }
 
-if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
-  #fwd txfm
-  add_proto qw/void av1_fwd_txfm2d_4x4/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
-  specialize qw/av1_fwd_txfm2d_4x4 sse4_1/;
-  add_proto qw/void av1_fwd_txfm2d_8x8/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
-  specialize qw/av1_fwd_txfm2d_8x8 sse4_1/;
-  add_proto qw/void av1_fwd_txfm2d_16x16/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
-  specialize qw/av1_fwd_txfm2d_16x16 sse4_1/;
-  add_proto qw/void av1_fwd_txfm2d_32x32/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
-  specialize qw/av1_fwd_txfm2d_32x32 sse4_1/;
-  add_proto qw/void av1_fwd_txfm2d_64x64/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
-  specialize qw/av1_fwd_txfm2d_64x64 sse4_1/;
-}
+#fwd txfm
+add_proto qw/void av1_fwd_txfm2d_4x8/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+add_proto qw/void av1_fwd_txfm2d_8x4/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+add_proto qw/void av1_fwd_txfm2d_8x16/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+add_proto qw/void av1_fwd_txfm2d_16x8/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+add_proto qw/void av1_fwd_txfm2d_16x32/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+add_proto qw/void av1_fwd_txfm2d_32x16/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+add_proto qw/void av1_fwd_txfm2d_4x4/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+specialize qw/av1_fwd_txfm2d_4x4 sse4_1/;
+add_proto qw/void av1_fwd_txfm2d_8x8/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+specialize qw/av1_fwd_txfm2d_8x8 sse4_1/;
+add_proto qw/void av1_fwd_txfm2d_16x16/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+specialize qw/av1_fwd_txfm2d_16x16 sse4_1/;
+add_proto qw/void av1_fwd_txfm2d_32x32/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+specialize qw/av1_fwd_txfm2d_32x32 sse4_1/;
+add_proto qw/void av1_fwd_txfm2d_64x64/, "const int16_t *input, int32_t *output, int stride, int tx_type, int bd";
+specialize qw/av1_fwd_txfm2d_64x64 sse4_1/;
 
 #
 # Motion search
 #
 add_proto qw/int av1_full_search_sad/, "const struct macroblock *x, const struct mv *ref_mv, int sad_per_bit, int distance, const struct aom_variance_vtable *fn_ptr, const struct mv *center_mv, struct mv *best_mv";
 specialize qw/av1_full_search_sad sse3 sse4_1/;
 $av1_full_search_sad_sse3=av1_full_search_sadx3;
 $av1_full_search_sad_sse4_1=av1_full_search_sadx8;
@@ -459,72 +476,44 @@ if (aom_config("CONFIG_HIGHBITDEPTH") eq
 
       add_proto qw/void highbd_quantize_64x64_fp_nuq/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *quant_ptr, const int16_t *dequant_ptr, const cuml_bins_type_nuq *cuml_bins_ptr, const dequant_val_type_nuq *dequant_val, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const int16_t *scan, const uint8_t *band";
     }
   }
 
   add_proto qw/int64_t av1_highbd_block_error/, "const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd";
   specialize qw/av1_highbd_block_error sse2/;
 
-  if (aom_config("CONFIG_AOM_QM") eq "yes") {
-    add_proto qw/void av1_highbd_quantize_fp/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr, int log_scale";
-
-    add_proto qw/void av1_highbd_quantize_fp_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr, int log_scale";
-
-    if (aom_config("CONFIG_TX64X64") eq "yes") {
-      add_proto qw/void av1_highbd_quantize_fp_64x64/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr, int log_scale";
-    }
-
-    add_proto qw/void av1_highbd_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr, int log_scale";
-  } else {
-    add_proto qw/void av1_highbd_quantize_fp/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale";
-    specialize qw/av1_highbd_quantize_fp sse4_1/;
-
-    add_proto qw/void av1_highbd_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale";
-  }
-
   # fdct functions
-  add_proto qw/void av1_highbd_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-  specialize qw/av1_highbd_fht4x4 sse4_1/;
-
-  add_proto qw/void av1_highbd_fht4x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
-  add_proto qw/void av1_highbd_fht8x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
-  add_proto qw/void av1_highbd_fht8x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
-  add_proto qw/void av1_highbd_fht16x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
-  add_proto qw/void av1_highbd_fht16x32/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
-  add_proto qw/void av1_highbd_fht32x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
-  add_proto qw/void av1_highbd_fht4x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
-  add_proto qw/void av1_highbd_fht16x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
-  add_proto qw/void av1_highbd_fht8x32/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
-  add_proto qw/void av1_highbd_fht32x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
-  add_proto qw/void av1_highbd_fht8x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
-  add_proto qw/void av1_highbd_fht16x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
-  add_proto qw/void av1_highbd_fht32x32/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
-
   if (aom_config("CONFIG_TX64X64") eq "yes") {
     add_proto qw/void av1_highbd_fht64x64/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
   }
 
-  add_proto qw/void av1_highbd_fwht4x4/, "const int16_t *input, tran_low_t *output, int stride";
-
   add_proto qw/void av1_highbd_temporal_filter_apply/, "uint8_t *frame1, unsigned int stride, uint8_t *frame2, unsigned int block_width, unsigned int block_height, int strength, int filter_weight, unsigned int *accumulator, uint16_t *count";
 
 }
+
+if (aom_config("CONFIG_AOM_QM") eq "yes") {
+  add_proto qw/void av1_highbd_quantize_fp/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr, int log_scale";
+
+  add_proto qw/void av1_highbd_quantize_fp_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr, int log_scale";
+
+  if (aom_config("CONFIG_TX64X64") eq "yes") {
+    add_proto qw/void av1_highbd_quantize_fp_64x64/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr, int log_scale";
+  }
+
+  add_proto qw/void av1_highbd_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr, int log_scale";
+} else {
+  add_proto qw/void av1_highbd_quantize_fp/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale";
+  specialize qw/av1_highbd_quantize_fp sse4_1 avx2/;
+
+  add_proto qw/void av1_highbd_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int log_scale";
+}
+
+add_proto qw/void av1_highbd_fwht4x4/, "const int16_t *input, tran_low_t *output, int stride";
+
 # End av1_high encoder functions
 
 if (aom_config("CONFIG_EXT_INTER") eq "yes") {
   add_proto qw/uint64_t av1_wedge_sse_from_residuals/, "const int16_t *r1, const int16_t *d, const uint8_t *m, int N";
   specialize qw/av1_wedge_sse_from_residuals sse2/;
   add_proto qw/int av1_wedge_sign_from_residuals/, "const int16_t *ds, const uint8_t *m, int N, int64_t limit";
   specialize qw/av1_wedge_sign_from_residuals sse2/;
   add_proto qw/void av1_wedge_compute_delta_squares/, "int16_t *d, const int16_t *a, const int16_t *b, int N";
@@ -534,35 +523,35 @@ if (aom_config("CONFIG_EXT_INTER") eq "y
 }
 # end encoder functions
 
 # If PVQ is enabled, fwd transforms are required by decoder
 if (aom_config("CONFIG_PVQ") eq "yes") {
 # fdct functions
 
 if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
-  add_proto qw/void av1_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+  add_proto qw/void av1_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
   specialize qw/av1_fht4x4 sse2/;
 
-  add_proto qw/void av1_fht8x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+  add_proto qw/void av1_fht8x8/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
   specialize qw/av1_fht8x8 sse2/;
 
-  add_proto qw/void av1_fht16x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+  add_proto qw/void av1_fht16x16/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
   specialize qw/av1_fht16x16 sse2/;
 
   add_proto qw/void av1_fwht4x4/, "const int16_t *input, tran_low_t *output, int stride";
   specialize qw/av1_fwht4x4 sse2/;
 } else {
-  add_proto qw/void av1_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+  add_proto qw/void av1_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
   specialize qw/av1_fht4x4 sse2 msa/;
 
-  add_proto qw/void av1_fht8x8/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+  add_proto qw/void av1_fht8x8/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
   specialize qw/av1_fht8x8 sse2 msa/;
 
-  add_proto qw/void av1_fht16x16/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
+  add_proto qw/void av1_fht16x16/, "const int16_t *input, tran_low_t *output, int stride, struct fwd_txfm_param *param";
   specialize qw/av1_fht16x16 sse2 msa/;
 
   add_proto qw/void av1_fwht4x4/, "const int16_t *input, tran_low_t *output, int stride";
   specialize qw/av1_fwht4x4 msa sse2/;
 }
 
 }
 
@@ -611,22 +600,29 @@ if (aom_config("CONFIG_PVQ") eq "yes") {
   add_proto qw/double pvq_search_rdo_double/, "const od_val16 *xcoeff, int n, int k, int *ypulse, double g2, double pvq_norm_lambda, int prev_k";
   specialize qw/pvq_search_rdo_double sse4_1/;
 }
 
 # WARPED_MOTION / GLOBAL_MOTION functions
 
 if ((aom_config("CONFIG_WARPED_MOTION") eq "yes") ||
     (aom_config("CONFIG_GLOBAL_MOTION") eq "yes")) {
-  add_proto qw/void av1_warp_affine/, "const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
+  add_proto qw/void av1_warp_affine/, "const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
   specialize qw/av1_warp_affine sse2 ssse3/;
 
+  if (aom_config("CONFIG_CONVOLVE_ROUND") eq "yes") {
+    add_proto qw/void av1_warp_affine_post_round/, "const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
+  }
+
   if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
-    add_proto qw/void av1_highbd_warp_affine/, "const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, int comp_avg, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
+    add_proto qw/void av1_highbd_warp_affine/, "const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
     specialize qw/av1_highbd_warp_affine ssse3/;
+    if (aom_config("CONFIG_CONVOLVE_ROUND") eq "yes") {
+      add_proto qw/void av1_highbd_warp_affine_post_round/, "const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
+    }
   }
 }
 
 if (aom_config("CONFIG_GLOBAL_MOTION") eq "yes" &&
     aom_config("CONFIG_AV1_ENCODER") eq "yes") {
   add_proto qw/double compute_cross_correlation/, "unsigned char *im1, int stride1, int x1, int y1, unsigned char *im2, int stride2, int x2, int y2";
   specialize qw/compute_cross_correlation sse4_1/;
 }
@@ -650,9 +646,21 @@ if (aom_config("CONFIG_LOOP_RESTORATION"
     add_proto qw/void av1_selfguided_restoration_highbd/, "uint16_t *dgd, int width, int height, int stride, int32_t *dst, int dst_stride, int bit_depth, int r, int eps, int32_t *tmpbuf";
     specialize qw/av1_selfguided_restoration_highbd sse4_1/;
 
     add_proto qw/void av1_highpass_filter_highbd/, "uint16_t *dgd, int width, int height, int stride, int32_t *dst, int dst_stride, int r, int eps";
     specialize qw/av1_highpass_filter_highbd sse4_1/;
   }
 }
 
+# CONVOLVE_ROUND/COMPOUND_ROUND functions
+
+if (aom_config("CONFIG_CONVOLVE_ROUND") eq "yes") {
+    add_proto qw/void av1_convolve_2d/, "const uint8_t *src, int src_stride, CONV_BUF_TYPE *dst, int dst_stride, int w, int h, InterpFilterParams *filter_params_x, InterpFilterParams *filter_params_y, const int subpel_x_q4, const int subpel_y_q4, ConvolveParams *conv_params";
+    specialize qw/av1_convolve_2d sse2/;
+
+  if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
+    add_proto qw/void av1_highbd_convolve_2d/, "const uint16_t *src, int src_stride, CONV_BUF_TYPE *dst, int dst_stride, int w, int h, InterpFilterParams *filter_params_x, InterpFilterParams *filter_params_y, const int subpel_x_q4, const int subpel_y_q4, ConvolveParams *conv_params, int bd";
+    specialize qw/av1_highbd_convolve_2d ssse3/;
+  }
+}
+
 1;
--- a/third_party/aom/av1/common/av1_txfm.h
+++ b/third_party/aom/av1/common/av1_txfm.h
@@ -115,21 +115,22 @@ static INLINE int get_max_bit(int x) {
   while (x) {
     x = x >> 1;
     max_bit++;
   }
   return max_bit;
 }
 
 // TODO(angiebird): implement SSE
-static INLINE void clamp_block(int16_t *block, int block_size, int stride,
-                               int low, int high) {
+static INLINE void clamp_block(int16_t *block, int block_size_row,
+                               int block_size_col, int stride, int low,
+                               int high) {
   int i, j;
-  for (i = 0; i < block_size; ++i) {
-    for (j = 0; j < block_size; ++j) {
+  for (i = 0; i < block_size_row; ++i) {
+    for (j = 0; j < block_size_col; ++j) {
       block[i * stride + j] = clamp(block[i * stride + j], low, high);
     }
   }
 }
 
 typedef void (*TxfmFunc)(const int32_t *input, int32_t *output,
                          const int8_t *cos_bit, const int8_t *stage_range);
 
--- a/third_party/aom/av1/common/blockd.c
+++ b/third_party/aom/av1/common/blockd.c
@@ -123,17 +123,17 @@ void av1_foreach_transformed_block_inter
 void av1_foreach_transformed_block_in_plane(
     const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane,
     foreach_transformed_block_visitor visit, void *arg) {
   const struct macroblockd_plane *const pd = &xd->plane[plane];
   // block and transform sizes, in number of 4x4 blocks log 2 ("*_b")
   // 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8
   // transform size varies per plane, look it up in a common way.
   const TX_SIZE tx_size = get_tx_size(plane, xd);
-#if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2
+#if CONFIG_CHROMA_SUB8X8
   const BLOCK_SIZE plane_bsize =
       AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
 #else
   const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
 #endif
   const uint8_t txw_unit = tx_size_wide_unit[tx_size];
   const uint8_t txh_unit = tx_size_high_unit[tx_size];
   const int step = txw_unit * txh_unit;
@@ -173,59 +173,16 @@ void av1_foreach_transformed_block(const
     (void)mi_row;
     (void)mi_col;
 #endif
     av1_foreach_transformed_block_in_plane(xd, bsize, plane, visit, arg);
   }
 }
 #endif
 
-#if CONFIG_DAALA_DIST
-void av1_foreach_8x8_transformed_block_in_yplane(
-    const MACROBLOCKD *const xd, BLOCK_SIZE bsize,
-    foreach_transformed_block_visitor visit,
-    foreach_transformed_block_visitor mi_visit, void *arg) {
-  const struct macroblockd_plane *const pd = &xd->plane[0];
-  // block and transform sizes, in number of 4x4 blocks log 2 ("*_b")
-  // 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8
-  // transform size varies per plane, look it up in a common way.
-  const TX_SIZE tx_size = get_tx_size(0, xd);
-  const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
-  const uint8_t txw_unit = tx_size_wide_unit[tx_size];
-  const uint8_t txh_unit = tx_size_high_unit[tx_size];
-  const int step = txw_unit * txh_unit;
-  int i = 0, r, c;
-
-  // If mb_to_right_edge is < 0 we are in a situation in which
-  // the current block size extends into the UMV and we won't
-  // visit the sub blocks that are wholly within the UMV.
-  const int max_blocks_wide = max_block_wide(xd, plane_bsize, 0);
-  const int max_blocks_high = max_block_high(xd, plane_bsize, 0);
-  const int skip_check_r = tx_size_high[tx_size] == 8 ? 1 : 0;
-  const int skip_check_c = tx_size_wide[tx_size] == 8 ? 1 : 0;
-
-  assert(plane_bsize >= BLOCK_8X8);
-  assert(tx_size == TX_4X4 || tx_size == TX_4X8 || tx_size == TX_8X4);
-
-  // Keep track of the row and column of the blocks we use so that we know
-  // if we are in the unrestricted motion border.
-  for (r = 0; r < max_blocks_high; r += txh_unit) {
-    // Skip visiting the sub blocks that are wholly within the UMV.
-    for (c = 0; c < max_blocks_wide; c += txw_unit) {
-      visit(0, i, r, c, plane_bsize, tx_size, arg);
-      // Call whenever each 8x8 tx block is done
-      if (((r & txh_unit) || skip_check_r) && ((c & txw_unit) || skip_check_c))
-        mi_visit(0, i, r - (1 - skip_check_r) * txh_unit,
-                 c - (1 - skip_check_c) * txw_unit, plane_bsize, tx_size, arg);
-      i += step;
-    }
-  }
-}
-#endif
-
 #if !CONFIG_PVQ || CONFIG_VAR_TX
 void av1_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd,
                       int plane, TX_SIZE tx_size, int has_eob, int aoff,
                       int loff) {
   ENTROPY_CONTEXT *const a = pd->above_context + aoff;
   ENTROPY_CONTEXT *const l = pd->left_context + loff;
   const int txs_wide = tx_size_wide_unit[tx_size];
   const int txs_high = tx_size_high_unit[tx_size];
@@ -277,21 +234,21 @@ void av1_reset_skip_context(MACROBLOCKD 
   nplanes = 1 + (MAX_MB_PLANE - 1) * chroma_ref;
 #else
   (void)mi_row;
   (void)mi_col;
   nplanes = MAX_MB_PLANE;
 #endif
   for (i = 0; i < nplanes; i++) {
     struct macroblockd_plane *const pd = &xd->plane[i];
-#if CONFIG_CHROMA_2X2 || !CONFIG_CB4X4
-    const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
-#else
+#if CONFIG_CHROMA_SUB8X8
     const BLOCK_SIZE plane_bsize =
         AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
+#else
+    const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
 #endif
     const int txs_wide = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
     const int txs_high = block_size_high[plane_bsize] >> tx_size_high_log2[0];
     memset(pd->above_context, 0, sizeof(ENTROPY_CONTEXT) * txs_wide);
     memset(pd->left_context, 0, sizeof(ENTROPY_CONTEXT) * txs_high);
   }
 }
 
--- a/third_party/aom/av1/common/blockd.h
+++ b/third_party/aom/av1/common/blockd.h
@@ -114,24 +114,27 @@ typedef struct {
   uint8_t *plane[MAX_MB_PLANE];
   int stride[MAX_MB_PLANE];
 } BUFFER_SET;
 
 #if CONFIG_EXT_INTER
 static INLINE int is_inter_singleref_mode(PREDICTION_MODE mode) {
   return mode >= NEARESTMV && mode <= NEWMV;
 }
+static INLINE int is_inter_compound_mode(PREDICTION_MODE mode) {
+  return mode >= NEAREST_NEARESTMV && mode <= NEW_NEWMV;
+}
 #if CONFIG_COMPOUND_SINGLEREF
 static INLINE int is_inter_singleref_comp_mode(PREDICTION_MODE mode) {
   return mode >= SR_NEAREST_NEARMV && mode <= SR_NEW_NEWMV;
 }
+static INLINE int is_inter_anyref_comp_mode(PREDICTION_MODE mode) {
+  return is_inter_compound_mode(mode) || is_inter_singleref_comp_mode(mode);
+}
 #endif  // CONFIG_COMPOUND_SINGLEREF
-static INLINE int is_inter_compound_mode(PREDICTION_MODE mode) {
-  return mode >= NEAREST_NEARESTMV && mode <= NEW_NEWMV;
-}
 
 static INLINE PREDICTION_MODE compound_ref0_mode(PREDICTION_MODE mode) {
   static PREDICTION_MODE lut[] = {
     MB_MODE_COUNT,  // DC_PRED
     MB_MODE_COUNT,  // V_PRED
     MB_MODE_COUNT,  // H_PRED
     MB_MODE_COUNT,  // D45_PRED
     MB_MODE_COUNT,  // D135_PRED
@@ -148,32 +151,36 @@ static INLINE PREDICTION_MODE compound_r
 #endif              // CONFIG_ALT_INTRA
     MB_MODE_COUNT,  // TM_PRED
     MB_MODE_COUNT,  // NEARESTMV
     MB_MODE_COUNT,  // NEARMV
     MB_MODE_COUNT,  // ZEROMV
     MB_MODE_COUNT,  // NEWMV
 #if CONFIG_COMPOUND_SINGLEREF
     NEARESTMV,  // SR_NEAREST_NEARMV
-    NEARESTMV,  // SR_NEAREST_NEWMV
+    // NEARESTMV,  // SR_NEAREST_NEWMV
     NEARMV,     // SR_NEAR_NEWMV
     ZEROMV,     // SR_ZERO_NEWMV
     NEWMV,      // SR_NEW_NEWMV
 #endif          // CONFIG_COMPOUND_SINGLEREF
     NEARESTMV,  // NEAREST_NEARESTMV
     NEARMV,     // NEAR_NEARMV
     NEARESTMV,  // NEAREST_NEWMV
     NEWMV,      // NEW_NEARESTMV
     NEARMV,     // NEAR_NEWMV
     NEWMV,      // NEW_NEARMV
     ZEROMV,     // ZERO_ZEROMV
     NEWMV,      // NEW_NEWMV
   };
   assert(NELEMENTS(lut) == MB_MODE_COUNT);
+#if CONFIG_COMPOUND_SINGLEREF
+  assert(is_inter_anyref_comp_mode(mode));
+#else   // !CONFIG_COMPOUND_SINGLEREF
   assert(is_inter_compound_mode(mode));
+#endif  // CONFIG_COMPOUND_SINGLEREF
   return lut[mode];
 }
 
 static INLINE PREDICTION_MODE compound_ref1_mode(PREDICTION_MODE mode) {
   static PREDICTION_MODE lut[] = {
     MB_MODE_COUNT,  // DC_PRED
     MB_MODE_COUNT,  // V_PRED
     MB_MODE_COUNT,  // H_PRED
@@ -191,43 +198,54 @@ static INLINE PREDICTION_MODE compound_r
 #endif              // CONFIG_SMOOTH_HV
 #endif              // CONFIG_ALT_INTRA
     MB_MODE_COUNT,  // TM_PRED
     MB_MODE_COUNT,  // NEARESTMV
     MB_MODE_COUNT,  // NEARMV
     MB_MODE_COUNT,  // ZEROMV
     MB_MODE_COUNT,  // NEWMV
 #if CONFIG_COMPOUND_SINGLEREF
-    NEARMV,     // SR_NEAREST_NEARMV
-    NEWMV,      // SR_NEAREST_NEWMV
+    NEARMV,  // SR_NEAREST_NEARMV
+    // NEWMV,      // SR_NEAREST_NEWMV
     NEWMV,      // SR_NEAR_NEWMV
     NEWMV,      // SR_ZERO_NEWMV
     NEWMV,      // SR_NEW_NEWMV
 #endif          // CONFIG_COMPOUND_SINGLEREF
     NEARESTMV,  // NEAREST_NEARESTMV
     NEARMV,     // NEAR_NEARMV
     NEWMV,      // NEAREST_NEWMV
     NEARESTMV,  // NEW_NEARESTMV
     NEWMV,      // NEAR_NEWMV
     NEARMV,     // NEW_NEARMV
     ZEROMV,     // ZERO_ZEROMV
     NEWMV,      // NEW_NEWMV
   };
   assert(NELEMENTS(lut) == MB_MODE_COUNT);
+#if CONFIG_COMPOUND_SINGLEREF
+  assert(is_inter_anyref_comp_mode(mode));
+#else   // !CONFIG_COMPOUND_SINGLEREF
   assert(is_inter_compound_mode(mode));
+#endif  // CONFIG_COMPOUND_SINGLEREF
   return lut[mode];
 }
 
 static INLINE int have_nearmv_in_inter_mode(PREDICTION_MODE mode) {
   return (mode == NEARMV || mode == NEAR_NEARMV || mode == NEAR_NEWMV ||
+#if CONFIG_COMPOUND_SINGLEREF
+          mode == SR_NEAREST_NEARMV || mode == SR_NEAR_NEWMV ||
+#endif  // CONFIG_COMPOUND_SINGLEREF
           mode == NEW_NEARMV);
 }
 
 static INLINE int have_newmv_in_inter_mode(PREDICTION_MODE mode) {
   return (mode == NEWMV || mode == NEW_NEWMV || mode == NEAREST_NEWMV ||
+#if CONFIG_COMPOUND_SINGLEREF
+          /* mode == SR_NEAREST_NEWMV || */ mode == SR_NEAR_NEWMV ||
+          mode == SR_ZERO_NEWMV || mode == SR_NEW_NEWMV ||
+#endif  // CONFIG_COMPOUND_SINGLEREF
           mode == NEW_NEARESTMV || mode == NEAR_NEWMV || mode == NEW_NEARMV);
 }
 
 static INLINE int use_masked_motion_search(COMPOUND_TYPE type) {
 #if CONFIG_WEDGE
   return (type == COMPOUND_WEDGE);
 #else
   (void)type;
@@ -241,17 +259,18 @@ static INLINE int is_masked_compound_typ
 #elif !CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
   return (type == COMPOUND_WEDGE);
 #elif CONFIG_COMPOUND_SEGMENT && !CONFIG_WEDGE
   return (type == COMPOUND_SEG);
 #endif  // CONFIG_COMPOUND_SEGMENT
   (void)type;
   return 0;
 }
-#else
+
+#else   // !CONFIG_EXT_INTER
 
 static INLINE int have_nearmv_in_inter_mode(PREDICTION_MODE mode) {
   return (mode == NEARMV);
 }
 
 static INLINE int have_newmv_in_inter_mode(PREDICTION_MODE mode) {
   return (mode == NEWMV);
 }
@@ -408,16 +427,23 @@ typedef struct MB_MODE_INFO {
 #endif  // CONFIG_WEDGE
 #if CONFIG_COMPOUND_SEGMENT
   SEG_MASK_TYPE mask_type;
 #endif  // CONFIG_COMPOUND_SEGMENT
 #endif  // CONFIG_EXT_INTER
   MOTION_MODE motion_mode;
 #if CONFIG_MOTION_VAR
   int overlappable_neighbors[2];
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+  // Applying different weighting kernels in ncobmc
+  // In current implementation, interpolation modes only defined for squared
+  // blocks. A rectangular block is divided into two squared blocks and each
+  // squared block has an interpolation mode.
+  NCOBMC_MODE ncobmc_mode[2];
+#endif
 #endif  // CONFIG_MOTION_VAR
   int_mv mv[2];
   int_mv pred_mv[2];
   uint8_t ref_mv_idx;
 #if CONFIG_EXT_PARTITION_TYPES
   PARTITION_TYPE partition;
 #endif
 #if CONFIG_NEW_QUANT
@@ -478,16 +504,43 @@ static INLINE int is_inter_block(const M
 #endif
   return mbmi->ref_frame[0] > INTRA_FRAME;
 }
 
 static INLINE int has_second_ref(const MB_MODE_INFO *mbmi) {
   return mbmi->ref_frame[1] > INTRA_FRAME;
 }
 
+#if CONFIG_EXT_COMP_REFS
+static INLINE int has_uni_comp_refs(const MB_MODE_INFO *mbmi) {
+  return has_second_ref(mbmi) && (!((mbmi->ref_frame[0] >= BWDREF_FRAME) ^
+                                    (mbmi->ref_frame[1] >= BWDREF_FRAME)));
+}
+
+static INLINE MV_REFERENCE_FRAME comp_ref0(int ref_idx) {
+  static const MV_REFERENCE_FRAME lut[] = {
+    LAST_FRAME,    // LAST_LAST2_FRAMES,
+    LAST_FRAME,    // LAST_GOLDEN_FRAMES,
+    BWDREF_FRAME,  // BWDREF_ALTREF_FRAMES,
+  };
+  assert(NELEMENTS(lut) == UNIDIR_COMP_REFS);
+  return lut[ref_idx];
+}
+
+static INLINE MV_REFERENCE_FRAME comp_ref1(int ref_idx) {
+  static const MV_REFERENCE_FRAME lut[] = {
+    LAST2_FRAME,   // LAST_LAST2_FRAMES,
+    GOLDEN_FRAME,  // LAST_GOLDEN_FRAMES,
+    ALTREF_FRAME,  // BWDREF_ALTREF_FRAMES,
+  };
+  assert(NELEMENTS(lut) == UNIDIR_COMP_REFS);
+  return lut[ref_idx];
+}
+#endif  // CONFIG_EXT_COMP_REFS
+
 PREDICTION_MODE av1_left_block_mode(const MODE_INFO *cur_mi,
                                     const MODE_INFO *left_mi, int b);
 
 PREDICTION_MODE av1_above_block_mode(const MODE_INFO *cur_mi,
                                      const MODE_INFO *above_mi, int b);
 
 #if CONFIG_GLOBAL_MOTION
 static INLINE int is_global_mv_block(const MODE_INFO *mi, int block,
@@ -562,16 +615,21 @@ typedef struct macroblockd_plane {
 
 #define BLOCK_OFFSET(x, i) \
   ((x) + (i) * (1 << (tx_size_wide_log2[0] + tx_size_high_log2[0])))
 
 typedef struct RefBuffer {
   int idx;
   YV12_BUFFER_CONFIG *buf;
   struct scale_factors sf;
+#if CONFIG_VAR_REFS
+  // TODO(zoeliu): To evaluate whether "is_valid" is needed or the use of it can
+  // be simply replaced by checking the "idx".
+  int is_valid;
+#endif  // CONFIG_VAR_REFS
 } RefBuffer;
 
 #if CONFIG_ADAPT_SCAN
 typedef int16_t EobThresholdMD[TX_TYPES][EOB_THRESHOLD_NUM];
 #endif
 
 typedef struct macroblockd {
   struct macroblockd_plane plane[MAX_MB_PLANE];
@@ -681,16 +739,20 @@ typedef struct macroblockd {
   DECLARE_ALIGNED(16, uint8_t, seg_mask[2 * MAX_SB_SQUARE]);
 #endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SEGMENT
 
 #if CONFIG_CFL
   CFL_CTX *cfl;
 #endif
 } MACROBLOCKD;
 
+static INLINE int get_bitdepth_data_path_index(const MACROBLOCKD *xd) {
+  return xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH ? 1 : 0;
+}
+
 static INLINE BLOCK_SIZE get_subsize(BLOCK_SIZE bsize,
                                      PARTITION_TYPE partition) {
   if (partition == PARTITION_INVALID)
     return BLOCK_INVALID;
   else
     return subsize_lookup[partition][bsize];
 }
 
@@ -860,17 +922,17 @@ static INLINE int get_ext_tx_types(TX_SI
   const int set_type =
       get_ext_tx_set_type(tx_size, bs, is_inter, use_reduced_set);
   return num_ext_tx_set[set_type];
 }
 
 #if CONFIG_RECT_TX
 static INLINE int is_rect_tx_allowed_bsize(BLOCK_SIZE bsize) {
   static const char LUT[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     0,  // BLOCK_2X2
     0,  // BLOCK_2X4
     0,  // BLOCK_4X2
 #endif
     0,  // BLOCK_4X4
     1,  // BLOCK_4X8
     1,  // BLOCK_8X4
     0,  // BLOCK_8X8
@@ -897,17 +959,17 @@ static INLINE int is_rect_tx_allowed(con
                                      const MB_MODE_INFO *mbmi) {
   return is_rect_tx_allowed_bsize(mbmi->sb_type) &&
          !xd->lossless[mbmi->segment_id];
 }
 
 #if CONFIG_RECT_TX_EXT
 static INLINE int is_quarter_tx_allowed_bsize(BLOCK_SIZE bsize) {
   static const char LUT_QTTX[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     0,  // BLOCK_2X2
     0,  // BLOCK_2X4
     0,  // BLOCK_4X2
 #endif
     0,  // BLOCK_4X4
     0,  // BLOCK_4X8
     0,  // BLOCK_8X4
     0,  // BLOCK_8X8
@@ -1010,16 +1072,28 @@ static INLINE int av1_block_index_to_ras
 // Note: only implemented for transform sizes 4x4, 4x8 and 8x4 right now.
 static INLINE int av1_raster_order_to_block_index(TX_SIZE tx_size,
                                                   int raster_order) {
   assert(tx_size == TX_4X4 || tx_size == TX_4X8 || tx_size == TX_8X4);
   // We ensure that block indices are 0 & 2 if tx size is 4x8 or 8x4.
   return (tx_size == TX_4X4) ? raster_order : (raster_order > 0) ? 2 : 0;
 }
 
+#if CONFIG_DPCM_INTRA || CONFIG_LGT
+static INLINE PREDICTION_MODE get_prediction_mode(const MODE_INFO *mi,
+                                                  int plane, TX_SIZE tx_size,
+                                                  int block_idx) {
+  const MB_MODE_INFO *const mbmi = &mi->mbmi;
+  if (is_inter_block(mbmi)) return mbmi->mode;
+
+  int block_raster_idx = av1_block_index_to_raster_order(tx_size, block_idx);
+  return (plane == 0) ? get_y_mode(mi, block_raster_idx) : mbmi->uv_mode;
+}
+#endif
+
 static INLINE TX_TYPE get_default_tx_type(PLANE_TYPE plane_type,
                                           const MACROBLOCKD *xd, int block_idx,
                                           TX_SIZE tx_size) {
   const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
 
   if (is_inter_block(mbmi) || plane_type != PLANE_TYPE_Y ||
       xd->lossless[mbmi->segment_id] || tx_size >= TX_32X32)
     return DCT_DCT;
@@ -1028,16 +1102,17 @@ static INLINE TX_TYPE get_default_tx_typ
                                            ? get_y_mode(xd->mi[0], block_idx)
                                            : mbmi->uv_mode];
 }
 
 static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type, const MACROBLOCKD *xd,
                                   int block, TX_SIZE tx_size) {
   const MODE_INFO *const mi = xd->mi[0];
   const MB_MODE_INFO *const mbmi = &mi->mbmi;
+
 #if CONFIG_INTRABC && (!CONFIG_EXT_TX || CONFIG_TXK_SEL)
   // TODO(aconverse@google.com): Handle INTRABC + EXT_TX + TXK_SEL
   if (is_intrabc_block(mbmi)) return DCT_DCT;
 #endif  // CONFIG_INTRABC && (!CONFIG_EXT_TX || CONFIG_TXK_SEL)
 #if !CONFIG_TXK_SEL
 #if FIXED_TX_TYPE
   const int block_raster_idx = av1_block_index_to_raster_order(tx_size, block);
   return get_default_tx_type(plane_type, xd, block_raster_idx, tx_size);
@@ -1091,17 +1166,17 @@ static INLINE TX_TYPE get_tx_type(PLANE_
       txsize_sqr_map[tx_size] >= TX_32X32)
     return DCT_DCT;
   return mbmi->tx_type;
 #endif  // CONFIG_EXT_TX
 #else   // !CONFIG_TXK_SEL
   (void)tx_size;
   TX_TYPE tx_type;
   if (plane_type != PLANE_TYPE_Y || xd->lossless[mbmi->segment_id] ||
-      mbmi->tx_size >= TX_32X32) {
+      txsize_sqr_map[tx_size] >= TX_32X32) {
     tx_type = DCT_DCT;
   } else {
     tx_type = mbmi->txk_type[block];
   }
   assert(tx_type >= DCT_DCT && tx_type < TX_TYPES);
   return tx_type;
 #endif  // !CONFIG_TXK_SEL
 }
@@ -1161,23 +1236,16 @@ void av1_foreach_transformed_block_in_pl
 
 #if CONFIG_LV_MAP
 void av1_foreach_transformed_block(const MACROBLOCKD *const xd,
                                    BLOCK_SIZE bsize, int mi_row, int mi_col,
                                    foreach_transformed_block_visitor visit,
                                    void *arg);
 #endif
 
-#if CONFIG_DAALA_DIST
-void av1_foreach_8x8_transformed_block_in_yplane(
-    const MACROBLOCKD *const xd, BLOCK_SIZE bsize,
-    foreach_transformed_block_visitor visit,
-    foreach_transformed_block_visitor mi_visit, void *arg);
-#endif
-
 #if CONFIG_COEF_INTERLEAVE
 static INLINE int get_max_4x4_size(int num_4x4, int mb_to_edge,
                                    int subsampling) {
   return num_4x4 + (mb_to_edge >= 0 ? 0 : mb_to_edge >> (5 + subsampling));
 }
 
 void av1_foreach_transformed_block_interleave(
     const MACROBLOCKD *const xd, BLOCK_SIZE bsize,
@@ -1253,17 +1321,21 @@ static INLINE int get_vartx_max_txsize(c
 
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 static INLINE int is_motion_variation_allowed_bsize(BLOCK_SIZE bsize) {
   return (bsize >= BLOCK_8X8);
 }
 
 static INLINE int is_motion_variation_allowed_compound(
     const MB_MODE_INFO *mbmi) {
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  if (!has_second_ref(mbmi) && !is_inter_singleref_comp_mode(mbmi->mode))
+#else
   if (!has_second_ref(mbmi))
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
     return 1;
   else
     return 0;
 }
 
 #if CONFIG_MOTION_VAR
 // input: log2 of length, 0(4), 1(8), ...
 static const int max_neighbor_obmc[6] = { 0, 1, 2, 3, 4, 4 };
@@ -1305,27 +1377,66 @@ static INLINE MOTION_MODE motion_mode_al
 #else
     return SIMPLE_TRANSLATION;
 #endif  // CONFIG_MOTION_VAR
   } else {
     return SIMPLE_TRANSLATION;
   }
 }
 
+#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
+static INLINE NCOBMC_MODE ncobmc_mode_allowed_bsize(BLOCK_SIZE bsize) {
+  if (bsize < BLOCK_8X8 || bsize > BLOCK_64X64)
+    return NO_OVERLAP;
+  else
+    return (NCOBMC_MODE)(MAX_NCOBMC_MODES - 1);
+}
+
+static INLINE MOTION_MODE
+motion_mode_allowed_wrapper(int for_mv_search,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                            int block, const WarpedMotionParams *gm_params,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                            const MODE_INFO *mi) {
+  const MB_MODE_INFO *mbmi = &mi->mbmi;
+  MOTION_MODE motion_mode_for_mv_search = motion_mode_allowed(
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+      int block, const WarpedMotionParams *gm_params,
+#endif
+      mi);
+  int ncobmc_mode_allowed =
+      ncobmc_mode_allowed_bsize(mbmi->sb_type) && is_inter_mode(mbmi->mode);
+  if (for_mv_search)
+    return motion_mode_for_mv_search;
+  else
+    return ncobmc_mode_allowed ? NCOBMC_ADAPT_WEIGHT
+                               : motion_mode_for_mv_search;
+}
+#endif
+
 static INLINE void assert_motion_mode_valid(MOTION_MODE mode,
 #if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
                                             int block,
                                             const WarpedMotionParams *gm_params,
 #endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
                                             const MODE_INFO *mi) {
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+  const MOTION_MODE last_motion_mode_allowed =
+      motion_mode_allowed_wrapper(0,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                  block, gm_params,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                  mi);
+#else
   const MOTION_MODE last_motion_mode_allowed = motion_mode_allowed(
 #if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
       block, gm_params,
 #endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
       mi);
+#endif
   // Check that the input mode is not illegal
   if (last_motion_mode_allowed < mode)
     assert(0 && "Illegal motion mode selected");
 }
 
 #if CONFIG_MOTION_VAR
 static INLINE int is_neighbor_overlappable(const MB_MODE_INFO *mbmi) {
   return (is_inter_block(mbmi));
@@ -1376,21 +1487,20 @@ static INLINE int is_nontrans_global_mot
   if (mbmi->sb_type >= BLOCK_8X8 || unify_bsize) {
 #if CONFIG_EXT_INTER
     if (mbmi->mode != ZEROMV && mbmi->mode != ZERO_ZEROMV) return 0;
 #else
     if (mbmi->mode != ZEROMV) return 0;
 #endif  // CONFIG_EXT_INTER
   } else {
 #if CONFIG_EXT_INTER
-    if (mi->bmi[0].as_mode != ZEROMV || mi->bmi[1].as_mode != ZEROMV ||
-        mi->bmi[2].as_mode != ZEROMV || mi->bmi[3].as_mode != ZEROMV ||
-        mi->bmi[0].as_mode != ZERO_ZEROMV ||
-        mi->bmi[1].as_mode != ZERO_ZEROMV ||
-        mi->bmi[2].as_mode != ZERO_ZEROMV || mi->bmi[3].as_mode != ZERO_ZEROMV)
+    if ((mi->bmi[0].as_mode != ZEROMV && mi->bmi[0].as_mode != ZERO_ZEROMV) ||
+        (mi->bmi[1].as_mode != ZEROMV && mi->bmi[1].as_mode != ZERO_ZEROMV) ||
+        (mi->bmi[2].as_mode != ZEROMV && mi->bmi[2].as_mode != ZERO_ZEROMV) ||
+        (mi->bmi[3].as_mode != ZEROMV && mi->bmi[3].as_mode != ZERO_ZEROMV))
       return 0;
 #else
     if (mi->bmi[0].as_mode != ZEROMV || mi->bmi[1].as_mode != ZEROMV ||
         mi->bmi[2].as_mode != ZEROMV || mi->bmi[3].as_mode != ZEROMV)
       return 0;
 #endif  // CONFIG_EXT_INTER
   }
 
--- a/third_party/aom/av1/common/cdef.c
+++ b/third_party/aom/av1/common/cdef.c
@@ -221,37 +221,35 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *
         dering_left = 0;
         continue;
       }
       if (!dering_left) cstart = -OD_FILT_HBORDER;
       nhb = AOMMIN(MAX_MIB_SIZE, cm->mi_cols - MAX_MIB_SIZE * sbc);
       nvb = AOMMIN(MAX_MIB_SIZE, cm->mi_rows - MAX_MIB_SIZE * sbr);
       int tile_top, tile_left, tile_bottom, tile_right;
       int mi_idx = MAX_MIB_SIZE * sbr * cm->mi_stride + MAX_MIB_SIZE * sbc;
-      BOUNDARY_TYPE boundary_tl =
-          cm->mi_grid_visible[MAX_MIB_SIZE * sbr * cm->mi_stride +
-                              MAX_MIB_SIZE * sbc]
-              ->mbmi.boundary_info;
+      MODE_INFO *const mi_tl = cm->mi + mi_idx;
+      BOUNDARY_TYPE boundary_tl = mi_tl->mbmi.boundary_info;
       tile_top = boundary_tl & TILE_ABOVE_BOUNDARY;
       tile_left = boundary_tl & TILE_LEFT_BOUNDARY;
-      /* Right and bottom information appear unreliable, so we use the top
-         and left flags for the next superblocks. */
+
       if (sbr != nvsb - 1 &&
-          cm->mi_grid_visible[mi_idx + MAX_MIB_SIZE * cm->mi_stride])
-        tile_bottom = cm->mi_grid_visible[mi_idx + MAX_MIB_SIZE * cm->mi_stride]
-                          ->mbmi.boundary_info &
-                      TILE_ABOVE_BOUNDARY;
+          (&cm->mi[mi_idx + (MAX_MIB_SIZE - 1) * cm->mi_stride]))
+        tile_bottom = cm->mi[mi_idx + (MAX_MIB_SIZE - 1) * cm->mi_stride]
+                          .mbmi.boundary_info &
+                      TILE_BOTTOM_BOUNDARY;
       else
         tile_bottom = 1;
-      if (sbc != nhsb - 1 && cm->mi_grid_visible[mi_idx + MAX_MIB_SIZE])
-        tile_right =
-            cm->mi_grid_visible[mi_idx + MAX_MIB_SIZE]->mbmi.boundary_info &
-            TILE_LEFT_BOUNDARY;
+
+      if (sbc != nhsb - 1 && (&cm->mi[mi_idx + MAX_MIB_SIZE - 1]))
+        tile_right = cm->mi[mi_idx + MAX_MIB_SIZE - 1].mbmi.boundary_info &
+                     TILE_RIGHT_BOUNDARY;
       else
         tile_right = 1;
+
       const int mbmi_cdef_strength =
           cm->mi_grid_visible[MAX_MIB_SIZE * sbr * cm->mi_stride +
                               MAX_MIB_SIZE * sbc]
               ->mbmi.cdef_strength;
       level = cm->cdef_strengths[mbmi_cdef_strength] / CLPF_STRENGTHS;
       clpf_strength = cm->cdef_strengths[mbmi_cdef_strength] % CLPF_STRENGTHS;
       clpf_strength += clpf_strength == 3;
       uv_level = cm->cdef_uv_strengths[mbmi_cdef_strength] / CLPF_STRENGTHS;
--- a/third_party/aom/av1/common/cdef.h
+++ b/third_party/aom/av1/common/cdef.h
@@ -40,14 +40,14 @@ extern "C" {
 #endif
 
 int sb_all_skip(const AV1_COMMON *const cm, int mi_row, int mi_col);
 int sb_compute_dering_list(const AV1_COMMON *const cm, int mi_row, int mi_col,
                            dering_list *dlist, int filter_skip);
 void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm, MACROBLOCKD *xd);
 
 void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
-                     AV1_COMMON *cm, MACROBLOCKD *xd);
+                     AV1_COMMON *cm, MACROBLOCKD *xd, int fast);
 
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 #endif  // AV1_COMMON_DERING_H_
--- a/third_party/aom/av1/common/cfl.c
+++ b/third_party/aom/av1/common/cfl.c
@@ -10,49 +10,135 @@
  */
 
 #include "av1/common/cfl.h"
 #include "av1/common/common_data.h"
 #include "av1/common/onyxc_int.h"
 
 #include "aom/internal/aom_codec_internal.h"
 
-void cfl_init(CFL_CTX *cfl, AV1_COMMON *cm, int subsampling_x,
-              int subsampling_y) {
-  if (!((subsampling_x == 0 && subsampling_y == 0) ||
-        (subsampling_x == 1 && subsampling_y == 1))) {
+void cfl_init(CFL_CTX *cfl, AV1_COMMON *cm) {
+  if (!((cm->subsampling_x == 0 && cm->subsampling_y == 0) ||
+        (cm->subsampling_x == 1 && cm->subsampling_y == 1))) {
     aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
                        "Only 4:4:4 and 4:2:0 are currently supported by CfL");
   }
   memset(&cfl->y_pix, 0, sizeof(uint8_t) * MAX_SB_SQUARE);
-  cfl->subsampling_x = subsampling_x;
-  cfl->subsampling_y = subsampling_y;
+  cfl->subsampling_x = cm->subsampling_x;
+  cfl->subsampling_y = cm->subsampling_y;
+  cfl->are_parameters_computed = 0;
+}
+
+// Load from the CfL pixel buffer into output
+static void cfl_load(CFL_CTX *cfl, int row, int col, int width, int height) {
+  const int sub_x = cfl->subsampling_x;
+  const int sub_y = cfl->subsampling_y;
+  const int off_log2 = tx_size_wide_log2[0];
+
+  // TODO(ltrudeau) convert to uint16 to add HBD support
+  const uint8_t *y_pix;
+  // TODO(ltrudeau) convert to uint16 to add HBD support
+  uint8_t *output = cfl->y_down_pix;
+
+  int pred_row_offset = 0;
+  int output_row_offset = 0;
+
+  // TODO(ltrudeau) should be faster to downsample when we store the values
+  // TODO(ltrudeau) add support for 4:2:2
+  if (sub_y == 0 && sub_x == 0) {
+    y_pix = &cfl->y_pix[(row * MAX_SB_SIZE + col) << off_log2];
+    for (int j = 0; j < height; j++) {
+      for (int i = 0; i < width; i++) {
+        // In 4:4:4, pixels match 1 to 1
+        output[output_row_offset + i] = y_pix[pred_row_offset + i];
+      }
+      pred_row_offset += MAX_SB_SIZE;
+      output_row_offset += MAX_SB_SIZE;
+    }
+  } else if (sub_y == 1 && sub_x == 1) {
+    y_pix = &cfl->y_pix[(row * MAX_SB_SIZE + col) << (off_log2 + sub_y)];
+    for (int j = 0; j < height; j++) {
+      for (int i = 0; i < width; i++) {
+        int top_left = (pred_row_offset + i) << sub_y;
+        int bot_left = top_left + MAX_SB_SIZE;
+        // In 4:2:0, average pixels in 2x2 grid
+        output[output_row_offset + i] = OD_SHR_ROUND(
+            y_pix[top_left] + y_pix[top_left + 1]        // Top row
+                + y_pix[bot_left] + y_pix[bot_left + 1]  // Bottom row
+            ,
+            2);
+      }
+      pred_row_offset += MAX_SB_SIZE;
+      output_row_offset += MAX_SB_SIZE;
+    }
+  } else {
+    assert(0);  // Unsupported chroma subsampling
+  }
+  // Due to frame boundary issues, it is possible that the total area of
+  // covered by Chroma exceeds that of Luma. When this happens, we write over
+  // the broken data by repeating the last columns and/or rows.
+  //
+  // Note that in order to manage the case where both rows and columns
+  // overrun,
+  // we apply rows first. This way, when the rows overrun the bottom of the
+  // frame, the columns will be copied over them.
+  const int uv_width = (col << off_log2) + width;
+  const int uv_height = (row << off_log2) + height;
+
+  const int diff_width = uv_width - (cfl->y_width >> sub_x);
+  const int diff_height = uv_height - (cfl->y_height >> sub_y);
+
+  if (diff_width > 0) {
+    int last_pixel;
+    output_row_offset = width - diff_width;
+
+    for (int j = 0; j < height; j++) {
+      last_pixel = output_row_offset - 1;
+      for (int i = 0; i < diff_width; i++) {
+        output[output_row_offset + i] = output[last_pixel];
+      }
+      output_row_offset += MAX_SB_SIZE;
+    }
+  }
+
+  if (diff_height > 0) {
+    output_row_offset = (height - diff_height) * MAX_SB_SIZE;
+    const int last_row_offset = output_row_offset - MAX_SB_SIZE;
+
+    for (int j = 0; j < diff_height; j++) {
+      for (int i = 0; i < width; i++) {
+        output[output_row_offset + i] = output[last_row_offset + i];
+      }
+      output_row_offset += MAX_SB_SIZE;
+    }
+  }
 }
 
 // CfL computes its own block-level DC_PRED. This is required to compute both
 // alpha_cb and alpha_cr before the prediction are computed.
-void cfl_dc_pred(MACROBLOCKD *xd, BLOCK_SIZE plane_bsize, TX_SIZE tx_size) {
+static void cfl_dc_pred(MACROBLOCKD *xd, BLOCK_SIZE plane_bsize) {
   const struct macroblockd_plane *const pd_u = &xd->plane[AOM_PLANE_U];
   const struct macroblockd_plane *const pd_v = &xd->plane[AOM_PLANE_V];
 
   const uint8_t *const dst_u = pd_u->dst.buf;
   const uint8_t *const dst_v = pd_v->dst.buf;
 
   const int dst_u_stride = pd_u->dst.stride;
   const int dst_v_stride = pd_v->dst.stride;
 
-  const int block_width = (plane_bsize != BLOCK_INVALID)
-                              ? block_size_wide[plane_bsize]
-                              : tx_size_wide[tx_size];
-  const int block_height = (plane_bsize != BLOCK_INVALID)
-                               ? block_size_high[plane_bsize]
-                               : tx_size_high[tx_size];
+  CFL_CTX *const cfl = xd->cfl;
 
+  // Compute DC_PRED until block boundary. We can't assume the neighbor will use
+  // the same transform size.
+  const int width = max_block_wide(xd, plane_bsize, AOM_PLANE_U)
+                    << tx_size_wide_log2[0];
+  const int height = max_block_high(xd, plane_bsize, AOM_PLANE_U)
+                     << tx_size_high_log2[0];
   // Number of pixel on the top and left borders.
-  const double num_pel = block_width + block_height;
+  const int num_pel = width + height;
 
   int sum_u = 0;
   int sum_v = 0;
 
 // Match behavior of build_intra_predictors (reconintra.c) at superblock
 // boundaries:
 //
 // 127 127 127 .. 127 127 127 127 127 127
@@ -63,181 +149,238 @@ void cfl_dc_pred(MACROBLOCKD *xd, BLOCK_
 // ..
 
 #if CONFIG_CHROMA_SUB8X8
   if (xd->chroma_up_available && xd->mb_to_right_edge >= 0) {
 #else
   if (xd->up_available && xd->mb_to_right_edge >= 0) {
 #endif
     // TODO(ltrudeau) replace this with DC_PRED assembly
-    for (int i = 0; i < block_width; i++) {
+    for (int i = 0; i < width; i++) {
       sum_u += dst_u[-dst_u_stride + i];
       sum_v += dst_v[-dst_v_stride + i];
     }
   } else {
-    sum_u = block_width * 127;
-    sum_v = block_width * 127;
+    sum_u = width * 127;
+    sum_v = width * 127;
   }
 
 #if CONFIG_CHROMA_SUB8X8
   if (xd->chroma_left_available && xd->mb_to_bottom_edge >= 0) {
 #else
   if (xd->left_available && xd->mb_to_bottom_edge >= 0) {
 #endif
-    for (int i = 0; i < block_height; i++) {
+    for (int i = 0; i < height; i++) {
       sum_u += dst_u[i * dst_u_stride - 1];
       sum_v += dst_v[i * dst_v_stride - 1];
     }
   } else {
-    sum_u += block_height * 129;
-    sum_v += block_height * 129;
+    sum_u += height * 129;
+    sum_v += height * 129;
   }
 
-  xd->cfl->dc_pred[CFL_PRED_U] = sum_u / num_pel;
-  xd->cfl->dc_pred[CFL_PRED_V] = sum_v / num_pel;
+  // TODO(ltrudeau) Because of max_block_wide and max_block_high, num_pel will
+  // not be a power of two. So these divisions will have to use a lookup table.
+  cfl->dc_pred[CFL_PRED_U] = (sum_u + (num_pel >> 1)) / num_pel;
+  cfl->dc_pred[CFL_PRED_V] = (sum_v + (num_pel >> 1)) / num_pel;
+}
+
+static void cfl_compute_averages(CFL_CTX *cfl, TX_SIZE tx_size) {
+  const int width = cfl->uv_width;
+  const int height = cfl->uv_height;
+  const int tx_height = tx_size_high[tx_size];
+  const int tx_width = tx_size_wide[tx_size];
+  const int stride = width >> tx_size_wide_log2[tx_size];
+  const int block_row_stride = MAX_SB_SIZE << tx_size_high_log2[tx_size];
+  const int num_pel_log2 =
+      (tx_size_high_log2[tx_size] + tx_size_wide_log2[tx_size]);
+
+  // TODO(ltrudeau) Convert to uint16 for HBD support
+  const uint8_t *y_pix = cfl->y_down_pix;
+  // TODO(ltrudeau) Convert to uint16 for HBD support
+  const uint8_t *t_y_pix;
+  int *averages_q3 = cfl->y_averages_q3;
+
+  cfl_load(cfl, 0, 0, width, height);
+
+  int a = 0;
+  for (int b_j = 0; b_j < height; b_j += tx_height) {
+    for (int b_i = 0; b_i < width; b_i += tx_width) {
+      int sum = 0;
+      t_y_pix = y_pix;
+      for (int t_j = 0; t_j < tx_height; t_j++) {
+        for (int t_i = b_i; t_i < b_i + tx_width; t_i++) {
+          sum += t_y_pix[t_i];
+        }
+        t_y_pix += MAX_SB_SIZE;
+      }
+      averages_q3[a++] =
+          ((sum << 3) + (1 << (num_pel_log2 - 1))) >> num_pel_log2;
+
+      // Loss is never more than 1/2 (in Q3)
+      assert(fabs((double)averages_q3[a - 1] -
+                  (sum / ((double)(1 << num_pel_log2))) * (1 << 3)) <= 0.5);
+    }
+    assert(a % stride == 0);
+    y_pix += block_row_stride;
+  }
+
+  cfl->y_averages_stride = stride;
+  assert(a <= MAX_NUM_TXB);
+}
+
+static INLINE double cfl_idx_to_alpha(int alpha_idx, CFL_SIGN_TYPE alpha_sign,
+                                      CFL_PRED_TYPE pred_type) {
+  const int mag_idx = cfl_alpha_codes[alpha_idx][pred_type];
+  const double abs_alpha = cfl_alpha_mags[mag_idx];
+  if (alpha_sign == CFL_SIGN_POS) {
+    return abs_alpha;
+  } else {
+    assert(abs_alpha != 0.0);
+    assert(cfl_alpha_mags[mag_idx + 1] == -abs_alpha);
+    return -abs_alpha;
+  }
 }
 
 // Predict the current transform block using CfL.
-void cfl_predict_block(const CFL_CTX *cfl, uint8_t *dst, int dst_stride,
-                       int row, int col, TX_SIZE tx_size, double dc_pred,
-                       double alpha) {
+void cfl_predict_block(MACROBLOCKD *const xd, uint8_t *dst, int dst_stride,
+                       int row, int col, TX_SIZE tx_size, int plane) {
+  CFL_CTX *const cfl = xd->cfl;
+  MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+
+  // CfL parameters must be computed before prediction can be done.
+  assert(cfl->are_parameters_computed == 1);
+
   const int width = tx_size_wide[tx_size];
   const int height = tx_size_high[tx_size];
+  // TODO(ltrudeau) Convert to uint16 to support HBD
+  const uint8_t *y_pix = cfl->y_down_pix;
 
-  const double y_avg = cfl_load(cfl, dst, dst_stride, row, col, width, height);
+  const int dc_pred = cfl->dc_pred[plane - 1];
+  const double alpha = cfl_idx_to_alpha(
+      mbmi->cfl_alpha_idx, mbmi->cfl_alpha_signs[plane - 1], plane - 1);
+  // TODO(ltrudeau) Convert alpha to fixed point.
+  const int alpha_q3 = (int)(alpha * 8);
 
+  const int avg_row =
+      (row << tx_size_wide_log2[0]) >> tx_size_wide_log2[tx_size];
+  const int avg_col =
+      (col << tx_size_high_log2[0]) >> tx_size_high_log2[tx_size];
+  const int avg_q3 =
+      cfl->y_averages_q3[cfl->y_averages_stride * avg_row + avg_col];
+
+  cfl_load(cfl, row, col, width, height);
   for (int j = 0; j < height; j++) {
     for (int i = 0; i < width; i++) {
-      dst[i] = (uint8_t)(alpha * (dst[i] - y_avg) + dc_pred + 0.5);
+      // TODO(ltrudeau) add support for HBD.
+      dst[i] =
+          clip_pixel(get_scaled_luma_q0(alpha_q3, y_pix[i], avg_q3) + dc_pred);
     }
     dst += dst_stride;
+    y_pix += MAX_SB_SIZE;
   }
 }
 
 void cfl_store(CFL_CTX *cfl, const uint8_t *input, int input_stride, int row,
-               int col, TX_SIZE tx_size) {
+               int col, TX_SIZE tx_size, BLOCK_SIZE bsize) {
   const int tx_width = tx_size_wide[tx_size];
   const int tx_height = tx_size_high[tx_size];
   const int tx_off_log2 = tx_size_wide_log2[0];
 
-  // Store the input into the CfL pixel buffer
-  uint8_t *y_pix = &cfl->y_pix[(row * MAX_SB_SIZE + col) << tx_off_log2];
+#if CONFIG_CHROMA_SUB8X8
+  if (bsize < BLOCK_8X8) {
+#if CONFIG_DEBUG
+    // Transform cannot be smaller than
+    assert(tx_width >= 4);
+    assert(tx_height >= 4);
+#endif
 
-  // Check that we remain inside the pixel buffer.
-  assert(MAX_SB_SIZE * (row + tx_height - 1) + col + tx_width - 1 <
-         MAX_SB_SQUARE);
+    const int bw = block_size_wide[bsize];
+    const int bh = block_size_high[bsize];
+
+    // For chroma_sub8x8, the CfL prediction for prediction blocks smaller than
+    // 8X8 uses non chroma reference reconstructed luma pixels. To do so, we
+    // combine the 4X4 non chroma reference into the CfL pixel buffers based on
+    // their row and column index.
 
-  for (int j = 0; j < tx_height; j++) {
-    for (int i = 0; i < tx_width; i++) {
-      y_pix[i] = input[i];
+    // The following code is adapted from the is_chroma_reference() function.
+    if ((cfl->mi_row &
+         0x01)        // Increment the row index for odd indexed 4X4 blocks
+        && (bh == 4)  // But not for 4X8 blocks
+        && cfl->subsampling_y) {  // And only when chroma is subsampled
+      assert(row == 0);
+      row++;
     }
-    y_pix += MAX_SB_SIZE;
-    input += input_stride;
+
+    if ((cfl->mi_col &
+         0x01)        // Increment the col index for odd indexed 4X4 blocks
+        && (bw == 4)  // But not for 8X4 blocks
+        && cfl->subsampling_x) {  // And only when chroma is subsampled
+      assert(col == 0);
+      col++;
+    }
   }
+#endif
+
+  // Invalidate current parameters
+  cfl->are_parameters_computed = 0;
 
   // Store the surface of the pixel buffer that was written to, this way we
   // can manage chroma overrun (e.g. when the chroma surfaces goes beyond the
   // frame boundary)
   if (col == 0 && row == 0) {
     cfl->y_width = tx_width;
     cfl->y_height = tx_height;
   } else {
     cfl->y_width = OD_MAXI((col << tx_off_log2) + tx_width, cfl->y_width);
     cfl->y_height = OD_MAXI((row << tx_off_log2) + tx_height, cfl->y_height);
   }
+
+  // Check that we will remain inside the pixel buffer.
+  assert((row << tx_off_log2) + tx_height <= MAX_SB_SIZE);
+  assert((col << tx_off_log2) + tx_width <= MAX_SB_SIZE);
+
+  // Store the input into the CfL pixel buffer
+  uint8_t *y_pix = &cfl->y_pix[(row * MAX_SB_SIZE + col) << tx_off_log2];
+
+  // TODO(ltrudeau) Speedup possible by moving the downsampling to cfl_store
+  for (int j = 0; j < tx_height; j++) {
+    for (int i = 0; i < tx_width; i++) {
+      y_pix[i] = input[i];
+    }
+    y_pix += MAX_SB_SIZE;
+    input += input_stride;
+  }
 }
 
-// Load from the CfL pixel buffer into output
-double cfl_load(const CFL_CTX *cfl, uint8_t *output, int output_stride, int row,
-                int col, int width, int height) {
-  const int sub_x = cfl->subsampling_x;
-  const int sub_y = cfl->subsampling_y;
-  const int tx_off_log2 = tx_size_wide_log2[0];
+void cfl_compute_parameters(MACROBLOCKD *const xd, TX_SIZE tx_size) {
+  CFL_CTX *const cfl = xd->cfl;
+  MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
 
-  const uint8_t *y_pix;
-
-  int diff_width = 0;
-  int diff_height = 0;
-
-  int pred_row_offset = 0;
-  int output_row_offset = 0;
-  int top_left, bot_left;
+  // Do not call cfl_compute_parameters multiple time on the same values.
+  assert(cfl->are_parameters_computed == 0);
 
-  // TODO(ltrudeau) add support for 4:2:2
-  if (sub_y == 0 && sub_x == 0) {
-    y_pix = &cfl->y_pix[(row * MAX_SB_SIZE + col) << tx_off_log2];
-    int uv_width = (col << tx_off_log2) + width;
-    diff_width = uv_width - cfl->y_width;
-    int uv_height = (row << tx_off_log2) + height;
-    diff_height = uv_height - cfl->y_height;
-    for (int j = 0; j < height; j++) {
-      for (int i = 0; i < width; i++) {
-        // In 4:4:4, pixels match 1 to 1
-        output[output_row_offset + i] = y_pix[pred_row_offset + i];
-      }
-      pred_row_offset += MAX_SB_SIZE;
-      output_row_offset += output_stride;
-    }
-  } else if (sub_y == 1 && sub_x == 1) {
-    y_pix = &cfl->y_pix[(row * MAX_SB_SIZE + col) << (tx_off_log2 + sub_y)];
-    int uv_width = ((col << tx_off_log2) + width) << sub_x;
-    diff_width = (uv_width - cfl->y_width) >> sub_x;
-    int uv_height = ((row << tx_off_log2) + height) << sub_y;
-    diff_height = (uv_height - cfl->y_height) >> sub_y;
-    for (int j = 0; j < height; j++) {
-      for (int i = 0; i < width; i++) {
-        top_left = (pred_row_offset + i) << sub_y;
-        bot_left = top_left + MAX_SB_SIZE;
-        // In 4:2:0, average pixels in 2x2 grid
-        output[output_row_offset + i] = OD_SHR_ROUND(
-            y_pix[top_left] + y_pix[top_left + 1]        // Top row
-                + y_pix[bot_left] + y_pix[bot_left + 1]  // Bottom row
-            ,
-            2);
-      }
-      pred_row_offset += MAX_SB_SIZE;
-      output_row_offset += output_stride;
-    }
-  } else {
-    assert(0);  // Unsupported chroma subsampling
+#if CONFIG_CHROMA_SUB8X8
+  const BLOCK_SIZE plane_bsize = AOMMAX(
+      BLOCK_4X4, get_plane_block_size(mbmi->sb_type, &xd->plane[AOM_PLANE_U]));
+#else
+  const BLOCK_SIZE plane_bsize =
+      get_plane_block_size(mbmi->sb_type, &xd->plane[AOM_PLANE_U]);
+#endif
+  // AOM_PLANE_U is used, but both planes will have the same sizes.
+  cfl->uv_width = max_intra_block_width(xd, plane_bsize, AOM_PLANE_U, tx_size);
+  cfl->uv_height =
+      max_intra_block_height(xd, plane_bsize, AOM_PLANE_U, tx_size);
+
+#if CONFIG_DEBUG
+  if (mbmi->sb_type >= BLOCK_8X8) {
+    assert(cfl->y_width <= cfl->uv_width << cfl->subsampling_x);
+    assert(cfl->y_height <= cfl->uv_height << cfl->subsampling_y);
   }
-  // Due to frame boundary issues, it is possible that the total area of
-  // covered by Chroma exceeds that of Luma. When this happens, we write over
-  // the broken data by repeating the last columns and/or rows.
-  //
-  // Note that in order to manage the case where both rows and columns
-  // overrun,
-  // we apply rows first. This way, when the rows overrun the bottom of the
-  // frame, the columns will be copied over them.
-  if (diff_width > 0) {
-    int last_pixel;
-    output_row_offset = width - diff_width;
-
-    for (int j = 0; j < height; j++) {
-      last_pixel = output_row_offset - 1;
-      for (int i = 0; i < diff_width; i++) {
-        output[output_row_offset + i] = output[last_pixel];
-      }
-      output_row_offset += output_stride;
-    }
-  }
+#endif
 
-  if (diff_height > 0) {
-    output_row_offset = diff_height * output_stride;
-    const int last_row_offset = output_row_offset - output_stride;
-    for (int j = 0; j < diff_height; j++) {
-      for (int i = 0; i < width; i++) {
-        output[output_row_offset + i] = output[last_row_offset + i];
-      }
-      output_row_offset += output_stride;
-    }
-  }
-
-  int avg = 0;
-  output_row_offset = 0;
-  for (int j = 0; j < height; j++) {
-    for (int i = 0; i < width; i++) {
-      avg += output[output_row_offset + i];
-    }
-    output_row_offset += output_stride;
-  }
-  return avg / (double)(width * height);
+  // Compute block-level DC_PRED for both chromatic planes.
+  // DC_PRED replaces beta in the linear model.
+  cfl_dc_pred(xd, plane_bsize);
+  // Compute transform-level average on reconstructed luma input.
+  cfl_compute_averages(cfl, tx_size);
+  cfl->are_parameters_computed = 1;
 }
--- a/third_party/aom/av1/common/cfl.h
+++ b/third_party/aom/av1/common/cfl.h
@@ -21,67 +21,73 @@
 typedef struct AV1Common AV1_COMMON;
 
 // Forward declaration of MACROBLOCK, in order to avoid creating a cyclic
 // dependency by importing av1/common/blockd.h
 typedef struct macroblockd MACROBLOCKD;
 
 typedef struct {
   // Pixel buffer containing the luma pixels used as prediction for chroma
+  // TODO(ltrudeau) Convert to uint16 for HBD support
   uint8_t y_pix[MAX_SB_SQUARE];
 
+  // Pixel buffer containing the downsampled luma pixels used as prediction for
+  // chroma
+  // TODO(ltrudeau) Convert to uint16 for HBD support
+  uint8_t y_down_pix[MAX_SB_SQUARE];
+
   // Height and width of the luma prediction block currently in the pixel buffer
   int y_height, y_width;
 
+  // Height and width of the chroma prediction block currently associated with
+  // this context
+  int uv_height, uv_width;
+
+  // Transform level averages of the luma reconstructed values over the entire
+  // prediction unit
+  // Fixed point y_averages is Q12.3:
+  //   * Worst case division is 1/1024
+  //   * Max error will be 1/16th.
+  // Note: 3 is chosen so that y_averages fits in 15 bits when 12 bit input is
+  // used
+  int y_averages_q3[MAX_NUM_TXB];
+  int y_averages_stride;
+
+  int are_parameters_computed;
+
   // Chroma subsampling
   int subsampling_x, subsampling_y;
 
-  // CfL Performs its own block level DC_PRED for each chromatic plane
-  double dc_pred[CFL_PRED_PLANES];
+  // Block level DC_PRED for each chromatic plane
+  int dc_pred[CFL_PRED_PLANES];
 
   // The rate associated with each alpha codeword
   int costs[CFL_ALPHABET_SIZE];
 
-  // Count the number of TX blocks in a predicted block to know when you are at
-  // the last one, so you can check for skips.
-  // TODO(any) Is there a better way to do this?
-  int num_tx_blk[CFL_PRED_PLANES];
+  int mi_row, mi_col;
 } CFL_CTX;
 
 static const double cfl_alpha_mags[CFL_MAGS_SIZE] = {
   0., 0.125, -0.125, 0.25, -0.25, 0.5, -0.5
 };
 
 static const int cfl_alpha_codes[CFL_ALPHABET_SIZE][CFL_PRED_PLANES] = {
   // barrbrain's simple 1D quant ordered by subset 3 likelihood
-  { 0, 0 }, { 1, 1 }, { 3, 0 }, { 3, 1 }, { 1, 0 }, { 3, 3 },
-  { 0, 1 }, { 5, 5 }, { 5, 3 }, { 1, 3 }, { 5, 3 }, { 3, 5 },
+  { 0, 0 }, { 1, 1 }, { 3, 0 }, { 3, 3 }, { 1, 0 }, { 3, 1 },
+  { 5, 5 }, { 0, 1 }, { 5, 3 }, { 5, 0 }, { 3, 5 }, { 1, 3 },
   { 0, 3 }, { 5, 1 }, { 1, 5 }, { 0, 5 }
 };
 
-void cfl_init(CFL_CTX *cfl, AV1_COMMON *cm, int subsampling_x,
-              int subsampling_y);
-
-void cfl_dc_pred(MACROBLOCKD *xd, BLOCK_SIZE plane_bsize, TX_SIZE tx_size);
-
-static INLINE double cfl_idx_to_alpha(int alpha_idx, CFL_SIGN_TYPE alpha_sign,
-                                      CFL_PRED_TYPE pred_type) {
-  const int mag_idx = cfl_alpha_codes[alpha_idx][pred_type];
-  const double abs_alpha = cfl_alpha_mags[mag_idx];
-  if (alpha_sign == CFL_SIGN_POS) {
-    return abs_alpha;
-  } else {
-    assert(abs_alpha != 0.0);
-    assert(cfl_alpha_mags[mag_idx + 1] == -abs_alpha);
-    return -abs_alpha;
-  }
+static INLINE int get_scaled_luma_q0(int alpha_q3, int y_pix, int avg_q3) {
+  return (alpha_q3 * ((y_pix << 3) - avg_q3) + 32) >> 6;
 }
 
-void cfl_predict_block(const CFL_CTX *cfl, uint8_t *dst, int dst_stride,
-                       int row, int col, TX_SIZE tx_size, double dc_pred,
-                       double alpha);
+void cfl_init(CFL_CTX *cfl, AV1_COMMON *cm);
+
+void cfl_predict_block(MACROBLOCKD *const xd, uint8_t *dst, int dst_stride,
+                       int row, int col, TX_SIZE tx_size, int plane);
 
 void cfl_store(CFL_CTX *cfl, const uint8_t *input, int input_stride, int row,
-               int col, TX_SIZE tx_size);
+               int col, TX_SIZE tx_size, BLOCK_SIZE bsize);
 
-double cfl_load(const CFL_CTX *cfl, uint8_t *output, int output_stride, int row,
-                int col, int width, int height);
+void cfl_compute_parameters(MACROBLOCKD *const xd, TX_SIZE tx_size);
+
 #endif  // AV1_COMMON_CFL_H_
--- a/third_party/aom/av1/common/common_data.h
+++ b/third_party/aom/av1/common/common_data.h
@@ -23,143 +23,153 @@ extern "C" {
 #if CONFIG_EXT_PARTITION
 #define IF_EXT_PARTITION(...) __VA_ARGS__,
 #else
 #define IF_EXT_PARTITION(...)
 #endif
 
 // Log 2 conversion lookup tables for block width and height
 static const uint8_t b_width_log2_lookup[BLOCK_SIZES_ALL] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   0, 0, 0,
 #endif
   0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, IF_EXT_PARTITION(4, 5, 5) 0, 2, 1, 3
 };
 static const uint8_t b_height_log2_lookup[BLOCK_SIZES_ALL] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   0, 0, 0,
 #endif
   0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, IF_EXT_PARTITION(5, 4, 5) 2, 0, 3, 1
 };
 // Log 2 conversion lookup tables for modeinfo width and height
 static const uint8_t mi_width_log2_lookup[BLOCK_SIZES_ALL] = {
 #if CONFIG_CB4X4
-  0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, IF_EXT_PARTITION(4, 5, 5) 0,
-  2, 1, 3
-#else
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+  0, 0, 0,
+#endif
+  0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, IF_EXT_PARTITION(4, 5, 5) 0, 2, 1, 3
+#else  // CONFIG_CB4X4
   0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, IF_EXT_PARTITION(3, 4, 4) 0, 1, 0, 2
 #endif
 };
 static const uint8_t mi_height_log2_lookup[BLOCK_SIZES_ALL] = {
 #if CONFIG_CB4X4
-  0, 0, 0, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, IF_EXT_PARTITION(5, 4, 5) 2,
-  0, 3, 1
-#else
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+  0, 0, 0,
+#endif
+  0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, IF_EXT_PARTITION(5, 4, 5) 2, 0, 3, 1
+#else  // CONFIG_CB4X4
   0, 0, 0, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, IF_EXT_PARTITION(4, 3, 4) 1, 0, 2, 0
 #endif
 };
 
 /* clang-format off */
 static const uint8_t mi_size_wide[BLOCK_SIZES_ALL] = {
 #if CONFIG_CB4X4
-  1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16,
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+  1, 1, 1,
+#endif
+  1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16,
   IF_EXT_PARTITION(16, 32, 32)  1, 4, 2, 8
-#else
+#else  // CONFIG_CB4X4
   1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, IF_EXT_PARTITION(8, 16, 16) 1, 2, 1, 4
 #endif
 };
 static const uint8_t mi_size_high[BLOCK_SIZES_ALL] = {
 #if CONFIG_CB4X4
-  1, 1, 1, 1, 2, 1, 2, 4, 2, 4, 8, 4, 8, 16, 8, 16,
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+  1, 1, 1,
+#endif
+  1, 2, 1, 2, 4, 2, 4, 8, 4, 8, 16, 8, 16,
   IF_EXT_PARTITION(32, 16, 32)  4, 1, 8, 2
-#else
+#else  // CONFIG_CB4X4
   1, 1, 1, 1, 2, 1, 2, 4, 2, 4, 8, 4, 8, IF_EXT_PARTITION(16, 8, 16) 2, 1, 4, 1
 #endif
 };
 /* clang-format on */
 
 // Width/height lookup tables in units of various block sizes
 static const uint8_t block_size_wide[BLOCK_SIZES_ALL] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   2,  2,  4,
 #endif
   4,  4,  8,  8,  8,  16, 16,
   16, 32, 32, 32, 64, 64, IF_EXT_PARTITION(64, 128, 128) 4,
   16, 8,  32
 };
 
 static const uint8_t block_size_high[BLOCK_SIZES_ALL] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   2,  4,  2,
 #endif
   4,  8,  4,  8,  16, 8,  16,
   32, 16, 32, 64, 32, 64, IF_EXT_PARTITION(128, 64, 128) 16,
   4,  32, 8
 };
 
 static const uint8_t num_4x4_blocks_wide_lookup[BLOCK_SIZES_ALL] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   1, 1, 1,
 #endif
   1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16, IF_EXT_PARTITION(16, 32, 32) 1,
   4, 2, 8
 };
 static const uint8_t num_4x4_blocks_high_lookup[BLOCK_SIZES_ALL] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   1, 1, 1,
 #endif
   1, 2, 1, 2, 4, 2, 4, 8, 4, 8, 16, 8, 16, IF_EXT_PARTITION(32, 16, 32) 4,
   1, 8, 2
 };
 static const uint8_t num_8x8_blocks_wide_lookup[BLOCK_SIZES_ALL] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   1, 1, 1,
 #endif
   1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, IF_EXT_PARTITION(8, 16, 16) 1, 2, 1, 4
 };
 static const uint8_t num_8x8_blocks_high_lookup[BLOCK_SIZES_ALL] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   1, 1, 1,
 #endif
   1, 1, 1, 1, 2, 1, 2, 4, 2, 4, 8, 4, 8, IF_EXT_PARTITION(16, 8, 16) 2, 1, 4, 1
 };
 static const uint8_t num_16x16_blocks_wide_lookup[BLOCK_SIZES_ALL] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   1, 1, 1,
 #endif
   1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4, 4, IF_EXT_PARTITION(4, 8, 8) 1, 1, 1, 2
 };
 static const uint8_t num_16x16_blocks_high_lookup[BLOCK_SIZES_ALL] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   1, 1, 1,
 #endif
   1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 4, 2, 4, IF_EXT_PARTITION(8, 4, 8) 1, 1, 2, 1
 };
 
 // AOMMIN(3, AOMMIN(b_width_log2(bsize), b_height_log2(bsize)))
 static const uint8_t size_group_lookup[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   0, 0, 0,
 #endif
   0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, IF_EXT_PARTITION(3, 3, 3)
 };
 
 static const uint8_t num_pels_log2_lookup[BLOCK_SIZES_ALL] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   2, 3, 3,
 #endif
   4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, IF_EXT_PARTITION(13, 13, 14) 6,
   6, 8, 8
 };
 
 /* clang-format off */
 static const PARTITION_TYPE
   partition_lookup[MAX_SB_SIZE_LOG2 - 1][BLOCK_SIZES] = {
   {     // 4X4 ->
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,            2X4,               4X2,
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #endif
     //                                    4X4
                                           PARTITION_NONE,
     // 4X8,            8X4,               8X8
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
     // 8X16,           16X8,              16X16
@@ -167,17 +177,17 @@ static const PARTITION_TYPE
     // 16X32,          32X16,             32X32
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
     // 32X64,          64X32,             64X64
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #if CONFIG_EXT_PARTITION
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #endif  // CONFIG_EXT_PARTITION
   }, {  // 8X8 ->
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,            2X4,               4X2,
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #endif
     //                                    4X4
                                           PARTITION_SPLIT,
     // 4X8,            8X4,               8X8
     PARTITION_VERT,    PARTITION_HORZ,    PARTITION_NONE,
     // 8X16,           16X8,              16X16
@@ -186,17 +196,17 @@ static const PARTITION_TYPE
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
     // 32X64,          64X32,             64X64
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #if CONFIG_EXT_PARTITION
     // 64x128,         128x64,            128x128
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #endif  // CONFIG_EXT_PARTITION
   }, {  // 16X16 ->
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,            2X4,               4X2,
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #endif
     //                                    4X4
                                           PARTITION_SPLIT,
     // 4X8,            8X4,               8X8
     PARTITION_SPLIT,   PARTITION_SPLIT,   PARTITION_SPLIT,
     // 8X16,           16X8,              16X16
@@ -205,17 +215,17 @@ static const PARTITION_TYPE
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
     // 32X64,          64X32,             64X64
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #if CONFIG_EXT_PARTITION
     // 64x128,         128x64,            128x128
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #endif  // CONFIG_EXT_PARTITION
   }, {  // 32X32 ->
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,            2X4,               4X2,
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #endif
     //                                    4X4
                                           PARTITION_SPLIT,
     // 4X8,            8X4,               8X8
     PARTITION_SPLIT,   PARTITION_SPLIT,   PARTITION_SPLIT,
     // 8X16,           16X8,              16X16
@@ -224,17 +234,17 @@ static const PARTITION_TYPE
     PARTITION_VERT,    PARTITION_HORZ,    PARTITION_NONE,
     // 32X64,          64X32,             64X64
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #if CONFIG_EXT_PARTITION
     // 64x128,         128x64,            128x128
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #endif  // CONFIG_EXT_PARTITION
   }, {  // 64X64 ->
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,            2X4,               4X2,
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #endif
     //                                    4X4
                                           PARTITION_SPLIT,
     // 4X8,            8X4,               8X8
     PARTITION_SPLIT,   PARTITION_SPLIT,   PARTITION_SPLIT,
     // 8X16,           16X8,              16X16
@@ -242,17 +252,17 @@ static const PARTITION_TYPE
     // 16X32,          32X16,             32X32
     PARTITION_SPLIT,   PARTITION_SPLIT,   PARTITION_SPLIT,
     // 32X64,          64X32,             64X64
     PARTITION_VERT,    PARTITION_HORZ,    PARTITION_NONE,
 #if CONFIG_EXT_PARTITION
     // 64x128,         128x64,            128x128
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
   }, {  // 128x128 ->
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,            2X4,               4X2,
     PARTITION_INVALID, PARTITION_INVALID, PARTITION_INVALID,
 #endif
     //                                    4X4
                                           PARTITION_SPLIT,
     // 4X8,            8X4,               8X8
     PARTITION_SPLIT,   PARTITION_SPLIT,   PARTITION_SPLIT,
     // 8X16,           16X8,              16X16
@@ -269,17 +279,17 @@ static const PARTITION_TYPE
 
 #if CONFIG_EXT_PARTITION_TYPES
 static const BLOCK_SIZE subsize_lookup[EXT_PARTITION_TYPES][BLOCK_SIZES] =
 #else
 static const BLOCK_SIZE subsize_lookup[PARTITION_TYPES][BLOCK_SIZES] =
 #endif  // CONFIG_EXT_PARTITION_TYPES
 {
   {     // PARTITION_NONE
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,        2X4,           4X2,
     BLOCK_2X2,     BLOCK_2X4,     BLOCK_4X2,
 #endif
     //                            4X4
                                   BLOCK_4X4,
     // 4X8,        8X4,           8X8
     BLOCK_4X8,     BLOCK_8X4,     BLOCK_8X8,
     // 8X16,       16X8,          16X16
@@ -288,17 +298,17 @@ static const BLOCK_SIZE subsize_lookup[P
     BLOCK_16X32,   BLOCK_32X16,   BLOCK_32X32,
     // 32X64,      64X32,         64X64
     BLOCK_32X64,   BLOCK_64X32,   BLOCK_64X64,
 #if CONFIG_EXT_PARTITION
     // 64x128,     128x64,        128x128
     BLOCK_64X128,  BLOCK_128X64,  BLOCK_128X128,
 #endif  // CONFIG_EXT_PARTITION
   }, {  // PARTITION_HORZ
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,        2X4,           4X2,
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
     //                            4X4
                                   BLOCK_4X2,
 #else
     //                            4X4
                                   BLOCK_INVALID,
 #endif
@@ -310,17 +320,17 @@ static const BLOCK_SIZE subsize_lookup[P
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X16,
     // 32X64,      64X32,         64X64
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X32,
 #if CONFIG_EXT_PARTITION
     // 64x128,     128x64,        128x128
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X64,
 #endif  // CONFIG_EXT_PARTITION
   }, {  // PARTITION_VERT
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,        2X4,           4X2,
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
     //                            4X4
                                   BLOCK_2X4,
 #else
     //                            4X4
                                   BLOCK_INVALID,
 #endif
@@ -332,17 +342,17 @@ static const BLOCK_SIZE subsize_lookup[P
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X32,
     // 32X64,      64X32,         64X64
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X64,
 #if CONFIG_EXT_PARTITION
     // 64x128,     128x64,        128x128
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X128,
 #endif  // CONFIG_EXT_PARTITION
   }, {  // PARTITION_SPLIT
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,        2X4,           4X2,
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
 #endif
     //                            4X4
                                   BLOCK_INVALID,
     // 4X8,        8X4,           8X8
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X4,
     // 8X16,       16X8,          16X16
@@ -352,17 +362,17 @@ static const BLOCK_SIZE subsize_lookup[P
     // 32X64,      64X32,         64X64
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X32,
 #if CONFIG_EXT_PARTITION
     // 64x128,     128x64,        128x128
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X64,
 #endif  // CONFIG_EXT_PARTITION
 #if CONFIG_EXT_PARTITION_TYPES
   }, {  // PARTITION_HORZ_A
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,        2X4,           4X2,
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
 #endif
     //                            4X4
                                   BLOCK_INVALID,
     // 4X8,        8X4,           8X8
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X4,
     // 8X16,       16X8,          16X16
@@ -371,17 +381,17 @@ static const BLOCK_SIZE subsize_lookup[P
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X16,
     // 32X64,      64X32,         64X64
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X32,
 #if CONFIG_EXT_PARTITION
     // 64x128,     128x64,        128x128
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X64,
 #endif  // CONFIG_EXT_PARTITION
   }, {  // PARTITION_HORZ_B
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,        2X4,           4X2,
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
 #endif
     //                            4X4
                                   BLOCK_INVALID,
     // 4X8,        8X4,           8X8
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X4,
     // 8X16,       16X8,          16X16
@@ -390,17 +400,17 @@ static const BLOCK_SIZE subsize_lookup[P
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X16,
     // 32X64,      64X32,         64X64
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X32,
 #if CONFIG_EXT_PARTITION
     // 64x128,     128x64,        128x128
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X64,
 #endif  // CONFIG_EXT_PARTITION
   }, {  // PARTITION_VERT_A
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,        2X4,           4X2,
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
 #endif
     //                            4X4
                                   BLOCK_INVALID,
     // 4X8,        8X4,           8X8
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X8,
     // 8X16,       16X8,          16X16
@@ -409,17 +419,17 @@ static const BLOCK_SIZE subsize_lookup[P
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X32,
     // 32X64,      64X32,         64X64
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X64,
 #if CONFIG_EXT_PARTITION
     // 64x128,     128x64,        128x128
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X128,
 #endif  // CONFIG_EXT_PARTITION
   }, {  // PARTITION_VERT_B
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     // 2X2,        2X4,           4X2,
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
 #endif
     //                            4X4
                                   BLOCK_INVALID,
     // 4X8,        8X4,           8X8
     BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X8,
     // 8X16,       16X8,          16X16
@@ -435,17 +445,17 @@ static const BLOCK_SIZE subsize_lookup[P
 #endif  // CONFIG_EXT_PARTITION_TYPES
   }
 };
 
 static const TX_SIZE max_txsize_lookup[BLOCK_SIZES] = {
   // 2X2,    2X4,      4X2,
 #if CONFIG_CHROMA_2X2
   TX_2X2,    TX_2X2,   TX_2X2,
-#elif CONFIG_CB4X4
+#elif CONFIG_CHROMA_SUB8X8
   TX_4X4,    TX_4X4,   TX_4X4,
 #endif
   //                   4X4
                        TX_4X4,
   // 4X8,    8X4,      8X8
   TX_4X4,    TX_4X4,   TX_8X8,
   // 8X16,   16X8,     16X16
   TX_8X8,    TX_8X8,   TX_16X16,
@@ -470,19 +480,19 @@ static const TX_SIZE max_txsize_lookup[B
 #endif  // CONFIG_TX64X64
 };
 
 #if CONFIG_RECT_TX && (CONFIG_EXT_TX || CONFIG_VAR_TX)
 static const TX_SIZE max_txsize_rect_lookup[BLOCK_SIZES] = {
   // 2X2,    2X4,      4X2,
 #if CONFIG_CHROMA_2X2
   TX_2X2,    TX_2X2,   TX_2X2,
-#elif CONFIG_CB4X4
+#elif CONFIG_CHROMA_SUB8X8
   TX_4X4,    TX_4X4,   TX_4X4,
-#endif
+#endif  // CONFIG_CHROMA_SUB8X8
   //                   4X4
                        TX_4X4,
   // 4X8,    8X4,      8X8
   TX_4X8,    TX_8X4,   TX_8X8,
   // 8X16,   16X8,     16X16
   TX_8X16,   TX_16X8,  TX_16X16,
   // 16X32,  32X16,    32X32
   TX_16X32,  TX_32X16, TX_32X32,
@@ -502,17 +512,17 @@ static const TX_SIZE max_txsize_rect_loo
   // 64x128, 128x64,   128x128
   TX_32X32,  TX_32X32, TX_32X32,
 #endif  // CONFIG_EXT_PARTITION
 #endif  // CONFIG_TX64X64
 };
 
 #if CONFIG_EXT_TX && CONFIG_RECT_TX_EXT
 static const TX_SIZE quarter_txsize_lookup[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   //     2X2,        2X4,        4X2,
   TX_INVALID, TX_INVALID, TX_INVALID,
 #endif
   //                             4x4,
                           TX_INVALID,
   //     4x8,        8x4,        8x8,
   TX_INVALID, TX_INVALID, TX_INVALID,
   // 8x16, 16x8, 16x16,
@@ -548,23 +558,25 @@ static const TX_TYPE_1D htx_tab[TX_TYPES
 };
 
 #if CONFIG_RECT_TX && (CONFIG_EXT_TX || CONFIG_VAR_TX)
 // Same as "max_txsize_lookup[bsize] - TX_8X8", except for rectangular
 // block which may use a rectangular transform, in which  case it is
 // "(max_txsize_lookup[bsize] + 1) - TX_8X8", invalid for bsize < 8X8
 static const int32_t intra_tx_size_cat_lookup[BLOCK_SIZES] = {
 #if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   // 2X2,             2X4,                4X2,
   INT32_MIN,          INT32_MIN,          INT32_MIN,
+#endif
   //                                      4X4,
                                           INT32_MIN,
   // 4X8,             8X4,                8X8,
   TX_8X8 - TX_8X8,    TX_8X8 - TX_8X8,    TX_8X8 - TX_8X8,
-#else
+#else  // CONFIG_CB4X4
   //                                      4X4
                                           INT32_MIN,
   // 4X8,             8X4,                8X8
   INT32_MIN,          INT32_MIN,          TX_8X8 - TX_8X8,
 #endif  // CONFIG_CB4X4
   // 8X16,            16X8,               16X16
   TX_16X16 - TX_8X8,  TX_16X16 - TX_8X8,  TX_16X16 - TX_8X8,
   // 16X32,           32X16,              32X32
@@ -585,17 +597,17 @@ static const int32_t intra_tx_size_cat_l
   // 64x128,          128x64,             128x128
   TX_32X32 - TX_8X8,  TX_32X32 - TX_8X8,  TX_32X32 - TX_8X8,
 #endif  // CONFIG_EXT_PARTITION
 #endif  // CONFIG_TX64X64
 };
 #else
 // Same as "max_txsize_lookup[bsize] - TX_8X8", invalid for bsize < 8X8
 static const int32_t intra_tx_size_cat_lookup[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   // 2X2,             2X4,                4X2,
   INT32_MIN,          INT32_MIN,          INT32_MIN,
 #endif
   //                                      4X4
                                           INT32_MIN,
   // 4X8,             8X4,                8X8
   INT32_MIN,          INT32_MIN,          TX_8X8 - TX_8X8,
   // 8X16,            16X8,               16X16
@@ -885,23 +897,27 @@ static const TX_SIZE tx_mode_to_biggest_
   TX_32X32,  // TX_MODE_SELECT
 #endif  // CONFIG_TX64X64
 };
 /* clang-format on */
 
 static const BLOCK_SIZE ss_size_lookup[BLOCK_SIZES][2][2] = {
 //  ss_x == 0    ss_x == 0        ss_x == 1      ss_x == 1
 //  ss_y == 0    ss_y == 1        ss_y == 0      ss_y == 1
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   { { BLOCK_2X2, BLOCK_INVALID }, { BLOCK_INVALID, BLOCK_INVALID } },
   { { BLOCK_2X4, BLOCK_INVALID }, { BLOCK_INVALID, BLOCK_INVALID } },
   { { BLOCK_4X2, BLOCK_INVALID }, { BLOCK_INVALID, BLOCK_INVALID } },
   { { BLOCK_4X4, BLOCK_4X2 }, { BLOCK_2X4, BLOCK_2X2 } },
   { { BLOCK_4X8, BLOCK_4X4 }, { BLOCK_INVALID, BLOCK_2X4 } },
   { { BLOCK_8X4, BLOCK_INVALID }, { BLOCK_4X4, BLOCK_4X2 } },
+#elif CONFIG_CB4X4
+  { { BLOCK_4X4, BLOCK_4X4 }, { BLOCK_4X4, BLOCK_4X4 } },
+  { { BLOCK_4X8, BLOCK_4X4 }, { BLOCK_INVALID, BLOCK_4X4 } },
+  { { BLOCK_8X4, BLOCK_INVALID }, { BLOCK_4X4, BLOCK_4X4 } },
 #else
   { { BLOCK_4X4, BLOCK_INVALID }, { BLOCK_INVALID, BLOCK_INVALID } },
   { { BLOCK_4X8, BLOCK_4X4 }, { BLOCK_INVALID, BLOCK_INVALID } },
   { { BLOCK_8X4, BLOCK_INVALID }, { BLOCK_4X4, BLOCK_INVALID } },
 #endif
   { { BLOCK_8X8, BLOCK_8X4 }, { BLOCK_4X8, BLOCK_4X4 } },
   { { BLOCK_8X16, BLOCK_8X8 }, { BLOCK_INVALID, BLOCK_4X8 } },
   { { BLOCK_16X8, BLOCK_INVALID }, { BLOCK_8X8, BLOCK_8X4 } },
@@ -917,17 +933,16 @@ static const BLOCK_SIZE ss_size_lookup[B
   { { BLOCK_128X64, BLOCK_INVALID }, { BLOCK_64X64, BLOCK_64X32 } },
   { { BLOCK_128X128, BLOCK_128X64 }, { BLOCK_64X128, BLOCK_64X64 } },
 #endif  // CONFIG_EXT_PARTITION
 };
 
 static const TX_SIZE uv_txsize_lookup[BLOCK_SIZES][TX_SIZES_ALL][2][2] = {
 //  ss_x == 0    ss_x == 0        ss_x == 1      ss_x == 1
 //  ss_y == 0    ss_y == 1        ss_y == 0      ss_y == 1
-#if CONFIG_CB4X4
 #if CONFIG_CHROMA_2X2
   {
       // BLOCK_2X2
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
@@ -982,17 +997,17 @@ static const TX_SIZE uv_txsize_lookup[BL
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_INVALID, TX_INVALID }, { TX_INVALID, TX_INVALID } },
       { { TX_INVALID, TX_INVALID }, { TX_INVALID, TX_INVALID } },
       { { TX_INVALID, TX_INVALID }, { TX_INVALID, TX_INVALID } },
       { { TX_INVALID, TX_INVALID }, { TX_INVALID, TX_INVALID } },
   },
-#else  // CONFIG_CHROMA_2X2
+#elif CONFIG_CHROMA_SUB8X8
   {
       // BLOCK_2X2
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
 #if CONFIG_TX64X64
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
@@ -1043,17 +1058,16 @@ static const TX_SIZE uv_txsize_lookup[BL
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
       { { TX_INVALID, TX_INVALID }, { TX_INVALID, TX_INVALID } },
       { { TX_INVALID, TX_INVALID }, { TX_INVALID, TX_INVALID } },
       { { TX_INVALID, TX_INVALID }, { TX_INVALID, TX_INVALID } },
       { { TX_INVALID, TX_INVALID }, { TX_INVALID, TX_INVALID } },
   },
-#endif  // CONFIG_CHROMA_2X2
 #endif
   {
 // BLOCK_4X4
 #if CONFIG_CHROMA_2X2
       { { TX_2X2, TX_2X2 }, { TX_2X2, TX_2X2 } },
       { { TX_4X4, TX_2X2 }, { TX_2X2, TX_2X2 } },
 #else
       { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
@@ -1440,17 +1454,17 @@ static const TX_SIZE uv_txsize_lookup[BL
 // a blocksize partition  1111 means we split 64x64, 32x32, 16x16
 // and 8x8.  1000 means we just split the 64x64 to 32x32
 /* clang-format off */
 static const struct {
   PARTITION_CONTEXT above;
   PARTITION_CONTEXT left;
 } partition_context_lookup[BLOCK_SIZES] = {
 #if CONFIG_EXT_PARTITION
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   { 31, 31 },  // 2X2   - {0b11111, 0b11111}
   { 31, 31 },  // 2X4   - {0b11111, 0b11111}
   { 31, 31 },  // 4X2   - {0b11111, 0b11111}
 #endif
   { 31, 31 },  // 4X4   - {0b11111, 0b11111}
   { 31, 30 },  // 4X8   - {0b11111, 0b11110}
   { 30, 31 },  // 8X4   - {0b11110, 0b11111}
   { 30, 30 },  // 8X8   - {0b11110, 0b11110}
@@ -1462,17 +1476,17 @@ static const struct {
   { 24, 24 },  // 32X32 - {0b11000, 0b11000}
   { 24, 16 },  // 32X64 - {0b11000, 0b10000}
   { 16, 24 },  // 64X32 - {0b10000, 0b11000}
   { 16, 16 },  // 64X64 - {0b10000, 0b10000}
   { 16, 0 },   // 64X128- {0b10000, 0b00000}
   { 0, 16 },   // 128X64- {0b00000, 0b10000}
   { 0, 0 },    // 128X128-{0b00000, 0b00000}
 #else
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   { 15, 15 },  // 2X2   - {0b1111, 0b1111}
   { 15, 15 },  // 2X4   - {0b1111, 0b1111}
   { 15, 15 },  // 4X2   - {0b1111, 0b1111}
 #endif
   { 15, 15 },  // 4X4   - {0b1111, 0b1111}
   { 15, 14 },  // 4X8   - {0b1111, 0b1110}
   { 14, 15 },  // 8X4   - {0b1110, 0b1111}
   { 14, 14 },  // 8X8   - {0b1110, 0b1110}
@@ -1511,16 +1525,44 @@ static const int partition_supertx_conte
 };
 
 #else
 static const int partition_supertx_context_lookup[PARTITION_TYPES] = { -1, 0, 0,
                                                                        1 };
 #endif  // CONFIG_EXT_PARTITION_TYPES
 #endif  // CONFIG_SUPERTX
 
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+// NCOBMC_ADAPT_INTRPL only supports block size >= BLOCK_8X8 and <= BLOCK_64X64
+static const ADAPT_OVERLAP_BLOCK adapt_overlap_block_lookup[BLOCK_SIZES_ALL] = {
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+  ADAPT_OVERLAP_BLOCK_INVALID,  // BLOCK_2X2
+  ADAPT_OVERLAP_BLOCK_INVALID,  // BLOCK_2X4
+  ADAPT_OVERLAP_BLOCK_INVALID,  // BLOCK_4X2
+#endif
+  ADAPT_OVERLAP_BLOCK_INVALID,  // BLOCK_4X4
+  ADAPT_OVERLAP_BLOCK_INVALID,  // BLOCK_4X8
+  ADAPT_OVERLAP_BLOCK_INVALID,  // BLOCK_8X4
+
+  // the rest of the block sizes round to the largest squared block less than
+  // the given block size
+  ADAPT_OVERLAP_BLOCK_8X8, ADAPT_OVERLAP_BLOCK_8X8, ADAPT_OVERLAP_BLOCK_8X8,
+  ADAPT_OVERLAP_BLOCK_16X16, ADAPT_OVERLAP_BLOCK_16X16,
+  ADAPT_OVERLAP_BLOCK_16X16, ADAPT_OVERLAP_BLOCK_32X32,
+  ADAPT_OVERLAP_BLOCK_32X32, ADAPT_OVERLAP_BLOCK_32X32,
+  ADAPT_OVERLAP_BLOCK_64X64,
+#if CONFIG_EXT_PARTITION
+  ADAPT_OVERLAP_BLOCK_INVALID, ADAPT_OVERLAP_BLOCK_INVALID,
+  ADAPT_OVERLAP_BLOCK_INVALID,
+#endif  // CONFIG_EXT_PARTITION
+  ADAPT_OVERLAP_BLOCK_INVALID, ADAPT_OVERLAP_BLOCK_INVALID,
+  ADAPT_OVERLAP_BLOCK_INVALID, ADAPT_OVERLAP_BLOCK_INVALID
+};
+#endif  // CONFIG_NCOBMC_ADAPT_WEIGHT
+
 #if CONFIG_ADAPT_SCAN
 #define EOB_THRESHOLD_NUM 2
 #endif
 
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
--- a/third_party/aom/av1/common/convolve.c
+++ b/third_party/aom/av1/common/convolve.c
@@ -38,28 +38,61 @@ void av1_convolve_horiz_c(const uint8_t 
     for (x = 0; x < w; ++x) {
       const uint8_t *const src_x = &src[x_q4 >> SUBPEL_BITS];
       const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
           filter_params, x_q4 & SUBPEL_MASK);
       int k, sum = 0;
       for (k = 0; k < filter_size; ++k) sum += src_x[k] * x_filter[k];
 
       sum = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
-      if (conv_params->ref)
+      if (conv_params->do_average)
         dst[x] = ROUND_POWER_OF_TWO(dst[x] + sum, 1);
       else
         dst[x] = sum;
 
       x_q4 += x_step_q4;
     }
     src += src_stride;
     dst += dst_stride;
   }
 }
 
+void av1_convolve_horiz_scale(const uint8_t *src, int src_stride, uint8_t *dst,
+                              int dst_stride, int w, int h,
+                              const InterpFilterParams filter_params,
+                              const int subpel_x_qn, int x_step_qn,
+                              ConvolveParams *conv_params) {
+  int x, y;
+  int filter_size = filter_params.taps;
+  assert(conv_params->round == CONVOLVE_OPT_ROUND);
+  src -= filter_size / 2 - 1;
+  for (y = 0; y < h; ++y) {
+    int x_qn = subpel_x_qn;
+    for (x = 0; x < w; ++x) {
+      const uint8_t *const src_x = &src[x_qn >> SCALE_SUBPEL_BITS];
+      const int x_filter_idx = (x_qn & SCALE_SUBPEL_MASK) >> SCALE_EXTRA_BITS;
+      assert(x_filter_idx < SUBPEL_SHIFTS);
+      const int16_t *x_filter =
+          av1_get_interp_filter_subpel_kernel(filter_params, x_filter_idx);
+      int k, sum = 0;
+      for (k = 0; k < filter_size; ++k) sum += src_x[k] * x_filter[k];
+
+      sum = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
+      if (conv_params->do_average)
+        dst[x] = ROUND_POWER_OF_TWO(dst[x] + sum, 1);
+      else
+        dst[x] = sum;
+
+      x_qn += x_step_qn;
+    }
+    src += src_stride;
+    dst += dst_stride;
+  }
+}
+
 void av1_convolve_vert_c(const uint8_t *src, int src_stride, uint8_t *dst,
                          int dst_stride, int w, int h,
                          const InterpFilterParams filter_params,
                          const int subpel_y_q4, int y_step_q4,
                          ConvolveParams *conv_params) {
   int x, y;
   int filter_size = filter_params.taps;
   assert(conv_params->round == CONVOLVE_OPT_ROUND);
@@ -70,33 +103,68 @@ void av1_convolve_vert_c(const uint8_t *
       const uint8_t *const src_y = &src[(y_q4 >> SUBPEL_BITS) * src_stride];
       const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
           filter_params, y_q4 & SUBPEL_MASK);
       int k, sum = 0;
       for (k = 0; k < filter_size; ++k)
         sum += src_y[k * src_stride] * y_filter[k];
 
       sum = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
-      if (conv_params->ref)
+      if (conv_params->do_average)
         dst[y * dst_stride] = ROUND_POWER_OF_TWO(dst[y * dst_stride] + sum, 1);
       else
         dst[y * dst_stride] = sum;
 
       y_q4 += y_step_q4;
     }
     ++src;
     ++dst;
   }
 }
 
+void av1_convolve_vert_scale(const uint8_t *src, int src_stride, uint8_t *dst,
+                             int dst_stride, int w, int h,
+                             const InterpFilterParams filter_params,
+                             const int subpel_y_qn, int y_step_qn,
+                             ConvolveParams *conv_params) {
+  int x, y;
+  int filter_size = filter_params.taps;
+  assert(conv_params->round == CONVOLVE_OPT_ROUND);
+  src -= src_stride * (filter_size / 2 - 1);
+  for (x = 0; x < w; ++x) {
+    int y_qn = subpel_y_qn;
+    for (y = 0; y < h; ++y) {
+      const uint8_t *const src_y =
+          &src[(y_qn >> SCALE_SUBPEL_BITS) * src_stride];
+      const int y_filter_idx = (y_qn & SCALE_SUBPEL_MASK) >> SCALE_EXTRA_BITS;
+      assert(y_filter_idx < SUBPEL_SHIFTS);
+      const int16_t *y_filter =
+          av1_get_interp_filter_subpel_kernel(filter_params, y_filter_idx);
+      int k, sum = 0;
+      for (k = 0; k < filter_size; ++k)
+        sum += src_y[k * src_stride] * y_filter[k];
+
+      sum = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
+      if (conv_params->do_average)
+        dst[y * dst_stride] = ROUND_POWER_OF_TWO(dst[y * dst_stride] + sum, 1);
+      else
+        dst[y * dst_stride] = sum;
+
+      y_qn += y_step_qn;
+    }
+    ++src;
+    ++dst;
+  }
+}
+
 static void convolve_copy(const uint8_t *src, int src_stride, uint8_t *dst,
                           int dst_stride, int w, int h,
                           ConvolveParams *conv_params) {
   assert(conv_params->round == CONVOLVE_OPT_ROUND);
-  if (conv_params->ref == 0) {
+  if (conv_params->do_average == 0) {
     int r;
     for (r = 0; r < h; ++r) {
       memcpy(dst, src, w);
       src += src_stride;
       dst += dst_stride;
     }
   } else {
     int r, c;
@@ -114,17 +182,17 @@ void av1_convolve_horiz_facade(const uin
                                int dst_stride, int w, int h,
                                const InterpFilterParams filter_params,
                                const int subpel_x_q4, int x_step_q4,
                                ConvolveParams *conv_params) {
   assert(conv_params->round == CONVOLVE_OPT_ROUND);
   if (filter_params.taps == SUBPEL_TAPS) {
     const int16_t *filter_x =
         av1_get_interp_filter_subpel_kernel(filter_params, subpel_x_q4);
-    if (conv_params->ref == 0)
+    if (conv_params->do_average == 0)
       aom_convolve8_horiz(src, src_stride, dst, dst_stride, filter_x, x_step_q4,
                           NULL, -1, w, h);
     else
       aom_convolve8_avg_horiz(src, src_stride, dst, dst_stride, filter_x,
                               x_step_q4, NULL, -1, w, h);
   } else {
     av1_convolve_horiz(src, src_stride, dst, dst_stride, w, h, filter_params,
                        subpel_x_q4, x_step_q4, conv_params);
@@ -135,38 +203,60 @@ void av1_convolve_horiz_facade_c(const u
                                  uint8_t *dst, int dst_stride, int w, int h,
                                  const InterpFilterParams filter_params,
                                  const int subpel_x_q4, int x_step_q4,
                                  ConvolveParams *conv_params) {
   assert(conv_params->round == CONVOLVE_OPT_ROUND);
   if (filter_params.taps == SUBPEL_TAPS) {
     const int16_t *filter_x =
         av1_get_interp_filter_subpel_kernel(filter_params, subpel_x_q4);
-    if (conv_params->ref == 0)
+    if (conv_params->do_average == 0)
       aom_convolve8_horiz_c(src, src_stride, dst, dst_stride, filter_x,
                             x_step_q4, NULL, -1, w, h);
     else
       aom_convolve8_avg_horiz_c(src, src_stride, dst, dst_stride, filter_x,
                                 x_step_q4, NULL, -1, w, h);
   } else {
     av1_convolve_horiz_c(src, src_stride, dst, dst_stride, w, h, filter_params,
                          subpel_x_q4, x_step_q4, conv_params);
   }
 }
 
+void av1_convolve_horiz_facade_scale(const uint8_t *src, int src_stride,
+                                     uint8_t *dst, int dst_stride, int w, int h,
+                                     const InterpFilterParams filter_params,
+                                     const int subpel_x_qn, int x_step_qn,
+                                     ConvolveParams *conv_params) {
+  assert(conv_params->round == CONVOLVE_OPT_ROUND);
+  if (filter_params.taps == SUBPEL_TAPS) {
+    const int16_t *filter_x = av1_get_interp_filter_subpel_kernel(
+        filter_params, subpel_x_qn >> SCALE_EXTRA_BITS);
+    if (conv_params->do_average == 0)
+      aom_convolve8_horiz_scale(src, src_stride, dst, dst_stride, filter_x,
+                                subpel_x_qn, x_step_qn, NULL, 0, -1, w, h);
+    else
+      aom_convolve8_avg_horiz_scale(src, src_stride, dst, dst_stride, filter_x,
+                                    subpel_x_qn, x_step_qn, NULL, 0, -1, w, h);
+  } else {
+    av1_convolve_horiz_scale(src, src_stride, dst, dst_stride, w, h,
+                             filter_params, subpel_x_qn, x_step_qn,
+                             conv_params);
+  }
+}
+
 void av1_convolve_vert_facade(const uint8_t *src, int src_stride, uint8_t *dst,
                               int dst_stride, int w, int h,
                               const InterpFilterParams filter_params,
                               const int subpel_y_q4, int y_step_q4,
                               ConvolveParams *conv_params) {
   assert(conv_params->round == CONVOLVE_OPT_ROUND);
   if (filter_params.taps == SUBPEL_TAPS) {
     const int16_t *filter_y =
         av1_get_interp_filter_subpel_kernel(filter_params, subpel_y_q4);
-    if (conv_params->ref == 0) {
+    if (conv_params->do_average == 0) {
       aom_convolve8_vert(src, src_stride, dst, dst_stride, NULL, -1, filter_y,
                          y_step_q4, w, h);
     } else {
       aom_convolve8_avg_vert(src, src_stride, dst, dst_stride, NULL, -1,
                              filter_y, y_step_q4, w, h);
     }
   } else {
     av1_convolve_vert(src, src_stride, dst, dst_stride, w, h, filter_params,
@@ -178,88 +268,164 @@ void av1_convolve_vert_facade_c(const ui
                                 uint8_t *dst, int dst_stride, int w, int h,
                                 const InterpFilterParams filter_params,
                                 const int subpel_y_q4, int y_step_q4,
                                 ConvolveParams *conv_params) {
   assert(conv_params->round == CONVOLVE_OPT_ROUND);
   if (filter_params.taps == SUBPEL_TAPS) {
     const int16_t *filter_y =
         av1_get_interp_filter_subpel_kernel(filter_params, subpel_y_q4);
-    if (conv_params->ref == 0) {
+    if (conv_params->do_average == 0) {
       aom_convolve8_vert_c(src, src_stride, dst, dst_stride, NULL, -1, filter_y,
                            y_step_q4, w, h);
     } else {
       aom_convolve8_avg_vert_c(src, src_stride, dst, dst_stride, NULL, -1,
                                filter_y, y_step_q4, w, h);
     }
   } else {
     av1_convolve_vert_c(src, src_stride, dst, dst_stride, w, h, filter_params,
                         subpel_y_q4, y_step_q4, conv_params);
   }
 }
 
+void av1_convolve_vert_facade_scale(const uint8_t *src, int src_stride,
+                                    uint8_t *dst, int dst_stride, int w, int h,
+                                    const InterpFilterParams filter_params,
+                                    const int subpel_y_qn, int y_step_qn,
+                                    ConvolveParams *conv_params) {
+  assert(conv_params->round == CONVOLVE_OPT_ROUND);
+  if (filter_params.taps == SUBPEL_TAPS) {
+    const int16_t *filter_y = av1_get_interp_filter_subpel_kernel(
+        filter_params, subpel_y_qn >> SCALE_EXTRA_BITS);
+    if (conv_params->do_average == 0) {
+      aom_convolve8_vert_scale(src, src_stride, dst, dst_stride, NULL, 0, -1,
+                               filter_y, subpel_y_qn, y_step_qn, w, h);
+    } else {
+      aom_convolve8_avg_vert_scale(src, src_stride, dst, dst_stride, NULL, 0,
+                                   -1, filter_y, subpel_y_qn, y_step_qn, w, h);
+    }
+  } else {
+    av1_convolve_vert_scale(src, src_stride, dst, dst_stride, w, h,
+                            filter_params, subpel_y_qn, y_step_qn, conv_params);
+  }
+}
+
 #if CONFIG_CONVOLVE_ROUND
 void av1_convolve_rounding(const int32_t *src, int src_stride, uint8_t *dst,
                            int dst_stride, int w, int h, int bits) {
   int r, c;
   for (r = 0; r < h; ++r) {
     for (c = 0; c < w; ++c) {
       dst[r * dst_stride + c] =
-          clip_pixel(ROUND_POWER_OF_TWO_SIGNED(src[r * src_stride + c], bits));
+          clip_pixel(ROUND_POWER_OF_TWO(src[r * src_stride + c], bits));
     }
   }
 }
 
-void av1_convolve_2d(const uint8_t *src, int src_stride, CONV_BUF_TYPE *dst,
-                     int dst_stride, int w, int h,
-                     InterpFilterParams *filter_params_x,
-                     InterpFilterParams *filter_params_y, const int subpel_x_q4,
-                     const int subpel_y_q4, ConvolveParams *conv_params) {
+#if CONFIG_COMPOUND_ROUND
+void av1_convolve_2d_c(const uint8_t *src, int src_stride, CONV_BUF_TYPE *dst,
+                       int dst_stride, int w, int h,
+                       InterpFilterParams *filter_params_x,
+                       InterpFilterParams *filter_params_y,
+                       const int subpel_x_q4, const int subpel_y_q4,
+                       ConvolveParams *conv_params) {
   int x, y, k;
-  CONV_BUF_TYPE im_block[(MAX_SB_SIZE + MAX_FILTER_TAP - 1) * MAX_SB_SIZE];
+  uint8_t im_block[(MAX_SB_SIZE + MAX_FILTER_TAP - 1) * MAX_SB_SIZE];
   int im_h = h + filter_params_y->taps - 1;
   int im_stride = w;
   const int fo_vert = filter_params_y->taps / 2 - 1;
   const int fo_horiz = filter_params_x->taps / 2 - 1;
-  (void)conv_params;
+
   // horizontal filter
   const uint8_t *src_horiz = src - fo_vert * src_stride;
   const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
       *filter_params_x, subpel_x_q4 & SUBPEL_MASK);
   for (y = 0; y < im_h; ++y) {
     for (x = 0; x < w; ++x) {
-      CONV_BUF_TYPE sum = 0;
+      int32_t sum = 0;
       for (k = 0; k < filter_params_x->taps; ++k) {
         sum += x_filter[k] * src_horiz[y * src_stride + x - fo_horiz + k];
       }
-#if CONFIG_COMPOUND_ROUND
       im_block[y * im_stride + x] =
-          clip_pixel(ROUND_POWER_OF_TWO_SIGNED(sum, conv_params->round_0));
-#else
-      im_block[y * im_stride + x] =
-          ROUND_POWER_OF_TWO_SIGNED(sum, conv_params->round_0);
-#endif
+          clip_pixel(ROUND_POWER_OF_TWO(sum, conv_params->round_0));
     }
   }
 
   // vertical filter
-  CONV_BUF_TYPE *src_vert = im_block + fo_vert * im_stride;
+  uint8_t *src_vert = im_block + fo_vert * im_stride;
   const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
       *filter_params_y, subpel_y_q4 & SUBPEL_MASK);
   for (y = 0; y < h; ++y) {
     for (x = 0; x < w; ++x) {
       CONV_BUF_TYPE sum = 0;
       for (k = 0; k < filter_params_y->taps; ++k) {
         sum += y_filter[k] * src_vert[(y - fo_vert + k) * im_stride + x];
       }
-      dst[y * dst_stride + x] +=
-          ROUND_POWER_OF_TWO_SIGNED(sum, conv_params->round_1);
+      CONV_BUF_TYPE res = ROUND_POWER_OF_TWO(sum, conv_params->round_1);
+      dst[y * dst_stride + x] += res;
     }
   }
 }
+#else
+/* When convolve-round is enabled and compound-round is disabled, we use a
+   high-precision convolve filter.
+   Note: For notes on hardware implementations, including the required
+   bit widths for various intermediate values, see the comments above
+   av1_warp_affine_c.
+*/
+void av1_convolve_2d_c(const uint8_t *src, int src_stride, CONV_BUF_TYPE *dst,
+                       int dst_stride, int w, int h,
+                       InterpFilterParams *filter_params_x,
+                       InterpFilterParams *filter_params_y,
+                       const int subpel_x_q4, const int subpel_y_q4,
+                       ConvolveParams *conv_params) {
+  int x, y, k;
+  int32_t im_block[(MAX_SB_SIZE + MAX_FILTER_TAP - 1) * MAX_SB_SIZE];
+  int im_h = h + filter_params_y->taps - 1;
+  int im_stride = w;
+  const int fo_vert = filter_params_y->taps / 2 - 1;
+  const int fo_horiz = filter_params_x->taps / 2 - 1;
+  const int bd = 8;
+
+  // horizontal filter
+  const uint8_t *src_horiz = src - fo_vert * src_stride;
+  const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
+      *filter_params_x, subpel_x_q4 & SUBPEL_MASK);
+  for (y = 0; y < im_h; ++y) {
+    for (x = 0; x < w; ++x) {
+      int32_t sum = (1 << (bd + FILTER_BITS - 1));
+      for (k = 0; k < filter_params_x->taps; ++k) {
+        sum += x_filter[k] * src_horiz[y * src_stride + x - fo_horiz + k];
+      }
+      assert(0 <= sum && sum < (1 << (bd + FILTER_BITS + 1)));
+      im_block[y * im_stride + x] =
+          ROUND_POWER_OF_TWO(sum, conv_params->round_0);
+    }
+  }
+
+  // vertical filter
+  int32_t *src_vert = im_block + fo_vert * im_stride;
+  const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
+      *filter_params_y, subpel_y_q4 & SUBPEL_MASK);
+  const int offset_bits = bd + 2 * FILTER_BITS - conv_params->round_0;
+  for (y = 0; y < h; ++y) {
+    for (x = 0; x < w; ++x) {
+      CONV_BUF_TYPE sum = 1 << offset_bits;
+      for (k = 0; k < filter_params_y->taps; ++k) {
+        sum += y_filter[k] * src_vert[(y - fo_vert + k) * im_stride + x];
+      }
+      assert(0 <= sum && sum < (1 << (offset_bits + 2)));
+      CONV_BUF_TYPE res = ROUND_POWER_OF_TWO(sum, conv_params->round_1) -
+                          ((1 << (offset_bits - conv_params->round_1)) +
+                           (1 << (offset_bits - conv_params->round_1 - 1)));
+      dst[y * dst_stride + x] += res;
+    }
+  }
+}
+#endif
 
 static INLINE void transpose_uint8(uint8_t *dst, int dst_stride,
                                    const uint8_t *src, int src_stride, int w,
                                    int h) {
   int r, c;
   for (r = 0; r < h; ++r)
     for (c = 0; c < w; ++c)
       dst[c * (dst_stride) + r] = src[r * (src_stride) + c];
@@ -345,70 +511,116 @@ static INLINE void transpose_uint16(uint
 void av1_highbd_convolve_rounding(const int32_t *src, int src_stride,
                                   uint8_t *dst8, int dst_stride, int w, int h,
                                   int bits, int bd) {
   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
   int r, c;
   for (r = 0; r < h; ++r) {
     for (c = 0; c < w; ++c) {
       dst[r * dst_stride + c] = clip_pixel_highbd(
-          ROUND_POWER_OF_TWO_SIGNED(src[r * src_stride + c], bits), bd);
+          ROUND_POWER_OF_TWO(src[r * src_stride + c], bits), bd);
     }
   }
 }
 
-void av1_highbd_convolve_2d(const uint16_t *src, int src_stride,
-                            CONV_BUF_TYPE *dst, int dst_stride, int w, int h,
-                            InterpFilterParams *filter_params_x,
-                            InterpFilterParams *filter_params_y,
-                            const int subpel_x_q4, const int subpel_y_q4,
-                            ConvolveParams *conv_params, int bd) {
+#if CONFIG_COMPOUND_ROUND
+void av1_highbd_convolve_2d_c(const uint16_t *src, int src_stride,
+                              CONV_BUF_TYPE *dst, int dst_stride, int w, int h,
+                              InterpFilterParams *filter_params_x,
+                              InterpFilterParams *filter_params_y,
+                              const int subpel_x_q4, const int subpel_y_q4,
+                              ConvolveParams *conv_params, int bd) {
   int x, y, k;
-  CONV_BUF_TYPE im_block[(MAX_SB_SIZE + MAX_FILTER_TAP - 1) * MAX_SB_SIZE];
+  uint16_t im_block[(MAX_SB_SIZE + MAX_FILTER_TAP - 1) * MAX_SB_SIZE];
   int im_h = h + filter_params_y->taps - 1;
   int im_stride = w;
   const int fo_vert = filter_params_y->taps / 2 - 1;
   const int fo_horiz = filter_params_x->taps / 2 - 1;
-  (void)conv_params;
+
   // horizontal filter
   const uint16_t *src_horiz = src - fo_vert * src_stride;
   const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
       *filter_params_x, subpel_x_q4 & SUBPEL_MASK);
   for (y = 0; y < im_h; ++y) {
     for (x = 0; x < w; ++x) {
-      CONV_BUF_TYPE sum = 0;
+      int32_t sum = 0;
       for (k = 0; k < filter_params_x->taps; ++k) {
         sum += x_filter[k] * src_horiz[y * src_stride + x - fo_horiz + k];
       }
-#if CONFIG_COMPOUND_ROUND
-      im_block[y * im_stride + x] = clip_pixel_highbd(
-          ROUND_POWER_OF_TWO_SIGNED(sum, conv_params->round_0), bd);
-#else
-      (void)bd;
       im_block[y * im_stride + x] =
-          ROUND_POWER_OF_TWO_SIGNED(sum, conv_params->round_0);
-#endif
+          clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, conv_params->round_0), bd);
     }
   }
 
   // vertical filter
-  CONV_BUF_TYPE *src_vert = im_block + fo_vert * im_stride;
+  uint16_t *src_vert = im_block + fo_vert * im_stride;
   const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
       *filter_params_y, subpel_y_q4 & SUBPEL_MASK);
   for (y = 0; y < h; ++y) {
     for (x = 0; x < w; ++x) {
       CONV_BUF_TYPE sum = 0;
       for (k = 0; k < filter_params_y->taps; ++k) {
         sum += y_filter[k] * src_vert[(y - fo_vert + k) * im_stride + x];
       }
-      dst[y * dst_stride + x] +=
-          ROUND_POWER_OF_TWO_SIGNED(sum, conv_params->round_1);
+      CONV_BUF_TYPE res = ROUND_POWER_OF_TWO(sum, conv_params->round_1);
+      dst[y * dst_stride + x] += res;
     }
   }
 }
+#else
+void av1_highbd_convolve_2d_c(const uint16_t *src, int src_stride,
+                              CONV_BUF_TYPE *dst, int dst_stride, int w, int h,
+                              InterpFilterParams *filter_params_x,
+                              InterpFilterParams *filter_params_y,
+                              const int subpel_x_q4, const int subpel_y_q4,
+                              ConvolveParams *conv_params, int bd) {
+  int x, y, k;
+  int32_t im_block[(MAX_SB_SIZE + MAX_FILTER_TAP - 1) * MAX_SB_SIZE];
+  int im_h = h + filter_params_y->taps - 1;
+  int im_stride = w;
+  const int fo_vert = filter_params_y->taps / 2 - 1;
+  const int fo_horiz = filter_params_x->taps / 2 - 1;
+
+  // horizontal filter
+  const uint16_t *src_horiz = src - fo_vert * src_stride;
+  const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
+      *filter_params_x, subpel_x_q4 & SUBPEL_MASK);
+  for (y = 0; y < im_h; ++y) {
+    for (x = 0; x < w; ++x) {
+      int32_t sum = (1 << (bd + FILTER_BITS - 1));
+      for (k = 0; k < filter_params_x->taps; ++k) {
+        sum += x_filter[k] * src_horiz[y * src_stride + x - fo_horiz + k];
+      }
+      assert(0 <= sum && sum < (1 << (bd + FILTER_BITS + 1)));
+      (void)bd;
+      im_block[y * im_stride + x] =
+          ROUND_POWER_OF_TWO(sum, conv_params->round_0);
+    }
+  }
+
+  // vertical filter
+  int32_t *src_vert = im_block + fo_vert * im_stride;
+  const int offset_bits = bd + 2 * FILTER_BITS - conv_params->round_0;
+  const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
+      *filter_params_y, subpel_y_q4 & SUBPEL_MASK);
+  for (y = 0; y < h; ++y) {
+    for (x = 0; x < w; ++x) {
+      CONV_BUF_TYPE sum = 1 << offset_bits;
+      for (k = 0; k < filter_params_y->taps; ++k) {
+        sum += y_filter[k] * src_vert[(y - fo_vert + k) * im_stride + x];
+      }
+      assert(0 <= sum && sum < (1 << (offset_bits + 2)));
+      CONV_BUF_TYPE res = ROUND_POWER_OF_TWO(sum, conv_params->round_1) -
+                          ((1 << (offset_bits - conv_params->round_1)) +
+                           (1 << (offset_bits - conv_params->round_1 - 1)));
+      dst[y * dst_stride + x] += res;
+    }
+  }
+}
+#endif
 
 void av1_highbd_convolve_2d_facade(const uint8_t *src8, int src_stride,
                                    uint8_t *dst, int dst_stride, int w, int h,
                                    const InterpFilter *interp_filter,
                                    const int subpel_x_q4, int x_step_q4,
                                    const int subpel_y_q4, int y_step_q4,
                                    ConvolveParams *conv_params, int bd) {
   (void)x_step_q4;
@@ -482,18 +694,18 @@ static void convolve_helper(const uint8_
 #else
                             const InterpFilter interp_filter,
 #endif
                             const int subpel_x_q4, int x_step_q4,
                             const int subpel_y_q4, int y_step_q4,
                             ConvolveParams *conv_params,
                             ConvolveFunc convolve_horiz,
                             ConvolveFunc convolve_vert) {
-  int ignore_horiz = x_step_q4 == 16 && subpel_x_q4 == 0;
-  int ignore_vert = y_step_q4 == 16 && subpel_y_q4 == 0;
+  int ignore_horiz = x_step_q4 == SUBPEL_SHIFTS && subpel_x_q4 == 0;
+  int ignore_vert = y_step_q4 == SUBPEL_SHIFTS && subpel_y_q4 == 0;
 #if CONFIG_DUAL_FILTER
   InterpFilterParams filter_params_x =
       av1_get_interp_filter_params(interp_filter[1 + 2 * conv_params->ref]);
   InterpFilterParams filter_params_y =
       av1_get_interp_filter_params(interp_filter[0 + 2 * conv_params->ref]);
   InterpFilterParams filter_params;
 #else
   InterpFilterParams filter_params =
@@ -540,16 +752,17 @@ static void convolve_helper(const uint8_
 
     // we do filter with fewer taps first to reduce hardware implementation
     // complexity
     if (filter_params_y.taps < filter_params_x.taps) {
       int intermediate_width;
       int temp_stride = max_intermediate_size;
       ConvolveParams temp_conv_params;
       temp_conv_params.ref = 0;
+      temp_conv_params.do_average = 0;
       temp_conv_params.round = CONVOLVE_OPT_ROUND;
       filter_params = filter_params_y;
       filter_size = filter_params_x.taps;
       intermediate_width =
           (((w - 1) * x_step_q4 + subpel_x_q4) >> SUBPEL_BITS) + filter_size;
       assert(intermediate_width <= max_intermediate_size);
 
       assert(filter_params.taps <= MAX_FILTER_TAP);
@@ -564,16 +777,17 @@ static void convolve_helper(const uint8_
                      w, h, filter_params, subpel_x_q4, x_step_q4, conv_params);
     } else
 #endif  // CONFIG_DUAL_FILTER && USE_EXTRA_FILTER
     {
       int intermediate_height;
       int temp_stride = MAX_SB_SIZE;
       ConvolveParams temp_conv_params;
       temp_conv_params.ref = 0;
+      temp_conv_params.do_average = 0;
       temp_conv_params.round = CONVOLVE_OPT_ROUND;
 #if CONFIG_DUAL_FILTER
       filter_params = filter_params_x;
       filter_size = filter_params_y.taps;
 #else
       filter_size = filter_params.taps;
 #endif
       intermediate_height =
@@ -594,16 +808,145 @@ static void convolve_helper(const uint8_
 
       convolve_vert(temp + temp_stride * (filter_size / 2 - 1), temp_stride,
                     dst, dst_stride, w, h, filter_params, subpel_y_q4,
                     y_step_q4, conv_params);
     }
   }
 }
 
+static void convolve_scale_helper(const uint8_t *src, int src_stride,
+                                  uint8_t *dst, int dst_stride, int w, int h,
+#if CONFIG_DUAL_FILTER
+                                  const InterpFilter *interp_filter,
+#else
+                                  const InterpFilter interp_filter,
+#endif
+                                  const int subpel_x_qn, int x_step_qn,
+                                  const int subpel_y_qn, int y_step_qn,
+                                  ConvolveParams *conv_params,
+                                  ConvolveFunc convolve_horiz,
+                                  ConvolveFunc convolve_vert) {
+  int ignore_horiz = x_step_qn == SCALE_SUBPEL_SHIFTS && subpel_x_qn == 0;
+  int ignore_vert = y_step_qn == SCALE_SUBPEL_SHIFTS && subpel_y_qn == 0;
+#if CONFIG_DUAL_FILTER
+  InterpFilterParams filter_params_x =
+      av1_get_interp_filter_params(interp_filter[1 + 2 * conv_params->ref]);
+  InterpFilterParams filter_params_y =
+      av1_get_interp_filter_params(interp_filter[0 + 2 * conv_params->ref]);
+  InterpFilterParams filter_params;
+#else
+  InterpFilterParams filter_params =
+      av1_get_interp_filter_params(interp_filter);
+#endif
+  assert(conv_params->round == CONVOLVE_OPT_ROUND);
+
+  assert(w <= MAX_BLOCK_WIDTH);
+  assert(h <= MAX_BLOCK_HEIGHT);
+  assert(y_step_qn <= (MAX_STEP << SCALE_EXTRA_BITS));
+  assert(x_step_qn <= (MAX_STEP << SCALE_EXTRA_BITS));
+
+  if (ignore_horiz && ignore_vert) {
+    convolve_copy(src, src_stride, dst, dst_stride, w, h, conv_params);
+  } else if (ignore_vert) {
+#if CONFIG_DUAL_FILTER
+    filter_params = filter_params_x;
+#endif
+    assert(filter_params.taps <= MAX_FILTER_TAP);
+    convolve_horiz(src, src_stride, dst, dst_stride, w, h, filter_params,
+                   subpel_x_qn, x_step_qn, conv_params);
+  } else if (ignore_horiz) {
+#if CONFIG_DUAL_FILTER
+    filter_params = filter_params_y;
+#endif
+    assert(filter_params.taps <= MAX_FILTER_TAP);
+    convolve_vert(src, src_stride, dst, dst_stride, w, h, filter_params,
+                  subpel_y_qn, y_step_qn, conv_params);
+  } else {
+    // temp's size is set to a 256 aligned value to facilitate SIMD
+    // implementation. The value is greater than (maximum possible intermediate
+    // height or width) * MAX_SB_SIZE
+    DECLARE_ALIGNED(16, uint8_t,
+                    temp[((MAX_SB_SIZE * 2 + 16) + 16) * MAX_SB_SIZE]);
+    int max_intermediate_size = ((MAX_SB_SIZE * 2 + 16) + 16);
+    int filter_size;
+#if CONFIG_DUAL_FILTER && USE_EXTRA_FILTER
+    if (interp_filter[0 + 2 * conv_params->ref] == MULTITAP_SHARP &&
+        interp_filter[1 + 2 * conv_params->ref] == MULTITAP_SHARP) {
+      // Avoid two directions both using 12-tap filter.
+      // This will reduce hardware implementation cost.
+      filter_params_y = av1_get_interp_filter_params(EIGHTTAP_SHARP);
+    }
+
+    // we do filter with fewer taps first to reduce hardware implementation
+    // complexity
+    if (filter_params_y.taps < filter_params_x.taps) {
+      int intermediate_width;
+      int temp_stride = max_intermediate_size;
+      ConvolveParams temp_conv_params;
+      temp_conv_params.ref = 0;
+      temp_conv_params.do_average = 0;
+      temp_conv_params.round = CONVOLVE_OPT_ROUND;
+      filter_params = filter_params_y;
+      filter_size = filter_params_x.taps;
+      intermediate_width =
+          (((w - 1) * x_step_qn + subpel_x_qn) >> SCALE_SUBPEL_BITS) +
+          filter_size;
+      assert(intermediate_width <= max_intermediate_size);
+
+      assert(filter_params.taps <= MAX_FILTER_TAP);
+
+      convolve_vert(src - (filter_size / 2 - 1), src_stride, temp, temp_stride,
+                    intermediate_width, h, filter_params, subpel_y_qn,
+                    y_step_qn, &temp_conv_params);
+
+      filter_params = filter_params_x;
+      assert(filter_params.taps <= MAX_FILTER_TAP);
+      convolve_horiz(temp + (filter_size / 2 - 1), temp_stride, dst, dst_stride,
+                     w, h, filter_params, subpel_x_qn, x_step_qn, conv_params);
+    } else {
+#endif  // CONFIG_DUAL_FILTER && USE_EXTRA_FILTER
+      int intermediate_height;
+      int temp_stride = MAX_SB_SIZE;
+      ConvolveParams temp_conv_params;
+      temp_conv_params.ref = 0;
+      temp_conv_params.do_average = 0;
+      temp_conv_params.round = CONVOLVE_OPT_ROUND;
+#if CONFIG_DUAL_FILTER
+      filter_params = filter_params_x;
+      filter_size = filter_params_y.taps;
+#else
+    filter_size = filter_params.taps;
+#endif
+      intermediate_height =
+          (((h - 1) * y_step_qn + subpel_y_qn) >> SCALE_SUBPEL_BITS) +
+          filter_size;
+      assert(intermediate_height <= max_intermediate_size);
+      (void)max_intermediate_size;
+
+      assert(filter_params.taps <= MAX_FILTER_TAP);
+
+      convolve_horiz(src - src_stride * (filter_size / 2 - 1), src_stride, temp,
+                     temp_stride, w, intermediate_height, filter_params,
+                     subpel_x_qn, x_step_qn, &temp_conv_params);
+
+#if CONFIG_DUAL_FILTER
+      filter_params = filter_params_y;
+#endif
+      assert(filter_params.taps <= MAX_FILTER_TAP);
+
+      convolve_vert(temp + temp_stride * (filter_size / 2 - 1), temp_stride,
+                    dst, dst_stride, w, h, filter_params, subpel_y_qn,
+                    y_step_qn, conv_params);
+#if CONFIG_DUAL_FILTER && USE_EXTRA_FILTER
+    }
+#endif  // CONFIG_DUAL_FILTER && USE_EXTRA_FILTER
+  }
+}
+
 void av1_convolve(const uint8_t *src, int src_stride, uint8_t *dst,
                   int dst_stride, int w, int h,
 #if CONFIG_DUAL_FILTER
                   const InterpFilter *interp_filter,
 #else
                   const InterpFilter interp_filter,
 #endif
                   const int subpel_x_q4, int x_step_q4, const int subpel_y_q4,
@@ -622,16 +965,32 @@ void av1_convolve_c(const uint8_t *src, 
 #endif
                     const int subpel_x_q4, int x_step_q4, const int subpel_y_q4,
                     int y_step_q4, ConvolveParams *conv_params) {
   convolve_helper(src, src_stride, dst, dst_stride, w, h, interp_filter,
                   subpel_x_q4, x_step_q4, subpel_y_q4, y_step_q4, conv_params,
                   av1_convolve_horiz_facade_c, av1_convolve_vert_facade_c);
 }
 
+void av1_convolve_scale(const uint8_t *src, int src_stride, uint8_t *dst,
+                        int dst_stride, int w, int h,
+#if CONFIG_DUAL_FILTER
+                        const InterpFilter *interp_filter,
+#else
+                        const InterpFilter interp_filter,
+#endif
+                        const int subpel_x_q4, int x_step_q4,
+                        const int subpel_y_q4, int y_step_q4,
+                        ConvolveParams *conv_params) {
+  convolve_scale_helper(src, src_stride, dst, dst_stride, w, h, interp_filter,
+                        subpel_x_q4, x_step_q4, subpel_y_q4, y_step_q4,
+                        conv_params, av1_convolve_horiz_facade_scale,
+                        av1_convolve_vert_facade_scale);
+}
+
 void av1_lowbd_convolve_init_c(void) {
   // A placeholder for SIMD initialization
   return;
 }
 
 void av1_highbd_convolve_init_c(void) {
   // A placeholder for SIMD initialization
   return;
@@ -792,18 +1151,18 @@ void av1_highbd_convolve(const uint8_t *
 #else
                          const InterpFilter interp_filter,
 #endif
                          const int subpel_x_q4, int x_step_q4,
                          const int subpel_y_q4, int y_step_q4, int ref_idx,
                          int bd) {
   uint16_t *src = CONVERT_TO_SHORTPTR(src8);
   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
-  int ignore_horiz = x_step_q4 == 16 && subpel_x_q4 == 0;
-  int ignore_vert = y_step_q4 == 16 && subpel_y_q4 == 0;
+  int ignore_horiz = x_step_q4 == SUBPEL_SHIFTS && subpel_x_q4 == 0;
+  int ignore_vert = y_step_q4 == SUBPEL_SHIFTS && subpel_y_q4 == 0;
 
   assert(w <= MAX_BLOCK_WIDTH);
   assert(h <= MAX_BLOCK_HEIGHT);
   assert(y_step_q4 <= MAX_STEP);
   assert(x_step_q4 <= MAX_STEP);
 
   if (ignore_horiz && ignore_vert) {
     highbd_convolve_copy(src, src_stride, dst, dst_stride, w, h, ref_idx, bd);
--- a/third_party/aom/av1/common/convolve.h
+++ b/third_party/aom/av1/common/convolve.h
@@ -22,54 +22,52 @@ typedef enum CONVOLVE_OPT {
   CONVOLVE_OPT_ROUND,
   CONVOLVE_OPT_NO_ROUND,
 } CONVOLVE_OPT;
 
 typedef int32_t CONV_BUF_TYPE;
 
 typedef struct ConvolveParams {
   int ref;
+  int do_average;
   CONVOLVE_OPT round;
   CONV_BUF_TYPE *dst;
   int dst_stride;
   int round_0;
   int round_1;
   int plane;
   int do_post_rounding;
 } ConvolveParams;
 
-static INLINE ConvolveParams get_conv_params(int ref, int plane) {
+static INLINE ConvolveParams get_conv_params(int ref, int do_average,
+                                             int plane) {
   ConvolveParams conv_params;
   conv_params.ref = ref;
+  conv_params.do_average = do_average;
   conv_params.round = CONVOLVE_OPT_ROUND;
   conv_params.plane = plane;
   conv_params.do_post_rounding = 0;
   return conv_params;
 }
 struct AV1Common;
 void av1_convolve_init(struct AV1Common *cm);
 #if CONFIG_CONVOLVE_ROUND
-void av1_convolve_2d(const uint8_t *src, int src_stride, CONV_BUF_TYPE *dst,
-                     int dst_stride, int w, int h,
-                     InterpFilterParams *filter_params_x,
-                     InterpFilterParams *filter_params_y, const int subpel_x_q4,
-                     const int subpel_y_q4, ConvolveParams *conv_params);
-
 void av1_convolve_2d_facade(const uint8_t *src, int src_stride, uint8_t *dst,
                             int dst_stride, int w, int h,
                             const InterpFilter *interp_filter,
                             const int subpel_x_q4, int x_step_q4,
                             const int subpel_y_q4, int y_step_q4,
                             ConvolveParams *conv_params);
 
-static INLINE ConvolveParams get_conv_params_no_round(int ref, int plane,
-                                                      int32_t *dst,
+static INLINE ConvolveParams get_conv_params_no_round(int ref, int do_average,
+                                                      int plane, int32_t *dst,
                                                       int dst_stride) {
   ConvolveParams conv_params;
   conv_params.ref = ref;
+  conv_params.do_average = do_average;
   conv_params.round = CONVOLVE_OPT_NO_ROUND;
 #if CONFIG_COMPOUND_ROUND
   conv_params.round_0 = FILTER_BITS;
 #else
   conv_params.round_0 = 5;
 #endif
   conv_params.round_1 = 0;
   conv_params.dst = dst;
@@ -82,23 +80,16 @@ static INLINE ConvolveParams get_conv_pa
 void av1_convolve_rounding(const int32_t *src, int src_stride, uint8_t *dst,
                            int dst_stride, int w, int h, int bits);
 
 #if CONFIG_HIGHBITDEPTH
 void av1_highbd_convolve_rounding(const int32_t *src, int src_stride,
                                   uint8_t *dst8, int dst_stride, int w, int h,
                                   int bits, int bd);
 
-void av1_highbd_convolve_2d(const uint16_t *src, int src_stride,
-                            CONV_BUF_TYPE *dst, int dst_stride, int w, int h,
-                            InterpFilterParams *filter_params_x,
-                            InterpFilterParams *filter_params_y,
-                            const int subpel_x_q4, const int subpel_y_q4,
-                            ConvolveParams *conv_params, int bd);
-
 void av1_highbd_convolve_2d_facade(const uint8_t *src8, int src_stride,
                                    uint8_t *dst, int dst_stride, int w, int h,
                                    const InterpFilter *interp_filter,
                                    const int subpel_x_q4, int x_step_q4,
                                    const int subpel_y_q4, int y_step_q4,
                                    ConvolveParams *conv_params, int bd);
 #endif
 #endif  // CONFIG_CONVOLVE_ROUND
@@ -118,16 +109,26 @@ void av1_convolve_c(const uint8_t *src, 
 #if CONFIG_DUAL_FILTER
                     const InterpFilter *interp_filter,
 #else
                     const InterpFilter interp_filter,
 #endif
                     const int subpel_x, int xstep, const int subpel_y,
                     int ystep, ConvolveParams *conv_params);
 
+void av1_convolve_scale(const uint8_t *src, int src_stride, uint8_t *dst,
+                        int dst_stride, int w, int h,
+#if CONFIG_DUAL_FILTER
+                        const InterpFilter *interp_filter,
+#else
+                        const InterpFilter interp_filter,
+#endif
+                        const int subpel_x, int xstep, const int subpel_y,
+                        int ystep, ConvolveParams *conv_params);
+
 #if CONFIG_HIGHBITDEPTH
 void av1_highbd_convolve(const uint8_t *src, int src_stride, uint8_t *dst,
                          int dst_stride, int w, int h,
 #if CONFIG_DUAL_FILTER
                          const InterpFilter *interp_filter,
 #else
                          const InterpFilter interp_filter,
 #endif
--- a/third_party/aom/av1/common/entropy.c
+++ b/third_party/aom/av1/common/entropy.c
@@ -5672,45 +5672,74 @@ void av1_average_tile_intra_cdfs(FRAME_C
   AVERAGE_TILE_CDFS(delta_q_cdf)
 #if CONFIG_EXT_DELTA_Q
   AVERAGE_TILE_CDFS(delta_lf_cdf)
 #endif
 #endif
 #if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
   AVERAGE_TILE_CDFS(intra_filter_cdf)
 #endif  // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
+
+#if CONFIG_NEW_MULTISYMBOL
+  AVERAGE_TILE_CDFS(skip_cdfs)
+#endif
 }
 
 void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
                                  FRAME_CONTEXT *ec_ctxs[],
                                  aom_cdf_prob *cdf_ptr[], int num_tiles) {
   int i, cdf_size;
 
   aom_cdf_prob *fc_cdf_ptr;
 
-  // FIXME: comp_inter_cdf not defined
-
-  // FIXME: comp_ref_cdf and comp_bwd_ref not defined
+#if CONFIG_NEW_MULTISYMBOL
+  AVERAGE_TILE_CDFS(comp_inter_cdf)
+#if CONFIG_EXT_REFS
+  AVERAGE_TILE_CDFS(comp_bwdref_cdf)
+#endif
+#endif
 
-  // FIXME: single_ref_cdf not defined
+#if CONFIG_NEW_MULTISYMBOL
+  AVERAGE_TILE_CDFS(single_ref_cdf)
 
-  // FIXME: cdfs not defined for newmv_mode, zeromv_mode, drl_mode, new2mv_mode
+  AVERAGE_TILE_CDFS(newmv_cdf)
+  AVERAGE_TILE_CDFS(zeromv_cdf)
+  AVERAGE_TILE_CDFS(refmv_cdf)
+  AVERAGE_TILE_CDFS(drl_cdf)
+#endif
+
+// FIXME: cdfs not defined for motion_mode_prob, obmc_prob
 
-  // FIXME: cdfs not defined for motion_mode_prob, obmc_prob
+// FIXME: cdfs not defined for super_tx
+#if CONFIG_EXT_INTER
+  AVERAGE_TILE_CDFS(inter_compound_mode_cdf)
 
-  // FIXME: cdfs not defined for super_tx
+#if CONFIG_EC_ADAPT
+  AVERAGE_TILE_CDFS(compound_type_cdf)
+#endif  // CONFIG_EC_ADAPT
 
-  // FIXME: CONFIG_EXT_INTER cdfs not defined for inter_compound_mode,
-  // interintra_mode etc
+#if CONFIG_INTERINTRA
+#if CONFIG_NEW_MULTISYMBOL
+  AVERAGE_TILE_CDFS(interintra_cdf)
+  AVERAGE_TILE_CDFS(wedge_interintra_cdf)
+#endif
+  AVERAGE_TILE_CDFS(interintra_mode_cdf)
+#endif
+#endif  // CONFIG_EXT_INTER
 
+  /* NB: kf_y_cdf is discarded after use, so no need
+     for backwards update */
   AVERAGE_TILE_CDFS(y_mode_cdf)
 
   if (cm->interp_filter == SWITCHABLE) {
     AVERAGE_TILE_CDFS(switchable_interp_cdf)
   }
+#if CONFIG_NEW_MULTISYMBOL
+  AVERAGE_TILE_CDFS(intra_inter_cdf)
+#endif
 }
 
 #if CONFIG_PVQ
 // Averaging PVQ's expected values for symbol coding
 static void av1_average_pvq_ex(int *cxt_ptr[], int *fc_cxt_ptr, int cxt_size,
                                const int num_tiles) {
   int i, j;
   for (i = 0; i < cxt_size; ++i) {
--- a/third_party/aom/av1/common/entropymode.c
+++ b/third_party/aom/av1/common/entropymode.c
@@ -288,16 +288,17 @@ const aom_prob default_coeff_lps[TX_SIZE
       { 161, 128, 174, 205, 128, 146, 182, 128, 59,  125, 179, 128,
         183, 208, 199, 220, 239, 184, 213, 217, 71,  141, 196, 217,
         213, 219, 215, 230, 237, 171, 224, 238, 112, 173, 193, 221,
         239, 246, 168, 243, 249, 93,  241, 247, 128, 195, 216, 233 },
   },
 };
 #endif  // CONFIG_LV_MAP
 
+#if !CONFIG_EC_ADAPT
 #if CONFIG_ALT_INTRA
 #if CONFIG_SMOOTH_HV
 const aom_prob av1_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1] = {
   {
       // above = dc
       { 111, 28, 44, 99, 166, 154, 28, 28, 27, 45, 134, 109 },    // left = dc
       { 82, 31, 102, 75, 117, 135, 33, 34, 21, 31, 134, 149 },    // left = v
       { 40, 29, 14, 161, 235, 180, 14, 12, 34, 52, 128, 69 },     // left = h
@@ -884,16 +885,17 @@ static const aom_prob default_uv_probs[I
   { 80, 5, 58, 178, 74, 83, 33, 62, 145 },      // y = d117
   { 86, 5, 32, 154, 192, 168, 14, 22, 163 },    // y = d153
   { 85, 5, 32, 156, 216, 148, 19, 29, 73 },     // y = d207
   { 77, 7, 64, 116, 132, 122, 37, 126, 120 },   // y = d63
   { 101, 21, 107, 181, 192, 103, 19, 67, 125 }  // y = tm
 };
 
 #endif  // CONFIG_ALT_INTRA
+#endif  // !CONFIG_EC_ADAPT
 
 #if CONFIG_EXT_PARTITION_TYPES
 static const aom_prob
     default_partition_probs[PARTITION_CONTEXTS][EXT_PARTITION_TYPES - 1] = {
       // 8x8 -> 4x4
       { 199, 122, 141, 128, 128, 128, 128 },  // a/l both not split
       { 147, 63, 159, 128, 128, 128, 128 },   // a split, l not split
       { 148, 133, 118, 128, 128, 128, 128 },  // l split, a not split
@@ -995,178 +997,405 @@ static const aom_prob default_zeromv_pro
 };
 
 static const aom_prob default_refmv_prob[REFMV_MODE_CONTEXTS] = {
   220, 220, 200, 200, 180, 128, 30, 220, 30,
 };
 
 static const aom_prob default_drl_prob[DRL_MODE_CONTEXTS] = { 128, 160, 180,
                                                               128, 160 };
-
-static const aom_prob
-    default_inter_mode_probs[INTER_MODE_CONTEXTS][INTER_MODES - 1] = {
-      { 2, 173, 34 },  // 0 = both zero mv
-      { 7, 145, 85 },  // 1 = one zero mv + one a predicted mv
-      { 7, 166, 63 },  // 2 = two predicted mvs
-      { 7, 94, 66 },   // 3 = one predicted/zero and one new mv
-      { 8, 64, 46 },   // 4 = two new mvs
-      { 17, 81, 31 },  // 5 = one intra neighbour + x
-      { 25, 29, 30 },  // 6 = two intra neighbours
-    };
+#if CONFIG_NEW_MULTISYMBOL
+static const aom_cdf_prob default_newmv_cdf[NEWMV_MODE_CONTEXTS][CDF_SIZE(2)] =
+    { { AOM_ICDF(128 * 200), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 150), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 150), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 110), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 70), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 60), AOM_ICDF(32768), 0 } };
+static const aom_cdf_prob default_zeromv_cdf[ZEROMV_MODE_CONTEXTS][CDF_SIZE(
+    2)] = { { AOM_ICDF(128 * 192), AOM_ICDF(32768), 0 },
+            { AOM_ICDF(128 * 64), AOM_ICDF(32768), 0 } };
+static const aom_cdf_prob default_refmv_cdf[REFMV_MODE_CONTEXTS][CDF_SIZE(2)] =
+    { { AOM_ICDF(128 * 220), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 220), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 200), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 200), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 30), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 220), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(128 * 30), AOM_ICDF(32768), 0 } };
+static const aom_cdf_prob default_drl_cdf[DRL_MODE_CONTEXTS][CDF_SIZE(2)] = {
+  { AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
+  { AOM_ICDF(128 * 160), AOM_ICDF(32768), 0 },
+  { AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
+  { AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
+  { AOM_ICDF(128 * 160), AOM_ICDF(32768), 0 }
+};
+#endif
 
 #if CONFIG_EXT_INTER
 static const aom_prob default_inter_compound_mode_probs
     [INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES - 1] = {
       { 2, 173, 68, 192, 128, 180, 180 },   // 0 = both zero mv
       { 7, 145, 160, 192, 128, 180, 180 },  // 1 = 1 zero + 1 predicted
       { 7, 166, 126, 192, 128, 180, 180 },  // 2 = two predicted mvs
       { 7, 94, 132, 192, 128, 180, 180 },   // 3 = 1 pred/zero, 1 new
       { 8, 64, 64, 192, 128, 180, 180 },    // 4 = two new mvs
       { 17, 81, 52, 192, 128, 180, 180 },   // 5 = one intra neighbour
       { 25, 29, 50, 192, 128, 180, 180 },   // 6 = two intra neighbours
     };
 
+#if CONFIG_EC_ADAPT
+static const aom_cdf_prob
+    default_inter_compound_mode_cdf[INTER_MODE_CONTEXTS][CDF_SIZE(
+        INTER_COMPOUND_MODES)] = {
+      { AOM_ICDF(21971), AOM_ICDF(24071), AOM_ICDF(24317), AOM_ICDF(24421),
+        AOM_ICDF(24667), AOM_ICDF(24771), AOM_ICDF(25027), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(18052), AOM_ICDF(24530), AOM_ICDF(25289), AOM_ICDF(25610),
+        AOM_ICDF(26369), AOM_ICDF(26690), AOM_ICDF(27586), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(20666), AOM_ICDF(24802), AOM_ICDF(25287), AOM_ICDF(25492),
+        AOM_ICDF(25977), AOM_ICDF(26182), AOM_ICDF(27078), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(11703), AOM_ICDF(19503), AOM_ICDF(20417), AOM_ICDF(20803),
+        AOM_ICDF(21717), AOM_ICDF(22103), AOM_ICDF(22999), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(7936), AOM_ICDF(12400), AOM_ICDF(12923), AOM_ICDF(13144),
+        AOM_ICDF(13667), AOM_ICDF(13888), AOM_ICDF(14912), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(9679), AOM_ICDF(12865), AOM_ICDF(13238), AOM_ICDF(13396),
+        AOM_ICDF(13769), AOM_ICDF(13927), AOM_ICDF(16103), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(3349), AOM_ICDF(7190), AOM_ICDF(7640), AOM_ICDF(7830),
+        AOM_ICDF(8280), AOM_ICDF(8470), AOM_ICDF(11670), AOM_ICDF(32768), 0 }
+    };
+#endif
+
 #if CONFIG_COMPOUND_SINGLEREF
 // TODO(zoeliu): Default values to be further adjusted based on the collected
 //               stats.
+/*
 static const aom_prob default_inter_singleref_comp_mode_probs
     [INTER_MODE_CONTEXTS][INTER_SINGLEREF_COMP_MODES - 1] = {
       { 2, 173, 68, 180 },   // 0 = both zero mv
       { 7, 145, 160, 180 },  // 1 = 1 zero + 1 predicted
       { 7, 166, 126, 180 },  // 2 = two predicted mvs
       { 7, 94, 132, 180 },   // 3 = 1 pred/zero, 1 new
       { 8, 64, 64, 180 },    // 4 = two new mvs
       { 17, 81, 52, 180 },   // 5 = one intra neighbour
       { 25, 29, 50, 180 },   // 6 = two intra neighbours
+    };*/
+static const aom_prob default_inter_singleref_comp_mode_probs
+    [INTER_MODE_CONTEXTS][INTER_SINGLEREF_COMP_MODES - 1] = {
+      { 2, 173, 68 },   // 0 = both zero mv
+      { 7, 145, 160 },  // 1 = 1 zero + 1 predicted
+      { 7, 166, 126 },  // 2 = two predicted mvs
+      { 7, 94, 132 },   // 3 = 1 pred/zero, 1 new
+      { 8, 64, 64 },    // 4 = two new mvs
+      { 17, 81, 52 },   // 5 = one intra neighbour
+      { 25, 29, 50 },   // 6 = two intra neighbours
     };
 #endif  // CONFIG_COMPOUND_SINGLEREF
 
 #if CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
 static const aom_prob
     default_compound_type_probs[BLOCK_SIZES][COMPOUND_TYPES - 1] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
       { 255, 128 }, { 255, 128 }, { 255, 128 },
 #endif
       { 208, 128 }, { 208, 128 }, { 208, 128 }, { 208, 128 }, { 208, 128 },
       { 208, 128 }, { 216, 128 }, { 216, 128 }, { 216, 128 }, { 224, 128 },
       { 224, 1 },   { 240, 1 },   { 240, 1 },
 #if CONFIG_EXT_PARTITION
       { 255, 1 },   { 255, 1 },   { 255, 1 },
 #endif  // CONFIG_EXT_PARTITION
     };
 #elif !CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
 static const aom_prob
     default_compound_type_probs[BLOCK_SIZES][COMPOUND_TYPES - 1] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
       { 255 }, { 255 }, { 255 },
 #endif
       { 208 }, { 208 }, { 208 }, { 208 }, { 208 }, { 208 }, { 216 },
       { 216 }, { 216 }, { 224 }, { 224 }, { 240 }, { 240 },
 #if CONFIG_EXT_PARTITION
       { 255 }, { 255 }, { 255 },
 #endif  // CONFIG_EXT_PARTITION
     };
 #elif CONFIG_COMPOUND_SEGMENT && !CONFIG_WEDGE
 static const aom_prob
     default_compound_type_probs[BLOCK_SIZES][COMPOUND_TYPES - 1] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
       { 255 }, { 255 }, { 255 },
 #endif
       { 208 }, { 208 }, { 208 }, { 208 }, { 208 }, { 208 }, { 216 },
       { 216 }, { 216 }, { 224 }, { 224 }, { 240 }, { 240 },
 #if CONFIG_EXT_PARTITION
       { 255 }, { 255 }, { 255 },
 #endif  // CONFIG_EXT_PARTITION
     };
 #else
 static const aom_prob default_compound_type_probs[BLOCK_SIZES]
                                                  [COMPOUND_TYPES - 1];
 #endif  // CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
 
+#if CONFIG_EC_ADAPT
+#if CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
+static const aom_cdf_prob
+    default_compound_type_cdf[BLOCK_SIZES][CDF_SIZE(COMPOUND_TYPES)] = {
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+      { AOM_ICDF(32640), AOM_ICDF(32704), AOM_ICDF(32768), 0 },  // 255, 128
+      { AOM_ICDF(32640), AOM_ICDF(32704), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(32640), AOM_ICDF(32704), AOM_ICDF(32768), 0 },
+#endif
+      { AOM_ICDF(26624), AOM_ICDF(29696), AOM_ICDF(32768), 0 },  // 208, 128
+      { AOM_ICDF(26624), AOM_ICDF(29696), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(26624), AOM_ICDF(29696), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(26624), AOM_ICDF(29696), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(26624), AOM_ICDF(29696), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(26624), AOM_ICDF(29696), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(27648), AOM_ICDF(30208), AOM_ICDF(32768), 0 },  // 216, 128
+      { AOM_ICDF(27648), AOM_ICDF(30208), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(27648), AOM_ICDF(30208), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(28672), AOM_ICDF(30720), AOM_ICDF(32768), 0 },  // 224, 128
+      { AOM_ICDF(28672), AOM_ICDF(28688), AOM_ICDF(32768), 0 },  // 224, 1
+      { AOM_ICDF(30720), AOM_ICDF(30728), AOM_ICDF(32768), 0 },  // 240, 1
+      { AOM_ICDF(30720), AOM_ICDF(30728), AOM_ICDF(32768), 0 },
+#if CONFIG_EXT_PARTITION
+      { AOM_ICDF(32640), AOM_ICDF(32641), AOM_ICDF(32768), 0 },  // 255, 1
+      { AOM_ICDF(32640), AOM_ICDF(32641), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(32640), AOM_ICDF(32641), AOM_ICDF(32768), 0 },
+#endif  // CONFIG_EXT_PARTITION
+    };
+#elif !CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
+static const aom_cdf_prob
+    default_compound_type_cdf[BLOCK_SIZES][CDF_SIZE(COMPOUND_TYPES)] = {
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+      { AOM_ICDF(32640), AOM_ICDF(32768), 0 },  // 255
+      { AOM_ICDF(32640), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(32640), AOM_ICDF(32768), 0 },
+#endif
+      { AOM_ICDF(26624), AOM_ICDF(32768), 0 },  // 208
+      { AOM_ICDF(26624), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(26624), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(26624), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(26624), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(26624), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(27648), AOM_ICDF(32768), 0 },  // 216
+      { AOM_ICDF(27648), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(27648), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(28672), AOM_ICDF(32768), 0 },  // 224
+      { AOM_ICDF(28672), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(30720), AOM_ICDF(32768), 0 },  // 240
+      { AOM_ICDF(30720), AOM_ICDF(32768), 0 },
+#if CONFIG_EXT_PARTITION
+      { AOM_ICDF(32640), AOM_ICDF(32768), 0 },  // 255
+      { AOM_ICDF(32640), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(32640), AOM_ICDF(32768), 0 },
+#endif  // CONFIG_EXT_PARTITION
+    };
+#elif CONFIG_COMPOUND_SEGMENT && !CONFIG_WEDGE
+static const aom_cdf_prob
+    default_compound_type_cdf[BLOCK_SIZES][CDF_SIZE(COMPOUND_TYPES)] = {
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+      { AOM_ICDF(32640), AOM_ICDF(32768), 0 },  // 255
+      { AOM_ICDF(32640), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(32640), AOM_ICDF(32768), 0 },
+#endif
+      { AOM_ICDF(26624), AOM_ICDF(32768), 0 },  // 208
+      { AOM_ICDF(26624), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(26624), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(26624), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(26624), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(26624), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(27648), AOM_ICDF(32768), 0 },  // 216
+      { AOM_ICDF(27648), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(27648), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(28672), AOM_ICDF(32768), 0 },  // 224
+      { AOM_ICDF(28672), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(30720), AOM_ICDF(32768), 0 },  // 240
+      { AOM_ICDF(30720), AOM_ICDF(32768), 0 },
+#if CONFIG_EXT_PARTITION
+      { AOM_ICDF(32640), AOM_ICDF(32768), 0 },  // 255
+      { AOM_ICDF(32640), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(32640), AOM_ICDF(32768), 0 },
+#endif  // CONFIG_EXT_PARTITION
+    };
+#else
+static const aom_cdf_prob default_compound_type_cdf[BLOCK_SIZES]
+                                                   [CDF_SIZE(COMPOUND_TYPES)];
+#endif  // CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
+#endif  // CONFIG_EC_ADAPT
+
 #if CONFIG_INTERINTRA
 static const aom_prob default_interintra_prob[BLOCK_SIZE_GROUPS] = {
   208, 208, 208, 208,
 };
+#if CONFIG_NEW_MULTISYMBOL
+static const aom_cdf_prob default_interintra_cdf[BLOCK_SIZE_GROUPS][CDF_SIZE(
+    2)] = { { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+            { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+            { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+            { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 } };
+#endif
 
 static const aom_prob
     default_interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1] = {
       { 88, 16, 150 },  // block_size < 8x8
       { 75, 26, 150 },  // block_size < 16x16
       { 73, 24, 150 },  // block_size < 32x32
       { 96, 27, 150 }   // block_size >= 32x32
     };
+#if CONFIG_EC_ADAPT
+static const aom_cdf_prob
+    default_interintra_mode_cdf[BLOCK_SIZE_GROUPS][CDF_SIZE(
+        INTERINTRA_MODES)] = {
+      { AOM_ICDF(11263), AOM_ICDF(23076), AOM_ICDF(31424), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(9600), AOM_ICDF(21796), AOM_ICDF(30415), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(9344), AOM_ICDF(21782), AOM_ICDF(30572), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(12288), AOM_ICDF(23022), AOM_ICDF(30608), AOM_ICDF(32768), 0 }
+    };
+#endif
 
 static const aom_prob default_wedge_interintra_prob[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   208, 208, 208,
 #endif
   208, 208, 208, 208, 208, 208, 216, 216, 216, 224, 224, 224, 240,
 #if CONFIG_EXT_PARTITION
   208, 208, 208
 #endif  // CONFIG_EXT_PARTITION
 };
+
+#if CONFIG_NEW_MULTISYMBOL
+static const aom_cdf_prob
+    default_wedge_interintra_cdf[BLOCK_SIZES][CDF_SIZE(2)] = {
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+      { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+#endif
+      { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(216 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(216 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(216 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(224 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(224 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(224 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(240 * 128), AOM_ICDF(32768), 0 },
+#if CONFIG_EXT_PARTITION
+      { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(208 * 128), AOM_ICDF(32768), 0 },
+#endif  // CONFIG_EXT_PARTITION
+    };
+#endif  // CONFIG_NEW_MULTISYMBOL
+
 #endif  // CONFIG_INTERINTRA
 #endif  // CONFIG_EXT_INTER
 
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+const aom_tree_index av1_ncobmc_mode_tree[TREE_SIZE(MAX_NCOBMC_MODES)] = {
+  -NO_OVERLAP,    2,  -NCOBMC_MODE_1, 4,
+  -NCOBMC_MODE_2, 6,  -NCOBMC_MODE_3, 8,
+  -NCOBMC_MODE_4, 10, -NCOBMC_MODE_5, 12,
+  -NCOBMC_MODE_6, 14, -NCOBMC_MODE_7, -NCOBMC_MODE_8
+};
+
+// TODO(weitinglin): find default prob
+static const aom_prob
+    default_ncobmc_mode_prob[ADAPT_OVERLAP_BLOCKS][MAX_NCOBMC_MODES - 1] = {
+      { 23, 37, 37, 38, 65, 71, 81, 86 },   // 8x8
+      { 28, 32, 37, 43, 51, 64, 85, 128 },  // 16X16 equal prob
+      { 86, 22, 32, 25, 10, 40, 97, 65 },   // 32X32
+      { 28, 32, 37, 43, 51, 64, 85, 128 }   // 64X64 equal prob
+    };
+#endif
+
 // Change this section appropriately once warped motion is supported
 #if CONFIG_MOTION_VAR && !CONFIG_WARPED_MOTION
+#if !CONFIG_NCOBMC_ADAPT_WEIGHT
 const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
   -SIMPLE_TRANSLATION, -OBMC_CAUSAL
 };
 static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
     {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
       { 255 }, { 255 }, { 255 },
 #endif
       { 255 }, { 255 }, { 255 }, { 151 }, { 153 }, { 144 }, { 178 },
       { 165 }, { 160 }, { 207 }, { 195 }, { 168 }, { 244 },
 #if CONFIG_EXT_PARTITION
       { 252 }, { 252 }, { 252 },
 #endif  // CONFIG_EXT_PARTITION
     };
+#else
+// TODO(weitinglin): The default probability is copied from warped motion right
+//                   now as a place holder. It needs to be fined tuned after
+//                   NCOBMC_ADAPT_WEIGHT is actually implemented. Also needs to
+//                   change this section appropriately once warped motion is
+//                   supported.
+const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
+  -SIMPLE_TRANSLATION, 2, -OBMC_CAUSAL, -NCOBMC_ADAPT_WEIGHT,
+};
+static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
+    {
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+      { 255, 200 }, { 255, 200 }, { 255, 200 },
+#endif
+      { 255, 200 }, { 255, 200 }, { 255, 200 }, { 151, 200 }, { 153, 200 },
+      { 144, 200 }, { 178, 200 }, { 165, 200 }, { 160, 200 }, { 207, 200 },
+      { 195, 200 }, { 168, 200 }, { 244, 200 },
+#if CONFIG_EXT_PARTITION
+      { 252, 200 }, { 252, 200 }, { 252, 200 },
+#endif  // CONFIG_EXT_PARTITION
+    };
+#endif
 
 #elif !CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
 
 const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
   -SIMPLE_TRANSLATION, -WARPED_CAUSAL
 };
 
 static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
     {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
       { 255 }, { 255 }, { 255 },
 #endif
       { 255 }, { 255 }, { 255 }, { 151 }, { 153 }, { 144 }, { 178 },
       { 165 }, { 160 }, { 207 }, { 195 }, { 168 }, { 244 },
 #if CONFIG_EXT_PARTITION
       { 252 }, { 252 }, { 252 },
 #endif  // CONFIG_EXT_PARTITION
     };
 
 #elif CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
 
 const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
   -SIMPLE_TRANSLATION, 2, -OBMC_CAUSAL, -WARPED_CAUSAL,
 };
 static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
     {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
       { 255, 200 }, { 255, 200 }, { 255, 200 },
 #endif
       { 255, 200 }, { 255, 200 }, { 255, 200 }, { 151, 200 }, { 153, 200 },
       { 144, 200 }, { 178, 200 }, { 165, 200 }, { 160, 200 }, { 207, 200 },
       { 195, 200 }, { 168, 200 }, { 244, 200 },
 #if CONFIG_EXT_PARTITION
       { 252, 200 }, { 252, 200 }, { 252, 200 },
 #endif  // CONFIG_EXT_PARTITION
     };
 
 // Probability for the case that only 1 additional motion mode is allowed
 static const aom_prob default_obmc_prob[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   255, 255, 255,
 #endif
   255, 255, 255, 151, 153, 144, 178, 165, 160, 207, 195, 168, 244,
 #if CONFIG_EXT_PARTITION
   252, 252, 252,
 #endif  // CONFIG_EXT_PARTITION
 };
 #endif
@@ -1179,27 +1408,47 @@ static const aom_cdf_prob default_delta_
 #if CONFIG_EXT_DELTA_Q
 static const aom_prob default_delta_lf_probs[DELTA_LF_PROBS] = { 220, 220,
                                                                  220 };
 static const aom_cdf_prob default_delta_lf_cdf[CDF_SIZE(DELTA_LF_PROBS + 1)] = {
   AOM_ICDF(28160), AOM_ICDF(32120), AOM_ICDF(32677), AOM_ICDF(32768), 0
 };
 #endif
 #endif
+#if !CONFIG_EC_ADAPT
 int av1_intra_mode_ind[INTRA_MODES];
 int av1_intra_mode_inv[INTRA_MODES];
-int av1_inter_mode_ind[INTER_MODES];
-int av1_inter_mode_inv[INTER_MODES];
+#endif
 #if CONFIG_EXT_TX
 int av1_ext_tx_intra_ind[EXT_TX_SETS_INTRA][TX_TYPES];
 int av1_ext_tx_intra_inv[EXT_TX_SETS_INTRA][TX_TYPES];
 int av1_ext_tx_inter_ind[EXT_TX_SETS_INTER][TX_TYPES];
 int av1_ext_tx_inter_inv[EXT_TX_SETS_INTER][TX_TYPES];
 #endif
 
+#if CONFIG_EC_ADAPT
+#if CONFIG_ALT_INTRA
+#if CONFIG_SMOOTH_HV
+const int av1_intra_mode_ind[INTRA_MODES] = { 0, 2, 3,  6,  4,  5, 8,
+                                              9, 7, 10, 11, 12, 1 };
+const int av1_intra_mode_inv[INTRA_MODES] = { 0, 12, 1, 2, 4,  5, 3,
+                                              8, 6,  7, 9, 10, 11 };
+#else
+const int av1_intra_mode_ind[INTRA_MODES] = {
+  0, 2, 3, 6, 4, 5, 8, 9, 7, 10, 1
+};
+const int av1_intra_mode_inv[INTRA_MODES] = {
+  0, 10, 1, 2, 4, 5, 3, 8, 6, 7, 9
+};
+#endif  // CONFIG_SMOOTH_HV
+#else
+const int av1_intra_mode_ind[INTRA_MODES] = { 0, 2, 3, 6, 4, 5, 8, 9, 7, 1 };
+const int av1_intra_mode_inv[INTRA_MODES] = { 0, 9, 1, 2, 4, 5, 3, 8, 6, 7 }
+#endif  // CONFIG_ALT_INTRA
+#else
 #if CONFIG_ALT_INTRA
 #if CONFIG_SMOOTH_HV
 const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
   -DC_PRED,
   2, /* 0 = DC_NODE */
   -TM_PRED,
   4, /* 1 = TM_NODE */
   -V_PRED,
@@ -1245,21 +1494,17 @@ const aom_tree_index av1_intra_mode_tree
   8,          12,         /* 3 = COM_NODE */
   -H_PRED,    10,         /* 4 = H_NODE */
   -D135_PRED, -D117_PRED, /* 5 = D135_NODE */
   -D45_PRED,  14,         /* 6 = D45_NODE */
   -D63_PRED,  16,         /* 7 = D63_NODE */
   -D153_PRED, -D207_PRED  /* 8 = D153_NODE */
 };
 #endif  // CONFIG_ALT_INTRA
-
-const aom_tree_index av1_inter_mode_tree[TREE_SIZE(INTER_MODES)] = {
-  -INTER_OFFSET(ZEROMV), 2, -INTER_OFFSET(NEARESTMV), 4, -INTER_OFFSET(NEARMV),
-  -INTER_OFFSET(NEWMV)
-};
+#endif  // !CONFIG_EC_ADAPT
 
 #if CONFIG_EXT_INTER
 /* clang-format off */
 #if CONFIG_INTERINTRA
 const aom_tree_index av1_interintra_mode_tree[TREE_SIZE(INTERINTRA_MODES)] = {
   -II_DC_PRED, 2,        /* 0 = II_DC_NODE     */
 #if CONFIG_ALT_INTRA
   -II_SMOOTH_PRED, 4,    /* 1 = II_SMOOTH_PRED */
@@ -1277,23 +1522,33 @@ const aom_tree_index av1_inter_compound_
   6, -INTER_COMPOUND_OFFSET(NEW_NEWMV),
   -INTER_COMPOUND_OFFSET(NEAR_NEARMV), 8,
   10, 12,
   -INTER_COMPOUND_OFFSET(NEAREST_NEWMV), -INTER_COMPOUND_OFFSET(NEW_NEARESTMV),
   -INTER_COMPOUND_OFFSET(NEAR_NEWMV), -INTER_COMPOUND_OFFSET(NEW_NEARMV)
 };
 
 #if CONFIG_COMPOUND_SINGLEREF
+// TODO(zoeliu): To redesign the tree structure once the number of mode changes.
+/*
 const aom_tree_index av1_inter_singleref_comp_mode_tree
     [TREE_SIZE(INTER_SINGLEREF_COMP_MODES)] = {
   -INTER_SINGLEREF_COMP_OFFSET(SR_ZERO_NEWMV), 2,
   -INTER_SINGLEREF_COMP_OFFSET(SR_NEAREST_NEARMV), 4,
   6, -INTER_SINGLEREF_COMP_OFFSET(SR_NEW_NEWMV),
   -INTER_SINGLEREF_COMP_OFFSET(SR_NEAREST_NEWMV),
   -INTER_SINGLEREF_COMP_OFFSET(SR_NEAR_NEWMV)
+};*/
+
+const aom_tree_index av1_inter_singleref_comp_mode_tree
+    [TREE_SIZE(INTER_SINGLEREF_COMP_MODES)] = {
+  -INTER_SINGLEREF_COMP_OFFSET(SR_ZERO_NEWMV), 2,
+  -INTER_SINGLEREF_COMP_OFFSET(SR_NEAREST_NEARMV), 4,
+  -INTER_SINGLEREF_COMP_OFFSET(SR_NEAR_NEWMV),
+      -INTER_SINGLEREF_COMP_OFFSET(SR_NEW_NEWMV)
 };
 #endif  // CONFIG_COMPOUND_SINGLEREF
 
 #if CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
 const aom_tree_index av1_compound_type_tree[TREE_SIZE(COMPOUND_TYPES)] = {
   -COMPOUND_AVERAGE, 2, -COMPOUND_WEDGE, -COMPOUND_SEG
 };
 #elif !CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
@@ -1327,55 +1582,166 @@ const aom_tree_index av1_ext_partition_t
 };
 /* clang-format on */
 #endif  // CONFIG_EXT_PARTITION_TYPES
 
 static const aom_prob default_intra_inter_p[INTRA_INTER_CONTEXTS] = {
   9, 102, 187, 225
 };
 
+#if CONFIG_NEW_MULTISYMBOL
+static const aom_cdf_prob
+    default_intra_inter_cdf[INTRA_INTER_CONTEXTS][CDF_SIZE(2)] = {
+      { AOM_ICDF(1152), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(13056), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(23936), AOM_ICDF(32768), 0 },
+      { AOM_ICDF(28800), AOM_ICDF(32768), 0 }
+    };
+#endif
+
 static const aom_prob default_comp_inter_p[COMP_INTER_CONTEXTS] = {
   239, 183, 119, 96, 41
 };
+#if CONFIG_NEW_MULTISYMBOL
+static const aom_cdf_prob default_comp_inter_cdf[COMP_INTER_CONTEXTS][CDF_SIZE(
+    2)] = { { AOM_ICDF(239 * 128), AOM_ICDF(32768), 0 },
+            { AOM_ICDF(183 * 128), AOM_ICDF(32768), 0 },
+            { AOM_ICDF(119 * 128), AOM_ICDF(32768), 0 },
+            { AOM_ICDF(96 * 128), AOM_ICDF(32768), 0 },
+            { AOM_ICDF(41 * 128), AOM_ICDF(32768), 0 } };
+#endif
+
+#if CONFIG_EXT_COMP_REFS
+static const aom_prob default_comp_ref_type_p[COMP_REF_TYPE_CONTEXTS] = {
+  30, 75, 120, 170, 230
+};
+
+static const aom_prob
+    default_uni_comp_ref_p[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1] = {
+      { 30, 20 }, { 75, 70 }, { 130, 130 }, { 165, 165 }, { 215, 220 }
+    };
+#endif  // CONFIG_EXT_COMP_REFS
 
 #if CONFIG_EXT_REFS
 static const aom_prob default_comp_ref_p[REF_CONTEXTS][FWD_REFS - 1] = {
   // TODO(zoeliu): To adjust the initial prob values.
   { 33, 16, 16 },
   { 77, 74, 74 },
   { 142, 142, 142 },
   { 172, 170, 170 },
   { 238, 247, 247 }
 };
 static const aom_prob default_comp_bwdref_p[REF_CONTEXTS][BWD_REFS - 1] = {
   { 16 }, { 74 }, { 142 }, { 170 }, { 247 }
 };
+#if CONFIG_NEW_MULTISYMBOL
+static const aom_cdf_prob
+    default_comp_ref_cdf[REF_CONTEXTS][FWD_REFS - 1][CDF_SIZE(2)] = {
+      // TODO(zoeliu): To adjust the initial prob values.
+      { { AOM_ICDF(33 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(77 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(172 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(238 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 } }
+    };
+static const aom_cdf_prob
+    default_comp_bwdref_cdf[REF_CONTEXTS][BWD_REFS - 1][CDF_SIZE(2)] = {
+      { { AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 } }
+    };
+#endif  // CONFIG_NEW_MULTISYMBOL
 #else
 static const aom_prob default_comp_ref_p[REF_CONTEXTS][COMP_REFS - 1] = {
   { 50 }, { 126 }, { 123 }, { 221 }, { 226 }
 };
+#if CONFIG_NEW_MULTISYMBOL
+static const aom_cdf_prob
+    default_comp_ref_cdf[REF_CONTEXTS][COMP_REFS - 1][CDF_SIZE(2)] = {
+      { { AOM_ICDF(50 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(126 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(123 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(221 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(226 * 128), AOM_ICDF(32768), 0 } }
+    };
+#endif  // CONFIG_NEW_MULTISYMBOL
 #endif  // CONFIG_EXT_REFS
 
 static const aom_prob default_single_ref_p[REF_CONTEXTS][SINGLE_REFS - 1] = {
 #if CONFIG_EXT_REFS
   { 33, 16, 16, 16, 16 },
   { 77, 74, 74, 74, 74 },
   { 142, 142, 142, 142, 142 },
   { 172, 170, 170, 170, 170 },
   { 238, 247, 247, 247, 247 }
 #else
   { 33, 16 }, { 77, 74 }, { 142, 142 }, { 172, 170 }, { 238, 247 }
 #endif  // CONFIG_EXT_REFS
 };
+#if CONFIG_NEW_MULTISYMBOL
+static const aom_cdf_prob
+    default_single_ref_cdf[REF_CONTEXTS][SINGLE_REFS - 1][CDF_SIZE(2)] = {
+#if CONFIG_EXT_REFS
+      { { AOM_ICDF(33 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(77 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(172 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(238 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 } }
+#else
+      { { AOM_ICDF(33 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(77 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(172 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 } },
+      { { AOM_ICDF(238 * 128), AOM_ICDF(32768), 0 },
+        { AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 } }
+#endif  // CONFIG_EXT_REFS
+    };
+#endif
 
 #if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 // TODO(zoeliu): Default values to be further adjusted based on the collected
 //               stats.
 static const aom_prob default_comp_inter_mode_p[COMP_INTER_MODE_CONTEXTS] = {
-  41, 119, 187, 225
+  40, 110, 160, 220
 };
 #endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 
 #if CONFIG_PALETTE
 
 // Tree to code palette size (number of colors in a palette) and the
 // corresponding probabilities for Y and UV planes.
 const aom_tree_index av1_palette_size_tree[TREE_SIZE(PALETTE_SIZES)] = {
@@ -1762,16 +2128,23 @@ int av1_get_palette_color_index_context(
 
 #if CONFIG_VAR_TX
 static const aom_prob default_txfm_partition_probs[TXFM_PARTITION_CONTEXTS] = {
   250, 231, 212, 241, 166, 66, 241, 230, 135, 243, 154, 64, 248, 161, 63, 128,
 };
 #endif
 
 static const aom_prob default_skip_probs[SKIP_CONTEXTS] = { 192, 128, 64 };
+#if CONFIG_NEW_MULTISYMBOL
+static const aom_cdf_prob default_skip_cdfs[SKIP_CONTEXTS][CDF_SIZE(2)] = {
+  { AOM_ICDF(24576), AOM_ICDF(32768), 0 },
+  { AOM_ICDF(16384), AOM_ICDF(32768), 0 },
+  { AOM_ICDF(8192), AOM_ICDF(32768), 0 }
+};
+#endif
 
 #if CONFIG_DUAL_FILTER
 #if USE_EXTRA_FILTER
 static const aom_prob default_switchable_interp_prob
     [SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS - 1] = {
       { 235, 192, 128 }, { 36, 243, 48 },   { 34, 16, 128 },
       { 34, 16, 128 },   { 149, 160, 128 }, { 235, 192, 128 },
       { 36, 243, 48 },   { 34, 16, 128 },   { 34, 16, 128 },
@@ -2574,27 +2947,16 @@ static const aom_cdf_prob
       { AOM_ICDF(28416), AOM_ICDF(28994), AOM_ICDF(29436), AOM_ICDF(32768), 0 },
       { AOM_ICDF(9216), AOM_ICDF(10688), AOM_ICDF(14483), AOM_ICDF(32768), 0 },
       { AOM_ICDF(7424), AOM_ICDF(10592), AOM_ICDF(11632), AOM_ICDF(32768), 0 },
       { AOM_ICDF(1280), AOM_ICDF(2141), AOM_ICDF(2859), AOM_ICDF(32768), 0 },
 #endif
     };
 #endif
 
-static const aom_cdf_prob
-    default_inter_mode_cdf[INTER_MODE_CONTEXTS][CDF_SIZE(INTER_MODES)] = {
-      { AOM_ICDF(256), AOM_ICDF(22227), AOM_ICDF(23627), AOM_ICDF(32768), 0 },
-      { AOM_ICDF(896), AOM_ICDF(18948), AOM_ICDF(23537), AOM_ICDF(32768), 0 },
-      { AOM_ICDF(896), AOM_ICDF(21563), AOM_ICDF(24320), AOM_ICDF(32768), 0 },
-      { AOM_ICDF(896), AOM_ICDF(12599), AOM_ICDF(17799), AOM_ICDF(32768), 0 },
-      { AOM_ICDF(1024), AOM_ICDF(8960), AOM_ICDF(13238), AOM_ICDF(32768), 0 },
-      { AOM_ICDF(2176), AOM_ICDF(11856), AOM_ICDF(14388), AOM_ICDF(32768), 0 },
-      { AOM_ICDF(3200), AOM_ICDF(6550), AOM_ICDF(9622), AOM_ICDF(32768), 0 },
-    };
-
 #if CONFIG_EXT_TX
 static const aom_cdf_prob default_intra_ext_tx_cdf
     [EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES][CDF_SIZE(TX_TYPES)] = {
       {
 // FIXME: unused zero positions, from uncoded trivial transform set
 #if CONFIG_CHROMA_2X2
           {
               { 0 },
@@ -3061,21 +3423,20 @@ static const aom_cdf_prob
       { AOM_ICDF(12032), AOM_ICDF(17297), AOM_ICDF(23522), AOM_ICDF(32768), 0 },
       { AOM_ICDF(6272), AOM_ICDF(8860), AOM_ICDF(11101), AOM_ICDF(32768), 0 },
       { AOM_ICDF(9216), AOM_ICDF(12712), AOM_ICDF(16629), AOM_ICDF(32768), 0 },
     };
 #endif  // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
 
 #if CONFIG_CFL
 static const aom_cdf_prob default_cfl_alpha_cdf[CDF_SIZE(CFL_ALPHABET_SIZE)] = {
-  // decreasing likelihood, after 6 iterations of alpha RDO on subset 3
-  AOM_ICDF(23928), AOM_ICDF(26267), AOM_ICDF(27319), AOM_ICDF(28330),
-  AOM_ICDF(29341), AOM_ICDF(30160), AOM_ICDF(30581), AOM_ICDF(30983),
-  AOM_ICDF(31353), AOM_ICDF(31634), AOM_ICDF(31907), AOM_ICDF(32171),
-  AOM_ICDF(32407), AOM_ICDF(32558), AOM_ICDF(32669), AOM_ICDF(32768)
+  AOM_ICDF(20492), AOM_ICDF(24094), AOM_ICDF(25679), AOM_ICDF(27242),
+  AOM_ICDF(28286), AOM_ICDF(29153), AOM_ICDF(29807), AOM_ICDF(30352),
+  AOM_ICDF(30866), AOM_ICDF(31295), AOM_ICDF(31703), AOM_ICDF(32046),
+  AOM_ICDF(32317), AOM_ICDF(32534), AOM_ICDF(32663), AOM_ICDF(32768)
 };
 #endif
 
 // CDF version of 'av1_kf_y_mode_prob'.
 const aom_cdf_prob
     av1_kf_y_mode_cdf[INTRA_MODES][INTRA_MODES][CDF_SIZE(INTRA_MODES)] = {
 #if CONFIG_ALT_INTRA
 #if CONFIG_SMOOTH_HV
@@ -4468,69 +4829,108 @@ const aom_cdf_prob
           AOM_ICDF(29938), AOM_ICDF(32768), 0 },
         { AOM_ICDF(5504), AOM_ICDF(14131), AOM_ICDF(17989), AOM_ICDF(23324),
           AOM_ICDF(25513), AOM_ICDF(26071), AOM_ICDF(27850), AOM_ICDF(29464),
           AOM_ICDF(30393), AOM_ICDF(32768), 0 } },
 #endif  // CONFIG_ALT_INTRA
     };
 
 static void init_mode_probs(FRAME_CONTEXT *fc) {
+#if !CONFIG_EC_ADAPT
   av1_copy(fc->uv_mode_prob, default_uv_probs);
   av1_copy(fc->y_mode_prob, default_if_y_probs);
+#endif
   av1_copy(fc->switchable_interp_prob, default_switchable_interp_prob);
   av1_copy(fc->partition_prob, default_partition_probs);
   av1_copy(fc->intra_inter_prob, default_intra_inter_p);
   av1_copy(fc->comp_inter_prob, default_comp_inter_p);
+#if CONFIG_NEW_MULTISYMBOL
+  av1_copy(fc->comp_inter_cdf, default_comp_inter_cdf);
+#endif
+#if CONFIG_EXT_COMP_REFS
+  av1_copy(fc->comp_ref_type_prob, default_comp_ref_type_p);
+  av1_copy(fc->uni_comp_ref_prob, default_uni_comp_ref_p);
+#endif  // CONFIG_EXT_COMP_REFS
   av1_copy(fc->comp_ref_prob, default_comp_ref_p);
+#if CONFIG_NEW_MULTISYMBOL
+  av1_copy(fc->comp_ref_cdf, default_comp_ref_cdf);
+#endif
 #if CONFIG_LV_MAP
   av1_copy(fc->txb_skip, default_txb_skip);
   av1_copy(fc->nz_map, default_nz_map);
   av1_copy(fc->eob_flag, default_eob_flag);
   av1_copy(fc->dc_sign, default_dc_sign);
   av1_copy(fc->coeff_base, default_coeff_base);
   av1_copy(fc->coeff_lps, default_coeff_lps);
 #endif
 #if CONFIG_EXT_REFS
   av1_copy(fc->comp_bwdref_prob, default_comp_bwdref_p);
+#if CONFIG_NEW_MULTISYMBOL
+  av1_copy(fc->comp_bwdref_cdf, default_comp_bwdref_cdf);
+#endif
 #endif  // CONFIG_EXT_REFS
   av1_copy(fc->single_ref_prob, default_single_ref_p);
+#if CONFIG_NEW_MULTISYMBOL
+  av1_copy(fc->single_ref_cdf, default_single_ref_cdf);
+#endif
 #if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   av1_copy(fc->comp_inter_mode_prob, default_comp_inter_mode_p);
 #endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   av1_copy(fc->tx_size_probs, default_tx_size_prob);
 #if CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
   fc->quarter_tx_size_prob = default_quarter_tx_size_prob;
 #endif  // CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
 #if CONFIG_VAR_TX
   av1_copy(fc->txfm_partition_prob, default_txfm_partition_probs);
 #endif
   av1_copy(fc->skip_probs, default_skip_probs);
   av1_copy(fc->newmv_prob, default_newmv_prob);
   av1_copy(fc->zeromv_prob, default_zeromv_prob);
   av1_copy(fc->refmv_prob, default_refmv_prob);
   av1_copy(fc->drl_prob, default_drl_prob);
-  av1_copy(fc->inter_mode_probs, default_inter_mode_probs);
+#if CONFIG_NEW_MULTISYMBOL
+  av1_copy(fc->newmv_cdf, default_newmv_cdf);
+  av1_copy(fc->zeromv_cdf, default_zeromv_cdf);
+  av1_copy(fc->refmv_cdf, default_refmv_cdf);
+  av1_copy(fc->drl_cdf, default_drl_cdf);
+#endif
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   av1_copy(fc->motion_mode_prob, default_motion_mode_prob);
+#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
+  av1_copy(fc->ncobmc_mode_prob, default_ncobmc_mode_prob);
+#endif
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
   av1_copy(fc->obmc_prob, default_obmc_prob);
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 #if CONFIG_EXT_INTER
   av1_copy(fc->inter_compound_mode_probs, default_inter_compound_mode_probs);
+#if CONFIG_EC_ADAPT
+  av1_copy(fc->inter_compound_mode_cdf, default_inter_compound_mode_cdf);
+#endif
 #if CONFIG_COMPOUND_SINGLEREF
   av1_copy(fc->inter_singleref_comp_mode_probs,
            default_inter_singleref_comp_mode_probs);
 #endif  // CONFIG_COMPOUND_SINGLEREF
   av1_copy(fc->compound_type_prob, default_compound_type_probs);
+#if CONFIG_EC_ADAPT
+  av1_copy(fc->compound_type_cdf, default_compound_type_cdf);
+#endif
 #if CONFIG_INTERINTRA
   av1_copy(fc->interintra_prob, default_interintra_prob);
+  av1_copy(fc->wedge_interintra_prob, default_wedge_interintra_prob);
+#if CONFIG_NEW_MULTISYMBOL
+  av1_copy(fc->interintra_cdf, default_interintra_cdf);
+  av1_copy(fc->wedge_interintra_cdf, default_wedge_interintra_cdf);
+#endif  // CONFIG_NEW_MULTISYMBOL
   av1_copy(fc->interintra_mode_prob, default_interintra_mode_prob);
-  av1_copy(fc->wedge_interintra_prob, default_wedge_interintra_prob);
+#if CONFIG_EC_ADAPT
+  av1_copy(fc->interintra_mode_cdf, default_interintra_mode_cdf);
 #endif
+#endif  // CONFIG_INTERINTRA
 #endif  // CONFIG_EXT_INTER
 #if CONFIG_SUPERTX
   av1_copy(fc->supertx_prob, default_supertx_prob);
 #endif  // CONFIG_SUPERTX
   av1_copy(fc->seg.tree_probs, default_segment_tree_probs);
   av1_copy(fc->seg.pred_probs, default_segment_pred_probs);
 #if CONFIG_EXT_INTRA
 #if CONFIG_INTRA_INTERP
@@ -4544,19 +4944,22 @@ static void init_mode_probs(FRAME_CONTEX
   av1_copy(fc->intra_ext_tx_prob, default_intra_ext_tx_prob);
 #if CONFIG_LOOP_RESTORATION
   av1_copy(fc->switchable_restore_prob, default_switchable_restore_prob);
 #endif  // CONFIG_LOOP_RESTORATION
   av1_copy(fc->y_mode_cdf, default_if_y_mode_cdf);
   av1_copy(fc->uv_mode_cdf, default_uv_mode_cdf);
   av1_copy(fc->switchable_interp_cdf, default_switchable_interp_cdf);
   av1_copy(fc->partition_cdf, default_partition_cdf);
-  av1_copy(fc->inter_mode_cdf, default_inter_mode_cdf);
   av1_copy(fc->intra_ext_tx_cdf, default_intra_ext_tx_cdf);
   av1_copy(fc->inter_ext_tx_cdf, default_inter_ext_tx_cdf);
+#if CONFIG_NEW_MULTISYMBOL
+  av1_copy(fc->skip_cdfs, default_skip_cdfs);
+  av1_copy(fc->intra_inter_cdf, default_intra_inter_cdf);
+#endif
 #if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
   av1_copy(fc->intra_filter_cdf, default_intra_filter_cdf);
 #endif  // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
   av1_copy(fc->seg.tree_cdf, default_seg_tree_cdf);
   av1_copy(fc->tx_size_cdf, default_tx_size_cdf);
 #if CONFIG_DELTA_Q
   av1_copy(fc->delta_q_prob, default_delta_q_probs);
   av1_copy(fc->delta_q_cdf, default_delta_q_cdf);
@@ -4580,19 +4983,21 @@ int av1_switchable_interp_inv[SWITCHABLE
 void av1_set_mode_cdfs(struct AV1Common *cm) {
   FRAME_CONTEXT *fc = cm->fc;
   int i, j;
   if (cm->seg.enabled && cm->seg.update_map) {
     av1_tree_to_cdf(av1_segment_tree, cm->fc->seg.tree_probs,
                     cm->fc->seg.tree_cdf);
   }
 
+#if !CONFIG_EC_ADAPT
   for (i = 0; i < INTRA_MODES; ++i)
     av1_tree_to_cdf(av1_intra_mode_tree, fc->uv_mode_prob[i],
                     fc->uv_mode_cdf[i]);
+#endif
 #if CONFIG_EXT_PARTITION_TYPES
   for (i = 0; i < PARTITION_PLOFFSET; ++i)
     av1_tree_to_cdf(av1_partition_tree, fc->partition_prob[i],
                     fc->partition_cdf[i]);
   // Logical index (enum value) to inorder index (tree_to_cdf order)
   aom_cdf_prob inorder_partition_cdf[CDF_SIZE(EXT_PARTITION_TYPES)] = {};
   // TODO(aconverse): Generate this dynamically. The assumptions that
   // av1_indices_from_tree() makes don't hold for this tree.
@@ -4615,31 +5020,31 @@ void av1_set_mode_cdfs(struct AV1Common 
     assert(cum_prob == CDF_PROB_TOP);
   }
 #else
   for (i = 0; i < PARTITION_CONTEXTS; ++i)
     av1_tree_to_cdf(av1_partition_tree, fc->partition_prob[i],
                     fc->partition_cdf[i]);
 #endif
 
+#if !CONFIG_EC_ADAPT
   for (i = 0; i < INTRA_MODES; ++i)
     for (j = 0; j < INTRA_MODES; ++j)
       av1_tree_to_cdf(av1_intra_mode_tree, cm->kf_y_prob[i][j],
                       cm->fc->kf_y_cdf[i][j]);
+#endif
 
   for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j)
     av1_tree_to_cdf(av1_switchable_interp_tree, fc->switchable_interp_prob[j],
                     fc->switchable_interp_cdf[j]);
 
-  for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
-    av1_tree_to_cdf(av1_inter_mode_tree, fc->inter_mode_probs[i],
-                    fc->inter_mode_cdf[i]);
-
+#if !CONFIG_EC_ADAPT
   for (i = 0; i < BLOCK_SIZE_GROUPS; ++i)
     av1_tree_to_cdf(av1_intra_mode_tree, fc->y_mode_prob[i], fc->y_mode_cdf[i]);
+#endif
 
 #if CONFIG_EXT_TX
   int s;
   for (s = 0; s < EXT_TX_SETS_INTRA; ++s)
     for (i = TX_4X4; i < EXT_TX_SIZES; ++i)
       for (j = 0; j < INTRA_MODES; ++j)
         av1_tree_to_cdf(av1_ext_tx_intra_tree[s],
                         fc->intra_ext_tx_prob[s][i][j],
@@ -4694,16 +5099,27 @@ void av1_adapt_inter_frame_probs(AV1_COM
   for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
     fc->intra_inter_prob[i] = av1_mode_mv_merge_probs(
         pre_fc->intra_inter_prob[i], counts->intra_inter[i]);
 
   for (i = 0; i < COMP_INTER_CONTEXTS; i++)
     fc->comp_inter_prob[i] = av1_mode_mv_merge_probs(pre_fc->comp_inter_prob[i],
                                                      counts->comp_inter[i]);
 
+#if CONFIG_EXT_COMP_REFS
+  for (i = 0; i < COMP_REF_TYPE_CONTEXTS; i++)
+    fc->comp_ref_type_prob[i] = av1_mode_mv_merge_probs(
+        pre_fc->comp_ref_type_prob[i], counts->comp_ref_type[i]);
+
+  for (i = 0; i < UNI_COMP_REF_CONTEXTS; i++)
+    for (j = 0; j < (UNIDIR_COMP_REFS - 1); j++)
+      fc->uni_comp_ref_prob[i][j] = av1_mode_mv_merge_probs(
+          pre_fc->uni_comp_ref_prob[i][j], counts->uni_comp_ref[i][j]);
+#endif  // CONFIG_EXT_COMP_REFS
+
 #if CONFIG_EXT_REFS
   for (i = 0; i < REF_CONTEXTS; i++)
     for (j = 0; j < (FWD_REFS - 1); j++)
       fc->comp_ref_prob[i][j] = mode_mv_merge_probs(pre_fc->comp_ref_prob[i][j],
                                                     counts->comp_ref[i][j]);
   for (i = 0; i < REF_CONTEXTS; i++)
     for (j = 0; j < (BWD_REFS - 1); j++)
       fc->comp_bwdref_prob[i][j] = mode_mv_merge_probs(
@@ -4740,16 +5156,21 @@ void av1_adapt_inter_frame_probs(AV1_COM
   for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
     fc->drl_prob[i] =
         av1_mode_mv_merge_probs(pre_fc->drl_prob[i], counts->drl_mode[i]);
 
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
     aom_tree_merge_probs(av1_motion_mode_tree, pre_fc->motion_mode_prob[i],
                          counts->motion_mode[i], fc->motion_mode_prob[i]);
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+  for (i = 0; i < ADAPT_OVERLAP_BLOCKS; ++i)
+    aom_tree_merge_probs(av1_ncobmc_mode_tree, pre_fc->ncobmc_mode_prob[i],
+                         counts->ncobmc_mode[i], fc->ncobmc_mode_prob[i]);
+#endif
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
   for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
     fc->obmc_prob[i] =
         av1_mode_mv_merge_probs(pre_fc->obmc_prob[i], counts->obmc[i]);
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
 #if CONFIG_SUPERTX
@@ -4801,19 +5222,21 @@ void av1_adapt_inter_frame_probs(AV1_COM
       aom_tree_merge_probs(
           av1_compound_type_tree, pre_fc->compound_type_prob[i],
           counts->compound_interinter[i], fc->compound_type_prob[i]);
     }
   }
 #endif  // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
 #endif  // CONFIG_EXT_INTER
 
+#if !CONFIG_EC_ADAPT
   for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
     aom_tree_merge_probs(av1_intra_mode_tree, pre_fc->y_mode_prob[i],
                          counts->y_mode[i], fc->y_mode_prob[i]);
+#endif
 
   if (cm->interp_filter == SWITCHABLE) {
     for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++)
       aom_tree_merge_probs(
           av1_switchable_interp_tree, pre_fc->switchable_interp_prob[i],
           counts->switchable_interp[i], fc->switchable_interp_prob[i]);
   }
 }
@@ -4888,19 +5311,21 @@ void av1_adapt_intra_frame_probs(AV1_COM
 
     aom_tree_merge_probs(av1_segment_tree, pre_fc->seg.tree_probs,
                          counts->seg.tree_mispred, fc->seg.tree_probs);
   } else {
     aom_tree_merge_probs(av1_segment_tree, pre_fc->seg.tree_probs,
                          counts->seg.tree_total, fc->seg.tree_probs);
   }
 
+#if !CONFIG_EC_ADAPT
   for (i = 0; i < INTRA_MODES; ++i)
     aom_tree_merge_probs(av1_intra_mode_tree, pre_fc->uv_mode_prob[i],
                          counts->uv_mode[i], fc->uv_mode_prob[i]);
+#endif
 
 #if CONFIG_EXT_PARTITION_TYPES
   for (i = 0; i < PARTITION_PLOFFSET; ++i)
     aom_tree_merge_probs(av1_partition_tree, pre_fc->partition_prob[i],
                          counts->partition[i], fc->partition_prob[i]);
   for (; i < PARTITION_CONTEXTS_PRIMARY; ++i)
     aom_tree_merge_probs(av1_ext_partition_tree, pre_fc->partition_prob[i],
                          counts->partition[i], fc->partition_prob[i]);
--- a/third_party/aom/av1/common/entropymode.h
+++ b/third_party/aom/av1/common/entropymode.h
@@ -180,58 +180,103 @@ typedef struct frame_contexts {
                      [COEFF_BASE_CONTEXTS];
   aom_prob coeff_lps[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS];
 #endif
 
   aom_prob newmv_prob[NEWMV_MODE_CONTEXTS];
   aom_prob zeromv_prob[ZEROMV_MODE_CONTEXTS];
   aom_prob refmv_prob[REFMV_MODE_CONTEXTS];
   aom_prob drl_prob[DRL_MODE_CONTEXTS];
+#if CONFIG_NEW_MULTISYMBOL
+  aom_cdf_prob newmv_cdf[NEWMV_MODE_CONTEXTS][CDF_SIZE(2)];
+  aom_cdf_prob zeromv_cdf[ZEROMV_MODE_CONTEXTS][CDF_SIZE(2)];
+  aom_cdf_prob refmv_cdf[REFMV_MODE_CONTEXTS][CDF_SIZE(2)];
+  aom_cdf_prob drl_cdf[DRL_MODE_CONTEXTS][CDF_SIZE(2)];
+#endif
 
-  aom_prob inter_mode_probs[INTER_MODE_CONTEXTS][INTER_MODES - 1];
 #if CONFIG_EXT_INTER
   aom_prob inter_compound_mode_probs[INTER_MODE_CONTEXTS]
                                     [INTER_COMPOUND_MODES - 1];
+#if CONFIG_EC_ADAPT
+  aom_cdf_prob inter_compound_mode_cdf[INTER_MODE_CONTEXTS]
+                                      [CDF_SIZE(INTER_COMPOUND_MODES)];
+#endif
 #if CONFIG_COMPOUND_SINGLEREF
   aom_prob inter_singleref_comp_mode_probs[INTER_MODE_CONTEXTS]
                                           [INTER_SINGLEREF_COMP_MODES - 1];
 #endif  // CONFIG_COMPOUND_SINGLEREF
   aom_prob compound_type_prob[BLOCK_SIZES][COMPOUND_TYPES - 1];
+#if CONFIG_EC_ADAPT
+  aom_cdf_prob compound_type_cdf[BLOCK_SIZES][CDF_SIZE(COMPOUND_TYPES)];
+#endif
 #if CONFIG_INTERINTRA
   aom_prob interintra_prob[BLOCK_SIZE_GROUPS];
+  aom_prob wedge_interintra_prob[BLOCK_SIZES];
   aom_prob interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1];
-  aom_prob wedge_interintra_prob[BLOCK_SIZES];
+#if CONFIG_EC_ADAPT
+#if CONFIG_NEW_MULTISYMBOL
+  aom_cdf_prob interintra_cdf[BLOCK_SIZE_GROUPS][CDF_SIZE(2)];
+  aom_cdf_prob wedge_interintra_cdf[BLOCK_SIZES][CDF_SIZE(2)];
+#endif
+  aom_cdf_prob interintra_mode_cdf[BLOCK_SIZE_GROUPS]
+                                  [CDF_SIZE(INTERINTRA_MODES)];
+#endif
 #endif  // CONFIG_INTERINTRA
 #endif  // CONFIG_EXT_INTER
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   aom_prob motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1];
+
+#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
+  aom_prob ncobmc_mode_prob[ADAPT_OVERLAP_BLOCKS][MAX_NCOBMC_MODES - 1];
+#endif
+
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
   aom_prob obmc_prob[BLOCK_SIZES];
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   aom_prob intra_inter_prob[INTRA_INTER_CONTEXTS];
   aom_prob comp_inter_prob[COMP_INTER_CONTEXTS];
+#if CONFIG_NEW_MULTISYMBOL
+  aom_cdf_prob comp_inter_cdf[COMP_INTER_CONTEXTS][CDF_SIZE(2)];
+  aom_cdf_prob single_ref_cdf[REF_CONTEXTS][SINGLE_REFS - 1][CDF_SIZE(2)];
+#endif
+#if CONFIG_EXT_COMP_REFS
+  aom_prob comp_ref_type_prob[COMP_REF_TYPE_CONTEXTS];
+  aom_prob uni_comp_ref_prob[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1];
+#endif  // CONFIG_EXT_COMP_REFS
   aom_prob single_ref_prob[REF_CONTEXTS][SINGLE_REFS - 1];
 #if CONFIG_EXT_REFS
   aom_prob comp_ref_prob[REF_CONTEXTS][FWD_REFS - 1];
   aom_prob comp_bwdref_prob[REF_CONTEXTS][BWD_REFS - 1];
 #else
   aom_prob comp_ref_prob[REF_CONTEXTS][COMP_REFS - 1];
 #endif  // CONFIG_EXT_REFS
+#if CONFIG_NEW_MULTISYMBOL
+#if CONFIG_EXT_REFS
+  aom_cdf_prob comp_ref_cdf[REF_CONTEXTS][FWD_REFS - 1][CDF_SIZE(2)];
+  aom_cdf_prob comp_bwdref_cdf[REF_CONTEXTS][BWD_REFS - 1][CDF_SIZE(2)];
+#else
+  aom_cdf_prob comp_ref_cdf[REF_CONTEXTS][COMP_REFS - 1][CDF_SIZE(2)];
+#endif  // CONFIG_EXT_REFS
+#endif
 #if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   aom_prob comp_inter_mode_prob[COMP_INTER_MODE_CONTEXTS];
 #endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   aom_prob tx_size_probs[MAX_TX_DEPTH][TX_SIZE_CONTEXTS][MAX_TX_DEPTH];
 #if CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
   aom_prob quarter_tx_size_prob;
 #endif  // CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
 #if CONFIG_VAR_TX
   aom_prob txfm_partition_prob[TXFM_PARTITION_CONTEXTS];
 #endif
   aom_prob skip_probs[SKIP_CONTEXTS];
+#if CONFIG_NEW_MULTISYMBOL
+  aom_cdf_prob skip_cdfs[SKIP_CONTEXTS][CDF_SIZE(2)];
+  aom_cdf_prob intra_inter_cdf[INTRA_INTER_CONTEXTS][CDF_SIZE(2)];
+#endif
   nmv_context nmvc[NMV_CONTEXTS];
 #if CONFIG_INTRABC
   nmv_context ndvc;
   aom_prob intrabc_prob;
 #endif
   int initialized;
 #if CONFIG_EXT_TX
   aom_prob inter_ext_tx_prob[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES - 1];
@@ -248,34 +293,32 @@ typedef struct frame_contexts {
 #if CONFIG_EXT_INTRA
 #if CONFIG_INTRA_INTERP
   aom_prob intra_filter_probs[INTRA_FILTERS + 1][INTRA_FILTERS - 1];
 #endif  // CONFIG_INTRA_INTERP
 #endif  // CONFIG_EXT_INTRA
 #if CONFIG_FILTER_INTRA
   aom_prob filter_intra_probs[PLANE_TYPES];
 #endif  // CONFIG_FILTER_INTRA
-#if CONFIG_GLOBAL_MOTION
-  aom_prob global_motion_types_prob[GLOBAL_TRANS_TYPES - 1];
-#endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_LOOP_RESTORATION
   aom_prob switchable_restore_prob[RESTORE_SWITCHABLE_TYPES - 1];
 #endif  // CONFIG_LOOP_RESTORATION
   aom_cdf_prob y_mode_cdf[BLOCK_SIZE_GROUPS][CDF_SIZE(INTRA_MODES)];
   aom_cdf_prob uv_mode_cdf[INTRA_MODES][CDF_SIZE(INTRA_MODES)];
 #if CONFIG_EXT_PARTITION_TYPES
   aom_cdf_prob partition_cdf[PARTITION_CONTEXTS][CDF_SIZE(EXT_PARTITION_TYPES)];
 #else
   aom_cdf_prob partition_cdf[PARTITION_CONTEXTS][CDF_SIZE(PARTITION_TYPES)];
 #endif
   aom_cdf_prob switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS]
                                     [CDF_SIZE(SWITCHABLE_FILTERS)];
-  aom_cdf_prob inter_mode_cdf[INTER_MODE_CONTEXTS][CDF_SIZE(INTER_MODES)];
-  /* Keep track of kf_y_cdf here, as this makes handling
-     multiple copies for adaptation in tiles easier */
+  /* kf_y_cdf is discarded after use, so does not require persistent storage.
+     However, we keep it with the other CDFs in this struct since it needs to
+     be copied to each tile to support parallelism just like the others.
+   */
   aom_cdf_prob kf_y_cdf[INTRA_MODES][INTRA_MODES][CDF_SIZE(INTRA_MODES)];
   aom_cdf_prob tx_size_cdf[MAX_TX_DEPTH][TX_SIZE_CONTEXTS]
                           [CDF_SIZE(MAX_TX_DEPTH + 1)];
 #if CONFIG_DELTA_Q
   aom_cdf_prob delta_q_cdf[CDF_SIZE(DELTA_Q_PROBS + 1)];
 #if CONFIG_EXT_DELTA_Q
   aom_cdf_prob delta_lf_cdf[CDF_SIZE(DELTA_LF_PROBS + 1)];
 #endif
@@ -304,21 +347,23 @@ typedef struct frame_contexts {
   od_adapt_ctx pvq_context;
 #endif  // CONFIG_PVQ
 #if CONFIG_CFL
   aom_cdf_prob cfl_alpha_cdf[CDF_SIZE(CFL_ALPHABET_SIZE)];
 #endif
 } FRAME_CONTEXT;
 
 typedef struct FRAME_COUNTS {
-  // Note: This structure should only contain 'unsigned int' fields, or
-  // aggregates built solely from 'unsigned int' fields/elements
+// Note: This structure should only contain 'unsigned int' fields, or
+// aggregates built solely from 'unsigned int' fields/elements
+#if !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
   unsigned int kf_y_mode[INTRA_MODES][INTRA_MODES][INTRA_MODES];
   unsigned int y_mode[BLOCK_SIZE_GROUPS][INTRA_MODES];
   unsigned int uv_mode[INTRA_MODES][INTRA_MODES];
+#endif  // !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
 #if CONFIG_EXT_PARTITION_TYPES
   unsigned int partition[PARTITION_CONTEXTS][EXT_PARTITION_TYPES];
 #else
   unsigned int partition[PARTITION_CONTEXTS][PARTITION_TYPES];
 #endif
   av1_coeff_count_model coef[TX_SIZES][PLANE_TYPES];
   unsigned int eob_branch[TX_SIZES][PLANE_TYPES][REF_TYPES][COEF_BANDS]
                          [COEFF_CONTEXTS];
@@ -355,38 +400,44 @@ typedef struct FRAME_COUNTS {
 
   av1_blockz_count_model blockz_count[TX_SIZES][PLANE_TYPES];
 
   unsigned int newmv_mode[NEWMV_MODE_CONTEXTS][2];
   unsigned int zeromv_mode[ZEROMV_MODE_CONTEXTS][2];
   unsigned int refmv_mode[REFMV_MODE_CONTEXTS][2];
   unsigned int drl_mode[DRL_MODE_CONTEXTS][2];
 
-  unsigned int inter_mode[INTER_MODE_CONTEXTS][INTER_MODES];
 #if CONFIG_EXT_INTER
   unsigned int inter_compound_mode[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES];
 #if CONFIG_COMPOUND_SINGLEREF
   unsigned int inter_singleref_comp_mode[INTER_MODE_CONTEXTS]
                                         [INTER_SINGLEREF_COMP_MODES];
 #endif  // CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_INTERINTRA
   unsigned int interintra[BLOCK_SIZE_GROUPS][2];
   unsigned int interintra_mode[BLOCK_SIZE_GROUPS][INTERINTRA_MODES];
   unsigned int wedge_interintra[BLOCK_SIZES][2];
 #endif  // CONFIG_INTERINTRA
   unsigned int compound_interinter[BLOCK_SIZES][COMPOUND_TYPES];
 #endif  // CONFIG_EXT_INTER
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   unsigned int motion_mode[BLOCK_SIZES][MOTION_MODES];
+#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
+  unsigned int ncobmc_mode[ADAPT_OVERLAP_BLOCKS][MAX_NCOBMC_MODES];
+#endif
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
   unsigned int obmc[BLOCK_SIZES][2];
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   unsigned int intra_inter[INTRA_INTER_CONTEXTS][2];
   unsigned int comp_inter[COMP_INTER_CONTEXTS][2];
+#if CONFIG_EXT_COMP_REFS
+  unsigned int comp_ref_type[COMP_REF_TYPE_CONTEXTS][2];
+  unsigned int uni_comp_ref[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1][2];
+#endif  // CONFIG_EXT_COMP_REFS
   unsigned int single_ref[REF_CONTEXTS][SINGLE_REFS - 1][2];
 #if CONFIG_EXT_REFS
   unsigned int comp_ref[REF_CONTEXTS][FWD_REFS - 1][2];
   unsigned int comp_bwdref[REF_CONTEXTS][BWD_REFS - 1][2];
 #else
   unsigned int comp_ref[REF_CONTEXTS][COMP_REFS - 1][2];
 #endif  // CONFIG_EXT_REFS
 #if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
@@ -436,21 +487,23 @@ typedef struct FRAME_COUNTS {
   unsigned int intra_filter[INTRA_FILTERS + 1][INTRA_FILTERS];
 #endif  // CONFIG_INTRA_INTERP
 #endif  // CONFIG_EXT_INTRA
 #if CONFIG_FILTER_INTRA
   unsigned int filter_intra[PLANE_TYPES][2];
 #endif  // CONFIG_FILTER_INTRA
 } FRAME_COUNTS;
 
+#if !CONFIG_EC_ADAPT
 // Default probabilities for signaling Intra mode for Y plane -- used only for
 // intra-only frames. ('default_if_y_probs' is used for inter frames).
 // Contexts used: Intra mode (Y plane) of 'above' and 'left' blocks.
 extern const aom_prob av1_kf_y_mode_prob[INTRA_MODES][INTRA_MODES]
                                         [INTRA_MODES - 1];
+#endif
 // CDF version of 'av1_kf_y_mode_prob'.
 extern const aom_cdf_prob av1_kf_y_mode_cdf[INTRA_MODES][INTRA_MODES]
                                            [CDF_SIZE(INTRA_MODES)];
 
 #if CONFIG_PALETTE
 extern const aom_prob av1_default_palette_y_mode_prob[PALETTE_BLOCK_SIZES]
                                                      [PALETTE_Y_MODE_CONTEXTS];
 extern const aom_prob
@@ -460,22 +513,24 @@ extern const aom_prob av1_default_palett
 extern const aom_prob av1_default_palette_uv_size_prob[PALETTE_BLOCK_SIZES]
                                                       [PALETTE_SIZES - 1];
 extern const aom_prob av1_default_palette_y_color_index_prob
     [PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS][PALETTE_COLORS - 1];
 extern const aom_prob av1_default_palette_uv_color_index_prob
     [PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS][PALETTE_COLORS - 1];
 #endif  // CONFIG_PALETTE
 
+#if !CONFIG_EC_ADAPT
 extern const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)];
-extern const aom_tree_index av1_inter_mode_tree[TREE_SIZE(INTER_MODES)];
 extern int av1_intra_mode_ind[INTRA_MODES];
 extern int av1_intra_mode_inv[INTRA_MODES];
-extern int av1_inter_mode_ind[INTER_MODES];
-extern int av1_inter_mode_inv[INTER_MODES];
+#else
+extern const int av1_intra_mode_ind[INTRA_MODES];
+extern const int av1_intra_mode_inv[INTRA_MODES];
+#endif
 #if CONFIG_EXT_TX
 extern int av1_ext_tx_intra_ind[EXT_TX_SETS_INTRA][TX_TYPES];
 extern int av1_ext_tx_intra_inv[EXT_TX_SETS_INTRA][TX_TYPES];
 extern int av1_ext_tx_inter_ind[EXT_TX_SETS_INTER][TX_TYPES];
 extern int av1_ext_tx_inter_inv[EXT_TX_SETS_INTER][TX_TYPES];
 #endif
 
 #if CONFIG_EXT_INTER
@@ -513,17 +568,19 @@ extern const aom_tree_index av1_ext_tx_i
 extern const aom_tree_index av1_ext_tx_intra_tree[EXT_TX_SETS_INTRA]
                                                  [TREE_SIZE(TX_TYPES)];
 #else
 extern const aom_tree_index av1_ext_tx_tree[TREE_SIZE(TX_TYPES)];
 #endif  // CONFIG_EXT_TX
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 extern const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)];
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
-
+#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
+extern const aom_tree_index av1_ncobmc_mode_tree[TREE_SIZE(MAX_NCOBMC_MODES)];
+#endif
 #if CONFIG_LOOP_RESTORATION
 #define RESTORE_NONE_SGRPROJ_PROB 64
 #define RESTORE_NONE_BILATERAL_PROB 16
 #define RESTORE_NONE_WIENER_PROB 64
 #define RESTORE_NONE_DOMAINTXFMRF_PROB 64
 extern const aom_tree_index
     av1_switchable_restore_tree[TREE_SIZE(RESTORE_SWITCHABLE_TYPES)];
 #endif  // CONFIG_LOOP_RESTORATION
--- a/third_party/aom/av1/common/entropymv.c
+++ b/third_party/aom/av1/common/entropymv.c
@@ -125,103 +125,73 @@ static const uint8_t log_in_base_2[] = {
   9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
   9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
   9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
   9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
   9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
   9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10
 };
 
-#if CONFIG_GLOBAL_MOTION
-#if GLOBAL_TRANS_TYPES == 7  // All models
-const aom_tree_index av1_global_motion_types_tree[TREE_SIZE(
-    GLOBAL_TRANS_TYPES)] = { -IDENTITY,   2,  -TRANSLATION,  4,
-                             -ROTZOOM,    6,  -AFFINE,       8,
-                             -HOMOGRAPHY, 10, -HORTRAPEZOID, -VERTRAPEZOID };
-
-static const aom_prob default_global_motion_types_prob[GLOBAL_TRANS_TYPES - 1] =
-    { 224, 128, 192, 192, 32, 128 };
-
-#elif GLOBAL_TRANS_TYPES == 6  // Do not allow full homography
-const aom_tree_index
-    av1_global_motion_types_tree[TREE_SIZE(GLOBAL_TRANS_TYPES)] = {
-      -IDENTITY,    2, -TRANSLATION, 4, -ROTZOOM, 6, -AFFINE, 8, -HORTRAPEZOID,
-      -VERTRAPEZOID
-    };
-
-static const aom_prob default_global_motion_types_prob[GLOBAL_TRANS_TYPES - 1] =
-    { 224, 128, 192, 192, 128 };
-
-#elif GLOBAL_TRANS_TYPES == 4  // Upto Affine
-const aom_tree_index av1_global_motion_types_tree[TREE_SIZE(
-    GLOBAL_TRANS_TYPES)] = { -IDENTITY, 2, -TRANSLATION, 4, -ROTZOOM, -AFFINE };
-
-static const aom_prob default_global_motion_types_prob[GLOBAL_TRANS_TYPES - 1] =
-    { 224, 128, 240 };
-
-#elif GLOBAL_TRANS_TYPES == 3  // Upto rotation-zoom
-
-const aom_tree_index av1_global_motion_types_tree[TREE_SIZE(
-    GLOBAL_TRANS_TYPES)] = { -IDENTITY, 2, -TRANSLATION, -ROTZOOM };
-
-static const aom_prob default_global_motion_types_prob[GLOBAL_TRANS_TYPES - 1] =
-    { 224, 128 };
-#endif                         // GLOBAL_TRANS_TYPES
-#endif                         // CONFIG_GLOBAL_MOTION
-
 static INLINE int mv_class_base(MV_CLASS_TYPE c) {
   return c ? CLASS0_SIZE << (c + 2) : 0;
 }
 
 MV_CLASS_TYPE av1_get_mv_class(int z, int *offset) {
   const MV_CLASS_TYPE c = (z >= CLASS0_SIZE * 4096)
                               ? MV_CLASS_10
                               : (MV_CLASS_TYPE)log_in_base_2[z >> 3];
   if (offset) *offset = z - mv_class_base(c);
   return c;
 }
 
 static void inc_mv_component(int v, nmv_component_counts *comp_counts, int incr,
-                             int usehp) {
+                             MvSubpelPrecision precision) {
   int s, z, c, o, d, e, f;
   assert(v != 0); /* should not be zero */
   s = v < 0;
   comp_counts->sign[s] += incr;
   z = (s ? -v : v) - 1; /* magnitude - 1 */
 
   c = av1_get_mv_class(z, &o);
   comp_counts->classes[c] += incr;
 
   d = (o >> 3);     /* int mv data */
   f = (o >> 1) & 3; /* fractional pel mv data */
   e = (o & 1);      /* high precision mv data */
 
   if (c == MV_CLASS_0) {
     comp_counts->class0[d] += incr;
-    comp_counts->class0_fp[d][f] += incr;
-    if (usehp) comp_counts->class0_hp[e] += incr;
+#if CONFIG_INTRABC
+    if (precision > MV_SUBPEL_NONE)
+#endif
+      comp_counts->class0_fp[d][f] += incr;
+    if (precision > MV_SUBPEL_LOW_PRECISION) comp_counts->class0_hp[e] += incr;
   } else {
     int i;
     int b = c + CLASS0_BITS - 1;  // number of bits
     for (i = 0; i < b; ++i) comp_counts->bits[i][((d >> i) & 1)] += incr;
-    comp_counts->fp[f] += incr;
-    if (usehp) comp_counts->hp[e] += incr;
+#if CONFIG_INTRABC
+    if (precision > MV_SUBPEL_NONE)
+#endif
+      comp_counts->fp[f] += incr;
+    if (precision > MV_SUBPEL_LOW_PRECISION) comp_counts->hp[e] += incr;
   }
 }
 
-void av1_inc_mv(const MV *mv, nmv_context_counts *counts, const int usehp) {
+void av1_inc_mv(const MV *mv, nmv_context_counts *counts,
+                MvSubpelPrecision precision) {
   if (counts != NULL) {
     const MV_JOINT_TYPE j = av1_get_mv_joint(mv);
     ++counts->joints[j];
 
     if (mv_joint_vertical(j))
-      inc_mv_component(mv->row, &counts->comps[0], 1, usehp);
+      inc_mv_component(mv->row, &counts->comps[0], 1, precision);
 
     if (mv_joint_horizontal(j))
-      inc_mv_component(mv->col, &counts->comps[1], 1, usehp);
+      inc_mv_component(mv->col, &counts->comps[1], 1, precision);
   }
 }
 
 void av1_adapt_mv_probs(AV1_COMMON *cm, int allow_hp) {
   int i, j;
   int idx;
   for (idx = 0; idx < NMV_CONTEXTS; ++idx) {
     nmv_context *nmvc = &cm->fc->nmvc[idx];
@@ -281,12 +251,9 @@ void av1_init_mv_probs(AV1_COMMON *cm) {
   int i;
   for (i = 0; i < NMV_CONTEXTS; ++i) {
     // NB: this sets CDFs too
     cm->fc->nmvc[i] = default_nmv_context;
   }
 #if CONFIG_INTRABC
   cm->fc->ndvc = default_nmv_context;
 #endif  // CONFIG_INTRABC
-#if CONFIG_GLOBAL_MOTION
-  av1_copy(cm->fc->global_motion_types_prob, default_global_motion_types_prob);
-#endif  // CONFIG_GLOBAL_MOTION
 }
--- a/third_party/aom/av1/common/entropymv.h
+++ b/third_party/aom/av1/common/entropymv.h
@@ -122,21 +122,26 @@ typedef struct {
   unsigned int hp[2];
 } nmv_component_counts;
 
 typedef struct {
   unsigned int joints[MV_JOINTS];
   nmv_component_counts comps[2];
 } nmv_context_counts;
 
-void av1_inc_mv(const MV *mv, nmv_context_counts *mvctx, const int usehp);
-#if CONFIG_GLOBAL_MOTION
-extern const aom_tree_index
-    av1_global_motion_types_tree[TREE_SIZE(GLOBAL_TRANS_TYPES)];
-#endif  // CONFIG_GLOBAL_MOTION
+typedef enum {
+#if CONFIG_INTRABC
+  MV_SUBPEL_NONE = -1,
+#endif
+  MV_SUBPEL_LOW_PRECISION = 0,
+  MV_SUBPEL_HIGH_PRECISION,
+} MvSubpelPrecision;
+
+void av1_inc_mv(const MV *mv, nmv_context_counts *mvctx,
+                MvSubpelPrecision precision);
 #if !CONFIG_EC_ADAPT
 void av1_set_mv_cdfs(nmv_context *ctx);
 #endif
 
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
--- a/third_party/aom/av1/common/enums.h
+++ b/third_party/aom/av1/common/enums.h
@@ -82,17 +82,17 @@ typedef enum BITSTREAM_PROFILE {
   PROFILE_3,
   MAX_PROFILES
 } BITSTREAM_PROFILE;
 
 // Note: Some enums use the attribute 'packed' to use smallest possible integer
 // type, so that we can save memory when they are used in structs/arrays.
 
 typedef enum ATTRIBUTE_PACKED {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   BLOCK_2X2,
   BLOCK_2X4,
   BLOCK_4X2,
 #endif
   BLOCK_4X4,
   BLOCK_4X8,
   BLOCK_8X4,
   BLOCK_8X8,
@@ -188,16 +188,32 @@ typedef enum ATTRIBUTE_PACKED {
 #define MAX_TX_SQUARE (MAX_TX_SIZE * MAX_TX_SIZE)
 
 // Number of maxium size transform blocks in the maximum size superblock
 #define MAX_TX_BLOCKS_IN_MAX_SB_LOG2 ((MAX_SB_SIZE_LOG2 - MAX_TX_SIZE_LOG2) * 2)
 #define MAX_TX_BLOCKS_IN_MAX_SB (1 << MAX_TX_BLOCKS_IN_MAX_SB_LOG2)
 
 #define MAX_NUM_TXB (1 << (MAX_SB_SIZE_LOG2 - MIN_TX_SIZE_LOG2))
 
+#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
+typedef enum ATTRIBUTE_PACKED {
+  NO_OVERLAP,
+  NCOBMC_MODE_1,
+  NCOBMC_MODE_2,
+  NCOBMC_MODE_3,
+  NCOBMC_MODE_4,
+  NCOBMC_MODE_5,
+  NCOBMC_MODE_6,
+  NCOBMC_MODE_7,
+  NCOBMC_MODE_8,
+  MAX_NCOBMC_MODES
+} NCOBMC_MODE;
+// #define MAX_INTRPL_MODES 9
+#endif
+
 // frame transform mode
 typedef enum {
   ONLY_4X4 = 0,     // only 4x4 transform used
   ALLOW_8X8 = 1,    // allow block transform size up to 8x8
   ALLOW_16X16 = 2,  // allow block transform size up to 16x16
   ALLOW_32X32 = 3,  // allow block transform size up to 32x32
 #if CONFIG_TX64X64
   ALLOW_64X64 = 4,  // allow block transform size up to 64x64
@@ -232,16 +248,22 @@ typedef enum {
   V_ADST = 12,
   H_ADST = 13,
   V_FLIPADST = 14,
   H_FLIPADST = 15,
 #endif  // CONFIG_EXT_TX
   TX_TYPES,
 } TX_TYPE;
 
+#if CONFIG_EXT_TX
+#define IS_2D_TRANSFORM(tx_type) (tx_type < IDTX)
+#else
+#define IS_2D_TRANSFORM(tx_type) 1
+#endif
+
 typedef enum {
   TILE_LEFT_BOUNDARY = 1,
   TILE_RIGHT_BOUNDARY = 2,
   TILE_ABOVE_BOUNDARY = 4,
   TILE_BOTTOM_BOUNDARY = 8,
   FRAME_LEFT_BOUNDARY = 16,
   FRAME_RIGHT_BOUNDARY = 32,
   FRAME_ABOVE_BOUNDARY = 64,
@@ -275,16 +297,28 @@ typedef enum {
   AOM_REFFRAME_ALL = (1 << 6) - 1
 #else
   AOM_GOLD_FLAG = 1 << 1,
   AOM_ALT_FLAG = 1 << 2,
   AOM_REFFRAME_ALL = (1 << 3) - 1
 #endif  // CONFIG_EXT_REFS
 } AOM_REFFRAME;
 
+#if CONFIG_EXT_COMP_REFS
+#define USE_UNI_COMP_REFS 1
+
+typedef enum {
+  UNIDIR_COMP_REFERENCE = 0,
+  BIDIR_COMP_REFERENCE = 1,
+  COMP_REFERENCE_TYPES = 2,
+} COMP_REFERENCE_TYPE;
+#else  // !CONFIG_EXT_COMP_REFS
+#define USE_UNI_COMP_REFS 0
+#endif  // CONFIG_EXT_COMP_REFS
+
 typedef enum { PLANE_TYPE_Y = 0, PLANE_TYPE_UV = 1, PLANE_TYPES } PLANE_TYPE;
 
 #if CONFIG_CFL
 // TODO(ltrudeau) this should change based on QP size
 #define CB_ALPHABET_SIZE 4
 #define CR_ALPHABET_SIZE 4
 #define CFL_ALPHABET_SIZE (CB_ALPHABET_SIZE * CR_ALPHABET_SIZE)
 #define CFL_MAGS_SIZE 7
@@ -313,16 +347,18 @@ typedef enum {
   PALETTE_COLOR_FIVE,
   PALETTE_COLOR_SIX,
   PALETTE_COLOR_SEVEN,
   PALETTE_COLOR_EIGHT,
   PALETTE_COLORS
 } PALETTE_COLOR;
 #endif  // CONFIG_PALETTE
 
+// Note: All directional predictors must be between V_PRED and D63_PRED (both
+// inclusive).
 typedef enum ATTRIBUTE_PACKED {
   DC_PRED,    // Average of above and left pixels
   V_PRED,     // Vertical
   H_PRED,     // Horizontal
   D45_PRED,   // Directional 45  deg = round(arctan(1/1) * 180/pi)
   D135_PRED,  // Directional 135 deg = 180 - 45
   D117_PRED,  // Directional 117 deg = 180 - 63
   D153_PRED,  // Directional 153 deg = 180 - 27
@@ -339,47 +375,61 @@ typedef enum ATTRIBUTE_PACKED {
   NEARESTMV,
   NEARMV,
   ZEROMV,
   NEWMV,
 #if CONFIG_EXT_INTER
 #if CONFIG_COMPOUND_SINGLEREF
   // Single ref compound modes
   SR_NEAREST_NEARMV,
-  SR_NEAREST_NEWMV,
+  // SR_NEAREST_NEWMV,
   SR_NEAR_NEWMV,
   SR_ZERO_NEWMV,
   SR_NEW_NEWMV,
 #endif  // CONFIG_COMPOUND_SINGLEREF
   // Compound ref compound modes
   NEAREST_NEARESTMV,
   NEAR_NEARMV,
   NEAREST_NEWMV,
   NEW_NEARESTMV,
   NEAR_NEWMV,
   NEW_NEARMV,
   ZERO_ZEROMV,
   NEW_NEWMV,
 #endif  // CONFIG_EXT_INTER
   MB_MODE_COUNT,
-  INTRA_MODES = TM_PRED + 1,
+  INTRA_MODES = TM_PRED + 1,     // TM_PRED has to be the last intra mode.
   INTRA_INVALID = MB_MODE_COUNT  // For uv_mode in inter blocks
 } PREDICTION_MODE;
 
 typedef enum {
   SIMPLE_TRANSLATION = 0,
 #if CONFIG_MOTION_VAR
   OBMC_CAUSAL,  // 2-sided OBMC
 #endif          // CONFIG_MOTION_VAR
 #if CONFIG_WARPED_MOTION
   WARPED_CAUSAL,  // 2-sided WARPED
 #endif            // CONFIG_WARPED_MOTION
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+  NCOBMC_ADAPT_WEIGHT,
+#endif
   MOTION_MODES
 } MOTION_MODE;
 
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+typedef enum {
+  ADAPT_OVERLAP_BLOCK_8X8,
+  ADAPT_OVERLAP_BLOCK_16X16,
+  ADAPT_OVERLAP_BLOCK_32X32,
+  ADAPT_OVERLAP_BLOCK_64X64,
+  ADAPT_OVERLAP_BLOCKS,
+  ADAPT_OVERLAP_BLOCK_INVALID = 255
+} ADAPT_OVERLAP_BLOCK;
+#endif
+
 #if CONFIG_EXT_INTER
 #if CONFIG_INTERINTRA
 typedef enum {
   II_DC_PRED = 0,
   II_V_PRED,
   II_H_PRED,
 #if CONFIG_ALT_INTRA
   II_SMOOTH_PRED,
@@ -474,16 +524,22 @@ typedef enum {
 #define REF_CAT_LEVEL 640
 #else
 #define REF_CAT_LEVEL 255
 #endif  // CONFIG_EXT_PARTITION
 
 #define INTRA_INTER_CONTEXTS 4
 #define COMP_INTER_CONTEXTS 5
 #define REF_CONTEXTS 5
+
+#if CONFIG_EXT_COMP_REFS
+#define COMP_REF_TYPE_CONTEXTS 5
+#define UNI_COMP_REF_CONTEXTS 5
+#endif  // CONFIG_EXT_COMP_REFS
+
 #if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 #define COMP_INTER_MODE_CONTEXTS 4
 #endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 
 #if CONFIG_VAR_TX
 #define TXFM_PARTITION_CONTEXTS ((TX_SIZES - TX_8X8) * 6 - 2)
 typedef uint8_t TXFM_CONTEXT;
 #endif
@@ -513,17 +569,27 @@ typedef uint8_t TXFM_CONTEXT;
 #define BWD_REFS (ALTREF_FRAME - BWDREF_FRAME + 1)
 #define BWD_RF_OFFSET(ref) (ref - BWDREF_FRAME)
 #else
 #define BWD_REFS 1
 #define BWD_RF_OFFSET(ref) (ref - ALTREF_FRAME)
 #endif  // CONFIG_EXT_REFS
 
 #define SINGLE_REFS (FWD_REFS + BWD_REFS)
+#if CONFIG_EXT_COMP_REFS
+typedef enum {
+  LAST_LAST2_FRAMES,     // { LAST_FRAME, LAST2_FRAME }
+  LAST_GOLDEN_FRAMES,    // { LAST_FRAME, GOLDEN_FRAME }
+  BWDREF_ALTREF_FRAMES,  // { BWDREF_FRAME, ALTREF_FRAME }
+  UNIDIR_COMP_REFS
+} UNIDIR_COMP_REF;
+#define COMP_REFS (FWD_REFS * BWD_REFS + UNIDIR_COMP_REFS)
+#else  // !CONFIG_EXT_COMP_REFS
 #define COMP_REFS (FWD_REFS * BWD_REFS)
+#endif  // CONFIG_EXT_COMP_REFS
 
 #define MODE_CTX_REF_FRAMES (TOTAL_REFS_PER_FRAME + COMP_REFS)
 
 #if CONFIG_SUPERTX
 #define PARTITION_SUPERTX_CONTEXTS 2
 #define MAX_SUPERTX_BLOCK_SIZE BLOCK_32X32
 #endif  // CONFIG_SUPERTX
 
@@ -534,17 +600,16 @@ typedef enum {
   RESTORE_SGRPROJ = 2,
   RESTORE_SWITCHABLE,
   RESTORE_SWITCHABLE_TYPES = RESTORE_SWITCHABLE,
   RESTORE_TYPES,
 } RestorationType;
 #endif  // CONFIG_LOOP_RESTORATION
 
 #if CONFIG_FRAME_SUPERRES
-#define SUPERRES_SCALE_DENOMINATOR 16
 #define SUPERRES_SCALE_BITS 3
 #define SUPERRES_SCALE_NUMERATOR_MIN 8
 #endif  // CONFIG_FRAME_SUPERRES
 
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
--- a/third_party/aom/av1/common/idct.c
+++ b/third_party/aom/av1/common/idct.c
@@ -108,117 +108,16 @@ static void ihalfright64_c(const tran_lo
   for (i = 0; i < 32; ++i) {
     output[i] = (tran_low_t)dct_const_round_shift(input[32 + i] * 4 * Sqrt2);
   }
   aom_idct32_c(inputhalf, output + 32);
   // Note overall scaling factor is 4 * sqrt(2)  times orthogonal
 }
 #endif  // CONFIG_TX64X64
 
-#if CONFIG_HIGHBITDEPTH
-#if CONFIG_EXT_TX
-// TODO(sarahparker) these functions will be removed once the highbitdepth
-// codepath works properly for rectangular transforms. They have almost
-// identical versions in av1_inv_txfm1d.c, but those are currently only
-// being used for square transforms.
-static void highbd_iidtx4_c(const tran_low_t *input, tran_low_t *output,
-                            int bd) {
-  int i;
-  for (i = 0; i < 4; ++i)
-    output[i] = HIGHBD_WRAPLOW(dct_const_round_shift(input[i] * Sqrt2), bd);
-}
-
-static void highbd_iidtx8_c(const tran_low_t *input, tran_low_t *output,
-                            int bd) {
-  int i;
-  (void)bd;
-  for (i = 0; i < 8; ++i) output[i] = input[i] * 2;
-}
-
-static void highbd_iidtx16_c(const tran_low_t *input, tran_low_t *output,
-                             int bd) {
-  int i;
-  for (i = 0; i < 16; ++i)
-    output[i] = HIGHBD_WRAPLOW(dct_const_round_shift(input[i] * 2 * Sqrt2), bd);
-}
-
-static void highbd_iidtx32_c(const tran_low_t *input, tran_low_t *output,
-                             int bd) {
-  int i;
-  (void)bd;
-  for (i = 0; i < 32; ++i) output[i] = input[i] * 4;
-}
-#endif  // CONFIG_EXT_TX
-
-static void highbd_ihalfright32_c(const tran_low_t *input, tran_low_t *output,
-                                  int bd) {
-  int i;
-  tran_low_t inputhalf[16];
-  // Multiply input by sqrt(2)
-  for (i = 0; i < 16; ++i) {
-    inputhalf[i] = HIGHBD_WRAPLOW(dct_const_round_shift(input[i] * Sqrt2), bd);
-  }
-  for (i = 0; i < 16; ++i) {
-    output[i] = input[16 + i] * 4;
-  }
-  aom_highbd_idct16_c(inputhalf, output + 16, bd);
-  // Note overall scaling factor is 4 times orthogonal
-}
-
-#if CONFIG_EXT_TX
-#if CONFIG_TX64X64
-static void highbd_iidtx64_c(const tran_low_t *input, tran_low_t *output,
-                             int bd) {
-  int i;
-  for (i = 0; i < 64; ++i)
-    output[i] = HIGHBD_WRAPLOW(dct_const_round_shift(input[i] * 4 * Sqrt2), bd);
-}
-#endif  // CONFIG_TX64X64
-#endif  // CONFIG_EXT_TX
-
-#if CONFIG_TX64X64
-// For use in lieu of ADST
-static void highbd_ihalfright64_c(const tran_low_t *input, tran_low_t *output,
-                                  int bd) {
-  int i;
-  tran_low_t inputhalf[32];
-  // Multiply input by sqrt(2)
-  for (i = 0; i < 32; ++i) {
-    inputhalf[i] = HIGHBD_WRAPLOW(dct_const_round_shift(input[i] * Sqrt2), bd);
-  }
-  for (i = 0; i < 32; ++i) {
-    output[i] =
-        HIGHBD_WRAPLOW(dct_const_round_shift(input[32 + i] * 4 * Sqrt2), bd);
-  }
-  aom_highbd_idct32_c(inputhalf, output + 32, bd);
-  // Note overall scaling factor is 4 * sqrt(2)  times orthogonal
-}
-
-static void highbd_idct64_col_c(const tran_low_t *input, tran_low_t *output,
-                                int bd) {
-  int32_t in[64], out[64];
-  int i;
-  (void)bd;
-  for (i = 0; i < 64; ++i) in[i] = (int32_t)input[i];
-  av1_idct64_new(in, out, inv_cos_bit_col_dct_64, inv_stage_range_col_dct_64);
-  for (i = 0; i < 64; ++i) output[i] = (tran_low_t)out[i];
-}
-
-static void highbd_idct64_row_c(const tran_low_t *input, tran_low_t *output,
-                                int bd) {
-  int32_t in[64], out[64];
-  int i;
-  (void)bd;
-  for (i = 0; i < 64; ++i) in[i] = (int32_t)input[i];
-  av1_idct64_new(in, out, inv_cos_bit_row_dct_64, inv_stage_range_row_dct_64);
-  for (i = 0; i < 64; ++i) output[i] = (tran_low_t)out[i];
-}
-#endif  // CONFIG_TX64X64
-#endif  // CONFIG_HIGHBITDEPTH
-
 // Inverse identity transform and add.
 #if CONFIG_EXT_TX
 static void inv_idtx_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                            int bs, int tx_type) {
   int r, c;
   const int shift = bs < 32 ? 3 : (bs < 64 ? 2 : 1);
   if (tx_type == IDTX) {
     for (r = 0; r < bs; ++r) {
@@ -273,75 +172,88 @@ static void maybe_flip_strides(uint8_t *
       FLIPUD_PTR(*src, *sstride, sizex);
       break;
     default: assert(0); break;
   }
 }
 #endif  // CONFIG_EXT_TX
 
 #if CONFIG_HIGHBITDEPTH
-#if CONFIG_EXT_TX
+#if CONFIG_EXT_TX && CONFIG_TX64X64
 static void highbd_inv_idtx_add_c(const tran_low_t *input, uint8_t *dest8,
                                   int stride, int bs, int tx_type, int bd) {
   int r, c;
   const int shift = bs < 32 ? 3 : 2;
   uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
 
   if (tx_type == IDTX) {
     for (r = 0; r < bs; ++r) {
       for (c = 0; c < bs; ++c)
         dest[c] = highbd_clip_pixel_add(dest[c], input[c] >> shift, bd);
       dest += stride;
       input += bs;
     }
   }
 }
-
-static void maybe_flip_strides16(uint16_t **dst, int *dstride, tran_low_t **src,
-                                 int *sstride, int tx_type, int sizey,
-                                 int sizex) {
-  // Note that the transpose of src will be added to dst. In order to LR
-  // flip the addends (in dst coordinates), we UD flip the src. To UD flip
-  // the addends, we UD flip the dst.
-  switch (tx_type) {
-    case DCT_DCT:
-    case ADST_DCT:
-    case DCT_ADST:
-    case ADST_ADST:
-    case IDTX:
-    case V_DCT:
-    case H_DCT:
-    case V_ADST:
-    case H_ADST: break;
-    case FLIPADST_DCT:
-    case FLIPADST_ADST:
-    case V_FLIPADST:
-      // flip UD
-      FLIPUD_PTR(*dst, *dstride, sizey);
-      break;
-    case DCT_FLIPADST:
-    case ADST_FLIPADST:
-    case H_FLIPADST:
-      // flip LR
-      FLIPUD_PTR(*src, *sstride, sizex);
-      break;
-    case FLIPADST_FLIPADST:
-      // flip UD
-      FLIPUD_PTR(*dst, *dstride, sizey);
-      // flip LR
-      FLIPUD_PTR(*src, *sstride, sizex);
-      break;
-    default: assert(0); break;
-  }
-}
-#endif  // CONFIG_EXT_TX
+#endif  // CONFIG_EXT_TX && CONFIG_TX64X64
 #endif  // CONFIG_HIGHBITDEPTH
 
+#if CONFIG_LGT
+void ilgt4(const tran_low_t *input, tran_low_t *output,
+           const tran_high_t *lgtmtx) {
+  if (!(input[0] | input[1] | input[2] | input[3])) {
+    output[0] = output[1] = output[2] = output[3] = 0;
+    return;
+  }
+
+  // evaluate s[j] = sum of all lgtmtx[i][j]*input[i] over i=1,...,4
+  tran_high_t s[4] = { 0 };
+  for (int i = 0; i < 4; ++i)
+    for (int j = 0; j < 4; ++j) s[j] += lgtmtx[i * 4 + j] * input[i];
+
+  for (int i = 0; i < 4; ++i) output[i] = WRAPLOW(dct_const_round_shift(s[i]));
+}
+
+void ilgt8(const tran_low_t *input, tran_low_t *output,
+           const tran_high_t *lgtmtx) {
+  // evaluate s[j] = sum of all lgtmtx[i][j]*input[i] over i=1,...,8
+  tran_high_t s[8] = { 0 };
+  for (int i = 0; i < 8; ++i)
+    for (int j = 0; j < 8; ++j) s[j] += lgtmtx[i * 8 + j] * input[i];
+
+  for (int i = 0; i < 8; ++i) output[i] = WRAPLOW(dct_const_round_shift(s[i]));
+}
+
+// The get_inv_lgt functions return 1 if LGT is chosen to apply, and 0 otherwise
+int get_inv_lgt4(transform_1d tx_orig, const INV_TXFM_PARAM *inv_txfm_param,
+                 const tran_high_t *lgtmtx[], int ntx) {
+  // inter/intra split
+  if (tx_orig == &aom_iadst4_c) {
+    for (int i = 0; i < ntx; ++i)
+      lgtmtx[i] = inv_txfm_param->is_inter ? &lgt4_170[0][0] : &lgt4_140[0][0];
+    return 1;
+  }
+  return 0;
+}
+
+int get_inv_lgt8(transform_1d tx_orig, const INV_TXFM_PARAM *inv_txfm_param,
+                 const tran_high_t *lgtmtx[], int ntx) {
+  // inter/intra split
+  if (tx_orig == &aom_iadst8_c) {
+    for (int i = 0; i < ntx; ++i)
+      lgtmtx[i] = inv_txfm_param->is_inter ? &lgt8_170[0][0] : &lgt8_150[0][0];
+    return 1;
+  }
+  return 0;
+}
+#endif  // CONFIG_LGT
+
 void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                         int tx_type) {
+                         const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_4[] = {
     { aom_idct4_c, aom_idct4_c },    // DCT_DCT  = 0
     { aom_iadst4_c, aom_idct4_c },   // ADST_DCT = 1
     { aom_idct4_c, aom_iadst4_c },   // DCT_ADST = 2
     { aom_iadst4_c, aom_iadst4_c },  // ADST_ADST = 3
 #if CONFIG_EXT_TX
     { aom_iadst4_c, aom_idct4_c },   // FLIPADST_DCT
     { aom_idct4_c, aom_iadst4_c },   // DCT_FLIPADST
@@ -350,41 +262,58 @@ void av1_iht4x4_16_add_c(const tran_low_
     { aom_iadst4_c, aom_iadst4_c },  // FLIPADST_ADST
     { iidtx4_c, iidtx4_c },          // IDTX
     { aom_idct4_c, iidtx4_c },       // V_DCT
     { iidtx4_c, aom_idct4_c },       // H_DCT
     { aom_iadst4_c, iidtx4_c },      // V_ADST
     { iidtx4_c, aom_iadst4_c },      // H_ADST
     { aom_iadst4_c, iidtx4_c },      // V_FLIPADST
     { iidtx4_c, aom_iadst4_c },      // H_FLIPADST
-#endif                               // CONFIG_EXT_TX
+#endif
   };
 
   int i, j;
   tran_low_t tmp[4][4];
   tran_low_t out[4][4];
   tran_low_t *outp = &out[0][0];
   int outstride = 4;
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_col[4];
+  const tran_high_t *lgtmtx_row[4];
+  int use_lgt_col = get_inv_lgt4(IHT_4[tx_type].cols, param, lgtmtx_col, 4);
+  int use_lgt_row = get_inv_lgt4(IHT_4[tx_type].rows, param, lgtmtx_row, 4);
+#endif
+
   // inverse transform row vectors
   for (i = 0; i < 4; ++i) {
-    IHT_4[tx_type].rows(input, out[i]);
+#if CONFIG_LGT
+    if (use_lgt_row)
+      ilgt4(input, out[i], lgtmtx_row[i]);
+    else
+#endif
+      IHT_4[tx_type].rows(input, out[i]);
     input += 4;
   }
 
   // transpose
   for (i = 0; i < 4; i++) {
     for (j = 0; j < 4; j++) {
       tmp[j][i] = out[i][j];
     }
   }
 
   // inverse transform column vectors
   for (i = 0; i < 4; ++i) {
-    IHT_4[tx_type].cols(tmp[i], out[i]);
+#if CONFIG_LGT
+    if (use_lgt_col)
+      ilgt4(tmp[i], out[i], lgtmtx_col[i]);
+    else
+#endif
+      IHT_4[tx_type].cols(tmp[i], out[i]);
   }
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 4, 4);
 #endif
 
   // Sum with the destination
   for (i = 0; i < 4; ++i) {
@@ -392,17 +321,18 @@ void av1_iht4x4_16_add_c(const tran_low_
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4));
     }
   }
 }
 
 void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                         int tx_type) {
+                         const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_4x8[] = {
     { aom_idct8_c, aom_idct4_c },    // DCT_DCT
     { aom_iadst8_c, aom_idct4_c },   // ADST_DCT
     { aom_idct8_c, aom_iadst4_c },   // DCT_ADST
     { aom_iadst8_c, aom_iadst4_c },  // ADST_ADST
 #if CONFIG_EXT_TX
     { aom_iadst8_c, aom_idct4_c },   // FLIPADST_DCT
     { aom_idct8_c, aom_iadst4_c },   // DCT_FLIPADST
@@ -421,27 +351,44 @@ void av1_iht4x8_32_add_c(const tran_low_
 
   const int n = 4;
   const int n2 = 8;
   int i, j;
   tran_low_t out[4][8], tmp[4][8], outtmp[4];
   tran_low_t *outp = &out[0][0];
   int outstride = n2;
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_col[4];
+  const tran_high_t *lgtmtx_row[8];
+  int use_lgt_col = get_inv_lgt8(IHT_4x8[tx_type].cols, param, lgtmtx_col, 4);
+  int use_lgt_row = get_inv_lgt4(IHT_4x8[tx_type].rows, param, lgtmtx_row, 8);
+#endif
+
   // inverse transform row vectors and transpose
   for (i = 0; i < n2; ++i) {
-    IHT_4x8[tx_type].rows(input, outtmp);
+#if CONFIG_LGT
+    if (use_lgt_row)
+      ilgt4(input, outtmp, lgtmtx_row[i]);
+    else
+#endif
+      IHT_4x8[tx_type].rows(input, outtmp);
     for (j = 0; j < n; ++j)
       tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
     input += n;
   }
 
   // inverse transform column vectors
   for (i = 0; i < n; ++i) {
-    IHT_4x8[tx_type].cols(tmp[i], out[i]);
+#if CONFIG_LGT
+    if (use_lgt_col)
+      ilgt8(tmp[i], out[i], lgtmtx_col[i]);
+    else
+#endif
+      IHT_4x8[tx_type].cols(tmp[i], out[i]);
   }
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n);
 #endif
 
   // Sum with the destination
   for (i = 0; i < n2; ++i) {
@@ -449,17 +396,18 @@ void av1_iht4x8_32_add_c(const tran_low_
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
     }
   }
 }
 
 void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                         int tx_type) {
+                         const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_8x4[] = {
     { aom_idct4_c, aom_idct8_c },    // DCT_DCT
     { aom_iadst4_c, aom_idct8_c },   // ADST_DCT
     { aom_idct4_c, aom_iadst8_c },   // DCT_ADST
     { aom_iadst4_c, aom_iadst8_c },  // ADST_ADST
 #if CONFIG_EXT_TX
     { aom_iadst4_c, aom_idct8_c },   // FLIPADST_DCT
     { aom_idct4_c, aom_iadst8_c },   // DCT_FLIPADST
@@ -470,35 +418,53 @@ void av1_iht8x4_32_add_c(const tran_low_
     { aom_idct4_c, iidtx8_c },       // V_DCT
     { iidtx4_c, aom_idct8_c },       // H_DCT
     { aom_iadst4_c, iidtx8_c },      // V_ADST
     { iidtx4_c, aom_iadst8_c },      // H_ADST
     { aom_iadst4_c, iidtx8_c },      // V_FLIPADST
     { iidtx4_c, aom_iadst8_c },      // H_FLIPADST
 #endif
   };
+
   const int n = 4;
   const int n2 = 8;
 
   int i, j;
   tran_low_t out[8][4], tmp[8][4], outtmp[8];
   tran_low_t *outp = &out[0][0];
   int outstride = n;
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_col[8];
+  const tran_high_t *lgtmtx_row[4];
+  int use_lgt_col = get_inv_lgt4(IHT_8x4[tx_type].cols, param, lgtmtx_col, 8);
+  int use_lgt_row = get_inv_lgt8(IHT_8x4[tx_type].rows, param, lgtmtx_row, 4);
+#endif
+
   // inverse transform row vectors and transpose
   for (i = 0; i < n; ++i) {
-    IHT_8x4[tx_type].rows(input, outtmp);
+#if CONFIG_LGT
+    if (use_lgt_row)
+      ilgt8(input, outtmp, lgtmtx_row[i]);
+    else
+#endif
+      IHT_8x4[tx_type].rows(input, outtmp);
     for (j = 0; j < n2; ++j)
       tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
     input += n2;
   }
 
   // inverse transform column vectors
   for (i = 0; i < n2; ++i) {
-    IHT_8x4[tx_type].cols(tmp[i], out[i]);
+#if CONFIG_LGT
+    if (use_lgt_col)
+      ilgt4(tmp[i], out[i], lgtmtx_col[i]);
+    else
+#endif
+      IHT_8x4[tx_type].cols(tmp[i], out[i]);
   }
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2);
 #endif
 
   // Sum with the destination
   for (i = 0; i < n; ++i) {
@@ -506,17 +472,18 @@ void av1_iht8x4_32_add_c(const tran_low_
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
     }
   }
 }
 
 void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                          int tx_type) {
+                          const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_4x16[] = {
     { aom_idct16_c, aom_idct4_c },    // DCT_DCT
     { aom_iadst16_c, aom_idct4_c },   // ADST_DCT
     { aom_idct16_c, aom_iadst4_c },   // DCT_ADST
     { aom_iadst16_c, aom_iadst4_c },  // ADST_ADST
 #if CONFIG_EXT_TX
     { aom_iadst16_c, aom_idct4_c },   // FLIPADST_DCT
     { aom_idct16_c, aom_iadst4_c },   // DCT_FLIPADST
@@ -535,42 +502,55 @@ void av1_iht4x16_64_add_c(const tran_low
 
   const int n = 4;
   const int n4 = 16;
   int i, j;
   tran_low_t out[4][16], tmp[4][16], outtmp[4];
   tran_low_t *outp = &out[0][0];
   int outstride = n4;
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_row[16];
+  int use_lgt_row = get_inv_lgt4(IHT_4x16[tx_type].rows, param, lgtmtx_row, 16);
+#endif
+
   // inverse transform row vectors and transpose
   for (i = 0; i < n4; ++i) {
-    IHT_4x16[tx_type].rows(input, outtmp);
+#if CONFIG_LGT
+    if (use_lgt_row)
+      ilgt4(input, outtmp, lgtmtx_row[i]);
+    else
+#endif
+      IHT_4x16[tx_type].rows(input, outtmp);
     for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j];
     input += n;
   }
 
   // inverse transform column vectors
-  for (i = 0; i < n; ++i) IHT_4x16[tx_type].cols(tmp[i], out[i]);
+  for (i = 0; i < n; ++i) {
+    IHT_4x16[tx_type].cols(tmp[i], out[i]);
+  }
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n4, n);
 #endif
 
   // Sum with the destination
   for (i = 0; i < n4; ++i) {
     for (j = 0; j < n; ++j) {
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
     }
   }
 }
 
 void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                          int tx_type) {
+                          const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_16x4[] = {
     { aom_idct4_c, aom_idct16_c },    // DCT_DCT
     { aom_iadst4_c, aom_idct16_c },   // ADST_DCT
     { aom_idct4_c, aom_iadst16_c },   // DCT_ADST
     { aom_iadst4_c, aom_iadst16_c },  // ADST_ADST
 #if CONFIG_EXT_TX
     { aom_iadst4_c, aom_idct16_c },   // FLIPADST_DCT
     { aom_idct4_c, aom_iadst16_c },   // DCT_FLIPADST
@@ -581,50 +561,64 @@ void av1_iht16x4_64_add_c(const tran_low
     { aom_idct4_c, iidtx16_c },       // V_DCT
     { iidtx4_c, aom_idct16_c },       // H_DCT
     { aom_iadst4_c, iidtx16_c },      // V_ADST
     { iidtx4_c, aom_iadst16_c },      // H_ADST
     { aom_iadst4_c, iidtx16_c },      // V_FLIPADST
     { iidtx4_c, aom_iadst16_c },      // H_FLIPADST
 #endif
   };
+
   const int n = 4;
   const int n4 = 16;
 
   int i, j;
   tran_low_t out[16][4], tmp[16][4], outtmp[16];
   tran_low_t *outp = &out[0][0];
   int outstride = n;
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_col[16];
+  int use_lgt_col = get_inv_lgt4(IHT_16x4[tx_type].cols, param, lgtmtx_col, 16);
+#endif
+
   // inverse transform row vectors and transpose
   for (i = 0; i < n; ++i) {
     IHT_16x4[tx_type].rows(input, outtmp);
     for (j = 0; j < n4; ++j) tmp[j][i] = outtmp[j];
     input += n4;
   }
 
   // inverse transform column vectors
-  for (i = 0; i < n4; ++i) IHT_16x4[tx_type].cols(tmp[i], out[i]);
+  for (i = 0; i < n4; ++i) {
+#if CONFIG_LGT
+    if (use_lgt_col)
+      ilgt4(tmp[i], out[i], lgtmtx_col[i]);
+    else
+#endif
+      IHT_16x4[tx_type].cols(tmp[i], out[i]);
+  }
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n4);
 #endif
 
   // Sum with the destination
   for (i = 0; i < n; ++i) {
     for (j = 0; j < n4; ++j) {
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
     }
   }
 }
 
 void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                           int tx_type) {
+                           const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_8x16[] = {
     { aom_idct16_c, aom_idct8_c },    // DCT_DCT
     { aom_iadst16_c, aom_idct8_c },   // ADST_DCT
     { aom_idct16_c, aom_iadst8_c },   // DCT_ADST
     { aom_iadst16_c, aom_iadst8_c },  // ADST_ADST
 #if CONFIG_EXT_TX
     { aom_iadst16_c, aom_idct8_c },   // FLIPADST_DCT
     { aom_idct16_c, aom_iadst8_c },   // DCT_FLIPADST
@@ -643,19 +637,29 @@ void av1_iht8x16_128_add_c(const tran_lo
 
   const int n = 8;
   const int n2 = 16;
   int i, j;
   tran_low_t out[8][16], tmp[8][16], outtmp[8];
   tran_low_t *outp = &out[0][0];
   int outstride = n2;
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_row[16];
+  int use_lgt_row = get_inv_lgt8(IHT_8x16[tx_type].rows, param, lgtmtx_row, 16);
+#endif
+
   // inverse transform row vectors and transpose
   for (i = 0; i < n2; ++i) {
-    IHT_8x16[tx_type].rows(input, outtmp);
+#if CONFIG_LGT
+    if (use_lgt_row)
+      ilgt8(input, outtmp, lgtmtx_row[i]);
+    else
+#endif
+      IHT_8x16[tx_type].rows(input, outtmp);
     for (j = 0; j < n; ++j)
       tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
     input += n;
   }
 
   // inverse transform column vectors
   for (i = 0; i < n; ++i) {
     IHT_8x16[tx_type].cols(tmp[i], out[i]);
@@ -671,17 +675,18 @@ void av1_iht8x16_128_add_c(const tran_lo
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
     }
   }
 }
 
 void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                           int tx_type) {
+                           const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_16x8[] = {
     { aom_idct8_c, aom_idct16_c },    // DCT_DCT
     { aom_iadst8_c, aom_idct16_c },   // ADST_DCT
     { aom_idct8_c, aom_iadst16_c },   // DCT_ADST
     { aom_iadst8_c, aom_iadst16_c },  // ADST_ADST
 #if CONFIG_EXT_TX
     { aom_iadst8_c, aom_idct16_c },   // FLIPADST_DCT
     { aom_idct8_c, aom_iadst16_c },   // DCT_FLIPADST
@@ -692,35 +697,46 @@ void av1_iht16x8_128_add_c(const tran_lo
     { aom_idct8_c, iidtx16_c },       // V_DCT
     { iidtx8_c, aom_idct16_c },       // H_DCT
     { aom_iadst8_c, iidtx16_c },      // V_ADST
     { iidtx8_c, aom_iadst16_c },      // H_ADST
     { aom_iadst8_c, iidtx16_c },      // V_FLIPADST
     { iidtx8_c, aom_iadst16_c },      // H_FLIPADST
 #endif
   };
+
   const int n = 8;
   const int n2 = 16;
 
   int i, j;
   tran_low_t out[16][8], tmp[16][8], outtmp[16];
   tran_low_t *outp = &out[0][0];
   int outstride = n;
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_col[16];
+  int use_lgt_col = get_inv_lgt8(IHT_16x8[tx_type].cols, param, lgtmtx_col, 16);
+#endif
+
   // inverse transform row vectors and transpose
   for (i = 0; i < n; ++i) {
     IHT_16x8[tx_type].rows(input, outtmp);
     for (j = 0; j < n2; ++j)
       tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
     input += n2;
   }
 
   // inverse transform column vectors
   for (i = 0; i < n2; ++i) {
-    IHT_16x8[tx_type].cols(tmp[i], out[i]);
+#if CONFIG_LGT
+    if (use_lgt_col)
+      ilgt8(tmp[i], out[i], lgtmtx_col[i]);
+    else
+#endif
+      IHT_16x8[tx_type].cols(tmp[i], out[i]);
   }
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2);
 #endif
 
   // Sum with the destination
   for (i = 0; i < n; ++i) {
@@ -728,17 +744,18 @@ void av1_iht16x8_128_add_c(const tran_lo
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
     }
   }
 }
 
 void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                           int tx_type) {
+                           const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_8x32[] = {
     { aom_idct32_c, aom_idct8_c },     // DCT_DCT
     { ihalfright32_c, aom_idct8_c },   // ADST_DCT
     { aom_idct32_c, aom_iadst8_c },    // DCT_ADST
     { ihalfright32_c, aom_iadst8_c },  // ADST_ADST
 #if CONFIG_EXT_TX
     { ihalfright32_c, aom_idct8_c },   // FLIPADST_DCT
     { aom_idct32_c, aom_iadst8_c },    // DCT_FLIPADST
@@ -757,42 +774,55 @@ void av1_iht8x32_256_add_c(const tran_lo
 
   const int n = 8;
   const int n4 = 32;
   int i, j;
   tran_low_t out[8][32], tmp[8][32], outtmp[8];
   tran_low_t *outp = &out[0][0];
   int outstride = n4;
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_row[32];
+  int use_lgt_row = get_inv_lgt8(IHT_8x32[tx_type].rows, param, lgtmtx_row, 32);
+#endif
+
   // inverse transform row vectors and transpose
   for (i = 0; i < n4; ++i) {
-    IHT_8x32[tx_type].rows(input, outtmp);
+#if CONFIG_LGT
+    if (use_lgt_row)
+      ilgt8(input, outtmp, lgtmtx_row[i]);
+    else
+#endif
+      IHT_8x32[tx_type].rows(input, outtmp);
     for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j];
     input += n;
   }
 
   // inverse transform column vectors
-  for (i = 0; i < n; ++i) IHT_8x32[tx_type].cols(tmp[i], out[i]);
+  for (i = 0; i < n; ++i) {
+    IHT_8x32[tx_type].cols(tmp[i], out[i]);
+  }
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n4, n);
 #endif
 
   // Sum with the destination
   for (i = 0; i < n4; ++i) {
     for (j = 0; j < n; ++j) {
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
     }
   }
 }
 
 void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                           int tx_type) {
+                           const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_32x8[] = {
     { aom_idct8_c, aom_idct32_c },     // DCT_DCT
     { aom_iadst8_c, aom_idct32_c },    // ADST_DCT
     { aom_idct8_c, ihalfright32_c },   // DCT_ADST
     { aom_iadst8_c, ihalfright32_c },  // ADST_ADST
 #if CONFIG_EXT_TX
     { aom_iadst8_c, aom_idct32_c },    // FLIPADST_DCT
     { aom_idct8_c, ihalfright32_c },   // DCT_FLIPADST
@@ -803,50 +833,64 @@ void av1_iht32x8_256_add_c(const tran_lo
     { aom_idct8_c, iidtx32_c },        // V_DCT
     { iidtx8_c, aom_idct32_c },        // H_DCT
     { aom_iadst8_c, iidtx32_c },       // V_ADST
     { iidtx8_c, ihalfright32_c },      // H_ADST
     { aom_iadst8_c, iidtx32_c },       // V_FLIPADST
     { iidtx8_c, ihalfright32_c },      // H_FLIPADST
 #endif
   };
+
   const int n = 8;
   const int n4 = 32;
 
   int i, j;
   tran_low_t out[32][8], tmp[32][8], outtmp[32];
   tran_low_t *outp = &out[0][0];
   int outstride = n;
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_col[32];
+  int use_lgt_col = get_inv_lgt4(IHT_32x8[tx_type].cols, param, lgtmtx_col, 32);
+#endif
+
   // inverse transform row vectors and transpose
   for (i = 0; i < n; ++i) {
     IHT_32x8[tx_type].rows(input, outtmp);
     for (j = 0; j < n4; ++j) tmp[j][i] = outtmp[j];
     input += n4;
   }
 
   // inverse transform column vectors
-  for (i = 0; i < n4; ++i) IHT_32x8[tx_type].cols(tmp[i], out[i]);
+  for (i = 0; i < n4; ++i) {
+#if CONFIG_LGT
+    if (use_lgt_col)
+      ilgt8(tmp[i], out[i], lgtmtx_col[i]);
+    else
+#endif
+      IHT_32x8[tx_type].cols(tmp[i], out[i]);
+  }
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n4);
 #endif
 
   // Sum with the destination
   for (i = 0; i < n; ++i) {
     for (j = 0; j < n4; ++j) {
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
     }
   }
 }
 
 void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                            int tx_type) {
+                            const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_16x32[] = {
     { aom_idct32_c, aom_idct16_c },     // DCT_DCT
     { ihalfright32_c, aom_idct16_c },   // ADST_DCT
     { aom_idct32_c, aom_iadst16_c },    // DCT_ADST
     { ihalfright32_c, aom_iadst16_c },  // ADST_ADST
 #if CONFIG_EXT_TX
     { ihalfright32_c, aom_idct16_c },   // FLIPADST_DCT
     { aom_idct32_c, aom_iadst16_c },    // DCT_FLIPADST
@@ -874,36 +918,35 @@ void av1_iht16x32_512_add_c(const tran_l
   for (i = 0; i < n2; ++i) {
     IHT_16x32[tx_type].rows(input, outtmp);
     for (j = 0; j < n; ++j)
       tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
     input += n;
   }
 
   // inverse transform column vectors
-  for (i = 0; i < n; ++i) {
-    IHT_16x32[tx_type].cols(tmp[i], out[i]);
-  }
+  for (i = 0; i < n; ++i) IHT_16x32[tx_type].cols(tmp[i], out[i]);
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n);
 #endif
 
   // Sum with the destination
   for (i = 0; i < n2; ++i) {
     for (j = 0; j < n; ++j) {
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
     }
   }
 }
 
 void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                            int tx_type) {
+                            const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_32x16[] = {
     { aom_idct16_c, aom_idct32_c },     // DCT_DCT
     { aom_iadst16_c, aom_idct32_c },    // ADST_DCT
     { aom_idct16_c, ihalfright32_c },   // DCT_ADST
     { aom_iadst16_c, ihalfright32_c },  // ADST_ADST
 #if CONFIG_EXT_TX
     { aom_iadst16_c, aom_idct32_c },    // FLIPADST_DCT
     { aom_idct16_c, ihalfright32_c },   // DCT_FLIPADST
@@ -931,36 +974,35 @@ void av1_iht32x16_512_add_c(const tran_l
   for (i = 0; i < n; ++i) {
     IHT_32x16[tx_type].rows(input, outtmp);
     for (j = 0; j < n2; ++j)
       tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
     input += n2;
   }
 
   // inverse transform column vectors
-  for (i = 0; i < n2; ++i) {
-    IHT_32x16[tx_type].cols(tmp[i], out[i]);
-  }
+  for (i = 0; i < n2; ++i) IHT_32x16[tx_type].cols(tmp[i], out[i]);
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2);
 #endif
 
   // Sum with the destination
   for (i = 0; i < n; ++i) {
     for (j = 0; j < n2; ++j) {
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
     }
   }
 }
 
 void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                         int tx_type) {
+                         const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_8[] = {
     { aom_idct8_c, aom_idct8_c },    // DCT_DCT  = 0
     { aom_iadst8_c, aom_idct8_c },   // ADST_DCT = 1
     { aom_idct8_c, aom_iadst8_c },   // DCT_ADST = 2
     { aom_iadst8_c, aom_iadst8_c },  // ADST_ADST = 3
 #if CONFIG_EXT_TX
     { aom_iadst8_c, aom_idct8_c },   // FLIPADST_DCT
     { aom_idct8_c, aom_iadst8_c },   // DCT_FLIPADST
@@ -969,41 +1011,58 @@ void av1_iht8x8_64_add_c(const tran_low_
     { aom_iadst8_c, aom_iadst8_c },  // FLIPADST_ADST
     { iidtx8_c, iidtx8_c },          // IDTX
     { aom_idct8_c, iidtx8_c },       // V_DCT
     { iidtx8_c, aom_idct8_c },       // H_DCT
     { aom_iadst8_c, iidtx8_c },      // V_ADST
     { iidtx8_c, aom_iadst8_c },      // H_ADST
     { aom_iadst8_c, iidtx8_c },      // V_FLIPADST
     { iidtx8_c, aom_iadst8_c },      // H_FLIPADST
-#endif                               // CONFIG_EXT_TX
+#endif
   };
 
   int i, j;
   tran_low_t tmp[8][8];
   tran_low_t out[8][8];
   tran_low_t *outp = &out[0][0];
   int outstride = 8;
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_col[8];
+  const tran_high_t *lgtmtx_row[8];
+  int use_lgt_col = get_inv_lgt8(IHT_8[tx_type].cols, param, lgtmtx_col, 8);
+  int use_lgt_row = get_inv_lgt8(IHT_8[tx_type].rows, param, lgtmtx_row, 8);
+#endif
+
   // inverse transform row vectors
   for (i = 0; i < 8; ++i) {
-    IHT_8[tx_type].rows(input, out[i]);
+#if CONFIG_LGT
+    if (use_lgt_row)
+      ilgt8(input, out[i], lgtmtx_row[i]);
+    else
+#endif
+      IHT_8[tx_type].rows(input, out[i]);
     input += 8;
   }
 
   // transpose
   for (i = 0; i < 8; i++) {
     for (j = 0; j < 8; j++) {
       tmp[j][i] = out[i][j];
     }
   }
 
   // inverse transform column vectors
   for (i = 0; i < 8; ++i) {
-    IHT_8[tx_type].cols(tmp[i], out[i]);
+#if CONFIG_LGT
+    if (use_lgt_col)
+      ilgt8(tmp[i], out[i], lgtmtx_col[i]);
+    else
+#endif
+      IHT_8[tx_type].cols(tmp[i], out[i]);
   }
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 8, 8);
 #endif
 
   // Sum with the destination
   for (i = 0; i < 8; ++i) {
@@ -1011,17 +1070,18 @@ void av1_iht8x8_64_add_c(const tran_low_
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
     }
   }
 }
 
 void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                            int tx_type) {
+                            const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_16[] = {
     { aom_idct16_c, aom_idct16_c },    // DCT_DCT  = 0
     { aom_iadst16_c, aom_idct16_c },   // ADST_DCT = 1
     { aom_idct16_c, aom_iadst16_c },   // DCT_ADST = 2
     { aom_iadst16_c, aom_iadst16_c },  // ADST_ADST = 3
 #if CONFIG_EXT_TX
     { aom_iadst16_c, aom_idct16_c },   // FLIPADST_DCT
     { aom_idct16_c, aom_iadst16_c },   // DCT_FLIPADST
@@ -1030,17 +1090,17 @@ void av1_iht16x16_256_add_c(const tran_l
     { aom_iadst16_c, aom_iadst16_c },  // FLIPADST_ADST
     { iidtx16_c, iidtx16_c },          // IDTX
     { aom_idct16_c, iidtx16_c },       // V_DCT
     { iidtx16_c, aom_idct16_c },       // H_DCT
     { aom_iadst16_c, iidtx16_c },      // V_ADST
     { iidtx16_c, aom_iadst16_c },      // H_ADST
     { aom_iadst16_c, iidtx16_c },      // V_FLIPADST
     { iidtx16_c, aom_iadst16_c },      // H_FLIPADST
-#endif                                 // CONFIG_EXT_TX
+#endif
   };
 
   int i, j;
   tran_low_t tmp[16][16];
   tran_low_t out[16][16];
   tran_low_t *outp = &out[0][0];
   int outstride = 16;
 
@@ -1053,19 +1113,17 @@ void av1_iht16x16_256_add_c(const tran_l
   // transpose
   for (i = 0; i < 16; i++) {
     for (j = 0; j < 16; j++) {
       tmp[j][i] = out[i][j];
     }
   }
 
   // inverse transform column vectors
-  for (i = 0; i < 16; ++i) {
-    IHT_16[tx_type].cols(tmp[i], out[i]);
-  }
+  for (i = 0; i < 16; ++i) IHT_16[tx_type].cols(tmp[i], out[i]);
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 16, 16);
 #endif
 
   // Sum with the destination
   for (i = 0; i < 16; ++i) {
     for (j = 0; j < 16; ++j) {
@@ -1073,17 +1131,18 @@ void av1_iht16x16_256_add_c(const tran_l
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
     }
   }
 }
 
 #if CONFIG_EXT_TX
 void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                             int tx_type) {
+                             const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_32[] = {
     { aom_idct32_c, aom_idct32_c },      // DCT_DCT
     { ihalfright32_c, aom_idct32_c },    // ADST_DCT
     { aom_idct32_c, ihalfright32_c },    // DCT_ADST
     { ihalfright32_c, ihalfright32_c },  // ADST_ADST
     { ihalfright32_c, aom_idct32_c },    // FLIPADST_DCT
     { aom_idct32_c, ihalfright32_c },    // DCT_FLIPADST
     { ihalfright32_c, ihalfright32_c },  // FLIPADST_FLIPADST
@@ -1113,36 +1172,35 @@ void av1_iht32x32_1024_add_c(const tran_
   // transpose
   for (i = 0; i < 32; i++) {
     for (j = 0; j < 32; j++) {
       tmp[j][i] = out[i][j];
     }
   }
 
   // inverse transform column vectors
-  for (i = 0; i < 32; ++i) {
-    IHT_32[tx_type].cols(tmp[i], out[i]);
-  }
+  for (i = 0; i < 32; ++i) IHT_32[tx_type].cols(tmp[i], out[i]);
 
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 32, 32);
 
   // Sum with the destination
   for (i = 0; i < 32; ++i) {
     for (j = 0; j < 32; ++j) {
       int d = i * stride + j;
       int s = j * outstride + i;
       dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
     }
   }
 }
 #endif  // CONFIG_EXT_TX
 
 #if CONFIG_TX64X64
 void av1_iht64x64_4096_add_c(const tran_low_t *input, uint8_t *dest, int stride,
-                             int tx_type) {
+                             const INV_TXFM_PARAM *param) {
+  int tx_type = param->tx_type;
   static const transform_2d IHT_64[] = {
     { idct64_col_c, idct64_row_c },      // DCT_DCT
     { ihalfright64_c, idct64_row_c },    // ADST_DCT
     { idct64_col_c, ihalfright64_c },    // DCT_ADST
     { ihalfright64_c, ihalfright64_c },  // ADST_ADST
 #if CONFIG_EXT_TX
     { ihalfright64_c, idct64_row_c },    // FLIPADST_DCT
     { idct64_col_c, ihalfright64_c },    // DCT_FLIPADST
@@ -1151,17 +1209,17 @@ void av1_iht64x64_4096_add_c(const tran_
     { ihalfright64_c, ihalfright64_c },  // FLIPADST_ADST
     { iidtx64_c, iidtx64_c },            // IDTX
     { idct64_col_c, iidtx64_c },         // V_DCT
     { iidtx64_c, idct64_row_c },         // H_DCT
     { ihalfright64_c, iidtx64_c },       // V_ADST
     { iidtx64_c, ihalfright64_c },       // H_ADST
     { ihalfright64_c, iidtx64_c },       // V_FLIPADST
     { iidtx64_c, ihalfright64_c },       // H_FLIPADST
-#endif                                   // CONFIG_EXT_TX
+#endif
   };
 
   int i, j;
   tran_low_t tmp[64][64];
   tran_low_t out[64][64];
   tran_low_t *outp = &out[0][0];
   int outstride = 64;
 
@@ -1175,19 +1233,17 @@ void av1_iht64x64_4096_add_c(const tran_
   // transpose
   for (i = 0; i < 64; i++) {
     for (j = 0; j < 64; j++) {
       tmp[j][i] = out[i][j];
     }
   }
 
   // inverse transform column vectors
-  for (i = 0; i < 64; ++i) {
-    IHT_64[tx_type].cols(tmp[i], out[i]);
-  }
+  for (i = 0; i < 64; ++i) IHT_64[tx_type].cols(tmp[i], out[i]);
 
 #if CONFIG_EXT_TX
   maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 64, 64);
 #endif  // CONFIG_EXT_TX
 
   // Sum with the destination
   for (i = 0; i < 64; ++i) {
     for (j = 0; j < 64; ++j) {
@@ -1292,189 +1348,240 @@ static void idct64x64_add(const tran_low
                           const INV_TXFM_PARAM *param) {
   (void)param;
   av1_iht64x64_4096_add(input, dest, stride, DCT_DCT);
 }
 #endif  // CONFIG_TX64X64
 
 #if CONFIG_CHROMA_2X2
 static void inv_txfm_add_2x2(const tran_low_t *input, uint8_t *dest, int stride,
-                             int eob, TX_TYPE tx_type, int lossless) {
+                             const INV_TXFM_PARAM *param) {
   tran_high_t a1 = input[0] >> UNIT_QUANT_SHIFT;
   tran_high_t b1 = input[1] >> UNIT_QUANT_SHIFT;
   tran_high_t c1 = input[2] >> UNIT_QUANT_SHIFT;
   tran_high_t d1 = input[3] >> UNIT_QUANT_SHIFT;
 
   tran_high_t a2 = a1 + c1;
   tran_high_t b2 = b1 + d1;
   tran_high_t c2 = a1 - c1;
   tran_high_t d2 = b1 - d1;
 
-  (void)tx_type;
-  (void)lossless;
-  (void)eob;
+  (void)param;
 
   a1 = (a2 + b2) >> 2;
   b1 = (a2 - b2) >> 2;
   c1 = (c2 + d2) >> 2;
   d1 = (c2 - d2) >> 2;
 
   dest[0] = clip_pixel_add(dest[0], WRAPLOW(a1));
   dest[1] = clip_pixel_add(dest[1], WRAPLOW(b1));
   dest[stride] = clip_pixel_add(dest[stride], WRAPLOW(c1));
   dest[stride + 1] = clip_pixel_add(dest[stride + 1], WRAPLOW(d1));
 }
 #endif
 
 static void inv_txfm_add_4x4(const tran_low_t *input, uint8_t *dest, int stride,
-                             int eob, TX_TYPE tx_type, int lossless) {
-  if (lossless) {
+                             const INV_TXFM_PARAM *param) {
+  const TX_TYPE tx_type = param->tx_type;
+  const int eob = param->eob;
+  if (param->lossless) {
     assert(tx_type == DCT_DCT);
     av1_iwht4x4_add(input, dest, stride, eob);
     return;
   }
 
   switch (tx_type) {
     case DCT_DCT: av1_idct4x4_add(input, dest, stride, eob); break;
     case ADST_DCT:
     case DCT_ADST:
-    case ADST_ADST: av1_iht4x4_16_add(input, dest, stride, tx_type); break;
+    case ADST_ADST:
+#if CONFIG_LGT
+      // LGT only exists in C verson
+      av1_iht4x4_16_add_c(input, dest, stride, param);
+      break;
+#else
+      av1_iht4x4_16_add(input, dest, stride, param);
+      break;
+#endif
 #if CONFIG_EXT_TX
     case FLIPADST_DCT:
     case DCT_FLIPADST:
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
-    case FLIPADST_ADST: av1_iht4x4_16_add(input, dest, stride, tx_type); break;
+    case FLIPADST_ADST:
+#if CONFIG_LGT
+      av1_iht4x4_16_add_c(input, dest, stride, param);
+      break;
+#else
+      av1_iht4x4_16_add(input, dest, stride, param);
+      break;
+#endif
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
     case H_FLIPADST:
       // Use C version since DST only exists in C code
-      av1_iht4x4_16_add_c(input, dest, stride, tx_type);
+      av1_iht4x4_16_add_c(input, dest, stride, param);
       break;
     case IDTX: inv_idtx_add_c(input, dest, stride, 4, tx_type); break;
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
   }
 }
 
 static void inv_txfm_add_4x8(const tran_low_t *input, uint8_t *dest, int stride,
-                             int eob, TX_TYPE tx_type) {
-  (void)eob;
-  av1_iht4x8_32_add(input, dest, stride, tx_type);
+                             const INV_TXFM_PARAM *param) {
+#if CONFIG_LGT
+  av1_iht4x8_32_add_c(input, dest, stride, param);
+#else
+  av1_iht4x8_32_add(input, dest, stride, param);
+#endif
 }
 
 static void inv_txfm_add_8x4(const tran_low_t *input, uint8_t *dest, int stride,
-                             int eob, TX_TYPE tx_type) {
-  (void)eob;
-  av1_iht8x4_32_add(input, dest, stride, tx_type);
+                             const INV_TXFM_PARAM *param) {
+#if CONFIG_LGT
+  av1_iht8x4_32_add_c(input, dest, stride, param);
+#else
+  av1_iht8x4_32_add(input, dest, stride, param);
+#endif
 }
 
 // These will be used by the masked-tx experiment in the future.
 #if CONFIG_RECT_TX && CONFIG_EXT_TX && CONFIG_RECT_TX_EXT
 static void inv_txfm_add_4x16(const tran_low_t *input, uint8_t *dest,
-                              int stride, int eob, TX_TYPE tx_type) {
-  (void)eob;
-  av1_iht4x16_64_add(input, dest, stride, tx_type);
+                              int stride, const INV_TXFM_PARAM *param) {
+#if CONFIG_LGT
+  av1_iht4x16_64_add_c(input, dest, stride, param);
+#else
+  av1_iht4x16_64_add(input, dest, stride, param);
+#endif
 }
 
 static void inv_txfm_add_16x4(const tran_low_t *input, uint8_t *dest,
-                              int stride, int eob, TX_TYPE tx_type) {
-  (void)eob;
-  av1_iht16x4_64_add(input, dest, stride, tx_type);
+                              int stride, const INV_TXFM_PARAM *param) {
+#if CONFIG_LGT
+  av1_iht16x4_64_add_c(input, dest, stride, param);
+#else
+  av1_iht16x4_64_add(input, dest, stride, param);
+#endif
 }
 
 static void inv_txfm_add_8x32(const tran_low_t *input, uint8_t *dest,
-                              int stride, int eob, TX_TYPE tx_type) {
-  (void)eob;
-  av1_iht8x32_256_add(input, dest, stride, tx_type);
+                              int stride, const INV_TXFM_PARAM *param) {
+#if CONFIG_LGT
+  av1_iht8x32_256_add_c(input, dest, stride, param);
+#else
+  av1_iht8x32_256_add(input, dest, stride, param);
+#endif
 }
 
 static void inv_txfm_add_32x8(const tran_low_t *input, uint8_t *dest,
-                              int stride, int eob, TX_TYPE tx_type) {
-  (void)eob;
-  av1_iht32x8_256_add(input, dest, stride, tx_type);
+                              int stride, const INV_TXFM_PARAM *param) {
+#if CONFIG_LGT
+  av1_iht32x8_256_add_c(input, dest, stride, param);
+#else
+  av1_iht32x8_256_add(input, dest, stride, param);
+#endif
 }
-#endif
+#endif  // CONFIG_RECT_TX && CONFIG_EXT_TX && CONFIG_RECT_TX_EXT
 
 static void inv_txfm_add_8x16(const tran_low_t *input, uint8_t *dest,
-                              int stride, int eob, TX_TYPE tx_type) {
-  (void)eob;
-  av1_iht8x16_128_add(input, dest, stride, tx_type);
+                              int stride, const INV_TXFM_PARAM *param) {
+#if CONFIG_LGT
+  av1_iht8x16_128_add_c(input, dest, stride, param);
+#else
+  av1_iht8x16_128_add(input, dest, stride, param);
+#endif
 }
 
 static void inv_txfm_add_16x8(const tran_low_t *input, uint8_t *dest,
-                              int stride, int eob, TX_TYPE tx_type) {
-  (void)eob;
-  av1_iht16x8_128_add(input, dest, stride, tx_type);
+                              int stride, const INV_TXFM_PARAM *param) {
+#if CONFIG_LGT
+  av1_iht16x8_128_add_c(input, dest, stride, param);
+#else
+  av1_iht16x8_128_add(input, dest, stride, param);
+#endif
 }
 
 static void inv_txfm_add_16x32(const tran_low_t *input, uint8_t *dest,
-                               int stride, int eob, TX_TYPE tx_type) {
-  (void)eob;
-  av1_iht16x32_512_add(input, dest, stride, tx_type);
+                               int stride, const INV_TXFM_PARAM *param) {
+  av1_iht16x32_512_add(input, dest, stride, param);
 }
 
 static void inv_txfm_add_32x16(const tran_low_t *input, uint8_t *dest,
-                               int stride, int eob, TX_TYPE tx_type) {
-  (void)eob;
-  av1_iht32x16_512_add(input, dest, stride, tx_type);
+                               int stride, const INV_TXFM_PARAM *param) {
+  av1_iht32x16_512_add(input, dest, stride, param);
 }
 
 static void inv_txfm_add_8x8(const tran_low_t *input, uint8_t *dest, int stride,
                              const INV_TXFM_PARAM *param) {
   const TX_TYPE tx_type = param->tx_type;
   switch (tx_type) {
     case DCT_DCT: idct8x8_add(input, dest, stride, param); break;
     case ADST_DCT:
     case DCT_ADST:
-    case ADST_ADST: av1_iht8x8_64_add(input, dest, stride, tx_type); break;
+    case ADST_ADST:
+#if CONFIG_LGT
+      av1_iht8x8_64_add_c(input, dest, stride, param);
+      break;
+#else
+      av1_iht8x8_64_add(input, dest, stride, param);
+      break;
+#endif
 #if CONFIG_EXT_TX
     case FLIPADST_DCT:
     case DCT_FLIPADST:
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
-    case FLIPADST_ADST: av1_iht8x8_64_add(input, dest, stride, tx_type); break;
+    case FLIPADST_ADST:
+#if CONFIG_LGT
+      av1_iht8x8_64_add_c(input, dest, stride, param);
+      break;
+#else
+      av1_iht8x8_64_add(input, dest, stride, param);
+      break;
+#endif
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
     case H_FLIPADST:
       // Use C version since DST only exists in C code
-      av1_iht8x8_64_add_c(input, dest, stride, tx_type);
+      av1_iht8x8_64_add_c(input, dest, stride, param);
       break;
     case IDTX: inv_idtx_add_c(input, dest, stride, 8, tx_type); break;
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
   }
 }
 
 static void inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest,
                                int stride, const INV_TXFM_PARAM *param) {
   const TX_TYPE tx_type = param->tx_type;
   switch (tx_type) {
     case DCT_DCT: idct16x16_add(input, dest, stride, param); break;
     case ADST_DCT:
     case DCT_ADST:
-    case ADST_ADST: av1_iht16x16_256_add(input, dest, stride, tx_type); break;
+    case ADST_ADST: av1_iht16x16_256_add(input, dest, stride, param); break;
 #if CONFIG_EXT_TX
     case FLIPADST_DCT:
     case DCT_FLIPADST:
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
     case FLIPADST_ADST:
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
-    case H_FLIPADST: av1_iht16x16_256_add(input, dest, stride, tx_type); break;
+    case H_FLIPADST: av1_iht16x16_256_add(input, dest, stride, param); break;
     case IDTX: inv_idtx_add_c(input, dest, stride, 16, tx_type); break;
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
   }
 }
 
 static void inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest,
                                int stride, const INV_TXFM_PARAM *param) {
@@ -1490,19 +1597,17 @@ static void inv_txfm_add_32x32(const tra
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
     case FLIPADST_ADST:
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
-    case H_FLIPADST:
-      av1_iht32x32_1024_add_c(input, dest, stride, tx_type);
-      break;
+    case H_FLIPADST: av1_iht32x32_1024_add_c(input, dest, stride, param); break;
     case IDTX: inv_idtx_add_c(input, dest, stride, 32, tx_type); break;
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
   }
 }
 
 #if CONFIG_TX64X64
 static void inv_txfm_add_64x64(const tran_low_t *input, uint8_t *dest,
@@ -1519,961 +1624,39 @@ static void inv_txfm_add_64x64(const tra
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
     case FLIPADST_ADST:
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
-    case H_FLIPADST:
-      av1_iht64x64_4096_add_c(input, dest, stride, tx_type);
-      break;
+    case H_FLIPADST: av1_iht64x64_4096_add_c(input, dest, stride, param); break;
     case IDTX: inv_idtx_add_c(input, dest, stride, 64, tx_type); break;
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
   }
 }
 #endif  // CONFIG_TX64X64
 
-#if CONFIG_HIGHBITDEPTH
-void av1_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest8,
-                                int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_4[] = {
-    { aom_highbd_idct4_c, aom_highbd_idct4_c },    // DCT_DCT
-    { aom_highbd_iadst4_c, aom_highbd_idct4_c },   // ADST_DCT
-    { aom_highbd_idct4_c, aom_highbd_iadst4_c },   // DCT_ADST
-    { aom_highbd_iadst4_c, aom_highbd_iadst4_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { aom_highbd_iadst4_c, aom_highbd_idct4_c },   // FLIPADST_DCT
-    { aom_highbd_idct4_c, aom_highbd_iadst4_c },   // DCT_FLIPADST
-    { aom_highbd_iadst4_c, aom_highbd_iadst4_c },  // FLIPADST_FLIPADST
-    { aom_highbd_iadst4_c, aom_highbd_iadst4_c },  // ADST_FLIPADST
-    { aom_highbd_iadst4_c, aom_highbd_iadst4_c },  // FLIPADST_ADST
-    { highbd_iidtx4_c, highbd_iidtx4_c },          // IDTX
-    { aom_highbd_idct4_c, highbd_iidtx4_c },       // V_DCT
-    { highbd_iidtx4_c, aom_highbd_idct4_c },       // H_DCT
-    { aom_highbd_iadst4_c, highbd_iidtx4_c },      // V_ADST
-    { highbd_iidtx4_c, aom_highbd_iadst4_c },      // H_ADST
-    { aom_highbd_iadst4_c, highbd_iidtx4_c },      // V_FLIPADST
-    { highbd_iidtx4_c, aom_highbd_iadst4_c },      // H_FLIPADST
-#endif                                             // CONFIG_EXT_TX
-  };
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t tmp[4][4];
-  tran_low_t out[4][4];
-  tran_low_t *outp = &out[0][0];
-  int outstride = 4;
-
-  // inverse transform row vectors
-  for (i = 0; i < 4; ++i) {
-    HIGH_IHT_4[tx_type].rows(input, out[i], bd);
-    input += 4;
-  }
-
-  // transpose
-  for (i = 0; i < 4; i++) {
-    for (j = 0; j < 4; j++) {
-      tmp[j][i] = out[i][j];
-    }
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < 4; ++i) {
-    HIGH_IHT_4[tx_type].cols(tmp[i], out[i], bd);
-  }
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, 4, 4);
-#endif
-
-  // Sum with the destination
-  for (i = 0; i < 4; ++i) {
-    for (j = 0; j < 4; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4), bd);
-    }
-  }
-}
-
-void av1_highbd_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest8,
-                                int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_4x8[] = {
-    { aom_highbd_idct8_c, aom_highbd_idct4_c },    // DCT_DCT
-    { aom_highbd_iadst8_c, aom_highbd_idct4_c },   // ADST_DCT
-    { aom_highbd_idct8_c, aom_highbd_iadst4_c },   // DCT_ADST
-    { aom_highbd_iadst8_c, aom_highbd_iadst4_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { aom_highbd_iadst8_c, aom_highbd_idct4_c },   // FLIPADST_DCT
-    { aom_highbd_idct8_c, aom_highbd_iadst4_c },   // DCT_FLIPADST
-    { aom_highbd_iadst8_c, aom_highbd_iadst4_c },  // FLIPADST_FLIPADST
-    { aom_highbd_iadst8_c, aom_highbd_iadst4_c },  // ADST_FLIPADST
-    { aom_highbd_iadst8_c, aom_highbd_iadst4_c },  // FLIPADST_ADST
-    { highbd_iidtx8_c, highbd_iidtx4_c },          // IDTX
-    { aom_highbd_idct8_c, highbd_iidtx4_c },       // V_DCT
-    { highbd_iidtx8_c, aom_highbd_idct4_c },       // H_DCT
-    { aom_highbd_iadst8_c, highbd_iidtx4_c },      // V_ADST
-    { highbd_iidtx8_c, aom_highbd_iadst4_c },      // H_ADST
-    { aom_highbd_iadst8_c, highbd_iidtx4_c },      // V_FLIPADST
-    { highbd_iidtx8_c, aom_highbd_iadst4_c },      // H_FLIPADST
-#endif                                             // CONFIG_EXT_TX
-  };
-  const int n = 4;
-  const int n2 = 8;
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t out[4][8], tmp[4][8], outtmp[4];
-  tran_low_t *outp = &out[0][0];
-  int outstride = n2;
-
-  // inverse transform row vectors, and transpose
-  for (i = 0; i < n2; ++i) {
-    HIGH_IHT_4x8[tx_type].rows(input, outtmp, bd);
-    for (j = 0; j < n; ++j) {
-      tmp[j][i] = HIGHBD_WRAPLOW(dct_const_round_shift(outtmp[j] * Sqrt2), bd);
-    }
-    input += n;
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < n; ++i) {
-    HIGH_IHT_4x8[tx_type].cols(tmp[i], out[i], bd);
-  }
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, n2, n);
-#endif  // CONFIG_EXT_TX
-
-  // Sum with the destination
-  for (i = 0; i < n2; ++i) {
-    for (j = 0; j < n; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5), bd);
-    }
-  }
-}
-
-void av1_highbd_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest8,
-                                int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_8x4[] = {
-    { aom_highbd_idct4_c, aom_highbd_idct8_c },    // DCT_DCT
-    { aom_highbd_iadst4_c, aom_highbd_idct8_c },   // ADST_DCT
-    { aom_highbd_idct4_c, aom_highbd_iadst8_c },   // DCT_ADST
-    { aom_highbd_iadst4_c, aom_highbd_iadst8_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { aom_highbd_iadst4_c, aom_highbd_idct8_c },   // FLIPADST_DCT
-    { aom_highbd_idct4_c, aom_highbd_iadst8_c },   // DCT_FLIPADST
-    { aom_highbd_iadst4_c, aom_highbd_iadst8_c },  // FLIPADST_FLIPADST
-    { aom_highbd_iadst4_c, aom_highbd_iadst8_c },  // ADST_FLIPADST
-    { aom_highbd_iadst4_c, aom_highbd_iadst8_c },  // FLIPADST_ADST
-    { highbd_iidtx4_c, highbd_iidtx8_c },          // IDTX
-    { aom_highbd_idct4_c, highbd_iidtx8_c },       // V_DCT
-    { highbd_iidtx4_c, aom_highbd_idct8_c },       // H_DCT
-    { aom_highbd_iadst4_c, highbd_iidtx8_c },      // V_ADST
-    { highbd_iidtx4_c, aom_highbd_iadst8_c },      // H_ADST
-    { aom_highbd_iadst4_c, highbd_iidtx8_c },      // V_FLIPADST
-    { highbd_iidtx4_c, aom_highbd_iadst8_c },      // H_FLIPADST
-#endif                                             // CONFIG_EXT_TX
-  };
-  const int n = 4;
-  const int n2 = 8;
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t out[8][4], tmp[8][4], outtmp[8];
-  tran_low_t *outp = &out[0][0];
-  int outstride = n;
-
-  // inverse transform row vectors, and transpose
-  for (i = 0; i < n; ++i) {
-    HIGH_IHT_8x4[tx_type].rows(input, outtmp, bd);
-    for (j = 0; j < n2; ++j) {
-      tmp[j][i] = HIGHBD_WRAPLOW(dct_const_round_shift(outtmp[j] * Sqrt2), bd);
-    }
-    input += n2;
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < n2; ++i) {
-    HIGH_IHT_8x4[tx_type].cols(tmp[i], out[i], bd);
-  }
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, n, n2);
-#endif  // CONFIG_EXT_TX
-
-  // Sum with the destination
-  for (i = 0; i < n; ++i) {
-    for (j = 0; j < n2; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5), bd);
-    }
-  }
-}
-
-void av1_highbd_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest8,
-                                 int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_4x16[] = {
-    { aom_highbd_idct16_c, aom_highbd_idct4_c },    // DCT_DCT
-    { aom_highbd_iadst16_c, aom_highbd_idct4_c },   // ADST_DCT
-    { aom_highbd_idct16_c, aom_highbd_iadst4_c },   // DCT_ADST
-    { aom_highbd_iadst16_c, aom_highbd_iadst4_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { aom_highbd_iadst16_c, aom_highbd_idct4_c },   // FLIPADST_DCT
-    { aom_highbd_idct16_c, aom_highbd_iadst4_c },   // DCT_FLIPADST
-    { aom_highbd_iadst16_c, aom_highbd_iadst4_c },  // FLIPADST_FLIPADST
-    { aom_highbd_iadst16_c, aom_highbd_iadst4_c },  // ADST_FLIPADST
-    { aom_highbd_iadst16_c, aom_highbd_iadst4_c },  // FLIPADST_ADST
-    { highbd_iidtx16_c, highbd_iidtx4_c },          // IDTX
-    { aom_highbd_idct16_c, highbd_iidtx4_c },       // V_DCT
-    { highbd_iidtx16_c, aom_highbd_idct4_c },       // H_DCT
-    { aom_highbd_iadst16_c, highbd_iidtx4_c },      // V_ADST
-    { highbd_iidtx16_c, aom_highbd_iadst4_c },      // H_ADST
-    { aom_highbd_iadst16_c, highbd_iidtx4_c },      // V_FLIPADST
-    { highbd_iidtx16_c, aom_highbd_iadst4_c },      // H_FLIPADST
-#endif                                              // CONFIG_EXT_TX
-  };
-  const int n = 4;
-  const int n4 = 16;
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t out[4][16], tmp[4][16], outtmp[4];
-  tran_low_t *outp = &out[0][0];
-  int outstride = n4;
-
-  // inverse transform row vectors, and transpose
-  for (i = 0; i < n4; ++i) {
-    HIGH_IHT_4x16[tx_type].rows(input, outtmp, bd);
-    for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j];
-    input += n;
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < n; ++i) HIGH_IHT_4x16[tx_type].cols(tmp[i], out[i], bd);
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, n4, n);
-#endif  // CONFIG_EXT_TX
-
-  // Sum with the destination
-  for (i = 0; i < n4; ++i) {
-    for (j = 0; j < n; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5), bd);
-    }
-  }
-}
-
-void av1_highbd_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest8,
-                                 int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_16x4[] = {
-    { aom_highbd_idct4_c, aom_highbd_idct16_c },    // DCT_DCT
-    { aom_highbd_iadst4_c, aom_highbd_idct16_c },   // ADST_DCT
-    { aom_highbd_idct4_c, aom_highbd_iadst16_c },   // DCT_ADST
-    { aom_highbd_iadst4_c, aom_highbd_iadst16_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { aom_highbd_iadst4_c, aom_highbd_idct16_c },   // FLIPADST_DCT
-    { aom_highbd_idct4_c, aom_highbd_iadst16_c },   // DCT_FLIPADST
-    { aom_highbd_iadst4_c, aom_highbd_iadst16_c },  // FLIPADST_FLIPADST
-    { aom_highbd_iadst4_c, aom_highbd_iadst16_c },  // ADST_FLIPADST
-    { aom_highbd_iadst4_c, aom_highbd_iadst16_c },  // FLIPADST_ADST
-    { highbd_iidtx4_c, highbd_iidtx16_c },          // IDTX
-    { aom_highbd_idct4_c, highbd_iidtx16_c },       // V_DCT
-    { highbd_iidtx4_c, aom_highbd_idct16_c },       // H_DCT
-    { aom_highbd_iadst4_c, highbd_iidtx16_c },      // V_ADST
-    { highbd_iidtx4_c, aom_highbd_iadst16_c },      // H_ADST
-    { aom_highbd_iadst4_c, highbd_iidtx16_c },      // V_FLIPADST
-    { highbd_iidtx4_c, aom_highbd_iadst16_c },      // H_FLIPADST
-#endif                                              // CONFIG_EXT_TX
-  };
-  const int n = 4;
-  const int n4 = 16;
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t out[16][4], tmp[16][4], outtmp[16];
-  tran_low_t *outp = &out[0][0];
-  int outstride = n;
-
-  // inverse transform row vectors, and transpose
-  for (i = 0; i < n; ++i) {
-    HIGH_IHT_16x4[tx_type].rows(input, outtmp, bd);
-    for (j = 0; j < n4; ++j) tmp[j][i] = outtmp[j];
-    input += n4;
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < n4; ++i) {
-    HIGH_IHT_16x4[tx_type].cols(tmp[i], out[i], bd);
-  }
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, n, n4);
-#endif  // CONFIG_EXT_TX
-
-  // Sum with the destination
-  for (i = 0; i < n; ++i) {
-    for (j = 0; j < n4; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5), bd);
-    }
-  }
-}
-
-void av1_highbd_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest8,
-                                  int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_8x16[] = {
-    { aom_highbd_idct16_c, aom_highbd_idct8_c },    // DCT_DCT
-    { aom_highbd_iadst16_c, aom_highbd_idct8_c },   // ADST_DCT
-    { aom_highbd_idct16_c, aom_highbd_iadst8_c },   // DCT_ADST
-    { aom_highbd_iadst16_c, aom_highbd_iadst8_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { aom_highbd_iadst16_c, aom_highbd_idct8_c },   // FLIPADST_DCT
-    { aom_highbd_idct16_c, aom_highbd_iadst8_c },   // DCT_FLIPADST
-    { aom_highbd_iadst16_c, aom_highbd_iadst8_c },  // FLIPADST_FLIPADST
-    { aom_highbd_iadst16_c, aom_highbd_iadst8_c },  // ADST_FLIPADST
-    { aom_highbd_iadst16_c, aom_highbd_iadst8_c },  // FLIPADST_ADST
-    { highbd_iidtx16_c, highbd_iidtx8_c },          // IDTX
-    { aom_highbd_idct16_c, highbd_iidtx8_c },       // V_DCT
-    { highbd_iidtx16_c, aom_highbd_idct8_c },       // H_DCT
-    { aom_highbd_iadst16_c, highbd_iidtx8_c },      // V_ADST
-    { highbd_iidtx16_c, aom_highbd_iadst8_c },      // H_ADST
-    { aom_highbd_iadst16_c, highbd_iidtx8_c },      // V_FLIPADST
-    { highbd_iidtx16_c, aom_highbd_iadst8_c },      // H_FLIPADST
-#endif                                              // CONFIG_EXT_TX
-  };
-  const int n = 8;
-  const int n2 = 16;
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t out[8][16], tmp[8][16], outtmp[8];
-  tran_low_t *outp = &out[0][0];
-  int outstride = n2;
-
-  // inverse transform row vectors, and transpose
-  for (i = 0; i < n2; ++i) {
-    HIGH_IHT_8x16[tx_type].rows(input, outtmp, bd);
-    for (j = 0; j < n; ++j)
-      tmp[j][i] = HIGHBD_WRAPLOW(dct_const_round_shift(outtmp[j] * Sqrt2), bd);
-    input += n;
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < n; ++i) {
-    HIGH_IHT_8x16[tx_type].cols(tmp[i], out[i], bd);
-  }
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, n2, n);
-#endif  // CONFIG_EXT_TX
-
-  // Sum with the destination
-  for (i = 0; i < n2; ++i) {
-    for (j = 0; j < n; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6), bd);
-    }
-  }
-}
-
-void av1_highbd_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest8,
-                                  int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_16x8[] = {
-    { aom_highbd_idct8_c, aom_highbd_idct16_c },    // DCT_DCT
-    { aom_highbd_iadst8_c, aom_highbd_idct16_c },   // ADST_DCT
-    { aom_highbd_idct8_c, aom_highbd_iadst16_c },   // DCT_ADST
-    { aom_highbd_iadst8_c, aom_highbd_iadst16_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { aom_highbd_iadst8_c, aom_highbd_idct16_c },   // FLIPADST_DCT
-    { aom_highbd_idct8_c, aom_highbd_iadst16_c },   // DCT_FLIPADST
-    { aom_highbd_iadst8_c, aom_highbd_iadst16_c },  // FLIPADST_FLIPADST
-    { aom_highbd_iadst8_c, aom_highbd_iadst16_c },  // ADST_FLIPADST
-    { aom_highbd_iadst8_c, aom_highbd_iadst16_c },  // FLIPADST_ADST
-    { highbd_iidtx8_c, highbd_iidtx16_c },          // IDTX
-    { aom_highbd_idct8_c, highbd_iidtx16_c },       // V_DCT
-    { highbd_iidtx8_c, aom_highbd_idct16_c },       // H_DCT
-    { aom_highbd_iadst8_c, highbd_iidtx16_c },      // V_ADST
-    { highbd_iidtx8_c, aom_highbd_iadst16_c },      // H_ADST
-    { aom_highbd_iadst8_c, highbd_iidtx16_c },      // V_FLIPADST
-    { highbd_iidtx8_c, aom_highbd_iadst16_c },      // H_FLIPADST
-#endif                                              // CONFIG_EXT_TX
-  };
-  const int n = 8;
-  const int n2 = 16;
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t out[16][8], tmp[16][8], outtmp[16];
-  tran_low_t *outp = &out[0][0];
-  int outstride = n;
-
-  // inverse transform row vectors, and transpose
-  for (i = 0; i < n; ++i) {
-    HIGH_IHT_16x8[tx_type].rows(input, outtmp, bd);
-    for (j = 0; j < n2; ++j)
-      tmp[j][i] = HIGHBD_WRAPLOW(dct_const_round_shift(outtmp[j] * Sqrt2), bd);
-    input += n2;
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < n2; ++i) {
-    HIGH_IHT_16x8[tx_type].cols(tmp[i], out[i], bd);
-  }
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, n, n2);
-#endif  // CONFIG_EXT_TX
-
-  // Sum with the destination
-  for (i = 0; i < n; ++i) {
-    for (j = 0; j < n2; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6), bd);
-    }
-  }
-}
-
-void av1_highbd_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest8,
-                                  int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_8x32[] = {
-    { aom_highbd_idct32_c, aom_highbd_idct8_c },     // DCT_DCT
-    { highbd_ihalfright32_c, aom_highbd_idct8_c },   // ADST_DCT
-    { aom_highbd_idct32_c, aom_highbd_iadst8_c },    // DCT_ADST
-    { highbd_ihalfright32_c, aom_highbd_iadst8_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { highbd_ihalfright32_c, aom_highbd_idct8_c },   // FLIPADST_DCT
-    { aom_highbd_idct32_c, aom_highbd_iadst8_c },    // DCT_FLIPADST
-    { highbd_ihalfright32_c, aom_highbd_iadst8_c },  // FLIPADST_FLIPADST
-    { highbd_ihalfright32_c, aom_highbd_iadst8_c },  // ADST_FLIPADST
-    { highbd_ihalfright32_c, aom_highbd_iadst8_c },  // FLIPADST_ADST
-    { highbd_iidtx32_c, highbd_iidtx8_c },           // IDTX
-    { aom_highbd_idct32_c, highbd_iidtx8_c },        // V_DCT
-    { highbd_iidtx32_c, aom_highbd_idct8_c },        // H_DCT
-    { highbd_ihalfright32_c, highbd_iidtx8_c },      // V_ADST
-    { highbd_iidtx32_c, aom_highbd_iadst8_c },       // H_ADST
-    { highbd_ihalfright32_c, highbd_iidtx8_c },      // V_FLIPADST
-    { highbd_iidtx32_c, aom_highbd_iadst8_c },       // H_FLIPADST
-#endif                                               // CONFIG_EXT_TX
-  };
-  const int n = 8;
-  const int n4 = 32;
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t out[8][32], tmp[8][32], outtmp[8];
-  tran_low_t *outp = &out[0][0];
-  int outstride = n4;
-
-  // inverse transform row vectors, and transpose
-  for (i = 0; i < n4; ++i) {
-    HIGH_IHT_8x32[tx_type].rows(input, outtmp, bd);
-    for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j];
-    input += n;
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < n; ++i) HIGH_IHT_8x32[tx_type].cols(tmp[i], out[i], bd);
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, n4, n);
-#endif  // CONFIG_EXT_TX
-
-  // Sum with the destination
-  for (i = 0; i < n4; ++i) {
-    for (j = 0; j < n; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6), bd);
-    }
-  }
-}
-
-void av1_highbd_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest8,
-                                  int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_32x8[] = {
-    { aom_highbd_idct8_c, aom_highbd_idct32_c },     // DCT_DCT
-    { aom_highbd_iadst8_c, aom_highbd_idct32_c },    // ADST_DCT
-    { aom_highbd_idct8_c, highbd_ihalfright32_c },   // DCT_ADST
-    { aom_highbd_iadst8_c, highbd_ihalfright32_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { aom_highbd_iadst8_c, aom_highbd_idct32_c },    // FLIPADST_DCT
-    { aom_highbd_idct8_c, highbd_ihalfright32_c },   // DCT_FLIPADST
-    { aom_highbd_iadst8_c, highbd_ihalfright32_c },  // FLIPADST_FLIPADST
-    { aom_highbd_iadst8_c, highbd_ihalfright32_c },  // ADST_FLIPADST
-    { aom_highbd_iadst8_c, highbd_ihalfright32_c },  // FLIPADST_ADST
-    { highbd_iidtx8_c, highbd_iidtx32_c },           // IDTX
-    { aom_highbd_idct8_c, highbd_iidtx32_c },        // V_DCT
-    { highbd_iidtx8_c, aom_highbd_idct32_c },        // H_DCT
-    { aom_highbd_iadst8_c, highbd_iidtx32_c },       // V_ADST
-    { highbd_iidtx8_c, highbd_ihalfright32_c },      // H_ADST
-    { aom_highbd_iadst8_c, highbd_iidtx32_c },       // V_FLIPADST
-    { highbd_iidtx8_c, highbd_ihalfright32_c },      // H_FLIPADST
-#endif                                               // CONFIG_EXT_TX
-  };
-  const int n = 8;
-  const int n4 = 32;
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t out[32][8], tmp[32][8], outtmp[32];
-  tran_low_t *outp = &out[0][0];
-  int outstride = n;
-
-  // inverse transform row vectors, and transpose
-  for (i = 0; i < n; ++i) {
-    HIGH_IHT_32x8[tx_type].rows(input, outtmp, bd);
-    for (j = 0; j < n4; ++j) tmp[j][i] = outtmp[j];
-    input += n4;
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < n4; ++i) HIGH_IHT_32x8[tx_type].cols(tmp[i], out[i], bd);
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, n, n4);
-#endif  // CONFIG_EXT_TX
-
-  // Sum with the destination
-  for (i = 0; i < n; ++i) {
-    for (j = 0; j < n4; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6), bd);
-    }
-  }
-}
-
-void av1_highbd_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest8,
-                                   int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_16x32[] = {
-    { aom_highbd_idct32_c, aom_highbd_idct16_c },     // DCT_DCT
-    { highbd_ihalfright32_c, aom_highbd_idct16_c },   // ADST_DCT
-    { aom_highbd_idct32_c, aom_highbd_iadst16_c },    // DCT_ADST
-    { highbd_ihalfright32_c, aom_highbd_iadst16_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { highbd_ihalfright32_c, aom_highbd_idct16_c },   // FLIPADST_DCT
-    { aom_highbd_idct32_c, aom_highbd_iadst16_c },    // DCT_FLIPADST
-    { highbd_ihalfright32_c, aom_highbd_iadst16_c },  // FLIPADST_FLIPADST
-    { highbd_ihalfright32_c, aom_highbd_iadst16_c },  // ADST_FLIPADST
-    { highbd_ihalfright32_c, aom_highbd_iadst16_c },  // FLIPADST_ADST
-    { highbd_iidtx32_c, highbd_iidtx16_c },           // IDTX
-    { aom_highbd_idct32_c, highbd_iidtx16_c },        // V_DCT
-    { highbd_iidtx32_c, aom_highbd_idct16_c },        // H_DCT
-    { highbd_ihalfright32_c, highbd_iidtx16_c },      // V_ADST
-    { highbd_iidtx32_c, aom_highbd_iadst16_c },       // H_ADST
-    { highbd_ihalfright32_c, highbd_iidtx16_c },      // V_FLIPADST
-    { highbd_iidtx32_c, aom_highbd_iadst16_c },       // H_FLIPADST
-#endif                                                // CONFIG_EXT_TX
-  };
-  const int n = 16;
-  const int n2 = 32;
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t out[16][32], tmp[16][32], outtmp[16];
-  tran_low_t *outp = &out[0][0];
-  int outstride = n2;
-
-  // inverse transform row vectors, and transpose
-  for (i = 0; i < n2; ++i) {
-    HIGH_IHT_16x32[tx_type].rows(input, outtmp, bd);
-    for (j = 0; j < n; ++j)
-      tmp[j][i] = HIGHBD_WRAPLOW(dct_const_round_shift(outtmp[j] * Sqrt2), bd);
-    input += n;
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < n; ++i) {
-    HIGH_IHT_16x32[tx_type].cols(tmp[i], out[i], bd);
-  }
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, n2, n);
-#endif  // CONFIG_EXT_TX
-
-  // Sum with the destination
-  for (i = 0; i < n2; ++i) {
-    for (j = 0; j < n; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6), bd);
-    }
-  }
-}
-
-void av1_highbd_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest8,
-                                   int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_32x16[] = {
-    { aom_highbd_idct16_c, aom_highbd_idct32_c },     // DCT_DCT
-    { aom_highbd_iadst16_c, aom_highbd_idct32_c },    // ADST_DCT
-    { aom_highbd_idct16_c, highbd_ihalfright32_c },   // DCT_ADST
-    { aom_highbd_iadst16_c, highbd_ihalfright32_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { aom_highbd_iadst16_c, aom_highbd_idct32_c },    // FLIPADST_DCT
-    { aom_highbd_idct16_c, highbd_ihalfright32_c },   // DCT_FLIPADST
-    { aom_highbd_iadst16_c, highbd_ihalfright32_c },  // FLIPADST_FLIPADST
-    { aom_highbd_iadst16_c, highbd_ihalfright32_c },  // ADST_FLIPADST
-    { aom_highbd_iadst16_c, highbd_ihalfright32_c },  // FLIPADST_ADST
-    { highbd_iidtx16_c, highbd_iidtx32_c },           // IDTX
-    { aom_highbd_idct16_c, highbd_iidtx32_c },        // V_DCT
-    { highbd_iidtx16_c, aom_highbd_idct32_c },        // H_DCT
-    { aom_highbd_iadst16_c, highbd_iidtx32_c },       // V_ADST
-    { highbd_iidtx16_c, highbd_ihalfright32_c },      // H_ADST
-    { aom_highbd_iadst16_c, highbd_iidtx32_c },       // V_FLIPADST
-    { highbd_iidtx16_c, highbd_ihalfright32_c },      // H_FLIPADST
-#endif                                                // CONFIG_EXT_TX
-  };
-  const int n = 16;
-  const int n2 = 32;
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t out[32][16], tmp[32][16], outtmp[32];
-  tran_low_t *outp = &out[0][0];
-  int outstride = n;
-
-  // inverse transform row vectors, and transpose
-  for (i = 0; i < n; ++i) {
-    HIGH_IHT_32x16[tx_type].rows(input, outtmp, bd);
-    for (j = 0; j < n2; ++j)
-      tmp[j][i] = HIGHBD_WRAPLOW(dct_const_round_shift(outtmp[j] * Sqrt2), bd);
-    input += n2;
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < n2; ++i) {
-    HIGH_IHT_32x16[tx_type].cols(tmp[i], out[i], bd);
-  }
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, n, n2);
-#endif  // CONFIG_EXT_TX
-
-  // Sum with the destination
-  for (i = 0; i < n; ++i) {
-    for (j = 0; j < n2; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6), bd);
-    }
-  }
-}
-
-void av1_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest8,
-                                int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_8[] = {
-    { aom_highbd_idct8_c, aom_highbd_idct8_c },    // DCT_DCT
-    { aom_highbd_iadst8_c, aom_highbd_idct8_c },   // ADST_DCT
-    { aom_highbd_idct8_c, aom_highbd_iadst8_c },   // DCT_ADST
-    { aom_highbd_iadst8_c, aom_highbd_iadst8_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { aom_highbd_iadst8_c, aom_highbd_idct8_c },   // FLIPADST_DCT
-    { aom_highbd_idct8_c, aom_highbd_iadst8_c },   // DCT_FLIPADST
-    { aom_highbd_iadst8_c, aom_highbd_iadst8_c },  // FLIPADST_FLIPADST
-    { aom_highbd_iadst8_c, aom_highbd_iadst8_c },  // ADST_FLIPADST
-    { aom_highbd_iadst8_c, aom_highbd_iadst8_c },  // FLIPADST_ADST
-    { highbd_iidtx8_c, highbd_iidtx8_c },          // IDTX
-    { aom_highbd_idct8_c, highbd_iidtx8_c },       // V_DCT
-    { highbd_iidtx8_c, aom_highbd_idct8_c },       // H_DCT
-    { aom_highbd_iadst8_c, highbd_iidtx8_c },      // V_ADST
-    { highbd_iidtx8_c, aom_highbd_iadst8_c },      // H_ADST
-    { aom_highbd_iadst8_c, highbd_iidtx8_c },      // V_FLIPADST
-    { highbd_iidtx8_c, aom_highbd_iadst8_c },      // H_FLIPADST
-#endif                                             // CONFIG_EXT_TX
-  };
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t tmp[8][8];
-  tran_low_t out[8][8];
-  tran_low_t *outp = &out[0][0];
-  int outstride = 8;
-
-  // inverse transform row vectors
-  for (i = 0; i < 8; ++i) {
-    HIGH_IHT_8[tx_type].rows(input, out[i], bd);
-    input += 8;
-  }
-
-  // transpose
-  for (i = 0; i < 8; i++) {
-    for (j = 0; j < 8; j++) {
-      tmp[j][i] = out[i][j];
-    }
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < 8; ++i) {
-    HIGH_IHT_8[tx_type].cols(tmp[i], out[i], bd);
-  }
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, 8, 8);
-#endif
-
-  // Sum with the destination
-  for (i = 0; i < 8; ++i) {
-    for (j = 0; j < 8; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5), bd);
-    }
-  }
-}
-
-void av1_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *dest8,
-                                   int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_16[] = {
-    { aom_highbd_idct16_c, aom_highbd_idct16_c },    // DCT_DCT
-    { aom_highbd_iadst16_c, aom_highbd_idct16_c },   // ADST_DCT
-    { aom_highbd_idct16_c, aom_highbd_iadst16_c },   // DCT_ADST
-    { aom_highbd_iadst16_c, aom_highbd_iadst16_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { aom_highbd_iadst16_c, aom_highbd_idct16_c },   // FLIPADST_DCT
-    { aom_highbd_idct16_c, aom_highbd_iadst16_c },   // DCT_FLIPADST
-    { aom_highbd_iadst16_c, aom_highbd_iadst16_c },  // FLIPADST_FLIPADST
-    { aom_highbd_iadst16_c, aom_highbd_iadst16_c },  // ADST_FLIPADST
-    { aom_highbd_iadst16_c, aom_highbd_iadst16_c },  // FLIPADST_ADST
-    { highbd_iidtx16_c, highbd_iidtx16_c },          // IDTX
-    { aom_highbd_idct16_c, highbd_iidtx16_c },       // V_DCT
-    { highbd_iidtx16_c, aom_highbd_idct16_c },       // H_DCT
-    { aom_highbd_iadst16_c, highbd_iidtx16_c },      // V_ADST
-    { highbd_iidtx16_c, aom_highbd_iadst16_c },      // H_ADST
-    { aom_highbd_iadst16_c, highbd_iidtx16_c },      // V_FLIPADST
-    { highbd_iidtx16_c, aom_highbd_iadst16_c },      // H_FLIPADST
-#endif                                               // CONFIG_EXT_TX
-  };
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t tmp[16][16];
-  tran_low_t out[16][16];
-  tran_low_t *outp = &out[0][0];
-  int outstride = 16;
-
-  // inverse transform row vectors
-  for (i = 0; i < 16; ++i) {
-    HIGH_IHT_16[tx_type].rows(input, out[i], bd);
-    input += 16;
-  }
-
-  // transpose
-  for (i = 0; i < 16; i++) {
-    for (j = 0; j < 16; j++) {
-      tmp[j][i] = out[i][j];
-    }
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < 16; ++i) {
-    HIGH_IHT_16[tx_type].cols(tmp[i], out[i], bd);
-  }
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, 16, 16);
-#endif
-
-  // Sum with the destination
-  for (i = 0; i < 16; ++i) {
-    for (j = 0; j < 16; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6), bd);
-    }
-  }
-}
-
-#if CONFIG_EXT_TX
-static void highbd_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *dest8,
-                                       int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_32[] = {
-    { aom_highbd_idct32_c, aom_highbd_idct32_c },      // DCT_DCT
-    { highbd_ihalfright32_c, aom_highbd_idct32_c },    // ADST_DCT
-    { aom_highbd_idct32_c, highbd_ihalfright32_c },    // DCT_ADST
-    { highbd_ihalfright32_c, highbd_ihalfright32_c },  // ADST_ADST
-    { highbd_ihalfright32_c, aom_highbd_idct32_c },    // FLIPADST_DCT
-    { aom_highbd_idct32_c, highbd_ihalfright32_c },    // DCT_FLIPADST
-    { highbd_ihalfright32_c, highbd_ihalfright32_c },  // FLIPADST_FLIPADST
-    { highbd_ihalfright32_c, highbd_ihalfright32_c },  // ADST_FLIPADST
-    { highbd_ihalfright32_c, highbd_ihalfright32_c },  // FLIPADST_ADST
-    { highbd_iidtx32_c, highbd_iidtx32_c },            // IDTX
-    { aom_highbd_idct32_c, highbd_iidtx32_c },         // V_DCT
-    { highbd_iidtx32_c, aom_highbd_idct32_c },         // H_DCT
-    { highbd_ihalfright32_c, highbd_iidtx32_c },       // V_ADST
-    { highbd_iidtx32_c, highbd_ihalfright32_c },       // H_ADST
-    { highbd_ihalfright32_c, highbd_iidtx32_c },       // V_FLIPADST
-    { highbd_iidtx32_c, highbd_ihalfright32_c },       // H_FLIPADST
-  };
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t tmp[32][32];
-  tran_low_t out[32][32];
-  tran_low_t *outp = &out[0][0];
-  int outstride = 32;
-
-  // inverse transform row vectors
-  for (i = 0; i < 32; ++i) {
-    HIGH_IHT_32[tx_type].rows(input, out[i], bd);
-    input += 32;
-  }
-
-  // transpose
-  for (i = 0; i < 32; i++) {
-    for (j = 0; j < 32; j++) {
-      tmp[j][i] = out[i][j];
-    }
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < 32; ++i) {
-    HIGH_IHT_32[tx_type].cols(tmp[i], out[i], bd);
-  }
-
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, 32, 32);
-
-  // Sum with the destination
-  for (i = 0; i < 32; ++i) {
-    for (j = 0; j < 32; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6), bd);
-    }
-  }
-}
-#endif  // CONFIG_EXT_TX
-
-#if CONFIG_TX64X64
-static void highbd_iht64x64_4096_add_c(const tran_low_t *input, uint8_t *dest8,
-                                       int stride, int tx_type, int bd) {
-  static const highbd_transform_2d HIGH_IHT_64[] = {
-    { highbd_idct64_col_c, highbd_idct64_row_c },      // DCT_DCT
-    { highbd_ihalfright64_c, highbd_idct64_row_c },    // ADST_DCT
-    { highbd_idct64_col_c, highbd_ihalfright64_c },    // DCT_ADST
-    { highbd_ihalfright64_c, highbd_ihalfright64_c },  // ADST_ADST
-#if CONFIG_EXT_TX
-    { highbd_ihalfright64_c, highbd_idct64_row_c },    // FLIPADST_DCT
-    { highbd_idct64_col_c, highbd_ihalfright64_c },    // DCT_FLIPADST
-    { highbd_ihalfright64_c, highbd_ihalfright64_c },  // FLIPADST_FLIPADST
-    { highbd_ihalfright64_c, highbd_ihalfright64_c },  // ADST_FLIPADST
-    { highbd_ihalfright64_c, highbd_ihalfright64_c },  // FLIPADST_ADST
-    { highbd_iidtx64_c, highbd_iidtx64_c },            // IDTX
-    { highbd_idct64_col_c, highbd_iidtx64_c },         // V_DCT
-    { highbd_iidtx64_c, highbd_idct64_row_c },         // H_DCT
-    { highbd_ihalfright64_c, highbd_iidtx64_c },       // V_ADST
-    { highbd_iidtx64_c, highbd_ihalfright64_c },       // H_ADST
-    { highbd_ihalfright64_c, highbd_iidtx64_c },       // V_FLIPADST
-    { highbd_iidtx64_c, highbd_ihalfright64_c },       // H_FLIPADST
-#endif                                                 // CONFIG_EXT_TX
-  };
-
-  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
-
-  int i, j;
-  tran_low_t tmp[64][64];
-  tran_low_t out[64][64];
-  tran_low_t *outp = &out[0][0];
-  int outstride = 64;
-
-  // inverse transform row vectors
-  for (i = 0; i < 64; ++i) {
-    HIGH_IHT_64[tx_type].rows(input, out[i], bd);
-    for (j = 0; j < 64; ++j) out[i][j] = ROUND_POWER_OF_TWO(out[i][j], 1);
-    input += 64;
-  }
-
-  // transpose
-  for (i = 0; i < 64; i++) {
-    for (j = 0; j < 64; j++) {
-      tmp[j][i] = out[i][j];
-    }
-  }
-
-  // inverse transform column vectors
-  for (i = 0; i < 64; ++i) {
-    HIGH_IHT_64[tx_type].cols(tmp[i], out[i], bd);
-  }
-
-#if CONFIG_EXT_TX
-  maybe_flip_strides16(&dest, &stride, &outp, &outstride, tx_type, 64, 64);
-#endif  // CONFIG_EXT_TX
-
-  // Sum with the destination
-  for (i = 0; i < 64; ++i) {
-    for (j = 0; j < 64; ++j) {
-      int d = i * stride + j;
-      int s = j * outstride + i;
-      dest[d] =
-          highbd_clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5), bd);
-    }
-  }
-}
-#endif  // CONFIG_TX64X64
-
-// idct
-void av1_highbd_idct4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
-                            int eob, int bd) {
-  if (eob > 1)
-    aom_highbd_idct4x4_16_add(input, dest, stride, bd);
-  else
-    aom_highbd_idct4x4_1_add(input, dest, stride, bd);
-}
-
 void av1_highbd_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
                             int eob, int bd) {
   if (eob > 1)
     aom_highbd_iwht4x4_16_add(input, dest, stride, bd);
   else
     aom_highbd_iwht4x4_1_add(input, dest, stride, bd);
 }
 
 #if CONFIG_CHROMA_2X2
 static void highbd_inv_txfm_add_2x2(const tran_low_t *input, uint8_t *dest,
-                                    int stride, int eob, int bd,
-                                    TX_TYPE tx_type, int lossless) {
+                                    int stride, const INV_TXFM_PARAM *param) {
+  int eob = param->eob;
+  int bd = param->bd;
+  int lossless = param->lossless;
+  TX_TYPE tx_type = param->tx_type;
   tran_high_t a1 = input[0] >> UNIT_QUANT_SHIFT;
   tran_high_t b1 = input[1] >> UNIT_QUANT_SHIFT;
   tran_high_t c1 = input[2] >> UNIT_QUANT_SHIFT;
   tran_high_t d1 = input[3] >> UNIT_QUANT_SHIFT;
 
   tran_high_t a2 = a1 + c1;
   tran_high_t b2 = b1 + d1;
   tran_high_t c2 = a1 - c1;
@@ -2493,330 +1676,329 @@ static void highbd_inv_txfm_add_2x2(cons
   dst[0] = highbd_clip_pixel_add(dst[0], a1, bd);
   dst[1] = highbd_clip_pixel_add(dst[1], b1, bd);
   dst[stride] = highbd_clip_pixel_add(dst[stride], c1, bd);
   dst[stride + 1] = highbd_clip_pixel_add(dst[stride + 1], d1, bd);
 }
 #endif
 
 void av1_highbd_inv_txfm_add_4x4(const tran_low_t *input, uint8_t *dest,
-                                 int stride, int eob, int bd, TX_TYPE tx_type,
-                                 int lossless) {
+                                 int stride, const INV_TXFM_PARAM *param) {
+  int eob = param->eob;
+  int bd = param->bd;
+  int lossless = param->lossless;
+  const int32_t *src = (const int32_t *)input;
+  TX_TYPE tx_type = param->tx_type;
   if (lossless) {
     assert(tx_type == DCT_DCT);
     av1_highbd_iwht4x4_add(input, dest, stride, eob, bd);
     return;
   }
-
   switch (tx_type) {
     case DCT_DCT:
     case ADST_DCT:
     case DCT_ADST:
     case ADST_ADST:
+      av1_inv_txfm2d_add_4x4(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type,
+                             bd);
+      break;
 #if CONFIG_EXT_TX
     case FLIPADST_DCT:
     case DCT_FLIPADST:
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
     case FLIPADST_ADST:
-#endif  // CONFIG_EXT_TX
-      av1_inv_txfm2d_add_4x4(input, CONVERT_TO_SHORTPTR(dest), stride, tx_type,
+      av1_inv_txfm2d_add_4x4(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type,
                              bd);
       break;
-#if CONFIG_EXT_TX
+    // use the c version for anything including identity for now
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
     case H_FLIPADST:
-      // Use C version since DST only exists in C code
-      av1_highbd_iht4x4_16_add_c(input, dest, stride, tx_type, bd);
-      break;
     case IDTX:
-      highbd_inv_idtx_add_c(input, dest, stride, 4, tx_type, bd);
+      av1_inv_txfm2d_add_4x4_c(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type,
+                               bd);
       break;
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
   }
 }
 
 void av1_highbd_inv_txfm_add_4x8(const tran_low_t *input, uint8_t *dest,
-                                 int stride, int eob, int bd, TX_TYPE tx_type) {
-  (void)eob;
-  av1_highbd_iht4x8_32_add_c(input, dest, stride, tx_type, bd);
+                                 int stride, const INV_TXFM_PARAM *param) {
+  const int32_t *src = (const int32_t *)input;
+  av1_inv_txfm2d_add_4x8_c(src, CONVERT_TO_SHORTPTR(dest), stride,
+                           param->tx_type, param->bd);
 }
 
 void av1_highbd_inv_txfm_add_8x4(const tran_low_t *input, uint8_t *dest,
-                                 int stride, int eob, int bd, TX_TYPE tx_type) {
-  (void)eob;
-  av1_highbd_iht8x4_32_add_c(input, dest, stride, tx_type, bd);
-}
-
-void av1_highbd_inv_txfm_add_4x16(const tran_low_t *input, uint8_t *dest,
-                                  int stride, int eob, int bd,
-                                  TX_TYPE tx_type) {
-  (void)eob;
-  av1_highbd_iht4x16_64_add_c(input, dest, stride, tx_type, bd);
-}
-
-void av1_highbd_inv_txfm_add_16x4(const tran_low_t *input, uint8_t *dest,
-                                  int stride, int eob, int bd,
-                                  TX_TYPE tx_type) {
-  (void)eob;
-  av1_highbd_iht16x4_64_add_c(input, dest, stride, tx_type, bd);
+                                 int stride, const INV_TXFM_PARAM *param) {
+  const int32_t *src = (const int32_t *)input;
+  av1_inv_txfm2d_add_8x4_c(src, CONVERT_TO_SHORTPTR(dest), stride,
+                           param->tx_type, param->bd);
 }
 
 static void highbd_inv_txfm_add_8x16(const tran_low_t *input, uint8_t *dest,
-                                     int stride, int eob, int bd,
-                                     TX_TYPE tx_type) {
-  (void)eob;
-  av1_highbd_iht8x16_128_add_c(input, dest, stride, tx_type, bd);
+                                     int stride, const INV_TXFM_PARAM *param) {
+  const int32_t *src = (const int32_t *)input;
+  av1_inv_txfm2d_add_8x16_c(src, CONVERT_TO_SHORTPTR(dest), stride,
+                            param->tx_type, param->bd);
 }
 
 static void highbd_inv_txfm_add_16x8(const tran_low_t *input, uint8_t *dest,
-                                     int stride, int eob, int bd,
-                                     TX_TYPE tx_type) {
-  (void)eob;
-  av1_highbd_iht16x8_128_add_c(input, dest, stride, tx_type, bd);
-}
-
-void av1_highbd_inv_txfm_add_8x32(const tran_low_t *input, uint8_t *dest,
-                                  int stride, int eob, int bd,
-                                  TX_TYPE tx_type) {
-  (void)eob;
-  av1_highbd_iht8x32_256_add_c(input, dest, stride, tx_type, bd);
-}
-
-void av1_highbd_inv_txfm_add_32x8(const tran_low_t *input, uint8_t *dest,
-                                  int stride, int eob, int bd,
-                                  TX_TYPE tx_type) {
-  (void)eob;
-  av1_highbd_iht32x8_256_add_c(input, dest, stride, tx_type, bd);
+                                     int stride, const INV_TXFM_PARAM *param) {
+  const int32_t *src = (const int32_t *)input;
+  av1_inv_txfm2d_add_16x8_c(src, CONVERT_TO_SHORTPTR(dest), stride,
+                            param->tx_type, param->bd);
 }
 
 static void highbd_inv_txfm_add_16x32(const tran_low_t *input, uint8_t *dest,
-                                      int stride, int eob, int bd,
-                                      TX_TYPE tx_type) {
-  (void)eob;
-  av1_highbd_iht16x32_512_add_c(input, dest, stride, tx_type, bd);
+                                      int stride, const INV_TXFM_PARAM *param) {
+  const int32_t *src = (const int32_t *)input;
+  av1_inv_txfm2d_add_16x32_c(src, CONVERT_TO_SHORTPTR(dest), stride,
+                             param->tx_type, param->bd);
 }
 
 static void highbd_inv_txfm_add_32x16(const tran_low_t *input, uint8_t *dest,
-                                      int stride, int eob, int bd,
-                                      TX_TYPE tx_type) {
-  (void)eob;
-  av1_highbd_iht32x16_512_add_c(input, dest, stride, tx_type, bd);
+                                      int stride, const INV_TXFM_PARAM *param) {
+  const int32_t *src = (const int32_t *)input;
+  av1_inv_txfm2d_add_32x16_c(src, CONVERT_TO_SHORTPTR(dest), stride,
+                             param->tx_type, param->bd);
 }
 
 static void highbd_inv_txfm_add_8x8(const tran_low_t *input, uint8_t *dest,
-                                    int stride, int eob, int bd,
-                                    TX_TYPE tx_type) {
-  (void)eob;
+                                    int stride, const INV_TXFM_PARAM *param) {
+  int bd = param->bd;
+  TX_TYPE tx_type = param->tx_type;
+  const int32_t *src = (const int32_t *)input;
   switch (tx_type) {
     case DCT_DCT:
     case ADST_DCT:
     case DCT_ADST:
     case ADST_ADST:
+      av1_inv_txfm2d_add_8x8(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type,
+                             bd);
+      break;
 #if CONFIG_EXT_TX
     case FLIPADST_DCT:
     case DCT_FLIPADST:
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
     case FLIPADST_ADST:
-#endif  // CONFIG_EXT_TX
-      av1_inv_txfm2d_add_8x8(input, CONVERT_TO_SHORTPTR(dest), stride, tx_type,
+      av1_inv_txfm2d_add_8x8(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type,
                              bd);
       break;
+    // use the c version for anything including identity for now
+    case V_DCT:
+    case H_DCT:
+    case V_ADST:
+    case H_ADST:
+    case V_FLIPADST:
+    case H_FLIPADST:
+    case IDTX:
+      av1_inv_txfm2d_add_8x8_c(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type,
+                               bd);
+      break;
+#endif  // CONFIG_EXT_TX
+    default: assert(0);
+  }
+}
+
+static void highbd_inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest,
+                                      int stride, const INV_TXFM_PARAM *param) {
+  int bd = param->bd;
+  TX_TYPE tx_type = param->tx_type;
+  const int32_t *src = (const int32_t *)input;
+  switch (tx_type) {
+    case DCT_DCT:
+    case ADST_DCT:
+    case DCT_ADST:
+    case ADST_ADST:
+      av1_inv_txfm2d_add_16x16(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type,
+                               bd);
+      break;
 #if CONFIG_EXT_TX
+    case FLIPADST_DCT:
+    case DCT_FLIPADST:
+    case FLIPADST_FLIPADST:
+    case ADST_FLIPADST:
+    case FLIPADST_ADST:
+      av1_inv_txfm2d_add_16x16(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type,
+                               bd);
+      break;
+    // use the c version for anything including identity for now
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
     case H_FLIPADST:
-      // Use C version since DST only exists in C code
-      av1_highbd_iht8x8_64_add_c(input, dest, stride, tx_type, bd);
-      break;
     case IDTX:
-      highbd_inv_idtx_add_c(input, dest, stride, 8, tx_type, bd);
+      av1_inv_txfm2d_add_16x16_c(src, CONVERT_TO_SHORTPTR(dest), stride,
+                                 tx_type, bd);
       break;
 #endif  // CONFIG_EXT_TX
-    default: assert(0); break;
+    default: assert(0);
   }
 }
 
-static void highbd_inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest,
-                                      int stride, int eob, int bd,
-                                      TX_TYPE tx_type) {
-  (void)eob;
+static void highbd_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest,
+                                      int stride, const INV_TXFM_PARAM *param) {
+  int bd = param->bd;
+  TX_TYPE tx_type = param->tx_type;
+  const int32_t *src = (const int32_t *)input;
   switch (tx_type) {
     case DCT_DCT:
     case ADST_DCT:
     case DCT_ADST:
     case ADST_ADST:
+      av1_inv_txfm2d_add_32x32(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type,
+                               bd);
+      break;
 #if CONFIG_EXT_TX
     case FLIPADST_DCT:
     case DCT_FLIPADST:
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
     case FLIPADST_ADST:
-#endif  // CONFIG_EXT_TX
-      av1_inv_txfm2d_add_16x16(input, CONVERT_TO_SHORTPTR(dest), stride,
-                               tx_type, bd);
+      av1_inv_txfm2d_add_32x32(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type,
+                               bd);
       break;
-#if CONFIG_EXT_TX
+    // use the c version for anything including identity for now
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
     case H_FLIPADST:
-      // Use C version since DST only exists in C code
-      av1_highbd_iht16x16_256_add_c(input, dest, stride, tx_type, bd);
-      break;
     case IDTX:
-      highbd_inv_idtx_add_c(input, dest, stride, 16, tx_type, bd);
+      av1_inv_txfm2d_add_32x32_c(src, CONVERT_TO_SHORTPTR(dest), stride,
+                                 tx_type, bd);
       break;
 #endif  // CONFIG_EXT_TX
-    default: assert(0); break;
+    default: assert(0);
   }
 }
 
-static void highbd_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest,
-                                      int stride, int eob, int bd,
-                                      TX_TYPE tx_type) {
-  (void)eob;
+#if CONFIG_TX64X64
+static void highbd_inv_txfm_add_64x64(const tran_low_t *input, uint8_t *dest,
+                                      int stride, const INV_TXFM_PARAM *param) {
+  int bd = param->bd;
+  TX_TYPE tx_type = param->tx_type;
+  const int32_t *src = (const int32_t *)input;
   switch (tx_type) {
     case DCT_DCT:
-      av1_inv_txfm2d_add_32x32(input, CONVERT_TO_SHORTPTR(dest), stride,
-                               DCT_DCT, bd);
+      av1_inv_txfm2d_add_64x64(src, CONVERT_TO_SHORTPTR(dest), stride, DCT_DCT,
+                               bd);
       break;
 #if CONFIG_EXT_TX
     case ADST_DCT:
     case DCT_ADST:
     case ADST_ADST:
     case FLIPADST_DCT:
     case DCT_FLIPADST:
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
     case FLIPADST_ADST:
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
     case H_FLIPADST:
-      highbd_iht32x32_1024_add_c(input, dest, stride, tx_type, bd);
-      break;
-    case IDTX:
-      highbd_inv_idtx_add_c(input, dest, stride, 32, tx_type, bd);
-      break;
-#endif  // CONFIG_EXT_TX
-    default: assert(0); break;
-  }
-}
-
-#if CONFIG_TX64X64
-static void highbd_inv_txfm_add_64x64(const tran_low_t *input, uint8_t *dest,
-                                      int stride, int eob, int bd,
-                                      TX_TYPE tx_type) {
-  (void)eob;
-  switch (tx_type) {
-    case DCT_DCT:
-      av1_inv_txfm2d_add_64x64(input, CONVERT_TO_SHORTPTR(dest), stride,
-                               DCT_DCT, bd);
-      break;
-#if CONFIG_EXT_TX
-    case ADST_DCT:
-    case DCT_ADST:
-    case ADST_ADST:
-    case FLIPADST_DCT:
-    case DCT_FLIPADST:
-    case FLIPADST_FLIPADST:
-    case ADST_FLIPADST:
-    case FLIPADST_ADST:
-    case V_DCT:
-    case H_DCT:
-    case V_ADST:
-    case H_ADST:
-    case V_FLIPADST:
-    case H_FLIPADST:
-      highbd_iht64x64_4096_add_c(input, dest, stride, tx_type, bd);
+      // TODO(sarahparker)
+      // I've deleted the 64x64 implementations that existed in lieu
+      // of adst, flipadst and identity for simplicity but will bring back
+      // in a later change. This shouldn't impact performance since
+      // DCT_DCT is the only extended type currently allowed for 64x64,
+      // as dictated by get_ext_tx_set_type in blockd.h.
+      av1_inv_txfm2d_add_64x64_c(src, CONVERT_TO_SHORTPTR(dest), stride,
+                                 DCT_DCT, bd);
       break;
     case IDTX:
       highbd_inv_idtx_add_c(input, dest, stride, 64, tx_type, bd);
       break;
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
   }
 }
 #endif  // CONFIG_TX64X64
-#endif  // CONFIG_HIGHBITDEPTH
 
 void av1_inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride,
                       INV_TXFM_PARAM *param) {
-  const TX_TYPE tx_type = param->tx_type;
   const TX_SIZE tx_size = param->tx_size;
-  const int eob = param->eob;
-  const int lossless = param->lossless;
-
   switch (tx_size) {
 #if CONFIG_TX64X64
     case TX_64X64: inv_txfm_add_64x64(input, dest, stride, param); break;
 #endif  // CONFIG_TX64X64
     case TX_32X32: inv_txfm_add_32x32(input, dest, stride, param); break;
     case TX_16X16: inv_txfm_add_16x16(input, dest, stride, param); break;
     case TX_8X8: inv_txfm_add_8x8(input, dest, stride, param); break;
-    case TX_4X8: inv_txfm_add_4x8(input, dest, stride, eob, tx_type); break;
-    case TX_8X4: inv_txfm_add_8x4(input, dest, stride, eob, tx_type); break;
-    case TX_8X16: inv_txfm_add_8x16(input, dest, stride, eob, tx_type); break;
-    case TX_16X8: inv_txfm_add_16x8(input, dest, stride, eob, tx_type); break;
-    case TX_16X32: inv_txfm_add_16x32(input, dest, stride, eob, tx_type); break;
-    case TX_32X16: inv_txfm_add_32x16(input, dest, stride, eob, tx_type); break;
+    case TX_4X8: inv_txfm_add_4x8(input, dest, stride, param); break;
+    case TX_8X4: inv_txfm_add_8x4(input, dest, stride, param); break;
+    case TX_8X16: inv_txfm_add_8x16(input, dest, stride, param); break;
+    case TX_16X8: inv_txfm_add_16x8(input, dest, stride, param); break;
+    case TX_16X32: inv_txfm_add_16x32(input, dest, stride, param); break;
+    case TX_32X16: inv_txfm_add_32x16(input, dest, stride, param); break;
     case TX_4X4:
       // this is like av1_short_idct4x4 but has a special case around eob<=1
       // which is significant (not just an optimization) for the lossless
       // case.
-      inv_txfm_add_4x4(input, dest, stride, eob, tx_type, lossless);
+      inv_txfm_add_4x4(input, dest, stride, param);
       break;
 #if CONFIG_CHROMA_2X2
-    case TX_2X2:
-      inv_txfm_add_2x2(input, dest, stride, eob, tx_type, lossless);
-      break;
+    case TX_2X2: inv_txfm_add_2x2(input, dest, stride, param); break;
 #endif
 #if CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
-    case TX_32X8: inv_txfm_add_32x8(input, dest, stride, eob, tx_type); break;
-    case TX_8X32: inv_txfm_add_8x32(input, dest, stride, eob, tx_type); break;
-    case TX_16X4: inv_txfm_add_16x4(input, dest, stride, eob, tx_type); break;
-    case TX_4X16: inv_txfm_add_4x16(input, dest, stride, eob, tx_type); break;
+    case TX_32X8: inv_txfm_add_32x8(input, dest, stride, param); break;
+    case TX_8X32: inv_txfm_add_8x32(input, dest, stride, param); break;
+    case TX_16X4: inv_txfm_add_16x4(input, dest, stride, param); break;
+    case TX_4X16: inv_txfm_add_4x16(input, dest, stride, param); break;
 #endif
     default: assert(0 && "Invalid transform size"); break;
   }
 }
 
 static void init_inv_txfm_param(const MACROBLOCKD *xd, TX_SIZE tx_size,
                                 TX_TYPE tx_type, int eob, INV_TXFM_PARAM *inv) {
   inv->tx_type = tx_type;
   inv->tx_size = tx_size;
   inv->eob = eob;
   inv->lossless = xd->lossless[xd->mi[0]->mbmi.segment_id];
 #if CONFIG_HIGHBITDEPTH
   inv->bd = xd->bd;
 #endif
+#if CONFIG_LGT
+  inv->is_inter = is_inter_block(&xd->mi[0]->mbmi);
+#endif
 #if CONFIG_ADAPT_SCAN
   inv->eob_threshold =
       (const int16_t *)&xd->eob_threshold_md[tx_size][tx_type][0];
 #endif
 }
 
+typedef void (*InvTxfmFunc)(const tran_low_t *dqcoeff, uint8_t *dst, int stride,
+                            INV_TXFM_PARAM *param);
+
+static InvTxfmFunc inv_txfm_func[2] = { av1_inv_txfm_add,
+                                        av1_highbd_inv_txfm_add };
+
+// TODO(kslu) Change input arguments to INV_TXFM_PARAM, which contains mode,
+// tx_type, tx_size, dst, stride, eob. Thus, the additional argument when LGT
+// is on will no longer be needed.
 void av1_inverse_transform_block(const MACROBLOCKD *xd,
-                                 const tran_low_t *dqcoeff, TX_TYPE tx_type,
-                                 TX_SIZE tx_size, uint8_t *dst, int stride,
-                                 int eob) {
+                                 const tran_low_t *dqcoeff,
+#if CONFIG_LGT
+                                 PREDICTION_MODE mode,
+#endif
+                                 TX_TYPE tx_type, TX_SIZE tx_size, uint8_t *dst,
+                                 int stride, int eob) {
   if (!eob) return;
 #if CONFIG_PVQ
   const BLOCK_SIZE tx_bsize = txsize_to_bsize[tx_size];
   const int txb_width = block_size_wide[tx_bsize];
   const int txb_height = block_size_high[tx_bsize];
   int r, c;
 #if CONFIG_HIGHBITDEPTH
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
@@ -2828,100 +2010,74 @@ void av1_inverse_transform_block(const M
     for (r = 0; r < txb_height; r++)
       for (c = 0; c < txb_width; c++) dst[r * stride + c] = 0;
 #if CONFIG_HIGHBITDEPTH
   }
 #endif  // CONFIG_HIGHBITDEPTH
 #endif  // CONFIG_PVQ
   INV_TXFM_PARAM inv_txfm_param;
   init_inv_txfm_param(xd, tx_size, tx_type, eob, &inv_txfm_param);
+#if CONFIG_LGT
+  inv_txfm_param.dst = dst;
+  inv_txfm_param.mode = mode;
+  inv_txfm_param.stride = stride;
+#endif
 
-#if CONFIG_HIGHBITDEPTH
-  if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-    av1_highbd_inv_txfm_add(dqcoeff, dst, stride, &inv_txfm_param);
-  } else {
-#endif  // CONFIG_HIGHBITDEPTH
-    av1_inv_txfm_add(dqcoeff, dst, stride, &inv_txfm_param);
-#if CONFIG_HIGHBITDEPTH
-  }
-#endif  // CONFIG_HIGHBITDEPTH
+  const int is_hbd = get_bitdepth_data_path_index(xd);
+  inv_txfm_func[is_hbd](dqcoeff, dst, stride, &inv_txfm_param);
 }
 
 void av1_inverse_transform_block_facade(MACROBLOCKD *xd, int plane, int block,
                                         int blk_row, int blk_col, int eob) {
   struct macroblockd_plane *const pd = &xd->plane[plane];
   tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
   const PLANE_TYPE plane_type = get_plane_type(plane);
   const TX_SIZE tx_size = get_tx_size(plane, xd);
   const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
   const int dst_stride = pd->dst.stride;
   uint8_t *dst =
       &pd->dst.buf[(blk_row * dst_stride + blk_col) << tx_size_wide_log2[0]];
+#if CONFIG_LGT
+  PREDICTION_MODE mode = get_prediction_mode(xd->mi[0], plane, tx_size, block);
+  av1_inverse_transform_block(xd, dqcoeff, mode, tx_type, tx_size, dst,
+                              dst_stride, eob);
+#else
   av1_inverse_transform_block(xd, dqcoeff, tx_type, tx_size, dst, dst_stride,
                               eob);
+#endif  // CONFIG_LGT
 }
 
-#if CONFIG_HIGHBITDEPTH
 void av1_highbd_inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride,
-                             INV_TXFM_PARAM *inv_txfm_param) {
-  const TX_TYPE tx_type = inv_txfm_param->tx_type;
-  const TX_SIZE tx_size = inv_txfm_param->tx_size;
-  const int eob = inv_txfm_param->eob;
-  const int bd = inv_txfm_param->bd;
-  const int lossless = inv_txfm_param->lossless;
-
+                             INV_TXFM_PARAM *param) {
+  const TX_SIZE tx_size = param->tx_size;
   switch (tx_size) {
 #if CONFIG_TX64X64
-    case TX_64X64:
-      highbd_inv_txfm_add_64x64(input, dest, stride, eob, bd, tx_type);
-      break;
+    case TX_64X64: highbd_inv_txfm_add_64x64(input, dest, stride, param); break;
 #endif  // CONFIG_TX64X64
-    case TX_32X32:
-      highbd_inv_txfm_add_32x32(input, dest, stride, eob, bd, tx_type);
-      break;
-    case TX_16X16:
-      highbd_inv_txfm_add_16x16(input, dest, stride, eob, bd, tx_type);
-      break;
-    case TX_8X8:
-      highbd_inv_txfm_add_8x8(input, dest, stride, eob, bd, tx_type);
-      break;
-    case TX_4X8:
-      av1_highbd_inv_txfm_add_4x8(input, dest, stride, eob, bd, tx_type);
-      break;
-    case TX_8X4:
-      av1_highbd_inv_txfm_add_8x4(input, dest, stride, eob, bd, tx_type);
-      break;
-    case TX_8X16:
-      highbd_inv_txfm_add_8x16(input, dest, stride, eob, bd, tx_type);
-      break;
-    case TX_16X8:
-      highbd_inv_txfm_add_16x8(input, dest, stride, eob, bd, tx_type);
-      break;
-    case TX_16X32:
-      highbd_inv_txfm_add_16x32(input, dest, stride, eob, bd, tx_type);
-      break;
-    case TX_32X16:
-      highbd_inv_txfm_add_32x16(input, dest, stride, eob, bd, tx_type);
-      break;
+    case TX_32X32: highbd_inv_txfm_add_32x32(input, dest, stride, param); break;
+    case TX_16X16: highbd_inv_txfm_add_16x16(input, dest, stride, param); break;
+    case TX_8X8: highbd_inv_txfm_add_8x8(input, dest, stride, param); break;
+    case TX_4X8: av1_highbd_inv_txfm_add_4x8(input, dest, stride, param); break;
+    case TX_8X4: av1_highbd_inv_txfm_add_8x4(input, dest, stride, param); break;
+    case TX_8X16: highbd_inv_txfm_add_8x16(input, dest, stride, param); break;
+    case TX_16X8: highbd_inv_txfm_add_16x8(input, dest, stride, param); break;
+    case TX_16X32: highbd_inv_txfm_add_16x32(input, dest, stride, param); break;
+    case TX_32X16: highbd_inv_txfm_add_32x16(input, dest, stride, param); break;
     case TX_4X4:
       // this is like av1_short_idct4x4 but has a special case around eob<=1
       // which is significant (not just an optimization) for the lossless
       // case.
-      av1_highbd_inv_txfm_add_4x4(input, dest, stride, eob, bd, tx_type,
-                                  lossless);
+      av1_highbd_inv_txfm_add_4x4(input, dest, stride, param);
       break;
 #if CONFIG_CHROMA_2X2
-    case TX_2X2:
-      highbd_inv_txfm_add_2x2(input, dest, stride, eob, bd, tx_type, lossless);
-      break;
+    case TX_2X2: highbd_inv_txfm_add_2x2(input, dest, stride, param); break;
 #endif
     default: assert(0 && "Invalid transform size"); break;
   }
 }
-#endif  // CONFIG_HIGHBITDEPTH
 
 #if CONFIG_DPCM_INTRA
 void av1_dpcm_inv_txfm_add_4_c(const tran_low_t *input, int stride,
                                TX_TYPE_1D tx_type, uint8_t *dest) {
   assert(tx_type < TX_TYPES_1D);
   static const transform_1d IHT[] = { aom_idct4_c, aom_iadst4_c, aom_iadst4_c,
                                       iidtx4_c };
   const transform_1d inv_tx = IHT[tx_type];
@@ -2985,78 +2141,114 @@ dpcm_inv_txfm_add_func av1_get_dpcm_inv_
     case 32:
       return av1_dpcm_inv_txfm_add_32_c;
     // TODO(huisu): add support for TX_64X64.
     default: assert(0); return NULL;
   }
 }
 
 #if CONFIG_HIGHBITDEPTH
+// TODO(sarahparker) I am adding a quick workaround for these functions
+// to remove the old hbd transforms. This will be cleaned up in a followup.
 void av1_hbd_dpcm_inv_txfm_add_4_c(const tran_low_t *input, int stride,
-                                   TX_TYPE_1D tx_type, int bd, uint16_t *dest) {
+                                   TX_TYPE_1D tx_type, int bd, uint16_t *dest,
+                                   int dir) {
   assert(tx_type < TX_TYPES_1D);
-  static const highbd_transform_1d IHT[] = { aom_highbd_idct4_c,
-                                             aom_highbd_iadst4_c,
-                                             aom_highbd_iadst4_c,
-                                             highbd_iidtx4_c };
-  const highbd_transform_1d inv_tx = IHT[tx_type];
+  static const TxfmFunc IHT[] = { av1_idct4_new, av1_iadst4_new, av1_iadst4_new,
+                                  av1_iidentity4_c };
+  // In order { horizontal, vertical }
+  static const TXFM_1D_CFG *inv_txfm_cfg_ls[TX_TYPES_1D][2] = {
+    { &inv_txfm_1d_row_cfg_dct_4, &inv_txfm_1d_col_cfg_dct_4 },
+    { &inv_txfm_1d_row_cfg_adst_4, &inv_txfm_1d_col_cfg_adst_4 },
+    { &inv_txfm_1d_row_cfg_adst_4, &inv_txfm_1d_col_cfg_adst_4 },
+    { &inv_txfm_1d_cfg_identity_4, &inv_txfm_1d_cfg_identity_4 }
+  };
+
+  const TXFM_1D_CFG *inv_txfm_cfg = inv_txfm_cfg_ls[tx_type][dir];
+  const TxfmFunc inv_tx = IHT[tx_type];
+
   tran_low_t out[4];
-  inv_tx(input, out, bd);
+  inv_tx(input, out, inv_txfm_cfg->cos_bit, inv_txfm_cfg->stage_range);
   for (int i = 0; i < 4; ++i) {
     out[i] = (tran_low_t)dct_const_round_shift(out[i] * Sqrt2);
     dest[i * stride] = highbd_clip_pixel_add(dest[i * stride],
                                              ROUND_POWER_OF_TWO(out[i], 4), bd);
   }
 }
 
 void av1_hbd_dpcm_inv_txfm_add_8_c(const tran_low_t *input, int stride,
-                                   TX_TYPE_1D tx_type, int bd, uint16_t *dest) {
-  static const highbd_transform_1d IHT[] = { aom_highbd_idct8_c,
-                                             aom_highbd_iadst8_c,
-                                             aom_highbd_iadst8_c,
-                                             highbd_iidtx8_c };
+                                   TX_TYPE_1D tx_type, int bd, uint16_t *dest,
+                                   int dir) {
   assert(tx_type < TX_TYPES_1D);
-  const highbd_transform_1d inv_tx = IHT[tx_type];
+  static const TxfmFunc IHT[] = { av1_idct4_new, av1_iadst4_new, av1_iadst4_new,
+                                  av1_iidentity4_c };
+  // In order { horizontal, vertical }
+  static const TXFM_1D_CFG *inv_txfm_cfg_ls[TX_TYPES_1D][2] = {
+    { &inv_txfm_1d_row_cfg_dct_8, &inv_txfm_1d_col_cfg_dct_8 },
+    { &inv_txfm_1d_row_cfg_adst_8, &inv_txfm_1d_col_cfg_adst_8 },
+    { &inv_txfm_1d_row_cfg_adst_8, &inv_txfm_1d_col_cfg_adst_8 },
+    { &inv_txfm_1d_cfg_identity_8, &inv_txfm_1d_cfg_identity_8 }
+  };
+
+  const TXFM_1D_CFG *inv_txfm_cfg = inv_txfm_cfg_ls[tx_type][dir];
+  const TxfmFunc inv_tx = IHT[tx_type];
+
   tran_low_t out[8];
-  inv_tx(input, out, bd);
+  inv_tx(input, out, inv_txfm_cfg->cos_bit, inv_txfm_cfg->stage_range);
   for (int i = 0; i < 8; ++i) {
     dest[i * stride] = highbd_clip_pixel_add(dest[i * stride],
                                              ROUND_POWER_OF_TWO(out[i], 4), bd);
   }
 }
 
 void av1_hbd_dpcm_inv_txfm_add_16_c(const tran_low_t *input, int stride,
-                                    TX_TYPE_1D tx_type, int bd,
-                                    uint16_t *dest) {
+                                    TX_TYPE_1D tx_type, int bd, uint16_t *dest,
+                                    int dir) {
   assert(tx_type < TX_TYPES_1D);
-  static const highbd_transform_1d IHT[] = { aom_highbd_idct16_c,
-                                             aom_highbd_iadst16_c,
-                                             aom_highbd_iadst16_c,
-                                             highbd_iidtx16_c };
-  const highbd_transform_1d inv_tx = IHT[tx_type];
+  static const TxfmFunc IHT[] = { av1_idct4_new, av1_iadst4_new, av1_iadst4_new,
+                                  av1_iidentity4_c };
+  // In order { horizontal, vertical }
+  static const TXFM_1D_CFG *inv_txfm_cfg_ls[TX_TYPES_1D][2] = {
+    { &inv_txfm_1d_row_cfg_dct_16, &inv_txfm_1d_col_cfg_dct_16 },
+    { &inv_txfm_1d_row_cfg_adst_16, &inv_txfm_1d_col_cfg_adst_16 },
+    { &inv_txfm_1d_row_cfg_adst_16, &inv_txfm_1d_col_cfg_adst_16 },
+    { &inv_txfm_1d_cfg_identity_16, &inv_txfm_1d_cfg_identity_16 }
+  };
+
+  const TXFM_1D_CFG *inv_txfm_cfg = inv_txfm_cfg_ls[tx_type][dir];
+  const TxfmFunc inv_tx = IHT[tx_type];
+
   tran_low_t out[16];
-  inv_tx(input, out, bd);
+  inv_tx(input, out, inv_txfm_cfg->cos_bit, inv_txfm_cfg->stage_range);
   for (int i = 0; i < 16; ++i) {
     out[i] = (tran_low_t)dct_const_round_shift(out[i] * Sqrt2);
     dest[i * stride] = highbd_clip_pixel_add(dest[i * stride],
                                              ROUND_POWER_OF_TWO(out[i], 5), bd);
   }
 }
 
 void av1_hbd_dpcm_inv_txfm_add_32_c(const tran_low_t *input, int stride,
-                                    TX_TYPE_1D tx_type, int bd,
-                                    uint16_t *dest) {
+                                    TX_TYPE_1D tx_type, int bd, uint16_t *dest,
+                                    int dir) {
   assert(tx_type < TX_TYPES_1D);
-  static const highbd_transform_1d IHT[] = { aom_highbd_idct32_c,
-                                             highbd_ihalfright32_c,
-                                             highbd_ihalfright32_c,
-                                             highbd_iidtx32_c };
-  const highbd_transform_1d inv_tx = IHT[tx_type];
+  static const TxfmFunc IHT[] = { av1_idct4_new, av1_iadst4_new, av1_iadst4_new,
+                                  av1_iidentity4_c };
+  // In order { horizontal, vertical }
+  static const TXFM_1D_CFG *inv_txfm_cfg_ls[TX_TYPES_1D][2] = {
+    { &inv_txfm_1d_row_cfg_dct_32, &inv_txfm_1d_col_cfg_dct_32 },
+    { &inv_txfm_1d_row_cfg_adst_32, &inv_txfm_1d_col_cfg_adst_32 },
+    { &inv_txfm_1d_row_cfg_adst_32, &inv_txfm_1d_col_cfg_adst_32 },
+    { &inv_txfm_1d_cfg_identity_32, &inv_txfm_1d_cfg_identity_32 }
+  };
+
+  const TXFM_1D_CFG *inv_txfm_cfg = inv_txfm_cfg_ls[tx_type][dir];
+  const TxfmFunc inv_tx = IHT[tx_type];
+
   tran_low_t out[32];
-  inv_tx(input, out, bd);
+  inv_tx(input, out, inv_txfm_cfg->cos_bit, inv_txfm_cfg->stage_range);
   for (int i = 0; i < 32; ++i) {
     dest[i * stride] = highbd_clip_pixel_add(dest[i * stride],
                                              ROUND_POWER_OF_TWO(out[i], 4), bd);
   }
 }
 
 hbd_dpcm_inv_txfm_add_func av1_get_hbd_dpcm_inv_txfm_add_func(int tx_length) {
   switch (tx_length) {
--- a/third_party/aom/av1/common/idct.h
+++ b/third_party/aom/av1/common/idct.h
@@ -21,26 +21,45 @@
 #include "aom_dsp/inv_txfm.h"
 #include "aom_dsp/txfm_common.h"
 #include "aom_ports/mem.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-typedef struct INV_TXFM_PARAM {
+// TODO(kslu) Combine FWD_TXFM_PARAM and INV_TXFM_PARAM into a common struct.
+// and move the common stuff in idct.h to av1_txfm.h or txfm_common.h
+typedef struct fwd_txfm_param {
+  TX_TYPE tx_type;
+  TX_SIZE tx_size;
+  int lossless;
+  int bd;
+#if CONFIG_LGT
+  int is_inter;
+  int stride;
+  PREDICTION_MODE mode;
+  uint8_t *dst;
+#endif
+} FWD_TXFM_PARAM;
+
+typedef struct inv_txfm_param {
 #if CONFIG_ADAPT_SCAN
   const int16_t *eob_threshold;
 #endif
   TX_TYPE tx_type;
   TX_SIZE tx_size;
   int eob;
   int lossless;
-#if CONFIG_HIGHBITDEPTH
   int bd;
+#if CONFIG_LGT
+  int is_inter;
+  int stride;
+  PREDICTION_MODE mode;
+  uint8_t *dst;
 #endif
 } INV_TXFM_PARAM;
 
 typedef void (*transform_1d)(const tran_low_t *, tran_low_t *);
 
 typedef struct {
   transform_1d cols, rows;  // vertical and horizontal
 } transform_2d;
@@ -59,60 +78,64 @@ int av1_get_tx_scale(const TX_SIZE tx_si
 void av1_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
                      int eob);
 void av1_idct4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
                      int eob);
 
 void av1_inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride,
                       INV_TXFM_PARAM *inv_txfm_param);
 void av1_inverse_transform_block(const MACROBLOCKD *xd,
-                                 const tran_low_t *dqcoeff, TX_TYPE tx_type,
-                                 TX_SIZE tx_size, uint8_t *dst, int stride,
-                                 int eob);
+                                 const tran_low_t *dqcoeff,
+#if CONFIG_LGT
+                                 PREDICTION_MODE mode,
+#endif
+                                 TX_TYPE tx_type, TX_SIZE tx_size, uint8_t *dst,
+                                 int stride, int eob);
 void av1_inverse_transform_block_facade(MACROBLOCKD *xd, int plane, int block,
                                         int blk_row, int blk_col, int eob);
-#if CONFIG_HIGHBITDEPTH
+
 void av1_highbd_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
                             int eob, int bd);
-void av1_highbd_idct4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
-                            int eob, int bd);
 void av1_highbd_inv_txfm_add_4x4(const tran_low_t *input, uint8_t *dest,
-                                 int stride, int eob, int bd, TX_TYPE tx_type,
-                                 int lossless);
+                                 int stride, const INV_TXFM_PARAM *param);
 void av1_highbd_inv_txfm_add_4x8(const tran_low_t *input, uint8_t *dest,
-                                 int stride, int eob, int bd, TX_TYPE tx_type);
+                                 int stride, const INV_TXFM_PARAM *param);
 void av1_highbd_inv_txfm_add_8x4(const tran_low_t *input, uint8_t *dest,
-                                 int stride, int eob, int bd, TX_TYPE tx_type);
+                                 int stride, const INV_TXFM_PARAM *param);
 void av1_highbd_inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride,
                              INV_TXFM_PARAM *inv_txfm_param);
-#endif  // CONFIG_HIGHBITDEPTH
+
 #if CONFIG_DPCM_INTRA
 void av1_dpcm_inv_txfm_add_4_c(const tran_low_t *input, int stride,
                                TX_TYPE_1D tx_type, uint8_t *dest);
 void av1_dpcm_inv_txfm_add_8_c(const tran_low_t *input, int stride,
                                TX_TYPE_1D tx_type, uint8_t *dest);
 void av1_dpcm_inv_txfm_add_16_c(const tran_low_t *input, int stride,
                                 TX_TYPE_1D tx_type, uint8_t *dest);
 void av1_dpcm_inv_txfm_add_32_c(const tran_low_t *input, int stride,
                                 TX_TYPE_1D tx_type, uint8_t *dest);
 typedef void (*dpcm_inv_txfm_add_func)(const tran_low_t *input, int stride,
                                        TX_TYPE_1D tx_type, uint8_t *dest);
 dpcm_inv_txfm_add_func av1_get_dpcm_inv_txfm_add_func(int tx_length);
 #if CONFIG_HIGHBITDEPTH
 void av1_hbd_dpcm_inv_txfm_add_4_c(const tran_low_t *input, int stride,
-                                   TX_TYPE_1D tx_type, int bd, uint16_t *dest);
+                                   TX_TYPE_1D tx_type, int bd, uint16_t *dest,
+                                   int dir);
 void av1_hbd_dpcm_inv_txfm_add_8_c(const tran_low_t *input, int stride,
-                                   TX_TYPE_1D tx_type, int bd, uint16_t *dest);
+                                   TX_TYPE_1D tx_type, int bd, uint16_t *dest,
+                                   int dir);
 void av1_hbd_dpcm_inv_txfm_add_16_c(const tran_low_t *input, int stride,
-                                    TX_TYPE_1D tx_type, int bd, uint16_t *dest);
+                                    TX_TYPE_1D tx_type, int bd, uint16_t *dest,
+                                    int dir);
 void av1_hbd_dpcm_inv_txfm_add_32_c(const tran_low_t *input, int stride,
-                                    TX_TYPE_1D tx_type, int bd, uint16_t *dest);
+                                    TX_TYPE_1D tx_type, int bd, uint16_t *dest,
+                                    int dir);
 typedef void (*hbd_dpcm_inv_txfm_add_func)(const tran_low_t *input, int stride,
                                            TX_TYPE_1D tx_type, int bd,
-                                           uint16_t *dest);
+                                           uint16_t *dest, int dir);
 hbd_dpcm_inv_txfm_add_func av1_get_hbd_dpcm_inv_txfm_add_func(int tx_length);
 #endif  // CONFIG_HIGHBITDEPTH
 #endif  // CONFIG_DPCM_INTRA
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
 #endif  // AV1_COMMON_IDCT_H_
--- a/third_party/aom/av1/common/mips/dspr2/av1_itrans16_dspr2.c
+++ b/third_party/aom/av1/common/mips/dspr2/av1_itrans16_dspr2.c
@@ -18,22 +18,23 @@
 #include "av1/common/blockd.h"
 #include "av1/common/idct.h"
 #include "aom_dsp/mips/inv_txfm_dspr2.h"
 #include "aom_dsp/txfm_common.h"
 #include "aom_ports/mem.h"
 
 #if HAVE_DSPR2
 void av1_iht16x16_256_add_dspr2(const int16_t *input, uint8_t *dest, int pitch,
-                                int tx_type) {
+                                FWD_TXFM_PARAM *param) {
   int i, j;
   DECLARE_ALIGNED(32, int16_t, out[16 * 16]);
   int16_t *outptr = out;
   int16_t temp_out[16];
   uint32_t pos = 45;
+  int tx_type = param->tx_type;
 
   /* bit positon for extract from acc */
   __asm__ __volatile__("wrdsp    %[pos],    1    \n\t" : : [pos] "r"(pos));
 
   switch (tx_type) {
     case DCT_DCT:  // DCT in both horizontal and vertical
       idct16_rows_dspr2(input, outptr, 16);
       idct16_cols_add_blk_dspr2(out, dest, pitch);
--- a/third_party/aom/av1/common/mips/dspr2/av1_itrans4_dspr2.c
+++ b/third_party/aom/av1/common/mips/dspr2/av1_itrans4_dspr2.c
@@ -18,22 +18,23 @@
 #include "av1/common/blockd.h"
 #include "av1/common/idct.h"
 #include "aom_dsp/mips/inv_txfm_dspr2.h"
 #include "aom_dsp/txfm_common.h"
 #include "aom_ports/mem.h"
 
 #if HAVE_DSPR2
 void av1_iht4x4_16_add_dspr2(const int16_t *input, uint8_t *dest,
-                             int dest_stride, int tx_type) {
+                             int dest_stride, FWD_TXFM_PARAM *param) {
   int i, j;
   DECLARE_ALIGNED(32, int16_t, out[4 * 4]);
   int16_t *outptr = out;
   int16_t temp_in[4 * 4], temp_out[4];
   uint32_t pos = 45;
+  int tx_type = param->tx_type;
 
   /* bit positon for extract from acc */
   __asm__ __volatile__("wrdsp      %[pos],     1           \n\t"
                        :
                        : [pos] "r"(pos));
 
   switch (tx_type) {
     case DCT_DCT:  // DCT in both horizontal and vertical
--- a/third_party/aom/av1/common/mips/dspr2/av1_itrans8_dspr2.c
+++ b/third_party/aom/av1/common/mips/dspr2/av1_itrans8_dspr2.c
@@ -11,28 +11,30 @@
 
 #include <assert.h>
 #include <stdio.h>
 
 #include "./aom_config.h"
 #include "./av1_rtcd.h"
 #include "av1/common/common.h"
 #include "av1/common/blockd.h"
+#include "av1/common/idct.h"
 #include "aom_dsp/mips/inv_txfm_dspr2.h"
 #include "aom_dsp/txfm_common.h"
 #include "aom_ports/mem.h"
 
 #if HAVE_DSPR2
 void av1_iht8x8_64_add_dspr2(const int16_t *input, uint8_t *dest,
-                             int dest_stride, int tx_type) {
+                             int dest_stride, FWD_TXFM_PARAM *param) {
   int i, j;
   DECLARE_ALIGNED(32, int16_t, out[8 * 8]);
   int16_t *outptr = out;
   int16_t temp_in[8 * 8], temp_out[8];
   uint32_t pos = 45;
+  int tx_type = param->tx_type;
 
   /* bit positon for extract from acc */
   __asm__ __volatile__("wrdsp    %[pos],    1    \n\t" : : [pos] "r"(pos));
 
   switch (tx_type) {
     case DCT_DCT:  // DCT in both horizontal and vertical
       idct8_rows_dspr2(input, outptr, 8);
       idct8_columns_add_blk_dspr2(&out[0], dest, dest_stride);
--- a/third_party/aom/av1/common/mips/msa/av1_idct16x16_msa.c
+++ b/third_party/aom/av1/common/mips/msa/av1_idct16x16_msa.c
@@ -7,23 +7,25 @@
  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #include <assert.h>
 
 #include "av1/common/enums.h"
+#include "av1/common/idct.h"
 #include "aom_dsp/mips/inv_txfm_msa.h"
 
 void av1_iht16x16_256_add_msa(const int16_t *input, uint8_t *dst,
-                              int32_t dst_stride, int32_t tx_type) {
+                              int32_t dst_stride, FWD_TXFM_PARAM *param) {
   int32_t i;
   DECLARE_ALIGNED(32, int16_t, out[16 * 16]);
   int16_t *out_ptr = &out[0];
+  int32_t tx_type = param->tx_type;
 
   switch (tx_type) {
     case DCT_DCT:
       /* transform rows */
       for (i = 0; i < 2; ++i) {
         /* process 16 * 8 block */
         aom_idct16_1d_rows_msa((input + (i << 7)), (out_ptr + (i << 7)));
       }
--- a/third_party/aom/av1/common/mips/msa/av1_idct4x4_msa.c
+++ b/third_party/aom/av1/common/mips/msa/av1_idct4x4_msa.c
@@ -7,21 +7,23 @@
  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #include <assert.h>
 
 #include "av1/common/enums.h"
+#include "av1/common/idct.h"
 #include "aom_dsp/mips/inv_txfm_msa.h"
 
 void av1_iht4x4_16_add_msa(const int16_t *input, uint8_t *dst,
-                           int32_t dst_stride, int32_t tx_type) {
+                           int32_t dst_stride, FWD_TXFM_PARAM *param) {
   v8i16 in0, in1, in2, in3;
+  int32_t tx_type = param->tx_type;
 
   /* load vector elements of 4x4 block */
   LD4x4_SH(input, in0, in1, in2, in3);
   TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3);
 
   switch (tx_type) {
     case DCT_DCT:
       /* DCT in horizontal */
--- a/third_party/aom/av1/common/mips/msa/av1_idct8x8_msa.c
+++ b/third_party/aom/av1/common/mips/msa/av1_idct8x8_msa.c
@@ -7,21 +7,23 @@
  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #include <assert.h>
 
 #include "av1/common/enums.h"
+#include "av1/common/idct.h"
 #include "aom_dsp/mips/inv_txfm_msa.h"
 
 void av1_iht8x8_64_add_msa(const int16_t *input, uint8_t *dst,
-                           int32_t dst_stride, int32_t tx_type) {
+                           int32_t dst_stride, FWD_TXFM_PARAM *param) {
   v8i16 in0, in1, in2, in3, in4, in5, in6, in7;
+  int32_t tx_type = param->tx_type;
 
   /* load vector elements of 8x8 block */
   LD_SH8(input, 8, in0, in1, in2, in3, in4, in5, in6, in7);
 
   TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3,
                      in4, in5, in6, in7);
 
   switch (tx_type) {
--- a/third_party/aom/av1/common/mv.h
+++ b/third_party/aom/av1/common/mv.h
@@ -39,19 +39,18 @@ typedef struct mv32 {
 #define SEPARATE_GLOBAL_MOTION 1
 #endif  // (CONFIG_WARPED_MOTION || CONFIG_MOTION_VAR) && CONFIG_GLOBAL_MOTION
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 // Bits of precision used for the model
 #define WARPEDMODEL_PREC_BITS 16
 #define WARPEDMODEL_ROW3HOMO_PREC_BITS 16
 
 #define WARPEDMODEL_TRANS_CLAMP (128 << WARPEDMODEL_PREC_BITS)
-#define WARPEDMODEL_DIAGAFFINE_CLAMP (1 << (WARPEDMODEL_PREC_BITS + 1))
-#define WARPEDMODEL_NONDIAGAFFINE_CLAMP (1 << (WARPEDMODEL_PREC_BITS - 1))
-#define WARPEDMODEL_ROW3HOMO_CLAMP (1 << (WARPEDMODEL_PREC_BITS - 1))
+#define WARPEDMODEL_NONDIAGAFFINE_CLAMP (1 << (WARPEDMODEL_PREC_BITS - 3))
+#define WARPEDMODEL_ROW3HOMO_CLAMP (1 << (WARPEDMODEL_PREC_BITS - 2))
 
 // Bits of subpel precision for warped interpolation
 #define WARPEDPIXEL_PREC_BITS 6
 #define WARPEDPIXEL_PREC_SHIFTS (1 << WARPEDPIXEL_PREC_BITS)
 
 // Taps for ntap filter
 #define WARPEDPIXEL_FILTER_TAPS 6
 
@@ -83,16 +82,21 @@ typedef enum {
 // Number of types used for global motion (must be >= 3 and <= TRANS_TYPES)
 // The following can be useful:
 // GLOBAL_TRANS_TYPES 3 - up to rotation-zoom
 // GLOBAL_TRANS_TYPES 4 - up to affine
 // GLOBAL_TRANS_TYPES 6 - up to hor/ver trapezoids
 // GLOBAL_TRANS_TYPES 7 - up to full homography
 #define GLOBAL_TRANS_TYPES 4
 
+// First bit indicates whether using identity or not
+// GLOBAL_TYPE_BITS=ceiling(log2(GLOBAL_TRANS_TYPES-1)) is the
+// number of bits needed to cover the remaining possibilities
+#define GLOBAL_TYPE_BITS (get_msb(2 * GLOBAL_TRANS_TYPES - 3))
+
 typedef struct {
 #if CONFIG_GLOBAL_MOTION
   int global_warp_allowed;
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_WARPED_MOTION
   int local_warp_allowed;
 #endif  // CONFIG_WARPED_MOTION
 } WarpTypesAllowed;
--- a/third_party/aom/av1/common/mvref_common.c
+++ b/third_party/aom/av1/common/mvref_common.c
@@ -835,27 +835,31 @@ void av1_find_mv_refs(const AV1_COMMON *
 #endif  // CONFIG_GLOBAL_MOTION
 
 #if CONFIG_EXT_INTER
   av1_update_mv_context(cm, xd, mi, ref_frame, mv_ref_list, -1, mi_row, mi_col,
                         compound_mode_context);
 #endif  // CONFIG_EXT_INTER
 
 #if CONFIG_GLOBAL_MOTION
-  av1_set_ref_frame(rf, ref_frame);
-  zeromv[0].as_int = gm_get_motion_vector(&cm->global_motion[rf[0]],
-                                          cm->allow_high_precision_mv, bsize,
-                                          mi_col, mi_row, 0)
-                         .as_int;
-  zeromv[1].as_int = (rf[1] != NONE_FRAME)
-                         ? gm_get_motion_vector(&cm->global_motion[rf[1]],
-                                                cm->allow_high_precision_mv,
-                                                bsize, mi_col, mi_row, 0)
-                               .as_int
-                         : 0;
+  if (!CONFIG_INTRABC || ref_frame != INTRA_FRAME) {
+    av1_set_ref_frame(rf, ref_frame);
+    zeromv[0].as_int = gm_get_motion_vector(&cm->global_motion[rf[0]],
+                                            cm->allow_high_precision_mv, bsize,
+                                            mi_col, mi_row, 0)
+                           .as_int;
+    zeromv[1].as_int = (rf[1] != NONE_FRAME)
+                           ? gm_get_motion_vector(&cm->global_motion[rf[1]],
+                                                  cm->allow_high_precision_mv,
+                                                  bsize, mi_col, mi_row, 0)
+                                 .as_int
+                           : 0;
+  } else {
+    zeromv[0].as_int = zeromv[1].as_int = 0;
+  }
 #else
   zeromv[0].as_int = zeromv[1].as_int = 0;
 #endif  // CONFIG_GLOBAL_MOTION
 
   if (ref_frame <= ALTREF_FRAME)
     find_mv_refs_idx(cm, xd, mi, ref_frame, mv_ref_list, -1, mi_row, mi_col,
                      sync, data, mode_context, zeromv[0]);
 
@@ -920,20 +924,20 @@ void av1_append_sub8x8_mvs_for_idx(const
   uint8_t idx;
   uint8_t above_count = 0, left_count = 0;
   MV_REFERENCE_FRAME rf[2] = { mi->mbmi.ref_frame[ref], NONE_FRAME };
   *ref_mv_count = 0;
 
   assert(MAX_MV_REF_CANDIDATES == 2);
 
 #if CONFIG_GLOBAL_MOTION
-  zeromv.as_int =
-      gm_get_motion_vector(&cm->global_motion[ref], cm->allow_high_precision_mv,
-                           mi->mbmi.sb_type, mi_col, mi_row, block)
-          .as_int;
+  zeromv.as_int = gm_get_motion_vector(&cm->global_motion[rf[0]],
+                                       cm->allow_high_precision_mv,
+                                       mi->mbmi.sb_type, mi_col, mi_row, block)
+                      .as_int;
 #else
   zeromv.as_int = 0;
 #endif
   find_mv_refs_idx(cm, xd, mi, mi->mbmi.ref_frame[ref], mv_list, block, mi_row,
                    mi_col, NULL, NULL, NULL, zeromv);
 
   scan_blk_mbmi(cm, xd, mi_row, mi_col, block, rf, -1, 0, ref_mv_stack,
                 ref_mv_count);
--- a/third_party/aom/av1/common/mvref_common.h
+++ b/third_party/aom/av1/common/mvref_common.h
@@ -61,17 +61,17 @@ static const int mode_2_counter[] = {
   9,    // TM_PRED
   0,    // NEARESTMV
   0,    // NEARMV
   3,    // ZEROMV
   1,    // NEWMV
 #if CONFIG_EXT_INTER
 #if CONFIG_COMPOUND_SINGLEREF
   0,    // SR_NEAREST_NEARMV
-  1,    // SR_NEAREST_NEWMV
+        //  1,    // SR_NEAREST_NEWMV
   1,    // SR_NEAR_NEWMV
   3,    // SR_ZERO_NEWMV
   1,    // SR_NEW_NEWMV
 #endif  // CONFIG_COMPOUND_SINGLEREF
   0,    // NEAREST_NEARESTMV
   0,    // NEAR_NEARMV
   1,    // NEAREST_NEWMV
   1,    // NEW_NEARESTMV
@@ -233,36 +233,73 @@ static INLINE int av1_nmv_ctx(const uint
                               const CANDIDATE_MV *ref_mv_stack, int ref,
                               int ref_mv_idx) {
   if (ref_mv_stack[ref_mv_idx].weight >= REF_CAT_LEVEL && ref_mv_count > 0)
     return ref_mv_stack[ref_mv_idx].pred_diff[ref];
 
   return 0;
 }
 
+#if CONFIG_EXT_COMP_REFS
+static INLINE int8_t av1_uni_comp_ref_idx(const MV_REFERENCE_FRAME *const rf) {
+  // Single ref pred
+  if (rf[1] <= INTRA_FRAME) return -1;
+
+  // Bi-directional comp ref pred
+  if ((rf[0] < BWDREF_FRAME) && (rf[1] >= BWDREF_FRAME)) return -1;
+
+  for (int8_t ref_idx = 0; ref_idx < UNIDIR_COMP_REFS; ++ref_idx) {
+    if (rf[0] == comp_ref0(ref_idx) && rf[1] == comp_ref1(ref_idx))
+      return ref_idx;
+  }
+  return -1;
+}
+#endif  // CONFIG_EXT_COMP_REFS
+
 static INLINE int8_t av1_ref_frame_type(const MV_REFERENCE_FRAME *const rf) {
   if (rf[1] > INTRA_FRAME) {
-    return TOTAL_REFS_PER_FRAME + FWD_RF_OFFSET(rf[0]) +
-           BWD_RF_OFFSET(rf[1]) * FWD_REFS;
+#if CONFIG_EXT_COMP_REFS
+    int8_t uni_comp_ref_idx = av1_uni_comp_ref_idx(rf);
+#if !USE_UNI_COMP_REFS
+    // NOTE: uni-directional comp refs disabled
+    assert(uni_comp_ref_idx < 0);
+#endif  // !USE_UNI_COMP_REFS
+    if (uni_comp_ref_idx >= 0) {
+      assert((TOTAL_REFS_PER_FRAME + FWD_REFS * BWD_REFS + uni_comp_ref_idx) <
+             MODE_CTX_REF_FRAMES);
+      return TOTAL_REFS_PER_FRAME + FWD_REFS * BWD_REFS + uni_comp_ref_idx;
+    } else {
+#endif  // CONFIG_EXT_COMP_REFS
+      return TOTAL_REFS_PER_FRAME + FWD_RF_OFFSET(rf[0]) +
+             BWD_RF_OFFSET(rf[1]) * FWD_REFS;
+#if CONFIG_EXT_COMP_REFS
+    }
+#endif  // CONFIG_EXT_COMP_REFS
   }
 
   return rf[0];
 }
 
 // clang-format off
 static MV_REFERENCE_FRAME ref_frame_map[COMP_REFS][2] = {
 #if CONFIG_EXT_REFS
   { LAST_FRAME, BWDREF_FRAME },  { LAST2_FRAME, BWDREF_FRAME },
   { LAST3_FRAME, BWDREF_FRAME }, { GOLDEN_FRAME, BWDREF_FRAME },
 
   { LAST_FRAME, ALTREF_FRAME },  { LAST2_FRAME, ALTREF_FRAME },
   { LAST3_FRAME, ALTREF_FRAME }, { GOLDEN_FRAME, ALTREF_FRAME }
-#else
+
+  // TODO(zoeliu): Temporarily disable uni-directional comp refs
+#if CONFIG_EXT_COMP_REFS
+  , { LAST_FRAME, LAST2_FRAME }, { LAST_FRAME, GOLDEN_FRAME },
+  { BWDREF_FRAME, ALTREF_FRAME }
+#endif  // CONFIG_EXT_COMP_REFS
+#else  // !CONFIG_EXT_REFS
   { LAST_FRAME, ALTREF_FRAME }, { GOLDEN_FRAME, ALTREF_FRAME }
-#endif
+#endif  // CONFIG_EXT_REFS
 };
 // clang-format on
 
 static INLINE void av1_set_ref_frame(MV_REFERENCE_FRAME *rf,
                                      int8_t ref_frame_type) {
   if (ref_frame_type >= TOTAL_REFS_PER_FRAME) {
     rf[0] = ref_frame_map[ref_frame_type - TOTAL_REFS_PER_FRAME][0];
     rf[1] = ref_frame_map[ref_frame_type - TOTAL_REFS_PER_FRAME][1];
--- a/third_party/aom/av1/common/onyxc_int.h
+++ b/third_party/aom/av1/common/onyxc_int.h
@@ -148,16 +148,20 @@ typedef struct BufferPool {
 
   // Frame buffers allocated internally by the codec.
   InternalFrameBufferList int_frame_buffers;
 } BufferPool;
 
 typedef struct AV1Common {
   struct aom_internal_error_info error;
   aom_color_space_t color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  aom_transfer_function_t transfer_function;
+  aom_chroma_sample_position_t chroma_sample_position;
+#endif
   int color_range;
   int width;
   int height;
   int render_width;
   int render_height;
   int last_width;
   int last_height;
 
@@ -297,31 +301,34 @@ typedef struct AV1Common {
   int seg_map_alloc_size;
 
   InterpFilter interp_filter;
 
   loop_filter_info_n lf_info;
 #if CONFIG_FRAME_SUPERRES
   // The numerator of the superres scale; the denominator is fixed.
   uint8_t superres_scale_numerator;
+  uint8_t superres_kf_scale_numerator;
+  int superres_upscaled_width;
+  int superres_upscaled_height;
 #endif  // CONFIG_FRAME_SUPERRES
 #if CONFIG_LOOP_RESTORATION
   RestorationInfo rst_info[MAX_MB_PLANE];
   RestorationInternal rst_internal;
 #endif  // CONFIG_LOOP_RESTORATION
 
   // Flag signaling how frame contexts should be updated at the end of
   // a frame decode
   REFRESH_FRAME_CONTEXT_MODE refresh_frame_context;
 
   int ref_frame_sign_bias[TOTAL_REFS_PER_FRAME]; /* Two state 0, 1 */
 
   struct loopfilter lf;
   struct segmentation seg;
-
+  int all_lossless;
   int frame_parallel_decode;  // frame-based threading.
 
 #if CONFIG_EXT_TX
   int reduced_tx_set_used;
 #endif  // CONFIG_EXT_TX
 
 // Context probabilities for reference frame prediction
 #if CONFIG_EXT_REFS
@@ -500,16 +507,34 @@ static INLINE void ref_cnt_fb(RefCntBuff
   if (ref_index >= 0 && bufs[ref_index].ref_count > 0)
     bufs[ref_index].ref_count--;
 
   *idx = new_idx;
 
   bufs[new_idx].ref_count++;
 }
 
+#if CONFIG_VAR_REFS
+#define LAST_IS_VALID(cm) ((cm)->frame_refs[LAST_FRAME - 1].is_valid)
+#define LAST2_IS_VALID(cm) ((cm)->frame_refs[LAST2_FRAME - 1].is_valid)
+#define LAST3_IS_VALID(cm) ((cm)->frame_refs[LAST3_FRAME - 1].is_valid)
+#define GOLDEN_IS_VALID(cm) ((cm)->frame_refs[GOLDEN_FRAME - 1].is_valid)
+#define BWDREF_IS_VALID(cm) ((cm)->frame_refs[BWDREF_FRAME - 1].is_valid)
+#define ALTREF_IS_VALID(cm) ((cm)->frame_refs[ALTREF_FRAME - 1].is_valid)
+
+#define L_OR_L2(cm) (LAST_IS_VALID(cm) || LAST2_IS_VALID(cm))
+#define L_AND_L2(cm) (LAST_IS_VALID(cm) && LAST2_IS_VALID(cm))
+
+#define L3_OR_G(cm) (LAST3_IS_VALID(cm) || GOLDEN_IS_VALID(cm))
+#define L3_AND_G(cm) (LAST3_IS_VALID(cm) && GOLDEN_IS_VALID(cm))
+
+#define BWD_OR_ALT(cm) (BWDREF_IS_VALID(cm) || ALTREF_IS_VALID(cm))
+#define BWD_AND_ALT(cm) (BWDREF_IS_VALID(cm) && ALTREF_IS_VALID(cm))
+#endif  // CONFIG_VAR_REFS
+
 static INLINE int mi_cols_aligned_to_sb(const AV1_COMMON *cm) {
   return ALIGN_POWER_OF_TWO(cm->mi_cols, cm->mib_size_log2);
 }
 
 static INLINE int mi_rows_aligned_to_sb(const AV1_COMMON *cm) {
   return ALIGN_POWER_OF_TWO(cm->mi_rows, cm->mib_size_log2);
 }
 
@@ -520,27 +545,21 @@ static INLINE int frame_is_intra_only(co
 static INLINE void av1_init_macroblockd(AV1_COMMON *cm, MACROBLOCKD *xd,
 #if CONFIG_PVQ
                                         tran_low_t *pvq_ref_coeff,
 #endif
 #if CONFIG_CFL
                                         CFL_CTX *cfl,
 #endif
                                         tran_low_t *dqcoeff) {
-  int i;
-  for (i = 0; i < MAX_MB_PLANE; ++i) {
+  for (int i = 0; i < MAX_MB_PLANE; ++i) {
     xd->plane[i].dqcoeff = dqcoeff;
 #if CONFIG_PVQ
     xd->plane[i].pvq_ref_coeff = pvq_ref_coeff;
 #endif
-#if CONFIG_CFL
-    xd->cfl = cfl;
-    cfl_init(cfl, cm, xd->plane[AOM_PLANE_U].subsampling_x,
-             xd->plane[AOM_PLANE_U].subsampling_y);
-#endif
     xd->above_context[i] = cm->above_context[i];
     if (xd->plane[i].plane_type == PLANE_TYPE_Y) {
       memcpy(xd->plane[i].seg_dequant, cm->y_dequant, sizeof(cm->y_dequant));
 #if CONFIG_AOM_QM
       memcpy(xd->plane[i].seg_iqmatrix, cm->y_iqmatrix, sizeof(cm->y_iqmatrix));
 #endif
 
 #if CONFIG_NEW_QUANT
@@ -553,22 +572,26 @@ static INLINE void av1_init_macroblockd(
       memcpy(xd->plane[i].seg_iqmatrix, cm->uv_iqmatrix,
              sizeof(cm->uv_iqmatrix));
 #endif
 #if CONFIG_NEW_QUANT
       memcpy(xd->plane[i].seg_dequant_nuq, cm->uv_dequant_nuq,
              sizeof(cm->uv_dequant_nuq));
 #endif
     }
-    xd->fc = cm->fc;
   }
+  xd->fc = cm->fc;
   xd->above_seg_context = cm->above_seg_context;
 #if CONFIG_VAR_TX
   xd->above_txfm_context = cm->above_txfm_context;
 #endif
+#if CONFIG_CFL
+  cfl_init(cfl, cm);
+  xd->cfl = cfl;
+#endif
   xd->mi_stride = cm->mi_stride;
   xd->error_info = &cm->error;
 }
 
 static INLINE void set_skip_context(MACROBLOCKD *xd, int mi_row, int mi_col) {
   int i;
   int row_offset = mi_row;
   int col_offset = mi_col;
@@ -737,16 +760,30 @@ static INLINE int is_chroma_reference(in
                   ((mi_col & 0x01) && subsampling_x));
 
   if (bsize >= BLOCK_8X8) ref_pos = 1;
 
   return ref_pos;
 #endif
 }
 
+#if CONFIG_SUPERTX
+static INLINE int need_handle_chroma_sub8x8(BLOCK_SIZE bsize, int subsampling_x,
+                                            int subsampling_y) {
+  const int bw = mi_size_wide[bsize];
+  const int bh = mi_size_high[bsize];
+
+  if (bsize >= BLOCK_8X8 ||
+      ((!(bh & 0x01) || !subsampling_y) && (!(bw & 0x01) || !subsampling_x)))
+    return 0;
+  else
+    return 1;
+}
+#endif
+
 static INLINE BLOCK_SIZE scale_chroma_bsize(BLOCK_SIZE bsize, int subsampling_x,
                                             int subsampling_y) {
   BLOCK_SIZE bs = bsize;
 
   if (bs < BLOCK_8X8) {
     if (subsampling_x == 1 && subsampling_y == 1)
       bs = BLOCK_8X8;
     else if (subsampling_x == 1)
@@ -856,16 +893,34 @@ static INLINE int max_block_high(const M
 
   if (xd->mb_to_bottom_edge < 0)
     max_blocks_high += xd->mb_to_bottom_edge >> (3 + pd->subsampling_y);
 
   // Scale the width in the transform block unit.
   return max_blocks_high >> tx_size_wide_log2[0];
 }
 
+#if CONFIG_CFL
+static INLINE int max_intra_block_width(const MACROBLOCKD *xd,
+                                        BLOCK_SIZE plane_bsize, int plane,
+                                        TX_SIZE tx_size) {
+  const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane)
+                              << tx_size_wide_log2[0];
+  return ALIGN_POWER_OF_TWO(max_blocks_wide, tx_size_wide_log2[tx_size]);
+}
+
+static INLINE int max_intra_block_height(const MACROBLOCKD *xd,
+                                         BLOCK_SIZE plane_bsize, int plane,
+                                         TX_SIZE tx_size) {
+  const int max_blocks_high = max_block_high(xd, plane_bsize, plane)
+                              << tx_size_high_log2[0];
+  return ALIGN_POWER_OF_TWO(max_blocks_high, tx_size_high_log2[tx_size]);
+}
+#endif  // CONFIG_CFL
+
 static INLINE void av1_zero_above_context(AV1_COMMON *const cm,
                                           int mi_col_start, int mi_col_end) {
   const int width = mi_col_end - mi_col_start;
   const int aligned_width = ALIGN_POWER_OF_TWO(width, cm->mib_size_log2);
 
   const int offset_y = mi_col_start << (MI_SIZE_LOG2 - tx_size_wide_log2[0]);
   const int width_y = aligned_width << (MI_SIZE_LOG2 - tx_size_wide_log2[0]);
   const int offset_uv = offset_y >> cm->subsampling_x;
@@ -886,22 +941,32 @@ static INLINE void av1_zero_above_contex
 static INLINE void av1_zero_left_context(MACROBLOCKD *const xd) {
   av1_zero(xd->left_context);
   av1_zero(xd->left_seg_context);
 #if CONFIG_VAR_TX
   av1_zero(xd->left_txfm_context_buffer);
 #endif
 }
 
-#if CONFIG_VAR_TX
+// Disable array-bounds checks as the TX_SIZE enum contains values larger than
+// TX_SIZES_ALL (TX_INVALID) which make extending the array as a workaround
+// infeasible. The assert is enough for static analysis and this or other tools
+// asan, valgrind would catch oob access at runtime.
+#if defined(__GNUC__) && __GNUC__ >= 4
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
 static INLINE TX_SIZE get_min_tx_size(TX_SIZE tx_size) {
   assert(tx_size < TX_SIZES_ALL);
   return txsize_sqr_map[tx_size];
 }
+#if defined(__GNUC__) && __GNUC__ >= 4
+#pragma GCC diagnostic warning "-Warray-bounds"
+#endif
 
+#if CONFIG_VAR_TX
 static INLINE void set_txfm_ctx(TXFM_CONTEXT *txfm_ctx, uint8_t txs, int len) {
   int i;
   for (i = 0; i < len; ++i) txfm_ctx[i] = txs;
 }
 
 static INLINE void set_txfm_ctxs(TX_SIZE tx_size, int n8_w, int n8_h, int skip,
                                  const MACROBLOCKD *xd) {
   uint8_t bw = tx_size_wide[tx_size];
@@ -1015,13 +1080,29 @@ static INLINE void set_sb_size(AV1_COMMO
   cm->mib_size = mi_size_wide[cm->sb_size];
 #if CONFIG_CB4X4
   cm->mib_size_log2 = b_width_log2_lookup[cm->sb_size];
 #else
   cm->mib_size_log2 = mi_width_log2_lookup[cm->sb_size];
 #endif
 }
 
+static INLINE int all_lossless(const AV1_COMMON *cm, const MACROBLOCKD *xd) {
+  int i;
+  int all_lossless = 1;
+  if (cm->seg.enabled) {
+    for (i = 0; i < MAX_SEGMENTS; ++i) {
+      if (!xd->lossless[i]) {
+        all_lossless = 0;
+        break;
+      }
+    }
+  } else {
+    all_lossless = xd->lossless[0];
+  }
+  return all_lossless;
+}
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
 #endif  // AV1_COMMON_ONYXC_INT_H_
--- a/third_party/aom/av1/common/pred_common.c
+++ b/third_party/aom/av1/common/pred_common.c
@@ -218,37 +218,44 @@ int av1_get_intra_inter_context(const MA
     return 0;
   }
 }
 
 #if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 // The compound/single mode info data structure has one element border above and
 // to the left of the entries corresponding to real macroblocks.
 // The prediction flags in these dummy entries are initialized to 0.
-// 0 - single/single
-// 1 - single/--, --/single, --/--
-// 2 - single/comp, comp/single
-// 3 - comp/comp, comp/--, --/comp
 int av1_get_inter_mode_context(const MACROBLOCKD *xd) {
   const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
   const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
   const int has_above = xd->up_available;
   const int has_left = xd->left_available;
 
-  if (has_above && has_left) {  // both edges available (0/2/3)
-    const int above_inter_comp_mode = is_inter_compound_mode(above_mbmi->mode);
-    const int left_inter_comp_mode = is_inter_compound_mode(left_mbmi->mode);
-    return (above_inter_comp_mode && left_inter_comp_mode)
-               ? 3
-               : (above_inter_comp_mode || left_inter_comp_mode) * 2;
-  } else if (has_above || has_left) {  // one edge available (1/3)
+  if (has_above && has_left) {  // both edges available
+    const int above_inter_comp_mode =
+        is_inter_anyref_comp_mode(above_mbmi->mode);
+    const int left_inter_comp_mode = is_inter_anyref_comp_mode(left_mbmi->mode);
+    if (above_inter_comp_mode && left_inter_comp_mode)
+      return 0;
+    else if (above_inter_comp_mode || left_inter_comp_mode)
+      return 1;
+    else if (!is_inter_block(above_mbmi) && !is_inter_block(left_mbmi))
+      return 2;
+    else
+      return 3;
+  } else if (has_above || has_left) {  // one edge available
     const MB_MODE_INFO *const edge_mbmi = has_above ? above_mbmi : left_mbmi;
-    return is_inter_compound_mode(edge_mbmi->mode) ? 3 : 1;
-  } else {  // no edge available (1)
-    return 1;
+    if (is_inter_anyref_comp_mode(edge_mbmi->mode))
+      return 1;
+    else if (!is_inter_block(edge_mbmi))
+      return 2;
+    else
+      return 3;
+  } else {  // no edge available
+    return 2;
   }
 }
 #endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 
 #if CONFIG_EXT_REFS
 #define CHECK_BACKWARD_REFS(ref_frame) \
   (((ref_frame) >= BWDREF_FRAME) && ((ref_frame) <= ALTREF_FRAME))
 #define IS_BACKWARD_REF_FRAME(ref_frame) CHECK_BACKWARD_REFS(ref_frame)
@@ -298,16 +305,290 @@ int av1_get_reference_mode_context(const
       ctx = 3;
   } else {  // no edges available (1)
     ctx = 1;
   }
   assert(ctx >= 0 && ctx < COMP_INTER_CONTEXTS);
   return ctx;
 }
 
+#if CONFIG_EXT_COMP_REFS
+#define CHECK_BWDREF_OR_ALTREF(ref_frame) \
+  ((ref_frame) == BWDREF_FRAME || (ref_frame) == ALTREF_FRAME)
+int av1_get_comp_reference_type_context(const AV1_COMMON *cm,
+                                        const MACROBLOCKD *xd) {
+  int pred_context;
+  const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
+  const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
+  const int above_in_image = xd->up_available;
+  const int left_in_image = xd->left_available;
+
+  (void)cm;
+
+  if (above_in_image && left_in_image) {  // both edges available
+    const int above_intra = !is_inter_block(above_mbmi);
+    const int left_intra = !is_inter_block(left_mbmi);
+
+    if (above_intra && left_intra) {  // intra/intra
+      pred_context = 2;
+    } else if (above_intra || left_intra) {  // intra/inter
+      const MB_MODE_INFO *inter_mbmi = above_intra ? left_mbmi : above_mbmi;
+
+      if (!has_second_ref(inter_mbmi))  // single pred
+        pred_context = 2;
+      else  // comp pred
+        pred_context = 1 + 2 * has_uni_comp_refs(inter_mbmi);
+    } else {  // inter/inter
+      const int a_sg = !has_second_ref(above_mbmi);
+      const int l_sg = !has_second_ref(left_mbmi);
+      const MV_REFERENCE_FRAME frfa = above_mbmi->ref_frame[0];
+      const MV_REFERENCE_FRAME frfl = left_mbmi->ref_frame[0];
+
+      if (a_sg && l_sg) {  // single/single
+        pred_context = 1 +
+                       2 * (!(CHECK_BWDREF_OR_ALTREF(frfa) ^
+                              CHECK_BWDREF_OR_ALTREF(frfl)));
+      } else if (l_sg || a_sg) {  // single/comp
+        const int uni_rfc =
+            a_sg ? has_uni_comp_refs(left_mbmi) : has_uni_comp_refs(above_mbmi);
+
+        if (!uni_rfc)  // comp bidir
+          pred_context = 1;
+        else  // comp unidir
+          pred_context = 3 + (!(CHECK_BWDREF_OR_ALTREF(frfa) ^
+                                CHECK_BWDREF_OR_ALTREF(frfl)));
+      } else {  // comp/comp
+        const int a_uni_rfc = has_uni_comp_refs(above_mbmi);
+        const int l_uni_rfc = has_uni_comp_refs(left_mbmi);
+
+        if (!a_uni_rfc && !l_uni_rfc)  // bidir/bidir
+          pred_context = 0;
+        else if (!a_uni_rfc || !l_uni_rfc)  // unidir/bidir
+          pred_context = 2;
+        else  // unidir/unidir
+          pred_context =
+              3 + (!((frfa == BWDREF_FRAME) ^ (frfl == BWDREF_FRAME)));
+      }
+    }
+  } else if (above_in_image || left_in_image) {  // one edge available
+    const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi;
+
+    if (!is_inter_block(edge_mbmi)) {  // intra
+      pred_context = 2;
+    } else {                           // inter
+      if (!has_second_ref(edge_mbmi))  // single pred
+        pred_context = 2;
+      else  // comp pred
+        pred_context = 4 * has_uni_comp_refs(edge_mbmi);
+    }
+  } else {  // no edges available
+    pred_context = 2;
+  }
+
+  assert(pred_context >= 0 && pred_context < COMP_REF_TYPE_CONTEXTS);
+  return pred_context;
+}
+
+// Returns a context number for the given MB prediction signal
+// Signal the uni-directional compound reference frame pair as
+// either (BWDREF, ALTREF), or (LAST, LAST2)/(LAST, GOLDEN),
+// conditioning on the pair is known as uni-directional.
+int av1_get_pred_context_uni_comp_ref_p(const AV1_COMMON *cm,
+                                        const MACROBLOCKD *xd) {
+  int pred_context;
+  const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
+  const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
+  const int above_in_image = xd->up_available;
+  const int left_in_image = xd->left_available;
+
+  (void)cm;
+
+  if (above_in_image && left_in_image) {  // both edges available
+    const int above_intra = !is_inter_block(above_mbmi);
+    const int left_intra = !is_inter_block(left_mbmi);
+
+    if (above_intra && left_intra) {  // intra/intra
+      pred_context = 2;
+    } else if (above_intra || left_intra) {  // intra/inter
+      const MB_MODE_INFO *inter_mbmi = above_intra ? left_mbmi : above_mbmi;
+
+      if (!has_second_ref(inter_mbmi)) {  // single pred
+        pred_context =
+            1 + 2 * (!CHECK_BWDREF_OR_ALTREF(inter_mbmi->ref_frame[0]));
+      } else {                              // comp pred
+        if (has_uni_comp_refs(inter_mbmi))  // comp unidir
+          pred_context = 4 * (inter_mbmi->ref_frame[0] != BWDREF_FRAME);
+        else  // comp_bidir
+          pred_context = 2;
+      }
+    } else {  // inter/inter
+      const int a_sg = !has_second_ref(above_mbmi);
+      const int l_sg = !has_second_ref(left_mbmi);
+      const MV_REFERENCE_FRAME frfa = above_mbmi->ref_frame[0];
+      const MV_REFERENCE_FRAME frfl = left_mbmi->ref_frame[0];
+
+      if (CHECK_BWDREF_OR_ALTREF(frfa) && CHECK_BWDREF_OR_ALTREF(frfl)) {
+        pred_context = 0;
+      } else if (a_sg && l_sg) {  // single/single
+        pred_context = 2 + (!CHECK_BWDREF_OR_ALTREF(frfa) &&
+                            !CHECK_BWDREF_OR_ALTREF(frfl));
+      } else if (l_sg || a_sg) {  // single/comp
+        const MV_REFERENCE_FRAME frfc = a_sg ? frfl : frfa;
+        const MV_REFERENCE_FRAME rfs = a_sg ? frfa : frfl;
+        const int uni_rfc =
+            a_sg ? has_uni_comp_refs(left_mbmi) : has_uni_comp_refs(above_mbmi);
+
+        if (uni_rfc && (frfc == BWDREF_FRAME))
+          pred_context = 1;
+        else if (uni_rfc && (frfc == LAST_FRAME))
+          pred_context = 3 + (!CHECK_BWDREF_OR_ALTREF(rfs));
+        else if (CHECK_BWDREF_OR_ALTREF(rfs))
+          pred_context = 2;
+        else
+          pred_context = 3;
+      } else {  // comp/comp
+        const int a_uni_rfc = has_uni_comp_refs(above_mbmi);
+        const int l_uni_rfc = has_uni_comp_refs(left_mbmi);
+
+        if (a_uni_rfc && l_uni_rfc)
+          pred_context = 2 + 2 * (frfa != BWDREF_FRAME && frfl != BWDREF_FRAME);
+        else if (a_uni_rfc || l_uni_rfc)
+          pred_context = 1 + 2 * (frfa != BWDREF_FRAME && frfl != BWDREF_FRAME);
+        else
+          pred_context = 2;
+      }
+    }
+  } else if (above_in_image || left_in_image) {  // one edge available
+    const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi;
+
+    if (!is_inter_block(edge_mbmi)) {  // intra
+      pred_context = 2;
+    } else {                             // inter
+      if (!has_second_ref(edge_mbmi)) {  // single pred
+        pred_context =
+            1 + 2 * (!CHECK_BWDREF_OR_ALTREF(edge_mbmi->ref_frame[0]));
+      } else {                             // comp pred
+        if (has_uni_comp_refs(edge_mbmi))  // comp unidir
+          pred_context = 4 * (edge_mbmi->ref_frame[0] != BWDREF_FRAME);
+        else  // comp bidir
+          pred_context = 2;
+      }
+    }
+  } else {  // no edges available
+    pred_context = 2;
+  }
+
+  assert(pred_context >= 0 && pred_context < UNI_COMP_REF_CONTEXTS);
+  return pred_context;
+}
+
+// Returns a context number for the given MB prediction signal
+// Signal the uni-directional compound reference frame pair as
+// either (BWDREF, ALTREF), or (LAST, LAST2)/(LAST, GOLDEN),
+// conditioning on the pair is known as uni-directional.
+#define CHECK_LAST2_OR_GOLDEN(ref_frame) \
+  ((ref_frame) == LAST2_FRAME || (ref_frame) == GOLDEN_FRAME)
+int av1_get_pred_context_uni_comp_ref_p1(const AV1_COMMON *cm,
+                                         const MACROBLOCKD *xd) {
+  int pred_context;
+  const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
+  const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
+  const int above_in_image = xd->up_available;
+  const int left_in_image = xd->left_available;
+
+  (void)cm;
+
+  if (above_in_image && left_in_image) {  // both edges available
+    const int above_intra = !is_inter_block(above_mbmi);
+    const int left_intra = !is_inter_block(left_mbmi);
+
+    if (above_intra && left_intra) {  // intra/intra
+      pred_context = 2;
+    } else if (above_intra || left_intra) {  // intra/inter
+      const MB_MODE_INFO *inter_mbmi = above_intra ? left_mbmi : above_mbmi;
+
+      if (!has_second_ref(inter_mbmi)) {  // single pred
+        if (CHECK_LAST2_OR_GOLDEN(inter_mbmi->ref_frame[0]))
+          pred_context = 1 + 2 * (inter_mbmi->ref_frame[0] == LAST2_FRAME);
+        else
+          pred_context = 2;
+      } else {  // comp pred
+        if (CHECK_LAST2_OR_GOLDEN(inter_mbmi->ref_frame[1]))
+          pred_context = 4 * (inter_mbmi->ref_frame[1] == LAST2_FRAME);
+        else
+          pred_context = 2;
+      }
+    } else {  // inter/inter
+      const int a_sg = !has_second_ref(above_mbmi);
+      const int l_sg = !has_second_ref(left_mbmi);
+      const MV_REFERENCE_FRAME frfa = above_mbmi->ref_frame[0];
+      const MV_REFERENCE_FRAME frfl = left_mbmi->ref_frame[0];
+      const MV_REFERENCE_FRAME brfa = above_mbmi->ref_frame[1];
+      const MV_REFERENCE_FRAME brfl = left_mbmi->ref_frame[1];
+
+      if (a_sg && l_sg) {  // single/single
+        if (CHECK_LAST2_OR_GOLDEN(frfa) && (frfa == frfl || frfl == LAST_FRAME))
+          pred_context = 1 + 2 * (frfa == LAST2_FRAME);
+        else if (frfa == LAST_FRAME && CHECK_LAST2_OR_GOLDEN(frfl))
+          pred_context = 1 + 2 * (frfl == LAST2_FRAME);
+        else
+          pred_context = 2;
+      } else if (l_sg || a_sg) {  // single/comp
+        const MV_REFERENCE_FRAME brfc = a_sg ? brfl : brfa;
+
+        if (CHECK_LAST2_OR_GOLDEN(brfc))
+          pred_context = 4 * (brfc == LAST2_FRAME);
+        if (CHECK_LAST2_OR_GOLDEN(frfa) && (frfa == frfl || frfl == LAST_FRAME))
+          pred_context = 1 + 2 * (frfa == LAST2_FRAME);
+        else if (frfa == LAST_FRAME && CHECK_LAST2_OR_GOLDEN(frfl))
+          pred_context = 1 + 2 * (frfl == LAST2_FRAME);
+        else
+          pred_context = 2;
+      } else {  // comp/comp
+        if (CHECK_LAST2_OR_GOLDEN(brfa) &&
+            (brfa == brfl || !CHECK_LAST2_OR_GOLDEN(brfl)))
+          pred_context = 4 * (brfa == LAST2_FRAME);
+        else if (!CHECK_LAST2_OR_GOLDEN(brfa) && CHECK_LAST2_OR_GOLDEN(brfl))
+          pred_context = 4 * (brfl == LAST2_FRAME);
+        else if (CHECK_LAST2_OR_GOLDEN(frfa) &&
+                 (frfa == frfl || frfl == LAST_FRAME))
+          pred_context = 1 + 2 * (frfa == LAST2_FRAME);
+        else if (frfa == LAST_FRAME && CHECK_LAST2_OR_GOLDEN(frfl))
+          pred_context = 1 + 2 * (frfl == LAST2_FRAME);
+        else
+          pred_context = 2;
+      }
+    }
+  } else if (above_in_image || left_in_image) {  // one edge available
+    const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi;
+
+    if (!is_inter_block(edge_mbmi)) {  // intra
+      pred_context = 2;
+    } else {                             // inter
+      if (!has_second_ref(edge_mbmi)) {  // single pred
+        if (CHECK_LAST2_OR_GOLDEN(edge_mbmi->ref_frame[0]))
+          pred_context = 1 + 2 * (edge_mbmi->ref_frame[0] == LAST2_FRAME);
+        else
+          pred_context = 2;
+      } else {  // comp pred
+        if (CHECK_LAST2_OR_GOLDEN(edge_mbmi->ref_frame[1]))
+          pred_context = 4 * (edge_mbmi->ref_frame[1] == LAST2_FRAME);
+        else
+          pred_context = 2;
+      }
+    }
+  } else {  // no edges available
+    pred_context = 2;
+  }
+
+  assert(pred_context >= 0 && pred_context < UNI_COMP_REF_CONTEXTS);
+  return pred_context;
+}
+#endif  // CONFIG_EXT_COMP_REFS
+
 #if CONFIG_EXT_REFS
 
 // TODO(zoeliu): Future work will be conducted to optimize the context design
 //               for the coding of the reference frames.
 
 #define CHECK_LAST_OR_LAST2(ref_frame) \
   ((ref_frame == LAST_FRAME) || (ref_frame == LAST2_FRAME))
 
@@ -315,41 +596,38 @@ int av1_get_reference_mode_context(const
   ((ref_frame == GOLDEN_FRAME) || (ref_frame == LAST3_FRAME))
 
 // Returns a context number for the given MB prediction signal
 // Signal the first reference frame for a compound mode be either
 // GOLDEN/LAST3, or LAST/LAST2.
 //
 // NOTE(zoeliu): The probability of ref_frame[0] is either
 //               GOLDEN_FRAME or LAST3_FRAME.
-#if CONFIG_ONE_SIDED_COMPOUND
-int av1_get_pred_context_comp_ref_p(UNUSED const AV1_COMMON *cm,
-                                    const MACROBLOCKD *xd) {
-#else
 int av1_get_pred_context_comp_ref_p(const AV1_COMMON *cm,
                                     const MACROBLOCKD *xd) {
-#endif
   int pred_context;
   const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
   const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
   const int above_in_image = xd->up_available;
   const int left_in_image = xd->left_available;
 
 // Note:
 // The mode info data structure has a one element border above and to the
 // left of the entries correpsonding to real macroblocks.
 // The prediction flags in these dummy entries are initialised to 0.
-#if CONFIG_ONE_SIDED_COMPOUND  // No change to bitstream
+#if CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS  // No change to bitstream
   // Code seems to assume that signbias of cm->comp_bwd_ref[0] is always 1
   const int bwd_ref_sign_idx = 1;
 #else
   const int bwd_ref_sign_idx = cm->ref_frame_sign_bias[cm->comp_bwd_ref[0]];
-#endif
+#endif  // CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS
   const int fwd_ref_sign_idx = !bwd_ref_sign_idx;
 
+  (void)cm;
+
   if (above_in_image && left_in_image) {  // both edges available
     const int above_intra = !is_inter_block(above_mbmi);
     const int left_intra = !is_inter_block(left_mbmi);
 
     if (above_intra && left_intra) {  // intra/intra (2)
       pred_context = 2;
     } else if (above_intra || left_intra) {  // intra/inter
       const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
@@ -391,18 +669,21 @@ int av1_get_pred_context_comp_ref_p(cons
         else if (CHECK_GOLDEN_OR_LAST3(rfs) && !CHECK_GOLDEN_OR_LAST3(frfc))
           pred_context = 2;
         else
           pred_context = 4;
       } else {  // comp/comp
         if ((CHECK_LAST_OR_LAST2(frfa) && CHECK_LAST_OR_LAST2(frfl))) {
           pred_context = 4;
         } else {
-          // NOTE(zoeliu): Following assert may be removed once confirmed.
+// NOTE(zoeliu): Following assert may be removed once confirmed.
+#if !USE_UNI_COMP_REFS
+          // TODO(zoeliu): To further study the UNIDIR scenario
           assert(CHECK_GOLDEN_OR_LAST3(frfa) || CHECK_GOLDEN_OR_LAST3(frfl));
+#endif  // !USE_UNI_COMP_REFS
           pred_context = 2;
         }
       }
     }
   } else if (above_in_image || left_in_image) {  // one edge available
     const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi;
 
     if (!is_inter_block(edge_mbmi)) {
@@ -425,41 +706,38 @@ int av1_get_pred_context_comp_ref_p(cons
 }
 
 // Returns a context number for the given MB prediction signal
 // Signal the first reference frame for a compound mode be LAST,
 // conditioning on that it is known either LAST/LAST2.
 //
 // NOTE(zoeliu): The probability of ref_frame[0] is LAST_FRAME,
 // conditioning on it is either LAST_FRAME or LAST2_FRAME.
-#if CONFIG_ONE_SIDED_COMPOUND
-int av1_get_pred_context_comp_ref_p1(UNUSED const AV1_COMMON *cm,
-                                     const MACROBLOCKD *xd) {
-#else
 int av1_get_pred_context_comp_ref_p1(const AV1_COMMON *cm,
                                      const MACROBLOCKD *xd) {
-#endif
   int pred_context;
   const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
   const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
   const int above_in_image = xd->up_available;
   const int left_in_image = xd->left_available;
 
 // Note:
 // The mode info data structure has a one element border above and to the
 // left of the entries correpsonding to real macroblocks.
 // The prediction flags in these dummy entries are initialised to 0.
-#if CONFIG_ONE_SIDED_COMPOUND  // No change to bitstream
+#if CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS  // No change to bitstream
   // Code seems to assume that signbias of cm->comp_bwd_ref[0] is always 1
   const int bwd_ref_sign_idx = 1;
 #else
   const int bwd_ref_sign_idx = cm->ref_frame_sign_bias[cm->comp_bwd_ref[0]];
-#endif
+#endif  //  CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS
   const int fwd_ref_sign_idx = !bwd_ref_sign_idx;
 
+  (void)cm;
+
   if (above_in_image && left_in_image) {  // both edges available
     const int above_intra = !is_inter_block(above_mbmi);
     const int left_intra = !is_inter_block(left_mbmi);
 
     if (above_intra && left_intra) {  // intra/intra (2)
       pred_context = 2;
     } else if (above_intra || left_intra) {  // intra/inter
       const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
@@ -536,41 +814,38 @@ int av1_get_pred_context_comp_ref_p1(con
 }
 
 // Returns a context number for the given MB prediction signal
 // Signal the first reference frame for a compound mode be GOLDEN,
 // conditioning on that it is known either GOLDEN or LAST3.
 //
 // NOTE(zoeliu): The probability of ref_frame[0] is GOLDEN_FRAME,
 // conditioning on it is either GOLDEN or LAST3.
-#if CONFIG_ONE_SIDED_COMPOUND
-int av1_get_pred_context_comp_ref_p2(UNUSED const AV1_COMMON *cm,
-                                     const MACROBLOCKD *xd) {
-#else
 int av1_get_pred_context_comp_ref_p2(const AV1_COMMON *cm,
                                      const MACROBLOCKD *xd) {
-#endif
   int pred_context;
   const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
   const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
   const int above_in_image = xd->up_available;
   const int left_in_image = xd->left_available;
 
 // Note:
 // The mode info data structure has a one element border above and to the
 // left of the entries correpsonding to real macroblocks.
 // The prediction flags in these dummy entries are initialised to 0.
-#if CONFIG_ONE_SIDED_COMPOUND  // No change to bitstream
+#if CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS  // No change to bitstream
   // Code seems to assume that signbias of cm->comp_bwd_ref[0] is always 1
   const int bwd_ref_sign_idx = 1;
 #else
   const int bwd_ref_sign_idx = cm->ref_frame_sign_bias[cm->comp_bwd_ref[0]];
-#endif
+#endif  // CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS
   const int fwd_ref_sign_idx = !bwd_ref_sign_idx;
 
+  (void)cm;
+
   if (above_in_image && left_in_image) {  // both edges available
     const int above_intra = !is_inter_block(above_mbmi);
     const int left_intra = !is_inter_block(left_mbmi);
 
     if (above_intra && left_intra) {  // intra/intra (2)
       pred_context = 2;
     } else if (above_intra || left_intra) {  // intra/inter
       const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
@@ -641,41 +916,38 @@ int av1_get_pred_context_comp_ref_p2(con
   }
 
   assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
 
   return pred_context;
 }
 
 // Returns a context number for the given MB prediction signal
-#if CONFIG_ONE_SIDED_COMPOUND
-int av1_get_pred_context_comp_bwdref_p(UNUSED const AV1_COMMON *cm,
-                                       const MACROBLOCKD *xd) {
-#else
 int av1_get_pred_context_comp_bwdref_p(const AV1_COMMON *cm,
                                        const MACROBLOCKD *xd) {
-#endif
   int pred_context;
   const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
   const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
   const int above_in_image = xd->up_available;
   const int left_in_image = xd->left_available;
 
 // Note:
 // The mode info data structure has a one element border above and to the
 // left of the entries corresponding to real macroblocks.
 // The prediction flags in these dummy entries are initialized to 0.
-#if CONFIG_ONE_SIDED_COMPOUND  // No change to bitstream
+#if CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS  // No change to bitstream
   // Code seems to assume that signbias of cm->comp_bwd_ref[0] is always 1
   const int bwd_ref_sign_idx = 1;
 #else
   const int bwd_ref_sign_idx = cm->ref_frame_sign_bias[cm->comp_bwd_ref[0]];
-#endif
+#endif  // CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS
   const int fwd_ref_sign_idx = !bwd_ref_sign_idx;
 
+  (void)cm;
+
   if (above_in_image && left_in_image) {  // both edges available
     const int above_intra = !is_inter_block(above_mbmi);
     const int left_intra = !is_inter_block(left_mbmi);
 
     if (above_intra && left_intra) {  // intra/intra (2)
       pred_context = 2;
     } else if (above_intra || left_intra) {  // intra/inter
       const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
@@ -704,31 +976,37 @@ int av1_get_pred_context_comp_bwdref_p(c
 
       if (l_comp && a_comp) {  // comp/comp
         if (l_brf == a_brf && l_brf == cm->comp_bwd_ref[1]) {
           pred_context = 0;
         } else if (l_brf == cm->comp_bwd_ref[1] ||
                    a_brf == cm->comp_bwd_ref[1]) {
           pred_context = 1;
         } else {
-          // NOTE: Backward ref should be either BWDREF or ALTREF.
+// NOTE: Backward ref should be either BWDREF or ALTREF.
+#if !USE_UNI_COMP_REFS
+          // TODO(zoeliu): To further study the UNIDIR scenario
           assert(l_brf == a_brf && l_brf != cm->comp_bwd_ref[1]);
+#endif  // !USE_UNI_COMP_REFS
           pred_context = 3;
         }
       } else if (!l_comp && !a_comp) {  // single/single
         if (l_frf == a_frf && l_frf == cm->comp_bwd_ref[1]) {
           pred_context = 0;
         } else if (l_frf == cm->comp_bwd_ref[1] ||
                    a_frf == cm->comp_bwd_ref[1]) {
           pred_context = 1;
         } else if (l_frf == a_frf) {
           pred_context = 3;
         } else {
+#if !USE_UNI_COMP_REFS
+          // TODO(zoeliu): To further study the UNIDIR scenario
           assert(l_frf != a_frf && l_frf != cm->comp_bwd_ref[1] &&
                  a_frf != cm->comp_bwd_ref[1]);
+#endif  // !USE_UNI_COMP_REFS
           pred_context = 4;
         }
       } else {  // comp/single
         assert((l_comp && !a_comp) || (!l_comp && a_comp));
 
         if ((l_comp && l_brf == cm->comp_bwd_ref[1] &&
              a_frf == cm->comp_bwd_ref[1]) ||
             (a_comp && a_brf == cm->comp_bwd_ref[1] &&
--- a/third_party/aom/av1/common/pred_common.h
+++ b/third_party/aom/av1/common/pred_common.h
@@ -96,48 +96,114 @@ static INLINE aom_prob av1_get_intra_int
 }
 
 int av1_get_reference_mode_context(const AV1_COMMON *cm, const MACROBLOCKD *xd);
 
 static INLINE aom_prob av1_get_reference_mode_prob(const AV1_COMMON *cm,
                                                    const MACROBLOCKD *xd) {
   return cm->fc->comp_inter_prob[av1_get_reference_mode_context(cm, xd)];
 }
+#if CONFIG_NEW_MULTISYMBOL
+static INLINE aom_cdf_prob *av1_get_reference_mode_cdf(const AV1_COMMON *cm,
+                                                       const MACROBLOCKD *xd) {
+  return xd->tile_ctx->comp_inter_cdf[av1_get_reference_mode_context(cm, xd)];
+}
+#endif
+
+#if CONFIG_EXT_COMP_REFS
+int av1_get_comp_reference_type_context(const AV1_COMMON *cm,
+                                        const MACROBLOCKD *xd);
+
+static INLINE aom_prob av1_get_comp_reference_type_prob(const AV1_COMMON *cm,
+                                                        const MACROBLOCKD *xd) {
+  return cm->fc
+      ->comp_ref_type_prob[av1_get_comp_reference_type_context(cm, xd)];
+}
+
+int av1_get_pred_context_uni_comp_ref_p(const AV1_COMMON *cm,
+                                        const MACROBLOCKD *xd);
+
+static INLINE aom_prob av1_get_pred_prob_uni_comp_ref_p(const AV1_COMMON *cm,
+                                                        const MACROBLOCKD *xd) {
+  const int pred_context = av1_get_pred_context_uni_comp_ref_p(cm, xd);
+  return cm->fc->uni_comp_ref_prob[pred_context][0];
+}
+
+int av1_get_pred_context_uni_comp_ref_p1(const AV1_COMMON *cm,
+                                         const MACROBLOCKD *xd);
+
+static INLINE aom_prob
+av1_get_pred_prob_uni_comp_ref_p1(const AV1_COMMON *cm, const MACROBLOCKD *xd) {
+  const int pred_context = av1_get_pred_context_uni_comp_ref_p1(cm, xd);
+  return cm->fc->uni_comp_ref_prob[pred_context][1];
+}
+#endif  // CONFIG_EXT_COMP_REFS
 
 int av1_get_pred_context_comp_ref_p(const AV1_COMMON *cm,
                                     const MACROBLOCKD *xd);
 
+#if CONFIG_NEW_MULTISYMBOL
+static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_ref_p(const AV1_COMMON *cm,
+                                                        const MACROBLOCKD *xd) {
+  const int pred_context = av1_get_pred_context_comp_ref_p(cm, xd);
+  return xd->tile_ctx->comp_ref_cdf[pred_context][0];
+}
+#endif
+
 static INLINE aom_prob av1_get_pred_prob_comp_ref_p(const AV1_COMMON *cm,
                                                     const MACROBLOCKD *xd) {
   const int pred_context = av1_get_pred_context_comp_ref_p(cm, xd);
   return cm->fc->comp_ref_prob[pred_context][0];
 }
 
 #if CONFIG_EXT_REFS
 int av1_get_pred_context_comp_ref_p1(const AV1_COMMON *cm,
                                      const MACROBLOCKD *xd);
 
+#if CONFIG_NEW_MULTISYMBOL
+static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_ref_p1(
+    const AV1_COMMON *cm, const MACROBLOCKD *xd) {
+  const int pred_context = av1_get_pred_context_comp_ref_p1(cm, xd);
+  return xd->tile_ctx->comp_ref_cdf[pred_context][1];
+}
+#endif
+
 static INLINE aom_prob av1_get_pred_prob_comp_ref_p1(const AV1_COMMON *cm,
                                                      const MACROBLOCKD *xd) {
   const int pred_context = av1_get_pred_context_comp_ref_p1(cm, xd);
   return cm->fc->comp_ref_prob[pred_context][1];
 }
 
 int av1_get_pred_context_comp_ref_p2(const AV1_COMMON *cm,
                                      const MACROBLOCKD *xd);
 
+#if CONFIG_NEW_MULTISYMBOL
+static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_ref_p2(
+    const AV1_COMMON *cm, const MACROBLOCKD *xd) {
+  const int pred_context = av1_get_pred_context_comp_ref_p2(cm, xd);
+  return xd->tile_ctx->comp_ref_cdf[pred_context][2];
+}
+#endif
+
 static INLINE aom_prob av1_get_pred_prob_comp_ref_p2(const AV1_COMMON *cm,
                                                      const MACROBLOCKD *xd) {
   const int pred_context = av1_get_pred_context_comp_ref_p2(cm, xd);
   return cm->fc->comp_ref_prob[pred_context][2];
 }
 
 int av1_get_pred_context_comp_bwdref_p(const AV1_COMMON *cm,
                                        const MACROBLOCKD *xd);
 
+#if CONFIG_NEW_MULTISYMBOL
+static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_bwdref_p(
+    const AV1_COMMON *cm, const MACROBLOCKD *xd) {
+  const int pred_context = av1_get_pred_context_comp_bwdref_p(cm, xd);
+  return xd->tile_ctx->comp_bwdref_cdf[pred_context][0];
+}
+#endif  // CONFIG_NEW_MULTISYMBOL
 static INLINE aom_prob av1_get_pred_prob_comp_bwdref_p(const AV1_COMMON *cm,
                                                        const MACROBLOCKD *xd) {
   const int pred_context = av1_get_pred_context_comp_bwdref_p(cm, xd);
   return cm->fc->comp_bwdref_prob[pred_context][0];
 }
 #endif  // CONFIG_EXT_REFS
 
 int av1_get_pred_context_single_ref_p1(const MACROBLOCKD *xd);
@@ -172,16 +238,51 @@ static INLINE aom_prob av1_get_pred_prob
 int av1_get_pred_context_single_ref_p5(const MACROBLOCKD *xd);
 
 static INLINE aom_prob av1_get_pred_prob_single_ref_p5(const AV1_COMMON *cm,
                                                        const MACROBLOCKD *xd) {
   return cm->fc->single_ref_prob[av1_get_pred_context_single_ref_p5(xd)][4];
 }
 #endif  // CONFIG_EXT_REFS
 
+#if CONFIG_NEW_MULTISYMBOL
+static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p1(
+    const AV1_COMMON *cm, const MACROBLOCKD *xd) {
+  (void)cm;
+  return xd->tile_ctx
+      ->single_ref_cdf[av1_get_pred_context_single_ref_p1(xd)][0];
+}
+static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p2(
+    const AV1_COMMON *cm, const MACROBLOCKD *xd) {
+  (void)cm;
+  return xd->tile_ctx
+      ->single_ref_cdf[av1_get_pred_context_single_ref_p2(xd)][1];
+}
+#if CONFIG_EXT_REFS
+static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p3(
+    const AV1_COMMON *cm, const MACROBLOCKD *xd) {
+  (void)cm;
+  return xd->tile_ctx
+      ->single_ref_cdf[av1_get_pred_context_single_ref_p3(xd)][2];
+}
+static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p4(
+    const AV1_COMMON *cm, const MACROBLOCKD *xd) {
+  (void)cm;
+  return xd->tile_ctx
+      ->single_ref_cdf[av1_get_pred_context_single_ref_p4(xd)][3];
+}
+static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p5(
+    const AV1_COMMON *cm, const MACROBLOCKD *xd) {
+  (void)cm;
+  return xd->tile_ctx
+      ->single_ref_cdf[av1_get_pred_context_single_ref_p5(xd)][4];
+}
+#endif  // CONFIG_EXT_REFS
+#endif  // CONFIG_NEW_MULTISYMBOL
+
 #if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 int av1_get_inter_mode_context(const MACROBLOCKD *xd);
 
 static INLINE aom_prob av1_get_inter_mode_prob(const AV1_COMMON *cm,
                                                const MACROBLOCKD *xd) {
   return cm->fc->comp_inter_mode_prob[av1_get_inter_mode_context(xd)];
 }
 #endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
@@ -204,68 +305,13 @@ static INLINE int get_tx_size_context(co
                      : max_tx_size;
 
   if (!has_left) left_ctx = above_ctx;
 
   if (!has_above) above_ctx = left_ctx;
   return (above_ctx + left_ctx) > max_tx_size + TX_SIZE_LUMA_MIN;
 }
 
-#if CONFIG_VAR_TX
-static void update_tx_counts(AV1_COMMON *cm, MACROBLOCKD *xd,
-                             MB_MODE_INFO *mbmi, BLOCK_SIZE plane_bsize,
-                             TX_SIZE tx_size, int blk_row, int blk_col,
-                             TX_SIZE max_tx_size, int ctx) {
-  const struct macroblockd_plane *const pd = &xd->plane[0];
-  const BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
-  const int tx_row = blk_row >> (1 - pd->subsampling_y);
-  const int tx_col = blk_col >> (1 - pd->subsampling_x);
-  const TX_SIZE plane_tx_size = mbmi->inter_tx_size[tx_row][tx_col];
-  const int max_blocks_high = max_block_high(xd, plane_bsize, 0);
-  const int max_blocks_wide = max_block_wide(xd, plane_bsize, 0);
-
-  if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
-
-  if (tx_size == plane_tx_size) {
-    int depth;
-    depth = tx_size_to_depth(tx_size);
-    ++xd->counts->tx_size[max_tx_size - TX_SIZE_CTX_MIN][ctx][depth];
-    mbmi->tx_size = tx_size;
-  } else {
-    int bsl = b_width_log2_lookup[bsize];
-    int i;
-
-    assert(bsl > 0);
-    --bsl;
-
-    for (i = 0; i < 4; ++i) {
-      const int offsetr = blk_row + ((i >> 1) << bsl);
-      const int offsetc = blk_col + ((i & 0x01) << bsl);
-
-      if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) continue;
-      update_tx_counts(cm, xd, mbmi, plane_bsize, (TX_SIZE)(tx_size - 1),
-                       offsetr, offsetc, max_tx_size, ctx);
-    }
-  }
-}
-
-static INLINE void inter_block_tx_count_update(AV1_COMMON *cm, MACROBLOCKD *xd,
-                                               MB_MODE_INFO *mbmi,
-                                               BLOCK_SIZE plane_bsize,
-                                               int ctx) {
-  const int mi_width = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
-  const int mi_height = block_size_high[plane_bsize] >> tx_size_wide_log2[0];
-  TX_SIZE max_tx_size = max_txsize_lookup[plane_bsize];
-  int bh = tx_size_wide_unit[max_tx_size];
-  int idx, idy;
-
-  for (idy = 0; idy < mi_height; idy += bh)
-    for (idx = 0; idx < mi_width; idx += bh)
-      update_tx_counts(cm, xd, mbmi, plane_bsize, max_tx_size, idy, idx,
-                       max_tx_size, ctx);
-}
-#endif
-
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
 #endif  // AV1_COMMON_PRED_COMMON_H_
--- a/third_party/aom/av1/common/quant_common.c
+++ b/third_party/aom/av1/common/quant_common.c
@@ -346,17 +346,17 @@ qm_val_t *aom_iqmatrix(AV1_COMMON *cm, i
                        TX_SIZE tx_size, int is_intra) {
   return &cm->giqmatrix[qmlevel][!!is_chroma][!!is_intra][tx_size][0];
 }
 qm_val_t *aom_qmatrix(AV1_COMMON *cm, int qmlevel, int is_chroma,
                       TX_SIZE tx_size, int is_intra) {
   return &cm->gqmatrix[qmlevel][!!is_chroma][!!is_intra][tx_size][0];
 }
 
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
 #define QM_TOTAL_SIZE 3348
 #else
 #define QM_TOTAL_SIZE 3344
 #endif
 static uint16_t wt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE];
 static uint16_t iwt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE];
 
 void aom_qm_init(AV1_COMMON *cm) {
@@ -390,14331 +390,13656 @@ void aom_qm_init(AV1_COMMON *cm) {
    frame.
    Matrices for different QM levels have been rescaled in the
    frequency domain according to different nominal viewing
    distances.
  */
 static uint16_t iwt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE] = {
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        86, 173, 173, 334,
+        43, 86, 86, 166,
 #endif
         /* Size 4x4 */
-        65, 86, 146, 202, 86, 134, 189, 239, 146, 189, 274, 270, 202, 239, 270,
-        405,
+        32, 43, 73, 97, 43, 67, 94, 110, 73, 94, 137, 150, 97, 110, 150, 200,
         /* Size 8x8 */
-        64, 65, 77, 103, 136, 168, 196, 230, 65, 71, 81, 99, 126, 152, 178, 212,
-        77, 81, 108, 130, 156, 182, 200, 211, 103, 99, 130, 165, 195, 223, 222,
-        228, 136, 126, 156, 195, 235, 269, 290, 277, 168, 152, 182, 223, 269,
-        304, 296, 366, 196, 178, 200, 222, 290, 296, 368, 485, 230, 212, 211,
-        228, 277, 366, 485, 446,
+        32, 32, 38, 51, 68, 84, 95, 109, 32, 35, 40, 49, 63, 76, 89, 102, 38,
+        40, 54, 65, 78, 91, 98, 106, 51, 49, 65, 82, 97, 111, 113, 121, 68, 63,
+        78, 97, 117, 134, 138, 142, 84, 76, 91, 111, 134, 152, 159, 168, 95, 89,
+        98, 113, 138, 159, 183, 199, 109, 102, 106, 121, 142, 168, 199, 220,
         /* Size 16x16 */
-        64, 63, 63, 68, 72, 88, 97, 118, 131, 160, 166, 184, 199, 216, 234, 253,
-        63, 65, 65, 67, 69, 82, 89, 108, 119, 145, 150, 167, 182, 198, 215, 233,
-        63, 65, 67, 71, 73, 84, 91, 108, 118, 143, 148, 163, 176, 189, 205, 223,
-        68, 67, 71, 79, 85, 95, 102, 117, 126, 148, 153, 165, 170, 181, 192,
-        209, 72, 69, 73, 85, 97, 108, 114, 128, 136, 158, 162, 177, 190, 191,
-        225, 239, 88, 82, 84, 95, 108, 127, 134, 151, 159, 181, 185, 189, 210,
-        199, 232, 252, 97, 89, 91, 102, 114, 134, 142, 161, 171, 193, 198, 218,
-        209, 232, 231, 272, 118, 108, 108, 117, 128, 151, 161, 184, 196, 221,
-        226, 226, 227, 263, 231, 296, 131, 119, 118, 126, 136, 159, 171, 196,
-        210, 237, 242, 261, 273, 289, 245, 319, 160, 145, 143, 148, 158, 181,
-        193, 221, 237, 268, 274, 278, 290, 272, 260, 359, 166, 150, 148, 153,
-        162, 185, 198, 226, 242, 274, 280, 295, 286, 282, 297, 376, 184, 167,
-        163, 165, 177, 189, 218, 226, 261, 278, 295, 319, 319, 329, 347, 429,
-        199, 182, 176, 170, 190, 210, 209, 227, 273, 290, 286, 319, 351, 351,
-        430, 448, 216, 198, 189, 181, 191, 199, 232, 263, 289, 272, 282, 329,
-        351, 386, 385, 528, 234, 215, 205, 192, 225, 232, 231, 231, 245, 260,
-        297, 347, 430, 385, 425, 418, 253, 233, 223, 209, 239, 252, 272, 296,
-        319, 359, 376, 429, 448, 528, 418, 468,
+        32, 31, 31, 34, 36, 44, 48, 59, 65, 80, 83, 91, 97, 104, 111, 119, 31,
+        32, 32, 33, 34, 41, 44, 54, 59, 72, 75, 83, 90, 97, 104, 112, 31, 32,
+        33, 35, 36, 42, 45, 54, 59, 71, 74, 81, 86, 93, 100, 107, 34, 33, 35,
+        39, 42, 47, 51, 58, 63, 74, 76, 81, 84, 90, 97, 105, 36, 34, 36, 42, 48,
+        54, 57, 64, 68, 79, 81, 88, 91, 96, 102, 105, 44, 41, 42, 47, 54, 63,
+        67, 75, 79, 90, 92, 95, 100, 102, 109, 112, 48, 44, 45, 51, 57, 67, 71,
+        80, 85, 96, 99, 107, 108, 111, 117, 120, 59, 54, 54, 58, 64, 75, 80, 92,
+        98, 110, 113, 115, 116, 122, 125, 130, 65, 59, 59, 63, 68, 79, 85, 98,
+        105, 118, 121, 127, 130, 134, 135, 140, 80, 72, 71, 74, 79, 90, 96, 110,
+        118, 134, 137, 140, 143, 144, 146, 152, 83, 75, 74, 76, 81, 92, 99, 113,
+        121, 137, 140, 151, 152, 155, 158, 165, 91, 83, 81, 81, 88, 95, 107,
+        115, 127, 140, 151, 159, 166, 169, 173, 179, 97, 90, 86, 84, 91, 100,
+        108, 116, 130, 143, 152, 166, 174, 182, 189, 193, 104, 97, 93, 90, 96,
+        102, 111, 122, 134, 144, 155, 169, 182, 191, 200, 210, 111, 104, 100,
+        97, 102, 109, 117, 125, 135, 146, 158, 173, 189, 200, 210, 220, 119,
+        112, 107, 105, 105, 112, 120, 130, 140, 152, 165, 179, 193, 210, 220,
+        231,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 64, 68, 70, 72, 79, 88, 92, 97, 108, 118, 124, 131,
-        143, 160, 163, 166, 177, 184, 192, 199, 207, 216, 225, 234, 243, 253,
-        263, 63, 64, 64, 64, 64, 65, 68, 69, 70, 77, 85, 89, 93, 103, 113, 118,
-        125, 136, 152, 154, 157, 168, 175, 182, 189, 196, 204, 213, 221, 230,
-        239, 246, 63, 64, 65, 65, 65, 65, 67, 68, 69, 75, 82, 85, 89, 99, 108,
-        113, 119, 130, 145, 147, 150, 160, 167, 174, 182, 190, 198, 206, 215,
-        224, 233, 249, 63, 64, 65, 65, 66, 67, 69, 70, 71, 77, 83, 86, 90, 99,
-        108, 113, 119, 129, 144, 146, 149, 159, 165, 173, 180, 187, 195, 202,
-        211, 219, 228, 229, 63, 64, 65, 66, 67, 68, 71, 72, 73, 78, 84, 88, 91,
-        100, 108, 113, 118, 129, 143, 145, 148, 157, 163, 169, 176, 181, 189,
-        197, 205, 214, 223, 237, 64, 65, 65, 67, 68, 71, 74, 75, 77, 81, 85, 88,
-        92, 99, 107, 111, 116, 126, 139, 141, 144, 152, 157, 163, 170, 178, 189,
-        196, 204, 212, 220, 223, 68, 68, 67, 69, 71, 74, 79, 82, 85, 90, 95, 99,
-        102, 109, 117, 121, 126, 136, 148, 151, 153, 161, 165, 166, 170, 176,
-        181, 184, 192, 200, 209, 228, 70, 69, 68, 70, 72, 75, 82, 86, 91, 95,
-        101, 104, 107, 114, 122, 126, 131, 141, 153, 155, 158, 166, 167, 173,
-        186, 193, 198, 191, 196, 203, 210, 208, 72, 70, 69, 71, 73, 77, 85, 91,
-        97, 101, 108, 111, 114, 120, 128, 132, 136, 146, 158, 160, 162, 171,
-        177, 186, 190, 185, 191, 204, 225, 232, 239, 218, 79, 77, 75, 77, 78,
-        81, 90, 95, 101, 108, 116, 119, 122, 130, 138, 142, 147, 156, 168, 171,
-        173, 182, 188, 186, 187, 200, 213, 219, 204, 211, 218, 262, 88, 85, 82,
-        83, 84, 85, 95, 101, 108, 116, 127, 130, 134, 143, 151, 155, 159, 169,
-        181, 183, 185, 192, 189, 192, 210, 213, 199, 205, 232, 245, 252, 226,
-        92, 89, 85, 86, 88, 88, 99, 104, 111, 119, 130, 134, 138, 148, 156, 160,
-        165, 175, 187, 189, 191, 197, 198, 213, 207, 203, 226, 239, 227, 218,
-        225, 273, 97, 93, 89, 90, 91, 92, 102, 107, 114, 122, 134, 138, 142,
-        153, 161, 166, 171, 181, 193, 195, 198, 206, 218, 210, 209, 237, 232,
-        215, 231, 266, 272, 232, 108, 103, 99, 99, 100, 99, 109, 114, 120, 130,
-        143, 148, 153, 165, 174, 179, 185, 195, 208, 210, 213, 223, 221, 216,
-        239, 222, 220, 263, 264, 228, 234, 297, 118, 113, 108, 108, 108, 107,
-        117, 122, 128, 138, 151, 156, 161, 174, 184, 190, 196, 207, 221, 223,
-        226, 232, 226, 248, 227, 235, 263, 232, 231, 292, 296, 241, 124, 118,
-        113, 113, 113, 111, 121, 126, 132, 142, 155, 160, 166, 179, 190, 196,
-        203, 214, 229, 231, 234, 238, 248, 241, 245, 271, 233, 263, 290, 241,
-        244, 324, 131, 125, 119, 119, 118, 116, 126, 131, 136, 147, 159, 165,
-        171, 185, 196, 203, 210, 222, 237, 239, 242, 251, 261, 246, 273, 242,
-        289, 282, 245, 301, 319, 250, 143, 136, 130, 129, 129, 126, 136, 141,
-        146, 156, 169, 175, 181, 195, 207, 214, 222, 235, 251, 253, 256, 269,
-        257, 286, 252, 290, 272, 255, 327, 277, 257, 349, 160, 152, 145, 144,
-        143, 139, 148, 153, 158, 168, 181, 187, 193, 208, 221, 229, 237, 251,
-        268, 271, 274, 280, 278, 276, 290, 286, 272, 320, 260, 310, 359, 264,
-        163, 154, 147, 146, 145, 141, 151, 155, 160, 171, 183, 189, 195, 210,
-        223, 231, 239, 253, 271, 274, 277, 286, 305, 280, 307, 279, 335, 270,
-        343, 311, 272, 394, 166, 157, 150, 149, 148, 144, 153, 158, 162, 173,
-        185, 191, 198, 213, 226, 234, 242, 256, 274, 277, 280, 292, 295, 331,
-        286, 336, 282, 366, 297, 309, 376, 278, 177, 168, 160, 159, 157, 152,
-        161, 166, 171, 182, 192, 197, 206, 223, 232, 238, 251, 269, 280, 286,
-        292, 304, 300, 306, 346, 296, 357, 301, 348, 366, 289, 409, 184, 175,
-        167, 165, 163, 157, 165, 167, 177, 188, 189, 198, 218, 221, 226, 248,
-        261, 257, 278, 305, 295, 300, 319, 307, 319, 351, 329, 350, 347, 316,
-        429, 296, 192, 182, 174, 173, 169, 163, 166, 173, 186, 186, 192, 213,
-        210, 216, 248, 241, 246, 286, 276, 280, 331, 306, 307, 334, 313, 334,
-        351, 373, 337, 408, 309, 469, 199, 189, 182, 180, 176, 170, 170, 186,
-        190, 187, 210, 207, 209, 239, 227, 245, 273, 252, 290, 307, 286, 346,
-        319, 313, 351, 321, 351, 345, 430, 321, 448, 316, 207, 196, 190, 187,
-        181, 178, 176, 193, 185, 200, 213, 203, 237, 222, 235, 271, 242, 290,
-        286, 279, 336, 296, 351, 334, 321, 368, 329, 369, 337, 485, 328, 484,
-        216, 204, 198, 195, 189, 189, 181, 198, 191, 213, 199, 226, 232, 220,
-        263, 233, 289, 272, 272, 335, 282, 357, 329, 351, 351, 329, 386, 337,
-        385, 345, 528, 336, 225, 213, 206, 202, 197, 196, 184, 191, 204, 219,
-        205, 239, 215, 263, 232, 263, 282, 255, 320, 270, 366, 301, 350, 373,
-        345, 369, 337, 405, 345, 401, 353, 574, 234, 221, 215, 211, 205, 204,
-        192, 196, 225, 204, 232, 227, 231, 264, 231, 290, 245, 327, 260, 343,
-        297, 348, 347, 337, 430, 337, 385, 345, 425, 353, 418, 361, 243, 230,
-        224, 219, 214, 212, 200, 203, 232, 211, 245, 218, 266, 228, 292, 241,
-        301, 277, 310, 311, 309, 366, 316, 408, 321, 485, 345, 401, 353, 446,
-        362, 436, 253, 239, 233, 228, 223, 220, 209, 210, 239, 218, 252, 225,
-        272, 234, 296, 244, 319, 257, 359, 272, 376, 289, 429, 309, 448, 328,
-        528, 353, 418, 362, 468, 370, 263, 246, 249, 229, 237, 223, 228, 208,
-        218, 262, 226, 273, 232, 297, 241, 324, 250, 349, 264, 394, 278, 409,
-        296, 469, 316, 484, 336, 574, 361, 436, 370, 491,
+        32, 31, 31, 31, 31, 32, 34, 35, 36, 39, 44, 46, 48, 54, 59, 62, 65, 71,
+        80, 81, 83, 88, 91, 94, 97, 101, 104, 107, 111, 115, 119, 123, 31, 32,
+        32, 32, 32, 32, 34, 34, 35, 38, 42, 44, 46, 51, 56, 59, 62, 68, 76, 77,
+        78, 84, 86, 89, 92, 95, 99, 102, 105, 109, 113, 116, 31, 32, 32, 32, 32,
+        32, 33, 34, 34, 37, 41, 42, 44, 49, 54, 56, 59, 65, 72, 73, 75, 80, 83,
+        86, 90, 93, 97, 101, 104, 108, 112, 116, 31, 32, 32, 32, 33, 33, 34, 35,
+        35, 38, 41, 43, 45, 49, 54, 56, 59, 64, 72, 73, 74, 79, 82, 85, 88, 91,
+        94, 97, 101, 104, 107, 111, 31, 32, 32, 33, 33, 34, 35, 36, 36, 39, 42,
+        44, 45, 50, 54, 56, 59, 64, 71, 72, 74, 78, 81, 84, 86, 89, 93, 96, 100,
+        104, 107, 111, 32, 32, 32, 33, 34, 35, 37, 37, 38, 40, 42, 44, 46, 49,
+        53, 55, 58, 63, 69, 70, 72, 76, 79, 82, 85, 89, 93, 96, 99, 102, 106,
+        109, 34, 34, 33, 34, 35, 37, 39, 41, 42, 45, 47, 49, 51, 54, 58, 60, 63,
+        68, 74, 75, 76, 80, 81, 82, 84, 87, 90, 93, 97, 101, 105, 110, 35, 34,
+        34, 35, 36, 37, 41, 43, 45, 47, 50, 52, 53, 57, 61, 63, 65, 70, 76, 77,
+        79, 82, 84, 86, 89, 91, 92, 93, 96, 100, 103, 107, 36, 35, 34, 35, 36,
+        38, 42, 45, 48, 50, 54, 55, 57, 60, 64, 66, 68, 73, 79, 80, 81, 85, 88,
+        90, 91, 93, 96, 99, 102, 103, 105, 107, 39, 38, 37, 38, 39, 40, 45, 47,
+        50, 54, 58, 59, 61, 65, 69, 71, 73, 78, 84, 85, 86, 91, 92, 92, 95, 98,
+        100, 101, 103, 106, 110, 114, 44, 42, 41, 41, 42, 42, 47, 50, 54, 58,
+        63, 65, 67, 71, 75, 77, 79, 84, 90, 91, 92, 95, 95, 97, 100, 101, 102,
+        105, 109, 111, 112, 114, 46, 44, 42, 43, 44, 44, 49, 52, 55, 59, 65, 67,
+        69, 74, 78, 80, 82, 87, 93, 94, 95, 98, 100, 103, 102, 105, 108, 110,
+        111, 113, 117, 121, 48, 46, 44, 45, 45, 46, 51, 53, 57, 61, 67, 69, 71,
+        76, 80, 83, 85, 90, 96, 97, 99, 103, 107, 105, 108, 111, 111, 113, 117,
+        119, 120, 122, 54, 51, 49, 49, 50, 49, 54, 57, 60, 65, 71, 74, 76, 82,
+        87, 89, 92, 97, 104, 105, 106, 111, 110, 111, 114, 113, 116, 120, 120,
+        121, 125, 130, 59, 56, 54, 54, 54, 53, 58, 61, 64, 69, 75, 78, 80, 87,
+        92, 95, 98, 103, 110, 111, 113, 115, 115, 119, 116, 120, 122, 122, 125,
+        129, 130, 130, 62, 59, 56, 56, 56, 55, 60, 63, 66, 71, 77, 80, 83, 89,
+        95, 98, 101, 107, 114, 115, 117, 119, 123, 121, 125, 126, 125, 129, 131,
+        131, 135, 140, 65, 62, 59, 59, 59, 58, 63, 65, 68, 73, 79, 82, 85, 92,
+        98, 101, 105, 111, 118, 119, 121, 126, 127, 128, 130, 130, 134, 133,
+        135, 140, 140, 140, 71, 68, 65, 64, 64, 63, 68, 70, 73, 78, 84, 87, 90,
+        97, 103, 107, 111, 117, 125, 126, 128, 134, 132, 136, 133, 138, 137,
+        140, 143, 142, 145, 150, 80, 76, 72, 72, 71, 69, 74, 76, 79, 84, 90, 93,
+        96, 104, 110, 114, 118, 125, 134, 135, 137, 139, 140, 139, 143, 142,
+        144, 146, 146, 151, 152, 151, 81, 77, 73, 73, 72, 70, 75, 77, 80, 85,
+        91, 94, 97, 105, 111, 115, 119, 126, 135, 137, 138, 144, 147, 146, 148,
+        149, 151, 150, 156, 155, 157, 163, 83, 78, 75, 74, 74, 72, 76, 79, 81,
+        86, 92, 95, 99, 106, 113, 117, 121, 128, 137, 138, 140, 147, 151, 156,
+        152, 157, 155, 161, 158, 162, 165, 164, 88, 84, 80, 79, 78, 76, 80, 82,
+        85, 91, 95, 98, 103, 111, 115, 119, 126, 134, 139, 144, 147, 152, 154,
+        158, 163, 159, 165, 163, 168, 168, 169, 176, 91, 86, 83, 82, 81, 79, 81,
+        84, 88, 92, 95, 100, 107, 110, 115, 123, 127, 132, 140, 147, 151, 154,
+        159, 161, 166, 171, 169, 173, 173, 176, 179, 177, 94, 89, 86, 85, 84,
+        82, 82, 86, 90, 92, 97, 103, 105, 111, 119, 121, 128, 136, 139, 146,
+        156, 158, 161, 166, 168, 174, 179, 178, 180, 183, 183, 190, 97, 92, 90,
+        88, 86, 85, 84, 89, 91, 95, 100, 102, 108, 114, 116, 125, 130, 133, 143,
+        148, 152, 163, 166, 168, 174, 176, 182, 187, 189, 188, 193, 191, 101,
+        95, 93, 91, 89, 89, 87, 91, 93, 98, 101, 105, 111, 113, 120, 126, 130,
+        138, 142, 149, 157, 159, 171, 174, 176, 183, 184, 191, 195, 199, 197,
+        204, 104, 99, 97, 94, 93, 93, 90, 92, 96, 100, 102, 108, 111, 116, 122,
+        125, 134, 137, 144, 151, 155, 165, 169, 179, 182, 184, 191, 193, 200,
+        204, 210, 206, 107, 102, 101, 97, 96, 96, 93, 93, 99, 101, 105, 110,
+        113, 120, 122, 129, 133, 140, 146, 150, 161, 163, 173, 178, 187, 191,
+        193, 200, 202, 210, 214, 222, 111, 105, 104, 101, 100, 99, 97, 96, 102,
+        103, 109, 111, 117, 120, 125, 131, 135, 143, 146, 156, 158, 168, 173,
+        180, 189, 195, 200, 202, 210, 212, 220, 224, 115, 109, 108, 104, 104,
+        102, 101, 100, 103, 106, 111, 113, 119, 121, 129, 131, 140, 142, 151,
+        155, 162, 168, 176, 183, 188, 199, 204, 210, 212, 220, 222, 230, 119,
+        113, 112, 107, 107, 106, 105, 103, 105, 110, 112, 117, 120, 125, 130,
+        135, 140, 145, 152, 157, 165, 169, 179, 183, 193, 197, 210, 214, 220,
+        222, 231, 232, 123, 116, 116, 111, 111, 109, 110, 107, 107, 114, 114,
+        121, 122, 130, 130, 140, 140, 150, 151, 163, 164, 176, 177, 190, 191,
+        204, 206, 222, 224, 230, 232, 242,
         /* Size 4x8 */
-        64, 85, 151, 202, 66, 85, 138, 188, 75, 116, 168, 205, 99, 142, 207,
-        256, 131, 169, 250, 260, 161, 193, 285, 301, 188, 214, 299, 358, 219,
-        218, 266, 343,
+        32, 42, 75, 91, 33, 42, 69, 86, 37, 58, 84, 91, 49, 71, 103, 110, 65,
+        84, 125, 128, 80, 97, 142, 152, 91, 100, 145, 178, 104, 112, 146, 190,
         /* Size 8x4 */
-        64, 66, 75, 99, 131, 161, 188, 219, 85, 85, 116, 142, 169, 193, 214,
-        218, 151, 138, 168, 207, 250, 285, 299, 266, 202, 188, 205, 256, 260,
-        301, 358, 343,
+        32, 33, 37, 49, 65, 80, 91, 104, 42, 42, 58, 71, 84, 97, 100, 112, 75,
+        69, 84, 103, 125, 142, 145, 146, 91, 86, 91, 110, 128, 152, 178, 190,
         /* Size 8x16 */
-        64, 64, 72, 107, 131, 174, 199, 229, 63, 66, 69, 99, 119, 157, 182, 211,
-        64, 68, 73, 100, 118, 154, 174, 202, 68, 74, 85, 109, 126, 159, 170,
-        190, 72, 77, 96, 120, 136, 168, 179, 221, 88, 86, 107, 143, 159, 191,
-        205, 235, 96, 93, 113, 152, 171, 204, 232, 256, 117, 108, 127, 174, 196,
-        232, 231, 282, 130, 117, 136, 185, 210, 249, 237, 292, 159, 140, 158,
-        208, 236, 282, 285, 309, 165, 145, 162, 212, 242, 289, 331, 310, 183,
-        160, 176, 218, 259, 294, 333, 325, 198, 174, 187, 209, 273, 344, 314,
-        327, 215, 188, 210, 229, 248, 281, 350, 337, 232, 205, 222, 261, 319,
-        363, 364, 342, 252, 223, 237, 272, 320, 378, 451, 431,
+        32, 32, 36, 53, 65, 87, 93, 99, 31, 33, 34, 49, 59, 78, 86, 93, 32, 34,
+        36, 50, 59, 77, 82, 89, 34, 37, 42, 54, 63, 79, 80, 88, 36, 38, 48, 60,
+        68, 84, 86, 90, 44, 43, 53, 71, 79, 95, 94, 97, 48, 46, 56, 76, 85, 102,
+        105, 105, 58, 54, 63, 87, 98, 116, 112, 115, 65, 58, 68, 92, 105, 124,
+        122, 124, 79, 70, 79, 104, 118, 141, 135, 135, 82, 72, 81, 106, 121,
+        144, 149, 146, 91, 80, 88, 106, 130, 148, 162, 159, 97, 86, 94, 107,
+        128, 157, 167, 171, 103, 93, 98, 114, 131, 150, 174, 186, 110, 100, 101,
+        117, 138, 161, 183, 193, 118, 107, 105, 118, 136, 157, 182, 203,
         /* Size 16x8 */
-        64, 63, 64, 68, 72, 88, 96, 117, 130, 159, 165, 183, 198, 215, 232, 252,
-        64, 66, 68, 74, 77, 86, 93, 108, 117, 140, 145, 160, 174, 188, 205, 223,
-        72, 69, 73, 85, 96, 107, 113, 127, 136, 158, 162, 176, 187, 210, 222,
-        237, 107, 99, 100, 109, 120, 143, 152, 174, 185, 208, 212, 218, 209,
-        229, 261, 272, 131, 119, 118, 126, 136, 159, 171, 196, 210, 236, 242,
-        259, 273, 248, 319, 320, 174, 157, 154, 159, 168, 191, 204, 232, 249,
-        282, 289, 294, 344, 281, 363, 378, 199, 182, 174, 170, 179, 205, 232,
-        231, 237, 285, 331, 333, 314, 350, 364, 451, 229, 211, 202, 190, 221,
-        235, 256, 282, 292, 309, 310, 325, 327, 337, 342, 431,
+        32, 31, 32, 34, 36, 44, 48, 58, 65, 79, 82, 91, 97, 103, 110, 118, 32,
+        33, 34, 37, 38, 43, 46, 54, 58, 70, 72, 80, 86, 93, 100, 107, 36, 34,
+        36, 42, 48, 53, 56, 63, 68, 79, 81, 88, 94, 98, 101, 105, 53, 49, 50,
+        54, 60, 71, 76, 87, 92, 104, 106, 106, 107, 114, 117, 118, 65, 59, 59,
+        63, 68, 79, 85, 98, 105, 118, 121, 130, 128, 131, 138, 136, 87, 78, 77,
+        79, 84, 95, 102, 116, 124, 141, 144, 148, 157, 150, 161, 157, 93, 86,
+        82, 80, 86, 94, 105, 112, 122, 135, 149, 162, 167, 174, 183, 182, 99,
+        93, 89, 88, 90, 97, 105, 115, 124, 135, 146, 159, 171, 186, 193, 203,
         /* Size 16x32 */
-        64, 63, 64, 68, 72, 88, 107, 118, 131, 158, 174, 186, 199, 214, 229,
-        245, 63, 64, 65, 68, 71, 85, 103, 113, 124, 151, 165, 176, 189, 202,
-        216, 229, 63, 65, 66, 67, 69, 82, 99, 108, 119, 144, 157, 169, 182, 196,
-        211, 232, 63, 65, 67, 69, 71, 83, 99, 108, 119, 143, 156, 168, 180, 193,
-        206, 213, 64, 65, 68, 71, 73, 84, 100, 108, 118, 142, 154, 165, 174,
-        188, 202, 221, 64, 66, 71, 74, 77, 85, 99, 107, 116, 138, 150, 159, 172,
-        188, 200, 210, 68, 68, 74, 79, 85, 96, 109, 117, 126, 147, 159, 163,
-        170, 176, 190, 214, 70, 69, 75, 82, 90, 101, 114, 122, 131, 152, 164,
-        169, 187, 184, 192, 195, 72, 69, 77, 86, 96, 108, 120, 128, 136, 157,
-        168, 183, 179, 200, 221, 205, 79, 75, 81, 90, 101, 116, 130, 138, 147,
-        168, 179, 183, 195, 205, 201, 248, 88, 82, 86, 96, 107, 126, 143, 151,
-        159, 180, 191, 189, 205, 200, 235, 213, 92, 86, 89, 99, 110, 130, 147,
-        156, 165, 186, 197, 211, 198, 231, 209, 260, 96, 90, 93, 102, 113, 134,
-        152, 161, 171, 192, 204, 210, 232, 208, 256, 220, 107, 99, 100, 109,
-        120, 142, 164, 174, 185, 207, 219, 213, 220, 256, 218, 284, 117, 108,
-        108, 117, 127, 150, 174, 184, 196, 220, 232, 242, 231, 228, 282, 230,
-        123, 114, 112, 121, 132, 155, 179, 190, 203, 228, 240, 242, 266, 257,
-        234, 311, 130, 120, 117, 126, 136, 159, 185, 196, 210, 236, 249, 242,
-        237, 269, 292, 239, 142, 131, 127, 136, 146, 169, 195, 207, 222, 250,
-        264, 276, 276, 260, 264, 335, 159, 145, 140, 148, 158, 181, 208, 221,
-        236, 267, 282, 279, 285, 309, 309, 253, 162, 148, 142, 151, 160, 183,
-        210, 224, 239, 270, 285, 275, 275, 263, 293, 380, 165, 151, 145, 153,
-        162, 185, 212, 226, 242, 273, 289, 314, 331, 348, 310, 268, 176, 161,
-        154, 161, 171, 193, 219, 232, 251, 285, 298, 305, 306, 301, 339, 393,
-        183, 167, 160, 165, 176, 203, 218, 226, 259, 293, 294, 301, 333, 337,
-        325, 285, 191, 174, 167, 167, 182, 208, 210, 231, 276, 275, 298, 327,
-        330, 365, 375, 451, 198, 181, 174, 171, 187, 210, 209, 259, 273, 269,
-        344, 318, 314, 340, 327, 304, 206, 188, 181, 177, 205, 214, 214, 264,
-        242, 299, 337, 312, 358, 358, 454, 465, 215, 195, 188, 184, 210, 199,
-        229, 264, 248, 325, 281, 372, 350, 328, 337, 324, 223, 203, 196, 191,
-        216, 205, 257, 232, 272, 321, 288, 394, 327, 392, 388, 550, 232, 211,
-        205, 198, 222, 212, 261, 232, 319, 260, 363, 340, 364, 390, 342, 348,
-        242, 219, 214, 205, 229, 218, 266, 238, 319, 266, 382, 301, 462, 343,
-        430, 420, 252, 228, 223, 212, 237, 225, 272, 244, 320, 272, 378, 308,
-        451, 351, 431, 356, 262, 232, 237, 214, 220, 270, 232, 318, 250, 385,
-        278, 457, 315, 543, 359, 471,
+        32, 31, 32, 34, 36, 44, 53, 59, 65, 79, 87, 90, 93, 96, 99, 102, 31, 32,
+        32, 34, 35, 42, 51, 56, 62, 75, 82, 85, 88, 91, 94, 97, 31, 32, 33, 33,
+        34, 41, 49, 54, 59, 72, 78, 82, 86, 90, 93, 97, 31, 32, 33, 34, 35, 41,
+        49, 54, 59, 71, 78, 81, 84, 87, 90, 93, 32, 32, 34, 35, 36, 42, 50, 54,
+        59, 71, 77, 80, 82, 86, 89, 93, 32, 33, 35, 37, 38, 42, 49, 53, 58, 69,
+        75, 78, 82, 86, 89, 92, 34, 34, 37, 39, 42, 48, 54, 58, 63, 73, 79, 78,
+        80, 83, 88, 92, 35, 34, 37, 41, 45, 50, 57, 61, 65, 76, 82, 83, 84, 84,
+        87, 90, 36, 34, 38, 43, 48, 54, 60, 64, 68, 78, 84, 87, 86, 89, 90, 90,
+        39, 37, 40, 45, 50, 58, 65, 69, 73, 84, 89, 89, 91, 91, 93, 96, 44, 41,
+        43, 48, 53, 63, 71, 75, 79, 90, 95, 93, 94, 95, 97, 97, 46, 43, 44, 49,
+        55, 65, 73, 78, 82, 93, 98, 100, 98, 100, 99, 103, 48, 45, 46, 51, 56,
+        67, 76, 80, 85, 96, 102, 102, 105, 102, 105, 104, 53, 49, 50, 54, 60,
+        71, 82, 87, 92, 103, 109, 107, 107, 110, 107, 111, 58, 54, 54, 58, 63,
+        75, 87, 92, 98, 110, 116, 115, 112, 111, 115, 112, 61, 57, 56, 60, 66,
+        77, 89, 95, 101, 114, 120, 118, 119, 118, 116, 120, 65, 60, 58, 63, 68,
+        79, 92, 98, 105, 118, 124, 123, 122, 123, 124, 121, 71, 65, 63, 68, 73,
+        84, 97, 103, 111, 125, 132, 132, 130, 128, 127, 130, 79, 72, 70, 74, 79,
+        90, 104, 110, 118, 133, 141, 136, 135, 135, 135, 131, 81, 74, 71, 75,
+        80, 91, 105, 112, 119, 135, 142, 140, 140, 138, 139, 142, 82, 75, 72,
+        76, 81, 92, 106, 113, 121, 136, 144, 151, 149, 149, 146, 143, 88, 80,
+        77, 80, 85, 97, 108, 115, 126, 142, 149, 153, 153, 152, 152, 154, 91,
+        83, 80, 81, 88, 100, 106, 114, 130, 142, 148, 155, 162, 160, 159, 155,
+        94, 85, 83, 82, 91, 100, 105, 118, 131, 137, 153, 160, 165, 167, 166,
+        168, 97, 88, 86, 85, 94, 100, 107, 123, 128, 140, 157, 161, 167, 173,
+        171, 169, 100, 91, 89, 87, 97, 100, 111, 121, 127, 145, 152, 164, 173,
+        178, 182, 181, 103, 94, 93, 90, 98, 101, 114, 120, 131, 144, 150, 170,
+        174, 180, 186, 183, 107, 97, 96, 93, 100, 104, 117, 119, 136, 142, 155,
+        168, 177, 187, 191, 198, 110, 101, 100, 97, 101, 108, 117, 123, 138,
+        141, 161, 165, 183, 188, 193, 200, 114, 104, 104, 100, 103, 112, 117,
+        127, 137, 146, 159, 167, 185, 190, 201, 206, 118, 108, 107, 103, 105,
+        115, 118, 131, 136, 151, 157, 172, 182, 197, 203, 208, 122, 111, 111,
+        107, 107, 119, 119, 136, 136, 156, 156, 178, 179, 203, 204, 217,
         /* Size 32x16 */
-        64, 63, 63, 63, 64, 64, 68, 70, 72, 79, 88, 92, 96, 107, 117, 123, 130,
-        142, 159, 162, 165, 176, 183, 191, 198, 206, 215, 223, 232, 242, 252,
-        262, 63, 64, 65, 65, 65, 66, 68, 69, 69, 75, 82, 86, 90, 99, 108, 114,
-        120, 131, 145, 148, 151, 161, 167, 174, 181, 188, 195, 203, 211, 219,
-        228, 232, 64, 65, 66, 67, 68, 71, 74, 75, 77, 81, 86, 89, 93, 100, 108,
-        112, 117, 127, 140, 142, 145, 154, 160, 167, 174, 181, 188, 196, 205,
-        214, 223, 237, 68, 68, 67, 69, 71, 74, 79, 82, 86, 90, 96, 99, 102, 109,
-        117, 121, 126, 136, 148, 151, 153, 161, 165, 167, 171, 177, 184, 191,
-        198, 205, 212, 214, 72, 71, 69, 71, 73, 77, 85, 90, 96, 101, 107, 110,
-        113, 120, 127, 132, 136, 146, 158, 160, 162, 171, 176, 182, 187, 205,
-        210, 216, 222, 229, 237, 220, 88, 85, 82, 83, 84, 85, 96, 101, 108, 116,
-        126, 130, 134, 142, 150, 155, 159, 169, 181, 183, 185, 193, 203, 208,
-        210, 214, 199, 205, 212, 218, 225, 270, 107, 103, 99, 99, 100, 99, 109,
-        114, 120, 130, 143, 147, 152, 164, 174, 179, 185, 195, 208, 210, 212,
-        219, 218, 210, 209, 214, 229, 257, 261, 266, 272, 232, 118, 113, 108,
-        108, 108, 107, 117, 122, 128, 138, 151, 156, 161, 174, 184, 190, 196,
-        207, 221, 224, 226, 232, 226, 231, 259, 264, 264, 232, 232, 238, 244,
-        318, 131, 124, 119, 119, 118, 116, 126, 131, 136, 147, 159, 165, 171,
-        185, 196, 203, 210, 222, 236, 239, 242, 251, 259, 276, 273, 242, 248,
-        272, 319, 319, 320, 250, 158, 151, 144, 143, 142, 138, 147, 152, 157,
-        168, 180, 186, 192, 207, 220, 228, 236, 250, 267, 270, 273, 285, 293,
-        275, 269, 299, 325, 321, 260, 266, 272, 385, 174, 165, 157, 156, 154,
-        150, 159, 164, 168, 179, 191, 197, 204, 219, 232, 240, 249, 264, 282,
-        285, 289, 298, 294, 298, 344, 337, 281, 288, 363, 382, 378, 278, 186,
-        176, 169, 168, 165, 159, 163, 169, 183, 183, 189, 211, 210, 213, 242,
-        242, 242, 276, 279, 275, 314, 305, 301, 327, 318, 312, 372, 394, 340,
-        301, 308, 457, 199, 189, 182, 180, 174, 172, 170, 187, 179, 195, 205,
-        198, 232, 220, 231, 266, 237, 276, 285, 275, 331, 306, 333, 330, 314,
-        358, 350, 327, 364, 462, 451, 315, 214, 202, 196, 193, 188, 188, 176,
-        184, 200, 205, 200, 231, 208, 256, 228, 257, 269, 260, 309, 263, 348,
-        301, 337, 365, 340, 358, 328, 392, 390, 343, 351, 543, 229, 216, 211,
-        206, 202, 200, 190, 192, 221, 201, 235, 209, 256, 218, 282, 234, 292,
-        264, 309, 293, 310, 339, 325, 375, 327, 454, 337, 388, 342, 430, 431,
-        359, 245, 229, 232, 213, 221, 210, 214, 195, 205, 248, 213, 260, 220,
-        284, 230, 311, 239, 335, 253, 380, 268, 393, 285, 451, 304, 465, 324,
-        550, 348, 420, 356, 471,
+        32, 31, 31, 31, 32, 32, 34, 35, 36, 39, 44, 46, 48, 53, 58, 61, 65, 71,
+        79, 81, 82, 88, 91, 94, 97, 100, 103, 107, 110, 114, 118, 122, 31, 32,
+        32, 32, 32, 33, 34, 34, 34, 37, 41, 43, 45, 49, 54, 57, 60, 65, 72, 74,
+        75, 80, 83, 85, 88, 91, 94, 97, 101, 104, 108, 111, 32, 32, 33, 33, 34,
+        35, 37, 37, 38, 40, 43, 44, 46, 50, 54, 56, 58, 63, 70, 71, 72, 77, 80,
+        83, 86, 89, 93, 96, 100, 104, 107, 111, 34, 34, 33, 34, 35, 37, 39, 41,
+        43, 45, 48, 49, 51, 54, 58, 60, 63, 68, 74, 75, 76, 80, 81, 82, 85, 87,
+        90, 93, 97, 100, 103, 107, 36, 35, 34, 35, 36, 38, 42, 45, 48, 50, 53,
+        55, 56, 60, 63, 66, 68, 73, 79, 80, 81, 85, 88, 91, 94, 97, 98, 100,
+        101, 103, 105, 107, 44, 42, 41, 41, 42, 42, 48, 50, 54, 58, 63, 65, 67,
+        71, 75, 77, 79, 84, 90, 91, 92, 97, 100, 100, 100, 100, 101, 104, 108,
+        112, 115, 119, 53, 51, 49, 49, 50, 49, 54, 57, 60, 65, 71, 73, 76, 82,
+        87, 89, 92, 97, 104, 105, 106, 108, 106, 105, 107, 111, 114, 117, 117,
+        117, 118, 119, 59, 56, 54, 54, 54, 53, 58, 61, 64, 69, 75, 78, 80, 87,
+        92, 95, 98, 103, 110, 112, 113, 115, 114, 118, 123, 121, 120, 119, 123,
+        127, 131, 136, 65, 62, 59, 59, 59, 58, 63, 65, 68, 73, 79, 82, 85, 92,
+        98, 101, 105, 111, 118, 119, 121, 126, 130, 131, 128, 127, 131, 136,
+        138, 137, 136, 136, 79, 75, 72, 71, 71, 69, 73, 76, 78, 84, 90, 93, 96,
+        103, 110, 114, 118, 125, 133, 135, 136, 142, 142, 137, 140, 145, 144,
+        142, 141, 146, 151, 156, 87, 82, 78, 78, 77, 75, 79, 82, 84, 89, 95, 98,
+        102, 109, 116, 120, 124, 132, 141, 142, 144, 149, 148, 153, 157, 152,
+        150, 155, 161, 159, 157, 156, 90, 85, 82, 81, 80, 78, 78, 83, 87, 89,
+        93, 100, 102, 107, 115, 118, 123, 132, 136, 140, 151, 153, 155, 160,
+        161, 164, 170, 168, 165, 167, 172, 178, 93, 88, 86, 84, 82, 82, 80, 84,
+        86, 91, 94, 98, 105, 107, 112, 119, 122, 130, 135, 140, 149, 153, 162,
+        165, 167, 173, 174, 177, 183, 185, 182, 179, 96, 91, 90, 87, 86, 86, 83,
+        84, 89, 91, 95, 100, 102, 110, 111, 118, 123, 128, 135, 138, 149, 152,
+        160, 167, 173, 178, 180, 187, 188, 190, 197, 203, 99, 94, 93, 90, 89,
+        89, 88, 87, 90, 93, 97, 99, 105, 107, 115, 116, 124, 127, 135, 139, 146,
+        152, 159, 166, 171, 182, 186, 191, 193, 201, 203, 204, 102, 97, 97, 93,
+        93, 92, 92, 90, 90, 96, 97, 103, 104, 111, 112, 120, 121, 130, 131, 142,
+        143, 154, 155, 168, 169, 181, 183, 198, 200, 206, 208, 217,
         /* Size 4x16 */
-        63, 88, 158, 214, 65, 82, 144, 196, 65, 84, 142, 188, 68, 96, 147, 176,
-        69, 108, 157, 200, 82, 126, 180, 200, 90, 134, 192, 208, 108, 150, 220,
-        228, 120, 159, 236, 269, 145, 181, 267, 309, 151, 185, 273, 348, 167,
-        203, 293, 337, 181, 210, 269, 340, 195, 199, 325, 328, 211, 212, 260,
-        390, 228, 225, 272, 351,
+        31, 44, 79, 96, 32, 41, 72, 90, 32, 42, 71, 86, 34, 48, 73, 83, 34, 54,
+        78, 89, 41, 63, 90, 95, 45, 67, 96, 102, 54, 75, 110, 111, 60, 79, 118,
+        123, 72, 90, 133, 135, 75, 92, 136, 149, 83, 100, 142, 160, 88, 100,
+        140, 173, 94, 101, 144, 180, 101, 108, 141, 188, 108, 115, 151, 197,
         /* Size 16x4 */
-        63, 65, 65, 68, 69, 82, 90, 108, 120, 145, 151, 167, 181, 195, 211, 228,
-        88, 82, 84, 96, 108, 126, 134, 150, 159, 181, 185, 203, 210, 199, 212,
-        225, 158, 144, 142, 147, 157, 180, 192, 220, 236, 267, 273, 293, 269,
-        325, 260, 272, 214, 196, 188, 176, 200, 200, 208, 228, 269, 309, 348,
-        337, 340, 328, 390, 351,
+        31, 32, 32, 34, 34, 41, 45, 54, 60, 72, 75, 83, 88, 94, 101, 108, 44,
+        41, 42, 48, 54, 63, 67, 75, 79, 90, 92, 100, 100, 101, 108, 115, 79, 72,
+        71, 73, 78, 90, 96, 110, 118, 133, 136, 142, 140, 144, 141, 151, 96, 90,
+        86, 83, 89, 95, 102, 111, 123, 135, 149, 160, 173, 180, 188, 197,
         /* Size 8x32 */
-        64, 64, 72, 107, 131, 174, 199, 229, 63, 65, 71, 103, 124, 165, 189,
-        216, 63, 66, 69, 99, 119, 157, 182, 211, 63, 67, 71, 99, 119, 156, 180,
-        206, 64, 68, 73, 100, 118, 154, 174, 202, 64, 71, 77, 99, 116, 150, 172,
-        200, 68, 74, 85, 109, 126, 159, 170, 190, 70, 75, 90, 114, 131, 164,
-        187, 192, 72, 77, 96, 120, 136, 168, 179, 221, 79, 81, 101, 130, 147,
-        179, 195, 201, 88, 86, 107, 143, 159, 191, 205, 235, 92, 89, 110, 147,
-        165, 197, 198, 209, 96, 93, 113, 152, 171, 204, 232, 256, 107, 100, 120,
-        164, 185, 219, 220, 218, 117, 108, 127, 174, 196, 232, 231, 282, 123,
-        112, 132, 179, 203, 240, 266, 234, 130, 117, 136, 185, 210, 249, 237,
-        292, 142, 127, 146, 195, 222, 264, 276, 264, 159, 140, 158, 208, 236,
-        282, 285, 309, 162, 142, 160, 210, 239, 285, 275, 293, 165, 145, 162,
-        212, 242, 289, 331, 310, 176, 154, 171, 219, 251, 298, 306, 339, 183,
-        160, 176, 218, 259, 294, 333, 325, 191, 167, 182, 210, 276, 298, 330,
-        375, 198, 174, 187, 209, 273, 344, 314, 327, 206, 181, 205, 214, 242,
-        337, 358, 454, 215, 188, 210, 229, 248, 281, 350, 337, 223, 196, 216,
-        257, 272, 288, 327, 388, 232, 205, 222, 261, 319, 363, 364, 342, 242,
-        214, 229, 266, 319, 382, 462, 430, 252, 223, 237, 272, 320, 378, 451,
-        431, 262, 237, 220, 232, 250, 278, 315, 359,
+        32, 32, 36, 53, 65, 87, 93, 99, 31, 32, 35, 51, 62, 82, 88, 94, 31, 33,
+        34, 49, 59, 78, 86, 93, 31, 33, 35, 49, 59, 78, 84, 90, 32, 34, 36, 50,
+        59, 77, 82, 89, 32, 35, 38, 49, 58, 75, 82, 89, 34, 37, 42, 54, 63, 79,
+        80, 88, 35, 37, 45, 57, 65, 82, 84, 87, 36, 38, 48, 60, 68, 84, 86, 90,
+        39, 40, 50, 65, 73, 89, 91, 93, 44, 43, 53, 71, 79, 95, 94, 97, 46, 44,
+        55, 73, 82, 98, 98, 99, 48, 46, 56, 76, 85, 102, 105, 105, 53, 50, 60,
+        82, 92, 109, 107, 107, 58, 54, 63, 87, 98, 116, 112, 115, 61, 56, 66,
+        89, 101, 120, 119, 116, 65, 58, 68, 92, 105, 124, 122, 124, 71, 63, 73,
+        97, 111, 132, 130, 127, 79, 70, 79, 104, 118, 141, 135, 135, 81, 71, 80,
+        105, 119, 142, 140, 139, 82, 72, 81, 106, 121, 144, 149, 146, 88, 77,
+        85, 108, 126, 149, 153, 152, 91, 80, 88, 106, 130, 148, 162, 159, 94,
+        83, 91, 105, 131, 153, 165, 166, 97, 86, 94, 107, 128, 157, 167, 171,
+        100, 89, 97, 111, 127, 152, 173, 182, 103, 93, 98, 114, 131, 150, 174,
+        186, 107, 96, 100, 117, 136, 155, 177, 191, 110, 100, 101, 117, 138,
+        161, 183, 193, 114, 104, 103, 117, 137, 159, 185, 201, 118, 107, 105,
+        118, 136, 157, 182, 203, 122, 111, 107, 119, 136, 156, 179, 204,
         /* Size 32x8 */
-        64, 63, 63, 63, 64, 64, 68, 70, 72, 79, 88, 92, 96, 107, 117, 123, 130,
-        142, 159, 162, 165, 176, 183, 191, 198, 206, 215, 223, 232, 242, 252,
-        262, 64, 65, 66, 67, 68, 71, 74, 75, 77, 81, 86, 89, 93, 100, 108, 112,
-        117, 127, 140, 142, 145, 154, 160, 167, 174, 181, 188, 196, 205, 214,
-        223, 237, 72, 71, 69, 71, 73, 77, 85, 90, 96, 101, 107, 110, 113, 120,
-        127, 132, 136, 146, 158, 160, 162, 171, 176, 182, 187, 205, 210, 216,
-        222, 229, 237, 220, 107, 103, 99, 99, 100, 99, 109, 114, 120, 130, 143,
-        147, 152, 164, 174, 179, 185, 195, 208, 210, 212, 219, 218, 210, 209,
-        214, 229, 257, 261, 266, 272, 232, 131, 124, 119, 119, 118, 116, 126,
-        131, 136, 147, 159, 165, 171, 185, 196, 203, 210, 222, 236, 239, 242,
-        251, 259, 276, 273, 242, 248, 272, 319, 319, 320, 250, 174, 165, 157,
-        156, 154, 150, 159, 164, 168, 179, 191, 197, 204, 219, 232, 240, 249,
-        264, 282, 285, 289, 298, 294, 298, 344, 337, 281, 288, 363, 382, 378,
-        278, 199, 189, 182, 180, 174, 172, 170, 187, 179, 195, 205, 198, 232,
-        220, 231, 266, 237, 276, 285, 275, 331, 306, 333, 330, 314, 358, 350,
-        327, 364, 462, 451, 315, 229, 216, 211, 206, 202, 200, 190, 192, 221,
-        201, 235, 209, 256, 218, 282, 234, 292, 264, 309, 293, 310, 339, 325,
-        375, 327, 454, 337, 388, 342, 430, 431, 359 },
+        32, 31, 31, 31, 32, 32, 34, 35, 36, 39, 44, 46, 48, 53, 58, 61, 65, 71,
+        79, 81, 82, 88, 91, 94, 97, 100, 103, 107, 110, 114, 118, 122, 32, 32,
+        33, 33, 34, 35, 37, 37, 38, 40, 43, 44, 46, 50, 54, 56, 58, 63, 70, 71,
+        72, 77, 80, 83, 86, 89, 93, 96, 100, 104, 107, 111, 36, 35, 34, 35, 36,
+        38, 42, 45, 48, 50, 53, 55, 56, 60, 63, 66, 68, 73, 79, 80, 81, 85, 88,
+        91, 94, 97, 98, 100, 101, 103, 105, 107, 53, 51, 49, 49, 50, 49, 54, 57,
+        60, 65, 71, 73, 76, 82, 87, 89, 92, 97, 104, 105, 106, 108, 106, 105,
+        107, 111, 114, 117, 117, 117, 118, 119, 65, 62, 59, 59, 59, 58, 63, 65,
+        68, 73, 79, 82, 85, 92, 98, 101, 105, 111, 118, 119, 121, 126, 130, 131,
+        128, 127, 131, 136, 138, 137, 136, 136, 87, 82, 78, 78, 77, 75, 79, 82,
+        84, 89, 95, 98, 102, 109, 116, 120, 124, 132, 141, 142, 144, 149, 148,
+        153, 157, 152, 150, 155, 161, 159, 157, 156, 93, 88, 86, 84, 82, 82, 80,
+        84, 86, 91, 94, 98, 105, 107, 112, 119, 122, 130, 135, 140, 149, 153,
+        162, 165, 167, 173, 174, 177, 183, 185, 182, 179, 99, 94, 93, 90, 89,
+        89, 88, 87, 90, 93, 97, 99, 105, 107, 115, 116, 124, 127, 135, 139, 146,
+        152, 159, 166, 171, 182, 186, 191, 193, 201, 203, 204 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        101, 125, 125, 205,
+        50, 62, 62, 100,
 #endif
         /* Size 4x4 */
-        71, 92, 115, 138, 92, 120, 139, 155, 115, 139, 180, 173, 138, 155, 173,
-        232,
+        35, 46, 57, 66, 46, 60, 69, 71, 57, 69, 90, 90, 66, 71, 90, 109,
         /* Size 8x8 */
-        63, 77, 94, 100, 114, 128, 139, 151, 77, 95, 93, 94, 104, 115, 125, 139,
-        94, 93, 109, 115, 123, 132, 138, 138, 100, 94, 115, 133, 145, 155, 150,
-        147, 114, 104, 123, 145, 164, 178, 184, 173, 128, 115, 132, 155, 178,
-        193, 188, 214, 139, 125, 138, 150, 184, 188, 218, 261, 151, 139, 138,
-        147, 173, 214, 261, 247,
+        31, 38, 47, 50, 57, 63, 67, 71, 38, 47, 46, 47, 52, 57, 62, 67, 47, 46,
+        54, 57, 61, 66, 67, 68, 50, 47, 57, 66, 72, 77, 75, 75, 57, 52, 61, 72,
+        82, 88, 86, 84, 63, 57, 66, 77, 88, 96, 95, 95, 67, 62, 67, 75, 86, 95,
+        104, 107, 71, 67, 68, 75, 84, 95, 107, 113,
         /* Size 16x16 */
-        64, 61, 67, 83, 98, 98, 101, 109, 114, 127, 130, 138, 144, 150, 157,
-        163, 61, 64, 71, 85, 93, 90, 93, 99, 104, 115, 117, 125, 131, 137, 144,
-        150, 67, 71, 78, 90, 95, 91, 93, 99, 102, 113, 115, 121, 126, 130, 136,
-        143, 83, 85, 90, 97, 101, 98, 100, 104, 107, 115, 117, 121, 121, 125,
-        127, 134, 98, 93, 95, 101, 106, 107, 108, 111, 113, 121, 123, 128, 134,
-        131, 147, 151, 98, 90, 91, 98, 107, 117, 120, 125, 127, 135, 136, 135,
-        145, 136, 151, 158, 101, 93, 93, 100, 108, 120, 123, 130, 134, 142, 143,
-        151, 144, 154, 150, 168, 109, 99, 99, 104, 111, 125, 130, 142, 147, 156,
-        158, 156, 154, 170, 151, 180, 114, 104, 102, 107, 113, 127, 134, 147,
-        153, 164, 166, 173, 177, 183, 158, 191, 127, 115, 113, 115, 121, 135,
-        142, 156, 164, 178, 180, 181, 186, 175, 166, 209, 130, 117, 115, 117,
-        123, 136, 143, 158, 166, 180, 183, 189, 184, 180, 185, 216, 138, 125,
-        121, 121, 128, 135, 151, 156, 173, 181, 189, 199, 199, 202, 207, 239,
-        144, 131, 126, 121, 134, 145, 144, 154, 177, 186, 184, 199, 212, 211,
-        241, 246, 150, 137, 130, 125, 131, 136, 154, 170, 183, 175, 180, 202,
-        211, 225, 224, 276, 157, 144, 136, 127, 147, 151, 150, 151, 158, 166,
-        185, 207, 241, 224, 240, 236, 163, 150, 143, 134, 151, 158, 168, 180,
-        191, 209, 216, 239, 246, 276, 236, 255,
+        32, 30, 33, 41, 49, 49, 50, 54, 57, 63, 65, 68, 70, 72, 74, 76, 30, 32,
+        35, 42, 46, 45, 46, 49, 52, 57, 58, 62, 64, 67, 70, 72, 33, 35, 39, 45,
+        47, 45, 46, 49, 51, 56, 57, 60, 62, 64, 66, 69, 41, 42, 45, 48, 50, 49,
+        50, 52, 53, 57, 58, 59, 60, 61, 64, 67, 49, 46, 47, 50, 53, 53, 54, 55,
+        56, 60, 61, 64, 64, 65, 66, 66, 49, 45, 45, 49, 53, 58, 60, 62, 63, 67,
+        68, 67, 69, 68, 70, 70, 50, 46, 46, 50, 54, 60, 61, 65, 67, 71, 71, 74,
+        73, 73, 74, 74, 54, 49, 49, 52, 55, 62, 65, 71, 73, 78, 79, 78, 77, 78,
+        78, 78, 57, 52, 51, 53, 56, 63, 67, 73, 76, 82, 83, 84, 84, 84, 82, 83,
+        63, 57, 56, 57, 60, 67, 71, 78, 82, 89, 90, 90, 89, 88, 87, 88, 65, 58,
+        57, 58, 61, 68, 71, 79, 83, 90, 91, 94, 93, 93, 92, 93, 68, 62, 60, 59,
+        64, 67, 74, 78, 84, 90, 94, 98, 99, 98, 98, 98, 70, 64, 62, 60, 64, 69,
+        73, 77, 84, 89, 93, 99, 102, 103, 104, 104, 72, 67, 64, 61, 65, 68, 73,
+        78, 84, 88, 93, 98, 103, 106, 108, 109, 74, 70, 66, 64, 66, 70, 74, 78,
+        82, 87, 92, 98, 104, 108, 111, 112, 76, 72, 69, 67, 66, 70, 74, 78, 83,
+        88, 93, 98, 104, 109, 112, 116,
         /* Size 32x32 */
-        64, 62, 61, 64, 67, 73, 83, 90, 98, 97, 98, 100, 101, 104, 109, 112,
-        114, 120, 127, 128, 130, 135, 138, 141, 144, 147, 150, 153, 157, 160,
-        163, 167, 62, 63, 62, 66, 69, 77, 85, 90, 95, 94, 94, 95, 97, 100, 104,
-        106, 109, 114, 121, 122, 123, 128, 130, 133, 136, 139, 142, 145, 148,
-        151, 154, 156, 61, 62, 64, 67, 71, 80, 85, 89, 93, 91, 90, 91, 93, 95,
-        99, 102, 104, 109, 115, 116, 117, 122, 125, 128, 131, 134, 137, 140,
-        144, 147, 150, 158, 64, 66, 67, 71, 74, 83, 87, 90, 94, 92, 90, 92, 93,
-        95, 99, 101, 103, 108, 114, 115, 116, 120, 123, 126, 130, 132, 135, 138,
-        141, 144, 147, 145, 67, 69, 71, 74, 78, 87, 90, 92, 95, 93, 91, 92, 93,
-        95, 99, 100, 102, 107, 113, 114, 115, 119, 121, 123, 126, 127, 130, 133,
-        136, 140, 143, 150, 73, 77, 80, 83, 87, 95, 95, 95, 96, 93, 91, 92, 92,
-        94, 97, 98, 100, 104, 109, 110, 111, 115, 116, 119, 122, 125, 131, 134,
-        136, 139, 142, 140, 83, 85, 85, 87, 90, 95, 97, 99, 101, 99, 98, 99,
-        100, 101, 104, 105, 107, 111, 115, 116, 117, 120, 121, 120, 121, 123,
-        125, 124, 127, 131, 134, 144, 90, 90, 89, 90, 92, 95, 99, 101, 103, 103,
-        103, 103, 104, 105, 107, 109, 110, 114, 118, 119, 120, 123, 123, 125,
-        131, 134, 135, 130, 131, 133, 136, 130, 98, 95, 93, 94, 95, 96, 101,
-        103, 106, 106, 107, 108, 108, 109, 111, 112, 113, 117, 121, 122, 123,
-        126, 128, 133, 134, 129, 131, 137, 147, 149, 151, 138, 97, 94, 91, 92,
-        93, 93, 99, 103, 106, 109, 111, 112, 113, 115, 117, 119, 120, 123, 127,
-        128, 129, 132, 135, 132, 132, 138, 144, 145, 136, 138, 140, 162, 98, 94,
-        90, 90, 91, 91, 98, 103, 107, 111, 117, 118, 120, 123, 125, 126, 127,
-        131, 135, 135, 136, 138, 135, 136, 145, 145, 136, 138, 151, 156, 158,
-        143, 100, 95, 91, 92, 92, 92, 99, 103, 108, 112, 118, 120, 121, 125,
-        128, 129, 131, 134, 138, 139, 140, 141, 141, 148, 143, 140, 150, 155,
-        148, 142, 144, 167, 101, 97, 93, 93, 93, 92, 100, 104, 108, 113, 120,
-        121, 123, 127, 130, 132, 134, 137, 142, 142, 143, 146, 151, 146, 144,
-        158, 154, 143, 150, 167, 168, 146, 104, 100, 95, 95, 95, 94, 101, 105,
-        109, 115, 123, 125, 127, 133, 137, 139, 141, 145, 150, 150, 151, 155,
-        153, 149, 160, 150, 148, 168, 167, 147, 149, 178, 109, 104, 99, 99, 99,
-        97, 104, 107, 111, 117, 125, 128, 130, 137, 142, 144, 147, 151, 156,
-        157, 158, 160, 156, 166, 154, 157, 170, 153, 151, 179, 180, 151, 112,
-        106, 102, 101, 100, 98, 105, 109, 112, 119, 126, 129, 132, 139, 144,
-        147, 150, 154, 160, 161, 162, 163, 167, 162, 163, 175, 155, 168, 180,
-        155, 155, 191, 114, 109, 104, 103, 102, 100, 107, 110, 113, 120, 127,
-        131, 134, 141, 147, 150, 153, 158, 164, 165, 166, 169, 173, 165, 177,
-        161, 183, 178, 158, 184, 191, 157, 120, 114, 109, 108, 107, 104, 111,
-        114, 117, 123, 131, 134, 137, 145, 151, 154, 158, 164, 170, 171, 172,
-        178, 171, 184, 167, 184, 174, 165, 198, 173, 162, 203, 127, 121, 115,
-        114, 113, 109, 115, 118, 121, 127, 135, 138, 142, 150, 156, 160, 164,
-        170, 178, 179, 180, 183, 181, 180, 186, 183, 175, 195, 166, 189, 209,
-        164, 128, 122, 116, 115, 114, 110, 116, 119, 122, 128, 135, 139, 142,
-        150, 157, 161, 165, 171, 179, 180, 182, 185, 193, 182, 192, 180, 204,
-        173, 205, 189, 170, 223, 130, 123, 117, 116, 115, 111, 117, 120, 123,
-        129, 136, 140, 143, 151, 158, 162, 166, 172, 180, 182, 183, 188, 189,
-        204, 184, 204, 180, 216, 185, 189, 216, 172, 135, 128, 122, 120, 119,
-        115, 120, 123, 126, 132, 138, 141, 146, 155, 160, 163, 169, 178, 183,
-        185, 188, 193, 191, 193, 210, 188, 213, 188, 208, 214, 179, 229, 138,
-        130, 125, 123, 121, 116, 121, 123, 128, 135, 135, 141, 151, 153, 156,
-        167, 173, 171, 181, 193, 189, 191, 199, 194, 199, 212, 202, 209, 207,
-        193, 239, 181, 141, 133, 128, 126, 123, 119, 120, 125, 133, 132, 136,
-        148, 146, 149, 166, 162, 165, 184, 180, 182, 204, 193, 194, 205, 196,
-        205, 211, 219, 204, 231, 189, 254, 144, 136, 131, 130, 126, 122, 121,
-        131, 134, 132, 145, 143, 144, 160, 154, 163, 177, 167, 186, 192, 184,
-        210, 199, 196, 212, 199, 211, 209, 241, 197, 246, 192, 147, 139, 134,
-        132, 127, 125, 123, 134, 129, 138, 145, 140, 158, 150, 157, 175, 161,
-        184, 183, 180, 204, 188, 212, 205, 199, 218, 203, 218, 205, 261, 199,
-        259, 150, 142, 137, 135, 130, 131, 125, 135, 131, 144, 136, 150, 154,
-        148, 170, 155, 183, 174, 175, 204, 180, 213, 202, 211, 211, 203, 225,
-        206, 224, 208, 276, 202, 153, 145, 140, 138, 133, 134, 124, 130, 137,
-        145, 138, 155, 143, 168, 153, 168, 178, 165, 195, 173, 216, 188, 209,
-        219, 209, 218, 206, 232, 209, 230, 211, 292, 157, 148, 144, 141, 136,
-        136, 127, 131, 147, 136, 151, 148, 150, 167, 151, 180, 158, 198, 166,
-        205, 185, 208, 207, 204, 241, 205, 224, 209, 240, 212, 236, 214, 160,
-        151, 147, 144, 140, 139, 131, 133, 149, 138, 156, 142, 167, 147, 179,
-        155, 184, 173, 189, 189, 189, 214, 193, 231, 197, 261, 208, 230, 212,
-        247, 215, 243, 163, 154, 150, 147, 143, 142, 134, 136, 151, 140, 158,
-        144, 168, 149, 180, 155, 191, 162, 209, 170, 216, 179, 239, 189, 246,
-        199, 276, 211, 236, 215, 255, 218, 167, 156, 158, 145, 150, 140, 144,
-        130, 138, 162, 143, 167, 146, 178, 151, 191, 157, 203, 164, 223, 172,
-        229, 181, 254, 192, 259, 202, 292, 214, 243, 218, 263,
+        32, 31, 30, 32, 33, 36, 41, 45, 49, 48, 49, 50, 50, 52, 54, 56, 57, 60,
+        63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 31, 31, 31, 33,
+        34, 38, 42, 45, 47, 47, 47, 47, 48, 50, 52, 53, 54, 57, 60, 61, 61, 63,
+        64, 65, 66, 67, 68, 69, 70, 71, 72, 74, 30, 31, 32, 33, 35, 40, 42, 44,
+        46, 45, 45, 45, 46, 47, 49, 51, 52, 54, 57, 58, 58, 61, 62, 63, 64, 66,
+        67, 68, 70, 71, 72, 74, 32, 33, 33, 35, 37, 41, 43, 45, 47, 46, 45, 46,
+        46, 47, 49, 50, 51, 54, 57, 57, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68,
+        69, 70, 33, 34, 35, 37, 39, 43, 45, 46, 47, 46, 45, 46, 46, 47, 49, 50,
+        51, 53, 56, 57, 57, 59, 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, 36, 38,
+        40, 41, 43, 47, 47, 47, 48, 46, 45, 46, 46, 47, 48, 49, 50, 52, 54, 55,
+        55, 57, 58, 59, 61, 62, 64, 65, 66, 67, 68, 69, 41, 42, 42, 43, 45, 47,
+        48, 49, 50, 49, 49, 49, 50, 50, 52, 52, 53, 55, 57, 58, 58, 60, 59, 59,
+        60, 61, 61, 63, 64, 66, 67, 69, 45, 45, 44, 45, 46, 47, 49, 50, 51, 51,
+        51, 51, 52, 52, 53, 54, 55, 57, 59, 59, 60, 61, 61, 62, 63, 63, 63, 63,
+        63, 64, 65, 66, 49, 47, 46, 47, 47, 48, 50, 51, 53, 53, 53, 54, 54, 54,
+        55, 56, 56, 58, 60, 61, 61, 63, 64, 64, 64, 64, 65, 66, 66, 66, 66, 66,
+        48, 47, 45, 46, 46, 46, 49, 51, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61,
+        63, 64, 64, 66, 66, 65, 66, 67, 67, 67, 67, 68, 69, 70, 49, 47, 45, 45,
+        45, 45, 49, 51, 53, 55, 58, 59, 60, 61, 62, 63, 63, 65, 67, 67, 68, 69,
+        67, 68, 69, 68, 68, 69, 70, 70, 70, 70, 50, 47, 45, 46, 46, 46, 49, 51,
+        54, 56, 59, 60, 60, 62, 64, 64, 65, 67, 69, 69, 70, 70, 71, 71, 70, 70,
+        71, 71, 71, 71, 72, 74, 50, 48, 46, 46, 46, 46, 50, 52, 54, 56, 60, 60,
+        61, 63, 65, 66, 67, 68, 71, 71, 71, 73, 74, 72, 73, 74, 73, 73, 74, 74,
+        74, 74, 52, 50, 47, 47, 47, 47, 50, 52, 54, 57, 61, 62, 63, 66, 68, 69,
+        70, 72, 75, 75, 75, 77, 75, 75, 76, 75, 75, 76, 75, 75, 76, 77, 54, 52,
+        49, 49, 49, 48, 52, 53, 55, 58, 62, 64, 65, 68, 71, 72, 73, 75, 78, 78,
+        79, 79, 78, 79, 77, 78, 78, 77, 78, 79, 78, 78, 56, 53, 51, 50, 50, 49,
+        52, 54, 56, 59, 63, 64, 66, 69, 72, 73, 75, 77, 80, 80, 81, 81, 82, 80,
+        81, 81, 79, 81, 80, 79, 81, 82, 57, 54, 52, 51, 51, 50, 53, 55, 56, 60,
+        63, 65, 67, 70, 73, 75, 76, 79, 82, 82, 83, 85, 84, 83, 84, 83, 84, 82,
+        82, 84, 83, 82, 60, 57, 54, 54, 53, 52, 55, 57, 58, 61, 65, 67, 68, 72,
+        75, 77, 79, 82, 85, 85, 86, 88, 86, 87, 85, 86, 85, 85, 86, 84, 85, 86,
+        63, 60, 57, 57, 56, 54, 57, 59, 60, 63, 67, 69, 71, 75, 78, 80, 82, 85,
+        89, 89, 90, 90, 90, 89, 89, 88, 88, 88, 87, 88, 88, 87, 64, 61, 58, 57,
+        57, 55, 58, 59, 61, 64, 67, 69, 71, 75, 78, 80, 82, 85, 89, 90, 91, 92,
+        93, 92, 92, 91, 91, 90, 91, 90, 90, 92, 65, 61, 58, 58, 57, 55, 58, 60,
+        61, 64, 68, 70, 71, 75, 79, 81, 83, 86, 90, 91, 91, 94, 94, 96, 93, 94,
+        93, 94, 92, 93, 93, 92, 67, 63, 61, 60, 59, 57, 60, 61, 63, 66, 69, 70,
+        73, 77, 79, 81, 85, 88, 90, 92, 94, 96, 96, 97, 98, 95, 97, 95, 96, 95,
+        95, 96, 68, 64, 62, 61, 60, 58, 59, 61, 64, 66, 67, 71, 74, 75, 78, 82,
+        84, 86, 90, 93, 94, 96, 98, 98, 99, 100, 98, 99, 98, 98, 98, 97, 69, 65,
+        63, 62, 61, 59, 59, 62, 64, 65, 68, 71, 72, 75, 79, 80, 83, 87, 89, 92,
+        96, 97, 98, 100, 100, 101, 102, 101, 101, 101, 100, 102, 70, 66, 64, 63,
+        62, 61, 60, 63, 64, 66, 69, 70, 73, 76, 77, 81, 84, 85, 89, 92, 93, 98,
+        99, 100, 102, 102, 103, 104, 104, 103, 104, 102, 71, 67, 66, 64, 63, 62,
+        61, 63, 64, 67, 68, 70, 74, 75, 78, 81, 83, 86, 88, 91, 94, 95, 100,
+        101, 102, 104, 104, 105, 106, 107, 105, 107, 72, 68, 67, 65, 64, 64, 61,
+        63, 65, 67, 68, 71, 73, 75, 78, 79, 84, 85, 88, 91, 93, 97, 98, 102,
+        103, 104, 106, 106, 108, 108, 109, 107, 73, 69, 68, 66, 65, 65, 63, 63,
+        66, 67, 69, 71, 73, 76, 77, 81, 82, 85, 88, 90, 94, 95, 99, 101, 104,
+        105, 106, 109, 108, 110, 111, 112, 74, 70, 70, 67, 66, 66, 64, 63, 66,
+        67, 70, 71, 74, 75, 78, 80, 82, 86, 87, 91, 92, 96, 98, 101, 104, 106,
+        108, 108, 111, 111, 112, 113, 75, 71, 71, 68, 68, 67, 66, 64, 66, 68,
+        70, 71, 74, 75, 79, 79, 84, 84, 88, 90, 93, 95, 98, 101, 103, 107, 108,
+        110, 111, 113, 113, 115, 76, 72, 72, 69, 69, 68, 67, 65, 66, 69, 70, 72,
+        74, 76, 78, 81, 83, 85, 88, 90, 93, 95, 98, 100, 104, 105, 109, 111,
+        112, 113, 116, 115, 78, 74, 74, 70, 70, 69, 69, 66, 66, 70, 70, 74, 74,
+        77, 78, 82, 82, 86, 87, 92, 92, 96, 97, 102, 102, 107, 107, 112, 113,
+        115, 115, 118,
         /* Size 4x8 */
-        63, 94, 120, 141, 80, 91, 109, 131, 92, 112, 128, 140, 96, 122, 150,
-        167, 109, 131, 170, 169, 122, 139, 185, 189, 133, 145, 189, 214, 144,
-        142, 169, 208,
+        31, 47, 60, 66, 40, 45, 54, 61, 46, 56, 64, 64, 48, 61, 75, 73, 54, 65,
+        85, 82, 61, 69, 92, 92, 64, 68, 90, 102, 68, 71, 87, 105,
         /* Size 8x4 */
-        63, 80, 92, 96, 109, 122, 133, 144, 94, 91, 112, 122, 131, 139, 145,
-        142, 120, 109, 128, 150, 170, 185, 189, 169, 141, 131, 140, 167, 169,
-        189, 214, 208,
+        31, 40, 46, 48, 54, 61, 64, 68, 47, 45, 56, 61, 65, 69, 68, 71, 60, 54,
+        64, 75, 85, 92, 90, 87, 66, 61, 64, 73, 82, 92, 102, 105,
         /* Size 8x16 */
-        64, 74, 96, 105, 115, 133, 144, 155, 61, 80, 92, 96, 104, 121, 131, 143,
-        67, 86, 94, 95, 103, 118, 125, 136, 84, 95, 100, 101, 107, 120, 121,
-        127, 98, 96, 106, 109, 114, 125, 127, 146, 98, 92, 107, 123, 128, 139,
-        142, 153, 101, 93, 108, 128, 134, 146, 157, 164, 109, 98, 111, 137, 147,
-        161, 156, 177, 114, 101, 113, 141, 153, 169, 160, 182, 127, 110, 121,
-        150, 164, 184, 183, 190, 129, 112, 123, 151, 166, 187, 203, 191, 137,
-        119, 128, 152, 173, 189, 205, 198, 143, 124, 132, 144, 177, 209, 197,
-        200, 149, 130, 142, 153, 163, 180, 211, 206, 156, 136, 146, 166, 194,
-        214, 216, 208, 163, 143, 150, 168, 191, 218, 247, 242,
+        32, 37, 48, 52, 57, 66, 68, 71, 30, 40, 46, 48, 52, 60, 63, 66, 33, 43,
+        47, 47, 51, 59, 60, 63, 42, 47, 50, 50, 53, 60, 59, 62, 49, 48, 53, 54,
+        57, 62, 62, 62, 49, 46, 53, 61, 64, 69, 66, 66, 50, 46, 54, 64, 67, 73,
+        72, 70, 54, 49, 55, 68, 73, 80, 76, 75, 57, 50, 56, 70, 76, 84, 80, 79,
+        63, 55, 60, 75, 82, 92, 87, 84, 64, 56, 61, 75, 83, 93, 93, 89, 68, 59,
+        64, 74, 86, 94, 98, 94, 70, 62, 66, 73, 83, 96, 99, 98, 72, 64, 66, 75,
+        83, 92, 101, 104, 74, 67, 66, 74, 84, 94, 103, 106, 76, 69, 67, 73, 82,
+        91, 101, 109,
         /* Size 16x8 */
-        64, 61, 67, 84, 98, 98, 101, 109, 114, 127, 129, 137, 143, 149, 156,
-        163, 74, 80, 86, 95, 96, 92, 93, 98, 101, 110, 112, 119, 124, 130, 136,
-        143, 96, 92, 94, 100, 106, 107, 108, 111, 113, 121, 123, 128, 132, 142,
-        146, 150, 105, 96, 95, 101, 109, 123, 128, 137, 141, 150, 151, 152, 144,
-        153, 166, 168, 115, 104, 103, 107, 114, 128, 134, 147, 153, 164, 166,
-        173, 177, 163, 194, 191, 133, 121, 118, 120, 125, 139, 146, 161, 169,
-        184, 187, 189, 209, 180, 214, 218, 144, 131, 125, 121, 127, 142, 157,
-        156, 160, 183, 203, 205, 197, 211, 216, 247, 155, 143, 136, 127, 146,
-        153, 164, 177, 182, 190, 191, 198, 200, 206, 208, 242,
+        32, 30, 33, 42, 49, 49, 50, 54, 57, 63, 64, 68, 70, 72, 74, 76, 37, 40,
+        43, 47, 48, 46, 46, 49, 50, 55, 56, 59, 62, 64, 67, 69, 48, 46, 47, 50,
+        53, 53, 54, 55, 56, 60, 61, 64, 66, 66, 66, 67, 52, 48, 47, 50, 54, 61,
+        64, 68, 70, 75, 75, 74, 73, 75, 74, 73, 57, 52, 51, 53, 57, 64, 67, 73,
+        76, 82, 83, 86, 83, 83, 84, 82, 66, 60, 59, 60, 62, 69, 73, 80, 84, 92,
+        93, 94, 96, 92, 94, 91, 68, 63, 60, 59, 62, 66, 72, 76, 80, 87, 93, 98,
+        99, 101, 103, 101, 71, 66, 63, 62, 62, 66, 70, 75, 79, 84, 89, 94, 98,
+        104, 106, 109,
         /* Size 16x32 */
-        64, 62, 74, 84, 96, 98, 105, 109, 115, 127, 133, 139, 144, 149, 155,
-        161, 63, 63, 77, 85, 94, 94, 100, 104, 109, 120, 126, 131, 136, 141,
-        147, 150, 61, 64, 80, 85, 92, 91, 96, 100, 104, 115, 121, 126, 131, 137,
-        143, 152, 64, 68, 83, 88, 93, 91, 96, 99, 103, 114, 119, 125, 130, 135,
-        140, 140, 67, 72, 86, 90, 94, 92, 95, 99, 103, 112, 118, 122, 125, 130,
-        136, 145, 74, 80, 94, 95, 95, 91, 94, 97, 100, 109, 114, 117, 123, 131,
-        135, 136, 84, 86, 95, 97, 100, 99, 101, 104, 107, 115, 120, 120, 121,
-        122, 127, 140, 90, 89, 95, 99, 103, 103, 105, 108, 110, 118, 123, 123,
-        132, 127, 130, 127, 98, 93, 96, 101, 106, 107, 109, 111, 114, 121, 125,
-        132, 127, 137, 146, 134, 97, 92, 94, 100, 106, 112, 115, 118, 120, 128,
-        132, 132, 137, 140, 135, 158, 98, 91, 92, 99, 107, 117, 123, 125, 128,
-        135, 139, 135, 142, 137, 153, 139, 99, 92, 92, 99, 107, 118, 125, 128,
-        131, 138, 142, 147, 138, 154, 139, 164, 101, 93, 93, 100, 108, 119, 128,
-        131, 134, 142, 146, 147, 157, 141, 164, 143, 104, 96, 95, 101, 109, 122,
-        133, 137, 142, 150, 154, 149, 150, 167, 145, 175, 109, 100, 98, 104,
-        111, 125, 137, 142, 147, 156, 161, 164, 156, 152, 177, 148, 111, 102,
-        99, 105, 112, 126, 139, 144, 150, 160, 165, 164, 174, 167, 153, 188,
-        114, 104, 101, 107, 113, 128, 141, 147, 153, 164, 169, 164, 160, 173,
-        182, 154, 120, 109, 105, 111, 117, 131, 145, 151, 158, 170, 176, 180,
-        179, 169, 169, 200, 127, 115, 110, 116, 121, 135, 150, 157, 164, 178,
-        184, 182, 183, 192, 190, 161, 128, 117, 111, 116, 122, 136, 151, 157,
-        165, 179, 185, 180, 179, 171, 183, 220, 129, 118, 112, 117, 123, 136,
-        151, 158, 166, 180, 187, 197, 203, 210, 191, 169, 134, 122, 116, 120,
-        126, 139, 153, 160, 169, 185, 191, 194, 193, 189, 204, 225, 137, 125,
-        119, 122, 128, 144, 152, 156, 173, 188, 189, 192, 205, 205, 198, 178,
-        140, 127, 121, 121, 130, 145, 146, 158, 180, 179, 190, 202, 203, 217,
-        219, 249, 143, 130, 124, 122, 132, 145, 144, 170, 177, 176, 209, 198,
-        197, 207, 200, 188, 146, 133, 127, 125, 141, 145, 146, 172, 161, 189,
-        205, 196, 215, 214, 250, 253, 149, 136, 130, 127, 142, 136, 153, 170,
-        163, 199, 180, 220, 211, 202, 206, 198, 152, 138, 133, 129, 144, 138,
-        166, 153, 174, 196, 183, 227, 202, 228, 226, 284, 156, 141, 136, 132,
-        146, 140, 166, 151, 194, 167, 214, 205, 216, 226, 208, 210, 159, 144,
-        140, 134, 148, 142, 167, 153, 193, 169, 221, 187, 253, 208, 242, 237,
-        163, 147, 143, 137, 150, 144, 168, 155, 191, 171, 218, 190, 247, 211,
-        242, 214, 166, 147, 150, 134, 139, 166, 147, 189, 157, 219, 172, 250,
-        192, 281, 214, 257,
+        32, 31, 37, 42, 48, 49, 52, 54, 57, 63, 66, 67, 68, 69, 71, 72, 31, 31,
+        38, 42, 47, 47, 50, 52, 54, 60, 63, 64, 65, 66, 67, 68, 30, 32, 40, 42,
+        46, 45, 48, 50, 52, 57, 60, 62, 63, 65, 66, 68, 32, 34, 41, 44, 46, 45,
+        48, 49, 51, 57, 59, 61, 62, 63, 64, 65, 33, 36, 43, 45, 47, 46, 47, 49,
+        51, 56, 59, 60, 60, 62, 63, 65, 37, 40, 47, 47, 47, 45, 47, 48, 50, 54,
+        57, 58, 60, 61, 62, 63, 42, 43, 47, 48, 50, 49, 50, 52, 53, 57, 60, 58,
+        59, 60, 62, 63, 45, 44, 47, 49, 51, 51, 52, 54, 55, 59, 61, 61, 61, 60,
+        61, 61, 49, 46, 48, 50, 53, 53, 54, 55, 57, 60, 62, 63, 62, 63, 62, 62,
+        48, 46, 47, 50, 53, 56, 57, 59, 60, 64, 66, 65, 65, 64, 64, 65, 49, 45,
+        46, 49, 53, 58, 61, 62, 64, 67, 69, 67, 66, 66, 66, 65, 49, 46, 46, 49,
+        53, 59, 62, 64, 65, 69, 71, 70, 68, 68, 67, 68, 50, 46, 46, 50, 54, 59,
+        64, 65, 67, 71, 73, 72, 72, 70, 70, 69, 52, 48, 47, 50, 54, 61, 66, 68,
+        71, 75, 77, 74, 73, 73, 71, 72, 54, 50, 49, 52, 55, 62, 68, 71, 73, 78,
+        80, 78, 76, 74, 75, 73, 55, 51, 49, 52, 56, 63, 69, 72, 75, 80, 82, 80,
+        79, 78, 76, 77, 57, 52, 50, 53, 56, 64, 70, 73, 76, 82, 84, 82, 80, 80,
+        79, 77, 60, 54, 52, 55, 58, 65, 72, 75, 79, 85, 88, 86, 84, 82, 81, 81,
+        63, 57, 55, 58, 60, 67, 75, 78, 82, 89, 92, 88, 87, 85, 84, 81, 64, 58,
+        55, 58, 61, 68, 75, 78, 82, 89, 92, 90, 89, 87, 86, 86, 64, 59, 56, 58,
+        61, 68, 75, 79, 83, 90, 93, 95, 93, 91, 89, 87, 67, 61, 58, 60, 63, 69,
+        76, 79, 85, 92, 95, 96, 94, 92, 91, 91, 68, 62, 59, 60, 64, 71, 74, 78,
+        86, 91, 94, 96, 98, 96, 94, 91, 69, 62, 60, 60, 65, 70, 72, 79, 85, 88,
+        95, 98, 99, 98, 97, 96, 70, 63, 62, 60, 66, 69, 73, 81, 83, 89, 96, 97,
+        99, 101, 98, 97, 71, 64, 63, 61, 67, 68, 74, 79, 82, 90, 93, 98, 102,
+        102, 102, 101, 72, 65, 64, 62, 66, 68, 75, 78, 83, 89, 92, 100, 101,
+        103, 104, 102, 73, 66, 65, 63, 66, 69, 75, 76, 84, 87, 93, 98, 102, 105,
+        106, 107, 74, 67, 67, 64, 66, 70, 74, 77, 84, 86, 94, 96, 103, 105, 106,
+        107, 75, 68, 68, 65, 66, 71, 74, 78, 83, 87, 93, 96, 103, 105, 109, 109,
+        76, 69, 69, 66, 67, 72, 73, 80, 82, 88, 91, 97, 101, 107, 109, 110, 77,
+        70, 70, 67, 67, 73, 73, 81, 81, 90, 90, 99, 99, 108, 108, 113,
         /* Size 32x16 */
-        64, 63, 61, 64, 67, 74, 84, 90, 98, 97, 98, 99, 101, 104, 109, 111, 114,
-        120, 127, 128, 129, 134, 137, 140, 143, 146, 149, 152, 156, 159, 163,
-        166, 62, 63, 64, 68, 72, 80, 86, 89, 93, 92, 91, 92, 93, 96, 100, 102,
-        104, 109, 115, 117, 118, 122, 125, 127, 130, 133, 136, 138, 141, 144,
-        147, 147, 74, 77, 80, 83, 86, 94, 95, 95, 96, 94, 92, 92, 93, 95, 98,
-        99, 101, 105, 110, 111, 112, 116, 119, 121, 124, 127, 130, 133, 136,
-        140, 143, 150, 84, 85, 85, 88, 90, 95, 97, 99, 101, 100, 99, 99, 100,
-        101, 104, 105, 107, 111, 116, 116, 117, 120, 122, 121, 122, 125, 127,
-        129, 132, 134, 137, 134, 96, 94, 92, 93, 94, 95, 100, 103, 106, 106,
-        107, 107, 108, 109, 111, 112, 113, 117, 121, 122, 123, 126, 128, 130,
-        132, 141, 142, 144, 146, 148, 150, 139, 98, 94, 91, 91, 92, 91, 99, 103,
-        107, 112, 117, 118, 119, 122, 125, 126, 128, 131, 135, 136, 136, 139,
-        144, 145, 145, 145, 136, 138, 140, 142, 144, 166, 105, 100, 96, 96, 95,
-        94, 101, 105, 109, 115, 123, 125, 128, 133, 137, 139, 141, 145, 150,
-        151, 151, 153, 152, 146, 144, 146, 153, 166, 166, 167, 168, 147, 109,
-        104, 100, 99, 99, 97, 104, 108, 111, 118, 125, 128, 131, 137, 142, 144,
-        147, 151, 157, 157, 158, 160, 156, 158, 170, 172, 170, 153, 151, 153,
-        155, 189, 115, 109, 104, 103, 103, 100, 107, 110, 114, 120, 128, 131,
-        134, 142, 147, 150, 153, 158, 164, 165, 166, 169, 173, 180, 177, 161,
-        163, 174, 194, 193, 191, 157, 127, 120, 115, 114, 112, 109, 115, 118,
-        121, 128, 135, 138, 142, 150, 156, 160, 164, 170, 178, 179, 180, 185,
-        188, 179, 176, 189, 199, 196, 167, 169, 171, 219, 133, 126, 121, 119,
-        118, 114, 120, 123, 125, 132, 139, 142, 146, 154, 161, 165, 169, 176,
-        184, 185, 187, 191, 189, 190, 209, 205, 180, 183, 214, 221, 218, 172,
-        139, 131, 126, 125, 122, 117, 120, 123, 132, 132, 135, 147, 147, 149,
-        164, 164, 164, 180, 182, 180, 197, 194, 192, 202, 198, 196, 220, 227,
-        205, 187, 190, 250, 144, 136, 131, 130, 125, 123, 121, 132, 127, 137,
-        142, 138, 157, 150, 156, 174, 160, 179, 183, 179, 203, 193, 205, 203,
-        197, 215, 211, 202, 216, 253, 247, 192, 149, 141, 137, 135, 130, 131,
-        122, 127, 137, 140, 137, 154, 141, 167, 152, 167, 173, 169, 192, 171,
-        210, 189, 205, 217, 207, 214, 202, 228, 226, 208, 211, 281, 155, 147,
-        143, 140, 136, 135, 127, 130, 146, 135, 153, 139, 164, 145, 177, 153,
-        182, 169, 190, 183, 191, 204, 198, 219, 200, 250, 206, 226, 208, 242,
-        242, 214, 161, 150, 152, 140, 145, 136, 140, 127, 134, 158, 139, 164,
-        143, 175, 148, 188, 154, 200, 161, 220, 169, 225, 178, 249, 188, 253,
-        198, 284, 210, 237, 214, 257,
+        32, 31, 30, 32, 33, 37, 42, 45, 49, 48, 49, 49, 50, 52, 54, 55, 57, 60,
+        63, 64, 64, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 31, 31, 32, 34,
+        36, 40, 43, 44, 46, 46, 45, 46, 46, 48, 50, 51, 52, 54, 57, 58, 59, 61,
+        62, 62, 63, 64, 65, 66, 67, 68, 69, 70, 37, 38, 40, 41, 43, 47, 47, 47,
+        48, 47, 46, 46, 46, 47, 49, 49, 50, 52, 55, 55, 56, 58, 59, 60, 62, 63,
+        64, 65, 67, 68, 69, 70, 42, 42, 42, 44, 45, 47, 48, 49, 50, 50, 49, 49,
+        50, 50, 52, 52, 53, 55, 58, 58, 58, 60, 60, 60, 60, 61, 62, 63, 64, 65,
+        66, 67, 48, 47, 46, 46, 47, 47, 50, 51, 53, 53, 53, 53, 54, 54, 55, 56,
+        56, 58, 60, 61, 61, 63, 64, 65, 66, 67, 66, 66, 66, 66, 67, 67, 49, 47,
+        45, 45, 46, 45, 49, 51, 53, 56, 58, 59, 59, 61, 62, 63, 64, 65, 67, 68,
+        68, 69, 71, 70, 69, 68, 68, 69, 70, 71, 72, 73, 52, 50, 48, 48, 47, 47,
+        50, 52, 54, 57, 61, 62, 64, 66, 68, 69, 70, 72, 75, 75, 75, 76, 74, 72,
+        73, 74, 75, 75, 74, 74, 73, 73, 54, 52, 50, 49, 49, 48, 52, 54, 55, 59,
+        62, 64, 65, 68, 71, 72, 73, 75, 78, 78, 79, 79, 78, 79, 81, 79, 78, 76,
+        77, 78, 80, 81, 57, 54, 52, 51, 51, 50, 53, 55, 57, 60, 64, 65, 67, 71,
+        73, 75, 76, 79, 82, 82, 83, 85, 86, 85, 83, 82, 83, 84, 84, 83, 82, 81,
+        63, 60, 57, 57, 56, 54, 57, 59, 60, 64, 67, 69, 71, 75, 78, 80, 82, 85,
+        89, 89, 90, 92, 91, 88, 89, 90, 89, 87, 86, 87, 88, 90, 66, 63, 60, 59,
+        59, 57, 60, 61, 62, 66, 69, 71, 73, 77, 80, 82, 84, 88, 92, 92, 93, 95,
+        94, 95, 96, 93, 92, 93, 94, 93, 91, 90, 67, 64, 62, 61, 60, 58, 58, 61,
+        63, 65, 67, 70, 72, 74, 78, 80, 82, 86, 88, 90, 95, 96, 96, 98, 97, 98,
+        100, 98, 96, 96, 97, 99, 68, 65, 63, 62, 60, 60, 59, 61, 62, 65, 66, 68,
+        72, 73, 76, 79, 80, 84, 87, 89, 93, 94, 98, 99, 99, 102, 101, 102, 103,
+        103, 101, 99, 69, 66, 65, 63, 62, 61, 60, 60, 63, 64, 66, 68, 70, 73,
+        74, 78, 80, 82, 85, 87, 91, 92, 96, 98, 101, 102, 103, 105, 105, 105,
+        107, 108, 71, 67, 66, 64, 63, 62, 62, 61, 62, 64, 66, 67, 70, 71, 75,
+        76, 79, 81, 84, 86, 89, 91, 94, 97, 98, 102, 104, 106, 106, 109, 109,
+        108, 72, 68, 68, 65, 65, 63, 63, 61, 62, 65, 65, 68, 69, 72, 73, 77, 77,
+        81, 81, 86, 87, 91, 91, 96, 97, 101, 102, 107, 107, 109, 110, 113,
         /* Size 4x16 */
-        62, 98, 127, 149, 64, 91, 115, 137, 72, 92, 112, 130, 86, 99, 115, 122,
-        93, 107, 121, 137, 91, 117, 135, 137, 93, 119, 142, 141, 100, 125, 156,
-        152, 104, 128, 164, 173, 115, 135, 178, 192, 118, 136, 180, 210, 125,
-        144, 188, 205, 130, 145, 176, 207, 136, 136, 199, 202, 141, 140, 167,
-        226, 147, 144, 171, 211,
+        31, 49, 63, 69, 32, 45, 57, 65, 36, 46, 56, 62, 43, 49, 57, 60, 46, 53,
+        60, 63, 45, 58, 67, 66, 46, 59, 71, 70, 50, 62, 78, 74, 52, 64, 82, 80,
+        57, 67, 89, 85, 59, 68, 90, 91, 62, 71, 91, 96, 63, 69, 89, 101, 65, 68,
+        89, 103, 67, 70, 86, 105, 69, 72, 88, 107,
         /* Size 16x4 */
-        62, 64, 72, 86, 93, 91, 93, 100, 104, 115, 118, 125, 130, 136, 141, 147,
-        98, 91, 92, 99, 107, 117, 119, 125, 128, 135, 136, 144, 145, 136, 140,
-        144, 127, 115, 112, 115, 121, 135, 142, 156, 164, 178, 180, 188, 176,
-        199, 167, 171, 149, 137, 130, 122, 137, 137, 141, 152, 173, 192, 210,
-        205, 207, 202, 226, 211,
+        31, 32, 36, 43, 46, 45, 46, 50, 52, 57, 59, 62, 63, 65, 67, 69, 49, 45,
+        46, 49, 53, 58, 59, 62, 64, 67, 68, 71, 69, 68, 70, 72, 63, 57, 56, 57,
+        60, 67, 71, 78, 82, 89, 90, 91, 89, 89, 86, 88, 69, 65, 62, 60, 63, 66,
+        70, 74, 80, 85, 91, 96, 101, 103, 105, 107,
         /* Size 8x32 */
-        64, 74, 96, 105, 115, 133, 144, 155, 63, 77, 94, 100, 109, 126, 136,
-        147, 61, 80, 92, 96, 104, 121, 131, 143, 64, 83, 93, 96, 103, 119, 130,
-        140, 67, 86, 94, 95, 103, 118, 125, 136, 74, 94, 95, 94, 100, 114, 123,
-        135, 84, 95, 100, 101, 107, 120, 121, 127, 90, 95, 103, 105, 110, 123,
-        132, 130, 98, 96, 106, 109, 114, 125, 127, 146, 97, 94, 106, 115, 120,
-        132, 137, 135, 98, 92, 107, 123, 128, 139, 142, 153, 99, 92, 107, 125,
-        131, 142, 138, 139, 101, 93, 108, 128, 134, 146, 157, 164, 104, 95, 109,
-        133, 142, 154, 150, 145, 109, 98, 111, 137, 147, 161, 156, 177, 111, 99,
-        112, 139, 150, 165, 174, 153, 114, 101, 113, 141, 153, 169, 160, 182,
-        120, 105, 117, 145, 158, 176, 179, 169, 127, 110, 121, 150, 164, 184,
-        183, 190, 128, 111, 122, 151, 165, 185, 179, 183, 129, 112, 123, 151,
-        166, 187, 203, 191, 134, 116, 126, 153, 169, 191, 193, 204, 137, 119,
-        128, 152, 173, 189, 205, 198, 140, 121, 130, 146, 180, 190, 203, 219,
-        143, 124, 132, 144, 177, 209, 197, 200, 146, 127, 141, 146, 161, 205,
-        215, 250, 149, 130, 142, 153, 163, 180, 211, 206, 152, 133, 144, 166,
-        174, 183, 202, 226, 156, 136, 146, 166, 194, 214, 216, 208, 159, 140,
-        148, 167, 193, 221, 253, 242, 163, 143, 150, 168, 191, 218, 247, 242,
-        166, 150, 139, 147, 157, 172, 192, 214,
+        32, 37, 48, 52, 57, 66, 68, 71, 31, 38, 47, 50, 54, 63, 65, 67, 30, 40,
+        46, 48, 52, 60, 63, 66, 32, 41, 46, 48, 51, 59, 62, 64, 33, 43, 47, 47,
+        51, 59, 60, 63, 37, 47, 47, 47, 50, 57, 60, 62, 42, 47, 50, 50, 53, 60,
+        59, 62, 45, 47, 51, 52, 55, 61, 61, 61, 49, 48, 53, 54, 57, 62, 62, 62,
+        48, 47, 53, 57, 60, 66, 65, 64, 49, 46, 53, 61, 64, 69, 66, 66, 49, 46,
+        53, 62, 65, 71, 68, 67, 50, 46, 54, 64, 67, 73, 72, 70, 52, 47, 54, 66,
+        71, 77, 73, 71, 54, 49, 55, 68, 73, 80, 76, 75, 55, 49, 56, 69, 75, 82,
+        79, 76, 57, 50, 56, 70, 76, 84, 80, 79, 60, 52, 58, 72, 79, 88, 84, 81,
+        63, 55, 60, 75, 82, 92, 87, 84, 64, 55, 61, 75, 82, 92, 89, 86, 64, 56,
+        61, 75, 83, 93, 93, 89, 67, 58, 63, 76, 85, 95, 94, 91, 68, 59, 64, 74,
+        86, 94, 98, 94, 69, 60, 65, 72, 85, 95, 99, 97, 70, 62, 66, 73, 83, 96,
+        99, 98, 71, 63, 67, 74, 82, 93, 102, 102, 72, 64, 66, 75, 83, 92, 101,
+        104, 73, 65, 66, 75, 84, 93, 102, 106, 74, 67, 66, 74, 84, 94, 103, 106,
+        75, 68, 66, 74, 83, 93, 103, 109, 76, 69, 67, 73, 82, 91, 101, 109, 77,
+        70, 67, 73, 81, 90, 99, 108,
         /* Size 32x8 */
-        64, 63, 61, 64, 67, 74, 84, 90, 98, 97, 98, 99, 101, 104, 109, 111, 114,
-        120, 127, 128, 129, 134, 137, 140, 143, 146, 149, 152, 156, 159, 163,
-        166, 74, 77, 80, 83, 86, 94, 95, 95, 96, 94, 92, 92, 93, 95, 98, 99,
-        101, 105, 110, 111, 112, 116, 119, 121, 124, 127, 130, 133, 136, 140,
-        143, 150, 96, 94, 92, 93, 94, 95, 100, 103, 106, 106, 107, 107, 108,
-        109, 111, 112, 113, 117, 121, 122, 123, 126, 128, 130, 132, 141, 142,
-        144, 146, 148, 150, 139, 105, 100, 96, 96, 95, 94, 101, 105, 109, 115,
-        123, 125, 128, 133, 137, 139, 141, 145, 150, 151, 151, 153, 152, 146,
-        144, 146, 153, 166, 166, 167, 168, 147, 115, 109, 104, 103, 103, 100,
-        107, 110, 114, 120, 128, 131, 134, 142, 147, 150, 153, 158, 164, 165,
-        166, 169, 173, 180, 177, 161, 163, 174, 194, 193, 191, 157, 133, 126,
-        121, 119, 118, 114, 120, 123, 125, 132, 139, 142, 146, 154, 161, 165,
-        169, 176, 184, 185, 187, 191, 189, 190, 209, 205, 180, 183, 214, 221,
-        218, 172, 144, 136, 131, 130, 125, 123, 121, 132, 127, 137, 142, 138,
-        157, 150, 156, 174, 160, 179, 183, 179, 203, 193, 205, 203, 197, 215,
-        211, 202, 216, 253, 247, 192, 155, 147, 143, 140, 136, 135, 127, 130,
-        146, 135, 153, 139, 164, 145, 177, 153, 182, 169, 190, 183, 191, 204,
-        198, 219, 200, 250, 206, 226, 208, 242, 242, 214 },
+        32, 31, 30, 32, 33, 37, 42, 45, 49, 48, 49, 49, 50, 52, 54, 55, 57, 60,
+        63, 64, 64, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 37, 38, 40, 41,
+        43, 47, 47, 47, 48, 47, 46, 46, 46, 47, 49, 49, 50, 52, 55, 55, 56, 58,
+        59, 60, 62, 63, 64, 65, 67, 68, 69, 70, 48, 47, 46, 46, 47, 47, 50, 51,
+        53, 53, 53, 53, 54, 54, 55, 56, 56, 58, 60, 61, 61, 63, 64, 65, 66, 67,
+        66, 66, 66, 66, 67, 67, 52, 50, 48, 48, 47, 47, 50, 52, 54, 57, 61, 62,
+        64, 66, 68, 69, 70, 72, 75, 75, 75, 76, 74, 72, 73, 74, 75, 75, 74, 74,
+        73, 73, 57, 54, 52, 51, 51, 50, 53, 55, 57, 60, 64, 65, 67, 71, 73, 75,
+        76, 79, 82, 82, 83, 85, 86, 85, 83, 82, 83, 84, 84, 83, 82, 81, 66, 63,
+        60, 59, 59, 57, 60, 61, 62, 66, 69, 71, 73, 77, 80, 82, 84, 88, 92, 92,
+        93, 95, 94, 95, 96, 93, 92, 93, 94, 93, 91, 90, 68, 65, 63, 62, 60, 60,
+        59, 61, 62, 65, 66, 68, 72, 73, 76, 79, 80, 84, 87, 89, 93, 94, 98, 99,
+        99, 102, 101, 102, 103, 103, 101, 99, 71, 67, 66, 64, 63, 62, 62, 61,
+        62, 64, 66, 67, 70, 71, 75, 76, 79, 81, 84, 86, 89, 91, 94, 97, 98, 102,
+        104, 106, 106, 109, 109, 108 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        79, 164, 164, 311,
+        39, 82, 82, 155,
 #endif
         /* Size 4x4 */
-        65, 82, 138, 189, 82, 127, 176, 219, 138, 176, 254, 259, 189, 219, 259,
-        371,
+        32, 41, 69, 92, 41, 63, 88, 103, 69, 88, 127, 140, 92, 103, 140, 184,
         /* Size 8x8 */
-        64, 65, 74, 95, 125, 157, 184, 213, 65, 71, 79, 93, 116, 144, 168, 197,
-        74, 79, 103, 120, 142, 169, 188, 198, 95, 93, 120, 146, 174, 201, 210,
-        215, 125, 116, 142, 174, 210, 242, 266, 258, 157, 144, 169, 201, 242,
-        280, 284, 332, 184, 168, 188, 210, 266, 284, 340, 426, 213, 197, 198,
-        215, 258, 332, 426, 406,
+        32, 32, 37, 47, 62, 78, 90, 102, 32, 35, 39, 46, 58, 72, 84, 96, 37, 39,
+        51, 60, 71, 84, 93, 100, 47, 46, 60, 73, 87, 100, 106, 113, 62, 58, 71,
+        87, 105, 121, 129, 132, 78, 72, 84, 100, 121, 140, 148, 155, 90, 84, 93,
+        106, 129, 148, 169, 183, 102, 96, 100, 113, 132, 155, 183, 201,
         /* Size 16x16 */
-        64, 63, 63, 65, 72, 79, 95, 108, 123, 143, 160, 173, 187, 202, 217, 234,
-        63, 64, 65, 66, 69, 75, 88, 100, 113, 131, 146, 158, 172, 186, 200, 216,
-        63, 65, 67, 69, 73, 78, 90, 100, 112, 129, 143, 154, 166, 177, 191, 207,
-        65, 66, 69, 73, 80, 84, 94, 103, 114, 130, 142, 153, 160, 170, 181, 196,
-        72, 69, 73, 80, 97, 101, 112, 120, 131, 146, 158, 168, 177, 180, 206,
-        217, 79, 75, 78, 84, 101, 108, 121, 130, 141, 156, 168, 178, 194, 189,
-        214, 230, 95, 88, 90, 94, 112, 121, 139, 151, 163, 178, 190, 200, 200,
-        215, 216, 247, 108, 100, 100, 103, 120, 130, 151, 165, 178, 195, 208,
-        218, 216, 241, 221, 268, 123, 113, 112, 114, 131, 141, 163, 178, 194,
-        213, 227, 238, 250, 264, 234, 288, 143, 131, 129, 130, 146, 156, 178,
-        195, 213, 235, 251, 263, 270, 259, 249, 321, 160, 146, 143, 142, 158,
-        168, 190, 208, 227, 251, 268, 281, 275, 271, 280, 338, 173, 158, 154,
-        153, 168, 178, 200, 218, 238, 263, 281, 295, 303, 308, 321, 380, 187,
-        172, 166, 160, 177, 194, 200, 216, 250, 270, 275, 303, 325, 329, 384,
-        399, 202, 186, 177, 170, 180, 189, 215, 241, 264, 259, 271, 308, 329,
-        355, 357, 461, 217, 200, 191, 181, 206, 214, 216, 221, 234, 249, 280,
-        321, 384, 357, 389, 387, 234, 216, 207, 196, 217, 230, 247, 268, 288,
-        321, 338, 380, 399, 461, 387, 425,
+        32, 31, 31, 32, 36, 39, 47, 54, 61, 71, 80, 86, 92, 98, 104, 111, 31,
+        32, 32, 33, 34, 37, 44, 50, 56, 65, 73, 79, 85, 91, 98, 105, 31, 32, 33,
+        34, 36, 39, 45, 50, 56, 64, 71, 77, 82, 88, 94, 100, 32, 33, 34, 36, 40,
+        42, 47, 51, 57, 65, 71, 76, 80, 85, 91, 98, 36, 34, 36, 40, 48, 50, 56,
+        60, 65, 73, 79, 84, 86, 90, 95, 98, 39, 37, 39, 42, 50, 54, 60, 65, 70,
+        78, 84, 89, 95, 96, 102, 105, 47, 44, 45, 47, 56, 60, 69, 75, 81, 89,
+        95, 100, 102, 104, 109, 112, 54, 50, 50, 51, 60, 65, 75, 82, 89, 97,
+        104, 109, 110, 114, 117, 121, 61, 56, 56, 57, 65, 70, 81, 89, 97, 106,
+        113, 119, 122, 126, 125, 130, 71, 65, 64, 65, 73, 78, 89, 97, 106, 117,
+        125, 131, 134, 134, 136, 141, 80, 73, 71, 71, 79, 84, 95, 104, 113, 125,
+        134, 140, 142, 145, 146, 152, 86, 79, 77, 76, 84, 89, 100, 109, 119,
+        131, 140, 147, 154, 157, 160, 165, 92, 85, 82, 80, 86, 95, 102, 110,
+        122, 134, 142, 154, 162, 168, 174, 178, 98, 91, 88, 85, 90, 96, 104,
+        114, 126, 134, 145, 157, 168, 176, 184, 193, 104, 98, 94, 91, 95, 102,
+        109, 117, 125, 136, 146, 160, 174, 184, 193, 201, 111, 105, 100, 98, 98,
+        105, 112, 121, 130, 141, 152, 165, 178, 193, 201, 210,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 64, 65, 68, 72, 76, 79, 88, 95, 99, 108, 118, 123,
-        131, 143, 153, 160, 166, 173, 180, 187, 194, 202, 209, 217, 225, 234,
-        243, 63, 64, 64, 64, 64, 65, 66, 68, 70, 74, 77, 85, 91, 95, 103, 113,
-        117, 125, 136, 145, 152, 157, 164, 171, 177, 184, 191, 198, 205, 213,
-        221, 227, 63, 64, 64, 65, 65, 65, 66, 67, 69, 73, 75, 82, 88, 92, 100,
-        109, 113, 120, 131, 140, 146, 152, 158, 165, 172, 178, 186, 193, 200,
-        208, 216, 229, 63, 64, 65, 65, 65, 66, 67, 68, 70, 73, 76, 82, 88, 91,
-        99, 108, 112, 119, 130, 138, 144, 150, 156, 163, 169, 175, 182, 189,
-        196, 203, 211, 212, 63, 64, 65, 65, 67, 68, 69, 71, 73, 76, 78, 84, 90,
-        93, 100, 108, 112, 118, 129, 137, 143, 148, 154, 160, 166, 171, 177,
-        184, 191, 199, 207, 218, 64, 65, 65, 66, 68, 71, 72, 74, 77, 79, 81, 85,
-        90, 93, 99, 107, 110, 116, 126, 133, 139, 144, 149, 156, 162, 168, 177,
-        184, 190, 197, 204, 208, 65, 66, 66, 67, 69, 72, 73, 76, 80, 82, 84, 89,
-        94, 97, 103, 111, 114, 120, 130, 137, 142, 147, 153, 156, 160, 166, 170,
-        174, 181, 188, 196, 211, 68, 68, 67, 68, 71, 74, 76, 79, 85, 88, 90, 95,
-        100, 103, 109, 117, 120, 126, 136, 143, 148, 153, 159, 164, 173, 178,
-        183, 179, 183, 189, 196, 195, 72, 70, 69, 70, 73, 77, 80, 85, 97, 100,
-        101, 108, 112, 115, 120, 128, 131, 136, 146, 153, 158, 162, 168, 173,
-        177, 175, 180, 191, 206, 211, 217, 203, 76, 74, 73, 73, 76, 79, 82, 88,
-        100, 103, 105, 112, 117, 120, 126, 134, 137, 142, 152, 159, 164, 169,
-        174, 175, 178, 188, 197, 201, 192, 198, 204, 237, 79, 77, 75, 76, 78,
-        81, 84, 90, 101, 105, 108, 116, 121, 124, 130, 138, 141, 147, 156, 163,
-        168, 173, 178, 184, 194, 197, 189, 194, 214, 224, 230, 211, 88, 85, 82,
-        82, 84, 85, 89, 95, 108, 112, 116, 127, 133, 136, 143, 151, 154, 159,
-        169, 176, 181, 185, 190, 197, 195, 194, 210, 219, 211, 206, 211, 248,
-        95, 91, 88, 88, 90, 90, 94, 100, 112, 117, 121, 133, 139, 142, 151, 159,
-        163, 168, 178, 185, 190, 195, 200, 199, 200, 218, 215, 204, 216, 242,
-        247, 218, 99, 95, 92, 91, 93, 93, 97, 103, 115, 120, 124, 136, 142, 146,
-        155, 163, 167, 174, 184, 191, 196, 201, 206, 208, 220, 210, 210, 240,
-        241, 215, 221, 268, 108, 103, 100, 99, 100, 99, 103, 109, 120, 126, 130,
-        143, 151, 155, 165, 174, 178, 185, 195, 203, 208, 213, 218, 227, 216,
-        223, 241, 220, 221, 264, 268, 227, 118, 113, 109, 108, 108, 107, 111,
-        117, 128, 134, 138, 151, 159, 163, 174, 184, 189, 196, 207, 215, 221,
-        226, 232, 228, 232, 247, 223, 245, 263, 229, 231, 291, 123, 117, 113,
-        112, 112, 110, 114, 120, 131, 137, 141, 154, 163, 167, 178, 189, 194,
-        202, 213, 221, 227, 232, 238, 237, 250, 233, 264, 259, 234, 275, 288,
-        237, 131, 125, 120, 119, 118, 116, 120, 126, 136, 142, 147, 159, 168,
-        174, 185, 196, 202, 210, 222, 231, 237, 242, 248, 260, 242, 266, 255,
-        244, 294, 258, 245, 314, 143, 136, 131, 130, 129, 126, 130, 136, 146,
-        152, 156, 169, 178, 184, 195, 207, 213, 222, 235, 244, 251, 256, 263,
-        261, 270, 267, 259, 291, 249, 286, 321, 251, 153, 145, 140, 138, 137,
-        133, 137, 143, 153, 159, 163, 176, 185, 191, 203, 215, 221, 231, 244,
-        254, 261, 267, 273, 270, 282, 267, 302, 259, 311, 288, 260, 351, 160,
-        152, 146, 144, 143, 139, 142, 148, 158, 164, 168, 181, 190, 196, 208,
-        221, 227, 237, 251, 261, 268, 274, 281, 298, 275, 305, 271, 328, 280,
-        289, 338, 265, 166, 157, 152, 150, 148, 144, 147, 153, 162, 169, 173,
-        185, 195, 201, 213, 226, 232, 242, 256, 267, 274, 280, 288, 292, 314,
-        284, 324, 286, 320, 332, 276, 365, 173, 164, 158, 156, 154, 149, 153,
-        159, 168, 174, 178, 190, 200, 206, 218, 232, 238, 248, 263, 273, 281,
-        288, 295, 295, 303, 323, 308, 323, 321, 299, 380, 282, 180, 171, 165,
-        163, 160, 156, 156, 164, 173, 175, 184, 197, 199, 208, 227, 228, 237,
-        260, 261, 270, 298, 292, 295, 311, 302, 315, 327, 341, 317, 367, 295,
-        414, 187, 177, 172, 169, 166, 162, 160, 173, 177, 178, 194, 195, 200,
-        220, 216, 232, 250, 242, 270, 282, 275, 314, 303, 302, 325, 308, 329,
-        326, 384, 307, 399, 301, 194, 184, 178, 175, 171, 168, 166, 178, 175,
-        188, 197, 194, 218, 210, 223, 247, 233, 266, 267, 267, 305, 284, 323,
-        315, 308, 340, 315, 344, 322, 426, 313, 429, 202, 191, 186, 182, 177,
-        177, 170, 183, 180, 197, 189, 210, 215, 210, 241, 223, 264, 255, 259,
-        302, 271, 324, 308, 327, 329, 315, 355, 323, 357, 329, 461, 320, 209,
-        198, 193, 189, 184, 184, 174, 179, 191, 201, 194, 219, 204, 240, 220,
-        245, 259, 244, 291, 259, 328, 286, 323, 341, 326, 344, 323, 371, 330,
-        372, 337, 498, 217, 205, 200, 196, 191, 190, 181, 183, 206, 192, 214,
-        211, 216, 241, 221, 263, 234, 294, 249, 311, 280, 320, 321, 317, 384,
-        322, 357, 330, 389, 337, 387, 344, 225, 213, 208, 203, 199, 197, 188,
-        189, 211, 198, 224, 206, 242, 215, 264, 229, 275, 258, 286, 288, 289,
-        332, 299, 367, 307, 426, 329, 372, 337, 406, 345, 402, 234, 221, 216,
-        211, 207, 204, 196, 196, 217, 204, 230, 211, 247, 221, 268, 231, 288,
-        245, 321, 260, 338, 276, 380, 295, 399, 313, 461, 337, 387, 345, 425,
-        353, 243, 227, 229, 212, 218, 208, 211, 195, 203, 237, 211, 248, 218,
-        268, 227, 291, 237, 314, 251, 351, 265, 365, 282, 414, 301, 429, 320,
-        498, 344, 402, 353, 444,
+        32, 31, 31, 31, 31, 32, 32, 34, 36, 38, 39, 44, 47, 49, 54, 59, 61, 65,
+        71, 76, 80, 83, 86, 89, 92, 95, 98, 101, 104, 108, 111, 114, 31, 32, 32,
+        32, 32, 32, 33, 34, 35, 37, 38, 42, 45, 47, 51, 56, 58, 62, 68, 72, 76,
+        78, 82, 85, 88, 90, 93, 96, 99, 102, 105, 109, 31, 32, 32, 32, 32, 32,
+        33, 33, 34, 36, 37, 41, 44, 46, 50, 54, 56, 60, 65, 70, 73, 76, 79, 82,
+        85, 88, 91, 95, 98, 101, 105, 109, 31, 32, 32, 32, 32, 33, 33, 34, 35,
+        36, 38, 41, 44, 45, 49, 54, 56, 59, 65, 69, 72, 75, 78, 81, 84, 86, 89,
+        92, 95, 98, 101, 104, 31, 32, 32, 32, 33, 34, 34, 35, 36, 38, 39, 42,
+        45, 46, 50, 54, 56, 59, 64, 68, 71, 74, 77, 79, 82, 85, 88, 91, 94, 97,
+        100, 104, 32, 32, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 45, 46, 49,
+        53, 55, 58, 63, 66, 69, 72, 74, 78, 81, 84, 87, 90, 93, 96, 99, 102, 32,
+        33, 33, 33, 34, 36, 36, 38, 40, 41, 42, 44, 47, 48, 51, 55, 57, 60, 65,
+        68, 71, 73, 76, 78, 80, 82, 85, 88, 91, 95, 98, 102, 34, 34, 33, 34, 35,
+        37, 38, 39, 42, 44, 45, 47, 50, 51, 54, 58, 60, 63, 68, 71, 74, 76, 79,
+        82, 85, 86, 87, 88, 90, 93, 96, 99, 36, 35, 34, 35, 36, 38, 40, 42, 48,
+        50, 50, 54, 56, 57, 60, 64, 65, 68, 73, 76, 79, 81, 84, 86, 86, 88, 90,
+        93, 95, 97, 98, 100, 38, 37, 36, 36, 38, 39, 41, 44, 50, 51, 52, 56, 58,
+        60, 63, 67, 68, 71, 76, 79, 82, 84, 87, 87, 90, 93, 94, 95, 96, 100,
+        103, 106, 39, 38, 37, 38, 39, 40, 42, 45, 50, 52, 54, 58, 60, 62, 65,
+        69, 70, 73, 78, 81, 84, 86, 89, 92, 95, 95, 96, 99, 102, 104, 105, 106,
+        44, 42, 41, 41, 42, 42, 44, 47, 54, 56, 58, 63, 66, 68, 71, 75, 77, 79,
+        84, 88, 90, 92, 95, 97, 97, 99, 102, 103, 103, 106, 109, 113, 47, 45,
+        44, 44, 45, 45, 47, 50, 56, 58, 60, 66, 69, 71, 75, 79, 81, 84, 89, 92,
+        95, 97, 100, 100, 102, 105, 104, 106, 109, 111, 112, 113, 49, 47, 46,
+        45, 46, 46, 48, 51, 57, 60, 62, 68, 71, 73, 77, 81, 83, 87, 92, 95, 98,
+        100, 103, 105, 107, 106, 109, 112, 112, 113, 117, 120, 54, 51, 50, 49,
+        50, 49, 51, 54, 60, 63, 65, 71, 75, 77, 82, 87, 89, 92, 97, 101, 104,
+        106, 109, 112, 110, 113, 114, 114, 117, 121, 121, 121, 59, 56, 54, 54,
+        54, 53, 55, 58, 64, 67, 69, 75, 79, 81, 87, 92, 94, 98, 103, 107, 110,
+        113, 116, 114, 117, 118, 117, 121, 122, 122, 125, 129, 61, 58, 56, 56,
+        56, 55, 57, 60, 65, 68, 70, 77, 81, 83, 89, 94, 97, 101, 106, 110, 113,
+        116, 119, 120, 122, 121, 126, 124, 125, 130, 130, 130, 65, 62, 60, 59,
+        59, 58, 60, 63, 68, 71, 73, 79, 84, 87, 92, 98, 101, 105, 111, 115, 118,
+        121, 124, 128, 125, 129, 128, 131, 133, 132, 135, 139, 71, 68, 65, 65,
+        64, 63, 65, 68, 73, 76, 78, 84, 89, 92, 97, 103, 106, 111, 117, 122,
+        125, 128, 131, 131, 134, 132, 134, 136, 136, 140, 141, 140, 76, 72, 70,
+        69, 68, 66, 68, 71, 76, 79, 81, 88, 92, 95, 101, 107, 110, 115, 122,
+        127, 130, 133, 136, 136, 138, 139, 141, 140, 145, 143, 146, 151, 80, 76,
+        73, 72, 71, 69, 71, 74, 79, 82, 84, 90, 95, 98, 104, 110, 113, 118, 125,
+        130, 134, 137, 140, 146, 142, 146, 145, 149, 146, 150, 152, 151, 83, 78,
+        76, 75, 74, 72, 73, 76, 81, 84, 86, 92, 97, 100, 106, 113, 116, 121,
+        128, 133, 137, 140, 144, 147, 152, 148, 154, 151, 156, 155, 156, 162,
+        86, 82, 79, 78, 77, 74, 76, 79, 84, 87, 89, 95, 100, 103, 109, 116, 119,
+        124, 131, 136, 140, 144, 147, 150, 154, 159, 157, 160, 160, 162, 165,
+        162, 89, 85, 82, 81, 79, 78, 78, 82, 86, 87, 92, 97, 100, 105, 112, 114,
+        120, 128, 131, 136, 146, 147, 150, 155, 156, 161, 166, 165, 167, 169,
+        169, 175, 92, 88, 85, 84, 82, 81, 80, 85, 86, 90, 95, 97, 102, 107, 110,
+        117, 122, 125, 134, 138, 142, 152, 154, 156, 162, 163, 168, 173, 174,
+        174, 178, 176, 95, 90, 88, 86, 85, 84, 82, 86, 88, 93, 95, 99, 105, 106,
+        113, 118, 121, 129, 132, 139, 146, 148, 159, 161, 163, 169, 170, 176,
+        180, 183, 181, 187, 98, 93, 91, 89, 88, 87, 85, 87, 90, 94, 96, 102,
+        104, 109, 114, 117, 126, 128, 134, 141, 145, 154, 157, 166, 168, 170,
+        176, 178, 184, 188, 193, 188, 101, 96, 95, 92, 91, 90, 88, 88, 93, 95,
+        99, 103, 106, 112, 114, 121, 124, 131, 136, 140, 149, 151, 160, 165,
+        173, 176, 178, 184, 186, 192, 196, 203, 104, 99, 98, 95, 94, 93, 91, 90,
+        95, 96, 102, 103, 109, 112, 117, 122, 125, 133, 136, 145, 146, 156, 160,
+        167, 174, 180, 184, 186, 193, 194, 201, 204, 108, 102, 101, 98, 97, 96,
+        95, 93, 97, 100, 104, 106, 111, 113, 121, 122, 130, 132, 140, 143, 150,
+        155, 162, 169, 174, 183, 188, 192, 194, 201, 202, 210, 111, 105, 105,
+        101, 100, 99, 98, 96, 98, 103, 105, 109, 112, 117, 121, 125, 130, 135,
+        141, 146, 152, 156, 165, 169, 178, 181, 193, 196, 201, 202, 210, 211,
+        114, 109, 109, 104, 104, 102, 102, 99, 100, 106, 106, 113, 113, 120,
+        121, 129, 130, 139, 140, 151, 151, 162, 162, 175, 176, 187, 188, 203,
+        204, 210, 211, 219,
         /* Size 4x8 */
-        64, 85, 139, 191, 66, 85, 128, 177, 73, 112, 154, 192, 92, 135, 186,
-        235, 120, 159, 225, 247, 151, 185, 260, 286, 176, 197, 279, 336, 203,
-        206, 254, 328,
+        32, 42, 69, 88, 33, 42, 64, 83, 36, 56, 77, 88, 46, 67, 93, 105, 60, 79,
+        112, 122, 75, 92, 130, 144, 86, 95, 136, 167, 98, 105, 136, 177,
         /* Size 8x4 */
-        64, 66, 73, 92, 120, 151, 176, 203, 85, 85, 112, 135, 159, 185, 197,
-        206, 139, 128, 154, 186, 225, 260, 279, 254, 191, 177, 192, 235, 247,
-        286, 336, 328,
+        32, 33, 36, 46, 60, 75, 86, 98, 42, 42, 56, 67, 79, 92, 95, 105, 69, 64,
+        77, 93, 112, 130, 136, 136, 88, 83, 88, 105, 122, 144, 167, 177,
         /* Size 8x16 */
-        64, 64, 72, 95, 131, 158, 189, 215, 63, 65, 70, 88, 120, 145, 173, 199,
-        64, 68, 73, 90, 118, 142, 166, 190, 65, 71, 80, 94, 120, 142, 161, 180,
-        72, 75, 96, 112, 136, 157, 171, 203, 79, 80, 101, 121, 147, 168, 192,
-        217, 94, 91, 112, 139, 168, 190, 215, 235, 107, 100, 120, 150, 185, 207,
-        220, 258, 122, 112, 131, 163, 201, 226, 230, 268, 142, 128, 146, 178,
-        222, 250, 266, 285, 159, 141, 158, 190, 236, 267, 302, 290, 172, 152,
-        168, 200, 248, 280, 312, 305, 186, 164, 178, 200, 251, 311, 304, 311,
-        200, 177, 194, 216, 238, 270, 328, 323, 216, 191, 204, 239, 288, 330,
-        341, 328, 232, 207, 216, 247, 289, 339, 401, 396,
+        32, 32, 36, 47, 65, 79, 90, 96, 31, 32, 35, 44, 60, 72, 84, 90, 32, 34,
+        36, 45, 59, 71, 80, 87, 32, 35, 40, 47, 60, 71, 78, 85, 36, 37, 48, 56,
+        68, 78, 83, 87, 39, 40, 50, 60, 73, 84, 91, 94, 47, 45, 56, 69, 84, 95,
+        101, 101, 53, 50, 60, 75, 92, 103, 108, 110, 61, 56, 65, 81, 100, 113,
+        116, 118, 71, 64, 73, 89, 111, 125, 129, 129, 79, 70, 79, 95, 118, 133,
+        142, 138, 86, 76, 84, 100, 124, 140, 153, 150, 92, 82, 89, 101, 121,
+        148, 157, 161, 98, 88, 93, 108, 124, 141, 163, 174, 104, 94, 95, 110,
+        129, 151, 171, 181, 110, 100, 98, 111, 127, 147, 169, 188,
         /* Size 16x8 */
-        64, 63, 64, 65, 72, 79, 94, 107, 122, 142, 159, 172, 186, 200, 216, 232,
-        64, 65, 68, 71, 75, 80, 91, 100, 112, 128, 141, 152, 164, 177, 191, 207,
-        72, 70, 73, 80, 96, 101, 112, 120, 131, 146, 158, 168, 178, 194, 204,
-        216, 95, 88, 90, 94, 112, 121, 139, 150, 163, 178, 190, 200, 200, 216,
-        239, 247, 131, 120, 118, 120, 136, 147, 168, 185, 201, 222, 236, 248,
-        251, 238, 288, 289, 158, 145, 142, 142, 157, 168, 190, 207, 226, 250,
-        267, 280, 311, 270, 330, 339, 189, 173, 166, 161, 171, 192, 215, 220,
-        230, 266, 302, 312, 304, 328, 341, 401, 215, 199, 190, 180, 203, 217,
-        235, 258, 268, 285, 290, 305, 311, 323, 328, 396,
+        32, 31, 32, 32, 36, 39, 47, 53, 61, 71, 79, 86, 92, 98, 104, 110, 32,
+        32, 34, 35, 37, 40, 45, 50, 56, 64, 70, 76, 82, 88, 94, 100, 36, 35, 36,
+        40, 48, 50, 56, 60, 65, 73, 79, 84, 89, 93, 95, 98, 47, 44, 45, 47, 56,
+        60, 69, 75, 81, 89, 95, 100, 101, 108, 110, 111, 65, 60, 59, 60, 68, 73,
+        84, 92, 100, 111, 118, 124, 121, 124, 129, 127, 79, 72, 71, 71, 78, 84,
+        95, 103, 113, 125, 133, 140, 148, 141, 151, 147, 90, 84, 80, 78, 83, 91,
+        101, 108, 116, 129, 142, 153, 157, 163, 171, 169, 96, 90, 87, 85, 87,
+        94, 101, 110, 118, 129, 138, 150, 161, 174, 181, 188,
         /* Size 16x32 */
-        64, 63, 64, 65, 72, 88, 95, 107, 131, 146, 158, 177, 189, 201, 215, 229,
-        63, 64, 65, 66, 71, 85, 91, 103, 124, 139, 151, 168, 179, 191, 203, 214,
-        63, 65, 65, 66, 70, 82, 88, 99, 120, 134, 145, 162, 173, 186, 199, 216,
-        63, 65, 66, 67, 70, 82, 88, 99, 119, 132, 143, 160, 171, 182, 194, 201,
-        64, 65, 68, 69, 73, 84, 90, 100, 118, 131, 142, 157, 166, 178, 190, 206,
-        64, 66, 70, 72, 77, 85, 90, 99, 116, 128, 138, 153, 164, 177, 188, 197,
-        65, 66, 71, 73, 80, 89, 94, 103, 120, 132, 142, 154, 161, 168, 180, 200,
-        68, 68, 72, 76, 85, 96, 101, 109, 126, 138, 147, 162, 174, 173, 181,
-        185, 72, 69, 75, 80, 96, 108, 112, 120, 136, 148, 157, 171, 171, 187,
-        203, 192, 76, 73, 78, 83, 99, 112, 117, 126, 142, 154, 163, 174, 184,
-        192, 191, 227, 79, 75, 80, 85, 101, 116, 121, 130, 147, 159, 168, 181,
-        192, 190, 217, 201, 88, 82, 85, 90, 107, 126, 132, 143, 159, 171, 180,
-        196, 190, 213, 198, 239, 94, 88, 91, 95, 112, 132, 139, 150, 168, 181,
-        190, 199, 215, 199, 235, 209, 98, 92, 94, 97, 114, 135, 142, 155, 173,
-        186, 195, 206, 209, 235, 209, 259, 107, 99, 100, 103, 120, 142, 150,
-        164, 185, 198, 207, 225, 220, 217, 258, 219, 117, 108, 108, 111, 127,
-        150, 159, 174, 196, 210, 220, 229, 244, 240, 224, 282, 122, 113, 112,
-        115, 131, 154, 163, 178, 201, 215, 226, 235, 230, 250, 268, 229, 130,
-        120, 118, 121, 136, 159, 168, 185, 210, 225, 236, 256, 258, 247, 249,
-        304, 142, 131, 128, 131, 146, 169, 178, 195, 222, 238, 250, 262, 266,
-        284, 285, 242, 152, 139, 136, 138, 153, 176, 185, 202, 230, 247, 260,
-        266, 264, 253, 275, 340, 159, 145, 141, 143, 158, 181, 190, 208, 236,
-        254, 267, 290, 302, 316, 290, 257, 165, 151, 146, 148, 162, 185, 195,
-        212, 242, 260, 273, 291, 290, 286, 313, 354, 172, 157, 152, 154, 168,
-        190, 200, 218, 248, 266, 280, 292, 312, 314, 305, 273, 179, 164, 158,
-        158, 173, 193, 199, 223, 253, 260, 287, 306, 312, 335, 344, 400, 186,
-        170, 164, 162, 178, 195, 200, 239, 251, 259, 311, 302, 304, 322, 311,
-        292, 193, 176, 171, 167, 190, 197, 205, 241, 233, 279, 305, 300, 333,
-        336, 405, 415, 200, 182, 177, 173, 194, 189, 216, 241, 238, 295, 270,
-        340, 328, 316, 323, 311, 208, 189, 184, 179, 199, 194, 236, 220, 256,
-        292, 276, 353, 313, 362, 362, 481, 216, 196, 191, 185, 204, 200, 239,
-        221, 288, 249, 330, 316, 341, 361, 328, 333, 224, 203, 199, 191, 210,
-        206, 243, 226, 288, 254, 343, 288, 410, 328, 395, 389, 232, 211, 207,
-        198, 216, 212, 247, 232, 289, 260, 339, 295, 401, 335, 396, 342, 241,
-        215, 219, 200, 204, 246, 218, 287, 237, 344, 265, 405, 301, 476, 342,
-        430,
+        32, 31, 32, 32, 36, 44, 47, 53, 65, 73, 79, 87, 90, 93, 96, 99, 31, 32,
+        32, 33, 35, 42, 45, 51, 62, 69, 75, 83, 86, 88, 91, 94, 31, 32, 32, 33,
+        35, 41, 44, 49, 60, 67, 72, 80, 84, 87, 90, 94, 31, 32, 33, 33, 35, 41,
+        44, 49, 59, 66, 71, 79, 82, 84, 87, 90, 32, 32, 34, 34, 36, 42, 45, 50,
+        59, 65, 71, 78, 80, 83, 87, 90, 32, 33, 35, 36, 38, 42, 45, 49, 58, 64,
+        69, 76, 80, 83, 86, 88, 32, 33, 35, 36, 40, 44, 47, 51, 60, 66, 71, 76,
+        78, 81, 85, 89, 34, 34, 36, 38, 42, 48, 50, 54, 63, 69, 73, 80, 82, 81,
+        84, 86, 36, 34, 37, 40, 48, 54, 56, 60, 68, 74, 78, 84, 83, 86, 87, 87,
+        38, 36, 39, 41, 49, 56, 58, 63, 71, 77, 81, 86, 88, 88, 90, 93, 39, 37,
+        40, 42, 50, 58, 60, 65, 73, 79, 84, 90, 91, 92, 94, 93, 44, 41, 42, 45,
+        53, 63, 66, 71, 79, 85, 90, 96, 94, 96, 96, 99, 47, 44, 45, 47, 56, 66,
+        69, 75, 84, 90, 95, 99, 101, 98, 101, 99, 49, 46, 47, 48, 57, 67, 71,
+        77, 86, 93, 97, 103, 103, 105, 102, 106, 53, 49, 50, 51, 60, 71, 75, 82,
+        92, 99, 103, 111, 108, 107, 110, 107, 58, 54, 54, 55, 63, 75, 79, 87,
+        98, 105, 110, 114, 114, 113, 111, 115, 61, 56, 56, 57, 65, 77, 81, 89,
+        100, 107, 113, 118, 116, 117, 118, 116, 65, 60, 59, 60, 68, 79, 84, 92,
+        105, 112, 118, 126, 124, 122, 121, 124, 71, 65, 64, 65, 73, 84, 89, 97,
+        111, 119, 125, 130, 129, 129, 129, 125, 76, 69, 68, 69, 76, 88, 92, 101,
+        115, 123, 130, 134, 134, 131, 132, 135, 79, 72, 70, 71, 79, 90, 95, 104,
+        118, 127, 133, 143, 142, 141, 138, 136, 82, 75, 73, 74, 81, 92, 97, 106,
+        121, 130, 136, 146, 145, 144, 144, 145, 86, 78, 76, 77, 84, 95, 100,
+        109, 124, 133, 140, 147, 153, 151, 150, 146, 89, 81, 79, 78, 87, 95, 99,
+        112, 124, 130, 145, 152, 156, 157, 156, 158, 92, 84, 82, 80, 89, 95,
+        101, 116, 121, 132, 148, 151, 157, 163, 161, 159, 95, 86, 85, 83, 92,
+        95, 105, 114, 120, 136, 143, 155, 163, 167, 171, 170, 98, 89, 88, 85,
+        93, 95, 108, 113, 124, 136, 141, 160, 163, 169, 174, 171, 101, 92, 91,
+        88, 94, 98, 110, 112, 128, 133, 146, 158, 166, 175, 179, 185, 104, 95,
+        94, 91, 95, 101, 110, 115, 129, 132, 151, 154, 171, 175, 181, 186, 107,
+        98, 97, 94, 96, 105, 110, 119, 128, 136, 149, 156, 173, 177, 188, 192,
+        110, 101, 100, 97, 98, 108, 111, 123, 127, 141, 147, 161, 169, 183, 188,
+        193, 114, 104, 104, 100, 100, 111, 111, 126, 127, 145, 145, 166, 166,
+        189, 190, 201,
         /* Size 32x16 */
-        64, 63, 63, 63, 64, 64, 65, 68, 72, 76, 79, 88, 94, 98, 107, 117, 122,
-        130, 142, 152, 159, 165, 172, 179, 186, 193, 200, 208, 216, 224, 232,
-        241, 63, 64, 65, 65, 65, 66, 66, 68, 69, 73, 75, 82, 88, 92, 99, 108,
-        113, 120, 131, 139, 145, 151, 157, 164, 170, 176, 182, 189, 196, 203,
-        211, 215, 64, 65, 65, 66, 68, 70, 71, 72, 75, 78, 80, 85, 91, 94, 100,
-        108, 112, 118, 128, 136, 141, 146, 152, 158, 164, 171, 177, 184, 191,
-        199, 207, 219, 65, 66, 66, 67, 69, 72, 73, 76, 80, 83, 85, 90, 95, 97,
-        103, 111, 115, 121, 131, 138, 143, 148, 154, 158, 162, 167, 173, 179,
-        185, 191, 198, 200, 72, 71, 70, 70, 73, 77, 80, 85, 96, 99, 101, 107,
-        112, 114, 120, 127, 131, 136, 146, 153, 158, 162, 168, 173, 178, 190,
-        194, 199, 204, 210, 216, 204, 88, 85, 82, 82, 84, 85, 89, 96, 108, 112,
-        116, 126, 132, 135, 142, 150, 154, 159, 169, 176, 181, 185, 190, 193,
-        195, 197, 189, 194, 200, 206, 212, 246, 95, 91, 88, 88, 90, 90, 94, 101,
-        112, 117, 121, 132, 139, 142, 150, 159, 163, 168, 178, 185, 190, 195,
-        200, 199, 200, 205, 216, 236, 239, 243, 247, 218, 107, 103, 99, 99, 100,
-        99, 103, 109, 120, 126, 130, 143, 150, 155, 164, 174, 178, 185, 195,
-        202, 208, 212, 218, 223, 239, 241, 241, 220, 221, 226, 232, 287, 131,
-        124, 120, 119, 118, 116, 120, 126, 136, 142, 147, 159, 168, 173, 185,
-        196, 201, 210, 222, 230, 236, 242, 248, 253, 251, 233, 238, 256, 288,
-        288, 289, 237, 146, 139, 134, 132, 131, 128, 132, 138, 148, 154, 159,
-        171, 181, 186, 198, 210, 215, 225, 238, 247, 254, 260, 266, 260, 259,
-        279, 295, 292, 249, 254, 260, 344, 158, 151, 145, 143, 142, 138, 142,
-        147, 157, 163, 168, 180, 190, 195, 207, 220, 226, 236, 250, 260, 267,
-        273, 280, 287, 311, 305, 270, 276, 330, 343, 339, 265, 177, 168, 162,
-        160, 157, 153, 154, 162, 171, 174, 181, 196, 199, 206, 225, 229, 235,
-        256, 262, 266, 290, 291, 292, 306, 302, 300, 340, 353, 316, 288, 295,
-        405, 189, 179, 173, 171, 166, 164, 161, 174, 171, 184, 192, 190, 215,
-        209, 220, 244, 230, 258, 266, 264, 302, 290, 312, 312, 304, 333, 328,
-        313, 341, 410, 401, 301, 201, 191, 186, 182, 178, 177, 168, 173, 187,
-        192, 190, 213, 199, 235, 217, 240, 250, 247, 284, 253, 316, 286, 314,
-        335, 322, 336, 316, 362, 361, 328, 335, 476, 215, 203, 199, 194, 190,
-        188, 180, 181, 203, 191, 217, 198, 235, 209, 258, 224, 268, 249, 285,
-        275, 290, 313, 305, 344, 311, 405, 323, 362, 328, 395, 396, 342, 229,
-        214, 216, 201, 206, 197, 200, 185, 192, 227, 201, 239, 209, 259, 219,
-        282, 229, 304, 242, 340, 257, 354, 273, 400, 292, 415, 311, 481, 333,
-        389, 342, 430,
+        32, 31, 31, 31, 32, 32, 32, 34, 36, 38, 39, 44, 47, 49, 53, 58, 61, 65,
+        71, 76, 79, 82, 86, 89, 92, 95, 98, 101, 104, 107, 110, 114, 31, 32, 32,
+        32, 32, 33, 33, 34, 34, 36, 37, 41, 44, 46, 49, 54, 56, 60, 65, 69, 72,
+        75, 78, 81, 84, 86, 89, 92, 95, 98, 101, 104, 32, 32, 32, 33, 34, 35,
+        35, 36, 37, 39, 40, 42, 45, 47, 50, 54, 56, 59, 64, 68, 70, 73, 76, 79,
+        82, 85, 88, 91, 94, 97, 100, 104, 32, 33, 33, 33, 34, 36, 36, 38, 40,
+        41, 42, 45, 47, 48, 51, 55, 57, 60, 65, 69, 71, 74, 77, 78, 80, 83, 85,
+        88, 91, 94, 97, 100, 36, 35, 35, 35, 36, 38, 40, 42, 48, 49, 50, 53, 56,
+        57, 60, 63, 65, 68, 73, 76, 79, 81, 84, 87, 89, 92, 93, 94, 95, 96, 98,
+        100, 44, 42, 41, 41, 42, 42, 44, 48, 54, 56, 58, 63, 66, 67, 71, 75, 77,
+        79, 84, 88, 90, 92, 95, 95, 95, 95, 95, 98, 101, 105, 108, 111, 47, 45,
+        44, 44, 45, 45, 47, 50, 56, 58, 60, 66, 69, 71, 75, 79, 81, 84, 89, 92,
+        95, 97, 100, 99, 101, 105, 108, 110, 110, 110, 111, 111, 53, 51, 49, 49,
+        50, 49, 51, 54, 60, 63, 65, 71, 75, 77, 82, 87, 89, 92, 97, 101, 104,
+        106, 109, 112, 116, 114, 113, 112, 115, 119, 123, 126, 65, 62, 60, 59,
+        59, 58, 60, 63, 68, 71, 73, 79, 84, 86, 92, 98, 100, 105, 111, 115, 118,
+        121, 124, 124, 121, 120, 124, 128, 129, 128, 127, 127, 73, 69, 67, 66,
+        65, 64, 66, 69, 74, 77, 79, 85, 90, 93, 99, 105, 107, 112, 119, 123,
+        127, 130, 133, 130, 132, 136, 136, 133, 132, 136, 141, 145, 79, 75, 72,
+        71, 71, 69, 71, 73, 78, 81, 84, 90, 95, 97, 103, 110, 113, 118, 125,
+        130, 133, 136, 140, 145, 148, 143, 141, 146, 151, 149, 147, 145, 87, 83,
+        80, 79, 78, 76, 76, 80, 84, 86, 90, 96, 99, 103, 111, 114, 118, 126,
+        130, 134, 143, 146, 147, 152, 151, 155, 160, 158, 154, 156, 161, 166,
+        90, 86, 84, 82, 80, 80, 78, 82, 83, 88, 91, 94, 101, 103, 108, 114, 116,
+        124, 129, 134, 142, 145, 153, 156, 157, 163, 163, 166, 171, 173, 169,
+        166, 93, 88, 87, 84, 83, 83, 81, 81, 86, 88, 92, 96, 98, 105, 107, 113,
+        117, 122, 129, 131, 141, 144, 151, 157, 163, 167, 169, 175, 175, 177,
+        183, 189, 96, 91, 90, 87, 87, 86, 85, 84, 87, 90, 94, 96, 101, 102, 110,
+        111, 118, 121, 129, 132, 138, 144, 150, 156, 161, 171, 174, 179, 181,
+        188, 188, 190, 99, 94, 94, 90, 90, 88, 89, 86, 87, 93, 93, 99, 99, 106,
+        107, 115, 116, 124, 125, 135, 136, 145, 146, 158, 159, 170, 171, 185,
+        186, 192, 193, 201,
         /* Size 4x16 */
-        63, 88, 146, 201, 65, 82, 134, 186, 65, 84, 131, 178, 66, 89, 132, 168,
-        69, 108, 148, 187, 75, 116, 159, 190, 88, 132, 181, 199, 99, 142, 198,
-        217, 113, 154, 215, 250, 131, 169, 238, 284, 145, 181, 254, 316, 157,
-        190, 266, 314, 170, 195, 259, 322, 182, 189, 295, 316, 196, 200, 249,
-        361, 211, 212, 260, 335,
+        31, 44, 73, 93, 32, 41, 67, 87, 32, 42, 65, 83, 33, 44, 66, 81, 34, 54,
+        74, 86, 37, 58, 79, 92, 44, 66, 90, 98, 49, 71, 99, 107, 56, 77, 107,
+        117, 65, 84, 119, 129, 72, 90, 127, 141, 78, 95, 133, 151, 84, 95, 132,
+        163, 89, 95, 136, 169, 95, 101, 132, 175, 101, 108, 141, 183,
         /* Size 16x4 */
-        63, 65, 65, 66, 69, 75, 88, 99, 113, 131, 145, 157, 170, 182, 196, 211,
-        88, 82, 84, 89, 108, 116, 132, 142, 154, 169, 181, 190, 195, 189, 200,
-        212, 146, 134, 131, 132, 148, 159, 181, 198, 215, 238, 254, 266, 259,
-        295, 249, 260, 201, 186, 178, 168, 187, 190, 199, 217, 250, 284, 316,
-        314, 322, 316, 361, 335,
+        31, 32, 32, 33, 34, 37, 44, 49, 56, 65, 72, 78, 84, 89, 95, 101, 44, 41,
+        42, 44, 54, 58, 66, 71, 77, 84, 90, 95, 95, 95, 101, 108, 73, 67, 65,
+        66, 74, 79, 90, 99, 107, 119, 127, 133, 132, 136, 132, 141, 93, 87, 83,
+        81, 86, 92, 98, 107, 117, 129, 141, 151, 163, 169, 175, 183,
         /* Size 8x32 */
-        64, 64, 72, 95, 131, 158, 189, 215, 63, 65, 71, 91, 124, 151, 179, 203,
-        63, 65, 70, 88, 120, 145, 173, 199, 63, 66, 70, 88, 119, 143, 171, 194,
-        64, 68, 73, 90, 118, 142, 166, 190, 64, 70, 77, 90, 116, 138, 164, 188,
-        65, 71, 80, 94, 120, 142, 161, 180, 68, 72, 85, 101, 126, 147, 174, 181,
-        72, 75, 96, 112, 136, 157, 171, 203, 76, 78, 99, 117, 142, 163, 184,
-        191, 79, 80, 101, 121, 147, 168, 192, 217, 88, 85, 107, 132, 159, 180,
-        190, 198, 94, 91, 112, 139, 168, 190, 215, 235, 98, 94, 114, 142, 173,
-        195, 209, 209, 107, 100, 120, 150, 185, 207, 220, 258, 117, 108, 127,
-        159, 196, 220, 244, 224, 122, 112, 131, 163, 201, 226, 230, 268, 130,
-        118, 136, 168, 210, 236, 258, 249, 142, 128, 146, 178, 222, 250, 266,
-        285, 152, 136, 153, 185, 230, 260, 264, 275, 159, 141, 158, 190, 236,
-        267, 302, 290, 165, 146, 162, 195, 242, 273, 290, 313, 172, 152, 168,
-        200, 248, 280, 312, 305, 179, 158, 173, 199, 253, 287, 312, 344, 186,
-        164, 178, 200, 251, 311, 304, 311, 193, 171, 190, 205, 233, 305, 333,
-        405, 200, 177, 194, 216, 238, 270, 328, 323, 208, 184, 199, 236, 256,
-        276, 313, 362, 216, 191, 204, 239, 288, 330, 341, 328, 224, 199, 210,
-        243, 288, 343, 410, 395, 232, 207, 216, 247, 289, 339, 401, 396, 241,
-        219, 204, 218, 237, 265, 301, 342,
+        32, 32, 36, 47, 65, 79, 90, 96, 31, 32, 35, 45, 62, 75, 86, 91, 31, 32,
+        35, 44, 60, 72, 84, 90, 31, 33, 35, 44, 59, 71, 82, 87, 32, 34, 36, 45,
+        59, 71, 80, 87, 32, 35, 38, 45, 58, 69, 80, 86, 32, 35, 40, 47, 60, 71,
+        78, 85, 34, 36, 42, 50, 63, 73, 82, 84, 36, 37, 48, 56, 68, 78, 83, 87,
+        38, 39, 49, 58, 71, 81, 88, 90, 39, 40, 50, 60, 73, 84, 91, 94, 44, 42,
+        53, 66, 79, 90, 94, 96, 47, 45, 56, 69, 84, 95, 101, 101, 49, 47, 57,
+        71, 86, 97, 103, 102, 53, 50, 60, 75, 92, 103, 108, 110, 58, 54, 63, 79,
+        98, 110, 114, 111, 61, 56, 65, 81, 100, 113, 116, 118, 65, 59, 68, 84,
+        105, 118, 124, 121, 71, 64, 73, 89, 111, 125, 129, 129, 76, 68, 76, 92,
+        115, 130, 134, 132, 79, 70, 79, 95, 118, 133, 142, 138, 82, 73, 81, 97,
+        121, 136, 145, 144, 86, 76, 84, 100, 124, 140, 153, 150, 89, 79, 87, 99,
+        124, 145, 156, 156, 92, 82, 89, 101, 121, 148, 157, 161, 95, 85, 92,
+        105, 120, 143, 163, 171, 98, 88, 93, 108, 124, 141, 163, 174, 101, 91,
+        94, 110, 128, 146, 166, 179, 104, 94, 95, 110, 129, 151, 171, 181, 107,
+        97, 96, 110, 128, 149, 173, 188, 110, 100, 98, 111, 127, 147, 169, 188,
+        114, 104, 100, 111, 127, 145, 166, 190,
         /* Size 32x8 */
-        64, 63, 63, 63, 64, 64, 65, 68, 72, 76, 79, 88, 94, 98, 107, 117, 122,
-        130, 142, 152, 159, 165, 172, 179, 186, 193, 200, 208, 216, 224, 232,
-        241, 64, 65, 65, 66, 68, 70, 71, 72, 75, 78, 80, 85, 91, 94, 100, 108,
-        112, 118, 128, 136, 141, 146, 152, 158, 164, 171, 177, 184, 191, 199,
-        207, 219, 72, 71, 70, 70, 73, 77, 80, 85, 96, 99, 101, 107, 112, 114,
-        120, 127, 131, 136, 146, 153, 158, 162, 168, 173, 178, 190, 194, 199,
-        204, 210, 216, 204, 95, 91, 88, 88, 90, 90, 94, 101, 112, 117, 121, 132,
-        139, 142, 150, 159, 163, 168, 178, 185, 190, 195, 200, 199, 200, 205,
-        216, 236, 239, 243, 247, 218, 131, 124, 120, 119, 118, 116, 120, 126,
-        136, 142, 147, 159, 168, 173, 185, 196, 201, 210, 222, 230, 236, 242,
-        248, 253, 251, 233, 238, 256, 288, 288, 289, 237, 158, 151, 145, 143,
-        142, 138, 142, 147, 157, 163, 168, 180, 190, 195, 207, 220, 226, 236,
-        250, 260, 267, 273, 280, 287, 311, 305, 270, 276, 330, 343, 339, 265,
-        189, 179, 173, 171, 166, 164, 161, 174, 171, 184, 192, 190, 215, 209,
-        220, 244, 230, 258, 266, 264, 302, 290, 312, 312, 304, 333, 328, 313,
-        341, 410, 401, 301, 215, 203, 199, 194, 190, 188, 180, 181, 203, 191,
-        217, 198, 235, 209, 258, 224, 268, 249, 285, 275, 290, 313, 305, 344,
-        311, 405, 323, 362, 328, 395, 396, 342 },
+        32, 31, 31, 31, 32, 32, 32, 34, 36, 38, 39, 44, 47, 49, 53, 58, 61, 65,
+        71, 76, 79, 82, 86, 89, 92, 95, 98, 101, 104, 107, 110, 114, 32, 32, 32,
+        33, 34, 35, 35, 36, 37, 39, 40, 42, 45, 47, 50, 54, 56, 59, 64, 68, 70,
+        73, 76, 79, 82, 85, 88, 91, 94, 97, 100, 104, 36, 35, 35, 35, 36, 38,
+        40, 42, 48, 49, 50, 53, 56, 57, 60, 63, 65, 68, 73, 76, 79, 81, 84, 87,
+        89, 92, 93, 94, 95, 96, 98, 100, 47, 45, 44, 44, 45, 45, 47, 50, 56, 58,
+        60, 66, 69, 71, 75, 79, 81, 84, 89, 92, 95, 97, 100, 99, 101, 105, 108,
+        110, 110, 110, 111, 111, 65, 62, 60, 59, 59, 58, 60, 63, 68, 71, 73, 79,
+        84, 86, 92, 98, 100, 105, 111, 115, 118, 121, 124, 124, 121, 120, 124,
+        128, 129, 128, 127, 127, 79, 75, 72, 71, 71, 69, 71, 73, 78, 81, 84, 90,
+        95, 97, 103, 110, 113, 118, 125, 130, 133, 136, 140, 145, 148, 143, 141,
+        146, 151, 149, 147, 145, 90, 86, 84, 82, 80, 80, 78, 82, 83, 88, 91, 94,
+        101, 103, 108, 114, 116, 124, 129, 134, 142, 145, 153, 156, 157, 163,
+        163, 166, 171, 173, 169, 166, 96, 91, 90, 87, 87, 86, 85, 84, 87, 90,
+        94, 96, 101, 102, 110, 111, 118, 121, 129, 132, 138, 144, 150, 156, 161,
+        171, 174, 179, 181, 188, 188, 190 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        97, 122, 122, 196,
+        48, 60, 60, 97,
 #endif
         /* Size 4x4 */
-        66, 90, 112, 133, 90, 117, 133, 148, 112, 133, 172, 169, 133, 148, 169,
-        220,
+        33, 45, 56, 64, 45, 58, 66, 69, 56, 66, 86, 87, 64, 69, 87, 105,
         /* Size 8x8 */
-        63, 77, 95, 97, 109, 123, 134, 145, 77, 95, 94, 93, 100, 111, 122, 134,
-        95, 94, 107, 111, 117, 127, 133, 134, 97, 93, 111, 125, 135, 145, 146,
-        144, 109, 100, 117, 135, 153, 166, 175, 166, 123, 111, 127, 145, 166,
-        183, 183, 201, 134, 122, 133, 146, 175, 183, 207, 240, 145, 134, 134,
-        144, 166, 201, 240, 233,
+        31, 38, 47, 48, 54, 61, 66, 69, 38, 47, 47, 46, 50, 55, 61, 65, 47, 47,
+        53, 55, 58, 63, 65, 66, 48, 46, 55, 62, 67, 72, 73, 73, 54, 50, 58, 67,
+        76, 83, 84, 82, 61, 55, 63, 72, 83, 91, 92, 92, 66, 61, 65, 73, 84, 92,
+        101, 103, 69, 65, 66, 73, 82, 92, 103, 109,
         /* Size 16x16 */
-        64, 61, 67, 77, 98, 97, 101, 104, 111, 120, 127, 133, 139, 144, 150,
-        157, 61, 63, 71, 82, 93, 92, 93, 96, 102, 110, 116, 121, 127, 133, 139,
-        145, 67, 71, 78, 88, 95, 93, 93, 95, 100, 107, 113, 117, 122, 126, 132,
-        138, 77, 82, 88, 95, 98, 96, 95, 96, 101, 107, 111, 116, 118, 121, 124,
-        130, 98, 93, 95, 98, 106, 106, 108, 109, 112, 117, 121, 125, 128, 127,
-        139, 143, 97, 92, 93, 96, 106, 109, 113, 115, 118, 123, 127, 131, 138,
-        132, 144, 149, 101, 93, 93, 95, 108, 113, 122, 126, 131, 136, 140, 144,
-        141, 147, 145, 158, 104, 96, 95, 96, 109, 115, 126, 133, 139, 145, 150,
-        153, 150, 161, 148, 169, 111, 102, 100, 101, 112, 118, 131, 139, 146,
-        154, 159, 163, 168, 173, 155, 179, 120, 110, 107, 107, 117, 123, 136,
-        145, 154, 164, 170, 175, 177, 170, 163, 195, 127, 116, 113, 111, 121,
-        127, 140, 150, 159, 170, 178, 183, 180, 176, 179, 202, 133, 121, 117,
-        116, 125, 131, 144, 153, 163, 175, 183, 189, 192, 193, 197, 221, 139,
-        127, 122, 118, 128, 138, 141, 150, 168, 177, 180, 192, 201, 203, 224,
-        228, 144, 133, 126, 121, 127, 132, 147, 161, 173, 170, 176, 193, 203,
-        213, 214, 253, 150, 139, 132, 124, 139, 144, 145, 148, 155, 163, 179,
-        197, 224, 214, 226, 225, 157, 145, 138, 130, 143, 149, 158, 169, 179,
-        195, 202, 221, 228, 253, 225, 240,
+        32, 30, 33, 38, 49, 48, 50, 52, 55, 60, 63, 66, 68, 70, 72, 74, 30, 31,
+        35, 41, 46, 46, 46, 48, 51, 55, 58, 60, 63, 65, 68, 70, 33, 35, 39, 44,
+        47, 46, 46, 47, 50, 53, 56, 58, 60, 62, 65, 67, 38, 41, 44, 47, 49, 48,
+        47, 48, 50, 53, 55, 58, 58, 60, 62, 65, 49, 46, 47, 49, 53, 53, 54, 54,
+        56, 58, 60, 62, 62, 63, 64, 64, 48, 46, 46, 48, 53, 54, 56, 57, 59, 61,
+        63, 65, 67, 66, 68, 68, 50, 46, 46, 47, 54, 56, 61, 63, 65, 68, 70, 72,
+        71, 71, 72, 72, 52, 48, 47, 48, 54, 57, 63, 66, 69, 72, 75, 76, 75, 76,
+        76, 76, 55, 51, 50, 50, 56, 59, 65, 69, 73, 77, 79, 81, 81, 81, 80, 80,
+        60, 55, 53, 53, 58, 61, 68, 72, 77, 82, 85, 87, 87, 85, 84, 85, 63, 58,
+        56, 55, 60, 63, 70, 75, 79, 85, 89, 91, 91, 90, 89, 90, 66, 60, 58, 58,
+        62, 65, 72, 76, 81, 87, 91, 94, 96, 95, 95, 95, 68, 63, 60, 58, 62, 67,
+        71, 75, 81, 87, 91, 96, 99, 100, 100, 100, 70, 65, 62, 60, 63, 66, 71,
+        76, 81, 85, 90, 95, 100, 103, 104, 105, 72, 68, 65, 62, 64, 68, 72, 76,
+        80, 84, 89, 95, 100, 104, 107, 108, 74, 70, 67, 65, 64, 68, 72, 76, 80,
+        85, 90, 95, 100, 105, 108, 111,
         /* Size 32x32 */
-        64, 62, 61, 62, 67, 73, 77, 83, 98, 98, 97, 98, 101, 102, 104, 109, 111,
-        114, 120, 124, 127, 130, 133, 136, 139, 142, 144, 147, 150, 153, 157,
-        160, 62, 63, 63, 64, 69, 77, 80, 85, 95, 95, 94, 94, 96, 97, 100, 104,
-        106, 109, 114, 118, 121, 123, 126, 129, 131, 134, 137, 139, 142, 145,
-        148, 149, 61, 63, 63, 65, 71, 79, 82, 85, 93, 92, 92, 91, 93, 94, 96,
-        100, 102, 105, 110, 114, 116, 118, 121, 124, 127, 130, 133, 136, 139,
-        142, 145, 151, 62, 64, 65, 66, 72, 81, 83, 86, 93, 92, 91, 90, 92, 93,
-        95, 99, 101, 103, 109, 112, 114, 117, 119, 123, 125, 128, 130, 133, 135,
-        138, 141, 140, 67, 69, 71, 72, 78, 87, 88, 90, 95, 93, 93, 91, 93, 94,
-        95, 99, 100, 102, 107, 110, 113, 115, 117, 120, 122, 123, 126, 129, 132,
-        135, 138, 144, 73, 77, 79, 81, 87, 95, 95, 95, 96, 94, 93, 91, 92, 93,
-        94, 97, 98, 100, 104, 107, 109, 111, 113, 116, 119, 122, 127, 129, 131,
-        134, 136, 136, 77, 80, 82, 83, 88, 95, 95, 96, 98, 96, 96, 94, 95, 95,
-        96, 99, 101, 102, 107, 109, 111, 113, 116, 116, 118, 120, 121, 121, 124,
-        127, 130, 139, 83, 85, 85, 86, 90, 95, 96, 97, 101, 100, 99, 98, 100,
-        100, 101, 104, 105, 107, 111, 113, 115, 117, 119, 122, 126, 127, 129,
-        125, 126, 128, 131, 127, 98, 95, 93, 93, 95, 96, 98, 101, 106, 106, 106,
-        107, 108, 108, 109, 111, 112, 113, 117, 119, 121, 123, 125, 127, 128,
-        125, 127, 132, 139, 141, 143, 133, 98, 95, 92, 92, 93, 94, 96, 100, 106,
-        107, 108, 110, 111, 111, 112, 115, 116, 117, 121, 123, 125, 127, 129,
-        128, 129, 133, 137, 138, 131, 134, 136, 152, 97, 94, 92, 91, 93, 93, 96,
-        99, 106, 108, 109, 111, 113, 113, 115, 117, 118, 120, 123, 126, 127,
-        129, 131, 133, 138, 138, 132, 134, 144, 148, 149, 138, 98, 94, 91, 90,
-        91, 91, 94, 98, 107, 110, 111, 117, 119, 120, 123, 125, 126, 127, 131,
-        133, 135, 136, 138, 141, 138, 136, 144, 148, 142, 138, 140, 158, 101,
-        96, 93, 92, 93, 92, 95, 100, 108, 111, 113, 119, 122, 123, 126, 129,
-        131, 133, 136, 138, 140, 142, 144, 142, 141, 150, 147, 140, 145, 157,
-        158, 142, 102, 97, 94, 93, 94, 93, 95, 100, 108, 111, 113, 120, 123,
-        125, 129, 132, 133, 135, 139, 141, 143, 145, 147, 147, 152, 146, 145,
-        159, 158, 144, 145, 168, 104, 100, 96, 95, 95, 94, 96, 101, 109, 112,
-        115, 123, 126, 129, 133, 137, 139, 141, 145, 148, 150, 151, 153, 157,
-        150, 152, 161, 149, 148, 169, 169, 147, 109, 104, 100, 99, 99, 97, 99,
-        104, 111, 115, 117, 125, 129, 132, 137, 142, 144, 147, 151, 154, 156,
-        158, 160, 157, 159, 165, 152, 162, 170, 151, 151, 179, 111, 106, 102,
-        101, 100, 98, 101, 105, 112, 116, 118, 126, 131, 133, 139, 144, 146,
-        149, 154, 157, 159, 161, 163, 162, 168, 158, 173, 169, 155, 174, 179,
-        153, 114, 109, 105, 103, 102, 100, 102, 107, 113, 117, 120, 127, 133,
-        135, 141, 147, 149, 153, 158, 161, 164, 166, 168, 173, 164, 175, 168,
-        162, 185, 166, 158, 190, 120, 114, 110, 109, 107, 104, 107, 111, 117,
-        121, 123, 131, 136, 139, 145, 151, 154, 158, 164, 168, 170, 172, 175,
-        173, 177, 175, 170, 184, 163, 180, 195, 160, 124, 118, 114, 112, 110,
-        107, 109, 113, 119, 123, 126, 133, 138, 141, 148, 154, 157, 161, 168,
-        172, 175, 177, 180, 178, 183, 175, 190, 169, 192, 181, 166, 207, 127,
-        121, 116, 114, 113, 109, 111, 115, 121, 125, 127, 135, 140, 143, 150,
-        156, 159, 164, 170, 175, 178, 180, 183, 190, 180, 192, 176, 201, 179,
-        182, 202, 168, 130, 123, 118, 117, 115, 111, 113, 117, 123, 127, 129,
-        136, 142, 145, 151, 158, 161, 166, 172, 177, 180, 183, 186, 188, 197,
-        183, 200, 183, 197, 201, 175, 213, 133, 126, 121, 119, 117, 113, 116,
-        119, 125, 129, 131, 138, 144, 147, 153, 160, 163, 168, 175, 180, 183,
-        186, 189, 189, 192, 200, 193, 199, 197, 187, 221, 177, 136, 129, 124,
-        123, 120, 116, 116, 122, 127, 128, 133, 141, 142, 147, 157, 157, 162,
-        173, 173, 178, 190, 188, 189, 196, 192, 197, 202, 207, 196, 216, 185,
-        234, 139, 131, 127, 125, 122, 119, 118, 126, 128, 129, 138, 138, 141,
-        152, 150, 159, 168, 164, 177, 183, 180, 197, 192, 192, 201, 194, 203,
-        201, 224, 191, 228, 187, 142, 134, 130, 128, 123, 122, 120, 127, 125,
-        133, 138, 136, 150, 146, 152, 165, 158, 175, 175, 175, 192, 183, 200,
-        197, 194, 207, 197, 208, 199, 240, 194, 239, 144, 137, 133, 130, 126,
-        127, 121, 129, 127, 137, 132, 144, 147, 145, 161, 152, 173, 168, 170,
-        190, 176, 200, 193, 202, 203, 197, 213, 200, 214, 202, 253, 196, 147,
-        139, 136, 133, 129, 129, 121, 125, 132, 138, 134, 148, 140, 159, 149,
-        162, 169, 162, 184, 169, 201, 183, 199, 207, 201, 208, 200, 220, 203,
-        219, 205, 266, 150, 142, 139, 135, 132, 131, 124, 126, 139, 131, 144,
-        142, 145, 158, 148, 170, 155, 185, 163, 192, 179, 197, 197, 196, 224,
-        199, 214, 203, 226, 206, 225, 208, 153, 145, 142, 138, 135, 134, 127,
-        128, 141, 134, 148, 138, 157, 144, 169, 151, 174, 166, 180, 181, 182,
-        201, 187, 216, 191, 240, 202, 219, 206, 233, 209, 230, 157, 148, 145,
-        141, 138, 136, 130, 131, 143, 136, 149, 140, 158, 145, 169, 151, 179,
-        158, 195, 166, 202, 175, 221, 185, 228, 194, 253, 205, 225, 209, 240,
-        212, 160, 149, 151, 140, 144, 136, 139, 127, 133, 152, 138, 158, 142,
-        168, 147, 179, 153, 190, 160, 207, 168, 213, 177, 234, 187, 239, 196,
-        266, 208, 230, 212, 247,
+        32, 31, 30, 31, 33, 36, 38, 41, 49, 49, 48, 49, 50, 51, 52, 54, 55, 57,
+        60, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 31, 31, 31, 32,
+        34, 38, 40, 42, 47, 47, 47, 47, 48, 48, 50, 52, 53, 54, 57, 59, 60, 61,
+        63, 64, 65, 66, 67, 67, 68, 69, 70, 71, 30, 31, 31, 32, 35, 39, 41, 42,
+        46, 46, 46, 45, 46, 47, 48, 50, 51, 52, 55, 57, 58, 59, 60, 62, 63, 64,
+        65, 67, 68, 69, 70, 71, 31, 32, 32, 33, 36, 40, 41, 43, 46, 46, 45, 45,
+        46, 46, 47, 49, 50, 51, 54, 56, 57, 58, 59, 61, 62, 63, 63, 64, 65, 66,
+        67, 68, 33, 34, 35, 36, 39, 43, 44, 45, 47, 46, 46, 45, 46, 47, 47, 49,
+        50, 51, 53, 55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 36, 38,
+        39, 40, 43, 47, 47, 47, 48, 47, 46, 45, 46, 46, 47, 48, 49, 50, 52, 53,
+        54, 55, 56, 58, 59, 61, 62, 63, 64, 65, 66, 66, 38, 40, 41, 41, 44, 47,
+        47, 48, 49, 48, 48, 47, 47, 47, 48, 49, 50, 51, 53, 54, 55, 56, 58, 58,
+        58, 59, 60, 61, 62, 64, 65, 66, 41, 42, 42, 43, 45, 47, 48, 48, 50, 50,
+        49, 49, 50, 50, 50, 52, 52, 53, 55, 56, 57, 58, 59, 60, 61, 61, 61, 61,
+        62, 63, 63, 64, 49, 47, 46, 46, 47, 48, 49, 50, 53, 53, 53, 53, 54, 54,
+        54, 55, 56, 56, 58, 59, 60, 61, 62, 63, 62, 62, 63, 64, 64, 64, 64, 64,
+        49, 47, 46, 46, 46, 47, 48, 50, 53, 53, 54, 55, 55, 55, 56, 57, 58, 58,
+        60, 61, 62, 63, 64, 64, 64, 65, 65, 65, 65, 66, 67, 68, 48, 47, 46, 45,
+        46, 46, 48, 49, 53, 54, 54, 55, 56, 56, 57, 58, 59, 60, 61, 63, 63, 64,
+        65, 66, 67, 66, 66, 67, 68, 68, 68, 68, 49, 47, 45, 45, 45, 45, 47, 49,
+        53, 55, 55, 58, 59, 60, 61, 62, 63, 63, 65, 66, 67, 68, 69, 69, 68, 68,
+        69, 69, 69, 69, 70, 71, 50, 48, 46, 46, 46, 46, 47, 50, 54, 55, 56, 59,
+        61, 61, 63, 64, 65, 66, 68, 69, 70, 71, 72, 71, 71, 72, 71, 71, 72, 72,
+        72, 71, 51, 48, 47, 46, 47, 46, 47, 50, 54, 55, 56, 60, 61, 62, 64, 66,
+        66, 67, 69, 70, 71, 72, 73, 73, 74, 73, 73, 74, 73, 73, 74, 75, 52, 50,
+        48, 47, 47, 47, 48, 50, 54, 56, 57, 61, 63, 64, 66, 68, 69, 70, 72, 74,
+        75, 75, 76, 77, 75, 76, 76, 75, 76, 77, 76, 75, 54, 52, 50, 49, 49, 48,
+        49, 52, 55, 57, 58, 62, 64, 66, 68, 71, 72, 73, 75, 77, 78, 79, 80, 78,
+        79, 78, 77, 78, 78, 77, 78, 79, 55, 53, 51, 50, 50, 49, 50, 52, 56, 58,
+        59, 63, 65, 66, 69, 72, 73, 74, 77, 78, 79, 80, 81, 81, 81, 80, 81, 80,
+        80, 81, 80, 79, 57, 54, 52, 51, 51, 50, 51, 53, 56, 58, 60, 63, 66, 67,
+        70, 73, 74, 76, 79, 80, 82, 83, 84, 85, 83, 84, 83, 83, 83, 82, 82, 83,
+        60, 57, 55, 54, 53, 52, 53, 55, 58, 60, 61, 65, 68, 69, 72, 75, 77, 79,
+        82, 84, 85, 86, 87, 86, 87, 85, 85, 85, 84, 86, 85, 84, 62, 59, 57, 56,
+        55, 53, 54, 56, 59, 61, 63, 66, 69, 70, 74, 77, 78, 80, 84, 86, 87, 88,
+        90, 89, 89, 88, 88, 87, 88, 87, 87, 88, 63, 60, 58, 57, 56, 54, 55, 57,
+        60, 62, 63, 67, 70, 71, 75, 78, 79, 82, 85, 87, 89, 90, 91, 93, 91, 91,
+        90, 91, 89, 90, 90, 89, 65, 61, 59, 58, 57, 55, 56, 58, 61, 63, 64, 68,
+        71, 72, 75, 79, 80, 83, 86, 88, 90, 91, 93, 94, 95, 92, 94, 92, 93, 92,
+        91, 93, 66, 63, 60, 59, 58, 56, 58, 59, 62, 64, 65, 69, 72, 73, 76, 80,
+        81, 84, 87, 90, 91, 93, 94, 95, 96, 97, 95, 95, 95, 95, 95, 93, 67, 64,
+        62, 61, 59, 58, 58, 60, 63, 64, 66, 69, 71, 73, 77, 78, 81, 85, 86, 89,
+        93, 94, 95, 97, 97, 98, 99, 97, 97, 97, 96, 98, 68, 65, 63, 62, 60, 59,
+        58, 61, 62, 64, 67, 68, 71, 74, 75, 79, 81, 83, 87, 89, 91, 95, 96, 97,
+        99, 98, 100, 100, 100, 99, 100, 98, 69, 66, 64, 63, 61, 61, 59, 61, 62,
+        65, 66, 68, 72, 73, 76, 78, 80, 84, 85, 88, 91, 92, 97, 98, 98, 101,
+        100, 102, 102, 103, 101, 102, 70, 67, 65, 63, 62, 62, 60, 61, 63, 65,
+        66, 69, 71, 73, 76, 77, 81, 83, 85, 88, 90, 94, 95, 99, 100, 100, 103,
+        102, 104, 104, 105, 103, 71, 67, 67, 64, 63, 63, 61, 61, 64, 65, 67, 69,
+        71, 74, 75, 78, 80, 83, 85, 87, 91, 92, 95, 97, 100, 102, 102, 105, 104,
+        106, 106, 108, 72, 68, 68, 65, 65, 64, 62, 62, 64, 65, 68, 69, 72, 73,
+        76, 78, 80, 83, 84, 88, 89, 93, 95, 97, 100, 102, 104, 104, 107, 106,
+        108, 108, 73, 69, 69, 66, 66, 65, 64, 63, 64, 66, 68, 69, 72, 73, 77,
+        77, 81, 82, 86, 87, 90, 92, 95, 97, 99, 103, 104, 106, 106, 109, 108,
+        110, 74, 70, 70, 67, 67, 66, 65, 63, 64, 67, 68, 70, 72, 74, 76, 78, 80,
+        82, 85, 87, 90, 91, 95, 96, 100, 101, 105, 106, 108, 108, 111, 110, 75,
+        71, 71, 68, 68, 66, 66, 64, 64, 68, 68, 71, 71, 75, 75, 79, 79, 83, 84,
+        88, 89, 93, 93, 98, 98, 102, 103, 108, 108, 110, 110, 113,
         /* Size 4x8 */
-        63, 94, 115, 137, 80, 91, 105, 127, 92, 110, 122, 134, 94, 120, 140,
-        158, 104, 128, 159, 164, 118, 136, 174, 183, 128, 138, 181, 206, 139,
-        138, 165, 202,
+        31, 47, 57, 65, 40, 45, 52, 61, 46, 55, 61, 63, 47, 60, 70, 72, 52, 64,
+        79, 81, 59, 68, 87, 90, 63, 66, 88, 99, 66, 69, 85, 102,
         /* Size 8x4 */
-        63, 80, 92, 94, 104, 118, 128, 139, 94, 91, 110, 120, 128, 136, 138,
-        138, 115, 105, 122, 140, 159, 174, 181, 165, 137, 127, 134, 158, 164,
-        183, 206, 202,
+        31, 40, 46, 47, 52, 59, 63, 66, 47, 45, 55, 60, 64, 68, 66, 69, 57, 52,
+        61, 70, 79, 87, 88, 85, 65, 61, 63, 72, 81, 90, 99, 102,
         /* Size 8x16 */
-        64, 71, 96, 101, 115, 127, 140, 150, 61, 76, 92, 93, 105, 116, 128, 139,
-        67, 83, 94, 93, 103, 112, 122, 132, 78, 92, 97, 95, 103, 111, 118, 125,
-        98, 96, 106, 108, 114, 121, 124, 139, 97, 93, 106, 113, 120, 128, 136,
-        146, 100, 93, 108, 122, 133, 140, 149, 156, 104, 95, 109, 127, 142, 150,
-        152, 167, 111, 99, 112, 131, 149, 159, 157, 173, 120, 106, 117, 136,
-        158, 170, 175, 181, 127, 111, 121, 140, 164, 178, 192, 184, 132, 116,
-        125, 144, 168, 183, 196, 191, 138, 121, 129, 142, 168, 196, 193, 194,
-        144, 126, 136, 148, 160, 177, 202, 200, 150, 132, 138, 157, 182, 202,
-        207, 203, 156, 138, 142, 159, 180, 203, 229, 229,
+        32, 35, 48, 50, 57, 63, 68, 70, 30, 38, 46, 46, 52, 58, 63, 65, 33, 41,
+        47, 46, 51, 56, 60, 63, 39, 46, 48, 47, 51, 55, 58, 61, 49, 48, 53, 54,
+        57, 60, 61, 61, 48, 46, 53, 56, 60, 64, 65, 65, 50, 46, 54, 61, 66, 70,
+        71, 69, 52, 47, 54, 63, 71, 75, 75, 74, 55, 49, 56, 65, 74, 79, 79, 78,
+        60, 53, 58, 68, 79, 85, 85, 82, 63, 55, 60, 70, 82, 89, 91, 87, 66, 58,
+        62, 72, 84, 91, 95, 91, 68, 60, 64, 71, 81, 94, 97, 96, 70, 62, 65, 73,
+        81, 89, 98, 101, 72, 65, 65, 72, 82, 92, 100, 103, 74, 67, 65, 71, 79,
+        89, 98, 105,
         /* Size 16x8 */
-        64, 61, 67, 78, 98, 97, 100, 104, 111, 120, 127, 132, 138, 144, 150,
-        156, 71, 76, 83, 92, 96, 93, 93, 95, 99, 106, 111, 116, 121, 126, 132,
-        138, 96, 92, 94, 97, 106, 106, 108, 109, 112, 117, 121, 125, 129, 136,
-        138, 142, 101, 93, 93, 95, 108, 113, 122, 127, 131, 136, 140, 144, 142,
-        148, 157, 159, 115, 105, 103, 103, 114, 120, 133, 142, 149, 158, 164,
-        168, 168, 160, 182, 180, 127, 116, 112, 111, 121, 128, 140, 150, 159,
-        170, 178, 183, 196, 177, 202, 203, 140, 128, 122, 118, 124, 136, 149,
-        152, 157, 175, 192, 196, 193, 202, 207, 229, 150, 139, 132, 125, 139,
-        146, 156, 167, 173, 181, 184, 191, 194, 200, 203, 229,
+        32, 30, 33, 39, 49, 48, 50, 52, 55, 60, 63, 66, 68, 70, 72, 74, 35, 38,
+        41, 46, 48, 46, 46, 47, 49, 53, 55, 58, 60, 62, 65, 67, 48, 46, 47, 48,
+        53, 53, 54, 54, 56, 58, 60, 62, 64, 65, 65, 65, 50, 46, 46, 47, 54, 56,
+        61, 63, 65, 68, 70, 72, 71, 73, 72, 71, 57, 52, 51, 51, 57, 60, 66, 71,
+        74, 79, 82, 84, 81, 81, 82, 79, 63, 58, 56, 55, 60, 64, 70, 75, 79, 85,
+        89, 91, 94, 89, 92, 89, 68, 63, 60, 58, 61, 65, 71, 75, 79, 85, 91, 95,
+        97, 98, 100, 98, 70, 65, 63, 61, 61, 65, 69, 74, 78, 82, 87, 91, 96,
+        101, 103, 105,
         /* Size 16x32 */
-        64, 62, 71, 77, 96, 98, 101, 105, 115, 122, 127, 135, 140, 145, 150,
-        155, 63, 63, 74, 80, 94, 94, 97, 100, 109, 115, 120, 128, 132, 137, 142,
-        145, 61, 64, 76, 81, 92, 91, 93, 97, 105, 111, 116, 123, 128, 133, 139,
-        147, 62, 66, 77, 83, 92, 91, 93, 96, 104, 110, 114, 121, 126, 130, 135,
-        136, 67, 72, 83, 88, 94, 92, 93, 95, 103, 108, 112, 119, 122, 127, 132,
-        140, 74, 80, 91, 95, 95, 91, 92, 94, 100, 105, 109, 115, 121, 127, 131,
-        132, 78, 82, 92, 95, 97, 94, 95, 97, 103, 108, 111, 116, 118, 120, 125,
-        135, 84, 86, 93, 96, 100, 99, 100, 101, 107, 112, 115, 121, 126, 123,
-        126, 124, 98, 93, 96, 98, 106, 107, 108, 109, 114, 118, 121, 127, 124,
-        132, 139, 130, 97, 92, 94, 97, 106, 110, 111, 113, 117, 122, 125, 128,
-        132, 134, 131, 149, 97, 92, 93, 96, 106, 112, 113, 115, 120, 124, 128,
-        133, 136, 134, 146, 135, 98, 91, 91, 94, 107, 117, 119, 123, 128, 132,
-        135, 141, 135, 146, 136, 155, 100, 93, 93, 96, 108, 119, 122, 127, 133,
-        137, 140, 143, 149, 139, 156, 139, 102, 94, 94, 96, 108, 120, 123, 129,
-        136, 140, 143, 146, 146, 158, 142, 165, 104, 96, 95, 97, 109, 122, 127,
-        133, 142, 146, 150, 156, 152, 149, 167, 145, 109, 100, 98, 100, 111,
-        125, 130, 137, 147, 152, 156, 159, 164, 161, 150, 177, 111, 102, 99,
-        101, 112, 126, 131, 139, 149, 155, 159, 161, 157, 166, 173, 151, 114,
-        104, 101, 103, 113, 128, 133, 141, 153, 159, 164, 172, 171, 164, 163,
-        187, 120, 109, 106, 107, 117, 131, 136, 145, 158, 165, 170, 175, 175,
-        182, 181, 158, 124, 113, 109, 110, 120, 133, 139, 148, 162, 169, 175,
-        177, 175, 168, 176, 204, 127, 115, 111, 112, 121, 135, 140, 150, 164,
-        172, 178, 187, 192, 197, 184, 166, 129, 118, 113, 114, 123, 136, 142,
-        151, 166, 174, 180, 188, 187, 183, 194, 210, 132, 121, 116, 116, 125,
-        138, 144, 153, 168, 177, 183, 188, 196, 196, 191, 175, 135, 123, 118,
-        117, 127, 138, 142, 155, 170, 173, 186, 194, 196, 205, 207, 230, 138,
-        126, 121, 119, 129, 138, 142, 162, 168, 172, 196, 192, 193, 200, 194,
-        184, 141, 128, 124, 121, 134, 138, 143, 162, 158, 181, 193, 191, 205,
-        206, 232, 235, 144, 131, 126, 123, 136, 133, 148, 161, 160, 187, 177,
-        207, 202, 198, 200, 193, 147, 133, 129, 125, 137, 135, 157, 149, 168,
-        185, 179, 212, 196, 216, 216, 261, 150, 136, 132, 127, 138, 136, 157,
-        148, 182, 163, 202, 196, 207, 215, 203, 204, 153, 139, 135, 130, 140,
-        138, 158, 150, 181, 165, 206, 183, 234, 202, 229, 226, 156, 141, 138,
-        132, 142, 140, 159, 151, 180, 167, 203, 185, 229, 205, 229, 208, 159,
-        142, 144, 130, 134, 157, 142, 178, 153, 204, 169, 231, 187, 258, 207,
-        242,
+        32, 31, 35, 38, 48, 49, 50, 52, 57, 61, 63, 67, 68, 69, 70, 71, 31, 31,
+        37, 40, 47, 47, 48, 50, 54, 57, 60, 63, 64, 65, 66, 67, 30, 32, 38, 40,
+        46, 45, 46, 48, 52, 55, 58, 61, 63, 64, 65, 67, 31, 33, 38, 41, 46, 45,
+        46, 48, 52, 55, 57, 60, 61, 62, 63, 64, 33, 36, 41, 44, 47, 46, 46, 47,
+        51, 54, 56, 59, 60, 61, 63, 64, 37, 40, 45, 47, 47, 45, 46, 47, 50, 52,
+        54, 57, 59, 61, 62, 62, 39, 41, 46, 47, 48, 47, 47, 48, 51, 54, 55, 57,
+        58, 59, 61, 62, 42, 43, 46, 48, 50, 49, 50, 50, 53, 56, 57, 60, 60, 59,
+        60, 60, 49, 46, 48, 49, 53, 53, 54, 54, 57, 59, 60, 63, 61, 62, 61, 61,
+        48, 46, 47, 48, 53, 55, 55, 56, 58, 61, 62, 64, 64, 63, 63, 64, 48, 46,
+        46, 48, 53, 56, 56, 57, 60, 62, 64, 66, 65, 65, 65, 64, 49, 45, 45, 47,
+        53, 58, 59, 61, 64, 66, 67, 69, 67, 67, 66, 67, 50, 46, 46, 48, 54, 59,
+        61, 63, 66, 68, 70, 71, 71, 68, 69, 67, 51, 47, 47, 48, 54, 60, 61, 64,
+        68, 70, 71, 73, 72, 72, 70, 71, 52, 48, 47, 48, 54, 61, 63, 66, 71, 73,
+        75, 77, 75, 73, 74, 71, 54, 50, 49, 50, 55, 62, 65, 68, 73, 76, 78, 79,
+        78, 76, 74, 75, 55, 51, 49, 50, 56, 63, 65, 69, 74, 77, 79, 81, 79, 78,
+        78, 75, 57, 52, 50, 51, 56, 64, 66, 70, 76, 79, 82, 85, 83, 81, 79, 79,
+        60, 54, 53, 53, 58, 65, 68, 72, 79, 82, 85, 87, 85, 84, 82, 80, 62, 56,
+        54, 55, 60, 66, 69, 74, 81, 84, 87, 88, 87, 85, 84, 84, 63, 57, 55, 56,
+        60, 67, 70, 75, 82, 86, 89, 92, 91, 89, 87, 84, 64, 59, 56, 57, 61, 68,
+        71, 75, 83, 87, 90, 93, 92, 90, 89, 89, 66, 60, 58, 58, 62, 69, 72, 76,
+        84, 88, 91, 94, 95, 93, 91, 89, 67, 61, 59, 58, 63, 68, 71, 78, 83, 86,
+        93, 96, 96, 96, 94, 94, 68, 62, 60, 59, 64, 67, 71, 79, 81, 86, 94, 95,
+        97, 98, 96, 94, 69, 63, 61, 60, 65, 66, 72, 77, 80, 88, 91, 96, 99, 99,
+        100, 98, 70, 64, 62, 60, 65, 66, 73, 76, 81, 87, 89, 97, 98, 100, 101,
+        99, 71, 65, 64, 61, 65, 67, 73, 74, 82, 85, 90, 95, 99, 102, 103, 104,
+        72, 65, 65, 62, 65, 68, 72, 75, 82, 83, 92, 93, 100, 102, 103, 104, 73,
+        66, 66, 63, 65, 69, 72, 76, 81, 85, 90, 93, 100, 102, 105, 106, 74, 67,
+        67, 64, 65, 70, 71, 77, 79, 86, 89, 94, 98, 103, 105, 106, 75, 68, 68,
+        65, 65, 71, 71, 78, 78, 87, 87, 96, 96, 105, 105, 109,
         /* Size 32x16 */
-        64, 63, 61, 62, 67, 74, 78, 84, 98, 97, 97, 98, 100, 102, 104, 109, 111,
-        114, 120, 124, 127, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156,
-        159, 62, 63, 64, 66, 72, 80, 82, 86, 93, 92, 92, 91, 93, 94, 96, 100,
-        102, 104, 109, 113, 115, 118, 121, 123, 126, 128, 131, 133, 136, 139,
-        141, 142, 71, 74, 76, 77, 83, 91, 92, 93, 96, 94, 93, 91, 93, 94, 95,
-        98, 99, 101, 106, 109, 111, 113, 116, 118, 121, 124, 126, 129, 132, 135,
-        138, 144, 77, 80, 81, 83, 88, 95, 95, 96, 98, 97, 96, 94, 96, 96, 97,
-        100, 101, 103, 107, 110, 112, 114, 116, 117, 119, 121, 123, 125, 127,
-        130, 132, 130, 96, 94, 92, 92, 94, 95, 97, 100, 106, 106, 106, 107, 108,
-        108, 109, 111, 112, 113, 117, 120, 121, 123, 125, 127, 129, 134, 136,
-        137, 138, 140, 142, 134, 98, 94, 91, 91, 92, 91, 94, 99, 107, 110, 112,
-        117, 119, 120, 122, 125, 126, 128, 131, 133, 135, 136, 138, 138, 138,
-        138, 133, 135, 136, 138, 140, 157, 101, 97, 93, 93, 93, 92, 95, 100,
-        108, 111, 113, 119, 122, 123, 127, 130, 131, 133, 136, 139, 140, 142,
-        144, 142, 142, 143, 148, 157, 157, 158, 159, 142, 105, 100, 97, 96, 95,
-        94, 97, 101, 109, 113, 115, 123, 127, 129, 133, 137, 139, 141, 145, 148,
-        150, 151, 153, 155, 162, 162, 161, 149, 148, 150, 151, 178, 115, 109,
-        105, 104, 103, 100, 103, 107, 114, 117, 120, 128, 133, 136, 142, 147,
-        149, 153, 158, 162, 164, 166, 168, 170, 168, 158, 160, 168, 182, 181,
-        180, 153, 122, 115, 111, 110, 108, 105, 108, 112, 118, 122, 124, 132,
-        137, 140, 146, 152, 155, 159, 165, 169, 172, 174, 177, 173, 172, 181,
-        187, 185, 163, 165, 167, 204, 127, 120, 116, 114, 112, 109, 111, 115,
-        121, 125, 128, 135, 140, 143, 150, 156, 159, 164, 170, 175, 178, 180,
-        183, 186, 196, 193, 177, 179, 202, 206, 203, 169, 135, 128, 123, 121,
-        119, 115, 116, 121, 127, 128, 133, 141, 143, 146, 156, 159, 161, 172,
-        175, 177, 187, 188, 188, 194, 192, 191, 207, 212, 196, 183, 185, 231,
-        140, 132, 128, 126, 122, 121, 118, 126, 124, 132, 136, 135, 149, 146,
-        152, 164, 157, 171, 175, 175, 192, 187, 196, 196, 193, 205, 202, 196,
-        207, 234, 229, 187, 145, 137, 133, 130, 127, 127, 120, 123, 132, 134,
-        134, 146, 139, 158, 149, 161, 166, 164, 182, 168, 197, 183, 196, 205,
-        200, 206, 198, 216, 215, 202, 205, 258, 150, 142, 139, 135, 132, 131,
-        125, 126, 139, 131, 146, 136, 156, 142, 167, 150, 173, 163, 181, 176,
-        184, 194, 191, 207, 194, 232, 200, 216, 203, 229, 229, 207, 155, 145,
-        147, 136, 140, 132, 135, 124, 130, 149, 135, 155, 139, 165, 145, 177,
-        151, 187, 158, 204, 166, 210, 175, 230, 184, 235, 193, 261, 204, 226,
-        208, 242,
+        32, 31, 30, 31, 33, 37, 39, 42, 49, 48, 48, 49, 50, 51, 52, 54, 55, 57,
+        60, 62, 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 31, 31, 32, 33,
+        36, 40, 41, 43, 46, 46, 46, 45, 46, 47, 48, 50, 51, 52, 54, 56, 57, 59,
+        60, 61, 62, 63, 64, 65, 65, 66, 67, 68, 35, 37, 38, 38, 41, 45, 46, 46,
+        48, 47, 46, 45, 46, 47, 47, 49, 49, 50, 53, 54, 55, 56, 58, 59, 60, 61,
+        62, 64, 65, 66, 67, 68, 38, 40, 40, 41, 44, 47, 47, 48, 49, 48, 48, 47,
+        48, 48, 48, 50, 50, 51, 53, 55, 56, 57, 58, 58, 59, 60, 60, 61, 62, 63,
+        64, 65, 48, 47, 46, 46, 47, 47, 48, 50, 53, 53, 53, 53, 54, 54, 54, 55,
+        56, 56, 58, 60, 60, 61, 62, 63, 64, 65, 65, 65, 65, 65, 65, 65, 49, 47,
+        45, 45, 46, 45, 47, 49, 53, 55, 56, 58, 59, 60, 61, 62, 63, 64, 65, 66,
+        67, 68, 69, 68, 67, 66, 66, 67, 68, 69, 70, 71, 50, 48, 46, 46, 46, 46,
+        47, 50, 54, 55, 56, 59, 61, 61, 63, 65, 65, 66, 68, 69, 70, 71, 72, 71,
+        71, 72, 73, 73, 72, 72, 71, 71, 52, 50, 48, 48, 47, 47, 48, 50, 54, 56,
+        57, 61, 63, 64, 66, 68, 69, 70, 72, 74, 75, 75, 76, 78, 79, 77, 76, 74,
+        75, 76, 77, 78, 57, 54, 52, 52, 51, 50, 51, 53, 57, 58, 60, 64, 66, 68,
+        71, 73, 74, 76, 79, 81, 82, 83, 84, 83, 81, 80, 81, 82, 82, 81, 79, 78,
+        61, 57, 55, 55, 54, 52, 54, 56, 59, 61, 62, 66, 68, 70, 73, 76, 77, 79,
+        82, 84, 86, 87, 88, 86, 86, 88, 87, 85, 83, 85, 86, 87, 63, 60, 58, 57,
+        56, 54, 55, 57, 60, 62, 64, 67, 70, 71, 75, 78, 79, 82, 85, 87, 89, 90,
+        91, 93, 94, 91, 89, 90, 92, 90, 89, 87, 67, 63, 61, 60, 59, 57, 57, 60,
+        63, 64, 66, 69, 71, 73, 77, 79, 81, 85, 87, 88, 92, 93, 94, 96, 95, 96,
+        97, 95, 93, 93, 94, 96, 68, 64, 63, 61, 60, 59, 58, 60, 61, 64, 65, 67,
+        71, 72, 75, 78, 79, 83, 85, 87, 91, 92, 95, 96, 97, 99, 98, 99, 100,
+        100, 98, 96, 69, 65, 64, 62, 61, 61, 59, 59, 62, 63, 65, 67, 68, 72, 73,
+        76, 78, 81, 84, 85, 89, 90, 93, 96, 98, 99, 100, 102, 102, 102, 103,
+        105, 70, 66, 65, 63, 63, 62, 61, 60, 61, 63, 65, 66, 69, 70, 74, 74, 78,
+        79, 82, 84, 87, 89, 91, 94, 96, 100, 101, 103, 103, 105, 105, 105, 71,
+        67, 67, 64, 64, 62, 62, 60, 61, 64, 64, 67, 67, 71, 71, 75, 75, 79, 80,
+        84, 84, 89, 89, 94, 94, 98, 99, 104, 104, 106, 106, 109,
         /* Size 4x16 */
-        62, 98, 122, 145, 64, 91, 111, 133, 72, 92, 108, 127, 82, 94, 108, 120,
-        93, 107, 118, 132, 92, 112, 124, 134, 93, 119, 137, 139, 96, 122, 146,
-        149, 102, 126, 155, 166, 109, 131, 165, 182, 115, 135, 172, 197, 121,
-        138, 177, 196, 126, 138, 172, 200, 131, 133, 187, 198, 136, 136, 163,
-        215, 141, 140, 167, 205,
+        31, 49, 61, 69, 32, 45, 55, 64, 36, 46, 54, 61, 41, 47, 54, 59, 46, 53,
+        59, 62, 46, 56, 62, 65, 46, 59, 68, 68, 48, 61, 73, 73, 51, 63, 77, 78,
+        54, 65, 82, 84, 57, 67, 86, 89, 60, 69, 88, 93, 62, 67, 86, 98, 64, 66,
+        87, 100, 65, 68, 83, 102, 67, 70, 86, 103,
         /* Size 16x4 */
-        62, 64, 72, 82, 93, 92, 93, 96, 102, 109, 115, 121, 126, 131, 136, 141,
-        98, 91, 92, 94, 107, 112, 119, 122, 126, 131, 135, 138, 138, 133, 136,
-        140, 122, 111, 108, 108, 118, 124, 137, 146, 155, 165, 172, 177, 172,
-        187, 163, 167, 145, 133, 127, 120, 132, 134, 139, 149, 166, 182, 197,
-        196, 200, 198, 215, 205,
+        31, 32, 36, 41, 46, 46, 46, 48, 51, 54, 57, 60, 62, 64, 65, 67, 49, 45,
+        46, 47, 53, 56, 59, 61, 63, 65, 67, 69, 67, 66, 68, 70, 61, 55, 54, 54,
+        59, 62, 68, 73, 77, 82, 86, 88, 86, 87, 83, 86, 69, 64, 61, 59, 62, 65,
+        68, 73, 78, 84, 89, 93, 98, 100, 102, 103,
         /* Size 8x32 */
-        64, 71, 96, 101, 115, 127, 140, 150, 63, 74, 94, 97, 109, 120, 132, 142,
-        61, 76, 92, 93, 105, 116, 128, 139, 62, 77, 92, 93, 104, 114, 126, 135,
-        67, 83, 94, 93, 103, 112, 122, 132, 74, 91, 95, 92, 100, 109, 121, 131,
-        78, 92, 97, 95, 103, 111, 118, 125, 84, 93, 100, 100, 107, 115, 126,
-        126, 98, 96, 106, 108, 114, 121, 124, 139, 97, 94, 106, 111, 117, 125,
-        132, 131, 97, 93, 106, 113, 120, 128, 136, 146, 98, 91, 107, 119, 128,
-        135, 135, 136, 100, 93, 108, 122, 133, 140, 149, 156, 102, 94, 108, 123,
-        136, 143, 146, 142, 104, 95, 109, 127, 142, 150, 152, 167, 109, 98, 111,
-        130, 147, 156, 164, 150, 111, 99, 112, 131, 149, 159, 157, 173, 114,
-        101, 113, 133, 153, 164, 171, 163, 120, 106, 117, 136, 158, 170, 175,
-        181, 124, 109, 120, 139, 162, 175, 175, 176, 127, 111, 121, 140, 164,
-        178, 192, 184, 129, 113, 123, 142, 166, 180, 187, 194, 132, 116, 125,
-        144, 168, 183, 196, 191, 135, 118, 127, 142, 170, 186, 196, 207, 138,
-        121, 129, 142, 168, 196, 193, 194, 141, 124, 134, 143, 158, 193, 205,
-        232, 144, 126, 136, 148, 160, 177, 202, 200, 147, 129, 137, 157, 168,
-        179, 196, 216, 150, 132, 138, 157, 182, 202, 207, 203, 153, 135, 140,
-        158, 181, 206, 234, 229, 156, 138, 142, 159, 180, 203, 229, 229, 159,
-        144, 134, 142, 153, 169, 187, 207,
+        32, 35, 48, 50, 57, 63, 68, 70, 31, 37, 47, 48, 54, 60, 64, 66, 30, 38,
+        46, 46, 52, 58, 63, 65, 31, 38, 46, 46, 52, 57, 61, 63, 33, 41, 47, 46,
+        51, 56, 60, 63, 37, 45, 47, 46, 50, 54, 59, 62, 39, 46, 48, 47, 51, 55,
+        58, 61, 42, 46, 50, 50, 53, 57, 60, 60, 49, 48, 53, 54, 57, 60, 61, 61,
+        48, 47, 53, 55, 58, 62, 64, 63, 48, 46, 53, 56, 60, 64, 65, 65, 49, 45,
+        53, 59, 64, 67, 67, 66, 50, 46, 54, 61, 66, 70, 71, 69, 51, 47, 54, 61,
+        68, 71, 72, 70, 52, 47, 54, 63, 71, 75, 75, 74, 54, 49, 55, 65, 73, 78,
+        78, 74, 55, 49, 56, 65, 74, 79, 79, 78, 57, 50, 56, 66, 76, 82, 83, 79,
+        60, 53, 58, 68, 79, 85, 85, 82, 62, 54, 60, 69, 81, 87, 87, 84, 63, 55,
+        60, 70, 82, 89, 91, 87, 64, 56, 61, 71, 83, 90, 92, 89, 66, 58, 62, 72,
+        84, 91, 95, 91, 67, 59, 63, 71, 83, 93, 96, 94, 68, 60, 64, 71, 81, 94,
+        97, 96, 69, 61, 65, 72, 80, 91, 99, 100, 70, 62, 65, 73, 81, 89, 98,
+        101, 71, 64, 65, 73, 82, 90, 99, 103, 72, 65, 65, 72, 82, 92, 100, 103,
+        73, 66, 65, 72, 81, 90, 100, 105, 74, 67, 65, 71, 79, 89, 98, 105, 75,
+        68, 65, 71, 78, 87, 96, 105,
         /* Size 32x8 */
-        64, 63, 61, 62, 67, 74, 78, 84, 98, 97, 97, 98, 100, 102, 104, 109, 111,
-        114, 120, 124, 127, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156,
-        159, 71, 74, 76, 77, 83, 91, 92, 93, 96, 94, 93, 91, 93, 94, 95, 98, 99,
-        101, 106, 109, 111, 113, 116, 118, 121, 124, 126, 129, 132, 135, 138,
-        144, 96, 94, 92, 92, 94, 95, 97, 100, 106, 106, 106, 107, 108, 108, 109,
-        111, 112, 113, 117, 120, 121, 123, 125, 127, 129, 134, 136, 137, 138,
-        140, 142, 134, 101, 97, 93, 93, 93, 92, 95, 100, 108, 111, 113, 119,
-        122, 123, 127, 130, 131, 133, 136, 139, 140, 142, 144, 142, 142, 143,
-        148, 157, 157, 158, 159, 142, 115, 109, 105, 104, 103, 100, 103, 107,
-        114, 117, 120, 128, 133, 136, 142, 147, 149, 153, 158, 162, 164, 166,
-        168, 170, 168, 158, 160, 168, 182, 181, 180, 153, 127, 120, 116, 114,
-        112, 109, 111, 115, 121, 125, 128, 135, 140, 143, 150, 156, 159, 164,
-        170, 175, 178, 180, 183, 186, 196, 193, 177, 179, 202, 206, 203, 169,
-        140, 132, 128, 126, 122, 121, 118, 126, 124, 132, 136, 135, 149, 146,
-        152, 164, 157, 171, 175, 175, 192, 187, 196, 196, 193, 205, 202, 196,
-        207, 234, 229, 187, 150, 142, 139, 135, 132, 131, 125, 126, 139, 131,
-        146, 136, 156, 142, 167, 150, 173, 163, 181, 176, 184, 194, 191, 207,
-        194, 232, 200, 216, 203, 229, 229, 207 },
+        32, 31, 30, 31, 33, 37, 39, 42, 49, 48, 48, 49, 50, 51, 52, 54, 55, 57,
+        60, 62, 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 35, 37, 38, 38,
+        41, 45, 46, 46, 48, 47, 46, 45, 46, 47, 47, 49, 49, 50, 53, 54, 55, 56,
+        58, 59, 60, 61, 62, 64, 65, 66, 67, 68, 48, 47, 46, 46, 47, 47, 48, 50,
+        53, 53, 53, 53, 54, 54, 54, 55, 56, 56, 58, 60, 60, 61, 62, 63, 64, 65,
+        65, 65, 65, 65, 65, 65, 50, 48, 46, 46, 46, 46, 47, 50, 54, 55, 56, 59,
+        61, 61, 63, 65, 65, 66, 68, 69, 70, 71, 72, 71, 71, 72, 73, 73, 72, 72,
+        71, 71, 57, 54, 52, 52, 51, 50, 51, 53, 57, 58, 60, 64, 66, 68, 71, 73,
+        74, 76, 79, 81, 82, 83, 84, 83, 81, 80, 81, 82, 82, 81, 79, 78, 63, 60,
+        58, 57, 56, 54, 55, 57, 60, 62, 64, 67, 70, 71, 75, 78, 79, 82, 85, 87,
+        89, 90, 91, 93, 94, 91, 89, 90, 92, 90, 89, 87, 68, 64, 63, 61, 60, 59,
+        58, 60, 61, 64, 65, 67, 71, 72, 75, 78, 79, 83, 85, 87, 91, 92, 95, 96,
+        97, 99, 98, 99, 100, 100, 98, 96, 70, 66, 65, 63, 63, 62, 61, 60, 61,
+        63, 65, 66, 69, 70, 74, 74, 78, 79, 82, 84, 87, 89, 91, 94, 96, 100,
+        101, 103, 103, 105, 105, 105 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        79, 153, 153, 280,
+        39, 76, 76, 140,
 #endif
         /* Size 4x4 */
-        65, 77, 127, 176, 77, 113, 157, 200, 127, 157, 227, 248, 176, 200, 248,
-        341,
+        32, 38, 63, 86, 38, 56, 78, 97, 63, 78, 113, 130, 86, 97, 130, 169,
         /* Size 8x8 */
-        64, 65, 70, 92, 114, 152, 172, 198, 65, 68, 75, 91, 108, 141, 159, 183,
-        70, 75, 97, 113, 128, 158, 176, 186, 92, 91, 113, 141, 161, 192, 199,
-        204, 114, 108, 128, 161, 186, 222, 245, 242, 152, 141, 158, 192, 222,
-        268, 272, 301, 172, 159, 176, 199, 245, 272, 314, 375, 198, 183, 186,
-        204, 242, 301, 375, 370,
+        32, 32, 35, 46, 57, 76, 85, 96, 32, 34, 37, 45, 54, 70, 79, 90, 35, 37,
+        48, 56, 64, 79, 87, 93, 46, 45, 56, 70, 80, 96, 100, 105, 57, 54, 64,
+        80, 93, 111, 121, 122, 76, 70, 79, 96, 111, 134, 138, 144, 85, 79, 87,
+        100, 121, 138, 156, 168, 96, 90, 93, 105, 122, 144, 168, 184,
         /* Size 16x16 */
-        64, 63, 63, 64, 69, 79, 88, 99, 116, 131, 143, 163, 176, 188, 202, 216,
-        63, 64, 65, 65, 68, 76, 83, 93, 108, 121, 132, 151, 162, 174, 187, 201,
-        63, 65, 67, 68, 72, 78, 84, 93, 106, 118, 129, 146, 156, 167, 179, 192,
-        64, 65, 68, 71, 75, 81, 85, 93, 105, 116, 126, 142, 151, 161, 171, 184,
-        69, 68, 72, 75, 85, 94, 100, 107, 119, 130, 140, 155, 164, 170, 188,
-        197, 79, 76, 78, 81, 94, 108, 116, 124, 136, 147, 156, 171, 180, 179,
-        197, 209, 88, 83, 84, 85, 100, 116, 127, 136, 149, 159, 169, 183, 192,
-        199, 203, 224, 99, 93, 93, 93, 107, 124, 136, 146, 162, 174, 184, 199,
-        206, 220, 210, 242, 116, 108, 106, 105, 119, 136, 149, 162, 180, 194,
-        205, 221, 230, 242, 223, 260, 131, 121, 118, 116, 130, 147, 159, 174,
-        194, 210, 222, 240, 251, 246, 238, 287, 143, 132, 129, 126, 140, 156,
-        169, 184, 205, 222, 235, 254, 265, 260, 264, 303, 163, 151, 146, 142,
-        155, 171, 183, 199, 221, 240, 254, 275, 287, 288, 296, 337, 176, 162,
-        156, 151, 164, 180, 192, 206, 230, 251, 265, 287, 301, 308, 342, 356,
-        188, 174, 167, 161, 170, 179, 199, 220, 242, 246, 260, 288, 308, 327,
-        332, 402, 202, 187, 179, 171, 188, 197, 203, 210, 223, 238, 264, 296,
-        342, 332, 355, 357, 216, 201, 192, 184, 197, 209, 224, 242, 260, 287,
-        303, 337, 356, 402, 357, 386,
+        32, 31, 31, 32, 34, 39, 44, 49, 58, 65, 71, 81, 87, 93, 98, 104, 31, 32,
+        32, 32, 34, 38, 41, 46, 54, 60, 66, 75, 81, 86, 92, 98, 31, 32, 33, 34,
+        36, 39, 42, 46, 53, 59, 64, 73, 78, 83, 88, 94, 32, 32, 34, 35, 37, 40,
+        42, 46, 52, 58, 63, 71, 75, 80, 86, 92, 34, 34, 36, 37, 42, 47, 50, 53,
+        59, 65, 70, 77, 82, 85, 89, 92, 39, 38, 39, 40, 47, 54, 58, 62, 68, 73,
+        78, 85, 90, 90, 96, 98, 44, 41, 42, 42, 50, 58, 63, 68, 74, 79, 84, 91,
+        96, 98, 102, 104, 49, 46, 46, 46, 53, 62, 68, 73, 81, 87, 92, 99, 103,
+        107, 109, 112, 58, 54, 53, 52, 59, 68, 74, 81, 90, 97, 102, 110, 114,
+        118, 117, 121, 65, 60, 59, 58, 65, 73, 79, 87, 97, 105, 111, 120, 125,
+        125, 126, 130, 71, 66, 64, 63, 70, 78, 84, 92, 102, 111, 117, 127, 133,
+        134, 136, 141, 81, 75, 73, 71, 77, 85, 91, 99, 110, 120, 127, 137, 143,
+        145, 148, 152, 87, 81, 78, 75, 82, 90, 96, 103, 114, 125, 133, 143, 150,
+        156, 160, 163, 93, 86, 83, 80, 85, 90, 98, 107, 118, 125, 134, 145, 156,
+        163, 169, 177, 98, 92, 88, 86, 89, 96, 102, 109, 117, 126, 136, 148,
+        160, 169, 176, 184, 104, 98, 94, 92, 92, 98, 104, 112, 121, 130, 141,
+        152, 163, 177, 184, 191,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 64, 64, 68, 69, 72, 79, 82, 88, 96, 99, 108, 116,
-        119, 131, 139, 143, 160, 163, 166, 176, 182, 188, 195, 202, 209, 216,
-        223, 63, 64, 64, 64, 64, 65, 65, 68, 69, 70, 77, 79, 85, 92, 95, 103,
-        111, 114, 125, 132, 136, 152, 155, 157, 167, 172, 178, 185, 191, 198,
-        204, 210, 63, 64, 64, 64, 65, 65, 65, 67, 68, 69, 76, 78, 83, 90, 93,
-        100, 108, 111, 121, 129, 132, 147, 151, 153, 162, 168, 174, 181, 187,
-        194, 201, 211, 63, 64, 64, 65, 65, 65, 65, 67, 68, 69, 75, 77, 82, 88,
-        91, 99, 106, 109, 119, 127, 130, 145, 148, 150, 159, 164, 170, 176, 182,
-        188, 195, 197, 63, 64, 65, 65, 67, 67, 68, 71, 72, 73, 78, 80, 84, 90,
-        93, 100, 106, 109, 118, 126, 129, 143, 146, 148, 156, 161, 167, 173,
-        179, 185, 192, 201, 64, 65, 65, 65, 67, 68, 69, 72, 73, 75, 80, 81, 85,
-        91, 93, 99, 106, 108, 117, 124, 127, 141, 144, 146, 154, 159, 166, 172,
-        177, 183, 189, 193, 64, 65, 65, 65, 68, 69, 71, 74, 75, 77, 81, 82, 85,
-        91, 93, 99, 105, 108, 116, 123, 126, 139, 142, 144, 151, 156, 161, 165,
-        171, 177, 184, 196, 68, 68, 67, 67, 71, 72, 74, 79, 82, 85, 90, 92, 95,
-        101, 103, 109, 115, 118, 126, 133, 136, 148, 151, 153, 161, 165, 168,
-        167, 171, 177, 182, 183, 69, 69, 68, 68, 72, 73, 75, 82, 85, 90, 94, 96,
-        100, 106, 107, 113, 119, 122, 130, 137, 140, 152, 155, 157, 164, 165,
-        170, 178, 188, 193, 197, 188, 72, 70, 69, 69, 73, 75, 77, 85, 90, 97,
-        101, 103, 108, 113, 115, 120, 126, 128, 136, 143, 146, 158, 160, 162,
-        170, 176, 182, 185, 180, 186, 191, 215, 79, 77, 76, 75, 78, 80, 81, 90,
-        94, 101, 108, 110, 116, 122, 124, 130, 136, 139, 147, 153, 156, 168,
-        171, 173, 180, 182, 179, 184, 197, 205, 209, 197, 82, 79, 78, 77, 80,
-        81, 82, 92, 96, 103, 110, 113, 119, 125, 127, 134, 140, 142, 150, 157,
-        160, 172, 175, 176, 183, 185, 195, 200, 197, 194, 199, 225, 88, 85, 83,
-        82, 84, 85, 85, 95, 100, 108, 116, 119, 127, 133, 136, 143, 149, 151,
-        159, 166, 169, 181, 183, 185, 192, 200, 199, 194, 203, 221, 224, 204,
-        96, 92, 90, 88, 90, 91, 91, 101, 106, 113, 122, 125, 133, 141, 143, 152,
-        158, 161, 170, 176, 180, 192, 194, 196, 203, 199, 201, 219, 220, 204,
-        209, 243, 99, 95, 93, 91, 93, 93, 93, 103, 107, 115, 124, 127, 136, 143,
-        146, 155, 162, 164, 174, 180, 184, 196, 199, 201, 206, 211, 220, 209,
-        210, 240, 242, 214, 108, 103, 100, 99, 100, 99, 99, 109, 113, 120, 130,
-        134, 143, 152, 155, 165, 172, 175, 185, 192, 195, 208, 211, 213, 220,
-        225, 214, 228, 239, 217, 220, 262, 116, 111, 108, 106, 106, 106, 105,
-        115, 119, 126, 136, 140, 149, 158, 162, 172, 180, 183, 194, 201, 205,
-        218, 221, 223, 230, 224, 242, 238, 223, 251, 260, 225, 119, 114, 111,
-        109, 109, 108, 108, 118, 122, 128, 139, 142, 151, 161, 164, 175, 183,
-        186, 198, 205, 209, 222, 225, 227, 234, 245, 239, 234, 265, 242, 233,
-        282, 131, 125, 121, 119, 118, 117, 116, 126, 130, 136, 147, 150, 159,
-        170, 174, 185, 194, 198, 210, 218, 222, 237, 240, 242, 251, 248, 246,
-        264, 238, 264, 287, 238, 139, 132, 129, 127, 126, 124, 123, 133, 137,
-        143, 153, 157, 166, 176, 180, 192, 201, 205, 218, 227, 231, 246, 250,
-        252, 259, 256, 272, 248, 282, 267, 248, 312, 143, 136, 132, 130, 129,
-        127, 126, 136, 140, 146, 156, 160, 169, 180, 184, 195, 205, 209, 222,
-        231, 235, 251, 254, 256, 265, 277, 260, 294, 264, 271, 303, 253, 160,
-        152, 147, 145, 143, 141, 139, 148, 152, 158, 168, 172, 181, 192, 196,
-        208, 218, 222, 237, 246, 251, 268, 272, 274, 285, 272, 294, 271, 294,
-        301, 264, 327, 163, 155, 151, 148, 146, 144, 142, 151, 155, 160, 171,
-        175, 183, 194, 199, 211, 221, 225, 240, 250, 254, 272, 275, 278, 287,
-        297, 288, 298, 296, 283, 337, 269, 166, 157, 153, 150, 148, 146, 144,
-        153, 157, 162, 173, 176, 185, 196, 201, 213, 223, 227, 242, 252, 256,
-        274, 278, 280, 290, 297, 305, 311, 298, 330, 282, 364, 176, 167, 162,
-        159, 156, 154, 151, 161, 164, 170, 180, 183, 192, 203, 206, 220, 230,
-        234, 251, 259, 265, 285, 287, 290, 301, 296, 308, 308, 342, 293, 356,
-        287, 182, 172, 168, 164, 161, 159, 156, 165, 165, 176, 182, 185, 200,
-        199, 211, 225, 224, 245, 248, 256, 277, 272, 297, 297, 296, 314, 303,
-        320, 308, 375, 299, 380, 188, 178, 174, 170, 167, 166, 161, 168, 170,
-        182, 179, 195, 199, 201, 220, 214, 242, 239, 246, 272, 260, 294, 288,
-        305, 308, 303, 327, 309, 332, 314, 402, 305, 195, 185, 181, 176, 173,
-        172, 165, 167, 178, 185, 184, 200, 194, 219, 209, 228, 238, 234, 264,
-        248, 294, 271, 298, 311, 308, 320, 309, 341, 315, 344, 321, 433, 202,
-        191, 187, 182, 179, 177, 171, 171, 188, 180, 197, 197, 203, 220, 210,
-        239, 223, 265, 238, 282, 264, 294, 296, 298, 342, 308, 332, 315, 355,
-        322, 357, 328, 209, 198, 194, 188, 185, 183, 177, 177, 193, 186, 205,
-        194, 221, 204, 240, 217, 251, 242, 264, 267, 271, 301, 283, 330, 293,
-        375, 314, 344, 322, 370, 329, 370, 216, 204, 201, 195, 192, 189, 184,
-        182, 197, 191, 209, 199, 224, 209, 242, 220, 260, 233, 287, 248, 303,
-        264, 337, 282, 356, 299, 402, 321, 357, 329, 386, 336, 223, 210, 211,
-        197, 201, 193, 196, 183, 188, 215, 197, 225, 204, 243, 214, 262, 225,
-        282, 238, 312, 253, 327, 269, 364, 287, 380, 305, 433, 328, 370, 336,
-        402,
+        32, 31, 31, 31, 31, 32, 32, 34, 34, 36, 39, 41, 44, 48, 49, 54, 58, 59,
+        65, 69, 71, 80, 81, 83, 87, 90, 93, 95, 98, 101, 104, 107, 31, 32, 32,
+        32, 32, 32, 32, 34, 34, 35, 38, 39, 42, 46, 47, 51, 55, 57, 62, 66, 68,
+        76, 77, 78, 83, 85, 88, 90, 93, 96, 99, 101, 31, 32, 32, 32, 32, 32, 32,
+        33, 34, 34, 38, 39, 41, 45, 46, 50, 54, 55, 60, 64, 66, 73, 75, 76, 81,
+        83, 86, 89, 92, 95, 98, 101, 31, 32, 32, 32, 32, 32, 32, 33, 34, 34, 37,
+        38, 41, 44, 45, 49, 53, 54, 59, 63, 65, 72, 74, 75, 79, 81, 84, 86, 89,
+        91, 94, 97, 31, 32, 32, 32, 33, 33, 34, 35, 36, 36, 39, 40, 42, 45, 46,
+        50, 53, 54, 59, 63, 64, 71, 73, 74, 78, 80, 83, 85, 88, 91, 94, 97, 32,
+        32, 32, 32, 33, 34, 34, 36, 36, 37, 40, 40, 42, 45, 46, 49, 53, 54, 58,
+        62, 63, 70, 72, 73, 77, 79, 82, 85, 87, 90, 92, 95, 32, 32, 32, 32, 34,
+        34, 35, 37, 37, 38, 40, 41, 42, 45, 46, 49, 52, 54, 58, 61, 63, 69, 71,
+        72, 75, 78, 80, 83, 86, 89, 92, 95, 34, 34, 33, 33, 35, 36, 37, 39, 41,
+        42, 45, 46, 47, 50, 51, 54, 57, 59, 63, 66, 68, 74, 75, 76, 80, 81, 82,
+        83, 85, 87, 90, 93, 34, 34, 34, 34, 36, 36, 37, 41, 42, 45, 47, 48, 50,
+        53, 53, 56, 59, 61, 65, 68, 70, 76, 77, 78, 82, 83, 85, 88, 89, 90, 92,
+        93, 36, 35, 34, 34, 36, 37, 38, 42, 45, 48, 50, 51, 54, 56, 57, 60, 63,
+        64, 68, 71, 73, 79, 80, 81, 85, 87, 89, 89, 90, 93, 96, 99, 39, 38, 38,
+        37, 39, 40, 40, 45, 47, 50, 54, 55, 58, 61, 62, 65, 68, 69, 73, 76, 78,
+        84, 85, 86, 90, 89, 90, 93, 96, 97, 98, 99, 41, 39, 39, 38, 40, 40, 41,
+        46, 48, 51, 55, 56, 59, 62, 63, 67, 70, 71, 75, 78, 80, 86, 87, 88, 91,
+        93, 96, 97, 97, 99, 102, 105, 44, 42, 41, 41, 42, 42, 42, 47, 50, 54,
+        58, 59, 63, 66, 68, 71, 74, 75, 79, 83, 84, 90, 91, 92, 96, 98, 98, 99,
+        102, 104, 104, 105, 48, 46, 45, 44, 45, 45, 45, 50, 53, 56, 61, 62, 66,
+        70, 71, 76, 79, 80, 85, 88, 90, 96, 97, 98, 101, 100, 102, 105, 105,
+        105, 109, 112, 49, 47, 46, 45, 46, 46, 46, 51, 53, 57, 62, 63, 68, 71,
+        73, 77, 81, 82, 87, 90, 92, 98, 99, 100, 103, 106, 107, 106, 109, 112,
+        112, 112, 54, 51, 50, 49, 50, 49, 49, 54, 56, 60, 65, 67, 71, 76, 77,
+        82, 86, 87, 92, 96, 97, 104, 105, 106, 110, 110, 109, 113, 114, 113,
+        116, 120, 58, 55, 54, 53, 53, 53, 52, 57, 59, 63, 68, 70, 74, 79, 81,
+        86, 90, 91, 97, 100, 102, 109, 110, 111, 114, 114, 118, 116, 117, 121,
+        121, 120, 59, 57, 55, 54, 54, 54, 54, 59, 61, 64, 69, 71, 75, 80, 82,
+        87, 91, 93, 99, 102, 104, 111, 112, 113, 117, 121, 120, 122, 124, 122,
+        125, 129, 65, 62, 60, 59, 59, 58, 58, 63, 65, 68, 73, 75, 79, 85, 87,
+        92, 97, 99, 105, 109, 111, 118, 120, 121, 125, 124, 125, 127, 126, 130,
+        130, 129, 69, 66, 64, 63, 63, 62, 61, 66, 68, 71, 76, 78, 83, 88, 90,
+        96, 100, 102, 109, 113, 115, 123, 125, 126, 129, 130, 131, 130, 134,
+        133, 135, 139, 71, 68, 66, 65, 64, 63, 63, 68, 70, 73, 78, 80, 84, 90,
+        92, 97, 102, 104, 111, 115, 117, 125, 127, 128, 133, 136, 134, 139, 136,
+        139, 141, 140, 80, 76, 73, 72, 71, 70, 69, 74, 76, 79, 84, 86, 90, 96,
+        98, 104, 109, 111, 118, 123, 125, 134, 136, 137, 142, 138, 143, 140,
+        144, 144, 144, 149, 81, 77, 75, 74, 73, 72, 71, 75, 77, 80, 85, 87, 91,
+        97, 99, 105, 110, 112, 120, 125, 127, 136, 137, 139, 143, 148, 145, 148,
+        148, 150, 152, 149, 83, 78, 76, 75, 74, 73, 72, 76, 78, 81, 86, 88, 92,
+        98, 100, 106, 111, 113, 121, 126, 128, 137, 139, 140, 145, 149, 153,
+        153, 154, 155, 155, 161, 87, 83, 81, 79, 78, 77, 75, 80, 82, 85, 90, 91,
+        96, 101, 103, 110, 114, 117, 125, 129, 133, 142, 143, 145, 150, 151,
+        156, 159, 160, 160, 163, 161, 90, 85, 83, 81, 80, 79, 78, 81, 83, 87,
+        89, 93, 98, 100, 106, 110, 114, 121, 124, 130, 136, 138, 148, 149, 151,
+        156, 157, 162, 166, 168, 166, 172, 93, 88, 86, 84, 83, 82, 80, 82, 85,
+        89, 90, 96, 98, 102, 107, 109, 118, 120, 125, 131, 134, 143, 145, 153,
+        156, 157, 163, 164, 169, 172, 177, 172, 95, 90, 89, 86, 85, 85, 83, 83,
+        88, 89, 93, 97, 99, 105, 106, 113, 116, 122, 127, 130, 139, 140, 148,
+        153, 159, 162, 164, 169, 170, 176, 179, 185, 98, 93, 92, 89, 88, 87, 86,
+        85, 89, 90, 96, 97, 102, 105, 109, 114, 117, 124, 126, 134, 136, 144,
+        148, 154, 160, 166, 169, 170, 176, 177, 184, 186, 101, 96, 95, 91, 91,
+        90, 89, 87, 90, 93, 97, 99, 104, 105, 112, 113, 121, 122, 130, 133, 139,
+        144, 150, 155, 160, 168, 172, 176, 177, 184, 185, 191, 104, 99, 98, 94,
+        94, 92, 92, 90, 92, 96, 98, 102, 104, 109, 112, 116, 121, 125, 130, 135,
+        141, 144, 152, 155, 163, 166, 177, 179, 184, 185, 191, 192, 107, 101,
+        101, 97, 97, 95, 95, 93, 93, 99, 99, 105, 105, 112, 112, 120, 120, 129,
+        129, 139, 140, 149, 149, 161, 161, 172, 172, 185, 186, 191, 192, 199,
         /* Size 4x8 */
-        64, 77, 124, 180, 65, 80, 117, 168, 69, 102, 136, 179, 89, 122, 170,
-        216, 109, 139, 197, 235, 145, 168, 236, 271, 165, 182, 260, 315, 189,
-        194, 243, 313,
+        32, 38, 62, 86, 32, 40, 58, 80, 34, 51, 68, 85, 44, 61, 85, 101, 54, 69,
+        98, 117, 72, 84, 118, 136, 82, 89, 129, 157, 92, 98, 127, 165,
         /* Size 8x4 */
-        64, 65, 69, 89, 109, 145, 165, 189, 77, 80, 102, 122, 139, 168, 182,
-        194, 124, 117, 136, 170, 197, 236, 260, 243, 180, 168, 179, 216, 235,
-        271, 315, 313,
+        32, 32, 34, 44, 54, 72, 82, 92, 38, 40, 51, 61, 69, 84, 89, 98, 62, 58,
+        68, 85, 98, 118, 129, 127, 86, 80, 85, 101, 117, 136, 157, 165,
         /* Size 8x16 */
-        64, 64, 72, 88, 116, 158, 179, 201, 63, 65, 70, 83, 108, 146, 165, 187,
-        64, 67, 73, 84, 106, 142, 158, 179, 64, 69, 77, 85, 105, 138, 154, 171,
-        69, 72, 89, 100, 119, 151, 163, 187, 79, 79, 101, 116, 136, 168, 179,
-        200, 88, 85, 107, 126, 149, 180, 199, 216, 98, 93, 114, 135, 162, 195,
-        209, 235, 115, 106, 126, 149, 180, 217, 222, 247, 130, 118, 136, 159,
-        194, 236, 249, 263, 142, 129, 146, 169, 205, 250, 276, 271, 162, 145,
-        161, 183, 221, 271, 292, 287, 175, 155, 170, 192, 230, 281, 294, 296,
-        187, 167, 179, 204, 229, 260, 307, 310, 200, 179, 187, 218, 261, 300,
-        320, 316, 215, 192, 197, 224, 261, 305, 357, 363,
+        32, 32, 36, 44, 58, 79, 88, 93, 31, 32, 35, 41, 54, 73, 81, 88, 32, 33,
+        36, 42, 53, 71, 78, 84, 32, 34, 38, 42, 52, 69, 76, 82, 34, 36, 44, 50,
+        59, 75, 81, 84, 39, 39, 50, 58, 68, 84, 88, 90, 44, 42, 53, 63, 74, 90,
+        97, 97, 49, 46, 57, 67, 81, 97, 104, 105, 57, 53, 63, 74, 90, 108, 111,
+        113, 65, 59, 68, 79, 97, 118, 123, 122, 71, 64, 73, 84, 102, 125, 135,
+        131, 81, 72, 80, 91, 110, 135, 145, 141, 87, 77, 85, 96, 114, 140, 148,
+        151, 92, 83, 88, 102, 117, 133, 153, 163, 98, 88, 89, 103, 121, 141,
+        160, 169, 103, 94, 92, 103, 119, 137, 158, 175,
         /* Size 16x8 */
-        64, 63, 64, 64, 69, 79, 88, 98, 115, 130, 142, 162, 175, 187, 200, 215,
-        64, 65, 67, 69, 72, 79, 85, 93, 106, 118, 129, 145, 155, 167, 179, 192,
-        72, 70, 73, 77, 89, 101, 107, 114, 126, 136, 146, 161, 170, 179, 187,
-        197, 88, 83, 84, 85, 100, 116, 126, 135, 149, 159, 169, 183, 192, 204,
-        218, 224, 116, 108, 106, 105, 119, 136, 149, 162, 180, 194, 205, 221,
-        230, 229, 261, 261, 158, 146, 142, 138, 151, 168, 180, 195, 217, 236,
-        250, 271, 281, 260, 300, 305, 179, 165, 158, 154, 163, 179, 199, 209,
-        222, 249, 276, 292, 294, 307, 320, 357, 201, 187, 179, 171, 187, 200,
-        216, 235, 247, 263, 271, 287, 296, 310, 316, 363,
+        32, 31, 32, 32, 34, 39, 44, 49, 57, 65, 71, 81, 87, 92, 98, 103, 32, 32,
+        33, 34, 36, 39, 42, 46, 53, 59, 64, 72, 77, 83, 88, 94, 36, 35, 36, 38,
+        44, 50, 53, 57, 63, 68, 73, 80, 85, 88, 89, 92, 44, 41, 42, 42, 50, 58,
+        63, 67, 74, 79, 84, 91, 96, 102, 103, 103, 58, 54, 53, 52, 59, 68, 74,
+        81, 90, 97, 102, 110, 114, 117, 121, 119, 79, 73, 71, 69, 75, 84, 90,
+        97, 108, 118, 125, 135, 140, 133, 141, 137, 88, 81, 78, 76, 81, 88, 97,
+        104, 111, 123, 135, 145, 148, 153, 160, 158, 93, 88, 84, 82, 84, 90, 97,
+        105, 113, 122, 131, 141, 151, 163, 169, 175,
         /* Size 16x32 */
-        64, 63, 64, 64, 72, 79, 88, 107, 116, 131, 158, 163, 179, 190, 201, 214,
-        63, 64, 65, 65, 71, 77, 85, 103, 111, 124, 151, 155, 169, 180, 191, 201,
-        63, 64, 65, 65, 70, 76, 83, 100, 108, 121, 146, 150, 165, 176, 187, 202,
-        63, 65, 65, 66, 69, 75, 82, 99, 106, 119, 144, 148, 162, 171, 182, 189,
-        64, 65, 67, 68, 73, 78, 84, 100, 106, 118, 142, 145, 158, 168, 179, 193,
-        64, 65, 68, 69, 75, 80, 85, 99, 106, 117, 140, 143, 157, 168, 177, 185,
-        64, 66, 69, 71, 77, 81, 85, 99, 105, 116, 138, 141, 154, 161, 171, 188,
-        68, 68, 71, 74, 85, 90, 96, 109, 115, 126, 147, 151, 163, 164, 171, 176,
-        69, 68, 72, 75, 89, 94, 100, 113, 119, 130, 151, 154, 163, 175, 187,
-        181, 72, 69, 74, 77, 96, 102, 108, 120, 126, 136, 157, 160, 173, 179,
-        180, 208, 79, 75, 79, 81, 101, 108, 116, 130, 136, 147, 168, 171, 179,
-        181, 200, 190, 81, 77, 81, 83, 103, 110, 119, 134, 140, 150, 171, 174,
-        183, 197, 189, 219, 88, 82, 85, 86, 107, 116, 126, 143, 149, 159, 180,
-        183, 199, 191, 216, 198, 95, 89, 91, 92, 112, 122, 133, 151, 158, 170,
-        191, 194, 199, 216, 199, 236, 98, 92, 93, 94, 114, 124, 135, 155, 162,
-        173, 195, 198, 209, 207, 235, 208, 107, 99, 100, 100, 120, 130, 142,
-        164, 172, 185, 207, 210, 224, 225, 213, 256, 115, 106, 106, 106, 126,
-        136, 149, 172, 180, 194, 217, 221, 222, 233, 247, 219, 118, 109, 109,
-        109, 128, 139, 151, 175, 183, 197, 222, 225, 240, 235, 235, 275, 130,
-        120, 118, 117, 136, 147, 159, 185, 194, 210, 236, 239, 249, 260, 263,
-        232, 138, 127, 125, 124, 143, 153, 166, 192, 201, 218, 245, 249, 254,
-        245, 258, 304, 142, 131, 129, 127, 146, 156, 169, 195, 205, 222, 250,
-        254, 276, 287, 271, 247, 159, 145, 142, 140, 158, 168, 181, 208, 218,
-        236, 267, 271, 275, 271, 288, 318, 162, 148, 145, 143, 161, 171, 183,
-        210, 221, 240, 271, 275, 292, 292, 287, 263, 165, 151, 147, 145, 162,
-        173, 185, 212, 223, 242, 273, 278, 295, 309, 315, 355, 175, 159, 155,
-        153, 170, 180, 192, 220, 230, 250, 281, 286, 294, 305, 296, 281, 181,
-        165, 161, 158, 176, 182, 197, 221, 224, 260, 277, 288, 309, 315, 361,
-        371, 187, 171, 167, 162, 179, 179, 204, 221, 229, 267, 260, 311, 307,
-        304, 310, 298, 194, 176, 173, 168, 183, 184, 216, 209, 241, 265, 265,
-        317, 300, 335, 338, 421, 200, 182, 179, 173, 187, 189, 218, 210, 261,
-        238, 300, 293, 320, 334, 316, 320, 207, 189, 186, 178, 192, 194, 221,
-        215, 260, 243, 307, 276, 363, 313, 362, 361, 215, 195, 192, 184, 197,
-        199, 224, 220, 261, 248, 305, 281, 357, 319, 363, 328, 222, 199, 202,
-        186, 190, 224, 205, 260, 225, 307, 253, 359, 287, 418, 326, 392,
+        32, 31, 32, 32, 36, 39, 44, 53, 58, 65, 79, 81, 88, 90, 93, 96, 31, 32,
+        32, 32, 35, 38, 42, 51, 55, 62, 75, 77, 83, 86, 88, 91, 31, 32, 32, 32,
+        35, 38, 41, 50, 54, 60, 73, 75, 81, 84, 88, 91, 31, 32, 32, 33, 34, 37,
+        41, 49, 53, 59, 72, 74, 79, 82, 84, 87, 32, 32, 33, 34, 36, 39, 42, 50,
+        53, 59, 71, 72, 78, 81, 84, 87, 32, 32, 34, 34, 37, 40, 42, 49, 53, 58,
+        70, 71, 77, 80, 83, 85, 32, 33, 34, 35, 38, 40, 42, 49, 52, 58, 69, 70,
+        76, 78, 82, 86, 34, 34, 35, 37, 42, 45, 48, 54, 57, 63, 73, 75, 79, 79,
+        81, 83, 34, 34, 36, 37, 44, 47, 50, 56, 59, 65, 75, 77, 81, 83, 84, 84,
+        36, 34, 37, 38, 48, 51, 54, 60, 63, 68, 78, 80, 85, 85, 86, 89, 39, 37,
+        39, 40, 50, 54, 58, 65, 68, 73, 84, 85, 88, 89, 90, 89, 40, 38, 40, 41,
+        51, 55, 59, 67, 70, 75, 85, 87, 91, 92, 92, 95, 44, 41, 42, 43, 53, 58,
+        63, 71, 74, 79, 90, 91, 97, 94, 97, 95, 47, 44, 45, 46, 56, 61, 66, 75,
+        79, 85, 95, 97, 99, 101, 98, 102, 49, 46, 46, 47, 57, 62, 67, 77, 81,
+        86, 97, 99, 104, 102, 105, 102, 53, 49, 50, 50, 60, 65, 71, 82, 86, 92,
+        103, 105, 109, 108, 106, 110, 57, 53, 53, 53, 63, 68, 74, 86, 90, 97,
+        108, 110, 111, 112, 113, 110, 59, 54, 54, 54, 64, 69, 75, 87, 91, 98,
+        111, 112, 119, 117, 115, 118, 65, 60, 59, 58, 68, 73, 79, 92, 97, 105,
+        118, 119, 123, 123, 122, 119, 69, 63, 62, 62, 71, 76, 83, 96, 100, 109,
+        122, 124, 127, 125, 125, 128, 71, 65, 64, 63, 73, 78, 84, 97, 102, 111,
+        125, 127, 135, 134, 131, 129, 79, 72, 71, 70, 79, 84, 90, 104, 109, 118,
+        133, 135, 137, 136, 136, 137, 81, 74, 72, 71, 80, 85, 91, 105, 110, 120,
+        135, 137, 145, 143, 141, 138, 82, 75, 73, 72, 81, 86, 92, 106, 111, 121,
+        136, 139, 147, 148, 147, 149, 87, 79, 77, 76, 85, 90, 96, 110, 114, 125,
+        140, 143, 148, 154, 151, 149, 90, 82, 80, 78, 87, 89, 99, 108, 113, 129,
+        135, 146, 153, 157, 160, 159, 92, 84, 83, 81, 88, 90, 102, 106, 117,
+        128, 133, 150, 153, 158, 163, 160, 95, 87, 85, 83, 88, 92, 103, 105,
+        120, 125, 137, 148, 155, 164, 168, 173, 98, 89, 88, 85, 89, 95, 103,
+        108, 121, 124, 141, 144, 160, 164, 169, 174, 100, 92, 91, 88, 90, 98,
+        103, 111, 120, 127, 139, 146, 161, 165, 175, 179, 103, 94, 94, 90, 92,
+        101, 103, 114, 119, 131, 137, 150, 158, 170, 175, 180, 106, 97, 97, 93,
+        93, 104, 104, 118, 118, 135, 135, 154, 155, 175, 176, 187,
         /* Size 32x16 */
-        64, 63, 63, 63, 64, 64, 64, 68, 69, 72, 79, 81, 88, 95, 98, 107, 115,
-        118, 130, 138, 142, 159, 162, 165, 175, 181, 187, 194, 200, 207, 215,
-        222, 63, 64, 64, 65, 65, 65, 66, 68, 68, 69, 75, 77, 82, 89, 92, 99,
-        106, 109, 120, 127, 131, 145, 148, 151, 159, 165, 171, 176, 182, 189,
-        195, 199, 64, 65, 65, 65, 67, 68, 69, 71, 72, 74, 79, 81, 85, 91, 93,
-        100, 106, 109, 118, 125, 129, 142, 145, 147, 155, 161, 167, 173, 179,
-        186, 192, 202, 64, 65, 65, 66, 68, 69, 71, 74, 75, 77, 81, 83, 86, 92,
-        94, 100, 106, 109, 117, 124, 127, 140, 143, 145, 153, 158, 162, 168,
-        173, 178, 184, 186, 72, 71, 70, 69, 73, 75, 77, 85, 89, 96, 101, 103,
-        107, 112, 114, 120, 126, 128, 136, 143, 146, 158, 161, 162, 170, 176,
-        179, 183, 187, 192, 197, 190, 79, 77, 76, 75, 78, 80, 81, 90, 94, 102,
-        108, 110, 116, 122, 124, 130, 136, 139, 147, 153, 156, 168, 171, 173,
-        180, 182, 179, 184, 189, 194, 199, 224, 88, 85, 83, 82, 84, 85, 85, 96,
-        100, 108, 116, 119, 126, 133, 135, 142, 149, 151, 159, 166, 169, 181,
-        183, 185, 192, 197, 204, 216, 218, 221, 224, 205, 107, 103, 100, 99,
-        100, 99, 99, 109, 113, 120, 130, 134, 143, 151, 155, 164, 172, 175, 185,
-        192, 195, 208, 210, 212, 220, 221, 221, 209, 210, 215, 220, 260, 116,
-        111, 108, 106, 106, 106, 105, 115, 119, 126, 136, 140, 149, 158, 162,
-        172, 180, 183, 194, 201, 205, 218, 221, 223, 230, 224, 229, 241, 261,
-        260, 261, 225, 131, 124, 121, 119, 118, 117, 116, 126, 130, 136, 147,
-        150, 159, 170, 173, 185, 194, 197, 210, 218, 222, 236, 240, 242, 250,
-        260, 267, 265, 238, 243, 248, 307, 158, 151, 146, 144, 142, 140, 138,
-        147, 151, 157, 168, 171, 180, 191, 195, 207, 217, 222, 236, 245, 250,
-        267, 271, 273, 281, 277, 260, 265, 300, 307, 305, 253, 163, 155, 150,
-        148, 145, 143, 141, 151, 154, 160, 171, 174, 183, 194, 198, 210, 221,
-        225, 239, 249, 254, 271, 275, 278, 286, 288, 311, 317, 293, 276, 281,
-        359, 179, 169, 165, 162, 158, 157, 154, 163, 163, 173, 179, 183, 199,
-        199, 209, 224, 222, 240, 249, 254, 276, 275, 292, 295, 294, 309, 307,
-        300, 320, 363, 357, 287, 190, 180, 176, 171, 168, 168, 161, 164, 175,
-        179, 181, 197, 191, 216, 207, 225, 233, 235, 260, 245, 287, 271, 292,
-        309, 305, 315, 304, 335, 334, 313, 319, 418, 201, 191, 187, 182, 179,
-        177, 171, 171, 187, 180, 200, 189, 216, 199, 235, 213, 247, 235, 263,
-        258, 271, 288, 287, 315, 296, 361, 310, 338, 316, 362, 363, 326, 214,
-        201, 202, 189, 193, 185, 188, 176, 181, 208, 190, 219, 198, 236, 208,
-        256, 219, 275, 232, 304, 247, 318, 263, 355, 281, 371, 298, 421, 320,
-        361, 328, 392,
+        32, 31, 31, 31, 32, 32, 32, 34, 34, 36, 39, 40, 44, 47, 49, 53, 57, 59,
+        65, 69, 71, 79, 81, 82, 87, 90, 92, 95, 98, 100, 103, 106, 31, 32, 32,
+        32, 32, 32, 33, 34, 34, 34, 37, 38, 41, 44, 46, 49, 53, 54, 60, 63, 65,
+        72, 74, 75, 79, 82, 84, 87, 89, 92, 94, 97, 32, 32, 32, 32, 33, 34, 34,
+        35, 36, 37, 39, 40, 42, 45, 46, 50, 53, 54, 59, 62, 64, 71, 72, 73, 77,
+        80, 83, 85, 88, 91, 94, 97, 32, 32, 32, 33, 34, 34, 35, 37, 37, 38, 40,
+        41, 43, 46, 47, 50, 53, 54, 58, 62, 63, 70, 71, 72, 76, 78, 81, 83, 85,
+        88, 90, 93, 36, 35, 35, 34, 36, 37, 38, 42, 44, 48, 50, 51, 53, 56, 57,
+        60, 63, 64, 68, 71, 73, 79, 80, 81, 85, 87, 88, 88, 89, 90, 92, 93, 39,
+        38, 38, 37, 39, 40, 40, 45, 47, 51, 54, 55, 58, 61, 62, 65, 68, 69, 73,
+        76, 78, 84, 85, 86, 90, 89, 90, 92, 95, 98, 101, 104, 44, 42, 41, 41,
+        42, 42, 42, 48, 50, 54, 58, 59, 63, 66, 67, 71, 74, 75, 79, 83, 84, 90,
+        91, 92, 96, 99, 102, 103, 103, 103, 103, 104, 53, 51, 50, 49, 50, 49,
+        49, 54, 56, 60, 65, 67, 71, 75, 77, 82, 86, 87, 92, 96, 97, 104, 105,
+        106, 110, 108, 106, 105, 108, 111, 114, 118, 58, 55, 54, 53, 53, 53, 52,
+        57, 59, 63, 68, 70, 74, 79, 81, 86, 90, 91, 97, 100, 102, 109, 110, 111,
+        114, 113, 117, 120, 121, 120, 119, 118, 65, 62, 60, 59, 59, 58, 58, 63,
+        65, 68, 73, 75, 79, 85, 86, 92, 97, 98, 105, 109, 111, 118, 120, 121,
+        125, 129, 128, 125, 124, 127, 131, 135, 79, 75, 73, 72, 71, 70, 69, 73,
+        75, 78, 84, 85, 90, 95, 97, 103, 108, 111, 118, 122, 125, 133, 135, 136,
+        140, 135, 133, 137, 141, 139, 137, 135, 81, 77, 75, 74, 72, 71, 70, 75,
+        77, 80, 85, 87, 91, 97, 99, 105, 110, 112, 119, 124, 127, 135, 137, 139,
+        143, 146, 150, 148, 144, 146, 150, 154, 88, 83, 81, 79, 78, 77, 76, 79,
+        81, 85, 88, 91, 97, 99, 104, 109, 111, 119, 123, 127, 135, 137, 145,
+        147, 148, 153, 153, 155, 160, 161, 158, 155, 90, 86, 84, 82, 81, 80, 78,
+        79, 83, 85, 89, 92, 94, 101, 102, 108, 112, 117, 123, 125, 134, 136,
+        143, 148, 154, 157, 158, 164, 164, 165, 170, 175, 93, 88, 88, 84, 84,
+        83, 82, 81, 84, 86, 90, 92, 97, 98, 105, 106, 113, 115, 122, 125, 131,
+        136, 141, 147, 151, 160, 163, 168, 169, 175, 175, 176, 96, 91, 91, 87,
+        87, 85, 86, 83, 84, 89, 89, 95, 95, 102, 102, 110, 110, 118, 119, 128,
+        129, 137, 138, 149, 149, 159, 160, 173, 174, 179, 180, 187,
         /* Size 4x16 */
-        63, 79, 131, 190, 64, 76, 121, 176, 65, 78, 118, 168, 66, 81, 116, 161,
-        68, 94, 130, 175, 75, 108, 147, 181, 82, 116, 159, 191, 92, 124, 173,
-        207, 106, 136, 194, 233, 120, 147, 210, 260, 131, 156, 222, 287, 148,
-        171, 240, 292, 159, 180, 250, 305, 171, 179, 267, 304, 182, 189, 238,
-        334, 195, 199, 248, 319,
+        31, 39, 65, 90, 32, 38, 60, 84, 32, 39, 59, 81, 33, 40, 58, 78, 34, 47,
+        65, 83, 37, 54, 73, 89, 41, 58, 79, 94, 46, 62, 86, 102, 53, 68, 97,
+        112, 60, 73, 105, 123, 65, 78, 111, 134, 74, 85, 120, 143, 79, 90, 125,
+        154, 84, 90, 128, 158, 89, 95, 124, 164, 94, 101, 131, 170,
         /* Size 16x4 */
-        63, 64, 65, 66, 68, 75, 82, 92, 106, 120, 131, 148, 159, 171, 182, 195,
-        79, 76, 78, 81, 94, 108, 116, 124, 136, 147, 156, 171, 180, 179, 189,
-        199, 131, 121, 118, 116, 130, 147, 159, 173, 194, 210, 222, 240, 250,
-        267, 238, 248, 190, 176, 168, 161, 175, 181, 191, 207, 233, 260, 287,
-        292, 305, 304, 334, 319,
+        31, 32, 32, 33, 34, 37, 41, 46, 53, 60, 65, 74, 79, 84, 89, 94, 39, 38,
+        39, 40, 47, 54, 58, 62, 68, 73, 78, 85, 90, 90, 95, 101, 65, 60, 59, 58,
+        65, 73, 79, 86, 97, 105, 111, 120, 125, 128, 124, 131, 90, 84, 81, 78,
+        83, 89, 94, 102, 112, 123, 134, 143, 154, 158, 164, 170,
         /* Size 8x32 */
-        64, 64, 72, 88, 116, 158, 179, 201, 63, 65, 71, 85, 111, 151, 169, 191,
-        63, 65, 70, 83, 108, 146, 165, 187, 63, 65, 69, 82, 106, 144, 162, 182,
-        64, 67, 73, 84, 106, 142, 158, 179, 64, 68, 75, 85, 106, 140, 157, 177,
-        64, 69, 77, 85, 105, 138, 154, 171, 68, 71, 85, 96, 115, 147, 163, 171,
-        69, 72, 89, 100, 119, 151, 163, 187, 72, 74, 96, 108, 126, 157, 173,
-        180, 79, 79, 101, 116, 136, 168, 179, 200, 81, 81, 103, 119, 140, 171,
-        183, 189, 88, 85, 107, 126, 149, 180, 199, 216, 95, 91, 112, 133, 158,
-        191, 199, 199, 98, 93, 114, 135, 162, 195, 209, 235, 107, 100, 120, 142,
-        172, 207, 224, 213, 115, 106, 126, 149, 180, 217, 222, 247, 118, 109,
-        128, 151, 183, 222, 240, 235, 130, 118, 136, 159, 194, 236, 249, 263,
-        138, 125, 143, 166, 201, 245, 254, 258, 142, 129, 146, 169, 205, 250,
-        276, 271, 159, 142, 158, 181, 218, 267, 275, 288, 162, 145, 161, 183,
-        221, 271, 292, 287, 165, 147, 162, 185, 223, 273, 295, 315, 175, 155,
-        170, 192, 230, 281, 294, 296, 181, 161, 176, 197, 224, 277, 309, 361,
-        187, 167, 179, 204, 229, 260, 307, 310, 194, 173, 183, 216, 241, 265,
-        300, 338, 200, 179, 187, 218, 261, 300, 320, 316, 207, 186, 192, 221,
-        260, 307, 363, 362, 215, 192, 197, 224, 261, 305, 357, 363, 222, 202,
-        190, 205, 225, 253, 287, 326,
+        32, 32, 36, 44, 58, 79, 88, 93, 31, 32, 35, 42, 55, 75, 83, 88, 31, 32,
+        35, 41, 54, 73, 81, 88, 31, 32, 34, 41, 53, 72, 79, 84, 32, 33, 36, 42,
+        53, 71, 78, 84, 32, 34, 37, 42, 53, 70, 77, 83, 32, 34, 38, 42, 52, 69,
+        76, 82, 34, 35, 42, 48, 57, 73, 79, 81, 34, 36, 44, 50, 59, 75, 81, 84,
+        36, 37, 48, 54, 63, 78, 85, 86, 39, 39, 50, 58, 68, 84, 88, 90, 40, 40,
+        51, 59, 70, 85, 91, 92, 44, 42, 53, 63, 74, 90, 97, 97, 47, 45, 56, 66,
+        79, 95, 99, 98, 49, 46, 57, 67, 81, 97, 104, 105, 53, 50, 60, 71, 86,
+        103, 109, 106, 57, 53, 63, 74, 90, 108, 111, 113, 59, 54, 64, 75, 91,
+        111, 119, 115, 65, 59, 68, 79, 97, 118, 123, 122, 69, 62, 71, 83, 100,
+        122, 127, 125, 71, 64, 73, 84, 102, 125, 135, 131, 79, 71, 79, 90, 109,
+        133, 137, 136, 81, 72, 80, 91, 110, 135, 145, 141, 82, 73, 81, 92, 111,
+        136, 147, 147, 87, 77, 85, 96, 114, 140, 148, 151, 90, 80, 87, 99, 113,
+        135, 153, 160, 92, 83, 88, 102, 117, 133, 153, 163, 95, 85, 88, 103,
+        120, 137, 155, 168, 98, 88, 89, 103, 121, 141, 160, 169, 100, 91, 90,
+        103, 120, 139, 161, 175, 103, 94, 92, 103, 119, 137, 158, 175, 106, 97,
+        93, 104, 118, 135, 155, 176,
         /* Size 32x8 */
-        64, 63, 63, 63, 64, 64, 64, 68, 69, 72, 79, 81, 88, 95, 98, 107, 115,
-        118, 130, 138, 142, 159, 162, 165, 175, 181, 187, 194, 200, 207, 215,
-        222, 64, 65, 65, 65, 67, 68, 69, 71, 72, 74, 79, 81, 85, 91, 93, 100,
-        106, 109, 118, 125, 129, 142, 145, 147, 155, 161, 167, 173, 179, 186,
-        192, 202, 72, 71, 70, 69, 73, 75, 77, 85, 89, 96, 101, 103, 107, 112,
-        114, 120, 126, 128, 136, 143, 146, 158, 161, 162, 170, 176, 179, 183,
-        187, 192, 197, 190, 88, 85, 83, 82, 84, 85, 85, 96, 100, 108, 116, 119,
-        126, 133, 135, 142, 149, 151, 159, 166, 169, 181, 183, 185, 192, 197,
-        204, 216, 218, 221, 224, 205, 116, 111, 108, 106, 106, 106, 105, 115,
-        119, 126, 136, 140, 149, 158, 162, 172, 180, 183, 194, 201, 205, 218,
-        221, 223, 230, 224, 229, 241, 261, 260, 261, 225, 158, 151, 146, 144,
-        142, 140, 138, 147, 151, 157, 168, 171, 180, 191, 195, 207, 217, 222,
-        236, 245, 250, 267, 271, 273, 281, 277, 260, 265, 300, 307, 305, 253,
-        179, 169, 165, 162, 158, 157, 154, 163, 163, 173, 179, 183, 199, 199,
-        209, 224, 222, 240, 249, 254, 276, 275, 292, 295, 294, 309, 307, 300,
-        320, 363, 357, 287, 201, 191, 187, 182, 179, 177, 171, 171, 187, 180,
-        200, 189, 216, 199, 235, 213, 247, 235, 263, 258, 271, 288, 287, 315,
-        296, 361, 310, 338, 316, 362, 363, 326 },
+        32, 31, 31, 31, 32, 32, 32, 34, 34, 36, 39, 40, 44, 47, 49, 53, 57, 59,
+        65, 69, 71, 79, 81, 82, 87, 90, 92, 95, 98, 100, 103, 106, 32, 32, 32,
+        32, 33, 34, 34, 35, 36, 37, 39, 40, 42, 45, 46, 50, 53, 54, 59, 62, 64,
+        71, 72, 73, 77, 80, 83, 85, 88, 91, 94, 97, 36, 35, 35, 34, 36, 37, 38,
+        42, 44, 48, 50, 51, 53, 56, 57, 60, 63, 64, 68, 71, 73, 79, 80, 81, 85,
+        87, 88, 88, 89, 90, 92, 93, 44, 42, 41, 41, 42, 42, 42, 48, 50, 54, 58,
+        59, 63, 66, 67, 71, 74, 75, 79, 83, 84, 90, 91, 92, 96, 99, 102, 103,
+        103, 103, 103, 104, 58, 55, 54, 53, 53, 53, 52, 57, 59, 63, 68, 70, 74,
+        79, 81, 86, 90, 91, 97, 100, 102, 109, 110, 111, 114, 113, 117, 120,
+        121, 120, 119, 118, 79, 75, 73, 72, 71, 70, 69, 73, 75, 78, 84, 85, 90,
+        95, 97, 103, 108, 111, 118, 122, 125, 133, 135, 136, 140, 135, 133, 137,
+        141, 139, 137, 135, 88, 83, 81, 79, 78, 77, 76, 79, 81, 85, 88, 91, 97,
+        99, 104, 109, 111, 119, 123, 127, 135, 137, 145, 147, 148, 153, 153,
+        155, 160, 161, 158, 155, 93, 88, 88, 84, 84, 83, 82, 81, 84, 86, 90, 92,
+        97, 98, 105, 106, 113, 115, 122, 125, 131, 136, 141, 147, 151, 160, 163,
+        168, 169, 175, 175, 176 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        97, 117, 117, 183,
+        48, 58, 58, 91,
 #endif
         /* Size 4x4 */
-        64, 91, 107, 128, 91, 110, 125, 140, 107, 125, 160, 166, 128, 140, 166,
-        208,
+        32, 45, 53, 63, 45, 55, 62, 67, 53, 62, 80, 84, 63, 67, 84, 101,
         /* Size 8x8 */
-        63, 73, 95, 97, 104, 121, 129, 139, 73, 86, 95, 93, 98, 111, 119, 129,
-        95, 95, 106, 108, 111, 121, 128, 129, 97, 93, 108, 122, 130, 141, 142,
-        140, 104, 98, 111, 130, 143, 157, 166, 160, 121, 111, 121, 141, 157,
-        178, 179, 189, 129, 119, 128, 142, 166, 179, 197, 221, 139, 129, 129,
-        140, 160, 189, 221, 219,
+        31, 36, 47, 48, 52, 60, 64, 67, 36, 43, 47, 46, 49, 55, 59, 63, 47, 47,
+        53, 54, 55, 60, 63, 64, 48, 46, 54, 61, 65, 70, 71, 71, 52, 49, 55, 65,
+        71, 78, 81, 79, 60, 55, 60, 70, 78, 89, 89, 89, 64, 59, 63, 71, 81, 89,
+        97, 99, 67, 63, 64, 71, 79, 89, 99, 104,
         /* Size 16x16 */
-        64, 61, 67, 73, 89, 97, 98, 102, 108, 114, 120, 129, 134, 139, 144, 150,
-        61, 63, 70, 79, 88, 92, 92, 95, 100, 106, 111, 119, 123, 129, 134, 140,
-        67, 70, 78, 87, 92, 93, 91, 94, 98, 102, 107, 114, 118, 122, 127, 133,
-        73, 79, 87, 95, 95, 93, 91, 93, 96, 100, 104, 110, 114, 118, 121, 126,
-        89, 88, 92, 95, 100, 102, 102, 103, 106, 109, 113, 119, 122, 124, 132,
-        135, 97, 92, 93, 93, 102, 109, 111, 113, 117, 120, 123, 129, 132, 129,
-        137, 141, 98, 92, 91, 91, 102, 111, 117, 120, 124, 127, 131, 136, 139,
-        140, 140, 149, 102, 95, 94, 93, 103, 113, 120, 125, 131, 135, 139, 144,
-        146, 152, 145, 159, 108, 100, 98, 96, 106, 117, 124, 131, 140, 146, 150,
-        156, 159, 163, 152, 168, 114, 106, 102, 100, 109, 120, 127, 135, 146,
-        153, 158, 165, 169, 165, 160, 181, 120, 111, 107, 104, 113, 123, 131,
-        139, 150, 158, 164, 172, 176, 173, 173, 189, 129, 119, 114, 110, 119,
-        129, 136, 144, 156, 165, 172, 181, 186, 186, 188, 205, 134, 123, 118,
-        114, 122, 132, 139, 146, 159, 169, 176, 186, 192, 194, 208, 212, 139,
-        129, 122, 118, 124, 129, 140, 152, 163, 165, 173, 186, 194, 202, 204,
-        231, 144, 134, 127, 121, 132, 137, 140, 145, 152, 160, 173, 188, 208,
-        204, 213, 214, 150, 140, 133, 126, 135, 141, 149, 159, 168, 181, 189,
-        205, 212, 231, 214, 225,
+        32, 30, 33, 36, 44, 48, 49, 51, 54, 57, 60, 64, 67, 68, 70, 72, 30, 31,
+        35, 39, 44, 46, 46, 47, 50, 53, 55, 59, 61, 64, 66, 68, 33, 35, 39, 43,
+        46, 46, 45, 47, 49, 51, 53, 57, 59, 61, 63, 65, 36, 39, 43, 47, 47, 46,
+        45, 46, 48, 50, 52, 55, 57, 58, 61, 63, 44, 44, 46, 47, 50, 51, 51, 51,
+        53, 54, 56, 59, 61, 61, 63, 62, 48, 46, 46, 46, 51, 54, 55, 56, 58, 60,
+        61, 64, 65, 64, 66, 66, 49, 46, 45, 45, 51, 55, 58, 60, 62, 63, 65, 68,
+        69, 69, 69, 69, 51, 47, 47, 46, 51, 56, 60, 62, 65, 67, 69, 72, 73, 74,
+        73, 73, 54, 50, 49, 48, 53, 58, 62, 65, 70, 73, 75, 78, 79, 79, 77, 77,
+        57, 53, 51, 50, 54, 60, 63, 67, 73, 76, 79, 82, 84, 83, 82, 82, 60, 55,
+        53, 52, 56, 61, 65, 69, 75, 79, 82, 86, 88, 87, 86, 87, 64, 59, 57, 55,
+        59, 64, 68, 72, 78, 82, 86, 90, 93, 92, 91, 92, 67, 61, 59, 57, 61, 65,
+        69, 73, 79, 84, 88, 93, 95, 96, 96, 96, 68, 64, 61, 58, 61, 64, 69, 74,
+        79, 83, 87, 92, 96, 99, 100, 101, 70, 66, 63, 61, 63, 66, 69, 73, 77,
+        82, 86, 91, 96, 100, 103, 104, 72, 68, 65, 63, 62, 66, 69, 73, 77, 82,
+        87, 92, 96, 101, 104, 106,
         /* Size 32x32 */
-        64, 62, 61, 61, 67, 70, 73, 83, 89, 98, 97, 97, 98, 101, 102, 104, 108,
-        110, 114, 118, 120, 127, 129, 130, 134, 137, 139, 142, 144, 147, 150,
-        153, 62, 63, 63, 62, 69, 73, 77, 85, 89, 95, 94, 94, 94, 97, 97, 100,
-        103, 104, 109, 112, 114, 121, 122, 123, 127, 129, 132, 134, 137, 139,
-        142, 143, 61, 63, 63, 63, 70, 74, 79, 85, 88, 94, 92, 92, 92, 94, 95,
-        97, 100, 102, 106, 109, 111, 117, 119, 120, 123, 126, 129, 131, 134,
-        137, 140, 144, 61, 62, 63, 64, 71, 75, 80, 85, 88, 93, 91, 91, 90, 93,
-        93, 95, 99, 100, 104, 107, 109, 115, 116, 117, 121, 123, 126, 128, 130,
-        133, 135, 135, 67, 69, 70, 71, 78, 82, 87, 90, 92, 95, 93, 92, 91, 93,
-        94, 95, 98, 99, 102, 106, 107, 113, 114, 115, 118, 120, 122, 125, 127,
-        130, 133, 138, 70, 73, 74, 75, 82, 86, 91, 92, 93, 95, 93, 92, 91, 93,
-        93, 94, 97, 98, 101, 104, 106, 111, 112, 113, 116, 119, 122, 124, 127,
-        129, 131, 131, 73, 77, 79, 80, 87, 91, 95, 95, 95, 96, 93, 92, 91, 92,
-        93, 94, 96, 97, 100, 103, 104, 109, 110, 111, 114, 116, 118, 119, 121,
-        124, 126, 133, 83, 85, 85, 85, 90, 92, 95, 97, 99, 101, 99, 99, 98, 100,
-        100, 101, 103, 104, 107, 109, 111, 115, 116, 117, 120, 121, 122, 121,
-        122, 124, 126, 124, 89, 89, 88, 88, 92, 93, 95, 99, 100, 103, 102, 102,
-        102, 103, 103, 104, 106, 107, 109, 112, 113, 118, 119, 119, 122, 122,
-        124, 127, 132, 133, 135, 128, 98, 95, 94, 93, 95, 95, 96, 101, 103, 106,
-        106, 107, 107, 108, 108, 109, 111, 111, 113, 116, 117, 121, 122, 123,
-        126, 128, 131, 131, 127, 129, 131, 143, 97, 94, 92, 91, 93, 93, 93, 99,
-        102, 106, 109, 109, 111, 113, 113, 115, 117, 118, 120, 122, 123, 127,
-        129, 129, 132, 132, 129, 131, 137, 140, 141, 133, 97, 94, 92, 91, 92,
-        92, 92, 99, 102, 107, 109, 110, 113, 115, 115, 117, 119, 120, 122, 125,
-        126, 130, 131, 131, 133, 133, 138, 140, 137, 134, 136, 149, 98, 94, 92,
-        90, 91, 91, 91, 98, 102, 107, 111, 113, 117, 119, 120, 123, 124, 125,
-        127, 130, 131, 135, 136, 136, 139, 142, 140, 137, 140, 149, 149, 138,
-        101, 97, 94, 93, 93, 93, 92, 100, 103, 108, 113, 115, 119, 122, 124,
-        127, 129, 130, 133, 136, 137, 141, 142, 143, 145, 142, 142, 150, 149,
-        140, 141, 158, 102, 97, 95, 93, 94, 93, 93, 100, 103, 108, 113, 115,
-        120, 124, 125, 129, 131, 132, 135, 138, 139, 143, 144, 145, 146, 148,
-        152, 145, 145, 159, 159, 143, 104, 100, 97, 95, 95, 94, 94, 101, 104,
-        109, 115, 117, 123, 127, 129, 133, 136, 137, 141, 144, 145, 150, 151,
-        151, 154, 156, 149, 155, 160, 147, 148, 168, 108, 103, 100, 99, 98, 97,
-        96, 103, 106, 111, 117, 119, 124, 129, 131, 136, 140, 141, 146, 149,
-        150, 155, 156, 157, 159, 155, 163, 160, 152, 165, 168, 149, 110, 104,
-        102, 100, 99, 98, 97, 104, 107, 111, 118, 120, 125, 130, 132, 137, 141,
-        143, 147, 150, 152, 157, 158, 159, 161, 166, 162, 159, 173, 160, 155,
-        178, 114, 109, 106, 104, 102, 101, 100, 107, 109, 113, 120, 122, 127,
-        133, 135, 141, 146, 147, 153, 156, 158, 164, 165, 166, 169, 167, 165,
-        173, 160, 172, 181, 156, 118, 112, 109, 107, 106, 104, 103, 109, 112,
-        116, 122, 125, 130, 136, 138, 144, 149, 150, 156, 160, 162, 168, 170,
-        170, 173, 171, 178, 166, 181, 173, 163, 192, 120, 114, 111, 109, 107,
-        106, 104, 111, 113, 117, 123, 126, 131, 137, 139, 145, 150, 152, 158,
-        162, 164, 170, 172, 172, 176, 181, 173, 188, 173, 175, 189, 164, 127,
-        121, 117, 115, 113, 111, 109, 115, 118, 121, 127, 130, 135, 141, 143,
-        150, 155, 157, 164, 168, 170, 178, 179, 180, 185, 179, 188, 177, 187,
-        189, 171, 199, 129, 122, 119, 116, 114, 112, 110, 116, 119, 122, 129,
-        131, 136, 142, 144, 151, 156, 158, 165, 170, 172, 179, 181, 182, 186,
-        190, 186, 189, 188, 182, 205, 173, 130, 123, 120, 117, 115, 113, 111,
-        117, 119, 123, 129, 131, 136, 143, 145, 151, 157, 159, 166, 170, 172,
-        180, 182, 183, 187, 190, 193, 195, 189, 202, 180, 216, 134, 127, 123,
-        121, 118, 116, 114, 120, 122, 126, 132, 133, 139, 145, 146, 154, 159,
-        161, 169, 173, 176, 185, 186, 187, 192, 190, 194, 194, 208, 187, 212,
-        182, 137, 129, 126, 123, 120, 119, 116, 121, 122, 128, 132, 133, 142,
-        142, 148, 156, 155, 166, 167, 171, 181, 179, 190, 190, 190, 197, 192,
-        199, 194, 221, 189, 222, 139, 132, 129, 126, 122, 122, 118, 122, 124,
-        131, 129, 138, 140, 142, 152, 149, 163, 162, 165, 178, 173, 188, 186,
-        193, 194, 192, 202, 195, 204, 196, 231, 191, 142, 134, 131, 128, 125,
-        124, 119, 121, 127, 131, 131, 140, 137, 150, 145, 155, 160, 159, 173,
-        166, 188, 177, 189, 195, 194, 199, 195, 208, 197, 209, 199, 243, 144,
-        137, 134, 130, 127, 127, 121, 122, 132, 127, 137, 137, 140, 149, 145,
-        160, 152, 173, 160, 181, 173, 187, 188, 189, 208, 194, 204, 197, 213,
-        200, 214, 202, 147, 139, 137, 133, 130, 129, 124, 124, 133, 129, 140,
-        134, 149, 140, 159, 147, 165, 160, 172, 173, 175, 189, 182, 202, 187,
-        221, 196, 209, 200, 219, 203, 219, 150, 142, 140, 135, 133, 131, 126,
-        126, 135, 131, 141, 136, 149, 141, 159, 148, 168, 155, 181, 163, 189,
-        171, 205, 180, 212, 189, 231, 199, 214, 203, 225, 205, 153, 143, 144,
-        135, 138, 131, 133, 124, 128, 143, 133, 149, 138, 158, 143, 168, 149,
-        178, 156, 192, 164, 199, 173, 216, 182, 222, 191, 243, 202, 219, 205,
-        231,
+        32, 31, 30, 30, 33, 35, 36, 41, 44, 49, 48, 48, 49, 50, 51, 52, 54, 55,
+        57, 59, 60, 63, 64, 65, 67, 68, 68, 69, 70, 71, 72, 73, 31, 31, 31, 31,
+        34, 36, 38, 42, 44, 47, 47, 47, 47, 48, 48, 50, 51, 52, 54, 56, 57, 60,
+        61, 61, 63, 64, 65, 66, 67, 67, 68, 69, 30, 31, 31, 31, 35, 37, 39, 42,
+        44, 47, 46, 46, 46, 47, 47, 48, 50, 51, 53, 54, 55, 58, 59, 60, 61, 63,
+        64, 65, 66, 67, 68, 69, 30, 31, 31, 32, 35, 37, 40, 42, 44, 46, 45, 45,
+        45, 46, 46, 47, 49, 50, 52, 53, 54, 57, 58, 58, 60, 61, 62, 63, 63, 64,
+        65, 66, 33, 34, 35, 35, 39, 41, 43, 45, 46, 47, 46, 46, 45, 46, 47, 47,
+        49, 49, 51, 53, 53, 56, 57, 57, 59, 60, 61, 62, 63, 64, 65, 66, 35, 36,
+        37, 37, 41, 43, 45, 46, 46, 47, 46, 46, 45, 46, 46, 47, 48, 49, 50, 52,
+        53, 55, 56, 56, 58, 59, 60, 61, 62, 63, 64, 64, 36, 38, 39, 40, 43, 45,
+        47, 47, 47, 48, 46, 46, 45, 46, 46, 47, 48, 48, 50, 51, 52, 54, 55, 55,
+        57, 58, 58, 59, 61, 62, 63, 64, 41, 42, 42, 42, 45, 46, 47, 48, 49, 50,
+        49, 49, 49, 50, 50, 50, 51, 52, 53, 54, 55, 57, 58, 58, 60, 60, 59, 59,
+        60, 61, 61, 62, 44, 44, 44, 44, 46, 46, 47, 49, 50, 51, 51, 51, 51, 51,
+        51, 52, 53, 53, 54, 56, 56, 59, 59, 59, 61, 61, 61, 62, 63, 62, 62, 62,
+        49, 47, 47, 46, 47, 47, 48, 50, 51, 53, 53, 53, 53, 54, 54, 54, 55, 55,
+        56, 58, 58, 60, 61, 61, 63, 63, 64, 63, 63, 64, 65, 66, 48, 47, 46, 45,
+        46, 46, 46, 49, 51, 53, 54, 54, 55, 56, 56, 57, 58, 59, 60, 61, 61, 63,
+        64, 64, 65, 65, 64, 65, 66, 66, 66, 66, 48, 47, 46, 45, 46, 46, 46, 49,
+        51, 53, 54, 55, 56, 57, 57, 58, 59, 60, 61, 62, 63, 65, 65, 65, 66, 67,
+        68, 67, 67, 67, 68, 69, 49, 47, 46, 45, 45, 45, 45, 49, 51, 53, 55, 56,
+        58, 59, 60, 61, 62, 62, 63, 65, 65, 67, 68, 68, 69, 70, 69, 69, 69, 70,
+        69, 69, 50, 48, 47, 46, 46, 46, 46, 50, 51, 54, 56, 57, 59, 61, 62, 63,
+        64, 65, 66, 68, 68, 70, 71, 71, 72, 71, 71, 72, 71, 71, 71, 72, 51, 48,
+        47, 46, 47, 46, 46, 50, 51, 54, 56, 57, 60, 62, 62, 64, 65, 66, 67, 69,
+        69, 71, 72, 72, 73, 74, 74, 72, 73, 74, 73, 73, 52, 50, 48, 47, 47, 47,
+        47, 50, 52, 54, 57, 58, 61, 63, 64, 66, 68, 68, 70, 72, 72, 75, 75, 75,
+        77, 76, 75, 76, 76, 74, 75, 76, 54, 51, 50, 49, 49, 48, 48, 51, 53, 55,
+        58, 59, 62, 64, 65, 68, 70, 70, 73, 74, 75, 77, 78, 78, 79, 78, 79, 78,
+        77, 78, 77, 77, 55, 52, 51, 50, 49, 49, 48, 52, 53, 55, 59, 60, 62, 65,
+        66, 68, 70, 71, 73, 75, 76, 78, 79, 79, 80, 81, 80, 80, 81, 79, 79, 81,
+        57, 54, 53, 52, 51, 50, 50, 53, 54, 56, 60, 61, 63, 66, 67, 70, 73, 73,
+        76, 78, 79, 82, 82, 83, 84, 83, 83, 83, 82, 83, 82, 81, 59, 56, 54, 53,
+        53, 52, 51, 54, 56, 58, 61, 62, 65, 68, 69, 72, 74, 75, 78, 80, 81, 84,
+        85, 85, 86, 86, 86, 84, 85, 84, 84, 85, 60, 57, 55, 54, 53, 53, 52, 55,
+        56, 58, 61, 63, 65, 68, 69, 72, 75, 76, 79, 81, 82, 85, 86, 86, 88, 88,
+        87, 88, 86, 87, 87, 85, 63, 60, 58, 57, 56, 55, 54, 57, 59, 60, 63, 65,
+        67, 70, 71, 75, 77, 78, 82, 84, 85, 89, 89, 90, 92, 89, 91, 89, 90, 89,
+        88, 89, 64, 61, 59, 58, 57, 56, 55, 58, 59, 61, 64, 65, 68, 71, 72, 75,
+        78, 79, 82, 85, 86, 89, 90, 91, 93, 94, 92, 92, 91, 91, 92, 90, 65, 61,
+        60, 58, 57, 56, 55, 58, 59, 61, 64, 65, 68, 71, 72, 75, 78, 79, 83, 85,
+        86, 90, 91, 91, 93, 94, 95, 94, 94, 94, 93, 94, 67, 63, 61, 60, 59, 58,
+        57, 60, 61, 63, 65, 66, 69, 72, 73, 77, 79, 80, 84, 86, 88, 92, 93, 93,
+        95, 95, 96, 97, 96, 95, 96, 94, 68, 64, 63, 61, 60, 59, 58, 60, 61, 63,
+        65, 67, 70, 71, 74, 76, 78, 81, 83, 86, 88, 89, 94, 94, 95, 97, 97, 98,
+        99, 99, 97, 99, 68, 65, 64, 62, 61, 60, 58, 59, 61, 64, 64, 68, 69, 71,
+        74, 75, 79, 80, 83, 86, 87, 91, 92, 95, 96, 97, 99, 99, 100, 100, 101,
+        99, 69, 66, 65, 63, 62, 61, 59, 59, 62, 63, 65, 67, 69, 72, 72, 76, 78,
+        80, 83, 84, 88, 89, 92, 94, 97, 98, 99, 101, 100, 102, 102, 104, 70, 67,
+        66, 63, 63, 62, 61, 60, 63, 63, 66, 67, 69, 71, 73, 76, 77, 81, 82, 85,
+        86, 90, 91, 94, 96, 99, 100, 100, 103, 102, 104, 104, 71, 67, 67, 64,
+        64, 63, 62, 61, 62, 64, 66, 67, 70, 71, 74, 74, 78, 79, 83, 84, 87, 89,
+        91, 94, 95, 99, 100, 102, 102, 104, 104, 106, 72, 68, 68, 65, 65, 64,
+        63, 61, 62, 65, 66, 68, 69, 71, 73, 75, 77, 79, 82, 84, 87, 88, 92, 93,
+        96, 97, 101, 102, 104, 104, 106, 106, 73, 69, 69, 66, 66, 64, 64, 62,
+        62, 66, 66, 69, 69, 72, 73, 76, 77, 81, 81, 85, 85, 89, 90, 94, 94, 99,
+        99, 104, 104, 106, 106, 108,
         /* Size 4x8 */
-        63, 94, 109, 133, 76, 93, 101, 123, 93, 107, 114, 129, 93, 113, 133,
-        150, 100, 118, 148, 160, 115, 128, 164, 178, 124, 132, 173, 198, 133,
-        134, 162, 196,
+        31, 47, 54, 64, 38, 46, 50, 60, 46, 53, 57, 62, 46, 56, 66, 71, 50, 59,
+        74, 79, 57, 64, 82, 88, 61, 65, 85, 97, 65, 67, 82, 99,
         /* Size 8x4 */
-        63, 76, 93, 93, 100, 115, 124, 133, 94, 93, 107, 113, 118, 128, 132,
-        134, 109, 101, 114, 133, 148, 164, 173, 162, 133, 123, 129, 150, 160,
-        178, 198, 196,
+        31, 38, 46, 46, 50, 57, 61, 65, 47, 46, 53, 56, 59, 64, 65, 67, 54, 50,
+        57, 66, 74, 82, 85, 82, 64, 60, 62, 71, 79, 88, 97, 99,
         /* Size 8x16 */
-        64, 68, 96, 98, 109, 127, 135, 145, 62, 72, 93, 92, 101, 117, 125, 134,
-        67, 80, 94, 92, 98, 112, 119, 128, 74, 88, 95, 91, 96, 109, 115, 122,
-        89, 92, 102, 102, 106, 118, 121, 132, 97, 93, 106, 112, 117, 128, 131,
-        139, 98, 91, 107, 117, 125, 135, 142, 148, 102, 94, 108, 120, 131, 143,
-        148, 158, 108, 98, 111, 124, 140, 155, 155, 164, 114, 102, 113, 128,
-        146, 164, 168, 172, 120, 107, 117, 131, 150, 170, 181, 176, 128, 114,
-        122, 136, 156, 179, 188, 184, 133, 118, 126, 139, 159, 183, 189, 188,
-        139, 123, 129, 143, 157, 173, 194, 195, 144, 128, 132, 149, 171, 190,
-        199, 198, 149, 133, 134, 150, 169, 190, 213, 216,
+        32, 34, 48, 49, 54, 63, 67, 69, 31, 36, 46, 46, 50, 58, 62, 65, 33, 40,
+        47, 46, 49, 56, 59, 62, 37, 44, 47, 45, 48, 54, 57, 60, 44, 46, 51, 51,
+        53, 59, 60, 61, 48, 46, 53, 56, 58, 64, 64, 64, 49, 45, 53, 58, 62, 67,
+        70, 68, 51, 47, 54, 60, 65, 71, 73, 72, 54, 49, 55, 62, 70, 77, 77, 76,
+        57, 51, 56, 64, 73, 82, 83, 81, 60, 53, 58, 65, 75, 85, 89, 85, 64, 57,
+        61, 68, 78, 89, 93, 89, 66, 59, 63, 69, 79, 91, 94, 93, 68, 61, 63, 71,
+        79, 87, 96, 98, 70, 63, 63, 70, 80, 89, 97, 100, 72, 65, 63, 69, 77, 86,
+        95, 102,
         /* Size 16x8 */
-        64, 62, 67, 74, 89, 97, 98, 102, 108, 114, 120, 128, 133, 139, 144, 149,
-        68, 72, 80, 88, 92, 93, 91, 94, 98, 102, 107, 114, 118, 123, 128, 133,
-        96, 93, 94, 95, 102, 106, 107, 108, 111, 113, 117, 122, 126, 129, 132,
-        134, 98, 92, 92, 91, 102, 112, 117, 120, 124, 128, 131, 136, 139, 143,
-        149, 150, 109, 101, 98, 96, 106, 117, 125, 131, 140, 146, 150, 156, 159,
-        157, 171, 169, 127, 117, 112, 109, 118, 128, 135, 143, 155, 164, 170,
-        179, 183, 173, 190, 190, 135, 125, 119, 115, 121, 131, 142, 148, 155,
-        168, 181, 188, 189, 194, 199, 213, 145, 134, 128, 122, 132, 139, 148,
-        158, 164, 172, 176, 184, 188, 195, 198, 216,
+        32, 31, 33, 37, 44, 48, 49, 51, 54, 57, 60, 64, 66, 68, 70, 72, 34, 36,
+        40, 44, 46, 46, 45, 47, 49, 51, 53, 57, 59, 61, 63, 65, 48, 46, 47, 47,
+        51, 53, 53, 54, 55, 56, 58, 61, 63, 63, 63, 63, 49, 46, 46, 45, 51, 56,
+        58, 60, 62, 64, 65, 68, 69, 71, 70, 69, 54, 50, 49, 48, 53, 58, 62, 65,
+        70, 73, 75, 78, 79, 79, 80, 77, 63, 58, 56, 54, 59, 64, 67, 71, 77, 82,
+        85, 89, 91, 87, 89, 86, 67, 62, 59, 57, 60, 64, 70, 73, 77, 83, 89, 93,
+        94, 96, 97, 95, 69, 65, 62, 60, 61, 64, 68, 72, 76, 81, 85, 89, 93, 98,
+        100, 102,
         /* Size 16x32 */
-        64, 62, 68, 74, 96, 97, 98, 105, 109, 115, 127, 129, 135, 140, 145, 149,
-        63, 63, 71, 77, 94, 94, 94, 100, 103, 109, 120, 122, 128, 133, 137, 140,
-        62, 64, 72, 79, 93, 92, 92, 97, 101, 106, 117, 119, 125, 130, 134, 141,
-        61, 64, 73, 80, 92, 91, 91, 96, 99, 104, 115, 116, 122, 126, 130, 132,
-        67, 72, 80, 86, 94, 93, 92, 95, 98, 103, 112, 114, 119, 124, 128, 135,
-        71, 76, 84, 90, 95, 93, 91, 95, 97, 101, 111, 112, 118, 123, 127, 129,
-        74, 80, 88, 94, 95, 93, 91, 94, 96, 100, 109, 110, 115, 117, 122, 131,
-        84, 86, 91, 95, 100, 100, 99, 101, 103, 107, 115, 117, 121, 120, 122,
-        121, 89, 89, 92, 95, 102, 102, 102, 104, 106, 109, 118, 119, 121, 127,
-        132, 126, 98, 93, 95, 96, 106, 107, 107, 109, 111, 114, 121, 122, 128,
-        129, 128, 141, 97, 92, 93, 94, 106, 109, 112, 115, 117, 120, 128, 129,
-        131, 130, 139, 131, 97, 91, 92, 93, 106, 110, 113, 117, 119, 122, 130,
-        131, 133, 139, 133, 147, 98, 91, 91, 92, 107, 112, 117, 123, 125, 128,
-        135, 136, 142, 136, 148, 136, 101, 93, 93, 93, 108, 113, 119, 127, 130,
-        133, 141, 142, 142, 150, 139, 156, 102, 94, 94, 94, 108, 114, 120, 129,
-        131, 136, 143, 144, 148, 145, 158, 141, 104, 96, 95, 95, 109, 115, 122,
-        133, 137, 142, 150, 151, 156, 154, 147, 167, 108, 99, 98, 97, 111, 117,
-        124, 136, 140, 146, 155, 156, 155, 159, 164, 148, 109, 100, 99, 98, 111,
-        118, 125, 137, 141, 148, 157, 158, 164, 160, 158, 176, 114, 104, 102,
-        101, 113, 120, 128, 141, 146, 153, 164, 165, 168, 172, 172, 155, 118,
-        108, 105, 104, 116, 123, 130, 144, 149, 157, 168, 170, 171, 165, 170,
-        190, 120, 109, 107, 105, 117, 124, 131, 145, 150, 158, 170, 172, 181,
-        185, 176, 163, 127, 115, 112, 110, 121, 128, 135, 150, 155, 164, 178,
-        180, 181, 178, 185, 196, 128, 117, 114, 111, 122, 129, 136, 151, 156,
-        165, 179, 181, 188, 187, 184, 171, 129, 118, 114, 112, 123, 130, 136,
-        151, 157, 166, 180, 182, 189, 195, 196, 213, 133, 122, 118, 115, 126,
-        132, 139, 154, 159, 169, 183, 186, 189, 193, 188, 180, 136, 124, 120,
-        117, 129, 132, 140, 154, 155, 173, 181, 186, 195, 198, 216, 218, 139,
-        126, 123, 119, 129, 129, 143, 152, 157, 176, 173, 196, 194, 193, 195,
-        189, 141, 128, 125, 121, 130, 131, 149, 145, 162, 174, 175, 198, 191,
-        206, 207, 239, 144, 131, 128, 123, 132, 133, 149, 145, 171, 160, 190,
-        187, 199, 205, 198, 199, 146, 133, 130, 125, 133, 134, 149, 146, 170,
-        162, 192, 178, 216, 196, 216, 216, 149, 136, 133, 127, 134, 136, 150,
-        148, 169, 163, 190, 180, 213, 199, 216, 202, 152, 136, 138, 126, 129,
-        148, 138, 167, 149, 190, 165, 213, 182, 237, 201, 228,
+        32, 31, 34, 37, 48, 48, 49, 52, 54, 57, 63, 64, 67, 68, 69, 69, 31, 31,
+        35, 38, 47, 47, 47, 50, 51, 54, 60, 61, 63, 64, 65, 66, 31, 32, 36, 39,
+        46, 46, 46, 48, 50, 53, 58, 59, 62, 63, 65, 66, 30, 32, 36, 40, 46, 45,
+        45, 48, 49, 52, 57, 58, 60, 61, 62, 63, 33, 36, 40, 43, 47, 46, 46, 47,
+        49, 51, 56, 57, 59, 60, 62, 63, 35, 38, 42, 45, 47, 46, 45, 47, 48, 50,
+        55, 56, 58, 60, 61, 61, 37, 40, 44, 47, 47, 46, 45, 47, 48, 50, 54, 55,
+        57, 58, 60, 61, 42, 43, 45, 47, 50, 50, 49, 50, 51, 53, 57, 58, 59, 58,
+        59, 59, 44, 44, 46, 47, 51, 51, 51, 52, 53, 54, 59, 59, 60, 61, 61, 60,
+        49, 46, 47, 48, 53, 53, 53, 54, 55, 57, 60, 61, 63, 62, 62, 63, 48, 46,
+        46, 47, 53, 54, 56, 57, 58, 60, 64, 64, 64, 64, 64, 63, 48, 45, 46, 46,
+        53, 55, 56, 58, 59, 61, 65, 65, 66, 66, 65, 66, 49, 45, 45, 46, 53, 56,
+        58, 61, 62, 64, 67, 68, 70, 67, 68, 66, 50, 46, 46, 46, 54, 56, 59, 63,
+        65, 66, 70, 71, 70, 71, 68, 70, 51, 47, 47, 47, 54, 57, 60, 64, 65, 68,
+        71, 72, 73, 71, 72, 70, 52, 48, 47, 47, 54, 57, 61, 66, 68, 71, 75, 75,
+        76, 75, 73, 73, 54, 49, 49, 48, 55, 58, 62, 68, 70, 73, 77, 78, 77, 77,
+        76, 74, 54, 50, 49, 49, 55, 59, 62, 68, 70, 74, 78, 79, 81, 79, 77, 78,
+        57, 52, 51, 50, 56, 60, 64, 70, 73, 76, 82, 82, 83, 82, 81, 78, 59, 54,
+        52, 52, 58, 61, 65, 72, 74, 78, 84, 85, 85, 83, 82, 82, 60, 54, 53, 52,
+        58, 62, 65, 72, 75, 79, 85, 86, 89, 87, 85, 82, 63, 57, 56, 55, 60, 64,
+        67, 75, 77, 82, 89, 90, 90, 88, 87, 86, 64, 58, 57, 55, 61, 64, 68, 75,
+        78, 82, 89, 90, 93, 91, 89, 87, 64, 59, 57, 56, 61, 65, 68, 75, 78, 83,
+        90, 91, 94, 93, 92, 91, 66, 60, 59, 57, 63, 66, 69, 77, 79, 84, 91, 93,
+        94, 95, 93, 91, 67, 61, 60, 58, 63, 65, 70, 75, 78, 85, 88, 93, 96, 97,
+        97, 95, 68, 62, 61, 59, 63, 64, 71, 74, 79, 84, 87, 94, 96, 97, 98, 96,
+        69, 63, 62, 60, 63, 65, 71, 72, 80, 82, 88, 93, 96, 99, 100, 101, 70,
+        64, 63, 60, 63, 66, 70, 73, 80, 81, 89, 90, 97, 99, 100, 101, 71, 65,
+        64, 61, 63, 67, 70, 74, 78, 82, 88, 90, 97, 99, 102, 103, 72, 65, 65,
+        62, 63, 68, 69, 75, 77, 83, 86, 92, 95, 100, 102, 103, 73, 66, 66, 63,
+        63, 69, 69, 76, 76, 84, 84, 93, 93, 101, 101, 105,
         /* Size 32x16 */
-        64, 63, 62, 61, 67, 71, 74, 84, 89, 98, 97, 97, 98, 101, 102, 104, 108,
-        109, 114, 118, 120, 127, 128, 129, 133, 136, 139, 141, 144, 146, 149,
-        152, 62, 63, 64, 64, 72, 76, 80, 86, 89, 93, 92, 91, 91, 93, 94, 96, 99,
-        100, 104, 108, 109, 115, 117, 118, 122, 124, 126, 128, 131, 133, 136,
-        136, 68, 71, 72, 73, 80, 84, 88, 91, 92, 95, 93, 92, 91, 93, 94, 95, 98,
-        99, 102, 105, 107, 112, 114, 114, 118, 120, 123, 125, 128, 130, 133,
-        138, 74, 77, 79, 80, 86, 90, 94, 95, 95, 96, 94, 93, 92, 93, 94, 95, 97,
-        98, 101, 104, 105, 110, 111, 112, 115, 117, 119, 121, 123, 125, 127,
-        126, 96, 94, 93, 92, 94, 95, 95, 100, 102, 106, 106, 106, 107, 108, 108,
-        109, 111, 111, 113, 116, 117, 121, 122, 123, 126, 129, 129, 130, 132,
-        133, 134, 129, 97, 94, 92, 91, 93, 93, 93, 100, 102, 107, 109, 110, 112,
-        113, 114, 115, 117, 118, 120, 123, 124, 128, 129, 130, 132, 132, 129,
-        131, 133, 134, 136, 148, 98, 94, 92, 91, 92, 91, 91, 99, 102, 107, 112,
-        113, 117, 119, 120, 122, 124, 125, 128, 130, 131, 135, 136, 136, 139,
-        140, 143, 149, 149, 149, 150, 138, 105, 100, 97, 96, 95, 95, 94, 101,
-        104, 109, 115, 117, 123, 127, 129, 133, 136, 137, 141, 144, 145, 150,
-        151, 151, 154, 154, 152, 145, 145, 146, 148, 167, 109, 103, 101, 99, 98,
-        97, 96, 103, 106, 111, 117, 119, 125, 130, 131, 137, 140, 141, 146, 149,
-        150, 155, 156, 157, 159, 155, 157, 162, 171, 170, 169, 149, 115, 109,
-        106, 104, 103, 101, 100, 107, 109, 114, 120, 122, 128, 133, 136, 142,
-        146, 148, 153, 157, 158, 164, 165, 166, 169, 173, 176, 174, 160, 162,
-        163, 190, 127, 120, 117, 115, 112, 111, 109, 115, 118, 121, 128, 130,
-        135, 141, 143, 150, 155, 157, 164, 168, 170, 178, 179, 180, 183, 181,
-        173, 175, 190, 192, 190, 165, 129, 122, 119, 116, 114, 112, 110, 117,
-        119, 122, 129, 131, 136, 142, 144, 151, 156, 158, 165, 170, 172, 180,
-        181, 182, 186, 186, 196, 198, 187, 178, 180, 213, 135, 128, 125, 122,
-        119, 118, 115, 121, 121, 128, 131, 133, 142, 142, 148, 156, 155, 164,
-        168, 171, 181, 181, 188, 189, 189, 195, 194, 191, 199, 216, 213, 182,
-        140, 133, 130, 126, 124, 123, 117, 120, 127, 129, 130, 139, 136, 150,
-        145, 154, 159, 160, 172, 165, 185, 178, 187, 195, 193, 198, 193, 206,
-        205, 196, 199, 237, 145, 137, 134, 130, 128, 127, 122, 122, 132, 128,
-        139, 133, 148, 139, 158, 147, 164, 158, 172, 170, 176, 185, 184, 196,
-        188, 216, 195, 207, 198, 216, 216, 201, 149, 140, 141, 132, 135, 129,
-        131, 121, 126, 141, 131, 147, 136, 156, 141, 167, 148, 176, 155, 190,
-        163, 196, 171, 213, 180, 218, 189, 239, 199, 216, 202, 228,
+        32, 31, 31, 30, 33, 35, 37, 42, 44, 49, 48, 48, 49, 50, 51, 52, 54, 54,
+        57, 59, 60, 63, 64, 64, 66, 67, 68, 69, 70, 71, 72, 73, 31, 31, 32, 32,
+        36, 38, 40, 43, 44, 46, 46, 45, 45, 46, 47, 48, 49, 50, 52, 54, 54, 57,
+        58, 59, 60, 61, 62, 63, 64, 65, 65, 66, 34, 35, 36, 36, 40, 42, 44, 45,
+        46, 47, 46, 46, 45, 46, 47, 47, 49, 49, 51, 52, 53, 56, 57, 57, 59, 60,
+        61, 62, 63, 64, 65, 66, 37, 38, 39, 40, 43, 45, 47, 47, 47, 48, 47, 46,
+        46, 46, 47, 47, 48, 49, 50, 52, 52, 55, 55, 56, 57, 58, 59, 60, 60, 61,
+        62, 63, 48, 47, 46, 46, 47, 47, 47, 50, 51, 53, 53, 53, 53, 54, 54, 54,
+        55, 55, 56, 58, 58, 60, 61, 61, 63, 63, 63, 63, 63, 63, 63, 63, 48, 47,
+        46, 45, 46, 46, 46, 50, 51, 53, 54, 55, 56, 56, 57, 57, 58, 59, 60, 61,
+        62, 64, 64, 65, 66, 65, 64, 65, 66, 67, 68, 69, 49, 47, 46, 45, 46, 45,
+        45, 49, 51, 53, 56, 56, 58, 59, 60, 61, 62, 62, 64, 65, 65, 67, 68, 68,
+        69, 70, 71, 71, 70, 70, 69, 69, 52, 50, 48, 48, 47, 47, 47, 50, 52, 54,
+        57, 58, 61, 63, 64, 66, 68, 68, 70, 72, 72, 75, 75, 75, 77, 75, 74, 72,
+        73, 74, 75, 76, 54, 51, 50, 49, 49, 48, 48, 51, 53, 55, 58, 59, 62, 65,
+        65, 68, 70, 70, 73, 74, 75, 77, 78, 78, 79, 78, 79, 80, 80, 78, 77, 76,
+        57, 54, 53, 52, 51, 50, 50, 53, 54, 57, 60, 61, 64, 66, 68, 71, 73, 74,
+        76, 78, 79, 82, 82, 83, 84, 85, 84, 82, 81, 82, 83, 84, 63, 60, 58, 57,
+        56, 55, 54, 57, 59, 60, 64, 65, 67, 70, 71, 75, 77, 78, 82, 84, 85, 89,
+        89, 90, 91, 88, 87, 88, 89, 88, 86, 84, 64, 61, 59, 58, 57, 56, 55, 58,
+        59, 61, 64, 65, 68, 71, 72, 75, 78, 79, 82, 85, 86, 90, 90, 91, 93, 93,
+        94, 93, 90, 90, 92, 93, 67, 63, 62, 60, 59, 58, 57, 59, 60, 63, 64, 66,
+        70, 70, 73, 76, 77, 81, 83, 85, 89, 90, 93, 94, 94, 96, 96, 96, 97, 97,
+        95, 93, 68, 64, 63, 61, 60, 60, 58, 58, 61, 62, 64, 66, 67, 71, 71, 75,
+        77, 79, 82, 83, 87, 88, 91, 93, 95, 97, 97, 99, 99, 99, 100, 101, 69,
+        65, 65, 62, 62, 61, 60, 59, 61, 62, 64, 65, 68, 68, 72, 73, 76, 77, 81,
+        82, 85, 87, 89, 92, 93, 97, 98, 100, 100, 102, 102, 101, 69, 66, 66, 63,
+        63, 61, 61, 59, 60, 63, 63, 66, 66, 70, 70, 73, 74, 78, 78, 82, 82, 86,
+        87, 91, 91, 95, 96, 101, 101, 103, 103, 105,
         /* Size 4x16 */
-        62, 97, 115, 140, 64, 92, 106, 130, 72, 93, 103, 124, 80, 93, 100, 117,
-        89, 102, 109, 127, 92, 109, 120, 130, 91, 112, 128, 136, 94, 114, 136,
-        145, 99, 117, 146, 159, 104, 120, 153, 172, 109, 124, 158, 185, 117,
-        129, 165, 187, 122, 132, 169, 193, 126, 129, 176, 193, 131, 133, 160,
-        205, 136, 136, 163, 199,
+        31, 48, 57, 68, 32, 46, 53, 63, 36, 46, 51, 60, 40, 46, 50, 58, 44, 51,
+        54, 61, 46, 54, 60, 64, 45, 56, 64, 67, 47, 57, 68, 71, 49, 58, 73, 77,
+        52, 60, 76, 82, 54, 62, 79, 87, 58, 64, 82, 91, 60, 66, 84, 95, 62, 64,
+        84, 97, 64, 66, 81, 99, 65, 68, 83, 100,
         /* Size 16x4 */
-        62, 64, 72, 80, 89, 92, 91, 94, 99, 104, 109, 117, 122, 126, 131, 136,
-        97, 92, 93, 93, 102, 109, 112, 114, 117, 120, 124, 129, 132, 129, 133,
-        136, 115, 106, 103, 100, 109, 120, 128, 136, 146, 153, 158, 165, 169,
-        176, 160, 163, 140, 130, 124, 117, 127, 130, 136, 145, 159, 172, 185,
-        187, 193, 193, 205, 199,
+        31, 32, 36, 40, 44, 46, 45, 47, 49, 52, 54, 58, 60, 62, 64, 65, 48, 46,
+        46, 46, 51, 54, 56, 57, 58, 60, 62, 64, 66, 64, 66, 68, 57, 53, 51, 50,
+        54, 60, 64, 68, 73, 76, 79, 82, 84, 84, 81, 83, 68, 63, 60, 58, 61, 64,
+        67, 71, 77, 82, 87, 91, 95, 97, 99, 100,
         /* Size 8x32 */
-        64, 68, 96, 98, 109, 127, 135, 145, 63, 71, 94, 94, 103, 120, 128, 137,
-        62, 72, 93, 92, 101, 117, 125, 134, 61, 73, 92, 91, 99, 115, 122, 130,
-        67, 80, 94, 92, 98, 112, 119, 128, 71, 84, 95, 91, 97, 111, 118, 127,
-        74, 88, 95, 91, 96, 109, 115, 122, 84, 91, 100, 99, 103, 115, 121, 122,
-        89, 92, 102, 102, 106, 118, 121, 132, 98, 95, 106, 107, 111, 121, 128,
-        128, 97, 93, 106, 112, 117, 128, 131, 139, 97, 92, 106, 113, 119, 130,
-        133, 133, 98, 91, 107, 117, 125, 135, 142, 148, 101, 93, 108, 119, 130,
-        141, 142, 139, 102, 94, 108, 120, 131, 143, 148, 158, 104, 95, 109, 122,
-        137, 150, 156, 147, 108, 98, 111, 124, 140, 155, 155, 164, 109, 99, 111,
-        125, 141, 157, 164, 158, 114, 102, 113, 128, 146, 164, 168, 172, 118,
-        105, 116, 130, 149, 168, 171, 170, 120, 107, 117, 131, 150, 170, 181,
-        176, 127, 112, 121, 135, 155, 178, 181, 185, 128, 114, 122, 136, 156,
-        179, 188, 184, 129, 114, 123, 136, 157, 180, 189, 196, 133, 118, 126,
-        139, 159, 183, 189, 188, 136, 120, 129, 140, 155, 181, 195, 216, 139,
-        123, 129, 143, 157, 173, 194, 195, 141, 125, 130, 149, 162, 175, 191,
-        207, 144, 128, 132, 149, 171, 190, 199, 198, 146, 130, 133, 149, 170,
-        192, 216, 216, 149, 133, 134, 150, 169, 190, 213, 216, 152, 138, 129,
-        138, 149, 165, 182, 201,
+        32, 34, 48, 49, 54, 63, 67, 69, 31, 35, 47, 47, 51, 60, 63, 65, 31, 36,
+        46, 46, 50, 58, 62, 65, 30, 36, 46, 45, 49, 57, 60, 62, 33, 40, 47, 46,
+        49, 56, 59, 62, 35, 42, 47, 45, 48, 55, 58, 61, 37, 44, 47, 45, 48, 54,
+        57, 60, 42, 45, 50, 49, 51, 57, 59, 59, 44, 46, 51, 51, 53, 59, 60, 61,
+        49, 47, 53, 53, 55, 60, 63, 62, 48, 46, 53, 56, 58, 64, 64, 64, 48, 46,
+        53, 56, 59, 65, 66, 65, 49, 45, 53, 58, 62, 67, 70, 68, 50, 46, 54, 59,
+        65, 70, 70, 68, 51, 47, 54, 60, 65, 71, 73, 72, 52, 47, 54, 61, 68, 75,
+        76, 73, 54, 49, 55, 62, 70, 77, 77, 76, 54, 49, 55, 62, 70, 78, 81, 77,
+        57, 51, 56, 64, 73, 82, 83, 81, 59, 52, 58, 65, 74, 84, 85, 82, 60, 53,
+        58, 65, 75, 85, 89, 85, 63, 56, 60, 67, 77, 89, 90, 87, 64, 57, 61, 68,
+        78, 89, 93, 89, 64, 57, 61, 68, 78, 90, 94, 92, 66, 59, 63, 69, 79, 91,
+        94, 93, 67, 60, 63, 70, 78, 88, 96, 97, 68, 61, 63, 71, 79, 87, 96, 98,
+        69, 62, 63, 71, 80, 88, 96, 100, 70, 63, 63, 70, 80, 89, 97, 100, 71,
+        64, 63, 70, 78, 88, 97, 102, 72, 65, 63, 69, 77, 86, 95, 102, 73, 66,
+        63, 69, 76, 84, 93, 101,
         /* Size 32x8 */
-        64, 63, 62, 61, 67, 71, 74, 84, 89, 98, 97, 97, 98, 101, 102, 104, 108,
-        109, 114, 118, 120, 127, 128, 129, 133, 136, 139, 141, 144, 146, 149,
-        152, 68, 71, 72, 73, 80, 84, 88, 91, 92, 95, 93, 92, 91, 93, 94, 95, 98,
-        99, 102, 105, 107, 112, 114, 114, 118, 120, 123, 125, 128, 130, 133,
-        138, 96, 94, 93, 92, 94, 95, 95, 100, 102, 106, 106, 106, 107, 108, 108,
-        109, 111, 111, 113, 116, 117, 121, 122, 123, 126, 129, 129, 130, 132,
-        133, 134, 129, 98, 94, 92, 91, 92, 91, 91, 99, 102, 107, 112, 113, 117,
-        119, 120, 122, 124, 125, 128, 130, 131, 135, 136, 136, 139, 140, 143,
-        149, 149, 149, 150, 138, 109, 103, 101, 99, 98, 97, 96, 103, 106, 111,
-        117, 119, 125, 130, 131, 137, 140, 141, 146, 149, 150, 155, 156, 157,
-        159, 155, 157, 162, 171, 170, 169, 149, 127, 120, 117, 115, 112, 111,
-        109, 115, 118, 121, 128, 130, 135, 141, 143, 150, 155, 157, 164, 168,
-        170, 178, 179, 180, 183, 181, 173, 175, 190, 192, 190, 165, 135, 128,
-        125, 122, 119, 118, 115, 121, 121, 128, 131, 133, 142, 142, 148, 156,
-        155, 164, 168, 171, 181, 181, 188, 189, 189, 195, 194, 191, 199, 216,
-        213, 182, 145, 137, 134, 130, 128, 127, 122, 122, 132, 128, 139, 133,
-        148, 139, 158, 147, 164, 158, 172, 170, 176, 185, 184, 196, 188, 216,
-        195, 207, 198, 216, 216, 201 },
+        32, 31, 31, 30, 33, 35, 37, 42, 44, 49, 48, 48, 49, 50, 51, 52, 54, 54,
+        57, 59, 60, 63, 64, 64, 66, 67, 68, 69, 70, 71, 72, 73, 34, 35, 36, 36,
+        40, 42, 44, 45, 46, 47, 46, 46, 45, 46, 47, 47, 49, 49, 51, 52, 53, 56,
+        57, 57, 59, 60, 61, 62, 63, 64, 65, 66, 48, 47, 46, 46, 47, 47, 47, 50,
+        51, 53, 53, 53, 53, 54, 54, 54, 55, 55, 56, 58, 58, 60, 61, 61, 63, 63,
+        63, 63, 63, 63, 63, 63, 49, 47, 46, 45, 46, 45, 45, 49, 51, 53, 56, 56,
+        58, 59, 60, 61, 62, 62, 64, 65, 65, 67, 68, 68, 69, 70, 71, 71, 70, 70,
+        69, 69, 54, 51, 50, 49, 49, 48, 48, 51, 53, 55, 58, 59, 62, 65, 65, 68,
+        70, 70, 73, 74, 75, 77, 78, 78, 79, 78, 79, 80, 80, 78, 77, 76, 63, 60,
+        58, 57, 56, 55, 54, 57, 59, 60, 64, 65, 67, 70, 71, 75, 77, 78, 82, 84,
+        85, 89, 89, 90, 91, 88, 87, 88, 89, 88, 86, 84, 67, 63, 62, 60, 59, 58,
+        57, 59, 60, 63, 64, 66, 70, 70, 73, 76, 77, 81, 83, 85, 89, 90, 93, 94,
+        94, 96, 96, 96, 97, 97, 95, 93, 69, 65, 65, 62, 62, 61, 60, 59, 61, 62,
+        64, 65, 68, 68, 72, 73, 76, 77, 81, 82, 85, 87, 89, 92, 93, 97, 98, 100,
+        100, 102, 102, 101 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        73, 142, 142, 268,
+        36, 71, 71, 134,
 #endif
         /* Size 4x4 */
-        65, 75, 117, 164, 75, 108, 145, 184, 117, 145, 204, 238, 164, 184, 238,
-        313,
+        32, 37, 58, 81, 37, 54, 72, 91, 58, 72, 102, 121, 81, 91, 121, 156,
         /* Size 8x8 */
-        64, 64, 70, 85, 107, 136, 157, 183, 64, 67, 72, 84, 103, 129, 148, 171,
-        70, 72, 92, 105, 121, 144, 160, 174, 85, 84, 105, 127, 146, 169, 185,
-        193, 107, 103, 121, 146, 172, 200, 218, 226, 136, 129, 144, 169, 200,
-        235, 256, 273, 157, 148, 160, 185, 218, 256, 280, 329, 183, 171, 174,
-        193, 226, 273, 329, 338,
+        32, 32, 35, 42, 53, 68, 78, 90, 32, 33, 36, 42, 51, 64, 74, 84, 35, 36,
+        46, 52, 60, 72, 80, 87, 42, 42, 52, 63, 73, 84, 92, 98, 53, 51, 60, 73,
+        86, 100, 109, 114, 68, 64, 72, 84, 100, 117, 128, 133, 78, 74, 80, 92,
+        109, 128, 140, 155, 90, 84, 87, 98, 114, 133, 155, 168,
         /* Size 16x16 */
-        64, 63, 63, 64, 68, 72, 82, 95, 108, 118, 131, 149, 164, 176, 187, 199,
-        63, 64, 65, 65, 68, 70, 79, 90, 101, 111, 122, 139, 153, 164, 175, 187,
-        63, 65, 66, 67, 70, 72, 80, 89, 99, 108, 119, 134, 147, 157, 167, 179,
-        64, 65, 67, 71, 74, 77, 83, 90, 99, 107, 116, 131, 143, 151, 161, 172,
-        68, 68, 70, 74, 79, 85, 92, 100, 109, 117, 126, 141, 152, 161, 172, 179,
-        72, 70, 72, 77, 85, 97, 104, 112, 120, 128, 136, 150, 161, 170, 182,
-        190, 82, 79, 80, 83, 92, 104, 114, 125, 135, 143, 151, 166, 177, 184,
-        191, 203, 95, 90, 89, 90, 100, 112, 125, 139, 151, 159, 168, 183, 194,
-        202, 200, 219, 108, 101, 99, 99, 109, 120, 135, 151, 165, 174, 185, 200,
-        212, 221, 213, 235, 118, 111, 108, 107, 117, 128, 143, 159, 174, 184,
-        196, 213, 225, 234, 228, 257, 131, 122, 119, 116, 126, 136, 151, 168,
-        185, 196, 210, 228, 241, 250, 248, 273, 149, 139, 134, 131, 141, 150,
-        166, 183, 200, 213, 228, 247, 262, 270, 274, 299, 164, 153, 147, 143,
-        152, 161, 177, 194, 212, 225, 241, 262, 278, 288, 305, 317, 176, 164,
-        157, 151, 161, 170, 184, 202, 221, 234, 250, 270, 288, 301, 308, 351,
-        187, 175, 167, 161, 172, 182, 191, 200, 213, 228, 248, 274, 305, 308,
-        325, 330, 199, 187, 179, 172, 179, 190, 203, 219, 235, 257, 273, 299,
-        317, 351, 330, 351,
+        32, 31, 31, 32, 34, 36, 41, 47, 54, 59, 65, 74, 82, 87, 92, 97, 31, 32,
+        32, 32, 34, 35, 39, 45, 50, 55, 61, 69, 76, 81, 87, 92, 31, 32, 33, 33,
+        35, 36, 40, 44, 49, 54, 59, 67, 73, 78, 83, 88, 32, 32, 33, 35, 37, 38,
+        41, 45, 49, 53, 58, 65, 71, 75, 80, 86, 34, 34, 35, 37, 39, 42, 46, 50,
+        54, 58, 63, 70, 76, 80, 84, 85, 36, 35, 36, 38, 42, 48, 52, 56, 60, 64,
+        68, 75, 80, 85, 90, 91, 41, 39, 40, 41, 46, 52, 57, 62, 67, 71, 75, 83,
+        88, 92, 95, 97, 47, 45, 44, 45, 50, 56, 62, 69, 75, 79, 84, 91, 97, 100,
+        102, 104, 54, 50, 49, 49, 54, 60, 67, 75, 82, 87, 92, 100, 106, 110,
+        109, 112, 59, 55, 54, 53, 58, 64, 71, 79, 87, 92, 98, 106, 112, 117,
+        117, 121, 65, 61, 59, 58, 63, 68, 75, 84, 92, 98, 105, 114, 120, 125,
+        126, 130, 74, 69, 67, 65, 70, 75, 83, 91, 100, 106, 114, 123, 131, 135,
+        137, 140, 82, 76, 73, 71, 76, 80, 88, 97, 106, 112, 120, 131, 139, 144,
+        148, 150, 87, 81, 78, 75, 80, 85, 92, 100, 110, 117, 125, 135, 144, 150,
+        155, 162, 92, 87, 83, 80, 84, 90, 95, 102, 109, 117, 126, 137, 148, 155,
+        162, 168, 97, 92, 88, 86, 85, 91, 97, 104, 112, 121, 130, 140, 150, 162,
+        168, 174,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 64, 65, 68, 71, 72, 79, 82, 88, 95, 97, 108,
-        112, 118, 128, 131, 143, 149, 160, 164, 166, 176, 181, 187, 193, 199,
-        206, 63, 64, 64, 64, 64, 64, 65, 66, 68, 70, 70, 77, 80, 85, 91, 93,
-        103, 107, 113, 122, 125, 136, 142, 152, 156, 157, 167, 172, 177, 183,
-        189, 194, 63, 64, 64, 64, 65, 65, 65, 66, 68, 69, 70, 76, 79, 84, 90,
-        91, 101, 105, 111, 120, 122, 134, 139, 149, 153, 154, 164, 169, 175,
-        181, 187, 195, 63, 64, 64, 65, 65, 65, 65, 66, 67, 68, 69, 75, 77, 82,
-        88, 89, 99, 102, 108, 117, 119, 130, 136, 145, 149, 150, 159, 164, 169,
-        175, 180, 183, 63, 64, 65, 65, 66, 66, 67, 68, 70, 72, 72, 78, 80, 84,
-        89, 91, 99, 103, 108, 116, 119, 129, 134, 143, 147, 148, 157, 162, 167,
-        173, 179, 186, 63, 64, 65, 65, 66, 67, 68, 69, 71, 72, 73, 78, 81, 84,
-        90, 91, 100, 103, 108, 116, 118, 129, 134, 143, 147, 148, 156, 161, 166,
-        171, 176, 180, 64, 65, 65, 65, 67, 68, 71, 72, 74, 76, 77, 81, 83, 85,
-        90, 92, 99, 102, 107, 114, 116, 126, 131, 139, 143, 144, 151, 156, 161,
-        166, 172, 181, 65, 66, 66, 66, 68, 69, 72, 73, 76, 79, 80, 84, 86, 89,
-        94, 95, 103, 106, 111, 118, 120, 130, 135, 142, 146, 147, 155, 156, 160,
-        165, 170, 171, 68, 68, 68, 67, 70, 71, 74, 76, 79, 84, 85, 90, 92, 95,
-        100, 102, 109, 112, 117, 124, 126, 136, 141, 148, 152, 153, 161, 166,
-        172, 176, 179, 175, 71, 70, 69, 68, 72, 72, 76, 79, 84, 92, 94, 99, 101,
-        105, 110, 111, 118, 121, 125, 132, 134, 144, 148, 156, 159, 160, 168,
-        170, 170, 174, 179, 195, 72, 70, 70, 69, 72, 73, 77, 80, 85, 94, 97,
-        101, 104, 108, 112, 114, 120, 123, 128, 134, 136, 146, 150, 158, 161,
-        162, 170, 174, 182, 187, 190, 184, 79, 77, 76, 75, 78, 78, 81, 84, 90,
-        99, 101, 108, 111, 116, 121, 122, 130, 133, 138, 145, 147, 156, 161,
-        168, 172, 173, 181, 184, 183, 183, 187, 205, 82, 80, 79, 77, 80, 81, 83,
-        86, 92, 101, 104, 111, 114, 120, 125, 127, 135, 138, 143, 150, 151, 161,
-        166, 173, 177, 178, 184, 184, 191, 201, 203, 192, 88, 85, 84, 82, 84,
-        84, 85, 89, 95, 105, 108, 116, 120, 127, 133, 134, 143, 146, 151, 158,
-        159, 169, 173, 181, 184, 185, 192, 200, 200, 193, 197, 220, 95, 91, 90,
-        88, 89, 90, 90, 94, 100, 110, 112, 121, 125, 133, 139, 141, 151, 154,
-        159, 166, 168, 178, 183, 190, 194, 195, 202, 198, 200, 217, 219, 202,
-        97, 93, 91, 89, 91, 91, 92, 95, 102, 111, 114, 122, 127, 134, 141, 142,
-        153, 156, 161, 169, 171, 181, 186, 193, 197, 198, 205, 212, 218, 206,
-        209, 236, 108, 103, 101, 99, 99, 100, 99, 103, 109, 118, 120, 130, 135,
-        143, 151, 153, 165, 168, 174, 183, 185, 195, 200, 208, 212, 213, 221,
-        219, 213, 230, 235, 213, 112, 107, 105, 102, 103, 103, 102, 106, 112,
-        121, 123, 133, 138, 146, 154, 156, 168, 172, 178, 187, 189, 200, 205,
-        213, 217, 218, 224, 224, 239, 226, 222, 253, 118, 113, 111, 108, 108,
-        108, 107, 111, 117, 125, 128, 138, 143, 151, 159, 161, 174, 178, 184,
-        194, 196, 207, 213, 221, 225, 226, 234, 240, 228, 244, 257, 226, 128,
-        122, 120, 117, 116, 116, 114, 118, 124, 132, 134, 145, 150, 158, 166,
-        169, 183, 187, 194, 204, 207, 219, 224, 233, 237, 238, 245, 238, 255,
-        247, 237, 277, 131, 125, 122, 119, 119, 118, 116, 120, 126, 134, 136,
-        147, 151, 159, 168, 171, 185, 189, 196, 207, 210, 222, 228, 237, 241,
-        242, 250, 263, 248, 254, 273, 241, 143, 136, 134, 130, 129, 129, 126,
-        130, 136, 144, 146, 156, 161, 169, 178, 181, 195, 200, 207, 219, 222,
-        235, 241, 251, 255, 256, 266, 258, 270, 273, 252, 292, 149, 142, 139,
-        136, 134, 134, 131, 135, 141, 148, 150, 161, 166, 173, 183, 186, 200,
-        205, 213, 224, 228, 241, 247, 257, 262, 263, 270, 276, 274, 268, 299,
-        256, 160, 152, 149, 145, 143, 143, 139, 142, 148, 156, 158, 168, 173,
-        181, 190, 193, 208, 213, 221, 233, 237, 251, 257, 268, 273, 274, 285,
-        285, 280, 297, 269, 321, 164, 156, 153, 149, 147, 147, 143, 146, 152,
-        159, 161, 172, 177, 184, 194, 197, 212, 217, 225, 237, 241, 255, 262,
-        273, 278, 279, 288, 291, 305, 280, 317, 274, 166, 157, 154, 150, 148,
-        148, 144, 147, 153, 160, 162, 173, 178, 185, 195, 198, 213, 218, 226,
-        238, 242, 256, 263, 274, 279, 280, 290, 298, 295, 329, 286, 337, 176,
-        167, 164, 159, 157, 156, 151, 155, 161, 168, 170, 181, 184, 192, 202,
-        205, 221, 224, 234, 245, 250, 266, 270, 285, 288, 290, 301, 296, 308,
-        300, 351, 291, 181, 172, 169, 164, 162, 161, 156, 156, 166, 170, 174,
-        184, 184, 200, 198, 212, 219, 224, 240, 238, 263, 258, 276, 285, 291,
-        298, 296, 313, 302, 319, 306, 376, 187, 177, 175, 169, 167, 166, 161,
-        160, 172, 170, 182, 183, 191, 200, 200, 218, 213, 239, 228, 255, 248,
-        270, 274, 280, 305, 295, 308, 302, 325, 308, 330, 312, 193, 183, 181,
-        175, 173, 171, 166, 165, 176, 174, 187, 183, 201, 193, 217, 206, 230,
-        226, 244, 247, 254, 273, 268, 297, 280, 329, 300, 319, 308, 338, 313,
-        341, 199, 189, 187, 180, 179, 176, 172, 170, 179, 179, 190, 187, 203,
-        197, 219, 209, 235, 222, 257, 237, 273, 252, 299, 269, 317, 286, 351,
-        306, 330, 313, 351, 319, 206, 194, 195, 183, 186, 180, 181, 171, 175,
-        195, 184, 205, 192, 220, 202, 236, 213, 253, 226, 277, 241, 292, 256,
-        321, 274, 337, 291, 376, 312, 341, 319, 364,
+        32, 31, 31, 31, 31, 31, 32, 32, 34, 35, 36, 39, 41, 44, 47, 48, 54, 56,
+        59, 64, 65, 71, 74, 80, 82, 83, 87, 90, 92, 95, 97, 100, 31, 32, 32, 32,
+        32, 32, 32, 33, 34, 35, 35, 38, 40, 42, 45, 46, 51, 53, 56, 61, 62, 68,
+        71, 76, 78, 78, 83, 85, 88, 90, 92, 95, 31, 32, 32, 32, 32, 32, 32, 33,
+        34, 34, 35, 38, 39, 42, 45, 45, 50, 52, 55, 60, 61, 67, 69, 74, 76, 77,
+        81, 84, 87, 89, 92, 95, 31, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 37,
+        38, 41, 44, 44, 49, 51, 54, 58, 59, 65, 68, 72, 74, 75, 79, 81, 84, 86,
+        88, 90, 31, 32, 32, 32, 33, 33, 33, 34, 35, 36, 36, 39, 40, 42, 44, 45,
+        49, 51, 54, 58, 59, 64, 67, 71, 73, 74, 78, 80, 83, 85, 88, 90, 31, 32,
+        32, 32, 33, 33, 34, 34, 35, 36, 36, 39, 40, 42, 45, 45, 50, 51, 54, 58,
+        59, 64, 67, 71, 73, 74, 78, 80, 82, 84, 86, 89, 32, 32, 32, 32, 33, 34,
+        35, 36, 37, 38, 38, 40, 41, 42, 45, 46, 49, 51, 53, 57, 58, 63, 65, 69,
+        71, 72, 75, 78, 80, 83, 86, 89, 32, 33, 33, 33, 34, 34, 36, 36, 38, 39,
+        40, 42, 43, 44, 47, 47, 51, 53, 55, 59, 60, 65, 67, 71, 73, 73, 77, 78,
+        80, 82, 84, 86, 34, 34, 34, 33, 35, 35, 37, 38, 39, 42, 42, 45, 46, 47,
+        50, 51, 54, 56, 58, 62, 63, 68, 70, 74, 76, 76, 80, 82, 84, 85, 85, 86,
+        35, 35, 34, 34, 36, 36, 38, 39, 42, 46, 47, 49, 50, 52, 55, 55, 59, 60,
+        62, 66, 67, 72, 74, 78, 79, 80, 83, 84, 85, 87, 90, 92, 36, 35, 35, 34,
+        36, 36, 38, 40, 42, 47, 48, 50, 52, 54, 56, 57, 60, 61, 64, 67, 68, 73,
+        75, 79, 80, 81, 85, 87, 90, 91, 91, 92, 39, 38, 38, 37, 39, 39, 40, 42,
+        45, 49, 50, 54, 55, 58, 60, 61, 65, 66, 69, 72, 73, 78, 80, 84, 86, 86,
+        90, 91, 91, 92, 95, 97, 41, 40, 39, 38, 40, 40, 41, 43, 46, 50, 52, 55,
+        57, 60, 62, 63, 67, 69, 71, 75, 75, 80, 83, 86, 88, 89, 92, 93, 95, 97,
+        97, 98, 44, 42, 42, 41, 42, 42, 42, 44, 47, 52, 54, 58, 60, 63, 66, 67,
+        71, 73, 75, 79, 79, 84, 86, 90, 92, 92, 96, 98, 98, 98, 101, 104, 47,
+        45, 45, 44, 44, 45, 45, 47, 50, 55, 56, 60, 62, 66, 69, 70, 75, 77, 79,
+        83, 84, 89, 91, 95, 97, 97, 100, 99, 102, 105, 104, 104, 48, 46, 45, 44,
+        45, 45, 46, 47, 51, 55, 57, 61, 63, 67, 70, 71, 76, 78, 80, 84, 85, 90,
+        93, 96, 98, 99, 102, 106, 106, 105, 108, 111, 54, 51, 50, 49, 49, 50,
+        49, 51, 54, 59, 60, 65, 67, 71, 75, 76, 82, 84, 87, 91, 92, 97, 100,
+        104, 106, 106, 110, 108, 109, 112, 112, 111, 56, 53, 52, 51, 51, 51, 51,
+        53, 56, 60, 61, 66, 69, 73, 77, 78, 84, 86, 89, 93, 94, 100, 102, 106,
+        108, 109, 112, 113, 115, 114, 116, 119, 59, 56, 55, 54, 54, 54, 53, 55,
+        58, 62, 64, 69, 71, 75, 79, 80, 87, 89, 92, 97, 98, 103, 106, 110, 112,
+        113, 117, 118, 117, 121, 121, 119, 64, 61, 60, 58, 58, 58, 57, 59, 62,
+        66, 67, 72, 75, 79, 83, 84, 91, 93, 97, 102, 103, 109, 112, 116, 118,
+        119, 122, 121, 125, 123, 125, 128, 65, 62, 61, 59, 59, 59, 58, 60, 63,
+        67, 68, 73, 75, 79, 84, 85, 92, 94, 98, 103, 105, 111, 114, 118, 120,
+        121, 125, 129, 126, 129, 130, 129, 71, 68, 67, 65, 64, 64, 63, 65, 68,
+        72, 73, 78, 80, 84, 89, 90, 97, 100, 103, 109, 111, 117, 120, 125, 127,
+        128, 133, 130, 134, 133, 133, 137, 74, 71, 69, 68, 67, 67, 65, 67, 70,
+        74, 75, 80, 83, 86, 91, 93, 100, 102, 106, 112, 114, 120, 123, 128, 131,
+        131, 135, 137, 137, 138, 140, 137, 80, 76, 74, 72, 71, 71, 69, 71, 74,
+        78, 79, 84, 86, 90, 95, 96, 104, 106, 110, 116, 118, 125, 128, 134, 136,
+        137, 142, 141, 142, 143, 143, 147, 82, 78, 76, 74, 73, 73, 71, 73, 76,
+        79, 80, 86, 88, 92, 97, 98, 106, 108, 112, 118, 120, 127, 131, 136, 139,
+        139, 144, 147, 148, 147, 150, 148, 83, 78, 77, 75, 74, 74, 72, 73, 76,
+        80, 81, 86, 89, 92, 97, 99, 106, 109, 113, 119, 121, 128, 131, 137, 139,
+        140, 145, 150, 152, 155, 152, 157, 87, 83, 81, 79, 78, 78, 75, 77, 80,
+        83, 85, 90, 92, 96, 100, 102, 110, 112, 117, 122, 125, 133, 135, 142,
+        144, 145, 150, 151, 155, 158, 162, 158, 90, 85, 84, 81, 80, 80, 78, 78,
+        82, 84, 87, 91, 93, 98, 99, 106, 108, 113, 118, 121, 129, 130, 137, 141,
+        147, 150, 151, 156, 156, 161, 164, 169, 92, 88, 87, 84, 83, 82, 80, 80,
+        84, 85, 90, 91, 95, 98, 102, 106, 109, 115, 117, 125, 126, 134, 137,
+        142, 148, 152, 155, 156, 162, 162, 168, 170, 95, 90, 89, 86, 85, 84, 83,
+        82, 85, 87, 91, 92, 97, 98, 105, 105, 112, 114, 121, 123, 129, 133, 138,
+        143, 147, 155, 158, 161, 162, 168, 168, 174, 97, 92, 92, 88, 88, 86, 86,
+        84, 85, 90, 91, 95, 97, 101, 104, 108, 112, 116, 121, 125, 130, 133,
+        140, 143, 150, 152, 162, 164, 168, 168, 174, 175, 100, 95, 95, 90, 90,
+        89, 89, 86, 86, 92, 92, 97, 98, 104, 104, 111, 111, 119, 119, 128, 129,
+        137, 137, 147, 148, 157, 158, 169, 170, 174, 175, 181,
         /* Size 4x8 */
-        64, 71, 119, 169, 65, 73, 114, 158, 69, 94, 130, 168, 82, 107, 156, 199,
-        103, 123, 185, 224, 131, 146, 216, 258, 151, 162, 235, 296, 175, 183,
-        232, 299,
+        32, 35, 59, 83, 32, 36, 57, 78, 34, 47, 65, 82, 41, 53, 78, 97, 51, 61,
+        92, 111, 65, 73, 108, 129, 75, 81, 117, 148, 86, 92, 119, 154,
         /* Size 8x4 */
-        64, 65, 69, 82, 103, 131, 151, 175, 71, 73, 94, 107, 123, 146, 162, 183,
-        119, 114, 130, 156, 185, 216, 235, 232, 169, 158, 168, 199, 224, 258,
-        296, 299,
+        32, 32, 34, 41, 51, 65, 75, 86, 35, 36, 47, 53, 61, 73, 81, 92, 59, 57,
+        65, 78, 92, 108, 117, 119, 83, 78, 82, 97, 111, 129, 148, 154,
         /* Size 8x16 */
-        64, 63, 70, 88, 107, 131, 164, 189, 63, 65, 69, 83, 101, 122, 153, 177,
-        63, 66, 71, 84, 99, 118, 147, 169, 64, 68, 75, 85, 99, 116, 142, 163,
-        68, 70, 83, 96, 109, 126, 152, 172, 72, 72, 92, 108, 120, 136, 161, 184,
-        82, 80, 99, 120, 135, 152, 177, 198, 94, 89, 107, 132, 150, 168, 194,
-        215, 107, 100, 115, 142, 164, 185, 212, 227, 117, 108, 123, 150, 174,
-        196, 225, 242, 130, 119, 132, 159, 185, 210, 241, 253, 149, 134, 146,
-        173, 200, 227, 262, 269, 164, 147, 158, 184, 211, 241, 278, 281, 175,
-        157, 166, 192, 220, 250, 288, 298, 186, 167, 172, 199, 236, 272, 299,
-        304, 198, 179, 180, 204, 235, 273, 317, 334,
+        32, 31, 35, 44, 53, 65, 82, 90, 31, 32, 34, 41, 50, 61, 76, 85, 31, 33,
+        35, 42, 49, 59, 73, 81, 32, 34, 37, 42, 49, 58, 71, 79, 34, 35, 41, 48,
+        54, 63, 76, 81, 36, 36, 46, 54, 60, 68, 80, 87, 41, 40, 49, 60, 67, 76,
+        88, 93, 47, 44, 53, 66, 75, 84, 97, 101, 53, 50, 57, 71, 82, 92, 106,
+        108, 58, 54, 61, 75, 87, 98, 112, 116, 65, 59, 66, 79, 92, 105, 120,
+        124, 74, 67, 73, 86, 100, 113, 131, 134, 82, 73, 79, 92, 105, 120, 139,
+        142, 87, 78, 83, 96, 110, 125, 144, 153, 92, 83, 84, 97, 114, 132, 150,
+        157, 97, 88, 86, 97, 111, 128, 147, 163,
         /* Size 16x8 */
-        64, 63, 63, 64, 68, 72, 82, 94, 107, 117, 130, 149, 164, 175, 186, 198,
-        63, 65, 66, 68, 70, 72, 80, 89, 100, 108, 119, 134, 147, 157, 167, 179,
-        70, 69, 71, 75, 83, 92, 99, 107, 115, 123, 132, 146, 158, 166, 172, 180,
-        88, 83, 84, 85, 96, 108, 120, 132, 142, 150, 159, 173, 184, 192, 199,
-        204, 107, 101, 99, 99, 109, 120, 135, 150, 164, 174, 185, 200, 211, 220,
-        236, 235, 131, 122, 118, 116, 126, 136, 152, 168, 185, 196, 210, 227,
-        241, 250, 272, 273, 164, 153, 147, 142, 152, 161, 177, 194, 212, 225,
-        241, 262, 278, 288, 299, 317, 189, 177, 169, 163, 172, 184, 198, 215,
-        227, 242, 253, 269, 281, 298, 304, 334,
+        32, 31, 31, 32, 34, 36, 41, 47, 53, 58, 65, 74, 82, 87, 92, 97, 31, 32,
+        33, 34, 35, 36, 40, 44, 50, 54, 59, 67, 73, 78, 83, 88, 35, 34, 35, 37,
+        41, 46, 49, 53, 57, 61, 66, 73, 79, 83, 84, 86, 44, 41, 42, 42, 48, 54,
+        60, 66, 71, 75, 79, 86, 92, 96, 97, 97, 53, 50, 49, 49, 54, 60, 67, 75,
+        82, 87, 92, 100, 105, 110, 114, 111, 65, 61, 59, 58, 63, 68, 76, 84, 92,
+        98, 105, 113, 120, 125, 132, 128, 82, 76, 73, 71, 76, 80, 88, 97, 106,
+        112, 120, 131, 139, 144, 150, 147, 90, 85, 81, 79, 81, 87, 93, 101, 108,
+        116, 124, 134, 142, 153, 157, 163,
         /* Size 16x32 */
-        64, 63, 63, 64, 70, 72, 88, 95, 107, 125, 131, 158, 164, 179, 189, 199,
-        63, 64, 64, 65, 70, 71, 85, 91, 103, 119, 124, 151, 156, 169, 179, 188,
-        63, 64, 65, 65, 69, 70, 83, 90, 101, 117, 122, 148, 153, 167, 177, 189,
-        63, 65, 65, 66, 68, 69, 82, 88, 99, 114, 119, 144, 149, 162, 171, 178,
-        63, 65, 66, 68, 71, 72, 84, 89, 99, 114, 118, 142, 147, 159, 169, 180,
-        64, 65, 66, 68, 72, 73, 84, 90, 100, 114, 118, 142, 146, 158, 167, 174,
-        64, 66, 68, 71, 75, 77, 85, 90, 99, 112, 116, 138, 142, 153, 163, 176,
-        65, 66, 69, 72, 78, 80, 89, 94, 103, 116, 120, 142, 146, 155, 161, 167,
-        68, 68, 70, 74, 83, 85, 96, 101, 109, 122, 126, 147, 152, 164, 172, 170,
-        71, 69, 72, 76, 90, 94, 105, 110, 118, 130, 134, 155, 159, 168, 171,
-        190, 72, 69, 72, 77, 92, 96, 108, 112, 120, 133, 136, 157, 161, 172,
-        184, 179, 79, 75, 78, 81, 96, 101, 116, 121, 130, 143, 147, 168, 172,
-        182, 180, 201, 82, 78, 80, 83, 99, 103, 120, 125, 135, 148, 152, 172,
-        177, 183, 198, 187, 88, 82, 84, 86, 102, 107, 126, 132, 143, 156, 159,
-        180, 184, 199, 190, 215, 94, 88, 89, 91, 107, 112, 132, 139, 150, 164,
-        168, 190, 194, 197, 215, 198, 96, 90, 91, 93, 108, 113, 134, 140, 152,
-        167, 171, 192, 197, 210, 204, 232, 107, 99, 100, 100, 115, 120, 142,
-        150, 164, 180, 185, 207, 212, 217, 227, 209, 111, 103, 103, 103, 118,
-        123, 145, 154, 168, 185, 189, 212, 217, 224, 222, 249, 117, 108, 108,
-        108, 123, 127, 150, 159, 174, 191, 196, 220, 225, 238, 242, 222, 127,
-        117, 116, 115, 130, 134, 157, 166, 182, 201, 207, 232, 237, 236, 242,
-        273, 130, 120, 119, 117, 132, 136, 159, 168, 185, 204, 210, 236, 241,
-        260, 253, 237, 142, 131, 129, 127, 142, 146, 169, 178, 195, 216, 222,
-        250, 255, 258, 266, 287, 149, 136, 134, 132, 146, 150, 173, 183, 200,
-        221, 227, 256, 262, 272, 269, 252, 159, 145, 143, 140, 154, 158, 181,
-        190, 208, 230, 236, 267, 273, 284, 289, 315, 164, 150, 147, 144, 158,
-        162, 184, 194, 211, 234, 241, 272, 278, 289, 281, 269, 165, 151, 148,
-        145, 159, 162, 185, 195, 212, 235, 242, 273, 279, 296, 322, 331, 175,
-        159, 157, 153, 166, 170, 192, 202, 220, 242, 250, 284, 288, 294, 298,
-        286, 180, 165, 162, 157, 169, 174, 198, 198, 226, 240, 254, 284, 288,
-        309, 315, 369, 186, 170, 167, 162, 172, 178, 199, 200, 236, 228, 272,
-        272, 299, 309, 304, 307, 192, 175, 173, 166, 176, 183, 201, 205, 235,
-        232, 276, 264, 322, 299, 333, 335, 198, 181, 179, 171, 180, 187, 204,
-        209, 235, 237, 273, 269, 317, 305, 334, 314, 205, 185, 186, 174, 176,
-        204, 192, 235, 213, 274, 241, 318, 274, 366, 311, 358,
+        32, 31, 31, 32, 35, 36, 44, 47, 53, 62, 65, 79, 82, 88, 90, 93, 31, 32,
+        32, 32, 35, 35, 42, 45, 51, 59, 62, 75, 78, 83, 86, 88, 31, 32, 32, 32,
+        34, 35, 41, 45, 50, 58, 61, 74, 76, 82, 85, 88, 31, 32, 32, 33, 34, 34,
+        41, 44, 49, 57, 59, 72, 74, 79, 82, 84, 31, 32, 33, 34, 35, 36, 42, 44,
+        49, 57, 59, 71, 73, 79, 81, 84, 32, 32, 33, 34, 36, 36, 42, 45, 50, 57,
+        59, 71, 73, 78, 80, 82, 32, 33, 34, 35, 37, 38, 42, 45, 49, 56, 58, 69,
+        71, 76, 79, 83, 32, 33, 34, 36, 39, 40, 44, 47, 51, 58, 60, 71, 73, 76,
+        78, 80, 34, 34, 35, 37, 41, 42, 48, 50, 54, 61, 63, 73, 76, 81, 81, 80,
+        35, 34, 36, 38, 45, 47, 52, 55, 59, 65, 67, 77, 79, 82, 83, 86, 36, 34,
+        36, 38, 46, 48, 54, 56, 60, 66, 68, 78, 80, 85, 87, 86, 39, 37, 39, 40,
+        48, 50, 58, 60, 65, 71, 73, 84, 86, 89, 88, 91, 41, 39, 40, 41, 49, 51,
+        60, 62, 67, 74, 76, 86, 88, 91, 93, 91, 44, 41, 42, 43, 51, 53, 63, 66,
+        71, 78, 79, 90, 92, 97, 94, 97, 47, 44, 44, 45, 53, 56, 66, 69, 75, 82,
+        84, 95, 97, 98, 101, 98, 48, 45, 45, 46, 54, 56, 67, 70, 76, 83, 85, 96,
+        98, 104, 101, 105, 53, 49, 50, 50, 57, 60, 71, 75, 82, 90, 92, 103, 106,
+        107, 108, 105, 55, 51, 51, 51, 59, 61, 72, 77, 84, 92, 94, 106, 108,
+        111, 110, 112, 58, 54, 54, 54, 61, 63, 75, 79, 87, 95, 98, 110, 112,
+        117, 116, 113, 63, 58, 58, 57, 65, 67, 78, 83, 91, 100, 103, 116, 118,
+        119, 119, 121, 65, 60, 59, 58, 66, 68, 79, 84, 92, 102, 105, 118, 120,
+        127, 124, 122, 71, 65, 64, 63, 71, 73, 84, 89, 97, 108, 111, 125, 127,
+        129, 129, 130, 74, 68, 67, 66, 73, 75, 86, 91, 100, 110, 113, 128, 131,
+        135, 134, 130, 79, 72, 71, 70, 77, 79, 90, 95, 104, 115, 118, 133, 136,
+        140, 139, 140, 82, 75, 73, 72, 79, 81, 92, 97, 105, 117, 120, 136, 139,
+        145, 142, 140, 82, 75, 74, 72, 79, 81, 92, 97, 106, 117, 121, 136, 139,
+        148, 150, 149, 87, 79, 78, 76, 83, 85, 96, 100, 110, 120, 125, 141, 144,
+        148, 153, 150, 89, 82, 81, 78, 83, 87, 97, 99, 113, 118, 128, 139, 145,
+        153, 157, 161, 92, 84, 83, 80, 84, 89, 97, 101, 114, 116, 132, 135, 150,
+        153, 157, 162, 94, 86, 85, 82, 85, 92, 97, 104, 112, 119, 130, 136, 151,
+        154, 163, 166, 97, 88, 88, 85, 86, 94, 97, 107, 111, 123, 128, 140, 147,
+        159, 163, 167, 99, 91, 91, 87, 87, 97, 97, 110, 110, 126, 126, 144, 144,
+        163, 163, 173,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 64, 64, 65, 68, 71, 72, 79, 82, 88, 94, 96, 107,
-        111, 117, 127, 130, 142, 149, 159, 164, 165, 175, 180, 186, 192, 198,
-        205, 63, 64, 64, 65, 65, 65, 66, 66, 68, 69, 69, 75, 78, 82, 88, 90, 99,
-        103, 108, 117, 120, 131, 136, 145, 150, 151, 159, 165, 170, 175, 181,
-        185, 63, 64, 65, 65, 66, 66, 68, 69, 70, 72, 72, 78, 80, 84, 89, 91,
-        100, 103, 108, 116, 119, 129, 134, 143, 147, 148, 157, 162, 167, 173,
-        179, 186, 64, 65, 65, 66, 68, 68, 71, 72, 74, 76, 77, 81, 83, 86, 91,
-        93, 100, 103, 108, 115, 117, 127, 132, 140, 144, 145, 153, 157, 162,
-        166, 171, 174, 70, 70, 69, 68, 71, 72, 75, 78, 83, 90, 92, 96, 99, 102,
-        107, 108, 115, 118, 123, 130, 132, 142, 146, 154, 158, 159, 166, 169,
-        172, 176, 180, 176, 72, 71, 70, 69, 72, 73, 77, 80, 85, 94, 96, 101,
-        103, 107, 112, 113, 120, 123, 127, 134, 136, 146, 150, 158, 162, 162,
-        170, 174, 178, 183, 187, 204, 88, 85, 83, 82, 84, 84, 85, 89, 96, 105,
-        108, 116, 120, 126, 132, 134, 142, 145, 150, 157, 159, 169, 173, 181,
-        184, 185, 192, 198, 199, 201, 204, 192, 95, 91, 90, 88, 89, 90, 90, 94,
-        101, 110, 112, 121, 125, 132, 139, 140, 150, 154, 159, 166, 168, 178,
-        183, 190, 194, 195, 202, 198, 200, 205, 209, 235, 107, 103, 101, 99, 99,
-        100, 99, 103, 109, 118, 120, 130, 135, 143, 150, 152, 164, 168, 174,
-        182, 185, 195, 200, 208, 211, 212, 220, 226, 236, 235, 235, 213, 125,
-        119, 117, 114, 114, 114, 112, 116, 122, 130, 133, 143, 148, 156, 164,
-        167, 180, 185, 191, 201, 204, 216, 221, 230, 234, 235, 242, 240, 228,
-        232, 237, 274, 131, 124, 122, 119, 118, 118, 116, 120, 126, 134, 136,
-        147, 152, 159, 168, 171, 185, 189, 196, 207, 210, 222, 227, 236, 241,
-        242, 250, 254, 272, 276, 273, 241, 158, 151, 148, 144, 142, 142, 138,
-        142, 147, 155, 157, 168, 172, 180, 190, 192, 207, 212, 220, 232, 236,
-        250, 256, 267, 272, 273, 284, 284, 272, 264, 269, 318, 164, 156, 153,
-        149, 147, 146, 142, 146, 152, 159, 161, 172, 177, 184, 194, 197, 212,
-        217, 225, 237, 241, 255, 262, 273, 278, 279, 288, 288, 299, 322, 317,
-        274, 179, 169, 167, 162, 159, 158, 153, 155, 164, 168, 172, 182, 183,
-        199, 197, 210, 217, 224, 238, 236, 260, 258, 272, 284, 289, 296, 294,
-        309, 309, 299, 305, 366, 189, 179, 177, 171, 169, 167, 163, 161, 172,
-        171, 184, 180, 198, 190, 215, 204, 227, 222, 242, 242, 253, 266, 269,
-        289, 281, 322, 298, 315, 304, 333, 334, 311, 199, 188, 189, 178, 180,
-        174, 176, 167, 170, 190, 179, 201, 187, 215, 198, 232, 209, 249, 222,
-        273, 237, 287, 252, 315, 269, 331, 286, 369, 307, 335, 314, 358,
+        32, 31, 31, 31, 31, 32, 32, 32, 34, 35, 36, 39, 41, 44, 47, 48, 53, 55,
+        58, 63, 65, 71, 74, 79, 82, 82, 87, 89, 92, 94, 97, 99, 31, 32, 32, 32,
+        32, 32, 33, 33, 34, 34, 34, 37, 39, 41, 44, 45, 49, 51, 54, 58, 60, 65,
+        68, 72, 75, 75, 79, 82, 84, 86, 88, 91, 31, 32, 32, 32, 33, 33, 34, 34,
+        35, 36, 36, 39, 40, 42, 44, 45, 50, 51, 54, 58, 59, 64, 67, 71, 73, 74,
+        78, 81, 83, 85, 88, 91, 32, 32, 32, 33, 34, 34, 35, 36, 37, 38, 38, 40,
+        41, 43, 45, 46, 50, 51, 54, 57, 58, 63, 66, 70, 72, 72, 76, 78, 80, 82,
+        85, 87, 35, 35, 34, 34, 35, 36, 37, 39, 41, 45, 46, 48, 49, 51, 53, 54,
+        57, 59, 61, 65, 66, 71, 73, 77, 79, 79, 83, 83, 84, 85, 86, 87, 36, 35,
+        35, 34, 36, 36, 38, 40, 42, 47, 48, 50, 51, 53, 56, 56, 60, 61, 63, 67,
+        68, 73, 75, 79, 81, 81, 85, 87, 89, 92, 94, 97, 44, 42, 41, 41, 42, 42,
+        42, 44, 48, 52, 54, 58, 60, 63, 66, 67, 71, 72, 75, 78, 79, 84, 86, 90,
+        92, 92, 96, 97, 97, 97, 97, 97, 47, 45, 45, 44, 44, 45, 45, 47, 50, 55,
+        56, 60, 62, 66, 69, 70, 75, 77, 79, 83, 84, 89, 91, 95, 97, 97, 100, 99,
+        101, 104, 107, 110, 53, 51, 50, 49, 49, 50, 49, 51, 54, 59, 60, 65, 67,
+        71, 75, 76, 82, 84, 87, 91, 92, 97, 100, 104, 105, 106, 110, 113, 114,
+        112, 111, 110, 62, 59, 58, 57, 57, 57, 56, 58, 61, 65, 66, 71, 74, 78,
+        82, 83, 90, 92, 95, 100, 102, 108, 110, 115, 117, 117, 120, 118, 116,
+        119, 123, 126, 65, 62, 61, 59, 59, 59, 58, 60, 63, 67, 68, 73, 76, 79,
+        84, 85, 92, 94, 98, 103, 105, 111, 113, 118, 120, 121, 125, 128, 132,
+        130, 128, 126, 79, 75, 74, 72, 71, 71, 69, 71, 73, 77, 78, 84, 86, 90,
+        95, 96, 103, 106, 110, 116, 118, 125, 128, 133, 136, 136, 141, 139, 135,
+        136, 140, 144, 82, 78, 76, 74, 73, 73, 71, 73, 76, 79, 80, 86, 88, 92,
+        97, 98, 106, 108, 112, 118, 120, 127, 131, 136, 139, 139, 144, 145, 150,
+        151, 147, 144, 88, 83, 82, 79, 79, 78, 76, 76, 81, 82, 85, 89, 91, 97,
+        98, 104, 107, 111, 117, 119, 127, 129, 135, 140, 145, 148, 148, 153,
+        153, 154, 159, 163, 90, 86, 85, 82, 81, 80, 79, 78, 81, 83, 87, 88, 93,
+        94, 101, 101, 108, 110, 116, 119, 124, 129, 134, 139, 142, 150, 153,
+        157, 157, 163, 163, 163, 93, 88, 88, 84, 84, 82, 83, 80, 80, 86, 86, 91,
+        91, 97, 98, 105, 105, 112, 113, 121, 122, 130, 130, 140, 140, 149, 150,
+        161, 162, 166, 167, 173,
         /* Size 4x16 */
-        63, 72, 125, 179, 64, 70, 117, 167, 65, 72, 114, 159, 66, 77, 112, 153,
-        68, 85, 122, 164, 69, 96, 133, 172, 78, 103, 148, 183, 88, 112, 164,
-        197, 99, 120, 180, 217, 108, 127, 191, 238, 120, 136, 204, 260, 136,
-        150, 221, 272, 150, 162, 234, 289, 159, 170, 242, 294, 170, 178, 228,
-        309, 181, 187, 237, 305,
+        31, 36, 62, 88, 32, 35, 58, 82, 32, 36, 57, 79, 33, 38, 56, 76, 34, 42,
+        61, 81, 34, 48, 66, 85, 39, 51, 74, 91, 44, 56, 82, 98, 49, 60, 90, 107,
+        54, 63, 95, 117, 60, 68, 102, 127, 68, 75, 110, 135, 75, 81, 117, 145,
+        79, 85, 120, 148, 84, 89, 116, 153, 88, 94, 123, 159,
         /* Size 16x4 */
-        63, 64, 65, 66, 68, 69, 78, 88, 99, 108, 120, 136, 150, 159, 170, 181,
-        72, 70, 72, 77, 85, 96, 103, 112, 120, 127, 136, 150, 162, 170, 178,
-        187, 125, 117, 114, 112, 122, 133, 148, 164, 180, 191, 204, 221, 234,
-        242, 228, 237, 179, 167, 159, 153, 164, 172, 183, 197, 217, 238, 260,
-        272, 289, 294, 309, 305,
+        31, 32, 32, 33, 34, 34, 39, 44, 49, 54, 60, 68, 75, 79, 84, 88, 36, 35,
+        36, 38, 42, 48, 51, 56, 60, 63, 68, 75, 81, 85, 89, 94, 62, 58, 57, 56,
+        61, 66, 74, 82, 90, 95, 102, 110, 117, 120, 116, 123, 88, 82, 79, 76,
+        81, 85, 91, 98, 107, 117, 127, 135, 145, 148, 153, 159,
         /* Size 8x32 */
-        64, 63, 70, 88, 107, 131, 164, 189, 63, 64, 70, 85, 103, 124, 156, 179,
-        63, 65, 69, 83, 101, 122, 153, 177, 63, 65, 68, 82, 99, 119, 149, 171,
-        63, 66, 71, 84, 99, 118, 147, 169, 64, 66, 72, 84, 100, 118, 146, 167,
-        64, 68, 75, 85, 99, 116, 142, 163, 65, 69, 78, 89, 103, 120, 146, 161,
-        68, 70, 83, 96, 109, 126, 152, 172, 71, 72, 90, 105, 118, 134, 159, 171,
-        72, 72, 92, 108, 120, 136, 161, 184, 79, 78, 96, 116, 130, 147, 172,
-        180, 82, 80, 99, 120, 135, 152, 177, 198, 88, 84, 102, 126, 143, 159,
-        184, 190, 94, 89, 107, 132, 150, 168, 194, 215, 96, 91, 108, 134, 152,
-        171, 197, 204, 107, 100, 115, 142, 164, 185, 212, 227, 111, 103, 118,
-        145, 168, 189, 217, 222, 117, 108, 123, 150, 174, 196, 225, 242, 127,
-        116, 130, 157, 182, 207, 237, 242, 130, 119, 132, 159, 185, 210, 241,
-        253, 142, 129, 142, 169, 195, 222, 255, 266, 149, 134, 146, 173, 200,
-        227, 262, 269, 159, 143, 154, 181, 208, 236, 273, 289, 164, 147, 158,
-        184, 211, 241, 278, 281, 165, 148, 159, 185, 212, 242, 279, 322, 175,
-        157, 166, 192, 220, 250, 288, 298, 180, 162, 169, 198, 226, 254, 288,
-        315, 186, 167, 172, 199, 236, 272, 299, 304, 192, 173, 176, 201, 235,
-        276, 322, 333, 198, 179, 180, 204, 235, 273, 317, 334, 205, 186, 176,
-        192, 213, 241, 274, 311,
+        32, 31, 35, 44, 53, 65, 82, 90, 31, 32, 35, 42, 51, 62, 78, 86, 31, 32,
+        34, 41, 50, 61, 76, 85, 31, 32, 34, 41, 49, 59, 74, 82, 31, 33, 35, 42,
+        49, 59, 73, 81, 32, 33, 36, 42, 50, 59, 73, 80, 32, 34, 37, 42, 49, 58,
+        71, 79, 32, 34, 39, 44, 51, 60, 73, 78, 34, 35, 41, 48, 54, 63, 76, 81,
+        35, 36, 45, 52, 59, 67, 79, 83, 36, 36, 46, 54, 60, 68, 80, 87, 39, 39,
+        48, 58, 65, 73, 86, 88, 41, 40, 49, 60, 67, 76, 88, 93, 44, 42, 51, 63,
+        71, 79, 92, 94, 47, 44, 53, 66, 75, 84, 97, 101, 48, 45, 54, 67, 76, 85,
+        98, 101, 53, 50, 57, 71, 82, 92, 106, 108, 55, 51, 59, 72, 84, 94, 108,
+        110, 58, 54, 61, 75, 87, 98, 112, 116, 63, 58, 65, 78, 91, 103, 118,
+        119, 65, 59, 66, 79, 92, 105, 120, 124, 71, 64, 71, 84, 97, 111, 127,
+        129, 74, 67, 73, 86, 100, 113, 131, 134, 79, 71, 77, 90, 104, 118, 136,
+        139, 82, 73, 79, 92, 105, 120, 139, 142, 82, 74, 79, 92, 106, 121, 139,
+        150, 87, 78, 83, 96, 110, 125, 144, 153, 89, 81, 83, 97, 113, 128, 145,
+        157, 92, 83, 84, 97, 114, 132, 150, 157, 94, 85, 85, 97, 112, 130, 151,
+        163, 97, 88, 86, 97, 111, 128, 147, 163, 99, 91, 87, 97, 110, 126, 144,
+        163,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 64, 64, 65, 68, 71, 72, 79, 82, 88, 94, 96, 107,
-        111, 117, 127, 130, 142, 149, 159, 164, 165, 175, 180, 186, 192, 198,
-        205, 63, 64, 65, 65, 66, 66, 68, 69, 70, 72, 72, 78, 80, 84, 89, 91,
-        100, 103, 108, 116, 119, 129, 134, 143, 147, 148, 157, 162, 167, 173,
-        179, 186, 70, 70, 69, 68, 71, 72, 75, 78, 83, 90, 92, 96, 99, 102, 107,
-        108, 115, 118, 123, 130, 132, 142, 146, 154, 158, 159, 166, 169, 172,
-        176, 180, 176, 88, 85, 83, 82, 84, 84, 85, 89, 96, 105, 108, 116, 120,
-        126, 132, 134, 142, 145, 150, 157, 159, 169, 173, 181, 184, 185, 192,
-        198, 199, 201, 204, 192, 107, 103, 101, 99, 99, 100, 99, 103, 109, 118,
-        120, 130, 135, 143, 150, 152, 164, 168, 174, 182, 185, 195, 200, 208,
-        211, 212, 220, 226, 236, 235, 235, 213, 131, 124, 122, 119, 118, 118,
-        116, 120, 126, 134, 136, 147, 152, 159, 168, 171, 185, 189, 196, 207,
-        210, 222, 227, 236, 241, 242, 250, 254, 272, 276, 273, 241, 164, 156,
-        153, 149, 147, 146, 142, 146, 152, 159, 161, 172, 177, 184, 194, 197,
-        212, 217, 225, 237, 241, 255, 262, 273, 278, 279, 288, 288, 299, 322,
-        317, 274, 189, 179, 177, 171, 169, 167, 163, 161, 172, 171, 184, 180,
-        198, 190, 215, 204, 227, 222, 242, 242, 253, 266, 269, 289, 281, 322,
-        298, 315, 304, 333, 334, 311 },
+        32, 31, 31, 31, 31, 32, 32, 32, 34, 35, 36, 39, 41, 44, 47, 48, 53, 55,
+        58, 63, 65, 71, 74, 79, 82, 82, 87, 89, 92, 94, 97, 99, 31, 32, 32, 32,
+        33, 33, 34, 34, 35, 36, 36, 39, 40, 42, 44, 45, 50, 51, 54, 58, 59, 64,
+        67, 71, 73, 74, 78, 81, 83, 85, 88, 91, 35, 35, 34, 34, 35, 36, 37, 39,
+        41, 45, 46, 48, 49, 51, 53, 54, 57, 59, 61, 65, 66, 71, 73, 77, 79, 79,
+        83, 83, 84, 85, 86, 87, 44, 42, 41, 41, 42, 42, 42, 44, 48, 52, 54, 58,
+        60, 63, 66, 67, 71, 72, 75, 78, 79, 84, 86, 90, 92, 92, 96, 97, 97, 97,
+        97, 97, 53, 51, 50, 49, 49, 50, 49, 51, 54, 59, 60, 65, 67, 71, 75, 76,
+        82, 84, 87, 91, 92, 97, 100, 104, 105, 106, 110, 113, 114, 112, 111,
+        110, 65, 62, 61, 59, 59, 59, 58, 60, 63, 67, 68, 73, 76, 79, 84, 85, 92,
+        94, 98, 103, 105, 111, 113, 118, 120, 121, 125, 128, 132, 130, 128, 126,
+        82, 78, 76, 74, 73, 73, 71, 73, 76, 79, 80, 86, 88, 92, 97, 98, 106,
+        108, 112, 118, 120, 127, 131, 136, 139, 139, 144, 145, 150, 151, 147,
+        144, 90, 86, 85, 82, 81, 80, 79, 78, 81, 83, 87, 88, 93, 94, 101, 101,
+        108, 110, 116, 119, 124, 129, 134, 139, 142, 150, 153, 157, 157, 163,
+        163, 163 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        95, 111, 111, 178,
+        47, 55, 55, 89,
 #endif
         /* Size 4x4 */
-        64, 91, 103, 123, 91, 109, 119, 133, 103, 119, 150, 162, 123, 133, 162,
-        196,
+        32, 45, 51, 61, 45, 54, 59, 65, 51, 59, 75, 81, 61, 65, 81, 97,
         /* Size 8x8 */
-        63, 69, 93, 94, 101, 114, 123, 134, 69, 78, 94, 91, 96, 107, 115, 124,
-        93, 94, 104, 105, 108, 116, 122, 125, 94, 91, 105, 117, 124, 131, 136,
-        136, 101, 96, 108, 124, 136, 147, 154, 154, 114, 107, 116, 131, 147,
-        164, 172, 178, 123, 115, 122, 136, 154, 172, 183, 203, 134, 124, 125,
-        136, 154, 178, 203, 206,
+        31, 34, 46, 47, 50, 57, 61, 65, 34, 39, 47, 45, 48, 53, 57, 61, 46, 47,
+        52, 52, 54, 58, 61, 62, 47, 45, 52, 58, 62, 65, 68, 68, 50, 48, 54, 62,
+        68, 73, 77, 76, 57, 53, 58, 65, 73, 82, 86, 86, 61, 57, 61, 68, 77, 86,
+        91, 95, 65, 61, 62, 68, 76, 86, 95, 100,
         /* Size 16x16 */
-        64, 62, 66, 73, 83, 98, 98, 101, 104, 109, 114, 123, 129, 134, 139, 144,
-        62, 63, 68, 78, 85, 94, 93, 95, 98, 102, 107, 114, 120, 125, 129, 134,
-        66, 68, 75, 85, 89, 94, 92, 93, 95, 99, 103, 110, 115, 119, 123, 128,
-        73, 78, 85, 95, 95, 96, 92, 92, 94, 97, 100, 106, 111, 114, 118, 123,
-        83, 85, 89, 95, 97, 101, 99, 100, 101, 104, 107, 112, 117, 120, 125,
-        127, 98, 94, 94, 96, 101, 106, 107, 108, 109, 111, 113, 119, 123, 126,
-        131, 134, 98, 93, 92, 92, 99, 107, 111, 115, 118, 120, 123, 128, 132,
-        134, 136, 141, 101, 95, 93, 92, 100, 108, 115, 122, 126, 129, 133, 138,
-        141, 144, 141, 149, 104, 98, 95, 94, 101, 109, 118, 126, 133, 137, 141,
-        147, 151, 154, 148, 158, 109, 102, 99, 97, 104, 111, 120, 129, 137, 142,
-        147, 153, 158, 161, 156, 169, 114, 107, 103, 100, 107, 113, 123, 133,
-        141, 147, 153, 160, 165, 169, 167, 177, 123, 114, 110, 106, 112, 119,
-        128, 138, 147, 153, 160, 169, 175, 178, 179, 189, 129, 120, 115, 111,
-        117, 123, 132, 141, 151, 158, 165, 175, 182, 186, 193, 197, 134, 125,
-        119, 114, 120, 126, 134, 144, 154, 161, 169, 178, 186, 192, 194, 212,
-        139, 129, 123, 118, 125, 131, 136, 141, 148, 156, 167, 179, 193, 194,
-        201, 203, 144, 134, 128, 123, 127, 134, 141, 149, 158, 169, 177, 189,
-        197, 212, 203, 212,
+        32, 31, 33, 36, 41, 49, 49, 50, 52, 54, 57, 61, 64, 67, 68, 70, 31, 31,
+        34, 39, 42, 47, 46, 47, 49, 51, 53, 57, 60, 62, 64, 66, 33, 34, 37, 42,
+        44, 47, 46, 46, 47, 49, 51, 55, 57, 59, 61, 63, 36, 39, 42, 47, 47, 48,
+        46, 46, 47, 48, 50, 53, 55, 57, 59, 61, 41, 42, 44, 47, 48, 50, 49, 50,
+        50, 52, 53, 56, 58, 60, 61, 60, 49, 47, 47, 48, 50, 53, 53, 54, 54, 55,
+        56, 59, 61, 63, 64, 64, 49, 46, 46, 46, 49, 53, 55, 57, 59, 60, 61, 64,
+        66, 67, 67, 67, 50, 47, 46, 46, 50, 54, 57, 61, 63, 64, 66, 69, 70, 72,
+        71, 71, 52, 49, 47, 47, 50, 54, 59, 63, 66, 68, 70, 73, 75, 77, 75, 75,
+        54, 51, 49, 48, 52, 55, 60, 64, 68, 71, 73, 76, 79, 80, 79, 79, 57, 53,
+        51, 50, 53, 56, 61, 66, 70, 73, 76, 80, 82, 84, 83, 84, 61, 57, 55, 53,
+        56, 59, 64, 69, 73, 76, 80, 84, 87, 89, 88, 88, 64, 60, 57, 55, 58, 61,
+        66, 70, 75, 79, 82, 87, 91, 93, 93, 93, 67, 62, 59, 57, 60, 63, 67, 72,
+        77, 80, 84, 89, 93, 95, 96, 97, 68, 64, 61, 59, 61, 64, 67, 71, 75, 79,
+        83, 88, 93, 96, 99, 100, 70, 66, 63, 61, 60, 64, 67, 71, 75, 79, 84, 88,
+        93, 97, 100, 102,
         /* Size 32x32 */
-        64, 62, 62, 61, 66, 67, 73, 77, 83, 95, 98, 97, 98, 98, 101, 101, 104,
-        106, 109, 113, 114, 120, 123, 127, 129, 130, 134, 136, 139, 141, 144,
-        146, 62, 63, 63, 62, 68, 69, 77, 80, 85, 93, 95, 94, 94, 94, 96, 97,
-        100, 101, 104, 108, 109, 114, 117, 121, 123, 123, 127, 129, 131, 134,
-        136, 138, 62, 63, 63, 63, 68, 70, 78, 81, 85, 92, 94, 93, 93, 92, 95,
-        95, 98, 100, 102, 106, 107, 112, 114, 118, 120, 121, 125, 127, 129, 132,
-        134, 138, 61, 62, 63, 64, 69, 71, 80, 82, 85, 91, 93, 91, 91, 90, 92,
-        93, 95, 97, 99, 103, 104, 109, 111, 115, 117, 117, 121, 123, 125, 127,
-        130, 130, 66, 68, 68, 69, 75, 77, 85, 87, 89, 93, 94, 92, 92, 91, 93,
-        93, 95, 97, 99, 102, 103, 107, 110, 113, 115, 115, 119, 121, 123, 126,
-        128, 132, 67, 69, 70, 71, 77, 78, 87, 88, 90, 94, 95, 93, 92, 91, 93,
-        93, 95, 96, 99, 102, 102, 107, 109, 113, 114, 115, 118, 120, 122, 124,
-        126, 126, 73, 77, 78, 80, 85, 87, 95, 95, 95, 95, 96, 93, 92, 91, 92,
-        92, 94, 95, 97, 99, 100, 104, 106, 109, 111, 111, 114, 116, 118, 120,
-        123, 128, 77, 80, 81, 82, 87, 88, 95, 95, 96, 97, 98, 96, 95, 94, 95,
-        95, 96, 98, 99, 102, 102, 107, 108, 111, 113, 113, 116, 116, 118, 119,
-        121, 120, 83, 85, 85, 85, 89, 90, 95, 96, 97, 100, 101, 99, 99, 98, 100,
-        100, 101, 102, 104, 106, 107, 111, 112, 115, 117, 117, 120, 122, 125,
-        126, 127, 123, 95, 93, 92, 91, 93, 94, 95, 97, 100, 104, 105, 105, 105,
-        105, 106, 106, 107, 108, 110, 111, 112, 116, 117, 120, 121, 122, 124,
-        125, 123, 125, 127, 135, 98, 95, 94, 93, 94, 95, 96, 98, 101, 105, 106,
-        106, 107, 107, 108, 108, 109, 110, 111, 113, 113, 117, 119, 121, 123,
-        123, 126, 127, 131, 133, 134, 129, 97, 94, 93, 91, 92, 93, 93, 96, 99,
-        105, 106, 109, 110, 111, 113, 113, 115, 116, 117, 119, 120, 123, 125,
-        127, 129, 129, 132, 133, 131, 130, 132, 141, 98, 94, 93, 91, 92, 92, 92,
-        95, 99, 105, 107, 110, 111, 114, 115, 116, 118, 119, 120, 122, 123, 126,
-        128, 130, 132, 132, 134, 133, 136, 141, 141, 133, 98, 94, 92, 90, 91,
-        91, 91, 94, 98, 105, 107, 111, 114, 117, 119, 120, 123, 124, 125, 127,
-        127, 131, 132, 135, 136, 136, 139, 142, 141, 136, 138, 149, 101, 96, 95,
-        92, 93, 93, 92, 95, 100, 106, 108, 113, 115, 119, 122, 122, 126, 128,
-        129, 132, 133, 136, 138, 140, 141, 142, 144, 141, 141, 150, 149, 139,
-        101, 97, 95, 93, 93, 93, 92, 95, 100, 106, 108, 113, 116, 120, 122, 123,
-        127, 129, 130, 133, 134, 137, 139, 142, 143, 143, 146, 149, 151, 143,
-        144, 158, 104, 100, 98, 95, 95, 95, 94, 96, 101, 107, 109, 115, 118,
-        123, 126, 127, 133, 135, 137, 140, 141, 145, 147, 150, 151, 151, 154,
-        152, 148, 156, 158, 145, 106, 101, 100, 97, 97, 96, 95, 98, 102, 108,
-        110, 116, 119, 124, 128, 129, 135, 136, 139, 143, 143, 147, 149, 152,
-        154, 154, 156, 155, 162, 154, 151, 166, 109, 104, 102, 99, 99, 99, 97,
-        99, 104, 110, 111, 117, 120, 125, 129, 130, 137, 139, 142, 146, 147,
-        151, 153, 156, 158, 158, 161, 163, 156, 164, 169, 153, 113, 108, 106,
-        103, 102, 102, 99, 102, 106, 111, 113, 119, 122, 127, 132, 133, 140,
-        143, 146, 150, 152, 157, 159, 162, 164, 164, 167, 162, 170, 165, 159,
-        178, 114, 109, 107, 104, 103, 102, 100, 102, 107, 112, 113, 120, 123,
-        127, 133, 134, 141, 143, 147, 152, 153, 158, 160, 164, 165, 166, 169,
-        175, 167, 169, 177, 161, 120, 114, 112, 109, 107, 107, 104, 107, 111,
-        116, 117, 123, 126, 131, 136, 137, 145, 147, 151, 157, 158, 164, 166,
-        170, 172, 172, 176, 172, 177, 178, 167, 185, 123, 117, 114, 111, 110,
-        109, 106, 108, 112, 117, 119, 125, 128, 132, 138, 139, 147, 149, 153,
-        159, 160, 166, 169, 173, 175, 176, 178, 180, 179, 176, 189, 169, 127,
-        121, 118, 115, 113, 113, 109, 111, 115, 120, 121, 127, 130, 135, 140,
-        142, 150, 152, 156, 162, 164, 170, 173, 178, 180, 180, 185, 184, 182,
-        189, 176, 199, 129, 123, 120, 117, 115, 114, 111, 113, 117, 121, 123,
-        129, 132, 136, 141, 143, 151, 154, 158, 164, 165, 172, 175, 180, 182,
-        183, 186, 187, 193, 182, 197, 178, 130, 123, 121, 117, 115, 115, 111,
-        113, 117, 122, 123, 129, 132, 136, 142, 143, 151, 154, 158, 164, 166,
-        172, 176, 180, 183, 183, 187, 190, 189, 203, 184, 205, 134, 127, 125,
-        121, 119, 118, 114, 116, 120, 124, 126, 132, 134, 139, 144, 146, 154,
-        156, 161, 167, 169, 176, 178, 185, 186, 187, 192, 189, 194, 191, 212,
-        186, 136, 129, 127, 123, 121, 120, 116, 116, 122, 125, 127, 133, 133,
-        142, 141, 149, 152, 155, 163, 162, 175, 172, 180, 184, 187, 190, 189,
-        196, 192, 199, 193, 221, 139, 131, 129, 125, 123, 122, 118, 118, 125,
-        123, 131, 131, 136, 141, 141, 151, 148, 162, 156, 170, 167, 177, 179,
-        182, 193, 189, 194, 192, 201, 194, 203, 196, 141, 134, 132, 127, 126,
-        124, 120, 119, 126, 125, 133, 130, 141, 136, 150, 143, 156, 154, 164,
-        165, 169, 178, 176, 189, 182, 203, 191, 199, 194, 206, 196, 207, 144,
-        136, 134, 130, 128, 126, 123, 121, 127, 127, 134, 132, 141, 138, 149,
-        144, 158, 151, 169, 159, 177, 167, 189, 176, 197, 184, 212, 193, 203,
-        196, 212, 199, 146, 138, 138, 130, 132, 126, 128, 120, 123, 135, 129,
-        141, 133, 149, 139, 158, 145, 166, 153, 178, 161, 185, 169, 199, 178,
-        205, 186, 221, 196, 207, 199, 217,
+        32, 31, 31, 30, 33, 33, 36, 38, 41, 47, 49, 48, 49, 49, 50, 50, 52, 53,
+        54, 56, 57, 60, 61, 63, 64, 65, 67, 67, 68, 69, 70, 71, 31, 31, 31, 31,
+        34, 34, 38, 40, 42, 46, 47, 47, 47, 47, 48, 48, 50, 50, 52, 54, 54, 57,
+        58, 60, 61, 61, 63, 64, 65, 65, 66, 67, 31, 31, 31, 31, 34, 35, 39, 40,
+        42, 46, 47, 46, 46, 46, 47, 47, 49, 50, 51, 53, 53, 56, 57, 59, 60, 60,
+        62, 63, 64, 65, 66, 67, 30, 31, 31, 32, 34, 35, 40, 41, 42, 45, 46, 45,
+        45, 45, 46, 46, 47, 48, 49, 51, 52, 54, 55, 57, 58, 58, 60, 61, 62, 62,
+        63, 64, 33, 34, 34, 34, 37, 38, 42, 43, 44, 46, 47, 46, 46, 45, 46, 46,
+        47, 48, 49, 51, 51, 53, 55, 56, 57, 57, 59, 60, 61, 62, 63, 64, 33, 34,
+        35, 35, 38, 39, 43, 44, 45, 47, 47, 46, 46, 45, 46, 46, 47, 48, 49, 51,
+        51, 53, 54, 56, 57, 57, 59, 60, 60, 61, 62, 62, 36, 38, 39, 40, 42, 43,
+        47, 47, 47, 47, 48, 46, 46, 45, 46, 46, 47, 47, 48, 49, 50, 52, 53, 54,
+        55, 55, 57, 58, 59, 60, 61, 62, 38, 40, 40, 41, 43, 44, 47, 47, 48, 48,
+        49, 48, 47, 47, 47, 47, 48, 49, 49, 51, 51, 53, 54, 55, 56, 56, 58, 58,
+        58, 59, 60, 60, 41, 42, 42, 42, 44, 45, 47, 48, 48, 50, 50, 49, 49, 49,
+        50, 50, 50, 51, 52, 53, 53, 55, 56, 57, 58, 58, 60, 61, 61, 61, 60, 60,
+        47, 46, 46, 45, 46, 47, 47, 48, 50, 52, 52, 52, 52, 52, 53, 53, 53, 54,
+        55, 55, 56, 58, 58, 60, 60, 61, 62, 61, 61, 62, 63, 64, 49, 47, 47, 46,
+        47, 47, 48, 49, 50, 52, 53, 53, 53, 53, 54, 54, 54, 55, 55, 56, 56, 58,
+        59, 60, 61, 61, 63, 63, 64, 64, 64, 64, 48, 47, 46, 45, 46, 46, 46, 48,
+        49, 52, 53, 54, 55, 55, 56, 56, 57, 58, 58, 59, 60, 61, 62, 63, 64, 64,
+        66, 65, 65, 65, 66, 67, 49, 47, 46, 45, 46, 46, 46, 47, 49, 52, 53, 55,
+        55, 57, 57, 58, 59, 59, 60, 61, 61, 63, 64, 65, 66, 66, 67, 67, 67, 68,
+        67, 67, 49, 47, 46, 45, 45, 45, 45, 47, 49, 52, 53, 55, 57, 58, 59, 60,
+        61, 62, 62, 63, 63, 65, 66, 67, 68, 68, 69, 70, 69, 68, 69, 70, 50, 48,
+        47, 46, 46, 46, 46, 47, 50, 53, 54, 56, 57, 59, 61, 61, 63, 64, 64, 66,
+        66, 68, 69, 70, 70, 71, 72, 70, 71, 72, 71, 70, 50, 48, 47, 46, 46, 46,
+        46, 47, 50, 53, 54, 56, 58, 60, 61, 61, 63, 64, 65, 66, 67, 68, 69, 71,
+        71, 71, 73, 74, 73, 72, 73, 74, 52, 50, 49, 47, 47, 47, 47, 48, 50, 53,
+        54, 57, 59, 61, 63, 63, 66, 67, 68, 70, 70, 72, 73, 75, 75, 75, 77, 75,
+        75, 76, 75, 74, 53, 50, 50, 48, 48, 48, 47, 49, 51, 54, 55, 58, 59, 62,
+        64, 64, 67, 68, 69, 71, 71, 73, 74, 76, 77, 77, 78, 78, 78, 76, 77, 78,
+        54, 52, 51, 49, 49, 49, 48, 49, 52, 55, 55, 58, 60, 62, 64, 65, 68, 69,
+        71, 73, 73, 75, 76, 78, 79, 79, 80, 80, 79, 80, 79, 78, 56, 54, 53, 51,
+        51, 51, 49, 51, 53, 55, 56, 59, 61, 63, 66, 66, 70, 71, 73, 75, 76, 78,
+        79, 81, 82, 82, 83, 81, 83, 81, 81, 82, 57, 54, 53, 52, 51, 51, 50, 51,
+        53, 56, 56, 60, 61, 63, 66, 67, 70, 71, 73, 76, 76, 79, 80, 82, 82, 83,
+        84, 85, 83, 84, 84, 82, 60, 57, 56, 54, 53, 53, 52, 53, 55, 58, 58, 61,
+        63, 65, 68, 68, 72, 73, 75, 78, 79, 82, 83, 85, 86, 86, 88, 86, 87, 86,
+        85, 86, 61, 58, 57, 55, 55, 54, 53, 54, 56, 58, 59, 62, 64, 66, 69, 69,
+        73, 74, 76, 79, 80, 83, 84, 86, 87, 88, 89, 89, 88, 88, 88, 86, 63, 60,
+        59, 57, 56, 56, 54, 55, 57, 60, 60, 63, 65, 67, 70, 71, 75, 76, 78, 81,
+        82, 85, 86, 89, 90, 90, 92, 91, 91, 90, 89, 91, 64, 61, 60, 58, 57, 57,
+        55, 56, 58, 60, 61, 64, 66, 68, 70, 71, 75, 77, 79, 82, 82, 86, 87, 90,
+        91, 91, 93, 93, 93, 92, 93, 91, 65, 61, 60, 58, 57, 57, 55, 56, 58, 61,
+        61, 64, 66, 68, 71, 71, 75, 77, 79, 82, 83, 86, 88, 90, 91, 91, 93, 94,
+        95, 95, 93, 95, 67, 63, 62, 60, 59, 59, 57, 58, 60, 62, 63, 66, 67, 69,
+        72, 73, 77, 78, 80, 83, 84, 88, 89, 92, 93, 93, 95, 95, 96, 96, 97, 95,
+        67, 64, 63, 61, 60, 60, 58, 58, 61, 61, 63, 65, 67, 70, 70, 74, 75, 78,
+        80, 81, 85, 86, 89, 91, 93, 94, 95, 97, 97, 98, 98, 100, 68, 65, 64, 62,
+        61, 60, 59, 58, 61, 61, 64, 65, 67, 69, 71, 73, 75, 78, 79, 83, 83, 87,
+        88, 91, 93, 95, 96, 97, 99, 98, 100, 100, 69, 65, 65, 62, 62, 61, 60,
+        59, 61, 62, 64, 65, 68, 68, 72, 72, 76, 76, 80, 81, 84, 86, 88, 90, 92,
+        95, 96, 98, 98, 100, 100, 101, 70, 66, 66, 63, 63, 62, 61, 60, 60, 63,
+        64, 66, 67, 69, 71, 73, 75, 77, 79, 81, 84, 85, 88, 89, 93, 93, 97, 98,
+        100, 100, 102, 101, 71, 67, 67, 64, 64, 62, 62, 60, 60, 64, 64, 67, 67,
+        70, 70, 74, 74, 78, 78, 82, 82, 86, 86, 91, 91, 95, 95, 100, 100, 101,
+        101, 104,
         /* Size 4x8 */
-        63, 94, 107, 128, 72, 94, 101, 119, 92, 105, 111, 124, 91, 107, 127,
-        142, 98, 110, 142, 156, 109, 117, 155, 173, 118, 123, 163, 190, 128,
-        131, 158, 191,
+        31, 47, 53, 63, 36, 47, 50, 59, 46, 52, 55, 61, 45, 53, 63, 70, 49, 55,
+        71, 77, 54, 58, 77, 86, 59, 61, 81, 94, 63, 65, 80, 95,
         /* Size 8x4 */
-        63, 72, 92, 91, 98, 109, 118, 128, 94, 94, 105, 107, 110, 117, 123, 131,
-        107, 101, 111, 127, 142, 155, 163, 158, 128, 119, 124, 142, 156, 173,
-        190, 191,
+        31, 36, 46, 45, 49, 54, 59, 63, 47, 47, 52, 53, 55, 58, 61, 65, 53, 50,
+        55, 63, 71, 77, 81, 80, 63, 59, 61, 70, 77, 86, 94, 95,
         /* Size 8x16 */
-        64, 66, 91, 98, 105, 115, 129, 140, 62, 69, 90, 93, 98, 107, 120, 131,
-        66, 75, 92, 91, 95, 103, 115, 124, 74, 86, 95, 91, 94, 100, 111, 119,
-        84, 89, 99, 99, 101, 107, 117, 125, 98, 94, 104, 107, 109, 114, 123,
-        132, 97, 92, 103, 114, 118, 123, 132, 140, 100, 93, 104, 119, 127, 133,
-        142, 149, 104, 95, 106, 122, 133, 142, 151, 156, 109, 99, 108, 125, 137,
-        147, 158, 164, 114, 103, 111, 128, 141, 153, 166, 169, 122, 110, 116,
-        133, 147, 160, 175, 177, 129, 115, 120, 136, 151, 166, 182, 183, 133,
-        119, 124, 139, 154, 169, 186, 190, 138, 124, 125, 141, 160, 179, 191,
-        193, 143, 128, 127, 141, 158, 177, 198, 205,
+        32, 33, 45, 49, 52, 57, 64, 68, 31, 34, 45, 46, 49, 53, 60, 64, 33, 37,
+        46, 45, 47, 51, 57, 61, 37, 43, 47, 45, 47, 50, 55, 59, 42, 44, 49, 49,
+        50, 53, 58, 60, 49, 47, 52, 53, 54, 57, 61, 63, 48, 46, 51, 57, 59, 61,
+        66, 67, 50, 46, 52, 59, 63, 66, 71, 71, 52, 47, 53, 61, 66, 71, 75, 74,
+        54, 49, 54, 62, 68, 73, 79, 79, 57, 51, 55, 64, 70, 76, 83, 83, 61, 55,
+        58, 66, 73, 80, 87, 87, 64, 57, 60, 68, 75, 83, 91, 91, 66, 59, 61, 69,
+        77, 84, 93, 95, 68, 61, 61, 68, 77, 86, 94, 97, 70, 63, 61, 67, 75, 83,
+        92, 98,
         /* Size 16x8 */
-        64, 62, 66, 74, 84, 98, 97, 100, 104, 109, 114, 122, 129, 133, 138, 143,
-        66, 69, 75, 86, 89, 94, 92, 93, 95, 99, 103, 110, 115, 119, 124, 128,
-        91, 90, 92, 95, 99, 104, 103, 104, 106, 108, 111, 116, 120, 124, 125,
-        127, 98, 93, 91, 91, 99, 107, 114, 119, 122, 125, 128, 133, 136, 139,
-        141, 141, 105, 98, 95, 94, 101, 109, 118, 127, 133, 137, 141, 147, 151,
-        154, 160, 158, 115, 107, 103, 100, 107, 114, 123, 133, 142, 147, 153,
-        160, 166, 169, 179, 177, 129, 120, 115, 111, 117, 123, 132, 142, 151,
-        158, 166, 175, 182, 186, 191, 198, 140, 131, 124, 119, 125, 132, 140,
-        149, 156, 164, 169, 177, 183, 190, 193, 205,
+        32, 31, 33, 37, 42, 49, 48, 50, 52, 54, 57, 61, 64, 66, 68, 70, 33, 34,
+        37, 43, 44, 47, 46, 46, 47, 49, 51, 55, 57, 59, 61, 63, 45, 45, 46, 47,
+        49, 52, 51, 52, 53, 54, 55, 58, 60, 61, 61, 61, 49, 46, 45, 45, 49, 53,
+        57, 59, 61, 62, 64, 66, 68, 69, 68, 67, 52, 49, 47, 47, 50, 54, 59, 63,
+        66, 68, 70, 73, 75, 77, 77, 75, 57, 53, 51, 50, 53, 57, 61, 66, 71, 73,
+        76, 80, 83, 84, 86, 83, 64, 60, 57, 55, 58, 61, 66, 71, 75, 79, 83, 87,
+        91, 93, 94, 92, 68, 64, 61, 59, 60, 63, 67, 71, 74, 79, 83, 87, 91, 95,
+        97, 98,
         /* Size 16x32 */
-        64, 62, 66, 74, 91, 96, 98, 101, 105, 112, 115, 127, 129, 135, 140, 144,
-        63, 63, 68, 77, 90, 94, 94, 97, 100, 107, 109, 120, 123, 128, 132, 136,
-        62, 64, 69, 78, 90, 93, 93, 95, 98, 105, 107, 118, 120, 126, 131, 136,
-        61, 64, 70, 80, 89, 92, 91, 93, 96, 102, 104, 115, 117, 122, 126, 128,
-        66, 70, 75, 85, 92, 94, 91, 93, 95, 101, 103, 113, 115, 120, 124, 130,
-        67, 72, 77, 86, 92, 94, 92, 93, 95, 101, 103, 112, 114, 119, 123, 125,
-        74, 80, 86, 94, 95, 95, 91, 92, 94, 99, 100, 109, 111, 115, 119, 126,
-        78, 82, 87, 95, 97, 97, 94, 95, 97, 101, 103, 111, 113, 116, 118, 119,
-        84, 86, 89, 95, 99, 100, 99, 100, 101, 106, 107, 115, 117, 122, 125,
-        122, 95, 92, 93, 96, 103, 105, 106, 106, 107, 111, 112, 120, 122, 124,
-        124, 134, 98, 93, 94, 96, 104, 106, 107, 108, 109, 113, 114, 121, 123,
-        127, 132, 127, 97, 92, 93, 94, 103, 106, 112, 113, 115, 119, 120, 128,
-        129, 133, 129, 140, 97, 91, 92, 93, 103, 106, 114, 115, 118, 122, 123,
-        130, 132, 133, 140, 132, 98, 91, 91, 92, 103, 107, 117, 119, 123, 127,
-        128, 135, 136, 142, 135, 148, 100, 93, 93, 93, 104, 108, 119, 122, 127,
-        131, 133, 140, 142, 141, 149, 138, 101, 93, 93, 93, 105, 108, 119, 123,
-        128, 133, 134, 142, 143, 148, 143, 157, 104, 96, 95, 95, 106, 109, 122,
-        127, 133, 140, 142, 150, 151, 152, 156, 144, 106, 98, 97, 96, 107, 110,
-        123, 128, 135, 142, 144, 152, 154, 156, 153, 165, 109, 100, 99, 98, 108,
-        111, 125, 130, 137, 145, 147, 156, 158, 163, 164, 152, 113, 103, 102,
-        100, 110, 113, 127, 132, 140, 149, 152, 162, 164, 162, 164, 177, 114,
-        104, 103, 101, 111, 113, 128, 133, 141, 151, 153, 164, 166, 174, 169,
-        160, 120, 109, 108, 105, 115, 117, 131, 136, 145, 155, 158, 170, 172,
-        173, 175, 184, 122, 112, 110, 107, 116, 119, 133, 138, 147, 158, 160,
-        173, 175, 179, 177, 167, 127, 115, 113, 110, 119, 121, 135, 140, 150,
-        161, 164, 178, 180, 184, 186, 197, 129, 117, 115, 112, 120, 123, 136,
-        142, 151, 162, 166, 180, 182, 187, 183, 176, 129, 118, 116, 112, 121,
-        123, 136, 142, 151, 163, 166, 180, 183, 190, 200, 203, 133, 122, 119,
-        115, 124, 126, 139, 144, 154, 165, 169, 185, 186, 189, 190, 184, 136,
-        124, 121, 117, 124, 127, 141, 141, 156, 163, 171, 184, 186, 195, 198,
-        219, 138, 126, 124, 119, 125, 129, 141, 142, 160, 157, 179, 179, 191,
-        195, 193, 194, 141, 128, 126, 121, 126, 131, 141, 143, 159, 158, 179,
-        174, 200, 191, 205, 205, 143, 130, 128, 122, 127, 132, 141, 144, 158,
-        159, 177, 176, 198, 193, 205, 197, 145, 131, 132, 122, 124, 140, 134,
-        157, 146, 177, 161, 197, 178, 218, 195, 215,
+        32, 31, 33, 37, 45, 48, 49, 50, 52, 56, 57, 63, 64, 67, 68, 68, 31, 31,
+        34, 38, 45, 47, 47, 48, 50, 53, 54, 60, 61, 63, 64, 65, 31, 32, 34, 39,
+        45, 46, 46, 47, 49, 52, 53, 59, 60, 62, 64, 65, 30, 32, 35, 40, 44, 46,
+        45, 46, 48, 51, 52, 57, 58, 60, 61, 62, 33, 35, 37, 42, 46, 47, 45, 46,
+        47, 50, 51, 56, 57, 60, 61, 62, 33, 36, 38, 43, 46, 47, 46, 46, 47, 50,
+        51, 56, 57, 59, 60, 60, 37, 40, 43, 47, 47, 47, 45, 46, 47, 49, 50, 54,
+        55, 57, 59, 61, 39, 41, 43, 47, 48, 48, 47, 47, 48, 50, 51, 55, 56, 57,
+        58, 59, 42, 43, 44, 47, 49, 50, 49, 50, 50, 53, 53, 57, 58, 60, 60, 59,
+        47, 46, 46, 48, 51, 52, 53, 53, 53, 55, 56, 60, 61, 61, 61, 62, 49, 46,
+        47, 48, 52, 53, 53, 54, 54, 56, 57, 60, 61, 63, 63, 62, 48, 46, 46, 47,
+        51, 53, 56, 56, 57, 59, 60, 64, 64, 65, 64, 65, 48, 45, 46, 46, 51, 53,
+        57, 57, 59, 61, 61, 65, 66, 66, 67, 65, 49, 45, 45, 46, 51, 53, 58, 59,
+        61, 63, 64, 67, 68, 70, 67, 68, 50, 46, 46, 46, 52, 54, 59, 61, 63, 65,
+        66, 70, 71, 70, 71, 68, 50, 46, 46, 46, 52, 54, 59, 61, 64, 66, 67, 71,
+        71, 73, 71, 72, 52, 48, 47, 47, 53, 54, 61, 63, 66, 70, 71, 75, 75, 75,
+        74, 72, 53, 49, 48, 48, 53, 55, 61, 64, 67, 71, 72, 76, 77, 77, 75, 76,
+        54, 50, 49, 49, 54, 55, 62, 65, 68, 72, 73, 78, 79, 80, 79, 76, 56, 51,
+        51, 50, 55, 56, 63, 66, 70, 74, 76, 81, 82, 81, 80, 80, 57, 52, 51, 50,
+        55, 56, 64, 66, 70, 75, 76, 82, 83, 85, 83, 80, 60, 54, 54, 52, 57, 58,
+        65, 68, 72, 77, 79, 85, 86, 86, 85, 84, 61, 56, 55, 53, 58, 59, 66, 69,
+        73, 79, 80, 86, 87, 89, 87, 84, 63, 57, 56, 55, 59, 60, 67, 70, 75, 80,
+        82, 89, 90, 91, 89, 89, 64, 58, 57, 56, 60, 61, 68, 71, 75, 81, 83, 90,
+        91, 93, 91, 89, 64, 59, 58, 56, 60, 61, 68, 71, 75, 81, 83, 90, 91, 94,
+        94, 93, 66, 60, 59, 57, 61, 63, 69, 72, 77, 82, 84, 92, 93, 94, 95, 93,
+        67, 61, 60, 58, 61, 63, 69, 70, 78, 80, 85, 90, 93, 96, 97, 97, 68, 62,
+        61, 59, 61, 64, 68, 71, 77, 79, 86, 88, 94, 96, 97, 98, 69, 63, 62, 59,
+        61, 65, 68, 72, 76, 80, 85, 88, 94, 95, 99, 99, 70, 63, 63, 60, 61, 66,
+        67, 73, 75, 81, 83, 89, 92, 97, 98, 99, 70, 64, 64, 61, 61, 67, 67, 74,
+        74, 82, 82, 90, 90, 98, 98, 102,
         /* Size 32x16 */
-        64, 63, 62, 61, 66, 67, 74, 78, 84, 95, 98, 97, 97, 98, 100, 101, 104,
-        106, 109, 113, 114, 120, 122, 127, 129, 129, 133, 136, 138, 141, 143,
-        145, 62, 63, 64, 64, 70, 72, 80, 82, 86, 92, 93, 92, 91, 91, 93, 93, 96,
-        98, 100, 103, 104, 109, 112, 115, 117, 118, 122, 124, 126, 128, 130,
-        131, 66, 68, 69, 70, 75, 77, 86, 87, 89, 93, 94, 93, 92, 91, 93, 93, 95,
-        97, 99, 102, 103, 108, 110, 113, 115, 116, 119, 121, 124, 126, 128, 132,
-        74, 77, 78, 80, 85, 86, 94, 95, 95, 96, 96, 94, 93, 92, 93, 93, 95, 96,
-        98, 100, 101, 105, 107, 110, 112, 112, 115, 117, 119, 121, 122, 122, 91,
-        90, 90, 89, 92, 92, 95, 97, 99, 103, 104, 103, 103, 103, 104, 105, 106,
-        107, 108, 110, 111, 115, 116, 119, 120, 121, 124, 124, 125, 126, 127,
-        124, 96, 94, 93, 92, 94, 94, 95, 97, 100, 105, 106, 106, 106, 107, 108,
-        108, 109, 110, 111, 113, 113, 117, 119, 121, 123, 123, 126, 127, 129,
-        131, 132, 140, 98, 94, 93, 91, 91, 92, 91, 94, 99, 106, 107, 112, 114,
-        117, 119, 119, 122, 123, 125, 127, 128, 131, 133, 135, 136, 136, 139,
-        141, 141, 141, 141, 134, 101, 97, 95, 93, 93, 93, 92, 95, 100, 106, 108,
-        113, 115, 119, 122, 123, 127, 128, 130, 132, 133, 136, 138, 140, 142,
-        142, 144, 141, 142, 143, 144, 157, 105, 100, 98, 96, 95, 95, 94, 97,
-        101, 107, 109, 115, 118, 123, 127, 128, 133, 135, 137, 140, 141, 145,
-        147, 150, 151, 151, 154, 156, 160, 159, 158, 146, 112, 107, 105, 102,
-        101, 101, 99, 101, 106, 111, 113, 119, 122, 127, 131, 133, 140, 142,
-        145, 149, 151, 155, 158, 161, 162, 163, 165, 163, 157, 158, 159, 177,
-        115, 109, 107, 104, 103, 103, 100, 103, 107, 112, 114, 120, 123, 128,
-        133, 134, 142, 144, 147, 152, 153, 158, 160, 164, 166, 166, 169, 171,
-        179, 179, 177, 161, 127, 120, 118, 115, 113, 112, 109, 111, 115, 120,
-        121, 128, 130, 135, 140, 142, 150, 152, 156, 162, 164, 170, 173, 178,
-        180, 180, 185, 184, 179, 174, 176, 197, 129, 123, 120, 117, 115, 114,
-        111, 113, 117, 122, 123, 129, 132, 136, 142, 143, 151, 154, 158, 164,
-        166, 172, 175, 180, 182, 183, 186, 186, 191, 200, 198, 178, 135, 128,
-        126, 122, 120, 119, 115, 116, 122, 124, 127, 133, 133, 142, 141, 148,
-        152, 156, 163, 162, 174, 173, 179, 184, 187, 190, 189, 195, 195, 191,
-        193, 218, 140, 132, 131, 126, 124, 123, 119, 118, 125, 124, 132, 129,
-        140, 135, 149, 143, 156, 153, 164, 164, 169, 175, 177, 186, 183, 200,
-        190, 198, 193, 205, 205, 195, 144, 136, 136, 128, 130, 125, 126, 119,
-        122, 134, 127, 140, 132, 148, 138, 157, 144, 165, 152, 177, 160, 184,
-        167, 197, 176, 203, 184, 219, 194, 205, 197, 215,
+        32, 31, 31, 30, 33, 33, 37, 39, 42, 47, 49, 48, 48, 49, 50, 50, 52, 53,
+        54, 56, 57, 60, 61, 63, 64, 64, 66, 67, 68, 69, 70, 70, 31, 31, 32, 32,
+        35, 36, 40, 41, 43, 46, 46, 46, 45, 45, 46, 46, 48, 49, 50, 51, 52, 54,
+        56, 57, 58, 59, 60, 61, 62, 63, 63, 64, 33, 34, 34, 35, 37, 38, 43, 43,
+        44, 46, 47, 46, 46, 45, 46, 46, 47, 48, 49, 51, 51, 54, 55, 56, 57, 58,
+        59, 60, 61, 62, 63, 64, 37, 38, 39, 40, 42, 43, 47, 47, 47, 48, 48, 47,
+        46, 46, 46, 46, 47, 48, 49, 50, 50, 52, 53, 55, 56, 56, 57, 58, 59, 59,
+        60, 61, 45, 45, 45, 44, 46, 46, 47, 48, 49, 51, 52, 51, 51, 51, 52, 52,
+        53, 53, 54, 55, 55, 57, 58, 59, 60, 60, 61, 61, 61, 61, 61, 61, 48, 47,
+        46, 46, 47, 47, 47, 48, 50, 52, 53, 53, 53, 53, 54, 54, 54, 55, 55, 56,
+        56, 58, 59, 60, 61, 61, 63, 63, 64, 65, 66, 67, 49, 47, 46, 45, 45, 46,
+        45, 47, 49, 53, 53, 56, 57, 58, 59, 59, 61, 61, 62, 63, 64, 65, 66, 67,
+        68, 68, 69, 69, 68, 68, 67, 67, 50, 48, 47, 46, 46, 46, 46, 47, 50, 53,
+        54, 56, 57, 59, 61, 61, 63, 64, 65, 66, 66, 68, 69, 70, 71, 71, 72, 70,
+        71, 72, 73, 74, 52, 50, 49, 48, 47, 47, 47, 48, 50, 53, 54, 57, 59, 61,
+        63, 64, 66, 67, 68, 70, 70, 72, 73, 75, 75, 75, 77, 78, 77, 76, 75, 74,
+        56, 53, 52, 51, 50, 50, 49, 50, 53, 55, 56, 59, 61, 63, 65, 66, 70, 71,
+        72, 74, 75, 77, 79, 80, 81, 81, 82, 80, 79, 80, 81, 82, 57, 54, 53, 52,
+        51, 51, 50, 51, 53, 56, 57, 60, 61, 64, 66, 67, 71, 72, 73, 76, 76, 79,
+        80, 82, 83, 83, 84, 85, 86, 85, 83, 82, 63, 60, 59, 57, 56, 56, 54, 55,
+        57, 60, 60, 64, 65, 67, 70, 71, 75, 76, 78, 81, 82, 85, 86, 89, 90, 90,
+        92, 90, 88, 88, 89, 90, 64, 61, 60, 58, 57, 57, 55, 56, 58, 61, 61, 64,
+        66, 68, 71, 71, 75, 77, 79, 82, 83, 86, 87, 90, 91, 91, 93, 93, 94, 94,
+        92, 90, 67, 63, 62, 60, 60, 59, 57, 57, 60, 61, 63, 65, 66, 70, 70, 73,
+        75, 77, 80, 81, 85, 86, 89, 91, 93, 94, 94, 96, 96, 95, 97, 98, 68, 64,
+        64, 61, 61, 60, 59, 58, 60, 61, 63, 64, 67, 67, 71, 71, 74, 75, 79, 80,
+        83, 85, 87, 89, 91, 94, 95, 97, 97, 99, 98, 98, 68, 65, 65, 62, 62, 60,
+        61, 59, 59, 62, 62, 65, 65, 68, 68, 72, 72, 76, 76, 80, 80, 84, 84, 89,
+        89, 93, 93, 97, 98, 99, 99, 102,
         /* Size 4x16 */
-        62, 96, 112, 135, 64, 93, 105, 126, 70, 94, 101, 120, 80, 95, 99, 115,
-        86, 100, 106, 122, 93, 106, 113, 127, 91, 106, 122, 133, 93, 108, 131,
-        141, 96, 109, 140, 152, 100, 111, 145, 163, 104, 113, 151, 174, 112,
-        119, 158, 179, 117, 123, 162, 187, 122, 126, 165, 189, 126, 129, 157,
-        195, 130, 132, 159, 193,
+        31, 48, 56, 67, 32, 46, 52, 62, 35, 47, 50, 60, 40, 47, 49, 57, 43, 50,
+        53, 60, 46, 53, 56, 63, 45, 53, 61, 66, 46, 54, 65, 70, 48, 54, 70, 75,
+        50, 55, 72, 80, 52, 56, 75, 85, 56, 59, 79, 89, 58, 61, 81, 93, 60, 63,
+        82, 94, 62, 64, 79, 96, 63, 66, 81, 97,
         /* Size 16x4 */
-        62, 64, 70, 80, 86, 93, 91, 93, 96, 100, 104, 112, 117, 122, 126, 130,
-        96, 93, 94, 95, 100, 106, 106, 108, 109, 111, 113, 119, 123, 126, 129,
-        132, 112, 105, 101, 99, 106, 113, 122, 131, 140, 145, 151, 158, 162,
-        165, 157, 159, 135, 126, 120, 115, 122, 127, 133, 141, 152, 163, 174,
-        179, 187, 189, 195, 193,
+        31, 32, 35, 40, 43, 46, 45, 46, 48, 50, 52, 56, 58, 60, 62, 63, 48, 46,
+        47, 47, 50, 53, 53, 54, 54, 55, 56, 59, 61, 63, 64, 66, 56, 52, 50, 49,
+        53, 56, 61, 65, 70, 72, 75, 79, 81, 82, 79, 81, 67, 62, 60, 57, 60, 63,
+        66, 70, 75, 80, 85, 89, 93, 94, 96, 97,
         /* Size 8x32 */
-        64, 66, 91, 98, 105, 115, 129, 140, 63, 68, 90, 94, 100, 109, 123, 132,
-        62, 69, 90, 93, 98, 107, 120, 131, 61, 70, 89, 91, 96, 104, 117, 126,
-        66, 75, 92, 91, 95, 103, 115, 124, 67, 77, 92, 92, 95, 103, 114, 123,
-        74, 86, 95, 91, 94, 100, 111, 119, 78, 87, 97, 94, 97, 103, 113, 118,
-        84, 89, 99, 99, 101, 107, 117, 125, 95, 93, 103, 106, 107, 112, 122,
-        124, 98, 94, 104, 107, 109, 114, 123, 132, 97, 93, 103, 112, 115, 120,
-        129, 129, 97, 92, 103, 114, 118, 123, 132, 140, 98, 91, 103, 117, 123,
-        128, 136, 135, 100, 93, 104, 119, 127, 133, 142, 149, 101, 93, 105, 119,
-        128, 134, 143, 143, 104, 95, 106, 122, 133, 142, 151, 156, 106, 97, 107,
-        123, 135, 144, 154, 153, 109, 99, 108, 125, 137, 147, 158, 164, 113,
-        102, 110, 127, 140, 152, 164, 164, 114, 103, 111, 128, 141, 153, 166,
-        169, 120, 108, 115, 131, 145, 158, 172, 175, 122, 110, 116, 133, 147,
-        160, 175, 177, 127, 113, 119, 135, 150, 164, 180, 186, 129, 115, 120,
-        136, 151, 166, 182, 183, 129, 116, 121, 136, 151, 166, 183, 200, 133,
-        119, 124, 139, 154, 169, 186, 190, 136, 121, 124, 141, 156, 171, 186,
-        198, 138, 124, 125, 141, 160, 179, 191, 193, 141, 126, 126, 141, 159,
-        179, 200, 205, 143, 128, 127, 141, 158, 177, 198, 205, 145, 132, 124,
-        134, 146, 161, 178, 195,
+        32, 33, 45, 49, 52, 57, 64, 68, 31, 34, 45, 47, 50, 54, 61, 64, 31, 34,
+        45, 46, 49, 53, 60, 64, 30, 35, 44, 45, 48, 52, 58, 61, 33, 37, 46, 45,
+        47, 51, 57, 61, 33, 38, 46, 46, 47, 51, 57, 60, 37, 43, 47, 45, 47, 50,
+        55, 59, 39, 43, 48, 47, 48, 51, 56, 58, 42, 44, 49, 49, 50, 53, 58, 60,
+        47, 46, 51, 53, 53, 56, 61, 61, 49, 47, 52, 53, 54, 57, 61, 63, 48, 46,
+        51, 56, 57, 60, 64, 64, 48, 46, 51, 57, 59, 61, 66, 67, 49, 45, 51, 58,
+        61, 64, 68, 67, 50, 46, 52, 59, 63, 66, 71, 71, 50, 46, 52, 59, 64, 67,
+        71, 71, 52, 47, 53, 61, 66, 71, 75, 74, 53, 48, 53, 61, 67, 72, 77, 75,
+        54, 49, 54, 62, 68, 73, 79, 79, 56, 51, 55, 63, 70, 76, 82, 80, 57, 51,
+        55, 64, 70, 76, 83, 83, 60, 54, 57, 65, 72, 79, 86, 85, 61, 55, 58, 66,
+        73, 80, 87, 87, 63, 56, 59, 67, 75, 82, 90, 89, 64, 57, 60, 68, 75, 83,
+        91, 91, 64, 58, 60, 68, 75, 83, 91, 94, 66, 59, 61, 69, 77, 84, 93, 95,
+        67, 60, 61, 69, 78, 85, 93, 97, 68, 61, 61, 68, 77, 86, 94, 97, 69, 62,
+        61, 68, 76, 85, 94, 99, 70, 63, 61, 67, 75, 83, 92, 98, 70, 64, 61, 67,
+        74, 82, 90, 98,
         /* Size 32x8 */
-        64, 63, 62, 61, 66, 67, 74, 78, 84, 95, 98, 97, 97, 98, 100, 101, 104,
-        106, 109, 113, 114, 120, 122, 127, 129, 129, 133, 136, 138, 141, 143,
-        145, 66, 68, 69, 70, 75, 77, 86, 87, 89, 93, 94, 93, 92, 91, 93, 93, 95,
-        97, 99, 102, 103, 108, 110, 113, 115, 116, 119, 121, 124, 126, 128, 132,
-        91, 90, 90, 89, 92, 92, 95, 97, 99, 103, 104, 103, 103, 103, 104, 105,
-        106, 107, 108, 110, 111, 115, 116, 119, 120, 121, 124, 124, 125, 126,
-        127, 124, 98, 94, 93, 91, 91, 92, 91, 94, 99, 106, 107, 112, 114, 117,
-        119, 119, 122, 123, 125, 127, 128, 131, 133, 135, 136, 136, 139, 141,
-        141, 141, 141, 134, 105, 100, 98, 96, 95, 95, 94, 97, 101, 107, 109,
-        115, 118, 123, 127, 128, 133, 135, 137, 140, 141, 145, 147, 150, 151,
-        151, 154, 156, 160, 159, 158, 146, 115, 109, 107, 104, 103, 103, 100,
-        103, 107, 112, 114, 120, 123, 128, 133, 134, 142, 144, 147, 152, 153,
-        158, 160, 164, 166, 166, 169, 171, 179, 179, 177, 161, 129, 123, 120,
-        117, 115, 114, 111, 113, 117, 122, 123, 129, 132, 136, 142, 143, 151,
-        154, 158, 164, 166, 172, 175, 180, 182, 183, 186, 186, 191, 200, 198,
-        178, 140, 132, 131, 126, 124, 123, 119, 118, 125, 124, 132, 129, 140,
-        135, 149, 143, 156, 153, 164, 164, 169, 175, 177, 186, 183, 200, 190,
-        198, 193, 205, 205, 195 },
+        32, 31, 31, 30, 33, 33, 37, 39, 42, 47, 49, 48, 48, 49, 50, 50, 52, 53,
+        54, 56, 57, 60, 61, 63, 64, 64, 66, 67, 68, 69, 70, 70, 33, 34, 34, 35,
+        37, 38, 43, 43, 44, 46, 47, 46, 46, 45, 46, 46, 47, 48, 49, 51, 51, 54,
+        55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 45, 45, 45, 44, 46, 46, 47, 48,
+        49, 51, 52, 51, 51, 51, 52, 52, 53, 53, 54, 55, 55, 57, 58, 59, 60, 60,
+        61, 61, 61, 61, 61, 61, 49, 47, 46, 45, 45, 46, 45, 47, 49, 53, 53, 56,
+        57, 58, 59, 59, 61, 61, 62, 63, 64, 65, 66, 67, 68, 68, 69, 69, 68, 68,
+        67, 67, 52, 50, 49, 48, 47, 47, 47, 48, 50, 53, 54, 57, 59, 61, 63, 64,
+        66, 67, 68, 70, 70, 72, 73, 75, 75, 75, 77, 78, 77, 76, 75, 74, 57, 54,
+        53, 52, 51, 51, 50, 51, 53, 56, 57, 60, 61, 64, 66, 67, 71, 72, 73, 76,
+        76, 79, 80, 82, 83, 83, 84, 85, 86, 85, 83, 82, 64, 61, 60, 58, 57, 57,
+        55, 56, 58, 61, 61, 64, 66, 68, 71, 71, 75, 77, 79, 82, 83, 86, 87, 90,
+        91, 91, 93, 93, 94, 94, 92, 90, 68, 64, 64, 61, 61, 60, 59, 58, 60, 61,
+        63, 64, 67, 67, 71, 71, 74, 75, 79, 80, 83, 85, 87, 89, 91, 94, 95, 97,
+        97, 99, 98, 98 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        71, 126, 126, 235,
+        35, 63, 63, 117,
 #endif
         /* Size 4x4 */
-        65, 69, 107, 150, 69, 98, 128, 163, 107, 128, 182, 225, 150, 163, 225,
-        280,
+        32, 34, 53, 75, 34, 49, 64, 81, 53, 64, 91, 112, 75, 81, 112, 140,
         /* Size 8x8 */
-        64, 64, 68, 79, 100, 125, 152, 170, 64, 67, 71, 80, 97, 118, 143, 159,
-        68, 71, 79, 92, 107, 126, 148, 163, 79, 80, 92, 113, 131, 150, 172, 183,
-        100, 97, 107, 131, 157, 180, 203, 211, 125, 118, 126, 150, 180, 210,
-        237, 247, 152, 143, 148, 172, 203, 237, 268, 289, 170, 159, 163, 183,
-        211, 247, 289, 308,
+        32, 32, 34, 39, 50, 62, 76, 84, 32, 33, 35, 40, 48, 59, 71, 79, 34, 35,
+        39, 46, 53, 63, 74, 81, 39, 40, 46, 56, 65, 75, 86, 92, 50, 48, 53, 65,
+        78, 90, 101, 106, 62, 59, 63, 75, 90, 105, 118, 123, 76, 71, 74, 86,
+        101, 118, 134, 142, 84, 79, 81, 92, 106, 123, 142, 153,
         /* Size 16x16 */
-        64, 63, 63, 64, 67, 72, 79, 88, 97, 108, 118, 133, 149, 163, 173, 184,
-        63, 64, 64, 65, 67, 70, 77, 84, 92, 102, 112, 126, 141, 154, 162, 174,
-        63, 64, 65, 66, 68, 70, 76, 83, 90, 99, 108, 121, 135, 147, 155, 166,
-        64, 65, 66, 69, 72, 75, 80, 85, 91, 99, 107, 119, 132, 143, 151, 161,
-        67, 67, 68, 72, 77, 84, 88, 93, 100, 107, 115, 126, 139, 149, 157, 163,
-        72, 70, 70, 75, 84, 97, 101, 108, 114, 120, 128, 138, 150, 160, 168,
-        173, 79, 77, 76, 80, 88, 101, 108, 116, 122, 130, 138, 148, 161, 171,
-        178, 185, 88, 84, 83, 85, 93, 108, 116, 127, 134, 143, 151, 161, 173,
-        183, 190, 198, 97, 92, 90, 91, 100, 114, 122, 134, 142, 153, 161, 173,
-        186, 196, 203, 212, 108, 102, 99, 99, 107, 120, 130, 143, 153, 165, 174,
-        187, 200, 211, 218, 229, 118, 112, 108, 107, 115, 128, 138, 151, 161,
-        174, 184, 198, 213, 224, 232, 245, 133, 126, 121, 119, 126, 138, 148,
-        161, 173, 187, 198, 215, 230, 242, 251, 265, 149, 141, 135, 132, 139,
-        150, 161, 173, 186, 200, 213, 230, 247, 261, 270, 282, 163, 154, 147,
-        143, 149, 160, 171, 183, 196, 211, 224, 242, 261, 275, 285, 307, 173,
-        162, 155, 151, 157, 168, 178, 190, 203, 218, 232, 251, 270, 285, 295,
-        305, 184, 174, 166, 161, 163, 173, 185, 198, 212, 229, 245, 265, 282,
-        307, 305, 319,
+        32, 31, 31, 32, 33, 36, 39, 44, 48, 54, 59, 66, 74, 81, 86, 91, 31, 32,
+        32, 32, 33, 35, 38, 42, 46, 51, 56, 63, 70, 77, 81, 86, 31, 32, 32, 33,
+        34, 35, 38, 41, 45, 49, 54, 60, 67, 73, 77, 82, 32, 32, 33, 34, 36, 37,
+        40, 42, 45, 49, 53, 59, 66, 71, 75, 80, 33, 33, 34, 36, 38, 42, 44, 46,
+        50, 53, 57, 63, 69, 74, 78, 80, 36, 35, 35, 37, 42, 48, 50, 54, 57, 60,
+        64, 69, 75, 80, 84, 85, 39, 38, 38, 40, 44, 50, 54, 58, 61, 65, 69, 74,
+        80, 85, 89, 91, 44, 42, 41, 42, 46, 54, 58, 63, 67, 71, 75, 80, 86, 91,
+        95, 97, 48, 46, 45, 45, 50, 57, 61, 67, 71, 76, 80, 86, 93, 98, 101,
+        104, 54, 51, 49, 49, 53, 60, 65, 71, 76, 82, 87, 93, 100, 105, 109, 112,
+        59, 56, 54, 53, 57, 64, 69, 75, 80, 87, 92, 99, 106, 112, 116, 120, 66,
+        63, 60, 59, 63, 69, 74, 80, 86, 93, 99, 107, 115, 121, 125, 129, 74, 70,
+        67, 66, 69, 75, 80, 86, 93, 100, 106, 115, 123, 130, 135, 138, 81, 77,
+        73, 71, 74, 80, 85, 91, 98, 105, 112, 121, 130, 137, 142, 148, 86, 81,
+        77, 75, 78, 84, 89, 95, 101, 109, 116, 125, 135, 142, 147, 153, 91, 86,
+        82, 80, 80, 85, 91, 97, 104, 112, 120, 129, 138, 148, 153, 159,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 64, 64, 67, 68, 72, 72, 79, 82, 88, 92, 97, 104,
-        108, 117, 118, 131, 133, 143, 149, 160, 163, 166, 173, 179, 184, 190,
-        63, 64, 64, 64, 64, 64, 65, 65, 67, 68, 70, 71, 77, 79, 85, 89, 93, 100,
-        103, 112, 113, 125, 127, 136, 142, 152, 155, 157, 164, 170, 175, 179,
-        63, 64, 64, 64, 64, 65, 65, 65, 67, 68, 70, 71, 77, 79, 84, 88, 92, 99,
-        102, 111, 112, 123, 126, 135, 141, 150, 154, 156, 162, 168, 174, 180,
-        63, 64, 64, 65, 65, 65, 65, 65, 67, 67, 69, 69, 75, 77, 82, 85, 89, 96,
-        99, 107, 108, 119, 121, 130, 136, 145, 148, 150, 156, 162, 167, 170, 63,
-        64, 64, 65, 65, 66, 66, 66, 68, 69, 70, 71, 76, 78, 83, 86, 90, 96, 99,
-        107, 108, 119, 121, 130, 135, 144, 147, 149, 155, 161, 166, 171, 63, 64,
-        65, 65, 66, 67, 67, 68, 70, 71, 73, 73, 78, 80, 84, 88, 91, 97, 100,
-        107, 108, 118, 120, 129, 134, 143, 146, 148, 154, 159, 163, 167, 64, 65,
-        65, 65, 66, 67, 69, 70, 72, 72, 75, 76, 80, 81, 85, 88, 91, 97, 99, 106,
-        107, 117, 119, 127, 132, 140, 143, 145, 151, 156, 161, 168, 64, 65, 65,
-        65, 66, 68, 70, 71, 73, 74, 77, 77, 81, 82, 85, 88, 92, 97, 99, 106,
-        107, 116, 118, 126, 131, 139, 142, 144, 149, 154, 158, 161, 67, 67, 67,
-        67, 68, 70, 72, 73, 77, 78, 84, 84, 88, 90, 93, 96, 100, 105, 107, 114,
-        115, 124, 126, 134, 139, 146, 149, 151, 157, 160, 163, 162, 68, 68, 68,
-        67, 69, 71, 72, 74, 78, 79, 85, 86, 90, 92, 95, 99, 102, 107, 109, 116,
-        117, 126, 128, 136, 141, 148, 151, 153, 159, 163, 167, 177, 72, 70, 70,
-        69, 70, 73, 75, 77, 84, 85, 97, 97, 101, 103, 108, 111, 114, 118, 120,
-        127, 128, 136, 138, 146, 150, 158, 160, 162, 168, 171, 173, 171, 72, 71,
-        71, 69, 71, 73, 76, 77, 84, 86, 97, 98, 102, 104, 108, 111, 114, 119,
-        121, 128, 129, 137, 139, 147, 151, 159, 161, 163, 169, 172, 176, 186,
-        79, 77, 77, 75, 76, 78, 80, 81, 88, 90, 101, 102, 108, 110, 116, 119,
-        122, 128, 130, 137, 138, 147, 148, 156, 161, 168, 171, 173, 178, 183,
-        185, 180, 82, 79, 79, 77, 78, 80, 81, 82, 90, 92, 103, 104, 110, 113,
-        119, 122, 126, 131, 134, 141, 141, 150, 152, 160, 164, 172, 175, 176,
-        182, 183, 187, 199, 88, 85, 84, 82, 83, 84, 85, 85, 93, 95, 108, 108,
-        116, 119, 127, 130, 134, 140, 143, 150, 151, 159, 161, 169, 173, 181,
-        183, 185, 190, 197, 198, 191, 92, 89, 88, 85, 86, 88, 88, 88, 96, 99,
-        111, 111, 119, 122, 130, 134, 138, 145, 148, 155, 156, 165, 167, 175,
-        179, 187, 189, 191, 196, 195, 198, 213, 97, 93, 92, 89, 90, 91, 91, 92,
-        100, 102, 114, 114, 122, 126, 134, 138, 142, 149, 153, 160, 161, 171,
-        173, 181, 186, 193, 196, 198, 203, 210, 212, 202, 104, 100, 99, 96, 96,
-        97, 97, 97, 105, 107, 118, 119, 128, 131, 140, 145, 149, 157, 161, 169,
-        170, 180, 182, 191, 195, 203, 206, 208, 213, 211, 211, 227, 108, 103,
-        102, 99, 99, 100, 99, 99, 107, 109, 120, 121, 130, 134, 143, 148, 153,
-        161, 165, 173, 174, 185, 187, 195, 200, 208, 211, 213, 218, 225, 229,
-        215, 117, 112, 111, 107, 107, 107, 106, 106, 114, 116, 127, 128, 137,
-        141, 150, 155, 160, 169, 173, 182, 183, 195, 197, 206, 211, 220, 223,
-        225, 230, 229, 226, 247, 118, 113, 112, 108, 108, 108, 107, 107, 115,
-        117, 128, 129, 138, 141, 151, 156, 161, 170, 174, 183, 184, 196, 198,
-        207, 213, 221, 224, 226, 232, 238, 245, 230, 131, 125, 123, 119, 119,
-        118, 117, 116, 124, 126, 136, 137, 147, 150, 159, 165, 171, 180, 185,
-        195, 196, 210, 212, 222, 228, 237, 240, 242, 248, 247, 240, 261, 133,
-        127, 126, 121, 121, 120, 119, 118, 126, 128, 138, 139, 148, 152, 161,
-        167, 173, 182, 187, 197, 198, 212, 215, 224, 230, 239, 242, 245, 251,
-        254, 265, 244, 143, 136, 135, 130, 130, 129, 127, 126, 134, 136, 146,
-        147, 156, 160, 169, 175, 181, 191, 195, 206, 207, 222, 224, 235, 241,
-        251, 254, 256, 263, 267, 257, 283, 149, 142, 141, 136, 135, 134, 132,
-        131, 139, 141, 150, 151, 161, 164, 173, 179, 186, 195, 200, 211, 213,
-        228, 230, 241, 247, 257, 261, 263, 270, 268, 282, 261, 160, 152, 150,
-        145, 144, 143, 140, 139, 146, 148, 158, 159, 168, 172, 181, 187, 193,
-        203, 208, 220, 221, 237, 239, 251, 257, 268, 272, 274, 281, 289, 273,
-        298, 163, 155, 154, 148, 147, 146, 143, 142, 149, 151, 160, 161, 171,
-        175, 183, 189, 196, 206, 211, 223, 224, 240, 242, 254, 261, 272, 275,
-        278, 285, 287, 307, 277, 166, 157, 156, 150, 149, 148, 145, 144, 151,
-        153, 162, 163, 173, 176, 185, 191, 198, 208, 213, 225, 226, 242, 245,
-        256, 263, 274, 278, 280, 288, 296, 292, 326, 173, 164, 162, 156, 155,
-        154, 151, 149, 157, 159, 168, 169, 178, 182, 190, 196, 203, 213, 218,
-        230, 232, 248, 251, 263, 270, 281, 285, 288, 295, 294, 305, 297, 179,
-        170, 168, 162, 161, 159, 156, 154, 160, 163, 171, 172, 183, 183, 197,
-        195, 210, 211, 225, 229, 238, 247, 254, 267, 268, 289, 287, 296, 294,
-        308, 299, 314, 184, 175, 174, 167, 166, 163, 161, 158, 163, 167, 173,
-        176, 185, 187, 198, 198, 212, 211, 229, 226, 245, 240, 265, 257, 282,
-        273, 307, 292, 305, 299, 319, 304, 190, 179, 180, 170, 171, 167, 168,
-        161, 162, 177, 171, 186, 180, 199, 191, 213, 202, 227, 215, 247, 230,
-        261, 244, 283, 261, 298, 277, 326, 297, 314, 304, 330,
+        32, 31, 31, 31, 31, 31, 32, 32, 33, 34, 36, 36, 39, 41, 44, 46, 48, 52,
+        54, 58, 59, 65, 66, 71, 74, 80, 81, 83, 86, 89, 91, 93, 31, 32, 32, 32,
+        32, 32, 32, 32, 33, 34, 35, 35, 38, 39, 42, 44, 46, 50, 51, 56, 56, 62,
+        63, 68, 71, 76, 77, 78, 82, 84, 86, 88, 31, 32, 32, 32, 32, 32, 32, 32,
+        33, 34, 35, 35, 38, 39, 42, 44, 46, 49, 51, 55, 56, 61, 63, 67, 70, 75,
+        77, 78, 81, 84, 86, 88, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34,
+        37, 38, 41, 42, 44, 48, 49, 53, 54, 59, 60, 65, 68, 72, 74, 75, 78, 80,
+        82, 84, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34, 35, 35, 38, 39, 41, 43,
+        45, 48, 49, 53, 54, 59, 60, 65, 67, 72, 73, 74, 77, 80, 82, 84, 31, 32,
+        32, 32, 33, 33, 33, 34, 35, 35, 36, 36, 39, 40, 42, 44, 45, 48, 50, 53,
+        54, 59, 60, 64, 67, 71, 73, 74, 77, 79, 81, 83, 32, 32, 32, 32, 33, 33,
+        34, 35, 36, 36, 37, 38, 40, 40, 42, 44, 45, 48, 49, 53, 53, 58, 59, 63,
+        66, 70, 71, 72, 75, 78, 80, 83, 32, 32, 32, 32, 33, 34, 35, 35, 36, 37,
+        38, 38, 40, 41, 42, 44, 46, 48, 49, 53, 53, 58, 59, 63, 65, 69, 71, 72,
+        74, 77, 79, 80, 33, 33, 33, 33, 34, 35, 36, 36, 38, 39, 42, 42, 44, 45,
+        46, 48, 50, 52, 53, 57, 57, 62, 63, 67, 69, 73, 74, 75, 78, 79, 80, 81,
+        34, 34, 34, 33, 34, 35, 36, 37, 39, 39, 42, 43, 45, 46, 47, 49, 51, 53,
+        54, 58, 58, 63, 64, 68, 70, 74, 75, 76, 79, 81, 84, 86, 36, 35, 35, 34,
+        35, 36, 37, 38, 42, 42, 48, 48, 50, 51, 54, 55, 57, 59, 60, 63, 64, 68,
+        69, 73, 75, 79, 80, 81, 84, 85, 85, 86, 36, 35, 35, 34, 35, 36, 38, 38,
+        42, 43, 48, 49, 51, 52, 54, 55, 57, 59, 60, 64, 64, 68, 69, 73, 75, 79,
+        80, 81, 84, 86, 88, 91, 39, 38, 38, 37, 38, 39, 40, 40, 44, 45, 50, 51,
+        54, 55, 58, 59, 61, 64, 65, 68, 69, 73, 74, 78, 80, 84, 85, 86, 89, 91,
+        91, 91, 41, 39, 39, 38, 39, 40, 40, 41, 45, 46, 51, 52, 55, 56, 59, 61,
+        63, 65, 67, 70, 70, 75, 76, 80, 82, 86, 87, 88, 91, 92, 94, 96, 44, 42,
+        42, 41, 41, 42, 42, 42, 46, 47, 54, 54, 58, 59, 63, 65, 67, 70, 71, 75,
+        75, 79, 80, 84, 86, 90, 91, 92, 95, 97, 97, 97, 46, 44, 44, 42, 43, 44,
+        44, 44, 48, 49, 55, 55, 59, 61, 65, 67, 69, 72, 74, 77, 78, 82, 83, 87,
+        89, 93, 94, 95, 98, 98, 100, 103, 48, 46, 46, 44, 45, 45, 45, 46, 50,
+        51, 57, 57, 61, 63, 67, 69, 71, 74, 76, 80, 80, 85, 86, 90, 93, 96, 98,
+        99, 101, 104, 104, 103, 52, 50, 49, 48, 48, 48, 48, 48, 52, 53, 59, 59,
+        64, 65, 70, 72, 74, 78, 80, 84, 85, 90, 91, 95, 97, 101, 103, 104, 106,
+        106, 107, 110, 54, 51, 51, 49, 49, 50, 49, 49, 53, 54, 60, 60, 65, 67,
+        71, 74, 76, 80, 82, 86, 87, 92, 93, 97, 100, 104, 105, 106, 109, 112,
+        112, 110, 58, 56, 55, 53, 53, 53, 53, 53, 57, 58, 63, 64, 68, 70, 75,
+        77, 80, 84, 86, 91, 91, 97, 98, 103, 105, 110, 111, 112, 115, 114, 115,
+        118, 59, 56, 56, 54, 54, 54, 53, 53, 57, 58, 64, 64, 69, 70, 75, 78, 80,
+        85, 87, 91, 92, 98, 99, 103, 106, 110, 112, 113, 116, 119, 120, 119, 65,
+        62, 61, 59, 59, 59, 58, 58, 62, 63, 68, 68, 73, 75, 79, 82, 85, 90, 92,
+        97, 98, 105, 106, 111, 114, 118, 120, 121, 124, 123, 123, 126, 66, 63,
+        63, 60, 60, 60, 59, 59, 63, 64, 69, 69, 74, 76, 80, 83, 86, 91, 93, 98,
+        99, 106, 107, 112, 115, 119, 121, 122, 125, 128, 129, 126, 71, 68, 67,
+        65, 65, 64, 63, 63, 67, 68, 73, 73, 78, 80, 84, 87, 90, 95, 97, 103,
+        103, 111, 112, 117, 120, 125, 127, 128, 131, 132, 132, 135, 74, 71, 70,
+        68, 67, 67, 66, 65, 69, 70, 75, 75, 80, 82, 86, 89, 93, 97, 100, 105,
+        106, 114, 115, 120, 123, 128, 130, 131, 135, 135, 138, 136, 80, 76, 75,
+        72, 72, 71, 70, 69, 73, 74, 79, 79, 84, 86, 90, 93, 96, 101, 104, 110,
+        110, 118, 119, 125, 128, 134, 136, 137, 140, 142, 140, 144, 81, 77, 77,
+        74, 73, 73, 71, 71, 74, 75, 80, 80, 85, 87, 91, 94, 98, 103, 105, 111,
+        112, 120, 121, 127, 130, 136, 137, 139, 142, 145, 148, 144, 83, 78, 78,
+        75, 74, 74, 72, 72, 75, 76, 81, 81, 86, 88, 92, 95, 99, 104, 106, 112,
+        113, 121, 122, 128, 131, 137, 139, 140, 144, 148, 150, 155, 86, 82, 81,
+        78, 77, 77, 75, 74, 78, 79, 84, 84, 89, 91, 95, 98, 101, 106, 109, 115,
+        116, 124, 125, 131, 135, 140, 142, 144, 147, 149, 153, 155, 89, 84, 84,
+        80, 80, 79, 78, 77, 79, 81, 85, 86, 91, 92, 97, 98, 104, 106, 112, 114,
+        119, 123, 128, 132, 135, 142, 145, 148, 149, 153, 154, 159, 91, 86, 86,
+        82, 82, 81, 80, 79, 80, 84, 85, 88, 91, 94, 97, 100, 104, 107, 112, 115,
+        120, 123, 129, 132, 138, 140, 148, 150, 153, 154, 159, 159, 93, 88, 88,
+        84, 84, 83, 83, 80, 81, 86, 86, 91, 91, 96, 97, 103, 103, 110, 110, 118,
+        119, 126, 126, 135, 136, 144, 144, 155, 155, 159, 159, 164,
         /* Size 4x8 */
-        64, 71, 103, 155, 65, 73, 100, 145, 68, 85, 109, 151, 77, 103, 134, 174,
-        96, 118, 161, 206, 120, 136, 185, 239, 145, 158, 208, 271, 162, 172,
-        222, 286,
+        32, 35, 51, 77, 32, 36, 50, 72, 34, 42, 54, 75, 38, 51, 67, 87, 48, 59,
+        80, 103, 60, 68, 92, 119, 72, 79, 104, 135, 81, 86, 112, 144,
         /* Size 8x4 */
-        64, 65, 68, 77, 96, 120, 145, 162, 71, 73, 85, 103, 118, 136, 158, 172,
-        103, 100, 109, 134, 161, 185, 208, 222, 155, 145, 151, 174, 206, 239,
-        271, 286,
+        32, 32, 34, 38, 48, 60, 72, 81, 35, 36, 42, 51, 59, 68, 79, 86, 51, 50,
+        54, 67, 80, 92, 104, 112, 77, 72, 75, 87, 103, 119, 135, 144,
         /* Size 8x16 */
-        64, 63, 67, 81, 103, 131, 158, 177, 63, 64, 67, 78, 98, 123, 149, 166,
-        63, 65, 68, 77, 95, 119, 143, 159, 64, 66, 72, 81, 96, 117, 139, 155,
-        67, 68, 77, 89, 104, 124, 145, 159, 72, 71, 84, 103, 117, 136, 157, 170,
-        79, 77, 88, 109, 127, 147, 168, 182, 88, 83, 93, 118, 139, 159, 180,
-        196, 96, 90, 100, 125, 148, 171, 192, 209, 107, 99, 107, 132, 159, 185,
-        207, 224, 117, 108, 115, 140, 168, 196, 220, 237, 132, 121, 126, 151,
-        181, 212, 238, 253, 149, 135, 139, 163, 194, 227, 256, 267, 162, 147,
-        150, 173, 204, 240, 271, 285, 172, 156, 157, 181, 212, 248, 280, 292,
-        183, 166, 164, 185, 212, 245, 282, 306,
+        32, 31, 33, 40, 51, 65, 79, 87, 31, 32, 33, 39, 49, 61, 74, 82, 31, 32,
+        34, 38, 47, 59, 71, 79, 32, 33, 36, 40, 48, 58, 69, 77, 33, 34, 38, 44,
+        52, 62, 72, 78, 36, 35, 42, 51, 58, 68, 78, 84, 39, 38, 44, 54, 63, 73,
+        84, 89, 44, 41, 46, 59, 69, 79, 90, 96, 48, 45, 50, 62, 74, 85, 96, 103,
+        53, 49, 53, 66, 79, 92, 103, 111, 58, 54, 57, 70, 84, 98, 110, 118, 66,
+        60, 63, 75, 90, 106, 119, 126, 74, 67, 69, 81, 97, 113, 128, 134, 81,
+        73, 75, 86, 102, 120, 135, 143, 86, 78, 78, 90, 106, 124, 140, 147, 91,
+        82, 80, 90, 103, 119, 137, 151,
         /* Size 16x8 */
-        64, 63, 63, 64, 67, 72, 79, 88, 96, 107, 117, 132, 149, 162, 172, 183,
-        63, 64, 65, 66, 68, 71, 77, 83, 90, 99, 108, 121, 135, 147, 156, 166,
-        67, 67, 68, 72, 77, 84, 88, 93, 100, 107, 115, 126, 139, 150, 157, 164,
-        81, 78, 77, 81, 89, 103, 109, 118, 125, 132, 140, 151, 163, 173, 181,
-        185, 103, 98, 95, 96, 104, 117, 127, 139, 148, 159, 168, 181, 194, 204,
-        212, 212, 131, 123, 119, 117, 124, 136, 147, 159, 171, 185, 196, 212,
-        227, 240, 248, 245, 158, 149, 143, 139, 145, 157, 168, 180, 192, 207,
-        220, 238, 256, 271, 280, 282, 177, 166, 159, 155, 159, 170, 182, 196,
-        209, 224, 237, 253, 267, 285, 292, 306,
+        32, 31, 31, 32, 33, 36, 39, 44, 48, 53, 58, 66, 74, 81, 86, 91, 31, 32,
+        32, 33, 34, 35, 38, 41, 45, 49, 54, 60, 67, 73, 78, 82, 33, 33, 34, 36,
+        38, 42, 44, 46, 50, 53, 57, 63, 69, 75, 78, 80, 40, 39, 38, 40, 44, 51,
+        54, 59, 62, 66, 70, 75, 81, 86, 90, 90, 51, 49, 47, 48, 52, 58, 63, 69,
+        74, 79, 84, 90, 97, 102, 106, 103, 65, 61, 59, 58, 62, 68, 73, 79, 85,
+        92, 98, 106, 113, 120, 124, 119, 79, 74, 71, 69, 72, 78, 84, 90, 96,
+        103, 110, 119, 128, 135, 140, 137, 87, 82, 79, 77, 78, 84, 89, 96, 103,
+        111, 118, 126, 134, 143, 147, 151,
         /* Size 16x32 */
-        64, 63, 63, 64, 67, 72, 81, 88, 103, 107, 131, 133, 158, 163, 177, 186,
-        63, 64, 64, 65, 67, 71, 79, 85, 99, 103, 124, 127, 151, 155, 168, 176,
-        63, 64, 64, 65, 67, 70, 78, 84, 98, 102, 123, 125, 149, 153, 166, 176,
-        63, 65, 65, 66, 67, 69, 76, 82, 95, 99, 119, 121, 144, 148, 160, 167,
-        63, 65, 65, 67, 68, 71, 77, 83, 95, 99, 119, 121, 143, 147, 159, 168,
-        64, 65, 66, 68, 70, 73, 79, 84, 96, 100, 118, 120, 142, 145, 157, 164,
-        64, 65, 66, 70, 72, 75, 81, 85, 96, 99, 117, 119, 139, 143, 155, 165,
-        64, 66, 67, 71, 73, 77, 82, 85, 96, 99, 116, 118, 138, 141, 152, 158,
-        67, 67, 68, 73, 77, 83, 89, 93, 104, 107, 124, 126, 145, 149, 159, 159,
-        68, 68, 69, 74, 78, 85, 91, 96, 106, 109, 126, 128, 147, 151, 162, 174,
-        72, 69, 71, 77, 84, 96, 103, 108, 117, 120, 136, 138, 157, 160, 170,
-        169, 72, 70, 71, 77, 84, 96, 103, 108, 118, 121, 137, 139, 158, 161,
-        171, 184, 79, 75, 77, 81, 88, 101, 109, 116, 127, 130, 147, 149, 168,
-        171, 182, 178, 81, 77, 78, 83, 90, 103, 112, 119, 130, 134, 150, 152,
-        171, 174, 181, 196, 88, 82, 83, 86, 93, 107, 118, 126, 139, 143, 159,
-        161, 180, 183, 196, 188, 92, 86, 87, 89, 97, 110, 121, 130, 144, 147,
-        165, 167, 186, 189, 194, 211, 96, 90, 90, 93, 100, 113, 125, 134, 148,
-        152, 171, 173, 192, 196, 209, 200, 104, 96, 97, 98, 105, 118, 130, 140,
-        156, 161, 180, 182, 202, 206, 210, 225, 107, 99, 99, 100, 107, 120, 132,
-        142, 159, 164, 185, 187, 207, 210, 224, 213, 116, 107, 107, 107, 114,
-        127, 139, 149, 167, 173, 195, 197, 219, 222, 227, 244, 117, 108, 108,
-        108, 115, 127, 140, 150, 168, 174, 196, 198, 220, 224, 237, 228, 130,
-        120, 119, 117, 124, 136, 149, 159, 179, 185, 210, 212, 236, 239, 246,
-        258, 132, 122, 121, 119, 126, 138, 151, 161, 181, 187, 212, 214, 238,
-        242, 253, 242, 142, 131, 130, 127, 134, 146, 159, 169, 189, 195, 222,
-        224, 250, 254, 265, 280, 149, 136, 135, 132, 139, 150, 163, 173, 194,
-        200, 227, 230, 256, 260, 267, 259, 159, 145, 144, 140, 147, 158, 171,
-        181, 202, 208, 236, 239, 267, 271, 287, 295, 162, 148, 147, 143, 150,
-        161, 173, 183, 204, 210, 240, 242, 271, 275, 285, 275, 165, 151, 149,
-        145, 151, 162, 175, 185, 206, 212, 242, 244, 273, 278, 294, 322, 172,
-        157, 156, 151, 157, 168, 181, 190, 212, 218, 248, 250, 280, 285, 292,
-        294, 178, 162, 161, 155, 161, 172, 183, 195, 212, 222, 247, 253, 286,
-        286, 305, 311, 183, 167, 166, 159, 164, 176, 185, 198, 212, 226, 245,
-        257, 282, 291, 306, 301, 189, 171, 172, 163, 164, 186, 180, 212, 202,
-        245, 230, 281, 261, 321, 296, 327,
+        32, 31, 31, 32, 33, 36, 40, 44, 51, 53, 65, 66, 79, 81, 87, 90, 31, 32,
+        32, 32, 33, 35, 39, 42, 49, 51, 62, 63, 75, 77, 83, 85, 31, 32, 32, 32,
+        33, 35, 39, 42, 49, 51, 61, 62, 74, 76, 82, 85, 31, 32, 32, 33, 33, 34,
+        38, 41, 47, 49, 59, 60, 72, 74, 79, 81, 31, 32, 32, 33, 34, 35, 38, 41,
+        47, 49, 59, 60, 71, 73, 79, 81, 32, 32, 33, 34, 35, 36, 39, 42, 48, 50,
+        59, 60, 71, 72, 78, 80, 32, 32, 33, 35, 36, 37, 40, 42, 48, 49, 58, 59,
+        69, 71, 77, 80, 32, 33, 33, 35, 36, 38, 41, 42, 48, 49, 58, 59, 69, 70,
+        75, 77, 33, 33, 34, 36, 38, 41, 44, 46, 52, 53, 62, 63, 72, 74, 78, 78,
+        34, 34, 34, 37, 39, 42, 45, 48, 53, 54, 63, 64, 73, 75, 80, 83, 36, 34,
+        35, 38, 42, 48, 51, 54, 58, 60, 68, 69, 78, 80, 84, 83, 36, 35, 35, 38,
+        42, 48, 51, 54, 59, 60, 68, 69, 79, 80, 85, 87, 39, 37, 38, 40, 44, 50,
+        54, 58, 63, 65, 73, 74, 84, 85, 89, 88, 40, 38, 39, 41, 45, 51, 56, 59,
+        65, 67, 75, 76, 85, 87, 90, 93, 44, 41, 41, 43, 46, 53, 59, 63, 69, 71,
+        79, 80, 90, 91, 96, 93, 46, 43, 43, 44, 48, 55, 60, 65, 72, 73, 82, 83,
+        93, 94, 97, 100, 48, 45, 45, 46, 50, 56, 62, 67, 74, 76, 85, 86, 96, 98,
+        103, 100, 52, 48, 48, 49, 52, 59, 65, 70, 78, 80, 90, 91, 101, 103, 105,
+        107, 53, 49, 49, 50, 53, 60, 66, 71, 79, 82, 92, 93, 103, 105, 111, 107,
+        58, 53, 53, 53, 57, 63, 69, 74, 83, 86, 97, 98, 109, 111, 113, 115, 58,
+        54, 54, 54, 57, 63, 70, 75, 84, 87, 98, 99, 110, 112, 118, 115, 65, 60,
+        59, 58, 62, 68, 74, 79, 89, 92, 105, 106, 118, 119, 122, 123, 66, 61,
+        60, 59, 63, 69, 75, 80, 90, 93, 106, 107, 119, 121, 126, 123, 71, 65,
+        65, 63, 67, 73, 79, 84, 94, 97, 111, 112, 125, 127, 131, 132, 74, 68,
+        67, 66, 69, 75, 81, 86, 97, 100, 113, 115, 128, 130, 134, 132, 79, 72,
+        72, 70, 73, 79, 85, 90, 101, 104, 118, 119, 133, 135, 141, 140, 81, 74,
+        73, 71, 75, 80, 86, 91, 102, 105, 120, 121, 135, 137, 143, 140, 82, 75,
+        74, 72, 75, 81, 87, 92, 103, 106, 121, 122, 136, 139, 147, 151, 86, 78,
+        78, 75, 78, 84, 90, 95, 106, 109, 124, 125, 140, 142, 147, 151, 88, 81,
+        80, 77, 80, 86, 90, 98, 105, 112, 122, 127, 140, 144, 152, 155, 91, 83,
+        82, 79, 80, 88, 90, 100, 103, 114, 119, 130, 137, 148, 151, 155, 93, 85,
+        85, 81, 81, 90, 90, 102, 103, 117, 117, 134, 134, 151, 152, 160,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 64, 64, 64, 67, 68, 72, 72, 79, 81, 88, 92, 96, 104,
-        107, 116, 117, 130, 132, 142, 149, 159, 162, 165, 172, 178, 183, 189,
-        63, 64, 64, 65, 65, 65, 65, 66, 67, 68, 69, 70, 75, 77, 82, 86, 90, 96,
-        99, 107, 108, 120, 122, 131, 136, 145, 148, 151, 157, 162, 167, 171, 63,
-        64, 64, 65, 65, 66, 66, 67, 68, 69, 71, 71, 77, 78, 83, 87, 90, 97, 99,
-        107, 108, 119, 121, 130, 135, 144, 147, 149, 156, 161, 166, 172, 64, 65,
-        65, 66, 67, 68, 70, 71, 73, 74, 77, 77, 81, 83, 86, 89, 93, 98, 100,
-        107, 108, 117, 119, 127, 132, 140, 143, 145, 151, 155, 159, 163, 67, 67,
-        67, 67, 68, 70, 72, 73, 77, 78, 84, 84, 88, 90, 93, 97, 100, 105, 107,
-        114, 115, 124, 126, 134, 139, 147, 150, 151, 157, 161, 164, 164, 72, 71,
-        70, 69, 71, 73, 75, 77, 83, 85, 96, 96, 101, 103, 107, 110, 113, 118,
-        120, 127, 127, 136, 138, 146, 150, 158, 161, 162, 168, 172, 176, 186,
-        81, 79, 78, 76, 77, 79, 81, 82, 89, 91, 103, 103, 109, 112, 118, 121,
-        125, 130, 132, 139, 140, 149, 151, 159, 163, 171, 173, 175, 181, 183,
-        185, 180, 88, 85, 84, 82, 83, 84, 85, 85, 93, 96, 108, 108, 116, 119,
-        126, 130, 134, 140, 142, 149, 150, 159, 161, 169, 173, 181, 183, 185,
-        190, 195, 198, 212, 103, 99, 98, 95, 95, 96, 96, 96, 104, 106, 117, 118,
-        127, 130, 139, 144, 148, 156, 159, 167, 168, 179, 181, 189, 194, 202,
-        204, 206, 212, 212, 212, 202, 107, 103, 102, 99, 99, 100, 99, 99, 107,
-        109, 120, 121, 130, 134, 143, 147, 152, 161, 164, 173, 174, 185, 187,
-        195, 200, 208, 210, 212, 218, 222, 226, 245, 131, 124, 123, 119, 119,
-        118, 117, 116, 124, 126, 136, 137, 147, 150, 159, 165, 171, 180, 185,
-        195, 196, 210, 212, 222, 227, 236, 240, 242, 248, 247, 245, 230, 133,
-        127, 125, 121, 121, 120, 119, 118, 126, 128, 138, 139, 149, 152, 161,
-        167, 173, 182, 187, 197, 198, 212, 214, 224, 230, 239, 242, 244, 250,
-        253, 257, 281, 158, 151, 149, 144, 143, 142, 139, 138, 145, 147, 157,
-        158, 168, 171, 180, 186, 192, 202, 207, 219, 220, 236, 238, 250, 256,
-        267, 271, 273, 280, 286, 282, 261, 163, 155, 153, 148, 147, 145, 143,
-        141, 149, 151, 160, 161, 171, 174, 183, 189, 196, 206, 210, 222, 224,
-        239, 242, 254, 260, 271, 275, 278, 285, 286, 291, 321, 177, 168, 166,
-        160, 159, 157, 155, 152, 159, 162, 170, 171, 182, 181, 196, 194, 209,
-        210, 224, 227, 237, 246, 253, 265, 267, 287, 285, 294, 292, 305, 306,
-        296, 186, 176, 176, 167, 168, 164, 165, 158, 159, 174, 169, 184, 178,
-        196, 188, 211, 200, 225, 213, 244, 228, 258, 242, 280, 259, 295, 275,
-        322, 294, 311, 301, 327,
+        32, 31, 31, 31, 31, 32, 32, 32, 33, 34, 36, 36, 39, 40, 44, 46, 48, 52,
+        53, 58, 58, 65, 66, 71, 74, 79, 81, 82, 86, 88, 91, 93, 31, 32, 32, 32,
+        32, 32, 32, 33, 33, 34, 34, 35, 37, 38, 41, 43, 45, 48, 49, 53, 54, 60,
+        61, 65, 68, 72, 74, 75, 78, 81, 83, 85, 31, 32, 32, 32, 32, 33, 33, 33,
+        34, 34, 35, 35, 38, 39, 41, 43, 45, 48, 49, 53, 54, 59, 60, 65, 67, 72,
+        73, 74, 78, 80, 82, 85, 32, 32, 32, 33, 33, 34, 35, 35, 36, 37, 38, 38,
+        40, 41, 43, 44, 46, 49, 50, 53, 54, 58, 59, 63, 66, 70, 71, 72, 75, 77,
+        79, 81, 33, 33, 33, 33, 34, 35, 36, 36, 38, 39, 42, 42, 44, 45, 46, 48,
+        50, 52, 53, 57, 57, 62, 63, 67, 69, 73, 75, 75, 78, 80, 80, 81, 36, 35,
+        35, 34, 35, 36, 37, 38, 41, 42, 48, 48, 50, 51, 53, 55, 56, 59, 60, 63,
+        63, 68, 69, 73, 75, 79, 80, 81, 84, 86, 88, 90, 40, 39, 39, 38, 38, 39,
+        40, 41, 44, 45, 51, 51, 54, 56, 59, 60, 62, 65, 66, 69, 70, 74, 75, 79,
+        81, 85, 86, 87, 90, 90, 90, 90, 44, 42, 42, 41, 41, 42, 42, 42, 46, 48,
+        54, 54, 58, 59, 63, 65, 67, 70, 71, 74, 75, 79, 80, 84, 86, 90, 91, 92,
+        95, 98, 100, 102, 51, 49, 49, 47, 47, 48, 48, 48, 52, 53, 58, 59, 63,
+        65, 69, 72, 74, 78, 79, 83, 84, 89, 90, 94, 97, 101, 102, 103, 106, 105,
+        103, 103, 53, 51, 51, 49, 49, 50, 49, 49, 53, 54, 60, 60, 65, 67, 71,
+        73, 76, 80, 82, 86, 87, 92, 93, 97, 100, 104, 105, 106, 109, 112, 114,
+        117, 65, 62, 61, 59, 59, 59, 58, 58, 62, 63, 68, 68, 73, 75, 79, 82, 85,
+        90, 92, 97, 98, 105, 106, 111, 113, 118, 120, 121, 124, 122, 119, 117,
+        66, 63, 62, 60, 60, 60, 59, 59, 63, 64, 69, 69, 74, 76, 80, 83, 86, 91,
+        93, 98, 99, 106, 107, 112, 115, 119, 121, 122, 125, 127, 130, 134, 79,
+        75, 74, 72, 71, 71, 69, 69, 72, 73, 78, 79, 84, 85, 90, 93, 96, 101,
+        103, 109, 110, 118, 119, 125, 128, 133, 135, 136, 140, 140, 137, 134,
+        81, 77, 76, 74, 73, 72, 71, 70, 74, 75, 80, 80, 85, 87, 91, 94, 98, 103,
+        105, 111, 112, 119, 121, 127, 130, 135, 137, 139, 142, 144, 148, 151,
+        87, 83, 82, 79, 79, 78, 77, 75, 78, 80, 84, 85, 89, 90, 96, 97, 103,
+        105, 111, 113, 118, 122, 126, 131, 134, 141, 143, 147, 147, 152, 151,
+        152, 90, 85, 85, 81, 81, 80, 80, 77, 78, 83, 83, 87, 88, 93, 93, 100,
+        100, 107, 107, 115, 115, 123, 123, 132, 132, 140, 140, 151, 151, 155,
+        155, 160,
         /* Size 4x16 */
-        63, 72, 107, 163, 64, 70, 102, 153, 65, 71, 99, 147, 65, 75, 99, 143,
-        67, 83, 107, 149, 69, 96, 120, 160, 75, 101, 130, 171, 82, 107, 143,
-        183, 90, 113, 152, 196, 99, 120, 164, 210, 108, 127, 174, 224, 122, 138,
-        187, 242, 136, 150, 200, 260, 148, 161, 210, 275, 157, 168, 218, 285,
-        167, 176, 226, 291,
+        31, 36, 53, 81, 32, 35, 51, 76, 32, 35, 49, 73, 32, 37, 49, 71, 33, 41,
+        53, 74, 34, 48, 60, 80, 37, 50, 65, 85, 41, 53, 71, 91, 45, 56, 76, 98,
+        49, 60, 82, 105, 54, 63, 87, 112, 61, 69, 93, 121, 68, 75, 100, 130, 74,
+        80, 105, 137, 78, 84, 109, 142, 83, 88, 114, 148,
         /* Size 16x4 */
-        63, 64, 65, 65, 67, 69, 75, 82, 90, 99, 108, 122, 136, 148, 157, 167,
-        72, 70, 71, 75, 83, 96, 101, 107, 113, 120, 127, 138, 150, 161, 168,
-        176, 107, 102, 99, 99, 107, 120, 130, 143, 152, 164, 174, 187, 200, 210,
-        218, 226, 163, 153, 147, 143, 149, 160, 171, 183, 196, 210, 224, 242,
-        260, 275, 285, 291,
+        31, 32, 32, 32, 33, 34, 37, 41, 45, 49, 54, 61, 68, 74, 78, 83, 36, 35,
+        35, 37, 41, 48, 50, 53, 56, 60, 63, 69, 75, 80, 84, 88, 53, 51, 49, 49,
+        53, 60, 65, 71, 76, 82, 87, 93, 100, 105, 109, 114, 81, 76, 73, 71, 74,
+        80, 85, 91, 98, 105, 112, 121, 130, 137, 142, 148,
         /* Size 8x32 */
-        64, 63, 67, 81, 103, 131, 158, 177, 63, 64, 67, 79, 99, 124, 151, 168,
-        63, 64, 67, 78, 98, 123, 149, 166, 63, 65, 67, 76, 95, 119, 144, 160,
-        63, 65, 68, 77, 95, 119, 143, 159, 64, 66, 70, 79, 96, 118, 142, 157,
-        64, 66, 72, 81, 96, 117, 139, 155, 64, 67, 73, 82, 96, 116, 138, 152,
-        67, 68, 77, 89, 104, 124, 145, 159, 68, 69, 78, 91, 106, 126, 147, 162,
-        72, 71, 84, 103, 117, 136, 157, 170, 72, 71, 84, 103, 118, 137, 158,
-        171, 79, 77, 88, 109, 127, 147, 168, 182, 81, 78, 90, 112, 130, 150,
-        171, 181, 88, 83, 93, 118, 139, 159, 180, 196, 92, 87, 97, 121, 144,
-        165, 186, 194, 96, 90, 100, 125, 148, 171, 192, 209, 104, 97, 105, 130,
-        156, 180, 202, 210, 107, 99, 107, 132, 159, 185, 207, 224, 116, 107,
-        114, 139, 167, 195, 219, 227, 117, 108, 115, 140, 168, 196, 220, 237,
-        130, 119, 124, 149, 179, 210, 236, 246, 132, 121, 126, 151, 181, 212,
-        238, 253, 142, 130, 134, 159, 189, 222, 250, 265, 149, 135, 139, 163,
-        194, 227, 256, 267, 159, 144, 147, 171, 202, 236, 267, 287, 162, 147,
-        150, 173, 204, 240, 271, 285, 165, 149, 151, 175, 206, 242, 273, 294,
-        172, 156, 157, 181, 212, 248, 280, 292, 178, 161, 161, 183, 212, 247,
-        286, 305, 183, 166, 164, 185, 212, 245, 282, 306, 189, 172, 164, 180,
-        202, 230, 261, 296,
+        32, 31, 33, 40, 51, 65, 79, 87, 31, 32, 33, 39, 49, 62, 75, 83, 31, 32,
+        33, 39, 49, 61, 74, 82, 31, 32, 33, 38, 47, 59, 72, 79, 31, 32, 34, 38,
+        47, 59, 71, 79, 32, 33, 35, 39, 48, 59, 71, 78, 32, 33, 36, 40, 48, 58,
+        69, 77, 32, 33, 36, 41, 48, 58, 69, 75, 33, 34, 38, 44, 52, 62, 72, 78,
+        34, 34, 39, 45, 53, 63, 73, 80, 36, 35, 42, 51, 58, 68, 78, 84, 36, 35,
+        42, 51, 59, 68, 79, 85, 39, 38, 44, 54, 63, 73, 84, 89, 40, 39, 45, 56,
+        65, 75, 85, 90, 44, 41, 46, 59, 69, 79, 90, 96, 46, 43, 48, 60, 72, 82,
+        93, 97, 48, 45, 50, 62, 74, 85, 96, 103, 52, 48, 52, 65, 78, 90, 101,
+        105, 53, 49, 53, 66, 79, 92, 103, 111, 58, 53, 57, 69, 83, 97, 109, 113,
+        58, 54, 57, 70, 84, 98, 110, 118, 65, 59, 62, 74, 89, 105, 118, 122, 66,
+        60, 63, 75, 90, 106, 119, 126, 71, 65, 67, 79, 94, 111, 125, 131, 74,
+        67, 69, 81, 97, 113, 128, 134, 79, 72, 73, 85, 101, 118, 133, 141, 81,
+        73, 75, 86, 102, 120, 135, 143, 82, 74, 75, 87, 103, 121, 136, 147, 86,
+        78, 78, 90, 106, 124, 140, 147, 88, 80, 80, 90, 105, 122, 140, 152, 91,
+        82, 80, 90, 103, 119, 137, 151, 93, 85, 81, 90, 103, 117, 134, 152,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 64, 64, 64, 67, 68, 72, 72, 79, 81, 88, 92, 96, 104,
-        107, 116, 117, 130, 132, 142, 149, 159, 162, 165, 172, 178, 183, 189,
-        63, 64, 64, 65, 65, 66, 66, 67, 68, 69, 71, 71, 77, 78, 83, 87, 90, 97,
-        99, 107, 108, 119, 121, 130, 135, 144, 147, 149, 156, 161, 166, 172, 67,
-        67, 67, 67, 68, 70, 72, 73, 77, 78, 84, 84, 88, 90, 93, 97, 100, 105,
-        107, 114, 115, 124, 126, 134, 139, 147, 150, 151, 157, 161, 164, 164,
-        81, 79, 78, 76, 77, 79, 81, 82, 89, 91, 103, 103, 109, 112, 118, 121,
-        125, 130, 132, 139, 140, 149, 151, 159, 163, 171, 173, 175, 181, 183,
-        185, 180, 103, 99, 98, 95, 95, 96, 96, 96, 104, 106, 117, 118, 127, 130,
-        139, 144, 148, 156, 159, 167, 168, 179, 181, 189, 194, 202, 204, 206,
-        212, 212, 212, 202, 131, 124, 123, 119, 119, 118, 117, 116, 124, 126,
-        136, 137, 147, 150, 159, 165, 171, 180, 185, 195, 196, 210, 212, 222,
-        227, 236, 240, 242, 248, 247, 245, 230, 158, 151, 149, 144, 143, 142,
-        139, 138, 145, 147, 157, 158, 168, 171, 180, 186, 192, 202, 207, 219,
-        220, 236, 238, 250, 256, 267, 271, 273, 280, 286, 282, 261, 177, 168,
-        166, 160, 159, 157, 155, 152, 159, 162, 170, 171, 182, 181, 196, 194,
-        209, 210, 224, 227, 237, 246, 253, 265, 267, 287, 285, 294, 292, 305,
-        306, 296 },
+        32, 31, 31, 31, 31, 32, 32, 32, 33, 34, 36, 36, 39, 40, 44, 46, 48, 52,
+        53, 58, 58, 65, 66, 71, 74, 79, 81, 82, 86, 88, 91, 93, 31, 32, 32, 32,
+        32, 33, 33, 33, 34, 34, 35, 35, 38, 39, 41, 43, 45, 48, 49, 53, 54, 59,
+        60, 65, 67, 72, 73, 74, 78, 80, 82, 85, 33, 33, 33, 33, 34, 35, 36, 36,
+        38, 39, 42, 42, 44, 45, 46, 48, 50, 52, 53, 57, 57, 62, 63, 67, 69, 73,
+        75, 75, 78, 80, 80, 81, 40, 39, 39, 38, 38, 39, 40, 41, 44, 45, 51, 51,
+        54, 56, 59, 60, 62, 65, 66, 69, 70, 74, 75, 79, 81, 85, 86, 87, 90, 90,
+        90, 90, 51, 49, 49, 47, 47, 48, 48, 48, 52, 53, 58, 59, 63, 65, 69, 72,
+        74, 78, 79, 83, 84, 89, 90, 94, 97, 101, 102, 103, 106, 105, 103, 103,
+        65, 62, 61, 59, 59, 59, 58, 58, 62, 63, 68, 68, 73, 75, 79, 82, 85, 90,
+        92, 97, 98, 105, 106, 111, 113, 118, 120, 121, 124, 122, 119, 117, 79,
+        75, 74, 72, 71, 71, 69, 69, 72, 73, 78, 79, 84, 85, 90, 93, 96, 101,
+        103, 109, 110, 118, 119, 125, 128, 133, 135, 136, 140, 140, 137, 134,
+        87, 83, 82, 79, 79, 78, 77, 75, 78, 80, 84, 85, 89, 90, 96, 97, 103,
+        105, 111, 113, 118, 122, 126, 131, 134, 141, 143, 147, 147, 152, 151,
+        152 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        95, 104, 104, 164,
+        47, 52, 52, 82,
 #endif
         /* Size 4x4 */
-        64, 93, 99, 117, 93, 106, 111, 124, 99, 111, 141, 157, 117, 124, 157,
-        183,
+        32, 46, 49, 58, 46, 53, 55, 62, 49, 55, 70, 78, 58, 62, 78, 91,
         /* Size 8x8 */
-        63, 69, 85, 94, 99, 109, 121, 128, 69, 78, 90, 92, 95, 102, 113, 119,
-        85, 90, 97, 99, 101, 107, 115, 121, 94, 92, 99, 110, 116, 122, 130, 133,
-        99, 95, 101, 116, 130, 139, 147, 149, 109, 102, 107, 122, 139, 153, 164,
-        167, 121, 113, 115, 130, 147, 164, 178, 186, 128, 119, 121, 133, 149,
-        167, 186, 194,
+        31, 34, 42, 47, 49, 54, 60, 64, 34, 39, 45, 46, 47, 51, 56, 59, 42, 45,
+        48, 49, 50, 53, 57, 60, 47, 46, 49, 55, 58, 61, 65, 66, 49, 47, 50, 58,
+        65, 69, 73, 74, 54, 51, 53, 61, 69, 76, 82, 83, 60, 56, 57, 65, 73, 82,
+        89, 92, 64, 59, 60, 66, 74, 83, 92, 96,
         /* Size 16x16 */
-        64, 62, 63, 71, 81, 98, 97, 98, 101, 104, 109, 115, 123, 129, 133, 138,
-        62, 63, 65, 74, 83, 95, 94, 93, 96, 99, 103, 109, 115, 121, 125, 129,
-        63, 65, 69, 79, 86, 93, 92, 90, 93, 95, 99, 104, 110, 115, 119, 123, 71,
-        74, 79, 88, 92, 95, 93, 91, 93, 94, 97, 102, 107, 112, 115, 119, 81, 83,
-        86, 92, 96, 100, 98, 97, 98, 99, 102, 106, 111, 115, 118, 120, 98, 95,
-        93, 95, 100, 106, 106, 107, 108, 109, 111, 114, 119, 122, 125, 126, 97,
-        94, 92, 93, 98, 106, 109, 111, 113, 115, 117, 121, 125, 129, 131, 133,
-        98, 93, 90, 91, 97, 107, 111, 117, 120, 123, 125, 128, 132, 136, 138,
-        140, 101, 96, 93, 93, 98, 108, 113, 120, 123, 127, 130, 135, 139, 143,
-        145, 148, 104, 99, 95, 94, 99, 109, 115, 123, 127, 133, 137, 142, 147,
-        151, 153, 157, 109, 103, 99, 97, 102, 111, 117, 125, 130, 137, 142, 148,
-        153, 157, 160, 165, 115, 109, 104, 102, 106, 114, 121, 128, 135, 142,
-        148, 155, 161, 166, 169, 175, 123, 115, 110, 107, 111, 119, 125, 132,
-        139, 147, 153, 161, 169, 175, 178, 183, 129, 121, 115, 112, 115, 122,
-        129, 136, 143, 151, 157, 166, 175, 181, 185, 194, 133, 125, 119, 115,
-        118, 125, 131, 138, 145, 153, 160, 169, 178, 185, 189, 193, 138, 129,
-        123, 119, 120, 126, 133, 140, 148, 157, 165, 175, 183, 194, 193, 199,
+        32, 31, 31, 35, 40, 49, 48, 49, 50, 52, 54, 57, 61, 64, 66, 68, 31, 31,
+        32, 37, 41, 47, 47, 46, 48, 49, 51, 54, 57, 60, 62, 64, 31, 32, 34, 39,
+        43, 46, 46, 45, 46, 47, 49, 52, 55, 57, 59, 61, 35, 37, 39, 44, 46, 47,
+        46, 45, 46, 47, 48, 51, 53, 56, 57, 59, 40, 41, 43, 46, 48, 50, 49, 48,
+        49, 49, 51, 53, 55, 57, 59, 59, 49, 47, 46, 47, 50, 53, 53, 53, 54, 54,
+        55, 57, 59, 61, 62, 62, 48, 47, 46, 46, 49, 53, 54, 55, 56, 57, 58, 60,
+        62, 64, 65, 65, 49, 46, 45, 45, 48, 53, 55, 58, 60, 61, 62, 64, 66, 68,
+        69, 69, 50, 48, 46, 46, 49, 54, 56, 60, 61, 63, 65, 67, 69, 71, 72, 72,
+        52, 49, 47, 47, 49, 54, 57, 61, 63, 66, 68, 71, 73, 75, 76, 77, 54, 51,
+        49, 48, 51, 55, 58, 62, 65, 68, 71, 74, 76, 78, 80, 81, 57, 54, 52, 51,
+        53, 57, 60, 64, 67, 71, 74, 77, 80, 83, 84, 85, 61, 57, 55, 53, 55, 59,
+        62, 66, 69, 73, 76, 80, 84, 87, 89, 89, 64, 60, 57, 56, 57, 61, 64, 68,
+        71, 75, 78, 83, 87, 90, 92, 94, 66, 62, 59, 57, 59, 62, 65, 69, 72, 76,
+        80, 84, 89, 92, 94, 96, 68, 64, 61, 59, 59, 62, 65, 69, 72, 77, 81, 85,
+        89, 94, 96, 98,
         /* Size 32x32 */
-        64, 62, 62, 61, 63, 67, 71, 73, 81, 83, 98, 98, 97, 97, 98, 100, 101,
-        104, 104, 109, 109, 114, 115, 120, 123, 127, 129, 130, 133, 135, 138,
-        140, 62, 63, 63, 62, 65, 69, 74, 77, 83, 85, 95, 95, 94, 94, 94, 95, 97,
-        99, 100, 104, 104, 109, 110, 114, 117, 121, 122, 123, 126, 128, 130,
-        132, 62, 63, 63, 63, 65, 70, 74, 78, 83, 85, 95, 95, 94, 93, 93, 95, 96,
-        98, 99, 103, 103, 108, 109, 113, 115, 119, 121, 122, 125, 127, 129, 132,
-        61, 62, 63, 64, 66, 71, 76, 80, 84, 85, 93, 93, 91, 91, 90, 91, 93, 95,
-        95, 99, 99, 104, 105, 109, 111, 115, 116, 117, 120, 122, 124, 125, 63,
-        65, 65, 66, 69, 74, 79, 83, 86, 87, 93, 93, 92, 91, 90, 92, 93, 95, 95,
-        99, 99, 103, 104, 108, 110, 114, 115, 116, 119, 121, 123, 126, 67, 69,
-        70, 71, 74, 78, 83, 87, 89, 90, 95, 94, 93, 92, 91, 92, 93, 95, 95, 98,
-        99, 102, 103, 107, 109, 113, 114, 115, 117, 119, 121, 122, 71, 74, 74,
-        76, 79, 83, 88, 92, 92, 93, 95, 95, 93, 92, 91, 92, 93, 94, 94, 97, 97,
-        101, 102, 105, 107, 110, 112, 113, 115, 117, 119, 123, 73, 77, 78, 80,
-        83, 87, 92, 95, 95, 95, 96, 95, 93, 92, 91, 92, 92, 93, 94, 96, 97, 100,
-        101, 104, 106, 109, 110, 111, 113, 115, 117, 117, 81, 83, 83, 84, 86,
-        89, 92, 95, 96, 97, 100, 99, 98, 98, 97, 98, 98, 99, 99, 102, 102, 105,
-        106, 109, 111, 114, 115, 116, 118, 119, 120, 118, 83, 85, 85, 85, 87,
-        90, 93, 95, 97, 97, 101, 100, 99, 99, 98, 99, 100, 101, 101, 104, 104,
-        107, 107, 111, 112, 115, 116, 117, 119, 121, 123, 127, 98, 95, 95, 93,
-        93, 95, 95, 96, 100, 101, 106, 106, 106, 107, 107, 108, 108, 109, 109,
-        111, 111, 113, 114, 117, 119, 121, 122, 123, 125, 126, 126, 124, 98, 95,
-        95, 93, 93, 94, 95, 95, 99, 100, 106, 106, 107, 107, 108, 108, 108, 109,
-        109, 111, 112, 114, 115, 118, 119, 122, 123, 124, 126, 127, 128, 133,
-        97, 94, 94, 91, 92, 93, 93, 93, 98, 99, 106, 107, 109, 109, 111, 112,
-        113, 114, 115, 117, 117, 120, 121, 123, 125, 127, 129, 129, 131, 133,
-        133, 129, 97, 94, 93, 91, 91, 92, 92, 92, 98, 99, 107, 107, 109, 110,
-        113, 114, 115, 116, 117, 119, 120, 122, 123, 126, 127, 130, 131, 131,
-        133, 133, 134, 140, 98, 94, 93, 90, 90, 91, 91, 91, 97, 98, 107, 108,
-        111, 113, 117, 118, 120, 122, 123, 125, 125, 127, 128, 131, 132, 135,
-        136, 136, 138, 141, 140, 135, 100, 95, 95, 91, 92, 92, 92, 92, 98, 99,
-        108, 108, 112, 114, 118, 120, 121, 124, 125, 127, 128, 131, 131, 134,
-        136, 138, 139, 140, 141, 140, 141, 148, 101, 97, 96, 93, 93, 93, 93, 92,
-        98, 100, 108, 108, 113, 115, 120, 121, 123, 126, 127, 130, 130, 134,
-        135, 137, 139, 142, 143, 143, 145, 148, 148, 142, 104, 99, 98, 95, 95,
-        95, 94, 93, 99, 101, 109, 109, 114, 116, 122, 124, 126, 130, 131, 135,
-        135, 139, 140, 143, 144, 147, 148, 149, 151, 149, 148, 156, 104, 100,
-        99, 95, 95, 95, 94, 94, 99, 101, 109, 109, 115, 117, 123, 125, 127, 131,
-        133, 137, 137, 141, 142, 145, 147, 150, 151, 151, 153, 156, 157, 149,
-        109, 104, 103, 99, 99, 98, 97, 96, 102, 104, 111, 111, 117, 119, 125,
-        127, 130, 135, 137, 141, 141, 146, 147, 150, 152, 156, 157, 157, 159,
-        158, 156, 165, 109, 104, 103, 99, 99, 99, 97, 97, 102, 104, 111, 112,
-        117, 120, 125, 128, 130, 135, 137, 141, 142, 147, 148, 151, 153, 156,
-        157, 158, 160, 162, 165, 157, 114, 109, 108, 104, 103, 102, 101, 100,
-        105, 107, 113, 114, 120, 122, 127, 131, 134, 139, 141, 146, 147, 153,
-        154, 158, 160, 164, 165, 166, 168, 167, 163, 172, 115, 110, 109, 105,
-        104, 103, 102, 101, 106, 107, 114, 115, 121, 123, 128, 131, 135, 140,
-        142, 147, 148, 154, 155, 159, 161, 165, 166, 167, 169, 170, 175, 164,
-        120, 114, 113, 109, 108, 107, 105, 104, 109, 111, 117, 118, 123, 126,
-        131, 134, 137, 143, 145, 150, 151, 158, 159, 164, 166, 170, 172, 172,
-        175, 176, 171, 183, 123, 117, 115, 111, 110, 109, 107, 106, 111, 112,
-        119, 119, 125, 127, 132, 136, 139, 144, 147, 152, 153, 160, 161, 166,
-        169, 173, 175, 176, 178, 177, 183, 173, 127, 121, 119, 115, 114, 113,
-        110, 109, 114, 115, 121, 122, 127, 130, 135, 138, 142, 147, 150, 156,
-        156, 164, 165, 170, 173, 178, 179, 180, 183, 186, 179, 190, 129, 122,
-        121, 116, 115, 114, 112, 110, 115, 116, 122, 123, 129, 131, 136, 139,
-        143, 148, 151, 157, 157, 165, 166, 172, 175, 179, 181, 182, 185, 186,
-        194, 181, 130, 123, 122, 117, 116, 115, 113, 111, 116, 117, 123, 124,
-        129, 131, 136, 140, 143, 149, 151, 157, 158, 166, 167, 172, 176, 180,
-        182, 183, 186, 189, 188, 202, 133, 126, 125, 120, 119, 117, 115, 113,
-        118, 119, 125, 126, 131, 133, 138, 141, 145, 151, 153, 159, 160, 168,
-        169, 175, 178, 183, 185, 186, 189, 188, 193, 190, 135, 128, 127, 122,
-        121, 119, 117, 115, 119, 121, 126, 127, 133, 133, 141, 140, 148, 149,
-        156, 158, 162, 167, 170, 176, 177, 186, 186, 189, 188, 194, 191, 197,
-        138, 130, 129, 124, 123, 121, 119, 117, 120, 123, 126, 128, 133, 134,
-        140, 141, 148, 148, 157, 156, 165, 163, 175, 171, 183, 179, 194, 188,
-        193, 191, 199, 193, 140, 132, 132, 125, 126, 122, 123, 117, 118, 127,
-        124, 133, 129, 140, 135, 148, 142, 156, 149, 165, 157, 172, 164, 183,
-        173, 190, 181, 202, 190, 197, 193, 203,
+        32, 31, 31, 30, 31, 33, 35, 36, 40, 41, 49, 49, 48, 48, 49, 50, 50, 52,
+        52, 54, 54, 57, 57, 60, 61, 63, 64, 65, 66, 67, 68, 69, 31, 31, 31, 31,
+        32, 34, 37, 38, 41, 42, 47, 47, 47, 47, 47, 47, 48, 49, 50, 52, 52, 54,
+        55, 57, 58, 60, 61, 61, 63, 64, 64, 65, 31, 31, 31, 31, 32, 35, 37, 39,
+        41, 42, 47, 47, 47, 46, 46, 47, 48, 49, 49, 51, 51, 54, 54, 56, 57, 59,
+        60, 61, 62, 63, 64, 65, 30, 31, 31, 32, 33, 35, 38, 40, 42, 42, 46, 46,
+        45, 45, 45, 45, 46, 47, 47, 49, 49, 52, 52, 54, 55, 57, 58, 58, 60, 61,
+        61, 62, 31, 32, 32, 33, 34, 37, 39, 41, 43, 43, 46, 46, 46, 45, 45, 46,
+        46, 47, 47, 49, 49, 51, 52, 54, 55, 57, 57, 58, 59, 60, 61, 62, 33, 34,
+        35, 35, 37, 39, 41, 43, 44, 45, 47, 47, 46, 46, 45, 46, 46, 47, 47, 49,
+        49, 51, 51, 53, 54, 56, 57, 57, 58, 59, 60, 61, 35, 37, 37, 38, 39, 41,
+        44, 46, 46, 46, 47, 47, 46, 46, 45, 46, 46, 47, 47, 48, 48, 50, 51, 52,
+        53, 55, 56, 56, 57, 58, 59, 61, 36, 38, 39, 40, 41, 43, 46, 47, 47, 47,
+        48, 47, 46, 46, 45, 46, 46, 46, 47, 48, 48, 50, 50, 52, 53, 54, 55, 55,
+        56, 57, 58, 58, 40, 41, 41, 42, 43, 44, 46, 47, 48, 48, 50, 49, 49, 49,
+        48, 49, 49, 49, 49, 51, 51, 52, 53, 54, 55, 57, 57, 58, 59, 59, 59, 59,
+        41, 42, 42, 42, 43, 45, 46, 47, 48, 48, 50, 50, 49, 49, 49, 49, 50, 50,
+        50, 52, 52, 53, 53, 55, 56, 57, 58, 58, 59, 60, 61, 62, 49, 47, 47, 46,
+        46, 47, 47, 48, 50, 50, 53, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 56,
+        57, 58, 59, 60, 61, 61, 62, 62, 62, 62, 49, 47, 47, 46, 46, 47, 47, 47,
+        49, 50, 53, 53, 53, 53, 54, 54, 54, 54, 54, 55, 56, 57, 57, 59, 59, 61,
+        61, 62, 63, 63, 64, 65, 48, 47, 47, 45, 46, 46, 46, 46, 49, 49, 53, 53,
+        54, 54, 55, 56, 56, 57, 57, 58, 58, 60, 60, 61, 62, 63, 64, 64, 65, 66,
+        65, 65, 48, 47, 46, 45, 45, 46, 46, 46, 49, 49, 53, 53, 54, 55, 56, 57,
+        57, 58, 58, 59, 60, 61, 61, 63, 63, 65, 65, 65, 66, 66, 67, 68, 49, 47,
+        46, 45, 45, 45, 45, 45, 48, 49, 53, 54, 55, 56, 58, 59, 60, 61, 61, 62,
+        62, 63, 64, 65, 66, 67, 68, 68, 69, 70, 69, 68, 50, 47, 47, 45, 46, 46,
+        46, 46, 49, 49, 54, 54, 56, 57, 59, 60, 60, 62, 62, 63, 64, 65, 65, 67,
+        68, 69, 69, 70, 70, 70, 71, 71, 50, 48, 48, 46, 46, 46, 46, 46, 49, 50,
+        54, 54, 56, 57, 60, 60, 61, 63, 63, 65, 65, 67, 67, 68, 69, 71, 71, 71,
+        72, 73, 72, 71, 52, 49, 49, 47, 47, 47, 47, 46, 49, 50, 54, 54, 57, 58,
+        61, 62, 63, 65, 65, 67, 67, 69, 70, 71, 72, 73, 74, 74, 75, 74, 74, 75,
+        52, 50, 49, 47, 47, 47, 47, 47, 49, 50, 54, 54, 57, 58, 61, 62, 63, 65,
+        66, 68, 68, 70, 71, 72, 73, 75, 75, 75, 76, 77, 77, 75, 54, 52, 51, 49,
+        49, 49, 48, 48, 51, 52, 55, 55, 58, 59, 62, 63, 65, 67, 68, 70, 70, 73,
+        73, 75, 76, 78, 78, 78, 79, 78, 78, 79, 54, 52, 51, 49, 49, 49, 48, 48,
+        51, 52, 55, 56, 58, 60, 62, 64, 65, 67, 68, 70, 71, 73, 74, 75, 76, 78,
+        78, 79, 80, 81, 81, 79, 57, 54, 54, 52, 51, 51, 50, 50, 52, 53, 56, 57,
+        60, 61, 63, 65, 67, 69, 70, 73, 73, 76, 77, 79, 80, 82, 82, 83, 84, 83,
+        82, 83, 57, 55, 54, 52, 52, 51, 51, 50, 53, 53, 57, 57, 60, 61, 64, 65,
+        67, 70, 71, 73, 74, 77, 77, 79, 80, 82, 83, 83, 84, 85, 85, 83, 60, 57,
+        56, 54, 54, 53, 52, 52, 54, 55, 58, 59, 61, 63, 65, 67, 68, 71, 72, 75,
+        75, 79, 79, 82, 83, 85, 86, 86, 87, 87, 86, 87, 61, 58, 57, 55, 55, 54,
+        53, 53, 55, 56, 59, 59, 62, 63, 66, 68, 69, 72, 73, 76, 76, 80, 80, 83,
+        84, 86, 87, 88, 89, 89, 89, 87, 63, 60, 59, 57, 57, 56, 55, 54, 57, 57,
+        60, 61, 63, 65, 67, 69, 71, 73, 75, 78, 78, 82, 82, 85, 86, 89, 89, 90,
+        91, 92, 90, 91, 64, 61, 60, 58, 57, 57, 56, 55, 57, 58, 61, 61, 64, 65,
+        68, 69, 71, 74, 75, 78, 78, 82, 83, 86, 87, 89, 90, 91, 92, 93, 94, 91,
+        65, 61, 61, 58, 58, 57, 56, 55, 58, 58, 61, 62, 64, 65, 68, 70, 71, 74,
+        75, 78, 79, 83, 83, 86, 88, 90, 91, 91, 93, 94, 94, 96, 66, 63, 62, 60,
+        59, 58, 57, 56, 59, 59, 62, 63, 65, 66, 69, 70, 72, 75, 76, 79, 80, 84,
+        84, 87, 89, 91, 92, 93, 94, 94, 96, 96, 67, 64, 63, 61, 60, 59, 58, 57,
+        59, 60, 62, 63, 66, 66, 70, 70, 73, 74, 77, 78, 81, 83, 85, 87, 89, 92,
+        93, 94, 94, 96, 96, 97, 68, 64, 64, 61, 61, 60, 59, 58, 59, 61, 62, 64,
+        65, 67, 69, 71, 72, 74, 77, 78, 81, 82, 85, 86, 89, 90, 94, 94, 96, 96,
+        98, 97, 69, 65, 65, 62, 62, 61, 61, 58, 59, 62, 62, 65, 65, 68, 68, 71,
+        71, 75, 75, 79, 79, 83, 83, 87, 87, 91, 91, 96, 96, 97, 97, 99,
         /* Size 4x8 */
-        63, 94, 100, 122, 72, 94, 95, 114, 86, 100, 101, 117, 91, 106, 117, 131,
-        95, 108, 132, 148, 104, 113, 141, 165, 115, 121, 150, 180, 123, 127,
-        155, 185,
+        31, 47, 50, 61, 36, 47, 47, 57, 43, 50, 50, 58, 45, 53, 58, 65, 47, 54,
+        66, 74, 52, 56, 70, 82, 57, 60, 75, 90, 61, 63, 77, 93,
         /* Size 8x4 */
-        63, 72, 86, 91, 95, 104, 115, 123, 94, 94, 100, 106, 108, 113, 121, 127,
-        100, 95, 101, 117, 132, 141, 150, 155, 122, 114, 117, 131, 148, 165,
-        180, 185,
+        31, 36, 43, 45, 47, 52, 57, 61, 47, 47, 50, 53, 54, 56, 60, 63, 50, 47,
+        50, 58, 66, 70, 75, 77, 61, 57, 58, 65, 74, 82, 90, 93,
         /* Size 8x16 */
-        64, 64, 81, 98, 103, 115, 127, 135, 62, 66, 83, 94, 98, 108, 119, 127,
-        63, 70, 86, 92, 95, 103, 114, 121, 71, 79, 92, 93, 94, 101, 110, 117,
-        82, 86, 96, 98, 99, 105, 114, 119, 98, 94, 100, 107, 109, 114, 121, 126,
-        97, 92, 98, 109, 114, 120, 128, 133, 98, 91, 97, 113, 122, 128, 135,
-        141, 101, 93, 99, 115, 126, 134, 142, 148, 104, 96, 100, 117, 131, 142,
-        150, 156, 109, 100, 103, 119, 134, 147, 156, 162, 115, 105, 106, 122,
-        139, 154, 165, 171, 122, 111, 112, 127, 144, 160, 173, 177, 128, 116,
-        116, 130, 147, 165, 179, 185, 132, 119, 119, 133, 150, 168, 183, 188,
-        137, 124, 121, 133, 149, 166, 183, 194,
+        32, 32, 40, 49, 51, 57, 63, 67, 31, 33, 41, 47, 49, 54, 59, 63, 31, 35,
+        43, 46, 47, 51, 57, 60, 35, 39, 46, 46, 47, 50, 55, 58, 41, 43, 48, 49,
+        49, 52, 57, 59, 49, 47, 50, 53, 54, 57, 60, 62, 48, 46, 49, 54, 57, 60,
+        64, 65, 49, 45, 48, 56, 61, 64, 67, 69, 50, 46, 49, 57, 63, 67, 71, 73,
+        52, 48, 50, 58, 65, 71, 75, 77, 54, 50, 51, 59, 67, 73, 78, 81, 57, 52,
+        53, 61, 69, 77, 82, 85, 61, 55, 56, 63, 72, 80, 86, 88, 64, 58, 58, 65,
+        73, 82, 89, 92, 66, 59, 59, 66, 75, 84, 91, 94, 68, 61, 59, 65, 72, 81,
+        89, 95,
         /* Size 16x8 */
-        64, 62, 63, 71, 82, 98, 97, 98, 101, 104, 109, 115, 122, 128, 132, 137,
-        64, 66, 70, 79, 86, 94, 92, 91, 93, 96, 100, 105, 111, 116, 119, 124,
-        81, 83, 86, 92, 96, 100, 98, 97, 99, 100, 103, 106, 112, 116, 119, 121,
-        98, 94, 92, 93, 98, 107, 109, 113, 115, 117, 119, 122, 127, 130, 133,
-        133, 103, 98, 95, 94, 99, 109, 114, 122, 126, 131, 134, 139, 144, 147,
-        150, 149, 115, 108, 103, 101, 105, 114, 120, 128, 134, 142, 147, 154,
-        160, 165, 168, 166, 127, 119, 114, 110, 114, 121, 128, 135, 142, 150,
-        156, 165, 173, 179, 183, 183, 135, 127, 121, 117, 119, 126, 133, 141,
-        148, 156, 162, 171, 177, 185, 188, 194,
+        32, 31, 31, 35, 41, 49, 48, 49, 50, 52, 54, 57, 61, 64, 66, 68, 32, 33,
+        35, 39, 43, 47, 46, 45, 46, 48, 50, 52, 55, 58, 59, 61, 40, 41, 43, 46,
+        48, 50, 49, 48, 49, 50, 51, 53, 56, 58, 59, 59, 49, 47, 46, 46, 49, 53,
+        54, 56, 57, 58, 59, 61, 63, 65, 66, 65, 51, 49, 47, 47, 49, 54, 57, 61,
+        63, 65, 67, 69, 72, 73, 75, 72, 57, 54, 51, 50, 52, 57, 60, 64, 67, 71,
+        73, 77, 80, 82, 84, 81, 63, 59, 57, 55, 57, 60, 64, 67, 71, 75, 78, 82,
+        86, 89, 91, 89, 67, 63, 60, 58, 59, 62, 65, 69, 73, 77, 81, 85, 88, 92,
+        94, 95,
         /* Size 16x32 */
-        64, 62, 64, 74, 81, 96, 98, 98, 103, 105, 115, 116, 127, 129, 135, 139,
-        63, 63, 66, 77, 83, 94, 94, 94, 99, 100, 109, 110, 120, 122, 128, 131,
-        62, 63, 66, 77, 83, 94, 94, 94, 98, 99, 108, 109, 119, 121, 127, 131,
-        61, 64, 67, 80, 84, 92, 91, 91, 95, 96, 104, 105, 115, 116, 122, 124,
-        63, 67, 70, 82, 86, 93, 92, 91, 95, 96, 103, 104, 114, 115, 121, 125,
-        67, 72, 74, 86, 89, 94, 93, 92, 95, 95, 103, 104, 112, 114, 119, 121,
-        71, 77, 79, 91, 92, 95, 93, 91, 94, 95, 101, 102, 110, 112, 117, 122,
-        74, 80, 83, 94, 95, 95, 93, 91, 93, 94, 100, 101, 109, 110, 115, 116,
-        82, 85, 86, 95, 96, 99, 98, 97, 99, 100, 105, 106, 114, 115, 119, 118,
-        84, 86, 87, 95, 97, 100, 99, 99, 101, 101, 107, 108, 115, 117, 121, 127,
-        98, 93, 94, 96, 100, 106, 107, 107, 109, 109, 114, 114, 121, 122, 126,
-        123, 98, 93, 94, 96, 100, 106, 107, 108, 109, 110, 114, 115, 122, 123,
-        126, 132, 97, 92, 92, 94, 98, 106, 109, 112, 114, 115, 120, 121, 128,
-        129, 133, 129, 97, 91, 92, 93, 98, 106, 110, 113, 116, 117, 122, 123,
-        130, 131, 132, 139, 98, 91, 91, 92, 97, 107, 113, 117, 122, 123, 128,
-        128, 135, 136, 141, 135, 99, 92, 92, 92, 98, 107, 114, 118, 124, 125,
-        131, 132, 138, 139, 140, 147, 101, 93, 93, 93, 99, 108, 115, 119, 126,
-        128, 134, 135, 142, 143, 148, 141, 103, 95, 95, 94, 99, 108, 116, 122,
-        129, 132, 139, 140, 147, 148, 149, 155, 104, 96, 96, 95, 100, 109, 117,
-        122, 131, 133, 142, 142, 150, 151, 156, 149, 108, 100, 99, 97, 102, 111,
-        119, 125, 134, 137, 146, 147, 155, 157, 158, 165, 109, 100, 100, 98,
-        103, 111, 119, 125, 134, 137, 147, 148, 156, 157, 162, 157, 114, 104,
-        104, 101, 105, 113, 121, 128, 138, 141, 153, 154, 164, 165, 167, 172,
-        115, 105, 105, 102, 106, 114, 122, 128, 139, 142, 154, 155, 165, 167,
-        171, 164, 120, 109, 109, 105, 110, 117, 125, 131, 142, 145, 158, 159,
-        170, 172, 176, 182, 122, 112, 111, 107, 112, 119, 127, 133, 144, 147,
-        160, 162, 173, 175, 177, 172, 127, 115, 114, 110, 114, 121, 129, 135,
-        146, 150, 164, 165, 178, 180, 186, 189, 128, 117, 116, 111, 116, 122,
-        130, 136, 147, 151, 165, 167, 179, 181, 185, 180, 129, 118, 117, 112,
-        116, 123, 131, 136, 148, 151, 166, 167, 180, 182, 189, 201, 132, 121,
-        119, 114, 119, 125, 133, 138, 150, 153, 168, 170, 183, 185, 188, 189,
-        135, 123, 122, 116, 120, 127, 133, 140, 149, 155, 167, 170, 185, 185,
-        194, 196, 137, 125, 124, 118, 121, 128, 133, 141, 149, 156, 166, 172,
-        183, 187, 194, 192, 139, 126, 127, 119, 120, 133, 130, 148, 142, 165,
-        157, 183, 173, 200, 189, 202,
+        32, 31, 32, 37, 40, 48, 49, 49, 51, 52, 57, 58, 63, 64, 67, 67, 31, 31,
+        33, 38, 41, 47, 47, 47, 49, 50, 54, 55, 60, 61, 63, 64, 31, 31, 33, 38,
+        41, 47, 47, 47, 49, 49, 54, 54, 59, 60, 63, 64, 30, 32, 33, 40, 42, 46,
+        45, 45, 47, 48, 52, 52, 57, 58, 60, 61, 31, 33, 35, 41, 43, 46, 46, 45,
+        47, 48, 51, 52, 57, 57, 60, 61, 33, 36, 37, 43, 44, 47, 46, 46, 47, 47,
+        51, 52, 56, 57, 59, 60, 35, 38, 39, 45, 46, 47, 46, 45, 47, 47, 50, 51,
+        55, 56, 58, 60, 37, 40, 41, 47, 47, 47, 46, 45, 46, 47, 50, 50, 54, 55,
+        57, 58, 41, 42, 43, 47, 48, 49, 49, 48, 49, 50, 52, 53, 57, 57, 59, 58,
+        42, 43, 43, 47, 48, 50, 49, 49, 50, 50, 53, 54, 57, 58, 60, 61, 49, 46,
+        47, 48, 50, 53, 53, 53, 54, 54, 57, 57, 60, 61, 62, 61, 49, 46, 47, 48,
+        50, 53, 53, 54, 54, 55, 57, 57, 61, 61, 63, 64, 48, 46, 46, 47, 49, 53,
+        54, 56, 57, 57, 60, 60, 64, 64, 65, 64, 48, 45, 46, 46, 49, 53, 55, 56,
+        58, 58, 61, 61, 65, 65, 66, 67, 49, 45, 45, 46, 48, 53, 56, 58, 61, 61,
+        64, 64, 67, 68, 69, 67, 49, 46, 46, 46, 49, 53, 57, 59, 62, 62, 65, 66,
+        69, 69, 70, 70, 50, 46, 46, 46, 49, 54, 57, 59, 63, 64, 67, 67, 71, 71,
+        73, 71, 51, 47, 47, 47, 49, 54, 58, 61, 64, 66, 69, 70, 73, 74, 74, 74,
+        52, 48, 48, 47, 50, 54, 58, 61, 65, 66, 71, 71, 75, 75, 77, 74, 54, 50,
+        49, 48, 51, 55, 59, 62, 67, 68, 73, 73, 77, 78, 78, 78, 54, 50, 50, 49,
+        51, 55, 59, 62, 67, 68, 73, 74, 78, 78, 81, 78, 57, 52, 52, 50, 52, 56,
+        60, 64, 69, 70, 76, 77, 82, 82, 83, 82, 57, 52, 52, 51, 53, 57, 61, 64,
+        69, 71, 77, 77, 82, 83, 85, 82, 60, 54, 54, 52, 55, 58, 62, 65, 71, 72,
+        79, 79, 85, 86, 87, 86, 61, 56, 55, 53, 56, 59, 63, 66, 72, 73, 80, 81,
+        86, 87, 88, 86, 63, 57, 57, 55, 57, 60, 64, 67, 73, 75, 82, 82, 89, 90,
+        92, 90, 64, 58, 58, 55, 58, 61, 65, 68, 73, 75, 82, 83, 89, 90, 92, 90,
+        64, 59, 58, 56, 58, 61, 65, 68, 74, 75, 83, 83, 90, 91, 94, 95, 66, 60,
+        59, 57, 59, 62, 66, 69, 75, 76, 84, 85, 91, 92, 94, 95, 67, 61, 60, 58,
+        59, 63, 66, 70, 74, 77, 82, 85, 91, 93, 96, 96, 68, 62, 61, 58, 59, 64,
+        65, 71, 72, 78, 81, 86, 89, 94, 95, 96, 68, 62, 62, 59, 59, 65, 65, 71,
+        71, 79, 79, 87, 87, 95, 95, 98,
         /* Size 32x16 */
-        64, 63, 62, 61, 63, 67, 71, 74, 82, 84, 98, 98, 97, 97, 98, 99, 101,
-        103, 104, 108, 109, 114, 115, 120, 122, 127, 128, 129, 132, 135, 137,
-        139, 62, 63, 63, 64, 67, 72, 77, 80, 85, 86, 93, 93, 92, 91, 91, 92, 93,
-        95, 96, 100, 100, 104, 105, 109, 112, 115, 117, 118, 121, 123, 125, 126,
-        64, 66, 66, 67, 70, 74, 79, 83, 86, 87, 94, 94, 92, 92, 91, 92, 93, 95,
-        96, 99, 100, 104, 105, 109, 111, 114, 116, 117, 119, 122, 124, 127, 74,
-        77, 77, 80, 82, 86, 91, 94, 95, 95, 96, 96, 94, 93, 92, 92, 93, 94, 95,
-        97, 98, 101, 102, 105, 107, 110, 111, 112, 114, 116, 118, 119, 81, 83,
-        83, 84, 86, 89, 92, 95, 96, 97, 100, 100, 98, 98, 97, 98, 99, 99, 100,
-        102, 103, 105, 106, 110, 112, 114, 116, 116, 119, 120, 121, 120, 96, 94,
-        94, 92, 93, 94, 95, 95, 99, 100, 106, 106, 106, 106, 107, 107, 108, 108,
-        109, 111, 111, 113, 114, 117, 119, 121, 122, 123, 125, 127, 128, 133,
-        98, 94, 94, 91, 92, 93, 93, 93, 98, 99, 107, 107, 109, 110, 113, 114,
-        115, 116, 117, 119, 119, 121, 122, 125, 127, 129, 130, 131, 133, 133,
-        133, 130, 98, 94, 94, 91, 91, 92, 91, 91, 97, 99, 107, 108, 112, 113,
-        117, 118, 119, 122, 122, 125, 125, 128, 128, 131, 133, 135, 136, 136,
-        138, 140, 141, 148, 103, 99, 98, 95, 95, 95, 94, 93, 99, 101, 109, 109,
-        114, 116, 122, 124, 126, 129, 131, 134, 134, 138, 139, 142, 144, 146,
-        147, 148, 150, 149, 149, 142, 105, 100, 99, 96, 96, 95, 95, 94, 100,
-        101, 109, 110, 115, 117, 123, 125, 128, 132, 133, 137, 137, 141, 142,
-        145, 147, 150, 151, 151, 153, 155, 156, 165, 115, 109, 108, 104, 103,
-        103, 101, 100, 105, 107, 114, 114, 120, 122, 128, 131, 134, 139, 142,
-        146, 147, 153, 154, 158, 160, 164, 165, 166, 168, 167, 166, 157, 116,
-        110, 109, 105, 104, 104, 102, 101, 106, 108, 114, 115, 121, 123, 128,
-        132, 135, 140, 142, 147, 148, 154, 155, 159, 162, 165, 167, 167, 170,
-        170, 172, 183, 127, 120, 119, 115, 114, 112, 110, 109, 114, 115, 121,
-        122, 128, 130, 135, 138, 142, 147, 150, 155, 156, 164, 165, 170, 173,
-        178, 179, 180, 183, 185, 183, 173, 129, 122, 121, 116, 115, 114, 112,
-        110, 115, 117, 122, 123, 129, 131, 136, 139, 143, 148, 151, 157, 157,
-        165, 167, 172, 175, 180, 181, 182, 185, 185, 187, 200, 135, 128, 127,
-        122, 121, 119, 117, 115, 119, 121, 126, 126, 133, 132, 141, 140, 148,
-        149, 156, 158, 162, 167, 171, 176, 177, 186, 185, 189, 188, 194, 194,
-        189, 139, 131, 131, 124, 125, 121, 122, 116, 118, 127, 123, 132, 129,
-        139, 135, 147, 141, 155, 149, 165, 157, 172, 164, 182, 172, 189, 180,
-        201, 189, 196, 192, 202,
+        32, 31, 31, 30, 31, 33, 35, 37, 41, 42, 49, 49, 48, 48, 49, 49, 50, 51,
+        52, 54, 54, 57, 57, 60, 61, 63, 64, 64, 66, 67, 68, 68, 31, 31, 31, 32,
+        33, 36, 38, 40, 42, 43, 46, 46, 46, 45, 45, 46, 46, 47, 48, 50, 50, 52,
+        52, 54, 56, 57, 58, 59, 60, 61, 62, 62, 32, 33, 33, 33, 35, 37, 39, 41,
+        43, 43, 47, 47, 46, 46, 45, 46, 46, 47, 48, 49, 50, 52, 52, 54, 55, 57,
+        58, 58, 59, 60, 61, 62, 37, 38, 38, 40, 41, 43, 45, 47, 47, 47, 48, 48,
+        47, 46, 46, 46, 46, 47, 47, 48, 49, 50, 51, 52, 53, 55, 55, 56, 57, 58,
+        58, 59, 40, 41, 41, 42, 43, 44, 46, 47, 48, 48, 50, 50, 49, 49, 48, 49,
+        49, 49, 50, 51, 51, 52, 53, 55, 56, 57, 58, 58, 59, 59, 59, 59, 48, 47,
+        47, 46, 46, 47, 47, 47, 49, 50, 53, 53, 53, 53, 53, 53, 54, 54, 54, 55,
+        55, 56, 57, 58, 59, 60, 61, 61, 62, 63, 64, 65, 49, 47, 47, 45, 46, 46,
+        46, 46, 49, 49, 53, 53, 54, 55, 56, 57, 57, 58, 58, 59, 59, 60, 61, 62,
+        63, 64, 65, 65, 66, 66, 65, 65, 49, 47, 47, 45, 45, 46, 45, 45, 48, 49,
+        53, 54, 56, 56, 58, 59, 59, 61, 61, 62, 62, 64, 64, 65, 66, 67, 68, 68,
+        69, 70, 71, 71, 51, 49, 49, 47, 47, 47, 47, 46, 49, 50, 54, 54, 57, 58,
+        61, 62, 63, 64, 65, 67, 67, 69, 69, 71, 72, 73, 73, 74, 75, 74, 72, 71,
+        52, 50, 49, 48, 48, 47, 47, 47, 50, 50, 54, 55, 57, 58, 61, 62, 64, 66,
+        66, 68, 68, 70, 71, 72, 73, 75, 75, 75, 76, 77, 78, 79, 57, 54, 54, 52,
+        51, 51, 50, 50, 52, 53, 57, 57, 60, 61, 64, 65, 67, 69, 71, 73, 73, 76,
+        77, 79, 80, 82, 82, 83, 84, 82, 81, 79, 58, 55, 54, 52, 52, 52, 51, 50,
+        53, 54, 57, 57, 60, 61, 64, 66, 67, 70, 71, 73, 74, 77, 77, 79, 81, 82,
+        83, 83, 85, 85, 86, 87, 63, 60, 59, 57, 57, 56, 55, 54, 57, 57, 60, 61,
+        64, 65, 67, 69, 71, 73, 75, 77, 78, 82, 82, 85, 86, 89, 89, 90, 91, 91,
+        89, 87, 64, 61, 60, 58, 57, 57, 56, 55, 57, 58, 61, 61, 64, 65, 68, 69,
+        71, 74, 75, 78, 78, 82, 83, 86, 87, 90, 90, 91, 92, 93, 94, 95, 67, 63,
+        63, 60, 60, 59, 58, 57, 59, 60, 62, 63, 65, 66, 69, 70, 73, 74, 77, 78,
+        81, 83, 85, 87, 88, 92, 92, 94, 94, 96, 95, 95, 67, 64, 64, 61, 61, 60,
+        60, 58, 58, 61, 61, 64, 64, 67, 67, 70, 71, 74, 74, 78, 78, 82, 82, 86,
+        86, 90, 90, 95, 95, 96, 96, 98,
         /* Size 4x16 */
-        62, 96, 105, 129, 63, 94, 99, 121, 67, 93, 96, 115, 77, 95, 95, 112, 85,
-        99, 100, 115, 93, 106, 109, 122, 92, 106, 115, 129, 91, 107, 123, 136,
-        93, 108, 128, 143, 96, 109, 133, 151, 100, 111, 137, 157, 105, 114, 142,
-        167, 112, 119, 147, 175, 117, 122, 151, 181, 121, 125, 153, 185, 125,
-        128, 156, 187,
+        31, 48, 52, 64, 31, 47, 49, 60, 33, 46, 48, 57, 38, 47, 47, 56, 42, 49,
+        50, 57, 46, 53, 54, 61, 46, 53, 57, 64, 45, 53, 61, 68, 46, 54, 64, 71,
+        48, 54, 66, 75, 50, 55, 68, 78, 52, 57, 71, 83, 56, 59, 73, 87, 58, 61,
+        75, 90, 60, 62, 76, 92, 62, 64, 78, 94,
         /* Size 16x4 */
-        62, 63, 67, 77, 85, 93, 92, 91, 93, 96, 100, 105, 112, 117, 121, 125,
-        96, 94, 93, 95, 99, 106, 106, 107, 108, 109, 111, 114, 119, 122, 125,
-        128, 105, 99, 96, 95, 100, 109, 115, 123, 128, 133, 137, 142, 147, 151,
-        153, 156, 129, 121, 115, 112, 115, 122, 129, 136, 143, 151, 157, 167,
-        175, 181, 185, 187,
+        31, 31, 33, 38, 42, 46, 46, 45, 46, 48, 50, 52, 56, 58, 60, 62, 48, 47,
+        46, 47, 49, 53, 53, 53, 54, 54, 55, 57, 59, 61, 62, 64, 52, 49, 48, 47,
+        50, 54, 57, 61, 64, 66, 68, 71, 73, 75, 76, 78, 64, 60, 57, 56, 57, 61,
+        64, 68, 71, 75, 78, 83, 87, 90, 92, 94,
         /* Size 8x32 */
-        64, 64, 81, 98, 103, 115, 127, 135, 63, 66, 83, 94, 99, 109, 120, 128,
-        62, 66, 83, 94, 98, 108, 119, 127, 61, 67, 84, 91, 95, 104, 115, 122,
-        63, 70, 86, 92, 95, 103, 114, 121, 67, 74, 89, 93, 95, 103, 112, 119,
-        71, 79, 92, 93, 94, 101, 110, 117, 74, 83, 95, 93, 93, 100, 109, 115,
-        82, 86, 96, 98, 99, 105, 114, 119, 84, 87, 97, 99, 101, 107, 115, 121,
-        98, 94, 100, 107, 109, 114, 121, 126, 98, 94, 100, 107, 109, 114, 122,
-        126, 97, 92, 98, 109, 114, 120, 128, 133, 97, 92, 98, 110, 116, 122,
-        130, 132, 98, 91, 97, 113, 122, 128, 135, 141, 99, 92, 98, 114, 124,
-        131, 138, 140, 101, 93, 99, 115, 126, 134, 142, 148, 103, 95, 99, 116,
-        129, 139, 147, 149, 104, 96, 100, 117, 131, 142, 150, 156, 108, 99, 102,
-        119, 134, 146, 155, 158, 109, 100, 103, 119, 134, 147, 156, 162, 114,
-        104, 105, 121, 138, 153, 164, 167, 115, 105, 106, 122, 139, 154, 165,
-        171, 120, 109, 110, 125, 142, 158, 170, 176, 122, 111, 112, 127, 144,
-        160, 173, 177, 127, 114, 114, 129, 146, 164, 178, 186, 128, 116, 116,
-        130, 147, 165, 179, 185, 129, 117, 116, 131, 148, 166, 180, 189, 132,
-        119, 119, 133, 150, 168, 183, 188, 135, 122, 120, 133, 149, 167, 185,
-        194, 137, 124, 121, 133, 149, 166, 183, 194, 139, 127, 120, 130, 142,
-        157, 173, 189,
+        32, 32, 40, 49, 51, 57, 63, 67, 31, 33, 41, 47, 49, 54, 60, 63, 31, 33,
+        41, 47, 49, 54, 59, 63, 30, 33, 42, 45, 47, 52, 57, 60, 31, 35, 43, 46,
+        47, 51, 57, 60, 33, 37, 44, 46, 47, 51, 56, 59, 35, 39, 46, 46, 47, 50,
+        55, 58, 37, 41, 47, 46, 46, 50, 54, 57, 41, 43, 48, 49, 49, 52, 57, 59,
+        42, 43, 48, 49, 50, 53, 57, 60, 49, 47, 50, 53, 54, 57, 60, 62, 49, 47,
+        50, 53, 54, 57, 61, 63, 48, 46, 49, 54, 57, 60, 64, 65, 48, 46, 49, 55,
+        58, 61, 65, 66, 49, 45, 48, 56, 61, 64, 67, 69, 49, 46, 49, 57, 62, 65,
+        69, 70, 50, 46, 49, 57, 63, 67, 71, 73, 51, 47, 49, 58, 64, 69, 73, 74,
+        52, 48, 50, 58, 65, 71, 75, 77, 54, 49, 51, 59, 67, 73, 77, 78, 54, 50,
+        51, 59, 67, 73, 78, 81, 57, 52, 52, 60, 69, 76, 82, 83, 57, 52, 53, 61,
+        69, 77, 82, 85, 60, 54, 55, 62, 71, 79, 85, 87, 61, 55, 56, 63, 72, 80,
+        86, 88, 63, 57, 57, 64, 73, 82, 89, 92, 64, 58, 58, 65, 73, 82, 89, 92,
+        64, 58, 58, 65, 74, 83, 90, 94, 66, 59, 59, 66, 75, 84, 91, 94, 67, 60,
+        59, 66, 74, 82, 91, 96, 68, 61, 59, 65, 72, 81, 89, 95, 68, 62, 59, 65,
+        71, 79, 87, 95,
         /* Size 32x8 */
-        64, 63, 62, 61, 63, 67, 71, 74, 82, 84, 98, 98, 97, 97, 98, 99, 101,
-        103, 104, 108, 109, 114, 115, 120, 122, 127, 128, 129, 132, 135, 137,
-        139, 64, 66, 66, 67, 70, 74, 79, 83, 86, 87, 94, 94, 92, 92, 91, 92, 93,
-        95, 96, 99, 100, 104, 105, 109, 111, 114, 116, 117, 119, 122, 124, 127,
-        81, 83, 83, 84, 86, 89, 92, 95, 96, 97, 100, 100, 98, 98, 97, 98, 99,
-        99, 100, 102, 103, 105, 106, 110, 112, 114, 116, 116, 119, 120, 121,
-        120, 98, 94, 94, 91, 92, 93, 93, 93, 98, 99, 107, 107, 109, 110, 113,
-        114, 115, 116, 117, 119, 119, 121, 122, 125, 127, 129, 130, 131, 133,
-        133, 133, 130, 103, 99, 98, 95, 95, 95, 94, 93, 99, 101, 109, 109, 114,
-        116, 122, 124, 126, 129, 131, 134, 134, 138, 139, 142, 144, 146, 147,
-        148, 150, 149, 149, 142, 115, 109, 108, 104, 103, 103, 101, 100, 105,
-        107, 114, 114, 120, 122, 128, 131, 134, 139, 142, 146, 147, 153, 154,
-        158, 160, 164, 165, 166, 168, 167, 166, 157, 127, 120, 119, 115, 114,
-        112, 110, 109, 114, 115, 121, 122, 128, 130, 135, 138, 142, 147, 150,
-        155, 156, 164, 165, 170, 173, 178, 179, 180, 183, 185, 183, 173, 135,
-        128, 127, 122, 121, 119, 117, 115, 119, 121, 126, 126, 133, 132, 141,
-        140, 148, 149, 156, 158, 162, 167, 171, 176, 177, 186, 185, 189, 188,
-        194, 194, 189 },
+        32, 31, 31, 30, 31, 33, 35, 37, 41, 42, 49, 49, 48, 48, 49, 49, 50, 51,
+        52, 54, 54, 57, 57, 60, 61, 63, 64, 64, 66, 67, 68, 68, 32, 33, 33, 33,
+        35, 37, 39, 41, 43, 43, 47, 47, 46, 46, 45, 46, 46, 47, 48, 49, 50, 52,
+        52, 54, 55, 57, 58, 58, 59, 60, 61, 62, 40, 41, 41, 42, 43, 44, 46, 47,
+        48, 48, 50, 50, 49, 49, 48, 49, 49, 49, 50, 51, 51, 52, 53, 55, 56, 57,
+        58, 58, 59, 59, 59, 59, 49, 47, 47, 45, 46, 46, 46, 46, 49, 49, 53, 53,
+        54, 55, 56, 57, 57, 58, 58, 59, 59, 60, 61, 62, 63, 64, 65, 65, 66, 66,
+        65, 65, 51, 49, 49, 47, 47, 47, 47, 46, 49, 50, 54, 54, 57, 58, 61, 62,
+        63, 64, 65, 67, 67, 69, 69, 71, 72, 73, 73, 74, 75, 74, 72, 71, 57, 54,
+        54, 52, 51, 51, 50, 50, 52, 53, 57, 57, 60, 61, 64, 65, 67, 69, 71, 73,
+        73, 76, 77, 79, 80, 82, 82, 83, 84, 82, 81, 79, 63, 60, 59, 57, 57, 56,
+        55, 54, 57, 57, 60, 61, 64, 65, 67, 69, 71, 73, 75, 77, 78, 82, 82, 85,
+        86, 89, 89, 90, 91, 91, 89, 87, 67, 63, 63, 60, 60, 59, 58, 57, 59, 60,
+        62, 63, 65, 66, 69, 70, 73, 74, 77, 78, 81, 83, 85, 87, 88, 92, 92, 94,
+        94, 96, 95, 95 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        71, 116, 116, 210,
+        35, 58, 58, 105,
 #endif
         /* Size 4x4 */
-        65, 69, 99, 145, 69, 97, 120, 158, 99, 120, 165, 208, 145, 158, 208,
-        268,
+        32, 34, 49, 72, 34, 48, 60, 79, 49, 60, 82, 104, 72, 79, 104, 134,
         /* Size 8x8 */
-        64, 64, 68, 77, 93, 113, 136, 157, 64, 67, 71, 78, 91, 108, 129, 148,
-        68, 71, 79, 90, 102, 117, 136, 153, 77, 78, 90, 108, 122, 138, 156, 173,
-        93, 91, 102, 122, 142, 161, 181, 198, 113, 108, 117, 138, 161, 184, 207,
-        226, 136, 129, 136, 156, 181, 207, 235, 256, 157, 148, 153, 173, 198,
-        226, 256, 280,
+        32, 32, 34, 38, 46, 56, 68, 78, 32, 33, 35, 39, 45, 54, 64, 74, 34, 35,
+        39, 45, 51, 58, 68, 76, 38, 39, 45, 54, 61, 69, 78, 86, 46, 45, 51, 61,
+        71, 80, 90, 99, 56, 54, 58, 69, 80, 92, 103, 113, 68, 64, 68, 78, 90,
+        103, 117, 128, 78, 74, 76, 86, 99, 113, 128, 140,
         /* Size 16x16 */
-        64, 63, 63, 63, 64, 68, 72, 79, 88, 97, 108, 118, 131, 143, 160, 166,
-        63, 64, 64, 64, 65, 68, 70, 77, 85, 93, 103, 113, 125, 136, 152, 157,
-        63, 64, 65, 65, 65, 67, 69, 75, 82, 89, 99, 108, 119, 130, 145, 150, 63,
-        64, 65, 67, 68, 71, 73, 78, 84, 91, 100, 108, 118, 129, 143, 148, 64,
-        65, 65, 68, 71, 74, 77, 81, 85, 92, 99, 107, 116, 126, 139, 144, 68, 68,
-        67, 71, 74, 79, 85, 90, 95, 102, 109, 117, 126, 136, 148, 153, 72, 70,
-        69, 73, 77, 85, 97, 101, 108, 114, 120, 128, 136, 146, 158, 162, 79, 77,
-        75, 78, 81, 90, 101, 108, 116, 122, 130, 138, 147, 156, 168, 173, 88,
-        85, 82, 84, 85, 95, 108, 116, 127, 134, 143, 151, 159, 169, 181, 185,
-        97, 93, 89, 91, 92, 102, 114, 122, 134, 142, 153, 161, 171, 181, 193,
-        198, 108, 103, 99, 100, 99, 109, 120, 130, 143, 153, 165, 174, 185, 195,
-        208, 213, 118, 113, 108, 108, 107, 117, 128, 138, 151, 161, 174, 184,
-        196, 207, 221, 226, 131, 125, 119, 118, 116, 126, 136, 147, 159, 171,
-        185, 196, 210, 222, 237, 242, 143, 136, 130, 129, 126, 136, 146, 156,
-        169, 181, 195, 207, 222, 235, 251, 256, 160, 152, 145, 143, 139, 148,
-        158, 168, 181, 193, 208, 221, 237, 251, 268, 274, 166, 157, 150, 148,
-        144, 153, 162, 173, 185, 198, 213, 226, 242, 256, 274, 280,
+        32, 31, 31, 31, 32, 34, 36, 39, 44, 48, 54, 59, 65, 71, 80, 83, 31, 32,
+        32, 32, 32, 34, 35, 38, 42, 46, 51, 56, 62, 68, 76, 78, 31, 32, 32, 32,
+        32, 33, 34, 37, 41, 44, 49, 54, 59, 65, 72, 75, 31, 32, 32, 33, 34, 35,
+        36, 39, 42, 45, 50, 54, 59, 64, 71, 74, 32, 32, 32, 34, 35, 37, 38, 40,
+        42, 46, 49, 53, 58, 63, 69, 72, 34, 34, 33, 35, 37, 39, 42, 45, 47, 51,
+        54, 58, 63, 68, 74, 76, 36, 35, 34, 36, 38, 42, 48, 50, 54, 57, 60, 64,
+        68, 73, 79, 81, 39, 38, 37, 39, 40, 45, 50, 54, 58, 61, 65, 69, 73, 78,
+        84, 86, 44, 42, 41, 42, 42, 47, 54, 58, 63, 67, 71, 75, 79, 84, 90, 92,
+        48, 46, 44, 45, 46, 51, 57, 61, 67, 71, 76, 80, 85, 90, 96, 99, 54, 51,
+        49, 50, 49, 54, 60, 65, 71, 76, 82, 87, 92, 97, 104, 106, 59, 56, 54,
+        54, 53, 58, 64, 69, 75, 80, 87, 92, 98, 103, 110, 113, 65, 62, 59, 59,
+        58, 63, 68, 73, 79, 85, 92, 98, 105, 111, 118, 121, 71, 68, 65, 64, 63,
+        68, 73, 78, 84, 90, 97, 103, 111, 117, 125, 128, 80, 76, 72, 71, 69, 74,
+        79, 84, 90, 96, 104, 110, 118, 125, 134, 137, 83, 78, 75, 74, 72, 76,
+        81, 86, 92, 99, 106, 113, 121, 128, 137, 140,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 63, 64, 64, 68, 68, 72, 72, 79, 79, 88, 88, 97,
-        97, 108, 108, 118, 118, 131, 131, 143, 143, 160, 160, 166, 166, 175, 63,
-        64, 64, 64, 64, 64, 64, 65, 65, 68, 68, 70, 70, 77, 77, 85, 85, 93, 93,
-        103, 103, 113, 113, 125, 125, 136, 136, 152, 152, 157, 157, 166, 63, 64,
-        64, 64, 64, 64, 64, 65, 65, 68, 68, 70, 70, 77, 77, 85, 85, 93, 93, 103,
-        103, 113, 113, 125, 125, 136, 136, 152, 152, 157, 157, 166, 63, 64, 64,
-        65, 65, 65, 65, 65, 65, 67, 67, 69, 69, 75, 75, 82, 82, 89, 89, 99, 99,
-        108, 108, 119, 119, 130, 130, 145, 145, 150, 150, 158, 63, 64, 64, 65,
-        65, 65, 65, 65, 65, 67, 67, 69, 69, 75, 75, 82, 82, 89, 89, 99, 99, 108,
-        108, 119, 119, 130, 130, 145, 145, 150, 150, 158, 63, 64, 64, 65, 65,
-        67, 67, 68, 68, 71, 71, 73, 73, 78, 78, 84, 84, 91, 91, 100, 100, 108,
-        108, 118, 118, 129, 129, 143, 143, 148, 148, 155, 63, 64, 64, 65, 65,
-        67, 67, 68, 68, 71, 71, 73, 73, 78, 78, 84, 84, 91, 91, 100, 100, 108,
-        108, 118, 118, 129, 129, 143, 143, 148, 148, 155, 64, 65, 65, 65, 65,
-        68, 68, 71, 71, 74, 74, 77, 77, 81, 81, 85, 85, 92, 92, 99, 99, 107,
-        107, 116, 116, 126, 126, 139, 139, 144, 144, 151, 64, 65, 65, 65, 65,
-        68, 68, 71, 71, 74, 74, 77, 77, 81, 81, 85, 85, 92, 92, 99, 99, 107,
-        107, 116, 116, 126, 126, 139, 139, 144, 144, 151, 68, 68, 68, 67, 67,
-        71, 71, 74, 74, 79, 79, 85, 85, 90, 90, 95, 95, 102, 102, 109, 109, 117,
-        117, 126, 126, 136, 136, 148, 148, 153, 153, 160, 68, 68, 68, 67, 67,
-        71, 71, 74, 74, 79, 79, 85, 85, 90, 90, 95, 95, 102, 102, 109, 109, 117,
-        117, 126, 126, 136, 136, 148, 148, 153, 153, 160, 72, 70, 70, 69, 69,
-        73, 73, 77, 77, 85, 85, 97, 97, 101, 101, 108, 108, 114, 114, 120, 120,
-        128, 128, 136, 136, 146, 146, 158, 158, 162, 162, 169, 72, 70, 70, 69,
-        69, 73, 73, 77, 77, 85, 85, 97, 97, 101, 101, 108, 108, 114, 114, 120,
-        120, 128, 128, 136, 136, 146, 146, 158, 158, 162, 162, 169, 79, 77, 77,
-        75, 75, 78, 78, 81, 81, 90, 90, 101, 101, 108, 108, 116, 116, 122, 122,
-        130, 130, 138, 138, 147, 147, 156, 156, 168, 168, 173, 173, 180, 79, 77,
-        77, 75, 75, 78, 78, 81, 81, 90, 90, 101, 101, 108, 108, 116, 116, 122,
-        122, 130, 130, 138, 138, 147, 147, 156, 156, 168, 168, 173, 173, 180,
-        88, 85, 85, 82, 82, 84, 84, 85, 85, 95, 95, 108, 108, 116, 116, 127,
-        127, 134, 134, 143, 143, 151, 151, 159, 159, 169, 169, 181, 181, 185,
-        185, 192, 88, 85, 85, 82, 82, 84, 84, 85, 85, 95, 95, 108, 108, 116,
-        116, 127, 127, 134, 134, 143, 143, 151, 151, 159, 159, 169, 169, 181,
-        181, 185, 185, 192, 97, 93, 93, 89, 89, 91, 91, 92, 92, 102, 102, 114,
-        114, 122, 122, 134, 134, 142, 142, 153, 153, 161, 161, 171, 171, 181,
-        181, 193, 193, 198, 198, 204, 97, 93, 93, 89, 89, 91, 91, 92, 92, 102,
-        102, 114, 114, 122, 122, 134, 134, 142, 142, 153, 153, 161, 161, 171,
-        171, 181, 181, 193, 193, 198, 198, 204, 108, 103, 103, 99, 99, 100, 100,
-        99, 99, 109, 109, 120, 120, 130, 130, 143, 143, 153, 153, 165, 165, 174,
-        174, 185, 185, 195, 195, 208, 208, 213, 213, 219, 108, 103, 103, 99, 99,
-        100, 100, 99, 99, 109, 109, 120, 120, 130, 130, 143, 143, 153, 153, 165,
-        165, 174, 174, 185, 185, 195, 195, 208, 208, 213, 213, 219, 118, 113,
-        113, 108, 108, 108, 108, 107, 107, 117, 117, 128, 128, 138, 138, 151,
-        151, 161, 161, 174, 174, 184, 184, 196, 196, 207, 207, 221, 221, 226,
-        226, 233, 118, 113, 113, 108, 108, 108, 108, 107, 107, 117, 117, 128,
-        128, 138, 138, 151, 151, 161, 161, 174, 174, 184, 184, 196, 196, 207,
-        207, 221, 221, 226, 226, 233, 131, 125, 125, 119, 119, 118, 118, 116,
-        116, 126, 126, 136, 136, 147, 147, 159, 159, 171, 171, 185, 185, 196,
-        196, 210, 210, 222, 222, 237, 237, 242, 242, 249, 131, 125, 125, 119,
-        119, 118, 118, 116, 116, 126, 126, 136, 136, 147, 147, 159, 159, 171,
-        171, 185, 185, 196, 196, 210, 210, 222, 222, 237, 237, 242, 242, 249,
-        143, 136, 136, 130, 130, 129, 129, 126, 126, 136, 136, 146, 146, 156,
-        156, 169, 169, 181, 181, 195, 195, 207, 207, 222, 222, 235, 235, 251,
-        251, 256, 256, 264, 143, 136, 136, 130, 130, 129, 129, 126, 126, 136,
-        136, 146, 146, 156, 156, 169, 169, 181, 181, 195, 195, 207, 207, 222,
-        222, 235, 235, 251, 251, 256, 256, 264, 160, 152, 152, 145, 145, 143,
-        143, 139, 139, 148, 148, 158, 158, 168, 168, 181, 181, 193, 193, 208,
-        208, 221, 221, 237, 237, 251, 251, 268, 268, 274, 274, 283, 160, 152,
-        152, 145, 145, 143, 143, 139, 139, 148, 148, 158, 158, 168, 168, 181,
-        181, 193, 193, 208, 208, 221, 221, 237, 237, 251, 251, 268, 268, 274,
-        274, 283, 166, 157, 157, 150, 150, 148, 148, 144, 144, 153, 153, 162,
-        162, 173, 173, 185, 185, 198, 198, 213, 213, 226, 226, 242, 242, 256,
-        256, 274, 274, 280, 280, 289, 166, 157, 157, 150, 150, 148, 148, 144,
-        144, 153, 153, 162, 162, 173, 173, 185, 185, 198, 198, 213, 213, 226,
-        226, 242, 242, 256, 256, 274, 274, 280, 280, 289, 175, 166, 166, 158,
-        158, 155, 155, 151, 151, 160, 160, 169, 169, 180, 180, 192, 192, 204,
-        204, 219, 219, 233, 233, 249, 249, 264, 264, 283, 283, 289, 289, 299,
+        32, 31, 31, 31, 31, 31, 31, 32, 32, 34, 34, 36, 36, 39, 39, 44, 44, 48,
+        48, 54, 54, 59, 59, 65, 65, 71, 71, 80, 80, 83, 83, 87, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 34, 34, 35, 35, 38, 38, 42, 42, 46, 46, 51, 51, 56,
+        56, 62, 62, 68, 68, 76, 76, 78, 78, 83, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 34, 34, 35, 35, 38, 38, 42, 42, 46, 46, 51, 51, 56, 56, 62, 62, 68,
+        68, 76, 76, 78, 78, 83, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34,
+        34, 37, 37, 41, 41, 44, 44, 49, 49, 54, 54, 59, 59, 65, 65, 72, 72, 75,
+        75, 79, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 37, 37, 41,
+        41, 44, 44, 49, 49, 54, 54, 59, 59, 65, 65, 72, 72, 75, 75, 79, 31, 32,
+        32, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 39, 39, 42, 42, 45, 45, 50,
+        50, 54, 54, 59, 59, 64, 64, 71, 71, 74, 74, 77, 31, 32, 32, 32, 32, 33,
+        33, 34, 34, 35, 35, 36, 36, 39, 39, 42, 42, 45, 45, 50, 50, 54, 54, 59,
+        59, 64, 64, 71, 71, 74, 74, 77, 32, 32, 32, 32, 32, 34, 34, 35, 35, 37,
+        37, 38, 38, 40, 40, 42, 42, 46, 46, 49, 49, 53, 53, 58, 58, 63, 63, 69,
+        69, 72, 72, 75, 32, 32, 32, 32, 32, 34, 34, 35, 35, 37, 37, 38, 38, 40,
+        40, 42, 42, 46, 46, 49, 49, 53, 53, 58, 58, 63, 63, 69, 69, 72, 72, 75,
+        34, 34, 34, 33, 33, 35, 35, 37, 37, 39, 39, 42, 42, 45, 45, 47, 47, 51,
+        51, 54, 54, 58, 58, 63, 63, 68, 68, 74, 74, 76, 76, 80, 34, 34, 34, 33,
+        33, 35, 35, 37, 37, 39, 39, 42, 42, 45, 45, 47, 47, 51, 51, 54, 54, 58,
+        58, 63, 63, 68, 68, 74, 74, 76, 76, 80, 36, 35, 35, 34, 34, 36, 36, 38,
+        38, 42, 42, 48, 48, 50, 50, 54, 54, 57, 57, 60, 60, 64, 64, 68, 68, 73,
+        73, 79, 79, 81, 81, 84, 36, 35, 35, 34, 34, 36, 36, 38, 38, 42, 42, 48,
+        48, 50, 50, 54, 54, 57, 57, 60, 60, 64, 64, 68, 68, 73, 73, 79, 79, 81,
+        81, 84, 39, 38, 38, 37, 37, 39, 39, 40, 40, 45, 45, 50, 50, 54, 54, 58,
+        58, 61, 61, 65, 65, 69, 69, 73, 73, 78, 78, 84, 84, 86, 86, 90, 39, 38,
+        38, 37, 37, 39, 39, 40, 40, 45, 45, 50, 50, 54, 54, 58, 58, 61, 61, 65,
+        65, 69, 69, 73, 73, 78, 78, 84, 84, 86, 86, 90, 44, 42, 42, 41, 41, 42,
+        42, 42, 42, 47, 47, 54, 54, 58, 58, 63, 63, 67, 67, 71, 71, 75, 75, 79,
+        79, 84, 84, 90, 90, 92, 92, 96, 44, 42, 42, 41, 41, 42, 42, 42, 42, 47,
+        47, 54, 54, 58, 58, 63, 63, 67, 67, 71, 71, 75, 75, 79, 79, 84, 84, 90,
+        90, 92, 92, 96, 48, 46, 46, 44, 44, 45, 45, 46, 46, 51, 51, 57, 57, 61,
+        61, 67, 67, 71, 71, 76, 76, 80, 80, 85, 85, 90, 90, 96, 96, 99, 99, 102,
+        48, 46, 46, 44, 44, 45, 45, 46, 46, 51, 51, 57, 57, 61, 61, 67, 67, 71,
+        71, 76, 76, 80, 80, 85, 85, 90, 90, 96, 96, 99, 99, 102, 54, 51, 51, 49,
+        49, 50, 50, 49, 49, 54, 54, 60, 60, 65, 65, 71, 71, 76, 76, 82, 82, 87,
+        87, 92, 92, 97, 97, 104, 104, 106, 106, 109, 54, 51, 51, 49, 49, 50, 50,
+        49, 49, 54, 54, 60, 60, 65, 65, 71, 71, 76, 76, 82, 82, 87, 87, 92, 92,
+        97, 97, 104, 104, 106, 106, 109, 59, 56, 56, 54, 54, 54, 54, 53, 53, 58,
+        58, 64, 64, 69, 69, 75, 75, 80, 80, 87, 87, 92, 92, 98, 98, 103, 103,
+        110, 110, 113, 113, 116, 59, 56, 56, 54, 54, 54, 54, 53, 53, 58, 58, 64,
+        64, 69, 69, 75, 75, 80, 80, 87, 87, 92, 92, 98, 98, 103, 103, 110, 110,
+        113, 113, 116, 65, 62, 62, 59, 59, 59, 59, 58, 58, 63, 63, 68, 68, 73,
+        73, 79, 79, 85, 85, 92, 92, 98, 98, 105, 105, 111, 111, 118, 118, 121,
+        121, 124, 65, 62, 62, 59, 59, 59, 59, 58, 58, 63, 63, 68, 68, 73, 73,
+        79, 79, 85, 85, 92, 92, 98, 98, 105, 105, 111, 111, 118, 118, 121, 121,
+        124, 71, 68, 68, 65, 65, 64, 64, 63, 63, 68, 68, 73, 73, 78, 78, 84, 84,
+        90, 90, 97, 97, 103, 103, 111, 111, 117, 117, 125, 125, 128, 128, 132,
+        71, 68, 68, 65, 65, 64, 64, 63, 63, 68, 68, 73, 73, 78, 78, 84, 84, 90,
+        90, 97, 97, 103, 103, 111, 111, 117, 117, 125, 125, 128, 128, 132, 80,
+        76, 76, 72, 72, 71, 71, 69, 69, 74, 74, 79, 79, 84, 84, 90, 90, 96, 96,
+        104, 104, 110, 110, 118, 118, 125, 125, 134, 134, 137, 137, 141, 80, 76,
+        76, 72, 72, 71, 71, 69, 69, 74, 74, 79, 79, 84, 84, 90, 90, 96, 96, 104,
+        104, 110, 110, 118, 118, 125, 125, 134, 134, 137, 137, 141, 83, 78, 78,
+        75, 75, 74, 74, 72, 72, 76, 76, 81, 81, 86, 86, 92, 92, 99, 99, 106,
+        106, 113, 113, 121, 121, 128, 128, 137, 137, 140, 140, 144, 83, 78, 78,
+        75, 75, 74, 74, 72, 72, 76, 76, 81, 81, 86, 86, 92, 92, 99, 99, 106,
+        106, 113, 113, 121, 121, 128, 128, 137, 137, 140, 140, 144, 87, 83, 83,
+        79, 79, 77, 77, 75, 75, 80, 80, 84, 84, 90, 90, 96, 96, 102, 102, 109,
+        109, 116, 116, 124, 124, 132, 132, 141, 141, 144, 144, 149,
         /* Size 4x8 */
-        64, 71, 103, 151, 65, 73, 100, 142, 68, 85, 109, 147, 75, 101, 130, 168,
-        90, 113, 152, 192, 108, 127, 174, 220, 131, 146, 195, 250, 151, 162,
-        212, 273,
+        32, 35, 51, 75, 32, 36, 50, 71, 34, 42, 54, 73, 37, 50, 65, 84, 45, 56,
+        76, 96, 54, 63, 87, 110, 65, 73, 97, 125, 75, 81, 106, 136,
         /* Size 8x4 */
-        64, 65, 68, 75, 90, 108, 131, 151, 71, 73, 85, 101, 113, 127, 146, 162,
-        103, 100, 109, 130, 152, 174, 195, 212, 151, 142, 147, 168, 192, 220,
-        250, 273,
+        32, 32, 34, 37, 45, 54, 65, 75, 35, 36, 42, 50, 56, 63, 73, 81, 51, 50,
+        54, 65, 76, 87, 97, 106, 75, 71, 73, 84, 96, 110, 125, 136,
         /* Size 8x16 */
-        64, 63, 64, 72, 88, 107, 131, 158, 63, 64, 65, 71, 85, 103, 124, 151,
-        63, 65, 66, 69, 82, 99, 119, 144, 64, 65, 68, 73, 84, 100, 118, 142, 64,
-        66, 71, 77, 85, 99, 116, 138, 68, 68, 74, 85, 96, 109, 126, 147, 72, 69,
-        77, 96, 108, 120, 136, 157, 79, 75, 81, 101, 116, 130, 147, 168, 88, 82,
-        86, 107, 126, 143, 159, 180, 96, 90, 93, 113, 134, 152, 171, 192, 107,
-        99, 100, 120, 142, 164, 185, 207, 117, 108, 108, 127, 150, 174, 196,
-        220, 130, 120, 117, 136, 159, 185, 210, 236, 142, 131, 127, 146, 169,
-        195, 222, 250, 159, 145, 140, 158, 181, 208, 236, 267, 165, 151, 145,
-        162, 185, 212, 242, 273,
+        32, 31, 32, 36, 44, 53, 65, 79, 31, 32, 32, 35, 42, 51, 62, 75, 31, 32,
+        33, 34, 41, 49, 59, 72, 32, 32, 34, 36, 42, 50, 59, 71, 32, 33, 35, 38,
+        42, 49, 58, 69, 34, 34, 37, 42, 48, 54, 63, 73, 36, 34, 38, 48, 54, 60,
+        68, 78, 39, 37, 40, 50, 58, 65, 73, 84, 44, 41, 43, 53, 63, 71, 79, 90,
+        48, 45, 46, 56, 67, 76, 85, 96, 53, 49, 50, 60, 71, 82, 92, 103, 58, 54,
+        54, 63, 75, 87, 98, 110, 65, 60, 58, 68, 79, 92, 105, 118, 71, 65, 63,
+        73, 84, 97, 111, 125, 79, 72, 70, 79, 90, 104, 118, 133, 82, 75, 72, 81,
+        92, 106, 121, 136,
         /* Size 16x8 */
-        64, 63, 63, 64, 64, 68, 72, 79, 88, 96, 107, 117, 130, 142, 159, 165,
-        63, 64, 65, 65, 66, 68, 69, 75, 82, 90, 99, 108, 120, 131, 145, 151, 64,
-        65, 66, 68, 71, 74, 77, 81, 86, 93, 100, 108, 117, 127, 140, 145, 72,
-        71, 69, 73, 77, 85, 96, 101, 107, 113, 120, 127, 136, 146, 158, 162, 88,
-        85, 82, 84, 85, 96, 108, 116, 126, 134, 142, 150, 159, 169, 181, 185,
-        107, 103, 99, 100, 99, 109, 120, 130, 143, 152, 164, 174, 185, 195, 208,
-        212, 131, 124, 119, 118, 116, 126, 136, 147, 159, 171, 185, 196, 210,
-        222, 236, 242, 158, 151, 144, 142, 138, 147, 157, 168, 180, 192, 207,
-        220, 236, 250, 267, 273,
+        32, 31, 31, 32, 32, 34, 36, 39, 44, 48, 53, 58, 65, 71, 79, 82, 31, 32,
+        32, 32, 33, 34, 34, 37, 41, 45, 49, 54, 60, 65, 72, 75, 32, 32, 33, 34,
+        35, 37, 38, 40, 43, 46, 50, 54, 58, 63, 70, 72, 36, 35, 34, 36, 38, 42,
+        48, 50, 53, 56, 60, 63, 68, 73, 79, 81, 44, 42, 41, 42, 42, 48, 54, 58,
+        63, 67, 71, 75, 79, 84, 90, 92, 53, 51, 49, 50, 49, 54, 60, 65, 71, 76,
+        82, 87, 92, 97, 104, 106, 65, 62, 59, 59, 58, 63, 68, 73, 79, 85, 92,
+        98, 105, 111, 118, 121, 79, 75, 72, 71, 69, 73, 78, 84, 90, 96, 103,
+        110, 118, 125, 133, 136,
         /* Size 16x32 */
-        64, 63, 63, 64, 64, 72, 72, 88, 88, 107, 107, 131, 131, 158, 158, 174,
-        63, 64, 64, 65, 65, 71, 71, 85, 85, 103, 103, 124, 124, 151, 151, 165,
-        63, 64, 64, 65, 65, 71, 71, 85, 85, 103, 103, 124, 124, 151, 151, 165,
-        63, 65, 65, 66, 66, 69, 69, 82, 82, 99, 99, 119, 119, 144, 144, 157, 63,
-        65, 65, 66, 66, 69, 69, 82, 82, 99, 99, 119, 119, 144, 144, 157, 64, 65,
-        65, 68, 68, 73, 73, 84, 84, 100, 100, 118, 118, 142, 142, 154, 64, 65,
-        65, 68, 68, 73, 73, 84, 84, 100, 100, 118, 118, 142, 142, 154, 64, 66,
-        66, 71, 71, 77, 77, 85, 85, 99, 99, 116, 116, 138, 138, 150, 64, 66, 66,
-        71, 71, 77, 77, 85, 85, 99, 99, 116, 116, 138, 138, 150, 68, 68, 68, 74,
-        74, 85, 85, 96, 96, 109, 109, 126, 126, 147, 147, 159, 68, 68, 68, 74,
-        74, 85, 85, 96, 96, 109, 109, 126, 126, 147, 147, 159, 72, 69, 69, 77,
-        77, 96, 96, 108, 108, 120, 120, 136, 136, 157, 157, 168, 72, 69, 69, 77,
-        77, 96, 96, 108, 108, 120, 120, 136, 136, 157, 157, 168, 79, 75, 75, 81,
-        81, 101, 101, 116, 116, 130, 130, 147, 147, 168, 168, 179, 79, 75, 75,
-        81, 81, 101, 101, 116, 116, 130, 130, 147, 147, 168, 168, 179, 88, 82,
-        82, 86, 86, 107, 107, 126, 126, 143, 143, 159, 159, 180, 180, 191, 88,
-        82, 82, 86, 86, 107, 107, 126, 126, 143, 143, 159, 159, 180, 180, 191,
-        96, 90, 90, 93, 93, 113, 113, 134, 134, 152, 152, 171, 171, 192, 192,
-        204, 96, 90, 90, 93, 93, 113, 113, 134, 134, 152, 152, 171, 171, 192,
-        192, 204, 107, 99, 99, 100, 100, 120, 120, 142, 142, 164, 164, 185, 185,
-        207, 207, 219, 107, 99, 99, 100, 100, 120, 120, 142, 142, 164, 164, 185,
-        185, 207, 207, 219, 117, 108, 108, 108, 108, 127, 127, 150, 150, 174,
-        174, 196, 196, 220, 220, 232, 117, 108, 108, 108, 108, 127, 127, 150,
-        150, 174, 174, 196, 196, 220, 220, 232, 130, 120, 120, 117, 117, 136,
-        136, 159, 159, 185, 185, 210, 210, 236, 236, 249, 130, 120, 120, 117,
-        117, 136, 136, 159, 159, 185, 185, 210, 210, 236, 236, 249, 142, 131,
-        131, 127, 127, 146, 146, 169, 169, 195, 195, 222, 222, 250, 250, 264,
-        142, 131, 131, 127, 127, 146, 146, 169, 169, 195, 195, 222, 222, 250,
-        250, 264, 159, 145, 145, 140, 140, 158, 158, 181, 181, 208, 208, 236,
-        236, 267, 267, 282, 159, 145, 145, 140, 140, 158, 158, 181, 181, 208,
-        208, 236, 236, 267, 267, 282, 165, 151, 151, 145, 145, 162, 162, 185,
-        185, 212, 212, 242, 242, 273, 273, 289, 165, 151, 151, 145, 145, 162,
-        162, 185, 185, 212, 212, 242, 242, 273, 273, 289, 174, 159, 159, 152,
-        152, 169, 169, 192, 192, 219, 219, 249, 249, 282, 282, 298,
+        32, 31, 31, 32, 32, 36, 36, 44, 44, 53, 53, 65, 65, 79, 79, 87, 31, 32,
+        32, 32, 32, 35, 35, 42, 42, 51, 51, 62, 62, 75, 75, 82, 31, 32, 32, 32,
+        32, 35, 35, 42, 42, 51, 51, 62, 62, 75, 75, 82, 31, 32, 32, 33, 33, 34,
+        34, 41, 41, 49, 49, 59, 59, 72, 72, 78, 31, 32, 32, 33, 33, 34, 34, 41,
+        41, 49, 49, 59, 59, 72, 72, 78, 32, 32, 32, 34, 34, 36, 36, 42, 42, 50,
+        50, 59, 59, 71, 71, 77, 32, 32, 32, 34, 34, 36, 36, 42, 42, 50, 50, 59,
+        59, 71, 71, 77, 32, 33, 33, 35, 35, 38, 38, 42, 42, 49, 49, 58, 58, 69,
+        69, 75, 32, 33, 33, 35, 35, 38, 38, 42, 42, 49, 49, 58, 58, 69, 69, 75,
+        34, 34, 34, 37, 37, 42, 42, 48, 48, 54, 54, 63, 63, 73, 73, 79, 34, 34,
+        34, 37, 37, 42, 42, 48, 48, 54, 54, 63, 63, 73, 73, 79, 36, 34, 34, 38,
+        38, 48, 48, 54, 54, 60, 60, 68, 68, 78, 78, 84, 36, 34, 34, 38, 38, 48,
+        48, 54, 54, 60, 60, 68, 68, 78, 78, 84, 39, 37, 37, 40, 40, 50, 50, 58,
+        58, 65, 65, 73, 73, 84, 84, 89, 39, 37, 37, 40, 40, 50, 50, 58, 58, 65,
+        65, 73, 73, 84, 84, 89, 44, 41, 41, 43, 43, 53, 53, 63, 63, 71, 71, 79,
+        79, 90, 90, 95, 44, 41, 41, 43, 43, 53, 53, 63, 63, 71, 71, 79, 79, 90,
+        90, 95, 48, 45, 45, 46, 46, 56, 56, 67, 67, 76, 76, 85, 85, 96, 96, 102,
+        48, 45, 45, 46, 46, 56, 56, 67, 67, 76, 76, 85, 85, 96, 96, 102, 53, 49,
+        49, 50, 50, 60, 60, 71, 71, 82, 82, 92, 92, 103, 103, 109, 53, 49, 49,
+        50, 50, 60, 60, 71, 71, 82, 82, 92, 92, 103, 103, 109, 58, 54, 54, 54,
+        54, 63, 63, 75, 75, 87, 87, 98, 98, 110, 110, 116, 58, 54, 54, 54, 54,
+        63, 63, 75, 75, 87, 87, 98, 98, 110, 110, 116, 65, 60, 60, 58, 58, 68,
+        68, 79, 79, 92, 92, 105, 105, 118, 118, 124, 65, 60, 60, 58, 58, 68, 68,
+        79, 79, 92, 92, 105, 105, 118, 118, 124, 71, 65, 65, 63, 63, 73, 73, 84,
+        84, 97, 97, 111, 111, 125, 125, 132, 71, 65, 65, 63, 63, 73, 73, 84, 84,
+        97, 97, 111, 111, 125, 125, 132, 79, 72, 72, 70, 70, 79, 79, 90, 90,
+        104, 104, 118, 118, 133, 133, 141, 79, 72, 72, 70, 70, 79, 79, 90, 90,
+        104, 104, 118, 118, 133, 133, 141, 82, 75, 75, 72, 72, 81, 81, 92, 92,
+        106, 106, 121, 121, 136, 136, 144, 82, 75, 75, 72, 72, 81, 81, 92, 92,
+        106, 106, 121, 121, 136, 136, 144, 87, 79, 79, 76, 76, 84, 84, 96, 96,
+        109, 109, 124, 124, 141, 141, 149,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 64, 64, 64, 64, 68, 68, 72, 72, 79, 79, 88, 88, 96,
-        96, 107, 107, 117, 117, 130, 130, 142, 142, 159, 159, 165, 165, 174, 63,
-        64, 64, 65, 65, 65, 65, 66, 66, 68, 68, 69, 69, 75, 75, 82, 82, 90, 90,
-        99, 99, 108, 108, 120, 120, 131, 131, 145, 145, 151, 151, 159, 63, 64,
-        64, 65, 65, 65, 65, 66, 66, 68, 68, 69, 69, 75, 75, 82, 82, 90, 90, 99,
-        99, 108, 108, 120, 120, 131, 131, 145, 145, 151, 151, 159, 64, 65, 65,
-        66, 66, 68, 68, 71, 71, 74, 74, 77, 77, 81, 81, 86, 86, 93, 93, 100,
-        100, 108, 108, 117, 117, 127, 127, 140, 140, 145, 145, 152, 64, 65, 65,
-        66, 66, 68, 68, 71, 71, 74, 74, 77, 77, 81, 81, 86, 86, 93, 93, 100,
-        100, 108, 108, 117, 117, 127, 127, 140, 140, 145, 145, 152, 72, 71, 71,
-        69, 69, 73, 73, 77, 77, 85, 85, 96, 96, 101, 101, 107, 107, 113, 113,
-        120, 120, 127, 127, 136, 136, 146, 146, 158, 158, 162, 162, 169, 72, 71,
-        71, 69, 69, 73, 73, 77, 77, 85, 85, 96, 96, 101, 101, 107, 107, 113,
-        113, 120, 120, 127, 127, 136, 136, 146, 146, 158, 158, 162, 162, 169,
-        88, 85, 85, 82, 82, 84, 84, 85, 85, 96, 96, 108, 108, 116, 116, 126,
-        126, 134, 134, 142, 142, 150, 150, 159, 159, 169, 169, 181, 181, 185,
-        185, 192, 88, 85, 85, 82, 82, 84, 84, 85, 85, 96, 96, 108, 108, 116,
-        116, 126, 126, 134, 134, 142, 142, 150, 150, 159, 159, 169, 169, 181,
-        181, 185, 185, 192, 107, 103, 103, 99, 99, 100, 100, 99, 99, 109, 109,
-        120, 120, 130, 130, 143, 143, 152, 152, 164, 164, 174, 174, 185, 185,
-        195, 195, 208, 208, 212, 212, 219, 107, 103, 103, 99, 99, 100, 100, 99,
-        99, 109, 109, 120, 120, 130, 130, 143, 143, 152, 152, 164, 164, 174,
-        174, 185, 185, 195, 195, 208, 208, 212, 212, 219, 131, 124, 124, 119,
-        119, 118, 118, 116, 116, 126, 126, 136, 136, 147, 147, 159, 159, 171,
-        171, 185, 185, 196, 196, 210, 210, 222, 222, 236, 236, 242, 242, 249,
-        131, 124, 124, 119, 119, 118, 118, 116, 116, 126, 126, 136, 136, 147,
-        147, 159, 159, 171, 171, 185, 185, 196, 196, 210, 210, 222, 222, 236,
-        236, 242, 242, 249, 158, 151, 151, 144, 144, 142, 142, 138, 138, 147,
-        147, 157, 157, 168, 168, 180, 180, 192, 192, 207, 207, 220, 220, 236,
-        236, 250, 250, 267, 267, 273, 273, 282, 158, 151, 151, 144, 144, 142,
-        142, 138, 138, 147, 147, 157, 157, 168, 168, 180, 180, 192, 192, 207,
-        207, 220, 220, 236, 236, 250, 250, 267, 267, 273, 273, 282, 174, 165,
-        165, 157, 157, 154, 154, 150, 150, 159, 159, 168, 168, 179, 179, 191,
-        191, 204, 204, 219, 219, 232, 232, 249, 249, 264, 264, 282, 282, 289,
-        289, 298,
+        32, 31, 31, 31, 31, 32, 32, 32, 32, 34, 34, 36, 36, 39, 39, 44, 44, 48,
+        48, 53, 53, 58, 58, 65, 65, 71, 71, 79, 79, 82, 82, 87, 31, 32, 32, 32,
+        32, 32, 32, 33, 33, 34, 34, 34, 34, 37, 37, 41, 41, 45, 45, 49, 49, 54,
+        54, 60, 60, 65, 65, 72, 72, 75, 75, 79, 31, 32, 32, 32, 32, 32, 32, 33,
+        33, 34, 34, 34, 34, 37, 37, 41, 41, 45, 45, 49, 49, 54, 54, 60, 60, 65,
+        65, 72, 72, 75, 75, 79, 32, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 38,
+        38, 40, 40, 43, 43, 46, 46, 50, 50, 54, 54, 58, 58, 63, 63, 70, 70, 72,
+        72, 76, 32, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 38, 38, 40, 40, 43,
+        43, 46, 46, 50, 50, 54, 54, 58, 58, 63, 63, 70, 70, 72, 72, 76, 36, 35,
+        35, 34, 34, 36, 36, 38, 38, 42, 42, 48, 48, 50, 50, 53, 53, 56, 56, 60,
+        60, 63, 63, 68, 68, 73, 73, 79, 79, 81, 81, 84, 36, 35, 35, 34, 34, 36,
+        36, 38, 38, 42, 42, 48, 48, 50, 50, 53, 53, 56, 56, 60, 60, 63, 63, 68,
+        68, 73, 73, 79, 79, 81, 81, 84, 44, 42, 42, 41, 41, 42, 42, 42, 42, 48,
+        48, 54, 54, 58, 58, 63, 63, 67, 67, 71, 71, 75, 75, 79, 79, 84, 84, 90,
+        90, 92, 92, 96, 44, 42, 42, 41, 41, 42, 42, 42, 42, 48, 48, 54, 54, 58,
+        58, 63, 63, 67, 67, 71, 71, 75, 75, 79, 79, 84, 84, 90, 90, 92, 92, 96,
+        53, 51, 51, 49, 49, 50, 50, 49, 49, 54, 54, 60, 60, 65, 65, 71, 71, 76,
+        76, 82, 82, 87, 87, 92, 92, 97, 97, 104, 104, 106, 106, 109, 53, 51, 51,
+        49, 49, 50, 50, 49, 49, 54, 54, 60, 60, 65, 65, 71, 71, 76, 76, 82, 82,
+        87, 87, 92, 92, 97, 97, 104, 104, 106, 106, 109, 65, 62, 62, 59, 59, 59,
+        59, 58, 58, 63, 63, 68, 68, 73, 73, 79, 79, 85, 85, 92, 92, 98, 98, 105,
+        105, 111, 111, 118, 118, 121, 121, 124, 65, 62, 62, 59, 59, 59, 59, 58,
+        58, 63, 63, 68, 68, 73, 73, 79, 79, 85, 85, 92, 92, 98, 98, 105, 105,
+        111, 111, 118, 118, 121, 121, 124, 79, 75, 75, 72, 72, 71, 71, 69, 69,
+        73, 73, 78, 78, 84, 84, 90, 90, 96, 96, 103, 103, 110, 110, 118, 118,
+        125, 125, 133, 133, 136, 136, 141, 79, 75, 75, 72, 72, 71, 71, 69, 69,
+        73, 73, 78, 78, 84, 84, 90, 90, 96, 96, 103, 103, 110, 110, 118, 118,
+        125, 125, 133, 133, 136, 136, 141, 87, 82, 82, 78, 78, 77, 77, 75, 75,
+        79, 79, 84, 84, 89, 89, 95, 95, 102, 102, 109, 109, 116, 116, 124, 124,
+        132, 132, 141, 141, 144, 144, 149,
         /* Size 4x16 */
-        63, 72, 107, 158, 64, 71, 103, 151, 65, 69, 99, 144, 65, 73, 100, 142,
-        66, 77, 99, 138, 68, 85, 109, 147, 69, 96, 120, 157, 75, 101, 130, 168,
-        82, 107, 143, 180, 90, 113, 152, 192, 99, 120, 164, 207, 108, 127, 174,
-        220, 120, 136, 185, 236, 131, 146, 195, 250, 145, 158, 208, 267, 151,
-        162, 212, 273,
+        31, 36, 53, 79, 32, 35, 51, 75, 32, 34, 49, 72, 32, 36, 50, 71, 33, 38,
+        49, 69, 34, 42, 54, 73, 34, 48, 60, 78, 37, 50, 65, 84, 41, 53, 71, 90,
+        45, 56, 76, 96, 49, 60, 82, 103, 54, 63, 87, 110, 60, 68, 92, 118, 65,
+        73, 97, 125, 72, 79, 104, 133, 75, 81, 106, 136,
         /* Size 16x4 */
-        63, 64, 65, 65, 66, 68, 69, 75, 82, 90, 99, 108, 120, 131, 145, 151, 72,
-        71, 69, 73, 77, 85, 96, 101, 107, 113, 120, 127, 136, 146, 158, 162,
-        107, 103, 99, 100, 99, 109, 120, 130, 143, 152, 164, 174, 185, 195, 208,
-        212, 158, 151, 144, 142, 138, 147, 157, 168, 180, 192, 207, 220, 236,
-        250, 267, 273,
+        31, 32, 32, 32, 33, 34, 34, 37, 41, 45, 49, 54, 60, 65, 72, 75, 36, 35,
+        34, 36, 38, 42, 48, 50, 53, 56, 60, 63, 68, 73, 79, 81, 53, 51, 49, 50,
+        49, 54, 60, 65, 71, 76, 82, 87, 92, 97, 104, 106, 79, 75, 72, 71, 69,
+        73, 78, 84, 90, 96, 103, 110, 118, 125, 133, 136,
         /* Size 8x32 */
-        64, 63, 64, 72, 88, 107, 131, 158, 63, 64, 65, 71, 85, 103, 124, 151,
-        63, 64, 65, 71, 85, 103, 124, 151, 63, 65, 66, 69, 82, 99, 119, 144, 63,
-        65, 66, 69, 82, 99, 119, 144, 64, 65, 68, 73, 84, 100, 118, 142, 64, 65,
-        68, 73, 84, 100, 118, 142, 64, 66, 71, 77, 85, 99, 116, 138, 64, 66, 71,
-        77, 85, 99, 116, 138, 68, 68, 74, 85, 96, 109, 126, 147, 68, 68, 74, 85,
-        96, 109, 126, 147, 72, 69, 77, 96, 108, 120, 136, 157, 72, 69, 77, 96,
-        108, 120, 136, 157, 79, 75, 81, 101, 116, 130, 147, 168, 79, 75, 81,
-        101, 116, 130, 147, 168, 88, 82, 86, 107, 126, 143, 159, 180, 88, 82,
-        86, 107, 126, 143, 159, 180, 96, 90, 93, 113, 134, 152, 171, 192, 96,
-        90, 93, 113, 134, 152, 171, 192, 107, 99, 100, 120, 142, 164, 185, 207,
-        107, 99, 100, 120, 142, 164, 185, 207, 117, 108, 108, 127, 150, 174,
-        196, 220, 117, 108, 108, 127, 150, 174, 196, 220, 130, 120, 117, 136,
-        159, 185, 210, 236, 130, 120, 117, 136, 159, 185, 210, 236, 142, 131,
-        127, 146, 169, 195, 222, 250, 142, 131, 127, 146, 169, 195, 222, 250,
-        159, 145, 140, 158, 181, 208, 236, 267, 159, 145, 140, 158, 181, 208,
-        236, 267, 165, 151, 145, 162, 185, 212, 242, 273, 165, 151, 145, 162,
-        185, 212, 242, 273, 174, 159, 152, 169, 192, 219, 249, 282,
+        32, 31, 32, 36, 44, 53, 65, 79, 31, 32, 32, 35, 42, 51, 62, 75, 31, 32,
+        32, 35, 42, 51, 62, 75, 31, 32, 33, 34, 41, 49, 59, 72, 31, 32, 33, 34,
+        41, 49, 59, 72, 32, 32, 34, 36, 42, 50, 59, 71, 32, 32, 34, 36, 42, 50,
+        59, 71, 32, 33, 35, 38, 42, 49, 58, 69, 32, 33, 35, 38, 42, 49, 58, 69,
+        34, 34, 37, 42, 48, 54, 63, 73, 34, 34, 37, 42, 48, 54, 63, 73, 36, 34,
+        38, 48, 54, 60, 68, 78, 36, 34, 38, 48, 54, 60, 68, 78, 39, 37, 40, 50,
+        58, 65, 73, 84, 39, 37, 40, 50, 58, 65, 73, 84, 44, 41, 43, 53, 63, 71,
+        79, 90, 44, 41, 43, 53, 63, 71, 79, 90, 48, 45, 46, 56, 67, 76, 85, 96,
+        48, 45, 46, 56, 67, 76, 85, 96, 53, 49, 50, 60, 71, 82, 92, 103, 53, 49,
+        50, 60, 71, 82, 92, 103, 58, 54, 54, 63, 75, 87, 98, 110, 58, 54, 54,
+        63, 75, 87, 98, 110, 65, 60, 58, 68, 79, 92, 105, 118, 65, 60, 58, 68,
+        79, 92, 105, 118, 71, 65, 63, 73, 84, 97, 111, 125, 71, 65, 63, 73, 84,
+        97, 111, 125, 79, 72, 70, 79, 90, 104, 118, 133, 79, 72, 70, 79, 90,
+        104, 118, 133, 82, 75, 72, 81, 92, 106, 121, 136, 82, 75, 72, 81, 92,
+        106, 121, 136, 87, 79, 76, 84, 96, 109, 124, 141,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 64, 64, 64, 64, 68, 68, 72, 72, 79, 79, 88, 88, 96,
-        96, 107, 107, 117, 117, 130, 130, 142, 142, 159, 159, 165, 165, 174, 63,
-        64, 64, 65, 65, 65, 65, 66, 66, 68, 68, 69, 69, 75, 75, 82, 82, 90, 90,
-        99, 99, 108, 108, 120, 120, 131, 131, 145, 145, 151, 151, 159, 64, 65,
-        65, 66, 66, 68, 68, 71, 71, 74, 74, 77, 77, 81, 81, 86, 86, 93, 93, 100,
-        100, 108, 108, 117, 117, 127, 127, 140, 140, 145, 145, 152, 72, 71, 71,
-        69, 69, 73, 73, 77, 77, 85, 85, 96, 96, 101, 101, 107, 107, 113, 113,
-        120, 120, 127, 127, 136, 136, 146, 146, 158, 158, 162, 162, 169, 88, 85,
-        85, 82, 82, 84, 84, 85, 85, 96, 96, 108, 108, 116, 116, 126, 126, 134,
-        134, 142, 142, 150, 150, 159, 159, 169, 169, 181, 181, 185, 185, 192,
-        107, 103, 103, 99, 99, 100, 100, 99, 99, 109, 109, 120, 120, 130, 130,
-        143, 143, 152, 152, 164, 164, 174, 174, 185, 185, 195, 195, 208, 208,
-        212, 212, 219, 131, 124, 124, 119, 119, 118, 118, 116, 116, 126, 126,
-        136, 136, 147, 147, 159, 159, 171, 171, 185, 185, 196, 196, 210, 210,
-        222, 222, 236, 236, 242, 242, 249, 158, 151, 151, 144, 144, 142, 142,
-        138, 138, 147, 147, 157, 157, 168, 168, 180, 180, 192, 192, 207, 207,
-        220, 220, 236, 236, 250, 250, 267, 267, 273, 273, 282 },
+        32, 31, 31, 31, 31, 32, 32, 32, 32, 34, 34, 36, 36, 39, 39, 44, 44, 48,
+        48, 53, 53, 58, 58, 65, 65, 71, 71, 79, 79, 82, 82, 87, 31, 32, 32, 32,
+        32, 32, 32, 33, 33, 34, 34, 34, 34, 37, 37, 41, 41, 45, 45, 49, 49, 54,
+        54, 60, 60, 65, 65, 72, 72, 75, 75, 79, 32, 32, 32, 33, 33, 34, 34, 35,
+        35, 37, 37, 38, 38, 40, 40, 43, 43, 46, 46, 50, 50, 54, 54, 58, 58, 63,
+        63, 70, 70, 72, 72, 76, 36, 35, 35, 34, 34, 36, 36, 38, 38, 42, 42, 48,
+        48, 50, 50, 53, 53, 56, 56, 60, 60, 63, 63, 68, 68, 73, 73, 79, 79, 81,
+        81, 84, 44, 42, 42, 41, 41, 42, 42, 42, 42, 48, 48, 54, 54, 58, 58, 63,
+        63, 67, 67, 71, 71, 75, 75, 79, 79, 84, 84, 90, 90, 92, 92, 96, 53, 51,
+        51, 49, 49, 50, 50, 49, 49, 54, 54, 60, 60, 65, 65, 71, 71, 76, 76, 82,
+        82, 87, 87, 92, 92, 97, 97, 104, 104, 106, 106, 109, 65, 62, 62, 59, 59,
+        59, 59, 58, 58, 63, 63, 68, 68, 73, 73, 79, 79, 85, 85, 92, 92, 98, 98,
+        105, 105, 111, 111, 118, 118, 121, 121, 124, 79, 75, 75, 72, 72, 71, 71,
+        69, 69, 73, 73, 78, 78, 84, 84, 90, 90, 96, 96, 103, 103, 110, 110, 118,
+        118, 125, 125, 133, 133, 136, 136, 141 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        95, 100, 100, 153,
+        47, 50, 50, 76,
 #endif
         /* Size 4x4 */
-        64, 93, 95, 115, 93, 106, 109, 121, 95, 109, 133, 150, 115, 121, 150,
-        178,
+        32, 46, 47, 57, 46, 53, 54, 60, 47, 54, 66, 75, 57, 60, 75, 89,
         /* Size 8x8 */
-        63, 69, 85, 94, 97, 104, 114, 123, 69, 78, 90, 93, 93, 99, 107, 115, 85,
-        90, 97, 99, 100, 104, 111, 117, 94, 93, 99, 109, 113, 117, 123, 129, 97,
-        93, 100, 113, 123, 130, 137, 143, 104, 99, 104, 117, 130, 142, 151, 158,
-        114, 107, 111, 123, 137, 151, 164, 172, 123, 115, 117, 129, 143, 158,
-        172, 183,
+        31, 34, 42, 47, 48, 52, 57, 61, 34, 39, 45, 46, 46, 49, 53, 57, 42, 45,
+        48, 49, 50, 52, 55, 58, 47, 46, 49, 54, 56, 58, 61, 64, 48, 46, 50, 56,
+        61, 65, 68, 71, 52, 49, 52, 58, 65, 71, 75, 79, 57, 53, 55, 61, 68, 75,
+        82, 86, 61, 57, 58, 64, 71, 79, 86, 91,
         /* Size 16x16 */
-        64, 62, 61, 67, 73, 83, 98, 97, 98, 101, 104, 109, 114, 120, 127, 130,
-        62, 63, 62, 69, 77, 85, 95, 94, 94, 97, 100, 104, 109, 114, 121, 123,
-        61, 62, 64, 71, 80, 85, 93, 91, 90, 93, 95, 99, 104, 109, 115, 117, 67,
-        69, 71, 78, 87, 90, 95, 93, 91, 93, 95, 99, 102, 107, 113, 115, 73, 77,
-        80, 87, 95, 95, 96, 93, 91, 92, 94, 97, 100, 104, 109, 111, 83, 85, 85,
-        90, 95, 97, 101, 99, 98, 100, 101, 104, 107, 111, 115, 117, 98, 95, 93,
-        95, 96, 101, 106, 106, 107, 108, 109, 111, 113, 117, 121, 123, 97, 94,
-        91, 93, 93, 99, 106, 109, 111, 113, 115, 117, 120, 123, 127, 129, 98,
-        94, 90, 91, 91, 98, 107, 111, 117, 120, 123, 125, 127, 131, 135, 136,
-        101, 97, 93, 93, 92, 100, 108, 113, 120, 123, 127, 130, 134, 137, 142,
-        143, 104, 100, 95, 95, 94, 101, 109, 115, 123, 127, 133, 137, 141, 145,
-        150, 151, 109, 104, 99, 99, 97, 104, 111, 117, 125, 130, 137, 142, 147,
-        151, 156, 158, 114, 109, 104, 102, 100, 107, 113, 120, 127, 134, 141,
-        147, 153, 158, 164, 166, 120, 114, 109, 107, 104, 111, 117, 123, 131,
-        137, 145, 151, 158, 164, 170, 172, 127, 121, 115, 113, 109, 115, 121,
-        127, 135, 142, 150, 156, 164, 170, 178, 180, 130, 123, 117, 115, 111,
-        117, 123, 129, 136, 143, 151, 158, 166, 172, 180, 183,
+        32, 31, 30, 33, 36, 41, 49, 48, 49, 50, 52, 54, 57, 60, 63, 65, 31, 31,
+        31, 34, 38, 42, 47, 47, 47, 48, 50, 52, 54, 57, 60, 61, 30, 31, 32, 35,
+        40, 42, 46, 45, 45, 46, 47, 49, 52, 54, 57, 58, 33, 34, 35, 39, 43, 45,
+        47, 46, 45, 46, 47, 49, 51, 53, 56, 57, 36, 38, 40, 43, 47, 47, 48, 46,
+        45, 46, 47, 48, 50, 52, 54, 55, 41, 42, 42, 45, 47, 48, 50, 49, 49, 50,
+        50, 52, 53, 55, 57, 58, 49, 47, 46, 47, 48, 50, 53, 53, 53, 54, 54, 55,
+        56, 58, 60, 61, 48, 47, 45, 46, 46, 49, 53, 54, 55, 56, 57, 58, 60, 61,
+        63, 64, 49, 47, 45, 45, 45, 49, 53, 55, 58, 60, 61, 62, 63, 65, 67, 68,
+        50, 48, 46, 46, 46, 50, 54, 56, 60, 61, 63, 65, 67, 68, 71, 71, 52, 50,
+        47, 47, 47, 50, 54, 57, 61, 63, 66, 68, 70, 72, 75, 75, 54, 52, 49, 49,
+        48, 52, 55, 58, 62, 65, 68, 71, 73, 75, 78, 79, 57, 54, 52, 51, 50, 53,
+        56, 60, 63, 67, 70, 73, 76, 79, 82, 83, 60, 57, 54, 53, 52, 55, 58, 61,
+        65, 68, 72, 75, 79, 82, 85, 86, 63, 60, 57, 56, 54, 57, 60, 63, 67, 71,
+        75, 78, 82, 85, 89, 90, 65, 61, 58, 57, 55, 58, 61, 64, 68, 71, 75, 79,
+        83, 86, 90, 91,
         /* Size 32x32 */
-        64, 62, 62, 61, 61, 67, 67, 73, 73, 83, 83, 98, 98, 97, 97, 98, 98, 101,
-        101, 104, 104, 109, 109, 114, 114, 120, 120, 127, 127, 130, 130, 134,
-        62, 63, 63, 62, 62, 69, 69, 77, 77, 85, 85, 95, 95, 94, 94, 94, 94, 97,
-        97, 100, 100, 104, 104, 109, 109, 114, 114, 121, 121, 123, 123, 127, 62,
-        63, 63, 62, 62, 69, 69, 77, 77, 85, 85, 95, 95, 94, 94, 94, 94, 97, 97,
-        100, 100, 104, 104, 109, 109, 114, 114, 121, 121, 123, 123, 127, 61, 62,
-        62, 64, 64, 71, 71, 80, 80, 85, 85, 93, 93, 91, 91, 90, 90, 93, 93, 95,
-        95, 99, 99, 104, 104, 109, 109, 115, 115, 117, 117, 121, 61, 62, 62, 64,
-        64, 71, 71, 80, 80, 85, 85, 93, 93, 91, 91, 90, 90, 93, 93, 95, 95, 99,
-        99, 104, 104, 109, 109, 115, 115, 117, 117, 121, 67, 69, 69, 71, 71, 78,
-        78, 87, 87, 90, 90, 95, 95, 93, 93, 91, 91, 93, 93, 95, 95, 99, 99, 102,
-        102, 107, 107, 113, 113, 115, 115, 118, 67, 69, 69, 71, 71, 78, 78, 87,
-        87, 90, 90, 95, 95, 93, 93, 91, 91, 93, 93, 95, 95, 99, 99, 102, 102,
-        107, 107, 113, 113, 115, 115, 118, 73, 77, 77, 80, 80, 87, 87, 95, 95,
-        95, 95, 96, 96, 93, 93, 91, 91, 92, 92, 94, 94, 97, 97, 100, 100, 104,
-        104, 109, 109, 111, 111, 114, 73, 77, 77, 80, 80, 87, 87, 95, 95, 95,
-        95, 96, 96, 93, 93, 91, 91, 92, 92, 94, 94, 97, 97, 100, 100, 104, 104,
-        109, 109, 111, 111, 114, 83, 85, 85, 85, 85, 90, 90, 95, 95, 97, 97,
-        101, 101, 99, 99, 98, 98, 100, 100, 101, 101, 104, 104, 107, 107, 111,
-        111, 115, 115, 117, 117, 120, 83, 85, 85, 85, 85, 90, 90, 95, 95, 97,
-        97, 101, 101, 99, 99, 98, 98, 100, 100, 101, 101, 104, 104, 107, 107,
-        111, 111, 115, 115, 117, 117, 120, 98, 95, 95, 93, 93, 95, 95, 96, 96,
-        101, 101, 106, 106, 106, 106, 107, 107, 108, 108, 109, 109, 111, 111,
-        113, 113, 117, 117, 121, 121, 123, 123, 125, 98, 95, 95, 93, 93, 95, 95,
-        96, 96, 101, 101, 106, 106, 106, 106, 107, 107, 108, 108, 109, 109, 111,
-        111, 113, 113, 117, 117, 121, 121, 123, 123, 125, 97, 94, 94, 91, 91,
-        93, 93, 93, 93, 99, 99, 106, 106, 109, 109, 111, 111, 113, 113, 115,
-        115, 117, 117, 120, 120, 123, 123, 127, 127, 129, 129, 132, 97, 94, 94,
-        91, 91, 93, 93, 93, 93, 99, 99, 106, 106, 109, 109, 111, 111, 113, 113,
-        115, 115, 117, 117, 120, 120, 123, 123, 127, 127, 129, 129, 132, 98, 94,
-        94, 90, 90, 91, 91, 91, 91, 98, 98, 107, 107, 111, 111, 117, 117, 120,
-        120, 123, 123, 125, 125, 127, 127, 131, 131, 135, 135, 136, 136, 138,
-        98, 94, 94, 90, 90, 91, 91, 91, 91, 98, 98, 107, 107, 111, 111, 117,
-        117, 120, 120, 123, 123, 125, 125, 127, 127, 131, 131, 135, 135, 136,
-        136, 138, 101, 97, 97, 93, 93, 93, 93, 92, 92, 100, 100, 108, 108, 113,
-        113, 120, 120, 123, 123, 127, 127, 130, 130, 134, 134, 137, 137, 142,
-        142, 143, 143, 145, 101, 97, 97, 93, 93, 93, 93, 92, 92, 100, 100, 108,
-        108, 113, 113, 120, 120, 123, 123, 127, 127, 130, 130, 134, 134, 137,
-        137, 142, 142, 143, 143, 145, 104, 100, 100, 95, 95, 95, 95, 94, 94,
-        101, 101, 109, 109, 115, 115, 123, 123, 127, 127, 133, 133, 137, 137,
-        141, 141, 145, 145, 150, 150, 151, 151, 153, 104, 100, 100, 95, 95, 95,
-        95, 94, 94, 101, 101, 109, 109, 115, 115, 123, 123, 127, 127, 133, 133,
-        137, 137, 141, 141, 145, 145, 150, 150, 151, 151, 153, 109, 104, 104,
-        99, 99, 99, 99, 97, 97, 104, 104, 111, 111, 117, 117, 125, 125, 130,
-        130, 137, 137, 142, 142, 147, 147, 151, 151, 156, 156, 158, 158, 161,
-        109, 104, 104, 99, 99, 99, 99, 97, 97, 104, 104, 111, 111, 117, 117,
-        125, 125, 130, 130, 137, 137, 142, 142, 147, 147, 151, 151, 156, 156,
-        158, 158, 161, 114, 109, 109, 104, 104, 102, 102, 100, 100, 107, 107,
-        113, 113, 120, 120, 127, 127, 134, 134, 141, 141, 147, 147, 153, 153,
-        158, 158, 164, 164, 166, 166, 169, 114, 109, 109, 104, 104, 102, 102,
-        100, 100, 107, 107, 113, 113, 120, 120, 127, 127, 134, 134, 141, 141,
-        147, 147, 153, 153, 158, 158, 164, 164, 166, 166, 169, 120, 114, 114,
-        109, 109, 107, 107, 104, 104, 111, 111, 117, 117, 123, 123, 131, 131,
-        137, 137, 145, 145, 151, 151, 158, 158, 164, 164, 170, 170, 172, 172,
-        176, 120, 114, 114, 109, 109, 107, 107, 104, 104, 111, 111, 117, 117,
-        123, 123, 131, 131, 137, 137, 145, 145, 151, 151, 158, 158, 164, 164,
-        170, 170, 172, 172, 176, 127, 121, 121, 115, 115, 113, 113, 109, 109,
-        115, 115, 121, 121, 127, 127, 135, 135, 142, 142, 150, 150, 156, 156,
-        164, 164, 170, 170, 178, 178, 180, 180, 184, 127, 121, 121, 115, 115,
-        113, 113, 109, 109, 115, 115, 121, 121, 127, 127, 135, 135, 142, 142,
-        150, 150, 156, 156, 164, 164, 170, 170, 178, 178, 180, 180, 184, 130,
-        123, 123, 117, 117, 115, 115, 111, 111, 117, 117, 123, 123, 129, 129,
-        136, 136, 143, 143, 151, 151, 158, 158, 166, 166, 172, 172, 180, 180,
-        183, 183, 187, 130, 123, 123, 117, 117, 115, 115, 111, 111, 117, 117,
-        123, 123, 129, 129, 136, 136, 143, 143, 151, 151, 158, 158, 166, 166,
-        172, 172, 180, 180, 183, 183, 187, 134, 127, 127, 121, 121, 118, 118,
-        114, 114, 120, 120, 125, 125, 132, 132, 138, 138, 145, 145, 153, 153,
-        161, 161, 169, 169, 176, 176, 184, 184, 187, 187, 191,
+        32, 31, 31, 30, 30, 33, 33, 36, 36, 41, 41, 49, 49, 48, 48, 49, 49, 50,
+        50, 52, 52, 54, 54, 57, 57, 60, 60, 63, 63, 65, 65, 67, 31, 31, 31, 31,
+        31, 34, 34, 38, 38, 42, 42, 47, 47, 47, 47, 47, 47, 48, 48, 50, 50, 52,
+        52, 54, 54, 57, 57, 60, 60, 61, 61, 63, 31, 31, 31, 31, 31, 34, 34, 38,
+        38, 42, 42, 47, 47, 47, 47, 47, 47, 48, 48, 50, 50, 52, 52, 54, 54, 57,
+        57, 60, 60, 61, 61, 63, 30, 31, 31, 32, 32, 35, 35, 40, 40, 42, 42, 46,
+        46, 45, 45, 45, 45, 46, 46, 47, 47, 49, 49, 52, 52, 54, 54, 57, 57, 58,
+        58, 60, 30, 31, 31, 32, 32, 35, 35, 40, 40, 42, 42, 46, 46, 45, 45, 45,
+        45, 46, 46, 47, 47, 49, 49, 52, 52, 54, 54, 57, 57, 58, 58, 60, 33, 34,
+        34, 35, 35, 39, 39, 43, 43, 45, 45, 47, 47, 46, 46, 45, 45, 46, 46, 47,
+        47, 49, 49, 51, 51, 53, 53, 56, 56, 57, 57, 59, 33, 34, 34, 35, 35, 39,
+        39, 43, 43, 45, 45, 47, 47, 46, 46, 45, 45, 46, 46, 47, 47, 49, 49, 51,
+        51, 53, 53, 56, 56, 57, 57, 59, 36, 38, 38, 40, 40, 43, 43, 47, 47, 47,
+        47, 48, 48, 46, 46, 45, 45, 46, 46, 47, 47, 48, 48, 50, 50, 52, 52, 54,
+        54, 55, 55, 57, 36, 38, 38, 40, 40, 43, 43, 47, 47, 47, 47, 48, 48, 46,
+        46, 45, 45, 46, 46, 47, 47, 48, 48, 50, 50, 52, 52, 54, 54, 55, 55, 57,
+        41, 42, 42, 42, 42, 45, 45, 47, 47, 48, 48, 50, 50, 49, 49, 49, 49, 50,
+        50, 50, 50, 52, 52, 53, 53, 55, 55, 57, 57, 58, 58, 60, 41, 42, 42, 42,
+        42, 45, 45, 47, 47, 48, 48, 50, 50, 49, 49, 49, 49, 50, 50, 50, 50, 52,
+        52, 53, 53, 55, 55, 57, 57, 58, 58, 60, 49, 47, 47, 46, 46, 47, 47, 48,
+        48, 50, 50, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 56, 56, 58,
+        58, 60, 60, 61, 61, 62, 49, 47, 47, 46, 46, 47, 47, 48, 48, 50, 50, 53,
+        53, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 56, 56, 58, 58, 60, 60, 61,
+        61, 62, 48, 47, 47, 45, 45, 46, 46, 46, 46, 49, 49, 53, 53, 54, 54, 55,
+        55, 56, 56, 57, 57, 58, 58, 60, 60, 61, 61, 63, 63, 64, 64, 66, 48, 47,
+        47, 45, 45, 46, 46, 46, 46, 49, 49, 53, 53, 54, 54, 55, 55, 56, 56, 57,
+        57, 58, 58, 60, 60, 61, 61, 63, 63, 64, 64, 66, 49, 47, 47, 45, 45, 45,
+        45, 45, 45, 49, 49, 53, 53, 55, 55, 58, 58, 60, 60, 61, 61, 62, 62, 63,
+        63, 65, 65, 67, 67, 68, 68, 69, 49, 47, 47, 45, 45, 45, 45, 45, 45, 49,
+        49, 53, 53, 55, 55, 58, 58, 60, 60, 61, 61, 62, 62, 63, 63, 65, 65, 67,
+        67, 68, 68, 69, 50, 48, 48, 46, 46, 46, 46, 46, 46, 50, 50, 54, 54, 56,
+        56, 60, 60, 61, 61, 63, 63, 65, 65, 67, 67, 68, 68, 71, 71, 71, 71, 72,
+        50, 48, 48, 46, 46, 46, 46, 46, 46, 50, 50, 54, 54, 56, 56, 60, 60, 61,
+        61, 63, 63, 65, 65, 67, 67, 68, 68, 71, 71, 71, 71, 72, 52, 50, 50, 47,
+        47, 47, 47, 47, 47, 50, 50, 54, 54, 57, 57, 61, 61, 63, 63, 66, 66, 68,
+        68, 70, 70, 72, 72, 75, 75, 75, 75, 76, 52, 50, 50, 47, 47, 47, 47, 47,
+        47, 50, 50, 54, 54, 57, 57, 61, 61, 63, 63, 66, 66, 68, 68, 70, 70, 72,
+        72, 75, 75, 75, 75, 76, 54, 52, 52, 49, 49, 49, 49, 48, 48, 52, 52, 55,
+        55, 58, 58, 62, 62, 65, 65, 68, 68, 71, 71, 73, 73, 75, 75, 78, 78, 79,
+        79, 80, 54, 52, 52, 49, 49, 49, 49, 48, 48, 52, 52, 55, 55, 58, 58, 62,
+        62, 65, 65, 68, 68, 71, 71, 73, 73, 75, 75, 78, 78, 79, 79, 80, 57, 54,
+        54, 52, 52, 51, 51, 50, 50, 53, 53, 56, 56, 60, 60, 63, 63, 67, 67, 70,
+        70, 73, 73, 76, 76, 79, 79, 82, 82, 83, 83, 84, 57, 54, 54, 52, 52, 51,
+        51, 50, 50, 53, 53, 56, 56, 60, 60, 63, 63, 67, 67, 70, 70, 73, 73, 76,
+        76, 79, 79, 82, 82, 83, 83, 84, 60, 57, 57, 54, 54, 53, 53, 52, 52, 55,
+        55, 58, 58, 61, 61, 65, 65, 68, 68, 72, 72, 75, 75, 79, 79, 82, 82, 85,
+        85, 86, 86, 88, 60, 57, 57, 54, 54, 53, 53, 52, 52, 55, 55, 58, 58, 61,
+        61, 65, 65, 68, 68, 72, 72, 75, 75, 79, 79, 82, 82, 85, 85, 86, 86, 88,
+        63, 60, 60, 57, 57, 56, 56, 54, 54, 57, 57, 60, 60, 63, 63, 67, 67, 71,
+        71, 75, 75, 78, 78, 82, 82, 85, 85, 89, 89, 90, 90, 92, 63, 60, 60, 57,
+        57, 56, 56, 54, 54, 57, 57, 60, 60, 63, 63, 67, 67, 71, 71, 75, 75, 78,
+        78, 82, 82, 85, 85, 89, 89, 90, 90, 92, 65, 61, 61, 58, 58, 57, 57, 55,
+        55, 58, 58, 61, 61, 64, 64, 68, 68, 71, 71, 75, 75, 79, 79, 83, 83, 86,
+        86, 90, 90, 91, 91, 93, 65, 61, 61, 58, 58, 57, 57, 55, 55, 58, 58, 61,
+        61, 64, 64, 68, 68, 71, 71, 75, 75, 79, 79, 83, 83, 86, 86, 90, 90, 91,
+        91, 93, 67, 63, 63, 60, 60, 59, 59, 57, 57, 60, 60, 62, 62, 66, 66, 69,
+        69, 72, 72, 76, 76, 80, 80, 84, 84, 88, 88, 92, 92, 93, 93, 95,
         /* Size 4x8 */
-        63, 94, 100, 120, 72, 94, 95, 112, 86, 100, 101, 115, 92, 106, 115, 128,
-        93, 108, 128, 142, 100, 111, 137, 156, 109, 117, 145, 170, 118, 123,
-        151, 180,
+        31, 47, 50, 60, 36, 47, 47, 56, 43, 50, 50, 57, 46, 53, 57, 64, 46, 54,
+        64, 71, 50, 55, 68, 78, 54, 58, 72, 85, 59, 61, 75, 90,
         /* Size 8x4 */
-        63, 72, 86, 92, 93, 100, 109, 118, 94, 94, 100, 106, 108, 111, 117, 123,
-        100, 95, 101, 115, 128, 137, 145, 151, 120, 112, 115, 128, 142, 156,
-        170, 180,
+        31, 36, 43, 46, 46, 50, 54, 59, 47, 47, 50, 53, 54, 55, 58, 61, 50, 47,
+        50, 57, 64, 68, 72, 75, 60, 56, 57, 64, 71, 78, 85, 90,
         /* Size 8x16 */
-        64, 62, 74, 96, 98, 105, 115, 127, 63, 63, 77, 94, 94, 100, 109, 120,
-        61, 64, 80, 92, 91, 96, 104, 115, 67, 72, 86, 94, 92, 95, 103, 112, 74,
-        80, 94, 95, 91, 94, 100, 109, 84, 86, 95, 100, 99, 101, 107, 115, 98,
-        93, 96, 106, 107, 109, 114, 121, 97, 92, 94, 106, 112, 115, 120, 128,
-        98, 91, 92, 107, 117, 123, 128, 135, 101, 93, 93, 108, 119, 128, 134,
-        142, 104, 96, 95, 109, 122, 133, 142, 150, 109, 100, 98, 111, 125, 137,
-        147, 156, 114, 104, 101, 113, 128, 141, 153, 164, 120, 109, 105, 117,
-        131, 145, 158, 170, 127, 115, 110, 121, 135, 150, 164, 178, 129, 118,
-        112, 123, 136, 151, 166, 180,
+        32, 31, 37, 48, 49, 52, 57, 63, 31, 31, 38, 47, 47, 50, 54, 60, 30, 32,
+        40, 46, 45, 48, 52, 57, 33, 36, 43, 47, 46, 47, 51, 56, 37, 40, 47, 47,
+        45, 47, 50, 54, 42, 43, 47, 50, 49, 50, 53, 57, 49, 46, 48, 53, 53, 54,
+        57, 60, 48, 46, 47, 53, 56, 57, 60, 64, 49, 45, 46, 53, 58, 61, 64, 67,
+        50, 46, 46, 54, 59, 64, 67, 71, 52, 48, 47, 54, 61, 66, 71, 75, 54, 50,
+        49, 55, 62, 68, 73, 78, 57, 52, 50, 56, 64, 70, 76, 82, 60, 54, 52, 58,
+        65, 72, 79, 85, 63, 57, 55, 60, 67, 75, 82, 89, 64, 59, 56, 61, 68, 75,
+        83, 90,
         /* Size 16x8 */
-        64, 63, 61, 67, 74, 84, 98, 97, 98, 101, 104, 109, 114, 120, 127, 129,
-        62, 63, 64, 72, 80, 86, 93, 92, 91, 93, 96, 100, 104, 109, 115, 118, 74,
-        77, 80, 86, 94, 95, 96, 94, 92, 93, 95, 98, 101, 105, 110, 112, 96, 94,
-        92, 94, 95, 100, 106, 106, 107, 108, 109, 111, 113, 117, 121, 123, 98,
-        94, 91, 92, 91, 99, 107, 112, 117, 119, 122, 125, 128, 131, 135, 136,
-        105, 100, 96, 95, 94, 101, 109, 115, 123, 128, 133, 137, 141, 145, 150,
-        151, 115, 109, 104, 103, 100, 107, 114, 120, 128, 134, 142, 147, 153,
-        158, 164, 166, 127, 120, 115, 112, 109, 115, 121, 128, 135, 142, 150,
-        156, 164, 170, 178, 180,
+        32, 31, 30, 33, 37, 42, 49, 48, 49, 50, 52, 54, 57, 60, 63, 64, 31, 31,
+        32, 36, 40, 43, 46, 46, 45, 46, 48, 50, 52, 54, 57, 59, 37, 38, 40, 43,
+        47, 47, 48, 47, 46, 46, 47, 49, 50, 52, 55, 56, 48, 47, 46, 47, 47, 50,
+        53, 53, 53, 54, 54, 55, 56, 58, 60, 61, 49, 47, 45, 46, 45, 49, 53, 56,
+        58, 59, 61, 62, 64, 65, 67, 68, 52, 50, 48, 47, 47, 50, 54, 57, 61, 64,
+        66, 68, 70, 72, 75, 75, 57, 54, 52, 51, 50, 53, 57, 60, 64, 67, 71, 73,
+        76, 79, 82, 83, 63, 60, 57, 56, 54, 57, 60, 64, 67, 71, 75, 78, 82, 85,
+        89, 90,
         /* Size 16x32 */
-        64, 62, 62, 74, 74, 96, 96, 98, 98, 105, 105, 115, 115, 127, 127, 133,
-        63, 63, 63, 77, 77, 94, 94, 94, 94, 100, 100, 109, 109, 120, 120, 126,
-        63, 63, 63, 77, 77, 94, 94, 94, 94, 100, 100, 109, 109, 120, 120, 126,
-        61, 64, 64, 80, 80, 92, 92, 91, 91, 96, 96, 104, 104, 115, 115, 121, 61,
-        64, 64, 80, 80, 92, 92, 91, 91, 96, 96, 104, 104, 115, 115, 121, 67, 72,
-        72, 86, 86, 94, 94, 92, 92, 95, 95, 103, 103, 112, 112, 118, 67, 72, 72,
-        86, 86, 94, 94, 92, 92, 95, 95, 103, 103, 112, 112, 118, 74, 80, 80, 94,
-        94, 95, 95, 91, 91, 94, 94, 100, 100, 109, 109, 114, 74, 80, 80, 94, 94,
-        95, 95, 91, 91, 94, 94, 100, 100, 109, 109, 114, 84, 86, 86, 95, 95,
-        100, 100, 99, 99, 101, 101, 107, 107, 115, 115, 120, 84, 86, 86, 95, 95,
-        100, 100, 99, 99, 101, 101, 107, 107, 115, 115, 120, 98, 93, 93, 96, 96,
-        106, 106, 107, 107, 109, 109, 114, 114, 121, 121, 125, 98, 93, 93, 96,
-        96, 106, 106, 107, 107, 109, 109, 114, 114, 121, 121, 125, 97, 92, 92,
-        94, 94, 106, 106, 112, 112, 115, 115, 120, 120, 128, 128, 132, 97, 92,
-        92, 94, 94, 106, 106, 112, 112, 115, 115, 120, 120, 128, 128, 132, 98,
-        91, 91, 92, 92, 107, 107, 117, 117, 123, 123, 128, 128, 135, 135, 139,
-        98, 91, 91, 92, 92, 107, 107, 117, 117, 123, 123, 128, 128, 135, 135,
-        139, 101, 93, 93, 93, 93, 108, 108, 119, 119, 128, 128, 134, 134, 142,
-        142, 146, 101, 93, 93, 93, 93, 108, 108, 119, 119, 128, 128, 134, 134,
-        142, 142, 146, 104, 96, 96, 95, 95, 109, 109, 122, 122, 133, 133, 142,
-        142, 150, 150, 154, 104, 96, 96, 95, 95, 109, 109, 122, 122, 133, 133,
-        142, 142, 150, 150, 154, 109, 100, 100, 98, 98, 111, 111, 125, 125, 137,
-        137, 147, 147, 156, 156, 161, 109, 100, 100, 98, 98, 111, 111, 125, 125,
-        137, 137, 147, 147, 156, 156, 161, 114, 104, 104, 101, 101, 113, 113,
-        128, 128, 141, 141, 153, 153, 164, 164, 169, 114, 104, 104, 101, 101,
-        113, 113, 128, 128, 141, 141, 153, 153, 164, 164, 169, 120, 109, 109,
-        105, 105, 117, 117, 131, 131, 145, 145, 158, 158, 170, 170, 176, 120,
-        109, 109, 105, 105, 117, 117, 131, 131, 145, 145, 158, 158, 170, 170,
-        176, 127, 115, 115, 110, 110, 121, 121, 135, 135, 150, 150, 164, 164,
-        178, 178, 184, 127, 115, 115, 110, 110, 121, 121, 135, 135, 150, 150,
-        164, 164, 178, 178, 184, 129, 118, 118, 112, 112, 123, 123, 136, 136,
-        151, 151, 166, 166, 180, 180, 187, 129, 118, 118, 112, 112, 123, 123,
-        136, 136, 151, 151, 166, 166, 180, 180, 187, 133, 121, 121, 115, 115,
-        126, 126, 139, 139, 154, 154, 169, 169, 184, 184, 191,
+        32, 31, 31, 37, 37, 48, 48, 49, 49, 52, 52, 57, 57, 63, 63, 66, 31, 31,
+        31, 38, 38, 47, 47, 47, 47, 50, 50, 54, 54, 60, 60, 63, 31, 31, 31, 38,
+        38, 47, 47, 47, 47, 50, 50, 54, 54, 60, 60, 63, 30, 32, 32, 40, 40, 46,
+        46, 45, 45, 48, 48, 52, 52, 57, 57, 60, 30, 32, 32, 40, 40, 46, 46, 45,
+        45, 48, 48, 52, 52, 57, 57, 60, 33, 36, 36, 43, 43, 47, 47, 46, 46, 47,
+        47, 51, 51, 56, 56, 59, 33, 36, 36, 43, 43, 47, 47, 46, 46, 47, 47, 51,
+        51, 56, 56, 59, 37, 40, 40, 47, 47, 47, 47, 45, 45, 47, 47, 50, 50, 54,
+        54, 57, 37, 40, 40, 47, 47, 47, 47, 45, 45, 47, 47, 50, 50, 54, 54, 57,
+        42, 43, 43, 47, 47, 50, 50, 49, 49, 50, 50, 53, 53, 57, 57, 60, 42, 43,
+        43, 47, 47, 50, 50, 49, 49, 50, 50, 53, 53, 57, 57, 60, 49, 46, 46, 48,
+        48, 53, 53, 53, 53, 54, 54, 57, 57, 60, 60, 62, 49, 46, 46, 48, 48, 53,
+        53, 53, 53, 54, 54, 57, 57, 60, 60, 62, 48, 46, 46, 47, 47, 53, 53, 56,
+        56, 57, 57, 60, 60, 64, 64, 66, 48, 46, 46, 47, 47, 53, 53, 56, 56, 57,
+        57, 60, 60, 64, 64, 66, 49, 45, 45, 46, 46, 53, 53, 58, 58, 61, 61, 64,
+        64, 67, 67, 69, 49, 45, 45, 46, 46, 53, 53, 58, 58, 61, 61, 64, 64, 67,
+        67, 69, 50, 46, 46, 46, 46, 54, 54, 59, 59, 64, 64, 67, 67, 71, 71, 73,
+        50, 46, 46, 46, 46, 54, 54, 59, 59, 64, 64, 67, 67, 71, 71, 73, 52, 48,
+        48, 47, 47, 54, 54, 61, 61, 66, 66, 71, 71, 75, 75, 77, 52, 48, 48, 47,
+        47, 54, 54, 61, 61, 66, 66, 71, 71, 75, 75, 77, 54, 50, 50, 49, 49, 55,
+        55, 62, 62, 68, 68, 73, 73, 78, 78, 80, 54, 50, 50, 49, 49, 55, 55, 62,
+        62, 68, 68, 73, 73, 78, 78, 80, 57, 52, 52, 50, 50, 56, 56, 64, 64, 70,
+        70, 76, 76, 82, 82, 84, 57, 52, 52, 50, 50, 56, 56, 64, 64, 70, 70, 76,
+        76, 82, 82, 84, 60, 54, 54, 52, 52, 58, 58, 65, 65, 72, 72, 79, 79, 85,
+        85, 88, 60, 54, 54, 52, 52, 58, 58, 65, 65, 72, 72, 79, 79, 85, 85, 88,
+        63, 57, 57, 55, 55, 60, 60, 67, 67, 75, 75, 82, 82, 89, 89, 92, 63, 57,
+        57, 55, 55, 60, 60, 67, 67, 75, 75, 82, 82, 89, 89, 92, 64, 59, 59, 56,
+        56, 61, 61, 68, 68, 75, 75, 83, 83, 90, 90, 93, 64, 59, 59, 56, 56, 61,
+        61, 68, 68, 75, 75, 83, 83, 90, 90, 93, 66, 60, 60, 57, 57, 63, 63, 69,
+        69, 77, 77, 84, 84, 92, 92, 95,
         /* Size 32x16 */
-        64, 63, 63, 61, 61, 67, 67, 74, 74, 84, 84, 98, 98, 97, 97, 98, 98, 101,
-        101, 104, 104, 109, 109, 114, 114, 120, 120, 127, 127, 129, 129, 133,
-        62, 63, 63, 64, 64, 72, 72, 80, 80, 86, 86, 93, 93, 92, 92, 91, 91, 93,
-        93, 96, 96, 100, 100, 104, 104, 109, 109, 115, 115, 118, 118, 121, 62,
-        63, 63, 64, 64, 72, 72, 80, 80, 86, 86, 93, 93, 92, 92, 91, 91, 93, 93,
-        96, 96, 100, 100, 104, 104, 109, 109, 115, 115, 118, 118, 121, 74, 77,
-        77, 80, 80, 86, 86, 94, 94, 95, 95, 96, 96, 94, 94, 92, 92, 93, 93, 95,
-        95, 98, 98, 101, 101, 105, 105, 110, 110, 112, 112, 115, 74, 77, 77, 80,
-        80, 86, 86, 94, 94, 95, 95, 96, 96, 94, 94, 92, 92, 93, 93, 95, 95, 98,
-        98, 101, 101, 105, 105, 110, 110, 112, 112, 115, 96, 94, 94, 92, 92, 94,
-        94, 95, 95, 100, 100, 106, 106, 106, 106, 107, 107, 108, 108, 109, 109,
-        111, 111, 113, 113, 117, 117, 121, 121, 123, 123, 126, 96, 94, 94, 92,
-        92, 94, 94, 95, 95, 100, 100, 106, 106, 106, 106, 107, 107, 108, 108,
-        109, 109, 111, 111, 113, 113, 117, 117, 121, 121, 123, 123, 126, 98, 94,
-        94, 91, 91, 92, 92, 91, 91, 99, 99, 107, 107, 112, 112, 117, 117, 119,
-        119, 122, 122, 125, 125, 128, 128, 131, 131, 135, 135, 136, 136, 139,
-        98, 94, 94, 91, 91, 92, 92, 91, 91, 99, 99, 107, 107, 112, 112, 117,
-        117, 119, 119, 122, 122, 125, 125, 128, 128, 131, 131, 135, 135, 136,
-        136, 139, 105, 100, 100, 96, 96, 95, 95, 94, 94, 101, 101, 109, 109,
-        115, 115, 123, 123, 128, 128, 133, 133, 137, 137, 141, 141, 145, 145,
-        150, 150, 151, 151, 154, 105, 100, 100, 96, 96, 95, 95, 94, 94, 101,
-        101, 109, 109, 115, 115, 123, 123, 128, 128, 133, 133, 137, 137, 141,
-        141, 145, 145, 150, 150, 151, 151, 154, 115, 109, 109, 104, 104, 103,
-        103, 100, 100, 107, 107, 114, 114, 120, 120, 128, 128, 134, 134, 142,
-        142, 147, 147, 153, 153, 158, 158, 164, 164, 166, 166, 169, 115, 109,
-        109, 104, 104, 103, 103, 100, 100, 107, 107, 114, 114, 120, 120, 128,
-        128, 134, 134, 142, 142, 147, 147, 153, 153, 158, 158, 164, 164, 166,
-        166, 169, 127, 120, 120, 115, 115, 112, 112, 109, 109, 115, 115, 121,
-        121, 128, 128, 135, 135, 142, 142, 150, 150, 156, 156, 164, 164, 170,
-        170, 178, 178, 180, 180, 184, 127, 120, 120, 115, 115, 112, 112, 109,
-        109, 115, 115, 121, 121, 128, 128, 135, 135, 142, 142, 150, 150, 156,
-        156, 164, 164, 170, 170, 178, 178, 180, 180, 184, 133, 126, 126, 121,
-        121, 118, 118, 114, 114, 120, 120, 125, 125, 132, 132, 139, 139, 146,
-        146, 154, 154, 161, 161, 169, 169, 176, 176, 184, 184, 187, 187, 191,
+        32, 31, 31, 30, 30, 33, 33, 37, 37, 42, 42, 49, 49, 48, 48, 49, 49, 50,
+        50, 52, 52, 54, 54, 57, 57, 60, 60, 63, 63, 64, 64, 66, 31, 31, 31, 32,
+        32, 36, 36, 40, 40, 43, 43, 46, 46, 46, 46, 45, 45, 46, 46, 48, 48, 50,
+        50, 52, 52, 54, 54, 57, 57, 59, 59, 60, 31, 31, 31, 32, 32, 36, 36, 40,
+        40, 43, 43, 46, 46, 46, 46, 45, 45, 46, 46, 48, 48, 50, 50, 52, 52, 54,
+        54, 57, 57, 59, 59, 60, 37, 38, 38, 40, 40, 43, 43, 47, 47, 47, 47, 48,
+        48, 47, 47, 46, 46, 46, 46, 47, 47, 49, 49, 50, 50, 52, 52, 55, 55, 56,
+        56, 57, 37, 38, 38, 40, 40, 43, 43, 47, 47, 47, 47, 48, 48, 47, 47, 46,
+        46, 46, 46, 47, 47, 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 57, 48, 47,
+        47, 46, 46, 47, 47, 47, 47, 50, 50, 53, 53, 53, 53, 53, 53, 54, 54, 54,
+        54, 55, 55, 56, 56, 58, 58, 60, 60, 61, 61, 63, 48, 47, 47, 46, 46, 47,
+        47, 47, 47, 50, 50, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 56,
+        56, 58, 58, 60, 60, 61, 61, 63, 49, 47, 47, 45, 45, 46, 46, 45, 45, 49,
+        49, 53, 53, 56, 56, 58, 58, 59, 59, 61, 61, 62, 62, 64, 64, 65, 65, 67,
+        67, 68, 68, 69, 49, 47, 47, 45, 45, 46, 46, 45, 45, 49, 49, 53, 53, 56,
+        56, 58, 58, 59, 59, 61, 61, 62, 62, 64, 64, 65, 65, 67, 67, 68, 68, 69,
+        52, 50, 50, 48, 48, 47, 47, 47, 47, 50, 50, 54, 54, 57, 57, 61, 61, 64,
+        64, 66, 66, 68, 68, 70, 70, 72, 72, 75, 75, 75, 75, 77, 52, 50, 50, 48,
+        48, 47, 47, 47, 47, 50, 50, 54, 54, 57, 57, 61, 61, 64, 64, 66, 66, 68,
+        68, 70, 70, 72, 72, 75, 75, 75, 75, 77, 57, 54, 54, 52, 52, 51, 51, 50,
+        50, 53, 53, 57, 57, 60, 60, 64, 64, 67, 67, 71, 71, 73, 73, 76, 76, 79,
+        79, 82, 82, 83, 83, 84, 57, 54, 54, 52, 52, 51, 51, 50, 50, 53, 53, 57,
+        57, 60, 60, 64, 64, 67, 67, 71, 71, 73, 73, 76, 76, 79, 79, 82, 82, 83,
+        83, 84, 63, 60, 60, 57, 57, 56, 56, 54, 54, 57, 57, 60, 60, 64, 64, 67,
+        67, 71, 71, 75, 75, 78, 78, 82, 82, 85, 85, 89, 89, 90, 90, 92, 63, 60,
+        60, 57, 57, 56, 56, 54, 54, 57, 57, 60, 60, 64, 64, 67, 67, 71, 71, 75,
+        75, 78, 78, 82, 82, 85, 85, 89, 89, 90, 90, 92, 66, 63, 63, 60, 60, 59,
+        59, 57, 57, 60, 60, 62, 62, 66, 66, 69, 69, 73, 73, 77, 77, 80, 80, 84,
+        84, 88, 88, 92, 92, 93, 93, 95,
         /* Size 4x16 */
-        62, 96, 105, 127, 63, 94, 100, 120, 64, 92, 96, 115, 72, 94, 95, 112,
-        80, 95, 94, 109, 86, 100, 101, 115, 93, 106, 109, 121, 92, 106, 115,
-        128, 91, 107, 123, 135, 93, 108, 128, 142, 96, 109, 133, 150, 100, 111,
-        137, 156, 104, 113, 141, 164, 109, 117, 145, 170, 115, 121, 150, 178,
-        118, 123, 151, 180,
+        31, 48, 52, 63, 31, 47, 50, 60, 32, 46, 48, 57, 36, 47, 47, 56, 40, 47,
+        47, 54, 43, 50, 50, 57, 46, 53, 54, 60, 46, 53, 57, 64, 45, 53, 61, 67,
+        46, 54, 64, 71, 48, 54, 66, 75, 50, 55, 68, 78, 52, 56, 70, 82, 54, 58,
+        72, 85, 57, 60, 75, 89, 59, 61, 75, 90,
         /* Size 16x4 */
-        62, 63, 64, 72, 80, 86, 93, 92, 91, 93, 96, 100, 104, 109, 115, 118, 96,
-        94, 92, 94, 95, 100, 106, 106, 107, 108, 109, 111, 113, 117, 121, 123,
-        105, 100, 96, 95, 94, 101, 109, 115, 123, 128, 133, 137, 141, 145, 150,
-        151, 127, 120, 115, 112, 109, 115, 121, 128, 135, 142, 150, 156, 164,
-        170, 178, 180,
+        31, 31, 32, 36, 40, 43, 46, 46, 45, 46, 48, 50, 52, 54, 57, 59, 48, 47,
+        46, 47, 47, 50, 53, 53, 53, 54, 54, 55, 56, 58, 60, 61, 52, 50, 48, 47,
+        47, 50, 54, 57, 61, 64, 66, 68, 70, 72, 75, 75, 63, 60, 57, 56, 54, 57,
+        60, 64, 67, 71, 75, 78, 82, 85, 89, 90,
         /* Size 8x32 */
-        64, 62, 74, 96, 98, 105, 115, 127, 63, 63, 77, 94, 94, 100, 109, 120,
-        63, 63, 77, 94, 94, 100, 109, 120, 61, 64, 80, 92, 91, 96, 104, 115, 61,
-        64, 80, 92, 91, 96, 104, 115, 67, 72, 86, 94, 92, 95, 103, 112, 67, 72,
-        86, 94, 92, 95, 103, 112, 74, 80, 94, 95, 91, 94, 100, 109, 74, 80, 94,
-        95, 91, 94, 100, 109, 84, 86, 95, 100, 99, 101, 107, 115, 84, 86, 95,
-        100, 99, 101, 107, 115, 98, 93, 96, 106, 107, 109, 114, 121, 98, 93, 96,
-        106, 107, 109, 114, 121, 97, 92, 94, 106, 112, 115, 120, 128, 97, 92,
-        94, 106, 112, 115, 120, 128, 98, 91, 92, 107, 117, 123, 128, 135, 98,
-        91, 92, 107, 117, 123, 128, 135, 101, 93, 93, 108, 119, 128, 134, 142,
-        101, 93, 93, 108, 119, 128, 134, 142, 104, 96, 95, 109, 122, 133, 142,
-        150, 104, 96, 95, 109, 122, 133, 142, 150, 109, 100, 98, 111, 125, 137,
-        147, 156, 109, 100, 98, 111, 125, 137, 147, 156, 114, 104, 101, 113,
-        128, 141, 153, 164, 114, 104, 101, 113, 128, 141, 153, 164, 120, 109,
-        105, 117, 131, 145, 158, 170, 120, 109, 105, 117, 131, 145, 158, 170,
-        127, 115, 110, 121, 135, 150, 164, 178, 127, 115, 110, 121, 135, 150,
-        164, 178, 129, 118, 112, 123, 136, 151, 166, 180, 129, 118, 112, 123,
-        136, 151, 166, 180, 133, 121, 115, 126, 139, 154, 169, 184,
+        32, 31, 37, 48, 49, 52, 57, 63, 31, 31, 38, 47, 47, 50, 54, 60, 31, 31,
+        38, 47, 47, 50, 54, 60, 30, 32, 40, 46, 45, 48, 52, 57, 30, 32, 40, 46,
+        45, 48, 52, 57, 33, 36, 43, 47, 46, 47, 51, 56, 33, 36, 43, 47, 46, 47,
+        51, 56, 37, 40, 47, 47, 45, 47, 50, 54, 37, 40, 47, 47, 45, 47, 50, 54,
+        42, 43, 47, 50, 49, 50, 53, 57, 42, 43, 47, 50, 49, 50, 53, 57, 49, 46,
+        48, 53, 53, 54, 57, 60, 49, 46, 48, 53, 53, 54, 57, 60, 48, 46, 47, 53,
+        56, 57, 60, 64, 48, 46, 47, 53, 56, 57, 60, 64, 49, 45, 46, 53, 58, 61,
+        64, 67, 49, 45, 46, 53, 58, 61, 64, 67, 50, 46, 46, 54, 59, 64, 67, 71,
+        50, 46, 46, 54, 59, 64, 67, 71, 52, 48, 47, 54, 61, 66, 71, 75, 52, 48,
+        47, 54, 61, 66, 71, 75, 54, 50, 49, 55, 62, 68, 73, 78, 54, 50, 49, 55,
+        62, 68, 73, 78, 57, 52, 50, 56, 64, 70, 76, 82, 57, 52, 50, 56, 64, 70,
+        76, 82, 60, 54, 52, 58, 65, 72, 79, 85, 60, 54, 52, 58, 65, 72, 79, 85,
+        63, 57, 55, 60, 67, 75, 82, 89, 63, 57, 55, 60, 67, 75, 82, 89, 64, 59,
+        56, 61, 68, 75, 83, 90, 64, 59, 56, 61, 68, 75, 83, 90, 66, 60, 57, 63,
+        69, 77, 84, 92,
         /* Size 32x8 */
-        64, 63, 63, 61, 61, 67, 67, 74, 74, 84, 84, 98, 98, 97, 97, 98, 98, 101,
-        101, 104, 104, 109, 109, 114, 114, 120, 120, 127, 127, 129, 129, 133,
-        62, 63, 63, 64, 64, 72, 72, 80, 80, 86, 86, 93, 93, 92, 92, 91, 91, 93,
-        93, 96, 96, 100, 100, 104, 104, 109, 109, 115, 115, 118, 118, 121, 74,
-        77, 77, 80, 80, 86, 86, 94, 94, 95, 95, 96, 96, 94, 94, 92, 92, 93, 93,
-        95, 95, 98, 98, 101, 101, 105, 105, 110, 110, 112, 112, 115, 96, 94, 94,
-        92, 92, 94, 94, 95, 95, 100, 100, 106, 106, 106, 106, 107, 107, 108,
-        108, 109, 109, 111, 111, 113, 113, 117, 117, 121, 121, 123, 123, 126,
-        98, 94, 94, 91, 91, 92, 92, 91, 91, 99, 99, 107, 107, 112, 112, 117,
-        117, 119, 119, 122, 122, 125, 125, 128, 128, 131, 131, 135, 135, 136,
-        136, 139, 105, 100, 100, 96, 96, 95, 95, 94, 94, 101, 101, 109, 109,
-        115, 115, 123, 123, 128, 128, 133, 133, 137, 137, 141, 141, 145, 145,
-        150, 150, 151, 151, 154, 115, 109, 109, 104, 104, 103, 103, 100, 100,
-        107, 107, 114, 114, 120, 120, 128, 128, 134, 134, 142, 142, 147, 147,
-        153, 153, 158, 158, 164, 164, 166, 166, 169, 127, 120, 120, 115, 115,
-        112, 112, 109, 109, 115, 115, 121, 121, 128, 128, 135, 135, 142, 142,
-        150, 150, 156, 156, 164, 164, 170, 170, 178, 178, 180, 180, 184 },
+        32, 31, 31, 30, 30, 33, 33, 37, 37, 42, 42, 49, 49, 48, 48, 49, 49, 50,
+        50, 52, 52, 54, 54, 57, 57, 60, 60, 63, 63, 64, 64, 66, 31, 31, 31, 32,
+        32, 36, 36, 40, 40, 43, 43, 46, 46, 46, 46, 45, 45, 46, 46, 48, 48, 50,
+        50, 52, 52, 54, 54, 57, 57, 59, 59, 60, 37, 38, 38, 40, 40, 43, 43, 47,
+        47, 47, 47, 48, 48, 47, 47, 46, 46, 46, 46, 47, 47, 49, 49, 50, 50, 52,
+        52, 55, 55, 56, 56, 57, 48, 47, 47, 46, 46, 47, 47, 47, 47, 50, 50, 53,
+        53, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 56, 56, 58, 58, 60, 60, 61,
+        61, 63, 49, 47, 47, 45, 45, 46, 46, 45, 45, 49, 49, 53, 53, 56, 56, 58,
+        58, 59, 59, 61, 61, 62, 62, 64, 64, 65, 65, 67, 67, 68, 68, 69, 52, 50,
+        50, 48, 48, 47, 47, 47, 47, 50, 50, 54, 54, 57, 57, 61, 61, 64, 64, 66,
+        66, 68, 68, 70, 70, 72, 72, 75, 75, 75, 75, 77, 57, 54, 54, 52, 52, 51,
+        51, 50, 50, 53, 53, 57, 57, 60, 60, 64, 64, 67, 67, 71, 71, 73, 73, 76,
+        76, 79, 79, 82, 82, 83, 83, 84, 63, 60, 60, 57, 57, 56, 56, 54, 54, 57,
+        57, 60, 60, 64, 64, 67, 67, 71, 71, 75, 75, 78, 78, 82, 82, 85, 85, 89,
+        89, 90, 90, 92 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        68, 105, 105, 178,
+        34, 52, 52, 89,
 #endif
         /* Size 4x4 */
-        64, 67, 90, 124, 67, 79, 102, 129, 90, 102, 142, 174, 124, 129, 174,
-        217,
+        32, 33, 45, 62, 33, 39, 51, 64, 45, 51, 71, 87, 62, 64, 87, 108,
         /* Size 8x8 */
-        63, 64, 65, 71, 85, 102, 119, 138, 64, 65, 67, 71, 83, 98, 113, 131, 65,
-        67, 71, 77, 86, 99, 112, 128, 71, 71, 77, 97, 108, 119, 132, 147, 85,
-        83, 86, 108, 127, 142, 155, 170, 102, 98, 99, 119, 142, 162, 178, 195,
-        119, 113, 112, 132, 155, 178, 196, 216, 138, 131, 128, 147, 170, 195,
-        216, 238,
+        31, 32, 32, 35, 42, 51, 59, 69, 32, 32, 33, 35, 41, 49, 56, 65, 32, 33,
+        35, 38, 43, 49, 56, 64, 35, 35, 38, 48, 54, 59, 66, 73, 42, 41, 43, 54,
+        63, 71, 77, 85, 51, 49, 49, 59, 71, 81, 89, 97, 59, 56, 56, 66, 77, 89,
+        98, 108, 69, 65, 64, 73, 85, 97, 108, 119,
         /* Size 16x16 */
-        64, 63, 63, 63, 64, 68, 71, 76, 82, 90, 97, 108, 118, 131, 143, 160, 63,
-        64, 64, 64, 65, 68, 70, 74, 80, 86, 93, 103, 113, 125, 136, 152, 63, 64,
-        65, 65, 65, 67, 68, 72, 77, 83, 89, 99, 108, 119, 130, 145, 63, 64, 65,
-        67, 68, 71, 72, 76, 81, 85, 91, 100, 108, 118, 129, 143, 64, 65, 65, 68,
-        71, 74, 76, 79, 83, 87, 92, 99, 107, 116, 126, 139, 68, 68, 67, 71, 74,
-        79, 84, 88, 92, 97, 102, 109, 117, 126, 136, 148, 71, 70, 68, 72, 76,
-        84, 92, 97, 101, 106, 111, 118, 125, 134, 144, 156, 76, 74, 72, 76, 79,
-        88, 97, 103, 108, 114, 119, 126, 134, 142, 152, 164, 82, 80, 77, 81, 83,
-        92, 101, 108, 114, 121, 127, 135, 143, 151, 161, 173, 90, 86, 83, 85,
-        87, 97, 106, 114, 121, 130, 136, 145, 153, 162, 171, 183, 97, 93, 89,
-        91, 92, 102, 111, 119, 127, 136, 142, 153, 161, 171, 181, 193, 108, 103,
-        99, 100, 99, 109, 118, 126, 135, 145, 153, 165, 174, 185, 195, 208, 118,
-        113, 108, 108, 107, 117, 125, 134, 143, 153, 161, 174, 184, 196, 207,
-        221, 131, 125, 119, 118, 116, 126, 134, 142, 151, 162, 171, 185, 196,
-        210, 222, 237, 143, 136, 130, 129, 126, 136, 144, 152, 161, 171, 181,
-        195, 207, 222, 235, 251, 160, 152, 145, 143, 139, 148, 156, 164, 173,
-        183, 193, 208, 221, 237, 251, 268,
+        32, 31, 31, 31, 32, 34, 35, 38, 41, 45, 48, 54, 59, 65, 71, 80, 31, 32,
+        32, 32, 32, 34, 35, 37, 40, 43, 46, 51, 56, 62, 68, 76, 31, 32, 32, 32,
+        32, 33, 34, 36, 38, 41, 44, 49, 54, 59, 65, 72, 31, 32, 32, 33, 34, 35,
+        36, 38, 40, 42, 45, 50, 54, 59, 64, 71, 32, 32, 32, 34, 35, 37, 38, 39,
+        41, 43, 46, 49, 53, 58, 63, 69, 34, 34, 33, 35, 37, 39, 42, 44, 46, 48,
+        51, 54, 58, 63, 68, 74, 35, 35, 34, 36, 38, 42, 46, 48, 50, 53, 55, 59,
+        62, 67, 72, 78, 38, 37, 36, 38, 39, 44, 48, 51, 54, 57, 59, 63, 67, 71,
+        76, 82, 41, 40, 38, 40, 41, 46, 50, 54, 57, 60, 63, 67, 71, 75, 80, 86,
+        45, 43, 41, 42, 43, 48, 53, 57, 60, 65, 68, 72, 76, 81, 85, 91, 48, 46,
+        44, 45, 46, 51, 55, 59, 63, 68, 71, 76, 80, 85, 90, 96, 54, 51, 49, 50,
+        49, 54, 59, 63, 67, 72, 76, 82, 87, 92, 97, 104, 59, 56, 54, 54, 53, 58,
+        62, 67, 71, 76, 80, 87, 92, 98, 103, 110, 65, 62, 59, 59, 58, 63, 67,
+        71, 75, 81, 85, 92, 98, 105, 111, 118, 71, 68, 65, 64, 63, 68, 72, 76,
+        80, 85, 90, 97, 103, 111, 117, 125, 80, 76, 72, 71, 69, 74, 78, 82, 86,
+        91, 96, 104, 110, 118, 125, 134,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 63, 64, 64, 64, 68, 68, 71, 72, 76, 79, 82, 88,
-        90, 97, 97, 107, 108, 115, 118, 124, 131, 134, 143, 145, 160, 160, 63,
-        63, 64, 64, 64, 64, 64, 64, 65, 65, 68, 68, 70, 71, 74, 77, 80, 85, 87,
-        93, 93, 102, 104, 110, 113, 119, 125, 128, 137, 138, 152, 152, 63, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 68, 68, 70, 70, 74, 77, 80, 85, 86, 93,
-        93, 102, 103, 110, 113, 118, 125, 128, 136, 138, 152, 152, 63, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 67, 67, 69, 69, 73, 76, 78, 83, 84, 90, 90,
-        99, 100, 106, 109, 115, 121, 124, 132, 133, 147, 147, 63, 64, 64, 64,
-        65, 65, 65, 65, 65, 66, 67, 67, 68, 69, 72, 75, 77, 82, 83, 89, 89, 98,
-        99, 105, 108, 113, 119, 122, 130, 131, 145, 145, 63, 64, 64, 65, 65, 65,
-        66, 66, 67, 67, 69, 69, 70, 71, 74, 77, 79, 83, 84, 90, 90, 98, 99, 105,
-        108, 113, 119, 122, 129, 131, 144, 144, 63, 64, 64, 65, 65, 66, 67, 67,
-        68, 68, 71, 71, 72, 73, 76, 78, 81, 84, 85, 91, 91, 99, 100, 105, 108,
-        113, 118, 121, 129, 130, 143, 143, 64, 64, 64, 65, 65, 66, 67, 68, 69,
-        69, 71, 71, 73, 74, 77, 79, 81, 84, 86, 91, 91, 99, 99, 105, 108, 113,
-        118, 121, 128, 129, 141, 141, 64, 65, 65, 65, 65, 67, 68, 69, 71, 71,
-        74, 74, 76, 77, 79, 81, 83, 85, 87, 92, 92, 98, 99, 104, 107, 111, 116,
-        119, 126, 127, 139, 139, 64, 65, 65, 65, 66, 67, 68, 69, 71, 71, 74, 74,
-        77, 77, 80, 82, 83, 86, 87, 93, 93, 99, 100, 105, 108, 112, 117, 120,
-        127, 128, 140, 140, 68, 68, 68, 67, 67, 69, 71, 71, 74, 74, 79, 79, 84,
-        85, 88, 90, 92, 95, 97, 102, 102, 108, 109, 114, 117, 121, 126, 129,
-        136, 137, 148, 148, 68, 68, 68, 67, 67, 69, 71, 71, 74, 74, 79, 79, 84,
-        85, 88, 90, 92, 95, 97, 102, 102, 108, 109, 114, 117, 121, 126, 129,
-        136, 137, 148, 148, 71, 70, 70, 69, 68, 70, 72, 73, 76, 77, 84, 84, 92,
-        94, 97, 99, 101, 105, 106, 111, 111, 117, 118, 123, 125, 129, 134, 137,
-        144, 145, 156, 156, 72, 71, 70, 69, 69, 71, 73, 74, 77, 77, 85, 85, 94,
-        97, 100, 101, 104, 108, 109, 114, 114, 119, 120, 125, 128, 132, 136,
-        139, 146, 147, 158, 158, 76, 74, 74, 73, 72, 74, 76, 77, 79, 80, 88, 88,
-        97, 100, 103, 105, 108, 112, 114, 119, 119, 125, 126, 131, 134, 138,
-        142, 145, 152, 153, 164, 164, 79, 77, 77, 76, 75, 77, 78, 79, 81, 82,
-        90, 90, 99, 101, 105, 108, 111, 116, 117, 122, 122, 129, 130, 135, 138,
-        142, 147, 149, 156, 157, 168, 168, 82, 80, 80, 78, 77, 79, 81, 81, 83,
-        83, 92, 92, 101, 104, 108, 111, 114, 120, 121, 127, 127, 134, 135, 140,
-        143, 147, 151, 154, 161, 162, 173, 173, 88, 85, 85, 83, 82, 83, 84, 84,
-        85, 86, 95, 95, 105, 108, 112, 116, 120, 127, 128, 134, 134, 142, 143,
-        148, 151, 155, 159, 162, 169, 170, 181, 181, 90, 87, 86, 84, 83, 84, 85,
-        86, 87, 87, 97, 97, 106, 109, 114, 117, 121, 128, 130, 136, 136, 144,
-        145, 150, 153, 157, 162, 164, 171, 172, 183, 183, 97, 93, 93, 90, 89,
-        90, 91, 91, 92, 93, 102, 102, 111, 114, 119, 122, 127, 134, 136, 142,
-        142, 151, 153, 158, 161, 166, 171, 174, 181, 182, 193, 193, 97, 93, 93,
-        90, 89, 90, 91, 91, 92, 93, 102, 102, 111, 114, 119, 122, 127, 134, 136,
-        142, 142, 151, 153, 158, 161, 166, 171, 174, 181, 182, 193, 193, 107,
-        102, 102, 99, 98, 98, 99, 99, 98, 99, 108, 108, 117, 119, 125, 129, 134,
-        142, 144, 151, 151, 162, 163, 170, 173, 178, 183, 186, 194, 195, 206,
-        206, 108, 104, 103, 100, 99, 99, 100, 99, 99, 100, 109, 109, 118, 120,
-        126, 130, 135, 143, 145, 153, 153, 163, 165, 171, 174, 179, 185, 188,
-        195, 196, 208, 208, 115, 110, 110, 106, 105, 105, 105, 105, 104, 105,
-        114, 114, 123, 125, 131, 135, 140, 148, 150, 158, 158, 170, 171, 178,
-        181, 187, 193, 196, 204, 205, 217, 217, 118, 113, 113, 109, 108, 108,
-        108, 108, 107, 108, 117, 117, 125, 128, 134, 138, 143, 151, 153, 161,
-        161, 173, 174, 181, 184, 190, 196, 199, 207, 209, 221, 221, 124, 119,
-        118, 115, 113, 113, 113, 113, 111, 112, 121, 121, 129, 132, 138, 142,
-        147, 155, 157, 166, 166, 178, 179, 187, 190, 196, 203, 206, 214, 216,
-        229, 229, 131, 125, 125, 121, 119, 119, 118, 118, 116, 117, 126, 126,
-        134, 136, 142, 147, 151, 159, 162, 171, 171, 183, 185, 193, 196, 203,
-        210, 213, 222, 223, 237, 237, 134, 128, 128, 124, 122, 122, 121, 121,
-        119, 120, 129, 129, 137, 139, 145, 149, 154, 162, 164, 174, 174, 186,
-        188, 196, 199, 206, 213, 217, 226, 227, 241, 241, 143, 137, 136, 132,
-        130, 129, 129, 128, 126, 127, 136, 136, 144, 146, 152, 156, 161, 169,
-        171, 181, 181, 194, 195, 204, 207, 214, 222, 226, 235, 236, 251, 251,
-        145, 138, 138, 133, 131, 131, 130, 129, 127, 128, 137, 137, 145, 147,
-        153, 157, 162, 170, 172, 182, 182, 195, 196, 205, 209, 216, 223, 227,
-        236, 238, 252, 252, 160, 152, 152, 147, 145, 144, 143, 141, 139, 140,
-        148, 148, 156, 158, 164, 168, 173, 181, 183, 193, 193, 206, 208, 217,
-        221, 229, 237, 241, 251, 252, 268, 268, 160, 152, 152, 147, 145, 144,
-        143, 141, 139, 140, 148, 148, 156, 158, 164, 168, 173, 181, 183, 193,
-        193, 206, 208, 217, 221, 229, 237, 241, 251, 252, 268, 268,
+        32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 34, 34, 35, 36, 38, 39, 41, 44,
+        45, 48, 48, 53, 54, 57, 59, 62, 65, 67, 71, 72, 80, 80, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 34, 34, 35, 35, 37, 38, 40, 42, 43, 46, 46, 51,
+        52, 55, 56, 59, 62, 64, 68, 69, 76, 76, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 34, 34, 35, 35, 37, 38, 40, 42, 43, 46, 46, 51, 51, 55, 56, 59,
+        62, 64, 68, 69, 76, 76, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        34, 34, 36, 38, 39, 41, 42, 45, 45, 49, 50, 53, 54, 57, 60, 62, 66, 66,
+        73, 73, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 36, 37,
+        38, 41, 41, 44, 44, 49, 49, 52, 54, 56, 59, 61, 65, 65, 72, 72, 31, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 35, 35, 37, 38, 39, 41, 42, 45,
+        45, 49, 49, 52, 54, 56, 59, 61, 64, 65, 72, 72, 31, 32, 32, 32, 32, 33,
+        33, 33, 34, 34, 35, 35, 36, 36, 38, 39, 40, 42, 42, 45, 45, 49, 50, 52,
+        54, 56, 59, 60, 64, 65, 71, 71, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34,
+        35, 35, 36, 37, 38, 39, 40, 42, 43, 45, 45, 49, 49, 52, 54, 56, 59, 60,
+        64, 64, 70, 70, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 37, 37, 38, 38,
+        39, 40, 41, 42, 43, 46, 46, 49, 49, 52, 53, 55, 58, 59, 63, 63, 69, 69,
+        32, 32, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 38, 38, 40, 41, 41, 43,
+        43, 46, 46, 49, 50, 52, 54, 56, 58, 60, 63, 64, 70, 70, 34, 34, 34, 33,
+        33, 34, 35, 35, 37, 37, 39, 39, 42, 42, 44, 45, 46, 47, 48, 51, 51, 54,
+        54, 57, 58, 60, 63, 64, 68, 68, 74, 74, 34, 34, 34, 33, 33, 34, 35, 35,
+        37, 37, 39, 39, 42, 42, 44, 45, 46, 47, 48, 51, 51, 54, 54, 57, 58, 60,
+        63, 64, 68, 68, 74, 74, 35, 35, 35, 34, 34, 35, 36, 36, 38, 38, 42, 42,
+        46, 47, 48, 49, 50, 52, 53, 55, 55, 58, 59, 61, 62, 64, 67, 68, 72, 72,
+        78, 78, 36, 35, 35, 34, 34, 35, 36, 37, 38, 38, 42, 42, 47, 48, 50, 50,
+        52, 54, 54, 57, 57, 59, 60, 62, 64, 66, 68, 69, 73, 73, 79, 79, 38, 37,
+        37, 36, 36, 37, 38, 38, 39, 40, 44, 44, 48, 50, 51, 52, 54, 56, 57, 59,
+        59, 62, 63, 65, 67, 69, 71, 72, 76, 76, 82, 82, 39, 38, 38, 38, 37, 38,
+        39, 39, 40, 41, 45, 45, 49, 50, 52, 54, 55, 58, 58, 61, 61, 64, 65, 67,
+        69, 71, 73, 74, 78, 78, 84, 84, 41, 40, 40, 39, 38, 39, 40, 40, 41, 41,
+        46, 46, 50, 52, 54, 55, 57, 60, 60, 63, 63, 67, 67, 70, 71, 73, 75, 77,
+        80, 81, 86, 86, 44, 42, 42, 41, 41, 41, 42, 42, 42, 43, 47, 47, 52, 54,
+        56, 58, 60, 63, 64, 67, 67, 71, 71, 74, 75, 77, 79, 81, 84, 85, 90, 90,
+        45, 43, 43, 42, 41, 42, 42, 43, 43, 43, 48, 48, 53, 54, 57, 58, 60, 64,
+        65, 68, 68, 72, 72, 75, 76, 78, 81, 82, 85, 86, 91, 91, 48, 46, 46, 45,
+        44, 45, 45, 45, 46, 46, 51, 51, 55, 57, 59, 61, 63, 67, 68, 71, 71, 75,
+        76, 79, 80, 83, 85, 87, 90, 91, 96, 96, 48, 46, 46, 45, 44, 45, 45, 45,
+        46, 46, 51, 51, 55, 57, 59, 61, 63, 67, 68, 71, 71, 75, 76, 79, 80, 83,
+        85, 87, 90, 91, 96, 96, 53, 51, 51, 49, 49, 49, 49, 49, 49, 49, 54, 54,
+        58, 59, 62, 64, 67, 71, 72, 75, 75, 81, 81, 85, 86, 89, 91, 93, 97, 97,
+        103, 103, 54, 52, 51, 50, 49, 49, 50, 49, 49, 50, 54, 54, 59, 60, 63,
+        65, 67, 71, 72, 76, 76, 81, 82, 85, 87, 89, 92, 94, 97, 98, 104, 104,
+        57, 55, 55, 53, 52, 52, 52, 52, 52, 52, 57, 57, 61, 62, 65, 67, 70, 74,
+        75, 79, 79, 85, 85, 89, 90, 93, 96, 98, 102, 102, 108, 108, 59, 56, 56,
+        54, 54, 54, 54, 54, 53, 54, 58, 58, 62, 64, 67, 69, 71, 75, 76, 80, 80,
+        86, 87, 90, 92, 95, 98, 99, 103, 104, 110, 110, 62, 59, 59, 57, 56, 56,
+        56, 56, 55, 56, 60, 60, 64, 66, 69, 71, 73, 77, 78, 83, 83, 89, 89, 93,
+        95, 98, 101, 103, 107, 108, 114, 114, 65, 62, 62, 60, 59, 59, 59, 59,
+        58, 58, 63, 63, 67, 68, 71, 73, 75, 79, 81, 85, 85, 91, 92, 96, 98, 101,
+        105, 106, 111, 111, 118, 118, 67, 64, 64, 62, 61, 61, 60, 60, 59, 60,
+        64, 64, 68, 69, 72, 74, 77, 81, 82, 87, 87, 93, 94, 98, 99, 103, 106,
+        108, 113, 113, 120, 120, 71, 68, 68, 66, 65, 64, 64, 64, 63, 63, 68, 68,
+        72, 73, 76, 78, 80, 84, 85, 90, 90, 97, 97, 102, 103, 107, 111, 113,
+        117, 118, 125, 125, 72, 69, 69, 66, 65, 65, 65, 64, 63, 64, 68, 68, 72,
+        73, 76, 78, 81, 85, 86, 91, 91, 97, 98, 102, 104, 108, 111, 113, 118,
+        119, 126, 126, 80, 76, 76, 73, 72, 72, 71, 70, 69, 70, 74, 74, 78, 79,
+        82, 84, 86, 90, 91, 96, 96, 103, 104, 108, 110, 114, 118, 120, 125, 126,
+        134, 134, 80, 76, 76, 73, 72, 72, 71, 70, 69, 70, 74, 74, 78, 79, 82,
+        84, 86, 90, 91, 96, 96, 103, 104, 108, 110, 114, 118, 120, 125, 126,
+        134, 134,
         /* Size 4x8 */
-        64, 68, 87, 125, 65, 69, 84, 119, 66, 74, 88, 117, 70, 86, 109, 136, 83,
-        96, 128, 159, 99, 108, 143, 183, 115, 121, 157, 203, 133, 137, 172, 223,
+        32, 34, 43, 62, 32, 34, 42, 59, 33, 37, 44, 58, 35, 43, 54, 68, 41, 48,
+        64, 79, 49, 54, 71, 91, 57, 60, 78, 101, 66, 68, 86, 111,
         /* Size 8x4 */
-        64, 65, 66, 70, 83, 99, 115, 133, 68, 69, 74, 86, 96, 108, 121, 137, 87,
-        84, 88, 109, 128, 143, 157, 172, 125, 119, 117, 136, 159, 183, 203, 223,
+        32, 32, 33, 35, 41, 49, 57, 66, 34, 34, 37, 43, 48, 54, 60, 68, 43, 42,
+        44, 54, 64, 71, 78, 86, 62, 59, 58, 68, 79, 91, 101, 111,
         /* Size 8x16 */
-        64, 63, 64, 72, 88, 107, 125, 146, 63, 64, 65, 71, 85, 103, 119, 139,
-        63, 65, 66, 69, 82, 99, 114, 133, 64, 65, 68, 73, 84, 100, 114, 131, 64,
-        66, 71, 77, 85, 99, 112, 128, 68, 68, 74, 85, 96, 109, 122, 138, 71, 69,
-        76, 94, 105, 118, 130, 146, 76, 73, 80, 99, 112, 126, 139, 154, 82, 78,
-        83, 103, 120, 135, 148, 163, 89, 84, 87, 108, 128, 145, 158, 173, 96,
-        90, 93, 113, 134, 152, 167, 183, 107, 99, 100, 120, 142, 164, 180, 198,
-        117, 108, 108, 127, 150, 174, 191, 210, 130, 120, 117, 136, 159, 185,
-        204, 225, 142, 131, 127, 146, 169, 195, 216, 238, 159, 145, 140, 158,
-        181, 208, 230, 254,
+        32, 31, 32, 36, 44, 53, 62, 73, 31, 32, 32, 35, 42, 51, 59, 69, 31, 32,
+        33, 34, 41, 49, 57, 66, 32, 32, 34, 36, 42, 50, 57, 65, 32, 33, 35, 38,
+        42, 49, 56, 64, 34, 34, 37, 42, 48, 54, 61, 69, 35, 34, 38, 47, 52, 59,
+        65, 73, 38, 36, 40, 49, 56, 63, 69, 77, 41, 39, 41, 51, 60, 67, 74, 81,
+        44, 42, 43, 54, 64, 72, 79, 86, 48, 45, 46, 56, 67, 76, 83, 91, 53, 49,
+        50, 60, 71, 82, 90, 99, 58, 54, 54, 63, 75, 87, 95, 105, 65, 60, 58, 68,
+        79, 92, 102, 112, 71, 65, 63, 73, 84, 97, 108, 119, 79, 72, 70, 79, 90,
+        104, 115, 127,
         /* Size 16x8 */
-        64, 63, 63, 64, 64, 68, 71, 76, 82, 89, 96, 107, 117, 130, 142, 159, 63,
-        64, 65, 65, 66, 68, 69, 73, 78, 84, 90, 99, 108, 120, 131, 145, 64, 65,
-        66, 68, 71, 74, 76, 80, 83, 87, 93, 100, 108, 117, 127, 140, 72, 71, 69,
-        73, 77, 85, 94, 99, 103, 108, 113, 120, 127, 136, 146, 158, 88, 85, 82,
-        84, 85, 96, 105, 112, 120, 128, 134, 142, 150, 159, 169, 181, 107, 103,
-        99, 100, 99, 109, 118, 126, 135, 145, 152, 164, 174, 185, 195, 208, 125,
-        119, 114, 114, 112, 122, 130, 139, 148, 158, 167, 180, 191, 204, 216,
-        230, 146, 139, 133, 131, 128, 138, 146, 154, 163, 173, 183, 198, 210,
-        225, 238, 254,
+        32, 31, 31, 32, 32, 34, 35, 38, 41, 44, 48, 53, 58, 65, 71, 79, 31, 32,
+        32, 32, 33, 34, 34, 36, 39, 42, 45, 49, 54, 60, 65, 72, 32, 32, 33, 34,
+        35, 37, 38, 40, 41, 43, 46, 50, 54, 58, 63, 70, 36, 35, 34, 36, 38, 42,
+        47, 49, 51, 54, 56, 60, 63, 68, 73, 79, 44, 42, 41, 42, 42, 48, 52, 56,
+        60, 64, 67, 71, 75, 79, 84, 90, 53, 51, 49, 50, 49, 54, 59, 63, 67, 72,
+        76, 82, 87, 92, 97, 104, 62, 59, 57, 57, 56, 61, 65, 69, 74, 79, 83, 90,
+        95, 102, 108, 115, 73, 69, 66, 65, 64, 69, 73, 77, 81, 86, 91, 99, 105,
+        112, 119, 127,
         /* Size 16x32 */
-        64, 63, 63, 64, 64, 68, 72, 76, 88, 89, 107, 107, 125, 131, 146, 158,
-        63, 64, 64, 65, 65, 68, 71, 75, 85, 87, 103, 103, 120, 125, 140, 151,
-        63, 64, 64, 65, 65, 68, 71, 74, 85, 86, 103, 103, 119, 124, 139, 151,
-        63, 64, 64, 65, 65, 67, 70, 73, 83, 84, 100, 100, 116, 121, 134, 146,
-        63, 65, 65, 65, 66, 67, 69, 73, 82, 83, 99, 99, 114, 119, 133, 144, 63,
-        65, 65, 66, 67, 69, 71, 74, 83, 84, 99, 99, 114, 119, 132, 143, 64, 65,
-        65, 67, 68, 71, 73, 76, 84, 86, 100, 100, 114, 118, 131, 142, 64, 65,
-        65, 68, 69, 71, 74, 77, 85, 86, 99, 99, 113, 118, 130, 140, 64, 65, 66,
-        69, 71, 74, 77, 79, 85, 87, 99, 99, 112, 116, 128, 138, 64, 66, 66, 69,
-        71, 74, 78, 80, 86, 88, 100, 100, 113, 117, 129, 139, 68, 68, 68, 72,
-        74, 79, 85, 88, 96, 97, 109, 109, 122, 126, 138, 147, 68, 68, 68, 72,
-        74, 79, 85, 88, 96, 97, 109, 109, 122, 126, 138, 147, 71, 69, 69, 74,
-        76, 84, 94, 97, 105, 106, 118, 118, 130, 134, 146, 155, 72, 70, 69, 75,
-        77, 86, 96, 99, 108, 109, 120, 120, 133, 136, 148, 157, 76, 73, 73, 77,
-        80, 88, 99, 103, 112, 114, 126, 126, 139, 142, 154, 163, 79, 76, 75, 80,
-        81, 90, 101, 105, 116, 117, 130, 130, 143, 147, 159, 168, 82, 78, 78,
-        82, 83, 92, 103, 108, 120, 121, 135, 135, 148, 152, 163, 172, 88, 83,
-        82, 85, 86, 96, 107, 112, 126, 128, 143, 143, 156, 159, 171, 180, 89,
-        84, 84, 86, 87, 97, 108, 113, 128, 129, 145, 145, 158, 162, 173, 182,
-        96, 90, 90, 92, 93, 102, 113, 119, 134, 135, 152, 152, 167, 171, 183,
-        192, 96, 90, 90, 92, 93, 102, 113, 119, 134, 135, 152, 152, 167, 171,
-        183, 192, 106, 99, 98, 99, 99, 108, 119, 125, 142, 143, 163, 163, 179,
-        183, 196, 206, 107, 100, 99, 100, 100, 109, 120, 126, 142, 144, 164,
-        164, 180, 185, 198, 207, 114, 106, 105, 105, 105, 114, 125, 131, 148,
-        150, 171, 171, 188, 193, 206, 216, 117, 109, 108, 108, 108, 117, 127,
-        134, 150, 152, 174, 174, 191, 196, 210, 220, 123, 115, 114, 113, 112,
-        121, 132, 138, 155, 157, 179, 179, 197, 203, 217, 228, 130, 121, 120,
-        118, 117, 126, 136, 142, 159, 161, 185, 185, 204, 210, 225, 236, 134,
-        124, 123, 121, 120, 129, 139, 145, 162, 164, 188, 188, 207, 213, 228,
-        240, 142, 132, 131, 128, 127, 136, 146, 152, 169, 171, 195, 195, 216,
-        222, 238, 250, 144, 133, 132, 129, 128, 137, 147, 153, 170, 172, 196,
-        196, 217, 223, 239, 251, 159, 147, 145, 142, 140, 148, 158, 164, 181,
-        183, 208, 208, 230, 236, 254, 267, 159, 147, 145, 142, 140, 148, 158,
-        164, 181, 183, 208, 208, 230, 236, 254, 267,
+        32, 31, 31, 32, 32, 34, 36, 38, 44, 44, 53, 53, 62, 65, 73, 79, 31, 32,
+        32, 32, 32, 34, 35, 37, 42, 43, 51, 51, 60, 62, 70, 75, 31, 32, 32, 32,
+        32, 34, 35, 37, 42, 43, 51, 51, 59, 62, 69, 75, 31, 32, 32, 32, 32, 33,
+        35, 36, 41, 42, 50, 50, 58, 60, 67, 73, 31, 32, 32, 32, 33, 33, 34, 36,
+        41, 41, 49, 49, 57, 59, 66, 72, 31, 32, 32, 33, 33, 34, 35, 37, 41, 42,
+        49, 49, 57, 59, 66, 71, 32, 32, 32, 33, 34, 35, 36, 38, 42, 43, 50, 50,
+        57, 59, 65, 71, 32, 32, 32, 34, 34, 35, 37, 38, 42, 43, 49, 49, 56, 59,
+        65, 70, 32, 32, 33, 34, 35, 37, 38, 39, 42, 43, 49, 49, 56, 58, 64, 69,
+        32, 33, 33, 34, 35, 37, 39, 40, 43, 44, 50, 50, 56, 58, 64, 69, 34, 34,
+        34, 36, 37, 39, 42, 44, 48, 48, 54, 54, 61, 63, 69, 73, 34, 34, 34, 36,
+        37, 39, 42, 44, 48, 48, 54, 54, 61, 63, 69, 73, 35, 34, 34, 37, 38, 42,
+        47, 48, 52, 53, 59, 59, 65, 67, 73, 77, 36, 35, 34, 37, 38, 43, 48, 49,
+        54, 54, 60, 60, 66, 68, 74, 78, 38, 36, 36, 38, 40, 44, 49, 51, 56, 57,
+        63, 63, 69, 71, 77, 81, 39, 38, 37, 40, 40, 45, 50, 52, 58, 58, 65, 65,
+        71, 73, 79, 84, 41, 39, 39, 41, 41, 46, 51, 54, 60, 60, 67, 67, 74, 76,
+        81, 86, 44, 41, 41, 42, 43, 48, 53, 56, 63, 64, 71, 71, 78, 79, 85, 90,
+        44, 42, 42, 43, 43, 48, 54, 56, 64, 64, 72, 72, 79, 81, 86, 91, 48, 45,
+        45, 46, 46, 51, 56, 59, 67, 67, 76, 76, 83, 85, 91, 96, 48, 45, 45, 46,
+        46, 51, 56, 59, 67, 67, 76, 76, 83, 85, 91, 96, 53, 49, 49, 49, 49, 54,
+        59, 62, 71, 71, 81, 81, 89, 91, 98, 103, 53, 50, 49, 50, 50, 54, 60, 63,
+        71, 72, 82, 82, 90, 92, 99, 103, 57, 53, 52, 52, 52, 57, 62, 65, 74, 75,
+        85, 85, 94, 96, 103, 108, 58, 54, 54, 54, 54, 58, 63, 67, 75, 76, 87,
+        87, 95, 98, 105, 110, 61, 57, 57, 56, 56, 60, 66, 69, 77, 78, 89, 89,
+        98, 101, 108, 114, 65, 60, 60, 59, 58, 63, 68, 71, 79, 80, 92, 92, 102,
+        105, 112, 118, 67, 62, 61, 60, 60, 64, 69, 72, 81, 82, 94, 94, 103, 106,
+        114, 120, 71, 66, 65, 64, 63, 68, 73, 76, 84, 85, 97, 97, 108, 111, 119,
+        125, 72, 66, 66, 64, 64, 68, 73, 76, 85, 86, 98, 98, 108, 111, 119, 125,
+        79, 73, 72, 71, 70, 74, 79, 82, 90, 91, 104, 104, 115, 118, 127, 133,
+        79, 73, 72, 71, 70, 74, 79, 82, 90, 91, 104, 104, 115, 118, 127, 133,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 64, 64, 64, 64, 68, 68, 71, 72, 76, 79, 82, 88,
-        89, 96, 96, 106, 107, 114, 117, 123, 130, 134, 142, 144, 159, 159, 63,
-        64, 64, 64, 65, 65, 65, 65, 65, 66, 68, 68, 69, 70, 73, 76, 78, 83, 84,
-        90, 90, 99, 100, 106, 109, 115, 121, 124, 132, 133, 147, 147, 63, 64,
-        64, 64, 65, 65, 65, 65, 66, 66, 68, 68, 69, 69, 73, 75, 78, 82, 84, 90,
-        90, 98, 99, 105, 108, 114, 120, 123, 131, 132, 145, 145, 64, 65, 65, 65,
-        65, 66, 67, 68, 69, 69, 72, 72, 74, 75, 77, 80, 82, 85, 86, 92, 92, 99,
-        100, 105, 108, 113, 118, 121, 128, 129, 142, 142, 64, 65, 65, 65, 66,
-        67, 68, 69, 71, 71, 74, 74, 76, 77, 80, 81, 83, 86, 87, 93, 93, 99, 100,
-        105, 108, 112, 117, 120, 127, 128, 140, 140, 68, 68, 68, 67, 67, 69, 71,
-        71, 74, 74, 79, 79, 84, 86, 88, 90, 92, 96, 97, 102, 102, 108, 109, 114,
-        117, 121, 126, 129, 136, 137, 148, 148, 72, 71, 71, 70, 69, 71, 73, 74,
-        77, 78, 85, 85, 94, 96, 99, 101, 103, 107, 108, 113, 113, 119, 120, 125,
-        127, 132, 136, 139, 146, 147, 158, 158, 76, 75, 74, 73, 73, 74, 76, 77,
-        79, 80, 88, 88, 97, 99, 103, 105, 108, 112, 113, 119, 119, 125, 126,
-        131, 134, 138, 142, 145, 152, 153, 164, 164, 88, 85, 85, 83, 82, 83, 84,
-        85, 85, 86, 96, 96, 105, 108, 112, 116, 120, 126, 128, 134, 134, 142,
-        142, 148, 150, 155, 159, 162, 169, 170, 181, 181, 89, 87, 86, 84, 83,
-        84, 86, 86, 87, 88, 97, 97, 106, 109, 114, 117, 121, 128, 129, 135, 135,
-        143, 144, 150, 152, 157, 161, 164, 171, 172, 183, 183, 107, 103, 103,
-        100, 99, 99, 100, 99, 99, 100, 109, 109, 118, 120, 126, 130, 135, 143,
-        145, 152, 152, 163, 164, 171, 174, 179, 185, 188, 195, 196, 208, 208,
-        107, 103, 103, 100, 99, 99, 100, 99, 99, 100, 109, 109, 118, 120, 126,
-        130, 135, 143, 145, 152, 152, 163, 164, 171, 174, 179, 185, 188, 195,
-        196, 208, 208, 125, 120, 119, 116, 114, 114, 114, 113, 112, 113, 122,
-        122, 130, 133, 139, 143, 148, 156, 158, 167, 167, 179, 180, 188, 191,
-        197, 204, 207, 216, 217, 230, 230, 131, 125, 124, 121, 119, 119, 118,
-        118, 116, 117, 126, 126, 134, 136, 142, 147, 152, 159, 162, 171, 171,
-        183, 185, 193, 196, 203, 210, 213, 222, 223, 236, 236, 146, 140, 139,
-        134, 133, 132, 131, 130, 128, 129, 138, 138, 146, 148, 154, 159, 163,
-        171, 173, 183, 183, 196, 198, 206, 210, 217, 225, 228, 238, 239, 254,
-        254, 158, 151, 151, 146, 144, 143, 142, 140, 138, 139, 147, 147, 155,
-        157, 163, 168, 172, 180, 182, 192, 192, 206, 207, 216, 220, 228, 236,
-        240, 250, 251, 267, 267,
+        32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 34, 35, 36, 38, 39, 41, 44,
+        44, 48, 48, 53, 53, 57, 58, 61, 65, 67, 71, 72, 79, 79, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 34, 34, 34, 35, 36, 38, 39, 41, 42, 45, 45, 49,
+        50, 53, 54, 57, 60, 62, 66, 66, 73, 73, 31, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 34, 34, 34, 34, 36, 37, 39, 41, 42, 45, 45, 49, 49, 52, 54, 57,
+        60, 61, 65, 66, 72, 72, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 36, 36,
+        37, 37, 38, 40, 41, 42, 43, 46, 46, 49, 50, 52, 54, 56, 59, 60, 64, 64,
+        71, 71, 32, 32, 32, 32, 33, 33, 34, 34, 35, 35, 37, 37, 38, 38, 40, 40,
+        41, 43, 43, 46, 46, 49, 50, 52, 54, 56, 58, 60, 63, 64, 70, 70, 34, 34,
+        34, 33, 33, 34, 35, 35, 37, 37, 39, 39, 42, 43, 44, 45, 46, 48, 48, 51,
+        51, 54, 54, 57, 58, 60, 63, 64, 68, 68, 74, 74, 36, 35, 35, 35, 34, 35,
+        36, 37, 38, 39, 42, 42, 47, 48, 49, 50, 51, 53, 54, 56, 56, 59, 60, 62,
+        63, 66, 68, 69, 73, 73, 79, 79, 38, 37, 37, 36, 36, 37, 38, 38, 39, 40,
+        44, 44, 48, 49, 51, 52, 54, 56, 56, 59, 59, 62, 63, 65, 67, 69, 71, 72,
+        76, 76, 82, 82, 44, 42, 42, 41, 41, 41, 42, 42, 42, 43, 48, 48, 52, 54,
+        56, 58, 60, 63, 64, 67, 67, 71, 71, 74, 75, 77, 79, 81, 84, 85, 90, 90,
+        44, 43, 43, 42, 41, 42, 43, 43, 43, 44, 48, 48, 53, 54, 57, 58, 60, 64,
+        64, 67, 67, 71, 72, 75, 76, 78, 80, 82, 85, 86, 91, 91, 53, 51, 51, 50,
+        49, 49, 50, 49, 49, 50, 54, 54, 59, 60, 63, 65, 67, 71, 72, 76, 76, 81,
+        82, 85, 87, 89, 92, 94, 97, 98, 104, 104, 53, 51, 51, 50, 49, 49, 50,
+        49, 49, 50, 54, 54, 59, 60, 63, 65, 67, 71, 72, 76, 76, 81, 82, 85, 87,
+        89, 92, 94, 97, 98, 104, 104, 62, 60, 59, 58, 57, 57, 57, 56, 56, 56,
+        61, 61, 65, 66, 69, 71, 74, 78, 79, 83, 83, 89, 90, 94, 95, 98, 102,
+        103, 108, 108, 115, 115, 65, 62, 62, 60, 59, 59, 59, 59, 58, 58, 63, 63,
+        67, 68, 71, 73, 76, 79, 81, 85, 85, 91, 92, 96, 98, 101, 105, 106, 111,
+        111, 118, 118, 73, 70, 69, 67, 66, 66, 65, 65, 64, 64, 69, 69, 73, 74,
+        77, 79, 81, 85, 86, 91, 91, 98, 99, 103, 105, 108, 112, 114, 119, 119,
+        127, 127, 79, 75, 75, 73, 72, 71, 71, 70, 69, 69, 73, 73, 77, 78, 81,
+        84, 86, 90, 91, 96, 96, 103, 103, 108, 110, 114, 118, 120, 125, 125,
+        133, 133,
         /* Size 4x16 */
-        63, 68, 89, 131, 64, 68, 86, 124, 65, 67, 83, 119, 65, 71, 86, 118, 65,
-        74, 87, 116, 68, 79, 97, 126, 69, 84, 106, 134, 73, 88, 114, 142, 78,
-        92, 121, 152, 84, 97, 129, 162, 90, 102, 135, 171, 100, 109, 144, 185,
-        109, 117, 152, 196, 121, 126, 161, 210, 132, 136, 171, 222, 147, 148,
-        183, 236,
+        31, 34, 44, 65, 32, 34, 43, 62, 32, 33, 41, 59, 32, 35, 43, 59, 32, 37,
+        43, 58, 34, 39, 48, 63, 34, 42, 53, 67, 36, 44, 57, 71, 39, 46, 60, 76,
+        42, 48, 64, 81, 45, 51, 67, 85, 50, 54, 72, 92, 54, 58, 76, 98, 60, 63,
+        80, 105, 66, 68, 85, 111, 73, 74, 91, 118,
         /* Size 16x4 */
-        63, 64, 65, 65, 65, 68, 69, 73, 78, 84, 90, 100, 109, 121, 132, 147, 68,
-        68, 67, 71, 74, 79, 84, 88, 92, 97, 102, 109, 117, 126, 136, 148, 89,
-        86, 83, 86, 87, 97, 106, 114, 121, 129, 135, 144, 152, 161, 171, 183,
-        131, 124, 119, 118, 116, 126, 134, 142, 152, 162, 171, 185, 196, 210,
-        222, 236,
+        31, 32, 32, 32, 32, 34, 34, 36, 39, 42, 45, 50, 54, 60, 66, 73, 34, 34,
+        33, 35, 37, 39, 42, 44, 46, 48, 51, 54, 58, 63, 68, 74, 44, 43, 41, 43,
+        43, 48, 53, 57, 60, 64, 67, 72, 76, 80, 85, 91, 65, 62, 59, 59, 58, 63,
+        67, 71, 76, 81, 85, 92, 98, 105, 111, 118,
         /* Size 8x32 */
-        64, 63, 64, 72, 88, 107, 125, 146, 63, 64, 65, 71, 85, 103, 120, 140,
-        63, 64, 65, 71, 85, 103, 119, 139, 63, 64, 65, 70, 83, 100, 116, 134,
-        63, 65, 66, 69, 82, 99, 114, 133, 63, 65, 67, 71, 83, 99, 114, 132, 64,
-        65, 68, 73, 84, 100, 114, 131, 64, 65, 69, 74, 85, 99, 113, 130, 64, 66,
-        71, 77, 85, 99, 112, 128, 64, 66, 71, 78, 86, 100, 113, 129, 68, 68, 74,
-        85, 96, 109, 122, 138, 68, 68, 74, 85, 96, 109, 122, 138, 71, 69, 76,
-        94, 105, 118, 130, 146, 72, 69, 77, 96, 108, 120, 133, 148, 76, 73, 80,
-        99, 112, 126, 139, 154, 79, 75, 81, 101, 116, 130, 143, 159, 82, 78, 83,
-        103, 120, 135, 148, 163, 88, 82, 86, 107, 126, 143, 156, 171, 89, 84,
-        87, 108, 128, 145, 158, 173, 96, 90, 93, 113, 134, 152, 167, 183, 96,
-        90, 93, 113, 134, 152, 167, 183, 106, 98, 99, 119, 142, 163, 179, 196,
-        107, 99, 100, 120, 142, 164, 180, 198, 114, 105, 105, 125, 148, 171,
-        188, 206, 117, 108, 108, 127, 150, 174, 191, 210, 123, 114, 112, 132,
-        155, 179, 197, 217, 130, 120, 117, 136, 159, 185, 204, 225, 134, 123,
-        120, 139, 162, 188, 207, 228, 142, 131, 127, 146, 169, 195, 216, 238,
-        144, 132, 128, 147, 170, 196, 217, 239, 159, 145, 140, 158, 181, 208,
-        230, 254, 159, 145, 140, 158, 181, 208, 230, 254,
+        32, 31, 32, 36, 44, 53, 62, 73, 31, 32, 32, 35, 42, 51, 60, 70, 31, 32,
+        32, 35, 42, 51, 59, 69, 31, 32, 32, 35, 41, 50, 58, 67, 31, 32, 33, 34,
+        41, 49, 57, 66, 31, 32, 33, 35, 41, 49, 57, 66, 32, 32, 34, 36, 42, 50,
+        57, 65, 32, 32, 34, 37, 42, 49, 56, 65, 32, 33, 35, 38, 42, 49, 56, 64,
+        32, 33, 35, 39, 43, 50, 56, 64, 34, 34, 37, 42, 48, 54, 61, 69, 34, 34,
+        37, 42, 48, 54, 61, 69, 35, 34, 38, 47, 52, 59, 65, 73, 36, 34, 38, 48,
+        54, 60, 66, 74, 38, 36, 40, 49, 56, 63, 69, 77, 39, 37, 40, 50, 58, 65,
+        71, 79, 41, 39, 41, 51, 60, 67, 74, 81, 44, 41, 43, 53, 63, 71, 78, 85,
+        44, 42, 43, 54, 64, 72, 79, 86, 48, 45, 46, 56, 67, 76, 83, 91, 48, 45,
+        46, 56, 67, 76, 83, 91, 53, 49, 49, 59, 71, 81, 89, 98, 53, 49, 50, 60,
+        71, 82, 90, 99, 57, 52, 52, 62, 74, 85, 94, 103, 58, 54, 54, 63, 75, 87,
+        95, 105, 61, 57, 56, 66, 77, 89, 98, 108, 65, 60, 58, 68, 79, 92, 102,
+        112, 67, 61, 60, 69, 81, 94, 103, 114, 71, 65, 63, 73, 84, 97, 108, 119,
+        72, 66, 64, 73, 85, 98, 108, 119, 79, 72, 70, 79, 90, 104, 115, 127, 79,
+        72, 70, 79, 90, 104, 115, 127,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 64, 64, 64, 64, 68, 68, 71, 72, 76, 79, 82, 88,
-        89, 96, 96, 106, 107, 114, 117, 123, 130, 134, 142, 144, 159, 159, 63,
-        64, 64, 64, 65, 65, 65, 65, 66, 66, 68, 68, 69, 69, 73, 75, 78, 82, 84,
-        90, 90, 98, 99, 105, 108, 114, 120, 123, 131, 132, 145, 145, 64, 65, 65,
-        65, 66, 67, 68, 69, 71, 71, 74, 74, 76, 77, 80, 81, 83, 86, 87, 93, 93,
-        99, 100, 105, 108, 112, 117, 120, 127, 128, 140, 140, 72, 71, 71, 70,
-        69, 71, 73, 74, 77, 78, 85, 85, 94, 96, 99, 101, 103, 107, 108, 113,
-        113, 119, 120, 125, 127, 132, 136, 139, 146, 147, 158, 158, 88, 85, 85,
-        83, 82, 83, 84, 85, 85, 86, 96, 96, 105, 108, 112, 116, 120, 126, 128,
-        134, 134, 142, 142, 148, 150, 155, 159, 162, 169, 170, 181, 181, 107,
-        103, 103, 100, 99, 99, 100, 99, 99, 100, 109, 109, 118, 120, 126, 130,
-        135, 143, 145, 152, 152, 163, 164, 171, 174, 179, 185, 188, 195, 196,
-        208, 208, 125, 120, 119, 116, 114, 114, 114, 113, 112, 113, 122, 122,
-        130, 133, 139, 143, 148, 156, 158, 167, 167, 179, 180, 188, 191, 197,
-        204, 207, 216, 217, 230, 230, 146, 140, 139, 134, 133, 132, 131, 130,
-        128, 129, 138, 138, 146, 148, 154, 159, 163, 171, 173, 183, 183, 196,
-        198, 206, 210, 217, 225, 228, 238, 239, 254, 254 },
+        32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 34, 35, 36, 38, 39, 41, 44,
+        44, 48, 48, 53, 53, 57, 58, 61, 65, 67, 71, 72, 79, 79, 31, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 34, 34, 34, 34, 36, 37, 39, 41, 42, 45, 45, 49,
+        49, 52, 54, 57, 60, 61, 65, 66, 72, 72, 32, 32, 32, 32, 33, 33, 34, 34,
+        35, 35, 37, 37, 38, 38, 40, 40, 41, 43, 43, 46, 46, 49, 50, 52, 54, 56,
+        58, 60, 63, 64, 70, 70, 36, 35, 35, 35, 34, 35, 36, 37, 38, 39, 42, 42,
+        47, 48, 49, 50, 51, 53, 54, 56, 56, 59, 60, 62, 63, 66, 68, 69, 73, 73,
+        79, 79, 44, 42, 42, 41, 41, 41, 42, 42, 42, 43, 48, 48, 52, 54, 56, 58,
+        60, 63, 64, 67, 67, 71, 71, 74, 75, 77, 79, 81, 84, 85, 90, 90, 53, 51,
+        51, 50, 49, 49, 50, 49, 49, 50, 54, 54, 59, 60, 63, 65, 67, 71, 72, 76,
+        76, 81, 82, 85, 87, 89, 92, 94, 97, 98, 104, 104, 62, 60, 59, 58, 57,
+        57, 57, 56, 56, 56, 61, 61, 65, 66, 69, 71, 74, 78, 79, 83, 83, 89, 90,
+        94, 95, 98, 102, 103, 108, 108, 115, 115, 73, 70, 69, 67, 66, 66, 65,
+        65, 64, 64, 69, 69, 73, 74, 77, 79, 81, 85, 86, 91, 91, 98, 99, 103,
+        105, 108, 112, 114, 119, 119, 127, 127 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        83, 97, 97, 139,
+        41, 48, 48, 69,
 #endif
         /* Size 4x4 */
-        63, 85, 94, 107, 85, 97, 100, 108, 94, 100, 123, 135, 107, 108, 135,
-        156,
+        31, 42, 47, 53, 42, 48, 50, 54, 47, 50, 61, 67, 53, 54, 67, 78,
         /* Size 8x8 */
-        63, 65, 77, 96, 94, 100, 107, 115, 65, 71, 84, 94, 90, 95, 101, 109, 77,
-        84, 95, 96, 91, 94, 99, 105, 96, 94, 96, 106, 107, 109, 112, 117, 94,
-        90, 91, 107, 117, 122, 126, 131, 100, 95, 94, 109, 122, 132, 138, 145,
-        107, 101, 99, 112, 126, 138, 147, 155, 115, 109, 105, 117, 131, 145,
-        155, 165,
+        31, 32, 38, 48, 47, 50, 53, 57, 32, 35, 42, 47, 45, 47, 50, 54, 38, 42,
+        47, 48, 45, 47, 49, 52, 48, 47, 48, 53, 53, 54, 56, 58, 47, 45, 45, 53,
+        58, 61, 63, 65, 50, 47, 47, 54, 61, 66, 69, 72, 53, 50, 49, 56, 63, 69,
+        73, 77, 57, 54, 52, 58, 65, 72, 77, 82,
         /* Size 16x16 */
-        64, 62, 61, 67, 73, 83, 95, 98, 98, 99, 101, 104, 109, 114, 120, 127,
-        62, 63, 62, 69, 77, 85, 93, 95, 94, 94, 97, 100, 104, 109, 114, 121, 61,
-        62, 64, 71, 80, 85, 91, 92, 91, 91, 93, 95, 99, 104, 109, 115, 67, 69,
-        71, 78, 87, 90, 94, 93, 92, 91, 93, 95, 99, 102, 107, 113, 73, 77, 80,
-        87, 95, 95, 95, 94, 92, 91, 92, 94, 97, 100, 104, 109, 83, 85, 85, 90,
-        95, 97, 100, 100, 99, 99, 100, 101, 104, 107, 111, 115, 95, 93, 91, 94,
-        95, 100, 104, 105, 105, 105, 106, 107, 110, 112, 116, 120, 98, 95, 92,
-        93, 94, 100, 105, 107, 108, 110, 111, 112, 115, 117, 121, 125, 98, 94,
-        91, 92, 92, 99, 105, 108, 111, 114, 116, 118, 120, 123, 126, 130, 99,
-        94, 91, 91, 91, 99, 105, 110, 114, 118, 120, 123, 126, 129, 132, 136,
-        101, 97, 93, 93, 92, 100, 106, 111, 116, 120, 123, 127, 130, 134, 137,
-        142, 104, 100, 95, 95, 94, 101, 107, 112, 118, 123, 127, 133, 137, 141,
-        145, 150, 109, 104, 99, 99, 97, 104, 110, 115, 120, 126, 130, 137, 142,
-        147, 151, 156, 114, 109, 104, 102, 100, 107, 112, 117, 123, 129, 134,
-        141, 147, 153, 158, 164, 120, 114, 109, 107, 104, 111, 116, 121, 126,
-        132, 137, 145, 151, 158, 164, 170, 127, 121, 115, 113, 109, 115, 120,
-        125, 130, 136, 142, 150, 156, 164, 170, 178,
+        32, 31, 30, 33, 36, 41, 47, 49, 49, 49, 50, 52, 54, 57, 60, 63, 31, 31,
+        31, 34, 38, 42, 46, 47, 47, 47, 48, 50, 52, 54, 57, 60, 30, 31, 32, 35,
+        40, 42, 45, 46, 45, 45, 46, 47, 49, 52, 54, 57, 33, 34, 35, 39, 43, 45,
+        47, 46, 46, 45, 46, 47, 49, 51, 53, 56, 36, 38, 40, 43, 47, 47, 47, 47,
+        46, 45, 46, 47, 48, 50, 52, 54, 41, 42, 42, 45, 47, 48, 50, 50, 49, 49,
+        50, 50, 52, 53, 55, 57, 47, 46, 45, 47, 47, 50, 52, 52, 52, 52, 53, 53,
+        55, 56, 58, 60, 49, 47, 46, 46, 47, 50, 52, 53, 54, 55, 55, 56, 57, 58,
+        60, 62, 49, 47, 45, 46, 46, 49, 52, 54, 55, 57, 58, 59, 60, 61, 63, 65,
+        49, 47, 45, 45, 45, 49, 52, 55, 57, 59, 60, 61, 63, 64, 66, 68, 50, 48,
+        46, 46, 46, 50, 53, 55, 58, 60, 61, 63, 65, 67, 68, 71, 52, 50, 47, 47,
+        47, 50, 53, 56, 59, 61, 63, 66, 68, 70, 72, 75, 54, 52, 49, 49, 48, 52,
+        55, 57, 60, 63, 65, 68, 71, 73, 75, 78, 57, 54, 52, 51, 50, 53, 56, 58,
+        61, 64, 67, 70, 73, 76, 79, 82, 60, 57, 54, 53, 52, 55, 58, 60, 63, 66,
+        68, 72, 75, 79, 82, 85, 63, 60, 57, 56, 54, 57, 60, 62, 65, 68, 71, 75,
+        78, 82, 85, 89,
         /* Size 32x32 */
-        64, 62, 62, 61, 61, 64, 67, 69, 73, 74, 83, 83, 95, 98, 98, 97, 98, 98,
-        99, 101, 101, 104, 104, 108, 109, 112, 114, 116, 120, 121, 127, 127, 62,
-        63, 63, 62, 62, 65, 69, 71, 77, 77, 84, 84, 93, 96, 95, 94, 94, 94, 95,
-        97, 97, 100, 100, 103, 105, 107, 109, 111, 115, 115, 121, 121, 62, 63,
-        63, 63, 62, 66, 69, 71, 77, 78, 85, 85, 93, 95, 95, 94, 94, 94, 94, 97,
-        97, 99, 100, 103, 104, 106, 109, 110, 114, 115, 121, 121, 61, 62, 63,
-        63, 63, 67, 70, 73, 79, 80, 85, 85, 92, 94, 93, 92, 92, 91, 92, 94, 94,
-        96, 97, 100, 101, 103, 105, 107, 110, 111, 117, 117, 61, 62, 62, 63, 64,
-        67, 71, 73, 80, 80, 85, 85, 91, 93, 92, 91, 91, 90, 91, 93, 93, 95, 95,
-        98, 99, 102, 104, 105, 109, 109, 115, 115, 64, 65, 66, 67, 67, 71, 74,
-        77, 83, 84, 87, 87, 92, 94, 93, 92, 91, 90, 91, 93, 93, 95, 95, 98, 99,
-        101, 103, 104, 108, 109, 114, 114, 67, 69, 69, 70, 71, 74, 78, 80, 87,
-        87, 90, 90, 94, 95, 93, 93, 92, 91, 91, 93, 93, 95, 95, 98, 99, 100,
-        102, 104, 107, 108, 113, 113, 69, 71, 71, 73, 73, 77, 80, 83, 89, 89,
-        91, 91, 94, 95, 94, 93, 92, 91, 91, 93, 93, 94, 95, 97, 98, 100, 102,
-        103, 106, 107, 111, 111, 73, 77, 77, 79, 80, 83, 87, 89, 95, 95, 95, 95,
-        95, 96, 94, 93, 92, 91, 91, 92, 92, 93, 94, 96, 97, 98, 100, 101, 104,
-        105, 109, 109, 74, 77, 78, 80, 80, 84, 87, 89, 95, 95, 95, 95, 96, 96,
-        95, 94, 93, 91, 92, 93, 93, 94, 94, 96, 97, 99, 100, 102, 105, 105, 110,
-        110, 83, 84, 85, 85, 85, 87, 90, 91, 95, 95, 97, 97, 100, 101, 100, 99,
-        99, 98, 99, 100, 100, 101, 101, 103, 104, 105, 107, 108, 111, 111, 115,
-        115, 83, 84, 85, 85, 85, 87, 90, 91, 95, 95, 97, 97, 100, 101, 100, 99,
-        99, 98, 99, 100, 100, 101, 101, 103, 104, 105, 107, 108, 111, 111, 115,
-        115, 95, 93, 93, 92, 91, 92, 94, 94, 95, 96, 100, 100, 104, 105, 105,
-        105, 105, 105, 105, 106, 106, 107, 107, 109, 110, 111, 112, 113, 116,
-        116, 120, 120, 98, 96, 95, 94, 93, 94, 95, 95, 96, 96, 101, 101, 105,
-        106, 106, 106, 107, 107, 107, 108, 108, 109, 109, 110, 111, 112, 113,
-        114, 117, 117, 121, 121, 98, 95, 95, 93, 92, 93, 93, 94, 94, 95, 100,
-        100, 105, 106, 107, 108, 108, 110, 110, 111, 111, 112, 112, 114, 115,
-        116, 117, 118, 121, 121, 125, 125, 97, 94, 94, 92, 91, 92, 93, 93, 93,
-        94, 99, 99, 105, 106, 108, 109, 110, 111, 112, 113, 113, 115, 115, 117,
-        117, 119, 120, 121, 123, 124, 127, 127, 98, 94, 94, 92, 91, 91, 92, 92,
-        92, 93, 99, 99, 105, 107, 108, 110, 111, 114, 114, 116, 116, 118, 118,
-        120, 120, 122, 123, 124, 126, 127, 130, 130, 98, 94, 94, 91, 90, 90, 91,
-        91, 91, 91, 98, 98, 105, 107, 110, 111, 114, 117, 118, 120, 120, 122,
-        123, 124, 125, 126, 127, 128, 131, 131, 135, 135, 99, 95, 94, 92, 91,
-        91, 91, 91, 91, 92, 99, 99, 105, 107, 110, 112, 114, 118, 118, 120, 120,
-        123, 123, 125, 126, 127, 129, 130, 132, 133, 136, 136, 101, 97, 97, 94,
-        93, 93, 93, 93, 92, 93, 100, 100, 106, 108, 111, 113, 116, 120, 120,
-        123, 123, 127, 127, 130, 130, 132, 134, 135, 137, 138, 142, 142, 101,
-        97, 97, 94, 93, 93, 93, 93, 92, 93, 100, 100, 106, 108, 111, 113, 116,
-        120, 120, 123, 123, 127, 127, 130, 130, 132, 134, 135, 137, 138, 142,
-        142, 104, 100, 99, 96, 95, 95, 95, 94, 93, 94, 101, 101, 107, 109, 112,
-        115, 118, 122, 123, 127, 127, 132, 133, 135, 136, 138, 141, 142, 144,
-        145, 149, 149, 104, 100, 100, 97, 95, 95, 95, 95, 94, 94, 101, 101, 107,
-        109, 112, 115, 118, 123, 123, 127, 127, 133, 133, 136, 137, 139, 141,
-        142, 145, 146, 150, 150, 108, 103, 103, 100, 98, 98, 98, 97, 96, 96,
-        103, 103, 109, 110, 114, 117, 120, 124, 125, 130, 130, 135, 136, 139,
-        140, 143, 145, 146, 149, 150, 154, 154, 109, 105, 104, 101, 99, 99, 99,
-        98, 97, 97, 104, 104, 110, 111, 115, 117, 120, 125, 126, 130, 130, 136,
-        137, 140, 142, 144, 147, 148, 151, 152, 156, 156, 112, 107, 106, 103,
-        102, 101, 100, 100, 98, 99, 105, 105, 111, 112, 116, 119, 122, 126, 127,
-        132, 132, 138, 139, 143, 144, 147, 150, 151, 154, 155, 160, 160, 114,
-        109, 109, 105, 104, 103, 102, 102, 100, 100, 107, 107, 112, 113, 117,
-        120, 123, 127, 129, 134, 134, 141, 141, 145, 147, 150, 153, 155, 158,
-        159, 164, 164, 116, 111, 110, 107, 105, 104, 104, 103, 101, 102, 108,
-        108, 113, 114, 118, 121, 124, 128, 130, 135, 135, 142, 142, 146, 148,
-        151, 155, 156, 160, 160, 166, 166, 120, 115, 114, 110, 109, 108, 107,
-        106, 104, 105, 111, 111, 116, 117, 121, 123, 126, 131, 132, 137, 137,
-        144, 145, 149, 151, 154, 158, 160, 164, 164, 170, 170, 121, 115, 115,
-        111, 109, 109, 108, 107, 105, 105, 111, 111, 116, 117, 121, 124, 127,
-        131, 133, 138, 138, 145, 146, 150, 152, 155, 159, 160, 164, 165, 171,
-        171, 127, 121, 121, 117, 115, 114, 113, 111, 109, 110, 115, 115, 120,
-        121, 125, 127, 130, 135, 136, 142, 142, 149, 150, 154, 156, 160, 164,
-        166, 170, 171, 178, 178, 127, 121, 121, 117, 115, 114, 113, 111, 109,
-        110, 115, 115, 120, 121, 125, 127, 130, 135, 136, 142, 142, 149, 150,
-        154, 156, 160, 164, 166, 170, 171, 178, 178,
+        32, 31, 31, 30, 30, 32, 33, 34, 36, 37, 41, 41, 47, 49, 49, 48, 49, 49,
+        49, 50, 50, 52, 52, 54, 54, 56, 57, 58, 60, 60, 63, 63, 31, 31, 31, 31,
+        31, 32, 34, 35, 38, 38, 42, 42, 46, 48, 47, 47, 47, 47, 47, 48, 48, 50,
+        50, 51, 52, 53, 54, 55, 57, 57, 60, 60, 31, 31, 31, 31, 31, 33, 34, 35,
+        38, 39, 42, 42, 46, 47, 47, 47, 47, 47, 47, 48, 48, 49, 50, 51, 52, 53,
+        54, 55, 57, 57, 60, 60, 30, 31, 31, 31, 31, 33, 35, 36, 39, 40, 42, 42,
+        46, 47, 46, 46, 46, 45, 46, 47, 47, 48, 48, 50, 50, 51, 52, 53, 55, 55,
+        58, 58, 30, 31, 31, 31, 32, 33, 35, 36, 40, 40, 42, 42, 45, 46, 46, 45,
+        45, 45, 45, 46, 46, 47, 47, 49, 49, 51, 52, 52, 54, 54, 57, 57, 32, 32,
+        33, 33, 33, 35, 37, 38, 41, 42, 43, 43, 46, 47, 46, 46, 45, 45, 45, 46,
+        46, 47, 47, 49, 49, 50, 51, 52, 54, 54, 57, 57, 33, 34, 34, 35, 35, 37,
+        39, 40, 43, 43, 45, 45, 47, 47, 46, 46, 46, 45, 45, 46, 46, 47, 47, 49,
+        49, 50, 51, 52, 53, 54, 56, 56, 34, 35, 35, 36, 36, 38, 40, 41, 44, 44,
+        45, 45, 47, 47, 47, 46, 46, 45, 45, 46, 46, 47, 47, 48, 49, 50, 51, 51,
+        53, 53, 55, 55, 36, 38, 38, 39, 40, 41, 43, 44, 47, 47, 47, 47, 47, 48,
+        47, 46, 46, 45, 45, 46, 46, 46, 47, 48, 48, 49, 50, 50, 52, 52, 54, 54,
+        37, 38, 39, 40, 40, 42, 43, 44, 47, 47, 47, 47, 48, 48, 47, 47, 46, 45,
+        46, 46, 46, 47, 47, 48, 48, 49, 50, 51, 52, 52, 55, 55, 41, 42, 42, 42,
+        42, 43, 45, 45, 47, 47, 48, 48, 50, 50, 50, 49, 49, 49, 49, 50, 50, 50,
+        50, 51, 52, 52, 53, 54, 55, 55, 57, 57, 41, 42, 42, 42, 42, 43, 45, 45,
+        47, 47, 48, 48, 50, 50, 50, 49, 49, 49, 49, 50, 50, 50, 50, 51, 52, 52,
+        53, 54, 55, 55, 57, 57, 47, 46, 46, 46, 45, 46, 47, 47, 47, 48, 50, 50,
+        52, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 54, 55, 55, 56, 56, 58, 58,
+        60, 60, 49, 48, 47, 47, 46, 47, 47, 47, 48, 48, 50, 50, 52, 53, 53, 53,
+        53, 53, 53, 54, 54, 54, 54, 55, 55, 56, 56, 57, 58, 58, 60, 60, 49, 47,
+        47, 46, 46, 46, 46, 47, 47, 47, 50, 50, 52, 53, 53, 54, 54, 55, 55, 55,
+        55, 56, 56, 57, 57, 58, 58, 59, 60, 60, 62, 62, 48, 47, 47, 46, 45, 46,
+        46, 46, 46, 47, 49, 49, 52, 53, 54, 54, 55, 55, 56, 56, 56, 57, 57, 58,
+        58, 59, 60, 60, 61, 62, 63, 63, 49, 47, 47, 46, 45, 45, 46, 46, 46, 46,
+        49, 49, 52, 53, 54, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62,
+        63, 63, 65, 65, 49, 47, 47, 45, 45, 45, 45, 45, 45, 45, 49, 49, 52, 53,
+        55, 55, 57, 58, 59, 60, 60, 61, 61, 62, 62, 63, 63, 64, 65, 65, 67, 67,
+        49, 47, 47, 46, 45, 45, 45, 45, 45, 46, 49, 49, 52, 53, 55, 56, 57, 59,
+        59, 60, 60, 61, 61, 62, 63, 63, 64, 65, 66, 66, 68, 68, 50, 48, 48, 47,
+        46, 46, 46, 46, 46, 46, 50, 50, 53, 54, 55, 56, 58, 60, 60, 61, 61, 63,
+        63, 65, 65, 66, 67, 67, 68, 69, 71, 71, 50, 48, 48, 47, 46, 46, 46, 46,
+        46, 46, 50, 50, 53, 54, 55, 56, 58, 60, 60, 61, 61, 63, 63, 65, 65, 66,
+        67, 67, 68, 69, 71, 71, 52, 50, 49, 48, 47, 47, 47, 47, 46, 47, 50, 50,
+        53, 54, 56, 57, 59, 61, 61, 63, 63, 66, 66, 67, 68, 69, 70, 71, 72, 72,
+        74, 74, 52, 50, 50, 48, 47, 47, 47, 47, 47, 47, 50, 50, 53, 54, 56, 57,
+        59, 61, 61, 63, 63, 66, 66, 68, 68, 69, 70, 71, 72, 73, 75, 75, 54, 51,
+        51, 50, 49, 49, 49, 48, 48, 48, 51, 51, 54, 55, 57, 58, 60, 62, 62, 65,
+        65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 77, 77, 54, 52, 52, 50, 49, 49,
+        49, 49, 48, 48, 52, 52, 55, 55, 57, 58, 60, 62, 63, 65, 65, 68, 68, 70,
+        71, 72, 73, 74, 75, 76, 78, 78, 56, 53, 53, 51, 51, 50, 50, 50, 49, 49,
+        52, 52, 55, 56, 58, 59, 61, 63, 63, 66, 66, 69, 69, 71, 72, 73, 75, 75,
+        77, 77, 80, 80, 57, 54, 54, 52, 52, 51, 51, 51, 50, 50, 53, 53, 56, 56,
+        58, 60, 61, 63, 64, 67, 67, 70, 70, 72, 73, 75, 76, 77, 79, 79, 82, 82,
+        58, 55, 55, 53, 52, 52, 52, 51, 50, 51, 54, 54, 56, 57, 59, 60, 62, 64,
+        65, 67, 67, 71, 71, 73, 74, 75, 77, 78, 80, 80, 83, 83, 60, 57, 57, 55,
+        54, 54, 53, 53, 52, 52, 55, 55, 58, 58, 60, 61, 63, 65, 66, 68, 68, 72,
+        72, 74, 75, 77, 79, 80, 82, 82, 85, 85, 60, 57, 57, 55, 54, 54, 54, 53,
+        52, 52, 55, 55, 58, 58, 60, 62, 63, 65, 66, 69, 69, 72, 73, 75, 76, 77,
+        79, 80, 82, 82, 85, 85, 63, 60, 60, 58, 57, 57, 56, 55, 54, 55, 57, 57,
+        60, 60, 62, 63, 65, 67, 68, 71, 71, 74, 75, 77, 78, 80, 82, 83, 85, 85,
+        89, 89, 63, 60, 60, 58, 57, 57, 56, 55, 54, 55, 57, 57, 60, 60, 62, 63,
+        65, 67, 68, 71, 71, 74, 75, 77, 78, 80, 82, 83, 85, 85, 89, 89,
         /* Size 4x8 */
-        63, 85, 95, 109, 67, 88, 91, 103, 80, 95, 92, 101, 94, 101, 108, 114,
-        91, 99, 118, 128, 96, 101, 123, 141, 103, 105, 127, 150, 111, 111, 133,
-        159,
+        31, 42, 47, 54, 33, 44, 45, 51, 40, 47, 46, 50, 47, 50, 54, 57, 45, 49,
+        59, 64, 48, 50, 61, 70, 51, 52, 63, 75, 55, 55, 66, 79,
         /* Size 8x4 */
-        63, 67, 80, 94, 91, 96, 103, 111, 85, 88, 95, 101, 99, 101, 105, 111,
-        95, 91, 92, 108, 118, 123, 127, 133, 109, 103, 101, 114, 128, 141, 150,
-        159,
+        31, 33, 40, 47, 45, 48, 51, 55, 42, 44, 47, 50, 49, 50, 52, 55, 47, 45,
+        46, 54, 59, 61, 63, 66, 54, 51, 50, 57, 64, 70, 75, 79,
         /* Size 8x16 */
-        64, 62, 74, 96, 98, 105, 112, 122, 63, 63, 77, 94, 94, 100, 107, 115,
-        61, 64, 80, 92, 91, 96, 102, 110, 67, 72, 86, 94, 92, 95, 101, 108, 74,
-        80, 94, 95, 91, 94, 99, 105, 84, 86, 95, 100, 99, 101, 106, 112, 95, 92,
-        96, 105, 106, 107, 111, 117, 97, 92, 95, 106, 110, 113, 116, 122, 97,
-        91, 93, 106, 114, 118, 122, 127, 98, 91, 92, 107, 117, 124, 128, 133,
-        101, 93, 93, 108, 119, 128, 133, 139, 104, 96, 95, 109, 122, 133, 140,
-        146, 109, 100, 98, 111, 125, 137, 145, 152, 114, 104, 101, 113, 128,
-        141, 151, 159, 120, 109, 105, 117, 131, 145, 155, 165, 127, 115, 110,
-        121, 135, 150, 161, 172,
+        32, 31, 37, 48, 49, 52, 56, 61, 31, 31, 38, 47, 47, 50, 53, 57, 30, 32,
+        40, 46, 45, 48, 51, 55, 33, 36, 43, 47, 46, 47, 50, 54, 37, 40, 47, 47,
+        45, 47, 49, 52, 42, 43, 47, 50, 49, 50, 53, 56, 47, 46, 48, 52, 53, 53,
+        55, 58, 48, 46, 47, 53, 55, 56, 58, 61, 48, 45, 46, 53, 57, 59, 61, 63,
+        49, 45, 46, 53, 58, 62, 64, 66, 50, 46, 46, 54, 59, 64, 66, 69, 52, 48,
+        47, 54, 61, 66, 70, 73, 54, 50, 49, 55, 62, 68, 72, 76, 57, 52, 50, 56,
+        64, 70, 75, 79, 60, 54, 52, 58, 65, 72, 77, 82, 63, 57, 55, 60, 67, 75,
+        80, 86,
         /* Size 16x8 */
-        64, 63, 61, 67, 74, 84, 95, 97, 97, 98, 101, 104, 109, 114, 120, 127,
-        62, 63, 64, 72, 80, 86, 92, 92, 91, 91, 93, 96, 100, 104, 109, 115, 74,
-        77, 80, 86, 94, 95, 96, 95, 93, 92, 93, 95, 98, 101, 105, 110, 96, 94,
-        92, 94, 95, 100, 105, 106, 106, 107, 108, 109, 111, 113, 117, 121, 98,
-        94, 91, 92, 91, 99, 106, 110, 114, 117, 119, 122, 125, 128, 131, 135,
-        105, 100, 96, 95, 94, 101, 107, 113, 118, 124, 128, 133, 137, 141, 145,
-        150, 112, 107, 102, 101, 99, 106, 111, 116, 122, 128, 133, 140, 145,
-        151, 155, 161, 122, 115, 110, 108, 105, 112, 117, 122, 127, 133, 139,
-        146, 152, 159, 165, 172,
+        32, 31, 30, 33, 37, 42, 47, 48, 48, 49, 50, 52, 54, 57, 60, 63, 31, 31,
+        32, 36, 40, 43, 46, 46, 45, 45, 46, 48, 50, 52, 54, 57, 37, 38, 40, 43,
+        47, 47, 48, 47, 46, 46, 46, 47, 49, 50, 52, 55, 48, 47, 46, 47, 47, 50,
+        52, 53, 53, 53, 54, 54, 55, 56, 58, 60, 49, 47, 45, 46, 45, 49, 53, 55,
+        57, 58, 59, 61, 62, 64, 65, 67, 52, 50, 48, 47, 47, 50, 53, 56, 59, 62,
+        64, 66, 68, 70, 72, 75, 56, 53, 51, 50, 49, 53, 55, 58, 61, 64, 66, 70,
+        72, 75, 77, 80, 61, 57, 55, 54, 52, 56, 58, 61, 63, 66, 69, 73, 76, 79,
+        82, 86,
         /* Size 16x32 */
-        64, 62, 62, 70, 74, 84, 96, 97, 98, 99, 105, 105, 112, 115, 122, 127,
-        63, 63, 63, 72, 77, 85, 94, 95, 95, 95, 100, 100, 108, 109, 116, 121,
-        63, 63, 63, 72, 77, 85, 94, 94, 94, 95, 100, 100, 107, 109, 115, 120,
-        61, 64, 64, 74, 79, 85, 93, 92, 92, 92, 97, 97, 104, 105, 112, 116, 61,
-        64, 64, 74, 80, 85, 92, 92, 91, 91, 96, 96, 102, 104, 110, 115, 64, 67,
-        68, 78, 83, 88, 93, 92, 91, 91, 96, 96, 102, 103, 109, 114, 67, 71, 72,
-        81, 86, 90, 94, 93, 92, 92, 95, 95, 101, 103, 108, 112, 69, 74, 74, 84,
-        89, 91, 94, 94, 91, 92, 95, 95, 100, 102, 107, 111, 74, 80, 80, 90, 94,
-        95, 95, 94, 91, 92, 94, 94, 99, 100, 105, 109, 75, 80, 81, 90, 94, 95,
-        96, 95, 92, 92, 95, 95, 99, 101, 106, 110, 84, 86, 86, 92, 95, 97, 100,
-        100, 99, 99, 101, 101, 106, 107, 112, 115, 84, 86, 86, 92, 95, 97, 100,
-        100, 99, 99, 101, 101, 106, 107, 112, 115, 95, 92, 92, 95, 96, 100, 105,
-        105, 106, 106, 107, 107, 111, 112, 117, 120, 98, 94, 93, 95, 96, 101,
-        106, 106, 107, 108, 109, 109, 113, 114, 118, 121, 97, 93, 92, 94, 95,
-        100, 106, 107, 110, 110, 113, 113, 116, 117, 122, 125, 97, 92, 92, 93,
-        94, 100, 106, 108, 112, 112, 115, 115, 119, 120, 124, 128, 97, 92, 91,
-        92, 93, 99, 106, 108, 114, 114, 118, 118, 122, 123, 127, 130, 98, 91,
-        91, 91, 92, 99, 107, 110, 117, 118, 123, 123, 127, 128, 132, 135, 98,
-        92, 91, 92, 92, 99, 107, 110, 117, 118, 124, 124, 128, 129, 133, 136,
-        101, 94, 93, 93, 93, 100, 108, 111, 119, 120, 128, 128, 133, 134, 139,
-        142, 101, 94, 93, 93, 93, 100, 108, 111, 119, 120, 128, 128, 133, 134,
-        139, 142, 104, 96, 96, 95, 94, 101, 109, 112, 122, 123, 133, 133, 139,
-        141, 145, 149, 104, 97, 96, 95, 95, 101, 109, 112, 122, 123, 133, 133,
-        140, 142, 146, 150, 107, 100, 99, 97, 97, 103, 110, 114, 124, 125, 136,
-        136, 143, 145, 150, 154, 109, 101, 100, 98, 98, 104, 111, 115, 125, 126,
-        137, 137, 145, 147, 152, 156, 111, 103, 102, 100, 99, 105, 112, 116,
-        126, 127, 139, 139, 148, 150, 156, 160, 114, 105, 104, 102, 101, 107,
-        113, 117, 128, 129, 141, 141, 151, 153, 159, 164, 116, 107, 106, 103,
-        102, 108, 114, 118, 129, 130, 142, 142, 152, 155, 161, 166, 120, 110,
-        109, 106, 105, 111, 117, 121, 131, 132, 145, 145, 155, 158, 165, 170,
-        120, 111, 110, 107, 106, 111, 118, 121, 131, 133, 146, 146, 156, 159,
-        166, 171, 127, 117, 115, 112, 110, 116, 121, 125, 135, 136, 150, 150,
-        161, 164, 172, 178, 127, 117, 115, 112, 110, 116, 121, 125, 135, 136,
-        150, 150, 161, 164, 172, 178,
+        32, 31, 31, 35, 37, 42, 48, 48, 49, 49, 52, 52, 56, 57, 61, 63, 31, 31,
+        31, 36, 38, 42, 47, 47, 47, 47, 50, 50, 54, 54, 58, 60, 31, 31, 31, 36,
+        38, 42, 47, 47, 47, 47, 50, 50, 53, 54, 57, 60, 30, 32, 32, 37, 39, 42,
+        46, 46, 46, 46, 48, 48, 52, 52, 56, 58, 30, 32, 32, 37, 40, 42, 46, 46,
+        45, 45, 48, 48, 51, 52, 55, 57, 32, 33, 34, 39, 41, 44, 46, 46, 45, 45,
+        48, 48, 51, 51, 54, 57, 33, 35, 36, 40, 43, 45, 47, 46, 46, 46, 47, 47,
+        50, 51, 54, 56, 34, 37, 37, 42, 44, 45, 47, 47, 45, 46, 47, 47, 50, 51,
+        53, 55, 37, 40, 40, 45, 47, 47, 47, 47, 45, 46, 47, 47, 49, 50, 52, 54,
+        37, 40, 40, 45, 47, 47, 48, 47, 46, 46, 47, 47, 49, 50, 53, 55, 42, 43,
+        43, 46, 47, 48, 50, 50, 49, 49, 50, 50, 53, 53, 56, 57, 42, 43, 43, 46,
+        47, 48, 50, 50, 49, 49, 50, 50, 53, 53, 56, 57, 47, 46, 46, 47, 48, 50,
+        52, 52, 53, 53, 53, 53, 55, 56, 58, 60, 49, 47, 46, 47, 48, 50, 53, 53,
+        53, 54, 54, 54, 56, 57, 59, 60, 48, 46, 46, 47, 47, 50, 53, 53, 55, 55,
+        56, 56, 58, 58, 61, 62, 48, 46, 46, 46, 47, 50, 53, 54, 56, 56, 57, 57,
+        59, 60, 62, 64, 48, 46, 45, 46, 46, 49, 53, 54, 57, 57, 59, 59, 61, 61,
+        63, 65, 49, 45, 45, 45, 46, 49, 53, 55, 58, 59, 61, 61, 63, 64, 66, 67,
+        49, 46, 45, 46, 46, 49, 53, 55, 58, 59, 62, 62, 64, 64, 66, 68, 50, 47,
+        46, 46, 46, 50, 54, 55, 59, 60, 64, 64, 66, 67, 69, 71, 50, 47, 46, 46,
+        46, 50, 54, 55, 59, 60, 64, 64, 66, 67, 69, 71, 52, 48, 48, 47, 47, 50,
+        54, 56, 61, 61, 66, 66, 69, 70, 72, 74, 52, 48, 48, 47, 47, 50, 54, 56,
+        61, 61, 66, 66, 70, 71, 73, 75, 53, 50, 49, 48, 48, 51, 55, 57, 62, 62,
+        68, 68, 71, 72, 75, 77, 54, 50, 50, 49, 49, 52, 55, 57, 62, 63, 68, 68,
+        72, 73, 76, 78, 55, 51, 51, 50, 49, 52, 56, 58, 63, 63, 69, 69, 74, 75,
+        78, 80, 57, 52, 52, 51, 50, 53, 56, 58, 64, 64, 70, 70, 75, 76, 79, 82,
+        58, 53, 53, 51, 51, 54, 57, 59, 64, 65, 71, 71, 76, 77, 80, 83, 60, 55,
+        54, 53, 52, 55, 58, 60, 65, 66, 72, 72, 77, 79, 82, 85, 60, 55, 55, 53,
+        53, 55, 59, 60, 65, 66, 73, 73, 78, 79, 83, 85, 63, 58, 57, 56, 55, 58,
+        60, 62, 67, 68, 75, 75, 80, 82, 86, 89, 63, 58, 57, 56, 55, 58, 60, 62,
+        67, 68, 75, 75, 80, 82, 86, 89,
         /* Size 32x16 */
-        64, 63, 63, 61, 61, 64, 67, 69, 74, 75, 84, 84, 95, 98, 97, 97, 97, 98,
-        98, 101, 101, 104, 104, 107, 109, 111, 114, 116, 120, 120, 127, 127, 62,
-        63, 63, 64, 64, 67, 71, 74, 80, 80, 86, 86, 92, 94, 93, 92, 92, 91, 92,
-        94, 94, 96, 97, 100, 101, 103, 105, 107, 110, 111, 117, 117, 62, 63, 63,
-        64, 64, 68, 72, 74, 80, 81, 86, 86, 92, 93, 92, 92, 91, 91, 91, 93, 93,
-        96, 96, 99, 100, 102, 104, 106, 109, 110, 115, 115, 70, 72, 72, 74, 74,
-        78, 81, 84, 90, 90, 92, 92, 95, 95, 94, 93, 92, 91, 92, 93, 93, 95, 95,
-        97, 98, 100, 102, 103, 106, 107, 112, 112, 74, 77, 77, 79, 80, 83, 86,
-        89, 94, 94, 95, 95, 96, 96, 95, 94, 93, 92, 92, 93, 93, 94, 95, 97, 98,
-        99, 101, 102, 105, 106, 110, 110, 84, 85, 85, 85, 85, 88, 90, 91, 95,
-        95, 97, 97, 100, 101, 100, 100, 99, 99, 99, 100, 100, 101, 101, 103,
-        104, 105, 107, 108, 111, 111, 116, 116, 96, 94, 94, 93, 92, 93, 94, 94,
-        95, 96, 100, 100, 105, 106, 106, 106, 106, 107, 107, 108, 108, 109, 109,
-        110, 111, 112, 113, 114, 117, 118, 121, 121, 97, 95, 94, 92, 92, 92, 93,
-        94, 94, 95, 100, 100, 105, 106, 107, 108, 108, 110, 110, 111, 111, 112,
-        112, 114, 115, 116, 117, 118, 121, 121, 125, 125, 98, 95, 94, 92, 91,
-        91, 92, 91, 91, 92, 99, 99, 106, 107, 110, 112, 114, 117, 117, 119, 119,
-        122, 122, 124, 125, 126, 128, 129, 131, 131, 135, 135, 99, 95, 95, 92,
-        91, 91, 92, 92, 92, 92, 99, 99, 106, 108, 110, 112, 114, 118, 118, 120,
-        120, 123, 123, 125, 126, 127, 129, 130, 132, 133, 136, 136, 105, 100,
-        100, 97, 96, 96, 95, 95, 94, 95, 101, 101, 107, 109, 113, 115, 118, 123,
-        124, 128, 128, 133, 133, 136, 137, 139, 141, 142, 145, 146, 150, 150,
-        105, 100, 100, 97, 96, 96, 95, 95, 94, 95, 101, 101, 107, 109, 113, 115,
-        118, 123, 124, 128, 128, 133, 133, 136, 137, 139, 141, 142, 145, 146,
-        150, 150, 112, 108, 107, 104, 102, 102, 101, 100, 99, 99, 106, 106, 111,
-        113, 116, 119, 122, 127, 128, 133, 133, 139, 140, 143, 145, 148, 151,
-        152, 155, 156, 161, 161, 115, 109, 109, 105, 104, 103, 103, 102, 100,
-        101, 107, 107, 112, 114, 117, 120, 123, 128, 129, 134, 134, 141, 142,
-        145, 147, 150, 153, 155, 158, 159, 164, 164, 122, 116, 115, 112, 110,
-        109, 108, 107, 105, 106, 112, 112, 117, 118, 122, 124, 127, 132, 133,
-        139, 139, 145, 146, 150, 152, 156, 159, 161, 165, 166, 172, 172, 127,
-        121, 120, 116, 115, 114, 112, 111, 109, 110, 115, 115, 120, 121, 125,
-        128, 130, 135, 136, 142, 142, 149, 150, 154, 156, 160, 164, 166, 170,
-        171, 178, 178,
+        32, 31, 31, 30, 30, 32, 33, 34, 37, 37, 42, 42, 47, 49, 48, 48, 48, 49,
+        49, 50, 50, 52, 52, 53, 54, 55, 57, 58, 60, 60, 63, 63, 31, 31, 31, 32,
+        32, 33, 35, 37, 40, 40, 43, 43, 46, 47, 46, 46, 46, 45, 46, 47, 47, 48,
+        48, 50, 50, 51, 52, 53, 55, 55, 58, 58, 31, 31, 31, 32, 32, 34, 36, 37,
+        40, 40, 43, 43, 46, 46, 46, 46, 45, 45, 45, 46, 46, 48, 48, 49, 50, 51,
+        52, 53, 54, 55, 57, 57, 35, 36, 36, 37, 37, 39, 40, 42, 45, 45, 46, 46,
+        47, 47, 47, 46, 46, 45, 46, 46, 46, 47, 47, 48, 49, 50, 51, 51, 53, 53,
+        56, 56, 37, 38, 38, 39, 40, 41, 43, 44, 47, 47, 47, 47, 48, 48, 47, 47,
+        46, 46, 46, 46, 46, 47, 47, 48, 49, 49, 50, 51, 52, 53, 55, 55, 42, 42,
+        42, 42, 42, 44, 45, 45, 47, 47, 48, 48, 50, 50, 50, 50, 49, 49, 49, 50,
+        50, 50, 50, 51, 52, 52, 53, 54, 55, 55, 58, 58, 48, 47, 47, 46, 46, 46,
+        47, 47, 47, 48, 50, 50, 52, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 55,
+        55, 56, 56, 57, 58, 59, 60, 60, 48, 47, 47, 46, 46, 46, 46, 47, 47, 47,
+        50, 50, 52, 53, 53, 54, 54, 55, 55, 55, 55, 56, 56, 57, 57, 58, 58, 59,
+        60, 60, 62, 62, 49, 47, 47, 46, 45, 45, 46, 45, 45, 46, 49, 49, 53, 53,
+        55, 56, 57, 58, 58, 59, 59, 61, 61, 62, 62, 63, 64, 64, 65, 65, 67, 67,
+        49, 47, 47, 46, 45, 45, 46, 46, 46, 46, 49, 49, 53, 54, 55, 56, 57, 59,
+        59, 60, 60, 61, 61, 62, 63, 63, 64, 65, 66, 66, 68, 68, 52, 50, 50, 48,
+        48, 48, 47, 47, 47, 47, 50, 50, 53, 54, 56, 57, 59, 61, 62, 64, 64, 66,
+        66, 68, 68, 69, 70, 71, 72, 73, 75, 75, 52, 50, 50, 48, 48, 48, 47, 47,
+        47, 47, 50, 50, 53, 54, 56, 57, 59, 61, 62, 64, 64, 66, 66, 68, 68, 69,
+        70, 71, 72, 73, 75, 75, 56, 54, 53, 52, 51, 51, 50, 50, 49, 49, 53, 53,
+        55, 56, 58, 59, 61, 63, 64, 66, 66, 69, 70, 71, 72, 74, 75, 76, 77, 78,
+        80, 80, 57, 54, 54, 52, 52, 51, 51, 51, 50, 50, 53, 53, 56, 57, 58, 60,
+        61, 64, 64, 67, 67, 70, 71, 72, 73, 75, 76, 77, 79, 79, 82, 82, 61, 58,
+        57, 56, 55, 54, 54, 53, 52, 53, 56, 56, 58, 59, 61, 62, 63, 66, 66, 69,
+        69, 72, 73, 75, 76, 78, 79, 80, 82, 83, 86, 86, 63, 60, 60, 58, 57, 57,
+        56, 55, 54, 55, 57, 57, 60, 60, 62, 64, 65, 67, 68, 71, 71, 74, 75, 77,
+        78, 80, 82, 83, 85, 85, 89, 89,
         /* Size 4x16 */
-        62, 84, 99, 115, 63, 85, 95, 109, 64, 85, 91, 104, 71, 90, 92, 103, 80,
-        95, 92, 100, 86, 97, 99, 107, 92, 100, 106, 112, 93, 100, 110, 117, 92,
-        99, 114, 123, 92, 99, 118, 129, 94, 100, 120, 134, 97, 101, 123, 142,
-        101, 104, 126, 147, 105, 107, 129, 153, 110, 111, 132, 158, 117, 116,
-        136, 164,
+        31, 42, 49, 57, 31, 42, 47, 54, 32, 42, 45, 52, 35, 45, 46, 51, 40, 47,
+        46, 50, 43, 48, 49, 53, 46, 50, 53, 56, 46, 50, 55, 58, 46, 49, 57, 61,
+        46, 49, 59, 64, 47, 50, 60, 67, 48, 50, 61, 71, 50, 52, 63, 73, 52, 53,
+        64, 76, 55, 55, 66, 79, 58, 58, 68, 82,
         /* Size 16x4 */
-        62, 63, 64, 71, 80, 86, 92, 93, 92, 92, 94, 97, 101, 105, 110, 117, 84,
-        85, 85, 90, 95, 97, 100, 100, 99, 99, 100, 101, 104, 107, 111, 116, 99,
-        95, 91, 92, 92, 99, 106, 110, 114, 118, 120, 123, 126, 129, 132, 136,
-        115, 109, 104, 103, 100, 107, 112, 117, 123, 129, 134, 142, 147, 153,
-        158, 164,
+        31, 31, 32, 35, 40, 43, 46, 46, 46, 46, 47, 48, 50, 52, 55, 58, 42, 42,
+        42, 45, 47, 48, 50, 50, 49, 49, 50, 50, 52, 53, 55, 58, 49, 47, 45, 46,
+        46, 49, 53, 55, 57, 59, 60, 61, 63, 64, 66, 68, 57, 54, 52, 51, 50, 53,
+        56, 58, 61, 64, 67, 71, 73, 76, 79, 82,
         /* Size 8x32 */
-        64, 62, 74, 96, 98, 105, 112, 122, 63, 63, 77, 94, 95, 100, 108, 116,
-        63, 63, 77, 94, 94, 100, 107, 115, 61, 64, 79, 93, 92, 97, 104, 112, 61,
-        64, 80, 92, 91, 96, 102, 110, 64, 68, 83, 93, 91, 96, 102, 109, 67, 72,
-        86, 94, 92, 95, 101, 108, 69, 74, 89, 94, 91, 95, 100, 107, 74, 80, 94,
-        95, 91, 94, 99, 105, 75, 81, 94, 96, 92, 95, 99, 106, 84, 86, 95, 100,
-        99, 101, 106, 112, 84, 86, 95, 100, 99, 101, 106, 112, 95, 92, 96, 105,
-        106, 107, 111, 117, 98, 93, 96, 106, 107, 109, 113, 118, 97, 92, 95,
-        106, 110, 113, 116, 122, 97, 92, 94, 106, 112, 115, 119, 124, 97, 91,
-        93, 106, 114, 118, 122, 127, 98, 91, 92, 107, 117, 123, 127, 132, 98,
-        91, 92, 107, 117, 124, 128, 133, 101, 93, 93, 108, 119, 128, 133, 139,
-        101, 93, 93, 108, 119, 128, 133, 139, 104, 96, 94, 109, 122, 133, 139,
-        145, 104, 96, 95, 109, 122, 133, 140, 146, 107, 99, 97, 110, 124, 136,
-        143, 150, 109, 100, 98, 111, 125, 137, 145, 152, 111, 102, 99, 112, 126,
-        139, 148, 156, 114, 104, 101, 113, 128, 141, 151, 159, 116, 106, 102,
-        114, 129, 142, 152, 161, 120, 109, 105, 117, 131, 145, 155, 165, 120,
-        110, 106, 118, 131, 146, 156, 166, 127, 115, 110, 121, 135, 150, 161,
-        172, 127, 115, 110, 121, 135, 150, 161, 172,
+        32, 31, 37, 48, 49, 52, 56, 61, 31, 31, 38, 47, 47, 50, 54, 58, 31, 31,
+        38, 47, 47, 50, 53, 57, 30, 32, 39, 46, 46, 48, 52, 56, 30, 32, 40, 46,
+        45, 48, 51, 55, 32, 34, 41, 46, 45, 48, 51, 54, 33, 36, 43, 47, 46, 47,
+        50, 54, 34, 37, 44, 47, 45, 47, 50, 53, 37, 40, 47, 47, 45, 47, 49, 52,
+        37, 40, 47, 48, 46, 47, 49, 53, 42, 43, 47, 50, 49, 50, 53, 56, 42, 43,
+        47, 50, 49, 50, 53, 56, 47, 46, 48, 52, 53, 53, 55, 58, 49, 46, 48, 53,
+        53, 54, 56, 59, 48, 46, 47, 53, 55, 56, 58, 61, 48, 46, 47, 53, 56, 57,
+        59, 62, 48, 45, 46, 53, 57, 59, 61, 63, 49, 45, 46, 53, 58, 61, 63, 66,
+        49, 45, 46, 53, 58, 62, 64, 66, 50, 46, 46, 54, 59, 64, 66, 69, 50, 46,
+        46, 54, 59, 64, 66, 69, 52, 48, 47, 54, 61, 66, 69, 72, 52, 48, 47, 54,
+        61, 66, 70, 73, 53, 49, 48, 55, 62, 68, 71, 75, 54, 50, 49, 55, 62, 68,
+        72, 76, 55, 51, 49, 56, 63, 69, 74, 78, 57, 52, 50, 56, 64, 70, 75, 79,
+        58, 53, 51, 57, 64, 71, 76, 80, 60, 54, 52, 58, 65, 72, 77, 82, 60, 55,
+        53, 59, 65, 73, 78, 83, 63, 57, 55, 60, 67, 75, 80, 86, 63, 57, 55, 60,
+        67, 75, 80, 86,
         /* Size 32x8 */
-        64, 63, 63, 61, 61, 64, 67, 69, 74, 75, 84, 84, 95, 98, 97, 97, 97, 98,
-        98, 101, 101, 104, 104, 107, 109, 111, 114, 116, 120, 120, 127, 127, 62,
-        63, 63, 64, 64, 68, 72, 74, 80, 81, 86, 86, 92, 93, 92, 92, 91, 91, 91,
-        93, 93, 96, 96, 99, 100, 102, 104, 106, 109, 110, 115, 115, 74, 77, 77,
-        79, 80, 83, 86, 89, 94, 94, 95, 95, 96, 96, 95, 94, 93, 92, 92, 93, 93,
-        94, 95, 97, 98, 99, 101, 102, 105, 106, 110, 110, 96, 94, 94, 93, 92,
-        93, 94, 94, 95, 96, 100, 100, 105, 106, 106, 106, 106, 107, 107, 108,
-        108, 109, 109, 110, 111, 112, 113, 114, 117, 118, 121, 121, 98, 95, 94,
-        92, 91, 91, 92, 91, 91, 92, 99, 99, 106, 107, 110, 112, 114, 117, 117,
-        119, 119, 122, 122, 124, 125, 126, 128, 129, 131, 131, 135, 135, 105,
-        100, 100, 97, 96, 96, 95, 95, 94, 95, 101, 101, 107, 109, 113, 115, 118,
-        123, 124, 128, 128, 133, 133, 136, 137, 139, 141, 142, 145, 146, 150,
-        150, 112, 108, 107, 104, 102, 102, 101, 100, 99, 99, 106, 106, 111, 113,
-        116, 119, 122, 127, 128, 133, 133, 139, 140, 143, 145, 148, 151, 152,
-        155, 156, 161, 161, 122, 116, 115, 112, 110, 109, 108, 107, 105, 106,
-        112, 112, 117, 118, 122, 124, 127, 132, 133, 139, 139, 145, 146, 150,
-        152, 156, 159, 161, 165, 166, 172, 172 },
+        32, 31, 31, 30, 30, 32, 33, 34, 37, 37, 42, 42, 47, 49, 48, 48, 48, 49,
+        49, 50, 50, 52, 52, 53, 54, 55, 57, 58, 60, 60, 63, 63, 31, 31, 31, 32,
+        32, 34, 36, 37, 40, 40, 43, 43, 46, 46, 46, 46, 45, 45, 45, 46, 46, 48,
+        48, 49, 50, 51, 52, 53, 54, 55, 57, 57, 37, 38, 38, 39, 40, 41, 43, 44,
+        47, 47, 47, 47, 48, 48, 47, 47, 46, 46, 46, 46, 46, 47, 47, 48, 49, 49,
+        50, 51, 52, 53, 55, 55, 48, 47, 47, 46, 46, 46, 47, 47, 47, 48, 50, 50,
+        52, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 56, 56, 57, 58, 59,
+        60, 60, 49, 47, 47, 46, 45, 45, 46, 45, 45, 46, 49, 49, 53, 53, 55, 56,
+        57, 58, 58, 59, 59, 61, 61, 62, 62, 63, 64, 64, 65, 65, 67, 67, 52, 50,
+        50, 48, 48, 48, 47, 47, 47, 47, 50, 50, 53, 54, 56, 57, 59, 61, 62, 64,
+        64, 66, 66, 68, 68, 69, 70, 71, 72, 73, 75, 75, 56, 54, 53, 52, 51, 51,
+        50, 50, 49, 49, 53, 53, 55, 56, 58, 59, 61, 63, 64, 66, 66, 69, 70, 71,
+        72, 74, 75, 76, 77, 78, 80, 80, 61, 58, 57, 56, 55, 54, 54, 53, 52, 53,
+        56, 56, 58, 59, 61, 62, 63, 66, 66, 69, 69, 72, 73, 75, 76, 78, 79, 80,
+        82, 83, 86, 86 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        67, 94, 94, 150,
+        33, 47, 47, 75,
 #endif
         /* Size 4x4 */
-        64, 67, 84, 111, 67, 77, 93, 115, 84, 93, 127, 151, 111, 115, 151, 184,
+        32, 33, 42, 55, 33, 38, 46, 57, 42, 46, 63, 75, 55, 57, 75, 92,
         /* Size 8x8 */
-        63, 64, 64, 69, 77, 92, 104, 126, 64, 65, 65, 68, 75, 88, 99, 119, 64,
-        65, 71, 75, 81, 90, 99, 116, 69, 68, 75, 85, 94, 105, 113, 130, 77, 75,
-        81, 94, 108, 121, 130, 147, 92, 88, 90, 105, 121, 139, 151, 168, 104,
-        99, 99, 113, 130, 151, 165, 185, 126, 119, 116, 130, 147, 168, 185, 210,
+        31, 32, 32, 34, 38, 46, 52, 63, 32, 32, 32, 34, 37, 44, 49, 59, 32, 32,
+        35, 37, 40, 45, 49, 58, 34, 34, 37, 42, 47, 52, 56, 65, 38, 37, 40, 47,
+        54, 60, 65, 73, 46, 44, 45, 52, 60, 69, 75, 84, 52, 49, 49, 56, 65, 75,
+        82, 92, 63, 59, 58, 65, 73, 84, 92, 105,
         /* Size 16x16 */
-        64, 63, 63, 63, 64, 64, 68, 72, 77, 82, 88, 97, 108, 116, 123, 131, 63,
-        64, 64, 64, 64, 65, 68, 70, 76, 80, 85, 93, 103, 111, 117, 125, 63, 64,
-        65, 65, 65, 65, 67, 69, 74, 77, 82, 89, 99, 106, 112, 119, 63, 64, 65,
-        66, 67, 67, 70, 72, 76, 80, 84, 91, 99, 106, 112, 119, 64, 64, 65, 67,
-        68, 69, 72, 74, 78, 81, 85, 91, 99, 106, 111, 118, 64, 65, 65, 67, 69,
-        71, 74, 77, 80, 83, 85, 92, 99, 105, 110, 116, 68, 68, 67, 70, 72, 74,
-        79, 85, 89, 92, 95, 102, 109, 115, 120, 126, 72, 70, 69, 72, 74, 77, 85,
-        97, 101, 104, 108, 114, 120, 126, 131, 136, 77, 76, 74, 76, 78, 80, 89,
-        101, 105, 109, 114, 121, 128, 134, 139, 144, 82, 80, 77, 80, 81, 83, 92,
-        104, 109, 114, 120, 127, 135, 141, 146, 151, 88, 85, 82, 84, 85, 85, 95,
-        108, 114, 120, 127, 134, 143, 149, 154, 159, 97, 93, 89, 91, 91, 92,
-        102, 114, 121, 127, 134, 142, 153, 159, 165, 171, 108, 103, 99, 99, 99,
-        99, 109, 120, 128, 135, 143, 153, 165, 172, 178, 185, 116, 111, 106,
-        106, 106, 105, 115, 126, 134, 141, 149, 159, 172, 180, 187, 194, 123,
-        117, 112, 112, 111, 110, 120, 131, 139, 146, 154, 165, 178, 187, 194,
-        202, 131, 125, 119, 119, 118, 116, 126, 136, 144, 151, 159, 171, 185,
-        194, 202, 210,
+        32, 31, 31, 31, 32, 32, 34, 36, 38, 41, 44, 48, 54, 58, 61, 65, 31, 32,
+        32, 32, 32, 32, 34, 35, 38, 40, 42, 46, 51, 55, 58, 62, 31, 32, 32, 32,
+        32, 32, 33, 34, 37, 38, 41, 44, 49, 53, 56, 59, 31, 32, 32, 33, 33, 33,
+        35, 36, 38, 40, 42, 45, 49, 53, 56, 59, 32, 32, 32, 33, 34, 34, 36, 37,
+        39, 40, 42, 45, 49, 53, 55, 59, 32, 32, 32, 33, 34, 35, 37, 38, 40, 41,
+        42, 46, 49, 52, 55, 58, 34, 34, 33, 35, 36, 37, 39, 42, 44, 46, 47, 51,
+        54, 57, 60, 63, 36, 35, 34, 36, 37, 38, 42, 48, 50, 52, 54, 57, 60, 63,
+        65, 68, 38, 38, 37, 38, 39, 40, 44, 50, 52, 54, 57, 60, 64, 67, 69, 72,
+        41, 40, 38, 40, 40, 41, 46, 52, 54, 57, 60, 63, 67, 70, 73, 75, 44, 42,
+        41, 42, 42, 42, 47, 54, 57, 60, 63, 67, 71, 74, 77, 79, 48, 46, 44, 45,
+        45, 46, 51, 57, 60, 63, 67, 71, 76, 79, 82, 85, 54, 51, 49, 49, 49, 49,
+        54, 60, 64, 67, 71, 76, 82, 86, 89, 92, 58, 55, 53, 53, 53, 52, 57, 63,
+        67, 70, 74, 79, 86, 90, 93, 97, 61, 58, 56, 56, 55, 55, 60, 65, 69, 73,
+        77, 82, 89, 93, 97, 101, 65, 62, 59, 59, 59, 58, 63, 68, 72, 75, 79, 85,
+        92, 97, 101, 105,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 67, 68, 69, 72, 72, 77, 79,
-        82, 88, 88, 95, 97, 101, 108, 108, 116, 118, 123, 131, 131, 140, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 67, 68, 69, 71, 71, 76, 77, 80, 85,
-        85, 92, 94, 98, 104, 104, 112, 114, 118, 126, 126, 135, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 65, 65, 67, 68, 69, 70, 70, 76, 77, 80, 85, 85, 91,
-        93, 97, 103, 103, 111, 113, 117, 125, 125, 134, 63, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 67, 68, 68, 70, 70, 75, 76, 79, 84, 84, 90, 91, 95,
-        101, 101, 109, 111, 115, 122, 122, 131, 63, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 67, 67, 68, 69, 69, 74, 75, 77, 82, 82, 88, 89, 93, 99, 99,
-        106, 108, 112, 119, 119, 128, 63, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 67, 67, 68, 69, 69, 74, 75, 77, 82, 82, 88, 89, 93, 99, 99, 106,
-        108, 112, 119, 119, 128, 63, 64, 64, 65, 65, 65, 66, 66, 67, 67, 67, 69,
-        70, 71, 72, 72, 76, 78, 80, 84, 84, 89, 91, 94, 99, 99, 106, 108, 112,
-        119, 119, 127, 63, 64, 64, 65, 65, 65, 66, 67, 67, 68, 68, 70, 71, 72,
-        73, 73, 77, 78, 81, 84, 84, 90, 91, 94, 100, 100, 106, 108, 112, 118,
-        118, 127, 64, 64, 64, 65, 65, 65, 67, 67, 68, 69, 69, 71, 72, 73, 74,
-        74, 78, 79, 81, 85, 85, 90, 91, 94, 99, 99, 106, 108, 111, 118, 118,
-        126, 64, 64, 65, 65, 65, 65, 67, 68, 69, 71, 71, 73, 74, 75, 77, 77, 80,
-        81, 83, 85, 85, 90, 92, 94, 99, 99, 105, 107, 110, 116, 116, 124, 64,
-        64, 65, 65, 65, 65, 67, 68, 69, 71, 71, 73, 74, 75, 77, 77, 80, 81, 83,
-        85, 85, 90, 92, 94, 99, 99, 105, 107, 110, 116, 116, 124, 67, 67, 67,
-        67, 67, 67, 69, 70, 71, 73, 73, 77, 78, 80, 84, 84, 87, 88, 90, 93, 93,
-        98, 100, 102, 107, 107, 113, 115, 118, 124, 124, 132, 68, 68, 68, 68,
-        67, 67, 70, 71, 72, 74, 74, 78, 79, 82, 85, 85, 89, 90, 92, 95, 95, 100,
-        102, 105, 109, 109, 115, 117, 120, 126, 126, 134, 69, 69, 69, 68, 68,
-        68, 71, 72, 73, 75, 75, 80, 82, 85, 90, 90, 93, 94, 97, 100, 100, 105,
-        106, 109, 113, 113, 119, 121, 124, 130, 130, 138, 72, 71, 70, 70, 69,
-        69, 72, 73, 74, 77, 77, 84, 85, 90, 97, 97, 101, 101, 104, 108, 108,
-        112, 114, 116, 120, 120, 126, 128, 131, 136, 136, 144, 72, 71, 70, 70,
-        69, 69, 72, 73, 74, 77, 77, 84, 85, 90, 97, 97, 101, 101, 104, 108, 108,
-        112, 114, 116, 120, 120, 126, 128, 131, 136, 136, 144, 77, 76, 76, 75,
-        74, 74, 76, 77, 78, 80, 80, 87, 89, 93, 101, 101, 105, 106, 109, 114,
-        114, 119, 121, 123, 128, 128, 134, 136, 139, 144, 144, 152, 79, 77, 77,
-        76, 75, 75, 78, 78, 79, 81, 81, 88, 90, 94, 101, 101, 106, 108, 111,
-        116, 116, 121, 122, 125, 130, 130, 136, 138, 141, 147, 147, 154, 82, 80,
-        80, 79, 77, 77, 80, 81, 81, 83, 83, 90, 92, 97, 104, 104, 109, 111, 114,
-        120, 120, 125, 127, 130, 135, 135, 141, 143, 146, 151, 151, 159, 88, 85,
-        85, 84, 82, 82, 84, 84, 85, 85, 85, 93, 95, 100, 108, 108, 114, 116,
-        120, 127, 127, 133, 134, 137, 143, 143, 149, 151, 154, 159, 159, 167,
-        88, 85, 85, 84, 82, 82, 84, 84, 85, 85, 85, 93, 95, 100, 108, 108, 114,
-        116, 120, 127, 127, 133, 134, 137, 143, 143, 149, 151, 154, 159, 159,
-        167, 95, 92, 91, 90, 88, 88, 89, 90, 90, 90, 90, 98, 100, 105, 112, 112,
-        119, 121, 125, 133, 133, 139, 141, 144, 151, 151, 157, 159, 163, 168,
-        168, 176, 97, 94, 93, 91, 89, 89, 91, 91, 91, 92, 92, 100, 102, 106,
-        114, 114, 121, 122, 127, 134, 134, 141, 142, 146, 153, 153, 159, 161,
-        165, 171, 171, 179, 101, 98, 97, 95, 93, 93, 94, 94, 94, 94, 94, 102,
-        105, 109, 116, 116, 123, 125, 130, 137, 137, 144, 146, 150, 157, 157,
-        164, 166, 170, 176, 176, 184, 108, 104, 103, 101, 99, 99, 99, 100, 99,
-        99, 99, 107, 109, 113, 120, 120, 128, 130, 135, 143, 143, 151, 153, 157,
-        165, 165, 172, 174, 178, 185, 185, 193, 108, 104, 103, 101, 99, 99, 99,
-        100, 99, 99, 99, 107, 109, 113, 120, 120, 128, 130, 135, 143, 143, 151,
-        153, 157, 165, 165, 172, 174, 178, 185, 185, 193, 116, 112, 111, 109,
-        106, 106, 106, 106, 106, 105, 105, 113, 115, 119, 126, 126, 134, 136,
-        141, 149, 149, 157, 159, 164, 172, 172, 180, 182, 187, 194, 194, 203,
-        118, 114, 113, 111, 108, 108, 108, 108, 108, 107, 107, 115, 117, 121,
-        128, 128, 136, 138, 143, 151, 151, 159, 161, 166, 174, 174, 182, 184,
-        189, 196, 196, 205, 123, 118, 117, 115, 112, 112, 112, 112, 111, 110,
-        110, 118, 120, 124, 131, 131, 139, 141, 146, 154, 154, 163, 165, 170,
-        178, 178, 187, 189, 194, 202, 202, 211, 131, 126, 125, 122, 119, 119,
-        119, 118, 118, 116, 116, 124, 126, 130, 136, 136, 144, 147, 151, 159,
-        159, 168, 171, 176, 185, 185, 194, 196, 202, 210, 210, 219, 131, 126,
-        125, 122, 119, 119, 119, 118, 118, 116, 116, 124, 126, 130, 136, 136,
-        144, 147, 151, 159, 159, 168, 171, 176, 185, 185, 194, 196, 202, 210,
-        210, 219, 140, 135, 134, 131, 128, 128, 127, 127, 126, 124, 124, 132,
-        134, 138, 144, 144, 152, 154, 159, 167, 167, 176, 179, 184, 193, 193,
-        203, 205, 211, 219, 219, 229,
+        32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 34, 36, 36, 38, 39,
+        41, 44, 44, 47, 48, 50, 54, 54, 58, 59, 61, 65, 65, 70, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 38, 38, 40, 42, 42, 46,
+        47, 49, 52, 52, 56, 57, 59, 63, 63, 67, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 34, 34, 35, 35, 38, 38, 40, 42, 42, 45, 46, 48, 51, 51,
+        55, 56, 58, 62, 62, 67, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        34, 34, 35, 35, 37, 38, 39, 42, 42, 45, 45, 47, 50, 50, 54, 55, 57, 61,
+        61, 65, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34,
+        37, 37, 38, 41, 41, 44, 44, 46, 49, 49, 53, 54, 56, 59, 59, 64, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 37, 37, 38, 41,
+        41, 44, 44, 46, 49, 49, 53, 54, 56, 59, 59, 64, 31, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 33, 34, 35, 35, 36, 36, 38, 39, 40, 42, 42, 44, 45, 47,
+        49, 49, 53, 54, 56, 59, 59, 63, 31, 32, 32, 32, 32, 32, 33, 33, 33, 34,
+        34, 35, 35, 36, 36, 36, 38, 39, 40, 42, 42, 45, 45, 47, 50, 50, 53, 54,
+        56, 59, 59, 63, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 35, 36, 36,
+        37, 37, 39, 39, 40, 42, 42, 45, 45, 47, 49, 49, 53, 54, 55, 59, 59, 63,
+        32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 36, 37, 37, 38, 38, 40, 40,
+        41, 42, 42, 45, 46, 47, 49, 49, 52, 53, 55, 58, 58, 62, 32, 32, 32, 32,
+        32, 32, 33, 34, 34, 35, 35, 36, 37, 37, 38, 38, 40, 40, 41, 42, 42, 45,
+        46, 47, 49, 49, 52, 53, 55, 58, 58, 62, 33, 33, 33, 33, 33, 33, 34, 35,
+        35, 36, 36, 38, 39, 40, 42, 42, 43, 44, 45, 46, 46, 49, 50, 51, 53, 53,
+        56, 57, 59, 62, 62, 66, 34, 34, 34, 34, 33, 33, 35, 35, 36, 37, 37, 39,
+        39, 41, 42, 42, 44, 45, 46, 47, 47, 50, 51, 52, 54, 54, 57, 58, 60, 63,
+        63, 67, 34, 34, 34, 34, 34, 34, 35, 36, 36, 37, 37, 40, 41, 42, 45, 45,
+        46, 47, 48, 50, 50, 52, 53, 54, 56, 56, 59, 60, 62, 65, 65, 69, 36, 35,
+        35, 35, 34, 34, 36, 36, 37, 38, 38, 42, 42, 45, 48, 48, 50, 50, 52, 54,
+        54, 56, 57, 58, 60, 60, 63, 64, 65, 68, 68, 72, 36, 35, 35, 35, 34, 34,
+        36, 36, 37, 38, 38, 42, 42, 45, 48, 48, 50, 50, 52, 54, 54, 56, 57, 58,
+        60, 60, 63, 64, 65, 68, 68, 72, 38, 38, 38, 37, 37, 37, 38, 38, 39, 40,
+        40, 43, 44, 46, 50, 50, 52, 53, 54, 57, 57, 59, 60, 61, 64, 64, 67, 68,
+        69, 72, 72, 76, 39, 38, 38, 38, 37, 37, 39, 39, 39, 40, 40, 44, 45, 47,
+        50, 50, 53, 54, 55, 58, 58, 60, 61, 62, 65, 65, 68, 69, 70, 73, 73, 77,
+        41, 40, 40, 39, 38, 38, 40, 40, 40, 41, 41, 45, 46, 48, 52, 52, 54, 55,
+        57, 60, 60, 62, 63, 65, 67, 67, 70, 71, 73, 75, 75, 79, 44, 42, 42, 42,
+        41, 41, 42, 42, 42, 42, 42, 46, 47, 50, 54, 54, 57, 58, 60, 63, 63, 66,
+        67, 68, 71, 71, 74, 75, 77, 79, 79, 83, 44, 42, 42, 42, 41, 41, 42, 42,
+        42, 42, 42, 46, 47, 50, 54, 54, 57, 58, 60, 63, 63, 66, 67, 68, 71, 71,
+        74, 75, 77, 79, 79, 83, 47, 46, 45, 45, 44, 44, 44, 45, 45, 45, 45, 49,
+        50, 52, 56, 56, 59, 60, 62, 66, 66, 69, 70, 72, 75, 75, 78, 79, 81, 84,
+        84, 88, 48, 47, 46, 45, 44, 44, 45, 45, 45, 46, 46, 50, 51, 53, 57, 57,
+        60, 61, 63, 67, 67, 70, 71, 73, 76, 76, 79, 80, 82, 85, 85, 89, 50, 49,
+        48, 47, 46, 46, 47, 47, 47, 47, 47, 51, 52, 54, 58, 58, 61, 62, 65, 68,
+        68, 72, 73, 75, 78, 78, 82, 83, 85, 88, 88, 92, 54, 52, 51, 50, 49, 49,
+        49, 50, 49, 49, 49, 53, 54, 56, 60, 60, 64, 65, 67, 71, 71, 75, 76, 78,
+        82, 82, 86, 87, 89, 92, 92, 96, 54, 52, 51, 50, 49, 49, 49, 50, 49, 49,
+        49, 53, 54, 56, 60, 60, 64, 65, 67, 71, 71, 75, 76, 78, 82, 82, 86, 87,
+        89, 92, 92, 96, 58, 56, 55, 54, 53, 53, 53, 53, 53, 52, 52, 56, 57, 59,
+        63, 63, 67, 68, 70, 74, 74, 78, 79, 82, 86, 86, 90, 91, 93, 97, 97, 101,
+        59, 57, 56, 55, 54, 54, 54, 54, 54, 53, 53, 57, 58, 60, 64, 64, 68, 69,
+        71, 75, 75, 79, 80, 83, 87, 87, 91, 92, 94, 98, 98, 102, 61, 59, 58, 57,
+        56, 56, 56, 56, 55, 55, 55, 59, 60, 62, 65, 65, 69, 70, 73, 77, 77, 81,
+        82, 85, 89, 89, 93, 94, 97, 101, 101, 105, 65, 63, 62, 61, 59, 59, 59,
+        59, 59, 58, 58, 62, 63, 65, 68, 68, 72, 73, 75, 79, 79, 84, 85, 88, 92,
+        92, 97, 98, 101, 105, 105, 109, 65, 63, 62, 61, 59, 59, 59, 59, 59, 58,
+        58, 62, 63, 65, 68, 68, 72, 73, 75, 79, 79, 84, 85, 88, 92, 92, 97, 98,
+        101, 105, 105, 109, 70, 67, 67, 65, 64, 64, 63, 63, 63, 62, 62, 66, 67,
+        69, 72, 72, 76, 77, 79, 83, 83, 88, 89, 92, 96, 96, 101, 102, 105, 109,
+        109, 114,
         /* Size 4x8 */
-        64, 65, 85, 112, 64, 66, 82, 106, 65, 71, 85, 105, 69, 75, 100, 119, 76,
-        81, 116, 136, 89, 91, 132, 157, 101, 100, 142, 172, 122, 117, 159, 194,
+        32, 32, 42, 56, 32, 33, 41, 53, 32, 35, 42, 52, 34, 37, 50, 59, 38, 40,
+        58, 68, 44, 45, 66, 78, 50, 50, 71, 86, 61, 58, 79, 97,
         /* Size 8x4 */
-        64, 64, 65, 69, 76, 89, 101, 122, 65, 66, 71, 75, 81, 91, 100, 117, 85,
-        82, 85, 100, 116, 132, 142, 159, 112, 106, 105, 119, 136, 157, 172, 194,
+        32, 32, 32, 34, 38, 44, 50, 61, 32, 33, 35, 37, 40, 45, 50, 58, 42, 41,
+        42, 50, 58, 66, 71, 79, 56, 53, 52, 59, 68, 78, 86, 97,
         /* Size 8x16 */
-        64, 63, 64, 70, 78, 88, 107, 131, 63, 64, 65, 70, 76, 85, 103, 124, 63,
-        65, 66, 68, 74, 82, 99, 119, 63, 65, 68, 71, 77, 84, 99, 118, 64, 65,
-        69, 73, 78, 85, 99, 117, 64, 66, 71, 75, 80, 85, 99, 116, 68, 68, 74,
-        83, 89, 96, 109, 126, 72, 69, 77, 92, 100, 108, 120, 136, 77, 74, 81,
-        95, 105, 114, 128, 144, 82, 78, 83, 99, 109, 120, 135, 152, 88, 82, 86,
-        102, 114, 126, 143, 159, 96, 90, 93, 108, 120, 134, 152, 171, 107, 99,
-        100, 115, 128, 142, 164, 185, 115, 106, 106, 121, 134, 149, 172, 194,
-        122, 113, 112, 126, 139, 154, 178, 201, 130, 120, 117, 132, 144, 159,
-        185, 210,
+        32, 31, 32, 35, 39, 44, 53, 65, 31, 32, 32, 35, 38, 42, 51, 62, 31, 32,
+        33, 34, 37, 41, 49, 59, 31, 32, 34, 35, 38, 42, 49, 59, 32, 32, 34, 36,
+        39, 42, 49, 58, 32, 33, 35, 37, 40, 42, 49, 58, 34, 34, 37, 41, 44, 48,
+        54, 63, 36, 34, 38, 46, 50, 54, 60, 68, 38, 37, 40, 47, 52, 57, 64, 72,
+        41, 39, 41, 49, 54, 60, 67, 76, 44, 41, 43, 51, 57, 63, 71, 79, 48, 45,
+        46, 54, 60, 67, 76, 85, 53, 49, 50, 57, 64, 71, 82, 92, 57, 53, 53, 60,
+        67, 74, 86, 97, 61, 56, 56, 63, 69, 77, 89, 100, 65, 60, 58, 66, 72, 79,
+        92, 105,
         /* Size 16x8 */
-        64, 63, 63, 63, 64, 64, 68, 72, 77, 82, 88, 96, 107, 115, 122, 130, 63,
-        64, 65, 65, 65, 66, 68, 69, 74, 78, 82, 90, 99, 106, 113, 120, 64, 65,
-        66, 68, 69, 71, 74, 77, 81, 83, 86, 93, 100, 106, 112, 117, 70, 70, 68,
-        71, 73, 75, 83, 92, 95, 99, 102, 108, 115, 121, 126, 132, 78, 76, 74,
-        77, 78, 80, 89, 100, 105, 109, 114, 120, 128, 134, 139, 144, 88, 85, 82,
-        84, 85, 85, 96, 108, 114, 120, 126, 134, 142, 149, 154, 159, 107, 103,
-        99, 99, 99, 99, 109, 120, 128, 135, 143, 152, 164, 172, 178, 185, 131,
-        124, 119, 118, 117, 116, 126, 136, 144, 152, 159, 171, 185, 194, 201,
-        210,
+        32, 31, 31, 31, 32, 32, 34, 36, 38, 41, 44, 48, 53, 57, 61, 65, 31, 32,
+        32, 32, 32, 33, 34, 34, 37, 39, 41, 45, 49, 53, 56, 60, 32, 32, 33, 34,
+        34, 35, 37, 38, 40, 41, 43, 46, 50, 53, 56, 58, 35, 35, 34, 35, 36, 37,
+        41, 46, 47, 49, 51, 54, 57, 60, 63, 66, 39, 38, 37, 38, 39, 40, 44, 50,
+        52, 54, 57, 60, 64, 67, 69, 72, 44, 42, 41, 42, 42, 42, 48, 54, 57, 60,
+        63, 67, 71, 74, 77, 79, 53, 51, 49, 49, 49, 49, 54, 60, 64, 67, 71, 76,
+        82, 86, 89, 92, 65, 62, 59, 59, 58, 58, 63, 68, 72, 76, 79, 85, 92, 97,
+        100, 105,
         /* Size 16x32 */
-        64, 63, 63, 63, 64, 64, 70, 72, 78, 88, 88, 103, 107, 116, 131, 131, 63,
-        64, 64, 64, 65, 65, 70, 71, 76, 85, 85, 99, 104, 112, 126, 126, 63, 64,
-        64, 64, 65, 65, 70, 71, 76, 85, 85, 99, 103, 111, 124, 124, 63, 64, 64,
-        65, 65, 65, 69, 70, 75, 83, 83, 97, 101, 109, 122, 122, 63, 64, 65, 65,
-        66, 66, 68, 69, 74, 82, 82, 95, 99, 106, 119, 119, 63, 64, 65, 65, 66,
-        66, 68, 69, 74, 82, 82, 95, 99, 106, 119, 119, 63, 65, 65, 66, 68, 68,
-        71, 72, 77, 84, 84, 96, 99, 106, 118, 118, 64, 65, 65, 66, 68, 68, 72,
-        73, 77, 84, 84, 96, 100, 106, 118, 118, 64, 65, 65, 67, 69, 69, 73, 75,
-        78, 85, 85, 96, 99, 106, 117, 117, 64, 65, 66, 68, 71, 71, 75, 77, 80,
-        85, 85, 96, 99, 105, 116, 116, 64, 65, 66, 68, 71, 71, 75, 77, 80, 85,
-        85, 96, 99, 105, 116, 116, 67, 67, 67, 70, 73, 73, 81, 83, 87, 93, 93,
-        104, 107, 113, 124, 124, 68, 68, 68, 70, 74, 74, 83, 85, 89, 96, 96,
-        106, 109, 115, 126, 126, 69, 69, 68, 71, 75, 75, 86, 89, 93, 100, 100,
-        110, 113, 119, 130, 130, 72, 70, 69, 72, 77, 77, 92, 96, 100, 108, 108,
-        117, 120, 126, 136, 136, 72, 70, 69, 72, 77, 77, 92, 96, 100, 108, 108,
-        117, 120, 126, 136, 136, 77, 75, 74, 77, 81, 81, 95, 100, 105, 114, 114,
-        125, 128, 134, 144, 144, 79, 76, 75, 78, 81, 81, 96, 101, 106, 116, 116,
-        127, 130, 136, 147, 147, 82, 79, 78, 80, 83, 83, 99, 103, 109, 120, 120,
-        132, 135, 141, 152, 152, 88, 83, 82, 84, 86, 86, 102, 107, 114, 126,
-        126, 139, 143, 149, 159, 159, 88, 83, 82, 84, 86, 86, 102, 107, 114,
-        126, 126, 139, 143, 149, 159, 159, 94, 89, 88, 89, 91, 91, 107, 112,
-        119, 132, 132, 146, 150, 157, 168, 168, 96, 91, 90, 91, 93, 93, 108,
-        113, 120, 134, 134, 148, 152, 159, 171, 171, 100, 95, 93, 94, 95, 95,
-        111, 116, 123, 137, 137, 152, 157, 164, 176, 176, 107, 101, 99, 100,
-        100, 100, 115, 120, 128, 142, 142, 159, 164, 172, 185, 185, 107, 101,
-        99, 100, 100, 100, 115, 120, 128, 142, 142, 159, 164, 172, 185, 185,
-        115, 108, 106, 106, 106, 106, 121, 126, 134, 149, 149, 166, 172, 180,
-        194, 194, 117, 110, 108, 108, 108, 108, 123, 127, 136, 150, 150, 168,
-        174, 182, 196, 196, 122, 114, 113, 112, 112, 112, 126, 131, 139, 154,
-        154, 172, 178, 187, 201, 201, 130, 122, 120, 119, 117, 117, 132, 136,
-        144, 159, 159, 179, 185, 194, 210, 210, 130, 122, 120, 119, 117, 117,
-        132, 136, 144, 159, 159, 179, 185, 194, 210, 210, 140, 130, 128, 127,
-        125, 125, 140, 144, 152, 167, 167, 187, 193, 203, 219, 219,
+        32, 31, 31, 31, 32, 32, 35, 36, 39, 44, 44, 51, 53, 58, 65, 65, 31, 32,
+        32, 32, 32, 32, 35, 35, 38, 42, 42, 49, 52, 56, 63, 63, 31, 32, 32, 32,
+        32, 32, 35, 35, 38, 42, 42, 49, 51, 55, 62, 62, 31, 32, 32, 32, 32, 32,
+        34, 35, 37, 41, 41, 48, 50, 54, 61, 61, 31, 32, 32, 32, 33, 33, 34, 34,
+        37, 41, 41, 47, 49, 53, 59, 59, 31, 32, 32, 32, 33, 33, 34, 34, 37, 41,
+        41, 47, 49, 53, 59, 59, 31, 32, 32, 33, 34, 34, 35, 36, 38, 42, 42, 48,
+        49, 53, 59, 59, 32, 32, 32, 33, 34, 34, 36, 36, 38, 42, 42, 48, 50, 53,
+        59, 59, 32, 32, 32, 33, 34, 34, 36, 37, 39, 42, 42, 48, 49, 53, 58, 58,
+        32, 32, 33, 34, 35, 35, 37, 38, 40, 42, 42, 48, 49, 52, 58, 58, 32, 32,
+        33, 34, 35, 35, 37, 38, 40, 42, 42, 48, 49, 52, 58, 58, 33, 33, 33, 35,
+        36, 36, 40, 41, 43, 46, 46, 52, 53, 56, 62, 62, 34, 34, 34, 35, 37, 37,
+        41, 42, 44, 48, 48, 53, 54, 57, 63, 63, 34, 34, 34, 35, 37, 37, 43, 44,
+        46, 50, 50, 55, 56, 59, 65, 65, 36, 35, 34, 36, 38, 38, 46, 48, 50, 54,
+        54, 58, 60, 63, 68, 68, 36, 35, 34, 36, 38, 38, 46, 48, 50, 54, 54, 58,
+        60, 63, 68, 68, 38, 37, 37, 38, 40, 40, 47, 50, 52, 57, 57, 62, 64, 67,
+        72, 72, 39, 38, 37, 39, 40, 40, 48, 50, 53, 58, 58, 63, 65, 68, 73, 73,
+        41, 39, 39, 40, 41, 41, 49, 51, 54, 60, 60, 66, 67, 70, 76, 76, 44, 41,
+        41, 42, 43, 43, 51, 53, 57, 63, 63, 69, 71, 74, 79, 79, 44, 41, 41, 42,
+        43, 43, 51, 53, 57, 63, 63, 69, 71, 74, 79, 79, 47, 44, 44, 44, 45, 45,
+        53, 56, 59, 66, 66, 73, 75, 78, 84, 84, 48, 45, 45, 45, 46, 46, 54, 56,
+        60, 67, 67, 74, 76, 79, 85, 85, 50, 47, 46, 47, 47, 47, 55, 58, 61, 68,
+        68, 76, 78, 82, 88, 88, 53, 50, 49, 50, 50, 50, 57, 60, 64, 71, 71, 79,
+        82, 86, 92, 92, 53, 50, 49, 50, 50, 50, 57, 60, 64, 71, 71, 79, 82, 86,
+        92, 92, 57, 54, 53, 53, 53, 53, 60, 63, 67, 74, 74, 83, 86, 90, 97, 97,
+        58, 55, 54, 54, 54, 54, 61, 63, 68, 75, 75, 84, 87, 91, 98, 98, 61, 57,
+        56, 56, 56, 56, 63, 65, 69, 77, 77, 86, 89, 93, 100, 100, 65, 61, 60,
+        59, 58, 58, 66, 68, 72, 79, 79, 89, 92, 97, 105, 105, 65, 61, 60, 59,
+        58, 58, 66, 68, 72, 79, 79, 89, 92, 97, 105, 105, 70, 65, 64, 63, 62,
+        62, 70, 72, 76, 83, 83, 93, 96, 101, 109, 109,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 67, 68, 69, 72, 72, 77, 79,
-        82, 88, 88, 94, 96, 100, 107, 107, 115, 117, 122, 130, 130, 140, 63, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 67, 68, 69, 70, 70, 75, 76, 79, 83,
-        83, 89, 91, 95, 101, 101, 108, 110, 114, 122, 122, 130, 63, 64, 64, 64,
-        65, 65, 65, 65, 65, 66, 66, 67, 68, 68, 69, 69, 74, 75, 78, 82, 82, 88,
-        90, 93, 99, 99, 106, 108, 113, 120, 120, 128, 63, 64, 64, 65, 65, 65,
-        66, 66, 67, 68, 68, 70, 70, 71, 72, 72, 77, 78, 80, 84, 84, 89, 91, 94,
-        100, 100, 106, 108, 112, 119, 119, 127, 64, 65, 65, 65, 66, 66, 68, 68,
-        69, 71, 71, 73, 74, 75, 77, 77, 81, 81, 83, 86, 86, 91, 93, 95, 100,
-        100, 106, 108, 112, 117, 117, 125, 64, 65, 65, 65, 66, 66, 68, 68, 69,
-        71, 71, 73, 74, 75, 77, 77, 81, 81, 83, 86, 86, 91, 93, 95, 100, 100,
-        106, 108, 112, 117, 117, 125, 70, 70, 70, 69, 68, 68, 71, 72, 73, 75,
-        75, 81, 83, 86, 92, 92, 95, 96, 99, 102, 102, 107, 108, 111, 115, 115,
-        121, 123, 126, 132, 132, 140, 72, 71, 71, 70, 69, 69, 72, 73, 75, 77,
-        77, 83, 85, 89, 96, 96, 100, 101, 103, 107, 107, 112, 113, 116, 120,
-        120, 126, 127, 131, 136, 136, 144, 78, 76, 76, 75, 74, 74, 77, 77, 78,
-        80, 80, 87, 89, 93, 100, 100, 105, 106, 109, 114, 114, 119, 120, 123,
-        128, 128, 134, 136, 139, 144, 144, 152, 88, 85, 85, 83, 82, 82, 84, 84,
-        85, 85, 85, 93, 96, 100, 108, 108, 114, 116, 120, 126, 126, 132, 134,
-        137, 142, 142, 149, 150, 154, 159, 159, 167, 88, 85, 85, 83, 82, 82, 84,
-        84, 85, 85, 85, 93, 96, 100, 108, 108, 114, 116, 120, 126, 126, 132,
-        134, 137, 142, 142, 149, 150, 154, 159, 159, 167, 103, 99, 99, 97, 95,
-        95, 96, 96, 96, 96, 96, 104, 106, 110, 117, 117, 125, 127, 132, 139,
-        139, 146, 148, 152, 159, 159, 166, 168, 172, 179, 179, 187, 107, 104,
-        103, 101, 99, 99, 99, 100, 99, 99, 99, 107, 109, 113, 120, 120, 128,
-        130, 135, 143, 143, 150, 152, 157, 164, 164, 172, 174, 178, 185, 185,
-        193, 116, 112, 111, 109, 106, 106, 106, 106, 106, 105, 105, 113, 115,
-        119, 126, 126, 134, 136, 141, 149, 149, 157, 159, 164, 172, 172, 180,
-        182, 187, 194, 194, 203, 131, 126, 124, 122, 119, 119, 118, 118, 117,
-        116, 116, 124, 126, 130, 136, 136, 144, 147, 152, 159, 159, 168, 171,
-        176, 185, 185, 194, 196, 201, 210, 210, 219, 131, 126, 124, 122, 119,
-        119, 118, 118, 117, 116, 116, 124, 126, 130, 136, 136, 144, 147, 152,
-        159, 159, 168, 171, 176, 185, 185, 194, 196, 201, 210, 210, 219,
+        32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33, 34, 34, 36, 36, 38, 39,
+        41, 44, 44, 47, 48, 50, 53, 53, 57, 58, 61, 65, 65, 70, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 37, 38, 39, 41, 41, 44,
+        45, 47, 50, 50, 54, 55, 57, 61, 61, 65, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 33, 34, 34, 34, 34, 37, 37, 39, 41, 41, 44, 45, 46, 49, 49,
+        53, 54, 56, 60, 60, 64, 31, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 35,
+        35, 35, 36, 36, 38, 39, 40, 42, 42, 44, 45, 47, 50, 50, 53, 54, 56, 59,
+        59, 63, 32, 32, 32, 32, 33, 33, 34, 34, 34, 35, 35, 36, 37, 37, 38, 38,
+        40, 40, 41, 43, 43, 45, 46, 47, 50, 50, 53, 54, 56, 58, 58, 62, 32, 32,
+        32, 32, 33, 33, 34, 34, 34, 35, 35, 36, 37, 37, 38, 38, 40, 40, 41, 43,
+        43, 45, 46, 47, 50, 50, 53, 54, 56, 58, 58, 62, 35, 35, 35, 34, 34, 34,
+        35, 36, 36, 37, 37, 40, 41, 43, 46, 46, 47, 48, 49, 51, 51, 53, 54, 55,
+        57, 57, 60, 61, 63, 66, 66, 70, 36, 35, 35, 35, 34, 34, 36, 36, 37, 38,
+        38, 41, 42, 44, 48, 48, 50, 50, 51, 53, 53, 56, 56, 58, 60, 60, 63, 63,
+        65, 68, 68, 72, 39, 38, 38, 37, 37, 37, 38, 38, 39, 40, 40, 43, 44, 46,
+        50, 50, 52, 53, 54, 57, 57, 59, 60, 61, 64, 64, 67, 68, 69, 72, 72, 76,
+        44, 42, 42, 41, 41, 41, 42, 42, 42, 42, 42, 46, 48, 50, 54, 54, 57, 58,
+        60, 63, 63, 66, 67, 68, 71, 71, 74, 75, 77, 79, 79, 83, 44, 42, 42, 41,
+        41, 41, 42, 42, 42, 42, 42, 46, 48, 50, 54, 54, 57, 58, 60, 63, 63, 66,
+        67, 68, 71, 71, 74, 75, 77, 79, 79, 83, 51, 49, 49, 48, 47, 47, 48, 48,
+        48, 48, 48, 52, 53, 55, 58, 58, 62, 63, 66, 69, 69, 73, 74, 76, 79, 79,
+        83, 84, 86, 89, 89, 93, 53, 52, 51, 50, 49, 49, 49, 50, 49, 49, 49, 53,
+        54, 56, 60, 60, 64, 65, 67, 71, 71, 75, 76, 78, 82, 82, 86, 87, 89, 92,
+        92, 96, 58, 56, 55, 54, 53, 53, 53, 53, 53, 52, 52, 56, 57, 59, 63, 63,
+        67, 68, 70, 74, 74, 78, 79, 82, 86, 86, 90, 91, 93, 97, 97, 101, 65, 63,
+        62, 61, 59, 59, 59, 59, 58, 58, 58, 62, 63, 65, 68, 68, 72, 73, 76, 79,
+        79, 84, 85, 88, 92, 92, 97, 98, 100, 105, 105, 109, 65, 63, 62, 61, 59,
+        59, 59, 59, 58, 58, 58, 62, 63, 65, 68, 68, 72, 73, 76, 79, 79, 84, 85,
+        88, 92, 92, 97, 98, 100, 105, 105, 109,
         /* Size 4x16 */
-        63, 64, 88, 116, 64, 65, 85, 111, 64, 66, 82, 106, 65, 68, 84, 106, 65,
-        69, 85, 106, 65, 71, 85, 105, 68, 74, 96, 115, 70, 77, 108, 126, 75, 81,
-        114, 134, 79, 83, 120, 141, 83, 86, 126, 149, 91, 93, 134, 159, 101,
-        100, 142, 172, 108, 106, 149, 180, 114, 112, 154, 187, 122, 117, 159,
-        194,
+        31, 32, 44, 58, 32, 32, 42, 55, 32, 33, 41, 53, 32, 34, 42, 53, 32, 34,
+        42, 53, 32, 35, 42, 52, 34, 37, 48, 57, 35, 38, 54, 63, 37, 40, 57, 67,
+        39, 41, 60, 70, 41, 43, 63, 74, 45, 46, 67, 79, 50, 50, 71, 86, 54, 53,
+        74, 90, 57, 56, 77, 93, 61, 58, 79, 97,
         /* Size 16x4 */
-        63, 64, 64, 65, 65, 65, 68, 70, 75, 79, 83, 91, 101, 108, 114, 122, 64,
-        65, 66, 68, 69, 71, 74, 77, 81, 83, 86, 93, 100, 106, 112, 117, 88, 85,
-        82, 84, 85, 85, 96, 108, 114, 120, 126, 134, 142, 149, 154, 159, 116,
-        111, 106, 106, 106, 105, 115, 126, 134, 141, 149, 159, 172, 180, 187,
-        194,
+        31, 32, 32, 32, 32, 32, 34, 35, 37, 39, 41, 45, 50, 54, 57, 61, 32, 32,
+        33, 34, 34, 35, 37, 38, 40, 41, 43, 46, 50, 53, 56, 58, 44, 42, 41, 42,
+        42, 42, 48, 54, 57, 60, 63, 67, 71, 74, 77, 79, 58, 55, 53, 53, 53, 52,
+        57, 63, 67, 70, 74, 79, 86, 90, 93, 97,
         /* Size 8x32 */
-        64, 63, 64, 70, 78, 88, 107, 131, 63, 64, 65, 70, 76, 85, 104, 126, 63,
-        64, 65, 70, 76, 85, 103, 124, 63, 64, 65, 69, 75, 83, 101, 122, 63, 65,
-        66, 68, 74, 82, 99, 119, 63, 65, 66, 68, 74, 82, 99, 119, 63, 65, 68,
-        71, 77, 84, 99, 118, 64, 65, 68, 72, 77, 84, 100, 118, 64, 65, 69, 73,
-        78, 85, 99, 117, 64, 66, 71, 75, 80, 85, 99, 116, 64, 66, 71, 75, 80,
-        85, 99, 116, 67, 67, 73, 81, 87, 93, 107, 124, 68, 68, 74, 83, 89, 96,
-        109, 126, 69, 68, 75, 86, 93, 100, 113, 130, 72, 69, 77, 92, 100, 108,
-        120, 136, 72, 69, 77, 92, 100, 108, 120, 136, 77, 74, 81, 95, 105, 114,
-        128, 144, 79, 75, 81, 96, 106, 116, 130, 147, 82, 78, 83, 99, 109, 120,
-        135, 152, 88, 82, 86, 102, 114, 126, 143, 159, 88, 82, 86, 102, 114,
-        126, 143, 159, 94, 88, 91, 107, 119, 132, 150, 168, 96, 90, 93, 108,
-        120, 134, 152, 171, 100, 93, 95, 111, 123, 137, 157, 176, 107, 99, 100,
-        115, 128, 142, 164, 185, 107, 99, 100, 115, 128, 142, 164, 185, 115,
-        106, 106, 121, 134, 149, 172, 194, 117, 108, 108, 123, 136, 150, 174,
-        196, 122, 113, 112, 126, 139, 154, 178, 201, 130, 120, 117, 132, 144,
-        159, 185, 210, 130, 120, 117, 132, 144, 159, 185, 210, 140, 128, 125,
-        140, 152, 167, 193, 219,
+        32, 31, 32, 35, 39, 44, 53, 65, 31, 32, 32, 35, 38, 42, 52, 63, 31, 32,
+        32, 35, 38, 42, 51, 62, 31, 32, 32, 34, 37, 41, 50, 61, 31, 32, 33, 34,
+        37, 41, 49, 59, 31, 32, 33, 34, 37, 41, 49, 59, 31, 32, 34, 35, 38, 42,
+        49, 59, 32, 32, 34, 36, 38, 42, 50, 59, 32, 32, 34, 36, 39, 42, 49, 58,
+        32, 33, 35, 37, 40, 42, 49, 58, 32, 33, 35, 37, 40, 42, 49, 58, 33, 33,
+        36, 40, 43, 46, 53, 62, 34, 34, 37, 41, 44, 48, 54, 63, 34, 34, 37, 43,
+        46, 50, 56, 65, 36, 34, 38, 46, 50, 54, 60, 68, 36, 34, 38, 46, 50, 54,
+        60, 68, 38, 37, 40, 47, 52, 57, 64, 72, 39, 37, 40, 48, 53, 58, 65, 73,
+        41, 39, 41, 49, 54, 60, 67, 76, 44, 41, 43, 51, 57, 63, 71, 79, 44, 41,
+        43, 51, 57, 63, 71, 79, 47, 44, 45, 53, 59, 66, 75, 84, 48, 45, 46, 54,
+        60, 67, 76, 85, 50, 46, 47, 55, 61, 68, 78, 88, 53, 49, 50, 57, 64, 71,
+        82, 92, 53, 49, 50, 57, 64, 71, 82, 92, 57, 53, 53, 60, 67, 74, 86, 97,
+        58, 54, 54, 61, 68, 75, 87, 98, 61, 56, 56, 63, 69, 77, 89, 100, 65, 60,
+        58, 66, 72, 79, 92, 105, 65, 60, 58, 66, 72, 79, 92, 105, 70, 64, 62,
+        70, 76, 83, 96, 109,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 67, 68, 69, 72, 72, 77, 79,
-        82, 88, 88, 94, 96, 100, 107, 107, 115, 117, 122, 130, 130, 140, 63, 64,
-        64, 64, 65, 65, 65, 65, 65, 66, 66, 67, 68, 68, 69, 69, 74, 75, 78, 82,
-        82, 88, 90, 93, 99, 99, 106, 108, 113, 120, 120, 128, 64, 65, 65, 65,
-        66, 66, 68, 68, 69, 71, 71, 73, 74, 75, 77, 77, 81, 81, 83, 86, 86, 91,
-        93, 95, 100, 100, 106, 108, 112, 117, 117, 125, 70, 70, 70, 69, 68, 68,
-        71, 72, 73, 75, 75, 81, 83, 86, 92, 92, 95, 96, 99, 102, 102, 107, 108,
-        111, 115, 115, 121, 123, 126, 132, 132, 140, 78, 76, 76, 75, 74, 74, 77,
-        77, 78, 80, 80, 87, 89, 93, 100, 100, 105, 106, 109, 114, 114, 119, 120,
-        123, 128, 128, 134, 136, 139, 144, 144, 152, 88, 85, 85, 83, 82, 82, 84,
-        84, 85, 85, 85, 93, 96, 100, 108, 108, 114, 116, 120, 126, 126, 132,
-        134, 137, 142, 142, 149, 150, 154, 159, 159, 167, 107, 104, 103, 101,
-        99, 99, 99, 100, 99, 99, 99, 107, 109, 113, 120, 120, 128, 130, 135,
-        143, 143, 150, 152, 157, 164, 164, 172, 174, 178, 185, 185, 193, 131,
-        126, 124, 122, 119, 119, 118, 118, 117, 116, 116, 124, 126, 130, 136,
-        136, 144, 147, 152, 159, 159, 168, 171, 176, 185, 185, 194, 196, 201,
-        210, 210, 219 },
+        32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33, 34, 34, 36, 36, 38, 39,
+        41, 44, 44, 47, 48, 50, 53, 53, 57, 58, 61, 65, 65, 70, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 37, 37, 39, 41, 41, 44,
+        45, 46, 49, 49, 53, 54, 56, 60, 60, 64, 32, 32, 32, 32, 33, 33, 34, 34,
+        34, 35, 35, 36, 37, 37, 38, 38, 40, 40, 41, 43, 43, 45, 46, 47, 50, 50,
+        53, 54, 56, 58, 58, 62, 35, 35, 35, 34, 34, 34, 35, 36, 36, 37, 37, 40,
+        41, 43, 46, 46, 47, 48, 49, 51, 51, 53, 54, 55, 57, 57, 60, 61, 63, 66,
+        66, 70, 39, 38, 38, 37, 37, 37, 38, 38, 39, 40, 40, 43, 44, 46, 50, 50,
+        52, 53, 54, 57, 57, 59, 60, 61, 64, 64, 67, 68, 69, 72, 72, 76, 44, 42,
+        42, 41, 41, 41, 42, 42, 42, 42, 42, 46, 48, 50, 54, 54, 57, 58, 60, 63,
+        63, 66, 67, 68, 71, 71, 74, 75, 77, 79, 79, 83, 53, 52, 51, 50, 49, 49,
+        49, 50, 49, 49, 49, 53, 54, 56, 60, 60, 64, 65, 67, 71, 71, 75, 76, 78,
+        82, 82, 86, 87, 89, 92, 92, 96, 65, 63, 62, 61, 59, 59, 59, 59, 58, 58,
+        58, 62, 63, 65, 68, 68, 72, 73, 76, 79, 79, 84, 85, 88, 92, 92, 97, 98,
+        100, 105, 105, 109 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        78, 94, 94, 127,
+        39, 47, 47, 63,
 #endif
         /* Size 4x4 */
-        63, 83, 92, 102, 83, 96, 97, 102, 92, 97, 117, 125, 102, 102, 125, 142,
+        31, 41, 46, 51, 41, 48, 48, 51, 46, 48, 58, 62, 51, 51, 62, 71,
         /* Size 8x8 */
-        63, 62, 76, 89, 95, 97, 101, 110, 62, 64, 80, 88, 91, 92, 95, 104, 76,
-        80, 95, 95, 93, 92, 94, 100, 89, 88, 95, 100, 102, 103, 104, 109, 95,
-        91, 93, 102, 109, 113, 115, 120, 97, 92, 92, 103, 113, 122, 126, 133,
-        101, 95, 94, 104, 115, 126, 133, 141, 110, 104, 100, 109, 120, 133, 141,
-        153,
+        31, 31, 38, 44, 47, 48, 50, 55, 31, 32, 40, 44, 45, 46, 47, 52, 38, 40,
+        47, 47, 46, 46, 47, 50, 44, 44, 47, 50, 51, 51, 52, 54, 47, 45, 46, 51,
+        54, 56, 57, 60, 48, 46, 46, 51, 56, 61, 63, 66, 50, 47, 47, 52, 57, 63,
+        66, 70, 55, 52, 50, 54, 60, 66, 70, 76,
         /* Size 16x16 */
-        64, 62, 61, 66, 69, 73, 83, 98, 97, 98, 98, 101, 104, 108, 111, 114, 62,
-        63, 62, 68, 72, 77, 85, 95, 94, 94, 94, 97, 100, 103, 106, 109, 61, 62,
-        64, 69, 74, 80, 85, 93, 91, 91, 90, 93, 95, 99, 101, 104, 66, 68, 69,
-        75, 80, 85, 89, 94, 93, 92, 91, 93, 95, 98, 100, 103, 69, 72, 74, 80,
-        85, 90, 92, 95, 93, 92, 91, 93, 94, 97, 99, 101, 73, 77, 80, 85, 90, 95,
-        95, 96, 94, 92, 91, 92, 94, 96, 98, 100, 83, 85, 85, 89, 92, 95, 97,
-        101, 100, 99, 98, 100, 101, 103, 105, 107, 98, 95, 93, 94, 95, 96, 101,
-        106, 106, 107, 107, 108, 109, 111, 112, 113, 97, 94, 91, 93, 93, 94,
-        100, 106, 108, 109, 111, 112, 114, 116, 117, 118, 98, 94, 91, 92, 92,
-        92, 99, 107, 109, 111, 114, 116, 118, 120, 121, 123, 98, 94, 90, 91, 91,
-        91, 98, 107, 111, 114, 117, 120, 123, 124, 126, 127, 101, 97, 93, 93,
-        93, 92, 100, 108, 112, 116, 120, 123, 127, 130, 132, 134, 104, 100, 95,
-        95, 94, 94, 101, 109, 114, 118, 123, 127, 133, 136, 139, 141, 108, 103,
-        99, 98, 97, 96, 103, 111, 116, 120, 124, 130, 136, 140, 143, 146, 111,
-        106, 101, 100, 99, 98, 105, 112, 117, 121, 126, 132, 139, 143, 146, 149,
-        114, 109, 104, 103, 101, 100, 107, 113, 118, 123, 127, 134, 141, 146,
-        149, 153,
+        32, 31, 30, 33, 34, 36, 41, 49, 48, 49, 49, 50, 52, 54, 55, 57, 31, 31,
+        31, 34, 36, 38, 42, 47, 47, 47, 47, 48, 50, 51, 53, 54, 30, 31, 32, 34,
+        37, 40, 42, 46, 45, 45, 45, 46, 47, 49, 50, 52, 33, 34, 34, 37, 40, 42,
+        44, 47, 46, 46, 45, 46, 47, 49, 50, 51, 34, 36, 37, 40, 42, 45, 46, 47,
+        46, 46, 45, 46, 47, 48, 49, 50, 36, 38, 40, 42, 45, 47, 47, 48, 47, 46,
+        45, 46, 47, 48, 49, 50, 41, 42, 42, 44, 46, 47, 48, 50, 50, 49, 49, 50,
+        50, 51, 52, 53, 49, 47, 46, 47, 47, 48, 50, 53, 53, 53, 53, 54, 54, 55,
+        56, 56, 48, 47, 45, 46, 46, 47, 50, 53, 54, 54, 55, 56, 57, 58, 58, 59,
+        49, 47, 45, 46, 46, 46, 49, 53, 54, 55, 57, 58, 59, 60, 60, 61, 49, 47,
+        45, 45, 45, 45, 49, 53, 55, 57, 58, 60, 61, 62, 63, 63, 50, 48, 46, 46,
+        46, 46, 50, 54, 56, 58, 60, 61, 63, 65, 66, 67, 52, 50, 47, 47, 47, 47,
+        50, 54, 57, 59, 61, 63, 66, 68, 69, 70, 54, 51, 49, 49, 48, 48, 51, 55,
+        58, 60, 62, 65, 68, 70, 71, 73, 55, 53, 50, 50, 49, 49, 52, 56, 58, 60,
+        63, 66, 69, 71, 73, 74, 57, 54, 52, 51, 50, 50, 53, 56, 59, 61, 63, 67,
+        70, 73, 74, 76,
         /* Size 32x32 */
-        64, 63, 62, 62, 61, 61, 66, 67, 69, 73, 73, 81, 83, 89, 98, 98, 97, 97,
-        98, 98, 98, 101, 101, 103, 104, 104, 108, 109, 111, 114, 114, 119, 63,
-        63, 63, 62, 62, 62, 67, 69, 72, 76, 76, 83, 84, 89, 96, 96, 95, 95, 95,
-        95, 95, 97, 98, 99, 101, 101, 104, 105, 107, 110, 110, 114, 62, 63, 63,
-        63, 62, 62, 68, 69, 72, 77, 77, 83, 85, 89, 95, 95, 94, 94, 94, 94, 94,
-        96, 97, 98, 100, 100, 103, 104, 106, 109, 109, 113, 62, 62, 63, 63, 63,
-        63, 68, 70, 73, 78, 78, 83, 85, 88, 94, 94, 93, 93, 93, 92, 92, 95, 95,
-        96, 98, 98, 101, 102, 104, 107, 107, 111, 61, 62, 62, 63, 64, 64, 69,
-        71, 74, 80, 80, 84, 85, 88, 93, 93, 91, 91, 91, 90, 90, 92, 93, 94, 95,
-        95, 99, 99, 101, 104, 104, 108, 61, 62, 62, 63, 64, 64, 69, 71, 74, 80,
-        80, 84, 85, 88, 93, 93, 91, 91, 91, 90, 90, 92, 93, 94, 95, 95, 99, 99,
-        101, 104, 104, 108, 66, 67, 68, 68, 69, 69, 75, 77, 80, 85, 85, 88, 89,
-        91, 94, 94, 93, 92, 92, 91, 91, 93, 93, 94, 95, 95, 98, 99, 100, 103,
-        103, 106, 67, 69, 69, 70, 71, 71, 77, 78, 81, 87, 87, 89, 90, 92, 95,
-        95, 93, 93, 92, 91, 91, 93, 93, 94, 95, 95, 98, 99, 100, 102, 102, 106,
-        69, 72, 72, 73, 74, 74, 80, 81, 85, 90, 90, 91, 92, 93, 95, 95, 93, 93,
-        92, 91, 91, 92, 93, 94, 94, 94, 97, 98, 99, 101, 101, 105, 73, 76, 77,
-        78, 80, 80, 85, 87, 90, 95, 95, 95, 95, 95, 96, 96, 94, 93, 92, 91, 91,
-        92, 92, 93, 94, 94, 96, 97, 98, 100, 100, 103, 73, 76, 77, 78, 80, 80,
-        85, 87, 90, 95, 95, 95, 95, 95, 96, 96, 94, 93, 92, 91, 91, 92, 92, 93,
-        94, 94, 96, 97, 98, 100, 100, 103, 81, 83, 83, 83, 84, 84, 88, 89, 91,
-        95, 95, 96, 97, 98, 100, 100, 98, 98, 98, 97, 97, 98, 98, 99, 99, 99,
-        102, 102, 103, 105, 105, 108, 83, 84, 85, 85, 85, 85, 89, 90, 92, 95,
-        95, 97, 97, 99, 101, 101, 100, 99, 99, 98, 98, 100, 100, 100, 101, 101,
-        103, 104, 105, 107, 107, 110, 89, 89, 89, 88, 88, 88, 91, 92, 93, 95,
-        95, 98, 99, 100, 103, 103, 102, 102, 102, 102, 102, 103, 103, 103, 104,
-        104, 106, 107, 108, 109, 109, 112, 98, 96, 95, 94, 93, 93, 94, 95, 95,
-        96, 96, 100, 101, 103, 106, 106, 106, 106, 107, 107, 107, 108, 108, 108,
-        109, 109, 111, 111, 112, 113, 113, 116, 98, 96, 95, 94, 93, 93, 94, 95,
-        95, 96, 96, 100, 101, 103, 106, 106, 106, 106, 107, 107, 107, 108, 108,
-        108, 109, 109, 111, 111, 112, 113, 113, 116, 97, 95, 94, 93, 91, 91, 93,
-        93, 93, 94, 94, 98, 100, 102, 106, 106, 108, 108, 109, 111, 111, 112,
-        112, 113, 114, 114, 116, 116, 117, 118, 118, 121, 97, 95, 94, 93, 91,
-        91, 92, 93, 93, 93, 93, 98, 99, 102, 106, 106, 108, 109, 110, 111, 111,
-        113, 113, 114, 115, 115, 117, 117, 118, 120, 120, 123, 98, 95, 94, 93,
-        91, 91, 92, 92, 92, 92, 92, 98, 99, 102, 107, 107, 109, 110, 111, 114,
-        114, 115, 116, 116, 118, 118, 120, 120, 121, 123, 123, 126, 98, 95, 94,
-        92, 90, 90, 91, 91, 91, 91, 91, 97, 98, 102, 107, 107, 111, 111, 114,
-        117, 117, 119, 120, 121, 123, 123, 124, 125, 126, 127, 127, 130, 98, 95,
-        94, 92, 90, 90, 91, 91, 91, 91, 91, 97, 98, 102, 107, 107, 111, 111,
-        114, 117, 117, 119, 120, 121, 123, 123, 124, 125, 126, 127, 127, 130,
-        101, 97, 96, 95, 92, 92, 93, 93, 92, 92, 92, 98, 100, 103, 108, 108,
-        112, 113, 115, 119, 119, 122, 122, 124, 126, 126, 129, 129, 131, 133,
-        133, 135, 101, 98, 97, 95, 93, 93, 93, 93, 93, 92, 92, 98, 100, 103,
-        108, 108, 112, 113, 116, 120, 120, 122, 123, 125, 127, 127, 130, 130,
-        132, 134, 134, 137, 103, 99, 98, 96, 94, 94, 94, 94, 94, 93, 93, 99,
-        100, 103, 108, 108, 113, 114, 116, 121, 121, 124, 125, 127, 130, 130,
-        132, 133, 134, 137, 137, 140, 104, 101, 100, 98, 95, 95, 95, 95, 94, 94,
-        94, 99, 101, 104, 109, 109, 114, 115, 118, 123, 123, 126, 127, 130, 133,
-        133, 136, 137, 139, 141, 141, 144, 104, 101, 100, 98, 95, 95, 95, 95,
-        94, 94, 94, 99, 101, 104, 109, 109, 114, 115, 118, 123, 123, 126, 127,
-        130, 133, 133, 136, 137, 139, 141, 141, 144, 108, 104, 103, 101, 99, 99,
-        98, 98, 97, 96, 96, 102, 103, 106, 111, 111, 116, 117, 120, 124, 124,
-        129, 130, 132, 136, 136, 140, 141, 143, 146, 146, 149, 109, 105, 104,
-        102, 99, 99, 99, 99, 98, 97, 97, 102, 104, 107, 111, 111, 116, 117, 120,
-        125, 125, 129, 130, 133, 137, 137, 141, 142, 144, 147, 147, 150, 111,
-        107, 106, 104, 101, 101, 100, 100, 99, 98, 98, 103, 105, 108, 112, 112,
-        117, 118, 121, 126, 126, 131, 132, 134, 139, 139, 143, 144, 146, 149,
-        149, 153, 114, 110, 109, 107, 104, 104, 103, 102, 101, 100, 100, 105,
-        107, 109, 113, 113, 118, 120, 123, 127, 127, 133, 134, 137, 141, 141,
-        146, 147, 149, 153, 153, 157, 114, 110, 109, 107, 104, 104, 103, 102,
-        101, 100, 100, 105, 107, 109, 113, 113, 118, 120, 123, 127, 127, 133,
-        134, 137, 141, 141, 146, 147, 149, 153, 153, 157, 119, 114, 113, 111,
-        108, 108, 106, 106, 105, 103, 103, 108, 110, 112, 116, 116, 121, 123,
-        126, 130, 130, 135, 137, 140, 144, 144, 149, 150, 153, 157, 157, 161,
+        32, 31, 31, 31, 30, 30, 33, 33, 34, 36, 36, 40, 41, 44, 49, 49, 48, 48,
+        49, 49, 49, 50, 50, 51, 52, 52, 54, 54, 55, 57, 57, 59, 31, 31, 31, 31,
+        31, 31, 33, 34, 36, 38, 38, 41, 42, 44, 48, 48, 47, 47, 47, 47, 47, 48,
+        49, 49, 50, 50, 52, 52, 53, 55, 55, 57, 31, 31, 31, 31, 31, 31, 34, 34,
+        36, 38, 38, 41, 42, 44, 47, 47, 47, 47, 47, 47, 47, 48, 48, 49, 50, 50,
+        51, 52, 53, 54, 54, 56, 31, 31, 31, 31, 31, 31, 34, 35, 36, 39, 39, 41,
+        42, 44, 47, 47, 46, 46, 46, 46, 46, 47, 47, 48, 49, 49, 50, 51, 52, 53,
+        53, 55, 30, 31, 31, 31, 32, 32, 34, 35, 37, 40, 40, 42, 42, 44, 46, 46,
+        45, 45, 45, 45, 45, 46, 46, 47, 47, 47, 49, 49, 50, 52, 52, 54, 30, 31,
+        31, 31, 32, 32, 34, 35, 37, 40, 40, 42, 42, 44, 46, 46, 45, 45, 45, 45,
+        45, 46, 46, 47, 47, 47, 49, 49, 50, 52, 52, 54, 33, 33, 34, 34, 34, 34,
+        37, 38, 40, 42, 42, 44, 44, 45, 47, 47, 46, 46, 46, 45, 45, 46, 46, 47,
+        47, 47, 49, 49, 50, 51, 51, 53, 33, 34, 34, 35, 35, 35, 38, 39, 40, 43,
+        43, 44, 45, 46, 47, 47, 46, 46, 46, 45, 45, 46, 46, 47, 47, 47, 49, 49,
+        50, 51, 51, 53, 34, 36, 36, 36, 37, 37, 40, 40, 42, 45, 45, 45, 46, 46,
+        47, 47, 46, 46, 46, 45, 45, 46, 46, 47, 47, 47, 48, 49, 49, 50, 50, 52,
+        36, 38, 38, 39, 40, 40, 42, 43, 45, 47, 47, 47, 47, 47, 48, 48, 47, 46,
+        46, 45, 45, 46, 46, 46, 47, 47, 48, 48, 49, 50, 50, 51, 36, 38, 38, 39,
+        40, 40, 42, 43, 45, 47, 47, 47, 47, 47, 48, 48, 47, 46, 46, 45, 45, 46,
+        46, 46, 47, 47, 48, 48, 49, 50, 50, 51, 40, 41, 41, 41, 42, 42, 44, 44,
+        45, 47, 47, 48, 48, 49, 50, 50, 49, 49, 49, 48, 48, 49, 49, 49, 49, 49,
+        51, 51, 51, 52, 52, 54, 41, 42, 42, 42, 42, 42, 44, 45, 46, 47, 47, 48,
+        48, 49, 50, 50, 50, 49, 49, 49, 49, 50, 50, 50, 50, 50, 51, 52, 52, 53,
+        53, 55, 44, 44, 44, 44, 44, 44, 45, 46, 46, 47, 47, 49, 49, 50, 51, 51,
+        51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 53, 53, 54, 54, 54, 56, 49, 48,
+        47, 47, 46, 46, 47, 47, 47, 48, 48, 50, 50, 51, 53, 53, 53, 53, 53, 53,
+        53, 54, 54, 54, 54, 54, 55, 55, 56, 56, 56, 58, 49, 48, 47, 47, 46, 46,
+        47, 47, 47, 48, 48, 50, 50, 51, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54,
+        54, 54, 55, 55, 56, 56, 56, 58, 48, 47, 47, 46, 45, 45, 46, 46, 46, 47,
+        47, 49, 50, 51, 53, 53, 54, 54, 54, 55, 55, 56, 56, 56, 57, 57, 58, 58,
+        58, 59, 59, 60, 48, 47, 47, 46, 45, 45, 46, 46, 46, 46, 46, 49, 49, 51,
+        53, 53, 54, 54, 55, 55, 55, 56, 56, 57, 57, 57, 58, 58, 59, 60, 60, 61,
+        49, 47, 47, 46, 45, 45, 46, 46, 46, 46, 46, 49, 49, 51, 53, 53, 54, 55,
+        55, 57, 57, 57, 58, 58, 59, 59, 60, 60, 60, 61, 61, 63, 49, 47, 47, 46,
+        45, 45, 45, 45, 45, 45, 45, 48, 49, 51, 53, 53, 55, 55, 57, 58, 58, 59,
+        60, 60, 61, 61, 62, 62, 63, 63, 63, 65, 49, 47, 47, 46, 45, 45, 45, 45,
+        45, 45, 45, 48, 49, 51, 53, 53, 55, 55, 57, 58, 58, 59, 60, 60, 61, 61,
+        62, 62, 63, 63, 63, 65, 50, 48, 48, 47, 46, 46, 46, 46, 46, 46, 46, 49,
+        50, 51, 54, 54, 56, 56, 57, 59, 59, 61, 61, 62, 63, 63, 64, 64, 65, 66,
+        66, 67, 50, 49, 48, 47, 46, 46, 46, 46, 46, 46, 46, 49, 50, 51, 54, 54,
+        56, 56, 58, 60, 60, 61, 61, 62, 63, 63, 65, 65, 66, 67, 67, 68, 51, 49,
+        49, 48, 47, 47, 47, 47, 47, 46, 46, 49, 50, 51, 54, 54, 56, 57, 58, 60,
+        60, 62, 62, 63, 65, 65, 66, 66, 67, 68, 68, 70, 52, 50, 50, 49, 47, 47,
+        47, 47, 47, 47, 47, 49, 50, 52, 54, 54, 57, 57, 59, 61, 61, 63, 63, 65,
+        66, 66, 68, 68, 69, 70, 70, 72, 52, 50, 50, 49, 47, 47, 47, 47, 47, 47,
+        47, 49, 50, 52, 54, 54, 57, 57, 59, 61, 61, 63, 63, 65, 66, 66, 68, 68,
+        69, 70, 70, 72, 54, 52, 51, 50, 49, 49, 49, 49, 48, 48, 48, 51, 51, 53,
+        55, 55, 58, 58, 60, 62, 62, 64, 65, 66, 68, 68, 70, 70, 71, 73, 73, 74,
+        54, 52, 52, 51, 49, 49, 49, 49, 49, 48, 48, 51, 52, 53, 55, 55, 58, 58,
+        60, 62, 62, 64, 65, 66, 68, 68, 70, 71, 72, 73, 73, 75, 55, 53, 53, 52,
+        50, 50, 50, 50, 49, 49, 49, 51, 52, 54, 56, 56, 58, 59, 60, 63, 63, 65,
+        66, 67, 69, 69, 71, 72, 73, 74, 74, 76, 57, 55, 54, 53, 52, 52, 51, 51,
+        50, 50, 50, 52, 53, 54, 56, 56, 59, 60, 61, 63, 63, 66, 67, 68, 70, 70,
+        73, 73, 74, 76, 76, 78, 57, 55, 54, 53, 52, 52, 51, 51, 50, 50, 50, 52,
+        53, 54, 56, 56, 59, 60, 61, 63, 63, 66, 67, 68, 70, 70, 73, 73, 74, 76,
+        76, 78, 59, 57, 56, 55, 54, 54, 53, 53, 52, 51, 51, 54, 55, 56, 58, 58,
+        60, 61, 63, 65, 65, 67, 68, 70, 72, 72, 74, 75, 76, 78, 78, 80,
         /* Size 4x8 */
-        63, 76, 95, 104, 64, 80, 91, 99, 79, 94, 91, 96, 89, 95, 102, 106, 93,
-        94, 112, 117, 94, 93, 119, 129, 97, 95, 122, 137, 106, 101, 128, 146,
+        31, 38, 47, 52, 32, 40, 45, 49, 39, 47, 45, 48, 44, 47, 51, 53, 46, 47,
+        56, 58, 47, 46, 59, 64, 48, 47, 61, 68, 53, 50, 64, 73,
         /* Size 8x4 */
-        63, 64, 79, 89, 93, 94, 97, 106, 76, 80, 94, 95, 94, 93, 95, 101, 95,
-        91, 91, 102, 112, 119, 122, 128, 104, 99, 96, 106, 117, 129, 137, 146,
+        31, 32, 39, 44, 46, 47, 48, 53, 38, 40, 47, 47, 47, 46, 47, 50, 47, 45,
+        45, 51, 56, 59, 61, 64, 52, 49, 48, 53, 58, 64, 68, 73,
         /* Size 8x16 */
-        64, 62, 74, 91, 97, 98, 105, 115, 63, 63, 77, 90, 94, 94, 100, 109, 61,
-        64, 80, 89, 91, 91, 96, 104, 66, 70, 85, 92, 93, 91, 95, 103, 70, 75,
-        89, 93, 93, 91, 95, 102, 74, 80, 94, 95, 94, 91, 94, 100, 84, 86, 95,
-        99, 100, 99, 101, 107, 98, 93, 96, 104, 106, 107, 109, 114, 97, 92, 94,
-        103, 108, 111, 114, 119, 97, 91, 93, 103, 109, 114, 118, 123, 98, 91,
-        92, 103, 111, 117, 123, 128, 101, 93, 93, 105, 112, 119, 128, 134, 104,
-        96, 95, 106, 114, 122, 133, 142, 108, 99, 97, 108, 116, 124, 136, 146,
-        111, 102, 99, 109, 117, 126, 139, 149, 114, 104, 101, 111, 119, 128,
-        141, 153,
+        32, 31, 37, 45, 48, 49, 52, 57, 31, 31, 38, 45, 47, 47, 50, 54, 30, 32,
+        40, 44, 45, 45, 48, 52, 33, 35, 42, 46, 46, 45, 47, 51, 35, 37, 44, 46,
+        46, 45, 47, 51, 37, 40, 47, 47, 47, 45, 47, 50, 42, 43, 47, 49, 50, 49,
+        50, 53, 49, 46, 48, 52, 53, 53, 54, 57, 48, 46, 47, 51, 54, 55, 57, 59,
+        48, 45, 46, 51, 54, 57, 59, 61, 49, 45, 46, 51, 55, 58, 61, 64, 50, 46,
+        46, 52, 56, 59, 64, 67, 52, 48, 47, 53, 57, 61, 66, 71, 54, 49, 48, 54,
+        58, 62, 68, 73, 55, 51, 49, 54, 58, 63, 69, 74, 57, 52, 50, 55, 59, 64,
+        70, 76,
         /* Size 16x8 */
-        64, 63, 61, 66, 70, 74, 84, 98, 97, 97, 98, 101, 104, 108, 111, 114, 62,
-        63, 64, 70, 75, 80, 86, 93, 92, 91, 91, 93, 96, 99, 102, 104, 74, 77,
-        80, 85, 89, 94, 95, 96, 94, 93, 92, 93, 95, 97, 99, 101, 91, 90, 89, 92,
-        93, 95, 99, 104, 103, 103, 103, 105, 106, 108, 109, 111, 97, 94, 91, 93,
-        93, 94, 100, 106, 108, 109, 111, 112, 114, 116, 117, 119, 98, 94, 91,
-        91, 91, 91, 99, 107, 111, 114, 117, 119, 122, 124, 126, 128, 105, 100,
-        96, 95, 95, 94, 101, 109, 114, 118, 123, 128, 133, 136, 139, 141, 115,
-        109, 104, 103, 102, 100, 107, 114, 119, 123, 128, 134, 142, 146, 149,
-        153,
+        32, 31, 30, 33, 35, 37, 42, 49, 48, 48, 49, 50, 52, 54, 55, 57, 31, 31,
+        32, 35, 37, 40, 43, 46, 46, 45, 45, 46, 48, 49, 51, 52, 37, 38, 40, 42,
+        44, 47, 47, 48, 47, 46, 46, 46, 47, 48, 49, 50, 45, 45, 44, 46, 46, 47,
+        49, 52, 51, 51, 51, 52, 53, 54, 54, 55, 48, 47, 45, 46, 46, 47, 50, 53,
+        54, 54, 55, 56, 57, 58, 58, 59, 49, 47, 45, 45, 45, 45, 49, 53, 55, 57,
+        58, 59, 61, 62, 63, 64, 52, 50, 48, 47, 47, 47, 50, 54, 57, 59, 61, 64,
+        66, 68, 69, 70, 57, 54, 52, 51, 51, 50, 53, 57, 59, 61, 64, 67, 71, 73,
+        74, 76,
         /* Size 16x32 */
-        64, 62, 62, 66, 74, 74, 91, 96, 97, 98, 98, 103, 105, 109, 115, 115, 63,
-        63, 63, 68, 76, 76, 90, 95, 95, 95, 95, 100, 101, 104, 110, 110, 63, 63,
-        63, 68, 77, 77, 90, 94, 94, 94, 94, 99, 100, 103, 109, 109, 62, 63, 64,
-        69, 78, 78, 90, 93, 93, 93, 93, 97, 98, 102, 107, 107, 61, 64, 64, 70,
-        80, 80, 89, 92, 91, 91, 91, 95, 96, 99, 104, 104, 61, 64, 64, 70, 80,
-        80, 89, 92, 91, 91, 91, 95, 96, 99, 104, 104, 66, 69, 70, 75, 85, 85,
-        92, 94, 93, 91, 91, 95, 95, 98, 103, 103, 67, 71, 72, 77, 86, 86, 92,
-        94, 93, 92, 92, 95, 95, 98, 103, 103, 70, 74, 75, 80, 89, 89, 93, 95,
-        93, 91, 91, 94, 95, 97, 102, 102, 74, 79, 80, 86, 94, 94, 95, 95, 94,
-        91, 91, 93, 94, 96, 100, 100, 74, 79, 80, 86, 94, 94, 95, 95, 94, 91,
-        91, 93, 94, 96, 100, 100, 82, 84, 85, 88, 95, 95, 98, 99, 98, 97, 97,
-        99, 100, 102, 105, 105, 84, 85, 86, 89, 95, 95, 99, 100, 100, 99, 99,
-        101, 101, 103, 107, 107, 89, 89, 89, 91, 95, 95, 101, 102, 102, 102,
-        102, 104, 104, 106, 109, 109, 98, 94, 93, 94, 96, 96, 104, 106, 106,
-        107, 107, 109, 109, 111, 114, 114, 98, 94, 93, 94, 96, 96, 104, 106,
-        106, 107, 107, 109, 109, 111, 114, 114, 97, 93, 92, 93, 94, 94, 103,
-        106, 108, 111, 111, 113, 114, 116, 119, 119, 97, 93, 92, 93, 94, 94,
-        103, 106, 108, 112, 112, 114, 115, 117, 120, 120, 97, 92, 91, 92, 93,
-        93, 103, 106, 109, 114, 114, 117, 118, 120, 123, 123, 98, 92, 91, 91,
-        92, 92, 103, 107, 111, 117, 117, 122, 123, 125, 128, 128, 98, 92, 91,
-        91, 92, 92, 103, 107, 111, 117, 117, 122, 123, 125, 128, 128, 100, 94,
-        93, 93, 93, 93, 104, 108, 112, 119, 119, 125, 127, 129, 133, 133, 101,
-        95, 93, 93, 93, 93, 105, 108, 112, 119, 119, 126, 128, 130, 134, 134,
-        102, 96, 94, 94, 94, 94, 105, 108, 113, 121, 121, 128, 130, 133, 137,
-        137, 104, 97, 96, 95, 95, 95, 106, 109, 114, 122, 122, 131, 133, 137,
-        142, 142, 104, 97, 96, 95, 95, 95, 106, 109, 114, 122, 122, 131, 133,
-        137, 142, 142, 108, 101, 99, 98, 97, 97, 108, 111, 116, 124, 124, 134,
-        136, 140, 146, 146, 109, 102, 100, 99, 98, 98, 108, 111, 116, 125, 125,
-        134, 137, 141, 147, 147, 111, 103, 102, 101, 99, 99, 109, 112, 117, 126,
-        126, 136, 139, 143, 149, 149, 114, 106, 104, 103, 101, 101, 111, 113,
-        119, 128, 128, 138, 141, 146, 153, 153, 114, 106, 104, 103, 101, 101,
-        111, 113, 119, 128, 128, 138, 141, 146, 153, 153, 118, 110, 108, 107,
-        104, 104, 114, 116, 122, 130, 130, 141, 144, 149, 157, 157,
+        32, 31, 31, 33, 37, 37, 45, 48, 48, 49, 49, 51, 52, 54, 57, 57, 31, 31,
+        31, 34, 38, 38, 45, 47, 47, 47, 47, 50, 50, 52, 55, 55, 31, 31, 31, 34,
+        38, 38, 45, 47, 47, 47, 47, 49, 50, 51, 54, 54, 31, 31, 32, 34, 39, 39,
+        45, 46, 46, 46, 46, 48, 49, 51, 53, 53, 30, 32, 32, 35, 40, 40, 44, 46,
+        45, 45, 45, 47, 48, 49, 52, 52, 30, 32, 32, 35, 40, 40, 44, 46, 45, 45,
+        45, 47, 48, 49, 52, 52, 33, 34, 35, 37, 42, 42, 46, 47, 46, 45, 45, 47,
+        47, 49, 51, 51, 33, 35, 36, 38, 43, 43, 46, 47, 46, 46, 46, 47, 47, 49,
+        51, 51, 35, 37, 37, 40, 44, 44, 46, 47, 46, 45, 45, 47, 47, 48, 51, 51,
+        37, 39, 40, 43, 47, 47, 47, 47, 47, 45, 45, 46, 47, 48, 50, 50, 37, 39,
+        40, 43, 47, 47, 47, 47, 47, 45, 45, 46, 47, 48, 50, 50, 41, 42, 42, 44,
+        47, 47, 49, 49, 49, 48, 48, 49, 50, 51, 52, 52, 42, 42, 43, 44, 47, 47,
+        49, 50, 50, 49, 49, 50, 50, 51, 53, 53, 44, 44, 44, 45, 47, 47, 50, 51,
+        51, 51, 51, 52, 52, 53, 54, 54, 49, 47, 46, 47, 48, 48, 52, 53, 53, 53,
+        53, 54, 54, 55, 57, 57, 49, 47, 46, 47, 48, 48, 52, 53, 53, 53, 53, 54,
+        54, 55, 57, 57, 48, 46, 46, 46, 47, 47, 51, 53, 54, 55, 55, 56, 57, 58,
+        59, 59, 48, 46, 46, 46, 47, 47, 51, 53, 54, 56, 56, 57, 57, 58, 60, 60,
+        48, 46, 45, 46, 46, 46, 51, 53, 54, 57, 57, 58, 59, 60, 61, 61, 49, 46,
+        45, 45, 46, 46, 51, 53, 55, 58, 58, 61, 61, 62, 64, 64, 49, 46, 45, 45,
+        46, 46, 51, 53, 55, 58, 58, 61, 61, 62, 64, 64, 50, 47, 46, 46, 46, 46,
+        52, 54, 56, 59, 59, 62, 63, 64, 66, 66, 50, 47, 46, 46, 46, 46, 52, 54,
+        56, 59, 59, 63, 64, 65, 67, 67, 51, 48, 47, 47, 47, 47, 52, 54, 56, 60,
+        60, 64, 65, 66, 68, 68, 52, 48, 48, 47, 47, 47, 53, 54, 57, 61, 61, 65,
+        66, 68, 71, 71, 52, 48, 48, 47, 47, 47, 53, 54, 57, 61, 61, 65, 66, 68,
+        71, 71, 54, 50, 49, 49, 48, 48, 54, 55, 58, 62, 62, 67, 68, 70, 73, 73,
+        54, 51, 50, 49, 49, 49, 54, 55, 58, 62, 62, 67, 68, 70, 73, 73, 55, 51,
+        51, 50, 49, 49, 54, 56, 58, 63, 63, 68, 69, 71, 74, 74, 57, 53, 52, 51,
+        50, 50, 55, 56, 59, 64, 64, 69, 70, 73, 76, 76, 57, 53, 52, 51, 50, 50,
+        55, 56, 59, 64, 64, 69, 70, 73, 76, 76, 59, 55, 54, 53, 52, 52, 57, 58,
+        61, 65, 65, 70, 72, 74, 78, 78,
         /* Size 32x16 */
-        64, 63, 63, 62, 61, 61, 66, 67, 70, 74, 74, 82, 84, 89, 98, 98, 97, 97,
-        97, 98, 98, 100, 101, 102, 104, 104, 108, 109, 111, 114, 114, 118, 62,
-        63, 63, 63, 64, 64, 69, 71, 74, 79, 79, 84, 85, 89, 94, 94, 93, 93, 92,
-        92, 92, 94, 95, 96, 97, 97, 101, 102, 103, 106, 106, 110, 62, 63, 63,
-        64, 64, 64, 70, 72, 75, 80, 80, 85, 86, 89, 93, 93, 92, 92, 91, 91, 91,
-        93, 93, 94, 96, 96, 99, 100, 102, 104, 104, 108, 66, 68, 68, 69, 70, 70,
-        75, 77, 80, 86, 86, 88, 89, 91, 94, 94, 93, 93, 92, 91, 91, 93, 93, 94,
-        95, 95, 98, 99, 101, 103, 103, 107, 74, 76, 77, 78, 80, 80, 85, 86, 89,
-        94, 94, 95, 95, 95, 96, 96, 94, 94, 93, 92, 92, 93, 93, 94, 95, 95, 97,
-        98, 99, 101, 101, 104, 74, 76, 77, 78, 80, 80, 85, 86, 89, 94, 94, 95,
-        95, 95, 96, 96, 94, 94, 93, 92, 92, 93, 93, 94, 95, 95, 97, 98, 99, 101,
-        101, 104, 91, 90, 90, 90, 89, 89, 92, 92, 93, 95, 95, 98, 99, 101, 104,
-        104, 103, 103, 103, 103, 103, 104, 105, 105, 106, 106, 108, 108, 109,
-        111, 111, 114, 96, 95, 94, 93, 92, 92, 94, 94, 95, 95, 95, 99, 100, 102,
-        106, 106, 106, 106, 106, 107, 107, 108, 108, 108, 109, 109, 111, 111,
-        112, 113, 113, 116, 97, 95, 94, 93, 91, 91, 93, 93, 93, 94, 94, 98, 100,
-        102, 106, 106, 108, 108, 109, 111, 111, 112, 112, 113, 114, 114, 116,
-        116, 117, 119, 119, 122, 98, 95, 94, 93, 91, 91, 91, 92, 91, 91, 91, 97,
-        99, 102, 107, 107, 111, 112, 114, 117, 117, 119, 119, 121, 122, 122,
-        124, 125, 126, 128, 128, 130, 98, 95, 94, 93, 91, 91, 91, 92, 91, 91,
-        91, 97, 99, 102, 107, 107, 111, 112, 114, 117, 117, 119, 119, 121, 122,
-        122, 124, 125, 126, 128, 128, 130, 103, 100, 99, 97, 95, 95, 95, 95, 94,
-        93, 93, 99, 101, 104, 109, 109, 113, 114, 117, 122, 122, 125, 126, 128,
-        131, 131, 134, 134, 136, 138, 138, 141, 105, 101, 100, 98, 96, 96, 95,
-        95, 95, 94, 94, 100, 101, 104, 109, 109, 114, 115, 118, 123, 123, 127,
-        128, 130, 133, 133, 136, 137, 139, 141, 141, 144, 109, 104, 103, 102,
-        99, 99, 98, 98, 97, 96, 96, 102, 103, 106, 111, 111, 116, 117, 120, 125,
-        125, 129, 130, 133, 137, 137, 140, 141, 143, 146, 146, 149, 115, 110,
-        109, 107, 104, 104, 103, 103, 102, 100, 100, 105, 107, 109, 114, 114,
-        119, 120, 123, 128, 128, 133, 134, 137, 142, 142, 146, 147, 149, 153,
-        153, 157, 115, 110, 109, 107, 104, 104, 103, 103, 102, 100, 100, 105,
-        107, 109, 114, 114, 119, 120, 123, 128, 128, 133, 134, 137, 142, 142,
-        146, 147, 149, 153, 153, 157,
+        32, 31, 31, 31, 30, 30, 33, 33, 35, 37, 37, 41, 42, 44, 49, 49, 48, 48,
+        48, 49, 49, 50, 50, 51, 52, 52, 54, 54, 55, 57, 57, 59, 31, 31, 31, 31,
+        32, 32, 34, 35, 37, 39, 39, 42, 42, 44, 47, 47, 46, 46, 46, 46, 46, 47,
+        47, 48, 48, 48, 50, 51, 51, 53, 53, 55, 31, 31, 31, 32, 32, 32, 35, 36,
+        37, 40, 40, 42, 43, 44, 46, 46, 46, 46, 45, 45, 45, 46, 46, 47, 48, 48,
+        49, 50, 51, 52, 52, 54, 33, 34, 34, 34, 35, 35, 37, 38, 40, 43, 43, 44,
+        44, 45, 47, 47, 46, 46, 46, 45, 45, 46, 46, 47, 47, 47, 49, 49, 50, 51,
+        51, 53, 37, 38, 38, 39, 40, 40, 42, 43, 44, 47, 47, 47, 47, 47, 48, 48,
+        47, 47, 46, 46, 46, 46, 46, 47, 47, 47, 48, 49, 49, 50, 50, 52, 37, 38,
+        38, 39, 40, 40, 42, 43, 44, 47, 47, 47, 47, 47, 48, 48, 47, 47, 46, 46,
+        46, 46, 46, 47, 47, 47, 48, 49, 49, 50, 50, 52, 45, 45, 45, 45, 44, 44,
+        46, 46, 46, 47, 47, 49, 49, 50, 52, 52, 51, 51, 51, 51, 51, 52, 52, 52,
+        53, 53, 54, 54, 54, 55, 55, 57, 48, 47, 47, 46, 46, 46, 47, 47, 47, 47,
+        47, 49, 50, 51, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 55, 55,
+        56, 56, 56, 58, 48, 47, 47, 46, 45, 45, 46, 46, 46, 47, 47, 49, 50, 51,
+        53, 53, 54, 54, 54, 55, 55, 56, 56, 56, 57, 57, 58, 58, 58, 59, 59, 61,
+        49, 47, 47, 46, 45, 45, 45, 46, 45, 45, 45, 48, 49, 51, 53, 53, 55, 56,
+        57, 58, 58, 59, 59, 60, 61, 61, 62, 62, 63, 64, 64, 65, 49, 47, 47, 46,
+        45, 45, 45, 46, 45, 45, 45, 48, 49, 51, 53, 53, 55, 56, 57, 58, 58, 59,
+        59, 60, 61, 61, 62, 62, 63, 64, 64, 65, 51, 50, 49, 48, 47, 47, 47, 47,
+        47, 46, 46, 49, 50, 52, 54, 54, 56, 57, 58, 61, 61, 62, 63, 64, 65, 65,
+        67, 67, 68, 69, 69, 70, 52, 50, 50, 49, 48, 48, 47, 47, 47, 47, 47, 50,
+        50, 52, 54, 54, 57, 57, 59, 61, 61, 63, 64, 65, 66, 66, 68, 68, 69, 70,
+        70, 72, 54, 52, 51, 51, 49, 49, 49, 49, 48, 48, 48, 51, 51, 53, 55, 55,
+        58, 58, 60, 62, 62, 64, 65, 66, 68, 68, 70, 70, 71, 73, 73, 74, 57, 55,
+        54, 53, 52, 52, 51, 51, 51, 50, 50, 52, 53, 54, 57, 57, 59, 60, 61, 64,
+        64, 66, 67, 68, 71, 71, 73, 73, 74, 76, 76, 78, 57, 55, 54, 53, 52, 52,
+        51, 51, 51, 50, 50, 52, 53, 54, 57, 57, 59, 60, 61, 64, 64, 66, 67, 68,
+        71, 71, 73, 73, 74, 76, 76, 78,
         /* Size 4x16 */
-        62, 74, 98, 109, 63, 77, 94, 103, 64, 80, 91, 99, 69, 85, 91, 98, 74,
-        89, 91, 97, 79, 94, 91, 96, 85, 95, 99, 103, 94, 96, 107, 111, 93, 94,
-        111, 116, 92, 93, 114, 120, 92, 92, 117, 125, 95, 93, 119, 130, 97, 95,
-        122, 137, 101, 97, 124, 140, 103, 99, 126, 143, 106, 101, 128, 146,
+        31, 37, 49, 54, 31, 38, 47, 51, 32, 40, 45, 49, 34, 42, 45, 49, 37, 44,
+        45, 48, 39, 47, 45, 48, 42, 47, 49, 51, 47, 48, 53, 55, 46, 47, 55, 58,
+        46, 46, 57, 60, 46, 46, 58, 62, 47, 46, 59, 65, 48, 47, 61, 68, 50, 48,
+        62, 70, 51, 49, 63, 71, 53, 50, 64, 73,
         /* Size 16x4 */
-        62, 63, 64, 69, 74, 79, 85, 94, 93, 92, 92, 95, 97, 101, 103, 106, 74,
-        77, 80, 85, 89, 94, 95, 96, 94, 93, 92, 93, 95, 97, 99, 101, 98, 94, 91,
-        91, 91, 91, 99, 107, 111, 114, 117, 119, 122, 124, 126, 128, 109, 103,
-        99, 98, 97, 96, 103, 111, 116, 120, 125, 130, 137, 140, 143, 146,
+        31, 31, 32, 34, 37, 39, 42, 47, 46, 46, 46, 47, 48, 50, 51, 53, 37, 38,
+        40, 42, 44, 47, 47, 48, 47, 46, 46, 46, 47, 48, 49, 50, 49, 47, 45, 45,
+        45, 45, 49, 53, 55, 57, 58, 59, 61, 62, 63, 64, 54, 51, 49, 49, 48, 48,
+        51, 55, 58, 60, 62, 65, 68, 70, 71, 73,
         /* Size 8x32 */
-        64, 62, 74, 91, 97, 98, 105, 115, 63, 63, 76, 90, 95, 95, 101, 110, 63,
-        63, 77, 90, 94, 94, 100, 109, 62, 64, 78, 90, 93, 93, 98, 107, 61, 64,
-        80, 89, 91, 91, 96, 104, 61, 64, 80, 89, 91, 91, 96, 104, 66, 70, 85,
-        92, 93, 91, 95, 103, 67, 72, 86, 92, 93, 92, 95, 103, 70, 75, 89, 93,
-        93, 91, 95, 102, 74, 80, 94, 95, 94, 91, 94, 100, 74, 80, 94, 95, 94,
-        91, 94, 100, 82, 85, 95, 98, 98, 97, 100, 105, 84, 86, 95, 99, 100, 99,
-        101, 107, 89, 89, 95, 101, 102, 102, 104, 109, 98, 93, 96, 104, 106,
-        107, 109, 114, 98, 93, 96, 104, 106, 107, 109, 114, 97, 92, 94, 103,
-        108, 111, 114, 119, 97, 92, 94, 103, 108, 112, 115, 120, 97, 91, 93,
-        103, 109, 114, 118, 123, 98, 91, 92, 103, 111, 117, 123, 128, 98, 91,
-        92, 103, 111, 117, 123, 128, 100, 93, 93, 104, 112, 119, 127, 133, 101,
-        93, 93, 105, 112, 119, 128, 134, 102, 94, 94, 105, 113, 121, 130, 137,
-        104, 96, 95, 106, 114, 122, 133, 142, 104, 96, 95, 106, 114, 122, 133,
-        142, 108, 99, 97, 108, 116, 124, 136, 146, 109, 100, 98, 108, 116, 125,
-        137, 147, 111, 102, 99, 109, 117, 126, 139, 149, 114, 104, 101, 111,
-        119, 128, 141, 153, 114, 104, 101, 111, 119, 128, 141, 153, 118, 108,
-        104, 114, 122, 130, 144, 157,
+        32, 31, 37, 45, 48, 49, 52, 57, 31, 31, 38, 45, 47, 47, 50, 55, 31, 31,
+        38, 45, 47, 47, 50, 54, 31, 32, 39, 45, 46, 46, 49, 53, 30, 32, 40, 44,
+        45, 45, 48, 52, 30, 32, 40, 44, 45, 45, 48, 52, 33, 35, 42, 46, 46, 45,
+        47, 51, 33, 36, 43, 46, 46, 46, 47, 51, 35, 37, 44, 46, 46, 45, 47, 51,
+        37, 40, 47, 47, 47, 45, 47, 50, 37, 40, 47, 47, 47, 45, 47, 50, 41, 42,
+        47, 49, 49, 48, 50, 52, 42, 43, 47, 49, 50, 49, 50, 53, 44, 44, 47, 50,
+        51, 51, 52, 54, 49, 46, 48, 52, 53, 53, 54, 57, 49, 46, 48, 52, 53, 53,
+        54, 57, 48, 46, 47, 51, 54, 55, 57, 59, 48, 46, 47, 51, 54, 56, 57, 60,
+        48, 45, 46, 51, 54, 57, 59, 61, 49, 45, 46, 51, 55, 58, 61, 64, 49, 45,
+        46, 51, 55, 58, 61, 64, 50, 46, 46, 52, 56, 59, 63, 66, 50, 46, 46, 52,
+        56, 59, 64, 67, 51, 47, 47, 52, 56, 60, 65, 68, 52, 48, 47, 53, 57, 61,
+        66, 71, 52, 48, 47, 53, 57, 61, 66, 71, 54, 49, 48, 54, 58, 62, 68, 73,
+        54, 50, 49, 54, 58, 62, 68, 73, 55, 51, 49, 54, 58, 63, 69, 74, 57, 52,
+        50, 55, 59, 64, 70, 76, 57, 52, 50, 55, 59, 64, 70, 76, 59, 54, 52, 57,
+        61, 65, 72, 78,
         /* Size 32x8 */
-        64, 63, 63, 62, 61, 61, 66, 67, 70, 74, 74, 82, 84, 89, 98, 98, 97, 97,
-        97, 98, 98, 100, 101, 102, 104, 104, 108, 109, 111, 114, 114, 118, 62,
-        63, 63, 64, 64, 64, 70, 72, 75, 80, 80, 85, 86, 89, 93, 93, 92, 92, 91,
-        91, 91, 93, 93, 94, 96, 96, 99, 100, 102, 104, 104, 108, 74, 76, 77, 78,
-        80, 80, 85, 86, 89, 94, 94, 95, 95, 95, 96, 96, 94, 94, 93, 92, 92, 93,
-        93, 94, 95, 95, 97, 98, 99, 101, 101, 104, 91, 90, 90, 90, 89, 89, 92,
-        92, 93, 95, 95, 98, 99, 101, 104, 104, 103, 103, 103, 103, 103, 104,
-        105, 105, 106, 106, 108, 108, 109, 111, 111, 114, 97, 95, 94, 93, 91,
-        91, 93, 93, 93, 94, 94, 98, 100, 102, 106, 106, 108, 108, 109, 111, 111,
-        112, 112, 113, 114, 114, 116, 116, 117, 119, 119, 122, 98, 95, 94, 93,
-        91, 91, 91, 92, 91, 91, 91, 97, 99, 102, 107, 107, 111, 112, 114, 117,
-        117, 119, 119, 121, 122, 122, 124, 125, 126, 128, 128, 130, 105, 101,
-        100, 98, 96, 96, 95, 95, 95, 94, 94, 100, 101, 104, 109, 109, 114, 115,
-        118, 123, 123, 127, 128, 130, 133, 133, 136, 137, 139, 141, 141, 144,
-        115, 110, 109, 107, 104, 104, 103, 103, 102, 100, 100, 105, 107, 109,
-        114, 114, 119, 120, 123, 128, 128, 133, 134, 137, 142, 142, 146, 147,
-        149, 153, 153, 157 },
+        32, 31, 31, 31, 30, 30, 33, 33, 35, 37, 37, 41, 42, 44, 49, 49, 48, 48,
+        48, 49, 49, 50, 50, 51, 52, 52, 54, 54, 55, 57, 57, 59, 31, 31, 31, 32,
+        32, 32, 35, 36, 37, 40, 40, 42, 43, 44, 46, 46, 46, 46, 45, 45, 45, 46,
+        46, 47, 48, 48, 49, 50, 51, 52, 52, 54, 37, 38, 38, 39, 40, 40, 42, 43,
+        44, 47, 47, 47, 47, 47, 48, 48, 47, 47, 46, 46, 46, 46, 46, 47, 47, 47,
+        48, 49, 49, 50, 50, 52, 45, 45, 45, 45, 44, 44, 46, 46, 46, 47, 47, 49,
+        49, 50, 52, 52, 51, 51, 51, 51, 51, 52, 52, 52, 53, 53, 54, 54, 54, 55,
+        55, 57, 48, 47, 47, 46, 45, 45, 46, 46, 46, 47, 47, 49, 50, 51, 53, 53,
+        54, 54, 54, 55, 55, 56, 56, 56, 57, 57, 58, 58, 58, 59, 59, 61, 49, 47,
+        47, 46, 45, 45, 45, 46, 45, 45, 45, 48, 49, 51, 53, 53, 55, 56, 57, 58,
+        58, 59, 59, 60, 61, 61, 62, 62, 63, 64, 64, 65, 52, 50, 50, 49, 48, 48,
+        47, 47, 47, 47, 47, 50, 50, 52, 54, 54, 57, 57, 59, 61, 61, 63, 64, 65,
+        66, 66, 68, 68, 69, 70, 70, 72, 57, 55, 54, 53, 52, 52, 51, 51, 51, 50,
+        50, 52, 53, 54, 57, 57, 59, 60, 61, 64, 64, 66, 67, 68, 71, 71, 73, 73,
+        74, 76, 76, 78 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        66, 85, 85, 128,
+        33, 42, 42, 64,
 #endif
         /* Size 4x4 */
-        64, 65, 77, 102, 65, 71, 81, 98, 77, 81, 108, 129, 102, 98, 129, 162,
+        32, 32, 38, 51, 32, 35, 40, 49, 38, 40, 54, 64, 51, 49, 64, 81,
         /* Size 8x8 */
-        63, 64, 64, 68, 71, 83, 94, 107, 64, 65, 65, 67, 69, 80, 89, 101, 64,
-        65, 68, 71, 74, 83, 91, 102, 68, 67, 71, 79, 85, 94, 102, 111, 71, 69,
-        74, 85, 97, 106, 114, 122, 83, 80, 83, 94, 106, 120, 130, 141, 94, 89,
-        91, 102, 114, 130, 142, 155, 107, 101, 102, 111, 122, 141, 155, 170,
+        31, 32, 32, 34, 35, 41, 47, 53, 32, 32, 32, 33, 34, 40, 44, 50, 32, 32,
+        34, 35, 37, 41, 45, 51, 34, 33, 35, 39, 42, 47, 51, 55, 35, 34, 37, 42,
+        48, 53, 57, 61, 41, 40, 41, 47, 53, 60, 65, 70, 47, 44, 45, 51, 57, 65,
+        71, 77, 53, 50, 51, 55, 61, 70, 77, 85,
         /* Size 16x16 */
-        64, 63, 63, 63, 63, 64, 65, 68, 72, 76, 79, 88, 95, 99, 108, 118, 63,
-        64, 64, 64, 64, 65, 66, 68, 70, 74, 77, 85, 91, 95, 103, 113, 63, 64,
-        64, 65, 65, 65, 66, 67, 69, 73, 75, 82, 88, 92, 100, 109, 63, 64, 65,
-        65, 65, 66, 67, 68, 70, 73, 76, 82, 88, 91, 99, 108, 63, 64, 65, 65, 67,
-        68, 69, 71, 73, 76, 78, 84, 90, 93, 100, 108, 64, 65, 65, 66, 68, 71,
-        72, 74, 77, 79, 81, 85, 90, 93, 99, 107, 65, 66, 66, 67, 69, 72, 73, 76,
-        80, 82, 84, 89, 94, 97, 103, 111, 68, 68, 67, 68, 71, 74, 76, 79, 85,
-        88, 90, 95, 100, 103, 109, 117, 72, 70, 69, 70, 73, 77, 80, 85, 97, 100,
-        101, 108, 112, 115, 120, 128, 76, 74, 73, 73, 76, 79, 82, 88, 100, 103,
-        105, 112, 117, 120, 126, 134, 79, 77, 75, 76, 78, 81, 84, 90, 101, 105,
-        108, 116, 121, 124, 130, 138, 88, 85, 82, 82, 84, 85, 89, 95, 108, 112,
-        116, 127, 133, 136, 143, 151, 95, 91, 88, 88, 90, 90, 94, 100, 112, 117,
-        121, 133, 139, 142, 151, 159, 99, 95, 92, 91, 93, 93, 97, 103, 115, 120,
-        124, 136, 142, 146, 155, 163, 108, 103, 100, 99, 100, 99, 103, 109, 120,
-        126, 130, 143, 151, 155, 165, 174, 118, 113, 109, 108, 108, 107, 111,
-        117, 128, 134, 138, 151, 159, 163, 174, 184,
+        32, 31, 31, 31, 31, 32, 32, 34, 36, 38, 39, 44, 47, 49, 54, 59, 31, 32,
+        32, 32, 32, 32, 33, 34, 35, 37, 38, 42, 45, 47, 51, 56, 31, 32, 32, 32,
+        32, 32, 33, 33, 34, 36, 37, 41, 44, 46, 50, 54, 31, 32, 32, 32, 32, 33,
+        33, 34, 35, 36, 38, 41, 44, 45, 49, 54, 31, 32, 32, 32, 33, 34, 34, 35,
+        36, 38, 39, 42, 45, 46, 50, 54, 32, 32, 32, 33, 34, 35, 36, 37, 38, 39,
+        40, 42, 45, 46, 49, 53, 32, 33, 33, 33, 34, 36, 36, 38, 40, 41, 42, 44,
+        47, 48, 51, 55, 34, 34, 33, 34, 35, 37, 38, 39, 42, 44, 45, 47, 50, 51,
+        54, 58, 36, 35, 34, 35, 36, 38, 40, 42, 48, 50, 50, 54, 56, 57, 60, 64,
+        38, 37, 36, 36, 38, 39, 41, 44, 50, 51, 52, 56, 58, 60, 63, 67, 39, 38,
+        37, 38, 39, 40, 42, 45, 50, 52, 54, 58, 60, 62, 65, 69, 44, 42, 41, 41,
+        42, 42, 44, 47, 54, 56, 58, 63, 66, 68, 71, 75, 47, 45, 44, 44, 45, 45,
+        47, 50, 56, 58, 60, 66, 69, 71, 75, 79, 49, 47, 46, 45, 46, 46, 48, 51,
+        57, 60, 62, 68, 71, 73, 77, 81, 54, 51, 50, 49, 50, 49, 51, 54, 60, 63,
+        65, 71, 75, 77, 82, 87, 59, 56, 54, 54, 54, 53, 55, 58, 64, 67, 69, 75,
+        79, 81, 87, 92,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 65, 68, 68, 70, 72, 72,
-        76, 79, 79, 85, 88, 89, 95, 97, 99, 107, 108, 111, 118, 118, 63, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 66, 68, 68, 69, 71, 71, 75, 78, 78,
-        83, 86, 87, 92, 94, 96, 103, 104, 107, 114, 114, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 66, 68, 68, 69, 70, 70, 74, 77, 77, 82, 85, 86,
-        91, 93, 95, 102, 103, 106, 113, 113, 63, 63, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 66, 68, 68, 69, 70, 70, 74, 77, 77, 82, 84, 85, 91, 93, 94,
-        102, 103, 105, 112, 112, 63, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65,
-        66, 67, 67, 68, 69, 69, 73, 75, 75, 80, 82, 83, 88, 90, 92, 99, 100,
-        102, 109, 109, 63, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 67,
-        67, 68, 69, 69, 72, 75, 75, 80, 82, 82, 88, 89, 91, 98, 99, 101, 108,
-        108, 63, 64, 64, 64, 65, 65, 65, 65, 65, 66, 66, 66, 67, 68, 68, 69, 70,
-        70, 73, 76, 76, 80, 82, 83, 88, 90, 91, 98, 99, 101, 108, 108, 63, 64,
-        64, 64, 65, 65, 65, 66, 66, 67, 68, 68, 69, 70, 70, 71, 73, 73, 76, 78,
-        78, 82, 84, 85, 89, 91, 93, 99, 100, 102, 108, 108, 63, 64, 64, 64, 65,
-        65, 65, 66, 67, 67, 68, 68, 69, 71, 71, 72, 73, 73, 76, 78, 78, 82, 84,
-        85, 90, 91, 93, 99, 100, 102, 108, 108, 64, 64, 64, 65, 65, 65, 66, 67,
-        67, 68, 69, 69, 70, 71, 71, 73, 74, 74, 77, 79, 79, 83, 84, 85, 90, 91,
-        93, 99, 99, 102, 108, 108, 64, 64, 65, 65, 65, 65, 66, 68, 68, 69, 71,
-        71, 72, 74, 74, 75, 77, 77, 79, 81, 81, 84, 85, 86, 90, 92, 93, 98, 99,
-        101, 107, 107, 64, 64, 65, 65, 65, 65, 66, 68, 68, 69, 71, 71, 72, 74,
-        74, 75, 77, 77, 79, 81, 81, 84, 85, 86, 90, 92, 93, 98, 99, 101, 107,
-        107, 65, 66, 66, 66, 66, 66, 67, 69, 69, 70, 72, 72, 73, 76, 76, 78, 80,
-        80, 82, 84, 84, 88, 89, 90, 94, 95, 97, 102, 103, 105, 111, 111, 68, 68,
-        68, 68, 67, 67, 68, 70, 71, 71, 74, 74, 76, 79, 79, 82, 85, 85, 88, 90,
-        90, 94, 95, 96, 100, 102, 103, 108, 109, 111, 117, 117, 68, 68, 68, 68,
-        67, 67, 68, 70, 71, 71, 74, 74, 76, 79, 79, 82, 85, 85, 88, 90, 90, 94,
-        95, 96, 100, 102, 103, 108, 109, 111, 117, 117, 70, 69, 69, 69, 68, 68,
-        69, 71, 72, 73, 75, 75, 78, 82, 82, 86, 91, 91, 94, 95, 95, 99, 101,
-        102, 106, 107, 109, 114, 114, 116, 122, 122, 72, 71, 70, 70, 69, 69, 70,
-        73, 73, 74, 77, 77, 80, 85, 85, 91, 97, 97, 100, 101, 101, 106, 108,
-        108, 112, 114, 115, 119, 120, 122, 128, 128, 72, 71, 70, 70, 69, 69, 70,
-        73, 73, 74, 77, 77, 80, 85, 85, 91, 97, 97, 100, 101, 101, 106, 108,
-        108, 112, 114, 115, 119, 120, 122, 128, 128, 76, 75, 74, 74, 73, 72, 73,
-        76, 76, 77, 79, 79, 82, 88, 88, 94, 100, 100, 103, 105, 105, 110, 112,
-        113, 117, 119, 120, 125, 126, 128, 134, 134, 79, 78, 77, 77, 75, 75, 76,
-        78, 78, 79, 81, 81, 84, 90, 90, 95, 101, 101, 105, 108, 108, 113, 116,
-        117, 121, 122, 124, 129, 130, 132, 138, 138, 79, 78, 77, 77, 75, 75, 76,
-        78, 78, 79, 81, 81, 84, 90, 90, 95, 101, 101, 105, 108, 108, 113, 116,
-        117, 121, 122, 124, 129, 130, 132, 138, 138, 85, 83, 82, 82, 80, 80, 80,
-        82, 82, 83, 84, 84, 88, 94, 94, 99, 106, 106, 110, 113, 113, 120, 123,
-        124, 129, 130, 132, 138, 139, 141, 147, 147, 88, 86, 85, 84, 82, 82, 82,
-        84, 84, 84, 85, 85, 89, 95, 95, 101, 108, 108, 112, 116, 116, 123, 127,
-        128, 133, 134, 136, 142, 143, 145, 151, 151, 89, 87, 86, 85, 83, 82, 83,
-        85, 85, 85, 86, 86, 90, 96, 96, 102, 108, 108, 113, 117, 117, 124, 128,
-        128, 133, 135, 137, 143, 144, 146, 152, 152, 95, 92, 91, 91, 88, 88, 88,
-        89, 90, 90, 90, 90, 94, 100, 100, 106, 112, 112, 117, 121, 121, 129,
-        133, 133, 139, 141, 142, 149, 151, 153, 159, 159, 97, 94, 93, 93, 90,
-        89, 90, 91, 91, 91, 92, 92, 95, 102, 102, 107, 114, 114, 119, 122, 122,
-        130, 134, 135, 141, 142, 144, 151, 153, 155, 161, 161, 99, 96, 95, 94,
-        92, 91, 91, 93, 93, 93, 93, 93, 97, 103, 103, 109, 115, 115, 120, 124,
-        124, 132, 136, 137, 142, 144, 146, 154, 155, 157, 163, 163, 107, 103,
-        102, 102, 99, 98, 98, 99, 99, 99, 98, 98, 102, 108, 108, 114, 119, 119,
-        125, 129, 129, 138, 142, 143, 149, 151, 154, 162, 163, 166, 173, 173,
-        108, 104, 103, 103, 100, 99, 99, 100, 100, 99, 99, 99, 103, 109, 109,
-        114, 120, 120, 126, 130, 130, 139, 143, 144, 151, 153, 155, 163, 165,
-        167, 174, 174, 111, 107, 106, 105, 102, 101, 101, 102, 102, 102, 101,
-        101, 105, 111, 111, 116, 122, 122, 128, 132, 132, 141, 145, 146, 153,
-        155, 157, 166, 167, 170, 177, 177, 118, 114, 113, 112, 109, 108, 108,
-        108, 108, 108, 107, 107, 111, 117, 117, 122, 128, 128, 134, 138, 138,
-        147, 151, 152, 159, 161, 163, 173, 174, 177, 184, 184, 118, 114, 113,
-        112, 109, 108, 108, 108, 108, 108, 107, 107, 111, 117, 117, 122, 128,
-        128, 134, 138, 138, 147, 151, 152, 159, 161, 163, 173, 174, 177, 184,
-        184,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 34, 35, 36, 36,
+        38, 39, 39, 42, 44, 44, 47, 48, 49, 53, 54, 55, 59, 59, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 35, 35, 37, 39, 39, 41,
+        43, 43, 46, 47, 48, 51, 52, 53, 57, 57, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 34, 34, 34, 35, 35, 37, 38, 38, 41, 42, 43, 45, 46,
+        47, 51, 51, 53, 56, 56, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 34, 34, 34, 35, 35, 37, 38, 38, 41, 42, 42, 45, 46, 47, 51, 51, 52,
+        56, 56, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34,
+        34, 34, 36, 37, 37, 40, 41, 41, 44, 45, 46, 49, 50, 51, 54, 54, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 36, 37,
+        37, 40, 41, 41, 44, 44, 45, 49, 49, 50, 54, 54, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35, 35, 36, 38, 38, 40, 41, 41,
+        44, 45, 45, 49, 49, 50, 54, 54, 31, 32, 32, 32, 32, 32, 32, 33, 33, 33,
+        34, 34, 34, 35, 35, 35, 36, 36, 38, 39, 39, 41, 42, 42, 44, 45, 46, 49,
+        50, 51, 54, 54, 31, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35,
+        35, 36, 36, 36, 38, 39, 39, 41, 42, 42, 45, 45, 46, 49, 50, 51, 54, 54,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 37, 37,
+        38, 39, 39, 41, 42, 42, 45, 45, 46, 49, 49, 51, 54, 54, 32, 32, 32, 32,
+        32, 32, 33, 34, 34, 34, 35, 35, 36, 37, 37, 37, 38, 38, 39, 40, 40, 42,
+        42, 43, 45, 46, 46, 49, 49, 50, 53, 53, 32, 32, 32, 32, 32, 32, 33, 34,
+        34, 34, 35, 35, 36, 37, 37, 37, 38, 38, 39, 40, 40, 42, 42, 43, 45, 46,
+        46, 49, 49, 50, 53, 53, 32, 33, 33, 33, 33, 33, 33, 34, 34, 35, 36, 36,
+        36, 38, 38, 39, 40, 40, 41, 42, 42, 44, 44, 45, 47, 47, 48, 51, 51, 52,
+        55, 55, 34, 34, 34, 34, 33, 33, 34, 35, 35, 35, 37, 37, 38, 39, 39, 41,
+        42, 42, 44, 45, 45, 47, 47, 48, 50, 51, 51, 54, 54, 55, 58, 58, 34, 34,
+        34, 34, 33, 33, 34, 35, 35, 35, 37, 37, 38, 39, 39, 41, 42, 42, 44, 45,
+        45, 47, 47, 48, 50, 51, 51, 54, 54, 55, 58, 58, 35, 34, 34, 34, 34, 34,
+        34, 35, 36, 36, 37, 37, 39, 41, 41, 43, 45, 45, 47, 47, 47, 49, 50, 51,
+        53, 53, 54, 57, 57, 58, 61, 61, 36, 35, 35, 35, 34, 34, 35, 36, 36, 37,
+        38, 38, 40, 42, 42, 45, 48, 48, 50, 50, 50, 53, 54, 54, 56, 57, 57, 59,
+        60, 61, 64, 64, 36, 35, 35, 35, 34, 34, 35, 36, 36, 37, 38, 38, 40, 42,
+        42, 45, 48, 48, 50, 50, 50, 53, 54, 54, 56, 57, 57, 59, 60, 61, 64, 64,
+        38, 37, 37, 37, 36, 36, 36, 38, 38, 38, 39, 39, 41, 44, 44, 47, 50, 50,
+        51, 52, 52, 55, 56, 56, 58, 59, 60, 62, 63, 64, 67, 67, 39, 39, 38, 38,
+        37, 37, 38, 39, 39, 39, 40, 40, 42, 45, 45, 47, 50, 50, 52, 54, 54, 56,
+        58, 58, 60, 61, 62, 64, 65, 66, 69, 69, 39, 39, 38, 38, 37, 37, 38, 39,
+        39, 39, 40, 40, 42, 45, 45, 47, 50, 50, 52, 54, 54, 56, 58, 58, 60, 61,
+        62, 64, 65, 66, 69, 69, 42, 41, 41, 41, 40, 40, 40, 41, 41, 41, 42, 42,
+        44, 47, 47, 49, 53, 53, 55, 56, 56, 60, 61, 62, 64, 65, 66, 69, 69, 70,
+        73, 73, 44, 43, 42, 42, 41, 41, 41, 42, 42, 42, 42, 42, 44, 47, 47, 50,
+        54, 54, 56, 58, 58, 61, 63, 64, 66, 67, 68, 71, 71, 72, 75, 75, 44, 43,
+        43, 42, 41, 41, 41, 42, 42, 42, 43, 43, 45, 48, 48, 51, 54, 54, 56, 58,
+        58, 62, 64, 64, 66, 67, 68, 71, 72, 73, 76, 76, 47, 46, 45, 45, 44, 44,
+        44, 44, 45, 45, 45, 45, 47, 50, 50, 53, 56, 56, 58, 60, 60, 64, 66, 66,
+        69, 70, 71, 74, 75, 76, 79, 79, 48, 47, 46, 46, 45, 44, 45, 45, 45, 45,
+        46, 46, 47, 51, 51, 53, 57, 57, 59, 61, 61, 65, 67, 67, 70, 71, 72, 75,
+        76, 77, 80, 80, 49, 48, 47, 47, 46, 45, 45, 46, 46, 46, 46, 46, 48, 51,
+        51, 54, 57, 57, 60, 62, 62, 66, 68, 68, 71, 72, 73, 77, 77, 78, 81, 81,
+        53, 51, 51, 51, 49, 49, 49, 49, 49, 49, 49, 49, 51, 54, 54, 57, 59, 59,
+        62, 64, 64, 69, 71, 71, 74, 75, 77, 81, 81, 83, 86, 86, 54, 52, 51, 51,
+        50, 49, 49, 50, 50, 49, 49, 49, 51, 54, 54, 57, 60, 60, 63, 65, 65, 69,
+        71, 72, 75, 76, 77, 81, 82, 83, 87, 87, 55, 53, 53, 52, 51, 50, 50, 51,
+        51, 51, 50, 50, 52, 55, 55, 58, 61, 61, 64, 66, 66, 70, 72, 73, 76, 77,
+        78, 83, 83, 85, 88, 88, 59, 57, 56, 56, 54, 54, 54, 54, 54, 54, 53, 53,
+        55, 58, 58, 61, 64, 64, 67, 69, 69, 73, 75, 76, 79, 80, 81, 86, 87, 88,
+        92, 92, 59, 57, 56, 56, 54, 54, 54, 54, 54, 54, 53, 53, 55, 58, 58, 61,
+        64, 64, 67, 69, 69, 73, 75, 76, 79, 80, 81, 86, 87, 88, 92, 92,
         /* Size 4x8 */
-        64, 65, 75, 104, 64, 66, 73, 99, 65, 69, 77, 99, 68, 74, 88, 109, 70,
-        77, 99, 120, 81, 85, 110, 139, 92, 93, 119, 152, 104, 102, 128, 167,
+        32, 32, 37, 52, 32, 33, 36, 49, 32, 34, 38, 49, 34, 37, 44, 54, 35, 38,
+        49, 60, 40, 42, 55, 69, 46, 46, 59, 76, 52, 51, 64, 83,
         /* Size 8x4 */
-        64, 64, 65, 68, 70, 81, 92, 104, 65, 66, 69, 74, 77, 85, 93, 102, 75,
-        73, 77, 88, 99, 110, 119, 128, 104, 99, 99, 109, 120, 139, 152, 167,
+        32, 32, 32, 34, 35, 40, 46, 52, 32, 33, 34, 37, 38, 42, 46, 51, 37, 36,
+        38, 44, 49, 55, 59, 64, 52, 49, 49, 54, 60, 69, 76, 83,
         /* Size 8x16 */
-        64, 63, 64, 65, 72, 88, 95, 107, 63, 64, 65, 66, 71, 85, 91, 103, 63,
-        65, 65, 66, 70, 82, 88, 99, 63, 65, 66, 67, 70, 82, 88, 99, 64, 65, 68,
-        69, 73, 84, 90, 100, 64, 66, 70, 72, 77, 85, 90, 99, 65, 66, 71, 73, 80,
-        89, 94, 103, 68, 68, 72, 76, 85, 96, 101, 109, 72, 69, 75, 80, 96, 108,
-        112, 120, 76, 73, 78, 83, 99, 112, 117, 126, 79, 75, 80, 85, 101, 116,
-        121, 130, 88, 82, 85, 90, 107, 126, 132, 143, 94, 88, 91, 95, 112, 132,
-        139, 150, 98, 92, 94, 97, 114, 135, 142, 155, 107, 99, 100, 103, 120,
-        142, 150, 164, 117, 108, 108, 111, 127, 150, 159, 174,
+        32, 31, 32, 32, 36, 44, 47, 53, 31, 32, 32, 33, 35, 42, 45, 51, 31, 32,
+        32, 33, 35, 41, 44, 49, 31, 32, 33, 33, 35, 41, 44, 49, 32, 32, 34, 34,
+        36, 42, 45, 50, 32, 33, 35, 36, 38, 42, 45, 49, 32, 33, 35, 36, 40, 44,
+        47, 51, 34, 34, 36, 38, 42, 48, 50, 54, 36, 34, 37, 40, 48, 54, 56, 60,
+        38, 36, 39, 41, 49, 56, 58, 63, 39, 37, 40, 42, 50, 58, 60, 65, 44, 41,
+        42, 45, 53, 63, 66, 71, 47, 44, 45, 47, 56, 66, 69, 75, 49, 46, 47, 48,
+        57, 67, 71, 77, 53, 49, 50, 51, 60, 71, 75, 82, 58, 54, 54, 55, 63, 75,
+        79, 87,
         /* Size 16x8 */
-        64, 63, 63, 63, 64, 64, 65, 68, 72, 76, 79, 88, 94, 98, 107, 117, 63,
-        64, 65, 65, 65, 66, 66, 68, 69, 73, 75, 82, 88, 92, 99, 108, 64, 65, 65,
-        66, 68, 70, 71, 72, 75, 78, 80, 85, 91, 94, 100, 108, 65, 66, 66, 67,
-        69, 72, 73, 76, 80, 83, 85, 90, 95, 97, 103, 111, 72, 71, 70, 70, 73,
-        77, 80, 85, 96, 99, 101, 107, 112, 114, 120, 127, 88, 85, 82, 82, 84,
-        85, 89, 96, 108, 112, 116, 126, 132, 135, 142, 150, 95, 91, 88, 88, 90,
-        90, 94, 101, 112, 117, 121, 132, 139, 142, 150, 159, 107, 103, 99, 99,
-        100, 99, 103, 109, 120, 126, 130, 143, 150, 155, 164, 174,
+        32, 31, 31, 31, 32, 32, 32, 34, 36, 38, 39, 44, 47, 49, 53, 58, 31, 32,
+        32, 32, 32, 33, 33, 34, 34, 36, 37, 41, 44, 46, 49, 54, 32, 32, 32, 33,
+        34, 35, 35, 36, 37, 39, 40, 42, 45, 47, 50, 54, 32, 33, 33, 33, 34, 36,
+        36, 38, 40, 41, 42, 45, 47, 48, 51, 55, 36, 35, 35, 35, 36, 38, 40, 42,
+        48, 49, 50, 53, 56, 57, 60, 63, 44, 42, 41, 41, 42, 42, 44, 48, 54, 56,
+        58, 63, 66, 67, 71, 75, 47, 45, 44, 44, 45, 45, 47, 50, 56, 58, 60, 66,
+        69, 71, 75, 79, 53, 51, 49, 49, 50, 49, 51, 54, 60, 63, 65, 71, 75, 77,
+        82, 87,
         /* Size 16x32 */
-        64, 63, 63, 63, 64, 64, 65, 71, 72, 76, 88, 88, 95, 107, 107, 118, 63,
-        64, 64, 64, 64, 65, 66, 70, 71, 75, 86, 86, 92, 104, 104, 114, 63, 64,
-        64, 64, 65, 65, 66, 70, 71, 74, 85, 85, 91, 103, 103, 113, 63, 64, 64,
-        64, 65, 65, 66, 70, 71, 74, 84, 84, 91, 102, 102, 112, 63, 64, 65, 65,
-        65, 65, 66, 69, 70, 73, 82, 82, 88, 99, 99, 109, 63, 64, 65, 65, 65, 66,
-        66, 69, 69, 73, 82, 82, 88, 99, 99, 108, 63, 64, 65, 65, 66, 66, 67, 70,
-        70, 73, 82, 82, 88, 99, 99, 108, 64, 65, 65, 65, 67, 68, 69, 72, 73, 76,
-        84, 84, 90, 99, 99, 108, 64, 65, 65, 66, 68, 68, 69, 73, 73, 76, 84, 84,
-        90, 100, 100, 108, 64, 65, 65, 66, 68, 69, 70, 74, 74, 77, 85, 85, 90,
-        99, 99, 108, 64, 65, 66, 66, 70, 71, 72, 76, 77, 79, 85, 85, 90, 99, 99,
-        107, 64, 65, 66, 66, 70, 71, 72, 76, 77, 79, 85, 85, 90, 99, 99, 107,
-        65, 66, 66, 67, 71, 72, 73, 79, 80, 83, 89, 89, 94, 103, 103, 111, 68,
-        68, 68, 68, 72, 74, 76, 84, 85, 88, 96, 96, 101, 109, 109, 117, 68, 68,
-        68, 68, 72, 74, 76, 84, 85, 88, 96, 96, 101, 109, 109, 117, 70, 69, 69,
-        69, 74, 75, 78, 89, 90, 93, 101, 101, 106, 114, 114, 122, 72, 70, 69,
-        70, 75, 77, 80, 94, 96, 99, 108, 108, 112, 120, 120, 128, 72, 70, 69,
-        70, 75, 77, 80, 94, 96, 99, 108, 108, 112, 120, 120, 128, 76, 74, 73,
-        74, 78, 80, 83, 97, 99, 103, 112, 112, 117, 126, 126, 134, 79, 76, 75,
-        76, 80, 81, 85, 98, 101, 105, 116, 116, 121, 130, 130, 138, 79, 76, 75,
-        76, 80, 81, 85, 98, 101, 105, 116, 116, 121, 130, 130, 138, 85, 81, 80,
-        81, 84, 85, 88, 103, 105, 110, 123, 123, 129, 139, 139, 147, 88, 84, 82,
-        83, 85, 86, 90, 105, 107, 112, 126, 126, 132, 143, 143, 151, 88, 85, 83,
-        83, 86, 87, 90, 105, 108, 113, 127, 127, 133, 144, 144, 152, 94, 90, 88,
-        89, 91, 91, 95, 109, 112, 117, 132, 132, 139, 150, 150, 159, 96, 92, 90,
-        90, 92, 93, 96, 111, 113, 119, 134, 134, 140, 152, 152, 161, 98, 94, 92,
-        92, 94, 94, 97, 112, 114, 120, 135, 135, 142, 155, 155, 163, 106, 100,
-        98, 98, 99, 99, 103, 117, 119, 125, 142, 142, 149, 163, 163, 173, 107,
-        102, 99, 99, 100, 100, 103, 118, 120, 126, 142, 142, 150, 164, 164, 174,
-        110, 104, 102, 102, 102, 102, 106, 120, 122, 128, 145, 145, 153, 167,
-        167, 177, 117, 111, 108, 108, 108, 108, 111, 125, 127, 134, 150, 150,
-        159, 174, 174, 184, 117, 111, 108, 108, 108, 108, 111, 125, 127, 134,
-        150, 150, 159, 174, 174, 184,
+        32, 31, 31, 31, 32, 32, 32, 35, 36, 38, 44, 44, 47, 53, 53, 59, 31, 32,
+        32, 32, 32, 32, 33, 35, 35, 37, 43, 43, 46, 52, 52, 57, 31, 32, 32, 32,
+        32, 32, 33, 35, 35, 37, 42, 42, 45, 51, 51, 56, 31, 32, 32, 32, 32, 32,
+        33, 35, 35, 37, 42, 42, 45, 51, 51, 56, 31, 32, 32, 32, 32, 32, 33, 34,
+        35, 36, 41, 41, 44, 49, 49, 54, 31, 32, 32, 32, 32, 33, 33, 34, 34, 36,
+        41, 41, 44, 49, 49, 54, 31, 32, 32, 32, 33, 33, 33, 35, 35, 36, 41, 41,
+        44, 49, 49, 54, 32, 32, 32, 32, 33, 34, 34, 36, 36, 38, 42, 42, 45, 49,
+        49, 54, 32, 32, 32, 33, 34, 34, 34, 36, 36, 38, 42, 42, 45, 50, 50, 54,
+        32, 32, 32, 33, 34, 34, 35, 37, 37, 38, 42, 42, 45, 49, 49, 54, 32, 32,
+        33, 33, 35, 35, 36, 38, 38, 39, 42, 42, 45, 49, 49, 53, 32, 32, 33, 33,
+        35, 35, 36, 38, 38, 39, 42, 42, 45, 49, 49, 53, 32, 33, 33, 33, 35, 36,
+        36, 39, 40, 41, 44, 44, 47, 51, 51, 55, 34, 34, 34, 34, 36, 37, 38, 42,
+        42, 44, 48, 48, 50, 54, 54, 58, 34, 34, 34, 34, 36, 37, 38, 42, 42, 44,
+        48, 48, 50, 54, 54, 58, 35, 34, 34, 34, 37, 37, 39, 44, 45, 46, 50, 50,
+        53, 57, 57, 61, 36, 35, 34, 35, 37, 38, 40, 47, 48, 49, 54, 54, 56, 60,
+        60, 64, 36, 35, 34, 35, 37, 38, 40, 47, 48, 49, 54, 54, 56, 60, 60, 64,
+        38, 37, 36, 37, 39, 40, 41, 48, 49, 51, 56, 56, 58, 63, 63, 67, 39, 38,
+        37, 38, 40, 40, 42, 49, 50, 52, 58, 58, 60, 65, 65, 69, 39, 38, 37, 38,
+        40, 40, 42, 49, 50, 52, 58, 58, 60, 65, 65, 69, 42, 40, 40, 40, 42, 42,
+        44, 51, 52, 55, 61, 61, 64, 69, 69, 73, 44, 42, 41, 41, 42, 43, 45, 52,
+        53, 56, 63, 63, 66, 71, 71, 75, 44, 42, 41, 41, 43, 43, 45, 52, 54, 56,
+        63, 63, 66, 72, 72, 76, 47, 45, 44, 44, 45, 45, 47, 54, 56, 58, 66, 66,
+        69, 75, 75, 79, 48, 46, 45, 45, 46, 46, 48, 55, 56, 59, 67, 67, 70, 76,
+        76, 80, 49, 47, 46, 46, 47, 47, 48, 56, 57, 60, 67, 67, 71, 77, 77, 81,
+        53, 50, 49, 49, 49, 49, 51, 58, 59, 62, 71, 71, 74, 81, 81, 86, 53, 51,
+        49, 49, 50, 50, 51, 59, 60, 63, 71, 71, 75, 82, 82, 87, 55, 52, 51, 51,
+        51, 51, 53, 60, 61, 64, 72, 72, 76, 83, 83, 88, 58, 55, 54, 54, 54, 54,
+        55, 62, 63, 67, 75, 75, 79, 87, 87, 92, 58, 55, 54, 54, 54, 54, 55, 62,
+        63, 67, 75, 75, 79, 87, 87, 92,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 65, 68, 68, 70, 72, 72,
-        76, 79, 79, 85, 88, 88, 94, 96, 98, 106, 107, 110, 117, 117, 63, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 66, 68, 68, 69, 70, 70, 74, 76, 76,
-        81, 84, 85, 90, 92, 94, 100, 102, 104, 111, 111, 63, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 68, 68, 69, 69, 69, 73, 75, 75, 80, 82, 83,
-        88, 90, 92, 98, 99, 102, 108, 108, 63, 64, 64, 64, 65, 65, 65, 65, 66,
-        66, 66, 66, 67, 68, 68, 69, 70, 70, 74, 76, 76, 81, 83, 83, 89, 90, 92,
-        98, 99, 102, 108, 108, 64, 64, 65, 65, 65, 65, 66, 67, 68, 68, 70, 70,
-        71, 72, 72, 74, 75, 75, 78, 80, 80, 84, 85, 86, 91, 92, 94, 99, 100,
-        102, 108, 108, 64, 65, 65, 65, 65, 66, 66, 68, 68, 69, 71, 71, 72, 74,
-        74, 75, 77, 77, 80, 81, 81, 85, 86, 87, 91, 93, 94, 99, 100, 102, 108,
-        108, 65, 66, 66, 66, 66, 66, 67, 69, 69, 70, 72, 72, 73, 76, 76, 78, 80,
-        80, 83, 85, 85, 88, 90, 90, 95, 96, 97, 103, 103, 106, 111, 111, 71, 70,
-        70, 70, 69, 69, 70, 72, 73, 74, 76, 76, 79, 84, 84, 89, 94, 94, 97, 98,
-        98, 103, 105, 105, 109, 111, 112, 117, 118, 120, 125, 125, 72, 71, 71,
-        71, 70, 69, 70, 73, 73, 74, 77, 77, 80, 85, 85, 90, 96, 96, 99, 101,
-        101, 105, 107, 108, 112, 113, 114, 119, 120, 122, 127, 127, 76, 75, 74,
-        74, 73, 73, 73, 76, 76, 77, 79, 79, 83, 88, 88, 93, 99, 99, 103, 105,
-        105, 110, 112, 113, 117, 119, 120, 125, 126, 128, 134, 134, 88, 86, 85,
-        84, 82, 82, 82, 84, 84, 85, 85, 85, 89, 96, 96, 101, 108, 108, 112, 116,
-        116, 123, 126, 127, 132, 134, 135, 142, 142, 145, 150, 150, 88, 86, 85,
-        84, 82, 82, 82, 84, 84, 85, 85, 85, 89, 96, 96, 101, 108, 108, 112, 116,
-        116, 123, 126, 127, 132, 134, 135, 142, 142, 145, 150, 150, 95, 92, 91,
-        91, 88, 88, 88, 90, 90, 90, 90, 90, 94, 101, 101, 106, 112, 112, 117,
-        121, 121, 129, 132, 133, 139, 140, 142, 149, 150, 153, 159, 159, 107,
-        104, 103, 102, 99, 99, 99, 99, 100, 99, 99, 99, 103, 109, 109, 114, 120,
-        120, 126, 130, 130, 139, 143, 144, 150, 152, 155, 163, 164, 167, 174,
-        174, 107, 104, 103, 102, 99, 99, 99, 99, 100, 99, 99, 99, 103, 109, 109,
-        114, 120, 120, 126, 130, 130, 139, 143, 144, 150, 152, 155, 163, 164,
-        167, 174, 174, 118, 114, 113, 112, 109, 108, 108, 108, 108, 108, 107,
-        107, 111, 117, 117, 122, 128, 128, 134, 138, 138, 147, 151, 152, 159,
-        161, 163, 173, 174, 177, 184, 184,
+        32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 34, 34, 35, 36, 36,
+        38, 39, 39, 42, 44, 44, 47, 48, 49, 53, 53, 55, 58, 58, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 35, 35, 37, 38, 38, 40,
+        42, 42, 45, 46, 47, 50, 51, 52, 55, 55, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 36, 37, 37, 40, 41, 41, 44, 45,
+        46, 49, 49, 51, 54, 54, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 34, 34, 34, 35, 35, 37, 38, 38, 40, 41, 41, 44, 45, 46, 49, 49, 51,
+        54, 54, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 35, 35, 35, 36, 36, 37,
+        37, 37, 39, 40, 40, 42, 42, 43, 45, 46, 47, 49, 50, 51, 54, 54, 32, 32,
+        32, 32, 32, 33, 33, 34, 34, 34, 35, 35, 36, 37, 37, 37, 38, 38, 40, 40,
+        40, 42, 43, 43, 45, 46, 47, 49, 50, 51, 54, 54, 32, 33, 33, 33, 33, 33,
+        33, 34, 34, 35, 36, 36, 36, 38, 38, 39, 40, 40, 41, 42, 42, 44, 45, 45,
+        47, 48, 48, 51, 51, 53, 55, 55, 35, 35, 35, 35, 34, 34, 35, 36, 36, 37,
+        38, 38, 39, 42, 42, 44, 47, 47, 48, 49, 49, 51, 52, 52, 54, 55, 56, 58,
+        59, 60, 62, 62, 36, 35, 35, 35, 35, 34, 35, 36, 36, 37, 38, 38, 40, 42,
+        42, 45, 48, 48, 49, 50, 50, 52, 53, 54, 56, 56, 57, 59, 60, 61, 63, 63,
+        38, 37, 37, 37, 36, 36, 36, 38, 38, 38, 39, 39, 41, 44, 44, 46, 49, 49,
+        51, 52, 52, 55, 56, 56, 58, 59, 60, 62, 63, 64, 67, 67, 44, 43, 42, 42,
+        41, 41, 41, 42, 42, 42, 42, 42, 44, 48, 48, 50, 54, 54, 56, 58, 58, 61,
+        63, 63, 66, 67, 67, 71, 71, 72, 75, 75, 44, 43, 42, 42, 41, 41, 41, 42,
+        42, 42, 42, 42, 44, 48, 48, 50, 54, 54, 56, 58, 58, 61, 63, 63, 66, 67,
+        67, 71, 71, 72, 75, 75, 47, 46, 45, 45, 44, 44, 44, 45, 45, 45, 45, 45,
+        47, 50, 50, 53, 56, 56, 58, 60, 60, 64, 66, 66, 69, 70, 71, 74, 75, 76,
+        79, 79, 53, 52, 51, 51, 49, 49, 49, 49, 50, 49, 49, 49, 51, 54, 54, 57,
+        60, 60, 63, 65, 65, 69, 71, 72, 75, 76, 77, 81, 82, 83, 87, 87, 53, 52,
+        51, 51, 49, 49, 49, 49, 50, 49, 49, 49, 51, 54, 54, 57, 60, 60, 63, 65,
+        65, 69, 71, 72, 75, 76, 77, 81, 82, 83, 87, 87, 59, 57, 56, 56, 54, 54,
+        54, 54, 54, 54, 53, 53, 55, 58, 58, 61, 64, 64, 67, 69, 69, 73, 75, 76,
+        79, 80, 81, 86, 87, 88, 92, 92,
         /* Size 4x16 */
-        63, 64, 76, 107, 64, 65, 74, 103, 64, 65, 73, 99, 64, 66, 73, 99, 65,
-        68, 76, 100, 65, 71, 79, 99, 66, 72, 83, 103, 68, 74, 88, 109, 70, 77,
-        99, 120, 74, 80, 103, 126, 76, 81, 105, 130, 84, 86, 112, 143, 90, 91,
-        117, 150, 94, 94, 120, 155, 102, 100, 126, 164, 111, 108, 134, 174,
+        31, 32, 38, 53, 32, 32, 37, 51, 32, 32, 36, 49, 32, 33, 36, 49, 32, 34,
+        38, 50, 32, 35, 39, 49, 33, 36, 41, 51, 34, 37, 44, 54, 35, 38, 49, 60,
+        37, 40, 51, 63, 38, 40, 52, 65, 42, 43, 56, 71, 45, 45, 58, 75, 47, 47,
+        60, 77, 51, 50, 63, 82, 55, 54, 67, 87,
         /* Size 16x4 */
-        63, 64, 64, 64, 65, 65, 66, 68, 70, 74, 76, 84, 90, 94, 102, 111, 64,
-        65, 65, 66, 68, 71, 72, 74, 77, 80, 81, 86, 91, 94, 100, 108, 76, 74,
-        73, 73, 76, 79, 83, 88, 99, 103, 105, 112, 117, 120, 126, 134, 107, 103,
-        99, 99, 100, 99, 103, 109, 120, 126, 130, 143, 150, 155, 164, 174,
+        31, 32, 32, 32, 32, 32, 33, 34, 35, 37, 38, 42, 45, 47, 51, 55, 32, 32,
+        32, 33, 34, 35, 36, 37, 38, 40, 40, 43, 45, 47, 50, 54, 38, 37, 36, 36,
+        38, 39, 41, 44, 49, 51, 52, 56, 58, 60, 63, 67, 53, 51, 49, 49, 50, 49,
+        51, 54, 60, 63, 65, 71, 75, 77, 82, 87,
         /* Size 8x32 */
-        64, 63, 64, 65, 72, 88, 95, 107, 63, 64, 64, 66, 71, 86, 92, 104, 63,
-        64, 65, 66, 71, 85, 91, 103, 63, 64, 65, 66, 71, 84, 91, 102, 63, 65,
-        65, 66, 70, 82, 88, 99, 63, 65, 65, 66, 69, 82, 88, 99, 63, 65, 66, 67,
-        70, 82, 88, 99, 64, 65, 67, 69, 73, 84, 90, 99, 64, 65, 68, 69, 73, 84,
-        90, 100, 64, 65, 68, 70, 74, 85, 90, 99, 64, 66, 70, 72, 77, 85, 90, 99,
-        64, 66, 70, 72, 77, 85, 90, 99, 65, 66, 71, 73, 80, 89, 94, 103, 68, 68,
-        72, 76, 85, 96, 101, 109, 68, 68, 72, 76, 85, 96, 101, 109, 70, 69, 74,
-        78, 90, 101, 106, 114, 72, 69, 75, 80, 96, 108, 112, 120, 72, 69, 75,
-        80, 96, 108, 112, 120, 76, 73, 78, 83, 99, 112, 117, 126, 79, 75, 80,
-        85, 101, 116, 121, 130, 79, 75, 80, 85, 101, 116, 121, 130, 85, 80, 84,
-        88, 105, 123, 129, 139, 88, 82, 85, 90, 107, 126, 132, 143, 88, 83, 86,
-        90, 108, 127, 133, 144, 94, 88, 91, 95, 112, 132, 139, 150, 96, 90, 92,
-        96, 113, 134, 140, 152, 98, 92, 94, 97, 114, 135, 142, 155, 106, 98, 99,
-        103, 119, 142, 149, 163, 107, 99, 100, 103, 120, 142, 150, 164, 110,
-        102, 102, 106, 122, 145, 153, 167, 117, 108, 108, 111, 127, 150, 159,
-        174, 117, 108, 108, 111, 127, 150, 159, 174,
+        32, 31, 32, 32, 36, 44, 47, 53, 31, 32, 32, 33, 35, 43, 46, 52, 31, 32,
+        32, 33, 35, 42, 45, 51, 31, 32, 32, 33, 35, 42, 45, 51, 31, 32, 32, 33,
+        35, 41, 44, 49, 31, 32, 32, 33, 34, 41, 44, 49, 31, 32, 33, 33, 35, 41,
+        44, 49, 32, 32, 33, 34, 36, 42, 45, 49, 32, 32, 34, 34, 36, 42, 45, 50,
+        32, 32, 34, 35, 37, 42, 45, 49, 32, 33, 35, 36, 38, 42, 45, 49, 32, 33,
+        35, 36, 38, 42, 45, 49, 32, 33, 35, 36, 40, 44, 47, 51, 34, 34, 36, 38,
+        42, 48, 50, 54, 34, 34, 36, 38, 42, 48, 50, 54, 35, 34, 37, 39, 45, 50,
+        53, 57, 36, 34, 37, 40, 48, 54, 56, 60, 36, 34, 37, 40, 48, 54, 56, 60,
+        38, 36, 39, 41, 49, 56, 58, 63, 39, 37, 40, 42, 50, 58, 60, 65, 39, 37,
+        40, 42, 50, 58, 60, 65, 42, 40, 42, 44, 52, 61, 64, 69, 44, 41, 42, 45,
+        53, 63, 66, 71, 44, 41, 43, 45, 54, 63, 66, 72, 47, 44, 45, 47, 56, 66,
+        69, 75, 48, 45, 46, 48, 56, 67, 70, 76, 49, 46, 47, 48, 57, 67, 71, 77,
+        53, 49, 49, 51, 59, 71, 74, 81, 53, 49, 50, 51, 60, 71, 75, 82, 55, 51,
+        51, 53, 61, 72, 76, 83, 58, 54, 54, 55, 63, 75, 79, 87, 58, 54, 54, 55,
+        63, 75, 79, 87,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 65, 68, 68, 70, 72, 72,
-        76, 79, 79, 85, 88, 88, 94, 96, 98, 106, 107, 110, 117, 117, 63, 64, 64,
-        64, 65, 65, 65, 65, 65, 65, 66, 66, 66, 68, 68, 69, 69, 69, 73, 75, 75,
-        80, 82, 83, 88, 90, 92, 98, 99, 102, 108, 108, 64, 64, 65, 65, 65, 65,
-        66, 67, 68, 68, 70, 70, 71, 72, 72, 74, 75, 75, 78, 80, 80, 84, 85, 86,
-        91, 92, 94, 99, 100, 102, 108, 108, 65, 66, 66, 66, 66, 66, 67, 69, 69,
-        70, 72, 72, 73, 76, 76, 78, 80, 80, 83, 85, 85, 88, 90, 90, 95, 96, 97,
-        103, 103, 106, 111, 111, 72, 71, 71, 71, 70, 69, 70, 73, 73, 74, 77, 77,
-        80, 85, 85, 90, 96, 96, 99, 101, 101, 105, 107, 108, 112, 113, 114, 119,
-        120, 122, 127, 127, 88, 86, 85, 84, 82, 82, 82, 84, 84, 85, 85, 85, 89,
-        96, 96, 101, 108, 108, 112, 116, 116, 123, 126, 127, 132, 134, 135, 142,
-        142, 145, 150, 150, 95, 92, 91, 91, 88, 88, 88, 90, 90, 90, 90, 90, 94,
-        101, 101, 106, 112, 112, 117, 121, 121, 129, 132, 133, 139, 140, 142,
-        149, 150, 153, 159, 159, 107, 104, 103, 102, 99, 99, 99, 99, 100, 99,
-        99, 99, 103, 109, 109, 114, 120, 120, 126, 130, 130, 139, 143, 144, 150,
-        152, 155, 163, 164, 167, 174, 174 },
+        32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 34, 34, 35, 36, 36,
+        38, 39, 39, 42, 44, 44, 47, 48, 49, 53, 53, 55, 58, 58, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 36, 37, 37, 40,
+        41, 41, 44, 45, 46, 49, 49, 51, 54, 54, 32, 32, 32, 32, 32, 32, 33, 33,
+        34, 34, 35, 35, 35, 36, 36, 37, 37, 37, 39, 40, 40, 42, 42, 43, 45, 46,
+        47, 49, 50, 51, 54, 54, 32, 33, 33, 33, 33, 33, 33, 34, 34, 35, 36, 36,
+        36, 38, 38, 39, 40, 40, 41, 42, 42, 44, 45, 45, 47, 48, 48, 51, 51, 53,
+        55, 55, 36, 35, 35, 35, 35, 34, 35, 36, 36, 37, 38, 38, 40, 42, 42, 45,
+        48, 48, 49, 50, 50, 52, 53, 54, 56, 56, 57, 59, 60, 61, 63, 63, 44, 43,
+        42, 42, 41, 41, 41, 42, 42, 42, 42, 42, 44, 48, 48, 50, 54, 54, 56, 58,
+        58, 61, 63, 63, 66, 67, 67, 71, 71, 72, 75, 75, 47, 46, 45, 45, 44, 44,
+        44, 45, 45, 45, 45, 45, 47, 50, 50, 53, 56, 56, 58, 60, 60, 64, 66, 66,
+        69, 70, 71, 74, 75, 76, 79, 79, 53, 52, 51, 51, 49, 49, 49, 49, 50, 49,
+        49, 49, 51, 54, 54, 57, 60, 60, 63, 65, 65, 69, 71, 72, 75, 76, 77, 81,
+        82, 83, 87, 87 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        77, 91, 91, 118,
+        38, 45, 45, 59,
 #endif
         /* Size 4x4 */
-        63, 77, 94, 99, 77, 95, 93, 93, 94, 93, 109, 115, 99, 93, 115, 132,
+        31, 38, 47, 49, 38, 47, 46, 46, 47, 46, 54, 57, 49, 46, 57, 66,
         /* Size 8x8 */
-        63, 62, 71, 84, 96, 95, 98, 102, 62, 64, 73, 85, 93, 90, 93, 97, 71, 73,
-        83, 91, 95, 91, 93, 96, 84, 85, 91, 97, 101, 99, 100, 102, 96, 93, 95,
-        101, 106, 107, 108, 109, 95, 90, 91, 99, 107, 114, 118, 121, 98, 93, 93,
-        100, 108, 118, 123, 128, 102, 97, 96, 102, 109, 121, 128, 136,
+        31, 31, 35, 42, 48, 47, 49, 51, 31, 32, 36, 42, 46, 45, 46, 48, 35, 36,
+        41, 45, 47, 45, 46, 48, 42, 42, 45, 48, 50, 49, 50, 51, 48, 46, 47, 50,
+        53, 53, 54, 54, 47, 45, 45, 49, 53, 57, 59, 60, 49, 46, 46, 50, 54, 59,
+        61, 64, 51, 48, 48, 51, 54, 60, 64, 68,
         /* Size 16x16 */
-        64, 62, 61, 62, 67, 73, 77, 83, 98, 98, 97, 98, 101, 102, 104, 109, 62,
-        63, 63, 64, 69, 77, 80, 85, 95, 95, 94, 94, 96, 97, 100, 104, 61, 63,
-        63, 65, 71, 79, 82, 85, 93, 92, 92, 91, 93, 94, 96, 100, 62, 64, 65, 66,
-        72, 81, 83, 86, 93, 92, 91, 90, 92, 93, 95, 99, 67, 69, 71, 72, 78, 87,
-        88, 90, 95, 93, 93, 91, 93, 94, 95, 99, 73, 77, 79, 81, 87, 95, 95, 95,
-        96, 94, 93, 91, 92, 93, 94, 97, 77, 80, 82, 83, 88, 95, 95, 96, 98, 96,
-        96, 94, 95, 95, 96, 99, 83, 85, 85, 86, 90, 95, 96, 97, 101, 100, 99,
-        98, 100, 100, 101, 104, 98, 95, 93, 93, 95, 96, 98, 101, 106, 106, 106,
-        107, 108, 108, 109, 111, 98, 95, 92, 92, 93, 94, 96, 100, 106, 107, 108,
-        110, 111, 111, 112, 115, 97, 94, 92, 91, 93, 93, 96, 99, 106, 108, 109,
-        111, 113, 113, 115, 117, 98, 94, 91, 90, 91, 91, 94, 98, 107, 110, 111,
-        117, 119, 120, 123, 125, 101, 96, 93, 92, 93, 92, 95, 100, 108, 111,
-        113, 119, 122, 123, 126, 129, 102, 97, 94, 93, 94, 93, 95, 100, 108,
-        111, 113, 120, 123, 125, 129, 132, 104, 100, 96, 95, 95, 94, 96, 101,
-        109, 112, 115, 123, 126, 129, 133, 137, 109, 104, 100, 99, 99, 97, 99,
-        104, 111, 115, 117, 125, 129, 132, 137, 142,
+        32, 31, 30, 31, 33, 36, 38, 41, 49, 49, 48, 49, 50, 51, 52, 54, 31, 31,
+        31, 32, 34, 38, 40, 42, 47, 47, 47, 47, 48, 48, 50, 52, 30, 31, 31, 32,
+        35, 39, 41, 42, 46, 46, 46, 45, 46, 47, 48, 50, 31, 32, 32, 33, 36, 40,
+        41, 43, 46, 46, 45, 45, 46, 46, 47, 49, 33, 34, 35, 36, 39, 43, 44, 45,
+        47, 46, 46, 45, 46, 47, 47, 49, 36, 38, 39, 40, 43, 47, 47, 47, 48, 47,
+        46, 45, 46, 46, 47, 48, 38, 40, 41, 41, 44, 47, 47, 48, 49, 48, 48, 47,
+        47, 47, 48, 49, 41, 42, 42, 43, 45, 47, 48, 48, 50, 50, 49, 49, 50, 50,
+        50, 52, 49, 47, 46, 46, 47, 48, 49, 50, 53, 53, 53, 53, 54, 54, 54, 55,
+        49, 47, 46, 46, 46, 47, 48, 50, 53, 53, 54, 55, 55, 55, 56, 57, 48, 47,
+        46, 45, 46, 46, 48, 49, 53, 54, 54, 55, 56, 56, 57, 58, 49, 47, 45, 45,
+        45, 45, 47, 49, 53, 55, 55, 58, 59, 60, 61, 62, 50, 48, 46, 46, 46, 46,
+        47, 50, 54, 55, 56, 59, 61, 61, 63, 64, 51, 48, 47, 46, 47, 46, 47, 50,
+        54, 55, 56, 60, 61, 62, 64, 66, 52, 50, 48, 47, 47, 47, 48, 50, 54, 56,
+        57, 61, 63, 64, 66, 68, 54, 52, 50, 49, 49, 48, 49, 52, 55, 57, 58, 62,
+        64, 66, 68, 71,
         /* Size 32x32 */
-        64, 63, 62, 62, 61, 61, 62, 66, 67, 69, 73, 73, 77, 83, 83, 90, 98, 98,
-        98, 97, 97, 98, 98, 98, 101, 101, 102, 104, 104, 106, 109, 109, 63, 63,
-        63, 63, 62, 62, 63, 68, 69, 71, 76, 76, 79, 84, 84, 90, 96, 96, 95, 95,
-        95, 95, 95, 95, 98, 98, 99, 101, 101, 102, 106, 106, 62, 63, 63, 63, 63,
-        62, 64, 69, 69, 71, 77, 77, 80, 85, 85, 90, 95, 95, 95, 94, 94, 94, 94,
-        94, 96, 97, 97, 99, 100, 101, 104, 104, 62, 63, 63, 63, 63, 63, 64, 69,
-        69, 72, 77, 77, 80, 85, 85, 90, 95, 95, 94, 94, 94, 94, 93, 94, 96, 96,
-        97, 99, 99, 101, 104, 104, 61, 62, 63, 63, 63, 63, 65, 70, 71, 73, 79,
-        79, 82, 85, 85, 89, 93, 93, 92, 92, 92, 91, 91, 91, 93, 94, 94, 96, 96,
-        97, 100, 100, 61, 62, 62, 63, 63, 64, 65, 70, 71, 73, 80, 80, 82, 85,
-        85, 89, 93, 93, 92, 91, 91, 90, 90, 90, 92, 93, 93, 95, 95, 97, 99, 99,
-        62, 63, 64, 64, 65, 65, 66, 71, 72, 75, 81, 81, 83, 86, 86, 89, 93, 93,
-        92, 91, 91, 91, 90, 90, 92, 93, 93, 95, 95, 96, 99, 99, 66, 68, 69, 69,
-        70, 70, 71, 77, 77, 80, 86, 86, 87, 89, 89, 92, 94, 94, 93, 92, 92, 91,
-        91, 91, 93, 93, 94, 95, 95, 96, 99, 99, 67, 69, 69, 69, 71, 71, 72, 77,
-        78, 80, 87, 87, 88, 90, 90, 92, 95, 95, 93, 93, 93, 91, 91, 91, 93, 93,
-        94, 95, 95, 96, 99, 99, 69, 71, 71, 72, 73, 73, 75, 80, 80, 83, 89, 89,
-        90, 91, 91, 93, 95, 95, 94, 93, 93, 91, 91, 91, 93, 93, 93, 94, 95, 96,
-        98, 98, 73, 76, 77, 77, 79, 80, 81, 86, 87, 89, 95, 95, 95, 95, 95, 95,
-        96, 96, 94, 93, 93, 91, 91, 91, 92, 92, 93, 93, 94, 94, 97, 97, 73, 76,
-        77, 77, 79, 80, 81, 86, 87, 89, 95, 95, 95, 95, 95, 95, 96, 96, 94, 93,
-        93, 91, 91, 91, 92, 92, 93, 93, 94, 94, 97, 97, 77, 79, 80, 80, 82, 82,
-        83, 87, 88, 90, 95, 95, 95, 96, 96, 97, 98, 98, 96, 96, 96, 94, 94, 94,
-        95, 95, 95, 96, 96, 97, 99, 99, 83, 84, 85, 85, 85, 85, 86, 89, 90, 91,
-        95, 95, 96, 97, 97, 99, 101, 101, 100, 99, 99, 99, 98, 99, 100, 100,
-        100, 101, 101, 102, 104, 104, 83, 84, 85, 85, 85, 85, 86, 89, 90, 91,
-        95, 95, 96, 97, 97, 99, 101, 101, 100, 99, 99, 99, 98, 99, 100, 100,
-        100, 101, 101, 102, 104, 104, 90, 90, 90, 90, 89, 89, 89, 92, 92, 93,
-        95, 95, 97, 99, 99, 101, 103, 103, 103, 103, 103, 103, 103, 103, 104,
-        104, 104, 105, 105, 105, 107, 107, 98, 96, 95, 95, 93, 93, 93, 94, 95,
-        95, 96, 96, 98, 101, 101, 103, 106, 106, 106, 106, 106, 107, 107, 107,
-        108, 108, 108, 109, 109, 109, 111, 111, 98, 96, 95, 95, 93, 93, 93, 94,
-        95, 95, 96, 96, 98, 101, 101, 103, 106, 106, 106, 106, 106, 107, 107,
-        107, 108, 108, 108, 109, 109, 109, 111, 111, 98, 95, 95, 94, 92, 92, 92,
-        93, 93, 94, 94, 94, 96, 100, 100, 103, 106, 106, 107, 108, 108, 109,
-        110, 110, 111, 111, 111, 112, 112, 113, 115, 115, 97, 95, 94, 94, 92,
-        91, 91, 92, 93, 93, 93, 93, 96, 99, 99, 103, 106, 106, 108, 109, 109,
-        111, 111, 112, 113, 113, 113, 115, 115, 116, 117, 117, 97, 95, 94, 94,
-        92, 91, 91, 92, 93, 93, 93, 93, 96, 99, 99, 103, 106, 106, 108, 109,
-        109, 111, 111, 112, 113, 113, 113, 115, 115, 116, 117, 117, 98, 95, 94,
-        94, 91, 90, 91, 91, 91, 91, 91, 91, 94, 99, 99, 103, 107, 107, 109, 111,
-        111, 114, 115, 116, 117, 118, 118, 120, 120, 121, 123, 123, 98, 95, 94,
-        93, 91, 90, 90, 91, 91, 91, 91, 91, 94, 98, 98, 103, 107, 107, 110, 111,
-        111, 115, 117, 117, 119, 120, 120, 122, 123, 123, 125, 125, 98, 95, 94,
-        94, 91, 90, 90, 91, 91, 91, 91, 91, 94, 99, 99, 103, 107, 107, 110, 112,
-        112, 116, 117, 118, 119, 120, 121, 123, 123, 124, 126, 126, 101, 98, 96,
-        96, 93, 92, 92, 93, 93, 93, 92, 92, 95, 100, 100, 104, 108, 108, 111,
-        113, 113, 117, 119, 119, 122, 122, 123, 126, 126, 127, 129, 129, 101,
-        98, 97, 96, 94, 93, 93, 93, 93, 93, 92, 92, 95, 100, 100, 104, 108, 108,
-        111, 113, 113, 118, 120, 120, 122, 123, 124, 127, 127, 128, 130, 130,
-        102, 99, 97, 97, 94, 93, 93, 94, 94, 93, 93, 93, 95, 100, 100, 104, 108,
-        108, 111, 113, 113, 118, 120, 121, 123, 124, 125, 128, 129, 129, 132,
-        132, 104, 101, 99, 99, 96, 95, 95, 95, 95, 94, 93, 93, 96, 101, 101,
-        105, 109, 109, 112, 115, 115, 120, 122, 123, 126, 127, 128, 132, 133,
-        134, 136, 136, 104, 101, 100, 99, 96, 95, 95, 95, 95, 95, 94, 94, 96,
-        101, 101, 105, 109, 109, 112, 115, 115, 120, 123, 123, 126, 127, 129,
-        133, 133, 134, 137, 137, 106, 102, 101, 101, 97, 97, 96, 96, 96, 96, 94,
-        94, 97, 102, 102, 105, 109, 109, 113, 116, 116, 121, 123, 124, 127, 128,
-        129, 134, 134, 136, 138, 138, 109, 106, 104, 104, 100, 99, 99, 99, 99,
-        98, 97, 97, 99, 104, 104, 107, 111, 111, 115, 117, 117, 123, 125, 126,
-        129, 130, 132, 136, 137, 138, 142, 142, 109, 106, 104, 104, 100, 99, 99,
-        99, 99, 98, 97, 97, 99, 104, 104, 107, 111, 111, 115, 117, 117, 123,
-        125, 126, 129, 130, 132, 136, 137, 138, 142, 142,
+        32, 31, 31, 31, 30, 30, 31, 33, 33, 34, 36, 36, 38, 41, 41, 45, 49, 49,
+        49, 48, 48, 49, 49, 49, 50, 50, 51, 52, 52, 53, 54, 54, 31, 31, 31, 31,
+        31, 31, 31, 34, 34, 35, 38, 38, 39, 42, 42, 45, 48, 48, 47, 47, 47, 47,
+        47, 47, 49, 49, 49, 50, 50, 51, 53, 53, 31, 31, 31, 31, 31, 31, 32, 34,
+        34, 35, 38, 38, 40, 42, 42, 45, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48,
+        48, 49, 50, 50, 52, 52, 31, 31, 31, 31, 31, 31, 32, 34, 34, 36, 38, 38,
+        40, 42, 42, 45, 47, 47, 47, 47, 47, 47, 46, 47, 48, 48, 48, 49, 49, 50,
+        52, 52, 30, 31, 31, 31, 31, 31, 32, 35, 35, 36, 39, 39, 41, 42, 42, 44,
+        46, 46, 46, 46, 46, 45, 45, 45, 46, 47, 47, 48, 48, 48, 50, 50, 30, 31,
+        31, 31, 31, 32, 32, 35, 35, 36, 40, 40, 41, 42, 42, 44, 46, 46, 46, 45,
+        45, 45, 45, 45, 46, 46, 46, 47, 47, 48, 49, 49, 31, 31, 32, 32, 32, 32,
+        33, 35, 36, 37, 40, 40, 41, 43, 43, 44, 46, 46, 46, 45, 45, 45, 45, 45,
+        46, 46, 46, 47, 47, 48, 49, 49, 33, 34, 34, 34, 35, 35, 35, 38, 38, 40,
+        43, 43, 43, 44, 44, 46, 47, 47, 46, 46, 46, 45, 45, 45, 46, 46, 47, 47,
+        47, 48, 49, 49, 33, 34, 34, 34, 35, 35, 36, 38, 39, 40, 43, 43, 44, 45,
+        45, 46, 47, 47, 46, 46, 46, 45, 45, 45, 46, 46, 47, 47, 47, 48, 49, 49,
+        34, 35, 35, 36, 36, 36, 37, 40, 40, 41, 44, 44, 45, 45, 45, 46, 47, 47,
+        47, 46, 46, 45, 45, 45, 46, 46, 46, 47, 47, 48, 49, 49, 36, 38, 38, 38,
+        39, 40, 40, 43, 43, 44, 47, 47, 47, 47, 47, 47, 48, 48, 47, 46, 46, 45,
+        45, 45, 46, 46, 46, 46, 47, 47, 48, 48, 36, 38, 38, 38, 39, 40, 40, 43,
+        43, 44, 47, 47, 47, 47, 47, 47, 48, 48, 47, 46, 46, 45, 45, 45, 46, 46,
+        46, 46, 47, 47, 48, 48, 38, 39, 40, 40, 41, 41, 41, 43, 44, 45, 47, 47,
+        47, 48, 48, 48, 49, 49, 48, 48, 48, 47, 47, 47, 47, 47, 47, 48, 48, 48,
+        49, 49, 41, 42, 42, 42, 42, 42, 43, 44, 45, 45, 47, 47, 48, 48, 48, 49,
+        50, 50, 50, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50, 51, 52, 52, 41, 42,
+        42, 42, 42, 42, 43, 44, 45, 45, 47, 47, 48, 48, 48, 49, 50, 50, 50, 49,
+        49, 49, 49, 49, 50, 50, 50, 50, 50, 51, 52, 52, 45, 45, 45, 45, 44, 44,
+        44, 46, 46, 46, 47, 47, 48, 49, 49, 50, 51, 51, 51, 51, 51, 51, 51, 51,
+        52, 52, 52, 52, 52, 52, 53, 53, 49, 48, 47, 47, 46, 46, 46, 47, 47, 47,
+        48, 48, 49, 50, 50, 51, 53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54,
+        54, 54, 55, 55, 49, 48, 47, 47, 46, 46, 46, 47, 47, 47, 48, 48, 49, 50,
+        50, 51, 53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 55, 55,
+        49, 47, 47, 47, 46, 46, 46, 46, 46, 47, 47, 47, 48, 50, 50, 51, 53, 53,
+        53, 54, 54, 54, 55, 55, 55, 55, 55, 56, 56, 56, 57, 57, 48, 47, 47, 47,
+        46, 45, 45, 46, 46, 46, 46, 46, 48, 49, 49, 51, 53, 53, 54, 54, 54, 55,
+        55, 56, 56, 56, 56, 57, 57, 58, 58, 58, 48, 47, 47, 47, 46, 45, 45, 46,
+        46, 46, 46, 46, 48, 49, 49, 51, 53, 53, 54, 54, 54, 55, 55, 56, 56, 56,
+        56, 57, 57, 58, 58, 58, 49, 47, 47, 47, 45, 45, 45, 45, 45, 45, 45, 45,
+        47, 49, 49, 51, 53, 53, 54, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 60,
+        61, 61, 49, 47, 47, 46, 45, 45, 45, 45, 45, 45, 45, 45, 47, 49, 49, 51,
+        53, 53, 55, 55, 55, 57, 58, 58, 59, 60, 60, 61, 61, 61, 62, 62, 49, 47,
+        47, 47, 45, 45, 45, 45, 45, 45, 45, 45, 47, 49, 49, 51, 53, 53, 55, 56,
+        56, 58, 58, 59, 59, 60, 60, 61, 61, 62, 63, 63, 50, 49, 48, 48, 46, 46,
+        46, 46, 46, 46, 46, 46, 47, 50, 50, 52, 54, 54, 55, 56, 56, 58, 59, 59,
+        61, 61, 61, 63, 63, 63, 64, 64, 50, 49, 48, 48, 47, 46, 46, 46, 46, 46,
+        46, 46, 47, 50, 50, 52, 54, 54, 55, 56, 56, 59, 60, 60, 61, 61, 62, 63,
+        63, 64, 65, 65, 51, 49, 48, 48, 47, 46, 46, 47, 47, 46, 46, 46, 47, 50,
+        50, 52, 54, 54, 55, 56, 56, 59, 60, 60, 61, 62, 62, 64, 64, 64, 66, 66,
+        52, 50, 49, 49, 48, 47, 47, 47, 47, 47, 46, 46, 48, 50, 50, 52, 54, 54,
+        56, 57, 57, 60, 61, 61, 63, 63, 64, 66, 66, 67, 68, 68, 52, 50, 50, 49,
+        48, 47, 47, 47, 47, 47, 47, 47, 48, 50, 50, 52, 54, 54, 56, 57, 57, 60,
+        61, 61, 63, 63, 64, 66, 66, 67, 68, 68, 53, 51, 50, 50, 48, 48, 48, 48,
+        48, 48, 47, 47, 48, 51, 51, 52, 54, 54, 56, 58, 58, 60, 61, 62, 63, 64,
+        64, 67, 67, 68, 69, 69, 54, 53, 52, 52, 50, 49, 49, 49, 49, 49, 48, 48,
+        49, 52, 52, 53, 55, 55, 57, 58, 58, 61, 62, 63, 64, 65, 66, 68, 68, 69,
+        71, 71, 54, 53, 52, 52, 50, 49, 49, 49, 49, 49, 48, 48, 49, 52, 52, 53,
+        55, 55, 57, 58, 58, 61, 62, 63, 64, 65, 66, 68, 68, 69, 71, 71,
         /* Size 4x8 */
-        63, 76, 95, 101, 63, 80, 92, 96, 73, 89, 94, 95, 85, 95, 100, 101, 95,
-        96, 106, 109, 93, 92, 109, 120, 96, 93, 111, 128, 100, 96, 113, 134,
+        31, 38, 47, 50, 31, 40, 46, 48, 36, 44, 47, 47, 42, 47, 50, 50, 47, 48,
+        53, 54, 46, 46, 54, 60, 48, 46, 55, 64, 50, 48, 56, 67,
         /* Size 8x4 */
-        63, 63, 73, 85, 95, 93, 96, 100, 76, 80, 89, 95, 96, 92, 93, 96, 95, 92,
-        94, 100, 106, 109, 111, 113, 101, 96, 95, 101, 109, 120, 128, 134,
+        31, 31, 36, 42, 47, 46, 48, 50, 38, 40, 44, 47, 48, 46, 46, 48, 47, 46,
+        47, 50, 53, 54, 55, 56, 50, 48, 47, 50, 54, 60, 64, 67,
         /* Size 8x16 */
-        64, 62, 71, 77, 96, 98, 101, 105, 63, 63, 74, 80, 94, 94, 97, 100, 61,
-        64, 76, 81, 92, 91, 93, 97, 62, 66, 77, 83, 92, 91, 93, 96, 67, 72, 83,
-        88, 94, 92, 93, 95, 74, 80, 91, 95, 95, 91, 92, 94, 78, 82, 92, 95, 97,
-        94, 95, 97, 84, 86, 93, 96, 100, 99, 100, 101, 98, 93, 96, 98, 106, 107,
-        108, 109, 97, 92, 94, 97, 106, 110, 111, 113, 97, 92, 93, 96, 106, 112,
-        113, 115, 98, 91, 91, 94, 107, 117, 119, 123, 100, 93, 93, 96, 108, 119,
-        122, 127, 102, 94, 94, 96, 108, 120, 123, 129, 104, 96, 95, 97, 109,
-        122, 127, 133, 109, 100, 98, 100, 111, 125, 130, 137,
+        32, 31, 35, 38, 48, 49, 50, 52, 31, 31, 37, 40, 47, 47, 48, 50, 30, 32,
+        38, 40, 46, 45, 46, 48, 31, 33, 38, 41, 46, 45, 46, 48, 33, 36, 41, 44,
+        47, 46, 46, 47, 37, 40, 45, 47, 47, 45, 46, 47, 39, 41, 46, 47, 48, 47,
+        47, 48, 42, 43, 46, 48, 50, 49, 50, 50, 49, 46, 48, 49, 53, 53, 54, 54,
+        48, 46, 47, 48, 53, 55, 55, 56, 48, 46, 46, 48, 53, 56, 56, 57, 49, 45,
+        45, 47, 53, 58, 59, 61, 50, 46, 46, 48, 54, 59, 61, 63, 51, 47, 47, 48,
+        54, 60, 61, 64, 52, 48, 47, 48, 54, 61, 63, 66, 54, 50, 49, 50, 55, 62,
+        65, 68,
         /* Size 16x8 */
-        64, 63, 61, 62, 67, 74, 78, 84, 98, 97, 97, 98, 100, 102, 104, 109, 62,
-        63, 64, 66, 72, 80, 82, 86, 93, 92, 92, 91, 93, 94, 96, 100, 71, 74, 76,
-        77, 83, 91, 92, 93, 96, 94, 93, 91, 93, 94, 95, 98, 77, 80, 81, 83, 88,
-        95, 95, 96, 98, 97, 96, 94, 96, 96, 97, 100, 96, 94, 92, 92, 94, 95, 97,
-        100, 106, 106, 106, 107, 108, 108, 109, 111, 98, 94, 91, 91, 92, 91, 94,
-        99, 107, 110, 112, 117, 119, 120, 122, 125, 101, 97, 93, 93, 93, 92, 95,
-        100, 108, 111, 113, 119, 122, 123, 127, 130, 105, 100, 97, 96, 95, 94,
-        97, 101, 109, 113, 115, 123, 127, 129, 133, 137,
+        32, 31, 30, 31, 33, 37, 39, 42, 49, 48, 48, 49, 50, 51, 52, 54, 31, 31,
+        32, 33, 36, 40, 41, 43, 46, 46, 46, 45, 46, 47, 48, 50, 35, 37, 38, 38,
+        41, 45, 46, 46, 48, 47, 46, 45, 46, 47, 47, 49, 38, 40, 40, 41, 44, 47,
+        47, 48, 49, 48, 48, 47, 48, 48, 48, 50, 48, 47, 46, 46, 47, 47, 48, 50,
+        53, 53, 53, 53, 54, 54, 54, 55, 49, 47, 45, 45, 46, 45, 47, 49, 53, 55,
+        56, 58, 59, 60, 61, 62, 50, 48, 46, 46, 46, 46, 47, 50, 54, 55, 56, 59,
+        61, 61, 63, 65, 52, 50, 48, 48, 47, 47, 48, 50, 54, 56, 57, 61, 63, 64,
+        66, 68,
         /* Size 16x32 */
-        64, 62, 62, 63, 71, 74, 77, 94, 96, 97, 98, 98, 101, 105, 105, 109, 63,
-        63, 63, 64, 73, 76, 79, 93, 95, 95, 96, 96, 98, 101, 101, 106, 63, 63,
-        63, 64, 74, 77, 80, 92, 94, 94, 94, 94, 97, 100, 100, 104, 62, 63, 63,
-        64, 74, 77, 80, 92, 94, 94, 94, 94, 96, 100, 100, 104, 61, 63, 64, 65,
-        76, 79, 81, 91, 92, 92, 91, 91, 93, 97, 97, 101, 61, 63, 64, 66, 76, 80,
-        82, 91, 92, 92, 91, 91, 93, 96, 96, 100, 62, 65, 66, 67, 77, 81, 83, 91,
-        92, 92, 91, 91, 93, 96, 96, 100, 67, 70, 71, 72, 82, 86, 87, 93, 94, 93,
-        91, 91, 93, 95, 95, 99, 67, 70, 72, 73, 83, 86, 88, 93, 94, 93, 92, 92,
-        93, 95, 95, 99, 69, 73, 74, 75, 85, 89, 90, 94, 94, 94, 91, 91, 93, 95,
-        95, 98, 74, 78, 80, 82, 91, 94, 95, 95, 95, 94, 91, 91, 92, 94, 94, 97,
-        74, 78, 80, 82, 91, 94, 95, 95, 95, 94, 91, 91, 92, 94, 94, 97, 78, 81,
-        82, 84, 92, 95, 95, 97, 97, 96, 94, 94, 95, 97, 97, 100, 84, 85, 86, 87,
-        93, 95, 96, 100, 100, 100, 99, 99, 100, 101, 101, 104, 84, 85, 86, 87,
-        93, 95, 96, 100, 100, 100, 99, 99, 100, 101, 101, 104, 90, 90, 89, 90,
-        94, 95, 97, 102, 103, 103, 103, 103, 104, 105, 105, 108, 98, 95, 93, 94,
-        96, 96, 98, 105, 106, 106, 107, 107, 108, 109, 109, 111, 98, 95, 93, 94,
-        96, 96, 98, 105, 106, 106, 107, 107, 108, 109, 109, 111, 97, 94, 92, 93,
-        94, 95, 97, 105, 106, 107, 110, 110, 111, 113, 113, 115, 97, 93, 92, 92,
-        93, 94, 96, 105, 106, 108, 112, 112, 113, 115, 115, 118, 97, 93, 92, 92,
-        93, 94, 96, 105, 106, 108, 112, 112, 113, 115, 115, 118, 98, 93, 91, 91,
-        92, 92, 95, 105, 107, 109, 115, 115, 117, 120, 120, 123, 98, 93, 91, 91,
-        91, 92, 94, 105, 107, 110, 117, 117, 119, 123, 123, 125, 98, 93, 91, 91,
-        92, 92, 94, 105, 107, 110, 117, 117, 120, 123, 123, 126, 100, 95, 93,
-        93, 93, 93, 96, 106, 108, 111, 119, 119, 122, 127, 127, 130, 101, 96,
-        93, 93, 93, 93, 96, 106, 108, 111, 119, 119, 123, 128, 128, 131, 102,
-        96, 94, 94, 94, 94, 96, 106, 108, 111, 120, 120, 123, 129, 129, 132,
-        104, 98, 96, 96, 95, 94, 97, 107, 109, 112, 122, 122, 126, 133, 133,
-        137, 104, 98, 96, 96, 95, 95, 97, 107, 109, 112, 122, 122, 127, 133,
-        133, 137, 106, 100, 97, 97, 96, 96, 98, 108, 109, 113, 123, 123, 127,
-        134, 134, 139, 109, 103, 100, 100, 98, 98, 100, 110, 111, 115, 125, 125,
-        130, 137, 137, 142, 109, 103, 100, 100, 98, 98, 100, 110, 111, 115, 125,
-        125, 130, 137, 137, 142,
+        32, 31, 31, 31, 35, 37, 38, 47, 48, 48, 49, 49, 50, 52, 52, 54, 31, 31,
+        31, 32, 36, 38, 39, 46, 47, 47, 48, 48, 49, 50, 50, 53, 31, 31, 31, 32,
+        37, 38, 40, 46, 47, 47, 47, 47, 48, 50, 50, 52, 31, 31, 31, 32, 37, 38,
+        40, 46, 47, 47, 47, 47, 48, 50, 50, 52, 30, 31, 32, 32, 38, 39, 40, 45,
+        46, 46, 45, 45, 46, 48, 48, 50, 30, 31, 32, 33, 38, 40, 41, 45, 46, 46,
+        45, 45, 46, 48, 48, 50, 31, 32, 33, 33, 38, 40, 41, 45, 46, 46, 45, 45,
+        46, 48, 48, 50, 33, 35, 35, 36, 41, 43, 43, 46, 47, 46, 45, 45, 46, 47,
+        47, 49, 33, 35, 36, 36, 41, 43, 44, 46, 47, 46, 46, 46, 46, 47, 47, 49,
+        34, 36, 37, 37, 42, 44, 45, 47, 47, 47, 45, 45, 46, 47, 47, 49, 37, 39,
+        40, 41, 45, 47, 47, 47, 47, 47, 45, 45, 46, 47, 47, 48, 37, 39, 40, 41,
+        45, 47, 47, 47, 47, 47, 45, 45, 46, 47, 47, 48, 39, 40, 41, 42, 46, 47,
+        47, 48, 48, 48, 47, 47, 47, 48, 48, 50, 42, 42, 43, 43, 46, 47, 48, 50,
+        50, 50, 49, 49, 50, 50, 50, 52, 42, 42, 43, 43, 46, 47, 48, 50, 50, 50,
+        49, 49, 50, 50, 50, 52, 45, 45, 44, 45, 47, 47, 48, 51, 51, 51, 51, 51,
+        52, 52, 52, 54, 49, 47, 46, 47, 48, 48, 49, 52, 53, 53, 53, 53, 54, 54,
+        54, 55, 49, 47, 46, 47, 48, 48, 49, 52, 53, 53, 53, 53, 54, 54, 54, 55,
+        48, 47, 46, 46, 47, 47, 48, 52, 53, 53, 55, 55, 55, 56, 56, 57, 48, 46,
+        46, 46, 46, 47, 48, 52, 53, 54, 56, 56, 56, 57, 57, 59, 48, 46, 46, 46,
+        46, 47, 48, 52, 53, 54, 56, 56, 56, 57, 57, 59, 49, 46, 45, 45, 46, 46,
+        47, 52, 53, 54, 57, 57, 58, 60, 60, 61, 49, 46, 45, 45, 45, 46, 47, 52,
+        53, 55, 58, 58, 59, 61, 61, 62, 49, 46, 45, 45, 46, 46, 47, 52, 53, 55,
+        58, 58, 60, 61, 61, 63, 50, 47, 46, 46, 46, 46, 48, 53, 54, 55, 59, 59,
+        61, 63, 63, 65, 50, 48, 46, 46, 46, 46, 48, 53, 54, 55, 59, 59, 61, 64,
+        64, 65, 51, 48, 47, 47, 47, 47, 48, 53, 54, 55, 60, 60, 61, 64, 64, 66,
+        52, 49, 48, 48, 47, 47, 48, 53, 54, 56, 61, 61, 63, 66, 66, 68, 52, 49,
+        48, 48, 47, 47, 48, 53, 54, 56, 61, 61, 63, 66, 66, 68, 53, 50, 48, 48,
+        48, 48, 49, 54, 54, 56, 61, 61, 63, 67, 67, 69, 54, 51, 50, 50, 49, 49,
+        50, 55, 55, 57, 62, 62, 65, 68, 68, 71, 54, 51, 50, 50, 49, 49, 50, 55,
+        55, 57, 62, 62, 65, 68, 68, 71,
         /* Size 32x16 */
-        64, 63, 63, 62, 61, 61, 62, 67, 67, 69, 74, 74, 78, 84, 84, 90, 98, 98,
-        97, 97, 97, 98, 98, 98, 100, 101, 102, 104, 104, 106, 109, 109, 62, 63,
-        63, 63, 63, 63, 65, 70, 70, 73, 78, 78, 81, 85, 85, 90, 95, 95, 94, 93,
-        93, 93, 93, 93, 95, 96, 96, 98, 98, 100, 103, 103, 62, 63, 63, 63, 64,
-        64, 66, 71, 72, 74, 80, 80, 82, 86, 86, 89, 93, 93, 92, 92, 92, 91, 91,
-        91, 93, 93, 94, 96, 96, 97, 100, 100, 63, 64, 64, 64, 65, 66, 67, 72,
-        73, 75, 82, 82, 84, 87, 87, 90, 94, 94, 93, 92, 92, 91, 91, 91, 93, 93,
-        94, 96, 96, 97, 100, 100, 71, 73, 74, 74, 76, 76, 77, 82, 83, 85, 91,
-        91, 92, 93, 93, 94, 96, 96, 94, 93, 93, 92, 91, 92, 93, 93, 94, 95, 95,
-        96, 98, 98, 74, 76, 77, 77, 79, 80, 81, 86, 86, 89, 94, 94, 95, 95, 95,
-        95, 96, 96, 95, 94, 94, 92, 92, 92, 93, 93, 94, 94, 95, 96, 98, 98, 77,
-        79, 80, 80, 81, 82, 83, 87, 88, 90, 95, 95, 95, 96, 96, 97, 98, 98, 97,
-        96, 96, 95, 94, 94, 96, 96, 96, 97, 97, 98, 100, 100, 94, 93, 92, 92,
-        91, 91, 91, 93, 93, 94, 95, 95, 97, 100, 100, 102, 105, 105, 105, 105,
-        105, 105, 105, 105, 106, 106, 106, 107, 107, 108, 110, 110, 96, 95, 94,
-        94, 92, 92, 92, 94, 94, 94, 95, 95, 97, 100, 100, 103, 106, 106, 106,
-        106, 106, 107, 107, 107, 108, 108, 108, 109, 109, 109, 111, 111, 97, 95,
-        94, 94, 92, 92, 92, 93, 93, 94, 94, 94, 96, 100, 100, 103, 106, 106,
-        107, 108, 108, 109, 110, 110, 111, 111, 111, 112, 112, 113, 115, 115,
-        98, 96, 94, 94, 91, 91, 91, 91, 92, 91, 91, 91, 94, 99, 99, 103, 107,
-        107, 110, 112, 112, 115, 117, 117, 119, 119, 120, 122, 122, 123, 125,
-        125, 98, 96, 94, 94, 91, 91, 91, 91, 92, 91, 91, 91, 94, 99, 99, 103,
-        107, 107, 110, 112, 112, 115, 117, 117, 119, 119, 120, 122, 122, 123,
-        125, 125, 101, 98, 97, 96, 93, 93, 93, 93, 93, 93, 92, 92, 95, 100, 100,
-        104, 108, 108, 111, 113, 113, 117, 119, 120, 122, 123, 123, 126, 127,
-        127, 130, 130, 105, 101, 100, 100, 97, 96, 96, 95, 95, 95, 94, 94, 97,
-        101, 101, 105, 109, 109, 113, 115, 115, 120, 123, 123, 127, 128, 129,
-        133, 133, 134, 137, 137, 105, 101, 100, 100, 97, 96, 96, 95, 95, 95, 94,
-        94, 97, 101, 101, 105, 109, 109, 113, 115, 115, 120, 123, 123, 127, 128,
-        129, 133, 133, 134, 137, 137, 109, 106, 104, 104, 101, 100, 100, 99, 99,
-        98, 97, 97, 100, 104, 104, 108, 111, 111, 115, 118, 118, 123, 125, 126,
-        130, 131, 132, 137, 137, 139, 142, 142,
+        32, 31, 31, 31, 30, 30, 31, 33, 33, 34, 37, 37, 39, 42, 42, 45, 49, 49,
+        48, 48, 48, 49, 49, 49, 50, 50, 51, 52, 52, 53, 54, 54, 31, 31, 31, 31,
+        31, 31, 32, 35, 35, 36, 39, 39, 40, 42, 42, 45, 47, 47, 47, 46, 46, 46,
+        46, 46, 47, 48, 48, 49, 49, 50, 51, 51, 31, 31, 31, 31, 32, 32, 33, 35,
+        36, 37, 40, 40, 41, 43, 43, 44, 46, 46, 46, 46, 46, 45, 45, 45, 46, 46,
+        47, 48, 48, 48, 50, 50, 31, 32, 32, 32, 32, 33, 33, 36, 36, 37, 41, 41,
+        42, 43, 43, 45, 47, 47, 46, 46, 46, 45, 45, 45, 46, 46, 47, 48, 48, 48,
+        50, 50, 35, 36, 37, 37, 38, 38, 38, 41, 41, 42, 45, 45, 46, 46, 46, 47,
+        48, 48, 47, 46, 46, 46, 45, 46, 46, 46, 47, 47, 47, 48, 49, 49, 37, 38,
+        38, 38, 39, 40, 40, 43, 43, 44, 47, 47, 47, 47, 47, 47, 48, 48, 47, 47,
+        47, 46, 46, 46, 46, 46, 47, 47, 47, 48, 49, 49, 38, 39, 40, 40, 40, 41,
+        41, 43, 44, 45, 47, 47, 47, 48, 48, 48, 49, 49, 48, 48, 48, 47, 47, 47,
+        48, 48, 48, 48, 48, 49, 50, 50, 47, 46, 46, 46, 45, 45, 45, 46, 46, 47,
+        47, 47, 48, 50, 50, 51, 52, 52, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53,
+        53, 54, 55, 55, 48, 47, 47, 47, 46, 46, 46, 47, 47, 47, 47, 47, 48, 50,
+        50, 51, 53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 55, 55,
+        48, 47, 47, 47, 46, 46, 46, 46, 46, 47, 47, 47, 48, 50, 50, 51, 53, 53,
+        53, 54, 54, 54, 55, 55, 55, 55, 55, 56, 56, 56, 57, 57, 49, 48, 47, 47,
+        45, 45, 45, 45, 46, 45, 45, 45, 47, 49, 49, 51, 53, 53, 55, 56, 56, 57,
+        58, 58, 59, 59, 60, 61, 61, 61, 62, 62, 49, 48, 47, 47, 45, 45, 45, 45,
+        46, 45, 45, 45, 47, 49, 49, 51, 53, 53, 55, 56, 56, 57, 58, 58, 59, 59,
+        60, 61, 61, 61, 62, 62, 50, 49, 48, 48, 46, 46, 46, 46, 46, 46, 46, 46,
+        47, 50, 50, 52, 54, 54, 55, 56, 56, 58, 59, 60, 61, 61, 61, 63, 63, 63,
+        65, 65, 52, 50, 50, 50, 48, 48, 48, 47, 47, 47, 47, 47, 48, 50, 50, 52,
+        54, 54, 56, 57, 57, 60, 61, 61, 63, 64, 64, 66, 66, 67, 68, 68, 52, 50,
+        50, 50, 48, 48, 48, 47, 47, 47, 47, 47, 48, 50, 50, 52, 54, 54, 56, 57,
+        57, 60, 61, 61, 63, 64, 64, 66, 66, 67, 68, 68, 54, 53, 52, 52, 50, 50,
+        50, 49, 49, 49, 48, 48, 50, 52, 52, 54, 55, 55, 57, 59, 59, 61, 62, 63,
+        65, 65, 66, 68, 68, 69, 71, 71,
         /* Size 4x16 */
-        62, 74, 97, 105, 63, 77, 94, 100, 63, 79, 92, 97, 65, 81, 92, 96, 70,
-        86, 93, 95, 78, 94, 94, 94, 81, 95, 96, 97, 85, 95, 100, 101, 95, 96,
-        106, 109, 94, 95, 107, 113, 93, 94, 108, 115, 93, 92, 110, 123, 95, 93,
-        111, 127, 96, 94, 111, 129, 98, 95, 112, 133, 103, 98, 115, 137,
+        31, 37, 48, 52, 31, 38, 47, 50, 31, 39, 46, 48, 32, 40, 46, 48, 35, 43,
+        46, 47, 39, 47, 47, 47, 40, 47, 48, 48, 42, 47, 50, 50, 47, 48, 53, 54,
+        47, 47, 53, 56, 46, 47, 54, 57, 46, 46, 55, 61, 47, 46, 55, 63, 48, 47,
+        55, 64, 49, 47, 56, 66, 51, 49, 57, 68,
         /* Size 16x4 */
-        62, 63, 63, 65, 70, 78, 81, 85, 95, 94, 93, 93, 95, 96, 98, 103, 74, 77,
-        79, 81, 86, 94, 95, 95, 96, 95, 94, 92, 93, 94, 95, 98, 97, 94, 92, 92,
-        93, 94, 96, 100, 106, 107, 108, 110, 111, 111, 112, 115, 105, 100, 97,
-        96, 95, 94, 97, 101, 109, 113, 115, 123, 127, 129, 133, 137,
+        31, 31, 31, 32, 35, 39, 40, 42, 47, 47, 46, 46, 47, 48, 49, 51, 37, 38,
+        39, 40, 43, 47, 47, 47, 48, 47, 47, 46, 46, 47, 47, 49, 48, 47, 46, 46,
+        46, 47, 48, 50, 53, 53, 54, 55, 55, 55, 56, 57, 52, 50, 48, 48, 47, 47,
+        48, 50, 54, 56, 57, 61, 63, 64, 66, 68,
         /* Size 8x32 */
-        64, 62, 71, 77, 96, 98, 101, 105, 63, 63, 73, 79, 95, 96, 98, 101, 63,
-        63, 74, 80, 94, 94, 97, 100, 62, 63, 74, 80, 94, 94, 96, 100, 61, 64,
-        76, 81, 92, 91, 93, 97, 61, 64, 76, 82, 92, 91, 93, 96, 62, 66, 77, 83,
-        92, 91, 93, 96, 67, 71, 82, 87, 94, 91, 93, 95, 67, 72, 83, 88, 94, 92,
-        93, 95, 69, 74, 85, 90, 94, 91, 93, 95, 74, 80, 91, 95, 95, 91, 92, 94,
-        74, 80, 91, 95, 95, 91, 92, 94, 78, 82, 92, 95, 97, 94, 95, 97, 84, 86,
-        93, 96, 100, 99, 100, 101, 84, 86, 93, 96, 100, 99, 100, 101, 90, 89,
-        94, 97, 103, 103, 104, 105, 98, 93, 96, 98, 106, 107, 108, 109, 98, 93,
-        96, 98, 106, 107, 108, 109, 97, 92, 94, 97, 106, 110, 111, 113, 97, 92,
-        93, 96, 106, 112, 113, 115, 97, 92, 93, 96, 106, 112, 113, 115, 98, 91,
-        92, 95, 107, 115, 117, 120, 98, 91, 91, 94, 107, 117, 119, 123, 98, 91,
-        92, 94, 107, 117, 120, 123, 100, 93, 93, 96, 108, 119, 122, 127, 101,
-        93, 93, 96, 108, 119, 123, 128, 102, 94, 94, 96, 108, 120, 123, 129,
-        104, 96, 95, 97, 109, 122, 126, 133, 104, 96, 95, 97, 109, 122, 127,
-        133, 106, 97, 96, 98, 109, 123, 127, 134, 109, 100, 98, 100, 111, 125,
-        130, 137, 109, 100, 98, 100, 111, 125, 130, 137,
+        32, 31, 35, 38, 48, 49, 50, 52, 31, 31, 36, 39, 47, 48, 49, 50, 31, 31,
+        37, 40, 47, 47, 48, 50, 31, 31, 37, 40, 47, 47, 48, 50, 30, 32, 38, 40,
+        46, 45, 46, 48, 30, 32, 38, 41, 46, 45, 46, 48, 31, 33, 38, 41, 46, 45,
+        46, 48, 33, 35, 41, 43, 47, 45, 46, 47, 33, 36, 41, 44, 47, 46, 46, 47,
+        34, 37, 42, 45, 47, 45, 46, 47, 37, 40, 45, 47, 47, 45, 46, 47, 37, 40,
+        45, 47, 47, 45, 46, 47, 39, 41, 46, 47, 48, 47, 47, 48, 42, 43, 46, 48,
+        50, 49, 50, 50, 42, 43, 46, 48, 50, 49, 50, 50, 45, 44, 47, 48, 51, 51,
+        52, 52, 49, 46, 48, 49, 53, 53, 54, 54, 49, 46, 48, 49, 53, 53, 54, 54,
+        48, 46, 47, 48, 53, 55, 55, 56, 48, 46, 46, 48, 53, 56, 56, 57, 48, 46,
+        46, 48, 53, 56, 56, 57, 49, 45, 46, 47, 53, 57, 58, 60, 49, 45, 45, 47,
+        53, 58, 59, 61, 49, 45, 46, 47, 53, 58, 60, 61, 50, 46, 46, 48, 54, 59,
+        61, 63, 50, 46, 46, 48, 54, 59, 61, 64, 51, 47, 47, 48, 54, 60, 61, 64,
+        52, 48, 47, 48, 54, 61, 63, 66, 52, 48, 47, 48, 54, 61, 63, 66, 53, 48,
+        48, 49, 54, 61, 63, 67, 54, 50, 49, 50, 55, 62, 65, 68, 54, 50, 49, 50,
+        55, 62, 65, 68,
         /* Size 32x8 */
-        64, 63, 63, 62, 61, 61, 62, 67, 67, 69, 74, 74, 78, 84, 84, 90, 98, 98,
-        97, 97, 97, 98, 98, 98, 100, 101, 102, 104, 104, 106, 109, 109, 62, 63,
-        63, 63, 64, 64, 66, 71, 72, 74, 80, 80, 82, 86, 86, 89, 93, 93, 92, 92,
-        92, 91, 91, 91, 93, 93, 94, 96, 96, 97, 100, 100, 71, 73, 74, 74, 76,
-        76, 77, 82, 83, 85, 91, 91, 92, 93, 93, 94, 96, 96, 94, 93, 93, 92, 91,
-        92, 93, 93, 94, 95, 95, 96, 98, 98, 77, 79, 80, 80, 81, 82, 83, 87, 88,
-        90, 95, 95, 95, 96, 96, 97, 98, 98, 97, 96, 96, 95, 94, 94, 96, 96, 96,
-        97, 97, 98, 100, 100, 96, 95, 94, 94, 92, 92, 92, 94, 94, 94, 95, 95,
-        97, 100, 100, 103, 106, 106, 106, 106, 106, 107, 107, 107, 108, 108,
-        108, 109, 109, 109, 111, 111, 98, 96, 94, 94, 91, 91, 91, 91, 92, 91,
-        91, 91, 94, 99, 99, 103, 107, 107, 110, 112, 112, 115, 117, 117, 119,
-        119, 120, 122, 122, 123, 125, 125, 101, 98, 97, 96, 93, 93, 93, 93, 93,
-        93, 92, 92, 95, 100, 100, 104, 108, 108, 111, 113, 113, 117, 119, 120,
-        122, 123, 123, 126, 127, 127, 130, 130, 105, 101, 100, 100, 97, 96, 96,
-        95, 95, 95, 94, 94, 97, 101, 101, 105, 109, 109, 113, 115, 115, 120,
-        123, 123, 127, 128, 129, 133, 133, 134, 137, 137 },
+        32, 31, 31, 31, 30, 30, 31, 33, 33, 34, 37, 37, 39, 42, 42, 45, 49, 49,
+        48, 48, 48, 49, 49, 49, 50, 50, 51, 52, 52, 53, 54, 54, 31, 31, 31, 31,
+        32, 32, 33, 35, 36, 37, 40, 40, 41, 43, 43, 44, 46, 46, 46, 46, 46, 45,
+        45, 45, 46, 46, 47, 48, 48, 48, 50, 50, 35, 36, 37, 37, 38, 38, 38, 41,
+        41, 42, 45, 45, 46, 46, 46, 47, 48, 48, 47, 46, 46, 46, 45, 46, 46, 46,
+        47, 47, 47, 48, 49, 49, 38, 39, 40, 40, 40, 41, 41, 43, 44, 45, 47, 47,
+        47, 48, 48, 48, 49, 49, 48, 48, 48, 47, 47, 47, 48, 48, 48, 48, 48, 49,
+        50, 50, 48, 47, 47, 47, 46, 46, 46, 47, 47, 47, 47, 47, 48, 50, 50, 51,
+        53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 55, 55, 49, 48,
+        47, 47, 45, 45, 45, 45, 46, 45, 45, 45, 47, 49, 49, 51, 53, 53, 55, 56,
+        56, 57, 58, 58, 59, 59, 60, 61, 61, 61, 62, 62, 50, 49, 48, 48, 46, 46,
+        46, 46, 46, 46, 46, 46, 47, 50, 50, 52, 54, 54, 55, 56, 56, 58, 59, 60,
+        61, 61, 61, 63, 63, 63, 65, 65, 52, 50, 50, 50, 48, 48, 48, 47, 47, 47,
+        47, 47, 48, 50, 50, 52, 54, 54, 56, 57, 57, 60, 61, 61, 63, 64, 64, 66,
+        66, 67, 68, 68 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        65, 76, 76, 108,
+        32, 38, 38, 54,
 #endif
         /* Size 4x4 */
-        64, 65, 70, 86, 65, 69, 75, 86, 70, 75, 97, 109, 86, 86, 109, 130,
+        32, 32, 35, 43, 32, 34, 37, 43, 35, 37, 48, 54, 43, 43, 54, 65,
         /* Size 8x8 */
-        63, 63, 64, 64, 68, 75, 86, 94, 63, 65, 65, 65, 68, 72, 82, 89, 64, 65,
-        67, 68, 71, 76, 84, 91, 64, 65, 68, 71, 74, 79, 85, 92, 68, 68, 71, 74,
-        82, 90, 98, 104, 75, 72, 76, 79, 90, 103, 112, 119, 86, 82, 84, 85, 98,
-        112, 127, 134, 94, 89, 91, 92, 104, 119, 134, 142,
+        31, 31, 32, 32, 34, 37, 43, 47, 31, 32, 32, 32, 34, 36, 41, 44, 32, 32,
+        33, 34, 35, 38, 42, 45, 32, 32, 34, 35, 37, 39, 42, 46, 34, 34, 35, 37,
+        41, 45, 49, 52, 37, 36, 38, 39, 45, 51, 56, 59, 43, 41, 42, 42, 49, 56,
+        63, 67, 47, 44, 45, 46, 52, 59, 67, 71,
         /* Size 16x16 */
-        64, 63, 63, 63, 63, 63, 64, 65, 68, 71, 72, 79, 82, 88, 95, 97, 63, 64,
-        64, 64, 64, 64, 65, 66, 68, 70, 70, 77, 80, 85, 91, 93, 63, 64, 64, 64,
-        65, 65, 65, 66, 68, 69, 70, 76, 79, 84, 90, 91, 63, 64, 64, 65, 65, 65,
-        65, 66, 67, 68, 69, 75, 77, 82, 88, 89, 63, 64, 65, 65, 66, 66, 67, 68,
-        70, 72, 72, 78, 80, 84, 89, 91, 63, 64, 65, 65, 66, 67, 68, 69, 71, 72,
-        73, 78, 81, 84, 90, 91, 64, 65, 65, 65, 67, 68, 71, 72, 74, 76, 77, 81,
-        83, 85, 90, 92, 65, 66, 66, 66, 68, 69, 72, 73, 76, 79, 80, 84, 86, 89,
-        94, 95, 68, 68, 68, 67, 70, 71, 74, 76, 79, 84, 85, 90, 92, 95, 100,
-        102, 71, 70, 69, 68, 72, 72, 76, 79, 84, 92, 94, 99, 101, 105, 110, 111,
-        72, 70, 70, 69, 72, 73, 77, 80, 85, 94, 97, 101, 104, 108, 112, 114, 79,
-        77, 76, 75, 78, 78, 81, 84, 90, 99, 101, 108, 111, 116, 121, 122, 82,
-        80, 79, 77, 80, 81, 83, 86, 92, 101, 104, 111, 114, 120, 125, 127, 88,
-        85, 84, 82, 84, 84, 85, 89, 95, 105, 108, 116, 120, 127, 133, 134, 95,
-        91, 90, 88, 89, 90, 90, 94, 100, 110, 112, 121, 125, 133, 139, 141, 97,
-        93, 91, 89, 91, 91, 92, 95, 102, 111, 114, 122, 127, 134, 141, 142,
+        32, 31, 31, 31, 31, 31, 32, 32, 34, 35, 36, 39, 41, 44, 47, 48, 31, 32,
+        32, 32, 32, 32, 32, 33, 34, 35, 35, 38, 40, 42, 45, 46, 31, 32, 32, 32,
+        32, 32, 32, 33, 34, 34, 35, 38, 39, 42, 45, 45, 31, 32, 32, 32, 32, 32,
+        32, 33, 33, 34, 34, 37, 38, 41, 44, 44, 31, 32, 32, 32, 33, 33, 33, 34,
+        35, 36, 36, 39, 40, 42, 44, 45, 31, 32, 32, 32, 33, 33, 34, 34, 35, 36,
+        36, 39, 40, 42, 45, 45, 32, 32, 32, 32, 33, 34, 35, 36, 37, 38, 38, 40,
+        41, 42, 45, 46, 32, 33, 33, 33, 34, 34, 36, 36, 38, 39, 40, 42, 43, 44,
+        47, 47, 34, 34, 34, 33, 35, 35, 37, 38, 39, 42, 42, 45, 46, 47, 50, 51,
+        35, 35, 34, 34, 36, 36, 38, 39, 42, 46, 47, 49, 50, 52, 55, 55, 36, 35,
+        35, 34, 36, 36, 38, 40, 42, 47, 48, 50, 52, 54, 56, 57, 39, 38, 38, 37,
+        39, 39, 40, 42, 45, 49, 50, 54, 55, 58, 60, 61, 41, 40, 39, 38, 40, 40,
+        41, 43, 46, 50, 52, 55, 57, 60, 62, 63, 44, 42, 42, 41, 42, 42, 42, 44,
+        47, 52, 54, 58, 60, 63, 66, 67, 47, 45, 45, 44, 44, 45, 45, 47, 50, 55,
+        56, 60, 62, 66, 69, 70, 48, 46, 45, 44, 45, 45, 46, 47, 51, 55, 57, 61,
+        63, 67, 70, 71,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 65, 68, 68, 68,
-        71, 72, 72, 76, 79, 79, 82, 88, 88, 90, 95, 97, 97, 103, 63, 63, 63, 63,
-        63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 66, 68, 68, 68, 70, 71, 71, 75,
-        78, 78, 81, 86, 86, 88, 93, 94, 94, 100, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 65, 65, 65, 66, 68, 68, 68, 70, 70, 70, 74, 77, 77, 80, 85,
-        85, 86, 91, 93, 93, 99, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65,
-        65, 65, 66, 68, 68, 68, 70, 70, 70, 74, 77, 77, 80, 85, 85, 86, 91, 93,
-        93, 99, 63, 63, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 66, 68,
-        68, 68, 69, 70, 70, 73, 76, 76, 79, 84, 84, 85, 90, 91, 91, 97, 63, 63,
-        64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 67, 68, 68, 69,
-        69, 72, 75, 75, 77, 82, 82, 83, 88, 89, 89, 95, 63, 63, 64, 64, 64, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 67, 68, 68, 69, 69, 72, 75, 75,
-        77, 82, 82, 83, 88, 89, 89, 95, 63, 64, 64, 64, 64, 65, 65, 65, 65, 65,
-        65, 66, 66, 66, 67, 68, 68, 68, 69, 70, 70, 73, 76, 76, 78, 82, 82, 84,
-        88, 90, 90, 95, 63, 64, 64, 64, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67,
-        68, 70, 70, 70, 72, 72, 72, 75, 78, 78, 80, 84, 84, 85, 89, 91, 91, 96,
-        63, 64, 64, 64, 65, 65, 65, 65, 66, 67, 67, 67, 68, 68, 69, 71, 71, 71,
-        72, 73, 73, 76, 78, 78, 81, 84, 84, 85, 90, 91, 91, 96, 63, 64, 64, 64,
-        65, 65, 65, 65, 66, 67, 67, 67, 68, 68, 69, 71, 71, 71, 72, 73, 73, 76,
-        78, 78, 81, 84, 84, 85, 90, 91, 91, 96, 64, 64, 65, 65, 65, 65, 65, 66,
-        67, 67, 67, 69, 70, 70, 71, 72, 72, 73, 75, 75, 75, 78, 80, 80, 82, 85,
-        85, 86, 90, 91, 91, 96, 64, 64, 65, 65, 65, 65, 65, 66, 67, 68, 68, 70,
-        71, 71, 72, 74, 74, 74, 76, 77, 77, 79, 81, 81, 83, 85, 85, 87, 90, 92,
-        92, 96, 64, 64, 65, 65, 65, 65, 65, 66, 67, 68, 68, 70, 71, 71, 72, 74,
-        74, 74, 76, 77, 77, 79, 81, 81, 83, 85, 85, 87, 90, 92, 92, 96, 65, 66,
-        66, 66, 66, 66, 66, 67, 68, 69, 69, 71, 72, 72, 73, 76, 76, 76, 79, 80,
-        80, 82, 84, 84, 86, 89, 89, 90, 94, 95, 95, 100, 68, 68, 68, 68, 68, 67,
-        67, 68, 70, 71, 71, 72, 74, 74, 76, 79, 79, 80, 84, 85, 85, 88, 90, 90,
-        92, 95, 95, 97, 100, 102, 102, 106, 68, 68, 68, 68, 68, 67, 67, 68, 70,
-        71, 71, 72, 74, 74, 76, 79, 79, 80, 84, 85, 85, 88, 90, 90, 92, 95, 95,
-        97, 100, 102, 102, 106, 68, 68, 68, 68, 68, 68, 68, 68, 70, 71, 71, 73,
-        74, 74, 76, 80, 80, 82, 86, 88, 88, 90, 92, 92, 94, 98, 98, 99, 103,
-        104, 104, 108, 71, 70, 70, 70, 69, 68, 68, 69, 72, 72, 72, 75, 76, 76,
-        79, 84, 84, 86, 92, 94, 94, 97, 99, 99, 101, 105, 105, 106, 110, 111,
-        111, 115, 72, 71, 70, 70, 70, 69, 69, 70, 72, 73, 73, 75, 77, 77, 80,
-        85, 85, 88, 94, 97, 97, 100, 101, 101, 104, 108, 108, 109, 112, 114,
-        114, 117, 72, 71, 70, 70, 70, 69, 69, 70, 72, 73, 73, 75, 77, 77, 80,
-        85, 85, 88, 94, 97, 97, 100, 101, 101, 104, 108, 108, 109, 112, 114,
-        114, 117, 76, 75, 74, 74, 73, 72, 72, 73, 75, 76, 76, 78, 79, 79, 82,
-        88, 88, 90, 97, 100, 100, 103, 105, 105, 108, 112, 112, 114, 117, 119,
-        119, 123, 79, 78, 77, 77, 76, 75, 75, 76, 78, 78, 78, 80, 81, 81, 84,
-        90, 90, 92, 99, 101, 101, 105, 108, 108, 111, 116, 116, 117, 121, 122,
-        122, 127, 79, 78, 77, 77, 76, 75, 75, 76, 78, 78, 78, 80, 81, 81, 84,
-        90, 90, 92, 99, 101, 101, 105, 108, 108, 111, 116, 116, 117, 121, 122,
-        122, 127, 82, 81, 80, 80, 79, 77, 77, 78, 80, 81, 81, 82, 83, 83, 86,
-        92, 92, 94, 101, 104, 104, 108, 111, 111, 114, 120, 120, 121, 125, 127,
-        127, 132, 88, 86, 85, 85, 84, 82, 82, 82, 84, 84, 84, 85, 85, 85, 89,
-        95, 95, 98, 105, 108, 108, 112, 116, 116, 120, 127, 127, 128, 133, 134,
-        134, 139, 88, 86, 85, 85, 84, 82, 82, 82, 84, 84, 84, 85, 85, 85, 89,
-        95, 95, 98, 105, 108, 108, 112, 116, 116, 120, 127, 127, 128, 133, 134,
-        134, 139, 90, 88, 86, 86, 85, 83, 83, 84, 85, 85, 85, 86, 87, 87, 90,
-        97, 97, 99, 106, 109, 109, 114, 117, 117, 121, 128, 128, 130, 134, 136,
-        136, 141, 95, 93, 91, 91, 90, 88, 88, 88, 89, 90, 90, 90, 90, 90, 94,
-        100, 100, 103, 110, 112, 112, 117, 121, 121, 125, 133, 133, 134, 139,
-        141, 141, 146, 97, 94, 93, 93, 91, 89, 89, 90, 91, 91, 91, 91, 92, 92,
-        95, 102, 102, 104, 111, 114, 114, 119, 122, 122, 127, 134, 134, 136,
-        141, 142, 142, 148, 97, 94, 93, 93, 91, 89, 89, 90, 91, 91, 91, 91, 92,
-        92, 95, 102, 102, 104, 111, 114, 114, 119, 122, 122, 127, 134, 134, 136,
-        141, 142, 142, 148, 103, 100, 99, 99, 97, 95, 95, 95, 96, 96, 96, 96,
-        96, 96, 100, 106, 106, 108, 115, 117, 117, 123, 127, 127, 132, 139, 139,
-        141, 146, 148, 148, 155,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 34, 34,
+        35, 36, 36, 38, 39, 39, 41, 44, 44, 45, 47, 48, 48, 51, 31, 31, 31, 31,
+        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 35, 35, 35, 37,
+        39, 39, 40, 43, 43, 44, 46, 47, 47, 50, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 35, 35, 35, 37, 38, 38, 40, 42,
+        42, 43, 45, 46, 46, 49, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 34, 34, 34, 35, 35, 35, 37, 38, 38, 40, 42, 42, 43, 45, 46,
+        46, 49, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34,
+        34, 34, 34, 35, 35, 36, 38, 38, 39, 42, 42, 42, 45, 45, 45, 48, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34,
+        34, 36, 37, 37, 38, 41, 41, 41, 44, 44, 44, 47, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 36, 37, 37,
+        38, 41, 41, 41, 44, 44, 44, 47, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 36, 38, 38, 39, 41, 41, 42,
+        44, 45, 45, 47, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
+        34, 35, 35, 35, 36, 36, 36, 37, 39, 39, 40, 42, 42, 42, 44, 45, 45, 48,
+        31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35, 35, 35,
+        36, 36, 36, 38, 39, 39, 40, 42, 42, 42, 45, 45, 45, 48, 31, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 38,
+        39, 39, 40, 42, 42, 42, 45, 45, 45, 48, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 33, 33, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 39, 40, 40, 41, 42,
+        42, 43, 45, 45, 45, 48, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 35,
+        35, 35, 36, 37, 37, 37, 38, 38, 38, 39, 40, 40, 41, 42, 42, 43, 45, 46,
+        46, 48, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 35, 35, 35, 36, 37,
+        37, 37, 38, 38, 38, 39, 40, 40, 41, 42, 42, 43, 45, 46, 46, 48, 32, 33,
+        33, 33, 33, 33, 33, 33, 34, 34, 34, 35, 36, 36, 36, 38, 38, 38, 39, 40,
+        40, 41, 42, 42, 43, 44, 44, 45, 47, 47, 47, 50, 34, 34, 34, 34, 34, 33,
+        33, 34, 35, 35, 35, 36, 37, 37, 38, 39, 39, 40, 42, 42, 42, 44, 45, 45,
+        46, 47, 47, 48, 50, 51, 51, 53, 34, 34, 34, 34, 34, 33, 33, 34, 35, 35,
+        35, 36, 37, 37, 38, 39, 39, 40, 42, 42, 42, 44, 45, 45, 46, 47, 47, 48,
+        50, 51, 51, 53, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 36, 37, 37,
+        38, 40, 40, 41, 43, 44, 44, 45, 46, 46, 47, 49, 49, 49, 51, 52, 52, 54,
+        35, 35, 35, 35, 34, 34, 34, 34, 36, 36, 36, 37, 38, 38, 39, 42, 42, 43,
+        46, 47, 47, 48, 49, 49, 50, 52, 52, 53, 55, 55, 55, 57, 36, 35, 35, 35,
+        35, 34, 34, 35, 36, 36, 36, 37, 38, 38, 40, 42, 42, 44, 47, 48, 48, 50,
+        50, 50, 52, 54, 54, 54, 56, 57, 57, 58, 36, 35, 35, 35, 35, 34, 34, 35,
+        36, 36, 36, 37, 38, 38, 40, 42, 42, 44, 47, 48, 48, 50, 50, 50, 52, 54,
+        54, 54, 56, 57, 57, 58, 38, 37, 37, 37, 36, 36, 36, 36, 37, 38, 38, 39,
+        39, 39, 41, 44, 44, 45, 48, 50, 50, 51, 52, 52, 54, 56, 56, 57, 58, 59,
+        59, 61, 39, 39, 38, 38, 38, 37, 37, 38, 39, 39, 39, 40, 40, 40, 42, 45,
+        45, 46, 49, 50, 50, 52, 54, 54, 55, 58, 58, 58, 60, 61, 61, 63, 39, 39,
+        38, 38, 38, 37, 37, 38, 39, 39, 39, 40, 40, 40, 42, 45, 45, 46, 49, 50,
+        50, 52, 54, 54, 55, 58, 58, 58, 60, 61, 61, 63, 41, 40, 40, 40, 39, 38,
+        38, 39, 40, 40, 40, 41, 41, 41, 43, 46, 46, 47, 50, 52, 52, 54, 55, 55,
+        57, 60, 60, 60, 62, 63, 63, 66, 44, 43, 42, 42, 42, 41, 41, 41, 42, 42,
+        42, 42, 42, 42, 44, 47, 47, 49, 52, 54, 54, 56, 58, 58, 60, 63, 63, 64,
+        66, 67, 67, 69, 44, 43, 42, 42, 42, 41, 41, 41, 42, 42, 42, 42, 42, 42,
+        44, 47, 47, 49, 52, 54, 54, 56, 58, 58, 60, 63, 63, 64, 66, 67, 67, 69,
+        45, 44, 43, 43, 42, 41, 41, 42, 42, 42, 42, 43, 43, 43, 45, 48, 48, 49,
+        53, 54, 54, 57, 58, 58, 60, 64, 64, 65, 67, 68, 68, 70, 47, 46, 45, 45,
+        45, 44, 44, 44, 44, 45, 45, 45, 45, 45, 47, 50, 50, 51, 55, 56, 56, 58,
+        60, 60, 62, 66, 66, 67, 69, 70, 70, 73, 48, 47, 46, 46, 45, 44, 44, 45,
+        45, 45, 45, 45, 46, 46, 47, 51, 51, 52, 55, 57, 57, 59, 61, 61, 63, 67,
+        67, 68, 70, 71, 71, 74, 48, 47, 46, 46, 45, 44, 44, 45, 45, 45, 45, 45,
+        46, 46, 47, 51, 51, 52, 55, 57, 57, 59, 61, 61, 63, 67, 67, 68, 70, 71,
+        71, 74, 51, 50, 49, 49, 48, 47, 47, 47, 48, 48, 48, 48, 48, 48, 50, 53,
+        53, 54, 57, 58, 58, 61, 63, 63, 66, 69, 69, 70, 73, 74, 74, 77,
         /* Size 4x8 */
-        63, 65, 71, 86, 64, 66, 69, 82, 65, 68, 73, 84, 65, 71, 77, 85, 68, 74,
-        87, 98, 74, 80, 99, 112, 84, 86, 107, 126, 92, 93, 113, 134,
+        31, 32, 35, 43, 32, 33, 34, 41, 32, 34, 36, 42, 32, 35, 38, 42, 34, 37,
+        43, 49, 37, 40, 49, 56, 42, 43, 53, 63, 46, 46, 56, 67,
         /* Size 8x4 */
-        63, 64, 65, 65, 68, 74, 84, 92, 65, 66, 68, 71, 74, 80, 86, 93, 71, 69,
-        73, 77, 87, 99, 107, 113, 86, 82, 84, 85, 98, 112, 126, 134,
+        31, 32, 32, 32, 34, 37, 42, 46, 32, 33, 34, 35, 37, 40, 43, 46, 35, 34,
+        36, 38, 43, 49, 53, 56, 43, 41, 42, 42, 49, 56, 63, 67,
         /* Size 8x16 */
-        64, 63, 63, 64, 70, 72, 88, 95, 63, 64, 64, 65, 70, 71, 85, 91, 63, 64,
-        65, 65, 69, 70, 83, 90, 63, 65, 65, 66, 68, 69, 82, 88, 63, 65, 66, 68,
-        71, 72, 84, 89, 64, 65, 66, 68, 72, 73, 84, 90, 64, 66, 68, 71, 75, 77,
-        85, 90, 65, 66, 69, 72, 78, 80, 89, 94, 68, 68, 70, 74, 83, 85, 96, 101,
-        71, 69, 72, 76, 90, 94, 105, 110, 72, 69, 72, 77, 92, 96, 108, 112, 79,
-        75, 78, 81, 96, 101, 116, 121, 82, 78, 80, 83, 99, 103, 120, 125, 88,
-        82, 84, 86, 102, 107, 126, 132, 94, 88, 89, 91, 107, 112, 132, 139, 96,
-        90, 91, 93, 108, 113, 134, 140,
+        32, 31, 31, 32, 35, 36, 44, 47, 31, 32, 32, 32, 35, 35, 42, 45, 31, 32,
+        32, 32, 34, 35, 41, 45, 31, 32, 32, 33, 34, 34, 41, 44, 31, 32, 33, 34,
+        35, 36, 42, 44, 32, 32, 33, 34, 36, 36, 42, 45, 32, 33, 34, 35, 37, 38,
+        42, 45, 32, 33, 34, 36, 39, 40, 44, 47, 34, 34, 35, 37, 41, 42, 48, 50,
+        35, 34, 36, 38, 45, 47, 52, 55, 36, 34, 36, 38, 46, 48, 54, 56, 39, 37,
+        39, 40, 48, 50, 58, 60, 41, 39, 40, 41, 49, 51, 60, 62, 44, 41, 42, 43,
+        51, 53, 63, 66, 47, 44, 44, 45, 53, 56, 66, 69, 48, 45, 45, 46, 54, 56,
+        67, 70,
         /* Size 16x8 */
-        64, 63, 63, 63, 63, 64, 64, 65, 68, 71, 72, 79, 82, 88, 94, 96, 63, 64,
-        64, 65, 65, 65, 66, 66, 68, 69, 69, 75, 78, 82, 88, 90, 63, 64, 65, 65,
-        66, 66, 68, 69, 70, 72, 72, 78, 80, 84, 89, 91, 64, 65, 65, 66, 68, 68,
-        71, 72, 74, 76, 77, 81, 83, 86, 91, 93, 70, 70, 69, 68, 71, 72, 75, 78,
-        83, 90, 92, 96, 99, 102, 107, 108, 72, 71, 70, 69, 72, 73, 77, 80, 85,
-        94, 96, 101, 103, 107, 112, 113, 88, 85, 83, 82, 84, 84, 85, 89, 96,
-        105, 108, 116, 120, 126, 132, 134, 95, 91, 90, 88, 89, 90, 90, 94, 101,
-        110, 112, 121, 125, 132, 139, 140,
+        32, 31, 31, 31, 31, 32, 32, 32, 34, 35, 36, 39, 41, 44, 47, 48, 31, 32,
+        32, 32, 32, 32, 33, 33, 34, 34, 34, 37, 39, 41, 44, 45, 31, 32, 32, 32,
+        33, 33, 34, 34, 35, 36, 36, 39, 40, 42, 44, 45, 32, 32, 32, 33, 34, 34,
+        35, 36, 37, 38, 38, 40, 41, 43, 45, 46, 35, 35, 34, 34, 35, 36, 37, 39,
+        41, 45, 46, 48, 49, 51, 53, 54, 36, 35, 35, 34, 36, 36, 38, 40, 42, 47,
+        48, 50, 51, 53, 56, 56, 44, 42, 41, 41, 42, 42, 42, 44, 48, 52, 54, 58,
+        60, 63, 66, 67, 47, 45, 45, 44, 44, 45, 45, 47, 50, 55, 56, 60, 62, 66,
+        69, 70,
         /* Size 16x32 */
-        64, 63, 63, 63, 63, 64, 64, 65, 70, 72, 72, 81, 88, 88, 95, 107, 63, 63,
-        64, 64, 64, 65, 65, 66, 70, 71, 71, 79, 86, 86, 93, 105, 63, 64, 64, 64,
-        64, 65, 65, 66, 70, 71, 71, 79, 85, 85, 91, 103, 63, 64, 64, 64, 64, 65,
-        65, 66, 70, 71, 71, 79, 85, 85, 91, 103, 63, 64, 64, 64, 65, 65, 65, 66,
-        69, 70, 70, 78, 83, 83, 90, 101, 63, 64, 65, 65, 65, 66, 66, 66, 68, 69,
-        69, 76, 82, 82, 88, 99, 63, 64, 65, 65, 65, 66, 66, 66, 68, 69, 69, 76,
-        82, 82, 88, 99, 63, 64, 65, 65, 65, 66, 66, 67, 69, 70, 70, 77, 82, 82,
-        88, 99, 63, 64, 65, 65, 66, 68, 68, 69, 71, 72, 72, 79, 84, 84, 89, 99,
-        64, 65, 65, 65, 66, 68, 68, 69, 72, 73, 73, 79, 84, 84, 90, 100, 64, 65,
-        65, 65, 66, 68, 68, 69, 72, 73, 73, 79, 84, 84, 90, 100, 64, 65, 65, 65,
-        67, 70, 70, 71, 74, 75, 75, 81, 85, 85, 90, 99, 64, 65, 66, 66, 68, 71,
-        71, 72, 75, 77, 77, 82, 85, 85, 90, 99, 64, 65, 66, 66, 68, 71, 71, 72,
-        75, 77, 77, 82, 85, 85, 90, 99, 65, 66, 66, 66, 69, 72, 72, 73, 78, 80,
-        80, 85, 89, 89, 94, 103, 68, 68, 68, 68, 70, 74, 74, 76, 83, 85, 85, 91,
-        96, 96, 101, 109, 68, 68, 68, 68, 70, 74, 74, 76, 83, 85, 85, 91, 96,
-        96, 101, 109, 68, 68, 68, 68, 70, 74, 74, 77, 84, 87, 87, 93, 98, 98,
-        103, 111, 71, 70, 69, 69, 72, 76, 76, 79, 90, 94, 94, 100, 105, 105,
-        110, 118, 72, 70, 69, 69, 72, 77, 77, 80, 92, 96, 96, 103, 108, 108,
-        112, 120, 72, 70, 69, 69, 72, 77, 77, 80, 92, 96, 96, 103, 108, 108,
-        112, 120, 76, 74, 73, 73, 75, 80, 80, 83, 94, 99, 99, 107, 112, 112,
-        117, 126, 79, 77, 75, 75, 78, 81, 81, 85, 96, 101, 101, 109, 116, 116,
-        121, 130, 79, 77, 75, 75, 78, 81, 81, 85, 96, 101, 101, 109, 116, 116,
-        121, 130, 82, 80, 78, 78, 80, 83, 83, 87, 99, 103, 103, 113, 120, 120,
-        125, 135, 88, 84, 82, 82, 84, 86, 86, 90, 102, 107, 107, 118, 126, 126,
-        132, 143, 88, 84, 82, 82, 84, 86, 86, 90, 102, 107, 107, 118, 126, 126,
-        132, 143, 89, 86, 84, 84, 85, 87, 87, 91, 103, 108, 108, 119, 128, 128,
-        134, 145, 94, 91, 88, 88, 89, 91, 91, 95, 107, 112, 112, 123, 132, 132,
-        139, 150, 96, 92, 90, 90, 91, 93, 93, 96, 108, 113, 113, 125, 134, 134,
-        140, 152, 96, 92, 90, 90, 91, 93, 93, 96, 108, 113, 113, 125, 134, 134,
-        140, 152, 103, 98, 95, 95, 96, 97, 97, 100, 112, 117, 117, 129, 139,
-        139, 146, 159,
+        32, 31, 31, 31, 31, 32, 32, 32, 35, 36, 36, 40, 44, 44, 47, 53, 31, 31,
+        32, 32, 32, 32, 32, 33, 35, 35, 35, 39, 43, 43, 46, 52, 31, 32, 32, 32,
+        32, 32, 32, 33, 35, 35, 35, 39, 42, 42, 45, 51, 31, 32, 32, 32, 32, 32,
+        32, 33, 35, 35, 35, 39, 42, 42, 45, 51, 31, 32, 32, 32, 32, 32, 32, 33,
+        34, 35, 35, 39, 41, 41, 45, 50, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34,
+        34, 38, 41, 41, 44, 49, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 38,
+        41, 41, 44, 49, 31, 32, 32, 32, 32, 33, 33, 33, 34, 35, 35, 38, 41, 41,
+        44, 49, 31, 32, 32, 32, 33, 34, 34, 34, 35, 36, 36, 39, 42, 42, 44, 49,
+        32, 32, 32, 32, 33, 34, 34, 34, 36, 36, 36, 39, 42, 42, 45, 50, 32, 32,
+        32, 32, 33, 34, 34, 34, 36, 36, 36, 39, 42, 42, 45, 50, 32, 32, 32, 32,
+        33, 35, 35, 35, 37, 37, 37, 40, 42, 42, 45, 49, 32, 32, 33, 33, 34, 35,
+        35, 36, 37, 38, 38, 41, 42, 42, 45, 49, 32, 32, 33, 33, 34, 35, 35, 36,
+        37, 38, 38, 41, 42, 42, 45, 49, 32, 33, 33, 33, 34, 36, 36, 36, 39, 40,
+        40, 42, 44, 44, 47, 51, 34, 34, 34, 34, 35, 37, 37, 38, 41, 42, 42, 45,
+        48, 48, 50, 54, 34, 34, 34, 34, 35, 37, 37, 38, 41, 42, 42, 45, 48, 48,
+        50, 54, 34, 34, 34, 34, 35, 37, 37, 38, 42, 43, 43, 46, 49, 49, 51, 55,
+        35, 35, 34, 34, 36, 38, 38, 39, 45, 47, 47, 50, 52, 52, 55, 59, 36, 35,
+        34, 34, 36, 38, 38, 40, 46, 48, 48, 51, 54, 54, 56, 60, 36, 35, 34, 34,
+        36, 38, 38, 40, 46, 48, 48, 51, 54, 54, 56, 60, 38, 37, 36, 36, 37, 40,
+        40, 41, 47, 49, 49, 53, 56, 56, 58, 63, 39, 38, 37, 37, 39, 40, 40, 42,
+        48, 50, 50, 54, 58, 58, 60, 65, 39, 38, 37, 37, 39, 40, 40, 42, 48, 50,
+        50, 54, 58, 58, 60, 65, 41, 40, 39, 39, 40, 41, 41, 43, 49, 51, 51, 56,
+        60, 60, 62, 67, 44, 42, 41, 41, 42, 43, 43, 45, 51, 53, 53, 59, 63, 63,
+        66, 71, 44, 42, 41, 41, 42, 43, 43, 45, 51, 53, 53, 59, 63, 63, 66, 71,
+        44, 43, 42, 42, 42, 43, 43, 45, 51, 54, 54, 59, 64, 64, 67, 72, 47, 45,
+        44, 44, 44, 45, 45, 47, 53, 56, 56, 61, 66, 66, 69, 75, 48, 46, 45, 45,
+        45, 46, 46, 48, 54, 56, 56, 62, 67, 67, 70, 76, 48, 46, 45, 45, 45, 46,
+        46, 48, 54, 56, 56, 62, 67, 67, 70, 76, 51, 49, 47, 47, 48, 48, 48, 50,
+        56, 58, 58, 64, 69, 69, 73, 79,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 65, 68, 68, 68,
-        71, 72, 72, 76, 79, 79, 82, 88, 88, 89, 94, 96, 96, 103, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66, 68, 68, 68, 70, 70, 70, 74,
-        77, 77, 80, 84, 84, 86, 91, 92, 92, 98, 63, 64, 64, 64, 64, 65, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 68, 68, 68, 69, 69, 69, 73, 75, 75, 78, 82,
-        82, 84, 88, 90, 90, 95, 63, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65,
-        66, 66, 66, 68, 68, 68, 69, 69, 69, 73, 75, 75, 78, 82, 82, 84, 88, 90,
-        90, 95, 63, 64, 64, 64, 65, 65, 65, 65, 66, 66, 66, 67, 68, 68, 69, 70,
-        70, 70, 72, 72, 72, 75, 78, 78, 80, 84, 84, 85, 89, 91, 91, 96, 64, 65,
-        65, 65, 65, 66, 66, 66, 68, 68, 68, 70, 71, 71, 72, 74, 74, 74, 76, 77,
-        77, 80, 81, 81, 83, 86, 86, 87, 91, 93, 93, 97, 64, 65, 65, 65, 65, 66,
-        66, 66, 68, 68, 68, 70, 71, 71, 72, 74, 74, 74, 76, 77, 77, 80, 81, 81,
-        83, 86, 86, 87, 91, 93, 93, 97, 65, 66, 66, 66, 66, 66, 66, 67, 69, 69,
-        69, 71, 72, 72, 73, 76, 76, 77, 79, 80, 80, 83, 85, 85, 87, 90, 90, 91,
-        95, 96, 96, 100, 70, 70, 70, 70, 69, 68, 68, 69, 71, 72, 72, 74, 75, 75,
-        78, 83, 83, 84, 90, 92, 92, 94, 96, 96, 99, 102, 102, 103, 107, 108,
-        108, 112, 72, 71, 71, 71, 70, 69, 69, 70, 72, 73, 73, 75, 77, 77, 80,
-        85, 85, 87, 94, 96, 96, 99, 101, 101, 103, 107, 107, 108, 112, 113, 113,
-        117, 72, 71, 71, 71, 70, 69, 69, 70, 72, 73, 73, 75, 77, 77, 80, 85, 85,
-        87, 94, 96, 96, 99, 101, 101, 103, 107, 107, 108, 112, 113, 113, 117,
-        81, 79, 79, 79, 78, 76, 76, 77, 79, 79, 79, 81, 82, 82, 85, 91, 91, 93,
-        100, 103, 103, 107, 109, 109, 113, 118, 118, 119, 123, 125, 125, 129,
-        88, 86, 85, 85, 83, 82, 82, 82, 84, 84, 84, 85, 85, 85, 89, 96, 96, 98,
-        105, 108, 108, 112, 116, 116, 120, 126, 126, 128, 132, 134, 134, 139,
-        88, 86, 85, 85, 83, 82, 82, 82, 84, 84, 84, 85, 85, 85, 89, 96, 96, 98,
-        105, 108, 108, 112, 116, 116, 120, 126, 126, 128, 132, 134, 134, 139,
-        95, 93, 91, 91, 90, 88, 88, 88, 89, 90, 90, 90, 90, 90, 94, 101, 101,
-        103, 110, 112, 112, 117, 121, 121, 125, 132, 132, 134, 139, 140, 140,
-        146, 107, 105, 103, 103, 101, 99, 99, 99, 99, 100, 100, 99, 99, 99, 103,
-        109, 109, 111, 118, 120, 120, 126, 130, 130, 135, 143, 143, 145, 150,
-        152, 152, 159,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 34, 34, 34,
+        35, 36, 36, 38, 39, 39, 41, 44, 44, 44, 47, 48, 48, 51, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 35, 35, 35, 37,
+        38, 38, 40, 42, 42, 43, 45, 46, 46, 49, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 34, 36, 37, 37, 39, 41,
+        41, 42, 44, 45, 45, 47, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 34, 34, 34, 34, 34, 34, 36, 37, 37, 39, 41, 41, 42, 44, 45,
+        45, 47, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35,
+        35, 35, 36, 36, 36, 37, 39, 39, 40, 42, 42, 42, 44, 45, 45, 48, 32, 32,
+        32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 37, 37, 37, 38, 38,
+        38, 40, 40, 40, 41, 43, 43, 43, 45, 46, 46, 48, 32, 32, 32, 32, 32, 33,
+        33, 33, 34, 34, 34, 35, 35, 35, 36, 37, 37, 37, 38, 38, 38, 40, 40, 40,
+        41, 43, 43, 43, 45, 46, 46, 48, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34,
+        34, 35, 36, 36, 36, 38, 38, 38, 39, 40, 40, 41, 42, 42, 43, 45, 45, 45,
+        47, 48, 48, 50, 35, 35, 35, 35, 34, 34, 34, 34, 35, 36, 36, 37, 37, 37,
+        39, 41, 41, 42, 45, 46, 46, 47, 48, 48, 49, 51, 51, 51, 53, 54, 54, 56,
+        36, 35, 35, 35, 35, 34, 34, 35, 36, 36, 36, 37, 38, 38, 40, 42, 42, 43,
+        47, 48, 48, 49, 50, 50, 51, 53, 53, 54, 56, 56, 56, 58, 36, 35, 35, 35,
+        35, 34, 34, 35, 36, 36, 36, 37, 38, 38, 40, 42, 42, 43, 47, 48, 48, 49,
+        50, 50, 51, 53, 53, 54, 56, 56, 56, 58, 40, 39, 39, 39, 39, 38, 38, 38,
+        39, 39, 39, 40, 41, 41, 42, 45, 45, 46, 50, 51, 51, 53, 54, 54, 56, 59,
+        59, 59, 61, 62, 62, 64, 44, 43, 42, 42, 41, 41, 41, 41, 42, 42, 42, 42,
+        42, 42, 44, 48, 48, 49, 52, 54, 54, 56, 58, 58, 60, 63, 63, 64, 66, 67,
+        67, 69, 44, 43, 42, 42, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 44, 48,
+        48, 49, 52, 54, 54, 56, 58, 58, 60, 63, 63, 64, 66, 67, 67, 69, 47, 46,
+        45, 45, 45, 44, 44, 44, 44, 45, 45, 45, 45, 45, 47, 50, 50, 51, 55, 56,
+        56, 58, 60, 60, 62, 66, 66, 67, 69, 70, 70, 73, 53, 52, 51, 51, 50, 49,
+        49, 49, 49, 50, 50, 49, 49, 49, 51, 54, 54, 55, 59, 60, 60, 63, 65, 65,
+        67, 71, 71, 72, 75, 76, 76, 79,
         /* Size 4x16 */
-        63, 64, 72, 88, 64, 65, 71, 85, 64, 65, 70, 83, 64, 66, 69, 82, 64, 68,
-        72, 84, 65, 68, 73, 84, 65, 71, 77, 85, 66, 72, 80, 89, 68, 74, 85, 96,
-        70, 76, 94, 105, 70, 77, 96, 108, 77, 81, 101, 116, 80, 83, 103, 120,
-        84, 86, 107, 126, 91, 91, 112, 132, 92, 93, 113, 134,
+        31, 32, 36, 44, 32, 32, 35, 42, 32, 32, 35, 41, 32, 33, 34, 41, 32, 34,
+        36, 42, 32, 34, 36, 42, 32, 35, 38, 42, 33, 36, 40, 44, 34, 37, 42, 48,
+        35, 38, 47, 52, 35, 38, 48, 54, 38, 40, 50, 58, 40, 41, 51, 60, 42, 43,
+        53, 63, 45, 45, 56, 66, 46, 46, 56, 67,
         /* Size 16x4 */
-        63, 64, 64, 64, 64, 65, 65, 66, 68, 70, 70, 77, 80, 84, 91, 92, 64, 65,
-        65, 66, 68, 68, 71, 72, 74, 76, 77, 81, 83, 86, 91, 93, 72, 71, 70, 69,
-        72, 73, 77, 80, 85, 94, 96, 101, 103, 107, 112, 113, 88, 85, 83, 82, 84,
-        84, 85, 89, 96, 105, 108, 116, 120, 126, 132, 134,
+        31, 32, 32, 32, 32, 32, 32, 33, 34, 35, 35, 38, 40, 42, 45, 46, 32, 32,
+        32, 33, 34, 34, 35, 36, 37, 38, 38, 40, 41, 43, 45, 46, 36, 35, 35, 34,
+        36, 36, 38, 40, 42, 47, 48, 50, 51, 53, 56, 56, 44, 42, 41, 41, 42, 42,
+        42, 44, 48, 52, 54, 58, 60, 63, 66, 67,
         /* Size 8x32 */
-        64, 63, 63, 64, 70, 72, 88, 95, 63, 64, 64, 65, 70, 71, 86, 93, 63, 64,
-        64, 65, 70, 71, 85, 91, 63, 64, 64, 65, 70, 71, 85, 91, 63, 64, 65, 65,
-        69, 70, 83, 90, 63, 65, 65, 66, 68, 69, 82, 88, 63, 65, 65, 66, 68, 69,
-        82, 88, 63, 65, 65, 66, 69, 70, 82, 88, 63, 65, 66, 68, 71, 72, 84, 89,
-        64, 65, 66, 68, 72, 73, 84, 90, 64, 65, 66, 68, 72, 73, 84, 90, 64, 65,
-        67, 70, 74, 75, 85, 90, 64, 66, 68, 71, 75, 77, 85, 90, 64, 66, 68, 71,
-        75, 77, 85, 90, 65, 66, 69, 72, 78, 80, 89, 94, 68, 68, 70, 74, 83, 85,
-        96, 101, 68, 68, 70, 74, 83, 85, 96, 101, 68, 68, 70, 74, 84, 87, 98,
-        103, 71, 69, 72, 76, 90, 94, 105, 110, 72, 69, 72, 77, 92, 96, 108, 112,
-        72, 69, 72, 77, 92, 96, 108, 112, 76, 73, 75, 80, 94, 99, 112, 117, 79,
-        75, 78, 81, 96, 101, 116, 121, 79, 75, 78, 81, 96, 101, 116, 121, 82,
-        78, 80, 83, 99, 103, 120, 125, 88, 82, 84, 86, 102, 107, 126, 132, 88,
-        82, 84, 86, 102, 107, 126, 132, 89, 84, 85, 87, 103, 108, 128, 134, 94,
-        88, 89, 91, 107, 112, 132, 139, 96, 90, 91, 93, 108, 113, 134, 140, 96,
-        90, 91, 93, 108, 113, 134, 140, 103, 95, 96, 97, 112, 117, 139, 146,
+        32, 31, 31, 32, 35, 36, 44, 47, 31, 32, 32, 32, 35, 35, 43, 46, 31, 32,
+        32, 32, 35, 35, 42, 45, 31, 32, 32, 32, 35, 35, 42, 45, 31, 32, 32, 32,
+        34, 35, 41, 45, 31, 32, 32, 33, 34, 34, 41, 44, 31, 32, 32, 33, 34, 34,
+        41, 44, 31, 32, 32, 33, 34, 35, 41, 44, 31, 32, 33, 34, 35, 36, 42, 44,
+        32, 32, 33, 34, 36, 36, 42, 45, 32, 32, 33, 34, 36, 36, 42, 45, 32, 32,
+        33, 35, 37, 37, 42, 45, 32, 33, 34, 35, 37, 38, 42, 45, 32, 33, 34, 35,
+        37, 38, 42, 45, 32, 33, 34, 36, 39, 40, 44, 47, 34, 34, 35, 37, 41, 42,
+        48, 50, 34, 34, 35, 37, 41, 42, 48, 50, 34, 34, 35, 37, 42, 43, 49, 51,
+        35, 34, 36, 38, 45, 47, 52, 55, 36, 34, 36, 38, 46, 48, 54, 56, 36, 34,
+        36, 38, 46, 48, 54, 56, 38, 36, 37, 40, 47, 49, 56, 58, 39, 37, 39, 40,
+        48, 50, 58, 60, 39, 37, 39, 40, 48, 50, 58, 60, 41, 39, 40, 41, 49, 51,
+        60, 62, 44, 41, 42, 43, 51, 53, 63, 66, 44, 41, 42, 43, 51, 53, 63, 66,
+        44, 42, 42, 43, 51, 54, 64, 67, 47, 44, 44, 45, 53, 56, 66, 69, 48, 45,
+        45, 46, 54, 56, 67, 70, 48, 45, 45, 46, 54, 56, 67, 70, 51, 47, 48, 48,
+        56, 58, 69, 73,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 65, 68, 68, 68,
-        71, 72, 72, 76, 79, 79, 82, 88, 88, 89, 94, 96, 96, 103, 63, 64, 64, 64,
-        64, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 68, 68, 68, 69, 69, 69, 73,
-        75, 75, 78, 82, 82, 84, 88, 90, 90, 95, 63, 64, 64, 64, 65, 65, 65, 65,
-        66, 66, 66, 67, 68, 68, 69, 70, 70, 70, 72, 72, 72, 75, 78, 78, 80, 84,
-        84, 85, 89, 91, 91, 96, 64, 65, 65, 65, 65, 66, 66, 66, 68, 68, 68, 70,
-        71, 71, 72, 74, 74, 74, 76, 77, 77, 80, 81, 81, 83, 86, 86, 87, 91, 93,
-        93, 97, 70, 70, 70, 70, 69, 68, 68, 69, 71, 72, 72, 74, 75, 75, 78, 83,
-        83, 84, 90, 92, 92, 94, 96, 96, 99, 102, 102, 103, 107, 108, 108, 112,
-        72, 71, 71, 71, 70, 69, 69, 70, 72, 73, 73, 75, 77, 77, 80, 85, 85, 87,
-        94, 96, 96, 99, 101, 101, 103, 107, 107, 108, 112, 113, 113, 117, 88,
-        86, 85, 85, 83, 82, 82, 82, 84, 84, 84, 85, 85, 85, 89, 96, 96, 98, 105,
-        108, 108, 112, 116, 116, 120, 126, 126, 128, 132, 134, 134, 139, 95, 93,
-        91, 91, 90, 88, 88, 88, 89, 90, 90, 90, 90, 90, 94, 101, 101, 103, 110,
-        112, 112, 117, 121, 121, 125, 132, 132, 134, 139, 140, 140, 146 },
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 34, 34, 34,
+        35, 36, 36, 38, 39, 39, 41, 44, 44, 44, 47, 48, 48, 51, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 34, 36,
+        37, 37, 39, 41, 41, 42, 44, 45, 45, 47, 31, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 39, 39, 40, 42,
+        42, 42, 44, 45, 45, 48, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35,
+        35, 35, 36, 37, 37, 37, 38, 38, 38, 40, 40, 40, 41, 43, 43, 43, 45, 46,
+        46, 48, 35, 35, 35, 35, 34, 34, 34, 34, 35, 36, 36, 37, 37, 37, 39, 41,
+        41, 42, 45, 46, 46, 47, 48, 48, 49, 51, 51, 51, 53, 54, 54, 56, 36, 35,
+        35, 35, 35, 34, 34, 35, 36, 36, 36, 37, 38, 38, 40, 42, 42, 43, 47, 48,
+        48, 49, 50, 50, 51, 53, 53, 54, 56, 56, 56, 58, 44, 43, 42, 42, 41, 41,
+        41, 41, 42, 42, 42, 42, 42, 42, 44, 48, 48, 49, 52, 54, 54, 56, 58, 58,
+        60, 63, 63, 64, 66, 67, 67, 69, 47, 46, 45, 45, 45, 44, 44, 44, 44, 45,
+        45, 45, 45, 45, 47, 50, 50, 51, 55, 56, 56, 58, 60, 60, 62, 66, 66, 67,
+        69, 70, 70, 73 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        66, 91, 91, 109,
+        33, 45, 45, 54,
 #endif
         /* Size 4x4 */
-        63, 74, 95, 94, 74, 88, 95, 91, 95, 95, 106, 107, 94, 91, 107, 118,
+        31, 37, 47, 47, 37, 44, 47, 45, 47, 47, 53, 53, 47, 45, 53, 59,
         /* Size 8x8 */
-        63, 62, 68, 75, 86, 96, 95, 99, 62, 64, 71, 80, 87, 92, 90, 93, 68, 71,
-        78, 87, 91, 93, 91, 93, 75, 80, 87, 95, 95, 94, 91, 92, 86, 87, 91, 95,
-        99, 101, 100, 101, 96, 92, 93, 94, 101, 107, 110, 111, 95, 90, 91, 91,
-        100, 110, 117, 120, 99, 93, 93, 92, 101, 111, 120, 123,
+        31, 31, 34, 37, 43, 48, 47, 49, 31, 32, 35, 40, 43, 46, 45, 46, 34, 35,
+        39, 43, 45, 46, 45, 46, 37, 40, 43, 47, 47, 47, 45, 46, 43, 43, 45, 47,
+        49, 50, 50, 50, 48, 46, 46, 47, 50, 53, 55, 55, 47, 45, 45, 45, 50, 55,
+        58, 60, 49, 46, 46, 46, 50, 55, 60, 61,
         /* Size 16x16 */
-        64, 62, 62, 61, 66, 67, 73, 77, 83, 95, 98, 97, 98, 98, 101, 101, 62,
-        63, 63, 62, 68, 69, 77, 80, 85, 93, 95, 94, 94, 94, 96, 97, 62, 63, 63,
-        63, 68, 70, 78, 81, 85, 92, 94, 93, 93, 92, 95, 95, 61, 62, 63, 64, 69,
-        71, 80, 82, 85, 91, 93, 91, 91, 90, 92, 93, 66, 68, 68, 69, 75, 77, 85,
-        87, 89, 93, 94, 92, 92, 91, 93, 93, 67, 69, 70, 71, 77, 78, 87, 88, 90,
-        94, 95, 93, 92, 91, 93, 93, 73, 77, 78, 80, 85, 87, 95, 95, 95, 95, 96,
-        93, 92, 91, 92, 92, 77, 80, 81, 82, 87, 88, 95, 95, 96, 97, 98, 96, 95,
-        94, 95, 95, 83, 85, 85, 85, 89, 90, 95, 96, 97, 100, 101, 99, 99, 98,
-        100, 100, 95, 93, 92, 91, 93, 94, 95, 97, 100, 104, 105, 105, 105, 105,
-        106, 106, 98, 95, 94, 93, 94, 95, 96, 98, 101, 105, 106, 106, 107, 107,
-        108, 108, 97, 94, 93, 91, 92, 93, 93, 96, 99, 105, 106, 109, 110, 111,
-        113, 113, 98, 94, 93, 91, 92, 92, 92, 95, 99, 105, 107, 110, 111, 114,
-        115, 116, 98, 94, 92, 90, 91, 91, 91, 94, 98, 105, 107, 111, 114, 117,
-        119, 120, 101, 96, 95, 92, 93, 93, 92, 95, 100, 106, 108, 113, 115, 119,
-        122, 122, 101, 97, 95, 93, 93, 93, 92, 95, 100, 106, 108, 113, 116, 120,
-        122, 123,
+        32, 31, 31, 30, 33, 33, 36, 38, 41, 47, 49, 48, 49, 49, 50, 50, 31, 31,
+        31, 31, 34, 34, 38, 40, 42, 46, 47, 47, 47, 47, 48, 48, 31, 31, 31, 31,
+        34, 35, 39, 40, 42, 46, 47, 46, 46, 46, 47, 47, 30, 31, 31, 32, 34, 35,
+        40, 41, 42, 45, 46, 45, 45, 45, 46, 46, 33, 34, 34, 34, 37, 38, 42, 43,
+        44, 46, 47, 46, 46, 45, 46, 46, 33, 34, 35, 35, 38, 39, 43, 44, 45, 47,
+        47, 46, 46, 45, 46, 46, 36, 38, 39, 40, 42, 43, 47, 47, 47, 47, 48, 46,
+        46, 45, 46, 46, 38, 40, 40, 41, 43, 44, 47, 47, 48, 48, 49, 48, 47, 47,
+        47, 47, 41, 42, 42, 42, 44, 45, 47, 48, 48, 50, 50, 49, 49, 49, 50, 50,
+        47, 46, 46, 45, 46, 47, 47, 48, 50, 52, 52, 52, 52, 52, 53, 53, 49, 47,
+        47, 46, 47, 47, 48, 49, 50, 52, 53, 53, 53, 53, 54, 54, 48, 47, 46, 45,
+        46, 46, 46, 48, 49, 52, 53, 54, 55, 55, 56, 56, 49, 47, 46, 45, 46, 46,
+        46, 47, 49, 52, 53, 55, 55, 57, 57, 58, 49, 47, 46, 45, 45, 45, 45, 47,
+        49, 52, 53, 55, 57, 58, 59, 60, 50, 48, 47, 46, 46, 46, 46, 47, 50, 53,
+        54, 56, 57, 59, 61, 61, 50, 48, 47, 46, 46, 46, 46, 47, 50, 53, 54, 56,
+        58, 60, 61, 61,
         /* Size 32x32 */
-        64, 63, 62, 62, 62, 61, 61, 62, 66, 67, 67, 71, 73, 73, 77, 83, 83, 86,
-        95, 98, 98, 98, 97, 97, 98, 98, 98, 99, 101, 101, 101, 103, 63, 63, 63,
-        63, 62, 62, 62, 63, 67, 68, 68, 72, 75, 75, 79, 84, 84, 86, 94, 96, 96,
-        96, 95, 95, 95, 95, 95, 96, 98, 99, 99, 100, 62, 63, 63, 63, 63, 62, 62,
-        64, 68, 69, 69, 74, 77, 77, 80, 85, 85, 87, 93, 95, 95, 95, 94, 94, 94,
-        94, 94, 94, 96, 97, 97, 99, 62, 63, 63, 63, 63, 62, 62, 64, 68, 69, 69,
-        74, 77, 77, 80, 85, 85, 87, 93, 95, 95, 95, 94, 94, 94, 94, 94, 94, 96,
-        97, 97, 99, 62, 62, 63, 63, 63, 63, 63, 64, 68, 70, 70, 75, 78, 78, 81,
-        85, 85, 87, 92, 94, 94, 93, 93, 93, 93, 92, 92, 93, 95, 95, 95, 97, 61,
-        62, 62, 62, 63, 64, 64, 65, 69, 71, 71, 76, 80, 80, 82, 85, 85, 87, 91,
-        93, 93, 92, 91, 91, 91, 90, 90, 91, 92, 93, 93, 94, 61, 62, 62, 62, 63,
-        64, 64, 65, 69, 71, 71, 76, 80, 80, 82, 85, 85, 87, 91, 93, 93, 92, 91,
-        91, 91, 90, 90, 91, 92, 93, 93, 94, 62, 63, 64, 64, 64, 65, 65, 66, 71,
-        72, 72, 77, 81, 81, 83, 86, 86, 87, 92, 93, 93, 92, 91, 91, 91, 90, 90,
-        91, 92, 93, 93, 94, 66, 67, 68, 68, 68, 69, 69, 71, 75, 77, 77, 82, 85,
-        85, 87, 89, 89, 90, 93, 94, 94, 93, 92, 92, 92, 91, 91, 91, 93, 93, 93,
-        94, 67, 68, 69, 69, 70, 71, 71, 72, 77, 78, 78, 83, 87, 87, 88, 90, 90,
-        91, 94, 95, 95, 93, 93, 93, 92, 91, 91, 91, 93, 93, 93, 94, 67, 68, 69,
-        69, 70, 71, 71, 72, 77, 78, 78, 83, 87, 87, 88, 90, 90, 91, 94, 95, 95,
-        93, 93, 93, 92, 91, 91, 91, 93, 93, 93, 94, 71, 72, 74, 74, 75, 76, 76,
-        77, 82, 83, 83, 88, 92, 92, 92, 93, 93, 93, 95, 95, 95, 94, 93, 93, 92,
-        91, 91, 91, 92, 93, 93, 94, 73, 75, 77, 77, 78, 80, 80, 81, 85, 87, 87,
-        92, 95, 95, 95, 95, 95, 95, 95, 96, 96, 94, 93, 93, 92, 91, 91, 91, 92,
-        92, 92, 93, 73, 75, 77, 77, 78, 80, 80, 81, 85, 87, 87, 92, 95, 95, 95,
-        95, 95, 95, 95, 96, 96, 94, 93, 93, 92, 91, 91, 91, 92, 92, 92, 93, 77,
-        79, 80, 80, 81, 82, 82, 83, 87, 88, 88, 92, 95, 95, 95, 96, 96, 96, 97,
-        98, 98, 96, 96, 96, 95, 94, 94, 94, 95, 95, 95, 96, 83, 84, 85, 85, 85,
-        85, 85, 86, 89, 90, 90, 93, 95, 95, 96, 97, 97, 98, 100, 101, 101, 100,
-        99, 99, 99, 98, 98, 99, 100, 100, 100, 101, 83, 84, 85, 85, 85, 85, 85,
-        86, 89, 90, 90, 93, 95, 95, 96, 97, 97, 98, 100, 101, 101, 100, 99, 99,
-        99, 98, 98, 99, 100, 100, 100, 101, 86, 86, 87, 87, 87, 87, 87, 87, 90,
-        91, 91, 93, 95, 95, 96, 98, 98, 99, 101, 102, 102, 101, 101, 101, 100,
-        100, 100, 100, 101, 101, 101, 102, 95, 94, 93, 93, 92, 91, 91, 92, 93,
-        94, 94, 95, 95, 95, 97, 100, 100, 101, 104, 105, 105, 105, 105, 105,
-        105, 105, 105, 105, 106, 106, 106, 107, 98, 96, 95, 95, 94, 93, 93, 93,
-        94, 95, 95, 95, 96, 96, 98, 101, 101, 102, 105, 106, 106, 106, 106, 106,
-        107, 107, 107, 107, 108, 108, 108, 108, 98, 96, 95, 95, 94, 93, 93, 93,
-        94, 95, 95, 95, 96, 96, 98, 101, 101, 102, 105, 106, 106, 106, 106, 106,
-        107, 107, 107, 107, 108, 108, 108, 108, 98, 96, 95, 95, 93, 92, 92, 92,
-        93, 93, 93, 94, 94, 94, 96, 100, 100, 101, 105, 106, 106, 107, 108, 108,
-        108, 110, 110, 110, 111, 111, 111, 112, 97, 95, 94, 94, 93, 91, 91, 91,
-        92, 93, 93, 93, 93, 93, 96, 99, 99, 101, 105, 106, 106, 108, 109, 109,
-        110, 111, 111, 112, 113, 113, 113, 114, 97, 95, 94, 94, 93, 91, 91, 91,
-        92, 93, 93, 93, 93, 93, 96, 99, 99, 101, 105, 106, 106, 108, 109, 109,
-        110, 111, 111, 112, 113, 113, 113, 114, 98, 95, 94, 94, 93, 91, 91, 91,
-        92, 92, 92, 92, 92, 92, 95, 99, 99, 100, 105, 107, 107, 108, 110, 110,
-        111, 114, 114, 114, 115, 116, 116, 117, 98, 95, 94, 94, 92, 90, 90, 90,
-        91, 91, 91, 91, 91, 91, 94, 98, 98, 100, 105, 107, 107, 110, 111, 111,
-        114, 117, 117, 118, 119, 120, 120, 121, 98, 95, 94, 94, 92, 90, 90, 90,
-        91, 91, 91, 91, 91, 91, 94, 98, 98, 100, 105, 107, 107, 110, 111, 111,
-        114, 117, 117, 118, 119, 120, 120, 121, 99, 96, 94, 94, 93, 91, 91, 91,
-        91, 91, 91, 91, 91, 91, 94, 99, 99, 100, 105, 107, 107, 110, 112, 112,
-        114, 118, 118, 118, 120, 120, 120, 122, 101, 98, 96, 96, 95, 92, 92, 92,
-        93, 93, 93, 92, 92, 92, 95, 100, 100, 101, 106, 108, 108, 111, 113, 113,
-        115, 119, 119, 120, 122, 122, 122, 125, 101, 99, 97, 97, 95, 93, 93, 93,
-        93, 93, 93, 93, 92, 92, 95, 100, 100, 101, 106, 108, 108, 111, 113, 113,
-        116, 120, 120, 120, 122, 123, 123, 126, 101, 99, 97, 97, 95, 93, 93, 93,
-        93, 93, 93, 93, 92, 92, 95, 100, 100, 101, 106, 108, 108, 111, 113, 113,
-        116, 120, 120, 120, 122, 123, 123, 126, 103, 100, 99, 99, 97, 94, 94,
-        94, 94, 94, 94, 94, 93, 93, 96, 101, 101, 102, 107, 108, 108, 112, 114,
-        114, 117, 121, 121, 122, 125, 126, 126, 129,
+        32, 31, 31, 31, 31, 30, 30, 31, 33, 33, 33, 35, 36, 36, 38, 41, 41, 43,
+        47, 49, 49, 49, 48, 48, 49, 49, 49, 49, 50, 50, 50, 51, 31, 31, 31, 31,
+        31, 31, 31, 31, 33, 34, 34, 36, 37, 37, 39, 42, 42, 43, 47, 48, 48, 48,
+        47, 47, 47, 47, 47, 48, 49, 49, 49, 50, 31, 31, 31, 31, 31, 31, 31, 32,
+        34, 34, 34, 37, 38, 38, 40, 42, 42, 43, 46, 47, 47, 47, 47, 47, 47, 47,
+        47, 47, 48, 48, 48, 49, 31, 31, 31, 31, 31, 31, 31, 32, 34, 34, 34, 37,
+        38, 38, 40, 42, 42, 43, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48,
+        48, 49, 31, 31, 31, 31, 31, 31, 31, 32, 34, 35, 35, 37, 39, 39, 40, 42,
+        42, 43, 46, 47, 47, 46, 46, 46, 46, 46, 46, 46, 47, 47, 47, 48, 30, 31,
+        31, 31, 31, 32, 32, 32, 34, 35, 35, 38, 40, 40, 41, 42, 42, 43, 45, 46,
+        46, 46, 45, 45, 45, 45, 45, 45, 46, 46, 46, 47, 30, 31, 31, 31, 31, 32,
+        32, 32, 34, 35, 35, 38, 40, 40, 41, 42, 42, 43, 45, 46, 46, 46, 45, 45,
+        45, 45, 45, 45, 46, 46, 46, 47, 31, 31, 32, 32, 32, 32, 32, 33, 35, 36,
+        36, 38, 40, 40, 41, 43, 43, 43, 46, 46, 46, 46, 45, 45, 45, 45, 45, 45,
+        46, 46, 46, 47, 33, 33, 34, 34, 34, 34, 34, 35, 37, 38, 38, 41, 42, 42,
+        43, 44, 44, 45, 46, 47, 47, 46, 46, 46, 46, 45, 45, 45, 46, 46, 46, 47,
+        33, 34, 34, 34, 35, 35, 35, 36, 38, 39, 39, 41, 43, 43, 44, 45, 45, 45,
+        47, 47, 47, 46, 46, 46, 46, 45, 45, 45, 46, 46, 46, 47, 33, 34, 34, 34,
+        35, 35, 35, 36, 38, 39, 39, 41, 43, 43, 44, 45, 45, 45, 47, 47, 47, 46,
+        46, 46, 46, 45, 45, 45, 46, 46, 46, 47, 35, 36, 37, 37, 37, 38, 38, 38,
+        41, 41, 41, 44, 46, 46, 46, 46, 46, 46, 47, 47, 47, 47, 46, 46, 46, 45,
+        45, 45, 46, 46, 46, 47, 36, 37, 38, 38, 39, 40, 40, 40, 42, 43, 43, 46,
+        47, 47, 47, 47, 47, 47, 47, 48, 48, 47, 46, 46, 46, 45, 45, 45, 46, 46,
+        46, 46, 36, 37, 38, 38, 39, 40, 40, 40, 42, 43, 43, 46, 47, 47, 47, 47,
+        47, 47, 47, 48, 48, 47, 46, 46, 46, 45, 45, 45, 46, 46, 46, 46, 38, 39,
+        40, 40, 40, 41, 41, 41, 43, 44, 44, 46, 47, 47, 47, 48, 48, 48, 48, 49,
+        49, 48, 48, 48, 47, 47, 47, 47, 47, 47, 47, 48, 41, 42, 42, 42, 42, 42,
+        42, 43, 44, 45, 45, 46, 47, 47, 48, 48, 48, 49, 50, 50, 50, 50, 49, 49,
+        49, 49, 49, 49, 50, 50, 50, 50, 41, 42, 42, 42, 42, 42, 42, 43, 44, 45,
+        45, 46, 47, 47, 48, 48, 48, 49, 50, 50, 50, 50, 49, 49, 49, 49, 49, 49,
+        50, 50, 50, 50, 43, 43, 43, 43, 43, 43, 43, 43, 45, 45, 45, 46, 47, 47,
+        48, 49, 49, 49, 50, 51, 51, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51,
+        47, 47, 46, 46, 46, 45, 45, 46, 46, 47, 47, 47, 47, 47, 48, 50, 50, 50,
+        52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 49, 48, 47, 47,
+        47, 46, 46, 46, 47, 47, 47, 47, 48, 48, 49, 50, 50, 51, 52, 53, 53, 53,
+        53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 49, 48, 47, 47, 47, 46, 46, 46,
+        47, 47, 47, 47, 48, 48, 49, 50, 50, 51, 52, 53, 53, 53, 53, 53, 53, 53,
+        53, 53, 54, 54, 54, 54, 49, 48, 47, 47, 46, 46, 46, 46, 46, 46, 46, 47,
+        47, 47, 48, 50, 50, 50, 52, 53, 53, 53, 54, 54, 54, 55, 55, 55, 55, 55,
+        55, 56, 48, 47, 47, 47, 46, 45, 45, 45, 46, 46, 46, 46, 46, 46, 48, 49,
+        49, 50, 52, 53, 53, 54, 54, 54, 55, 55, 55, 56, 56, 56, 56, 57, 48, 47,
+        47, 47, 46, 45, 45, 45, 46, 46, 46, 46, 46, 46, 48, 49, 49, 50, 52, 53,
+        53, 54, 54, 54, 55, 55, 55, 56, 56, 56, 56, 57, 49, 47, 47, 47, 46, 45,
+        45, 45, 46, 46, 46, 46, 46, 46, 47, 49, 49, 50, 52, 53, 53, 54, 55, 55,
+        55, 57, 57, 57, 57, 58, 58, 58, 49, 47, 47, 47, 46, 45, 45, 45, 45, 45,
+        45, 45, 45, 45, 47, 49, 49, 50, 52, 53, 53, 55, 55, 55, 57, 58, 58, 59,
+        59, 60, 60, 60, 49, 47, 47, 47, 46, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+        47, 49, 49, 50, 52, 53, 53, 55, 55, 55, 57, 58, 58, 59, 59, 60, 60, 60,
+        49, 48, 47, 47, 46, 45, 45, 45, 45, 45, 45, 45, 45, 45, 47, 49, 49, 50,
+        52, 53, 53, 55, 56, 56, 57, 59, 59, 59, 60, 60, 60, 61, 50, 49, 48, 48,
+        47, 46, 46, 46, 46, 46, 46, 46, 46, 46, 47, 50, 50, 50, 53, 54, 54, 55,
+        56, 56, 57, 59, 59, 60, 61, 61, 61, 62, 50, 49, 48, 48, 47, 46, 46, 46,
+        46, 46, 46, 46, 46, 46, 47, 50, 50, 50, 53, 54, 54, 55, 56, 56, 58, 60,
+        60, 60, 61, 61, 61, 63, 50, 49, 48, 48, 47, 46, 46, 46, 46, 46, 46, 46,
+        46, 46, 47, 50, 50, 50, 53, 54, 54, 55, 56, 56, 58, 60, 60, 60, 61, 61,
+        61, 63, 51, 50, 49, 49, 48, 47, 47, 47, 47, 47, 47, 47, 46, 46, 48, 50,
+        50, 51, 53, 54, 54, 56, 57, 57, 58, 60, 60, 61, 62, 63, 63, 64,
         /* Size 4x8 */
-        63, 76, 95, 96, 63, 80, 92, 91, 70, 86, 94, 92, 78, 94, 95, 91, 87, 95,
-        101, 100, 94, 95, 106, 110, 93, 92, 107, 117, 96, 93, 108, 119,
+        31, 38, 47, 48, 31, 40, 46, 45, 35, 43, 47, 46, 39, 47, 47, 45, 43, 47,
+        50, 50, 47, 47, 53, 55, 46, 46, 53, 58, 48, 46, 54, 59,
         /* Size 8x4 */
-        63, 63, 70, 78, 87, 94, 93, 96, 76, 80, 86, 94, 95, 95, 92, 93, 95, 92,
-        94, 95, 101, 106, 107, 108, 96, 91, 92, 91, 100, 110, 117, 119,
+        31, 31, 35, 39, 43, 47, 46, 48, 38, 40, 43, 47, 47, 47, 46, 46, 47, 46,
+        47, 47, 50, 53, 53, 54, 48, 45, 46, 45, 50, 55, 58, 59,
         /* Size 8x16 */
-        64, 62, 66, 74, 91, 96, 98, 101, 63, 63, 68, 77, 90, 94, 94, 97, 62, 64,
-        69, 78, 90, 93, 93, 95, 61, 64, 70, 80, 89, 92, 91, 93, 66, 70, 75, 85,
-        92, 94, 91, 93, 67, 72, 77, 86, 92, 94, 92, 93, 74, 80, 86, 94, 95, 95,
-        91, 92, 78, 82, 87, 95, 97, 97, 94, 95, 84, 86, 89, 95, 99, 100, 99,
-        100, 95, 92, 93, 96, 103, 105, 106, 106, 98, 93, 94, 96, 104, 106, 107,
-        108, 97, 92, 93, 94, 103, 106, 112, 113, 97, 91, 92, 93, 103, 106, 114,
-        115, 98, 91, 91, 92, 103, 107, 117, 119, 100, 93, 93, 93, 104, 108, 119,
-        122, 101, 93, 93, 93, 105, 108, 119, 123,
+        32, 31, 33, 37, 45, 48, 49, 50, 31, 31, 34, 38, 45, 47, 47, 48, 31, 32,
+        34, 39, 45, 46, 46, 47, 30, 32, 35, 40, 44, 46, 45, 46, 33, 35, 37, 42,
+        46, 47, 45, 46, 33, 36, 38, 43, 46, 47, 46, 46, 37, 40, 43, 47, 47, 47,
+        45, 46, 39, 41, 43, 47, 48, 48, 47, 47, 42, 43, 44, 47, 49, 50, 49, 50,
+        47, 46, 46, 48, 51, 52, 53, 53, 49, 46, 47, 48, 52, 53, 53, 54, 48, 46,
+        46, 47, 51, 53, 56, 56, 48, 45, 46, 46, 51, 53, 57, 57, 49, 45, 45, 46,
+        51, 53, 58, 59, 50, 46, 46, 46, 52, 54, 59, 61, 50, 46, 46, 46, 52, 54,
+        59, 61,
         /* Size 16x8 */
-        64, 63, 62, 61, 66, 67, 74, 78, 84, 95, 98, 97, 97, 98, 100, 101, 62,
-        63, 64, 64, 70, 72, 80, 82, 86, 92, 93, 92, 91, 91, 93, 93, 66, 68, 69,
-        70, 75, 77, 86, 87, 89, 93, 94, 93, 92, 91, 93, 93, 74, 77, 78, 80, 85,
-        86, 94, 95, 95, 96, 96, 94, 93, 92, 93, 93, 91, 90, 90, 89, 92, 92, 95,
-        97, 99, 103, 104, 103, 103, 103, 104, 105, 96, 94, 93, 92, 94, 94, 95,
-        97, 100, 105, 106, 106, 106, 107, 108, 108, 98, 94, 93, 91, 91, 92, 91,
-        94, 99, 106, 107, 112, 114, 117, 119, 119, 101, 97, 95, 93, 93, 93, 92,
-        95, 100, 106, 108, 113, 115, 119, 122, 123,
+        32, 31, 31, 30, 33, 33, 37, 39, 42, 47, 49, 48, 48, 49, 50, 50, 31, 31,
+        32, 32, 35, 36, 40, 41, 43, 46, 46, 46, 45, 45, 46, 46, 33, 34, 34, 35,
+        37, 38, 43, 43, 44, 46, 47, 46, 46, 45, 46, 46, 37, 38, 39, 40, 42, 43,
+        47, 47, 47, 48, 48, 47, 46, 46, 46, 46, 45, 45, 45, 44, 46, 46, 47, 48,
+        49, 51, 52, 51, 51, 51, 52, 52, 48, 47, 46, 46, 47, 47, 47, 48, 50, 52,
+        53, 53, 53, 53, 54, 54, 49, 47, 46, 45, 45, 46, 45, 47, 49, 53, 53, 56,
+        57, 58, 59, 59, 50, 48, 47, 46, 46, 46, 46, 47, 50, 53, 54, 56, 57, 59,
+        61, 61,
         /* Size 16x32 */
-        64, 62, 62, 62, 66, 74, 74, 77, 91, 96, 96, 98, 98, 98, 101, 105, 63,
-        63, 63, 63, 67, 76, 76, 79, 90, 95, 95, 96, 96, 96, 98, 102, 63, 63, 63,
-        63, 68, 77, 77, 80, 90, 94, 94, 94, 94, 94, 97, 100, 63, 63, 63, 63, 68,
-        77, 77, 80, 90, 94, 94, 94, 94, 94, 97, 100, 62, 63, 64, 64, 69, 78, 78,
-        81, 90, 93, 93, 93, 93, 93, 95, 98, 61, 63, 64, 64, 70, 80, 80, 82, 89,
-        92, 92, 91, 91, 91, 93, 96, 61, 63, 64, 64, 70, 80, 80, 82, 89, 92, 92,
-        91, 91, 91, 93, 96, 62, 64, 66, 66, 71, 81, 81, 83, 90, 92, 92, 91, 91,
-        91, 93, 96, 66, 68, 70, 70, 75, 85, 85, 86, 92, 94, 94, 92, 91, 91, 93,
-        95, 67, 70, 72, 72, 77, 86, 86, 88, 92, 94, 94, 93, 92, 92, 93, 95, 67,
-        70, 72, 72, 77, 86, 86, 88, 92, 94, 94, 93, 92, 92, 93, 95, 71, 74, 77,
-        77, 82, 91, 91, 92, 94, 95, 95, 93, 91, 91, 93, 95, 74, 78, 80, 80, 86,
-        94, 94, 95, 95, 95, 95, 93, 91, 91, 92, 94, 74, 78, 80, 80, 86, 94, 94,
-        95, 95, 95, 95, 93, 91, 91, 92, 94, 78, 80, 82, 82, 87, 95, 95, 95, 97,
-        97, 97, 95, 94, 94, 95, 97, 84, 85, 86, 86, 89, 95, 95, 96, 99, 100,
-        100, 99, 99, 99, 100, 101, 84, 85, 86, 86, 89, 95, 95, 96, 99, 100, 100,
-        99, 99, 99, 100, 101, 86, 87, 87, 87, 90, 95, 95, 96, 100, 101, 101,
-        101, 100, 100, 101, 103, 95, 93, 92, 92, 93, 96, 96, 97, 103, 105, 105,
-        105, 106, 106, 106, 107, 98, 95, 93, 93, 94, 96, 96, 98, 104, 106, 106,
-        107, 107, 107, 108, 109, 98, 95, 93, 93, 94, 96, 96, 98, 104, 106, 106,
-        107, 107, 107, 108, 109, 97, 94, 92, 92, 93, 95, 95, 97, 104, 106, 106,
-        108, 110, 110, 111, 113, 97, 94, 92, 92, 93, 94, 94, 96, 103, 106, 106,
-        109, 112, 112, 113, 115, 97, 94, 92, 92, 93, 94, 94, 96, 103, 106, 106,
-        109, 112, 112, 113, 115, 97, 94, 91, 91, 92, 93, 93, 95, 103, 106, 106,
-        111, 114, 114, 115, 118, 98, 93, 91, 91, 91, 92, 92, 94, 103, 107, 107,
-        113, 117, 117, 119, 123, 98, 93, 91, 91, 91, 92, 92, 94, 103, 107, 107,
-        113, 117, 117, 119, 123, 98, 94, 91, 91, 91, 92, 92, 95, 104, 107, 107,
-        113, 117, 117, 120, 124, 100, 96, 93, 93, 93, 93, 93, 96, 104, 108, 108,
-        114, 119, 119, 122, 127, 101, 96, 93, 93, 93, 93, 93, 96, 105, 108, 108,
-        115, 119, 119, 123, 128, 101, 96, 93, 93, 93, 93, 93, 96, 105, 108, 108,
-        115, 119, 119, 123, 128, 103, 98, 95, 95, 95, 94, 94, 97, 105, 108, 108,
-        116, 121, 121, 125, 131,
+        32, 31, 31, 31, 33, 37, 37, 38, 45, 48, 48, 49, 49, 49, 50, 52, 31, 31,
+        31, 31, 33, 38, 38, 39, 45, 47, 47, 48, 48, 48, 49, 51, 31, 31, 31, 31,
+        34, 38, 38, 40, 45, 47, 47, 47, 47, 47, 48, 50, 31, 31, 31, 31, 34, 38,
+        38, 40, 45, 47, 47, 47, 47, 47, 48, 50, 31, 31, 32, 32, 34, 39, 39, 40,
+        45, 46, 46, 46, 46, 46, 47, 49, 30, 31, 32, 32, 35, 40, 40, 41, 44, 46,
+        46, 45, 45, 45, 46, 48, 30, 31, 32, 32, 35, 40, 40, 41, 44, 46, 46, 45,
+        45, 45, 46, 48, 31, 32, 33, 33, 35, 40, 40, 41, 45, 46, 46, 45, 45, 45,
+        46, 48, 33, 34, 35, 35, 37, 42, 42, 43, 46, 47, 47, 46, 45, 45, 46, 47,
+        33, 35, 36, 36, 38, 43, 43, 44, 46, 47, 47, 46, 46, 46, 46, 47, 33, 35,
+        36, 36, 38, 43, 43, 44, 46, 47, 47, 46, 46, 46, 46, 47, 35, 37, 38, 38,
+        41, 45, 45, 46, 47, 47, 47, 46, 45, 45, 46, 47, 37, 39, 40, 40, 43, 47,
+        47, 47, 47, 47, 47, 46, 45, 45, 46, 47, 37, 39, 40, 40, 43, 47, 47, 47,
+        47, 47, 47, 46, 45, 45, 46, 47, 39, 40, 41, 41, 43, 47, 47, 47, 48, 48,
+        48, 47, 47, 47, 47, 48, 42, 42, 43, 43, 44, 47, 47, 48, 49, 50, 50, 49,
+        49, 49, 50, 50, 42, 42, 43, 43, 44, 47, 47, 48, 49, 50, 50, 49, 49, 49,
+        50, 50, 43, 43, 43, 43, 45, 47, 47, 48, 50, 50, 50, 50, 50, 50, 50, 51,
+        47, 46, 46, 46, 46, 48, 48, 48, 51, 52, 52, 52, 53, 53, 53, 53, 49, 47,
+        46, 46, 47, 48, 48, 49, 52, 53, 53, 53, 53, 53, 54, 54, 49, 47, 46, 46,
+        47, 48, 48, 49, 52, 53, 53, 53, 53, 53, 54, 54, 48, 47, 46, 46, 46, 47,
+        47, 48, 52, 53, 53, 54, 55, 55, 55, 56, 48, 47, 46, 46, 46, 47, 47, 48,
+        51, 53, 53, 54, 56, 56, 56, 57, 48, 47, 46, 46, 46, 47, 47, 48, 51, 53,
+        53, 54, 56, 56, 56, 57, 48, 47, 45, 45, 46, 46, 46, 47, 51, 53, 53, 55,
+        57, 57, 57, 59, 49, 46, 45, 45, 45, 46, 46, 47, 51, 53, 53, 56, 58, 58,
+        59, 61, 49, 46, 45, 45, 45, 46, 46, 47, 51, 53, 53, 56, 58, 58, 59, 61,
+        49, 47, 45, 45, 45, 46, 46, 47, 52, 53, 53, 56, 58, 58, 60, 62, 50, 48,
+        46, 46, 46, 46, 46, 48, 52, 54, 54, 57, 59, 59, 61, 63, 50, 48, 46, 46,
+        46, 46, 46, 48, 52, 54, 54, 57, 59, 59, 61, 64, 50, 48, 46, 46, 46, 46,
+        46, 48, 52, 54, 54, 57, 59, 59, 61, 64, 51, 49, 47, 47, 47, 47, 47, 48,
+        52, 54, 54, 58, 60, 60, 62, 65,
         /* Size 32x16 */
-        64, 63, 63, 63, 62, 61, 61, 62, 66, 67, 67, 71, 74, 74, 78, 84, 84, 86,
-        95, 98, 98, 97, 97, 97, 97, 98, 98, 98, 100, 101, 101, 103, 62, 63, 63,
-        63, 63, 63, 63, 64, 68, 70, 70, 74, 78, 78, 80, 85, 85, 87, 93, 95, 95,
-        94, 94, 94, 94, 93, 93, 94, 96, 96, 96, 98, 62, 63, 63, 63, 64, 64, 64,
-        66, 70, 72, 72, 77, 80, 80, 82, 86, 86, 87, 92, 93, 93, 92, 92, 92, 91,
-        91, 91, 91, 93, 93, 93, 95, 62, 63, 63, 63, 64, 64, 64, 66, 70, 72, 72,
-        77, 80, 80, 82, 86, 86, 87, 92, 93, 93, 92, 92, 92, 91, 91, 91, 91, 93,
-        93, 93, 95, 66, 67, 68, 68, 69, 70, 70, 71, 75, 77, 77, 82, 86, 86, 87,
-        89, 89, 90, 93, 94, 94, 93, 93, 93, 92, 91, 91, 91, 93, 93, 93, 95, 74,
-        76, 77, 77, 78, 80, 80, 81, 85, 86, 86, 91, 94, 94, 95, 95, 95, 95, 96,
-        96, 96, 95, 94, 94, 93, 92, 92, 92, 93, 93, 93, 94, 74, 76, 77, 77, 78,
-        80, 80, 81, 85, 86, 86, 91, 94, 94, 95, 95, 95, 95, 96, 96, 96, 95, 94,
-        94, 93, 92, 92, 92, 93, 93, 93, 94, 77, 79, 80, 80, 81, 82, 82, 83, 86,
-        88, 88, 92, 95, 95, 95, 96, 96, 96, 97, 98, 98, 97, 96, 96, 95, 94, 94,
-        95, 96, 96, 96, 97, 91, 90, 90, 90, 90, 89, 89, 90, 92, 92, 92, 94, 95,
-        95, 97, 99, 99, 100, 103, 104, 104, 104, 103, 103, 103, 103, 103, 104,
-        104, 105, 105, 105, 96, 95, 94, 94, 93, 92, 92, 92, 94, 94, 94, 95, 95,
-        95, 97, 100, 100, 101, 105, 106, 106, 106, 106, 106, 106, 107, 107, 107,
-        108, 108, 108, 108, 96, 95, 94, 94, 93, 92, 92, 92, 94, 94, 94, 95, 95,
-        95, 97, 100, 100, 101, 105, 106, 106, 106, 106, 106, 106, 107, 107, 107,
-        108, 108, 108, 108, 98, 96, 94, 94, 93, 91, 91, 91, 92, 93, 93, 93, 93,
-        93, 95, 99, 99, 101, 105, 107, 107, 108, 109, 109, 111, 113, 113, 113,
-        114, 115, 115, 116, 98, 96, 94, 94, 93, 91, 91, 91, 91, 92, 92, 91, 91,
-        91, 94, 99, 99, 100, 106, 107, 107, 110, 112, 112, 114, 117, 117, 117,
-        119, 119, 119, 121, 98, 96, 94, 94, 93, 91, 91, 91, 91, 92, 92, 91, 91,
-        91, 94, 99, 99, 100, 106, 107, 107, 110, 112, 112, 114, 117, 117, 117,
-        119, 119, 119, 121, 101, 98, 97, 97, 95, 93, 93, 93, 93, 93, 93, 93, 92,
-        92, 95, 100, 100, 101, 106, 108, 108, 111, 113, 113, 115, 119, 119, 120,
-        122, 123, 123, 125, 105, 102, 100, 100, 98, 96, 96, 96, 95, 95, 95, 95,
-        94, 94, 97, 101, 101, 103, 107, 109, 109, 113, 115, 115, 118, 123, 123,
-        124, 127, 128, 128, 131,
+        32, 31, 31, 31, 31, 30, 30, 31, 33, 33, 33, 35, 37, 37, 39, 42, 42, 43,
+        47, 49, 49, 48, 48, 48, 48, 49, 49, 49, 50, 50, 50, 51, 31, 31, 31, 31,
+        31, 31, 31, 32, 34, 35, 35, 37, 39, 39, 40, 42, 42, 43, 46, 47, 47, 47,
+        47, 47, 47, 46, 46, 47, 48, 48, 48, 49, 31, 31, 31, 31, 32, 32, 32, 33,
+        35, 36, 36, 38, 40, 40, 41, 43, 43, 43, 46, 46, 46, 46, 46, 46, 45, 45,
+        45, 45, 46, 46, 46, 47, 31, 31, 31, 31, 32, 32, 32, 33, 35, 36, 36, 38,
+        40, 40, 41, 43, 43, 43, 46, 46, 46, 46, 46, 46, 45, 45, 45, 45, 46, 46,
+        46, 47, 33, 33, 34, 34, 34, 35, 35, 35, 37, 38, 38, 41, 43, 43, 43, 44,
+        44, 45, 46, 47, 47, 46, 46, 46, 46, 45, 45, 45, 46, 46, 46, 47, 37, 38,
+        38, 38, 39, 40, 40, 40, 42, 43, 43, 45, 47, 47, 47, 47, 47, 47, 48, 48,
+        48, 47, 47, 47, 46, 46, 46, 46, 46, 46, 46, 47, 37, 38, 38, 38, 39, 40,
+        40, 40, 42, 43, 43, 45, 47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 47, 47,
+        46, 46, 46, 46, 46, 46, 46, 47, 38, 39, 40, 40, 40, 41, 41, 41, 43, 44,
+        44, 46, 47, 47, 47, 48, 48, 48, 48, 49, 49, 48, 48, 48, 47, 47, 47, 47,
+        48, 48, 48, 48, 45, 45, 45, 45, 45, 44, 44, 45, 46, 46, 46, 47, 47, 47,
+        48, 49, 49, 50, 51, 52, 52, 52, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52,
+        48, 47, 47, 47, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 50, 50, 50,
+        52, 53, 53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 48, 47, 47, 47,
+        46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 50, 50, 50, 52, 53, 53, 53,
+        53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 49, 48, 47, 47, 46, 45, 45, 45,
+        46, 46, 46, 46, 46, 46, 47, 49, 49, 50, 52, 53, 53, 54, 54, 54, 55, 56,
+        56, 56, 57, 57, 57, 58, 49, 48, 47, 47, 46, 45, 45, 45, 45, 46, 46, 45,
+        45, 45, 47, 49, 49, 50, 53, 53, 53, 55, 56, 56, 57, 58, 58, 58, 59, 59,
+        59, 60, 49, 48, 47, 47, 46, 45, 45, 45, 45, 46, 46, 45, 45, 45, 47, 49,
+        49, 50, 53, 53, 53, 55, 56, 56, 57, 58, 58, 58, 59, 59, 59, 60, 50, 49,
+        48, 48, 47, 46, 46, 46, 46, 46, 46, 46, 46, 46, 47, 50, 50, 50, 53, 54,
+        54, 55, 56, 56, 57, 59, 59, 60, 61, 61, 61, 62, 52, 51, 50, 50, 49, 48,
+        48, 48, 47, 47, 47, 47, 47, 47, 48, 50, 50, 51, 53, 54, 54, 56, 57, 57,
+        59, 61, 61, 62, 63, 64, 64, 65,
         /* Size 4x16 */
-        62, 74, 96, 98, 63, 77, 94, 94, 63, 78, 93, 93, 63, 80, 92, 91, 68, 85,
-        94, 91, 70, 86, 94, 92, 78, 94, 95, 91, 80, 95, 97, 94, 85, 95, 100, 99,
-        93, 96, 105, 106, 95, 96, 106, 107, 94, 94, 106, 112, 94, 93, 106, 114,
-        93, 92, 107, 117, 96, 93, 108, 119, 96, 93, 108, 119,
+        31, 37, 48, 49, 31, 38, 47, 47, 31, 39, 46, 46, 31, 40, 46, 45, 34, 42,
+        47, 45, 35, 43, 47, 46, 39, 47, 47, 45, 40, 47, 48, 47, 42, 47, 50, 49,
+        46, 48, 52, 53, 47, 48, 53, 53, 47, 47, 53, 56, 47, 46, 53, 57, 46, 46,
+        53, 58, 48, 46, 54, 59, 48, 46, 54, 59,
         /* Size 16x4 */
-        62, 63, 63, 63, 68, 70, 78, 80, 85, 93, 95, 94, 94, 93, 96, 96, 74, 77,
-        78, 80, 85, 86, 94, 95, 95, 96, 96, 94, 93, 92, 93, 93, 96, 94, 93, 92,
-        94, 94, 95, 97, 100, 105, 106, 106, 106, 107, 108, 108, 98, 94, 93, 91,
-        91, 92, 91, 94, 99, 106, 107, 112, 114, 117, 119, 119,
+        31, 31, 31, 31, 34, 35, 39, 40, 42, 46, 47, 47, 47, 46, 48, 48, 37, 38,
+        39, 40, 42, 43, 47, 47, 47, 48, 48, 47, 46, 46, 46, 46, 48, 47, 46, 46,
+        47, 47, 47, 48, 50, 52, 53, 53, 53, 53, 54, 54, 49, 47, 46, 45, 45, 46,
+        45, 47, 49, 53, 53, 56, 57, 58, 59, 59,
         /* Size 8x32 */
-        64, 62, 66, 74, 91, 96, 98, 101, 63, 63, 67, 76, 90, 95, 96, 98, 63, 63,
-        68, 77, 90, 94, 94, 97, 63, 63, 68, 77, 90, 94, 94, 97, 62, 64, 69, 78,
-        90, 93, 93, 95, 61, 64, 70, 80, 89, 92, 91, 93, 61, 64, 70, 80, 89, 92,
-        91, 93, 62, 66, 71, 81, 90, 92, 91, 93, 66, 70, 75, 85, 92, 94, 91, 93,
-        67, 72, 77, 86, 92, 94, 92, 93, 67, 72, 77, 86, 92, 94, 92, 93, 71, 77,
-        82, 91, 94, 95, 91, 93, 74, 80, 86, 94, 95, 95, 91, 92, 74, 80, 86, 94,
-        95, 95, 91, 92, 78, 82, 87, 95, 97, 97, 94, 95, 84, 86, 89, 95, 99, 100,
-        99, 100, 84, 86, 89, 95, 99, 100, 99, 100, 86, 87, 90, 95, 100, 101,
-        100, 101, 95, 92, 93, 96, 103, 105, 106, 106, 98, 93, 94, 96, 104, 106,
-        107, 108, 98, 93, 94, 96, 104, 106, 107, 108, 97, 92, 93, 95, 104, 106,
-        110, 111, 97, 92, 93, 94, 103, 106, 112, 113, 97, 92, 93, 94, 103, 106,
-        112, 113, 97, 91, 92, 93, 103, 106, 114, 115, 98, 91, 91, 92, 103, 107,
-        117, 119, 98, 91, 91, 92, 103, 107, 117, 119, 98, 91, 91, 92, 104, 107,
-        117, 120, 100, 93, 93, 93, 104, 108, 119, 122, 101, 93, 93, 93, 105,
-        108, 119, 123, 101, 93, 93, 93, 105, 108, 119, 123, 103, 95, 95, 94,
-        105, 108, 121, 125,
+        32, 31, 33, 37, 45, 48, 49, 50, 31, 31, 33, 38, 45, 47, 48, 49, 31, 31,
+        34, 38, 45, 47, 47, 48, 31, 31, 34, 38, 45, 47, 47, 48, 31, 32, 34, 39,
+        45, 46, 46, 47, 30, 32, 35, 40, 44, 46, 45, 46, 30, 32, 35, 40, 44, 46,
+        45, 46, 31, 33, 35, 40, 45, 46, 45, 46, 33, 35, 37, 42, 46, 47, 45, 46,
+        33, 36, 38, 43, 46, 47, 46, 46, 33, 36, 38, 43, 46, 47, 46, 46, 35, 38,
+        41, 45, 47, 47, 45, 46, 37, 40, 43, 47, 47, 47, 45, 46, 37, 40, 43, 47,
+        47, 47, 45, 46, 39, 41, 43, 47, 48, 48, 47, 47, 42, 43, 44, 47, 49, 50,
+        49, 50, 42, 43, 44, 47, 49, 50, 49, 50, 43, 43, 45, 47, 50, 50, 50, 50,
+        47, 46, 46, 48, 51, 52, 53, 53, 49, 46, 47, 48, 52, 53, 53, 54, 49, 46,
+        47, 48, 52, 53, 53, 54, 48, 46, 46, 47, 52, 53, 55, 55, 48, 46, 46, 47,
+        51, 53, 56, 56, 48, 46, 46, 47, 51, 53, 56, 56, 48, 45, 46, 46, 51, 53,
+        57, 57, 49, 45, 45, 46, 51, 53, 58, 59, 49, 45, 45, 46, 51, 53, 58, 59,
+        49, 45, 45, 46, 52, 53, 58, 60, 50, 46, 46, 46, 52, 54, 59, 61, 50, 46,
+        46, 46, 52, 54, 59, 61, 50, 46, 46, 46, 52, 54, 59, 61, 51, 47, 47, 47,
+        52, 54, 60, 62,
         /* Size 32x8 */
-        64, 63, 63, 63, 62, 61, 61, 62, 66, 67, 67, 71, 74, 74, 78, 84, 84, 86,
-        95, 98, 98, 97, 97, 97, 97, 98, 98, 98, 100, 101, 101, 103, 62, 63, 63,
-        63, 64, 64, 64, 66, 70, 72, 72, 77, 80, 80, 82, 86, 86, 87, 92, 93, 93,
-        92, 92, 92, 91, 91, 91, 91, 93, 93, 93, 95, 66, 67, 68, 68, 69, 70, 70,
-        71, 75, 77, 77, 82, 86, 86, 87, 89, 89, 90, 93, 94, 94, 93, 93, 93, 92,
-        91, 91, 91, 93, 93, 93, 95, 74, 76, 77, 77, 78, 80, 80, 81, 85, 86, 86,
-        91, 94, 94, 95, 95, 95, 95, 96, 96, 96, 95, 94, 94, 93, 92, 92, 92, 93,
-        93, 93, 94, 91, 90, 90, 90, 90, 89, 89, 90, 92, 92, 92, 94, 95, 95, 97,
-        99, 99, 100, 103, 104, 104, 104, 103, 103, 103, 103, 103, 104, 104, 105,
-        105, 105, 96, 95, 94, 94, 93, 92, 92, 92, 94, 94, 94, 95, 95, 95, 97,
-        100, 100, 101, 105, 106, 106, 106, 106, 106, 106, 107, 107, 107, 108,
-        108, 108, 108, 98, 96, 94, 94, 93, 91, 91, 91, 91, 92, 92, 91, 91, 91,
-        94, 99, 99, 100, 106, 107, 107, 110, 112, 112, 114, 117, 117, 117, 119,
-        119, 119, 121, 101, 98, 97, 97, 95, 93, 93, 93, 93, 93, 93, 93, 92, 92,
-        95, 100, 100, 101, 106, 108, 108, 111, 113, 113, 115, 119, 119, 120,
-        122, 123, 123, 125 },
+        32, 31, 31, 31, 31, 30, 30, 31, 33, 33, 33, 35, 37, 37, 39, 42, 42, 43,
+        47, 49, 49, 48, 48, 48, 48, 49, 49, 49, 50, 50, 50, 51, 31, 31, 31, 31,
+        32, 32, 32, 33, 35, 36, 36, 38, 40, 40, 41, 43, 43, 43, 46, 46, 46, 46,
+        46, 46, 45, 45, 45, 45, 46, 46, 46, 47, 33, 33, 34, 34, 34, 35, 35, 35,
+        37, 38, 38, 41, 43, 43, 43, 44, 44, 45, 46, 47, 47, 46, 46, 46, 46, 45,
+        45, 45, 46, 46, 46, 47, 37, 38, 38, 38, 39, 40, 40, 40, 42, 43, 43, 45,
+        47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 47, 47, 46, 46, 46, 46, 46, 46,
+        46, 47, 45, 45, 45, 45, 45, 44, 44, 45, 46, 46, 46, 47, 47, 47, 48, 49,
+        49, 50, 51, 52, 52, 52, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 48, 47,
+        47, 47, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 50, 50, 50, 52, 53,
+        53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 49, 48, 47, 47, 46, 45,
+        45, 45, 45, 46, 46, 45, 45, 45, 47, 49, 49, 50, 53, 53, 53, 55, 56, 56,
+        57, 58, 58, 58, 59, 59, 59, 60, 50, 49, 48, 48, 47, 46, 46, 46, 46, 46,
+        46, 46, 46, 46, 47, 50, 50, 50, 53, 54, 54, 55, 56, 56, 57, 59, 59, 60,
+        61, 61, 61, 62 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        65, 69, 69, 97,
+        32, 34, 34, 48,
 #endif
         /* Size 4x4 */
-        64, 64, 68, 77, 64, 67, 71, 78, 68, 71, 79, 90, 77, 78, 90, 108,
+        32, 32, 34, 38, 32, 33, 35, 39, 34, 35, 39, 45, 38, 39, 45, 54,
         /* Size 8x8 */
-        63, 63, 64, 64, 66, 69, 74, 82, 63, 64, 65, 65, 66, 69, 73, 79, 64, 65,
-        65, 66, 68, 70, 74, 80, 64, 65, 66, 68, 71, 73, 77, 82, 66, 66, 68, 71,
-        74, 78, 83, 88, 69, 69, 70, 73, 78, 86, 93, 98, 74, 73, 74, 77, 83, 93,
-        102, 108, 82, 79, 80, 82, 88, 98, 108, 116,
+        31, 31, 32, 32, 33, 34, 37, 41, 31, 32, 32, 32, 33, 34, 36, 39, 32, 32,
+        32, 33, 34, 35, 37, 40, 32, 32, 33, 34, 35, 36, 38, 41, 33, 33, 34, 35,
+        37, 39, 41, 44, 34, 34, 35, 36, 39, 43, 46, 49, 37, 36, 37, 38, 41, 46,
+        51, 54, 41, 39, 40, 41, 44, 49, 54, 58,
         /* Size 16x16 */
-        64, 63, 63, 63, 63, 63, 63, 64, 64, 68, 68, 72, 72, 79, 79, 88, 63, 64,
-        64, 64, 64, 64, 64, 65, 65, 68, 68, 70, 70, 77, 77, 85, 63, 64, 64, 64,
-        64, 64, 64, 65, 65, 68, 68, 70, 70, 77, 77, 85, 63, 64, 64, 65, 65, 65,
-        65, 65, 65, 67, 67, 69, 69, 75, 75, 82, 63, 64, 64, 65, 65, 65, 65, 65,
-        65, 67, 67, 69, 69, 75, 75, 82, 63, 64, 64, 65, 65, 67, 67, 68, 68, 71,
-        71, 73, 73, 78, 78, 84, 63, 64, 64, 65, 65, 67, 67, 68, 68, 71, 71, 73,
-        73, 78, 78, 84, 64, 65, 65, 65, 65, 68, 68, 71, 71, 74, 74, 77, 77, 81,
-        81, 85, 64, 65, 65, 65, 65, 68, 68, 71, 71, 74, 74, 77, 77, 81, 81, 85,
-        68, 68, 68, 67, 67, 71, 71, 74, 74, 79, 79, 85, 85, 90, 90, 95, 68, 68,
-        68, 67, 67, 71, 71, 74, 74, 79, 79, 85, 85, 90, 90, 95, 72, 70, 70, 69,
-        69, 73, 73, 77, 77, 85, 85, 97, 97, 101, 101, 108, 72, 70, 70, 69, 69,
-        73, 73, 77, 77, 85, 85, 97, 97, 101, 101, 108, 79, 77, 77, 75, 75, 78,
-        78, 81, 81, 90, 90, 101, 101, 108, 108, 116, 79, 77, 77, 75, 75, 78, 78,
-        81, 81, 90, 90, 101, 101, 108, 108, 116, 88, 85, 85, 82, 82, 84, 84, 85,
-        85, 95, 95, 108, 108, 116, 116, 127,
+        32, 31, 31, 31, 31, 31, 31, 32, 32, 34, 34, 36, 36, 39, 39, 44, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 34, 34, 35, 35, 38, 38, 42, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 34, 34, 35, 35, 38, 38, 42, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 34, 34, 37, 37, 41, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 34, 34, 37, 37, 41, 31, 32, 32, 32, 32, 33, 33, 34, 34, 35,
+        35, 36, 36, 39, 39, 42, 31, 32, 32, 32, 32, 33, 33, 34, 34, 35, 35, 36,
+        36, 39, 39, 42, 32, 32, 32, 32, 32, 34, 34, 35, 35, 37, 37, 38, 38, 40,
+        40, 42, 32, 32, 32, 32, 32, 34, 34, 35, 35, 37, 37, 38, 38, 40, 40, 42,
+        34, 34, 34, 33, 33, 35, 35, 37, 37, 39, 39, 42, 42, 45, 45, 47, 34, 34,
+        34, 33, 33, 35, 35, 37, 37, 39, 39, 42, 42, 45, 45, 47, 36, 35, 35, 34,
+        34, 36, 36, 38, 38, 42, 42, 48, 48, 50, 50, 54, 36, 35, 35, 34, 34, 36,
+        36, 38, 38, 42, 42, 48, 48, 50, 50, 54, 39, 38, 38, 37, 37, 39, 39, 40,
+        40, 45, 45, 50, 50, 54, 54, 58, 39, 38, 38, 37, 37, 39, 39, 40, 40, 45,
+        45, 50, 50, 54, 54, 58, 44, 42, 42, 41, 41, 42, 42, 42, 42, 47, 47, 54,
+        54, 58, 58, 63,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 66,
-        68, 68, 68, 70, 72, 72, 72, 75, 79, 79, 79, 83, 88, 88, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 66, 68, 68, 68, 69,
-        71, 71, 71, 74, 78, 78, 78, 82, 86, 86, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 65, 65, 65, 65, 66, 68, 68, 68, 69, 70, 70, 70, 74,
-        77, 77, 77, 81, 85, 85, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 65, 65, 65, 65, 66, 68, 68, 68, 69, 70, 70, 70, 74, 77, 77, 77, 81,
-        85, 85, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65,
-        65, 66, 68, 68, 68, 69, 70, 70, 70, 74, 77, 77, 77, 81, 85, 85, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 68, 68,
-        68, 69, 70, 70, 70, 73, 76, 76, 76, 79, 83, 83, 63, 63, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 67, 67, 68, 69, 69,
-        69, 72, 75, 75, 75, 78, 82, 82, 63, 63, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 66, 67, 67, 67, 68, 69, 69, 69, 72, 75, 75,
-        75, 78, 82, 82, 63, 63, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 67, 67, 67, 68, 69, 69, 69, 72, 75, 75, 75, 78, 82, 82,
-        63, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66, 66, 66, 66, 67, 67, 67, 68,
-        69, 69, 69, 70, 71, 71, 71, 74, 77, 77, 77, 80, 83, 83, 63, 64, 64, 64,
-        64, 65, 65, 65, 65, 66, 67, 67, 67, 67, 68, 68, 68, 69, 71, 71, 71, 72,
-        73, 73, 73, 76, 78, 78, 78, 81, 84, 84, 63, 64, 64, 64, 64, 65, 65, 65,
-        65, 66, 67, 67, 67, 67, 68, 68, 68, 69, 71, 71, 71, 72, 73, 73, 73, 76,
-        78, 78, 78, 81, 84, 84, 63, 64, 64, 64, 64, 65, 65, 65, 65, 66, 67, 67,
-        67, 67, 68, 68, 68, 69, 71, 71, 71, 72, 73, 73, 73, 76, 78, 78, 78, 81,
-        84, 84, 64, 64, 65, 65, 65, 65, 65, 65, 65, 66, 67, 67, 67, 68, 69, 69,
-        69, 71, 72, 72, 72, 73, 75, 75, 75, 77, 80, 80, 80, 82, 85, 85, 64, 64,
-        65, 65, 65, 65, 65, 65, 65, 67, 68, 68, 68, 69, 71, 71, 71, 72, 74, 74,
-        74, 75, 77, 77, 77, 79, 81, 81, 81, 83, 85, 85, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 67, 68, 68, 68, 69, 71, 71, 71, 72, 74, 74, 74, 75, 77, 77,
-        77, 79, 81, 81, 81, 83, 85, 85, 64, 64, 65, 65, 65, 65, 65, 65, 65, 67,
-        68, 68, 68, 69, 71, 71, 71, 72, 74, 74, 74, 75, 77, 77, 77, 79, 81, 81,
-        81, 83, 85, 85, 66, 66, 66, 66, 66, 66, 66, 66, 66, 68, 69, 69, 69, 71,
-        72, 72, 72, 74, 76, 76, 76, 78, 81, 81, 81, 83, 85, 85, 85, 88, 90, 90,
-        68, 68, 68, 68, 68, 68, 67, 67, 67, 69, 71, 71, 71, 72, 74, 74, 74, 76,
-        79, 79, 79, 82, 85, 85, 85, 88, 90, 90, 90, 93, 95, 95, 68, 68, 68, 68,
-        68, 68, 67, 67, 67, 69, 71, 71, 71, 72, 74, 74, 74, 76, 79, 79, 79, 82,
-        85, 85, 85, 88, 90, 90, 90, 93, 95, 95, 68, 68, 68, 68, 68, 68, 67, 67,
-        67, 69, 71, 71, 71, 72, 74, 74, 74, 76, 79, 79, 79, 82, 85, 85, 85, 88,
-        90, 90, 90, 93, 95, 95, 70, 69, 69, 69, 69, 69, 68, 68, 68, 70, 72, 72,
-        72, 73, 75, 75, 75, 78, 82, 82, 82, 86, 91, 91, 91, 93, 95, 95, 95, 98,
-        101, 101, 72, 71, 70, 70, 70, 70, 69, 69, 69, 71, 73, 73, 73, 75, 77,
-        77, 77, 81, 85, 85, 85, 91, 97, 97, 97, 99, 101, 101, 101, 104, 108,
-        108, 72, 71, 70, 70, 70, 70, 69, 69, 69, 71, 73, 73, 73, 75, 77, 77, 77,
-        81, 85, 85, 85, 91, 97, 97, 97, 99, 101, 101, 101, 104, 108, 108, 72,
-        71, 70, 70, 70, 70, 69, 69, 69, 71, 73, 73, 73, 75, 77, 77, 77, 81, 85,
-        85, 85, 91, 97, 97, 97, 99, 101, 101, 101, 104, 108, 108, 75, 74, 74,
-        74, 74, 73, 72, 72, 72, 74, 76, 76, 76, 77, 79, 79, 79, 83, 88, 88, 88,
-        93, 99, 99, 99, 102, 104, 104, 104, 108, 112, 112, 79, 78, 77, 77, 77,
-        76, 75, 75, 75, 77, 78, 78, 78, 80, 81, 81, 81, 85, 90, 90, 90, 95, 101,
-        101, 101, 104, 108, 108, 108, 112, 116, 116, 79, 78, 77, 77, 77, 76, 75,
-        75, 75, 77, 78, 78, 78, 80, 81, 81, 81, 85, 90, 90, 90, 95, 101, 101,
-        101, 104, 108, 108, 108, 112, 116, 116, 79, 78, 77, 77, 77, 76, 75, 75,
-        75, 77, 78, 78, 78, 80, 81, 81, 81, 85, 90, 90, 90, 95, 101, 101, 101,
-        104, 108, 108, 108, 112, 116, 116, 83, 82, 81, 81, 81, 79, 78, 78, 78,
-        80, 81, 81, 81, 82, 83, 83, 83, 88, 93, 93, 93, 98, 104, 104, 104, 108,
-        112, 112, 112, 116, 121, 121, 88, 86, 85, 85, 85, 83, 82, 82, 82, 83,
-        84, 84, 84, 85, 85, 85, 85, 90, 95, 95, 95, 101, 108, 108, 108, 112,
-        116, 116, 116, 121, 127, 127, 88, 86, 85, 85, 85, 83, 82, 82, 82, 83,
-        84, 84, 84, 85, 85, 85, 85, 90, 95, 95, 95, 101, 108, 108, 108, 112,
-        116, 116, 116, 121, 127, 127,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33,
+        34, 34, 34, 35, 36, 36, 36, 37, 39, 39, 39, 41, 44, 44, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 34,
+        35, 35, 35, 37, 39, 39, 39, 41, 43, 43, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 35, 35, 37,
+        38, 38, 38, 40, 42, 42, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 35, 35, 37, 38, 38, 38, 40,
+        42, 42, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 34, 34, 34, 34, 35, 35, 35, 37, 38, 38, 38, 40, 42, 42, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34,
+        34, 34, 35, 35, 35, 36, 38, 38, 38, 39, 41, 41, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34,
+        34, 36, 37, 37, 37, 39, 41, 41, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 36, 37, 37,
+        37, 39, 41, 41, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 36, 37, 37, 37, 39, 41, 41,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 34,
+        34, 34, 34, 35, 35, 35, 35, 37, 38, 38, 38, 40, 41, 41, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 36,
+        36, 36, 36, 38, 39, 39, 39, 40, 42, 42, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 36, 36, 36, 36, 38,
+        39, 39, 39, 40, 42, 42, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
+        33, 33, 34, 34, 34, 34, 35, 35, 35, 36, 36, 36, 36, 38, 39, 39, 39, 40,
+        42, 42, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34,
+        34, 35, 36, 36, 36, 36, 37, 37, 37, 38, 40, 40, 40, 41, 42, 42, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 35, 35, 36, 37, 37,
+        37, 37, 38, 38, 38, 39, 40, 40, 40, 41, 42, 42, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 34, 34, 34, 34, 35, 35, 35, 36, 37, 37, 37, 37, 38, 38,
+        38, 39, 40, 40, 40, 41, 42, 42, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        34, 34, 34, 34, 35, 35, 35, 36, 37, 37, 37, 37, 38, 38, 38, 39, 40, 40,
+        40, 41, 42, 42, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 35,
+        36, 36, 36, 37, 38, 38, 38, 39, 40, 40, 40, 41, 42, 42, 42, 44, 45, 45,
+        34, 34, 34, 34, 34, 34, 33, 33, 33, 34, 35, 35, 35, 36, 37, 37, 37, 38,
+        39, 39, 39, 41, 42, 42, 42, 44, 45, 45, 45, 46, 47, 47, 34, 34, 34, 34,
+        34, 34, 33, 33, 33, 34, 35, 35, 35, 36, 37, 37, 37, 38, 39, 39, 39, 41,
+        42, 42, 42, 44, 45, 45, 45, 46, 47, 47, 34, 34, 34, 34, 34, 34, 33, 33,
+        33, 34, 35, 35, 35, 36, 37, 37, 37, 38, 39, 39, 39, 41, 42, 42, 42, 44,
+        45, 45, 45, 46, 47, 47, 35, 34, 34, 34, 34, 34, 34, 34, 34, 35, 36, 36,
+        36, 36, 37, 37, 37, 39, 41, 41, 41, 43, 45, 45, 45, 46, 47, 47, 47, 49,
+        50, 50, 36, 35, 35, 35, 35, 35, 34, 34, 34, 35, 36, 36, 36, 37, 38, 38,
+        38, 40, 42, 42, 42, 45, 48, 48, 48, 49, 50, 50, 50, 52, 54, 54, 36, 35,
+        35, 35, 35, 35, 34, 34, 34, 35, 36, 36, 36, 37, 38, 38, 38, 40, 42, 42,
+        42, 45, 48, 48, 48, 49, 50, 50, 50, 52, 54, 54, 36, 35, 35, 35, 35, 35,
+        34, 34, 34, 35, 36, 36, 36, 37, 38, 38, 38, 40, 42, 42, 42, 45, 48, 48,
+        48, 49, 50, 50, 50, 52, 54, 54, 37, 37, 37, 37, 37, 36, 36, 36, 36, 37,
+        38, 38, 38, 38, 39, 39, 39, 41, 44, 44, 44, 46, 49, 49, 49, 51, 52, 52,
+        52, 54, 56, 56, 39, 39, 38, 38, 38, 38, 37, 37, 37, 38, 39, 39, 39, 40,
+        40, 40, 40, 42, 45, 45, 45, 47, 50, 50, 50, 52, 54, 54, 54, 56, 58, 58,
+        39, 39, 38, 38, 38, 38, 37, 37, 37, 38, 39, 39, 39, 40, 40, 40, 40, 42,
+        45, 45, 45, 47, 50, 50, 50, 52, 54, 54, 54, 56, 58, 58, 39, 39, 38, 38,
+        38, 38, 37, 37, 37, 38, 39, 39, 39, 40, 40, 40, 40, 42, 45, 45, 45, 47,
+        50, 50, 50, 52, 54, 54, 54, 56, 58, 58, 41, 41, 40, 40, 40, 39, 39, 39,
+        39, 40, 40, 40, 40, 41, 41, 41, 41, 44, 46, 46, 46, 49, 52, 52, 52, 54,
+        56, 56, 56, 58, 60, 60, 44, 43, 42, 42, 42, 41, 41, 41, 41, 41, 42, 42,
+        42, 42, 42, 42, 42, 45, 47, 47, 47, 50, 54, 54, 54, 56, 58, 58, 58, 60,
+        63, 63, 44, 43, 42, 42, 42, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42,
+        42, 45, 47, 47, 47, 50, 54, 54, 54, 56, 58, 58, 58, 60, 63, 63,
         /* Size 4x8 */
-        63, 64, 68, 78, 64, 65, 68, 76, 64, 66, 69, 77, 65, 67, 72, 80, 66, 69,
-        76, 85, 69, 72, 82, 95, 74, 76, 88, 105, 81, 81, 93, 112,
+        31, 32, 34, 39, 32, 32, 34, 38, 32, 33, 34, 38, 32, 33, 36, 40, 33, 34,
+        38, 42, 34, 36, 41, 47, 37, 38, 44, 52, 40, 40, 46, 56,
         /* Size 8x4 */
-        63, 64, 64, 65, 66, 69, 74, 81, 64, 65, 66, 67, 69, 72, 76, 81, 68, 68,
-        69, 72, 76, 82, 88, 93, 78, 76, 77, 80, 85, 95, 105, 112,
+        31, 32, 32, 32, 33, 34, 37, 40, 32, 32, 33, 33, 34, 36, 38, 40, 34, 34,
+        34, 36, 38, 41, 44, 46, 39, 38, 38, 40, 42, 47, 52, 56,
         /* Size 8x16 */
-        64, 63, 63, 64, 64, 72, 72, 88, 63, 64, 64, 65, 65, 71, 71, 85, 63, 64,
-        64, 65, 65, 71, 71, 85, 63, 65, 65, 66, 66, 69, 69, 82, 63, 65, 65, 66,
-        66, 69, 69, 82, 64, 65, 65, 68, 68, 73, 73, 84, 64, 65, 65, 68, 68, 73,
-        73, 84, 64, 66, 66, 71, 71, 77, 77, 85, 64, 66, 66, 71, 71, 77, 77, 85,
-        68, 68, 68, 74, 74, 85, 85, 96, 68, 68, 68, 74, 74, 85, 85, 96, 72, 69,
-        69, 77, 77, 96, 96, 108, 72, 69, 69, 77, 77, 96, 96, 108, 79, 75, 75,
-        81, 81, 101, 101, 116, 79, 75, 75, 81, 81, 101, 101, 116, 88, 82, 82,
-        86, 86, 107, 107, 126,
+        32, 31, 31, 32, 32, 36, 36, 44, 31, 32, 32, 32, 32, 35, 35, 42, 31, 32,
+        32, 32, 32, 35, 35, 42, 31, 32, 32, 33, 33, 34, 34, 41, 31, 32, 32, 33,
+        33, 34, 34, 41, 32, 32, 32, 34, 34, 36, 36, 42, 32, 32, 32, 34, 34, 36,
+        36, 42, 32, 33, 33, 35, 35, 38, 38, 42, 32, 33, 33, 35, 35, 38, 38, 42,
+        34, 34, 34, 37, 37, 42, 42, 48, 34, 34, 34, 37, 37, 42, 42, 48, 36, 34,
+        34, 38, 38, 48, 48, 54, 36, 34, 34, 38, 38, 48, 48, 54, 39, 37, 37, 40,
+        40, 50, 50, 58, 39, 37, 37, 40, 40, 50, 50, 58, 44, 41, 41, 43, 43, 53,
+        53, 63,
         /* Size 16x8 */
-        64, 63, 63, 63, 63, 64, 64, 64, 64, 68, 68, 72, 72, 79, 79, 88, 63, 64,
-        64, 65, 65, 65, 65, 66, 66, 68, 68, 69, 69, 75, 75, 82, 63, 64, 64, 65,
-        65, 65, 65, 66, 66, 68, 68, 69, 69, 75, 75, 82, 64, 65, 65, 66, 66, 68,
-        68, 71, 71, 74, 74, 77, 77, 81, 81, 86, 64, 65, 65, 66, 66, 68, 68, 71,
-        71, 74, 74, 77, 77, 81, 81, 86, 72, 71, 71, 69, 69, 73, 73, 77, 77, 85,
-        85, 96, 96, 101, 101, 107, 72, 71, 71, 69, 69, 73, 73, 77, 77, 85, 85,
-        96, 96, 101, 101, 107, 88, 85, 85, 82, 82, 84, 84, 85, 85, 96, 96, 108,
-        108, 116, 116, 126,
+        32, 31, 31, 31, 31, 32, 32, 32, 32, 34, 34, 36, 36, 39, 39, 44, 31, 32,
+        32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 34, 37, 37, 41, 31, 32, 32, 32,
+        32, 32, 32, 33, 33, 34, 34, 34, 34, 37, 37, 41, 32, 32, 32, 33, 33, 34,
+        34, 35, 35, 37, 37, 38, 38, 40, 40, 43, 32, 32, 32, 33, 33, 34, 34, 35,
+        35, 37, 37, 38, 38, 40, 40, 43, 36, 35, 35, 34, 34, 36, 36, 38, 38, 42,
+        42, 48, 48, 50, 50, 53, 36, 35, 35, 34, 34, 36, 36, 38, 38, 42, 42, 48,
+        48, 50, 50, 53, 44, 42, 42, 41, 41, 42, 42, 42, 42, 48, 48, 54, 54, 58,
+        58, 63,
         /* Size 16x32 */
-        64, 63, 63, 63, 63, 64, 64, 64, 64, 68, 72, 72, 72, 79, 88, 88, 63, 63,
-        63, 63, 63, 64, 64, 64, 64, 68, 71, 71, 71, 78, 86, 86, 63, 64, 64, 64,
-        64, 64, 65, 65, 65, 68, 71, 71, 71, 77, 85, 85, 63, 64, 64, 64, 64, 64,
-        65, 65, 65, 68, 71, 71, 71, 77, 85, 85, 63, 64, 64, 64, 64, 64, 65, 65,
-        65, 68, 71, 71, 71, 77, 85, 85, 63, 64, 64, 64, 64, 65, 65, 65, 65, 68,
-        70, 70, 70, 76, 83, 83, 63, 64, 65, 65, 65, 65, 66, 66, 66, 67, 69, 69,
-        69, 75, 82, 82, 63, 64, 65, 65, 65, 65, 66, 66, 66, 67, 69, 69, 69, 75,
-        82, 82, 63, 64, 65, 65, 65, 65, 66, 66, 66, 67, 69, 69, 69, 75, 82, 82,
-        63, 64, 65, 65, 65, 66, 67, 67, 67, 69, 71, 71, 71, 77, 83, 83, 64, 64,
-        65, 65, 65, 67, 68, 68, 68, 71, 73, 73, 73, 78, 84, 84, 64, 64, 65, 65,
-        65, 67, 68, 68, 68, 71, 73, 73, 73, 78, 84, 84, 64, 64, 65, 65, 65, 67,
-        68, 68, 68, 71, 73, 73, 73, 78, 84, 84, 64, 65, 65, 65, 65, 67, 69, 69,
-        69, 72, 75, 75, 75, 80, 85, 85, 64, 65, 66, 66, 66, 68, 71, 71, 71, 74,
-        77, 77, 77, 81, 85, 85, 64, 65, 66, 66, 66, 68, 71, 71, 71, 74, 77, 77,
-        77, 81, 85, 85, 64, 65, 66, 66, 66, 68, 71, 71, 71, 74, 77, 77, 77, 81,
-        85, 85, 66, 66, 67, 67, 67, 69, 72, 72, 72, 76, 81, 81, 81, 85, 90, 90,
-        68, 68, 68, 68, 68, 71, 74, 74, 74, 79, 85, 85, 85, 90, 96, 96, 68, 68,
-        68, 68, 68, 71, 74, 74, 74, 79, 85, 85, 85, 90, 96, 96, 68, 68, 68, 68,
-        68, 71, 74, 74, 74, 79, 85, 85, 85, 90, 96, 96, 70, 69, 69, 69, 69, 72,
-        75, 75, 75, 82, 90, 90, 90, 95, 101, 101, 72, 70, 69, 69, 69, 73, 77,
-        77, 77, 86, 96, 96, 96, 102, 108, 108, 72, 70, 69, 69, 69, 73, 77, 77,
-        77, 86, 96, 96, 96, 102, 108, 108, 72, 70, 69, 69, 69, 73, 77, 77, 77,
-        86, 96, 96, 96, 102, 108, 108, 75, 74, 72, 72, 72, 76, 79, 79, 79, 88,
-        98, 98, 98, 105, 112, 112, 79, 77, 75, 75, 75, 78, 81, 81, 81, 90, 101,
-        101, 101, 108, 116, 116, 79, 77, 75, 75, 75, 78, 81, 81, 81, 90, 101,
-        101, 101, 108, 116, 116, 79, 77, 75, 75, 75, 78, 81, 81, 81, 90, 101,
-        101, 101, 108, 116, 116, 83, 81, 79, 79, 79, 81, 84, 84, 84, 93, 104,
-        104, 104, 112, 121, 121, 88, 85, 82, 82, 82, 84, 86, 86, 86, 96, 107,
-        107, 107, 116, 126, 126, 88, 85, 82, 82, 82, 84, 86, 86, 86, 96, 107,
-        107, 107, 116, 126, 126,
+        32, 31, 31, 31, 31, 32, 32, 32, 32, 34, 36, 36, 36, 39, 44, 44, 31, 31,
+        31, 31, 31, 32, 32, 32, 32, 34, 35, 35, 35, 39, 43, 43, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 34, 35, 35, 35, 38, 42, 42, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 34, 35, 35, 35, 38, 42, 42, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 34, 35, 35, 35, 38, 42, 42, 31, 32, 32, 32, 32, 32, 32, 32, 32, 34,
+        35, 35, 35, 38, 41, 41, 31, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34,
+        34, 37, 41, 41, 31, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 37,
+        41, 41, 31, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 37, 41, 41,
+        31, 32, 32, 32, 32, 33, 33, 33, 33, 34, 35, 35, 35, 38, 41, 41, 32, 32,
+        32, 32, 32, 33, 34, 34, 34, 35, 36, 36, 36, 39, 42, 42, 32, 32, 32, 32,
+        32, 33, 34, 34, 34, 35, 36, 36, 36, 39, 42, 42, 32, 32, 32, 32, 32, 33,
+        34, 34, 34, 35, 36, 36, 36, 39, 42, 42, 32, 32, 32, 32, 32, 33, 34, 34,
+        34, 36, 37, 37, 37, 40, 42, 42, 32, 32, 33, 33, 33, 34, 35, 35, 35, 37,
+        38, 38, 38, 40, 42, 42, 32, 32, 33, 33, 33, 34, 35, 35, 35, 37, 38, 38,
+        38, 40, 42, 42, 32, 32, 33, 33, 33, 34, 35, 35, 35, 37, 38, 38, 38, 40,
+        42, 42, 33, 33, 33, 33, 33, 34, 36, 36, 36, 38, 40, 40, 40, 42, 45, 45,
+        34, 34, 34, 34, 34, 35, 37, 37, 37, 39, 42, 42, 42, 45, 48, 48, 34, 34,
+        34, 34, 34, 35, 37, 37, 37, 39, 42, 42, 42, 45, 48, 48, 34, 34, 34, 34,
+        34, 35, 37, 37, 37, 39, 42, 42, 42, 45, 48, 48, 35, 34, 34, 34, 34, 36,
+        37, 37, 37, 41, 45, 45, 45, 47, 50, 50, 36, 35, 34, 34, 34, 36, 38, 38,
+        38, 43, 48, 48, 48, 51, 54, 54, 36, 35, 34, 34, 34, 36, 38, 38, 38, 43,
+        48, 48, 48, 51, 54, 54, 36, 35, 34, 34, 34, 36, 38, 38, 38, 43, 48, 48,
+        48, 51, 54, 54, 37, 37, 36, 36, 36, 38, 39, 39, 39, 44, 49, 49, 49, 52,
+        56, 56, 39, 38, 37, 37, 37, 39, 40, 40, 40, 45, 50, 50, 50, 54, 58, 58,
+        39, 38, 37, 37, 37, 39, 40, 40, 40, 45, 50, 50, 50, 54, 58, 58, 39, 38,
+        37, 37, 37, 39, 40, 40, 40, 45, 50, 50, 50, 54, 58, 58, 41, 40, 39, 39,
+        39, 40, 42, 42, 42, 46, 52, 52, 52, 56, 60, 60, 44, 42, 41, 41, 41, 42,
+        43, 43, 43, 48, 53, 53, 53, 58, 63, 63, 44, 42, 41, 41, 41, 42, 43, 43,
+        43, 48, 53, 53, 53, 58, 63, 63,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 66,
-        68, 68, 68, 70, 72, 72, 72, 75, 79, 79, 79, 83, 88, 88, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 66, 68, 68, 68, 69,
-        70, 70, 70, 74, 77, 77, 77, 81, 85, 85, 63, 63, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 68, 68, 68, 69, 69, 69, 69, 72,
-        75, 75, 75, 79, 82, 82, 63, 63, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 65, 66, 66, 66, 67, 68, 68, 68, 69, 69, 69, 69, 72, 75, 75, 75, 79,
-        82, 82, 63, 63, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66,
-        66, 67, 68, 68, 68, 69, 69, 69, 69, 72, 75, 75, 75, 79, 82, 82, 64, 64,
-        64, 64, 64, 65, 65, 65, 65, 66, 67, 67, 67, 67, 68, 68, 68, 69, 71, 71,
-        71, 72, 73, 73, 73, 76, 78, 78, 78, 81, 84, 84, 64, 64, 65, 65, 65, 65,
-        66, 66, 66, 67, 68, 68, 68, 69, 71, 71, 71, 72, 74, 74, 74, 75, 77, 77,
-        77, 79, 81, 81, 81, 84, 86, 86, 64, 64, 65, 65, 65, 65, 66, 66, 66, 67,
-        68, 68, 68, 69, 71, 71, 71, 72, 74, 74, 74, 75, 77, 77, 77, 79, 81, 81,
-        81, 84, 86, 86, 64, 64, 65, 65, 65, 65, 66, 66, 66, 67, 68, 68, 68, 69,
-        71, 71, 71, 72, 74, 74, 74, 75, 77, 77, 77, 79, 81, 81, 81, 84, 86, 86,
-        68, 68, 68, 68, 68, 68, 67, 67, 67, 69, 71, 71, 71, 72, 74, 74, 74, 76,
-        79, 79, 79, 82, 86, 86, 86, 88, 90, 90, 90, 93, 96, 96, 72, 71, 71, 71,
-        71, 70, 69, 69, 69, 71, 73, 73, 73, 75, 77, 77, 77, 81, 85, 85, 85, 90,
-        96, 96, 96, 98, 101, 101, 101, 104, 107, 107, 72, 71, 71, 71, 71, 70,
-        69, 69, 69, 71, 73, 73, 73, 75, 77, 77, 77, 81, 85, 85, 85, 90, 96, 96,
-        96, 98, 101, 101, 101, 104, 107, 107, 72, 71, 71, 71, 71, 70, 69, 69,
-        69, 71, 73, 73, 73, 75, 77, 77, 77, 81, 85, 85, 85, 90, 96, 96, 96, 98,
-        101, 101, 101, 104, 107, 107, 79, 78, 77, 77, 77, 76, 75, 75, 75, 77,
-        78, 78, 78, 80, 81, 81, 81, 85, 90, 90, 90, 95, 102, 102, 102, 105, 108,
-        108, 108, 112, 116, 116, 88, 86, 85, 85, 85, 83, 82, 82, 82, 83, 84, 84,
-        84, 85, 85, 85, 85, 90, 96, 96, 96, 101, 108, 108, 108, 112, 116, 116,
-        116, 121, 126, 126, 88, 86, 85, 85, 85, 83, 82, 82, 82, 83, 84, 84, 84,
-        85, 85, 85, 85, 90, 96, 96, 96, 101, 108, 108, 108, 112, 116, 116, 116,
-        121, 126, 126,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33,
+        34, 34, 34, 35, 36, 36, 36, 37, 39, 39, 39, 41, 44, 44, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 34,
+        35, 35, 35, 37, 38, 38, 38, 40, 42, 42, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 36,
+        37, 37, 37, 39, 41, 41, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 36, 37, 37, 37, 39,
+        41, 41, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 34, 34, 34, 34, 34, 34, 34, 36, 37, 37, 37, 39, 41, 41, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35,
+        35, 36, 36, 36, 36, 38, 39, 39, 39, 40, 42, 42, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 36, 37, 37, 37, 37, 38, 38,
+        38, 39, 40, 40, 40, 42, 43, 43, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        34, 34, 34, 34, 35, 35, 35, 36, 37, 37, 37, 37, 38, 38, 38, 39, 40, 40,
+        40, 42, 43, 43, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34,
+        35, 35, 35, 36, 37, 37, 37, 37, 38, 38, 38, 39, 40, 40, 40, 42, 43, 43,
+        34, 34, 34, 34, 34, 34, 33, 33, 33, 34, 35, 35, 35, 36, 37, 37, 37, 38,
+        39, 39, 39, 41, 43, 43, 43, 44, 45, 45, 45, 46, 48, 48, 36, 35, 35, 35,
+        35, 35, 34, 34, 34, 35, 36, 36, 36, 37, 38, 38, 38, 40, 42, 42, 42, 45,
+        48, 48, 48, 49, 50, 50, 50, 52, 53, 53, 36, 35, 35, 35, 35, 35, 34, 34,
+        34, 35, 36, 36, 36, 37, 38, 38, 38, 40, 42, 42, 42, 45, 48, 48, 48, 49,
+        50, 50, 50, 52, 53, 53, 36, 35, 35, 35, 35, 35, 34, 34, 34, 35, 36, 36,
+        36, 37, 38, 38, 38, 40, 42, 42, 42, 45, 48, 48, 48, 49, 50, 50, 50, 52,
+        53, 53, 39, 39, 38, 38, 38, 38, 37, 37, 37, 38, 39, 39, 39, 40, 40, 40,
+        40, 42, 45, 45, 45, 47, 51, 51, 51, 52, 54, 54, 54, 56, 58, 58, 44, 43,
+        42, 42, 42, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 45, 48, 48,
+        48, 50, 54, 54, 54, 56, 58, 58, 58, 60, 63, 63, 44, 43, 42, 42, 42, 41,
+        41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 45, 48, 48, 48, 50, 54, 54,
+        54, 56, 58, 58, 58, 60, 63, 63,
         /* Size 4x16 */
-        63, 64, 68, 79, 64, 64, 68, 77, 64, 64, 68, 77, 64, 65, 67, 75, 64, 65,
-        67, 75, 64, 67, 71, 78, 64, 67, 71, 78, 65, 68, 74, 81, 65, 68, 74, 81,
-        68, 71, 79, 90, 68, 71, 79, 90, 70, 73, 86, 102, 70, 73, 86, 102, 77,
-        78, 90, 108, 77, 78, 90, 108, 85, 84, 96, 116,
+        31, 32, 34, 39, 32, 32, 34, 38, 32, 32, 34, 38, 32, 32, 33, 37, 32, 32,
+        33, 37, 32, 33, 35, 39, 32, 33, 35, 39, 32, 34, 37, 40, 32, 34, 37, 40,
+        34, 35, 39, 45, 34, 35, 39, 45, 35, 36, 43, 51, 35, 36, 43, 51, 38, 39,
+        45, 54, 38, 39, 45, 54, 42, 42, 48, 58,
         /* Size 16x4 */
-        63, 64, 64, 64, 64, 64, 64, 65, 65, 68, 68, 70, 70, 77, 77, 85, 64, 64,
-        64, 65, 65, 67, 67, 68, 68, 71, 71, 73, 73, 78, 78, 84, 68, 68, 68, 67,
-        67, 71, 71, 74, 74, 79, 79, 86, 86, 90, 90, 96, 79, 77, 77, 75, 75, 78,
-        78, 81, 81, 90, 90, 102, 102, 108, 108, 116,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 34, 34, 35, 35, 38, 38, 42, 32, 32,
+        32, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 39, 39, 42, 34, 34, 34, 33,
+        33, 35, 35, 37, 37, 39, 39, 43, 43, 45, 45, 48, 39, 38, 38, 37, 37, 39,
+        39, 40, 40, 45, 45, 51, 51, 54, 54, 58,
         /* Size 8x32 */
-        64, 63, 63, 64, 64, 72, 72, 88, 63, 63, 63, 64, 64, 71, 71, 86, 63, 64,
-        64, 65, 65, 71, 71, 85, 63, 64, 64, 65, 65, 71, 71, 85, 63, 64, 64, 65,
-        65, 71, 71, 85, 63, 64, 64, 65, 65, 70, 70, 83, 63, 65, 65, 66, 66, 69,
-        69, 82, 63, 65, 65, 66, 66, 69, 69, 82, 63, 65, 65, 66, 66, 69, 69, 82,
-        63, 65, 65, 67, 67, 71, 71, 83, 64, 65, 65, 68, 68, 73, 73, 84, 64, 65,
-        65, 68, 68, 73, 73, 84, 64, 65, 65, 68, 68, 73, 73, 84, 64, 65, 65, 69,
-        69, 75, 75, 85, 64, 66, 66, 71, 71, 77, 77, 85, 64, 66, 66, 71, 71, 77,
-        77, 85, 64, 66, 66, 71, 71, 77, 77, 85, 66, 67, 67, 72, 72, 81, 81, 90,
-        68, 68, 68, 74, 74, 85, 85, 96, 68, 68, 68, 74, 74, 85, 85, 96, 68, 68,
-        68, 74, 74, 85, 85, 96, 70, 69, 69, 75, 75, 90, 90, 101, 72, 69, 69, 77,
-        77, 96, 96, 108, 72, 69, 69, 77, 77, 96, 96, 108, 72, 69, 69, 77, 77,
-        96, 96, 108, 75, 72, 72, 79, 79, 98, 98, 112, 79, 75, 75, 81, 81, 101,
-        101, 116, 79, 75, 75, 81, 81, 101, 101, 116, 79, 75, 75, 81, 81, 101,
-        101, 116, 83, 79, 79, 84, 84, 104, 104, 121, 88, 82, 82, 86, 86, 107,
-        107, 126, 88, 82, 82, 86, 86, 107, 107, 126,
+        32, 31, 31, 32, 32, 36, 36, 44, 31, 31, 31, 32, 32, 35, 35, 43, 31, 32,
+        32, 32, 32, 35, 35, 42, 31, 32, 32, 32, 32, 35, 35, 42, 31, 32, 32, 32,
+        32, 35, 35, 42, 31, 32, 32, 32, 32, 35, 35, 41, 31, 32, 32, 33, 33, 34,
+        34, 41, 31, 32, 32, 33, 33, 34, 34, 41, 31, 32, 32, 33, 33, 34, 34, 41,
+        31, 32, 32, 33, 33, 35, 35, 41, 32, 32, 32, 34, 34, 36, 36, 42, 32, 32,
+        32, 34, 34, 36, 36, 42, 32, 32, 32, 34, 34, 36, 36, 42, 32, 32, 32, 34,
+        34, 37, 37, 42, 32, 33, 33, 35, 35, 38, 38, 42, 32, 33, 33, 35, 35, 38,
+        38, 42, 32, 33, 33, 35, 35, 38, 38, 42, 33, 33, 33, 36, 36, 40, 40, 45,
+        34, 34, 34, 37, 37, 42, 42, 48, 34, 34, 34, 37, 37, 42, 42, 48, 34, 34,
+        34, 37, 37, 42, 42, 48, 35, 34, 34, 37, 37, 45, 45, 50, 36, 34, 34, 38,
+        38, 48, 48, 54, 36, 34, 34, 38, 38, 48, 48, 54, 36, 34, 34, 38, 38, 48,
+        48, 54, 37, 36, 36, 39, 39, 49, 49, 56, 39, 37, 37, 40, 40, 50, 50, 58,
+        39, 37, 37, 40, 40, 50, 50, 58, 39, 37, 37, 40, 40, 50, 50, 58, 41, 39,
+        39, 42, 42, 52, 52, 60, 44, 41, 41, 43, 43, 53, 53, 63, 44, 41, 41, 43,
+        43, 53, 53, 63,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 66,
-        68, 68, 68, 70, 72, 72, 72, 75, 79, 79, 79, 83, 88, 88, 63, 63, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 68, 68, 68, 69,
-        69, 69, 69, 72, 75, 75, 75, 79, 82, 82, 63, 63, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 68, 68, 68, 69, 69, 69, 69, 72,
-        75, 75, 75, 79, 82, 82, 64, 64, 65, 65, 65, 65, 66, 66, 66, 67, 68, 68,
-        68, 69, 71, 71, 71, 72, 74, 74, 74, 75, 77, 77, 77, 79, 81, 81, 81, 84,
-        86, 86, 64, 64, 65, 65, 65, 65, 66, 66, 66, 67, 68, 68, 68, 69, 71, 71,
-        71, 72, 74, 74, 74, 75, 77, 77, 77, 79, 81, 81, 81, 84, 86, 86, 72, 71,
-        71, 71, 71, 70, 69, 69, 69, 71, 73, 73, 73, 75, 77, 77, 77, 81, 85, 85,
-        85, 90, 96, 96, 96, 98, 101, 101, 101, 104, 107, 107, 72, 71, 71, 71,
-        71, 70, 69, 69, 69, 71, 73, 73, 73, 75, 77, 77, 77, 81, 85, 85, 85, 90,
-        96, 96, 96, 98, 101, 101, 101, 104, 107, 107, 88, 86, 85, 85, 85, 83,
-        82, 82, 82, 83, 84, 84, 84, 85, 85, 85, 85, 90, 96, 96, 96, 101, 108,
-        108, 108, 112, 116, 116, 116, 121, 126, 126 },
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33,
+        34, 34, 34, 35, 36, 36, 36, 37, 39, 39, 39, 41, 44, 44, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34,
+        34, 34, 34, 36, 37, 37, 37, 39, 41, 41, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 36,
+        37, 37, 37, 39, 41, 41, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34,
+        34, 34, 35, 35, 35, 36, 37, 37, 37, 37, 38, 38, 38, 39, 40, 40, 40, 42,
+        43, 43, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35,
+        35, 36, 37, 37, 37, 37, 38, 38, 38, 39, 40, 40, 40, 42, 43, 43, 36, 35,
+        35, 35, 35, 35, 34, 34, 34, 35, 36, 36, 36, 37, 38, 38, 38, 40, 42, 42,
+        42, 45, 48, 48, 48, 49, 50, 50, 50, 52, 53, 53, 36, 35, 35, 35, 35, 35,
+        34, 34, 34, 35, 36, 36, 36, 37, 38, 38, 38, 40, 42, 42, 42, 45, 48, 48,
+        48, 49, 50, 50, 50, 52, 53, 53, 44, 43, 42, 42, 42, 41, 41, 41, 41, 41,
+        42, 42, 42, 42, 42, 42, 42, 45, 48, 48, 48, 50, 54, 54, 54, 56, 58, 58,
+        58, 60, 63, 63 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        64, 93, 93, 106,
+        32, 46, 46, 53,
 #endif
         /* Size 4x4 */
-        63, 69, 85, 94, 69, 78, 90, 93, 85, 90, 97, 99, 94, 93, 99, 109,
+        31, 34, 42, 47, 34, 39, 45, 46, 42, 45, 48, 49, 47, 46, 49, 54,
         /* Size 8x8 */
-        63, 62, 65, 71, 79, 90, 96, 96, 62, 63, 66, 74, 82, 89, 93, 92, 65, 66,
-        71, 79, 85, 90, 93, 91, 71, 74, 79, 86, 91, 94, 94, 92, 79, 82, 85, 91,
-        95, 97, 97, 95, 90, 89, 90, 94, 97, 101, 103, 103, 96, 93, 93, 94, 97,
-        103, 107, 108, 96, 92, 91, 92, 95, 103, 108, 112,
+        31, 31, 32, 35, 39, 45, 48, 48, 31, 31, 33, 37, 41, 44, 46, 46, 32, 33,
+        35, 39, 42, 45, 46, 45, 35, 37, 39, 43, 45, 47, 47, 46, 39, 41, 42, 45,
+        47, 48, 48, 47, 45, 44, 45, 47, 48, 50, 51, 51, 48, 46, 46, 47, 48, 51,
+        53, 54, 48, 46, 45, 46, 47, 51, 54, 56,
         /* Size 16x16 */
-        64, 62, 62, 61, 61, 67, 67, 73, 73, 83, 83, 98, 98, 97, 97, 98, 62, 63,
-        63, 62, 62, 69, 69, 77, 77, 85, 85, 95, 95, 94, 94, 94, 62, 63, 63, 62,
-        62, 69, 69, 77, 77, 85, 85, 95, 95, 94, 94, 94, 61, 62, 62, 64, 64, 71,
-        71, 80, 80, 85, 85, 93, 93, 91, 91, 90, 61, 62, 62, 64, 64, 71, 71, 80,
-        80, 85, 85, 93, 93, 91, 91, 90, 67, 69, 69, 71, 71, 78, 78, 87, 87, 90,
-        90, 95, 95, 93, 93, 91, 67, 69, 69, 71, 71, 78, 78, 87, 87, 90, 90, 95,
-        95, 93, 93, 91, 73, 77, 77, 80, 80, 87, 87, 95, 95, 95, 95, 96, 96, 93,
-        93, 91, 73, 77, 77, 80, 80, 87, 87, 95, 95, 95, 95, 96, 96, 93, 93, 91,
-        83, 85, 85, 85, 85, 90, 90, 95, 95, 97, 97, 101, 101, 99, 99, 98, 83,
-        85, 85, 85, 85, 90, 90, 95, 95, 97, 97, 101, 101, 99, 99, 98, 98, 95,
-        95, 93, 93, 95, 95, 96, 96, 101, 101, 106, 106, 106, 106, 107, 98, 95,
-        95, 93, 93, 95, 95, 96, 96, 101, 101, 106, 106, 106, 106, 107, 97, 94,
-        94, 91, 91, 93, 93, 93, 93, 99, 99, 106, 106, 109, 109, 111, 97, 94, 94,
-        91, 91, 93, 93, 93, 93, 99, 99, 106, 106, 109, 109, 111, 98, 94, 94, 90,
-        90, 91, 91, 91, 91, 98, 98, 107, 107, 111, 111, 117,
+        32, 31, 31, 30, 30, 33, 33, 36, 36, 41, 41, 49, 49, 48, 48, 49, 31, 31,
+        31, 31, 31, 34, 34, 38, 38, 42, 42, 47, 47, 47, 47, 47, 31, 31, 31, 31,
+        31, 34, 34, 38, 38, 42, 42, 47, 47, 47, 47, 47, 30, 31, 31, 32, 32, 35,
+        35, 40, 40, 42, 42, 46, 46, 45, 45, 45, 30, 31, 31, 32, 32, 35, 35, 40,
+        40, 42, 42, 46, 46, 45, 45, 45, 33, 34, 34, 35, 35, 39, 39, 43, 43, 45,
+        45, 47, 47, 46, 46, 45, 33, 34, 34, 35, 35, 39, 39, 43, 43, 45, 45, 47,
+        47, 46, 46, 45, 36, 38, 38, 40, 40, 43, 43, 47, 47, 47, 47, 48, 48, 46,
+        46, 45, 36, 38, 38, 40, 40, 43, 43, 47, 47, 47, 47, 48, 48, 46, 46, 45,
+        41, 42, 42, 42, 42, 45, 45, 47, 47, 48, 48, 50, 50, 49, 49, 49, 41, 42,
+        42, 42, 42, 45, 45, 47, 47, 48, 48, 50, 50, 49, 49, 49, 49, 47, 47, 46,
+        46, 47, 47, 48, 48, 50, 50, 53, 53, 53, 53, 53, 49, 47, 47, 46, 46, 47,
+        47, 48, 48, 50, 50, 53, 53, 53, 53, 53, 48, 47, 47, 45, 45, 46, 46, 46,
+        46, 49, 49, 53, 53, 54, 54, 55, 48, 47, 47, 45, 45, 46, 46, 46, 46, 49,
+        49, 53, 53, 54, 54, 55, 49, 47, 47, 45, 45, 45, 45, 45, 45, 49, 49, 53,
+        53, 55, 55, 58,
         /* Size 32x32 */
-        64, 63, 62, 62, 62, 62, 61, 61, 61, 64, 67, 67, 67, 70, 73, 73, 73, 78,
-        83, 83, 83, 90, 98, 98, 98, 98, 97, 97, 97, 98, 98, 98, 63, 63, 63, 63,
-        63, 62, 62, 62, 62, 65, 68, 68, 68, 71, 75, 75, 75, 79, 84, 84, 84, 90,
-        97, 97, 97, 96, 96, 96, 96, 96, 96, 96, 62, 63, 63, 63, 63, 63, 62, 62,
-        62, 66, 69, 69, 69, 73, 77, 77, 77, 81, 85, 85, 85, 90, 95, 95, 95, 95,
-        94, 94, 94, 94, 94, 94, 62, 63, 63, 63, 63, 63, 62, 62, 62, 66, 69, 69,
-        69, 73, 77, 77, 77, 81, 85, 85, 85, 90, 95, 95, 95, 95, 94, 94, 94, 94,
-        94, 94, 62, 63, 63, 63, 63, 63, 62, 62, 62, 66, 69, 69, 69, 73, 77, 77,
-        77, 81, 85, 85, 85, 90, 95, 95, 95, 95, 94, 94, 94, 94, 94, 94, 62, 62,
-        63, 63, 63, 63, 63, 63, 63, 66, 70, 70, 70, 74, 78, 78, 78, 82, 85, 85,
-        85, 89, 94, 94, 94, 93, 93, 93, 93, 92, 92, 92, 61, 62, 62, 62, 62, 63,
-        64, 64, 64, 67, 71, 71, 71, 75, 80, 80, 80, 83, 85, 85, 85, 89, 93, 93,
-        93, 92, 91, 91, 91, 91, 90, 90, 61, 62, 62, 62, 62, 63, 64, 64, 64, 67,
-        71, 71, 71, 75, 80, 80, 80, 83, 85, 85, 85, 89, 93, 93, 93, 92, 91, 91,
-        91, 91, 90, 90, 61, 62, 62, 62, 62, 63, 64, 64, 64, 67, 71, 71, 71, 75,
-        80, 80, 80, 83, 85, 85, 85, 89, 93, 93, 93, 92, 91, 91, 91, 91, 90, 90,
-        64, 65, 66, 66, 66, 66, 67, 67, 67, 71, 74, 74, 74, 79, 83, 83, 83, 85,
-        87, 87, 87, 90, 94, 94, 94, 93, 92, 92, 92, 91, 90, 90, 67, 68, 69, 69,
-        69, 70, 71, 71, 71, 74, 78, 78, 78, 82, 87, 87, 87, 88, 90, 90, 90, 92,
-        95, 95, 95, 94, 93, 93, 93, 92, 91, 91, 67, 68, 69, 69, 69, 70, 71, 71,
-        71, 74, 78, 78, 78, 82, 87, 87, 87, 88, 90, 90, 90, 92, 95, 95, 95, 94,
-        93, 93, 93, 92, 91, 91, 67, 68, 69, 69, 69, 70, 71, 71, 71, 74, 78, 78,
-        78, 82, 87, 87, 87, 88, 90, 90, 90, 92, 95, 95, 95, 94, 93, 93, 93, 92,
-        91, 91, 70, 71, 73, 73, 73, 74, 75, 75, 75, 79, 82, 82, 82, 86, 91, 91,
-        91, 91, 92, 92, 92, 94, 95, 95, 95, 94, 93, 93, 93, 92, 91, 91, 73, 75,
-        77, 77, 77, 78, 80, 80, 80, 83, 87, 87, 87, 91, 95, 95, 95, 95, 95, 95,
-        95, 95, 96, 96, 96, 94, 93, 93, 93, 92, 91, 91, 73, 75, 77, 77, 77, 78,
-        80, 80, 80, 83, 87, 87, 87, 91, 95, 95, 95, 95, 95, 95, 95, 95, 96, 96,
-        96, 94, 93, 93, 93, 92, 91, 91, 73, 75, 77, 77, 77, 78, 80, 80, 80, 83,
-        87, 87, 87, 91, 95, 95, 95, 95, 95, 95, 95, 95, 96, 96, 96, 94, 93, 93,
-        93, 92, 91, 91, 78, 79, 81, 81, 81, 82, 83, 83, 83, 85, 88, 88, 88, 91,
-        95, 95, 95, 95, 96, 96, 96, 97, 98, 98, 98, 97, 96, 96, 96, 95, 94, 94,
-        83, 84, 85, 85, 85, 85, 85, 85, 85, 87, 90, 90, 90, 92, 95, 95, 95, 96,
-        97, 97, 97, 99, 101, 101, 101, 100, 99, 99, 99, 99, 98, 98, 83, 84, 85,
-        85, 85, 85, 85, 85, 85, 87, 90, 90, 90, 92, 95, 95, 95, 96, 97, 97, 97,
-        99, 101, 101, 101, 100, 99, 99, 99, 99, 98, 98, 83, 84, 85, 85, 85, 85,
-        85, 85, 85, 87, 90, 90, 90, 92, 95, 95, 95, 96, 97, 97, 97, 99, 101,
-        101, 101, 100, 99, 99, 99, 99, 98, 98, 90, 90, 90, 90, 90, 89, 89, 89,
-        89, 90, 92, 92, 92, 94, 95, 95, 95, 97, 99, 99, 99, 101, 103, 103, 103,
-        103, 103, 103, 103, 103, 103, 103, 98, 97, 95, 95, 95, 94, 93, 93, 93,
-        94, 95, 95, 95, 95, 96, 96, 96, 98, 101, 101, 101, 103, 106, 106, 106,
-        106, 106, 106, 106, 107, 107, 107, 98, 97, 95, 95, 95, 94, 93, 93, 93,
-        94, 95, 95, 95, 95, 96, 96, 96, 98, 101, 101, 101, 103, 106, 106, 106,
-        106, 106, 106, 106, 107, 107, 107, 98, 97, 95, 95, 95, 94, 93, 93, 93,
-        94, 95, 95, 95, 95, 96, 96, 96, 98, 101, 101, 101, 103, 106, 106, 106,
-        106, 106, 106, 106, 107, 107, 107, 98, 96, 95, 95, 95, 93, 92, 92, 92,
-        93, 94, 94, 94, 94, 94, 94, 94, 97, 100, 100, 100, 103, 106, 106, 106,
-        107, 107, 107, 107, 108, 109, 109, 97, 96, 94, 94, 94, 93, 91, 91, 91,
-        92, 93, 93, 93, 93, 93, 93, 93, 96, 99, 99, 99, 103, 106, 106, 106, 107,
-        109, 109, 109, 110, 111, 111, 97, 96, 94, 94, 94, 93, 91, 91, 91, 92,
-        93, 93, 93, 93, 93, 93, 93, 96, 99, 99, 99, 103, 106, 106, 106, 107,
-        109, 109, 109, 110, 111, 111, 97, 96, 94, 94, 94, 93, 91, 91, 91, 92,
-        93, 93, 93, 93, 93, 93, 93, 96, 99, 99, 99, 103, 106, 106, 106, 107,
-        109, 109, 109, 110, 111, 111, 98, 96, 94, 94, 94, 92, 91, 91, 91, 91,
-        92, 92, 92, 92, 92, 92, 92, 95, 99, 99, 99, 103, 107, 107, 107, 108,
-        110, 110, 110, 112, 114, 114, 98, 96, 94, 94, 94, 92, 90, 90, 90, 90,
-        91, 91, 91, 91, 91, 91, 91, 94, 98, 98, 98, 103, 107, 107, 107, 109,
-        111, 111, 111, 114, 117, 117, 98, 96, 94, 94, 94, 92, 90, 90, 90, 90,
-        91, 91, 91, 91, 91, 91, 91, 94, 98, 98, 98, 103, 107, 107, 107, 109,
-        111, 111, 111, 114, 117, 117,
+        32, 31, 31, 31, 31, 31, 30, 30, 30, 32, 33, 33, 33, 35, 36, 36, 36, 39,
+        41, 41, 41, 45, 49, 49, 49, 49, 48, 48, 48, 49, 49, 49, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 32, 34, 34, 34, 35, 37, 37, 37, 39, 42, 42, 42, 45,
+        48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 33, 34, 34, 34, 36, 38, 38, 38, 40, 42, 42, 42, 45, 47, 47, 47, 47,
+        47, 47, 47, 47, 47, 47, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 34,
+        34, 36, 38, 38, 38, 40, 42, 42, 42, 45, 47, 47, 47, 47, 47, 47, 47, 47,
+        47, 47, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 34, 34, 36, 38, 38,
+        38, 40, 42, 42, 42, 45, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 33, 35, 35, 35, 37, 39, 39, 39, 41, 42, 42,
+        42, 44, 47, 47, 47, 46, 46, 46, 46, 46, 46, 46, 30, 31, 31, 31, 31, 31,
+        32, 32, 32, 33, 35, 35, 35, 37, 40, 40, 40, 41, 42, 42, 42, 44, 46, 46,
+        46, 46, 45, 45, 45, 45, 45, 45, 30, 31, 31, 31, 31, 31, 32, 32, 32, 33,
+        35, 35, 35, 37, 40, 40, 40, 41, 42, 42, 42, 44, 46, 46, 46, 46, 45, 45,
+        45, 45, 45, 45, 30, 31, 31, 31, 31, 31, 32, 32, 32, 33, 35, 35, 35, 37,
+        40, 40, 40, 41, 42, 42, 42, 44, 46, 46, 46, 46, 45, 45, 45, 45, 45, 45,
+        32, 32, 33, 33, 33, 33, 33, 33, 33, 35, 37, 37, 37, 39, 41, 41, 41, 42,
+        43, 43, 43, 45, 47, 47, 47, 46, 46, 46, 46, 45, 45, 45, 33, 34, 34, 34,
+        34, 35, 35, 35, 35, 37, 39, 39, 39, 41, 43, 43, 43, 44, 45, 45, 45, 46,
+        47, 47, 47, 47, 46, 46, 46, 46, 45, 45, 33, 34, 34, 34, 34, 35, 35, 35,
+        35, 37, 39, 39, 39, 41, 43, 43, 43, 44, 45, 45, 45, 46, 47, 47, 47, 47,
+        46, 46, 46, 46, 45, 45, 33, 34, 34, 34, 34, 35, 35, 35, 35, 37, 39, 39,
+        39, 41, 43, 43, 43, 44, 45, 45, 45, 46, 47, 47, 47, 47, 46, 46, 46, 46,
+        45, 45, 35, 35, 36, 36, 36, 37, 37, 37, 37, 39, 41, 41, 41, 43, 45, 45,
+        45, 45, 46, 46, 46, 47, 47, 47, 47, 47, 46, 46, 46, 46, 45, 45, 36, 37,
+        38, 38, 38, 39, 40, 40, 40, 41, 43, 43, 43, 45, 47, 47, 47, 47, 47, 47,
+        47, 47, 48, 48, 48, 47, 46, 46, 46, 46, 45, 45, 36, 37, 38, 38, 38, 39,
+        40, 40, 40, 41, 43, 43, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48,
+        48, 47, 46, 46, 46, 46, 45, 45, 36, 37, 38, 38, 38, 39, 40, 40, 40, 41,
+        43, 43, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 46, 46,
+        46, 46, 45, 45, 39, 39, 40, 40, 40, 41, 41, 41, 41, 42, 44, 44, 44, 45,
+        47, 47, 47, 47, 48, 48, 48, 48, 49, 49, 49, 48, 48, 48, 48, 47, 47, 47,
+        41, 42, 42, 42, 42, 42, 42, 42, 42, 43, 45, 45, 45, 46, 47, 47, 47, 48,
+        48, 48, 48, 49, 50, 50, 50, 50, 49, 49, 49, 49, 49, 49, 41, 42, 42, 42,
+        42, 42, 42, 42, 42, 43, 45, 45, 45, 46, 47, 47, 47, 48, 48, 48, 48, 49,
+        50, 50, 50, 50, 49, 49, 49, 49, 49, 49, 41, 42, 42, 42, 42, 42, 42, 42,
+        42, 43, 45, 45, 45, 46, 47, 47, 47, 48, 48, 48, 48, 49, 50, 50, 50, 50,
+        49, 49, 49, 49, 49, 49, 45, 45, 45, 45, 45, 44, 44, 44, 44, 45, 46, 46,
+        46, 47, 47, 47, 47, 48, 49, 49, 49, 50, 51, 51, 51, 51, 51, 51, 51, 51,
+        51, 51, 49, 48, 47, 47, 47, 47, 46, 46, 46, 47, 47, 47, 47, 47, 48, 48,
+        48, 49, 50, 50, 50, 51, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 49, 48,
+        47, 47, 47, 47, 46, 46, 46, 47, 47, 47, 47, 47, 48, 48, 48, 49, 50, 50,
+        50, 51, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 49, 48, 47, 47, 47, 47,
+        46, 46, 46, 47, 47, 47, 47, 47, 48, 48, 48, 49, 50, 50, 50, 51, 53, 53,
+        53, 53, 53, 53, 53, 53, 53, 53, 49, 48, 47, 47, 47, 46, 46, 46, 46, 46,
+        47, 47, 47, 47, 47, 47, 47, 48, 50, 50, 50, 51, 53, 53, 53, 53, 53, 53,
+        53, 54, 54, 54, 48, 48, 47, 47, 47, 46, 45, 45, 45, 46, 46, 46, 46, 46,
+        46, 46, 46, 48, 49, 49, 49, 51, 53, 53, 53, 53, 54, 54, 54, 55, 55, 55,
+        48, 48, 47, 47, 47, 46, 45, 45, 45, 46, 46, 46, 46, 46, 46, 46, 46, 48,
+        49, 49, 49, 51, 53, 53, 53, 53, 54, 54, 54, 55, 55, 55, 48, 48, 47, 47,
+        47, 46, 45, 45, 45, 46, 46, 46, 46, 46, 46, 46, 46, 48, 49, 49, 49, 51,
+        53, 53, 53, 53, 54, 54, 54, 55, 55, 55, 49, 48, 47, 47, 47, 46, 45, 45,
+        45, 45, 46, 46, 46, 46, 46, 46, 46, 47, 49, 49, 49, 51, 53, 53, 53, 54,
+        55, 55, 55, 56, 57, 57, 49, 48, 47, 47, 47, 46, 45, 45, 45, 45, 45, 45,
+        45, 45, 45, 45, 45, 47, 49, 49, 49, 51, 53, 53, 53, 54, 55, 55, 55, 57,
+        58, 58, 49, 48, 47, 47, 47, 46, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+        45, 47, 49, 49, 49, 51, 53, 53, 53, 54, 55, 55, 55, 57, 58, 58,
         /* Size 4x8 */
-        63, 68, 84, 96, 63, 70, 85, 93, 66, 75, 88, 92, 73, 82, 92, 93, 81, 88,
-        96, 96, 90, 92, 99, 103, 95, 94, 100, 108, 94, 92, 99, 110,
+        31, 34, 42, 48, 31, 35, 42, 46, 33, 37, 44, 46, 36, 41, 46, 46, 40, 44,
+        48, 48, 45, 46, 49, 51, 47, 47, 50, 54, 47, 46, 49, 55,
         /* Size 8x4 */
-        63, 63, 66, 73, 81, 90, 95, 94, 68, 70, 75, 82, 88, 92, 94, 92, 84, 85,
-        88, 92, 96, 99, 100, 99, 96, 93, 92, 93, 96, 103, 108, 110,
+        31, 31, 33, 36, 40, 45, 47, 47, 34, 35, 37, 41, 44, 46, 47, 46, 42, 42,
+        44, 46, 48, 49, 50, 49, 48, 46, 46, 46, 48, 51, 54, 55,
         /* Size 8x16 */
-        64, 62, 62, 74, 74, 96, 96, 98, 63, 63, 63, 77, 77, 94, 94, 94, 63, 63,
-        63, 77, 77, 94, 94, 94, 61, 64, 64, 80, 80, 92, 92, 91, 61, 64, 64, 80,
-        80, 92, 92, 91, 67, 72, 72, 86, 86, 94, 94, 92, 67, 72, 72, 86, 86, 94,
-        94, 92, 74, 80, 80, 94, 94, 95, 95, 91, 74, 80, 80, 94, 94, 95, 95, 91,
-        84, 86, 86, 95, 95, 100, 100, 99, 84, 86, 86, 95, 95, 100, 100, 99, 98,
-        93, 93, 96, 96, 106, 106, 107, 98, 93, 93, 96, 96, 106, 106, 107, 97,
-        92, 92, 94, 94, 106, 106, 112, 97, 92, 92, 94, 94, 106, 106, 112, 98,
-        91, 91, 92, 92, 107, 107, 117,
+        32, 31, 31, 37, 37, 48, 48, 49, 31, 31, 31, 38, 38, 47, 47, 47, 31, 31,
+        31, 38, 38, 47, 47, 47, 30, 32, 32, 40, 40, 46, 46, 45, 30, 32, 32, 40,
+        40, 46, 46, 45, 33, 36, 36, 43, 43, 47, 47, 46, 33, 36, 36, 43, 43, 47,
+        47, 46, 37, 40, 40, 47, 47, 47, 47, 45, 37, 40, 40, 47, 47, 47, 47, 45,
+        42, 43, 43, 47, 47, 50, 50, 49, 42, 43, 43, 47, 47, 50, 50, 49, 49, 46,
+        46, 48, 48, 53, 53, 53, 49, 46, 46, 48, 48, 53, 53, 53, 48, 46, 46, 47,
+        47, 53, 53, 56, 48, 46, 46, 47, 47, 53, 53, 56, 49, 45, 45, 46, 46, 53,
+        53, 58,
         /* Size 16x8 */
-        64, 63, 63, 61, 61, 67, 67, 74, 74, 84, 84, 98, 98, 97, 97, 98, 62, 63,
-        63, 64, 64, 72, 72, 80, 80, 86, 86, 93, 93, 92, 92, 91, 62, 63, 63, 64,
-        64, 72, 72, 80, 80, 86, 86, 93, 93, 92, 92, 91, 74, 77, 77, 80, 80, 86,
-        86, 94, 94, 95, 95, 96, 96, 94, 94, 92, 74, 77, 77, 80, 80, 86, 86, 94,
-        94, 95, 95, 96, 96, 94, 94, 92, 96, 94, 94, 92, 92, 94, 94, 95, 95, 100,
-        100, 106, 106, 106, 106, 107, 96, 94, 94, 92, 92, 94, 94, 95, 95, 100,
-        100, 106, 106, 106, 106, 107, 98, 94, 94, 91, 91, 92, 92, 91, 91, 99,
-        99, 107, 107, 112, 112, 117,
+        32, 31, 31, 30, 30, 33, 33, 37, 37, 42, 42, 49, 49, 48, 48, 49, 31, 31,
+        31, 32, 32, 36, 36, 40, 40, 43, 43, 46, 46, 46, 46, 45, 31, 31, 31, 32,
+        32, 36, 36, 40, 40, 43, 43, 46, 46, 46, 46, 45, 37, 38, 38, 40, 40, 43,
+        43, 47, 47, 47, 47, 48, 48, 47, 47, 46, 37, 38, 38, 40, 40, 43, 43, 47,
+        47, 47, 47, 48, 48, 47, 47, 46, 48, 47, 47, 46, 46, 47, 47, 47, 47, 50,
+        50, 53, 53, 53, 53, 53, 48, 47, 47, 46, 46, 47, 47, 47, 47, 50, 50, 53,
+        53, 53, 53, 53, 49, 47, 47, 45, 45, 46, 46, 45, 45, 49, 49, 53, 53, 56,
+        56, 58,
         /* Size 16x32 */
-        64, 63, 62, 62, 62, 67, 74, 74, 74, 84, 96, 96, 96, 97, 98, 98, 63, 63,
-        62, 62, 62, 68, 75, 75, 75, 84, 95, 95, 95, 96, 96, 96, 63, 63, 63, 63,
-        63, 69, 77, 77, 77, 85, 94, 94, 94, 94, 94, 94, 63, 63, 63, 63, 63, 69,
-        77, 77, 77, 85, 94, 94, 94, 94, 94, 94, 63, 63, 63, 63, 63, 69, 77, 77,
-        77, 85, 94, 94, 94, 94, 94, 94, 62, 63, 64, 64, 64, 70, 78, 78, 78, 85,
-        93, 93, 93, 93, 92, 92, 61, 63, 64, 64, 64, 71, 80, 80, 80, 85, 92, 92,
-        92, 91, 91, 91, 61, 63, 64, 64, 64, 71, 80, 80, 80, 85, 92, 92, 92, 91,
-        91, 91, 61, 63, 64, 64, 64, 71, 80, 80, 80, 85, 92, 92, 92, 91, 91, 91,
-        64, 66, 68, 68, 68, 75, 83, 83, 83, 88, 93, 93, 93, 92, 91, 91, 67, 69,
-        72, 72, 72, 78, 86, 86, 86, 90, 94, 94, 94, 93, 92, 92, 67, 69, 72, 72,
-        72, 78, 86, 86, 86, 90, 94, 94, 94, 93, 92, 92, 67, 69, 72, 72, 72, 78,
-        86, 86, 86, 90, 94, 94, 94, 93, 92, 92, 71, 73, 76, 76, 76, 82, 90, 90,
-        90, 92, 95, 95, 95, 93, 91, 91, 74, 77, 80, 80, 80, 87, 94, 94, 94, 95,
-        95, 95, 95, 93, 91, 91, 74, 77, 80, 80, 80, 87, 94, 94, 94, 95, 95, 95,
-        95, 93, 91, 91, 74, 77, 80, 80, 80, 87, 94, 94, 94, 95, 95, 95, 95, 93,
-        91, 91, 79, 81, 83, 83, 83, 88, 95, 95, 95, 96, 98, 98, 98, 96, 95, 95,
-        84, 85, 86, 86, 86, 90, 95, 95, 95, 97, 100, 100, 100, 100, 99, 99, 84,
-        85, 86, 86, 86, 90, 95, 95, 95, 97, 100, 100, 100, 100, 99, 99, 84, 85,
-        86, 86, 86, 90, 95, 95, 95, 97, 100, 100, 100, 100, 99, 99, 90, 90, 89,
-        89, 89, 92, 95, 95, 95, 99, 103, 103, 103, 103, 103, 103, 98, 96, 93,
-        93, 93, 95, 96, 96, 96, 101, 106, 106, 106, 107, 107, 107, 98, 96, 93,
-        93, 93, 95, 96, 96, 96, 101, 106, 106, 106, 107, 107, 107, 98, 96, 93,
-        93, 93, 95, 96, 96, 96, 101, 106, 106, 106, 107, 107, 107, 97, 95, 93,
-        93, 93, 94, 95, 95, 95, 100, 106, 106, 106, 108, 109, 109, 97, 94, 92,
-        92, 92, 93, 94, 94, 94, 100, 106, 106, 106, 109, 112, 112, 97, 94, 92,
-        92, 92, 93, 94, 94, 94, 100, 106, 106, 106, 109, 112, 112, 97, 94, 92,
-        92, 92, 93, 94, 94, 94, 100, 106, 106, 106, 109, 112, 112, 97, 94, 91,
-        91, 91, 92, 93, 93, 93, 99, 106, 106, 106, 110, 114, 114, 98, 94, 91,
-        91, 91, 91, 92, 92, 92, 99, 107, 107, 107, 112, 117, 117, 98, 94, 91,
-        91, 91, 91, 92, 92, 92, 99, 107, 107, 107, 112, 117, 117,
+        32, 31, 31, 31, 31, 33, 37, 37, 37, 42, 48, 48, 48, 48, 49, 49, 31, 31,
+        31, 31, 31, 34, 37, 37, 37, 42, 47, 47, 47, 48, 48, 48, 31, 31, 31, 31,
+        31, 34, 38, 38, 38, 42, 47, 47, 47, 47, 47, 47, 31, 31, 31, 31, 31, 34,
+        38, 38, 38, 42, 47, 47, 47, 47, 47, 47, 31, 31, 31, 31, 31, 34, 38, 38,
+        38, 42, 47, 47, 47, 47, 47, 47, 31, 31, 32, 32, 32, 35, 39, 39, 39, 42,
+        46, 46, 46, 46, 46, 46, 30, 31, 32, 32, 32, 35, 40, 40, 40, 42, 46, 46,
+        46, 45, 45, 45, 30, 31, 32, 32, 32, 35, 40, 40, 40, 42, 46, 46, 46, 45,
+        45, 45, 30, 31, 32, 32, 32, 35, 40, 40, 40, 42, 46, 46, 46, 45, 45, 45,
+        32, 33, 34, 34, 34, 37, 41, 41, 41, 44, 46, 46, 46, 46, 45, 45, 33, 34,
+        36, 36, 36, 39, 43, 43, 43, 45, 47, 47, 47, 46, 46, 46, 33, 34, 36, 36,
+        36, 39, 43, 43, 43, 45, 47, 47, 47, 46, 46, 46, 33, 34, 36, 36, 36, 39,
+        43, 43, 43, 45, 47, 47, 47, 46, 46, 46, 35, 36, 38, 38, 38, 41, 45, 45,
+        45, 46, 47, 47, 47, 46, 45, 45, 37, 38, 40, 40, 40, 43, 47, 47, 47, 47,
+        47, 47, 47, 46, 45, 45, 37, 38, 40, 40, 40, 43, 47, 47, 47, 47, 47, 47,
+        47, 46, 45, 45, 37, 38, 40, 40, 40, 43, 47, 47, 47, 47, 47, 47, 47, 46,
+        45, 45, 39, 40, 41, 41, 41, 44, 47, 47, 47, 48, 49, 49, 49, 48, 47, 47,
+        42, 42, 43, 43, 43, 45, 47, 47, 47, 48, 50, 50, 50, 50, 49, 49, 42, 42,
+        43, 43, 43, 45, 47, 47, 47, 48, 50, 50, 50, 50, 49, 49, 42, 42, 43, 43,
+        43, 45, 47, 47, 47, 48, 50, 50, 50, 50, 49, 49, 45, 45, 44, 44, 44, 46,
+        47, 47, 47, 49, 51, 51, 51, 51, 51, 51, 49, 48, 46, 46, 46, 47, 48, 48,
+        48, 50, 53, 53, 53, 53, 53, 53, 49, 48, 46, 46, 46, 47, 48, 48, 48, 50,
+        53, 53, 53, 53, 53, 53, 49, 48, 46, 46, 46, 47, 48, 48, 48, 50, 53, 53,
+        53, 53, 53, 53, 48, 47, 46, 46, 46, 47, 47, 47, 47, 50, 53, 53, 53, 54,
+        54, 54, 48, 47, 46, 46, 46, 46, 47, 47, 47, 50, 53, 53, 53, 54, 56, 56,
+        48, 47, 46, 46, 46, 46, 47, 47, 47, 50, 53, 53, 53, 54, 56, 56, 48, 47,
+        46, 46, 46, 46, 47, 47, 47, 50, 53, 53, 53, 54, 56, 56, 48, 47, 45, 45,
+        45, 46, 46, 46, 46, 49, 53, 53, 53, 55, 57, 57, 49, 47, 45, 45, 45, 45,
+        46, 46, 46, 49, 53, 53, 53, 56, 58, 58, 49, 47, 45, 45, 45, 45, 46, 46,
+        46, 49, 53, 53, 53, 56, 58, 58,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 62, 61, 61, 61, 64, 67, 67, 67, 71, 74, 74, 74, 79,
-        84, 84, 84, 90, 98, 98, 98, 97, 97, 97, 97, 97, 98, 98, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 66, 69, 69, 69, 73, 77, 77, 77, 81, 85, 85, 85, 90,
-        96, 96, 96, 95, 94, 94, 94, 94, 94, 94, 62, 62, 63, 63, 63, 64, 64, 64,
-        64, 68, 72, 72, 72, 76, 80, 80, 80, 83, 86, 86, 86, 89, 93, 93, 93, 93,
-        92, 92, 92, 91, 91, 91, 62, 62, 63, 63, 63, 64, 64, 64, 64, 68, 72, 72,
-        72, 76, 80, 80, 80, 83, 86, 86, 86, 89, 93, 93, 93, 93, 92, 92, 92, 91,
-        91, 91, 62, 62, 63, 63, 63, 64, 64, 64, 64, 68, 72, 72, 72, 76, 80, 80,
-        80, 83, 86, 86, 86, 89, 93, 93, 93, 93, 92, 92, 92, 91, 91, 91, 67, 68,
-        69, 69, 69, 70, 71, 71, 71, 75, 78, 78, 78, 82, 87, 87, 87, 88, 90, 90,
-        90, 92, 95, 95, 95, 94, 93, 93, 93, 92, 91, 91, 74, 75, 77, 77, 77, 78,
-        80, 80, 80, 83, 86, 86, 86, 90, 94, 94, 94, 95, 95, 95, 95, 95, 96, 96,
-        96, 95, 94, 94, 94, 93, 92, 92, 74, 75, 77, 77, 77, 78, 80, 80, 80, 83,
-        86, 86, 86, 90, 94, 94, 94, 95, 95, 95, 95, 95, 96, 96, 96, 95, 94, 94,
-        94, 93, 92, 92, 74, 75, 77, 77, 77, 78, 80, 80, 80, 83, 86, 86, 86, 90,
-        94, 94, 94, 95, 95, 95, 95, 95, 96, 96, 96, 95, 94, 94, 94, 93, 92, 92,
-        84, 84, 85, 85, 85, 85, 85, 85, 85, 88, 90, 90, 90, 92, 95, 95, 95, 96,
-        97, 97, 97, 99, 101, 101, 101, 100, 100, 100, 100, 99, 99, 99, 96, 95,
-        94, 94, 94, 93, 92, 92, 92, 93, 94, 94, 94, 95, 95, 95, 95, 98, 100,
-        100, 100, 103, 106, 106, 106, 106, 106, 106, 106, 106, 107, 107, 96, 95,
-        94, 94, 94, 93, 92, 92, 92, 93, 94, 94, 94, 95, 95, 95, 95, 98, 100,
-        100, 100, 103, 106, 106, 106, 106, 106, 106, 106, 106, 107, 107, 96, 95,
-        94, 94, 94, 93, 92, 92, 92, 93, 94, 94, 94, 95, 95, 95, 95, 98, 100,
-        100, 100, 103, 106, 106, 106, 106, 106, 106, 106, 106, 107, 107, 97, 96,
-        94, 94, 94, 93, 91, 91, 91, 92, 93, 93, 93, 93, 93, 93, 93, 96, 100,
-        100, 100, 103, 107, 107, 107, 108, 109, 109, 109, 110, 112, 112, 98, 96,
-        94, 94, 94, 92, 91, 91, 91, 91, 92, 92, 92, 91, 91, 91, 91, 95, 99, 99,
-        99, 103, 107, 107, 107, 109, 112, 112, 112, 114, 117, 117, 98, 96, 94,
-        94, 94, 92, 91, 91, 91, 91, 92, 92, 92, 91, 91, 91, 91, 95, 99, 99, 99,
-        103, 107, 107, 107, 109, 112, 112, 112, 114, 117, 117,
+        32, 31, 31, 31, 31, 31, 30, 30, 30, 32, 33, 33, 33, 35, 37, 37, 37, 39,
+        42, 42, 42, 45, 49, 49, 49, 48, 48, 48, 48, 48, 49, 49, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 33, 34, 34, 34, 36, 38, 38, 38, 40, 42, 42, 42, 45,
+        48, 48, 48, 47, 47, 47, 47, 47, 47, 47, 31, 31, 31, 31, 31, 32, 32, 32,
+        32, 34, 36, 36, 36, 38, 40, 40, 40, 41, 43, 43, 43, 44, 46, 46, 46, 46,
+        46, 46, 46, 45, 45, 45, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 36, 36,
+        36, 38, 40, 40, 40, 41, 43, 43, 43, 44, 46, 46, 46, 46, 46, 46, 46, 45,
+        45, 45, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 36, 36, 36, 38, 40, 40,
+        40, 41, 43, 43, 43, 44, 46, 46, 46, 46, 46, 46, 46, 45, 45, 45, 33, 34,
+        34, 34, 34, 35, 35, 35, 35, 37, 39, 39, 39, 41, 43, 43, 43, 44, 45, 45,
+        45, 46, 47, 47, 47, 47, 46, 46, 46, 46, 45, 45, 37, 37, 38, 38, 38, 39,
+        40, 40, 40, 41, 43, 43, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48,
+        48, 47, 47, 47, 47, 46, 46, 46, 37, 37, 38, 38, 38, 39, 40, 40, 40, 41,
+        43, 43, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 47, 47,
+        47, 46, 46, 46, 37, 37, 38, 38, 38, 39, 40, 40, 40, 41, 43, 43, 43, 45,
+        47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 47, 47, 47, 46, 46, 46,
+        42, 42, 42, 42, 42, 42, 42, 42, 42, 44, 45, 45, 45, 46, 47, 47, 47, 48,
+        48, 48, 48, 49, 50, 50, 50, 50, 50, 50, 50, 49, 49, 49, 48, 47, 47, 47,
+        47, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 49, 50, 50, 50, 51,
+        53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 48, 47, 47, 47, 47, 46, 46, 46,
+        46, 46, 47, 47, 47, 47, 47, 47, 47, 49, 50, 50, 50, 51, 53, 53, 53, 53,
+        53, 53, 53, 53, 53, 53, 48, 47, 47, 47, 47, 46, 46, 46, 46, 46, 47, 47,
+        47, 47, 47, 47, 47, 49, 50, 50, 50, 51, 53, 53, 53, 53, 53, 53, 53, 53,
+        53, 53, 48, 48, 47, 47, 47, 46, 45, 45, 45, 46, 46, 46, 46, 46, 46, 46,
+        46, 48, 50, 50, 50, 51, 53, 53, 53, 54, 54, 54, 54, 55, 56, 56, 49, 48,
+        47, 47, 47, 46, 45, 45, 45, 45, 46, 46, 46, 45, 45, 45, 45, 47, 49, 49,
+        49, 51, 53, 53, 53, 54, 56, 56, 56, 57, 58, 58, 49, 48, 47, 47, 47, 46,
+        45, 45, 45, 45, 46, 46, 46, 45, 45, 45, 45, 47, 49, 49, 49, 51, 53, 53,
+        53, 54, 56, 56, 56, 57, 58, 58,
         /* Size 4x16 */
-        63, 67, 84, 97, 63, 69, 85, 94, 63, 69, 85, 94, 63, 71, 85, 91, 63, 71,
-        85, 91, 69, 78, 90, 93, 69, 78, 90, 93, 77, 87, 95, 93, 77, 87, 95, 93,
-        85, 90, 97, 100, 85, 90, 97, 100, 96, 95, 101, 107, 96, 95, 101, 107,
-        94, 93, 100, 109, 94, 93, 100, 109, 94, 91, 99, 112,
+        31, 33, 42, 48, 31, 34, 42, 47, 31, 34, 42, 47, 31, 35, 42, 45, 31, 35,
+        42, 45, 34, 39, 45, 46, 34, 39, 45, 46, 38, 43, 47, 46, 38, 43, 47, 46,
+        42, 45, 48, 50, 42, 45, 48, 50, 48, 47, 50, 53, 48, 47, 50, 53, 47, 46,
+        50, 54, 47, 46, 50, 54, 47, 45, 49, 56,
         /* Size 16x4 */
-        63, 63, 63, 63, 63, 69, 69, 77, 77, 85, 85, 96, 96, 94, 94, 94, 67, 69,
-        69, 71, 71, 78, 78, 87, 87, 90, 90, 95, 95, 93, 93, 91, 84, 85, 85, 85,
-        85, 90, 90, 95, 95, 97, 97, 101, 101, 100, 100, 99, 97, 94, 94, 91, 91,
-        93, 93, 93, 93, 100, 100, 107, 107, 109, 109, 112,
+        31, 31, 31, 31, 31, 34, 34, 38, 38, 42, 42, 48, 48, 47, 47, 47, 33, 34,
+        34, 35, 35, 39, 39, 43, 43, 45, 45, 47, 47, 46, 46, 45, 42, 42, 42, 42,
+        42, 45, 45, 47, 47, 48, 48, 50, 50, 50, 50, 49, 48, 47, 47, 45, 45, 46,
+        46, 46, 46, 50, 50, 53, 53, 54, 54, 56,
         /* Size 8x32 */
-        64, 62, 62, 74, 74, 96, 96, 98, 63, 62, 62, 75, 75, 95, 95, 96, 63, 63,
-        63, 77, 77, 94, 94, 94, 63, 63, 63, 77, 77, 94, 94, 94, 63, 63, 63, 77,
-        77, 94, 94, 94, 62, 64, 64, 78, 78, 93, 93, 92, 61, 64, 64, 80, 80, 92,
-        92, 91, 61, 64, 64, 80, 80, 92, 92, 91, 61, 64, 64, 80, 80, 92, 92, 91,
-        64, 68, 68, 83, 83, 93, 93, 91, 67, 72, 72, 86, 86, 94, 94, 92, 67, 72,
-        72, 86, 86, 94, 94, 92, 67, 72, 72, 86, 86, 94, 94, 92, 71, 76, 76, 90,
-        90, 95, 95, 91, 74, 80, 80, 94, 94, 95, 95, 91, 74, 80, 80, 94, 94, 95,
-        95, 91, 74, 80, 80, 94, 94, 95, 95, 91, 79, 83, 83, 95, 95, 98, 98, 95,
-        84, 86, 86, 95, 95, 100, 100, 99, 84, 86, 86, 95, 95, 100, 100, 99, 84,
-        86, 86, 95, 95, 100, 100, 99, 90, 89, 89, 95, 95, 103, 103, 103, 98, 93,
-        93, 96, 96, 106, 106, 107, 98, 93, 93, 96, 96, 106, 106, 107, 98, 93,
-        93, 96, 96, 106, 106, 107, 97, 93, 93, 95, 95, 106, 106, 109, 97, 92,
-        92, 94, 94, 106, 106, 112, 97, 92, 92, 94, 94, 106, 106, 112, 97, 92,
-        92, 94, 94, 106, 106, 112, 97, 91, 91, 93, 93, 106, 106, 114, 98, 91,
-        91, 92, 92, 107, 107, 117, 98, 91, 91, 92, 92, 107, 107, 117,
+        32, 31, 31, 37, 37, 48, 48, 49, 31, 31, 31, 37, 37, 47, 47, 48, 31, 31,
+        31, 38, 38, 47, 47, 47, 31, 31, 31, 38, 38, 47, 47, 47, 31, 31, 31, 38,
+        38, 47, 47, 47, 31, 32, 32, 39, 39, 46, 46, 46, 30, 32, 32, 40, 40, 46,
+        46, 45, 30, 32, 32, 40, 40, 46, 46, 45, 30, 32, 32, 40, 40, 46, 46, 45,
+        32, 34, 34, 41, 41, 46, 46, 45, 33, 36, 36, 43, 43, 47, 47, 46, 33, 36,
+        36, 43, 43, 47, 47, 46, 33, 36, 36, 43, 43, 47, 47, 46, 35, 38, 38, 45,
+        45, 47, 47, 45, 37, 40, 40, 47, 47, 47, 47, 45, 37, 40, 40, 47, 47, 47,
+        47, 45, 37, 40, 40, 47, 47, 47, 47, 45, 39, 41, 41, 47, 47, 49, 49, 47,
+        42, 43, 43, 47, 47, 50, 50, 49, 42, 43, 43, 47, 47, 50, 50, 49, 42, 43,
+        43, 47, 47, 50, 50, 49, 45, 44, 44, 47, 47, 51, 51, 51, 49, 46, 46, 48,
+        48, 53, 53, 53, 49, 46, 46, 48, 48, 53, 53, 53, 49, 46, 46, 48, 48, 53,
+        53, 53, 48, 46, 46, 47, 47, 53, 53, 54, 48, 46, 46, 47, 47, 53, 53, 56,
+        48, 46, 46, 47, 47, 53, 53, 56, 48, 46, 46, 47, 47, 53, 53, 56, 48, 45,
+        45, 46, 46, 53, 53, 57, 49, 45, 45, 46, 46, 53, 53, 58, 49, 45, 45, 46,
+        46, 53, 53, 58,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 62, 61, 61, 61, 64, 67, 67, 67, 71, 74, 74, 74, 79,
-        84, 84, 84, 90, 98, 98, 98, 97, 97, 97, 97, 97, 98, 98, 62, 62, 63, 63,
-        63, 64, 64, 64, 64, 68, 72, 72, 72, 76, 80, 80, 80, 83, 86, 86, 86, 89,
-        93, 93, 93, 93, 92, 92, 92, 91, 91, 91, 62, 62, 63, 63, 63, 64, 64, 64,
-        64, 68, 72, 72, 72, 76, 80, 80, 80, 83, 86, 86, 86, 89, 93, 93, 93, 93,
-        92, 92, 92, 91, 91, 91, 74, 75, 77, 77, 77, 78, 80, 80, 80, 83, 86, 86,
-        86, 90, 94, 94, 94, 95, 95, 95, 95, 95, 96, 96, 96, 95, 94, 94, 94, 93,
-        92, 92, 74, 75, 77, 77, 77, 78, 80, 80, 80, 83, 86, 86, 86, 90, 94, 94,
-        94, 95, 95, 95, 95, 95, 96, 96, 96, 95, 94, 94, 94, 93, 92, 92, 96, 95,
-        94, 94, 94, 93, 92, 92, 92, 93, 94, 94, 94, 95, 95, 95, 95, 98, 100,
-        100, 100, 103, 106, 106, 106, 106, 106, 106, 106, 106, 107, 107, 96, 95,
-        94, 94, 94, 93, 92, 92, 92, 93, 94, 94, 94, 95, 95, 95, 95, 98, 100,
-        100, 100, 103, 106, 106, 106, 106, 106, 106, 106, 106, 107, 107, 98, 96,
-        94, 94, 94, 92, 91, 91, 91, 91, 92, 92, 92, 91, 91, 91, 91, 95, 99, 99,
-        99, 103, 107, 107, 107, 109, 112, 112, 112, 114, 117, 117 },
+        32, 31, 31, 31, 31, 31, 30, 30, 30, 32, 33, 33, 33, 35, 37, 37, 37, 39,
+        42, 42, 42, 45, 49, 49, 49, 48, 48, 48, 48, 48, 49, 49, 31, 31, 31, 31,
+        31, 32, 32, 32, 32, 34, 36, 36, 36, 38, 40, 40, 40, 41, 43, 43, 43, 44,
+        46, 46, 46, 46, 46, 46, 46, 45, 45, 45, 31, 31, 31, 31, 31, 32, 32, 32,
+        32, 34, 36, 36, 36, 38, 40, 40, 40, 41, 43, 43, 43, 44, 46, 46, 46, 46,
+        46, 46, 46, 45, 45, 45, 37, 37, 38, 38, 38, 39, 40, 40, 40, 41, 43, 43,
+        43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 47, 47, 47, 46,
+        46, 46, 37, 37, 38, 38, 38, 39, 40, 40, 40, 41, 43, 43, 43, 45, 47, 47,
+        47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 47, 47, 47, 46, 46, 46, 48, 47,
+        47, 47, 47, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 49, 50, 50,
+        50, 51, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 48, 47, 47, 47, 47, 46,
+        46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 49, 50, 50, 50, 51, 53, 53,
+        53, 53, 53, 53, 53, 53, 53, 53, 49, 48, 47, 47, 47, 46, 45, 45, 45, 45,
+        46, 46, 46, 45, 45, 45, 45, 47, 49, 49, 49, 51, 53, 53, 53, 54, 56, 56,
+        56, 57, 58, 58 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        64, 67, 67, 79,
+        32, 33, 33, 39,
 #endif
         /* Size 4x4 */
-        64, 64, 65, 70, 64, 65, 66, 70, 65, 66, 71, 76, 70, 70, 76, 92,
+        32, 32, 32, 35, 32, 32, 33, 35, 32, 33, 35, 38, 35, 35, 38, 46,
         /* Size 8x8 */
-        63, 63, 63, 64, 64, 65, 68, 71, 63, 64, 64, 64, 65, 66, 68, 70, 63, 64,
-        65, 65, 65, 66, 67, 69, 64, 64, 65, 67, 68, 69, 71, 73, 64, 65, 65, 68,
-        70, 71, 73, 76, 65, 66, 66, 69, 71, 73, 76, 80, 68, 68, 67, 71, 73, 76,
-        79, 85, 71, 70, 69, 73, 76, 80, 85, 97,
+        31, 31, 31, 32, 32, 32, 34, 35, 31, 32, 32, 32, 32, 33, 34, 35, 31, 32,
+        32, 32, 32, 33, 33, 34, 32, 32, 32, 33, 34, 34, 35, 36, 32, 32, 32, 34,
+        35, 35, 36, 38, 32, 33, 33, 34, 35, 36, 38, 40, 34, 34, 33, 35, 36, 38,
+        39, 42, 35, 35, 34, 36, 38, 40, 42, 48,
         /* Size 16x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 67, 68, 69, 72, 72, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 67, 68, 69, 71, 71, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 65, 65, 67, 68, 69, 70, 70, 63, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 67, 68, 68, 70, 70, 63, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 67, 67, 68, 69, 69, 63, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 67, 67, 68, 69, 69, 63, 64, 64, 65, 65, 65, 66, 66, 67, 67, 67, 69,
-        70, 71, 72, 72, 63, 64, 64, 65, 65, 65, 66, 67, 67, 68, 68, 70, 71, 72,
-        73, 73, 64, 64, 64, 65, 65, 65, 67, 67, 68, 69, 69, 71, 72, 73, 74, 74,
-        64, 64, 65, 65, 65, 65, 67, 68, 69, 71, 71, 73, 74, 75, 77, 77, 64, 64,
-        65, 65, 65, 65, 67, 68, 69, 71, 71, 73, 74, 75, 77, 77, 67, 67, 67, 67,
-        67, 67, 69, 70, 71, 73, 73, 77, 78, 80, 84, 84, 68, 68, 68, 68, 67, 67,
-        70, 71, 72, 74, 74, 78, 79, 82, 85, 85, 69, 69, 69, 68, 68, 68, 71, 72,
-        73, 75, 75, 80, 82, 85, 90, 90, 72, 71, 70, 70, 69, 69, 72, 73, 74, 77,
-        77, 84, 85, 90, 97, 97, 72, 71, 70, 70, 69, 69, 72, 73, 74, 77, 77, 84,
-        85, 90, 97, 97,
+        32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 34, 36, 36, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 34, 34, 34, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 34, 34, 34, 31, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34,
+        35, 35, 36, 36, 31, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 35, 35, 36,
+        36, 36, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 35, 36, 36, 37, 37,
+        32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 36, 37, 37, 38, 38, 32, 32,
+        32, 32, 32, 32, 33, 34, 34, 35, 35, 36, 37, 37, 38, 38, 33, 33, 33, 33,
+        33, 33, 34, 35, 35, 36, 36, 38, 39, 40, 42, 42, 34, 34, 34, 34, 33, 33,
+        35, 35, 36, 37, 37, 39, 39, 41, 42, 42, 34, 34, 34, 34, 34, 34, 35, 36,
+        36, 37, 37, 40, 41, 42, 45, 45, 36, 35, 35, 35, 34, 34, 36, 36, 37, 38,
+        38, 42, 42, 45, 48, 48, 36, 35, 35, 35, 34, 34, 36, 36, 37, 38, 38, 42,
+        42, 45, 48, 48,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 65, 67, 68, 68, 68, 69, 71, 72, 72, 72, 74, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65,
-        67, 68, 68, 68, 69, 70, 71, 71, 71, 74, 63, 63, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 66, 67, 68, 68, 68,
-        69, 70, 71, 71, 71, 73, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 65, 65, 65, 65, 66, 67, 68, 68, 68, 69, 70, 70, 70,
-        70, 73, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 65, 65, 65, 65, 66, 67, 68, 68, 68, 69, 70, 70, 70, 70, 73, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65,
-        65, 66, 67, 68, 68, 68, 69, 70, 70, 70, 70, 73, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 68,
-        68, 68, 68, 69, 70, 70, 70, 72, 63, 63, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 67, 67, 67, 68, 69,
-        69, 69, 69, 71, 63, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 66, 67, 67, 67, 67, 68, 68, 69, 69, 69, 71,
-        63, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 67, 67, 67, 67, 68, 68, 69, 69, 69, 71, 63, 63, 64, 64,
-        64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66,
-        67, 67, 67, 67, 68, 68, 69, 69, 69, 71, 63, 63, 64, 64, 64, 64, 64, 65,
-        65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 67, 68, 69, 69, 69,
-        69, 70, 70, 70, 70, 73, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66,
-        66, 66, 66, 66, 67, 67, 67, 67, 67, 68, 69, 70, 70, 70, 71, 72, 72, 72,
-        72, 74, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66, 66, 67, 67, 67,
-        67, 68, 68, 68, 68, 69, 70, 71, 71, 71, 72, 72, 73, 73, 73, 75, 63, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 66, 66, 67, 67, 67, 67, 68, 68, 68,
-        68, 69, 70, 71, 71, 71, 72, 72, 73, 73, 73, 75, 63, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 66, 66, 67, 67, 67, 67, 68, 68, 68, 68, 69, 70, 71,
-        71, 71, 72, 72, 73, 73, 73, 75, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 66, 67, 67, 67, 67, 68, 69, 69, 69, 69, 70, 71, 72, 72, 72, 73, 74,
-        74, 74, 74, 76, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 68,
-        68, 68, 69, 70, 70, 70, 70, 71, 72, 73, 73, 73, 74, 75, 76, 76, 76, 78,
-        64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 68, 68, 68, 69, 70,
-        71, 71, 71, 72, 73, 74, 74, 74, 75, 76, 77, 77, 77, 78, 64, 64, 64, 65,
-        65, 65, 65, 65, 65, 65, 65, 66, 67, 68, 68, 68, 69, 70, 71, 71, 71, 72,
-        73, 74, 74, 74, 75, 76, 77, 77, 77, 78, 64, 64, 64, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 67, 68, 68, 68, 69, 70, 71, 71, 71, 72, 73, 74, 74, 74,
-        75, 76, 77, 77, 77, 78, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 67,
-        68, 69, 69, 69, 70, 71, 72, 72, 72, 73, 75, 76, 76, 76, 77, 79, 80, 80,
-        80, 82, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 68, 69, 70, 70, 70,
-        71, 72, 73, 73, 73, 75, 77, 78, 78, 78, 80, 82, 84, 84, 84, 85, 68, 68,
-        68, 68, 68, 68, 68, 67, 67, 67, 67, 69, 70, 71, 71, 71, 72, 73, 74, 74,
-        74, 76, 78, 79, 79, 79, 82, 84, 85, 85, 85, 87, 68, 68, 68, 68, 68, 68,
-        68, 67, 67, 67, 67, 69, 70, 71, 71, 71, 72, 73, 74, 74, 74, 76, 78, 79,
-        79, 79, 82, 84, 85, 85, 85, 87, 68, 68, 68, 68, 68, 68, 68, 67, 67, 67,
-        67, 69, 70, 71, 71, 71, 72, 73, 74, 74, 74, 76, 78, 79, 79, 79, 82, 84,
-        85, 85, 85, 87, 69, 69, 69, 69, 69, 69, 68, 68, 68, 68, 68, 69, 71, 72,
-        72, 72, 73, 74, 75, 75, 75, 77, 80, 82, 82, 82, 85, 88, 90, 90, 90, 91,
-        71, 70, 70, 70, 70, 70, 69, 69, 68, 68, 68, 70, 72, 72, 72, 72, 74, 75,
-        76, 76, 76, 79, 82, 84, 84, 84, 88, 92, 94, 94, 94, 96, 72, 71, 71, 70,
-        70, 70, 70, 69, 69, 69, 69, 70, 72, 73, 73, 73, 74, 76, 77, 77, 77, 80,
-        84, 85, 85, 85, 90, 94, 97, 97, 97, 99, 72, 71, 71, 70, 70, 70, 70, 69,
-        69, 69, 69, 70, 72, 73, 73, 73, 74, 76, 77, 77, 77, 80, 84, 85, 85, 85,
-        90, 94, 97, 97, 97, 99, 72, 71, 71, 70, 70, 70, 70, 69, 69, 69, 69, 70,
-        72, 73, 73, 73, 74, 76, 77, 77, 77, 80, 84, 85, 85, 85, 90, 94, 97, 97,
-        97, 99, 74, 74, 73, 73, 73, 73, 72, 71, 71, 71, 71, 73, 74, 75, 75, 75,
-        76, 78, 78, 78, 78, 82, 85, 87, 87, 87, 91, 96, 99, 99, 99, 101,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 36, 36, 36, 37, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 34, 34, 34, 34, 35, 35, 35, 35, 37, 31, 31, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34,
+        34, 35, 35, 35, 35, 36, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 35,
+        35, 36, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 36, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 36, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34,
+        34, 34, 34, 34, 35, 35, 35, 36, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34, 34,
+        34, 34, 34, 35, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34,
+        34, 35, 35, 35, 35, 36, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35, 36, 36, 36,
+        36, 37, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33,
+        33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 36, 37, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34,
+        34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 36, 37, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35,
+        35, 35, 36, 36, 36, 36, 36, 37, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 36, 36, 36, 36, 37,
+        37, 37, 37, 38, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34,
+        34, 34, 34, 35, 35, 35, 35, 35, 36, 36, 36, 36, 37, 37, 38, 38, 38, 39,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 34, 35,
+        35, 35, 35, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 36,
+        36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 36, 36, 37, 37, 37,
+        37, 38, 38, 38, 38, 39, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        34, 34, 34, 34, 35, 35, 36, 36, 36, 36, 37, 38, 38, 38, 38, 39, 40, 40,
+        40, 41, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 35, 35, 35,
+        35, 36, 36, 36, 36, 37, 38, 39, 39, 39, 40, 41, 42, 42, 42, 42, 34, 34,
+        34, 34, 34, 34, 34, 33, 33, 33, 33, 34, 35, 35, 35, 35, 36, 36, 37, 37,
+        37, 38, 39, 39, 39, 39, 41, 42, 42, 42, 42, 43, 34, 34, 34, 34, 34, 34,
+        34, 33, 33, 33, 33, 34, 35, 35, 35, 35, 36, 36, 37, 37, 37, 38, 39, 39,
+        39, 39, 41, 42, 42, 42, 42, 43, 34, 34, 34, 34, 34, 34, 34, 33, 33, 33,
+        33, 34, 35, 35, 35, 35, 36, 36, 37, 37, 37, 38, 39, 39, 39, 39, 41, 42,
+        42, 42, 42, 43, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 36,
+        36, 36, 36, 37, 37, 37, 37, 38, 40, 41, 41, 41, 42, 44, 45, 45, 45, 45,
+        35, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, 35, 36, 36, 36, 36, 37, 37,
+        38, 38, 38, 39, 41, 42, 42, 42, 44, 46, 47, 47, 47, 48, 36, 35, 35, 35,
+        35, 35, 35, 34, 34, 34, 34, 35, 36, 36, 36, 36, 37, 38, 38, 38, 38, 40,
+        42, 42, 42, 42, 45, 47, 48, 48, 48, 49, 36, 35, 35, 35, 35, 35, 35, 34,
+        34, 34, 34, 35, 36, 36, 36, 36, 37, 38, 38, 38, 38, 40, 42, 42, 42, 42,
+        45, 47, 48, 48, 48, 49, 36, 35, 35, 35, 35, 35, 35, 34, 34, 34, 34, 35,
+        36, 36, 36, 36, 37, 38, 38, 38, 38, 40, 42, 42, 42, 42, 45, 47, 48, 48,
+        48, 49, 37, 37, 36, 36, 36, 36, 36, 35, 35, 35, 35, 36, 37, 37, 37, 37,
+        38, 39, 39, 39, 39, 41, 42, 43, 43, 43, 45, 48, 49, 49, 49, 50,
         /* Size 4x8 */
-        63, 63, 64, 71, 64, 64, 65, 71, 64, 65, 66, 69, 64, 65, 68, 73, 64, 66,
-        70, 76, 66, 66, 72, 80, 68, 68, 74, 85, 71, 69, 77, 96,
+        31, 31, 32, 35, 32, 32, 32, 35, 32, 32, 33, 34, 32, 32, 34, 36, 32, 33,
+        35, 38, 33, 33, 36, 40, 34, 34, 37, 42, 35, 34, 38, 48,
         /* Size 8x4 */
-        63, 64, 64, 64, 64, 66, 68, 71, 63, 64, 65, 65, 66, 66, 68, 69, 64, 65,
-        66, 68, 70, 72, 74, 77, 71, 71, 69, 73, 76, 80, 85, 96,
+        31, 32, 32, 32, 32, 33, 34, 35, 31, 32, 32, 32, 33, 33, 34, 34, 32, 32,
+        33, 34, 35, 36, 37, 38, 35, 35, 34, 36, 38, 40, 42, 48,
         /* Size 8x16 */
-        64, 63, 63, 63, 64, 64, 70, 72, 63, 64, 64, 64, 65, 65, 70, 71, 63, 64,
-        64, 64, 65, 65, 70, 71, 63, 64, 64, 65, 65, 65, 69, 70, 63, 64, 65, 65,
-        66, 66, 68, 69, 63, 64, 65, 65, 66, 66, 68, 69, 63, 65, 65, 66, 68, 68,
-        71, 72, 64, 65, 65, 66, 68, 68, 72, 73, 64, 65, 65, 67, 69, 69, 73, 75,
-        64, 65, 66, 68, 71, 71, 75, 77, 64, 65, 66, 68, 71, 71, 75, 77, 67, 67,
-        67, 70, 73, 73, 81, 83, 68, 68, 68, 70, 74, 74, 83, 85, 69, 69, 68, 71,
-        75, 75, 86, 89, 72, 70, 69, 72, 77, 77, 92, 96, 72, 70, 69, 72, 77, 77,
-        92, 96,
+        32, 31, 31, 31, 32, 32, 35, 36, 31, 32, 32, 32, 32, 32, 35, 35, 31, 32,
+        32, 32, 32, 32, 35, 35, 31, 32, 32, 32, 32, 32, 34, 35, 31, 32, 32, 32,
+        33, 33, 34, 34, 31, 32, 32, 32, 33, 33, 34, 34, 31, 32, 32, 33, 34, 34,
+        35, 36, 32, 32, 32, 33, 34, 34, 36, 36, 32, 32, 32, 33, 34, 34, 36, 37,
+        32, 32, 33, 34, 35, 35, 37, 38, 32, 32, 33, 34, 35, 35, 37, 38, 33, 33,
+        33, 35, 36, 36, 40, 41, 34, 34, 34, 35, 37, 37, 41, 42, 34, 34, 34, 35,
+        37, 37, 43, 44, 36, 35, 34, 36, 38, 38, 46, 48, 36, 35, 34, 36, 38, 38,
+        46, 48,
         /* Size 16x8 */
-        64, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 67, 68, 69, 72, 72, 63, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 67, 68, 69, 70, 70, 63, 64, 64, 64,
-        65, 65, 65, 65, 65, 66, 66, 67, 68, 68, 69, 69, 63, 64, 64, 65, 65, 65,
-        66, 66, 67, 68, 68, 70, 70, 71, 72, 72, 64, 65, 65, 65, 66, 66, 68, 68,
-        69, 71, 71, 73, 74, 75, 77, 77, 64, 65, 65, 65, 66, 66, 68, 68, 69, 71,
-        71, 73, 74, 75, 77, 77, 70, 70, 70, 69, 68, 68, 71, 72, 73, 75, 75, 81,
-        83, 86, 92, 92, 72, 71, 71, 70, 69, 69, 72, 73, 75, 77, 77, 83, 85, 89,
-        96, 96,
+        32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33, 34, 34, 36, 36, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 31, 32, 32, 32, 32, 32,
+        33, 33, 33, 34, 34, 35, 35, 35, 36, 36, 32, 32, 32, 32, 33, 33, 34, 34,
+        34, 35, 35, 36, 37, 37, 38, 38, 32, 32, 32, 32, 33, 33, 34, 34, 34, 35,
+        35, 36, 37, 37, 38, 38, 35, 35, 35, 34, 34, 34, 35, 36, 36, 37, 37, 40,
+        41, 43, 46, 46, 36, 35, 35, 35, 34, 34, 36, 36, 37, 38, 38, 41, 42, 44,
+        48, 48,
         /* Size 16x32 */
-        64, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 67, 70, 72, 72, 72, 63, 63,
-        63, 63, 63, 63, 64, 64, 64, 64, 64, 67, 70, 71, 71, 71, 63, 63, 64, 64,
-        64, 64, 64, 65, 65, 65, 65, 67, 70, 71, 71, 71, 63, 64, 64, 64, 64, 64,
-        64, 65, 65, 65, 65, 67, 70, 71, 71, 71, 63, 64, 64, 64, 64, 64, 64, 65,
-        65, 65, 65, 67, 70, 71, 71, 71, 63, 64, 64, 64, 64, 64, 64, 65, 65, 65,
-        65, 67, 70, 71, 71, 71, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 67,
-        69, 70, 70, 70, 63, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 67, 69, 70,
-        70, 70, 63, 64, 64, 65, 65, 65, 65, 65, 66, 66, 66, 67, 68, 69, 69, 69,
-        63, 64, 64, 65, 65, 65, 65, 65, 66, 66, 66, 67, 68, 69, 69, 69, 63, 64,
-        64, 65, 65, 65, 65, 65, 66, 66, 66, 67, 68, 69, 69, 69, 63, 64, 65, 65,
-        65, 65, 66, 66, 67, 67, 67, 68, 70, 71, 71, 71, 63, 64, 65, 65, 65, 65,
-        66, 67, 68, 68, 68, 69, 71, 72, 72, 72, 64, 64, 65, 65, 65, 65, 66, 68,
-        68, 68, 68, 70, 72, 73, 73, 73, 64, 64, 65, 65, 65, 65, 66, 68, 68, 68,
-        68, 70, 72, 73, 73, 73, 64, 64, 65, 65, 65, 65, 66, 68, 68, 68, 68, 70,
-        72, 73, 73, 73, 64, 64, 65, 65, 65, 65, 67, 68, 69, 69, 69, 71, 73, 75,
-        75, 75, 64, 64, 65, 66, 66, 66, 67, 69, 70, 70, 70, 72, 75, 76, 76, 76,
-        64, 64, 65, 66, 66, 66, 68, 70, 71, 71, 71, 73, 75, 77, 77, 77, 64, 64,
-        65, 66, 66, 66, 68, 70, 71, 71, 71, 73, 75, 77, 77, 77, 64, 64, 65, 66,
-        66, 66, 68, 70, 71, 71, 71, 73, 75, 77, 77, 77, 65, 66, 66, 66, 66, 66,
-        69, 71, 72, 72, 72, 75, 78, 80, 80, 80, 67, 67, 67, 67, 67, 67, 70, 72,
-        73, 73, 73, 77, 81, 83, 83, 83, 68, 68, 68, 68, 68, 68, 70, 72, 74, 74,
-        74, 78, 83, 85, 85, 85, 68, 68, 68, 68, 68, 68, 70, 72, 74, 74, 74, 78,
-        83, 85, 85, 85, 68, 68, 68, 68, 68, 68, 70, 72, 74, 74, 74, 78, 83, 85,
-        85, 85, 69, 69, 69, 68, 68, 68, 71, 74, 75, 75, 75, 80, 86, 89, 89, 89,
-        71, 70, 69, 69, 69, 69, 72, 75, 76, 76, 76, 82, 90, 94, 94, 94, 72, 71,
-        70, 69, 69, 69, 72, 75, 77, 77, 77, 84, 92, 96, 96, 96, 72, 71, 70, 69,
-        69, 69, 72, 75, 77, 77, 77, 84, 92, 96, 96, 96, 72, 71, 70, 69, 69, 69,
-        72, 75, 77, 77, 77, 84, 92, 96, 96, 96, 74, 73, 72, 72, 72, 72, 74, 77,
-        79, 79, 79, 85, 93, 98, 98, 98,
+        32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33, 35, 36, 36, 36, 31, 31,
+        31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 35, 35, 35, 35, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 35, 35, 35, 35, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 35, 35, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 35, 35, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 35, 35, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        34, 35, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 35,
+        35, 35, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34,
+        31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 31, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 31, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 34, 35, 35, 35, 35, 31, 32, 32, 32, 32, 32,
+        33, 33, 34, 34, 34, 34, 35, 36, 36, 36, 32, 32, 32, 32, 32, 32, 33, 34,
+        34, 34, 34, 35, 36, 36, 36, 36, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34,
+        34, 35, 36, 36, 36, 36, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 34, 35,
+        36, 36, 36, 36, 32, 32, 32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 36, 37,
+        37, 37, 32, 32, 32, 33, 33, 33, 33, 34, 35, 35, 35, 36, 37, 38, 38, 38,
+        32, 32, 32, 33, 33, 33, 34, 35, 35, 35, 35, 36, 37, 38, 38, 38, 32, 32,
+        32, 33, 33, 33, 34, 35, 35, 35, 35, 36, 37, 38, 38, 38, 32, 32, 32, 33,
+        33, 33, 34, 35, 35, 35, 35, 36, 37, 38, 38, 38, 32, 33, 33, 33, 33, 33,
+        34, 35, 36, 36, 36, 37, 39, 40, 40, 40, 33, 33, 33, 33, 33, 33, 35, 36,
+        36, 36, 36, 38, 40, 41, 41, 41, 34, 34, 34, 34, 34, 34, 35, 36, 37, 37,
+        37, 39, 41, 42, 42, 42, 34, 34, 34, 34, 34, 34, 35, 36, 37, 37, 37, 39,
+        41, 42, 42, 42, 34, 34, 34, 34, 34, 34, 35, 36, 37, 37, 37, 39, 41, 42,
+        42, 42, 34, 34, 34, 34, 34, 34, 35, 37, 37, 37, 37, 40, 43, 44, 44, 44,
+        35, 35, 34, 34, 34, 34, 36, 37, 38, 38, 38, 41, 45, 47, 47, 47, 36, 35,
+        35, 34, 34, 34, 36, 37, 38, 38, 38, 42, 46, 48, 48, 48, 36, 35, 35, 34,
+        34, 34, 36, 37, 38, 38, 38, 42, 46, 48, 48, 48, 36, 35, 35, 34, 34, 34,
+        36, 37, 38, 38, 38, 42, 46, 48, 48, 48, 37, 36, 36, 36, 36, 36, 37, 38,
+        39, 39, 39, 42, 46, 49, 49, 49,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 65, 67, 68, 68, 68, 69, 71, 72, 72, 72, 74, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 66,
-        67, 68, 68, 68, 69, 70, 71, 71, 71, 73, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 68, 68, 68,
-        69, 69, 70, 70, 70, 72, 63, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 68, 68, 68, 68, 69, 69, 69,
-        69, 72, 63, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 66, 66, 66, 66, 66, 67, 68, 68, 68, 68, 69, 69, 69, 69, 72, 63, 63,
-        64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66,
-        66, 66, 67, 68, 68, 68, 68, 69, 69, 69, 69, 72, 63, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 67, 68, 68, 68, 69, 70, 70,
-        70, 70, 71, 72, 72, 72, 72, 74, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 66, 67, 68, 68, 68, 68, 69, 70, 70, 70, 71, 72, 72, 72, 72, 74, 75,
-        75, 75, 75, 77, 64, 64, 65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 68, 68,
-        68, 68, 69, 70, 71, 71, 71, 72, 73, 74, 74, 74, 75, 76, 77, 77, 77, 79,
-        64, 64, 65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 68, 68, 68, 68, 69, 70,
-        71, 71, 71, 72, 73, 74, 74, 74, 75, 76, 77, 77, 77, 79, 64, 64, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 67, 68, 68, 68, 68, 69, 70, 71, 71, 71, 72,
-        73, 74, 74, 74, 75, 76, 77, 77, 77, 79, 67, 67, 67, 67, 67, 67, 67, 67,
-        67, 67, 67, 68, 69, 70, 70, 70, 71, 72, 73, 73, 73, 75, 77, 78, 78, 78,
-        80, 82, 84, 84, 84, 85, 70, 70, 70, 70, 70, 70, 69, 69, 68, 68, 68, 70,
-        71, 72, 72, 72, 73, 75, 75, 75, 75, 78, 81, 83, 83, 83, 86, 90, 92, 92,
-        92, 93, 72, 71, 71, 71, 71, 71, 70, 70, 69, 69, 69, 71, 72, 73, 73, 73,
-        75, 76, 77, 77, 77, 80, 83, 85, 85, 85, 89, 94, 96, 96, 96, 98, 72, 71,
-        71, 71, 71, 71, 70, 70, 69, 69, 69, 71, 72, 73, 73, 73, 75, 76, 77, 77,
-        77, 80, 83, 85, 85, 85, 89, 94, 96, 96, 96, 98, 72, 71, 71, 71, 71, 71,
-        70, 70, 69, 69, 69, 71, 72, 73, 73, 73, 75, 76, 77, 77, 77, 80, 83, 85,
-        85, 85, 89, 94, 96, 96, 96, 98,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 36, 36, 36, 37, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 34, 34, 34, 34, 35, 35, 35, 35, 36, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34,
+        34, 34, 35, 35, 35, 36, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34,
+        34, 36, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 36, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
+        33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 36, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35,
+        35, 35, 35, 36, 36, 36, 36, 37, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 37, 37,
+        37, 37, 37, 38, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34,
+        34, 34, 34, 35, 35, 35, 35, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35,
+        35, 35, 35, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 36,
+        36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 37, 38, 39, 39, 39,
+        40, 41, 42, 42, 42, 42, 35, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, 35,
+        35, 36, 36, 36, 36, 37, 37, 37, 37, 39, 40, 41, 41, 41, 43, 45, 46, 46,
+        46, 46, 36, 35, 35, 35, 35, 35, 35, 35, 34, 34, 34, 35, 36, 36, 36, 36,
+        37, 38, 38, 38, 38, 40, 41, 42, 42, 42, 44, 47, 48, 48, 48, 49, 36, 35,
+        35, 35, 35, 35, 35, 35, 34, 34, 34, 35, 36, 36, 36, 36, 37, 38, 38, 38,
+        38, 40, 41, 42, 42, 42, 44, 47, 48, 48, 48, 49, 36, 35, 35, 35, 35, 35,
+        35, 35, 34, 34, 34, 35, 36, 36, 36, 36, 37, 38, 38, 38, 38, 40, 41, 42,
+        42, 42, 44, 47, 48, 48, 48, 49,
         /* Size 4x16 */
-        63, 63, 64, 72, 63, 64, 65, 71, 64, 64, 65, 71, 64, 64, 65, 70, 64, 65,
-        66, 69, 64, 65, 66, 69, 64, 65, 68, 72, 64, 65, 68, 73, 64, 65, 69, 75,
-        64, 66, 71, 77, 64, 66, 71, 77, 67, 67, 73, 83, 68, 68, 74, 85, 69, 68,
-        75, 89, 71, 69, 77, 96, 71, 69, 77, 96,
+        31, 31, 32, 36, 31, 32, 32, 35, 32, 32, 32, 35, 32, 32, 32, 35, 32, 32,
+        33, 34, 32, 32, 33, 34, 32, 32, 34, 36, 32, 32, 34, 36, 32, 32, 34, 37,
+        32, 33, 35, 38, 32, 33, 35, 38, 33, 33, 36, 41, 34, 34, 37, 42, 34, 34,
+        37, 44, 35, 34, 38, 48, 35, 34, 38, 48,
         /* Size 16x4 */
-        63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 67, 68, 69, 71, 71, 63, 64,
-        64, 64, 65, 65, 65, 65, 65, 66, 66, 67, 68, 68, 69, 69, 64, 65, 65, 65,
-        66, 66, 68, 68, 69, 71, 71, 73, 74, 75, 77, 77, 72, 71, 71, 70, 69, 69,
-        72, 73, 75, 77, 77, 83, 85, 89, 96, 96,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 32, 32, 32, 32,
+        33, 33, 34, 34, 34, 35, 35, 36, 37, 37, 38, 38, 36, 35, 35, 35, 34, 34,
+        36, 36, 37, 38, 38, 41, 42, 44, 48, 48,
         /* Size 8x32 */
-        64, 63, 63, 63, 64, 64, 70, 72, 63, 63, 63, 64, 64, 64, 70, 71, 63, 64,
-        64, 64, 65, 65, 70, 71, 63, 64, 64, 64, 65, 65, 70, 71, 63, 64, 64, 64,
-        65, 65, 70, 71, 63, 64, 64, 64, 65, 65, 70, 71, 63, 64, 64, 65, 65, 65,
-        69, 70, 63, 64, 65, 65, 65, 65, 69, 70, 63, 64, 65, 65, 66, 66, 68, 69,
-        63, 64, 65, 65, 66, 66, 68, 69, 63, 64, 65, 65, 66, 66, 68, 69, 63, 65,
-        65, 66, 67, 67, 70, 71, 63, 65, 65, 66, 68, 68, 71, 72, 64, 65, 65, 66,
-        68, 68, 72, 73, 64, 65, 65, 66, 68, 68, 72, 73, 64, 65, 65, 66, 68, 68,
-        72, 73, 64, 65, 65, 67, 69, 69, 73, 75, 64, 65, 66, 67, 70, 70, 75, 76,
-        64, 65, 66, 68, 71, 71, 75, 77, 64, 65, 66, 68, 71, 71, 75, 77, 64, 65,
-        66, 68, 71, 71, 75, 77, 65, 66, 66, 69, 72, 72, 78, 80, 67, 67, 67, 70,
-        73, 73, 81, 83, 68, 68, 68, 70, 74, 74, 83, 85, 68, 68, 68, 70, 74, 74,
-        83, 85, 68, 68, 68, 70, 74, 74, 83, 85, 69, 69, 68, 71, 75, 75, 86, 89,
-        71, 69, 69, 72, 76, 76, 90, 94, 72, 70, 69, 72, 77, 77, 92, 96, 72, 70,
-        69, 72, 77, 77, 92, 96, 72, 70, 69, 72, 77, 77, 92, 96, 74, 72, 72, 74,
-        79, 79, 93, 98,
+        32, 31, 31, 31, 32, 32, 35, 36, 31, 31, 31, 32, 32, 32, 35, 35, 31, 32,
+        32, 32, 32, 32, 35, 35, 31, 32, 32, 32, 32, 32, 35, 35, 31, 32, 32, 32,
+        32, 32, 35, 35, 31, 32, 32, 32, 32, 32, 35, 35, 31, 32, 32, 32, 32, 32,
+        34, 35, 31, 32, 32, 32, 32, 32, 34, 35, 31, 32, 32, 32, 33, 33, 34, 34,
+        31, 32, 32, 32, 33, 33, 34, 34, 31, 32, 32, 32, 33, 33, 34, 34, 31, 32,
+        32, 33, 33, 33, 35, 35, 31, 32, 32, 33, 34, 34, 35, 36, 32, 32, 32, 33,
+        34, 34, 36, 36, 32, 32, 32, 33, 34, 34, 36, 36, 32, 32, 32, 33, 34, 34,
+        36, 36, 32, 32, 32, 33, 34, 34, 36, 37, 32, 32, 33, 33, 35, 35, 37, 38,
+        32, 32, 33, 34, 35, 35, 37, 38, 32, 32, 33, 34, 35, 35, 37, 38, 32, 32,
+        33, 34, 35, 35, 37, 38, 32, 33, 33, 34, 36, 36, 39, 40, 33, 33, 33, 35,
+        36, 36, 40, 41, 34, 34, 34, 35, 37, 37, 41, 42, 34, 34, 34, 35, 37, 37,
+        41, 42, 34, 34, 34, 35, 37, 37, 41, 42, 34, 34, 34, 35, 37, 37, 43, 44,
+        35, 34, 34, 36, 38, 38, 45, 47, 36, 35, 34, 36, 38, 38, 46, 48, 36, 35,
+        34, 36, 38, 38, 46, 48, 36, 35, 34, 36, 38, 38, 46, 48, 37, 36, 36, 37,
+        39, 39, 46, 49,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 65, 67, 68, 68, 68, 69, 71, 72, 72, 72, 74, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66,
-        67, 68, 68, 68, 69, 69, 70, 70, 70, 72, 63, 63, 64, 64, 64, 64, 64, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 68, 68, 68,
-        68, 69, 69, 69, 69, 72, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66,
-        66, 66, 66, 66, 67, 67, 68, 68, 68, 69, 70, 70, 70, 70, 71, 72, 72, 72,
-        72, 74, 64, 64, 65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 68, 68, 68, 68,
-        69, 70, 71, 71, 71, 72, 73, 74, 74, 74, 75, 76, 77, 77, 77, 79, 64, 64,
-        65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 68, 68, 68, 68, 69, 70, 71, 71,
-        71, 72, 73, 74, 74, 74, 75, 76, 77, 77, 77, 79, 70, 70, 70, 70, 70, 70,
-        69, 69, 68, 68, 68, 70, 71, 72, 72, 72, 73, 75, 75, 75, 75, 78, 81, 83,
-        83, 83, 86, 90, 92, 92, 92, 93, 72, 71, 71, 71, 71, 71, 70, 70, 69, 69,
-        69, 71, 72, 73, 73, 73, 75, 76, 77, 77, 77, 80, 83, 85, 85, 85, 89, 94,
-        96, 96, 96, 98 },
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 34, 34, 34, 34, 35, 36, 36, 36, 37, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 34, 34, 34, 34, 34, 35, 35, 35, 36, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34,
+        34, 34, 34, 34, 34, 36, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 35, 36, 36, 36,
+        36, 37, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34,
+        34, 35, 35, 35, 35, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35,
+        35, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 35, 35, 35, 35, 35, 35,
+        34, 34, 34, 34, 34, 35, 35, 36, 36, 36, 36, 37, 37, 37, 37, 39, 40, 41,
+        41, 41, 43, 45, 46, 46, 46, 46, 36, 35, 35, 35, 35, 35, 35, 35, 34, 34,
+        34, 35, 36, 36, 36, 36, 37, 38, 38, 38, 38, 40, 41, 42, 42, 42, 44, 47,
+        48, 48, 48, 49 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        63, 85, 85, 97,
+        31, 42, 42, 48,
 #endif
         /* Size 4x4 */
-        63, 65, 77, 93, 65, 69, 83, 92, 77, 83, 95, 95, 93, 92, 95, 104,
+        31, 32, 38, 46, 32, 34, 41, 46, 38, 41, 47, 47, 46, 46, 47, 52,
         /* Size 8x8 */
-        63, 63, 61, 68, 73, 78, 84, 97, 63, 63, 62, 69, 75, 80, 85, 95, 61, 62,
-        64, 71, 78, 82, 85, 93, 68, 69, 71, 78, 85, 88, 90, 95, 73, 75, 78, 85,
-        92, 94, 94, 95, 78, 80, 82, 88, 94, 95, 96, 98, 84, 85, 85, 90, 94, 96,
-        97, 101, 97, 95, 93, 95, 95, 98, 101, 106,
+        31, 31, 30, 34, 36, 39, 42, 48, 31, 31, 31, 34, 37, 40, 42, 47, 30, 31,
+        32, 35, 39, 41, 42, 46, 34, 34, 35, 39, 42, 44, 45, 47, 36, 37, 39, 42,
+        46, 47, 47, 47, 39, 40, 41, 44, 47, 47, 48, 49, 42, 42, 42, 45, 47, 48,
+        48, 50, 48, 47, 46, 47, 47, 49, 50, 53,
         /* Size 16x16 */
-        64, 63, 62, 62, 61, 61, 66, 67, 69, 73, 73, 81, 83, 89, 98, 98, 63, 63,
-        63, 62, 62, 62, 67, 69, 72, 76, 76, 83, 84, 89, 96, 96, 62, 63, 63, 63,
-        62, 62, 68, 69, 72, 77, 77, 83, 85, 89, 95, 95, 62, 62, 63, 63, 63, 63,
-        68, 70, 73, 78, 78, 83, 85, 88, 94, 94, 61, 62, 62, 63, 64, 64, 69, 71,
-        74, 80, 80, 84, 85, 88, 93, 93, 61, 62, 62, 63, 64, 64, 69, 71, 74, 80,
-        80, 84, 85, 88, 93, 93, 66, 67, 68, 68, 69, 69, 75, 77, 80, 85, 85, 88,
-        89, 91, 94, 94, 67, 69, 69, 70, 71, 71, 77, 78, 81, 87, 87, 89, 90, 92,
-        95, 95, 69, 72, 72, 73, 74, 74, 80, 81, 85, 90, 90, 91, 92, 93, 95, 95,
-        73, 76, 77, 78, 80, 80, 85, 87, 90, 95, 95, 95, 95, 95, 96, 96, 73, 76,
-        77, 78, 80, 80, 85, 87, 90, 95, 95, 95, 95, 95, 96, 96, 81, 83, 83, 83,
-        84, 84, 88, 89, 91, 95, 95, 96, 97, 98, 100, 100, 83, 84, 85, 85, 85,
-        85, 89, 90, 92, 95, 95, 97, 97, 99, 101, 101, 89, 89, 89, 88, 88, 88,
-        91, 92, 93, 95, 95, 98, 99, 100, 103, 103, 98, 96, 95, 94, 93, 93, 94,
-        95, 95, 96, 96, 100, 101, 103, 106, 106, 98, 96, 95, 94, 93, 93, 94, 95,
-        95, 96, 96, 100, 101, 103, 106, 106,
+        32, 31, 31, 31, 30, 30, 33, 33, 34, 36, 36, 40, 41, 44, 49, 49, 31, 31,
+        31, 31, 31, 31, 33, 34, 36, 38, 38, 41, 42, 44, 48, 48, 31, 31, 31, 31,
+        31, 31, 34, 34, 36, 38, 38, 41, 42, 44, 47, 47, 31, 31, 31, 31, 31, 31,
+        34, 35, 36, 39, 39, 41, 42, 44, 47, 47, 30, 31, 31, 31, 32, 32, 34, 35,
+        37, 40, 40, 42, 42, 44, 46, 46, 30, 31, 31, 31, 32, 32, 34, 35, 37, 40,
+        40, 42, 42, 44, 46, 46, 33, 33, 34, 34, 34, 34, 37, 38, 40, 42, 42, 44,
+        44, 45, 47, 47, 33, 34, 34, 35, 35, 35, 38, 39, 40, 43, 43, 44, 45, 46,
+        47, 47, 34, 36, 36, 36, 37, 37, 40, 40, 42, 45, 45, 45, 46, 46, 47, 47,
+        36, 38, 38, 39, 40, 40, 42, 43, 45, 47, 47, 47, 47, 47, 48, 48, 36, 38,
+        38, 39, 40, 40, 42, 43, 45, 47, 47, 47, 47, 47, 48, 48, 40, 41, 41, 41,
+        42, 42, 44, 44, 45, 47, 47, 48, 48, 49, 50, 50, 41, 42, 42, 42, 42, 42,
+        44, 45, 46, 47, 47, 48, 48, 49, 50, 50, 44, 44, 44, 44, 44, 44, 45, 46,
+        46, 47, 47, 49, 49, 50, 51, 51, 49, 48, 47, 47, 46, 46, 47, 47, 47, 48,
+        48, 50, 50, 51, 53, 53, 49, 48, 47, 47, 46, 46, 47, 47, 47, 48, 48, 50,
+        50, 51, 53, 53,
         /* Size 32x32 */
-        64, 63, 63, 62, 62, 62, 62, 61, 61, 61, 61, 63, 66, 67, 67, 67, 69, 72,
-        73, 73, 73, 77, 81, 83, 83, 83, 89, 95, 98, 98, 98, 98, 63, 63, 63, 63,
-        63, 63, 62, 62, 61, 61, 61, 64, 66, 68, 68, 68, 70, 73, 75, 75, 75, 78,
-        82, 84, 84, 84, 89, 94, 97, 97, 97, 97, 63, 63, 63, 63, 63, 63, 62, 62,
-        62, 62, 62, 65, 67, 69, 69, 69, 72, 75, 76, 76, 76, 79, 83, 84, 84, 84,
-        89, 93, 96, 96, 96, 95, 62, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 65,
-        68, 69, 69, 69, 72, 75, 77, 77, 77, 80, 83, 85, 85, 85, 89, 93, 95, 95,
-        95, 95, 62, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 65, 68, 69, 69, 69,
-        72, 75, 77, 77, 77, 80, 83, 85, 85, 85, 89, 93, 95, 95, 95, 95, 62, 63,
-        63, 63, 63, 63, 63, 63, 62, 62, 62, 65, 68, 69, 69, 69, 72, 75, 77, 77,
-        77, 80, 83, 85, 85, 85, 89, 93, 95, 95, 95, 95, 62, 62, 62, 63, 63, 63,
-        63, 63, 63, 63, 63, 66, 68, 70, 70, 70, 73, 76, 78, 78, 78, 81, 83, 85,
-        85, 85, 88, 92, 94, 94, 94, 94, 61, 62, 62, 63, 63, 63, 63, 63, 63, 63,
-        63, 66, 69, 71, 71, 71, 74, 77, 79, 79, 79, 82, 84, 85, 85, 85, 88, 92,
-        93, 93, 93, 93, 61, 61, 62, 62, 62, 62, 63, 63, 64, 64, 64, 66, 69, 71,
-        71, 71, 74, 78, 80, 80, 80, 82, 84, 85, 85, 85, 88, 91, 93, 93, 93, 92,
-        61, 61, 62, 62, 62, 62, 63, 63, 64, 64, 64, 66, 69, 71, 71, 71, 74, 78,
-        80, 80, 80, 82, 84, 85, 85, 85, 88, 91, 93, 93, 93, 92, 61, 61, 62, 62,
-        62, 62, 63, 63, 64, 64, 64, 66, 69, 71, 71, 71, 74, 78, 80, 80, 80, 82,
-        84, 85, 85, 85, 88, 91, 93, 93, 93, 92, 63, 64, 65, 65, 65, 65, 66, 66,
-        66, 66, 66, 69, 72, 74, 74, 74, 77, 81, 83, 83, 83, 84, 86, 87, 87, 87,
-        89, 92, 93, 93, 93, 93, 66, 66, 67, 68, 68, 68, 68, 69, 69, 69, 69, 72,
-        75, 77, 77, 77, 80, 83, 85, 85, 85, 87, 88, 89, 89, 89, 91, 93, 94, 94,
-        94, 93, 67, 68, 69, 69, 69, 69, 70, 71, 71, 71, 71, 74, 77, 78, 78, 78,
-        81, 85, 87, 87, 87, 88, 89, 90, 90, 90, 92, 94, 95, 95, 95, 94, 67, 68,
-        69, 69, 69, 69, 70, 71, 71, 71, 71, 74, 77, 78, 78, 78, 81, 85, 87, 87,
-        87, 88, 89, 90, 90, 90, 92, 94, 95, 95, 95, 94, 67, 68, 69, 69, 69, 69,
-        70, 71, 71, 71, 71, 74, 77, 78, 78, 78, 81, 85, 87, 87, 87, 88, 89, 90,
-        90, 90, 92, 94, 95, 95, 95, 94, 69, 70, 72, 72, 72, 72, 73, 74, 74, 74,
-        74, 77, 80, 81, 81, 81, 85, 88, 90, 90, 90, 91, 91, 92, 92, 92, 93, 94,
-        95, 95, 95, 94, 72, 73, 75, 75, 75, 75, 76, 77, 78, 78, 78, 81, 83, 85,
-        85, 85, 88, 92, 93, 93, 93, 94, 94, 94, 94, 94, 94, 95, 95, 95, 95, 94,
-        73, 75, 76, 77, 77, 77, 78, 79, 80, 80, 80, 83, 85, 87, 87, 87, 90, 93,
-        95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 96, 96, 96, 95, 73, 75, 76, 77,
-        77, 77, 78, 79, 80, 80, 80, 83, 85, 87, 87, 87, 90, 93, 95, 95, 95, 95,
-        95, 95, 95, 95, 95, 95, 96, 96, 96, 95, 73, 75, 76, 77, 77, 77, 78, 79,
-        80, 80, 80, 83, 85, 87, 87, 87, 90, 93, 95, 95, 95, 95, 95, 95, 95, 95,
-        95, 95, 96, 96, 96, 95, 77, 78, 79, 80, 80, 80, 81, 82, 82, 82, 82, 84,
-        87, 88, 88, 88, 91, 94, 95, 95, 95, 95, 96, 96, 96, 96, 96, 97, 98, 98,
-        98, 97, 81, 82, 83, 83, 83, 83, 83, 84, 84, 84, 84, 86, 88, 89, 89, 89,
-        91, 94, 95, 95, 95, 96, 96, 97, 97, 97, 98, 99, 100, 100, 100, 99, 83,
-        84, 84, 85, 85, 85, 85, 85, 85, 85, 85, 87, 89, 90, 90, 90, 92, 94, 95,
-        95, 95, 96, 97, 97, 97, 97, 99, 100, 101, 101, 101, 100, 83, 84, 84, 85,
-        85, 85, 85, 85, 85, 85, 85, 87, 89, 90, 90, 90, 92, 94, 95, 95, 95, 96,
-        97, 97, 97, 97, 99, 100, 101, 101, 101, 100, 83, 84, 84, 85, 85, 85, 85,
-        85, 85, 85, 85, 87, 89, 90, 90, 90, 92, 94, 95, 95, 95, 96, 97, 97, 97,
-        97, 99, 100, 101, 101, 101, 100, 89, 89, 89, 89, 89, 89, 88, 88, 88, 88,
-        88, 89, 91, 92, 92, 92, 93, 94, 95, 95, 95, 96, 98, 99, 99, 99, 100,
-        102, 103, 103, 103, 102, 95, 94, 93, 93, 93, 93, 92, 92, 91, 91, 91, 92,
-        93, 94, 94, 94, 94, 95, 95, 95, 95, 97, 99, 100, 100, 100, 102, 104,
-        105, 105, 105, 105, 98, 97, 96, 95, 95, 95, 94, 93, 93, 93, 93, 93, 94,
-        95, 95, 95, 95, 95, 96, 96, 96, 98, 100, 101, 101, 101, 103, 105, 106,
-        106, 106, 106, 98, 97, 96, 95, 95, 95, 94, 93, 93, 93, 93, 93, 94, 95,
-        95, 95, 95, 95, 96, 96, 96, 98, 100, 101, 101, 101, 103, 105, 106, 106,
-        106, 106, 98, 97, 96, 95, 95, 95, 94, 93, 93, 93, 93, 93, 94, 95, 95,
-        95, 95, 95, 96, 96, 96, 98, 100, 101, 101, 101, 103, 105, 106, 106, 106,
-        106, 98, 97, 95, 95, 95, 95, 94, 93, 92, 92, 92, 93, 93, 94, 94, 94, 94,
-        94, 95, 95, 95, 97, 99, 100, 100, 100, 102, 105, 106, 106, 106, 107,
+        32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 31, 33, 33, 33, 33, 34, 36,
+        36, 36, 36, 38, 40, 41, 41, 41, 44, 47, 49, 49, 49, 49, 31, 31, 31, 31,
+        31, 31, 31, 31, 30, 30, 30, 32, 33, 34, 34, 34, 35, 36, 37, 37, 37, 39,
+        41, 42, 42, 42, 44, 47, 48, 48, 48, 48, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 32, 33, 34, 34, 34, 36, 37, 38, 38, 38, 39, 41, 42, 42, 42,
+        44, 46, 48, 48, 48, 47, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
+        34, 34, 34, 34, 36, 37, 38, 38, 38, 40, 41, 42, 42, 42, 44, 46, 47, 47,
+        47, 47, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 34, 34, 34, 34,
+        36, 37, 38, 38, 38, 40, 41, 42, 42, 42, 44, 46, 47, 47, 47, 47, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 34, 34, 34, 34, 36, 37, 38, 38,
+        38, 40, 41, 42, 42, 42, 44, 46, 47, 47, 47, 47, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 33, 34, 35, 35, 35, 36, 38, 39, 39, 39, 40, 41, 42,
+        42, 42, 44, 46, 47, 47, 47, 47, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 33, 34, 35, 35, 35, 37, 38, 39, 39, 39, 41, 42, 42, 42, 42, 44, 46,
+        46, 46, 46, 46, 30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 35,
+        35, 35, 37, 39, 40, 40, 40, 41, 42, 42, 42, 42, 44, 45, 46, 46, 46, 46,
+        30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35, 37, 39,
+        40, 40, 40, 41, 42, 42, 42, 42, 44, 45, 46, 46, 46, 46, 30, 30, 31, 31,
+        31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35, 37, 39, 40, 40, 40, 41,
+        42, 42, 42, 42, 44, 45, 46, 46, 46, 46, 31, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 34, 36, 37, 37, 37, 38, 40, 41, 41, 41, 42, 43, 43, 43, 43,
+        44, 46, 46, 46, 46, 46, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 36,
+        37, 38, 38, 38, 40, 41, 42, 42, 42, 43, 44, 44, 44, 44, 45, 46, 47, 47,
+        47, 46, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 37, 38, 39, 39, 39,
+        40, 42, 43, 43, 43, 44, 44, 45, 45, 45, 46, 47, 47, 47, 47, 47, 33, 34,
+        34, 34, 34, 34, 35, 35, 35, 35, 35, 37, 38, 39, 39, 39, 40, 42, 43, 43,
+        43, 44, 44, 45, 45, 45, 46, 47, 47, 47, 47, 47, 33, 34, 34, 34, 34, 34,
+        35, 35, 35, 35, 35, 37, 38, 39, 39, 39, 40, 42, 43, 43, 43, 44, 44, 45,
+        45, 45, 46, 47, 47, 47, 47, 47, 34, 35, 36, 36, 36, 36, 36, 37, 37, 37,
+        37, 38, 40, 40, 40, 40, 42, 44, 45, 45, 45, 45, 45, 46, 46, 46, 46, 47,
+        47, 47, 47, 47, 36, 36, 37, 37, 37, 37, 38, 38, 39, 39, 39, 40, 41, 42,
+        42, 42, 44, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+        36, 37, 38, 38, 38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 43, 43, 45, 46,
+        47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 36, 37, 38, 38,
+        38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 43, 43, 45, 46, 47, 47, 47, 47,
+        47, 47, 47, 47, 47, 47, 48, 48, 48, 47, 36, 37, 38, 38, 38, 38, 39, 39,
+        40, 40, 40, 41, 42, 43, 43, 43, 45, 46, 47, 47, 47, 47, 47, 47, 47, 47,
+        47, 47, 48, 48, 48, 47, 38, 39, 39, 40, 40, 40, 40, 41, 41, 41, 41, 42,
+        43, 44, 44, 44, 45, 47, 47, 47, 47, 47, 48, 48, 48, 48, 48, 48, 49, 49,
+        49, 48, 40, 41, 41, 41, 41, 41, 41, 42, 42, 42, 42, 43, 44, 44, 44, 44,
+        45, 47, 47, 47, 47, 48, 48, 48, 48, 48, 49, 49, 50, 50, 50, 49, 41, 42,
+        42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 44, 45, 45, 45, 46, 47, 47, 47,
+        47, 48, 48, 48, 48, 48, 49, 50, 50, 50, 50, 50, 41, 42, 42, 42, 42, 42,
+        42, 42, 42, 42, 42, 43, 44, 45, 45, 45, 46, 47, 47, 47, 47, 48, 48, 48,
+        48, 48, 49, 50, 50, 50, 50, 50, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42,
+        42, 43, 44, 45, 45, 45, 46, 47, 47, 47, 47, 48, 48, 48, 48, 48, 49, 50,
+        50, 50, 50, 50, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 46,
+        46, 46, 46, 47, 47, 47, 47, 48, 49, 49, 49, 49, 50, 51, 51, 51, 51, 51,
+        47, 47, 46, 46, 46, 46, 46, 46, 45, 45, 45, 46, 46, 47, 47, 47, 47, 47,
+        47, 47, 47, 48, 49, 50, 50, 50, 51, 52, 52, 52, 52, 52, 49, 48, 48, 47,
+        47, 47, 47, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 48, 48, 49,
+        50, 50, 50, 50, 51, 52, 53, 53, 53, 53, 49, 48, 48, 47, 47, 47, 47, 46,
+        46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 48, 48, 48, 49, 50, 50, 50, 50,
+        51, 52, 53, 53, 53, 53, 49, 48, 48, 47, 47, 47, 47, 46, 46, 46, 46, 46,
+        47, 47, 47, 47, 47, 47, 48, 48, 48, 49, 50, 50, 50, 50, 51, 52, 53, 53,
+        53, 53, 49, 48, 47, 47, 47, 47, 47, 46, 46, 46, 46, 46, 46, 47, 47, 47,
+        47, 47, 47, 47, 47, 48, 49, 50, 50, 50, 51, 52, 53, 53, 53, 53,
         /* Size 4x8 */
-        63, 62, 75, 96, 63, 63, 77, 94, 62, 64, 80, 92, 69, 72, 86, 94, 75, 79,
-        93, 95, 79, 82, 95, 97, 85, 86, 95, 100, 96, 93, 96, 106,
+        31, 31, 37, 48, 31, 31, 38, 47, 31, 32, 40, 46, 34, 36, 43, 47, 37, 39,
+        46, 47, 39, 41, 47, 48, 42, 43, 47, 50, 48, 46, 48, 53,
         /* Size 8x4 */
-        63, 63, 62, 69, 75, 79, 85, 96, 62, 63, 64, 72, 79, 82, 86, 93, 75, 77,
-        80, 86, 93, 95, 95, 96, 96, 94, 92, 94, 95, 97, 100, 106,
+        31, 31, 31, 34, 37, 39, 42, 48, 31, 31, 32, 36, 39, 41, 43, 46, 37, 38,
+        40, 43, 46, 47, 47, 48, 48, 47, 46, 47, 47, 48, 50, 53,
         /* Size 8x16 */
-        64, 62, 62, 66, 74, 74, 91, 96, 63, 63, 63, 68, 76, 76, 90, 95, 63, 63,
-        63, 68, 77, 77, 90, 94, 62, 63, 64, 69, 78, 78, 90, 93, 61, 64, 64, 70,
-        80, 80, 89, 92, 61, 64, 64, 70, 80, 80, 89, 92, 66, 69, 70, 75, 85, 85,
-        92, 94, 67, 71, 72, 77, 86, 86, 92, 94, 70, 74, 75, 80, 89, 89, 93, 95,
-        74, 79, 80, 86, 94, 94, 95, 95, 74, 79, 80, 86, 94, 94, 95, 95, 82, 84,
-        85, 88, 95, 95, 98, 99, 84, 85, 86, 89, 95, 95, 99, 100, 89, 89, 89, 91,
-        95, 95, 101, 102, 98, 94, 93, 94, 96, 96, 104, 106, 98, 94, 93, 94, 96,
-        96, 104, 106,
+        32, 31, 31, 33, 37, 37, 45, 48, 31, 31, 31, 34, 38, 38, 45, 47, 31, 31,
+        31, 34, 38, 38, 45, 47, 31, 31, 32, 34, 39, 39, 45, 46, 30, 32, 32, 35,
+        40, 40, 44, 46, 30, 32, 32, 35, 40, 40, 44, 46, 33, 34, 35, 37, 42, 42,
+        46, 47, 33, 35, 36, 38, 43, 43, 46, 47, 35, 37, 37, 40, 44, 44, 46, 47,
+        37, 39, 40, 43, 47, 47, 47, 47, 37, 39, 40, 43, 47, 47, 47, 47, 41, 42,
+        42, 44, 47, 47, 49, 49, 42, 42, 43, 44, 47, 47, 49, 50, 44, 44, 44, 45,
+        47, 47, 50, 51, 49, 47, 46, 47, 48, 48, 52, 53, 49, 47, 46, 47, 48, 48,
+        52, 53,
         /* Size 16x8 */
-        64, 63, 63, 62, 61, 61, 66, 67, 70, 74, 74, 82, 84, 89, 98, 98, 62, 63,
-        63, 63, 64, 64, 69, 71, 74, 79, 79, 84, 85, 89, 94, 94, 62, 63, 63, 64,
-        64, 64, 70, 72, 75, 80, 80, 85, 86, 89, 93, 93, 66, 68, 68, 69, 70, 70,
-        75, 77, 80, 86, 86, 88, 89, 91, 94, 94, 74, 76, 77, 78, 80, 80, 85, 86,
-        89, 94, 94, 95, 95, 95, 96, 96, 74, 76, 77, 78, 80, 80, 85, 86, 89, 94,
-        94, 95, 95, 95, 96, 96, 91, 90, 90, 90, 89, 89, 92, 92, 93, 95, 95, 98,
-        99, 101, 104, 104, 96, 95, 94, 93, 92, 92, 94, 94, 95, 95, 95, 99, 100,
-        102, 106, 106,
+        32, 31, 31, 31, 30, 30, 33, 33, 35, 37, 37, 41, 42, 44, 49, 49, 31, 31,
+        31, 31, 32, 32, 34, 35, 37, 39, 39, 42, 42, 44, 47, 47, 31, 31, 31, 32,
+        32, 32, 35, 36, 37, 40, 40, 42, 43, 44, 46, 46, 33, 34, 34, 34, 35, 35,
+        37, 38, 40, 43, 43, 44, 44, 45, 47, 47, 37, 38, 38, 39, 40, 40, 42, 43,
+        44, 47, 47, 47, 47, 47, 48, 48, 37, 38, 38, 39, 40, 40, 42, 43, 44, 47,
+        47, 47, 47, 47, 48, 48, 45, 45, 45, 45, 44, 44, 46, 46, 46, 47, 47, 49,
+        49, 50, 52, 52, 48, 47, 47, 46, 46, 46, 47, 47, 47, 47, 47, 49, 50, 51,
+        53, 53,
         /* Size 16x32 */
-        64, 63, 62, 62, 62, 62, 66, 71, 74, 74, 74, 81, 91, 96, 96, 96, 63, 63,
-        62, 62, 62, 62, 67, 72, 75, 75, 75, 82, 91, 96, 96, 96, 63, 63, 63, 63,
-        63, 63, 68, 73, 76, 76, 76, 83, 90, 95, 95, 95, 63, 63, 63, 63, 63, 63,
-        68, 74, 77, 77, 77, 83, 90, 94, 94, 94, 63, 63, 63, 63, 63, 63, 68, 74,
-        77, 77, 77, 83, 90, 94, 94, 94, 63, 63, 63, 63, 63, 63, 68, 74, 77, 77,
-        77, 83, 90, 94, 94, 94, 62, 63, 63, 64, 64, 64, 69, 75, 78, 78, 78, 83,
-        90, 93, 93, 93, 61, 62, 63, 64, 64, 64, 69, 76, 79, 79, 79, 84, 89, 92,
-        92, 92, 61, 62, 64, 64, 64, 64, 70, 76, 80, 80, 80, 84, 89, 92, 92, 92,
-        61, 62, 64, 64, 64, 64, 70, 76, 80, 80, 80, 84, 89, 92, 92, 92, 61, 62,
-        64, 64, 64, 64, 70, 76, 80, 80, 80, 84, 89, 92, 92, 92, 63, 65, 66, 67,
-        67, 67, 72, 79, 82, 82, 82, 86, 90, 93, 93, 93, 66, 68, 69, 70, 70, 70,
-        75, 81, 85, 85, 85, 88, 92, 94, 94, 94, 67, 69, 71, 72, 72, 72, 77, 83,
-        86, 86, 86, 89, 92, 94, 94, 94, 67, 69, 71, 72, 72, 72, 77, 83, 86, 86,
-        86, 89, 92, 94, 94, 94, 67, 69, 71, 72, 72, 72, 77, 83, 86, 86, 86, 89,
-        92, 94, 94, 94, 70, 72, 74, 75, 75, 75, 80, 86, 89, 89, 89, 91, 93, 95,
-        95, 95, 73, 75, 77, 79, 79, 79, 84, 89, 93, 93, 93, 94, 95, 95, 95, 95,
-        74, 76, 79, 80, 80, 80, 86, 91, 94, 94, 94, 95, 95, 95, 95, 95, 74, 76,
-        79, 80, 80, 80, 86, 91, 94, 94, 94, 95, 95, 95, 95, 95, 74, 76, 79, 80,
-        80, 80, 86, 91, 94, 94, 94, 95, 95, 95, 95, 95, 78, 79, 81, 82, 82, 82,
-        87, 92, 95, 95, 95, 96, 97, 97, 97, 97, 82, 83, 84, 85, 85, 85, 88, 92,
-        95, 95, 95, 96, 98, 99, 99, 99, 84, 85, 85, 86, 86, 86, 89, 93, 95, 95,
-        95, 97, 99, 100, 100, 100, 84, 85, 85, 86, 86, 86, 89, 93, 95, 95, 95,
-        97, 99, 100, 100, 100, 84, 85, 85, 86, 86, 86, 89, 93, 95, 95, 95, 97,
-        99, 100, 100, 100, 89, 89, 89, 89, 89, 89, 91, 94, 95, 95, 95, 98, 101,
-        102, 102, 102, 95, 93, 92, 92, 92, 92, 93, 95, 96, 96, 96, 99, 103, 105,
-        105, 105, 98, 96, 94, 93, 93, 93, 94, 96, 96, 96, 96, 100, 104, 106,
-        106, 106, 98, 96, 94, 93, 93, 93, 94, 96, 96, 96, 96, 100, 104, 106,
-        106, 106, 98, 96, 94, 93, 93, 93, 94, 96, 96, 96, 96, 100, 104, 106,
-        106, 106, 98, 96, 94, 93, 93, 93, 94, 95, 95, 95, 95, 99, 104, 106, 106,
-        106,
+        32, 31, 31, 31, 31, 31, 33, 35, 37, 37, 37, 40, 45, 48, 48, 48, 31, 31,
+        31, 31, 31, 31, 33, 36, 37, 37, 37, 41, 45, 48, 48, 48, 31, 31, 31, 31,
+        31, 31, 34, 36, 38, 38, 38, 41, 45, 47, 47, 47, 31, 31, 31, 31, 31, 31,
+        34, 37, 38, 38, 38, 41, 45, 47, 47, 47, 31, 31, 31, 31, 31, 31, 34, 37,
+        38, 38, 38, 41, 45, 47, 47, 47, 31, 31, 31, 31, 31, 31, 34, 37, 38, 38,
+        38, 41, 45, 47, 47, 47, 31, 31, 31, 32, 32, 32, 34, 37, 39, 39, 39, 41,
+        45, 46, 46, 46, 30, 31, 31, 32, 32, 32, 34, 38, 39, 39, 39, 42, 44, 46,
+        46, 46, 30, 31, 32, 32, 32, 32, 35, 38, 40, 40, 40, 42, 44, 46, 46, 46,
+        30, 31, 32, 32, 32, 32, 35, 38, 40, 40, 40, 42, 44, 46, 46, 46, 30, 31,
+        32, 32, 32, 32, 35, 38, 40, 40, 40, 42, 44, 46, 46, 46, 31, 32, 33, 33,
+        33, 33, 36, 39, 41, 41, 41, 43, 45, 46, 46, 46, 33, 34, 34, 35, 35, 35,
+        37, 40, 42, 42, 42, 44, 46, 47, 47, 47, 33, 34, 35, 36, 36, 36, 38, 41,
+        43, 43, 43, 44, 46, 47, 47, 47, 33, 34, 35, 36, 36, 36, 38, 41, 43, 43,
+        43, 44, 46, 47, 47, 47, 33, 34, 35, 36, 36, 36, 38, 41, 43, 43, 43, 44,
+        46, 47, 47, 47, 35, 36, 37, 37, 37, 37, 40, 43, 44, 44, 44, 45, 46, 47,
+        47, 47, 36, 37, 38, 39, 39, 39, 42, 44, 46, 46, 46, 47, 47, 47, 47, 47,
+        37, 38, 39, 40, 40, 40, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 37, 38,
+        39, 40, 40, 40, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 37, 38, 39, 40,
+        40, 40, 43, 45, 47, 47, 47, 47, 47, 47, 47, 47, 39, 39, 40, 41, 41, 41,
+        43, 46, 47, 47, 47, 48, 48, 48, 48, 48, 41, 41, 42, 42, 42, 42, 44, 46,
+        47, 47, 47, 48, 49, 49, 49, 49, 42, 42, 42, 43, 43, 43, 44, 46, 47, 47,
+        47, 48, 49, 50, 50, 50, 42, 42, 42, 43, 43, 43, 44, 46, 47, 47, 47, 48,
+        49, 50, 50, 50, 42, 42, 42, 43, 43, 43, 44, 46, 47, 47, 47, 48, 49, 50,
+        50, 50, 44, 44, 44, 44, 44, 44, 45, 47, 47, 47, 47, 49, 50, 51, 51, 51,
+        47, 46, 46, 46, 46, 46, 46, 47, 48, 48, 48, 49, 51, 52, 52, 52, 49, 48,
+        47, 46, 46, 46, 47, 48, 48, 48, 48, 50, 52, 53, 53, 53, 49, 48, 47, 46,
+        46, 46, 47, 48, 48, 48, 48, 50, 52, 53, 53, 53, 49, 48, 47, 46, 46, 46,
+        47, 48, 48, 48, 48, 50, 52, 53, 53, 53, 49, 48, 47, 46, 46, 46, 47, 47,
+        47, 47, 47, 49, 52, 53, 53, 53,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 62, 61, 61, 61, 61, 63, 66, 67, 67, 67, 70, 73,
-        74, 74, 74, 78, 82, 84, 84, 84, 89, 95, 98, 98, 98, 98, 63, 63, 63, 63,
-        63, 63, 63, 62, 62, 62, 62, 65, 68, 69, 69, 69, 72, 75, 76, 76, 76, 79,
-        83, 85, 85, 85, 89, 93, 96, 96, 96, 96, 62, 62, 63, 63, 63, 63, 63, 63,
-        64, 64, 64, 66, 69, 71, 71, 71, 74, 77, 79, 79, 79, 81, 84, 85, 85, 85,
-        89, 92, 94, 94, 94, 94, 62, 62, 63, 63, 63, 63, 64, 64, 64, 64, 64, 67,
-        70, 72, 72, 72, 75, 79, 80, 80, 80, 82, 85, 86, 86, 86, 89, 92, 93, 93,
-        93, 93, 62, 62, 63, 63, 63, 63, 64, 64, 64, 64, 64, 67, 70, 72, 72, 72,
-        75, 79, 80, 80, 80, 82, 85, 86, 86, 86, 89, 92, 93, 93, 93, 93, 62, 62,
-        63, 63, 63, 63, 64, 64, 64, 64, 64, 67, 70, 72, 72, 72, 75, 79, 80, 80,
-        80, 82, 85, 86, 86, 86, 89, 92, 93, 93, 93, 93, 66, 67, 68, 68, 68, 68,
-        69, 69, 70, 70, 70, 72, 75, 77, 77, 77, 80, 84, 86, 86, 86, 87, 88, 89,
-        89, 89, 91, 93, 94, 94, 94, 94, 71, 72, 73, 74, 74, 74, 75, 76, 76, 76,
-        76, 79, 81, 83, 83, 83, 86, 89, 91, 91, 91, 92, 92, 93, 93, 93, 94, 95,
-        96, 96, 96, 95, 74, 75, 76, 77, 77, 77, 78, 79, 80, 80, 80, 82, 85, 86,
-        86, 86, 89, 93, 94, 94, 94, 95, 95, 95, 95, 95, 95, 96, 96, 96, 96, 95,
-        74, 75, 76, 77, 77, 77, 78, 79, 80, 80, 80, 82, 85, 86, 86, 86, 89, 93,
-        94, 94, 94, 95, 95, 95, 95, 95, 95, 96, 96, 96, 96, 95, 74, 75, 76, 77,
-        77, 77, 78, 79, 80, 80, 80, 82, 85, 86, 86, 86, 89, 93, 94, 94, 94, 95,
-        95, 95, 95, 95, 95, 96, 96, 96, 96, 95, 81, 82, 83, 83, 83, 83, 83, 84,
-        84, 84, 84, 86, 88, 89, 89, 89, 91, 94, 95, 95, 95, 96, 96, 97, 97, 97,
-        98, 99, 100, 100, 100, 99, 91, 91, 90, 90, 90, 90, 90, 89, 89, 89, 89,
-        90, 92, 92, 92, 92, 93, 95, 95, 95, 95, 97, 98, 99, 99, 99, 101, 103,
-        104, 104, 104, 104, 96, 96, 95, 94, 94, 94, 93, 92, 92, 92, 92, 93, 94,
-        94, 94, 94, 95, 95, 95, 95, 95, 97, 99, 100, 100, 100, 102, 105, 106,
-        106, 106, 106, 96, 96, 95, 94, 94, 94, 93, 92, 92, 92, 92, 93, 94, 94,
-        94, 94, 95, 95, 95, 95, 95, 97, 99, 100, 100, 100, 102, 105, 106, 106,
-        106, 106, 96, 96, 95, 94, 94, 94, 93, 92, 92, 92, 92, 93, 94, 94, 94,
-        94, 95, 95, 95, 95, 95, 97, 99, 100, 100, 100, 102, 105, 106, 106, 106,
-        106,
+        32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 31, 33, 33, 33, 33, 35, 36,
+        37, 37, 37, 39, 41, 42, 42, 42, 44, 47, 49, 49, 49, 49, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 34, 34, 34, 34, 36, 37, 38, 38, 38, 39,
+        41, 42, 42, 42, 44, 46, 48, 48, 48, 48, 31, 31, 31, 31, 31, 31, 31, 31,
+        32, 32, 32, 33, 34, 35, 35, 35, 37, 38, 39, 39, 39, 40, 42, 42, 42, 42,
+        44, 46, 47, 47, 47, 47, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 33,
+        35, 36, 36, 36, 37, 39, 40, 40, 40, 41, 42, 43, 43, 43, 44, 46, 46, 46,
+        46, 46, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 35, 36, 36, 36,
+        37, 39, 40, 40, 40, 41, 42, 43, 43, 43, 44, 46, 46, 46, 46, 46, 31, 31,
+        31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 35, 36, 36, 36, 37, 39, 40, 40,
+        40, 41, 42, 43, 43, 43, 44, 46, 46, 46, 46, 46, 33, 33, 34, 34, 34, 34,
+        34, 34, 35, 35, 35, 36, 37, 38, 38, 38, 40, 42, 43, 43, 43, 43, 44, 44,
+        44, 44, 45, 46, 47, 47, 47, 47, 35, 36, 36, 37, 37, 37, 37, 38, 38, 38,
+        38, 39, 40, 41, 41, 41, 43, 44, 45, 45, 45, 46, 46, 46, 46, 46, 47, 47,
+        48, 48, 48, 47, 37, 37, 38, 38, 38, 38, 39, 39, 40, 40, 40, 41, 42, 43,
+        43, 43, 44, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 48, 47,
+        37, 37, 38, 38, 38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 43, 43, 44, 46,
+        47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 48, 47, 37, 37, 38, 38,
+        38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 43, 43, 44, 46, 47, 47, 47, 47,
+        47, 47, 47, 47, 47, 48, 48, 48, 48, 47, 40, 41, 41, 41, 41, 41, 41, 42,
+        42, 42, 42, 43, 44, 44, 44, 44, 45, 47, 47, 47, 47, 48, 48, 48, 48, 48,
+        49, 49, 50, 50, 50, 49, 45, 45, 45, 45, 45, 45, 45, 44, 44, 44, 44, 45,
+        46, 46, 46, 46, 46, 47, 47, 47, 47, 48, 49, 49, 49, 49, 50, 51, 52, 52,
+        52, 52, 48, 48, 47, 47, 47, 47, 46, 46, 46, 46, 46, 46, 47, 47, 47, 47,
+        47, 47, 47, 47, 47, 48, 49, 50, 50, 50, 51, 52, 53, 53, 53, 53, 48, 48,
+        47, 47, 47, 47, 46, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47,
+        47, 48, 49, 50, 50, 50, 51, 52, 53, 53, 53, 53, 48, 48, 47, 47, 47, 47,
+        46, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 49, 50,
+        50, 50, 51, 52, 53, 53, 53, 53,
         /* Size 4x16 */
-        63, 62, 74, 96, 63, 63, 76, 95, 63, 63, 77, 94, 63, 64, 78, 93, 62, 64,
-        80, 92, 62, 64, 80, 92, 68, 70, 85, 94, 69, 72, 86, 94, 72, 75, 89, 95,
-        76, 80, 94, 95, 76, 80, 94, 95, 83, 85, 95, 99, 85, 86, 95, 100, 89, 89,
-        95, 102, 96, 93, 96, 106, 96, 93, 96, 106,
+        31, 31, 37, 48, 31, 31, 38, 47, 31, 31, 38, 47, 31, 32, 39, 46, 31, 32,
+        40, 46, 31, 32, 40, 46, 34, 35, 42, 47, 34, 36, 43, 47, 36, 37, 44, 47,
+        38, 40, 47, 47, 38, 40, 47, 47, 41, 42, 47, 49, 42, 43, 47, 50, 44, 44,
+        47, 51, 48, 46, 48, 53, 48, 46, 48, 53,
         /* Size 16x4 */
-        63, 63, 63, 63, 62, 62, 68, 69, 72, 76, 76, 83, 85, 89, 96, 96, 62, 63,
-        63, 64, 64, 64, 70, 72, 75, 80, 80, 85, 86, 89, 93, 93, 74, 76, 77, 78,
-        80, 80, 85, 86, 89, 94, 94, 95, 95, 95, 96, 96, 96, 95, 94, 93, 92, 92,
-        94, 94, 95, 95, 95, 99, 100, 102, 106, 106,
+        31, 31, 31, 31, 31, 31, 34, 34, 36, 38, 38, 41, 42, 44, 48, 48, 31, 31,
+        31, 32, 32, 32, 35, 36, 37, 40, 40, 42, 43, 44, 46, 46, 37, 38, 38, 39,
+        40, 40, 42, 43, 44, 47, 47, 47, 47, 47, 48, 48, 48, 47, 47, 46, 46, 46,
+        47, 47, 47, 47, 47, 49, 50, 51, 53, 53,
         /* Size 8x32 */
-        64, 62, 62, 66, 74, 74, 91, 96, 63, 62, 62, 67, 75, 75, 91, 96, 63, 63,
-        63, 68, 76, 76, 90, 95, 63, 63, 63, 68, 77, 77, 90, 94, 63, 63, 63, 68,
-        77, 77, 90, 94, 63, 63, 63, 68, 77, 77, 90, 94, 62, 63, 64, 69, 78, 78,
-        90, 93, 61, 63, 64, 69, 79, 79, 89, 92, 61, 64, 64, 70, 80, 80, 89, 92,
-        61, 64, 64, 70, 80, 80, 89, 92, 61, 64, 64, 70, 80, 80, 89, 92, 63, 66,
-        67, 72, 82, 82, 90, 93, 66, 69, 70, 75, 85, 85, 92, 94, 67, 71, 72, 77,
-        86, 86, 92, 94, 67, 71, 72, 77, 86, 86, 92, 94, 67, 71, 72, 77, 86, 86,
-        92, 94, 70, 74, 75, 80, 89, 89, 93, 95, 73, 77, 79, 84, 93, 93, 95, 95,
-        74, 79, 80, 86, 94, 94, 95, 95, 74, 79, 80, 86, 94, 94, 95, 95, 74, 79,
-        80, 86, 94, 94, 95, 95, 78, 81, 82, 87, 95, 95, 97, 97, 82, 84, 85, 88,
-        95, 95, 98, 99, 84, 85, 86, 89, 95, 95, 99, 100, 84, 85, 86, 89, 95, 95,
-        99, 100, 84, 85, 86, 89, 95, 95, 99, 100, 89, 89, 89, 91, 95, 95, 101,
-        102, 95, 92, 92, 93, 96, 96, 103, 105, 98, 94, 93, 94, 96, 96, 104, 106,
-        98, 94, 93, 94, 96, 96, 104, 106, 98, 94, 93, 94, 96, 96, 104, 106, 98,
-        94, 93, 94, 95, 95, 104, 106,
+        32, 31, 31, 33, 37, 37, 45, 48, 31, 31, 31, 33, 37, 37, 45, 48, 31, 31,
+        31, 34, 38, 38, 45, 47, 31, 31, 31, 34, 38, 38, 45, 47, 31, 31, 31, 34,
+        38, 38, 45, 47, 31, 31, 31, 34, 38, 38, 45, 47, 31, 31, 32, 34, 39, 39,
+        45, 46, 30, 31, 32, 34, 39, 39, 44, 46, 30, 32, 32, 35, 40, 40, 44, 46,
+        30, 32, 32, 35, 40, 40, 44, 46, 30, 32, 32, 35, 40, 40, 44, 46, 31, 33,
+        33, 36, 41, 41, 45, 46, 33, 34, 35, 37, 42, 42, 46, 47, 33, 35, 36, 38,
+        43, 43, 46, 47, 33, 35, 36, 38, 43, 43, 46, 47, 33, 35, 36, 38, 43, 43,
+        46, 47, 35, 37, 37, 40, 44, 44, 46, 47, 36, 38, 39, 42, 46, 46, 47, 47,
+        37, 39, 40, 43, 47, 47, 47, 47, 37, 39, 40, 43, 47, 47, 47, 47, 37, 39,
+        40, 43, 47, 47, 47, 47, 39, 40, 41, 43, 47, 47, 48, 48, 41, 42, 42, 44,
+        47, 47, 49, 49, 42, 42, 43, 44, 47, 47, 49, 50, 42, 42, 43, 44, 47, 47,
+        49, 50, 42, 42, 43, 44, 47, 47, 49, 50, 44, 44, 44, 45, 47, 47, 50, 51,
+        47, 46, 46, 46, 48, 48, 51, 52, 49, 47, 46, 47, 48, 48, 52, 53, 49, 47,
+        46, 47, 48, 48, 52, 53, 49, 47, 46, 47, 48, 48, 52, 53, 49, 47, 46, 47,
+        47, 47, 52, 53,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 62, 61, 61, 61, 61, 63, 66, 67, 67, 67, 70, 73,
-        74, 74, 74, 78, 82, 84, 84, 84, 89, 95, 98, 98, 98, 98, 62, 62, 63, 63,
-        63, 63, 63, 63, 64, 64, 64, 66, 69, 71, 71, 71, 74, 77, 79, 79, 79, 81,
-        84, 85, 85, 85, 89, 92, 94, 94, 94, 94, 62, 62, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 67, 70, 72, 72, 72, 75, 79, 80, 80, 80, 82, 85, 86, 86, 86,
-        89, 92, 93, 93, 93, 93, 66, 67, 68, 68, 68, 68, 69, 69, 70, 70, 70, 72,
-        75, 77, 77, 77, 80, 84, 86, 86, 86, 87, 88, 89, 89, 89, 91, 93, 94, 94,
-        94, 94, 74, 75, 76, 77, 77, 77, 78, 79, 80, 80, 80, 82, 85, 86, 86, 86,
-        89, 93, 94, 94, 94, 95, 95, 95, 95, 95, 95, 96, 96, 96, 96, 95, 74, 75,
-        76, 77, 77, 77, 78, 79, 80, 80, 80, 82, 85, 86, 86, 86, 89, 93, 94, 94,
-        94, 95, 95, 95, 95, 95, 95, 96, 96, 96, 96, 95, 91, 91, 90, 90, 90, 90,
-        90, 89, 89, 89, 89, 90, 92, 92, 92, 92, 93, 95, 95, 95, 95, 97, 98, 99,
-        99, 99, 101, 103, 104, 104, 104, 104, 96, 96, 95, 94, 94, 94, 93, 92,
-        92, 92, 92, 93, 94, 94, 94, 94, 95, 95, 95, 95, 95, 97, 99, 100, 100,
-        100, 102, 105, 106, 106, 106, 106 },
+        32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 31, 33, 33, 33, 33, 35, 36,
+        37, 37, 37, 39, 41, 42, 42, 42, 44, 47, 49, 49, 49, 49, 31, 31, 31, 31,
+        31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35, 37, 38, 39, 39, 39, 40,
+        42, 42, 42, 42, 44, 46, 47, 47, 47, 47, 31, 31, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 33, 35, 36, 36, 36, 37, 39, 40, 40, 40, 41, 42, 43, 43, 43,
+        44, 46, 46, 46, 46, 46, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 36,
+        37, 38, 38, 38, 40, 42, 43, 43, 43, 43, 44, 44, 44, 44, 45, 46, 47, 47,
+        47, 47, 37, 37, 38, 38, 38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 43, 43,
+        44, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 48, 47, 37, 37,
+        38, 38, 38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 43, 43, 44, 46, 47, 47,
+        47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 48, 47, 45, 45, 45, 45, 45, 45,
+        45, 44, 44, 44, 44, 45, 46, 46, 46, 46, 46, 47, 47, 47, 47, 48, 49, 49,
+        49, 49, 50, 51, 52, 52, 52, 52, 48, 48, 47, 47, 47, 47, 46, 46, 46, 46,
+        46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 49, 50, 50, 50, 51, 52,
+        53, 53, 53, 53 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        64, 65, 65, 70,
+        32, 32, 32, 35,
 #endif
         /* Size 4x4 */
-        63, 64, 64, 65, 64, 65, 65, 66, 64, 65, 67, 68, 65, 66, 68, 71,
+        31, 32, 32, 32, 32, 32, 32, 33, 32, 32, 33, 34, 32, 33, 34, 35,
         /* Size 8x8 */
-        63, 63, 63, 63, 64, 64, 64, 67, 63, 64, 64, 64, 64, 64, 65, 67, 63, 64,
-        64, 64, 65, 65, 65, 67, 63, 64, 64, 65, 65, 65, 65, 67, 64, 64, 65, 65,
-        67, 67, 68, 70, 64, 64, 65, 65, 67, 68, 69, 71, 64, 65, 65, 65, 68, 69,
-        71, 73, 67, 67, 67, 67, 70, 71, 73, 76,
+        31, 31, 31, 31, 32, 32, 32, 33, 31, 32, 32, 32, 32, 32, 32, 33, 31, 32,
+        32, 32, 32, 32, 32, 33, 31, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32,
+        33, 33, 34, 35, 32, 32, 32, 32, 33, 34, 34, 35, 32, 32, 32, 32, 34, 34,
+        35, 36, 33, 33, 33, 33, 35, 35, 36, 38,
         /* Size 16x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 65, 68, 63, 63,
-        63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 66, 68, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 66, 68, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 65, 65, 65, 66, 68, 63, 63, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 65, 66, 68, 63, 63, 64, 64, 64, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 66, 67, 63, 63, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 66, 67, 63, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 66, 66, 66,
-        67, 68, 63, 64, 64, 64, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67, 68, 70,
-        63, 64, 64, 64, 65, 65, 65, 65, 66, 67, 67, 67, 68, 68, 69, 71, 63, 64,
-        64, 64, 65, 65, 65, 65, 66, 67, 67, 67, 68, 68, 69, 71, 64, 64, 65, 65,
-        65, 65, 65, 66, 67, 67, 67, 69, 70, 70, 71, 72, 64, 64, 65, 65, 65, 65,
-        65, 66, 67, 68, 68, 70, 71, 71, 72, 74, 64, 64, 65, 65, 65, 65, 65, 66,
-        67, 68, 68, 70, 71, 71, 72, 74, 65, 66, 66, 66, 66, 66, 66, 67, 68, 69,
-        69, 71, 72, 72, 73, 76, 68, 68, 68, 68, 68, 67, 67, 68, 70, 71, 71, 72,
-        74, 74, 76, 79,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 34, 31, 31,
+        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
+        33, 34, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 35,
+        31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35, 31, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 33, 33, 34, 35, 35, 35, 36, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 34, 34, 35, 35, 35, 36, 37, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 34, 34, 35, 35, 35, 36, 37, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34,
+        34, 35, 36, 36, 36, 38, 34, 34, 34, 34, 34, 33, 33, 34, 35, 35, 35, 36,
+        37, 37, 38, 39,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 65, 66, 68, 68, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 67, 68, 68, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 65, 66, 67, 68, 68, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66, 67,
-        68, 68, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 66, 67, 68, 68, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 66, 67, 68, 68, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 66, 67, 68, 68, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65,
-        66, 67, 68, 68, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 68, 68,
-        63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 67, 67, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 67, 67, 67, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 66, 66, 67, 67, 67, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 67,
-        67, 67, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 67, 67, 67, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 66, 66, 66, 66, 66, 66, 66, 67, 67, 68, 68, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 67,
-        67, 67, 67, 67, 68, 68, 69, 69, 63, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 68,
-        68, 69, 70, 70, 63, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 66, 66, 67, 67, 67, 67, 67, 67, 68, 68, 68, 68, 68, 69, 70, 71, 71,
-        63, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 66, 66, 67,
-        67, 67, 67, 67, 67, 68, 68, 68, 68, 68, 69, 70, 71, 71, 63, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 66, 66, 67, 67, 67, 67, 67,
-        67, 68, 68, 68, 68, 68, 69, 70, 71, 71, 63, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 65, 65, 66, 66, 67, 67, 67, 67, 67, 67, 68, 68, 68,
-        68, 68, 69, 70, 71, 71, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65,
-        65, 65, 66, 66, 67, 67, 67, 67, 67, 68, 68, 69, 69, 69, 69, 69, 70, 71,
-        71, 71, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66,
-        67, 67, 67, 67, 67, 68, 69, 69, 70, 70, 70, 70, 71, 71, 72, 72, 64, 64,
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 67, 68, 68, 68,
-        68, 69, 69, 70, 70, 70, 70, 71, 71, 72, 73, 73, 64, 64, 64, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 67, 68, 68, 68, 68, 69, 70, 70,
-        71, 71, 71, 71, 72, 73, 74, 74, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 66, 67, 67, 68, 68, 68, 68, 69, 70, 70, 71, 71, 71, 71,
-        72, 73, 74, 74, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        66, 67, 67, 68, 68, 68, 68, 69, 70, 70, 71, 71, 71, 71, 72, 73, 74, 74,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 68, 68,
-        68, 68, 68, 69, 70, 71, 71, 71, 71, 71, 72, 73, 74, 74, 65, 65, 66, 66,
-        66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 67, 68, 68, 69, 69, 69, 69, 70,
-        71, 71, 72, 72, 72, 72, 73, 74, 76, 76, 66, 67, 67, 67, 67, 67, 67, 67,
-        67, 67, 67, 67, 67, 67, 67, 68, 69, 70, 70, 70, 70, 71, 71, 72, 73, 73,
-        73, 73, 74, 76, 77, 77, 68, 68, 68, 68, 68, 68, 68, 68, 68, 67, 67, 67,
-        67, 67, 68, 69, 70, 71, 71, 71, 71, 71, 72, 73, 74, 74, 74, 74, 76, 77,
-        79, 79, 68, 68, 68, 68, 68, 68, 68, 68, 68, 67, 67, 67, 67, 67, 68, 69,
-        70, 71, 71, 71, 71, 71, 72, 73, 74, 74, 74, 74, 76, 77, 79, 79,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 34, 34, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        34, 34, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 34, 34, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 34, 34, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34,
+        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 33, 33, 33, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
+        33, 33, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 34, 34, 34, 34, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34,
+        34, 34, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
+        33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33,
+        33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34,
+        34, 34, 34, 35, 35, 35, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 35, 35,
+        35, 35, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 33, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34,
+        34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 36, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35,
+        35, 35, 35, 35, 36, 36, 37, 37, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35,
+        36, 36, 37, 37, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 37, 37,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34,
+        34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 37, 37, 32, 32, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35,
+        35, 35, 36, 36, 36, 36, 36, 37, 38, 38, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 36,
+        36, 36, 37, 38, 38, 38, 34, 34, 34, 34, 34, 34, 34, 34, 34, 33, 33, 33,
+        33, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 37, 37, 37, 37, 38, 38,
+        39, 39, 34, 34, 34, 34, 34, 34, 34, 34, 34, 33, 33, 33, 33, 33, 34, 34,
+        35, 35, 35, 35, 35, 35, 36, 36, 37, 37, 37, 37, 38, 38, 39, 39,
         /* Size 4x8 */
-        63, 63, 64, 64, 63, 64, 65, 65, 64, 64, 65, 65, 64, 65, 65, 66, 64, 65,
-        67, 68, 64, 65, 68, 69, 64, 66, 69, 71, 67, 67, 71, 73,
+        31, 31, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32,
+        33, 34, 32, 32, 34, 34, 32, 33, 34, 35, 33, 33, 35, 36,
         /* Size 8x4 */
-        63, 63, 64, 64, 64, 64, 64, 67, 63, 64, 64, 65, 65, 65, 66, 67, 64, 65,
-        65, 65, 67, 68, 69, 71, 64, 65, 65, 66, 68, 69, 71, 73,
+        31, 31, 32, 32, 32, 32, 32, 33, 31, 32, 32, 32, 32, 32, 33, 33, 32, 32,
+        32, 32, 33, 34, 34, 35, 32, 32, 32, 33, 34, 34, 35, 36,
         /* Size 8x16 */
-        64, 63, 63, 63, 63, 64, 64, 65, 63, 63, 64, 64, 64, 65, 65, 66, 63, 64,
-        64, 64, 64, 65, 65, 66, 63, 64, 64, 64, 64, 65, 65, 66, 63, 64, 64, 64,
-        65, 65, 65, 66, 63, 64, 65, 65, 65, 66, 66, 66, 63, 64, 65, 65, 65, 66,
-        66, 66, 63, 64, 65, 65, 65, 66, 66, 67, 63, 64, 65, 65, 66, 68, 68, 69,
-        64, 65, 65, 65, 66, 68, 68, 69, 64, 65, 65, 65, 66, 68, 68, 69, 64, 65,
-        65, 65, 67, 70, 70, 71, 64, 65, 66, 66, 68, 71, 71, 72, 64, 65, 66, 66,
-        68, 71, 71, 72, 65, 66, 66, 66, 69, 72, 72, 73, 68, 68, 68, 68, 70, 74,
-        74, 76,
+        32, 31, 31, 31, 31, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 33, 31, 32,
+        32, 32, 32, 32, 32, 33, 31, 32, 32, 32, 32, 32, 32, 33, 31, 32, 32, 32,
+        32, 32, 32, 33, 31, 32, 32, 32, 32, 33, 33, 33, 31, 32, 32, 32, 32, 33,
+        33, 33, 31, 32, 32, 32, 32, 33, 33, 33, 31, 32, 32, 32, 33, 34, 34, 34,
+        32, 32, 32, 32, 33, 34, 34, 34, 32, 32, 32, 32, 33, 34, 34, 34, 32, 32,
+        32, 32, 33, 35, 35, 35, 32, 32, 33, 33, 34, 35, 35, 36, 32, 32, 33, 33,
+        34, 35, 35, 36, 32, 33, 33, 33, 34, 36, 36, 36, 34, 34, 34, 34, 35, 37,
+        37, 38,
         /* Size 16x8 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 65, 68, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66, 68, 63, 64, 64, 64,
-        64, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 68, 63, 64, 64, 64, 64, 65,
-        65, 65, 65, 65, 65, 65, 66, 66, 66, 68, 63, 64, 64, 64, 65, 65, 65, 65,
-        66, 66, 66, 67, 68, 68, 69, 70, 64, 65, 65, 65, 65, 66, 66, 66, 68, 68,
-        68, 70, 71, 71, 72, 74, 64, 65, 65, 65, 65, 66, 66, 66, 68, 68, 68, 70,
-        71, 71, 72, 74, 65, 66, 66, 66, 66, 66, 66, 67, 69, 69, 69, 71, 72, 72,
-        73, 76,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 34, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 31, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 34, 34, 34, 35, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34,
+        34, 35, 35, 35, 36, 37, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35,
+        35, 35, 36, 37, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 35, 36, 36,
+        36, 38,
         /* Size 16x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 65, 68, 63, 63,
-        63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 66, 68, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 66, 68, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 65, 65, 65, 65, 65, 66, 68, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 65, 65, 65, 65, 65, 66, 68, 63, 63, 64, 64, 64, 64, 64, 64, 64, 65,
-        65, 65, 65, 65, 66, 68, 63, 63, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65,
-        65, 65, 66, 68, 63, 63, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65,
-        66, 68, 63, 63, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 66, 68,
-        63, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 66, 67, 63, 64,
-        64, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 63, 64, 64, 65,
-        65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 63, 64, 64, 65, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 63, 64, 64, 65, 65, 65, 65, 65,
-        65, 65, 66, 66, 66, 66, 66, 67, 63, 64, 64, 65, 65, 65, 65, 65, 65, 66,
-        66, 66, 66, 66, 67, 68, 63, 64, 64, 65, 65, 65, 65, 65, 66, 66, 67, 67,
-        67, 67, 68, 69, 63, 64, 64, 65, 65, 65, 65, 65, 66, 67, 68, 68, 68, 68,
-        69, 70, 64, 64, 65, 65, 65, 65, 65, 66, 66, 67, 68, 68, 68, 68, 69, 71,
-        64, 64, 65, 65, 65, 65, 65, 66, 66, 67, 68, 68, 68, 68, 69, 71, 64, 64,
-        65, 65, 65, 65, 65, 66, 66, 67, 68, 68, 68, 68, 69, 71, 64, 64, 65, 65,
-        65, 65, 65, 66, 66, 67, 68, 68, 68, 68, 69, 71, 64, 64, 65, 65, 65, 65,
-        65, 66, 67, 68, 69, 69, 69, 69, 70, 71, 64, 64, 65, 65, 65, 65, 65, 66,
-        67, 68, 70, 70, 70, 70, 71, 72, 64, 64, 65, 65, 66, 66, 66, 66, 67, 69,
-        70, 70, 70, 70, 72, 73, 64, 64, 65, 65, 66, 66, 66, 66, 68, 69, 71, 71,
-        71, 71, 72, 74, 64, 64, 65, 65, 66, 66, 66, 66, 68, 69, 71, 71, 71, 71,
-        72, 74, 64, 64, 65, 65, 66, 66, 66, 66, 68, 69, 71, 71, 71, 71, 72, 74,
-        64, 65, 65, 66, 66, 66, 66, 66, 68, 69, 71, 71, 71, 71, 72, 74, 65, 66,
-        66, 66, 66, 66, 66, 67, 69, 70, 72, 72, 72, 72, 73, 76, 67, 67, 67, 67,
-        67, 67, 67, 68, 69, 71, 73, 73, 73, 73, 75, 77, 68, 68, 68, 68, 68, 68,
-        68, 68, 70, 72, 74, 74, 74, 74, 76, 79, 68, 68, 68, 68, 68, 68, 68, 68,
-        70, 72, 74, 74, 74, 74, 76, 79,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 34, 31, 31,
+        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 33, 33, 33, 33, 34, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 33, 34, 34, 31, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 34, 34,
+        34, 35, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 35,
+        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 35, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 35, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 34, 35, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 34, 34, 34, 34, 34, 35, 35, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 34, 35, 35, 35, 35, 35, 36, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34,
+        35, 35, 35, 35, 36, 36, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 35, 35,
+        35, 35, 36, 37, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35,
+        36, 37, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35, 36, 37,
+        32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35, 36, 37, 32, 33,
+        33, 33, 33, 33, 33, 33, 34, 35, 36, 36, 36, 36, 36, 38, 33, 33, 33, 33,
+        33, 33, 33, 34, 34, 35, 36, 36, 36, 36, 37, 38, 34, 34, 34, 34, 34, 34,
+        34, 34, 35, 36, 37, 37, 37, 37, 38, 39, 34, 34, 34, 34, 34, 34, 34, 34,
+        35, 36, 37, 37, 37, 37, 38, 39,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 67, 68, 68, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 65, 66, 67, 68, 68, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 66, 67, 68, 68, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 67,
-        68, 68, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 67, 68, 68, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 66, 66, 66, 66, 66, 67, 68, 68, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66,
-        66, 66, 66, 66, 66, 67, 68, 68, 63, 63, 64, 64, 64, 64, 64, 64, 64, 65,
-        65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
-        67, 68, 68, 68, 63, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 66, 66, 66, 66, 66, 66, 67, 67, 67, 68, 68, 68, 68, 69, 69, 70, 70,
-        64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 67, 67,
-        67, 67, 67, 68, 68, 69, 69, 69, 69, 69, 70, 71, 72, 72, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 68, 68, 68, 68, 68, 69,
-        70, 70, 71, 71, 71, 71, 72, 73, 74, 74, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 65, 66, 66, 66, 66, 66, 67, 68, 68, 68, 68, 68, 69, 70, 70, 71, 71,
-        71, 71, 72, 73, 74, 74, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66,
-        66, 66, 66, 67, 68, 68, 68, 68, 68, 69, 70, 70, 71, 71, 71, 71, 72, 73,
-        74, 74, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 67,
-        68, 68, 68, 68, 68, 69, 70, 70, 71, 71, 71, 71, 72, 73, 74, 74, 65, 66,
-        66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 67, 68, 69, 69, 69, 69,
-        69, 70, 71, 72, 72, 72, 72, 72, 73, 75, 76, 76, 68, 68, 68, 68, 68, 68,
-        68, 68, 68, 67, 67, 67, 67, 67, 68, 69, 70, 71, 71, 71, 71, 71, 72, 73,
-        74, 74, 74, 74, 76, 77, 79, 79,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 34, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
+        34, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 34, 34, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 33, 33, 33, 33, 33, 34, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 34, 34, 34, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 35, 35, 36, 36, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34,
+        35, 35, 35, 35, 35, 35, 36, 36, 37, 37, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35,
+        35, 35, 36, 36, 37, 37, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36,
+        37, 37, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
+        34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 37, 37, 32, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34,
+        34, 35, 35, 36, 36, 36, 36, 36, 36, 37, 38, 38, 34, 34, 34, 34, 34, 34,
+        34, 34, 34, 33, 33, 33, 33, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36,
+        37, 37, 37, 37, 38, 38, 39, 39,
         /* Size 4x16 */
-        63, 63, 64, 64, 63, 64, 64, 65, 63, 64, 65, 65, 63, 64, 65, 65, 63, 64,
-        65, 65, 64, 65, 65, 66, 64, 65, 65, 66, 64, 65, 66, 66, 64, 65, 67, 68,
-        64, 65, 67, 68, 64, 65, 67, 68, 64, 65, 68, 70, 64, 66, 69, 71, 64, 66,
-        69, 71, 66, 66, 70, 72, 68, 68, 72, 74,
+        31, 31, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32,
+        32, 32, 32, 32, 32, 33, 32, 32, 32, 33, 32, 32, 33, 33, 32, 32, 33, 34,
+        32, 32, 33, 34, 32, 32, 33, 34, 32, 32, 34, 35, 32, 33, 34, 35, 32, 33,
+        34, 35, 33, 33, 35, 36, 34, 34, 36, 37,
         /* Size 16x4 */
-        63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 66, 68, 63, 64,
-        64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 68, 64, 64, 65, 65,
-        65, 65, 65, 66, 67, 67, 67, 68, 69, 69, 70, 72, 64, 65, 65, 65, 65, 66,
-        66, 66, 68, 68, 68, 70, 71, 71, 72, 74,
+        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 35, 36, 32, 32, 32, 32, 32, 33,
+        33, 33, 34, 34, 34, 35, 35, 35, 36, 37,
         /* Size 8x32 */
-        64, 63, 63, 63, 63, 64, 64, 65, 63, 63, 63, 63, 64, 64, 64, 66, 63, 63,
-        64, 64, 64, 65, 65, 66, 63, 64, 64, 64, 64, 65, 65, 66, 63, 64, 64, 64,
-        64, 65, 65, 66, 63, 64, 64, 64, 64, 65, 65, 66, 63, 64, 64, 64, 64, 65,
-        65, 66, 63, 64, 64, 64, 64, 65, 65, 66, 63, 64, 64, 64, 65, 65, 65, 66,
-        63, 64, 64, 64, 65, 65, 65, 66, 63, 64, 65, 65, 65, 66, 66, 66, 63, 64,
-        65, 65, 65, 66, 66, 66, 63, 64, 65, 65, 65, 66, 66, 66, 63, 64, 65, 65,
-        65, 66, 66, 66, 63, 64, 65, 65, 65, 66, 66, 67, 63, 64, 65, 65, 66, 67,
-        67, 68, 63, 64, 65, 65, 66, 68, 68, 69, 64, 65, 65, 65, 66, 68, 68, 69,
-        64, 65, 65, 65, 66, 68, 68, 69, 64, 65, 65, 65, 66, 68, 68, 69, 64, 65,
-        65, 65, 66, 68, 68, 69, 64, 65, 65, 65, 67, 69, 69, 70, 64, 65, 65, 65,
-        67, 70, 70, 71, 64, 65, 66, 66, 67, 70, 70, 72, 64, 65, 66, 66, 68, 71,
-        71, 72, 64, 65, 66, 66, 68, 71, 71, 72, 64, 65, 66, 66, 68, 71, 71, 72,
-        64, 65, 66, 66, 68, 71, 71, 72, 65, 66, 66, 66, 69, 72, 72, 73, 67, 67,
-        67, 67, 69, 73, 73, 75, 68, 68, 68, 68, 70, 74, 74, 76, 68, 68, 68, 68,
-        70, 74, 74, 76,
+        32, 31, 31, 31, 31, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 33, 31, 31,
+        32, 32, 32, 32, 32, 33, 31, 32, 32, 32, 32, 32, 32, 33, 31, 32, 32, 32,
+        32, 32, 32, 33, 31, 32, 32, 32, 32, 32, 32, 33, 31, 32, 32, 32, 32, 32,
+        32, 33, 31, 32, 32, 32, 32, 32, 32, 33, 31, 32, 32, 32, 32, 32, 32, 33,
+        31, 32, 32, 32, 32, 32, 32, 33, 31, 32, 32, 32, 32, 33, 33, 33, 31, 32,
+        32, 32, 32, 33, 33, 33, 31, 32, 32, 32, 32, 33, 33, 33, 31, 32, 32, 32,
+        32, 33, 33, 33, 31, 32, 32, 32, 32, 33, 33, 33, 31, 32, 32, 32, 33, 33,
+        33, 34, 31, 32, 32, 32, 33, 34, 34, 34, 32, 32, 32, 32, 33, 34, 34, 34,
+        32, 32, 32, 32, 33, 34, 34, 34, 32, 32, 32, 32, 33, 34, 34, 34, 32, 32,
+        32, 32, 33, 34, 34, 34, 32, 32, 32, 32, 33, 34, 34, 35, 32, 32, 32, 32,
+        33, 35, 35, 35, 32, 32, 33, 33, 33, 35, 35, 36, 32, 32, 33, 33, 34, 35,
+        35, 36, 32, 32, 33, 33, 34, 35, 35, 36, 32, 32, 33, 33, 34, 35, 35, 36,
+        32, 32, 33, 33, 34, 35, 35, 36, 32, 33, 33, 33, 34, 36, 36, 36, 33, 33,
+        33, 33, 34, 36, 36, 37, 34, 34, 34, 34, 35, 37, 37, 38, 34, 34, 34, 34,
+        35, 37, 37, 38,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 67, 68, 68, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 66, 67, 68, 68, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66,
-        66, 66, 66, 67, 68, 68, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 67,
-        68, 68, 63, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 66,
-        66, 66, 66, 66, 66, 67, 67, 67, 68, 68, 68, 68, 69, 69, 70, 70, 64, 64,
-        65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 68, 68, 68, 68,
-        68, 69, 70, 70, 71, 71, 71, 71, 72, 73, 74, 74, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 68, 68, 68, 68, 68, 69, 70, 70,
-        71, 71, 71, 71, 72, 73, 74, 74, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66,
-        66, 66, 66, 66, 67, 68, 69, 69, 69, 69, 69, 70, 71, 72, 72, 72, 72, 72,
-        73, 75, 76, 76 },
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 34, 34, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
+        33, 33, 33, 33, 34, 34, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33,
+        34, 34, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34,
+        34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 37, 37, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35,
+        35, 35, 35, 35, 36, 36, 37, 37, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 36, 36, 36, 36, 36,
+        36, 37, 38, 38 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        63, 76, 76, 93,
+        31, 38, 38, 46,
 #endif
         /* Size 4x4 */
-        63, 62, 69, 77, 62, 64, 71, 80, 69, 71, 78, 87, 77, 80, 87, 95,
+        31, 31, 34, 38, 31, 32, 35, 40, 34, 35, 39, 43, 38, 40, 43, 47,
         /* Size 8x8 */
-        63, 62, 62, 61, 68, 70, 74, 81, 62, 63, 63, 62, 69, 71, 77, 82, 62, 63,
-        63, 63, 70, 73, 79, 83, 61, 62, 63, 64, 71, 73, 80, 84, 68, 69, 70, 71,
-        78, 80, 87, 89, 70, 71, 73, 73, 80, 83, 89, 91, 74, 77, 79, 80, 87, 89,
-        95, 95, 81, 82, 83, 84, 89, 91, 95, 96,
+        31, 31, 31, 30, 34, 35, 37, 40, 31, 31, 31, 31, 34, 35, 38, 41, 31, 31,
+        31, 31, 35, 36, 39, 41, 30, 31, 31, 32, 35, 36, 40, 42, 34, 34, 35, 35,
+        39, 40, 43, 44, 35, 35, 36, 36, 40, 41, 44, 45, 37, 38, 39, 40, 43, 44,
+        47, 47, 40, 41, 41, 42, 44, 45, 47, 48,
         /* Size 16x16 */
-        64, 63, 62, 62, 62, 61, 61, 62, 66, 67, 67, 71, 73, 73, 77, 83, 63, 63,
-        63, 63, 62, 62, 62, 63, 67, 68, 68, 72, 75, 75, 79, 84, 62, 63, 63, 63,
-        63, 62, 62, 64, 68, 69, 69, 74, 77, 77, 80, 85, 62, 63, 63, 63, 63, 62,
-        62, 64, 68, 69, 69, 74, 77, 77, 80, 85, 62, 62, 63, 63, 63, 63, 63, 64,
-        68, 70, 70, 75, 78, 78, 81, 85, 61, 62, 62, 62, 63, 64, 64, 65, 69, 71,
-        71, 76, 80, 80, 82, 85, 61, 62, 62, 62, 63, 64, 64, 65, 69, 71, 71, 76,
-        80, 80, 82, 85, 62, 63, 64, 64, 64, 65, 65, 66, 71, 72, 72, 77, 81, 81,
-        83, 86, 66, 67, 68, 68, 68, 69, 69, 71, 75, 77, 77, 82, 85, 85, 87, 89,
-        67, 68, 69, 69, 70, 71, 71, 72, 77, 78, 78, 83, 87, 87, 88, 90, 67, 68,
-        69, 69, 70, 71, 71, 72, 77, 78, 78, 83, 87, 87, 88, 90, 71, 72, 74, 74,
-        75, 76, 76, 77, 82, 83, 83, 88, 92, 92, 92, 93, 73, 75, 77, 77, 78, 80,
-        80, 81, 85, 87, 87, 92, 95, 95, 95, 95, 73, 75, 77, 77, 78, 80, 80, 81,
-        85, 87, 87, 92, 95, 95, 95, 95, 77, 79, 80, 80, 81, 82, 82, 83, 87, 88,
-        88, 92, 95, 95, 95, 96, 83, 84, 85, 85, 85, 85, 85, 86, 89, 90, 90, 93,
-        95, 95, 96, 97,
+        32, 31, 31, 31, 31, 30, 30, 31, 33, 33, 33, 35, 36, 36, 38, 41, 31, 31,
+        31, 31, 31, 31, 31, 31, 33, 34, 34, 36, 37, 37, 39, 42, 31, 31, 31, 31,
+        31, 31, 31, 32, 34, 34, 34, 37, 38, 38, 40, 42, 31, 31, 31, 31, 31, 31,
+        31, 32, 34, 34, 34, 37, 38, 38, 40, 42, 31, 31, 31, 31, 31, 31, 31, 32,
+        34, 35, 35, 37, 39, 39, 40, 42, 30, 31, 31, 31, 31, 32, 32, 32, 34, 35,
+        35, 38, 40, 40, 41, 42, 30, 31, 31, 31, 31, 32, 32, 32, 34, 35, 35, 38,
+        40, 40, 41, 42, 31, 31, 32, 32, 32, 32, 32, 33, 35, 36, 36, 38, 40, 40,
+        41, 43, 33, 33, 34, 34, 34, 34, 34, 35, 37, 38, 38, 41, 42, 42, 43, 44,
+        33, 34, 34, 34, 35, 35, 35, 36, 38, 39, 39, 41, 43, 43, 44, 45, 33, 34,
+        34, 34, 35, 35, 35, 36, 38, 39, 39, 41, 43, 43, 44, 45, 35, 36, 37, 37,
+        37, 38, 38, 38, 41, 41, 41, 44, 46, 46, 46, 46, 36, 37, 38, 38, 39, 40,
+        40, 40, 42, 43, 43, 46, 47, 47, 47, 47, 36, 37, 38, 38, 39, 40, 40, 40,
+        42, 43, 43, 46, 47, 47, 47, 47, 38, 39, 40, 40, 40, 41, 41, 41, 43, 44,
+        44, 46, 47, 47, 47, 48, 41, 42, 42, 42, 42, 42, 42, 43, 44, 45, 45, 46,
+        47, 47, 48, 48,
         /* Size 32x32 */
-        64, 63, 63, 62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 61, 62, 64, 66, 67,
-        67, 67, 67, 69, 71, 73, 73, 73, 73, 74, 77, 80, 83, 83, 63, 63, 63, 63,
-        62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 62, 64, 66, 68, 68, 68, 68, 70,
-        72, 74, 74, 74, 74, 75, 78, 81, 84, 84, 63, 63, 63, 63, 63, 63, 63, 63,
-        62, 62, 62, 62, 62, 62, 63, 65, 67, 68, 68, 68, 68, 70, 72, 75, 75, 75,
-        75, 76, 79, 81, 84, 84, 62, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62,
-        62, 62, 64, 65, 68, 69, 69, 69, 69, 71, 73, 76, 77, 77, 77, 77, 80, 82,
-        84, 84, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 64, 66,
-        68, 69, 69, 69, 69, 71, 74, 76, 77, 77, 77, 78, 80, 82, 85, 85, 62, 62,
-        63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 64, 66, 68, 69, 69, 69,
-        69, 71, 74, 76, 77, 77, 77, 78, 80, 82, 85, 85, 62, 62, 63, 63, 63, 63,
-        63, 63, 63, 63, 62, 62, 62, 62, 64, 66, 68, 69, 69, 69, 69, 71, 74, 76,
-        77, 77, 77, 78, 80, 82, 85, 85, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 64, 66, 68, 69, 69, 69, 69, 72, 74, 76, 77, 77, 77, 78,
-        80, 82, 85, 85, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        64, 66, 68, 70, 70, 70, 70, 72, 75, 77, 78, 78, 78, 79, 81, 83, 85, 85,
-        61, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 67, 69, 70,
-        70, 70, 70, 73, 75, 78, 79, 79, 79, 80, 81, 83, 85, 85, 61, 61, 62, 62,
-        62, 62, 62, 63, 63, 63, 64, 64, 64, 64, 65, 67, 69, 71, 71, 71, 71, 73,
-        76, 79, 80, 80, 80, 80, 82, 84, 85, 85, 61, 61, 62, 62, 62, 62, 62, 63,
-        63, 63, 64, 64, 64, 64, 65, 67, 69, 71, 71, 71, 71, 73, 76, 79, 80, 80,
-        80, 80, 82, 84, 85, 85, 61, 61, 62, 62, 62, 62, 62, 63, 63, 63, 64, 64,
-        64, 64, 65, 67, 69, 71, 71, 71, 71, 73, 76, 79, 80, 80, 80, 80, 82, 84,
-        85, 85, 61, 61, 62, 62, 62, 62, 62, 63, 63, 63, 64, 64, 64, 64, 65, 67,
-        69, 71, 71, 71, 71, 73, 76, 79, 80, 80, 80, 80, 82, 84, 85, 85, 62, 62,
-        63, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66, 68, 71, 72, 72, 72,
-        72, 75, 77, 80, 81, 81, 81, 82, 83, 85, 86, 86, 64, 64, 65, 65, 66, 66,
-        66, 66, 66, 67, 67, 67, 67, 67, 68, 71, 73, 74, 74, 74, 74, 77, 79, 82,
-        83, 83, 83, 84, 85, 86, 87, 87, 66, 66, 67, 68, 68, 68, 68, 68, 68, 69,
-        69, 69, 69, 69, 71, 73, 75, 77, 77, 77, 77, 79, 82, 84, 85, 85, 85, 86,
-        87, 88, 89, 89, 67, 68, 68, 69, 69, 69, 69, 69, 70, 70, 71, 71, 71, 71,
-        72, 74, 77, 78, 78, 78, 78, 80, 83, 86, 87, 87, 87, 87, 88, 89, 90, 90,
-        67, 68, 68, 69, 69, 69, 69, 69, 70, 70, 71, 71, 71, 71, 72, 74, 77, 78,
-        78, 78, 78, 80, 83, 86, 87, 87, 87, 87, 88, 89, 90, 90, 67, 68, 68, 69,
-        69, 69, 69, 69, 70, 70, 71, 71, 71, 71, 72, 74, 77, 78, 78, 78, 78, 80,
-        83, 86, 87, 87, 87, 87, 88, 89, 90, 90, 67, 68, 68, 69, 69, 69, 69, 69,
-        70, 70, 71, 71, 71, 71, 72, 74, 77, 78, 78, 78, 78, 80, 83, 86, 87, 87,
-        87, 87, 88, 89, 90, 90, 69, 70, 70, 71, 71, 71, 71, 72, 72, 73, 73, 73,
-        73, 73, 75, 77, 79, 80, 80, 80, 80, 83, 85, 88, 89, 89, 89, 89, 90, 91,
-        91, 91, 71, 72, 72, 73, 74, 74, 74, 74, 75, 75, 76, 76, 76, 76, 77, 79,
-        82, 83, 83, 83, 83, 85, 88, 91, 92, 92, 92, 92, 92, 92, 93, 93, 73, 74,
-        75, 76, 76, 76, 76, 76, 77, 78, 79, 79, 79, 79, 80, 82, 84, 86, 86, 86,
-        86, 88, 91, 93, 94, 94, 94, 94, 94, 94, 94, 94, 73, 74, 75, 77, 77, 77,
-        77, 77, 78, 79, 80, 80, 80, 80, 81, 83, 85, 87, 87, 87, 87, 89, 92, 94,
-        95, 95, 95, 95, 95, 95, 95, 95, 73, 74, 75, 77, 77, 77, 77, 77, 78, 79,
-        80, 80, 80, 80, 81, 83, 85, 87, 87, 87, 87, 89, 92, 94, 95, 95, 95, 95,
-        95, 95, 95, 95, 73, 74, 75, 77, 77, 77, 77, 77, 78, 79, 80, 80, 80, 80,
-        81, 83, 85, 87, 87, 87, 87, 89, 92, 94, 95, 95, 95, 95, 95, 95, 95, 95,
-        74, 75, 76, 77, 78, 78, 78, 78, 79, 80, 80, 80, 80, 80, 82, 84, 86, 87,
-        87, 87, 87, 89, 92, 94, 95, 95, 95, 95, 95, 95, 95, 95, 77, 78, 79, 80,
-        80, 80, 80, 80, 81, 81, 82, 82, 82, 82, 83, 85, 87, 88, 88, 88, 88, 90,
-        92, 94, 95, 95, 95, 95, 95, 96, 96, 96, 80, 81, 81, 82, 82, 82, 82, 82,
-        83, 83, 84, 84, 84, 84, 85, 86, 88, 89, 89, 89, 89, 91, 92, 94, 95, 95,
-        95, 95, 96, 96, 96, 96, 83, 84, 84, 84, 85, 85, 85, 85, 85, 85, 85, 85,
-        85, 85, 86, 87, 89, 90, 90, 90, 90, 91, 93, 94, 95, 95, 95, 95, 96, 96,
-        97, 97, 83, 84, 84, 84, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 86, 87,
-        89, 90, 90, 90, 90, 91, 93, 94, 95, 95, 95, 95, 96, 96, 97, 97,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 31, 32, 33, 33,
+        33, 33, 33, 34, 35, 36, 36, 36, 36, 37, 38, 40, 41, 41, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 31, 32, 33, 34, 34, 34, 34, 35,
+        36, 37, 37, 37, 37, 37, 39, 40, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34, 34, 34, 35, 36, 37, 37, 37,
+        37, 38, 39, 40, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 32, 32, 34, 34, 34, 34, 34, 35, 36, 38, 38, 38, 38, 38, 40, 41,
+        42, 42, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33,
+        34, 34, 34, 34, 34, 35, 37, 38, 38, 38, 38, 39, 40, 41, 42, 42, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34, 34, 34,
+        34, 35, 37, 38, 38, 38, 38, 39, 40, 41, 42, 42, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34, 34, 34, 34, 35, 37, 38,
+        38, 38, 38, 39, 40, 41, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 32, 33, 34, 34, 34, 34, 34, 36, 37, 38, 38, 38, 38, 39,
+        40, 41, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        32, 33, 34, 35, 35, 35, 35, 36, 37, 38, 39, 39, 39, 39, 40, 41, 42, 42,
+        30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 35,
+        35, 35, 35, 36, 37, 39, 39, 39, 39, 40, 40, 41, 42, 42, 30, 30, 31, 31,
+        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 34, 35, 35, 35, 35, 36,
+        38, 39, 40, 40, 40, 40, 41, 42, 42, 42, 30, 30, 31, 31, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 33, 34, 35, 35, 35, 35, 36, 38, 39, 40, 40,
+        40, 40, 41, 42, 42, 42, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 33, 34, 35, 35, 35, 35, 36, 38, 39, 40, 40, 40, 40, 41, 42,
+        42, 42, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 33,
+        34, 35, 35, 35, 35, 36, 38, 39, 40, 40, 40, 40, 41, 42, 42, 42, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 35, 36, 36, 36,
+        36, 37, 38, 40, 40, 40, 40, 41, 41, 42, 43, 43, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 34, 35, 36, 37, 37, 37, 37, 38, 39, 41,
+        41, 41, 41, 42, 42, 43, 43, 43, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34,
+        34, 34, 34, 34, 35, 36, 37, 38, 38, 38, 38, 39, 41, 42, 42, 42, 42, 43,
+        43, 44, 44, 44, 33, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35,
+        36, 37, 38, 39, 39, 39, 39, 40, 41, 43, 43, 43, 43, 43, 44, 44, 45, 45,
+        33, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 37, 38, 39,
+        39, 39, 39, 40, 41, 43, 43, 43, 43, 43, 44, 44, 45, 45, 33, 34, 34, 34,
+        34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 37, 38, 39, 39, 39, 39, 40,
+        41, 43, 43, 43, 43, 43, 44, 44, 45, 45, 33, 34, 34, 34, 34, 34, 34, 34,
+        35, 35, 35, 35, 35, 35, 36, 37, 38, 39, 39, 39, 39, 40, 41, 43, 43, 43,
+        43, 43, 44, 44, 45, 45, 34, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36,
+        36, 36, 37, 38, 39, 40, 40, 40, 40, 41, 42, 44, 44, 44, 44, 44, 45, 45,
+        45, 45, 35, 36, 36, 36, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 39,
+        41, 41, 41, 41, 41, 42, 44, 45, 46, 46, 46, 46, 46, 46, 46, 46, 36, 37,
+        37, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 40, 41, 42, 43, 43, 43,
+        43, 44, 45, 46, 47, 47, 47, 47, 47, 47, 47, 47, 36, 37, 37, 38, 38, 38,
+        38, 38, 39, 39, 40, 40, 40, 40, 40, 41, 42, 43, 43, 43, 43, 44, 46, 47,
+        47, 47, 47, 47, 47, 47, 47, 47, 36, 37, 37, 38, 38, 38, 38, 38, 39, 39,
+        40, 40, 40, 40, 40, 41, 42, 43, 43, 43, 43, 44, 46, 47, 47, 47, 47, 47,
+        47, 47, 47, 47, 36, 37, 37, 38, 38, 38, 38, 38, 39, 39, 40, 40, 40, 40,
+        40, 41, 42, 43, 43, 43, 43, 44, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+        37, 37, 38, 38, 39, 39, 39, 39, 39, 40, 40, 40, 40, 40, 41, 42, 43, 43,
+        43, 43, 43, 44, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 38, 39, 39, 40,
+        40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 42, 43, 44, 44, 44, 44, 45,
+        46, 47, 47, 47, 47, 47, 47, 48, 48, 48, 40, 40, 40, 41, 41, 41, 41, 41,
+        41, 41, 42, 42, 42, 42, 42, 43, 44, 44, 44, 44, 44, 45, 46, 47, 47, 47,
+        47, 47, 48, 48, 48, 48, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
+        42, 42, 43, 43, 44, 45, 45, 45, 45, 45, 46, 47, 47, 47, 47, 47, 48, 48,
+        48, 48, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 43,
+        44, 45, 45, 45, 45, 45, 46, 47, 47, 47, 47, 47, 48, 48, 48, 48,
         /* Size 4x8 */
-        63, 62, 70, 75, 63, 63, 72, 77, 62, 64, 74, 79, 62, 64, 74, 80, 69, 72,
-        81, 86, 71, 74, 84, 89, 76, 80, 90, 94, 82, 84, 91, 95,
+        31, 31, 35, 37, 31, 31, 36, 38, 31, 32, 37, 39, 31, 32, 37, 40, 34, 36,
+        40, 43, 35, 37, 42, 44, 38, 40, 45, 47, 41, 42, 45, 47,
         /* Size 8x4 */
-        63, 63, 62, 62, 69, 71, 76, 82, 62, 63, 64, 64, 72, 74, 80, 84, 70, 72,
-        74, 74, 81, 84, 90, 91, 75, 77, 79, 80, 86, 89, 94, 95,
+        31, 31, 31, 31, 34, 35, 38, 41, 31, 31, 32, 32, 36, 37, 40, 42, 35, 36,
+        37, 37, 40, 42, 45, 45, 37, 38, 39, 40, 43, 44, 47, 47,
         /* Size 8x16 */
-        64, 62, 62, 62, 66, 74, 74, 77, 63, 63, 63, 63, 67, 76, 76, 79, 63, 63,
-        63, 63, 68, 77, 77, 80, 63, 63, 63, 63, 68, 77, 77, 80, 62, 63, 64, 64,
-        69, 78, 78, 81, 61, 63, 64, 64, 70, 80, 80, 82, 61, 63, 64, 64, 70, 80,
-        80, 82, 62, 64, 66, 66, 71, 81, 81, 83, 66, 68, 70, 70, 75, 85, 85, 86,
-        67, 70, 72, 72, 77, 86, 86, 88, 67, 70, 72, 72, 77, 86, 86, 88, 71, 74,
-        77, 77, 82, 91, 91, 92, 74, 78, 80, 80, 86, 94, 94, 95, 74, 78, 80, 80,
-        86, 94, 94, 95, 78, 80, 82, 82, 87, 95, 95, 95, 84, 85, 86, 86, 89, 95,
-        95, 96,
+        32, 31, 31, 31, 33, 37, 37, 38, 31, 31, 31, 31, 33, 38, 38, 39, 31, 31,
+        31, 31, 34, 38, 38, 40, 31, 31, 31, 31, 34, 38, 38, 40, 31, 31, 32, 32,
+        34, 39, 39, 40, 30, 31, 32, 32, 35, 40, 40, 41, 30, 31, 32, 32, 35, 40,
+        40, 41, 31, 32, 33, 33, 35, 40, 40, 41, 33, 34, 35, 35, 37, 42, 42, 43,
+        33, 35, 36, 36, 38, 43, 43, 44, 33, 35, 36, 36, 38, 43, 43, 44, 35, 37,
+        38, 38, 41, 45, 45, 46, 37, 39, 40, 40, 43, 47, 47, 47, 37, 39, 40, 40,
+        43, 47, 47, 47, 39, 40, 41, 41, 43, 47, 47, 47, 42, 42, 43, 43, 44, 47,
+        47, 48,
         /* Size 16x8 */
-        64, 63, 63, 63, 62, 61, 61, 62, 66, 67, 67, 71, 74, 74, 78, 84, 62, 63,
-        63, 63, 63, 63, 63, 64, 68, 70, 70, 74, 78, 78, 80, 85, 62, 63, 63, 63,
-        64, 64, 64, 66, 70, 72, 72, 77, 80, 80, 82, 86, 62, 63, 63, 63, 64, 64,
-        64, 66, 70, 72, 72, 77, 80, 80, 82, 86, 66, 67, 68, 68, 69, 70, 70, 71,
-        75, 77, 77, 82, 86, 86, 87, 89, 74, 76, 77, 77, 78, 80, 80, 81, 85, 86,
-        86, 91, 94, 94, 95, 95, 74, 76, 77, 77, 78, 80, 80, 81, 85, 86, 86, 91,
-        94, 94, 95, 95, 77, 79, 80, 80, 81, 82, 82, 83, 86, 88, 88, 92, 95, 95,
-        95, 96,
+        32, 31, 31, 31, 31, 30, 30, 31, 33, 33, 33, 35, 37, 37, 39, 42, 31, 31,
+        31, 31, 31, 31, 31, 32, 34, 35, 35, 37, 39, 39, 40, 42, 31, 31, 31, 31,
+        32, 32, 32, 33, 35, 36, 36, 38, 40, 40, 41, 43, 31, 31, 31, 31, 32, 32,
+        32, 33, 35, 36, 36, 38, 40, 40, 41, 43, 33, 33, 34, 34, 34, 35, 35, 35,
+        37, 38, 38, 41, 43, 43, 43, 44, 37, 38, 38, 38, 39, 40, 40, 40, 42, 43,
+        43, 45, 47, 47, 47, 47, 37, 38, 38, 38, 39, 40, 40, 40, 42, 43, 43, 45,
+        47, 47, 47, 47, 38, 39, 40, 40, 40, 41, 41, 41, 43, 44, 44, 46, 47, 47,
+        47, 48,
         /* Size 16x32 */
-        64, 63, 62, 62, 62, 62, 62, 63, 66, 70, 74, 74, 74, 74, 77, 84, 63, 63,
-        63, 62, 62, 62, 62, 63, 67, 70, 75, 75, 75, 75, 78, 84, 63, 63, 63, 63,
-        63, 63, 63, 64, 67, 71, 76, 76, 76, 76, 79, 84, 63, 63, 63, 63, 63, 63,
-        63, 64, 68, 72, 77, 77, 77, 77, 80, 85, 63, 63, 63, 63, 63, 63, 63, 64,
-        68, 72, 77, 77, 77, 77, 80, 85, 63, 63, 63, 63, 63, 63, 63, 64, 68, 72,
-        77, 77, 77, 77, 80, 85, 63, 63, 63, 63, 63, 63, 63, 64, 68, 72, 77, 77,
-        77, 77, 80, 85, 62, 63, 63, 63, 63, 63, 63, 64, 68, 72, 77, 77, 77, 77,
-        80, 85, 62, 62, 63, 63, 64, 64, 64, 65, 69, 73, 78, 78, 78, 78, 81, 85,
-        61, 62, 63, 64, 64, 64, 64, 65, 69, 74, 79, 79, 79, 79, 81, 85, 61, 62,
-        63, 64, 64, 64, 64, 66, 70, 74, 80, 80, 80, 80, 82, 85, 61, 62, 63, 64,
-        64, 64, 64, 66, 70, 74, 80, 80, 80, 80, 82, 85, 61, 62, 63, 64, 64, 64,
-        64, 66, 70, 74, 80, 80, 80, 80, 82, 85, 61, 62, 63, 64, 64, 64, 64, 66,
-        70, 74, 80, 80, 80, 80, 82, 85, 62, 63, 64, 65, 66, 66, 66, 67, 71, 76,
-        81, 81, 81, 81, 83, 86, 64, 65, 66, 67, 68, 68, 68, 69, 73, 78, 83, 83,
-        83, 83, 85, 88, 66, 67, 68, 70, 70, 70, 70, 71, 75, 80, 85, 85, 85, 85,
-        86, 89, 67, 69, 70, 71, 72, 72, 72, 73, 77, 81, 86, 86, 86, 86, 88, 90,
-        67, 69, 70, 71, 72, 72, 72, 73, 77, 81, 86, 86, 86, 86, 88, 90, 67, 69,
-        70, 71, 72, 72, 72, 73, 77, 81, 86, 86, 86, 86, 88, 90, 67, 69, 70, 71,
-        72, 72, 72, 73, 77, 81, 86, 86, 86, 86, 88, 90, 69, 71, 72, 74, 74, 74,
-        74, 75, 79, 84, 89, 89, 89, 89, 90, 91, 71, 73, 74, 76, 77, 77, 77, 78,
-        82, 86, 91, 91, 91, 91, 92, 93, 73, 75, 77, 79, 79, 79, 79, 81, 85, 89,
-        94, 94, 94, 94, 94, 94, 74, 76, 78, 80, 80, 80, 80, 82, 86, 90, 94, 94,
-        94, 94, 95, 95, 74, 76, 78, 80, 80, 80, 80, 82, 86, 90, 94, 94, 94, 94,
-        95, 95, 74, 76, 78, 80, 80, 80, 80, 82, 86, 90, 94, 94, 94, 94, 95, 95,
-        75, 77, 78, 80, 81, 81, 81, 82, 86, 90, 94, 94, 94, 94, 95, 95, 78, 79,
-        80, 82, 82, 82, 82, 84, 87, 91, 95, 95, 95, 95, 95, 96, 81, 82, 83, 84,
-        84, 84, 84, 85, 88, 91, 95, 95, 95, 95, 95, 97, 84, 84, 85, 86, 86, 86,
-        86, 87, 89, 92, 95, 95, 95, 95, 96, 97, 84, 84, 85, 86, 86, 86, 86, 87,
-        89, 92, 95, 95, 95, 95, 96, 97,
+        32, 31, 31, 31, 31, 31, 31, 31, 33, 35, 37, 37, 37, 37, 38, 42, 31, 31,
+        31, 31, 31, 31, 31, 31, 33, 35, 37, 37, 37, 37, 39, 42, 31, 31, 31, 31,
+        31, 31, 31, 32, 33, 35, 38, 38, 38, 38, 39, 42, 31, 31, 31, 31, 31, 31,
+        31, 32, 34, 36, 38, 38, 38, 38, 40, 42, 31, 31, 31, 31, 31, 31, 31, 32,
+        34, 36, 38, 38, 38, 38, 40, 42, 31, 31, 31, 31, 31, 31, 31, 32, 34, 36,
+        38, 38, 38, 38, 40, 42, 31, 31, 31, 31, 31, 31, 31, 32, 34, 36, 38, 38,
+        38, 38, 40, 42, 31, 31, 31, 31, 31, 31, 31, 32, 34, 36, 38, 38, 38, 38,
+        40, 42, 31, 31, 31, 31, 32, 32, 32, 32, 34, 36, 39, 39, 39, 39, 40, 42,
+        30, 31, 31, 32, 32, 32, 32, 32, 34, 37, 39, 39, 39, 39, 40, 42, 30, 31,
+        31, 32, 32, 32, 32, 33, 35, 37, 40, 40, 40, 40, 41, 42, 30, 31, 31, 32,
+        32, 32, 32, 33, 35, 37, 40, 40, 40, 40, 41, 42, 30, 31, 31, 32, 32, 32,
+        32, 33, 35, 37, 40, 40, 40, 40, 41, 42, 30, 31, 31, 32, 32, 32, 32, 33,
+        35, 37, 40, 40, 40, 40, 41, 42, 31, 31, 32, 32, 33, 33, 33, 33, 35, 38,
+        40, 40, 40, 40, 41, 43, 32, 32, 33, 33, 34, 34, 34, 34, 36, 39, 41, 41,
+        41, 41, 42, 44, 33, 33, 34, 35, 35, 35, 35, 35, 37, 40, 42, 42, 42, 42,
+        43, 44, 33, 34, 35, 35, 36, 36, 36, 36, 38, 40, 43, 43, 43, 43, 44, 45,
+        33, 34, 35, 35, 36, 36, 36, 36, 38, 40, 43, 43, 43, 43, 44, 45, 33, 34,
+        35, 35, 36, 36, 36, 36, 38, 40, 43, 43, 43, 43, 44, 45, 33, 34, 35, 35,
+        36, 36, 36, 36, 38, 40, 43, 43, 43, 43, 44, 45, 34, 35, 36, 37, 37, 37,
+        37, 37, 39, 42, 44, 44, 44, 44, 45, 45, 35, 36, 37, 38, 38, 38, 38, 39,
+        41, 43, 45, 45, 45, 45, 46, 46, 36, 37, 38, 39, 39, 39, 39, 40, 42, 44,
+        47, 47, 47, 47, 47, 47, 37, 38, 39, 40, 40, 40, 40, 41, 43, 45, 47, 47,
+        47, 47, 47, 47, 37, 38, 39, 40, 40, 40, 40, 41, 43, 45, 47, 47, 47, 47,
+        47, 47, 37, 38, 39, 40, 40, 40, 40, 41, 43, 45, 47, 47, 47, 47, 47, 47,
+        37, 38, 39, 40, 40, 40, 40, 41, 43, 45, 47, 47, 47, 47, 47, 47, 39, 39,
+        40, 41, 41, 41, 41, 42, 43, 45, 47, 47, 47, 47, 47, 48, 40, 41, 41, 42,
+        42, 42, 42, 42, 44, 45, 47, 47, 47, 47, 47, 48, 42, 42, 42, 43, 43, 43,
+        43, 43, 44, 46, 47, 47, 47, 47, 48, 48, 42, 42, 42, 43, 43, 43, 43, 43,
+        44, 46, 47, 47, 47, 47, 48, 48,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 63, 62, 62, 61, 61, 61, 61, 61, 62, 64, 66, 67,
-        67, 67, 67, 69, 71, 73, 74, 74, 74, 75, 78, 81, 84, 84, 63, 63, 63, 63,
-        63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 63, 65, 67, 69, 69, 69, 69, 71,
-        73, 75, 76, 76, 76, 77, 79, 82, 84, 84, 62, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 64, 66, 68, 70, 70, 70, 70, 72, 74, 77, 78, 78,
-        78, 78, 80, 83, 85, 85, 62, 62, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64,
-        64, 64, 65, 67, 70, 71, 71, 71, 71, 74, 76, 79, 80, 80, 80, 80, 82, 84,
-        86, 86, 62, 62, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 66, 68,
-        70, 72, 72, 72, 72, 74, 77, 79, 80, 80, 80, 81, 82, 84, 86, 86, 62, 62,
-        63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 66, 68, 70, 72, 72, 72,
-        72, 74, 77, 79, 80, 80, 80, 81, 82, 84, 86, 86, 62, 62, 63, 63, 63, 63,
-        63, 63, 64, 64, 64, 64, 64, 64, 66, 68, 70, 72, 72, 72, 72, 74, 77, 79,
-        80, 80, 80, 81, 82, 84, 86, 86, 63, 63, 64, 64, 64, 64, 64, 64, 65, 65,
-        66, 66, 66, 66, 67, 69, 71, 73, 73, 73, 73, 75, 78, 81, 82, 82, 82, 82,
-        84, 85, 87, 87, 66, 67, 67, 68, 68, 68, 68, 68, 69, 69, 70, 70, 70, 70,
-        71, 73, 75, 77, 77, 77, 77, 79, 82, 85, 86, 86, 86, 86, 87, 88, 89, 89,
-        70, 70, 71, 72, 72, 72, 72, 72, 73, 74, 74, 74, 74, 74, 76, 78, 80, 81,
-        81, 81, 81, 84, 86, 89, 90, 90, 90, 90, 91, 91, 92, 92, 74, 75, 76, 77,
-        77, 77, 77, 77, 78, 79, 80, 80, 80, 80, 81, 83, 85, 86, 86, 86, 86, 89,
-        91, 94, 94, 94, 94, 94, 95, 95, 95, 95, 74, 75, 76, 77, 77, 77, 77, 77,
-        78, 79, 80, 80, 80, 80, 81, 83, 85, 86, 86, 86, 86, 89, 91, 94, 94, 94,
-        94, 94, 95, 95, 95, 95, 74, 75, 76, 77, 77, 77, 77, 77, 78, 79, 80, 80,
-        80, 80, 81, 83, 85, 86, 86, 86, 86, 89, 91, 94, 94, 94, 94, 94, 95, 95,
-        95, 95, 74, 75, 76, 77, 77, 77, 77, 77, 78, 79, 80, 80, 80, 80, 81, 83,
-        85, 86, 86, 86, 86, 89, 91, 94, 94, 94, 94, 94, 95, 95, 95, 95, 77, 78,
-        79, 80, 80, 80, 80, 80, 81, 81, 82, 82, 82, 82, 83, 85, 86, 88, 88, 88,
-        88, 90, 92, 94, 95, 95, 95, 95, 95, 95, 96, 96, 84, 84, 84, 85, 85, 85,
-        85, 85, 85, 85, 85, 85, 85, 85, 86, 88, 89, 90, 90, 90, 90, 91, 93, 94,
-        95, 95, 95, 95, 96, 97, 97, 97,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 31, 32, 33, 33,
+        33, 33, 33, 34, 35, 36, 37, 37, 37, 37, 39, 40, 42, 42, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34, 34, 34, 35,
+        36, 37, 38, 38, 38, 38, 39, 41, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 32, 33, 34, 35, 35, 35, 35, 36, 37, 38, 39, 39,
+        39, 39, 40, 41, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 33, 35, 35, 35, 35, 35, 37, 38, 39, 40, 40, 40, 40, 41, 42,
+        43, 43, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 33, 34,
+        35, 36, 36, 36, 36, 37, 38, 39, 40, 40, 40, 40, 41, 42, 43, 43, 31, 31,
+        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 33, 34, 35, 36, 36, 36,
+        36, 37, 38, 39, 40, 40, 40, 40, 41, 42, 43, 43, 31, 31, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 33, 34, 35, 36, 36, 36, 36, 37, 38, 39,
+        40, 40, 40, 40, 41, 42, 43, 43, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 33, 34, 35, 36, 36, 36, 36, 37, 39, 40, 41, 41, 41, 41,
+        42, 42, 43, 43, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35,
+        35, 36, 37, 38, 38, 38, 38, 39, 41, 42, 43, 43, 43, 43, 43, 44, 44, 44,
+        35, 35, 35, 36, 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, 38, 39, 40, 40,
+        40, 40, 40, 42, 43, 44, 45, 45, 45, 45, 45, 45, 46, 46, 37, 37, 38, 38,
+        38, 38, 38, 38, 39, 39, 40, 40, 40, 40, 40, 41, 42, 43, 43, 43, 43, 44,
+        45, 47, 47, 47, 47, 47, 47, 47, 47, 47, 37, 37, 38, 38, 38, 38, 38, 38,
+        39, 39, 40, 40, 40, 40, 40, 41, 42, 43, 43, 43, 43, 44, 45, 47, 47, 47,
+        47, 47, 47, 47, 47, 47, 37, 37, 38, 38, 38, 38, 38, 38, 39, 39, 40, 40,
+        40, 40, 40, 41, 42, 43, 43, 43, 43, 44, 45, 47, 47, 47, 47, 47, 47, 47,
+        47, 47, 37, 37, 38, 38, 38, 38, 38, 38, 39, 39, 40, 40, 40, 40, 40, 41,
+        42, 43, 43, 43, 43, 44, 45, 47, 47, 47, 47, 47, 47, 47, 47, 47, 38, 39,
+        39, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 42, 43, 44, 44, 44,
+        44, 45, 46, 47, 47, 47, 47, 47, 47, 47, 48, 48, 42, 42, 42, 42, 42, 42,
+        42, 42, 42, 42, 42, 42, 42, 42, 43, 44, 44, 45, 45, 45, 45, 45, 46, 47,
+        47, 47, 47, 47, 48, 48, 48, 48,
         /* Size 4x16 */
-        63, 62, 70, 74, 63, 63, 71, 76, 63, 63, 72, 77, 63, 63, 72, 77, 62, 64,
-        73, 78, 62, 64, 74, 80, 62, 64, 74, 80, 63, 66, 76, 81, 67, 70, 80, 85,
-        69, 72, 81, 86, 69, 72, 81, 86, 73, 77, 86, 91, 76, 80, 90, 94, 76, 80,
-        90, 94, 79, 82, 91, 95, 84, 86, 92, 95,
+        31, 31, 35, 37, 31, 31, 35, 38, 31, 31, 36, 38, 31, 31, 36, 38, 31, 32,
+        36, 39, 31, 32, 37, 40, 31, 32, 37, 40, 31, 33, 38, 40, 33, 35, 40, 42,
+        34, 36, 40, 43, 34, 36, 40, 43, 36, 38, 43, 45, 38, 40, 45, 47, 38, 40,
+        45, 47, 39, 41, 45, 47, 42, 43, 46, 47,
         /* Size 16x4 */
-        63, 63, 63, 63, 62, 62, 62, 63, 67, 69, 69, 73, 76, 76, 79, 84, 62, 63,
-        63, 63, 64, 64, 64, 66, 70, 72, 72, 77, 80, 80, 82, 86, 70, 71, 72, 72,
-        73, 74, 74, 76, 80, 81, 81, 86, 90, 90, 91, 92, 74, 76, 77, 77, 78, 80,
-        80, 81, 85, 86, 86, 91, 94, 94, 95, 95,
+        31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 34, 36, 38, 38, 39, 42, 31, 31,
+        31, 31, 32, 32, 32, 33, 35, 36, 36, 38, 40, 40, 41, 43, 35, 35, 36, 36,
+        36, 37, 37, 38, 40, 40, 40, 43, 45, 45, 45, 46, 37, 38, 38, 38, 39, 40,
+        40, 40, 42, 43, 43, 45, 47, 47, 47, 47,
         /* Size 8x32 */
-        64, 62, 62, 62, 66, 74, 74, 77, 63, 63, 62, 62, 67, 75, 75, 78, 63, 63,
-        63, 63, 67, 76, 76, 79, 63, 63, 63, 63, 68, 77, 77, 80, 63, 63, 63, 63,
-        68, 77, 77, 80, 63, 63, 63, 63, 68, 77, 77, 80, 63, 63, 63, 63, 68, 77,
-        77, 80, 62, 63, 63, 63, 68, 77, 77, 80, 62, 63, 64, 64, 69, 78, 78, 81,
-        61, 63, 64, 64, 69, 79, 79, 81, 61, 63, 64, 64, 70, 80, 80, 82, 61, 63,
-        64, 64, 70, 80, 80, 82, 61, 63, 64, 64, 70, 80, 80, 82, 61, 63, 64, 64,
-        70, 80, 80, 82, 62, 64, 66, 66, 71, 81, 81, 83, 64, 66, 68, 68, 73, 83,
-        83, 85, 66, 68, 70, 70, 75, 85, 85, 86, 67, 70, 72, 72, 77, 86, 86, 88,
-        67, 70, 72, 72, 77, 86, 86, 88, 67, 70, 72, 72, 77, 86, 86, 88, 67, 70,
-        72, 72, 77, 86, 86, 88, 69, 72, 74, 74, 79, 89, 89, 90, 71, 74, 77, 77,
-        82, 91, 91, 92, 73, 77, 79, 79, 85, 94, 94, 94, 74, 78, 80, 80, 86, 94,
-        94, 95, 74, 78, 80, 80, 86, 94, 94, 95, 74, 78, 80, 80, 86, 94, 94, 95,
-        75, 78, 81, 81, 86, 94, 94, 95, 78, 80, 82, 82, 87, 95, 95, 95, 81, 83,
-        84, 84, 88, 95, 95, 95, 84, 85, 86, 86, 89, 95, 95, 96, 84, 85, 86, 86,
-        89, 95, 95, 96,
+        32, 31, 31, 31, 33, 37, 37, 38, 31, 31, 31, 31, 33, 37, 37, 39, 31, 31,
+        31, 31, 33, 38, 38, 39, 31, 31, 31, 31, 34, 38, 38, 40, 31, 31, 31, 31,
+        34, 38, 38, 40, 31, 31, 31, 31, 34, 38, 38, 40, 31, 31, 31, 31, 34, 38,
+        38, 40, 31, 31, 31, 31, 34, 38, 38, 40, 31, 31, 32, 32, 34, 39, 39, 40,
+        30, 31, 32, 32, 34, 39, 39, 40, 30, 31, 32, 32, 35, 40, 40, 41, 30, 31,
+        32, 32, 35, 40, 40, 41, 30, 31, 32, 32, 35, 40, 40, 41, 30, 31, 32, 32,
+        35, 40, 40, 41, 31, 32, 33, 33, 35, 40, 40, 41, 32, 33, 34, 34, 36, 41,
+        41, 42, 33, 34, 35, 35, 37, 42, 42, 43, 33, 35, 36, 36, 38, 43, 43, 44,
+        33, 35, 36, 36, 38, 43, 43, 44, 33, 35, 36, 36, 38, 43, 43, 44, 33, 35,
+        36, 36, 38, 43, 43, 44, 34, 36, 37, 37, 39, 44, 44, 45, 35, 37, 38, 38,
+        41, 45, 45, 46, 36, 38, 39, 39, 42, 47, 47, 47, 37, 39, 40, 40, 43, 47,
+        47, 47, 37, 39, 40, 40, 43, 47, 47, 47, 37, 39, 40, 40, 43, 47, 47, 47,
+        37, 39, 40, 40, 43, 47, 47, 47, 39, 40, 41, 41, 43, 47, 47, 47, 40, 41,
+        42, 42, 44, 47, 47, 47, 42, 42, 43, 43, 44, 47, 47, 48, 42, 42, 43, 43,
+        44, 47, 47, 48,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 63, 62, 62, 61, 61, 61, 61, 61, 62, 64, 66, 67,
-        67, 67, 67, 69, 71, 73, 74, 74, 74, 75, 78, 81, 84, 84, 62, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 66, 68, 70, 70, 70, 70, 72,
-        74, 77, 78, 78, 78, 78, 80, 83, 85, 85, 62, 62, 63, 63, 63, 63, 63, 63,
-        64, 64, 64, 64, 64, 64, 66, 68, 70, 72, 72, 72, 72, 74, 77, 79, 80, 80,
-        80, 81, 82, 84, 86, 86, 62, 62, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64,
-        64, 64, 66, 68, 70, 72, 72, 72, 72, 74, 77, 79, 80, 80, 80, 81, 82, 84,
-        86, 86, 66, 67, 67, 68, 68, 68, 68, 68, 69, 69, 70, 70, 70, 70, 71, 73,
-        75, 77, 77, 77, 77, 79, 82, 85, 86, 86, 86, 86, 87, 88, 89, 89, 74, 75,
-        76, 77, 77, 77, 77, 77, 78, 79, 80, 80, 80, 80, 81, 83, 85, 86, 86, 86,
-        86, 89, 91, 94, 94, 94, 94, 94, 95, 95, 95, 95, 74, 75, 76, 77, 77, 77,
-        77, 77, 78, 79, 80, 80, 80, 80, 81, 83, 85, 86, 86, 86, 86, 89, 91, 94,
-        94, 94, 94, 94, 95, 95, 95, 95, 77, 78, 79, 80, 80, 80, 80, 80, 81, 81,
-        82, 82, 82, 82, 83, 85, 86, 88, 88, 88, 88, 90, 92, 94, 95, 95, 95, 95,
-        95, 95, 96, 96 },
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 31, 32, 33, 33,
+        33, 33, 33, 34, 35, 36, 37, 37, 37, 37, 39, 40, 42, 42, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 35, 35, 35, 35, 36,
+        37, 38, 39, 39, 39, 39, 40, 41, 42, 42, 31, 31, 31, 31, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 33, 34, 35, 36, 36, 36, 36, 37, 38, 39, 40, 40,
+        40, 40, 41, 42, 43, 43, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 32, 33, 34, 35, 36, 36, 36, 36, 37, 38, 39, 40, 40, 40, 40, 41, 42,
+        43, 43, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 36,
+        37, 38, 38, 38, 38, 39, 41, 42, 43, 43, 43, 43, 43, 44, 44, 44, 37, 37,
+        38, 38, 38, 38, 38, 38, 39, 39, 40, 40, 40, 40, 40, 41, 42, 43, 43, 43,
+        43, 44, 45, 47, 47, 47, 47, 47, 47, 47, 47, 47, 37, 37, 38, 38, 38, 38,
+        38, 38, 39, 39, 40, 40, 40, 40, 40, 41, 42, 43, 43, 43, 43, 44, 45, 47,
+        47, 47, 47, 47, 47, 47, 47, 47, 38, 39, 39, 40, 40, 40, 40, 40, 40, 40,
+        41, 41, 41, 41, 41, 42, 43, 44, 44, 44, 44, 45, 46, 47, 47, 47, 47, 47,
+        47, 47, 48, 48 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        64, 64, 64, 66,
+        32, 32, 32, 33,
 #endif
         /* Size 4x4 */
-        63, 63, 63, 64, 63, 64, 64, 65, 63, 64, 65, 65, 64, 65, 65, 67,
+        31, 31, 31, 32, 31, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 33,
         /* Size 8x8 */
-        63, 63, 63, 63, 63, 63, 64, 64, 63, 64, 64, 64, 64, 64, 64, 64, 63, 64,
-        64, 64, 64, 64, 64, 64, 63, 64, 64, 64, 64, 64, 65, 65, 63, 64, 64, 64,
-        65, 65, 65, 65, 63, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 65, 65, 65,
-        67, 67, 64, 64, 64, 65, 65, 65, 67, 67,
+        31, 31, 31, 31, 31, 31, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32,
+        32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32,
+        32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 32, 32, 32, 32, 32, 32, 33, 33,
         /* Size 16x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 63, 63, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 65, 63, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        63, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63,
-        64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63, 64, 64,
-        64, 64, 64, 65, 65, 65, 65, 65, 66, 66, 66, 66, 63, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 63, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 66, 66, 67, 67, 67, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 66, 66, 67, 67, 67, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66,
-        66, 67, 67, 67,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 33, 33, 33,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65,
-        65, 65, 65, 65, 65, 65, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 65, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63,
-        63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 66, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66,
-        66, 66, 66, 66, 66, 66, 66, 67, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67,
-        67, 67, 67, 67, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 63, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 63, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 67,
-        67, 67, 67, 67, 67, 67, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67, 67, 67,
-        67, 67, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 67,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
         /* Size 4x8 */
-        63, 63, 63, 64, 63, 64, 64, 65, 63, 64, 64, 65, 63, 64, 64, 65, 63, 65,
-        65, 65, 63, 65, 65, 66, 64, 65, 65, 67, 64, 65, 65, 67,
+        31, 31, 31, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32,
+        32, 32, 31, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33,
         /* Size 8x4 */
-        63, 63, 63, 63, 63, 63, 64, 64, 63, 64, 64, 64, 65, 65, 65, 65, 63, 64,
-        64, 64, 65, 65, 65, 65, 64, 65, 65, 65, 65, 66, 67, 67,
+        31, 31, 31, 31, 31, 31, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
         /* Size 8x16 */
-        64, 63, 63, 63, 63, 63, 63, 64, 63, 63, 63, 63, 63, 63, 64, 64, 63, 63,
-        64, 64, 64, 64, 64, 65, 63, 64, 64, 64, 64, 64, 64, 65, 63, 64, 64, 64,
-        64, 64, 64, 65, 63, 64, 64, 64, 64, 64, 64, 65, 63, 64, 64, 64, 64, 64,
-        65, 65, 63, 64, 64, 65, 65, 65, 65, 65, 63, 64, 64, 65, 65, 65, 65, 65,
-        63, 64, 64, 65, 65, 65, 65, 65, 63, 64, 64, 65, 65, 65, 65, 65, 63, 64,
-        65, 65, 65, 65, 66, 66, 63, 64, 65, 65, 65, 65, 66, 67, 64, 64, 65, 65,
-        65, 65, 66, 68, 64, 64, 65, 65, 65, 65, 66, 68, 64, 64, 65, 65, 65, 65,
-        66, 68,
+        32, 31, 31, 31, 31, 31, 31, 32, 31, 31, 31, 31, 31, 31, 32, 32, 31, 31,
+        32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32,
+        32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32,
+        32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32,
+        31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32,
+        32, 32, 32, 32, 33, 33, 31, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32,
+        32, 32, 33, 34, 32, 32, 32, 32, 32, 32, 33, 34, 32, 32, 32, 32, 32, 32,
+        33, 34,
         /* Size 16x8 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 63, 63, 64, 64, 64, 64,
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63, 64, 64, 64, 64, 64, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 63, 63, 64, 64, 64, 64, 64, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 63, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66,
-        66, 66, 66, 66, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 67, 68,
-        68, 68,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34,
+        34, 34,
         /* Size 16x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 65, 65, 65, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 65, 65, 65, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65,
-        65, 65, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65,
-        63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 65, 65, 65, 65, 65, 63, 63, 64, 64, 64, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 63, 63, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 63, 63, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 66, 63, 63, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66,
-        63, 63, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 63, 63,
-        64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 63, 63, 64, 64,
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 63, 63, 64, 64, 64, 65,
-        65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 63, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 67, 63, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 65, 66, 66, 67, 67, 63, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 66,
-        66, 67, 67, 68, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 67,
-        68, 68, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 67, 68, 68,
-        64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 67, 68, 68, 64, 64,
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 67, 68, 68, 64, 64, 64, 65,
-        65, 65, 65, 65, 65, 65, 65, 66, 66, 67, 68, 68, 64, 64, 64, 65, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 67, 68, 68, 64, 64, 64, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 67, 67, 68, 69,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 33, 33, 34, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
+        34, 34, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 34, 34, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 33, 34, 34,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65,
-        65, 65, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66,
-        66, 66, 66, 66, 66, 66, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66,
-        66, 67, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 67, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 66, 66, 67, 67, 68, 68, 68, 68, 68, 68, 68, 64, 64, 64, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 67, 67,
-        68, 68, 68, 68, 68, 68, 68, 69,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        34, 34, 34, 34, 34, 34, 34, 34,
         /* Size 4x16 */
-        63, 63, 63, 64, 63, 63, 63, 64, 63, 64, 64, 64, 63, 64, 64, 65, 63, 64,
-        64, 65, 63, 64, 64, 65, 63, 64, 64, 65, 63, 65, 65, 65, 63, 65, 65, 65,
-        63, 65, 65, 65, 63, 65, 65, 65, 64, 65, 65, 66, 64, 65, 65, 67, 64, 65,
-        65, 67, 64, 65, 65, 67, 64, 65, 65, 67,
+        31, 31, 31, 32, 31, 31, 31, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32,
+        32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32,
+        31, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 33, 32, 32,
+        32, 33, 32, 32, 32, 33, 32, 32, 32, 33,
         /* Size 16x4 */
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 63, 63,
-        64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63, 64, 64,
-        64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 65, 65, 65,
-        65, 65, 65, 65, 65, 66, 67, 67, 67, 67,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 33, 33, 33,
         /* Size 8x32 */
-        64, 63, 63, 63, 63, 63, 63, 64, 63, 63, 63, 63, 63, 63, 64, 64, 63, 63,
-        63, 63, 63, 63, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64,
-        64, 64, 64, 65, 63, 64, 64, 64, 64, 64, 64, 65, 63, 64, 64, 64, 64, 64,
-        64, 65, 63, 64, 64, 64, 64, 64, 64, 65, 63, 64, 64, 64, 64, 64, 64, 65,
-        63, 64, 64, 64, 64, 64, 64, 65, 63, 64, 64, 64, 64, 64, 64, 65, 63, 64,
-        64, 64, 64, 64, 64, 65, 63, 64, 64, 64, 64, 64, 65, 65, 63, 64, 64, 64,
-        64, 64, 65, 65, 63, 64, 64, 65, 65, 65, 65, 65, 63, 64, 64, 65, 65, 65,
-        65, 65, 63, 64, 64, 65, 65, 65, 65, 65, 63, 64, 64, 65, 65, 65, 65, 65,
-        63, 64, 64, 65, 65, 65, 65, 65, 63, 64, 64, 65, 65, 65, 65, 65, 63, 64,
-        64, 65, 65, 65, 65, 65, 63, 64, 64, 65, 65, 65, 65, 66, 63, 64, 65, 65,
-        65, 65, 66, 66, 63, 64, 65, 65, 65, 65, 66, 67, 63, 64, 65, 65, 65, 65,
-        66, 67, 64, 64, 65, 65, 65, 65, 66, 68, 64, 64, 65, 65, 65, 65, 66, 68,
-        64, 64, 65, 65, 65, 65, 66, 68, 64, 64, 65, 65, 65, 65, 66, 68, 64, 64,
-        65, 65, 65, 65, 66, 68, 64, 64, 65, 65, 65, 65, 66, 68, 64, 64, 65, 65,
-        65, 65, 67, 68,
+        32, 31, 31, 31, 31, 31, 31, 32, 31, 31, 31, 31, 31, 31, 32, 32, 31, 31,
+        31, 31, 31, 31, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
+        32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32,
+        32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32,
+        31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32,
+        32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32,
+        32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32,
+        32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32,
+        31, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 32, 31, 32,
+        32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 32, 33, 31, 32, 32, 32,
+        32, 32, 33, 33, 31, 32, 32, 32, 32, 32, 33, 33, 31, 32, 32, 32, 32, 32,
+        33, 33, 32, 32, 32, 32, 32, 32, 33, 34, 32, 32, 32, 32, 32, 32, 33, 34,
+        32, 32, 32, 32, 32, 32, 33, 34, 32, 32, 32, 32, 32, 32, 33, 34, 32, 32,
+        32, 32, 32, 32, 33, 34, 32, 32, 32, 32, 32, 32, 33, 34, 32, 32, 32, 32,
+        32, 32, 33, 34,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66,
-        66, 66, 66, 66, 66, 66, 66, 67, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 67, 67, 68, 68, 68,
-        68, 68, 68, 68 },
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34,
+        34, 34, 34, 34 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        63, 66, 66, 72,
+        31, 33, 33, 36,
 #endif
         /* Size 4x4 */
-        63, 62, 62, 68, 62, 63, 63, 70, 62, 63, 64, 71, 68, 70, 71, 78,
+        31, 31, 31, 34, 31, 31, 31, 35, 31, 31, 32, 35, 34, 35, 35, 39,
         /* Size 8x8 */
-        63, 62, 62, 62, 61, 62, 67, 67, 62, 63, 63, 63, 62, 64, 69, 69, 62, 63,
-        63, 63, 62, 64, 69, 69, 62, 63, 63, 63, 63, 64, 70, 70, 61, 62, 62, 63,
-        64, 65, 71, 71, 62, 64, 64, 64, 65, 66, 72, 72, 67, 69, 69, 70, 71, 72,
-        78, 78, 67, 69, 69, 70, 71, 72, 78, 78,
+        31, 31, 31, 31, 30, 31, 33, 33, 31, 31, 31, 31, 31, 32, 34, 34, 31, 31,
+        31, 31, 31, 32, 34, 34, 31, 31, 31, 31, 31, 32, 35, 35, 30, 31, 31, 31,
+        32, 32, 35, 35, 31, 32, 32, 32, 32, 33, 36, 36, 33, 34, 34, 35, 35, 36,
+        39, 39, 33, 34, 34, 35, 35, 36, 39, 39,
         /* Size 16x16 */
-        64, 63, 63, 62, 62, 62, 62, 61, 61, 61, 61, 63, 66, 67, 67, 67, 63, 63,
-        63, 63, 63, 63, 62, 62, 61, 61, 61, 64, 66, 68, 68, 68, 63, 63, 63, 63,
-        63, 63, 62, 62, 62, 62, 62, 65, 67, 69, 69, 69, 62, 63, 63, 63, 63, 63,
-        63, 63, 62, 62, 62, 65, 68, 69, 69, 69, 62, 63, 63, 63, 63, 63, 63, 63,
-        62, 62, 62, 65, 68, 69, 69, 69, 62, 63, 63, 63, 63, 63, 63, 63, 62, 62,
-        62, 65, 68, 69, 69, 69, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 66,
-        68, 70, 70, 70, 61, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 66, 69, 71,
-        71, 71, 61, 61, 62, 62, 62, 62, 63, 63, 64, 64, 64, 66, 69, 71, 71, 71,
-        61, 61, 62, 62, 62, 62, 63, 63, 64, 64, 64, 66, 69, 71, 71, 71, 61, 61,
-        62, 62, 62, 62, 63, 63, 64, 64, 64, 66, 69, 71, 71, 71, 63, 64, 65, 65,
-        65, 65, 66, 66, 66, 66, 66, 69, 72, 74, 74, 74, 66, 66, 67, 68, 68, 68,
-        68, 69, 69, 69, 69, 72, 75, 77, 77, 77, 67, 68, 69, 69, 69, 69, 70, 71,
-        71, 71, 71, 74, 77, 78, 78, 78, 67, 68, 69, 69, 69, 69, 70, 71, 71, 71,
-        71, 74, 77, 78, 78, 78, 67, 68, 69, 69, 69, 69, 70, 71, 71, 71, 71, 74,
-        77, 78, 78, 78,
+        32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 31, 33, 33, 33, 33, 31, 31,
+        31, 31, 31, 31, 31, 31, 30, 30, 30, 32, 33, 34, 34, 34, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34, 34, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 32, 34, 34, 34, 34, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 32, 34, 34, 34, 34, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 32, 34, 34, 34, 34, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33,
+        34, 35, 35, 35, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 35,
+        35, 35, 30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35,
+        30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35, 30, 30,
+        31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35, 31, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 34, 36, 37, 37, 37, 33, 33, 33, 34, 34, 34,
+        34, 34, 34, 34, 34, 36, 37, 38, 38, 38, 33, 34, 34, 34, 34, 34, 35, 35,
+        35, 35, 35, 37, 38, 39, 39, 39, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35,
+        35, 37, 38, 39, 39, 39, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 37,
+        38, 39, 39, 39,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 61,
-        61, 61, 61, 62, 63, 64, 66, 67, 67, 67, 67, 67, 67, 68, 63, 63, 63, 63,
-        63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 61, 61, 61, 62,
-        63, 65, 66, 67, 67, 67, 67, 67, 67, 69, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 62, 62, 62, 61, 61, 61, 61, 61, 61, 63, 64, 65, 66, 68,
-        68, 68, 68, 68, 68, 69, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62,
-        62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 64, 66, 67, 68, 68, 68, 68, 68,
-        68, 70, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62,
-        62, 62, 62, 62, 62, 63, 65, 66, 67, 69, 69, 69, 69, 69, 69, 70, 62, 62,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62,
-        62, 64, 65, 66, 68, 69, 69, 69, 69, 69, 69, 71, 62, 62, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 64, 65, 66,
-        68, 69, 69, 69, 69, 69, 69, 71, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 64, 65, 66, 68, 69, 69, 69,
-        69, 69, 69, 71, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 62, 62, 62, 62, 62, 62, 64, 65, 66, 68, 69, 69, 69, 69, 69, 69, 71,
-        62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62,
-        62, 62, 62, 64, 65, 66, 68, 69, 69, 69, 69, 69, 69, 71, 62, 62, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 64,
-        65, 66, 68, 69, 69, 69, 69, 69, 69, 71, 62, 62, 62, 62, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 65, 67, 68, 70,
-        70, 70, 70, 70, 70, 71, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 66, 67, 68, 70, 70, 70, 70, 70,
-        70, 71, 61, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 64, 66, 67, 69, 70, 70, 70, 70, 70, 70, 72, 61, 61,
-        62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 65, 66, 68, 69, 71, 71, 71, 71, 71, 71, 72, 61, 61, 61, 62, 62, 62,
-        62, 62, 62, 62, 62, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 65, 66, 68,
-        69, 71, 71, 71, 71, 71, 71, 73, 61, 61, 61, 62, 62, 62, 62, 62, 62, 62,
-        62, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 65, 66, 68, 69, 71, 71, 71,
-        71, 71, 71, 73, 61, 61, 61, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 65, 66, 68, 69, 71, 71, 71, 71, 71, 71, 73,
-        61, 61, 61, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 65, 66, 68, 69, 71, 71, 71, 71, 71, 71, 73, 61, 61, 61, 62,
-        62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 65,
-        66, 68, 69, 71, 71, 71, 71, 71, 71, 73, 61, 61, 61, 62, 62, 62, 62, 62,
-        62, 62, 62, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 65, 66, 68, 69, 71,
-        71, 71, 71, 71, 71, 73, 62, 62, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 66, 68, 69, 71, 72, 72, 72, 72, 72,
-        72, 74, 63, 63, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66,
-        66, 66, 66, 66, 66, 68, 69, 71, 72, 74, 74, 74, 74, 74, 74, 75, 64, 65,
-        65, 66, 66, 66, 66, 66, 66, 66, 66, 67, 67, 67, 68, 68, 68, 68, 68, 68,
-        68, 69, 71, 72, 74, 75, 75, 75, 75, 75, 75, 77, 66, 66, 66, 67, 67, 68,
-        68, 68, 68, 68, 68, 68, 68, 69, 69, 69, 69, 69, 69, 69, 69, 71, 72, 74,
-        75, 77, 77, 77, 77, 77, 77, 78, 67, 67, 68, 68, 69, 69, 69, 69, 69, 69,
-        69, 70, 70, 70, 71, 71, 71, 71, 71, 71, 71, 72, 74, 75, 77, 78, 78, 78,
-        78, 78, 78, 80, 67, 67, 68, 68, 69, 69, 69, 69, 69, 69, 69, 70, 70, 70,
-        71, 71, 71, 71, 71, 71, 71, 72, 74, 75, 77, 78, 78, 78, 78, 78, 78, 80,
-        67, 67, 68, 68, 69, 69, 69, 69, 69, 69, 69, 70, 70, 70, 71, 71, 71, 71,
-        71, 71, 71, 72, 74, 75, 77, 78, 78, 78, 78, 78, 78, 80, 67, 67, 68, 68,
-        69, 69, 69, 69, 69, 69, 69, 70, 70, 70, 71, 71, 71, 71, 71, 71, 71, 72,
-        74, 75, 77, 78, 78, 78, 78, 78, 78, 80, 67, 67, 68, 68, 69, 69, 69, 69,
-        69, 69, 69, 70, 70, 70, 71, 71, 71, 71, 71, 71, 71, 72, 74, 75, 77, 78,
-        78, 78, 78, 78, 78, 80, 67, 67, 68, 68, 69, 69, 69, 69, 69, 69, 69, 70,
-        70, 70, 71, 71, 71, 71, 71, 71, 71, 72, 74, 75, 77, 78, 78, 78, 78, 78,
-        78, 80, 68, 69, 69, 70, 70, 71, 71, 71, 71, 71, 71, 71, 71, 72, 72, 73,
-        73, 73, 73, 73, 73, 74, 75, 77, 78, 80, 80, 80, 80, 80, 80, 81,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30,
+        30, 30, 30, 31, 31, 32, 33, 33, 33, 33, 33, 33, 33, 34, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 31,
+        31, 32, 33, 33, 33, 33, 33, 33, 33, 34, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 31, 32, 32, 33, 34,
+        34, 34, 34, 34, 34, 34, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 33, 34, 34, 34, 34, 34,
+        34, 35, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 32, 33, 33, 34, 34, 34, 34, 34, 34, 35, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 32, 32, 33, 34, 34, 34, 34, 34, 34, 34, 35, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 33,
+        34, 34, 34, 34, 34, 34, 34, 35, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 33, 34, 34, 34, 34,
+        34, 34, 34, 35, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 32, 33, 34, 34, 34, 34, 34, 34, 34, 35,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 32, 32, 33, 34, 34, 34, 34, 34, 34, 34, 35, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
+        32, 33, 34, 34, 34, 34, 34, 34, 34, 35, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 33, 34, 35,
+        35, 35, 35, 35, 35, 35, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 33, 34, 35, 35, 35, 35, 35,
+        35, 35, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 32, 33, 33, 34, 35, 35, 35, 35, 35, 35, 36, 30, 30,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 32, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 30, 30, 30, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 34,
+        34, 35, 35, 35, 35, 35, 35, 36, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 35,
+        35, 35, 35, 36, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36,
+        30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 30, 30, 30, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
+        33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 30, 30, 30, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35,
+        35, 35, 35, 35, 35, 36, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 36, 36, 36, 36, 36,
+        36, 37, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 34, 34, 35, 36, 37, 37, 37, 37, 37, 37, 37, 32, 32,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34,
+        34, 34, 35, 36, 37, 37, 37, 37, 37, 37, 37, 38, 33, 33, 33, 33, 33, 34,
+        34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 36, 37,
+        37, 38, 38, 38, 38, 38, 38, 39, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34,
+        34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 37, 37, 38, 39, 39, 39,
+        39, 39, 39, 40, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35,
+        35, 35, 35, 35, 35, 35, 35, 36, 37, 37, 38, 39, 39, 39, 39, 39, 39, 40,
+        33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35,
+        35, 35, 35, 36, 37, 37, 38, 39, 39, 39, 39, 39, 39, 40, 33, 33, 34, 34,
+        34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36,
+        37, 37, 38, 39, 39, 39, 39, 39, 39, 40, 33, 33, 34, 34, 34, 34, 34, 34,
+        34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 37, 37, 38, 39,
+        39, 39, 39, 39, 39, 40, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35,
+        35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 37, 37, 38, 39, 39, 39, 39, 39,
+        39, 40, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 36, 36,
+        36, 36, 36, 36, 36, 37, 37, 38, 39, 40, 40, 40, 40, 40, 40, 40,
         /* Size 4x8 */
-        63, 62, 62, 69, 63, 63, 63, 71, 63, 63, 63, 71, 62, 64, 64, 72, 62, 64,
-        64, 73, 63, 66, 66, 74, 68, 72, 72, 80, 68, 72, 72, 80,
+        31, 31, 31, 34, 31, 31, 31, 35, 31, 31, 31, 35, 31, 32, 32, 36, 31, 32,
+        32, 36, 31, 33, 33, 37, 34, 36, 36, 40, 34, 36, 36, 40,
         /* Size 8x4 */
-        63, 63, 63, 62, 62, 63, 68, 68, 62, 63, 63, 64, 64, 66, 72, 72, 62, 63,
-        63, 64, 64, 66, 72, 72, 69, 71, 71, 72, 73, 74, 80, 80,
+        31, 31, 31, 31, 31, 31, 34, 34, 31, 31, 31, 32, 32, 33, 36, 36, 31, 31,
+        31, 32, 32, 33, 36, 36, 34, 35, 35, 36, 36, 37, 40, 40,
         /* Size 8x16 */
-        64, 63, 62, 62, 62, 62, 66, 71, 63, 63, 62, 62, 62, 62, 67, 72, 63, 63,
-        63, 63, 63, 63, 68, 73, 63, 63, 63, 63, 63, 63, 68, 74, 63, 63, 63, 63,
-        63, 63, 68, 74, 63, 63, 63, 63, 63, 63, 68, 74, 62, 63, 63, 64, 64, 64,
-        69, 75, 61, 62, 63, 64, 64, 64, 69, 76, 61, 62, 64, 64, 64, 64, 70, 76,
-        61, 62, 64, 64, 64, 64, 70, 76, 61, 62, 64, 64, 64, 64, 70, 76, 63, 65,
-        66, 67, 67, 67, 72, 79, 66, 68, 69, 70, 70, 70, 75, 81, 67, 69, 71, 72,
-        72, 72, 77, 83, 67, 69, 71, 72, 72, 72, 77, 83, 67, 69, 71, 72, 72, 72,
-        77, 83,
+        32, 31, 31, 31, 31, 31, 33, 35, 31, 31, 31, 31, 31, 31, 33, 36, 31, 31,
+        31, 31, 31, 31, 34, 36, 31, 31, 31, 31, 31, 31, 34, 37, 31, 31, 31, 31,
+        31, 31, 34, 37, 31, 31, 31, 31, 31, 31, 34, 37, 31, 31, 31, 32, 32, 32,
+        34, 37, 30, 31, 31, 32, 32, 32, 34, 38, 30, 31, 32, 32, 32, 32, 35, 38,
+        30, 31, 32, 32, 32, 32, 35, 38, 30, 31, 32, 32, 32, 32, 35, 38, 31, 32,
+        33, 33, 33, 33, 36, 39, 33, 34, 34, 35, 35, 35, 37, 40, 33, 34, 35, 36,
+        36, 36, 38, 41, 33, 34, 35, 36, 36, 36, 38, 41, 33, 34, 35, 36, 36, 36,
+        38, 41,
         /* Size 16x8 */
-        64, 63, 63, 63, 63, 63, 62, 61, 61, 61, 61, 63, 66, 67, 67, 67, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 62, 62, 65, 68, 69, 69, 69, 62, 62, 63, 63,
-        63, 63, 63, 63, 64, 64, 64, 66, 69, 71, 71, 71, 62, 62, 63, 63, 63, 63,
-        64, 64, 64, 64, 64, 67, 70, 72, 72, 72, 62, 62, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 67, 70, 72, 72, 72, 62, 62, 63, 63, 63, 63, 64, 64, 64, 64,
-        64, 67, 70, 72, 72, 72, 66, 67, 68, 68, 68, 68, 69, 69, 70, 70, 70, 72,
-        75, 77, 77, 77, 71, 72, 73, 74, 74, 74, 75, 76, 76, 76, 76, 79, 81, 83,
-        83, 83,
+        32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 31, 33, 33, 33, 33, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 34, 34, 34, 34, 31, 31, 31, 31,
+        31, 31, 31, 31, 32, 32, 32, 33, 34, 35, 35, 35, 31, 31, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 33, 35, 36, 36, 36, 31, 31, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 33, 35, 36, 36, 36, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 33, 35, 36, 36, 36, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 36,
+        37, 38, 38, 38, 35, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 40, 41,
+        41, 41,
         /* Size 16x32 */
-        64, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 64, 66, 68, 71, 74, 63, 63,
-        63, 62, 62, 62, 62, 62, 62, 62, 62, 64, 66, 69, 71, 74, 63, 63, 63, 63,
-        62, 62, 62, 62, 62, 62, 62, 64, 67, 69, 72, 75, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 65, 67, 70, 73, 76, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 65, 68, 70, 73, 76, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 66, 68, 71, 74, 77, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 66,
-        68, 71, 74, 77, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 66, 68, 71,
-        74, 77, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 66, 68, 71, 74, 77,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 66, 68, 71, 74, 77, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 66, 68, 71, 74, 77, 62, 62, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 66, 68, 71, 74, 77, 62, 62, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 66, 69, 72, 75, 78, 62, 62, 62, 63, 63, 64, 64, 64,
-        64, 64, 64, 66, 69, 72, 75, 79, 61, 62, 62, 63, 63, 64, 64, 64, 64, 64,
-        64, 67, 69, 72, 76, 79, 61, 62, 62, 63, 64, 64, 64, 64, 64, 64, 64, 67,
-        70, 73, 76, 80, 61, 62, 62, 63, 64, 64, 64, 64, 64, 64, 64, 67, 70, 73,
-        76, 80, 61, 62, 62, 63, 64, 64, 64, 64, 64, 64, 64, 67, 70, 73, 76, 80,
-        61, 62, 62, 63, 64, 64, 64, 64, 64, 64, 64, 67, 70, 73, 76, 80, 61, 62,
-        62, 63, 64, 64, 64, 64, 64, 64, 64, 67, 70, 73, 76, 80, 61, 62, 62, 63,
-        64, 64, 64, 64, 64, 64, 64, 67, 70, 73, 76, 80, 62, 63, 63, 64, 65, 66,
-        66, 66, 66, 66, 66, 68, 71, 74, 77, 81, 63, 64, 65, 66, 66, 67, 67, 67,
-        67, 67, 67, 70, 72, 75, 79, 82, 65, 65, 66, 67, 68, 68, 68, 68, 68, 68,
-        68, 71, 74, 77, 80, 83, 66, 67, 68, 68, 69, 70, 70, 70, 70, 70, 70, 73,
-        75, 78, 81, 85, 67, 68, 69, 70, 71, 72, 72, 72, 72, 72, 72, 74, 77, 80,
-        83, 86, 67, 68, 69, 70, 71, 72, 72, 72, 72, 72, 72, 74, 77, 80, 83, 86,
-        67, 68, 69, 70, 71, 72, 72, 72, 72, 72, 72, 74, 77, 80, 83, 86, 67, 68,
-        69, 70, 71, 72, 72, 72, 72, 72, 72, 74, 77, 80, 83, 86, 67, 68, 69, 70,
-        71, 72, 72, 72, 72, 72, 72, 74, 77, 80, 83, 86, 67, 68, 69, 70, 71, 72,
-        72, 72, 72, 72, 72, 74, 77, 80, 83, 86, 69, 69, 70, 71, 72, 73, 73, 73,
-        73, 73, 73, 76, 78, 81, 84, 88,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 35, 37, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 35, 37, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 36, 37, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 32, 33, 35, 36, 38, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 32, 34, 35, 36, 38, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 33, 34, 35, 37, 38, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33,
+        34, 35, 37, 38, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 35,
+        37, 38, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 35, 37, 38,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 35, 37, 38, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 34, 35, 37, 38, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 33, 34, 35, 37, 38, 31, 31, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 33, 34, 36, 37, 39, 31, 31, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 33, 34, 36, 37, 39, 30, 31, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 33, 34, 36, 38, 39, 30, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33,
+        35, 36, 38, 40, 30, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 35, 36,
+        38, 40, 30, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 35, 36, 38, 40,
+        30, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 35, 36, 38, 40, 30, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 35, 36, 38, 40, 30, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 33, 35, 36, 38, 40, 31, 31, 31, 32, 32, 33,
+        33, 33, 33, 33, 33, 34, 35, 37, 38, 40, 31, 32, 32, 33, 33, 33, 33, 33,
+        33, 33, 33, 35, 36, 37, 39, 41, 32, 32, 33, 33, 34, 34, 34, 34, 34, 34,
+        34, 35, 37, 38, 40, 41, 33, 33, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36,
+        37, 39, 40, 42, 33, 34, 34, 35, 35, 36, 36, 36, 36, 36, 36, 37, 38, 40,
+        41, 43, 33, 34, 34, 35, 35, 36, 36, 36, 36, 36, 36, 37, 38, 40, 41, 43,
+        33, 34, 34, 35, 35, 36, 36, 36, 36, 36, 36, 37, 38, 40, 41, 43, 33, 34,
+        34, 35, 35, 36, 36, 36, 36, 36, 36, 37, 38, 40, 41, 43, 33, 34, 34, 35,
+        35, 36, 36, 36, 36, 36, 36, 37, 38, 40, 41, 43, 33, 34, 34, 35, 35, 36,
+        36, 36, 36, 36, 36, 37, 38, 40, 41, 43, 34, 34, 35, 35, 36, 36, 36, 36,
+        36, 36, 36, 38, 39, 40, 42, 44,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 61, 61, 61,
-        61, 61, 61, 62, 63, 65, 66, 67, 67, 67, 67, 67, 67, 69, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63,
-        64, 65, 67, 68, 68, 68, 68, 68, 68, 69, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 63, 65, 66, 68, 69,
-        69, 69, 69, 69, 69, 70, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 66, 67, 68, 70, 70, 70, 70, 70,
-        70, 71, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 65, 66, 68, 69, 71, 71, 71, 71, 71, 71, 72, 62, 62,
-        62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 66, 67, 68, 70, 72, 72, 72, 72, 72, 72, 73, 62, 62, 62, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 66, 67, 68,
-        70, 72, 72, 72, 72, 72, 72, 73, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 66, 67, 68, 70, 72, 72, 72,
-        72, 72, 72, 73, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 66, 67, 68, 70, 72, 72, 72, 72, 72, 72, 73,
-        62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 66, 67, 68, 70, 72, 72, 72, 72, 72, 72, 73, 62, 62, 62, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 66,
-        67, 68, 70, 72, 72, 72, 72, 72, 72, 73, 64, 64, 64, 65, 65, 66, 66, 66,
-        66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 68, 70, 71, 73, 74,
-        74, 74, 74, 74, 74, 76, 66, 66, 67, 67, 68, 68, 68, 68, 68, 68, 68, 68,
-        69, 69, 69, 70, 70, 70, 70, 70, 70, 71, 72, 74, 75, 77, 77, 77, 77, 77,
-        77, 78, 68, 69, 69, 70, 70, 71, 71, 71, 71, 71, 71, 71, 72, 72, 72, 73,
-        73, 73, 73, 73, 73, 74, 75, 77, 78, 80, 80, 80, 80, 80, 80, 81, 71, 71,
-        72, 73, 73, 74, 74, 74, 74, 74, 74, 74, 75, 75, 76, 76, 76, 76, 76, 76,
-        76, 77, 79, 80, 81, 83, 83, 83, 83, 83, 83, 84, 74, 74, 75, 76, 76, 77,
-        77, 77, 77, 77, 77, 77, 78, 79, 79, 80, 80, 80, 80, 80, 80, 81, 82, 83,
-        85, 86, 86, 86, 86, 86, 86, 88,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30,
+        30, 30, 30, 31, 31, 32, 33, 33, 33, 33, 33, 33, 33, 34, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        32, 32, 33, 34, 34, 34, 34, 34, 34, 34, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34,
+        34, 34, 34, 34, 34, 35, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 33, 34, 35, 35, 35, 35, 35,
+        35, 35, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 33, 34, 34, 35, 35, 35, 35, 35, 35, 36, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 34, 35, 36, 36, 36, 36, 36, 36, 36, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34,
+        35, 36, 36, 36, 36, 36, 36, 36, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 35, 36, 36, 36,
+        36, 36, 36, 36, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 35, 36, 36, 36, 36, 36, 36, 36,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 33, 33, 34, 35, 36, 36, 36, 36, 36, 36, 36, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33,
+        33, 34, 35, 36, 36, 36, 36, 36, 36, 36, 32, 32, 32, 32, 32, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 35, 35, 36, 37,
+        37, 37, 37, 37, 37, 38, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34,
+        34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 36, 37, 37, 38, 38, 38, 38, 38,
+        38, 39, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36,
+        36, 36, 36, 36, 36, 37, 37, 38, 39, 40, 40, 40, 40, 40, 40, 40, 35, 35,
+        36, 36, 36, 37, 37, 37, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38,
+        38, 38, 39, 40, 40, 41, 41, 41, 41, 41, 41, 42, 37, 37, 37, 38, 38, 38,
+        38, 38, 38, 38, 38, 38, 39, 39, 39, 40, 40, 40, 40, 40, 40, 40, 41, 41,
+        42, 43, 43, 43, 43, 43, 43, 44,
         /* Size 4x16 */
-        63, 62, 62, 68, 63, 62, 62, 69, 63, 63, 63, 70, 63, 63, 63, 71, 63, 63,
-        63, 71, 63, 63, 63, 71, 62, 64, 64, 72, 62, 64, 64, 72, 62, 64, 64, 73,
-        62, 64, 64, 73, 62, 64, 64, 73, 64, 67, 67, 75, 67, 70, 70, 78, 68, 72,
-        72, 80, 68, 72, 72, 80, 68, 72, 72, 80,
+        31, 31, 31, 34, 31, 31, 31, 34, 31, 31, 31, 35, 31, 31, 31, 35, 31, 31,
+        31, 35, 31, 31, 31, 35, 31, 32, 32, 36, 31, 32, 32, 36, 31, 32, 32, 36,
+        31, 32, 32, 36, 31, 32, 32, 36, 32, 33, 33, 37, 33, 35, 35, 39, 34, 36,
+        36, 40, 34, 36, 36, 40, 34, 36, 36, 40,
         /* Size 16x4 */
-        63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 64, 67, 68, 68, 68, 62, 62,
-        63, 63, 63, 63, 64, 64, 64, 64, 64, 67, 70, 72, 72, 72, 62, 62, 63, 63,
-        63, 63, 64, 64, 64, 64, 64, 67, 70, 72, 72, 72, 68, 69, 70, 71, 71, 71,
-        72, 72, 73, 73, 73, 75, 78, 80, 80, 80,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 34, 34, 31, 31,
+        31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 35, 36, 36, 36, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 33, 35, 36, 36, 36, 34, 34, 35, 35, 35, 35,
+        36, 36, 36, 36, 36, 37, 39, 40, 40, 40,
         /* Size 8x32 */
-        64, 63, 62, 62, 62, 62, 66, 71, 63, 63, 62, 62, 62, 62, 66, 71, 63, 63,
-        62, 62, 62, 62, 67, 72, 63, 63, 63, 63, 63, 63, 67, 73, 63, 63, 63, 63,
-        63, 63, 68, 73, 63, 63, 63, 63, 63, 63, 68, 74, 63, 63, 63, 63, 63, 63,
-        68, 74, 63, 63, 63, 63, 63, 63, 68, 74, 63, 63, 63, 63, 63, 63, 68, 74,
-        63, 63, 63, 63, 63, 63, 68, 74, 63, 63, 63, 63, 63, 63, 68, 74, 62, 63,
-        63, 63, 63, 63, 68, 74, 62, 63, 63, 64, 64, 64, 69, 75, 62, 62, 63, 64,
-        64, 64, 69, 75, 61, 62, 63, 64, 64, 64, 69, 76, 61, 62, 64, 64, 64, 64,
-        70, 76, 61, 62, 64, 64, 64, 64, 70, 76, 61, 62, 64, 64, 64, 64, 70, 76,
-        61, 62, 64, 64, 64, 64, 70, 76, 61, 62, 64, 64, 64, 64, 70, 76, 61, 62,
-        64, 64, 64, 64, 70, 76, 62, 63, 65, 66, 66, 66, 71, 77, 63, 65, 66, 67,
-        67, 67, 72, 79, 65, 66, 68, 68, 68, 68, 74, 80, 66, 68, 69, 70, 70, 70,
-        75, 81, 67, 69, 71, 72, 72, 72, 77, 83, 67, 69, 71, 72, 72, 72, 77, 83,
-        67, 69, 71, 72, 72, 72, 77, 83, 67, 69, 71, 72, 72, 72, 77, 83, 67, 69,
-        71, 72, 72, 72, 77, 83, 67, 69, 71, 72, 72, 72, 77, 83, 69, 70, 72, 73,
-        73, 73, 78, 84,
+        32, 31, 31, 31, 31, 31, 33, 35, 31, 31, 31, 31, 31, 31, 33, 35, 31, 31,
+        31, 31, 31, 31, 33, 36, 31, 31, 31, 31, 31, 31, 33, 36, 31, 31, 31, 31,
+        31, 31, 34, 36, 31, 31, 31, 31, 31, 31, 34, 37, 31, 31, 31, 31, 31, 31,
+        34, 37, 31, 31, 31, 31, 31, 31, 34, 37, 31, 31, 31, 31, 31, 31, 34, 37,
+        31, 31, 31, 31, 31, 31, 34, 37, 31, 31, 31, 31, 31, 31, 34, 37, 31, 31,
+        31, 31, 31, 31, 34, 37, 31, 31, 31, 32, 32, 32, 34, 37, 31, 31, 31, 32,
+        32, 32, 34, 37, 30, 31, 31, 32, 32, 32, 34, 38, 30, 31, 32, 32, 32, 32,
+        35, 38, 30, 31, 32, 32, 32, 32, 35, 38, 30, 31, 32, 32, 32, 32, 35, 38,
+        30, 31, 32, 32, 32, 32, 35, 38, 30, 31, 32, 32, 32, 32, 35, 38, 30, 31,
+        32, 32, 32, 32, 35, 38, 31, 31, 32, 33, 33, 33, 35, 38, 31, 32, 33, 33,
+        33, 33, 36, 39, 32, 33, 34, 34, 34, 34, 37, 40, 33, 34, 34, 35, 35, 35,
+        37, 40, 33, 34, 35, 36, 36, 36, 38, 41, 33, 34, 35, 36, 36, 36, 38, 41,
+        33, 34, 35, 36, 36, 36, 38, 41, 33, 34, 35, 36, 36, 36, 38, 41, 33, 34,
+        35, 36, 36, 36, 38, 41, 33, 34, 35, 36, 36, 36, 38, 41, 34, 35, 36, 36,
+        36, 36, 39, 42,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 61, 61, 61,
-        61, 61, 61, 62, 63, 65, 66, 67, 67, 67, 67, 67, 67, 69, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 63,
-        65, 66, 68, 69, 69, 69, 69, 69, 69, 70, 62, 62, 62, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 65, 66, 68, 69, 71,
-        71, 71, 71, 71, 71, 72, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 66, 67, 68, 70, 72, 72, 72, 72, 72,
-        72, 73, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 66, 67, 68, 70, 72, 72, 72, 72, 72, 72, 73, 62, 62,
-        62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 66, 67, 68, 70, 72, 72, 72, 72, 72, 72, 73, 66, 66, 67, 67, 68, 68,
-        68, 68, 68, 68, 68, 68, 69, 69, 69, 70, 70, 70, 70, 70, 70, 71, 72, 74,
-        75, 77, 77, 77, 77, 77, 77, 78, 71, 71, 72, 73, 73, 74, 74, 74, 74, 74,
-        74, 74, 75, 75, 76, 76, 76, 76, 76, 76, 76, 77, 79, 80, 81, 83, 83, 83,
-        83, 83, 83, 84 },
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30,
+        30, 30, 30, 31, 31, 32, 33, 33, 33, 33, 33, 33, 33, 34, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        32, 33, 34, 34, 34, 34, 34, 34, 34, 35, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 33, 34, 34, 35,
+        35, 35, 35, 35, 35, 36, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 35, 36, 36, 36, 36, 36,
+        36, 36, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 33, 33, 34, 35, 36, 36, 36, 36, 36, 36, 36, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 33, 33, 34, 35, 36, 36, 36, 36, 36, 36, 36, 33, 33, 33, 33, 34, 34,
+        34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 36, 37,
+        37, 38, 38, 38, 38, 38, 38, 39, 35, 35, 36, 36, 36, 37, 37, 37, 37, 37,
+        37, 37, 37, 37, 38, 38, 38, 38, 38, 38, 38, 38, 39, 40, 40, 41, 41, 41,
+        41, 41, 41, 42 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        63, 63, 63, 64,
+        31, 31, 31, 32,
 #endif
         /* Size 4x4 */
-        63, 63, 63, 63, 63, 64, 64, 64, 63, 64, 64, 64, 63, 64, 64, 64,
+        31, 31, 31, 31, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32,
         /* Size 8x8 */
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64,
-        64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64,
-        64, 64, 63, 63, 64, 64, 64, 64, 64, 65,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
+        32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
+        32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
         /* Size 16x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 65, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 63, 63, 63, 63, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 65, 65, 65, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x8 */
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 63, 64, 64, 64, 63, 64,
-        64, 64, 63, 64, 64, 64, 63, 64, 64, 64, 63, 64, 64, 65,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32,
+        32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32,
         /* Size 8x4 */
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63,
-        64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 65,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31,
+        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
         /* Size 8x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 63, 63, 63, 64,
-        64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64,
-        64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64,
-        63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63,
-        64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64,
-        64, 64, 64, 64, 63, 63, 64, 64, 64, 65, 65, 65, 63, 63, 64, 64, 64, 65,
-        65, 65,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 31, 31, 31, 32,
+        32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
+        32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
+        31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31,
+        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
+        32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
+        32, 32,
         /* Size 16x8 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32,
         /* Size 16x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 65, 65, 65, 65, 65, 65, 65,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 63, 63, 63, 63,
-        63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 63, 63, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 63, 63,
-        63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 63, 63, 63, 63, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x16 */
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 63, 64,
-        64, 64, 63, 64, 64, 64, 63, 64, 64, 64, 63, 64, 64, 64, 63, 64, 64, 64,
-        63, 64, 64, 64, 63, 64, 64, 64, 63, 64, 64, 64, 63, 64, 64, 64, 63, 64,
-        64, 64, 63, 64, 64, 65, 63, 64, 65, 65,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 31, 32,
+        32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32,
+        31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31, 32,
+        32, 32, 31, 32, 32, 32, 31, 32, 32, 32,
         /* Size 16x4 */
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64,
-        64, 64, 63, 63, 63, 64, 64, 64, 64, 64, 63, 63, 63, 64, 64, 64, 64, 64,
-        63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63,
-        64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64,
-        64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64,
-        64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64,
-        63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63,
-        64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64,
-        64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64,
-        64, 64, 63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, 64,
-        63, 63, 64, 64, 64, 64, 64, 64, 63, 63, 64, 64, 64, 65, 65, 65, 63, 63,
-        64, 64, 64, 65, 65, 65, 63, 63, 64, 64, 64, 65, 65, 65, 63, 63, 64, 64,
-        64, 65, 65, 65,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
+        32, 32, 31, 31, 31, 32, 32, 32, 32, 32, 31, 31, 31, 32, 32, 32, 32, 32,
+        31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31,
+        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
+        32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
+        32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
+        31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31,
+        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
+        32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
+        32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32,
+        31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31,
+        32, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32, 32, 32, 31, 31, 32, 32,
+        32, 32, 32, 32,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 63, 63, 63, 63, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65 },
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        63, 62, 62, 63,
+        31, 31, 31, 31,
 #endif
         /* Size 4x4 */
-        63, 62, 62, 62, 62, 63, 63, 63, 62, 63, 63, 63, 62, 63, 63, 63,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
         /* Size 8x8 */
-        63, 63, 63, 62, 62, 62, 62, 61, 63, 63, 63, 63, 63, 62, 62, 62, 63, 63,
-        63, 63, 63, 63, 62, 62, 62, 63, 63, 63, 63, 63, 63, 62, 62, 63, 63, 63,
-        63, 63, 63, 62, 62, 62, 63, 63, 63, 63, 63, 63, 62, 62, 62, 63, 63, 63,
-        63, 63, 61, 62, 62, 62, 62, 63, 63, 63,
+        31, 31, 31, 31, 31, 31, 31, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 30, 31, 31, 31, 31, 31, 31, 31,
         /* Size 16x16 */
-        64, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 61, 61, 61, 63, 63,
-        63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 61, 61, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 61, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62,
-        62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 61, 62, 62, 62, 62, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 61, 61, 62, 62, 62, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 61, 61, 61, 62, 62, 62, 62, 62, 62, 62, 62, 63,
-        63, 63, 63, 64,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 32,
         /* Size 32x32 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62,
-        62, 62, 62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 61, 61, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
-        62, 62, 62, 62, 61, 61, 61, 61, 61, 61, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
-        62, 61, 61, 61, 61, 61, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62,
-        62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 61, 61,
-        61, 61, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 61, 61, 61, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62,
-        62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62,
-        62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62,
-        62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62,
-        62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62,
-        62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62,
-        62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62,
-        62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62,
-        62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 61, 61, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        61, 61, 61, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 61, 61, 61, 61,
-        62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 61, 61, 61, 61, 61, 62, 62, 62,
-        62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 61, 61, 61, 61, 61, 62, 62, 62, 62, 62, 62, 62,
-        62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        64, 64, 61, 61, 61, 61, 61, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
-        62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30,
+        30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        32, 32, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
         /* Size 4x8 */
-        63, 63, 62, 62, 63, 63, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 62, 63, 63, 63, 62, 63, 64, 64, 61, 63, 64, 64,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 30, 31, 32, 32,
         /* Size 8x4 */
-        63, 63, 63, 63, 63, 62, 62, 61, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62,
-        63, 63, 63, 63, 64, 64, 62, 62, 63, 63, 63, 63, 64, 64,
+        31, 31, 31, 31, 31, 31, 31, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 32, 32, 31, 31, 31, 31, 31, 31, 32, 32,
         /* Size 8x16 */
-        64, 63, 63, 62, 62, 62, 62, 62, 63, 63, 63, 62, 62, 62, 62, 62, 63, 63,
-        63, 63, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62,
-        63, 63, 63, 63, 63, 63, 62, 62, 63, 63, 63, 64, 64, 64, 62, 62, 62, 63,
-        63, 64, 64, 64, 61, 62, 62, 63, 63, 64, 64, 64, 61, 62, 62, 63, 64, 64,
-        64, 64,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 31, 31, 31, 31,
+        31, 32, 32, 32, 30, 31, 31, 31, 31, 32, 32, 32, 30, 31, 31, 31, 32, 32,
+        32, 32,
         /* Size 16x8 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 61, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 64, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 64, 64, 64, 64, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        64, 64, 64, 64, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64,
-        64, 64,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
+        32, 32,
         /* Size 16x32 */
-        64, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63,
-        63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63,
-        63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63,
-        63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 62,
-        62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62,
-        62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63,
-        64, 64, 64, 64, 64, 64, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 64, 64,
-        64, 64, 64, 64, 62, 62, 62, 62, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 62, 62, 62, 62, 62, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64,
-        61, 62, 62, 62, 62, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 61, 62,
-        62, 62, 62, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 61, 61, 62, 62,
-        62, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 61, 61, 62, 62, 62, 63,
-        63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 61, 61, 62, 62, 62, 63, 63, 63,
-        64, 64, 64, 64, 64, 64, 64, 64,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
+        30, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 30, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 30, 30, 31, 31,
+        31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 30, 30, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 30, 30, 31, 31, 31, 31, 31, 31,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 32x16 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 61, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62,
-        62, 62, 62, 62, 62, 62, 62, 61, 61, 61, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62,
-        62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62,
-        62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64,
-        62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 62, 62, 62, 62,
-        62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 62, 62, 62, 62, 62, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 62,
-        62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 62, 62, 62, 62, 62,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 64, 64,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x16 */
-        63, 63, 62, 62, 63, 63, 62, 62, 63, 63, 62, 62, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 62, 63, 63, 63, 62, 63, 63, 64, 62, 63,
-        64, 64, 62, 63, 64, 64, 61, 63, 64, 64,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 31, 31,
+        32, 32, 31, 31, 32, 32, 30, 31, 32, 32,
         /* Size 16x4 */
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 61, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 62, 62, 62, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 64, 64, 64, 64,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
         /* Size 8x32 */
-        64, 63, 63, 62, 62, 62, 62, 62, 63, 63, 63, 62, 62, 62, 62, 62, 63, 63,
-        63, 62, 62, 62, 62, 62, 63, 63, 63, 63, 62, 62, 62, 62, 63, 63, 63, 63,
-        62, 62, 62, 62, 63, 63, 63, 63, 63, 62, 62, 62, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 62, 63, 63, 63, 63, 63, 63, 63, 62, 62, 63, 63,
-        63, 63, 63, 63, 62, 62, 63, 63, 63, 64, 64, 64, 62, 62, 63, 63, 63, 64,
-        64, 64, 62, 62, 63, 63, 63, 64, 64, 64, 62, 62, 62, 63, 63, 64, 64, 64,
-        61, 62, 62, 63, 63, 64, 64, 64, 61, 62, 62, 63, 63, 64, 64, 64, 61, 62,
-        62, 63, 64, 64, 64, 64, 61, 62, 62, 63, 64, 64, 64, 64, 61, 62, 62, 63,
-        64, 64, 64, 64,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 31, 31, 31, 31, 31, 32,
+        32, 32, 31, 31, 31, 31, 31, 32, 32, 32, 31, 31, 31, 31, 31, 32, 32, 32,
+        30, 31, 31, 31, 31, 32, 32, 32, 30, 31, 31, 31, 31, 32, 32, 32, 30, 31,
+        31, 31, 32, 32, 32, 32, 30, 31, 31, 31, 32, 32, 32, 32, 30, 31, 31, 31,
+        32, 32, 32, 32,
         /* Size 32x8 */
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 61, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 62, 62,
-        62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 62, 62, 62, 62, 62,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64,
-        64, 64, 64, 64 },
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
+        32, 32, 32, 32 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        64, 64, 64, 64,
+        32, 32, 32, 32,
 #endif
         /* Size 4x4 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 16x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32,
         /* Size 32x32 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x4 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32,
         /* Size 16x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32,
         /* Size 16x32 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 32x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 16x4 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x32 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32,
         /* Size 32x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64 },
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        64, 64, 64, 64,
+        32, 32, 32, 32,
 #endif
         /* Size 4x4 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 16x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32,
         /* Size 32x32 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x4 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32,
         /* Size 16x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32,
         /* Size 16x32 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 32x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 16x4 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x32 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32,
         /* Size 32x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64 },
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32 },
   },
 };
 
 static uint16_t wt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE] = {
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        48, 24, 24, 12,
+        24, 12, 12, 6,
+#endif
+        /* Size 4x4 */
+        32, 24, 14, 11, 24, 15, 11, 9, 14, 11, 7, 7, 11, 9, 7, 5,
+        /* Size 8x8 */
+        32, 32, 27, 20, 15, 12, 11, 9, 32, 29, 26, 21, 16, 13, 12, 10, 27, 26,
+        19, 16, 13, 11, 10, 10, 20, 21, 16, 12, 11, 9, 9, 8, 15, 16, 13, 11, 9,
+        8, 7, 7, 12, 13, 11, 9, 8, 7, 6, 6, 11, 12, 10, 9, 7, 6, 6, 5, 9, 10,
+        10, 8, 7, 6, 5, 5,
+        /* Size 16x16 */
+        32, 33, 33, 30, 28, 23, 21, 17, 16, 13, 12, 11, 11, 10, 9, 9, 33, 32,
+        32, 31, 30, 25, 23, 19, 17, 14, 14, 12, 11, 11, 10, 9, 33, 32, 31, 29,
+        28, 24, 23, 19, 17, 14, 14, 13, 12, 11, 10, 10, 30, 31, 29, 26, 24, 22,
+        20, 18, 16, 14, 13, 13, 12, 11, 11, 10, 28, 30, 28, 24, 21, 19, 18, 16,
+        15, 13, 13, 12, 11, 11, 10, 10, 23, 25, 24, 22, 19, 16, 15, 14, 13, 11,
+        11, 11, 10, 10, 9, 9, 21, 23, 23, 20, 18, 15, 14, 13, 12, 11, 10, 10, 9,
+        9, 9, 9, 17, 19, 19, 18, 16, 14, 13, 11, 10, 9, 9, 9, 9, 8, 8, 8, 16,
+        17, 17, 16, 15, 13, 12, 10, 10, 9, 8, 8, 8, 8, 8, 7, 13, 14, 14, 14, 13,
+        11, 11, 9, 9, 8, 7, 7, 7, 7, 7, 7, 12, 14, 14, 13, 13, 11, 10, 9, 8, 7,
+        7, 7, 7, 7, 6, 6, 11, 12, 13, 13, 12, 11, 10, 9, 8, 7, 7, 6, 6, 6, 6, 6,
+        11, 11, 12, 12, 11, 10, 9, 9, 8, 7, 7, 6, 6, 6, 5, 5, 10, 11, 11, 11,
+        11, 10, 9, 8, 8, 7, 7, 6, 6, 5, 5, 5, 9, 10, 10, 11, 10, 9, 9, 8, 8, 7,
+        6, 6, 5, 5, 5, 5, 9, 9, 10, 10, 10, 9, 9, 8, 7, 7, 6, 6, 5, 5, 5, 4,
+        /* Size 32x32 */
+        32, 33, 33, 33, 33, 32, 30, 29, 28, 26, 23, 22, 21, 19, 17, 17, 16, 14,
+        13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 33, 32, 32, 32, 32,
+        32, 30, 30, 29, 27, 24, 23, 22, 20, 18, 17, 17, 15, 13, 13, 13, 12, 12,
+        12, 11, 11, 10, 10, 10, 9, 9, 9, 33, 32, 32, 32, 32, 32, 31, 30, 30, 28,
+        25, 24, 23, 21, 19, 18, 17, 16, 14, 14, 14, 13, 12, 12, 11, 11, 11, 10,
+        10, 9, 9, 9, 33, 32, 32, 32, 31, 31, 30, 29, 29, 27, 25, 24, 23, 21, 19,
+        18, 17, 16, 14, 14, 14, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 33,
+        32, 32, 31, 31, 30, 29, 28, 28, 26, 24, 23, 23, 20, 19, 18, 17, 16, 14,
+        14, 14, 13, 13, 12, 12, 12, 11, 11, 10, 10, 10, 9, 32, 32, 32, 31, 30,
+        29, 28, 28, 27, 26, 24, 23, 22, 21, 19, 19, 18, 16, 15, 15, 14, 13, 13,
+        12, 12, 12, 11, 11, 10, 10, 10, 9, 30, 30, 31, 30, 29, 28, 26, 25, 24,
+        23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 14, 13, 13, 13, 12, 12, 12, 11,
+        11, 11, 10, 10, 9, 29, 30, 30, 29, 28, 28, 25, 24, 23, 22, 20, 20, 19,
+        18, 17, 16, 16, 15, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10,
+        10, 28, 29, 30, 29, 28, 27, 24, 23, 21, 20, 19, 19, 18, 17, 16, 16, 15,
+        14, 13, 13, 13, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 26, 27, 28,
+        27, 26, 26, 23, 22, 20, 19, 18, 17, 17, 16, 15, 14, 14, 13, 12, 12, 12,
+        11, 11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 23, 24, 25, 25, 24, 24, 22,
+        20, 19, 18, 16, 16, 15, 14, 14, 13, 13, 12, 11, 11, 11, 11, 11, 11, 10,
+        10, 10, 10, 9, 9, 9, 9, 22, 23, 24, 24, 23, 23, 21, 20, 19, 17, 16, 15,
+        15, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9,
+        8, 21, 22, 23, 23, 23, 22, 20, 19, 18, 17, 15, 15, 14, 13, 13, 12, 12,
+        11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 19, 20, 21, 21, 20,
+        21, 19, 18, 17, 16, 14, 14, 13, 12, 12, 12, 11, 11, 10, 10, 10, 9, 9, 9,
+        9, 9, 9, 9, 9, 8, 8, 8, 17, 18, 19, 19, 19, 19, 18, 17, 16, 15, 14, 13,
+        13, 12, 11, 11, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 17,
+        17, 18, 18, 18, 19, 17, 16, 16, 14, 13, 13, 12, 12, 11, 10, 10, 10, 9,
+        9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 16, 17, 17, 17, 17, 18, 16, 16,
+        15, 14, 13, 12, 12, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        7, 7, 7, 14, 15, 16, 16, 16, 16, 15, 15, 14, 13, 12, 12, 11, 11, 10, 10,
+        9, 9, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 13, 13, 14, 14, 14, 15,
+        14, 13, 13, 12, 11, 11, 11, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7,
+        7, 7, 7, 7, 7, 13, 13, 14, 14, 14, 15, 14, 13, 13, 12, 11, 11, 11, 10,
+        9, 9, 9, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 12, 13, 14, 14,
+        14, 14, 13, 13, 13, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 7, 7, 7, 7, 7,
+        7, 7, 6, 6, 6, 6, 6, 12, 12, 13, 13, 13, 13, 13, 12, 12, 11, 11, 10, 10,
+        9, 9, 9, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 11, 12, 12, 12,
+        13, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6,
+        6, 6, 6, 6, 6, 6, 6, 11, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 10, 10,
+        9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 11, 11, 11, 12,
+        12, 12, 12, 12, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 6,
+        6, 6, 5, 5, 5, 5, 5, 10, 11, 11, 11, 12, 12, 12, 11, 11, 10, 10, 10, 9,
+        9, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 10, 10, 11, 11,
+        11, 11, 11, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6,
+        5, 5, 5, 5, 5, 5, 10, 10, 10, 11, 11, 11, 11, 11, 10, 10, 10, 9, 9, 9,
+        8, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 9, 10, 10, 10, 10,
+        10, 11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5,
+        5, 5, 5, 5, 5, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 8, 8, 8, 7,
+        7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 9, 9, 9, 10, 10, 10, 10,
+        10, 10, 9, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5,
+        4, 4, 8, 9, 9, 9, 9, 9, 9, 10, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6,
+        6, 6, 5, 5, 5, 5, 5, 5, 4, 4, 4,
+        /* Size 4x8 */
+        32, 24, 14, 11, 31, 24, 15, 12, 28, 18, 12, 11, 21, 14, 10, 9, 16, 12,
+        8, 8, 13, 11, 7, 7, 11, 10, 7, 6, 10, 9, 7, 5,
+        /* Size 8x4 */
+        32, 31, 28, 21, 16, 13, 11, 10, 24, 24, 18, 14, 12, 11, 10, 9, 14, 15,
+        12, 10, 8, 7, 7, 7, 11, 12, 11, 9, 8, 7, 6, 5,
+        /* Size 8x16 */
+        32, 32, 28, 19, 16, 12, 11, 10, 33, 31, 30, 21, 17, 13, 12, 11, 32, 30,
+        28, 20, 17, 13, 12, 12, 30, 28, 24, 19, 16, 13, 13, 12, 28, 27, 21, 17,
+        15, 12, 12, 11, 23, 24, 19, 14, 13, 11, 11, 11, 21, 22, 18, 13, 12, 10,
+        10, 10, 18, 19, 16, 12, 10, 9, 9, 9, 16, 18, 15, 11, 10, 8, 8, 8, 13,
+        15, 13, 10, 9, 7, 8, 8, 12, 14, 13, 10, 8, 7, 7, 7, 11, 13, 12, 10, 8,
+        7, 6, 6, 11, 12, 11, 10, 8, 7, 6, 6, 10, 11, 10, 9, 8, 7, 6, 6, 9, 10,
+        10, 9, 7, 6, 6, 5, 9, 10, 10, 9, 8, 7, 6, 5,
+        /* Size 16x8 */
+        32, 33, 32, 30, 28, 23, 21, 18, 16, 13, 12, 11, 11, 10, 9, 9, 32, 31,
+        30, 28, 27, 24, 22, 19, 18, 15, 14, 13, 12, 11, 10, 10, 28, 30, 28, 24,
+        21, 19, 18, 16, 15, 13, 13, 12, 11, 10, 10, 10, 19, 21, 20, 19, 17, 14,
+        13, 12, 11, 10, 10, 10, 10, 9, 9, 9, 16, 17, 17, 16, 15, 13, 12, 10, 10,
+        9, 8, 8, 8, 8, 7, 8, 12, 13, 13, 13, 12, 11, 10, 9, 8, 7, 7, 7, 7, 7, 6,
+        7, 11, 12, 12, 13, 12, 11, 10, 9, 8, 8, 7, 6, 6, 6, 6, 6, 10, 11, 12,
+        12, 11, 11, 10, 9, 8, 8, 7, 6, 6, 6, 5, 5,
+        /* Size 16x32 */
+        32, 33, 32, 30, 28, 23, 19, 17, 16, 13, 12, 11, 11, 11, 10, 10, 33, 32,
+        32, 30, 29, 24, 20, 18, 17, 14, 12, 12, 12, 11, 11, 11, 33, 32, 31, 31,
+        30, 25, 21, 19, 17, 14, 13, 12, 12, 11, 11, 11, 33, 32, 31, 30, 29, 25,
+        21, 19, 17, 14, 13, 13, 12, 12, 11, 11, 32, 32, 30, 29, 28, 24, 20, 19,
+        17, 14, 13, 13, 12, 12, 12, 11, 32, 31, 29, 28, 27, 24, 21, 19, 18, 15,
+        14, 13, 12, 12, 12, 11, 30, 30, 28, 26, 24, 21, 19, 18, 16, 14, 13, 13,
+        13, 12, 12, 11, 29, 30, 28, 25, 23, 20, 18, 17, 16, 13, 12, 12, 12, 12,
+        12, 11, 28, 30, 27, 24, 21, 19, 17, 16, 15, 13, 12, 12, 12, 12, 11, 11,
+        26, 28, 26, 23, 20, 18, 16, 15, 14, 12, 12, 12, 11, 11, 11, 11, 23, 25,
+        24, 21, 19, 16, 14, 14, 13, 11, 11, 11, 11, 11, 11, 11, 22, 24, 23, 21,
+        19, 16, 14, 13, 12, 11, 10, 10, 10, 10, 10, 10, 21, 23, 22, 20, 18, 15,
+        13, 13, 12, 11, 10, 10, 10, 10, 10, 10, 19, 21, 20, 19, 17, 14, 12, 12,
+        11, 10, 9, 10, 10, 9, 10, 9, 18, 19, 19, 18, 16, 14, 12, 11, 10, 9, 9,
+        9, 9, 9, 9, 9, 17, 18, 18, 17, 16, 13, 12, 11, 10, 9, 9, 9, 9, 9, 9, 9,
+        16, 17, 18, 16, 15, 13, 11, 10, 10, 9, 8, 8, 8, 8, 8, 8, 14, 16, 16, 15,
+        14, 12, 11, 10, 9, 8, 8, 8, 8, 8, 8, 8, 13, 14, 15, 14, 13, 11, 10, 9,
+        9, 8, 7, 8, 8, 8, 8, 8, 13, 14, 14, 14, 13, 11, 10, 9, 9, 8, 7, 7, 7, 7,
+        7, 7, 12, 14, 14, 13, 13, 11, 10, 9, 8, 8, 7, 7, 7, 7, 7, 7, 12, 13, 13,
+        13, 12, 11, 9, 9, 8, 7, 7, 7, 7, 7, 7, 7, 11, 12, 13, 13, 12, 10, 10, 9,
+        8, 7, 7, 7, 6, 6, 6, 7, 11, 12, 12, 12, 11, 10, 10, 9, 8, 7, 7, 6, 6, 6,
+        6, 6, 11, 12, 12, 12, 11, 10, 10, 8, 8, 7, 7, 6, 6, 6, 6, 6, 10, 11, 12,
+        12, 11, 10, 9, 8, 8, 7, 7, 6, 6, 6, 6, 6, 10, 11, 11, 11, 10, 10, 9, 9,
+        8, 7, 7, 6, 6, 6, 6, 6, 10, 11, 11, 11, 10, 10, 9, 9, 8, 7, 7, 6, 6, 5,
+        5, 5, 9, 10, 10, 11, 10, 9, 9, 8, 7, 7, 6, 6, 6, 5, 5, 5, 9, 10, 10, 10,
+        10, 9, 9, 8, 7, 7, 6, 6, 6, 5, 5, 5, 9, 9, 10, 10, 10, 9, 9, 8, 8, 7, 7,
+        6, 6, 5, 5, 5, 8, 9, 9, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 5,
+        /* Size 32x16 */
+        32, 33, 33, 33, 32, 32, 30, 29, 28, 26, 23, 22, 21, 19, 18, 17, 16, 14,
+        13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 33, 32, 32, 32, 32,
+        31, 30, 30, 30, 28, 25, 24, 23, 21, 19, 18, 17, 16, 14, 14, 14, 13, 12,
+        12, 12, 11, 11, 11, 10, 10, 9, 9, 32, 32, 31, 31, 30, 29, 28, 28, 27,
+        26, 24, 23, 22, 20, 19, 18, 18, 16, 15, 14, 14, 13, 13, 12, 12, 12, 11,
+        11, 10, 10, 10, 9, 30, 30, 31, 30, 29, 28, 26, 25, 24, 23, 21, 21, 20,
+        19, 18, 17, 16, 15, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10,
+        10, 28, 29, 30, 29, 28, 27, 24, 23, 21, 20, 19, 19, 18, 17, 16, 16, 15,
+        14, 13, 13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 23, 24, 25,
+        25, 24, 24, 21, 20, 19, 18, 16, 16, 15, 14, 14, 13, 13, 12, 11, 11, 11,
+        11, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 19, 20, 21, 21, 20, 21, 19, 18,
+        17, 16, 14, 14, 13, 12, 12, 12, 11, 11, 10, 10, 10, 9, 10, 10, 10, 9, 9,
+        9, 9, 9, 9, 9, 17, 18, 19, 19, 19, 19, 18, 17, 16, 15, 14, 13, 13, 12,
+        11, 11, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 9, 9, 8, 8, 8, 8, 16, 17, 17,
+        17, 17, 18, 16, 16, 15, 14, 13, 12, 12, 11, 10, 10, 10, 9, 9, 9, 8, 8,
+        8, 8, 8, 8, 8, 8, 7, 7, 8, 8, 13, 14, 14, 14, 14, 15, 14, 13, 13, 12,
+        11, 11, 11, 10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+        12, 12, 13, 13, 13, 14, 13, 12, 12, 12, 11, 10, 10, 9, 9, 9, 8, 8, 7, 7,
+        7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 7, 7, 11, 12, 12, 13, 13, 13, 13, 12, 12,
+        12, 11, 10, 10, 10, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6,
+        6, 11, 12, 12, 12, 12, 12, 13, 12, 12, 11, 11, 10, 10, 10, 9, 9, 8, 8,
+        8, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 11, 11, 11, 12, 12, 12, 12,
+        12, 12, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5,
+        5, 5, 5, 10, 11, 11, 11, 12, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9,
+        8, 8, 8, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 10, 11, 11, 11, 11, 11,
+        11, 11, 11, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5,
+        5, 5, 5, 5,
+        /* Size 4x16 */
+        33, 23, 13, 11, 32, 25, 14, 11, 32, 24, 14, 12, 30, 21, 14, 12, 30, 19,
+        13, 12, 25, 16, 11, 11, 23, 15, 11, 10, 19, 14, 9, 9, 17, 13, 9, 8, 14,
+        11, 8, 8, 14, 11, 8, 7, 12, 10, 7, 6, 12, 10, 7, 6, 11, 10, 7, 6, 10, 9,
+        7, 5, 9, 9, 7, 5,
+        /* Size 16x4 */
+        33, 32, 32, 30, 30, 25, 23, 19, 17, 14, 14, 12, 12, 11, 10, 9, 23, 25,
+        24, 21, 19, 16, 15, 14, 13, 11, 11, 10, 10, 10, 9, 9, 13, 14, 14, 14,
+        13, 11, 11, 9, 9, 8, 8, 7, 7, 7, 7, 7, 11, 11, 12, 12, 12, 11, 10, 9, 8,
+        8, 7, 6, 6, 6, 5, 5,
+        /* Size 8x32 */
+        32, 32, 28, 19, 16, 12, 11, 10, 33, 32, 29, 20, 17, 12, 12, 11, 33, 31,
+        30, 21, 17, 13, 12, 11, 33, 31, 29, 21, 17, 13, 12, 11, 32, 30, 28, 20,
+        17, 13, 12, 12, 32, 29, 27, 21, 18, 14, 12, 12, 30, 28, 24, 19, 16, 13,
+        13, 12, 29, 28, 23, 18, 16, 12, 12, 12, 28, 27, 21, 17, 15, 12, 12, 11,
+        26, 26, 20, 16, 14, 12, 11, 11, 23, 24, 19, 14, 13, 11, 11, 11, 22, 23,
+        19, 14, 12, 10, 10, 10, 21, 22, 18, 13, 12, 10, 10, 10, 19, 20, 17, 12,
+        11, 9, 10, 10, 18, 19, 16, 12, 10, 9, 9, 9, 17, 18, 16, 12, 10, 9, 9, 9,
+        16, 18, 15, 11, 10, 8, 8, 8, 14, 16, 14, 11, 9, 8, 8, 8, 13, 15, 13, 10,
+        9, 7, 8, 8, 13, 14, 13, 10, 9, 7, 7, 7, 12, 14, 13, 10, 8, 7, 7, 7, 12,
+        13, 12, 9, 8, 7, 7, 7, 11, 13, 12, 10, 8, 7, 6, 6, 11, 12, 11, 10, 8, 7,
+        6, 6, 11, 12, 11, 10, 8, 7, 6, 6, 10, 12, 11, 9, 8, 7, 6, 6, 10, 11, 10,
+        9, 8, 7, 6, 6, 10, 11, 10, 9, 8, 7, 6, 5, 9, 10, 10, 9, 7, 6, 6, 5, 9,
+        10, 10, 9, 7, 6, 6, 5, 9, 10, 10, 9, 8, 7, 6, 5, 8, 9, 10, 9, 8, 7, 6,
+        5,
+        /* Size 32x8 */
+        32, 33, 33, 33, 32, 32, 30, 29, 28, 26, 23, 22, 21, 19, 18, 17, 16, 14,
+        13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 32, 32, 31, 31, 30,
+        29, 28, 28, 27, 26, 24, 23, 22, 20, 19, 18, 18, 16, 15, 14, 14, 13, 13,
+        12, 12, 12, 11, 11, 10, 10, 10, 9, 28, 29, 30, 29, 28, 27, 24, 23, 21,
+        20, 19, 19, 18, 17, 16, 16, 15, 14, 13, 13, 13, 12, 12, 11, 11, 11, 10,
+        10, 10, 10, 10, 10, 19, 20, 21, 21, 20, 21, 19, 18, 17, 16, 14, 14, 13,
+        12, 12, 12, 11, 11, 10, 10, 10, 9, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 16,
+        17, 17, 17, 17, 18, 16, 16, 15, 14, 13, 12, 12, 11, 10, 10, 10, 9, 9, 9,
+        8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 8, 8, 12, 12, 13, 13, 13, 14, 13, 12, 12,
+        12, 11, 10, 10, 9, 9, 9, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 7, 7,
+        11, 12, 12, 12, 12, 12, 13, 12, 12, 11, 11, 10, 10, 10, 9, 9, 8, 8, 8,
+        7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 10, 11, 11, 11, 12, 12, 12, 12,
+        11, 11, 11, 10, 10, 10, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5,
+        5, 5 },
+      { /* Chroma */
+#if CONFIG_CHROMA_2X2
+        /* Size 2x2 */
+        20, 17, 17, 10,
 #endif
         /* Size 4x4 */
-        63, 48, 28, 20, 48, 31, 22, 17, 28, 22, 15, 15, 20, 17, 15, 10,
+        29, 22, 18, 16, 22, 17, 15, 14, 18, 15, 11, 11, 16, 14, 11, 9,
         /* Size 8x8 */
-        64, 63, 53, 40, 30, 24, 21, 18, 63, 58, 51, 41, 33, 27, 23, 19, 53, 51,
-        38, 32, 26, 23, 20, 19, 40, 41, 32, 25, 21, 18, 18, 18, 30, 33, 26, 21,
-        17, 15, 14, 15, 24, 27, 23, 18, 15, 13, 14, 11, 21, 23, 20, 18, 14, 14,
-        11, 8, 18, 19, 19, 18, 15, 11, 8, 9,
+        33, 27, 22, 20, 18, 16, 15, 14, 27, 22, 22, 22, 20, 18, 17, 15, 22, 22,
+        19, 18, 17, 16, 15, 15, 20, 22, 18, 16, 14, 13, 14, 14, 18, 20, 17, 14,
+        12, 12, 12, 12, 16, 18, 16, 13, 12, 11, 11, 11, 15, 17, 15, 14, 12, 11,
+        10, 10, 14, 15, 15, 14, 12, 11, 10, 9,
         /* Size 16x16 */
-        64, 65, 65, 60, 57, 47, 42, 35, 31, 26, 25, 22, 21, 19, 18, 16, 65, 63,
-        63, 61, 59, 50, 46, 38, 34, 28, 27, 25, 23, 21, 19, 18, 65, 63, 61, 58,
-        56, 49, 45, 38, 35, 29, 28, 25, 23, 22, 20, 18, 60, 61, 58, 52, 48, 43,
-        40, 35, 33, 28, 27, 25, 24, 23, 21, 20, 57, 59, 56, 48, 42, 38, 36, 32,
-        30, 26, 25, 23, 22, 21, 18, 17, 47, 50, 49, 43, 38, 32, 31, 27, 26, 23,
-        22, 22, 20, 21, 18, 16, 42, 46, 45, 40, 36, 31, 29, 25, 24, 21, 21, 19,
-        20, 18, 18, 15, 35, 38, 38, 35, 32, 27, 25, 22, 21, 19, 18, 18, 18, 16,
-        18, 14, 31, 34, 35, 33, 30, 26, 24, 21, 20, 17, 17, 16, 15, 14, 17, 13,
-        26, 28, 29, 28, 26, 23, 21, 19, 17, 15, 15, 15, 14, 15, 16, 11, 25, 27,
-        28, 27, 25, 22, 21, 18, 17, 15, 15, 14, 14, 15, 14, 11, 22, 25, 25, 25,
-        23, 22, 19, 18, 16, 15, 14, 13, 13, 12, 12, 10, 21, 23, 23, 24, 22, 20,
-        20, 18, 15, 14, 14, 13, 12, 12, 10, 9, 19, 21, 22, 23, 21, 21, 18, 16,
-        14, 15, 15, 12, 12, 11, 11, 8, 18, 19, 20, 21, 18, 18, 18, 18, 17, 16,
-        14, 12, 10, 11, 10, 10, 16, 18, 18, 20, 17, 16, 15, 14, 13, 11, 11, 10,
-        9, 8, 10, 9,
+        32, 34, 31, 25, 21, 21, 20, 19, 18, 16, 16, 15, 15, 14, 14, 13, 34, 32,
+        29, 24, 22, 23, 22, 21, 20, 18, 18, 17, 16, 15, 15, 14, 31, 29, 26, 23,
+        22, 23, 22, 21, 20, 18, 18, 17, 17, 16, 16, 15, 25, 24, 23, 21, 20, 21,
+        20, 20, 19, 18, 18, 17, 17, 17, 16, 15, 21, 22, 22, 20, 19, 19, 19, 19,
+        18, 17, 17, 16, 16, 16, 16, 16, 21, 23, 23, 21, 19, 18, 17, 17, 16, 15,
+        15, 15, 15, 15, 15, 15, 20, 22, 22, 20, 19, 17, 17, 16, 15, 14, 14, 14,
+        14, 14, 14, 14, 19, 21, 21, 20, 19, 17, 16, 14, 14, 13, 13, 13, 13, 13,
+        13, 13, 18, 20, 20, 19, 18, 16, 15, 14, 13, 12, 12, 12, 12, 12, 12, 12,
+        16, 18, 18, 18, 17, 15, 14, 13, 12, 12, 11, 11, 12, 12, 12, 12, 16, 18,
+        18, 18, 17, 15, 14, 13, 12, 11, 11, 11, 11, 11, 11, 11, 15, 17, 17, 17,
+        16, 15, 14, 13, 12, 11, 11, 10, 10, 10, 10, 10, 15, 16, 17, 17, 16, 15,
+        14, 13, 12, 12, 11, 10, 10, 10, 10, 10, 14, 15, 16, 17, 16, 15, 14, 13,
+        12, 12, 11, 10, 10, 10, 9, 9, 14, 15, 16, 16, 16, 15, 14, 13, 12, 12,
+        11, 10, 10, 9, 9, 9, 13, 14, 15, 15, 16, 15, 14, 13, 12, 12, 11, 10, 10,
+        9, 9, 9,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 64, 60, 59, 57, 52, 47, 45, 42, 38, 35, 33, 31, 29,
-        26, 25, 25, 23, 22, 21, 21, 20, 19, 18, 18, 17, 16, 16, 65, 64, 64, 64,
-        64, 63, 60, 59, 59, 53, 48, 46, 44, 40, 36, 35, 33, 30, 27, 27, 26, 24,
-        23, 23, 22, 21, 20, 19, 19, 18, 17, 17, 65, 64, 63, 63, 63, 63, 61, 60,
-        59, 55, 50, 48, 46, 41, 38, 36, 34, 32, 28, 28, 27, 26, 25, 24, 23, 22,
-        21, 20, 19, 18, 18, 16, 65, 64, 63, 63, 62, 61, 59, 59, 58, 53, 49, 48,
-        46, 41, 38, 36, 34, 32, 28, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 19,
-        18, 18, 65, 64, 63, 62, 61, 60, 58, 57, 56, 53, 49, 47, 45, 41, 38, 36,
-        35, 32, 29, 28, 28, 26, 25, 24, 23, 23, 22, 21, 20, 19, 18, 17, 64, 63,
-        63, 61, 60, 58, 55, 55, 53, 51, 48, 47, 45, 41, 38, 37, 35, 33, 29, 29,
-        28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 19, 18, 60, 60, 61, 59, 58, 55,
-        52, 50, 48, 46, 43, 41, 40, 38, 35, 34, 33, 30, 28, 27, 27, 25, 25, 25,
-        24, 23, 23, 22, 21, 20, 20, 18, 59, 59, 60, 59, 57, 55, 50, 48, 45, 43,
-        41, 39, 38, 36, 34, 33, 31, 29, 27, 26, 26, 25, 25, 24, 22, 21, 21, 21,
-        21, 20, 20, 20, 57, 59, 59, 58, 56, 53, 48, 45, 42, 41, 38, 37, 36, 34,
-        32, 31, 30, 28, 26, 26, 25, 24, 23, 22, 22, 22, 21, 20, 18, 18, 17, 19,
-        52, 53, 55, 53, 53, 51, 46, 43, 41, 38, 35, 34, 34, 32, 30, 29, 28, 26,
-        24, 24, 24, 23, 22, 22, 22, 20, 19, 19, 20, 19, 19, 16, 47, 48, 50, 49,
-        49, 48, 43, 41, 38, 35, 32, 32, 31, 29, 27, 26, 26, 24, 23, 22, 22, 21,
-        22, 21, 20, 19, 21, 20, 18, 17, 16, 18, 45, 46, 48, 48, 47, 47, 41, 39,
-        37, 34, 32, 31, 30, 28, 26, 26, 25, 23, 22, 22, 21, 21, 21, 19, 20, 20,
-        18, 17, 18, 19, 18, 15, 42, 44, 46, 46, 45, 45, 40, 38, 36, 34, 31, 30,
-        29, 27, 25, 25, 24, 23, 21, 21, 21, 20, 19, 20, 20, 17, 18, 19, 18, 15,
-        15, 18, 38, 40, 41, 41, 41, 41, 38, 36, 34, 32, 29, 28, 27, 25, 24, 23,
-        22, 21, 20, 20, 19, 18, 19, 19, 17, 18, 19, 16, 16, 18, 18, 14, 35, 36,
-        38, 38, 38, 38, 35, 34, 32, 30, 27, 26, 25, 24, 22, 22, 21, 20, 19, 18,
-        18, 18, 18, 17, 18, 17, 16, 18, 18, 14, 14, 17, 33, 35, 36, 36, 36, 37,
-        34, 33, 31, 29, 26, 26, 25, 23, 22, 21, 20, 19, 18, 18, 18, 17, 17, 17,
-        17, 15, 18, 16, 14, 17, 17, 13, 31, 33, 34, 34, 35, 35, 33, 31, 30, 28,
-        26, 25, 24, 22, 21, 20, 20, 18, 17, 17, 17, 16, 16, 17, 15, 17, 14, 15,
-        17, 14, 13, 16, 29, 30, 32, 32, 32, 33, 30, 29, 28, 26, 24, 23, 23, 21,
-        20, 19, 18, 17, 16, 16, 16, 15, 16, 14, 16, 14, 15, 16, 13, 15, 16, 12,
-        26, 27, 28, 28, 29, 29, 28, 27, 26, 24, 23, 22, 21, 20, 19, 18, 17, 16,
-        15, 15, 15, 15, 15, 15, 14, 14, 15, 13, 16, 13, 11, 16, 25, 27, 28, 28,
-        28, 29, 27, 26, 26, 24, 22, 22, 21, 20, 18, 18, 17, 16, 15, 15, 15, 14,
-        13, 15, 13, 15, 12, 15, 12, 13, 15, 10, 25, 26, 27, 27, 28, 28, 27, 26,
-        25, 24, 22, 21, 21, 19, 18, 18, 17, 16, 15, 15, 15, 14, 14, 12, 14, 12,
-        15, 11, 14, 13, 11, 15, 23, 24, 26, 26, 26, 27, 25, 25, 24, 23, 21, 21,
-        20, 18, 18, 17, 16, 15, 15, 14, 14, 13, 14, 13, 12, 14, 11, 14, 12, 11,
-        14, 10, 22, 23, 25, 25, 25, 26, 25, 25, 23, 22, 22, 21, 19, 19, 18, 17,
-        16, 16, 15, 13, 14, 14, 13, 13, 13, 12, 12, 12, 12, 13, 10, 14, 21, 23,
-        24, 24, 24, 25, 25, 24, 22, 22, 21, 19, 20, 19, 17, 17, 17, 14, 15, 15,
-        12, 13, 13, 12, 13, 12, 12, 11, 12, 10, 13, 9, 21, 22, 23, 23, 23, 24,
-        24, 22, 22, 22, 20, 20, 20, 17, 18, 17, 15, 16, 14, 13, 14, 12, 13, 13,
-        12, 13, 12, 12, 10, 13, 9, 13, 20, 21, 22, 22, 23, 23, 23, 21, 22, 20,
-        19, 20, 17, 18, 17, 15, 17, 14, 14, 15, 12, 14, 12, 12, 13, 11, 12, 11,
-        12, 8, 12, 8, 19, 20, 21, 21, 22, 22, 23, 21, 21, 19, 21, 18, 18, 19,
-        16, 18, 14, 15, 15, 12, 15, 11, 12, 12, 12, 12, 11, 12, 11, 12, 8, 12,
-        18, 19, 20, 20, 21, 21, 22, 21, 20, 19, 20, 17, 19, 16, 18, 16, 15, 16,
-        13, 15, 11, 14, 12, 11, 12, 11, 12, 10, 12, 10, 12, 7, 18, 19, 19, 19,
-        20, 20, 21, 21, 18, 20, 18, 18, 18, 16, 18, 14, 17, 13, 16, 12, 14, 12,
-        12, 12, 10, 12, 11, 12, 10, 12, 10, 11, 17, 18, 18, 19, 19, 19, 20, 20,
-        18, 19, 17, 19, 15, 18, 14, 17, 14, 15, 13, 13, 13, 11, 13, 10, 13, 8,
-        12, 10, 12, 9, 11, 9, 16, 17, 18, 18, 18, 19, 20, 20, 17, 19, 16, 18,
-        15, 18, 14, 17, 13, 16, 11, 15, 11, 14, 10, 13, 9, 12, 8, 12, 10, 11, 9,
-        11, 16, 17, 16, 18, 17, 18, 18, 20, 19, 16, 18, 15, 18, 14, 17, 13, 16,
-        12, 16, 10, 15, 10, 14, 9, 13, 8, 12, 7, 11, 9, 11, 8,
+        32, 33, 34, 32, 31, 28, 25, 23, 21, 21, 21, 20, 20, 20, 19, 18, 18, 17,
+        16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 33, 33, 33, 31,
+        30, 27, 24, 23, 22, 22, 22, 22, 21, 20, 20, 19, 19, 18, 17, 17, 17, 16,
+        16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 34, 33, 32, 31, 29, 26, 24, 23,
+        22, 23, 23, 23, 22, 22, 21, 20, 20, 19, 18, 18, 18, 17, 17, 16, 16, 16,
+        15, 15, 15, 14, 14, 14, 32, 31, 31, 29, 28, 25, 24, 23, 22, 22, 23, 22,
+        22, 22, 21, 20, 20, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 16, 15, 15,
+        15, 15, 31, 30, 29, 28, 26, 24, 23, 22, 22, 22, 23, 22, 22, 22, 21, 20,
+        20, 19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 28, 27,
+        26, 25, 24, 22, 22, 22, 21, 22, 23, 22, 22, 22, 21, 21, 20, 20, 19, 19,
+        19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 25, 24, 24, 24, 23, 22,
+        21, 21, 20, 21, 21, 21, 20, 20, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17,
+        17, 17, 17, 16, 16, 16, 15, 15, 23, 23, 23, 23, 22, 22, 21, 20, 20, 20,
+        20, 20, 20, 20, 19, 19, 19, 18, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16,
+        16, 16, 16, 16, 21, 22, 22, 22, 22, 21, 20, 20, 19, 19, 19, 19, 19, 19,
+        19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+        21, 22, 23, 22, 22, 22, 21, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17,
+        16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 21, 22, 23, 23,
+        23, 23, 21, 20, 19, 19, 18, 17, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15,
+        15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 20, 22, 23, 22, 22, 22, 21, 20,
+        19, 18, 17, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15, 15, 14, 14, 15, 15,
+        14, 14, 14, 14, 14, 14, 20, 21, 22, 22, 22, 22, 20, 20, 19, 18, 17, 17,
+        17, 16, 16, 16, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+        14, 14, 20, 20, 22, 22, 22, 22, 20, 20, 19, 18, 17, 17, 16, 16, 15, 15,
+        15, 14, 14, 14, 14, 13, 14, 14, 13, 14, 14, 13, 14, 14, 13, 13, 19, 20,
+        21, 21, 21, 21, 20, 19, 19, 18, 17, 16, 16, 15, 14, 14, 14, 14, 13, 13,
+        13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 18, 19, 20, 20, 20, 21,
+        20, 19, 18, 17, 16, 16, 16, 15, 14, 14, 14, 13, 13, 13, 13, 13, 12, 13,
+        13, 13, 13, 13, 13, 13, 13, 12, 18, 19, 20, 20, 20, 20, 19, 19, 18, 17,
+        16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+        12, 12, 12, 12, 17, 18, 19, 19, 19, 20, 19, 18, 18, 17, 16, 15, 15, 14,
+        14, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+        16, 17, 18, 18, 18, 19, 18, 17, 17, 16, 15, 15, 14, 14, 13, 13, 12, 12,
+        12, 12, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 17, 18, 18,
+        18, 19, 18, 17, 17, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11,
+        11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 16, 17, 18, 18, 18, 19, 18, 17,
+        17, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11,
+        11, 11, 11, 11, 11, 11, 15, 16, 17, 17, 17, 18, 17, 17, 16, 16, 15, 15,
+        14, 13, 13, 13, 12, 12, 11, 11, 11, 11, 11, 11, 10, 11, 11, 11, 11, 11,
+        11, 11, 15, 16, 17, 17, 17, 18, 17, 17, 16, 16, 15, 14, 14, 14, 13, 12,
+        12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 15, 16,
+        16, 17, 17, 17, 17, 17, 16, 16, 15, 14, 14, 14, 13, 13, 12, 12, 12, 11,
+        11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15, 16, 16, 16, 17, 17,
+        17, 16, 16, 16, 15, 15, 14, 13, 13, 13, 12, 12, 12, 11, 11, 10, 10, 10,
+        10, 10, 10, 10, 10, 10, 10, 10, 14, 15, 16, 16, 16, 17, 17, 16, 16, 15,
+        15, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10,
+        10, 10, 10, 10, 14, 15, 15, 16, 16, 16, 17, 16, 16, 15, 15, 14, 14, 14,
+        13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 9, 9, 9, 10, 14,
+        15, 15, 16, 16, 16, 16, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12,
+        11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 14, 15, 15, 15, 16, 16,
+        16, 16, 16, 15, 15, 14, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10,
+        10, 10, 9, 9, 9, 9, 9, 9, 14, 14, 14, 15, 15, 15, 16, 16, 16, 15, 15,
+        14, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9,
+        9, 9, 13, 14, 14, 15, 15, 15, 15, 16, 16, 15, 15, 14, 14, 13, 13, 13,
+        12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 13, 14, 14,
+        15, 15, 15, 15, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11,
+        11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 9,
         /* Size 4x8 */
-        64, 48, 27, 20, 62, 48, 30, 22, 55, 35, 24, 20, 41, 29, 20, 16, 31, 24,
-        16, 16, 25, 21, 14, 14, 22, 19, 14, 11, 19, 19, 15, 12,
+        33, 22, 17, 16, 26, 23, 19, 17, 22, 18, 16, 16, 21, 17, 14, 14, 19, 16,
+        12, 12, 17, 15, 11, 11, 16, 15, 11, 10, 15, 14, 12, 10,
         /* Size 8x4 */
-        64, 62, 55, 41, 31, 25, 22, 19, 48, 48, 35, 29, 24, 21, 19, 19, 27, 30,
-        24, 20, 16, 14, 14, 15, 20, 22, 20, 16, 16, 14, 11, 12,
+        33, 26, 22, 21, 19, 17, 16, 15, 22, 23, 18, 17, 16, 15, 15, 14, 17, 19,
+        16, 14, 12, 11, 11, 12, 16, 17, 16, 14, 12, 11, 10, 10,
         /* Size 8x16 */
-        64, 64, 57, 38, 31, 24, 21, 18, 65, 62, 59, 41, 34, 26, 23, 19, 64, 60,
-        56, 41, 35, 27, 24, 20, 60, 55, 48, 38, 33, 26, 24, 22, 57, 53, 43, 34,
-        30, 24, 23, 19, 47, 48, 38, 29, 26, 21, 20, 17, 43, 44, 36, 27, 24, 20,
-        18, 16, 35, 38, 32, 24, 21, 18, 18, 15, 32, 35, 30, 22, 20, 16, 17, 14,
-        26, 29, 26, 20, 17, 15, 14, 13, 25, 28, 25, 19, 17, 14, 12, 13, 22, 26,
-        23, 19, 16, 14, 12, 13, 21, 24, 22, 20, 15, 12, 13, 13, 19, 22, 20, 18,
-        17, 15, 12, 12, 18, 20, 18, 16, 13, 11, 11, 12, 16, 18, 17, 15, 13, 11,
-        9, 10,
+        32, 28, 21, 20, 18, 16, 15, 14, 34, 26, 22, 21, 20, 17, 16, 16, 31, 24,
+        22, 22, 20, 17, 17, 16, 24, 22, 20, 20, 19, 17, 17, 17, 21, 21, 19, 19,
+        18, 17, 17, 17, 21, 22, 19, 17, 16, 15, 16, 16, 20, 22, 19, 16, 15, 14,
+        14, 15, 19, 21, 19, 15, 14, 13, 13, 14, 18, 20, 18, 15, 13, 12, 13, 13,
+        16, 19, 17, 14, 12, 11, 12, 12, 16, 18, 17, 14, 12, 11, 11, 12, 15, 17,
+        16, 14, 12, 11, 10, 11, 15, 17, 16, 14, 12, 11, 10, 10, 14, 16, 16, 14,
+        12, 11, 10, 10, 14, 15, 16, 14, 12, 11, 10, 10, 13, 15, 15, 14, 12, 11,
+        10, 9,
         /* Size 16x8 */
-        64, 65, 64, 60, 57, 47, 43, 35, 32, 26, 25, 22, 21, 19, 18, 16, 64, 62,
-        60, 55, 53, 48, 44, 38, 35, 29, 28, 26, 24, 22, 20, 18, 57, 59, 56, 48,
-        43, 38, 36, 32, 30, 26, 25, 23, 22, 20, 18, 17, 38, 41, 41, 38, 34, 29,
-        27, 24, 22, 20, 19, 19, 20, 18, 16, 15, 31, 34, 35, 33, 30, 26, 24, 21,
-        20, 17, 17, 16, 15, 17, 13, 13, 24, 26, 27, 26, 24, 21, 20, 18, 16, 15,
-        14, 14, 12, 15, 11, 11, 21, 23, 24, 24, 23, 20, 18, 18, 17, 14, 12, 12,
-        13, 12, 11, 9, 18, 19, 20, 22, 19, 17, 16, 15, 14, 13, 13, 13, 13, 12,
-        12, 10,
+        32, 34, 31, 24, 21, 21, 20, 19, 18, 16, 16, 15, 15, 14, 14, 13, 28, 26,
+        24, 22, 21, 22, 22, 21, 20, 19, 18, 17, 17, 16, 15, 15, 21, 22, 22, 20,
+        19, 19, 19, 19, 18, 17, 17, 16, 16, 16, 16, 15, 20, 21, 22, 20, 19, 17,
+        16, 15, 15, 14, 14, 14, 14, 14, 14, 14, 18, 20, 20, 19, 18, 16, 15, 14,
+        13, 12, 12, 12, 12, 12, 12, 12, 16, 17, 17, 17, 17, 15, 14, 13, 12, 11,
+        11, 11, 11, 11, 11, 11, 15, 16, 17, 17, 17, 16, 14, 13, 13, 12, 11, 10,
+        10, 10, 10, 10, 14, 16, 16, 17, 17, 16, 15, 14, 13, 12, 12, 11, 10, 10,
+        10, 9,
         /* Size 16x32 */
-        64, 65, 64, 60, 57, 47, 38, 35, 31, 26, 24, 22, 21, 19, 18, 17, 65, 64,
-        63, 60, 58, 48, 40, 36, 33, 27, 25, 23, 22, 20, 19, 18, 65, 63, 62, 61,
-        59, 50, 41, 38, 34, 28, 26, 24, 23, 21, 19, 18, 65, 63, 61, 59, 58, 49,
-        41, 38, 34, 29, 26, 24, 23, 21, 20, 19, 64, 63, 60, 58, 56, 49, 41, 38,
-        35, 29, 27, 25, 24, 22, 20, 19, 64, 62, 58, 55, 53, 48, 41, 38, 35, 30,
-        27, 26, 24, 22, 20, 20, 60, 60, 55, 52, 48, 43, 38, 35, 33, 28, 26, 25,
-        24, 23, 22, 19, 59, 59, 55, 50, 46, 41, 36, 34, 31, 27, 25, 24, 22, 22,
-        21, 21, 57, 59, 53, 48, 43, 38, 34, 32, 30, 26, 24, 22, 23, 20, 19, 20,
-        52, 55, 51, 46, 41, 35, 32, 30, 28, 24, 23, 22, 21, 20, 20, 17, 47, 50,
-        48, 43, 38, 33, 29, 27, 26, 23, 21, 22, 20, 20, 17, 19, 45, 48, 46, 41,
-        37, 32, 28, 26, 25, 22, 21, 19, 21, 18, 20, 16, 43, 46, 44, 40, 36, 31,
-        27, 25, 24, 21, 20, 20, 18, 20, 16, 19, 38, 41, 41, 38, 34, 29, 25, 24,
-        22, 20, 19, 19, 19, 16, 19, 14, 35, 38, 38, 35, 32, 27, 24, 22, 21, 19,
-        18, 17, 18, 18, 15, 18, 33, 36, 37, 34, 31, 26, 23, 22, 20, 18, 17, 17,
-        15, 16, 18, 13, 32, 34, 35, 33, 30, 26, 22, 21, 20, 17, 16, 17, 17, 15,
-        14, 17, 29, 31, 32, 30, 28, 24, 21, 20, 18, 16, 16, 15, 15, 16, 16, 12,
-        26, 28, 29, 28, 26, 23, 20, 19, 17, 15, 15, 15, 14, 13, 13, 16, 25, 28,
-        29, 27, 26, 22, 20, 18, 17, 15, 14, 15, 15, 16, 14, 11, 25, 27, 28, 27,
-        25, 22, 19, 18, 17, 15, 14, 13, 12, 12, 13, 15, 23, 25, 27, 25, 24, 21,
-        19, 18, 16, 14, 14, 13, 13, 14, 12, 10, 22, 25, 26, 25, 23, 20, 19, 18,
-        16, 14, 14, 14, 12, 12, 13, 14, 21, 24, 25, 25, 23, 20, 20, 18, 15, 15,
-        14, 13, 12, 11, 11, 9, 21, 23, 24, 24, 22, 20, 20, 16, 15, 15, 12, 13,
-        13, 12, 13, 13, 20, 22, 23, 23, 20, 19, 19, 16, 17, 14, 12, 13, 11, 11,
-        9, 9, 19, 21, 22, 22, 20, 21, 18, 16, 17, 13, 15, 11, 12, 12, 12, 13,
-        18, 20, 21, 21, 19, 20, 16, 18, 15, 13, 14, 10, 13, 10, 11, 7, 18, 19,
-        20, 21, 18, 19, 16, 18, 13, 16, 11, 12, 11, 11, 12, 12, 17, 19, 19, 20,
-        18, 19, 15, 17, 13, 15, 11, 14, 9, 12, 10, 10, 16, 18, 18, 19, 17, 18,
-        15, 17, 13, 15, 11, 13, 9, 12, 10, 12, 16, 18, 17, 19, 19, 15, 18, 13,
-        16, 11, 15, 9, 13, 8, 11, 9,
+        32, 33, 28, 24, 21, 21, 20, 19, 18, 16, 16, 15, 15, 15, 14, 14, 33, 33,
+        27, 24, 22, 22, 20, 20, 19, 17, 16, 16, 16, 16, 15, 15, 34, 32, 26, 24,
+        22, 23, 21, 20, 20, 18, 17, 17, 16, 16, 16, 15, 32, 30, 25, 23, 22, 23,
+        21, 21, 20, 18, 17, 17, 17, 16, 16, 16, 31, 28, 24, 23, 22, 22, 22, 21,
+        20, 18, 17, 17, 17, 17, 16, 16, 28, 26, 22, 22, 22, 23, 22, 21, 20, 19,
+        18, 18, 17, 17, 17, 16, 24, 24, 22, 21, 20, 21, 20, 20, 19, 18, 17, 18,
+        17, 17, 17, 16, 23, 23, 22, 21, 20, 20, 20, 19, 19, 17, 17, 17, 17, 17,
+        17, 17, 21, 22, 21, 20, 19, 19, 19, 19, 18, 17, 17, 16, 17, 16, 17, 17,
+        21, 22, 22, 20, 19, 18, 18, 17, 17, 16, 16, 16, 16, 16, 16, 16, 21, 23,
+        22, 21, 19, 18, 17, 17, 16, 15, 15, 15, 16, 16, 16, 16, 21, 22, 22, 21,
+        19, 17, 17, 16, 16, 15, 14, 15, 15, 15, 15, 15, 20, 22, 22, 20, 19, 17,
+        16, 16, 15, 14, 14, 14, 14, 15, 15, 15, 20, 21, 22, 20, 19, 17, 16, 15,
+        14, 14, 13, 14, 14, 14, 14, 14, 19, 20, 21, 20, 19, 17, 15, 14, 14, 13,
+        13, 13, 13, 14, 14, 14, 19, 20, 21, 20, 18, 16, 15, 14, 14, 13, 12, 13,
+        13, 13, 13, 13, 18, 20, 20, 19, 18, 16, 15, 14, 13, 12, 12, 12, 13, 13,
+        13, 13, 17, 19, 20, 19, 18, 16, 14, 14, 13, 12, 12, 12, 12, 12, 13, 13,
+        16, 18, 19, 18, 17, 15, 14, 13, 12, 12, 11, 12, 12, 12, 12, 13, 16, 18,
+        19, 18, 17, 15, 14, 13, 12, 12, 11, 11, 12, 12, 12, 12, 16, 17, 18, 18,
+        17, 15, 14, 13, 12, 11, 11, 11, 11, 11, 12, 12, 15, 17, 18, 17, 16, 15,
+        13, 13, 12, 11, 11, 11, 11, 11, 11, 11, 15, 17, 17, 17, 16, 14, 14, 13,
+        12, 11, 11, 11, 10, 11, 11, 11, 15, 17, 17, 17, 16, 15, 14, 13, 12, 12,
+        11, 10, 10, 10, 11, 11, 15, 16, 17, 17, 16, 15, 14, 13, 12, 12, 11, 11,
+        10, 10, 10, 11, 14, 16, 16, 17, 15, 15, 14, 13, 12, 11, 11, 10, 10, 10,
+        10, 10, 14, 16, 16, 17, 16, 15, 14, 13, 12, 12, 11, 10, 10, 10, 10, 10,
+        14, 16, 16, 16, 16, 15, 14, 13, 12, 12, 11, 10, 10, 10, 10, 10, 14, 15,
+        15, 16, 16, 15, 14, 13, 12, 12, 11, 11, 10, 10, 10, 10, 14, 15, 15, 16,
+        16, 14, 14, 13, 12, 12, 11, 11, 10, 10, 9, 9, 13, 15, 15, 16, 15, 14,
+        14, 13, 12, 12, 11, 11, 10, 10, 9, 9, 13, 15, 15, 15, 15, 14, 14, 13,
+        13, 11, 11, 10, 10, 9, 9, 9,
         /* Size 32x16 */
-        64, 65, 65, 65, 64, 64, 60, 59, 57, 52, 47, 45, 43, 38, 35, 33, 32, 29,
-        26, 25, 25, 23, 22, 21, 21, 20, 19, 18, 18, 17, 16, 16, 65, 64, 63, 63,
-        63, 62, 60, 59, 59, 55, 50, 48, 46, 41, 38, 36, 34, 31, 28, 28, 27, 25,
-        25, 24, 23, 22, 21, 20, 19, 19, 18, 18, 64, 63, 62, 61, 60, 58, 55, 55,
-        53, 51, 48, 46, 44, 41, 38, 37, 35, 32, 29, 29, 28, 27, 26, 25, 24, 23,
-        22, 21, 20, 19, 18, 17, 60, 60, 61, 59, 58, 55, 52, 50, 48, 46, 43, 41,
-        40, 38, 35, 34, 33, 30, 28, 27, 27, 25, 25, 25, 24, 23, 22, 21, 21, 20,
-        19, 19, 57, 58, 59, 58, 56, 53, 48, 46, 43, 41, 38, 37, 36, 34, 32, 31,
-        30, 28, 26, 26, 25, 24, 23, 23, 22, 20, 20, 19, 18, 18, 17, 19, 47, 48,
-        50, 49, 49, 48, 43, 41, 38, 35, 33, 32, 31, 29, 27, 26, 26, 24, 23, 22,
-        22, 21, 20, 20, 20, 19, 21, 20, 19, 19, 18, 15, 38, 40, 41, 41, 41, 41,
-        38, 36, 34, 32, 29, 28, 27, 25, 24, 23, 22, 21, 20, 20, 19, 19, 19, 20,
-        20, 19, 18, 16, 16, 15, 15, 18, 35, 36, 38, 38, 38, 38, 35, 34, 32, 30,
-        27, 26, 25, 24, 22, 22, 21, 20, 19, 18, 18, 18, 18, 18, 16, 16, 16, 18,
-        18, 17, 17, 13, 31, 33, 34, 34, 35, 35, 33, 31, 30, 28, 26, 25, 24, 22,
-        21, 20, 20, 18, 17, 17, 17, 16, 16, 15, 15, 17, 17, 15, 13, 13, 13, 16,
-        26, 27, 28, 29, 29, 30, 28, 27, 26, 24, 23, 22, 21, 20, 19, 18, 17, 16,
-        15, 15, 15, 14, 14, 15, 15, 14, 13, 13, 16, 15, 15, 11, 24, 25, 26, 26,
-        27, 27, 26, 25, 24, 23, 21, 21, 20, 19, 18, 17, 16, 16, 15, 14, 14, 14,
-        14, 14, 12, 12, 15, 14, 11, 11, 11, 15, 22, 23, 24, 24, 25, 26, 25, 24,
-        22, 22, 22, 19, 20, 19, 17, 17, 17, 15, 15, 15, 13, 13, 14, 13, 13, 13,
-        11, 10, 12, 14, 13, 9, 21, 22, 23, 23, 24, 24, 24, 22, 23, 21, 20, 21,
-        18, 19, 18, 15, 17, 15, 14, 15, 12, 13, 12, 12, 13, 11, 12, 13, 11, 9,
-        9, 13, 19, 20, 21, 21, 22, 22, 23, 22, 20, 20, 20, 18, 20, 16, 18, 16,
-        15, 16, 13, 16, 12, 14, 12, 11, 12, 11, 12, 10, 11, 12, 12, 8, 18, 19,
-        19, 20, 20, 20, 22, 21, 19, 20, 17, 20, 16, 19, 15, 18, 14, 16, 13, 14,
-        13, 12, 13, 11, 13, 9, 12, 11, 12, 10, 10, 11, 17, 18, 18, 19, 19, 20,
-        19, 21, 20, 17, 19, 16, 19, 14, 18, 13, 17, 12, 16, 11, 15, 10, 14, 9,
-        13, 9, 13, 7, 12, 10, 12, 9,
+        32, 33, 34, 32, 31, 28, 24, 23, 21, 21, 21, 21, 20, 20, 19, 19, 18, 17,
+        16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 33, 33, 32, 30,
+        28, 26, 24, 23, 22, 22, 23, 22, 22, 21, 20, 20, 20, 19, 18, 18, 17, 17,
+        17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 28, 27, 26, 25, 24, 22, 22, 22,
+        21, 22, 22, 22, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16,
+        16, 16, 15, 15, 15, 15, 24, 24, 24, 23, 23, 22, 21, 21, 20, 20, 21, 21,
+        20, 20, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 17, 17, 17, 16, 16, 16,
+        16, 15, 21, 22, 22, 22, 22, 22, 20, 20, 19, 19, 19, 19, 19, 19, 19, 18,
+        18, 18, 17, 17, 17, 16, 16, 16, 16, 15, 16, 16, 16, 16, 15, 15, 21, 22,
+        23, 23, 22, 23, 21, 20, 19, 18, 18, 17, 17, 17, 17, 16, 16, 16, 15, 15,
+        15, 15, 14, 15, 15, 15, 15, 15, 15, 14, 14, 14, 20, 20, 21, 21, 22, 22,
+        20, 20, 19, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 14, 14, 13, 14, 14,
+        14, 14, 14, 14, 14, 14, 14, 14, 19, 20, 20, 21, 21, 21, 20, 19, 19, 17,
+        17, 16, 16, 15, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+        13, 13, 13, 13, 18, 19, 20, 20, 20, 20, 19, 19, 18, 17, 16, 16, 15, 14,
+        14, 14, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13,
+        16, 17, 18, 18, 18, 19, 18, 17, 17, 16, 15, 15, 14, 14, 13, 13, 12, 12,
+        12, 12, 11, 11, 11, 12, 12, 11, 12, 12, 12, 12, 12, 11, 16, 16, 17, 17,
+        17, 18, 17, 17, 17, 16, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11,
+        11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 15, 16, 17, 17, 17, 18, 18, 17,
+        16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11, 10, 11, 10,
+        10, 10, 11, 11, 11, 10, 15, 16, 16, 17, 17, 17, 17, 17, 17, 16, 16, 15,
+        14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10,
+        10, 10, 15, 16, 16, 16, 17, 17, 17, 17, 16, 16, 16, 15, 15, 14, 14, 13,
+        13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 9, 14, 15,
+        16, 16, 16, 17, 17, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12,
+        12, 11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, 14, 15, 15, 16, 16, 16, 16,
+        17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 13, 12, 12, 11, 11, 11, 11,
+        10, 10, 10, 10, 9, 9, 9,
         /* Size 4x16 */
-        65, 47, 26, 19, 63, 50, 28, 21, 63, 49, 29, 22, 60, 43, 28, 23, 59, 38,
-        26, 20, 50, 33, 23, 20, 46, 31, 21, 20, 38, 27, 19, 18, 34, 26, 17, 15,
-        28, 23, 15, 13, 27, 22, 15, 12, 25, 20, 14, 12, 23, 20, 15, 12, 21, 21,
-        13, 12, 19, 19, 16, 11, 18, 18, 15, 12,
+        33, 21, 16, 15, 32, 23, 18, 16, 28, 22, 18, 17, 24, 21, 18, 17, 22, 19,
+        17, 16, 23, 18, 15, 16, 22, 17, 14, 15, 20, 17, 13, 14, 20, 16, 12, 13,
+        18, 15, 12, 12, 17, 15, 11, 11, 17, 14, 11, 11, 16, 15, 12, 10, 16, 15,
+        12, 10, 15, 15, 12, 10, 15, 14, 12, 10,
         /* Size 16x4 */
-        65, 63, 63, 60, 59, 50, 46, 38, 34, 28, 27, 25, 23, 21, 19, 18, 47, 50,
-        49, 43, 38, 33, 31, 27, 26, 23, 22, 20, 20, 21, 19, 18, 26, 28, 29, 28,
-        26, 23, 21, 19, 17, 15, 15, 14, 15, 13, 16, 15, 19, 21, 22, 23, 20, 20,
-        20, 18, 15, 13, 12, 12, 12, 12, 11, 12,
+        33, 32, 28, 24, 22, 23, 22, 20, 20, 18, 17, 17, 16, 16, 15, 15, 21, 23,
+        22, 21, 19, 18, 17, 17, 16, 15, 15, 14, 15, 15, 15, 14, 16, 18, 18, 18,
+        17, 15, 14, 13, 12, 12, 11, 11, 12, 12, 12, 12, 15, 16, 17, 17, 16, 16,
+        15, 14, 13, 12, 11, 11, 10, 10, 10, 10,
         /* Size 8x32 */
-        64, 64, 57, 38, 31, 24, 21, 18, 65, 63, 58, 40, 33, 25, 22, 19, 65, 62,
-        59, 41, 34, 26, 23, 19, 65, 61, 58, 41, 34, 26, 23, 20, 64, 60, 56, 41,
-        35, 27, 24, 20, 64, 58, 53, 41, 35, 27, 24, 20, 60, 55, 48, 38, 33, 26,
-        24, 22, 59, 55, 46, 36, 31, 25, 22, 21, 57, 53, 43, 34, 30, 24, 23, 19,
-        52, 51, 41, 32, 28, 23, 21, 20, 47, 48, 38, 29, 26, 21, 20, 17, 45, 46,
-        37, 28, 25, 21, 21, 20, 43, 44, 36, 27, 24, 20, 18, 16, 38, 41, 34, 25,
-        22, 19, 19, 19, 35, 38, 32, 24, 21, 18, 18, 15, 33, 37, 31, 23, 20, 17,
-        15, 18, 32, 35, 30, 22, 20, 16, 17, 14, 29, 32, 28, 21, 18, 16, 15, 16,
-        26, 29, 26, 20, 17, 15, 14, 13, 25, 29, 26, 20, 17, 14, 15, 14, 25, 28,
-        25, 19, 17, 14, 12, 13, 23, 27, 24, 19, 16, 14, 13, 12, 22, 26, 23, 19,
-        16, 14, 12, 13, 21, 25, 23, 20, 15, 14, 12, 11, 21, 24, 22, 20, 15, 12,
-        13, 13, 20, 23, 20, 19, 17, 12, 11, 9, 19, 22, 20, 18, 17, 15, 12, 12,
-        18, 21, 19, 16, 15, 14, 13, 11, 18, 20, 18, 16, 13, 11, 11, 12, 17, 19,
-        18, 15, 13, 11, 9, 10, 16, 18, 17, 15, 13, 11, 9, 10, 16, 17, 19, 18,
-        16, 15, 13, 11,
+        32, 28, 21, 20, 18, 16, 15, 14, 33, 27, 22, 20, 19, 16, 16, 15, 34, 26,
+        22, 21, 20, 17, 16, 16, 32, 25, 22, 21, 20, 17, 17, 16, 31, 24, 22, 22,
+        20, 17, 17, 16, 28, 22, 22, 22, 20, 18, 17, 17, 24, 22, 20, 20, 19, 17,
+        17, 17, 23, 22, 20, 20, 19, 17, 17, 17, 21, 21, 19, 19, 18, 17, 17, 17,
+        21, 22, 19, 18, 17, 16, 16, 16, 21, 22, 19, 17, 16, 15, 16, 16, 21, 22,
+        19, 17, 16, 14, 15, 15, 20, 22, 19, 16, 15, 14, 14, 15, 20, 22, 19, 16,
+        14, 13, 14, 14, 19, 21, 19, 15, 14, 13, 13, 14, 19, 21, 18, 15, 14, 12,
+        13, 13, 18, 20, 18, 15, 13, 12, 13, 13, 17, 20, 18, 14, 13, 12, 12, 13,
+        16, 19, 17, 14, 12, 11, 12, 12, 16, 19, 17, 14, 12, 11, 12, 12, 16, 18,
+        17, 14, 12, 11, 11, 12, 15, 18, 16, 13, 12, 11, 11, 11, 15, 17, 16, 14,
+        12, 11, 10, 11, 15, 17, 16, 14, 12, 11, 10, 11, 15, 17, 16, 14, 12, 11,
+        10, 10, 14, 16, 15, 14, 12, 11, 10, 10, 14, 16, 16, 14, 12, 11, 10, 10,
+        14, 16, 16, 14, 12, 11, 10, 10, 14, 15, 16, 14, 12, 11, 10, 10, 14, 15,
+        16, 14, 12, 11, 10, 9, 13, 15, 15, 14, 12, 11, 10, 9, 13, 15, 15, 14,
+        13, 11, 10, 9,
         /* Size 32x8 */
-        64, 65, 65, 65, 64, 64, 60, 59, 57, 52, 47, 45, 43, 38, 35, 33, 32, 29,
-        26, 25, 25, 23, 22, 21, 21, 20, 19, 18, 18, 17, 16, 16, 64, 63, 62, 61,
-        60, 58, 55, 55, 53, 51, 48, 46, 44, 41, 38, 37, 35, 32, 29, 29, 28, 27,
-        26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 57, 58, 59, 58, 56, 53, 48, 46,
-        43, 41, 38, 37, 36, 34, 32, 31, 30, 28, 26, 26, 25, 24, 23, 23, 22, 20,
-        20, 19, 18, 18, 17, 19, 38, 40, 41, 41, 41, 41, 38, 36, 34, 32, 29, 28,
-        27, 25, 24, 23, 22, 21, 20, 20, 19, 19, 19, 20, 20, 19, 18, 16, 16, 15,
-        15, 18, 31, 33, 34, 34, 35, 35, 33, 31, 30, 28, 26, 25, 24, 22, 21, 20,
-        20, 18, 17, 17, 17, 16, 16, 15, 15, 17, 17, 15, 13, 13, 13, 16, 24, 25,
-        26, 26, 27, 27, 26, 25, 24, 23, 21, 21, 20, 19, 18, 17, 16, 16, 15, 14,
-        14, 14, 14, 14, 12, 12, 15, 14, 11, 11, 11, 15, 21, 22, 23, 23, 24, 24,
-        24, 22, 23, 21, 20, 21, 18, 19, 18, 15, 17, 15, 14, 15, 12, 13, 12, 12,
-        13, 11, 12, 13, 11, 9, 9, 13, 18, 19, 19, 20, 20, 20, 22, 21, 19, 20,
-        17, 20, 16, 19, 15, 18, 14, 16, 13, 14, 13, 12, 13, 11, 13, 9, 12, 11,
-        12, 10, 10, 11 },
-      { /* Chroma */
-#if CONFIG_CB4X4
+        32, 33, 34, 32, 31, 28, 24, 23, 21, 21, 21, 21, 20, 20, 19, 19, 18, 17,
+        16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 28, 27, 26, 25,
+        24, 22, 22, 22, 21, 22, 22, 22, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18,
+        17, 17, 17, 16, 16, 16, 15, 15, 15, 15, 21, 22, 22, 22, 22, 22, 20, 20,
+        19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 16, 15,
+        16, 16, 16, 16, 15, 15, 20, 20, 21, 21, 22, 22, 20, 20, 19, 18, 17, 17,
+        16, 16, 15, 15, 15, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14,
+        14, 14, 18, 19, 20, 20, 20, 20, 19, 19, 18, 17, 16, 16, 15, 14, 14, 14,
+        13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 16, 16,
+        17, 17, 17, 18, 17, 17, 17, 16, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11,
+        11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 15, 16, 16, 17, 17, 17,
+        17, 17, 17, 16, 16, 15, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 10, 10,
+        10, 10, 10, 10, 10, 10, 10, 10, 14, 15, 16, 16, 16, 17, 17, 17, 17, 16,
+        16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10,
+        10, 9, 9, 9 },
+  },
+  {
+      { /* Luma */
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        41, 33, 33, 20,
+        26, 12, 12, 7,
 #endif
         /* Size 4x4 */
-        58, 45, 36, 30, 45, 34, 29, 26, 36, 29, 23, 24, 30, 26, 24, 18,
+        32, 25, 15, 11, 25, 16, 12, 10, 15, 12, 8, 7, 11, 10, 7, 6,
         /* Size 8x8 */
-        65, 53, 44, 41, 36, 32, 29, 27, 53, 43, 44, 44, 39, 36, 33, 29, 44, 44,
-        38, 36, 33, 31, 30, 30, 41, 44, 36, 31, 28, 26, 27, 28, 36, 39, 33, 28,
-        25, 23, 22, 24, 32, 36, 31, 26, 23, 21, 22, 19, 29, 33, 30, 27, 22, 22,
-        19, 16, 27, 29, 30, 28, 24, 19, 16, 17,
+        32, 32, 28, 22, 17, 13, 11, 10, 32, 29, 26, 22, 18, 14, 12, 11, 28, 26,
+        20, 17, 14, 12, 11, 10, 22, 22, 17, 14, 12, 10, 10, 9, 17, 18, 14, 12,
+        10, 8, 8, 8, 13, 14, 12, 10, 8, 7, 7, 7, 11, 12, 11, 10, 8, 7, 6, 6, 10,
+        11, 10, 9, 8, 7, 6, 5,
         /* Size 16x16 */
-        64, 67, 61, 49, 42, 42, 41, 38, 36, 32, 32, 30, 28, 27, 26, 25, 67, 64,
-        58, 48, 44, 46, 44, 41, 39, 36, 35, 33, 31, 30, 28, 27, 61, 58, 53, 46,
-        43, 45, 44, 41, 40, 36, 36, 34, 33, 32, 30, 29, 49, 48, 46, 42, 41, 42,
-        41, 39, 38, 36, 35, 34, 34, 33, 32, 31, 42, 44, 43, 41, 39, 38, 38, 37,
-        36, 34, 33, 32, 31, 31, 28, 27, 42, 46, 45, 42, 38, 35, 34, 33, 32, 30,
-        30, 30, 28, 30, 27, 26, 41, 44, 44, 41, 38, 34, 33, 32, 31, 29, 29, 27,
-        28, 27, 27, 24, 38, 41, 41, 39, 37, 33, 32, 29, 28, 26, 26, 26, 27, 24,
-        27, 23, 36, 39, 40, 38, 36, 32, 31, 28, 27, 25, 25, 24, 23, 22, 26, 21,
-        32, 36, 36, 36, 34, 30, 29, 26, 25, 23, 23, 23, 22, 23, 25, 20, 32, 35,
-        36, 35, 33, 30, 29, 26, 25, 23, 22, 22, 22, 23, 22, 19, 30, 33, 34, 34,
-        32, 30, 27, 26, 24, 23, 22, 21, 21, 20, 20, 17, 28, 31, 33, 34, 31, 28,
-        28, 27, 23, 22, 22, 21, 19, 19, 17, 17, 27, 30, 32, 33, 31, 30, 27, 24,
-        22, 23, 23, 20, 19, 18, 18, 15, 26, 28, 30, 32, 28, 27, 27, 27, 26, 25,
-        22, 20, 17, 18, 17, 17, 25, 27, 29, 31, 27, 26, 24, 23, 21, 20, 19, 17,
-        17, 15, 17, 16,
+        32, 33, 33, 32, 28, 26, 22, 19, 17, 14, 13, 12, 11, 10, 10, 9, 33, 32,
+        32, 31, 30, 28, 23, 20, 18, 16, 14, 13, 12, 11, 10, 10, 33, 32, 31, 30,
+        28, 26, 23, 20, 18, 16, 14, 13, 12, 12, 11, 10, 32, 31, 30, 28, 26, 24,
+        22, 20, 18, 16, 14, 13, 13, 12, 11, 10, 28, 30, 28, 26, 21, 20, 18, 17,
+        16, 14, 13, 12, 12, 11, 11, 10, 26, 28, 26, 24, 20, 19, 17, 16, 15, 13,
+        12, 12, 11, 11, 10, 10, 22, 23, 23, 22, 18, 17, 15, 14, 13, 12, 11, 10,
+        10, 10, 9, 9, 19, 20, 20, 20, 17, 16, 14, 12, 12, 11, 10, 9, 9, 9, 9, 8,
+        17, 18, 18, 18, 16, 15, 13, 12, 11, 10, 9, 9, 8, 8, 8, 8, 14, 16, 16,
+        16, 14, 13, 12, 11, 10, 9, 8, 8, 8, 8, 8, 7, 13, 14, 14, 14, 13, 12, 11,
+        10, 9, 8, 8, 7, 7, 7, 7, 7, 12, 13, 13, 13, 12, 12, 10, 9, 9, 8, 7, 7,
+        7, 7, 6, 6, 11, 12, 12, 13, 12, 11, 10, 9, 8, 8, 7, 7, 6, 6, 6, 6, 10,
+        11, 12, 12, 11, 11, 10, 9, 8, 8, 7, 7, 6, 6, 6, 5, 10, 10, 11, 11, 11,
+        10, 9, 9, 8, 8, 7, 6, 6, 6, 5, 5, 9, 10, 10, 10, 10, 10, 9, 8, 8, 7, 7,
+        6, 6, 5, 5, 5,
         /* Size 32x32 */
-        64, 66, 67, 64, 61, 56, 49, 46, 42, 42, 42, 41, 41, 39, 38, 37, 36, 34,
-        32, 32, 32, 30, 30, 29, 28, 28, 27, 27, 26, 26, 25, 25, 66, 65, 66, 62,
-        59, 53, 48, 46, 43, 44, 44, 43, 42, 41, 39, 39, 38, 36, 34, 34, 33, 32,
-        32, 31, 30, 29, 29, 28, 28, 27, 27, 26, 67, 66, 64, 61, 58, 51, 48, 46,
-        44, 45, 46, 45, 44, 43, 41, 40, 39, 38, 36, 35, 35, 34, 33, 32, 31, 31,
-        30, 29, 28, 28, 27, 26, 64, 62, 61, 58, 55, 49, 47, 46, 44, 45, 46, 45,
-        44, 43, 41, 41, 40, 38, 36, 36, 35, 34, 33, 33, 32, 31, 30, 30, 29, 28,
-        28, 28, 61, 59, 58, 55, 53, 47, 46, 45, 43, 44, 45, 45, 44, 43, 41, 41,
-        40, 38, 36, 36, 36, 34, 34, 33, 33, 32, 32, 31, 30, 29, 29, 27, 56, 53,
-        51, 49, 47, 43, 43, 43, 43, 44, 45, 45, 45, 44, 42, 42, 41, 39, 38, 37,
-        37, 36, 35, 34, 34, 33, 31, 31, 30, 29, 29, 29, 49, 48, 48, 47, 46, 43,
-        42, 41, 41, 41, 42, 41, 41, 41, 39, 39, 38, 37, 36, 35, 35, 34, 34, 34,
-        34, 33, 33, 33, 32, 31, 31, 28, 46, 46, 46, 46, 45, 43, 41, 41, 40, 40,
-        40, 40, 39, 39, 38, 38, 37, 36, 35, 34, 34, 33, 33, 33, 31, 31, 30, 32,
-        31, 31, 30, 32, 42, 43, 44, 44, 43, 43, 41, 40, 39, 39, 38, 38, 38, 38,
-        37, 37, 36, 35, 34, 34, 33, 33, 32, 31, 31, 32, 31, 30, 28, 27, 27, 30,
-        42, 44, 45, 45, 44, 44, 41, 40, 39, 38, 37, 37, 36, 36, 35, 34, 34, 33,
-        32, 32, 32, 31, 30, 31, 31, 30, 28, 28, 30, 30, 29, 25, 42, 44, 46, 46,
-        45, 45, 42, 40, 38, 37, 35, 35, 34, 33, 33, 33, 32, 31, 30, 30, 30, 30,
-        30, 30, 28, 28, 30, 30, 27, 26, 26, 29, 41, 43, 45, 45, 45, 45, 41, 40,
-        38, 37, 35, 34, 34, 33, 32, 32, 31, 31, 30, 29, 29, 29, 29, 28, 29, 29,
-        27, 26, 28, 29, 28, 25, 41, 42, 44, 44, 44, 45, 41, 39, 38, 36, 34, 34,
-        33, 32, 32, 31, 31, 30, 29, 29, 29, 28, 27, 28, 28, 26, 27, 29, 27, 25,
-        24, 28, 39, 41, 43, 43, 43, 44, 41, 39, 38, 36, 33, 33, 32, 31, 30, 29,
-        29, 28, 27, 27, 27, 26, 27, 27, 26, 27, 28, 24, 25, 28, 27, 23, 38, 39,
-        41, 41, 41, 42, 39, 38, 37, 35, 33, 32, 32, 30, 29, 28, 28, 27, 26, 26,
-        26, 26, 26, 25, 27, 26, 24, 27, 27, 23, 23, 27, 37, 39, 40, 41, 41, 42,
-        39, 38, 37, 34, 33, 32, 31, 29, 28, 28, 27, 27, 26, 25, 25, 25, 25, 25,
-        25, 23, 26, 24, 23, 26, 26, 21, 36, 38, 39, 40, 40, 41, 38, 37, 36, 34,
-        32, 31, 31, 29, 28, 27, 27, 26, 25, 25, 25, 24, 24, 25, 23, 25, 22, 23,
-        26, 22, 21, 26, 34, 36, 38, 38, 38, 39, 37, 36, 35, 33, 31, 31, 30, 28,
-        27, 27, 26, 25, 24, 24, 24, 23, 24, 22, 25, 22, 24, 25, 21, 24, 25, 20,
-        32, 34, 36, 36, 36, 38, 36, 35, 34, 32, 30, 30, 29, 27, 26, 26, 25, 24,
-        23, 23, 23, 22, 23, 23, 22, 22, 23, 21, 25, 22, 20, 25, 32, 34, 35, 36,
-        36, 37, 35, 34, 34, 32, 30, 29, 29, 27, 26, 25, 25, 24, 23, 23, 23, 22,
-        21, 23, 21, 23, 20, 24, 20, 22, 24, 18, 32, 33, 35, 35, 36, 37, 35, 34,
-        33, 32, 30, 29, 29, 27, 26, 25, 25, 24, 23, 23, 22, 22, 22, 20, 22, 20,
-        23, 19, 22, 22, 19, 24, 30, 32, 34, 34, 34, 36, 34, 33, 33, 31, 30, 29,
-        28, 26, 26, 25, 24, 23, 22, 22, 22, 21, 21, 21, 20, 22, 19, 22, 20, 19,
-        23, 18, 30, 32, 33, 33, 34, 35, 34, 33, 32, 30, 30, 29, 27, 27, 26, 25,
-        24, 24, 23, 21, 22, 21, 21, 21, 21, 19, 20, 20, 20, 21, 17, 23, 29, 31,
-        32, 33, 33, 34, 34, 33, 31, 31, 30, 28, 28, 27, 25, 25, 25, 22, 23, 23,
-        20, 21, 21, 20, 21, 20, 19, 19, 20, 18, 22, 16, 28, 30, 31, 32, 33, 34,
-        34, 31, 31, 31, 28, 29, 28, 26, 27, 25, 23, 25, 22, 21, 22, 20, 21, 21,
-        19, 21, 19, 20, 17, 21, 17, 21, 28, 29, 31, 31, 32, 33, 33, 31, 32, 30,
-        28, 29, 26, 27, 26, 23, 25, 22, 22, 23, 20, 22, 19, 20, 21, 19, 20, 19,
-        20, 16, 21, 16, 27, 29, 30, 30, 32, 31, 33, 30, 31, 28, 30, 27, 27, 28,
-        24, 26, 22, 24, 23, 20, 23, 19, 20, 19, 19, 20, 18, 20, 18, 20, 15, 20,
-        27, 28, 29, 30, 31, 31, 33, 32, 30, 28, 30, 26, 29, 24, 27, 24, 23, 25,
-        21, 24, 19, 22, 20, 19, 20, 19, 20, 18, 20, 18, 19, 14, 26, 28, 28, 29,
-        30, 30, 32, 31, 28, 30, 27, 28, 27, 25, 27, 23, 26, 21, 25, 20, 22, 20,
-        20, 20, 17, 20, 18, 20, 17, 19, 17, 19, 26, 27, 28, 28, 29, 29, 31, 31,
-        27, 30, 26, 29, 25, 28, 23, 26, 22, 24, 22, 22, 22, 19, 21, 18, 21, 16,
-        20, 18, 19, 17, 19, 17, 25, 27, 27, 28, 29, 29, 31, 30, 27, 29, 26, 28,
-        24, 27, 23, 26, 21, 25, 20, 24, 19, 23, 17, 22, 17, 21, 15, 19, 17, 19,
-        16, 19, 25, 26, 26, 28, 27, 29, 28, 32, 30, 25, 29, 25, 28, 23, 27, 21,
-        26, 20, 25, 18, 24, 18, 23, 16, 21, 16, 20, 14, 19, 17, 19, 16,
+        32, 33, 33, 33, 33, 32, 32, 30, 28, 27, 26, 23, 22, 21, 19, 17, 17, 16,
+        14, 13, 13, 12, 12, 12, 11, 11, 10, 10, 10, 9, 9, 9, 33, 32, 32, 32, 32,
+        32, 31, 30, 29, 28, 27, 24, 23, 22, 20, 18, 18, 17, 15, 14, 13, 13, 12,
+        12, 12, 11, 11, 11, 10, 10, 10, 9, 33, 32, 32, 32, 32, 32, 31, 31, 30,
+        28, 28, 25, 23, 22, 20, 19, 18, 17, 16, 15, 14, 13, 13, 12, 12, 12, 11,
+        11, 10, 10, 10, 9, 33, 32, 32, 32, 32, 31, 31, 30, 29, 28, 27, 25, 23,
+        23, 21, 19, 18, 17, 16, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 10, 10,
+        10, 33, 32, 32, 32, 31, 30, 30, 29, 28, 27, 26, 24, 23, 22, 20, 19, 18,
+        17, 16, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 32, 32, 32,
+        31, 30, 29, 28, 28, 27, 26, 26, 24, 23, 22, 21, 19, 19, 18, 16, 16, 15,
+        14, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 32, 31, 31, 31, 30, 28, 28,
+        27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 14, 13, 13, 13,
+        12, 12, 12, 11, 11, 10, 10, 30, 30, 31, 30, 29, 28, 27, 26, 24, 23, 23,
+        22, 20, 20, 19, 18, 17, 16, 15, 14, 14, 13, 13, 12, 12, 12, 12, 12, 11,
+        11, 11, 10, 28, 29, 30, 29, 28, 27, 26, 24, 21, 20, 20, 19, 18, 18, 17,
+        16, 16, 15, 14, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 27,
+        28, 28, 28, 27, 26, 25, 23, 20, 20, 20, 18, 18, 17, 16, 15, 15, 14, 13,
+        13, 12, 12, 12, 12, 11, 11, 11, 11, 11, 10, 10, 10, 26, 27, 28, 27, 26,
+        26, 24, 23, 20, 20, 19, 18, 17, 17, 16, 15, 15, 14, 13, 13, 12, 12, 12,
+        11, 11, 11, 11, 10, 10, 10, 10, 10, 23, 24, 25, 25, 24, 24, 23, 22, 19,
+        18, 18, 16, 16, 15, 14, 14, 13, 13, 12, 12, 11, 11, 11, 11, 11, 10, 10,
+        10, 10, 10, 9, 9, 22, 23, 23, 23, 23, 23, 22, 20, 18, 18, 17, 16, 15,
+        14, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9,
+        21, 22, 22, 23, 22, 22, 21, 20, 18, 17, 17, 15, 14, 14, 13, 13, 12, 12,
+        11, 11, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 19, 20, 20, 21, 20,
+        21, 20, 19, 17, 16, 16, 14, 14, 13, 12, 12, 12, 11, 11, 10, 10, 10, 9,
+        9, 9, 9, 9, 9, 9, 8, 8, 8, 17, 18, 19, 19, 19, 19, 19, 18, 16, 15, 15,
+        14, 13, 13, 12, 11, 11, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8,
+        17, 18, 18, 18, 18, 19, 18, 17, 16, 15, 15, 13, 13, 12, 12, 11, 11, 10,
+        10, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 16, 17, 17, 17, 17, 18, 17,
+        16, 15, 14, 14, 13, 12, 12, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 8, 8, 8,
+        8, 8, 8, 8, 7, 14, 15, 16, 16, 16, 16, 16, 15, 14, 13, 13, 12, 12, 11,
+        11, 10, 10, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 13, 14, 15, 15,
+        15, 16, 15, 14, 13, 13, 13, 12, 11, 11, 10, 10, 9, 9, 8, 8, 8, 8, 8, 8,
+        7, 7, 7, 7, 7, 7, 7, 7, 13, 13, 14, 14, 14, 15, 14, 14, 13, 12, 12, 11,
+        11, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 12, 13,
+        13, 14, 14, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 8, 7, 7,
+        7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 12, 12, 13, 13, 13, 14, 13, 13, 12, 12,
+        12, 11, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 6, 7, 6, 6, 6, 6, 6,
+        12, 12, 12, 13, 13, 13, 13, 12, 12, 12, 11, 11, 10, 10, 9, 9, 9, 8, 8,
+        8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 11, 12, 12, 12, 12, 13, 13, 12,
+        12, 11, 11, 11, 10, 10, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
+        6, 6, 11, 11, 12, 12, 12, 12, 12, 12, 12, 11, 11, 10, 10, 10, 9, 9, 8,
+        8, 8, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 10, 11, 11, 12, 12, 12, 12,
+        12, 11, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
+        5, 5, 5, 10, 11, 11, 11, 11, 11, 12, 12, 11, 11, 10, 10, 10, 9, 9, 8, 8,
+        8, 8, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 10, 10, 10, 11, 11, 11, 11,
+        11, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5,
+        5, 5, 5, 9, 10, 10, 10, 11, 11, 11, 11, 11, 10, 10, 10, 9, 9, 8, 8, 8,
+        8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 9, 10, 10, 10, 10, 10, 10,
+        11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5,
+        5, 5, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7,
+        7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5,
         /* Size 4x8 */
-        65, 44, 34, 29, 51, 45, 38, 31, 45, 37, 32, 29, 43, 34, 27, 25, 38, 31,
-        24, 24, 34, 29, 22, 22, 31, 28, 22, 19, 28, 29, 24, 20,
+        32, 24, 15, 12, 31, 24, 16, 12, 28, 18, 13, 12, 22, 15, 11, 10, 17, 13,
+        9, 8, 14, 11, 8, 7, 12, 11, 8, 6, 10, 10, 8, 6,
         /* Size 8x4 */
-        65, 51, 45, 43, 38, 34, 31, 28, 44, 45, 37, 34, 31, 29, 28, 29, 34, 38,
-        32, 27, 24, 22, 22, 24, 29, 31, 29, 25, 24, 22, 19, 20,
+        32, 31, 28, 22, 17, 14, 12, 10, 24, 24, 18, 15, 13, 11, 11, 10, 15, 16,
+        13, 11, 9, 8, 8, 8, 12, 12, 12, 10, 8, 7, 6, 6,
         /* Size 8x16 */
-        64, 55, 43, 39, 36, 31, 28, 26, 67, 51, 45, 43, 39, 34, 31, 29, 61, 48,
-        44, 43, 40, 35, 33, 30, 49, 43, 41, 41, 38, 34, 34, 32, 42, 43, 39, 38,
-        36, 33, 32, 28, 42, 45, 38, 33, 32, 29, 29, 27, 41, 44, 38, 32, 31, 28,
-        26, 25, 38, 42, 37, 30, 28, 25, 26, 23, 36, 41, 36, 29, 27, 24, 26, 23,
-        32, 37, 34, 27, 25, 22, 22, 22, 32, 37, 33, 27, 25, 22, 20, 21, 30, 34,
-        32, 27, 24, 22, 20, 21, 29, 33, 31, 28, 23, 20, 21, 20, 27, 32, 29, 27,
-        25, 23, 19, 20, 26, 30, 28, 25, 21, 19, 19, 20, 25, 29, 27, 24, 21, 19,
-        17, 17,
+        32, 32, 28, 22, 16, 13, 11, 11, 33, 32, 29, 23, 17, 14, 12, 11, 32, 30,
+        28, 23, 17, 14, 13, 12, 32, 29, 26, 22, 17, 14, 13, 12, 28, 28, 21, 18,
+        15, 13, 12, 12, 26, 26, 20, 17, 14, 12, 11, 11, 22, 23, 18, 15, 12, 11,
+        10, 10, 19, 20, 17, 14, 11, 10, 9, 9, 17, 18, 16, 13, 10, 9, 9, 9, 14,
+        16, 14, 12, 9, 8, 8, 8, 13, 15, 13, 11, 9, 8, 7, 7, 12, 13, 12, 10, 8,
+        7, 7, 7, 11, 12, 12, 10, 8, 7, 7, 6, 10, 12, 11, 9, 8, 7, 6, 6, 10, 11,
+        11, 9, 8, 7, 6, 6, 9, 10, 10, 9, 8, 7, 6, 5,
         /* Size 16x8 */
-        64, 67, 61, 49, 42, 42, 41, 38, 36, 32, 32, 30, 29, 27, 26, 25, 55, 51,
-        48, 43, 43, 45, 44, 42, 41, 37, 37, 34, 33, 32, 30, 29, 43, 45, 44, 41,
-        39, 38, 38, 37, 36, 34, 33, 32, 31, 29, 28, 27, 39, 43, 43, 41, 38, 33,
-        32, 30, 29, 27, 27, 27, 28, 27, 25, 24, 36, 39, 40, 38, 36, 32, 31, 28,
-        27, 25, 25, 24, 23, 25, 21, 21, 31, 34, 35, 34, 33, 29, 28, 25, 24, 22,
-        22, 22, 20, 23, 19, 19, 28, 31, 33, 34, 32, 29, 26, 26, 26, 22, 20, 20,
-        21, 19, 19, 17, 26, 29, 30, 32, 28, 27, 25, 23, 23, 22, 21, 21, 20, 20,
-        20, 17,
+        32, 33, 32, 32, 28, 26, 22, 19, 17, 14, 13, 12, 11, 10, 10, 9, 32, 32,
+        30, 29, 28, 26, 23, 20, 18, 16, 15, 13, 12, 12, 11, 10, 28, 29, 28, 26,
+        21, 20, 18, 17, 16, 14, 13, 12, 12, 11, 11, 10, 22, 23, 23, 22, 18, 17,
+        15, 14, 13, 12, 11, 10, 10, 9, 9, 9, 16, 17, 17, 17, 15, 14, 12, 11, 10,
+        9, 9, 8, 8, 8, 8, 8, 13, 14, 14, 14, 13, 12, 11, 10, 9, 8, 8, 7, 7, 7,
+        7, 7, 11, 12, 13, 13, 12, 11, 10, 9, 9, 8, 7, 7, 7, 6, 6, 6, 11, 11, 12,
+        12, 12, 11, 10, 9, 9, 8, 7, 7, 6, 6, 6, 5,
         /* Size 16x32 */
-        64, 66, 55, 49, 43, 42, 39, 38, 36, 32, 31, 29, 28, 27, 26, 25, 65, 65,
-        53, 48, 44, 44, 41, 39, 38, 34, 33, 31, 30, 29, 28, 27, 67, 64, 51, 48,
-        45, 45, 43, 41, 39, 36, 34, 33, 31, 30, 29, 27, 64, 60, 49, 47, 44, 45,
-        43, 41, 40, 36, 34, 33, 32, 30, 29, 29, 61, 57, 48, 46, 44, 45, 43, 41,
-        40, 37, 35, 34, 33, 32, 30, 28, 55, 51, 44, 43, 43, 45, 44, 42, 41, 38,
-        36, 35, 33, 31, 30, 30, 49, 48, 43, 42, 41, 41, 41, 39, 38, 36, 34, 34,
-        34, 34, 32, 29, 46, 46, 43, 41, 40, 40, 39, 38, 37, 35, 33, 33, 31, 32,
-        32, 32, 42, 44, 43, 41, 39, 38, 38, 37, 36, 34, 33, 31, 32, 30, 28, 31,
-        42, 45, 44, 41, 39, 37, 36, 35, 34, 32, 31, 31, 30, 29, 30, 26, 42, 45,
-        45, 41, 38, 35, 33, 33, 32, 30, 29, 30, 29, 30, 27, 29, 41, 45, 45, 41,
-        38, 35, 33, 32, 31, 30, 29, 28, 30, 27, 29, 25, 41, 44, 44, 41, 38, 34,
-        32, 31, 31, 29, 28, 28, 26, 29, 25, 29, 39, 43, 43, 41, 38, 34, 31, 30,
-        29, 27, 27, 27, 27, 25, 28, 23, 38, 41, 42, 39, 37, 33, 30, 29, 28, 26,
-        25, 25, 26, 27, 23, 28, 37, 40, 41, 39, 37, 33, 29, 28, 27, 26, 25, 25,
-        24, 25, 27, 22, 36, 39, 41, 38, 36, 32, 29, 28, 27, 25, 24, 25, 26, 24,
-        23, 27, 34, 38, 39, 37, 35, 31, 28, 27, 26, 24, 23, 23, 23, 24, 24, 20,
-        32, 36, 37, 35, 34, 30, 27, 26, 25, 23, 22, 23, 22, 21, 22, 25, 32, 35,
-        37, 35, 34, 30, 27, 26, 25, 23, 22, 23, 23, 24, 22, 19, 32, 35, 37, 35,
-        33, 30, 27, 26, 25, 23, 22, 21, 20, 20, 21, 24, 31, 34, 35, 34, 33, 29,
-        27, 26, 24, 22, 21, 21, 21, 22, 20, 18, 30, 33, 34, 34, 32, 28, 27, 26,
-        24, 22, 22, 21, 20, 20, 21, 23, 29, 32, 34, 34, 32, 28, 28, 26, 23, 23,
-        22, 20, 20, 19, 19, 16, 29, 32, 33, 34, 31, 28, 28, 24, 23, 23, 20, 21,
-        21, 20, 20, 22, 28, 31, 32, 33, 29, 28, 28, 24, 25, 22, 20, 21, 19, 19,
-        16, 16, 27, 30, 32, 32, 29, 30, 27, 24, 25, 21, 23, 19, 19, 20, 20, 21,
-        27, 30, 31, 32, 28, 30, 25, 27, 24, 21, 22, 18, 20, 18, 18, 14, 26, 29,
-        30, 31, 28, 29, 25, 27, 21, 25, 19, 20, 19, 18, 20, 20, 26, 28, 29, 31,
-        28, 29, 25, 27, 21, 24, 19, 22, 16, 20, 17, 17, 25, 28, 29, 30, 27, 28,
-        24, 26, 21, 24, 19, 22, 17, 19, 17, 19, 25, 28, 27, 31, 29, 25, 28, 22,
-        26, 19, 24, 16, 21, 15, 19, 16,
+        32, 33, 32, 32, 28, 23, 22, 19, 16, 14, 13, 12, 11, 11, 11, 10, 33, 32,
+        32, 31, 29, 24, 23, 20, 17, 15, 14, 12, 12, 12, 11, 11, 33, 32, 32, 31,
+        29, 25, 23, 21, 17, 15, 14, 13, 12, 12, 11, 11, 33, 32, 31, 31, 29, 25,
+        23, 21, 17, 16, 14, 13, 12, 12, 12, 11, 32, 32, 30, 30, 28, 24, 23, 20,
+        17, 16, 14, 13, 13, 12, 12, 11, 32, 31, 29, 28, 27, 24, 23, 21, 18, 16,
+        15, 13, 13, 12, 12, 12, 32, 31, 29, 28, 26, 23, 22, 20, 17, 16, 14, 13,
+        13, 13, 12, 12, 30, 30, 28, 27, 24, 21, 20, 19, 16, 15, 14, 13, 12, 13,
+        12, 12, 28, 30, 28, 26, 21, 19, 18, 17, 15, 14, 13, 12, 12, 12, 12, 12,
+        27, 28, 26, 25, 21, 18, 18, 16, 14, 13, 13, 12, 12, 12, 11, 11, 26, 28,
+        26, 24, 20, 18, 17, 16, 14, 13, 12, 11, 11, 11, 11, 11, 23, 25, 24, 23,
+        19, 16, 16, 14, 13, 12, 11, 11, 11, 11, 11, 10, 22, 23, 23, 22, 18, 16,
+        15, 14, 12, 11, 11, 10, 10, 10, 10, 10, 21, 22, 22, 21, 18, 15, 14, 13,
+        12, 11, 11, 10, 10, 10, 10, 10, 19, 21, 20, 20, 17, 14, 14, 12, 11, 10,
+        10, 9, 9, 10, 9, 10, 18, 19, 19, 19, 16, 14, 13, 12, 10, 10, 9, 9, 9, 9,
+        9, 9, 17, 18, 18, 18, 16, 13, 13, 12, 10, 10, 9, 9, 9, 9, 9, 9, 16, 17,
+        17, 17, 15, 13, 12, 11, 10, 9, 9, 8, 8, 8, 8, 8, 14, 16, 16, 16, 14, 12,
+        12, 11, 9, 9, 8, 8, 8, 8, 8, 8, 13, 15, 15, 15, 13, 12, 11, 10, 9, 8, 8,
+        8, 8, 8, 8, 8, 13, 14, 15, 14, 13, 11, 11, 10, 9, 8, 8, 7, 7, 7, 7, 8,
+        12, 14, 14, 14, 13, 11, 11, 10, 8, 8, 8, 7, 7, 7, 7, 7, 12, 13, 13, 13,
+        12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 7, 7, 12, 13, 13, 13, 12, 11, 10, 9, 8,
+        8, 7, 7, 7, 7, 7, 6, 11, 12, 12, 13, 12, 11, 10, 9, 8, 8, 7, 7, 7, 6, 6,
+        6, 11, 12, 12, 12, 11, 11, 10, 9, 9, 8, 7, 7, 6, 6, 6, 6, 10, 12, 12,
+        12, 11, 11, 9, 9, 8, 8, 7, 6, 6, 6, 6, 6, 10, 11, 11, 12, 11, 10, 9, 9,
+        8, 8, 7, 6, 6, 6, 6, 6, 10, 11, 11, 11, 11, 10, 9, 9, 8, 8, 7, 7, 6, 6,
+        6, 6, 10, 10, 11, 11, 11, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 9, 10, 10,
+        11, 10, 9, 9, 8, 8, 7, 7, 6, 6, 6, 5, 5, 9, 10, 10, 10, 10, 9, 9, 8, 8,
+        7, 7, 6, 6, 5, 5, 5,
         /* Size 32x16 */
-        64, 65, 67, 64, 61, 55, 49, 46, 42, 42, 42, 41, 41, 39, 38, 37, 36, 34,
-        32, 32, 32, 31, 30, 29, 29, 28, 27, 27, 26, 26, 25, 25, 66, 65, 64, 60,
-        57, 51, 48, 46, 44, 45, 45, 45, 44, 43, 41, 40, 39, 38, 36, 35, 35, 34,
-        33, 32, 32, 31, 30, 30, 29, 28, 28, 28, 55, 53, 51, 49, 48, 44, 43, 43,
-        43, 44, 45, 45, 44, 43, 42, 41, 41, 39, 37, 37, 37, 35, 34, 34, 33, 32,
-        32, 31, 30, 29, 29, 27, 49, 48, 48, 47, 46, 43, 42, 41, 41, 41, 41, 41,
-        41, 41, 39, 39, 38, 37, 35, 35, 35, 34, 34, 34, 34, 33, 32, 32, 31, 31,
-        30, 31, 43, 44, 45, 44, 44, 43, 41, 40, 39, 39, 38, 38, 38, 38, 37, 37,
-        36, 35, 34, 34, 33, 33, 32, 32, 31, 29, 29, 28, 28, 28, 27, 29, 42, 44,
-        45, 45, 45, 45, 41, 40, 38, 37, 35, 35, 34, 34, 33, 33, 32, 31, 30, 30,
-        30, 29, 28, 28, 28, 28, 30, 30, 29, 29, 28, 25, 39, 41, 43, 43, 43, 44,
-        41, 39, 38, 36, 33, 33, 32, 31, 30, 29, 29, 28, 27, 27, 27, 27, 27, 28,
-        28, 28, 27, 25, 25, 25, 24, 28, 38, 39, 41, 41, 41, 42, 39, 38, 37, 35,
-        33, 32, 31, 30, 29, 28, 28, 27, 26, 26, 26, 26, 26, 26, 24, 24, 24, 27,
-        27, 27, 26, 22, 36, 38, 39, 40, 40, 41, 38, 37, 36, 34, 32, 31, 31, 29,
-        28, 27, 27, 26, 25, 25, 25, 24, 24, 23, 23, 25, 25, 24, 21, 21, 21, 26,
-        32, 34, 36, 36, 37, 38, 36, 35, 34, 32, 30, 30, 29, 27, 26, 26, 25, 24,
-        23, 23, 23, 22, 22, 23, 23, 22, 21, 21, 25, 24, 24, 19, 31, 33, 34, 34,
-        35, 36, 34, 33, 33, 31, 29, 29, 28, 27, 25, 25, 24, 23, 22, 22, 22, 21,
-        22, 22, 20, 20, 23, 22, 19, 19, 19, 24, 29, 31, 33, 33, 34, 35, 34, 33,
-        31, 31, 30, 28, 28, 27, 25, 25, 25, 23, 23, 23, 21, 21, 21, 20, 21, 21,
-        19, 18, 20, 22, 22, 16, 28, 30, 31, 32, 33, 33, 34, 31, 32, 30, 29, 30,
-        26, 27, 26, 24, 26, 23, 22, 23, 20, 21, 20, 20, 21, 19, 19, 20, 19, 16,
-        17, 21, 27, 29, 30, 30, 32, 31, 34, 32, 30, 29, 30, 27, 29, 25, 27, 25,
-        24, 24, 21, 24, 20, 22, 20, 19, 20, 19, 20, 18, 18, 20, 19, 15, 26, 28,
-        29, 29, 30, 30, 32, 32, 28, 30, 27, 29, 25, 28, 23, 27, 23, 24, 22, 22,
-        21, 20, 21, 19, 20, 16, 20, 18, 20, 17, 17, 19, 25, 27, 27, 29, 28, 30,
-        29, 32, 31, 26, 29, 25, 29, 23, 28, 22, 27, 20, 25, 19, 24, 18, 23, 16,
-        22, 16, 21, 14, 20, 17, 19, 16,
+        32, 33, 33, 33, 32, 32, 32, 30, 28, 27, 26, 23, 22, 21, 19, 18, 17, 16,
+        14, 13, 13, 12, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 33, 32, 32, 32,
+        32, 31, 31, 30, 30, 28, 28, 25, 23, 22, 21, 19, 18, 17, 16, 15, 14, 14,
+        13, 13, 12, 12, 12, 11, 11, 10, 10, 10, 32, 32, 32, 31, 30, 29, 29, 28,
+        28, 26, 26, 24, 23, 22, 20, 19, 18, 17, 16, 15, 15, 14, 13, 13, 12, 12,
+        12, 11, 11, 11, 10, 10, 32, 31, 31, 31, 30, 28, 28, 27, 26, 25, 24, 23,
+        22, 21, 20, 19, 18, 17, 16, 15, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11,
+        11, 10, 28, 29, 29, 29, 28, 27, 26, 24, 21, 21, 20, 19, 18, 18, 17, 16,
+        16, 15, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 11, 11, 10, 10, 23, 24,
+        25, 25, 24, 24, 23, 21, 19, 18, 18, 16, 16, 15, 14, 14, 13, 13, 12, 12,
+        11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 9, 9, 22, 23, 23, 23, 23, 23,
+        22, 20, 18, 18, 17, 16, 15, 14, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10,
+        10, 10, 9, 9, 9, 9, 9, 9, 19, 20, 21, 21, 20, 21, 20, 19, 17, 16, 16,
+        14, 14, 13, 12, 12, 12, 11, 11, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 8,
+        8, 16, 17, 17, 17, 17, 18, 17, 16, 15, 14, 14, 13, 12, 12, 11, 10, 10,
+        10, 9, 9, 9, 8, 8, 8, 8, 9, 8, 8, 8, 8, 8, 8, 14, 15, 15, 16, 16, 16,
+        16, 15, 14, 13, 13, 12, 11, 11, 10, 10, 10, 9, 9, 8, 8, 8, 8, 8, 8, 8,
+        8, 8, 8, 8, 7, 7, 13, 14, 14, 14, 14, 15, 14, 14, 13, 13, 12, 11, 11,
+        11, 10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 12, 12, 13,
+        13, 13, 13, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7,
+        7, 7, 7, 6, 6, 7, 7, 6, 6, 11, 12, 12, 12, 13, 13, 13, 12, 12, 12, 11,
+        11, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 11,
+        12, 12, 12, 12, 12, 13, 13, 12, 12, 11, 11, 10, 10, 10, 9, 9, 8, 8, 8,
+        7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 11, 11, 11, 12, 12, 12, 12, 12, 12,
+        11, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5,
+        5, 10, 11, 11, 11, 11, 12, 12, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 8,
+        8, 8, 8, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5,
         /* Size 4x16 */
-        66, 42, 32, 27, 64, 45, 36, 30, 57, 45, 37, 32, 48, 41, 36, 34, 44, 38,
-        34, 30, 45, 35, 30, 30, 44, 34, 29, 29, 41, 33, 26, 27, 39, 32, 25, 24,
-        36, 30, 23, 21, 35, 30, 23, 20, 33, 28, 22, 20, 32, 28, 23, 20, 30, 30,
-        21, 20, 29, 29, 25, 18, 28, 28, 24, 19,
+        33, 23, 14, 11, 32, 25, 15, 12, 32, 24, 16, 12, 31, 23, 16, 13, 30, 19,
+        14, 12, 28, 18, 13, 11, 23, 16, 11, 10, 21, 14, 10, 10, 18, 13, 10, 9,
+        16, 12, 9, 8, 14, 11, 8, 7, 13, 11, 8, 7, 12, 11, 8, 6, 12, 11, 8, 6,
+        11, 10, 8, 6, 10, 9, 7, 6,
         /* Size 16x4 */
-        66, 64, 57, 48, 44, 45, 44, 41, 39, 36, 35, 33, 32, 30, 29, 28, 42, 45,
-        45, 41, 38, 35, 34, 33, 32, 30, 30, 28, 28, 30, 29, 28, 32, 36, 37, 36,
-        34, 30, 29, 26, 25, 23, 23, 22, 23, 21, 25, 24, 27, 30, 32, 34, 30, 30,
-        29, 27, 24, 21, 20, 20, 20, 20, 18, 19,
+        33, 32, 32, 31, 30, 28, 23, 21, 18, 16, 14, 13, 12, 12, 11, 10, 23, 25,
+        24, 23, 19, 18, 16, 14, 13, 12, 11, 11, 11, 11, 10, 9, 14, 15, 16, 16,
+        14, 13, 11, 10, 10, 9, 8, 8, 8, 8, 8, 7, 11, 12, 12, 13, 12, 11, 10, 10,
+        9, 8, 7, 7, 6, 6, 6, 6,
         /* Size 8x32 */
-        64, 55, 43, 39, 36, 31, 28, 26, 65, 53, 44, 41, 38, 33, 30, 28, 67, 51,
-        45, 43, 39, 34, 31, 29, 64, 49, 44, 43, 40, 34, 32, 29, 61, 48, 44, 43,
-        40, 35, 33, 30, 55, 44, 43, 44, 41, 36, 33, 30, 49, 43, 41, 41, 38, 34,
-        34, 32, 46, 43, 40, 39, 37, 33, 31, 32, 42, 43, 39, 38, 36, 33, 32, 28,
-        42, 44, 39, 36, 34, 31, 30, 30, 42, 45, 38, 33, 32, 29, 29, 27, 41, 45,
-        38, 33, 31, 29, 30, 29, 41, 44, 38, 32, 31, 28, 26, 25, 39, 43, 38, 31,
-        29, 27, 27, 28, 38, 42, 37, 30, 28, 25, 26, 23, 37, 41, 37, 29, 27, 25,
-        24, 27, 36, 41, 36, 29, 27, 24, 26, 23, 34, 39, 35, 28, 26, 23, 23, 24,
-        32, 37, 34, 27, 25, 22, 22, 22, 32, 37, 34, 27, 25, 22, 23, 22, 32, 37,
-        33, 27, 25, 22, 20, 21, 31, 35, 33, 27, 24, 21, 21, 20, 30, 34, 32, 27,
-        24, 22, 20, 21, 29, 34, 32, 28, 23, 22, 20, 19, 29, 33, 31, 28, 23, 20,
-        21, 20, 28, 32, 29, 28, 25, 20, 19, 16, 27, 32, 29, 27, 25, 23, 19, 20,
-        27, 31, 28, 25, 24, 22, 20, 18, 26, 30, 28, 25, 21, 19, 19, 20, 26, 29,
-        28, 25, 21, 19, 16, 17, 25, 29, 27, 24, 21, 19, 17, 17, 25, 27, 29, 28,
-        26, 24, 21, 19,
+        32, 32, 28, 22, 16, 13, 11, 11, 33, 32, 29, 23, 17, 14, 12, 11, 33, 32,
+        29, 23, 17, 14, 12, 11, 33, 31, 29, 23, 17, 14, 12, 12, 32, 30, 28, 23,
+        17, 14, 13, 12, 32, 29, 27, 23, 18, 15, 13, 12, 32, 29, 26, 22, 17, 14,
+        13, 12, 30, 28, 24, 20, 16, 14, 12, 12, 28, 28, 21, 18, 15, 13, 12, 12,
+        27, 26, 21, 18, 14, 13, 12, 11, 26, 26, 20, 17, 14, 12, 11, 11, 23, 24,
+        19, 16, 13, 11, 11, 11, 22, 23, 18, 15, 12, 11, 10, 10, 21, 22, 18, 14,
+        12, 11, 10, 10, 19, 20, 17, 14, 11, 10, 9, 9, 18, 19, 16, 13, 10, 9, 9,
+        9, 17, 18, 16, 13, 10, 9, 9, 9, 16, 17, 15, 12, 10, 9, 8, 8, 14, 16, 14,
+        12, 9, 8, 8, 8, 13, 15, 13, 11, 9, 8, 8, 8, 13, 15, 13, 11, 9, 8, 7, 7,
+        12, 14, 13, 11, 8, 8, 7, 7, 12, 13, 12, 10, 8, 7, 7, 7, 12, 13, 12, 10,
+        8, 7, 7, 7, 11, 12, 12, 10, 8, 7, 7, 6, 11, 12, 11, 10, 9, 7, 6, 6, 10,
+        12, 11, 9, 8, 7, 6, 6, 10, 11, 11, 9, 8, 7, 6, 6, 10, 11, 11, 9, 8, 7,
+        6, 6, 10, 11, 11, 9, 8, 7, 6, 5, 9, 10, 10, 9, 8, 7, 6, 5, 9, 10, 10, 9,
+        8, 7, 6, 5,
         /* Size 32x8 */
-        64, 65, 67, 64, 61, 55, 49, 46, 42, 42, 42, 41, 41, 39, 38, 37, 36, 34,
-        32, 32, 32, 31, 30, 29, 29, 28, 27, 27, 26, 26, 25, 25, 55, 53, 51, 49,
-        48, 44, 43, 43, 43, 44, 45, 45, 44, 43, 42, 41, 41, 39, 37, 37, 37, 35,
-        34, 34, 33, 32, 32, 31, 30, 29, 29, 27, 43, 44, 45, 44, 44, 43, 41, 40,
-        39, 39, 38, 38, 38, 38, 37, 37, 36, 35, 34, 34, 33, 33, 32, 32, 31, 29,
-        29, 28, 28, 28, 27, 29, 39, 41, 43, 43, 43, 44, 41, 39, 38, 36, 33, 33,
-        32, 31, 30, 29, 29, 28, 27, 27, 27, 27, 27, 28, 28, 28, 27, 25, 25, 25,
-        24, 28, 36, 38, 39, 40, 40, 41, 38, 37, 36, 34, 32, 31, 31, 29, 28, 27,
-        27, 26, 25, 25, 25, 24, 24, 23, 23, 25, 25, 24, 21, 21, 21, 26, 31, 33,
-        34, 34, 35, 36, 34, 33, 33, 31, 29, 29, 28, 27, 25, 25, 24, 23, 22, 22,
-        22, 21, 22, 22, 20, 20, 23, 22, 19, 19, 19, 24, 28, 30, 31, 32, 33, 33,
-        34, 31, 32, 30, 29, 30, 26, 27, 26, 24, 26, 23, 22, 23, 20, 21, 20, 20,
-        21, 19, 19, 20, 19, 16, 17, 21, 26, 28, 29, 29, 30, 30, 32, 32, 28, 30,
-        27, 29, 25, 28, 23, 27, 23, 24, 22, 22, 21, 20, 21, 19, 20, 16, 20, 18,
-        20, 17, 17, 19 },
+        32, 33, 33, 33, 32, 32, 32, 30, 28, 27, 26, 23, 22, 21, 19, 18, 17, 16,
+        14, 13, 13, 12, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 32, 32, 32, 31,
+        30, 29, 29, 28, 28, 26, 26, 24, 23, 22, 20, 19, 18, 17, 16, 15, 15, 14,
+        13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 28, 29, 29, 29, 28, 27, 26, 24,
+        21, 21, 20, 19, 18, 18, 17, 16, 16, 15, 14, 13, 13, 13, 12, 12, 12, 11,
+        11, 11, 11, 11, 10, 10, 22, 23, 23, 23, 23, 23, 22, 20, 18, 18, 17, 16,
+        15, 14, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 9,
+        9, 16, 17, 17, 17, 17, 18, 17, 16, 15, 14, 14, 13, 12, 12, 11, 10, 10,
+        10, 9, 9, 9, 8, 8, 8, 8, 9, 8, 8, 8, 8, 8, 8, 13, 14, 14, 14, 14, 15,
+        14, 14, 13, 13, 12, 11, 11, 11, 10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7,
+        7, 7, 7, 7, 7, 11, 12, 12, 12, 13, 13, 13, 12, 12, 12, 11, 11, 10, 10,
+        9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 11, 11, 11, 12,
+        12, 12, 12, 12, 12, 11, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6,
+        6, 6, 6, 6, 5, 5, 5 },
+      { /* Chroma */
+#if CONFIG_CHROMA_2X2
+        /* Size 2x2 */
+        21, 17, 17, 11,
+#endif
+        /* Size 4x4 */
+        31, 23, 18, 16, 23, 18, 16, 15, 18, 16, 12, 12, 16, 15, 12, 10,
+        /* Size 8x8 */
+        33, 27, 22, 21, 19, 17, 16, 15, 27, 22, 22, 22, 20, 19, 17, 16, 22, 22,
+        19, 19, 18, 16, 16, 16, 21, 22, 19, 17, 15, 14, 14, 14, 19, 20, 18, 15,
+        13, 12, 12, 12, 17, 19, 16, 14, 12, 11, 11, 11, 16, 17, 16, 14, 12, 11,
+        10, 10, 15, 16, 16, 14, 12, 11, 10, 9,
+        /* Size 16x16 */
+        32, 34, 31, 27, 21, 21, 20, 20, 19, 17, 16, 16, 15, 15, 14, 14, 34, 33,
+        29, 25, 22, 22, 22, 21, 20, 19, 18, 17, 16, 16, 15, 15, 31, 29, 26, 23,
+        22, 22, 22, 22, 20, 19, 18, 18, 17, 17, 16, 15, 27, 25, 23, 22, 21, 21,
+        22, 21, 20, 19, 19, 18, 18, 17, 17, 16, 21, 22, 22, 21, 19, 19, 19, 19,
+        18, 18, 17, 17, 17, 16, 16, 16, 21, 22, 22, 21, 19, 19, 18, 18, 17, 17,
+        16, 16, 15, 16, 15, 15, 20, 22, 22, 22, 19, 18, 17, 16, 16, 15, 15, 14,
+        14, 14, 14, 14, 20, 21, 22, 21, 19, 18, 16, 16, 15, 14, 14, 13, 14, 13,
+        13, 13, 19, 20, 20, 20, 18, 17, 16, 15, 14, 13, 13, 13, 13, 13, 13, 13,
+        17, 19, 19, 19, 18, 17, 15, 14, 13, 12, 12, 12, 12, 12, 12, 12, 16, 18,
+        18, 19, 17, 16, 15, 14, 13, 12, 12, 11, 11, 11, 12, 11, 16, 17, 18, 18,
+        17, 16, 14, 13, 13, 12, 11, 11, 11, 11, 11, 11, 15, 16, 17, 18, 17, 15,
+        14, 14, 13, 12, 11, 11, 10, 10, 10, 10, 15, 16, 17, 17, 16, 16, 14, 13,
+        13, 12, 11, 11, 10, 10, 10, 10, 14, 15, 16, 17, 16, 15, 14, 13, 13, 12,
+        12, 11, 10, 10, 10, 9, 14, 15, 15, 16, 16, 15, 14, 13, 13, 12, 11, 11,
+        10, 10, 9, 9,
+        /* Size 32x32 */
+        32, 33, 34, 33, 31, 28, 27, 25, 21, 21, 21, 21, 20, 20, 20, 19, 19, 18,
+        17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 33, 33, 33, 32,
+        30, 27, 26, 24, 22, 22, 22, 22, 21, 21, 20, 20, 19, 19, 18, 17, 17, 17,
+        16, 16, 16, 16, 15, 15, 15, 15, 15, 14, 34, 33, 33, 32, 29, 26, 25, 24,
+        22, 22, 22, 23, 22, 22, 21, 20, 20, 20, 19, 18, 18, 17, 17, 17, 16, 16,
+        16, 15, 15, 15, 15, 14, 33, 32, 32, 31, 28, 26, 25, 24, 22, 22, 23, 23,
+        22, 22, 22, 21, 20, 20, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 16, 16,
+        15, 15, 31, 30, 29, 28, 26, 24, 23, 23, 22, 22, 22, 23, 22, 22, 22, 21,
+        20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 16, 15, 15, 28, 27,
+        26, 26, 24, 22, 22, 22, 21, 22, 22, 23, 22, 22, 22, 21, 21, 20, 20, 19,
+        19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 16, 16, 27, 26, 25, 25, 23, 22,
+        22, 21, 21, 21, 21, 22, 22, 22, 21, 21, 20, 20, 19, 19, 19, 18, 18, 18,
+        18, 17, 17, 17, 17, 16, 16, 16, 25, 24, 24, 24, 23, 22, 21, 21, 20, 20,
+        21, 21, 20, 20, 20, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 17, 17, 17,
+        17, 16, 16, 16, 21, 22, 22, 22, 22, 21, 21, 20, 19, 19, 19, 19, 19, 19,
+        19, 19, 18, 18, 18, 17, 17, 17, 17, 16, 17, 17, 16, 16, 16, 16, 16, 16,
+        21, 22, 22, 22, 22, 22, 21, 20, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18,
+        17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 21, 22, 22, 23,
+        22, 22, 21, 21, 19, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 16, 16, 16,
+        16, 16, 15, 16, 16, 15, 15, 15, 15, 15, 21, 22, 23, 23, 23, 23, 22, 21,
+        19, 19, 19, 18, 17, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15,
+        15, 15, 15, 15, 15, 14, 20, 21, 22, 22, 22, 22, 22, 20, 19, 19, 18, 17,
+        17, 17, 16, 16, 16, 16, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+        14, 14, 20, 21, 22, 22, 22, 22, 22, 20, 19, 19, 18, 17, 17, 17, 16, 16,
+        16, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 20, 20,
+        21, 22, 22, 22, 21, 20, 19, 18, 18, 17, 16, 16, 16, 15, 15, 15, 14, 14,
+        14, 14, 13, 13, 14, 13, 13, 14, 13, 13, 13, 14, 19, 20, 20, 21, 21, 21,
+        21, 20, 19, 18, 18, 17, 16, 16, 15, 14, 14, 14, 14, 13, 13, 13, 13, 13,
+        13, 13, 13, 13, 13, 13, 13, 13, 19, 19, 20, 20, 20, 21, 20, 20, 18, 18,
+        17, 16, 16, 16, 15, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+        13, 13, 13, 13, 18, 19, 20, 20, 20, 20, 20, 19, 18, 18, 17, 16, 16, 15,
+        15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+        17, 18, 19, 19, 19, 20, 19, 19, 18, 17, 17, 16, 15, 15, 14, 14, 13, 13,
+        12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 17, 17, 18, 18,
+        19, 19, 19, 18, 17, 17, 16, 16, 15, 15, 14, 13, 13, 13, 12, 12, 12, 12,
+        11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 17, 18, 18, 18, 19, 19, 18,
+        17, 17, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11,
+        11, 11, 12, 11, 11, 12, 16, 17, 17, 18, 18, 19, 18, 18, 17, 16, 16, 15,
+        14, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+        11, 11, 16, 16, 17, 17, 18, 18, 18, 17, 17, 16, 16, 15, 14, 14, 13, 13,
+        13, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 15, 16,
+        17, 17, 17, 18, 18, 17, 16, 16, 16, 15, 14, 14, 13, 13, 13, 12, 12, 12,
+        11, 11, 11, 11, 11, 10, 10, 11, 11, 11, 11, 10, 15, 16, 16, 17, 17, 17,
+        18, 17, 17, 16, 15, 15, 14, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11,
+        10, 10, 10, 10, 10, 10, 10, 10, 15, 16, 16, 16, 17, 17, 17, 17, 17, 16,
+        16, 15, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10,
+        10, 10, 10, 10, 15, 15, 16, 16, 17, 17, 17, 17, 16, 16, 16, 15, 14, 14,
+        13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+        14, 15, 15, 16, 16, 16, 17, 17, 16, 16, 15, 15, 14, 14, 14, 13, 13, 12,
+        12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 9, 14, 15, 15, 16,
+        16, 16, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 11,
+        11, 11, 10, 10, 10, 10, 10, 10, 9, 9, 14, 15, 15, 16, 16, 16, 16, 16,
+        16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 11, 10, 10,
+        10, 10, 10, 9, 9, 9, 14, 15, 15, 15, 15, 16, 16, 16, 16, 15, 15, 15, 14,
+        14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9,
+        14, 14, 14, 15, 15, 16, 16, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 12,
+        12, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 9,
+        /* Size 4x8 */
+        33, 22, 18, 16, 26, 23, 20, 17, 22, 19, 17, 16, 22, 17, 15, 14, 20, 16,
+        13, 13, 17, 15, 12, 11, 16, 16, 12, 10, 16, 15, 12, 10,
+        /* Size 8x4 */
+        33, 26, 22, 22, 20, 17, 16, 16, 22, 23, 19, 17, 16, 15, 16, 15, 18, 20,
+        17, 15, 13, 12, 12, 12, 16, 17, 16, 14, 13, 11, 10, 10,
+        /* Size 8x16 */
+        32, 29, 21, 20, 18, 16, 15, 15, 34, 27, 22, 22, 20, 18, 16, 16, 31, 25,
+        22, 22, 20, 18, 17, 16, 26, 22, 21, 22, 20, 19, 18, 17, 21, 21, 19, 19,
+        18, 17, 17, 17, 21, 22, 19, 18, 17, 16, 16, 16, 20, 22, 19, 17, 16, 15,
+        14, 15, 20, 22, 19, 16, 14, 14, 14, 14, 19, 21, 18, 16, 14, 13, 13, 13,
+        17, 19, 18, 15, 13, 12, 12, 12, 16, 19, 17, 15, 12, 12, 11, 12, 16, 18,
+        17, 14, 12, 11, 11, 11, 15, 17, 16, 14, 13, 11, 11, 11, 15, 17, 16, 14,
+        13, 12, 10, 10, 14, 16, 16, 14, 12, 11, 10, 10, 14, 15, 16, 14, 13, 12,
+        10, 10,
+        /* Size 16x8 */
+        32, 34, 31, 26, 21, 21, 20, 20, 19, 17, 16, 16, 15, 15, 14, 14, 29, 27,
+        25, 22, 21, 22, 22, 22, 21, 19, 19, 18, 17, 17, 16, 15, 21, 22, 22, 21,
+        19, 19, 19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 20, 22, 22, 22, 19, 18,
+        17, 16, 16, 15, 15, 14, 14, 14, 14, 14, 18, 20, 20, 20, 18, 17, 16, 14,
+        14, 13, 12, 12, 13, 13, 12, 13, 16, 18, 18, 19, 17, 16, 15, 14, 13, 12,
+        12, 11, 11, 12, 11, 12, 15, 16, 17, 18, 17, 16, 14, 14, 13, 12, 11, 11,
+        11, 10, 10, 10, 15, 16, 16, 17, 17, 16, 15, 14, 13, 12, 12, 11, 11, 10,
+        10, 10,
+        /* Size 16x32 */
+        32, 33, 29, 27, 21, 21, 20, 20, 18, 17, 16, 15, 15, 15, 15, 14, 33, 33,
+        28, 26, 22, 22, 21, 20, 19, 18, 17, 16, 16, 16, 16, 15, 34, 32, 27, 26,
+        22, 23, 22, 21, 20, 19, 18, 17, 16, 16, 16, 15, 33, 31, 27, 25, 22, 23,
+        22, 21, 20, 19, 18, 17, 17, 17, 16, 16, 31, 28, 25, 23, 22, 22, 22, 22,
+        20, 19, 18, 17, 17, 17, 16, 16, 28, 26, 23, 22, 22, 23, 22, 22, 20, 20,
+        19, 18, 17, 17, 17, 17, 26, 25, 22, 22, 21, 22, 22, 21, 20, 19, 19, 18,
+        18, 17, 17, 17, 24, 24, 22, 21, 20, 21, 20, 20, 19, 18, 18, 17, 17, 17,
+        17, 17, 21, 22, 21, 21, 19, 19, 19, 19, 18, 17, 17, 16, 17, 17, 17, 17,
+        21, 22, 22, 21, 19, 19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 16, 21, 22,
+        22, 21, 19, 18, 18, 18, 17, 17, 16, 16, 16, 16, 16, 16, 21, 23, 23, 22,
+        19, 18, 17, 17, 16, 16, 15, 15, 15, 15, 16, 15, 20, 22, 22, 21, 19, 17,
+        17, 16, 16, 15, 15, 14, 14, 15, 15, 15, 20, 22, 22, 21, 19, 17, 17, 16,
+        15, 15, 14, 14, 14, 14, 15, 14, 20, 21, 22, 21, 19, 17, 16, 16, 14, 14,
+        14, 13, 14, 14, 14, 14, 19, 20, 21, 20, 19, 17, 16, 15, 14, 13, 13, 13,
+        13, 13, 14, 14, 19, 20, 21, 20, 18, 16, 16, 15, 14, 13, 13, 13, 13, 13,
+        13, 14, 18, 20, 20, 20, 18, 16, 16, 15, 13, 13, 12, 12, 12, 13, 13, 13,
+        17, 19, 19, 19, 18, 16, 15, 14, 13, 12, 12, 12, 12, 12, 12, 13, 17, 18,
+        19, 19, 17, 16, 15, 14, 13, 12, 12, 12, 12, 12, 12, 12, 16, 18, 19, 18,
+        17, 15, 15, 14, 12, 12, 12, 11, 11, 12, 12, 12, 16, 17, 18, 18, 17, 15,
+        14, 14, 12, 12, 11, 11, 11, 11, 12, 12, 16, 17, 18, 18, 17, 15, 14, 13,
+        12, 12, 11, 11, 11, 11, 11, 12, 15, 17, 17, 18, 16, 15, 14, 13, 12, 12,
+        11, 11, 11, 11, 11, 11, 15, 17, 17, 17, 16, 15, 14, 13, 13, 12, 11, 11,
+        11, 10, 11, 11, 15, 16, 17, 17, 16, 16, 14, 13, 13, 12, 11, 11, 10, 10,
+        10, 10, 15, 16, 17, 17, 16, 16, 14, 13, 13, 12, 12, 11, 10, 10, 10, 10,
+        14, 16, 16, 17, 16, 15, 14, 14, 12, 12, 11, 11, 10, 10, 10, 10, 14, 16,
+        16, 17, 16, 15, 14, 14, 12, 12, 11, 11, 10, 10, 10, 10, 14, 16, 16, 16,
+        16, 15, 14, 13, 13, 12, 11, 11, 10, 10, 10, 10, 14, 15, 15, 16, 16, 15,
+        14, 13, 13, 12, 12, 11, 10, 10, 10, 10, 14, 15, 15, 16, 16, 14, 14, 13,
+        13, 12, 12, 11, 11, 10, 10, 9,
+        /* Size 32x16 */
+        32, 33, 34, 33, 31, 28, 26, 24, 21, 21, 21, 21, 20, 20, 20, 19, 19, 18,
+        17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 33, 33, 32, 31,
+        28, 26, 25, 24, 22, 22, 22, 23, 22, 22, 21, 20, 20, 20, 19, 18, 18, 17,
+        17, 17, 17, 16, 16, 16, 16, 16, 15, 15, 29, 28, 27, 27, 25, 23, 22, 22,
+        21, 22, 22, 23, 22, 22, 22, 21, 21, 20, 19, 19, 19, 18, 18, 17, 17, 17,
+        17, 16, 16, 16, 15, 15, 27, 26, 26, 25, 23, 22, 22, 21, 21, 21, 21, 22,
+        21, 21, 21, 20, 20, 20, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17, 17, 16,
+        16, 16, 21, 22, 22, 22, 22, 22, 21, 20, 19, 19, 19, 19, 19, 19, 19, 19,
+        18, 18, 18, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 21, 22,
+        23, 23, 22, 23, 22, 21, 19, 19, 18, 18, 17, 17, 17, 17, 16, 16, 16, 16,
+        15, 15, 15, 15, 15, 16, 16, 15, 15, 15, 15, 14, 20, 21, 22, 22, 22, 22,
+        22, 20, 19, 19, 18, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 14, 14, 14,
+        14, 14, 14, 14, 14, 14, 14, 14, 20, 20, 21, 21, 22, 22, 21, 20, 19, 18,
+        18, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 13, 14,
+        14, 13, 13, 13, 18, 19, 20, 20, 20, 20, 20, 19, 18, 18, 17, 16, 16, 15,
+        14, 14, 14, 13, 13, 13, 12, 12, 12, 12, 13, 13, 13, 12, 12, 13, 13, 13,
+        17, 18, 19, 19, 19, 20, 19, 18, 17, 17, 17, 16, 15, 15, 14, 13, 13, 13,
+        12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 17, 18, 18,
+        18, 19, 19, 18, 17, 17, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 12, 11,
+        11, 11, 11, 11, 12, 11, 11, 11, 12, 12, 15, 16, 17, 17, 17, 18, 18, 17,
+        16, 16, 16, 15, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 11, 11, 11,
+        11, 11, 11, 11, 11, 11, 15, 16, 16, 17, 17, 17, 18, 17, 17, 16, 16, 15,
+        14, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10,
+        10, 11, 15, 16, 16, 17, 17, 17, 17, 17, 17, 16, 16, 15, 15, 14, 14, 13,
+        13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 15, 16,
+        16, 16, 16, 17, 17, 17, 17, 16, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12,
+        12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 14, 15, 15, 16, 16, 17,
+        17, 17, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 12, 12, 12, 12, 11,
+        11, 10, 10, 10, 10, 10, 10, 9,
+        /* Size 4x16 */
+        33, 21, 17, 15, 32, 23, 19, 16, 28, 22, 19, 17, 25, 22, 19, 17, 22, 19,
+        17, 17, 22, 18, 17, 16, 22, 17, 15, 15, 21, 17, 14, 14, 20, 16, 13, 13,
+        19, 16, 12, 12, 18, 15, 12, 12, 17, 15, 12, 11, 17, 15, 12, 10, 16, 16,
+        12, 10, 16, 15, 12, 10, 15, 15, 12, 10,
+        /* Size 16x4 */
+        33, 32, 28, 25, 22, 22, 22, 21, 20, 19, 18, 17, 17, 16, 16, 15, 21, 23,
+        22, 22, 19, 18, 17, 17, 16, 16, 15, 15, 15, 16, 15, 15, 17, 19, 19, 19,
+        17, 17, 15, 14, 13, 12, 12, 12, 12, 12, 12, 12, 15, 16, 17, 17, 17, 16,
+        15, 14, 13, 12, 12, 11, 10, 10, 10, 10,
+        /* Size 8x32 */
+        32, 29, 21, 20, 18, 16, 15, 15, 33, 28, 22, 21, 19, 17, 16, 16, 34, 27,
+        22, 22, 20, 18, 16, 16, 33, 27, 22, 22, 20, 18, 17, 16, 31, 25, 22, 22,
+        20, 18, 17, 16, 28, 23, 22, 22, 20, 19, 17, 17, 26, 22, 21, 22, 20, 19,
+        18, 17, 24, 22, 20, 20, 19, 18, 17, 17, 21, 21, 19, 19, 18, 17, 17, 17,
+        21, 22, 19, 19, 18, 17, 16, 16, 21, 22, 19, 18, 17, 16, 16, 16, 21, 23,
+        19, 17, 16, 15, 15, 16, 20, 22, 19, 17, 16, 15, 14, 15, 20, 22, 19, 17,
+        15, 14, 14, 15, 20, 22, 19, 16, 14, 14, 14, 14, 19, 21, 19, 16, 14, 13,
+        13, 14, 19, 21, 18, 16, 14, 13, 13, 13, 18, 20, 18, 16, 13, 12, 12, 13,
+        17, 19, 18, 15, 13, 12, 12, 12, 17, 19, 17, 15, 13, 12, 12, 12, 16, 19,
+        17, 15, 12, 12, 11, 12, 16, 18, 17, 14, 12, 11, 11, 12, 16, 18, 17, 14,
+        12, 11, 11, 11, 15, 17, 16, 14, 12, 11, 11, 11, 15, 17, 16, 14, 13, 11,
+        11, 11, 15, 17, 16, 14, 13, 11, 10, 10, 15, 17, 16, 14, 13, 12, 10, 10,
+        14, 16, 16, 14, 12, 11, 10, 10, 14, 16, 16, 14, 12, 11, 10, 10, 14, 16,
+        16, 14, 13, 11, 10, 10, 14, 15, 16, 14, 13, 12, 10, 10, 14, 15, 16, 14,
+        13, 12, 11, 10,
+        /* Size 32x8 */
+        32, 33, 34, 33, 31, 28, 26, 24, 21, 21, 21, 21, 20, 20, 20, 19, 19, 18,
+        17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 29, 28, 27, 27,
+        25, 23, 22, 22, 21, 22, 22, 23, 22, 22, 22, 21, 21, 20, 19, 19, 19, 18,
+        18, 17, 17, 17, 17, 16, 16, 16, 15, 15, 21, 22, 22, 22, 22, 22, 21, 20,
+        19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 16,
+        16, 16, 16, 16, 16, 16, 20, 21, 22, 22, 22, 22, 22, 20, 19, 19, 18, 17,
+        17, 17, 16, 16, 16, 16, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+        14, 14, 18, 19, 20, 20, 20, 20, 20, 19, 18, 18, 17, 16, 16, 15, 14, 14,
+        14, 13, 13, 13, 12, 12, 12, 12, 13, 13, 13, 12, 12, 13, 13, 13, 16, 17,
+        18, 18, 18, 19, 19, 18, 17, 17, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12,
+        12, 11, 11, 11, 11, 11, 12, 11, 11, 11, 12, 12, 15, 16, 16, 17, 17, 17,
+        18, 17, 17, 16, 16, 15, 14, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11,
+        11, 10, 10, 10, 10, 10, 10, 11, 15, 16, 16, 16, 16, 17, 17, 17, 17, 16,
+        16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 10, 10, 10,
+        10, 10, 10, 10 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        52, 25, 25, 13,
+        26, 13, 13, 7,
+#endif
+        /* Size 4x4 */
+        32, 27, 16, 12, 27, 18, 13, 11, 16, 13, 9, 8, 12, 11, 8, 6,
+        /* Size 8x8 */
+        32, 32, 29, 22, 18, 13, 12, 11, 32, 30, 28, 23, 19, 15, 13, 11, 29, 28,
+        21, 18, 16, 13, 12, 11, 22, 23, 18, 15, 13, 11, 10, 10, 18, 19, 16, 13,
+        11, 9, 8, 8, 13, 15, 13, 11, 9, 8, 7, 7, 12, 13, 12, 10, 8, 7, 7, 6, 11,
+        11, 11, 10, 8, 7, 6, 6,
+        /* Size 16x16 */
+        32, 33, 33, 32, 30, 26, 23, 21, 18, 16, 14, 13, 12, 11, 10, 10, 33, 32,
+        32, 32, 30, 27, 25, 22, 19, 17, 16, 14, 13, 12, 11, 10, 33, 32, 31, 30,
+        28, 26, 24, 22, 19, 17, 16, 14, 13, 12, 12, 11, 32, 32, 30, 29, 28, 26,
+        24, 22, 20, 18, 16, 14, 14, 13, 12, 11, 30, 30, 28, 28, 24, 22, 20, 19,
+        17, 16, 15, 13, 12, 12, 12, 11, 26, 27, 26, 26, 22, 19, 18, 17, 15, 14,
+        13, 12, 11, 11, 11, 10, 23, 25, 24, 24, 20, 18, 16, 15, 14, 13, 12, 11,
+        11, 10, 10, 10, 21, 22, 22, 22, 19, 17, 15, 14, 13, 12, 11, 10, 10, 10,
+        9, 9, 18, 19, 19, 20, 17, 15, 14, 13, 11, 11, 10, 9, 9, 9, 9, 8, 16, 17,
+        17, 18, 16, 14, 13, 12, 11, 10, 9, 9, 8, 8, 8, 8, 14, 16, 16, 16, 15,
+        13, 12, 11, 10, 9, 9, 8, 8, 8, 8, 7, 13, 14, 14, 14, 13, 12, 11, 10, 9,
+        9, 8, 7, 7, 7, 7, 7, 12, 13, 13, 14, 12, 11, 11, 10, 9, 8, 8, 7, 7, 7,
+        6, 6, 11, 12, 12, 13, 12, 11, 10, 10, 9, 8, 8, 7, 7, 6, 6, 6, 10, 11,
+        12, 12, 12, 11, 10, 9, 9, 8, 8, 7, 6, 6, 6, 6, 10, 10, 11, 11, 11, 10,
+        10, 9, 8, 8, 7, 7, 6, 6, 6, 5,
+        /* Size 32x32 */
+        32, 33, 33, 33, 33, 32, 32, 30, 30, 28, 26, 25, 23, 21, 21, 19, 18, 17,
+        16, 15, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 10, 33, 32, 32, 32,
+        32, 32, 32, 30, 30, 29, 27, 26, 24, 22, 22, 20, 19, 18, 17, 16, 15, 13,
+        13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 33, 32, 32, 32, 32, 32, 32, 31,
+        30, 30, 27, 26, 25, 23, 22, 20, 19, 19, 17, 16, 16, 14, 14, 13, 13, 12,
+        12, 12, 11, 11, 10, 10, 33, 32, 32, 32, 32, 32, 32, 31, 30, 30, 28, 27,
+        25, 23, 23, 21, 19, 19, 17, 16, 16, 14, 14, 14, 13, 13, 12, 12, 12, 11,
+        11, 11, 33, 32, 32, 32, 31, 31, 30, 29, 28, 28, 26, 26, 24, 23, 22, 20,
+        19, 19, 17, 16, 16, 14, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 32, 32,
+        32, 32, 31, 30, 30, 28, 28, 28, 26, 26, 24, 23, 22, 21, 19, 19, 18, 17,
+        16, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 32, 32, 32, 32, 30, 30,
+        29, 28, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 14,
+        14, 13, 13, 12, 12, 12, 11, 11, 30, 30, 31, 31, 29, 28, 28, 26, 25, 24,
+        23, 22, 22, 20, 20, 19, 18, 17, 16, 16, 15, 14, 14, 13, 13, 13, 12, 12,
+        12, 12, 11, 11, 30, 30, 30, 30, 28, 28, 28, 25, 24, 23, 22, 21, 20, 19,
+        19, 18, 17, 17, 16, 15, 15, 13, 13, 13, 12, 12, 12, 12, 12, 11, 11, 11,
+        28, 29, 30, 30, 28, 28, 27, 24, 23, 21, 20, 20, 19, 18, 18, 17, 16, 16,
+        15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 10, 26, 27, 27, 28,
+        26, 26, 26, 23, 22, 20, 19, 19, 18, 17, 17, 16, 15, 15, 14, 13, 13, 12,
+        12, 12, 11, 12, 11, 11, 11, 11, 10, 10, 25, 26, 26, 27, 26, 26, 25, 22,
+        21, 20, 19, 18, 17, 17, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11,
+        11, 11, 11, 10, 10, 10, 23, 24, 25, 25, 24, 24, 24, 22, 20, 19, 18, 17,
+        16, 16, 15, 14, 14, 14, 13, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10,
+        10, 10, 21, 22, 23, 23, 23, 23, 23, 20, 19, 18, 17, 17, 16, 15, 14, 13,
+        13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 9, 9, 21, 22,
+        22, 23, 22, 22, 22, 20, 19, 18, 17, 16, 15, 14, 14, 13, 13, 12, 12, 11,
+        11, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 19, 20, 20, 21, 20, 21, 21,
+        19, 18, 17, 16, 15, 14, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9,
+        9, 9, 9, 9, 9, 9, 9, 18, 19, 19, 19, 19, 19, 20, 18, 17, 16, 15, 15, 14,
+        13, 13, 12, 11, 11, 11, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 9, 17, 18,
+        19, 19, 19, 19, 19, 17, 17, 16, 15, 14, 14, 13, 12, 12, 11, 11, 10, 10,
+        10, 9, 9, 9, 9, 8, 9, 8, 8, 8, 8, 8, 16, 17, 17, 17, 17, 18, 18, 16, 16,
+        15, 14, 14, 13, 12, 12, 11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8,
+        8, 8, 15, 16, 16, 16, 16, 17, 17, 16, 15, 14, 13, 13, 12, 12, 11, 11,
+        10, 10, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 14, 15, 16, 16, 16,
+        16, 16, 15, 15, 14, 13, 13, 12, 11, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 8,
+        8, 8, 7, 8, 7, 7, 7, 13, 13, 14, 14, 14, 15, 15, 14, 13, 13, 12, 12, 11,
+        11, 10, 10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 13, 13, 14,
+        14, 14, 14, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 7,
+        7, 7, 7, 7, 7, 7, 7, 7, 7, 12, 13, 13, 14, 14, 14, 14, 13, 13, 13, 12,
+        12, 11, 10, 10, 10, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 12,
+        12, 13, 13, 13, 13, 14, 13, 12, 12, 11, 11, 11, 10, 10, 9, 9, 9, 8, 8,
+        8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 11, 12, 12, 13, 13, 13, 13, 13, 12,
+        12, 12, 11, 10, 10, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6,
+        6, 11, 12, 12, 12, 12, 12, 13, 12, 12, 12, 11, 11, 10, 10, 10, 9, 9, 9,
+        8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 11, 11, 12, 12, 12, 12, 12,
+        12, 12, 12, 11, 11, 10, 10, 10, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6,
+        6, 6, 6, 6, 10, 11, 11, 12, 12, 12, 12, 12, 12, 11, 11, 11, 10, 10, 9,
+        9, 9, 8, 8, 8, 8, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 10, 11, 11, 11, 11,
+        11, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6,
+        6, 6, 6, 6, 6, 5, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 9,
+        9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 10, 10, 10, 11,
+        11, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 7, 7, 7, 7, 6, 6,
+        6, 6, 6, 6, 5, 5, 5,
+        /* Size 4x8 */
+        32, 27, 17, 12, 32, 26, 18, 13, 30, 20, 15, 12, 23, 17, 12, 10, 19, 15,
+        10, 9, 14, 12, 9, 8, 12, 12, 8, 7, 11, 10, 8, 6,
+        /* Size 8x4 */
+        32, 32, 30, 23, 19, 14, 12, 11, 27, 26, 20, 17, 15, 12, 12, 10, 17, 18,
+        15, 12, 10, 9, 8, 8, 12, 13, 12, 10, 9, 8, 7, 6,
+        /* Size 8x16 */
+        32, 32, 28, 23, 18, 13, 12, 11, 33, 32, 29, 25, 19, 14, 13, 12, 32, 31,
+        28, 24, 19, 14, 13, 12, 32, 30, 27, 24, 20, 15, 13, 12, 30, 28, 23, 20,
+        17, 14, 13, 12, 26, 26, 20, 18, 15, 12, 12, 11, 23, 24, 19, 16, 14, 11,
+        11, 11, 21, 22, 18, 15, 13, 11, 10, 10, 18, 19, 16, 14, 11, 9, 9, 9, 16,
+        17, 15, 13, 11, 9, 8, 8, 14, 16, 14, 12, 10, 8, 8, 8, 13, 14, 13, 11, 9,
+        8, 7, 7, 12, 13, 12, 11, 9, 7, 7, 7, 11, 12, 12, 10, 9, 8, 7, 6, 10, 12,
+        12, 10, 8, 7, 6, 6, 10, 11, 11, 10, 9, 7, 6, 6,
+        /* Size 16x8 */
+        32, 33, 32, 32, 30, 26, 23, 21, 18, 16, 14, 13, 12, 11, 10, 10, 32, 32,
+        31, 30, 28, 26, 24, 22, 19, 17, 16, 14, 13, 12, 12, 11, 28, 29, 28, 27,
+        23, 20, 19, 18, 16, 15, 14, 13, 12, 12, 12, 11, 23, 25, 24, 24, 20, 18,
+        16, 15, 14, 13, 12, 11, 11, 10, 10, 10, 18, 19, 19, 20, 17, 15, 14, 13,
+        11, 11, 10, 9, 9, 9, 8, 9, 13, 14, 14, 15, 14, 12, 11, 11, 9, 9, 8, 8,
+        7, 8, 7, 7, 12, 13, 13, 13, 13, 12, 11, 10, 9, 8, 8, 7, 7, 7, 6, 6, 11,
+        12, 12, 12, 12, 11, 11, 10, 9, 8, 8, 7, 7, 6, 6, 6,
+        /* Size 16x32 */
+        32, 33, 32, 32, 28, 26, 23, 19, 18, 16, 13, 13, 12, 11, 11, 11, 33, 32,
+        32, 32, 29, 27, 24, 20, 19, 17, 14, 13, 12, 12, 12, 11, 33, 32, 32, 32,
+        29, 27, 25, 20, 19, 17, 14, 14, 13, 12, 12, 11, 33, 32, 32, 31, 30, 28,
+        25, 21, 19, 17, 14, 14, 13, 12, 12, 12, 32, 32, 31, 30, 28, 26, 24, 20,
+        19, 17, 14, 14, 13, 13, 12, 12, 32, 32, 30, 30, 28, 26, 24, 21, 19, 18,
+        15, 14, 13, 13, 12, 12, 32, 31, 30, 29, 27, 26, 24, 21, 20, 18, 15, 15,
+        13, 13, 12, 12, 30, 30, 29, 28, 24, 23, 21, 19, 18, 16, 14, 14, 13, 13,
+        13, 12, 30, 30, 28, 28, 23, 22, 20, 18, 17, 16, 14, 13, 13, 12, 12, 12,
+        28, 30, 28, 27, 21, 20, 19, 17, 16, 15, 13, 13, 12, 12, 12, 12, 26, 28,
+        26, 26, 20, 19, 18, 16, 15, 14, 12, 12, 12, 12, 11, 12, 26, 27, 26, 25,
+        20, 19, 17, 15, 15, 14, 12, 12, 11, 11, 11, 11, 23, 25, 24, 24, 19, 18,
+        16, 14, 14, 13, 11, 11, 11, 11, 11, 11, 22, 23, 23, 22, 18, 17, 16, 14,
+        13, 12, 11, 11, 10, 10, 10, 10, 21, 22, 22, 22, 18, 17, 15, 13, 13, 12,
+        11, 10, 10, 10, 10, 10, 19, 21, 20, 20, 17, 16, 14, 12, 12, 11, 10, 10,
+        9, 9, 10, 9, 18, 19, 19, 19, 16, 15, 14, 12, 11, 11, 9, 9, 9, 9, 9, 9,
+        17, 19, 19, 19, 16, 15, 14, 12, 11, 10, 9, 9, 9, 9, 9, 9, 16, 17, 17,
+        18, 15, 14, 13, 11, 11, 10, 9, 9, 8, 8, 8, 9, 15, 16, 17, 17, 14, 13,
+        12, 11, 10, 9, 8, 8, 8, 8, 8, 8, 14, 16, 16, 16, 14, 13, 12, 11, 10, 9,
+        8, 8, 8, 8, 8, 8, 13, 14, 14, 15, 13, 12, 11, 10, 9, 9, 8, 8, 7, 8, 8,
+        7, 13, 14, 14, 14, 13, 12, 11, 10, 9, 9, 8, 7, 7, 7, 7, 7, 12, 14, 14,
+        14, 13, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 7, 12, 13, 13, 13, 12, 11, 11,
+        9, 9, 8, 7, 7, 7, 7, 7, 7, 11, 12, 13, 13, 12, 12, 10, 9, 9, 8, 8, 7, 7,
+        7, 6, 6, 11, 12, 12, 13, 12, 11, 10, 10, 9, 8, 8, 7, 7, 6, 6, 6, 11, 12,
+        12, 12, 12, 11, 10, 10, 9, 8, 7, 7, 7, 6, 6, 6, 10, 12, 12, 12, 12, 11,
+        10, 9, 8, 8, 7, 7, 6, 6, 6, 6, 10, 11, 11, 12, 11, 10, 10, 9, 9, 8, 7,
+        7, 6, 6, 6, 6, 10, 11, 11, 11, 11, 10, 10, 9, 9, 8, 7, 7, 6, 6, 6, 6,
+        10, 11, 11, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5,
+        /* Size 32x16 */
+        32, 33, 33, 33, 32, 32, 32, 30, 30, 28, 26, 26, 23, 22, 21, 19, 18, 17,
+        16, 15, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 10, 33, 32, 32, 32,
+        32, 32, 31, 30, 30, 30, 28, 27, 25, 23, 22, 21, 19, 19, 17, 16, 16, 14,
+        14, 14, 13, 12, 12, 12, 12, 11, 11, 11, 32, 32, 32, 32, 31, 30, 30, 29,
+        28, 28, 26, 26, 24, 23, 22, 20, 19, 19, 17, 17, 16, 14, 14, 14, 13, 13,
+        12, 12, 12, 11, 11, 11, 32, 32, 32, 31, 30, 30, 29, 28, 28, 27, 26, 25,
+        24, 22, 22, 20, 19, 19, 18, 17, 16, 15, 14, 14, 13, 13, 13, 12, 12, 12,
+        11, 11, 28, 29, 29, 30, 28, 28, 27, 24, 23, 21, 20, 20, 19, 18, 18, 17,
+        16, 16, 15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 12, 11, 11, 11, 26, 27,
+        27, 28, 26, 26, 26, 23, 22, 20, 19, 19, 18, 17, 17, 16, 15, 15, 14, 13,
+        13, 12, 12, 12, 11, 12, 11, 11, 11, 10, 10, 10, 23, 24, 25, 25, 24, 24,
+        24, 21, 20, 19, 18, 17, 16, 16, 15, 14, 14, 14, 13, 12, 12, 11, 11, 11,
+        11, 10, 10, 10, 10, 10, 10, 10, 19, 20, 20, 21, 20, 21, 21, 19, 18, 17,
+        16, 15, 14, 14, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 10, 10, 9,
+        9, 9, 9, 18, 19, 19, 19, 19, 19, 20, 18, 17, 16, 15, 15, 14, 13, 13, 12,
+        11, 11, 11, 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9, 9, 16, 17, 17, 17, 17,
+        18, 18, 16, 16, 15, 14, 14, 13, 12, 12, 11, 11, 10, 10, 9, 9, 9, 9, 8,
+        8, 8, 8, 8, 8, 8, 8, 8, 13, 14, 14, 14, 14, 15, 15, 14, 14, 13, 12, 12,
+        11, 11, 11, 10, 9, 9, 9, 8, 8, 8, 8, 8, 7, 8, 8, 7, 7, 7, 7, 8, 13, 13,
+        14, 14, 14, 14, 15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 9, 8, 8,
+        8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 12, 12, 13, 13, 13, 13, 13, 13, 13, 12,
+        12, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 7,
+        11, 12, 12, 12, 13, 13, 13, 13, 12, 12, 12, 11, 11, 10, 10, 9, 9, 9, 8,
+        8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 11, 12, 12, 12, 12, 12, 12, 13,
+        12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 6, 6, 6, 6,
+        6, 6, 6, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 10, 10, 9,
+        9, 9, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5,
+        /* Size 4x16 */
+        33, 26, 16, 11, 32, 27, 17, 12, 32, 26, 17, 13, 31, 26, 18, 13, 30, 22,
+        16, 12, 28, 19, 14, 12, 25, 18, 13, 11, 22, 17, 12, 10, 19, 15, 11, 9,
+        17, 14, 10, 8, 16, 13, 9, 8, 14, 12, 9, 7, 13, 11, 8, 7, 12, 11, 8, 6,
+        12, 11, 8, 6, 11, 10, 8, 6,
+        /* Size 16x4 */
+        33, 32, 32, 31, 30, 28, 25, 22, 19, 17, 16, 14, 13, 12, 12, 11, 26, 27,
+        26, 26, 22, 19, 18, 17, 15, 14, 13, 12, 11, 11, 11, 10, 16, 17, 17, 18,
+        16, 14, 13, 12, 11, 10, 9, 9, 8, 8, 8, 8, 11, 12, 13, 13, 12, 12, 11,
+        10, 9, 8, 8, 7, 7, 6, 6, 6,
+        /* Size 8x32 */
+        32, 32, 28, 23, 18, 13, 12, 11, 33, 32, 29, 24, 19, 14, 12, 12, 33, 32,
+        29, 25, 19, 14, 13, 12, 33, 32, 30, 25, 19, 14, 13, 12, 32, 31, 28, 24,
+        19, 14, 13, 12, 32, 30, 28, 24, 19, 15, 13, 12, 32, 30, 27, 24, 20, 15,
+        13, 12, 30, 29, 24, 21, 18, 14, 13, 13, 30, 28, 23, 20, 17, 14, 13, 12,
+        28, 28, 21, 19, 16, 13, 12, 12, 26, 26, 20, 18, 15, 12, 12, 11, 26, 26,
+        20, 17, 15, 12, 11, 11, 23, 24, 19, 16, 14, 11, 11, 11, 22, 23, 18, 16,
+        13, 11, 10, 10, 21, 22, 18, 15, 13, 11, 10, 10, 19, 20, 17, 14, 12, 10,
+        9, 10, 18, 19, 16, 14, 11, 9, 9, 9, 17, 19, 16, 14, 11, 9, 9, 9, 16, 17,
+        15, 13, 11, 9, 8, 8, 15, 17, 14, 12, 10, 8, 8, 8, 14, 16, 14, 12, 10, 8,
+        8, 8, 13, 14, 13, 11, 9, 8, 7, 8, 13, 14, 13, 11, 9, 8, 7, 7, 12, 14,
+        13, 11, 9, 8, 7, 7, 12, 13, 12, 11, 9, 7, 7, 7, 11, 13, 12, 10, 9, 8, 7,
+        6, 11, 12, 12, 10, 9, 8, 7, 6, 11, 12, 12, 10, 9, 7, 7, 6, 10, 12, 12,
+        10, 8, 7, 6, 6, 10, 11, 11, 10, 9, 7, 6, 6, 10, 11, 11, 10, 9, 7, 6, 6,
+        10, 11, 11, 10, 9, 8, 7, 6,
+        /* Size 32x8 */
+        32, 33, 33, 33, 32, 32, 32, 30, 30, 28, 26, 26, 23, 22, 21, 19, 18, 17,
+        16, 15, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 10, 32, 32, 32, 32,
+        31, 30, 30, 29, 28, 28, 26, 26, 24, 23, 22, 20, 19, 19, 17, 17, 16, 14,
+        14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 28, 29, 29, 30, 28, 28, 27, 24,
+        23, 21, 20, 20, 19, 18, 18, 17, 16, 16, 15, 14, 14, 13, 13, 13, 12, 12,
+        12, 12, 12, 11, 11, 11, 23, 24, 25, 25, 24, 24, 24, 21, 20, 19, 18, 17,
+        16, 16, 15, 14, 14, 14, 13, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10,
+        10, 10, 18, 19, 19, 19, 19, 19, 20, 18, 17, 16, 15, 15, 14, 13, 13, 12,
+        11, 11, 11, 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9, 9, 13, 14, 14, 14, 14,
+        15, 15, 14, 14, 13, 12, 12, 11, 11, 11, 10, 9, 9, 9, 8, 8, 8, 8, 8, 7,
+        8, 8, 7, 7, 7, 7, 8, 12, 12, 13, 13, 13, 13, 13, 13, 13, 12, 12, 11, 11,
+        10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 7, 11, 12, 12,
+        12, 12, 12, 12, 13, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 8, 8, 8, 8, 7,
+        7, 7, 6, 6, 6, 6, 6, 6, 6 },
+      { /* Chroma */
+#if CONFIG_CHROMA_2X2
+        /* Size 2x2 */
+        21, 18, 18, 11,
 #endif
         /* Size 4x4 */
-        63, 50, 30, 22, 50, 32, 23, 19, 30, 23, 16, 16, 22, 19, 16, 11,
+        32, 23, 19, 16, 23, 19, 17, 15, 19, 17, 13, 12, 16, 15, 12, 10,
         /* Size 8x8 */
-        64, 63, 55, 43, 33, 26, 22, 19, 63, 58, 52, 44, 35, 28, 24, 21, 55, 52,
-        40, 34, 29, 24, 22, 21, 43, 44, 34, 28, 24, 20, 20, 19, 33, 35, 29, 24,
-        20, 17, 15, 16, 26, 28, 24, 20, 17, 15, 14, 12, 22, 24, 22, 20, 15, 14,
-        12, 10, 19, 21, 21, 19, 16, 12, 10, 10,
+        33, 28, 22, 21, 20, 17, 16, 15, 28, 24, 22, 22, 21, 19, 17, 16, 22, 22,
+        19, 19, 19, 17, 16, 16, 21, 22, 19, 17, 16, 15, 14, 14, 20, 21, 19, 16,
+        14, 13, 13, 13, 17, 19, 17, 15, 13, 12, 12, 12, 16, 17, 16, 14, 13, 12,
+        11, 10, 15, 16, 16, 14, 13, 12, 10, 10,
         /* Size 16x16 */
-        64, 65, 65, 63, 57, 52, 43, 38, 33, 29, 26, 24, 22, 20, 19, 18, 65, 64,
-        63, 62, 59, 55, 47, 41, 36, 31, 28, 26, 24, 22, 20, 19, 65, 63, 61, 59,
-        56, 53, 46, 41, 37, 32, 29, 27, 25, 23, 21, 20, 63, 62, 59, 56, 51, 49,
-        44, 40, 36, 32, 29, 27, 26, 24, 23, 21, 57, 59, 56, 51, 42, 41, 37, 34,
-        31, 28, 26, 24, 23, 23, 20, 19, 52, 55, 53, 49, 41, 38, 34, 32, 29, 26,
-        24, 23, 21, 22, 19, 18, 43, 47, 46, 44, 37, 34, 29, 27, 25, 23, 22, 20,
-        20, 19, 19, 17, 38, 41, 41, 40, 34, 32, 27, 25, 23, 21, 20, 19, 19, 17,
-        19, 15, 33, 36, 37, 36, 31, 29, 25, 23, 21, 19, 18, 17, 16, 16, 18, 14,
-        29, 31, 32, 32, 28, 26, 23, 21, 19, 17, 16, 16, 15, 16, 16, 13, 26, 28,
-        29, 29, 26, 24, 22, 20, 18, 16, 15, 15, 15, 15, 15, 12, 24, 26, 27, 27,
-        24, 23, 20, 19, 17, 16, 15, 14, 14, 13, 13, 11, 22, 24, 25, 26, 23, 21,
-        20, 19, 16, 15, 15, 14, 13, 12, 11, 10, 20, 22, 23, 24, 23, 22, 19, 17,
-        16, 16, 15, 13, 12, 12, 11, 9, 19, 20, 21, 23, 20, 19, 19, 19, 18, 16,
-        15, 13, 11, 11, 11, 11, 18, 19, 20, 21, 19, 18, 17, 15, 14, 13, 12, 11,
-        10, 9, 11, 10,
+        32, 34, 31, 28, 23, 21, 21, 20, 19, 18, 17, 16, 15, 15, 15, 14, 34, 33,
+        29, 26, 23, 22, 22, 22, 20, 19, 19, 17, 17, 16, 16, 15, 31, 29, 26, 24,
+        22, 22, 23, 22, 21, 20, 19, 18, 17, 17, 16, 16, 28, 26, 24, 22, 22, 22,
+        23, 22, 21, 20, 20, 19, 18, 18, 17, 16, 23, 23, 22, 22, 20, 20, 20, 20,
+        19, 19, 18, 17, 17, 17, 16, 17, 21, 22, 22, 22, 20, 19, 19, 18, 18, 17,
+        17, 16, 16, 16, 16, 16, 21, 22, 23, 23, 20, 19, 18, 17, 17, 16, 16, 15,
+        15, 15, 15, 15, 20, 22, 22, 22, 20, 18, 17, 17, 16, 15, 15, 14, 14, 14,
+        14, 14, 19, 20, 21, 21, 19, 18, 17, 16, 15, 14, 14, 13, 13, 13, 13, 13,
+        18, 19, 20, 20, 19, 17, 16, 15, 14, 13, 13, 12, 12, 12, 12, 12, 17, 19,
+        19, 20, 18, 17, 16, 15, 14, 13, 12, 12, 12, 12, 12, 12, 16, 17, 18, 19,
+        17, 16, 15, 14, 13, 12, 12, 11, 11, 11, 11, 11, 15, 17, 17, 18, 17, 16,
+        15, 14, 13, 12, 12, 11, 11, 11, 11, 11, 15, 16, 17, 18, 17, 16, 15, 14,
+        13, 12, 12, 11, 11, 10, 10, 10, 15, 16, 16, 17, 16, 16, 15, 14, 13, 12,
+        12, 11, 11, 10, 10, 10, 14, 15, 16, 16, 17, 16, 15, 14, 13, 12, 12, 11,
+        11, 10, 10, 10,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 64, 63, 60, 57, 54, 52, 47, 43, 41, 38, 35, 33, 31,
-        29, 27, 26, 25, 24, 23, 22, 21, 20, 20, 19, 18, 18, 17, 65, 64, 64, 64,
-        64, 63, 62, 60, 59, 55, 53, 48, 45, 43, 40, 36, 35, 33, 30, 28, 27, 26,
-        25, 24, 23, 22, 21, 21, 20, 19, 19, 18, 65, 64, 64, 63, 63, 63, 62, 61,
-        59, 56, 55, 50, 47, 45, 41, 38, 36, 34, 31, 29, 28, 27, 26, 25, 24, 23,
-        22, 21, 20, 20, 19, 18, 65, 64, 63, 63, 63, 62, 61, 60, 59, 56, 54, 50,
-        47, 45, 41, 38, 37, 34, 32, 30, 28, 27, 26, 25, 24, 23, 23, 22, 21, 20,
-        19, 19, 65, 64, 63, 63, 61, 60, 59, 58, 56, 54, 53, 49, 46, 44, 41, 38,
-        37, 35, 32, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 21, 20, 19, 64, 63,
-        63, 62, 60, 58, 57, 55, 53, 52, 51, 48, 46, 44, 41, 38, 37, 35, 33, 31,
-        29, 28, 27, 26, 25, 24, 23, 22, 22, 21, 20, 20, 63, 62, 62, 61, 59, 57,
-        56, 54, 51, 50, 49, 46, 44, 42, 40, 37, 36, 34, 32, 30, 29, 28, 27, 26,
-        26, 25, 24, 24, 23, 22, 21, 19, 60, 60, 61, 60, 58, 55, 54, 52, 48, 47,
-        46, 43, 41, 40, 38, 35, 34, 33, 30, 29, 28, 27, 26, 25, 24, 23, 22, 23,
-        22, 22, 21, 21, 57, 59, 59, 59, 56, 53, 51, 48, 42, 41, 41, 38, 37, 36,
-        34, 32, 31, 30, 28, 27, 26, 25, 24, 24, 23, 23, 23, 21, 20, 19, 19, 20,
-        54, 55, 56, 56, 54, 52, 50, 47, 41, 40, 39, 37, 35, 34, 33, 31, 30, 29,
-        27, 26, 25, 24, 24, 23, 23, 22, 21, 20, 21, 21, 20, 17, 52, 53, 55, 54,
-        53, 51, 49, 46, 41, 39, 38, 35, 34, 33, 32, 30, 29, 28, 26, 25, 24, 24,
-        23, 22, 21, 21, 22, 21, 19, 18, 18, 19, 47, 48, 50, 50, 49, 48, 46, 43,
-        38, 37, 35, 32, 31, 30, 29, 27, 27, 26, 24, 23, 23, 22, 22, 21, 21, 21,
-        20, 19, 19, 20, 19, 17, 43, 45, 47, 47, 46, 46, 44, 41, 37, 35, 34, 31,
-        29, 29, 27, 26, 25, 24, 23, 22, 22, 21, 20, 21, 20, 19, 19, 20, 19, 17,
-        17, 19, 41, 43, 45, 45, 44, 44, 42, 40, 36, 34, 33, 30, 29, 28, 26, 25,
-        25, 24, 22, 21, 21, 20, 20, 20, 19, 20, 20, 17, 17, 19, 19, 15, 38, 40,
-        41, 41, 41, 41, 40, 38, 34, 33, 32, 29, 27, 26, 25, 24, 23, 22, 21, 20,
-        20, 19, 19, 18, 19, 18, 17, 19, 19, 16, 15, 18, 35, 36, 38, 38, 38, 38,
-        37, 35, 32, 31, 30, 27, 26, 25, 24, 22, 22, 21, 20, 19, 19, 18, 18, 18,
-        18, 17, 18, 17, 16, 18, 18, 14, 33, 35, 36, 37, 37, 37, 36, 34, 31, 30,
-        29, 27, 25, 25, 23, 22, 21, 20, 19, 19, 18, 18, 17, 17, 16, 18, 16, 16,
-        18, 15, 14, 17, 31, 33, 34, 34, 35, 35, 34, 33, 30, 29, 28, 26, 24, 24,
-        22, 21, 20, 20, 18, 18, 17, 17, 17, 16, 17, 15, 16, 17, 14, 16, 17, 13,
-        29, 30, 31, 32, 32, 33, 32, 30, 28, 27, 26, 24, 23, 22, 21, 20, 19, 18,
-        17, 17, 16, 16, 16, 16, 15, 15, 16, 14, 16, 14, 13, 16, 27, 28, 29, 30,
-        30, 31, 30, 29, 27, 26, 25, 23, 22, 21, 20, 19, 19, 18, 17, 16, 16, 15,
-        15, 15, 15, 15, 14, 16, 13, 14, 16, 12, 26, 27, 28, 28, 29, 29, 29, 28,
-        26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 16, 15, 15, 15, 14, 15, 13,
-        15, 12, 15, 14, 12, 15, 25, 26, 27, 27, 28, 28, 28, 27, 25, 24, 24, 22,
-        21, 20, 19, 18, 18, 17, 16, 15, 15, 15, 14, 14, 13, 14, 13, 14, 13, 12,
-        15, 11, 24, 25, 26, 26, 27, 27, 27, 26, 24, 24, 23, 22, 20, 20, 19, 18,
-        17, 17, 16, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 14, 11, 15, 23, 24,
-        25, 25, 26, 26, 26, 25, 24, 23, 22, 21, 21, 20, 18, 18, 17, 16, 16, 15,
-        14, 14, 14, 13, 14, 13, 13, 12, 13, 11, 14, 10, 22, 23, 24, 24, 25, 25,
-        26, 24, 23, 23, 21, 21, 20, 19, 19, 18, 16, 17, 15, 15, 15, 13, 14, 14,
-        13, 13, 12, 13, 11, 13, 10, 14, 21, 22, 23, 23, 24, 24, 25, 23, 23, 22,
-        21, 21, 19, 20, 18, 17, 18, 15, 15, 15, 13, 14, 13, 13, 13, 12, 13, 12,
-        13, 10, 13, 10, 20, 21, 22, 23, 23, 23, 24, 22, 23, 21, 22, 20, 19, 20,
-        17, 18, 16, 16, 16, 14, 15, 13, 13, 13, 12, 13, 12, 13, 11, 12, 9, 13,
-        20, 21, 21, 22, 22, 22, 24, 23, 21, 20, 21, 19, 20, 17, 19, 17, 16, 17,
-        14, 16, 12, 14, 13, 12, 13, 12, 13, 11, 12, 11, 12, 8, 19, 20, 20, 21,
-        21, 22, 23, 22, 20, 21, 19, 19, 19, 17, 19, 16, 18, 14, 16, 13, 15, 13,
-        13, 13, 11, 13, 11, 12, 11, 12, 11, 12, 18, 19, 20, 20, 21, 21, 22, 22,
-        19, 21, 18, 20, 17, 19, 16, 18, 15, 16, 14, 14, 14, 12, 14, 11, 13, 10,
-        12, 11, 12, 10, 12, 10, 18, 19, 19, 19, 20, 20, 21, 21, 19, 20, 18, 19,
-        17, 19, 15, 18, 14, 17, 13, 16, 12, 15, 11, 14, 10, 13, 9, 12, 11, 12,
-        10, 12, 17, 18, 18, 19, 19, 20, 19, 21, 20, 17, 19, 17, 19, 15, 18, 14,
-        17, 13, 16, 12, 15, 11, 15, 10, 14, 10, 13, 8, 12, 10, 12, 9,
+        32, 33, 34, 34, 31, 29, 28, 25, 23, 21, 21, 21, 21, 20, 20, 20, 19, 19,
+        18, 17, 17, 16, 16, 16, 15, 15, 15, 15, 15, 14, 14, 14, 33, 33, 33, 33,
+        30, 28, 27, 24, 23, 22, 22, 22, 22, 21, 21, 20, 20, 20, 19, 18, 18, 17,
+        17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 34, 33, 33, 33, 29, 28, 26, 24,
+        23, 22, 22, 22, 22, 22, 22, 21, 20, 20, 19, 19, 19, 18, 17, 17, 17, 16,
+        16, 16, 16, 15, 15, 15, 34, 33, 33, 32, 29, 28, 26, 24, 23, 22, 23, 23,
+        23, 22, 22, 22, 21, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16,
+        16, 16, 31, 30, 29, 29, 26, 25, 24, 23, 22, 22, 22, 22, 23, 22, 22, 22,
+        21, 21, 20, 19, 19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 16, 16, 29, 28,
+        28, 28, 25, 24, 23, 22, 22, 22, 22, 22, 23, 22, 22, 22, 21, 21, 20, 20,
+        19, 19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 16, 28, 27, 26, 26, 24, 23,
+        22, 22, 22, 21, 22, 22, 23, 22, 22, 22, 21, 21, 20, 20, 20, 19, 19, 19,
+        18, 18, 18, 17, 17, 17, 16, 16, 25, 24, 24, 24, 23, 22, 22, 21, 21, 20,
+        21, 21, 21, 20, 20, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17,
+        17, 17, 17, 17, 23, 23, 23, 23, 22, 22, 22, 21, 20, 20, 20, 20, 20, 20,
+        20, 20, 19, 19, 19, 18, 18, 17, 17, 17, 17, 17, 17, 17, 16, 17, 17, 17,
+        21, 22, 22, 22, 22, 22, 21, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        18, 18, 18, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 21, 22, 22, 23,
+        22, 22, 22, 21, 20, 19, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17, 16,
+        16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 21, 22, 22, 23, 22, 22, 22, 21,
+        20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17, 16, 16, 16, 16, 16, 15,
+        15, 15, 15, 15, 15, 15, 21, 22, 22, 23, 23, 23, 23, 21, 20, 19, 19, 18,
+        18, 17, 17, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+        15, 15, 20, 21, 22, 22, 22, 22, 22, 20, 20, 19, 18, 18, 17, 17, 17, 16,
+        16, 16, 16, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 20, 21,
+        22, 22, 22, 22, 22, 20, 20, 19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15,
+        15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 20, 20, 21, 22, 22, 22,
+        22, 20, 20, 19, 18, 18, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14, 14, 14,
+        13, 13, 14, 13, 13, 14, 14, 13, 19, 20, 20, 21, 21, 21, 21, 20, 19, 19,
+        18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13,
+        13, 13, 13, 13, 19, 20, 20, 20, 21, 21, 21, 20, 19, 19, 17, 17, 17, 16,
+        16, 15, 15, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+        18, 19, 19, 20, 20, 20, 20, 19, 19, 18, 17, 17, 16, 16, 15, 15, 14, 14,
+        13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 17, 18, 19, 19,
+        19, 20, 20, 19, 18, 18, 17, 17, 16, 15, 15, 14, 14, 14, 13, 13, 13, 12,
+        12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 17, 18, 19, 19, 19, 19, 20, 19,
+        18, 18, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 12, 12,
+        12, 12, 12, 12, 12, 12, 16, 17, 18, 18, 18, 19, 19, 18, 17, 17, 16, 16,
+        15, 15, 14, 14, 13, 13, 12, 12, 12, 12, 12, 11, 11, 12, 11, 12, 11, 12,
+        12, 12, 16, 17, 17, 18, 18, 18, 19, 18, 17, 17, 16, 16, 15, 14, 14, 14,
+        13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 16, 17,
+        17, 18, 18, 18, 19, 18, 17, 17, 16, 16, 15, 14, 14, 14, 13, 13, 12, 12,
+        12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 15, 16, 17, 17, 17, 18,
+        18, 17, 17, 16, 16, 16, 15, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11,
+        11, 11, 11, 11, 11, 11, 11, 11, 15, 16, 16, 17, 17, 17, 18, 17, 17, 16,
+        16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11, 10,
+        10, 10, 11, 10, 15, 16, 16, 17, 17, 17, 18, 17, 17, 16, 16, 15, 15, 14,
+        14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10,
+        15, 16, 16, 16, 17, 17, 17, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13,
+        12, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 15, 15, 16, 16,
+        16, 17, 17, 17, 16, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12, 11,
+        11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 14, 15, 15, 16, 16, 16, 17, 17,
+        17, 16, 16, 15, 15, 14, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 10,
+        10, 10, 10, 10, 10, 10, 14, 15, 15, 16, 16, 16, 16, 17, 17, 16, 16, 15,
+        15, 14, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10,
+        10, 10, 14, 15, 15, 16, 16, 16, 16, 17, 17, 16, 16, 15, 15, 14, 14, 13,
+        13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 9,
         /* Size 4x8 */
-        64, 48, 29, 21, 62, 48, 32, 23, 56, 37, 27, 21, 45, 30, 22, 17, 34, 26,
-        18, 17, 27, 22, 16, 14, 23, 21, 15, 12, 20, 20, 16, 12,
+        33, 22, 19, 16, 27, 22, 20, 17, 22, 19, 18, 17, 22, 18, 16, 14, 20, 17,
+        14, 13, 18, 16, 12, 12, 17, 16, 12, 11, 16, 15, 12, 10,
         /* Size 8x4 */
-        64, 62, 56, 45, 34, 27, 23, 20, 48, 48, 37, 30, 26, 22, 21, 20, 29, 32,
-        27, 22, 18, 16, 15, 16, 21, 23, 21, 17, 17, 14, 12, 12,
+        33, 27, 22, 22, 20, 18, 17, 16, 22, 22, 19, 18, 17, 16, 16, 15, 19, 20,
+        18, 16, 14, 12, 12, 12, 16, 17, 17, 14, 13, 12, 11, 10,
         /* Size 8x16 */
-        64, 64, 57, 43, 31, 26, 22, 19, 65, 63, 59, 47, 34, 28, 24, 21, 64, 60,
-        56, 46, 35, 29, 25, 22, 63, 58, 51, 44, 34, 29, 25, 23, 57, 55, 43, 37,
-        30, 26, 24, 20, 52, 51, 41, 34, 28, 24, 21, 19, 44, 45, 37, 29, 24, 22,
-        19, 17, 38, 41, 34, 27, 22, 20, 19, 16, 34, 37, 31, 25, 20, 18, 18, 15,
-        29, 32, 28, 23, 18, 16, 15, 14, 26, 29, 26, 22, 17, 15, 14, 14, 24, 27,
-        24, 20, 17, 15, 13, 13, 22, 25, 23, 20, 16, 13, 13, 13, 20, 23, 21, 19,
-        17, 15, 12, 13, 19, 21, 20, 17, 14, 12, 12, 12, 18, 20, 19, 17, 14, 12,
+        32, 30, 21, 21, 19, 16, 15, 15, 33, 28, 22, 22, 20, 18, 17, 16, 31, 26,
+        22, 22, 21, 18, 17, 17, 28, 23, 22, 23, 21, 19, 18, 17, 23, 22, 20, 20,
+        19, 17, 17, 17, 21, 22, 19, 18, 18, 16, 16, 16, 21, 23, 19, 18, 17, 15,
+        15, 15, 20, 22, 19, 17, 16, 14, 14, 14, 19, 21, 19, 17, 15, 13, 13, 13,
+        18, 20, 18, 16, 14, 12, 12, 13, 17, 19, 18, 16, 14, 12, 12, 12, 16, 18,
+        17, 15, 13, 12, 11, 12, 16, 17, 16, 15, 13, 11, 11, 11, 15, 17, 16, 14,
+        13, 12, 11, 10, 15, 16, 16, 15, 13, 12, 11, 10, 14, 16, 16, 15, 13, 12,
+        11, 10,
+        /* Size 16x8 */
+        32, 33, 31, 28, 23, 21, 21, 20, 19, 18, 17, 16, 16, 15, 15, 14, 30, 28,
+        26, 23, 22, 22, 23, 22, 21, 20, 19, 18, 17, 17, 16, 16, 21, 22, 22, 22,
+        20, 19, 19, 19, 19, 18, 18, 17, 16, 16, 16, 16, 21, 22, 22, 23, 20, 18,
+        18, 17, 17, 16, 16, 15, 15, 14, 15, 15, 19, 20, 21, 21, 19, 18, 17, 16,
+        15, 14, 14, 13, 13, 13, 13, 13, 16, 18, 18, 19, 17, 16, 15, 14, 13, 12,
+        12, 12, 11, 12, 12, 12, 15, 17, 17, 18, 17, 16, 15, 14, 13, 12, 12, 11,
+        11, 11, 11, 11, 15, 16, 17, 17, 17, 16, 15, 14, 13, 13, 12, 12, 11, 10,
         10, 10,
-        /* Size 16x8 */
-        64, 65, 64, 63, 57, 52, 44, 38, 34, 29, 26, 24, 22, 20, 19, 18, 64, 63,
-        60, 58, 55, 51, 45, 41, 37, 32, 29, 27, 25, 23, 21, 20, 57, 59, 56, 51,
-        43, 41, 37, 34, 31, 28, 26, 24, 23, 21, 20, 19, 43, 47, 46, 44, 37, 34,
-        29, 27, 25, 23, 22, 20, 20, 19, 17, 17, 31, 34, 35, 34, 30, 28, 24, 22,
-        20, 18, 17, 17, 16, 17, 14, 14, 26, 28, 29, 29, 26, 24, 22, 20, 18, 16,
-        15, 15, 13, 15, 12, 12, 22, 24, 25, 25, 24, 21, 19, 19, 18, 15, 14, 13,
-        13, 12, 12, 10, 19, 21, 22, 23, 20, 19, 17, 16, 15, 14, 14, 13, 13, 13,
-        12, 10,
         /* Size 16x32 */
-        64, 65, 64, 63, 57, 47, 43, 38, 31, 28, 26, 23, 22, 20, 19, 18, 65, 64,
-        63, 62, 58, 48, 45, 40, 33, 29, 27, 24, 23, 21, 20, 19, 65, 63, 63, 62,
-        59, 50, 47, 41, 34, 31, 28, 25, 24, 22, 21, 19, 65, 63, 62, 61, 59, 50,
-        47, 41, 34, 31, 29, 26, 24, 23, 21, 20, 64, 63, 60, 59, 56, 49, 46, 41,
-        35, 31, 29, 26, 25, 23, 22, 20, 64, 62, 59, 57, 53, 48, 46, 41, 35, 32,
-        30, 27, 25, 23, 22, 21, 63, 62, 58, 56, 51, 46, 44, 40, 34, 31, 29, 27,
-        25, 24, 23, 20, 60, 60, 57, 54, 48, 43, 41, 38, 33, 30, 28, 25, 24, 24,
-        23, 22, 57, 59, 55, 51, 43, 38, 37, 34, 30, 28, 26, 24, 24, 22, 20, 21,
-        54, 56, 53, 49, 41, 37, 35, 33, 29, 27, 25, 24, 22, 21, 21, 18, 52, 55,
-        51, 48, 41, 35, 34, 32, 28, 26, 24, 23, 21, 22, 19, 20, 47, 50, 48, 46,
-        38, 33, 31, 29, 26, 24, 23, 21, 22, 19, 21, 17, 44, 47, 45, 43, 37, 31,
-        29, 27, 24, 23, 22, 21, 19, 21, 17, 20, 42, 45, 44, 42, 36, 30, 29, 26,
-        24, 22, 21, 20, 20, 17, 20, 16, 38, 41, 41, 40, 34, 29, 27, 25, 22, 21,
-        20, 18, 19, 19, 16, 19, 35, 38, 38, 37, 32, 27, 26, 24, 21, 20, 19, 18,
-        17, 17, 18, 15, 34, 36, 37, 36, 31, 27, 25, 23, 20, 19, 18, 17, 18, 16,
-        15, 18, 32, 34, 35, 34, 30, 26, 24, 22, 20, 18, 17, 16, 16, 17, 16, 13,
-        29, 31, 32, 31, 28, 24, 23, 21, 18, 17, 16, 16, 15, 14, 14, 17, 27, 29,
-        30, 30, 27, 23, 22, 20, 18, 17, 16, 15, 16, 16, 15, 12, 26, 28, 29, 29,
-        26, 23, 22, 20, 17, 16, 15, 14, 14, 13, 14, 16, 25, 27, 28, 28, 25, 22,
-        21, 19, 17, 16, 15, 14, 14, 14, 13, 12, 24, 26, 27, 27, 24, 22, 20, 19,
-        17, 15, 15, 14, 13, 13, 13, 15, 23, 25, 26, 26, 24, 21, 21, 18, 16, 16,
-        14, 13, 13, 12, 12, 10, 22, 24, 25, 25, 23, 21, 20, 17, 16, 16, 13, 14,
-        13, 13, 13, 14, 21, 23, 24, 25, 22, 21, 20, 17, 18, 15, 13, 14, 12, 12,
-        10, 10, 20, 23, 23, 24, 21, 22, 19, 17, 17, 14, 15, 12, 12, 13, 13, 13,
-        20, 22, 22, 23, 21, 21, 17, 19, 16, 14, 15, 12, 13, 11, 11, 9, 19, 21,
-        21, 22, 20, 20, 17, 19, 14, 16, 12, 13, 12, 11, 12, 12, 18, 20, 21, 21,
-        20, 20, 17, 18, 14, 16, 12, 14, 10, 12, 10, 11, 18, 19, 20, 21, 19, 19,
-        17, 18, 14, 16, 12, 14, 10, 12, 10, 12, 17, 19, 19, 20, 20, 17, 19, 14,
-        17, 12, 15, 10, 14, 9, 12, 10,
+        32, 33, 30, 28, 21, 21, 21, 20, 19, 18, 16, 16, 15, 15, 15, 15, 33, 33,
+        29, 27, 22, 22, 22, 20, 20, 19, 17, 17, 16, 16, 16, 16, 33, 32, 28, 26,
+        22, 22, 22, 21, 20, 19, 18, 17, 17, 16, 16, 16, 34, 32, 28, 26, 22, 23,
+        23, 21, 21, 20, 18, 18, 17, 17, 17, 16, 31, 28, 26, 24, 22, 22, 22, 22,
+        21, 20, 18, 18, 17, 17, 17, 16, 29, 27, 24, 23, 22, 22, 23, 22, 21, 20,
+        19, 18, 18, 17, 17, 17, 28, 26, 23, 22, 22, 22, 23, 22, 21, 20, 19, 19,
+        18, 18, 17, 17, 24, 24, 23, 22, 20, 20, 21, 20, 20, 19, 18, 18, 17, 18,
+        17, 17, 23, 23, 22, 22, 20, 20, 20, 20, 19, 19, 17, 17, 17, 17, 17, 17,
+        21, 22, 22, 21, 19, 19, 19, 19, 19, 18, 17, 17, 16, 17, 17, 16, 21, 22,
+        22, 22, 19, 19, 18, 18, 18, 17, 16, 16, 16, 16, 16, 16, 21, 23, 22, 22,
+        19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 16, 16, 21, 23, 23, 22, 19, 18,
+        18, 17, 17, 16, 15, 15, 15, 15, 15, 16, 20, 22, 22, 22, 19, 18, 17, 16,
+        16, 16, 15, 14, 15, 14, 15, 15, 20, 22, 22, 22, 19, 18, 17, 16, 16, 15,
+        14, 14, 14, 14, 14, 15, 20, 21, 22, 22, 19, 18, 17, 16, 15, 14, 14, 14,
+        13, 14, 14, 14, 19, 21, 21, 21, 19, 18, 17, 15, 15, 14, 13, 13, 13, 13,
+        13, 14, 19, 20, 21, 21, 19, 17, 17, 15, 15, 14, 13, 13, 13, 13, 13, 13,
+        18, 20, 20, 20, 18, 17, 16, 15, 14, 13, 12, 12, 12, 12, 13, 13, 17, 19,
+        20, 20, 18, 17, 16, 14, 14, 13, 12, 12, 12, 12, 12, 12, 17, 19, 19, 20,
+        18, 17, 16, 14, 14, 13, 12, 12, 12, 12, 12, 12, 16, 18, 18, 19, 17, 16,
+        15, 14, 13, 12, 12, 11, 11, 12, 12, 12, 16, 18, 18, 19, 17, 16, 15, 14,
+        13, 12, 12, 11, 11, 11, 12, 12, 16, 17, 18, 18, 17, 16, 15, 14, 13, 12,
+        11, 11, 11, 11, 11, 11, 16, 17, 17, 18, 16, 16, 15, 13, 13, 12, 11, 11,
+        11, 11, 11, 11, 15, 17, 17, 18, 16, 16, 15, 14, 13, 12, 12, 11, 11, 11,
+        11, 11, 15, 17, 17, 17, 16, 16, 14, 14, 13, 12, 12, 11, 11, 11, 10, 11,
+        15, 16, 17, 17, 16, 16, 14, 14, 13, 12, 12, 11, 11, 10, 10, 10, 15, 16,
+        16, 17, 16, 16, 15, 14, 13, 13, 12, 11, 11, 10, 10, 10, 14, 16, 16, 17,
+        16, 15, 15, 14, 13, 12, 12, 11, 11, 10, 10, 10, 14, 16, 16, 17, 16, 15,
+        15, 14, 13, 12, 12, 11, 11, 10, 10, 10, 14, 16, 16, 16, 16, 15, 15, 13,
+        13, 12, 12, 11, 11, 10, 10, 10,
         /* Size 32x16 */
-        64, 65, 65, 65, 64, 64, 63, 60, 57, 54, 52, 47, 44, 42, 38, 35, 34, 32,
-        29, 27, 26, 25, 24, 23, 22, 21, 20, 20, 19, 18, 18, 17, 65, 64, 63, 63,
-        63, 62, 62, 60, 59, 56, 55, 50, 47, 45, 41, 38, 36, 34, 31, 29, 28, 27,
-        26, 25, 24, 23, 23, 22, 21, 20, 19, 19, 64, 63, 63, 62, 60, 59, 58, 57,
-        55, 53, 51, 48, 45, 44, 41, 38, 37, 35, 32, 30, 29, 28, 27, 26, 25, 24,
-        23, 22, 21, 21, 20, 19, 63, 62, 62, 61, 59, 57, 56, 54, 51, 49, 48, 46,
-        43, 42, 40, 37, 36, 34, 31, 30, 29, 28, 27, 26, 25, 25, 24, 23, 22, 21,
-        21, 20, 57, 58, 59, 59, 56, 53, 51, 48, 43, 41, 41, 38, 37, 36, 34, 32,
-        31, 30, 28, 27, 26, 25, 24, 24, 23, 22, 21, 21, 20, 20, 19, 20, 47, 48,
-        50, 50, 49, 48, 46, 43, 38, 37, 35, 33, 31, 30, 29, 27, 27, 26, 24, 23,
-        23, 22, 22, 21, 21, 21, 22, 21, 20, 20, 19, 17, 43, 45, 47, 47, 46, 46,
-        44, 41, 37, 35, 34, 31, 29, 29, 27, 26, 25, 24, 23, 22, 22, 21, 20, 21,
-        20, 20, 19, 17, 17, 17, 17, 19, 38, 40, 41, 41, 41, 41, 40, 38, 34, 33,
-        32, 29, 27, 26, 25, 24, 23, 22, 21, 20, 20, 19, 19, 18, 17, 17, 17, 19,
-        19, 18, 18, 14, 31, 33, 34, 34, 35, 35, 34, 33, 30, 29, 28, 26, 24, 24,
-        22, 21, 20, 20, 18, 18, 17, 17, 17, 16, 16, 18, 17, 16, 14, 14, 14, 17,
-        28, 29, 31, 31, 31, 32, 31, 30, 28, 27, 26, 24, 23, 22, 21, 20, 19, 18,
-        17, 17, 16, 16, 15, 16, 16, 15, 14, 14, 16, 16, 16, 12, 26, 27, 28, 29,
-        29, 30, 29, 28, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 16, 15, 15,
-        15, 14, 13, 13, 15, 15, 12, 12, 12, 15, 23, 24, 25, 26, 26, 27, 27, 25,
-        24, 24, 23, 21, 21, 20, 18, 18, 17, 16, 16, 15, 14, 14, 14, 13, 14, 14,
-        12, 12, 13, 14, 14, 10, 22, 23, 24, 24, 25, 25, 25, 24, 24, 22, 21, 22,
-        19, 20, 19, 17, 18, 16, 15, 16, 14, 14, 13, 13, 13, 12, 12, 13, 12, 10,
-        10, 14, 20, 21, 22, 23, 23, 23, 24, 24, 22, 21, 22, 19, 21, 17, 19, 17,
-        16, 17, 14, 16, 13, 14, 13, 12, 13, 12, 13, 11, 11, 12, 12, 9, 19, 20,
-        21, 21, 22, 22, 23, 23, 20, 21, 19, 21, 17, 20, 16, 18, 15, 16, 14, 15,
-        14, 13, 13, 12, 13, 10, 13, 11, 12, 10, 10, 12, 18, 19, 19, 20, 20, 21,
-        20, 22, 21, 18, 20, 17, 20, 16, 19, 15, 18, 13, 17, 12, 16, 12, 15, 10,
-        14, 10, 13, 9, 12, 11, 12, 10,
+        32, 33, 33, 34, 31, 29, 28, 24, 23, 21, 21, 21, 21, 20, 20, 20, 19, 19,
+        18, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 33, 33, 32, 32,
+        28, 27, 26, 24, 23, 22, 22, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18,
+        18, 17, 17, 17, 17, 16, 16, 16, 16, 16, 30, 29, 28, 28, 26, 24, 23, 23,
+        22, 22, 22, 22, 23, 22, 22, 22, 21, 21, 20, 20, 19, 18, 18, 18, 17, 17,
+        17, 17, 16, 16, 16, 16, 28, 27, 26, 26, 24, 23, 22, 22, 22, 21, 22, 22,
+        22, 22, 22, 22, 21, 21, 20, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 17,
+        17, 16, 21, 22, 22, 22, 22, 22, 22, 20, 20, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 21, 22,
+        22, 23, 22, 22, 22, 20, 20, 19, 19, 19, 18, 18, 18, 18, 18, 17, 17, 17,
+        17, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 21, 22, 22, 23, 22, 23,
+        23, 21, 20, 19, 18, 18, 18, 17, 17, 17, 17, 17, 16, 16, 16, 15, 15, 15,
+        15, 15, 14, 14, 15, 15, 15, 15, 20, 20, 21, 21, 22, 22, 22, 20, 20, 19,
+        18, 18, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14, 14, 14, 13, 14, 14, 14,
+        14, 14, 14, 13, 19, 20, 20, 21, 21, 21, 21, 20, 19, 19, 18, 17, 17, 16,
+        16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+        18, 19, 19, 20, 20, 20, 20, 19, 19, 18, 17, 17, 16, 16, 15, 14, 14, 14,
+        13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 13, 12, 12, 12, 16, 17, 18, 18,
+        18, 19, 19, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 12,
+        12, 11, 11, 12, 12, 12, 12, 12, 12, 12, 16, 17, 17, 18, 18, 18, 19, 18,
+        17, 17, 16, 16, 15, 14, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11, 11,
+        11, 11, 11, 11, 11, 11, 15, 16, 17, 17, 17, 18, 18, 17, 17, 16, 16, 16,
+        15, 15, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+        11, 11, 15, 16, 16, 17, 17, 17, 18, 18, 17, 17, 16, 16, 15, 14, 14, 14,
+        13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 15, 16,
+        16, 17, 17, 17, 17, 17, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12,
+        12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 15, 16, 16, 16, 16, 17,
+        17, 17, 17, 16, 16, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 12, 11,
+        11, 11, 11, 10, 10, 10, 10, 10,
         /* Size 4x16 */
-        65, 47, 28, 20, 63, 50, 31, 22, 63, 49, 31, 23, 62, 46, 31, 24, 59, 38,
-        28, 22, 55, 35, 26, 22, 47, 31, 23, 21, 41, 29, 21, 19, 36, 27, 19, 16,
-        31, 24, 17, 14, 28, 23, 16, 13, 26, 22, 15, 13, 24, 21, 16, 13, 23, 22,
-        14, 13, 21, 20, 16, 11, 19, 19, 16, 12,
+        33, 21, 18, 15, 32, 22, 19, 16, 28, 22, 20, 17, 26, 22, 20, 18, 23, 20,
+        19, 17, 22, 19, 17, 16, 23, 18, 16, 15, 22, 18, 15, 14, 21, 18, 14, 13,
+        20, 17, 13, 12, 19, 17, 13, 12, 18, 16, 12, 11, 17, 16, 12, 11, 17, 16,
+        12, 11, 16, 16, 13, 10, 16, 15, 12, 10,
         /* Size 16x4 */
-        65, 63, 63, 62, 59, 55, 47, 41, 36, 31, 28, 26, 24, 23, 21, 19, 47, 50,
-        49, 46, 38, 35, 31, 29, 27, 24, 23, 22, 21, 22, 20, 19, 28, 31, 31, 31,
-        28, 26, 23, 21, 19, 17, 16, 15, 16, 14, 16, 16, 20, 22, 23, 24, 22, 22,
-        21, 19, 16, 14, 13, 13, 13, 13, 11, 12,
+        33, 32, 28, 26, 23, 22, 23, 22, 21, 20, 19, 18, 17, 17, 16, 16, 21, 22,
+        22, 22, 20, 19, 18, 18, 18, 17, 17, 16, 16, 16, 16, 15, 18, 19, 20, 20,
+        19, 17, 16, 15, 14, 13, 13, 12, 12, 12, 13, 12, 15, 16, 17, 18, 17, 16,
+        15, 14, 13, 12, 12, 11, 11, 11, 10, 10,
         /* Size 8x32 */
-        64, 64, 57, 43, 31, 26, 22, 19, 65, 63, 58, 45, 33, 27, 23, 20, 65, 63,
-        59, 47, 34, 28, 24, 21, 65, 62, 59, 47, 34, 29, 24, 21, 64, 60, 56, 46,
-        35, 29, 25, 22, 64, 59, 53, 46, 35, 30, 25, 22, 63, 58, 51, 44, 34, 29,
-        25, 23, 60, 57, 48, 41, 33, 28, 24, 23, 57, 55, 43, 37, 30, 26, 24, 20,
-        54, 53, 41, 35, 29, 25, 22, 21, 52, 51, 41, 34, 28, 24, 21, 19, 47, 48,
-        38, 31, 26, 23, 22, 21, 44, 45, 37, 29, 24, 22, 19, 17, 42, 44, 36, 29,
-        24, 21, 20, 20, 38, 41, 34, 27, 22, 20, 19, 16, 35, 38, 32, 26, 21, 19,
-        17, 18, 34, 37, 31, 25, 20, 18, 18, 15, 32, 35, 30, 24, 20, 17, 16, 16,
-        29, 32, 28, 23, 18, 16, 15, 14, 27, 30, 27, 22, 18, 16, 16, 15, 26, 29,
-        26, 22, 17, 15, 14, 14, 25, 28, 25, 21, 17, 15, 14, 13, 24, 27, 24, 20,
-        17, 15, 13, 13, 23, 26, 24, 21, 16, 14, 13, 12, 22, 25, 23, 20, 16, 13,
-        13, 13, 21, 24, 22, 20, 18, 13, 12, 10, 20, 23, 21, 19, 17, 15, 12, 13,
-        20, 22, 21, 17, 16, 15, 13, 11, 19, 21, 20, 17, 14, 12, 12, 12, 18, 21,
-        20, 17, 14, 12, 10, 10, 18, 20, 19, 17, 14, 12, 10, 10, 17, 19, 20, 19,
-        17, 15, 14, 12,
+        32, 30, 21, 21, 19, 16, 15, 15, 33, 29, 22, 22, 20, 17, 16, 16, 33, 28,
+        22, 22, 20, 18, 17, 16, 34, 28, 22, 23, 21, 18, 17, 17, 31, 26, 22, 22,
+        21, 18, 17, 17, 29, 24, 22, 23, 21, 19, 18, 17, 28, 23, 22, 23, 21, 19,
+        18, 17, 24, 23, 20, 21, 20, 18, 17, 17, 23, 22, 20, 20, 19, 17, 17, 17,
+        21, 22, 19, 19, 19, 17, 16, 17, 21, 22, 19, 18, 18, 16, 16, 16, 21, 22,
+        19, 18, 17, 16, 16, 16, 21, 23, 19, 18, 17, 15, 15, 15, 20, 22, 19, 17,
+        16, 15, 15, 15, 20, 22, 19, 17, 16, 14, 14, 14, 20, 22, 19, 17, 15, 14,
+        13, 14, 19, 21, 19, 17, 15, 13, 13, 13, 19, 21, 19, 17, 15, 13, 13, 13,
+        18, 20, 18, 16, 14, 12, 12, 13, 17, 20, 18, 16, 14, 12, 12, 12, 17, 19,
+        18, 16, 14, 12, 12, 12, 16, 18, 17, 15, 13, 12, 11, 12, 16, 18, 17, 15,
+        13, 12, 11, 12, 16, 18, 17, 15, 13, 11, 11, 11, 16, 17, 16, 15, 13, 11,
+        11, 11, 15, 17, 16, 15, 13, 12, 11, 11, 15, 17, 16, 14, 13, 12, 11, 10,
+        15, 17, 16, 14, 13, 12, 11, 10, 15, 16, 16, 15, 13, 12, 11, 10, 14, 16,
+        16, 15, 13, 12, 11, 10, 14, 16, 16, 15, 13, 12, 11, 10, 14, 16, 16, 15,
+        13, 12, 11, 10,
         /* Size 32x8 */
-        64, 65, 65, 65, 64, 64, 63, 60, 57, 54, 52, 47, 44, 42, 38, 35, 34, 32,
-        29, 27, 26, 25, 24, 23, 22, 21, 20, 20, 19, 18, 18, 17, 64, 63, 63, 62,
-        60, 59, 58, 57, 55, 53, 51, 48, 45, 44, 41, 38, 37, 35, 32, 30, 29, 28,
-        27, 26, 25, 24, 23, 22, 21, 21, 20, 19, 57, 58, 59, 59, 56, 53, 51, 48,
-        43, 41, 41, 38, 37, 36, 34, 32, 31, 30, 28, 27, 26, 25, 24, 24, 23, 22,
-        21, 21, 20, 20, 19, 20, 43, 45, 47, 47, 46, 46, 44, 41, 37, 35, 34, 31,
-        29, 29, 27, 26, 25, 24, 23, 22, 22, 21, 20, 21, 20, 20, 19, 17, 17, 17,
-        17, 19, 31, 33, 34, 34, 35, 35, 34, 33, 30, 29, 28, 26, 24, 24, 22, 21,
-        20, 20, 18, 18, 17, 17, 17, 16, 16, 18, 17, 16, 14, 14, 14, 17, 26, 27,
-        28, 29, 29, 30, 29, 28, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 16,
-        15, 15, 15, 14, 13, 13, 15, 15, 12, 12, 12, 15, 22, 23, 24, 24, 25, 25,
-        25, 24, 24, 22, 21, 22, 19, 20, 19, 17, 18, 16, 15, 16, 14, 14, 13, 13,
-        13, 12, 12, 13, 12, 10, 10, 14, 19, 20, 21, 21, 22, 22, 23, 23, 20, 21,
-        19, 21, 17, 20, 16, 18, 15, 16, 14, 15, 14, 13, 13, 12, 13, 10, 13, 11,
-        12, 10, 10, 12 },
-      { /* Chroma */
-#if CONFIG_CB4X4
-        /* Size 2x2 */
-        42, 34, 34, 21,
-#endif
-        /* Size 4x4 */
-        62, 46, 37, 31, 46, 35, 31, 28, 37, 31, 24, 24, 31, 28, 24, 19,
-        /* Size 8x8 */
-        65, 53, 43, 42, 38, 33, 31, 28, 53, 43, 44, 44, 41, 37, 34, 31, 43, 44,
-        38, 37, 35, 32, 31, 31, 42, 44, 37, 33, 30, 28, 28, 28, 38, 41, 35, 30,
-        27, 25, 23, 25, 33, 37, 32, 28, 25, 22, 22, 20, 31, 34, 31, 28, 23, 22,
-        20, 17, 28, 31, 31, 28, 25, 20, 17, 18,
-        /* Size 16x16 */
-        64, 67, 61, 53, 42, 42, 41, 39, 37, 34, 32, 31, 29, 28, 27, 26, 67, 65,
-        58, 50, 44, 45, 44, 43, 40, 37, 35, 34, 32, 31, 29, 28, 61, 58, 53, 47,
-        43, 44, 44, 43, 41, 38, 36, 35, 34, 33, 31, 30, 53, 50, 47, 43, 42, 43,
-        43, 43, 41, 38, 37, 35, 35, 34, 33, 32, 42, 44, 43, 42, 39, 39, 38, 38,
-        37, 35, 34, 33, 32, 32, 29, 29, 42, 45, 44, 43, 39, 38, 36, 36, 35, 33,
-        32, 31, 30, 31, 28, 27, 41, 44, 44, 43, 38, 36, 34, 33, 31, 30, 29, 28,
-        29, 28, 28, 26, 39, 43, 43, 43, 38, 36, 33, 31, 29, 28, 27, 27, 27, 25,
-        28, 24, 37, 40, 41, 41, 37, 35, 31, 29, 28, 27, 26, 25, 24, 24, 26, 23,
-        34, 37, 38, 38, 35, 33, 30, 28, 27, 25, 24, 23, 23, 24, 25, 21, 32, 35,
-        36, 37, 34, 32, 29, 27, 26, 24, 23, 22, 23, 23, 23, 20, 31, 34, 35, 35,
-        33, 31, 28, 27, 25, 23, 22, 22, 21, 21, 21, 19, 29, 32, 34, 35, 32, 30,
-        29, 27, 24, 23, 23, 21, 20, 20, 18, 18, 28, 31, 33, 34, 32, 31, 28, 25,
-        24, 24, 23, 21, 20, 19, 19, 16, 27, 29, 31, 33, 29, 28, 28, 28, 26, 25,
-        23, 21, 18, 19, 18, 18, 26, 28, 30, 32, 29, 27, 26, 24, 23, 21, 20, 19,
-        18, 16, 18, 17,
-        /* Size 32x32 */
-        64, 66, 67, 66, 61, 56, 53, 49, 42, 42, 42, 42, 41, 40, 39, 38, 37, 36,
-        34, 33, 32, 32, 31, 30, 29, 29, 28, 28, 27, 27, 26, 26, 66, 65, 65, 64,
-        59, 53, 51, 48, 43, 43, 44, 44, 43, 42, 41, 39, 39, 38, 36, 35, 34, 33,
-        33, 32, 31, 31, 30, 29, 29, 28, 28, 27, 67, 65, 65, 63, 58, 52, 50, 48,
-        44, 45, 45, 45, 44, 44, 43, 41, 40, 39, 37, 36, 35, 35, 34, 33, 32, 32,
-        31, 30, 29, 29, 28, 27, 66, 64, 63, 62, 57, 51, 49, 48, 44, 45, 45, 46,
-        45, 44, 43, 41, 41, 40, 38, 37, 36, 35, 34, 33, 33, 32, 32, 31, 30, 30,
-        29, 29, 61, 59, 58, 57, 53, 47, 47, 46, 43, 44, 44, 45, 44, 44, 43, 41,
-        41, 40, 38, 37, 36, 36, 35, 34, 34, 33, 33, 32, 31, 30, 30, 28, 56, 53,
-        52, 51, 47, 43, 43, 43, 43, 44, 44, 45, 45, 44, 44, 42, 42, 41, 39, 38,
-        38, 37, 36, 35, 34, 34, 32, 32, 31, 31, 30, 30, 53, 51, 50, 49, 47, 43,
-        43, 43, 42, 43, 43, 44, 43, 43, 43, 41, 41, 40, 38, 38, 37, 36, 35, 35,
-        35, 34, 34, 34, 33, 32, 32, 29, 49, 48, 48, 48, 46, 43, 43, 42, 41, 41,
-        41, 42, 41, 41, 41, 39, 39, 38, 37, 36, 36, 35, 34, 34, 33, 32, 32, 33,
-        33, 32, 31, 32, 42, 43, 44, 44, 43, 43, 42, 41, 39, 39, 39, 38, 38, 38,
-        38, 37, 37, 36, 35, 34, 34, 33, 33, 32, 32, 33, 32, 31, 29, 29, 29, 31,
-        42, 43, 45, 45, 44, 44, 43, 41, 39, 38, 38, 37, 37, 37, 37, 36, 35, 35,
-        34, 33, 33, 32, 32, 32, 32, 31, 30, 30, 31, 31, 30, 27, 42, 44, 45, 45,
-        44, 44, 43, 41, 39, 38, 38, 37, 36, 36, 36, 35, 35, 34, 33, 33, 32, 32,
-        31, 31, 30, 30, 31, 31, 28, 28, 27, 30, 42, 44, 45, 46, 45, 45, 44, 42,
-        38, 37, 37, 35, 34, 34, 33, 33, 33, 32, 31, 31, 30, 30, 30, 29, 30, 30,
-        28, 28, 29, 30, 29, 26, 41, 43, 44, 45, 44, 45, 43, 41, 38, 37, 36, 34,
-        34, 33, 33, 32, 31, 31, 30, 30, 29, 29, 28, 29, 29, 27, 28, 29, 28, 26,
-        26, 29, 40, 42, 44, 44, 44, 44, 43, 41, 38, 37, 36, 34, 33, 33, 32, 31,
-        31, 30, 29, 29, 29, 28, 28, 28, 27, 28, 28, 26, 26, 28, 28, 24, 39, 41,
-        43, 43, 43, 44, 43, 41, 38, 37, 36, 33, 33, 32, 31, 30, 29, 29, 28, 28,
-        27, 27, 27, 26, 27, 27, 25, 27, 28, 24, 24, 28, 38, 39, 41, 41, 41, 42,
-        41, 39, 37, 36, 35, 33, 32, 31, 30, 29, 28, 28, 27, 27, 26, 26, 26, 26,
-        26, 25, 27, 25, 24, 27, 27, 23, 37, 39, 40, 41, 41, 42, 41, 39, 37, 35,
-        35, 33, 31, 31, 29, 28, 28, 27, 27, 26, 26, 25, 25, 25, 24, 26, 24, 24,
-        26, 24, 23, 27, 36, 38, 39, 40, 40, 41, 40, 38, 36, 35, 34, 32, 31, 30,
-        29, 28, 27, 27, 26, 25, 25, 25, 24, 24, 25, 23, 24, 25, 22, 25, 26, 22,
-        34, 36, 37, 38, 38, 39, 38, 37, 35, 34, 33, 31, 30, 29, 28, 27, 27, 26,
-        25, 24, 24, 24, 23, 24, 23, 23, 24, 22, 25, 23, 21, 26, 33, 35, 36, 37,
-        37, 38, 38, 36, 34, 33, 33, 31, 30, 29, 28, 27, 26, 25, 24, 24, 23, 23,
-        23, 23, 22, 23, 22, 24, 21, 23, 25, 20, 32, 34, 35, 36, 36, 38, 37, 36,
-        34, 33, 32, 30, 29, 29, 27, 26, 26, 25, 24, 23, 23, 23, 22, 22, 23, 21,
-        23, 20, 23, 23, 20, 24, 32, 33, 35, 35, 36, 37, 36, 35, 33, 32, 32, 30,
-        29, 28, 27, 26, 25, 25, 24, 23, 23, 22, 22, 22, 21, 22, 20, 22, 21, 20,
-        23, 19, 31, 33, 34, 34, 35, 36, 35, 34, 33, 32, 31, 30, 28, 28, 27, 26,
-        25, 24, 23, 23, 22, 22, 22, 22, 21, 20, 21, 21, 21, 22, 19, 23, 30, 32,
-        33, 33, 34, 35, 35, 34, 32, 32, 31, 29, 29, 28, 26, 26, 25, 24, 24, 23,
-        22, 22, 22, 21, 21, 21, 20, 20, 21, 19, 22, 18, 29, 31, 32, 33, 34, 34,
-        35, 33, 32, 32, 30, 30, 29, 27, 27, 26, 24, 25, 23, 22, 23, 21, 21, 21,
-        20, 21, 20, 20, 18, 21, 18, 22, 29, 31, 32, 32, 33, 34, 34, 32, 33, 31,
-        30, 30, 27, 28, 27, 25, 26, 23, 23, 23, 21, 22, 20, 21, 21, 20, 21, 20,
-        21, 17, 21, 17, 28, 30, 31, 32, 33, 32, 34, 32, 32, 30, 31, 28, 28, 28,
-        25, 27, 24, 24, 24, 22, 23, 20, 21, 20, 20, 21, 19, 20, 19, 20, 16, 21,
-        28, 29, 30, 31, 32, 32, 34, 33, 31, 30, 31, 28, 29, 26, 27, 25, 24, 25,
-        22, 24, 20, 22, 21, 20, 20, 20, 20, 19, 20, 19, 20, 15, 27, 29, 29, 30,
-        31, 31, 33, 33, 29, 31, 28, 29, 28, 26, 28, 24, 26, 22, 25, 21, 23, 21,
-        21, 21, 18, 21, 19, 20, 18, 20, 18, 20, 27, 28, 29, 30, 30, 31, 32, 32,
-        29, 31, 28, 30, 26, 28, 24, 27, 24, 25, 23, 23, 23, 20, 22, 19, 21, 17,
-        20, 19, 20, 18, 20, 18, 26, 28, 28, 29, 30, 30, 32, 31, 29, 30, 27, 29,
-        26, 28, 24, 27, 23, 26, 21, 25, 20, 23, 19, 22, 18, 21, 16, 20, 18, 20,
-        17, 19, 26, 27, 27, 29, 28, 30, 29, 32, 31, 27, 30, 26, 29, 24, 28, 23,
-        27, 22, 26, 20, 24, 19, 23, 18, 22, 17, 21, 15, 20, 18, 19, 17,
-        /* Size 4x8 */
-        65, 44, 36, 30, 51, 45, 39, 32, 45, 37, 34, 31, 44, 34, 29, 26, 39, 32,
-        26, 25, 35, 30, 24, 22, 32, 30, 23, 20, 29, 30, 25, 20,
-        /* Size 8x4 */
-        65, 51, 45, 44, 39, 35, 32, 29, 44, 45, 37, 34, 32, 30, 30, 30, 36, 39,
-        34, 29, 26, 24, 23, 25, 30, 32, 31, 26, 25, 22, 20, 20,
-        /* Size 8x16 */
-        64, 58, 43, 41, 36, 32, 29, 27, 67, 54, 45, 44, 39, 35, 32, 29, 61, 49,
-        44, 44, 40, 37, 34, 31, 53, 45, 42, 43, 40, 37, 35, 33, 42, 43, 39, 38,
-        36, 34, 33, 29, 42, 44, 39, 36, 34, 32, 30, 28, 41, 44, 38, 34, 31, 29,
-        27, 26, 39, 43, 38, 32, 29, 27, 27, 25, 37, 41, 37, 31, 27, 26, 26, 24,
-        34, 39, 35, 30, 26, 24, 23, 23, 32, 37, 34, 29, 25, 23, 21, 22, 31, 35,
-        33, 28, 24, 22, 21, 21, 30, 34, 32, 29, 24, 21, 21, 21, 28, 33, 30, 28,
-        26, 23, 20, 20, 27, 31, 30, 26, 23, 20, 20, 20, 26, 30, 29, 26, 23, 20,
-        18, 18,
-        /* Size 16x8 */
-        64, 67, 61, 53, 42, 42, 41, 39, 37, 34, 32, 31, 30, 28, 27, 26, 58, 54,
-        49, 45, 43, 44, 44, 43, 41, 39, 37, 35, 34, 33, 31, 30, 43, 45, 44, 42,
-        39, 39, 38, 38, 37, 35, 34, 33, 32, 30, 30, 29, 41, 44, 44, 43, 38, 36,
-        34, 32, 31, 30, 29, 28, 29, 28, 26, 26, 36, 39, 40, 40, 36, 34, 31, 29,
-        27, 26, 25, 24, 24, 26, 23, 23, 32, 35, 37, 37, 34, 32, 29, 27, 26, 24,
-        23, 22, 21, 23, 20, 20, 29, 32, 34, 35, 33, 30, 27, 27, 26, 23, 21, 21,
-        21, 20, 20, 18, 27, 29, 31, 33, 29, 28, 26, 25, 24, 23, 22, 21, 21, 20,
-        20, 18,
-        /* Size 16x32 */
-        64, 66, 58, 53, 43, 42, 41, 39, 36, 34, 32, 30, 29, 28, 27, 26, 65, 65,
-        55, 51, 44, 44, 42, 41, 38, 36, 34, 32, 31, 30, 29, 28, 67, 64, 54, 51,
-        45, 45, 44, 42, 39, 37, 35, 33, 32, 31, 29, 28, 66, 62, 53, 49, 45, 45,
-        44, 43, 39, 37, 36, 34, 33, 32, 30, 30, 61, 57, 49, 47, 44, 45, 44, 43,
-        40, 38, 37, 34, 34, 32, 31, 29, 55, 51, 45, 43, 43, 45, 45, 44, 41, 39,
-        38, 36, 34, 32, 31, 31, 53, 50, 45, 43, 42, 44, 43, 42, 40, 38, 37, 35,
-        35, 34, 33, 30, 49, 48, 44, 43, 41, 41, 41, 41, 38, 37, 36, 34, 33, 33,
-        33, 33, 42, 44, 43, 42, 39, 38, 38, 38, 36, 35, 34, 32, 33, 31, 29, 32,
-        42, 45, 44, 42, 39, 37, 37, 36, 35, 34, 33, 32, 31, 31, 31, 27, 42, 45,
-        44, 43, 39, 37, 36, 36, 34, 33, 32, 31, 30, 31, 28, 30, 42, 45, 45, 44,
-        38, 35, 34, 33, 32, 31, 30, 29, 30, 28, 30, 26, 41, 44, 44, 43, 38, 34,
-        34, 32, 31, 30, 29, 29, 27, 29, 26, 29, 40, 44, 44, 43, 38, 34, 33, 32,
-        30, 29, 29, 28, 28, 26, 29, 25, 39, 43, 43, 42, 38, 34, 32, 31, 29, 28,
-        27, 26, 27, 27, 25, 28, 38, 41, 42, 41, 37, 33, 32, 30, 28, 27, 26, 26,
-        25, 25, 27, 23, 37, 40, 41, 41, 37, 33, 31, 29, 27, 26, 26, 25, 26, 25,
-        24, 27, 36, 39, 41, 40, 36, 32, 31, 29, 27, 26, 25, 24, 24, 25, 25, 22,
-        34, 38, 39, 38, 35, 31, 30, 28, 26, 25, 24, 23, 23, 23, 23, 26, 33, 36,
-        38, 37, 34, 31, 29, 28, 25, 24, 23, 23, 23, 24, 23, 20, 32, 36, 37, 37,
-        34, 30, 29, 27, 25, 24, 23, 22, 21, 21, 22, 25, 32, 35, 36, 36, 33, 30,
-        29, 27, 25, 24, 23, 22, 22, 22, 21, 20, 31, 34, 35, 35, 33, 30, 28, 27,
-        24, 23, 22, 22, 21, 21, 21, 23, 30, 33, 35, 35, 32, 30, 29, 26, 24, 24,
-        22, 21, 21, 20, 20, 18, 30, 33, 34, 34, 32, 30, 29, 25, 24, 24, 21, 21,
-        21, 20, 21, 22, 29, 32, 33, 34, 31, 30, 29, 25, 26, 23, 21, 21, 20, 20,
-        18, 17, 28, 31, 33, 33, 30, 31, 28, 25, 26, 22, 23, 20, 20, 21, 20, 21,
-        28, 31, 32, 33, 30, 30, 26, 27, 24, 22, 23, 19, 21, 19, 19, 16, 27, 30,
-        31, 32, 30, 30, 26, 28, 23, 25, 20, 21, 20, 19, 20, 20, 27, 29, 30, 32,
-        29, 30, 26, 27, 23, 25, 20, 22, 18, 20, 18, 18, 26, 29, 30, 31, 29, 29,
-        26, 27, 23, 25, 20, 22, 18, 20, 18, 20, 26, 29, 28, 32, 31, 26, 29, 23,
-        27, 20, 24, 18, 22, 16, 20, 17,
-        /* Size 32x16 */
-        64, 65, 67, 66, 61, 55, 53, 49, 42, 42, 42, 42, 41, 40, 39, 38, 37, 36,
-        34, 33, 32, 32, 31, 30, 30, 29, 28, 28, 27, 27, 26, 26, 66, 65, 64, 62,
-        57, 51, 50, 48, 44, 45, 45, 45, 44, 44, 43, 41, 40, 39, 38, 36, 36, 35,
-        34, 33, 33, 32, 31, 31, 30, 29, 29, 29, 58, 55, 54, 53, 49, 45, 45, 44,
-        43, 44, 44, 45, 44, 44, 43, 42, 41, 41, 39, 38, 37, 36, 35, 35, 34, 33,
-        33, 32, 31, 30, 30, 28, 53, 51, 51, 49, 47, 43, 43, 43, 42, 42, 43, 44,
-        43, 43, 42, 41, 41, 40, 38, 37, 37, 36, 35, 35, 34, 34, 33, 33, 32, 32,
-        31, 32, 43, 44, 45, 45, 44, 43, 42, 41, 39, 39, 39, 38, 38, 38, 38, 37,
-        37, 36, 35, 34, 34, 33, 33, 32, 32, 31, 30, 30, 30, 29, 29, 31, 42, 44,
-        45, 45, 45, 45, 44, 41, 38, 37, 37, 35, 34, 34, 34, 33, 33, 32, 31, 31,
-        30, 30, 30, 30, 30, 30, 31, 30, 30, 30, 29, 26, 41, 42, 44, 44, 44, 45,
-        43, 41, 38, 37, 36, 34, 34, 33, 32, 32, 31, 31, 30, 29, 29, 29, 28, 29,
-        29, 29, 28, 26, 26, 26, 26, 29, 39, 41, 42, 43, 43, 44, 42, 41, 38, 36,
-        36, 33, 32, 32, 31, 30, 29, 29, 28, 28, 27, 27, 27, 26, 25, 25, 25, 27,
-        28, 27, 27, 23, 36, 38, 39, 39, 40, 41, 40, 38, 36, 35, 34, 32, 31, 30,
-        29, 28, 27, 27, 26, 25, 25, 25, 24, 24, 24, 26, 26, 24, 23, 23, 23, 27,
-        34, 36, 37, 37, 38, 39, 38, 37, 35, 34, 33, 31, 30, 29, 28, 27, 26, 26,
-        25, 24, 24, 24, 23, 24, 24, 23, 22, 22, 25, 25, 25, 20, 32, 34, 35, 36,
-        37, 38, 37, 36, 34, 33, 32, 30, 29, 29, 27, 26, 26, 25, 24, 23, 23, 23,
-        22, 22, 21, 21, 23, 23, 20, 20, 20, 24, 30, 32, 33, 34, 34, 36, 35, 34,
-        32, 32, 31, 29, 29, 28, 26, 26, 25, 24, 23, 23, 22, 22, 22, 21, 21, 21,
-        20, 19, 21, 22, 22, 18, 29, 31, 32, 33, 34, 34, 35, 33, 33, 31, 30, 30,
-        27, 28, 27, 25, 26, 24, 23, 23, 21, 22, 21, 21, 21, 20, 20, 21, 20, 18,
-        18, 22, 28, 30, 31, 32, 32, 32, 34, 33, 31, 31, 31, 28, 29, 26, 27, 25,
-        25, 25, 23, 24, 21, 22, 21, 20, 20, 20, 21, 19, 19, 20, 20, 16, 27, 29,
-        29, 30, 31, 31, 33, 33, 29, 31, 28, 30, 26, 29, 25, 27, 24, 25, 23, 23,
-        22, 21, 21, 20, 21, 18, 20, 19, 20, 18, 18, 20, 26, 28, 28, 30, 29, 31,
-        30, 33, 32, 27, 30, 26, 29, 25, 28, 23, 27, 22, 26, 20, 25, 20, 23, 18,
-        22, 17, 21, 16, 20, 18, 20, 17,
-        /* Size 4x16 */
-        66, 42, 34, 28, 64, 45, 37, 31, 57, 45, 38, 32, 50, 44, 38, 34, 44, 38,
-        35, 31, 45, 37, 33, 31, 44, 34, 30, 29, 43, 34, 28, 27, 40, 33, 26, 25,
-        38, 31, 25, 23, 36, 30, 24, 21, 34, 30, 23, 21, 33, 30, 24, 20, 31, 31,
-        22, 21, 30, 30, 25, 19, 29, 29, 25, 20,
-        /* Size 16x4 */
-        66, 64, 57, 50, 44, 45, 44, 43, 40, 38, 36, 34, 33, 31, 30, 29, 42, 45,
-        45, 44, 38, 37, 34, 34, 33, 31, 30, 30, 30, 31, 30, 29, 34, 37, 38, 38,
-        35, 33, 30, 28, 26, 25, 24, 23, 24, 22, 25, 25, 28, 31, 32, 34, 31, 31,
-        29, 27, 25, 23, 21, 21, 20, 21, 19, 20,
-        /* Size 8x32 */
-        64, 58, 43, 41, 36, 32, 29, 27, 65, 55, 44, 42, 38, 34, 31, 29, 67, 54,
-        45, 44, 39, 35, 32, 29, 66, 53, 45, 44, 39, 36, 33, 30, 61, 49, 44, 44,
-        40, 37, 34, 31, 55, 45, 43, 45, 41, 38, 34, 31, 53, 45, 42, 43, 40, 37,
-        35, 33, 49, 44, 41, 41, 38, 36, 33, 33, 42, 43, 39, 38, 36, 34, 33, 29,
-        42, 44, 39, 37, 35, 33, 31, 31, 42, 44, 39, 36, 34, 32, 30, 28, 42, 45,
-        38, 34, 32, 30, 30, 30, 41, 44, 38, 34, 31, 29, 27, 26, 40, 44, 38, 33,
-        30, 29, 28, 29, 39, 43, 38, 32, 29, 27, 27, 25, 38, 42, 37, 32, 28, 26,
-        25, 27, 37, 41, 37, 31, 27, 26, 26, 24, 36, 41, 36, 31, 27, 25, 24, 25,
-        34, 39, 35, 30, 26, 24, 23, 23, 33, 38, 34, 29, 25, 23, 23, 23, 32, 37,
-        34, 29, 25, 23, 21, 22, 32, 36, 33, 29, 25, 23, 22, 21, 31, 35, 33, 28,
-        24, 22, 21, 21, 30, 35, 32, 29, 24, 22, 21, 20, 30, 34, 32, 29, 24, 21,
-        21, 21, 29, 33, 31, 29, 26, 21, 20, 18, 28, 33, 30, 28, 26, 23, 20, 20,
-        28, 32, 30, 26, 24, 23, 21, 19, 27, 31, 30, 26, 23, 20, 20, 20, 27, 30,
-        29, 26, 23, 20, 18, 18, 26, 30, 29, 26, 23, 20, 18, 18, 26, 28, 31, 29,
-        27, 24, 22, 20,
-        /* Size 32x8 */
-        64, 65, 67, 66, 61, 55, 53, 49, 42, 42, 42, 42, 41, 40, 39, 38, 37, 36,
-        34, 33, 32, 32, 31, 30, 30, 29, 28, 28, 27, 27, 26, 26, 58, 55, 54, 53,
-        49, 45, 45, 44, 43, 44, 44, 45, 44, 44, 43, 42, 41, 41, 39, 38, 37, 36,
-        35, 35, 34, 33, 33, 32, 31, 30, 30, 28, 43, 44, 45, 45, 44, 43, 42, 41,
-        39, 39, 39, 38, 38, 38, 38, 37, 37, 36, 35, 34, 34, 33, 33, 32, 32, 31,
-        30, 30, 30, 29, 29, 31, 41, 42, 44, 44, 44, 45, 43, 41, 38, 37, 36, 34,
-        34, 33, 32, 32, 31, 31, 30, 29, 29, 29, 28, 29, 29, 29, 28, 26, 26, 26,
-        26, 29, 36, 38, 39, 39, 40, 41, 40, 38, 36, 35, 34, 32, 31, 30, 29, 28,
-        27, 27, 26, 25, 25, 25, 24, 24, 24, 26, 26, 24, 23, 23, 23, 27, 32, 34,
-        35, 36, 37, 38, 37, 36, 34, 33, 32, 30, 29, 29, 27, 26, 26, 25, 24, 23,
-        23, 23, 22, 22, 21, 21, 23, 23, 20, 20, 20, 24, 29, 31, 32, 33, 34, 34,
-        35, 33, 33, 31, 30, 30, 27, 28, 27, 25, 26, 24, 23, 23, 21, 22, 21, 21,
-        21, 20, 20, 21, 20, 18, 18, 22, 27, 29, 29, 30, 31, 31, 33, 33, 29, 31,
-        28, 30, 26, 29, 25, 27, 24, 25, 23, 23, 22, 21, 21, 20, 21, 18, 20, 19,
-        20, 18, 18, 20 },
+        32, 33, 33, 34, 31, 29, 28, 24, 23, 21, 21, 21, 21, 20, 20, 20, 19, 19,
+        18, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 30, 29, 28, 28,
+        26, 24, 23, 23, 22, 22, 22, 22, 23, 22, 22, 22, 21, 21, 20, 20, 19, 18,
+        18, 18, 17, 17, 17, 17, 16, 16, 16, 16, 21, 22, 22, 22, 22, 22, 22, 20,
+        20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16,
+        16, 16, 16, 16, 16, 16, 21, 22, 22, 23, 22, 23, 23, 21, 20, 19, 18, 18,
+        18, 17, 17, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15, 15, 14, 14, 15, 15,
+        15, 15, 19, 20, 20, 21, 21, 21, 21, 20, 19, 19, 18, 17, 17, 16, 16, 15,
+        15, 15, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 16, 17,
+        18, 18, 18, 19, 19, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12,
+        12, 12, 12, 11, 11, 12, 12, 12, 12, 12, 12, 12, 15, 16, 17, 17, 17, 18,
+        18, 17, 17, 16, 16, 16, 15, 15, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11,
+        11, 11, 11, 11, 11, 11, 11, 11, 15, 16, 16, 17, 17, 17, 17, 17, 17, 17,
+        16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 10, 10,
+        10, 10, 10, 10 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        52, 27, 27, 15,
+        28, 14, 14, 8,
+#endif
+        /* Size 4x4 */
+        32, 28, 18, 13, 28, 19, 14, 11, 18, 14, 10, 8, 13, 11, 8, 7,
+        /* Size 8x8 */
+        32, 32, 29, 24, 19, 15, 13, 11, 32, 31, 28, 24, 20, 16, 14, 12, 29, 28,
+        22, 20, 17, 14, 13, 12, 24, 24, 20, 16, 14, 12, 11, 10, 19, 20, 17, 14,
+        12, 10, 9, 9, 15, 16, 14, 12, 10, 9, 8, 8, 13, 14, 13, 11, 9, 8, 7, 7,
+        11, 12, 12, 10, 9, 8, 7, 6,
+        /* Size 16x16 */
+        32, 33, 33, 32, 30, 28, 25, 22, 19, 17, 16, 14, 12, 12, 11, 11, 33, 32,
+        32, 32, 30, 29, 26, 23, 20, 19, 17, 15, 13, 13, 12, 11, 33, 32, 31, 31,
+        29, 28, 26, 23, 21, 19, 17, 15, 14, 13, 12, 12, 32, 32, 31, 29, 28, 27,
+        25, 23, 21, 19, 18, 16, 14, 14, 13, 12, 30, 30, 29, 28, 26, 24, 22, 20,
+        19, 18, 16, 15, 13, 13, 12, 12, 28, 29, 28, 27, 24, 21, 20, 18, 17, 16,
+        15, 14, 13, 12, 11, 11, 25, 26, 26, 25, 22, 20, 18, 17, 15, 14, 14, 12,
+        12, 11, 11, 11, 22, 23, 23, 23, 20, 18, 17, 15, 14, 13, 12, 11, 11, 10,
+        10, 10, 19, 20, 21, 21, 19, 17, 15, 14, 12, 12, 11, 10, 10, 9, 9, 9, 17,
+        19, 19, 19, 18, 16, 14, 13, 12, 11, 10, 10, 9, 9, 9, 8, 16, 17, 17, 18,
+        16, 15, 14, 12, 11, 10, 10, 9, 9, 8, 8, 8, 14, 15, 15, 16, 15, 14, 12,
+        11, 10, 10, 9, 8, 8, 8, 7, 7, 12, 13, 14, 14, 13, 13, 12, 11, 10, 9, 9,
+        8, 7, 7, 7, 7, 12, 13, 13, 14, 13, 12, 11, 10, 9, 9, 8, 8, 7, 7, 7, 6,
+        11, 12, 12, 13, 12, 11, 11, 10, 9, 9, 8, 7, 7, 7, 6, 6, 11, 11, 12, 12,
+        12, 11, 11, 10, 9, 8, 8, 7, 7, 6, 6, 6,
+        /* Size 32x32 */
+        32, 33, 33, 33, 33, 33, 32, 32, 30, 29, 28, 26, 25, 23, 22, 21, 19, 18,
+        17, 16, 16, 14, 14, 13, 12, 12, 12, 11, 11, 11, 11, 10, 33, 32, 32, 32,
+        32, 32, 32, 31, 30, 29, 29, 27, 26, 24, 23, 22, 20, 19, 18, 17, 17, 15,
+        14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 33, 32, 32, 32, 32, 32, 32, 31,
+        30, 30, 29, 27, 26, 24, 23, 23, 20, 20, 19, 17, 17, 15, 15, 14, 13, 13,
+        13, 12, 12, 12, 11, 11, 33, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 28,
+        27, 25, 23, 23, 21, 20, 19, 18, 17, 16, 15, 14, 14, 14, 13, 13, 12, 12,
+        12, 11, 33, 32, 32, 32, 31, 31, 31, 30, 29, 28, 28, 26, 26, 24, 23, 23,
+        21, 20, 19, 18, 17, 16, 15, 14, 14, 14, 13, 13, 12, 12, 12, 11, 33, 32,
+        32, 32, 31, 31, 30, 30, 29, 28, 28, 26, 26, 24, 23, 23, 20, 20, 19, 18,
+        17, 16, 15, 14, 14, 14, 13, 13, 12, 12, 12, 12, 32, 32, 32, 32, 31, 30,
+        29, 28, 28, 27, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 18, 16, 16, 15,
+        14, 14, 14, 13, 13, 12, 12, 12, 32, 31, 31, 31, 30, 30, 28, 28, 27, 26,
+        26, 24, 24, 23, 22, 22, 20, 19, 19, 17, 17, 16, 15, 14, 14, 14, 13, 13,
+        13, 12, 12, 12, 30, 30, 30, 31, 29, 29, 28, 27, 26, 24, 24, 23, 22, 22,
+        20, 20, 19, 18, 18, 17, 16, 15, 15, 14, 13, 13, 13, 12, 12, 12, 12, 12,
+        29, 29, 30, 30, 28, 28, 27, 26, 24, 22, 22, 21, 20, 20, 19, 19, 17, 17,
+        17, 16, 15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 11, 11, 28, 29, 29, 30,
+        28, 28, 27, 26, 24, 22, 21, 20, 20, 19, 18, 18, 17, 17, 16, 15, 15, 14,
+        14, 13, 13, 13, 12, 12, 11, 11, 11, 11, 26, 27, 27, 28, 26, 26, 26, 24,
+        23, 21, 20, 19, 19, 18, 17, 17, 16, 16, 15, 14, 14, 13, 13, 12, 12, 12,
+        11, 11, 11, 11, 11, 11, 25, 26, 26, 27, 26, 26, 25, 24, 22, 20, 20, 19,
+        18, 17, 17, 16, 15, 15, 14, 14, 14, 13, 12, 12, 12, 12, 11, 11, 11, 11,
+        11, 10, 23, 24, 24, 25, 24, 24, 24, 23, 22, 20, 19, 18, 17, 16, 16, 15,
+        14, 14, 14, 13, 13, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 22, 23,
+        23, 23, 23, 23, 23, 22, 20, 19, 18, 17, 17, 16, 15, 15, 14, 13, 13, 12,
+        12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 21, 22, 23, 23, 23, 23,
+        22, 22, 20, 19, 18, 17, 16, 15, 15, 14, 13, 13, 13, 12, 12, 11, 11, 11,
+        10, 10, 10, 10, 10, 10, 9, 9, 19, 20, 20, 21, 21, 20, 21, 20, 19, 17,
+        17, 16, 15, 14, 14, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9,
+        9, 9, 9, 18, 19, 20, 20, 20, 20, 20, 19, 18, 17, 17, 16, 15, 14, 13, 13,
+        12, 12, 12, 11, 11, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 17, 18, 19, 19,
+        19, 19, 19, 19, 18, 17, 16, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10,
+        10, 9, 9, 9, 9, 9, 9, 8, 8, 9, 16, 17, 17, 18, 18, 18, 18, 17, 17, 16,
+        15, 14, 14, 13, 12, 12, 11, 11, 11, 10, 10, 9, 9, 9, 9, 9, 8, 8, 8, 8,
+        8, 8, 16, 17, 17, 17, 17, 17, 18, 17, 16, 15, 15, 14, 14, 13, 12, 12,
+        11, 11, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 14, 15, 15, 16, 16,
+        16, 16, 16, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 9, 9, 8,
+        8, 8, 8, 8, 8, 8, 8, 7, 14, 14, 15, 15, 15, 15, 16, 15, 15, 14, 14, 13,
+        12, 12, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 13,
+        13, 14, 14, 14, 14, 15, 14, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 9,
+        9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 12, 13, 13, 14, 14, 14, 14, 14,
+        13, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7,
+        7, 7, 7, 12, 13, 13, 14, 14, 14, 14, 14, 13, 13, 13, 12, 12, 11, 11, 10,
+        10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 12, 12, 13, 13, 13, 13,
+        14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7,
+        7, 7, 6, 6, 6, 11, 12, 12, 13, 13, 13, 13, 13, 12, 12, 12, 11, 11, 10,
+        10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 11, 12, 12, 12,
+        12, 12, 13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7,
+        7, 7, 7, 7, 6, 6, 6, 6, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11,
+        11, 10, 10, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 11, 11,
+        11, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 8,
+        7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 10, 11, 11, 11, 11, 12, 12, 12, 12, 11,
+        11, 11, 10, 10, 10, 9, 9, 9, 9, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
+        /* Size 4x8 */
+        32, 29, 17, 12, 32, 28, 18, 13, 30, 22, 16, 12, 25, 19, 13, 11, 20, 17,
+        11, 9, 16, 14, 9, 8, 14, 13, 9, 7, 12, 11, 9, 7,
+        /* Size 8x4 */
+        32, 32, 30, 25, 20, 16, 14, 12, 29, 28, 22, 19, 17, 14, 13, 11, 17, 18,
+        16, 13, 11, 9, 9, 9, 12, 13, 12, 11, 9, 8, 7, 7,
+        /* Size 8x16 */
+        32, 33, 29, 23, 19, 16, 12, 11, 33, 32, 30, 25, 20, 17, 13, 12, 33, 31,
+        29, 24, 21, 17, 14, 13, 32, 30, 28, 24, 21, 18, 14, 13, 30, 29, 25, 21,
+        19, 16, 13, 13, 28, 28, 22, 19, 17, 15, 13, 12, 25, 26, 21, 17, 15, 13,
+        12, 11, 22, 23, 19, 16, 14, 12, 11, 10, 19, 20, 18, 14, 12, 11, 10, 9,
+        18, 19, 17, 14, 12, 10, 9, 9, 16, 17, 16, 13, 11, 10, 9, 8, 14, 15, 14,
+        12, 10, 9, 8, 8, 12, 14, 13, 11, 10, 9, 7, 7, 12, 13, 12, 11, 9, 8, 7,
+        7, 11, 12, 12, 11, 9, 8, 7, 7, 11, 12, 12, 11, 9, 8, 7, 6,
+        /* Size 16x8 */
+        32, 33, 33, 32, 30, 28, 25, 22, 19, 18, 16, 14, 12, 12, 11, 11, 33, 32,
+        31, 30, 29, 28, 26, 23, 20, 19, 17, 15, 14, 13, 12, 12, 29, 30, 29, 28,
+        25, 22, 21, 19, 18, 17, 16, 14, 13, 12, 12, 12, 23, 25, 24, 24, 21, 19,
+        17, 16, 14, 14, 13, 12, 11, 11, 11, 11, 19, 20, 21, 21, 19, 17, 15, 14,
+        12, 12, 11, 10, 10, 9, 9, 9, 16, 17, 17, 18, 16, 15, 13, 12, 11, 10, 10,
+        9, 9, 8, 8, 8, 12, 13, 14, 14, 13, 13, 12, 11, 10, 9, 9, 8, 7, 7, 7, 7,
+        11, 12, 13, 13, 13, 12, 11, 10, 9, 9, 8, 8, 7, 7, 7, 6,
+        /* Size 16x32 */
+        32, 33, 33, 32, 29, 28, 23, 22, 19, 17, 16, 13, 12, 12, 11, 11, 33, 32,
+        32, 32, 29, 29, 24, 23, 20, 17, 17, 14, 13, 12, 12, 12, 33, 32, 32, 32,
+        30, 29, 25, 23, 20, 18, 17, 14, 13, 12, 12, 12, 33, 32, 32, 31, 30, 30,
+        25, 23, 21, 18, 17, 14, 14, 13, 12, 12, 33, 32, 31, 30, 29, 28, 24, 23,
+        21, 18, 17, 14, 14, 13, 13, 12, 32, 32, 31, 30, 28, 28, 24, 23, 20, 18,
+        17, 14, 14, 13, 13, 12, 32, 31, 30, 29, 28, 27, 24, 23, 21, 18, 18, 15,
+        14, 13, 13, 12, 32, 31, 30, 28, 26, 26, 23, 22, 20, 18, 17, 14, 14, 13,
+        13, 13, 30, 30, 29, 28, 25, 24, 21, 20, 19, 17, 16, 14, 13, 13, 13, 13,
+        29, 30, 28, 27, 23, 22, 20, 19, 17, 16, 15, 13, 13, 12, 12, 12, 28, 30,
+        28, 27, 22, 21, 19, 18, 17, 16, 15, 13, 13, 12, 12, 12, 26, 28, 26, 26,
+        21, 20, 18, 17, 16, 14, 14, 12, 12, 12, 12, 11, 25, 26, 26, 25, 21, 20,
+        17, 17, 15, 14, 13, 12, 12, 11, 11, 11, 23, 25, 24, 24, 20, 19, 16, 16,
+        14, 13, 13, 11, 11, 11, 11, 11, 22, 23, 23, 23, 19, 18, 16, 15, 14, 12,
+        12, 11, 11, 10, 10, 10, 21, 23, 23, 22, 19, 18, 15, 15, 13, 12, 12, 11,
+        10, 10, 10, 10, 19, 21, 20, 20, 18, 17, 14, 14, 12, 11, 11, 10, 10, 10,
+        9, 10, 19, 20, 20, 20, 17, 17, 14, 13, 12, 11, 11, 10, 9, 9, 9, 9, 18,
+        19, 19, 19, 17, 16, 14, 13, 12, 11, 10, 9, 9, 9, 9, 9, 16, 18, 18, 18,
+        16, 15, 13, 12, 11, 10, 10, 9, 9, 9, 9, 8, 16, 17, 17, 18, 16, 15, 13,
+        12, 11, 10, 10, 9, 9, 8, 8, 8, 14, 16, 16, 16, 14, 14, 12, 12, 11, 9, 9,
+        8, 8, 8, 8, 8, 14, 15, 15, 16, 14, 14, 12, 11, 10, 9, 9, 8, 8, 8, 8, 8,
+        13, 14, 14, 15, 13, 13, 11, 11, 10, 9, 9, 8, 8, 7, 7, 7, 12, 14, 14, 14,
+        13, 13, 11, 11, 10, 9, 9, 8, 7, 7, 7, 7, 12, 14, 14, 14, 13, 13, 11, 11,
+        10, 9, 8, 8, 7, 7, 7, 7, 12, 13, 13, 13, 12, 12, 11, 10, 9, 9, 8, 7, 7,
+        7, 7, 7, 12, 12, 13, 13, 12, 12, 11, 10, 9, 9, 8, 7, 7, 7, 7, 6, 11, 12,
+        12, 13, 12, 12, 11, 10, 9, 9, 8, 8, 7, 7, 7, 6, 11, 12, 12, 12, 12, 11,
+        11, 10, 9, 9, 8, 8, 7, 7, 6, 6, 11, 12, 12, 12, 12, 11, 11, 10, 9, 8, 8,
+        7, 7, 6, 6, 6, 10, 11, 11, 12, 12, 11, 11, 9, 9, 8, 8, 7, 7, 6, 6, 6,
+        /* Size 32x16 */
+        32, 33, 33, 33, 33, 32, 32, 32, 30, 29, 28, 26, 25, 23, 22, 21, 19, 19,
+        18, 16, 16, 14, 14, 13, 12, 12, 12, 12, 11, 11, 11, 10, 33, 32, 32, 32,
+        32, 32, 31, 31, 30, 30, 30, 28, 26, 25, 23, 23, 21, 20, 19, 18, 17, 16,
+        15, 14, 14, 14, 13, 12, 12, 12, 12, 11, 33, 32, 32, 32, 31, 31, 30, 30,
+        29, 28, 28, 26, 26, 24, 23, 23, 20, 20, 19, 18, 17, 16, 15, 14, 14, 14,
+        13, 13, 12, 12, 12, 11, 32, 32, 32, 31, 30, 30, 29, 28, 28, 27, 27, 26,
+        25, 24, 23, 22, 20, 20, 19, 18, 18, 16, 16, 15, 14, 14, 13, 13, 13, 12,
+        12, 12, 29, 29, 30, 30, 29, 28, 28, 26, 25, 23, 22, 21, 21, 20, 19, 19,
+        18, 17, 17, 16, 16, 14, 14, 13, 13, 13, 12, 12, 12, 12, 12, 12, 28, 29,
+        29, 30, 28, 28, 27, 26, 24, 22, 21, 20, 20, 19, 18, 18, 17, 17, 16, 15,
+        15, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 23, 24, 25, 25, 24, 24,
+        24, 23, 21, 20, 19, 18, 17, 16, 16, 15, 14, 14, 14, 13, 13, 12, 12, 11,
+        11, 11, 11, 11, 11, 11, 11, 11, 22, 23, 23, 23, 23, 23, 23, 22, 20, 19,
+        18, 17, 17, 16, 15, 15, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11, 10, 10,
+        10, 10, 10, 9, 19, 20, 20, 21, 21, 20, 21, 20, 19, 17, 17, 16, 15, 14,
+        14, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 17,
+        17, 18, 18, 18, 18, 18, 18, 17, 16, 16, 14, 14, 13, 12, 12, 11, 11, 11,
+        10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 16, 17, 17, 17, 17, 17, 18, 17,
+        16, 15, 15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8,
+        8, 8, 8, 8, 13, 14, 14, 14, 14, 14, 15, 14, 14, 13, 13, 12, 12, 11, 11,
+        11, 10, 10, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 8, 8, 7, 7, 12, 13, 13, 14,
+        14, 14, 14, 14, 13, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8,
+        7, 7, 7, 7, 7, 7, 7, 7, 12, 12, 12, 13, 13, 13, 13, 13, 13, 12, 12, 12,
+        11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 11, 12,
+        12, 12, 13, 13, 13, 13, 13, 12, 12, 12, 11, 11, 10, 10, 9, 9, 9, 9, 8,
+        8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 11, 12, 12, 12, 12, 12, 12, 13, 13, 12,
+        12, 11, 11, 11, 10, 10, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6,
+        /* Size 4x16 */
+        33, 28, 17, 12, 32, 29, 18, 12, 32, 28, 18, 13, 31, 27, 18, 13, 30, 24,
+        17, 13, 30, 21, 16, 12, 26, 20, 14, 11, 23, 18, 12, 10, 21, 17, 11, 10,
+        19, 16, 11, 9, 17, 15, 10, 8, 15, 14, 9, 8, 14, 13, 9, 7, 13, 12, 9, 7,
+        12, 12, 9, 7, 12, 11, 8, 6,
+        /* Size 16x4 */
+        33, 32, 32, 31, 30, 30, 26, 23, 21, 19, 17, 15, 14, 13, 12, 12, 28, 29,
+        28, 27, 24, 21, 20, 18, 17, 16, 15, 14, 13, 12, 12, 11, 17, 18, 18, 18,
+        17, 16, 14, 12, 11, 11, 10, 9, 9, 9, 9, 8, 12, 12, 13, 13, 13, 12, 11,
+        10, 10, 9, 8, 8, 7, 7, 7, 6,
+        /* Size 8x32 */
+        32, 33, 29, 23, 19, 16, 12, 11, 33, 32, 29, 24, 20, 17, 13, 12, 33, 32,
+        30, 25, 20, 17, 13, 12, 33, 32, 30, 25, 21, 17, 14, 12, 33, 31, 29, 24,
+        21, 17, 14, 13, 32, 31, 28, 24, 20, 17, 14, 13, 32, 30, 28, 24, 21, 18,
+        14, 13, 32, 30, 26, 23, 20, 17, 14, 13, 30, 29, 25, 21, 19, 16, 13, 13,
+        29, 28, 23, 20, 17, 15, 13, 12, 28, 28, 22, 19, 17, 15, 13, 12, 26, 26,
+        21, 18, 16, 14, 12, 12, 25, 26, 21, 17, 15, 13, 12, 11, 23, 24, 20, 16,
+        14, 13, 11, 11, 22, 23, 19, 16, 14, 12, 11, 10, 21, 23, 19, 15, 13, 12,
+        10, 10, 19, 20, 18, 14, 12, 11, 10, 9, 19, 20, 17, 14, 12, 11, 9, 9, 18,
+        19, 17, 14, 12, 10, 9, 9, 16, 18, 16, 13, 11, 10, 9, 9, 16, 17, 16, 13,
+        11, 10, 9, 8, 14, 16, 14, 12, 11, 9, 8, 8, 14, 15, 14, 12, 10, 9, 8, 8,
+        13, 14, 13, 11, 10, 9, 8, 7, 12, 14, 13, 11, 10, 9, 7, 7, 12, 14, 13,
+        11, 10, 8, 7, 7, 12, 13, 12, 11, 9, 8, 7, 7, 12, 13, 12, 11, 9, 8, 7, 7,
+        11, 12, 12, 11, 9, 8, 7, 7, 11, 12, 12, 11, 9, 8, 7, 6, 11, 12, 12, 11,
+        9, 8, 7, 6, 10, 11, 12, 11, 9, 8, 7, 6,
+        /* Size 32x8 */
+        32, 33, 33, 33, 33, 32, 32, 32, 30, 29, 28, 26, 25, 23, 22, 21, 19, 19,
+        18, 16, 16, 14, 14, 13, 12, 12, 12, 12, 11, 11, 11, 10, 33, 32, 32, 32,
+        31, 31, 30, 30, 29, 28, 28, 26, 26, 24, 23, 23, 20, 20, 19, 18, 17, 16,
+        15, 14, 14, 14, 13, 13, 12, 12, 12, 11, 29, 29, 30, 30, 29, 28, 28, 26,
+        25, 23, 22, 21, 21, 20, 19, 19, 18, 17, 17, 16, 16, 14, 14, 13, 13, 13,
+        12, 12, 12, 12, 12, 12, 23, 24, 25, 25, 24, 24, 24, 23, 21, 20, 19, 18,
+        17, 16, 16, 15, 14, 14, 14, 13, 13, 12, 12, 11, 11, 11, 11, 11, 11, 11,
+        11, 11, 19, 20, 20, 21, 21, 20, 21, 20, 19, 17, 17, 16, 15, 14, 14, 13,
+        12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 16, 17, 17,
+        17, 17, 17, 18, 17, 16, 15, 15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10,
+        9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 12, 13, 13, 14, 14, 14, 14, 14, 13, 13,
+        13, 12, 12, 11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7,
+        11, 12, 12, 12, 13, 13, 13, 13, 13, 12, 12, 12, 11, 11, 10, 10, 9, 9, 9,
+        9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6 },
+      { /* Chroma */
+#if CONFIG_CHROMA_2X2
+        /* Size 2x2 */
+        22, 19, 19, 12,
 #endif
         /* Size 4x4 */
-        63, 53, 32, 23, 53, 36, 26, 20, 32, 26, 18, 17, 23, 20, 17, 12,
+        32, 23, 20, 17, 23, 19, 17, 16, 20, 17, 14, 13, 17, 16, 13, 11,
         /* Size 8x8 */
-        64, 63, 59, 45, 36, 27, 24, 21, 63, 60, 55, 45, 38, 29, 26, 22, 59, 55,
-        42, 36, 32, 26, 23, 22, 45, 45, 36, 29, 25, 21, 21, 20, 36, 38, 32, 25,
-        22, 18, 17, 17, 27, 29, 26, 21, 18, 15, 15, 14, 24, 26, 23, 21, 17, 15,
-        13, 11, 21, 22, 22, 20, 17, 14, 11, 11,
+        33, 30, 22, 22, 20, 18, 17, 16, 30, 26, 22, 23, 21, 19, 18, 17, 22, 22,
+        20, 20, 19, 18, 17, 17, 22, 23, 20, 18, 17, 16, 15, 15, 20, 21, 19, 17,
+        15, 14, 13, 13, 18, 19, 18, 16, 14, 12, 12, 12, 17, 18, 17, 15, 13, 12,
+        11, 11, 16, 17, 17, 15, 13, 12, 11, 10,
         /* Size 16x16 */
-        64, 65, 65, 64, 59, 52, 47, 41, 35, 31, 29, 25, 23, 22, 20, 19, 65, 64,
-        63, 63, 60, 54, 49, 44, 38, 34, 31, 27, 25, 24, 22, 20, 65, 63, 61, 60,
-        57, 53, 49, 44, 39, 35, 32, 28, 26, 25, 23, 21, 64, 63, 60, 58, 55, 51,
-        48, 44, 39, 35, 33, 29, 27, 25, 24, 22, 59, 60, 57, 55, 48, 44, 41, 38,
-        34, 32, 29, 26, 25, 24, 22, 21, 52, 54, 53, 51, 44, 38, 35, 33, 30, 28,
-        26, 24, 23, 23, 21, 20, 47, 49, 49, 48, 41, 35, 32, 30, 27, 26, 24, 22,
-        21, 21, 20, 18, 41, 44, 44, 44, 38, 33, 30, 28, 25, 24, 22, 21, 20, 19,
-        20, 17, 35, 38, 39, 39, 34, 30, 27, 25, 23, 21, 20, 19, 18, 17, 18, 16,
-        31, 34, 35, 35, 32, 28, 26, 24, 21, 20, 18, 17, 16, 17, 17, 14, 29, 31,
-        32, 33, 29, 26, 24, 22, 20, 18, 17, 16, 15, 16, 16, 14, 25, 27, 28, 29,
-        26, 24, 22, 21, 19, 17, 16, 15, 14, 14, 14, 12, 23, 25, 26, 27, 25, 23,
-        21, 20, 18, 16, 15, 14, 14, 13, 12, 12, 22, 24, 25, 25, 24, 23, 21, 19,
-        17, 17, 16, 14, 13, 13, 12, 10, 20, 22, 23, 24, 22, 21, 20, 20, 18, 17,
-        16, 14, 12, 12, 12, 11, 19, 20, 21, 22, 21, 20, 18, 17, 16, 14, 14, 12,
-        12, 10, 11, 11,
+        32, 33, 31, 28, 25, 21, 21, 20, 20, 19, 18, 17, 16, 15, 15, 15, 33, 33,
+        30, 26, 24, 22, 22, 22, 21, 20, 19, 18, 17, 17, 16, 16, 31, 30, 28, 24,
+        23, 22, 22, 22, 22, 21, 20, 19, 18, 17, 17, 16, 28, 26, 24, 22, 22, 21,
+        22, 22, 22, 21, 20, 19, 19, 18, 17, 17, 25, 24, 23, 22, 21, 20, 21, 20,
+        20, 20, 19, 18, 18, 17, 17, 17, 21, 22, 22, 21, 20, 19, 19, 19, 19, 19,
+        18, 17, 17, 16, 16, 16, 21, 22, 22, 22, 21, 19, 19, 18, 17, 17, 17, 16,
+        16, 15, 15, 15, 20, 22, 22, 22, 20, 19, 18, 17, 16, 16, 16, 15, 15, 14,
+        14, 14, 20, 21, 22, 22, 20, 19, 17, 16, 16, 15, 15, 14, 14, 13, 14, 14,
+        19, 20, 21, 21, 20, 19, 17, 16, 15, 14, 14, 13, 13, 13, 13, 13, 18, 19,
+        20, 20, 19, 18, 17, 16, 15, 14, 13, 13, 12, 12, 12, 12, 17, 18, 19, 19,
+        18, 17, 16, 15, 14, 13, 13, 12, 12, 12, 12, 12, 16, 17, 18, 19, 18, 17,
+        16, 15, 14, 13, 12, 12, 11, 11, 11, 11, 15, 17, 17, 18, 17, 16, 15, 14,
+        13, 13, 12, 12, 11, 11, 11, 11, 15, 16, 17, 17, 17, 16, 15, 14, 14, 13,
+        12, 12, 11, 11, 10, 10, 15, 16, 16, 17, 17, 16, 15, 14, 14, 13, 12, 12,
+        11, 11, 10, 10,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 64, 64, 60, 59, 57, 52, 50, 47, 43, 41, 38, 35, 34,
-        31, 29, 29, 26, 25, 25, 23, 23, 22, 21, 20, 20, 19, 18, 65, 64, 64, 64,
-        64, 63, 63, 60, 59, 59, 53, 52, 48, 45, 43, 40, 37, 36, 33, 31, 30, 27,
-        26, 26, 25, 24, 23, 22, 21, 21, 20, 20, 65, 64, 64, 64, 63, 63, 63, 61,
-        60, 59, 54, 53, 49, 46, 44, 41, 38, 37, 34, 32, 31, 28, 27, 27, 25, 24,
-        24, 23, 22, 21, 20, 19, 65, 64, 64, 63, 63, 63, 63, 61, 60, 59, 55, 53,
-        50, 47, 45, 41, 39, 38, 34, 32, 32, 28, 28, 27, 26, 25, 24, 23, 23, 22,
-        21, 21, 65, 64, 63, 63, 61, 61, 60, 58, 57, 56, 53, 51, 49, 46, 44, 41,
-        39, 38, 35, 33, 32, 29, 28, 28, 26, 25, 25, 24, 23, 22, 21, 20, 64, 63,
-        63, 63, 61, 60, 59, 57, 56, 55, 51, 51, 48, 45, 44, 41, 39, 38, 35, 33,
-        32, 29, 28, 28, 27, 26, 25, 24, 23, 22, 22, 21, 64, 63, 63, 63, 60, 59,
-        58, 55, 55, 53, 51, 50, 48, 45, 44, 41, 39, 38, 35, 33, 33, 29, 29, 28,
-        27, 26, 25, 25, 24, 23, 22, 21, 60, 60, 61, 61, 58, 57, 55, 52, 50, 48,
-        46, 45, 43, 41, 40, 38, 36, 35, 33, 31, 30, 28, 27, 27, 25, 25, 24, 25,
-        24, 23, 23, 22, 59, 59, 60, 60, 57, 56, 55, 50, 48, 46, 44, 43, 41, 39,
-        38, 36, 34, 34, 32, 30, 29, 27, 26, 26, 25, 25, 24, 23, 22, 21, 21, 22,
-        57, 59, 59, 59, 56, 55, 53, 48, 46, 42, 41, 40, 38, 36, 36, 34, 33, 32,
-        30, 29, 28, 26, 26, 25, 24, 23, 23, 22, 23, 22, 21, 19, 52, 53, 54, 55,
-        53, 51, 51, 46, 44, 41, 38, 37, 35, 34, 33, 32, 30, 29, 28, 27, 26, 24,
-        24, 24, 23, 23, 23, 22, 21, 20, 20, 21, 50, 52, 53, 53, 51, 51, 50, 45,
-        43, 40, 37, 36, 34, 33, 32, 31, 29, 29, 27, 26, 26, 24, 23, 23, 22, 22,
-        21, 20, 21, 21, 21, 18, 47, 48, 49, 50, 49, 48, 48, 43, 41, 38, 35, 34,
-        32, 31, 30, 29, 27, 27, 26, 25, 24, 23, 22, 22, 21, 20, 21, 21, 20, 19,
-        18, 20, 43, 45, 46, 47, 46, 45, 45, 41, 39, 36, 34, 33, 31, 29, 29, 27,
-        26, 25, 24, 23, 23, 21, 21, 21, 20, 21, 20, 19, 19, 20, 20, 17, 41, 43,
-        44, 45, 44, 44, 44, 40, 38, 36, 33, 32, 30, 29, 28, 26, 25, 25, 24, 23,
-        22, 21, 21, 20, 20, 19, 19, 20, 20, 17, 17, 19, 38, 40, 41, 41, 41, 41,
-        41, 38, 36, 34, 32, 31, 29, 27, 26, 25, 24, 23, 22, 21, 21, 20, 19, 19,
-        19, 18, 19, 18, 17, 19, 19, 16, 35, 37, 38, 39, 39, 39, 39, 36, 34, 33,
-        30, 29, 27, 26, 25, 24, 23, 22, 21, 20, 20, 19, 19, 18, 18, 18, 17, 17,
-        18, 16, 16, 18, 34, 36, 37, 38, 38, 38, 38, 35, 34, 32, 29, 29, 27, 25,
-        25, 23, 22, 22, 21, 20, 20, 18, 18, 18, 18, 17, 17, 18, 15, 17, 18, 15,
-        31, 33, 34, 34, 35, 35, 35, 33, 32, 30, 28, 27, 26, 24, 24, 22, 21, 21,
-        20, 19, 18, 17, 17, 17, 16, 17, 17, 16, 17, 16, 14, 17, 29, 31, 32, 32,
-        33, 33, 33, 31, 30, 29, 27, 26, 25, 23, 23, 21, 20, 20, 19, 18, 18, 17,
-        16, 16, 16, 16, 15, 17, 15, 15, 17, 13, 29, 30, 31, 32, 32, 32, 33, 30,
-        29, 28, 26, 26, 24, 23, 22, 21, 20, 20, 18, 18, 17, 16, 16, 16, 15, 15,
-        16, 14, 16, 15, 14, 16, 26, 27, 28, 28, 29, 29, 29, 28, 27, 26, 24, 24,
-        23, 21, 21, 20, 19, 18, 17, 17, 16, 15, 15, 15, 14, 15, 14, 15, 14, 14,
-        16, 13, 25, 26, 27, 28, 28, 28, 29, 27, 26, 26, 24, 23, 22, 21, 21, 19,
-        19, 18, 17, 16, 16, 15, 15, 15, 14, 14, 14, 14, 14, 14, 12, 15, 25, 26,
-        27, 27, 28, 28, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 18, 17, 16,
-        16, 15, 15, 15, 14, 14, 13, 13, 14, 12, 15, 11, 23, 25, 25, 26, 26, 27,
-        27, 25, 25, 24, 23, 22, 21, 20, 20, 19, 18, 18, 16, 16, 15, 14, 14, 14,
-        14, 14, 13, 13, 12, 14, 12, 14, 23, 24, 24, 25, 25, 26, 26, 25, 25, 23,
-        23, 22, 20, 21, 19, 18, 18, 17, 17, 16, 15, 15, 14, 14, 14, 13, 14, 13,
-        13, 11, 14, 11, 22, 23, 24, 24, 25, 25, 25, 24, 24, 23, 23, 21, 21, 20,
-        19, 19, 17, 17, 17, 15, 16, 14, 14, 13, 13, 14, 13, 13, 12, 13, 10, 13,
-        21, 22, 23, 23, 24, 24, 25, 25, 23, 22, 22, 20, 21, 19, 20, 18, 17, 18,
-        16, 17, 14, 15, 14, 13, 13, 13, 13, 12, 13, 12, 13, 9, 20, 21, 22, 23,
-        23, 23, 24, 24, 22, 23, 21, 21, 20, 19, 20, 17, 18, 15, 17, 15, 16, 14,
-        14, 14, 12, 13, 12, 13, 12, 13, 11, 12, 20, 21, 21, 22, 22, 22, 23, 23,
-        21, 22, 20, 21, 19, 20, 17, 19, 16, 17, 16, 15, 15, 14, 14, 12, 14, 11,
-        13, 12, 13, 11, 12, 11, 19, 20, 20, 21, 21, 22, 22, 23, 21, 21, 20, 21,
-        18, 20, 17, 19, 16, 18, 14, 17, 14, 16, 12, 15, 12, 14, 10, 13, 11, 12,
-        11, 12, 18, 20, 19, 21, 20, 21, 21, 22, 22, 19, 21, 18, 20, 17, 19, 16,
-        18, 15, 17, 13, 16, 13, 15, 11, 14, 11, 13, 9, 12, 11, 12, 10,
+        32, 33, 33, 34, 31, 31, 28, 27, 25, 22, 21, 21, 21, 21, 20, 20, 20, 19,
+        19, 18, 18, 17, 17, 16, 16, 16, 15, 15, 15, 15, 15, 14, 33, 33, 33, 33,
+        30, 30, 27, 26, 24, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 19, 19, 18,
+        18, 17, 17, 17, 16, 16, 16, 16, 16, 15, 33, 33, 33, 33, 30, 29, 26, 26,
+        24, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 19, 19, 18, 18, 17, 17, 17,
+        17, 16, 16, 16, 16, 15, 34, 33, 33, 32, 30, 29, 26, 25, 24, 23, 22, 23,
+        23, 23, 22, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 17,
+        16, 16, 31, 30, 30, 30, 28, 27, 24, 24, 23, 22, 22, 22, 22, 23, 22, 22,
+        22, 21, 21, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 31, 30,
+        29, 29, 27, 26, 24, 23, 23, 22, 22, 22, 22, 23, 22, 22, 22, 21, 21, 20,
+        20, 19, 19, 18, 18, 18, 17, 17, 17, 17, 17, 17, 28, 27, 26, 26, 24, 24,
+        22, 22, 22, 22, 21, 22, 22, 23, 22, 22, 22, 22, 21, 21, 20, 20, 19, 19,
+        19, 19, 18, 18, 17, 17, 17, 17, 27, 26, 26, 25, 24, 23, 22, 22, 21, 21,
+        21, 21, 22, 22, 22, 22, 21, 21, 21, 20, 20, 19, 19, 19, 18, 18, 18, 18,
+        18, 17, 17, 17, 25, 24, 24, 24, 23, 23, 22, 21, 21, 20, 20, 21, 21, 21,
+        20, 20, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17,
+        22, 22, 22, 23, 22, 22, 22, 21, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19,
+        19, 19, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 16, 16, 21, 22, 22, 22,
+        22, 22, 21, 21, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18,
+        17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 21, 22, 22, 23, 22, 22, 22, 21,
+        21, 20, 19, 19, 19, 19, 18, 18, 18, 18, 18, 17, 17, 17, 17, 16, 16, 16,
+        16, 16, 16, 16, 16, 15, 21, 22, 22, 23, 22, 22, 22, 22, 21, 20, 19, 19,
+        19, 18, 18, 18, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 15, 15, 15, 15,
+        15, 15, 21, 22, 22, 23, 23, 23, 23, 22, 21, 20, 19, 19, 18, 18, 17, 17,
+        17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 20, 21,
+        22, 22, 22, 22, 22, 22, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 16,
+        16, 15, 15, 15, 15, 14, 14, 15, 14, 14, 14, 15, 20, 21, 22, 22, 22, 22,
+        22, 22, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 14,
+        14, 14, 14, 14, 14, 14, 14, 14, 20, 20, 21, 22, 22, 22, 22, 21, 20, 19,
+        19, 18, 17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 14,
+        14, 13, 14, 14, 19, 20, 20, 21, 21, 21, 22, 21, 20, 19, 19, 18, 17, 17,
+        16, 16, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+        19, 20, 20, 21, 21, 21, 21, 21, 20, 19, 19, 18, 17, 17, 16, 16, 15, 15,
+        14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 18, 19, 19, 20,
+        20, 20, 21, 20, 19, 19, 18, 17, 17, 16, 16, 16, 15, 14, 14, 14, 13, 13,
+        13, 13, 12, 12, 12, 13, 12, 13, 13, 12, 18, 19, 19, 20, 20, 20, 20, 20,
+        19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 13, 12, 12, 12,
+        12, 12, 12, 12, 12, 12, 17, 18, 18, 19, 19, 19, 20, 19, 19, 18, 18, 17,
+        16, 16, 15, 15, 14, 14, 14, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+        12, 12, 17, 18, 18, 19, 19, 19, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15,
+        14, 14, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 17,
+        17, 18, 18, 18, 19, 19, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13,
+        12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 12, 11, 16, 17, 17, 18, 18, 18,
+        19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 12, 11,
+        11, 11, 11, 11, 11, 11, 11, 11, 16, 17, 17, 18, 18, 18, 19, 18, 18, 17,
+        17, 16, 16, 15, 14, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11,
+        11, 11, 11, 11, 15, 16, 17, 17, 17, 17, 18, 18, 17, 17, 16, 16, 15, 15,
+        14, 14, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+        15, 16, 16, 17, 17, 17, 18, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 13,
+        13, 13, 12, 12, 12, 11, 11, 11, 11, 11, 11, 10, 10, 10, 15, 16, 16, 17,
+        17, 17, 17, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 13, 13, 12, 12, 12,
+        12, 11, 11, 11, 11, 11, 10, 10, 10, 10, 15, 16, 16, 17, 17, 17, 17, 17,
+        17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 13, 12, 12, 12, 11, 11, 11,
+        11, 10, 10, 10, 10, 10, 15, 16, 16, 16, 16, 17, 17, 17, 17, 16, 16, 16,
+        15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 10, 10, 10,
+        10, 10, 14, 15, 15, 16, 16, 17, 17, 17, 17, 16, 16, 15, 15, 15, 15, 14,
+        14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10,
         /* Size 4x8 */
-        64, 53, 33, 23, 63, 51, 35, 24, 59, 40, 30, 23, 46, 34, 24, 19, 38, 29,
-        21, 17, 28, 24, 17, 15, 25, 23, 16, 13, 22, 21, 17, 13,
+        33, 22, 19, 16, 28, 22, 20, 17, 22, 20, 19, 17, 23, 19, 16, 15, 21, 19,
+        14, 13, 19, 18, 13, 12, 17, 17, 13, 11, 16, 16, 13, 11,
         /* Size 8x4 */
-        64, 63, 59, 46, 38, 28, 25, 22, 53, 51, 40, 34, 29, 24, 23, 21, 33, 35,
-        30, 24, 21, 17, 16, 17, 23, 24, 23, 19, 17, 15, 13, 13,
+        33, 28, 22, 23, 21, 19, 17, 16, 22, 22, 20, 19, 19, 18, 17, 16, 19, 20,
+        19, 16, 14, 13, 13, 13, 16, 17, 17, 15, 13, 12, 11, 11,
         /* Size 8x16 */
-        64, 64, 57, 47, 35, 26, 23, 20, 65, 63, 59, 49, 38, 28, 25, 22, 64, 61,
-        56, 49, 39, 29, 26, 23, 64, 59, 53, 48, 39, 30, 27, 24, 59, 57, 46, 41,
-        34, 27, 25, 22, 52, 52, 41, 35, 30, 24, 23, 20, 47, 48, 38, 33, 27, 23,
-        21, 19, 42, 44, 36, 30, 25, 21, 20, 17, 36, 39, 33, 27, 23, 19, 18, 17,
-        32, 35, 30, 26, 21, 17, 16, 16, 29, 32, 28, 24, 20, 16, 15, 15, 25, 28,
-        25, 22, 19, 15, 14, 14, 23, 26, 24, 21, 18, 15, 14, 14, 22, 25, 23, 20,
-        18, 16, 13, 13, 20, 23, 22, 19, 16, 14, 13, 13, 19, 21, 21, 18, 16, 13,
-        11, 11,
+        32, 31, 23, 21, 20, 18, 16, 15, 33, 30, 23, 22, 21, 19, 17, 16, 31, 28,
+        22, 23, 22, 20, 18, 17, 28, 24, 22, 23, 22, 20, 19, 17, 24, 23, 21, 21,
+        20, 19, 18, 17, 21, 22, 20, 19, 19, 18, 17, 16, 21, 22, 20, 18, 17, 17,
+        16, 15, 20, 22, 20, 17, 16, 16, 14, 14, 20, 22, 19, 17, 16, 14, 14, 14,
+        19, 21, 19, 17, 15, 14, 13, 13, 18, 20, 19, 16, 15, 13, 12, 12, 17, 19,
+        18, 16, 14, 13, 12, 12, 16, 18, 17, 15, 14, 12, 11, 11, 16, 17, 17, 15,
+        13, 12, 11, 11, 15, 17, 17, 15, 13, 12, 11, 11, 15, 16, 17, 15, 14, 12,
+        11, 10,
         /* Size 16x8 */
-        64, 65, 64, 64, 59, 52, 47, 42, 36, 32, 29, 25, 23, 22, 20, 19, 64, 63,
-        61, 59, 57, 52, 48, 44, 39, 35, 32, 28, 26, 25, 23, 21, 57, 59, 56, 53,
-        46, 41, 38, 36, 33, 30, 28, 25, 24, 23, 22, 21, 47, 49, 49, 48, 41, 35,
-        33, 30, 27, 26, 24, 22, 21, 20, 19, 18, 35, 38, 39, 39, 34, 30, 27, 25,
-        23, 21, 20, 19, 18, 18, 16, 16, 26, 28, 29, 30, 27, 24, 23, 21, 19, 17,
-        16, 15, 15, 16, 14, 13, 23, 25, 26, 27, 25, 23, 21, 20, 18, 16, 15, 14,
-        14, 13, 13, 11, 20, 22, 23, 24, 22, 20, 19, 17, 17, 16, 15, 14, 14, 13,
-        13, 11,
+        32, 33, 31, 28, 24, 21, 21, 20, 20, 19, 18, 17, 16, 16, 15, 15, 31, 30,
+        28, 24, 23, 22, 22, 22, 22, 21, 20, 19, 18, 17, 17, 16, 23, 23, 22, 22,
+        21, 20, 20, 20, 19, 19, 19, 18, 17, 17, 17, 17, 21, 22, 23, 23, 21, 19,
+        18, 17, 17, 17, 16, 16, 15, 15, 15, 15, 20, 21, 22, 22, 20, 19, 17, 16,
+        16, 15, 15, 14, 14, 13, 13, 14, 18, 19, 20, 20, 19, 18, 17, 16, 14, 14,
+        13, 13, 12, 12, 12, 12, 16, 17, 18, 19, 18, 17, 16, 14, 14, 13, 12, 12,
+        11, 11, 11, 11, 15, 16, 17, 17, 17, 16, 15, 14, 14, 13, 12, 12, 11, 11,
+        11, 10,
         /* Size 16x32 */
-        64, 65, 64, 64, 57, 52, 47, 38, 35, 31, 26, 25, 23, 22, 20, 19, 65, 64,
-        63, 63, 58, 53, 48, 40, 37, 33, 27, 26, 24, 23, 21, 20, 65, 64, 63, 63,
-        59, 54, 49, 41, 38, 34, 28, 27, 25, 23, 22, 20, 65, 63, 63, 62, 59, 55,
-        50, 41, 39, 34, 28, 28, 25, 24, 23, 22, 64, 63, 61, 60, 56, 53, 49, 41,
-        39, 35, 29, 28, 26, 24, 23, 21, 64, 63, 60, 59, 55, 51, 48, 41, 39, 35,
-        29, 29, 26, 24, 23, 22, 64, 62, 59, 58, 53, 51, 48, 41, 39, 35, 30, 29,
-        27, 25, 24, 22, 60, 60, 58, 55, 48, 46, 43, 38, 36, 33, 28, 27, 25, 25,
-        24, 23, 59, 60, 57, 55, 46, 44, 41, 36, 34, 32, 27, 27, 25, 23, 22, 23,
-        57, 59, 55, 53, 43, 40, 38, 34, 33, 30, 26, 26, 24, 23, 23, 20, 52, 55,
-        52, 51, 41, 38, 35, 32, 30, 28, 24, 24, 23, 23, 20, 22, 51, 53, 51, 49,
-        40, 37, 34, 31, 29, 27, 24, 24, 22, 21, 22, 19, 47, 50, 48, 48, 38, 35,
-        33, 29, 27, 26, 23, 22, 21, 21, 19, 21, 43, 46, 45, 45, 37, 34, 31, 27,
-        26, 24, 21, 21, 21, 19, 21, 17, 42, 45, 44, 44, 36, 33, 30, 26, 25, 24,
-        21, 21, 20, 20, 17, 20, 38, 41, 41, 41, 34, 32, 29, 25, 24, 22, 20, 20,
-        18, 18, 19, 16, 36, 39, 39, 39, 33, 30, 27, 24, 23, 21, 19, 19, 18, 18,
-        17, 19, 35, 38, 38, 38, 32, 29, 27, 23, 22, 21, 18, 18, 17, 17, 17, 15,
-        32, 34, 35, 35, 30, 28, 26, 22, 21, 20, 17, 17, 16, 16, 16, 18, 30, 32,
-        33, 33, 29, 27, 25, 21, 20, 19, 17, 16, 16, 17, 16, 13, 29, 31, 32, 32,
-        28, 26, 24, 21, 20, 18, 16, 16, 15, 14, 15, 17, 26, 28, 29, 29, 26, 24,
-        23, 20, 19, 17, 15, 15, 15, 15, 14, 13, 25, 28, 28, 29, 25, 24, 22, 20,
-        19, 17, 15, 15, 14, 14, 14, 16, 25, 27, 28, 28, 25, 24, 22, 19, 18, 17,
-        15, 15, 14, 13, 13, 12, 23, 26, 26, 27, 24, 23, 21, 19, 18, 16, 15, 14,
-        14, 13, 14, 15, 23, 25, 25, 26, 23, 23, 21, 19, 18, 16, 15, 14, 13, 13,
-        11, 11, 22, 24, 25, 25, 23, 23, 20, 19, 18, 15, 16, 13, 13, 13, 13, 14,
-        21, 23, 24, 24, 22, 22, 19, 20, 17, 15, 15, 13, 14, 12, 12, 10, 20, 23,
-        23, 24, 22, 22, 19, 20, 16, 17, 14, 14, 13, 12, 13, 13, 20, 22, 22, 23,
-        21, 21, 19, 19, 16, 17, 13, 15, 11, 13, 11, 11, 19, 21, 21, 22, 21, 21,
-        18, 19, 16, 17, 13, 15, 11, 13, 11, 12, 18, 21, 20, 22, 22, 18, 20, 16,
-        18, 13, 16, 11, 14, 10, 13, 10,
+        32, 33, 31, 28, 23, 21, 21, 20, 20, 18, 18, 16, 16, 15, 15, 15, 33, 33,
+        30, 27, 23, 22, 22, 21, 20, 19, 19, 17, 17, 16, 16, 16, 33, 32, 30, 26,
+        23, 22, 22, 22, 21, 20, 19, 17, 17, 17, 16, 16, 34, 32, 29, 26, 23, 22,
+        23, 22, 21, 20, 20, 18, 18, 17, 17, 17, 31, 29, 28, 24, 22, 22, 23, 22,
+        22, 20, 20, 18, 18, 17, 17, 17, 31, 28, 27, 24, 22, 22, 22, 22, 22, 20,
+        20, 18, 18, 17, 17, 17, 28, 26, 24, 22, 22, 22, 23, 22, 22, 21, 20, 19,
+        19, 18, 17, 17, 26, 25, 24, 22, 21, 21, 22, 22, 21, 20, 20, 19, 18, 18,
+        18, 17, 24, 24, 23, 22, 21, 20, 21, 20, 20, 19, 19, 18, 18, 17, 17, 17,
+        22, 22, 22, 21, 20, 20, 19, 19, 19, 19, 18, 17, 17, 17, 17, 17, 21, 22,
+        22, 21, 20, 19, 19, 19, 19, 18, 18, 17, 17, 16, 16, 17, 21, 22, 22, 22,
+        20, 19, 18, 18, 18, 17, 17, 16, 16, 16, 16, 16, 21, 23, 22, 22, 20, 19,
+        18, 18, 17, 17, 17, 16, 16, 16, 15, 16, 21, 23, 23, 22, 20, 19, 18, 17,
+        17, 16, 16, 15, 15, 15, 15, 15, 20, 22, 22, 22, 20, 19, 17, 17, 16, 16,
+        16, 15, 14, 15, 14, 15, 20, 22, 22, 22, 20, 19, 17, 17, 16, 16, 15, 14,
+        14, 14, 14, 14, 20, 21, 22, 22, 19, 19, 17, 16, 16, 15, 14, 14, 14, 14,
+        14, 14, 19, 21, 21, 21, 19, 19, 17, 16, 15, 14, 14, 13, 13, 13, 14, 13,
+        19, 20, 21, 21, 19, 19, 17, 16, 15, 14, 14, 13, 13, 13, 13, 13, 18, 20,
+        20, 20, 19, 18, 16, 16, 15, 14, 13, 13, 12, 13, 13, 13, 18, 20, 20, 20,
+        19, 18, 16, 16, 15, 14, 13, 12, 12, 12, 12, 13, 17, 19, 19, 20, 18, 18,
+        16, 15, 14, 13, 13, 12, 12, 12, 12, 12, 17, 18, 19, 19, 18, 17, 16, 15,
+        14, 13, 13, 12, 12, 12, 12, 12, 16, 18, 18, 19, 17, 17, 15, 15, 14, 13,
+        12, 12, 11, 11, 12, 12, 16, 18, 18, 18, 17, 17, 15, 14, 14, 13, 12, 11,
+        11, 11, 11, 12, 16, 17, 18, 18, 17, 17, 15, 14, 14, 13, 12, 11, 11, 11,
+        11, 11, 16, 17, 17, 18, 17, 16, 15, 14, 13, 12, 12, 11, 11, 11, 11, 11,
+        15, 17, 17, 18, 17, 16, 15, 15, 13, 13, 12, 11, 11, 11, 11, 11, 15, 17,
+        17, 17, 17, 16, 15, 14, 13, 13, 12, 12, 11, 11, 11, 10, 15, 16, 17, 17,
+        17, 16, 15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 15, 16, 16, 17, 17, 16,
+        15, 14, 14, 13, 12, 12, 11, 11, 10, 10, 15, 16, 16, 17, 17, 15, 15, 14,
+        14, 12, 12, 11, 11, 10, 10, 10,
         /* Size 32x16 */
-        64, 65, 65, 65, 64, 64, 64, 60, 59, 57, 52, 51, 47, 43, 42, 38, 36, 35,
-        32, 30, 29, 26, 25, 25, 23, 23, 22, 21, 20, 20, 19, 18, 65, 64, 64, 63,
-        63, 63, 62, 60, 60, 59, 55, 53, 50, 46, 45, 41, 39, 38, 34, 32, 31, 28,
-        28, 27, 26, 25, 24, 23, 23, 22, 21, 21, 64, 63, 63, 63, 61, 60, 59, 58,
-        57, 55, 52, 51, 48, 45, 44, 41, 39, 38, 35, 33, 32, 29, 28, 28, 26, 25,
-        25, 24, 23, 22, 21, 20, 64, 63, 63, 62, 60, 59, 58, 55, 55, 53, 51, 49,
-        48, 45, 44, 41, 39, 38, 35, 33, 32, 29, 29, 28, 27, 26, 25, 24, 24, 23,
-        22, 22, 57, 58, 59, 59, 56, 55, 53, 48, 46, 43, 41, 40, 38, 37, 36, 34,
-        33, 32, 30, 29, 28, 26, 25, 25, 24, 23, 23, 22, 22, 21, 21, 22, 52, 53,
-        54, 55, 53, 51, 51, 46, 44, 40, 38, 37, 35, 34, 33, 32, 30, 29, 28, 27,
-        26, 24, 24, 24, 23, 23, 23, 22, 22, 21, 21, 18, 47, 48, 49, 50, 49, 48,
-        48, 43, 41, 38, 35, 34, 33, 31, 30, 29, 27, 27, 26, 25, 24, 23, 22, 22,
-        21, 21, 20, 19, 19, 19, 18, 20, 38, 40, 41, 41, 41, 41, 41, 38, 36, 34,
-        32, 31, 29, 27, 26, 25, 24, 23, 22, 21, 21, 20, 20, 19, 19, 19, 19, 20,
-        20, 19, 19, 16, 35, 37, 38, 39, 39, 39, 39, 36, 34, 33, 30, 29, 27, 26,
-        25, 24, 23, 22, 21, 20, 20, 19, 19, 18, 18, 18, 18, 17, 16, 16, 16, 18,
-        31, 33, 34, 34, 35, 35, 35, 33, 32, 30, 28, 27, 26, 24, 24, 22, 21, 21,
-        20, 19, 18, 17, 17, 17, 16, 16, 15, 15, 17, 17, 17, 13, 26, 27, 28, 28,
-        29, 29, 30, 28, 27, 26, 24, 24, 23, 21, 21, 20, 19, 18, 17, 17, 16, 15,
-        15, 15, 15, 15, 16, 15, 14, 13, 13, 16, 25, 26, 27, 28, 28, 29, 29, 27,
-        27, 26, 24, 24, 22, 21, 21, 20, 19, 18, 17, 16, 16, 15, 15, 15, 14, 14,
-        13, 13, 14, 15, 15, 11, 23, 24, 25, 25, 26, 26, 27, 25, 25, 24, 23, 22,
-        21, 21, 20, 18, 18, 17, 16, 16, 15, 15, 14, 14, 14, 13, 13, 14, 13, 11,
-        11, 14, 22, 23, 23, 24, 24, 24, 25, 25, 23, 23, 23, 21, 21, 19, 20, 18,
-        18, 17, 16, 17, 14, 15, 14, 13, 13, 13, 13, 12, 12, 13, 13, 10, 20, 21,
-        22, 23, 23, 23, 24, 24, 22, 23, 20, 22, 19, 21, 17, 19, 17, 17, 16, 16,
-        15, 14, 14, 13, 14, 11, 13, 12, 13, 11, 11, 13, 19, 20, 20, 22, 21, 22,
-        22, 23, 23, 20, 22, 19, 21, 17, 20, 16, 19, 15, 18, 13, 17, 13, 16, 12,
-        15, 11, 14, 10, 13, 11, 12, 10,
+        32, 33, 33, 34, 31, 31, 28, 26, 24, 22, 21, 21, 21, 21, 20, 20, 20, 19,
+        19, 18, 18, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 33, 33, 32, 32,
+        29, 28, 26, 25, 24, 22, 22, 22, 23, 23, 22, 22, 21, 21, 20, 20, 20, 19,
+        18, 18, 18, 17, 17, 17, 17, 16, 16, 16, 31, 30, 30, 29, 28, 27, 24, 24,
+        23, 22, 22, 22, 22, 23, 22, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 18,
+        17, 17, 17, 17, 16, 16, 28, 27, 26, 26, 24, 24, 22, 22, 22, 21, 21, 22,
+        22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 19, 19, 18, 18, 18, 18, 17, 17,
+        17, 17, 23, 23, 23, 23, 22, 22, 22, 21, 21, 20, 20, 20, 20, 20, 20, 20,
+        19, 19, 19, 19, 19, 18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 17, 21, 22,
+        22, 22, 22, 22, 22, 21, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18,
+        18, 18, 17, 17, 17, 17, 16, 16, 16, 16, 16, 15, 21, 22, 22, 23, 23, 22,
+        23, 22, 21, 19, 19, 18, 18, 18, 17, 17, 17, 17, 17, 16, 16, 16, 16, 15,
+        15, 15, 15, 15, 15, 15, 15, 15, 20, 21, 22, 22, 22, 22, 22, 22, 20, 19,
+        19, 18, 18, 17, 17, 17, 16, 16, 16, 16, 16, 15, 15, 15, 14, 14, 14, 15,
+        14, 14, 14, 14, 20, 20, 21, 21, 22, 22, 22, 21, 20, 19, 19, 18, 17, 17,
+        16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13, 13, 14, 14,
+        18, 19, 20, 20, 20, 20, 21, 20, 19, 19, 18, 17, 17, 16, 16, 16, 15, 14,
+        14, 14, 14, 13, 13, 13, 13, 13, 12, 13, 13, 13, 13, 12, 18, 19, 19, 20,
+        20, 20, 20, 20, 19, 18, 18, 17, 17, 16, 16, 15, 14, 14, 14, 13, 13, 13,
+        13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 17, 17, 18, 18, 18, 19, 19,
+        18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 11, 11,
+        11, 11, 12, 12, 12, 11, 16, 17, 17, 18, 18, 18, 19, 18, 18, 17, 17, 16,
+        16, 15, 14, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11,
+        11, 11, 15, 16, 17, 17, 17, 17, 18, 18, 17, 17, 16, 16, 16, 15, 15, 14,
+        14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 10, 15, 16,
+        16, 17, 17, 17, 17, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13,
+        12, 12, 12, 12, 11, 11, 11, 11, 11, 10, 10, 10, 15, 16, 16, 17, 17, 17,
+        17, 17, 17, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 13, 12, 12, 12,
+        12, 11, 11, 11, 10, 10, 10, 10,
         /* Size 4x16 */
-        65, 52, 31, 22, 64, 54, 34, 23, 63, 53, 35, 24, 62, 51, 35, 25, 60, 44,
-        32, 23, 55, 38, 28, 23, 50, 35, 26, 21, 45, 33, 24, 20, 39, 30, 21, 18,
-        34, 28, 20, 16, 31, 26, 18, 14, 28, 24, 17, 14, 26, 23, 16, 13, 24, 23,
-        15, 13, 23, 22, 17, 12, 21, 21, 17, 13,
+        33, 21, 18, 15, 32, 22, 20, 17, 29, 22, 20, 17, 26, 22, 21, 18, 24, 20,
+        19, 17, 22, 19, 18, 16, 23, 19, 17, 16, 22, 19, 16, 15, 21, 19, 15, 14,
+        20, 19, 14, 13, 20, 18, 14, 12, 18, 17, 13, 12, 18, 17, 13, 11, 17, 16,
+        12, 11, 17, 16, 13, 11, 16, 16, 13, 11,
         /* Size 16x4 */
-        65, 64, 63, 62, 60, 55, 50, 45, 39, 34, 31, 28, 26, 24, 23, 21, 52, 54,
-        53, 51, 44, 38, 35, 33, 30, 28, 26, 24, 23, 23, 22, 21, 31, 34, 35, 35,
-        32, 28, 26, 24, 21, 20, 18, 17, 16, 15, 17, 17, 22, 23, 24, 25, 23, 23,
-        21, 20, 18, 16, 14, 14, 13, 13, 12, 13,
+        33, 32, 29, 26, 24, 22, 23, 22, 21, 20, 20, 18, 18, 17, 17, 16, 21, 22,
+        22, 22, 20, 19, 19, 19, 19, 19, 18, 17, 17, 16, 16, 16, 18, 20, 20, 21,
+        19, 18, 17, 16, 15, 14, 14, 13, 13, 12, 13, 13, 15, 17, 17, 18, 17, 16,
+        16, 15, 14, 13, 12, 12, 11, 11, 11, 11,
         /* Size 8x32 */
-        64, 64, 57, 47, 35, 26, 23, 20, 65, 63, 58, 48, 37, 27, 24, 21, 65, 63,
-        59, 49, 38, 28, 25, 22, 65, 63, 59, 50, 39, 28, 25, 23, 64, 61, 56, 49,
-        39, 29, 26, 23, 64, 60, 55, 48, 39, 29, 26, 23, 64, 59, 53, 48, 39, 30,
-        27, 24, 60, 58, 48, 43, 36, 28, 25, 24, 59, 57, 46, 41, 34, 27, 25, 22,
-        57, 55, 43, 38, 33, 26, 24, 23, 52, 52, 41, 35, 30, 24, 23, 20, 51, 51,
-        40, 34, 29, 24, 22, 22, 47, 48, 38, 33, 27, 23, 21, 19, 43, 45, 37, 31,
-        26, 21, 21, 21, 42, 44, 36, 30, 25, 21, 20, 17, 38, 41, 34, 29, 24, 20,
-        18, 19, 36, 39, 33, 27, 23, 19, 18, 17, 35, 38, 32, 27, 22, 18, 17, 17,
-        32, 35, 30, 26, 21, 17, 16, 16, 30, 33, 29, 25, 20, 17, 16, 16, 29, 32,
-        28, 24, 20, 16, 15, 15, 26, 29, 26, 23, 19, 15, 15, 14, 25, 28, 25, 22,
-        19, 15, 14, 14, 25, 28, 25, 22, 18, 15, 14, 13, 23, 26, 24, 21, 18, 15,
-        14, 14, 23, 25, 23, 21, 18, 15, 13, 11, 22, 25, 23, 20, 18, 16, 13, 13,
-        21, 24, 22, 19, 17, 15, 14, 12, 20, 23, 22, 19, 16, 14, 13, 13, 20, 22,
-        21, 19, 16, 13, 11, 11, 19, 21, 21, 18, 16, 13, 11, 11, 18, 20, 22, 20,
-        18, 16, 14, 13,
+        32, 31, 23, 21, 20, 18, 16, 15, 33, 30, 23, 22, 20, 19, 17, 16, 33, 30,
+        23, 22, 21, 19, 17, 16, 34, 29, 23, 23, 21, 20, 18, 17, 31, 28, 22, 23,
+        22, 20, 18, 17, 31, 27, 22, 22, 22, 20, 18, 17, 28, 24, 22, 23, 22, 20,
+        19, 17, 26, 24, 21, 22, 21, 20, 18, 18, 24, 23, 21, 21, 20, 19, 18, 17,
+        22, 22, 20, 19, 19, 18, 17, 17, 21, 22, 20, 19, 19, 18, 17, 16, 21, 22,
+        20, 18, 18, 17, 16, 16, 21, 22, 20, 18, 17, 17, 16, 15, 21, 23, 20, 18,
+        17, 16, 15, 15, 20, 22, 20, 17, 16, 16, 14, 14, 20, 22, 20, 17, 16, 15,
+        14, 14, 20, 22, 19, 17, 16, 14, 14, 14, 19, 21, 19, 17, 15, 14, 13, 14,
+        19, 21, 19, 17, 15, 14, 13, 13, 18, 20, 19, 16, 15, 13, 12, 13, 18, 20,
+        19, 16, 15, 13, 12, 12, 17, 19, 18, 16, 14, 13, 12, 12, 17, 19, 18, 16,
+        14, 13, 12, 12, 16, 18, 17, 15, 14, 12, 11, 12, 16, 18, 17, 15, 14, 12,
+        11, 11, 16, 18, 17, 15, 14, 12, 11, 11, 16, 17, 17, 15, 13, 12, 11, 11,
+        15, 17, 17, 15, 13, 12, 11, 11, 15, 17, 17, 15, 13, 12, 11, 11, 15, 17,
+        17, 15, 13, 12, 11, 10, 15, 16, 17, 15, 14, 12, 11, 10, 15, 16, 17, 15,
+        14, 12, 11, 10,
         /* Size 32x8 */
-        64, 65, 65, 65, 64, 64, 64, 60, 59, 57, 52, 51, 47, 43, 42, 38, 36, 35,
-        32, 30, 29, 26, 25, 25, 23, 23, 22, 21, 20, 20, 19, 18, 64, 63, 63, 63,
-        61, 60, 59, 58, 57, 55, 52, 51, 48, 45, 44, 41, 39, 38, 35, 33, 32, 29,
-        28, 28, 26, 25, 25, 24, 23, 22, 21, 20, 57, 58, 59, 59, 56, 55, 53, 48,
-        46, 43, 41, 40, 38, 37, 36, 34, 33, 32, 30, 29, 28, 26, 25, 25, 24, 23,
-        23, 22, 22, 21, 21, 22, 47, 48, 49, 50, 49, 48, 48, 43, 41, 38, 35, 34,
-        33, 31, 30, 29, 27, 27, 26, 25, 24, 23, 22, 22, 21, 21, 20, 19, 19, 19,
-        18, 20, 35, 37, 38, 39, 39, 39, 39, 36, 34, 33, 30, 29, 27, 26, 25, 24,
-        23, 22, 21, 20, 20, 19, 19, 18, 18, 18, 18, 17, 16, 16, 16, 18, 26, 27,
-        28, 28, 29, 29, 30, 28, 27, 26, 24, 24, 23, 21, 21, 20, 19, 18, 17, 17,
-        16, 15, 15, 15, 15, 15, 16, 15, 14, 13, 13, 16, 23, 24, 25, 25, 26, 26,
-        27, 25, 25, 24, 23, 22, 21, 21, 20, 18, 18, 17, 16, 16, 15, 15, 14, 14,
-        14, 13, 13, 14, 13, 11, 11, 14, 20, 21, 22, 23, 23, 23, 24, 24, 22, 23,
-        20, 22, 19, 21, 17, 19, 17, 17, 16, 16, 15, 14, 14, 13, 14, 11, 13, 12,
-        13, 11, 11, 13 },
-      { /* Chroma */
-#if CONFIG_CB4X4
-        /* Size 2x2 */
-        42, 35, 35, 22,
-#endif
-        /* Size 4x4 */
-        64, 45, 38, 32, 45, 37, 33, 29, 38, 33, 26, 25, 32, 29, 25, 20,
-        /* Size 8x8 */
-        65, 56, 43, 42, 39, 34, 32, 29, 56, 48, 43, 44, 42, 37, 34, 32, 43, 43,
-        39, 38, 37, 34, 32, 32, 42, 44, 38, 34, 32, 29, 29, 29, 39, 42, 37, 32,
-        29, 26, 25, 26, 34, 37, 34, 29, 26, 23, 23, 22, 32, 34, 32, 29, 25, 23,
-        21, 19, 29, 32, 32, 29, 26, 22, 19, 19,
-        /* Size 16x16 */
-        64, 67, 61, 56, 46, 42, 42, 40, 38, 36, 34, 32, 31, 29, 28, 27, 67, 65,
-        59, 52, 47, 45, 45, 43, 41, 39, 37, 34, 33, 32, 31, 29, 61, 59, 53, 47,
-        45, 44, 45, 44, 42, 40, 38, 36, 35, 34, 32, 31, 56, 52, 47, 43, 43, 44,
-        45, 44, 43, 41, 39, 37, 36, 35, 34, 33, 46, 47, 45, 43, 41, 40, 40, 40,
-        39, 38, 36, 34, 34, 33, 31, 30, 42, 45, 44, 44, 40, 38, 37, 36, 35, 34,
-        33, 32, 31, 32, 30, 29, 42, 45, 45, 45, 40, 37, 35, 34, 33, 32, 31, 30,
-        29, 29, 29, 27, 40, 43, 44, 44, 40, 36, 34, 33, 31, 30, 29, 28, 28, 27,
-        28, 26, 38, 41, 42, 43, 39, 35, 33, 31, 29, 28, 27, 26, 26, 25, 27, 24,
-        36, 39, 40, 41, 38, 34, 32, 30, 28, 27, 26, 25, 24, 25, 26, 23, 34, 37,
-        38, 39, 36, 33, 31, 29, 27, 26, 25, 24, 23, 24, 24, 22, 32, 34, 36, 37,
-        34, 32, 30, 28, 26, 25, 24, 23, 22, 22, 22, 20, 31, 33, 35, 36, 34, 31,
-        29, 28, 26, 24, 23, 22, 21, 21, 20, 19, 29, 32, 34, 35, 33, 32, 29, 27,
-        25, 25, 24, 22, 21, 20, 20, 18, 28, 31, 32, 34, 31, 30, 29, 28, 27, 26,
-        24, 22, 20, 20, 19, 19, 27, 29, 31, 33, 30, 29, 27, 26, 24, 23, 22, 20,
-        19, 18, 19, 18,
-        /* Size 32x32 */
-        64, 66, 67, 67, 61, 59, 56, 49, 46, 42, 42, 42, 42, 41, 40, 39, 38, 37,
-        36, 35, 34, 32, 32, 32, 31, 30, 29, 29, 28, 28, 27, 27, 66, 65, 65, 66,
-        59, 56, 53, 48, 46, 43, 44, 44, 44, 42, 42, 41, 40, 39, 38, 37, 36, 34,
-        34, 33, 32, 32, 31, 31, 30, 29, 29, 29, 67, 65, 65, 65, 59, 55, 52, 48,
-        47, 44, 45, 45, 45, 44, 43, 42, 41, 40, 39, 38, 37, 35, 34, 34, 33, 33,
-        32, 31, 31, 30, 29, 28, 67, 66, 65, 64, 58, 55, 51, 48, 47, 44, 45, 45,
-        46, 44, 44, 43, 41, 41, 39, 38, 38, 36, 35, 35, 34, 33, 33, 32, 32, 31,
-        30, 30, 61, 59, 59, 58, 53, 50, 47, 46, 45, 43, 44, 45, 45, 44, 44, 43,
-        42, 41, 40, 39, 38, 36, 36, 36, 35, 34, 34, 33, 32, 32, 31, 30, 59, 56,
-        55, 55, 50, 48, 45, 45, 44, 43, 44, 45, 45, 44, 44, 44, 42, 42, 41, 39,
-        39, 37, 37, 36, 35, 34, 34, 33, 32, 32, 31, 31, 56, 53, 52, 51, 47, 45,
-        43, 43, 43, 43, 44, 45, 45, 45, 44, 44, 43, 42, 41, 40, 39, 38, 37, 37,
-        36, 35, 35, 34, 34, 33, 33, 31, 49, 48, 48, 48, 46, 45, 43, 42, 41, 41,
-        41, 41, 42, 41, 41, 41, 40, 39, 38, 38, 37, 36, 35, 35, 34, 34, 34, 34,
-        34, 33, 33, 33, 46, 46, 47, 47, 45, 44, 43, 41, 41, 40, 40, 40, 40, 40,
-        40, 39, 39, 38, 38, 37, 36, 35, 34, 34, 34, 34, 33, 32, 31, 31, 30, 32,
-        42, 43, 44, 44, 43, 43, 43, 41, 40, 39, 39, 38, 38, 38, 38, 38, 37, 37,
-        36, 35, 35, 34, 34, 33, 33, 32, 31, 31, 32, 32, 31, 29, 42, 44, 45, 45,
-        44, 44, 44, 41, 40, 39, 38, 38, 37, 36, 36, 36, 35, 35, 34, 34, 33, 32,
-        32, 32, 31, 31, 32, 31, 30, 29, 29, 31, 42, 44, 45, 45, 45, 45, 45, 41,
-        40, 38, 38, 37, 36, 36, 36, 35, 34, 34, 34, 33, 33, 32, 31, 31, 31, 31,
-        30, 29, 30, 31, 30, 27, 42, 44, 45, 46, 45, 45, 45, 42, 40, 38, 37, 36,
-        35, 34, 34, 33, 33, 33, 32, 32, 31, 30, 30, 30, 29, 29, 29, 30, 29, 27,
-        27, 30, 41, 42, 44, 44, 44, 44, 45, 41, 40, 38, 36, 36, 34, 34, 33, 32,
-        32, 32, 31, 30, 30, 29, 29, 29, 28, 29, 29, 27, 27, 29, 29, 26, 40, 42,
-        43, 44, 44, 44, 44, 41, 40, 38, 36, 36, 34, 33, 33, 32, 31, 31, 30, 30,
-        29, 29, 28, 28, 28, 28, 27, 28, 28, 26, 26, 29, 39, 41, 42, 43, 43, 44,
-        44, 41, 39, 38, 36, 35, 33, 32, 32, 31, 30, 30, 29, 28, 28, 27, 27, 27,
-        27, 26, 27, 26, 26, 28, 28, 24, 38, 40, 41, 41, 42, 42, 43, 40, 39, 37,
-        35, 34, 33, 32, 31, 30, 29, 29, 28, 27, 27, 26, 26, 26, 26, 26, 25, 26,
-        27, 25, 24, 27, 37, 39, 40, 41, 41, 42, 42, 39, 38, 37, 35, 34, 33, 32,
-        31, 30, 29, 29, 28, 27, 27, 26, 26, 26, 25, 25, 25, 26, 24, 26, 26, 23,
-        36, 38, 39, 39, 40, 41, 41, 38, 38, 36, 34, 34, 32, 31, 30, 29, 28, 28,
-        27, 26, 26, 25, 25, 25, 24, 25, 25, 24, 26, 24, 23, 26, 35, 37, 38, 38,
-        39, 39, 40, 38, 37, 35, 34, 33, 32, 30, 30, 28, 27, 27, 26, 26, 25, 24,
-        24, 24, 24, 24, 23, 25, 23, 24, 25, 21, 34, 36, 37, 38, 38, 39, 39, 37,
-        36, 35, 33, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 24, 24, 23, 23,
-        24, 22, 24, 23, 22, 25, 32, 34, 35, 36, 36, 37, 38, 36, 35, 34, 32, 32,
-        30, 29, 29, 27, 26, 26, 25, 24, 24, 23, 23, 23, 22, 23, 22, 23, 22, 22,
-        24, 21, 32, 34, 34, 35, 36, 37, 37, 35, 34, 34, 32, 31, 30, 29, 28, 27,
-        26, 26, 25, 24, 24, 23, 23, 23, 22, 22, 22, 22, 22, 23, 20, 24, 32, 33,
-        34, 35, 36, 36, 37, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 26, 25, 24,
-        24, 23, 23, 22, 22, 22, 21, 21, 22, 20, 23, 19, 31, 32, 33, 34, 35, 35,
-        36, 34, 34, 33, 31, 31, 29, 28, 28, 27, 26, 25, 24, 24, 23, 22, 22, 22,
-        21, 22, 21, 21, 20, 22, 19, 23, 30, 32, 33, 33, 34, 34, 35, 34, 34, 32,
-        31, 31, 29, 29, 28, 26, 26, 25, 25, 24, 23, 23, 22, 22, 22, 21, 21, 21,
-        21, 19, 22, 18, 29, 31, 32, 33, 34, 34, 35, 34, 33, 31, 32, 30, 29, 29,
-        27, 27, 25, 25, 25, 23, 24, 22, 22, 21, 21, 21, 20, 21, 20, 21, 18, 21,
-        29, 31, 31, 32, 33, 33, 34, 34, 32, 31, 31, 29, 30, 27, 28, 26, 26, 26,
-        24, 25, 22, 23, 22, 21, 21, 21, 21, 20, 21, 20, 21, 17, 28, 30, 31, 32,
-        32, 32, 34, 34, 31, 32, 30, 30, 29, 27, 28, 26, 27, 24, 26, 23, 24, 22,
-        22, 22, 20, 21, 20, 21, 19, 20, 19, 20, 28, 29, 30, 31, 32, 32, 33, 33,
-        31, 32, 29, 31, 27, 29, 26, 28, 25, 26, 24, 24, 23, 22, 23, 20, 22, 19,
-        21, 20, 20, 19, 20, 19, 27, 29, 29, 30, 31, 31, 33, 33, 30, 31, 29, 30,
-        27, 29, 26, 28, 24, 26, 23, 25, 22, 24, 20, 23, 19, 22, 18, 21, 19, 20,
-        18, 20, 27, 29, 28, 30, 30, 31, 31, 33, 32, 29, 31, 27, 30, 26, 29, 24,
-        27, 23, 26, 21, 25, 21, 24, 19, 23, 18, 21, 17, 20, 19, 20, 18,
-        /* Size 4x8 */
-        65, 44, 38, 31, 54, 44, 41, 33, 44, 38, 36, 32, 44, 36, 31, 27, 41, 35,
-        28, 26, 36, 32, 25, 23, 33, 31, 24, 21, 31, 31, 25, 21,
-        /* Size 8x4 */
-        65, 54, 44, 44, 41, 36, 33, 31, 44, 44, 38, 36, 35, 32, 31, 31, 38, 41,
-        36, 31, 28, 25, 24, 25, 31, 33, 32, 27, 26, 23, 21, 21,
-        /* Size 8x16 */
-        64, 60, 43, 42, 38, 32, 30, 28, 66, 57, 44, 45, 41, 35, 33, 31, 61, 51,
-        44, 45, 42, 37, 34, 32, 55, 47, 43, 45, 43, 38, 36, 34, 46, 45, 40, 40,
-        39, 35, 34, 31, 42, 44, 39, 37, 35, 32, 31, 29, 42, 45, 38, 35, 33, 30,
-        29, 28, 40, 44, 38, 34, 31, 29, 28, 26, 38, 42, 37, 33, 29, 26, 26, 25,
-        36, 40, 36, 32, 28, 25, 24, 24, 34, 38, 35, 31, 27, 24, 23, 23, 32, 36,
-        34, 30, 26, 23, 22, 22, 31, 35, 33, 29, 26, 22, 22, 22, 29, 33, 32, 29,
-        26, 24, 21, 21, 28, 32, 31, 27, 24, 22, 21, 21, 27, 31, 31, 27, 24, 22,
-        19, 19,
-        /* Size 16x8 */
-        64, 66, 61, 55, 46, 42, 42, 40, 38, 36, 34, 32, 31, 29, 28, 27, 60, 57,
-        51, 47, 45, 44, 45, 44, 42, 40, 38, 36, 35, 33, 32, 31, 43, 44, 44, 43,
-        40, 39, 38, 38, 37, 36, 35, 34, 33, 32, 31, 31, 42, 45, 45, 45, 40, 37,
-        35, 34, 33, 32, 31, 30, 29, 29, 27, 27, 38, 41, 42, 43, 39, 35, 33, 31,
-        29, 28, 27, 26, 26, 26, 24, 24, 32, 35, 37, 38, 35, 32, 30, 29, 26, 25,
-        24, 23, 22, 24, 22, 22, 30, 33, 34, 36, 34, 31, 29, 28, 26, 24, 23, 22,
-        22, 21, 21, 19, 28, 31, 32, 34, 31, 29, 28, 26, 25, 24, 23, 22, 22, 21,
-        21, 19,
-        /* Size 16x32 */
-        64, 66, 60, 55, 43, 42, 42, 39, 38, 36, 32, 32, 30, 29, 28, 27, 65, 65,
-        58, 53, 44, 44, 44, 41, 40, 38, 34, 34, 32, 31, 30, 29, 66, 64, 57, 52,
-        44, 45, 45, 42, 41, 39, 35, 34, 33, 32, 31, 29, 67, 64, 56, 51, 45, 45,
-        45, 43, 41, 39, 36, 35, 34, 33, 32, 31, 61, 57, 51, 48, 44, 44, 45, 43,
-        42, 40, 37, 36, 34, 33, 32, 30, 58, 54, 49, 46, 43, 44, 45, 43, 42, 41,
-        37, 37, 35, 33, 32, 32, 55, 51, 47, 44, 43, 44, 45, 44, 43, 41, 38, 37,
-        36, 35, 34, 31, 49, 48, 45, 43, 41, 41, 41, 41, 40, 38, 36, 35, 34, 34,
-        34, 34, 46, 46, 45, 43, 40, 40, 40, 39, 39, 38, 35, 34, 34, 32, 31, 33,
-        42, 44, 43, 43, 39, 38, 38, 38, 37, 36, 34, 34, 32, 32, 32, 29, 42, 45,
-        44, 44, 39, 38, 37, 36, 35, 34, 32, 32, 31, 32, 29, 31, 42, 45, 45, 44,
-        39, 37, 36, 35, 34, 34, 32, 31, 31, 29, 31, 28, 42, 45, 45, 45, 38, 37,
-        35, 33, 33, 32, 30, 30, 29, 30, 28, 30, 41, 44, 44, 44, 38, 36, 34, 32,
-        32, 31, 29, 29, 29, 27, 29, 26, 40, 44, 44, 44, 38, 36, 34, 32, 31, 30,
-        29, 28, 28, 28, 26, 29, 39, 43, 43, 43, 38, 36, 34, 31, 30, 29, 27, 27,
-        26, 27, 28, 25, 38, 41, 42, 42, 37, 35, 33, 30, 29, 28, 26, 26, 26, 26,
-        25, 28, 38, 41, 41, 42, 37, 35, 33, 30, 29, 28, 26, 26, 25, 26, 26, 23,
-        36, 39, 40, 41, 36, 34, 32, 29, 28, 27, 25, 25, 24, 24, 24, 26, 35, 38,
-        39, 39, 35, 33, 32, 28, 27, 26, 24, 24, 24, 25, 24, 22, 34, 38, 38, 39,
-        35, 33, 31, 28, 27, 26, 24, 24, 23, 22, 23, 25, 32, 36, 37, 37, 34, 32,
-        30, 27, 26, 25, 23, 23, 23, 23, 22, 21, 32, 35, 36, 37, 34, 32, 30, 27,
-        26, 25, 23, 23, 22, 22, 22, 24, 32, 35, 36, 37, 33, 32, 30, 27, 26, 25,
-        23, 23, 22, 21, 21, 19, 31, 34, 35, 36, 33, 31, 29, 27, 26, 24, 22, 22,
-        22, 21, 22, 23, 30, 33, 34, 35, 32, 31, 29, 27, 26, 24, 23, 22, 21, 21,
-        19, 19, 29, 33, 33, 34, 32, 32, 29, 27, 26, 23, 24, 21, 21, 21, 21, 22,
-        29, 32, 33, 34, 32, 31, 27, 28, 25, 24, 23, 21, 21, 20, 20, 17, 28, 31,
-        32, 33, 31, 31, 27, 28, 24, 26, 22, 22, 21, 20, 21, 21, 28, 31, 32, 33,
-        31, 31, 27, 28, 24, 25, 21, 23, 19, 21, 19, 19, 27, 30, 31, 32, 31, 30,
-        27, 28, 24, 25, 22, 23, 19, 21, 19, 20, 27, 30, 30, 33, 32, 28, 30, 25,
-        27, 22, 25, 19, 23, 17, 20, 18,
-        /* Size 32x16 */
-        64, 65, 66, 67, 61, 58, 55, 49, 46, 42, 42, 42, 42, 41, 40, 39, 38, 38,
-        36, 35, 34, 32, 32, 32, 31, 30, 29, 29, 28, 28, 27, 27, 66, 65, 64, 64,
-        57, 54, 51, 48, 46, 44, 45, 45, 45, 44, 44, 43, 41, 41, 39, 38, 38, 36,
-        35, 35, 34, 33, 33, 32, 31, 31, 30, 30, 60, 58, 57, 56, 51, 49, 47, 45,
-        45, 43, 44, 45, 45, 44, 44, 43, 42, 41, 40, 39, 38, 37, 36, 36, 35, 34,
-        33, 33, 32, 32, 31, 30, 55, 53, 52, 51, 48, 46, 44, 43, 43, 43, 44, 44,
-        45, 44, 44, 43, 42, 42, 41, 39, 39, 37, 37, 37, 36, 35, 34, 34, 33, 33,
-        32, 33, 43, 44, 44, 45, 44, 43, 43, 41, 40, 39, 39, 39, 38, 38, 38, 38,
-        37, 37, 36, 35, 35, 34, 34, 33, 33, 32, 32, 32, 31, 31, 31, 32, 42, 44,
-        45, 45, 44, 44, 44, 41, 40, 38, 38, 37, 37, 36, 36, 36, 35, 35, 34, 33,
-        33, 32, 32, 32, 31, 31, 32, 31, 31, 31, 30, 28, 42, 44, 45, 45, 45, 45,
-        45, 41, 40, 38, 37, 36, 35, 34, 34, 34, 33, 33, 32, 32, 31, 30, 30, 30,
-        29, 29, 29, 27, 27, 27, 27, 30, 39, 41, 42, 43, 43, 43, 44, 41, 39, 38,
-        36, 35, 33, 32, 32, 31, 30, 30, 29, 28, 28, 27, 27, 27, 27, 27, 27, 28,
-        28, 28, 28, 25, 38, 40, 41, 41, 42, 42, 43, 40, 39, 37, 35, 34, 33, 32,
-        31, 30, 29, 29, 28, 27, 27, 26, 26, 26, 26, 26, 26, 25, 24, 24, 24, 27,
-        36, 38, 39, 39, 40, 41, 41, 38, 38, 36, 34, 34, 32, 31, 30, 29, 28, 28,
-        27, 26, 26, 25, 25, 25, 24, 24, 23, 24, 26, 25, 25, 22, 32, 34, 35, 36,
-        37, 37, 38, 36, 35, 34, 32, 32, 30, 29, 29, 27, 26, 26, 25, 24, 24, 23,
-        23, 23, 22, 23, 24, 23, 22, 21, 22, 25, 32, 34, 34, 35, 36, 37, 37, 35,
-        34, 34, 32, 31, 30, 29, 28, 27, 26, 26, 25, 24, 24, 23, 23, 23, 22, 22,
-        21, 21, 22, 23, 23, 19, 30, 32, 33, 34, 34, 35, 36, 34, 34, 32, 31, 31,
-        29, 29, 28, 26, 26, 25, 24, 24, 23, 23, 22, 22, 22, 21, 21, 21, 21, 19,
-        19, 23, 29, 31, 32, 33, 33, 33, 35, 34, 32, 32, 32, 29, 30, 27, 28, 27,
-        26, 26, 24, 25, 22, 23, 22, 21, 21, 21, 21, 20, 20, 21, 21, 17, 28, 30,
-        31, 32, 32, 32, 34, 34, 31, 32, 29, 31, 28, 29, 26, 28, 25, 26, 24, 24,
-        23, 22, 22, 21, 22, 19, 21, 20, 21, 19, 19, 20, 27, 29, 29, 31, 30, 32,
-        31, 34, 33, 29, 31, 28, 30, 26, 29, 25, 28, 23, 26, 22, 25, 21, 24, 19,
-        23, 19, 22, 17, 21, 19, 20, 18,
-        /* Size 4x16 */
-        66, 42, 36, 29, 64, 45, 39, 32, 57, 44, 40, 33, 51, 44, 41, 35, 46, 40,
-        38, 32, 45, 38, 34, 32, 45, 37, 32, 30, 44, 36, 30, 28, 41, 35, 28, 26,
-        39, 34, 27, 24, 38, 33, 26, 22, 35, 32, 25, 22, 34, 31, 24, 21, 33, 32,
-        23, 21, 31, 31, 26, 20, 30, 30, 25, 21,
-        /* Size 16x4 */
-        66, 64, 57, 51, 46, 45, 45, 44, 41, 39, 38, 35, 34, 33, 31, 30, 42, 45,
-        44, 44, 40, 38, 37, 36, 35, 34, 33, 32, 31, 32, 31, 30, 36, 39, 40, 41,
-        38, 34, 32, 30, 28, 27, 26, 25, 24, 23, 26, 25, 29, 32, 33, 35, 32, 32,
-        30, 28, 26, 24, 22, 22, 21, 21, 20, 21,
-        /* Size 8x32 */
-        64, 60, 43, 42, 38, 32, 30, 28, 65, 58, 44, 44, 40, 34, 32, 30, 66, 57,
-        44, 45, 41, 35, 33, 31, 67, 56, 45, 45, 41, 36, 34, 32, 61, 51, 44, 45,
-        42, 37, 34, 32, 58, 49, 43, 45, 42, 37, 35, 32, 55, 47, 43, 45, 43, 38,
-        36, 34, 49, 45, 41, 41, 40, 36, 34, 34, 46, 45, 40, 40, 39, 35, 34, 31,
-        42, 43, 39, 38, 37, 34, 32, 32, 42, 44, 39, 37, 35, 32, 31, 29, 42, 45,
-        39, 36, 34, 32, 31, 31, 42, 45, 38, 35, 33, 30, 29, 28, 41, 44, 38, 34,
-        32, 29, 29, 29, 40, 44, 38, 34, 31, 29, 28, 26, 39, 43, 38, 34, 30, 27,
-        26, 28, 38, 42, 37, 33, 29, 26, 26, 25, 38, 41, 37, 33, 29, 26, 25, 26,
-        36, 40, 36, 32, 28, 25, 24, 24, 35, 39, 35, 32, 27, 24, 24, 24, 34, 38,
-        35, 31, 27, 24, 23, 23, 32, 37, 34, 30, 26, 23, 23, 22, 32, 36, 34, 30,
-        26, 23, 22, 22, 32, 36, 33, 30, 26, 23, 22, 21, 31, 35, 33, 29, 26, 22,
-        22, 22, 30, 34, 32, 29, 26, 23, 21, 19, 29, 33, 32, 29, 26, 24, 21, 21,
-        29, 33, 32, 27, 25, 23, 21, 20, 28, 32, 31, 27, 24, 22, 21, 21, 28, 32,
-        31, 27, 24, 21, 19, 19, 27, 31, 31, 27, 24, 22, 19, 19, 27, 30, 32, 30,
-        27, 25, 23, 20,
-        /* Size 32x8 */
-        64, 65, 66, 67, 61, 58, 55, 49, 46, 42, 42, 42, 42, 41, 40, 39, 38, 38,
-        36, 35, 34, 32, 32, 32, 31, 30, 29, 29, 28, 28, 27, 27, 60, 58, 57, 56,
-        51, 49, 47, 45, 45, 43, 44, 45, 45, 44, 44, 43, 42, 41, 40, 39, 38, 37,
-        36, 36, 35, 34, 33, 33, 32, 32, 31, 30, 43, 44, 44, 45, 44, 43, 43, 41,
-        40, 39, 39, 39, 38, 38, 38, 38, 37, 37, 36, 35, 35, 34, 34, 33, 33, 32,
-        32, 32, 31, 31, 31, 32, 42, 44, 45, 45, 45, 45, 45, 41, 40, 38, 37, 36,
-        35, 34, 34, 34, 33, 33, 32, 32, 31, 30, 30, 30, 29, 29, 29, 27, 27, 27,
-        27, 30, 38, 40, 41, 41, 42, 42, 43, 40, 39, 37, 35, 34, 33, 32, 31, 30,
-        29, 29, 28, 27, 27, 26, 26, 26, 26, 26, 26, 25, 24, 24, 24, 27, 32, 34,
-        35, 36, 37, 37, 38, 36, 35, 34, 32, 32, 30, 29, 29, 27, 26, 26, 25, 24,
-        24, 23, 23, 23, 22, 23, 24, 23, 22, 21, 22, 25, 30, 32, 33, 34, 34, 35,
-        36, 34, 34, 32, 31, 31, 29, 29, 28, 26, 26, 25, 24, 24, 23, 23, 22, 22,
-        22, 21, 21, 21, 21, 19, 19, 23, 28, 30, 31, 32, 32, 32, 34, 34, 31, 32,
-        29, 31, 28, 29, 26, 28, 25, 26, 24, 24, 23, 22, 22, 21, 22, 19, 21, 20,
-        21, 19, 19, 20 },
+        32, 33, 33, 34, 31, 31, 28, 26, 24, 22, 21, 21, 21, 21, 20, 20, 20, 19,
+        19, 18, 18, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 31, 30, 30, 29,
+        28, 27, 24, 24, 23, 22, 22, 22, 22, 23, 22, 22, 22, 21, 21, 20, 20, 19,
+        19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 23, 23, 23, 23, 22, 22, 22, 21,
+        21, 20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 18, 18, 17, 17, 17,
+        17, 17, 17, 17, 17, 17, 21, 22, 22, 23, 23, 22, 23, 22, 21, 19, 19, 18,
+        18, 18, 17, 17, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15,
+        15, 15, 20, 20, 21, 21, 22, 22, 22, 21, 20, 19, 19, 18, 17, 17, 16, 16,
+        16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13, 13, 14, 14, 18, 19,
+        19, 20, 20, 20, 20, 20, 19, 18, 18, 17, 17, 16, 16, 15, 14, 14, 14, 13,
+        13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 17, 17, 18, 18, 18,
+        19, 18, 18, 17, 17, 16, 16, 15, 14, 14, 14, 13, 13, 12, 12, 12, 12, 11,
+        11, 11, 11, 11, 11, 11, 11, 11, 15, 16, 16, 17, 17, 17, 17, 18, 17, 17,
+        16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11,
+        11, 10, 10, 10 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        56, 29, 29, 15,
+        29, 16, 16, 9,
+#endif
+        /* Size 4x4 */
+        32, 30, 19, 14, 30, 21, 16, 13, 19, 16, 11, 9, 14, 13, 9, 7,
+        /* Size 8x8 */
+        32, 32, 30, 26, 20, 17, 13, 12, 32, 31, 29, 26, 21, 17, 14, 13, 30, 29,
+        26, 22, 19, 16, 14, 13, 26, 26, 22, 18, 16, 14, 12, 11, 20, 21, 19, 16,
+        13, 11, 10, 10, 17, 17, 16, 14, 11, 10, 9, 8, 13, 14, 14, 12, 10, 9, 8,
+        7, 12, 13, 13, 11, 10, 8, 7, 7,
+        /* Size 16x16 */
+        32, 33, 33, 32, 31, 28, 26, 23, 21, 19, 17, 16, 14, 13, 12, 11, 33, 32,
+        32, 32, 31, 29, 27, 24, 22, 20, 18, 16, 15, 13, 13, 12, 33, 32, 32, 31,
+        30, 29, 27, 25, 23, 21, 19, 17, 15, 14, 13, 12, 32, 32, 31, 30, 28, 28,
+        26, 24, 23, 21, 19, 17, 16, 14, 14, 13, 31, 31, 30, 28, 27, 24, 23, 22,
+        20, 19, 18, 16, 15, 14, 13, 13, 28, 29, 29, 28, 24, 21, 20, 19, 18, 17,
+        16, 15, 14, 13, 12, 12, 26, 27, 27, 26, 23, 20, 19, 18, 17, 16, 15, 14,
+        13, 12, 12, 11, 23, 24, 25, 24, 22, 19, 18, 16, 15, 14, 14, 13, 12, 11,
+        11, 11, 21, 22, 23, 23, 20, 18, 17, 15, 14, 13, 13, 12, 11, 10, 10, 10,
+        19, 20, 21, 21, 19, 17, 16, 14, 13, 12, 12, 11, 10, 10, 9, 9, 17, 18,
+        19, 19, 18, 16, 15, 14, 13, 12, 11, 10, 10, 9, 9, 9, 16, 16, 17, 17, 16,
+        15, 14, 13, 12, 11, 10, 10, 9, 8, 8, 8, 14, 15, 15, 16, 15, 14, 13, 12,
+        11, 10, 10, 9, 8, 8, 8, 7, 13, 13, 14, 14, 14, 13, 12, 11, 10, 10, 9, 8,
+        8, 7, 7, 7, 12, 13, 13, 14, 13, 12, 12, 11, 10, 9, 9, 8, 8, 7, 7, 7, 11,
+        12, 12, 13, 13, 12, 11, 11, 10, 9, 9, 8, 7, 7, 7, 6,
+        /* Size 32x32 */
+        32, 33, 33, 33, 33, 33, 32, 32, 31, 30, 28, 28, 26, 25, 23, 22, 21, 20,
+        19, 18, 17, 16, 16, 14, 14, 13, 13, 12, 12, 12, 11, 11, 33, 32, 32, 32,
+        32, 32, 32, 32, 31, 30, 29, 29, 27, 26, 24, 23, 22, 20, 20, 18, 18, 17,
+        16, 15, 14, 13, 13, 13, 12, 12, 12, 12, 33, 32, 32, 32, 32, 32, 32, 32,
+        31, 30, 29, 29, 27, 26, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 15, 14,
+        13, 13, 13, 12, 12, 12, 33, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30,
+        28, 27, 25, 24, 23, 21, 21, 19, 19, 17, 17, 16, 15, 14, 14, 14, 13, 13,
+        12, 12, 33, 32, 32, 32, 32, 31, 31, 31, 30, 30, 29, 29, 27, 26, 25, 24,
+        23, 21, 21, 19, 19, 17, 17, 16, 15, 14, 14, 14, 13, 13, 12, 12, 33, 32,
+        32, 32, 31, 31, 31, 30, 29, 29, 28, 28, 26, 26, 24, 23, 23, 21, 20, 19,
+        19, 17, 17, 16, 15, 14, 14, 14, 13, 13, 13, 12, 32, 32, 32, 32, 31, 31,
+        30, 29, 28, 28, 28, 27, 26, 26, 24, 23, 23, 21, 21, 19, 19, 18, 17, 16,
+        16, 15, 14, 14, 14, 13, 13, 12, 32, 32, 32, 32, 31, 30, 29, 29, 28, 28,
+        27, 27, 26, 25, 24, 23, 22, 21, 21, 19, 19, 18, 17, 16, 16, 15, 14, 14,
+        14, 13, 13, 13, 31, 31, 31, 31, 30, 29, 28, 28, 27, 26, 24, 24, 23, 23,
+        22, 21, 20, 20, 19, 18, 18, 17, 16, 15, 15, 14, 14, 14, 13, 13, 13, 13,
+        30, 30, 30, 31, 30, 29, 28, 28, 26, 26, 24, 24, 23, 22, 22, 21, 20, 19,
+        19, 18, 18, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 28, 29, 29, 30,
+        29, 28, 28, 27, 24, 24, 21, 21, 20, 20, 19, 19, 18, 17, 17, 16, 16, 15,
+        15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 28, 29, 29, 30, 29, 28, 27, 27,
+        24, 24, 21, 21, 20, 20, 19, 19, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13,
+        13, 13, 12, 12, 12, 11, 26, 27, 27, 28, 27, 26, 26, 26, 23, 23, 20, 20,
+        19, 19, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 12, 11,
+        11, 11, 25, 26, 26, 27, 26, 26, 26, 25, 23, 22, 20, 20, 19, 18, 17, 17,
+        16, 16, 15, 15, 15, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 23, 24,
+        24, 25, 25, 24, 24, 24, 22, 22, 19, 19, 18, 17, 16, 16, 15, 15, 14, 14,
+        14, 13, 13, 12, 12, 11, 11, 11, 11, 11, 11, 11, 22, 23, 23, 24, 24, 23,
+        23, 23, 21, 21, 19, 19, 17, 17, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12,
+        12, 11, 11, 11, 10, 10, 10, 10, 21, 22, 22, 23, 23, 23, 23, 22, 20, 20,
+        18, 18, 17, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 11, 11, 11, 10, 10,
+        10, 10, 10, 10, 20, 20, 21, 21, 21, 21, 21, 21, 20, 19, 17, 17, 16, 16,
+        15, 14, 14, 13, 13, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 9,
+        19, 20, 20, 21, 21, 20, 21, 21, 19, 19, 17, 17, 16, 15, 14, 14, 13, 13,
+        12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 18, 18, 19, 19, 19,
+        19, 19, 19, 18, 18, 16, 16, 15, 15, 14, 13, 13, 12, 12, 11, 11, 11, 10,
+        10, 10, 9, 9, 9, 9, 9, 9, 9, 17, 18, 18, 19, 19, 19, 19, 19, 18, 18, 16,
+        16, 15, 15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 9,
+        9, 9, 16, 17, 17, 17, 17, 17, 18, 18, 17, 16, 15, 15, 14, 14, 13, 12,
+        12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 8, 16, 16, 16, 17,
+        17, 17, 17, 17, 16, 16, 15, 15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10,
+        10, 9, 9, 9, 8, 8, 8, 8, 8, 8, 14, 15, 15, 16, 16, 16, 16, 16, 15, 15,
+        14, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 8,
+        8, 8, 14, 14, 15, 15, 15, 15, 16, 16, 15, 15, 14, 14, 13, 12, 12, 12,
+        11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 8, 8, 8, 7, 8, 13, 13, 14, 14, 14,
+        14, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 9, 9, 9, 9, 8,
+        8, 8, 8, 7, 7, 7, 7, 7, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 13, 13,
+        12, 12, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 12,
+        13, 13, 14, 14, 14, 14, 14, 14, 13, 13, 13, 12, 12, 11, 11, 10, 10, 10,
+        9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 12, 12, 13, 13, 13, 13, 14, 14,
+        13, 13, 12, 12, 12, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7,
+        7, 7, 7, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 12, 12, 11, 11, 11, 10,
+        10, 10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 11, 12, 12, 12, 12,
+        13, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 7,
+        7, 7, 7, 7, 7, 6, 6, 11, 12, 12, 12, 12, 12, 12, 13, 13, 12, 12, 11, 11,
+        11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6,
+        /* Size 4x8 */
+        32, 29, 20, 13, 32, 28, 20, 14, 30, 24, 19, 14, 27, 20, 15, 12, 21, 17,
+        13, 10, 17, 15, 11, 9, 14, 13, 10, 8, 13, 12, 9, 7,
+        /* Size 8x4 */
+        32, 32, 30, 27, 21, 17, 14, 13, 29, 28, 24, 20, 17, 15, 13, 12, 20, 20,
+        19, 15, 13, 11, 10, 9, 13, 14, 14, 12, 10, 9, 8, 7,
+        /* Size 8x16 */
+        32, 33, 31, 26, 20, 16, 13, 12, 33, 32, 31, 26, 21, 17, 14, 12, 33, 32,
+        30, 27, 22, 17, 14, 13, 32, 31, 28, 26, 21, 18, 15, 13, 31, 30, 27, 23,
+        20, 17, 14, 13, 28, 29, 24, 20, 18, 15, 13, 12, 26, 27, 23, 19, 16, 14,
+        12, 12, 23, 25, 22, 17, 15, 13, 11, 11, 21, 23, 20, 17, 14, 12, 11, 10,
+        19, 21, 19, 16, 13, 11, 10, 9, 18, 19, 18, 15, 12, 10, 9, 9, 16, 17, 16,
+        14, 11, 10, 9, 8, 14, 15, 15, 13, 11, 9, 8, 8, 13, 14, 14, 12, 10, 9, 8,
+        7, 12, 13, 13, 11, 10, 8, 7, 7, 11, 12, 13, 11, 10, 9, 7, 7,
+        /* Size 16x8 */
+        32, 33, 33, 32, 31, 28, 26, 23, 21, 19, 18, 16, 14, 13, 12, 11, 33, 32,
+        32, 31, 30, 29, 27, 25, 23, 21, 19, 17, 15, 14, 13, 12, 31, 31, 30, 28,
+        27, 24, 23, 22, 20, 19, 18, 16, 15, 14, 13, 13, 26, 26, 27, 26, 23, 20,
+        19, 17, 17, 16, 15, 14, 13, 12, 11, 11, 20, 21, 22, 21, 20, 18, 16, 15,
+        14, 13, 12, 11, 11, 10, 10, 10, 16, 17, 17, 18, 17, 15, 14, 13, 12, 11,
+        10, 10, 9, 9, 8, 9, 13, 14, 14, 15, 14, 13, 12, 11, 11, 10, 9, 9, 8, 8,
+        7, 7, 12, 12, 13, 13, 13, 12, 12, 11, 10, 9, 9, 8, 8, 7, 7, 7,
+        /* Size 16x32 */
+        32, 33, 33, 32, 31, 28, 26, 23, 20, 19, 16, 16, 13, 13, 12, 11, 33, 32,
+        32, 32, 31, 29, 26, 24, 21, 20, 17, 16, 14, 13, 12, 12, 33, 32, 32, 32,
+        31, 29, 26, 24, 21, 20, 17, 17, 14, 13, 12, 12, 33, 32, 32, 31, 31, 30,
+        27, 25, 22, 21, 17, 17, 14, 14, 13, 13, 33, 32, 32, 31, 30, 29, 27, 25,
+        22, 21, 17, 17, 14, 14, 13, 13, 32, 32, 31, 30, 29, 28, 26, 24, 21, 20,
+        17, 17, 14, 14, 13, 13, 32, 32, 31, 29, 28, 28, 26, 24, 21, 21, 18, 17,
+        15, 14, 13, 13, 32, 31, 31, 29, 28, 27, 25, 24, 21, 21, 18, 17, 15, 15,
+        14, 13, 31, 31, 30, 28, 27, 25, 23, 22, 20, 19, 17, 16, 14, 14, 13, 13,
+        30, 30, 30, 28, 26, 24, 23, 21, 19, 19, 16, 16, 14, 14, 13, 12, 28, 30,
+        29, 27, 24, 21, 20, 19, 18, 17, 15, 15, 13, 13, 12, 12, 28, 29, 29, 27,
+        24, 21, 20, 19, 17, 17, 15, 15, 13, 13, 12, 12, 26, 28, 27, 26, 23, 20,
+        19, 18, 16, 16, 14, 14, 12, 12, 12, 12, 26, 27, 26, 25, 23, 20, 18, 17,
+        16, 15, 14, 13, 12, 12, 11, 11, 23, 25, 25, 24, 22, 19, 17, 16, 15, 14,
+        13, 13, 11, 11, 11, 11, 22, 24, 24, 23, 21, 19, 17, 16, 14, 14, 12, 12,
+        11, 11, 11, 10, 21, 23, 23, 22, 20, 18, 17, 15, 14, 13, 12, 12, 11, 10,
+        10, 10, 20, 21, 21, 21, 20, 17, 16, 15, 13, 13, 11, 11, 10, 10, 10, 10,
+        19, 21, 21, 20, 19, 17, 16, 14, 13, 12, 11, 11, 10, 10, 9, 10, 18, 19,
+        19, 19, 18, 16, 15, 14, 12, 12, 11, 10, 9, 9, 9, 9, 18, 19, 19, 19, 18,
+        16, 15, 14, 12, 12, 10, 10, 9, 9, 9, 9, 16, 17, 17, 18, 17, 15, 14, 13,
+        12, 11, 10, 10, 9, 9, 8, 8, 16, 17, 17, 17, 16, 15, 14, 13, 11, 11, 10,
+        10, 9, 8, 8, 8, 14, 16, 16, 16, 15, 14, 13, 12, 11, 11, 9, 9, 8, 8, 8,
+        8, 14, 15, 15, 16, 15, 14, 13, 12, 11, 10, 9, 9, 8, 8, 8, 8, 13, 14, 14,
+        15, 14, 13, 12, 11, 10, 10, 9, 9, 8, 8, 7, 7, 13, 14, 14, 14, 14, 13,
+        12, 11, 10, 10, 9, 8, 8, 7, 7, 7, 12, 14, 14, 14, 14, 13, 12, 11, 10,
+        10, 8, 8, 8, 7, 7, 7, 12, 13, 13, 14, 13, 12, 11, 11, 10, 9, 8, 8, 7, 7,
+        7, 7, 12, 13, 13, 13, 13, 12, 11, 10, 10, 9, 8, 8, 7, 7, 7, 7, 11, 12,
+        12, 13, 13, 12, 11, 10, 10, 9, 9, 8, 7, 7, 7, 7, 11, 12, 12, 13, 13, 11,
+        11, 10, 10, 9, 9, 8, 8, 7, 7, 6,
+        /* Size 32x16 */
+        32, 33, 33, 33, 33, 32, 32, 32, 31, 30, 28, 28, 26, 26, 23, 22, 21, 20,
+        19, 18, 18, 16, 16, 14, 14, 13, 13, 12, 12, 12, 11, 11, 33, 32, 32, 32,
+        32, 32, 32, 31, 31, 30, 30, 29, 28, 27, 25, 24, 23, 21, 21, 19, 19, 17,
+        17, 16, 15, 14, 14, 14, 13, 13, 12, 12, 33, 32, 32, 32, 32, 31, 31, 31,
+        30, 30, 29, 29, 27, 26, 25, 24, 23, 21, 21, 19, 19, 17, 17, 16, 15, 14,
+        14, 14, 13, 13, 12, 12, 32, 32, 32, 31, 31, 30, 29, 29, 28, 28, 27, 27,
+        26, 25, 24, 23, 22, 21, 20, 19, 19, 18, 17, 16, 16, 15, 14, 14, 14, 13,
+        13, 13, 31, 31, 31, 31, 30, 29, 28, 28, 27, 26, 24, 24, 23, 23, 22, 21,
+        20, 20, 19, 18, 18, 17, 16, 15, 15, 14, 14, 14, 13, 13, 13, 13, 28, 29,
+        29, 30, 29, 28, 28, 27, 25, 24, 21, 21, 20, 20, 19, 19, 18, 17, 17, 16,
+        16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12, 11, 26, 26, 26, 27, 27, 26,
+        26, 25, 23, 23, 20, 20, 19, 18, 17, 17, 17, 16, 16, 15, 15, 14, 14, 13,
+        13, 12, 12, 12, 11, 11, 11, 11, 23, 24, 24, 25, 25, 24, 24, 24, 22, 21,
+        19, 19, 18, 17, 16, 16, 15, 15, 14, 14, 14, 13, 13, 12, 12, 11, 11, 11,
+        11, 10, 10, 10, 20, 21, 21, 22, 22, 21, 21, 21, 20, 19, 18, 17, 16, 16,
+        15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10,
+        19, 20, 20, 21, 21, 20, 21, 21, 19, 19, 17, 17, 16, 15, 14, 14, 13, 13,
+        12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 16, 17, 17, 17, 17,
+        17, 18, 18, 17, 16, 15, 15, 14, 14, 13, 12, 12, 11, 11, 11, 10, 10, 10,
+        9, 9, 9, 9, 8, 8, 8, 9, 9, 16, 16, 17, 17, 17, 17, 17, 17, 16, 16, 15,
+        15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 9, 8, 8, 8, 8, 8,
+        8, 13, 14, 14, 14, 14, 14, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 11,
+        10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 8, 13, 13, 13, 14, 14, 14,
+        14, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 8,
+        7, 7, 7, 7, 7, 7, 12, 12, 12, 13, 13, 13, 13, 14, 13, 13, 12, 12, 12,
+        11, 11, 11, 10, 10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 11, 12,
+        12, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 10, 10, 10, 10, 9,
+        9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6,
+        /* Size 4x16 */
+        33, 28, 19, 13, 32, 29, 20, 13, 32, 29, 21, 14, 32, 28, 21, 14, 31, 25,
+        19, 14, 30, 21, 17, 13, 28, 20, 16, 12, 25, 19, 14, 11, 23, 18, 13, 10,
+        21, 17, 12, 10, 19, 16, 12, 9, 17, 15, 11, 8, 15, 14, 10, 8, 14, 13, 10,
+        7, 13, 12, 9, 7, 12, 12, 9, 7,
+        /* Size 16x4 */
+        33, 32, 32, 32, 31, 30, 28, 25, 23, 21, 19, 17, 15, 14, 13, 12, 28, 29,
+        29, 28, 25, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 12, 19, 20, 21, 21,
+        19, 17, 16, 14, 13, 12, 12, 11, 10, 10, 9, 9, 13, 13, 14, 14, 14, 13,
+        12, 11, 10, 10, 9, 8, 8, 7, 7, 7,
+        /* Size 8x32 */
+        32, 33, 31, 26, 20, 16, 13, 12, 33, 32, 31, 26, 21, 17, 14, 12, 33, 32,
+        31, 26, 21, 17, 14, 12, 33, 32, 31, 27, 22, 17, 14, 13, 33, 32, 30, 27,
+        22, 17, 14, 13, 32, 31, 29, 26, 21, 17, 14, 13, 32, 31, 28, 26, 21, 18,
+        15, 13, 32, 31, 28, 25, 21, 18, 15, 14, 31, 30, 27, 23, 20, 17, 14, 13,
+        30, 30, 26, 23, 19, 16, 14, 13, 28, 29, 24, 20, 18, 15, 13, 12, 28, 29,
+        24, 20, 17, 15, 13, 12, 26, 27, 23, 19, 16, 14, 12, 12, 26, 26, 23, 18,
+        16, 14, 12, 11, 23, 25, 22, 17, 15, 13, 11, 11, 22, 24, 21, 17, 14, 12,
+        11, 11, 21, 23, 20, 17, 14, 12, 11, 10, 20, 21, 20, 16, 13, 11, 10, 10,
+        19, 21, 19, 16, 13, 11, 10, 9, 18, 19, 18, 15, 12, 11, 9, 9, 18, 19, 18,
+        15, 12, 10, 9, 9, 16, 17, 17, 14, 12, 10, 9, 8, 16, 17, 16, 14, 11, 10,
+        9, 8, 14, 16, 15, 13, 11, 9, 8, 8, 14, 15, 15, 13, 11, 9, 8, 8, 13, 14,
+        14, 12, 10, 9, 8, 7, 13, 14, 14, 12, 10, 9, 8, 7, 12, 14, 14, 12, 10, 8,
+        8, 7, 12, 13, 13, 11, 10, 8, 7, 7, 12, 13, 13, 11, 10, 8, 7, 7, 11, 12,
+        13, 11, 10, 9, 7, 7, 11, 12, 13, 11, 10, 9, 8, 7,
+        /* Size 32x8 */
+        32, 33, 33, 33, 33, 32, 32, 32, 31, 30, 28, 28, 26, 26, 23, 22, 21, 20,
+        19, 18, 18, 16, 16, 14, 14, 13, 13, 12, 12, 12, 11, 11, 33, 32, 32, 32,
+        32, 31, 31, 31, 30, 30, 29, 29, 27, 26, 25, 24, 23, 21, 21, 19, 19, 17,
+        17, 16, 15, 14, 14, 14, 13, 13, 12, 12, 31, 31, 31, 31, 30, 29, 28, 28,
+        27, 26, 24, 24, 23, 23, 22, 21, 20, 20, 19, 18, 18, 17, 16, 15, 15, 14,
+        14, 14, 13, 13, 13, 13, 26, 26, 26, 27, 27, 26, 26, 25, 23, 23, 20, 20,
+        19, 18, 17, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11,
+        11, 11, 20, 21, 21, 22, 22, 21, 21, 21, 20, 19, 18, 17, 16, 16, 15, 14,
+        14, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 16, 17,
+        17, 17, 17, 17, 18, 18, 17, 16, 15, 15, 14, 14, 13, 12, 12, 11, 11, 11,
+        10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 9, 9, 13, 14, 14, 14, 14, 14, 15, 15,
+        14, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 8,
+        7, 7, 7, 8, 12, 12, 12, 13, 13, 13, 13, 14, 13, 13, 12, 12, 12, 11, 11,
+        11, 10, 10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7 },
+      { /* Chroma */
+#if CONFIG_CHROMA_2X2
+        /* Size 2x2 */
+        22, 20, 20, 12,
 #endif
         /* Size 4x4 */
-        63, 55, 35, 25, 55, 38, 28, 22, 35, 28, 20, 17, 25, 22, 17, 13,
+        32, 22, 21, 18, 22, 19, 19, 17, 21, 19, 15, 13, 18, 17, 13, 11,
         /* Size 8x8 */
-        64, 64, 59, 48, 38, 30, 26, 22, 64, 61, 57, 49, 40, 32, 28, 24, 59, 57,
-        45, 39, 34, 28, 26, 24, 48, 49, 39, 32, 28, 24, 22, 21, 38, 40, 34, 28,
-        24, 20, 19, 18, 30, 32, 28, 24, 20, 17, 16, 15, 26, 28, 26, 22, 19, 16,
-        15, 12, 22, 24, 24, 21, 18, 15, 12, 12,
+        33, 30, 24, 22, 21, 19, 17, 16, 30, 26, 23, 22, 22, 20, 18, 17, 24, 23,
+        21, 21, 20, 19, 18, 17, 22, 22, 21, 19, 18, 17, 16, 16, 21, 22, 20, 18,
+        16, 15, 14, 14, 19, 20, 19, 17, 15, 13, 12, 12, 17, 18, 18, 16, 14, 12,
+        12, 11, 16, 17, 17, 16, 14, 12, 11, 11,
         /* Size 16x16 */
-        64, 65, 65, 64, 60, 57, 50, 43, 38, 35, 31, 27, 25, 23, 22, 21, 65, 64,
-        63, 63, 60, 59, 52, 46, 41, 37, 34, 29, 27, 25, 23, 22, 65, 63, 62, 61,
-        59, 57, 51, 46, 41, 38, 34, 31, 28, 26, 25, 23, 64, 63, 61, 58, 55, 53,
-        49, 46, 41, 38, 35, 31, 29, 27, 25, 24, 60, 60, 59, 55, 52, 48, 45, 41,
-        38, 35, 33, 29, 27, 25, 24, 23, 57, 59, 57, 53, 48, 42, 39, 37, 34, 32,
-        30, 27, 25, 24, 23, 22, 50, 52, 51, 49, 45, 39, 36, 33, 30, 29, 27, 25,
-        23, 22, 21, 20, 43, 46, 46, 46, 41, 37, 33, 29, 27, 26, 24, 22, 21, 20,
-        20, 19, 38, 41, 41, 41, 38, 34, 30, 27, 25, 24, 22, 20, 19, 19, 19, 17,
-        35, 37, 38, 38, 35, 32, 29, 26, 24, 22, 21, 19, 18, 18, 18, 16, 31, 34,
-        34, 35, 33, 30, 27, 24, 22, 21, 20, 18, 17, 16, 17, 15, 27, 29, 31, 31,
-        29, 27, 25, 22, 20, 19, 18, 17, 16, 15, 15, 14, 25, 27, 28, 29, 27, 25,
-        23, 21, 19, 18, 17, 16, 15, 14, 13, 13, 23, 25, 26, 27, 25, 24, 22, 20,
-        19, 18, 16, 15, 14, 14, 13, 12, 22, 23, 25, 25, 24, 23, 21, 20, 19, 18,
-        17, 15, 13, 13, 13, 12, 21, 22, 23, 24, 23, 22, 20, 19, 17, 16, 15, 14,
-        13, 12, 12, 12,
+        32, 33, 33, 29, 26, 21, 21, 21, 20, 20, 19, 18, 17, 16, 16, 15, 33, 33,
+        32, 28, 25, 22, 22, 22, 21, 21, 20, 19, 18, 17, 17, 16, 33, 32, 30, 26,
+        24, 22, 22, 23, 22, 22, 21, 20, 19, 18, 17, 17, 29, 28, 26, 23, 22, 22,
+        22, 23, 22, 22, 21, 20, 19, 18, 18, 17, 26, 25, 24, 22, 21, 20, 21, 21,
+        21, 21, 20, 19, 19, 18, 17, 17, 21, 22, 22, 22, 20, 19, 19, 19, 19, 19,
+        19, 18, 17, 17, 17, 17, 21, 22, 22, 22, 21, 19, 19, 19, 18, 18, 18, 17,
+        17, 16, 16, 16, 21, 22, 23, 23, 21, 19, 19, 18, 17, 17, 17, 16, 16, 15,
+        15, 15, 20, 21, 22, 22, 21, 19, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14,
+        20, 21, 22, 22, 21, 19, 18, 17, 16, 16, 15, 14, 14, 14, 13, 13, 19, 20,
+        21, 21, 20, 19, 18, 17, 16, 15, 14, 14, 13, 13, 13, 13, 18, 19, 20, 20,
+        19, 18, 17, 16, 15, 14, 14, 13, 13, 12, 12, 12, 17, 18, 19, 19, 19, 17,
+        17, 16, 15, 14, 13, 13, 12, 12, 12, 12, 16, 17, 18, 18, 18, 17, 16, 15,
+        14, 14, 13, 12, 12, 11, 11, 11, 16, 17, 17, 18, 17, 17, 16, 15, 14, 13,
+        13, 12, 12, 11, 11, 11, 15, 16, 17, 17, 17, 17, 16, 15, 14, 13, 13, 12,
+        12, 11, 11, 10,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 64, 63, 60, 58, 57, 52, 50, 47, 43, 42, 38, 37,
-        35, 32, 31, 29, 27, 26, 25, 25, 23, 23, 22, 21, 21, 20, 65, 64, 64, 64,
-        64, 64, 63, 62, 60, 59, 59, 53, 51, 48, 45, 44, 40, 38, 36, 34, 33, 30,
-        29, 27, 26, 26, 25, 24, 23, 22, 22, 21, 65, 64, 64, 64, 63, 63, 63, 62,
-        60, 59, 59, 54, 52, 49, 46, 45, 41, 39, 37, 34, 34, 31, 29, 27, 27, 27,
-        25, 24, 23, 23, 22, 21, 65, 64, 64, 63, 63, 63, 63, 62, 61, 60, 59, 55,
-        53, 50, 47, 46, 41, 40, 38, 35, 34, 32, 30, 28, 27, 27, 26, 25, 24, 23,
-        23, 22, 65, 64, 63, 63, 62, 62, 61, 60, 59, 57, 57, 53, 51, 49, 46, 45,
-        41, 40, 38, 35, 34, 32, 31, 29, 28, 28, 26, 25, 25, 24, 23, 22, 65, 64,
-        63, 63, 62, 61, 60, 59, 58, 57, 56, 53, 51, 49, 46, 45, 41, 40, 38, 35,
-        35, 32, 31, 29, 28, 28, 26, 25, 25, 24, 23, 23, 64, 63, 63, 63, 61, 60,
-        58, 57, 55, 54, 53, 51, 49, 48, 46, 45, 41, 40, 38, 36, 35, 33, 31, 29,
-        29, 28, 27, 26, 25, 25, 24, 23, 63, 62, 62, 62, 60, 59, 57, 56, 54, 52,
-        51, 49, 48, 46, 44, 43, 40, 39, 37, 35, 34, 32, 30, 29, 28, 28, 26, 26,
-        26, 25, 24, 24, 60, 60, 60, 61, 59, 58, 55, 54, 52, 49, 48, 46, 45, 43,
-        41, 40, 38, 37, 35, 33, 33, 30, 29, 28, 27, 27, 25, 25, 24, 23, 23, 23,
-        58, 59, 59, 60, 57, 57, 54, 52, 49, 45, 44, 41, 41, 39, 37, 37, 35, 34,
-        33, 31, 31, 28, 28, 26, 26, 26, 24, 24, 24, 24, 23, 21, 57, 59, 59, 59,
-        57, 56, 53, 51, 48, 44, 42, 41, 39, 38, 37, 36, 34, 33, 32, 31, 30, 28,
-        27, 26, 25, 25, 24, 24, 23, 22, 22, 22, 52, 53, 54, 55, 53, 53, 51, 49,
-        46, 41, 41, 38, 37, 35, 34, 34, 32, 31, 30, 28, 28, 26, 25, 24, 24, 24,
-        23, 22, 22, 22, 22, 20, 50, 51, 52, 53, 51, 51, 49, 48, 45, 41, 39, 37,
-        36, 34, 33, 32, 30, 30, 29, 27, 27, 25, 25, 24, 23, 23, 22, 22, 21, 20,
-        20, 21, 47, 48, 49, 50, 49, 49, 48, 46, 43, 39, 38, 35, 34, 32, 31, 31,
-        29, 28, 27, 26, 26, 24, 24, 23, 22, 22, 21, 20, 20, 21, 21, 19, 43, 45,
-        46, 47, 46, 46, 46, 44, 41, 37, 37, 34, 33, 31, 29, 29, 27, 27, 26, 25,
-        24, 23, 22, 22, 21, 21, 20, 21, 20, 19, 19, 20, 42, 44, 45, 46, 45, 45,
-        45, 43, 40, 37, 36, 34, 32, 31, 29, 29, 27, 26, 25, 24, 24, 23, 22, 21,
-        21, 21, 20, 19, 19, 20, 20, 17, 38, 40, 41, 41, 41, 41, 41, 40, 38, 35,
-        34, 32, 30, 29, 27, 27, 25, 24, 24, 22, 22, 21, 20, 20, 19, 19, 19, 19,
-        19, 18, 17, 19, 37, 38, 39, 40, 40, 40, 40, 39, 37, 34, 33, 31, 30, 28,
-        27, 26, 24, 24, 23, 22, 22, 20, 20, 19, 19, 19, 18, 18, 17, 18, 18, 16,
-        35, 36, 37, 38, 38, 38, 38, 37, 35, 33, 32, 30, 29, 27, 26, 25, 24, 23,
-        22, 21, 21, 20, 19, 19, 18, 18, 18, 17, 18, 17, 16, 18, 32, 34, 34, 35,
-        35, 35, 36, 35, 33, 31, 31, 28, 27, 26, 25, 24, 22, 22, 21, 20, 20, 19,
-        18, 18, 17, 17, 17, 17, 16, 17, 17, 15, 31, 33, 34, 34, 34, 35, 35, 34,
-        33, 31, 30, 28, 27, 26, 24, 24, 22, 22, 21, 20, 20, 18, 18, 17, 17, 17,
-        16, 16, 17, 16, 15, 17, 29, 30, 31, 32, 32, 32, 33, 32, 30, 28, 28, 26,
-        25, 24, 23, 23, 21, 20, 20, 19, 18, 17, 17, 16, 16, 16, 15, 16, 15, 15,
-        16, 14, 27, 29, 29, 30, 31, 31, 31, 30, 29, 28, 27, 25, 25, 24, 22, 22,
-        20, 20, 19, 18, 18, 17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 16, 26, 27,
-        27, 28, 29, 29, 29, 29, 28, 26, 26, 24, 24, 23, 22, 21, 20, 19, 19, 18,
-        17, 16, 16, 15, 15, 15, 14, 14, 15, 14, 15, 13, 25, 26, 27, 27, 28, 28,
-        29, 28, 27, 26, 25, 24, 23, 22, 21, 21, 19, 19, 18, 17, 17, 16, 16, 15,
-        15, 15, 14, 14, 13, 15, 13, 15, 25, 26, 27, 27, 28, 28, 28, 28, 27, 26,
-        25, 24, 23, 22, 21, 21, 19, 19, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14,
-        14, 12, 14, 12, 23, 25, 25, 26, 26, 26, 27, 26, 25, 24, 24, 23, 22, 21,
-        20, 20, 19, 18, 18, 17, 16, 15, 15, 14, 14, 14, 14, 14, 13, 14, 12, 14,
-        23, 24, 24, 25, 25, 25, 26, 26, 25, 24, 24, 22, 22, 20, 21, 19, 19, 18,
-        17, 17, 16, 16, 15, 14, 14, 14, 14, 13, 14, 13, 13, 11, 22, 23, 23, 24,
-        25, 25, 25, 26, 24, 24, 23, 22, 21, 20, 20, 19, 19, 17, 18, 16, 17, 15,
-        15, 15, 13, 14, 13, 14, 13, 13, 12, 13, 21, 22, 23, 23, 24, 24, 25, 25,
-        23, 24, 22, 22, 20, 21, 19, 20, 18, 18, 17, 17, 16, 15, 15, 14, 15, 12,
-        14, 13, 13, 12, 13, 12, 21, 22, 22, 23, 23, 23, 24, 24, 23, 23, 22, 22,
-        20, 21, 19, 20, 17, 18, 16, 17, 15, 16, 14, 15, 13, 14, 12, 13, 12, 13,
-        12, 13, 20, 21, 21, 22, 22, 23, 23, 24, 23, 21, 22, 20, 21, 19, 20, 17,
-        19, 16, 18, 15, 17, 14, 16, 13, 15, 12, 14, 11, 13, 12, 13, 11,
+        32, 33, 33, 34, 33, 31, 29, 28, 26, 25, 21, 21, 21, 21, 21, 20, 20, 20,
+        20, 19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 15, 15, 15, 33, 33, 33, 33,
+        32, 30, 28, 27, 25, 24, 22, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 19,
+        19, 18, 18, 17, 17, 17, 16, 16, 16, 16, 33, 33, 33, 33, 32, 29, 28, 26,
+        25, 24, 22, 22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 19, 19, 18, 18, 17,
+        17, 17, 17, 16, 16, 16, 34, 33, 33, 32, 31, 29, 27, 26, 24, 24, 22, 22,
+        23, 23, 23, 23, 22, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 18, 17, 17,
+        17, 17, 33, 32, 32, 31, 30, 28, 26, 25, 24, 24, 22, 22, 22, 23, 23, 22,
+        22, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 17, 31, 30,
+        29, 29, 28, 26, 25, 24, 23, 23, 22, 22, 22, 22, 23, 22, 22, 22, 22, 21,
+        21, 20, 20, 19, 19, 18, 18, 18, 18, 17, 17, 17, 29, 28, 28, 27, 26, 25,
+        23, 22, 22, 22, 22, 22, 22, 22, 23, 22, 22, 22, 22, 21, 21, 20, 20, 20,
+        19, 19, 18, 18, 18, 18, 17, 17, 28, 27, 26, 26, 25, 24, 22, 22, 22, 22,
+        21, 22, 22, 22, 23, 22, 22, 22, 22, 21, 21, 20, 20, 20, 19, 19, 19, 19,
+        18, 18, 18, 18, 26, 25, 25, 24, 24, 23, 22, 22, 21, 21, 20, 21, 21, 21,
+        21, 21, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17,
+        25, 24, 24, 24, 24, 23, 22, 22, 21, 21, 20, 20, 21, 21, 21, 21, 20, 20,
+        20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17, 21, 22, 22, 22,
+        22, 22, 22, 21, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18,
+        18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 21, 22, 22, 22, 22, 22, 22, 22,
+        21, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 17, 17, 17,
+        17, 17, 16, 16, 16, 16, 21, 22, 22, 23, 22, 22, 22, 22, 21, 21, 19, 19,
+        19, 19, 19, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, 16, 16, 16, 16, 16,
+        16, 16, 21, 22, 22, 23, 23, 22, 22, 22, 21, 21, 19, 19, 19, 19, 18, 18,
+        18, 18, 18, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 15, 15, 21, 22,
+        22, 23, 23, 23, 23, 23, 21, 21, 19, 19, 19, 18, 18, 17, 17, 17, 17, 17,
+        17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 20, 22, 22, 23, 22, 22,
+        22, 22, 21, 21, 19, 19, 18, 18, 17, 17, 17, 17, 17, 16, 16, 16, 16, 15,
+        15, 15, 15, 15, 15, 15, 14, 14, 20, 21, 21, 22, 22, 22, 22, 22, 21, 20,
+        19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14,
+        14, 14, 14, 14, 20, 21, 21, 22, 22, 22, 22, 22, 21, 20, 19, 19, 18, 18,
+        17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+        20, 20, 21, 22, 22, 22, 22, 22, 21, 20, 19, 19, 18, 18, 17, 17, 16, 16,
+        16, 15, 15, 15, 14, 14, 14, 14, 14, 14, 13, 13, 13, 14, 19, 20, 20, 21,
+        21, 21, 21, 21, 20, 20, 19, 19, 18, 17, 17, 16, 16, 15, 15, 15, 15, 14,
+        14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 19, 20, 20, 21, 21, 21, 21, 21,
+        20, 20, 19, 18, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 14, 14, 13, 13,
+        13, 13, 13, 13, 13, 13, 18, 19, 19, 20, 20, 20, 20, 20, 20, 19, 18, 18,
+        17, 17, 16, 16, 15, 15, 15, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 12,
+        12, 12, 18, 19, 19, 20, 20, 20, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16,
+        15, 15, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 17, 18,
+        18, 19, 19, 19, 20, 20, 19, 19, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14,
+        14, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 17, 18, 18, 19, 19, 19,
+        19, 19, 19, 18, 17, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 13, 12,
+        12, 12, 12, 12, 12, 12, 12, 12, 16, 17, 17, 18, 18, 18, 19, 19, 18, 18,
+        17, 17, 16, 16, 15, 15, 14, 14, 14, 13, 13, 12, 12, 12, 12, 12, 12, 11,
+        11, 11, 11, 11, 16, 17, 17, 18, 18, 18, 18, 19, 18, 18, 17, 17, 16, 16,
+        15, 15, 14, 14, 14, 13, 13, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11,
+        16, 17, 17, 18, 18, 18, 18, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14,
+        14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 16, 16, 17, 17,
+        17, 18, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12,
+        12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 15, 16, 16, 17, 17, 17, 18, 18,
+        17, 17, 17, 16, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 11,
+        11, 11, 11, 11, 11, 11, 15, 16, 16, 17, 17, 17, 17, 18, 17, 17, 17, 16,
+        16, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11,
+        10, 11, 15, 16, 16, 17, 17, 17, 17, 18, 17, 17, 17, 16, 16, 15, 15, 14,
+        14, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 10,
         /* Size 4x8 */
-        64, 58, 34, 24, 63, 56, 36, 26, 59, 44, 32, 24, 50, 38, 26, 21, 40, 33,
-        22, 18, 31, 28, 19, 16, 27, 25, 17, 14, 23, 22, 18, 14,
+        33, 22, 20, 17, 28, 22, 22, 18, 24, 20, 20, 18, 23, 19, 18, 16, 22, 19,
+        16, 14, 20, 18, 15, 12, 18, 17, 14, 11, 17, 16, 13, 11,
         /* Size 8x4 */
-        64, 63, 59, 50, 40, 31, 27, 23, 58, 56, 44, 38, 33, 28, 25, 22, 34, 36,
-        32, 26, 22, 19, 17, 18, 24, 26, 24, 21, 18, 16, 14, 14,
+        33, 28, 24, 23, 22, 20, 18, 17, 22, 22, 20, 19, 19, 18, 17, 16, 20, 22,
+        20, 18, 16, 15, 14, 13, 17, 18, 18, 16, 14, 12, 11, 11,
         /* Size 8x16 */
-        64, 65, 59, 47, 38, 31, 25, 22, 65, 63, 59, 49, 41, 34, 27, 23, 65, 62,
-        58, 49, 41, 35, 28, 24, 64, 60, 55, 48, 41, 35, 29, 25, 60, 59, 49, 43,
-        38, 33, 27, 24, 57, 57, 45, 38, 34, 30, 25, 22, 50, 51, 41, 34, 30, 27,
-        23, 21, 44, 46, 38, 31, 27, 24, 21, 19, 38, 41, 36, 29, 25, 22, 19, 18,
-        35, 38, 33, 27, 24, 21, 18, 17, 32, 34, 31, 26, 22, 20, 17, 16, 27, 31,
-        28, 24, 20, 18, 16, 15, 25, 28, 26, 22, 19, 17, 15, 15, 23, 26, 25, 21,
-        19, 16, 14, 14, 22, 25, 24, 21, 17, 15, 14, 13, 21, 23, 23, 20, 17, 15,
-        13, 12,
+        32, 32, 26, 21, 20, 18, 16, 15, 33, 31, 25, 22, 21, 19, 17, 16, 33, 29,
+        24, 22, 22, 20, 18, 17, 29, 26, 22, 22, 22, 20, 19, 18, 25, 24, 21, 21,
+        21, 20, 18, 17, 21, 22, 20, 19, 19, 18, 17, 17, 21, 22, 21, 19, 18, 17,
+        16, 16, 21, 23, 21, 18, 17, 16, 15, 15, 20, 22, 21, 18, 16, 15, 14, 14,
+        20, 21, 20, 18, 16, 14, 14, 13, 19, 20, 20, 17, 15, 14, 13, 13, 18, 20,
+        19, 17, 15, 13, 12, 12, 17, 19, 18, 16, 14, 13, 12, 12, 16, 18, 18, 16,
+        14, 12, 12, 11, 16, 17, 17, 16, 14, 12, 11, 11, 15, 17, 17, 16, 14, 13,
+        12, 11,
         /* Size 16x8 */
-        64, 65, 65, 64, 60, 57, 50, 44, 38, 35, 32, 27, 25, 23, 22, 21, 65, 63,
-        62, 60, 59, 57, 51, 46, 41, 38, 34, 31, 28, 26, 25, 23, 59, 59, 58, 55,
-        49, 45, 41, 38, 36, 33, 31, 28, 26, 25, 24, 23, 47, 49, 49, 48, 43, 38,
-        34, 31, 29, 27, 26, 24, 22, 21, 21, 20, 38, 41, 41, 41, 38, 34, 30, 27,
-        25, 24, 22, 20, 19, 19, 17, 17, 31, 34, 35, 35, 33, 30, 27, 24, 22, 21,
-        20, 18, 17, 16, 15, 15, 25, 27, 28, 29, 27, 25, 23, 21, 19, 18, 17, 16,
-        15, 14, 14, 13, 22, 23, 24, 25, 24, 22, 21, 19, 18, 17, 16, 15, 15, 14,
-        13, 12,
+        32, 33, 33, 29, 25, 21, 21, 21, 20, 20, 19, 18, 17, 16, 16, 15, 32, 31,
+        29, 26, 24, 22, 22, 23, 22, 21, 20, 20, 19, 18, 17, 17, 26, 25, 24, 22,
+        21, 20, 21, 21, 21, 20, 20, 19, 18, 18, 17, 17, 21, 22, 22, 22, 21, 19,
+        19, 18, 18, 18, 17, 17, 16, 16, 16, 16, 20, 21, 22, 22, 21, 19, 18, 17,
+        16, 16, 15, 15, 14, 14, 14, 14, 18, 19, 20, 20, 20, 18, 17, 16, 15, 14,
+        14, 13, 13, 12, 12, 13, 16, 17, 18, 19, 18, 17, 16, 15, 14, 14, 13, 12,
+        12, 12, 11, 12, 15, 16, 17, 18, 17, 17, 16, 15, 14, 13, 13, 12, 12, 11,
+        11, 11,
         /* Size 16x32 */
-        64, 65, 65, 64, 59, 57, 47, 43, 38, 33, 31, 26, 25, 23, 22, 21, 65, 64,
-        64, 63, 59, 58, 48, 45, 40, 34, 33, 27, 26, 24, 23, 22, 65, 64, 63, 63,
-        59, 59, 49, 46, 41, 35, 34, 28, 27, 25, 23, 22, 65, 63, 63, 62, 60, 59,
-        50, 47, 41, 36, 34, 28, 27, 25, 24, 23, 65, 63, 62, 60, 58, 57, 49, 46,
-        41, 36, 35, 29, 28, 26, 24, 23, 64, 63, 62, 60, 57, 56, 49, 46, 41, 36,
-        35, 29, 28, 26, 25, 24, 64, 62, 60, 58, 55, 53, 48, 46, 41, 37, 35, 30,
-        29, 27, 25, 23, 63, 62, 59, 57, 53, 51, 46, 44, 40, 35, 34, 29, 28, 26,
-        25, 25, 60, 60, 59, 55, 49, 48, 43, 41, 38, 34, 33, 28, 27, 25, 24, 24,
-        58, 59, 57, 54, 46, 44, 39, 37, 35, 32, 31, 26, 26, 24, 24, 22, 57, 59,
-        57, 53, 45, 43, 38, 37, 34, 31, 30, 26, 25, 24, 22, 23, 52, 55, 53, 51,
-        43, 41, 35, 34, 32, 29, 28, 24, 24, 23, 23, 20, 50, 53, 51, 49, 41, 40,
-        34, 33, 30, 28, 27, 24, 23, 22, 21, 22, 47, 50, 49, 48, 40, 38, 33, 31,
-        29, 26, 26, 23, 22, 21, 22, 19, 44, 47, 46, 45, 38, 37, 31, 29, 27, 25,
-        24, 22, 21, 21, 19, 21, 43, 46, 45, 44, 38, 36, 31, 29, 27, 25, 24, 21,
-        21, 20, 20, 18, 38, 41, 41, 41, 36, 34, 29, 27, 25, 23, 22, 20, 19, 19,
-        18, 20, 37, 40, 40, 40, 35, 33, 28, 27, 24, 22, 22, 19, 19, 18, 18, 16,
-        35, 38, 38, 38, 33, 32, 27, 26, 24, 21, 21, 19, 18, 17, 17, 18, 32, 35,
-        35, 36, 32, 31, 26, 25, 23, 20, 20, 18, 17, 17, 17, 15, 32, 34, 34, 35,
-        31, 30, 26, 24, 22, 20, 20, 17, 17, 16, 16, 17, 29, 31, 32, 32, 29, 28,
-        24, 23, 21, 19, 18, 16, 16, 16, 15, 14, 27, 30, 31, 31, 28, 27, 24, 22,
-        20, 19, 18, 16, 16, 15, 15, 16, 26, 28, 29, 29, 27, 26, 23, 22, 20, 18,
-        17, 15, 15, 14, 14, 13, 25, 27, 28, 28, 26, 25, 22, 21, 19, 18, 17, 15,
-        15, 14, 15, 15, 25, 27, 28, 28, 26, 25, 22, 21, 19, 17, 17, 15, 15, 14,
-        13, 12, 23, 26, 26, 27, 25, 24, 21, 20, 19, 17, 16, 14, 14, 14, 14, 14,
-        23, 25, 25, 26, 24, 24, 21, 21, 18, 17, 16, 14, 14, 13, 13, 11, 22, 24,
-        25, 25, 24, 23, 21, 20, 17, 18, 15, 15, 14, 13, 13, 13, 21, 23, 24, 25,
-        23, 22, 20, 20, 17, 18, 15, 16, 13, 14, 12, 12, 21, 23, 23, 24, 23, 22,
-        20, 20, 17, 17, 15, 15, 13, 13, 12, 13, 20, 22, 22, 24, 23, 20, 21, 17,
-        19, 15, 17, 13, 15, 11, 13, 11,
+        32, 33, 32, 28, 26, 21, 21, 21, 20, 20, 18, 18, 16, 16, 15, 15, 33, 33,
+        31, 27, 25, 22, 22, 22, 21, 20, 19, 19, 17, 17, 16, 16, 33, 33, 31, 27,
+        25, 22, 22, 22, 21, 21, 19, 19, 17, 17, 16, 16, 34, 32, 31, 26, 24, 22,
+        23, 23, 22, 21, 20, 20, 18, 18, 17, 17, 33, 31, 29, 25, 24, 22, 22, 23,
+        22, 21, 20, 20, 18, 18, 17, 17, 31, 28, 28, 24, 23, 22, 22, 22, 22, 22,
+        20, 20, 18, 18, 17, 17, 29, 27, 26, 23, 22, 22, 22, 23, 22, 22, 20, 20,
+        19, 18, 18, 17, 28, 26, 25, 22, 22, 22, 22, 23, 22, 22, 20, 20, 19, 19,
+        18, 18, 25, 24, 24, 22, 21, 21, 21, 21, 21, 20, 20, 19, 18, 18, 17, 18,
+        24, 24, 24, 22, 21, 20, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 21, 22,
+        22, 21, 20, 19, 19, 19, 19, 19, 18, 18, 17, 17, 17, 17, 21, 22, 22, 21,
+        20, 19, 19, 19, 19, 19, 18, 18, 17, 17, 16, 16, 21, 22, 22, 22, 21, 19,
+        19, 18, 18, 18, 17, 17, 16, 16, 16, 16, 21, 23, 22, 22, 21, 19, 19, 18,
+        18, 18, 17, 17, 16, 16, 16, 15, 21, 23, 23, 22, 21, 19, 18, 18, 17, 17,
+        16, 16, 15, 15, 15, 15, 21, 22, 22, 22, 21, 19, 18, 17, 17, 17, 16, 16,
+        15, 15, 15, 15, 20, 22, 22, 22, 21, 19, 18, 17, 16, 16, 15, 15, 14, 14,
+        14, 14, 20, 22, 22, 22, 21, 19, 18, 17, 16, 16, 15, 15, 14, 14, 14, 14,
+        20, 21, 21, 22, 20, 19, 18, 17, 16, 16, 14, 14, 14, 14, 13, 14, 19, 20,
+        21, 21, 20, 19, 17, 17, 15, 15, 14, 14, 13, 13, 13, 13, 19, 20, 20, 21,
+        20, 19, 17, 17, 15, 15, 14, 14, 13, 13, 13, 13, 18, 20, 20, 20, 20, 18,
+        17, 16, 15, 15, 13, 13, 12, 12, 12, 12, 18, 20, 20, 20, 19, 18, 17, 16,
+        15, 14, 13, 13, 12, 12, 12, 12, 17, 19, 19, 20, 19, 18, 17, 16, 14, 14,
+        13, 13, 12, 12, 12, 12, 17, 18, 19, 19, 18, 17, 16, 16, 14, 14, 13, 13,
+        12, 12, 12, 12, 16, 18, 18, 19, 18, 17, 16, 15, 14, 14, 12, 12, 12, 11,
+        11, 11, 16, 18, 18, 19, 18, 17, 16, 15, 14, 14, 12, 12, 12, 11, 11, 11,
+        16, 17, 18, 18, 18, 17, 16, 15, 14, 14, 12, 12, 11, 11, 11, 11, 16, 17,
+        17, 18, 17, 17, 16, 15, 14, 13, 12, 12, 11, 11, 11, 11, 15, 17, 17, 18,
+        17, 16, 16, 15, 14, 13, 12, 12, 11, 11, 11, 11, 15, 17, 17, 18, 17, 16,
+        16, 14, 14, 13, 13, 12, 12, 11, 11, 11, 15, 17, 17, 17, 17, 16, 16, 14,
+        14, 13, 13, 12, 12, 11, 11, 10,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 64, 64, 63, 60, 58, 57, 52, 50, 47, 44, 43, 38, 37,
-        35, 32, 32, 29, 27, 26, 25, 25, 23, 23, 22, 21, 21, 20, 65, 64, 64, 63,
-        63, 63, 62, 62, 60, 59, 59, 55, 53, 50, 47, 46, 41, 40, 38, 35, 34, 31,
-        30, 28, 27, 27, 26, 25, 24, 23, 23, 22, 65, 64, 63, 63, 62, 62, 60, 59,
-        59, 57, 57, 53, 51, 49, 46, 45, 41, 40, 38, 35, 34, 32, 31, 29, 28, 28,
-        26, 25, 25, 24, 23, 22, 64, 63, 63, 62, 60, 60, 58, 57, 55, 54, 53, 51,
-        49, 48, 45, 44, 41, 40, 38, 36, 35, 32, 31, 29, 28, 28, 27, 26, 25, 25,
-        24, 24, 59, 59, 59, 60, 58, 57, 55, 53, 49, 46, 45, 43, 41, 40, 38, 38,
-        36, 35, 33, 32, 31, 29, 28, 27, 26, 26, 25, 24, 24, 23, 23, 23, 57, 58,
-        59, 59, 57, 56, 53, 51, 48, 44, 43, 41, 40, 38, 37, 36, 34, 33, 32, 31,
-        30, 28, 27, 26, 25, 25, 24, 24, 23, 22, 22, 20, 47, 48, 49, 50, 49, 49,
-        48, 46, 43, 39, 38, 35, 34, 33, 31, 31, 29, 28, 27, 26, 26, 24, 24, 23,
-        22, 22, 21, 21, 21, 20, 20, 21, 43, 45, 46, 47, 46, 46, 46, 44, 41, 37,
-        37, 34, 33, 31, 29, 29, 27, 27, 26, 25, 24, 23, 22, 22, 21, 21, 20, 21,
-        20, 20, 20, 17, 38, 40, 41, 41, 41, 41, 41, 40, 38, 35, 34, 32, 30, 29,
-        27, 27, 25, 24, 24, 23, 22, 21, 20, 20, 19, 19, 19, 18, 17, 17, 17, 19,
-        33, 34, 35, 36, 36, 36, 37, 35, 34, 32, 31, 29, 28, 26, 25, 25, 23, 22,
-        21, 20, 20, 19, 19, 18, 18, 17, 17, 17, 18, 18, 17, 15, 31, 33, 34, 34,
-        35, 35, 35, 34, 33, 31, 30, 28, 27, 26, 24, 24, 22, 22, 21, 20, 20, 18,
-        18, 17, 17, 17, 16, 16, 15, 15, 15, 17, 26, 27, 28, 28, 29, 29, 30, 29,
-        28, 26, 26, 24, 24, 23, 22, 21, 20, 19, 19, 18, 17, 16, 16, 15, 15, 15,
-        14, 14, 15, 16, 15, 13, 25, 26, 27, 27, 28, 28, 29, 28, 27, 26, 25, 24,
-        23, 22, 21, 21, 19, 19, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 14, 13,
-        13, 15, 23, 24, 25, 25, 26, 26, 27, 26, 25, 24, 24, 23, 22, 21, 21, 20,
-        19, 18, 17, 17, 16, 16, 15, 14, 14, 14, 14, 13, 13, 14, 13, 11, 22, 23,
-        23, 24, 24, 25, 25, 25, 24, 24, 22, 23, 21, 22, 19, 20, 18, 18, 17, 17,
-        16, 15, 15, 14, 15, 13, 14, 13, 13, 12, 12, 13, 21, 22, 22, 23, 23, 24,
-        23, 25, 24, 22, 23, 20, 22, 19, 21, 18, 20, 16, 18, 15, 17, 14, 16, 13,
-        15, 12, 14, 11, 13, 12, 13, 11,
+        32, 33, 33, 34, 33, 31, 29, 28, 25, 24, 21, 21, 21, 21, 21, 21, 20, 20,
+        20, 19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 15, 15, 15, 33, 33, 33, 32,
+        31, 28, 27, 26, 24, 24, 22, 22, 22, 23, 23, 22, 22, 22, 21, 20, 20, 20,
+        20, 19, 18, 18, 18, 17, 17, 17, 17, 17, 32, 31, 31, 31, 29, 28, 26, 25,
+        24, 24, 22, 22, 22, 22, 23, 22, 22, 22, 21, 21, 20, 20, 20, 19, 19, 18,
+        18, 18, 17, 17, 17, 17, 28, 27, 27, 26, 25, 24, 23, 22, 22, 22, 21, 21,
+        22, 22, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18,
+        18, 17, 26, 25, 25, 24, 24, 23, 22, 22, 21, 21, 20, 20, 21, 21, 21, 21,
+        21, 21, 20, 20, 20, 20, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17, 21, 22,
+        22, 22, 22, 22, 22, 22, 21, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 18, 18, 18, 17, 17, 17, 17, 17, 16, 16, 16, 21, 22, 22, 23, 22, 22,
+        22, 22, 21, 21, 19, 19, 19, 19, 18, 18, 18, 18, 18, 17, 17, 17, 17, 17,
+        16, 16, 16, 16, 16, 16, 16, 16, 21, 22, 22, 23, 23, 22, 23, 23, 21, 21,
+        19, 19, 18, 18, 18, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15,
+        15, 15, 14, 14, 20, 21, 21, 22, 22, 22, 22, 22, 21, 20, 19, 19, 18, 18,
+        17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+        20, 20, 21, 21, 21, 22, 22, 22, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16,
+        16, 15, 15, 15, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 18, 19, 19, 20,
+        20, 20, 20, 20, 20, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 13,
+        13, 13, 13, 12, 12, 12, 12, 12, 13, 13, 18, 19, 19, 20, 20, 20, 20, 20,
+        19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 13, 13, 13, 13, 12,
+        12, 12, 12, 12, 12, 12, 16, 17, 17, 18, 18, 18, 19, 19, 18, 18, 17, 17,
+        16, 16, 15, 15, 14, 14, 14, 13, 13, 12, 12, 12, 12, 12, 12, 11, 11, 11,
+        12, 12, 16, 17, 17, 18, 18, 18, 18, 19, 18, 18, 17, 17, 16, 16, 15, 15,
+        14, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 15, 16,
+        16, 17, 17, 17, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 14, 14, 13, 13,
+        13, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 15, 16, 16, 17, 17, 17,
+        17, 18, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 14, 13, 13, 12, 12, 12,
+        12, 11, 11, 11, 11, 11, 11, 10,
         /* Size 4x16 */
-        65, 57, 33, 23, 64, 59, 35, 25, 63, 57, 36, 26, 62, 53, 37, 27, 60, 48,
-        34, 25, 59, 43, 31, 24, 53, 40, 28, 22, 47, 37, 25, 21, 41, 34, 23, 19,
-        38, 32, 21, 17, 34, 30, 20, 16, 30, 27, 19, 15, 27, 25, 18, 14, 26, 24,
-        17, 14, 24, 23, 18, 13, 23, 22, 17, 13,
+        33, 21, 20, 16, 33, 22, 21, 17, 31, 22, 21, 18, 27, 22, 22, 18, 24, 21,
+        20, 18, 22, 19, 19, 17, 22, 19, 18, 16, 23, 19, 17, 15, 22, 19, 16, 14,
+        21, 19, 16, 14, 20, 19, 15, 13, 20, 18, 14, 12, 18, 17, 14, 12, 18, 17,
+        14, 11, 17, 17, 13, 11, 17, 16, 13, 11,
         /* Size 16x4 */
-        65, 64, 63, 62, 60, 59, 53, 47, 41, 38, 34, 30, 27, 26, 24, 23, 57, 59,
-        57, 53, 48, 43, 40, 37, 34, 32, 30, 27, 25, 24, 23, 22, 33, 35, 36, 37,
-        34, 31, 28, 25, 23, 21, 20, 19, 18, 17, 18, 17, 23, 25, 26, 27, 25, 24,
-        22, 21, 19, 17, 16, 15, 14, 14, 13, 13,
+        33, 33, 31, 27, 24, 22, 22, 23, 22, 21, 20, 20, 18, 18, 17, 17, 21, 22,
+        22, 22, 21, 19, 19, 19, 19, 19, 19, 18, 17, 17, 17, 16, 20, 21, 21, 22,
+        20, 19, 18, 17, 16, 16, 15, 14, 14, 14, 13, 13, 16, 17, 18, 18, 18, 17,
+        16, 15, 14, 14, 13, 12, 12, 11, 11, 11,
         /* Size 8x32 */
-        64, 65, 59, 47, 38, 31, 25, 22, 65, 64, 59, 48, 40, 33, 26, 23, 65, 63,
-        59, 49, 41, 34, 27, 23, 65, 63, 60, 50, 41, 34, 27, 24, 65, 62, 58, 49,
-        41, 35, 28, 24, 64, 62, 57, 49, 41, 35, 28, 25, 64, 60, 55, 48, 41, 35,
-        29, 25, 63, 59, 53, 46, 40, 34, 28, 25, 60, 59, 49, 43, 38, 33, 27, 24,
-        58, 57, 46, 39, 35, 31, 26, 24, 57, 57, 45, 38, 34, 30, 25, 22, 52, 53,
-        43, 35, 32, 28, 24, 23, 50, 51, 41, 34, 30, 27, 23, 21, 47, 49, 40, 33,
-        29, 26, 22, 22, 44, 46, 38, 31, 27, 24, 21, 19, 43, 45, 38, 31, 27, 24,
-        21, 20, 38, 41, 36, 29, 25, 22, 19, 18, 37, 40, 35, 28, 24, 22, 19, 18,
-        35, 38, 33, 27, 24, 21, 18, 17, 32, 35, 32, 26, 23, 20, 17, 17, 32, 34,
-        31, 26, 22, 20, 17, 16, 29, 32, 29, 24, 21, 18, 16, 15, 27, 31, 28, 24,
-        20, 18, 16, 15, 26, 29, 27, 23, 20, 17, 15, 14, 25, 28, 26, 22, 19, 17,
-        15, 15, 25, 28, 26, 22, 19, 17, 15, 13, 23, 26, 25, 21, 19, 16, 14, 14,
-        23, 25, 24, 21, 18, 16, 14, 13, 22, 25, 24, 21, 17, 15, 14, 13, 21, 24,
-        23, 20, 17, 15, 13, 12, 21, 23, 23, 20, 17, 15, 13, 12, 20, 22, 23, 21,
-        19, 17, 15, 13,
+        32, 32, 26, 21, 20, 18, 16, 15, 33, 31, 25, 22, 21, 19, 17, 16, 33, 31,
+        25, 22, 21, 19, 17, 16, 34, 31, 24, 23, 22, 20, 18, 17, 33, 29, 24, 22,
+        22, 20, 18, 17, 31, 28, 23, 22, 22, 20, 18, 17, 29, 26, 22, 22, 22, 20,
+        19, 18, 28, 25, 22, 22, 22, 20, 19, 18, 25, 24, 21, 21, 21, 20, 18, 17,
+        24, 24, 21, 21, 20, 19, 18, 17, 21, 22, 20, 19, 19, 18, 17, 17, 21, 22,
+        20, 19, 19, 18, 17, 16, 21, 22, 21, 19, 18, 17, 16, 16, 21, 22, 21, 19,
+        18, 17, 16, 16, 21, 23, 21, 18, 17, 16, 15, 15, 21, 22, 21, 18, 17, 16,
+        15, 15, 20, 22, 21, 18, 16, 15, 14, 14, 20, 22, 21, 18, 16, 15, 14, 14,
+        20, 21, 20, 18, 16, 14, 14, 13, 19, 21, 20, 17, 15, 14, 13, 13, 19, 20,
+        20, 17, 15, 14, 13, 13, 18, 20, 20, 17, 15, 13, 12, 12, 18, 20, 19, 17,
+        15, 13, 12, 12, 17, 19, 19, 17, 14, 13, 12, 12, 17, 19, 18, 16, 14, 13,
+        12, 12, 16, 18, 18, 16, 14, 12, 12, 11, 16, 18, 18, 16, 14, 12, 12, 11,
+        16, 18, 18, 16, 14, 12, 11, 11, 16, 17, 17, 16, 14, 12, 11, 11, 15, 17,
+        17, 16, 14, 12, 11, 11, 15, 17, 17, 16, 14, 13, 12, 11, 15, 17, 17, 16,
+        14, 13, 12, 11,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 64, 64, 63, 60, 58, 57, 52, 50, 47, 44, 43, 38, 37,
-        35, 32, 32, 29, 27, 26, 25, 25, 23, 23, 22, 21, 21, 20, 65, 64, 63, 63,
-        62, 62, 60, 59, 59, 57, 57, 53, 51, 49, 46, 45, 41, 40, 38, 35, 34, 32,
-        31, 29, 28, 28, 26, 25, 25, 24, 23, 22, 59, 59, 59, 60, 58, 57, 55, 53,
-        49, 46, 45, 43, 41, 40, 38, 38, 36, 35, 33, 32, 31, 29, 28, 27, 26, 26,
-        25, 24, 24, 23, 23, 23, 47, 48, 49, 50, 49, 49, 48, 46, 43, 39, 38, 35,
-        34, 33, 31, 31, 29, 28, 27, 26, 26, 24, 24, 23, 22, 22, 21, 21, 21, 20,
-        20, 21, 38, 40, 41, 41, 41, 41, 41, 40, 38, 35, 34, 32, 30, 29, 27, 27,
-        25, 24, 24, 23, 22, 21, 20, 20, 19, 19, 19, 18, 17, 17, 17, 19, 31, 33,
-        34, 34, 35, 35, 35, 34, 33, 31, 30, 28, 27, 26, 24, 24, 22, 22, 21, 20,
-        20, 18, 18, 17, 17, 17, 16, 16, 15, 15, 15, 17, 25, 26, 27, 27, 28, 28,
-        29, 28, 27, 26, 25, 24, 23, 22, 21, 21, 19, 19, 18, 17, 17, 16, 16, 15,
-        15, 15, 14, 14, 14, 13, 13, 15, 22, 23, 23, 24, 24, 25, 25, 25, 24, 24,
-        22, 23, 21, 22, 19, 20, 18, 18, 17, 17, 16, 15, 15, 14, 15, 13, 14, 13,
-        13, 12, 12, 13 },
-      { /* Chroma */
-#if CONFIG_CB4X4
+        32, 33, 33, 34, 33, 31, 29, 28, 25, 24, 21, 21, 21, 21, 21, 21, 20, 20,
+        20, 19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 15, 15, 15, 32, 31, 31, 31,
+        29, 28, 26, 25, 24, 24, 22, 22, 22, 22, 23, 22, 22, 22, 21, 21, 20, 20,
+        20, 19, 19, 18, 18, 18, 17, 17, 17, 17, 26, 25, 25, 24, 24, 23, 22, 22,
+        21, 21, 20, 20, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 19, 19, 18, 18,
+        18, 18, 17, 17, 17, 17, 21, 22, 22, 23, 22, 22, 22, 22, 21, 21, 19, 19,
+        19, 19, 18, 18, 18, 18, 18, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16,
+        16, 16, 20, 21, 21, 22, 22, 22, 22, 22, 21, 20, 19, 19, 18, 18, 17, 17,
+        16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 18, 19,
+        19, 20, 20, 20, 20, 20, 20, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14,
+        14, 13, 13, 13, 13, 12, 12, 12, 12, 12, 13, 13, 16, 17, 17, 18, 18, 18,
+        19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 13, 13, 12, 12, 12,
+        12, 12, 12, 11, 11, 11, 12, 12, 15, 16, 16, 17, 17, 17, 18, 18, 17, 17,
+        17, 16, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11,
+        11, 11, 11, 11 },
+  },
+  {
+      { /* Luma */
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        43, 37, 37, 23,
+        29, 18, 18, 10,
 #endif
         /* Size 4x4 */
-        64, 45, 40, 33, 45, 38, 34, 31, 40, 34, 27, 25, 33, 31, 25, 21,
+        32, 30, 21, 14, 30, 21, 17, 13, 21, 17, 12, 10, 14, 13, 10, 8,
         /* Size 8x8 */
-        65, 59, 44, 44, 41, 36, 33, 31, 59, 53, 44, 45, 43, 38, 36, 33, 44, 44,
-        39, 39, 38, 35, 34, 33, 44, 45, 39, 35, 33, 31, 30, 30, 41, 43, 38, 33,
-        30, 28, 27, 27, 36, 38, 35, 31, 28, 25, 24, 23, 33, 36, 34, 30, 27, 24,
-        22, 20, 31, 33, 33, 30, 27, 23, 20, 20,
+        32, 32, 30, 27, 22, 18, 15, 13, 32, 31, 29, 26, 23, 19, 16, 14, 30, 29,
+        26, 23, 20, 18, 15, 13, 27, 26, 23, 19, 17, 15, 13, 12, 22, 23, 20, 17,
+        14, 13, 11, 10, 18, 19, 18, 15, 13, 11, 10, 9, 15, 16, 15, 13, 11, 10,
+        9, 8, 13, 14, 13, 12, 10, 9, 8, 7,
         /* Size 16x16 */
-        64, 66, 62, 56, 49, 42, 42, 41, 39, 38, 36, 33, 32, 31, 29, 28, 66, 65,
-        60, 53, 48, 44, 44, 43, 42, 40, 38, 36, 34, 33, 32, 31, 62, 60, 55, 48,
-        46, 44, 45, 44, 43, 41, 40, 37, 36, 34, 33, 32, 56, 53, 48, 43, 43, 43,
-        45, 45, 44, 42, 41, 39, 37, 36, 35, 33, 49, 48, 46, 43, 42, 41, 41, 41,
-        41, 39, 38, 37, 35, 34, 33, 32, 42, 44, 44, 43, 41, 39, 38, 38, 38, 37,
-        36, 34, 33, 33, 31, 31, 42, 44, 45, 45, 41, 38, 37, 36, 35, 34, 33, 32,
-        31, 31, 30, 29, 41, 43, 44, 45, 41, 38, 36, 34, 33, 32, 31, 30, 29, 28,
-        29, 27, 39, 42, 43, 44, 41, 38, 35, 33, 31, 30, 29, 28, 27, 27, 28, 26,
-        38, 40, 41, 42, 39, 37, 34, 32, 30, 29, 28, 27, 26, 25, 26, 24, 36, 38,
-        40, 41, 38, 36, 33, 31, 29, 28, 27, 26, 25, 24, 25, 23, 33, 36, 37, 39,
-        37, 34, 32, 30, 28, 27, 26, 24, 23, 23, 23, 22, 32, 34, 36, 37, 35, 33,
-        31, 29, 27, 26, 25, 23, 23, 22, 21, 21, 31, 33, 34, 36, 34, 33, 31, 28,
-        27, 25, 24, 23, 22, 21, 21, 19, 29, 32, 33, 35, 33, 31, 30, 29, 28, 26,
-        25, 23, 21, 21, 20, 20, 28, 31, 32, 33, 32, 31, 29, 27, 26, 24, 23, 22,
-        21, 19, 20, 19,
+        32, 33, 33, 33, 32, 30, 28, 26, 23, 21, 19, 17, 16, 14, 13, 12, 33, 32,
+        32, 32, 32, 30, 29, 27, 24, 22, 20, 18, 17, 15, 13, 13, 33, 32, 32, 32,
+        32, 31, 30, 28, 25, 23, 21, 19, 17, 16, 14, 14, 33, 32, 32, 31, 30, 29,
+        28, 26, 24, 23, 20, 19, 17, 16, 14, 14, 32, 32, 32, 30, 29, 28, 27, 26,
+        24, 22, 21, 19, 18, 16, 15, 14, 30, 30, 31, 29, 28, 26, 24, 23, 22, 20,
+        19, 18, 16, 15, 14, 13, 28, 29, 30, 28, 27, 24, 21, 20, 19, 18, 17, 16,
+        15, 14, 13, 13, 26, 27, 28, 26, 26, 23, 20, 19, 18, 17, 16, 15, 14, 13,
+        12, 12, 23, 24, 25, 24, 24, 22, 19, 18, 16, 15, 14, 14, 13, 12, 11, 11,
+        21, 22, 23, 23, 22, 20, 18, 17, 15, 14, 13, 13, 12, 11, 11, 10, 19, 20,
+        21, 20, 21, 19, 17, 16, 14, 13, 12, 12, 11, 11, 10, 10, 17, 18, 19, 19,
+        19, 18, 16, 15, 14, 13, 12, 11, 10, 10, 9, 9, 16, 17, 17, 17, 18, 16,
+        15, 14, 13, 12, 11, 10, 10, 9, 9, 8, 14, 15, 16, 16, 16, 15, 14, 13, 12,
+        11, 11, 10, 9, 9, 8, 8, 13, 13, 14, 14, 15, 14, 13, 12, 11, 11, 10, 9,
+        9, 8, 8, 7, 12, 13, 14, 14, 14, 13, 13, 12, 11, 10, 10, 9, 8, 8, 7, 7,
         /* Size 32x32 */
-        64, 66, 66, 67, 62, 61, 56, 53, 49, 43, 42, 42, 42, 42, 41, 41, 39, 39,
-        38, 36, 36, 34, 33, 32, 32, 32, 31, 30, 29, 29, 28, 28, 66, 65, 65, 66,
-        60, 59, 53, 51, 48, 44, 43, 44, 44, 44, 43, 42, 41, 41, 39, 38, 38, 36,
-        35, 34, 33, 33, 32, 32, 31, 31, 30, 30, 66, 65, 65, 65, 60, 59, 53, 51,
-        48, 45, 44, 44, 44, 45, 43, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 34,
-        33, 32, 32, 31, 31, 30, 67, 66, 65, 64, 59, 58, 51, 50, 48, 45, 44, 45,
-        45, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 35, 34, 33, 33, 32,
-        32, 32, 62, 60, 60, 59, 55, 53, 48, 47, 46, 44, 44, 45, 45, 45, 44, 44,
-        43, 42, 41, 40, 40, 38, 37, 36, 36, 36, 34, 34, 33, 33, 32, 31, 61, 59,
-        59, 58, 53, 53, 47, 47, 46, 44, 43, 44, 45, 45, 44, 44, 43, 43, 41, 40,
-        40, 38, 38, 36, 36, 36, 35, 34, 34, 33, 33, 33, 56, 53, 53, 51, 48, 47,
-        43, 43, 43, 43, 43, 44, 45, 45, 45, 45, 44, 43, 42, 41, 41, 39, 39, 38,
-        37, 37, 36, 35, 35, 34, 33, 32, 53, 51, 51, 50, 47, 47, 43, 43, 43, 42,
-        42, 43, 43, 44, 43, 43, 43, 42, 41, 40, 40, 38, 38, 37, 36, 36, 35, 35,
-        35, 34, 34, 34, 49, 48, 48, 48, 46, 46, 43, 43, 42, 41, 41, 41, 41, 42,
-        41, 41, 41, 40, 39, 39, 38, 37, 37, 36, 35, 35, 34, 34, 33, 33, 32, 33,
-        43, 44, 45, 45, 44, 44, 43, 42, 41, 39, 39, 39, 39, 39, 39, 39, 38, 38,
-        37, 37, 37, 35, 35, 34, 34, 34, 33, 33, 33, 33, 32, 30, 42, 43, 44, 44,
-        44, 43, 43, 42, 41, 39, 39, 39, 38, 38, 38, 38, 38, 37, 37, 36, 36, 35,
-        34, 34, 33, 33, 33, 32, 31, 31, 31, 32, 42, 44, 44, 45, 45, 44, 44, 43,
-        41, 39, 39, 38, 37, 37, 36, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 32,
-        31, 31, 31, 32, 31, 29, 42, 44, 44, 45, 45, 45, 45, 43, 41, 39, 38, 37,
-        37, 36, 36, 35, 35, 34, 34, 34, 33, 33, 32, 32, 31, 31, 31, 31, 30, 29,
-        29, 31, 42, 44, 45, 46, 45, 45, 45, 44, 42, 39, 38, 37, 36, 35, 34, 34,
-        33, 33, 33, 32, 32, 31, 31, 30, 30, 30, 29, 29, 29, 30, 30, 27, 41, 43,
-        43, 45, 44, 44, 45, 43, 41, 39, 38, 36, 36, 34, 34, 34, 33, 32, 32, 31,
-        31, 30, 30, 29, 29, 29, 28, 29, 29, 27, 27, 29, 41, 42, 43, 44, 44, 44,
-        45, 43, 41, 39, 38, 36, 35, 34, 34, 33, 32, 32, 32, 31, 31, 30, 29, 29,
-        29, 29, 28, 27, 27, 29, 28, 26, 39, 41, 42, 43, 43, 43, 44, 43, 41, 38,
-        38, 36, 35, 33, 33, 32, 31, 30, 30, 29, 29, 28, 28, 27, 27, 27, 27, 27,
-        28, 26, 26, 28, 39, 41, 41, 42, 42, 43, 43, 42, 40, 38, 37, 35, 34, 33,
-        32, 32, 30, 30, 29, 29, 29, 28, 27, 27, 27, 27, 26, 26, 25, 27, 27, 25,
-        38, 39, 40, 41, 41, 41, 42, 41, 39, 37, 37, 35, 34, 33, 32, 32, 30, 29,
-        29, 28, 28, 27, 27, 26, 26, 26, 25, 25, 26, 25, 24, 27, 36, 38, 39, 40,
-        40, 40, 41, 40, 39, 37, 36, 34, 34, 32, 31, 31, 29, 29, 28, 27, 27, 26,
-        26, 25, 25, 25, 25, 25, 24, 25, 26, 23, 36, 38, 38, 39, 40, 40, 41, 40,
-        38, 37, 36, 34, 33, 32, 31, 31, 29, 29, 28, 27, 27, 26, 26, 25, 25, 25,
-        24, 23, 25, 24, 23, 25, 34, 36, 37, 38, 38, 38, 39, 38, 37, 35, 35, 33,
-        33, 31, 30, 30, 28, 28, 27, 26, 26, 25, 25, 24, 24, 24, 23, 24, 23, 23,
-        25, 22, 33, 35, 36, 37, 37, 38, 39, 38, 37, 35, 34, 33, 32, 31, 30, 29,
-        28, 27, 27, 26, 26, 25, 24, 24, 23, 23, 23, 23, 23, 23, 22, 24, 32, 34,
-        35, 36, 36, 36, 38, 37, 36, 34, 34, 32, 32, 30, 29, 29, 27, 27, 26, 25,
-        25, 24, 24, 23, 23, 23, 22, 22, 23, 22, 23, 21, 32, 33, 34, 35, 36, 36,
-        37, 36, 35, 34, 33, 32, 31, 30, 29, 29, 27, 27, 26, 25, 25, 24, 23, 23,
-        23, 22, 22, 22, 21, 23, 21, 23, 32, 33, 34, 35, 36, 36, 37, 36, 35, 34,
-        33, 32, 31, 30, 29, 29, 27, 27, 26, 25, 25, 24, 23, 23, 22, 22, 22, 22,
-        22, 20, 22, 20, 31, 32, 33, 34, 34, 35, 36, 35, 34, 33, 33, 31, 31, 29,
-        28, 28, 27, 26, 25, 25, 24, 23, 23, 22, 22, 22, 21, 22, 21, 21, 19, 22,
-        30, 32, 32, 33, 34, 34, 35, 35, 34, 33, 32, 31, 31, 29, 29, 27, 27, 26,
-        25, 25, 23, 24, 23, 22, 22, 22, 22, 21, 21, 21, 21, 19, 29, 31, 32, 33,
-        33, 34, 35, 35, 33, 33, 31, 31, 30, 29, 29, 27, 28, 25, 26, 24, 25, 23,
-        23, 23, 21, 22, 21, 21, 20, 21, 20, 21, 29, 31, 31, 32, 33, 33, 34, 34,
-        33, 33, 31, 32, 29, 30, 27, 29, 26, 27, 25, 25, 24, 23, 23, 22, 23, 20,
-        21, 21, 21, 20, 21, 20, 28, 30, 31, 32, 32, 33, 33, 34, 32, 32, 31, 31,
-        29, 30, 27, 28, 26, 27, 24, 26, 23, 25, 22, 23, 21, 22, 19, 21, 20, 21,
-        19, 21, 28, 30, 30, 32, 31, 33, 32, 34, 33, 30, 32, 29, 31, 27, 29, 26,
-        28, 25, 27, 23, 25, 22, 24, 21, 23, 20, 22, 19, 21, 20, 21, 19,
+        32, 33, 33, 33, 33, 33, 33, 32, 32, 30, 30, 28, 28, 26, 26, 23, 23, 21,
+        21, 19, 19, 17, 17, 16, 16, 14, 14, 13, 13, 12, 12, 12, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 30, 30, 29, 29, 27, 27, 24, 24, 22, 22, 20, 20, 18,
+        18, 17, 17, 15, 15, 13, 13, 13, 13, 12, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 30, 30, 29, 29, 27, 27, 24, 24, 22, 22, 20, 20, 18, 18, 17, 17, 15,
+        15, 13, 13, 13, 13, 12, 33, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30,
+        30, 28, 28, 25, 25, 23, 23, 21, 21, 19, 19, 17, 17, 16, 16, 14, 14, 14,
+        14, 13, 33, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 28, 28, 25,
+        25, 23, 23, 21, 21, 19, 19, 17, 17, 16, 16, 14, 14, 14, 14, 13, 33, 32,
+        32, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 26, 26, 24, 24, 23, 23, 20,
+        20, 19, 19, 17, 17, 16, 16, 14, 14, 14, 14, 13, 33, 32, 32, 32, 32, 31,
+        31, 30, 30, 29, 29, 28, 28, 26, 26, 24, 24, 23, 23, 20, 20, 19, 19, 17,
+        17, 16, 16, 14, 14, 14, 14, 13, 32, 32, 32, 32, 32, 30, 30, 29, 29, 28,
+        28, 27, 27, 26, 26, 24, 24, 22, 22, 21, 21, 19, 19, 18, 18, 16, 16, 15,
+        15, 14, 14, 14, 32, 32, 32, 32, 32, 30, 30, 29, 29, 28, 28, 27, 27, 26,
+        26, 24, 24, 22, 22, 21, 21, 19, 19, 18, 18, 16, 16, 15, 15, 14, 14, 14,
+        30, 30, 30, 31, 31, 29, 29, 28, 28, 26, 26, 24, 24, 23, 23, 22, 22, 20,
+        20, 19, 19, 18, 18, 16, 16, 15, 15, 14, 14, 13, 13, 13, 30, 30, 30, 31,
+        31, 29, 29, 28, 28, 26, 26, 24, 24, 23, 23, 22, 22, 20, 20, 19, 19, 18,
+        18, 16, 16, 15, 15, 14, 14, 13, 13, 13, 28, 29, 29, 30, 30, 28, 28, 27,
+        27, 24, 24, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14,
+        14, 13, 13, 13, 13, 12, 28, 29, 29, 30, 30, 28, 28, 27, 27, 24, 24, 21,
+        21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13,
+        13, 12, 26, 27, 27, 28, 28, 26, 26, 26, 26, 23, 23, 20, 20, 19, 19, 18,
+        18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 12, 11, 26, 27,
+        27, 28, 28, 26, 26, 26, 26, 23, 23, 20, 20, 19, 19, 18, 18, 17, 17, 16,
+        16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 12, 11, 23, 24, 24, 25, 25, 24,
+        24, 24, 24, 22, 22, 19, 19, 18, 18, 16, 16, 15, 15, 14, 14, 14, 14, 13,
+        13, 12, 12, 11, 11, 11, 11, 11, 23, 24, 24, 25, 25, 24, 24, 24, 24, 22,
+        22, 19, 19, 18, 18, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 12, 12, 11,
+        11, 11, 11, 11, 21, 22, 22, 23, 23, 23, 23, 22, 22, 20, 20, 18, 18, 17,
+        17, 15, 15, 14, 14, 13, 13, 13, 13, 12, 12, 11, 11, 11, 11, 10, 10, 10,
+        21, 22, 22, 23, 23, 23, 23, 22, 22, 20, 20, 18, 18, 17, 17, 15, 15, 14,
+        14, 13, 13, 13, 13, 12, 12, 11, 11, 11, 11, 10, 10, 10, 19, 20, 20, 21,
+        21, 20, 20, 21, 21, 19, 19, 17, 17, 16, 16, 14, 14, 13, 13, 12, 12, 12,
+        12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 19, 20, 20, 21, 21, 20, 20, 21,
+        21, 19, 19, 17, 17, 16, 16, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11,
+        11, 10, 10, 10, 10, 9, 17, 18, 18, 19, 19, 19, 19, 19, 19, 18, 18, 16,
+        16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9,
+        9, 17, 18, 18, 19, 19, 19, 19, 19, 19, 18, 18, 16, 16, 15, 15, 14, 14,
+        13, 13, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 9, 16, 17, 17, 17,
+        17, 17, 17, 18, 18, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10,
+        10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 16, 17, 17, 17, 17, 17, 17, 18, 18, 16,
+        16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9,
+        8, 8, 8, 14, 15, 15, 16, 16, 16, 16, 16, 16, 15, 15, 14, 14, 13, 13, 12,
+        12, 11, 11, 11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 8, 14, 15, 15, 16,
+        16, 16, 16, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 11, 11, 10,
+        10, 9, 9, 9, 9, 8, 8, 8, 8, 8, 13, 13, 13, 14, 14, 14, 14, 15, 15, 14,
+        14, 13, 13, 12, 12, 11, 11, 11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7,
+        7, 7, 13, 13, 13, 14, 14, 14, 14, 15, 15, 14, 14, 13, 13, 12, 12, 11,
+        11, 11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 12, 13, 13, 14, 14,
+        14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 8,
+        8, 8, 8, 7, 7, 7, 7, 7, 12, 13, 13, 14, 14, 14, 14, 14, 14, 13, 13, 13,
+        13, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 12,
+        12, 12, 13, 13, 13, 13, 14, 14, 13, 13, 12, 12, 11, 11, 11, 11, 10, 10,
+        9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7,
         /* Size 4x8 */
-        65, 44, 38, 32, 57, 44, 41, 34, 45, 39, 37, 33, 45, 38, 32, 29, 42, 37,
-        29, 26, 38, 35, 26, 24, 35, 33, 25, 22, 32, 31, 26, 21,
+        32, 29, 20, 14, 32, 28, 20, 14, 30, 24, 19, 14, 28, 20, 16, 12, 23, 18,
+        13, 11, 19, 16, 12, 9, 16, 14, 11, 8, 14, 13, 10, 8,
         /* Size 8x4 */
-        65, 57, 45, 45, 42, 38, 35, 32, 44, 44, 39, 38, 37, 35, 33, 31, 38, 41,
-        37, 32, 29, 26, 25, 26, 32, 34, 33, 29, 26, 24, 22, 21,
+        32, 32, 30, 28, 23, 19, 16, 14, 29, 28, 24, 20, 18, 16, 14, 13, 20, 20,
+        19, 16, 13, 12, 11, 10, 14, 14, 14, 12, 11, 9, 8, 8,
         /* Size 8x16 */
-        64, 62, 45, 42, 39, 36, 32, 29, 66, 59, 46, 44, 42, 38, 34, 31, 62, 55,
-        45, 45, 43, 40, 36, 33, 55, 48, 43, 45, 44, 41, 37, 34, 49, 46, 41, 41,
-        41, 38, 35, 33, 42, 44, 39, 38, 38, 36, 33, 31, 42, 45, 40, 36, 35, 33,
-        31, 29, 41, 44, 39, 34, 32, 31, 29, 27, 39, 43, 39, 34, 31, 29, 27, 26,
-        38, 41, 38, 33, 30, 28, 26, 25, 36, 40, 37, 32, 29, 27, 25, 24, 34, 37,
-        35, 31, 28, 26, 23, 23, 32, 36, 34, 30, 27, 25, 23, 22, 31, 34, 33, 29,
-        27, 24, 22, 22, 30, 33, 33, 29, 26, 23, 21, 21, 29, 32, 32, 29, 26, 23,
-        21, 20,
+        32, 33, 32, 28, 23, 19, 16, 13, 33, 32, 32, 29, 24, 20, 17, 14, 33, 32,
+        31, 30, 25, 21, 17, 14, 32, 32, 30, 28, 24, 20, 17, 14, 32, 31, 29, 27,
+        24, 21, 18, 15, 30, 30, 28, 24, 21, 19, 16, 14, 28, 30, 27, 21, 19, 17,
+        15, 13, 26, 28, 26, 20, 18, 16, 14, 12, 23, 25, 24, 19, 16, 14, 13, 11,
+        21, 23, 22, 18, 15, 13, 12, 11, 19, 21, 20, 17, 14, 12, 11, 10, 18, 19,
+        19, 16, 14, 12, 10, 9, 16, 17, 18, 15, 13, 11, 10, 9, 14, 16, 16, 14,
+        12, 11, 9, 8, 13, 14, 15, 13, 11, 10, 9, 8, 12, 14, 14, 13, 11, 10, 8,
+        8,
         /* Size 16x8 */
-        64, 66, 62, 55, 49, 42, 42, 41, 39, 38, 36, 34, 32, 31, 30, 29, 62, 59,
-        55, 48, 46, 44, 45, 44, 43, 41, 40, 37, 36, 34, 33, 32, 45, 46, 45, 43,
-        41, 39, 40, 39, 39, 38, 37, 35, 34, 33, 33, 32, 42, 44, 45, 45, 41, 38,
-        36, 34, 34, 33, 32, 31, 30, 29, 29, 29, 39, 42, 43, 44, 41, 38, 35, 32,
-        31, 30, 29, 28, 27, 27, 26, 26, 36, 38, 40, 41, 38, 36, 33, 31, 29, 28,
-        27, 26, 25, 24, 23, 23, 32, 34, 36, 37, 35, 33, 31, 29, 27, 26, 25, 23,
-        23, 22, 21, 21, 29, 31, 33, 34, 33, 31, 29, 27, 26, 25, 24, 23, 22, 22,
-        21, 20,
+        32, 33, 33, 32, 32, 30, 28, 26, 23, 21, 19, 18, 16, 14, 13, 12, 33, 32,
+        32, 32, 31, 30, 30, 28, 25, 23, 21, 19, 17, 16, 14, 14, 32, 32, 31, 30,
+        29, 28, 27, 26, 24, 22, 20, 19, 18, 16, 15, 14, 28, 29, 30, 28, 27, 24,
+        21, 20, 19, 18, 17, 16, 15, 14, 13, 13, 23, 24, 25, 24, 24, 21, 19, 18,
+        16, 15, 14, 14, 13, 12, 11, 11, 19, 20, 21, 20, 21, 19, 17, 16, 14, 13,
+        12, 12, 11, 11, 10, 10, 16, 17, 17, 17, 18, 16, 15, 14, 13, 12, 11, 10,
+        10, 9, 9, 8, 13, 14, 14, 14, 15, 14, 13, 12, 11, 11, 10, 9, 9, 8, 8, 8,
         /* Size 16x32 */
-        64, 66, 62, 55, 45, 43, 42, 41, 39, 37, 36, 32, 32, 30, 29, 28, 65, 65,
-        60, 53, 46, 44, 44, 42, 41, 38, 38, 34, 33, 32, 31, 30, 66, 64, 59, 53,
-        46, 44, 44, 43, 42, 39, 38, 35, 34, 33, 31, 30, 67, 64, 59, 51, 46, 45,
-        45, 44, 43, 40, 39, 36, 35, 34, 33, 32, 62, 59, 55, 48, 45, 44, 45, 44,
-        43, 41, 40, 36, 36, 34, 33, 32, 61, 57, 53, 48, 45, 44, 45, 44, 43, 41,
-        40, 37, 36, 34, 33, 33, 55, 51, 48, 44, 43, 43, 45, 45, 44, 41, 41, 38,
-        37, 36, 34, 33, 53, 50, 47, 43, 42, 42, 44, 43, 42, 41, 40, 37, 36, 35,
-        35, 34, 49, 48, 46, 43, 41, 41, 41, 41, 41, 39, 38, 36, 35, 34, 33, 34,
-        43, 45, 44, 43, 40, 39, 39, 39, 38, 37, 37, 34, 34, 33, 33, 31, 42, 44,
-        44, 43, 39, 39, 38, 38, 38, 36, 36, 34, 33, 32, 31, 32, 42, 45, 44, 44,
-        40, 39, 37, 36, 36, 34, 34, 32, 32, 31, 32, 29, 42, 45, 45, 44, 40, 39,
-        36, 36, 35, 34, 33, 32, 31, 31, 29, 31, 42, 45, 45, 45, 40, 38, 35, 34,
-        33, 32, 32, 30, 30, 29, 30, 28, 41, 44, 44, 44, 39, 38, 34, 34, 32, 31,
-        31, 29, 29, 29, 27, 30, 41, 44, 44, 44, 39, 38, 34, 33, 32, 31, 31, 29,
-        29, 28, 29, 26, 39, 43, 43, 43, 39, 38, 34, 32, 31, 29, 29, 27, 27, 27,
-        26, 28, 39, 42, 42, 43, 38, 37, 33, 32, 30, 29, 28, 27, 27, 26, 27, 25,
-        38, 41, 41, 42, 38, 37, 33, 32, 30, 28, 28, 26, 26, 25, 25, 27, 36, 40,
-        40, 41, 37, 36, 32, 31, 29, 27, 27, 25, 25, 25, 25, 23, 36, 39, 40, 41,
-        37, 36, 32, 31, 29, 27, 27, 25, 25, 24, 24, 26, 34, 38, 38, 39, 36, 35,
-        31, 30, 28, 26, 26, 24, 24, 24, 23, 22, 34, 37, 37, 38, 35, 34, 31, 30,
-        28, 26, 26, 24, 23, 23, 23, 25, 32, 36, 36, 37, 34, 34, 30, 29, 27, 25,
-        25, 23, 23, 22, 22, 21, 32, 35, 36, 37, 34, 33, 30, 29, 27, 25, 25, 23,
-        23, 22, 22, 23, 32, 35, 35, 37, 34, 33, 30, 29, 27, 25, 25, 23, 22, 22,
-        20, 20, 31, 34, 34, 36, 33, 33, 29, 28, 27, 25, 24, 22, 22, 22, 22, 22,
-        30, 33, 34, 35, 33, 32, 29, 29, 26, 25, 24, 22, 22, 21, 21, 19, 30, 33,
-        33, 34, 33, 32, 29, 29, 26, 26, 23, 23, 21, 21, 21, 21, 29, 32, 33, 34,
-        33, 31, 29, 29, 26, 26, 23, 24, 20, 21, 20, 20, 29, 32, 32, 34, 32, 31,
-        29, 28, 26, 26, 23, 23, 21, 21, 20, 21, 28, 31, 31, 34, 33, 29, 31, 26,
-        28, 23, 25, 21, 23, 19, 21, 19,
+        32, 33, 33, 32, 32, 28, 28, 23, 23, 19, 19, 16, 16, 13, 13, 12, 33, 32,
+        32, 32, 32, 29, 29, 24, 24, 20, 20, 17, 17, 14, 14, 12, 33, 32, 32, 32,
+        32, 29, 29, 24, 24, 20, 20, 17, 17, 14, 14, 12, 33, 32, 32, 31, 31, 30,
+        30, 25, 25, 21, 21, 17, 17, 14, 14, 13, 33, 32, 32, 31, 31, 30, 30, 25,
+        25, 21, 21, 17, 17, 14, 14, 13, 32, 32, 32, 30, 30, 28, 28, 24, 24, 20,
+        20, 17, 17, 14, 14, 13, 32, 32, 32, 30, 30, 28, 28, 24, 24, 20, 20, 17,
+        17, 14, 14, 13, 32, 31, 31, 29, 29, 27, 27, 24, 24, 21, 21, 18, 18, 15,
+        15, 14, 32, 31, 31, 29, 29, 27, 27, 24, 24, 21, 21, 18, 18, 15, 15, 14,
+        30, 30, 30, 28, 28, 24, 24, 21, 21, 19, 19, 16, 16, 14, 14, 13, 30, 30,
+        30, 28, 28, 24, 24, 21, 21, 19, 19, 16, 16, 14, 14, 13, 28, 30, 30, 27,
+        27, 21, 21, 19, 19, 17, 17, 15, 15, 13, 13, 12, 28, 30, 30, 27, 27, 21,
+        21, 19, 19, 17, 17, 15, 15, 13, 13, 12, 26, 28, 28, 26, 26, 20, 20, 18,
+        18, 16, 16, 14, 14, 12, 12, 12, 26, 28, 28, 26, 26, 20, 20, 18, 18, 16,
+        16, 14, 14, 12, 12, 12, 23, 25, 25, 24, 24, 19, 19, 16, 16, 14, 14, 13,
+        13, 11, 11, 11, 23, 25, 25, 24, 24, 19, 19, 16, 16, 14, 14, 13, 13, 11,
+        11, 11, 21, 23, 23, 22, 22, 18, 18, 15, 15, 13, 13, 12, 12, 11, 11, 10,
+        21, 23, 23, 22, 22, 18, 18, 15, 15, 13, 13, 12, 12, 11, 11, 10, 19, 21,
+        21, 20, 20, 17, 17, 14, 14, 12, 12, 11, 11, 10, 10, 9, 19, 21, 21, 20,
+        20, 17, 17, 14, 14, 12, 12, 11, 11, 10, 10, 9, 18, 19, 19, 19, 19, 16,
+        16, 14, 14, 12, 12, 10, 10, 9, 9, 9, 18, 19, 19, 19, 19, 16, 16, 14, 14,
+        12, 12, 10, 10, 9, 9, 9, 16, 17, 17, 18, 18, 15, 15, 13, 13, 11, 11, 10,
+        10, 9, 9, 8, 16, 17, 17, 18, 18, 15, 15, 13, 13, 11, 11, 10, 10, 9, 9,
+        8, 14, 16, 16, 16, 16, 14, 14, 12, 12, 11, 11, 9, 9, 8, 8, 8, 14, 16,
+        16, 16, 16, 14, 14, 12, 12, 11, 11, 9, 9, 8, 8, 8, 13, 14, 14, 15, 15,
+        13, 13, 11, 11, 10, 10, 9, 9, 8, 8, 7, 13, 14, 14, 15, 15, 13, 13, 11,
+        11, 10, 10, 9, 9, 8, 8, 7, 12, 14, 14, 14, 14, 13, 13, 11, 11, 10, 10,
+        8, 8, 8, 8, 7, 12, 14, 14, 14, 14, 13, 13, 11, 11, 10, 10, 8, 8, 8, 8,
+        7, 12, 13, 13, 13, 13, 12, 12, 11, 11, 9, 9, 8, 8, 7, 7, 7,
         /* Size 32x16 */
-        64, 65, 66, 67, 62, 61, 55, 53, 49, 43, 42, 42, 42, 42, 41, 41, 39, 39,
-        38, 36, 36, 34, 34, 32, 32, 32, 31, 30, 30, 29, 29, 28, 66, 65, 64, 64,
-        59, 57, 51, 50, 48, 45, 44, 45, 45, 45, 44, 44, 43, 42, 41, 40, 39, 38,
-        37, 36, 35, 35, 34, 33, 33, 32, 32, 31, 62, 60, 59, 59, 55, 53, 48, 47,
-        46, 44, 44, 44, 45, 45, 44, 44, 43, 42, 41, 40, 40, 38, 37, 36, 36, 35,
-        34, 34, 33, 33, 32, 31, 55, 53, 53, 51, 48, 48, 44, 43, 43, 43, 43, 44,
-        44, 45, 44, 44, 43, 43, 42, 41, 41, 39, 38, 37, 37, 37, 36, 35, 34, 34,
-        34, 34, 45, 46, 46, 46, 45, 45, 43, 42, 41, 40, 39, 40, 40, 40, 39, 39,
-        39, 38, 38, 37, 37, 36, 35, 34, 34, 34, 33, 33, 33, 33, 32, 33, 43, 44,
-        44, 45, 44, 44, 43, 42, 41, 39, 39, 39, 39, 38, 38, 38, 38, 37, 37, 36,
-        36, 35, 34, 34, 33, 33, 33, 32, 32, 31, 31, 29, 42, 44, 44, 45, 45, 45,
-        45, 44, 41, 39, 38, 37, 36, 35, 34, 34, 34, 33, 33, 32, 32, 31, 31, 30,
-        30, 30, 29, 29, 29, 29, 29, 31, 41, 42, 43, 44, 44, 44, 45, 43, 41, 39,
-        38, 36, 36, 34, 34, 33, 32, 32, 32, 31, 31, 30, 30, 29, 29, 29, 28, 29,
-        29, 29, 28, 26, 39, 41, 42, 43, 43, 43, 44, 42, 41, 38, 38, 36, 35, 33,
-        32, 32, 31, 30, 30, 29, 29, 28, 28, 27, 27, 27, 27, 26, 26, 26, 26, 28,
-        37, 38, 39, 40, 41, 41, 41, 41, 39, 37, 36, 34, 34, 32, 31, 31, 29, 29,
-        28, 27, 27, 26, 26, 25, 25, 25, 25, 25, 26, 26, 26, 23, 36, 38, 38, 39,
-        40, 40, 41, 40, 38, 37, 36, 34, 33, 32, 31, 31, 29, 28, 28, 27, 27, 26,
-        26, 25, 25, 25, 24, 24, 23, 23, 23, 25, 32, 34, 35, 36, 36, 37, 38, 37,
-        36, 34, 34, 32, 32, 30, 29, 29, 27, 27, 26, 25, 25, 24, 24, 23, 23, 23,
-        22, 22, 23, 24, 23, 21, 32, 33, 34, 35, 36, 36, 37, 36, 35, 34, 33, 32,
-        31, 30, 29, 29, 27, 27, 26, 25, 25, 24, 23, 23, 23, 22, 22, 22, 21, 20,
-        21, 23, 30, 32, 33, 34, 34, 34, 36, 35, 34, 33, 32, 31, 31, 29, 29, 28,
-        27, 26, 25, 25, 24, 24, 23, 22, 22, 22, 22, 21, 21, 21, 21, 19, 29, 31,
-        31, 33, 33, 33, 34, 35, 33, 33, 31, 32, 29, 30, 27, 29, 26, 27, 25, 25,
-        24, 23, 23, 22, 22, 20, 22, 21, 21, 20, 20, 21, 28, 30, 30, 32, 32, 33,
-        33, 34, 34, 31, 32, 29, 31, 28, 30, 26, 28, 25, 27, 23, 26, 22, 25, 21,
-        23, 20, 22, 19, 21, 20, 21, 19,
+        32, 33, 33, 33, 33, 32, 32, 32, 32, 30, 30, 28, 28, 26, 26, 23, 23, 21,
+        21, 19, 19, 18, 18, 16, 16, 14, 14, 13, 13, 12, 12, 12, 33, 32, 32, 32,
+        32, 32, 32, 31, 31, 30, 30, 30, 30, 28, 28, 25, 25, 23, 23, 21, 21, 19,
+        19, 17, 17, 16, 16, 14, 14, 14, 14, 13, 33, 32, 32, 32, 32, 32, 32, 31,
+        31, 30, 30, 30, 30, 28, 28, 25, 25, 23, 23, 21, 21, 19, 19, 17, 17, 16,
+        16, 14, 14, 14, 14, 13, 32, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27,
+        27, 26, 26, 24, 24, 22, 22, 20, 20, 19, 19, 18, 18, 16, 16, 15, 15, 14,
+        14, 13, 32, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 24,
+        24, 22, 22, 20, 20, 19, 19, 18, 18, 16, 16, 15, 15, 14, 14, 13, 28, 29,
+        29, 30, 30, 28, 28, 27, 27, 24, 24, 21, 21, 20, 20, 19, 19, 18, 18, 17,
+        17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 13, 12, 28, 29, 29, 30, 30, 28,
+        28, 27, 27, 24, 24, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15,
+        15, 14, 14, 13, 13, 13, 13, 12, 23, 24, 24, 25, 25, 24, 24, 24, 24, 21,
+        21, 19, 19, 18, 18, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 12, 12, 11,
+        11, 11, 11, 11, 23, 24, 24, 25, 25, 24, 24, 24, 24, 21, 21, 19, 19, 18,
+        18, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 12, 12, 11, 11, 11, 11, 11,
+        19, 20, 20, 21, 21, 20, 20, 21, 21, 19, 19, 17, 17, 16, 16, 14, 14, 13,
+        13, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 19, 20, 20, 21,
+        21, 20, 20, 21, 21, 19, 19, 17, 17, 16, 16, 14, 14, 13, 13, 12, 12, 12,
+        12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 16, 17, 17, 17, 17, 17, 17, 18,
+        18, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10, 10, 9,
+        9, 9, 9, 8, 8, 8, 16, 17, 17, 17, 17, 17, 17, 18, 18, 16, 16, 15, 15,
+        14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 13,
+        14, 14, 14, 14, 14, 14, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 11, 11,
+        10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 7, 13, 14, 14, 14, 14, 14, 14, 15,
+        15, 14, 14, 13, 13, 12, 12, 11, 11, 11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8,
+        8, 8, 8, 7, 12, 12, 12, 13, 13, 13, 13, 14, 14, 13, 13, 12, 12, 12, 12,
+        11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7,
         /* Size 4x16 */
-        66, 43, 37, 30, 64, 44, 39, 33, 59, 44, 41, 34, 51, 43, 41, 36, 48, 41,
-        39, 34, 44, 39, 36, 32, 45, 39, 34, 31, 44, 38, 31, 29, 43, 38, 29, 27,
-        41, 37, 28, 25, 39, 36, 27, 24, 37, 34, 26, 23, 35, 33, 25, 22, 34, 33,
-        25, 22, 33, 32, 26, 21, 32, 31, 26, 21,
+        33, 28, 19, 13, 32, 29, 20, 14, 32, 30, 21, 14, 32, 28, 20, 14, 31, 27,
+        21, 15, 30, 24, 19, 14, 30, 21, 17, 13, 28, 20, 16, 12, 25, 19, 14, 11,
+        23, 18, 13, 11, 21, 17, 12, 10, 19, 16, 12, 9, 17, 15, 11, 9, 16, 14,
+        11, 8, 14, 13, 10, 8, 14, 13, 10, 8,
         /* Size 16x4 */
-        66, 64, 59, 51, 48, 44, 45, 44, 43, 41, 39, 37, 35, 34, 33, 32, 43, 44,
-        44, 43, 41, 39, 39, 38, 38, 37, 36, 34, 33, 33, 32, 31, 37, 39, 41, 41,
-        39, 36, 34, 31, 29, 28, 27, 26, 25, 25, 26, 26, 30, 33, 34, 36, 34, 32,
-        31, 29, 27, 25, 24, 23, 22, 22, 21, 21,
+        33, 32, 32, 32, 31, 30, 30, 28, 25, 23, 21, 19, 17, 16, 14, 14, 28, 29,
+        30, 28, 27, 24, 21, 20, 19, 18, 17, 16, 15, 14, 13, 13, 19, 20, 21, 20,
+        21, 19, 17, 16, 14, 13, 12, 12, 11, 11, 10, 10, 13, 14, 14, 14, 15, 14,
+        13, 12, 11, 11, 10, 9, 9, 8, 8, 8,
         /* Size 8x32 */
-        64, 62, 45, 42, 39, 36, 32, 29, 65, 60, 46, 44, 41, 38, 33, 31, 66, 59,
-        46, 44, 42, 38, 34, 31, 67, 59, 46, 45, 43, 39, 35, 33, 62, 55, 45, 45,
-        43, 40, 36, 33, 61, 53, 45, 45, 43, 40, 36, 33, 55, 48, 43, 45, 44, 41,
-        37, 34, 53, 47, 42, 44, 42, 40, 36, 35, 49, 46, 41, 41, 41, 38, 35, 33,
-        43, 44, 40, 39, 38, 37, 34, 33, 42, 44, 39, 38, 38, 36, 33, 31, 42, 44,
-        40, 37, 36, 34, 32, 32, 42, 45, 40, 36, 35, 33, 31, 29, 42, 45, 40, 35,
-        33, 32, 30, 30, 41, 44, 39, 34, 32, 31, 29, 27, 41, 44, 39, 34, 32, 31,
-        29, 29, 39, 43, 39, 34, 31, 29, 27, 26, 39, 42, 38, 33, 30, 28, 27, 27,
-        38, 41, 38, 33, 30, 28, 26, 25, 36, 40, 37, 32, 29, 27, 25, 25, 36, 40,
-        37, 32, 29, 27, 25, 24, 34, 38, 36, 31, 28, 26, 24, 23, 34, 37, 35, 31,
-        28, 26, 23, 23, 32, 36, 34, 30, 27, 25, 23, 22, 32, 36, 34, 30, 27, 25,
-        23, 22, 32, 35, 34, 30, 27, 25, 22, 20, 31, 34, 33, 29, 27, 24, 22, 22,
-        30, 34, 33, 29, 26, 24, 22, 21, 30, 33, 33, 29, 26, 23, 21, 21, 29, 33,
-        33, 29, 26, 23, 20, 20, 29, 32, 32, 29, 26, 23, 21, 20, 28, 31, 33, 31,
-        28, 25, 23, 21,
+        32, 33, 32, 28, 23, 19, 16, 13, 33, 32, 32, 29, 24, 20, 17, 14, 33, 32,
+        32, 29, 24, 20, 17, 14, 33, 32, 31, 30, 25, 21, 17, 14, 33, 32, 31, 30,
+        25, 21, 17, 14, 32, 32, 30, 28, 24, 20, 17, 14, 32, 32, 30, 28, 24, 20,
+        17, 14, 32, 31, 29, 27, 24, 21, 18, 15, 32, 31, 29, 27, 24, 21, 18, 15,
+        30, 30, 28, 24, 21, 19, 16, 14, 30, 30, 28, 24, 21, 19, 16, 14, 28, 30,
+        27, 21, 19, 17, 15, 13, 28, 30, 27, 21, 19, 17, 15, 13, 26, 28, 26, 20,
+        18, 16, 14, 12, 26, 28, 26, 20, 18, 16, 14, 12, 23, 25, 24, 19, 16, 14,
+        13, 11, 23, 25, 24, 19, 16, 14, 13, 11, 21, 23, 22, 18, 15, 13, 12, 11,
+        21, 23, 22, 18, 15, 13, 12, 11, 19, 21, 20, 17, 14, 12, 11, 10, 19, 21,
+        20, 17, 14, 12, 11, 10, 18, 19, 19, 16, 14, 12, 10, 9, 18, 19, 19, 16,
+        14, 12, 10, 9, 16, 17, 18, 15, 13, 11, 10, 9, 16, 17, 18, 15, 13, 11,
+        10, 9, 14, 16, 16, 14, 12, 11, 9, 8, 14, 16, 16, 14, 12, 11, 9, 8, 13,
+        14, 15, 13, 11, 10, 9, 8, 13, 14, 15, 13, 11, 10, 9, 8, 12, 14, 14, 13,
+        11, 10, 8, 8, 12, 14, 14, 13, 11, 10, 8, 8, 12, 13, 13, 12, 11, 9, 8, 7,
         /* Size 32x8 */
-        64, 65, 66, 67, 62, 61, 55, 53, 49, 43, 42, 42, 42, 42, 41, 41, 39, 39,
-        38, 36, 36, 34, 34, 32, 32, 32, 31, 30, 30, 29, 29, 28, 62, 60, 59, 59,
-        55, 53, 48, 47, 46, 44, 44, 44, 45, 45, 44, 44, 43, 42, 41, 40, 40, 38,
-        37, 36, 36, 35, 34, 34, 33, 33, 32, 31, 45, 46, 46, 46, 45, 45, 43, 42,
-        41, 40, 39, 40, 40, 40, 39, 39, 39, 38, 38, 37, 37, 36, 35, 34, 34, 34,
-        33, 33, 33, 33, 32, 33, 42, 44, 44, 45, 45, 45, 45, 44, 41, 39, 38, 37,
-        36, 35, 34, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 30, 29, 29, 29, 29,
-        29, 31, 39, 41, 42, 43, 43, 43, 44, 42, 41, 38, 38, 36, 35, 33, 32, 32,
-        31, 30, 30, 29, 29, 28, 28, 27, 27, 27, 27, 26, 26, 26, 26, 28, 36, 38,
-        38, 39, 40, 40, 41, 40, 38, 37, 36, 34, 33, 32, 31, 31, 29, 28, 28, 27,
-        27, 26, 26, 25, 25, 25, 24, 24, 23, 23, 23, 25, 32, 33, 34, 35, 36, 36,
-        37, 36, 35, 34, 33, 32, 31, 30, 29, 29, 27, 27, 26, 25, 25, 24, 23, 23,
-        23, 22, 22, 22, 21, 20, 21, 23, 29, 31, 31, 33, 33, 33, 34, 35, 33, 33,
-        31, 32, 29, 30, 27, 29, 26, 27, 25, 25, 24, 23, 23, 22, 22, 20, 22, 21,
-        21, 20, 20, 21 },
+        32, 33, 33, 33, 33, 32, 32, 32, 32, 30, 30, 28, 28, 26, 26, 23, 23, 21,
+        21, 19, 19, 18, 18, 16, 16, 14, 14, 13, 13, 12, 12, 12, 33, 32, 32, 32,
+        32, 32, 32, 31, 31, 30, 30, 30, 30, 28, 28, 25, 25, 23, 23, 21, 21, 19,
+        19, 17, 17, 16, 16, 14, 14, 14, 14, 13, 32, 32, 32, 31, 31, 30, 30, 29,
+        29, 28, 28, 27, 27, 26, 26, 24, 24, 22, 22, 20, 20, 19, 19, 18, 18, 16,
+        16, 15, 15, 14, 14, 13, 28, 29, 29, 30, 30, 28, 28, 27, 27, 24, 24, 21,
+        21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13,
+        13, 12, 23, 24, 24, 25, 25, 24, 24, 24, 24, 21, 21, 19, 19, 18, 18, 16,
+        16, 15, 15, 14, 14, 14, 14, 13, 13, 12, 12, 11, 11, 11, 11, 11, 19, 20,
+        20, 21, 21, 20, 20, 21, 21, 19, 19, 17, 17, 16, 16, 14, 14, 13, 13, 12,
+        12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 16, 17, 17, 17, 17, 17,
+        17, 18, 18, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10,
+        10, 9, 9, 9, 9, 8, 8, 8, 13, 14, 14, 14, 14, 14, 14, 15, 15, 14, 14, 13,
+        13, 12, 12, 11, 11, 11, 11, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 7 },
+      { /* Chroma */
+#if CONFIG_CHROMA_2X2
+        /* Size 2x2 */
+        22, 20, 20, 13,
+#endif
+        /* Size 4x4 */
+        32, 22, 22, 18, 22, 19, 19, 17, 22, 19, 16, 14, 18, 17, 14, 12,
+        /* Size 8x8 */
+        33, 30, 24, 22, 21, 20, 18, 17, 30, 26, 23, 22, 22, 21, 19, 18, 24, 23,
+        21, 21, 20, 20, 19, 18, 22, 22, 21, 19, 18, 18, 17, 16, 21, 22, 20, 18,
+        17, 16, 15, 14, 20, 21, 20, 18, 16, 14, 14, 13, 18, 19, 19, 17, 15, 14,
+        12, 12, 17, 18, 18, 16, 14, 13, 12, 11,
+        /* Size 16x16 */
+        32, 33, 34, 31, 28, 25, 21, 21, 21, 20, 20, 19, 18, 17, 16, 16, 33, 33,
+        33, 30, 27, 24, 22, 22, 22, 21, 20, 20, 19, 18, 17, 17, 34, 33, 32, 29,
+        26, 24, 22, 23, 23, 22, 22, 21, 20, 19, 18, 18, 31, 30, 29, 26, 24, 23,
+        22, 22, 23, 22, 22, 21, 20, 19, 18, 18, 28, 27, 26, 24, 22, 22, 21, 22,
+        23, 22, 22, 21, 20, 20, 19, 19, 25, 24, 24, 23, 22, 21, 20, 21, 21, 20,
+        20, 20, 19, 19, 18, 18, 21, 22, 22, 22, 21, 20, 19, 19, 19, 19, 19, 19,
+        18, 18, 17, 17, 21, 22, 23, 22, 22, 21, 19, 19, 19, 18, 18, 18, 17, 17,
+        16, 16, 21, 22, 23, 23, 23, 21, 19, 19, 18, 17, 17, 17, 16, 16, 15, 15,
+        20, 21, 22, 22, 22, 20, 19, 18, 17, 17, 16, 16, 15, 15, 14, 14, 20, 20,
+        22, 22, 22, 20, 19, 18, 17, 16, 16, 15, 15, 14, 14, 14, 19, 20, 21, 21,
+        21, 20, 19, 18, 17, 16, 15, 14, 14, 14, 13, 13, 18, 19, 20, 20, 20, 19,
+        18, 17, 16, 15, 15, 14, 13, 13, 12, 12, 17, 18, 19, 19, 20, 19, 18, 17,
+        16, 15, 14, 14, 13, 12, 12, 12, 16, 17, 18, 18, 19, 18, 17, 16, 15, 14,
+        14, 13, 12, 12, 12, 11, 16, 17, 18, 18, 19, 18, 17, 16, 15, 14, 14, 13,
+        12, 12, 11, 11,
+        /* Size 32x32 */
+        32, 33, 33, 34, 34, 31, 31, 28, 28, 25, 25, 21, 21, 21, 21, 21, 21, 20,
+        20, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 15, 33, 33, 33, 33,
+        33, 30, 30, 27, 27, 24, 24, 22, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20,
+        20, 19, 19, 18, 18, 17, 17, 17, 17, 16, 33, 33, 33, 33, 33, 30, 30, 27,
+        27, 24, 24, 22, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 20, 19, 19, 18,
+        18, 17, 17, 17, 17, 16, 34, 33, 33, 32, 32, 29, 29, 26, 26, 24, 24, 22,
+        22, 23, 23, 23, 23, 22, 22, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 18,
+        18, 17, 34, 33, 33, 32, 32, 29, 29, 26, 26, 24, 24, 22, 22, 23, 23, 23,
+        23, 22, 22, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 18, 18, 17, 31, 30,
+        30, 29, 29, 26, 26, 24, 24, 23, 23, 22, 22, 22, 22, 23, 23, 22, 22, 22,
+        22, 21, 21, 20, 20, 19, 19, 18, 18, 18, 18, 17, 31, 30, 30, 29, 29, 26,
+        26, 24, 24, 23, 23, 22, 22, 22, 22, 23, 23, 22, 22, 22, 22, 21, 21, 20,
+        20, 19, 19, 18, 18, 18, 18, 17, 28, 27, 27, 26, 26, 24, 24, 22, 22, 22,
+        22, 21, 21, 22, 22, 23, 23, 22, 22, 22, 22, 21, 21, 20, 20, 20, 20, 19,
+        19, 19, 19, 18, 28, 27, 27, 26, 26, 24, 24, 22, 22, 22, 22, 21, 21, 22,
+        22, 23, 23, 22, 22, 22, 22, 21, 21, 20, 20, 20, 20, 19, 19, 19, 19, 18,
+        25, 24, 24, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 21, 21, 21, 21, 20,
+        20, 20, 20, 20, 20, 19, 19, 19, 19, 18, 18, 18, 18, 17, 25, 24, 24, 24,
+        24, 23, 23, 22, 22, 21, 21, 20, 20, 21, 21, 21, 21, 20, 20, 20, 20, 20,
+        20, 19, 19, 19, 19, 18, 18, 18, 18, 17, 21, 22, 22, 22, 22, 22, 22, 21,
+        21, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18,
+        18, 17, 17, 17, 17, 17, 21, 22, 22, 22, 22, 22, 22, 21, 21, 20, 20, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17,
+        17, 17, 21, 22, 22, 23, 23, 22, 22, 22, 22, 21, 21, 19, 19, 19, 19, 19,
+        19, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, 16, 16, 16, 16, 16, 21, 22,
+        22, 23, 23, 22, 22, 22, 22, 21, 21, 19, 19, 19, 19, 19, 19, 18, 18, 18,
+        18, 18, 18, 17, 17, 17, 17, 16, 16, 16, 16, 16, 21, 22, 22, 23, 23, 23,
+        23, 23, 23, 21, 21, 19, 19, 19, 19, 18, 18, 17, 17, 17, 17, 17, 17, 16,
+        16, 16, 16, 15, 15, 15, 15, 15, 21, 22, 22, 23, 23, 23, 23, 23, 23, 21,
+        21, 19, 19, 19, 19, 18, 18, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 15,
+        15, 15, 15, 15, 20, 21, 21, 22, 22, 22, 22, 22, 22, 20, 20, 19, 19, 18,
+        18, 17, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14,
+        20, 21, 21, 22, 22, 22, 22, 22, 22, 20, 20, 19, 19, 18, 18, 17, 17, 17,
+        17, 16, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 20, 20, 20, 22,
+        22, 22, 22, 22, 22, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 15,
+        15, 15, 15, 14, 14, 14, 14, 14, 14, 13, 20, 20, 20, 22, 22, 22, 22, 22,
+        22, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 14,
+        14, 14, 14, 14, 14, 13, 19, 20, 20, 21, 21, 21, 21, 21, 21, 20, 20, 19,
+        19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 14, 14, 14, 13, 13, 13,
+        13, 13, 19, 20, 20, 21, 21, 21, 21, 21, 21, 20, 20, 19, 19, 18, 18, 17,
+        17, 16, 16, 15, 15, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 18, 19,
+        19, 20, 20, 20, 20, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 15,
+        15, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 12, 18, 19, 19, 20, 20, 20,
+        20, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 15, 15, 14, 14, 13,
+        13, 13, 13, 12, 12, 12, 12, 12, 17, 18, 18, 19, 19, 19, 19, 20, 20, 19,
+        19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 12, 12, 12,
+        12, 12, 12, 12, 17, 18, 18, 19, 19, 19, 19, 20, 20, 19, 19, 18, 18, 17,
+        17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 12, 12, 12, 12, 12, 12, 12,
+        16, 17, 17, 18, 18, 18, 18, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14,
+        14, 14, 14, 13, 13, 12, 12, 12, 12, 12, 12, 11, 11, 11, 16, 17, 17, 18,
+        18, 18, 18, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13,
+        13, 12, 12, 12, 12, 12, 12, 11, 11, 11, 16, 17, 17, 18, 18, 18, 18, 19,
+        19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 12, 12, 12,
+        12, 11, 11, 11, 11, 11, 16, 17, 17, 18, 18, 18, 18, 19, 19, 18, 18, 17,
+        17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11,
+        11, 11, 15, 16, 16, 17, 17, 17, 17, 18, 18, 17, 17, 17, 17, 16, 16, 15,
+        15, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 11,
+        /* Size 4x8 */
+        33, 22, 20, 17, 28, 22, 22, 18, 24, 20, 20, 18, 22, 19, 18, 16, 22, 19,
+        16, 14, 20, 19, 15, 13, 19, 18, 14, 12, 17, 17, 14, 11,
+        /* Size 8x4 */
+        33, 28, 24, 22, 22, 20, 19, 17, 22, 22, 20, 19, 19, 19, 18, 17, 20, 22,
+        20, 18, 16, 15, 14, 14, 17, 18, 18, 16, 14, 13, 12, 11,
+        /* Size 8x16 */
+        32, 33, 28, 21, 21, 20, 18, 16, 33, 33, 27, 22, 22, 20, 19, 17, 34, 32,
+        26, 22, 23, 21, 20, 18, 31, 28, 24, 22, 22, 22, 20, 18, 28, 26, 22, 22,
+        23, 22, 20, 19, 24, 24, 22, 20, 21, 20, 19, 18, 21, 22, 21, 19, 19, 19,
+        18, 17, 21, 22, 22, 19, 18, 18, 17, 16, 21, 23, 22, 19, 18, 17, 16, 15,
+        20, 22, 22, 19, 17, 16, 15, 14, 20, 21, 22, 19, 17, 16, 14, 14, 19, 20,
+        21, 19, 17, 15, 14, 13, 18, 20, 20, 18, 16, 15, 13, 12, 17, 19, 20, 18,
+        16, 14, 13, 12, 16, 18, 19, 17, 15, 14, 12, 12, 16, 17, 18, 17, 15, 14,
+        12, 11,
+        /* Size 16x8 */
+        32, 33, 34, 31, 28, 24, 21, 21, 21, 20, 20, 19, 18, 17, 16, 16, 33, 33,
+        32, 28, 26, 24, 22, 22, 23, 22, 21, 20, 20, 19, 18, 17, 28, 27, 26, 24,
+        22, 22, 21, 22, 22, 22, 22, 21, 20, 20, 19, 18, 21, 22, 22, 22, 22, 20,
+        19, 19, 19, 19, 19, 19, 18, 18, 17, 17, 21, 22, 23, 22, 23, 21, 19, 18,
+        18, 17, 17, 17, 16, 16, 15, 15, 20, 20, 21, 22, 22, 20, 19, 18, 17, 16,
+        16, 15, 15, 14, 14, 14, 18, 19, 20, 20, 20, 19, 18, 17, 16, 15, 14, 14,
+        13, 13, 12, 12, 16, 17, 18, 18, 19, 18, 17, 16, 15, 14, 14, 13, 12, 12,
+        12, 11,
+        /* Size 16x32 */
+        32, 33, 33, 28, 28, 21, 21, 21, 21, 20, 20, 18, 18, 16, 16, 16, 33, 33,
+        33, 27, 27, 22, 22, 22, 22, 20, 20, 19, 19, 17, 17, 16, 33, 33, 33, 27,
+        27, 22, 22, 22, 22, 20, 20, 19, 19, 17, 17, 16, 34, 32, 32, 26, 26, 22,
+        22, 23, 23, 21, 21, 20, 20, 18, 18, 17, 34, 32, 32, 26, 26, 22, 22, 23,
+        23, 21, 21, 20, 20, 18, 18, 17, 31, 28, 28, 24, 24, 22, 22, 22, 22, 22,
+        22, 20, 20, 18, 18, 17, 31, 28, 28, 24, 24, 22, 22, 22, 22, 22, 22, 20,
+        20, 18, 18, 17, 28, 26, 26, 22, 22, 22, 22, 23, 23, 22, 22, 20, 20, 19,
+        19, 18, 28, 26, 26, 22, 22, 22, 22, 23, 23, 22, 22, 20, 20, 19, 19, 18,
+        24, 24, 24, 22, 22, 20, 20, 21, 21, 20, 20, 19, 19, 18, 18, 17, 24, 24,
+        24, 22, 22, 20, 20, 21, 21, 20, 20, 19, 19, 18, 18, 17, 21, 22, 22, 21,
+        21, 19, 19, 19, 19, 19, 19, 18, 18, 17, 17, 17, 21, 22, 22, 21, 21, 19,
+        19, 19, 19, 19, 19, 18, 18, 17, 17, 17, 21, 22, 22, 22, 22, 19, 19, 18,
+        18, 18, 18, 17, 17, 16, 16, 16, 21, 22, 22, 22, 22, 19, 19, 18, 18, 18,
+        18, 17, 17, 16, 16, 16, 21, 23, 23, 22, 22, 19, 19, 18, 18, 17, 17, 16,
+        16, 15, 15, 15, 21, 23, 23, 22, 22, 19, 19, 18, 18, 17, 17, 16, 16, 15,
+        15, 15, 20, 22, 22, 22, 22, 19, 19, 17, 17, 16, 16, 15, 15, 14, 14, 14,
+        20, 22, 22, 22, 22, 19, 19, 17, 17, 16, 16, 15, 15, 14, 14, 14, 20, 21,
+        21, 22, 22, 19, 19, 17, 17, 16, 16, 14, 14, 14, 14, 13, 20, 21, 21, 22,
+        22, 19, 19, 17, 17, 16, 16, 14, 14, 14, 14, 13, 19, 20, 20, 21, 21, 19,
+        19, 17, 17, 15, 15, 14, 14, 13, 13, 13, 19, 20, 20, 21, 21, 19, 19, 17,
+        17, 15, 15, 14, 14, 13, 13, 13, 18, 20, 20, 20, 20, 18, 18, 16, 16, 15,
+        15, 13, 13, 12, 12, 12, 18, 20, 20, 20, 20, 18, 18, 16, 16, 15, 15, 13,
+        13, 12, 12, 12, 17, 19, 19, 20, 20, 18, 18, 16, 16, 14, 14, 13, 13, 12,
+        12, 12, 17, 19, 19, 20, 20, 18, 18, 16, 16, 14, 14, 13, 13, 12, 12, 12,
+        16, 18, 18, 19, 19, 17, 17, 15, 15, 14, 14, 12, 12, 12, 12, 11, 16, 18,
+        18, 19, 19, 17, 17, 15, 15, 14, 14, 12, 12, 12, 12, 11, 16, 17, 17, 18,
+        18, 17, 17, 15, 15, 14, 14, 12, 12, 11, 11, 11, 16, 17, 17, 18, 18, 17,
+        17, 15, 15, 14, 14, 12, 12, 11, 11, 11, 16, 17, 17, 18, 18, 16, 16, 15,
+        15, 13, 13, 12, 12, 11, 11, 11,
+        /* Size 32x16 */
+        32, 33, 33, 34, 34, 31, 31, 28, 28, 24, 24, 21, 21, 21, 21, 21, 21, 20,
+        20, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 16, 33, 33, 33, 32,
+        32, 28, 28, 26, 26, 24, 24, 22, 22, 22, 22, 23, 23, 22, 22, 21, 21, 20,
+        20, 20, 20, 19, 19, 18, 18, 17, 17, 17, 33, 33, 33, 32, 32, 28, 28, 26,
+        26, 24, 24, 22, 22, 22, 22, 23, 23, 22, 22, 21, 21, 20, 20, 20, 20, 19,
+        19, 18, 18, 17, 17, 17, 28, 27, 27, 26, 26, 24, 24, 22, 22, 22, 22, 21,
+        21, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 20, 19, 19, 18,
+        18, 18, 28, 27, 27, 26, 26, 24, 24, 22, 22, 22, 22, 21, 21, 22, 22, 22,
+        22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 20, 19, 19, 18, 18, 18, 21, 22,
+        22, 22, 22, 22, 22, 22, 22, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17, 16, 21, 22, 22, 22, 22, 22,
+        22, 22, 22, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18,
+        18, 18, 18, 17, 17, 17, 17, 16, 21, 22, 22, 23, 23, 22, 22, 23, 23, 21,
+        21, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 15,
+        15, 15, 15, 15, 21, 22, 22, 23, 23, 22, 22, 23, 23, 21, 21, 19, 19, 18,
+        18, 18, 18, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 15,
+        20, 20, 20, 21, 21, 22, 22, 22, 22, 20, 20, 19, 19, 18, 18, 17, 17, 16,
+        16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 13, 20, 20, 20, 21,
+        21, 22, 22, 22, 22, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 15,
+        15, 15, 15, 14, 14, 14, 14, 14, 14, 13, 18, 19, 19, 20, 20, 20, 20, 20,
+        20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 13,
+        13, 12, 12, 12, 12, 12, 18, 19, 19, 20, 20, 20, 20, 20, 20, 19, 19, 18,
+        18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12,
+        12, 12, 16, 17, 17, 18, 18, 18, 18, 19, 19, 18, 18, 17, 17, 16, 16, 15,
+        15, 14, 14, 14, 14, 13, 13, 12, 12, 12, 12, 12, 12, 11, 11, 11, 16, 17,
+        17, 18, 18, 18, 18, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14,
+        14, 13, 13, 12, 12, 12, 12, 12, 12, 11, 11, 11, 16, 16, 16, 17, 17, 17,
+        17, 18, 18, 17, 17, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 13, 12,
+        12, 12, 12, 11, 11, 11, 11, 11,
+        /* Size 4x16 */
+        33, 21, 20, 16, 33, 22, 20, 17, 32, 22, 21, 18, 28, 22, 22, 18, 26, 22,
+        22, 19, 24, 20, 20, 18, 22, 19, 19, 17, 22, 19, 18, 16, 23, 19, 17, 15,
+        22, 19, 16, 14, 21, 19, 16, 14, 20, 19, 15, 13, 20, 18, 15, 12, 19, 18,
+        14, 12, 18, 17, 14, 12, 17, 17, 14, 11,
+        /* Size 16x4 */
+        33, 33, 32, 28, 26, 24, 22, 22, 23, 22, 21, 20, 20, 19, 18, 17, 21, 22,
+        22, 22, 22, 20, 19, 19, 19, 19, 19, 19, 18, 18, 17, 17, 20, 20, 21, 22,
+        22, 20, 19, 18, 17, 16, 16, 15, 15, 14, 14, 14, 16, 17, 18, 18, 19, 18,
+        17, 16, 15, 14, 14, 13, 12, 12, 12, 11,
+        /* Size 8x32 */
+        32, 33, 28, 21, 21, 20, 18, 16, 33, 33, 27, 22, 22, 20, 19, 17, 33, 33,
+        27, 22, 22, 20, 19, 17, 34, 32, 26, 22, 23, 21, 20, 18, 34, 32, 26, 22,
+        23, 21, 20, 18, 31, 28, 24, 22, 22, 22, 20, 18, 31, 28, 24, 22, 22, 22,
+        20, 18, 28, 26, 22, 22, 23, 22, 20, 19, 28, 26, 22, 22, 23, 22, 20, 19,
+        24, 24, 22, 20, 21, 20, 19, 18, 24, 24, 22, 20, 21, 20, 19, 18, 21, 22,
+        21, 19, 19, 19, 18, 17, 21, 22, 21, 19, 19, 19, 18, 17, 21, 22, 22, 19,
+        18, 18, 17, 16, 21, 22, 22, 19, 18, 18, 17, 16, 21, 23, 22, 19, 18, 17,
+        16, 15, 21, 23, 22, 19, 18, 17, 16, 15, 20, 22, 22, 19, 17, 16, 15, 14,
+        20, 22, 22, 19, 17, 16, 15, 14, 20, 21, 22, 19, 17, 16, 14, 14, 20, 21,
+        22, 19, 17, 16, 14, 14, 19, 20, 21, 19, 17, 15, 14, 13, 19, 20, 21, 19,
+        17, 15, 14, 13, 18, 20, 20, 18, 16, 15, 13, 12, 18, 20, 20, 18, 16, 15,
+        13, 12, 17, 19, 20, 18, 16, 14, 13, 12, 17, 19, 20, 18, 16, 14, 13, 12,
+        16, 18, 19, 17, 15, 14, 12, 12, 16, 18, 19, 17, 15, 14, 12, 12, 16, 17,
+        18, 17, 15, 14, 12, 11, 16, 17, 18, 17, 15, 14, 12, 11, 16, 17, 18, 16,
+        15, 13, 12, 11,
+        /* Size 32x8 */
+        32, 33, 33, 34, 34, 31, 31, 28, 28, 24, 24, 21, 21, 21, 21, 21, 21, 20,
+        20, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 16, 33, 33, 33, 32,
+        32, 28, 28, 26, 26, 24, 24, 22, 22, 22, 22, 23, 23, 22, 22, 21, 21, 20,
+        20, 20, 20, 19, 19, 18, 18, 17, 17, 17, 28, 27, 27, 26, 26, 24, 24, 22,
+        22, 22, 22, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20,
+        20, 19, 19, 18, 18, 18, 21, 22, 22, 22, 22, 22, 22, 22, 22, 20, 20, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17,
+        17, 16, 21, 22, 22, 23, 23, 22, 22, 23, 23, 21, 21, 19, 19, 18, 18, 18,
+        18, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 20, 20,
+        20, 21, 21, 22, 22, 22, 22, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 16,
+        16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 13, 18, 19, 19, 20, 20, 20,
+        20, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13,
+        13, 13, 13, 12, 12, 12, 12, 12, 16, 17, 17, 18, 18, 18, 18, 19, 19, 18,
+        18, 17, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 12, 12, 12, 12, 12,
+        12, 11, 11, 11 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        58, 33, 33, 17,
+        30, 20, 20, 12,
 #endif
         /* Size 4x4 */
-        63, 59, 38, 27, 59, 42, 32, 25, 38, 32, 23, 18, 27, 25, 18, 15,
+        32, 31, 23, 17, 31, 26, 20, 16, 23, 20, 14, 12, 17, 16, 12, 9,
         /* Size 8x8 */
-        64, 64, 60, 52, 41, 33, 27, 24, 64, 61, 58, 51, 42, 35, 29, 26, 60, 58,
-        52, 45, 38, 33, 28, 25, 52, 51, 45, 36, 31, 27, 24, 22, 41, 42, 38, 31,
-        26, 23, 20, 19, 33, 35, 33, 27, 23, 20, 17, 17, 27, 29, 28, 24, 20, 17,
-        15, 14, 24, 26, 25, 22, 19, 17, 14, 13,
+        33, 32, 32, 29, 24, 20, 17, 15, 32, 32, 31, 29, 25, 21, 18, 16, 32, 31,
+        29, 27, 24, 21, 18, 16, 29, 29, 27, 21, 19, 17, 16, 14, 24, 25, 24, 19,
+        16, 14, 13, 12, 20, 21, 21, 17, 14, 13, 12, 11, 17, 18, 18, 16, 13, 12,
+        10, 9, 15, 16, 16, 14, 12, 11, 9, 9,
         /* Size 16x16 */
-        64, 65, 65, 64, 61, 57, 52, 47, 42, 38, 35, 31, 27, 25, 24, 22, 65, 64,
-        64, 63, 61, 59, 53, 49, 45, 40, 37, 33, 29, 27, 25, 24, 65, 64, 63, 62,
-        60, 59, 54, 49, 46, 41, 38, 34, 30, 28, 26, 25, 64, 63, 62, 59, 57, 55,
-        51, 48, 45, 41, 38, 34, 31, 29, 27, 25, 61, 61, 60, 57, 53, 49, 47, 44,
-        41, 38, 36, 33, 29, 27, 26, 25, 57, 59, 59, 55, 49, 42, 41, 38, 36, 34,
-        32, 30, 27, 26, 24, 24, 52, 53, 54, 51, 47, 41, 38, 35, 34, 32, 30, 28,
-        25, 24, 23, 22, 47, 49, 49, 48, 44, 38, 35, 32, 31, 29, 27, 25, 24, 22,
-        22, 21, 42, 45, 46, 45, 41, 36, 34, 31, 29, 27, 25, 24, 22, 21, 20, 19,
-        38, 40, 41, 41, 38, 34, 32, 29, 27, 25, 24, 22, 20, 19, 19, 18, 35, 37,
-        38, 38, 36, 32, 30, 27, 25, 24, 22, 21, 19, 18, 18, 17, 31, 33, 34, 34,
-        33, 30, 28, 25, 24, 22, 21, 19, 18, 17, 16, 15, 27, 29, 30, 31, 29, 27,
-        25, 24, 22, 20, 19, 18, 17, 16, 15, 15, 25, 27, 28, 29, 27, 26, 24, 22,
-        21, 19, 18, 17, 16, 15, 14, 13, 24, 25, 26, 27, 26, 24, 23, 22, 20, 19,
-        18, 16, 15, 14, 14, 13, 22, 24, 25, 25, 25, 24, 22, 21, 19, 18, 17, 15,
-        15, 13, 13, 13,
+        32, 33, 33, 33, 32, 30, 29, 27, 25, 23, 21, 19, 17, 16, 14, 13, 33, 32,
+        32, 32, 32, 30, 29, 28, 26, 24, 22, 20, 18, 17, 15, 13, 33, 32, 32, 32,
+        32, 31, 30, 28, 27, 25, 23, 21, 19, 17, 16, 14, 33, 32, 32, 31, 30, 29,
+        28, 27, 26, 24, 23, 20, 19, 17, 16, 14, 32, 32, 32, 30, 29, 28, 27, 26,
+        25, 24, 22, 21, 19, 18, 16, 15, 30, 30, 31, 29, 28, 26, 24, 23, 22, 21,
+        20, 19, 18, 16, 15, 14, 29, 29, 30, 28, 27, 24, 22, 21, 20, 19, 19, 17,
+        17, 15, 14, 13, 27, 28, 28, 27, 26, 23, 21, 20, 19, 18, 17, 16, 15, 14,
+        13, 12, 25, 26, 27, 26, 25, 22, 20, 19, 18, 17, 16, 15, 14, 14, 13, 12,
+        23, 24, 25, 24, 24, 21, 19, 18, 17, 16, 15, 14, 13, 13, 12, 11, 21, 22,
+        23, 23, 22, 20, 19, 17, 16, 15, 14, 13, 13, 12, 11, 11, 19, 20, 21, 20,
+        21, 19, 17, 16, 15, 14, 13, 12, 12, 11, 11, 10, 17, 18, 19, 19, 19, 18,
+        17, 15, 14, 13, 13, 12, 11, 10, 10, 9, 16, 17, 17, 17, 18, 16, 15, 14,
+        14, 13, 12, 11, 10, 10, 9, 9, 14, 15, 16, 16, 16, 15, 14, 13, 13, 12,
+        11, 11, 10, 9, 9, 8, 13, 13, 14, 14, 15, 14, 13, 12, 12, 11, 11, 10, 9,
+        9, 8, 8,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 64, 64, 61, 60, 57, 57, 52, 50, 47, 45, 42, 39,
-        38, 35, 35, 31, 31, 29, 27, 26, 25, 25, 24, 23, 22, 22, 65, 64, 64, 64,
-        64, 64, 63, 63, 61, 60, 59, 58, 53, 52, 48, 46, 44, 41, 40, 37, 36, 33,
-        32, 30, 29, 27, 26, 26, 25, 24, 23, 23, 65, 64, 64, 64, 64, 63, 63, 63,
-        61, 60, 59, 58, 53, 52, 49, 47, 45, 41, 40, 37, 37, 33, 33, 30, 29, 27,
-        27, 26, 25, 24, 24, 23, 65, 64, 64, 63, 63, 63, 63, 63, 61, 61, 59, 59,
-        55, 53, 50, 48, 46, 43, 41, 38, 38, 34, 34, 32, 30, 28, 28, 27, 26, 25,
-        25, 24, 65, 64, 64, 63, 63, 62, 62, 62, 60, 59, 59, 58, 54, 53, 49, 48,
-        46, 43, 41, 38, 38, 34, 34, 32, 30, 28, 28, 27, 26, 25, 25, 24, 65, 64,
-        63, 63, 62, 61, 61, 60, 59, 58, 56, 56, 53, 51, 49, 47, 45, 42, 41, 38,
-        38, 35, 34, 32, 31, 29, 28, 28, 27, 26, 25, 25, 64, 63, 63, 63, 62, 61,
-        59, 59, 57, 57, 55, 54, 51, 51, 48, 47, 45, 42, 41, 39, 38, 35, 34, 32,
-        31, 29, 29, 28, 27, 26, 25, 24, 64, 63, 63, 63, 62, 60, 59, 58, 56, 55,
-        53, 53, 51, 50, 48, 47, 45, 42, 41, 39, 38, 35, 35, 33, 31, 29, 29, 28,
-        27, 27, 26, 25, 61, 61, 61, 61, 60, 59, 57, 56, 53, 53, 49, 49, 47, 46,
-        44, 43, 41, 39, 38, 36, 36, 33, 33, 31, 29, 28, 27, 27, 26, 26, 25, 25,
-        60, 60, 60, 61, 59, 58, 57, 55, 53, 52, 48, 48, 46, 45, 43, 41, 40, 38,
-        38, 35, 35, 33, 32, 30, 29, 28, 27, 27, 26, 25, 25, 23, 57, 59, 59, 59,
-        59, 56, 55, 53, 49, 48, 42, 42, 41, 40, 38, 37, 36, 35, 34, 32, 32, 30,
-        30, 28, 27, 26, 26, 25, 24, 24, 24, 24, 57, 58, 58, 59, 58, 56, 54, 53,
-        49, 48, 42, 42, 40, 39, 38, 37, 36, 34, 34, 32, 32, 30, 29, 28, 27, 26,
-        25, 25, 24, 24, 23, 22, 52, 53, 53, 55, 54, 53, 51, 51, 47, 46, 41, 40,
-        38, 37, 35, 34, 34, 32, 32, 30, 30, 28, 28, 26, 25, 24, 24, 24, 23, 22,
-        22, 23, 50, 52, 52, 53, 53, 51, 51, 50, 46, 45, 40, 39, 37, 36, 34, 34,
-        33, 31, 31, 29, 29, 27, 27, 26, 25, 24, 23, 23, 23, 22, 22, 21, 47, 48,
-        49, 50, 49, 49, 48, 48, 44, 43, 38, 38, 35, 34, 32, 32, 31, 29, 29, 27,
-        27, 26, 25, 24, 24, 23, 22, 22, 22, 21, 21, 21, 45, 46, 47, 48, 48, 47,
-        47, 47, 43, 41, 37, 37, 34, 34, 32, 31, 30, 28, 28, 26, 26, 25, 25, 23,
-        23, 22, 22, 21, 21, 21, 21, 19, 42, 44, 45, 46, 46, 45, 45, 45, 41, 40,
-        36, 36, 34, 33, 31, 30, 29, 27, 27, 26, 25, 24, 24, 23, 22, 21, 21, 21,
-        20, 20, 19, 20, 39, 41, 41, 43, 43, 42, 42, 42, 39, 38, 35, 34, 32, 31,
-        29, 28, 27, 26, 25, 24, 24, 23, 23, 21, 21, 20, 20, 20, 19, 19, 19, 18,
-        38, 40, 40, 41, 41, 41, 41, 41, 38, 38, 34, 34, 32, 31, 29, 28, 27, 25,
-        25, 24, 24, 22, 22, 21, 20, 20, 19, 19, 19, 18, 18, 19, 35, 37, 37, 38,
-        38, 38, 39, 39, 36, 35, 32, 32, 30, 29, 27, 26, 26, 24, 24, 23, 22, 21,
-        21, 20, 19, 19, 18, 18, 18, 18, 18, 17, 35, 36, 37, 38, 38, 38, 38, 38,
-        36, 35, 32, 32, 30, 29, 27, 26, 25, 24, 24, 22, 22, 21, 21, 20, 19, 19,
-        18, 18, 18, 17, 17, 18, 31, 33, 33, 34, 34, 35, 35, 35, 33, 33, 30, 30,
-        28, 27, 26, 25, 24, 23, 22, 21, 21, 20, 19, 18, 18, 17, 17, 17, 17, 17,
-        17, 16, 31, 32, 33, 34, 34, 34, 34, 35, 33, 32, 30, 29, 28, 27, 25, 25,
-        24, 23, 22, 21, 21, 19, 19, 18, 18, 17, 17, 17, 16, 16, 15, 17, 29, 30,
-        30, 32, 32, 32, 32, 33, 31, 30, 28, 28, 26, 26, 24, 23, 23, 21, 21, 20,
-        20, 18, 18, 17, 17, 16, 16, 16, 16, 15, 16, 14, 27, 29, 29, 30, 30, 31,
-        31, 31, 29, 29, 27, 27, 25, 25, 24, 23, 22, 21, 20, 19, 19, 18, 18, 17,
-        17, 16, 16, 16, 15, 15, 15, 16, 26, 27, 27, 28, 28, 29, 29, 29, 28, 28,
-        26, 26, 24, 24, 23, 22, 21, 20, 20, 19, 19, 17, 17, 16, 16, 15, 15, 15,
-        15, 14, 15, 14, 25, 26, 27, 28, 28, 28, 29, 29, 27, 27, 26, 25, 24, 23,
-        22, 22, 21, 20, 19, 18, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 13, 15,
-        25, 26, 26, 27, 27, 28, 28, 28, 27, 27, 25, 25, 24, 23, 22, 21, 21, 20,
-        19, 18, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 14, 13, 24, 25, 25, 26,
-        26, 27, 27, 27, 26, 26, 24, 24, 23, 23, 22, 21, 20, 19, 19, 18, 18, 17,
-        16, 16, 15, 15, 14, 14, 14, 14, 13, 14, 23, 24, 24, 25, 25, 26, 26, 27,
-        26, 25, 24, 24, 22, 22, 21, 21, 20, 19, 18, 18, 17, 17, 16, 15, 15, 14,
-        14, 14, 14, 13, 14, 13, 22, 23, 24, 25, 25, 25, 25, 26, 25, 25, 24, 23,
-        22, 22, 21, 21, 19, 19, 18, 18, 17, 17, 15, 16, 15, 15, 13, 14, 13, 14,
-        13, 13, 22, 23, 23, 24, 24, 25, 24, 25, 25, 23, 24, 22, 23, 21, 21, 19,
-        20, 18, 19, 17, 18, 16, 17, 14, 16, 14, 15, 13, 14, 13, 13, 12,
+        32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 30, 30, 29, 28, 27, 26, 25, 23,
+        23, 21, 21, 19, 19, 18, 17, 17, 16, 15, 14, 14, 13, 13, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 30, 30, 29, 29, 28, 27, 26, 24, 24, 22, 22, 20,
+        20, 19, 18, 17, 17, 16, 15, 15, 13, 13, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 30, 30, 29, 29, 28, 27, 26, 24, 24, 22, 22, 20, 20, 19, 18, 17,
+        17, 16, 15, 15, 13, 13, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        30, 30, 28, 27, 26, 25, 24, 23, 23, 21, 20, 19, 19, 18, 17, 17, 16, 16,
+        14, 14, 33, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 28, 28,
+        27, 25, 25, 23, 23, 21, 21, 20, 19, 18, 17, 17, 16, 16, 14, 14, 33, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 29, 29, 28, 27, 26, 25, 24, 23,
+        23, 21, 21, 20, 19, 18, 17, 17, 16, 16, 14, 14, 33, 32, 32, 32, 32, 31,
+        31, 31, 30, 30, 29, 29, 28, 28, 27, 26, 26, 24, 24, 23, 23, 21, 20, 20,
+        19, 18, 17, 17, 16, 16, 14, 14, 32, 32, 32, 32, 32, 31, 31, 30, 30, 30,
+        29, 29, 28, 28, 27, 26, 26, 24, 24, 23, 23, 21, 21, 20, 19, 18, 17, 17,
+        16, 16, 15, 15, 32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 28, 28, 27, 27,
+        26, 26, 25, 24, 24, 22, 22, 21, 21, 20, 19, 19, 18, 17, 16, 16, 15, 15,
+        32, 32, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 25, 25, 24,
+        24, 22, 22, 21, 20, 20, 19, 18, 18, 17, 16, 16, 15, 15, 30, 30, 30, 31,
+        31, 30, 29, 29, 28, 28, 26, 26, 24, 24, 23, 23, 22, 22, 21, 20, 20, 19,
+        19, 18, 18, 17, 16, 16, 15, 15, 14, 14, 30, 30, 30, 31, 31, 30, 29, 29,
+        28, 28, 26, 26, 24, 24, 23, 23, 22, 22, 21, 20, 20, 19, 19, 18, 18, 17,
+        16, 16, 15, 15, 14, 14, 29, 29, 29, 30, 30, 29, 28, 28, 27, 27, 24, 24,
+        22, 22, 21, 21, 20, 20, 19, 19, 19, 18, 17, 17, 17, 16, 15, 15, 14, 14,
+        13, 13, 28, 29, 29, 30, 30, 29, 28, 28, 27, 27, 24, 24, 22, 21, 20, 20,
+        20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 27, 28,
+        28, 28, 28, 28, 27, 27, 26, 26, 23, 23, 21, 20, 20, 20, 19, 18, 18, 17,
+        17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 26, 27, 27, 27, 28, 27,
+        26, 26, 26, 25, 23, 23, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15,
+        15, 14, 14, 14, 13, 13, 12, 12, 25, 26, 26, 26, 27, 26, 26, 26, 25, 25,
+        22, 22, 20, 20, 19, 19, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 14, 13,
+        13, 13, 12, 12, 23, 24, 24, 25, 25, 25, 24, 24, 24, 24, 22, 22, 20, 19,
+        18, 18, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 13, 12, 12, 11, 11,
+        23, 24, 24, 24, 25, 24, 24, 24, 24, 24, 21, 21, 19, 19, 18, 18, 17, 16,
+        16, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 21, 22, 22, 23,
+        23, 23, 23, 23, 22, 22, 20, 20, 19, 18, 17, 17, 16, 15, 15, 14, 14, 14,
+        13, 13, 13, 12, 12, 12, 11, 11, 11, 11, 21, 22, 22, 23, 23, 23, 23, 23,
+        22, 22, 20, 20, 19, 18, 17, 17, 16, 15, 15, 14, 14, 14, 13, 13, 13, 12,
+        12, 12, 11, 11, 11, 11, 19, 20, 20, 21, 21, 21, 21, 21, 21, 21, 19, 19,
+        18, 17, 17, 16, 15, 14, 14, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11,
+        10, 10, 19, 20, 20, 20, 21, 21, 20, 21, 21, 20, 19, 19, 17, 17, 16, 16,
+        15, 14, 14, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 10, 10, 10, 18, 19,
+        19, 19, 20, 20, 20, 20, 20, 20, 18, 18, 17, 17, 16, 15, 15, 14, 14, 13,
+        13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 17, 18, 18, 19, 19, 19,
+        19, 19, 19, 19, 18, 18, 17, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 11,
+        11, 11, 10, 10, 10, 10, 9, 9, 17, 17, 17, 18, 18, 18, 18, 18, 19, 18,
+        17, 17, 16, 16, 15, 14, 14, 13, 13, 12, 12, 12, 12, 11, 11, 10, 10, 10,
+        10, 9, 9, 9, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 16, 16, 15, 15, 14,
+        14, 14, 13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 15, 16,
+        16, 17, 17, 17, 17, 17, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12,
+        12, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 9, 14, 15, 15, 16, 16, 16, 16,
+        16, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 11, 11, 11, 11, 10, 10,
+        10, 9, 9, 9, 9, 8, 8, 14, 15, 15, 16, 16, 16, 16, 16, 16, 16, 15, 15,
+        14, 14, 13, 13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 9, 9, 8, 8,
+        13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 14, 14, 13, 13, 12, 12, 12, 11,
+        11, 11, 11, 10, 10, 9, 9, 9, 9, 9, 8, 8, 8, 8, 13, 13, 13, 14, 14, 14,
+        14, 15, 15, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11, 10, 10, 9,
+        9, 9, 9, 9, 8, 8, 8, 8,
         /* Size 4x8 */
-        64, 58, 40, 26, 63, 56, 41, 28, 60, 48, 38, 27, 53, 40, 31, 24, 43, 35,
-        25, 20, 34, 30, 22, 17, 28, 26, 20, 15, 25, 24, 18, 14,
+        32, 30, 24, 17, 32, 30, 24, 17, 31, 28, 23, 18, 29, 24, 19, 15, 25, 21,
+        16, 13, 21, 19, 14, 11, 18, 17, 13, 10, 16, 15, 12, 9,
         /* Size 8x4 */
-        64, 63, 60, 53, 43, 34, 28, 25, 58, 56, 48, 40, 35, 30, 26, 24, 40, 41,
-        38, 31, 25, 22, 20, 18, 26, 28, 27, 24, 20, 17, 15, 14,
+        32, 32, 31, 29, 25, 21, 18, 16, 30, 30, 28, 24, 21, 19, 17, 15, 24, 24,
+        23, 19, 16, 14, 13, 12, 17, 17, 18, 15, 13, 11, 10, 9,
         /* Size 8x16 */
-        64, 65, 61, 51, 40, 31, 26, 23, 65, 64, 61, 53, 42, 33, 27, 25, 65, 63,
-        60, 53, 43, 34, 29, 26, 64, 62, 57, 51, 43, 35, 29, 26, 61, 60, 53, 46,
-        39, 33, 28, 26, 57, 58, 49, 40, 35, 30, 26, 24, 52, 53, 47, 38, 32, 28,
-        24, 23, 47, 49, 44, 35, 29, 26, 23, 21, 43, 46, 41, 33, 28, 24, 21, 20,
-        38, 41, 38, 31, 26, 22, 20, 18, 35, 38, 36, 29, 24, 21, 19, 17, 31, 34,
-        33, 27, 23, 19, 17, 16, 27, 30, 29, 25, 21, 18, 16, 15, 25, 28, 27, 24,
-        20, 17, 15, 14, 24, 26, 26, 23, 19, 17, 15, 14, 22, 25, 25, 22, 19, 17,
-        15, 13,
+        32, 33, 32, 28, 23, 19, 17, 14, 33, 32, 32, 29, 24, 20, 17, 15, 33, 32,
+        31, 30, 25, 21, 18, 16, 32, 32, 30, 28, 24, 20, 18, 16, 32, 31, 29, 27,
+        24, 21, 18, 16, 30, 30, 28, 24, 21, 19, 17, 15, 29, 30, 27, 22, 20, 17,
+        16, 14, 27, 28, 26, 21, 18, 16, 15, 13, 25, 26, 25, 20, 17, 15, 14, 13,
+        23, 24, 24, 19, 16, 14, 13, 12, 21, 23, 22, 18, 15, 13, 12, 11, 19, 21,
+        20, 17, 14, 12, 11, 10, 18, 19, 19, 16, 14, 12, 11, 10, 16, 17, 18, 15,
+        13, 11, 10, 9, 14, 16, 16, 14, 12, 11, 9, 9, 13, 14, 15, 13, 11, 10, 9,
+        8,
         /* Size 16x8 */
-        64, 65, 65, 64, 61, 57, 52, 47, 43, 38, 35, 31, 27, 25, 24, 22, 65, 64,
-        63, 62, 60, 58, 53, 49, 46, 41, 38, 34, 30, 28, 26, 25, 61, 61, 60, 57,
-        53, 49, 47, 44, 41, 38, 36, 33, 29, 27, 26, 25, 51, 53, 53, 51, 46, 40,
-        38, 35, 33, 31, 29, 27, 25, 24, 23, 22, 40, 42, 43, 43, 39, 35, 32, 29,
-        28, 26, 24, 23, 21, 20, 19, 19, 31, 33, 34, 35, 33, 30, 28, 26, 24, 22,
-        21, 19, 18, 17, 17, 17, 26, 27, 29, 29, 28, 26, 24, 23, 21, 20, 19, 17,
-        16, 15, 15, 15, 23, 25, 26, 26, 26, 24, 23, 21, 20, 18, 17, 16, 15, 14,
-        14, 13,
+        32, 33, 33, 32, 32, 30, 29, 27, 25, 23, 21, 19, 18, 16, 14, 13, 33, 32,
+        32, 32, 31, 30, 30, 28, 26, 24, 23, 21, 19, 17, 16, 14, 32, 32, 31, 30,
+        29, 28, 27, 26, 25, 24, 22, 20, 19, 18, 16, 15, 28, 29, 30, 28, 27, 24,
+        22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 23, 24, 25, 24, 24, 21, 20, 18,
+        17, 16, 15, 14, 14, 13, 12, 11, 19, 20, 21, 20, 21, 19, 17, 16, 15, 14,
+        13, 12, 12, 11, 11, 10, 17, 17, 18, 18, 18, 17, 16, 15, 14, 13, 12, 11,
+        11, 10, 9, 9, 14, 15, 16, 16, 16, 15, 14, 13, 13, 12, 11, 10, 10, 9, 9,
+        8,
         /* Size 16x32 */
-        64, 65, 65, 64, 61, 57, 51, 47, 40, 38, 31, 31, 26, 25, 23, 22, 65, 64,
-        64, 63, 61, 58, 52, 48, 41, 40, 33, 32, 27, 26, 24, 23, 65, 64, 64, 63,
-        61, 59, 53, 49, 42, 40, 33, 33, 27, 27, 25, 23, 65, 63, 63, 62, 61, 59,
-        54, 50, 43, 41, 34, 34, 28, 28, 26, 25, 65, 63, 63, 61, 60, 58, 53, 49,
-        43, 41, 34, 34, 29, 28, 26, 24, 64, 63, 62, 60, 59, 56, 52, 49, 43, 41,
-        35, 34, 29, 28, 26, 25, 64, 63, 62, 59, 57, 55, 51, 48, 43, 41, 35, 34,
-        29, 29, 26, 25, 64, 62, 61, 58, 56, 53, 50, 48, 43, 41, 35, 35, 30, 29,
-        27, 26, 61, 61, 60, 56, 53, 49, 46, 44, 39, 38, 33, 33, 28, 27, 26, 26,
-        60, 60, 59, 55, 53, 48, 45, 43, 39, 38, 33, 32, 28, 27, 25, 24, 57, 59,
-        58, 53, 49, 43, 40, 38, 35, 34, 30, 30, 26, 26, 24, 24, 57, 59, 58, 53,
-        49, 43, 40, 38, 35, 34, 30, 29, 26, 25, 24, 22, 52, 55, 53, 51, 47, 41,
-        38, 35, 32, 32, 28, 27, 24, 24, 23, 23, 51, 53, 53, 49, 46, 40, 37, 34,
-        32, 31, 27, 27, 24, 24, 23, 21, 47, 50, 49, 48, 44, 38, 35, 33, 29, 29,
-        26, 25, 23, 22, 21, 22, 45, 48, 47, 46, 42, 37, 34, 32, 28, 28, 25, 25,
-        22, 22, 21, 19, 43, 46, 46, 44, 41, 36, 33, 31, 28, 27, 24, 24, 21, 21,
-        20, 20, 39, 43, 42, 42, 39, 35, 32, 29, 26, 25, 23, 23, 20, 20, 20, 18,
-        38, 41, 41, 41, 38, 34, 31, 29, 26, 25, 22, 22, 20, 20, 18, 19, 35, 38,
-        38, 38, 36, 32, 29, 27, 25, 24, 21, 21, 19, 18, 18, 17, 35, 38, 38, 38,
-        36, 32, 29, 27, 24, 24, 21, 21, 19, 18, 17, 18, 32, 34, 34, 35, 33, 30,
-        27, 26, 23, 22, 20, 19, 17, 17, 17, 16, 31, 34, 34, 34, 33, 30, 27, 25,
-        23, 22, 19, 19, 17, 17, 16, 17, 29, 31, 32, 32, 31, 28, 26, 24, 22, 21,
-        18, 18, 16, 16, 15, 15, 27, 30, 30, 31, 29, 27, 25, 24, 21, 20, 18, 18,
-        16, 16, 15, 16, 26, 28, 28, 29, 28, 26, 24, 23, 20, 20, 17, 17, 15, 15,
-        14, 14, 25, 28, 28, 29, 27, 25, 24, 22, 20, 20, 17, 17, 15, 15, 14, 15,
-        25, 27, 27, 28, 27, 25, 23, 22, 20, 19, 17, 17, 15, 15, 14, 13, 24, 26,
-        26, 27, 26, 24, 23, 22, 19, 19, 17, 16, 15, 14, 14, 14, 23, 25, 25, 26,
-        25, 24, 22, 21, 19, 18, 17, 16, 14, 14, 13, 13, 22, 25, 25, 26, 25, 23,
-        22, 21, 19, 18, 17, 16, 15, 14, 13, 14, 22, 24, 24, 25, 25, 22, 23, 19,
-        20, 17, 18, 15, 16, 13, 14, 13,
+        32, 33, 33, 32, 32, 30, 28, 27, 23, 23, 19, 19, 17, 16, 14, 13, 33, 32,
+        32, 32, 32, 30, 29, 28, 24, 24, 20, 20, 17, 17, 15, 14, 33, 32, 32, 32,
+        32, 30, 29, 28, 24, 24, 20, 20, 17, 17, 15, 14, 33, 32, 32, 32, 32, 31,
+        29, 28, 25, 24, 20, 20, 18, 17, 15, 14, 33, 32, 32, 32, 31, 31, 30, 28,
+        25, 25, 21, 21, 18, 17, 16, 14, 33, 32, 32, 31, 31, 30, 29, 28, 25, 24,
+        21, 21, 18, 17, 16, 14, 32, 32, 32, 31, 30, 29, 28, 27, 24, 24, 20, 20,
+        18, 17, 16, 14, 32, 32, 32, 30, 30, 29, 28, 27, 24, 24, 21, 21, 18, 17,
+        16, 15, 32, 32, 31, 30, 29, 28, 27, 26, 24, 24, 21, 21, 18, 18, 16, 15,
+        32, 31, 31, 30, 29, 28, 26, 26, 24, 23, 20, 20, 18, 18, 16, 15, 30, 30,
+        30, 28, 28, 26, 24, 23, 21, 21, 19, 19, 17, 16, 15, 14, 30, 30, 30, 28,
+        28, 26, 24, 23, 21, 21, 19, 19, 17, 16, 15, 14, 29, 30, 30, 28, 27, 24,
+        22, 21, 20, 19, 17, 17, 16, 15, 14, 13, 28, 29, 30, 28, 27, 24, 21, 21,
+        19, 19, 17, 17, 16, 15, 14, 13, 27, 28, 28, 27, 26, 23, 21, 20, 18, 18,
+        16, 16, 15, 14, 13, 13, 26, 27, 28, 26, 26, 23, 20, 20, 18, 18, 16, 16,
+        14, 14, 13, 12, 25, 26, 26, 25, 25, 22, 20, 19, 17, 17, 15, 15, 14, 13,
+        13, 12, 23, 25, 25, 24, 24, 21, 19, 18, 16, 16, 14, 14, 13, 13, 12, 11,
+        23, 24, 24, 24, 24, 21, 19, 18, 16, 16, 14, 14, 13, 13, 12, 11, 21, 23,
+        23, 22, 22, 20, 18, 17, 15, 15, 13, 13, 12, 12, 11, 11, 21, 23, 23, 22,
+        22, 20, 18, 17, 15, 15, 13, 13, 12, 12, 11, 11, 19, 21, 21, 21, 21, 19,
+        17, 17, 14, 14, 13, 13, 12, 11, 10, 10, 19, 20, 21, 20, 20, 19, 17, 16,
+        14, 14, 12, 12, 11, 11, 10, 10, 18, 19, 20, 20, 20, 18, 17, 16, 14, 14,
+        12, 12, 11, 11, 10, 9, 18, 19, 19, 19, 19, 18, 16, 15, 14, 13, 12, 12,
+        11, 10, 10, 9, 17, 18, 18, 18, 18, 17, 16, 15, 13, 13, 12, 12, 10, 10,
+        9, 9, 16, 17, 17, 17, 18, 16, 15, 14, 13, 13, 11, 11, 10, 10, 9, 9, 15,
+        17, 17, 17, 17, 16, 15, 14, 13, 12, 11, 11, 10, 10, 9, 9, 14, 16, 16,
+        16, 16, 15, 14, 13, 12, 12, 11, 11, 9, 9, 9, 8, 14, 16, 16, 16, 16, 15,
+        14, 13, 12, 12, 10, 10, 9, 9, 9, 8, 13, 14, 14, 14, 15, 14, 13, 12, 11,
+        11, 10, 10, 9, 9, 8, 8, 13, 14, 14, 14, 15, 14, 13, 12, 11, 11, 10, 10,
+        9, 9, 8, 8,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 64, 64, 64, 61, 60, 57, 57, 52, 51, 47, 45, 43, 39,
-        38, 35, 35, 32, 31, 29, 27, 26, 25, 25, 24, 23, 22, 22, 65, 64, 64, 63,
-        63, 63, 63, 62, 61, 60, 59, 59, 55, 53, 50, 48, 46, 43, 41, 38, 38, 34,
-        34, 31, 30, 28, 28, 27, 26, 25, 25, 24, 65, 64, 64, 63, 63, 62, 62, 61,
-        60, 59, 58, 58, 53, 53, 49, 47, 46, 42, 41, 38, 38, 34, 34, 32, 30, 28,
-        28, 27, 26, 25, 25, 24, 64, 63, 63, 62, 61, 60, 59, 58, 56, 55, 53, 53,
-        51, 49, 48, 46, 44, 42, 41, 38, 38, 35, 34, 32, 31, 29, 29, 28, 27, 26,
-        26, 25, 61, 61, 61, 61, 60, 59, 57, 56, 53, 53, 49, 49, 47, 46, 44, 42,
-        41, 39, 38, 36, 36, 33, 33, 31, 29, 28, 27, 27, 26, 25, 25, 25, 57, 58,
-        59, 59, 58, 56, 55, 53, 49, 48, 43, 43, 41, 40, 38, 37, 36, 35, 34, 32,
-        32, 30, 30, 28, 27, 26, 25, 25, 24, 24, 23, 22, 51, 52, 53, 54, 53, 52,
-        51, 50, 46, 45, 40, 40, 38, 37, 35, 34, 33, 32, 31, 29, 29, 27, 27, 26,
-        25, 24, 24, 23, 23, 22, 22, 23, 47, 48, 49, 50, 49, 49, 48, 48, 44, 43,
-        38, 38, 35, 34, 33, 32, 31, 29, 29, 27, 27, 26, 25, 24, 24, 23, 22, 22,
-        22, 21, 21, 19, 40, 41, 42, 43, 43, 43, 43, 43, 39, 39, 35, 35, 32, 32,
-        29, 28, 28, 26, 26, 25, 24, 23, 23, 22, 21, 20, 20, 20, 19, 19, 19, 20,
-        38, 40, 40, 41, 41, 41, 41, 41, 38, 38, 34, 34, 32, 31, 29, 28, 27, 25,
-        25, 24, 24, 22, 22, 21, 20, 20, 20, 19, 19, 18, 18, 17, 31, 33, 33, 34,
-        34, 35, 35, 35, 33, 33, 30, 30, 28, 27, 26, 25, 24, 23, 22, 21, 21, 20,
-        19, 18, 18, 17, 17, 17, 17, 17, 17, 18, 31, 32, 33, 34, 34, 34, 34, 35,
-        33, 32, 30, 29, 27, 27, 25, 25, 24, 23, 22, 21, 21, 19, 19, 18, 18, 17,
-        17, 17, 16, 16, 16, 15, 26, 27, 27, 28, 29, 29, 29, 30, 28, 28, 26, 26,
-        24, 24, 23, 22, 21, 20, 20, 19, 19, 17, 17, 16, 16, 15, 15, 15, 15, 14,
-        15, 16, 25, 26, 27, 28, 28, 28, 29, 29, 27, 27, 26, 25, 24, 24, 22, 22,
-        21, 20, 20, 18, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 14, 13, 23, 24,
-        25, 26, 26, 26, 26, 27, 26, 25, 24, 24, 23, 23, 21, 21, 20, 20, 18, 18,
-        17, 17, 16, 15, 15, 14, 14, 14, 14, 13, 13, 14, 22, 23, 23, 25, 24, 25,
-        25, 26, 26, 24, 24, 22, 23, 21, 22, 19, 20, 18, 19, 17, 18, 16, 17, 15,
-        16, 14, 15, 13, 14, 13, 14, 13,
+        32, 33, 33, 33, 33, 33, 32, 32, 32, 32, 30, 30, 29, 28, 27, 26, 25, 23,
+        23, 21, 21, 19, 19, 18, 18, 17, 16, 15, 14, 14, 13, 13, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 30, 30, 30, 29, 28, 27, 26, 25, 24, 23, 23, 21,
+        20, 19, 19, 18, 17, 17, 16, 16, 14, 14, 33, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 30, 30, 30, 30, 28, 28, 26, 25, 24, 23, 23, 21, 21, 20, 19, 18,
+        17, 17, 16, 16, 14, 14, 32, 32, 32, 32, 32, 31, 31, 30, 30, 30, 28, 28,
+        28, 28, 27, 26, 25, 24, 24, 22, 22, 21, 20, 20, 19, 18, 17, 17, 16, 16,
+        14, 14, 32, 32, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26,
+        25, 24, 24, 22, 22, 21, 20, 20, 19, 18, 18, 17, 16, 16, 15, 15, 30, 30,
+        30, 31, 31, 30, 29, 29, 28, 28, 26, 26, 24, 24, 23, 23, 22, 21, 21, 20,
+        20, 19, 19, 18, 18, 17, 16, 16, 15, 15, 14, 14, 28, 29, 29, 29, 30, 29,
+        28, 28, 27, 26, 24, 24, 22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 17,
+        16, 16, 15, 15, 14, 14, 13, 13, 27, 28, 28, 28, 28, 28, 27, 27, 26, 26,
+        23, 23, 21, 21, 20, 20, 19, 18, 18, 17, 17, 17, 16, 16, 15, 15, 14, 14,
+        13, 13, 12, 12, 23, 24, 24, 25, 25, 25, 24, 24, 24, 24, 21, 21, 20, 19,
+        18, 18, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 13, 12, 12, 11, 11,
+        23, 24, 24, 24, 25, 24, 24, 24, 24, 23, 21, 21, 19, 19, 18, 18, 17, 16,
+        16, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 19, 20, 20, 20,
+        21, 21, 20, 21, 21, 20, 19, 19, 17, 17, 16, 16, 15, 14, 14, 13, 13, 13,
+        12, 12, 12, 12, 11, 11, 11, 10, 10, 10, 19, 20, 20, 20, 21, 21, 20, 21,
+        21, 20, 19, 19, 17, 17, 16, 16, 15, 14, 14, 13, 13, 13, 12, 12, 12, 12,
+        11, 11, 11, 10, 10, 10, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 17, 17,
+        16, 16, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9,
+        9, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 16, 16, 15, 15, 14, 14, 13,
+        13, 13, 12, 12, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 14, 15, 15, 15,
+        16, 16, 16, 16, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 11, 11, 10,
+        10, 10, 10, 9, 9, 9, 9, 9, 8, 8, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15,
+        14, 14, 13, 13, 13, 12, 12, 11, 11, 11, 11, 10, 10, 9, 9, 9, 9, 9, 8, 8,
+        8, 8,
         /* Size 4x16 */
-        65, 57, 38, 25, 64, 59, 40, 27, 63, 58, 41, 28, 63, 55, 41, 29, 61, 49,
-        38, 27, 59, 43, 34, 26, 55, 41, 32, 24, 50, 38, 29, 22, 46, 36, 27, 21,
-        41, 34, 25, 20, 38, 32, 24, 18, 34, 30, 22, 17, 30, 27, 20, 16, 28, 25,
-        20, 15, 26, 24, 19, 14, 25, 23, 18, 14,
+        33, 30, 23, 16, 32, 30, 24, 17, 32, 31, 25, 17, 32, 29, 24, 17, 32, 28,
+        24, 18, 30, 26, 21, 16, 30, 24, 19, 15, 28, 23, 18, 14, 26, 22, 17, 13,
+        24, 21, 16, 13, 23, 20, 15, 12, 20, 19, 14, 11, 19, 18, 13, 10, 17, 16,
+        13, 10, 16, 15, 12, 9, 14, 14, 11, 9,
         /* Size 16x4 */
-        65, 64, 63, 63, 61, 59, 55, 50, 46, 41, 38, 34, 30, 28, 26, 25, 57, 59,
-        58, 55, 49, 43, 41, 38, 36, 34, 32, 30, 27, 25, 24, 23, 38, 40, 41, 41,
-        38, 34, 32, 29, 27, 25, 24, 22, 20, 20, 19, 18, 25, 27, 28, 29, 27, 26,
-        24, 22, 21, 20, 18, 17, 16, 15, 14, 14,
+        33, 32, 32, 32, 32, 30, 30, 28, 26, 24, 23, 20, 19, 17, 16, 14, 30, 30,
+        31, 29, 28, 26, 24, 23, 22, 21, 20, 19, 18, 16, 15, 14, 23, 24, 25, 24,
+        24, 21, 19, 18, 17, 16, 15, 14, 13, 13, 12, 11, 16, 17, 17, 17, 18, 16,
+        15, 14, 13, 13, 12, 11, 10, 10, 9, 9,
         /* Size 8x32 */
-        64, 65, 61, 51, 40, 31, 26, 23, 65, 64, 61, 52, 41, 33, 27, 24, 65, 64,
-        61, 53, 42, 33, 27, 25, 65, 63, 61, 54, 43, 34, 28, 26, 65, 63, 60, 53,
-        43, 34, 29, 26, 64, 62, 59, 52, 43, 35, 29, 26, 64, 62, 57, 51, 43, 35,
-        29, 26, 64, 61, 56, 50, 43, 35, 30, 27, 61, 60, 53, 46, 39, 33, 28, 26,
-        60, 59, 53, 45, 39, 33, 28, 25, 57, 58, 49, 40, 35, 30, 26, 24, 57, 58,
-        49, 40, 35, 30, 26, 24, 52, 53, 47, 38, 32, 28, 24, 23, 51, 53, 46, 37,
-        32, 27, 24, 23, 47, 49, 44, 35, 29, 26, 23, 21, 45, 47, 42, 34, 28, 25,
-        22, 21, 43, 46, 41, 33, 28, 24, 21, 20, 39, 42, 39, 32, 26, 23, 20, 20,
-        38, 41, 38, 31, 26, 22, 20, 18, 35, 38, 36, 29, 25, 21, 19, 18, 35, 38,
-        36, 29, 24, 21, 19, 17, 32, 34, 33, 27, 23, 20, 17, 17, 31, 34, 33, 27,
-        23, 19, 17, 16, 29, 32, 31, 26, 22, 18, 16, 15, 27, 30, 29, 25, 21, 18,
-        16, 15, 26, 28, 28, 24, 20, 17, 15, 14, 25, 28, 27, 24, 20, 17, 15, 14,
-        25, 27, 27, 23, 20, 17, 15, 14, 24, 26, 26, 23, 19, 17, 15, 14, 23, 25,
-        25, 22, 19, 17, 14, 13, 22, 25, 25, 22, 19, 17, 15, 13, 22, 24, 25, 23,
-        20, 18, 16, 14,
+        32, 33, 32, 28, 23, 19, 17, 14, 33, 32, 32, 29, 24, 20, 17, 15, 33, 32,
+        32, 29, 24, 20, 17, 15, 33, 32, 32, 29, 25, 20, 18, 15, 33, 32, 31, 30,
+        25, 21, 18, 16, 33, 32, 31, 29, 25, 21, 18, 16, 32, 32, 30, 28, 24, 20,
+        18, 16, 32, 32, 30, 28, 24, 21, 18, 16, 32, 31, 29, 27, 24, 21, 18, 16,
+        32, 31, 29, 26, 24, 20, 18, 16, 30, 30, 28, 24, 21, 19, 17, 15, 30, 30,
+        28, 24, 21, 19, 17, 15, 29, 30, 27, 22, 20, 17, 16, 14, 28, 30, 27, 21,
+        19, 17, 16, 14, 27, 28, 26, 21, 18, 16, 15, 13, 26, 28, 26, 20, 18, 16,
+        14, 13, 25, 26, 25, 20, 17, 15, 14, 13, 23, 25, 24, 19, 16, 14, 13, 12,
+        23, 24, 24, 19, 16, 14, 13, 12, 21, 23, 22, 18, 15, 13, 12, 11, 21, 23,
+        22, 18, 15, 13, 12, 11, 19, 21, 21, 17, 14, 13, 12, 10, 19, 21, 20, 17,
+        14, 12, 11, 10, 18, 20, 20, 17, 14, 12, 11, 10, 18, 19, 19, 16, 14, 12,
+        11, 10, 17, 18, 18, 16, 13, 12, 10, 9, 16, 17, 18, 15, 13, 11, 10, 9,
+        15, 17, 17, 15, 13, 11, 10, 9, 14, 16, 16, 14, 12, 11, 9, 9, 14, 16, 16,
+        14, 12, 10, 9, 9, 13, 14, 15, 13, 11, 10, 9, 8, 13, 14, 15, 13, 11, 10,
+        9, 8,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 64, 64, 64, 61, 60, 57, 57, 52, 51, 47, 45, 43, 39,
-        38, 35, 35, 32, 31, 29, 27, 26, 25, 25, 24, 23, 22, 22, 65, 64, 64, 63,
-        63, 62, 62, 61, 60, 59, 58, 58, 53, 53, 49, 47, 46, 42, 41, 38, 38, 34,
-        34, 32, 30, 28, 28, 27, 26, 25, 25, 24, 61, 61, 61, 61, 60, 59, 57, 56,
-        53, 53, 49, 49, 47, 46, 44, 42, 41, 39, 38, 36, 36, 33, 33, 31, 29, 28,
-        27, 27, 26, 25, 25, 25, 51, 52, 53, 54, 53, 52, 51, 50, 46, 45, 40, 40,
-        38, 37, 35, 34, 33, 32, 31, 29, 29, 27, 27, 26, 25, 24, 24, 23, 23, 22,
-        22, 23, 40, 41, 42, 43, 43, 43, 43, 43, 39, 39, 35, 35, 32, 32, 29, 28,
-        28, 26, 26, 25, 24, 23, 23, 22, 21, 20, 20, 20, 19, 19, 19, 20, 31, 33,
-        33, 34, 34, 35, 35, 35, 33, 33, 30, 30, 28, 27, 26, 25, 24, 23, 22, 21,
-        21, 20, 19, 18, 18, 17, 17, 17, 17, 17, 17, 18, 26, 27, 27, 28, 29, 29,
-        29, 30, 28, 28, 26, 26, 24, 24, 23, 22, 21, 20, 20, 19, 19, 17, 17, 16,
-        16, 15, 15, 15, 15, 14, 15, 16, 23, 24, 25, 26, 26, 26, 26, 27, 26, 25,
-        24, 24, 23, 23, 21, 21, 20, 20, 18, 18, 17, 17, 16, 15, 15, 14, 14, 14,
-        14, 13, 13, 14 },
+        32, 33, 33, 33, 33, 33, 32, 32, 32, 32, 30, 30, 29, 28, 27, 26, 25, 23,
+        23, 21, 21, 19, 19, 18, 18, 17, 16, 15, 14, 14, 13, 13, 33, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 30, 30, 30, 30, 28, 28, 26, 25, 24, 23, 23, 21,
+        21, 20, 19, 18, 17, 17, 16, 16, 14, 14, 32, 32, 32, 32, 31, 31, 30, 30,
+        29, 29, 28, 28, 27, 27, 26, 26, 25, 24, 24, 22, 22, 21, 20, 20, 19, 18,
+        18, 17, 16, 16, 15, 15, 28, 29, 29, 29, 30, 29, 28, 28, 27, 26, 24, 24,
+        22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 15, 15, 14, 14,
+        13, 13, 23, 24, 24, 25, 25, 25, 24, 24, 24, 24, 21, 21, 20, 19, 18, 18,
+        17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 13, 12, 12, 11, 11, 19, 20,
+        20, 20, 21, 21, 20, 21, 21, 20, 19, 19, 17, 17, 16, 16, 15, 14, 14, 13,
+        13, 13, 12, 12, 12, 12, 11, 11, 11, 10, 10, 10, 17, 17, 17, 18, 18, 18,
+        18, 18, 18, 18, 17, 17, 16, 16, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11,
+        11, 10, 10, 10, 9, 9, 9, 9, 14, 15, 15, 15, 16, 16, 16, 16, 16, 16, 15,
+        15, 14, 14, 13, 13, 13, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 9,
+        8, 8 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        43, 39, 39, 25,
+        25, 21, 21, 15,
 #endif
         /* Size 4x4 */
-        64, 44, 41, 35, 44, 39, 37, 33, 41, 37, 29, 26, 35, 33, 26, 22,
+        33, 24, 22, 19, 24, 21, 20, 19, 22, 20, 17, 15, 19, 19, 15, 13,
         /* Size 8x8 */
-        65, 59, 48, 44, 41, 38, 34, 32, 59, 53, 46, 45, 43, 40, 36, 34, 48, 46,
-        42, 41, 41, 38, 36, 34, 44, 45, 41, 37, 35, 34, 32, 31, 41, 43, 41, 35,
-        32, 29, 28, 27, 38, 40, 38, 34, 29, 27, 25, 25, 34, 36, 36, 32, 28, 25,
-        23, 22, 32, 34, 34, 31, 27, 25, 22, 21,
+        33, 32, 27, 21, 22, 20, 19, 18, 32, 29, 24, 22, 23, 22, 20, 19, 27, 24,
+        22, 21, 23, 22, 21, 20, 21, 22, 21, 19, 19, 19, 18, 18, 22, 23, 23, 19,
+        18, 17, 16, 16, 20, 22, 22, 19, 17, 16, 15, 14, 19, 20, 21, 18, 16, 15,
+        14, 13, 18, 19, 20, 18, 16, 14, 13, 12,
         /* Size 16x16 */
-        64, 66, 65, 58, 51, 42, 42, 42, 41, 39, 38, 36, 33, 32, 31, 30, 66, 65,
-        63, 55, 49, 43, 44, 44, 43, 41, 40, 38, 36, 34, 33, 32, 65, 63, 59, 52,
-        48, 44, 45, 46, 44, 43, 41, 39, 37, 36, 34, 33, 58, 55, 52, 47, 45, 43,
-        44, 45, 44, 44, 42, 40, 38, 37, 36, 34, 51, 49, 48, 45, 43, 41, 42, 42,
-        42, 41, 40, 39, 37, 36, 35, 34, 42, 43, 44, 43, 41, 39, 39, 38, 38, 38,
-        37, 36, 34, 34, 33, 33, 42, 44, 45, 44, 42, 39, 38, 37, 36, 36, 35, 34,
-        33, 32, 31, 31, 42, 44, 46, 45, 42, 38, 37, 35, 34, 33, 33, 32, 31, 30,
-        30, 29, 41, 43, 44, 44, 42, 38, 36, 34, 33, 32, 32, 30, 29, 29, 28, 28,
-        39, 41, 43, 44, 41, 38, 36, 33, 32, 31, 30, 29, 28, 27, 27, 26, 38, 40,
-        41, 42, 40, 37, 35, 33, 32, 30, 29, 28, 27, 26, 26, 25, 36, 38, 39, 40,
-        39, 36, 34, 32, 30, 29, 28, 26, 25, 25, 24, 23, 33, 36, 37, 38, 37, 34,
-        33, 31, 29, 28, 27, 25, 24, 23, 23, 22, 32, 34, 36, 37, 36, 34, 32, 30,
-        29, 27, 26, 25, 23, 23, 22, 21, 31, 33, 34, 36, 35, 33, 31, 30, 28, 27,
-        26, 24, 23, 22, 22, 21, 30, 32, 33, 34, 34, 33, 31, 29, 28, 26, 25, 23,
-        22, 21, 21, 21,
+        32, 33, 34, 31, 28, 25, 22, 21, 21, 21, 20, 20, 19, 18, 17, 16, 33, 33,
+        33, 30, 27, 24, 22, 22, 22, 22, 21, 20, 20, 19, 18, 17, 34, 33, 32, 29,
+        26, 24, 23, 22, 23, 23, 22, 22, 21, 20, 19, 18, 31, 30, 29, 26, 24, 23,
+        22, 22, 22, 23, 22, 22, 21, 20, 19, 18, 28, 27, 26, 24, 22, 22, 22, 22,
+        22, 23, 22, 22, 21, 20, 20, 19, 25, 24, 24, 23, 22, 21, 20, 20, 21, 21,
+        20, 20, 20, 19, 19, 18, 22, 22, 23, 22, 22, 20, 20, 20, 20, 20, 19, 19,
+        19, 18, 18, 17, 21, 22, 22, 22, 22, 20, 20, 19, 19, 19, 19, 18, 18, 18,
+        17, 17, 21, 22, 23, 22, 22, 21, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16,
+        21, 22, 23, 23, 23, 21, 20, 19, 18, 17, 17, 17, 16, 16, 16, 15, 20, 21,
+        22, 22, 22, 20, 19, 19, 18, 17, 17, 16, 16, 15, 15, 14, 20, 20, 22, 22,
+        22, 20, 19, 18, 17, 17, 16, 16, 15, 15, 14, 14, 19, 20, 21, 21, 21, 20,
+        19, 18, 17, 16, 16, 15, 14, 14, 14, 13, 18, 19, 20, 20, 20, 19, 18, 18,
+        17, 16, 15, 15, 14, 13, 13, 12, 17, 18, 19, 19, 20, 19, 18, 17, 16, 16,
+        15, 14, 14, 13, 12, 12, 16, 17, 18, 18, 19, 18, 17, 17, 16, 15, 14, 14,
+        13, 12, 12, 12,
         /* Size 32x32 */
-        64, 66, 66, 67, 65, 61, 58, 56, 51, 49, 42, 42, 42, 42, 42, 41, 41, 39,
-        39, 38, 38, 36, 36, 34, 33, 32, 32, 32, 31, 30, 30, 29, 66, 65, 65, 66,
-        63, 59, 55, 53, 49, 48, 43, 43, 44, 44, 44, 43, 42, 41, 41, 39, 39, 38,
-        37, 36, 35, 34, 34, 33, 33, 32, 32, 31, 66, 65, 65, 65, 63, 59, 55, 53,
-        49, 48, 43, 43, 44, 44, 44, 43, 43, 42, 41, 40, 40, 38, 38, 36, 36, 34,
-        34, 34, 33, 32, 32, 31, 67, 66, 65, 64, 62, 58, 54, 51, 49, 48, 44, 44,
-        45, 45, 46, 45, 44, 43, 43, 41, 41, 39, 39, 38, 37, 36, 35, 35, 34, 34,
-        33, 33, 65, 63, 63, 62, 59, 55, 52, 49, 48, 47, 44, 44, 45, 45, 46, 45,
-        44, 43, 43, 41, 41, 40, 39, 38, 37, 36, 36, 35, 34, 34, 33, 33, 61, 59,
-        59, 58, 55, 53, 49, 47, 46, 46, 43, 44, 44, 45, 45, 45, 44, 43, 43, 42,
-        41, 40, 40, 38, 38, 36, 36, 36, 35, 34, 34, 34, 58, 55, 55, 54, 52, 49,
-        47, 45, 45, 44, 43, 43, 44, 45, 45, 45, 44, 44, 44, 42, 42, 41, 40, 39,
-        38, 37, 37, 36, 36, 35, 34, 33, 56, 53, 53, 51, 49, 47, 45, 43, 43, 43,
-        43, 43, 44, 45, 45, 45, 45, 44, 44, 43, 42, 41, 41, 39, 39, 38, 37, 37,
-        36, 36, 35, 35, 51, 49, 49, 49, 48, 46, 45, 43, 43, 42, 41, 41, 42, 42,
-        42, 42, 42, 41, 41, 40, 40, 39, 39, 38, 37, 36, 36, 35, 35, 34, 34, 35,
-        49, 48, 48, 48, 47, 46, 44, 43, 42, 42, 41, 41, 41, 41, 42, 41, 41, 41,
-        41, 39, 39, 38, 38, 37, 37, 36, 35, 35, 34, 34, 33, 32, 42, 43, 43, 44,
-        44, 43, 43, 43, 41, 41, 39, 39, 39, 38, 38, 38, 38, 38, 38, 37, 37, 36,
-        36, 35, 34, 34, 34, 33, 33, 33, 33, 33, 42, 43, 43, 44, 44, 44, 43, 43,
-        41, 41, 39, 39, 38, 38, 38, 38, 38, 38, 38, 37, 37, 36, 36, 35, 34, 34,
-        33, 33, 33, 32, 32, 31, 42, 44, 44, 45, 45, 44, 44, 44, 42, 41, 39, 38,
-        38, 38, 37, 37, 36, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 32, 31, 31,
-        31, 32, 42, 44, 44, 45, 45, 45, 45, 45, 42, 41, 38, 38, 38, 37, 36, 36,
-        36, 35, 35, 34, 34, 34, 33, 33, 32, 32, 31, 31, 31, 31, 31, 29, 42, 44,
-        44, 46, 46, 45, 45, 45, 42, 42, 38, 38, 37, 36, 35, 35, 34, 34, 33, 33,
-        33, 32, 32, 31, 31, 30, 30, 30, 30, 29, 29, 30, 41, 43, 43, 45, 45, 45,
-        45, 45, 42, 41, 38, 38, 37, 36, 35, 34, 34, 33, 33, 32, 32, 31, 31, 31,
-        30, 30, 29, 29, 29, 29, 29, 28, 41, 42, 43, 44, 44, 44, 44, 45, 42, 41,
-        38, 38, 36, 36, 34, 34, 33, 33, 32, 32, 32, 31, 30, 30, 29, 29, 29, 29,
-        28, 28, 28, 29, 39, 41, 42, 43, 43, 43, 44, 44, 41, 41, 38, 38, 36, 35,
-        34, 33, 33, 32, 31, 30, 30, 29, 29, 29, 28, 28, 28, 27, 27, 27, 28, 26,
-        39, 41, 41, 43, 43, 43, 44, 44, 41, 41, 38, 38, 36, 35, 33, 33, 32, 31,
-        31, 30, 30, 29, 29, 28, 28, 27, 27, 27, 27, 26, 26, 27, 38, 39, 40, 41,
-        41, 42, 42, 43, 40, 39, 37, 37, 35, 34, 33, 32, 32, 30, 30, 29, 29, 28,
-        28, 27, 27, 26, 26, 26, 26, 26, 26, 25, 38, 39, 40, 41, 41, 41, 42, 42,
-        40, 39, 37, 37, 35, 34, 33, 32, 32, 30, 30, 29, 29, 28, 28, 27, 27, 26,
-        26, 26, 26, 25, 25, 26, 36, 38, 38, 39, 40, 40, 41, 41, 39, 38, 36, 36,
-        34, 34, 32, 31, 31, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 25, 24, 25,
-        25, 24, 36, 37, 38, 39, 39, 40, 40, 41, 39, 38, 36, 36, 34, 33, 32, 31,
-        30, 29, 29, 28, 28, 27, 26, 26, 25, 25, 25, 25, 24, 24, 23, 25, 34, 36,
-        36, 38, 38, 38, 39, 39, 38, 37, 35, 35, 33, 33, 31, 31, 30, 29, 28, 27,
-        27, 26, 26, 25, 25, 24, 24, 24, 23, 23, 24, 22, 33, 35, 36, 37, 37, 38,
-        38, 39, 37, 37, 34, 34, 33, 32, 31, 30, 29, 28, 28, 27, 27, 26, 25, 25,
-        24, 24, 23, 23, 23, 23, 22, 24, 32, 34, 34, 36, 36, 36, 37, 38, 36, 36,
-        34, 34, 32, 32, 30, 30, 29, 28, 27, 26, 26, 25, 25, 24, 24, 23, 23, 23,
-        22, 22, 23, 22, 32, 34, 34, 35, 36, 36, 37, 37, 36, 35, 34, 33, 32, 31,
-        30, 29, 29, 28, 27, 26, 26, 25, 25, 24, 23, 23, 23, 23, 22, 22, 21, 23,
-        32, 33, 34, 35, 35, 36, 36, 37, 35, 35, 33, 33, 32, 31, 30, 29, 29, 27,
-        27, 26, 26, 25, 25, 24, 23, 23, 23, 22, 22, 22, 22, 20, 31, 33, 33, 34,
-        34, 35, 36, 36, 35, 34, 33, 33, 31, 31, 30, 29, 28, 27, 27, 26, 26, 24,
-        24, 23, 23, 22, 22, 22, 22, 22, 21, 22, 30, 32, 32, 34, 34, 34, 35, 36,
-        34, 34, 33, 32, 31, 31, 29, 29, 28, 27, 26, 26, 25, 25, 24, 23, 23, 22,
-        22, 22, 22, 21, 21, 21, 30, 32, 32, 33, 33, 34, 34, 35, 34, 33, 33, 32,
-        31, 31, 29, 29, 28, 28, 26, 26, 25, 25, 23, 24, 22, 23, 21, 22, 21, 21,
-        21, 21, 29, 31, 31, 33, 33, 34, 33, 35, 35, 32, 33, 31, 32, 29, 30, 28,
-        29, 26, 27, 25, 26, 24, 25, 22, 24, 22, 23, 20, 22, 21, 21, 20,
+        32, 33, 33, 34, 34, 32, 31, 30, 28, 28, 25, 25, 22, 21, 21, 21, 21, 21,
+        21, 20, 20, 20, 20, 19, 19, 18, 18, 18, 17, 17, 16, 16, 33, 33, 33, 33,
+        33, 32, 30, 29, 27, 27, 24, 24, 22, 21, 22, 22, 22, 22, 22, 21, 21, 20,
+        20, 20, 20, 19, 19, 19, 18, 18, 17, 17, 33, 33, 33, 33, 33, 31, 30, 29,
+        27, 26, 24, 24, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 19,
+        19, 19, 18, 18, 17, 17, 34, 33, 33, 33, 33, 31, 29, 28, 26, 26, 24, 24,
+        22, 22, 22, 22, 22, 23, 22, 22, 22, 21, 21, 20, 20, 20, 20, 19, 19, 19,
+        18, 18, 34, 33, 33, 33, 32, 31, 29, 28, 26, 26, 24, 24, 23, 22, 22, 23,
+        23, 23, 23, 22, 22, 22, 22, 21, 21, 20, 20, 20, 19, 19, 18, 18, 32, 32,
+        31, 31, 31, 29, 28, 27, 25, 24, 24, 24, 22, 22, 22, 22, 23, 23, 23, 22,
+        22, 22, 22, 21, 21, 20, 20, 20, 19, 19, 18, 18, 31, 30, 30, 29, 29, 28,
+        26, 26, 24, 24, 23, 23, 22, 22, 22, 22, 22, 23, 23, 22, 22, 22, 22, 21,
+        21, 20, 20, 20, 19, 19, 18, 18, 30, 29, 29, 28, 28, 27, 26, 25, 23, 23,
+        23, 23, 22, 22, 22, 22, 22, 23, 23, 22, 22, 22, 22, 21, 21, 20, 20, 20,
+        19, 19, 19, 19, 28, 27, 27, 26, 26, 25, 24, 23, 22, 22, 22, 22, 22, 21,
+        22, 22, 22, 23, 23, 22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 20, 19, 19,
+        28, 27, 26, 26, 26, 24, 24, 23, 22, 22, 22, 22, 21, 21, 22, 22, 22, 23,
+        22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 20, 19, 19, 25, 24, 24, 24,
+        24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 20, 21, 21, 21, 21, 20, 20, 20,
+        20, 20, 20, 20, 19, 19, 19, 19, 18, 18, 25, 24, 24, 24, 24, 24, 23, 23,
+        22, 22, 21, 21, 20, 20, 20, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20,
+        19, 19, 19, 19, 18, 18, 22, 22, 22, 22, 23, 22, 22, 22, 22, 21, 20, 20,
+        20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18,
+        17, 17, 21, 21, 22, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 17, 17, 21, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19,
+        19, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, 17, 21, 22, 22, 22, 23, 22,
+        22, 22, 22, 22, 21, 21, 20, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18,
+        18, 17, 17, 17, 17, 17, 16, 16, 21, 22, 22, 22, 23, 23, 22, 22, 22, 22,
+        21, 21, 20, 19, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17,
+        16, 16, 16, 16, 21, 22, 22, 23, 23, 23, 23, 23, 23, 23, 21, 21, 20, 19,
+        19, 19, 18, 18, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 15, 15,
+        21, 22, 22, 22, 23, 23, 23, 23, 23, 22, 21, 21, 20, 19, 19, 18, 18, 17,
+        17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 15, 15, 20, 21, 21, 22,
+        22, 22, 22, 22, 22, 22, 20, 20, 19, 19, 19, 18, 18, 17, 17, 17, 17, 16,
+        16, 16, 16, 16, 15, 15, 15, 15, 14, 14, 20, 21, 21, 22, 22, 22, 22, 22,
+        22, 22, 20, 20, 19, 19, 19, 18, 18, 17, 17, 17, 17, 16, 16, 16, 16, 16,
+        15, 15, 15, 15, 14, 14, 20, 20, 21, 21, 22, 22, 22, 22, 22, 22, 20, 20,
+        19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14,
+        14, 14, 20, 20, 20, 21, 22, 22, 22, 22, 22, 22, 20, 20, 19, 19, 18, 18,
+        17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 19, 20,
+        20, 20, 21, 21, 21, 21, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16,
+        16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 19, 20, 20, 20, 21, 21,
+        21, 21, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 16, 15, 15, 15,
+        14, 14, 14, 14, 14, 13, 13, 13, 18, 19, 19, 20, 20, 20, 20, 20, 21, 21,
+        20, 20, 19, 18, 18, 17, 17, 16, 16, 16, 16, 15, 15, 14, 14, 14, 14, 14,
+        13, 13, 13, 13, 18, 19, 19, 20, 20, 20, 20, 20, 20, 20, 19, 19, 18, 18,
+        18, 17, 17, 16, 16, 15, 15, 15, 15, 14, 14, 14, 13, 13, 13, 13, 12, 12,
+        18, 19, 19, 19, 20, 20, 20, 20, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16,
+        16, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 17, 18, 18, 19,
+        19, 19, 19, 19, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 16, 15, 15, 14,
+        14, 14, 14, 13, 13, 13, 12, 12, 12, 12, 17, 18, 18, 19, 19, 19, 19, 19,
+        20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 16, 15, 15, 14, 14, 14, 13, 13,
+        13, 13, 12, 12, 12, 12, 16, 17, 17, 18, 18, 18, 18, 19, 19, 19, 18, 18,
+        17, 17, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 13, 12, 12, 12, 12,
+        12, 12, 16, 17, 17, 18, 18, 18, 18, 19, 19, 19, 18, 18, 17, 17, 17, 16,
+        16, 15, 15, 14, 14, 14, 14, 13, 13, 13, 12, 12, 12, 12, 12, 12,
         /* Size 4x8 */
-        65, 44, 41, 34, 57, 44, 43, 36, 48, 41, 41, 35, 45, 39, 35, 31, 43, 38,
-        31, 28, 39, 36, 29, 25, 36, 34, 27, 23, 33, 32, 26, 22,
+        33, 24, 22, 19, 31, 23, 23, 20, 26, 22, 22, 20, 22, 20, 19, 18, 23, 21,
+        17, 16, 21, 20, 17, 15, 20, 20, 16, 14, 19, 19, 16, 13,
         /* Size 8x4 */
-        65, 57, 48, 45, 43, 39, 36, 33, 44, 44, 41, 39, 38, 36, 34, 32, 41, 43,
-        41, 35, 31, 29, 27, 26, 34, 36, 35, 31, 28, 25, 23, 22,
+        33, 31, 26, 22, 23, 21, 20, 19, 24, 23, 22, 20, 21, 20, 20, 19, 22, 23,
+        22, 19, 17, 17, 16, 16, 19, 20, 20, 18, 16, 15, 14, 13,
         /* Size 8x16 */
-        64, 64, 51, 42, 40, 36, 32, 30, 66, 62, 49, 44, 42, 38, 34, 32, 65, 59,
-        48, 45, 43, 40, 36, 34, 58, 52, 45, 44, 44, 41, 37, 35, 50, 48, 43, 42,
-        41, 39, 36, 34, 42, 44, 41, 38, 38, 36, 34, 33, 42, 45, 42, 38, 36, 34,
-        32, 31, 42, 45, 42, 36, 34, 32, 30, 29, 41, 44, 41, 36, 33, 31, 29, 28,
-        39, 43, 41, 35, 31, 29, 27, 26, 38, 41, 40, 34, 31, 28, 26, 25, 36, 39,
-        39, 34, 29, 27, 25, 24, 34, 37, 37, 32, 28, 26, 24, 23, 32, 35, 35, 32,
-        28, 25, 23, 22, 31, 34, 34, 31, 27, 24, 22, 22, 30, 33, 34, 31, 27, 25,
-        22, 21,
+        32, 33, 28, 21, 21, 20, 18, 17, 33, 33, 27, 22, 22, 20, 19, 18, 34, 32,
+        26, 22, 23, 21, 20, 19, 31, 28, 24, 22, 22, 22, 20, 19, 28, 26, 22, 22,
+        23, 22, 21, 20, 24, 24, 22, 20, 21, 20, 19, 18, 22, 22, 21, 20, 19, 19,
+        19, 18, 21, 22, 22, 19, 19, 18, 18, 17, 21, 23, 22, 19, 18, 17, 17, 16,
+        21, 23, 22, 19, 18, 17, 16, 16, 20, 22, 22, 19, 17, 16, 16, 15, 20, 21,
+        22, 19, 17, 16, 15, 14, 19, 20, 21, 19, 17, 15, 14, 13, 18, 20, 20, 18,
+        16, 15, 14, 13, 17, 19, 20, 18, 16, 14, 13, 12, 16, 18, 19, 17, 15, 14,
+        13, 12,
         /* Size 16x8 */
-        64, 66, 65, 58, 50, 42, 42, 42, 41, 39, 38, 36, 34, 32, 31, 30, 64, 62,
-        59, 52, 48, 44, 45, 45, 44, 43, 41, 39, 37, 35, 34, 33, 51, 49, 48, 45,
-        43, 41, 42, 42, 41, 41, 40, 39, 37, 35, 34, 34, 42, 44, 45, 44, 42, 38,
-        38, 36, 36, 35, 34, 34, 32, 32, 31, 31, 40, 42, 43, 44, 41, 38, 36, 34,
-        33, 31, 31, 29, 28, 28, 27, 27, 36, 38, 40, 41, 39, 36, 34, 32, 31, 29,
-        28, 27, 26, 25, 24, 25, 32, 34, 36, 37, 36, 34, 32, 30, 29, 27, 26, 25,
-        24, 23, 22, 22, 30, 32, 34, 35, 34, 33, 31, 29, 28, 26, 25, 24, 23, 22,
-        22, 21,
+        32, 33, 34, 31, 28, 24, 22, 21, 21, 21, 20, 20, 19, 18, 17, 16, 33, 33,
+        32, 28, 26, 24, 22, 22, 23, 23, 22, 21, 20, 20, 19, 18, 28, 27, 26, 24,
+        22, 22, 21, 22, 22, 22, 22, 22, 21, 20, 20, 19, 21, 22, 22, 22, 22, 20,
+        20, 19, 19, 19, 19, 19, 19, 18, 18, 17, 21, 22, 23, 22, 23, 21, 19, 19,
+        18, 18, 17, 17, 17, 16, 16, 15, 20, 20, 21, 22, 22, 20, 19, 18, 17, 17,
+        16, 16, 15, 15, 14, 14, 18, 19, 20, 20, 21, 19, 19, 18, 17, 16, 16, 15,
+        14, 14, 13, 13, 17, 18, 19, 19, 20, 18, 18, 17, 16, 16, 15, 14, 13, 13,
+        12, 12,
         /* Size 16x32 */
-        64, 66, 64, 55, 51, 43, 42, 42, 40, 39, 36, 35, 32, 32, 30, 29, 65, 65,
-        62, 53, 49, 44, 44, 44, 41, 41, 38, 37, 34, 34, 32, 31, 66, 65, 62, 53,
-        49, 44, 44, 44, 42, 41, 38, 38, 34, 34, 32, 31, 67, 64, 61, 51, 49, 45,
-        45, 45, 43, 43, 39, 39, 36, 35, 34, 33, 65, 61, 59, 50, 48, 44, 45, 45,
-        43, 43, 40, 39, 36, 36, 34, 33, 61, 57, 55, 48, 46, 44, 44, 45, 43, 43,
-        40, 39, 37, 36, 34, 34, 58, 53, 52, 45, 45, 43, 44, 45, 44, 43, 41, 40,
-        37, 37, 35, 34, 55, 51, 49, 44, 43, 43, 44, 45, 44, 44, 41, 41, 38, 37,
-        36, 35, 50, 48, 48, 43, 43, 41, 42, 42, 41, 41, 39, 39, 36, 36, 34, 35,
-        49, 48, 47, 43, 42, 41, 41, 41, 41, 41, 38, 38, 36, 35, 34, 32, 42, 44,
-        44, 43, 41, 39, 38, 38, 38, 38, 36, 36, 34, 34, 33, 33, 42, 44, 44, 43,
-        41, 39, 38, 38, 38, 37, 36, 36, 34, 33, 33, 31, 42, 45, 45, 44, 42, 39,
-        38, 37, 36, 36, 34, 34, 32, 32, 31, 32, 42, 45, 45, 44, 42, 39, 37, 36,
-        35, 35, 34, 33, 32, 31, 31, 29, 42, 45, 45, 45, 42, 38, 36, 35, 34, 33,
-        32, 32, 30, 30, 29, 30, 41, 45, 45, 45, 42, 38, 36, 35, 33, 33, 31, 31,
-        30, 29, 29, 28, 41, 44, 44, 44, 41, 38, 36, 34, 33, 32, 31, 30, 29, 29,
-        28, 29, 40, 43, 43, 44, 41, 38, 35, 34, 32, 31, 29, 29, 28, 28, 27, 26,
-        39, 43, 43, 43, 41, 38, 35, 34, 31, 31, 29, 29, 27, 27, 26, 27, 38, 41,
-        41, 42, 40, 37, 34, 33, 31, 30, 28, 28, 26, 26, 26, 25, 38, 41, 41, 42,
-        40, 37, 34, 33, 31, 30, 28, 28, 26, 26, 25, 26, 36, 39, 39, 41, 39, 36,
-        34, 32, 30, 29, 27, 27, 25, 25, 25, 24, 36, 39, 39, 40, 39, 36, 34, 32,
-        29, 29, 27, 26, 25, 25, 24, 25, 34, 38, 38, 39, 37, 35, 33, 31, 29, 28,
-        26, 26, 24, 24, 23, 23, 34, 37, 37, 38, 37, 34, 32, 31, 28, 28, 26, 25,
-        24, 23, 23, 24, 32, 36, 36, 37, 36, 34, 32, 30, 28, 27, 25, 25, 23, 23,
-        22, 22, 32, 35, 35, 37, 35, 34, 32, 30, 28, 27, 25, 25, 23, 23, 22, 23,
-        32, 35, 35, 37, 35, 33, 31, 30, 28, 27, 25, 25, 23, 23, 22, 20, 31, 34,
-        34, 36, 34, 33, 31, 30, 27, 27, 24, 24, 22, 22, 22, 22, 30, 33, 34, 35,
-        34, 32, 31, 29, 27, 26, 25, 24, 22, 22, 21, 21, 30, 33, 33, 35, 34, 32,
-        31, 29, 27, 26, 25, 24, 22, 22, 21, 21, 29, 33, 32, 34, 34, 31, 32, 28,
-        29, 25, 26, 22, 24, 20, 22, 20,
+        32, 33, 33, 29, 28, 24, 21, 21, 21, 21, 20, 20, 18, 18, 17, 16, 33, 33,
+        33, 28, 27, 24, 22, 22, 22, 22, 20, 20, 19, 19, 18, 17, 33, 33, 33, 28,
+        27, 24, 22, 22, 22, 22, 20, 20, 19, 19, 18, 17, 34, 32, 32, 28, 26, 24,
+        22, 22, 22, 22, 21, 21, 20, 20, 18, 18, 34, 32, 32, 28, 26, 24, 22, 22,
+        23, 23, 21, 21, 20, 20, 19, 18, 32, 31, 30, 26, 25, 23, 22, 22, 23, 23,
+        21, 21, 20, 20, 19, 18, 31, 29, 28, 26, 24, 23, 22, 22, 22, 22, 22, 22,
+        20, 20, 19, 18, 30, 28, 28, 24, 23, 23, 22, 22, 23, 22, 22, 22, 20, 20,
+        19, 19, 28, 26, 26, 23, 22, 22, 22, 22, 23, 22, 22, 22, 21, 20, 20, 19,
+        28, 26, 26, 23, 22, 22, 21, 22, 22, 22, 22, 22, 21, 20, 19, 19, 24, 24,
+        24, 22, 22, 21, 20, 20, 21, 21, 20, 20, 19, 19, 18, 18, 24, 24, 24, 22,
+        22, 21, 20, 20, 21, 21, 20, 20, 19, 19, 18, 18, 22, 22, 22, 22, 21, 20,
+        20, 20, 19, 19, 19, 19, 19, 18, 18, 17, 21, 22, 22, 22, 21, 20, 19, 19,
+        19, 19, 19, 19, 18, 18, 17, 17, 21, 22, 22, 22, 22, 20, 19, 19, 19, 19,
+        18, 18, 18, 18, 17, 17, 21, 22, 22, 22, 22, 20, 19, 19, 18, 18, 18, 18,
+        17, 17, 17, 16, 21, 22, 23, 22, 22, 21, 19, 19, 18, 18, 17, 17, 17, 17,
+        16, 16, 21, 23, 23, 23, 22, 21, 19, 19, 18, 17, 17, 17, 16, 16, 16, 15,
+        21, 22, 23, 22, 22, 21, 19, 19, 18, 17, 17, 17, 16, 16, 16, 15, 20, 22,
+        22, 22, 22, 20, 19, 19, 17, 17, 16, 16, 16, 15, 15, 14, 20, 22, 22, 22,
+        22, 20, 19, 19, 17, 17, 16, 16, 16, 15, 15, 14, 20, 21, 21, 22, 22, 20,
+        19, 18, 17, 17, 16, 16, 15, 15, 14, 14, 20, 21, 21, 22, 22, 20, 19, 18,
+        17, 17, 16, 16, 15, 14, 14, 14, 19, 20, 21, 21, 21, 20, 19, 18, 17, 17,
+        15, 15, 14, 14, 14, 13, 19, 20, 20, 21, 21, 20, 19, 18, 17, 16, 15, 15,
+        14, 14, 13, 13, 19, 20, 20, 20, 21, 20, 18, 18, 16, 16, 15, 15, 14, 14,
+        13, 13, 18, 20, 20, 20, 20, 19, 18, 18, 16, 16, 15, 15, 14, 13, 13, 12,
+        18, 19, 19, 20, 20, 19, 18, 17, 16, 16, 14, 14, 13, 13, 13, 12, 17, 19,
+        19, 19, 20, 19, 18, 17, 16, 16, 14, 14, 13, 13, 12, 12, 17, 19, 19, 19,
+        19, 19, 17, 17, 16, 16, 14, 14, 13, 13, 12, 12, 16, 18, 18, 18, 19, 18,
+        17, 17, 15, 15, 14, 14, 13, 12, 12, 12, 16, 18, 18, 18, 19, 18, 17, 17,
+        15, 15, 14, 14, 13, 12, 12, 12,
         /* Size 32x16 */
-        64, 65, 66, 67, 65, 61, 58, 55, 50, 49, 42, 42, 42, 42, 42, 41, 41, 40,
-        39, 38, 38, 36, 36, 34, 34, 32, 32, 32, 31, 30, 30, 29, 66, 65, 65, 64,
-        61, 57, 53, 51, 48, 48, 44, 44, 45, 45, 45, 45, 44, 43, 43, 41, 41, 39,
-        39, 38, 37, 36, 35, 35, 34, 33, 33, 33, 64, 62, 62, 61, 59, 55, 52, 49,
-        48, 47, 44, 44, 45, 45, 45, 45, 44, 43, 43, 41, 41, 39, 39, 38, 37, 36,
-        35, 35, 34, 34, 33, 32, 55, 53, 53, 51, 50, 48, 45, 44, 43, 43, 43, 43,
-        44, 44, 45, 45, 44, 44, 43, 42, 42, 41, 40, 39, 38, 37, 37, 37, 36, 35,
-        35, 34, 51, 49, 49, 49, 48, 46, 45, 43, 43, 42, 41, 41, 42, 42, 42, 42,
-        41, 41, 41, 40, 40, 39, 39, 37, 37, 36, 35, 35, 34, 34, 34, 34, 43, 44,
-        44, 45, 44, 44, 43, 43, 41, 41, 39, 39, 39, 39, 38, 38, 38, 38, 38, 37,
-        37, 36, 36, 35, 34, 34, 34, 33, 33, 32, 32, 31, 42, 44, 44, 45, 45, 44,
-        44, 44, 42, 41, 38, 38, 38, 37, 36, 36, 36, 35, 35, 34, 34, 34, 34, 33,
-        32, 32, 32, 31, 31, 31, 31, 32, 42, 44, 44, 45, 45, 45, 45, 45, 42, 41,
-        38, 38, 37, 36, 35, 35, 34, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 30,
-        30, 29, 29, 28, 40, 41, 42, 43, 43, 43, 44, 44, 41, 41, 38, 38, 36, 35,
-        34, 33, 33, 32, 31, 31, 31, 30, 29, 29, 28, 28, 28, 28, 27, 27, 27, 29,
-        39, 41, 41, 43, 43, 43, 43, 44, 41, 41, 38, 37, 36, 35, 33, 33, 32, 31,
-        31, 30, 30, 29, 29, 28, 28, 27, 27, 27, 27, 26, 26, 25, 36, 38, 38, 39,
-        40, 40, 41, 41, 39, 38, 36, 36, 34, 34, 32, 31, 31, 29, 29, 28, 28, 27,
-        27, 26, 26, 25, 25, 25, 24, 25, 25, 26, 35, 37, 38, 39, 39, 39, 40, 41,
-        39, 38, 36, 36, 34, 33, 32, 31, 30, 29, 29, 28, 28, 27, 26, 26, 25, 25,
-        25, 25, 24, 24, 24, 22, 32, 34, 34, 36, 36, 37, 37, 38, 36, 36, 34, 34,
-        32, 32, 30, 30, 29, 28, 27, 26, 26, 25, 25, 24, 24, 23, 23, 23, 22, 22,
-        22, 24, 32, 34, 34, 35, 36, 36, 37, 37, 36, 35, 34, 33, 32, 31, 30, 29,
-        29, 28, 27, 26, 26, 25, 25, 24, 23, 23, 23, 23, 22, 22, 22, 20, 30, 32,
-        32, 34, 34, 34, 35, 36, 34, 34, 33, 33, 31, 31, 29, 29, 28, 27, 26, 26,
-        25, 25, 24, 23, 23, 22, 22, 22, 22, 21, 21, 22, 29, 31, 31, 33, 33, 34,
-        34, 35, 35, 32, 33, 31, 32, 29, 30, 28, 29, 26, 27, 25, 26, 24, 25, 23,
-        24, 22, 23, 20, 22, 21, 21, 20,
+        32, 33, 33, 34, 34, 32, 31, 30, 28, 28, 24, 24, 22, 21, 21, 21, 21, 21,
+        21, 20, 20, 20, 20, 19, 19, 19, 18, 18, 17, 17, 16, 16, 33, 33, 33, 32,
+        32, 31, 29, 28, 26, 26, 24, 24, 22, 22, 22, 22, 22, 23, 22, 22, 22, 21,
+        21, 20, 20, 20, 20, 19, 19, 19, 18, 18, 33, 33, 33, 32, 32, 30, 28, 28,
+        26, 26, 24, 24, 22, 22, 22, 22, 23, 23, 23, 22, 22, 21, 21, 21, 20, 20,
+        20, 19, 19, 19, 18, 18, 29, 28, 28, 28, 28, 26, 26, 24, 23, 23, 22, 22,
+        22, 22, 22, 22, 22, 23, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 19, 19,
+        18, 18, 28, 27, 27, 26, 26, 25, 24, 23, 22, 22, 22, 22, 21, 21, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 24, 24,
+        24, 24, 24, 23, 23, 23, 22, 22, 21, 21, 20, 20, 20, 20, 21, 21, 21, 20,
+        20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 18, 18, 21, 22, 22, 22, 22, 22,
+        22, 22, 22, 21, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 18, 18, 18, 18, 17, 17, 17, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 17,
+        17, 17, 17, 17, 21, 22, 22, 22, 23, 23, 22, 23, 23, 22, 21, 21, 19, 19,
+        19, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 15, 15,
+        21, 22, 22, 22, 23, 23, 22, 22, 22, 22, 21, 21, 19, 19, 19, 18, 18, 17,
+        17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 15, 15, 20, 20, 20, 21,
+        21, 21, 22, 22, 22, 22, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16,
+        16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 20, 20, 20, 21, 21, 21, 22, 22,
+        22, 22, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15,
+        15, 14, 14, 14, 14, 14, 18, 19, 19, 20, 20, 20, 20, 20, 21, 21, 19, 19,
+        19, 18, 18, 17, 17, 16, 16, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 13,
+        13, 13, 18, 19, 19, 20, 20, 20, 20, 20, 20, 20, 19, 19, 18, 18, 18, 17,
+        17, 16, 16, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 17, 18,
+        18, 18, 19, 19, 19, 19, 20, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 15,
+        15, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 16, 17, 17, 18, 18, 18,
+        18, 19, 19, 19, 18, 18, 17, 17, 17, 16, 16, 15, 15, 14, 14, 14, 14, 13,
+        13, 13, 12, 12, 12, 12, 12, 12,
         /* Size 4x16 */
-        66, 43, 39, 32, 65, 44, 41, 34, 61, 44, 43, 36, 53, 43, 43, 37, 48, 41,
-        41, 36, 44, 39, 38, 34, 45, 39, 36, 32, 45, 38, 33, 30, 44, 38, 32, 29,
-        43, 38, 31, 27, 41, 37, 30, 26, 39, 36, 29, 25, 37, 34, 28, 23, 35, 34,
-        27, 23, 34, 33, 27, 22, 33, 32, 26, 22,
+        33, 24, 21, 18, 33, 24, 22, 19, 32, 24, 23, 20, 29, 23, 22, 20, 26, 22,
+        22, 20, 24, 21, 21, 19, 22, 20, 19, 18, 22, 20, 19, 18, 22, 21, 18, 17,
+        22, 21, 17, 16, 22, 20, 17, 15, 21, 20, 17, 14, 20, 20, 16, 14, 20, 19,
+        16, 13, 19, 19, 16, 13, 18, 18, 15, 12,
         /* Size 16x4 */
-        66, 65, 61, 53, 48, 44, 45, 45, 44, 43, 41, 39, 37, 35, 34, 33, 43, 44,
-        44, 43, 41, 39, 39, 38, 38, 38, 37, 36, 34, 34, 33, 32, 39, 41, 43, 43,
-        41, 38, 36, 33, 32, 31, 30, 29, 28, 27, 27, 26, 32, 34, 36, 37, 36, 34,
-        32, 30, 29, 27, 26, 25, 23, 23, 22, 22,
+        33, 33, 32, 29, 26, 24, 22, 22, 22, 22, 22, 21, 20, 20, 19, 18, 24, 24,
+        24, 23, 22, 21, 20, 20, 21, 21, 20, 20, 20, 19, 19, 18, 21, 22, 23, 22,
+        22, 21, 19, 19, 18, 17, 17, 17, 16, 16, 16, 15, 18, 19, 20, 20, 20, 19,
+        18, 18, 17, 16, 15, 14, 14, 13, 13, 12,
         /* Size 8x32 */
-        64, 64, 51, 42, 40, 36, 32, 30, 65, 62, 49, 44, 41, 38, 34, 32, 66, 62,
-        49, 44, 42, 38, 34, 32, 67, 61, 49, 45, 43, 39, 36, 34, 65, 59, 48, 45,
-        43, 40, 36, 34, 61, 55, 46, 44, 43, 40, 37, 34, 58, 52, 45, 44, 44, 41,
-        37, 35, 55, 49, 43, 44, 44, 41, 38, 36, 50, 48, 43, 42, 41, 39, 36, 34,
-        49, 47, 42, 41, 41, 38, 36, 34, 42, 44, 41, 38, 38, 36, 34, 33, 42, 44,
-        41, 38, 38, 36, 34, 33, 42, 45, 42, 38, 36, 34, 32, 31, 42, 45, 42, 37,
-        35, 34, 32, 31, 42, 45, 42, 36, 34, 32, 30, 29, 41, 45, 42, 36, 33, 31,
-        30, 29, 41, 44, 41, 36, 33, 31, 29, 28, 40, 43, 41, 35, 32, 29, 28, 27,
-        39, 43, 41, 35, 31, 29, 27, 26, 38, 41, 40, 34, 31, 28, 26, 26, 38, 41,
-        40, 34, 31, 28, 26, 25, 36, 39, 39, 34, 30, 27, 25, 25, 36, 39, 39, 34,
-        29, 27, 25, 24, 34, 38, 37, 33, 29, 26, 24, 23, 34, 37, 37, 32, 28, 26,
-        24, 23, 32, 36, 36, 32, 28, 25, 23, 22, 32, 35, 35, 32, 28, 25, 23, 22,
-        32, 35, 35, 31, 28, 25, 23, 22, 31, 34, 34, 31, 27, 24, 22, 22, 30, 34,
-        34, 31, 27, 25, 22, 21, 30, 33, 34, 31, 27, 25, 22, 21, 29, 32, 34, 32,
-        29, 26, 24, 22,
+        32, 33, 28, 21, 21, 20, 18, 17, 33, 33, 27, 22, 22, 20, 19, 18, 33, 33,
+        27, 22, 22, 20, 19, 18, 34, 32, 26, 22, 22, 21, 20, 18, 34, 32, 26, 22,
+        23, 21, 20, 19, 32, 30, 25, 22, 23, 21, 20, 19, 31, 28, 24, 22, 22, 22,
+        20, 19, 30, 28, 23, 22, 23, 22, 20, 19, 28, 26, 22, 22, 23, 22, 21, 20,
+        28, 26, 22, 21, 22, 22, 21, 19, 24, 24, 22, 20, 21, 20, 19, 18, 24, 24,
+        22, 20, 21, 20, 19, 18, 22, 22, 21, 20, 19, 19, 19, 18, 21, 22, 21, 19,
+        19, 19, 18, 17, 21, 22, 22, 19, 19, 18, 18, 17, 21, 22, 22, 19, 18, 18,
+        17, 17, 21, 23, 22, 19, 18, 17, 17, 16, 21, 23, 22, 19, 18, 17, 16, 16,
+        21, 23, 22, 19, 18, 17, 16, 16, 20, 22, 22, 19, 17, 16, 16, 15, 20, 22,
+        22, 19, 17, 16, 16, 15, 20, 21, 22, 19, 17, 16, 15, 14, 20, 21, 22, 19,
+        17, 16, 15, 14, 19, 21, 21, 19, 17, 15, 14, 14, 19, 20, 21, 19, 17, 15,
+        14, 13, 19, 20, 21, 18, 16, 15, 14, 13, 18, 20, 20, 18, 16, 15, 14, 13,
+        18, 19, 20, 18, 16, 14, 13, 13, 17, 19, 20, 18, 16, 14, 13, 12, 17, 19,
+        19, 17, 16, 14, 13, 12, 16, 18, 19, 17, 15, 14, 13, 12, 16, 18, 19, 17,
+        15, 14, 13, 12,
         /* Size 32x8 */
-        64, 65, 66, 67, 65, 61, 58, 55, 50, 49, 42, 42, 42, 42, 42, 41, 41, 40,
-        39, 38, 38, 36, 36, 34, 34, 32, 32, 32, 31, 30, 30, 29, 64, 62, 62, 61,
-        59, 55, 52, 49, 48, 47, 44, 44, 45, 45, 45, 45, 44, 43, 43, 41, 41, 39,
-        39, 38, 37, 36, 35, 35, 34, 34, 33, 32, 51, 49, 49, 49, 48, 46, 45, 43,
-        43, 42, 41, 41, 42, 42, 42, 42, 41, 41, 41, 40, 40, 39, 39, 37, 37, 36,
-        35, 35, 34, 34, 34, 34, 42, 44, 44, 45, 45, 44, 44, 44, 42, 41, 38, 38,
-        38, 37, 36, 36, 36, 35, 35, 34, 34, 34, 34, 33, 32, 32, 32, 31, 31, 31,
-        31, 32, 40, 41, 42, 43, 43, 43, 44, 44, 41, 41, 38, 38, 36, 35, 34, 33,
-        33, 32, 31, 31, 31, 30, 29, 29, 28, 28, 28, 28, 27, 27, 27, 29, 36, 38,
-        38, 39, 40, 40, 41, 41, 39, 38, 36, 36, 34, 34, 32, 31, 31, 29, 29, 28,
-        28, 27, 27, 26, 26, 25, 25, 25, 24, 25, 25, 26, 32, 34, 34, 36, 36, 37,
-        37, 38, 36, 36, 34, 34, 32, 32, 30, 30, 29, 28, 27, 26, 26, 25, 25, 24,
-        24, 23, 23, 23, 22, 22, 22, 24, 30, 32, 32, 34, 34, 34, 35, 36, 34, 34,
-        33, 33, 31, 31, 29, 29, 28, 27, 26, 26, 25, 25, 24, 23, 23, 22, 22, 22,
-        22, 21, 21, 22 },
+        32, 33, 33, 34, 34, 32, 31, 30, 28, 28, 24, 24, 22, 21, 21, 21, 21, 21,
+        21, 20, 20, 20, 20, 19, 19, 19, 18, 18, 17, 17, 16, 16, 33, 33, 33, 32,
+        32, 30, 28, 28, 26, 26, 24, 24, 22, 22, 22, 22, 23, 23, 23, 22, 22, 21,
+        21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 28, 27, 27, 26, 26, 25, 24, 23,
+        22, 22, 22, 22, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21,
+        20, 20, 20, 19, 19, 19, 21, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20,
+        20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 17,
+        17, 17, 21, 22, 22, 22, 23, 23, 22, 23, 23, 22, 21, 21, 19, 19, 19, 18,
+        18, 18, 18, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 15, 15, 20, 20,
+        20, 21, 21, 21, 22, 22, 22, 22, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16,
+        16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 18, 19, 19, 20, 20, 20,
+        20, 20, 21, 21, 19, 19, 19, 18, 18, 17, 17, 16, 16, 16, 16, 15, 15, 14,
+        14, 14, 14, 13, 13, 13, 13, 13, 17, 18, 18, 18, 19, 19, 19, 19, 20, 19,
+        18, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 14, 14, 14, 13, 13, 13, 13,
+        12, 12, 12, 12 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        58, 35, 35, 20,
-#endif
-        /* Size 4x4 */
-        63, 59, 41, 28, 59, 42, 34, 26, 41, 34, 25, 20, 28, 26, 20, 15,
-        /* Size 8x8 */
-        64, 64, 60, 53, 44, 36, 30, 26, 64, 61, 58, 53, 45, 38, 32, 28, 60, 58,
-        52, 46, 40, 35, 30, 27, 53, 53, 46, 38, 34, 30, 26, 24, 44, 45, 40, 34,
-        29, 25, 23, 21, 36, 38, 35, 30, 25, 22, 20, 18, 30, 32, 30, 26, 23, 20,
-        17, 16, 26, 28, 27, 24, 21, 18, 16, 15,
-        /* Size 16x16 */
-        64, 65, 65, 65, 64, 60, 57, 52, 47, 42, 38, 35, 31, 29, 26, 25, 65, 64,
-        64, 64, 63, 60, 59, 53, 48, 44, 40, 36, 33, 30, 27, 26, 65, 64, 63, 63,
-        63, 61, 59, 55, 50, 46, 41, 38, 34, 32, 28, 27, 65, 64, 63, 61, 60, 58,
-        56, 53, 49, 45, 41, 38, 35, 32, 29, 28, 64, 63, 63, 60, 58, 55, 53, 51,
-        48, 45, 41, 38, 35, 33, 29, 28, 60, 60, 61, 58, 55, 52, 48, 46, 43, 40,
-        38, 35, 33, 30, 28, 27, 57, 59, 59, 56, 53, 48, 42, 41, 38, 36, 34, 32,
-        30, 28, 26, 25, 52, 53, 55, 53, 51, 46, 41, 38, 35, 34, 32, 30, 28, 26,
-        24, 24, 47, 48, 50, 49, 48, 43, 38, 35, 32, 31, 29, 27, 26, 24, 23, 22,
-        42, 44, 46, 45, 45, 40, 36, 34, 31, 29, 27, 25, 24, 23, 21, 21, 38, 40,
-        41, 41, 41, 38, 34, 32, 29, 27, 25, 24, 22, 21, 20, 19, 35, 36, 38, 38,
-        38, 35, 32, 30, 27, 25, 24, 22, 21, 20, 19, 18, 31, 33, 34, 35, 35, 33,
-        30, 28, 26, 24, 22, 21, 20, 18, 17, 17, 29, 30, 32, 32, 33, 30, 28, 26,
-        24, 23, 21, 20, 18, 17, 16, 16, 26, 27, 28, 29, 29, 28, 26, 24, 23, 21,
-        20, 19, 17, 16, 15, 15, 25, 26, 27, 28, 28, 27, 25, 24, 22, 21, 19, 18,
-        17, 16, 15, 15,
-        /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 65, 64, 64, 60, 60, 57, 57, 52, 52, 47, 47, 42,
-        42, 38, 38, 35, 35, 31, 31, 29, 29, 26, 26, 25, 25, 23, 65, 64, 64, 64,
-        64, 64, 64, 63, 63, 60, 60, 59, 59, 53, 53, 48, 48, 44, 44, 40, 40, 36,
-        36, 33, 33, 30, 30, 27, 27, 26, 26, 25, 65, 64, 64, 64, 64, 64, 64, 63,
-        63, 60, 60, 59, 59, 53, 53, 48, 48, 44, 44, 40, 40, 36, 36, 33, 33, 30,
-        30, 27, 27, 26, 26, 25, 65, 64, 64, 63, 63, 63, 63, 63, 63, 61, 61, 59,
-        59, 55, 55, 50, 50, 46, 46, 41, 41, 38, 38, 34, 34, 32, 32, 28, 28, 27,
-        27, 26, 65, 64, 64, 63, 63, 63, 63, 63, 63, 61, 61, 59, 59, 55, 55, 50,
-        50, 46, 46, 41, 41, 38, 38, 34, 34, 32, 32, 28, 28, 27, 27, 26, 65, 64,
-        64, 63, 63, 61, 61, 60, 60, 58, 58, 56, 56, 53, 53, 49, 49, 45, 45, 41,
-        41, 38, 38, 35, 35, 32, 32, 29, 29, 28, 28, 26, 65, 64, 64, 63, 63, 61,
-        61, 60, 60, 58, 58, 56, 56, 53, 53, 49, 49, 45, 45, 41, 41, 38, 38, 35,
-        35, 32, 32, 29, 29, 28, 28, 26, 64, 63, 63, 63, 63, 60, 60, 58, 58, 55,
-        55, 53, 53, 51, 51, 48, 48, 45, 45, 41, 41, 38, 38, 35, 35, 33, 33, 29,
-        29, 28, 28, 27, 64, 63, 63, 63, 63, 60, 60, 58, 58, 55, 55, 53, 53, 51,
-        51, 48, 48, 45, 45, 41, 41, 38, 38, 35, 35, 33, 33, 29, 29, 28, 28, 27,
-        60, 60, 60, 61, 61, 58, 58, 55, 55, 52, 52, 48, 48, 46, 46, 43, 43, 40,
-        40, 38, 38, 35, 35, 33, 33, 30, 30, 28, 28, 27, 27, 26, 60, 60, 60, 61,
-        61, 58, 58, 55, 55, 52, 52, 48, 48, 46, 46, 43, 43, 40, 40, 38, 38, 35,
-        35, 33, 33, 30, 30, 28, 28, 27, 27, 26, 57, 59, 59, 59, 59, 56, 56, 53,
-        53, 48, 48, 42, 42, 41, 41, 38, 38, 36, 36, 34, 34, 32, 32, 30, 30, 28,
-        28, 26, 26, 25, 25, 24, 57, 59, 59, 59, 59, 56, 56, 53, 53, 48, 48, 42,
-        42, 41, 41, 38, 38, 36, 36, 34, 34, 32, 32, 30, 30, 28, 28, 26, 26, 25,
-        25, 24, 52, 53, 53, 55, 55, 53, 53, 51, 51, 46, 46, 41, 41, 38, 38, 35,
-        35, 34, 34, 32, 32, 30, 30, 28, 28, 26, 26, 24, 24, 24, 24, 23, 52, 53,
-        53, 55, 55, 53, 53, 51, 51, 46, 46, 41, 41, 38, 38, 35, 35, 34, 34, 32,
-        32, 30, 30, 28, 28, 26, 26, 24, 24, 24, 24, 23, 47, 48, 48, 50, 50, 49,
-        49, 48, 48, 43, 43, 38, 38, 35, 35, 32, 32, 31, 31, 29, 29, 27, 27, 26,
-        26, 24, 24, 23, 23, 22, 22, 21, 47, 48, 48, 50, 50, 49, 49, 48, 48, 43,
-        43, 38, 38, 35, 35, 32, 32, 31, 31, 29, 29, 27, 27, 26, 26, 24, 24, 23,
-        23, 22, 22, 21, 42, 44, 44, 46, 46, 45, 45, 45, 45, 40, 40, 36, 36, 34,
-        34, 31, 31, 29, 29, 27, 27, 25, 25, 24, 24, 23, 23, 21, 21, 21, 21, 20,
-        42, 44, 44, 46, 46, 45, 45, 45, 45, 40, 40, 36, 36, 34, 34, 31, 31, 29,
-        29, 27, 27, 25, 25, 24, 24, 23, 23, 21, 21, 21, 21, 20, 38, 40, 40, 41,
-        41, 41, 41, 41, 41, 38, 38, 34, 34, 32, 32, 29, 29, 27, 27, 25, 25, 24,
-        24, 22, 22, 21, 21, 20, 20, 19, 19, 19, 38, 40, 40, 41, 41, 41, 41, 41,
-        41, 38, 38, 34, 34, 32, 32, 29, 29, 27, 27, 25, 25, 24, 24, 22, 22, 21,
-        21, 20, 20, 19, 19, 19, 35, 36, 36, 38, 38, 38, 38, 38, 38, 35, 35, 32,
-        32, 30, 30, 27, 27, 25, 25, 24, 24, 22, 22, 21, 21, 20, 20, 19, 19, 18,
-        18, 18, 35, 36, 36, 38, 38, 38, 38, 38, 38, 35, 35, 32, 32, 30, 30, 27,
-        27, 25, 25, 24, 24, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 18, 31, 33,
-        33, 34, 34, 35, 35, 35, 35, 33, 33, 30, 30, 28, 28, 26, 26, 24, 24, 22,
-        22, 21, 21, 20, 20, 18, 18, 17, 17, 17, 17, 16, 31, 33, 33, 34, 34, 35,
-        35, 35, 35, 33, 33, 30, 30, 28, 28, 26, 26, 24, 24, 22, 22, 21, 21, 20,
-        20, 18, 18, 17, 17, 17, 17, 16, 29, 30, 30, 32, 32, 32, 32, 33, 33, 30,
-        30, 28, 28, 26, 26, 24, 24, 23, 23, 21, 21, 20, 20, 18, 18, 17, 17, 16,
-        16, 16, 16, 16, 29, 30, 30, 32, 32, 32, 32, 33, 33, 30, 30, 28, 28, 26,
-        26, 24, 24, 23, 23, 21, 21, 20, 20, 18, 18, 17, 17, 16, 16, 16, 16, 16,
-        26, 27, 27, 28, 28, 29, 29, 29, 29, 28, 28, 26, 26, 24, 24, 23, 23, 21,
-        21, 20, 20, 19, 19, 17, 17, 16, 16, 15, 15, 15, 15, 14, 26, 27, 27, 28,
-        28, 29, 29, 29, 29, 28, 28, 26, 26, 24, 24, 23, 23, 21, 21, 20, 20, 19,
-        19, 17, 17, 16, 16, 15, 15, 15, 15, 14, 25, 26, 26, 27, 27, 28, 28, 28,
-        28, 27, 27, 25, 25, 24, 24, 22, 22, 21, 21, 19, 19, 18, 18, 17, 17, 16,
-        16, 15, 15, 15, 15, 14, 25, 26, 26, 27, 27, 28, 28, 28, 28, 27, 27, 25,
-        25, 24, 24, 22, 22, 21, 21, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 15,
-        15, 14, 23, 25, 25, 26, 26, 26, 26, 27, 27, 26, 26, 24, 24, 23, 23, 21,
-        21, 20, 20, 19, 19, 18, 18, 16, 16, 16, 16, 14, 14, 14, 14, 14,
-        /* Size 4x8 */
-        64, 58, 40, 27, 63, 56, 41, 29, 60, 48, 38, 28, 55, 41, 32, 24, 46, 36,
-        27, 21, 38, 32, 24, 19, 31, 28, 21, 16, 27, 25, 19, 15,
-        /* Size 8x4 */
-        64, 63, 60, 55, 46, 38, 31, 27, 58, 56, 48, 41, 36, 32, 28, 25, 40, 41,
-        38, 32, 27, 24, 21, 19, 27, 29, 28, 24, 21, 19, 16, 15,
-        /* Size 8x16 */
-        64, 65, 64, 57, 47, 38, 31, 26, 65, 64, 63, 58, 48, 40, 33, 27, 65, 63,
-        62, 59, 50, 41, 34, 28, 64, 63, 60, 56, 49, 41, 35, 29, 64, 62, 58, 53,
-        48, 41, 35, 30, 60, 60, 55, 48, 43, 38, 33, 28, 57, 59, 53, 43, 38, 34,
-        30, 26, 52, 55, 51, 41, 35, 32, 28, 24, 47, 50, 48, 38, 33, 29, 26, 23,
-        43, 46, 44, 36, 31, 27, 24, 21, 38, 41, 41, 34, 29, 25, 22, 20, 35, 38,
-        38, 32, 27, 24, 21, 19, 32, 34, 35, 30, 26, 22, 20, 17, 29, 31, 32, 28,
-        24, 21, 18, 16, 26, 28, 29, 26, 23, 20, 17, 15, 25, 27, 28, 25, 22, 19,
-        17, 15,
-        /* Size 16x8 */
-        64, 65, 65, 64, 64, 60, 57, 52, 47, 43, 38, 35, 32, 29, 26, 25, 65, 64,
-        63, 63, 62, 60, 59, 55, 50, 46, 41, 38, 34, 31, 28, 27, 64, 63, 62, 60,
-        58, 55, 53, 51, 48, 44, 41, 38, 35, 32, 29, 28, 57, 58, 59, 56, 53, 48,
-        43, 41, 38, 36, 34, 32, 30, 28, 26, 25, 47, 48, 50, 49, 48, 43, 38, 35,
-        33, 31, 29, 27, 26, 24, 23, 22, 38, 40, 41, 41, 41, 38, 34, 32, 29, 27,
-        25, 24, 22, 21, 20, 19, 31, 33, 34, 35, 35, 33, 30, 28, 26, 24, 22, 21,
-        20, 18, 17, 17, 26, 27, 28, 29, 30, 28, 26, 24, 23, 21, 20, 19, 17, 16,
-        15, 15,
-        /* Size 16x32 */
-        64, 65, 65, 64, 64, 57, 57, 47, 47, 38, 38, 31, 31, 26, 26, 24, 65, 64,
-        64, 63, 63, 58, 58, 48, 48, 40, 40, 33, 33, 27, 27, 25, 65, 64, 64, 63,
-        63, 58, 58, 48, 48, 40, 40, 33, 33, 27, 27, 25, 65, 63, 63, 62, 62, 59,
-        59, 50, 50, 41, 41, 34, 34, 28, 28, 26, 65, 63, 63, 62, 62, 59, 59, 50,
-        50, 41, 41, 34, 34, 28, 28, 26, 64, 63, 63, 60, 60, 56, 56, 49, 49, 41,
-        41, 35, 35, 29, 29, 27, 64, 63, 63, 60, 60, 56, 56, 49, 49, 41, 41, 35,
-        35, 29, 29, 27, 64, 62, 62, 58, 58, 53, 53, 48, 48, 41, 41, 35, 35, 30,
-        30, 27, 64, 62, 62, 58, 58, 53, 53, 48, 48, 41, 41, 35, 35, 30, 30, 27,
-        60, 60, 60, 55, 55, 48, 48, 43, 43, 38, 38, 33, 33, 28, 28, 26, 60, 60,
-        60, 55, 55, 48, 48, 43, 43, 38, 38, 33, 33, 28, 28, 26, 57, 59, 59, 53,
-        53, 43, 43, 38, 38, 34, 34, 30, 30, 26, 26, 24, 57, 59, 59, 53, 53, 43,
-        43, 38, 38, 34, 34, 30, 30, 26, 26, 24, 52, 55, 55, 51, 51, 41, 41, 35,
-        35, 32, 32, 28, 28, 24, 24, 23, 52, 55, 55, 51, 51, 41, 41, 35, 35, 32,
-        32, 28, 28, 24, 24, 23, 47, 50, 50, 48, 48, 38, 38, 33, 33, 29, 29, 26,
-        26, 23, 23, 21, 47, 50, 50, 48, 48, 38, 38, 33, 33, 29, 29, 26, 26, 23,
-        23, 21, 43, 46, 46, 44, 44, 36, 36, 31, 31, 27, 27, 24, 24, 21, 21, 20,
-        43, 46, 46, 44, 44, 36, 36, 31, 31, 27, 27, 24, 24, 21, 21, 20, 38, 41,
-        41, 41, 41, 34, 34, 29, 29, 25, 25, 22, 22, 20, 20, 19, 38, 41, 41, 41,
-        41, 34, 34, 29, 29, 25, 25, 22, 22, 20, 20, 19, 35, 38, 38, 38, 38, 32,
-        32, 27, 27, 24, 24, 21, 21, 19, 19, 18, 35, 38, 38, 38, 38, 32, 32, 27,
-        27, 24, 24, 21, 21, 19, 19, 18, 32, 34, 34, 35, 35, 30, 30, 26, 26, 22,
-        22, 20, 20, 17, 17, 16, 32, 34, 34, 35, 35, 30, 30, 26, 26, 22, 22, 20,
-        20, 17, 17, 16, 29, 31, 31, 32, 32, 28, 28, 24, 24, 21, 21, 18, 18, 16,
-        16, 16, 29, 31, 31, 32, 32, 28, 28, 24, 24, 21, 21, 18, 18, 16, 16, 16,
-        26, 28, 28, 29, 29, 26, 26, 23, 23, 20, 20, 17, 17, 15, 15, 15, 26, 28,
-        28, 29, 29, 26, 26, 23, 23, 20, 20, 17, 17, 15, 15, 15, 25, 27, 27, 28,
-        28, 25, 25, 22, 22, 19, 19, 17, 17, 15, 15, 14, 25, 27, 27, 28, 28, 25,
-        25, 22, 22, 19, 19, 17, 17, 15, 15, 14, 24, 26, 26, 27, 27, 24, 24, 21,
-        21, 19, 19, 16, 16, 15, 15, 14,
-        /* Size 32x16 */
-        64, 65, 65, 65, 65, 64, 64, 64, 64, 60, 60, 57, 57, 52, 52, 47, 47, 43,
-        43, 38, 38, 35, 35, 32, 32, 29, 29, 26, 26, 25, 25, 24, 65, 64, 64, 63,
-        63, 63, 63, 62, 62, 60, 60, 59, 59, 55, 55, 50, 50, 46, 46, 41, 41, 38,
-        38, 34, 34, 31, 31, 28, 28, 27, 27, 26, 65, 64, 64, 63, 63, 63, 63, 62,
-        62, 60, 60, 59, 59, 55, 55, 50, 50, 46, 46, 41, 41, 38, 38, 34, 34, 31,
-        31, 28, 28, 27, 27, 26, 64, 63, 63, 62, 62, 60, 60, 58, 58, 55, 55, 53,
-        53, 51, 51, 48, 48, 44, 44, 41, 41, 38, 38, 35, 35, 32, 32, 29, 29, 28,
-        28, 27, 64, 63, 63, 62, 62, 60, 60, 58, 58, 55, 55, 53, 53, 51, 51, 48,
-        48, 44, 44, 41, 41, 38, 38, 35, 35, 32, 32, 29, 29, 28, 28, 27, 57, 58,
-        58, 59, 59, 56, 56, 53, 53, 48, 48, 43, 43, 41, 41, 38, 38, 36, 36, 34,
-        34, 32, 32, 30, 30, 28, 28, 26, 26, 25, 25, 24, 57, 58, 58, 59, 59, 56,
-        56, 53, 53, 48, 48, 43, 43, 41, 41, 38, 38, 36, 36, 34, 34, 32, 32, 30,
-        30, 28, 28, 26, 26, 25, 25, 24, 47, 48, 48, 50, 50, 49, 49, 48, 48, 43,
-        43, 38, 38, 35, 35, 33, 33, 31, 31, 29, 29, 27, 27, 26, 26, 24, 24, 23,
-        23, 22, 22, 21, 47, 48, 48, 50, 50, 49, 49, 48, 48, 43, 43, 38, 38, 35,
-        35, 33, 33, 31, 31, 29, 29, 27, 27, 26, 26, 24, 24, 23, 23, 22, 22, 21,
-        38, 40, 40, 41, 41, 41, 41, 41, 41, 38, 38, 34, 34, 32, 32, 29, 29, 27,
-        27, 25, 25, 24, 24, 22, 22, 21, 21, 20, 20, 19, 19, 19, 38, 40, 40, 41,
-        41, 41, 41, 41, 41, 38, 38, 34, 34, 32, 32, 29, 29, 27, 27, 25, 25, 24,
-        24, 22, 22, 21, 21, 20, 20, 19, 19, 19, 31, 33, 33, 34, 34, 35, 35, 35,
-        35, 33, 33, 30, 30, 28, 28, 26, 26, 24, 24, 22, 22, 21, 21, 20, 20, 18,
-        18, 17, 17, 17, 17, 16, 31, 33, 33, 34, 34, 35, 35, 35, 35, 33, 33, 30,
-        30, 28, 28, 26, 26, 24, 24, 22, 22, 21, 21, 20, 20, 18, 18, 17, 17, 17,
-        17, 16, 26, 27, 27, 28, 28, 29, 29, 30, 30, 28, 28, 26, 26, 24, 24, 23,
-        23, 21, 21, 20, 20, 19, 19, 17, 17, 16, 16, 15, 15, 15, 15, 15, 26, 27,
-        27, 28, 28, 29, 29, 30, 30, 28, 28, 26, 26, 24, 24, 23, 23, 21, 21, 20,
-        20, 19, 19, 17, 17, 16, 16, 15, 15, 15, 15, 15, 24, 25, 25, 26, 26, 27,
-        27, 27, 27, 26, 26, 24, 24, 23, 23, 21, 21, 20, 20, 19, 19, 18, 18, 16,
-        16, 16, 16, 15, 15, 14, 14, 14,
-        /* Size 4x16 */
-        65, 57, 38, 26, 64, 58, 40, 27, 63, 59, 41, 28, 63, 56, 41, 29, 62, 53,
-        41, 30, 60, 48, 38, 28, 59, 43, 34, 26, 55, 41, 32, 24, 50, 38, 29, 23,
-        46, 36, 27, 21, 41, 34, 25, 20, 38, 32, 24, 19, 34, 30, 22, 17, 31, 28,
-        21, 16, 28, 26, 20, 15, 27, 25, 19, 15,
-        /* Size 16x4 */
-        65, 64, 63, 63, 62, 60, 59, 55, 50, 46, 41, 38, 34, 31, 28, 27, 57, 58,
-        59, 56, 53, 48, 43, 41, 38, 36, 34, 32, 30, 28, 26, 25, 38, 40, 41, 41,
-        41, 38, 34, 32, 29, 27, 25, 24, 22, 21, 20, 19, 26, 27, 28, 29, 30, 28,
-        26, 24, 23, 21, 20, 19, 17, 16, 15, 15,
-        /* Size 8x32 */
-        64, 65, 64, 57, 47, 38, 31, 26, 65, 64, 63, 58, 48, 40, 33, 27, 65, 64,
-        63, 58, 48, 40, 33, 27, 65, 63, 62, 59, 50, 41, 34, 28, 65, 63, 62, 59,
-        50, 41, 34, 28, 64, 63, 60, 56, 49, 41, 35, 29, 64, 63, 60, 56, 49, 41,
-        35, 29, 64, 62, 58, 53, 48, 41, 35, 30, 64, 62, 58, 53, 48, 41, 35, 30,
-        60, 60, 55, 48, 43, 38, 33, 28, 60, 60, 55, 48, 43, 38, 33, 28, 57, 59,
-        53, 43, 38, 34, 30, 26, 57, 59, 53, 43, 38, 34, 30, 26, 52, 55, 51, 41,
-        35, 32, 28, 24, 52, 55, 51, 41, 35, 32, 28, 24, 47, 50, 48, 38, 33, 29,
-        26, 23, 47, 50, 48, 38, 33, 29, 26, 23, 43, 46, 44, 36, 31, 27, 24, 21,
-        43, 46, 44, 36, 31, 27, 24, 21, 38, 41, 41, 34, 29, 25, 22, 20, 38, 41,
-        41, 34, 29, 25, 22, 20, 35, 38, 38, 32, 27, 24, 21, 19, 35, 38, 38, 32,
-        27, 24, 21, 19, 32, 34, 35, 30, 26, 22, 20, 17, 32, 34, 35, 30, 26, 22,
-        20, 17, 29, 31, 32, 28, 24, 21, 18, 16, 29, 31, 32, 28, 24, 21, 18, 16,
-        26, 28, 29, 26, 23, 20, 17, 15, 26, 28, 29, 26, 23, 20, 17, 15, 25, 27,
-        28, 25, 22, 19, 17, 15, 25, 27, 28, 25, 22, 19, 17, 15, 24, 26, 27, 24,
-        21, 19, 16, 15,
-        /* Size 32x8 */
-        64, 65, 65, 65, 65, 64, 64, 64, 64, 60, 60, 57, 57, 52, 52, 47, 47, 43,
-        43, 38, 38, 35, 35, 32, 32, 29, 29, 26, 26, 25, 25, 24, 65, 64, 64, 63,
-        63, 63, 63, 62, 62, 60, 60, 59, 59, 55, 55, 50, 50, 46, 46, 41, 41, 38,
-        38, 34, 34, 31, 31, 28, 28, 27, 27, 26, 64, 63, 63, 62, 62, 60, 60, 58,
-        58, 55, 55, 53, 53, 51, 51, 48, 48, 44, 44, 41, 41, 38, 38, 35, 35, 32,
-        32, 29, 29, 28, 28, 27, 57, 58, 58, 59, 59, 56, 56, 53, 53, 48, 48, 43,
-        43, 41, 41, 38, 38, 36, 36, 34, 34, 32, 32, 30, 30, 28, 28, 26, 26, 25,
-        25, 24, 47, 48, 48, 50, 50, 49, 49, 48, 48, 43, 43, 38, 38, 35, 35, 33,
-        33, 31, 31, 29, 29, 27, 27, 26, 26, 24, 24, 23, 23, 22, 22, 21, 38, 40,
-        40, 41, 41, 41, 41, 41, 41, 38, 38, 34, 34, 32, 32, 29, 29, 27, 27, 25,
-        25, 24, 24, 22, 22, 21, 21, 20, 20, 19, 19, 19, 31, 33, 33, 34, 34, 35,
-        35, 35, 35, 33, 33, 30, 30, 28, 28, 26, 26, 24, 24, 22, 22, 21, 21, 20,
-        20, 18, 18, 17, 17, 17, 17, 16, 26, 27, 27, 28, 28, 29, 29, 30, 30, 28,
-        28, 26, 26, 24, 24, 23, 23, 21, 21, 20, 20, 19, 19, 17, 17, 16, 16, 15,
-        15, 15, 15, 15 },
-      { /* Chroma */
-#if CONFIG_CB4X4
-        /* Size 2x2 */
-        43, 41, 41, 27,
+        31, 22, 22, 14,
 #endif
         /* Size 4x4 */
-        64, 44, 43, 36, 44, 39, 38, 34, 43, 38, 31, 27, 36, 34, 27, 23,
+        32, 31, 24, 19, 31, 27, 22, 18, 24, 22, 16, 14, 19, 18, 14, 11,
         /* Size 8x8 */
-        65, 59, 48, 44, 42, 39, 36, 33, 59, 53, 46, 44, 44, 41, 38, 36, 48, 46,
-        42, 41, 41, 39, 37, 35, 44, 44, 41, 38, 36, 35, 33, 32, 42, 44, 41, 36,
-        33, 32, 30, 29, 39, 41, 39, 35, 32, 29, 27, 26, 36, 38, 37, 33, 30, 27,
-        25, 24, 33, 36, 35, 32, 29, 26, 24, 22,
+        33, 32, 32, 30, 27, 22, 20, 16, 32, 32, 32, 30, 28, 23, 21, 17, 32, 32,
+        29, 28, 26, 23, 21, 18, 30, 30, 28, 24, 22, 20, 18, 16, 27, 28, 26, 22,
+        19, 17, 16, 14, 22, 23, 23, 20, 17, 15, 14, 12, 20, 21, 21, 18, 16, 14,
+        12, 11, 16, 17, 18, 16, 14, 12, 11, 10,
         /* Size 16x16 */
-        64, 66, 67, 61, 56, 49, 42, 42, 42, 41, 39, 38, 36, 34, 32, 32, 66, 65,
-        66, 59, 53, 48, 43, 44, 44, 42, 41, 39, 38, 36, 34, 33, 67, 66, 64, 58,
-        51, 48, 44, 45, 46, 44, 43, 41, 39, 38, 36, 35, 61, 59, 58, 53, 47, 46,
-        43, 44, 45, 44, 43, 41, 40, 38, 36, 36, 56, 53, 51, 47, 43, 43, 43, 44,
-        45, 45, 44, 42, 41, 39, 38, 37, 49, 48, 48, 46, 43, 42, 41, 41, 42, 41,
-        41, 39, 38, 37, 36, 35, 42, 43, 44, 43, 43, 41, 39, 39, 38, 38, 38, 37,
-        36, 35, 34, 33, 42, 44, 45, 44, 44, 41, 39, 38, 37, 36, 36, 35, 34, 33,
-        32, 32, 42, 44, 46, 45, 45, 42, 38, 37, 35, 34, 33, 33, 32, 31, 30, 30,
-        41, 42, 44, 44, 45, 41, 38, 36, 34, 33, 32, 32, 31, 30, 29, 29, 39, 41,
-        43, 43, 44, 41, 38, 36, 33, 32, 31, 30, 29, 28, 27, 27, 38, 39, 41, 41,
-        42, 39, 37, 35, 33, 32, 30, 29, 28, 27, 26, 26, 36, 38, 39, 40, 41, 38,
-        36, 34, 32, 31, 29, 28, 27, 26, 25, 25, 34, 36, 38, 38, 39, 37, 35, 33,
-        31, 30, 28, 27, 26, 25, 24, 24, 32, 34, 36, 36, 38, 36, 34, 32, 30, 29,
-        27, 26, 25, 24, 23, 23, 32, 33, 35, 36, 37, 35, 33, 32, 30, 29, 27, 26,
-        25, 24, 23, 22,
+        32, 33, 33, 33, 32, 32, 30, 28, 27, 25, 23, 21, 19, 18, 17, 16, 33, 32,
+        32, 32, 32, 32, 30, 29, 27, 26, 24, 22, 20, 19, 18, 17, 33, 32, 32, 32,
+        32, 32, 31, 30, 28, 27, 25, 23, 21, 19, 18, 17, 33, 32, 32, 31, 31, 31,
+        29, 28, 27, 26, 24, 23, 21, 19, 18, 17, 32, 32, 32, 31, 30, 30, 28, 28,
+        26, 26, 24, 23, 21, 19, 19, 17, 32, 32, 32, 31, 30, 29, 28, 27, 26, 25,
+        24, 22, 21, 20, 19, 18, 30, 30, 31, 29, 28, 28, 26, 24, 23, 22, 22, 20,
+        19, 18, 17, 16, 28, 29, 30, 28, 28, 27, 24, 21, 20, 20, 19, 18, 17, 16,
+        16, 15, 27, 27, 28, 27, 26, 26, 23, 20, 20, 19, 18, 17, 16, 15, 15, 14,
+        25, 26, 27, 26, 26, 25, 22, 20, 19, 18, 17, 16, 15, 15, 14, 14, 23, 24,
+        25, 24, 24, 24, 22, 19, 18, 17, 16, 15, 14, 14, 13, 13, 21, 22, 23, 23,
+        23, 22, 20, 18, 17, 16, 15, 14, 13, 13, 12, 12, 19, 20, 21, 21, 21, 21,
+        19, 17, 16, 15, 14, 13, 12, 12, 12, 11, 18, 19, 19, 19, 19, 20, 18, 16,
+        15, 15, 14, 13, 12, 11, 11, 11, 17, 18, 18, 18, 19, 19, 17, 16, 15, 14,
+        13, 12, 12, 11, 11, 10, 16, 17, 17, 17, 17, 18, 16, 15, 14, 14, 13, 12,
+        11, 11, 10, 10,
         /* Size 32x32 */
-        64, 66, 66, 67, 67, 61, 61, 56, 56, 49, 49, 42, 42, 42, 42, 42, 42, 41,
-        41, 39, 39, 38, 38, 36, 36, 34, 34, 32, 32, 32, 32, 31, 66, 65, 65, 66,
-        66, 59, 59, 53, 53, 48, 48, 43, 43, 44, 44, 44, 44, 42, 42, 41, 41, 39,
-        39, 38, 38, 36, 36, 34, 34, 33, 33, 32, 66, 65, 65, 66, 66, 59, 59, 53,
-        53, 48, 48, 43, 43, 44, 44, 44, 44, 42, 42, 41, 41, 39, 39, 38, 38, 36,
-        36, 34, 34, 33, 33, 32, 67, 66, 66, 64, 64, 58, 58, 51, 51, 48, 48, 44,
-        44, 45, 45, 46, 46, 44, 44, 43, 43, 41, 41, 39, 39, 38, 38, 36, 36, 35,
-        35, 34, 67, 66, 66, 64, 64, 58, 58, 51, 51, 48, 48, 44, 44, 45, 45, 46,
-        46, 44, 44, 43, 43, 41, 41, 39, 39, 38, 38, 36, 36, 35, 35, 34, 61, 59,
-        59, 58, 58, 53, 53, 47, 47, 46, 46, 43, 43, 44, 44, 45, 45, 44, 44, 43,
-        43, 41, 41, 40, 40, 38, 38, 36, 36, 36, 36, 35, 61, 59, 59, 58, 58, 53,
-        53, 47, 47, 46, 46, 43, 43, 44, 44, 45, 45, 44, 44, 43, 43, 41, 41, 40,
-        40, 38, 38, 36, 36, 36, 36, 35, 56, 53, 53, 51, 51, 47, 47, 43, 43, 43,
-        43, 43, 43, 44, 44, 45, 45, 45, 45, 44, 44, 42, 42, 41, 41, 39, 39, 38,
-        38, 37, 37, 36, 56, 53, 53, 51, 51, 47, 47, 43, 43, 43, 43, 43, 43, 44,
-        44, 45, 45, 45, 45, 44, 44, 42, 42, 41, 41, 39, 39, 38, 38, 37, 37, 36,
-        49, 48, 48, 48, 48, 46, 46, 43, 43, 42, 42, 41, 41, 41, 41, 42, 42, 41,
-        41, 41, 41, 39, 39, 38, 38, 37, 37, 36, 36, 35, 35, 34, 49, 48, 48, 48,
-        48, 46, 46, 43, 43, 42, 42, 41, 41, 41, 41, 42, 42, 41, 41, 41, 41, 39,
-        39, 38, 38, 37, 37, 36, 36, 35, 35, 34, 42, 43, 43, 44, 44, 43, 43, 43,
-        43, 41, 41, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 37, 37, 36, 36, 35,
-        35, 34, 34, 33, 33, 33, 42, 43, 43, 44, 44, 43, 43, 43, 43, 41, 41, 39,
-        39, 39, 39, 38, 38, 38, 38, 38, 38, 37, 37, 36, 36, 35, 35, 34, 34, 33,
-        33, 33, 42, 44, 44, 45, 45, 44, 44, 44, 44, 41, 41, 39, 39, 38, 38, 37,
-        37, 36, 36, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 32, 32, 31, 42, 44,
-        44, 45, 45, 44, 44, 44, 44, 41, 41, 39, 39, 38, 38, 37, 37, 36, 36, 36,
-        36, 35, 35, 34, 34, 33, 33, 32, 32, 32, 32, 31, 42, 44, 44, 46, 46, 45,
-        45, 45, 45, 42, 42, 38, 38, 37, 37, 35, 35, 34, 34, 33, 33, 33, 33, 32,
-        32, 31, 31, 30, 30, 30, 30, 30, 42, 44, 44, 46, 46, 45, 45, 45, 45, 42,
-        42, 38, 38, 37, 37, 35, 35, 34, 34, 33, 33, 33, 33, 32, 32, 31, 31, 30,
-        30, 30, 30, 30, 41, 42, 42, 44, 44, 44, 44, 45, 45, 41, 41, 38, 38, 36,
-        36, 34, 34, 33, 33, 32, 32, 32, 32, 31, 31, 30, 30, 29, 29, 29, 29, 28,
-        41, 42, 42, 44, 44, 44, 44, 45, 45, 41, 41, 38, 38, 36, 36, 34, 34, 33,
-        33, 32, 32, 32, 32, 31, 31, 30, 30, 29, 29, 29, 29, 28, 39, 41, 41, 43,
-        43, 43, 43, 44, 44, 41, 41, 38, 38, 36, 36, 33, 33, 32, 32, 31, 31, 30,
-        30, 29, 29, 28, 28, 27, 27, 27, 27, 27, 39, 41, 41, 43, 43, 43, 43, 44,
-        44, 41, 41, 38, 38, 36, 36, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28,
-        28, 27, 27, 27, 27, 27, 38, 39, 39, 41, 41, 41, 41, 42, 42, 39, 39, 37,
-        37, 35, 35, 33, 33, 32, 32, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 26,
-        26, 25, 38, 39, 39, 41, 41, 41, 41, 42, 42, 39, 39, 37, 37, 35, 35, 33,
-        33, 32, 32, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 26, 26, 25, 36, 38,
-        38, 39, 39, 40, 40, 41, 41, 38, 38, 36, 36, 34, 34, 32, 32, 31, 31, 29,
-        29, 28, 28, 27, 27, 26, 26, 25, 25, 25, 25, 24, 36, 38, 38, 39, 39, 40,
-        40, 41, 41, 38, 38, 36, 36, 34, 34, 32, 32, 31, 31, 29, 29, 28, 28, 27,
-        27, 26, 26, 25, 25, 25, 25, 24, 34, 36, 36, 38, 38, 38, 38, 39, 39, 37,
-        37, 35, 35, 33, 33, 31, 31, 30, 30, 28, 28, 27, 27, 26, 26, 25, 25, 24,
-        24, 24, 24, 23, 34, 36, 36, 38, 38, 38, 38, 39, 39, 37, 37, 35, 35, 33,
-        33, 31, 31, 30, 30, 28, 28, 27, 27, 26, 26, 25, 25, 24, 24, 24, 24, 23,
-        32, 34, 34, 36, 36, 36, 36, 38, 38, 36, 36, 34, 34, 32, 32, 30, 30, 29,
-        29, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 23, 23, 22, 32, 34, 34, 36,
-        36, 36, 36, 38, 38, 36, 36, 34, 34, 32, 32, 30, 30, 29, 29, 27, 27, 26,
-        26, 25, 25, 24, 24, 23, 23, 23, 23, 22, 32, 33, 33, 35, 35, 36, 36, 37,
-        37, 35, 35, 33, 33, 32, 32, 30, 30, 29, 29, 27, 27, 26, 26, 25, 25, 24,
-        24, 23, 23, 22, 22, 22, 32, 33, 33, 35, 35, 36, 36, 37, 37, 35, 35, 33,
-        33, 32, 32, 30, 30, 29, 29, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22,
-        22, 22, 31, 32, 32, 34, 34, 35, 35, 36, 36, 34, 34, 33, 33, 31, 31, 30,
-        30, 28, 28, 27, 27, 25, 25, 24, 24, 23, 23, 22, 22, 22, 22, 21,
+        32, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 31, 30, 30, 28, 28, 27, 26,
+        25, 23, 23, 22, 21, 20, 19, 19, 18, 17, 17, 16, 16, 15, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 27, 27, 26, 24, 24, 22,
+        22, 21, 20, 20, 18, 18, 17, 16, 16, 15, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 30, 30, 29, 29, 27, 27, 26, 24, 24, 23, 22, 21, 20, 20,
+        19, 18, 18, 17, 17, 15, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        30, 30, 29, 29, 28, 27, 26, 24, 24, 23, 23, 22, 20, 20, 19, 19, 18, 17,
+        17, 16, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 30,
+        28, 28, 27, 25, 25, 23, 23, 22, 21, 21, 19, 19, 18, 17, 17, 16, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 30, 28, 28, 27, 25,
+        25, 23, 23, 22, 21, 21, 19, 19, 18, 17, 17, 16, 33, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 31, 30, 29, 29, 28, 28, 27, 26, 26, 24, 24, 23, 23, 22,
+        21, 21, 19, 19, 18, 17, 17, 16, 33, 32, 32, 32, 32, 32, 31, 31, 31, 30,
+        30, 29, 29, 28, 28, 28, 27, 26, 26, 24, 24, 23, 23, 22, 20, 20, 19, 19,
+        18, 17, 17, 16, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 30, 29, 28, 28,
+        28, 28, 26, 26, 26, 24, 24, 23, 23, 22, 21, 21, 19, 19, 19, 17, 17, 16,
+        32, 32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 28, 28, 28, 27, 27, 26, 26,
+        25, 24, 24, 23, 22, 22, 21, 21, 20, 19, 19, 18, 18, 17, 32, 32, 32, 32,
+        32, 32, 31, 30, 30, 29, 29, 28, 28, 28, 27, 27, 26, 26, 25, 24, 24, 23,
+        22, 22, 21, 21, 20, 19, 19, 18, 18, 17, 31, 31, 31, 31, 31, 31, 30, 29,
+        29, 28, 28, 27, 26, 26, 24, 24, 24, 23, 23, 22, 22, 21, 20, 20, 19, 19,
+        18, 18, 17, 17, 17, 16, 30, 30, 30, 30, 31, 31, 29, 29, 28, 28, 28, 26,
+        26, 25, 24, 24, 23, 23, 22, 22, 22, 20, 20, 20, 19, 19, 18, 18, 17, 16,
+        16, 15, 30, 30, 30, 30, 30, 30, 29, 28, 28, 28, 28, 26, 25, 24, 23, 23,
+        22, 22, 21, 20, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 15, 28, 29,
+        29, 29, 30, 30, 28, 28, 28, 27, 27, 24, 24, 23, 21, 21, 20, 20, 20, 19,
+        19, 18, 18, 18, 17, 17, 16, 16, 16, 15, 15, 14, 28, 29, 29, 29, 30, 30,
+        28, 28, 28, 27, 27, 24, 24, 23, 21, 21, 20, 20, 20, 19, 19, 18, 18, 18,
+        17, 17, 16, 16, 16, 15, 15, 14, 27, 27, 27, 28, 28, 28, 27, 27, 26, 26,
+        26, 24, 23, 22, 20, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 15, 15,
+        15, 14, 14, 13, 26, 27, 27, 27, 28, 28, 26, 26, 26, 26, 26, 23, 23, 22,
+        20, 20, 19, 19, 19, 18, 18, 17, 17, 17, 16, 16, 15, 15, 15, 14, 14, 13,
+        25, 26, 26, 26, 27, 27, 26, 26, 26, 25, 25, 23, 22, 21, 20, 20, 19, 19,
+        18, 17, 17, 17, 16, 16, 15, 15, 15, 14, 14, 14, 14, 13, 23, 24, 24, 24,
+        25, 25, 24, 24, 24, 24, 24, 22, 22, 20, 19, 19, 18, 18, 17, 16, 16, 16,
+        15, 15, 14, 14, 14, 14, 13, 13, 13, 12, 23, 24, 24, 24, 25, 25, 24, 24,
+        24, 24, 24, 22, 22, 20, 19, 19, 18, 18, 17, 16, 16, 16, 15, 15, 14, 14,
+        14, 14, 13, 13, 13, 12, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 21,
+        20, 20, 18, 18, 17, 17, 17, 16, 16, 15, 15, 14, 14, 14, 13, 13, 13, 12,
+        12, 12, 21, 22, 22, 23, 23, 23, 23, 23, 23, 22, 22, 20, 20, 19, 18, 18,
+        17, 17, 16, 15, 15, 15, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 20, 21,
+        21, 22, 22, 22, 22, 22, 22, 22, 22, 20, 20, 19, 18, 18, 17, 17, 16, 15,
+        15, 14, 14, 14, 13, 13, 12, 12, 12, 12, 12, 11, 19, 20, 20, 20, 21, 21,
+        21, 20, 21, 21, 21, 19, 19, 18, 17, 17, 16, 16, 15, 14, 14, 14, 13, 13,
+        12, 12, 12, 12, 12, 11, 11, 11, 19, 20, 20, 20, 21, 21, 21, 20, 21, 21,
+        21, 19, 19, 18, 17, 17, 16, 16, 15, 14, 14, 14, 13, 13, 12, 12, 12, 12,
+        12, 11, 11, 11, 18, 18, 19, 19, 19, 19, 19, 19, 19, 20, 20, 18, 18, 17,
+        16, 16, 15, 15, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11, 11, 10,
+        17, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 17, 16, 16, 15, 15,
+        14, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 17, 17, 18, 18,
+        18, 18, 18, 18, 19, 19, 19, 17, 17, 17, 16, 16, 15, 15, 14, 13, 13, 13,
+        12, 12, 12, 12, 11, 11, 11, 10, 10, 10, 16, 16, 17, 17, 17, 17, 17, 17,
+        17, 18, 18, 17, 16, 16, 15, 15, 14, 14, 14, 13, 13, 12, 12, 12, 11, 11,
+        11, 10, 10, 10, 10, 9, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 17,
+        16, 16, 15, 15, 14, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10,
+        10, 9, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17, 17, 16, 15, 15, 14, 14,
+        13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9,
         /* Size 4x8 */
-        65, 44, 41, 34, 57, 44, 43, 37, 48, 41, 41, 36, 45, 39, 36, 32, 44, 38,
-        32, 29, 41, 37, 30, 26, 38, 35, 28, 24, 35, 33, 27, 23,
+        32, 32, 24, 18, 32, 31, 25, 19, 32, 29, 24, 20, 30, 28, 20, 17, 27, 26,
+        18, 15, 23, 23, 16, 13, 20, 20, 14, 12, 17, 18, 13, 11,
         /* Size 8x4 */
-        65, 57, 48, 45, 44, 41, 38, 35, 44, 44, 41, 39, 38, 37, 35, 33, 41, 43,
-        41, 36, 32, 30, 28, 27, 34, 37, 36, 32, 29, 26, 24, 23,
+        32, 32, 32, 30, 27, 23, 20, 17, 32, 31, 29, 28, 26, 23, 20, 18, 24, 25,
+        24, 20, 18, 16, 14, 13, 18, 19, 20, 17, 15, 13, 12, 11,
         /* Size 8x16 */
-        64, 66, 55, 43, 42, 39, 36, 32, 65, 65, 53, 44, 44, 41, 38, 34, 67, 64,
-        51, 45, 45, 43, 39, 36, 61, 57, 48, 44, 45, 43, 40, 37, 55, 51, 44, 43,
-        45, 44, 41, 38, 49, 48, 43, 41, 41, 41, 38, 36, 42, 44, 43, 39, 38, 38,
-        36, 34, 42, 45, 44, 39, 37, 36, 34, 32, 42, 45, 45, 38, 35, 33, 32, 30,
-        41, 44, 44, 38, 34, 32, 31, 29, 39, 43, 43, 38, 34, 31, 29, 27, 38, 41,
-        42, 37, 33, 30, 28, 26, 36, 39, 41, 36, 32, 29, 27, 25, 34, 38, 39, 35,
-        31, 28, 26, 24, 32, 36, 37, 34, 30, 27, 25, 23, 32, 35, 37, 33, 30, 27,
-        25, 23,
+        32, 33, 32, 29, 26, 23, 19, 16, 33, 32, 32, 29, 27, 24, 20, 17, 33, 32,
+        31, 30, 28, 25, 21, 17, 33, 32, 30, 29, 27, 24, 21, 17, 32, 32, 30, 28,
+        26, 24, 21, 18, 32, 31, 29, 28, 26, 24, 21, 18, 30, 30, 28, 25, 23, 21,
+        19, 16, 28, 30, 27, 22, 20, 19, 17, 15, 27, 28, 26, 22, 20, 18, 16, 14,
+        25, 26, 25, 21, 19, 17, 15, 13, 23, 25, 24, 20, 18, 16, 14, 13, 21, 23,
+        22, 19, 17, 15, 13, 12, 19, 21, 20, 18, 16, 14, 12, 11, 18, 19, 19, 17,
+        15, 14, 12, 11, 17, 18, 18, 16, 15, 13, 12, 10, 16, 17, 18, 16, 14, 13,
+        11, 10,
         /* Size 16x8 */
-        64, 65, 67, 61, 55, 49, 42, 42, 42, 41, 39, 38, 36, 34, 32, 32, 66, 65,
-        64, 57, 51, 48, 44, 45, 45, 44, 43, 41, 39, 38, 36, 35, 55, 53, 51, 48,
-        44, 43, 43, 44, 45, 44, 43, 42, 41, 39, 37, 37, 43, 44, 45, 44, 43, 41,
-        39, 39, 38, 38, 38, 37, 36, 35, 34, 33, 42, 44, 45, 45, 45, 41, 38, 37,
-        35, 34, 34, 33, 32, 31, 30, 30, 39, 41, 43, 43, 44, 41, 38, 36, 33, 32,
-        31, 30, 29, 28, 27, 27, 36, 38, 39, 40, 41, 38, 36, 34, 32, 31, 29, 28,
-        27, 26, 25, 25, 32, 34, 36, 37, 38, 36, 34, 32, 30, 29, 27, 26, 25, 24,
-        23, 23,
+        32, 33, 33, 33, 32, 32, 30, 28, 27, 25, 23, 21, 19, 18, 17, 16, 33, 32,
+        32, 32, 32, 31, 30, 30, 28, 26, 25, 23, 21, 19, 18, 17, 32, 32, 31, 30,
+        30, 29, 28, 27, 26, 25, 24, 22, 20, 19, 18, 18, 29, 29, 30, 29, 28, 28,
+        25, 22, 22, 21, 20, 19, 18, 17, 16, 16, 26, 27, 28, 27, 26, 26, 23, 20,
+        20, 19, 18, 17, 16, 15, 15, 14, 23, 24, 25, 24, 24, 24, 21, 19, 18, 17,
+        16, 15, 14, 14, 13, 13, 19, 20, 21, 21, 21, 21, 19, 17, 16, 15, 14, 13,
+        12, 12, 12, 11, 16, 17, 17, 17, 18, 18, 16, 15, 14, 13, 13, 12, 11, 11,
+        10, 10,
         /* Size 16x32 */
-        64, 66, 66, 55, 55, 43, 43, 42, 42, 39, 39, 36, 36, 32, 32, 31, 65, 65,
-        65, 53, 53, 44, 44, 44, 44, 41, 41, 38, 38, 34, 34, 33, 65, 65, 65, 53,
-        53, 44, 44, 44, 44, 41, 41, 38, 38, 34, 34, 33, 67, 64, 64, 51, 51, 45,
-        45, 45, 45, 43, 43, 39, 39, 36, 36, 34, 67, 64, 64, 51, 51, 45, 45, 45,
-        45, 43, 43, 39, 39, 36, 36, 34, 61, 57, 57, 48, 48, 44, 44, 45, 45, 43,
-        43, 40, 40, 37, 37, 35, 61, 57, 57, 48, 48, 44, 44, 45, 45, 43, 43, 40,
-        40, 37, 37, 35, 55, 51, 51, 44, 44, 43, 43, 45, 45, 44, 44, 41, 41, 38,
-        38, 36, 55, 51, 51, 44, 44, 43, 43, 45, 45, 44, 44, 41, 41, 38, 38, 36,
-        49, 48, 48, 43, 43, 41, 41, 41, 41, 41, 41, 38, 38, 36, 36, 34, 49, 48,
-        48, 43, 43, 41, 41, 41, 41, 41, 41, 38, 38, 36, 36, 34, 42, 44, 44, 43,
-        43, 39, 39, 38, 38, 38, 38, 36, 36, 34, 34, 33, 42, 44, 44, 43, 43, 39,
-        39, 38, 38, 38, 38, 36, 36, 34, 34, 33, 42, 45, 45, 44, 44, 39, 39, 37,
-        37, 36, 36, 34, 34, 32, 32, 31, 42, 45, 45, 44, 44, 39, 39, 37, 37, 36,
-        36, 34, 34, 32, 32, 31, 42, 45, 45, 45, 45, 38, 38, 35, 35, 33, 33, 32,
-        32, 30, 30, 29, 42, 45, 45, 45, 45, 38, 38, 35, 35, 33, 33, 32, 32, 30,
-        30, 29, 41, 44, 44, 44, 44, 38, 38, 34, 34, 32, 32, 31, 31, 29, 29, 28,
-        41, 44, 44, 44, 44, 38, 38, 34, 34, 32, 32, 31, 31, 29, 29, 28, 39, 43,
-        43, 43, 43, 38, 38, 34, 34, 31, 31, 29, 29, 27, 27, 27, 39, 43, 43, 43,
-        43, 38, 38, 34, 34, 31, 31, 29, 29, 27, 27, 27, 38, 41, 41, 42, 42, 37,
-        37, 33, 33, 30, 30, 28, 28, 26, 26, 25, 38, 41, 41, 42, 42, 37, 37, 33,
-        33, 30, 30, 28, 28, 26, 26, 25, 36, 39, 39, 41, 41, 36, 36, 32, 32, 29,
-        29, 27, 27, 25, 25, 24, 36, 39, 39, 41, 41, 36, 36, 32, 32, 29, 29, 27,
-        27, 25, 25, 24, 34, 38, 38, 39, 39, 35, 35, 31, 31, 28, 28, 26, 26, 24,
-        24, 23, 34, 38, 38, 39, 39, 35, 35, 31, 31, 28, 28, 26, 26, 24, 24, 23,
-        32, 36, 36, 37, 37, 34, 34, 30, 30, 27, 27, 25, 25, 23, 23, 22, 32, 36,
-        36, 37, 37, 34, 34, 30, 30, 27, 27, 25, 25, 23, 23, 22, 32, 35, 35, 37,
-        37, 33, 33, 30, 30, 27, 27, 25, 25, 23, 23, 22, 32, 35, 35, 37, 37, 33,
-        33, 30, 30, 27, 27, 25, 25, 23, 23, 22, 31, 34, 34, 36, 36, 33, 33, 29,
-        29, 27, 27, 24, 24, 22, 22, 21,
+        32, 33, 33, 33, 32, 32, 29, 28, 26, 23, 23, 20, 19, 18, 16, 16, 33, 32,
+        32, 32, 32, 32, 29, 29, 27, 24, 24, 21, 20, 18, 16, 16, 33, 32, 32, 32,
+        32, 32, 29, 29, 27, 24, 24, 21, 20, 19, 17, 17, 33, 32, 32, 32, 32, 32,
+        30, 29, 28, 25, 25, 21, 20, 19, 17, 17, 33, 32, 32, 32, 31, 31, 30, 30,
+        28, 25, 25, 22, 21, 19, 17, 17, 33, 32, 32, 32, 31, 31, 30, 30, 28, 25,
+        25, 22, 21, 19, 17, 17, 33, 32, 32, 31, 30, 30, 29, 28, 27, 24, 24, 21,
+        21, 19, 17, 17, 32, 32, 32, 31, 30, 30, 28, 28, 27, 24, 24, 21, 20, 19,
+        17, 17, 32, 32, 32, 31, 30, 30, 28, 28, 26, 24, 24, 21, 21, 19, 18, 18,
+        32, 32, 31, 30, 29, 29, 28, 27, 26, 24, 24, 21, 21, 20, 18, 18, 32, 32,
+        31, 30, 29, 29, 28, 27, 26, 24, 24, 21, 21, 20, 18, 18, 31, 31, 31, 29,
+        28, 28, 26, 25, 24, 22, 22, 20, 19, 18, 17, 17, 30, 30, 30, 29, 28, 28,
+        25, 24, 23, 21, 21, 19, 19, 18, 16, 16, 30, 30, 30, 29, 28, 28, 24, 23,
+        22, 20, 20, 19, 18, 17, 16, 16, 28, 29, 30, 28, 27, 27, 22, 21, 20, 19,
+        19, 18, 17, 16, 15, 15, 28, 29, 30, 28, 27, 27, 22, 21, 20, 19, 19, 18,
+        17, 16, 15, 15, 27, 28, 28, 27, 26, 26, 22, 20, 20, 18, 18, 17, 16, 15,
+        14, 14, 26, 27, 28, 26, 26, 26, 21, 20, 19, 18, 18, 16, 16, 15, 14, 14,
+        25, 26, 26, 26, 25, 25, 21, 20, 19, 17, 17, 16, 15, 15, 13, 13, 23, 25,
+        25, 24, 24, 24, 20, 19, 18, 16, 16, 15, 14, 14, 13, 13, 23, 25, 25, 24,
+        24, 24, 20, 19, 18, 16, 16, 15, 14, 14, 13, 13, 22, 23, 23, 23, 23, 23,
+        19, 18, 17, 16, 16, 14, 14, 13, 12, 12, 21, 23, 23, 23, 22, 22, 19, 18,
+        17, 15, 15, 14, 13, 13, 12, 12, 20, 22, 22, 22, 22, 22, 19, 18, 17, 15,
+        15, 13, 13, 12, 12, 12, 19, 20, 21, 20, 20, 20, 18, 17, 16, 14, 14, 13,
+        12, 12, 11, 11, 19, 20, 21, 20, 20, 20, 18, 17, 16, 14, 14, 13, 12, 12,
+        11, 11, 18, 19, 19, 19, 19, 19, 17, 16, 15, 14, 14, 12, 12, 11, 11, 11,
+        18, 19, 19, 19, 19, 19, 17, 16, 15, 14, 14, 12, 12, 11, 10, 10, 17, 18,
+        18, 18, 18, 18, 16, 16, 15, 13, 13, 12, 12, 11, 10, 10, 16, 17, 17, 17,
+        18, 18, 16, 15, 14, 13, 13, 12, 11, 11, 10, 10, 16, 17, 17, 17, 18, 18,
+        16, 15, 14, 13, 13, 12, 11, 11, 10, 10, 15, 16, 16, 16, 17, 17, 15, 14,
+        13, 12, 12, 11, 11, 10, 9, 9,
         /* Size 32x16 */
-        64, 65, 65, 67, 67, 61, 61, 55, 55, 49, 49, 42, 42, 42, 42, 42, 42, 41,
-        41, 39, 39, 38, 38, 36, 36, 34, 34, 32, 32, 32, 32, 31, 66, 65, 65, 64,
-        64, 57, 57, 51, 51, 48, 48, 44, 44, 45, 45, 45, 45, 44, 44, 43, 43, 41,
-        41, 39, 39, 38, 38, 36, 36, 35, 35, 34, 66, 65, 65, 64, 64, 57, 57, 51,
-        51, 48, 48, 44, 44, 45, 45, 45, 45, 44, 44, 43, 43, 41, 41, 39, 39, 38,
-        38, 36, 36, 35, 35, 34, 55, 53, 53, 51, 51, 48, 48, 44, 44, 43, 43, 43,
-        43, 44, 44, 45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 39, 39, 37, 37, 37,
-        37, 36, 55, 53, 53, 51, 51, 48, 48, 44, 44, 43, 43, 43, 43, 44, 44, 45,
-        45, 44, 44, 43, 43, 42, 42, 41, 41, 39, 39, 37, 37, 37, 37, 36, 43, 44,
-        44, 45, 45, 44, 44, 43, 43, 41, 41, 39, 39, 39, 39, 38, 38, 38, 38, 38,
-        38, 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 33, 43, 44, 44, 45, 45, 44,
-        44, 43, 43, 41, 41, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 37, 37, 36,
-        36, 35, 35, 34, 34, 33, 33, 33, 42, 44, 44, 45, 45, 45, 45, 45, 45, 41,
-        41, 38, 38, 37, 37, 35, 35, 34, 34, 34, 34, 33, 33, 32, 32, 31, 31, 30,
-        30, 30, 30, 29, 42, 44, 44, 45, 45, 45, 45, 45, 45, 41, 41, 38, 38, 37,
-        37, 35, 35, 34, 34, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 30, 30, 29,
-        39, 41, 41, 43, 43, 43, 43, 44, 44, 41, 41, 38, 38, 36, 36, 33, 33, 32,
-        32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 27, 27, 27, 39, 41, 41, 43,
-        43, 43, 43, 44, 44, 41, 41, 38, 38, 36, 36, 33, 33, 32, 32, 31, 31, 30,
-        30, 29, 29, 28, 28, 27, 27, 27, 27, 27, 36, 38, 38, 39, 39, 40, 40, 41,
-        41, 38, 38, 36, 36, 34, 34, 32, 32, 31, 31, 29, 29, 28, 28, 27, 27, 26,
-        26, 25, 25, 25, 25, 24, 36, 38, 38, 39, 39, 40, 40, 41, 41, 38, 38, 36,
-        36, 34, 34, 32, 32, 31, 31, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 25,
-        25, 24, 32, 34, 34, 36, 36, 37, 37, 38, 38, 36, 36, 34, 34, 32, 32, 30,
-        30, 29, 29, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 23, 23, 22, 32, 34,
-        34, 36, 36, 37, 37, 38, 38, 36, 36, 34, 34, 32, 32, 30, 30, 29, 29, 27,
-        27, 26, 26, 25, 25, 24, 24, 23, 23, 23, 23, 22, 31, 33, 33, 34, 34, 35,
-        35, 36, 36, 34, 34, 33, 33, 31, 31, 29, 29, 28, 28, 27, 27, 25, 25, 24,
-        24, 23, 23, 22, 22, 22, 22, 21,
+        32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 31, 30, 30, 28, 28, 27, 26,
+        25, 23, 23, 22, 21, 20, 19, 19, 18, 18, 17, 16, 16, 15, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 28, 27, 26, 25, 25, 23,
+        23, 22, 20, 20, 19, 19, 18, 17, 17, 16, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 31, 30, 30, 30, 30, 28, 28, 26, 25, 25, 23, 23, 22, 21, 21,
+        19, 19, 18, 17, 17, 16, 33, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 29,
+        29, 29, 28, 28, 27, 26, 26, 24, 24, 23, 23, 22, 20, 20, 19, 19, 18, 17,
+        17, 16, 32, 32, 32, 32, 31, 31, 30, 30, 30, 29, 29, 28, 28, 28, 27, 27,
+        26, 26, 25, 24, 24, 23, 22, 22, 20, 20, 19, 19, 18, 18, 18, 17, 32, 32,
+        32, 32, 31, 31, 30, 30, 30, 29, 29, 28, 28, 28, 27, 27, 26, 26, 25, 24,
+        24, 23, 22, 22, 20, 20, 19, 19, 18, 18, 18, 17, 29, 29, 29, 30, 30, 30,
+        29, 28, 28, 28, 28, 26, 25, 24, 22, 22, 22, 21, 21, 20, 20, 19, 19, 19,
+        18, 18, 17, 17, 16, 16, 16, 15, 28, 29, 29, 29, 30, 30, 28, 28, 28, 27,
+        27, 25, 24, 23, 21, 21, 20, 20, 20, 19, 19, 18, 18, 18, 17, 17, 16, 16,
+        16, 15, 15, 14, 26, 27, 27, 28, 28, 28, 27, 27, 26, 26, 26, 24, 23, 22,
+        20, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 15, 15, 15, 14, 14, 13,
+        23, 24, 24, 25, 25, 25, 24, 24, 24, 24, 24, 22, 21, 20, 19, 19, 18, 18,
+        17, 16, 16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 13, 12, 23, 24, 24, 25,
+        25, 25, 24, 24, 24, 24, 24, 22, 21, 20, 19, 19, 18, 18, 17, 16, 16, 16,
+        15, 15, 14, 14, 14, 14, 13, 13, 13, 12, 20, 21, 21, 21, 22, 22, 21, 21,
+        21, 21, 21, 20, 19, 19, 18, 18, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13,
+        12, 12, 12, 12, 12, 11, 19, 20, 20, 20, 21, 21, 21, 20, 21, 21, 21, 19,
+        19, 18, 17, 17, 16, 16, 15, 14, 14, 14, 13, 13, 12, 12, 12, 12, 12, 11,
+        11, 11, 18, 18, 19, 19, 19, 19, 19, 19, 19, 20, 20, 18, 18, 17, 16, 16,
+        15, 15, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11, 11, 10, 16, 16,
+        17, 17, 17, 17, 17, 17, 18, 18, 18, 17, 16, 16, 15, 15, 14, 14, 13, 13,
+        13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 9, 16, 16, 17, 17, 17, 17,
+        17, 17, 18, 18, 18, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12,
+        11, 11, 11, 10, 10, 10, 10, 9,
         /* Size 4x16 */
-        66, 43, 39, 32, 65, 44, 41, 34, 64, 45, 43, 36, 57, 44, 43, 37, 51, 43,
-        44, 38, 48, 41, 41, 36, 44, 39, 38, 34, 45, 39, 36, 32, 45, 38, 33, 30,
-        44, 38, 32, 29, 43, 38, 31, 27, 41, 37, 30, 26, 39, 36, 29, 25, 38, 35,
-        28, 24, 36, 34, 27, 23, 35, 33, 27, 23,
+        33, 32, 23, 18, 32, 32, 24, 19, 32, 31, 25, 19, 32, 30, 24, 19, 32, 30,
+        24, 19, 32, 29, 24, 20, 30, 28, 21, 18, 29, 27, 19, 16, 28, 26, 18, 15,
+        26, 25, 17, 15, 25, 24, 16, 14, 23, 22, 15, 13, 20, 20, 14, 12, 19, 19,
+        14, 11, 18, 18, 13, 11, 17, 18, 13, 11,
         /* Size 16x4 */
-        66, 65, 64, 57, 51, 48, 44, 45, 45, 44, 43, 41, 39, 38, 36, 35, 43, 44,
-        45, 44, 43, 41, 39, 39, 38, 38, 38, 37, 36, 35, 34, 33, 39, 41, 43, 43,
-        44, 41, 38, 36, 33, 32, 31, 30, 29, 28, 27, 27, 32, 34, 36, 37, 38, 36,
-        34, 32, 30, 29, 27, 26, 25, 24, 23, 23,
+        33, 32, 32, 32, 32, 32, 30, 29, 28, 26, 25, 23, 20, 19, 18, 17, 32, 32,
+        31, 30, 30, 29, 28, 27, 26, 25, 24, 22, 20, 19, 18, 18, 23, 24, 25, 24,
+        24, 24, 21, 19, 18, 17, 16, 15, 14, 14, 13, 13, 18, 19, 19, 19, 19, 20,
+        18, 16, 15, 15, 14, 13, 12, 11, 11, 11,
         /* Size 8x32 */
-        64, 66, 55, 43, 42, 39, 36, 32, 65, 65, 53, 44, 44, 41, 38, 34, 65, 65,
-        53, 44, 44, 41, 38, 34, 67, 64, 51, 45, 45, 43, 39, 36, 67, 64, 51, 45,
-        45, 43, 39, 36, 61, 57, 48, 44, 45, 43, 40, 37, 61, 57, 48, 44, 45, 43,
-        40, 37, 55, 51, 44, 43, 45, 44, 41, 38, 55, 51, 44, 43, 45, 44, 41, 38,
-        49, 48, 43, 41, 41, 41, 38, 36, 49, 48, 43, 41, 41, 41, 38, 36, 42, 44,
-        43, 39, 38, 38, 36, 34, 42, 44, 43, 39, 38, 38, 36, 34, 42, 45, 44, 39,
-        37, 36, 34, 32, 42, 45, 44, 39, 37, 36, 34, 32, 42, 45, 45, 38, 35, 33,
-        32, 30, 42, 45, 45, 38, 35, 33, 32, 30, 41, 44, 44, 38, 34, 32, 31, 29,
-        41, 44, 44, 38, 34, 32, 31, 29, 39, 43, 43, 38, 34, 31, 29, 27, 39, 43,
-        43, 38, 34, 31, 29, 27, 38, 41, 42, 37, 33, 30, 28, 26, 38, 41, 42, 37,
-        33, 30, 28, 26, 36, 39, 41, 36, 32, 29, 27, 25, 36, 39, 41, 36, 32, 29,
-        27, 25, 34, 38, 39, 35, 31, 28, 26, 24, 34, 38, 39, 35, 31, 28, 26, 24,
-        32, 36, 37, 34, 30, 27, 25, 23, 32, 36, 37, 34, 30, 27, 25, 23, 32, 35,
-        37, 33, 30, 27, 25, 23, 32, 35, 37, 33, 30, 27, 25, 23, 31, 34, 36, 33,
-        29, 27, 24, 22,
+        32, 33, 32, 29, 26, 23, 19, 16, 33, 32, 32, 29, 27, 24, 20, 16, 33, 32,
+        32, 29, 27, 24, 20, 17, 33, 32, 32, 30, 28, 25, 20, 17, 33, 32, 31, 30,
+        28, 25, 21, 17, 33, 32, 31, 30, 28, 25, 21, 17, 33, 32, 30, 29, 27, 24,
+        21, 17, 32, 32, 30, 28, 27, 24, 20, 17, 32, 32, 30, 28, 26, 24, 21, 18,
+        32, 31, 29, 28, 26, 24, 21, 18, 32, 31, 29, 28, 26, 24, 21, 18, 31, 31,
+        28, 26, 24, 22, 19, 17, 30, 30, 28, 25, 23, 21, 19, 16, 30, 30, 28, 24,
+        22, 20, 18, 16, 28, 30, 27, 22, 20, 19, 17, 15, 28, 30, 27, 22, 20, 19,
+        17, 15, 27, 28, 26, 22, 20, 18, 16, 14, 26, 28, 26, 21, 19, 18, 16, 14,
+        25, 26, 25, 21, 19, 17, 15, 13, 23, 25, 24, 20, 18, 16, 14, 13, 23, 25,
+        24, 20, 18, 16, 14, 13, 22, 23, 23, 19, 17, 16, 14, 12, 21, 23, 22, 19,
+        17, 15, 13, 12, 20, 22, 22, 19, 17, 15, 13, 12, 19, 21, 20, 18, 16, 14,
+        12, 11, 19, 21, 20, 18, 16, 14, 12, 11, 18, 19, 19, 17, 15, 14, 12, 11,
+        18, 19, 19, 17, 15, 14, 12, 10, 17, 18, 18, 16, 15, 13, 12, 10, 16, 17,
+        18, 16, 14, 13, 11, 10, 16, 17, 18, 16, 14, 13, 11, 10, 15, 16, 17, 15,
+        13, 12, 11, 9,
         /* Size 32x8 */
-        64, 65, 65, 67, 67, 61, 61, 55, 55, 49, 49, 42, 42, 42, 42, 42, 42, 41,
-        41, 39, 39, 38, 38, 36, 36, 34, 34, 32, 32, 32, 32, 31, 66, 65, 65, 64,
-        64, 57, 57, 51, 51, 48, 48, 44, 44, 45, 45, 45, 45, 44, 44, 43, 43, 41,
-        41, 39, 39, 38, 38, 36, 36, 35, 35, 34, 55, 53, 53, 51, 51, 48, 48, 44,
-        44, 43, 43, 43, 43, 44, 44, 45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 39,
-        39, 37, 37, 37, 37, 36, 43, 44, 44, 45, 45, 44, 44, 43, 43, 41, 41, 39,
-        39, 39, 39, 38, 38, 38, 38, 38, 38, 37, 37, 36, 36, 35, 35, 34, 34, 33,
-        33, 33, 42, 44, 44, 45, 45, 45, 45, 45, 45, 41, 41, 38, 38, 37, 37, 35,
-        35, 34, 34, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 30, 30, 29, 39, 41,
-        41, 43, 43, 43, 43, 44, 44, 41, 41, 38, 38, 36, 36, 33, 33, 32, 32, 31,
-        31, 30, 30, 29, 29, 28, 28, 27, 27, 27, 27, 27, 36, 38, 38, 39, 39, 40,
-        40, 41, 41, 38, 38, 36, 36, 34, 34, 32, 32, 31, 31, 29, 29, 28, 28, 27,
-        27, 26, 26, 25, 25, 25, 25, 24, 32, 34, 34, 36, 36, 37, 37, 38, 38, 36,
-        36, 34, 34, 32, 32, 30, 30, 29, 29, 27, 27, 26, 26, 25, 25, 24, 24, 23,
-        23, 23, 23, 22 },
-  },
-  {
-      { /* Luma */
-#if CONFIG_CB4X4
+        32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 31, 30, 30, 28, 28, 27, 26,
+        25, 23, 23, 22, 21, 20, 19, 19, 18, 18, 17, 16, 16, 15, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 28, 28, 26, 25, 25, 23,
+        23, 22, 21, 21, 19, 19, 18, 17, 17, 16, 32, 32, 32, 32, 31, 31, 30, 30,
+        30, 29, 29, 28, 28, 28, 27, 27, 26, 26, 25, 24, 24, 23, 22, 22, 20, 20,
+        19, 19, 18, 18, 18, 17, 29, 29, 29, 30, 30, 30, 29, 28, 28, 28, 28, 26,
+        25, 24, 22, 22, 22, 21, 21, 20, 20, 19, 19, 19, 18, 18, 17, 17, 16, 16,
+        16, 15, 26, 27, 27, 28, 28, 28, 27, 27, 26, 26, 26, 24, 23, 22, 20, 20,
+        20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 15, 15, 15, 14, 14, 13, 23, 24,
+        24, 25, 25, 25, 24, 24, 24, 24, 24, 22, 21, 20, 19, 19, 18, 18, 17, 16,
+        16, 16, 15, 15, 14, 14, 14, 14, 13, 13, 13, 12, 19, 20, 20, 20, 21, 21,
+        21, 20, 21, 21, 21, 19, 19, 18, 17, 17, 16, 16, 15, 14, 14, 14, 13, 13,
+        12, 12, 12, 12, 12, 11, 11, 11, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18,
+        18, 17, 16, 16, 15, 15, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10,
+        10, 10, 10, 9 },
+      { /* Chroma */
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        60, 39, 39, 23,
+        26, 22, 22, 16,
 #endif
         /* Size 4x4 */
-        64, 61, 46, 33, 61, 52, 40, 32, 46, 40, 29, 24, 33, 32, 24, 19,
+        33, 25, 22, 20, 25, 21, 21, 20, 22, 21, 18, 17, 20, 20, 17, 14,
         /* Size 8x8 */
-        65, 64, 63, 58, 48, 40, 34, 30, 64, 63, 61, 58, 49, 42, 36, 31, 63, 61,
-        58, 53, 48, 41, 37, 32, 58, 58, 53, 42, 38, 34, 31, 28, 48, 49, 48, 38,
-        32, 29, 26, 24, 40, 42, 41, 34, 29, 25, 23, 21, 34, 36, 37, 31, 26, 23,
-        21, 19, 30, 31, 32, 28, 24, 21, 19, 17,
+        33, 33, 27, 23, 22, 21, 20, 19, 33, 32, 26, 23, 23, 22, 22, 20, 27, 26,
+        22, 22, 22, 22, 22, 20, 23, 23, 22, 20, 20, 20, 20, 19, 22, 23, 22, 20,
+        19, 18, 18, 17, 21, 22, 22, 20, 18, 17, 16, 16, 20, 22, 22, 20, 18, 16,
+        16, 15, 19, 20, 20, 19, 17, 16, 15, 13,
         /* Size 16x16 */
-        64, 65, 65, 65, 64, 60, 58, 54, 50, 46, 42, 38, 35, 31, 29, 26, 65, 64,
-        64, 64, 63, 60, 59, 55, 51, 48, 44, 40, 36, 33, 30, 27, 65, 64, 63, 63,
-        63, 61, 60, 57, 53, 49, 46, 41, 38, 34, 32, 28, 65, 64, 63, 61, 60, 58,
-        57, 54, 51, 48, 45, 41, 38, 35, 32, 29, 64, 63, 63, 60, 58, 55, 54, 52,
-        49, 47, 45, 41, 38, 35, 33, 29, 60, 60, 61, 58, 55, 52, 49, 47, 45, 42,
-        40, 38, 35, 33, 30, 28, 58, 59, 60, 57, 54, 49, 45, 42, 41, 39, 37, 35,
-        33, 31, 28, 26, 54, 55, 57, 54, 52, 47, 42, 40, 38, 36, 34, 33, 31, 29,
-        27, 25, 50, 51, 53, 51, 49, 45, 41, 38, 36, 34, 32, 30, 29, 27, 25, 24,
-        46, 48, 49, 48, 47, 42, 39, 36, 34, 32, 30, 28, 27, 25, 24, 22, 42, 44,
-        46, 45, 45, 40, 37, 34, 32, 30, 29, 27, 25, 24, 23, 21, 38, 40, 41, 41,
-        41, 38, 35, 33, 30, 28, 27, 25, 24, 22, 21, 20, 35, 36, 38, 38, 38, 35,
-        33, 31, 29, 27, 25, 24, 22, 21, 20, 19, 31, 33, 34, 35, 35, 33, 31, 29,
-        27, 25, 24, 22, 21, 20, 18, 17, 29, 30, 32, 32, 33, 30, 28, 27, 25, 24,
-        23, 21, 20, 18, 17, 16, 26, 27, 28, 29, 29, 28, 26, 25, 24, 22, 21, 20,
-        19, 17, 16, 15,
+        32, 33, 34, 31, 30, 28, 25, 21, 21, 21, 21, 20, 20, 19, 19, 18, 33, 33,
+        33, 30, 28, 27, 24, 22, 22, 22, 22, 21, 20, 20, 19, 19, 34, 33, 32, 30,
+        28, 26, 24, 22, 23, 23, 23, 22, 22, 21, 20, 20, 31, 30, 30, 28, 26, 24,
+        23, 22, 22, 22, 23, 22, 22, 21, 20, 20, 30, 28, 28, 26, 24, 23, 22, 22,
+        22, 22, 23, 22, 22, 21, 21, 20, 28, 27, 26, 24, 23, 22, 22, 21, 22, 22,
+        23, 22, 22, 21, 21, 20, 25, 24, 24, 23, 22, 22, 21, 20, 20, 21, 21, 20,
+        20, 20, 20, 19, 21, 22, 22, 22, 22, 21, 20, 19, 19, 19, 19, 19, 19, 19,
+        18, 18, 21, 22, 23, 22, 22, 22, 20, 19, 19, 19, 19, 18, 18, 18, 18, 17,
+        21, 22, 23, 22, 22, 22, 21, 19, 19, 19, 18, 18, 17, 17, 17, 17, 21, 22,
+        23, 23, 23, 23, 21, 19, 19, 18, 18, 17, 17, 17, 16, 16, 20, 21, 22, 22,
+        22, 22, 20, 19, 18, 18, 17, 17, 16, 16, 16, 15, 20, 20, 22, 22, 22, 22,
+        20, 19, 18, 17, 17, 16, 16, 15, 15, 15, 19, 20, 21, 21, 21, 21, 20, 19,
+        18, 17, 17, 16, 15, 15, 14, 14, 19, 19, 20, 20, 21, 21, 20, 18, 18, 17,
+        16, 16, 15, 14, 14, 14, 18, 19, 20, 20, 20, 20, 19, 18, 17, 17, 16, 15,
+        15, 14, 14, 13,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 65, 64, 64, 64, 60, 60, 58, 57, 54, 52, 50, 47,
-        46, 42, 42, 38, 38, 36, 35, 33, 31, 31, 29, 28, 26, 26, 65, 65, 64, 64,
-        64, 64, 64, 64, 63, 63, 60, 60, 59, 58, 55, 53, 51, 48, 47, 44, 44, 40,
-        39, 37, 36, 34, 33, 32, 30, 30, 27, 27, 65, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 60, 60, 59, 59, 55, 53, 51, 48, 48, 44, 44, 40, 40, 37, 36, 35,
-        33, 32, 30, 30, 27, 27, 65, 64, 64, 64, 64, 63, 63, 63, 63, 63, 61, 61,
-        59, 59, 56, 54, 53, 49, 49, 46, 46, 41, 41, 39, 38, 36, 34, 33, 31, 31,
-        28, 28, 65, 64, 64, 64, 63, 63, 63, 63, 63, 62, 61, 61, 60, 59, 57, 55,
-        53, 50, 49, 46, 46, 42, 41, 39, 38, 36, 34, 34, 32, 31, 28, 28, 65, 64,
-        64, 63, 63, 63, 62, 62, 61, 61, 59, 59, 59, 58, 55, 53, 52, 49, 49, 46,
-        46, 42, 41, 39, 38, 36, 34, 34, 32, 31, 28, 28, 65, 64, 64, 63, 63, 62,
-        61, 61, 60, 60, 58, 58, 57, 56, 54, 53, 51, 49, 48, 45, 45, 41, 41, 39,
-        38, 36, 35, 34, 32, 32, 29, 29, 64, 64, 64, 63, 63, 62, 61, 60, 59, 59,
-        58, 58, 56, 55, 53, 52, 51, 49, 48, 45, 45, 41, 41, 39, 38, 36, 35, 34,
-        32, 32, 29, 29, 64, 63, 63, 63, 63, 61, 60, 59, 58, 58, 55, 55, 54, 53,
-        52, 51, 49, 48, 47, 45, 45, 42, 41, 39, 38, 37, 35, 34, 33, 32, 29, 29,
-        64, 63, 63, 63, 62, 61, 60, 59, 58, 58, 55, 55, 53, 53, 51, 50, 49, 48,
-        47, 44, 44, 41, 41, 39, 38, 37, 35, 34, 32, 32, 29, 29, 60, 60, 60, 61,
-        61, 59, 58, 58, 55, 55, 52, 52, 49, 48, 47, 46, 45, 43, 42, 40, 40, 38,
-        38, 36, 35, 34, 33, 32, 30, 30, 28, 28, 60, 60, 60, 61, 61, 59, 58, 58,
-        55, 55, 52, 52, 49, 48, 47, 46, 45, 43, 42, 40, 40, 38, 38, 36, 35, 34,
-        33, 32, 30, 30, 28, 28, 58, 59, 59, 59, 60, 59, 57, 56, 54, 53, 49, 49,
-        45, 44, 42, 41, 41, 39, 39, 37, 37, 35, 35, 33, 33, 32, 31, 30, 28, 28,
-        26, 26, 57, 58, 59, 59, 59, 58, 56, 55, 53, 53, 48, 48, 44, 42, 41, 41,
-        39, 38, 38, 36, 36, 34, 34, 33, 32, 31, 30, 29, 28, 28, 26, 26, 54, 55,
-        55, 56, 57, 55, 54, 53, 52, 51, 47, 47, 42, 41, 40, 39, 38, 37, 36, 34,
-        34, 33, 33, 31, 31, 30, 29, 28, 27, 27, 25, 25, 52, 53, 53, 54, 55, 53,
-        53, 52, 51, 50, 46, 46, 41, 41, 39, 38, 37, 35, 35, 34, 34, 32, 32, 30,
-        30, 29, 28, 27, 26, 26, 24, 24, 50, 51, 51, 53, 53, 52, 51, 51, 49, 49,
-        45, 45, 41, 39, 38, 37, 36, 34, 34, 32, 32, 31, 30, 29, 29, 28, 27, 27,
-        25, 25, 24, 24, 47, 48, 48, 49, 50, 49, 49, 49, 48, 48, 43, 43, 39, 38,
-        37, 35, 34, 32, 32, 31, 31, 29, 29, 28, 27, 26, 26, 25, 24, 24, 23, 23,
-        46, 47, 48, 49, 49, 49, 48, 48, 47, 47, 42, 42, 39, 38, 36, 35, 34, 32,
-        32, 30, 30, 28, 28, 27, 27, 26, 25, 25, 24, 24, 22, 22, 42, 44, 44, 46,
-        46, 46, 45, 45, 45, 44, 40, 40, 37, 36, 34, 34, 32, 31, 30, 29, 29, 27,
-        27, 26, 25, 25, 24, 24, 23, 23, 21, 21, 42, 44, 44, 46, 46, 46, 45, 45,
-        45, 44, 40, 40, 37, 36, 34, 34, 32, 31, 30, 29, 29, 27, 27, 26, 25, 25,
-        24, 24, 23, 23, 21, 21, 38, 40, 40, 41, 42, 42, 41, 41, 42, 41, 38, 38,
-        35, 34, 33, 32, 31, 29, 28, 27, 27, 25, 25, 24, 24, 23, 22, 22, 21, 21,
-        20, 20, 38, 39, 40, 41, 41, 41, 41, 41, 41, 41, 38, 38, 35, 34, 33, 32,
-        30, 29, 28, 27, 27, 25, 25, 24, 24, 23, 22, 22, 21, 21, 20, 20, 36, 37,
-        37, 39, 39, 39, 39, 39, 39, 39, 36, 36, 33, 33, 31, 30, 29, 28, 27, 26,
-        26, 24, 24, 23, 23, 22, 21, 21, 20, 20, 19, 19, 35, 36, 36, 38, 38, 38,
-        38, 38, 38, 38, 35, 35, 33, 32, 31, 30, 29, 27, 27, 25, 25, 24, 24, 23,
-        22, 22, 21, 21, 20, 20, 19, 19, 33, 34, 35, 36, 36, 36, 36, 36, 37, 37,
-        34, 34, 32, 31, 30, 29, 28, 26, 26, 25, 25, 23, 23, 22, 22, 21, 20, 20,
-        19, 19, 18, 18, 31, 33, 33, 34, 34, 34, 35, 35, 35, 35, 33, 33, 31, 30,
-        29, 28, 27, 26, 25, 24, 24, 22, 22, 21, 21, 20, 20, 19, 18, 18, 17, 17,
-        31, 32, 32, 33, 34, 34, 34, 34, 34, 34, 32, 32, 30, 29, 28, 27, 27, 25,
-        25, 24, 24, 22, 22, 21, 21, 20, 19, 19, 18, 18, 17, 17, 29, 30, 30, 31,
-        32, 32, 32, 32, 33, 32, 30, 30, 28, 28, 27, 26, 25, 24, 24, 23, 23, 21,
-        21, 20, 20, 19, 18, 18, 17, 17, 16, 16, 28, 30, 30, 31, 31, 31, 32, 32,
-        32, 32, 30, 30, 28, 28, 27, 26, 25, 24, 24, 23, 23, 21, 21, 20, 20, 19,
-        18, 18, 17, 17, 16, 16, 26, 27, 27, 28, 28, 28, 29, 29, 29, 29, 28, 28,
-        26, 26, 25, 24, 24, 23, 22, 21, 21, 20, 20, 19, 19, 18, 17, 17, 16, 16,
-        15, 15, 26, 27, 27, 28, 28, 28, 29, 29, 29, 29, 28, 28, 26, 26, 25, 24,
-        24, 23, 22, 21, 21, 20, 20, 19, 19, 18, 17, 17, 16, 16, 15, 15,
+        32, 33, 33, 33, 34, 34, 31, 31, 30, 28, 28, 26, 25, 23, 21, 21, 21, 21,
+        21, 21, 21, 20, 20, 20, 20, 20, 19, 19, 19, 18, 18, 17, 33, 33, 33, 33,
+        33, 33, 31, 30, 28, 27, 27, 25, 24, 23, 21, 21, 22, 22, 22, 22, 22, 21,
+        21, 21, 20, 20, 20, 20, 19, 19, 19, 18, 33, 33, 33, 33, 33, 33, 30, 30,
+        28, 27, 27, 25, 24, 23, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 20, 20,
+        20, 20, 19, 19, 19, 18, 33, 33, 33, 33, 33, 33, 30, 29, 28, 26, 26, 25,
+        24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 19,
+        19, 19, 34, 33, 33, 33, 32, 32, 30, 29, 28, 26, 26, 24, 24, 23, 22, 22,
+        23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 19, 34, 33,
+        33, 33, 32, 32, 30, 29, 28, 26, 26, 24, 24, 23, 22, 22, 23, 23, 23, 23,
+        23, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 19, 31, 31, 30, 30, 30, 30,
+        28, 27, 26, 24, 24, 23, 23, 23, 22, 22, 22, 22, 22, 23, 23, 22, 22, 22,
+        22, 22, 21, 21, 20, 20, 20, 19, 31, 30, 30, 29, 29, 29, 27, 26, 26, 24,
+        24, 23, 23, 22, 22, 22, 22, 22, 22, 23, 23, 22, 22, 22, 22, 22, 21, 21,
+        20, 20, 20, 19, 30, 28, 28, 28, 28, 28, 26, 26, 24, 23, 23, 23, 22, 22,
+        22, 22, 22, 22, 22, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 20,
+        28, 27, 27, 26, 26, 26, 24, 24, 23, 22, 22, 22, 22, 22, 21, 21, 22, 22,
+        22, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 28, 27, 27, 26,
+        26, 26, 24, 24, 23, 22, 22, 22, 22, 22, 21, 21, 22, 22, 22, 23, 23, 22,
+        22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 26, 25, 25, 25, 24, 24, 23, 23,
+        23, 22, 22, 21, 21, 21, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+        20, 20, 20, 20, 20, 19, 25, 24, 24, 24, 24, 24, 23, 23, 22, 22, 22, 21,
+        21, 21, 20, 20, 20, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 19,
+        19, 19, 23, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 21, 21, 20, 20, 20,
+        20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 18, 21, 21,
+        22, 22, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 21, 21, 22, 22, 22, 22,
+        22, 22, 22, 21, 21, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 18, 18, 18, 18, 21, 22, 22, 22, 23, 23, 22, 22, 22, 22,
+        22, 21, 20, 20, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18,
+        18, 17, 17, 17, 21, 22, 22, 22, 23, 23, 22, 22, 22, 22, 22, 21, 21, 20,
+        19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17,
+        21, 22, 22, 22, 23, 23, 22, 22, 22, 22, 22, 21, 21, 20, 19, 19, 19, 19,
+        19, 18, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 16, 21, 22, 22, 22,
+        23, 23, 23, 23, 23, 23, 23, 21, 21, 20, 19, 19, 19, 19, 18, 18, 18, 17,
+        17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 21, 22, 22, 22, 23, 23, 23, 23,
+        23, 23, 23, 21, 21, 20, 19, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 17,
+        17, 17, 16, 16, 16, 16, 20, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 21,
+        20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16,
+        16, 15, 20, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 19, 19,
+        18, 18, 18, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 15, 15, 15, 20, 21,
+        21, 21, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 19, 19, 18, 18, 18, 17,
+        17, 17, 17, 16, 16, 16, 16, 16, 15, 15, 15, 15, 20, 20, 20, 21, 22, 22,
+        22, 22, 22, 22, 22, 21, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16,
+        16, 16, 15, 15, 15, 15, 15, 14, 20, 20, 20, 21, 22, 22, 22, 22, 22, 22,
+        22, 21, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 16, 16, 15, 15,
+        15, 15, 15, 14, 19, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 20, 20, 19,
+        19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14,
+        19, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 20, 20, 19, 19, 19, 18, 18,
+        17, 17, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14, 14, 14, 19, 19, 19, 20,
+        20, 20, 20, 20, 21, 21, 21, 20, 20, 19, 18, 18, 18, 17, 17, 16, 16, 16,
+        16, 15, 15, 15, 14, 14, 14, 14, 14, 13, 18, 19, 19, 19, 20, 20, 20, 20,
+        20, 20, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15,
+        14, 14, 14, 13, 13, 13, 18, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20,
+        19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 13,
+        13, 13, 17, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 19, 19, 18, 18, 18,
+        17, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13,
         /* Size 4x8 */
-        64, 60, 47, 33, 63, 59, 49, 34, 62, 55, 47, 35, 59, 48, 38, 30, 49, 43,
-        32, 26, 41, 38, 29, 22, 36, 34, 26, 20, 31, 30, 24, 18,
+        33, 27, 22, 20, 32, 26, 23, 21, 26, 22, 23, 21, 23, 22, 20, 19, 22, 22,
+        18, 18, 22, 22, 17, 16, 21, 22, 17, 15, 19, 20, 16, 14,
         /* Size 8x4 */
-        64, 63, 62, 59, 49, 41, 36, 31, 60, 59, 55, 48, 43, 38, 34, 30, 47, 49,
-        47, 38, 32, 29, 26, 24, 33, 34, 35, 30, 26, 22, 20, 18,
+        33, 32, 26, 23, 22, 22, 21, 19, 27, 26, 22, 22, 22, 22, 22, 20, 22, 23,
+        23, 20, 18, 17, 17, 16, 20, 21, 21, 19, 18, 16, 15, 14,
         /* Size 8x16 */
-        64, 65, 64, 57, 47, 38, 33, 28, 65, 64, 63, 58, 48, 40, 34, 29, 65, 63,
-        62, 59, 50, 41, 36, 31, 64, 63, 60, 56, 49, 41, 36, 31, 64, 62, 58, 53,
-        48, 41, 37, 32, 60, 60, 55, 48, 43, 38, 34, 30, 58, 59, 54, 44, 39, 35,
-        32, 28, 54, 56, 51, 41, 37, 33, 29, 27, 50, 53, 49, 40, 34, 30, 28, 25,
-        46, 49, 47, 38, 32, 28, 26, 24, 43, 46, 44, 36, 31, 27, 25, 22, 38, 41,
-        41, 34, 29, 25, 23, 21, 35, 38, 38, 32, 27, 24, 21, 20, 32, 34, 35, 30,
-        26, 22, 20, 18, 29, 31, 32, 28, 24, 21, 19, 17, 26, 28, 29, 26, 23, 20,
-        18, 16,
+        32, 33, 28, 23, 21, 21, 20, 18, 33, 33, 27, 23, 22, 22, 20, 19, 34, 32,
+        26, 23, 23, 23, 21, 20, 31, 29, 24, 22, 22, 23, 22, 20, 29, 28, 23, 22,
+        22, 23, 22, 20, 28, 26, 22, 22, 22, 23, 22, 20, 24, 24, 22, 21, 20, 21,
+        20, 19, 21, 22, 21, 20, 19, 19, 19, 18, 21, 22, 22, 20, 19, 19, 18, 17,
+        21, 23, 22, 20, 19, 18, 17, 17, 21, 23, 22, 20, 19, 18, 17, 16, 20, 22,
+        22, 20, 18, 17, 16, 15, 20, 21, 22, 19, 18, 17, 16, 14, 19, 21, 21, 19,
+        18, 17, 15, 14, 19, 20, 21, 19, 18, 16, 15, 14, 18, 20, 20, 19, 17, 16,
+        15, 13,
         /* Size 16x8 */
-        64, 65, 65, 64, 64, 60, 58, 54, 50, 46, 43, 38, 35, 32, 29, 26, 65, 64,
-        63, 63, 62, 60, 59, 56, 53, 49, 46, 41, 38, 34, 31, 28, 64, 63, 62, 60,
-        58, 55, 54, 51, 49, 47, 44, 41, 38, 35, 32, 29, 57, 58, 59, 56, 53, 48,
-        44, 41, 40, 38, 36, 34, 32, 30, 28, 26, 47, 48, 50, 49, 48, 43, 39, 37,
-        34, 32, 31, 29, 27, 26, 24, 23, 38, 40, 41, 41, 41, 38, 35, 33, 30, 28,
-        27, 25, 24, 22, 21, 20, 33, 34, 36, 36, 37, 34, 32, 29, 28, 26, 25, 23,
-        21, 20, 19, 18, 28, 29, 31, 31, 32, 30, 28, 27, 25, 24, 22, 21, 20, 18,
-        17, 16,
+        32, 33, 34, 31, 29, 28, 24, 21, 21, 21, 21, 20, 20, 19, 19, 18, 33, 33,
+        32, 29, 28, 26, 24, 22, 22, 23, 23, 22, 21, 21, 20, 20, 28, 27, 26, 24,
+        23, 22, 22, 21, 22, 22, 22, 22, 22, 21, 21, 20, 23, 23, 23, 22, 22, 22,
+        21, 20, 20, 20, 20, 20, 19, 19, 19, 19, 21, 22, 23, 22, 22, 22, 20, 19,
+        19, 19, 19, 18, 18, 18, 18, 17, 21, 22, 23, 23, 23, 23, 21, 19, 19, 18,
+        18, 17, 17, 17, 16, 16, 20, 20, 21, 22, 22, 22, 20, 19, 18, 17, 17, 16,
+        16, 15, 15, 15, 18, 19, 20, 20, 20, 20, 19, 18, 17, 17, 16, 15, 14, 14,
+        14, 13,
         /* Size 16x32 */
-        64, 65, 65, 64, 64, 60, 57, 54, 47, 46, 38, 38, 33, 31, 28, 26, 65, 64,
-        64, 63, 63, 60, 58, 55, 48, 47, 40, 40, 34, 33, 29, 27, 65, 64, 64, 63,
-        63, 60, 58, 55, 48, 48, 40, 40, 34, 33, 29, 27, 65, 64, 64, 63, 63, 61,
-        59, 56, 49, 49, 41, 41, 35, 34, 31, 28, 65, 63, 63, 63, 62, 61, 59, 56,
-        50, 49, 41, 41, 36, 34, 31, 28, 65, 63, 63, 62, 61, 59, 58, 55, 49, 49,
-        41, 41, 36, 34, 31, 29, 64, 63, 63, 61, 60, 58, 56, 54, 49, 48, 41, 41,
-        36, 35, 31, 29, 64, 63, 63, 60, 59, 58, 55, 53, 48, 48, 41, 41, 36, 35,
-        32, 29, 64, 63, 62, 59, 58, 55, 53, 52, 48, 47, 41, 41, 37, 35, 32, 30,
-        64, 62, 62, 59, 58, 55, 53, 51, 48, 47, 41, 41, 36, 35, 32, 29, 60, 60,
-        60, 57, 55, 52, 48, 47, 43, 42, 38, 38, 34, 33, 30, 28, 60, 60, 60, 57,
-        55, 52, 48, 47, 43, 42, 38, 38, 34, 33, 30, 28, 58, 59, 59, 55, 54, 49,
-        44, 42, 39, 39, 35, 35, 32, 31, 28, 26, 57, 59, 59, 55, 53, 48, 43, 41,
-        38, 38, 34, 34, 31, 30, 28, 26, 54, 56, 56, 53, 51, 47, 41, 40, 37, 36,
-        33, 33, 29, 29, 27, 25, 52, 54, 55, 51, 51, 46, 41, 39, 35, 35, 32, 32,
-        29, 28, 26, 24, 50, 53, 53, 50, 49, 45, 40, 38, 34, 34, 30, 30, 28, 27,
-        25, 24, 47, 49, 50, 48, 48, 43, 38, 37, 33, 32, 29, 29, 26, 26, 24, 23,
-        46, 49, 49, 48, 47, 42, 38, 36, 32, 32, 28, 28, 26, 25, 24, 23, 43, 46,
-        46, 45, 44, 40, 36, 34, 31, 30, 27, 27, 25, 24, 22, 21, 43, 46, 46, 45,
-        44, 40, 36, 34, 31, 30, 27, 27, 25, 24, 22, 21, 39, 41, 42, 41, 41, 38,
-        34, 33, 29, 29, 25, 25, 23, 22, 21, 20, 38, 41, 41, 41, 41, 38, 34, 33,
-        29, 28, 25, 25, 23, 22, 21, 20, 36, 39, 39, 39, 39, 36, 33, 31, 28, 27,
-        24, 24, 22, 21, 20, 19, 35, 38, 38, 38, 38, 35, 32, 31, 27, 27, 24, 24,
-        21, 21, 20, 19, 33, 36, 36, 36, 37, 34, 31, 30, 26, 26, 23, 23, 21, 20,
-        19, 18, 32, 34, 34, 35, 35, 33, 30, 29, 26, 25, 22, 22, 20, 20, 18, 17,
-        31, 33, 33, 34, 34, 32, 29, 28, 25, 25, 22, 22, 20, 19, 18, 17, 29, 31,
-        31, 32, 32, 30, 28, 27, 24, 24, 21, 21, 19, 18, 17, 16, 28, 31, 31, 32,
-        32, 30, 28, 27, 24, 24, 21, 21, 19, 18, 17, 16, 26, 28, 28, 29, 29, 28,
-        26, 25, 23, 22, 20, 20, 18, 17, 16, 15, 26, 28, 28, 29, 29, 28, 26, 25,
-        23, 22, 20, 20, 18, 17, 16, 15,
+        32, 33, 33, 31, 28, 28, 23, 21, 21, 21, 21, 20, 20, 19, 18, 18, 33, 33,
+        33, 30, 27, 27, 23, 22, 22, 22, 22, 20, 20, 20, 19, 19, 33, 33, 33, 30,
+        27, 27, 23, 22, 22, 22, 22, 21, 20, 20, 19, 19, 33, 33, 32, 30, 26, 26,
+        23, 22, 22, 22, 22, 21, 21, 20, 19, 19, 34, 32, 32, 29, 26, 26, 23, 22,
+        23, 23, 23, 22, 21, 21, 20, 20, 34, 32, 32, 29, 26, 26, 23, 22, 23, 23,
+        23, 22, 21, 21, 20, 20, 31, 30, 29, 28, 24, 24, 22, 22, 22, 23, 23, 22,
+        22, 21, 20, 20, 31, 29, 28, 27, 24, 24, 22, 22, 22, 22, 22, 22, 22, 21,
+        20, 20, 29, 28, 28, 26, 23, 23, 22, 22, 22, 23, 23, 22, 22, 21, 20, 20,
+        28, 26, 26, 24, 22, 22, 22, 22, 22, 23, 23, 22, 22, 21, 20, 20, 28, 26,
+        26, 24, 22, 22, 22, 22, 22, 23, 23, 22, 22, 21, 20, 20, 25, 24, 24, 23,
+        22, 22, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 24, 24, 24, 23, 22, 22,
+        21, 20, 20, 21, 21, 20, 20, 20, 19, 19, 23, 23, 23, 23, 22, 22, 20, 20,
+        20, 20, 20, 20, 20, 19, 19, 19, 21, 22, 22, 22, 21, 21, 20, 19, 19, 19,
+        19, 19, 19, 19, 18, 18, 21, 22, 22, 22, 21, 21, 20, 19, 19, 19, 19, 19,
+        19, 19, 18, 18, 21, 22, 22, 22, 22, 22, 20, 19, 19, 19, 19, 18, 18, 18,
+        17, 17, 21, 22, 22, 22, 22, 22, 20, 19, 19, 18, 18, 18, 18, 18, 17, 17,
+        21, 22, 23, 22, 22, 22, 20, 19, 19, 18, 18, 18, 17, 17, 17, 17, 21, 22,
+        23, 23, 22, 22, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 21, 22, 23, 23,
+        22, 22, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 20, 22, 22, 22, 22, 22,
+        20, 19, 18, 17, 17, 17, 16, 16, 16, 16, 20, 22, 22, 22, 22, 22, 20, 19,
+        18, 17, 17, 16, 16, 16, 15, 15, 20, 21, 22, 22, 22, 22, 20, 19, 18, 17,
+        17, 16, 16, 16, 15, 15, 20, 21, 21, 22, 22, 22, 19, 19, 18, 17, 17, 16,
+        16, 15, 14, 14, 20, 21, 21, 22, 22, 22, 19, 19, 18, 17, 17, 16, 16, 15,
+        14, 14, 19, 20, 21, 21, 21, 21, 19, 19, 18, 17, 17, 15, 15, 15, 14, 14,
+        19, 20, 20, 21, 21, 21, 19, 19, 18, 17, 17, 15, 15, 15, 14, 14, 19, 20,
+        20, 20, 21, 21, 19, 18, 18, 16, 16, 15, 15, 14, 14, 14, 18, 19, 20, 20,
+        20, 20, 19, 18, 17, 16, 16, 15, 15, 14, 13, 13, 18, 19, 20, 20, 20, 20,
+        19, 18, 17, 16, 16, 15, 15, 14, 13, 13, 17, 19, 19, 19, 20, 20, 18, 18,
+        17, 16, 16, 15, 14, 14, 13, 13,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 64, 64, 64, 64, 60, 60, 58, 57, 54, 52, 50, 47,
-        46, 43, 43, 39, 38, 36, 35, 33, 32, 31, 29, 28, 26, 26, 65, 64, 64, 64,
-        63, 63, 63, 63, 63, 62, 60, 60, 59, 59, 56, 54, 53, 49, 49, 46, 46, 41,
-        41, 39, 38, 36, 34, 33, 31, 31, 28, 28, 65, 64, 64, 64, 63, 63, 63, 63,
-        62, 62, 60, 60, 59, 59, 56, 55, 53, 50, 49, 46, 46, 42, 41, 39, 38, 36,
-        34, 33, 31, 31, 28, 28, 64, 63, 63, 63, 63, 62, 61, 60, 59, 59, 57, 57,
-        55, 55, 53, 51, 50, 48, 48, 45, 45, 41, 41, 39, 38, 36, 35, 34, 32, 32,
-        29, 29, 64, 63, 63, 63, 62, 61, 60, 59, 58, 58, 55, 55, 54, 53, 51, 51,
-        49, 48, 47, 44, 44, 41, 41, 39, 38, 37, 35, 34, 32, 32, 29, 29, 60, 60,
-        60, 61, 61, 59, 58, 58, 55, 55, 52, 52, 49, 48, 47, 46, 45, 43, 42, 40,
-        40, 38, 38, 36, 35, 34, 33, 32, 30, 30, 28, 28, 57, 58, 58, 59, 59, 58,
-        56, 55, 53, 53, 48, 48, 44, 43, 41, 41, 40, 38, 38, 36, 36, 34, 34, 33,
-        32, 31, 30, 29, 28, 28, 26, 26, 54, 55, 55, 56, 56, 55, 54, 53, 52, 51,
-        47, 47, 42, 41, 40, 39, 38, 37, 36, 34, 34, 33, 33, 31, 31, 30, 29, 28,
-        27, 27, 25, 25, 47, 48, 48, 49, 50, 49, 49, 48, 48, 48, 43, 43, 39, 38,
-        37, 35, 34, 33, 32, 31, 31, 29, 29, 28, 27, 26, 26, 25, 24, 24, 23, 23,
-        46, 47, 48, 49, 49, 49, 48, 48, 47, 47, 42, 42, 39, 38, 36, 35, 34, 32,
-        32, 30, 30, 29, 28, 27, 27, 26, 25, 25, 24, 24, 22, 22, 38, 40, 40, 41,
-        41, 41, 41, 41, 41, 41, 38, 38, 35, 34, 33, 32, 30, 29, 28, 27, 27, 25,
-        25, 24, 24, 23, 22, 22, 21, 21, 20, 20, 38, 40, 40, 41, 41, 41, 41, 41,
-        41, 41, 38, 38, 35, 34, 33, 32, 30, 29, 28, 27, 27, 25, 25, 24, 24, 23,
-        22, 22, 21, 21, 20, 20, 33, 34, 34, 35, 36, 36, 36, 36, 37, 36, 34, 34,
-        32, 31, 29, 29, 28, 26, 26, 25, 25, 23, 23, 22, 21, 21, 20, 20, 19, 19,
-        18, 18, 31, 33, 33, 34, 34, 34, 35, 35, 35, 35, 33, 33, 31, 30, 29, 28,
-        27, 26, 25, 24, 24, 22, 22, 21, 21, 20, 20, 19, 18, 18, 17, 17, 28, 29,
-        29, 31, 31, 31, 31, 32, 32, 32, 30, 30, 28, 28, 27, 26, 25, 24, 24, 22,
-        22, 21, 21, 20, 20, 19, 18, 18, 17, 17, 16, 16, 26, 27, 27, 28, 28, 29,
-        29, 29, 30, 29, 28, 28, 26, 26, 25, 24, 24, 23, 23, 21, 21, 20, 20, 19,
-        19, 18, 17, 17, 16, 16, 15, 15,
+        32, 33, 33, 33, 34, 34, 31, 31, 29, 28, 28, 25, 24, 23, 21, 21, 21, 21,
+        21, 21, 21, 20, 20, 20, 20, 20, 19, 19, 19, 18, 18, 17, 33, 33, 33, 33,
+        32, 32, 30, 29, 28, 26, 26, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 33, 33, 33, 32, 32, 32, 29, 28,
+        28, 26, 26, 24, 24, 23, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 21, 21,
+        21, 20, 20, 20, 20, 19, 31, 30, 30, 30, 29, 29, 28, 27, 26, 24, 24, 23,
+        23, 23, 22, 22, 22, 22, 22, 23, 23, 22, 22, 22, 22, 22, 21, 21, 20, 20,
+        20, 19, 28, 27, 27, 26, 26, 26, 24, 24, 23, 22, 22, 22, 22, 22, 21, 21,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 28, 27,
+        27, 26, 26, 26, 24, 24, 23, 22, 22, 22, 22, 22, 21, 21, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 23, 23, 23, 23, 23, 23,
+        22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+        19, 19, 19, 19, 19, 19, 19, 18, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 21, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        18, 18, 18, 18, 21, 22, 22, 22, 23, 23, 22, 22, 22, 22, 22, 21, 20, 20,
+        19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18, 18, 17, 17, 17,
+        21, 22, 22, 22, 23, 23, 23, 22, 23, 23, 23, 21, 21, 20, 19, 19, 19, 18,
+        18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 21, 22, 22, 22,
+        23, 23, 23, 22, 23, 23, 23, 21, 21, 20, 19, 19, 19, 18, 18, 18, 18, 17,
+        17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 20, 20, 21, 21, 22, 22, 22, 22,
+        22, 22, 22, 21, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 16,
+        15, 15, 15, 15, 15, 15, 20, 20, 20, 21, 21, 21, 22, 22, 22, 22, 22, 20,
+        20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 16, 16, 15, 15, 15, 15,
+        15, 14, 19, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 20, 20, 19, 19, 19,
+        18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 18, 19,
+        19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16,
+        16, 16, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13, 18, 19, 19, 19, 20, 20,
+        20, 20, 20, 20, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15,
+        14, 14, 14, 14, 14, 13, 13, 13,
         /* Size 4x16 */
-        65, 60, 46, 31, 64, 60, 48, 33, 63, 61, 49, 34, 63, 58, 48, 35, 63, 55,
-        47, 35, 60, 52, 42, 33, 59, 49, 39, 31, 56, 47, 36, 29, 53, 45, 34, 27,
-        49, 42, 32, 25, 46, 40, 30, 24, 41, 38, 28, 22, 38, 35, 27, 21, 34, 33,
-        25, 20, 31, 30, 24, 18, 28, 28, 22, 17,
+        33, 28, 21, 19, 33, 27, 22, 20, 32, 26, 23, 21, 30, 24, 23, 21, 28, 23,
+        23, 21, 26, 22, 23, 21, 24, 22, 21, 20, 22, 21, 19, 19, 22, 22, 19, 18,
+        22, 22, 18, 17, 22, 22, 18, 17, 22, 22, 17, 16, 21, 22, 17, 15, 20, 21,
+        17, 15, 20, 21, 16, 14, 19, 20, 16, 14,
         /* Size 16x4 */
-        65, 64, 63, 63, 63, 60, 59, 56, 53, 49, 46, 41, 38, 34, 31, 28, 60, 60,
-        61, 58, 55, 52, 49, 47, 45, 42, 40, 38, 35, 33, 30, 28, 46, 48, 49, 48,
-        47, 42, 39, 36, 34, 32, 30, 28, 27, 25, 24, 22, 31, 33, 34, 35, 35, 33,
-        31, 29, 27, 25, 24, 22, 21, 20, 18, 17,
+        33, 33, 32, 30, 28, 26, 24, 22, 22, 22, 22, 22, 21, 20, 20, 19, 28, 27,
+        26, 24, 23, 22, 22, 21, 22, 22, 22, 22, 22, 21, 21, 20, 21, 22, 23, 23,
+        23, 23, 21, 19, 19, 18, 18, 17, 17, 17, 16, 16, 19, 20, 21, 21, 21, 21,
+        20, 19, 18, 17, 17, 16, 15, 15, 14, 14,
         /* Size 8x32 */
-        64, 65, 64, 57, 47, 38, 33, 28, 65, 64, 63, 58, 48, 40, 34, 29, 65, 64,
-        63, 58, 48, 40, 34, 29, 65, 64, 63, 59, 49, 41, 35, 31, 65, 63, 62, 59,
-        50, 41, 36, 31, 65, 63, 61, 58, 49, 41, 36, 31, 64, 63, 60, 56, 49, 41,
-        36, 31, 64, 63, 59, 55, 48, 41, 36, 32, 64, 62, 58, 53, 48, 41, 37, 32,
-        64, 62, 58, 53, 48, 41, 36, 32, 60, 60, 55, 48, 43, 38, 34, 30, 60, 60,
-        55, 48, 43, 38, 34, 30, 58, 59, 54, 44, 39, 35, 32, 28, 57, 59, 53, 43,
-        38, 34, 31, 28, 54, 56, 51, 41, 37, 33, 29, 27, 52, 55, 51, 41, 35, 32,
-        29, 26, 50, 53, 49, 40, 34, 30, 28, 25, 47, 50, 48, 38, 33, 29, 26, 24,
-        46, 49, 47, 38, 32, 28, 26, 24, 43, 46, 44, 36, 31, 27, 25, 22, 43, 46,
-        44, 36, 31, 27, 25, 22, 39, 42, 41, 34, 29, 25, 23, 21, 38, 41, 41, 34,
-        29, 25, 23, 21, 36, 39, 39, 33, 28, 24, 22, 20, 35, 38, 38, 32, 27, 24,
-        21, 20, 33, 36, 37, 31, 26, 23, 21, 19, 32, 34, 35, 30, 26, 22, 20, 18,
-        31, 33, 34, 29, 25, 22, 20, 18, 29, 31, 32, 28, 24, 21, 19, 17, 28, 31,
-        32, 28, 24, 21, 19, 17, 26, 28, 29, 26, 23, 20, 18, 16, 26, 28, 29, 26,
-        23, 20, 18, 16,
+        32, 33, 28, 23, 21, 21, 20, 18, 33, 33, 27, 23, 22, 22, 20, 19, 33, 33,
+        27, 23, 22, 22, 20, 19, 33, 32, 26, 23, 22, 22, 21, 19, 34, 32, 26, 23,
+        23, 23, 21, 20, 34, 32, 26, 23, 23, 23, 21, 20, 31, 29, 24, 22, 22, 23,
+        22, 20, 31, 28, 24, 22, 22, 22, 22, 20, 29, 28, 23, 22, 22, 23, 22, 20,
+        28, 26, 22, 22, 22, 23, 22, 20, 28, 26, 22, 22, 22, 23, 22, 20, 25, 24,
+        22, 21, 21, 21, 20, 20, 24, 24, 22, 21, 20, 21, 20, 19, 23, 23, 22, 20,
+        20, 20, 20, 19, 21, 22, 21, 20, 19, 19, 19, 18, 21, 22, 21, 20, 19, 19,
+        19, 18, 21, 22, 22, 20, 19, 19, 18, 17, 21, 22, 22, 20, 19, 18, 18, 17,
+        21, 23, 22, 20, 19, 18, 17, 17, 21, 23, 22, 20, 19, 18, 17, 16, 21, 23,
+        22, 20, 19, 18, 17, 16, 20, 22, 22, 20, 18, 17, 16, 16, 20, 22, 22, 20,
+        18, 17, 16, 15, 20, 22, 22, 20, 18, 17, 16, 15, 20, 21, 22, 19, 18, 17,
+        16, 14, 20, 21, 22, 19, 18, 17, 16, 14, 19, 21, 21, 19, 18, 17, 15, 14,
+        19, 20, 21, 19, 18, 17, 15, 14, 19, 20, 21, 19, 18, 16, 15, 14, 18, 20,
+        20, 19, 17, 16, 15, 13, 18, 20, 20, 19, 17, 16, 15, 13, 17, 19, 20, 18,
+        17, 16, 14, 13,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 64, 64, 64, 64, 60, 60, 58, 57, 54, 52, 50, 47,
-        46, 43, 43, 39, 38, 36, 35, 33, 32, 31, 29, 28, 26, 26, 65, 64, 64, 64,
-        63, 63, 63, 63, 62, 62, 60, 60, 59, 59, 56, 55, 53, 50, 49, 46, 46, 42,
-        41, 39, 38, 36, 34, 33, 31, 31, 28, 28, 64, 63, 63, 63, 62, 61, 60, 59,
-        58, 58, 55, 55, 54, 53, 51, 51, 49, 48, 47, 44, 44, 41, 41, 39, 38, 37,
-        35, 34, 32, 32, 29, 29, 57, 58, 58, 59, 59, 58, 56, 55, 53, 53, 48, 48,
-        44, 43, 41, 41, 40, 38, 38, 36, 36, 34, 34, 33, 32, 31, 30, 29, 28, 28,
-        26, 26, 47, 48, 48, 49, 50, 49, 49, 48, 48, 48, 43, 43, 39, 38, 37, 35,
-        34, 33, 32, 31, 31, 29, 29, 28, 27, 26, 26, 25, 24, 24, 23, 23, 38, 40,
-        40, 41, 41, 41, 41, 41, 41, 41, 38, 38, 35, 34, 33, 32, 30, 29, 28, 27,
-        27, 25, 25, 24, 24, 23, 22, 22, 21, 21, 20, 20, 33, 34, 34, 35, 36, 36,
-        36, 36, 37, 36, 34, 34, 32, 31, 29, 29, 28, 26, 26, 25, 25, 23, 23, 22,
-        21, 21, 20, 20, 19, 19, 18, 18, 28, 29, 29, 31, 31, 31, 31, 32, 32, 32,
-        30, 30, 28, 28, 27, 26, 25, 24, 24, 22, 22, 21, 21, 20, 20, 19, 18, 18,
-        17, 17, 16, 16 },
-      { /* Chroma */
-#if CONFIG_CB4X4
-        /* Size 2x2 */
-        49, 42, 42, 29,
-#endif
-        /* Size 4x4 */
-        65, 48, 44, 38, 48, 42, 41, 38, 44, 41, 33, 30, 38, 38, 30, 26,
-        /* Size 8x8 */
-        65, 63, 53, 43, 44, 41, 38, 36, 63, 58, 49, 44, 46, 43, 41, 38, 53, 49,
-        43, 43, 45, 44, 41, 39, 43, 44, 43, 39, 38, 38, 37, 35, 44, 46, 45, 38,
-        35, 34, 33, 31, 41, 43, 44, 38, 34, 31, 30, 28, 38, 41, 41, 37, 33, 30,
-        28, 26, 36, 38, 39, 35, 31, 28, 26, 25,
-        /* Size 16x16 */
-        64, 66, 67, 61, 56, 49, 43, 42, 42, 41, 41, 39, 38, 36, 34, 32, 66, 65,
-        66, 59, 53, 48, 44, 43, 44, 44, 42, 41, 39, 38, 36, 34, 67, 66, 64, 58,
-        51, 48, 45, 45, 45, 45, 44, 43, 41, 39, 38, 36, 61, 59, 58, 53, 47, 46,
-        44, 44, 45, 45, 44, 43, 41, 40, 38, 36, 56, 53, 51, 47, 43, 43, 43, 44,
-        45, 45, 45, 44, 42, 41, 39, 38, 49, 48, 48, 46, 43, 42, 41, 41, 41, 41,
-        41, 41, 39, 38, 37, 36, 43, 44, 45, 44, 43, 41, 39, 39, 39, 39, 39, 38,
-        37, 37, 35, 34, 42, 43, 45, 44, 44, 41, 39, 38, 38, 37, 37, 37, 36, 35,
-        34, 33, 42, 44, 45, 45, 45, 41, 39, 38, 37, 36, 35, 35, 34, 33, 33, 32,
-        41, 44, 45, 45, 45, 41, 39, 37, 36, 35, 34, 33, 33, 32, 31, 30, 41, 42,
-        44, 44, 45, 41, 39, 37, 35, 34, 33, 32, 32, 31, 30, 29, 39, 41, 43, 43,
-        44, 41, 38, 37, 35, 33, 32, 31, 30, 29, 28, 27, 38, 39, 41, 41, 42, 39,
-        37, 36, 34, 33, 32, 30, 29, 28, 27, 26, 36, 38, 39, 40, 41, 38, 37, 35,
-        33, 32, 31, 29, 28, 27, 26, 25, 34, 36, 38, 38, 39, 37, 35, 34, 33, 31,
-        30, 28, 27, 26, 25, 24, 32, 34, 36, 36, 38, 36, 34, 33, 32, 30, 29, 27,
-        26, 25, 24, 23,
-        /* Size 32x32 */
-        64, 66, 66, 67, 67, 64, 61, 59, 56, 55, 49, 49, 43, 42, 42, 42, 42, 42,
-        41, 41, 41, 39, 39, 38, 38, 37, 36, 35, 34, 34, 32, 32, 66, 65, 65, 66,
-        66, 63, 59, 58, 53, 53, 49, 49, 44, 43, 43, 44, 44, 44, 43, 42, 42, 41,
-        41, 40, 39, 38, 38, 37, 36, 36, 34, 34, 66, 65, 65, 65, 66, 62, 59, 58,
-        53, 53, 48, 48, 44, 43, 43, 44, 44, 44, 44, 42, 42, 41, 41, 40, 39, 39,
-        38, 37, 36, 36, 34, 34, 67, 66, 65, 65, 65, 61, 59, 56, 52, 51, 48, 48,
-        45, 44, 44, 45, 45, 45, 45, 44, 44, 43, 42, 41, 41, 40, 39, 38, 37, 37,
-        35, 35, 67, 66, 66, 65, 64, 61, 58, 56, 51, 51, 48, 48, 45, 44, 45, 45,
-        45, 46, 45, 44, 44, 43, 43, 42, 41, 40, 39, 39, 38, 38, 36, 36, 64, 63,
-        62, 61, 61, 58, 55, 53, 49, 49, 47, 47, 45, 44, 44, 45, 45, 46, 45, 44,
-        44, 43, 43, 42, 41, 41, 40, 39, 38, 38, 36, 36, 61, 59, 59, 59, 58, 55,
-        53, 51, 47, 47, 46, 46, 44, 43, 44, 44, 45, 45, 45, 44, 44, 43, 43, 42,
-        41, 41, 40, 39, 38, 38, 36, 36, 59, 58, 58, 56, 56, 53, 51, 49, 46, 46,
-        45, 45, 44, 43, 44, 44, 45, 45, 45, 44, 44, 44, 43, 42, 42, 41, 40, 40,
-        39, 38, 37, 37, 56, 53, 53, 52, 51, 49, 47, 46, 43, 43, 43, 43, 43, 43,
-        44, 44, 45, 45, 45, 45, 45, 44, 44, 43, 42, 42, 41, 41, 39, 39, 38, 38,
-        55, 53, 53, 51, 51, 49, 47, 46, 43, 43, 43, 43, 43, 43, 43, 44, 44, 45,
-        45, 44, 44, 44, 44, 43, 42, 41, 41, 40, 39, 39, 37, 37, 49, 49, 48, 48,
-        48, 47, 46, 45, 43, 43, 42, 42, 41, 41, 41, 41, 41, 42, 41, 41, 41, 41,
-        41, 40, 39, 39, 38, 38, 37, 37, 36, 36, 49, 49, 48, 48, 48, 47, 46, 45,
-        43, 43, 42, 42, 41, 41, 41, 41, 41, 42, 41, 41, 41, 41, 41, 40, 39, 39,
-        38, 38, 37, 37, 36, 36, 43, 44, 44, 45, 45, 45, 44, 44, 43, 43, 41, 41,
-        39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 38, 38, 37, 37, 37, 36, 35, 35,
-        34, 34, 42, 43, 43, 44, 44, 44, 43, 43, 43, 43, 41, 41, 39, 39, 39, 39,
-        38, 38, 38, 38, 38, 38, 38, 37, 37, 37, 36, 36, 35, 35, 34, 34, 42, 43,
-        43, 44, 45, 44, 44, 44, 44, 43, 41, 41, 39, 39, 38, 38, 38, 37, 37, 37,
-        37, 37, 37, 36, 36, 35, 35, 35, 34, 34, 33, 33, 42, 44, 44, 45, 45, 45,
-        44, 44, 44, 44, 41, 41, 39, 39, 38, 38, 37, 37, 37, 36, 36, 36, 36, 35,
-        35, 34, 34, 34, 33, 33, 32, 32, 42, 44, 44, 45, 45, 45, 45, 45, 45, 44,
-        41, 41, 39, 38, 38, 37, 37, 36, 36, 35, 35, 35, 35, 34, 34, 34, 33, 33,
-        33, 32, 32, 32, 42, 44, 44, 45, 46, 46, 45, 45, 45, 45, 42, 42, 39, 38,
-        37, 37, 36, 35, 35, 34, 34, 34, 33, 33, 33, 33, 32, 32, 31, 31, 30, 30,
-        41, 43, 44, 45, 45, 45, 45, 45, 45, 45, 41, 41, 39, 38, 37, 37, 36, 35,
-        35, 34, 34, 33, 33, 33, 33, 32, 32, 32, 31, 31, 30, 30, 41, 42, 42, 44,
-        44, 44, 44, 44, 45, 44, 41, 41, 39, 38, 37, 36, 35, 34, 34, 33, 33, 32,
-        32, 32, 32, 31, 31, 30, 30, 30, 29, 29, 41, 42, 42, 44, 44, 44, 44, 44,
-        45, 44, 41, 41, 39, 38, 37, 36, 35, 34, 34, 33, 33, 32, 32, 32, 32, 31,
-        31, 30, 30, 30, 29, 29, 39, 41, 41, 43, 43, 43, 43, 44, 44, 44, 41, 41,
-        38, 38, 37, 36, 35, 34, 33, 32, 32, 31, 31, 30, 30, 30, 29, 29, 28, 28,
-        27, 27, 39, 41, 41, 42, 43, 43, 43, 43, 44, 44, 41, 41, 38, 38, 37, 36,
-        35, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 29, 28, 28, 27, 27, 38, 40,
-        40, 41, 42, 42, 42, 42, 43, 43, 40, 40, 38, 37, 36, 35, 34, 33, 33, 32,
-        32, 30, 30, 29, 29, 29, 28, 28, 27, 27, 27, 27, 38, 39, 39, 41, 41, 41,
-        41, 42, 42, 42, 39, 39, 37, 37, 36, 35, 34, 33, 33, 32, 32, 30, 30, 29,
-        29, 28, 28, 28, 27, 27, 26, 26, 37, 38, 39, 40, 40, 41, 41, 41, 42, 41,
-        39, 39, 37, 37, 35, 34, 34, 33, 32, 31, 31, 30, 29, 29, 28, 28, 27, 27,
-        27, 26, 26, 26, 36, 38, 38, 39, 39, 40, 40, 40, 41, 41, 38, 38, 37, 36,
-        35, 34, 33, 32, 32, 31, 31, 29, 29, 28, 28, 27, 27, 26, 26, 26, 25, 25,
-        35, 37, 37, 38, 39, 39, 39, 40, 41, 40, 38, 38, 36, 36, 35, 34, 33, 32,
-        32, 30, 30, 29, 29, 28, 28, 27, 26, 26, 26, 26, 25, 25, 34, 36, 36, 37,
-        38, 38, 38, 39, 39, 39, 37, 37, 35, 35, 34, 33, 33, 31, 31, 30, 30, 28,
-        28, 27, 27, 27, 26, 26, 25, 25, 24, 24, 34, 36, 36, 37, 38, 38, 38, 38,
-        39, 39, 37, 37, 35, 35, 34, 33, 32, 31, 31, 30, 30, 28, 28, 27, 27, 26,
-        26, 26, 25, 25, 24, 24, 32, 34, 34, 35, 36, 36, 36, 37, 38, 37, 36, 36,
-        34, 34, 33, 32, 32, 30, 30, 29, 29, 27, 27, 27, 26, 26, 25, 25, 24, 24,
-        23, 23, 32, 34, 34, 35, 36, 36, 36, 37, 38, 37, 36, 36, 34, 34, 33, 32,
-        32, 30, 30, 29, 29, 27, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23,
-        /* Size 4x8 */
-        65, 48, 43, 38, 61, 47, 45, 40, 51, 43, 45, 41, 44, 41, 38, 36, 45, 41,
-        35, 32, 43, 41, 33, 29, 40, 39, 32, 27, 37, 37, 31, 26,
-        /* Size 8x4 */
-        65, 61, 51, 44, 45, 43, 40, 37, 48, 47, 43, 41, 41, 41, 39, 37, 43, 45,
-        45, 38, 35, 33, 32, 31, 38, 40, 41, 36, 32, 29, 27, 26,
-        /* Size 8x16 */
-        64, 66, 55, 43, 42, 39, 37, 34, 65, 65, 53, 44, 44, 41, 38, 36, 67, 64,
-        51, 45, 45, 43, 40, 37, 61, 57, 48, 44, 45, 43, 41, 38, 55, 51, 44, 43,
-        45, 44, 41, 39, 49, 48, 43, 41, 41, 41, 39, 37, 43, 45, 43, 39, 39, 38,
-        37, 35, 42, 45, 43, 39, 37, 36, 35, 34, 42, 45, 44, 39, 36, 35, 34, 32,
-        42, 45, 45, 38, 35, 33, 32, 31, 41, 44, 44, 38, 34, 32, 31, 29, 39, 43,
-        43, 38, 34, 31, 29, 28, 38, 41, 42, 37, 33, 30, 28, 27, 36, 39, 41, 36,
-        32, 29, 27, 26, 34, 38, 39, 35, 31, 28, 26, 25, 32, 36, 37, 34, 30, 27,
-        25, 24,
-        /* Size 16x8 */
-        64, 65, 67, 61, 55, 49, 43, 42, 42, 42, 41, 39, 38, 36, 34, 32, 66, 65,
-        64, 57, 51, 48, 45, 45, 45, 45, 44, 43, 41, 39, 38, 36, 55, 53, 51, 48,
-        44, 43, 43, 43, 44, 45, 44, 43, 42, 41, 39, 37, 43, 44, 45, 44, 43, 41,
-        39, 39, 39, 38, 38, 38, 37, 36, 35, 34, 42, 44, 45, 45, 45, 41, 39, 37,
-        36, 35, 34, 34, 33, 32, 31, 30, 39, 41, 43, 43, 44, 41, 38, 36, 35, 33,
-        32, 31, 30, 29, 28, 27, 37, 38, 40, 41, 41, 39, 37, 35, 34, 32, 31, 29,
-        28, 27, 26, 25, 34, 36, 37, 38, 39, 37, 35, 34, 32, 31, 29, 28, 27, 26,
-        25, 24,
-        /* Size 16x32 */
-        64, 66, 66, 59, 55, 49, 43, 42, 42, 41, 39, 39, 37, 36, 34, 32, 65, 65,
-        65, 57, 53, 48, 44, 43, 43, 43, 41, 41, 38, 38, 35, 34, 65, 65, 65, 57,
-        53, 48, 44, 44, 44, 43, 41, 41, 38, 38, 36, 34, 67, 64, 64, 55, 52, 48,
-        44, 45, 45, 45, 42, 42, 39, 39, 37, 35, 67, 64, 64, 55, 51, 48, 45, 45,
-        45, 45, 43, 43, 40, 39, 37, 36, 64, 61, 60, 53, 49, 47, 44, 45, 45, 45,
-        43, 43, 40, 40, 38, 36, 61, 58, 57, 51, 48, 46, 44, 44, 45, 45, 43, 43,
-        41, 40, 38, 37, 59, 55, 55, 49, 46, 45, 44, 44, 45, 45, 43, 43, 41, 40,
-        38, 37, 55, 51, 51, 46, 44, 43, 43, 44, 45, 45, 44, 44, 41, 41, 39, 38,
-        55, 51, 51, 46, 44, 43, 43, 43, 45, 45, 43, 43, 41, 41, 39, 37, 49, 48,
-        48, 45, 43, 42, 41, 41, 41, 41, 41, 41, 39, 38, 37, 36, 49, 48, 48, 45,
-        43, 42, 41, 41, 41, 41, 41, 41, 39, 38, 37, 36, 43, 45, 45, 43, 43, 41,
-        39, 39, 39, 39, 38, 38, 37, 37, 35, 34, 42, 44, 44, 43, 43, 41, 39, 39,
-        38, 38, 38, 38, 36, 36, 35, 34, 42, 44, 45, 44, 43, 41, 39, 38, 37, 37,
-        36, 36, 35, 35, 34, 33, 42, 45, 45, 44, 44, 41, 39, 38, 37, 37, 36, 36,
-        34, 34, 33, 32, 42, 45, 45, 45, 44, 41, 39, 38, 36, 36, 35, 35, 34, 33,
-        32, 32, 42, 45, 45, 45, 45, 41, 38, 37, 35, 35, 33, 33, 32, 32, 31, 30,
-        42, 45, 45, 45, 45, 41, 38, 37, 35, 35, 33, 33, 32, 32, 31, 30, 41, 44,
-        44, 44, 44, 41, 38, 37, 34, 34, 32, 32, 31, 31, 29, 29, 41, 44, 44, 44,
-        44, 41, 38, 37, 34, 34, 32, 32, 31, 31, 29, 29, 39, 43, 43, 43, 44, 41,
-        38, 37, 34, 33, 31, 31, 29, 29, 28, 27, 39, 42, 43, 43, 43, 41, 38, 37,
-        34, 33, 31, 31, 29, 29, 28, 27, 38, 41, 41, 42, 42, 40, 37, 36, 33, 33,
-        30, 30, 29, 28, 27, 27, 38, 41, 41, 42, 42, 39, 37, 36, 33, 33, 30, 30,
-        28, 28, 27, 26, 37, 40, 40, 41, 41, 39, 37, 35, 33, 32, 29, 29, 28, 27,
-        26, 26, 36, 39, 39, 40, 41, 38, 36, 35, 32, 32, 29, 29, 27, 27, 26, 25,
-        35, 38, 39, 40, 40, 38, 36, 35, 32, 32, 29, 29, 27, 26, 25, 25, 34, 37,
-        38, 39, 39, 37, 35, 34, 31, 31, 28, 28, 26, 26, 25, 24, 34, 37, 37, 38,
-        39, 37, 35, 34, 31, 31, 28, 28, 26, 26, 25, 24, 32, 35, 36, 37, 37, 35,
-        34, 33, 30, 30, 27, 27, 25, 25, 24, 23, 32, 35, 36, 37, 37, 35, 34, 33,
-        30, 30, 27, 27, 25, 25, 24, 23,
-        /* Size 32x16 */
-        64, 65, 65, 67, 67, 64, 61, 59, 55, 55, 49, 49, 43, 42, 42, 42, 42, 42,
-        42, 41, 41, 39, 39, 38, 38, 37, 36, 35, 34, 34, 32, 32, 66, 65, 65, 64,
-        64, 61, 58, 55, 51, 51, 48, 48, 45, 44, 44, 45, 45, 45, 45, 44, 44, 43,
-        42, 41, 41, 40, 39, 38, 37, 37, 35, 35, 66, 65, 65, 64, 64, 60, 57, 55,
-        51, 51, 48, 48, 45, 44, 45, 45, 45, 45, 45, 44, 44, 43, 43, 41, 41, 40,
-        39, 39, 38, 37, 36, 36, 59, 57, 57, 55, 55, 53, 51, 49, 46, 46, 45, 45,
-        43, 43, 44, 44, 45, 45, 45, 44, 44, 43, 43, 42, 42, 41, 40, 40, 39, 38,
-        37, 37, 55, 53, 53, 52, 51, 49, 48, 46, 44, 44, 43, 43, 43, 43, 43, 44,
-        44, 45, 45, 44, 44, 44, 43, 42, 42, 41, 41, 40, 39, 39, 37, 37, 49, 48,
-        48, 48, 48, 47, 46, 45, 43, 43, 42, 42, 41, 41, 41, 41, 41, 41, 41, 41,
-        41, 41, 41, 40, 39, 39, 38, 38, 37, 37, 35, 35, 43, 44, 44, 44, 45, 44,
-        44, 44, 43, 43, 41, 41, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 37,
-        37, 37, 36, 36, 35, 35, 34, 34, 42, 43, 44, 45, 45, 45, 44, 44, 44, 43,
-        41, 41, 39, 39, 38, 38, 38, 37, 37, 37, 37, 37, 37, 36, 36, 35, 35, 35,
-        34, 34, 33, 33, 42, 43, 44, 45, 45, 45, 45, 45, 45, 45, 41, 41, 39, 38,
-        37, 37, 36, 35, 35, 34, 34, 34, 34, 33, 33, 33, 32, 32, 31, 31, 30, 30,
-        41, 43, 43, 45, 45, 45, 45, 45, 45, 45, 41, 41, 39, 38, 37, 37, 36, 35,
-        35, 34, 34, 33, 33, 33, 33, 32, 32, 32, 31, 31, 30, 30, 39, 41, 41, 42,
-        43, 43, 43, 43, 44, 43, 41, 41, 38, 38, 36, 36, 35, 33, 33, 32, 32, 31,
-        31, 30, 30, 29, 29, 29, 28, 28, 27, 27, 39, 41, 41, 42, 43, 43, 43, 43,
-        44, 43, 41, 41, 38, 38, 36, 36, 35, 33, 33, 32, 32, 31, 31, 30, 30, 29,
-        29, 29, 28, 28, 27, 27, 37, 38, 38, 39, 40, 40, 41, 41, 41, 41, 39, 39,
-        37, 36, 35, 34, 34, 32, 32, 31, 31, 29, 29, 29, 28, 28, 27, 27, 26, 26,
-        25, 25, 36, 38, 38, 39, 39, 40, 40, 40, 41, 41, 38, 38, 37, 36, 35, 34,
-        33, 32, 32, 31, 31, 29, 29, 28, 28, 27, 27, 26, 26, 26, 25, 25, 34, 35,
-        36, 37, 37, 38, 38, 38, 39, 39, 37, 37, 35, 35, 34, 33, 32, 31, 31, 29,
-        29, 28, 28, 27, 27, 26, 26, 25, 25, 25, 24, 24, 32, 34, 34, 35, 36, 36,
-        37, 37, 38, 37, 36, 36, 34, 34, 33, 32, 32, 30, 30, 29, 29, 27, 27, 27,
-        26, 26, 25, 25, 24, 24, 23, 23,
-        /* Size 4x16 */
-        66, 49, 41, 36, 65, 48, 43, 38, 64, 48, 45, 39, 58, 46, 45, 40, 51, 43,
-        45, 41, 48, 42, 41, 38, 45, 41, 39, 37, 44, 41, 37, 35, 45, 41, 36, 33,
-        45, 41, 35, 32, 44, 41, 34, 31, 42, 41, 33, 29, 41, 39, 33, 28, 39, 38,
-        32, 27, 37, 37, 31, 26, 35, 35, 30, 25,
-        /* Size 16x4 */
-        66, 65, 64, 58, 51, 48, 45, 44, 45, 45, 44, 42, 41, 39, 37, 35, 49, 48,
-        48, 46, 43, 42, 41, 41, 41, 41, 41, 41, 39, 38, 37, 35, 41, 43, 45, 45,
-        45, 41, 39, 37, 36, 35, 34, 33, 33, 32, 31, 30, 36, 38, 39, 40, 41, 38,
-        37, 35, 33, 32, 31, 29, 28, 27, 26, 25,
-        /* Size 8x32 */
-        64, 66, 55, 43, 42, 39, 37, 34, 65, 65, 53, 44, 43, 41, 38, 35, 65, 65,
-        53, 44, 44, 41, 38, 36, 67, 64, 52, 44, 45, 42, 39, 37, 67, 64, 51, 45,
-        45, 43, 40, 37, 64, 60, 49, 44, 45, 43, 40, 38, 61, 57, 48, 44, 45, 43,
-        41, 38, 59, 55, 46, 44, 45, 43, 41, 38, 55, 51, 44, 43, 45, 44, 41, 39,
-        55, 51, 44, 43, 45, 43, 41, 39, 49, 48, 43, 41, 41, 41, 39, 37, 49, 48,
-        43, 41, 41, 41, 39, 37, 43, 45, 43, 39, 39, 38, 37, 35, 42, 44, 43, 39,
-        38, 38, 36, 35, 42, 45, 43, 39, 37, 36, 35, 34, 42, 45, 44, 39, 37, 36,
-        34, 33, 42, 45, 44, 39, 36, 35, 34, 32, 42, 45, 45, 38, 35, 33, 32, 31,
-        42, 45, 45, 38, 35, 33, 32, 31, 41, 44, 44, 38, 34, 32, 31, 29, 41, 44,
-        44, 38, 34, 32, 31, 29, 39, 43, 44, 38, 34, 31, 29, 28, 39, 43, 43, 38,
-        34, 31, 29, 28, 38, 41, 42, 37, 33, 30, 29, 27, 38, 41, 42, 37, 33, 30,
-        28, 27, 37, 40, 41, 37, 33, 29, 28, 26, 36, 39, 41, 36, 32, 29, 27, 26,
-        35, 39, 40, 36, 32, 29, 27, 25, 34, 38, 39, 35, 31, 28, 26, 25, 34, 37,
-        39, 35, 31, 28, 26, 25, 32, 36, 37, 34, 30, 27, 25, 24, 32, 36, 37, 34,
-        30, 27, 25, 24,
-        /* Size 32x8 */
-        64, 65, 65, 67, 67, 64, 61, 59, 55, 55, 49, 49, 43, 42, 42, 42, 42, 42,
-        42, 41, 41, 39, 39, 38, 38, 37, 36, 35, 34, 34, 32, 32, 66, 65, 65, 64,
-        64, 60, 57, 55, 51, 51, 48, 48, 45, 44, 45, 45, 45, 45, 45, 44, 44, 43,
-        43, 41, 41, 40, 39, 39, 38, 37, 36, 36, 55, 53, 53, 52, 51, 49, 48, 46,
-        44, 44, 43, 43, 43, 43, 43, 44, 44, 45, 45, 44, 44, 44, 43, 42, 42, 41,
-        41, 40, 39, 39, 37, 37, 43, 44, 44, 44, 45, 44, 44, 44, 43, 43, 41, 41,
-        39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 37, 37, 37, 36, 36, 35, 35,
-        34, 34, 42, 43, 44, 45, 45, 45, 45, 45, 45, 45, 41, 41, 39, 38, 37, 37,
-        36, 35, 35, 34, 34, 34, 34, 33, 33, 33, 32, 32, 31, 31, 30, 30, 39, 41,
-        41, 42, 43, 43, 43, 43, 44, 43, 41, 41, 38, 38, 36, 36, 35, 33, 33, 32,
-        32, 31, 31, 30, 30, 29, 29, 29, 28, 28, 27, 27, 37, 38, 38, 39, 40, 40,
-        41, 41, 41, 41, 39, 39, 37, 36, 35, 34, 34, 32, 32, 31, 31, 29, 29, 29,
-        28, 28, 27, 27, 26, 26, 25, 25, 34, 35, 36, 37, 37, 38, 38, 38, 39, 39,
-        37, 37, 35, 35, 34, 33, 32, 31, 31, 29, 29, 28, 28, 27, 27, 26, 26, 25,
-        25, 25, 24, 24 },
+        32, 33, 33, 33, 34, 34, 31, 31, 29, 28, 28, 25, 24, 23, 21, 21, 21, 21,
+        21, 21, 21, 20, 20, 20, 20, 20, 19, 19, 19, 18, 18, 17, 33, 33, 33, 32,
+        32, 32, 29, 28, 28, 26, 26, 24, 24, 23, 22, 22, 22, 22, 23, 23, 23, 22,
+        22, 22, 21, 21, 21, 20, 20, 20, 20, 19, 28, 27, 27, 26, 26, 26, 24, 24,
+        23, 22, 22, 22, 22, 22, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        21, 21, 21, 20, 20, 20, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 21,
+        21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19,
+        19, 18, 21, 22, 22, 22, 23, 23, 22, 22, 22, 22, 22, 21, 20, 20, 19, 19,
+        19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 21, 22,
+        22, 22, 23, 23, 23, 22, 23, 23, 23, 21, 21, 20, 19, 19, 19, 18, 18, 18,
+        18, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 20, 20, 20, 21, 21, 21,
+        22, 22, 22, 22, 22, 20, 20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16,
+        16, 16, 15, 15, 15, 15, 15, 14, 18, 19, 19, 19, 20, 20, 20, 20, 20, 20,
+        20, 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 14, 14, 14, 14,
+        14, 13, 13, 13 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        61, 44, 44, 27,
+        31, 24, 24, 16,
 #endif
         /* Size 4x4 */
-        64, 61, 49, 37, 61, 53, 44, 36, 49, 44, 32, 27, 37, 36, 27, 22,
+        32, 32, 27, 20, 32, 29, 26, 21, 27, 26, 19, 16, 20, 21, 16, 13,
         /* Size 8x8 */
-        65, 64, 64, 59, 53, 45, 39, 33, 64, 63, 63, 60, 55, 47, 41, 34, 64, 63,
-        58, 55, 51, 46, 41, 35, 59, 60, 55, 48, 44, 39, 36, 32, 53, 55, 51, 44,
-        38, 34, 32, 28, 45, 47, 46, 39, 34, 29, 27, 24, 39, 41, 41, 36, 32, 27,
-        25, 22, 33, 34, 35, 32, 28, 24, 22, 20,
+        33, 32, 32, 30, 29, 25, 22, 19, 32, 32, 32, 31, 30, 26, 23, 20, 32, 32,
+        30, 29, 28, 25, 23, 20, 30, 31, 29, 26, 24, 22, 20, 19, 29, 30, 28, 24,
+        21, 19, 18, 17, 25, 26, 25, 22, 19, 17, 16, 15, 22, 23, 23, 20, 18, 16,
+        14, 13, 19, 20, 20, 19, 17, 15, 13, 12,
         /* Size 16x16 */
-        64, 65, 65, 65, 64, 64, 60, 57, 53, 50, 47, 42, 38, 35, 33, 31, 65, 64,
-        64, 64, 64, 63, 60, 59, 54, 51, 48, 44, 40, 37, 35, 33, 65, 64, 63, 63,
-        63, 63, 61, 59, 55, 53, 50, 46, 41, 39, 37, 34, 65, 64, 63, 62, 61, 61,
-        59, 57, 54, 51, 49, 45, 41, 39, 37, 34, 64, 64, 63, 61, 60, 59, 57, 55,
-        53, 51, 48, 45, 41, 39, 37, 35, 64, 63, 63, 61, 59, 58, 55, 53, 51, 49,
-        48, 45, 41, 39, 37, 35, 60, 60, 61, 59, 57, 55, 52, 48, 46, 45, 43, 40,
-        38, 36, 34, 33, 57, 59, 59, 57, 55, 53, 48, 42, 41, 39, 38, 36, 34, 33,
-        31, 30, 53, 54, 55, 54, 53, 51, 46, 41, 39, 38, 36, 34, 32, 31, 29, 28,
-        50, 51, 53, 51, 51, 49, 45, 39, 38, 36, 34, 32, 30, 29, 28, 27, 47, 48,
-        50, 49, 48, 48, 43, 38, 36, 34, 32, 31, 29, 27, 27, 26, 42, 44, 46, 45,
-        45, 45, 40, 36, 34, 32, 31, 29, 27, 26, 25, 24, 38, 40, 41, 41, 41, 41,
-        38, 34, 32, 30, 29, 27, 25, 24, 23, 22, 35, 37, 39, 39, 39, 39, 36, 33,
-        31, 29, 27, 26, 24, 23, 22, 21, 33, 35, 37, 37, 37, 37, 34, 31, 29, 28,
-        27, 25, 23, 22, 21, 20, 31, 33, 34, 34, 35, 35, 33, 30, 28, 27, 26, 24,
-        22, 21, 20, 20,
+        32, 33, 33, 33, 33, 32, 32, 30, 28, 27, 26, 23, 22, 21, 19, 17, 33, 32,
+        32, 32, 32, 32, 31, 30, 29, 28, 27, 24, 23, 22, 20, 18, 33, 32, 32, 32,
+        32, 32, 31, 31, 30, 28, 28, 25, 23, 22, 20, 19, 33, 32, 32, 32, 32, 31,
+        31, 30, 29, 28, 27, 25, 23, 23, 21, 19, 33, 32, 32, 32, 31, 30, 30, 29,
+        28, 27, 26, 24, 23, 22, 20, 19, 32, 32, 32, 31, 30, 29, 28, 28, 27, 26,
+        26, 24, 23, 22, 21, 19, 32, 31, 31, 31, 30, 28, 28, 27, 26, 25, 24, 23,
+        22, 21, 20, 19, 30, 30, 31, 30, 29, 28, 27, 26, 24, 23, 23, 22, 20, 20,
+        19, 18, 28, 29, 30, 29, 28, 27, 26, 24, 21, 20, 20, 19, 18, 18, 17, 16,
+        27, 28, 28, 28, 27, 26, 25, 23, 20, 20, 20, 18, 18, 17, 16, 15, 26, 27,
+        28, 27, 26, 26, 24, 23, 20, 20, 19, 18, 17, 17, 16, 15, 23, 24, 25, 25,
+        24, 24, 23, 22, 19, 18, 18, 16, 16, 15, 14, 14, 22, 23, 23, 23, 23, 23,
+        22, 20, 18, 18, 17, 16, 15, 14, 14, 13, 21, 22, 22, 23, 22, 22, 21, 20,
+        18, 17, 17, 15, 14, 14, 13, 13, 19, 20, 20, 21, 20, 21, 20, 19, 17, 16,
+        16, 14, 14, 13, 12, 12, 17, 18, 19, 19, 19, 19, 19, 18, 16, 15, 15, 14,
+        13, 13, 12, 11,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 61, 60, 59, 57, 57, 53, 52,
-        50, 47, 47, 43, 42, 41, 38, 38, 35, 35, 33, 31, 31, 29, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 64, 61, 60, 59, 58, 58, 54, 53, 51, 48, 48, 45,
-        44, 42, 39, 39, 37, 36, 35, 33, 33, 30, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 63, 63, 61, 60, 59, 59, 59, 54, 53, 51, 48, 48, 45, 44, 42, 40, 40,
-        37, 36, 35, 33, 33, 31, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 61,
-        60, 60, 59, 59, 55, 54, 52, 49, 49, 46, 45, 43, 41, 41, 38, 37, 36, 34,
-        34, 31, 65, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 61, 61, 60, 59, 59,
-        55, 55, 53, 50, 50, 47, 46, 44, 41, 41, 39, 38, 37, 34, 34, 32, 65, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 61, 61, 60, 59, 59, 55, 55, 53, 50,
-        50, 47, 46, 44, 41, 41, 39, 38, 37, 34, 34, 32, 65, 64, 64, 63, 63, 63,
-        62, 62, 61, 61, 61, 59, 59, 58, 57, 57, 54, 53, 51, 49, 49, 46, 45, 44,
-        41, 41, 39, 38, 37, 34, 34, 32, 65, 64, 64, 63, 63, 63, 62, 61, 61, 60,
-        60, 59, 58, 57, 56, 56, 53, 53, 51, 49, 49, 46, 45, 44, 41, 41, 39, 38,
-        37, 35, 35, 32, 64, 64, 64, 63, 63, 63, 61, 61, 60, 59, 59, 58, 57, 56,
-        55, 55, 53, 52, 51, 48, 48, 46, 45, 44, 41, 41, 39, 38, 37, 35, 35, 33,
-        64, 64, 63, 63, 63, 63, 61, 60, 59, 58, 58, 56, 55, 55, 53, 53, 51, 51,
-        49, 48, 48, 46, 45, 44, 41, 41, 39, 38, 37, 35, 35, 33, 64, 64, 63, 63,
-        63, 63, 61, 60, 59, 58, 58, 56, 55, 55, 53, 53, 51, 51, 49, 48, 48, 46,
-        45, 44, 41, 41, 39, 38, 37, 35, 35, 33, 61, 61, 61, 61, 61, 61, 59, 59,
-        58, 56, 56, 53, 53, 51, 49, 49, 47, 47, 46, 44, 44, 42, 41, 40, 38, 38,
-        36, 36, 35, 33, 33, 31, 60, 60, 60, 60, 61, 61, 59, 58, 57, 55, 55, 53,
-        52, 50, 48, 48, 46, 46, 45, 43, 43, 41, 40, 39, 38, 38, 36, 35, 34, 33,
-        33, 31, 59, 59, 59, 60, 60, 60, 58, 57, 56, 55, 55, 51, 50, 48, 46, 46,
-        44, 44, 42, 41, 41, 39, 39, 38, 36, 36, 34, 34, 33, 32, 32, 30, 57, 58,
-        59, 59, 59, 59, 57, 56, 55, 53, 53, 49, 48, 46, 42, 42, 41, 41, 39, 38,
-        38, 37, 36, 35, 34, 34, 33, 32, 31, 30, 30, 28, 57, 58, 59, 59, 59, 59,
-        57, 56, 55, 53, 53, 49, 48, 46, 42, 42, 41, 41, 39, 38, 38, 37, 36, 35,
-        34, 34, 33, 32, 31, 30, 30, 28, 53, 54, 54, 55, 55, 55, 54, 53, 53, 51,
-        51, 47, 46, 44, 41, 41, 39, 39, 38, 36, 36, 34, 34, 33, 32, 32, 31, 30,
-        29, 28, 28, 27, 52, 53, 53, 54, 55, 55, 53, 53, 52, 51, 51, 47, 46, 44,
-        41, 41, 39, 38, 37, 35, 35, 34, 34, 33, 32, 32, 30, 30, 29, 28, 28, 27,
-        50, 51, 51, 52, 53, 53, 51, 51, 51, 49, 49, 46, 45, 42, 39, 39, 38, 37,
-        36, 34, 34, 33, 32, 32, 30, 30, 29, 29, 28, 27, 27, 26, 47, 48, 48, 49,
-        50, 50, 49, 49, 48, 48, 48, 44, 43, 41, 38, 38, 36, 35, 34, 32, 32, 31,
-        31, 30, 29, 29, 27, 27, 27, 26, 26, 25, 47, 48, 48, 49, 50, 50, 49, 49,
-        48, 48, 48, 44, 43, 41, 38, 38, 36, 35, 34, 32, 32, 31, 31, 30, 29, 29,
-        27, 27, 27, 26, 26, 25, 43, 45, 45, 46, 47, 47, 46, 46, 46, 46, 46, 42,
-        41, 39, 37, 37, 34, 34, 33, 31, 31, 29, 29, 28, 27, 27, 26, 26, 25, 24,
-        24, 23, 42, 44, 44, 45, 46, 46, 45, 45, 45, 45, 45, 41, 40, 39, 36, 36,
-        34, 34, 32, 31, 31, 29, 29, 28, 27, 27, 26, 25, 25, 24, 24, 23, 41, 42,
-        42, 43, 44, 44, 44, 44, 44, 44, 44, 40, 39, 38, 35, 35, 33, 33, 32, 30,
-        30, 28, 28, 27, 26, 26, 25, 25, 24, 23, 23, 22, 38, 39, 40, 41, 41, 41,
-        41, 41, 41, 41, 41, 38, 38, 36, 34, 34, 32, 32, 30, 29, 29, 27, 27, 26,
-        25, 25, 24, 24, 23, 22, 22, 21, 38, 39, 40, 41, 41, 41, 41, 41, 41, 41,
-        41, 38, 38, 36, 34, 34, 32, 32, 30, 29, 29, 27, 27, 26, 25, 25, 24, 24,
-        23, 22, 22, 21, 35, 37, 37, 38, 39, 39, 39, 39, 39, 39, 39, 36, 36, 34,
-        33, 33, 31, 30, 29, 27, 27, 26, 26, 25, 24, 24, 23, 23, 22, 21, 21, 20,
-        35, 36, 36, 37, 38, 38, 38, 38, 38, 38, 38, 36, 35, 34, 32, 32, 30, 30,
-        29, 27, 27, 26, 25, 25, 24, 24, 23, 22, 22, 21, 21, 20, 33, 35, 35, 36,
-        37, 37, 37, 37, 37, 37, 37, 35, 34, 33, 31, 31, 29, 29, 28, 27, 27, 25,
-        25, 24, 23, 23, 22, 22, 21, 20, 20, 19, 31, 33, 33, 34, 34, 34, 34, 35,
-        35, 35, 35, 33, 33, 32, 30, 30, 28, 28, 27, 26, 26, 24, 24, 23, 22, 22,
-        21, 21, 20, 20, 20, 19, 31, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 33,
-        33, 32, 30, 30, 28, 28, 27, 26, 26, 24, 24, 23, 22, 22, 21, 21, 20, 20,
-        20, 19, 29, 30, 31, 31, 32, 32, 32, 32, 33, 33, 33, 31, 31, 30, 28, 28,
-        27, 27, 26, 25, 25, 23, 23, 22, 21, 21, 20, 20, 19, 19, 19, 18,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 30, 30, 29, 28, 28,
+        27, 26, 26, 24, 23, 23, 22, 21, 21, 19, 19, 19, 17, 17, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 30, 29, 29, 28, 26, 26, 25,
+        24, 24, 22, 22, 21, 20, 20, 19, 18, 18, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 30, 30, 30, 29, 29, 28, 27, 27, 25, 24, 24, 23, 22,
+        22, 20, 20, 19, 18, 18, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 30, 30, 30, 29, 29, 28, 27, 27, 25, 24, 24, 23, 22, 22, 20, 20, 20,
+        18, 18, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30,
+        30, 30, 28, 28, 28, 26, 25, 25, 23, 23, 22, 21, 20, 20, 19, 19, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 28, 28,
+        28, 26, 25, 25, 23, 23, 23, 21, 21, 20, 19, 19, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 29, 29, 28, 27, 27, 26, 25, 25,
+        23, 23, 23, 21, 21, 20, 19, 19, 33, 32, 32, 32, 32, 32, 32, 31, 31, 31,
+        30, 30, 30, 29, 29, 29, 28, 28, 27, 26, 26, 25, 24, 24, 23, 23, 22, 21,
+        20, 20, 19, 19, 33, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 29,
+        29, 28, 28, 28, 27, 26, 26, 25, 24, 24, 23, 23, 22, 21, 20, 20, 19, 19,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 29, 29, 29, 28, 28, 28,
+        27, 26, 26, 25, 24, 24, 23, 23, 22, 21, 21, 20, 19, 19, 32, 32, 32, 32,
+        32, 32, 31, 30, 30, 30, 29, 29, 28, 28, 28, 28, 27, 27, 26, 26, 26, 24,
+        24, 24, 23, 22, 22, 21, 21, 20, 19, 19, 32, 32, 32, 32, 32, 32, 31, 30,
+        30, 30, 29, 29, 28, 28, 28, 28, 27, 27, 26, 26, 26, 24, 24, 24, 23, 22,
+        22, 21, 21, 20, 19, 19, 32, 31, 31, 31, 31, 31, 31, 30, 30, 29, 28, 28,
+        28, 27, 27, 26, 26, 26, 25, 24, 24, 23, 23, 23, 22, 22, 21, 20, 20, 20,
+        19, 19, 30, 30, 30, 30, 31, 31, 30, 29, 29, 29, 28, 28, 27, 26, 26, 25,
+        24, 24, 23, 23, 23, 22, 22, 21, 20, 20, 20, 19, 19, 19, 18, 18, 30, 30,
+        30, 30, 31, 31, 30, 29, 29, 29, 28, 28, 27, 26, 26, 25, 24, 24, 23, 23,
+        23, 22, 22, 21, 20, 20, 20, 19, 19, 19, 18, 18, 29, 30, 30, 30, 30, 30,
+        30, 29, 28, 28, 28, 28, 26, 25, 25, 24, 23, 23, 22, 22, 22, 21, 20, 20,
+        19, 19, 19, 18, 18, 18, 17, 17, 28, 29, 29, 29, 30, 30, 29, 28, 28, 28,
+        27, 27, 26, 24, 24, 23, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17,
+        17, 17, 16, 16, 28, 29, 29, 29, 30, 30, 29, 28, 28, 28, 27, 27, 26, 24,
+        24, 23, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16,
+        27, 28, 28, 28, 28, 28, 28, 27, 27, 27, 26, 26, 25, 23, 23, 22, 20, 20,
+        20, 20, 20, 19, 18, 18, 18, 17, 17, 17, 16, 16, 15, 15, 26, 26, 27, 27,
+        28, 28, 27, 26, 26, 26, 26, 26, 24, 23, 23, 22, 20, 20, 20, 19, 19, 18,
+        18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 26, 26, 27, 27, 28, 28, 27, 26,
+        26, 26, 26, 26, 24, 23, 23, 22, 20, 20, 20, 19, 19, 18, 18, 18, 17, 17,
+        17, 16, 16, 16, 15, 15, 24, 25, 25, 25, 26, 26, 26, 25, 25, 25, 24, 24,
+        23, 22, 22, 21, 19, 19, 19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15,
+        14, 14, 23, 24, 24, 24, 25, 25, 25, 24, 24, 24, 24, 24, 23, 22, 22, 20,
+        19, 19, 18, 18, 18, 17, 16, 16, 16, 15, 15, 14, 14, 14, 14, 14, 23, 24,
+        24, 24, 25, 25, 25, 24, 24, 24, 24, 24, 23, 21, 21, 20, 19, 19, 18, 18,
+        18, 17, 16, 16, 16, 15, 15, 14, 14, 14, 13, 13, 22, 22, 23, 23, 23, 23,
+        23, 23, 23, 23, 23, 23, 22, 20, 20, 19, 18, 18, 18, 17, 17, 16, 16, 16,
+        15, 15, 14, 14, 14, 13, 13, 13, 21, 22, 22, 22, 23, 23, 23, 23, 23, 23,
+        22, 22, 22, 20, 20, 19, 18, 18, 17, 17, 17, 16, 15, 15, 15, 14, 14, 14,
+        13, 13, 13, 13, 21, 21, 22, 22, 22, 23, 23, 22, 22, 22, 22, 22, 21, 20,
+        20, 19, 18, 18, 17, 17, 17, 16, 15, 15, 14, 14, 14, 13, 13, 13, 13, 13,
+        19, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 20, 19, 19, 18, 17, 17,
+        17, 16, 16, 15, 14, 14, 14, 14, 13, 13, 13, 12, 12, 12, 19, 20, 20, 20,
+        20, 21, 21, 20, 20, 21, 21, 21, 20, 19, 19, 18, 17, 17, 16, 16, 16, 15,
+        14, 14, 14, 13, 13, 13, 12, 12, 12, 12, 19, 19, 19, 20, 20, 20, 20, 20,
+        20, 20, 20, 20, 20, 19, 19, 18, 17, 17, 16, 16, 16, 15, 14, 14, 13, 13,
+        13, 12, 12, 12, 12, 12, 17, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 18, 18, 17, 16, 16, 15, 15, 15, 14, 14, 13, 13, 13, 13, 12, 12, 12,
+        11, 11, 17, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 17,
+        16, 16, 15, 15, 15, 14, 14, 13, 13, 13, 13, 12, 12, 12, 11, 11,
         /* Size 4x8 */
-        64, 63, 48, 37, 64, 62, 50, 39, 63, 58, 48, 39, 59, 55, 41, 34, 54, 51,
-        35, 30, 46, 45, 31, 26, 41, 41, 29, 24, 34, 35, 26, 21,
+        32, 32, 28, 20, 32, 31, 28, 21, 32, 30, 27, 21, 30, 28, 23, 19, 29, 27,
+        21, 17, 26, 24, 19, 15, 22, 22, 17, 13, 20, 20, 16, 12,
         /* Size 8x4 */
-        64, 64, 63, 59, 54, 46, 41, 34, 63, 62, 58, 55, 51, 45, 41, 35, 48, 50,
-        48, 41, 35, 31, 29, 26, 37, 39, 39, 34, 30, 26, 24, 21,
+        32, 32, 32, 30, 29, 26, 22, 20, 32, 31, 30, 28, 27, 24, 22, 20, 28, 28,
+        27, 23, 21, 19, 17, 16, 20, 21, 21, 19, 17, 15, 13, 12,
         /* Size 8x16 */
-        64, 65, 64, 59, 53, 47, 38, 31, 65, 64, 63, 59, 54, 48, 40, 33, 65, 63,
-        62, 60, 55, 50, 41, 34, 65, 63, 60, 58, 53, 49, 41, 35, 64, 63, 59, 56,
-        53, 48, 41, 35, 64, 62, 58, 55, 51, 48, 41, 35, 60, 60, 55, 49, 46, 43,
-        38, 33, 57, 59, 53, 45, 41, 38, 34, 30, 53, 55, 51, 43, 39, 36, 32, 28,
-        50, 53, 49, 41, 38, 34, 30, 27, 47, 50, 48, 40, 36, 33, 29, 26, 43, 46,
-        44, 38, 34, 31, 27, 24, 38, 41, 41, 36, 32, 29, 25, 22, 36, 39, 39, 34,
-        31, 27, 24, 21, 34, 36, 37, 33, 29, 27, 23, 20, 32, 34, 35, 31, 28, 26,
-        22, 20,
+        32, 33, 32, 32, 28, 23, 22, 19, 33, 32, 32, 31, 29, 24, 23, 20, 33, 32,
+        32, 31, 29, 25, 23, 21, 33, 32, 31, 31, 29, 25, 23, 21, 32, 32, 30, 30,
+        28, 24, 23, 20, 32, 31, 29, 28, 27, 24, 23, 21, 32, 31, 29, 28, 26, 23,
+        22, 20, 30, 30, 28, 27, 24, 21, 20, 19, 28, 30, 28, 26, 21, 19, 18, 17,
+        27, 28, 26, 25, 21, 18, 18, 16, 26, 28, 26, 24, 20, 18, 17, 16, 23, 25,
+        24, 23, 19, 16, 16, 14, 22, 23, 23, 22, 18, 16, 15, 14, 21, 22, 22, 21,
+        18, 15, 14, 13, 19, 21, 20, 20, 17, 14, 14, 12, 18, 19, 19, 19, 16, 14,
+        13, 12,
         /* Size 16x8 */
-        64, 65, 65, 65, 64, 64, 60, 57, 53, 50, 47, 43, 38, 36, 34, 32, 65, 64,
-        63, 63, 63, 62, 60, 59, 55, 53, 50, 46, 41, 39, 36, 34, 64, 63, 62, 60,
-        59, 58, 55, 53, 51, 49, 48, 44, 41, 39, 37, 35, 59, 59, 60, 58, 56, 55,
-        49, 45, 43, 41, 40, 38, 36, 34, 33, 31, 53, 54, 55, 53, 53, 51, 46, 41,
-        39, 38, 36, 34, 32, 31, 29, 28, 47, 48, 50, 49, 48, 48, 43, 38, 36, 34,
-        33, 31, 29, 27, 27, 26, 38, 40, 41, 41, 41, 41, 38, 34, 32, 30, 29, 27,
-        25, 24, 23, 22, 31, 33, 34, 35, 35, 35, 33, 30, 28, 27, 26, 24, 22, 21,
-        20, 20,
+        32, 33, 33, 33, 32, 32, 32, 30, 28, 27, 26, 23, 22, 21, 19, 18, 33, 32,
+        32, 32, 32, 31, 31, 30, 30, 28, 28, 25, 23, 22, 21, 19, 32, 32, 32, 31,
+        30, 29, 29, 28, 28, 26, 26, 24, 23, 22, 20, 19, 32, 31, 31, 31, 30, 28,
+        28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 28, 29, 29, 29, 28, 27, 26, 24,
+        21, 21, 20, 19, 18, 18, 17, 16, 23, 24, 25, 25, 24, 24, 23, 21, 19, 18,
+        18, 16, 16, 15, 14, 14, 22, 23, 23, 23, 23, 23, 22, 20, 18, 18, 17, 16,
+        15, 14, 14, 13, 19, 20, 21, 21, 20, 21, 20, 19, 17, 16, 16, 14, 14, 13,
+        12, 12,
         /* Size 16x32 */
-        64, 65, 65, 65, 64, 64, 59, 57, 53, 47, 47, 40, 38, 35, 31, 31, 65, 64,
-        64, 64, 63, 63, 59, 58, 54, 48, 48, 41, 39, 37, 33, 33, 65, 64, 64, 64,
-        63, 63, 59, 58, 54, 48, 48, 41, 40, 37, 33, 33, 65, 64, 64, 63, 63, 63,
-        59, 59, 55, 49, 49, 42, 41, 38, 34, 34, 65, 64, 63, 63, 62, 62, 60, 59,
-        55, 50, 50, 43, 41, 39, 34, 34, 65, 64, 63, 63, 62, 62, 60, 59, 55, 50,
-        50, 43, 41, 39, 34, 34, 65, 63, 63, 62, 60, 60, 58, 57, 53, 49, 49, 43,
-        41, 39, 35, 35, 64, 63, 63, 62, 60, 60, 57, 56, 53, 49, 49, 43, 41, 39,
-        35, 35, 64, 63, 63, 61, 59, 59, 56, 55, 53, 48, 48, 43, 41, 39, 35, 35,
-        64, 63, 62, 60, 58, 58, 55, 53, 51, 48, 48, 43, 41, 39, 35, 35, 64, 63,
-        62, 60, 58, 58, 55, 53, 51, 48, 48, 43, 41, 39, 35, 35, 61, 61, 61, 59,
-        56, 56, 51, 49, 47, 44, 44, 39, 38, 36, 33, 33, 60, 60, 60, 59, 55, 55,
-        49, 48, 46, 43, 43, 39, 38, 36, 33, 33, 59, 59, 60, 58, 55, 55, 48, 46,
-        44, 41, 41, 37, 36, 34, 32, 32, 57, 59, 59, 57, 53, 53, 45, 43, 41, 38,
-        38, 35, 34, 33, 30, 30, 57, 59, 59, 57, 53, 53, 45, 43, 41, 38, 38, 35,
-        34, 33, 30, 30, 53, 55, 55, 53, 51, 51, 43, 41, 39, 36, 36, 33, 32, 31,
-        28, 28, 52, 54, 55, 53, 51, 51, 43, 41, 39, 35, 35, 32, 32, 30, 28, 28,
-        50, 52, 53, 51, 49, 49, 41, 40, 38, 34, 34, 31, 30, 29, 27, 27, 47, 49,
-        50, 49, 48, 48, 40, 38, 36, 33, 33, 29, 29, 27, 26, 26, 47, 49, 50, 49,
-        48, 48, 40, 38, 36, 33, 33, 29, 29, 27, 26, 26, 44, 46, 47, 46, 45, 45,
-        38, 37, 34, 31, 31, 28, 27, 26, 24, 24, 43, 45, 46, 45, 44, 44, 38, 36,
-        34, 31, 31, 28, 27, 26, 24, 24, 41, 43, 44, 44, 43, 43, 37, 35, 33, 30,
-        30, 27, 26, 25, 23, 23, 38, 41, 41, 41, 41, 41, 36, 34, 32, 29, 29, 26,
-        25, 24, 22, 22, 38, 41, 41, 41, 41, 41, 36, 34, 32, 29, 29, 26, 25, 24,
-        22, 22, 36, 38, 39, 39, 39, 39, 34, 33, 31, 27, 27, 25, 24, 23, 21, 21,
-        35, 37, 38, 38, 38, 38, 33, 32, 30, 27, 27, 24, 24, 23, 21, 21, 34, 36,
-        36, 37, 37, 37, 33, 31, 29, 27, 27, 24, 23, 22, 20, 20, 32, 34, 34, 34,
-        35, 35, 31, 30, 28, 26, 26, 23, 22, 21, 20, 20, 32, 34, 34, 34, 35, 35,
-        31, 30, 28, 26, 26, 23, 22, 21, 20, 20, 29, 32, 32, 32, 33, 33, 29, 28,
-        27, 25, 25, 22, 21, 20, 19, 19,
+        32, 33, 33, 33, 32, 32, 32, 29, 28, 27, 23, 23, 22, 19, 19, 17, 33, 32,
+        32, 32, 32, 32, 31, 29, 29, 28, 24, 24, 22, 20, 20, 18, 33, 32, 32, 32,
+        32, 32, 31, 29, 29, 28, 24, 24, 23, 20, 20, 18, 33, 32, 32, 32, 32, 32,
+        31, 29, 29, 28, 24, 24, 23, 20, 20, 18, 33, 32, 32, 32, 32, 32, 31, 30,
+        29, 28, 25, 25, 23, 21, 21, 19, 33, 32, 32, 32, 32, 31, 31, 30, 30, 28,
+        25, 25, 23, 21, 21, 19, 33, 32, 32, 32, 31, 31, 31, 29, 29, 28, 25, 25,
+        23, 21, 21, 19, 32, 32, 32, 32, 31, 30, 30, 28, 28, 27, 24, 24, 23, 21,
+        21, 19, 32, 32, 32, 31, 30, 30, 30, 28, 28, 27, 24, 24, 23, 20, 20, 19,
+        32, 32, 32, 31, 30, 30, 29, 28, 28, 27, 24, 24, 23, 21, 21, 19, 32, 32,
+        31, 31, 29, 29, 28, 27, 27, 26, 24, 24, 23, 21, 21, 19, 32, 32, 31, 31,
+        29, 29, 28, 27, 27, 26, 24, 24, 23, 21, 21, 19, 32, 31, 31, 31, 29, 28,
+        28, 26, 26, 25, 23, 23, 22, 20, 20, 19, 30, 30, 30, 30, 28, 28, 27, 24,
+        24, 23, 21, 21, 20, 19, 19, 18, 30, 30, 30, 30, 28, 28, 27, 24, 24, 23,
+        21, 21, 20, 19, 19, 18, 29, 30, 30, 30, 28, 28, 26, 23, 23, 22, 20, 20,
+        19, 18, 18, 17, 28, 29, 30, 29, 28, 27, 26, 22, 21, 21, 19, 19, 18, 17,
+        17, 16, 28, 29, 30, 29, 28, 27, 26, 22, 21, 21, 19, 19, 18, 17, 17, 16,
+        27, 28, 28, 28, 26, 26, 25, 21, 21, 20, 18, 18, 18, 16, 16, 15, 26, 27,
+        28, 27, 26, 26, 24, 21, 20, 20, 18, 18, 17, 16, 16, 15, 26, 27, 28, 27,
+        26, 26, 24, 21, 20, 20, 18, 18, 17, 16, 16, 15, 24, 26, 26, 26, 24, 24,
+        23, 20, 20, 19, 17, 17, 16, 15, 15, 14, 23, 24, 25, 25, 24, 24, 23, 20,
+        19, 18, 16, 16, 16, 14, 14, 14, 23, 24, 25, 25, 24, 24, 23, 20, 19, 18,
+        16, 16, 16, 14, 14, 13, 22, 23, 23, 23, 23, 23, 22, 19, 18, 18, 16, 16,
+        15, 14, 14, 13, 21, 22, 23, 23, 22, 22, 21, 19, 18, 17, 15, 15, 15, 13,
+        13, 13, 21, 22, 22, 22, 22, 22, 21, 18, 18, 17, 15, 15, 14, 13, 13, 13,
+        19, 20, 21, 21, 21, 21, 20, 18, 17, 17, 14, 14, 14, 13, 13, 12, 19, 20,
+        21, 21, 20, 20, 20, 17, 17, 16, 14, 14, 14, 12, 12, 12, 19, 20, 20, 20,
+        20, 20, 19, 17, 17, 16, 14, 14, 13, 12, 12, 12, 18, 19, 19, 19, 19, 19,
+        19, 17, 16, 15, 14, 14, 13, 12, 12, 11, 18, 19, 19, 19, 19, 19, 19, 17,
+        16, 15, 14, 14, 13, 12, 12, 11,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 61, 60, 59, 57, 57, 53, 52,
-        50, 47, 47, 44, 43, 41, 38, 38, 36, 35, 34, 32, 32, 29, 65, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 61, 60, 59, 59, 59, 55, 54, 52, 49, 49, 46,
-        45, 43, 41, 41, 38, 37, 36, 34, 34, 32, 65, 64, 64, 64, 63, 63, 63, 63,
-        63, 62, 62, 61, 60, 60, 59, 59, 55, 55, 53, 50, 50, 47, 46, 44, 41, 41,
-        39, 38, 36, 34, 34, 32, 65, 64, 64, 63, 63, 63, 62, 62, 61, 60, 60, 59,
-        59, 58, 57, 57, 53, 53, 51, 49, 49, 46, 45, 44, 41, 41, 39, 38, 37, 34,
-        34, 32, 64, 63, 63, 63, 62, 62, 60, 60, 59, 58, 58, 56, 55, 55, 53, 53,
-        51, 51, 49, 48, 48, 45, 44, 43, 41, 41, 39, 38, 37, 35, 35, 33, 64, 63,
-        63, 63, 62, 62, 60, 60, 59, 58, 58, 56, 55, 55, 53, 53, 51, 51, 49, 48,
-        48, 45, 44, 43, 41, 41, 39, 38, 37, 35, 35, 33, 59, 59, 59, 59, 60, 60,
-        58, 57, 56, 55, 55, 51, 49, 48, 45, 45, 43, 43, 41, 40, 40, 38, 38, 37,
-        36, 36, 34, 33, 33, 31, 31, 29, 57, 58, 58, 59, 59, 59, 57, 56, 55, 53,
-        53, 49, 48, 46, 43, 43, 41, 41, 40, 38, 38, 37, 36, 35, 34, 34, 33, 32,
-        31, 30, 30, 28, 53, 54, 54, 55, 55, 55, 53, 53, 53, 51, 51, 47, 46, 44,
-        41, 41, 39, 39, 38, 36, 36, 34, 34, 33, 32, 32, 31, 30, 29, 28, 28, 27,
-        47, 48, 48, 49, 50, 50, 49, 49, 48, 48, 48, 44, 43, 41, 38, 38, 36, 35,
-        34, 33, 33, 31, 31, 30, 29, 29, 27, 27, 27, 26, 26, 25, 47, 48, 48, 49,
-        50, 50, 49, 49, 48, 48, 48, 44, 43, 41, 38, 38, 36, 35, 34, 33, 33, 31,
-        31, 30, 29, 29, 27, 27, 27, 26, 26, 25, 40, 41, 41, 42, 43, 43, 43, 43,
-        43, 43, 43, 39, 39, 37, 35, 35, 33, 32, 31, 29, 29, 28, 28, 27, 26, 26,
-        25, 24, 24, 23, 23, 22, 38, 39, 40, 41, 41, 41, 41, 41, 41, 41, 41, 38,
-        38, 36, 34, 34, 32, 32, 30, 29, 29, 27, 27, 26, 25, 25, 24, 24, 23, 22,
-        22, 21, 35, 37, 37, 38, 39, 39, 39, 39, 39, 39, 39, 36, 36, 34, 33, 33,
-        31, 30, 29, 27, 27, 26, 26, 25, 24, 24, 23, 23, 22, 21, 21, 20, 31, 33,
-        33, 34, 34, 34, 35, 35, 35, 35, 35, 33, 33, 32, 30, 30, 28, 28, 27, 26,
-        26, 24, 24, 23, 22, 22, 21, 21, 20, 20, 20, 19, 31, 33, 33, 34, 34, 34,
-        35, 35, 35, 35, 35, 33, 33, 32, 30, 30, 28, 28, 27, 26, 26, 24, 24, 23,
-        22, 22, 21, 21, 20, 20, 20, 19,
+        32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 30, 30, 29, 28, 28,
+        27, 26, 26, 24, 23, 23, 22, 21, 21, 19, 19, 19, 18, 18, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 30, 29, 29, 28, 27, 27, 26,
+        24, 24, 23, 22, 22, 20, 20, 20, 19, 19, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 30, 30, 30, 30, 30, 28, 28, 28, 26, 25, 25, 23, 23,
+        22, 21, 21, 20, 19, 19, 33, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 30, 30, 30, 29, 29, 28, 27, 27, 26, 25, 25, 23, 23, 22, 21, 21, 20,
+        19, 19, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 29, 29, 29, 28, 28, 28,
+        28, 28, 26, 26, 26, 24, 24, 24, 23, 22, 22, 21, 20, 20, 19, 19, 32, 32,
+        32, 32, 32, 31, 31, 30, 30, 30, 29, 29, 28, 28, 28, 28, 27, 27, 26, 26,
+        26, 24, 24, 24, 23, 22, 22, 21, 20, 20, 19, 19, 32, 31, 31, 31, 31, 31,
+        31, 30, 30, 29, 28, 28, 28, 27, 27, 26, 26, 26, 25, 24, 24, 23, 23, 23,
+        22, 21, 21, 20, 20, 19, 19, 19, 29, 29, 29, 29, 30, 30, 29, 28, 28, 28,
+        27, 27, 26, 24, 24, 23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 18, 18,
+        17, 17, 17, 17, 28, 29, 29, 29, 29, 30, 29, 28, 28, 28, 27, 27, 26, 24,
+        24, 23, 21, 21, 21, 20, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16,
+        27, 28, 28, 28, 28, 28, 28, 27, 27, 27, 26, 26, 25, 23, 23, 22, 21, 21,
+        20, 20, 20, 19, 18, 18, 18, 17, 17, 17, 16, 16, 15, 15, 23, 24, 24, 24,
+        25, 25, 25, 24, 24, 24, 24, 24, 23, 21, 21, 20, 19, 19, 18, 18, 18, 17,
+        16, 16, 16, 15, 15, 14, 14, 14, 14, 14, 23, 24, 24, 24, 25, 25, 25, 24,
+        24, 24, 24, 24, 23, 21, 21, 20, 19, 19, 18, 18, 18, 17, 16, 16, 16, 15,
+        15, 14, 14, 14, 14, 14, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+        22, 20, 20, 19, 18, 18, 18, 17, 17, 16, 16, 16, 15, 15, 14, 14, 14, 13,
+        13, 13, 19, 20, 20, 20, 21, 21, 21, 21, 20, 21, 21, 21, 20, 19, 19, 18,
+        17, 17, 16, 16, 16, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 12, 19, 20,
+        20, 20, 21, 21, 21, 21, 20, 21, 21, 21, 20, 19, 19, 18, 17, 17, 16, 16,
+        16, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 12, 17, 18, 18, 18, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 18, 18, 17, 16, 16, 15, 15, 15, 14, 14, 13,
+        13, 13, 13, 12, 12, 12, 11, 11,
         /* Size 4x16 */
-        65, 64, 47, 35, 64, 63, 48, 37, 64, 62, 50, 39, 63, 60, 49, 39, 63, 59,
-        48, 39, 63, 58, 48, 39, 60, 55, 43, 36, 59, 53, 38, 33, 55, 51, 36, 31,
-        52, 49, 34, 29, 49, 48, 33, 27, 45, 44, 31, 26, 41, 41, 29, 24, 38, 39,
-        27, 23, 36, 37, 27, 22, 34, 35, 26, 21,
+        33, 32, 27, 19, 32, 32, 28, 20, 32, 32, 28, 21, 32, 31, 28, 21, 32, 30,
+        27, 20, 32, 29, 26, 21, 31, 28, 25, 20, 30, 28, 23, 19, 29, 27, 21, 17,
+        28, 26, 20, 16, 27, 26, 20, 16, 24, 24, 18, 14, 23, 23, 18, 14, 22, 22,
+        17, 13, 20, 20, 16, 12, 19, 19, 15, 12,
         /* Size 16x4 */
-        65, 64, 64, 63, 63, 63, 60, 59, 55, 52, 49, 45, 41, 38, 36, 34, 64, 63,
-        62, 60, 59, 58, 55, 53, 51, 49, 48, 44, 41, 39, 37, 35, 47, 48, 50, 49,
-        48, 48, 43, 38, 36, 34, 33, 31, 29, 27, 27, 26, 35, 37, 39, 39, 39, 39,
-        36, 33, 31, 29, 27, 26, 24, 23, 22, 21,
+        33, 32, 32, 32, 32, 32, 31, 30, 29, 28, 27, 24, 23, 22, 20, 19, 32, 32,
+        32, 31, 30, 29, 28, 28, 27, 26, 26, 24, 23, 22, 20, 19, 27, 28, 28, 28,
+        27, 26, 25, 23, 21, 20, 20, 18, 18, 17, 16, 15, 19, 20, 21, 21, 20, 21,
+        20, 19, 17, 16, 16, 14, 14, 13, 12, 12,
         /* Size 8x32 */
-        64, 65, 64, 59, 53, 47, 38, 31, 65, 64, 63, 59, 54, 48, 39, 33, 65, 64,
-        63, 59, 54, 48, 40, 33, 65, 64, 63, 59, 55, 49, 41, 34, 65, 63, 62, 60,
-        55, 50, 41, 34, 65, 63, 62, 60, 55, 50, 41, 34, 65, 63, 60, 58, 53, 49,
-        41, 35, 64, 63, 60, 57, 53, 49, 41, 35, 64, 63, 59, 56, 53, 48, 41, 35,
-        64, 62, 58, 55, 51, 48, 41, 35, 64, 62, 58, 55, 51, 48, 41, 35, 61, 61,
-        56, 51, 47, 44, 38, 33, 60, 60, 55, 49, 46, 43, 38, 33, 59, 60, 55, 48,
-        44, 41, 36, 32, 57, 59, 53, 45, 41, 38, 34, 30, 57, 59, 53, 45, 41, 38,
-        34, 30, 53, 55, 51, 43, 39, 36, 32, 28, 52, 55, 51, 43, 39, 35, 32, 28,
-        50, 53, 49, 41, 38, 34, 30, 27, 47, 50, 48, 40, 36, 33, 29, 26, 47, 50,
-        48, 40, 36, 33, 29, 26, 44, 47, 45, 38, 34, 31, 27, 24, 43, 46, 44, 38,
-        34, 31, 27, 24, 41, 44, 43, 37, 33, 30, 26, 23, 38, 41, 41, 36, 32, 29,
-        25, 22, 38, 41, 41, 36, 32, 29, 25, 22, 36, 39, 39, 34, 31, 27, 24, 21,
-        35, 38, 38, 33, 30, 27, 24, 21, 34, 36, 37, 33, 29, 27, 23, 20, 32, 34,
-        35, 31, 28, 26, 22, 20, 32, 34, 35, 31, 28, 26, 22, 20, 29, 32, 33, 29,
-        27, 25, 21, 19,
+        32, 33, 32, 32, 28, 23, 22, 19, 33, 32, 32, 31, 29, 24, 22, 20, 33, 32,
+        32, 31, 29, 24, 23, 20, 33, 32, 32, 31, 29, 24, 23, 20, 33, 32, 32, 31,
+        29, 25, 23, 21, 33, 32, 32, 31, 30, 25, 23, 21, 33, 32, 31, 31, 29, 25,
+        23, 21, 32, 32, 31, 30, 28, 24, 23, 21, 32, 32, 30, 30, 28, 24, 23, 20,
+        32, 32, 30, 29, 28, 24, 23, 21, 32, 31, 29, 28, 27, 24, 23, 21, 32, 31,
+        29, 28, 27, 24, 23, 21, 32, 31, 29, 28, 26, 23, 22, 20, 30, 30, 28, 27,
+        24, 21, 20, 19, 30, 30, 28, 27, 24, 21, 20, 19, 29, 30, 28, 26, 23, 20,
+        19, 18, 28, 30, 28, 26, 21, 19, 18, 17, 28, 30, 28, 26, 21, 19, 18, 17,
+        27, 28, 26, 25, 21, 18, 18, 16, 26, 28, 26, 24, 20, 18, 17, 16, 26, 28,
+        26, 24, 20, 18, 17, 16, 24, 26, 24, 23, 20, 17, 16, 15, 23, 25, 24, 23,
+        19, 16, 16, 14, 23, 25, 24, 23, 19, 16, 16, 14, 22, 23, 23, 22, 18, 16,
+        15, 14, 21, 23, 22, 21, 18, 15, 15, 13, 21, 22, 22, 21, 18, 15, 14, 13,
+        19, 21, 21, 20, 17, 14, 14, 13, 19, 21, 20, 20, 17, 14, 14, 12, 19, 20,
+        20, 19, 17, 14, 13, 12, 18, 19, 19, 19, 16, 14, 13, 12, 18, 19, 19, 19,
+        16, 14, 13, 12,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 61, 60, 59, 57, 57, 53, 52,
-        50, 47, 47, 44, 43, 41, 38, 38, 36, 35, 34, 32, 32, 29, 65, 64, 64, 64,
-        63, 63, 63, 63, 63, 62, 62, 61, 60, 60, 59, 59, 55, 55, 53, 50, 50, 47,
-        46, 44, 41, 41, 39, 38, 36, 34, 34, 32, 64, 63, 63, 63, 62, 62, 60, 60,
-        59, 58, 58, 56, 55, 55, 53, 53, 51, 51, 49, 48, 48, 45, 44, 43, 41, 41,
-        39, 38, 37, 35, 35, 33, 59, 59, 59, 59, 60, 60, 58, 57, 56, 55, 55, 51,
-        49, 48, 45, 45, 43, 43, 41, 40, 40, 38, 38, 37, 36, 36, 34, 33, 33, 31,
-        31, 29, 53, 54, 54, 55, 55, 55, 53, 53, 53, 51, 51, 47, 46, 44, 41, 41,
-        39, 39, 38, 36, 36, 34, 34, 33, 32, 32, 31, 30, 29, 28, 28, 27, 47, 48,
-        48, 49, 50, 50, 49, 49, 48, 48, 48, 44, 43, 41, 38, 38, 36, 35, 34, 33,
-        33, 31, 31, 30, 29, 29, 27, 27, 27, 26, 26, 25, 38, 39, 40, 41, 41, 41,
-        41, 41, 41, 41, 41, 38, 38, 36, 34, 34, 32, 32, 30, 29, 29, 27, 27, 26,
-        25, 25, 24, 24, 23, 22, 22, 21, 31, 33, 33, 34, 34, 34, 35, 35, 35, 35,
-        35, 33, 33, 32, 30, 30, 28, 28, 27, 26, 26, 24, 24, 23, 22, 22, 21, 21,
-        20, 20, 20, 19 },
+        32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 30, 30, 29, 28, 28,
+        27, 26, 26, 24, 23, 23, 22, 21, 21, 19, 19, 19, 18, 18, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 30, 28, 28, 28, 26,
+        25, 25, 23, 23, 22, 21, 21, 20, 19, 19, 32, 32, 32, 32, 32, 32, 31, 31,
+        30, 30, 29, 29, 29, 28, 28, 28, 28, 28, 26, 26, 26, 24, 24, 24, 23, 22,
+        22, 21, 20, 20, 19, 19, 32, 31, 31, 31, 31, 31, 31, 30, 30, 29, 28, 28,
+        28, 27, 27, 26, 26, 26, 25, 24, 24, 23, 23, 23, 22, 21, 21, 20, 20, 19,
+        19, 19, 28, 29, 29, 29, 29, 30, 29, 28, 28, 28, 27, 27, 26, 24, 24, 23,
+        21, 21, 21, 20, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 23, 24,
+        24, 24, 25, 25, 25, 24, 24, 24, 24, 24, 23, 21, 21, 20, 19, 19, 18, 18,
+        18, 17, 16, 16, 16, 15, 15, 14, 14, 14, 14, 14, 22, 22, 23, 23, 23, 23,
+        23, 23, 23, 23, 23, 23, 22, 20, 20, 19, 18, 18, 18, 17, 17, 16, 16, 16,
+        15, 15, 14, 14, 14, 13, 13, 13, 19, 20, 20, 20, 21, 21, 21, 21, 20, 21,
+        21, 21, 20, 19, 19, 18, 17, 17, 16, 16, 16, 15, 14, 14, 14, 13, 13, 13,
+        12, 12, 12, 12 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        53, 44, 44, 32,
+        27, 23, 23, 17,
 #endif
         /* Size 4x4 */
-        65, 49, 45, 40, 49, 43, 42, 40, 45, 42, 35, 33, 40, 40, 33, 29,
+        33, 27, 22, 21, 27, 22, 22, 22, 22, 22, 19, 18, 21, 22, 18, 16,
         /* Size 8x8 */
-        65, 66, 54, 46, 43, 42, 41, 37, 66, 64, 51, 47, 45, 45, 43, 39, 54, 51,
-        43, 43, 44, 45, 44, 41, 46, 47, 43, 41, 40, 40, 39, 38, 43, 45, 44, 40,
-        38, 36, 36, 34, 42, 45, 45, 40, 36, 34, 33, 31, 41, 43, 44, 39, 36, 33,
-        31, 29, 37, 39, 41, 38, 34, 31, 29, 27,
+        33, 33, 29, 24, 21, 22, 21, 20, 33, 32, 28, 24, 22, 23, 22, 21, 29, 28,
+        25, 23, 22, 23, 22, 21, 24, 24, 23, 21, 20, 21, 20, 20, 21, 22, 22, 20,
+        19, 19, 19, 19, 22, 23, 23, 21, 19, 18, 17, 17, 21, 22, 22, 20, 19, 17,
+        17, 16, 20, 21, 21, 20, 19, 17, 16, 15,
         /* Size 16x16 */
-        64, 66, 67, 62, 59, 56, 49, 42, 42, 42, 42, 41, 39, 38, 37, 36, 66, 65,
-        66, 60, 57, 53, 48, 43, 44, 44, 44, 42, 41, 40, 39, 38, 67, 66, 64, 59,
-        55, 51, 48, 44, 45, 45, 46, 44, 43, 41, 41, 39, 62, 60, 59, 55, 51, 48,
-        46, 44, 44, 45, 45, 44, 43, 42, 41, 40, 59, 57, 55, 51, 48, 46, 45, 43,
-        44, 45, 45, 44, 44, 42, 41, 41, 56, 53, 51, 48, 46, 43, 43, 43, 44, 45,
-        45, 45, 44, 43, 42, 41, 49, 48, 48, 46, 45, 43, 42, 41, 41, 41, 42, 41,
-        41, 40, 39, 38, 42, 43, 44, 44, 43, 43, 41, 39, 39, 38, 38, 38, 38, 37,
-        37, 36, 42, 44, 45, 44, 44, 44, 41, 39, 38, 38, 37, 37, 36, 35, 35, 35,
-        42, 44, 45, 45, 45, 45, 41, 38, 38, 37, 36, 35, 35, 34, 34, 33, 42, 44,
-        46, 45, 45, 45, 42, 38, 37, 36, 35, 34, 33, 33, 33, 32, 41, 42, 44, 44,
-        44, 45, 41, 38, 37, 35, 34, 33, 32, 32, 31, 31, 39, 41, 43, 43, 44, 44,
-        41, 38, 36, 35, 33, 32, 31, 30, 29, 29, 38, 40, 41, 42, 42, 43, 40, 37,
-        35, 34, 33, 32, 30, 29, 29, 28, 37, 39, 41, 41, 41, 42, 39, 37, 35, 34,
-        33, 31, 29, 29, 28, 27, 36, 38, 39, 40, 41, 41, 38, 36, 35, 33, 32, 31,
-        29, 28, 27, 27,
+        32, 33, 34, 33, 31, 28, 27, 25, 21, 21, 21, 21, 20, 20, 20, 19, 33, 33,
+        33, 32, 30, 27, 26, 24, 22, 22, 22, 22, 21, 21, 20, 20, 34, 33, 33, 32,
+        29, 26, 25, 24, 22, 22, 22, 23, 22, 22, 21, 20, 33, 32, 32, 31, 28, 26,
+        25, 24, 22, 22, 23, 23, 22, 22, 22, 21, 31, 30, 29, 28, 26, 24, 23, 23,
+        22, 22, 22, 23, 22, 22, 22, 21, 28, 27, 26, 26, 24, 22, 22, 22, 21, 22,
+        22, 23, 22, 22, 22, 21, 27, 26, 25, 25, 23, 22, 22, 21, 21, 21, 21, 22,
+        22, 22, 21, 21, 25, 24, 24, 24, 23, 22, 21, 21, 20, 20, 21, 21, 20, 20,
+        20, 20, 21, 22, 22, 22, 22, 21, 21, 20, 19, 19, 19, 19, 19, 19, 19, 19,
+        21, 22, 22, 22, 22, 22, 21, 20, 19, 19, 19, 19, 19, 19, 18, 18, 21, 22,
+        22, 23, 22, 22, 21, 21, 19, 19, 19, 19, 18, 18, 18, 18, 21, 22, 23, 23,
+        23, 23, 22, 21, 19, 19, 19, 18, 17, 17, 17, 17, 20, 21, 22, 22, 22, 22,
+        22, 20, 19, 19, 18, 17, 17, 17, 16, 16, 20, 21, 22, 22, 22, 22, 22, 20,
+        19, 19, 18, 17, 17, 17, 16, 16, 20, 20, 21, 22, 22, 22, 21, 20, 19, 18,
+        18, 17, 16, 16, 16, 15, 19, 20, 20, 21, 21, 21, 21, 20, 19, 18, 18, 17,
+        16, 16, 15, 14,
         /* Size 32x32 */
-        64, 65, 66, 66, 67, 67, 62, 61, 59, 56, 56, 51, 49, 46, 42, 42, 42, 42,
-        42, 42, 42, 41, 41, 40, 39, 39, 38, 38, 37, 36, 36, 34, 65, 65, 65, 66,
-        66, 66, 61, 59, 57, 54, 54, 49, 49, 46, 43, 43, 43, 43, 43, 43, 43, 42,
-        42, 41, 41, 41, 39, 39, 38, 37, 37, 36, 66, 65, 65, 65, 66, 66, 60, 59,
-        57, 53, 53, 49, 48, 46, 43, 43, 44, 44, 44, 44, 44, 43, 42, 42, 41, 41,
-        40, 39, 39, 38, 38, 36, 66, 66, 65, 65, 65, 65, 60, 59, 56, 53, 53, 49,
-        48, 47, 44, 44, 44, 44, 44, 45, 45, 43, 43, 43, 42, 42, 41, 40, 39, 38,
-        38, 37, 67, 66, 66, 65, 64, 64, 59, 58, 55, 51, 51, 49, 48, 47, 44, 44,
-        45, 45, 45, 46, 46, 45, 44, 44, 43, 43, 41, 41, 41, 39, 39, 38, 67, 66,
-        66, 65, 64, 64, 59, 58, 55, 51, 51, 49, 48, 47, 44, 44, 45, 45, 45, 46,
-        46, 45, 44, 44, 43, 43, 41, 41, 41, 39, 39, 38, 62, 61, 60, 60, 59, 59,
-        55, 53, 51, 48, 48, 47, 46, 45, 44, 44, 44, 45, 45, 45, 45, 44, 44, 44,
-        43, 43, 42, 41, 41, 40, 40, 39, 61, 59, 59, 59, 58, 58, 53, 53, 51, 47,
-        47, 46, 46, 45, 43, 43, 44, 44, 45, 45, 45, 44, 44, 44, 43, 43, 42, 41,
-        41, 40, 40, 39, 59, 57, 57, 56, 55, 55, 51, 51, 48, 46, 46, 45, 45, 44,
-        43, 43, 44, 44, 45, 45, 45, 45, 44, 44, 44, 44, 42, 42, 41, 41, 41, 39,
-        56, 54, 53, 53, 51, 51, 48, 47, 46, 43, 43, 43, 43, 43, 43, 43, 44, 44,
-        45, 45, 45, 45, 45, 44, 44, 44, 43, 42, 42, 41, 41, 40, 56, 54, 53, 53,
-        51, 51, 48, 47, 46, 43, 43, 43, 43, 43, 43, 43, 44, 44, 45, 45, 45, 45,
-        45, 44, 44, 44, 43, 42, 42, 41, 41, 40, 51, 49, 49, 49, 49, 49, 47, 46,
-        45, 43, 43, 43, 42, 42, 41, 41, 42, 42, 42, 42, 42, 42, 42, 41, 41, 41,
-        40, 40, 40, 39, 39, 38, 49, 49, 48, 48, 48, 48, 46, 46, 45, 43, 43, 42,
-        42, 41, 41, 41, 41, 41, 41, 42, 42, 41, 41, 41, 41, 41, 40, 39, 39, 38,
-        38, 37, 46, 46, 46, 47, 47, 47, 45, 45, 44, 43, 43, 42, 41, 41, 40, 40,
-        40, 40, 40, 40, 40, 40, 40, 40, 39, 39, 39, 38, 38, 38, 38, 37, 42, 43,
-        43, 44, 44, 44, 44, 43, 43, 43, 43, 41, 41, 40, 39, 39, 39, 39, 38, 38,
-        38, 38, 38, 38, 38, 38, 37, 37, 37, 36, 36, 35, 42, 43, 43, 44, 44, 44,
-        44, 43, 43, 43, 43, 41, 41, 40, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38,
-        38, 38, 37, 37, 37, 36, 36, 35, 42, 43, 44, 44, 45, 45, 44, 44, 44, 44,
-        44, 42, 41, 40, 39, 39, 38, 38, 38, 37, 37, 37, 37, 36, 36, 36, 35, 35,
-        35, 35, 35, 34, 42, 43, 44, 44, 45, 45, 45, 44, 44, 44, 44, 42, 41, 40,
-        39, 39, 38, 38, 37, 37, 37, 36, 36, 36, 36, 36, 35, 35, 35, 34, 34, 33,
-        42, 43, 44, 44, 45, 45, 45, 45, 45, 45, 45, 42, 41, 40, 38, 38, 38, 37,
-        37, 36, 36, 36, 35, 35, 35, 35, 34, 34, 34, 33, 33, 33, 42, 43, 44, 45,
-        46, 46, 45, 45, 45, 45, 45, 42, 42, 40, 38, 38, 37, 37, 36, 35, 35, 34,
-        34, 34, 33, 33, 33, 33, 33, 32, 32, 32, 42, 43, 44, 45, 46, 46, 45, 45,
-        45, 45, 45, 42, 42, 40, 38, 38, 37, 37, 36, 35, 35, 34, 34, 34, 33, 33,
-        33, 33, 33, 32, 32, 32, 41, 42, 43, 43, 45, 45, 44, 44, 45, 45, 45, 42,
-        41, 40, 38, 38, 37, 36, 36, 34, 34, 34, 34, 33, 33, 33, 32, 32, 31, 31,
-        31, 30, 41, 42, 42, 43, 44, 44, 44, 44, 44, 45, 45, 42, 41, 40, 38, 38,
-        37, 36, 35, 34, 34, 34, 33, 33, 32, 32, 32, 32, 31, 31, 31, 30, 40, 41,
-        42, 43, 44, 44, 44, 44, 44, 44, 44, 41, 41, 40, 38, 38, 36, 36, 35, 34,
-        34, 33, 33, 32, 32, 32, 31, 31, 31, 30, 30, 29, 39, 41, 41, 42, 43, 43,
-        43, 43, 44, 44, 44, 41, 41, 39, 38, 38, 36, 36, 35, 33, 33, 33, 32, 32,
-        31, 31, 30, 30, 29, 29, 29, 28, 39, 41, 41, 42, 43, 43, 43, 43, 44, 44,
-        44, 41, 41, 39, 38, 38, 36, 36, 35, 33, 33, 33, 32, 32, 31, 31, 30, 30,
-        29, 29, 29, 28, 38, 39, 40, 41, 41, 41, 42, 42, 42, 43, 43, 40, 40, 39,
-        37, 37, 35, 35, 34, 33, 33, 32, 32, 31, 30, 30, 29, 29, 29, 28, 28, 27,
-        38, 39, 39, 40, 41, 41, 41, 41, 42, 42, 42, 40, 39, 38, 37, 37, 35, 35,
-        34, 33, 33, 32, 32, 31, 30, 30, 29, 29, 28, 28, 28, 27, 37, 38, 39, 39,
-        41, 41, 41, 41, 41, 42, 42, 40, 39, 38, 37, 37, 35, 35, 34, 33, 33, 31,
-        31, 31, 29, 29, 29, 28, 28, 27, 27, 27, 36, 37, 38, 38, 39, 39, 40, 40,
-        41, 41, 41, 39, 38, 38, 36, 36, 35, 34, 33, 32, 32, 31, 31, 30, 29, 29,
-        28, 28, 27, 27, 27, 26, 36, 37, 38, 38, 39, 39, 40, 40, 41, 41, 41, 39,
-        38, 38, 36, 36, 35, 34, 33, 32, 32, 31, 31, 30, 29, 29, 28, 28, 27, 27,
-        27, 26, 34, 36, 36, 37, 38, 38, 39, 39, 39, 40, 40, 38, 37, 37, 35, 35,
-        34, 33, 33, 32, 32, 30, 30, 29, 28, 28, 27, 27, 27, 26, 26, 25,
+        32, 33, 33, 33, 34, 34, 33, 31, 31, 30, 28, 28, 27, 25, 25, 23, 21, 21,
+        21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 19, 19, 19, 33, 33, 33, 33,
+        33, 33, 33, 30, 30, 29, 27, 27, 26, 24, 24, 23, 21, 21, 22, 22, 22, 22,
+        22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 33, 33, 33, 33, 33, 33, 32, 30,
+        30, 29, 27, 27, 26, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21,
+        21, 21, 20, 20, 20, 20, 33, 33, 33, 33, 33, 33, 32, 30, 30, 28, 27, 27,
+        26, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 20,
+        20, 20, 34, 33, 33, 33, 33, 33, 32, 29, 29, 28, 26, 26, 25, 24, 24, 23,
+        22, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 21, 21, 21, 20, 20, 34, 33,
+        33, 33, 33, 32, 32, 29, 29, 28, 26, 26, 25, 24, 24, 23, 22, 22, 22, 23,
+        23, 23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21, 33, 33, 32, 32, 32, 32,
+        31, 29, 28, 28, 26, 26, 25, 24, 24, 23, 22, 22, 22, 23, 23, 23, 23, 23,
+        22, 22, 22, 22, 22, 21, 21, 21, 31, 30, 30, 30, 29, 29, 29, 27, 27, 26,
+        24, 24, 24, 23, 23, 22, 22, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 22,
+        22, 21, 21, 21, 31, 30, 30, 30, 29, 29, 28, 27, 26, 26, 24, 24, 23, 23,
+        23, 22, 22, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21,
+        30, 29, 29, 28, 28, 28, 28, 26, 26, 25, 23, 23, 23, 23, 23, 22, 22, 22,
+        22, 22, 22, 23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21, 28, 27, 27, 27,
+        26, 26, 26, 24, 24, 23, 22, 22, 22, 22, 22, 22, 21, 21, 22, 22, 22, 23,
+        23, 23, 22, 22, 22, 22, 22, 22, 21, 21, 28, 27, 27, 27, 26, 26, 26, 24,
+        24, 23, 22, 22, 22, 22, 22, 22, 21, 21, 22, 22, 22, 23, 23, 23, 22, 22,
+        22, 22, 22, 22, 21, 21, 27, 26, 26, 26, 25, 25, 25, 24, 23, 23, 22, 22,
+        22, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 21, 21, 21,
+        21, 21, 25, 24, 24, 24, 24, 24, 24, 23, 23, 23, 22, 22, 21, 21, 21, 21,
+        20, 20, 20, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 25, 24,
+        24, 24, 24, 24, 24, 23, 23, 23, 22, 22, 21, 21, 21, 21, 20, 20, 20, 21,
+        21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 23, 23, 23, 23, 23, 23,
+        23, 22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+        20, 20, 20, 20, 20, 20, 19, 19, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
+        21, 21, 21, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 20,
+        20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 21, 22, 22, 22,
+        22, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21, 20, 19, 19, 19, 19, 19, 19,
+        19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 21, 22, 22, 22, 22, 23, 23, 22,
+        22, 22, 22, 22, 21, 21, 21, 20, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 21, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
+        22, 21, 21, 20, 19, 19, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17, 17,
+        17, 17, 21, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 22, 21, 21, 20,
+        19, 19, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 21, 22,
+        22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 22, 21, 21, 20, 19, 19, 19, 18,
+        18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 16, 16, 20, 21, 21, 21, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17,
+        17, 17, 17, 16, 16, 16, 16, 16, 20, 21, 21, 21, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 20, 20, 20, 19, 19, 19, 18, 18, 17, 17, 17, 17, 17, 17, 16,
+        16, 16, 16, 16, 20, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 20,
+        20, 20, 19, 19, 19, 18, 18, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16,
+        20, 20, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20, 19, 19,
+        18, 18, 18, 17, 17, 17, 16, 16, 16, 16, 16, 15, 15, 15, 20, 20, 20, 21,
+        21, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20, 19, 19, 18, 18, 18, 17,
+        17, 17, 16, 16, 16, 16, 16, 15, 15, 15, 19, 20, 20, 20, 21, 21, 21, 21,
+        21, 21, 22, 22, 21, 20, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16,
+        16, 15, 15, 15, 15, 15, 19, 19, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21,
+        21, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 16, 16, 16, 16, 15, 15, 15,
+        14, 14, 19, 19, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 19,
+        19, 19, 18, 18, 18, 17, 17, 16, 16, 16, 16, 15, 15, 15, 14, 14,
         /* Size 4x8 */
-        65, 54, 43, 39, 64, 51, 45, 41, 52, 44, 45, 43, 46, 43, 40, 39, 44, 44,
-        37, 35, 44, 44, 34, 32, 42, 43, 34, 30, 39, 41, 32, 28,
+        33, 27, 22, 20, 33, 26, 22, 21, 28, 23, 22, 22, 24, 22, 20, 20, 22, 21,
+        19, 19, 22, 22, 19, 17, 21, 22, 19, 16, 20, 21, 18, 15,
         /* Size 8x4 */
-        65, 64, 52, 46, 44, 44, 42, 39, 54, 51, 44, 43, 44, 44, 43, 41, 43, 45,
-        45, 40, 37, 34, 34, 32, 39, 41, 43, 39, 35, 32, 30, 28,
+        33, 33, 28, 24, 22, 22, 21, 20, 27, 26, 23, 22, 21, 22, 22, 21, 22, 22,
+        22, 20, 19, 19, 19, 18, 20, 21, 22, 20, 19, 17, 16, 15,
         /* Size 8x16 */
-        64, 66, 55, 45, 42, 42, 39, 36, 65, 65, 53, 46, 44, 44, 41, 38, 67, 64,
-        51, 46, 45, 45, 43, 39, 62, 59, 48, 45, 44, 45, 43, 40, 59, 55, 46, 44,
-        44, 45, 43, 40, 55, 51, 44, 43, 44, 45, 44, 41, 49, 48, 43, 41, 41, 41,
-        41, 38, 42, 44, 43, 39, 39, 38, 38, 36, 42, 45, 44, 40, 38, 37, 36, 34,
-        42, 45, 44, 40, 38, 36, 35, 33, 42, 45, 45, 40, 37, 35, 33, 32, 41, 44,
-        44, 39, 37, 34, 32, 31, 39, 43, 43, 39, 36, 34, 31, 29, 38, 41, 42, 38,
-        35, 33, 30, 28, 37, 40, 41, 38, 35, 33, 29, 27, 36, 39, 41, 37, 34, 32,
-        29, 27,
+        32, 33, 29, 27, 21, 21, 20, 20, 33, 33, 28, 26, 22, 22, 21, 20, 34, 32,
+        27, 26, 22, 23, 22, 21, 33, 31, 27, 25, 22, 23, 22, 21, 31, 28, 25, 23,
+        22, 22, 22, 22, 28, 26, 23, 22, 22, 23, 22, 22, 26, 25, 22, 22, 21, 22,
+        22, 21, 24, 24, 22, 21, 20, 21, 20, 20, 21, 22, 21, 21, 19, 19, 19, 19,
+        21, 22, 22, 21, 19, 19, 19, 18, 21, 22, 22, 21, 19, 18, 18, 18, 21, 23,
+        23, 22, 19, 18, 17, 17, 20, 22, 22, 21, 19, 17, 17, 16, 20, 22, 22, 21,
+        19, 17, 17, 16, 20, 21, 22, 21, 19, 17, 16, 16, 19, 20, 21, 20, 19, 17,
+        16, 15,
         /* Size 16x8 */
-        64, 65, 67, 62, 59, 55, 49, 42, 42, 42, 42, 41, 39, 38, 37, 36, 66, 65,
-        64, 59, 55, 51, 48, 44, 45, 45, 45, 44, 43, 41, 40, 39, 55, 53, 51, 48,
-        46, 44, 43, 43, 44, 44, 45, 44, 43, 42, 41, 41, 45, 46, 46, 45, 44, 43,
-        41, 39, 40, 40, 40, 39, 39, 38, 38, 37, 42, 44, 45, 44, 44, 44, 41, 39,
-        38, 38, 37, 37, 36, 35, 35, 34, 42, 44, 45, 45, 45, 45, 41, 38, 37, 36,
-        35, 34, 34, 33, 33, 32, 39, 41, 43, 43, 43, 44, 41, 38, 36, 35, 33, 32,
-        31, 30, 29, 29, 36, 38, 39, 40, 40, 41, 38, 36, 34, 33, 32, 31, 29, 28,
-        27, 27,
+        32, 33, 34, 33, 31, 28, 26, 24, 21, 21, 21, 21, 20, 20, 20, 19, 33, 33,
+        32, 31, 28, 26, 25, 24, 22, 22, 22, 23, 22, 22, 21, 20, 29, 28, 27, 27,
+        25, 23, 22, 22, 21, 22, 22, 23, 22, 22, 22, 21, 27, 26, 26, 25, 23, 22,
+        22, 21, 21, 21, 21, 22, 21, 21, 21, 20, 21, 22, 22, 22, 22, 22, 21, 20,
+        19, 19, 19, 19, 19, 19, 19, 19, 21, 22, 23, 23, 22, 23, 22, 21, 19, 19,
+        18, 18, 17, 17, 17, 17, 20, 21, 22, 22, 22, 22, 22, 20, 19, 19, 18, 17,
+        17, 17, 16, 16, 20, 20, 21, 21, 22, 22, 21, 20, 19, 18, 18, 17, 16, 16,
+        16, 15,
         /* Size 16x32 */
-        64, 66, 66, 62, 55, 55, 45, 43, 42, 42, 42, 40, 39, 38, 36, 36, 65, 65,
-        65, 60, 54, 54, 46, 43, 43, 43, 43, 41, 41, 39, 37, 37, 65, 65, 65, 60,
-        53, 53, 46, 44, 44, 44, 44, 41, 41, 40, 38, 38, 66, 65, 64, 59, 53, 53,
-        46, 44, 44, 44, 44, 42, 42, 40, 38, 38, 67, 64, 64, 59, 51, 51, 46, 45,
-        45, 45, 45, 43, 43, 41, 39, 39, 67, 64, 64, 59, 51, 51, 46, 45, 45, 45,
-        45, 43, 43, 41, 39, 39, 62, 59, 59, 55, 48, 48, 45, 44, 44, 45, 45, 43,
-        43, 42, 40, 40, 61, 58, 57, 53, 48, 48, 45, 44, 44, 45, 45, 43, 43, 42,
-        40, 40, 59, 55, 55, 51, 46, 46, 44, 43, 44, 45, 45, 44, 43, 42, 40, 40,
-        55, 52, 51, 48, 44, 44, 43, 43, 44, 45, 45, 44, 44, 43, 41, 41, 55, 52,
-        51, 48, 44, 44, 43, 43, 44, 45, 45, 44, 44, 43, 41, 41, 50, 49, 48, 47,
-        43, 43, 42, 41, 42, 42, 42, 41, 41, 40, 39, 39, 49, 48, 48, 46, 43, 43,
-        41, 41, 41, 41, 41, 41, 41, 40, 38, 38, 46, 46, 46, 45, 43, 43, 41, 40,
-        40, 40, 40, 39, 39, 39, 38, 38, 42, 44, 44, 44, 43, 43, 39, 39, 39, 38,
-        38, 38, 38, 37, 36, 36, 42, 44, 44, 44, 43, 43, 39, 39, 39, 38, 38, 38,
-        38, 37, 36, 36, 42, 44, 45, 44, 44, 44, 40, 39, 38, 37, 37, 36, 36, 35,
-        34, 34, 42, 44, 45, 44, 44, 44, 40, 39, 38, 37, 37, 36, 36, 35, 34, 34,
-        42, 45, 45, 45, 44, 44, 40, 39, 38, 36, 36, 35, 35, 34, 33, 33, 42, 45,
-        45, 45, 45, 45, 40, 38, 37, 35, 35, 34, 33, 33, 32, 32, 42, 45, 45, 45,
-        45, 45, 40, 38, 37, 35, 35, 34, 33, 33, 32, 32, 41, 44, 44, 44, 44, 44,
-        39, 38, 37, 34, 34, 33, 32, 32, 31, 31, 41, 43, 44, 44, 44, 44, 39, 38,
-        37, 34, 34, 33, 32, 32, 31, 31, 40, 43, 44, 44, 44, 44, 39, 38, 36, 34,
-        34, 32, 32, 31, 30, 30, 39, 42, 43, 43, 43, 43, 39, 38, 36, 34, 34, 31,
-        31, 30, 29, 29, 39, 42, 43, 43, 43, 43, 39, 38, 36, 34, 34, 31, 31, 30,
-        29, 29, 38, 41, 41, 42, 42, 42, 38, 37, 35, 33, 33, 31, 30, 29, 28, 28,
-        38, 40, 41, 41, 42, 42, 38, 37, 35, 33, 33, 31, 30, 29, 28, 28, 37, 40,
-        40, 41, 41, 41, 38, 37, 35, 33, 33, 30, 29, 29, 27, 27, 36, 39, 39, 40,
-        41, 41, 37, 36, 34, 32, 32, 30, 29, 28, 27, 27, 36, 39, 39, 40, 41, 41,
-        37, 36, 34, 32, 32, 30, 29, 28, 27, 27, 35, 37, 38, 38, 39, 39, 36, 35,
-        34, 32, 32, 29, 28, 27, 26, 26,
+        32, 33, 33, 33, 29, 28, 27, 22, 21, 21, 21, 21, 20, 20, 20, 19, 33, 33,
+        33, 32, 28, 27, 26, 22, 22, 22, 21, 21, 21, 20, 20, 19, 33, 33, 33, 32,
+        28, 27, 26, 22, 22, 22, 22, 22, 21, 20, 20, 20, 33, 33, 33, 32, 28, 27,
+        26, 22, 22, 22, 22, 22, 21, 20, 20, 20, 34, 33, 32, 32, 27, 26, 26, 23,
+        22, 22, 23, 23, 22, 21, 21, 20, 34, 33, 32, 31, 27, 26, 25, 23, 22, 22,
+        23, 23, 22, 21, 21, 20, 33, 32, 31, 31, 27, 26, 25, 23, 22, 22, 23, 23,
+        22, 21, 21, 20, 31, 29, 29, 28, 25, 24, 24, 22, 22, 22, 23, 23, 22, 22,
+        22, 21, 31, 29, 28, 28, 25, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 21,
+        30, 28, 28, 28, 24, 23, 23, 22, 22, 22, 23, 23, 22, 22, 22, 21, 28, 26,
+        26, 25, 23, 22, 22, 22, 22, 22, 23, 23, 22, 22, 22, 21, 28, 26, 26, 25,
+        23, 22, 22, 22, 22, 22, 23, 23, 22, 22, 22, 21, 26, 26, 25, 24, 22, 22,
+        22, 21, 21, 21, 22, 22, 22, 21, 21, 20, 24, 24, 24, 24, 22, 22, 21, 20,
+        20, 20, 21, 21, 20, 20, 20, 20, 24, 24, 24, 24, 22, 22, 21, 20, 20, 20,
+        21, 21, 20, 20, 20, 20, 23, 23, 23, 23, 22, 22, 21, 20, 20, 20, 20, 20,
+        20, 20, 20, 19, 21, 22, 22, 22, 21, 21, 21, 20, 19, 19, 19, 19, 19, 19,
+        19, 19, 21, 22, 22, 22, 21, 21, 21, 20, 19, 19, 19, 19, 19, 19, 19, 19,
+        21, 22, 22, 22, 22, 22, 21, 20, 19, 19, 19, 19, 19, 18, 18, 18, 21, 22,
+        22, 22, 22, 22, 21, 20, 19, 19, 18, 18, 18, 18, 18, 17, 21, 22, 22, 22,
+        22, 22, 21, 20, 19, 19, 18, 18, 18, 18, 18, 17, 21, 22, 23, 23, 22, 22,
+        22, 20, 19, 19, 18, 18, 18, 17, 17, 17, 21, 22, 23, 23, 23, 22, 22, 20,
+        19, 19, 18, 18, 17, 17, 17, 17, 21, 22, 23, 23, 22, 22, 22, 20, 19, 19,
+        18, 18, 17, 17, 17, 16, 20, 22, 22, 22, 22, 22, 21, 19, 19, 19, 17, 17,
+        17, 16, 16, 16, 20, 21, 22, 22, 22, 22, 21, 19, 19, 19, 17, 17, 17, 16,
+        16, 16, 20, 21, 22, 22, 22, 22, 21, 19, 19, 19, 17, 17, 17, 16, 16, 16,
+        20, 21, 21, 21, 22, 22, 21, 19, 19, 18, 17, 17, 16, 16, 16, 15, 20, 21,
+        21, 21, 22, 22, 21, 19, 19, 18, 17, 17, 16, 16, 16, 15, 19, 20, 21, 21,
+        21, 21, 21, 19, 19, 18, 17, 17, 16, 15, 15, 15, 19, 20, 20, 20, 21, 21,
+        20, 19, 19, 18, 17, 17, 16, 15, 15, 14, 19, 20, 20, 20, 21, 21, 20, 19,
+        19, 18, 17, 17, 16, 15, 15, 14,
         /* Size 32x16 */
-        64, 65, 65, 66, 67, 67, 62, 61, 59, 55, 55, 50, 49, 46, 42, 42, 42, 42,
-        42, 42, 42, 41, 41, 40, 39, 39, 38, 38, 37, 36, 36, 35, 66, 65, 65, 65,
-        64, 64, 59, 58, 55, 52, 52, 49, 48, 46, 44, 44, 44, 44, 45, 45, 45, 44,
-        43, 43, 42, 42, 41, 40, 40, 39, 39, 37, 66, 65, 65, 64, 64, 64, 59, 57,
-        55, 51, 51, 48, 48, 46, 44, 44, 45, 45, 45, 45, 45, 44, 44, 44, 43, 43,
-        41, 41, 40, 39, 39, 38, 62, 60, 60, 59, 59, 59, 55, 53, 51, 48, 48, 47,
-        46, 45, 44, 44, 44, 44, 45, 45, 45, 44, 44, 44, 43, 43, 42, 41, 41, 40,
-        40, 38, 55, 54, 53, 53, 51, 51, 48, 48, 46, 44, 44, 43, 43, 43, 43, 43,
-        44, 44, 44, 45, 45, 44, 44, 44, 43, 43, 42, 42, 41, 41, 41, 39, 55, 54,
-        53, 53, 51, 51, 48, 48, 46, 44, 44, 43, 43, 43, 43, 43, 44, 44, 44, 45,
-        45, 44, 44, 44, 43, 43, 42, 42, 41, 41, 41, 39, 45, 46, 46, 46, 46, 46,
-        45, 45, 44, 43, 43, 42, 41, 41, 39, 39, 40, 40, 40, 40, 40, 39, 39, 39,
-        39, 39, 38, 38, 38, 37, 37, 36, 43, 43, 44, 44, 45, 45, 44, 44, 43, 43,
-        43, 41, 41, 40, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 38, 37, 37,
-        37, 36, 36, 35, 42, 43, 44, 44, 45, 45, 44, 44, 44, 44, 44, 42, 41, 40,
-        39, 39, 38, 38, 38, 37, 37, 37, 37, 36, 36, 36, 35, 35, 35, 34, 34, 34,
-        42, 43, 44, 44, 45, 45, 45, 45, 45, 45, 45, 42, 41, 40, 38, 38, 37, 37,
-        36, 35, 35, 34, 34, 34, 34, 34, 33, 33, 33, 32, 32, 32, 42, 43, 44, 44,
-        45, 45, 45, 45, 45, 45, 45, 42, 41, 40, 38, 38, 37, 37, 36, 35, 35, 34,
-        34, 34, 34, 34, 33, 33, 33, 32, 32, 32, 40, 41, 41, 42, 43, 43, 43, 43,
-        44, 44, 44, 41, 41, 39, 38, 38, 36, 36, 35, 34, 34, 33, 33, 32, 31, 31,
-        31, 31, 30, 30, 30, 29, 39, 41, 41, 42, 43, 43, 43, 43, 43, 44, 44, 41,
-        41, 39, 38, 38, 36, 36, 35, 33, 33, 32, 32, 32, 31, 31, 30, 30, 29, 29,
-        29, 28, 38, 39, 40, 40, 41, 41, 42, 42, 42, 43, 43, 40, 40, 39, 37, 37,
-        35, 35, 34, 33, 33, 32, 32, 31, 30, 30, 29, 29, 29, 28, 28, 27, 36, 37,
-        38, 38, 39, 39, 40, 40, 40, 41, 41, 39, 38, 38, 36, 36, 34, 34, 33, 32,
-        32, 31, 31, 30, 29, 29, 28, 28, 27, 27, 27, 26, 36, 37, 38, 38, 39, 39,
-        40, 40, 40, 41, 41, 39, 38, 38, 36, 36, 34, 34, 33, 32, 32, 31, 31, 30,
-        29, 29, 28, 28, 27, 27, 27, 26,
+        32, 33, 33, 33, 34, 34, 33, 31, 31, 30, 28, 28, 26, 24, 24, 23, 21, 21,
+        21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 19, 19, 19, 33, 33, 33, 33,
+        33, 33, 32, 29, 29, 28, 26, 26, 26, 24, 24, 23, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 21, 21, 21, 21, 20, 20, 20, 33, 33, 33, 33, 32, 32, 31, 29,
+        28, 28, 26, 26, 25, 24, 24, 23, 22, 22, 22, 22, 22, 23, 23, 23, 22, 22,
+        22, 21, 21, 21, 20, 20, 33, 32, 32, 32, 32, 31, 31, 28, 28, 28, 25, 25,
+        24, 24, 24, 23, 22, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 21, 21, 21,
+        20, 20, 29, 28, 28, 28, 27, 27, 27, 25, 25, 24, 23, 23, 22, 22, 22, 22,
+        21, 21, 22, 22, 22, 22, 23, 22, 22, 22, 22, 22, 22, 21, 21, 21, 28, 27,
+        27, 27, 26, 26, 26, 24, 24, 23, 22, 22, 22, 22, 22, 22, 21, 21, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 27, 26, 26, 26, 26, 25,
+        25, 24, 23, 23, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22,
+        21, 21, 21, 21, 21, 21, 20, 20, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22,
+        22, 22, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19,
+        19, 19, 19, 19, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20,
+        20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 21, 21, 22, 22,
+        23, 23, 23, 23, 22, 23, 23, 23, 22, 21, 21, 20, 19, 19, 19, 18, 18, 18,
+        18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 21, 21, 22, 22, 23, 23, 23, 23,
+        22, 23, 23, 23, 22, 21, 21, 20, 19, 19, 19, 18, 18, 18, 18, 18, 17, 17,
+        17, 17, 17, 17, 17, 17, 20, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 17, 16, 16, 16,
+        16, 16, 20, 20, 20, 20, 21, 21, 21, 22, 22, 22, 22, 22, 21, 20, 20, 20,
+        19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 16, 16, 15, 15, 15, 20, 20,
+        20, 20, 21, 21, 21, 22, 22, 22, 22, 22, 21, 20, 20, 20, 19, 19, 18, 18,
+        18, 17, 17, 17, 16, 16, 16, 16, 16, 15, 15, 15, 19, 19, 20, 20, 20, 20,
+        20, 21, 21, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 17, 17, 17, 17, 16,
+        16, 16, 16, 15, 15, 15, 14, 14,
         /* Size 4x16 */
-        66, 55, 42, 38, 65, 53, 44, 40, 64, 51, 45, 41, 59, 48, 45, 42, 55, 46,
-        45, 42, 52, 44, 45, 43, 48, 43, 41, 40, 44, 43, 38, 37, 44, 44, 37, 35,
-        45, 44, 36, 34, 45, 45, 35, 33, 43, 44, 34, 32, 42, 43, 34, 30, 41, 42,
-        33, 29, 40, 41, 33, 29, 39, 41, 32, 28,
+        33, 28, 21, 20, 33, 27, 22, 20, 33, 26, 22, 21, 32, 26, 22, 21, 29, 24,
+        22, 22, 26, 22, 22, 22, 26, 22, 21, 21, 24, 22, 20, 20, 22, 21, 19, 19,
+        22, 22, 19, 18, 22, 22, 19, 18, 22, 22, 19, 17, 22, 22, 19, 16, 21, 22,
+        19, 16, 21, 22, 18, 16, 20, 21, 18, 15,
         /* Size 16x4 */
-        66, 65, 64, 59, 55, 52, 48, 44, 44, 45, 45, 43, 42, 41, 40, 39, 55, 53,
-        51, 48, 46, 44, 43, 43, 44, 44, 45, 44, 43, 42, 41, 41, 42, 44, 45, 45,
-        45, 45, 41, 38, 37, 36, 35, 34, 34, 33, 33, 32, 38, 40, 41, 42, 42, 43,
-        40, 37, 35, 34, 33, 32, 30, 29, 29, 28,
+        33, 33, 33, 32, 29, 26, 26, 24, 22, 22, 22, 22, 22, 21, 21, 20, 28, 27,
+        26, 26, 24, 22, 22, 22, 21, 22, 22, 22, 22, 22, 22, 21, 21, 22, 22, 22,
+        22, 22, 21, 20, 19, 19, 19, 19, 19, 19, 18, 18, 20, 20, 21, 21, 22, 22,
+        21, 20, 19, 18, 18, 17, 16, 16, 16, 15,
         /* Size 8x32 */
-        64, 66, 55, 45, 42, 42, 39, 36, 65, 65, 54, 46, 43, 43, 41, 37, 65, 65,
-        53, 46, 44, 44, 41, 38, 66, 64, 53, 46, 44, 44, 42, 38, 67, 64, 51, 46,
-        45, 45, 43, 39, 67, 64, 51, 46, 45, 45, 43, 39, 62, 59, 48, 45, 44, 45,
-        43, 40, 61, 57, 48, 45, 44, 45, 43, 40, 59, 55, 46, 44, 44, 45, 43, 40,
-        55, 51, 44, 43, 44, 45, 44, 41, 55, 51, 44, 43, 44, 45, 44, 41, 50, 48,
-        43, 42, 42, 42, 41, 39, 49, 48, 43, 41, 41, 41, 41, 38, 46, 46, 43, 41,
-        40, 40, 39, 38, 42, 44, 43, 39, 39, 38, 38, 36, 42, 44, 43, 39, 39, 38,
-        38, 36, 42, 45, 44, 40, 38, 37, 36, 34, 42, 45, 44, 40, 38, 37, 36, 34,
-        42, 45, 44, 40, 38, 36, 35, 33, 42, 45, 45, 40, 37, 35, 33, 32, 42, 45,
-        45, 40, 37, 35, 33, 32, 41, 44, 44, 39, 37, 34, 32, 31, 41, 44, 44, 39,
-        37, 34, 32, 31, 40, 44, 44, 39, 36, 34, 32, 30, 39, 43, 43, 39, 36, 34,
-        31, 29, 39, 43, 43, 39, 36, 34, 31, 29, 38, 41, 42, 38, 35, 33, 30, 28,
-        38, 41, 42, 38, 35, 33, 30, 28, 37, 40, 41, 38, 35, 33, 29, 27, 36, 39,
-        41, 37, 34, 32, 29, 27, 36, 39, 41, 37, 34, 32, 29, 27, 35, 38, 39, 36,
-        34, 32, 28, 26,
+        32, 33, 29, 27, 21, 21, 20, 20, 33, 33, 28, 26, 22, 21, 21, 20, 33, 33,
+        28, 26, 22, 22, 21, 20, 33, 33, 28, 26, 22, 22, 21, 20, 34, 32, 27, 26,
+        22, 23, 22, 21, 34, 32, 27, 25, 22, 23, 22, 21, 33, 31, 27, 25, 22, 23,
+        22, 21, 31, 29, 25, 24, 22, 23, 22, 22, 31, 28, 25, 23, 22, 22, 22, 22,
+        30, 28, 24, 23, 22, 23, 22, 22, 28, 26, 23, 22, 22, 23, 22, 22, 28, 26,
+        23, 22, 22, 23, 22, 22, 26, 25, 22, 22, 21, 22, 22, 21, 24, 24, 22, 21,
+        20, 21, 20, 20, 24, 24, 22, 21, 20, 21, 20, 20, 23, 23, 22, 21, 20, 20,
+        20, 20, 21, 22, 21, 21, 19, 19, 19, 19, 21, 22, 21, 21, 19, 19, 19, 19,
+        21, 22, 22, 21, 19, 19, 19, 18, 21, 22, 22, 21, 19, 18, 18, 18, 21, 22,
+        22, 21, 19, 18, 18, 18, 21, 23, 22, 22, 19, 18, 18, 17, 21, 23, 23, 22,
+        19, 18, 17, 17, 21, 23, 22, 22, 19, 18, 17, 17, 20, 22, 22, 21, 19, 17,
+        17, 16, 20, 22, 22, 21, 19, 17, 17, 16, 20, 22, 22, 21, 19, 17, 17, 16,
+        20, 21, 22, 21, 19, 17, 16, 16, 20, 21, 22, 21, 19, 17, 16, 16, 19, 21,
+        21, 21, 19, 17, 16, 15, 19, 20, 21, 20, 19, 17, 16, 15, 19, 20, 21, 20,
+        19, 17, 16, 15,
         /* Size 32x8 */
-        64, 65, 65, 66, 67, 67, 62, 61, 59, 55, 55, 50, 49, 46, 42, 42, 42, 42,
-        42, 42, 42, 41, 41, 40, 39, 39, 38, 38, 37, 36, 36, 35, 66, 65, 65, 64,
-        64, 64, 59, 57, 55, 51, 51, 48, 48, 46, 44, 44, 45, 45, 45, 45, 45, 44,
-        44, 44, 43, 43, 41, 41, 40, 39, 39, 38, 55, 54, 53, 53, 51, 51, 48, 48,
-        46, 44, 44, 43, 43, 43, 43, 43, 44, 44, 44, 45, 45, 44, 44, 44, 43, 43,
-        42, 42, 41, 41, 41, 39, 45, 46, 46, 46, 46, 46, 45, 45, 44, 43, 43, 42,
-        41, 41, 39, 39, 40, 40, 40, 40, 40, 39, 39, 39, 39, 39, 38, 38, 38, 37,
-        37, 36, 42, 43, 44, 44, 45, 45, 44, 44, 44, 44, 44, 42, 41, 40, 39, 39,
-        38, 38, 38, 37, 37, 37, 37, 36, 36, 36, 35, 35, 35, 34, 34, 34, 42, 43,
-        44, 44, 45, 45, 45, 45, 45, 45, 45, 42, 41, 40, 38, 38, 37, 37, 36, 35,
-        35, 34, 34, 34, 34, 34, 33, 33, 33, 32, 32, 32, 39, 41, 41, 42, 43, 43,
-        43, 43, 43, 44, 44, 41, 41, 39, 38, 38, 36, 36, 35, 33, 33, 32, 32, 32,
-        31, 31, 30, 30, 29, 29, 29, 28, 36, 37, 38, 38, 39, 39, 40, 40, 40, 41,
-        41, 39, 38, 38, 36, 36, 34, 34, 33, 32, 32, 31, 31, 30, 29, 29, 28, 28,
-        27, 27, 27, 26 },
+        32, 33, 33, 33, 34, 34, 33, 31, 31, 30, 28, 28, 26, 24, 24, 23, 21, 21,
+        21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 19, 19, 19, 33, 33, 33, 33,
+        32, 32, 31, 29, 28, 28, 26, 26, 25, 24, 24, 23, 22, 22, 22, 22, 22, 23,
+        23, 23, 22, 22, 22, 21, 21, 21, 20, 20, 29, 28, 28, 28, 27, 27, 27, 25,
+        25, 24, 23, 23, 22, 22, 22, 22, 21, 21, 22, 22, 22, 22, 23, 22, 22, 22,
+        22, 22, 22, 21, 21, 21, 27, 26, 26, 26, 26, 25, 25, 24, 23, 23, 22, 22,
+        22, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 21, 21, 21, 21, 21, 21,
+        20, 20, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 21, 21,
+        22, 22, 23, 23, 23, 23, 22, 23, 23, 23, 22, 21, 21, 20, 19, 19, 19, 18,
+        18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 20, 21, 21, 21, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17,
+        17, 17, 17, 16, 16, 16, 16, 16, 20, 20, 20, 20, 21, 21, 21, 22, 22, 22,
+        22, 22, 21, 20, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 16,
+        16, 15, 15, 15 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        62, 48, 48, 32,
+        32, 27, 27, 19,
 #endif
         /* Size 4x4 */
-        64, 63, 53, 40, 63, 58, 51, 42, 53, 51, 38, 32, 40, 42, 32, 25,
+        32, 32, 29, 24, 32, 30, 28, 24, 29, 28, 21, 19, 24, 24, 19, 16,
         /* Size 8x8 */
-        65, 64, 64, 60, 58, 49, 44, 38, 64, 63, 63, 61, 59, 51, 46, 41, 64, 63,
-        60, 58, 55, 49, 45, 40, 60, 61, 58, 52, 48, 44, 40, 37, 58, 59, 55, 48,
-        42, 39, 36, 34, 49, 51, 49, 44, 39, 34, 32, 29, 44, 46, 45, 40, 36, 32,
-        29, 26, 38, 41, 40, 37, 34, 29, 26, 24,
+        33, 33, 32, 32, 30, 28, 24, 22, 33, 32, 32, 32, 30, 28, 25, 23, 32, 32,
+        31, 30, 29, 27, 24, 23, 32, 32, 30, 29, 28, 26, 24, 22, 30, 30, 29, 28,
+        25, 23, 21, 20, 28, 28, 27, 26, 23, 20, 18, 17, 24, 25, 24, 24, 21, 18,
+        16, 15, 22, 23, 23, 22, 20, 17, 15, 14,
         /* Size 16x16 */
-        64, 65, 65, 65, 65, 64, 63, 60, 57, 54, 52, 47, 43, 41, 38, 35, 65, 64,
-        64, 64, 64, 63, 62, 60, 59, 55, 53, 48, 45, 43, 40, 36, 65, 64, 64, 63,
-        63, 63, 62, 61, 59, 56, 55, 50, 47, 45, 41, 38, 65, 64, 63, 63, 63, 62,
-        61, 60, 59, 56, 54, 50, 47, 45, 41, 38, 65, 64, 63, 63, 61, 60, 59, 58,
-        56, 54, 53, 49, 46, 44, 41, 38, 64, 63, 63, 62, 60, 58, 57, 55, 53, 52,
-        51, 48, 46, 44, 41, 38, 63, 62, 62, 61, 59, 57, 56, 54, 51, 50, 49, 46,
-        44, 42, 40, 37, 60, 60, 61, 60, 58, 55, 54, 52, 48, 47, 46, 43, 41, 40,
-        38, 35, 57, 59, 59, 59, 56, 53, 51, 48, 42, 41, 41, 38, 37, 36, 34, 32,
-        54, 55, 56, 56, 54, 52, 50, 47, 41, 40, 39, 37, 35, 34, 33, 31, 52, 53,
-        55, 54, 53, 51, 49, 46, 41, 39, 38, 35, 34, 33, 32, 30, 47, 48, 50, 50,
-        49, 48, 46, 43, 38, 37, 35, 32, 31, 30, 29, 27, 43, 45, 47, 47, 46, 46,
-        44, 41, 37, 35, 34, 31, 29, 29, 27, 26, 41, 43, 45, 45, 44, 44, 42, 40,
-        36, 34, 33, 30, 29, 28, 26, 25, 38, 40, 41, 41, 41, 41, 40, 38, 34, 33,
-        32, 29, 27, 26, 25, 24, 35, 36, 38, 38, 38, 38, 37, 35, 32, 31, 30, 27,
-        26, 25, 24, 22,
+        32, 33, 33, 33, 33, 33, 32, 32, 30, 29, 28, 26, 25, 23, 22, 21, 33, 32,
+        32, 32, 32, 32, 32, 31, 30, 29, 29, 27, 26, 24, 23, 22, 33, 32, 32, 32,
+        32, 32, 32, 31, 30, 30, 29, 27, 26, 24, 23, 23, 33, 32, 32, 32, 32, 32,
+        32, 31, 31, 30, 30, 28, 27, 25, 23, 23, 33, 32, 32, 32, 31, 31, 31, 30,
+        29, 28, 28, 26, 26, 24, 23, 23, 33, 32, 32, 32, 31, 31, 30, 30, 29, 28,
+        28, 26, 26, 24, 23, 23, 32, 32, 32, 32, 31, 30, 29, 28, 28, 27, 27, 26,
+        25, 24, 23, 22, 32, 31, 31, 31, 30, 30, 28, 28, 27, 26, 26, 24, 24, 23,
+        22, 22, 30, 30, 30, 31, 29, 29, 28, 27, 26, 24, 24, 23, 22, 22, 20, 20,
+        29, 29, 30, 30, 28, 28, 27, 26, 24, 22, 22, 21, 20, 20, 19, 19, 28, 29,
+        29, 30, 28, 28, 27, 26, 24, 22, 21, 20, 20, 19, 18, 18, 26, 27, 27, 28,
+        26, 26, 26, 24, 23, 21, 20, 19, 19, 18, 17, 17, 25, 26, 26, 27, 26, 26,
+        25, 24, 22, 20, 20, 19, 18, 17, 17, 16, 23, 24, 24, 25, 24, 24, 24, 23,
+        22, 20, 19, 18, 17, 16, 16, 15, 22, 23, 23, 23, 23, 23, 23, 22, 20, 19,
+        18, 17, 17, 16, 15, 15, 21, 22, 23, 23, 23, 23, 22, 22, 20, 19, 18, 17,
+        16, 15, 15, 14,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 63, 60, 60, 59, 57, 57,
-        54, 52, 52, 48, 47, 46, 43, 42, 41, 38, 38, 37, 35, 35, 65, 65, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64, 62, 60, 60, 59, 58, 58, 55, 53, 53, 49,
-        48, 47, 45, 44, 43, 40, 39, 38, 36, 36, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 62, 60, 60, 59, 59, 59, 55, 53, 53, 50, 48, 48, 45, 44,
-        43, 40, 40, 39, 36, 36, 65, 65, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63,
-        62, 60, 60, 59, 59, 59, 55, 53, 53, 50, 49, 48, 45, 44, 44, 40, 40, 39,
-        37, 37, 65, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 62, 61, 61, 60,
-        59, 59, 56, 55, 55, 51, 50, 49, 47, 46, 45, 41, 41, 40, 38, 38, 65, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 61, 60, 59, 59, 57, 55,
-        55, 51, 50, 50, 47, 46, 45, 42, 41, 41, 38, 38, 65, 64, 64, 64, 63, 63,
-        63, 63, 63, 62, 62, 62, 61, 60, 60, 59, 59, 59, 56, 54, 54, 51, 50, 49,
-        47, 46, 45, 42, 41, 41, 38, 38, 65, 64, 64, 64, 63, 63, 63, 62, 62, 61,
-        60, 60, 59, 59, 59, 58, 56, 56, 54, 53, 53, 50, 49, 48, 46, 45, 44, 41,
-        41, 40, 38, 38, 65, 64, 64, 64, 63, 63, 63, 62, 61, 61, 60, 60, 59, 58,
-        58, 57, 56, 56, 54, 53, 53, 50, 49, 48, 46, 45, 44, 41, 41, 40, 38, 38,
-        64, 64, 64, 63, 63, 63, 62, 61, 61, 60, 59, 59, 59, 58, 58, 56, 55, 55,
-        53, 52, 52, 49, 49, 48, 46, 45, 44, 41, 41, 40, 38, 38, 64, 64, 63, 63,
-        63, 63, 62, 60, 60, 59, 58, 58, 57, 55, 55, 55, 53, 53, 52, 51, 51, 49,
-        48, 48, 46, 45, 44, 42, 41, 41, 38, 38, 64, 64, 63, 63, 63, 63, 62, 60,
-        60, 59, 58, 58, 57, 55, 55, 55, 53, 53, 52, 51, 51, 49, 48, 48, 46, 45,
-        44, 42, 41, 41, 38, 38, 63, 62, 62, 62, 62, 62, 61, 59, 59, 59, 57, 57,
-        56, 54, 54, 53, 51, 51, 50, 49, 49, 47, 46, 46, 44, 43, 42, 40, 40, 39,
-        37, 37, 60, 60, 60, 60, 61, 61, 60, 59, 58, 58, 55, 55, 54, 52, 52, 50,
-        48, 48, 47, 46, 46, 44, 43, 43, 41, 40, 40, 38, 38, 37, 35, 35, 60, 60,
-        60, 60, 61, 61, 60, 59, 58, 58, 55, 55, 54, 52, 52, 50, 48, 48, 47, 46,
-        46, 44, 43, 43, 41, 40, 40, 38, 38, 37, 35, 35, 59, 59, 59, 59, 60, 60,
-        59, 58, 57, 56, 55, 55, 53, 50, 50, 48, 45, 45, 44, 43, 43, 41, 41, 40,
-        39, 38, 38, 36, 36, 35, 34, 34, 57, 58, 59, 59, 59, 59, 59, 56, 56, 55,
-        53, 53, 51, 48, 48, 45, 42, 42, 41, 41, 41, 39, 38, 38, 37, 36, 36, 34,
-        34, 34, 32, 32, 57, 58, 59, 59, 59, 59, 59, 56, 56, 55, 53, 53, 51, 48,
-        48, 45, 42, 42, 41, 41, 41, 39, 38, 38, 37, 36, 36, 34, 34, 34, 32, 32,
-        54, 55, 55, 55, 56, 57, 56, 54, 54, 53, 52, 52, 50, 47, 47, 44, 41, 41,
-        40, 39, 39, 37, 37, 36, 35, 34, 34, 33, 33, 32, 31, 31, 52, 53, 53, 53,
-        55, 55, 54, 53, 53, 52, 51, 51, 49, 46, 46, 43, 41, 41, 39, 38, 38, 36,
-        35, 35, 34, 34, 33, 32, 32, 31, 30, 30, 52, 53, 53, 53, 55, 55, 54, 53,
-        53, 52, 51, 51, 49, 46, 46, 43, 41, 41, 39, 38, 38, 36, 35, 35, 34, 34,
-        33, 32, 32, 31, 30, 30, 48, 49, 50, 50, 51, 51, 51, 50, 50, 49, 49, 49,
-        47, 44, 44, 41, 39, 39, 37, 36, 36, 34, 33, 33, 32, 32, 31, 30, 29, 29,
-        28, 28, 47, 48, 48, 49, 50, 50, 50, 49, 49, 49, 48, 48, 46, 43, 43, 41,
-        38, 38, 37, 35, 35, 33, 32, 32, 31, 31, 30, 29, 29, 28, 27, 27, 46, 47,
-        48, 48, 49, 50, 49, 48, 48, 48, 48, 48, 46, 43, 43, 40, 38, 38, 36, 35,
-        35, 33, 32, 32, 31, 30, 30, 29, 28, 28, 27, 27, 43, 45, 45, 45, 47, 47,
-        47, 46, 46, 46, 46, 46, 44, 41, 41, 39, 37, 37, 35, 34, 34, 32, 31, 31,
-        29, 29, 29, 27, 27, 27, 26, 26, 42, 44, 44, 44, 46, 46, 46, 45, 45, 45,
-        45, 45, 43, 40, 40, 38, 36, 36, 34, 34, 34, 32, 31, 30, 29, 29, 28, 27,
-        27, 26, 25, 25, 41, 43, 43, 44, 45, 45, 45, 44, 44, 44, 44, 44, 42, 40,
-        40, 38, 36, 36, 34, 33, 33, 31, 30, 30, 29, 28, 28, 27, 26, 26, 25, 25,
-        38, 40, 40, 40, 41, 42, 42, 41, 41, 41, 42, 42, 40, 38, 38, 36, 34, 34,
-        33, 32, 32, 30, 29, 29, 27, 27, 27, 25, 25, 25, 24, 24, 38, 39, 40, 40,
-        41, 41, 41, 41, 41, 41, 41, 41, 40, 38, 38, 36, 34, 34, 33, 32, 32, 29,
-        29, 28, 27, 27, 26, 25, 25, 25, 24, 24, 37, 38, 39, 39, 40, 41, 41, 40,
-        40, 40, 41, 41, 39, 37, 37, 35, 34, 34, 32, 31, 31, 29, 28, 28, 27, 26,
-        26, 25, 25, 24, 23, 23, 35, 36, 36, 37, 38, 38, 38, 38, 38, 38, 38, 38,
-        37, 35, 35, 34, 32, 32, 31, 30, 30, 28, 27, 27, 26, 25, 25, 24, 24, 23,
-        22, 22, 35, 36, 36, 37, 38, 38, 38, 38, 38, 38, 38, 38, 37, 35, 35, 34,
-        32, 32, 31, 30, 30, 28, 27, 27, 26, 25, 25, 24, 24, 23, 22, 22,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 30, 30, 30,
+        29, 28, 28, 27, 26, 26, 25, 23, 23, 23, 22, 21, 21, 20, 33, 33, 33, 33,
+        33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 30, 29, 29, 29, 28,
+        26, 26, 26, 24, 24, 23, 22, 22, 22, 20, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 30, 30, 30, 29, 29, 29, 28, 27, 27, 26, 24,
+        24, 24, 23, 22, 22, 21, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 30, 30, 30, 29, 29, 29, 28, 27, 27, 26, 24, 24, 24, 23, 22,
+        22, 21, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30,
+        30, 30, 30, 29, 29, 28, 27, 27, 26, 24, 24, 24, 23, 23, 23, 21, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30,
+        30, 28, 28, 28, 27, 25, 25, 25, 23, 23, 23, 22, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 28, 28, 28,
+        27, 25, 25, 25, 23, 23, 23, 22, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 31, 31, 30, 30, 30, 30, 29, 29, 28, 27, 27, 26, 25, 25, 24,
+        23, 23, 23, 22, 33, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
+        30, 29, 29, 29, 28, 28, 28, 28, 26, 26, 26, 24, 24, 24, 23, 23, 23, 21,
+        33, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 29, 29, 29,
+        28, 28, 28, 27, 26, 26, 26, 24, 24, 24, 23, 23, 23, 21, 33, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 29, 29, 29, 28, 28, 28, 27,
+        26, 26, 26, 24, 24, 24, 23, 23, 23, 21, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 31, 31, 30, 29, 29, 29, 28, 28, 28, 28, 28, 28, 26, 26, 26, 25, 24,
+        24, 24, 23, 23, 23, 21, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 29,
+        29, 29, 28, 28, 28, 28, 27, 27, 27, 26, 26, 26, 25, 24, 24, 24, 23, 22,
+        22, 21, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 29, 29, 29, 28, 28,
+        28, 28, 27, 27, 27, 26, 26, 26, 25, 24, 24, 24, 23, 22, 22, 21, 32, 31,
+        31, 31, 31, 31, 31, 31, 30, 30, 30, 29, 28, 28, 28, 27, 27, 27, 26, 26,
+        26, 25, 24, 24, 24, 23, 23, 23, 22, 22, 22, 20, 30, 30, 30, 30, 30, 31,
+        31, 30, 29, 29, 29, 28, 28, 28, 27, 26, 26, 26, 24, 24, 24, 23, 23, 23,
+        22, 22, 22, 21, 20, 20, 20, 19, 30, 30, 30, 30, 30, 31, 31, 30, 29, 29,
+        29, 28, 28, 28, 27, 26, 26, 26, 24, 24, 24, 23, 23, 23, 22, 22, 22, 21,
+        20, 20, 20, 19, 30, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 28, 28, 28,
+        27, 26, 26, 25, 24, 23, 23, 23, 22, 22, 22, 21, 21, 21, 20, 20, 20, 19,
+        29, 29, 29, 29, 30, 30, 30, 30, 28, 28, 28, 28, 27, 27, 26, 24, 24, 24,
+        22, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 19, 18, 28, 29, 29, 29,
+        29, 30, 30, 29, 28, 28, 28, 28, 27, 27, 26, 24, 24, 23, 22, 21, 21, 20,
+        20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 28, 29, 29, 29, 29, 30, 30, 29,
+        28, 28, 28, 28, 27, 27, 26, 24, 24, 23, 22, 21, 21, 20, 20, 20, 20, 19,
+        19, 19, 18, 18, 18, 18, 27, 28, 28, 28, 28, 28, 28, 28, 28, 27, 27, 26,
+        26, 26, 25, 23, 23, 23, 21, 20, 20, 20, 20, 20, 19, 18, 18, 18, 18, 17,
+        17, 17, 26, 26, 27, 27, 27, 28, 28, 27, 26, 26, 26, 26, 26, 26, 24, 23,
+        23, 22, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 26, 26,
+        27, 27, 27, 28, 28, 27, 26, 26, 26, 26, 26, 26, 24, 23, 23, 22, 21, 20,
+        20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 25, 26, 26, 26, 26, 27,
+        27, 26, 26, 26, 26, 25, 25, 25, 24, 22, 22, 22, 20, 20, 20, 19, 19, 19,
+        18, 17, 17, 17, 17, 16, 16, 16, 23, 24, 24, 24, 24, 25, 25, 25, 24, 24,
+        24, 24, 24, 24, 23, 22, 22, 21, 20, 19, 19, 18, 18, 18, 17, 16, 16, 16,
+        16, 15, 15, 15, 23, 24, 24, 24, 24, 25, 25, 25, 24, 24, 24, 24, 24, 24,
+        23, 22, 22, 21, 20, 19, 19, 18, 18, 18, 17, 16, 16, 16, 16, 15, 15, 15,
+        23, 23, 24, 24, 24, 25, 25, 24, 24, 24, 24, 24, 24, 24, 23, 21, 21, 21,
+        19, 19, 19, 18, 18, 18, 17, 16, 16, 16, 15, 15, 15, 15, 22, 22, 23, 23,
+        23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 22, 20, 20, 20, 19, 18, 18, 18,
+        17, 17, 17, 16, 16, 15, 15, 15, 15, 14, 21, 22, 22, 22, 23, 23, 23, 23,
+        23, 23, 23, 23, 22, 22, 22, 20, 20, 20, 19, 18, 18, 17, 17, 17, 16, 15,
+        15, 15, 15, 14, 14, 14, 21, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
+        22, 22, 22, 20, 20, 20, 19, 18, 18, 17, 17, 17, 16, 15, 15, 15, 15, 14,
+        14, 14, 20, 20, 21, 21, 21, 22, 22, 22, 21, 21, 21, 21, 21, 21, 20, 19,
+        19, 19, 18, 18, 18, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14, 13,
         /* Size 4x8 */
-        64, 63, 55, 39, 64, 62, 56, 41, 63, 59, 53, 41, 60, 55, 47, 38, 59, 53,
-        41, 34, 51, 48, 37, 29, 45, 44, 34, 27, 39, 40, 32, 25,
+        33, 32, 29, 24, 32, 31, 30, 25, 32, 30, 28, 24, 32, 29, 27, 24, 30, 28,
+        24, 21, 28, 26, 21, 18, 24, 24, 19, 16, 22, 22, 18, 15,
         /* Size 8x4 */
-        64, 64, 63, 60, 59, 51, 45, 39, 63, 62, 59, 55, 53, 48, 44, 40, 55, 56,
-        53, 47, 41, 37, 34, 32, 39, 41, 41, 38, 34, 29, 27, 25,
+        33, 32, 32, 32, 30, 28, 24, 22, 32, 31, 30, 29, 28, 26, 24, 22, 29, 30,
+        28, 27, 24, 21, 19, 18, 24, 25, 24, 24, 21, 18, 16, 15,
         /* Size 8x16 */
-        64, 65, 64, 63, 57, 47, 43, 38, 65, 64, 63, 62, 58, 48, 45, 40, 65, 63,
-        63, 62, 59, 50, 47, 41, 65, 63, 62, 61, 59, 50, 47, 41, 64, 63, 60, 59,
-        56, 49, 46, 41, 64, 62, 59, 57, 53, 48, 46, 41, 63, 62, 58, 56, 51, 46,
-        44, 40, 60, 60, 57, 54, 48, 43, 41, 38, 57, 59, 55, 51, 43, 38, 37, 34,
-        54, 56, 53, 49, 41, 37, 35, 33, 52, 55, 51, 48, 41, 35, 34, 32, 47, 50,
-        48, 46, 38, 33, 31, 29, 44, 47, 45, 43, 37, 31, 29, 27, 42, 45, 44, 42,
-        36, 30, 29, 26, 38, 41, 41, 40, 34, 29, 27, 25, 35, 38, 38, 37, 32, 27,
-        26, 24,
+        32, 33, 33, 32, 29, 28, 23, 22, 33, 32, 32, 32, 29, 29, 24, 23, 33, 32,
+        32, 32, 30, 29, 25, 23, 33, 32, 32, 31, 30, 30, 25, 23, 33, 32, 31, 30,
+        29, 28, 24, 23, 32, 32, 31, 30, 28, 28, 24, 23, 32, 31, 30, 29, 28, 27,
+        24, 23, 32, 31, 30, 28, 26, 26, 23, 22, 30, 30, 29, 28, 25, 24, 21, 20,
+        29, 30, 28, 27, 23, 22, 20, 19, 28, 30, 28, 27, 22, 21, 19, 18, 26, 28,
+        26, 26, 21, 20, 18, 17, 25, 26, 26, 25, 21, 20, 17, 17, 23, 25, 24, 24,
+        20, 19, 16, 16, 22, 23, 23, 23, 19, 18, 16, 15, 21, 23, 23, 22, 19, 18,
+        15, 15,
         /* Size 16x8 */
-        64, 65, 65, 65, 64, 64, 63, 60, 57, 54, 52, 47, 44, 42, 38, 35, 65, 64,
-        63, 63, 63, 62, 62, 60, 59, 56, 55, 50, 47, 45, 41, 38, 64, 63, 63, 62,
-        60, 59, 58, 57, 55, 53, 51, 48, 45, 44, 41, 38, 63, 62, 62, 61, 59, 57,
-        56, 54, 51, 49, 48, 46, 43, 42, 40, 37, 57, 58, 59, 59, 56, 53, 51, 48,
-        43, 41, 41, 38, 37, 36, 34, 32, 47, 48, 50, 50, 49, 48, 46, 43, 38, 37,
-        35, 33, 31, 30, 29, 27, 43, 45, 47, 47, 46, 46, 44, 41, 37, 35, 34, 31,
-        29, 29, 27, 26, 38, 40, 41, 41, 41, 41, 40, 38, 34, 33, 32, 29, 27, 26,
-        25, 24,
+        32, 33, 33, 33, 33, 32, 32, 32, 30, 29, 28, 26, 25, 23, 22, 21, 33, 32,
+        32, 32, 32, 32, 31, 31, 30, 30, 30, 28, 26, 25, 23, 23, 33, 32, 32, 32,
+        31, 31, 30, 30, 29, 28, 28, 26, 26, 24, 23, 23, 32, 32, 32, 31, 30, 30,
+        29, 28, 28, 27, 27, 26, 25, 24, 23, 22, 29, 29, 30, 30, 29, 28, 28, 26,
+        25, 23, 22, 21, 21, 20, 19, 19, 28, 29, 29, 30, 28, 28, 27, 26, 24, 22,
+        21, 20, 20, 19, 18, 18, 23, 24, 25, 25, 24, 24, 24, 23, 21, 20, 19, 18,
+        17, 16, 16, 15, 22, 23, 23, 23, 23, 23, 23, 22, 20, 19, 18, 17, 17, 16,
+        15, 15,
         /* Size 16x32 */
-        64, 65, 65, 65, 64, 64, 63, 58, 57, 54, 47, 47, 43, 38, 38, 35, 65, 64,
-        64, 64, 64, 63, 62, 59, 58, 55, 48, 48, 45, 39, 39, 36, 65, 64, 64, 64,
-        63, 63, 62, 59, 58, 55, 48, 48, 45, 40, 40, 36, 65, 64, 64, 64, 63, 63,
-        62, 59, 58, 55, 49, 49, 45, 40, 40, 37, 65, 64, 63, 63, 63, 63, 62, 59,
-        59, 56, 50, 50, 47, 41, 41, 38, 65, 64, 63, 63, 63, 62, 62, 59, 59, 56,
-        50, 50, 47, 41, 41, 38, 65, 64, 63, 63, 62, 62, 61, 59, 59, 56, 50, 50,
-        47, 41, 41, 38, 64, 63, 63, 63, 61, 60, 59, 57, 56, 54, 49, 49, 46, 41,
-        41, 38, 64, 63, 63, 62, 60, 60, 59, 56, 56, 54, 49, 49, 46, 41, 41, 38,
-        64, 63, 63, 62, 60, 59, 59, 55, 55, 53, 48, 48, 46, 41, 41, 38, 64, 63,
-        62, 62, 59, 58, 57, 54, 53, 52, 48, 48, 46, 41, 41, 38, 64, 63, 62, 62,
-        59, 58, 57, 54, 53, 52, 48, 48, 46, 41, 41, 38, 63, 62, 62, 61, 58, 57,
-        56, 52, 51, 49, 46, 46, 44, 40, 40, 37, 60, 60, 60, 60, 57, 55, 54, 49,
-        48, 47, 43, 43, 41, 38, 38, 35, 60, 60, 60, 60, 57, 55, 54, 49, 48, 47,
-        43, 43, 41, 38, 38, 35, 59, 59, 59, 59, 55, 55, 53, 46, 46, 44, 41, 41,
-        39, 36, 36, 34, 57, 59, 59, 59, 55, 53, 51, 44, 43, 41, 38, 38, 37, 34,
-        34, 32, 57, 59, 59, 59, 55, 53, 51, 44, 43, 41, 38, 38, 37, 34, 34, 32,
-        54, 55, 56, 55, 53, 51, 49, 42, 41, 40, 37, 37, 35, 33, 33, 31, 52, 54,
-        55, 54, 51, 51, 48, 42, 41, 39, 35, 35, 34, 32, 32, 30, 52, 54, 55, 54,
-        51, 51, 48, 42, 41, 39, 35, 35, 34, 32, 32, 30, 48, 51, 51, 51, 49, 48,
-        47, 40, 39, 37, 33, 33, 32, 29, 29, 28, 47, 49, 50, 49, 48, 48, 46, 39,
-        38, 37, 33, 33, 31, 29, 29, 27, 47, 48, 49, 49, 48, 47, 46, 39, 38, 36,
-        32, 32, 31, 28, 28, 27, 44, 46, 47, 46, 45, 45, 43, 38, 37, 35, 31, 31,
-        29, 27, 27, 26, 43, 45, 46, 46, 45, 44, 43, 37, 36, 34, 31, 31, 29, 27,
-        27, 25, 42, 44, 45, 45, 44, 44, 42, 37, 36, 34, 30, 30, 29, 26, 26, 25,
-        39, 41, 42, 42, 41, 41, 40, 35, 34, 33, 29, 29, 27, 25, 25, 24, 38, 40,
-        41, 41, 41, 41, 40, 35, 34, 33, 29, 29, 27, 25, 25, 24, 37, 39, 40, 40,
-        40, 40, 39, 34, 34, 32, 28, 28, 27, 25, 25, 23, 35, 37, 38, 38, 38, 38,
-        37, 33, 32, 31, 27, 27, 26, 24, 24, 22, 35, 37, 38, 38, 38, 38, 37, 33,
-        32, 31, 27, 27, 26, 24, 24, 22,
+        32, 33, 33, 33, 33, 32, 32, 32, 29, 28, 28, 26, 23, 23, 22, 19, 33, 33,
+        32, 32, 32, 32, 32, 31, 29, 29, 29, 26, 24, 24, 22, 20, 33, 32, 32, 32,
+        32, 32, 32, 31, 29, 29, 29, 26, 24, 24, 23, 20, 33, 32, 32, 32, 32, 32,
+        32, 31, 29, 29, 29, 26, 24, 24, 23, 20, 33, 32, 32, 32, 32, 32, 32, 31,
+        30, 29, 29, 26, 25, 25, 23, 20, 33, 32, 32, 32, 32, 31, 31, 31, 30, 30,
+        30, 27, 25, 25, 23, 21, 33, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 27,
+        25, 25, 23, 21, 33, 32, 32, 32, 32, 31, 31, 31, 30, 29, 29, 27, 25, 25,
+        23, 21, 33, 32, 32, 32, 31, 30, 30, 30, 29, 28, 28, 26, 24, 24, 23, 21,
+        32, 32, 32, 32, 31, 30, 30, 30, 28, 28, 28, 26, 24, 24, 23, 20, 32, 32,
+        32, 32, 31, 30, 30, 30, 28, 28, 28, 26, 24, 24, 23, 20, 32, 32, 32, 32,
+        31, 29, 29, 29, 28, 28, 28, 26, 24, 24, 23, 21, 32, 32, 31, 31, 30, 29,
+        29, 28, 28, 27, 27, 25, 24, 24, 23, 21, 32, 32, 31, 31, 30, 29, 29, 28,
+        28, 27, 27, 25, 24, 24, 23, 21, 32, 31, 31, 31, 30, 28, 28, 28, 26, 26,
+        26, 24, 23, 23, 22, 20, 30, 30, 30, 30, 29, 28, 28, 27, 25, 24, 24, 23,
+        21, 21, 20, 19, 30, 30, 30, 30, 29, 28, 28, 27, 25, 24, 24, 23, 21, 21,
+        20, 19, 30, 30, 30, 30, 29, 28, 28, 27, 24, 24, 24, 22, 21, 21, 20, 19,
+        29, 29, 30, 30, 28, 27, 27, 26, 23, 22, 22, 20, 20, 20, 19, 17, 28, 29,
+        30, 30, 28, 27, 27, 26, 22, 21, 21, 20, 19, 19, 18, 17, 28, 29, 30, 30,
+        28, 27, 27, 26, 22, 21, 21, 20, 19, 19, 18, 17, 27, 28, 28, 28, 28, 26,
+        26, 25, 22, 21, 21, 19, 18, 18, 18, 16, 26, 27, 28, 28, 26, 26, 26, 24,
+        21, 20, 20, 19, 18, 18, 17, 16, 26, 27, 28, 28, 26, 26, 26, 24, 21, 20,
+        20, 19, 18, 18, 17, 16, 25, 26, 26, 26, 26, 25, 25, 24, 21, 20, 20, 18,
+        17, 17, 17, 15, 23, 24, 25, 25, 24, 24, 24, 23, 20, 19, 19, 17, 16, 16,
+        16, 14, 23, 24, 25, 25, 24, 24, 24, 23, 20, 19, 19, 17, 16, 16, 16, 14,
+        23, 24, 24, 24, 24, 24, 24, 23, 20, 19, 19, 17, 16, 16, 15, 14, 22, 23,
+        23, 23, 23, 23, 23, 22, 19, 18, 18, 17, 16, 16, 15, 14, 21, 22, 23, 23,
+        23, 22, 22, 21, 19, 18, 18, 17, 15, 15, 15, 13, 21, 22, 23, 23, 23, 22,
+        22, 21, 19, 18, 18, 17, 15, 15, 15, 13, 20, 21, 22, 22, 21, 21, 21, 20,
+        18, 18, 18, 16, 15, 15, 14, 13,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 63, 60, 60, 59, 57, 57,
-        54, 52, 52, 48, 47, 47, 44, 43, 42, 39, 38, 37, 35, 35, 65, 64, 64, 64,
-        64, 64, 64, 63, 63, 63, 63, 63, 62, 60, 60, 59, 59, 59, 55, 54, 54, 51,
-        49, 48, 46, 45, 44, 41, 40, 39, 37, 37, 65, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 62, 62, 62, 60, 60, 59, 59, 59, 56, 55, 55, 51, 50, 49, 47, 46,
-        45, 42, 41, 40, 38, 38, 65, 64, 64, 64, 63, 63, 63, 63, 62, 62, 62, 62,
-        61, 60, 60, 59, 59, 59, 55, 54, 54, 51, 49, 49, 46, 46, 45, 42, 41, 40,
-        38, 38, 64, 64, 63, 63, 63, 63, 62, 61, 60, 60, 59, 59, 58, 57, 57, 55,
-        55, 55, 53, 51, 51, 49, 48, 48, 45, 45, 44, 41, 41, 40, 38, 38, 64, 63,
-        63, 63, 63, 62, 62, 60, 60, 59, 58, 58, 57, 55, 55, 55, 53, 53, 51, 51,
-        51, 48, 48, 47, 45, 44, 44, 41, 41, 40, 38, 38, 63, 62, 62, 62, 62, 62,
-        61, 59, 59, 59, 57, 57, 56, 54, 54, 53, 51, 51, 49, 48, 48, 47, 46, 46,
-        43, 43, 42, 40, 40, 39, 37, 37, 58, 59, 59, 59, 59, 59, 59, 57, 56, 55,
-        54, 54, 52, 49, 49, 46, 44, 44, 42, 42, 42, 40, 39, 39, 38, 37, 37, 35,
-        35, 34, 33, 33, 57, 58, 58, 58, 59, 59, 59, 56, 56, 55, 53, 53, 51, 48,
-        48, 46, 43, 43, 41, 41, 41, 39, 38, 38, 37, 36, 36, 34, 34, 34, 32, 32,
-        54, 55, 55, 55, 56, 56, 56, 54, 54, 53, 52, 52, 49, 47, 47, 44, 41, 41,
-        40, 39, 39, 37, 37, 36, 35, 34, 34, 33, 33, 32, 31, 31, 47, 48, 48, 49,
-        50, 50, 50, 49, 49, 48, 48, 48, 46, 43, 43, 41, 38, 38, 37, 35, 35, 33,
-        33, 32, 31, 31, 30, 29, 29, 28, 27, 27, 47, 48, 48, 49, 50, 50, 50, 49,
-        49, 48, 48, 48, 46, 43, 43, 41, 38, 38, 37, 35, 35, 33, 33, 32, 31, 31,
-        30, 29, 29, 28, 27, 27, 43, 45, 45, 45, 47, 47, 47, 46, 46, 46, 46, 46,
-        44, 41, 41, 39, 37, 37, 35, 34, 34, 32, 31, 31, 29, 29, 29, 27, 27, 27,
-        26, 26, 38, 39, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 40, 38, 38, 36,
-        34, 34, 33, 32, 32, 29, 29, 28, 27, 27, 26, 25, 25, 25, 24, 24, 38, 39,
-        40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 40, 38, 38, 36, 34, 34, 33, 32,
-        32, 29, 29, 28, 27, 27, 26, 25, 25, 25, 24, 24, 35, 36, 36, 37, 38, 38,
-        38, 38, 38, 38, 38, 38, 37, 35, 35, 34, 32, 32, 31, 30, 30, 28, 27, 27,
-        26, 25, 25, 24, 24, 23, 22, 22,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 30, 30, 30,
+        29, 28, 28, 27, 26, 26, 25, 23, 23, 23, 22, 21, 21, 20, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 30, 29, 29, 29, 28,
+        27, 27, 26, 24, 24, 24, 23, 22, 22, 21, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 30, 30, 28, 28, 28, 26, 25,
+        25, 24, 23, 23, 23, 22, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 30, 30, 30, 30, 30, 30, 28, 28, 28, 26, 25, 25, 24, 23, 23,
+        23, 22, 33, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 29,
+        29, 29, 28, 28, 28, 28, 26, 26, 26, 24, 24, 24, 23, 23, 23, 21, 32, 32,
+        32, 32, 32, 31, 31, 31, 30, 30, 30, 29, 29, 29, 28, 28, 28, 28, 27, 27,
+        27, 26, 26, 26, 25, 24, 24, 24, 23, 22, 22, 21, 32, 32, 32, 32, 32, 31,
+        31, 31, 30, 30, 30, 29, 29, 29, 28, 28, 28, 28, 27, 27, 27, 26, 26, 26,
+        25, 24, 24, 24, 23, 22, 22, 21, 32, 31, 31, 31, 31, 31, 31, 31, 30, 30,
+        30, 29, 28, 28, 28, 27, 27, 27, 26, 26, 26, 25, 24, 24, 24, 23, 23, 23,
+        22, 21, 21, 20, 29, 29, 29, 29, 30, 30, 30, 30, 29, 28, 28, 28, 28, 28,
+        26, 25, 25, 24, 23, 22, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18,
+        28, 29, 29, 29, 29, 30, 30, 29, 28, 28, 28, 28, 27, 27, 26, 24, 24, 24,
+        22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 28, 29, 29, 29,
+        29, 30, 30, 29, 28, 28, 28, 28, 27, 27, 26, 24, 24, 24, 22, 21, 21, 21,
+        20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 26, 26, 26, 26, 26, 27, 27, 27,
+        26, 26, 26, 26, 25, 25, 24, 23, 23, 22, 20, 20, 20, 19, 19, 19, 18, 17,
+        17, 17, 17, 17, 17, 16, 23, 24, 24, 24, 25, 25, 25, 25, 24, 24, 24, 24,
+        24, 24, 23, 21, 21, 21, 20, 19, 19, 18, 18, 18, 17, 16, 16, 16, 16, 15,
+        15, 15, 23, 24, 24, 24, 25, 25, 25, 25, 24, 24, 24, 24, 24, 24, 23, 21,
+        21, 21, 20, 19, 19, 18, 18, 18, 17, 16, 16, 16, 16, 15, 15, 15, 22, 22,
+        23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 22, 20, 20, 20, 19, 18,
+        18, 18, 17, 17, 17, 16, 16, 15, 15, 15, 15, 14, 19, 20, 20, 20, 20, 21,
+        21, 21, 21, 20, 20, 21, 21, 21, 20, 19, 19, 19, 17, 17, 17, 16, 16, 16,
+        15, 14, 14, 14, 14, 13, 13, 13,
         /* Size 4x16 */
-        65, 64, 54, 38, 64, 63, 55, 40, 64, 63, 56, 41, 64, 62, 56, 41, 63, 60,
-        54, 41, 63, 58, 52, 41, 62, 57, 49, 40, 60, 55, 47, 38, 59, 53, 41, 34,
-        55, 51, 40, 33, 54, 51, 39, 32, 49, 48, 37, 29, 46, 45, 35, 27, 44, 44,
-        34, 26, 40, 41, 33, 25, 37, 38, 31, 24,
+        33, 32, 28, 23, 32, 32, 29, 24, 32, 32, 29, 25, 32, 31, 30, 25, 32, 30,
+        28, 24, 32, 30, 28, 24, 32, 29, 27, 24, 31, 28, 26, 23, 30, 28, 24, 21,
+        29, 27, 22, 20, 29, 27, 21, 19, 27, 26, 20, 18, 26, 25, 20, 17, 24, 24,
+        19, 16, 23, 23, 18, 16, 22, 22, 18, 15,
         /* Size 16x4 */
-        65, 64, 64, 64, 63, 63, 62, 60, 59, 55, 54, 49, 46, 44, 40, 37, 64, 63,
-        63, 62, 60, 58, 57, 55, 53, 51, 51, 48, 45, 44, 41, 38, 54, 55, 56, 56,
-        54, 52, 49, 47, 41, 40, 39, 37, 35, 34, 33, 31, 38, 40, 41, 41, 41, 41,
-        40, 38, 34, 33, 32, 29, 27, 26, 25, 24,
+        33, 32, 32, 32, 32, 32, 32, 31, 30, 29, 29, 27, 26, 24, 23, 22, 32, 32,
+        32, 31, 30, 30, 29, 28, 28, 27, 27, 26, 25, 24, 23, 22, 28, 29, 29, 30,
+        28, 28, 27, 26, 24, 22, 21, 20, 20, 19, 18, 18, 23, 24, 25, 25, 24, 24,
+        24, 23, 21, 20, 19, 18, 17, 16, 16, 15,
         /* Size 8x32 */
-        64, 65, 64, 63, 57, 47, 43, 38, 65, 64, 64, 62, 58, 48, 45, 39, 65, 64,
-        63, 62, 58, 48, 45, 40, 65, 64, 63, 62, 58, 49, 45, 40, 65, 63, 63, 62,
-        59, 50, 47, 41, 65, 63, 63, 62, 59, 50, 47, 41, 65, 63, 62, 61, 59, 50,
-        47, 41, 64, 63, 61, 59, 56, 49, 46, 41, 64, 63, 60, 59, 56, 49, 46, 41,
-        64, 63, 60, 59, 55, 48, 46, 41, 64, 62, 59, 57, 53, 48, 46, 41, 64, 62,
-        59, 57, 53, 48, 46, 41, 63, 62, 58, 56, 51, 46, 44, 40, 60, 60, 57, 54,
-        48, 43, 41, 38, 60, 60, 57, 54, 48, 43, 41, 38, 59, 59, 55, 53, 46, 41,
-        39, 36, 57, 59, 55, 51, 43, 38, 37, 34, 57, 59, 55, 51, 43, 38, 37, 34,
-        54, 56, 53, 49, 41, 37, 35, 33, 52, 55, 51, 48, 41, 35, 34, 32, 52, 55,
-        51, 48, 41, 35, 34, 32, 48, 51, 49, 47, 39, 33, 32, 29, 47, 50, 48, 46,
-        38, 33, 31, 29, 47, 49, 48, 46, 38, 32, 31, 28, 44, 47, 45, 43, 37, 31,
-        29, 27, 43, 46, 45, 43, 36, 31, 29, 27, 42, 45, 44, 42, 36, 30, 29, 26,
-        39, 42, 41, 40, 34, 29, 27, 25, 38, 41, 41, 40, 34, 29, 27, 25, 37, 40,
-        40, 39, 34, 28, 27, 25, 35, 38, 38, 37, 32, 27, 26, 24, 35, 38, 38, 37,
-        32, 27, 26, 24,
+        32, 33, 33, 32, 29, 28, 23, 22, 33, 32, 32, 32, 29, 29, 24, 22, 33, 32,
+        32, 32, 29, 29, 24, 23, 33, 32, 32, 32, 29, 29, 24, 23, 33, 32, 32, 32,
+        30, 29, 25, 23, 33, 32, 32, 31, 30, 30, 25, 23, 33, 32, 32, 31, 30, 30,
+        25, 23, 33, 32, 32, 31, 30, 29, 25, 23, 33, 32, 31, 30, 29, 28, 24, 23,
+        32, 32, 31, 30, 28, 28, 24, 23, 32, 32, 31, 30, 28, 28, 24, 23, 32, 32,
+        31, 29, 28, 28, 24, 23, 32, 31, 30, 29, 28, 27, 24, 23, 32, 31, 30, 29,
+        28, 27, 24, 23, 32, 31, 30, 28, 26, 26, 23, 22, 30, 30, 29, 28, 25, 24,
+        21, 20, 30, 30, 29, 28, 25, 24, 21, 20, 30, 30, 29, 28, 24, 24, 21, 20,
+        29, 30, 28, 27, 23, 22, 20, 19, 28, 30, 28, 27, 22, 21, 19, 18, 28, 30,
+        28, 27, 22, 21, 19, 18, 27, 28, 28, 26, 22, 21, 18, 18, 26, 28, 26, 26,
+        21, 20, 18, 17, 26, 28, 26, 26, 21, 20, 18, 17, 25, 26, 26, 25, 21, 20,
+        17, 17, 23, 25, 24, 24, 20, 19, 16, 16, 23, 25, 24, 24, 20, 19, 16, 16,
+        23, 24, 24, 24, 20, 19, 16, 15, 22, 23, 23, 23, 19, 18, 16, 15, 21, 23,
+        23, 22, 19, 18, 15, 15, 21, 23, 23, 22, 19, 18, 15, 15, 20, 22, 21, 21,
+        18, 18, 15, 14,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 63, 60, 60, 59, 57, 57,
-        54, 52, 52, 48, 47, 47, 44, 43, 42, 39, 38, 37, 35, 35, 65, 64, 64, 64,
-        63, 63, 63, 63, 63, 63, 62, 62, 62, 60, 60, 59, 59, 59, 56, 55, 55, 51,
-        50, 49, 47, 46, 45, 42, 41, 40, 38, 38, 64, 64, 63, 63, 63, 63, 62, 61,
-        60, 60, 59, 59, 58, 57, 57, 55, 55, 55, 53, 51, 51, 49, 48, 48, 45, 45,
-        44, 41, 41, 40, 38, 38, 63, 62, 62, 62, 62, 62, 61, 59, 59, 59, 57, 57,
-        56, 54, 54, 53, 51, 51, 49, 48, 48, 47, 46, 46, 43, 43, 42, 40, 40, 39,
-        37, 37, 57, 58, 58, 58, 59, 59, 59, 56, 56, 55, 53, 53, 51, 48, 48, 46,
-        43, 43, 41, 41, 41, 39, 38, 38, 37, 36, 36, 34, 34, 34, 32, 32, 47, 48,
-        48, 49, 50, 50, 50, 49, 49, 48, 48, 48, 46, 43, 43, 41, 38, 38, 37, 35,
-        35, 33, 33, 32, 31, 31, 30, 29, 29, 28, 27, 27, 43, 45, 45, 45, 47, 47,
-        47, 46, 46, 46, 46, 46, 44, 41, 41, 39, 37, 37, 35, 34, 34, 32, 31, 31,
-        29, 29, 29, 27, 27, 27, 26, 26, 38, 39, 40, 40, 41, 41, 41, 41, 41, 41,
-        41, 41, 40, 38, 38, 36, 34, 34, 33, 32, 32, 29, 29, 28, 27, 27, 26, 25,
-        25, 25, 24, 24 },
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 30, 30, 30,
+        29, 28, 28, 27, 26, 26, 25, 23, 23, 23, 22, 21, 21, 20, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 30, 30, 28,
+        28, 28, 26, 25, 25, 24, 23, 23, 23, 22, 33, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 30, 30, 30, 29, 29, 29, 28, 28, 28, 28, 26, 26, 26, 24,
+        24, 24, 23, 23, 23, 21, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 29,
+        29, 29, 28, 28, 28, 28, 27, 27, 27, 26, 26, 26, 25, 24, 24, 24, 23, 22,
+        22, 21, 29, 29, 29, 29, 30, 30, 30, 30, 29, 28, 28, 28, 28, 28, 26, 25,
+        25, 24, 23, 22, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 28, 29,
+        29, 29, 29, 30, 30, 29, 28, 28, 28, 28, 27, 27, 26, 24, 24, 24, 22, 21,
+        21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 23, 24, 24, 24, 25, 25,
+        25, 25, 24, 24, 24, 24, 24, 24, 23, 21, 21, 21, 20, 19, 19, 18, 18, 18,
+        17, 16, 16, 16, 16, 15, 15, 15, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
+        23, 23, 23, 23, 22, 20, 20, 20, 19, 18, 18, 18, 17, 17, 17, 16, 16, 15,
+        15, 15, 15, 14 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        53, 45, 45, 35,
+        31, 23, 23, 19,
 #endif
         /* Size 4x4 */
-        65, 53, 44, 41, 53, 43, 44, 44, 44, 44, 38, 36, 41, 44, 36, 31,
+        33, 28, 22, 22, 28, 23, 22, 23, 22, 22, 19, 19, 22, 23, 19, 17,
         /* Size 8x8 */
-        65, 66, 58, 49, 43, 43, 42, 40, 66, 64, 56, 48, 44, 46, 44, 42, 58, 56,
-        49, 45, 43, 45, 44, 43, 49, 48, 45, 42, 41, 41, 41, 40, 43, 44, 43, 41,
-        39, 38, 38, 38, 43, 46, 45, 41, 38, 36, 35, 34, 42, 44, 44, 41, 38, 35,
-        33, 32, 40, 42, 43, 40, 38, 34, 32, 30,
+        33, 33, 30, 28, 24, 21, 22, 21, 33, 32, 29, 26, 24, 22, 23, 22, 30, 29,
+        26, 24, 23, 22, 23, 22, 28, 26, 24, 22, 22, 22, 23, 22, 24, 24, 23, 22,
+        21, 20, 20, 20, 21, 22, 22, 22, 20, 19, 19, 19, 22, 23, 23, 23, 20, 19,
+        18, 17, 21, 22, 22, 22, 20, 19, 17, 17,
         /* Size 16x16 */
-        64, 66, 67, 66, 61, 56, 53, 49, 42, 42, 42, 42, 41, 40, 39, 38, 66, 65,
-        65, 64, 59, 53, 51, 48, 43, 43, 44, 44, 43, 42, 41, 39, 67, 65, 65, 63,
-        58, 52, 50, 48, 44, 45, 45, 45, 44, 44, 43, 41, 66, 64, 63, 62, 57, 51,
-        49, 48, 44, 45, 45, 46, 45, 44, 43, 41, 61, 59, 58, 57, 53, 47, 47, 46,
-        43, 44, 44, 45, 44, 44, 43, 41, 56, 53, 52, 51, 47, 43, 43, 43, 43, 44,
-        44, 45, 45, 44, 44, 42, 53, 51, 50, 49, 47, 43, 43, 43, 42, 43, 43, 44,
-        43, 43, 43, 41, 49, 48, 48, 48, 46, 43, 43, 42, 41, 41, 41, 42, 41, 41,
-        41, 39, 42, 43, 44, 44, 43, 43, 42, 41, 39, 39, 39, 38, 38, 38, 38, 37,
-        42, 43, 45, 45, 44, 44, 43, 41, 39, 38, 38, 37, 37, 37, 37, 36, 42, 44,
-        45, 45, 44, 44, 43, 41, 39, 38, 38, 37, 36, 36, 36, 35, 42, 44, 45, 46,
-        45, 45, 44, 42, 38, 37, 37, 35, 34, 34, 33, 33, 41, 43, 44, 45, 44, 45,
-        43, 41, 38, 37, 36, 34, 34, 33, 33, 32, 40, 42, 44, 44, 44, 44, 43, 41,
-        38, 37, 36, 34, 33, 33, 32, 31, 39, 41, 43, 43, 43, 44, 43, 41, 38, 37,
-        36, 33, 33, 32, 31, 30, 38, 39, 41, 41, 41, 42, 41, 39, 37, 36, 35, 33,
-        32, 31, 30, 29,
+        32, 33, 33, 34, 31, 31, 28, 27, 25, 22, 21, 21, 21, 21, 20, 20, 33, 33,
+        33, 33, 30, 30, 27, 26, 24, 22, 22, 22, 22, 22, 21, 21, 33, 33, 33, 33,
+        30, 29, 26, 26, 24, 22, 22, 22, 22, 22, 22, 22, 34, 33, 33, 32, 30, 29,
+        26, 25, 24, 23, 22, 23, 23, 23, 22, 22, 31, 30, 30, 30, 28, 27, 24, 24,
+        23, 22, 22, 22, 22, 23, 22, 22, 31, 30, 29, 29, 27, 26, 24, 23, 23, 22,
+        22, 22, 22, 23, 22, 22, 28, 27, 26, 26, 24, 24, 22, 22, 22, 22, 21, 22,
+        22, 23, 22, 22, 27, 26, 26, 25, 24, 23, 22, 22, 21, 21, 21, 21, 22, 22,
+        22, 22, 25, 24, 24, 24, 23, 23, 22, 21, 21, 20, 20, 21, 21, 21, 20, 20,
+        22, 22, 22, 23, 22, 22, 22, 21, 20, 20, 20, 20, 20, 20, 19, 19, 21, 22,
+        22, 22, 22, 22, 21, 21, 20, 20, 19, 19, 19, 19, 19, 19, 21, 22, 22, 23,
+        22, 22, 22, 21, 21, 20, 19, 19, 19, 19, 18, 18, 21, 22, 22, 23, 22, 22,
+        22, 22, 21, 20, 19, 19, 19, 18, 18, 18, 21, 22, 22, 23, 23, 23, 23, 22,
+        21, 20, 19, 19, 18, 18, 17, 17, 20, 21, 22, 22, 22, 22, 22, 22, 20, 19,
+        19, 18, 18, 17, 17, 17, 20, 21, 22, 22, 22, 22, 22, 22, 20, 19, 19, 18,
+        18, 17, 17, 17,
         /* Size 32x32 */
-        64, 65, 66, 66, 67, 67, 66, 62, 61, 59, 56, 56, 53, 49, 49, 46, 42, 42,
-        42, 42, 42, 42, 42, 42, 41, 41, 40, 39, 39, 39, 38, 38, 65, 65, 65, 65,
-        66, 66, 65, 60, 59, 58, 54, 54, 52, 49, 49, 46, 43, 43, 43, 43, 43, 43,
-        43, 43, 42, 42, 41, 41, 41, 40, 39, 39, 66, 65, 65, 65, 65, 66, 64, 59,
-        59, 58, 53, 53, 51, 48, 48, 46, 43, 43, 43, 44, 44, 44, 44, 44, 43, 42,
-        42, 41, 41, 41, 39, 39, 66, 65, 65, 65, 65, 65, 64, 59, 59, 57, 53, 53,
-        51, 48, 48, 46, 43, 43, 44, 44, 44, 44, 44, 44, 43, 43, 42, 41, 41, 41,
-        39, 39, 67, 66, 65, 65, 65, 65, 63, 59, 58, 56, 52, 52, 50, 48, 48, 46,
-        44, 44, 45, 45, 45, 45, 45, 45, 44, 44, 44, 43, 43, 42, 41, 41, 67, 66,
-        66, 65, 65, 64, 63, 59, 58, 56, 51, 51, 50, 48, 48, 46, 44, 44, 45, 45,
-        45, 46, 46, 46, 45, 44, 44, 43, 43, 42, 41, 41, 66, 65, 64, 64, 63, 63,
-        62, 58, 57, 55, 51, 51, 49, 48, 48, 46, 44, 44, 45, 45, 45, 45, 46, 46,
-        45, 44, 44, 43, 43, 43, 41, 41, 62, 60, 59, 59, 59, 59, 58, 53, 53, 51,
-        48, 48, 47, 46, 46, 45, 44, 44, 44, 45, 45, 45, 45, 45, 44, 44, 44, 43,
-        43, 43, 41, 41, 61, 59, 59, 59, 58, 58, 57, 53, 53, 51, 47, 47, 47, 46,
-        46, 45, 43, 43, 44, 44, 44, 45, 45, 45, 44, 44, 44, 43, 43, 43, 41, 41,
-        59, 58, 58, 57, 56, 56, 55, 51, 51, 49, 46, 46, 46, 45, 45, 44, 43, 43,
-        44, 44, 44, 45, 45, 45, 44, 44, 44, 44, 43, 43, 42, 42, 56, 54, 53, 53,
-        52, 51, 51, 48, 47, 46, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 45,
-        45, 45, 45, 45, 44, 44, 44, 44, 42, 42, 56, 54, 53, 53, 52, 51, 51, 48,
-        47, 46, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 45, 45, 45, 45, 45,
-        44, 44, 44, 44, 42, 42, 53, 52, 51, 51, 50, 50, 49, 47, 47, 46, 43, 43,
-        43, 43, 43, 42, 42, 42, 43, 43, 43, 44, 44, 44, 43, 43, 43, 43, 43, 42,
-        41, 41, 49, 49, 48, 48, 48, 48, 48, 46, 46, 45, 43, 43, 43, 42, 42, 41,
-        41, 41, 41, 41, 41, 41, 42, 41, 41, 41, 41, 41, 41, 40, 39, 39, 49, 49,
-        48, 48, 48, 48, 48, 46, 46, 45, 43, 43, 43, 42, 42, 41, 41, 41, 41, 41,
-        41, 41, 42, 41, 41, 41, 41, 41, 41, 40, 39, 39, 46, 46, 46, 46, 46, 46,
-        46, 45, 45, 44, 43, 43, 42, 41, 41, 41, 40, 40, 40, 40, 40, 40, 40, 40,
-        39, 39, 39, 39, 39, 39, 38, 38, 42, 43, 43, 43, 44, 44, 44, 44, 43, 43,
-        43, 43, 42, 41, 41, 40, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 38,
-        38, 38, 37, 37, 42, 43, 43, 43, 44, 44, 44, 44, 43, 43, 43, 43, 42, 41,
-        41, 40, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 38, 38, 38, 37, 37,
-        42, 43, 43, 44, 45, 45, 45, 44, 44, 44, 44, 44, 43, 41, 41, 40, 39, 39,
-        38, 38, 38, 38, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 42, 43, 44, 44,
-        45, 45, 45, 45, 44, 44, 44, 44, 43, 41, 41, 40, 39, 39, 38, 38, 38, 37,
-        37, 37, 36, 36, 36, 36, 36, 35, 35, 35, 42, 43, 44, 44, 45, 45, 45, 45,
-        44, 44, 44, 44, 43, 41, 41, 40, 39, 39, 38, 38, 38, 37, 37, 37, 36, 36,
-        36, 36, 36, 35, 35, 35, 42, 43, 44, 44, 45, 46, 45, 45, 45, 45, 45, 45,
-        44, 41, 41, 40, 38, 38, 38, 37, 37, 36, 36, 35, 35, 35, 35, 34, 34, 34,
-        33, 33, 42, 43, 44, 44, 45, 46, 46, 45, 45, 45, 45, 45, 44, 42, 42, 40,
-        38, 38, 37, 37, 37, 36, 35, 35, 34, 34, 34, 34, 33, 33, 33, 33, 42, 43,
-        44, 44, 45, 46, 46, 45, 45, 45, 45, 45, 44, 41, 41, 40, 38, 38, 37, 37,
-        37, 35, 35, 35, 34, 34, 34, 33, 33, 33, 33, 33, 41, 42, 43, 43, 44, 45,
-        45, 44, 44, 44, 45, 45, 43, 41, 41, 39, 38, 38, 37, 36, 36, 35, 34, 34,
-        34, 34, 33, 33, 33, 32, 32, 32, 41, 42, 42, 43, 44, 44, 44, 44, 44, 44,
-        45, 45, 43, 41, 41, 39, 38, 38, 37, 36, 36, 35, 34, 34, 34, 33, 33, 32,
-        32, 32, 32, 32, 40, 41, 42, 42, 44, 44, 44, 44, 44, 44, 44, 44, 43, 41,
-        41, 39, 38, 38, 37, 36, 36, 35, 34, 34, 33, 33, 33, 32, 32, 32, 31, 31,
-        39, 41, 41, 41, 43, 43, 43, 43, 43, 44, 44, 44, 43, 41, 41, 39, 38, 38,
-        37, 36, 36, 34, 34, 33, 33, 32, 32, 31, 31, 31, 30, 30, 39, 41, 41, 41,
-        43, 43, 43, 43, 43, 43, 44, 44, 43, 41, 41, 39, 38, 38, 37, 36, 36, 34,
-        33, 33, 33, 32, 32, 31, 31, 31, 30, 30, 39, 40, 41, 41, 42, 42, 43, 43,
-        43, 43, 44, 44, 42, 40, 40, 39, 38, 38, 36, 35, 35, 34, 33, 33, 32, 32,
-        32, 31, 31, 30, 30, 30, 38, 39, 39, 39, 41, 41, 41, 41, 41, 42, 42, 42,
-        41, 39, 39, 38, 37, 37, 36, 35, 35, 33, 33, 33, 32, 32, 31, 30, 30, 30,
-        29, 29, 38, 39, 39, 39, 41, 41, 41, 41, 41, 42, 42, 42, 41, 39, 39, 38,
-        37, 37, 36, 35, 35, 33, 33, 33, 32, 32, 31, 30, 30, 30, 29, 29,
+        32, 33, 33, 33, 33, 34, 34, 33, 31, 31, 31, 29, 28, 28, 27, 25, 25, 24,
+        22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 33, 33, 33, 33,
+        33, 33, 33, 33, 31, 30, 30, 28, 28, 28, 26, 24, 24, 24, 22, 21, 21, 21,
+        22, 22, 22, 22, 22, 21, 21, 21, 21, 20, 33, 33, 33, 33, 33, 33, 33, 32,
+        30, 30, 30, 28, 27, 27, 26, 24, 24, 24, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 21, 21, 21, 21, 33, 33, 33, 33, 33, 33, 33, 32, 30, 30, 30, 28,
+        27, 27, 26, 24, 24, 24, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21,
+        21, 21, 33, 33, 33, 33, 33, 33, 33, 32, 30, 29, 29, 28, 26, 26, 26, 24,
+        24, 24, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 34, 33,
+        33, 33, 33, 32, 32, 32, 30, 29, 29, 27, 26, 26, 25, 24, 24, 24, 23, 22,
+        22, 22, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 34, 33, 33, 33, 33, 32,
+        32, 32, 30, 29, 29, 27, 26, 26, 25, 24, 24, 24, 23, 22, 22, 22, 23, 23,
+        23, 23, 23, 23, 22, 22, 22, 22, 33, 33, 32, 32, 32, 32, 32, 31, 29, 28,
+        28, 27, 26, 26, 25, 24, 24, 24, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23,
+        22, 22, 22, 22, 31, 31, 30, 30, 30, 30, 30, 29, 28, 27, 27, 25, 24, 24,
+        24, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 22,
+        31, 30, 30, 30, 29, 29, 29, 28, 27, 26, 26, 25, 24, 24, 23, 23, 23, 23,
+        22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 22, 31, 30, 30, 30,
+        29, 29, 29, 28, 27, 26, 26, 25, 24, 24, 23, 23, 23, 23, 22, 22, 22, 22,
+        22, 22, 22, 23, 23, 23, 22, 22, 22, 22, 29, 28, 28, 28, 28, 27, 27, 27,
+        25, 25, 25, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
+        23, 23, 22, 22, 22, 22, 28, 28, 27, 27, 26, 26, 26, 26, 24, 24, 24, 22,
+        22, 22, 22, 22, 22, 22, 22, 21, 21, 22, 22, 22, 22, 23, 23, 23, 22, 22,
+        22, 22, 28, 28, 27, 27, 26, 26, 26, 26, 24, 24, 24, 22, 22, 22, 22, 22,
+        22, 22, 22, 21, 21, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 22, 27, 26,
+        26, 26, 26, 25, 25, 25, 24, 23, 23, 22, 22, 22, 22, 21, 21, 21, 21, 21,
+        21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 21, 25, 24, 24, 24, 24, 24,
+        24, 24, 23, 23, 23, 22, 22, 22, 21, 21, 21, 21, 20, 20, 20, 20, 21, 21,
+        21, 21, 21, 21, 20, 20, 20, 20, 25, 24, 24, 24, 24, 24, 24, 24, 23, 23,
+        23, 22, 22, 22, 21, 21, 21, 21, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21,
+        20, 20, 20, 20, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 22, 22, 22,
+        21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+        22, 22, 22, 22, 22, 23, 23, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20,
+        20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 21, 21, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 20, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 21, 21, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 21, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 18, 21, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 22, 22, 22, 21, 21,
+        21, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 21, 22,
+        22, 22, 22, 23, 23, 23, 22, 22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 19,
+        19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 21, 22, 22, 22, 22, 23,
+        23, 23, 22, 22, 22, 22, 22, 22, 22, 21, 21, 20, 20, 19, 19, 19, 19, 19,
+        19, 18, 18, 18, 18, 18, 18, 18, 21, 22, 22, 22, 22, 23, 23, 23, 23, 23,
+        23, 23, 23, 23, 22, 21, 21, 20, 20, 19, 19, 19, 19, 19, 18, 18, 18, 17,
+        17, 17, 17, 17, 21, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+        22, 21, 21, 20, 20, 19, 19, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 17,
+        21, 21, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 22, 21, 21, 20,
+        20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 20, 21, 21, 21,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 20, 20, 20, 19, 19, 19, 19,
+        18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 20, 21, 21, 21, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 20, 20, 20, 19, 19, 19, 19, 18, 18, 18, 17,
+        17, 17, 17, 17, 17, 16, 20, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 20, 20, 20, 19, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 17,
+        17, 16, 20, 20, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20,
+        20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17, 16, 16, 16,
         /* Size 4x8 */
-        65, 54, 43, 41, 65, 51, 45, 43, 56, 46, 44, 43, 48, 43, 41, 41, 43, 43,
-        39, 38, 44, 45, 38, 34, 43, 44, 37, 32, 41, 43, 36, 31,
+        33, 27, 22, 21, 33, 26, 22, 23, 29, 24, 22, 22, 26, 22, 22, 23, 24, 22,
+        20, 20, 22, 22, 19, 19, 22, 22, 19, 18, 21, 22, 19, 17,
         /* Size 8x4 */
-        65, 65, 56, 48, 43, 44, 43, 41, 54, 51, 46, 43, 43, 45, 44, 43, 43, 45,
-        44, 41, 39, 38, 37, 36, 41, 43, 43, 41, 38, 34, 32, 31,
+        33, 33, 29, 26, 24, 22, 22, 21, 27, 26, 24, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 20, 19, 19, 19, 21, 23, 22, 23, 20, 19, 18, 17,
         /* Size 8x16 */
-        64, 66, 58, 53, 43, 42, 41, 39, 65, 65, 55, 51, 44, 44, 42, 41, 67, 64,
-        54, 51, 45, 45, 44, 42, 66, 62, 53, 49, 45, 45, 44, 43, 61, 57, 49, 47,
-        44, 45, 44, 43, 55, 51, 45, 43, 43, 45, 45, 44, 53, 50, 45, 43, 42, 44,
-        43, 42, 49, 48, 44, 43, 41, 41, 41, 41, 42, 44, 43, 42, 39, 38, 38, 38,
-        42, 45, 44, 42, 39, 37, 37, 36, 42, 45, 44, 43, 39, 37, 36, 36, 42, 45,
-        45, 44, 38, 35, 34, 33, 41, 44, 44, 43, 38, 34, 34, 32, 40, 44, 44, 43,
-        38, 34, 33, 32, 39, 43, 43, 42, 38, 34, 32, 31, 38, 41, 42, 41, 37, 33,
-        32, 30,
+        32, 33, 31, 28, 23, 21, 21, 20, 33, 33, 30, 27, 23, 22, 22, 21, 33, 32,
+        30, 26, 23, 22, 22, 22, 34, 32, 29, 26, 23, 22, 23, 22, 31, 29, 28, 24,
+        22, 22, 23, 22, 31, 28, 27, 24, 22, 22, 22, 22, 28, 26, 24, 22, 22, 22,
+        23, 22, 26, 25, 24, 22, 21, 21, 22, 22, 24, 24, 23, 22, 21, 20, 21, 20,
+        22, 22, 22, 21, 20, 20, 19, 19, 21, 22, 22, 21, 20, 19, 19, 19, 21, 22,
+        22, 22, 20, 19, 18, 18, 21, 23, 22, 22, 20, 19, 18, 18, 21, 23, 23, 22,
+        20, 19, 18, 17, 20, 22, 22, 22, 20, 19, 17, 17, 20, 22, 22, 22, 20, 19,
+        17, 17,
         /* Size 16x8 */
-        64, 65, 67, 66, 61, 55, 53, 49, 42, 42, 42, 42, 41, 40, 39, 38, 66, 65,
-        64, 62, 57, 51, 50, 48, 44, 45, 45, 45, 44, 44, 43, 41, 58, 55, 54, 53,
-        49, 45, 45, 44, 43, 44, 44, 45, 44, 44, 43, 42, 53, 51, 51, 49, 47, 43,
-        43, 43, 42, 42, 43, 44, 43, 43, 42, 41, 43, 44, 45, 45, 44, 43, 42, 41,
-        39, 39, 39, 38, 38, 38, 38, 37, 42, 44, 45, 45, 45, 45, 44, 41, 38, 37,
-        37, 35, 34, 34, 34, 33, 41, 42, 44, 44, 44, 45, 43, 41, 38, 37, 36, 34,
-        34, 33, 32, 32, 39, 41, 42, 43, 43, 44, 42, 41, 38, 36, 36, 33, 32, 32,
-        31, 30,
+        32, 33, 33, 34, 31, 31, 28, 26, 24, 22, 21, 21, 21, 21, 20, 20, 33, 33,
+        32, 32, 29, 28, 26, 25, 24, 22, 22, 22, 23, 23, 22, 22, 31, 30, 30, 29,
+        28, 27, 24, 24, 23, 22, 22, 22, 22, 23, 22, 22, 28, 27, 26, 26, 24, 24,
+        22, 22, 22, 21, 21, 22, 22, 22, 22, 22, 23, 23, 23, 23, 22, 22, 22, 21,
+        21, 20, 20, 20, 20, 20, 20, 20, 21, 22, 22, 22, 22, 22, 22, 21, 20, 20,
+        19, 19, 19, 19, 19, 19, 21, 22, 22, 23, 23, 22, 23, 22, 21, 19, 19, 18,
+        18, 18, 17, 17, 20, 21, 22, 22, 22, 22, 22, 22, 20, 19, 19, 18, 18, 17,
+        17, 17,
         /* Size 16x32 */
-        64, 66, 66, 65, 58, 55, 53, 44, 43, 42, 42, 42, 41, 39, 39, 38, 65, 65,
-        65, 64, 56, 54, 52, 44, 43, 43, 43, 43, 42, 41, 41, 39, 65, 65, 65, 64,
-        55, 53, 51, 45, 44, 44, 44, 44, 42, 41, 41, 39, 66, 65, 65, 64, 55, 53,
-        51, 45, 44, 44, 44, 44, 43, 41, 41, 39, 67, 65, 64, 63, 54, 52, 51, 45,
-        45, 45, 45, 45, 44, 42, 42, 41, 67, 65, 64, 62, 54, 51, 50, 45, 45, 45,
-        45, 45, 44, 43, 43, 41, 66, 63, 62, 61, 53, 51, 49, 45, 45, 45, 45, 45,
-        44, 43, 43, 41, 61, 59, 58, 57, 50, 48, 47, 44, 44, 44, 45, 45, 44, 43,
-        43, 41, 61, 59, 57, 56, 49, 48, 47, 44, 44, 44, 45, 45, 44, 43, 43, 41,
-        59, 56, 55, 55, 48, 46, 46, 44, 44, 44, 45, 45, 44, 43, 43, 42, 55, 53,
-        51, 50, 45, 44, 43, 43, 43, 44, 45, 45, 45, 44, 44, 42, 55, 53, 51, 50,
-        45, 44, 43, 43, 43, 44, 45, 45, 45, 44, 44, 42, 53, 51, 50, 49, 45, 43,
-        43, 42, 42, 43, 44, 44, 43, 42, 42, 41, 49, 48, 48, 47, 44, 43, 43, 41,
-        41, 41, 41, 41, 41, 41, 41, 39, 49, 48, 48, 47, 44, 43, 43, 41, 41, 41,
-        41, 41, 41, 41, 41, 39, 46, 46, 46, 46, 44, 43, 42, 40, 40, 40, 40, 40,
-        39, 39, 39, 38, 42, 43, 44, 44, 43, 43, 42, 39, 39, 39, 38, 38, 38, 38,
-        38, 37, 42, 43, 44, 44, 43, 43, 42, 39, 39, 39, 38, 38, 38, 38, 38, 37,
-        42, 44, 45, 44, 44, 43, 42, 39, 39, 38, 37, 37, 37, 36, 36, 36, 42, 44,
-        45, 45, 44, 44, 43, 39, 39, 38, 37, 37, 36, 36, 36, 35, 42, 44, 45, 45,
-        44, 44, 43, 39, 39, 38, 37, 37, 36, 36, 36, 35, 42, 44, 45, 45, 45, 45,
-        43, 39, 38, 38, 36, 36, 35, 34, 34, 33, 42, 44, 45, 45, 45, 45, 44, 39,
-        38, 37, 35, 35, 34, 33, 33, 33, 42, 44, 45, 45, 45, 45, 44, 39, 38, 37,
-        35, 35, 34, 33, 33, 33, 41, 43, 44, 44, 44, 44, 43, 39, 38, 37, 34, 34,
-        34, 32, 32, 32, 41, 43, 44, 44, 44, 44, 43, 39, 38, 37, 34, 34, 33, 32,
-        32, 31, 40, 43, 44, 44, 44, 44, 43, 39, 38, 37, 34, 34, 33, 32, 32, 31,
-        39, 42, 43, 43, 43, 44, 42, 38, 38, 37, 34, 34, 33, 31, 31, 30, 39, 42,
-        43, 43, 43, 43, 42, 38, 38, 37, 34, 34, 32, 31, 31, 30, 39, 41, 42, 42,
-        43, 43, 42, 38, 38, 36, 33, 33, 32, 31, 31, 29, 38, 40, 41, 41, 42, 42,
-        41, 37, 37, 36, 33, 33, 32, 30, 30, 29, 38, 40, 41, 41, 42, 42, 41, 37,
-        37, 36, 33, 33, 32, 30, 30, 29,
+        32, 33, 33, 33, 31, 28, 28, 27, 23, 21, 21, 21, 21, 21, 20, 20, 33, 33,
+        33, 33, 31, 27, 27, 26, 23, 22, 22, 21, 21, 21, 21, 20, 33, 33, 33, 33,
+        30, 27, 27, 26, 23, 22, 22, 22, 22, 22, 21, 20, 33, 33, 33, 33, 30, 27,
+        27, 26, 23, 22, 22, 22, 22, 22, 21, 20, 33, 33, 32, 32, 30, 26, 26, 26,
+        23, 22, 22, 22, 22, 22, 22, 21, 34, 33, 32, 32, 29, 26, 26, 25, 23, 22,
+        22, 23, 23, 23, 22, 21, 34, 33, 32, 32, 29, 26, 26, 25, 23, 22, 22, 23,
+        23, 23, 22, 21, 33, 32, 31, 31, 29, 26, 26, 25, 23, 22, 22, 23, 23, 23,
+        22, 21, 31, 30, 29, 29, 28, 24, 24, 24, 22, 22, 22, 22, 23, 23, 22, 22,
+        31, 29, 28, 28, 27, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 31, 29,
+        28, 28, 27, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 29, 28, 27, 27,
+        25, 23, 23, 22, 22, 22, 22, 22, 23, 23, 22, 22, 28, 26, 26, 26, 24, 22,
+        22, 22, 22, 22, 22, 22, 23, 23, 22, 22, 28, 26, 26, 26, 24, 22, 22, 22,
+        22, 22, 22, 22, 23, 23, 22, 22, 26, 26, 25, 25, 24, 22, 22, 22, 21, 21,
+        21, 22, 22, 22, 22, 21, 24, 24, 24, 24, 23, 22, 22, 21, 21, 20, 20, 21,
+        21, 21, 20, 20, 24, 24, 24, 24, 23, 22, 22, 21, 21, 20, 20, 21, 21, 21,
+        20, 20, 24, 24, 24, 24, 23, 22, 22, 21, 20, 20, 20, 20, 20, 20, 20, 20,
+        22, 22, 22, 22, 22, 21, 21, 21, 20, 20, 20, 20, 19, 19, 19, 19, 21, 22,
+        22, 22, 22, 21, 21, 21, 20, 19, 19, 19, 19, 19, 19, 19, 21, 22, 22, 22,
+        22, 21, 21, 21, 20, 19, 19, 19, 19, 19, 19, 19, 21, 22, 22, 22, 22, 22,
+        22, 21, 20, 19, 19, 19, 19, 19, 19, 18, 21, 22, 22, 22, 22, 22, 22, 21,
+        20, 19, 19, 19, 18, 18, 18, 18, 21, 22, 22, 22, 22, 22, 22, 21, 20, 19,
+        19, 19, 18, 18, 18, 18, 21, 22, 23, 23, 22, 22, 22, 22, 20, 19, 19, 19,
+        18, 18, 18, 17, 21, 22, 23, 23, 23, 22, 22, 22, 20, 19, 19, 18, 18, 18,
+        17, 17, 21, 22, 23, 23, 23, 22, 22, 22, 20, 19, 19, 18, 18, 18, 17, 17,
+        21, 22, 23, 23, 23, 22, 22, 22, 20, 19, 19, 18, 18, 18, 17, 17, 20, 21,
+        22, 22, 22, 22, 22, 21, 20, 19, 19, 18, 17, 17, 17, 16, 20, 21, 22, 22,
+        22, 22, 22, 21, 20, 19, 19, 18, 17, 17, 17, 16, 20, 21, 22, 22, 22, 22,
+        22, 21, 20, 19, 19, 18, 17, 17, 17, 16, 20, 21, 22, 22, 22, 22, 22, 21,
+        20, 19, 19, 18, 17, 17, 17, 16,
         /* Size 32x16 */
-        64, 65, 65, 66, 67, 67, 66, 61, 61, 59, 55, 55, 53, 49, 49, 46, 42, 42,
-        42, 42, 42, 42, 42, 42, 41, 41, 40, 39, 39, 39, 38, 38, 66, 65, 65, 65,
-        65, 65, 63, 59, 59, 56, 53, 53, 51, 48, 48, 46, 43, 43, 44, 44, 44, 44,
-        44, 44, 43, 43, 43, 42, 42, 41, 40, 40, 66, 65, 65, 65, 64, 64, 62, 58,
-        57, 55, 51, 51, 50, 48, 48, 46, 44, 44, 45, 45, 45, 45, 45, 45, 44, 44,
-        44, 43, 43, 42, 41, 41, 65, 64, 64, 64, 63, 62, 61, 57, 56, 55, 50, 50,
-        49, 47, 47, 46, 44, 44, 44, 45, 45, 45, 45, 45, 44, 44, 44, 43, 43, 42,
-        41, 41, 58, 56, 55, 55, 54, 54, 53, 50, 49, 48, 45, 45, 45, 44, 44, 44,
-        43, 43, 44, 44, 44, 45, 45, 45, 44, 44, 44, 43, 43, 43, 42, 42, 55, 54,
-        53, 53, 52, 51, 51, 48, 48, 46, 44, 44, 43, 43, 43, 43, 43, 43, 43, 44,
-        44, 45, 45, 45, 44, 44, 44, 44, 43, 43, 42, 42, 53, 52, 51, 51, 51, 50,
-        49, 47, 47, 46, 43, 43, 43, 43, 43, 42, 42, 42, 42, 43, 43, 43, 44, 44,
-        43, 43, 43, 42, 42, 42, 41, 41, 44, 44, 45, 45, 45, 45, 45, 44, 44, 44,
-        43, 43, 42, 41, 41, 40, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38,
-        38, 38, 37, 37, 43, 43, 44, 44, 45, 45, 45, 44, 44, 44, 43, 43, 42, 41,
-        41, 40, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 38, 38, 38, 37, 37,
-        42, 43, 44, 44, 45, 45, 45, 44, 44, 44, 44, 44, 43, 41, 41, 40, 39, 39,
-        38, 38, 38, 38, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 42, 43, 44, 44,
-        45, 45, 45, 45, 45, 45, 45, 45, 44, 41, 41, 40, 38, 38, 37, 37, 37, 36,
-        35, 35, 34, 34, 34, 34, 34, 33, 33, 33, 42, 43, 44, 44, 45, 45, 45, 45,
-        45, 45, 45, 45, 44, 41, 41, 40, 38, 38, 37, 37, 37, 36, 35, 35, 34, 34,
-        34, 34, 34, 33, 33, 33, 41, 42, 42, 43, 44, 44, 44, 44, 44, 44, 45, 45,
-        43, 41, 41, 39, 38, 38, 37, 36, 36, 35, 34, 34, 34, 33, 33, 33, 32, 32,
-        32, 32, 39, 41, 41, 41, 42, 43, 43, 43, 43, 43, 44, 44, 42, 41, 41, 39,
-        38, 38, 36, 36, 36, 34, 33, 33, 32, 32, 32, 31, 31, 31, 30, 30, 39, 41,
-        41, 41, 42, 43, 43, 43, 43, 43, 44, 44, 42, 41, 41, 39, 38, 38, 36, 36,
-        36, 34, 33, 33, 32, 32, 32, 31, 31, 31, 30, 30, 38, 39, 39, 39, 41, 41,
-        41, 41, 41, 42, 42, 42, 41, 39, 39, 38, 37, 37, 36, 35, 35, 33, 33, 33,
-        32, 31, 31, 30, 30, 29, 29, 29,
+        32, 33, 33, 33, 33, 34, 34, 33, 31, 31, 31, 29, 28, 28, 26, 24, 24, 24,
+        22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 33, 33, 33, 33,
+        33, 33, 33, 32, 30, 29, 29, 28, 26, 26, 26, 24, 24, 24, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 33, 33, 33, 33, 32, 32, 32, 31,
+        29, 28, 28, 27, 26, 26, 25, 24, 24, 24, 22, 22, 22, 22, 22, 22, 23, 23,
+        23, 23, 22, 22, 22, 22, 33, 33, 33, 33, 32, 32, 32, 31, 29, 28, 28, 27,
+        26, 26, 25, 24, 24, 24, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 22, 22,
+        22, 22, 31, 31, 30, 30, 30, 29, 29, 29, 28, 27, 27, 25, 24, 24, 24, 23,
+        23, 23, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 22, 28, 27,
+        27, 27, 26, 26, 26, 26, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 21, 21,
+        21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 28, 27, 27, 27, 26, 26,
+        26, 26, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 21, 21, 21, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 27, 26, 26, 26, 26, 25, 25, 25, 24, 23,
+        23, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
+        21, 21, 21, 21, 23, 23, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22,
+        21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+        21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20,
+        20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 21, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20, 20, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 21, 21, 22, 22, 22, 23, 23, 23,
+        22, 22, 22, 22, 22, 22, 22, 21, 21, 20, 20, 19, 19, 19, 19, 19, 19, 18,
+        18, 18, 18, 18, 18, 18, 21, 21, 22, 22, 22, 23, 23, 23, 23, 22, 22, 23,
+        23, 23, 22, 21, 21, 20, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 17, 17,
+        17, 17, 21, 21, 22, 22, 22, 23, 23, 23, 23, 22, 22, 23, 23, 23, 22, 21,
+        21, 20, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, 20, 21,
+        21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 20, 20, 20, 19, 19,
+        19, 19, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 20, 20, 20, 20, 21, 21,
+        21, 21, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18,
+        17, 17, 17, 17, 16, 16, 16, 16,
         /* Size 4x16 */
-        66, 55, 42, 39, 65, 53, 44, 41, 65, 52, 45, 42, 63, 51, 45, 43, 59, 48,
-        44, 43, 53, 44, 44, 44, 51, 43, 43, 42, 48, 43, 41, 41, 43, 43, 39, 38,
-        44, 43, 38, 36, 44, 44, 38, 36, 44, 45, 37, 33, 43, 44, 37, 32, 43, 44,
-        37, 32, 42, 43, 37, 31, 40, 42, 36, 30,
+        33, 28, 21, 21, 33, 27, 22, 22, 33, 26, 22, 22, 33, 26, 22, 23, 30, 24,
+        22, 23, 29, 24, 22, 22, 26, 22, 22, 23, 26, 22, 21, 22, 24, 22, 20, 21,
+        22, 21, 20, 19, 22, 21, 19, 19, 22, 22, 19, 18, 22, 22, 19, 18, 22, 22,
+        19, 18, 21, 22, 19, 17, 21, 22, 19, 17,
         /* Size 16x4 */
-        66, 65, 65, 63, 59, 53, 51, 48, 43, 44, 44, 44, 43, 43, 42, 40, 55, 53,
-        52, 51, 48, 44, 43, 43, 43, 43, 44, 45, 44, 44, 43, 42, 42, 44, 45, 45,
-        44, 44, 43, 41, 39, 38, 38, 37, 37, 37, 37, 36, 39, 41, 42, 43, 43, 44,
-        42, 41, 38, 36, 36, 33, 32, 32, 31, 30,
+        33, 33, 33, 33, 30, 29, 26, 26, 24, 22, 22, 22, 22, 22, 21, 21, 28, 27,
+        26, 26, 24, 24, 22, 22, 22, 21, 21, 22, 22, 22, 22, 22, 21, 22, 22, 22,
+        22, 22, 22, 21, 20, 20, 19, 19, 19, 19, 19, 19, 21, 22, 22, 23, 23, 22,
+        23, 22, 21, 19, 19, 18, 18, 18, 17, 17,
         /* Size 8x32 */
-        64, 66, 58, 53, 43, 42, 41, 39, 65, 65, 56, 52, 43, 43, 42, 41, 65, 65,
-        55, 51, 44, 44, 42, 41, 66, 65, 55, 51, 44, 44, 43, 41, 67, 64, 54, 51,
-        45, 45, 44, 42, 67, 64, 54, 50, 45, 45, 44, 43, 66, 62, 53, 49, 45, 45,
-        44, 43, 61, 58, 50, 47, 44, 45, 44, 43, 61, 57, 49, 47, 44, 45, 44, 43,
-        59, 55, 48, 46, 44, 45, 44, 43, 55, 51, 45, 43, 43, 45, 45, 44, 55, 51,
-        45, 43, 43, 45, 45, 44, 53, 50, 45, 43, 42, 44, 43, 42, 49, 48, 44, 43,
-        41, 41, 41, 41, 49, 48, 44, 43, 41, 41, 41, 41, 46, 46, 44, 42, 40, 40,
-        39, 39, 42, 44, 43, 42, 39, 38, 38, 38, 42, 44, 43, 42, 39, 38, 38, 38,
-        42, 45, 44, 42, 39, 37, 37, 36, 42, 45, 44, 43, 39, 37, 36, 36, 42, 45,
-        44, 43, 39, 37, 36, 36, 42, 45, 45, 43, 38, 36, 35, 34, 42, 45, 45, 44,
-        38, 35, 34, 33, 42, 45, 45, 44, 38, 35, 34, 33, 41, 44, 44, 43, 38, 34,
-        34, 32, 41, 44, 44, 43, 38, 34, 33, 32, 40, 44, 44, 43, 38, 34, 33, 32,
-        39, 43, 43, 42, 38, 34, 33, 31, 39, 43, 43, 42, 38, 34, 32, 31, 39, 42,
-        43, 42, 38, 33, 32, 31, 38, 41, 42, 41, 37, 33, 32, 30, 38, 41, 42, 41,
-        37, 33, 32, 30,
+        32, 33, 31, 28, 23, 21, 21, 20, 33, 33, 31, 27, 23, 22, 21, 21, 33, 33,
+        30, 27, 23, 22, 22, 21, 33, 33, 30, 27, 23, 22, 22, 21, 33, 32, 30, 26,
+        23, 22, 22, 22, 34, 32, 29, 26, 23, 22, 23, 22, 34, 32, 29, 26, 23, 22,
+        23, 22, 33, 31, 29, 26, 23, 22, 23, 22, 31, 29, 28, 24, 22, 22, 23, 22,
+        31, 28, 27, 24, 22, 22, 22, 22, 31, 28, 27, 24, 22, 22, 22, 22, 29, 27,
+        25, 23, 22, 22, 23, 22, 28, 26, 24, 22, 22, 22, 23, 22, 28, 26, 24, 22,
+        22, 22, 23, 22, 26, 25, 24, 22, 21, 21, 22, 22, 24, 24, 23, 22, 21, 20,
+        21, 20, 24, 24, 23, 22, 21, 20, 21, 20, 24, 24, 23, 22, 20, 20, 20, 20,
+        22, 22, 22, 21, 20, 20, 19, 19, 21, 22, 22, 21, 20, 19, 19, 19, 21, 22,
+        22, 21, 20, 19, 19, 19, 21, 22, 22, 22, 20, 19, 19, 19, 21, 22, 22, 22,
+        20, 19, 18, 18, 21, 22, 22, 22, 20, 19, 18, 18, 21, 23, 22, 22, 20, 19,
+        18, 18, 21, 23, 23, 22, 20, 19, 18, 17, 21, 23, 23, 22, 20, 19, 18, 17,
+        21, 23, 23, 22, 20, 19, 18, 17, 20, 22, 22, 22, 20, 19, 17, 17, 20, 22,
+        22, 22, 20, 19, 17, 17, 20, 22, 22, 22, 20, 19, 17, 17, 20, 22, 22, 22,
+        20, 19, 17, 17,
         /* Size 32x8 */
-        64, 65, 65, 66, 67, 67, 66, 61, 61, 59, 55, 55, 53, 49, 49, 46, 42, 42,
-        42, 42, 42, 42, 42, 42, 41, 41, 40, 39, 39, 39, 38, 38, 66, 65, 65, 65,
-        64, 64, 62, 58, 57, 55, 51, 51, 50, 48, 48, 46, 44, 44, 45, 45, 45, 45,
-        45, 45, 44, 44, 44, 43, 43, 42, 41, 41, 58, 56, 55, 55, 54, 54, 53, 50,
-        49, 48, 45, 45, 45, 44, 44, 44, 43, 43, 44, 44, 44, 45, 45, 45, 44, 44,
-        44, 43, 43, 43, 42, 42, 53, 52, 51, 51, 51, 50, 49, 47, 47, 46, 43, 43,
-        43, 43, 43, 42, 42, 42, 42, 43, 43, 43, 44, 44, 43, 43, 43, 42, 42, 42,
-        41, 41, 43, 43, 44, 44, 45, 45, 45, 44, 44, 44, 43, 43, 42, 41, 41, 40,
-        39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 38, 38, 38, 37, 37, 42, 43,
-        44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 44, 41, 41, 40, 38, 38, 37, 37,
-        37, 36, 35, 35, 34, 34, 34, 34, 34, 33, 33, 33, 41, 42, 42, 43, 44, 44,
-        44, 44, 44, 44, 45, 45, 43, 41, 41, 39, 38, 38, 37, 36, 36, 35, 34, 34,
-        34, 33, 33, 33, 32, 32, 32, 32, 39, 41, 41, 41, 42, 43, 43, 43, 43, 43,
-        44, 44, 42, 41, 41, 39, 38, 38, 36, 36, 36, 34, 33, 33, 32, 32, 32, 31,
-        31, 31, 30, 30 },
+        32, 33, 33, 33, 33, 34, 34, 33, 31, 31, 31, 29, 28, 28, 26, 24, 24, 24,
+        22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 33, 33, 33, 33,
+        32, 32, 32, 31, 29, 28, 28, 27, 26, 26, 25, 24, 24, 24, 22, 22, 22, 22,
+        22, 22, 23, 23, 23, 23, 22, 22, 22, 22, 31, 31, 30, 30, 30, 29, 29, 29,
+        28, 27, 27, 25, 24, 24, 24, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 23,
+        23, 23, 22, 22, 22, 22, 28, 27, 27, 27, 26, 26, 26, 26, 24, 24, 24, 23,
+        22, 22, 22, 22, 22, 22, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 21, 21,
+        21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20, 20, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 21, 21, 22, 22, 22, 23,
+        23, 23, 23, 22, 22, 23, 23, 23, 22, 21, 21, 20, 19, 19, 19, 19, 18, 18,
+        18, 18, 18, 18, 17, 17, 17, 17, 20, 21, 21, 21, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 20, 20, 20, 19, 19, 19, 19, 18, 18, 18, 17, 17, 17,
+        17, 17, 17, 17 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        63, 54, 54, 38,
-#endif
-        /* Size 4x4 */
-        64, 63, 59, 48, 63, 59, 55, 48, 59, 55, 42, 38, 48, 48, 38, 32,
-        /* Size 8x8 */
-        65, 65, 64, 64, 60, 55, 48, 44, 65, 63, 63, 63, 60, 57, 50, 46, 64, 63,
-        61, 60, 58, 54, 49, 45, 64, 63, 60, 58, 55, 52, 48, 45, 60, 60, 58, 55,
-        50, 46, 42, 39, 55, 57, 54, 52, 46, 40, 37, 34, 48, 50, 49, 48, 42, 37,
-        32, 31, 44, 46, 45, 45, 39, 34, 31, 29,
-        /* Size 16x16 */
-        64, 65, 65, 65, 65, 65, 64, 63, 60, 58, 57, 52, 50, 47, 43, 42, 65, 64,
-        64, 64, 64, 64, 63, 62, 60, 59, 59, 53, 51, 48, 45, 44, 65, 64, 64, 64,
-        63, 63, 63, 62, 60, 59, 59, 54, 52, 49, 46, 45, 65, 64, 64, 63, 63, 63,
-        63, 62, 61, 60, 59, 55, 53, 50, 47, 46, 65, 64, 63, 63, 62, 62, 61, 60,
-        59, 57, 57, 53, 51, 49, 46, 45, 65, 64, 63, 63, 62, 61, 60, 59, 58, 57,
-        56, 53, 51, 49, 46, 45, 64, 63, 63, 63, 61, 60, 58, 57, 55, 54, 53, 51,
-        49, 48, 46, 45, 63, 62, 62, 62, 60, 59, 57, 56, 54, 52, 51, 49, 48, 46,
-        44, 43, 60, 60, 60, 61, 59, 58, 55, 54, 52, 49, 48, 46, 45, 43, 41, 40,
-        58, 59, 59, 60, 57, 57, 54, 52, 49, 45, 44, 41, 41, 39, 37, 37, 57, 59,
-        59, 59, 57, 56, 53, 51, 48, 44, 42, 41, 39, 38, 37, 36, 52, 53, 54, 55,
-        53, 53, 51, 49, 46, 41, 41, 38, 37, 35, 34, 34, 50, 51, 52, 53, 51, 51,
-        49, 48, 45, 41, 39, 37, 36, 34, 33, 32, 47, 48, 49, 50, 49, 49, 48, 46,
-        43, 39, 38, 35, 34, 32, 31, 31, 43, 45, 46, 47, 46, 46, 46, 44, 41, 37,
-        37, 34, 33, 31, 29, 29, 42, 44, 45, 46, 45, 45, 45, 43, 40, 37, 36, 34,
-        32, 31, 29, 29,
-        /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 63, 60, 60, 60,
-        58, 57, 57, 54, 52, 52, 50, 47, 47, 46, 43, 42, 42, 40, 65, 65, 65, 65,
-        65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 62, 60, 60, 60, 59, 58, 58, 55,
-        53, 53, 51, 48, 48, 47, 44, 44, 44, 41, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 63, 63, 63, 62, 60, 60, 60, 59, 59, 59, 55, 53, 53, 51, 48,
-        48, 48, 45, 44, 44, 41, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63,
-        63, 63, 62, 60, 60, 60, 59, 59, 59, 55, 53, 53, 51, 48, 48, 48, 45, 44,
-        44, 41, 65, 65, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 62, 60,
-        60, 60, 59, 59, 59, 56, 54, 54, 52, 49, 49, 48, 46, 45, 45, 42, 65, 65,
-        64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 61, 60, 60, 59,
-        59, 57, 55, 55, 53, 50, 50, 49, 47, 46, 46, 43, 65, 65, 64, 64, 64, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 61, 60, 60, 59, 59, 57, 55, 55,
-        53, 50, 50, 49, 47, 46, 46, 43, 65, 64, 64, 64, 64, 63, 63, 63, 63, 63,
-        63, 62, 62, 62, 61, 60, 60, 60, 59, 59, 59, 56, 54, 54, 53, 50, 50, 49,
-        47, 46, 46, 43, 65, 64, 64, 64, 63, 63, 63, 63, 62, 62, 62, 61, 61, 61,
-        60, 59, 59, 59, 57, 57, 57, 55, 53, 53, 51, 49, 49, 48, 46, 45, 45, 43,
-        65, 64, 64, 64, 63, 63, 63, 63, 62, 61, 61, 61, 60, 60, 59, 58, 58, 58,
-        57, 56, 56, 54, 53, 53, 51, 49, 49, 48, 46, 45, 45, 43, 65, 64, 64, 64,
-        63, 63, 63, 63, 62, 61, 61, 61, 60, 60, 59, 58, 58, 58, 57, 56, 56, 54,
-        53, 53, 51, 49, 49, 48, 46, 45, 45, 43, 64, 64, 63, 63, 63, 63, 63, 62,
-        61, 61, 61, 59, 59, 59, 58, 57, 57, 56, 55, 55, 55, 53, 51, 51, 50, 48,
-        48, 48, 46, 45, 45, 43, 64, 64, 63, 63, 63, 63, 63, 62, 61, 60, 60, 59,
-        58, 58, 57, 55, 55, 55, 54, 53, 53, 52, 51, 51, 49, 48, 48, 47, 46, 45,
-        45, 43, 64, 64, 63, 63, 63, 63, 63, 62, 61, 60, 60, 59, 58, 58, 57, 55,
-        55, 55, 54, 53, 53, 52, 51, 51, 49, 48, 48, 47, 46, 45, 45, 43, 63, 62,
-        62, 62, 62, 62, 62, 61, 60, 59, 59, 58, 57, 57, 56, 54, 54, 54, 52, 51,
-        51, 50, 49, 49, 48, 46, 46, 46, 44, 43, 43, 41, 60, 60, 60, 60, 60, 61,
-        61, 60, 59, 58, 58, 57, 55, 55, 54, 52, 52, 51, 49, 48, 48, 47, 46, 46,
-        45, 43, 43, 42, 41, 40, 40, 39, 60, 60, 60, 60, 60, 61, 61, 60, 59, 58,
-        58, 57, 55, 55, 54, 52, 52, 51, 49, 48, 48, 47, 46, 46, 45, 43, 43, 42,
-        41, 40, 40, 39, 60, 60, 60, 60, 60, 60, 60, 60, 59, 58, 58, 56, 55, 55,
-        54, 51, 51, 50, 48, 47, 47, 46, 45, 45, 44, 42, 42, 41, 40, 39, 39, 38,
-        58, 59, 59, 59, 59, 60, 60, 59, 57, 57, 57, 55, 54, 54, 52, 49, 49, 48,
-        45, 44, 44, 42, 41, 41, 41, 39, 39, 39, 37, 37, 37, 36, 57, 58, 59, 59,
-        59, 59, 59, 59, 57, 56, 56, 55, 53, 53, 51, 48, 48, 47, 44, 42, 42, 41,
-        41, 41, 39, 38, 38, 38, 37, 36, 36, 35, 57, 58, 59, 59, 59, 59, 59, 59,
-        57, 56, 56, 55, 53, 53, 51, 48, 48, 47, 44, 42, 42, 41, 41, 41, 39, 38,
-        38, 38, 37, 36, 36, 35, 54, 55, 55, 55, 56, 57, 57, 56, 55, 54, 54, 53,
-        52, 52, 50, 47, 47, 46, 42, 41, 41, 40, 39, 39, 38, 37, 37, 36, 35, 34,
-        34, 33, 52, 53, 53, 53, 54, 55, 55, 54, 53, 53, 53, 51, 51, 51, 49, 46,
-        46, 45, 41, 41, 41, 39, 38, 38, 37, 35, 35, 35, 34, 34, 34, 32, 52, 53,
-        53, 53, 54, 55, 55, 54, 53, 53, 53, 51, 51, 51, 49, 46, 46, 45, 41, 41,
-        41, 39, 38, 38, 37, 35, 35, 35, 34, 34, 34, 32, 50, 51, 51, 51, 52, 53,
-        53, 53, 51, 51, 51, 50, 49, 49, 48, 45, 45, 44, 41, 39, 39, 38, 37, 37,
-        36, 34, 34, 34, 33, 32, 32, 31, 47, 48, 48, 48, 49, 50, 50, 50, 49, 49,
-        49, 48, 48, 48, 46, 43, 43, 42, 39, 38, 38, 37, 35, 35, 34, 32, 32, 32,
-        31, 31, 31, 29, 47, 48, 48, 48, 49, 50, 50, 50, 49, 49, 49, 48, 48, 48,
-        46, 43, 43, 42, 39, 38, 38, 37, 35, 35, 34, 32, 32, 32, 31, 31, 31, 29,
-        46, 47, 48, 48, 48, 49, 49, 49, 48, 48, 48, 48, 47, 47, 46, 42, 42, 41,
-        39, 38, 38, 36, 35, 35, 34, 32, 32, 32, 31, 30, 30, 29, 43, 44, 45, 45,
-        46, 47, 47, 47, 46, 46, 46, 46, 46, 46, 44, 41, 41, 40, 37, 37, 37, 35,
-        34, 34, 33, 31, 31, 31, 29, 29, 29, 28, 42, 44, 44, 44, 45, 46, 46, 46,
-        45, 45, 45, 45, 45, 45, 43, 40, 40, 39, 37, 36, 36, 34, 34, 34, 32, 31,
-        31, 30, 29, 29, 29, 28, 42, 44, 44, 44, 45, 46, 46, 46, 45, 45, 45, 45,
-        45, 45, 43, 40, 40, 39, 37, 36, 36, 34, 34, 34, 32, 31, 31, 30, 29, 29,
-        29, 28, 40, 41, 41, 41, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 41, 39,
-        39, 38, 36, 35, 35, 33, 32, 32, 31, 29, 29, 29, 28, 28, 28, 26,
-        /* Size 4x8 */
-        65, 63, 58, 48, 64, 62, 59, 50, 63, 60, 56, 49, 63, 58, 53, 48, 60, 55,
-        47, 42, 55, 51, 41, 37, 49, 48, 38, 33, 45, 44, 36, 31,
-        /* Size 8x4 */
-        65, 64, 63, 63, 60, 55, 49, 45, 63, 62, 60, 58, 55, 51, 48, 44, 58, 59,
-        56, 53, 47, 41, 38, 36, 48, 50, 49, 48, 42, 37, 33, 31,
-        /* Size 8x16 */
-        64, 65, 65, 64, 59, 57, 47, 43, 65, 64, 64, 63, 59, 58, 48, 45, 65, 64,
-        63, 63, 59, 59, 49, 46, 65, 63, 63, 62, 60, 59, 50, 47, 65, 63, 62, 60,
-        58, 57, 49, 46, 64, 63, 62, 60, 57, 56, 49, 46, 64, 62, 60, 58, 55, 53,
-        48, 46, 63, 62, 59, 57, 53, 51, 46, 44, 60, 60, 59, 55, 49, 48, 43, 41,
-        58, 59, 57, 54, 46, 44, 39, 37, 57, 59, 57, 53, 45, 43, 38, 37, 52, 55,
-        53, 51, 43, 41, 35, 34, 50, 53, 51, 49, 41, 40, 34, 33, 47, 50, 49, 48,
-        40, 38, 33, 31, 44, 47, 46, 45, 38, 37, 31, 29, 43, 46, 45, 44, 38, 36,
-        31, 29,
-        /* Size 16x8 */
-        64, 65, 65, 65, 65, 64, 64, 63, 60, 58, 57, 52, 50, 47, 44, 43, 65, 64,
-        64, 63, 63, 63, 62, 62, 60, 59, 59, 55, 53, 50, 47, 46, 65, 64, 63, 63,
-        62, 62, 60, 59, 59, 57, 57, 53, 51, 49, 46, 45, 64, 63, 63, 62, 60, 60,
-        58, 57, 55, 54, 53, 51, 49, 48, 45, 44, 59, 59, 59, 60, 58, 57, 55, 53,
-        49, 46, 45, 43, 41, 40, 38, 38, 57, 58, 59, 59, 57, 56, 53, 51, 48, 44,
-        43, 41, 40, 38, 37, 36, 47, 48, 49, 50, 49, 49, 48, 46, 43, 39, 38, 35,
-        34, 33, 31, 31, 43, 45, 46, 47, 46, 46, 46, 44, 41, 37, 37, 34, 33, 31,
-        29, 29,
-        /* Size 16x32 */
-        64, 65, 65, 65, 65, 64, 64, 63, 59, 57, 57, 51, 47, 47, 43, 38, 65, 65,
-        64, 64, 64, 63, 63, 62, 59, 58, 58, 52, 48, 48, 44, 39, 65, 64, 64, 64,
-        64, 63, 63, 62, 59, 58, 58, 52, 48, 48, 45, 40, 65, 64, 64, 64, 64, 63,
-        63, 62, 59, 58, 58, 52, 48, 48, 45, 40, 65, 64, 64, 64, 63, 63, 63, 62,
-        59, 59, 59, 53, 49, 49, 46, 41, 65, 64, 63, 63, 63, 62, 62, 62, 60, 59,
-        59, 54, 50, 50, 47, 41, 65, 64, 63, 63, 63, 62, 62, 62, 60, 59, 59, 54,
-        50, 50, 47, 41, 65, 64, 63, 63, 63, 62, 62, 61, 59, 59, 59, 53, 50, 50,
-        47, 41, 65, 64, 63, 63, 62, 60, 60, 59, 58, 57, 57, 52, 49, 49, 46, 41,
-        64, 63, 63, 63, 62, 60, 60, 59, 57, 56, 56, 52, 49, 49, 46, 41, 64, 63,
-        63, 63, 62, 60, 60, 59, 57, 56, 56, 52, 49, 49, 46, 41, 64, 63, 63, 63,
-        61, 59, 59, 58, 55, 55, 55, 51, 48, 48, 46, 41, 64, 63, 62, 62, 60, 58,
-        58, 57, 55, 53, 53, 50, 48, 48, 46, 41, 64, 63, 62, 62, 60, 58, 58, 57,
-        55, 53, 53, 50, 48, 48, 46, 41, 63, 62, 62, 62, 59, 57, 57, 56, 53, 51,
-        51, 48, 46, 46, 44, 40, 60, 60, 60, 60, 59, 55, 55, 54, 49, 48, 48, 45,
-        43, 43, 41, 38, 60, 60, 60, 60, 59, 55, 55, 54, 49, 48, 48, 45, 43, 43,
-        41, 38, 60, 60, 60, 60, 59, 55, 55, 53, 49, 47, 47, 44, 42, 42, 40, 37,
-        58, 59, 59, 59, 57, 54, 54, 52, 46, 44, 44, 41, 39, 39, 37, 35, 57, 59,
-        59, 59, 57, 53, 53, 51, 45, 43, 43, 40, 38, 38, 37, 34, 57, 59, 59, 59,
-        57, 53, 53, 51, 45, 43, 43, 40, 38, 38, 37, 34, 54, 55, 56, 56, 55, 51,
-        51, 49, 44, 41, 41, 38, 37, 37, 35, 33, 52, 53, 55, 55, 53, 51, 51, 48,
-        43, 41, 41, 38, 35, 35, 34, 32, 52, 53, 55, 55, 53, 51, 51, 48, 43, 41,
-        41, 38, 35, 35, 34, 32, 50, 51, 53, 53, 51, 49, 49, 47, 41, 40, 40, 36,
-        34, 34, 33, 30, 47, 49, 50, 50, 49, 48, 48, 46, 40, 38, 38, 35, 33, 33,
-        31, 29, 47, 49, 50, 50, 49, 48, 48, 46, 40, 38, 38, 35, 33, 33, 31, 29,
-        46, 48, 49, 49, 48, 47, 47, 45, 40, 38, 38, 34, 32, 32, 31, 28, 44, 45,
-        47, 47, 46, 45, 45, 43, 38, 37, 37, 33, 31, 31, 29, 27, 43, 45, 46, 46,
-        45, 44, 44, 43, 38, 36, 36, 33, 31, 31, 29, 27, 43, 45, 46, 46, 45, 44,
-        44, 43, 38, 36, 36, 33, 31, 31, 29, 27, 40, 42, 43, 43, 43, 42, 42, 41,
-        37, 35, 35, 32, 29, 29, 28, 26,
-        /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 63, 60, 60, 60,
-        58, 57, 57, 54, 52, 52, 50, 47, 47, 46, 44, 43, 43, 40, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 62, 60, 60, 60, 59, 59, 59, 55,
-        53, 53, 51, 49, 49, 48, 45, 45, 45, 42, 65, 64, 64, 64, 64, 63, 63, 63,
-        63, 63, 63, 63, 62, 62, 62, 60, 60, 60, 59, 59, 59, 56, 55, 55, 53, 50,
-        50, 49, 47, 46, 46, 43, 65, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63,
-        62, 62, 62, 60, 60, 60, 59, 59, 59, 56, 55, 55, 53, 50, 50, 49, 47, 46,
-        46, 43, 65, 64, 64, 64, 63, 63, 63, 63, 62, 62, 62, 61, 60, 60, 59, 59,
-        59, 59, 57, 57, 57, 55, 53, 53, 51, 49, 49, 48, 46, 45, 45, 43, 64, 63,
-        63, 63, 63, 62, 62, 62, 60, 60, 60, 59, 58, 58, 57, 55, 55, 55, 54, 53,
-        53, 51, 51, 51, 49, 48, 48, 47, 45, 44, 44, 42, 64, 63, 63, 63, 63, 62,
-        62, 62, 60, 60, 60, 59, 58, 58, 57, 55, 55, 55, 54, 53, 53, 51, 51, 51,
-        49, 48, 48, 47, 45, 44, 44, 42, 63, 62, 62, 62, 62, 62, 62, 61, 59, 59,
-        59, 58, 57, 57, 56, 54, 54, 53, 52, 51, 51, 49, 48, 48, 47, 46, 46, 45,
-        43, 43, 43, 41, 59, 59, 59, 59, 59, 60, 60, 59, 58, 57, 57, 55, 55, 55,
-        53, 49, 49, 49, 46, 45, 45, 44, 43, 43, 41, 40, 40, 40, 38, 38, 38, 37,
-        57, 58, 58, 58, 59, 59, 59, 59, 57, 56, 56, 55, 53, 53, 51, 48, 48, 47,
-        44, 43, 43, 41, 41, 41, 40, 38, 38, 38, 37, 36, 36, 35, 57, 58, 58, 58,
-        59, 59, 59, 59, 57, 56, 56, 55, 53, 53, 51, 48, 48, 47, 44, 43, 43, 41,
-        41, 41, 40, 38, 38, 38, 37, 36, 36, 35, 51, 52, 52, 52, 53, 54, 54, 53,
-        52, 52, 52, 51, 50, 50, 48, 45, 45, 44, 41, 40, 40, 38, 38, 38, 36, 35,
-        35, 34, 33, 33, 33, 32, 47, 48, 48, 48, 49, 50, 50, 50, 49, 49, 49, 48,
-        48, 48, 46, 43, 43, 42, 39, 38, 38, 37, 35, 35, 34, 33, 33, 32, 31, 31,
-        31, 29, 47, 48, 48, 48, 49, 50, 50, 50, 49, 49, 49, 48, 48, 48, 46, 43,
-        43, 42, 39, 38, 38, 37, 35, 35, 34, 33, 33, 32, 31, 31, 31, 29, 43, 44,
-        45, 45, 46, 47, 47, 47, 46, 46, 46, 46, 46, 46, 44, 41, 41, 40, 37, 37,
-        37, 35, 34, 34, 33, 31, 31, 31, 29, 29, 29, 28, 38, 39, 40, 40, 41, 41,
-        41, 41, 41, 41, 41, 41, 41, 41, 40, 38, 38, 37, 35, 34, 34, 33, 32, 32,
-        30, 29, 29, 28, 27, 27, 27, 26,
-        /* Size 4x16 */
-        65, 64, 57, 47, 64, 63, 58, 48, 64, 63, 59, 49, 64, 62, 59, 50, 64, 60,
-        57, 49, 63, 60, 56, 49, 63, 58, 53, 48, 62, 57, 51, 46, 60, 55, 48, 43,
-        59, 54, 44, 39, 59, 53, 43, 38, 53, 51, 41, 35, 51, 49, 40, 34, 49, 48,
-        38, 33, 45, 45, 37, 31, 45, 44, 36, 31,
-        /* Size 16x4 */
-        65, 64, 64, 64, 64, 63, 63, 62, 60, 59, 59, 53, 51, 49, 45, 45, 64, 63,
-        63, 62, 60, 60, 58, 57, 55, 54, 53, 51, 49, 48, 45, 44, 57, 58, 59, 59,
-        57, 56, 53, 51, 48, 44, 43, 41, 40, 38, 37, 36, 47, 48, 49, 50, 49, 49,
-        48, 46, 43, 39, 38, 35, 34, 33, 31, 31,
-        /* Size 8x32 */
-        64, 65, 65, 64, 59, 57, 47, 43, 65, 64, 64, 63, 59, 58, 48, 44, 65, 64,
-        64, 63, 59, 58, 48, 45, 65, 64, 64, 63, 59, 58, 48, 45, 65, 64, 63, 63,
-        59, 59, 49, 46, 65, 63, 63, 62, 60, 59, 50, 47, 65, 63, 63, 62, 60, 59,
-        50, 47, 65, 63, 63, 62, 59, 59, 50, 47, 65, 63, 62, 60, 58, 57, 49, 46,
-        64, 63, 62, 60, 57, 56, 49, 46, 64, 63, 62, 60, 57, 56, 49, 46, 64, 63,
-        61, 59, 55, 55, 48, 46, 64, 62, 60, 58, 55, 53, 48, 46, 64, 62, 60, 58,
-        55, 53, 48, 46, 63, 62, 59, 57, 53, 51, 46, 44, 60, 60, 59, 55, 49, 48,
-        43, 41, 60, 60, 59, 55, 49, 48, 43, 41, 60, 60, 59, 55, 49, 47, 42, 40,
-        58, 59, 57, 54, 46, 44, 39, 37, 57, 59, 57, 53, 45, 43, 38, 37, 57, 59,
-        57, 53, 45, 43, 38, 37, 54, 56, 55, 51, 44, 41, 37, 35, 52, 55, 53, 51,
-        43, 41, 35, 34, 52, 55, 53, 51, 43, 41, 35, 34, 50, 53, 51, 49, 41, 40,
-        34, 33, 47, 50, 49, 48, 40, 38, 33, 31, 47, 50, 49, 48, 40, 38, 33, 31,
-        46, 49, 48, 47, 40, 38, 32, 31, 44, 47, 46, 45, 38, 37, 31, 29, 43, 46,
-        45, 44, 38, 36, 31, 29, 43, 46, 45, 44, 38, 36, 31, 29, 40, 43, 43, 42,
-        37, 35, 29, 28,
-        /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 63, 60, 60, 60,
-        58, 57, 57, 54, 52, 52, 50, 47, 47, 46, 44, 43, 43, 40, 65, 64, 64, 64,
-        64, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 60, 60, 60, 59, 59, 59, 56,
-        55, 55, 53, 50, 50, 49, 47, 46, 46, 43, 65, 64, 64, 64, 63, 63, 63, 63,
-        62, 62, 62, 61, 60, 60, 59, 59, 59, 59, 57, 57, 57, 55, 53, 53, 51, 49,
-        49, 48, 46, 45, 45, 43, 64, 63, 63, 63, 63, 62, 62, 62, 60, 60, 60, 59,
-        58, 58, 57, 55, 55, 55, 54, 53, 53, 51, 51, 51, 49, 48, 48, 47, 45, 44,
-        44, 42, 59, 59, 59, 59, 59, 60, 60, 59, 58, 57, 57, 55, 55, 55, 53, 49,
-        49, 49, 46, 45, 45, 44, 43, 43, 41, 40, 40, 40, 38, 38, 38, 37, 57, 58,
-        58, 58, 59, 59, 59, 59, 57, 56, 56, 55, 53, 53, 51, 48, 48, 47, 44, 43,
-        43, 41, 41, 41, 40, 38, 38, 38, 37, 36, 36, 35, 47, 48, 48, 48, 49, 50,
-        50, 50, 49, 49, 49, 48, 48, 48, 46, 43, 43, 42, 39, 38, 38, 37, 35, 35,
-        34, 33, 33, 32, 31, 31, 31, 29, 43, 44, 45, 45, 46, 47, 47, 47, 46, 46,
-        46, 46, 46, 46, 44, 41, 41, 40, 37, 37, 37, 35, 34, 34, 33, 31, 31, 31,
-        29, 29, 29, 28 },
-      { /* Chroma */
-#if CONFIG_CB4X4
-        /* Size 2x2 */
-        62, 45, 45, 38,
+        32, 30, 30, 21,
 #endif
         /* Size 4x4 */
-        65, 55, 43, 44, 55, 47, 43, 45, 43, 43, 39, 38, 44, 45, 38, 35,
+        32, 32, 30, 27, 32, 31, 29, 26, 30, 29, 26, 23, 27, 26, 23, 19,
         /* Size 8x8 */
-        65, 66, 60, 55, 48, 43, 43, 41, 66, 64, 58, 51, 47, 45, 46, 44, 60, 58,
-        53, 47, 45, 44, 45, 44, 55, 51, 47, 43, 43, 44, 45, 45, 48, 47, 45, 43,
-        41, 41, 41, 41, 43, 45, 44, 44, 41, 38, 37, 37, 43, 46, 45, 45, 41, 37,
-        35, 34, 41, 44, 44, 45, 41, 37, 34, 33,
+        33, 33, 32, 32, 31, 30, 28, 25, 33, 32, 32, 32, 31, 30, 28, 26, 32, 32,
+        32, 31, 30, 29, 28, 26, 32, 32, 31, 30, 29, 28, 27, 25, 31, 31, 30, 29,
+        28, 26, 25, 23, 30, 30, 29, 28, 26, 24, 22, 21, 28, 28, 28, 27, 25, 22,
+        20, 19, 25, 26, 26, 25, 23, 21, 19, 18,
         /* Size 16x16 */
-        64, 66, 66, 67, 62, 61, 56, 53, 49, 43, 42, 42, 42, 42, 41, 41, 66, 65,
-        65, 66, 60, 59, 53, 51, 48, 44, 43, 44, 44, 44, 43, 42, 66, 65, 65, 65,
-        60, 59, 53, 51, 48, 45, 44, 44, 44, 45, 43, 43, 67, 66, 65, 64, 59, 58,
-        51, 50, 48, 45, 44, 45, 45, 46, 45, 44, 62, 60, 60, 59, 55, 53, 48, 47,
-        46, 44, 44, 45, 45, 45, 44, 44, 61, 59, 59, 58, 53, 53, 47, 47, 46, 44,
-        43, 44, 45, 45, 44, 44, 56, 53, 53, 51, 48, 47, 43, 43, 43, 43, 43, 44,
-        45, 45, 45, 45, 53, 51, 51, 50, 47, 47, 43, 43, 43, 42, 42, 43, 43, 44,
-        43, 43, 49, 48, 48, 48, 46, 46, 43, 43, 42, 41, 41, 41, 41, 42, 41, 41,
-        43, 44, 45, 45, 44, 44, 43, 42, 41, 39, 39, 39, 39, 39, 39, 39, 42, 43,
-        44, 44, 44, 43, 43, 42, 41, 39, 39, 39, 38, 38, 38, 38, 42, 44, 44, 45,
-        45, 44, 44, 43, 41, 39, 39, 38, 37, 37, 36, 36, 42, 44, 44, 45, 45, 45,
-        45, 43, 41, 39, 38, 37, 37, 36, 36, 35, 42, 44, 45, 46, 45, 45, 45, 44,
-        42, 39, 38, 37, 36, 35, 34, 34, 41, 43, 43, 45, 44, 44, 45, 43, 41, 39,
-        38, 36, 36, 34, 34, 34, 41, 42, 43, 44, 44, 44, 45, 43, 41, 39, 38, 36,
-        35, 34, 34, 33,
+        32, 33, 33, 33, 33, 33, 33, 32, 32, 30, 30, 28, 28, 26, 26, 23, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 30, 30, 29, 29, 27, 27, 24, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 30, 30, 29, 29, 27, 27, 24, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 30, 30, 28, 28, 25, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 30, 30, 28, 28, 25, 33, 32, 32, 32, 32, 31, 31, 30, 30, 29,
+        29, 28, 28, 26, 26, 24, 33, 32, 32, 32, 32, 31, 31, 30, 30, 29, 29, 28,
+        28, 26, 26, 24, 32, 32, 32, 32, 32, 30, 30, 29, 29, 28, 28, 27, 27, 26,
+        26, 24, 32, 32, 32, 32, 32, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 24,
+        30, 30, 30, 31, 31, 29, 29, 28, 28, 26, 26, 24, 24, 23, 23, 22, 30, 30,
+        30, 31, 31, 29, 29, 28, 28, 26, 26, 24, 24, 23, 23, 22, 28, 29, 29, 30,
+        30, 28, 28, 27, 27, 24, 24, 21, 21, 20, 20, 19, 28, 29, 29, 30, 30, 28,
+        28, 27, 27, 24, 24, 21, 21, 20, 20, 19, 26, 27, 27, 28, 28, 26, 26, 26,
+        26, 23, 23, 20, 20, 19, 19, 18, 26, 27, 27, 28, 28, 26, 26, 26, 26, 23,
+        23, 20, 20, 19, 19, 18, 23, 24, 24, 25, 25, 24, 24, 24, 24, 22, 22, 19,
+        19, 18, 18, 16,
         /* Size 32x32 */
-        64, 65, 66, 66, 66, 67, 67, 66, 62, 61, 61, 58, 56, 56, 53, 49, 49, 48,
-        43, 42, 42, 42, 42, 42, 42, 42, 42, 41, 41, 41, 41, 40, 65, 65, 65, 65,
-        66, 66, 66, 65, 61, 60, 60, 57, 55, 55, 52, 49, 49, 48, 44, 43, 43, 43,
-        43, 43, 43, 43, 43, 43, 42, 41, 41, 41, 66, 65, 65, 65, 65, 66, 66, 64,
-        60, 59, 59, 55, 53, 53, 51, 48, 48, 47, 44, 43, 43, 43, 44, 44, 44, 44,
-        44, 44, 43, 42, 42, 41, 66, 65, 65, 65, 65, 66, 66, 64, 60, 59, 59, 55,
-        53, 53, 51, 48, 48, 47, 44, 43, 43, 43, 44, 44, 44, 44, 44, 44, 43, 42,
-        42, 41, 66, 66, 65, 65, 65, 65, 65, 64, 60, 59, 59, 55, 53, 53, 51, 48,
-        48, 47, 45, 44, 44, 44, 44, 44, 44, 45, 45, 44, 43, 43, 43, 42, 67, 66,
-        66, 66, 65, 64, 64, 63, 59, 58, 58, 54, 51, 51, 50, 48, 48, 47, 45, 44,
-        44, 45, 45, 45, 45, 46, 46, 45, 45, 44, 44, 44, 67, 66, 66, 66, 65, 64,
-        64, 63, 59, 58, 58, 54, 51, 51, 50, 48, 48, 47, 45, 44, 44, 45, 45, 45,
-        45, 46, 46, 45, 45, 44, 44, 44, 66, 65, 64, 64, 64, 63, 63, 62, 58, 57,
-        57, 53, 51, 51, 49, 48, 48, 47, 45, 44, 44, 45, 45, 45, 45, 46, 46, 45,
-        45, 44, 44, 44, 62, 61, 60, 60, 60, 59, 59, 58, 55, 53, 53, 50, 48, 48,
-        47, 46, 46, 46, 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 44, 44, 44, 44,
-        61, 60, 59, 59, 59, 58, 58, 57, 53, 53, 53, 49, 47, 47, 47, 46, 46, 45,
-        44, 43, 43, 44, 44, 44, 45, 45, 45, 45, 44, 44, 44, 44, 61, 60, 59, 59,
-        59, 58, 58, 57, 53, 53, 53, 49, 47, 47, 47, 46, 46, 45, 44, 43, 43, 44,
-        44, 44, 45, 45, 45, 45, 44, 44, 44, 44, 58, 57, 55, 55, 55, 54, 54, 53,
-        50, 49, 49, 47, 45, 45, 45, 44, 44, 44, 43, 43, 43, 44, 44, 44, 45, 45,
-        45, 45, 45, 44, 44, 44, 56, 55, 53, 53, 53, 51, 51, 51, 48, 47, 47, 45,
-        43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 45, 45, 45, 45, 45, 45,
-        45, 44, 56, 55, 53, 53, 53, 51, 51, 51, 48, 47, 47, 45, 43, 43, 43, 43,
-        43, 43, 43, 43, 43, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 44, 53, 52,
-        51, 51, 51, 50, 50, 49, 47, 47, 47, 45, 43, 43, 43, 43, 43, 43, 42, 42,
-        42, 43, 43, 43, 43, 44, 44, 44, 43, 43, 43, 43, 49, 49, 48, 48, 48, 48,
-        48, 48, 46, 46, 46, 44, 43, 43, 43, 42, 42, 42, 41, 41, 41, 41, 41, 41,
-        41, 42, 42, 41, 41, 41, 41, 41, 49, 49, 48, 48, 48, 48, 48, 48, 46, 46,
-        46, 44, 43, 43, 43, 42, 42, 42, 41, 41, 41, 41, 41, 41, 41, 42, 42, 41,
-        41, 41, 41, 41, 48, 48, 47, 47, 47, 47, 47, 47, 46, 45, 45, 44, 43, 43,
-        43, 42, 42, 41, 41, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 40,
-        43, 44, 44, 44, 45, 45, 45, 45, 44, 44, 44, 43, 43, 43, 42, 41, 41, 41,
-        39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 42, 43, 43, 43,
-        44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 42, 41, 41, 40, 39, 39, 39, 39,
-        39, 39, 38, 38, 38, 38, 38, 38, 38, 38, 42, 43, 43, 43, 44, 44, 44, 44,
-        44, 43, 43, 43, 43, 43, 42, 41, 41, 40, 39, 39, 39, 39, 39, 39, 38, 38,
-        38, 38, 38, 38, 38, 38, 42, 43, 43, 43, 44, 45, 45, 45, 44, 44, 44, 44,
-        44, 44, 43, 41, 41, 41, 39, 39, 39, 38, 38, 38, 38, 37, 37, 37, 37, 37,
-        37, 37, 42, 43, 44, 44, 44, 45, 45, 45, 45, 44, 44, 44, 44, 44, 43, 41,
-        41, 41, 39, 39, 39, 38, 38, 38, 37, 37, 37, 37, 36, 36, 36, 36, 42, 43,
-        44, 44, 44, 45, 45, 45, 45, 44, 44, 44, 44, 44, 43, 41, 41, 41, 39, 39,
-        39, 38, 38, 38, 37, 37, 37, 37, 36, 36, 36, 36, 42, 43, 44, 44, 44, 45,
-        45, 45, 45, 45, 45, 45, 45, 45, 43, 41, 41, 41, 39, 38, 38, 38, 37, 37,
-        37, 36, 36, 36, 36, 35, 35, 35, 42, 43, 44, 44, 45, 46, 46, 46, 45, 45,
-        45, 45, 45, 45, 44, 42, 42, 41, 39, 38, 38, 37, 37, 37, 36, 35, 35, 35,
-        34, 34, 34, 34, 42, 43, 44, 44, 45, 46, 46, 46, 45, 45, 45, 45, 45, 45,
-        44, 42, 42, 41, 39, 38, 38, 37, 37, 37, 36, 35, 35, 35, 34, 34, 34, 34,
-        41, 43, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 44, 41, 41, 41,
-        39, 38, 38, 37, 37, 37, 36, 35, 35, 35, 34, 34, 34, 34, 41, 42, 43, 43,
-        43, 45, 45, 45, 44, 44, 44, 45, 45, 45, 43, 41, 41, 41, 39, 38, 38, 37,
-        36, 36, 36, 34, 34, 34, 34, 34, 34, 33, 41, 41, 42, 42, 43, 44, 44, 44,
-        44, 44, 44, 44, 45, 45, 43, 41, 41, 41, 39, 38, 38, 37, 36, 36, 35, 34,
-        34, 34, 34, 33, 33, 33, 41, 41, 42, 42, 43, 44, 44, 44, 44, 44, 44, 44,
-        45, 45, 43, 41, 41, 41, 39, 38, 38, 37, 36, 36, 35, 34, 34, 34, 34, 33,
-        33, 33, 40, 41, 41, 41, 42, 44, 44, 44, 44, 44, 44, 44, 44, 44, 43, 41,
-        41, 40, 38, 38, 38, 37, 36, 36, 35, 34, 34, 34, 33, 33, 33, 32,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 31,
+        30, 30, 30, 29, 28, 28, 28, 28, 26, 26, 26, 25, 23, 23, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 30, 30,
+        29, 29, 29, 28, 26, 26, 26, 25, 24, 24, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 30, 30, 29, 29, 29, 28,
+        27, 27, 27, 26, 24, 24, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 30, 30, 30, 30, 29, 29, 29, 28, 27, 27, 27, 26,
+        24, 24, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 30, 30, 30, 30, 29, 29, 29, 28, 27, 27, 27, 26, 24, 24, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30,
+        30, 30, 29, 29, 29, 28, 27, 27, 27, 26, 25, 25, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30,
+        30, 28, 28, 28, 28, 26, 25, 25, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 28, 28, 28,
+        28, 26, 25, 25, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 28, 28, 28, 28, 26, 25, 25,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 30,
+        30, 30, 30, 29, 29, 29, 29, 28, 27, 27, 27, 26, 25, 25, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 30, 30, 30, 30, 29, 29, 29, 28,
+        28, 28, 28, 27, 26, 26, 26, 26, 24, 24, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 31, 31, 31, 30, 30, 30, 30, 29, 29, 29, 28, 28, 28, 28, 27,
+        26, 26, 26, 26, 24, 24, 33, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31,
+        31, 31, 30, 30, 30, 30, 29, 29, 29, 28, 28, 28, 28, 27, 26, 26, 26, 26,
+        24, 24, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30,
+        30, 29, 28, 28, 28, 28, 28, 28, 28, 27, 26, 26, 26, 25, 24, 24, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 30, 30, 29, 29, 29, 28, 28, 28,
+        28, 28, 27, 27, 27, 26, 26, 26, 26, 25, 24, 24, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 30, 30, 30, 30, 29, 29, 29, 28, 28, 28, 28, 28, 27, 27,
+        27, 26, 26, 26, 26, 25, 24, 24, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        30, 30, 30, 30, 29, 29, 29, 28, 28, 28, 28, 28, 27, 27, 27, 26, 26, 26,
+        26, 25, 24, 24, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 29,
+        28, 28, 28, 28, 27, 27, 27, 26, 26, 26, 26, 25, 24, 24, 24, 23, 23, 23,
+        30, 30, 30, 30, 30, 30, 31, 31, 31, 30, 29, 29, 29, 28, 28, 28, 28, 27,
+        26, 26, 26, 25, 24, 24, 24, 23, 23, 23, 23, 22, 22, 22, 30, 30, 30, 30,
+        30, 30, 31, 31, 31, 30, 29, 29, 29, 28, 28, 28, 28, 27, 26, 26, 26, 25,
+        24, 24, 24, 23, 23, 23, 23, 22, 22, 22, 30, 30, 30, 30, 30, 30, 31, 31,
+        31, 30, 29, 29, 29, 28, 28, 28, 28, 27, 26, 26, 26, 25, 24, 24, 24, 23,
+        23, 23, 23, 22, 22, 22, 29, 30, 30, 30, 30, 30, 30, 30, 30, 29, 28, 28,
+        28, 28, 28, 28, 28, 26, 25, 25, 25, 24, 23, 23, 23, 22, 22, 22, 22, 21,
+        20, 20, 28, 29, 29, 29, 29, 29, 30, 30, 30, 29, 28, 28, 28, 28, 27, 27,
+        27, 26, 24, 24, 24, 23, 21, 21, 21, 21, 20, 20, 20, 20, 19, 19, 28, 29,
+        29, 29, 29, 29, 30, 30, 30, 29, 28, 28, 28, 28, 27, 27, 27, 26, 24, 24,
+        24, 23, 21, 21, 21, 21, 20, 20, 20, 20, 19, 19, 28, 29, 29, 29, 29, 29,
+        30, 30, 30, 29, 28, 28, 28, 28, 27, 27, 27, 26, 24, 24, 24, 23, 21, 21,
+        21, 21, 20, 20, 20, 20, 19, 19, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+        27, 27, 27, 27, 26, 26, 26, 25, 23, 23, 23, 22, 21, 21, 21, 20, 20, 20,
+        20, 19, 18, 18, 26, 26, 27, 27, 27, 27, 28, 28, 28, 27, 26, 26, 26, 26,
+        26, 26, 26, 24, 23, 23, 23, 22, 20, 20, 20, 20, 19, 19, 19, 18, 18, 18,
+        26, 26, 27, 27, 27, 27, 28, 28, 28, 27, 26, 26, 26, 26, 26, 26, 26, 24,
+        23, 23, 23, 22, 20, 20, 20, 20, 19, 19, 19, 18, 18, 18, 26, 26, 27, 27,
+        27, 27, 28, 28, 28, 27, 26, 26, 26, 26, 26, 26, 26, 24, 23, 23, 23, 22,
+        20, 20, 20, 20, 19, 19, 19, 18, 18, 18, 25, 25, 26, 26, 26, 26, 26, 26,
+        26, 26, 26, 26, 26, 25, 25, 25, 25, 23, 22, 22, 22, 21, 20, 20, 20, 19,
+        18, 18, 18, 18, 17, 17, 23, 24, 24, 24, 24, 25, 25, 25, 25, 25, 24, 24,
+        24, 24, 24, 24, 24, 23, 22, 22, 22, 20, 19, 19, 19, 18, 18, 18, 18, 17,
+        16, 16, 23, 24, 24, 24, 24, 25, 25, 25, 25, 25, 24, 24, 24, 24, 24, 24,
+        24, 23, 22, 22, 22, 20, 19, 19, 19, 18, 18, 18, 18, 17, 16, 16,
         /* Size 4x8 */
-        65, 54, 43, 43, 65, 51, 45, 45, 59, 48, 44, 45, 53, 44, 43, 45, 47, 43,
-        41, 41, 44, 43, 39, 37, 44, 45, 38, 35, 43, 44, 38, 34,
+        33, 32, 30, 26, 32, 32, 30, 27, 32, 31, 30, 27, 32, 31, 28, 26, 31, 30,
+        27, 24, 30, 28, 25, 22, 28, 27, 23, 20, 26, 26, 22, 18,
         /* Size 8x4 */
-        65, 65, 59, 53, 47, 44, 44, 43, 54, 51, 48, 44, 43, 43, 45, 44, 43, 45,
-        44, 43, 41, 39, 38, 38, 43, 45, 45, 45, 41, 37, 35, 34,
+        33, 32, 32, 32, 31, 30, 28, 26, 32, 32, 31, 31, 30, 28, 27, 26, 30, 30,
+        30, 28, 27, 25, 23, 22, 26, 27, 27, 26, 24, 22, 20, 18,
         /* Size 8x16 */
-        64, 66, 62, 55, 45, 43, 42, 41, 65, 65, 60, 53, 46, 44, 44, 42, 66, 64,
-        59, 53, 46, 44, 44, 43, 67, 64, 59, 51, 46, 45, 45, 44, 62, 59, 55, 48,
-        45, 44, 45, 44, 61, 57, 53, 48, 45, 44, 45, 44, 55, 51, 48, 44, 43, 43,
-        45, 45, 53, 50, 47, 43, 42, 42, 44, 43, 49, 48, 46, 43, 41, 41, 41, 41,
-        43, 45, 44, 43, 40, 39, 39, 39, 42, 44, 44, 43, 39, 39, 38, 38, 42, 45,
-        44, 44, 40, 39, 37, 36, 42, 45, 45, 44, 40, 39, 36, 36, 42, 45, 45, 45,
-        40, 38, 35, 34, 41, 44, 44, 44, 39, 38, 34, 34, 41, 44, 44, 44, 39, 38,
-        34, 33,
+        32, 33, 33, 32, 32, 28, 28, 23, 33, 32, 32, 32, 32, 29, 29, 24, 33, 32,
+        32, 32, 32, 29, 29, 24, 33, 32, 32, 31, 31, 30, 30, 25, 33, 32, 32, 31,
+        31, 30, 30, 25, 32, 32, 32, 30, 30, 28, 28, 24, 32, 32, 32, 30, 30, 28,
+        28, 24, 32, 31, 31, 29, 29, 27, 27, 24, 32, 31, 31, 29, 29, 27, 27, 24,
+        30, 30, 30, 28, 28, 24, 24, 21, 30, 30, 30, 28, 28, 24, 24, 21, 28, 30,
+        30, 27, 27, 21, 21, 19, 28, 30, 30, 27, 27, 21, 21, 19, 26, 28, 28, 26,
+        26, 20, 20, 18, 26, 28, 28, 26, 26, 20, 20, 18, 23, 25, 25, 24, 24, 19,
+        19, 16,
         /* Size 16x8 */
-        64, 65, 66, 67, 62, 61, 55, 53, 49, 43, 42, 42, 42, 42, 41, 41, 66, 65,
-        64, 64, 59, 57, 51, 50, 48, 45, 44, 45, 45, 45, 44, 44, 62, 60, 59, 59,
-        55, 53, 48, 47, 46, 44, 44, 44, 45, 45, 44, 44, 55, 53, 53, 51, 48, 48,
-        44, 43, 43, 43, 43, 44, 44, 45, 44, 44, 45, 46, 46, 46, 45, 45, 43, 42,
-        41, 40, 39, 40, 40, 40, 39, 39, 43, 44, 44, 45, 44, 44, 43, 42, 41, 39,
-        39, 39, 39, 38, 38, 38, 42, 44, 44, 45, 45, 45, 45, 44, 41, 39, 38, 37,
-        36, 35, 34, 34, 41, 42, 43, 44, 44, 44, 45, 43, 41, 39, 38, 36, 36, 34,
-        34, 33,
+        32, 33, 33, 33, 33, 32, 32, 32, 32, 30, 30, 28, 28, 26, 26, 23, 33, 32,
+        32, 32, 32, 32, 32, 31, 31, 30, 30, 30, 30, 28, 28, 25, 33, 32, 32, 32,
+        32, 32, 32, 31, 31, 30, 30, 30, 30, 28, 28, 25, 32, 32, 32, 31, 31, 30,
+        30, 29, 29, 28, 28, 27, 27, 26, 26, 24, 32, 32, 32, 31, 31, 30, 30, 29,
+        29, 28, 28, 27, 27, 26, 26, 24, 28, 29, 29, 30, 30, 28, 28, 27, 27, 24,
+        24, 21, 21, 20, 20, 19, 28, 29, 29, 30, 30, 28, 28, 27, 27, 24, 24, 21,
+        21, 20, 20, 19, 23, 24, 24, 25, 25, 24, 24, 24, 24, 21, 21, 19, 19, 18,
+        18, 16,
         /* Size 16x32 */
-        64, 66, 66, 66, 62, 55, 55, 53, 45, 43, 43, 42, 42, 42, 41, 39, 65, 65,
-        65, 65, 61, 54, 54, 52, 46, 43, 43, 43, 43, 43, 42, 40, 65, 65, 65, 65,
-        60, 53, 53, 51, 46, 44, 44, 44, 44, 44, 42, 41, 65, 65, 65, 65, 60, 53,
-        53, 51, 46, 44, 44, 44, 44, 44, 42, 41, 66, 65, 64, 64, 59, 53, 53, 51,
-        46, 44, 44, 44, 44, 44, 43, 42, 67, 65, 64, 64, 59, 51, 51, 50, 46, 45,
-        45, 45, 45, 45, 44, 43, 67, 65, 64, 64, 59, 51, 51, 50, 46, 45, 45, 45,
-        45, 45, 44, 43, 66, 64, 62, 62, 58, 51, 51, 49, 46, 45, 45, 45, 45, 45,
-        44, 43, 62, 60, 59, 59, 55, 48, 48, 48, 45, 44, 44, 45, 45, 45, 44, 43,
-        61, 59, 57, 57, 53, 48, 48, 47, 45, 44, 44, 44, 45, 45, 44, 43, 61, 59,
-        57, 57, 53, 48, 48, 47, 45, 44, 44, 44, 45, 45, 44, 43, 58, 55, 53, 53,
-        50, 45, 45, 45, 44, 43, 43, 44, 45, 45, 44, 43, 55, 53, 51, 51, 48, 44,
-        44, 43, 43, 43, 43, 44, 45, 45, 45, 44, 55, 53, 51, 51, 48, 44, 44, 43,
-        43, 43, 43, 44, 45, 45, 45, 44, 53, 51, 50, 50, 47, 43, 43, 43, 42, 42,
-        42, 43, 44, 44, 43, 42, 49, 48, 48, 48, 46, 43, 43, 43, 41, 41, 41, 41,
-        41, 41, 41, 41, 49, 48, 48, 48, 46, 43, 43, 43, 41, 41, 41, 41, 41, 41,
-        41, 41, 48, 47, 47, 47, 46, 43, 43, 43, 41, 41, 41, 41, 41, 41, 41, 40,
-        43, 44, 45, 45, 44, 43, 43, 42, 40, 39, 39, 39, 39, 39, 39, 38, 42, 43,
-        44, 44, 44, 43, 43, 42, 39, 39, 39, 38, 38, 38, 38, 38, 42, 43, 44, 44,
-        44, 43, 43, 42, 39, 39, 39, 38, 38, 38, 38, 38, 42, 44, 45, 45, 44, 43,
-        43, 42, 39, 39, 39, 38, 37, 37, 37, 36, 42, 44, 45, 45, 44, 44, 44, 43,
-        40, 39, 39, 38, 37, 37, 36, 36, 42, 44, 45, 45, 44, 44, 44, 43, 40, 39,
-        39, 38, 37, 37, 36, 36, 42, 44, 45, 45, 45, 44, 44, 43, 40, 39, 39, 37,
-        36, 36, 36, 35, 42, 44, 45, 45, 45, 45, 45, 44, 40, 38, 38, 36, 35, 35,
-        34, 33, 42, 44, 45, 45, 45, 45, 45, 44, 40, 38, 38, 36, 35, 35, 34, 33,
-        42, 44, 45, 45, 45, 45, 45, 43, 39, 38, 38, 36, 35, 35, 34, 33, 41, 43,
-        44, 44, 44, 44, 44, 43, 39, 38, 38, 36, 34, 34, 34, 32, 41, 43, 44, 44,
-        44, 44, 44, 43, 39, 38, 38, 36, 34, 34, 33, 32, 41, 43, 44, 44, 44, 44,
-        44, 43, 39, 38, 38, 36, 34, 34, 33, 32, 40, 42, 43, 43, 43, 44, 44, 42,
-        39, 38, 38, 35, 34, 34, 33, 31,
+        32, 33, 33, 33, 33, 32, 32, 32, 32, 30, 28, 28, 28, 26, 23, 23, 33, 33,
+        33, 33, 33, 32, 32, 32, 32, 30, 29, 29, 29, 26, 24, 24, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 30, 29, 29, 29, 27, 24, 24, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 30, 29, 29, 29, 27, 24, 24, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 30, 29, 29, 29, 27, 24, 24, 33, 32, 32, 32, 32, 32, 32, 32, 32, 30,
+        29, 29, 29, 27, 25, 25, 33, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30,
+        30, 28, 25, 25, 33, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 28,
+        25, 25, 33, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 28, 25, 25,
+        33, 32, 32, 32, 32, 31, 31, 31, 31, 30, 29, 29, 29, 27, 25, 25, 32, 32,
+        32, 32, 32, 31, 30, 30, 30, 29, 28, 28, 28, 26, 24, 24, 32, 32, 32, 32,
+        32, 31, 30, 30, 30, 29, 28, 28, 28, 26, 24, 24, 32, 32, 32, 32, 32, 31,
+        30, 30, 30, 29, 28, 28, 28, 26, 24, 24, 32, 32, 32, 32, 32, 31, 30, 30,
+        30, 28, 28, 28, 28, 26, 24, 24, 32, 32, 31, 31, 31, 30, 29, 29, 29, 28,
+        27, 27, 27, 26, 24, 24, 32, 32, 31, 31, 31, 30, 29, 29, 29, 28, 27, 27,
+        27, 26, 24, 24, 32, 32, 31, 31, 31, 30, 29, 29, 29, 28, 27, 27, 27, 26,
+        24, 24, 31, 31, 31, 31, 31, 30, 28, 28, 28, 27, 26, 26, 26, 24, 23, 23,
+        30, 30, 30, 30, 30, 29, 28, 28, 28, 26, 24, 24, 24, 23, 21, 21, 30, 30,
+        30, 30, 30, 29, 28, 28, 28, 26, 24, 24, 24, 23, 21, 21, 30, 30, 30, 30,
+        30, 29, 28, 28, 28, 26, 24, 24, 24, 23, 21, 21, 29, 30, 30, 30, 30, 28,
+        28, 28, 28, 25, 23, 23, 23, 22, 20, 20, 28, 29, 30, 30, 30, 28, 27, 27,
+        27, 24, 21, 21, 21, 20, 19, 19, 28, 29, 30, 30, 30, 28, 27, 27, 27, 24,
+        21, 21, 21, 20, 19, 19, 28, 29, 30, 30, 30, 28, 27, 27, 27, 24, 21, 21,
+        21, 20, 19, 19, 28, 28, 28, 28, 28, 27, 26, 26, 26, 23, 21, 21, 21, 20,
+        18, 18, 26, 27, 28, 28, 28, 26, 26, 26, 26, 23, 20, 20, 20, 19, 18, 18,
+        26, 27, 28, 28, 28, 26, 26, 26, 26, 23, 20, 20, 20, 19, 18, 18, 26, 27,
+        28, 28, 28, 26, 26, 26, 26, 23, 20, 20, 20, 19, 18, 18, 25, 26, 26, 26,
+        26, 26, 24, 24, 24, 22, 20, 20, 20, 18, 17, 17, 23, 24, 25, 25, 25, 24,
+        24, 24, 24, 21, 19, 19, 19, 18, 16, 16, 23, 24, 25, 25, 25, 24, 24, 24,
+        24, 21, 19, 19, 19, 18, 16, 16,
         /* Size 32x16 */
-        64, 65, 65, 65, 66, 67, 67, 66, 62, 61, 61, 58, 55, 55, 53, 49, 49, 48,
-        43, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 41, 41, 40, 66, 65, 65, 65,
-        65, 65, 65, 64, 60, 59, 59, 55, 53, 53, 51, 48, 48, 47, 44, 43, 43, 44,
-        44, 44, 44, 44, 44, 44, 43, 43, 43, 42, 66, 65, 65, 65, 64, 64, 64, 62,
-        59, 57, 57, 53, 51, 51, 50, 48, 48, 47, 45, 44, 44, 45, 45, 45, 45, 45,
-        45, 45, 44, 44, 44, 43, 66, 65, 65, 65, 64, 64, 64, 62, 59, 57, 57, 53,
-        51, 51, 50, 48, 48, 47, 45, 44, 44, 45, 45, 45, 45, 45, 45, 45, 44, 44,
-        44, 43, 62, 61, 60, 60, 59, 59, 59, 58, 55, 53, 53, 50, 48, 48, 47, 46,
-        46, 46, 44, 44, 44, 44, 44, 44, 45, 45, 45, 45, 44, 44, 44, 43, 55, 54,
-        53, 53, 53, 51, 51, 51, 48, 48, 48, 45, 44, 44, 43, 43, 43, 43, 43, 43,
-        43, 43, 44, 44, 44, 45, 45, 45, 44, 44, 44, 44, 55, 54, 53, 53, 53, 51,
-        51, 51, 48, 48, 48, 45, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44,
-        44, 45, 45, 45, 44, 44, 44, 44, 53, 52, 51, 51, 51, 50, 50, 49, 48, 47,
-        47, 45, 43, 43, 43, 43, 43, 43, 42, 42, 42, 42, 43, 43, 43, 44, 44, 43,
-        43, 43, 43, 42, 45, 46, 46, 46, 46, 46, 46, 46, 45, 45, 45, 44, 43, 43,
-        42, 41, 41, 41, 40, 39, 39, 39, 40, 40, 40, 40, 40, 39, 39, 39, 39, 39,
-        43, 43, 44, 44, 44, 45, 45, 45, 44, 44, 44, 43, 43, 43, 42, 41, 41, 41,
-        39, 39, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 38, 43, 43, 44, 44,
-        44, 45, 45, 45, 44, 44, 44, 43, 43, 43, 42, 41, 41, 41, 39, 39, 39, 39,
-        39, 39, 39, 38, 38, 38, 38, 38, 38, 38, 42, 43, 44, 44, 44, 45, 45, 45,
-        45, 44, 44, 44, 44, 44, 43, 41, 41, 41, 39, 38, 38, 38, 38, 38, 37, 36,
-        36, 36, 36, 36, 36, 35, 42, 43, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45,
-        45, 45, 44, 41, 41, 41, 39, 38, 38, 37, 37, 37, 36, 35, 35, 35, 34, 34,
-        34, 34, 42, 43, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 44, 41,
-        41, 41, 39, 38, 38, 37, 37, 37, 36, 35, 35, 35, 34, 34, 34, 34, 41, 42,
-        42, 42, 43, 44, 44, 44, 44, 44, 44, 44, 45, 45, 43, 41, 41, 41, 39, 38,
-        38, 37, 36, 36, 36, 34, 34, 34, 34, 33, 33, 33, 39, 40, 41, 41, 42, 43,
-        43, 43, 43, 43, 43, 43, 44, 44, 42, 41, 41, 40, 38, 38, 38, 36, 36, 36,
-        35, 33, 33, 33, 32, 32, 32, 31,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31,
+        30, 30, 30, 29, 28, 28, 28, 28, 26, 26, 26, 25, 23, 23, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 30, 30,
+        29, 29, 29, 28, 27, 27, 27, 26, 24, 24, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 28,
+        28, 28, 28, 26, 25, 25, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 28, 28, 28, 28, 26,
+        25, 25, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 30, 30, 30, 30, 30, 30, 30, 28, 28, 28, 28, 26, 25, 25, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 30, 30, 30, 30, 29, 29,
+        29, 28, 28, 28, 28, 27, 26, 26, 26, 26, 24, 24, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 30, 30, 30, 30, 29, 29, 29, 28, 28, 28, 28, 28, 27, 27,
+        27, 26, 26, 26, 26, 24, 24, 24, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        30, 30, 30, 30, 29, 29, 29, 28, 28, 28, 28, 28, 27, 27, 27, 26, 26, 26,
+        26, 24, 24, 24, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30,
+        29, 29, 29, 28, 28, 28, 28, 28, 27, 27, 27, 26, 26, 26, 26, 24, 24, 24,
+        30, 30, 30, 30, 30, 30, 31, 31, 31, 30, 29, 29, 29, 28, 28, 28, 28, 27,
+        26, 26, 26, 25, 24, 24, 24, 23, 23, 23, 23, 22, 21, 21, 28, 29, 29, 29,
+        29, 29, 30, 30, 30, 29, 28, 28, 28, 28, 27, 27, 27, 26, 24, 24, 24, 23,
+        21, 21, 21, 21, 20, 20, 20, 20, 19, 19, 28, 29, 29, 29, 29, 29, 30, 30,
+        30, 29, 28, 28, 28, 28, 27, 27, 27, 26, 24, 24, 24, 23, 21, 21, 21, 21,
+        20, 20, 20, 20, 19, 19, 28, 29, 29, 29, 29, 29, 30, 30, 30, 29, 28, 28,
+        28, 28, 27, 27, 27, 26, 24, 24, 24, 23, 21, 21, 21, 21, 20, 20, 20, 20,
+        19, 19, 26, 26, 27, 27, 27, 27, 28, 28, 28, 27, 26, 26, 26, 26, 26, 26,
+        26, 24, 23, 23, 23, 22, 20, 20, 20, 20, 19, 19, 19, 18, 18, 18, 23, 24,
+        24, 24, 24, 25, 25, 25, 25, 25, 24, 24, 24, 24, 24, 24, 24, 23, 21, 21,
+        21, 20, 19, 19, 19, 18, 18, 18, 18, 17, 16, 16, 23, 24, 24, 24, 24, 25,
+        25, 25, 25, 25, 24, 24, 24, 24, 24, 24, 24, 23, 21, 21, 21, 20, 19, 19,
+        19, 18, 18, 18, 18, 17, 16, 16,
         /* Size 4x16 */
-        66, 55, 43, 42, 65, 53, 44, 44, 65, 53, 44, 44, 65, 51, 45, 45, 60, 48,
-        44, 45, 59, 48, 44, 45, 53, 44, 43, 45, 51, 43, 42, 44, 48, 43, 41, 41,
-        44, 43, 39, 39, 43, 43, 39, 38, 44, 44, 39, 37, 44, 44, 39, 36, 44, 45,
-        38, 35, 43, 44, 38, 34, 43, 44, 38, 34,
+        33, 32, 30, 26, 32, 32, 30, 27, 32, 32, 30, 27, 32, 32, 31, 28, 32, 32,
+        31, 28, 32, 31, 29, 26, 32, 31, 29, 26, 32, 30, 28, 26, 32, 30, 28, 26,
+        30, 29, 26, 23, 30, 29, 26, 23, 29, 28, 24, 20, 29, 28, 24, 20, 27, 26,
+        23, 19, 27, 26, 23, 19, 24, 24, 21, 18,
         /* Size 16x4 */
-        66, 65, 65, 65, 60, 59, 53, 51, 48, 44, 43, 44, 44, 44, 43, 43, 55, 53,
-        53, 51, 48, 48, 44, 43, 43, 43, 43, 44, 44, 45, 44, 44, 43, 44, 44, 45,
-        44, 44, 43, 42, 41, 39, 39, 39, 39, 38, 38, 38, 42, 44, 44, 45, 45, 45,
-        45, 44, 41, 39, 38, 37, 36, 35, 34, 34,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 30, 30, 29, 29, 27, 27, 24, 32, 32,
+        32, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 26, 26, 24, 30, 30, 30, 31,
+        31, 29, 29, 28, 28, 26, 26, 24, 24, 23, 23, 21, 26, 27, 27, 28, 28, 26,
+        26, 26, 26, 23, 23, 20, 20, 19, 19, 18,
         /* Size 8x32 */
-        64, 66, 62, 55, 45, 43, 42, 41, 65, 65, 61, 54, 46, 43, 43, 42, 65, 65,
-        60, 53, 46, 44, 44, 42, 65, 65, 60, 53, 46, 44, 44, 42, 66, 64, 59, 53,
-        46, 44, 44, 43, 67, 64, 59, 51, 46, 45, 45, 44, 67, 64, 59, 51, 46, 45,
-        45, 44, 66, 62, 58, 51, 46, 45, 45, 44, 62, 59, 55, 48, 45, 44, 45, 44,
-        61, 57, 53, 48, 45, 44, 45, 44, 61, 57, 53, 48, 45, 44, 45, 44, 58, 53,
-        50, 45, 44, 43, 45, 44, 55, 51, 48, 44, 43, 43, 45, 45, 55, 51, 48, 44,
-        43, 43, 45, 45, 53, 50, 47, 43, 42, 42, 44, 43, 49, 48, 46, 43, 41, 41,
-        41, 41, 49, 48, 46, 43, 41, 41, 41, 41, 48, 47, 46, 43, 41, 41, 41, 41,
-        43, 45, 44, 43, 40, 39, 39, 39, 42, 44, 44, 43, 39, 39, 38, 38, 42, 44,
-        44, 43, 39, 39, 38, 38, 42, 45, 44, 43, 39, 39, 37, 37, 42, 45, 44, 44,
-        40, 39, 37, 36, 42, 45, 44, 44, 40, 39, 37, 36, 42, 45, 45, 44, 40, 39,
-        36, 36, 42, 45, 45, 45, 40, 38, 35, 34, 42, 45, 45, 45, 40, 38, 35, 34,
-        42, 45, 45, 45, 39, 38, 35, 34, 41, 44, 44, 44, 39, 38, 34, 34, 41, 44,
-        44, 44, 39, 38, 34, 33, 41, 44, 44, 44, 39, 38, 34, 33, 40, 43, 43, 44,
-        39, 38, 34, 33,
+        32, 33, 33, 32, 32, 28, 28, 23, 33, 33, 33, 32, 32, 29, 29, 24, 33, 32,
+        32, 32, 32, 29, 29, 24, 33, 32, 32, 32, 32, 29, 29, 24, 33, 32, 32, 32,
+        32, 29, 29, 24, 33, 32, 32, 32, 32, 29, 29, 25, 33, 32, 32, 31, 31, 30,
+        30, 25, 33, 32, 32, 31, 31, 30, 30, 25, 33, 32, 32, 31, 31, 30, 30, 25,
+        33, 32, 32, 31, 31, 29, 29, 25, 32, 32, 32, 30, 30, 28, 28, 24, 32, 32,
+        32, 30, 30, 28, 28, 24, 32, 32, 32, 30, 30, 28, 28, 24, 32, 32, 32, 30,
+        30, 28, 28, 24, 32, 31, 31, 29, 29, 27, 27, 24, 32, 31, 31, 29, 29, 27,
+        27, 24, 32, 31, 31, 29, 29, 27, 27, 24, 31, 31, 31, 28, 28, 26, 26, 23,
+        30, 30, 30, 28, 28, 24, 24, 21, 30, 30, 30, 28, 28, 24, 24, 21, 30, 30,
+        30, 28, 28, 24, 24, 21, 29, 30, 30, 28, 28, 23, 23, 20, 28, 30, 30, 27,
+        27, 21, 21, 19, 28, 30, 30, 27, 27, 21, 21, 19, 28, 30, 30, 27, 27, 21,
+        21, 19, 28, 28, 28, 26, 26, 21, 21, 18, 26, 28, 28, 26, 26, 20, 20, 18,
+        26, 28, 28, 26, 26, 20, 20, 18, 26, 28, 28, 26, 26, 20, 20, 18, 25, 26,
+        26, 24, 24, 20, 20, 17, 23, 25, 25, 24, 24, 19, 19, 16, 23, 25, 25, 24,
+        24, 19, 19, 16,
         /* Size 32x8 */
-        64, 65, 65, 65, 66, 67, 67, 66, 62, 61, 61, 58, 55, 55, 53, 49, 49, 48,
-        43, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 41, 41, 40, 66, 65, 65, 65,
-        64, 64, 64, 62, 59, 57, 57, 53, 51, 51, 50, 48, 48, 47, 45, 44, 44, 45,
-        45, 45, 45, 45, 45, 45, 44, 44, 44, 43, 62, 61, 60, 60, 59, 59, 59, 58,
-        55, 53, 53, 50, 48, 48, 47, 46, 46, 46, 44, 44, 44, 44, 44, 44, 45, 45,
-        45, 45, 44, 44, 44, 43, 55, 54, 53, 53, 53, 51, 51, 51, 48, 48, 48, 45,
-        44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 45, 45, 45, 44, 44,
-        44, 44, 45, 46, 46, 46, 46, 46, 46, 46, 45, 45, 45, 44, 43, 43, 42, 41,
-        41, 41, 40, 39, 39, 39, 40, 40, 40, 40, 40, 39, 39, 39, 39, 39, 43, 43,
-        44, 44, 44, 45, 45, 45, 44, 44, 44, 43, 43, 43, 42, 41, 41, 41, 39, 39,
-        39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 38, 42, 43, 44, 44, 44, 45,
-        45, 45, 45, 45, 45, 45, 45, 45, 44, 41, 41, 41, 39, 38, 38, 37, 37, 37,
-        36, 35, 35, 35, 34, 34, 34, 34, 41, 42, 42, 42, 43, 44, 44, 44, 44, 44,
-        44, 44, 45, 45, 43, 41, 41, 41, 39, 38, 38, 37, 36, 36, 36, 34, 34, 34,
-        34, 33, 33, 33 },
-  },
-  {
-      { /* Luma */
-#if CONFIG_CB4X4
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31,
+        30, 30, 30, 29, 28, 28, 28, 28, 26, 26, 26, 25, 23, 23, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30,
+        30, 30, 30, 28, 28, 28, 28, 26, 25, 25, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 28,
+        28, 28, 28, 26, 25, 25, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30,
+        30, 30, 29, 29, 29, 28, 28, 28, 28, 28, 27, 27, 27, 26, 26, 26, 26, 24,
+        24, 24, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 29, 29,
+        29, 28, 28, 28, 28, 28, 27, 27, 27, 26, 26, 26, 26, 24, 24, 24, 28, 29,
+        29, 29, 29, 29, 30, 30, 30, 29, 28, 28, 28, 28, 27, 27, 27, 26, 24, 24,
+        24, 23, 21, 21, 21, 21, 20, 20, 20, 20, 19, 19, 28, 29, 29, 29, 29, 29,
+        30, 30, 30, 29, 28, 28, 28, 28, 27, 27, 27, 26, 24, 24, 24, 23, 21, 21,
+        21, 21, 20, 20, 20, 20, 19, 19, 23, 24, 24, 24, 24, 25, 25, 25, 25, 25,
+        24, 24, 24, 24, 24, 24, 24, 23, 21, 21, 21, 20, 19, 19, 19, 18, 18, 18,
+        18, 17, 16, 16 },
+      { /* Chroma */
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        63, 59, 59, 42,
+        32, 22, 22, 19,
 #endif
         /* Size 4x4 */
-        64, 64, 60, 53, 64, 61, 58, 53, 60, 58, 52, 46, 53, 53, 46, 38,
+        33, 30, 24, 22, 30, 26, 23, 22, 24, 23, 21, 21, 22, 22, 21, 19,
         /* Size 8x8 */
-        65, 65, 64, 64, 62, 59, 55, 50, 65, 64, 63, 63, 62, 59, 56, 52, 64, 63,
-        63, 62, 60, 59, 55, 51, 64, 63, 62, 60, 58, 56, 53, 50, 62, 62, 60, 58,
-        55, 53, 49, 47, 59, 59, 59, 56, 53, 48, 44, 42, 55, 56, 55, 53, 49, 44,
-        40, 38, 50, 52, 51, 50, 47, 42, 38, 35,
+        33, 33, 32, 29, 26, 23, 21, 21, 33, 33, 31, 28, 25, 23, 22, 22, 32, 31,
+        29, 26, 24, 23, 22, 23, 29, 28, 26, 24, 23, 22, 22, 22, 26, 25, 24, 23,
+        22, 21, 21, 22, 23, 23, 23, 22, 21, 20, 20, 20, 21, 22, 22, 22, 21, 20,
+        19, 19, 21, 22, 23, 22, 22, 20, 19, 18,
         /* Size 16x16 */
-        64, 65, 65, 65, 65, 65, 65, 64, 64, 60, 60, 57, 57, 52, 52, 47, 65, 64,
-        64, 64, 64, 64, 64, 63, 63, 60, 60, 59, 59, 53, 53, 48, 65, 64, 64, 64,
-        64, 64, 64, 63, 63, 60, 60, 59, 59, 53, 53, 48, 65, 64, 64, 63, 63, 63,
-        63, 63, 63, 61, 61, 59, 59, 55, 55, 50, 65, 64, 64, 63, 63, 63, 63, 63,
-        63, 61, 61, 59, 59, 55, 55, 50, 65, 64, 64, 63, 63, 61, 61, 60, 60, 58,
-        58, 56, 56, 53, 53, 49, 65, 64, 64, 63, 63, 61, 61, 60, 60, 58, 58, 56,
-        56, 53, 53, 49, 64, 63, 63, 63, 63, 60, 60, 58, 58, 55, 55, 53, 53, 51,
-        51, 48, 64, 63, 63, 63, 63, 60, 60, 58, 58, 55, 55, 53, 53, 51, 51, 48,
-        60, 60, 60, 61, 61, 58, 58, 55, 55, 52, 52, 48, 48, 46, 46, 43, 60, 60,
-        60, 61, 61, 58, 58, 55, 55, 52, 52, 48, 48, 46, 46, 43, 57, 59, 59, 59,
-        59, 56, 56, 53, 53, 48, 48, 42, 42, 41, 41, 38, 57, 59, 59, 59, 59, 56,
-        56, 53, 53, 48, 48, 42, 42, 41, 41, 38, 52, 53, 53, 55, 55, 53, 53, 51,
-        51, 46, 46, 41, 41, 38, 38, 35, 52, 53, 53, 55, 55, 53, 53, 51, 51, 46,
-        46, 41, 41, 38, 38, 35, 47, 48, 48, 50, 50, 49, 49, 48, 48, 43, 43, 38,
-        38, 35, 35, 32,
+        32, 33, 33, 34, 34, 31, 31, 28, 28, 25, 25, 21, 21, 21, 21, 21, 33, 33,
+        33, 33, 33, 30, 30, 27, 27, 24, 24, 22, 22, 22, 22, 22, 33, 33, 33, 33,
+        33, 30, 30, 27, 27, 24, 24, 22, 22, 22, 22, 22, 34, 33, 33, 32, 32, 29,
+        29, 26, 26, 24, 24, 22, 22, 23, 23, 23, 34, 33, 33, 32, 32, 29, 29, 26,
+        26, 24, 24, 22, 22, 23, 23, 23, 31, 30, 30, 29, 29, 26, 26, 24, 24, 23,
+        23, 22, 22, 22, 22, 23, 31, 30, 30, 29, 29, 26, 26, 24, 24, 23, 23, 22,
+        22, 22, 22, 23, 28, 27, 27, 26, 26, 24, 24, 22, 22, 22, 22, 21, 21, 22,
+        22, 23, 28, 27, 27, 26, 26, 24, 24, 22, 22, 22, 22, 21, 21, 22, 22, 23,
+        25, 24, 24, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 21, 21, 21, 25, 24,
+        24, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 21, 21, 21, 21, 22, 22, 22,
+        22, 22, 22, 21, 21, 20, 20, 19, 19, 19, 19, 19, 21, 22, 22, 22, 22, 22,
+        22, 21, 21, 20, 20, 19, 19, 19, 19, 19, 21, 22, 22, 23, 23, 22, 22, 22,
+        22, 21, 21, 19, 19, 19, 19, 19, 21, 22, 22, 23, 23, 22, 22, 22, 22, 21,
+        21, 19, 19, 19, 19, 19, 21, 22, 22, 23, 23, 23, 23, 23, 23, 21, 21, 19,
+        19, 19, 19, 18,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 62,
-        60, 60, 60, 59, 57, 57, 57, 55, 52, 52, 52, 49, 47, 47, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 62, 60, 60, 60, 59,
-        58, 58, 58, 55, 53, 53, 53, 50, 48, 48, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 63, 63, 63, 63, 62, 60, 60, 60, 59, 59, 59, 59, 55,
-        53, 53, 53, 51, 48, 48, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 63, 63, 63, 63, 62, 60, 60, 60, 59, 59, 59, 59, 55, 53, 53, 53, 51,
-        48, 48, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63,
-        63, 62, 60, 60, 60, 59, 59, 59, 59, 55, 53, 53, 53, 51, 48, 48, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 60, 60,
-        60, 59, 59, 59, 59, 56, 54, 54, 54, 52, 49, 49, 65, 65, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 61, 61, 60, 59, 59,
-        59, 57, 55, 55, 55, 53, 50, 50, 65, 65, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 62, 61, 61, 61, 60, 59, 59, 59, 57, 55, 55,
-        55, 53, 50, 50, 65, 65, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 61, 61, 61, 60, 59, 59, 59, 57, 55, 55, 55, 53, 50, 50,
-        65, 64, 64, 64, 64, 63, 63, 63, 63, 63, 62, 62, 62, 62, 61, 61, 61, 60,
-        59, 59, 59, 59, 58, 58, 58, 55, 53, 53, 53, 51, 49, 49, 65, 64, 64, 64,
-        64, 63, 63, 63, 63, 62, 61, 61, 61, 61, 60, 60, 60, 59, 58, 58, 58, 57,
-        56, 56, 56, 54, 53, 53, 53, 51, 49, 49, 65, 64, 64, 64, 64, 63, 63, 63,
-        63, 62, 61, 61, 61, 61, 60, 60, 60, 59, 58, 58, 58, 57, 56, 56, 56, 54,
-        53, 53, 53, 51, 49, 49, 65, 64, 64, 64, 64, 63, 63, 63, 63, 62, 61, 61,
-        61, 61, 60, 60, 60, 59, 58, 58, 58, 57, 56, 56, 56, 54, 53, 53, 53, 51,
-        49, 49, 64, 64, 63, 63, 63, 63, 63, 63, 63, 62, 61, 61, 61, 60, 59, 59,
-        59, 58, 57, 57, 57, 56, 55, 55, 55, 53, 51, 51, 51, 50, 48, 48, 64, 64,
-        63, 63, 63, 63, 63, 63, 63, 61, 60, 60, 60, 59, 58, 58, 58, 57, 55, 55,
-        55, 55, 53, 53, 53, 52, 51, 51, 51, 49, 48, 48, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 61, 60, 60, 60, 59, 58, 58, 58, 57, 55, 55, 55, 55, 53, 53,
-        53, 52, 51, 51, 51, 49, 48, 48, 64, 64, 63, 63, 63, 63, 63, 63, 63, 61,
-        60, 60, 60, 59, 58, 58, 58, 57, 55, 55, 55, 55, 53, 53, 53, 52, 51, 51,
-        51, 49, 48, 48, 62, 62, 62, 62, 62, 62, 62, 62, 62, 60, 59, 59, 59, 58,
-        57, 57, 57, 55, 54, 54, 54, 53, 51, 51, 51, 49, 48, 48, 48, 47, 46, 46,
-        60, 60, 60, 60, 60, 60, 61, 61, 61, 59, 58, 58, 58, 57, 55, 55, 55, 54,
-        52, 52, 52, 50, 48, 48, 48, 47, 46, 46, 46, 44, 43, 43, 60, 60, 60, 60,
-        60, 60, 61, 61, 61, 59, 58, 58, 58, 57, 55, 55, 55, 54, 52, 52, 52, 50,
-        48, 48, 48, 47, 46, 46, 46, 44, 43, 43, 60, 60, 60, 60, 60, 60, 61, 61,
-        61, 59, 58, 58, 58, 57, 55, 55, 55, 54, 52, 52, 52, 50, 48, 48, 48, 47,
-        46, 46, 46, 44, 43, 43, 59, 59, 59, 59, 59, 59, 60, 60, 60, 59, 57, 57,
-        57, 56, 55, 55, 55, 53, 50, 50, 50, 48, 45, 45, 45, 44, 43, 43, 43, 42,
-        41, 41, 57, 58, 59, 59, 59, 59, 59, 59, 59, 58, 56, 56, 56, 55, 53, 53,
-        53, 51, 48, 48, 48, 45, 42, 42, 42, 41, 41, 41, 41, 39, 38, 38, 57, 58,
-        59, 59, 59, 59, 59, 59, 59, 58, 56, 56, 56, 55, 53, 53, 53, 51, 48, 48,
-        48, 45, 42, 42, 42, 41, 41, 41, 41, 39, 38, 38, 57, 58, 59, 59, 59, 59,
-        59, 59, 59, 58, 56, 56, 56, 55, 53, 53, 53, 51, 48, 48, 48, 45, 42, 42,
-        42, 41, 41, 41, 41, 39, 38, 38, 55, 55, 55, 55, 55, 56, 57, 57, 57, 55,
-        54, 54, 54, 53, 52, 52, 52, 49, 47, 47, 47, 44, 41, 41, 41, 40, 39, 39,
-        39, 38, 37, 37, 52, 53, 53, 53, 53, 54, 55, 55, 55, 53, 53, 53, 53, 51,
-        51, 51, 51, 48, 46, 46, 46, 43, 41, 41, 41, 39, 38, 38, 38, 37, 35, 35,
-        52, 53, 53, 53, 53, 54, 55, 55, 55, 53, 53, 53, 53, 51, 51, 51, 51, 48,
-        46, 46, 46, 43, 41, 41, 41, 39, 38, 38, 38, 37, 35, 35, 52, 53, 53, 53,
-        53, 54, 55, 55, 55, 53, 53, 53, 53, 51, 51, 51, 51, 48, 46, 46, 46, 43,
-        41, 41, 41, 39, 38, 38, 38, 37, 35, 35, 49, 50, 51, 51, 51, 52, 53, 53,
-        53, 51, 51, 51, 51, 50, 49, 49, 49, 47, 44, 44, 44, 42, 39, 39, 39, 38,
-        37, 37, 37, 35, 34, 34, 47, 48, 48, 48, 48, 49, 50, 50, 50, 49, 49, 49,
-        49, 48, 48, 48, 48, 46, 43, 43, 43, 41, 38, 38, 38, 37, 35, 35, 35, 34,
-        32, 32, 47, 48, 48, 48, 48, 49, 50, 50, 50, 49, 49, 49, 49, 48, 48, 48,
-        48, 46, 43, 43, 43, 41, 38, 38, 38, 37, 35, 35, 35, 34, 32, 32,
+        32, 33, 33, 33, 33, 33, 34, 34, 34, 32, 31, 31, 31, 29, 28, 28, 28, 26,
+        25, 25, 25, 23, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 32, 30, 30, 30, 29, 28, 28, 28, 26, 24, 24, 24, 23,
+        21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 31, 30, 30, 30, 28, 27, 27, 27, 26, 24, 24, 24, 23, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 30, 30,
+        30, 28, 27, 27, 27, 26, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 30, 30, 30, 28, 27, 27,
+        27, 26, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 31, 29, 29, 29, 28, 26, 26, 26, 25, 24, 24,
+        24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 34, 33, 33, 33, 33, 33,
+        32, 32, 32, 31, 29, 29, 29, 28, 26, 26, 26, 25, 24, 24, 24, 23, 22, 22,
+        22, 22, 23, 23, 23, 23, 23, 23, 34, 33, 33, 33, 33, 33, 32, 32, 32, 31,
+        29, 29, 29, 28, 26, 26, 26, 25, 24, 24, 24, 23, 22, 22, 22, 22, 23, 23,
+        23, 23, 23, 23, 34, 33, 33, 33, 33, 33, 32, 32, 32, 31, 29, 29, 29, 28,
+        26, 26, 26, 25, 24, 24, 24, 23, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23,
+        32, 32, 31, 31, 31, 31, 31, 31, 31, 29, 28, 28, 28, 26, 25, 25, 25, 24,
+        24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 31, 30, 30, 30,
+        30, 29, 29, 29, 29, 28, 26, 26, 26, 25, 24, 24, 24, 23, 23, 23, 23, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 31, 30, 30, 30, 30, 29, 29, 29,
+        29, 28, 26, 26, 26, 25, 24, 24, 24, 23, 23, 23, 23, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 23, 23, 31, 30, 30, 30, 30, 29, 29, 29, 29, 28, 26, 26,
+        26, 25, 24, 24, 24, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        23, 23, 29, 29, 28, 28, 28, 28, 28, 28, 28, 26, 25, 25, 25, 24, 23, 23,
+        23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 28, 28,
+        27, 27, 27, 26, 26, 26, 26, 25, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22,
+        22, 22, 21, 21, 21, 22, 22, 22, 22, 22, 23, 23, 28, 28, 27, 27, 27, 26,
+        26, 26, 26, 25, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21,
+        21, 22, 22, 22, 22, 22, 23, 23, 28, 28, 27, 27, 27, 26, 26, 26, 26, 25,
+        24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 22, 22, 22,
+        22, 22, 23, 23, 26, 26, 26, 26, 26, 25, 25, 25, 25, 24, 23, 23, 23, 23,
+        22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22,
+        25, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 22, 22, 22, 22, 21,
+        21, 21, 21, 21, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 25, 24, 24, 24,
+        24, 24, 24, 24, 24, 24, 23, 23, 23, 22, 22, 22, 22, 21, 21, 21, 21, 21,
+        20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 25, 24, 24, 24, 24, 24, 24, 24,
+        24, 24, 23, 23, 23, 22, 22, 22, 22, 21, 21, 21, 21, 21, 20, 20, 20, 20,
+        21, 21, 21, 21, 21, 21, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 22, 22,
+        22, 22, 22, 22, 22, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+        20, 20, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21,
+        21, 21, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 21, 21,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 20, 20,
+        20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 21, 21, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 20, 20, 20, 20, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 21, 21, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 22, 22,
+        22, 22, 22, 21, 21, 21, 21, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        21, 21, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 21,
+        21, 21, 21, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 21, 21, 22, 22,
+        22, 22, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 20,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 21, 21, 22, 22, 22, 22, 23, 23,
+        23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 20, 19, 19, 19, 19,
+        19, 19, 19, 18, 18, 18, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23,
+        23, 23, 23, 23, 23, 22, 21, 21, 21, 20, 19, 19, 19, 19, 19, 19, 19, 18,
+        18, 18, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+        23, 22, 21, 21, 21, 20, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18,
         /* Size 4x8 */
-        65, 64, 60, 53, 64, 63, 60, 54, 64, 62, 59, 53, 63, 61, 57, 51, 62, 59,
-        54, 48, 59, 57, 50, 43, 55, 54, 47, 39, 51, 51, 44, 37,
+        33, 30, 24, 21, 33, 29, 24, 22, 31, 28, 23, 22, 28, 25, 22, 22, 26, 23,
+        21, 21, 23, 22, 21, 20, 22, 22, 20, 19, 22, 22, 21, 19,
         /* Size 8x4 */
-        65, 64, 64, 63, 62, 59, 55, 51, 64, 63, 62, 61, 59, 57, 54, 51, 60, 60,
-        59, 57, 54, 50, 47, 44, 53, 54, 53, 51, 48, 43, 39, 37,
+        33, 33, 31, 28, 26, 23, 22, 22, 30, 29, 28, 25, 23, 22, 22, 22, 24, 24,
+        23, 22, 21, 21, 20, 21, 21, 22, 22, 22, 21, 20, 19, 19,
         /* Size 8x16 */
-        64, 65, 65, 64, 64, 57, 57, 47, 65, 64, 64, 63, 63, 58, 58, 48, 65, 64,
-        64, 63, 63, 58, 58, 48, 65, 63, 63, 62, 62, 59, 59, 50, 65, 63, 63, 62,
-        62, 59, 59, 50, 64, 63, 63, 60, 60, 56, 56, 49, 64, 63, 63, 60, 60, 56,
-        56, 49, 64, 62, 62, 58, 58, 53, 53, 48, 64, 62, 62, 58, 58, 53, 53, 48,
-        60, 60, 60, 55, 55, 48, 48, 43, 60, 60, 60, 55, 55, 48, 48, 43, 57, 59,
-        59, 53, 53, 43, 43, 38, 57, 59, 59, 53, 53, 43, 43, 38, 52, 55, 55, 51,
-        51, 41, 41, 35, 52, 55, 55, 51, 51, 41, 41, 35, 47, 50, 50, 48, 48, 38,
-        38, 33,
+        32, 33, 33, 28, 28, 21, 21, 21, 33, 33, 33, 27, 27, 22, 22, 22, 33, 33,
+        33, 27, 27, 22, 22, 22, 34, 32, 32, 26, 26, 22, 22, 23, 34, 32, 32, 26,
+        26, 22, 22, 23, 31, 28, 28, 24, 24, 22, 22, 22, 31, 28, 28, 24, 24, 22,
+        22, 22, 28, 26, 26, 22, 22, 22, 22, 23, 28, 26, 26, 22, 22, 22, 22, 23,
+        24, 24, 24, 22, 22, 20, 20, 21, 24, 24, 24, 22, 22, 20, 20, 21, 21, 22,
+        22, 21, 21, 19, 19, 19, 21, 22, 22, 21, 21, 19, 19, 19, 21, 22, 22, 22,
+        22, 19, 19, 18, 21, 22, 22, 22, 22, 19, 19, 18, 21, 23, 23, 22, 22, 19,
+        19, 18,
         /* Size 16x8 */
-        64, 65, 65, 65, 65, 64, 64, 64, 64, 60, 60, 57, 57, 52, 52, 47, 65, 64,
-        64, 63, 63, 63, 63, 62, 62, 60, 60, 59, 59, 55, 55, 50, 65, 64, 64, 63,
-        63, 63, 63, 62, 62, 60, 60, 59, 59, 55, 55, 50, 64, 63, 63, 62, 62, 60,
-        60, 58, 58, 55, 55, 53, 53, 51, 51, 48, 64, 63, 63, 62, 62, 60, 60, 58,
-        58, 55, 55, 53, 53, 51, 51, 48, 57, 58, 58, 59, 59, 56, 56, 53, 53, 48,
-        48, 43, 43, 41, 41, 38, 57, 58, 58, 59, 59, 56, 56, 53, 53, 48, 48, 43,
-        43, 41, 41, 38, 47, 48, 48, 50, 50, 49, 49, 48, 48, 43, 43, 38, 38, 35,
-        35, 33,
+        32, 33, 33, 34, 34, 31, 31, 28, 28, 24, 24, 21, 21, 21, 21, 21, 33, 33,
+        33, 32, 32, 28, 28, 26, 26, 24, 24, 22, 22, 22, 22, 23, 33, 33, 33, 32,
+        32, 28, 28, 26, 26, 24, 24, 22, 22, 22, 22, 23, 28, 27, 27, 26, 26, 24,
+        24, 22, 22, 22, 22, 21, 21, 22, 22, 22, 28, 27, 27, 26, 26, 24, 24, 22,
+        22, 22, 22, 21, 21, 22, 22, 22, 21, 22, 22, 22, 22, 22, 22, 22, 22, 20,
+        20, 19, 19, 19, 19, 19, 21, 22, 22, 22, 22, 22, 22, 22, 22, 20, 20, 19,
+        19, 19, 19, 19, 21, 22, 22, 23, 23, 22, 22, 23, 23, 21, 21, 19, 19, 18,
+        18, 18,
         /* Size 16x32 */
-        64, 65, 65, 65, 65, 64, 64, 64, 64, 60, 57, 57, 57, 52, 47, 47, 65, 65,
-        65, 65, 65, 64, 64, 64, 64, 60, 58, 58, 58, 53, 48, 48, 65, 64, 64, 64,
-        64, 64, 63, 63, 63, 60, 58, 58, 58, 53, 48, 48, 65, 64, 64, 64, 64, 64,
-        63, 63, 63, 60, 58, 58, 58, 53, 48, 48, 65, 64, 64, 64, 64, 64, 63, 63,
-        63, 60, 58, 58, 58, 53, 48, 48, 65, 64, 64, 64, 64, 63, 63, 63, 63, 60,
-        59, 59, 59, 54, 49, 49, 65, 64, 63, 63, 63, 63, 62, 62, 62, 61, 59, 59,
-        59, 55, 50, 50, 65, 64, 63, 63, 63, 63, 62, 62, 62, 61, 59, 59, 59, 55,
-        50, 50, 65, 64, 63, 63, 63, 63, 62, 62, 62, 61, 59, 59, 59, 55, 50, 50,
-        65, 64, 63, 63, 63, 62, 61, 61, 61, 59, 58, 58, 58, 53, 49, 49, 64, 64,
-        63, 63, 63, 61, 60, 60, 60, 58, 56, 56, 56, 53, 49, 49, 64, 64, 63, 63,
-        63, 61, 60, 60, 60, 58, 56, 56, 56, 53, 49, 49, 64, 64, 63, 63, 63, 61,
-        60, 60, 60, 58, 56, 56, 56, 53, 49, 49, 64, 63, 63, 63, 63, 61, 59, 59,
-        59, 57, 55, 55, 55, 51, 48, 48, 64, 63, 62, 62, 62, 60, 58, 58, 58, 55,
-        53, 53, 53, 51, 48, 48, 64, 63, 62, 62, 62, 60, 58, 58, 58, 55, 53, 53,
-        53, 51, 48, 48, 64, 63, 62, 62, 62, 60, 58, 58, 58, 55, 53, 53, 53, 51,
-        48, 48, 62, 62, 61, 61, 61, 59, 57, 57, 57, 54, 51, 51, 51, 48, 46, 46,
-        60, 60, 60, 60, 60, 58, 55, 55, 55, 52, 48, 48, 48, 46, 43, 43, 60, 60,
-        60, 60, 60, 58, 55, 55, 55, 52, 48, 48, 48, 46, 43, 43, 60, 60, 60, 60,
-        60, 58, 55, 55, 55, 52, 48, 48, 48, 46, 43, 43, 59, 59, 59, 59, 59, 57,
-        55, 55, 55, 50, 46, 46, 46, 43, 41, 41, 57, 59, 59, 59, 59, 56, 53, 53,
-        53, 48, 43, 43, 43, 40, 38, 38, 57, 59, 59, 59, 59, 56, 53, 53, 53, 48,
-        43, 43, 43, 40, 38, 38, 57, 59, 59, 59, 59, 56, 53, 53, 53, 48, 43, 43,
-        43, 40, 38, 38, 55, 55, 57, 57, 57, 54, 52, 52, 52, 47, 42, 42, 42, 39,
-        37, 37, 52, 53, 55, 55, 55, 53, 51, 51, 51, 46, 41, 41, 41, 38, 35, 35,
-        52, 53, 55, 55, 55, 53, 51, 51, 51, 46, 41, 41, 41, 38, 35, 35, 52, 53,
-        55, 55, 55, 53, 51, 51, 51, 46, 41, 41, 41, 38, 35, 35, 49, 51, 52, 52,
-        52, 51, 49, 49, 49, 44, 39, 39, 39, 37, 34, 34, 47, 48, 50, 50, 50, 49,
-        48, 48, 48, 43, 38, 38, 38, 35, 33, 33, 47, 48, 50, 50, 50, 49, 48, 48,
-        48, 43, 38, 38, 38, 35, 33, 33,
+        32, 33, 33, 33, 33, 31, 28, 28, 28, 24, 21, 21, 21, 21, 21, 21, 33, 33,
+        33, 33, 33, 30, 28, 28, 28, 24, 22, 22, 22, 21, 21, 21, 33, 33, 33, 33,
+        33, 30, 27, 27, 27, 24, 22, 22, 22, 22, 22, 22, 33, 33, 33, 33, 33, 30,
+        27, 27, 27, 24, 22, 22, 22, 22, 22, 22, 33, 33, 33, 33, 33, 30, 27, 27,
+        27, 24, 22, 22, 22, 22, 22, 22, 33, 33, 32, 32, 32, 29, 26, 26, 26, 24,
+        22, 22, 22, 22, 22, 22, 34, 33, 32, 32, 32, 29, 26, 26, 26, 24, 22, 22,
+        22, 23, 23, 23, 34, 33, 32, 32, 32, 29, 26, 26, 26, 24, 22, 22, 22, 23,
+        23, 23, 34, 33, 32, 32, 32, 29, 26, 26, 26, 24, 22, 22, 22, 23, 23, 23,
+        32, 31, 30, 30, 30, 28, 25, 25, 25, 23, 22, 22, 22, 22, 23, 23, 31, 30,
+        28, 28, 28, 26, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 31, 30, 28, 28,
+        28, 26, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 31, 30, 28, 28, 28, 26,
+        24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 29, 28, 27, 27, 27, 25, 23, 23,
+        23, 22, 22, 22, 22, 22, 23, 23, 28, 27, 26, 26, 26, 24, 22, 22, 22, 22,
+        22, 22, 22, 22, 23, 23, 28, 27, 26, 26, 26, 24, 22, 22, 22, 22, 22, 22,
+        22, 22, 23, 23, 28, 27, 26, 26, 26, 24, 22, 22, 22, 22, 22, 22, 22, 22,
+        23, 23, 26, 26, 25, 25, 25, 23, 22, 22, 22, 21, 21, 21, 21, 21, 22, 22,
+        24, 24, 24, 24, 24, 23, 22, 22, 22, 21, 20, 20, 20, 20, 21, 21, 24, 24,
+        24, 24, 24, 23, 22, 22, 22, 21, 20, 20, 20, 20, 21, 21, 24, 24, 24, 24,
+        24, 23, 22, 22, 22, 21, 20, 20, 20, 20, 21, 21, 23, 23, 23, 23, 23, 22,
+        22, 22, 22, 21, 20, 20, 20, 20, 20, 20, 21, 21, 22, 22, 22, 22, 21, 21,
+        21, 20, 19, 19, 19, 19, 19, 19, 21, 21, 22, 22, 22, 22, 21, 21, 21, 20,
+        19, 19, 19, 19, 19, 19, 21, 21, 22, 22, 22, 22, 21, 21, 21, 20, 19, 19,
+        19, 19, 19, 19, 21, 22, 22, 22, 22, 22, 22, 22, 22, 20, 19, 19, 19, 19,
+        19, 19, 21, 22, 22, 22, 22, 22, 22, 22, 22, 20, 19, 19, 19, 19, 18, 18,
+        21, 22, 22, 22, 22, 22, 22, 22, 22, 20, 19, 19, 19, 19, 18, 18, 21, 22,
+        22, 22, 22, 22, 22, 22, 22, 20, 19, 19, 19, 19, 18, 18, 21, 22, 23, 23,
+        23, 22, 22, 22, 22, 21, 19, 19, 19, 19, 18, 18, 21, 22, 23, 23, 23, 23,
+        22, 22, 22, 21, 19, 19, 19, 18, 18, 18, 21, 22, 23, 23, 23, 23, 22, 22,
+        22, 21, 19, 19, 19, 18, 18, 18,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 62,
-        60, 60, 60, 59, 57, 57, 57, 55, 52, 52, 52, 49, 47, 47, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 62, 60, 60, 60, 59,
-        59, 59, 59, 55, 53, 53, 53, 51, 48, 48, 65, 65, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 60, 60, 60, 59, 59, 59, 59, 57,
-        55, 55, 55, 52, 50, 50, 65, 65, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 63, 62, 62, 62, 61, 60, 60, 60, 59, 59, 59, 59, 57, 55, 55, 55, 52,
-        50, 50, 65, 65, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62,
-        62, 61, 60, 60, 60, 59, 59, 59, 59, 57, 55, 55, 55, 52, 50, 50, 64, 64,
-        64, 64, 64, 63, 63, 63, 63, 62, 61, 61, 61, 61, 60, 60, 60, 59, 58, 58,
-        58, 57, 56, 56, 56, 54, 53, 53, 53, 51, 49, 49, 64, 64, 63, 63, 63, 63,
-        62, 62, 62, 61, 60, 60, 60, 59, 58, 58, 58, 57, 55, 55, 55, 55, 53, 53,
-        53, 52, 51, 51, 51, 49, 48, 48, 64, 64, 63, 63, 63, 63, 62, 62, 62, 61,
-        60, 60, 60, 59, 58, 58, 58, 57, 55, 55, 55, 55, 53, 53, 53, 52, 51, 51,
-        51, 49, 48, 48, 64, 64, 63, 63, 63, 63, 62, 62, 62, 61, 60, 60, 60, 59,
-        58, 58, 58, 57, 55, 55, 55, 55, 53, 53, 53, 52, 51, 51, 51, 49, 48, 48,
-        60, 60, 60, 60, 60, 60, 61, 61, 61, 59, 58, 58, 58, 57, 55, 55, 55, 54,
-        52, 52, 52, 50, 48, 48, 48, 47, 46, 46, 46, 44, 43, 43, 57, 58, 58, 58,
-        58, 59, 59, 59, 59, 58, 56, 56, 56, 55, 53, 53, 53, 51, 48, 48, 48, 46,
-        43, 43, 43, 42, 41, 41, 41, 39, 38, 38, 57, 58, 58, 58, 58, 59, 59, 59,
-        59, 58, 56, 56, 56, 55, 53, 53, 53, 51, 48, 48, 48, 46, 43, 43, 43, 42,
-        41, 41, 41, 39, 38, 38, 57, 58, 58, 58, 58, 59, 59, 59, 59, 58, 56, 56,
-        56, 55, 53, 53, 53, 51, 48, 48, 48, 46, 43, 43, 43, 42, 41, 41, 41, 39,
-        38, 38, 52, 53, 53, 53, 53, 54, 55, 55, 55, 53, 53, 53, 53, 51, 51, 51,
-        51, 48, 46, 46, 46, 43, 40, 40, 40, 39, 38, 38, 38, 37, 35, 35, 47, 48,
-        48, 48, 48, 49, 50, 50, 50, 49, 49, 49, 49, 48, 48, 48, 48, 46, 43, 43,
-        43, 41, 38, 38, 38, 37, 35, 35, 35, 34, 33, 33, 47, 48, 48, 48, 48, 49,
-        50, 50, 50, 49, 49, 49, 49, 48, 48, 48, 48, 46, 43, 43, 43, 41, 38, 38,
-        38, 37, 35, 35, 35, 34, 33, 33,
+        32, 33, 33, 33, 33, 33, 34, 34, 34, 32, 31, 31, 31, 29, 28, 28, 28, 26,
+        24, 24, 24, 23, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 31, 30, 30, 30, 28, 27, 27, 27, 26, 24, 24, 24, 23,
+        21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 33, 33, 33, 33, 33, 32, 32, 32,
+        32, 30, 28, 28, 28, 27, 26, 26, 26, 25, 24, 24, 24, 23, 22, 22, 22, 22,
+        22, 22, 22, 23, 23, 23, 33, 33, 33, 33, 33, 32, 32, 32, 32, 30, 28, 28,
+        28, 27, 26, 26, 26, 25, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 23,
+        23, 23, 33, 33, 33, 33, 33, 32, 32, 32, 32, 30, 28, 28, 28, 27, 26, 26,
+        26, 25, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 31, 30,
+        30, 30, 30, 29, 29, 29, 29, 28, 26, 26, 26, 25, 24, 24, 24, 23, 23, 23,
+        23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 28, 28, 27, 27, 27, 26,
+        26, 26, 26, 25, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21,
+        21, 22, 22, 22, 22, 22, 22, 22, 28, 28, 27, 27, 27, 26, 26, 26, 26, 25,
+        24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 22, 22, 22,
+        22, 22, 22, 22, 28, 28, 27, 27, 27, 26, 26, 26, 26, 25, 24, 24, 24, 23,
+        22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22,
+        24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 22, 22, 22, 22, 21,
+        21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20, 20,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 21, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20, 20, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 21, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 21, 21, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22,
+        22, 21, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 21, 21,
+        22, 22, 22, 22, 23, 23, 23, 23, 22, 22, 22, 23, 23, 23, 23, 22, 21, 21,
+        21, 20, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 21, 21, 22, 22, 22, 22,
+        23, 23, 23, 23, 22, 22, 22, 23, 23, 23, 23, 22, 21, 21, 21, 20, 19, 19,
+        19, 19, 18, 18, 18, 18, 18, 18,
         /* Size 4x16 */
-        65, 64, 60, 52, 64, 64, 60, 53, 64, 64, 60, 53, 64, 63, 61, 55, 64, 63,
-        61, 55, 64, 61, 58, 53, 64, 61, 58, 53, 63, 60, 55, 51, 63, 60, 55, 51,
-        60, 58, 52, 46, 60, 58, 52, 46, 59, 56, 48, 40, 59, 56, 48, 40, 53, 53,
-        46, 38, 53, 53, 46, 38, 48, 49, 43, 35,
+        33, 31, 24, 21, 33, 30, 24, 22, 33, 30, 24, 22, 33, 29, 24, 23, 33, 29,
+        24, 23, 30, 26, 23, 22, 30, 26, 23, 22, 27, 24, 22, 22, 27, 24, 22, 22,
+        24, 23, 21, 20, 24, 23, 21, 20, 21, 22, 20, 19, 21, 22, 20, 19, 22, 22,
+        20, 19, 22, 22, 20, 19, 22, 23, 21, 18,
         /* Size 16x4 */
-        65, 64, 64, 64, 64, 64, 64, 63, 63, 60, 60, 59, 59, 53, 53, 48, 64, 64,
-        64, 63, 63, 61, 61, 60, 60, 58, 58, 56, 56, 53, 53, 49, 60, 60, 60, 61,
-        61, 58, 58, 55, 55, 52, 52, 48, 48, 46, 46, 43, 52, 53, 53, 55, 55, 53,
-        53, 51, 51, 46, 46, 40, 40, 38, 38, 35,
+        33, 33, 33, 33, 33, 30, 30, 27, 27, 24, 24, 21, 21, 22, 22, 22, 31, 30,
+        30, 29, 29, 26, 26, 24, 24, 23, 23, 22, 22, 22, 22, 23, 24, 24, 24, 24,
+        24, 23, 23, 22, 22, 21, 21, 20, 20, 20, 20, 21, 21, 22, 22, 23, 23, 22,
+        22, 22, 22, 20, 20, 19, 19, 19, 19, 18,
         /* Size 8x32 */
-        64, 65, 65, 64, 64, 57, 57, 47, 65, 65, 65, 64, 64, 58, 58, 48, 65, 64,
-        64, 63, 63, 58, 58, 48, 65, 64, 64, 63, 63, 58, 58, 48, 65, 64, 64, 63,
-        63, 58, 58, 48, 65, 64, 64, 63, 63, 59, 59, 49, 65, 63, 63, 62, 62, 59,
-        59, 50, 65, 63, 63, 62, 62, 59, 59, 50, 65, 63, 63, 62, 62, 59, 59, 50,
-        65, 63, 63, 61, 61, 58, 58, 49, 64, 63, 63, 60, 60, 56, 56, 49, 64, 63,
-        63, 60, 60, 56, 56, 49, 64, 63, 63, 60, 60, 56, 56, 49, 64, 63, 63, 59,
-        59, 55, 55, 48, 64, 62, 62, 58, 58, 53, 53, 48, 64, 62, 62, 58, 58, 53,
-        53, 48, 64, 62, 62, 58, 58, 53, 53, 48, 62, 61, 61, 57, 57, 51, 51, 46,
-        60, 60, 60, 55, 55, 48, 48, 43, 60, 60, 60, 55, 55, 48, 48, 43, 60, 60,
-        60, 55, 55, 48, 48, 43, 59, 59, 59, 55, 55, 46, 46, 41, 57, 59, 59, 53,
-        53, 43, 43, 38, 57, 59, 59, 53, 53, 43, 43, 38, 57, 59, 59, 53, 53, 43,
-        43, 38, 55, 57, 57, 52, 52, 42, 42, 37, 52, 55, 55, 51, 51, 41, 41, 35,
-        52, 55, 55, 51, 51, 41, 41, 35, 52, 55, 55, 51, 51, 41, 41, 35, 49, 52,
-        52, 49, 49, 39, 39, 34, 47, 50, 50, 48, 48, 38, 38, 33, 47, 50, 50, 48,
-        48, 38, 38, 33,
+        32, 33, 33, 28, 28, 21, 21, 21, 33, 33, 33, 28, 28, 22, 22, 21, 33, 33,
+        33, 27, 27, 22, 22, 22, 33, 33, 33, 27, 27, 22, 22, 22, 33, 33, 33, 27,
+        27, 22, 22, 22, 33, 32, 32, 26, 26, 22, 22, 22, 34, 32, 32, 26, 26, 22,
+        22, 23, 34, 32, 32, 26, 26, 22, 22, 23, 34, 32, 32, 26, 26, 22, 22, 23,
+        32, 30, 30, 25, 25, 22, 22, 23, 31, 28, 28, 24, 24, 22, 22, 22, 31, 28,
+        28, 24, 24, 22, 22, 22, 31, 28, 28, 24, 24, 22, 22, 22, 29, 27, 27, 23,
+        23, 22, 22, 23, 28, 26, 26, 22, 22, 22, 22, 23, 28, 26, 26, 22, 22, 22,
+        22, 23, 28, 26, 26, 22, 22, 22, 22, 23, 26, 25, 25, 22, 22, 21, 21, 22,
+        24, 24, 24, 22, 22, 20, 20, 21, 24, 24, 24, 22, 22, 20, 20, 21, 24, 24,
+        24, 22, 22, 20, 20, 21, 23, 23, 23, 22, 22, 20, 20, 20, 21, 22, 22, 21,
+        21, 19, 19, 19, 21, 22, 22, 21, 21, 19, 19, 19, 21, 22, 22, 21, 21, 19,
+        19, 19, 21, 22, 22, 22, 22, 19, 19, 19, 21, 22, 22, 22, 22, 19, 19, 18,
+        21, 22, 22, 22, 22, 19, 19, 18, 21, 22, 22, 22, 22, 19, 19, 18, 21, 23,
+        23, 22, 22, 19, 19, 18, 21, 23, 23, 22, 22, 19, 19, 18, 21, 23, 23, 22,
+        22, 19, 19, 18,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 62,
-        60, 60, 60, 59, 57, 57, 57, 55, 52, 52, 52, 49, 47, 47, 65, 65, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 60, 60, 60, 59,
-        59, 59, 59, 57, 55, 55, 55, 52, 50, 50, 65, 65, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 60, 60, 60, 59, 59, 59, 59, 57,
-        55, 55, 55, 52, 50, 50, 64, 64, 63, 63, 63, 63, 62, 62, 62, 61, 60, 60,
-        60, 59, 58, 58, 58, 57, 55, 55, 55, 55, 53, 53, 53, 52, 51, 51, 51, 49,
-        48, 48, 64, 64, 63, 63, 63, 63, 62, 62, 62, 61, 60, 60, 60, 59, 58, 58,
-        58, 57, 55, 55, 55, 55, 53, 53, 53, 52, 51, 51, 51, 49, 48, 48, 57, 58,
-        58, 58, 58, 59, 59, 59, 59, 58, 56, 56, 56, 55, 53, 53, 53, 51, 48, 48,
-        48, 46, 43, 43, 43, 42, 41, 41, 41, 39, 38, 38, 57, 58, 58, 58, 58, 59,
-        59, 59, 59, 58, 56, 56, 56, 55, 53, 53, 53, 51, 48, 48, 48, 46, 43, 43,
-        43, 42, 41, 41, 41, 39, 38, 38, 47, 48, 48, 48, 48, 49, 50, 50, 50, 49,
-        49, 49, 49, 48, 48, 48, 48, 46, 43, 43, 43, 41, 38, 38, 38, 37, 35, 35,
-        35, 34, 33, 33 },
-      { /* Chroma */
-#if CONFIG_CB4X4
-        /* Size 2x2 */
-        64, 44, 44, 39,
-#endif
-        /* Size 4x4 */
-        65, 59, 48, 44, 59, 53, 46, 44, 48, 46, 42, 41, 44, 44, 41, 38,
-        /* Size 8x8 */
-        65, 66, 63, 58, 52, 46, 43, 43, 66, 65, 62, 55, 50, 46, 44, 45, 63, 62,
-        58, 52, 48, 46, 44, 45, 58, 55, 52, 48, 45, 44, 44, 45, 52, 50, 48, 45,
-        43, 42, 42, 43, 46, 46, 46, 44, 42, 41, 40, 40, 43, 44, 44, 44, 42, 40,
-        38, 38, 43, 45, 45, 45, 43, 40, 38, 37,
-        /* Size 16x16 */
-        64, 66, 66, 67, 67, 61, 61, 56, 56, 49, 49, 42, 42, 42, 42, 42, 66, 65,
-        65, 66, 66, 59, 59, 53, 53, 48, 48, 43, 43, 44, 44, 44, 66, 65, 65, 66,
-        66, 59, 59, 53, 53, 48, 48, 43, 43, 44, 44, 44, 67, 66, 66, 64, 64, 58,
-        58, 51, 51, 48, 48, 44, 44, 45, 45, 46, 67, 66, 66, 64, 64, 58, 58, 51,
-        51, 48, 48, 44, 44, 45, 45, 46, 61, 59, 59, 58, 58, 53, 53, 47, 47, 46,
-        46, 43, 43, 44, 44, 45, 61, 59, 59, 58, 58, 53, 53, 47, 47, 46, 46, 43,
-        43, 44, 44, 45, 56, 53, 53, 51, 51, 47, 47, 43, 43, 43, 43, 43, 43, 44,
-        44, 45, 56, 53, 53, 51, 51, 47, 47, 43, 43, 43, 43, 43, 43, 44, 44, 45,
-        49, 48, 48, 48, 48, 46, 46, 43, 43, 42, 42, 41, 41, 41, 41, 42, 49, 48,
-        48, 48, 48, 46, 46, 43, 43, 42, 42, 41, 41, 41, 41, 42, 42, 43, 43, 44,
-        44, 43, 43, 43, 43, 41, 41, 39, 39, 39, 39, 38, 42, 43, 43, 44, 44, 43,
-        43, 43, 43, 41, 41, 39, 39, 39, 39, 38, 42, 44, 44, 45, 45, 44, 44, 44,
-        44, 41, 41, 39, 39, 38, 38, 37, 42, 44, 44, 45, 45, 44, 44, 44, 44, 41,
-        41, 39, 39, 38, 38, 37, 42, 44, 44, 46, 46, 45, 45, 45, 45, 42, 42, 38,
-        38, 37, 37, 35,
-        /* Size 32x32 */
-        64, 65, 66, 66, 66, 66, 67, 67, 67, 64, 61, 61, 61, 59, 56, 56, 56, 53,
-        49, 49, 49, 46, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 65, 65, 65, 65,
-        65, 66, 66, 66, 66, 63, 60, 60, 60, 58, 55, 55, 55, 52, 49, 49, 49, 46,
-        42, 42, 42, 43, 43, 43, 43, 43, 43, 43, 66, 65, 65, 65, 65, 65, 66, 66,
-        66, 62, 59, 59, 59, 56, 53, 53, 53, 51, 48, 48, 48, 46, 43, 43, 43, 43,
-        44, 44, 44, 44, 44, 44, 66, 65, 65, 65, 65, 65, 66, 66, 66, 62, 59, 59,
-        59, 56, 53, 53, 53, 51, 48, 48, 48, 46, 43, 43, 43, 43, 44, 44, 44, 44,
-        44, 44, 66, 65, 65, 65, 65, 65, 66, 66, 66, 62, 59, 59, 59, 56, 53, 53,
-        53, 51, 48, 48, 48, 46, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 66, 66,
-        65, 65, 65, 65, 65, 65, 65, 62, 59, 59, 59, 55, 53, 53, 53, 50, 48, 48,
-        48, 46, 44, 44, 44, 44, 44, 44, 44, 45, 45, 45, 67, 66, 66, 66, 66, 65,
-        64, 64, 64, 61, 58, 58, 58, 55, 51, 51, 51, 49, 48, 48, 48, 46, 44, 44,
-        44, 45, 45, 45, 45, 45, 46, 46, 67, 66, 66, 66, 66, 65, 64, 64, 64, 61,
-        58, 58, 58, 55, 51, 51, 51, 49, 48, 48, 48, 46, 44, 44, 44, 45, 45, 45,
-        45, 45, 46, 46, 67, 66, 66, 66, 66, 65, 64, 64, 64, 61, 58, 58, 58, 55,
-        51, 51, 51, 49, 48, 48, 48, 46, 44, 44, 44, 45, 45, 45, 45, 45, 46, 46,
-        64, 63, 62, 62, 62, 62, 61, 61, 61, 58, 55, 55, 55, 52, 49, 49, 49, 48,
-        47, 47, 47, 46, 44, 44, 44, 44, 45, 45, 45, 45, 46, 46, 61, 60, 59, 59,
-        59, 59, 58, 58, 58, 55, 53, 53, 53, 50, 47, 47, 47, 47, 46, 46, 46, 45,
-        43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 61, 60, 59, 59, 59, 59, 58, 58,
-        58, 55, 53, 53, 53, 50, 47, 47, 47, 47, 46, 46, 46, 45, 43, 43, 43, 44,
-        44, 44, 44, 45, 45, 45, 61, 60, 59, 59, 59, 59, 58, 58, 58, 55, 53, 53,
-        53, 50, 47, 47, 47, 47, 46, 46, 46, 45, 43, 43, 43, 44, 44, 44, 44, 45,
-        45, 45, 59, 58, 56, 56, 56, 55, 55, 55, 55, 52, 50, 50, 50, 48, 45, 45,
-        45, 45, 45, 45, 45, 44, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 56, 55,
-        53, 53, 53, 53, 51, 51, 51, 49, 47, 47, 47, 45, 43, 43, 43, 43, 43, 43,
-        43, 43, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 56, 55, 53, 53, 53, 53,
-        51, 51, 51, 49, 47, 47, 47, 45, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
-        43, 44, 44, 44, 44, 45, 45, 45, 56, 55, 53, 53, 53, 53, 51, 51, 51, 49,
-        47, 47, 47, 45, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44,
-        44, 45, 45, 45, 53, 52, 51, 51, 51, 50, 49, 49, 49, 48, 47, 47, 47, 45,
-        43, 43, 43, 43, 43, 43, 43, 42, 42, 42, 42, 42, 43, 43, 43, 43, 44, 44,
-        49, 49, 48, 48, 48, 48, 48, 48, 48, 47, 46, 46, 46, 45, 43, 43, 43, 43,
-        42, 42, 42, 41, 41, 41, 41, 41, 41, 41, 41, 41, 42, 42, 49, 49, 48, 48,
-        48, 48, 48, 48, 48, 47, 46, 46, 46, 45, 43, 43, 43, 43, 42, 42, 42, 41,
-        41, 41, 41, 41, 41, 41, 41, 41, 42, 42, 49, 49, 48, 48, 48, 48, 48, 48,
-        48, 47, 46, 46, 46, 45, 43, 43, 43, 43, 42, 42, 42, 41, 41, 41, 41, 41,
-        41, 41, 41, 41, 42, 42, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 45, 45,
-        45, 44, 43, 43, 43, 42, 41, 41, 41, 41, 40, 40, 40, 40, 40, 40, 40, 40,
-        40, 40, 42, 42, 43, 43, 43, 44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 43,
-        43, 42, 41, 41, 41, 40, 39, 39, 39, 39, 39, 39, 39, 38, 38, 38, 42, 42,
-        43, 43, 43, 44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 42, 41, 41,
-        41, 40, 39, 39, 39, 39, 39, 39, 39, 38, 38, 38, 42, 42, 43, 43, 43, 44,
-        44, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 42, 41, 41, 41, 40, 39, 39,
-        39, 39, 39, 39, 39, 38, 38, 38, 42, 43, 43, 43, 43, 44, 45, 45, 45, 44,
-        44, 44, 44, 44, 44, 44, 44, 42, 41, 41, 41, 40, 39, 39, 39, 38, 38, 38,
-        38, 38, 38, 38, 42, 43, 44, 44, 44, 44, 45, 45, 45, 45, 44, 44, 44, 44,
-        44, 44, 44, 43, 41, 41, 41, 40, 39, 39, 39, 38, 38, 38, 38, 37, 37, 37,
-        42, 43, 44, 44, 44, 44, 45, 45, 45, 45, 44, 44, 44, 44, 44, 44, 44, 43,
-        41, 41, 41, 40, 39, 39, 39, 38, 38, 38, 38, 37, 37, 37, 42, 43, 44, 44,
-        44, 44, 45, 45, 45, 45, 44, 44, 44, 44, 44, 44, 44, 43, 41, 41, 41, 40,
-        39, 39, 39, 38, 38, 38, 38, 37, 37, 37, 42, 43, 44, 44, 44, 45, 45, 45,
-        45, 45, 45, 45, 45, 45, 45, 45, 45, 43, 41, 41, 41, 40, 38, 38, 38, 38,
-        37, 37, 37, 37, 36, 36, 42, 43, 44, 44, 44, 45, 46, 46, 46, 46, 45, 45,
-        45, 45, 45, 45, 45, 44, 42, 42, 42, 40, 38, 38, 38, 38, 37, 37, 37, 36,
-        35, 35, 42, 43, 44, 44, 44, 45, 46, 46, 46, 46, 45, 45, 45, 45, 45, 45,
-        45, 44, 42, 42, 42, 40, 38, 38, 38, 38, 37, 37, 37, 36, 35, 35,
-        /* Size 4x8 */
-        65, 60, 49, 43, 65, 59, 48, 44, 62, 55, 47, 45, 56, 50, 45, 44, 51, 47,
-        43, 43, 46, 45, 41, 40, 43, 44, 41, 38, 44, 45, 41, 37,
-        /* Size 8x4 */
-        65, 65, 62, 56, 51, 46, 43, 44, 60, 59, 55, 50, 47, 45, 44, 45, 49, 48,
-        47, 45, 43, 41, 41, 41, 43, 44, 45, 44, 43, 40, 38, 37,
-        /* Size 8x16 */
-        64, 66, 66, 55, 55, 43, 43, 42, 65, 65, 65, 53, 53, 44, 44, 44, 65, 65,
-        65, 53, 53, 44, 44, 44, 67, 64, 64, 51, 51, 45, 45, 45, 67, 64, 64, 51,
-        51, 45, 45, 45, 61, 57, 57, 48, 48, 44, 44, 45, 61, 57, 57, 48, 48, 44,
-        44, 45, 55, 51, 51, 44, 44, 43, 43, 45, 55, 51, 51, 44, 44, 43, 43, 45,
-        49, 48, 48, 43, 43, 41, 41, 41, 49, 48, 48, 43, 43, 41, 41, 41, 42, 44,
-        44, 43, 43, 39, 39, 38, 42, 44, 44, 43, 43, 39, 39, 38, 42, 45, 45, 44,
-        44, 39, 39, 37, 42, 45, 45, 44, 44, 39, 39, 37, 42, 45, 45, 45, 45, 38,
-        38, 35,
-        /* Size 16x8 */
-        64, 65, 65, 67, 67, 61, 61, 55, 55, 49, 49, 42, 42, 42, 42, 42, 66, 65,
-        65, 64, 64, 57, 57, 51, 51, 48, 48, 44, 44, 45, 45, 45, 66, 65, 65, 64,
-        64, 57, 57, 51, 51, 48, 48, 44, 44, 45, 45, 45, 55, 53, 53, 51, 51, 48,
-        48, 44, 44, 43, 43, 43, 43, 44, 44, 45, 55, 53, 53, 51, 51, 48, 48, 44,
-        44, 43, 43, 43, 43, 44, 44, 45, 43, 44, 44, 45, 45, 44, 44, 43, 43, 41,
-        41, 39, 39, 39, 39, 38, 43, 44, 44, 45, 45, 44, 44, 43, 43, 41, 41, 39,
-        39, 39, 39, 38, 42, 44, 44, 45, 45, 45, 45, 45, 45, 41, 41, 38, 38, 37,
-        37, 35,
-        /* Size 16x32 */
-        64, 65, 66, 66, 66, 61, 55, 55, 55, 49, 43, 43, 43, 42, 42, 42, 65, 65,
-        66, 66, 66, 60, 55, 55, 55, 49, 43, 43, 43, 43, 43, 43, 65, 65, 65, 65,
-        65, 59, 53, 53, 53, 48, 44, 44, 44, 44, 44, 44, 65, 65, 65, 65, 65, 59,
-        53, 53, 53, 48, 44, 44, 44, 44, 44, 44, 65, 65, 65, 65, 65, 59, 53, 53,
-        53, 48, 44, 44, 44, 44, 44, 44, 66, 65, 64, 64, 64, 59, 53, 53, 53, 48,
-        44, 44, 44, 44, 45, 45, 67, 65, 64, 64, 64, 58, 51, 51, 51, 48, 45, 45,
-        45, 45, 45, 45, 67, 65, 64, 64, 64, 58, 51, 51, 51, 48, 45, 45, 45, 45,
-        45, 45, 67, 65, 64, 64, 64, 58, 51, 51, 51, 48, 45, 45, 45, 45, 45, 45,
-        64, 62, 60, 60, 60, 55, 49, 49, 49, 47, 44, 44, 44, 45, 45, 45, 61, 59,
-        57, 57, 57, 53, 48, 48, 48, 46, 44, 44, 44, 44, 45, 45, 61, 59, 57, 57,
-        57, 53, 48, 48, 48, 46, 44, 44, 44, 44, 45, 45, 61, 59, 57, 57, 57, 53,
-        48, 48, 48, 46, 44, 44, 44, 44, 45, 45, 58, 56, 54, 54, 54, 50, 46, 46,
-        46, 45, 43, 43, 43, 44, 45, 45, 55, 53, 51, 51, 51, 47, 44, 44, 44, 43,
-        43, 43, 43, 44, 45, 45, 55, 53, 51, 51, 51, 47, 44, 44, 44, 43, 43, 43,
-        43, 44, 45, 45, 55, 53, 51, 51, 51, 47, 44, 44, 44, 43, 43, 43, 43, 44,
-        45, 45, 52, 51, 49, 49, 49, 47, 43, 43, 43, 43, 42, 42, 42, 43, 43, 43,
-        49, 48, 48, 48, 48, 46, 43, 43, 43, 42, 41, 41, 41, 41, 41, 41, 49, 48,
-        48, 48, 48, 46, 43, 43, 43, 42, 41, 41, 41, 41, 41, 41, 49, 48, 48, 48,
-        48, 46, 43, 43, 43, 42, 41, 41, 41, 41, 41, 41, 46, 46, 46, 46, 46, 45,
-        43, 43, 43, 41, 40, 40, 40, 40, 40, 40, 42, 43, 44, 44, 44, 43, 43, 43,
-        43, 41, 39, 39, 39, 38, 38, 38, 42, 43, 44, 44, 44, 43, 43, 43, 43, 41,
-        39, 39, 39, 38, 38, 38, 42, 43, 44, 44, 44, 43, 43, 43, 43, 41, 39, 39,
-        39, 38, 38, 38, 42, 43, 44, 44, 44, 44, 43, 43, 43, 41, 39, 39, 39, 38,
-        38, 38, 42, 44, 45, 45, 45, 44, 44, 44, 44, 41, 39, 39, 39, 38, 37, 37,
-        42, 44, 45, 45, 45, 44, 44, 44, 44, 41, 39, 39, 39, 38, 37, 37, 42, 44,
-        45, 45, 45, 44, 44, 44, 44, 41, 39, 39, 39, 38, 37, 37, 42, 44, 45, 45,
-        45, 45, 44, 44, 44, 41, 39, 39, 39, 37, 36, 36, 42, 44, 45, 45, 45, 45,
-        45, 45, 45, 41, 38, 38, 38, 37, 35, 35, 42, 44, 45, 45, 45, 45, 45, 45,
-        45, 41, 38, 38, 38, 37, 35, 35,
-        /* Size 32x16 */
-        64, 65, 65, 65, 65, 66, 67, 67, 67, 64, 61, 61, 61, 58, 55, 55, 55, 52,
-        49, 49, 49, 46, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 62, 59, 59, 59, 56, 53, 53, 53, 51, 48, 48, 48, 46,
-        43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 66, 66, 65, 65, 65, 64, 64, 64,
-        64, 60, 57, 57, 57, 54, 51, 51, 51, 49, 48, 48, 48, 46, 44, 44, 44, 44,
-        45, 45, 45, 45, 45, 45, 66, 66, 65, 65, 65, 64, 64, 64, 64, 60, 57, 57,
-        57, 54, 51, 51, 51, 49, 48, 48, 48, 46, 44, 44, 44, 44, 45, 45, 45, 45,
-        45, 45, 66, 66, 65, 65, 65, 64, 64, 64, 64, 60, 57, 57, 57, 54, 51, 51,
-        51, 49, 48, 48, 48, 46, 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 61, 60,
-        59, 59, 59, 59, 58, 58, 58, 55, 53, 53, 53, 50, 47, 47, 47, 47, 46, 46,
-        46, 45, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 55, 55, 53, 53, 53, 53,
-        51, 51, 51, 49, 48, 48, 48, 46, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43,
-        43, 43, 44, 44, 44, 44, 45, 45, 55, 55, 53, 53, 53, 53, 51, 51, 51, 49,
-        48, 48, 48, 46, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44,
-        44, 44, 45, 45, 55, 55, 53, 53, 53, 53, 51, 51, 51, 49, 48, 48, 48, 46,
-        44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 45, 45,
-        49, 49, 48, 48, 48, 48, 48, 48, 48, 47, 46, 46, 46, 45, 43, 43, 43, 43,
-        42, 42, 42, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 43, 43, 44, 44,
-        44, 44, 45, 45, 45, 44, 44, 44, 44, 43, 43, 43, 43, 42, 41, 41, 41, 40,
-        39, 39, 39, 39, 39, 39, 39, 39, 38, 38, 43, 43, 44, 44, 44, 44, 45, 45,
-        45, 44, 44, 44, 44, 43, 43, 43, 43, 42, 41, 41, 41, 40, 39, 39, 39, 39,
-        39, 39, 39, 39, 38, 38, 43, 43, 44, 44, 44, 44, 45, 45, 45, 44, 44, 44,
-        44, 43, 43, 43, 43, 42, 41, 41, 41, 40, 39, 39, 39, 39, 39, 39, 39, 39,
-        38, 38, 42, 43, 44, 44, 44, 44, 45, 45, 45, 45, 44, 44, 44, 44, 44, 44,
-        44, 43, 41, 41, 41, 40, 38, 38, 38, 38, 38, 38, 38, 37, 37, 37, 42, 43,
-        44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 43, 41, 41,
-        41, 40, 38, 38, 38, 38, 37, 37, 37, 36, 35, 35, 42, 43, 44, 44, 44, 45,
-        45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 43, 41, 41, 41, 40, 38, 38,
-        38, 38, 37, 37, 37, 36, 35, 35,
-        /* Size 4x16 */
-        65, 61, 49, 42, 65, 59, 48, 44, 65, 59, 48, 44, 65, 58, 48, 45, 65, 58,
-        48, 45, 59, 53, 46, 44, 59, 53, 46, 44, 53, 47, 43, 44, 53, 47, 43, 44,
-        48, 46, 42, 41, 48, 46, 42, 41, 43, 43, 41, 38, 43, 43, 41, 38, 44, 44,
-        41, 38, 44, 44, 41, 38, 44, 45, 41, 37,
-        /* Size 16x4 */
-        65, 65, 65, 65, 65, 59, 59, 53, 53, 48, 48, 43, 43, 44, 44, 44, 61, 59,
-        59, 58, 58, 53, 53, 47, 47, 46, 46, 43, 43, 44, 44, 45, 49, 48, 48, 48,
-        48, 46, 46, 43, 43, 42, 42, 41, 41, 41, 41, 41, 42, 44, 44, 45, 45, 44,
-        44, 44, 44, 41, 41, 38, 38, 38, 38, 37,
-        /* Size 8x32 */
-        64, 66, 66, 55, 55, 43, 43, 42, 65, 66, 66, 55, 55, 43, 43, 43, 65, 65,
-        65, 53, 53, 44, 44, 44, 65, 65, 65, 53, 53, 44, 44, 44, 65, 65, 65, 53,
-        53, 44, 44, 44, 66, 64, 64, 53, 53, 44, 44, 45, 67, 64, 64, 51, 51, 45,
-        45, 45, 67, 64, 64, 51, 51, 45, 45, 45, 67, 64, 64, 51, 51, 45, 45, 45,
-        64, 60, 60, 49, 49, 44, 44, 45, 61, 57, 57, 48, 48, 44, 44, 45, 61, 57,
-        57, 48, 48, 44, 44, 45, 61, 57, 57, 48, 48, 44, 44, 45, 58, 54, 54, 46,
-        46, 43, 43, 45, 55, 51, 51, 44, 44, 43, 43, 45, 55, 51, 51, 44, 44, 43,
-        43, 45, 55, 51, 51, 44, 44, 43, 43, 45, 52, 49, 49, 43, 43, 42, 42, 43,
-        49, 48, 48, 43, 43, 41, 41, 41, 49, 48, 48, 43, 43, 41, 41, 41, 49, 48,
-        48, 43, 43, 41, 41, 41, 46, 46, 46, 43, 43, 40, 40, 40, 42, 44, 44, 43,
-        43, 39, 39, 38, 42, 44, 44, 43, 43, 39, 39, 38, 42, 44, 44, 43, 43, 39,
-        39, 38, 42, 44, 44, 43, 43, 39, 39, 38, 42, 45, 45, 44, 44, 39, 39, 37,
-        42, 45, 45, 44, 44, 39, 39, 37, 42, 45, 45, 44, 44, 39, 39, 37, 42, 45,
-        45, 44, 44, 39, 39, 36, 42, 45, 45, 45, 45, 38, 38, 35, 42, 45, 45, 45,
-        45, 38, 38, 35,
-        /* Size 32x8 */
-        64, 65, 65, 65, 65, 66, 67, 67, 67, 64, 61, 61, 61, 58, 55, 55, 55, 52,
-        49, 49, 49, 46, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 66, 66, 65, 65,
-        65, 64, 64, 64, 64, 60, 57, 57, 57, 54, 51, 51, 51, 49, 48, 48, 48, 46,
-        44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 66, 66, 65, 65, 65, 64, 64, 64,
-        64, 60, 57, 57, 57, 54, 51, 51, 51, 49, 48, 48, 48, 46, 44, 44, 44, 44,
-        45, 45, 45, 45, 45, 45, 55, 55, 53, 53, 53, 53, 51, 51, 51, 49, 48, 48,
-        48, 46, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44,
-        45, 45, 55, 55, 53, 53, 53, 53, 51, 51, 51, 49, 48, 48, 48, 46, 44, 44,
-        44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 45, 45, 43, 43,
-        44, 44, 44, 44, 45, 45, 45, 44, 44, 44, 44, 43, 43, 43, 43, 42, 41, 41,
-        41, 40, 39, 39, 39, 39, 39, 39, 39, 39, 38, 38, 43, 43, 44, 44, 44, 44,
-        45, 45, 45, 44, 44, 44, 44, 43, 43, 43, 43, 42, 41, 41, 41, 40, 39, 39,
-        39, 39, 39, 39, 39, 39, 38, 38, 42, 43, 44, 44, 44, 45, 45, 45, 45, 45,
-        45, 45, 45, 45, 45, 45, 45, 43, 41, 41, 41, 40, 38, 38, 38, 38, 37, 37,
-        37, 36, 35, 35 },
+        32, 33, 33, 33, 33, 33, 34, 34, 34, 32, 31, 31, 31, 29, 28, 28, 28, 26,
+        24, 24, 24, 23, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 33, 33, 33, 33,
+        33, 32, 32, 32, 32, 30, 28, 28, 28, 27, 26, 26, 26, 25, 24, 24, 24, 23,
+        22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 33, 33, 33, 33, 33, 32, 32, 32,
+        32, 30, 28, 28, 28, 27, 26, 26, 26, 25, 24, 24, 24, 23, 22, 22, 22, 22,
+        22, 22, 22, 23, 23, 23, 28, 28, 27, 27, 27, 26, 26, 26, 26, 25, 24, 24,
+        24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 22, 22, 22, 22, 22,
+        22, 22, 28, 28, 27, 27, 27, 26, 26, 26, 26, 25, 24, 24, 24, 23, 22, 22,
+        22, 22, 22, 22, 22, 22, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 21, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20,
+        20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 21, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20, 20, 20, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23,
+        22, 22, 22, 23, 23, 23, 23, 22, 21, 21, 21, 20, 19, 19, 19, 19, 18, 18,
+        18, 18, 18, 18 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        64, 61, 61, 52,
+        32, 31, 31, 26,
 #endif
         /* Size 4x4 */
-        64, 64, 63, 59, 64, 63, 62, 59, 63, 62, 58, 54, 59, 59, 54, 45,
+        32, 32, 32, 29, 32, 32, 31, 29, 32, 31, 29, 27, 29, 29, 27, 22,
         /* Size 8x8 */
-        65, 65, 65, 64, 64, 63, 60, 58, 65, 64, 64, 64, 63, 62, 60, 59, 65, 64,
-        63, 63, 63, 62, 61, 59, 64, 64, 63, 61, 60, 59, 58, 56, 64, 63, 63, 60,
-        59, 58, 56, 54, 63, 62, 62, 59, 58, 56, 54, 51, 60, 60, 61, 58, 56, 54,
-        52, 48, 58, 59, 59, 56, 54, 51, 48, 42,
+        33, 33, 33, 32, 32, 32, 30, 29, 33, 32, 32, 32, 32, 31, 30, 29, 33, 32,
+        32, 32, 32, 31, 31, 30, 32, 32, 32, 31, 30, 30, 29, 28, 32, 32, 32, 30,
+        29, 29, 28, 27, 32, 31, 31, 30, 29, 28, 27, 26, 30, 30, 31, 29, 28, 27,
+        26, 24, 29, 29, 30, 28, 27, 26, 24, 21,
         /* Size 16x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 61, 60, 59, 57, 57, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 61, 60, 59, 58, 58, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 63, 63, 61, 60, 59, 59, 59, 65, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 61, 60, 60, 59, 59, 65, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 61, 61, 60, 59, 59, 65, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 61, 61, 60, 59, 59, 65, 64, 64, 63, 63, 63, 62, 62, 61, 61, 61, 59,
-        59, 58, 57, 57, 65, 64, 64, 63, 63, 63, 62, 61, 61, 60, 60, 59, 58, 57,
-        56, 56, 64, 64, 64, 63, 63, 63, 61, 61, 60, 59, 59, 58, 57, 56, 55, 55,
-        64, 64, 63, 63, 63, 63, 61, 60, 59, 58, 58, 56, 55, 55, 53, 53, 64, 64,
-        63, 63, 63, 63, 61, 60, 59, 58, 58, 56, 55, 55, 53, 53, 61, 61, 61, 61,
-        61, 61, 59, 59, 58, 56, 56, 53, 53, 51, 49, 49, 60, 60, 60, 60, 61, 61,
-        59, 58, 57, 55, 55, 53, 52, 50, 48, 48, 59, 59, 59, 60, 60, 60, 58, 57,
-        56, 55, 55, 51, 50, 48, 46, 46, 57, 58, 59, 59, 59, 59, 57, 56, 55, 53,
-        53, 49, 48, 46, 42, 42, 57, 58, 59, 59, 59, 59, 57, 56, 55, 53, 53, 49,
-        48, 46, 42, 42,
+        32, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 31, 30, 30, 28, 28, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 30, 30, 30, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 30, 30, 30, 33, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 30,
+        29, 29, 28, 28, 33, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 29, 29, 28,
+        28, 28, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 30, 29, 28, 28, 28, 28,
+        32, 32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 28, 28, 28, 27, 27, 32, 32,
+        32, 32, 32, 32, 31, 30, 30, 29, 29, 28, 28, 28, 27, 27, 31, 31, 31, 31,
+        31, 31, 30, 29, 29, 28, 28, 27, 26, 26, 24, 24, 30, 30, 30, 30, 31, 31,
+        29, 29, 28, 28, 28, 26, 26, 25, 24, 24, 30, 30, 30, 30, 30, 30, 29, 28,
+        28, 28, 28, 26, 25, 24, 23, 23, 28, 29, 29, 29, 30, 30, 28, 28, 28, 27,
+        27, 24, 24, 23, 21, 21, 28, 29, 29, 29, 30, 30, 28, 28, 28, 27, 27, 24,
+        24, 23, 21, 21,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 63, 61, 60, 60, 60, 59, 58, 57, 57, 57, 55, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63,
-        61, 60, 60, 60, 59, 59, 58, 58, 58, 55, 65, 65, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 61, 60, 60, 60,
-        59, 59, 58, 58, 58, 56, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 63, 63, 63, 63, 62, 61, 60, 60, 60, 59, 59, 59, 59,
-        59, 56, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 63, 63, 63, 63, 62, 61, 60, 60, 60, 59, 59, 59, 59, 59, 56, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63,
-        63, 62, 61, 60, 60, 60, 59, 59, 59, 59, 59, 56, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 60,
-        60, 60, 60, 59, 59, 59, 59, 57, 65, 65, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 61, 61, 61, 60, 59,
-        59, 59, 59, 58, 65, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 62, 61, 61, 61, 61, 60, 60, 59, 59, 59, 58,
-        65, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 61, 61, 61, 61, 60, 60, 59, 59, 59, 58, 65, 65, 64, 64,
-        64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62,
-        61, 61, 61, 61, 60, 60, 59, 59, 59, 58, 65, 65, 64, 64, 64, 64, 64, 63,
-        63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 61, 60, 59, 59, 59,
-        59, 59, 59, 59, 59, 56, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 62,
-        62, 62, 62, 62, 61, 61, 61, 61, 61, 60, 59, 59, 59, 59, 58, 57, 57, 57,
-        57, 55, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 62, 62, 61, 61, 61,
-        61, 60, 60, 60, 60, 59, 59, 58, 58, 58, 57, 57, 56, 56, 56, 55, 65, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 62, 62, 61, 61, 61, 61, 60, 60, 60,
-        60, 59, 59, 58, 58, 58, 57, 57, 56, 56, 56, 55, 65, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 62, 62, 61, 61, 61, 61, 60, 60, 60, 60, 59, 59, 58,
-        58, 58, 57, 57, 56, 56, 56, 55, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 62, 61, 61, 61, 61, 60, 59, 59, 59, 59, 59, 58, 57, 57, 57, 56, 55,
-        55, 55, 55, 54, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 60,
-        60, 60, 59, 59, 59, 59, 59, 58, 57, 56, 56, 56, 55, 55, 54, 54, 54, 53,
-        64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 60, 60, 60, 59, 59,
-        58, 58, 58, 57, 56, 55, 55, 55, 55, 54, 53, 53, 53, 53, 64, 64, 64, 63,
-        63, 63, 63, 63, 63, 63, 63, 62, 61, 60, 60, 60, 59, 59, 58, 58, 58, 57,
-        56, 55, 55, 55, 55, 54, 53, 53, 53, 53, 64, 64, 64, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 61, 60, 60, 60, 59, 59, 58, 58, 58, 57, 56, 55, 55, 55,
-        55, 54, 53, 53, 53, 53, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 61,
-        60, 59, 59, 59, 59, 58, 57, 57, 57, 56, 55, 54, 54, 54, 53, 52, 51, 51,
-        51, 50, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 60, 59, 59, 59, 59,
-        58, 57, 56, 56, 56, 55, 53, 53, 53, 53, 51, 50, 49, 49, 49, 48, 60, 60,
-        60, 60, 60, 60, 60, 61, 61, 61, 61, 59, 59, 58, 58, 58, 57, 56, 55, 55,
-        55, 54, 53, 52, 52, 52, 50, 49, 48, 48, 48, 47, 60, 60, 60, 60, 60, 60,
-        60, 61, 61, 61, 61, 59, 59, 58, 58, 58, 57, 56, 55, 55, 55, 54, 53, 52,
-        52, 52, 50, 49, 48, 48, 48, 47, 60, 60, 60, 60, 60, 60, 60, 61, 61, 61,
-        61, 59, 59, 58, 58, 58, 57, 56, 55, 55, 55, 54, 53, 52, 52, 52, 50, 49,
-        48, 48, 48, 47, 59, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 59, 58, 57,
-        57, 57, 56, 55, 55, 55, 55, 53, 51, 50, 50, 50, 48, 47, 46, 46, 46, 45,
-        58, 59, 59, 59, 59, 59, 59, 59, 60, 60, 60, 59, 57, 57, 57, 57, 55, 55,
-        54, 54, 54, 52, 50, 49, 49, 49, 47, 45, 44, 44, 44, 43, 57, 58, 58, 59,
-        59, 59, 59, 59, 59, 59, 59, 59, 57, 56, 56, 56, 55, 54, 53, 53, 53, 51,
-        49, 48, 48, 48, 46, 44, 42, 42, 42, 41, 57, 58, 58, 59, 59, 59, 59, 59,
-        59, 59, 59, 59, 57, 56, 56, 56, 55, 54, 53, 53, 53, 51, 49, 48, 48, 48,
-        46, 44, 42, 42, 42, 41, 57, 58, 58, 59, 59, 59, 59, 59, 59, 59, 59, 59,
-        57, 56, 56, 56, 55, 54, 53, 53, 53, 51, 49, 48, 48, 48, 46, 44, 42, 42,
-        42, 41, 55, 55, 56, 56, 56, 56, 57, 58, 58, 58, 58, 56, 55, 55, 55, 55,
-        54, 53, 53, 53, 53, 50, 48, 47, 47, 47, 45, 43, 41, 41, 41, 41,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 32, 31, 30, 30, 30, 30, 29, 28, 28, 28, 28, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 30, 30, 30, 30, 29, 29, 29, 29, 28, 33, 33, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 30,
+        30, 29, 29, 29, 29, 28, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 30, 30, 29, 29, 29,
+        29, 28, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 30, 30, 30, 30, 29, 29, 29, 29, 28, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 30, 30, 30, 30, 29, 29, 29, 29, 28, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30,
+        30, 30, 30, 30, 29, 29, 29, 28, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 30, 30,
+        30, 30, 30, 29, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 31, 31, 31, 30, 30, 30, 30, 30, 29, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30,
+        30, 29, 29, 29, 29, 28, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 29, 29, 29, 29, 28, 28, 28,
+        28, 28, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31,
+        31, 30, 30, 30, 30, 30, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 30, 30, 30,
+        30, 30, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29, 29,
+        29, 29, 28, 28, 28, 28, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29, 29, 28, 28, 28, 28, 28,
+        28, 28, 28, 27, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30,
+        30, 30, 30, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 27, 27, 27, 26,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 30, 30, 29,
+        29, 29, 29, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 30, 30, 29, 29, 29, 29, 28,
+        28, 28, 28, 28, 28, 27, 27, 27, 27, 26, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 30, 30, 30, 30, 29, 29, 29, 29, 28, 28, 28, 28, 28,
+        28, 27, 27, 27, 27, 26, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        30, 30, 30, 30, 29, 29, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26, 26, 26,
+        26, 25, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 29, 29, 29,
+        29, 28, 28, 28, 28, 28, 27, 26, 26, 26, 26, 25, 24, 24, 24, 24, 30, 30,
+        30, 30, 30, 30, 30, 31, 31, 31, 31, 30, 29, 29, 29, 29, 28, 28, 28, 28,
+        28, 27, 26, 26, 26, 26, 25, 24, 24, 24, 24, 24, 30, 30, 30, 30, 30, 30,
+        30, 31, 31, 31, 31, 30, 29, 29, 29, 29, 28, 28, 28, 28, 28, 27, 26, 26,
+        26, 26, 25, 24, 24, 24, 24, 24, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31,
+        31, 30, 29, 29, 29, 29, 28, 28, 28, 28, 28, 27, 26, 26, 26, 26, 25, 24,
+        24, 24, 24, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 29, 28,
+        28, 28, 28, 28, 28, 28, 28, 27, 26, 25, 25, 25, 24, 23, 23, 23, 23, 23,
+        29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 29, 28, 28, 28, 28, 28, 28,
+        27, 27, 27, 26, 25, 24, 24, 24, 23, 22, 22, 22, 22, 21, 28, 29, 29, 29,
+        29, 29, 29, 30, 30, 30, 30, 29, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26,
+        24, 24, 24, 24, 23, 22, 21, 21, 21, 21, 28, 29, 29, 29, 29, 29, 29, 30,
+        30, 30, 30, 29, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26, 24, 24, 24, 24,
+        23, 22, 21, 21, 21, 21, 28, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 29,
+        28, 28, 28, 28, 28, 27, 27, 27, 27, 26, 24, 24, 24, 24, 23, 22, 21, 21,
+        21, 21, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 28, 28, 28, 28, 28,
+        27, 26, 26, 26, 26, 25, 24, 24, 24, 24, 23, 21, 21, 21, 21, 20,
         /* Size 4x8 */
-        65, 65, 64, 58, 64, 64, 63, 58, 64, 63, 62, 59, 64, 63, 60, 56, 64, 62,
-        59, 54, 62, 62, 57, 51, 60, 60, 55, 48, 58, 59, 53, 43,
+        33, 33, 32, 29, 32, 32, 32, 29, 32, 32, 31, 30, 32, 32, 30, 28, 32, 31,
+        29, 27, 31, 31, 28, 26, 30, 30, 28, 24, 29, 30, 27, 21,
         /* Size 8x4 */
-        65, 64, 64, 64, 64, 62, 60, 58, 65, 64, 63, 63, 62, 62, 60, 59, 64, 63,
-        62, 60, 59, 57, 55, 53, 58, 58, 59, 56, 54, 51, 48, 43,
+        33, 32, 32, 32, 32, 31, 30, 29, 33, 32, 32, 32, 31, 31, 30, 30, 32, 32,
+        31, 30, 29, 28, 28, 27, 29, 29, 30, 28, 27, 26, 24, 21,
         /* Size 8x16 */
-        64, 65, 65, 65, 64, 64, 59, 57, 65, 64, 64, 64, 63, 63, 59, 58, 65, 64,
-        64, 64, 63, 63, 59, 58, 65, 64, 64, 63, 63, 63, 59, 59, 65, 64, 63, 63,
-        62, 62, 60, 59, 65, 64, 63, 63, 62, 62, 60, 59, 65, 63, 63, 62, 60, 60,
-        58, 57, 64, 63, 63, 62, 60, 60, 57, 56, 64, 63, 63, 61, 59, 59, 56, 55,
-        64, 63, 62, 60, 58, 58, 55, 53, 64, 63, 62, 60, 58, 58, 55, 53, 61, 61,
-        61, 59, 56, 56, 51, 49, 60, 60, 60, 59, 55, 55, 49, 48, 59, 59, 60, 58,
-        55, 55, 48, 46, 57, 59, 59, 57, 53, 53, 45, 43, 57, 59, 59, 57, 53, 53,
-        45, 43,
+        32, 33, 33, 33, 32, 32, 29, 28, 33, 32, 32, 32, 32, 32, 29, 29, 33, 32,
+        32, 32, 32, 32, 29, 29, 33, 32, 32, 32, 32, 32, 30, 29, 33, 32, 32, 32,
+        31, 31, 30, 30, 33, 32, 32, 32, 31, 31, 30, 30, 33, 32, 32, 31, 30, 30,
+        29, 28, 32, 32, 32, 31, 30, 30, 28, 28, 32, 32, 32, 31, 30, 30, 28, 28,
+        32, 32, 31, 30, 29, 29, 28, 27, 32, 32, 31, 30, 29, 29, 28, 27, 31, 31,
+        31, 29, 28, 28, 26, 25, 30, 30, 30, 29, 28, 28, 25, 24, 30, 30, 30, 29,
+        28, 28, 24, 23, 28, 29, 30, 28, 27, 27, 22, 21, 28, 29, 30, 28, 27, 27,
+        22, 21,
         /* Size 16x8 */
-        64, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 61, 60, 59, 57, 57, 65, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 61, 60, 59, 59, 59, 65, 64, 64, 64,
-        63, 63, 63, 63, 63, 62, 62, 61, 60, 60, 59, 59, 65, 64, 64, 63, 63, 63,
-        62, 62, 61, 60, 60, 59, 59, 58, 57, 57, 64, 63, 63, 63, 62, 62, 60, 60,
-        59, 58, 58, 56, 55, 55, 53, 53, 64, 63, 63, 63, 62, 62, 60, 60, 59, 58,
-        58, 56, 55, 55, 53, 53, 59, 59, 59, 59, 60, 60, 58, 57, 56, 55, 55, 51,
-        49, 48, 45, 45, 57, 58, 58, 59, 59, 59, 57, 56, 55, 53, 53, 49, 48, 46,
-        43, 43,
+        32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 31, 30, 30, 28, 28, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 33, 32, 32, 32, 32, 32,
+        31, 31, 31, 30, 30, 29, 29, 29, 28, 28, 32, 32, 32, 32, 31, 31, 30, 30,
+        30, 29, 29, 28, 28, 28, 27, 27, 32, 32, 32, 32, 31, 31, 30, 30, 30, 29,
+        29, 28, 28, 28, 27, 27, 29, 29, 29, 30, 30, 30, 29, 28, 28, 28, 28, 26,
+        25, 24, 22, 22, 28, 29, 29, 29, 30, 30, 28, 28, 28, 27, 27, 25, 24, 23,
+        21, 21,
         /* Size 16x32 */
-        64, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 61, 59, 57, 57, 57, 65, 65,
-        65, 65, 65, 65, 64, 64, 64, 64, 64, 61, 59, 58, 58, 58, 65, 65, 64, 64,
-        64, 64, 64, 63, 63, 63, 63, 61, 59, 58, 58, 58, 65, 64, 64, 64, 64, 64,
-        64, 63, 63, 63, 63, 61, 59, 58, 58, 58, 65, 64, 64, 64, 64, 64, 64, 63,
-        63, 63, 63, 61, 59, 58, 58, 58, 65, 64, 64, 64, 64, 64, 64, 63, 63, 63,
-        63, 61, 59, 58, 58, 58, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 61,
-        59, 59, 59, 59, 65, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 61, 59, 59,
-        59, 59, 65, 64, 64, 63, 63, 63, 63, 63, 62, 62, 62, 61, 60, 59, 59, 59,
-        65, 64, 64, 63, 63, 63, 63, 63, 62, 62, 62, 61, 60, 59, 59, 59, 65, 64,
-        64, 63, 63, 63, 63, 63, 62, 62, 62, 61, 60, 59, 59, 59, 65, 64, 63, 63,
-        63, 63, 62, 62, 61, 61, 61, 60, 59, 58, 58, 58, 65, 64, 63, 63, 63, 63,
-        62, 61, 60, 60, 60, 59, 58, 57, 57, 57, 64, 64, 63, 63, 63, 63, 62, 60,
-        60, 60, 60, 59, 57, 56, 56, 56, 64, 64, 63, 63, 63, 63, 62, 60, 60, 60,
-        60, 59, 57, 56, 56, 56, 64, 64, 63, 63, 63, 63, 62, 60, 60, 60, 60, 59,
-        57, 56, 56, 56, 64, 64, 63, 63, 63, 63, 61, 60, 59, 59, 59, 58, 56, 55,
-        55, 55, 64, 64, 63, 62, 62, 62, 61, 59, 59, 59, 59, 57, 55, 54, 54, 54,
-        64, 64, 63, 62, 62, 62, 60, 59, 58, 58, 58, 56, 55, 53, 53, 53, 64, 64,
-        63, 62, 62, 62, 60, 59, 58, 58, 58, 56, 55, 53, 53, 53, 64, 64, 63, 62,
-        62, 62, 60, 59, 58, 58, 58, 56, 55, 53, 53, 53, 63, 62, 62, 62, 62, 62,
-        59, 58, 57, 57, 57, 55, 53, 51, 51, 51, 61, 61, 61, 61, 61, 61, 59, 57,
-        56, 56, 56, 53, 51, 49, 49, 49, 60, 60, 60, 60, 60, 60, 59, 57, 55, 55,
-        55, 53, 49, 48, 48, 48, 60, 60, 60, 60, 60, 60, 59, 57, 55, 55, 55, 53,
-        49, 48, 48, 48, 60, 60, 60, 60, 60, 60, 59, 57, 55, 55, 55, 53, 49, 48,
-        48, 48, 59, 59, 59, 60, 60, 60, 58, 55, 55, 55, 55, 51, 48, 46, 46, 46,
-        58, 59, 59, 59, 59, 59, 57, 55, 54, 54, 54, 50, 46, 44, 44, 44, 57, 58,
-        59, 59, 59, 59, 57, 55, 53, 53, 53, 49, 45, 43, 43, 43, 57, 58, 59, 59,
-        59, 59, 57, 55, 53, 53, 53, 49, 45, 43, 43, 43, 57, 58, 59, 59, 59, 59,
-        57, 55, 53, 53, 53, 49, 45, 43, 43, 43, 55, 56, 57, 57, 57, 57, 55, 53,
-        52, 52, 52, 48, 44, 42, 42, 42,
+        32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 31, 29, 28, 28, 28, 33, 33,
+        33, 33, 33, 33, 32, 32, 32, 32, 32, 31, 29, 29, 29, 29, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 29, 29, 29, 29, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 29, 29, 29, 29, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 29, 29, 29, 29, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 29, 29, 29, 29, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        30, 29, 29, 29, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 29,
+        29, 29, 33, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30,
+        33, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 33, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 33, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 30, 29, 29, 29, 29, 33, 32, 32, 32, 32, 32,
+        31, 31, 30, 30, 30, 30, 29, 28, 28, 28, 32, 32, 32, 32, 32, 32, 31, 30,
+        30, 30, 30, 29, 28, 28, 28, 28, 32, 32, 32, 32, 32, 32, 31, 30, 30, 30,
+        30, 29, 28, 28, 28, 28, 32, 32, 32, 32, 32, 32, 31, 30, 30, 30, 30, 29,
+        28, 28, 28, 28, 32, 32, 32, 32, 32, 32, 31, 30, 30, 30, 30, 29, 28, 28,
+        28, 28, 32, 32, 32, 31, 31, 31, 31, 30, 29, 29, 29, 28, 28, 27, 27, 27,
+        32, 32, 32, 31, 31, 31, 30, 29, 29, 29, 29, 28, 28, 27, 27, 27, 32, 32,
+        32, 31, 31, 31, 30, 29, 29, 29, 29, 28, 28, 27, 27, 27, 32, 32, 32, 31,
+        31, 31, 30, 29, 29, 29, 29, 28, 28, 27, 27, 27, 32, 31, 31, 31, 31, 31,
+        30, 29, 28, 28, 28, 28, 26, 26, 26, 26, 31, 31, 31, 31, 31, 31, 29, 28,
+        28, 28, 28, 27, 26, 25, 25, 25, 30, 30, 30, 30, 30, 30, 29, 28, 28, 28,
+        28, 26, 25, 24, 24, 24, 30, 30, 30, 30, 30, 30, 29, 28, 28, 28, 28, 26,
+        25, 24, 24, 24, 30, 30, 30, 30, 30, 30, 29, 28, 28, 28, 28, 26, 25, 24,
+        24, 24, 30, 30, 30, 30, 30, 30, 29, 28, 28, 28, 28, 26, 24, 23, 23, 23,
+        29, 29, 30, 30, 30, 30, 28, 28, 27, 27, 27, 25, 23, 22, 22, 22, 28, 29,
+        29, 30, 30, 30, 28, 28, 27, 27, 27, 24, 22, 21, 21, 21, 28, 29, 29, 30,
+        30, 30, 28, 28, 27, 27, 27, 24, 22, 21, 21, 21, 28, 29, 29, 30, 30, 30,
+        28, 28, 27, 27, 27, 24, 22, 21, 21, 21, 28, 28, 28, 28, 28, 28, 28, 27,
+        26, 26, 26, 24, 22, 21, 21, 21,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 63, 61, 60, 60, 60, 59, 58, 57, 57, 57, 55, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62,
-        61, 60, 60, 60, 59, 59, 58, 58, 58, 56, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 60, 60, 60,
-        59, 59, 59, 59, 59, 57, 65, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 61, 60, 60, 60, 60, 59, 59, 59,
-        59, 57, 65, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 62, 62, 62, 62, 62, 61, 60, 60, 60, 60, 59, 59, 59, 59, 57, 65, 65,
-        64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62,
-        62, 62, 61, 60, 60, 60, 60, 59, 59, 59, 59, 57, 65, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 61, 61, 60, 60, 60, 59, 59, 59,
-        59, 59, 58, 57, 57, 57, 57, 55, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 62, 61, 60, 60, 60, 60, 59, 59, 59, 59, 58, 57, 57, 57, 57, 55, 55,
-        55, 55, 55, 53, 64, 64, 63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 60, 60,
-        60, 60, 59, 59, 58, 58, 58, 57, 56, 55, 55, 55, 55, 54, 53, 53, 53, 52,
-        64, 64, 63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 60, 60, 60, 60, 59, 59,
-        58, 58, 58, 57, 56, 55, 55, 55, 55, 54, 53, 53, 53, 52, 64, 64, 63, 63,
-        63, 63, 63, 63, 62, 62, 62, 61, 60, 60, 60, 60, 59, 59, 58, 58, 58, 57,
-        56, 55, 55, 55, 55, 54, 53, 53, 53, 52, 61, 61, 61, 61, 61, 61, 61, 61,
-        61, 61, 61, 60, 59, 59, 59, 59, 58, 57, 56, 56, 56, 55, 53, 53, 53, 53,
-        51, 50, 49, 49, 49, 48, 59, 59, 59, 59, 59, 59, 59, 59, 60, 60, 60, 59,
-        58, 57, 57, 57, 56, 55, 55, 55, 55, 53, 51, 49, 49, 49, 48, 46, 45, 45,
-        45, 44, 57, 58, 58, 58, 58, 58, 59, 59, 59, 59, 59, 58, 57, 56, 56, 56,
-        55, 54, 53, 53, 53, 51, 49, 48, 48, 48, 46, 44, 43, 43, 43, 42, 57, 58,
-        58, 58, 58, 58, 59, 59, 59, 59, 59, 58, 57, 56, 56, 56, 55, 54, 53, 53,
-        53, 51, 49, 48, 48, 48, 46, 44, 43, 43, 43, 42, 57, 58, 58, 58, 58, 58,
-        59, 59, 59, 59, 59, 58, 57, 56, 56, 56, 55, 54, 53, 53, 53, 51, 49, 48,
-        48, 48, 46, 44, 43, 43, 43, 42,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 30, 30, 30, 30, 29, 28, 28, 28, 28, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 30, 30, 30, 30, 29, 29, 29, 29, 28, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 30,
+        30, 30, 29, 29, 29, 28, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30,
+        30, 28, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 28, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31,
+        31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 28, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 29, 29,
+        29, 29, 29, 28, 28, 28, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 30, 30, 30, 30, 30, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28,
+        28, 28, 28, 27, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30,
+        30, 30, 30, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29,
+        29, 29, 29, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29, 29, 29, 29, 28,
+        28, 28, 28, 28, 28, 27, 27, 27, 27, 26, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 30, 30, 29, 29, 29, 29, 28, 28, 28, 28, 28, 27, 26, 26, 26,
+        26, 25, 24, 24, 24, 24, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 29,
+        29, 28, 28, 28, 28, 28, 28, 28, 28, 26, 26, 25, 25, 25, 24, 23, 22, 22,
+        22, 22, 28, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 29, 28, 28, 28, 28,
+        28, 27, 27, 27, 27, 26, 25, 24, 24, 24, 23, 22, 21, 21, 21, 21, 28, 29,
+        29, 29, 29, 29, 29, 29, 30, 30, 30, 29, 28, 28, 28, 28, 28, 27, 27, 27,
+        27, 26, 25, 24, 24, 24, 23, 22, 21, 21, 21, 21, 28, 29, 29, 29, 29, 29,
+        29, 29, 30, 30, 30, 29, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26, 25, 24,
+        24, 24, 23, 22, 21, 21, 21, 21,
         /* Size 4x16 */
-        65, 65, 64, 57, 65, 64, 63, 58, 64, 64, 63, 58, 64, 64, 63, 59, 64, 63,
-        62, 59, 64, 63, 62, 59, 64, 63, 60, 57, 64, 63, 60, 56, 64, 63, 59, 55,
-        64, 62, 58, 53, 64, 62, 58, 53, 61, 61, 56, 49, 60, 60, 55, 48, 59, 60,
-        55, 46, 58, 59, 53, 43, 58, 59, 53, 43,
+        33, 33, 32, 28, 33, 32, 32, 29, 32, 32, 32, 29, 32, 32, 32, 29, 32, 32,
+        31, 30, 32, 32, 31, 30, 32, 32, 30, 28, 32, 32, 30, 28, 32, 32, 30, 28,
+        32, 31, 29, 27, 32, 31, 29, 27, 31, 31, 28, 25, 30, 30, 28, 24, 30, 30,
+        28, 23, 29, 30, 27, 21, 29, 30, 27, 21,
         /* Size 16x4 */
-        65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 61, 60, 59, 58, 58, 65, 64,
-        64, 64, 63, 63, 63, 63, 63, 62, 62, 61, 60, 60, 59, 59, 64, 63, 63, 63,
-        62, 62, 60, 60, 59, 58, 58, 56, 55, 55, 53, 53, 57, 58, 58, 59, 59, 59,
-        57, 56, 55, 53, 53, 49, 48, 46, 43, 43,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 32, 32, 32, 32,
+        31, 31, 30, 30, 30, 29, 29, 28, 28, 28, 27, 27, 28, 29, 29, 29, 30, 30,
+        28, 28, 28, 27, 27, 25, 24, 23, 21, 21,
         /* Size 8x32 */
-        64, 65, 65, 65, 64, 64, 59, 57, 65, 65, 65, 64, 64, 64, 59, 58, 65, 64,
-        64, 64, 63, 63, 59, 58, 65, 64, 64, 64, 63, 63, 59, 58, 65, 64, 64, 64,
-        63, 63, 59, 58, 65, 64, 64, 64, 63, 63, 59, 58, 65, 64, 64, 63, 63, 63,
-        59, 59, 65, 64, 63, 63, 63, 63, 59, 59, 65, 64, 63, 63, 62, 62, 60, 59,
-        65, 64, 63, 63, 62, 62, 60, 59, 65, 64, 63, 63, 62, 62, 60, 59, 65, 63,
-        63, 62, 61, 61, 59, 58, 65, 63, 63, 62, 60, 60, 58, 57, 64, 63, 63, 62,
-        60, 60, 57, 56, 64, 63, 63, 62, 60, 60, 57, 56, 64, 63, 63, 62, 60, 60,
-        57, 56, 64, 63, 63, 61, 59, 59, 56, 55, 64, 63, 62, 61, 59, 59, 55, 54,
-        64, 63, 62, 60, 58, 58, 55, 53, 64, 63, 62, 60, 58, 58, 55, 53, 64, 63,
-        62, 60, 58, 58, 55, 53, 63, 62, 62, 59, 57, 57, 53, 51, 61, 61, 61, 59,
-        56, 56, 51, 49, 60, 60, 60, 59, 55, 55, 49, 48, 60, 60, 60, 59, 55, 55,
-        49, 48, 60, 60, 60, 59, 55, 55, 49, 48, 59, 59, 60, 58, 55, 55, 48, 46,
-        58, 59, 59, 57, 54, 54, 46, 44, 57, 59, 59, 57, 53, 53, 45, 43, 57, 59,
-        59, 57, 53, 53, 45, 43, 57, 59, 59, 57, 53, 53, 45, 43, 55, 57, 57, 55,
-        52, 52, 44, 42,
+        32, 33, 33, 33, 32, 32, 29, 28, 33, 33, 33, 32, 32, 32, 29, 29, 33, 32,
+        32, 32, 32, 32, 29, 29, 33, 32, 32, 32, 32, 32, 29, 29, 33, 32, 32, 32,
+        32, 32, 29, 29, 33, 32, 32, 32, 32, 32, 29, 29, 33, 32, 32, 32, 32, 32,
+        30, 29, 33, 32, 32, 32, 32, 32, 30, 29, 33, 32, 32, 32, 31, 31, 30, 30,
+        33, 32, 32, 32, 31, 31, 30, 30, 33, 32, 32, 32, 31, 31, 30, 30, 33, 32,
+        32, 31, 31, 31, 29, 29, 33, 32, 32, 31, 30, 30, 29, 28, 32, 32, 32, 31,
+        30, 30, 28, 28, 32, 32, 32, 31, 30, 30, 28, 28, 32, 32, 32, 31, 30, 30,
+        28, 28, 32, 32, 32, 31, 30, 30, 28, 28, 32, 32, 31, 31, 29, 29, 28, 27,
+        32, 32, 31, 30, 29, 29, 28, 27, 32, 32, 31, 30, 29, 29, 28, 27, 32, 32,
+        31, 30, 29, 29, 28, 27, 32, 31, 31, 30, 28, 28, 26, 26, 31, 31, 31, 29,
+        28, 28, 26, 25, 30, 30, 30, 29, 28, 28, 25, 24, 30, 30, 30, 29, 28, 28,
+        25, 24, 30, 30, 30, 29, 28, 28, 25, 24, 30, 30, 30, 29, 28, 28, 24, 23,
+        29, 30, 30, 28, 27, 27, 23, 22, 28, 29, 30, 28, 27, 27, 22, 21, 28, 29,
+        30, 28, 27, 27, 22, 21, 28, 29, 30, 28, 27, 27, 22, 21, 28, 28, 28, 28,
+        26, 26, 22, 21,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 63, 61, 60, 60, 60, 59, 58, 57, 57, 57, 55, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62,
-        61, 60, 60, 60, 59, 59, 59, 59, 59, 57, 65, 65, 64, 64, 64, 64, 64, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 61, 60, 60, 60,
-        60, 59, 59, 59, 59, 57, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 62,
-        62, 62, 62, 62, 61, 61, 60, 60, 60, 59, 59, 59, 59, 59, 58, 57, 57, 57,
-        57, 55, 64, 64, 63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 60, 60, 60, 60,
-        59, 59, 58, 58, 58, 57, 56, 55, 55, 55, 55, 54, 53, 53, 53, 52, 64, 64,
-        63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 60, 60, 60, 60, 59, 59, 58, 58,
-        58, 57, 56, 55, 55, 55, 55, 54, 53, 53, 53, 52, 59, 59, 59, 59, 59, 59,
-        59, 59, 60, 60, 60, 59, 58, 57, 57, 57, 56, 55, 55, 55, 55, 53, 51, 49,
-        49, 49, 48, 46, 45, 45, 45, 44, 57, 58, 58, 58, 58, 58, 59, 59, 59, 59,
-        59, 58, 57, 56, 56, 56, 55, 54, 53, 53, 53, 51, 49, 48, 48, 48, 46, 44,
-        43, 43, 43, 42 },
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 30, 30, 30, 30, 29, 28, 28, 28, 28, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 30, 30, 30, 30, 30, 29, 29, 29, 28, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 30, 30, 30,
+        30, 30, 30, 30, 30, 28, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 29, 29, 29, 29, 29, 28, 28, 28,
+        28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30,
+        30, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29, 29, 29,
+        29, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26, 29, 29, 29, 29, 29, 29,
+        30, 30, 30, 30, 30, 29, 29, 28, 28, 28, 28, 28, 28, 28, 28, 26, 26, 25,
+        25, 25, 24, 23, 22, 22, 22, 22, 28, 29, 29, 29, 29, 29, 29, 29, 30, 30,
+        30, 29, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26, 25, 24, 24, 24, 23, 22,
+        21, 21, 21, 21 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        65, 48, 48, 42,
+        33, 24, 24, 21,
 #endif
         /* Size 4x4 */
-        65, 63, 53, 44, 63, 59, 49, 45, 53, 49, 43, 43, 44, 45, 43, 39,
+        33, 32, 27, 22, 32, 30, 25, 22, 27, 25, 22, 22, 22, 22, 22, 20,
         /* Size 8x8 */
-        65, 65, 67, 60, 56, 53, 49, 42, 65, 65, 66, 59, 55, 51, 48, 43, 67, 66,
-        64, 58, 53, 50, 48, 44, 60, 59, 58, 53, 48, 47, 46, 43, 56, 55, 53, 48,
-        45, 44, 44, 43, 53, 51, 50, 47, 44, 43, 43, 42, 49, 48, 48, 46, 44, 43,
-        42, 41, 42, 43, 44, 43, 43, 42, 41, 39,
+        33, 33, 34, 30, 28, 26, 24, 21, 33, 33, 33, 30, 28, 26, 24, 22, 34, 33,
+        32, 29, 26, 25, 24, 22, 30, 30, 29, 26, 24, 23, 23, 22, 28, 28, 26, 24,
+        22, 22, 22, 22, 26, 26, 25, 23, 22, 22, 21, 21, 24, 24, 24, 23, 22, 21,
+        21, 20, 21, 22, 22, 22, 22, 21, 20, 19,
         /* Size 16x16 */
-        64, 65, 66, 66, 67, 67, 62, 61, 59, 56, 56, 51, 49, 46, 42, 42, 65, 65,
-        65, 66, 66, 66, 61, 59, 57, 54, 54, 49, 49, 46, 43, 43, 66, 65, 65, 65,
-        66, 66, 60, 59, 57, 53, 53, 49, 48, 46, 43, 43, 66, 66, 65, 65, 65, 65,
-        60, 59, 56, 53, 53, 49, 48, 47, 44, 44, 67, 66, 66, 65, 64, 64, 59, 58,
-        55, 51, 51, 49, 48, 47, 44, 44, 67, 66, 66, 65, 64, 64, 59, 58, 55, 51,
-        51, 49, 48, 47, 44, 44, 62, 61, 60, 60, 59, 59, 55, 53, 51, 48, 48, 47,
-        46, 45, 44, 44, 61, 59, 59, 59, 58, 58, 53, 53, 51, 47, 47, 46, 46, 45,
-        43, 43, 59, 57, 57, 56, 55, 55, 51, 51, 48, 46, 46, 45, 45, 44, 43, 43,
-        56, 54, 53, 53, 51, 51, 48, 47, 46, 43, 43, 43, 43, 43, 43, 43, 56, 54,
-        53, 53, 51, 51, 48, 47, 46, 43, 43, 43, 43, 43, 43, 43, 51, 49, 49, 49,
-        49, 49, 47, 46, 45, 43, 43, 43, 42, 42, 41, 41, 49, 49, 48, 48, 48, 48,
-        46, 46, 45, 43, 43, 42, 42, 41, 41, 41, 46, 46, 46, 47, 47, 47, 45, 45,
-        44, 43, 43, 42, 41, 41, 40, 40, 42, 43, 43, 44, 44, 44, 44, 43, 43, 43,
-        43, 41, 41, 40, 39, 39, 42, 43, 43, 44, 44, 44, 44, 43, 43, 43, 43, 41,
-        41, 40, 39, 39,
+        32, 33, 33, 33, 34, 34, 31, 31, 30, 28, 28, 26, 25, 23, 21, 21, 33, 33,
+        33, 33, 33, 33, 31, 30, 28, 27, 27, 25, 24, 23, 21, 21, 33, 33, 33, 33,
+        33, 33, 30, 30, 28, 27, 27, 25, 24, 23, 22, 22, 33, 33, 33, 33, 33, 33,
+        30, 29, 28, 26, 26, 25, 24, 23, 22, 22, 34, 33, 33, 33, 32, 32, 30, 29,
+        28, 26, 26, 24, 24, 23, 22, 22, 34, 33, 33, 33, 32, 32, 30, 29, 28, 26,
+        26, 24, 24, 23, 22, 22, 31, 31, 30, 30, 30, 30, 28, 27, 26, 24, 24, 23,
+        23, 23, 22, 22, 31, 30, 30, 29, 29, 29, 27, 26, 26, 24, 24, 23, 23, 22,
+        22, 22, 30, 28, 28, 28, 28, 28, 26, 26, 24, 23, 23, 23, 22, 22, 22, 22,
+        28, 27, 27, 26, 26, 26, 24, 24, 23, 22, 22, 22, 22, 22, 21, 21, 28, 27,
+        27, 26, 26, 26, 24, 24, 23, 22, 22, 22, 22, 22, 21, 21, 26, 25, 25, 25,
+        24, 24, 23, 23, 23, 22, 22, 21, 21, 21, 20, 20, 25, 24, 24, 24, 24, 24,
+        23, 23, 22, 22, 22, 21, 21, 21, 20, 20, 23, 23, 23, 23, 23, 23, 23, 22,
+        22, 22, 22, 21, 21, 20, 20, 20, 21, 21, 22, 22, 22, 22, 22, 22, 22, 21,
+        21, 20, 20, 20, 19, 19, 21, 21, 22, 22, 22, 22, 22, 22, 22, 21, 21, 20,
+        20, 20, 19, 19,
         /* Size 32x32 */
-        64, 65, 65, 66, 66, 66, 66, 67, 67, 67, 67, 65, 62, 61, 61, 61, 59, 57,
-        56, 56, 56, 53, 51, 49, 49, 49, 46, 43, 42, 42, 42, 42, 65, 65, 65, 65,
-        65, 65, 66, 66, 67, 67, 67, 64, 62, 60, 60, 60, 59, 56, 55, 55, 55, 53,
-        50, 49, 49, 49, 46, 44, 42, 42, 42, 42, 65, 65, 65, 65, 65, 65, 66, 66,
-        66, 66, 66, 63, 61, 59, 59, 59, 57, 55, 54, 54, 54, 52, 49, 49, 49, 49,
-        46, 44, 43, 43, 43, 43, 66, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 63,
-        60, 59, 59, 59, 57, 55, 53, 53, 53, 51, 49, 48, 48, 48, 46, 44, 43, 43,
-        43, 43, 66, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 63, 60, 59, 59, 59,
-        57, 55, 53, 53, 53, 51, 49, 48, 48, 48, 46, 44, 43, 43, 43, 43, 66, 65,
-        65, 65, 65, 65, 65, 65, 66, 66, 66, 63, 60, 59, 59, 59, 57, 55, 53, 53,
-        53, 51, 49, 48, 48, 48, 46, 44, 43, 43, 43, 43, 66, 66, 66, 65, 65, 65,
-        65, 65, 65, 65, 65, 62, 60, 59, 59, 59, 56, 54, 53, 53, 53, 51, 49, 48,
-        48, 48, 47, 45, 44, 44, 44, 44, 67, 66, 66, 65, 65, 65, 65, 65, 65, 65,
-        65, 62, 59, 58, 58, 58, 55, 53, 52, 52, 52, 50, 49, 48, 48, 48, 47, 45,
-        44, 44, 44, 44, 67, 67, 66, 66, 66, 66, 65, 65, 64, 64, 64, 62, 59, 58,
-        58, 58, 55, 53, 51, 51, 51, 50, 49, 48, 48, 48, 47, 45, 44, 44, 44, 45,
-        67, 67, 66, 66, 66, 66, 65, 65, 64, 64, 64, 62, 59, 58, 58, 58, 55, 53,
-        51, 51, 51, 50, 49, 48, 48, 48, 47, 45, 44, 44, 44, 45, 67, 67, 66, 66,
-        66, 66, 65, 65, 64, 64, 64, 62, 59, 58, 58, 58, 55, 53, 51, 51, 51, 50,
-        49, 48, 48, 48, 47, 45, 44, 44, 44, 45, 65, 64, 63, 63, 63, 63, 62, 62,
-        62, 62, 62, 59, 57, 55, 55, 55, 53, 51, 49, 49, 49, 49, 48, 47, 47, 47,
-        46, 45, 44, 44, 44, 44, 62, 62, 61, 60, 60, 60, 60, 59, 59, 59, 59, 57,
-        55, 53, 53, 53, 51, 49, 48, 48, 48, 47, 47, 46, 46, 46, 45, 44, 44, 44,
-        44, 44, 61, 60, 59, 59, 59, 59, 59, 58, 58, 58, 58, 55, 53, 53, 53, 53,
-        51, 48, 47, 47, 47, 47, 46, 46, 46, 46, 45, 44, 43, 43, 43, 44, 61, 60,
-        59, 59, 59, 59, 59, 58, 58, 58, 58, 55, 53, 53, 53, 53, 51, 48, 47, 47,
-        47, 47, 46, 46, 46, 46, 45, 44, 43, 43, 43, 44, 61, 60, 59, 59, 59, 59,
-        59, 58, 58, 58, 58, 55, 53, 53, 53, 53, 51, 48, 47, 47, 47, 47, 46, 46,
-        46, 46, 45, 44, 43, 43, 43, 44, 59, 59, 57, 57, 57, 57, 56, 55, 55, 55,
-        55, 53, 51, 51, 51, 51, 48, 47, 46, 46, 46, 45, 45, 45, 45, 45, 44, 44,
-        43, 43, 43, 44, 57, 56, 55, 55, 55, 55, 54, 53, 53, 53, 53, 51, 49, 48,
-        48, 48, 47, 45, 44, 44, 44, 44, 44, 44, 44, 44, 44, 43, 43, 43, 43, 44,
-        56, 55, 54, 53, 53, 53, 53, 52, 51, 51, 51, 49, 48, 47, 47, 47, 46, 44,
-        43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 56, 55, 54, 53,
-        53, 53, 53, 52, 51, 51, 51, 49, 48, 47, 47, 47, 46, 44, 43, 43, 43, 43,
-        43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 56, 55, 54, 53, 53, 53, 53, 52,
-        51, 51, 51, 49, 48, 47, 47, 47, 46, 44, 43, 43, 43, 43, 43, 43, 43, 43,
-        43, 43, 43, 43, 43, 43, 53, 53, 52, 51, 51, 51, 51, 50, 50, 50, 50, 49,
-        47, 47, 47, 47, 45, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 42,
-        42, 42, 51, 50, 49, 49, 49, 49, 49, 49, 49, 49, 49, 48, 47, 46, 46, 46,
-        45, 44, 43, 43, 43, 43, 43, 42, 42, 42, 42, 41, 41, 41, 41, 41, 49, 49,
-        49, 48, 48, 48, 48, 48, 48, 48, 48, 47, 46, 46, 46, 46, 45, 44, 43, 43,
-        43, 43, 42, 42, 42, 42, 41, 41, 41, 41, 41, 41, 49, 49, 49, 48, 48, 48,
-        48, 48, 48, 48, 48, 47, 46, 46, 46, 46, 45, 44, 43, 43, 43, 43, 42, 42,
-        42, 42, 41, 41, 41, 41, 41, 41, 49, 49, 49, 48, 48, 48, 48, 48, 48, 48,
-        48, 47, 46, 46, 46, 46, 45, 44, 43, 43, 43, 43, 42, 42, 42, 42, 41, 41,
-        41, 41, 41, 41, 46, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 46, 45, 45,
-        45, 45, 44, 44, 43, 43, 43, 43, 42, 41, 41, 41, 41, 40, 40, 40, 40, 40,
-        43, 44, 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 44, 44, 44, 44, 44, 43,
-        43, 43, 43, 42, 41, 41, 41, 41, 40, 39, 39, 39, 39, 39, 42, 42, 43, 43,
-        43, 43, 44, 44, 44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 42,
-        41, 41, 41, 41, 40, 39, 39, 39, 39, 39, 42, 42, 43, 43, 43, 43, 44, 44,
-        44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 42, 41, 41, 41, 41,
-        40, 39, 39, 39, 39, 39, 42, 42, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44,
-        44, 43, 43, 43, 43, 43, 43, 43, 43, 42, 41, 41, 41, 41, 40, 39, 39, 39,
-        39, 39, 42, 42, 43, 43, 43, 43, 44, 44, 45, 45, 45, 44, 44, 44, 44, 44,
-        44, 44, 43, 43, 43, 42, 41, 41, 41, 41, 40, 39, 39, 39, 39, 38,
+        32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 33, 31, 31, 31, 31, 30, 28,
+        28, 28, 28, 27, 26, 25, 25, 25, 23, 22, 21, 21, 21, 21, 33, 33, 33, 33,
+        33, 33, 33, 33, 34, 34, 34, 32, 31, 30, 30, 30, 29, 28, 28, 28, 28, 26,
+        25, 24, 24, 24, 23, 22, 21, 21, 21, 21, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 32, 31, 30, 30, 30, 28, 28, 27, 27, 27, 26, 25, 24, 24, 24,
+        23, 22, 21, 21, 21, 22, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32,
+        30, 30, 30, 30, 28, 28, 27, 27, 27, 26, 25, 24, 24, 24, 23, 22, 22, 22,
+        22, 22, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 30, 30, 30, 30,
+        28, 28, 27, 27, 27, 26, 25, 24, 24, 24, 23, 22, 22, 22, 22, 22, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 30, 30, 30, 30, 28, 28, 27, 27,
+        27, 26, 25, 24, 24, 24, 23, 22, 22, 22, 22, 22, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 31, 30, 29, 29, 29, 28, 27, 26, 26, 26, 26, 25, 24,
+        24, 24, 23, 22, 22, 22, 22, 22, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 31, 30, 29, 29, 29, 28, 27, 26, 26, 26, 25, 24, 24, 24, 24, 23, 22,
+        22, 22, 22, 22, 34, 34, 33, 33, 33, 33, 33, 33, 32, 32, 32, 31, 30, 29,
+        29, 29, 28, 26, 26, 26, 26, 25, 24, 24, 24, 24, 23, 23, 22, 22, 22, 22,
+        34, 34, 33, 33, 33, 33, 33, 33, 32, 32, 32, 31, 30, 29, 29, 29, 28, 26,
+        26, 26, 26, 25, 24, 24, 24, 24, 23, 23, 22, 22, 22, 22, 34, 34, 33, 33,
+        33, 33, 33, 33, 32, 32, 32, 31, 30, 29, 29, 29, 28, 26, 26, 26, 26, 25,
+        24, 24, 24, 24, 23, 23, 22, 22, 22, 22, 33, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 30, 28, 28, 28, 28, 27, 26, 25, 25, 25, 24, 24, 24, 24, 24,
+        23, 22, 22, 22, 22, 22, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 28,
+        28, 27, 27, 27, 26, 25, 24, 24, 24, 24, 23, 23, 23, 23, 23, 22, 22, 22,
+        22, 22, 31, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 28, 27, 26, 26, 26,
+        26, 24, 24, 24, 24, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 31, 30,
+        30, 30, 30, 30, 29, 29, 29, 29, 29, 28, 27, 26, 26, 26, 26, 24, 24, 24,
+        24, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 31, 30, 30, 30, 30, 30,
+        29, 29, 29, 29, 29, 28, 27, 26, 26, 26, 26, 24, 24, 24, 24, 23, 23, 23,
+        23, 23, 22, 22, 22, 22, 22, 22, 30, 29, 28, 28, 28, 28, 28, 28, 28, 28,
+        28, 27, 26, 26, 26, 26, 24, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 28, 28, 28, 28, 28, 28, 27, 27, 26, 26, 26, 26, 25, 24,
+        24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        28, 28, 27, 27, 27, 27, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24, 23, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 22, 28, 28, 27, 27,
+        27, 27, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24, 23, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 21, 21, 21, 22, 28, 28, 27, 27, 27, 27, 26, 26,
+        26, 26, 26, 25, 24, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 21, 21, 21, 22, 27, 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 24,
+        24, 23, 23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21,
+        21, 21, 26, 25, 25, 25, 25, 25, 25, 24, 24, 24, 24, 24, 23, 23, 23, 23,
+        23, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 21, 25, 24,
+        24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 22, 22, 22, 22,
+        22, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 25, 24, 24, 24, 24, 24,
+        24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21,
+        21, 21, 21, 20, 20, 20, 20, 20, 25, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+        24, 24, 23, 23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 20,
+        20, 20, 20, 20, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 22,
+        22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20,
+        22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21,
+        20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 21, 21, 21, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 20, 20, 20, 20,
+        20, 20, 19, 19, 19, 19, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 19, 19,
+        19, 19, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 20, 20, 19, 19, 19, 19,
         /* Size 4x8 */
-        65, 66, 55, 43, 65, 65, 53, 44, 66, 64, 51, 45, 59, 57, 48, 44, 55, 52,
-        44, 43, 52, 50, 43, 42, 48, 48, 43, 41, 43, 44, 43, 39,
+        33, 33, 28, 21, 33, 33, 27, 22, 33, 32, 26, 22, 30, 28, 24, 22, 28, 26,
+        22, 22, 26, 25, 22, 21, 24, 24, 22, 20, 21, 22, 21, 19,
         /* Size 8x4 */
-        65, 65, 66, 59, 55, 52, 48, 43, 66, 65, 64, 57, 52, 50, 48, 44, 55, 53,
-        51, 48, 44, 43, 43, 43, 43, 44, 45, 44, 43, 42, 41, 39,
+        33, 33, 33, 30, 28, 26, 24, 21, 33, 33, 32, 28, 26, 25, 24, 22, 28, 27,
+        26, 24, 22, 22, 22, 21, 21, 22, 22, 22, 22, 21, 20, 19,
         /* Size 8x16 */
-        64, 66, 66, 62, 55, 55, 45, 43, 65, 65, 65, 60, 54, 54, 46, 43, 65, 65,
-        65, 60, 53, 53, 46, 44, 66, 65, 64, 59, 53, 53, 46, 44, 67, 64, 64, 59,
-        51, 51, 46, 45, 67, 64, 64, 59, 51, 51, 46, 45, 62, 59, 59, 55, 48, 48,
-        45, 44, 61, 58, 57, 53, 48, 48, 45, 44, 59, 55, 55, 51, 46, 46, 44, 43,
-        55, 52, 51, 48, 44, 44, 43, 43, 55, 52, 51, 48, 44, 44, 43, 43, 50, 49,
-        48, 47, 43, 43, 42, 41, 49, 48, 48, 46, 43, 43, 41, 41, 46, 46, 46, 45,
-        43, 43, 41, 40, 42, 44, 44, 44, 43, 43, 39, 39, 42, 44, 44, 44, 43, 43,
-        39, 39,
+        32, 33, 33, 31, 28, 28, 23, 21, 33, 33, 33, 30, 27, 27, 23, 22, 33, 33,
+        33, 30, 27, 27, 23, 22, 33, 33, 32, 30, 26, 26, 23, 22, 34, 32, 32, 29,
+        26, 26, 23, 22, 34, 32, 32, 29, 26, 26, 23, 22, 31, 30, 29, 28, 24, 24,
+        22, 22, 31, 29, 28, 27, 24, 24, 22, 22, 29, 28, 28, 26, 23, 23, 22, 22,
+        28, 26, 26, 24, 22, 22, 22, 22, 28, 26, 26, 24, 22, 22, 22, 22, 25, 24,
+        24, 23, 22, 22, 21, 21, 24, 24, 24, 23, 22, 22, 21, 20, 23, 23, 23, 23,
+        22, 22, 20, 20, 21, 22, 22, 22, 21, 21, 20, 19, 21, 22, 22, 22, 21, 21,
+        20, 19,
         /* Size 16x8 */
-        64, 65, 65, 66, 67, 67, 62, 61, 59, 55, 55, 50, 49, 46, 42, 42, 66, 65,
-        65, 65, 64, 64, 59, 58, 55, 52, 52, 49, 48, 46, 44, 44, 66, 65, 65, 64,
-        64, 64, 59, 57, 55, 51, 51, 48, 48, 46, 44, 44, 62, 60, 60, 59, 59, 59,
-        55, 53, 51, 48, 48, 47, 46, 45, 44, 44, 55, 54, 53, 53, 51, 51, 48, 48,
-        46, 44, 44, 43, 43, 43, 43, 43, 55, 54, 53, 53, 51, 51, 48, 48, 46, 44,
-        44, 43, 43, 43, 43, 43, 45, 46, 46, 46, 46, 46, 45, 45, 44, 43, 43, 42,
-        41, 41, 39, 39, 43, 43, 44, 44, 45, 45, 44, 44, 43, 43, 43, 41, 41, 40,
-        39, 39,
+        32, 33, 33, 33, 34, 34, 31, 31, 29, 28, 28, 25, 24, 23, 21, 21, 33, 33,
+        33, 33, 32, 32, 30, 29, 28, 26, 26, 24, 24, 23, 22, 22, 33, 33, 33, 32,
+        32, 32, 29, 28, 28, 26, 26, 24, 24, 23, 22, 22, 31, 30, 30, 30, 29, 29,
+        28, 27, 26, 24, 24, 23, 23, 23, 22, 22, 28, 27, 27, 26, 26, 26, 24, 24,
+        23, 22, 22, 22, 22, 22, 21, 21, 28, 27, 27, 26, 26, 26, 24, 24, 23, 22,
+        22, 22, 22, 22, 21, 21, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 21,
+        21, 20, 20, 20, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 20, 20,
+        19, 19,
         /* Size 16x32 */
-        64, 65, 66, 66, 66, 66, 62, 58, 55, 55, 55, 51, 45, 43, 43, 43, 65, 65,
-        66, 66, 66, 66, 61, 57, 55, 55, 55, 50, 45, 43, 43, 43, 65, 65, 65, 65,
-        65, 65, 60, 56, 54, 54, 54, 49, 46, 43, 43, 43, 65, 65, 65, 65, 65, 65,
-        60, 55, 53, 53, 53, 49, 46, 44, 44, 44, 65, 65, 65, 65, 65, 65, 60, 55,
-        53, 53, 53, 49, 46, 44, 44, 44, 65, 65, 65, 65, 65, 65, 60, 55, 53, 53,
-        53, 49, 46, 44, 44, 44, 66, 65, 65, 64, 64, 64, 59, 55, 53, 53, 53, 49,
-        46, 44, 44, 44, 67, 66, 65, 64, 64, 64, 59, 54, 52, 52, 52, 49, 46, 45,
-        45, 45, 67, 66, 64, 64, 64, 64, 59, 54, 51, 51, 51, 49, 46, 45, 45, 45,
-        67, 66, 64, 64, 64, 64, 59, 54, 51, 51, 51, 49, 46, 45, 45, 45, 67, 66,
-        64, 64, 64, 64, 59, 54, 51, 51, 51, 49, 46, 45, 45, 45, 65, 63, 62, 61,
-        61, 61, 57, 52, 50, 50, 50, 48, 46, 44, 44, 44, 62, 60, 59, 59, 59, 59,
-        55, 51, 48, 48, 48, 47, 45, 44, 44, 44, 61, 59, 58, 57, 57, 57, 53, 49,
-        48, 48, 48, 46, 45, 44, 44, 44, 61, 59, 58, 57, 57, 57, 53, 49, 48, 48,
-        48, 46, 45, 44, 44, 44, 61, 59, 58, 57, 57, 57, 53, 49, 48, 48, 48, 46,
-        45, 44, 44, 44, 59, 57, 55, 55, 55, 55, 51, 48, 46, 46, 46, 45, 44, 43,
-        43, 43, 56, 55, 53, 52, 52, 52, 49, 46, 44, 44, 44, 44, 43, 43, 43, 43,
-        55, 54, 52, 51, 51, 51, 48, 45, 44, 44, 44, 43, 43, 43, 43, 43, 55, 54,
-        52, 51, 51, 51, 48, 45, 44, 44, 44, 43, 43, 43, 43, 43, 55, 54, 52, 51,
-        51, 51, 48, 45, 44, 44, 44, 43, 43, 43, 43, 43, 53, 52, 51, 50, 50, 50,
-        47, 45, 43, 43, 43, 43, 42, 42, 42, 42, 50, 49, 49, 48, 48, 48, 47, 45,
-        43, 43, 43, 43, 42, 41, 41, 41, 49, 48, 48, 48, 48, 48, 46, 44, 43, 43,
-        43, 42, 41, 41, 41, 41, 49, 48, 48, 48, 48, 48, 46, 44, 43, 43, 43, 42,
-        41, 41, 41, 41, 49, 48, 48, 48, 48, 48, 46, 44, 43, 43, 43, 42, 41, 41,
-        41, 41, 46, 46, 46, 46, 46, 46, 45, 44, 43, 43, 43, 42, 41, 40, 40, 40,
-        43, 44, 45, 45, 45, 45, 44, 43, 43, 43, 43, 41, 40, 39, 39, 39, 42, 43,
-        44, 44, 44, 44, 44, 43, 43, 43, 43, 41, 39, 39, 39, 39, 42, 43, 44, 44,
-        44, 44, 44, 43, 43, 43, 43, 41, 39, 39, 39, 39, 42, 43, 44, 44, 44, 44,
-        44, 43, 43, 43, 43, 41, 39, 39, 39, 39, 42, 43, 44, 44, 44, 44, 44, 43,
-        43, 43, 43, 41, 39, 39, 39, 39,
+        32, 33, 33, 33, 33, 33, 31, 29, 28, 28, 28, 26, 23, 21, 21, 21, 33, 33,
+        33, 33, 33, 33, 31, 28, 28, 28, 28, 25, 23, 21, 21, 21, 33, 33, 33, 33,
+        33, 33, 30, 28, 27, 27, 27, 25, 23, 22, 22, 22, 33, 33, 33, 33, 33, 33,
+        30, 28, 27, 27, 27, 25, 23, 22, 22, 22, 33, 33, 33, 33, 33, 33, 30, 28,
+        27, 27, 27, 25, 23, 22, 22, 22, 33, 33, 33, 33, 33, 33, 30, 28, 27, 27,
+        27, 25, 23, 22, 22, 22, 33, 33, 33, 32, 32, 32, 30, 28, 26, 26, 26, 25,
+        23, 22, 22, 22, 34, 33, 33, 32, 32, 32, 30, 27, 26, 26, 26, 24, 23, 22,
+        22, 22, 34, 33, 32, 32, 32, 32, 29, 27, 26, 26, 26, 24, 23, 22, 22, 22,
+        34, 33, 32, 32, 32, 32, 29, 27, 26, 26, 26, 24, 23, 22, 22, 22, 34, 33,
+        32, 32, 32, 32, 29, 27, 26, 26, 26, 24, 23, 22, 22, 22, 33, 32, 31, 31,
+        31, 31, 28, 26, 25, 25, 25, 24, 23, 22, 22, 22, 31, 30, 30, 29, 29, 29,
+        28, 26, 24, 24, 24, 23, 22, 22, 22, 22, 31, 30, 29, 28, 28, 28, 27, 25,
+        24, 24, 24, 23, 22, 22, 22, 22, 31, 30, 29, 28, 28, 28, 27, 25, 24, 24,
+        24, 23, 22, 22, 22, 22, 31, 30, 29, 28, 28, 28, 27, 25, 24, 24, 24, 23,
+        22, 22, 22, 22, 29, 28, 28, 28, 28, 28, 26, 24, 23, 23, 23, 23, 22, 22,
+        22, 22, 28, 28, 27, 26, 26, 26, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22,
+        28, 27, 26, 26, 26, 26, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 28, 27,
+        26, 26, 26, 26, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 28, 27, 26, 26,
+        26, 26, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 26, 26, 26, 25, 25, 25,
+        24, 22, 22, 22, 22, 21, 21, 21, 21, 21, 25, 25, 24, 24, 24, 24, 23, 22,
+        22, 22, 22, 21, 21, 21, 21, 21, 24, 24, 24, 24, 24, 24, 23, 22, 22, 22,
+        22, 21, 21, 20, 20, 20, 24, 24, 24, 24, 24, 24, 23, 22, 22, 22, 22, 21,
+        21, 20, 20, 20, 24, 24, 24, 24, 24, 24, 23, 22, 22, 22, 22, 21, 21, 20,
+        20, 20, 23, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 21, 20, 20, 20, 20,
+        22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 20, 20, 20, 20, 21, 21,
+        22, 22, 22, 22, 22, 21, 21, 21, 21, 20, 20, 19, 19, 19, 21, 21, 22, 22,
+        22, 22, 22, 21, 21, 21, 21, 20, 20, 19, 19, 19, 21, 21, 22, 22, 22, 22,
+        22, 21, 21, 21, 21, 20, 20, 19, 19, 19, 21, 21, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 21, 20, 19, 19, 19,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 66, 67, 67, 67, 67, 65, 62, 61, 61, 61, 59, 56,
-        55, 55, 55, 53, 50, 49, 49, 49, 46, 43, 42, 42, 42, 42, 65, 65, 65, 65,
-        65, 65, 65, 66, 66, 66, 66, 63, 60, 59, 59, 59, 57, 55, 54, 54, 54, 52,
-        49, 48, 48, 48, 46, 44, 43, 43, 43, 43, 66, 66, 65, 65, 65, 65, 65, 65,
-        64, 64, 64, 62, 59, 58, 58, 58, 55, 53, 52, 52, 52, 51, 49, 48, 48, 48,
-        46, 45, 44, 44, 44, 44, 66, 66, 65, 65, 65, 65, 64, 64, 64, 64, 64, 61,
-        59, 57, 57, 57, 55, 52, 51, 51, 51, 50, 48, 48, 48, 48, 46, 45, 44, 44,
-        44, 44, 66, 66, 65, 65, 65, 65, 64, 64, 64, 64, 64, 61, 59, 57, 57, 57,
-        55, 52, 51, 51, 51, 50, 48, 48, 48, 48, 46, 45, 44, 44, 44, 44, 66, 66,
-        65, 65, 65, 65, 64, 64, 64, 64, 64, 61, 59, 57, 57, 57, 55, 52, 51, 51,
-        51, 50, 48, 48, 48, 48, 46, 45, 44, 44, 44, 44, 62, 61, 60, 60, 60, 60,
-        59, 59, 59, 59, 59, 57, 55, 53, 53, 53, 51, 49, 48, 48, 48, 47, 47, 46,
-        46, 46, 45, 44, 44, 44, 44, 44, 58, 57, 56, 55, 55, 55, 55, 54, 54, 54,
-        54, 52, 51, 49, 49, 49, 48, 46, 45, 45, 45, 45, 45, 44, 44, 44, 44, 43,
-        43, 43, 43, 43, 55, 55, 54, 53, 53, 53, 53, 52, 51, 51, 51, 50, 48, 48,
-        48, 48, 46, 44, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
-        55, 55, 54, 53, 53, 53, 53, 52, 51, 51, 51, 50, 48, 48, 48, 48, 46, 44,
-        44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 55, 55, 54, 53,
-        53, 53, 53, 52, 51, 51, 51, 50, 48, 48, 48, 48, 46, 44, 44, 44, 44, 43,
-        43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 51, 50, 49, 49, 49, 49, 49, 49,
-        49, 49, 49, 48, 47, 46, 46, 46, 45, 44, 43, 43, 43, 43, 43, 42, 42, 42,
-        42, 41, 41, 41, 41, 41, 45, 45, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
-        45, 45, 45, 45, 44, 43, 43, 43, 43, 42, 42, 41, 41, 41, 41, 40, 39, 39,
-        39, 39, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 45, 44, 44, 44, 44, 44,
-        43, 43, 43, 43, 43, 42, 41, 41, 41, 41, 40, 39, 39, 39, 39, 39, 43, 43,
-        43, 44, 44, 44, 44, 45, 45, 45, 45, 44, 44, 44, 44, 44, 43, 43, 43, 43,
-        43, 42, 41, 41, 41, 41, 40, 39, 39, 39, 39, 39, 43, 43, 43, 44, 44, 44,
-        44, 45, 45, 45, 45, 44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 42, 41, 41,
-        41, 41, 40, 39, 39, 39, 39, 39,
+        32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 33, 31, 31, 31, 31, 29, 28,
+        28, 28, 28, 26, 25, 24, 24, 24, 23, 22, 21, 21, 21, 21, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 30, 30, 30, 30, 28, 28, 27, 27, 27, 26,
+        25, 24, 24, 24, 23, 22, 21, 21, 21, 21, 33, 33, 33, 33, 33, 33, 33, 33,
+        32, 32, 32, 31, 30, 29, 29, 29, 28, 27, 26, 26, 26, 26, 24, 24, 24, 24,
+        23, 22, 22, 22, 22, 22, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 31,
+        29, 28, 28, 28, 28, 26, 26, 26, 26, 25, 24, 24, 24, 24, 23, 22, 22, 22,
+        22, 22, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 31, 29, 28, 28, 28,
+        28, 26, 26, 26, 26, 25, 24, 24, 24, 24, 23, 22, 22, 22, 22, 22, 33, 33,
+        33, 33, 33, 33, 32, 32, 32, 32, 32, 31, 29, 28, 28, 28, 28, 26, 26, 26,
+        26, 25, 24, 24, 24, 24, 23, 22, 22, 22, 22, 22, 31, 31, 30, 30, 30, 30,
+        30, 30, 29, 29, 29, 28, 28, 27, 27, 27, 26, 24, 24, 24, 24, 24, 23, 23,
+        23, 23, 23, 22, 22, 22, 22, 22, 29, 28, 28, 28, 28, 28, 28, 27, 27, 27,
+        27, 26, 26, 25, 25, 25, 24, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22,
+        21, 21, 21, 22, 28, 28, 27, 27, 27, 27, 26, 26, 26, 26, 26, 25, 24, 24,
+        24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 22,
+        28, 28, 27, 27, 27, 27, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24, 23, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 22, 28, 28, 27, 27,
+        27, 27, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24, 23, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 21, 21, 21, 21, 22, 26, 25, 25, 25, 25, 25, 25, 24,
+        24, 24, 24, 24, 23, 23, 23, 23, 23, 22, 22, 22, 22, 21, 21, 21, 21, 21,
+        21, 21, 20, 20, 20, 21, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 20, 20, 20, 20,
+        20, 20, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 20, 20, 19, 19, 19, 19, 21, 21,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 21, 21, 20, 20, 20, 20, 20, 19, 19, 19, 19, 21, 21, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 20,
+        20, 20, 20, 20, 19, 19, 19, 19,
         /* Size 4x16 */
-        65, 66, 55, 43, 65, 65, 54, 43, 65, 65, 53, 44, 65, 64, 53, 44, 66, 64,
-        51, 45, 66, 64, 51, 45, 60, 59, 48, 44, 59, 57, 48, 44, 57, 55, 46, 43,
-        54, 51, 44, 43, 54, 51, 44, 43, 49, 48, 43, 41, 48, 48, 43, 41, 46, 46,
-        43, 40, 43, 44, 43, 39, 43, 44, 43, 39,
+        33, 33, 28, 21, 33, 33, 27, 22, 33, 33, 27, 22, 33, 32, 26, 22, 33, 32,
+        26, 22, 33, 32, 26, 22, 30, 29, 24, 22, 30, 28, 24, 22, 28, 28, 23, 22,
+        27, 26, 22, 22, 27, 26, 22, 22, 25, 24, 22, 21, 24, 24, 22, 20, 23, 23,
+        22, 20, 21, 22, 21, 19, 21, 22, 21, 19,
         /* Size 16x4 */
-        65, 65, 65, 65, 66, 66, 60, 59, 57, 54, 54, 49, 48, 46, 43, 43, 66, 65,
-        65, 64, 64, 64, 59, 57, 55, 51, 51, 48, 48, 46, 44, 44, 55, 54, 53, 53,
-        51, 51, 48, 48, 46, 44, 44, 43, 43, 43, 43, 43, 43, 43, 44, 44, 45, 45,
-        44, 44, 43, 43, 43, 41, 41, 40, 39, 39,
+        33, 33, 33, 33, 33, 33, 30, 30, 28, 27, 27, 25, 24, 23, 21, 21, 33, 33,
+        33, 32, 32, 32, 29, 28, 28, 26, 26, 24, 24, 23, 22, 22, 28, 27, 27, 26,
+        26, 26, 24, 24, 23, 22, 22, 22, 22, 22, 21, 21, 21, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 21, 20, 20, 19, 19,
         /* Size 8x32 */
-        64, 66, 66, 62, 55, 55, 45, 43, 65, 66, 66, 61, 55, 55, 45, 43, 65, 65,
-        65, 60, 54, 54, 46, 43, 65, 65, 65, 60, 53, 53, 46, 44, 65, 65, 65, 60,
-        53, 53, 46, 44, 65, 65, 65, 60, 53, 53, 46, 44, 66, 65, 64, 59, 53, 53,
-        46, 44, 67, 65, 64, 59, 52, 52, 46, 45, 67, 64, 64, 59, 51, 51, 46, 45,
-        67, 64, 64, 59, 51, 51, 46, 45, 67, 64, 64, 59, 51, 51, 46, 45, 65, 62,
-        61, 57, 50, 50, 46, 44, 62, 59, 59, 55, 48, 48, 45, 44, 61, 58, 57, 53,
-        48, 48, 45, 44, 61, 58, 57, 53, 48, 48, 45, 44, 61, 58, 57, 53, 48, 48,
-        45, 44, 59, 55, 55, 51, 46, 46, 44, 43, 56, 53, 52, 49, 44, 44, 43, 43,
-        55, 52, 51, 48, 44, 44, 43, 43, 55, 52, 51, 48, 44, 44, 43, 43, 55, 52,
-        51, 48, 44, 44, 43, 43, 53, 51, 50, 47, 43, 43, 42, 42, 50, 49, 48, 47,
-        43, 43, 42, 41, 49, 48, 48, 46, 43, 43, 41, 41, 49, 48, 48, 46, 43, 43,
-        41, 41, 49, 48, 48, 46, 43, 43, 41, 41, 46, 46, 46, 45, 43, 43, 41, 40,
-        43, 45, 45, 44, 43, 43, 40, 39, 42, 44, 44, 44, 43, 43, 39, 39, 42, 44,
-        44, 44, 43, 43, 39, 39, 42, 44, 44, 44, 43, 43, 39, 39, 42, 44, 44, 44,
-        43, 43, 39, 39,
+        32, 33, 33, 31, 28, 28, 23, 21, 33, 33, 33, 31, 28, 28, 23, 21, 33, 33,
+        33, 30, 27, 27, 23, 22, 33, 33, 33, 30, 27, 27, 23, 22, 33, 33, 33, 30,
+        27, 27, 23, 22, 33, 33, 33, 30, 27, 27, 23, 22, 33, 33, 32, 30, 26, 26,
+        23, 22, 34, 33, 32, 30, 26, 26, 23, 22, 34, 32, 32, 29, 26, 26, 23, 22,
+        34, 32, 32, 29, 26, 26, 23, 22, 34, 32, 32, 29, 26, 26, 23, 22, 33, 31,
+        31, 28, 25, 25, 23, 22, 31, 30, 29, 28, 24, 24, 22, 22, 31, 29, 28, 27,
+        24, 24, 22, 22, 31, 29, 28, 27, 24, 24, 22, 22, 31, 29, 28, 27, 24, 24,
+        22, 22, 29, 28, 28, 26, 23, 23, 22, 22, 28, 27, 26, 24, 22, 22, 22, 22,
+        28, 26, 26, 24, 22, 22, 22, 22, 28, 26, 26, 24, 22, 22, 22, 22, 28, 26,
+        26, 24, 22, 22, 22, 22, 26, 26, 25, 24, 22, 22, 21, 21, 25, 24, 24, 23,
+        22, 22, 21, 21, 24, 24, 24, 23, 22, 22, 21, 20, 24, 24, 24, 23, 22, 22,
+        21, 20, 24, 24, 24, 23, 22, 22, 21, 20, 23, 23, 23, 23, 22, 22, 20, 20,
+        22, 22, 22, 22, 21, 21, 20, 20, 21, 22, 22, 22, 21, 21, 20, 19, 21, 22,
+        22, 22, 21, 21, 20, 19, 21, 22, 22, 22, 21, 21, 20, 19, 21, 22, 22, 22,
+        22, 22, 20, 19,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 66, 67, 67, 67, 67, 65, 62, 61, 61, 61, 59, 56,
-        55, 55, 55, 53, 50, 49, 49, 49, 46, 43, 42, 42, 42, 42, 66, 66, 65, 65,
-        65, 65, 65, 65, 64, 64, 64, 62, 59, 58, 58, 58, 55, 53, 52, 52, 52, 51,
-        49, 48, 48, 48, 46, 45, 44, 44, 44, 44, 66, 66, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 61, 59, 57, 57, 57, 55, 52, 51, 51, 51, 50, 48, 48, 48, 48,
-        46, 45, 44, 44, 44, 44, 62, 61, 60, 60, 60, 60, 59, 59, 59, 59, 59, 57,
-        55, 53, 53, 53, 51, 49, 48, 48, 48, 47, 47, 46, 46, 46, 45, 44, 44, 44,
-        44, 44, 55, 55, 54, 53, 53, 53, 53, 52, 51, 51, 51, 50, 48, 48, 48, 48,
-        46, 44, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 55, 55,
-        54, 53, 53, 53, 53, 52, 51, 51, 51, 50, 48, 48, 48, 48, 46, 44, 44, 44,
-        44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 45, 45, 46, 46, 46, 46,
-        46, 46, 46, 46, 46, 46, 45, 45, 45, 45, 44, 43, 43, 43, 43, 42, 42, 41,
-        41, 41, 41, 40, 39, 39, 39, 39, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45,
-        45, 44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 42, 41, 41, 41, 41, 40, 39,
-        39, 39, 39, 39 },
+        32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 33, 31, 31, 31, 31, 29, 28,
+        28, 28, 28, 26, 25, 24, 24, 24, 23, 22, 21, 21, 21, 21, 33, 33, 33, 33,
+        33, 33, 33, 33, 32, 32, 32, 31, 30, 29, 29, 29, 28, 27, 26, 26, 26, 26,
+        24, 24, 24, 24, 23, 22, 22, 22, 22, 22, 33, 33, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 31, 29, 28, 28, 28, 28, 26, 26, 26, 26, 25, 24, 24, 24, 24,
+        23, 22, 22, 22, 22, 22, 31, 31, 30, 30, 30, 30, 30, 30, 29, 29, 29, 28,
+        28, 27, 27, 27, 26, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, 22, 22, 22,
+        22, 22, 28, 28, 27, 27, 27, 27, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24,
+        23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 22, 28, 28,
+        27, 27, 27, 27, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24, 23, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 22, 23, 23, 23, 23, 23, 23,
+        23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21,
+        21, 21, 20, 20, 20, 20, 20, 20, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 20, 20, 20, 20, 20,
+        19, 19, 19, 19 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        64, 63, 63, 59,
+        32, 32, 32, 29,
 #endif
         /* Size 4x4 */
-        65, 64, 64, 63, 64, 63, 63, 62, 64, 63, 61, 60, 63, 62, 60, 58,
+        33, 32, 32, 32, 32, 32, 32, 31, 32, 32, 31, 30, 32, 31, 30, 29,
         /* Size 8x8 */
-        65, 65, 65, 65, 64, 64, 64, 61, 65, 64, 64, 64, 64, 64, 63, 61, 65, 64,
-        64, 64, 63, 63, 63, 61, 65, 64, 64, 63, 63, 63, 63, 61, 64, 64, 63, 63,
-        61, 61, 60, 59, 64, 64, 63, 63, 61, 60, 59, 58, 64, 63, 63, 63, 60, 59,
-        58, 56, 61, 61, 61, 61, 59, 58, 56, 54,
+        33, 33, 33, 33, 32, 32, 32, 31, 33, 32, 32, 32, 32, 32, 32, 31, 33, 32,
+        32, 32, 32, 32, 32, 31, 33, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32,
+        31, 31, 30, 29, 32, 32, 32, 32, 31, 30, 30, 29, 32, 32, 32, 32, 30, 30,
+        29, 28, 31, 31, 31, 31, 29, 29, 28, 27,
         /* Size 16x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 63, 60, 65, 65,
-        65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 62, 60, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 62, 60, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 63, 63, 63, 62, 60, 65, 65, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 63, 62, 60, 65, 65, 64, 64, 64, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 62, 61, 65, 65, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 62, 61, 65, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 62, 62, 62,
-        61, 60, 65, 64, 64, 64, 63, 63, 63, 63, 62, 62, 62, 61, 61, 61, 60, 59,
-        65, 64, 64, 64, 63, 63, 63, 63, 62, 61, 61, 61, 60, 60, 59, 58, 65, 64,
-        64, 64, 63, 63, 63, 63, 62, 61, 61, 61, 60, 60, 59, 58, 64, 64, 63, 63,
-        63, 63, 63, 62, 61, 61, 61, 59, 59, 59, 58, 57, 64, 64, 63, 63, 63, 63,
-        63, 62, 61, 60, 60, 59, 58, 58, 57, 55, 64, 64, 63, 63, 63, 63, 63, 62,
-        61, 60, 60, 59, 58, 58, 57, 55, 63, 62, 62, 62, 62, 62, 62, 61, 60, 59,
-        59, 58, 57, 57, 56, 54, 60, 60, 60, 60, 60, 61, 61, 60, 59, 58, 58, 57,
-        55, 55, 54, 52,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 30, 33, 33,
+        33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31, 30, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 30, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31,
+        31, 30, 33, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 30, 29,
+        33, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 29, 33, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 29, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 31, 31, 30, 29, 29, 29, 28, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 30, 30, 29, 29, 29, 28, 28, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 30, 30, 29, 29, 29, 28, 28, 32, 31, 31, 31, 31, 31, 31, 31, 30, 30,
+        30, 29, 28, 28, 28, 27, 30, 30, 30, 30, 30, 31, 31, 30, 29, 29, 29, 28,
+        28, 28, 27, 26,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 63, 62, 60, 60, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 61, 60, 60, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 63, 62, 61, 60, 60, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 62, 61,
-        60, 60, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 62, 61, 60, 60, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 62, 61, 60, 60, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 62, 61, 60, 60, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63,
-        62, 61, 60, 60, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 60, 60,
-        65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 61, 61, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 61, 61, 61, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 62, 62, 61, 61, 61, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 61,
-        61, 61, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 61, 61, 61, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 62, 62, 62, 62, 62, 62, 62, 61, 61, 60, 60, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 61,
-        61, 61, 61, 61, 60, 60, 59, 59, 65, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 61, 61, 60,
-        60, 59, 59, 59, 65, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 62, 62, 61, 61, 61, 61, 61, 61, 60, 60, 60, 60, 60, 59, 59, 58, 58,
-        65, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 62, 62, 61,
-        61, 61, 61, 61, 61, 60, 60, 60, 60, 60, 59, 59, 58, 58, 65, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 62, 62, 61, 61, 61, 61, 61,
-        61, 60, 60, 60, 60, 60, 59, 59, 58, 58, 65, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 63, 63, 62, 62, 61, 61, 61, 61, 61, 61, 60, 60, 60,
-        60, 60, 59, 59, 58, 58, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63,
-        63, 63, 62, 62, 61, 61, 61, 61, 61, 60, 60, 59, 59, 59, 59, 59, 59, 58,
-        58, 58, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62,
-        61, 61, 61, 61, 61, 60, 59, 59, 59, 59, 59, 59, 58, 58, 57, 57, 64, 64,
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 61, 60, 60, 60,
-        60, 59, 59, 59, 59, 59, 59, 58, 58, 57, 56, 56, 64, 64, 64, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 61, 60, 60, 60, 60, 59, 59, 59,
-        58, 58, 58, 58, 57, 56, 55, 55, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 62, 61, 61, 60, 60, 60, 60, 59, 59, 59, 58, 58, 58, 58,
-        57, 56, 55, 55, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        62, 61, 61, 60, 60, 60, 60, 59, 59, 59, 58, 58, 58, 58, 57, 56, 55, 55,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 61, 60, 60,
-        60, 60, 60, 59, 59, 58, 58, 58, 58, 58, 57, 56, 55, 55, 63, 63, 62, 62,
-        62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 61, 60, 60, 59, 59, 59, 59, 59,
-        58, 58, 57, 57, 57, 57, 56, 55, 54, 54, 62, 61, 61, 61, 61, 61, 61, 61,
-        61, 61, 61, 61, 61, 61, 61, 60, 59, 59, 59, 59, 59, 58, 58, 57, 56, 56,
-        56, 56, 55, 54, 53, 53, 60, 60, 60, 60, 60, 60, 60, 60, 60, 61, 61, 61,
-        61, 61, 60, 59, 59, 58, 58, 58, 58, 58, 57, 56, 55, 55, 55, 55, 54, 53,
-        52, 52, 60, 60, 60, 60, 60, 60, 60, 60, 60, 61, 61, 61, 61, 61, 60, 59,
-        59, 58, 58, 58, 58, 58, 57, 56, 55, 55, 55, 55, 54, 53, 52, 52,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 30, 30, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        30, 30, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 30, 30, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 30, 30, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30,
+        33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 31, 31, 31, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31,
+        31, 31, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 30, 30, 30, 30, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30,
+        30, 30, 29, 29, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 29, 29, 29,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31,
+        31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 29, 29, 29, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31,
+        31, 30, 30, 30, 30, 30, 30, 29, 29, 29, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30,
+        30, 30, 30, 29, 29, 29, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 29, 29,
+        29, 29, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 31, 30, 30, 30, 29, 29, 29, 29, 29, 29, 28, 28, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30,
+        30, 30, 30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 30, 29, 29,
+        29, 29, 29, 29, 28, 28, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29,
+        28, 28, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 30, 30,
+        30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 32, 32, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 29,
+        29, 29, 28, 28, 28, 28, 28, 28, 27, 27, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 30, 30, 29, 29, 29, 29, 29, 29, 28, 28, 28,
+        28, 28, 28, 27, 27, 27, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31,
+        31, 31, 30, 30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 27, 27,
+        26, 26, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 30, 30,
+        29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 27, 27, 26, 26,
         /* Size 4x8 */
-        65, 65, 64, 64, 65, 64, 63, 63, 64, 64, 63, 63, 64, 63, 63, 62, 64, 63,
-        61, 60, 64, 63, 60, 59, 64, 62, 59, 58, 61, 61, 58, 56,
+        33, 33, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 32, 32,
+        31, 30, 32, 32, 30, 30, 32, 31, 30, 29, 31, 31, 29, 28,
         /* Size 8x4 */
-        65, 65, 64, 64, 64, 64, 64, 61, 65, 64, 64, 63, 63, 63, 62, 61, 64, 63,
-        63, 63, 61, 60, 59, 58, 64, 63, 63, 62, 60, 59, 58, 56,
+        33, 33, 32, 32, 32, 32, 32, 31, 33, 32, 32, 32, 32, 32, 31, 31, 32, 32,
+        32, 32, 31, 30, 30, 29, 32, 32, 32, 31, 30, 30, 29, 28,
         /* Size 8x16 */
-        64, 65, 65, 65, 65, 64, 64, 63, 65, 65, 64, 64, 64, 63, 63, 62, 65, 64,
-        64, 64, 64, 63, 63, 62, 65, 64, 64, 64, 64, 63, 63, 62, 65, 64, 64, 64,
-        63, 63, 63, 62, 65, 64, 63, 63, 63, 62, 62, 62, 65, 64, 63, 63, 63, 62,
-        62, 62, 65, 64, 63, 63, 63, 62, 62, 61, 65, 64, 63, 63, 62, 60, 60, 59,
-        64, 63, 63, 63, 62, 60, 60, 59, 64, 63, 63, 63, 62, 60, 60, 59, 64, 63,
-        63, 63, 61, 59, 59, 58, 64, 63, 62, 62, 60, 58, 58, 57, 64, 63, 62, 62,
-        60, 58, 58, 57, 63, 62, 62, 62, 59, 57, 57, 56, 60, 60, 60, 60, 59, 55,
-        55, 54,
+        32, 33, 33, 33, 33, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 31, 33, 32,
+        32, 32, 32, 32, 32, 31, 33, 32, 32, 32, 32, 32, 32, 31, 33, 32, 32, 32,
+        32, 32, 32, 31, 33, 32, 32, 32, 32, 31, 31, 31, 33, 32, 32, 32, 32, 31,
+        31, 31, 33, 32, 32, 32, 32, 31, 31, 31, 33, 32, 32, 32, 31, 30, 30, 30,
+        32, 32, 32, 32, 31, 30, 30, 30, 32, 32, 32, 32, 31, 30, 30, 30, 32, 32,
+        32, 32, 31, 29, 29, 29, 32, 32, 31, 31, 30, 29, 29, 28, 32, 32, 31, 31,
+        30, 29, 29, 28, 32, 31, 31, 31, 30, 28, 28, 28, 30, 30, 30, 30, 29, 28,
+        28, 27,
         /* Size 16x8 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 63, 60, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 62, 60, 65, 64, 64, 64,
-        64, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 60, 65, 64, 64, 64, 64, 63,
-        63, 63, 63, 63, 63, 63, 62, 62, 62, 60, 65, 64, 64, 64, 63, 63, 63, 63,
-        62, 62, 62, 61, 60, 60, 59, 59, 64, 63, 63, 63, 63, 62, 62, 62, 60, 60,
-        60, 59, 58, 58, 57, 55, 64, 63, 63, 63, 63, 62, 62, 62, 60, 60, 60, 59,
-        58, 58, 57, 55, 63, 62, 62, 62, 62, 62, 62, 61, 59, 59, 59, 58, 57, 57,
-        56, 54,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 30, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 33, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 30, 30, 30, 29, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30,
+        30, 29, 29, 29, 28, 28, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 29,
+        29, 29, 28, 28, 32, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 29, 28, 28,
+        28, 27,
         /* Size 16x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 63, 60, 65, 65,
-        65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 62, 60, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 62, 60, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 63, 63, 63, 63, 63, 62, 60, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 63, 63, 63, 63, 63, 62, 60, 65, 65, 64, 64, 64, 64, 64, 64, 64, 63,
-        63, 63, 63, 63, 62, 60, 65, 65, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63,
-        63, 63, 62, 60, 65, 65, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63,
-        62, 60, 65, 65, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 62, 60,
-        65, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 62, 61, 65, 64,
-        64, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 61, 65, 64, 64, 63,
-        63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 61, 65, 64, 64, 63, 63, 63,
-        63, 63, 63, 63, 62, 62, 62, 62, 62, 61, 65, 64, 64, 63, 63, 63, 63, 63,
-        63, 63, 62, 62, 62, 62, 62, 61, 65, 64, 64, 63, 63, 63, 63, 63, 63, 62,
-        62, 62, 62, 62, 61, 60, 65, 64, 64, 63, 63, 63, 63, 63, 62, 62, 61, 61,
-        61, 61, 60, 59, 65, 64, 64, 63, 63, 63, 63, 63, 62, 61, 60, 60, 60, 60,
-        59, 59, 64, 64, 63, 63, 63, 63, 63, 62, 62, 61, 60, 60, 60, 60, 59, 58,
-        64, 64, 63, 63, 63, 63, 63, 62, 62, 61, 60, 60, 60, 60, 59, 58, 64, 64,
-        63, 63, 63, 63, 63, 62, 62, 61, 60, 60, 60, 60, 59, 58, 64, 64, 63, 63,
-        63, 63, 63, 62, 62, 61, 60, 60, 60, 60, 59, 58, 64, 64, 63, 63, 63, 63,
-        63, 62, 61, 60, 59, 59, 59, 59, 59, 58, 64, 64, 63, 63, 63, 63, 63, 62,
-        61, 60, 59, 59, 59, 59, 58, 57, 64, 64, 63, 63, 62, 62, 62, 62, 61, 59,
-        59, 59, 59, 59, 57, 56, 64, 64, 63, 63, 62, 62, 62, 62, 60, 59, 58, 58,
-        58, 58, 57, 55, 64, 64, 63, 63, 62, 62, 62, 62, 60, 59, 58, 58, 58, 58,
-        57, 55, 64, 64, 63, 63, 62, 62, 62, 62, 60, 59, 58, 58, 58, 58, 57, 55,
-        64, 63, 63, 62, 62, 62, 62, 62, 60, 59, 58, 58, 58, 58, 57, 55, 63, 62,
-        62, 62, 62, 62, 62, 61, 59, 59, 57, 57, 57, 57, 56, 54, 61, 61, 61, 61,
-        61, 61, 61, 60, 59, 58, 56, 56, 56, 56, 55, 53, 60, 60, 60, 60, 60, 60,
-        60, 60, 59, 57, 55, 55, 55, 55, 54, 52, 60, 60, 60, 60, 60, 60, 60, 60,
-        59, 57, 55, 55, 55, 55, 54, 52,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 30, 33, 33,
+        33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 31, 30, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 30, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 30, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 30, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 30, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 31, 31, 31, 31, 30, 33, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 31, 30, 30, 33, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 30, 30,
+        30, 29, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 30, 29,
+        32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 30, 29, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 30, 29, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 31, 30, 30, 30, 30, 30, 29, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 30, 30, 30, 30, 30, 29, 29, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 30, 29, 29, 29, 29, 29, 28, 32, 32, 32, 32, 31, 31, 31, 31, 31, 30,
+        29, 29, 29, 29, 28, 28, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 29, 29,
+        29, 29, 28, 28, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 29, 29, 29, 29,
+        28, 28, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 29, 29, 29, 29, 28, 28,
+        32, 32, 32, 31, 31, 31, 31, 31, 30, 30, 29, 29, 29, 29, 28, 28, 32, 31,
+        31, 31, 31, 31, 31, 31, 30, 29, 28, 28, 28, 28, 28, 27, 31, 31, 31, 31,
+        31, 31, 31, 30, 30, 29, 28, 28, 28, 28, 28, 27, 30, 30, 30, 30, 30, 30,
+        30, 30, 29, 28, 28, 28, 28, 28, 27, 26, 30, 30, 30, 30, 30, 30, 30, 30,
+        29, 28, 28, 28, 28, 28, 27, 26,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 61, 60, 60, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 63, 62, 61, 60, 60, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 62, 61, 60, 60, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 61,
-        60, 60, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 61, 60, 60, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 62, 62, 62, 62, 62, 61, 60, 60, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62,
-        62, 62, 62, 62, 62, 61, 60, 60, 65, 65, 64, 64, 64, 64, 64, 64, 64, 63,
-        63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
-        61, 60, 60, 60, 65, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 62, 62, 62, 62, 62, 62, 61, 61, 61, 60, 60, 60, 60, 59, 59, 59, 59,
-        64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 61, 61,
-        61, 61, 61, 60, 60, 59, 59, 59, 59, 59, 59, 58, 57, 57, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 61, 60, 60, 60, 60, 60, 59,
-        59, 59, 58, 58, 58, 58, 57, 56, 55, 55, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 63, 62, 62, 62, 62, 62, 61, 60, 60, 60, 60, 60, 59, 59, 59, 58, 58,
-        58, 58, 57, 56, 55, 55, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62,
-        62, 62, 62, 61, 60, 60, 60, 60, 60, 59, 59, 59, 58, 58, 58, 58, 57, 56,
-        55, 55, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 61,
-        60, 60, 60, 60, 60, 59, 59, 59, 58, 58, 58, 58, 57, 56, 55, 55, 63, 62,
-        62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 61, 60, 59, 59, 59, 59,
-        59, 59, 58, 57, 57, 57, 57, 57, 56, 55, 54, 54, 60, 60, 60, 60, 60, 60,
-        60, 60, 60, 61, 61, 61, 61, 61, 60, 59, 59, 58, 58, 58, 58, 58, 57, 56,
-        55, 55, 55, 55, 54, 53, 52, 52,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 30, 30, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31,
+        30, 30, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 30, 30, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 30, 30, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 31, 31, 31, 31, 31, 30, 30, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 30, 30, 30, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 29, 29,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 29, 29, 28, 28, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30,
+        29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29,
+        29, 29, 28, 28, 28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 28, 28,
+        28, 28, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
+        30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 32, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30,
+        30, 29, 29, 28, 28, 28, 28, 28, 28, 28, 27, 27, 30, 30, 30, 30, 30, 30,
+        30, 30, 30, 31, 31, 31, 31, 31, 30, 30, 29, 29, 29, 29, 29, 29, 28, 28,
+        28, 28, 28, 28, 27, 27, 26, 26,
         /* Size 4x16 */
-        65, 65, 64, 64, 65, 64, 64, 63, 65, 64, 63, 63, 65, 64, 63, 63, 65, 64,
-        63, 63, 64, 63, 63, 62, 64, 63, 63, 62, 64, 63, 62, 62, 64, 63, 61, 60,
-        64, 63, 61, 60, 64, 63, 61, 60, 64, 63, 60, 59, 64, 62, 59, 58, 64, 62,
-        59, 58, 62, 62, 59, 57, 60, 60, 57, 55,
+        33, 33, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32,
+        32, 32, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32, 31, 31, 32, 32, 31, 30,
+        32, 32, 31, 30, 32, 32, 31, 30, 32, 32, 30, 29, 32, 31, 30, 29, 32, 31,
+        30, 29, 31, 31, 29, 28, 30, 30, 28, 28,
         /* Size 16x4 */
-        65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 60, 65, 64,
-        64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 60, 64, 64, 63, 63,
-        63, 63, 63, 62, 61, 61, 61, 60, 59, 59, 59, 57, 64, 63, 63, 63, 63, 62,
-        62, 62, 60, 60, 60, 59, 58, 58, 57, 55,
+        33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 29, 28, 32, 32, 32, 32, 32, 31,
+        31, 31, 30, 30, 30, 29, 29, 29, 28, 28,
         /* Size 8x32 */
-        64, 65, 65, 65, 65, 64, 64, 63, 65, 65, 65, 65, 64, 64, 64, 62, 65, 65,
-        64, 64, 64, 63, 63, 62, 65, 64, 64, 64, 64, 63, 63, 62, 65, 64, 64, 64,
-        64, 63, 63, 62, 65, 64, 64, 64, 64, 63, 63, 62, 65, 64, 64, 64, 64, 63,
-        63, 62, 65, 64, 64, 64, 64, 63, 63, 62, 65, 64, 64, 64, 63, 63, 63, 62,
-        65, 64, 64, 64, 63, 63, 63, 62, 65, 64, 63, 63, 63, 62, 62, 62, 65, 64,
-        63, 63, 63, 62, 62, 62, 65, 64, 63, 63, 63, 62, 62, 62, 65, 64, 63, 63,
-        63, 62, 62, 62, 65, 64, 63, 63, 63, 62, 62, 61, 65, 64, 63, 63, 62, 61,
-        61, 60, 65, 64, 63, 63, 62, 60, 60, 59, 64, 63, 63, 63, 62, 60, 60, 59,
-        64, 63, 63, 63, 62, 60, 60, 59, 64, 63, 63, 63, 62, 60, 60, 59, 64, 63,
-        63, 63, 62, 60, 60, 59, 64, 63, 63, 63, 61, 59, 59, 59, 64, 63, 63, 63,
-        61, 59, 59, 58, 64, 63, 62, 62, 61, 59, 59, 57, 64, 63, 62, 62, 60, 58,
-        58, 57, 64, 63, 62, 62, 60, 58, 58, 57, 64, 63, 62, 62, 60, 58, 58, 57,
-        64, 63, 62, 62, 60, 58, 58, 57, 63, 62, 62, 62, 59, 57, 57, 56, 61, 61,
-        61, 61, 59, 56, 56, 55, 60, 60, 60, 60, 59, 55, 55, 54, 60, 60, 60, 60,
-        59, 55, 55, 54,
+        32, 33, 33, 33, 33, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 31, 33, 33,
+        32, 32, 32, 32, 32, 31, 33, 32, 32, 32, 32, 32, 32, 31, 33, 32, 32, 32,
+        32, 32, 32, 31, 33, 32, 32, 32, 32, 32, 32, 31, 33, 32, 32, 32, 32, 32,
+        32, 31, 33, 32, 32, 32, 32, 32, 32, 31, 33, 32, 32, 32, 32, 32, 32, 31,
+        33, 32, 32, 32, 32, 32, 32, 31, 33, 32, 32, 32, 32, 31, 31, 31, 33, 32,
+        32, 32, 32, 31, 31, 31, 33, 32, 32, 32, 32, 31, 31, 31, 33, 32, 32, 32,
+        32, 31, 31, 31, 33, 32, 32, 32, 32, 31, 31, 31, 33, 32, 32, 32, 31, 31,
+        31, 30, 33, 32, 32, 32, 31, 30, 30, 30, 32, 32, 32, 32, 31, 30, 30, 30,
+        32, 32, 32, 32, 31, 30, 30, 30, 32, 32, 32, 32, 31, 30, 30, 30, 32, 32,
+        32, 32, 31, 30, 30, 30, 32, 32, 32, 32, 31, 30, 30, 29, 32, 32, 32, 32,
+        31, 29, 29, 29, 32, 32, 31, 31, 31, 29, 29, 28, 32, 32, 31, 31, 30, 29,
+        29, 28, 32, 32, 31, 31, 30, 29, 29, 28, 32, 32, 31, 31, 30, 29, 29, 28,
+        32, 32, 31, 31, 30, 29, 29, 28, 32, 31, 31, 31, 30, 28, 28, 28, 31, 31,
+        31, 31, 30, 28, 28, 28, 30, 30, 30, 30, 29, 28, 28, 27, 30, 30, 30, 30,
+        29, 28, 28, 27,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 61, 60, 60, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 62, 61, 60, 60, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62,
-        62, 62, 62, 61, 60, 60, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 61,
-        60, 60, 65, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 62,
-        62, 62, 62, 62, 62, 61, 61, 61, 60, 60, 60, 60, 59, 59, 59, 59, 64, 64,
-        63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 61, 60, 60, 60, 60,
-        60, 59, 59, 59, 58, 58, 58, 58, 57, 56, 55, 55, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 63, 62, 62, 62, 62, 62, 61, 60, 60, 60, 60, 60, 59, 59, 59,
-        58, 58, 58, 58, 57, 56, 55, 55, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62,
-        62, 62, 62, 62, 61, 60, 59, 59, 59, 59, 59, 59, 58, 57, 57, 57, 57, 57,
-        56, 55, 54, 54 },
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 31, 31, 30, 30, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31,
+        31, 31, 31, 31, 30, 30, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31,
+        30, 30, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 29, 29, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30,
+        30, 30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 29, 29,
+        29, 29, 29, 29, 28, 28, 28, 28, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 29, 29, 28, 28, 28, 28, 28,
+        28, 28, 27, 27 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        65, 54, 54, 44,
+        33, 27, 27, 22,
 #endif
         /* Size 4x4 */
-        65, 66, 59, 53, 66, 64, 58, 51, 59, 58, 53, 47, 53, 51, 47, 43,
+        33, 33, 30, 27, 33, 32, 29, 26, 30, 29, 26, 24, 27, 26, 24, 22,
         /* Size 8x8 */
-        65, 66, 66, 67, 60, 59, 55, 51, 66, 65, 65, 66, 59, 58, 53, 50, 66, 65,
-        65, 65, 59, 56, 52, 49, 67, 66, 65, 64, 58, 56, 51, 49, 60, 59, 59, 58,
-        53, 51, 47, 46, 59, 58, 56, 56, 51, 49, 46, 45, 55, 53, 52, 51, 47, 46,
-        43, 43, 51, 50, 49, 49, 46, 45, 43, 43,
+        33, 33, 33, 34, 30, 29, 28, 26, 33, 33, 33, 33, 30, 29, 27, 25, 33, 33,
+        33, 33, 29, 28, 26, 25, 34, 33, 33, 32, 29, 28, 26, 24, 30, 30, 29, 29,
+        26, 26, 24, 23, 29, 29, 28, 28, 26, 25, 23, 23, 28, 27, 26, 26, 24, 23,
+        22, 22, 26, 25, 25, 24, 23, 23, 22, 21,
         /* Size 16x16 */
-        64, 65, 66, 66, 66, 67, 67, 66, 62, 61, 61, 58, 56, 56, 53, 49, 65, 65,
-        65, 65, 66, 66, 66, 65, 61, 60, 60, 57, 55, 55, 52, 49, 66, 65, 65, 65,
-        65, 66, 66, 64, 60, 59, 59, 55, 53, 53, 51, 48, 66, 65, 65, 65, 65, 66,
-        66, 64, 60, 59, 59, 55, 53, 53, 51, 48, 66, 66, 65, 65, 65, 65, 65, 64,
-        60, 59, 59, 55, 53, 53, 51, 48, 67, 66, 66, 66, 65, 64, 64, 63, 59, 58,
-        58, 54, 51, 51, 50, 48, 67, 66, 66, 66, 65, 64, 64, 63, 59, 58, 58, 54,
-        51, 51, 50, 48, 66, 65, 64, 64, 64, 63, 63, 62, 58, 57, 57, 53, 51, 51,
-        49, 48, 62, 61, 60, 60, 60, 59, 59, 58, 55, 53, 53, 50, 48, 48, 47, 46,
-        61, 60, 59, 59, 59, 58, 58, 57, 53, 53, 53, 49, 47, 47, 47, 46, 61, 60,
-        59, 59, 59, 58, 58, 57, 53, 53, 53, 49, 47, 47, 47, 46, 58, 57, 55, 55,
-        55, 54, 54, 53, 50, 49, 49, 47, 45, 45, 45, 44, 56, 55, 53, 53, 53, 51,
-        51, 51, 48, 47, 47, 45, 43, 43, 43, 43, 56, 55, 53, 53, 53, 51, 51, 51,
-        48, 47, 47, 45, 43, 43, 43, 43, 53, 52, 51, 51, 51, 50, 50, 49, 47, 47,
-        47, 45, 43, 43, 43, 43, 49, 49, 48, 48, 48, 48, 48, 48, 46, 46, 46, 44,
-        43, 43, 43, 42,
+        32, 33, 33, 33, 33, 34, 34, 33, 31, 31, 31, 29, 28, 28, 27, 25, 33, 33,
+        33, 33, 33, 33, 33, 33, 31, 30, 30, 28, 28, 28, 26, 24, 33, 33, 33, 33,
+        33, 33, 33, 32, 30, 30, 30, 28, 27, 27, 26, 24, 33, 33, 33, 33, 33, 33,
+        33, 32, 30, 30, 30, 28, 27, 27, 26, 24, 33, 33, 33, 33, 33, 33, 33, 32,
+        30, 29, 29, 28, 26, 26, 26, 24, 34, 33, 33, 33, 33, 32, 32, 32, 30, 29,
+        29, 27, 26, 26, 25, 24, 34, 33, 33, 33, 33, 32, 32, 32, 30, 29, 29, 27,
+        26, 26, 25, 24, 33, 33, 32, 32, 32, 32, 32, 31, 29, 28, 28, 27, 26, 26,
+        25, 24, 31, 31, 30, 30, 30, 30, 30, 29, 28, 27, 27, 25, 24, 24, 24, 23,
+        31, 30, 30, 30, 29, 29, 29, 28, 27, 26, 26, 25, 24, 24, 23, 23, 31, 30,
+        30, 30, 29, 29, 29, 28, 27, 26, 26, 25, 24, 24, 23, 23, 29, 28, 28, 28,
+        28, 27, 27, 27, 25, 25, 25, 23, 22, 22, 22, 22, 28, 28, 27, 27, 26, 26,
+        26, 26, 24, 24, 24, 22, 22, 22, 22, 22, 28, 28, 27, 27, 26, 26, 26, 26,
+        24, 24, 24, 22, 22, 22, 22, 22, 27, 26, 26, 26, 26, 25, 25, 25, 24, 23,
+        23, 22, 22, 22, 22, 21, 25, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 22,
+        22, 22, 21, 21,
         /* Size 32x32 */
-        64, 65, 65, 66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 66, 64, 62, 61,
-        61, 61, 61, 59, 58, 56, 56, 56, 56, 55, 53, 51, 49, 49, 65, 65, 65, 65,
-        66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 66, 64, 62, 60, 60, 60, 60, 59,
-        57, 55, 55, 55, 55, 55, 53, 51, 49, 49, 65, 65, 65, 65, 65, 65, 65, 65,
-        66, 66, 66, 66, 66, 66, 65, 63, 61, 60, 60, 60, 60, 59, 57, 55, 55, 55,
-        55, 54, 52, 51, 49, 49, 66, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66,
-        66, 66, 64, 63, 60, 59, 59, 59, 59, 58, 56, 54, 53, 53, 53, 53, 51, 50,
-        49, 49, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 64, 62,
-        60, 59, 59, 59, 59, 58, 55, 54, 53, 53, 53, 53, 51, 50, 48, 48, 66, 66,
-        65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 64, 62, 60, 59, 59, 59,
-        59, 58, 55, 54, 53, 53, 53, 53, 51, 50, 48, 48, 66, 66, 65, 65, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 66, 64, 62, 60, 59, 59, 59, 59, 58, 55, 54,
-        53, 53, 53, 53, 51, 50, 48, 48, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 64, 62, 60, 59, 59, 59, 59, 57, 55, 54, 53, 53, 53, 53,
-        51, 50, 48, 48, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        64, 62, 60, 59, 59, 59, 59, 57, 55, 53, 53, 53, 53, 52, 51, 49, 48, 48,
-        67, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 63, 61, 59, 59,
-        59, 59, 59, 56, 55, 53, 52, 52, 52, 51, 51, 49, 48, 48, 67, 67, 66, 66,
-        66, 66, 66, 65, 65, 65, 64, 64, 64, 64, 63, 61, 59, 58, 58, 58, 58, 56,
-        54, 52, 51, 51, 51, 51, 50, 49, 48, 48, 67, 67, 66, 66, 66, 66, 66, 65,
-        65, 65, 64, 64, 64, 64, 63, 61, 59, 58, 58, 58, 58, 56, 54, 52, 51, 51,
-        51, 51, 50, 49, 48, 48, 67, 67, 66, 66, 66, 66, 66, 65, 65, 65, 64, 64,
-        64, 64, 63, 61, 59, 58, 58, 58, 58, 56, 54, 52, 51, 51, 51, 51, 50, 49,
-        48, 48, 67, 67, 66, 66, 66, 66, 66, 65, 65, 65, 64, 64, 64, 64, 63, 61,
-        59, 58, 58, 58, 58, 56, 54, 52, 51, 51, 51, 51, 50, 49, 48, 48, 66, 66,
-        65, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 62, 60, 58, 57, 57, 57,
-        57, 55, 53, 51, 51, 51, 51, 50, 49, 48, 48, 48, 64, 64, 63, 63, 62, 62,
-        62, 62, 62, 61, 61, 61, 61, 61, 60, 58, 56, 55, 55, 55, 55, 53, 52, 50,
-        49, 49, 49, 49, 48, 48, 47, 47, 62, 62, 61, 60, 60, 60, 60, 60, 60, 59,
-        59, 59, 59, 59, 58, 56, 55, 53, 53, 53, 53, 52, 50, 49, 48, 48, 48, 48,
-        47, 47, 46, 46, 61, 60, 60, 59, 59, 59, 59, 59, 59, 59, 58, 58, 58, 58,
-        57, 55, 53, 53, 53, 53, 53, 51, 49, 48, 47, 47, 47, 47, 47, 46, 46, 46,
-        61, 60, 60, 59, 59, 59, 59, 59, 59, 59, 58, 58, 58, 58, 57, 55, 53, 53,
-        53, 53, 53, 51, 49, 48, 47, 47, 47, 47, 47, 46, 46, 46, 61, 60, 60, 59,
-        59, 59, 59, 59, 59, 59, 58, 58, 58, 58, 57, 55, 53, 53, 53, 53, 53, 51,
-        49, 48, 47, 47, 47, 47, 47, 46, 46, 46, 61, 60, 60, 59, 59, 59, 59, 59,
-        59, 59, 58, 58, 58, 58, 57, 55, 53, 53, 53, 53, 53, 51, 49, 48, 47, 47,
-        47, 47, 47, 46, 46, 46, 59, 59, 59, 58, 58, 58, 58, 57, 57, 56, 56, 56,
-        56, 56, 55, 53, 52, 51, 51, 51, 51, 49, 48, 47, 46, 46, 46, 46, 46, 45,
-        45, 45, 58, 57, 57, 56, 55, 55, 55, 55, 55, 55, 54, 54, 54, 54, 53, 52,
-        50, 49, 49, 49, 49, 48, 47, 45, 45, 45, 45, 45, 45, 45, 44, 44, 56, 55,
-        55, 54, 54, 54, 54, 54, 53, 53, 52, 52, 52, 52, 51, 50, 49, 48, 48, 48,
-        48, 47, 45, 44, 44, 44, 44, 44, 44, 44, 44, 44, 56, 55, 55, 53, 53, 53,
-        53, 53, 53, 52, 51, 51, 51, 51, 51, 49, 48, 47, 47, 47, 47, 46, 45, 44,
-        43, 43, 43, 43, 43, 43, 43, 43, 56, 55, 55, 53, 53, 53, 53, 53, 53, 52,
-        51, 51, 51, 51, 51, 49, 48, 47, 47, 47, 47, 46, 45, 44, 43, 43, 43, 43,
-        43, 43, 43, 43, 56, 55, 55, 53, 53, 53, 53, 53, 53, 52, 51, 51, 51, 51,
-        51, 49, 48, 47, 47, 47, 47, 46, 45, 44, 43, 43, 43, 43, 43, 43, 43, 43,
-        55, 55, 54, 53, 53, 53, 53, 53, 52, 51, 51, 51, 51, 51, 50, 49, 48, 47,
-        47, 47, 47, 46, 45, 44, 43, 43, 43, 43, 43, 43, 43, 43, 53, 53, 52, 51,
-        51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 49, 48, 47, 47, 47, 47, 47, 46,
-        45, 44, 43, 43, 43, 43, 43, 43, 43, 43, 51, 51, 51, 50, 50, 50, 50, 50,
-        49, 49, 49, 49, 49, 49, 48, 48, 47, 46, 46, 46, 46, 45, 45, 44, 43, 43,
-        43, 43, 43, 43, 43, 43, 49, 49, 49, 49, 48, 48, 48, 48, 48, 48, 48, 48,
-        48, 48, 48, 47, 46, 46, 46, 46, 46, 45, 44, 44, 43, 43, 43, 43, 43, 43,
-        42, 42, 49, 49, 49, 49, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 47,
-        46, 46, 46, 46, 46, 45, 44, 44, 43, 43, 43, 43, 43, 43, 42, 42,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 33, 32, 31, 31,
+        31, 31, 31, 30, 29, 28, 28, 28, 28, 28, 27, 26, 25, 25, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 33, 32, 31, 30, 30, 30, 30, 29,
+        28, 28, 28, 28, 28, 28, 26, 26, 24, 24, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 31, 30, 30, 30, 30, 29, 28, 28, 28, 28,
+        28, 27, 26, 26, 24, 24, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 32, 32, 30, 30, 30, 30, 30, 29, 28, 27, 27, 27, 27, 27, 26, 25,
+        24, 24, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 31,
+        30, 30, 30, 30, 30, 29, 28, 27, 27, 27, 27, 26, 26, 25, 24, 24, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 31, 30, 30, 30, 30,
+        30, 29, 28, 27, 27, 27, 27, 26, 26, 25, 24, 24, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 32, 31, 30, 30, 30, 30, 30, 29, 28, 27,
+        27, 27, 27, 26, 26, 25, 24, 24, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 32, 31, 30, 30, 30, 30, 30, 28, 28, 27, 27, 27, 27, 26,
+        26, 25, 24, 24, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        32, 31, 30, 29, 29, 29, 29, 28, 28, 27, 26, 26, 26, 26, 26, 25, 24, 24,
+        34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 31, 30, 29,
+        29, 29, 29, 28, 28, 26, 26, 26, 26, 26, 26, 25, 24, 24, 34, 34, 33, 33,
+        33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 31, 30, 29, 29, 29, 29, 28,
+        27, 26, 26, 26, 26, 26, 25, 24, 24, 24, 34, 34, 33, 33, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 31, 30, 29, 29, 29, 29, 28, 27, 26, 26, 26,
+        26, 26, 25, 24, 24, 24, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 31, 30, 29, 29, 29, 29, 28, 27, 26, 26, 26, 26, 26, 25, 24,
+        24, 24, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 31,
+        30, 29, 29, 29, 29, 28, 27, 26, 26, 26, 26, 26, 25, 24, 24, 24, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 29, 28, 28, 28,
+        28, 28, 27, 26, 26, 26, 26, 25, 25, 24, 24, 24, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 30, 29, 28, 28, 28, 28, 28, 27, 26, 25,
+        25, 25, 25, 24, 24, 24, 24, 24, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30,
+        30, 30, 30, 30, 29, 28, 28, 27, 27, 27, 27, 26, 25, 24, 24, 24, 24, 24,
+        24, 23, 23, 23, 31, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29,
+        28, 28, 27, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24, 24, 23, 23, 23, 23,
+        31, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 28, 28, 27, 26,
+        26, 26, 26, 26, 25, 24, 24, 24, 24, 24, 23, 23, 23, 23, 31, 30, 30, 30,
+        30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 28, 28, 27, 26, 26, 26, 26, 26,
+        25, 24, 24, 24, 24, 24, 23, 23, 23, 23, 31, 30, 30, 30, 30, 30, 30, 30,
+        29, 29, 29, 29, 29, 29, 28, 28, 27, 26, 26, 26, 26, 26, 25, 24, 24, 24,
+        24, 24, 23, 23, 23, 23, 30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28,
+        28, 28, 28, 27, 26, 26, 26, 26, 26, 25, 24, 23, 23, 23, 23, 23, 23, 23,
+        23, 23, 29, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 27, 26,
+        25, 25, 25, 25, 25, 24, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 28, 28,
+        28, 27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24,
+        24, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 28, 28, 28, 27, 27, 27,
+        27, 27, 26, 26, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24, 24, 23, 22, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 28, 28, 28, 27, 27, 27, 27, 27, 26, 26,
+        26, 26, 26, 26, 26, 25, 24, 24, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22,
+        22, 22, 22, 22, 28, 28, 28, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26,
+        26, 25, 24, 24, 24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+        28, 28, 27, 27, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 25, 24, 24, 24,
+        24, 24, 24, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 27, 26, 26, 26,
+        26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 25, 24, 24, 23, 23, 23, 23, 23,
+        22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 26, 26, 26, 25, 25, 25, 25, 25,
+        25, 25, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22,
+        22, 22, 21, 21, 21, 21, 25, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+        24, 24, 24, 24, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 21, 21,
+        21, 21, 25, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+        23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21,
         /* Size 4x8 */
-        65, 66, 59, 55, 65, 65, 57, 53, 66, 64, 55, 52, 66, 64, 55, 51, 59, 57,
-        51, 48, 58, 55, 49, 46, 54, 51, 46, 44, 50, 49, 45, 43,
+        33, 33, 29, 28, 33, 33, 28, 27, 33, 32, 28, 26, 33, 32, 28, 26, 30, 28,
+        26, 24, 29, 28, 24, 23, 27, 26, 23, 22, 25, 24, 23, 22,
         /* Size 8x4 */
-        65, 65, 66, 66, 59, 58, 54, 50, 66, 65, 64, 64, 57, 55, 51, 49, 59, 57,
-        55, 55, 51, 49, 46, 45, 55, 53, 52, 51, 48, 46, 44, 43,
+        33, 33, 33, 33, 30, 29, 27, 25, 33, 33, 32, 32, 28, 28, 26, 24, 29, 28,
+        28, 28, 26, 24, 23, 23, 28, 27, 26, 26, 24, 23, 22, 22,
         /* Size 8x16 */
-        64, 66, 66, 66, 62, 55, 55, 53, 65, 65, 65, 65, 61, 54, 54, 52, 65, 65,
-        65, 65, 60, 53, 53, 51, 65, 65, 65, 65, 60, 53, 53, 51, 66, 65, 64, 64,
-        59, 53, 53, 51, 67, 65, 64, 64, 59, 51, 51, 50, 67, 65, 64, 64, 59, 51,
-        51, 50, 66, 64, 62, 62, 58, 51, 51, 49, 62, 60, 59, 59, 55, 48, 48, 48,
-        61, 59, 57, 57, 53, 48, 48, 47, 61, 59, 57, 57, 53, 48, 48, 47, 58, 55,
-        53, 53, 50, 45, 45, 45, 55, 53, 51, 51, 48, 44, 44, 43, 55, 53, 51, 51,
-        48, 44, 44, 43, 53, 51, 50, 50, 47, 43, 43, 43, 49, 48, 48, 48, 46, 43,
-        43, 43,
+        32, 33, 33, 33, 31, 28, 28, 27, 33, 33, 33, 33, 31, 27, 27, 26, 33, 33,
+        33, 33, 30, 27, 27, 26, 33, 33, 33, 33, 30, 27, 27, 26, 33, 33, 32, 32,
+        30, 26, 26, 26, 34, 33, 32, 32, 29, 26, 26, 25, 34, 33, 32, 32, 29, 26,
+        26, 25, 33, 32, 31, 31, 29, 26, 26, 25, 31, 30, 29, 29, 28, 24, 24, 24,
+        31, 29, 28, 28, 27, 24, 24, 23, 31, 29, 28, 28, 27, 24, 24, 23, 29, 28,
+        27, 27, 25, 23, 23, 22, 28, 26, 26, 26, 24, 22, 22, 22, 28, 26, 26, 26,
+        24, 22, 22, 22, 26, 26, 25, 25, 24, 22, 22, 22, 24, 24, 24, 24, 23, 22,
+        22, 21,
         /* Size 16x8 */
-        64, 65, 65, 65, 66, 67, 67, 66, 62, 61, 61, 58, 55, 55, 53, 49, 66, 65,
-        65, 65, 65, 65, 65, 64, 60, 59, 59, 55, 53, 53, 51, 48, 66, 65, 65, 65,
-        64, 64, 64, 62, 59, 57, 57, 53, 51, 51, 50, 48, 66, 65, 65, 65, 64, 64,
-        64, 62, 59, 57, 57, 53, 51, 51, 50, 48, 62, 61, 60, 60, 59, 59, 59, 58,
-        55, 53, 53, 50, 48, 48, 47, 46, 55, 54, 53, 53, 53, 51, 51, 51, 48, 48,
-        48, 45, 44, 44, 43, 43, 55, 54, 53, 53, 53, 51, 51, 51, 48, 48, 48, 45,
-        44, 44, 43, 43, 53, 52, 51, 51, 51, 50, 50, 49, 48, 47, 47, 45, 43, 43,
-        43, 43,
+        32, 33, 33, 33, 33, 34, 34, 33, 31, 31, 31, 29, 28, 28, 26, 24, 33, 33,
+        33, 33, 33, 33, 33, 32, 30, 29, 29, 28, 26, 26, 26, 24, 33, 33, 33, 33,
+        32, 32, 32, 31, 29, 28, 28, 27, 26, 26, 25, 24, 33, 33, 33, 33, 32, 32,
+        32, 31, 29, 28, 28, 27, 26, 26, 25, 24, 31, 31, 30, 30, 30, 29, 29, 29,
+        28, 27, 27, 25, 24, 24, 24, 23, 28, 27, 27, 27, 26, 26, 26, 26, 24, 24,
+        24, 23, 22, 22, 22, 22, 28, 27, 27, 27, 26, 26, 26, 26, 24, 24, 24, 23,
+        22, 22, 22, 22, 27, 26, 26, 26, 26, 25, 25, 25, 24, 23, 23, 22, 22, 22,
+        22, 21,
         /* Size 16x32 */
-        64, 65, 66, 66, 66, 66, 66, 65, 62, 59, 55, 55, 55, 55, 53, 49, 65, 65,
-        65, 66, 66, 66, 66, 65, 61, 59, 55, 55, 55, 55, 53, 49, 65, 65, 65, 65,
-        65, 65, 65, 64, 61, 58, 54, 54, 54, 54, 52, 49, 65, 65, 65, 65, 65, 65,
-        65, 64, 60, 57, 53, 53, 53, 53, 51, 48, 65, 65, 65, 65, 65, 65, 65, 64,
-        60, 57, 53, 53, 53, 53, 51, 48, 65, 65, 65, 65, 65, 65, 65, 64, 60, 57,
-        53, 53, 53, 53, 51, 48, 65, 65, 65, 65, 65, 65, 65, 64, 60, 57, 53, 53,
-        53, 53, 51, 48, 66, 65, 65, 65, 65, 65, 65, 64, 60, 57, 53, 53, 53, 53,
-        51, 48, 66, 66, 65, 65, 64, 64, 64, 63, 59, 56, 53, 53, 53, 53, 51, 48,
-        67, 66, 65, 64, 64, 64, 64, 63, 59, 55, 52, 52, 52, 52, 51, 48, 67, 66,
-        65, 64, 64, 64, 64, 62, 59, 55, 51, 51, 51, 51, 50, 48, 67, 66, 65, 64,
-        64, 64, 64, 62, 59, 55, 51, 51, 51, 51, 50, 48, 67, 66, 65, 64, 64, 64,
-        64, 62, 59, 55, 51, 51, 51, 51, 50, 48, 67, 66, 65, 64, 64, 64, 64, 62,
-        59, 55, 51, 51, 51, 51, 50, 48, 66, 65, 64, 63, 62, 62, 62, 61, 58, 54,
-        51, 51, 51, 51, 49, 48, 64, 63, 62, 61, 60, 60, 60, 59, 56, 53, 49, 49,
-        49, 49, 48, 47, 62, 61, 60, 59, 59, 59, 59, 58, 55, 51, 48, 48, 48, 48,
-        48, 46, 61, 59, 59, 58, 57, 57, 57, 56, 53, 51, 48, 48, 48, 48, 47, 46,
-        61, 59, 59, 58, 57, 57, 57, 56, 53, 51, 48, 48, 48, 48, 47, 46, 61, 59,
-        59, 58, 57, 57, 57, 56, 53, 51, 48, 48, 48, 48, 47, 46, 61, 59, 59, 58,
-        57, 57, 57, 56, 53, 51, 48, 48, 48, 48, 47, 46, 59, 58, 57, 55, 55, 55,
-        55, 55, 52, 49, 46, 46, 46, 46, 46, 45, 58, 56, 55, 54, 53, 53, 53, 53,
-        50, 48, 45, 45, 45, 45, 45, 44, 56, 55, 53, 52, 52, 52, 52, 51, 48, 46,
-        44, 44, 44, 44, 44, 44, 55, 54, 53, 51, 51, 51, 51, 50, 48, 46, 44, 44,
-        44, 44, 43, 43, 55, 54, 53, 51, 51, 51, 51, 50, 48, 46, 44, 44, 44, 44,
-        43, 43, 55, 54, 53, 51, 51, 51, 51, 50, 48, 46, 44, 44, 44, 44, 43, 43,
-        55, 53, 53, 51, 51, 51, 51, 50, 48, 46, 44, 44, 44, 44, 43, 43, 53, 52,
-        51, 50, 50, 50, 50, 49, 47, 45, 43, 43, 43, 43, 43, 43, 51, 50, 49, 49,
-        49, 49, 49, 48, 47, 45, 43, 43, 43, 43, 43, 42, 49, 49, 48, 48, 48, 48,
-        48, 47, 46, 45, 43, 43, 43, 43, 43, 42, 49, 49, 48, 48, 48, 48, 48, 47,
-        46, 45, 43, 43, 43, 43, 43, 42,
+        32, 33, 33, 33, 33, 33, 33, 33, 31, 29, 28, 28, 28, 28, 27, 24, 33, 33,
+        33, 33, 33, 33, 33, 33, 31, 29, 28, 28, 28, 28, 26, 24, 33, 33, 33, 33,
+        33, 33, 33, 32, 31, 29, 27, 27, 27, 27, 26, 24, 33, 33, 33, 33, 33, 33,
+        33, 32, 30, 28, 27, 27, 27, 27, 26, 24, 33, 33, 33, 33, 33, 33, 33, 32,
+        30, 28, 27, 27, 27, 27, 26, 24, 33, 33, 33, 33, 33, 33, 33, 32, 30, 28,
+        27, 27, 27, 27, 26, 24, 33, 33, 33, 33, 33, 33, 33, 32, 30, 28, 27, 27,
+        27, 27, 26, 24, 33, 33, 33, 33, 33, 33, 33, 32, 30, 28, 27, 27, 27, 27,
+        26, 24, 33, 33, 33, 33, 32, 32, 32, 32, 30, 28, 26, 26, 26, 26, 26, 24,
+        34, 33, 33, 32, 32, 32, 32, 32, 30, 28, 26, 26, 26, 26, 26, 24, 34, 33,
+        33, 32, 32, 32, 32, 31, 29, 28, 26, 26, 26, 26, 25, 24, 34, 33, 33, 32,
+        32, 32, 32, 31, 29, 28, 26, 26, 26, 26, 25, 24, 34, 33, 33, 32, 32, 32,
+        32, 31, 29, 28, 26, 26, 26, 26, 25, 24, 34, 33, 33, 32, 32, 32, 32, 31,
+        29, 28, 26, 26, 26, 26, 25, 24, 33, 33, 32, 32, 31, 31, 31, 31, 29, 27,
+        26, 26, 26, 26, 25, 24, 32, 32, 31, 31, 30, 30, 30, 30, 28, 26, 25, 25,
+        25, 25, 24, 23, 31, 31, 30, 29, 29, 29, 29, 29, 28, 26, 24, 24, 24, 24,
+        24, 23, 31, 30, 29, 29, 28, 28, 28, 28, 27, 26, 24, 24, 24, 24, 23, 23,
+        31, 30, 29, 29, 28, 28, 28, 28, 27, 26, 24, 24, 24, 24, 23, 23, 31, 30,
+        29, 29, 28, 28, 28, 28, 27, 26, 24, 24, 24, 24, 23, 23, 31, 30, 29, 29,
+        28, 28, 28, 28, 27, 26, 24, 24, 24, 24, 23, 23, 30, 29, 28, 28, 28, 28,
+        28, 28, 26, 24, 23, 23, 23, 23, 23, 23, 29, 28, 28, 27, 27, 27, 27, 26,
+        25, 24, 23, 23, 23, 23, 22, 22, 28, 28, 27, 26, 26, 26, 26, 26, 24, 23,
+        22, 22, 22, 22, 22, 22, 28, 27, 26, 26, 26, 26, 26, 25, 24, 23, 22, 22,
+        22, 22, 22, 22, 28, 27, 26, 26, 26, 26, 26, 25, 24, 23, 22, 22, 22, 22,
+        22, 22, 28, 27, 26, 26, 26, 26, 26, 25, 24, 23, 22, 22, 22, 22, 22, 22,
+        28, 27, 26, 26, 26, 26, 26, 25, 24, 23, 22, 22, 22, 22, 22, 22, 26, 26,
+        26, 25, 25, 25, 25, 24, 24, 23, 22, 22, 22, 22, 22, 21, 26, 25, 25, 24,
+        24, 24, 24, 24, 23, 23, 22, 22, 22, 22, 22, 21, 24, 24, 24, 24, 24, 24,
+        24, 24, 23, 22, 22, 22, 22, 22, 21, 21, 24, 24, 24, 24, 24, 24, 24, 24,
+        23, 22, 22, 22, 22, 22, 21, 21,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 65, 66, 66, 67, 67, 67, 67, 67, 66, 64, 62, 61,
-        61, 61, 61, 59, 58, 56, 55, 55, 55, 55, 53, 51, 49, 49, 65, 65, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 65, 63, 61, 59, 59, 59, 59, 58,
-        56, 55, 54, 54, 54, 53, 52, 50, 49, 49, 66, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 64, 62, 60, 59, 59, 59, 59, 57, 55, 53, 53, 53,
-        53, 53, 51, 49, 48, 48, 66, 66, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64,
-        64, 64, 63, 61, 59, 58, 58, 58, 58, 55, 54, 52, 51, 51, 51, 51, 50, 49,
-        48, 48, 66, 66, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 62, 60,
-        59, 57, 57, 57, 57, 55, 53, 52, 51, 51, 51, 51, 50, 49, 48, 48, 66, 66,
-        65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 62, 60, 59, 57, 57, 57,
-        57, 55, 53, 52, 51, 51, 51, 51, 50, 49, 48, 48, 66, 66, 65, 65, 65, 65,
-        65, 65, 64, 64, 64, 64, 64, 64, 62, 60, 59, 57, 57, 57, 57, 55, 53, 52,
-        51, 51, 51, 51, 50, 49, 48, 48, 65, 65, 64, 64, 64, 64, 64, 64, 63, 63,
-        62, 62, 62, 62, 61, 59, 58, 56, 56, 56, 56, 55, 53, 51, 50, 50, 50, 50,
-        49, 48, 47, 47, 62, 61, 61, 60, 60, 60, 60, 60, 59, 59, 59, 59, 59, 59,
-        58, 56, 55, 53, 53, 53, 53, 52, 50, 48, 48, 48, 48, 48, 47, 47, 46, 46,
-        59, 59, 58, 57, 57, 57, 57, 57, 56, 55, 55, 55, 55, 55, 54, 53, 51, 51,
-        51, 51, 51, 49, 48, 46, 46, 46, 46, 46, 45, 45, 45, 45, 55, 55, 54, 53,
-        53, 53, 53, 53, 53, 52, 51, 51, 51, 51, 51, 49, 48, 48, 48, 48, 48, 46,
-        45, 44, 44, 44, 44, 44, 43, 43, 43, 43, 55, 55, 54, 53, 53, 53, 53, 53,
-        53, 52, 51, 51, 51, 51, 51, 49, 48, 48, 48, 48, 48, 46, 45, 44, 44, 44,
-        44, 44, 43, 43, 43, 43, 55, 55, 54, 53, 53, 53, 53, 53, 53, 52, 51, 51,
-        51, 51, 51, 49, 48, 48, 48, 48, 48, 46, 45, 44, 44, 44, 44, 44, 43, 43,
-        43, 43, 55, 55, 54, 53, 53, 53, 53, 53, 53, 52, 51, 51, 51, 51, 51, 49,
-        48, 48, 48, 48, 48, 46, 45, 44, 44, 44, 44, 44, 43, 43, 43, 43, 53, 53,
-        52, 51, 51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 49, 48, 48, 47, 47, 47,
-        47, 46, 45, 44, 43, 43, 43, 43, 43, 43, 43, 43, 49, 49, 49, 48, 48, 48,
-        48, 48, 48, 48, 48, 48, 48, 48, 48, 47, 46, 46, 46, 46, 46, 45, 44, 44,
-        43, 43, 43, 43, 43, 42, 42, 42,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 33, 32, 31, 31,
+        31, 31, 31, 30, 29, 28, 28, 28, 28, 28, 26, 26, 24, 24, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 31, 30, 30, 30, 30, 29,
+        28, 28, 27, 27, 27, 27, 26, 25, 24, 24, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 32, 31, 30, 29, 29, 29, 29, 28, 28, 27, 26, 26,
+        26, 26, 26, 25, 24, 24, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 31, 29, 29, 29, 29, 29, 28, 27, 26, 26, 26, 26, 26, 25, 24,
+        24, 24, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 31, 30,
+        29, 28, 28, 28, 28, 28, 27, 26, 26, 26, 26, 26, 25, 24, 24, 24, 33, 33,
+        33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 31, 30, 29, 28, 28, 28,
+        28, 28, 27, 26, 26, 26, 26, 26, 25, 24, 24, 24, 33, 33, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 31, 30, 29, 28, 28, 28, 28, 28, 27, 26,
+        26, 26, 26, 26, 25, 24, 24, 24, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 31, 30, 29, 28, 28, 28, 28, 28, 26, 26, 25, 25, 25, 25,
+        24, 24, 24, 24, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29,
+        29, 28, 28, 27, 27, 27, 27, 26, 25, 24, 24, 24, 24, 24, 24, 23, 23, 23,
+        29, 29, 29, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27, 26, 26, 26,
+        26, 26, 26, 24, 24, 23, 23, 23, 23, 23, 23, 23, 22, 22, 28, 28, 27, 27,
+        27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24, 24, 23,
+        23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 28, 28, 27, 27, 27, 27, 27, 27,
+        26, 26, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24, 24, 23, 23, 22, 22, 22,
+        22, 22, 22, 22, 22, 22, 28, 28, 27, 27, 27, 27, 27, 27, 26, 26, 26, 26,
+        26, 26, 26, 25, 24, 24, 24, 24, 24, 23, 23, 22, 22, 22, 22, 22, 22, 22,
+        22, 22, 28, 28, 27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 26, 25,
+        24, 24, 24, 24, 24, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 27, 26,
+        26, 26, 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 25, 24, 24, 23, 23, 23,
+        23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 24, 24, 24, 24, 24, 24,
+        24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, 23, 23, 22, 22,
+        22, 22, 22, 22, 21, 21, 21, 21,
         /* Size 4x16 */
-        65, 66, 59, 55, 65, 65, 58, 54, 65, 65, 57, 53, 65, 65, 57, 53, 66, 64,
-        56, 53, 66, 64, 55, 51, 66, 64, 55, 51, 65, 62, 54, 51, 61, 59, 51, 48,
-        59, 57, 51, 48, 59, 57, 51, 48, 56, 53, 48, 45, 54, 51, 46, 44, 54, 51,
-        46, 44, 52, 50, 45, 43, 49, 48, 45, 43,
+        33, 33, 29, 28, 33, 33, 29, 27, 33, 33, 28, 27, 33, 33, 28, 27, 33, 32,
+        28, 26, 33, 32, 28, 26, 33, 32, 28, 26, 33, 31, 27, 26, 31, 29, 26, 24,
+        30, 28, 26, 24, 30, 28, 26, 24, 28, 27, 24, 23, 27, 26, 23, 22, 27, 26,
+        23, 22, 26, 25, 23, 22, 24, 24, 22, 22,
         /* Size 16x4 */
-        65, 65, 65, 65, 66, 66, 66, 65, 61, 59, 59, 56, 54, 54, 52, 49, 66, 65,
-        65, 65, 64, 64, 64, 62, 59, 57, 57, 53, 51, 51, 50, 48, 59, 58, 57, 57,
-        56, 55, 55, 54, 51, 51, 51, 48, 46, 46, 45, 45, 55, 54, 53, 53, 53, 51,
-        51, 51, 48, 48, 48, 45, 44, 44, 43, 43,
+        33, 33, 33, 33, 33, 33, 33, 33, 31, 30, 30, 28, 27, 27, 26, 24, 33, 33,
+        33, 33, 32, 32, 32, 31, 29, 28, 28, 27, 26, 26, 25, 24, 29, 29, 28, 28,
+        28, 28, 28, 27, 26, 26, 26, 24, 23, 23, 23, 22, 28, 27, 27, 27, 26, 26,
+        26, 26, 24, 24, 24, 23, 22, 22, 22, 22,
         /* Size 8x32 */
-        64, 66, 66, 66, 62, 55, 55, 53, 65, 65, 66, 66, 61, 55, 55, 53, 65, 65,
-        65, 65, 61, 54, 54, 52, 65, 65, 65, 65, 60, 53, 53, 51, 65, 65, 65, 65,
-        60, 53, 53, 51, 65, 65, 65, 65, 60, 53, 53, 51, 65, 65, 65, 65, 60, 53,
-        53, 51, 66, 65, 65, 65, 60, 53, 53, 51, 66, 65, 64, 64, 59, 53, 53, 51,
-        67, 65, 64, 64, 59, 52, 52, 51, 67, 65, 64, 64, 59, 51, 51, 50, 67, 65,
-        64, 64, 59, 51, 51, 50, 67, 65, 64, 64, 59, 51, 51, 50, 67, 65, 64, 64,
-        59, 51, 51, 50, 66, 64, 62, 62, 58, 51, 51, 49, 64, 62, 60, 60, 56, 49,
-        49, 48, 62, 60, 59, 59, 55, 48, 48, 48, 61, 59, 57, 57, 53, 48, 48, 47,
-        61, 59, 57, 57, 53, 48, 48, 47, 61, 59, 57, 57, 53, 48, 48, 47, 61, 59,
-        57, 57, 53, 48, 48, 47, 59, 57, 55, 55, 52, 46, 46, 46, 58, 55, 53, 53,
-        50, 45, 45, 45, 56, 53, 52, 52, 48, 44, 44, 44, 55, 53, 51, 51, 48, 44,
-        44, 43, 55, 53, 51, 51, 48, 44, 44, 43, 55, 53, 51, 51, 48, 44, 44, 43,
-        55, 53, 51, 51, 48, 44, 44, 43, 53, 51, 50, 50, 47, 43, 43, 43, 51, 49,
-        49, 49, 47, 43, 43, 43, 49, 48, 48, 48, 46, 43, 43, 43, 49, 48, 48, 48,
-        46, 43, 43, 43,
+        32, 33, 33, 33, 31, 28, 28, 27, 33, 33, 33, 33, 31, 28, 28, 26, 33, 33,
+        33, 33, 31, 27, 27, 26, 33, 33, 33, 33, 30, 27, 27, 26, 33, 33, 33, 33,
+        30, 27, 27, 26, 33, 33, 33, 33, 30, 27, 27, 26, 33, 33, 33, 33, 30, 27,
+        27, 26, 33, 33, 33, 33, 30, 27, 27, 26, 33, 33, 32, 32, 30, 26, 26, 26,
+        34, 33, 32, 32, 30, 26, 26, 26, 34, 33, 32, 32, 29, 26, 26, 25, 34, 33,
+        32, 32, 29, 26, 26, 25, 34, 33, 32, 32, 29, 26, 26, 25, 34, 33, 32, 32,
+        29, 26, 26, 25, 33, 32, 31, 31, 29, 26, 26, 25, 32, 31, 30, 30, 28, 25,
+        25, 24, 31, 30, 29, 29, 28, 24, 24, 24, 31, 29, 28, 28, 27, 24, 24, 23,
+        31, 29, 28, 28, 27, 24, 24, 23, 31, 29, 28, 28, 27, 24, 24, 23, 31, 29,
+        28, 28, 27, 24, 24, 23, 30, 28, 28, 28, 26, 23, 23, 23, 29, 28, 27, 27,
+        25, 23, 23, 22, 28, 27, 26, 26, 24, 22, 22, 22, 28, 26, 26, 26, 24, 22,
+        22, 22, 28, 26, 26, 26, 24, 22, 22, 22, 28, 26, 26, 26, 24, 22, 22, 22,
+        28, 26, 26, 26, 24, 22, 22, 22, 26, 26, 25, 25, 24, 22, 22, 22, 26, 25,
+        24, 24, 23, 22, 22, 22, 24, 24, 24, 24, 23, 22, 22, 21, 24, 24, 24, 24,
+        23, 22, 22, 21,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 65, 66, 66, 67, 67, 67, 67, 67, 66, 64, 62, 61,
-        61, 61, 61, 59, 58, 56, 55, 55, 55, 55, 53, 51, 49, 49, 66, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 62, 60, 59, 59, 59, 59, 57,
-        55, 53, 53, 53, 53, 53, 51, 49, 48, 48, 66, 66, 65, 65, 65, 65, 65, 65,
-        64, 64, 64, 64, 64, 64, 62, 60, 59, 57, 57, 57, 57, 55, 53, 52, 51, 51,
-        51, 51, 50, 49, 48, 48, 66, 66, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64,
-        64, 64, 62, 60, 59, 57, 57, 57, 57, 55, 53, 52, 51, 51, 51, 51, 50, 49,
-        48, 48, 62, 61, 61, 60, 60, 60, 60, 60, 59, 59, 59, 59, 59, 59, 58, 56,
-        55, 53, 53, 53, 53, 52, 50, 48, 48, 48, 48, 48, 47, 47, 46, 46, 55, 55,
-        54, 53, 53, 53, 53, 53, 53, 52, 51, 51, 51, 51, 51, 49, 48, 48, 48, 48,
-        48, 46, 45, 44, 44, 44, 44, 44, 43, 43, 43, 43, 55, 55, 54, 53, 53, 53,
-        53, 53, 53, 52, 51, 51, 51, 51, 51, 49, 48, 48, 48, 48, 48, 46, 45, 44,
-        44, 44, 44, 44, 43, 43, 43, 43, 53, 53, 52, 51, 51, 51, 51, 51, 51, 51,
-        50, 50, 50, 50, 49, 48, 48, 47, 47, 47, 47, 46, 45, 44, 43, 43, 43, 43,
-        43, 43, 43, 43 },
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 33, 32, 31, 31,
+        31, 31, 31, 30, 29, 28, 28, 28, 28, 28, 26, 26, 24, 24, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 31, 30, 29, 29, 29, 29, 28,
+        28, 27, 26, 26, 26, 26, 26, 25, 24, 24, 33, 33, 33, 33, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 31, 30, 29, 28, 28, 28, 28, 28, 27, 26, 26, 26,
+        26, 26, 25, 24, 24, 24, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32,
+        32, 32, 31, 30, 29, 28, 28, 28, 28, 28, 27, 26, 26, 26, 26, 26, 25, 24,
+        24, 24, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 28,
+        28, 27, 27, 27, 27, 26, 25, 24, 24, 24, 24, 24, 24, 23, 23, 23, 28, 28,
+        27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24,
+        24, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 28, 28, 27, 27, 27, 27,
+        27, 27, 26, 26, 26, 26, 26, 26, 26, 25, 24, 24, 24, 24, 24, 23, 23, 22,
+        22, 22, 22, 22, 22, 22, 22, 22, 27, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+        25, 25, 25, 25, 25, 24, 24, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22,
+        22, 22, 21, 21 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        64, 64, 64, 62,
+        32, 32, 32, 31,
 #endif
         /* Size 4x4 */
-        65, 65, 65, 64, 65, 64, 64, 63, 65, 64, 63, 63, 64, 63, 63, 61,
+        33, 33, 33, 32, 33, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 31,
         /* Size 8x8 */
-        65, 65, 65, 65, 65, 65, 64, 64, 65, 64, 64, 64, 64, 64, 64, 64, 65, 64,
-        64, 64, 64, 64, 64, 64, 65, 64, 64, 64, 64, 64, 63, 63, 65, 64, 64, 64,
-        63, 63, 63, 63, 65, 64, 64, 64, 63, 63, 63, 63, 64, 64, 64, 63, 63, 63,
-        61, 61, 64, 64, 64, 63, 63, 63, 61, 61,
+        33, 33, 33, 33, 33, 33, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32,
+        32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32,
+        32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 32, 32, 32, 32, 32, 32, 31, 31,
         /* Size 16x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 65, 65, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 63, 65, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        65, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65,
-        64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 64, 64,
-        64, 64, 64, 63, 63, 63, 63, 63, 62, 62, 62, 62, 65, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 65, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 62, 62, 61, 61, 61, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 62, 62, 61, 61, 61, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 62,
-        62, 61, 61, 61,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 31, 31, 31,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63,
-        63, 63, 63, 63, 63, 63, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 63, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65,
-        65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 62, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62, 62, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62,
-        62, 62, 62, 62, 62, 62, 62, 61, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 61, 61,
-        61, 61, 61, 61, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 61, 61, 61, 61, 61, 61,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 62, 62, 62, 61, 61, 61, 61, 61, 61, 61, 65, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        62, 62, 62, 61, 61, 61, 61, 61, 61, 61, 65, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 61,
-        61, 61, 61, 61, 61, 61, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 61, 61, 61, 61, 61,
-        61, 61, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 62, 61, 61, 61, 61, 61, 61, 61, 61,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31,
+        31, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
         /* Size 4x8 */
-        65, 65, 65, 64, 65, 64, 64, 63, 65, 64, 64, 63, 65, 64, 64, 63, 65, 63,
-        63, 63, 65, 63, 63, 62, 64, 63, 63, 61, 64, 63, 63, 61,
+        33, 33, 33, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32,
+        32, 32, 33, 32, 32, 31, 32, 32, 32, 31, 32, 32, 32, 31,
         /* Size 8x4 */
-        65, 65, 65, 65, 65, 65, 64, 64, 65, 64, 64, 64, 63, 63, 63, 63, 65, 64,
-        64, 64, 63, 63, 63, 63, 64, 63, 63, 63, 63, 62, 61, 61,
+        33, 33, 33, 33, 33, 33, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31,
         /* Size 8x16 */
-        64, 65, 65, 65, 65, 65, 65, 64, 65, 65, 65, 65, 65, 65, 64, 64, 65, 65,
-        64, 64, 64, 64, 64, 63, 65, 64, 64, 64, 64, 64, 64, 63, 65, 64, 64, 64,
-        64, 64, 64, 63, 65, 64, 64, 64, 64, 64, 64, 63, 65, 64, 64, 64, 64, 64,
-        63, 63, 65, 64, 64, 63, 63, 63, 63, 63, 65, 64, 64, 63, 63, 63, 63, 63,
-        65, 64, 64, 63, 63, 63, 63, 63, 65, 64, 64, 63, 63, 63, 63, 63, 65, 64,
-        63, 63, 63, 63, 62, 62, 65, 64, 63, 63, 63, 63, 62, 61, 64, 64, 63, 63,
-        63, 63, 62, 60, 64, 64, 63, 63, 63, 63, 62, 60, 64, 64, 63, 63, 63, 63,
-        62, 60,
+        32, 33, 33, 33, 33, 33, 33, 32, 33, 33, 33, 33, 33, 33, 32, 32, 33, 33,
+        32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32,
+        32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32,
+        32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32,
+        33, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32,
+        32, 32, 32, 32, 31, 31, 33, 32, 32, 32, 32, 32, 31, 31, 32, 32, 32, 32,
+        32, 32, 31, 30, 32, 32, 32, 32, 32, 32, 31, 30, 32, 32, 32, 32, 32, 32,
+        31, 30,
         /* Size 16x8 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 65, 65, 64, 64, 64, 64,
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 64, 64, 64, 64, 64, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 64, 64, 64, 64, 64, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 65, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 62,
-        62, 62, 62, 62, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 61, 60,
-        60, 60,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30,
+        30, 30,
         /* Size 16x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 63, 63, 63, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 63, 63, 63, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63,
-        63, 63, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63,
-        65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 63, 63, 63, 63, 63, 65, 65, 64, 64, 64, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 65, 65, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 65, 65, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 62, 65, 65, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62,
-        65, 65, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 65, 65,
-        64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 65, 65, 64, 64,
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 65, 65, 64, 64, 64, 63,
-        63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 65, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 63, 62, 62, 62, 61, 65, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 63, 62, 62, 61, 61, 65, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 62,
-        62, 61, 61, 60, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 61,
-        60, 60, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 61, 60, 60,
-        64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 61, 60, 60, 64, 64,
-        64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 61, 60, 60, 64, 64, 64, 63,
-        63, 63, 63, 63, 63, 63, 63, 62, 62, 61, 60, 60, 64, 64, 64, 63, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 61, 60, 60, 64, 64, 64, 63, 63, 63, 63, 63,
-        63, 63, 63, 62, 61, 61, 60, 59,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 31, 31, 30, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31,
+        30, 30, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 30, 30, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 31, 30, 30,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63,
-        63, 63, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62,
-        62, 62, 62, 62, 62, 62, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 62,
-        62, 61, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 62, 62, 62, 61, 61, 61, 61, 61, 61, 61, 61, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 62, 62, 61, 61, 60, 60, 60, 60, 60, 60, 60, 64, 64, 64, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 61, 61,
-        60, 60, 60, 60, 60, 60, 60, 59,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 31, 31, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31,
+        31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+        30, 30, 30, 30, 30, 30, 30, 30,
         /* Size 4x16 */
-        65, 65, 65, 64, 65, 65, 65, 64, 65, 64, 64, 64, 65, 64, 64, 63, 65, 64,
-        64, 63, 65, 64, 64, 63, 65, 64, 64, 63, 65, 63, 63, 63, 65, 63, 63, 63,
-        65, 63, 63, 63, 65, 63, 63, 63, 64, 63, 63, 62, 64, 63, 63, 61, 64, 63,
-        63, 61, 64, 63, 63, 61, 64, 63, 63, 61,
+        33, 33, 33, 32, 33, 33, 33, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32,
+        32, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32,
+        33, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 31, 32, 32, 32, 31, 32, 32,
+        32, 31, 32, 32, 32, 31, 32, 32, 32, 31,
         /* Size 16x4 */
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 65, 65,
-        64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 64, 64,
-        64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 63, 63, 63,
-        63, 63, 63, 63, 63, 62, 61, 61, 61, 61,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 31, 31, 31,
         /* Size 8x32 */
-        64, 65, 65, 65, 65, 65, 65, 64, 65, 65, 65, 65, 65, 65, 64, 64, 65, 65,
-        65, 65, 65, 65, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64,
-        64, 64, 64, 63, 65, 64, 64, 64, 64, 64, 64, 63, 65, 64, 64, 64, 64, 64,
-        64, 63, 65, 64, 64, 64, 64, 64, 64, 63, 65, 64, 64, 64, 64, 64, 64, 63,
-        65, 64, 64, 64, 64, 64, 64, 63, 65, 64, 64, 64, 64, 64, 64, 63, 65, 64,
-        64, 64, 64, 64, 64, 63, 65, 64, 64, 64, 64, 64, 63, 63, 65, 64, 64, 64,
-        64, 64, 63, 63, 65, 64, 64, 63, 63, 63, 63, 63, 65, 64, 64, 63, 63, 63,
-        63, 63, 65, 64, 64, 63, 63, 63, 63, 63, 65, 64, 64, 63, 63, 63, 63, 63,
-        65, 64, 64, 63, 63, 63, 63, 63, 65, 64, 64, 63, 63, 63, 63, 63, 65, 64,
-        64, 63, 63, 63, 63, 63, 65, 64, 64, 63, 63, 63, 63, 62, 65, 64, 63, 63,
-        63, 63, 62, 62, 65, 64, 63, 63, 63, 63, 62, 61, 65, 64, 63, 63, 63, 63,
-        62, 61, 64, 64, 63, 63, 63, 63, 62, 60, 64, 64, 63, 63, 63, 63, 62, 60,
-        64, 64, 63, 63, 63, 63, 62, 60, 64, 64, 63, 63, 63, 63, 62, 60, 64, 64,
-        63, 63, 63, 63, 62, 60, 64, 64, 63, 63, 63, 63, 62, 60, 64, 64, 63, 63,
-        63, 63, 61, 60,
+        32, 33, 33, 33, 33, 33, 33, 32, 33, 33, 33, 33, 33, 33, 32, 32, 33, 33,
+        33, 33, 33, 33, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32,
+        32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32,
+        32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32,
+        33, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32,
+        32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32,
+        32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32,
+        32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32,
+        33, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 32, 33, 32,
+        32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32, 32, 31, 33, 32, 32, 32,
+        32, 32, 31, 31, 33, 32, 32, 32, 32, 32, 31, 31, 33, 32, 32, 32, 32, 32,
+        31, 31, 32, 32, 32, 32, 32, 32, 31, 30, 32, 32, 32, 32, 32, 32, 31, 30,
+        32, 32, 32, 32, 32, 32, 31, 30, 32, 32, 32, 32, 32, 32, 31, 30, 32, 32,
+        32, 32, 32, 32, 31, 30, 32, 32, 32, 32, 32, 32, 31, 30, 32, 32, 32, 32,
+        32, 32, 31, 30,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-        63, 63, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62,
-        62, 62, 62, 62, 62, 62, 62, 61, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63,
-        63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 61, 61, 60, 60, 60,
-        60, 60, 60, 60 },
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30,
+        30, 30, 30, 30 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        65, 62, 62, 57,
+        33, 31, 31, 28,
 #endif
         /* Size 4x4 */
-        65, 66, 66, 60, 66, 65, 65, 59, 66, 65, 64, 58, 60, 59, 58, 53,
+        33, 33, 33, 30, 33, 33, 33, 29, 33, 33, 32, 29, 30, 29, 29, 26,
         /* Size 8x8 */
-        65, 66, 66, 66, 67, 66, 61, 61, 66, 65, 65, 65, 66, 64, 59, 59, 66, 65,
-        65, 65, 66, 64, 59, 59, 66, 65, 65, 65, 65, 64, 59, 59, 67, 66, 66, 65,
-        64, 63, 58, 58, 66, 64, 64, 64, 63, 62, 57, 57, 61, 59, 59, 59, 58, 57,
-        53, 53, 61, 59, 59, 59, 58, 57, 53, 53,
+        33, 33, 33, 33, 34, 33, 31, 31, 33, 33, 33, 33, 33, 32, 30, 30, 33, 33,
+        33, 33, 33, 32, 30, 30, 33, 33, 33, 33, 33, 32, 29, 29, 34, 33, 33, 33,
+        32, 32, 29, 29, 33, 32, 32, 32, 32, 31, 28, 28, 31, 30, 30, 29, 29, 28,
+        26, 26, 31, 30, 30, 29, 29, 28, 26, 26,
         /* Size 16x16 */
-        64, 65, 65, 66, 66, 66, 66, 67, 67, 67, 67, 65, 62, 61, 61, 61, 65, 65,
-        65, 65, 65, 65, 66, 66, 67, 67, 67, 64, 62, 60, 60, 60, 65, 65, 65, 65,
-        65, 65, 66, 66, 66, 66, 66, 63, 61, 59, 59, 59, 66, 65, 65, 65, 65, 65,
-        65, 65, 66, 66, 66, 63, 60, 59, 59, 59, 66, 65, 65, 65, 65, 65, 65, 65,
-        66, 66, 66, 63, 60, 59, 59, 59, 66, 65, 65, 65, 65, 65, 65, 65, 66, 66,
-        66, 63, 60, 59, 59, 59, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 62,
-        60, 59, 59, 59, 67, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 62, 59, 58,
-        58, 58, 67, 67, 66, 66, 66, 66, 65, 65, 64, 64, 64, 62, 59, 58, 58, 58,
-        67, 67, 66, 66, 66, 66, 65, 65, 64, 64, 64, 62, 59, 58, 58, 58, 67, 67,
-        66, 66, 66, 66, 65, 65, 64, 64, 64, 62, 59, 58, 58, 58, 65, 64, 63, 63,
-        63, 63, 62, 62, 62, 62, 62, 59, 57, 55, 55, 55, 62, 62, 61, 60, 60, 60,
-        60, 59, 59, 59, 59, 57, 55, 53, 53, 53, 61, 60, 59, 59, 59, 59, 59, 58,
-        58, 58, 58, 55, 53, 53, 53, 53, 61, 60, 59, 59, 59, 59, 59, 58, 58, 58,
-        58, 55, 53, 53, 53, 53, 61, 60, 59, 59, 59, 59, 59, 58, 58, 58, 58, 55,
-        53, 53, 53, 53,
+        32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 33, 31, 31, 31, 31, 33, 33,
+        33, 33, 33, 33, 33, 33, 34, 34, 34, 32, 31, 30, 30, 30, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 31, 30, 30, 30, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 32, 30, 30, 30, 30, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 32, 30, 30, 30, 30, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 32, 30, 30, 30, 30, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31,
+        30, 29, 29, 29, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 30, 29,
+        29, 29, 34, 34, 33, 33, 33, 33, 33, 33, 32, 32, 32, 31, 30, 29, 29, 29,
+        34, 34, 33, 33, 33, 33, 33, 33, 32, 32, 32, 31, 30, 29, 29, 29, 34, 34,
+        33, 33, 33, 33, 33, 33, 32, 32, 32, 31, 30, 29, 29, 29, 33, 32, 32, 32,
+        32, 32, 31, 31, 31, 31, 31, 30, 28, 28, 28, 28, 31, 31, 31, 30, 30, 30,
+        30, 30, 30, 30, 30, 28, 28, 27, 27, 27, 31, 30, 30, 30, 30, 30, 29, 29,
+        29, 29, 29, 28, 27, 26, 26, 26, 31, 30, 30, 30, 30, 30, 29, 29, 29, 29,
+        29, 28, 27, 26, 26, 26, 31, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 28,
+        27, 26, 26, 26,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67,
-        67, 67, 67, 66, 65, 64, 62, 61, 61, 61, 61, 61, 61, 60, 65, 65, 65, 65,
-        65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 66,
-        65, 63, 62, 61, 61, 61, 61, 61, 61, 59, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 65, 64, 63, 62, 60,
-        60, 60, 60, 60, 60, 59, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66,
-        66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 64, 62, 61, 60, 60, 60, 60, 60,
-        60, 59, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66,
-        66, 66, 66, 66, 66, 65, 63, 62, 61, 59, 59, 59, 59, 59, 59, 59, 66, 66,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66,
-        66, 64, 63, 62, 60, 59, 59, 59, 59, 59, 59, 58, 66, 66, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 64, 63, 62,
-        60, 59, 59, 59, 59, 59, 59, 58, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 64, 63, 62, 60, 59, 59, 59,
-        59, 59, 59, 58, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 66, 66, 66, 66, 66, 66, 64, 63, 62, 60, 59, 59, 59, 59, 59, 59, 58,
-        66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66,
-        66, 66, 66, 64, 63, 62, 60, 59, 59, 59, 59, 59, 59, 58, 66, 66, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 64,
-        63, 62, 60, 59, 59, 59, 59, 59, 59, 58, 66, 66, 66, 66, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 63, 61, 60, 59,
-        59, 59, 59, 59, 59, 58, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 62, 61, 60, 59, 59, 59, 59, 59,
-        59, 58, 67, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 64, 62, 61, 59, 59, 59, 59, 59, 59, 59, 57, 67, 67,
-        66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 63, 62, 60, 59, 58, 58, 58, 58, 58, 58, 57, 67, 67, 67, 66, 66, 66,
-        66, 66, 66, 66, 66, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 63, 62, 60,
-        59, 58, 58, 58, 58, 58, 58, 56, 67, 67, 67, 66, 66, 66, 66, 66, 66, 66,
-        66, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 63, 62, 60, 59, 58, 58, 58,
-        58, 58, 58, 56, 67, 67, 67, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 63, 62, 60, 59, 58, 58, 58, 58, 58, 58, 56,
-        67, 67, 67, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 63, 62, 60, 59, 58, 58, 58, 58, 58, 58, 56, 67, 67, 67, 66,
-        66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 63,
-        62, 60, 59, 58, 58, 58, 58, 58, 58, 56, 67, 67, 67, 66, 66, 66, 66, 66,
-        66, 66, 66, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 63, 62, 60, 59, 58,
-        58, 58, 58, 58, 58, 56, 66, 66, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 63, 63, 63, 62, 60, 59, 58, 57, 57, 57, 57, 57,
-        57, 55, 65, 65, 64, 64, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62,
-        62, 62, 62, 62, 62, 60, 59, 58, 57, 55, 55, 55, 55, 55, 55, 55, 64, 63,
-        63, 62, 62, 62, 62, 62, 62, 62, 62, 61, 61, 61, 60, 60, 60, 60, 60, 60,
-        60, 59, 58, 57, 55, 55, 55, 55, 55, 55, 55, 53, 62, 62, 62, 61, 61, 60,
-        60, 60, 60, 60, 60, 60, 60, 59, 59, 59, 59, 59, 59, 59, 59, 58, 57, 55,
-        55, 53, 53, 53, 53, 53, 53, 53, 61, 61, 60, 60, 59, 59, 59, 59, 59, 59,
-        59, 59, 59, 59, 58, 58, 58, 58, 58, 58, 58, 57, 55, 55, 53, 53, 53, 53,
-        53, 53, 53, 51, 61, 61, 60, 60, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
-        58, 58, 58, 58, 58, 58, 58, 57, 55, 55, 53, 53, 53, 53, 53, 53, 53, 51,
-        61, 61, 60, 60, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 58, 58, 58, 58,
-        58, 58, 58, 57, 55, 55, 53, 53, 53, 53, 53, 53, 53, 51, 61, 61, 60, 60,
-        59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 58, 58, 58, 58, 58, 58, 58, 57,
-        55, 55, 53, 53, 53, 53, 53, 53, 53, 51, 61, 61, 60, 60, 59, 59, 59, 59,
-        59, 59, 59, 59, 59, 59, 58, 58, 58, 58, 58, 58, 58, 57, 55, 55, 53, 53,
-        53, 53, 53, 53, 53, 51, 61, 61, 60, 60, 59, 59, 59, 59, 59, 59, 59, 59,
-        59, 59, 58, 58, 58, 58, 58, 58, 58, 57, 55, 55, 53, 53, 53, 53, 53, 53,
-        53, 51, 60, 59, 59, 59, 59, 58, 58, 58, 58, 58, 58, 58, 58, 57, 57, 56,
-        56, 56, 56, 56, 56, 55, 55, 53, 53, 51, 51, 51, 51, 51, 51, 51,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34,
+        34, 34, 34, 33, 33, 32, 31, 31, 31, 31, 31, 31, 31, 30, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 33,
+        33, 32, 31, 31, 31, 31, 31, 31, 31, 30, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 33, 32, 32, 31, 30,
+        30, 30, 30, 30, 30, 30, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 31, 31, 30, 30, 30, 30, 30,
+        30, 29, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 32, 31, 31, 30, 30, 30, 30, 30, 30, 29, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 32, 32, 31, 30, 30, 30, 30, 30, 30, 30, 29, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 31,
+        30, 30, 30, 30, 30, 30, 30, 29, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 31, 30, 30, 30, 30,
+        30, 30, 30, 29, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 32, 31, 30, 30, 30, 30, 30, 30, 30, 29,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 32, 32, 31, 30, 30, 30, 30, 30, 30, 30, 29, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32,
+        32, 31, 30, 30, 30, 30, 30, 30, 30, 29, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 31, 30, 29,
+        29, 29, 29, 29, 29, 29, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 31, 31, 30, 29, 29, 29, 29, 29,
+        29, 29, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 32, 31, 31, 30, 29, 29, 29, 29, 29, 29, 28, 34, 34,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 32, 31, 30, 30, 29, 29, 29, 29, 29, 29, 28, 34, 34, 34, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31, 30,
+        30, 29, 29, 29, 29, 29, 29, 28, 34, 34, 34, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 29,
+        29, 29, 29, 28, 34, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 29, 29, 29, 29, 28,
+        34, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 31, 30, 30, 29, 29, 29, 29, 29, 29, 28, 34, 34, 34, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32,
+        31, 30, 30, 29, 29, 29, 29, 29, 29, 28, 34, 34, 34, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 29,
+        29, 29, 29, 29, 29, 28, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 29, 28, 28, 28, 28, 28,
+        28, 28, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31,
+        31, 31, 31, 31, 31, 30, 30, 29, 28, 28, 28, 28, 28, 28, 28, 28, 32, 32,
+        32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30,
+        30, 30, 29, 28, 28, 28, 28, 28, 28, 28, 28, 27, 31, 31, 31, 31, 31, 30,
+        30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 29, 28, 28,
+        28, 27, 27, 27, 27, 27, 27, 26, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30,
+        30, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 27, 26, 26, 26,
+        26, 26, 26, 26, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29,
+        29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 27, 26, 26, 26, 26, 26, 26, 26,
+        31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 29,
+        29, 29, 29, 28, 28, 28, 27, 26, 26, 26, 26, 26, 26, 26, 31, 31, 30, 30,
+        30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28,
+        28, 28, 27, 26, 26, 26, 26, 26, 26, 26, 31, 31, 30, 30, 30, 30, 30, 30,
+        30, 30, 30, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 27, 26,
+        26, 26, 26, 26, 26, 26, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 29,
+        29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 27, 26, 26, 26, 26, 26,
+        26, 26, 30, 30, 30, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28,
+        28, 28, 28, 28, 28, 28, 28, 27, 26, 26, 26, 26, 26, 26, 26, 26,
         /* Size 4x8 */
-        65, 66, 66, 59, 65, 65, 65, 58, 65, 65, 65, 58, 66, 64, 64, 57, 66, 64,
-        64, 56, 65, 62, 62, 55, 60, 57, 57, 51, 60, 57, 57, 51,
+        33, 33, 33, 30, 33, 33, 33, 29, 33, 33, 33, 29, 33, 32, 32, 28, 33, 32,
+        32, 28, 33, 31, 31, 28, 30, 28, 28, 26, 30, 28, 28, 26,
         /* Size 8x4 */
-        65, 65, 65, 66, 66, 65, 60, 60, 66, 65, 65, 64, 64, 62, 57, 57, 66, 65,
-        65, 64, 64, 62, 57, 57, 59, 58, 58, 57, 56, 55, 51, 51,
+        33, 33, 33, 33, 33, 33, 30, 30, 33, 33, 33, 32, 32, 31, 28, 28, 33, 33,
+        33, 32, 32, 31, 28, 28, 30, 29, 29, 28, 28, 28, 26, 26,
         /* Size 8x16 */
-        64, 65, 66, 66, 66, 66, 62, 58, 65, 65, 66, 66, 66, 66, 61, 57, 65, 65,
-        65, 65, 65, 65, 60, 56, 65, 65, 65, 65, 65, 65, 60, 55, 65, 65, 65, 65,
-        65, 65, 60, 55, 65, 65, 65, 65, 65, 65, 60, 55, 66, 65, 65, 64, 64, 64,
-        59, 55, 67, 66, 65, 64, 64, 64, 59, 54, 67, 66, 64, 64, 64, 64, 59, 54,
-        67, 66, 64, 64, 64, 64, 59, 54, 67, 66, 64, 64, 64, 64, 59, 54, 65, 63,
-        62, 61, 61, 61, 57, 52, 62, 60, 59, 59, 59, 59, 55, 51, 61, 59, 58, 57,
-        57, 57, 53, 49, 61, 59, 58, 57, 57, 57, 53, 49, 61, 59, 58, 57, 57, 57,
-        53, 49,
+        32, 33, 33, 33, 33, 33, 31, 29, 33, 33, 33, 33, 33, 33, 31, 28, 33, 33,
+        33, 33, 33, 33, 30, 28, 33, 33, 33, 33, 33, 33, 30, 28, 33, 33, 33, 33,
+        33, 33, 30, 28, 33, 33, 33, 33, 33, 33, 30, 28, 33, 33, 33, 32, 32, 32,
+        30, 28, 34, 33, 33, 32, 32, 32, 30, 27, 34, 33, 32, 32, 32, 32, 29, 27,
+        34, 33, 32, 32, 32, 32, 29, 27, 34, 33, 32, 32, 32, 32, 29, 27, 33, 32,
+        31, 31, 31, 31, 28, 26, 31, 30, 30, 29, 29, 29, 28, 26, 31, 30, 29, 28,
+        28, 28, 27, 25, 31, 30, 29, 28, 28, 28, 27, 25, 31, 30, 29, 28, 28, 28,
+        27, 25,
         /* Size 16x8 */
-        64, 65, 65, 65, 65, 65, 66, 67, 67, 67, 67, 65, 62, 61, 61, 61, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 66, 66, 63, 60, 59, 59, 59, 66, 66, 65, 65,
-        65, 65, 65, 65, 64, 64, 64, 62, 59, 58, 58, 58, 66, 66, 65, 65, 65, 65,
-        64, 64, 64, 64, 64, 61, 59, 57, 57, 57, 66, 66, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 61, 59, 57, 57, 57, 66, 66, 65, 65, 65, 65, 64, 64, 64, 64,
-        64, 61, 59, 57, 57, 57, 62, 61, 60, 60, 60, 60, 59, 59, 59, 59, 59, 57,
-        55, 53, 53, 53, 58, 57, 56, 55, 55, 55, 55, 54, 54, 54, 54, 52, 51, 49,
-        49, 49,
+        32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 33, 31, 31, 31, 31, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 30, 30, 30, 30, 33, 33, 33, 33,
+        33, 33, 33, 33, 32, 32, 32, 31, 30, 29, 29, 29, 33, 33, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 31, 29, 28, 28, 28, 33, 33, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 31, 29, 28, 28, 28, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32,
+        32, 31, 29, 28, 28, 28, 31, 31, 30, 30, 30, 30, 30, 30, 29, 29, 29, 28,
+        28, 27, 27, 27, 29, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 26, 26, 25,
+        25, 25,
         /* Size 16x32 */
-        64, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 64, 62, 60, 58, 55, 65, 65,
-        65, 66, 66, 66, 66, 66, 66, 66, 66, 64, 62, 59, 58, 55, 65, 65, 65, 65,
-        66, 66, 66, 66, 66, 66, 66, 64, 61, 59, 57, 55, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 63, 61, 59, 56, 54, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 63, 60, 59, 56, 54, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 62, 60, 58, 55, 53, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 62,
-        60, 58, 55, 53, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 62, 60, 58,
-        55, 53, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 62, 60, 58, 55, 53,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 62, 60, 58, 55, 53, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 62, 60, 58, 55, 53, 66, 66, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 62, 60, 58, 55, 53, 66, 66, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 62, 59, 57, 55, 53, 66, 66, 66, 65, 65, 64, 64, 64,
-        64, 64, 64, 62, 59, 57, 55, 52, 67, 66, 66, 65, 65, 64, 64, 64, 64, 64,
-        64, 61, 59, 57, 54, 52, 67, 66, 66, 65, 64, 64, 64, 64, 64, 64, 64, 61,
-        59, 56, 54, 51, 67, 66, 66, 65, 64, 64, 64, 64, 64, 64, 64, 61, 59, 56,
-        54, 51, 67, 66, 66, 65, 64, 64, 64, 64, 64, 64, 64, 61, 59, 56, 54, 51,
-        67, 66, 66, 65, 64, 64, 64, 64, 64, 64, 64, 61, 59, 56, 54, 51, 67, 66,
-        66, 65, 64, 64, 64, 64, 64, 64, 64, 61, 59, 56, 54, 51, 67, 66, 66, 65,
-        64, 64, 64, 64, 64, 64, 64, 61, 59, 56, 54, 51, 66, 65, 65, 64, 63, 62,
-        62, 62, 62, 62, 62, 60, 58, 55, 53, 51, 65, 64, 63, 62, 62, 61, 61, 61,
-        61, 61, 61, 59, 57, 55, 52, 50, 63, 63, 62, 61, 60, 60, 60, 60, 60, 60,
-        60, 58, 55, 53, 51, 49, 62, 61, 60, 60, 59, 59, 59, 59, 59, 59, 59, 56,
-        55, 53, 51, 48, 61, 60, 59, 59, 58, 57, 57, 57, 57, 57, 57, 55, 53, 51,
-        49, 48, 61, 60, 59, 59, 58, 57, 57, 57, 57, 57, 57, 55, 53, 51, 49, 48,
-        61, 60, 59, 59, 58, 57, 57, 57, 57, 57, 57, 55, 53, 51, 49, 48, 61, 60,
-        59, 59, 58, 57, 57, 57, 57, 57, 57, 55, 53, 51, 49, 48, 61, 60, 59, 59,
-        58, 57, 57, 57, 57, 57, 57, 55, 53, 51, 49, 48, 61, 60, 59, 59, 58, 57,
-        57, 57, 57, 57, 57, 55, 53, 51, 49, 48, 59, 59, 59, 58, 57, 56, 56, 56,
-        56, 56, 56, 54, 53, 51, 49, 47,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 31, 30, 29, 28, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 31, 30, 29, 28, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 31, 30, 28, 28, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 32, 31, 29, 28, 27, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 32, 30, 29, 28, 27, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 31, 30, 29, 28, 27, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31,
+        30, 29, 28, 27, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 30, 29,
+        28, 27, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 30, 29, 28, 27,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 30, 29, 28, 27, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 31, 30, 29, 28, 27, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 31, 30, 29, 28, 27, 33, 33, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 31, 30, 28, 28, 26, 33, 33, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 31, 30, 28, 28, 26, 34, 33, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 31, 30, 28, 27, 26, 34, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31,
+        29, 28, 27, 26, 34, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31, 29, 28,
+        27, 26, 34, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31, 29, 28, 27, 26,
+        34, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31, 29, 28, 27, 26, 34, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 31, 29, 28, 27, 26, 34, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 31, 29, 28, 27, 26, 33, 33, 33, 32, 32, 31,
+        31, 31, 31, 31, 31, 30, 29, 28, 27, 26, 33, 32, 32, 31, 31, 31, 31, 31,
+        31, 31, 31, 29, 28, 28, 26, 25, 32, 32, 31, 31, 30, 30, 30, 30, 30, 30,
+        30, 29, 28, 27, 26, 25, 31, 31, 30, 30, 30, 29, 29, 29, 29, 29, 29, 28,
+        28, 26, 26, 24, 31, 30, 30, 29, 29, 28, 28, 28, 28, 28, 28, 28, 27, 26,
+        25, 24, 31, 30, 30, 29, 29, 28, 28, 28, 28, 28, 28, 28, 27, 26, 25, 24,
+        31, 30, 30, 29, 29, 28, 28, 28, 28, 28, 28, 28, 27, 26, 25, 24, 31, 30,
+        30, 29, 29, 28, 28, 28, 28, 28, 28, 28, 27, 26, 25, 24, 31, 30, 30, 29,
+        29, 28, 28, 28, 28, 28, 28, 28, 27, 26, 25, 24, 31, 30, 30, 29, 29, 28,
+        28, 28, 28, 28, 28, 28, 27, 26, 25, 24, 30, 30, 29, 29, 28, 28, 28, 28,
+        28, 28, 28, 27, 26, 26, 24, 23,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67, 67,
-        67, 67, 67, 66, 65, 63, 62, 61, 61, 61, 61, 61, 61, 59, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 65,
-        64, 63, 61, 60, 60, 60, 60, 60, 60, 59, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 65, 63, 62, 60, 59,
-        59, 59, 59, 59, 59, 59, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 62, 61, 60, 59, 59, 59, 59, 59,
-        59, 58, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 63, 62, 60, 59, 58, 58, 58, 58, 58, 58, 57, 66, 66,
-        66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 62, 61, 60, 59, 57, 57, 57, 57, 57, 57, 56, 66, 66, 66, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 61, 60,
-        59, 57, 57, 57, 57, 57, 57, 56, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 61, 60, 59, 57, 57, 57,
-        57, 57, 57, 56, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 62, 61, 60, 59, 57, 57, 57, 57, 57, 57, 56,
-        66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 62, 61, 60, 59, 57, 57, 57, 57, 57, 57, 56, 66, 66, 66, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62,
-        61, 60, 59, 57, 57, 57, 57, 57, 57, 56, 64, 64, 64, 63, 63, 62, 62, 62,
-        62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 61, 61, 61, 60, 59, 58, 56, 55,
-        55, 55, 55, 55, 55, 54, 62, 62, 61, 61, 60, 60, 60, 60, 60, 60, 60, 60,
-        59, 59, 59, 59, 59, 59, 59, 59, 59, 58, 57, 55, 55, 53, 53, 53, 53, 53,
-        53, 53, 60, 59, 59, 59, 59, 58, 58, 58, 58, 58, 58, 58, 57, 57, 57, 56,
-        56, 56, 56, 56, 56, 55, 55, 53, 53, 51, 51, 51, 51, 51, 51, 51, 58, 58,
-        57, 56, 56, 55, 55, 55, 55, 55, 55, 55, 55, 55, 54, 54, 54, 54, 54, 54,
-        54, 53, 52, 51, 51, 49, 49, 49, 49, 49, 49, 49, 55, 55, 55, 54, 54, 53,
-        53, 53, 53, 53, 53, 53, 53, 52, 52, 51, 51, 51, 51, 51, 51, 51, 50, 49,
-        48, 48, 48, 48, 48, 48, 48, 47,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34,
+        34, 34, 34, 33, 33, 32, 31, 31, 31, 31, 31, 31, 31, 30, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        32, 32, 31, 30, 30, 30, 30, 30, 30, 30, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 31, 30, 30,
+        30, 30, 30, 30, 30, 29, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 31, 31, 30, 29, 29, 29, 29, 29,
+        29, 29, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 31, 30, 30, 29, 29, 29, 29, 29, 29, 28, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 30, 29, 28, 28, 28, 28, 28, 28, 28, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30,
+        29, 28, 28, 28, 28, 28, 28, 28, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 29, 28, 28, 28,
+        28, 28, 28, 28, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 29, 28, 28, 28, 28, 28, 28, 28,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 31, 31, 30, 29, 28, 28, 28, 28, 28, 28, 28, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31,
+        31, 30, 29, 28, 28, 28, 28, 28, 28, 28, 32, 32, 32, 32, 32, 31, 31, 31,
+        31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 29, 29, 28, 28,
+        28, 28, 28, 28, 28, 27, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30,
+        30, 30, 30, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 27, 27, 27, 27, 27,
+        27, 26, 30, 30, 30, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28,
+        28, 28, 28, 28, 28, 28, 28, 27, 26, 26, 26, 26, 26, 26, 26, 26, 29, 29,
+        28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 27, 27,
+        27, 27, 26, 26, 26, 25, 25, 25, 25, 25, 25, 24, 28, 28, 28, 27, 27, 27,
+        27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 25, 25,
+        24, 24, 24, 24, 24, 24, 24, 23,
         /* Size 4x16 */
-        65, 66, 66, 60, 65, 66, 66, 59, 65, 65, 65, 59, 65, 65, 65, 58, 65, 65,
-        65, 58, 65, 65, 65, 58, 66, 64, 64, 57, 66, 64, 64, 57, 66, 64, 64, 56,
-        66, 64, 64, 56, 66, 64, 64, 56, 64, 61, 61, 55, 61, 59, 59, 53, 60, 57,
-        57, 51, 60, 57, 57, 51, 60, 57, 57, 51,
+        33, 33, 33, 30, 33, 33, 33, 30, 33, 33, 33, 29, 33, 33, 33, 29, 33, 33,
+        33, 29, 33, 33, 33, 29, 33, 32, 32, 28, 33, 32, 32, 28, 33, 32, 32, 28,
+        33, 32, 32, 28, 33, 32, 32, 28, 32, 31, 31, 28, 31, 29, 29, 26, 30, 28,
+        28, 26, 30, 28, 28, 26, 30, 28, 28, 26,
         /* Size 16x4 */
-        65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 64, 61, 60, 60, 60, 66, 66,
-        65, 65, 65, 65, 64, 64, 64, 64, 64, 61, 59, 57, 57, 57, 66, 66, 65, 65,
-        65, 65, 64, 64, 64, 64, 64, 61, 59, 57, 57, 57, 60, 59, 59, 58, 58, 58,
-        57, 57, 56, 56, 56, 55, 53, 51, 51, 51,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 31, 30, 30, 30, 33, 33,
+        33, 33, 33, 33, 32, 32, 32, 32, 32, 31, 29, 28, 28, 28, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 31, 29, 28, 28, 28, 30, 30, 29, 29, 29, 29,
+        28, 28, 28, 28, 28, 28, 26, 26, 26, 26,
         /* Size 8x32 */
-        64, 65, 66, 66, 66, 66, 62, 58, 65, 65, 66, 66, 66, 66, 62, 58, 65, 65,
-        66, 66, 66, 66, 61, 57, 65, 65, 65, 65, 65, 65, 61, 56, 65, 65, 65, 65,
-        65, 65, 60, 56, 65, 65, 65, 65, 65, 65, 60, 55, 65, 65, 65, 65, 65, 65,
-        60, 55, 65, 65, 65, 65, 65, 65, 60, 55, 65, 65, 65, 65, 65, 65, 60, 55,
-        65, 65, 65, 65, 65, 65, 60, 55, 65, 65, 65, 65, 65, 65, 60, 55, 66, 65,
-        65, 65, 65, 65, 60, 55, 66, 65, 65, 64, 64, 64, 59, 55, 66, 66, 65, 64,
-        64, 64, 59, 55, 67, 66, 65, 64, 64, 64, 59, 54, 67, 66, 64, 64, 64, 64,
-        59, 54, 67, 66, 64, 64, 64, 64, 59, 54, 67, 66, 64, 64, 64, 64, 59, 54,
-        67, 66, 64, 64, 64, 64, 59, 54, 67, 66, 64, 64, 64, 64, 59, 54, 67, 66,
-        64, 64, 64, 64, 59, 54, 66, 65, 63, 62, 62, 62, 58, 53, 65, 63, 62, 61,
-        61, 61, 57, 52, 63, 62, 60, 60, 60, 60, 55, 51, 62, 60, 59, 59, 59, 59,
-        55, 51, 61, 59, 58, 57, 57, 57, 53, 49, 61, 59, 58, 57, 57, 57, 53, 49,
-        61, 59, 58, 57, 57, 57, 53, 49, 61, 59, 58, 57, 57, 57, 53, 49, 61, 59,
-        58, 57, 57, 57, 53, 49, 61, 59, 58, 57, 57, 57, 53, 49, 59, 59, 57, 56,
-        56, 56, 53, 49,
+        32, 33, 33, 33, 33, 33, 31, 29, 33, 33, 33, 33, 33, 33, 31, 29, 33, 33,
+        33, 33, 33, 33, 31, 28, 33, 33, 33, 33, 33, 33, 31, 28, 33, 33, 33, 33,
+        33, 33, 30, 28, 33, 33, 33, 33, 33, 33, 30, 28, 33, 33, 33, 33, 33, 33,
+        30, 28, 33, 33, 33, 33, 33, 33, 30, 28, 33, 33, 33, 33, 33, 33, 30, 28,
+        33, 33, 33, 33, 33, 33, 30, 28, 33, 33, 33, 33, 33, 33, 30, 28, 33, 33,
+        33, 33, 33, 33, 30, 28, 33, 33, 33, 32, 32, 32, 30, 28, 33, 33, 33, 32,
+        32, 32, 30, 28, 34, 33, 33, 32, 32, 32, 30, 27, 34, 33, 32, 32, 32, 32,
+        29, 27, 34, 33, 32, 32, 32, 32, 29, 27, 34, 33, 32, 32, 32, 32, 29, 27,
+        34, 33, 32, 32, 32, 32, 29, 27, 34, 33, 32, 32, 32, 32, 29, 27, 34, 33,
+        32, 32, 32, 32, 29, 27, 33, 33, 32, 31, 31, 31, 29, 27, 33, 32, 31, 31,
+        31, 31, 28, 26, 32, 31, 30, 30, 30, 30, 28, 26, 31, 30, 30, 29, 29, 29,
+        28, 26, 31, 30, 29, 28, 28, 28, 27, 25, 31, 30, 29, 28, 28, 28, 27, 25,
+        31, 30, 29, 28, 28, 28, 27, 25, 31, 30, 29, 28, 28, 28, 27, 25, 31, 30,
+        29, 28, 28, 28, 27, 25, 31, 30, 29, 28, 28, 28, 27, 25, 30, 29, 28, 28,
+        28, 28, 26, 24,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67, 67,
-        67, 67, 67, 66, 65, 63, 62, 61, 61, 61, 61, 61, 61, 59, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 65,
-        63, 62, 60, 59, 59, 59, 59, 59, 59, 59, 66, 66, 66, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 63, 62, 60, 59, 58,
-        58, 58, 58, 58, 58, 57, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 61, 60, 59, 57, 57, 57, 57, 57,
-        57, 56, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 62, 61, 60, 59, 57, 57, 57, 57, 57, 57, 56, 66, 66,
-        66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 62, 61, 60, 59, 57, 57, 57, 57, 57, 57, 56, 62, 62, 61, 61, 60, 60,
-        60, 60, 60, 60, 60, 60, 59, 59, 59, 59, 59, 59, 59, 59, 59, 58, 57, 55,
-        55, 53, 53, 53, 53, 53, 53, 53, 58, 58, 57, 56, 56, 55, 55, 55, 55, 55,
-        55, 55, 55, 55, 54, 54, 54, 54, 54, 54, 54, 53, 52, 51, 51, 49, 49, 49,
-        49, 49, 49, 49 },
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34,
+        34, 34, 34, 33, 33, 32, 31, 31, 31, 31, 31, 31, 31, 30, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        32, 31, 30, 30, 30, 30, 30, 30, 30, 29, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 31, 30, 30, 29,
+        29, 29, 29, 29, 29, 28, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 30, 29, 28, 28, 28, 28, 28,
+        28, 28, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 31, 31, 30, 29, 28, 28, 28, 28, 28, 28, 28, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 31, 31, 30, 29, 28, 28, 28, 28, 28, 28, 28, 31, 31, 31, 31, 30, 30,
+        30, 30, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 29, 28, 28,
+        28, 27, 27, 27, 27, 27, 27, 26, 29, 29, 28, 28, 28, 28, 28, 28, 28, 28,
+        28, 28, 28, 28, 27, 27, 27, 27, 27, 27, 27, 27, 26, 26, 26, 25, 25, 25,
+        25, 25, 25, 24 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        65, 65, 65, 64,
+        33, 33, 33, 32,
 #endif
         /* Size 4x4 */
-        65, 65, 65, 65, 65, 64, 64, 64, 65, 64, 64, 64, 65, 64, 64, 64,
+        33, 33, 33, 33, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32,
         /* Size 8x8 */
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64,
-        64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64,
-        64, 64, 65, 65, 64, 64, 64, 64, 64, 63,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32,
+        32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32,
+        32, 32, 33, 33, 32, 32, 32, 32, 32, 32,
         /* Size 16x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 63, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 65, 65, 65, 65, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 63, 63, 63, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x8 */
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 65, 64, 64, 64, 65, 64,
-        64, 64, 65, 64, 64, 64, 65, 64, 64, 64, 65, 64, 64, 63,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32,
+        32, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32,
         /* Size 8x4 */
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65,
-        64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 63,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33,
+        32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32,
         /* Size 8x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 65, 65, 65, 64,
-        64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64,
-        64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64,
-        65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65,
-        64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64,
-        64, 64, 64, 64, 65, 65, 64, 64, 64, 63, 63, 63, 65, 65, 64, 64, 64, 63,
-        63, 63,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 33, 33, 33, 32,
+        32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32,
+        32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32,
+        33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33,
+        32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32,
+        32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32,
+        32, 32,
         /* Size 16x8 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32,
         /* Size 16x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 63, 63, 63, 63, 63, 63, 63,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 65, 65, 65, 65,
-        65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 65, 65, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 63, 63, 63, 63, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
-        63, 63, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 65, 65,
-        65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 65, 65, 65, 65, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x16 */
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 65, 64,
-        64, 64, 65, 64, 64, 64, 65, 64, 64, 64, 65, 64, 64, 64, 65, 64, 64, 64,
-        65, 64, 64, 64, 65, 64, 64, 64, 65, 64, 64, 64, 65, 64, 64, 64, 65, 64,
-        64, 64, 65, 64, 64, 63, 65, 64, 63, 63,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 33, 32,
+        32, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32,
+        33, 32, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32, 32, 32, 33, 32,
+        32, 32, 33, 32, 32, 32, 33, 32, 32, 32,
         /* Size 16x4 */
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64,
-        64, 64, 65, 65, 65, 64, 64, 64, 64, 64, 65, 65, 65, 64, 64, 64, 64, 64,
-        65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65,
-        64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64,
-        64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64,
-        64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64,
-        65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65,
-        64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64,
-        64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64,
-        64, 64, 65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 64, 64, 64,
-        65, 65, 64, 64, 64, 64, 64, 64, 65, 65, 64, 64, 64, 63, 63, 63, 65, 65,
-        64, 64, 64, 63, 63, 63, 65, 65, 64, 64, 64, 63, 63, 63, 65, 65, 64, 64,
-        64, 63, 63, 63,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32,
+        32, 32, 33, 33, 33, 32, 32, 32, 32, 32, 33, 33, 33, 32, 32, 32, 32, 32,
+        33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33,
+        32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32,
+        32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32,
+        32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32,
+        33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33,
+        32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32,
+        32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32,
+        32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32,
+        33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33,
+        32, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 32, 33, 33, 32, 32,
+        32, 32, 32, 32,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
-        65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 65, 65, 65, 65, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 63, 63, 63, 63, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        63, 63, 63, 63 },
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        65, 66, 66, 65,
+        33, 33, 33, 33,
 #endif
         /* Size 4x4 */
-        65, 66, 66, 66, 66, 65, 65, 65, 66, 65, 65, 65, 66, 65, 65, 65,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
         /* Size 8x8 */
-        65, 65, 65, 66, 66, 66, 66, 67, 65, 65, 65, 65, 65, 66, 66, 66, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 65, 65, 65, 65, 65, 65, 66, 66, 65, 65, 65,
-        65, 65, 65, 66, 66, 66, 65, 65, 65, 65, 65, 65, 66, 66, 66, 65, 65, 65,
-        65, 65, 67, 66, 66, 66, 66, 65, 65, 65,
+        33, 33, 33, 33, 33, 33, 33, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 34, 33, 33, 33, 33, 33, 33, 33,
         /* Size 16x16 */
-        64, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 67, 67, 67, 65, 65,
-        65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 67, 67, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 67, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66,
-        66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 67, 66, 66, 66, 66, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 67, 67, 66, 66, 66, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 67, 67, 67, 66, 66, 66, 66, 66, 66, 66, 66, 65,
-        65, 65, 65, 64,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 34, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 32,
         /* Size 32x32 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66,
-        66, 66, 66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
-        66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
-        66, 67, 67, 67, 67, 67, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66,
-        66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 67, 67,
-        67, 67, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 67, 67, 67, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66,
-        66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66,
-        66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66,
-        66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66,
-        66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66,
-        66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66,
-        66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66,
-        66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66,
-        66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 67, 67, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        67, 67, 67, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 67, 67, 67, 67,
-        66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 67, 67, 67, 67, 67, 66, 66, 66,
-        66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 67, 67, 67, 67, 67, 66, 66, 66, 66, 66, 66, 66,
-        66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        64, 64, 67, 67, 67, 67, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
-        66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 34, 34, 34, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34,
+        34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        34, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        32, 32, 34, 34, 34, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32,
         /* Size 4x8 */
-        65, 65, 66, 66, 65, 65, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 66, 65, 65, 65, 66, 65, 64, 64, 67, 65, 64, 64,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 34, 33, 32, 32,
         /* Size 8x4 */
-        65, 65, 65, 65, 65, 66, 66, 67, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66,
-        65, 65, 65, 65, 64, 64, 66, 66, 65, 65, 65, 65, 64, 64,
+        33, 33, 33, 33, 33, 33, 33, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 32, 32, 33, 33, 33, 33, 33, 33, 32, 32,
         /* Size 8x16 */
-        64, 65, 65, 66, 66, 66, 66, 66, 65, 65, 65, 66, 66, 66, 66, 66, 65, 65,
-        65, 65, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66,
-        65, 65, 65, 65, 65, 65, 66, 66, 65, 65, 65, 64, 64, 64, 66, 66, 66, 65,
-        65, 64, 64, 64, 67, 66, 66, 65, 65, 64, 64, 64, 67, 66, 66, 65, 64, 64,
-        64, 64,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 33, 33, 33, 33,
+        33, 32, 32, 32, 34, 33, 33, 33, 33, 32, 32, 32, 34, 33, 33, 33, 32, 32,
+        32, 32,
         /* Size 16x8 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 67, 67, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 64, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 64, 64, 64, 64, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        64, 64, 64, 64, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64,
-        64, 64,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32,
+        32, 32,
         /* Size 16x32 */
-        64, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65,
-        65, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65,
-        65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 66,
-        66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66,
-        66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65,
-        64, 64, 64, 64, 64, 64, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 64, 64,
-        64, 64, 64, 64, 66, 66, 66, 66, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 66, 66, 66, 66, 66, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64,
-        67, 66, 66, 66, 66, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 67, 66,
-        66, 66, 66, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 67, 67, 66, 66,
-        66, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 67, 67, 66, 66, 66, 65,
-        65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 67, 67, 66, 66, 66, 65, 65, 65,
-        64, 64, 64, 64, 64, 64, 64, 64,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32,
+        32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32,
+        34, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 34, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 34, 34, 33, 33,
+        33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 34, 34, 33, 33, 33, 33,
+        33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 34, 34, 33, 33, 33, 33, 33, 33,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 32x16 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66,
-        66, 66, 66, 66, 66, 66, 66, 67, 67, 67, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66,
-        66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66,
-        66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64,
-        66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 66, 66, 66, 66,
-        66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 66, 66, 66, 66, 66, 66, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 66, 66,
-        66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 66, 66, 66, 66, 66, 66,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 64, 64,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x16 */
-        65, 65, 66, 66, 65, 65, 66, 66, 65, 65, 66, 66, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 66, 65, 65, 65, 66, 65, 65, 64, 66, 65,
-        64, 64, 66, 65, 64, 64, 67, 65, 64, 64,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 33, 33,
+        32, 32, 33, 33, 32, 32, 34, 33, 32, 32,
         /* Size 16x4 */
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 67, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 66, 66, 66, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 64, 64, 64, 64,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 32, 32, 32, 32,
         /* Size 8x32 */
-        64, 65, 65, 66, 66, 66, 66, 66, 65, 65, 65, 66, 66, 66, 66, 66, 65, 65,
-        65, 66, 66, 66, 66, 66, 65, 65, 65, 65, 66, 66, 66, 66, 65, 65, 65, 65,
-        66, 66, 66, 66, 65, 65, 65, 65, 65, 66, 66, 66, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 66, 65, 65, 65, 65, 65, 65, 65, 66, 66, 65, 65,
-        65, 65, 65, 65, 66, 66, 65, 65, 65, 64, 64, 64, 66, 66, 65, 65, 65, 64,
-        64, 64, 66, 66, 65, 65, 65, 64, 64, 64, 66, 66, 66, 65, 65, 64, 64, 64,
-        67, 66, 66, 65, 65, 64, 64, 64, 67, 66, 66, 65, 65, 64, 64, 64, 67, 66,
-        66, 65, 64, 64, 64, 64, 67, 66, 66, 65, 64, 64, 64, 64, 67, 66, 66, 65,
-        64, 64, 64, 64,
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 33, 33, 33, 33, 33, 32,
+        32, 32, 33, 33, 33, 33, 33, 32, 32, 32, 33, 33, 33, 33, 33, 32, 32, 32,
+        34, 33, 33, 33, 33, 32, 32, 32, 34, 33, 33, 33, 33, 32, 32, 32, 34, 33,
+        33, 33, 32, 32, 32, 32, 34, 33, 33, 33, 32, 32, 32, 32, 34, 33, 33, 33,
+        32, 32, 32, 32,
         /* Size 32x8 */
-        64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 66, 66,
-        66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-        65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 64, 64, 66, 66, 66, 66, 66, 66,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65,
-        65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64,
-        64, 64, 64, 64 },
+        32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+        33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32,
+        32, 32, 32, 32 },
   },
   {
       { /* Luma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        64, 64, 64, 64,
+        32, 32, 32, 32,
 #endif
         /* Size 4x4 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 16x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32,
         /* Size 32x32 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x4 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32,
         /* Size 16x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32,
         /* Size 16x32 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 32x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 16x4 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x32 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32,
         /* Size 32x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64 },
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32 },
       { /* Chroma */
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2
         /* Size 2x2 */
-        64, 64, 64, 64,
+        32, 32, 32, 32,
 #endif
         /* Size 4x4 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 16x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32,
         /* Size 32x32 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x4 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32,
         /* Size 16x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32,
         /* Size 16x32 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 32x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 4x16 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 16x4 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
         /* Size 8x32 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32,
         /* Size 32x8 */
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-        64, 64, 64, 64 },
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+        32, 32, 32, 32 },
   },
 };
 #endif
 
 #if CONFIG_PVQ || CONFIG_DAALA_DIST
 /* Quantization matrices for 8x8. For other block sizes, we currently just do
    resampling. */
 /* Flat quantization, i.e. optimize for PSNR. */
--- a/third_party/aom/av1/common/reconinter.c
+++ b/third_party/aom/av1/common/reconinter.c
@@ -155,21 +155,21 @@ static const wedge_code_type wedge_codeb
   { WEDGE_VERTICAL, 2, 4 },   { WEDGE_VERTICAL, 6, 4 },
   { WEDGE_OBLIQUE27, 4, 2 },  { WEDGE_OBLIQUE27, 4, 6 },
   { WEDGE_OBLIQUE153, 4, 2 }, { WEDGE_OBLIQUE153, 4, 6 },
   { WEDGE_OBLIQUE63, 2, 4 },  { WEDGE_OBLIQUE63, 6, 4 },
   { WEDGE_OBLIQUE117, 2, 4 }, { WEDGE_OBLIQUE117, 6, 4 },
 };
 
 const wedge_params_type wedge_params_lookup[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   { 0, NULL, NULL, 0, NULL },
   { 0, NULL, NULL, 0, NULL },
   { 0, NULL, NULL, 0, NULL },
-#endif  // CONFIG_CB4X4
+#endif  // CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   { 0, NULL, NULL, 0, NULL },
   { 0, NULL, NULL, 0, NULL },
   { 0, NULL, NULL, 0, NULL },
 #if CONFIG_WEDGE
   { 4, wedge_codebook_16_heqw, wedge_signflip_lookup[BLOCK_8X8], 0,
     wedge_masks[BLOCK_8X8] },
   { 4, wedge_codebook_16_hgtw, wedge_signflip_lookup[BLOCK_8X16], 0,
     wedge_masks[BLOCK_8X16] },
@@ -705,46 +705,41 @@ void av1_make_masked_inter_predictor(con
                                      int wedge_offset_x, int wedge_offset_y,
 #endif  // CONFIG_SUPERTX
                                      int plane,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
                                      const WarpTypesAllowed *warp_types,
                                      int p_col, int p_row, int ref,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
                                      MACROBLOCKD *xd) {
-  MODE_INFO *mi = xd->mi[0];
+  const MODE_INFO *mi = xd->mi[0];
+
   const INTERINTER_COMPOUND_DATA comp_data = {
 #if CONFIG_WEDGE
     mi->mbmi.wedge_index,
     mi->mbmi.wedge_sign,
 #endif  // CONFIG_WEDGE
 #if CONFIG_COMPOUND_SEGMENT
     mi->mbmi.mask_type,
     xd->seg_mask,
 #endif  // CONFIG_COMPOUND_SEGMENT
     mi->mbmi.interinter_compound_type
   };
-// The prediction filter types used here should be those for
-// the second reference block.
-#if CONFIG_DUAL_FILTER
-  InterpFilter tmp_ipf[4] = {
-    interp_filter[2], interp_filter[3], interp_filter[2], interp_filter[3],
-  };
-#else
-  InterpFilter tmp_ipf = interp_filter;
-#endif  // CONFIG_DUAL_FILTER
-  ConvolveParams conv_params = get_conv_params(0, plane);
+#if !CONFIG_GLOBAL_MOTION && !CONFIG_WARPED_MOTION
+  int ref = 0;
+#endif  // !CONFIG_GLOBAL_MOTION && !CONFIG_WARPED_MOTION
+  ConvolveParams conv_params = get_conv_params(ref, 0, plane);
 
 #if CONFIG_HIGHBITDEPTH
   DECLARE_ALIGNED(16, uint8_t, tmp_dst_[2 * MAX_SB_SQUARE]);
   uint8_t *tmp_dst = (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
                          ? CONVERT_TO_BYTEPTR(tmp_dst_)
                          : tmp_dst_;
   av1_make_inter_predictor(pre, pre_stride, tmp_dst, MAX_SB_SIZE, subpel_x,
-                           subpel_y, sf, w, h, &conv_params, tmp_ipf,
+                           subpel_y, sf, w, h, &conv_params, interp_filter,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
                            warp_types, p_col, p_row, plane, ref,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 #if CONFIG_MOTION_VAR
                            0, 0,
 #endif
                            xs, ys, xd);
 #if CONFIG_COMPOUND_SEGMENT
@@ -777,17 +772,17 @@ void av1_make_masked_inter_predictor(con
   else
     build_masked_compound(dst, dst_stride, dst, dst_stride, tmp_dst,
                           MAX_SB_SIZE, &comp_data, mi->mbmi.sb_type, h, w);
 #endif  // CONFIG_SUPERTX
 
 #else  // CONFIG_HIGHBITDEPTH
   DECLARE_ALIGNED(16, uint8_t, tmp_dst[MAX_SB_SQUARE]);
   av1_make_inter_predictor(pre, pre_stride, tmp_dst, MAX_SB_SIZE, subpel_x,
-                           subpel_y, sf, w, h, &conv_params, tmp_ipf,
+                           subpel_y, sf, w, h, &conv_params, interp_filter,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
                            warp_types, p_col, p_row, plane, ref,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 #if CONFIG_MOTION_VAR
                            0, 0,
 #endif
                            xs, ys, xd);
 #if CONFIG_COMPOUND_SEGMENT
@@ -827,21 +822,24 @@ void av1_highbd_build_inter_predictor(
     const WarpTypesAllowed *warp_types, int p_col, int p_row,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
     int plane, enum mv_precision precision, int x, int y,
     const MACROBLOCKD *xd) {
   const int is_q4 = precision == MV_PRECISION_Q4;
   const MV mv_q4 = { is_q4 ? src_mv->row : src_mv->row * 2,
                      is_q4 ? src_mv->col : src_mv->col * 2 };
   MV32 mv = av1_scale_mv(&mv_q4, x, y, sf);
-  const int subpel_x = mv.col & SUBPEL_MASK;
-  const int subpel_y = mv.row & SUBPEL_MASK;
-  ConvolveParams conv_params = get_conv_params(ref, plane);
+  mv.col += SCALE_EXTRA_OFF;
+  mv.row += SCALE_EXTRA_OFF;
+  const int subpel_x = mv.col & SCALE_SUBPEL_MASK;
+  const int subpel_y = mv.row & SCALE_SUBPEL_MASK;
+  ConvolveParams conv_params = get_conv_params(ref, ref, plane);
 
-  src += (mv.row >> SUBPEL_BITS) * src_stride + (mv.col >> SUBPEL_BITS);
+  src += (mv.row >> SCALE_SUBPEL_BITS) * src_stride +
+         (mv.col >> SCALE_SUBPEL_BITS);
 
   av1_make_inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y,
                            sf, w, h, &conv_params, interp_filter,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
                            warp_types, p_col, p_row, plane, ref,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 #if CONFIG_MOTION_VAR
                            0, 0,
@@ -864,20 +862,23 @@ void av1_build_inter_predictor(const uin
                                int p_row, int plane, int ref,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
                                enum mv_precision precision, int x, int y,
                                const MACROBLOCKD *xd) {
   const int is_q4 = precision == MV_PRECISION_Q4;
   const MV mv_q4 = { is_q4 ? src_mv->row : src_mv->row * 2,
                      is_q4 ? src_mv->col : src_mv->col * 2 };
   MV32 mv = av1_scale_mv(&mv_q4, x, y, sf);
-  const int subpel_x = mv.col & SUBPEL_MASK;
-  const int subpel_y = mv.row & SUBPEL_MASK;
+  mv.col += SCALE_EXTRA_OFF;
+  mv.row += SCALE_EXTRA_OFF;
+  const int subpel_x = mv.col & SCALE_SUBPEL_MASK;
+  const int subpel_y = mv.row & SCALE_SUBPEL_MASK;
 
-  src += (mv.row >> SUBPEL_BITS) * src_stride + (mv.col >> SUBPEL_BITS);
+  src += (mv.row >> SCALE_SUBPEL_BITS) * src_stride +
+         (mv.col >> SCALE_SUBPEL_BITS);
 
   av1_make_inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y,
                            sf, w, h, conv_params, interp_filter,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
                            warp_types, p_col, p_row, plane, ref,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 #if CONFIG_MOTION_VAR
                            0, 0,
@@ -904,27 +905,34 @@ void build_inter_predictors(const AV1_CO
                             int mi_x, int mi_y) {
   struct macroblockd_plane *const pd = &xd->plane[plane];
 #if CONFIG_MOTION_VAR
   const MODE_INFO *mi = xd->mi[mi_col_offset + xd->mi_stride * mi_row_offset];
 #else
   const MODE_INFO *mi = xd->mi[0];
 #endif  // CONFIG_MOTION_VAR
   int is_compound = has_second_ref(&mi->mbmi);
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  int is_comp_mode_pred =
+      is_compound || is_inter_singleref_comp_mode(mi->mbmi.mode);
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   int ref;
 #if CONFIG_INTRABC
   const int is_intrabc = is_intrabc_block(&mi->mbmi);
   assert(IMPLIES(is_intrabc, !is_compound));
 #endif  // CONFIG_INTRABC
 #if CONFIG_GLOBAL_MOTION
   int is_global[2] = { 0, 0 };
   for (ref = 0; ref < 1 + is_compound; ++ref) {
     WarpedMotionParams *const wm = &xd->global_motion[mi->mbmi.ref_frame[ref]];
     is_global[ref] = is_global_mv_block(mi, block, wm->wmtype);
   }
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  if (!is_compound && is_comp_mode_pred) is_global[1] = is_global[0];
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 #endif  // CONFIG_GLOBAL_MOTION
 
 #if CONFIG_CB4X4
   (void)block;
   (void)cm;
 #endif
 
 #if CONFIG_MOTION_VAR && (CONFIG_CHROMA_SUB8X8 || !CONFIG_CB4X4)
@@ -969,17 +977,18 @@ void build_inter_predictors(const AV1_CO
     const struct buf_2d orig_pred_buf[2] = { pd->pre[0], pd->pre[1] };
 
     int row = row_start;
     for (idy = 0; idy < b8_h; idy += b4_h) {
       int col = col_start;
       for (idx = 0; idx < b8_w; idx += b4_w) {
         MB_MODE_INFO *this_mbmi = &xd->mi[row * xd->mi_stride + col]->mbmi;
         is_compound = has_second_ref(this_mbmi);
-
+        // TODO(zoeliu): If single ref comp modes are considered here, a
+        //               mismatch was caused. Need a further investigation.
         for (ref = 0; ref < 1 + is_compound; ++ref) {
           struct buf_2d *const dst_buf = &pd->dst;
 
           const RefBuffer *ref_buf =
               &cm->frame_refs[this_mbmi->ref_frame[ref] - LAST_FRAME];
 
           const int c_offset = (mi_x + MI_SIZE * col_start) >> ss_x;
           const int r_offset = (mi_y + MI_SIZE * row_start) >> ss_y;
@@ -990,33 +999,30 @@ void build_inter_predictors(const AV1_CO
                                                        ref_buf->buf->uv_stride,
                                                        &ref_buf->sf);
           pd->pre[ref].width = ref_buf->buf->uv_crop_width;
           pd->pre[ref].height = ref_buf->buf->uv_crop_height;
           pd->pre[ref].stride = ref_buf->buf->uv_stride;
 
 #if CONFIG_INTRABC
           const struct scale_factors *const sf =
-              is_intrabc ? &xd->sf_identity : &xd->block_refs[ref]->sf;
+              is_intrabc ? &xd->sf_identity : &ref_buf->sf;
           struct buf_2d *const pre_buf = is_intrabc ? dst_buf : &pd->pre[ref];
 #else
-          const struct scale_factors *const sf = &xd->block_refs[ref]->sf;
+          const struct scale_factors *const sf = &ref_buf->sf;
           struct buf_2d *const pre_buf = &pd->pre[ref];
 #endif  // CONFIG_INTRABC
           uint8_t *dst = dst_buf->buf;
 
           const MV mv = this_mbmi->mv[ref].as_mv;
 
-          const MV mv_q4 = clamp_mv_to_umv_border_sb(
-              xd, &mv, bw, bh, pd->subsampling_x, pd->subsampling_y);
           uint8_t *pre;
-          MV32 scaled_mv;
           int xs, ys, subpel_x, subpel_y;
           const int is_scaled = av1_is_scaled(sf);
-          ConvolveParams conv_params = get_conv_params(ref, plane);
+          ConvolveParams conv_params = get_conv_params(ref, ref, plane);
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
           WarpTypesAllowed warp_types;
 #if CONFIG_GLOBAL_MOTION
           warp_types.global_warp_allowed = is_global[ref];
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_WARPED_MOTION
           warp_types.local_warp_allowed =
               this_mbmi->motion_mode == WARPED_CAUSAL;
@@ -1024,33 +1030,54 @@ void build_inter_predictors(const AV1_CO
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 
           x = x_base + idx;
           y = y_base + idy;
 
           dst += dst_buf->stride * y + x;
 
           if (is_scaled) {
-            pre =
-                pre_buf->buf + scaled_buffer_offset(x, y, pre_buf->stride, sf);
-            scaled_mv = av1_scale_mv(&mv_q4, mi_x + x, mi_y + y, sf);
+            int ssx = pd->subsampling_x;
+            int ssy = pd->subsampling_y;
+            int orig_pos_y = (mi_y << (SUBPEL_BITS - ssy)) + (y << SUBPEL_BITS);
+            orig_pos_y += mv.row * (1 << (1 - ssy));
+            int orig_pos_x = (mi_x << (SUBPEL_BITS - ssx)) + (x << SUBPEL_BITS);
+            orig_pos_x += mv.col * (1 << (1 - ssx));
+            int pos_y = sf->scale_value_y(orig_pos_y, sf);
+            int pos_x = sf->scale_value_x(orig_pos_x, sf);
+            pos_x += SCALE_EXTRA_OFF;
+            pos_y += SCALE_EXTRA_OFF;
+
+            const int top = -((AOM_INTERP_EXTEND + bh) << SCALE_SUBPEL_BITS);
+            const int bottom = (pre_buf->height + AOM_INTERP_EXTEND)
+                               << SCALE_SUBPEL_BITS;
+            const int left = -((AOM_INTERP_EXTEND + bw) << SCALE_SUBPEL_BITS);
+            const int right = (pre_buf->width + AOM_INTERP_EXTEND)
+                              << SCALE_SUBPEL_BITS;
+            pos_y = clamp(pos_y, top, bottom);
+            pos_x = clamp(pos_x, left, right);
+
+            pre = pre_buf->buf0 +
+                  (pos_y >> SCALE_SUBPEL_BITS) * pre_buf->stride +
+                  (pos_x >> SCALE_SUBPEL_BITS);
+            subpel_x = pos_x & SCALE_SUBPEL_MASK;
+            subpel_y = pos_y & SCALE_SUBPEL_MASK;
             xs = sf->x_step_q4;
             ys = sf->y_step_q4;
           } else {
-            pre = pre_buf->buf + y * pre_buf->stride + x;
-            scaled_mv.row = mv_q4.row;
-            scaled_mv.col = mv_q4.col;
-            xs = ys = 16;
+            const MV mv_q4 = clamp_mv_to_umv_border_sb(
+                xd, &mv, bw, bh, pd->subsampling_x, pd->subsampling_y);
+            xs = ys = SCALE_SUBPEL_SHIFTS;
+            subpel_x = (mv_q4.col & SUBPEL_MASK) << SCALE_EXTRA_BITS;
+            subpel_y = (mv_q4.row & SUBPEL_MASK) << SCALE_EXTRA_BITS;
+            pre = pre_buf->buf +
+                  (y + (mv_q4.row >> SUBPEL_BITS)) * pre_buf->stride +
+                  (x + (mv_q4.col >> SUBPEL_BITS));
           }
 
-          subpel_x = scaled_mv.col & SUBPEL_MASK;
-          subpel_y = scaled_mv.row & SUBPEL_MASK;
-          pre += (scaled_mv.row >> SUBPEL_BITS) * pre_buf->stride +
-                 (scaled_mv.col >> SUBPEL_BITS);
-
 #if CONFIG_EXT_INTER
           if (ref && is_masked_compound_type(mi->mbmi.interinter_compound_type))
             av1_make_masked_inter_predictor(
                 pre, pre_buf->stride, dst, dst_buf->stride, subpel_x, subpel_y,
                 sf, w, h, mi->mbmi.interp_filter, xs, ys,
 #if CONFIG_SUPERTX
                 wedge_offset_x, wedge_offset_y,
 #endif  // CONFIG_SUPERTX
@@ -1066,17 +1093,17 @@ void build_inter_predictors(const AV1_CO
                 pre, pre_buf->stride, dst, dst_buf->stride, subpel_x, subpel_y,
                 sf, b4_w, b4_h, &conv_params, this_mbmi->interp_filter,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
                 &warp_types, (mi_x >> pd->subsampling_x) + x,
                 (mi_y >> pd->subsampling_y) + y, plane, ref,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 #if CONFIG_MOTION_VAR
                 mi_col_offset, mi_row_offset,
-#endif
+#endif  // CONFIG_MOTION_VAR
                 xs, ys, xd);
         }
         ++col;
       }
       ++row;
     }
 
     for (ref = 0; ref < 2; ++ref) pd->pre[ref] = orig_pred_buf[ref];
@@ -1085,24 +1112,27 @@ void build_inter_predictors(const AV1_CO
 #else
   (void)cm;
 #endif  // CONFIG_CHROMA_SUB8X8
 
   {
     struct buf_2d *const dst_buf = &pd->dst;
     uint8_t *const dst = dst_buf->buf + dst_buf->stride * y + x;
     uint8_t *pre[2];
-    MV32 scaled_mv[2];
     SubpelParams subpel_params[2];
 #if CONFIG_CONVOLVE_ROUND
     DECLARE_ALIGNED(16, int32_t, tmp_dst[MAX_SB_SIZE * MAX_SB_SIZE]);
     av1_zero(tmp_dst);
 #endif  // CONFIG_CONVOLVE_ROUND
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    for (ref = 0; ref < 1 + is_comp_mode_pred; ++ref) {
+#else
     for (ref = 0; ref < 1 + is_compound; ++ref) {
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_INTRABC
       const struct scale_factors *const sf =
           is_intrabc ? &xd->sf_identity : &xd->block_refs[ref]->sf;
       struct buf_2d *const pre_buf = is_intrabc ? dst_buf : &pd->pre[ref];
 #else
       const struct scale_factors *const sf = &xd->block_refs[ref]->sf;
       struct buf_2d *const pre_buf = &pd->pre[ref];
 #endif  // CONFIG_INTRABC
@@ -1115,52 +1145,80 @@ void build_inter_predictors(const AV1_CO
               ?
 #else
           mi->mbmi.sb_type < BLOCK_8X8 ?
 #endif
               average_split_mvs(pd, mi, ref, block)
               : mi->mbmi.mv[ref].as_mv;
 #endif
 
-      // TODO(jkoleszar): This clamping is done in the incorrect place for the
-      // scaling case. It needs to be done on the scaled MV, not the pre-scaling
-      // MV. Note however that it performs the subsampling aware scaling so
-      // that the result is always q4.
-      // mv_precision precision is MV_PRECISION_Q4.
-      const MV mv_q4 = clamp_mv_to_umv_border_sb(
-          xd, &mv, bw, bh, pd->subsampling_x, pd->subsampling_y);
-
       const int is_scaled = av1_is_scaled(sf);
       if (is_scaled) {
-        pre[ref] =
-            pre_buf->buf + scaled_buffer_offset(x, y, pre_buf->stride, sf);
-        scaled_mv[ref] = av1_scale_mv(&mv_q4, mi_x + x, mi_y + y, sf);
+        // Note: The various inputs here have different units:
+        // * mi_x/mi_y are in units of luma pixels
+        // * mv is in units of 1/8 luma pixels
+        // * x/y are in units of pixels *in the current plane*
+        // Here we unify these into a q4-format position within the current
+        // plane, then project into the reference frame
+        int ssx = pd->subsampling_x;
+        int ssy = pd->subsampling_y;
+        int orig_pos_y = (mi_y << (SUBPEL_BITS - ssy)) + (y << SUBPEL_BITS);
+        orig_pos_y += mv.row * (1 << (1 - ssy));
+        int orig_pos_x = (mi_x << (SUBPEL_BITS - ssx)) + (x << SUBPEL_BITS);
+        orig_pos_x += mv.col * (1 << (1 - ssx));
+        int pos_y = sf->scale_value_y(orig_pos_y, sf);
+        int pos_x = sf->scale_value_x(orig_pos_x, sf);
+        pos_x += SCALE_EXTRA_OFF;
+        pos_y += SCALE_EXTRA_OFF;
+
+        // Clamp against the reference frame borders, with enough extension
+        // that we don't force the reference block to be partially onscreen.
+        const int top = -((AOM_INTERP_EXTEND + bh) << SCALE_SUBPEL_BITS);
+        const int bottom = (pre_buf->height + AOM_INTERP_EXTEND)
+                           << SCALE_SUBPEL_BITS;
+        const int left = -((AOM_INTERP_EXTEND + bw) << SCALE_SUBPEL_BITS);
+        const int right = (pre_buf->width + AOM_INTERP_EXTEND)
+                          << SCALE_SUBPEL_BITS;
+        pos_y = clamp(pos_y, top, bottom);
+        pos_x = clamp(pos_x, left, right);
+
+        pre[ref] = pre_buf->buf0 +
+                   (pos_y >> SCALE_SUBPEL_BITS) * pre_buf->stride +
+                   (pos_x >> SCALE_SUBPEL_BITS);
+        subpel_params[ref].subpel_x = pos_x & SCALE_SUBPEL_MASK;
+        subpel_params[ref].subpel_y = pos_y & SCALE_SUBPEL_MASK;
         subpel_params[ref].xs = sf->x_step_q4;
         subpel_params[ref].ys = sf->y_step_q4;
       } else {
-        pre[ref] = pre_buf->buf + (y * pre_buf->stride + x);
-        scaled_mv[ref].row = mv_q4.row;
-        scaled_mv[ref].col = mv_q4.col;
-        subpel_params[ref].xs = 16;
-        subpel_params[ref].ys = 16;
+        const MV mv_q4 = clamp_mv_to_umv_border_sb(
+            xd, &mv, bw, bh, pd->subsampling_x, pd->subsampling_y);
+        subpel_params[ref].subpel_x = (mv_q4.col & SUBPEL_MASK)
+                                      << SCALE_EXTRA_BITS;
+        subpel_params[ref].subpel_y = (mv_q4.row & SUBPEL_MASK)
+                                      << SCALE_EXTRA_BITS;
+        subpel_params[ref].xs = SCALE_SUBPEL_SHIFTS;
+        subpel_params[ref].ys = SCALE_SUBPEL_SHIFTS;
+        pre[ref] = pre_buf->buf +
+                   (y + (mv_q4.row >> SUBPEL_BITS)) * pre_buf->stride +
+                   (x + (mv_q4.col >> SUBPEL_BITS));
       }
-
-      subpel_params[ref].subpel_x = scaled_mv[ref].col & SUBPEL_MASK;
-      subpel_params[ref].subpel_y = scaled_mv[ref].row & SUBPEL_MASK;
-      pre[ref] += (scaled_mv[ref].row >> SUBPEL_BITS) * pre_buf->stride +
-                  (scaled_mv[ref].col >> SUBPEL_BITS);
     }
 
 #if CONFIG_CONVOLVE_ROUND
     ConvolveParams conv_params =
-        get_conv_params_no_round(ref, plane, tmp_dst, MAX_SB_SIZE);
+        get_conv_params_no_round(ref, ref, plane, tmp_dst, MAX_SB_SIZE);
 #else
-    ConvolveParams conv_params = get_conv_params(ref, plane);
+    ConvolveParams conv_params = get_conv_params(ref, ref, plane);
 #endif  // CONFIG_CONVOLVE_ROUND
+
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    for (ref = 0; ref < 1 + is_comp_mode_pred; ++ref) {
+#else
     for (ref = 0; ref < 1 + is_compound; ++ref) {
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_INTRABC
       const struct scale_factors *const sf =
           is_intrabc ? &xd->sf_identity : &xd->block_refs[ref]->sf;
       struct buf_2d *const pre_buf = is_intrabc ? dst_buf : &pd->pre[ref];
 #else
       const struct scale_factors *const sf = &xd->block_refs[ref]->sf;
       struct buf_2d *const pre_buf = &pd->pre[ref];
 #endif  // CONFIG_INTRABC
@@ -1169,16 +1227,17 @@ void build_inter_predictors(const AV1_CO
 #if CONFIG_GLOBAL_MOTION
       warp_types.global_warp_allowed = is_global[ref];
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_WARPED_MOTION
       warp_types.local_warp_allowed = mi->mbmi.motion_mode == WARPED_CAUSAL;
 #endif  // CONFIG_WARPED_MOTION
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
       conv_params.ref = ref;
+      conv_params.do_average = ref;
 #if CONFIG_EXT_INTER
       if (ref && is_masked_compound_type(mi->mbmi.interinter_compound_type))
         av1_make_masked_inter_predictor(
             pre[ref], pre_buf->stride, dst, dst_buf->stride,
             subpel_params[ref].subpel_x, subpel_params[ref].subpel_y, sf, w, h,
             mi->mbmi.interp_filter, subpel_params[ref].xs,
             subpel_params[ref].ys,
 #if CONFIG_SUPERTX
@@ -1197,40 +1256,47 @@ void build_inter_predictors(const AV1_CO
             subpel_params[ref].subpel_x, subpel_params[ref].subpel_y, sf, w, h,
             &conv_params, mi->mbmi.interp_filter,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
             &warp_types, (mi_x >> pd->subsampling_x) + x,
             (mi_y >> pd->subsampling_y) + y, plane, ref,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 #if CONFIG_MOTION_VAR
             mi_col_offset, mi_row_offset,
-#endif
+#endif  // CONFIG_MOTION_VAR
             subpel_params[ref].xs, subpel_params[ref].ys, xd);
     }
 
 #if CONFIG_CONVOLVE_ROUND
     // TODO(angiebird): This part needs optimization
     if (conv_params.do_post_rounding) {
 #if CONFIG_HIGHBITDEPTH
       if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
         av1_highbd_convolve_rounding(tmp_dst, MAX_SB_SIZE, dst, dst_buf->stride,
                                      w, h, FILTER_BITS * 2 + is_compound -
                                                conv_params.round_0 -
                                                conv_params.round_1,
                                      xd->bd);
       else
 #endif  // CONFIG_HIGHBITDEPTH
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
         av1_convolve_rounding(tmp_dst, MAX_SB_SIZE, dst, dst_buf->stride, w, h,
-                              FILTER_BITS * 2 + is_compound -
+                              FILTER_BITS * 2 + is_comp_mode_pred -
                                   conv_params.round_0 - conv_params.round_1);
+#else   // !(CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF)
+      av1_convolve_rounding(tmp_dst, MAX_SB_SIZE, dst, dst_buf->stride, w, h,
+                            FILTER_BITS * 2 + is_compound -
+                                conv_params.round_0 - conv_params.round_1);
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
     }
 #endif  // CONFIG_CONVOLVE_ROUND
   }
 }
 
+#if 0
 void av1_build_inter_predictor_sub8x8(const AV1_COMMON *cm, MACROBLOCKD *xd,
                                       int plane, int i, int ir, int ic,
                                       int mi_row, int mi_col) {
   struct macroblockd_plane *const pd = &xd->plane[plane];
   MODE_INFO *const mi = xd->mi[0];
   const BLOCK_SIZE plane_bsize = get_plane_block_size(mi->mbmi.sb_type, pd);
   const int width = block_size_wide[plane_bsize];
   const int height = block_size_high[plane_bsize];
@@ -1248,17 +1314,17 @@ void av1_build_inter_predictor_sub8x8(co
   for (ref = 0; ref < 1 + is_compound; ++ref) {
     WarpedMotionParams *const wm = &xd->global_motion[mi->mbmi.ref_frame[ref]];
     is_global[ref] = is_global_mv_block(mi, i, wm->wmtype);
   }
 #endif  // CONFIG_GLOBAL_MOTION
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 
   for (ref = 0; ref < 1 + is_compound; ++ref) {
-    ConvolveParams conv_params = get_conv_params(ref, plane);
+    ConvolveParams conv_params = get_conv_params(ref, ref, plane);
     const uint8_t *pre =
         &pd->pre[ref].buf[(ir * pd->pre[ref].stride + ic) << 2];
 #if CONFIG_GLOBAL_MOTION
     warp_types.global_warp_allowed = is_global[ref];
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_WARPED_MOTION
     warp_types.local_warp_allowed = mi->mbmi.motion_mode == WARPED_CAUSAL;
 #endif  // CONFIG_WARPED_MOTION
@@ -1282,16 +1348,17 @@ void av1_build_inter_predictor_sub8x8(co
                                 &conv_params, mi->mbmi.interp_filter,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
                                 &warp_types, p_col, p_row, plane, ref,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
                                 MV_PRECISION_Q3, mi_col * MI_SIZE + 4 * ic,
                                 mi_row * MI_SIZE + 4 * ir, xd);
   }
 }
+#endif
 
 static void build_inter_predictors_for_planes(const AV1_COMMON *cm,
                                               MACROBLOCKD *xd, BLOCK_SIZE bsize,
                                               int mi_row, int mi_col,
                                               int plane_from, int plane_to) {
   int plane;
   const int mi_x = mi_col * MI_SIZE;
   const int mi_y = mi_row * MI_SIZE;
@@ -1580,101 +1647,83 @@ void av1_build_masked_inter_predictor_co
 
   do {
     memcpy(dst, pre, w_remain * sizeof(uint8_t));
     dst += dst_stride;
     pre += pre_stride;
   } while (--h_remain);
 }
 
-void av1_build_inter_predictors_sb_sub8x8_extend(const AV1_COMMON *cm,
-                                                 MACROBLOCKD *xd,
+void av1_build_inter_predictor_sb_sub8x8_extend(const AV1_COMMON *cm,
+                                                MACROBLOCKD *xd,
 #if CONFIG_EXT_INTER
-                                                 int mi_row_ori, int mi_col_ori,
+                                                int mi_row_ori, int mi_col_ori,
 #endif  // CONFIG_EXT_INTER
-                                                 int mi_row, int mi_col,
-                                                 BLOCK_SIZE bsize, int block) {
+                                                int mi_row, int mi_col,
+                                                int plane, BLOCK_SIZE bsize,
+                                                int block) {
   // Prediction function used in supertx:
   // Use the mv at current block (which is less than 8x8)
   // to get prediction of a block located at (mi_row, mi_col) at size of bsize
   // bsize can be larger than 8x8.
   // block (0-3): the sub8x8 location of current block
-  int plane;
   const int mi_x = mi_col * MI_SIZE;
   const int mi_y = mi_row * MI_SIZE;
 #if CONFIG_EXT_INTER
   const int wedge_offset_x = (mi_col_ori - mi_col) * MI_SIZE;
   const int wedge_offset_y = (mi_row_ori - mi_row) * MI_SIZE;
 #endif  // CONFIG_EXT_INTER
 
   // For sub8x8 uv:
   // Skip uv prediction in supertx except the first block (block = 0)
   int max_plane = block ? 1 : MAX_MB_PLANE;
+  if (plane >= max_plane) return;
 
-  for (plane = 0; plane < max_plane; plane++) {
-    const BLOCK_SIZE plane_bsize =
-        get_plane_block_size(bsize, &xd->plane[plane]);
-    const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize];
-    const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize];
-    const int bw = 4 * num_4x4_w;
-    const int bh = 4 * num_4x4_h;
+  const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, &xd->plane[plane]);
+  const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize];
+  const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize];
+  const int bw = 4 * num_4x4_w;
+  const int bh = 4 * num_4x4_h;
 
-    build_inter_predictors(cm, xd, plane,
+  build_inter_predictors(cm, xd, plane,
 #if CONFIG_MOTION_VAR
-                           0, 0,
+                         0, 0,
 #endif  // CONFIG_MOTION_VAR
-                           block, bw, bh, 0, 0, bw, bh,
+                         block, bw, bh, 0, 0, bw, bh,
 #if CONFIG_EXT_INTER
-                           wedge_offset_x, wedge_offset_y,
+                         wedge_offset_x, wedge_offset_y,
 #endif  // CONFIG_EXT_INTER
-                           mi_x, mi_y);
-  }
-#if CONFIG_EXT_INTER
-  if (is_interintra_pred(&xd->mi[0]->mbmi)) {
-    BUFFER_SET ctx = { { xd->plane[0].dst.buf, xd->plane[1].dst.buf,
-                         xd->plane[2].dst.buf },
-                       { xd->plane[0].dst.stride, xd->plane[1].dst.stride,
-                         xd->plane[2].dst.stride } };
-    av1_build_interintra_predictors(
-        xd, xd->plane[0].dst.buf, xd->plane[1].dst.buf, xd->plane[2].dst.buf,
-        xd->plane[0].dst.stride, xd->plane[1].dst.stride,
-        xd->plane[2].dst.stride, &ctx, bsize);
-  }
-#endif  // CONFIG_EXT_INTER
+                         mi_x, mi_y);
 }
 
-void av1_build_inter_predictors_sb_extend(const AV1_COMMON *cm, MACROBLOCKD *xd,
+void av1_build_inter_predictor_sb_extend(const AV1_COMMON *cm, MACROBLOCKD *xd,
 #if CONFIG_EXT_INTER
-                                          int mi_row_ori, int mi_col_ori,
+                                         int mi_row_ori, int mi_col_ori,
 #endif  // CONFIG_EXT_INTER
-                                          int mi_row, int mi_col,
-                                          BLOCK_SIZE bsize) {
-  int plane;
+                                         int mi_row, int mi_col, int plane,
+                                         BLOCK_SIZE bsize) {
   const int mi_x = mi_col * MI_SIZE;
   const int mi_y = mi_row * MI_SIZE;
 #if CONFIG_EXT_INTER
   const int wedge_offset_x = (mi_col_ori - mi_col) * MI_SIZE;
   const int wedge_offset_y = (mi_row_ori - mi_row) * MI_SIZE;
 #endif  // CONFIG_EXT_INTER
-  for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
-    const BLOCK_SIZE plane_bsize =
-        get_plane_block_size(bsize, &xd->plane[plane]);
-    const int bw = block_size_wide[plane_bsize];
-    const int bh = block_size_high[plane_bsize];
+  const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, &xd->plane[plane]);
+  const int bw = block_size_wide[plane_bsize];
+  const int bh = block_size_high[plane_bsize];
 
-    build_inter_predictors(cm, xd, plane,
+  build_inter_predictors(cm, xd, plane,
 #if CONFIG_MOTION_VAR
-                           0, 0,
+                         0, 0,
 #endif  // CONFIG_MOTION_VAR
-                           0, bw, bh, 0, 0, bw, bh,
+                         0, bw, bh, 0, 0, bw, bh,
 #if CONFIG_EXT_INTER
-                           wedge_offset_x, wedge_offset_y,
+                         wedge_offset_x, wedge_offset_y,
 #endif  // CONFIG_EXT_INTER
-                           mi_x, mi_y);
-  }
+                         mi_x, mi_y);
 }
 #endif  // CONFIG_SUPERTX
 
 #if CONFIG_MOTION_VAR
 // obmc_mask_N[overlap_position]
 static const uint8_t obmc_mask_1[1] = { 64 };
 
 static const uint8_t obmc_mask_2[2] = { 45, 64 };
@@ -1823,17 +1872,17 @@ void av1_count_overlappable_neighbors(co
 #define DISABLE_CHROMA_U8X8_OBMC 0  // 0: one-sided obmc; 1: disable
 
 int skip_u4x4_pred_in_obmc(BLOCK_SIZE bsize, const struct macroblockd_plane *pd,
                            int dir) {
   assert(is_motion_variation_allowed_bsize(bsize));
 
   BLOCK_SIZE bsize_plane =
       ss_size_lookup[bsize][pd->subsampling_x][pd->subsampling_y];
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   if (bsize_plane < BLOCK_4X4) return 1;
 #endif
   switch (bsize_plane) {
 #if DISABLE_CHROMA_U8X8_OBMC
     case BLOCK_4X4:
     case BLOCK_8X4:
     case BLOCK_4X8: return 1; break;
 #else
@@ -1980,16 +2029,24 @@ void av1_build_obmc_inter_prediction(con
 void modify_neighbor_predictor_for_obmc(MB_MODE_INFO *mbmi) {
 #if CONFIG_EXT_INTER
   if (is_interintra_pred(mbmi)) {
     mbmi->ref_frame[1] = NONE_FRAME;
   } else if (has_second_ref(mbmi) &&
              is_masked_compound_type(mbmi->interinter_compound_type)) {
     mbmi->interinter_compound_type = COMPOUND_AVERAGE;
     mbmi->ref_frame[1] = NONE_FRAME;
+#if CONFIG_COMPOUND_SINGLEREF
+  } else if (!has_second_ref(mbmi) &&
+             is_inter_singleref_comp_mode(mbmi->mode)) {
+    // mbmi->mode = compound_ref0_mode(mbmi->mode);
+    mbmi->mode = compound_ref1_mode(mbmi->mode);
+    assert(is_inter_singleref_mode(mbmi->mode));
+    mbmi->mv[0].as_int = mbmi->mv[1].as_int;
+#endif  // CONFIG_COMPOUND_SINGLEREF
   }
 #endif  // CONFIG_EXT_INTER
   if (has_second_ref(mbmi)) mbmi->ref_frame[1] = NONE_FRAME;
   return;
 }
 
 void av1_build_prediction_by_above_preds(const AV1_COMMON *cm, MACROBLOCKD *xd,
                                          int mi_row, int mi_col,
@@ -2036,18 +2093,26 @@ void av1_build_prediction_by_above_preds
     modify_neighbor_predictor_for_obmc(above_mbmi);
 
     for (j = 0; j < MAX_MB_PLANE; ++j) {
       struct macroblockd_plane *const pd = &xd->plane[j];
       setup_pred_plane(&pd->dst, a_bsize, tmp_buf[j], tmp_width[j],
                        tmp_height[j], tmp_stride[j], 0, i, NULL,
                        pd->subsampling_x, pd->subsampling_y);
     }
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    for (ref = 0; ref < 1 + (is_inter_anyref_comp_mode(above_mbmi->mode));
+         ++ref) {
+      const MV_REFERENCE_FRAME frame = has_second_ref(above_mbmi)
+                                           ? above_mbmi->ref_frame[ref]
+                                           : above_mbmi->ref_frame[0];
+#else   // !(CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF)
     for (ref = 0; ref < 1 + has_second_ref(above_mbmi); ++ref) {
       const MV_REFERENCE_FRAME frame = above_mbmi->ref_frame[ref];
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
       const RefBuffer *const ref_buf = &cm->frame_refs[frame - LAST_FRAME];
 
       xd->block_refs[ref] = ref_buf;
       if ((!av1_is_valid_scale(&ref_buf->sf)))
         aom_internal_error(xd->error_info, AOM_CODEC_UNSUP_BITSTREAM,
                            "Reference frame has invalid dimensions");
       av1_setup_pre_planes(xd, ref, ref_buf->buf, mi_row, mi_col + i,
                            &ref_buf->sf);
@@ -2125,18 +2190,26 @@ void av1_build_prediction_by_left_preds(
     modify_neighbor_predictor_for_obmc(left_mbmi);
 
     for (j = 0; j < MAX_MB_PLANE; ++j) {
       struct macroblockd_plane *const pd = &xd->plane[j];
       setup_pred_plane(&pd->dst, l_bsize, tmp_buf[j], tmp_width[j],
                        tmp_height[j], tmp_stride[j], i, 0, NULL,
                        pd->subsampling_x, pd->subsampling_y);
     }
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    for (ref = 0; ref < 1 + (is_inter_anyref_comp_mode(left_mbmi->mode));
+         ++ref) {
+      const MV_REFERENCE_FRAME frame = has_second_ref(left_mbmi)
+                                           ? left_mbmi->ref_frame[ref]
+                                           : left_mbmi->ref_frame[0];
+#else   // !(CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF)
     for (ref = 0; ref < 1 + has_second_ref(left_mbmi); ++ref) {
       const MV_REFERENCE_FRAME frame = left_mbmi->ref_frame[ref];
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
       const RefBuffer *const ref_buf = &cm->frame_refs[frame - LAST_FRAME];
 
       xd->block_refs[ref] = ref_buf;
       if ((!av1_is_valid_scale(&ref_buf->sf)))
         aom_internal_error(xd->error_info, AOM_CODEC_UNSUP_BITSTREAM,
                            "Reference frame has invalid dimensions");
       av1_setup_pre_planes(xd, ref, ref_buf->buf, mi_row + i, mi_col,
                            &ref_buf->sf);
@@ -2579,16 +2652,17 @@ void av1_build_ncobmc_inter_predictors_s
     dst_buf2[0] = tmp_buf2;
     dst_buf2[1] = tmp_buf2 + MAX_SB_SQUARE;
     dst_buf2[2] = tmp_buf2 + MAX_SB_SQUARE * 2;
 #if CONFIG_HIGHBITDEPTH
   }
 #endif  // CONFIG_HIGHBITDEPTH
 
   const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type;
+  // TODO(zoeliu): COMPOUND_SINGLEREF has not worked with NCOBMC yet.
   av1_build_prediction_by_bottom_preds(cm, xd, mi_row, mi_col, dst_buf1,
                                        dst_width1, dst_height1, dst_stride1);
   av1_build_prediction_by_right_preds(cm, xd, mi_row, mi_col, dst_buf2,
                                       dst_width2, dst_height2, dst_stride2);
   av1_setup_dst_planes(xd->plane, bsize, get_frame_new_buffer(cm), mi_row,
                        mi_col);
   av1_merge_dst_bottom_right_preds(cm, xd, mi_row, mi_col, dst_buf1,
                                    dst_stride1, dst_buf2, dst_stride2);
@@ -2610,31 +2684,31 @@ static const int ii_weights1d[MAX_SB_SIZ
   31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 22, 21, 20, 19, 19, 18, 18, 17, 16,
   16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 10, 10, 10,  9,  9,  9,  8,
   8,  8,  8,  7,  7,  7,  7,  6,  6,  6,  6,  6,  5,  5,  5,  5,  5,  4,  4,
   4,  4,  4,  4,  4,  4,  3,  3,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,
   2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  1,  1,  1,  1,  1,  1,  1,  1,
   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
 };
 static int ii_size_scales[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     32, 32, 32,
 #endif
     32, 16, 16, 16, 8, 8, 8, 4,
     4,  4,  2,  2,  2, 1, 1, 1,
 };
 #else
 static const int ii_weights1d[MAX_SB_SIZE] = {
   60, 56, 52, 48, 45, 42, 39, 37, 34, 32, 30, 28, 26, 24, 22, 21,
   19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 10,  9,  8,  8,  7,  7,
   6,  6,  6,  5,  5,  4,  4,  4,  4,  3,  3,  3,  3,  3,  2,  2,
   2,  2,  2,  2,  2,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
 };
 static int ii_size_scales[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     16, 16, 16,
 #endif
     16, 8, 8, 8, 4, 4, 4,
     2,  2, 2, 1, 1, 1,
 };
 /* clang-format on */
 #endif  // CONFIG_EXT_PARTITION
 
@@ -2913,57 +2987,73 @@ static void build_inter_predictors_singl
       ext_dst_stride * y + x;
 #else
   uint8_t *const dst = ext_dst + ext_dst_stride * y + x;
 #endif
   const MV mv = mi->mbmi.sb_type < BLOCK_8X8
                     ? average_split_mvs(pd, mi, ref, block)
                     : mi->mbmi.mv[ref].as_mv;
 
-  // TODO(jkoleszar): This clamping is done in the incorrect place for the
-  // scaling case. It needs to be done on the scaled MV, not the pre-scaling
-  // MV. Note however that it performs the subsampling aware scaling so
-  // that the result is always q4.
-  // mv_precision precision is MV_PRECISION_Q4.
-  const MV mv_q4 = clamp_mv_to_umv_border_sb(xd, &mv, bw, bh, pd->subsampling_x,
-                                             pd->subsampling_y);
-
   uint8_t *pre;
-  MV32 scaled_mv;
   int xs, ys, subpel_x, subpel_y;
   const int is_scaled = av1_is_scaled(sf);
-  ConvolveParams conv_params = get_conv_params(0, plane);
+  ConvolveParams conv_params = get_conv_params(ref, 0, plane);
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
   WarpTypesAllowed warp_types;
 #if CONFIG_GLOBAL_MOTION
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  WarpedMotionParams *const wm =
+      mi->mbmi.ref_frame[ref] > 0 ? &xd->global_motion[mi->mbmi.ref_frame[ref]]
+                                  : &xd->global_motion[mi->mbmi.ref_frame[0]];
+#else   // !(CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF)
   WarpedMotionParams *const wm = &xd->global_motion[mi->mbmi.ref_frame[ref]];
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   warp_types.global_warp_allowed = is_global_mv_block(mi, block, wm->wmtype);
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_WARPED_MOTION
   warp_types.local_warp_allowed = mi->mbmi.motion_mode == WARPED_CAUSAL;
 #endif  // CONFIG_WARPED_MOTION
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 
   if (is_scaled) {
-    pre = pre_buf->buf + scaled_buffer_offset(x, y, pre_buf->stride, sf);
-    scaled_mv = av1_scale_mv(&mv_q4, mi_x + x, mi_y + y, sf);
+    int ssx = pd->subsampling_x;
+    int ssy = pd->subsampling_y;
+    int orig_pos_y = (mi_y << (SUBPEL_BITS - ssy)) + (y << SUBPEL_BITS);
+    orig_pos_y += mv.row * (1 << (1 - ssy));
+    int orig_pos_x = (mi_x << (SUBPEL_BITS - ssx)) + (x << SUBPEL_BITS);
+    orig_pos_x += mv.col * (1 << (1 - ssx));
+    int pos_y = sf->scale_value_y(orig_pos_y, sf);
+    int pos_x = sf->scale_value_x(orig_pos_x, sf);
+    pos_x += SCALE_EXTRA_OFF;
+    pos_y += SCALE_EXTRA_OFF;
+
+    const int top = -((AOM_INTERP_EXTEND + bh) << SCALE_SUBPEL_BITS);
+    const int bottom = (pre_buf->height + AOM_INTERP_EXTEND)
+                       << SCALE_SUBPEL_BITS;
+    const int left = -((AOM_INTERP_EXTEND + bw) << SCALE_SUBPEL_BITS);
+    const int right = (pre_buf->width + AOM_INTERP_EXTEND) << SCALE_SUBPEL_BITS;
+    pos_y = clamp(pos_y, top, bottom);
+    pos_x = clamp(pos_x, left, right);
+
+    pre = pre_buf->buf0 + (pos_y >> SCALE_SUBPEL_BITS) * pre_buf->stride +
+          (pos_x >> SCALE_SUBPEL_BITS);
+    subpel_x = pos_x & SCALE_SUBPEL_MASK;
+    subpel_y = pos_y & SCALE_SUBPEL_MASK;
     xs = sf->x_step_q4;
     ys = sf->y_step_q4;
   } else {
-    pre = pre_buf->buf + (y * pre_buf->stride + x);
-    scaled_mv.row = mv_q4.row;
-    scaled_mv.col = mv_q4.col;
-    xs = ys = 16;
+    const MV mv_q4 = clamp_mv_to_umv_border_sb(
+        xd, &mv, bw, bh, pd->subsampling_x, pd->subsampling_y);
+    xs = ys = SCALE_SUBPEL_SHIFTS;
+    subpel_x = (mv_q4.col & SUBPEL_MASK) << SCALE_EXTRA_BITS;
+    subpel_y = (mv_q4.row & SUBPEL_MASK) << SCALE_EXTRA_BITS;
+    pre = pre_buf->buf + (y + (mv_q4.row >> SUBPEL_BITS)) * pre_buf->stride +
+          (x + (mv_q4.col >> SUBPEL_BITS));
   }
 
-  subpel_x = scaled_mv.col & SUBPEL_MASK;
-  subpel_y = scaled_mv.row & SUBPEL_MASK;
-  pre += (scaled_mv.row >> SUBPEL_BITS) * pre_buf->stride +
-         (scaled_mv.col >> SUBPEL_BITS);
-
   av1_make_inter_predictor(pre, pre_buf->stride, dst, ext_dst_stride, subpel_x,
                            subpel_y, sf, w, h, &conv_params,
                            mi->mbmi.interp_filter,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
                            &warp_types, (mi_x >> pd->subsampling_x) + x,
                            (mi_y >> pd->subsampling_y) + y, plane, ref,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 #if CONFIG_MOTION_VAR
@@ -2984,16 +3074,20 @@ void av1_build_inter_predictors_for_plan
     const int bw = block_size_wide[plane_bsize];
     const int bh = block_size_high[plane_bsize];
 
     if (xd->mi[0]->mbmi.sb_type < BLOCK_8X8 && !CONFIG_CB4X4) {
       int x, y;
       const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize];
       const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize];
       assert(bsize == BLOCK_8X8);
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+      assert(has_second_ref(&xd->mi[0]->mbmi) ||
+             !is_inter_singleref_comp_mode(xd->mi[0]->mbmi.mode));
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
       for (y = 0; y < num_4x4_h; ++y)
         for (x = 0; x < num_4x4_w; ++x)
           build_inter_predictors_single_buf(
               xd, plane, y * 2 + x, bw, bh, 4 * x, 4 * y, 4, 4, mi_x, mi_y, ref,
               ext_dst[plane], ext_dst_stride[plane]);
     } else {
       build_inter_predictors_single_buf(xd, plane, 0, bw, bh, 0, 0, bw, bh,
                                         mi_x, mi_y, ref, ext_dst[plane],
@@ -3021,17 +3115,22 @@ static void build_wedge_inter_predictor_
 #endif  // CONFIG_WEDGE
 #if CONFIG_COMPOUND_SEGMENT
     mbmi->mask_type,
     xd->seg_mask,
 #endif  // CONFIG_COMPOUND_SEGMENT
     mbmi->interinter_compound_type
   };
 
+#if CONFIG_COMPOUND_SINGLEREF
+  if ((is_compound || is_inter_singleref_comp_mode(mbmi->mode)) &&
+      is_masked_compound_type(mbmi->interinter_compound_type)) {
+#else   // !CONFIG_COMPOUND_SINGLEREF
   if (is_compound && is_masked_compound_type(mbmi->interinter_compound_type)) {
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_COMPOUND_SEGMENT
     if (!plane && comp_data.interinter_compound_type == COMPOUND_SEG) {
 #if CONFIG_HIGHBITDEPTH
       if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
         build_compound_seg_mask_highbd(
             comp_data.seg_mask, comp_data.mask_type,
             CONVERT_TO_BYTEPTR(ext_dst0), ext_dst_stride0,
             CONVERT_TO_BYTEPTR(ext_dst1), ext_dst_stride1, mbmi->sb_type, h, w,
@@ -3052,17 +3151,17 @@ static void build_wedge_inter_predictor_
           CONVERT_TO_BYTEPTR(ext_dst1), ext_dst_stride1, &comp_data,
           mbmi->sb_type, wedge_offset_x, wedge_offset_y, h, w, xd->bd);
     else
 #endif  // CONFIG_HIGHBITDEPTH
       build_masked_compound_wedge_extend(
           dst, dst_buf->stride, ext_dst0, ext_dst_stride0, ext_dst1,
           ext_dst_stride1, &comp_data, mbmi->sb_type, wedge_offset_x,
           wedge_offset_y, h, w);
-#else
+#else  // !CONFIG_SUPERTX
 #if CONFIG_HIGHBITDEPTH
     if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
       build_masked_compound_highbd(
           dst, dst_buf->stride, CONVERT_TO_BYTEPTR(ext_dst0), ext_dst_stride0,
           CONVERT_TO_BYTEPTR(ext_dst1), ext_dst_stride1, &comp_data,
           mbmi->sb_type, h, w, xd->bd);
     else
 #endif  // CONFIG_HIGHBITDEPTH
--- a/third_party/aom/av1/common/reconinter.h
+++ b/third_party/aom/av1/common/reconinter.h
@@ -27,17 +27,19 @@
 #if CONFIG_MOTION_VAR && CONFIG_GLOBAL_MOTION
 #define WARP_GM_NEIGHBORS_WITH_OBMC 0
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-static INLINE int has_scale(int xs, int ys) { return xs != 16 || ys != 16; }
+static INLINE int has_scale(int xs, int ys) {
+  return xs != SCALE_SUBPEL_SHIFTS || ys != SCALE_SUBPEL_SHIFTS;
+}
 
 static INLINE void inter_predictor(const uint8_t *src, int src_stride,
                                    uint8_t *dst, int dst_stride, int subpel_x,
                                    int subpel_y, const struct scale_factors *sf,
                                    int w, int h, ConvolveParams *conv_params,
 #if CONFIG_DUAL_FILTER
                                    const InterpFilter *interp_filter,
 #else
@@ -54,111 +56,136 @@ static INLINE void inter_predictor(const
   const InterpFilterParams interp_filter_params_y =
       av1_get_interp_filter_params(filter_y);
 #else
   const InterpFilterParams interp_filter_params_x =
       av1_get_interp_filter_params(interp_filter);
   const InterpFilterParams interp_filter_params_y = interp_filter_params_x;
 #endif
 
+  assert(conv_params->do_average == 0 || conv_params->do_average == 1);
   assert(sf);
   if (has_scale(xs, ys)) {
-    av1_convolve_c(src, src_stride, dst, dst_stride, w, h, interp_filter,
-                   subpel_x, xs, subpel_y, ys, conv_params);
-  } else if (conv_params->round == CONVOLVE_OPT_NO_ROUND) {
-#if CONFIG_CONVOLVE_ROUND
-    av1_convolve_2d_facade(src, src_stride, dst, dst_stride, w, h,
-#if CONFIG_DUAL_FILTER
-                           interp_filter,
-#else   // CONFIG_DUAL_FILTER
-                           &interp_filter,
-#endif  // CONFIG_DUAL_FILTER
-                           subpel_x, xs, subpel_y, ys, conv_params);
-    conv_params->do_post_rounding = 1;
-#else
-    assert(0);
-#endif  // CONFIG_CONVOLVE_ROUND
+    // TODO(afergs, debargha): Use a different scale convolve function
+    // that uses higher precision for subpel_x, subpel_y, xs, ys
+    av1_convolve_scale(src, src_stride, dst, dst_stride, w, h, interp_filter,
+                       subpel_x, xs, subpel_y, ys, conv_params);
   } else {
-    assert(conv_params->round == CONVOLVE_OPT_ROUND);
-    if (w <= 2 || h <= 2) {
-      av1_convolve_c(src, src_stride, dst, dst_stride, w, h, interp_filter,
+    subpel_x >>= SCALE_EXTRA_BITS;
+    subpel_y >>= SCALE_EXTRA_BITS;
+    xs >>= SCALE_EXTRA_BITS;
+    ys >>= SCALE_EXTRA_BITS;
+    assert(subpel_x < SUBPEL_SHIFTS);
+    assert(subpel_y < SUBPEL_SHIFTS);
+    assert(xs <= SUBPEL_SHIFTS);
+    assert(ys <= SUBPEL_SHIFTS);
+    if (conv_params->round == CONVOLVE_OPT_NO_ROUND) {
+#if CONFIG_CONVOLVE_ROUND
+      av1_convolve_2d_facade(src, src_stride, dst, dst_stride, w, h,
+#if CONFIG_DUAL_FILTER
+                             interp_filter,
+#else   // CONFIG_DUAL_FILTER
+                             &interp_filter,
+#endif  // CONFIG_DUAL_FILTER
+                             subpel_x, xs, subpel_y, ys, conv_params);
+      conv_params->do_post_rounding = 1;
+#else
+      assert(0);
+#endif  // CONFIG_CONVOLVE_ROUND
+    } else {
+      assert(conv_params->round == CONVOLVE_OPT_ROUND);
+      if (w <= 2 || h <= 2) {
+        av1_convolve_c(src, src_stride, dst, dst_stride, w, h, interp_filter,
+                       subpel_x, xs, subpel_y, ys, conv_params);
+      } else if (interp_filter_params_x.taps == SUBPEL_TAPS &&
+                 interp_filter_params_y.taps == SUBPEL_TAPS) {
+        const int16_t *kernel_x = av1_get_interp_filter_subpel_kernel(
+            interp_filter_params_x, subpel_x);
+        const int16_t *kernel_y = av1_get_interp_filter_subpel_kernel(
+            interp_filter_params_y, subpel_y);
+        sf->predict[subpel_x != 0][subpel_y != 0][conv_params->do_average](
+            src, src_stride, dst, dst_stride, kernel_x, xs, kernel_y, ys, w, h);
+      } else {
+        av1_convolve(src, src_stride, dst, dst_stride, w, h, interp_filter,
                      subpel_x, xs, subpel_y, ys, conv_params);
-    } else if (interp_filter_params_x.taps == SUBPEL_TAPS &&
-               interp_filter_params_y.taps == SUBPEL_TAPS) {
-      const int16_t *kernel_x =
-          av1_get_interp_filter_subpel_kernel(interp_filter_params_x, subpel_x);
-      const int16_t *kernel_y =
-          av1_get_interp_filter_subpel_kernel(interp_filter_params_y, subpel_y);
-      sf->predict[subpel_x != 0][subpel_y != 0][conv_params->ref](
-          src, src_stride, dst, dst_stride, kernel_x, xs, kernel_y, ys, w, h);
-    } else {
-      av1_convolve(src, src_stride, dst, dst_stride, w, h, interp_filter,
-                   subpel_x, xs, subpel_y, ys, conv_params);
+      }
     }
   }
 }
 
 #if CONFIG_HIGHBITDEPTH
 static INLINE void highbd_inter_predictor(const uint8_t *src, int src_stride,
                                           uint8_t *dst, int dst_stride,
-                                          const int subpel_x,
-                                          const int subpel_y,
+                                          int subpel_x, int subpel_y,
                                           const struct scale_factors *sf, int w,
                                           int h, ConvolveParams *conv_params,
 #if CONFIG_DUAL_FILTER
                                           const InterpFilter *interp_filter,
 #else
                                           const InterpFilter interp_filter,
 #endif
                                           int xs, int ys, int bd) {
+  const int avg = conv_params->do_average;
+  assert(avg == 0 || avg == 1);
+#if CONFIG_DUAL_FILTER
   const int ref = conv_params->ref;
-  // ref > 0 means this is the second reference frame
-  // first reference frame's prediction result is already in dst
-  // therefore we need to average the first and second results
-  const int avg = ref > 0;
-#if CONFIG_DUAL_FILTER
   const InterpFilterParams interp_filter_params_x =
       av1_get_interp_filter_params(interp_filter[1 + 2 * ref]);
   const InterpFilterParams interp_filter_params_y =
       av1_get_interp_filter_params(interp_filter[0 + 2 * ref]);
 #else
   const InterpFilterParams interp_filter_params_x =
       av1_get_interp_filter_params(interp_filter);
   const InterpFilterParams interp_filter_params_y = interp_filter_params_x;
 #endif
 
   if (has_scale(xs, ys)) {
+    // TODO(afergs, debargha): Use a different scale convolve function
+    // that uses higher precision for subpel_x, subpel_y, xs, ys
     av1_highbd_convolve(src, src_stride, dst, dst_stride, w, h, interp_filter,
-                        subpel_x, xs, subpel_y, ys, avg, bd);
-  } else if (conv_params->round == CONVOLVE_OPT_NO_ROUND) {
+                        subpel_x >> SCALE_EXTRA_BITS, xs >> SCALE_EXTRA_BITS,
+                        subpel_y >> SCALE_EXTRA_BITS, ys >> SCALE_EXTRA_BITS,
+                        avg, bd);
+  } else {
+    subpel_x >>= SCALE_EXTRA_BITS;
+    subpel_y >>= SCALE_EXTRA_BITS;
+    xs >>= SCALE_EXTRA_BITS;
+    ys >>= SCALE_EXTRA_BITS;
+    assert(subpel_x < SUBPEL_SHIFTS);
+    assert(subpel_y < SUBPEL_SHIFTS);
+    assert(xs <= SUBPEL_SHIFTS);
+    assert(ys <= SUBPEL_SHIFTS);
+    if (conv_params->round == CONVOLVE_OPT_NO_ROUND) {
 #if CONFIG_CONVOLVE_ROUND
-    av1_highbd_convolve_2d_facade(src, src_stride, dst, dst_stride, w, h,
+      av1_highbd_convolve_2d_facade(src, src_stride, dst, dst_stride, w, h,
 #if CONFIG_DUAL_FILTER
-                                  interp_filter,
-#else   // CONFIG_DUAL_FILTER
-                                  &interp_filter,
+                                    interp_filter,
+#else  // CONFIG_DUAL_FILTER
+                                    &interp_filter,
 #endif  // CONFIG_DUAL_FILTER
-                                  subpel_x, xs, subpel_y, ys, conv_params, bd);
-    conv_params->do_post_rounding = 1;
+                                    subpel_x, xs, subpel_y, ys, conv_params,
+                                    bd);
+      conv_params->do_post_rounding = 1;
 #else
-    assert(0);
+      assert(0);
 #endif  // CONFIG_CONVOLVE_ROUND
-  } else {
-    if (interp_filter_params_x.taps == SUBPEL_TAPS &&
-        interp_filter_params_y.taps == SUBPEL_TAPS && w > 2 && h > 2) {
-      const int16_t *kernel_x =
-          av1_get_interp_filter_subpel_kernel(interp_filter_params_x, subpel_x);
-      const int16_t *kernel_y =
-          av1_get_interp_filter_subpel_kernel(interp_filter_params_y, subpel_y);
-      sf->highbd_predict[subpel_x != 0][subpel_y != 0][ref](
-          src, src_stride, dst, dst_stride, kernel_x, xs, kernel_y, ys, w, h,
-          bd);
     } else {
-      av1_highbd_convolve(src, src_stride, dst, dst_stride, w, h, interp_filter,
-                          subpel_x, xs, subpel_y, ys, avg, bd);
+      if (interp_filter_params_x.taps == SUBPEL_TAPS &&
+          interp_filter_params_y.taps == SUBPEL_TAPS && w > 2 && h > 2) {
+        const int16_t *kernel_x = av1_get_interp_filter_subpel_kernel(
+            interp_filter_params_x, subpel_x);
+        const int16_t *kernel_y = av1_get_interp_filter_subpel_kernel(
+            interp_filter_params_y, subpel_y);
+        sf->highbd_predict[subpel_x != 0][subpel_y != 0][avg](
+            src, src_stride, dst, dst_stride, kernel_x, xs, kernel_y, ys, w, h,
+            bd);
+      } else {
+        av1_highbd_convolve(src, src_stride, dst, dst_stride, w, h,
+                            interp_filter, subpel_x, xs, subpel_y, ys, avg, bd);
+      }
     }
   }
 }
 #endif  // CONFIG_HIGHBITDEPTH
 
 #if CONFIG_EXT_INTER
 // Set to (1 << 5) if the 32-ary codebooks are used for any bock size
 #define MAX_WEDGE_TYPES (1 << 4)
@@ -200,29 +227,36 @@ typedef struct {
 } wedge_params_type;
 
 extern const wedge_params_type wedge_params_lookup[BLOCK_SIZES];
 
 static INLINE int is_interinter_compound_used(COMPOUND_TYPE type,
                                               BLOCK_SIZE sb_type) {
   (void)sb_type;
   switch (type) {
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+    case COMPOUND_AVERAGE: return sb_type >= BLOCK_4X4;
+#else   // CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
     case COMPOUND_AVERAGE: return 1;
+#endif  // CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
 #if CONFIG_WEDGE
     case COMPOUND_WEDGE: return wedge_params_lookup[sb_type].bits > 0;
 #endif  // CONFIG_WEDGE
 #if CONFIG_COMPOUND_SEGMENT
     case COMPOUND_SEG: return sb_type >= BLOCK_8X8;
 #endif  // CONFIG_COMPOUND_SEGMENT
     default: assert(0); return 0;
   }
 }
 
 static INLINE int is_any_masked_compound_used(BLOCK_SIZE sb_type) {
   COMPOUND_TYPE comp_type;
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
+  if (sb_type < BLOCK_4X4) return 0;
+#endif  // CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   for (comp_type = 0; comp_type < COMPOUND_TYPES; comp_type++) {
     if (is_masked_compound_type(comp_type) &&
         is_interinter_compound_used(comp_type, sb_type))
       return 1;
   }
   return 0;
 }
 
@@ -403,40 +437,43 @@ static INLINE void av1_make_inter_predic
 #if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
                            0, xd->global_motion,
 #endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
                            mi);
 #endif  // CONFIG MOTION_VAR || CONFIG_WARPED_MOTION
 
 #if CONFIG_WARPED_MOTION || CONFIG_GLOBAL_MOTION
   WarpedMotionParams final_warp_params;
-  const int do_warp = allow_warp(mi, warp_types,
+  const int do_warp = allow_warp(
+      mi, warp_types,
 #if CONFIG_GLOBAL_MOTION
-                                 &xd->global_motion[mi->mbmi.ref_frame[ref]],
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+      // TODO(zoeliu): To further check the single
+      // ref comp mode to work together with
+      //               global motion.
+      has_second_ref(&mi->mbmi) ? &xd->global_motion[mi->mbmi.ref_frame[ref]]
+                                : &xd->global_motion[mi->mbmi.ref_frame[0]],
+#else   // !(CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF)
+      &xd->global_motion[mi->mbmi.ref_frame[ref]],
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_MOTION_VAR
-                                 mi_col_offset, mi_row_offset,
+      mi_col_offset, mi_row_offset,
 #endif  // CONFIG_MOTION_VAR
-                                 &final_warp_params);
+      &final_warp_params);
   if (do_warp) {
     const struct macroblockd_plane *const pd = &xd->plane[plane];
     const struct buf_2d *const pre_buf = &pd->pre[ref];
-#if CONFIG_EXT_INTER
-    int compute_avg =
-        ref && mi->mbmi.interinter_compound_type == COMPOUND_AVERAGE;
-#else
-    int compute_avg = ref;
-#endif  // CONFIG_EXT_INTER
     av1_warp_plane(&final_warp_params,
 #if CONFIG_HIGHBITDEPTH
                    xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
 #endif  // CONFIG_HIGHBITDEPTH
                    pre_buf->buf0, pre_buf->width, pre_buf->height,
                    pre_buf->stride, dst, p_col, p_row, w, h, dst_stride,
-                   pd->subsampling_x, pd->subsampling_y, xs, ys, compute_avg);
+                   pd->subsampling_x, pd->subsampling_y, xs, ys, conv_params);
     return;
   }
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 #if CONFIG_HIGHBITDEPTH
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
     highbd_inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y,
                            sf, w, h, conv_params, interp_filter, xs, ys,
                            xd->bd);
@@ -548,30 +585,31 @@ void av1_build_inter_predictors_sbuv(con
                                      int mi_row, int mi_col, BUFFER_SET *ctx,
                                      BLOCK_SIZE bsize);
 
 void av1_build_inter_predictors_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
                                    int mi_row, int mi_col, BUFFER_SET *ctx,
                                    BLOCK_SIZE bsize);
 
 #if CONFIG_SUPERTX
-void av1_build_inter_predictors_sb_sub8x8_extend(const AV1_COMMON *cm,
-                                                 MACROBLOCKD *xd,
+void av1_build_inter_predictor_sb_sub8x8_extend(const AV1_COMMON *cm,
+                                                MACROBLOCKD *xd,
 #if CONFIG_EXT_INTER
-                                                 int mi_row_ori, int mi_col_ori,
+                                                int mi_row_ori, int mi_col_ori,
 #endif  // CONFIG_EXT_INTER
-                                                 int mi_row, int mi_col,
-                                                 BLOCK_SIZE bsize, int block);
+                                                int mi_row, int mi_col,
+                                                int plane, BLOCK_SIZE bsize,
+                                                int block);
 
-void av1_build_inter_predictors_sb_extend(const AV1_COMMON *cm, MACROBLOCKD *xd,
+void av1_build_inter_predictor_sb_extend(const AV1_COMMON *cm, MACROBLOCKD *xd,
 #if CONFIG_EXT_INTER
-                                          int mi_row_ori, int mi_col_ori,
+                                         int mi_row_ori, int mi_col_ori,
 #endif  // CONFIG_EXT_INTER
-                                          int mi_row, int mi_col,
-                                          BLOCK_SIZE bsize);
+                                         int mi_row, int mi_col, int plane,
+                                         BLOCK_SIZE bsize);
 struct macroblockd_plane;
 void av1_build_masked_inter_predictor_complex(
     MACROBLOCKD *xd, uint8_t *dst, int dst_stride, const uint8_t *pre,
     int pre_stride, int mi_row, int mi_col, int mi_row_ori, int mi_col_ori,
     BLOCK_SIZE bsize, BLOCK_SIZE top_bsize, PARTITION_TYPE partition,
     int plane);
 #endif  // CONFIG_SUPERTX
 
@@ -604,18 +642,20 @@ void av1_highbd_build_inter_predictor(
     const WarpTypesAllowed *warp_types, int p_col, int p_row,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
     int plane, enum mv_precision precision, int x, int y,
     const MACROBLOCKD *xd);
 #endif
 
 static INLINE int scaled_buffer_offset(int x_offset, int y_offset, int stride,
                                        const struct scale_factors *sf) {
-  const int x = sf ? sf->scale_value_x(x_offset, sf) : x_offset;
-  const int y = sf ? sf->scale_value_y(y_offset, sf) : y_offset;
+  const int x =
+      sf ? sf->scale_value_x(x_offset, sf) >> SCALE_EXTRA_BITS : x_offset;
+  const int y =
+      sf ? sf->scale_value_y(y_offset, sf) >> SCALE_EXTRA_BITS : y_offset;
   return y * stride + x;
 }
 
 static INLINE void setup_pred_plane(struct buf_2d *dst, BLOCK_SIZE bsize,
                                     uint8_t *src, int width, int height,
                                     int stride, int mi_row, int mi_col,
                                     const struct scale_factors *scale,
                                     int subsampling_x, int subsampling_y) {
--- a/third_party/aom/av1/common/reconintra.c
+++ b/third_party/aom/av1/common/reconintra.c
@@ -31,16 +31,24 @@
 enum {
   NEED_LEFT = 1 << 1,
   NEED_ABOVE = 1 << 2,
   NEED_ABOVERIGHT = 1 << 3,
   NEED_ABOVELEFT = 1 << 4,
   NEED_BOTTOMLEFT = 1 << 5,
 };
 
+#if CONFIG_INTRA_EDGE
+#define INTRA_EDGE_FILT 3
+#define INTRA_EDGE_TAPS 5
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+#define MAX_UPSAMPLE_SZ 12
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
+#endif  // CONFIG_INTRA_EDGE
+
 static const uint8_t extend_modes[INTRA_MODES] = {
   NEED_ABOVE | NEED_LEFT,                   // DC
   NEED_ABOVE,                               // V
   NEED_LEFT,                                // H
   NEED_ABOVE | NEED_ABOVERIGHT,             // D45
   NEED_LEFT | NEED_ABOVE | NEED_ABOVELEFT,  // D135
   NEED_LEFT | NEED_ABOVE | NEED_ABOVELEFT,  // D117
   NEED_LEFT | NEED_ABOVE | NEED_ABOVELEFT,  // D153
@@ -288,23 +296,25 @@ static const uint16_t orders_4x4[1024] =
 };
 #endif
 #endif  // CONFIG_CB4X4 || CONFIG_EXT_PARTITION
 
 #if CONFIG_EXT_PARTITION
 /* clang-format off */
 static const uint16_t *const orders[BLOCK_SIZES] = {
 #if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   // 2X2,         2X4,            4X2
   orders_4x4,     orders_4x4,     orders_4x4,
+#endif
   //                              4X4
                                   orders_4x4,
   // 4X8,         8X4,            8X8
   orders_4x8,     orders_8x4,     orders_8x8,
-#else
+#else  // CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   //                              4X4
                                   orders_8x8,
   // 4X8,         8X4,            8X8
   orders_8x8,     orders_8x8,     orders_8x8,
 #endif
   // 8X16,        16X8,           16X16
   orders_8x16,    orders_16x8,    orders_16x16,
   // 16X32,       32X16,          32X32
@@ -314,23 +324,25 @@ static const uint16_t *const orders[BLOC
   // 64x128,      128x64,         128x128
   orders_64x128,  orders_128x64,  orders_128x128
 };
 /* clang-format on */
 #else
 /* clang-format off */
 static const uint16_t *const orders[BLOCK_SIZES] = {
 #if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   // 2X2,         2X4,            4X2
   orders_8x8,     orders_8x8,     orders_8x8,
+#endif
   //                              4X4
                                   orders_8x8,
   // 4X8,         8X4,            8X8
   orders_8x16,    orders_16x8,    orders_16x16,
-#else
+#else  // CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   //                              4X4
                                   orders_16x16,
   // 4X8,         8X4,            8X8
   orders_16x16,   orders_16x16,   orders_16x16,
 #endif
   // 8X16,        16X8,           16X16
   orders_16x32,   orders_32x16,   orders_32x32,
   // 16X32,       32X16,          32X32
@@ -375,17 +387,17 @@ static const uint16_t orders_verta_8x8[2
   169, 170, 173, 174, 185, 186, 189, 190, 233, 234, 237, 238, 249, 250, 253,
   254,
 };
 #endif  // CONFIG_EXT_PARTITION || CONFIG_CB4X4
 
 #if CONFIG_EXT_PARTITION
 /* clang-format off */
 static const uint16_t *const orders_verta[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   // 2X2,           2X4,              4X2
   orders_4x4,       orders_4x4,       orders_4x4,
 #endif
   //                                  4X4
                                       orders_verta_8x8,
   // 4X8,           8X4,              8X8
   orders_verta_8x8, orders_verta_8x8, orders_verta_8x8,
   // 8X16,          16X8,             16X16
@@ -397,23 +409,25 @@ static const uint16_t *const orders_vert
   // 64x128,        128x64,           128x128
   orders_64x128,    orders_128x64,    orders_128x128
 };
 /* clang-format on */
 #else
 /* clang-format off */
 static const uint16_t *const orders_verta[BLOCK_SIZES] = {
 #if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   // 2X2,             2X4,                4X2
   orders_verta_8x8,   orders_verta_8x8,   orders_verta_8x8,
+#endif
   //                                      4X4
                                           orders_verta_8x8,
   // 4X8,             8X4,                8X8
   orders_verta_8x8,   orders_verta_8x8,   orders_verta_16x16,
-#else
+#else  // CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   //                                      4X4
                                           orders_verta_16x16,
   // 4X8,             8X4,                8X8
   orders_verta_16x16, orders_verta_16x16, orders_verta_16x16,
 #endif
   // 8X16,            16X8,               16X16
   orders_16x32,       orders_32x16,       orders_verta_32x32,
   // 16X32,           32X16,              32X32
@@ -547,42 +561,53 @@ static int has_bottom_left(BLOCK_SIZE bs
     const uint16_t bl_blk_order = order[bl_blk_index];
     return bl_blk_order < this_blk_order;
   }
 }
 
 typedef void (*intra_pred_fn)(uint8_t *dst, ptrdiff_t stride,
                               const uint8_t *above, const uint8_t *left);
 
-static intra_pred_fn pred[INTRA_MODES][TX_SIZES];
-static intra_pred_fn dc_pred[2][2][TX_SIZES];
+static intra_pred_fn pred[INTRA_MODES][TX_SIZES_ALL];
+static intra_pred_fn dc_pred[2][2][TX_SIZES_ALL];
 
 #if CONFIG_HIGHBITDEPTH
 typedef void (*intra_high_pred_fn)(uint16_t *dst, ptrdiff_t stride,
                                    const uint16_t *above, const uint16_t *left,
                                    int bd);
-static intra_high_pred_fn pred_high[INTRA_MODES][TX_SIZES];
-static intra_high_pred_fn dc_pred_high[2][2][TX_SIZES];
+static intra_high_pred_fn pred_high[INTRA_MODES][TX_SIZES_ALL];
+static intra_high_pred_fn dc_pred_high[2][2][TX_SIZES_ALL];
 #endif  // CONFIG_HIGHBITDEPTH
 
 static void av1_init_intra_predictors_internal(void) {
 #if CONFIG_EXT_INTRA
   assert(NELEMENTS(mode_to_angle_map) == INTRA_MODES);
 #endif  // CONFIG_EXT_INTRA
+
+#define INIT_RECTANGULAR(p, type)             \
+  p[TX_4X8] = aom_##type##_predictor_4x8;     \
+  p[TX_8X4] = aom_##type##_predictor_8x4;     \
+  p[TX_8X16] = aom_##type##_predictor_8x16;   \
+  p[TX_16X8] = aom_##type##_predictor_16x8;   \
+  p[TX_16X32] = aom_##type##_predictor_16x32; \
+  p[TX_32X16] = aom_##type##_predictor_32x16;
+
 #if CONFIG_TX64X64
 #define INIT_NO_4X4(p, type)                  \
   p[TX_8X8] = aom_##type##_predictor_8x8;     \
   p[TX_16X16] = aom_##type##_predictor_16x16; \
   p[TX_32X32] = aom_##type##_predictor_32x32; \
-  p[TX_64X64] = aom_##type##_predictor_64x64
+  p[TX_64X64] = aom_##type##_predictor_64x64; \
+  INIT_RECTANGULAR(p, type)
 #else
 #define INIT_NO_4X4(p, type)                  \
   p[TX_8X8] = aom_##type##_predictor_8x8;     \
   p[TX_16X16] = aom_##type##_predictor_16x16; \
-  p[TX_32X32] = aom_##type##_predictor_32x32
+  p[TX_32X32] = aom_##type##_predictor_32x32; \
+  INIT_RECTANGULAR(p, type)
 #endif  // CONFIG_TX64X64
 
 #if CONFIG_CHROMA_2X2
 #define INIT_ALL_SIZES(p, type)           \
   p[TX_2X2] = aom_##type##_predictor_2x2; \
   p[TX_4X4] = aom_##type##_predictor_4x4; \
   INIT_NO_4X4(p, type)
 #else
@@ -674,21 +699,24 @@ static int intra_subpel_interp(int base,
     }
   }
 
   return val;
 }
 #endif  // CONFIG_INTRA_INTERP
 
 // Directional prediction, zone 1: 0 < angle < 90
-static void dr_prediction_z1(uint8_t *dst, ptrdiff_t stride, int bs,
+static void dr_prediction_z1(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
                              const uint8_t *above, const uint8_t *left,
 #if CONFIG_INTRA_INTERP
                              INTRA_FILTER filter_type,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                             int upsample_above,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                              int dx, int dy) {
   int r, c, x, base, shift, val;
 
   (void)left;
   (void)dy;
   assert(dy == 1);
   assert(dx > 0);
 
@@ -697,141 +725,160 @@ static void dr_prediction_z1(uint8_t *ds
     const int pad_size = SUBPEL_TAPS >> 1;
     int len;
     DECLARE_ALIGNED(16, uint8_t, buf[SUBPEL_SHIFTS][MAX_SB_SIZE]);
     DECLARE_ALIGNED(16, uint8_t, src[MAX_SB_SIZE + SUBPEL_TAPS]);
     uint8_t flags[SUBPEL_SHIFTS];
 
     memset(flags, 0, SUBPEL_SHIFTS * sizeof(flags[0]));
     memset(src, above[0], pad_size * sizeof(above[0]));
-    memcpy(src + pad_size, above, 2 * bs * sizeof(above[0]));
-    memset(src + pad_size + 2 * bs, above[2 * bs - 1],
+    memcpy(src + pad_size, above, (bw + bh) * sizeof(above[0]));
+    memset(src + pad_size + bw + bh, above[bw + bh - 1],
            pad_size * sizeof(above[0]));
     flags[0] = 1;
     x = dx;
-    for (r = 0; r < bs; ++r, dst += stride, x += dx) {
+    for (r = 0; r < bh; ++r, dst += stride, x += dx) {
       base = x >> 8;
       shift = x & 0xFF;
       shift = ROUND_POWER_OF_TWO(shift, 8 - SUBPEL_BITS);
       if (shift == SUBPEL_SHIFTS) {
         base += 1;
         shift = 0;
       }
-      len = AOMMIN(bs, 2 * bs - 1 - base);
+      len = AOMMIN(bw, bw + bh - 1 - base);
       if (len <= 0) {
         int i;
-        for (i = r; i < bs; ++i) {
-          memset(dst, above[2 * bs - 1], bs * sizeof(dst[0]));
+        for (i = r; i < bh; ++i) {
+          memset(dst, above[bw + bh - 1], bw * sizeof(dst[0]));
           dst += stride;
         }
         return;
       }
 
-      if (len <= (bs >> 1) && !flags[shift]) {
+      if (len <= (bw >> 1) && !flags[shift]) {
         base = x >> 8;
         shift = x & 0xFF;
         for (c = 0; c < len; ++c) {
-          val = intra_subpel_interp(base, shift, above, 0, 2 * bs - 1,
+          val = intra_subpel_interp(base, shift, above, 0, bw + bh - 1,
                                     filter_type);
           dst[c] = clip_pixel(val);
           ++base;
         }
       } else {
         if (!flags[shift]) {
           const int16_t *filter = av1_intra_filter_kernels[filter_type][shift];
-          aom_convolve8_horiz(src + pad_size, 2 * bs, buf[shift], 2 * bs,
-                              filter, 16, NULL, 16, 2 * bs,
-                              2 * bs < 16 ? 2 : 1);
+          aom_convolve8_horiz(src + pad_size, bw + bh, buf[shift], bw + bh,
+                              filter, 16, NULL, 16, bw + bh,
+                              bw + bh < 16 ? 2 : 1);
           flags[shift] = 1;
         }
         memcpy(dst, shift == 0 ? src + pad_size + base : &buf[shift][base],
                len * sizeof(dst[0]));
       }
 
-      if (len < bs)
-        memset(dst + len, above[2 * bs - 1], (bs - len) * sizeof(dst[0]));
+      if (len < bw)
+        memset(dst + len, above[bw + bh - 1], (bw - len) * sizeof(dst[0]));
     }
     return;
   }
 #endif  // CONFIG_INTRA_INTERP
 
+#if !CONFIG_INTRA_EDGE_UPSAMPLE
+  const int upsample_above = 0;
+#endif  // !CONFIG_INTRA_EDGE_UPSAMPLE
+  const int max_base_x = ((bw + bh) - 1) << upsample_above;
+  const int frac_bits = 8 - upsample_above;
+  const int base_inc = 1 << upsample_above;
   x = dx;
-  for (r = 0; r < bs; ++r, dst += stride, x += dx) {
-    base = x >> 8;
-    shift = x & 0xFF;
+  for (r = 0; r < bh; ++r, dst += stride, x += dx) {
+    base = x >> frac_bits;
+    shift = (x << upsample_above) & 0xFF;
 
-    if (base >= 2 * bs - 1) {
-      int i;
-      for (i = r; i < bs; ++i) {
-        memset(dst, above[2 * bs - 1], bs * sizeof(dst[0]));
+    if (base >= max_base_x) {
+      for (int i = r; i < bh; ++i) {
+        memset(dst, above[max_base_x], bw * sizeof(dst[0]));
         dst += stride;
       }
       return;
     }
 
-    for (c = 0; c < bs; ++c, ++base) {
-      if (base < 2 * bs - 1) {
+    for (c = 0; c < bw; ++c, base += base_inc) {
+      if (base < max_base_x) {
         val = above[base] * (256 - shift) + above[base + 1] * shift;
         val = ROUND_POWER_OF_TWO(val, 8);
         dst[c] = clip_pixel(val);
       } else {
-        dst[c] = above[2 * bs - 1];
+        dst[c] = above[max_base_x];
       }
     }
   }
 }
 
 // Directional prediction, zone 2: 90 < angle < 180
-static void dr_prediction_z2(uint8_t *dst, ptrdiff_t stride, int bs,
+static void dr_prediction_z2(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
                              const uint8_t *above, const uint8_t *left,
 #if CONFIG_INTRA_INTERP
                              INTRA_FILTER filter_type,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                             int upsample_above, int upsample_left,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                              int dx, int dy) {
   int r, c, x, y, shift1, shift2, val, base1, base2;
 
   assert(dx > 0);
   assert(dy > 0);
 
+#if !CONFIG_INTRA_EDGE_UPSAMPLE
+  const int upsample_above = 0;
+  const int upsample_left = 0;
+#endif  // !CONFIG_INTRA_EDGE_UPSAMPLE
+  const int min_base_x = -(1 << upsample_above);
+  const int frac_bits_x = 8 - upsample_above;
+  const int frac_bits_y = 8 - upsample_left;
+  const int base_inc_x = 1 << upsample_above;
   x = -dx;
-  for (r = 0; r < bs; ++r, x -= dx, dst += stride) {
-    base1 = x >> 8;
+  for (r = 0; r < bh; ++r, x -= dx, dst += stride) {
+    base1 = x >> frac_bits_x;
     y = (r << 8) - dy;
-    for (c = 0; c < bs; ++c, ++base1, y -= dy) {
-      if (base1 >= -1) {
-        shift1 = x & 0xFF;
+    for (c = 0; c < bw; ++c, base1 += base_inc_x, y -= dy) {
+      if (base1 >= min_base_x) {
+        shift1 = (x * (1 << upsample_above)) & 0xFF;
 #if CONFIG_INTRA_INTERP
         val =
-            intra_subpel_interp(base1, shift1, above, -1, bs - 1, filter_type);
+            intra_subpel_interp(base1, shift1, above, -1, bw - 1, filter_type);
 #else
         val = above[base1] * (256 - shift1) + above[base1 + 1] * shift1;
         val = ROUND_POWER_OF_TWO(val, 8);
 #endif  // CONFIG_INTRA_INTERP
       } else {
-        base2 = y >> 8;
-        assert(base2 >= -1);
-        shift2 = y & 0xFF;
+        base2 = y >> frac_bits_y;
+        assert(base2 >= -(1 << upsample_left));
+        shift2 = (y * (1 << upsample_left)) & 0xFF;
 #if CONFIG_INTRA_INTERP
-        val = intra_subpel_interp(base2, shift2, left, -1, bs - 1, filter_type);
+        val = intra_subpel_interp(base2, shift2, left, -1, bh - 1, filter_type);
 #else
         val = left[base2] * (256 - shift2) + left[base2 + 1] * shift2;
         val = ROUND_POWER_OF_TWO(val, 8);
 #endif  // CONFIG_INTRA_INTERP
       }
       dst[c] = clip_pixel(val);
     }
   }
 }
 
 // Directional prediction, zone 3: 180 < angle < 270
-static void dr_prediction_z3(uint8_t *dst, ptrdiff_t stride, int bs,
+static void dr_prediction_z3(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
                              const uint8_t *above, const uint8_t *left,
 #if CONFIG_INTRA_INTERP
                              INTRA_FILTER filter_type,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                             int upsample_left,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                              int dx, int dy) {
   int r, c, y, base, shift, val;
 
   (void)above;
   (void)dx;
 
   assert(dx == 1);
   assert(dy > 0);
@@ -841,89 +888,95 @@ static void dr_prediction_z3(uint8_t *ds
     const int pad_size = SUBPEL_TAPS >> 1;
     int len, i;
     DECLARE_ALIGNED(16, uint8_t, buf[MAX_SB_SIZE][4 * SUBPEL_SHIFTS]);
     DECLARE_ALIGNED(16, uint8_t, src[(MAX_SB_SIZE + SUBPEL_TAPS) * 4]);
     uint8_t flags[SUBPEL_SHIFTS];
 
     memset(flags, 0, SUBPEL_SHIFTS * sizeof(flags[0]));
     for (i = 0; i < pad_size; ++i) src[4 * i] = left[0];
-    for (i = 0; i < 2 * bs; ++i) src[4 * (i + pad_size)] = left[i];
+    for (i = 0; i < bw + bh; ++i) src[4 * (i + pad_size)] = left[i];
     for (i = 0; i < pad_size; ++i)
-      src[4 * (i + 2 * bs + pad_size)] = left[2 * bs - 1];
+      src[4 * (i + bw + bh + pad_size)] = left[bw + bh - 1];
     flags[0] = 1;
     y = dy;
-    for (c = 0; c < bs; ++c, y += dy) {
+    for (c = 0; c < bw; ++c, y += dy) {
       base = y >> 8;
       shift = y & 0xFF;
       shift = ROUND_POWER_OF_TWO(shift, 8 - SUBPEL_BITS);
       if (shift == SUBPEL_SHIFTS) {
         base += 1;
         shift = 0;
       }
-      len = AOMMIN(bs, 2 * bs - 1 - base);
+      len = AOMMIN(bh, bw + bh - 1 - base);
 
       if (len <= 0) {
-        for (r = 0; r < bs; ++r) {
-          dst[r * stride + c] = left[2 * bs - 1];
+        for (r = 0; r < bh; ++r) {
+          dst[r * stride + c] = left[bw + bh - 1];
         }
         continue;
       }
 
-      if (len <= (bs >> 1) && !flags[shift]) {
+      if (len <= (bh >> 1) && !flags[shift]) {
         base = y >> 8;
         shift = y & 0xFF;
         for (r = 0; r < len; ++r) {
-          val = intra_subpel_interp(base, shift, left, 0, 2 * bs - 1,
+          val = intra_subpel_interp(base, shift, left, 0, bw + bh - 1,
                                     filter_type);
           dst[r * stride + c] = clip_pixel(val);
           ++base;
         }
       } else {
         if (!flags[shift]) {
           const int16_t *filter = av1_intra_filter_kernels[filter_type][shift];
           aom_convolve8_vert(src + 4 * pad_size, 4, buf[0] + 4 * shift,
                              4 * SUBPEL_SHIFTS, NULL, 16, filter, 16,
-                             2 * bs < 16 ? 4 : 4, 2 * bs);
+                             bw + bh < 16 ? 4 : 4, bw + bh);
           flags[shift] = 1;
         }
 
         if (shift == 0) {
           for (r = 0; r < len; ++r) {
             dst[r * stride + c] = left[r + base];
           }
         } else {
           for (r = 0; r < len; ++r) {
             dst[r * stride + c] = buf[r + base][4 * shift];
           }
         }
       }
 
-      if (len < bs) {
-        for (r = len; r < bs; ++r) {
-          dst[r * stride + c] = left[2 * bs - 1];
+      if (len < bh) {
+        for (r = len; r < bh; ++r) {
+          dst[r * stride + c] = left[bw + bh - 1];
         }
       }
     }
     return;
   }
 #endif  // CONFIG_INTRA_INTERP
 
+#if !CONFIG_INTRA_EDGE_UPSAMPLE
+  const int upsample_left = 0;
+#endif  // !CONFIG_INTRA_EDGE_UPSAMPLE
+  const int max_base_y = (bw + bh - 1) << upsample_left;
+  const int frac_bits = 8 - upsample_left;
+  const int base_inc = 1 << upsample_left;
   y = dy;
-  for (c = 0; c < bs; ++c, y += dy) {
-    base = y >> 8;
-    shift = y & 0xFF;
+  for (c = 0; c < bw; ++c, y += dy) {
+    base = y >> frac_bits;
+    shift = (y << upsample_left) & 0xFF;
 
-    for (r = 0; r < bs; ++r, ++base) {
-      if (base < 2 * bs - 1) {
+    for (r = 0; r < bh; ++r, base += base_inc) {
+      if (base < max_base_y) {
         val = left[base] * (256 - shift) + left[base + 1] * shift;
         val = ROUND_POWER_OF_TWO(val, 8);
         dst[r * stride + c] = clip_pixel(val);
       } else {
-        for (; r < bs; ++r) dst[r * stride + c] = left[2 * bs - 1];
+        for (; r < bh; ++r) dst[r * stride + c] = left[max_base_y];
         break;
       }
     }
   }
 }
 
 // Get the shift (up-scaled by 256) in X w.r.t a unit change in Y.
 // If angle > 0 && angle < 90, dx = -((int)(256 / t));
@@ -955,39 +1008,52 @@ static INLINE int get_dy(int angle) {
   }
 }
 
 static void dr_predictor(uint8_t *dst, ptrdiff_t stride, TX_SIZE tx_size,
                          const uint8_t *above, const uint8_t *left,
 #if CONFIG_INTRA_INTERP
                          INTRA_FILTER filter_type,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                         int upsample_above, int upsample_left,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                          int angle) {
   const int dx = get_dx(angle);
   const int dy = get_dy(angle);
-  const int bs = tx_size_wide[tx_size];
+  const int bw = tx_size_wide[tx_size];
+  const int bh = tx_size_high[tx_size];
   assert(angle > 0 && angle < 270);
 
   if (angle > 0 && angle < 90) {
-    dr_prediction_z1(dst, stride, bs, above, left,
+    dr_prediction_z1(dst, stride, bw, bh, above, left,
 #if CONFIG_INTRA_INTERP
                      filter_type,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                     upsample_above,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                      dx, dy);
   } else if (angle > 90 && angle < 180) {
-    dr_prediction_z2(dst, stride, bs, above, left,
+    dr_prediction_z2(dst, stride, bw, bh, above, left,
 #if CONFIG_INTRA_INTERP
                      filter_type,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                     upsample_above, upsample_left,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                      dx, dy);
   } else if (angle > 180 && angle < 270) {
-    dr_prediction_z3(dst, stride, bs, above, left,
+    dr_prediction_z3(dst, stride, bw, bh, above, left,
 #if CONFIG_INTRA_INTERP
                      filter_type,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                     upsample_left,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                      dx, dy);
   } else if (angle == 90) {
     pred[V_PRED][tx_size](dst, stride, above, left);
   } else if (angle == 180) {
     pred[H_PRED][tx_size](dst, stride, above, left);
   }
 }
 
@@ -1019,198 +1085,219 @@ static int highbd_intra_subpel_interp(in
     }
   }
 
   return val;
 }
 #endif  // CONFIG_INTRA_INTERP
 
 // Directional prediction, zone 1: 0 < angle < 90
-static void highbd_dr_prediction_z1(uint16_t *dst, ptrdiff_t stride, int bs,
-                                    const uint16_t *above, const uint16_t *left,
+static void highbd_dr_prediction_z1(uint16_t *dst, ptrdiff_t stride, int bw,
+                                    int bh, const uint16_t *above,
+                                    const uint16_t *left,
 #if CONFIG_INTRA_INTERP
                                     INTRA_FILTER filter_type,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                                    int upsample_above,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                                     int dx, int dy, int bd) {
   int r, c, x, base, shift, val;
 
   (void)left;
   (void)dy;
   assert(dy == 1);
   assert(dx > 0);
 
+#if !CONFIG_INTRA_EDGE_UPSAMPLE
+  const int upsample_above = 0;
+#endif  // !CONFIG_INTRA_EDGE_UPSAMPLE
+  const int max_base_x = ((bw + bh) - 1) << upsample_above;
+  const int frac_bits = 8 - upsample_above;
+  const int base_inc = 1 << upsample_above;
   x = dx;
-  for (r = 0; r < bs; ++r, dst += stride, x += dx) {
-    base = x >> 8;
-    shift = x & 0xFF;
+  for (r = 0; r < bh; ++r, dst += stride, x += dx) {
+    base = x >> frac_bits;
+    shift = (x << upsample_above) & 0xFF;
 
-    if (base >= 2 * bs - 1) {
-      int i;
-      for (i = r; i < bs; ++i) {
-        aom_memset16(dst, above[2 * bs - 1], bs);
+    if (base >= max_base_x) {
+      for (int i = r; i < bh; ++i) {
+        aom_memset16(dst, above[max_base_x], bw);
         dst += stride;
       }
       return;
     }
 
-    for (c = 0; c < bs; ++c, ++base) {
-      if (base < 2 * bs - 1) {
+    for (c = 0; c < bw; ++c, base += base_inc) {
+      if (base < max_base_x) {
 #if CONFIG_INTRA_INTERP
-        val = highbd_intra_subpel_interp(base, shift, above, 0, 2 * bs - 1,
+        val = highbd_intra_subpel_interp(base, shift, above, 0, bw + bh - 1,
                                          filter_type);
 #else
         val = above[base] * (256 - shift) + above[base + 1] * shift;
         val = ROUND_POWER_OF_TWO(val, 8);
 #endif  // CONFIG_INTRA_INTERP
         dst[c] = clip_pixel_highbd(val, bd);
       } else {
-        dst[c] = above[2 * bs - 1];
+        dst[c] = above[max_base_x];
       }
     }
   }
 }
 
 // Directional prediction, zone 2: 90 < angle < 180
-static void highbd_dr_prediction_z2(uint16_t *dst, ptrdiff_t stride, int bs,
-                                    const uint16_t *above, const uint16_t *left,
+static void highbd_dr_prediction_z2(uint16_t *dst, ptrdiff_t stride, int bw,
+                                    int bh, const uint16_t *above,
+                                    const uint16_t *left,
 #if CONFIG_INTRA_INTERP
                                     INTRA_FILTER filter_type,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                                    int upsample_above, int upsample_left,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                                     int dx, int dy, int bd) {
   int r, c, x, y, shift, val, base;
 
   assert(dx > 0);
   assert(dy > 0);
 
-  for (r = 0; r < bs; ++r) {
-    for (c = 0; c < bs; ++c) {
+#if !CONFIG_INTRA_EDGE_UPSAMPLE
+  const int upsample_above = 0;
+  const int upsample_left = 0;
+#endif  // !CONFIG_INTRA_EDGE_UPSAMPLE
+  const int min_base_x = -(1 << upsample_above);
+  const int frac_bits_x = 8 - upsample_above;
+  const int frac_bits_y = 8 - upsample_left;
+  for (r = 0; r < bh; ++r) {
+    for (c = 0; c < bw; ++c) {
       y = r + 1;
       x = (c << 8) - y * dx;
-      base = x >> 8;
-      if (base >= -1) {
-        shift = x & 0xFF;
+      base = x >> frac_bits_x;
+      if (base >= min_base_x) {
+        shift = (x * (1 << upsample_above)) & 0xFF;
 #if CONFIG_INTRA_INTERP
-        val = highbd_intra_subpel_interp(base, shift, above, -1, bs - 1,
+        val = highbd_intra_subpel_interp(base, shift, above, -1, bw - 1,
                                          filter_type);
 #else
         val = above[base] * (256 - shift) + above[base + 1] * shift;
         val = ROUND_POWER_OF_TWO(val, 8);
 #endif  // CONFIG_INTRA_INTERP
       } else {
         x = c + 1;
         y = (r << 8) - x * dy;
-        base = y >> 8;
-        shift = y & 0xFF;
+        base = y >> frac_bits_y;
+        shift = (y * (1 << upsample_left)) & 0xFF;
 #if CONFIG_INTRA_INTERP
-        val = highbd_intra_subpel_interp(base, shift, left, -1, bs - 1,
+        val = highbd_intra_subpel_interp(base, shift, left, -1, bh - 1,
                                          filter_type);
 #else
         val = left[base] * (256 - shift) + left[base + 1] * shift;
         val = ROUND_POWER_OF_TWO(val, 8);
 #endif  // CONFIG_INTRA_INTERP
       }
       dst[c] = clip_pixel_highbd(val, bd);
     }
     dst += stride;
   }
 }
 
 // Directional prediction, zone 3: 180 < angle < 270
-static void highbd_dr_prediction_z3(uint16_t *dst, ptrdiff_t stride, int bs,
-                                    const uint16_t *above, const uint16_t *left,
+static void highbd_dr_prediction_z3(uint16_t *dst, ptrdiff_t stride, int bw,
+                                    int bh, const uint16_t *above,
+                                    const uint16_t *left,
 #if CONFIG_INTRA_INTERP
                                     INTRA_FILTER filter_type,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                                    int upsample_left,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                                     int dx, int dy, int bd) {
   int r, c, y, base, shift, val;
 
   (void)above;
   (void)dx;
   assert(dx == 1);
   assert(dy > 0);
 
+#if !CONFIG_INTRA_EDGE_UPSAMPLE
+  const int upsample_left = 0;
+#endif  // !CONFIG_INTRA_EDGE_UPSAMPLE
+  const int max_base_y = (bw + bh - 1) << upsample_left;
+  const int frac_bits = 8 - upsample_left;
+  const int base_inc = 1 << upsample_left;
   y = dy;
-  for (c = 0; c < bs; ++c, y += dy) {
-    base = y >> 8;
-    shift = y & 0xFF;
+  for (c = 0; c < bw; ++c, y += dy) {
+    base = y >> frac_bits;
+    shift = (y << upsample_left) & 0xFF;
 
-    for (r = 0; r < bs; ++r, ++base) {
-      if (base < 2 * bs - 1) {
+    for (r = 0; r < bh; ++r, base += base_inc) {
+      if (base < max_base_y) {
 #if CONFIG_INTRA_INTERP
-        val = highbd_intra_subpel_interp(base, shift, left, 0, 2 * bs - 1,
+        val = highbd_intra_subpel_interp(base, shift, left, 0, bw + bh - 1,
                                          filter_type);
 #else
         val = left[base] * (256 - shift) + left[base + 1] * shift;
         val = ROUND_POWER_OF_TWO(val, 8);
 #endif  // CONFIG_INTRA_INTERP
         dst[r * stride + c] = clip_pixel_highbd(val, bd);
       } else {
-        for (; r < bs; ++r) dst[r * stride + c] = left[2 * bs - 1];
+        for (; r < bh; ++r) dst[r * stride + c] = left[max_base_y];
         break;
       }
     }
   }
 }
 
-static INLINE void highbd_v_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
-                                      const uint16_t *above,
-                                      const uint16_t *left, int bd) {
-  int r;
-  (void)left;
-  (void)bd;
-  for (r = 0; r < bs; r++) {
-    memcpy(dst, above, bs * sizeof(uint16_t));
-    dst += stride;
-  }
-}
-
-static INLINE void highbd_h_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
-                                      const uint16_t *above,
-                                      const uint16_t *left, int bd) {
-  int r;
-  (void)above;
-  (void)bd;
-  for (r = 0; r < bs; r++) {
-    aom_memset16(dst, left[r], bs);
-    dst += stride;
-  }
-}
-
-static void highbd_dr_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
-                                const uint16_t *above, const uint16_t *left,
+static void highbd_dr_predictor(uint16_t *dst, ptrdiff_t stride,
+                                TX_SIZE tx_size, const uint16_t *above,
+                                const uint16_t *left,
 #if CONFIG_INTRA_INTERP
                                 INTRA_FILTER filter,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                                int upsample_above, int upsample_left,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                                 int angle, int bd) {
   const int dx = get_dx(angle);
   const int dy = get_dy(angle);
+  const int bw = tx_size_wide[tx_size];
+  const int bh = tx_size_high[tx_size];
   assert(angle > 0 && angle < 270);
 
   if (angle > 0 && angle < 90) {
-    highbd_dr_prediction_z1(dst, stride, bs, above, left,
+    highbd_dr_prediction_z1(dst, stride, bw, bh, above, left,
 #if CONFIG_INTRA_INTERP
                             filter,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                            upsample_above,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                             dx, dy, bd);
   } else if (angle > 90 && angle < 180) {
-    highbd_dr_prediction_z2(dst, stride, bs, above, left,
+    highbd_dr_prediction_z2(dst, stride, bw, bh, above, left,
 #if CONFIG_INTRA_INTERP
                             filter,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                            upsample_above, upsample_left,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                             dx, dy, bd);
   } else if (angle > 180 && angle < 270) {
-    highbd_dr_prediction_z3(dst, stride, bs, above, left,
+    highbd_dr_prediction_z3(dst, stride, bw, bh, above, left,
 #if CONFIG_INTRA_INTERP
                             filter,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                            upsample_left,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                             dx, dy, bd);
   } else if (angle == 90) {
-    highbd_v_predictor(dst, stride, bs, above, left, bd);
+    pred_high[V_PRED][tx_size](dst, stride, above, left, bd);
   } else if (angle == 180) {
-    highbd_h_predictor(dst, stride, bs, above, left, bd);
+    pred_high[H_PRED][tx_size](dst, stride, above, left, bd);
   }
 }
 #endif  // CONFIG_HIGHBITDEPTH
 #endif  // CONFIG_EXT_INTRA
 
 #if CONFIG_FILTER_INTRA
 #if USE_3TAP_INTRA_FILTER
 static int filter_intra_taps_3[TX_SIZES][FILTER_INTRA_MODES][3] = {
@@ -1852,121 +1939,195 @@ static void highbd_filter_intra_predicto
 #endif  // CONFIG_HIGHBITDEPTH
 #endif  // CONFIG_FILTER_INTRA
 
 #if CONFIG_INTRA_EDGE
 static int intra_edge_filter_strength(int bsz, int delta) {
   const int d = abs(delta);
   int strength = 0;
 
-  if (bsz == 8) {
-    if (d < 8) {
-      strength = 0;
-    } else if (d < 32) {
-      strength = 1;
-    } else if (d < 90) {
-      strength = 3;
-    }
-  } else if (bsz == 16) {
-    if (d < 4) {
-      strength = 0;
-    } else if (d < 16) {
-      strength = 1;
-    } else if (d < 90) {
-      strength = 3;
-    }
-  } else if (bsz == 32) {
-    if (d < 16) {
-      strength = 2;
-    } else if (d < 90) {
-      strength = 3;
-    }
+  switch (bsz) {
+    case 4:
+      if (d < 56) {
+        strength = 0;
+      } else if (d < 90) {
+        strength = 1;
+      }
+      break;
+    case 8:
+      if (d < 8) {
+        strength = 0;
+      } else if (d < 32) {
+        strength = 1;
+      } else if (d < 90) {
+        strength = 3;
+      }
+      break;
+    case 16:
+      if (d < 4) {
+        strength = 0;
+      } else if (d < 16) {
+        strength = 1;
+      } else if (d < 90) {
+        strength = 3;
+      }
+      break;
+    case 32:
+      if (d < 16) {
+        strength = 2;
+      } else if (d < 90) {
+        strength = 3;
+      }
+      break;
+    default: strength = 0; break;
   }
 
   return strength;
 }
 
 static void filter_intra_edge(uint8_t *p, int sz, int strength) {
   if (!strength) return;
 
-  const int kernel[3][5] = {
+  const int kernel[INTRA_EDGE_FILT][INTRA_EDGE_TAPS] = {
     { 0, 4, 8, 4, 0 }, { 0, 5, 6, 5, 0 }, { 2, 4, 4, 4, 2 }
   };
   const int filt = strength - 1;
   uint8_t edge[129];
 
   memcpy(edge, p, sz * sizeof(*p));
   for (int i = 1; i < sz - 1; i++) {
     int s = 0;
-    for (int j = 0; j < 5; j++) {
+    for (int j = 0; j < INTRA_EDGE_TAPS; j++) {
       int k = i - 2 + j;
       k = (k < 0) ? 0 : k;
       k = (k > sz - 1) ? sz - 1 : k;
       s += edge[k] * kernel[filt][j];
     }
     s = (s + 8) >> 4;
     p[i] = s;
   }
 }
 
 #if CONFIG_HIGHBITDEPTH
 static void filter_intra_edge_high(uint16_t *p, int sz, int strength) {
   if (!strength) return;
 
-  const int kernel[3][5] = {
+  const int kernel[INTRA_EDGE_FILT][INTRA_EDGE_TAPS] = {
     { 0, 4, 8, 4, 0 }, { 0, 5, 6, 5, 0 }, { 2, 4, 4, 4, 2 }
   };
   const int filt = strength - 1;
   uint16_t edge[129];
 
   memcpy(edge, p, sz * sizeof(*p));
   for (int i = 1; i < sz - 1; i++) {
     int s = 0;
-    for (int j = 0; j < 5; j++) {
+    for (int j = 0; j < INTRA_EDGE_TAPS; j++) {
       int k = i - 2 + j;
       k = (k < 0) ? 0 : k;
       k = (k > sz - 1) ? sz - 1 : k;
       s += edge[k] * kernel[filt][j];
     }
     s = (s + 8) >> 4;
     p[i] = s;
   }
 }
+#endif  // CONFIG_HIGHBITDEPTH
+
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+static int use_intra_edge_upsample(int bsz, int delta) {
+  const int d = abs(delta);
+  return (bsz == 4 && d > 0 && d < 56);
+}
+
+static void upsample_intra_edge(uint8_t *p, int sz) {
+  // interpolate half-sample positions
+  assert(sz <= MAX_UPSAMPLE_SZ);
+
+  uint8_t in[MAX_UPSAMPLE_SZ + 3];
+  // copy p[-1..(sz-1)] and extend first and last samples
+  in[0] = p[-1];
+  in[1] = p[-1];
+  for (int i = 0; i < sz; i++) {
+    in[i + 2] = p[i];
+  }
+  in[sz + 2] = p[sz - 1];
+
+  // interpolate half-sample edge positions
+  p[-2] = in[0];
+  for (int i = 0; i < sz; i++) {
+    int s = -in[i] + (9 * in[i + 1]) + (9 * in[i + 2]) - in[i + 3];
+    s = clip_pixel((s + 8) >> 4);
+    p[2 * i - 1] = s;
+    p[2 * i] = in[i + 2];
+  }
+}
+
+#if CONFIG_HIGHBITDEPTH
+static void upsample_intra_edge_high(uint16_t *p, int sz, int bd) {
+  // interpolate half-sample positions
+  assert(sz <= MAX_UPSAMPLE_SZ);
+
+  uint16_t in[MAX_UPSAMPLE_SZ + 3];
+  // copy p[-1..(sz-1)] and extend first and last samples
+  in[0] = p[-1];
+  in[1] = p[-1];
+  for (int i = 0; i < sz; i++) {
+    in[i + 2] = p[i];
+  }
+  in[sz + 2] = p[sz - 1];
+
+  // interpolate half-sample edge positions
+  p[-2] = in[0];
+  for (int i = 0; i < sz; i++) {
+    int s = -in[i] + (9 * in[i + 1]) + (9 * in[i + 2]) - in[i + 3];
+    s = (s + 8) >> 4;
+    s = clip_pixel_highbd(s, bd);
+    p[2 * i - 1] = s;
+    p[2 * i] = in[i + 2];
+  }
+}
+#endif  // CONFIG_HIGHBITDEPTH
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
+
 #endif  // CONFIG_INTRA_EDGE
-#endif  // CONFIG_HIGHBITDEPTH
 
 #if CONFIG_HIGHBITDEPTH
 static void build_intra_predictors_high(
     const MACROBLOCKD *xd, const uint8_t *ref8, int ref_stride, uint8_t *dst8,
     int dst_stride, PREDICTION_MODE mode, TX_SIZE tx_size, int n_top_px,
     int n_topright_px, int n_left_px, int n_bottomleft_px, int plane) {
   int i;
   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
   uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
   DECLARE_ALIGNED(16, uint16_t, left_data[MAX_TX_SIZE * 2 + 16]);
   DECLARE_ALIGNED(16, uint16_t, above_data[MAX_TX_SIZE * 2 + 16]);
   uint16_t *const above_row = above_data + 16;
   uint16_t *const left_col = left_data + 16;
-  const int bs = tx_size_wide[tx_size];
+  const int txwpx = tx_size_wide[tx_size];
+  const int txhpx = tx_size_high[tx_size];
+#if !(CONFIG_RECT_INTRA_PRED && CONFIG_RECT_TX && \
+      (CONFIG_VAR_TX || CONFIG_EXT_TX))
+  assert(txwpx == txhpx);
+#endif  // !(CONFIG_RECT_INTRA_PRED && CONFIG_RECT_TX &&
+        // (CONFIG_VAR_TX || CONFIG_EXT_TX))
   int need_left = extend_modes[mode] & NEED_LEFT;
   int need_above = extend_modes[mode] & NEED_ABOVE;
   int need_above_left = extend_modes[mode] & NEED_ABOVELEFT;
   const uint16_t *above_ref = ref - ref_stride;
 #if CONFIG_EXT_INTRA
   int p_angle = 0;
   const int is_dr_mode = av1_is_directional_mode(mode, xd->mi[0]->mbmi.sb_type);
 #endif  // CONFIG_EXT_INTRA
 #if CONFIG_FILTER_INTRA
   const FILTER_INTRA_MODE_INFO *filter_intra_mode_info =
       &xd->mi[0]->mbmi.filter_intra_mode_info;
   const FILTER_INTRA_MODE filter_intra_mode =
       filter_intra_mode_info->filter_intra_mode[plane != 0];
 #endif  // CONFIG_FILTER_INTRA
   int base = 128 << (xd->bd - 8);
-  assert(tx_size_wide[tx_size] == tx_size_high[tx_size]);
 
   // base-1 base-1 base-1 .. base-1 base-1 base-1 base-1 base-1 base-1
   // base+1   A      B  ..     Y      Z
   // base+1   C      D  ..     W      X
   // base+1   E      F  ..     U      V
   // base+1   G      H  ..     S      T      T      T      T      T
   aom_memset16(left_data, base + 1, sizeof(left_data) / sizeof(*left_data));
 
@@ -1998,19 +2159,19 @@ static void build_intra_predictors_high(
     int val;
     if (need_left) {
       val = (n_top_px > 0) ? above_ref[0] : base + 1;
     } else {
       val = (n_left_px > 0) ? ref[-1] : base - 1;
     }
 #else
     const int val = need_left ? base + 1 : base - 1;
-#endif
-    for (i = 0; i < bs; ++i) {
-      aom_memset16(dst, val, bs);
+#endif  // CONFIG_INTRA_EDGE
+    for (i = 0; i < txhpx; ++i) {
+      aom_memset16(dst, val, txwpx);
       dst += dst_stride;
     }
     return;
   }
 
   // NEED_LEFT
   if (need_left) {
 #if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA
@@ -2020,36 +2181,37 @@ static void build_intra_predictors_high(
       need_bottom = 0;
 #endif  // CONFIG_FILTER_INTRA
 #if CONFIG_EXT_INTRA
     if (is_dr_mode) need_bottom = p_angle > 180;
 #endif  // CONFIG_EXT_INTRA
 #else
     const int need_bottom = !!(extend_modes[mode] & NEED_BOTTOMLEFT);
 #endif  // CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA
+    const int num_left_pixels_needed = txhpx + (need_bottom ? txwpx : 0);
     i = 0;
     if (n_left_px > 0) {
       for (; i < n_left_px; i++) left_col[i] = ref[i * ref_stride - 1];
       if (need_bottom && n_bottomleft_px > 0) {
-        assert(i == bs);
-        for (; i < bs + n_bottomleft_px; i++)
+        assert(i == txhpx);
+        for (; i < txhpx + n_bottomleft_px; i++)
           left_col[i] = ref[i * ref_stride - 1];
       }
-      if (i < (bs << need_bottom))
-        aom_memset16(&left_col[i], left_col[i - 1], (bs << need_bottom) - i);
+      if (i < num_left_pixels_needed)
+        aom_memset16(&left_col[i], left_col[i - 1], num_left_pixels_needed - i);
     } else {
 #if CONFIG_INTRA_EDGE
       if (n_top_px > 0) {
-        aom_memset16(left_col, above_ref[0], bs << need_bottom);
+        aom_memset16(left_col, above_ref[0], num_left_pixels_needed);
       } else {
-#endif
-        aom_memset16(left_col, base + 1, bs << need_bottom);
+#endif  // CONFIG_INTRA_EDGE
+        aom_memset16(left_col, base + 1, num_left_pixels_needed);
 #if CONFIG_INTRA_EDGE
       }
-#endif
+#endif  // CONFIG_INTRA_EDGE
     }
   }
 
   // NEED_ABOVE
   if (need_above) {
 #if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA
     int need_right = !!(extend_modes[mode] & NEED_ABOVERIGHT);
 #if CONFIG_FILTER_INTRA
@@ -2057,37 +2219,39 @@ static void build_intra_predictors_high(
       need_right = 1;
 #endif  // CONFIG_FILTER_INTRA
 #if CONFIG_EXT_INTRA
     if (is_dr_mode) need_right = p_angle < 90;
 #endif  // CONFIG_EXT_INTRA
 #else
     const int need_right = !!(extend_modes[mode] & NEED_ABOVERIGHT);
 #endif  // CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA
+    const int num_top_pixels_needed = txwpx + (need_right ? txhpx : 0);
     if (n_top_px > 0) {
       memcpy(above_row, above_ref, n_top_px * sizeof(above_ref[0]));
       i = n_top_px;
       if (need_right && n_topright_px > 0) {
-        assert(n_top_px == bs);
-        memcpy(above_row + bs, above_ref + bs,
+        assert(n_top_px == txwpx);
+        memcpy(above_row + txwpx, above_ref + txwpx,
                n_topright_px * sizeof(above_ref[0]));
         i += n_topright_px;
       }
-      if (i < (bs << need_right))
-        aom_memset16(&above_row[i], above_row[i - 1], (bs << need_right) - i);
+      if (i < num_top_pixels_needed)
+        aom_memset16(&above_row[i], above_row[i - 1],
+                     num_top_pixels_needed - i);
     } else {
 #if CONFIG_INTRA_EDGE
       if (n_left_px > 0) {
-        aom_memset16(above_row, ref[-1], bs << need_right);
+        aom_memset16(above_row, ref[-1], num_top_pixels_needed);
       } else {
-#endif
-        aom_memset16(above_row, base - 1, bs << need_right);
+#endif  // CONFIG_INTRA_EDGE
+        aom_memset16(above_row, base - 1, num_top_pixels_needed);
 #if CONFIG_INTRA_EDGE
       }
-#endif
+#endif  // CONFIG_INTRA_EDGE
     }
   }
 
   if (need_above_left) {
 #if CONFIG_INTRA_EDGE
     if (n_top_px > 0 && n_left_px > 0) {
       above_row[-1] = above_ref[-1];
     } else if (n_top_px > 0) {
@@ -2095,57 +2259,73 @@ static void build_intra_predictors_high(
     } else if (n_left_px > 0) {
       above_row[-1] = ref[-1];
     } else {
       above_row[-1] = base;
     }
 #else
     above_row[-1] =
         n_top_px > 0 ? (n_left_px > 0 ? above_ref[-1] : base + 1) : base - 1;
-#endif
+#endif  // CONFIG_INTRA_EDGE
     left_col[-1] = above_row[-1];
   }
 
-#if CONFIG_EXT_INTRA && CONFIG_INTRA_EDGE
-  if (is_dr_mode && p_angle != 90 && p_angle != 180) {
-    const int ab_le = need_above_left ? 1 : 0;
-    if (need_above && n_top_px > 0) {
-      const int strength = intra_edge_filter_strength(bs, p_angle - 90);
-      const int need_right = p_angle < 90;
-      const int n_px = n_top_px + ab_le + (need_right ? n_topright_px : 0);
-      filter_intra_edge_high(above_row - ab_le, n_px, strength);
-    }
-    if (need_left && n_left_px > 0) {
-      const int strength = intra_edge_filter_strength(bs, p_angle - 180);
-      const int need_bottom = p_angle > 180;
-      const int n_px = n_left_px + ab_le + (need_bottom ? n_bottomleft_px : 0);
-      filter_intra_edge_high(left_col - ab_le, n_px, strength);
-    }
-  }
-#endif
-
 #if CONFIG_FILTER_INTRA
   if (filter_intra_mode_info->use_filter_intra_mode[plane != 0]) {
-    highbd_filter_intra_predictors(filter_intra_mode, dst, dst_stride, bs,
+    // TODO(huisu): Make these work with rectangular blocks.
+    highbd_filter_intra_predictors(filter_intra_mode, dst, dst_stride, txwpx,
                                    above_row, left_col, xd->bd);
     return;
   }
 #endif  // CONFIG_FILTER_INTRA
 
 #if CONFIG_EXT_INTRA
   if (is_dr_mode) {
 #if CONFIG_INTRA_INTERP
     INTRA_FILTER filter = INTRA_FILTER_LINEAR;
     if (plane == 0 && av1_is_intra_filter_switchable(p_angle))
       filter = xd->mi[0]->mbmi.intra_filter;
 #endif  // CONFIG_INTRA_INTERP
-    highbd_dr_predictor(dst, dst_stride, bs, above_row, left_col,
+#if CONFIG_INTRA_EDGE
+    const int need_right = p_angle < 90;
+    const int need_bottom = p_angle > 180;
+    if (p_angle != 90 && p_angle != 180) {
+      const int ab_le = need_above_left ? 1 : 0;
+      if (need_above && n_top_px > 0) {
+        const int strength = intra_edge_filter_strength(txwpx, p_angle - 90);
+        const int n_px = n_top_px + ab_le + (need_right ? n_topright_px : 0);
+        filter_intra_edge_high(above_row - ab_le, n_px, strength);
+      }
+      if (need_left && n_left_px > 0) {
+        const int strength = intra_edge_filter_strength(txhpx, p_angle - 180);
+        const int n_px =
+            n_left_px + ab_le + (need_bottom ? n_bottomleft_px : 0);
+        filter_intra_edge_high(left_col - ab_le, n_px, strength);
+      }
+    }
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+    const int upsample_above = use_intra_edge_upsample(txwpx, p_angle - 90);
+    if (upsample_above) {
+      const int n_px = txwpx + (need_right ? txhpx : 0);
+      upsample_intra_edge_high(above_row, n_px, xd->bd);
+    }
+    const int upsample_left = use_intra_edge_upsample(txhpx, p_angle - 180);
+    if (upsample_left) {
+      const int n_px = txhpx + (need_bottom ? txwpx : 0);
+      upsample_intra_edge_high(left_col, n_px, xd->bd);
+    }
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
+#endif  // CONFIG_INTRA_EDGE
+    highbd_dr_predictor(dst, dst_stride, tx_size, above_row, left_col,
 #if CONFIG_INTRA_INTERP
                         filter,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                        upsample_above, upsample_left,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                         p_angle, xd->bd);
     return;
   }
 #endif  // CONFIG_EXT_INTRA
 
   // predict
   if (mode == DC_PRED) {
     dc_pred_high[n_left_px > 0][n_top_px > 0][tx_size](
@@ -2163,32 +2343,37 @@ static void build_intra_predictors(const
                                    int n_left_px, int n_bottomleft_px,
                                    int plane) {
   int i;
   const uint8_t *above_ref = ref - ref_stride;
   DECLARE_ALIGNED(16, uint8_t, left_data[MAX_TX_SIZE * 2 + 16]);
   DECLARE_ALIGNED(16, uint8_t, above_data[MAX_TX_SIZE * 2 + 16]);
   uint8_t *const above_row = above_data + 16;
   uint8_t *const left_col = left_data + 16;
-  const int bs = tx_size_wide[tx_size];
+  const int txwpx = tx_size_wide[tx_size];
+  const int txhpx = tx_size_high[tx_size];
+#if !(CONFIG_RECT_INTRA_PRED && CONFIG_RECT_TX && \
+      (CONFIG_VAR_TX || CONFIG_EXT_TX))
+  assert(txwpx == txhpx);
+#endif  // !(CONFIG_RECT_INTRA_PRED && CONFIG_RECT_TX &&
+        // (CONFIG_VAR_TX || CONFIG_EXT_TX))
   int need_left = extend_modes[mode] & NEED_LEFT;
   int need_above = extend_modes[mode] & NEED_ABOVE;
   int need_above_left = extend_modes[mode] & NEED_ABOVELEFT;
 #if CONFIG_EXT_INTRA
   int p_angle = 0;
   const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
   const int is_dr_mode = av1_is_directional_mode(mode, mbmi->sb_type);
 #endif  // CONFIG_EXT_INTRA
 #if CONFIG_FILTER_INTRA
   const FILTER_INTRA_MODE_INFO *filter_intra_mode_info =
       &xd->mi[0]->mbmi.filter_intra_mode_info;
   const FILTER_INTRA_MODE filter_intra_mode =
       filter_intra_mode_info->filter_intra_mode[plane != 0];
 #endif  // CONFIG_FILTER_INTRA
-  assert(tx_size_wide[tx_size] == tx_size_high[tx_size]);
 
   // 127 127 127 .. 127 127 127 127 127 127
   // 129  A   B  ..  Y   Z
   // 129  C   D  ..  W   X
   // 129  E   F  ..  U   V
   // 129  G   H  ..  S   T   T   T   T   T
   // ..
   memset(left_data, 129, sizeof(left_data));
@@ -2222,19 +2407,19 @@ static void build_intra_predictors(const
     int val;
     if (need_left) {
       val = (n_top_px > 0) ? above_ref[0] : 129;
     } else {
       val = (n_left_px > 0) ? ref[-1] : 127;
     }
 #else
     const int val = need_left ? 129 : 127;
-#endif
-    for (i = 0; i < bs; ++i) {
-      memset(dst, val, bs);
+#endif  // CONFIG_INTRA_EDGE
+    for (i = 0; i < txhpx; ++i) {
+      memset(dst, val, txwpx);
       dst += dst_stride;
     }
     return;
   }
 
   // NEED_LEFT
   if (need_left) {
 #if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA
@@ -2244,36 +2429,37 @@ static void build_intra_predictors(const
       need_bottom = 0;
 #endif  // CONFIG_FILTER_INTRA
 #if CONFIG_EXT_INTRA
     if (is_dr_mode) need_bottom = p_angle > 180;
 #endif  // CONFIG_EXT_INTRA
 #else
     const int need_bottom = !!(extend_modes[mode] & NEED_BOTTOMLEFT);
 #endif  // CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA
+    const int num_left_pixels_needed = txhpx + (need_bottom ? txwpx : 0);
     i = 0;
     if (n_left_px > 0) {
       for (; i < n_left_px; i++) left_col[i] = ref[i * ref_stride - 1];
       if (need_bottom && n_bottomleft_px > 0) {
-        assert(i == bs);
-        for (; i < bs + n_bottomleft_px; i++)
+        assert(i == txhpx);
+        for (; i < txhpx + n_bottomleft_px; i++)
           left_col[i] = ref[i * ref_stride - 1];
       }
-      if (i < (bs << need_bottom))
-        memset(&left_col[i], left_col[i - 1], (bs << need_bottom) - i);
+      if (i < num_left_pixels_needed)
+        memset(&left_col[i], left_col[i - 1], num_left_pixels_needed - i);
     } else {
 #if CONFIG_INTRA_EDGE
       if (n_top_px > 0) {
-        memset(left_col, above_ref[0], bs << need_bottom);
+        memset(left_col, above_ref[0], num_left_pixels_needed);
       } else {
-#endif
-        memset(left_col, 129, bs << need_bottom);
+#endif  // CONFIG_INTRA_EDGE
+        memset(left_col, 129, num_left_pixels_needed);
 #if CONFIG_INTRA_EDGE
       }
-#endif
+#endif  // CONFIG_INTRA_EDGE
     }
   }
 
   // NEED_ABOVE
   if (need_above) {
 #if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA
     int need_right = !!(extend_modes[mode] & NEED_ABOVERIGHT);
 #if CONFIG_FILTER_INTRA
@@ -2281,92 +2467,110 @@ static void build_intra_predictors(const
       need_right = 1;
 #endif  // CONFIG_FILTER_INTRA
 #if CONFIG_EXT_INTRA
     if (is_dr_mode) need_right = p_angle < 90;
 #endif  // CONFIG_EXT_INTRA
 #else
     const int need_right = !!(extend_modes[mode] & NEED_ABOVERIGHT);
 #endif  // CONFIG_EXT_INTRA || CONFIG_FITLER_INTRA
+    const int num_top_pixels_needed = txwpx + (need_right ? txhpx : 0);
     if (n_top_px > 0) {
       memcpy(above_row, above_ref, n_top_px);
       i = n_top_px;
       if (need_right && n_topright_px > 0) {
-        assert(n_top_px == bs);
-        memcpy(above_row + bs, above_ref + bs, n_topright_px);
+        assert(n_top_px == txwpx);
+        memcpy(above_row + txwpx, above_ref + txwpx, n_topright_px);
         i += n_topright_px;
       }
-      if (i < (bs << need_right))
-        memset(&above_row[i], above_row[i - 1], (bs << need_right) - i);
+      if (i < num_top_pixels_needed)
+        memset(&above_row[i], above_row[i - 1], num_top_pixels_needed - i);
     } else {
 #if CONFIG_INTRA_EDGE
       if (n_left_px > 0) {
-        memset(above_row, ref[-1], bs << need_right);
+        memset(above_row, ref[-1], num_top_pixels_needed);
       } else {
-#endif
-        memset(above_row, 127, bs << need_right);
+#endif  // CONFIG_INTRA_EDGE
+        memset(above_row, 127, num_top_pixels_needed);
 #if CONFIG_INTRA_EDGE
       }
-#endif
+#endif  // CONFIG_INTRA_EDGE
     }
   }
 
   if (need_above_left) {
 #if CONFIG_INTRA_EDGE
     if (n_top_px > 0 && n_left_px > 0) {
       above_row[-1] = above_ref[-1];
     } else if (n_top_px > 0) {
       above_row[-1] = above_ref[0];
     } else if (n_left_px > 0) {
       above_row[-1] = ref[-1];
     } else {
       above_row[-1] = 128;
     }
 #else
     above_row[-1] = n_top_px > 0 ? (n_left_px > 0 ? above_ref[-1] : 129) : 127;
-#endif
+#endif  // CONFIG_INTRA_EDGE
     left_col[-1] = above_row[-1];
   }
 
-#if CONFIG_EXT_INTRA && CONFIG_INTRA_EDGE
-  if (is_dr_mode && p_angle != 90 && p_angle != 180) {
-    const int ab_le = need_above_left ? 1 : 0;
-    if (need_above && n_top_px > 0) {
-      const int strength = intra_edge_filter_strength(bs, p_angle - 90);
-      const int need_right = p_angle < 90;
-      const int n_px = n_top_px + ab_le + (need_right ? n_topright_px : 0);
-      filter_intra_edge(above_row - ab_le, n_px, strength);
-    }
-    if (need_left && n_left_px > 0) {
-      const int strength = intra_edge_filter_strength(bs, p_angle - 180);
-      const int need_bottom = p_angle > 180;
-      const int n_px = n_left_px + ab_le + (need_bottom ? n_bottomleft_px : 0);
-      filter_intra_edge(left_col - ab_le, n_px, strength);
-    }
-  }
-#endif
-
 #if CONFIG_FILTER_INTRA
   if (filter_intra_mode_info->use_filter_intra_mode[plane != 0]) {
-    filter_intra_predictors(filter_intra_mode, dst, dst_stride, bs, above_row,
-                            left_col);
+    // TODO(huisu): Make these work with rectangular blocks.
+    filter_intra_predictors(filter_intra_mode, dst, dst_stride, txwpx,
+                            above_row, left_col);
     return;
   }
 #endif  // CONFIG_FILTER_INTRA
+
 #if CONFIG_EXT_INTRA
   if (is_dr_mode) {
 #if CONFIG_INTRA_INTERP
     INTRA_FILTER filter = INTRA_FILTER_LINEAR;
     if (plane == 0 && av1_is_intra_filter_switchable(p_angle))
       filter = xd->mi[0]->mbmi.intra_filter;
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE
+    const int need_right = p_angle < 90;
+    const int need_bottom = p_angle > 180;
+    if (p_angle != 90 && p_angle != 180) {
+      const int ab_le = need_above_left ? 1 : 0;
+      if (need_above && n_top_px > 0) {
+        const int strength = intra_edge_filter_strength(txwpx, p_angle - 90);
+        const int n_px = n_top_px + ab_le + (need_right ? n_topright_px : 0);
+        filter_intra_edge(above_row - ab_le, n_px, strength);
+      }
+      if (need_left && n_left_px > 0) {
+        const int strength = intra_edge_filter_strength(txhpx, p_angle - 180);
+        const int n_px =
+            n_left_px + ab_le + (need_bottom ? n_bottomleft_px : 0);
+        filter_intra_edge(left_col - ab_le, n_px, strength);
+      }
+    }
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+    const int upsample_above = use_intra_edge_upsample(txwpx, p_angle - 90);
+    if (upsample_above) {
+      const int n_px = txwpx + (need_right ? txhpx : 0);
+      upsample_intra_edge(above_row, n_px);
+    }
+    const int upsample_left = use_intra_edge_upsample(txhpx, p_angle - 180);
+    if (upsample_left) {
+      const int n_px = txhpx + (need_bottom ? txwpx : 0);
+      upsample_intra_edge(left_col, n_px);
+    }
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
+#endif  // CONFIG_INTRA_EDGE
     dr_predictor(dst, dst_stride, tx_size, above_row, left_col,
 #if CONFIG_INTRA_INTERP
                  filter,
 #endif  // CONFIG_INTRA_INTERP
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+                 upsample_above, upsample_left,
+#endif  // CONFIG_INTRA_EDGE_UPSAMPLE
                  p_angle);
     return;
   }
 #endif  // CONFIG_EXT_INTRA
 
   // predict
   if (mode == DC_PRED) {
 #if CONFIG_CFL
@@ -2379,17 +2583,17 @@ static void build_intra_predictors(const
     }
 #endif
 
   } else {
     pred[mode][tx_size](dst, dst_stride, above_row, left_col);
   }
 }
 
-static void predict_square_intra_block(const MACROBLOCKD *xd, int wpx, int hpx,
+static void predict_intra_block_helper(const MACROBLOCKD *xd, int wpx, int hpx,
                                        TX_SIZE tx_size, PREDICTION_MODE mode,
                                        const uint8_t *ref, int ref_stride,
                                        uint8_t *dst, int dst_stride,
                                        int col_off, int row_off, int plane) {
   BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type;
   const struct macroblockd_plane *const pd = &xd->plane[plane];
   const int txw = tx_size_wide_unit[tx_size];
 #if CONFIG_CB4X4 && CONFIG_CHROMA_SUB8X8
@@ -2403,16 +2607,21 @@ static void predict_square_intra_block(c
   const int have_left = col_off || xd->left_available;
 #endif
   const int x = col_off << tx_size_wide_log2[0];
   const int y = row_off << tx_size_high_log2[0];
   const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
   const int mi_col = -xd->mb_to_left_edge >> (3 + MI_SIZE_LOG2);
   const int txwpx = tx_size_wide[tx_size];
   const int txhpx = tx_size_high[tx_size];
+#if !(CONFIG_RECT_INTRA_PRED && CONFIG_RECT_TX && \
+      (CONFIG_VAR_TX || CONFIG_EXT_TX))
+  assert(txwpx == txhpx);
+#endif  // !(CONFIG_RECT_INTRA_PRED && CONFIG_RECT_TX &&
+        // (CONFIG_VAR_TX || CONFIG_EXT_TX))
 #if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2
   const int xr_chr_offset = (pd->subsampling_x && bsize < BLOCK_8X8) ? 2 : 0;
   const int yd_chr_offset = (pd->subsampling_y && bsize < BLOCK_8X8) ? 2 : 0;
 #else
   const int xr_chr_offset = 0;
   const int yd_chr_offset = 0;
 #endif
 
@@ -2441,39 +2650,36 @@ static void predict_square_intra_block(c
       has_top_right(bsize, mi_row, mi_col, have_top, right_available,
 #if CONFIG_EXT_PARTITION_TYPES
                     partition,
 #endif
                     tx_size, row_off, col_off, pd->subsampling_x);
   const int have_bottom_left =
       has_bottom_left(bsize, mi_row, mi_col, bottom_available, have_left,
                       tx_size, row_off, col_off, pd->subsampling_y);
-  assert(txwpx == txhpx);
-
 #if CONFIG_PALETTE
   if (xd->mi[0]->mbmi.palette_mode_info.palette_size[plane != 0] > 0) {
-    const int bs = tx_size_wide[tx_size];
     const int stride = wpx;
     int r, c;
     const uint8_t *const map = xd->plane[plane != 0].color_index_map;
     uint16_t *palette = xd->mi[0]->mbmi.palette_mode_info.palette_colors +
                         plane * PALETTE_MAX_SIZE;
 
 #if CONFIG_HIGHBITDEPTH
     if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
       uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst);
-      for (r = 0; r < bs; ++r) {
-        for (c = 0; c < bs; ++c) {
+      for (r = 0; r < txhpx; ++r) {
+        for (c = 0; c < txwpx; ++c) {
           dst16[r * dst_stride + c] = palette[map[(r + y) * stride + c + x]];
         }
       }
     } else {
 #endif  // CONFIG_HIGHBITDEPTH
-      for (r = 0; r < bs; ++r) {
-        for (c = 0; c < bs; ++c) {
+      for (r = 0; r < txhpx; ++r) {
+        for (c = 0; c < txwpx; ++c) {
           dst[r * dst_stride + c] =
               (uint8_t)palette[map[(r + y) * stride + c + x]];
         }
       }
 #if CONFIG_HIGHBITDEPTH
     }
 #endif  // CONFIG_HIGHBITDEPTH
     return;
@@ -2510,58 +2716,65 @@ void av1_predict_intra_block_facade(MACR
   const PREDICTION_MODE mode =
       (plane == 0) ? get_y_mode(xd->mi[0], block_raster_idx) : mbmi->uv_mode;
   av1_predict_intra_block(xd, pd->width, pd->height, txsize_to_bsize[tx_size],
                           mode, dst, dst_stride, dst, dst_stride, blk_col,
                           blk_row, plane);
 #if CONFIG_CFL
   if (plane != AOM_PLANE_Y && mbmi->uv_mode == DC_PRED) {
     if (plane == AOM_PLANE_U && blk_col == 0 && blk_row == 0) {
-      // Compute the block-level DC_PRED for both chromatic planes prior to
-      // processing the first chromatic plane in order to compute alpha_cb and
-      // alpha_cr. Note: This is not required on the decoder side because alpha
-      // is signaled.
-      cfl_dc_pred(xd, get_plane_block_size(block_idx, pd), tx_size);
+      // Avoid computing the CfL parameters twice, if they have already been
+      // computed in the encoder_facade
+      if (!xd->cfl->are_parameters_computed)
+        cfl_compute_parameters(xd, tx_size);
     }
 
-    cfl_predict_block(
-        xd->cfl, dst, pd->dst.stride, blk_row, blk_col, tx_size,
-        xd->cfl->dc_pred[plane - 1],
-        cfl_idx_to_alpha(mbmi->cfl_alpha_idx, mbmi->cfl_alpha_signs[plane - 1],
-                         plane - 1));
+    cfl_predict_block(xd, dst, pd->dst.stride, blk_row, blk_col, tx_size,
+                      plane);
   }
 #endif
 }
 
 void av1_predict_intra_block(const MACROBLOCKD *xd, int wpx, int hpx,
                              BLOCK_SIZE bsize, PREDICTION_MODE mode,
                              const uint8_t *ref, int ref_stride, uint8_t *dst,
                              int dst_stride, int col_off, int row_off,
                              int plane) {
   const int block_width = block_size_wide[bsize];
   const int block_height = block_size_high[bsize];
-  TX_SIZE tx_size = max_txsize_lookup[bsize];
+#if CONFIG_RECT_INTRA_PRED && CONFIG_RECT_TX && (CONFIG_VAR_TX || CONFIG_EXT_TX)
+  const TX_SIZE tx_size = max_txsize_rect_lookup[bsize];
+  assert(tx_size < TX_SIZES_ALL);
+#else
+  const TX_SIZE tx_size = max_txsize_lookup[bsize];
   assert(tx_size < TX_SIZES);
+#endif  // CONFIG_RECT_INTRA_PRED && CONFIG_RECT_TX && (CONFIG_VAR_TX ||
+        // CONFIG_EXT_TX)
+
   if (block_width == block_height) {
-    predict_square_intra_block(xd, wpx, hpx, tx_size, mode, ref, ref_stride,
+    predict_intra_block_helper(xd, wpx, hpx, tx_size, mode, ref, ref_stride,
                                dst, dst_stride, col_off, row_off, plane);
   } else {
 #if (CONFIG_RECT_TX && (CONFIG_VAR_TX || CONFIG_EXT_TX)) || (CONFIG_EXT_INTER)
-#if CONFIG_HIGHBITDEPTH
-    uint16_t tmp16[MAX_SB_SIZE];
-#endif
-    uint8_t tmp[MAX_SB_SIZE];
     assert((block_width == wpx && block_height == hpx) ||
            (block_width == (wpx >> 1) && block_height == hpx) ||
            (block_width == wpx && block_height == (hpx >> 1)));
+#if CONFIG_RECT_INTRA_PRED && CONFIG_RECT_TX && (CONFIG_VAR_TX || CONFIG_EXT_TX)
+    predict_intra_block_helper(xd, wpx, hpx, tx_size, mode, ref, ref_stride,
+                               dst, dst_stride, col_off, row_off, plane);
+#else
+#if CONFIG_HIGHBITDEPTH
+    uint16_t tmp16[MAX_SB_SIZE];
+#endif  // CONFIG_HIGHBITDEPTH
+    uint8_t tmp[MAX_SB_SIZE];
 
     if (block_width < block_height) {
       assert(block_height == (block_width << 1));
       // Predict the top square sub-block.
-      predict_square_intra_block(xd, wpx, hpx, tx_size, mode, ref, ref_stride,
+      predict_intra_block_helper(xd, wpx, hpx, tx_size, mode, ref, ref_stride,
                                  dst, dst_stride, col_off, row_off, plane);
       {
         const int half_block_height = block_height >> 1;
         const int half_block_height_unit =
             half_block_height >> tx_size_wide_log2[0];
         // Cast away const to modify 'ref' temporarily; will be restored later.
         uint8_t *src_2 = (uint8_t *)ref + half_block_height * ref_stride;
         uint8_t *dst_2 = dst + half_block_height * dst_stride;
@@ -2582,17 +2795,17 @@ void av1_predict_intra_block(const MACRO
             memcpy(tmp, src_2 - ref_stride, block_width * sizeof(*src_2));
             memcpy(src_2 - ref_stride, dst_2 - dst_stride,
                    block_width * sizeof(*src_2));
 #if CONFIG_HIGHBITDEPTH
           }
 #endif  // CONFIG_HIGHBITDEPTH
         }
         // Predict the bottom square sub-block.
-        predict_square_intra_block(xd, wpx, hpx, tx_size, mode, src_2,
+        predict_intra_block_helper(xd, wpx, hpx, tx_size, mode, src_2,
                                    ref_stride, dst_2, dst_stride, col_off,
                                    row_off_2, plane);
         // Restore the last row of top square sub-block.
         if (src_2 != dst_2 || ref_stride != dst_stride) {
 #if CONFIG_HIGHBITDEPTH
           if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
             uint16_t *src_2_16 = CONVERT_TO_SHORTPTR(src_2);
             memcpy(src_2_16 - ref_stride, tmp16,
@@ -2603,17 +2816,17 @@ void av1_predict_intra_block(const MACRO
 #if CONFIG_HIGHBITDEPTH
           }
 #endif  // CONFIG_HIGHBITDEPTH
         }
       }
     } else {  // block_width > block_height
       assert(block_width == (block_height << 1));
       // Predict the left square sub-block
-      predict_square_intra_block(xd, wpx, hpx, tx_size, mode, ref, ref_stride,
+      predict_intra_block_helper(xd, wpx, hpx, tx_size, mode, ref, ref_stride,
                                  dst, dst_stride, col_off, row_off, plane);
       {
         int i;
         const int half_block_width = block_width >> 1;
         const int half_block_width_unit =
             half_block_width >> tx_size_wide_log2[0];
         // Cast away const to modify 'ref' temporarily; will be restored later.
         uint8_t *src_2 = (uint8_t *)ref + half_block_width;
@@ -2637,17 +2850,17 @@ void av1_predict_intra_block(const MACRO
               tmp[i] = src_2[i * ref_stride - 1];
               src_2[i * ref_stride - 1] = dst_2[i * dst_stride - 1];
             }
 #if CONFIG_HIGHBITDEPTH
           }
 #endif  // CONFIG_HIGHBITDEPTH
         }
         // Predict the right square sub-block.
-        predict_square_intra_block(xd, wpx, hpx, tx_size, mode, src_2,
+        predict_intra_block_helper(xd, wpx, hpx, tx_size, mode, src_2,
                                    ref_stride, dst_2, dst_stride, col_off_2,
                                    row_off, plane);
         // Restore the last column of left square sub-block.
         if (save_src) {
 #if CONFIG_HIGHBITDEPTH
           if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
             uint16_t *src_2_16 = CONVERT_TO_SHORTPTR(src_2);
             for (i = 0; i < block_height; ++i) {
@@ -2659,16 +2872,18 @@ void av1_predict_intra_block(const MACRO
               src_2[i * ref_stride - 1] = tmp[i];
             }
 #if CONFIG_HIGHBITDEPTH
           }
 #endif  // CONFIG_HIGHBITDEPTH
         }
       }
     }
+#endif  // CONFIG_RECT_INTRA_PRED && CONFIG_RECT_TX && (CONFIG_VAR_TX ||
+        // CONFIG_EXT_TX)
 #else
     assert(0);
 #endif  // (CONFIG_RECT_TX && (CONFIG_VAR_TX || CONFIG_EXT_TX)) ||
         // (CONFIG_EXT_INTER)
   }
 }
 
 void av1_init_intra_predictors(void) {
--- a/third_party/aom/av1/common/reconintra.h
+++ b/third_party/aom/av1/common/reconintra.h
@@ -68,26 +68,36 @@ static const INTERINTRA_MODE intra_to_in
 #endif
 };
 #endif  // CONFIG_EXT_INTER && CONFIG_INTERINTRA
 
 #if CONFIG_FILTER_INTRA
 #define FILTER_INTRA_PREC_BITS 10
 #endif  // CONFIG_FILTER_INTRA
 
+#define CONFIG_INTRA_EDGE_UPSAMPLE CONFIG_INTRA_EDGE
+#define CONFIG_USE_ANGLE_DELTA_SUB8X8 0
+
 #if CONFIG_EXT_INTRA
 static INLINE int av1_is_directional_mode(PREDICTION_MODE mode,
                                           BLOCK_SIZE bsize) {
-  return mode != DC_PRED && mode != TM_PRED &&
-#if CONFIG_ALT_INTRA
-         mode != SMOOTH_PRED &&
-#if CONFIG_SMOOTH_HV
-         mode != SMOOTH_V_PRED && mode != SMOOTH_H_PRED &&
-#endif  // CONFIG_SMOOTH_HV
-#endif  // CONFIG_ALT_INTRA
-         bsize >= BLOCK_8X8;
+#if CONFIG_INTRA_EDGE_UPSAMPLE
+  (void)bsize;
+  return mode >= V_PRED && mode <= D63_PRED;
+#else
+  return mode >= V_PRED && mode <= D63_PRED && bsize >= BLOCK_8X8;
+#endif
+}
+
+static INLINE int av1_use_angle_delta(BLOCK_SIZE bsize) {
+  (void)bsize;
+#if CONFIG_USE_ANGLE_DELTA_SUB8X8
+  return 1;
+#else
+  return bsize >= BLOCK_8X8;
+#endif
 }
 #endif  // CONFIG_EXT_INTRA
 
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 #endif  // AV1_COMMON_RECONINTRA_H_
--- a/third_party/aom/av1/common/resize.c
+++ b/third_party/aom/av1/common/resize.c
@@ -25,120 +25,297 @@
 #include "av1/common/common.h"
 #include "av1/common/resize.h"
 
 #include "./aom_scale_rtcd.h"
 
 #define FILTER_BITS 7
 
 #define INTERP_TAPS 8
-#define SUBPEL_BITS_RS 5
+#define SUBPEL_BITS_RS 6
 #define SUBPEL_MASK_RS ((1 << SUBPEL_BITS_RS) - 1)
 #define INTERP_PRECISION_BITS 32
+#define SUBPEL_INTERP_EXTRA_BITS (INTERP_PRECISION_BITS - SUBPEL_BITS_RS)
+#define SUBPEL_INTERP_EXTRA_OFF (1 << (SUBPEL_INTERP_EXTRA_BITS - 1))
 
 typedef int16_t interp_kernel[INTERP_TAPS];
 
 // Filters for interpolation (0.5-band) - note this also filters integer pels.
 static const interp_kernel filteredinterp_filters500[(1 << SUBPEL_BITS_RS)] = {
+#if SUBPEL_BITS_RS == 5
   { -3, 0, 35, 64, 35, 0, -3, 0 },    { -3, -1, 34, 64, 36, 1, -3, 0 },
   { -3, -1, 32, 64, 38, 1, -3, 0 },   { -2, -2, 31, 63, 39, 2, -3, 0 },
   { -2, -2, 29, 63, 41, 2, -3, 0 },   { -2, -2, 28, 63, 42, 3, -4, 0 },
   { -2, -3, 27, 63, 43, 4, -4, 0 },   { -2, -3, 25, 62, 45, 5, -4, 0 },
   { -2, -3, 24, 62, 46, 5, -4, 0 },   { -2, -3, 23, 61, 47, 6, -4, 0 },
   { -2, -3, 21, 60, 49, 7, -4, 0 },   { -1, -4, 20, 60, 50, 8, -4, -1 },
   { -1, -4, 19, 59, 51, 9, -4, -1 },  { -1, -4, 17, 58, 52, 10, -4, 0 },
   { -1, -4, 16, 57, 53, 12, -4, -1 }, { -1, -4, 15, 56, 54, 13, -4, -1 },
   { -1, -4, 14, 55, 55, 14, -4, -1 }, { -1, -4, 13, 54, 56, 15, -4, -1 },
   { -1, -4, 12, 53, 57, 16, -4, -1 }, { 0, -4, 10, 52, 58, 17, -4, -1 },
   { -1, -4, 9, 51, 59, 19, -4, -1 },  { -1, -4, 8, 50, 60, 20, -4, -1 },
   { 0, -4, 7, 49, 60, 21, -3, -2 },   { 0, -4, 6, 47, 61, 23, -3, -2 },
   { 0, -4, 5, 46, 62, 24, -3, -2 },   { 0, -4, 5, 45, 62, 25, -3, -2 },
   { 0, -4, 4, 43, 63, 27, -3, -2 },   { 0, -4, 3, 42, 63, 28, -2, -2 },
   { 0, -3, 2, 41, 63, 29, -2, -2 },   { 0, -3, 2, 39, 63, 31, -2, -2 },
-  { 0, -3, 1, 38, 64, 32, -1, -3 },   { 0, -3, 1, 36, 64, 34, -1, -3 }
+  { 0, -3, 1, 38, 64, 32, -1, -3 },   { 0, -3, 1, 36, 64, 34, -1, -3 },
+#elif SUBPEL_BITS_RS == 6
+  { -3, 0, 35, 64, 35, 0, -3, 0 },    { -3, 0, 34, 64, 36, 0, -3, 0 },
+  { -3, -1, 34, 64, 36, 1, -3, 0 },   { -3, -1, 33, 64, 37, 1, -3, 0 },
+  { -3, -1, 32, 64, 38, 1, -3, 0 },   { -3, -1, 31, 64, 39, 1, -3, 0 },
+  { -3, -1, 31, 63, 39, 2, -3, 0 },   { -2, -2, 30, 63, 40, 2, -3, 0 },
+  { -2, -2, 29, 63, 41, 2, -3, 0 },   { -2, -2, 29, 63, 41, 3, -4, 0 },
+  { -2, -2, 28, 63, 42, 3, -4, 0 },   { -2, -2, 27, 63, 43, 3, -4, 0 },
+  { -2, -3, 27, 63, 43, 4, -4, 0 },   { -2, -3, 26, 62, 44, 5, -4, 0 },
+  { -2, -3, 25, 62, 45, 5, -4, 0 },   { -2, -3, 25, 62, 45, 5, -4, 0 },
+  { -2, -3, 24, 62, 46, 5, -4, 0 },   { -2, -3, 23, 61, 47, 6, -4, 0 },
+  { -2, -3, 23, 61, 47, 6, -4, 0 },   { -2, -3, 22, 61, 48, 7, -4, -1 },
+  { -2, -3, 21, 60, 49, 7, -4, 0 },   { -1, -4, 20, 60, 49, 8, -4, 0 },
+  { -1, -4, 20, 60, 50, 8, -4, -1 },  { -1, -4, 19, 59, 51, 9, -4, -1 },
+  { -1, -4, 19, 59, 51, 9, -4, -1 },  { -1, -4, 18, 58, 52, 10, -4, -1 },
+  { -1, -4, 17, 58, 52, 11, -4, -1 }, { -1, -4, 16, 58, 53, 11, -4, -1 },
+  { -1, -4, 16, 57, 53, 12, -4, -1 }, { -1, -4, 15, 57, 54, 12, -4, -1 },
+  { -1, -4, 15, 56, 54, 13, -4, -1 }, { -1, -4, 14, 56, 55, 13, -4, -1 },
+  { -1, -4, 14, 55, 55, 14, -4, -1 }, { -1, -4, 13, 55, 56, 14, -4, -1 },
+  { -1, -4, 13, 54, 56, 15, -4, -1 }, { -1, -4, 12, 54, 57, 15, -4, -1 },
+  { -1, -4, 12, 53, 57, 16, -4, -1 }, { -1, -4, 11, 53, 58, 16, -4, -1 },
+  { -1, -4, 11, 52, 58, 17, -4, -1 }, { -1, -4, 10, 52, 58, 18, -4, -1 },
+  { -1, -4, 9, 51, 59, 19, -4, -1 },  { -1, -4, 9, 51, 59, 19, -4, -1 },
+  { -1, -4, 8, 50, 60, 20, -4, -1 },  { 0, -4, 8, 49, 60, 20, -4, -1 },
+  { 0, -4, 7, 49, 60, 21, -3, -2 },   { -1, -4, 7, 48, 61, 22, -3, -2 },
+  { 0, -4, 6, 47, 61, 23, -3, -2 },   { 0, -4, 6, 47, 61, 23, -3, -2 },
+  { 0, -4, 5, 46, 62, 24, -3, -2 },   { 0, -4, 5, 45, 62, 25, -3, -2 },
+  { 0, -4, 5, 45, 62, 25, -3, -2 },   { 0, -4, 5, 44, 62, 26, -3, -2 },
+  { 0, -4, 4, 43, 63, 27, -3, -2 },   { 0, -4, 3, 43, 63, 27, -2, -2 },
+  { 0, -4, 3, 42, 63, 28, -2, -2 },   { 0, -4, 3, 41, 63, 29, -2, -2 },
+  { 0, -3, 2, 41, 63, 29, -2, -2 },   { 0, -3, 2, 40, 63, 30, -2, -2 },
+  { 0, -3, 2, 39, 63, 31, -1, -3 },   { 0, -3, 1, 39, 64, 31, -1, -3 },
+  { 0, -3, 1, 38, 64, 32, -1, -3 },   { 0, -3, 1, 37, 64, 33, -1, -3 },
+  { 0, -3, 1, 36, 64, 34, -1, -3 },   { 0, -3, 0, 36, 64, 34, 0, -3 },
+#endif  // SUBPEL_BITS_RS == 5
 };
 
 // Filters for interpolation (0.625-band) - note this also filters integer pels.
 static const interp_kernel filteredinterp_filters625[(1 << SUBPEL_BITS_RS)] = {
+#if SUBPEL_BITS_RS == 5
   { -1, -8, 33, 80, 33, -8, -1, 0 }, { -1, -8, 30, 80, 35, -8, -1, 1 },
   { -1, -8, 28, 80, 37, -7, -2, 1 }, { 0, -8, 26, 79, 39, -7, -2, 1 },
   { 0, -8, 24, 79, 41, -7, -2, 1 },  { 0, -8, 22, 78, 43, -6, -2, 1 },
   { 0, -8, 20, 78, 45, -5, -3, 1 },  { 0, -8, 18, 77, 48, -5, -3, 1 },
   { 0, -8, 16, 76, 50, -4, -3, 1 },  { 0, -8, 15, 75, 52, -3, -4, 1 },
   { 0, -7, 13, 74, 54, -3, -4, 1 },  { 0, -7, 11, 73, 56, -2, -4, 1 },
   { 0, -7, 10, 71, 58, -1, -4, 1 },  { 1, -7, 8, 70, 60, 0, -5, 1 },
   { 1, -6, 6, 68, 62, 1, -5, 1 },    { 1, -6, 5, 67, 63, 2, -5, 1 },
   { 1, -6, 4, 65, 65, 4, -6, 1 },    { 1, -5, 2, 63, 67, 5, -6, 1 },
   { 1, -5, 1, 62, 68, 6, -6, 1 },    { 1, -5, 0, 60, 70, 8, -7, 1 },
   { 1, -4, -1, 58, 71, 10, -7, 0 },  { 1, -4, -2, 56, 73, 11, -7, 0 },
   { 1, -4, -3, 54, 74, 13, -7, 0 },  { 1, -4, -3, 52, 75, 15, -8, 0 },
   { 1, -3, -4, 50, 76, 16, -8, 0 },  { 1, -3, -5, 48, 77, 18, -8, 0 },
   { 1, -3, -5, 45, 78, 20, -8, 0 },  { 1, -2, -6, 43, 78, 22, -8, 0 },
   { 1, -2, -7, 41, 79, 24, -8, 0 },  { 1, -2, -7, 39, 79, 26, -8, 0 },
   { 1, -2, -7, 37, 80, 28, -8, -1 }, { 1, -1, -8, 35, 80, 30, -8, -1 },
+#elif SUBPEL_BITS_RS == 6
+  { -1, -8, 33, 80, 33, -8, -1, 0 }, { -1, -8, 31, 80, 34, -8, -1, 1 },
+  { -1, -8, 30, 80, 35, -8, -1, 1 }, { -1, -8, 29, 80, 36, -7, -2, 1 },
+  { -1, -8, 28, 80, 37, -7, -2, 1 }, { -1, -8, 27, 80, 38, -7, -2, 1 },
+  { 0, -8, 26, 79, 39, -7, -2, 1 },  { 0, -8, 25, 79, 40, -7, -2, 1 },
+  { 0, -8, 24, 79, 41, -7, -2, 1 },  { 0, -8, 23, 78, 42, -6, -2, 1 },
+  { 0, -8, 22, 78, 43, -6, -2, 1 },  { 0, -8, 21, 78, 44, -6, -2, 1 },
+  { 0, -8, 20, 78, 45, -5, -3, 1 },  { 0, -8, 19, 77, 47, -5, -3, 1 },
+  { 0, -8, 18, 77, 48, -5, -3, 1 },  { 0, -8, 17, 77, 49, -5, -3, 1 },
+  { 0, -8, 16, 76, 50, -4, -3, 1 },  { 0, -8, 15, 76, 51, -4, -3, 1 },
+  { 0, -8, 15, 75, 52, -3, -4, 1 },  { 0, -7, 14, 74, 53, -3, -4, 1 },
+  { 0, -7, 13, 74, 54, -3, -4, 1 },  { 0, -7, 12, 73, 55, -2, -4, 1 },
+  { 0, -7, 11, 73, 56, -2, -4, 1 },  { 0, -7, 10, 72, 57, -1, -4, 1 },
+  { 1, -7, 10, 71, 58, -1, -5, 1 },  { 0, -7, 9, 71, 59, 0, -5, 1 },
+  { 1, -7, 8, 70, 60, 0, -5, 1 },    { 1, -7, 7, 69, 61, 1, -5, 1 },
+  { 1, -6, 6, 68, 62, 1, -5, 1 },    { 0, -6, 6, 68, 62, 2, -5, 1 },
+  { 1, -6, 5, 67, 63, 2, -5, 1 },    { 1, -6, 5, 66, 64, 3, -6, 1 },
+  { 1, -6, 4, 65, 65, 4, -6, 1 },    { 1, -6, 3, 64, 66, 5, -6, 1 },
+  { 1, -5, 2, 63, 67, 5, -6, 1 },    { 1, -5, 2, 62, 68, 6, -6, 0 },
+  { 1, -5, 1, 62, 68, 6, -6, 1 },    { 1, -5, 1, 61, 69, 7, -7, 1 },
+  { 1, -5, 0, 60, 70, 8, -7, 1 },    { 1, -5, 0, 59, 71, 9, -7, 0 },
+  { 1, -5, -1, 58, 71, 10, -7, 1 },  { 1, -4, -1, 57, 72, 10, -7, 0 },
+  { 1, -4, -2, 56, 73, 11, -7, 0 },  { 1, -4, -2, 55, 73, 12, -7, 0 },
+  { 1, -4, -3, 54, 74, 13, -7, 0 },  { 1, -4, -3, 53, 74, 14, -7, 0 },
+  { 1, -4, -3, 52, 75, 15, -8, 0 },  { 1, -3, -4, 51, 76, 15, -8, 0 },
+  { 1, -3, -4, 50, 76, 16, -8, 0 },  { 1, -3, -5, 49, 77, 17, -8, 0 },
+  { 1, -3, -5, 48, 77, 18, -8, 0 },  { 1, -3, -5, 47, 77, 19, -8, 0 },
+  { 1, -3, -5, 45, 78, 20, -8, 0 },  { 1, -2, -6, 44, 78, 21, -8, 0 },
+  { 1, -2, -6, 43, 78, 22, -8, 0 },  { 1, -2, -6, 42, 78, 23, -8, 0 },
+  { 1, -2, -7, 41, 79, 24, -8, 0 },  { 1, -2, -7, 40, 79, 25, -8, 0 },
+  { 1, -2, -7, 39, 79, 26, -8, 0 },  { 1, -2, -7, 38, 80, 27, -8, -1 },
+  { 1, -2, -7, 37, 80, 28, -8, -1 }, { 1, -2, -7, 36, 80, 29, -8, -1 },
+  { 1, -1, -8, 35, 80, 30, -8, -1 }, { 1, -1, -8, 34, 80, 31, -8, -1 },
+#endif  // SUBPEL_BITS_RS == 5
 };
 
 // Filters for interpolation (0.75-band) - note this also filters integer pels.
 static const interp_kernel filteredinterp_filters750[(1 << SUBPEL_BITS_RS)] = {
+#if SUBPEL_BITS_RS == 5
   { 2, -11, 25, 96, 25, -11, 2, 0 }, { 2, -11, 22, 96, 28, -11, 2, 0 },
   { 2, -10, 19, 95, 31, -11, 2, 0 }, { 2, -10, 17, 95, 34, -12, 2, 0 },
   { 2, -9, 14, 94, 37, -12, 2, 0 },  { 2, -8, 12, 93, 40, -12, 1, 0 },
   { 2, -8, 9, 92, 43, -12, 1, 1 },   { 2, -7, 7, 91, 46, -12, 1, 0 },
   { 2, -7, 5, 90, 49, -12, 1, 0 },   { 2, -6, 3, 88, 52, -12, 0, 1 },
   { 2, -5, 1, 86, 55, -12, 0, 1 },   { 2, -5, -1, 84, 58, -11, 0, 1 },
   { 2, -4, -2, 82, 61, -11, -1, 1 }, { 2, -4, -4, 80, 64, -10, -1, 1 },
   { 1, -3, -5, 77, 67, -9, -1, 1 },  { 1, -3, -6, 75, 70, -8, -2, 1 },
   { 1, -2, -7, 72, 72, -7, -2, 1 },  { 1, -2, -8, 70, 75, -6, -3, 1 },
   { 1, -1, -9, 67, 77, -5, -3, 1 },  { 1, -1, -10, 64, 80, -4, -4, 2 },
   { 1, -1, -11, 61, 82, -2, -4, 2 }, { 1, 0, -11, 58, 84, -1, -5, 2 },
   { 1, 0, -12, 55, 86, 1, -5, 2 },   { 1, 0, -12, 52, 88, 3, -6, 2 },
   { 0, 1, -12, 49, 90, 5, -7, 2 },   { 0, 1, -12, 46, 91, 7, -7, 2 },
   { 1, 1, -12, 43, 92, 9, -8, 2 },   { 0, 1, -12, 40, 93, 12, -8, 2 },
   { 0, 2, -12, 37, 94, 14, -9, 2 },  { 0, 2, -12, 34, 95, 17, -10, 2 },
-  { 0, 2, -11, 31, 95, 19, -10, 2 }, { 0, 2, -11, 28, 96, 22, -11, 2 }
+  { 0, 2, -11, 31, 95, 19, -10, 2 }, { 0, 2, -11, 28, 96, 22, -11, 2 },
+#elif SUBPEL_BITS_RS == 6
+  { 2, -11, 25, 96, 25, -11, 2, 0 }, { 2, -11, 24, 96, 26, -11, 2, 0 },
+  { 2, -11, 22, 96, 28, -11, 2, 0 }, { 2, -10, 21, 96, 29, -12, 2, 0 },
+  { 2, -10, 19, 96, 31, -12, 2, 0 }, { 2, -10, 18, 95, 32, -11, 2, 0 },
+  { 2, -10, 17, 95, 34, -12, 2, 0 }, { 2, -9, 15, 95, 35, -12, 2, 0 },
+  { 2, -9, 14, 94, 37, -12, 2, 0 },  { 2, -9, 13, 94, 38, -12, 2, 0 },
+  { 2, -8, 12, 93, 40, -12, 1, 0 },  { 2, -8, 11, 93, 41, -12, 1, 0 },
+  { 2, -8, 9, 92, 43, -12, 1, 1 },   { 2, -8, 8, 92, 44, -12, 1, 1 },
+  { 2, -7, 7, 91, 46, -12, 1, 0 },   { 2, -7, 6, 90, 47, -12, 1, 1 },
+  { 2, -7, 5, 90, 49, -12, 1, 0 },   { 2, -6, 4, 89, 50, -12, 1, 0 },
+  { 2, -6, 3, 88, 52, -12, 0, 1 },   { 2, -6, 2, 87, 54, -12, 0, 1 },
+  { 2, -5, 1, 86, 55, -12, 0, 1 },   { 2, -5, 0, 85, 57, -12, 0, 1 },
+  { 2, -5, -1, 84, 58, -11, 0, 1 },  { 2, -5, -2, 83, 60, -11, 0, 1 },
+  { 2, -4, -2, 82, 61, -11, -1, 1 }, { 1, -4, -3, 81, 63, -10, -1, 1 },
+  { 2, -4, -4, 80, 64, -10, -1, 1 }, { 1, -4, -4, 79, 66, -10, -1, 1 },
+  { 1, -3, -5, 77, 67, -9, -1, 1 },  { 1, -3, -6, 76, 69, -9, -1, 1 },
+  { 1, -3, -6, 75, 70, -8, -2, 1 },  { 1, -2, -7, 74, 71, -8, -2, 1 },
+  { 1, -2, -7, 72, 72, -7, -2, 1 },  { 1, -2, -8, 71, 74, -7, -2, 1 },
+  { 1, -2, -8, 70, 75, -6, -3, 1 },  { 1, -1, -9, 69, 76, -6, -3, 1 },
+  { 1, -1, -9, 67, 77, -5, -3, 1 },  { 1, -1, -10, 66, 79, -4, -4, 1 },
+  { 1, -1, -10, 64, 80, -4, -4, 2 }, { 1, -1, -10, 63, 81, -3, -4, 1 },
+  { 1, -1, -11, 61, 82, -2, -4, 2 }, { 1, 0, -11, 60, 83, -2, -5, 2 },
+  { 1, 0, -11, 58, 84, -1, -5, 2 },  { 1, 0, -12, 57, 85, 0, -5, 2 },
+  { 1, 0, -12, 55, 86, 1, -5, 2 },   { 1, 0, -12, 54, 87, 2, -6, 2 },
+  { 1, 0, -12, 52, 88, 3, -6, 2 },   { 0, 1, -12, 50, 89, 4, -6, 2 },
+  { 0, 1, -12, 49, 90, 5, -7, 2 },   { 1, 1, -12, 47, 90, 6, -7, 2 },
+  { 0, 1, -12, 46, 91, 7, -7, 2 },   { 1, 1, -12, 44, 92, 8, -8, 2 },
+  { 1, 1, -12, 43, 92, 9, -8, 2 },   { 0, 1, -12, 41, 93, 11, -8, 2 },
+  { 0, 1, -12, 40, 93, 12, -8, 2 },  { 0, 2, -12, 38, 94, 13, -9, 2 },
+  { 0, 2, -12, 37, 94, 14, -9, 2 },  { 0, 2, -12, 35, 95, 15, -9, 2 },
+  { 0, 2, -12, 34, 95, 17, -10, 2 }, { 0, 2, -11, 32, 95, 18, -10, 2 },
+  { 0, 2, -12, 31, 96, 19, -10, 2 }, { 0, 2, -12, 29, 96, 21, -10, 2 },
+  { 0, 2, -11, 28, 96, 22, -11, 2 }, { 0, 2, -11, 26, 96, 24, -11, 2 },
+#endif  // SUBPEL_BITS_RS == 5
 };
 
 // Filters for interpolation (0.875-band) - note this also filters integer pels.
 static const interp_kernel filteredinterp_filters875[(1 << SUBPEL_BITS_RS)] = {
+#if SUBPEL_BITS_RS == 5
   { 3, -8, 13, 112, 13, -8, 3, 0 },   { 3, -7, 10, 112, 17, -9, 3, -1 },
   { 2, -6, 7, 111, 21, -9, 3, -1 },   { 2, -5, 4, 111, 24, -10, 3, -1 },
   { 2, -4, 1, 110, 28, -11, 3, -1 },  { 1, -3, -1, 108, 32, -12, 4, -1 },
   { 1, -2, -3, 106, 36, -13, 4, -1 }, { 1, -1, -6, 105, 40, -14, 4, -1 },
   { 1, -1, -7, 102, 44, -14, 4, -1 }, { 1, 0, -9, 100, 48, -15, 4, -1 },
   { 1, 1, -11, 97, 53, -16, 4, -1 },  { 0, 1, -12, 95, 57, -16, 4, -1 },
   { 0, 2, -13, 91, 61, -16, 4, -1 },  { 0, 2, -14, 88, 65, -16, 4, -1 },
   { 0, 3, -15, 84, 69, -17, 4, 0 },   { 0, 3, -16, 81, 73, -16, 3, 0 },
   { 0, 3, -16, 77, 77, -16, 3, 0 },   { 0, 3, -16, 73, 81, -16, 3, 0 },
   { 0, 4, -17, 69, 84, -15, 3, 0 },   { -1, 4, -16, 65, 88, -14, 2, 0 },
   { -1, 4, -16, 61, 91, -13, 2, 0 },  { -1, 4, -16, 57, 95, -12, 1, 0 },
   { -1, 4, -16, 53, 97, -11, 1, 1 },  { -1, 4, -15, 48, 100, -9, 0, 1 },
   { -1, 4, -14, 44, 102, -7, -1, 1 }, { -1, 4, -14, 40, 105, -6, -1, 1 },
   { -1, 4, -13, 36, 106, -3, -2, 1 }, { -1, 4, -12, 32, 108, -1, -3, 1 },
   { -1, 3, -11, 28, 110, 1, -4, 2 },  { -1, 3, -10, 24, 111, 4, -5, 2 },
-  { -1, 3, -9, 21, 111, 7, -6, 2 },   { -1, 3, -9, 17, 112, 10, -7, 3 }
+  { -1, 3, -9, 21, 111, 7, -6, 2 },   { -1, 3, -9, 17, 112, 10, -7, 3 },
+#elif SUBPEL_BITS_RS == 6
+  { 3, -8, 13, 112, 13, -8, 3, 0 },   { 2, -7, 12, 112, 15, -8, 3, -1 },
+  { 3, -7, 10, 112, 17, -9, 3, -1 },  { 2, -6, 8, 112, 19, -9, 3, -1 },
+  { 2, -6, 7, 112, 21, -10, 3, -1 },  { 2, -5, 6, 111, 22, -10, 3, -1 },
+  { 2, -5, 4, 111, 24, -10, 3, -1 },  { 2, -4, 3, 110, 26, -11, 3, -1 },
+  { 2, -4, 1, 110, 28, -11, 3, -1 },  { 2, -4, 0, 109, 30, -12, 4, -1 },
+  { 1, -3, -1, 108, 32, -12, 4, -1 }, { 1, -3, -2, 108, 34, -13, 4, -1 },
+  { 1, -2, -4, 107, 36, -13, 4, -1 }, { 1, -2, -5, 106, 38, -13, 4, -1 },
+  { 1, -1, -6, 105, 40, -14, 4, -1 }, { 1, -1, -7, 104, 42, -14, 4, -1 },
+  { 1, -1, -7, 103, 44, -15, 4, -1 }, { 1, 0, -8, 101, 46, -15, 4, -1 },
+  { 1, 0, -9, 100, 48, -15, 4, -1 },  { 1, 0, -10, 99, 50, -15, 4, -1 },
+  { 1, 1, -11, 97, 53, -16, 4, -1 },  { 0, 1, -11, 96, 55, -16, 4, -1 },
+  { 0, 1, -12, 95, 57, -16, 4, -1 },  { 0, 2, -13, 93, 59, -16, 4, -1 },
+  { 0, 2, -13, 91, 61, -16, 4, -1 },  { 0, 2, -14, 90, 63, -16, 4, -1 },
+  { 0, 2, -14, 88, 65, -16, 4, -1 },  { 0, 2, -15, 86, 67, -16, 4, 0 },
+  { 0, 3, -15, 84, 69, -17, 4, 0 },   { 0, 3, -16, 83, 71, -17, 4, 0 },
+  { 0, 3, -16, 81, 73, -16, 3, 0 },   { 0, 3, -16, 79, 75, -16, 3, 0 },
+  { 0, 3, -16, 77, 77, -16, 3, 0 },   { 0, 3, -16, 75, 79, -16, 3, 0 },
+  { 0, 3, -16, 73, 81, -16, 3, 0 },   { 0, 4, -17, 71, 83, -16, 3, 0 },
+  { 0, 4, -17, 69, 84, -15, 3, 0 },   { 0, 4, -16, 67, 86, -15, 2, 0 },
+  { -1, 4, -16, 65, 88, -14, 2, 0 },  { -1, 4, -16, 63, 90, -14, 2, 0 },
+  { -1, 4, -16, 61, 91, -13, 2, 0 },  { -1, 4, -16, 59, 93, -13, 2, 0 },
+  { -1, 4, -16, 57, 95, -12, 1, 0 },  { -1, 4, -16, 55, 96, -11, 1, 0 },
+  { -1, 4, -16, 53, 97, -11, 1, 1 },  { -1, 4, -15, 50, 99, -10, 0, 1 },
+  { -1, 4, -15, 48, 100, -9, 0, 1 },  { -1, 4, -15, 46, 101, -8, 0, 1 },
+  { -1, 4, -15, 44, 103, -7, -1, 1 }, { -1, 4, -14, 42, 104, -7, -1, 1 },
+  { -1, 4, -14, 40, 105, -6, -1, 1 }, { -1, 4, -13, 38, 106, -5, -2, 1 },
+  { -1, 4, -13, 36, 107, -4, -2, 1 }, { -1, 4, -13, 34, 108, -2, -3, 1 },
+  { -1, 4, -12, 32, 108, -1, -3, 1 }, { -1, 4, -12, 30, 109, 0, -4, 2 },
+  { -1, 3, -11, 28, 110, 1, -4, 2 },  { -1, 3, -11, 26, 110, 3, -4, 2 },
+  { -1, 3, -10, 24, 111, 4, -5, 2 },  { -1, 3, -10, 22, 111, 6, -5, 2 },
+  { -1, 3, -10, 21, 112, 7, -6, 2 },  { -1, 3, -9, 19, 112, 8, -6, 2 },
+  { -1, 3, -9, 17, 112, 10, -7, 3 },  { -1, 3, -8, 15, 112, 12, -7, 2 },
+#endif  // SUBPEL_BITS_RS == 5
 };
 
 // Filters for interpolation (full-band) - no filtering for integer pixels
 static const interp_kernel filteredinterp_filters1000[(1 << SUBPEL_BITS_RS)] = {
+#if SUBPEL_BITS_RS == 5
   { 0, 0, 0, 128, 0, 0, 0, 0 },        { 0, 1, -3, 128, 3, -1, 0, 0 },
   { -1, 2, -6, 127, 7, -2, 1, 0 },     { -1, 3, -9, 126, 12, -4, 1, 0 },
   { -1, 4, -12, 125, 16, -5, 1, 0 },   { -1, 4, -14, 123, 20, -6, 2, 0 },
   { -1, 5, -15, 120, 25, -8, 2, 0 },   { -1, 5, -17, 118, 30, -9, 3, -1 },
   { -1, 6, -18, 114, 35, -10, 3, -1 }, { -1, 6, -19, 111, 41, -12, 3, -1 },
   { -1, 6, -20, 107, 46, -13, 4, -1 }, { -1, 6, -21, 103, 52, -14, 4, -1 },
   { -1, 6, -21, 99, 57, -16, 5, -1 },  { -1, 6, -21, 94, 63, -17, 5, -1 },
   { -1, 6, -20, 89, 68, -18, 5, -1 },  { -1, 6, -20, 84, 73, -19, 6, -1 },
   { -1, 6, -20, 79, 79, -20, 6, -1 },  { -1, 6, -19, 73, 84, -20, 6, -1 },
   { -1, 5, -18, 68, 89, -20, 6, -1 },  { -1, 5, -17, 63, 94, -21, 6, -1 },
   { -1, 5, -16, 57, 99, -21, 6, -1 },  { -1, 4, -14, 52, 103, -21, 6, -1 },
   { -1, 4, -13, 46, 107, -20, 6, -1 }, { -1, 3, -12, 41, 111, -19, 6, -1 },
   { -1, 3, -10, 35, 114, -18, 6, -1 }, { -1, 3, -9, 30, 118, -17, 5, -1 },
   { 0, 2, -8, 25, 120, -15, 5, -1 },   { 0, 2, -6, 20, 123, -14, 4, -1 },
   { 0, 1, -5, 16, 125, -12, 4, -1 },   { 0, 1, -4, 12, 126, -9, 3, -1 },
-  { 0, 1, -2, 7, 127, -6, 2, -1 },     { 0, 0, -1, 3, 128, -3, 1, 0 }
+  { 0, 1, -2, 7, 127, -6, 2, -1 },     { 0, 0, -1, 3, 128, -3, 1, 0 },
+#elif SUBPEL_BITS_RS == 6
+  { 0, 0, 0, 128, 0, 0, 0, 0 },        { 0, 0, -1, 128, 2, -1, 0, 0 },
+  { 0, 1, -3, 127, 4, -2, 1, 0 },      { 0, 1, -4, 127, 6, -3, 1, 0 },
+  { 0, 2, -6, 126, 8, -3, 1, 0 },      { 0, 2, -7, 125, 11, -4, 1, 0 },
+  { -1, 2, -8, 125, 13, -5, 2, 0 },    { -1, 3, -9, 124, 15, -6, 2, 0 },
+  { -1, 3, -10, 123, 18, -6, 2, -1 },  { -1, 3, -11, 122, 20, -7, 3, -1 },
+  { -1, 4, -12, 121, 22, -8, 3, -1 },  { -1, 4, -13, 120, 25, -9, 3, -1 },
+  { -1, 4, -14, 118, 28, -9, 3, -1 },  { -1, 4, -15, 117, 30, -10, 4, -1 },
+  { -1, 5, -16, 116, 32, -11, 4, -1 }, { -1, 5, -16, 114, 35, -12, 4, -1 },
+  { -1, 5, -17, 112, 38, -12, 4, -1 }, { -1, 5, -18, 111, 40, -13, 5, -1 },
+  { -1, 5, -18, 109, 43, -14, 5, -1 }, { -1, 6, -19, 107, 45, -14, 5, -1 },
+  { -1, 6, -19, 105, 48, -15, 5, -1 }, { -1, 6, -19, 103, 51, -16, 5, -1 },
+  { -1, 6, -20, 101, 53, -16, 6, -1 }, { -1, 6, -20, 99, 56, -17, 6, -1 },
+  { -1, 6, -20, 97, 58, -17, 6, -1 },  { -1, 6, -20, 95, 61, -18, 6, -1 },
+  { -2, 7, -20, 93, 64, -18, 6, -2 },  { -2, 7, -20, 91, 66, -19, 6, -1 },
+  { -2, 7, -20, 88, 69, -19, 6, -1 },  { -2, 7, -20, 86, 71, -19, 6, -1 },
+  { -2, 7, -20, 84, 74, -20, 7, -2 },  { -2, 7, -20, 81, 76, -20, 7, -1 },
+  { -2, 7, -20, 79, 79, -20, 7, -2 },  { -1, 7, -20, 76, 81, -20, 7, -2 },
+  { -2, 7, -20, 74, 84, -20, 7, -2 },  { -1, 6, -19, 71, 86, -20, 7, -2 },
+  { -1, 6, -19, 69, 88, -20, 7, -2 },  { -1, 6, -19, 66, 91, -20, 7, -2 },
+  { -2, 6, -18, 64, 93, -20, 7, -2 },  { -1, 6, -18, 61, 95, -20, 6, -1 },
+  { -1, 6, -17, 58, 97, -20, 6, -1 },  { -1, 6, -17, 56, 99, -20, 6, -1 },
+  { -1, 6, -16, 53, 101, -20, 6, -1 }, { -1, 5, -16, 51, 103, -19, 6, -1 },
+  { -1, 5, -15, 48, 105, -19, 6, -1 }, { -1, 5, -14, 45, 107, -19, 6, -1 },
+  { -1, 5, -14, 43, 109, -18, 5, -1 }, { -1, 5, -13, 40, 111, -18, 5, -1 },
+  { -1, 4, -12, 38, 112, -17, 5, -1 }, { -1, 4, -12, 35, 114, -16, 5, -1 },
+  { -1, 4, -11, 32, 116, -16, 5, -1 }, { -1, 4, -10, 30, 117, -15, 4, -1 },
+  { -1, 3, -9, 28, 118, -14, 4, -1 },  { -1, 3, -9, 25, 120, -13, 4, -1 },
+  { -1, 3, -8, 22, 121, -12, 4, -1 },  { -1, 3, -7, 20, 122, -11, 3, -1 },
+  { -1, 2, -6, 18, 123, -10, 3, -1 },  { 0, 2, -6, 15, 124, -9, 3, -1 },
+  { 0, 2, -5, 13, 125, -8, 2, -1 },    { 0, 1, -4, 11, 125, -7, 2, 0 },
+  { 0, 1, -3, 8, 126, -6, 2, 0 },      { 0, 1, -3, 6, 127, -4, 1, 0 },
+  { 0, 1, -2, 4, 127, -3, 1, 0 },      { 0, 0, -1, 2, 128, -1, 0, 0 },
+#endif  // SUBPEL_BITS_RS == 5
 };
 
 // Filters for factor of 2 downsampling.
 static const int16_t av1_down2_symeven_half_filter[] = { 56, 12, -3, -1 };
 static const int16_t av1_down2_symodd_half_filter[] = { 64, 35, 0, -3 };
 
 static const interp_kernel *choose_interp_filter(int inlength, int outlength) {
   int outlength16 = outlength * 16;
@@ -167,75 +344,72 @@ static void interpolate(const uint8_t *c
   uint8_t *optr = output;
   int x, x1, x2, sum, k, int_pel, sub_pel;
   int64_t y;
 
   const interp_kernel *interp_filters =
       choose_interp_filter(inlength, outlength);
 
   x = 0;
-  y = offset;
+  y = offset + SUBPEL_INTERP_EXTRA_OFF;
   while ((y >> INTERP_PRECISION_BITS) < (INTERP_TAPS / 2 - 1)) {
     x++;
     y += delta;
   }
   x1 = x;
   x = outlength - 1;
-  y = delta * x + offset;
+  y = delta * x + offset + SUBPEL_INTERP_EXTRA_OFF;
   while ((y >> INTERP_PRECISION_BITS) + (int64_t)(INTERP_TAPS / 2) >=
          inlength) {
     x--;
     y -= delta;
   }
   x2 = x;
   if (x1 > x2) {
-    for (x = 0, y = offset; x < outlength; ++x, y += delta) {
+    for (x = 0, y = offset + SUBPEL_INTERP_EXTRA_OFF; x < outlength;
+         ++x, y += delta) {
       const int16_t *filter;
       int_pel = y >> INTERP_PRECISION_BITS;
-      sub_pel =
-          (y >> (INTERP_PRECISION_BITS - SUBPEL_BITS_RS)) & SUBPEL_MASK_RS;
+      sub_pel = (y >> SUBPEL_INTERP_EXTRA_BITS) & SUBPEL_MASK_RS;
       filter = interp_filters[sub_pel];
       sum = 0;
       for (k = 0; k < INTERP_TAPS; ++k) {
         const int pk = int_pel - INTERP_TAPS / 2 + 1 + k;
         sum += filter[k] * input[AOMMAX(AOMMIN(pk, inlength - 1), 0)];
       }
       *optr++ = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
     }
   } else {
     // Initial part.
-    for (x = 0, y = offset; x < x1; ++x, y += delta) {
+    for (x = 0, y = offset + SUBPEL_INTERP_EXTRA_OFF; x < x1; ++x, y += delta) {
       const int16_t *filter;
       int_pel = y >> INTERP_PRECISION_BITS;
-      sub_pel =
-          (y >> (INTERP_PRECISION_BITS - SUBPEL_BITS_RS)) & SUBPEL_MASK_RS;
+      sub_pel = (y >> SUBPEL_INTERP_EXTRA_BITS) & SUBPEL_MASK_RS;
       filter = interp_filters[sub_pel];
       sum = 0;
       for (k = 0; k < INTERP_TAPS; ++k)
         sum += filter[k] * input[AOMMAX(int_pel - INTERP_TAPS / 2 + 1 + k, 0)];
       *optr++ = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
     }
     // Middle part.
     for (; x <= x2; ++x, y += delta) {
       const int16_t *filter;
       int_pel = y >> INTERP_PRECISION_BITS;
-      sub_pel =
-          (y >> (INTERP_PRECISION_BITS - SUBPEL_BITS_RS)) & SUBPEL_MASK_RS;
+      sub_pel = (y >> SUBPEL_INTERP_EXTRA_BITS) & SUBPEL_MASK_RS;
       filter = interp_filters[sub_pel];
       sum = 0;
       for (k = 0; k < INTERP_TAPS; ++k)
         sum += filter[k] * input[int_pel - INTERP_TAPS / 2 + 1 + k];
       *optr++ = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
     }
     // End part.
     for (; x < outlength; ++x, y += delta) {
       const int16_t *filter;
       int_pel = y >> INTERP_PRECISION_BITS;
-      sub_pel =
-          (y >> (INTERP_PRECISION_BITS - SUBPEL_BITS_RS)) & SUBPEL_MASK_RS;
+      sub_pel = (y >> SUBPEL_INTERP_EXTRA_BITS) & SUBPEL_MASK_RS;
       filter = interp_filters[sub_pel];
       sum = 0;
       for (k = 0; k < INTERP_TAPS; ++k)
         sum += filter[k] *
                input[AOMMIN(int_pel - INTERP_TAPS / 2 + 1 + k, inlength - 1)];
       *optr++ = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
     }
   }
@@ -466,84 +640,82 @@ static void highbd_interpolate(const uin
   uint16_t *optr = output;
   int x, x1, x2, sum, k, int_pel, sub_pel;
   int64_t y;
 
   const interp_kernel *interp_filters =
       choose_interp_filter(inlength, outlength);
 
   x = 0;
-  y = offset;
+  y = offset + SUBPEL_INTERP_EXTRA_OFF;
   while ((y >> INTERP_PRECISION_BITS) < (INTERP_TAPS / 2 - 1)) {
     x++;
     y += delta;
   }
   x1 = x;
   x = outlength - 1;
-  y = delta * x + offset;
+  y = delta * x + offset + SUBPEL_INTERP_EXTRA_OFF;
   while ((y >> INTERP_PRECISION_BITS) + (int64_t)(INTERP_TAPS / 2) >=
          inlength) {
     x--;
     y -= delta;
   }
   x2 = x;
   if (x1 > x2) {
-    for (x = 0, y = offset; x < outlength; ++x, y += delta) {
+    for (x = 0, y = offset + SUBPEL_INTERP_EXTRA_OFF; x < outlength;
+         ++x, y += delta) {
       const int16_t *filter;
       int_pel = y >> INTERP_PRECISION_BITS;
-      sub_pel =
-          (y >> (INTERP_PRECISION_BITS - SUBPEL_BITS_RS)) & SUBPEL_MASK_RS;
+      sub_pel = (y >> SUBPEL_INTERP_EXTRA_BITS) & SUBPEL_MASK_RS;
       filter = interp_filters[sub_pel];
       sum = 0;
       for (k = 0; k < INTERP_TAPS; ++k) {
         const int pk = int_pel - INTERP_TAPS / 2 + 1 + k;
         sum += filter[k] * input[AOMMAX(AOMMIN(pk, inlength - 1), 0)];
       }
       *optr++ = clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd);
     }
   } else {
     // Initial part.
-    for (x = 0, y = offset; x < x1; ++x, y += delta) {
+    for (x = 0, y = offset + SUBPEL_INTERP_EXTRA_OFF; x < x1; ++x, y += delta) {
       const int16_t *filter;
       int_pel = y >> INTERP_PRECISION_BITS;
-      sub_pel =
-          (y >> (INTERP_PRECISION_BITS - SUBPEL_BITS_RS)) & SUBPEL_MASK_RS;
+      sub_pel = (y >> SUBPEL_INTERP_EXTRA_BITS) & SUBPEL_MASK_RS;
       filter = interp_filters[sub_pel];
       sum = 0;
       for (k = 0; k < INTERP_TAPS; ++k)
         sum += filter[k] * input[AOMMAX(int_pel - INTERP_TAPS / 2 + 1 + k, 0)];
       *optr++ = clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd);
     }
     // Middle part.
     for (; x <= x2; ++x, y += delta) {
       const int16_t *filter;
       int_pel = y >> INTERP_PRECISION_BITS;
-      sub_pel =
-          (y >> (INTERP_PRECISION_BITS - SUBPEL_BITS_RS)) & SUBPEL_MASK_RS;
+      sub_pel = (y >> SUBPEL_INTERP_EXTRA_BITS) & SUBPEL_MASK_RS;
       filter = interp_filters[sub_pel];
       sum = 0;
       for (k = 0; k < INTERP_TAPS; ++k)
         sum += filter[k] * input[int_pel - INTERP_TAPS / 2 + 1 + k];
       *optr++ = clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd);
     }
     // End part.
     for (; x < outlength; ++x, y += delta) {
       const int16_t *filter;
       int_pel = y >> INTERP_PRECISION_BITS;
-      sub_pel =
-          (y >> (INTERP_PRECISION_BITS - SUBPEL_BITS_RS)) & SUBPEL_MASK_RS;
+      sub_pel = (y >> SUBPEL_INTERP_EXTRA_BITS) & SUBPEL_MASK_RS;
       filter = interp_filters[sub_pel];
       sum = 0;
       for (k = 0; k < INTERP_TAPS; ++k)
         sum += filter[k] *
                input[AOMMIN(int_pel - INTERP_TAPS / 2 + 1 + k, inlength - 1)];
       *optr++ = clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd);
     }
   }
 }
+
 #ifndef __clang_analyzer__
 static void highbd_down2_symeven(const uint16_t *const input, int length,
                                  uint16_t *output, int bd) {
   // Actual filter len = 2 * filter_len_half.
   static const int16_t *filter = av1_down2_symeven_half_filter;
   const int filter_len_half = sizeof(av1_down2_symeven_half_filter) / 2;
   int i, j;
   uint16_t *optr = output;
@@ -811,21 +983,21 @@ void av1_highbd_resize_frame444(const ui
   av1_highbd_resize_plane(u, height, width, uv_stride, ou, oheight, owidth,
                           ouv_stride, bd);
   av1_highbd_resize_plane(v, height, width, uv_stride, ov, oheight, owidth,
                           ouv_stride, bd);
 }
 #endif  // CONFIG_HIGHBITDEPTH
 
 #if CONFIG_HIGHBITDEPTH
-static void resize_and_extend_frame(const YV12_BUFFER_CONFIG *src,
-                                    YV12_BUFFER_CONFIG *dst, int bd) {
+void av1_resize_and_extend_frame(const YV12_BUFFER_CONFIG *src,
+                                 YV12_BUFFER_CONFIG *dst, int bd) {
 #else
-static void resize_and_extend_frame(const YV12_BUFFER_CONFIG *src,
-                                    YV12_BUFFER_CONFIG *dst) {
+void av1_resize_and_extend_frame(const YV12_BUFFER_CONFIG *src,
+                                 YV12_BUFFER_CONFIG *dst) {
 #endif  // CONFIG_HIGHBITDEPTH
   // TODO(dkovalev): replace YV12_BUFFER_CONFIG with aom_image_t
   int i;
   const uint8_t *const srcs[3] = { src->y_buffer, src->u_buffer,
                                    src->v_buffer };
   const int src_strides[3] = { src->y_stride, src->uv_stride, src->uv_stride };
   const int src_widths[3] = { src->y_crop_width, src->uv_crop_width,
                               src->uv_crop_width };
@@ -850,33 +1022,130 @@ static void resize_and_extend_frame(cons
                        dsts[i], dst_heights[i], dst_widths[i], dst_strides[i]);
   }
   aom_extend_frame_borders(dst);
 }
 
 YV12_BUFFER_CONFIG *av1_scale_if_required_fast(AV1_COMMON *cm,
                                                YV12_BUFFER_CONFIG *unscaled,
                                                YV12_BUFFER_CONFIG *scaled) {
-  if (cm->mi_cols * MI_SIZE != unscaled->y_width ||
-      cm->mi_rows * MI_SIZE != unscaled->y_height) {
+  if (cm->width != unscaled->y_crop_width ||
+      cm->height != unscaled->y_crop_height) {
     // For 2x2 scaling down.
     aom_scale_frame(unscaled, scaled, unscaled->y_buffer, 9, 2, 1, 2, 1, 0);
     aom_extend_frame_borders(scaled);
     return scaled;
   } else {
     return unscaled;
   }
 }
 
 YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm,
                                           YV12_BUFFER_CONFIG *unscaled,
                                           YV12_BUFFER_CONFIG *scaled) {
-  if (cm->width != unscaled->y_width || cm->height != unscaled->y_height) {
+  if (cm->width != unscaled->y_crop_width ||
+      cm->height != unscaled->y_crop_height) {
 #if CONFIG_HIGHBITDEPTH
-    resize_and_extend_frame(unscaled, scaled, (int)cm->bit_depth);
+    av1_resize_and_extend_frame(unscaled, scaled, (int)cm->bit_depth);
 #else
-    resize_and_extend_frame(unscaled, scaled);
+    av1_resize_and_extend_frame(unscaled, scaled);
 #endif  // CONFIG_HIGHBITDEPTH
     return scaled;
   } else {
     return unscaled;
   }
 }
+
+void av1_calculate_scaled_size(int *width, int *height, int num) {
+  if (num != SCALE_DENOMINATOR) {
+    *width = *width * num / SCALE_DENOMINATOR;
+    *height = *height * num / SCALE_DENOMINATOR;
+    // Make width and height even
+    *width += *width & 1;
+    *height += *height & 1;
+  }
+}
+
+#if CONFIG_FRAME_SUPERRES
+// TODO(afergs): Look for in-place upscaling
+// TODO(afergs): aom_ vs av1_ functions? Which can I use?
+// Upscale decoded image.
+void av1_superres_upscale(AV1_COMMON *cm, BufferPool *const pool) {
+  if (av1_superres_unscaled(cm)) return;
+
+  YV12_BUFFER_CONFIG copy_buffer;
+  memset(&copy_buffer, 0, sizeof(copy_buffer));
+
+  YV12_BUFFER_CONFIG *const frame_to_show = get_frame_new_buffer(cm);
+
+  if (aom_alloc_frame_buffer(&copy_buffer, cm->width, cm->height,
+                             cm->subsampling_x, cm->subsampling_y,
+#if CONFIG_HIGHBITDEPTH
+                             cm->use_highbitdepth,
+#endif  // CONFIG_HIGHBITDEPTH
+                             AOM_BORDER_IN_PIXELS, cm->byte_alignment))
+    aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
+                       "Failed to allocate copy buffer for superres upscaling");
+
+  // Copy function assumes the frames are the same size, doesn't copy bit_depth.
+  aom_yv12_copy_frame(frame_to_show, &copy_buffer);
+  copy_buffer.bit_depth = frame_to_show->bit_depth;
+  assert(copy_buffer.y_crop_width == cm->width);
+  assert(copy_buffer.y_crop_height == cm->height);
+
+  // Realloc the current frame buffer at a higher resolution in place.
+  if (pool != NULL) {
+    // Use callbacks if on the decoder.
+    aom_codec_frame_buffer_t *fb =
+        &pool->frame_bufs[cm->new_fb_idx].raw_frame_buffer;
+    aom_release_frame_buffer_cb_fn_t release_fb_cb = pool->release_fb_cb;
+    aom_get_frame_buffer_cb_fn_t cb = pool->get_fb_cb;
+    void *cb_priv = pool->cb_priv;
+
+    // Realloc with callback does not release the frame buffer - release first.
+    if (release_fb_cb(cb_priv, fb))
+      aom_internal_error(
+          &cm->error, AOM_CODEC_MEM_ERROR,
+          "Failed to free current frame buffer before superres upscaling");
+
+    if (aom_realloc_frame_buffer(
+            frame_to_show, cm->superres_upscaled_width,
+            cm->superres_upscaled_height, cm->subsampling_x, cm->subsampling_y,
+#if CONFIG_HIGHBITDEPTH
+            cm->use_highbitdepth,
+#endif  // CONFIG_HIGHBITDEPTH
+            AOM_BORDER_IN_PIXELS, cm->byte_alignment, fb, cb, cb_priv))
+      aom_internal_error(
+          &cm->error, AOM_CODEC_MEM_ERROR,
+          "Failed to allocate current frame buffer for superres upscaling");
+  } else {
+    // Don't use callbacks on the encoder.
+    if (aom_alloc_frame_buffer(frame_to_show, cm->superres_upscaled_width,
+                               cm->superres_upscaled_height, cm->subsampling_x,
+                               cm->subsampling_y,
+#if CONFIG_HIGHBITDEPTH
+                               cm->use_highbitdepth,
+#endif  // CONFIG_HIGHBITDEPTH
+                               AOM_BORDER_IN_PIXELS, cm->byte_alignment))
+      aom_internal_error(
+          &cm->error, AOM_CODEC_MEM_ERROR,
+          "Failed to reallocate current frame buffer for superres upscaling");
+  }
+  // TODO(afergs): verify frame_to_show is correct after realloc
+  //               encoder:
+  //               decoder:
+  frame_to_show->bit_depth = copy_buffer.bit_depth;
+  assert(frame_to_show->y_crop_width == cm->superres_upscaled_width);
+  assert(frame_to_show->y_crop_height == cm->superres_upscaled_height);
+
+  // Scale up and back into frame_to_show.
+  assert(frame_to_show->y_crop_width != cm->width);
+  assert(frame_to_show->y_crop_height != cm->height);
+#if CONFIG_HIGHBITDEPTH
+  av1_resize_and_extend_frame(&copy_buffer, frame_to_show, (int)cm->bit_depth);
+#else
+  av1_resize_and_extend_frame(&copy_buffer, frame_to_show);
+#endif  // CONFIG_HIGHBITDEPTH
+
+  // Free the copy buffer
+  aom_free_frame_buffer(&copy_buffer);
+}
+#endif  // CONFIG_FRAME_SUPERRES
--- a/third_party/aom/av1/common/resize.h
+++ b/third_party/aom/av1/common/resize.h
@@ -58,21 +58,40 @@ void av1_highbd_resize_frame422(const ui
 void av1_highbd_resize_frame444(const uint8_t *const y, int y_stride,
                                 const uint8_t *const u, const uint8_t *const v,
                                 int uv_stride, int height, int width,
                                 uint8_t *oy, int oy_stride, uint8_t *ou,
                                 uint8_t *ov, int ouv_stride, int oheight,
                                 int owidth, int bd);
 #endif  // CONFIG_HIGHBITDEPTH
 
+#if CONFIG_HIGHBITDEPTH
+void av1_resize_and_extend_frame(const YV12_BUFFER_CONFIG *src,
+                                 YV12_BUFFER_CONFIG *dst, int bd);
+#else
+void av1_resize_and_extend_frame(const YV12_BUFFER_CONFIG *src,
+                                 YV12_BUFFER_CONFIG *dst);
+#endif  // CONFIG_HIGHBITDEPTH
+
 YV12_BUFFER_CONFIG *av1_scale_if_required_fast(AV1_COMMON *cm,
                                                YV12_BUFFER_CONFIG *unscaled,
                                                YV12_BUFFER_CONFIG *scaled);
 
 YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm,
                                           YV12_BUFFER_CONFIG *unscaled,
                                           YV12_BUFFER_CONFIG *scaled);
 
+void av1_calculate_scaled_size(int *width, int *height, int num);
+
+#if CONFIG_FRAME_SUPERRES
+void av1_superres_upscale(AV1_COMMON *cm, BufferPool *const pool);
+
+// Returns 1 if a superres upscaled frame is unscaled and 0 otherwise.
+static INLINE int av1_superres_unscaled(const AV1_COMMON *cm) {
+  return (cm->superres_scale_numerator == SCALE_DENOMINATOR);
+}
+#endif  // CONFIG_FRAME_SUPERRES
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
 #endif  // AV1_ENCODER_RESIZE_H_
--- a/third_party/aom/av1/common/restoration.c
+++ b/third_party/aom/av1/common/restoration.c
@@ -1232,18 +1232,20 @@ static void loop_switchable_filter_highb
 }
 #endif  // CONFIG_HIGHBITDEPTH
 
 static void loop_restoration_rows(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
                                   int start_mi_row, int end_mi_row,
                                   int components_pattern, RestorationInfo *rsi,
                                   YV12_BUFFER_CONFIG *dst) {
   const int ywidth = frame->y_crop_width;
+  const int yheight = frame->y_crop_height;
+  const int uvwidth = frame->uv_crop_width;
+  const int uvheight = frame->uv_crop_height;
   const int ystride = frame->y_stride;
-  const int uvwidth = frame->uv_crop_width;
   const int uvstride = frame->uv_stride;
   const int ystart = start_mi_row << MI_SIZE_LOG2;
   const int uvstart = ystart >> cm->subsampling_y;
   int yend = end_mi_row << MI_SIZE_LOG2;
   int uvend = yend >> cm->subsampling_y;
   restore_func_type restore_funcs[RESTORE_TYPES] = {
     NULL, loop_wiener_filter, loop_sgrproj_filter, loop_switchable_filter
   };
@@ -1254,18 +1256,18 @@ static void loop_restoration_rows(YV12_B
   };
 #endif  // CONFIG_HIGHBITDEPTH
   restore_func_type restore_func;
 #if CONFIG_HIGHBITDEPTH
   restore_func_highbd_type restore_func_highbd;
 #endif  // CONFIG_HIGHBITDEPTH
   YV12_BUFFER_CONFIG dst_;
 
-  yend = AOMMIN(yend, cm->height);
-  uvend = AOMMIN(uvend, cm->subsampling_y ? (cm->height + 1) >> 1 : cm->height);
+  yend = AOMMIN(yend, yheight);
+  uvend = AOMMIN(uvend, uvheight);
 
   if (components_pattern == (1 << AOM_PLANE_Y)) {
     // Only y
     if (rsi[0].frame_restoration_type == RESTORE_NONE) {
       if (dst) aom_yv12_copy_y(frame, dst);
       return;
     }
   } else if (components_pattern == (1 << AOM_PLANE_U)) {
@@ -1290,29 +1292,29 @@ static void loop_restoration_rows(YV12_B
       return;
     }
   }
 
   if (!dst) {
     dst = &dst_;
     memset(dst, 0, sizeof(YV12_BUFFER_CONFIG));
     if (aom_realloc_frame_buffer(
-            dst, cm->width, cm->height, cm->subsampling_x, cm->subsampling_y,
+            dst, ywidth, yheight, cm->subsampling_x, cm->subsampling_y,
 #if CONFIG_HIGHBITDEPTH
             cm->use_highbitdepth,
 #endif
             AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL, NULL, NULL) < 0)
       aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
                          "Failed to allocate restoration dst buffer");
   }
 
   if ((components_pattern >> AOM_PLANE_Y) & 1) {
     if (rsi[0].frame_restoration_type != RESTORE_NONE) {
       cm->rst_internal.ntiles = av1_get_rest_ntiles(
-          cm->width, cm->height, cm->rst_info[AOM_PLANE_Y].restoration_tilesize,
+          ywidth, yheight, cm->rst_info[AOM_PLANE_Y].restoration_tilesize,
           &cm->rst_internal.tile_width, &cm->rst_internal.tile_height,
           &cm->rst_internal.nhtiles, &cm->rst_internal.nvtiles);
       cm->rst_internal.rsi = &rsi[0];
       restore_func =
           restore_funcs[cm->rst_internal.rsi->frame_restoration_type];
 #if CONFIG_HIGHBITDEPTH
       restore_func_highbd =
           restore_funcs_highbd[cm->rst_internal.rsi->frame_restoration_type];
@@ -1329,19 +1331,17 @@ static void loop_restoration_rows(YV12_B
     } else {
       aom_yv12_copy_y(frame, dst);
     }
   }
 
   if ((components_pattern >> AOM_PLANE_U) & 1) {
     if (rsi[AOM_PLANE_U].frame_restoration_type != RESTORE_NONE) {
       cm->rst_internal.ntiles = av1_get_rest_ntiles(
-          ROUND_POWER_OF_TWO(cm->width, cm->subsampling_x),
-          ROUND_POWER_OF_TWO(cm->height, cm->subsampling_y),
-          cm->rst_info[AOM_PLANE_U].restoration_tilesize,
+          uvwidth, uvheight, cm->rst_info[AOM_PLANE_U].restoration_tilesize,
           &cm->rst_internal.tile_width, &cm->rst_internal.tile_height,
           &cm->rst_internal.nhtiles, &cm->rst_internal.nvtiles);
       cm->rst_internal.rsi = &rsi[AOM_PLANE_U];
       restore_func =
           restore_funcs[cm->rst_internal.rsi->frame_restoration_type];
 #if CONFIG_HIGHBITDEPTH
       restore_func_highbd =
           restore_funcs_highbd[cm->rst_internal.rsi->frame_restoration_type];
@@ -1358,19 +1358,17 @@ static void loop_restoration_rows(YV12_B
     } else {
       aom_yv12_copy_u(frame, dst);
     }
   }
 
   if ((components_pattern >> AOM_PLANE_V) & 1) {
     if (rsi[AOM_PLANE_V].frame_restoration_type != RESTORE_NONE) {
       cm->rst_internal.ntiles = av1_get_rest_ntiles(
-          ROUND_POWER_OF_TWO(cm->width, cm->subsampling_x),
-          ROUND_POWER_OF_TWO(cm->height, cm->subsampling_y),
-          cm->rst_info[AOM_PLANE_V].restoration_tilesize,
+          uvwidth, uvheight, cm->rst_info[AOM_PLANE_V].restoration_tilesize,
           &cm->rst_internal.tile_width, &cm->rst_internal.tile_height,
           &cm->rst_internal.nhtiles, &cm->rst_internal.nvtiles);
       cm->rst_internal.rsi = &rsi[AOM_PLANE_V];
       restore_func =
           restore_funcs[cm->rst_internal.rsi->frame_restoration_type];
 #if CONFIG_HIGHBITDEPTH
       restore_func_highbd =
           restore_funcs_highbd[cm->rst_internal.rsi->frame_restoration_type];
@@ -1397,19 +1395,24 @@ static void loop_restoration_rows(YV12_B
   }
 }
 
 void av1_loop_restoration_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
                                 RestorationInfo *rsi, int components_pattern,
                                 int partial_frame, YV12_BUFFER_CONFIG *dst) {
   int start_mi_row, end_mi_row, mi_rows_to_filter;
   start_mi_row = 0;
+#if CONFIG_FRAME_SUPERRES
+  mi_rows_to_filter =
+      ALIGN_POWER_OF_TWO(cm->superres_upscaled_height, 3) >> MI_SIZE_LOG2;
+#else
   mi_rows_to_filter = cm->mi_rows;
-  if (partial_frame && cm->mi_rows > 8) {
-    start_mi_row = cm->mi_rows >> 1;
+#endif  // CONFIG_FRAME_SUPERRES
+  if (partial_frame && mi_rows_to_filter > 8) {
+    start_mi_row = mi_rows_to_filter >> 1;
     start_mi_row &= 0xfffffff8;
-    mi_rows_to_filter = AOMMAX(cm->mi_rows / 8, 8);
+    mi_rows_to_filter = AOMMAX(mi_rows_to_filter / 8, 8);
   }
   end_mi_row = start_mi_row + mi_rows_to_filter;
   loop_restoration_init(&cm->rst_internal, cm->frame_type == KEY_FRAME);
   loop_restoration_rows(frame, cm, start_mi_row, end_mi_row, components_pattern,
                         rsi, dst);
 }
--- a/third_party/aom/av1/common/scale.c
+++ b/third_party/aom/av1/common/scale.c
@@ -9,42 +9,63 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #include "./aom_dsp_rtcd.h"
 #include "av1/common/filter.h"
 #include "av1/common/scale.h"
 #include "aom_dsp/aom_filter.h"
 
+// Note: Expect val to be in q4 precision
 static INLINE int scaled_x(int val, const struct scale_factors *sf) {
-  return (int)((int64_t)val * sf->x_scale_fp >> REF_SCALE_SHIFT);
+  const int off = (sf->x_scale_fp - (1 << REF_SCALE_SHIFT))
+                  << (SUBPEL_BITS - 1);
+  const int64_t tval = (int64_t)val * sf->x_scale_fp + off;
+  return (int)ROUND_POWER_OF_TWO_SIGNED_64(tval,
+                                           REF_SCALE_SHIFT - SCALE_EXTRA_BITS);
 }
 
+// Note: Expect val to be in q4 precision
 static INLINE int scaled_y(int val, const struct scale_factors *sf) {
-  return (int)((int64_t)val * sf->y_scale_fp >> REF_SCALE_SHIFT);
+  const int off = (sf->y_scale_fp - (1 << REF_SCALE_SHIFT))
+                  << (SUBPEL_BITS - 1);
+  const int64_t tval = (int64_t)val * sf->y_scale_fp + off;
+  return (int)ROUND_POWER_OF_TWO_SIGNED_64(tval,
+                                           REF_SCALE_SHIFT - SCALE_EXTRA_BITS);
 }
 
+// Note: Expect val to be in q4 precision
 static int unscaled_value(int val, const struct scale_factors *sf) {
   (void)sf;
-  return val;
+  return val << SCALE_EXTRA_BITS;
 }
 
 static int get_fixed_point_scale_factor(int other_size, int this_size) {
   // Calculate scaling factor once for each reference frame
   // and use fixed point scaling factors in decoding and encoding routines.
   // Hardware implementations can calculate scale factor in device driver
   // and use multiplication and shifting on hardware instead of division.
-  return (other_size << REF_SCALE_SHIFT) / this_size;
+  return ((other_size << REF_SCALE_SHIFT) + this_size / 2) / this_size;
 }
 
-MV32 av1_scale_mv(const MV *mv, int x, int y, const struct scale_factors *sf) {
-  const int x_off_q4 = scaled_x(x << SUBPEL_BITS, sf) & SUBPEL_MASK;
-  const int y_off_q4 = scaled_y(y << SUBPEL_BITS, sf) & SUBPEL_MASK;
-  const MV32 res = { scaled_y(mv->row, sf) + y_off_q4,
-                     scaled_x(mv->col, sf) + x_off_q4 };
+static int get_coarse_point_scale_factor(int other_size, int this_size) {
+  // Calculate scaling factor once for each reference frame
+  // and use fixed point scaling factors in decoding and encoding routines.
+  // Hardware implementations can calculate scale factor in device driver
+  // and use multiplication and shifting on hardware instead of division.
+  return ((other_size << SCALE_SUBPEL_BITS) + this_size / 2) / this_size;
+}
+
+// Note: x and y are integer precision, mvq4 is q4 precision.
+MV32 av1_scale_mv(const MV *mvq4, int x, int y,
+                  const struct scale_factors *sf) {
+  const int x_off_q4 = scaled_x(x << SUBPEL_BITS, sf);
+  const int y_off_q4 = scaled_y(y << SUBPEL_BITS, sf);
+  const MV32 res = { scaled_y((y << SUBPEL_BITS) + mvq4->row, sf) - y_off_q4,
+                     scaled_x((x << SUBPEL_BITS) + mvq4->col, sf) - x_off_q4 };
   return res;
 }
 
 #if CONFIG_HIGHBITDEPTH
 void av1_setup_scale_factors_for_frame(struct scale_factors *sf, int other_w,
                                        int other_h, int this_w, int this_h,
                                        int use_highbd) {
 #else
@@ -54,35 +75,36 @@ void av1_setup_scale_factors_for_frame(s
   if (!valid_ref_frame_size(other_w, other_h, this_w, this_h)) {
     sf->x_scale_fp = REF_INVALID_SCALE;
     sf->y_scale_fp = REF_INVALID_SCALE;
     return;
   }
 
   sf->x_scale_fp = get_fixed_point_scale_factor(other_w, this_w);
   sf->y_scale_fp = get_fixed_point_scale_factor(other_h, this_h);
-  sf->x_step_q4 = scaled_x(16, sf);
-  sf->y_step_q4 = scaled_y(16, sf);
+
+  sf->x_step_q4 = get_coarse_point_scale_factor(other_w, this_w);
+  sf->y_step_q4 = get_coarse_point_scale_factor(other_h, this_h);
 
   if (av1_is_scaled(sf)) {
     sf->scale_value_x = scaled_x;
     sf->scale_value_y = scaled_y;
   } else {
     sf->scale_value_x = unscaled_value;
     sf->scale_value_y = unscaled_value;
   }
 
   // TODO(agrange): Investigate the best choice of functions to use here
   // for EIGHTTAP_SMOOTH. Since it is not interpolating, need to choose what
   // to do at full-pel offsets. The current selection, where the filter is
   // applied in one direction only, and not at all for 0,0, seems to give the
   // best quality, but it may be worth trying an additional mode that does
   // do the filtering on full-pel.
-  if (sf->x_step_q4 == 16) {
-    if (sf->y_step_q4 == 16) {
+  if (sf->x_step_q4 == SCALE_SUBPEL_SHIFTS) {
+    if (sf->y_step_q4 == SCALE_SUBPEL_SHIFTS) {
       // No scaling in either direction.
       sf->predict[0][0][0] = aom_convolve_copy;
       sf->predict[0][0][1] = aom_convolve_avg;
       sf->predict[0][1][0] = aom_convolve8_vert;
       sf->predict[0][1][1] = aom_convolve8_avg_vert;
       sf->predict[1][0][0] = aom_convolve8_horiz;
       sf->predict[1][0][1] = aom_convolve8_avg_horiz;
     } else {
@@ -90,17 +112,17 @@ void av1_setup_scale_factors_for_frame(s
       sf->predict[0][0][0] = aom_convolve8_vert;
       sf->predict[0][0][1] = aom_convolve8_avg_vert;
       sf->predict[0][1][0] = aom_convolve8_vert;
       sf->predict[0][1][1] = aom_convolve8_avg_vert;
       sf->predict[1][0][0] = aom_convolve8;
       sf->predict[1][0][1] = aom_convolve8_avg;
     }
   } else {
-    if (sf->y_step_q4 == 16) {
+    if (sf->y_step_q4 == SCALE_SUBPEL_SHIFTS) {
       // No scaling in the y direction. Must always scale in the x direction.
       sf->predict[0][0][0] = aom_convolve8_horiz;
       sf->predict[0][0][1] = aom_convolve8_avg_horiz;
       sf->predict[0][1][0] = aom_convolve8;
       sf->predict[0][1][1] = aom_convolve8_avg;
       sf->predict[1][0][0] = aom_convolve8_horiz;
       sf->predict[1][0][1] = aom_convolve8_avg_horiz;
     } else {
@@ -114,18 +136,18 @@ void av1_setup_scale_factors_for_frame(s
     }
   }
   // 2D subpel motion always gets filtered in both directions
   sf->predict[1][1][0] = aom_convolve8;
   sf->predict[1][1][1] = aom_convolve8_avg;
 
 #if CONFIG_HIGHBITDEPTH
   if (use_highbd) {
-    if (sf->x_step_q4 == 16) {
-      if (sf->y_step_q4 == 16) {
+    if (sf->x_step_q4 == SCALE_SUBPEL_SHIFTS) {
+      if (sf->y_step_q4 == SCALE_SUBPEL_SHIFTS) {
         // No scaling in either direction.
         sf->highbd_predict[0][0][0] = aom_highbd_convolve_copy;
         sf->highbd_predict[0][0][1] = aom_highbd_convolve_avg;
         sf->highbd_predict[0][1][0] = aom_highbd_convolve8_vert;
         sf->highbd_predict[0][1][1] = aom_highbd_convolve8_avg_vert;
         sf->highbd_predict[1][0][0] = aom_highbd_convolve8_horiz;
         sf->highbd_predict[1][0][1] = aom_highbd_convolve8_avg_horiz;
       } else {
@@ -133,17 +155,17 @@ void av1_setup_scale_factors_for_frame(s
         sf->highbd_predict[0][0][0] = aom_highbd_convolve8_vert;
         sf->highbd_predict[0][0][1] = aom_highbd_convolve8_avg_vert;
         sf->highbd_predict[0][1][0] = aom_highbd_convolve8_vert;
         sf->highbd_predict[0][1][1] = aom_highbd_convolve8_avg_vert;
         sf->highbd_predict[1][0][0] = aom_highbd_convolve8;
         sf->highbd_predict[1][0][1] = aom_highbd_convolve8_avg;
       }
     } else {
-      if (sf->y_step_q4 == 16) {
+      if (sf->y_step_q4 == SCALE_SUBPEL_SHIFTS) {
         // No scaling in the y direction. Must always scale in the x direction.
         sf->highbd_predict[0][0][0] = aom_highbd_convolve8_horiz;
         sf->highbd_predict[0][0][1] = aom_highbd_convolve8_avg_horiz;
         sf->highbd_predict[0][1][0] = aom_highbd_convolve8;
         sf->highbd_predict[0][1][1] = aom_highbd_convolve8_avg;
         sf->highbd_predict[1][0][0] = aom_highbd_convolve8_horiz;
         sf->highbd_predict[1][0][1] = aom_highbd_convolve8_avg_horiz;
       } else {
--- a/third_party/aom/av1/common/scale.h
+++ b/third_party/aom/av1/common/scale.h
@@ -14,16 +14,18 @@
 
 #include "av1/common/mv.h"
 #include "aom_dsp/aom_convolve.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#define SCALE_DENOMINATOR 16
+
 #define REF_SCALE_SHIFT 14
 #define REF_NO_SCALE (1 << REF_SCALE_SHIFT)
 #define REF_INVALID_SCALE -1
 
 struct scale_factors {
   int x_scale_fp;  // horizontal fixed point scale factor
   int y_scale_fp;  // vertical fixed point scale factor
   int x_step_q4;
--- a/third_party/aom/av1/common/scan.h
+++ b/third_party/aom/av1/common/scan.h
@@ -73,22 +73,24 @@ static INLINE const SCAN_ORDER *get_defa
                   : &av1_intra_scan_orders[tx_size][tx_type];
 #else
   (void)is_inter;
   return &av1_intra_scan_orders[tx_size][tx_type];
 #endif  // CONFIG_EXT_TX
 }
 
 static INLINE const SCAN_ORDER *get_scan(const AV1_COMMON *cm, TX_SIZE tx_size,
-                                         TX_TYPE tx_type, int is_inter) {
+                                         TX_TYPE tx_type,
+                                         const MB_MODE_INFO *mbmi) {
 #if CONFIG_ADAPT_SCAN
-  (void)is_inter;
+  (void)mbmi;
   return &cm->fc->sc[tx_size][tx_type];
 #else   // CONFIG_ADAPT_SCAN
   (void)cm;
+  const int is_inter = is_inter_block(mbmi);
   return get_default_scan(tx_size, tx_type, is_inter);
 #endif  // CONFIG_ADAPT_SCAN
 }
 
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
--- a/third_party/aom/av1/common/tile_common.c
+++ b/third_party/aom/av1/common/tile_common.c
@@ -77,31 +77,41 @@ void av1_get_tile_n_bits(int mi_cols, in
   assert(*min_log2_tile_cols <= *max_log2_tile_cols);
 }
 #endif  // !CONFIG_EXT_TILE
 
 void av1_update_boundary_info(const struct AV1Common *cm,
                               const TileInfo *const tile_info, int mi_row,
                               int mi_col) {
   int row, col;
-  for (row = mi_row; row < (mi_row + cm->mib_size); row++)
-    for (col = mi_col; col < (mi_col + cm->mib_size); col++) {
+  for (row = mi_row; ((row < (mi_row + cm->mib_size)) && (row < cm->mi_rows));
+       row++)
+    for (col = mi_col; ((col < (mi_col + cm->mib_size)) && (col < cm->mi_cols));
+         col++) {
       MODE_INFO *const mi = cm->mi + row * cm->mi_stride + col;
       mi->mbmi.boundary_info = 0;
 
       // If horizontal dependent tile is enabled, then the horizontal
       // tile boundary is not treated as real tile boundary for loop
       // filtering, only the horizontal tile group boundary is treated
       // as tile boundary.
       // Otherwise, tile group boundary is treated the same as tile boundary.
       // Loop filtering operation is done based on the
       // loopfilter_across_tiles_enabled flag for both tile boundary and tile
       // group boundary.
+      // the tile boundary flag is updated only when
+      // loopfilter_across_tiles_enabled value is 0.
 
-      if (cm->tile_cols * cm->tile_rows > 1) {
+      int lpf_across_tiles_enabled = 1;
+
+#if CONFIG_LOOPFILTERING_ACROSS_TILES
+      lpf_across_tiles_enabled = cm->loop_filter_across_tiles_enabled;
+#endif
+
+      if ((cm->tile_cols * cm->tile_rows > 1) && (!lpf_across_tiles_enabled)) {
 #if CONFIG_DEPENDENT_HORZTILES
 #if CONFIG_TILE_GROUPS
         if (row == tile_info->mi_row_start &&
             (!cm->dependent_horz_tiles || tile_info->tg_horz_boundary))
 #else
         if (row == tile_info->mi_row_start && !cm->dependent_horz_tiles)
 #endif  // CONFIG_TILE_GROUPS
 #else
--- a/third_party/aom/av1/common/txb_common.h
+++ b/third_party/aom/av1/common/txb_common.h
@@ -19,71 +19,77 @@ extern const int16_t av1_coeff_band_16x1
 
 extern const int16_t av1_coeff_band_32x32[1024];
 
 typedef struct txb_ctx {
   int txb_skip_ctx;
   int dc_sign_ctx;
 } TXB_CTX;
 
+static INLINE TX_SIZE get_txsize_context(TX_SIZE tx_size) {
+  return txsize_sqr_up_map[tx_size];
+}
+
 #define BASE_CONTEXT_POSITION_NUM 12
 static int base_ref_offset[BASE_CONTEXT_POSITION_NUM][2] = {
   /* clang-format off*/
   { -2, 0 }, { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -2 }, { 0, -1 }, { 0, 1 },
   { 0, 2 },  { 1, -1 },  { 1, 0 },  { 1, 1 },  { 2, 0 }
   /* clang-format on*/
 };
 
 static INLINE int get_level_count(const tran_low_t *tcoeffs, int stride,
-                                  int row, int col, int level,
+                                  int height, int row, int col, int level,
                                   int (*nb_offset)[2], int nb_num) {
   int count = 0;
   for (int idx = 0; idx < nb_num; ++idx) {
     const int ref_row = row + nb_offset[idx][0];
     const int ref_col = col + nb_offset[idx][1];
     const int pos = ref_row * stride + ref_col;
-    if (ref_row < 0 || ref_col < 0 || ref_row >= stride || ref_col >= stride)
+    if (ref_row < 0 || ref_col < 0 || ref_row >= height || ref_col >= stride)
       continue;
     tran_low_t abs_coeff = abs(tcoeffs[pos]);
     count += abs_coeff > level;
   }
   return count;
 }
 
 static INLINE void get_mag(int *mag, const tran_low_t *tcoeffs, int stride,
-                           int row, int col, int (*nb_offset)[2], int nb_num) {
+                           int height, int row, int col, int (*nb_offset)[2],
+                           int nb_num) {
   mag[0] = 0;
   mag[1] = 0;
   for (int idx = 0; idx < nb_num; ++idx) {
     const int ref_row = row + nb_offset[idx][0];
     const int ref_col = col + nb_offset[idx][1];
     const int pos = ref_row * stride + ref_col;
-    if (ref_row < 0 || ref_col < 0 || ref_row >= stride || ref_col >= stride)
+    if (ref_row < 0 || ref_col < 0 || ref_row >= height || ref_col >= stride)
       continue;
     tran_low_t abs_coeff = abs(tcoeffs[pos]);
     if (nb_offset[idx][0] >= 0 && nb_offset[idx][1] >= 0) {
       if (abs_coeff > mag[0]) {
         mag[0] = abs_coeff;
         mag[1] = 1;
       } else if (abs_coeff == mag[0]) {
         ++mag[1];
       }
     }
   }
 }
 static INLINE int get_level_count_mag(int *mag, const tran_low_t *tcoeffs,
-                                      int stride, int row, int col, int level,
-                                      int (*nb_offset)[2], int nb_num) {
+                                      int stride, int height, int row, int col,
+                                      int level, int (*nb_offset)[2],
+                                      int nb_num) {
   int count = 0;
   *mag = 0;
   for (int idx = 0; idx < nb_num; ++idx) {
     const int ref_row = row + nb_offset[idx][0];
     const int ref_col = col + nb_offset[idx][1];
     const int pos = ref_row * stride + ref_col;
-    if (ref_row < 0 || ref_col < 0 || ref_row >= stride || ref_col >= stride)
+    if (ref_row < 0 || ref_col < 0 || ref_row >= height || ref_col >= stride)
       continue;
     tran_low_t abs_coeff = abs(tcoeffs[pos]);
     count += abs_coeff > level;
     if (nb_offset[idx][0] >= 0 && nb_offset[idx][1] >= 0)
       *mag = AOMMAX(*mag, abs_coeff);
   }
   return count;
 }
@@ -106,25 +112,26 @@ static INLINE int get_base_ctx_from_coun
     ctx_idx = 8 + 10 + 10 + (ctx << 1) + sig_mag;
     assert(ctx_idx < COEFF_BASE_CONTEXTS);
   }
   return ctx_idx;
 }
 
 static INLINE int get_base_ctx(const tran_low_t *tcoeffs,
                                int c,  // raster order
-                               const int bwl, const int level) {
+                               const int bwl, const int height,
+                               const int level) {
   const int stride = 1 << bwl;
   const int row = c >> bwl;
   const int col = c - (row << bwl);
   const int level_minus_1 = level - 1;
   int mag;
-  int count =
-      get_level_count_mag(&mag, tcoeffs, stride, row, col, level_minus_1,
-                          base_ref_offset, BASE_CONTEXT_POSITION_NUM);
+  int count = get_level_count_mag(&mag, tcoeffs, stride, height, row, col,
+                                  level_minus_1, base_ref_offset,
+                                  BASE_CONTEXT_POSITION_NUM);
   int ctx_idx = get_base_ctx_from_count_mag(row, col, count, mag, level);
   return ctx_idx;
 }
 
 #define BR_CONTEXT_POSITION_NUM 8  // Base range coefficient context
 static int br_ref_offset[BR_CONTEXT_POSITION_NUM][2] = {
   /* clang-format off*/
   { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 },
@@ -164,39 +171,39 @@ static INLINE int get_br_ctx_from_count_
   if (col == 0) return 5 + ctx;
 
   // others: 8 - 11
   return 8 + ctx;
 }
 
 static INLINE int get_br_ctx(const tran_low_t *tcoeffs,
                              const int c,  // raster order
-                             const int bwl) {
+                             const int bwl, const int height) {
   const int stride = 1 << bwl;
   const int row = c >> bwl;
   const int col = c - (row << bwl);
   const int level_minus_1 = NUM_BASE_LEVELS;
   int mag;
-  const int count =
-      get_level_count_mag(&mag, tcoeffs, stride, row, col, level_minus_1,
-                          br_ref_offset, BR_CONTEXT_POSITION_NUM);
+  const int count = get_level_count_mag(&mag, tcoeffs, stride, height, row, col,
+                                        level_minus_1, br_ref_offset,
+                                        BR_CONTEXT_POSITION_NUM);
   const int ctx = get_br_ctx_from_count_mag(row, col, count, mag);
   return ctx;
 }
 
 #define SIG_REF_OFFSET_NUM 11
 static int sig_ref_offset[SIG_REF_OFFSET_NUM][2] = {
   { -2, -1 }, { -2, 0 }, { -2, 1 }, { -1, -2 }, { -1, -1 }, { -1, 0 },
   { -1, 1 },  { 0, -2 }, { 0, -1 }, { 1, -2 },  { 1, -1 },
 };
 
 static INLINE int get_nz_map_ctx(const tran_low_t *tcoeffs,
                                  const uint8_t *txb_mask,
                                  const int coeff_idx,  // raster order
-                                 const int bwl) {
+                                 const int bwl, const int height) {
   const int row = coeff_idx >> bwl;
   const int col = coeff_idx - (row << bwl);
   int ctx = 0;
   int idx;
   int stride = 1 << bwl;
 
   if (row == 0 && col == 0) return 0;
 
@@ -219,17 +226,17 @@ static INLINE int get_nz_map_ctx(const t
     return 5 + ctx;
   }
 
   for (idx = 0; idx < SIG_REF_OFFSET_NUM; ++idx) {
     int ref_row = row + sig_ref_offset[idx][0];
     int ref_col = col + sig_ref_offset[idx][1];
     int pos;
 
-    if (ref_row < 0 || ref_col < 0 || ref_row >= stride || ref_col >= stride)
+    if (ref_row < 0 || ref_col < 0 || ref_row >= height || ref_col >= stride)
       continue;
 
     pos = (ref_row << bwl) + ref_col;
 
     if (txb_mask[pos]) ctx += (tcoeffs[pos] != 0);
   }
 
   if (row == 0) {
@@ -248,24 +255,25 @@ static INLINE int get_nz_map_ctx(const t
 
   ctx >>= 1;
 
   assert(14 + ctx < 20);
 
   return 14 + ctx;
 }
 
-static INLINE int get_nz_count(const tran_low_t *tcoeffs, int stride, int row,
-                               int col, const int16_t *iscan) {
+static INLINE int get_nz_count(const tran_low_t *tcoeffs, int stride,
+                               int height, int row, int col,
+                               const int16_t *iscan) {
   int count = 0;
   const int pos = row * stride + col;
   for (int idx = 0; idx < SIG_REF_OFFSET_NUM; ++idx) {
     const int ref_row = row + sig_ref_offset[idx][0];
     const int ref_col = col + sig_ref_offset[idx][1];
-    if (ref_row < 0 || ref_col < 0 || ref_row >= stride || ref_col >= stride)
+    if (ref_row < 0 || ref_col < 0 || ref_row >= height || ref_col >= stride)
       continue;
     const int nb_pos = ref_row * stride + ref_col;
     if (iscan[nb_pos] < iscan[pos]) count += (tcoeffs[nb_pos] != 0);
   }
   return count;
 }
 
 // TODO(angiebird): optimize this function by generate a table that maps from
@@ -319,32 +327,33 @@ static INLINE int get_nz_map_ctx_from_co
 
   return 14 + ctx;
 }
 
 // TODO(angiebird): merge this function with get_nz_map_ctx() after proper
 // testing
 static INLINE int get_nz_map_ctx2(const tran_low_t *tcoeffs,
                                   const int coeff_idx,  // raster order
-                                  const int bwl, const int16_t *iscan) {
+                                  const int bwl, const int height,
+                                  const int16_t *iscan) {
   int stride = 1 << bwl;
   const int row = coeff_idx >> bwl;
   const int col = coeff_idx - (row << bwl);
-  int count = get_nz_count(tcoeffs, stride, row, col, iscan);
+  int count = get_nz_count(tcoeffs, stride, height, row, col, iscan);
   return get_nz_map_ctx_from_count(count, tcoeffs, coeff_idx, bwl, iscan);
 }
 
 static INLINE int get_eob_ctx(const tran_low_t *tcoeffs,
                               const int coeff_idx,  // raster order
-                              const int bwl) {
+                              const TX_SIZE txs_ctx) {
   (void)tcoeffs;
-  if (bwl == 2) return av1_coeff_band_4x4[coeff_idx];
-  if (bwl == 3) return av1_coeff_band_8x8[coeff_idx];
-  if (bwl == 4) return av1_coeff_band_16x16[coeff_idx];
-  if (bwl == 5) return av1_coeff_band_32x32[coeff_idx];
+  if (txs_ctx == TX_4X4) return av1_coeff_band_4x4[coeff_idx];
+  if (txs_ctx == TX_8X8) return av1_coeff_band_8x8[coeff_idx];
+  if (txs_ctx == TX_16X16) return av1_coeff_band_16x16[coeff_idx];
+  if (txs_ctx == TX_32X32) return av1_coeff_band_32x32[coeff_idx];
 
   assert(0);
   return 0;
 }
 
 static INLINE void set_dc_sign(int *cul_level, tran_low_t v) {
   if (v < 0)
     *cul_level |= 1 << COEFF_CONTEXT_BITS;
--- a/third_party/aom/av1/common/warped_motion.c
+++ b/third_party/aom/av1/common/warped_motion.c
@@ -12,16 +12,19 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <memory.h>
 #include <math.h>
 #include <assert.h>
 
 #include "./av1_rtcd.h"
 #include "av1/common/warped_motion.h"
+#include "av1/common/scale.h"
+
+#define WARP_ERROR_BLOCK 32
 
 /* clang-format off */
 static const int error_measure_lut[512] = {
   // pow 0.7
   16384, 16339, 16294, 16249, 16204, 16158, 16113, 16068,
   16022, 15977, 15932, 15886, 15840, 15795, 15749, 15703,
   15657, 15612, 15566, 15520, 15474, 15427, 15381, 15335,
   15289, 15242, 15196, 15149, 15103, 15056, 15010, 14963,
@@ -274,39 +277,16 @@ void project_points_homography(const int
     *(proj++) = (int)xp;
     *(proj++) = (int)yp;
 
     points += stride_points - 2;
     proj += stride_proj - 2;
   }
 }
 
-// 'points' are at original scale, output 'proj's are scaled up by
-// 1 << WARPEDPIXEL_PREC_BITS
-void project_points(const WarpedMotionParams *wm_params, int *points, int *proj,
-                    const int n, const int stride_points, const int stride_proj,
-                    const int subsampling_x, const int subsampling_y) {
-  switch (wm_params->wmtype) {
-    case AFFINE:
-      project_points_affine(wm_params->wmmat, points, proj, n, stride_points,
-                            stride_proj, subsampling_x, subsampling_y);
-      break;
-    case ROTZOOM:
-      project_points_rotzoom(wm_params->wmmat, points, proj, n, stride_points,
-                             stride_proj, subsampling_x, subsampling_y);
-      break;
-    case HOMOGRAPHY:
-      project_points_homography(wm_params->wmmat, points, proj, n,
-                                stride_points, stride_proj, subsampling_x,
-                                subsampling_y);
-      break;
-    default: assert(0 && "Invalid warped motion type!"); return;
-  }
-}
-
 static const int16_t
     filter_ntap[WARPEDPIXEL_PREC_SHIFTS][WARPEDPIXEL_FILTER_TAPS] = {
 #if WARPEDPIXEL_PREC_BITS == 6
       { 0, 0, 128, 0, 0, 0 },      { 0, -1, 128, 2, -1, 0 },
       { 1, -3, 127, 4, -1, 0 },    { 1, -4, 126, 6, -2, 1 },
       { 1, -5, 126, 8, -3, 1 },    { 1, -6, 125, 11, -4, 1 },
       { 1, -7, 124, 13, -4, 1 },   { 2, -8, 123, 15, -5, 1 },
       { 2, -9, 122, 18, -6, 1 },   { 2, -10, 121, 20, -6, 1 },
@@ -906,35 +886,38 @@ static INLINE int highbd_error_measure(i
   int e1, e2;
   err = abs(err);
   e1 = err >> b;
   e2 = err & bmask;
   return error_measure_lut[255 + e1] * (v - e2) +
          error_measure_lut[256 + e1] * e2;
 }
 
-static void highbd_warp_plane_old(
-    const WarpedMotionParams *const wm, const uint8_t *const ref8, int width,
-    int height, int stride, const uint8_t *const pred8, int p_col, int p_row,
-    int p_width, int p_height, int p_stride, int subsampling_x,
-    int subsampling_y, int x_scale, int y_scale, int bd, int comp_avg) {
+static void highbd_warp_plane_old(const WarpedMotionParams *const wm,
+                                  const uint8_t *const ref8, int width,
+                                  int height, int stride,
+                                  const uint8_t *const pred8, int p_col,
+                                  int p_row, int p_width, int p_height,
+                                  int p_stride, int subsampling_x,
+                                  int subsampling_y, int x_scale, int y_scale,
+                                  int bd, ConvolveParams *conv_params) {
   int i, j;
   ProjectPointsFunc projectpoints = get_project_points_type(wm->wmtype);
   uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
   const uint16_t *const ref = CONVERT_TO_SHORTPTR(ref8);
   if (projectpoints == NULL) return;
   for (i = p_row; i < p_row + p_height; ++i) {
     for (j = p_col; j < p_col + p_width; ++j) {
       int in[2], out[2];
       in[0] = j;
       in[1] = i;
       projectpoints(wm->wmmat, in, out, 1, 2, 2, subsampling_x, subsampling_y);
       out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4);
       out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4);
-      if (comp_avg)
+      if (conv_params->do_average)
         pred[(j - p_col) + (i - p_row) * p_stride] = ROUND_POWER_OF_TWO(
             pred[(j - p_col) + (i - p_row) * p_stride] +
                 highbd_warp_interpolate(ref, out[0], out[1], width, height,
                                         stride, bd),
             1);
       else
         pred[(j - p_col) + (i - p_row) * p_stride] = highbd_warp_interpolate(
             ref, out[0], out[1], width, height, stride, bd);
@@ -944,20 +927,20 @@ static void highbd_warp_plane_old(
 
 /* Note: For an explanation of the warp algorithm, and some notes on bit widths
     for hardware implementations, see the comments above av1_warp_affine_c
 */
 void av1_highbd_warp_affine_c(const int32_t *mat, const uint16_t *ref,
                               int width, int height, int stride, uint16_t *pred,
                               int p_col, int p_row, int p_width, int p_height,
                               int p_stride, int subsampling_x,
-                              int subsampling_y, int bd, int comp_avg,
-                              int16_t alpha, int16_t beta, int16_t gamma,
-                              int16_t delta) {
-  uint32_t tmp[15 * 8];
+                              int subsampling_y, int bd,
+                              ConvolveParams *conv_params, int16_t alpha,
+                              int16_t beta, int16_t gamma, int16_t delta) {
+  int32_t tmp[15 * 8];
   int i, j, k, l, m;
 
   for (i = p_row; i < p_row + p_height; i += 8) {
     for (j = p_col; j < p_col + p_width; j += 8) {
       int32_t x4, y4, ix4, sx4, iy4, sy4;
       if (subsampling_x)
         x4 = (mat[2] * 4 * (j + 4) + mat[3] * 4 * (i + 4) + mat[0] * 2 +
               (mat[2] + mat[3] - (1 << WARPEDMODEL_PREC_BITS))) /
@@ -1032,115 +1015,248 @@ void av1_highbd_warp_affine_c(const int3
                               HORSHEAR_REDUCE_PREC_BITS);
           for (m = 0; m < 8; ++m) {
             sum += tmp[(k + m + 4) * 8 + (l + 4)] * coeffs[m];
           }
           sum = ROUND_POWER_OF_TWO(sum, VERSHEAR_REDUCE_PREC_BITS);
           assert(0 <= sum && sum < (1 << (bd + 2)));
           uint16_t px =
               clip_pixel_highbd(sum - (1 << (bd - 1)) - (1 << bd), bd);
-          if (comp_avg)
+          if (conv_params->do_average)
             *p = ROUND_POWER_OF_TWO(*p + px, 1);
           else
             *p = px;
           sy += gamma;
         }
       }
     }
   }
 }
 
+#if CONFIG_CONVOLVE_ROUND
+void av1_highbd_warp_affine_post_round_c(
+    const int32_t *mat, const uint16_t *ref, int width, int height, int stride,
+    uint16_t *pred, int p_col, int p_row, int p_width, int p_height,
+    int p_stride, int subsampling_x, int subsampling_y, int bd,
+    ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma,
+    int16_t delta) {
+  (void)pred;
+  (void)p_stride;
+  int32_t tmp[15 * 8];
+  int i, j, k, l, m;
+  const int offset_bits_horiz = bd + FILTER_BITS - 1;
+  const int offset_bits_vert = bd + 2 * FILTER_BITS - conv_params->round_0;
+  assert(FILTER_BITS == WARPEDPIXEL_FILTER_BITS);
+
+  for (i = p_row; i < p_row + p_height; i += 8) {
+    for (j = p_col; j < p_col + p_width; j += 8) {
+      int32_t x4, y4, ix4, sx4, iy4, sy4;
+      if (subsampling_x)
+        x4 = (mat[2] * 4 * (j + 4) + mat[3] * 4 * (i + 4) + mat[0] * 2 +
+              (mat[2] + mat[3] - (1 << WARPEDMODEL_PREC_BITS))) /
+             4;
+      else
+        x4 = mat[2] * (j + 4) + mat[3] * (i + 4) + mat[0];
+
+      if (subsampling_y)
+        y4 = (mat[4] * 4 * (j + 4) + mat[5] * 4 * (i + 4) + mat[1] * 2 +
+              (mat[4] + mat[5] - (1 << WARPEDMODEL_PREC_BITS))) /
+             4;
+      else
+        y4 = mat[4] * (j + 4) + mat[5] * (i + 4) + mat[1];
+
+      ix4 = x4 >> WARPEDMODEL_PREC_BITS;
+      sx4 = x4 & ((1 << WARPEDMODEL_PREC_BITS) - 1);
+      iy4 = y4 >> WARPEDMODEL_PREC_BITS;
+      sy4 = y4 & ((1 << WARPEDMODEL_PREC_BITS) - 1);
+
+      sx4 += alpha * (-4) + beta * (-4);
+      sy4 += gamma * (-4) + delta * (-4);
+
+      sx4 &= ~((1 << WARP_PARAM_REDUCE_BITS) - 1);
+      sy4 &= ~((1 << WARP_PARAM_REDUCE_BITS) - 1);
+
+      // Horizontal filter
+      for (k = -7; k < 8; ++k) {
+        int iy = iy4 + k;
+        if (iy < 0)
+          iy = 0;
+        else if (iy > height - 1)
+          iy = height - 1;
+
+        int sx = sx4 + beta * (k + 4);
+        for (l = -4; l < 4; ++l) {
+          int ix = ix4 + l - 3;
+          const int offs = ROUND_POWER_OF_TWO(sx, WARPEDDIFF_PREC_BITS) +
+                           WARPEDPIXEL_PREC_SHIFTS;
+          assert(offs >= 0 && offs <= WARPEDPIXEL_PREC_SHIFTS * 3);
+          const int16_t *coeffs = warped_filter[offs];
+
+          int32_t sum = 1 << offset_bits_horiz;
+          for (m = 0; m < 8; ++m) {
+            int sample_x = ix + m;
+            if (sample_x < 0)
+              sample_x = 0;
+            else if (sample_x > width - 1)
+              sample_x = width - 1;
+            sum += ref[iy * stride + sample_x] * coeffs[m];
+          }
+          sum = ROUND_POWER_OF_TWO(sum, conv_params->round_0);
+          assert(0 <= sum &&
+                 sum < (1 << (bd + FILTER_BITS + 1 - conv_params->round_0)));
+          tmp[(k + 7) * 8 + (l + 4)] = sum;
+          sx += alpha;
+        }
+      }
+
+      // Vertical filter
+      for (k = -4; k < AOMMIN(4, p_row + p_height - i - 4); ++k) {
+        int sy = sy4 + delta * (k + 4);
+        for (l = -4; l < 4; ++l) {
+          const int offs = ROUND_POWER_OF_TWO(sy, WARPEDDIFF_PREC_BITS) +
+                           WARPEDPIXEL_PREC_SHIFTS;
+          assert(offs >= 0 && offs <= WARPEDPIXEL_PREC_SHIFTS * 3);
+          const int16_t *coeffs = warped_filter[offs];
+
+          int32_t sum = 1 << offset_bits_vert;
+          for (m = 0; m < 8; ++m) {
+            sum += tmp[(k + m + 4) * 8 + (l + 4)] * coeffs[m];
+          }
+
+          sum = ROUND_POWER_OF_TWO(sum, conv_params->round_1) -
+                (1 << (offset_bits_horiz + FILTER_BITS - conv_params->round_0 -
+                       conv_params->round_1)) -
+                (1 << (offset_bits_vert - conv_params->round_1));
+          CONV_BUF_TYPE *p =
+              &conv_params->dst[(i - p_row + k + 4) * conv_params->dst_stride +
+                                (j - p_col + l + 4)];
+          *p += sum;
+          sy += gamma;
+        }
+      }
+    }
+  }
+}
+#endif
+
 static void highbd_warp_plane(WarpedMotionParams *wm, const uint8_t *const ref8,
                               int width, int height, int stride,
                               const uint8_t *const pred8, int p_col, int p_row,
                               int p_width, int p_height, int p_stride,
                               int subsampling_x, int subsampling_y, int x_scale,
-                              int y_scale, int bd, int comp_avg) {
+                              int y_scale, int bd,
+                              ConvolveParams *conv_params) {
   if (wm->wmtype == ROTZOOM) {
     wm->wmmat[5] = wm->wmmat[2];
     wm->wmmat[4] = -wm->wmmat[3];
   }
-  if ((wm->wmtype == ROTZOOM || wm->wmtype == AFFINE) && x_scale == 16 &&
-      y_scale == 16) {
+  if ((wm->wmtype == ROTZOOM || wm->wmtype == AFFINE) &&
+      x_scale == SCALE_SUBPEL_SHIFTS && y_scale == SCALE_SUBPEL_SHIFTS) {
     const int32_t *const mat = wm->wmmat;
     const int16_t alpha = wm->alpha;
     const int16_t beta = wm->beta;
     const int16_t gamma = wm->gamma;
     const int16_t delta = wm->delta;
 
     const uint16_t *const ref = CONVERT_TO_SHORTPTR(ref8);
     uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
+#if CONFIG_CONVOLVE_ROUND
+    if (conv_params->round == CONVOLVE_OPT_NO_ROUND) {
+      conv_params->do_post_rounding = 1;
+      av1_highbd_warp_affine_post_round(
+          mat, ref, width, height, stride, pred, p_col, p_row, p_width,
+          p_height, p_stride, subsampling_x, subsampling_y, bd, conv_params,
+          alpha, beta, gamma, delta);
+    } else {
+      av1_highbd_warp_affine(mat, ref, width, height, stride, pred, p_col,
+                             p_row, p_width, p_height, p_stride, subsampling_x,
+                             subsampling_y, bd, conv_params, alpha, beta, gamma,
+                             delta);
+    }
+#else
     av1_highbd_warp_affine(mat, ref, width, height, stride, pred, p_col, p_row,
                            p_width, p_height, p_stride, subsampling_x,
-                           subsampling_y, bd, comp_avg, alpha, beta, gamma,
+                           subsampling_y, bd, conv_params, alpha, beta, gamma,
                            delta);
+#endif
   } else {
     highbd_warp_plane_old(wm, ref8, width, height, stride, pred8, p_col, p_row,
                           p_width, p_height, p_stride, subsampling_x,
-                          subsampling_y, x_scale, y_scale, bd, comp_avg);
+                          subsampling_y, x_scale, y_scale, bd, conv_params);
   }
 }
 
 static int64_t highbd_frame_error(const uint16_t *const ref, int stride,
-                                  const uint16_t *const dst, int p_col,
-                                  int p_row, int p_width, int p_height,
-                                  int p_stride, int bd) {
+                                  const uint16_t *const dst, int p_width,
+                                  int p_height, int p_stride, int bd) {
   int64_t sum_error = 0;
   for (int i = 0; i < p_height; ++i) {
     for (int j = 0; j < p_width; ++j) {
-      sum_error += highbd_error_measure(
-          dst[j + i * p_stride] - ref[(j + p_col) + (i + p_row) * stride], bd);
+      sum_error +=
+          highbd_error_measure(dst[j + i * p_stride] - ref[j + i * stride], bd);
     }
   }
   return sum_error;
 }
 
 static int64_t highbd_warp_error(
     WarpedMotionParams *wm, const uint8_t *const ref8, int width, int height,
     int stride, const uint8_t *const dst8, int p_col, int p_row, int p_width,
     int p_height, int p_stride, int subsampling_x, int subsampling_y,
-    int x_scale, int y_scale, int bd) {
+    int x_scale, int y_scale, int bd, int64_t best_error) {
   int64_t gm_sumerr = 0;
-  uint16_t *tmp = aom_malloc(p_width * p_height * sizeof(*tmp));
-  if (!tmp) return INT64_MAX;
+  int warp_w, warp_h;
+  int error_bsize_w = AOMMIN(p_width, WARP_ERROR_BLOCK);
+  int error_bsize_h = AOMMIN(p_height, WARP_ERROR_BLOCK);
+  uint16_t tmp[WARP_ERROR_BLOCK * WARP_ERROR_BLOCK];
 
-  highbd_warp_plane(wm, ref8, width, height, stride, CONVERT_TO_BYTEPTR(tmp),
-                    p_col, p_row, p_width, p_height, p_width, subsampling_x,
-                    subsampling_y, x_scale, y_scale, bd, 0);
+  ConvolveParams conv_params = get_conv_params(0, 0, 0);
+  for (int i = p_row; i < p_row + p_height; i += WARP_ERROR_BLOCK) {
+    for (int j = p_col; j < p_col + p_width; j += WARP_ERROR_BLOCK) {
+      // avoid warping extra 8x8 blocks in the padded region of the frame
+      // when p_width and p_height are not multiples of WARP_ERROR_BLOCK
+      warp_w = AOMMIN(error_bsize_w, p_col + p_width - j);
+      warp_h = AOMMIN(error_bsize_h, p_row + p_height - i);
+      highbd_warp_plane(wm, ref8, width, height, stride,
+                        CONVERT_TO_BYTEPTR(tmp), j, i, warp_w, warp_h,
+                        WARP_ERROR_BLOCK, subsampling_x, subsampling_y, x_scale,
+                        y_scale, bd, &conv_params);
 
-  gm_sumerr = highbd_frame_error(tmp, p_width, CONVERT_TO_SHORTPTR(dst8), p_col,
-                                 p_row, p_width, p_height, p_stride, bd);
-
-  aom_free(tmp);
+      gm_sumerr += highbd_frame_error(
+          tmp, WARP_ERROR_BLOCK, CONVERT_TO_SHORTPTR(dst8) + j + i * p_stride,
+          warp_w, warp_h, p_stride, bd);
+      if (gm_sumerr > best_error) return gm_sumerr;
+    }
+  }
   return gm_sumerr;
 }
 #endif  // CONFIG_HIGHBITDEPTH
 
 static INLINE int error_measure(int err) {
   return error_measure_lut[255 + err];
 }
 
 static void warp_plane_old(const WarpedMotionParams *const wm,
                            const uint8_t *const ref, int width, int height,
                            int stride, uint8_t *pred, int p_col, int p_row,
                            int p_width, int p_height, int p_stride,
                            int subsampling_x, int subsampling_y, int x_scale,
-                           int y_scale, int comp_avg) {
+                           int y_scale, ConvolveParams *conv_params) {
   int i, j;
   ProjectPointsFunc projectpoints = get_project_points_type(wm->wmtype);
   if (projectpoints == NULL) return;
   for (i = p_row; i < p_row + p_height; ++i) {
     for (j = p_col; j < p_col + p_width; ++j) {
       int in[2], out[2];
       in[0] = j;
       in[1] = i;
       projectpoints(wm->wmmat, in, out, 1, 2, 2, subsampling_x, subsampling_y);
       out[0] = ROUND_POWER_OF_TWO_SIGNED(out[0] * x_scale, 4);
       out[1] = ROUND_POWER_OF_TWO_SIGNED(out[1] * y_scale, 4);
-      if (comp_avg)
+      if (conv_params->do_average)
         pred[(j - p_col) + (i - p_row) * p_stride] = ROUND_POWER_OF_TWO(
             pred[(j - p_col) + (i - p_row) * p_stride] +
                 warp_interpolate(ref, out[0], out[1], width, height, stride),
             1);
       else
         pred[(j - p_col) + (i - p_row) * p_stride] =
             warp_interpolate(ref, out[0], out[1], width, height, stride);
     }
@@ -1230,20 +1346,20 @@ static void warp_plane_old(const WarpedM
     the convolve-round experiment. As of the time of writing, the Wiener filter
     from loop-restoration can encode a central coefficient up to 216, which
     leads to a maximum value of about 282 * 2^k after applying the offset.
     So in that case we still need to clamp.
 */
 void av1_warp_affine_c(const int32_t *mat, const uint8_t *ref, int width,
                        int height, int stride, uint8_t *pred, int p_col,
                        int p_row, int p_width, int p_height, int p_stride,
-                       int subsampling_x, int subsampling_y, int comp_avg,
-                       int16_t alpha, int16_t beta, int16_t gamma,
-                       int16_t delta) {
-  uint16_t tmp[15 * 8];
+                       int subsampling_x, int subsampling_y,
+                       ConvolveParams *conv_params, int16_t alpha, int16_t beta,
+                       int16_t gamma, int16_t delta) {
+  int32_t tmp[15 * 8];
   int i, j, k, l, m;
   const int bd = 8;
 
   for (i = p_row; i < p_row + p_height; i += 8) {
     for (j = p_col; j < p_col + p_width; j += 8) {
       int32_t x4, y4, ix4, sx4, iy4, sy4;
       if (subsampling_x)
         x4 = (mat[2] * 4 * (j + 4) + mat[3] * 4 * (i + 4) + mat[0] * 2 +
@@ -1324,144 +1440,284 @@ void av1_warp_affine_c(const int32_t *ma
           int32_t sum = 1 << (bd + 2 * WARPEDPIXEL_FILTER_BITS -
                               HORSHEAR_REDUCE_PREC_BITS);
           for (m = 0; m < 8; ++m) {
             sum += tmp[(k + m + 4) * 8 + (l + 4)] * coeffs[m];
           }
           sum = ROUND_POWER_OF_TWO(sum, VERSHEAR_REDUCE_PREC_BITS);
           assert(0 <= sum && sum < (1 << (bd + 2)));
           uint8_t px = clip_pixel(sum - (1 << (bd - 1)) - (1 << bd));
-          if (comp_avg)
+          if (conv_params->do_average)
             *p = ROUND_POWER_OF_TWO(*p + px, 1);
           else
             *p = px;
           sy += gamma;
         }
       }
     }
   }
 }
 
+#if CONFIG_CONVOLVE_ROUND
+void av1_warp_affine_post_round_c(const int32_t *mat, const uint8_t *ref,
+                                  int width, int height, int stride,
+                                  uint8_t *pred, int p_col, int p_row,
+                                  int p_width, int p_height, int p_stride,
+                                  int subsampling_x, int subsampling_y,
+                                  ConvolveParams *conv_params, int16_t alpha,
+                                  int16_t beta, int16_t gamma, int16_t delta) {
+  (void)pred;
+  (void)p_stride;
+  int32_t tmp[15 * 8];
+  int i, j, k, l, m;
+  const int bd = 8;
+  const int offset_bits_horiz = bd + FILTER_BITS - 1;
+  const int offset_bits_vert = bd + 2 * FILTER_BITS - conv_params->round_0;
+  assert(FILTER_BITS == WARPEDPIXEL_FILTER_BITS);
+
+  for (i = p_row; i < p_row + p_height; i += 8) {
+    for (j = p_col; j < p_col + p_width; j += 8) {
+      int32_t x4, y4, ix4, sx4, iy4, sy4;
+      if (subsampling_x)
+        x4 = (mat[2] * 4 * (j + 4) + mat[3] * 4 * (i + 4) + mat[0] * 2 +
+              (mat[2] + mat[3] - (1 << WARPEDMODEL_PREC_BITS))) /
+             4;
+      else
+        x4 = mat[2] * (j + 4) + mat[3] * (i + 4) + mat[0];
+
+      if (subsampling_y)
+        y4 = (mat[4] * 4 * (j + 4) + mat[5] * 4 * (i + 4) + mat[1] * 2 +
+              (mat[4] + mat[5] - (1 << WARPEDMODEL_PREC_BITS))) /
+             4;
+      else
+        y4 = mat[4] * (j + 4) + mat[5] * (i + 4) + mat[1];
+
+      ix4 = x4 >> WARPEDMODEL_PREC_BITS;
+      sx4 = x4 & ((1 << WARPEDMODEL_PREC_BITS) - 1);
+      iy4 = y4 >> WARPEDMODEL_PREC_BITS;
+      sy4 = y4 & ((1 << WARPEDMODEL_PREC_BITS) - 1);
+
+      sx4 += alpha * (-4) + beta * (-4);
+      sy4 += gamma * (-4) + delta * (-4);
+
+      sx4 &= ~((1 << WARP_PARAM_REDUCE_BITS) - 1);
+      sy4 &= ~((1 << WARP_PARAM_REDUCE_BITS) - 1);
+
+      // Horizontal filter
+      for (k = -7; k < 8; ++k) {
+        // Clamp to top/bottom edge of the frame
+        int iy = iy4 + k;
+        if (iy < 0)
+          iy = 0;
+        else if (iy > height - 1)
+          iy = height - 1;
+
+        int sx = sx4 + beta * (k + 4);
+
+        for (l = -4; l < 4; ++l) {
+          int ix = ix4 + l - 3;
+          // At this point, sx = sx4 + alpha * l + beta * k
+          const int offs = ROUND_POWER_OF_TWO(sx, WARPEDDIFF_PREC_BITS) +
+                           WARPEDPIXEL_PREC_SHIFTS;
+          assert(offs >= 0 && offs <= WARPEDPIXEL_PREC_SHIFTS * 3);
+          const int16_t *coeffs = warped_filter[offs];
+
+          int32_t sum = 1 << offset_bits_horiz;
+          for (m = 0; m < 8; ++m) {
+            // Clamp to left/right edge of the frame
+            int sample_x = ix + m;
+            if (sample_x < 0)
+              sample_x = 0;
+            else if (sample_x > width - 1)
+              sample_x = width - 1;
+
+            sum += ref[iy * stride + sample_x] * coeffs[m];
+          }
+          sum = ROUND_POWER_OF_TWO(sum, conv_params->round_0);
+          assert(0 <= sum &&
+                 sum < (1 << (bd + FILTER_BITS + 1 - conv_params->round_0)));
+          tmp[(k + 7) * 8 + (l + 4)] = sum;
+          sx += alpha;
+        }
+      }
+
+      // Vertical filter
+      for (k = -4; k < AOMMIN(4, p_row + p_height - i - 4); ++k) {
+        int sy = sy4 + delta * (k + 4);
+        for (l = -4; l < AOMMIN(4, p_col + p_width - j - 4); ++l) {
+          // At this point, sy = sy4 + gamma * l + delta * k
+          const int offs = ROUND_POWER_OF_TWO(sy, WARPEDDIFF_PREC_BITS) +
+                           WARPEDPIXEL_PREC_SHIFTS;
+          assert(offs >= 0 && offs <= WARPEDPIXEL_PREC_SHIFTS * 3);
+          const int16_t *coeffs = warped_filter[offs];
+
+          int32_t sum = 1 << offset_bits_vert;
+
+          for (m = 0; m < 8; ++m) {
+            sum += tmp[(k + m + 4) * 8 + (l + 4)] * coeffs[m];
+          }
+
+          sum = ROUND_POWER_OF_TWO(sum, conv_params->round_1) -
+                (1 << (offset_bits_horiz + FILTER_BITS - conv_params->round_0 -
+                       conv_params->round_1)) -
+                (1 << (offset_bits_vert - conv_params->round_1));
+          CONV_BUF_TYPE *p =
+              &conv_params->dst[(i - p_row + k + 4) * conv_params->dst_stride +
+                                (j - p_col + l + 4)];
+          *p += sum;
+          sy += gamma;
+        }
+      }
+    }
+  }
+}
+#endif  // CONFIG_CONVOLVE_ROUND
+
 static void warp_plane(WarpedMotionParams *wm, const uint8_t *const ref,
                        int width, int height, int stride, uint8_t *pred,
                        int p_col, int p_row, int p_width, int p_height,
                        int p_stride, int subsampling_x, int subsampling_y,
-                       int x_scale, int y_scale, int comp_avg) {
+                       int x_scale, int y_scale, ConvolveParams *conv_params) {
   if (wm->wmtype == ROTZOOM) {
     wm->wmmat[5] = wm->wmmat[2];
     wm->wmmat[4] = -wm->wmmat[3];
   }
-  if ((wm->wmtype == ROTZOOM || wm->wmtype == AFFINE) && x_scale == 16 &&
-      y_scale == 16) {
+  if ((wm->wmtype == ROTZOOM || wm->wmtype == AFFINE) &&
+      x_scale == SCALE_SUBPEL_SHIFTS && y_scale == SCALE_SUBPEL_SHIFTS) {
     const int32_t *const mat = wm->wmmat;
     const int16_t alpha = wm->alpha;
     const int16_t beta = wm->beta;
     const int16_t gamma = wm->gamma;
     const int16_t delta = wm->delta;
 
+#if CONFIG_CONVOLVE_ROUND
+    if (conv_params->round == CONVOLVE_OPT_NO_ROUND) {
+      conv_params->do_post_rounding = 1;
+      av1_warp_affine_post_round(mat, ref, width, height, stride, pred, p_col,
+                                 p_row, p_width, p_height, p_stride,
+                                 subsampling_x, subsampling_y, conv_params,
+                                 alpha, beta, gamma, delta);
+    } else {
+      av1_warp_affine(mat, ref, width, height, stride, pred, p_col, p_row,
+                      p_width, p_height, p_stride, subsampling_x, subsampling_y,
+                      conv_params, alpha, beta, gamma, delta);
+    }
+#else
     av1_warp_affine(mat, ref, width, height, stride, pred, p_col, p_row,
                     p_width, p_height, p_stride, subsampling_x, subsampling_y,
-                    comp_avg, alpha, beta, gamma, delta);
+                    conv_params, alpha, beta, gamma, delta);
+#endif
   } else {
     warp_plane_old(wm, ref, width, height, stride, pred, p_col, p_row, p_width,
                    p_height, p_stride, subsampling_x, subsampling_y, x_scale,
-                   y_scale, comp_avg);
+                   y_scale, conv_params);
   }
 }
 
 static int64_t frame_error(const uint8_t *const ref, int stride,
-                           const uint8_t *const dst, int p_col, int p_row,
-                           int p_width, int p_height, int p_stride) {
+                           const uint8_t *const dst, int p_width, int p_height,
+                           int p_stride) {
   int64_t sum_error = 0;
   for (int i = 0; i < p_height; ++i) {
     for (int j = 0; j < p_width; ++j) {
-      sum_error += (int64_t)error_measure(
-          dst[j + i * p_stride] - ref[(j + p_col) + (i + p_row) * stride]);
+      sum_error +=
+          (int64_t)error_measure(dst[j + i * p_stride] - ref[j + i * stride]);
     }
   }
   return sum_error;
 }
 
 static int64_t warp_error(WarpedMotionParams *wm, const uint8_t *const ref,
                           int width, int height, int stride,
                           const uint8_t *const dst, int p_col, int p_row,
                           int p_width, int p_height, int p_stride,
                           int subsampling_x, int subsampling_y, int x_scale,
-                          int y_scale) {
+                          int y_scale, int64_t best_error) {
   int64_t gm_sumerr = 0;
-  uint8_t *tmp = aom_malloc(p_width * p_height);
-  if (!tmp) return INT64_MAX;
+  int warp_w, warp_h;
+  int error_bsize_w = AOMMIN(p_width, WARP_ERROR_BLOCK);
+  int error_bsize_h = AOMMIN(p_height, WARP_ERROR_BLOCK);
+  uint8_t tmp[WARP_ERROR_BLOCK * WARP_ERROR_BLOCK];
+  ConvolveParams conv_params = get_conv_params(0, 0, 0);
 
-  warp_plane(wm, ref, width, height, stride, tmp, p_col, p_row, p_width,
-             p_height, p_width, subsampling_x, subsampling_y, x_scale, y_scale,
-             0);
+  for (int i = p_row; i < p_row + p_height; i += WARP_ERROR_BLOCK) {
+    for (int j = p_col; j < p_col + p_width; j += WARP_ERROR_BLOCK) {
+      // avoid warping extra 8x8 blocks in the padded region of the frame
+      // when p_width and p_height are not multiples of WARP_ERROR_BLOCK
+      warp_w = AOMMIN(error_bsize_w, p_col + p_width - j);
+      warp_h = AOMMIN(error_bsize_h, p_row + p_height - i);
+      warp_plane(wm, ref, width, height, stride, tmp, j, i, warp_w, warp_h,
+                 WARP_ERROR_BLOCK, subsampling_x, subsampling_y, x_scale,
+                 y_scale, &conv_params);
 
-  gm_sumerr =
-      frame_error(tmp, p_width, dst, p_col, p_row, p_width, p_height, p_stride);
-
-  aom_free(tmp);
+      gm_sumerr += frame_error(tmp, WARP_ERROR_BLOCK, dst + j + i * p_stride,
+                               warp_w, warp_h, p_stride);
+      if (gm_sumerr > best_error) return gm_sumerr;
+    }
+  }
   return gm_sumerr;
 }
 
 int64_t av1_frame_error(
 #if CONFIG_HIGHBITDEPTH
     int use_hbd, int bd,
 #endif  // CONFIG_HIGHBITDEPTH
-    const uint8_t *ref, int stride, uint8_t *dst, int p_col, int p_row,
-    int p_width, int p_height, int p_stride) {
+    const uint8_t *ref, int stride, uint8_t *dst, int p_width, int p_height,
+    int p_stride) {
 #if CONFIG_HIGHBITDEPTH
   if (use_hbd) {
     return highbd_frame_error(CONVERT_TO_SHORTPTR(ref), stride,
-                              CONVERT_TO_SHORTPTR(dst), p_col, p_row, p_width,
-                              p_height, p_stride, bd);
+                              CONVERT_TO_SHORTPTR(dst), p_width, p_height,
+                              p_stride, bd);
   }
 #endif  // CONFIG_HIGHBITDEPTH
-  return frame_error(ref, stride, dst, p_col, p_row, p_width, p_height,
-                     p_stride);
+  return frame_error(ref, stride, dst, p_width, p_height, p_stride);
 }
 
 int64_t av1_warp_error(WarpedMotionParams *wm,
 #if CONFIG_HIGHBITDEPTH
                        int use_hbd, int bd,
 #endif  // CONFIG_HIGHBITDEPTH
                        const uint8_t *ref, int width, int height, int stride,
                        uint8_t *dst, int p_col, int p_row, int p_width,
                        int p_height, int p_stride, int subsampling_x,
-                       int subsampling_y, int x_scale, int y_scale) {
+                       int subsampling_y, int x_scale, int y_scale,
+                       int64_t best_error) {
   if (wm->wmtype <= AFFINE)
     if (!get_shear_params(wm)) return 1;
 #if CONFIG_HIGHBITDEPTH
   if (use_hbd)
     return highbd_warp_error(wm, ref, width, height, stride, dst, p_col, p_row,
                              p_width, p_height, p_stride, subsampling_x,
-                             subsampling_y, x_scale, y_scale, bd);
+                             subsampling_y, x_scale, y_scale, bd, best_error);
 #endif  // CONFIG_HIGHBITDEPTH
   return warp_error(wm, ref, width, height, stride, dst, p_col, p_row, p_width,
                     p_height, p_stride, subsampling_x, subsampling_y, x_scale,
-                    y_scale);
+                    y_scale, best_error);
 }
 
 void av1_warp_plane(WarpedMotionParams *wm,
 #if CONFIG_HIGHBITDEPTH
                     int use_hbd, int bd,
 #endif  // CONFIG_HIGHBITDEPTH
                     const uint8_t *ref, int width, int height, int stride,
                     uint8_t *pred, int p_col, int p_row, int p_width,
                     int p_height, int p_stride, int subsampling_x,
-                    int subsampling_y, int x_scale, int y_scale, int comp_avg) {
+                    int subsampling_y, int x_scale, int y_scale,
+                    ConvolveParams *conv_params) {
 #if CONFIG_HIGHBITDEPTH
   if (use_hbd)
     highbd_warp_plane(wm, ref, width, height, stride, pred, p_col, p_row,
                       p_width, p_height, p_stride, subsampling_x, subsampling_y,
-                      x_scale, y_scale, bd, comp_avg);
+                      x_scale, y_scale, bd, conv_params);
   else
 #endif  // CONFIG_HIGHBITDEPTH
     warp_plane(wm, ref, width, height, stride, pred, p_col, p_row, p_width,
                p_height, p_stride, subsampling_x, subsampling_y, x_scale,
-               y_scale, comp_avg);
+               y_scale, conv_params);
 }
 
 #if CONFIG_WARPED_MOTION
 #define LEAST_SQUARES_ORDER 2
 
 #define LS_MV_MAX 256  // max mv in 1/8-pel
 #define LS_STEP 2
 
@@ -1487,28 +1743,107 @@ void av1_warp_plane(WarpedMotionParams *
 #define LS_SUM(a) ((a)*4 + LS_STEP * 2)
 #define LS_SQUARE(a) \
   (((a) * (a)*4 + (a)*4 * LS_STEP + LS_STEP * LS_STEP * 2) >> 2)
 #define LS_PRODUCT1(a, b) \
   (((a) * (b)*4 + ((a) + (b)) * 2 * LS_STEP + LS_STEP * LS_STEP) >> 2)
 #define LS_PRODUCT2(a, b) \
   (((a) * (b)*4 + ((a) + (b)) * 2 * LS_STEP + LS_STEP * LS_STEP * 2) >> 2)
 
+#define USE_LIMITED_PREC_MULT 0
+
+#if USE_LIMITED_PREC_MULT
+
+#define MUL_PREC_BITS 16
+static uint16_t resolve_multiplier_64(uint64_t D, int16_t *shift) {
+  int msb = 0;
+  uint16_t mult = 0;
+  *shift = 0;
+  if (D != 0) {
+    msb = (int16_t)((D >> 32) ? get_msb((unsigned int)(D >> 32)) + 32
+                              : get_msb((unsigned int)D));
+    if (msb >= MUL_PREC_BITS) {
+      mult = (uint16_t)ROUND_POWER_OF_TWO_64(D, msb + 1 - MUL_PREC_BITS);
+      *shift = msb + 1 - MUL_PREC_BITS;
+    } else {
+      mult = (uint16_t)D;
+      *shift = 0;
+    }
+  }
+  return mult;
+}
+
+static int32_t get_mult_shift_ndiag(int64_t Px, int16_t iDet, int shift) {
+  int32_t ret;
+  int16_t mshift;
+  uint16_t Mul = resolve_multiplier_64(llabs(Px), &mshift);
+  int32_t v = (int32_t)Mul * (int32_t)iDet * (Px < 0 ? -1 : 1);
+  shift -= mshift;
+  if (shift > 0) {
+    return (int32_t)clamp(ROUND_POWER_OF_TWO_SIGNED(v, shift),
+                          -WARPEDMODEL_NONDIAGAFFINE_CLAMP + 1,
+                          WARPEDMODEL_NONDIAGAFFINE_CLAMP - 1);
+  } else {
+    return (int32_t)clamp(v * (1 << (-shift)),
+                          -WARPEDMODEL_NONDIAGAFFINE_CLAMP + 1,
+                          WARPEDMODEL_NONDIAGAFFINE_CLAMP - 1);
+  }
+  return ret;
+}
+
+static int32_t get_mult_shift_diag(int64_t Px, int16_t iDet, int shift) {
+  int16_t mshift;
+  uint16_t Mul = resolve_multiplier_64(llabs(Px), &mshift);
+  int32_t v = (int32_t)Mul * (int32_t)iDet * (Px < 0 ? -1 : 1);
+  shift -= mshift;
+  if (shift > 0) {
+    return (int32_t)clamp(
+        ROUND_POWER_OF_TWO_SIGNED(v, shift),
+        (1 << WARPEDMODEL_PREC_BITS) - WARPEDMODEL_NONDIAGAFFINE_CLAMP + 1,
+        (1 << WARPEDMODEL_PREC_BITS) + WARPEDMODEL_NONDIAGAFFINE_CLAMP - 1);
+  } else {
+    return (int32_t)clamp(
+        v * (1 << (-shift)),
+        (1 << WARPEDMODEL_PREC_BITS) - WARPEDMODEL_NONDIAGAFFINE_CLAMP + 1,
+        (1 << WARPEDMODEL_PREC_BITS) + WARPEDMODEL_NONDIAGAFFINE_CLAMP - 1);
+  }
+}
+
+#else
+
+static int32_t get_mult_shift_ndiag(int64_t Px, int16_t iDet, int shift) {
+  int64_t v = Px * (int64_t)iDet;
+  return (int32_t)clamp64(ROUND_POWER_OF_TWO_SIGNED_64(v, shift),
+                          -WARPEDMODEL_NONDIAGAFFINE_CLAMP + 1,
+                          WARPEDMODEL_NONDIAGAFFINE_CLAMP - 1);
+}
+
+static int32_t get_mult_shift_diag(int64_t Px, int16_t iDet, int shift) {
+  int64_t v = Px * (int64_t)iDet;
+  return (int32_t)clamp64(
+      ROUND_POWER_OF_TWO_SIGNED_64(v, shift),
+      (1 << WARPEDMODEL_PREC_BITS) - WARPEDMODEL_NONDIAGAFFINE_CLAMP + 1,
+      (1 << WARPEDMODEL_PREC_BITS) + WARPEDMODEL_NONDIAGAFFINE_CLAMP - 1);
+}
+#endif  // USE_LIMITED_PREC_MULT
+
 static int find_affine_int(int np, int *pts1, int *pts2, BLOCK_SIZE bsize,
                            int mvy, int mvx, WarpedMotionParams *wm, int mi_row,
                            int mi_col) {
   int32_t A[2][2] = { { 0, 0 }, { 0, 0 } };
   int32_t Bx[2] = { 0, 0 };
   int32_t By[2] = { 0, 0 };
   int i, n = 0;
 
   const int bw = block_size_wide[bsize];
   const int bh = block_size_high[bsize];
-  const int suy = (mi_row * MI_SIZE + AOMMAX(bh, MI_SIZE) / 2 - 1) * 8;
-  const int sux = (mi_col * MI_SIZE + AOMMAX(bw, MI_SIZE) / 2 - 1) * 8;
+  const int isuy = (mi_row * MI_SIZE + AOMMAX(bh, MI_SIZE) / 2 - 1);
+  const int isux = (mi_col * MI_SIZE + AOMMAX(bw, MI_SIZE) / 2 - 1);
+  const int suy = isuy * 8;
+  const int sux = isux * 8;
   const int duy = suy + mvy;
   const int dux = sux + mvx;
 
   // Assume the center pixel of the block has exactly the same motion vector
   // as transmitted for the block. First shift the origin of the source
   // points to the block center, and the origin of the destination points to
   // the block center added to the motion vector transmitted.
   // Let (xi, yi) denote the source points and (xi', yi') denote destination
@@ -1585,68 +1920,46 @@ static int find_affine_int(int np, int *
   if (Det == 0) return 1;
   iDet = resolve_divisor_64(llabs(Det), &shift) * (Det < 0 ? -1 : 1);
   shift -= WARPEDMODEL_PREC_BITS;
   if (shift < 0) {
     iDet <<= (-shift);
     shift = 0;
   }
 
-  int64_t v;
-  v = Px[0] * (int64_t)iDet;
-  wm->wmmat[2] = (int32_t)(ROUND_POWER_OF_TWO_SIGNED_64(v, shift));
-  v = Px[1] * (int64_t)iDet;
-  wm->wmmat[3] = (int32_t)(ROUND_POWER_OF_TWO_SIGNED_64(v, shift));
-  v = ((int64_t)dux * (1 << WARPEDMODEL_PREC_BITS)) -
-      (int64_t)sux * wm->wmmat[2] - (int64_t)suy * wm->wmmat[3];
-  wm->wmmat[0] = (int32_t)(ROUND_POWER_OF_TWO_SIGNED(v, 3));
+  wm->wmmat[2] = get_mult_shift_diag(Px[0], iDet, shift);
+  wm->wmmat[3] = get_mult_shift_ndiag(Px[1], iDet, shift);
+  wm->wmmat[4] = get_mult_shift_ndiag(Py[0], iDet, shift);
+  wm->wmmat[5] = get_mult_shift_diag(Py[1], iDet, shift);
 
-  v = Py[0] * (int64_t)iDet;
-  wm->wmmat[4] = (int32_t)(ROUND_POWER_OF_TWO_SIGNED_64(v, shift));
-  v = Py[1] * (int64_t)iDet;
-  wm->wmmat[5] = (int32_t)(ROUND_POWER_OF_TWO_SIGNED_64(v, shift));
-  v = ((int64_t)duy * (1 << WARPEDMODEL_PREC_BITS)) -
-      (int64_t)sux * wm->wmmat[4] - (int64_t)suy * wm->wmmat[5];
-  wm->wmmat[1] = (int32_t)(ROUND_POWER_OF_TWO_SIGNED(v, 3));
+  // Note: In the vx, vy expressions below, the max value of each of the
+  // 2nd and 3rd terms are (2^16 - 1) * (2^13 - 1). That leaves enough room
+  // for the first term so that the overall sum in the worst case fits
+  // within 32 bits overall.
+  int32_t vx = mvx * (1 << (WARPEDMODEL_PREC_BITS - 3)) -
+               (isux * (wm->wmmat[2] - (1 << WARPEDMODEL_PREC_BITS)) +
+                isuy * wm->wmmat[3]);
+  int32_t vy = mvy * (1 << (WARPEDMODEL_PREC_BITS - 3)) -
+               (isux * wm->wmmat[4] +
+                isuy * (wm->wmmat[5] - (1 << WARPEDMODEL_PREC_BITS)));
+  wm->wmmat[0] =
+      clamp(vx, -WARPEDMODEL_TRANS_CLAMP, WARPEDMODEL_TRANS_CLAMP - 1);
+  wm->wmmat[1] =
+      clamp(vy, -WARPEDMODEL_TRANS_CLAMP, WARPEDMODEL_TRANS_CLAMP - 1);
 
   wm->wmmat[6] = wm->wmmat[7] = 0;
-
-  // Clamp values
-  wm->wmmat[0] = clamp(wm->wmmat[0], -WARPEDMODEL_TRANS_CLAMP,
-                       WARPEDMODEL_TRANS_CLAMP - 1);
-  wm->wmmat[1] = clamp(wm->wmmat[1], -WARPEDMODEL_TRANS_CLAMP,
-                       WARPEDMODEL_TRANS_CLAMP - 1);
-  wm->wmmat[2] = clamp(wm->wmmat[2], -WARPEDMODEL_DIAGAFFINE_CLAMP,
-                       WARPEDMODEL_DIAGAFFINE_CLAMP - 1);
-  wm->wmmat[5] = clamp(wm->wmmat[5], -WARPEDMODEL_DIAGAFFINE_CLAMP,
-                       WARPEDMODEL_DIAGAFFINE_CLAMP - 1);
-  wm->wmmat[3] = clamp(wm->wmmat[3], -WARPEDMODEL_NONDIAGAFFINE_CLAMP,
-                       WARPEDMODEL_NONDIAGAFFINE_CLAMP - 1);
-  wm->wmmat[4] = clamp(wm->wmmat[4], -WARPEDMODEL_NONDIAGAFFINE_CLAMP,
-                       WARPEDMODEL_NONDIAGAFFINE_CLAMP - 1);
   return 0;
 }
 
 int find_projection(int np, int *pts1, int *pts2, BLOCK_SIZE bsize, int mvy,
                     int mvx, WarpedMotionParams *wm_params, int mi_row,
                     int mi_col) {
-  int result = 1;
-  switch (wm_params->wmtype) {
-    case AFFINE:
-      result = find_affine_int(np, pts1, pts2, bsize, mvy, mvx, wm_params,
-                               mi_row, mi_col);
-      break;
-    default: assert(0 && "Invalid warped motion type!"); return 1;
-  }
+  assert(wm_params->wmtype == AFFINE);
+  const int result = find_affine_int(np, pts1, pts2, bsize, mvy, mvx, wm_params,
+                                     mi_row, mi_col);
   if (result == 0) {
-    if (wm_params->wmtype == ROTZOOM) {
-      wm_params->wmmat[5] = wm_params->wmmat[2];
-      wm_params->wmmat[4] = -wm_params->wmmat[3];
-    }
-    if (wm_params->wmtype == AFFINE || wm_params->wmtype == ROTZOOM) {
-      // check compatibility with the fast warp filter
-      if (!get_shear_params(wm_params)) return 1;
-    }
+    // check compatibility with the fast warp filter
+    if (!get_shear_params(wm_params)) return 1;
   }
 
   return result;
 }
 #endif  // CONFIG_WARPED_MOTION
--- a/third_party/aom/av1/common/warped_motion.h
+++ b/third_party/aom/av1/common/warped_motion.h
@@ -17,23 +17,23 @@
 #include <memory.h>
 #include <math.h>
 #include <assert.h>
 
 #include "./aom_config.h"
 #include "aom_ports/mem.h"
 #include "aom_dsp/aom_dsp_common.h"
 #include "av1/common/mv.h"
+#include "av1/common/convolve.h"
 
 #define MAX_PARAMDIM 9
 #if CONFIG_WARPED_MOTION
-#define SAMPLES_ARRAY_SIZE ((2 * MAX_MIB_SIZE + 2) * 2)
-
 #define LEAST_SQUARES_SAMPLES_MAX_BITS 3
 #define LEAST_SQUARES_SAMPLES_MAX (1 << LEAST_SQUARES_SAMPLES_MAX_BITS)
+#define SAMPLES_ARRAY_SIZE (LEAST_SQUARES_SAMPLES_MAX * 2)
 
 #define DEFAULT_WMTYPE AFFINE
 #endif  // CONFIG_WARPED_MOTION
 
 extern const int16_t warped_filter[WARPEDPIXEL_PREC_SHIFTS * 3 + 1][8];
 
 typedef void (*ProjectPointsFunc)(const int32_t *mat, int *points, int *proj,
                                   const int n, const int stride_points,
@@ -64,47 +64,45 @@ void project_points_vertrapezoid(const i
                                  const int n, const int stride_points,
                                  const int stride_proj, const int subsampling_x,
                                  const int subsampling_y);
 void project_points_homography(const int32_t *mat, int *points, int *proj,
                                const int n, const int stride_points,
                                const int stride_proj, const int subsampling_x,
                                const int subsampling_y);
 
-void project_points(const WarpedMotionParams *wm_params, int *points, int *proj,
-                    const int n, const int stride_points, const int stride_proj,
-                    const int subsampling_x, const int subsampling_y);
-
 // Returns the error between the result of applying motion 'wm' to the frame
 // described by 'ref' and the frame described by 'dst'.
 int64_t av1_warp_error(WarpedMotionParams *wm,
 #if CONFIG_HIGHBITDEPTH
                        int use_hbd, int bd,
 #endif  // CONFIG_HIGHBITDEPTH
                        const uint8_t *ref, int width, int height, int stride,
                        uint8_t *dst, int p_col, int p_row, int p_width,
                        int p_height, int p_stride, int subsampling_x,
-                       int subsampling_y, int x_scale, int y_scale);
+                       int subsampling_y, int x_scale, int y_scale,
+                       int64_t best_error);
 
 // Returns the error between the frame described by 'ref' and the frame
 // described by 'dst'.
 int64_t av1_frame_error(
 #if CONFIG_HIGHBITDEPTH
     int use_hbd, int bd,
 #endif  // CONFIG_HIGHBITDEPTH
-    const uint8_t *ref, int stride, uint8_t *dst, int p_col, int p_row,
-    int p_width, int p_height, int p_stride);
+    const uint8_t *ref, int stride, uint8_t *dst, int p_width, int p_height,
+    int p_stride);
 
 void av1_warp_plane(WarpedMotionParams *wm,
 #if CONFIG_HIGHBITDEPTH
                     int use_hbd, int bd,
 #endif  // CONFIG_HIGHBITDEPTH
                     const uint8_t *ref, int width, int height, int stride,
                     uint8_t *pred, int p_col, int p_row, int p_width,
                     int p_height, int p_stride, int subsampling_x,
-                    int subsampling_y, int x_scale, int y_scale, int comp_avg);
+                    int subsampling_y, int x_scale, int y_scale,
+                    ConvolveParams *conv_params);
 
 int find_projection(int np, int *pts1, int *pts2, BLOCK_SIZE bsize, int mvy,
                     int mvx, WarpedMotionParams *wm_params, int mi_row,
                     int mi_col);
 
 int get_shear_params(WarpedMotionParams *wm);
 #endif  // AV1_COMMON_WARPED_MOTION_H_
--- a/third_party/aom/av1/common/x86/av1_convolve_ssse3.c
+++ b/third_party/aom/av1/common/x86/av1_convolve_ssse3.c
@@ -671,21 +671,22 @@ void av1_convolve_horiz_ssse3(const uint
                               int dst_stride, int w, int h,
                               const InterpFilterParams filter_params,
                               const int subpel_x_q4, int x_step_q4,
                               ConvolveParams *conv_params) {
   DECLARE_ALIGNED(16, uint16_t, temp[8 * 8]);
   __m128i verf[6];
   __m128i horf[2];
   SubpelFilterCoeffs hCoeffs, vCoeffs;
+  assert(conv_params->do_average == 0 || conv_params->do_average == 1);
   const uint8_t *src_ptr;
-  store_pixel_t store2p = store2pixelTab[conv_params->ref];
-  store_pixel_t store4p = store4pixelTab[conv_params->ref];
-  transpose_to_dst_t transpose_4x4 = trans4x4Tab[conv_params->ref];
-  transpose_to_dst_t transpose_8x8 = trans8x8Tab[conv_params->ref];
+  store_pixel_t store2p = store2pixelTab[conv_params->do_average];
+  store_pixel_t store4p = store4pixelTab[conv_params->do_average];
+  transpose_to_dst_t transpose_4x4 = trans4x4Tab[conv_params->do_average];
+  transpose_to_dst_t transpose_8x8 = trans8x8Tab[conv_params->do_average];
 
   const int tapsNum = filter_params.taps;
   int block_height, block_residu;
   int i, col, count;
   (void)x_step_q4;
 
   if (0 == subpel_x_q4 || 16 != x_step_q4) {
     av1_convolve_horiz_c(src, src_stride, dst, dst_stride, w, h, filter_params,
@@ -885,20 +886,21 @@ static void filter_vert_compute_large(co
 void av1_convolve_vert_ssse3(const uint8_t *src, int src_stride, uint8_t *dst,
                              int dst_stride, int w, int h,
                              const InterpFilterParams filter_params,
                              const int subpel_y_q4, int y_step_q4,
                              ConvolveParams *conv_params) {
   __m128i verf[6];
   SubpelFilterCoeffs vCoeffs;
   const uint8_t *src_ptr;
+  assert(conv_params->do_average == 0 || conv_params->do_average == 1);
   uint8_t *dst_ptr = dst;
-  store_pixel_t store2p = store2pixelTab[conv_params->ref];
-  store_pixel_t store4p = store4pixelTab[conv_params->ref];
-  store_pixel_t store8p = store8pixelTab[conv_params->ref];
+  store_pixel_t store2p = store2pixelTab[conv_params->do_average];
+  store_pixel_t store4p = store4pixelTab[conv_params->do_average];
+  store_pixel_t store8p = store8pixelTab[conv_params->do_average];
   const int tapsNum = filter_params.taps;
 
   if (0 == subpel_y_q4 || 16 != y_step_q4) {
     av1_convolve_vert_c(src, src_stride, dst, dst_stride, w, h, filter_params,
                         subpel_y_q4, y_step_q4, conv_params);
     return;
   }
 
--- a/third_party/aom/av1/common/x86/av1_fwd_txfm2d_sse4.c
+++ b/third_party/aom/av1/common/x86/av1_fwd_txfm2d_sse4.c
@@ -35,17 +35,22 @@ static INLINE TxfmFuncSSE2 fwd_txfm_type
   }
   return NULL;
 }
 
 static INLINE void fwd_txfm2d_sse4_1(const int16_t *input, int32_t *output,
                                      const int stride,
                                      const TXFM_2D_FLIP_CFG *cfg,
                                      int32_t *txfm_buf) {
-  // TODO(sarahparker) must correct for rectangular transforms in follow up
+  // TODO(sarahparker) This does not currently support rectangular transforms
+  // and will break without splitting txfm_size out into row and col size.
+  // Rectangular transforms use c code only, so it should be ok for now.
+  // It will be corrected when there are sse implementations for rectangular
+  // transforms.
+  assert(cfg->row_cfg->txfm_size == cfg->col_cfg->txfm_size);
   const int txfm_size = cfg->row_cfg->txfm_size;
   const int8_t *shift = cfg->row_cfg->shift;
   const int8_t *stage_range_col = cfg->col_cfg->stage_range;
   const int8_t *stage_range_row = cfg->row_cfg->stage_range;
   const int8_t *cos_bit_col = cfg->col_cfg->cos_bit;
   const int8_t *cos_bit_row = cfg->row_cfg->cos_bit;
   const TxfmFuncSSE2 txfm_func_col =
       fwd_txfm_type_to_func(cfg->col_cfg->txfm_type);
--- a/third_party/aom/av1/common/x86/av1_txfm1d_sse4.h
+++ b/third_party/aom/av1/common/x86/av1_txfm1d_sse4.h
@@ -59,17 +59,17 @@ static INLINE void transpose_32_4x4(int 
   output[1 * stride] = _mm_unpackhi_epi32(temp0, temp2);
   output[2 * stride] = _mm_unpacklo_epi32(temp1, temp3);
   output[3 * stride] = _mm_unpackhi_epi32(temp1, temp3);
 }
 
 // the entire input block can be represent by a grid of 4x4 blocks
 // each 4x4 blocks can be represent by 4 vertical __m128i
 // we first transpose each 4x4 block internally
-// than transpose the grid
+// then transpose the grid
 static INLINE void transpose_32(int txfm_size, const __m128i *input,
                                 __m128i *output) {
   const int num_per_128 = 4;
   const int row_size = txfm_size;
   const int col_size = txfm_size / num_per_128;
   int r, c;
 
   // transpose each 4x4 block internally
new file mode 100644
--- /dev/null
+++ b/third_party/aom/av1/common/x86/convolve_2d_sse2.c
@@ -0,0 +1,367 @@
+/*
+ * Copyright (c) 2016, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+#include <emmintrin.h>
+
+#include "./aom_dsp_rtcd.h"
+#include "aom_dsp/aom_convolve.h"
+#include "aom_dsp/aom_dsp_common.h"
+#include "aom_dsp/aom_filter.h"
+#include "av1/common/convolve.h"
+
+#if CONFIG_COMPOUND_ROUND
+void av1_convolve_2d_sse2(const uint8_t *src, int src_stride,
+                          CONV_BUF_TYPE *dst, int dst_stride, int w, int h,
+                          InterpFilterParams *filter_params_x,
+                          InterpFilterParams *filter_params_y,
+                          const int subpel_x_q4, const int subpel_y_q4,
+                          ConvolveParams *conv_params) {
+  DECLARE_ALIGNED(16, uint8_t,
+                  im_block[(MAX_SB_SIZE + MAX_FILTER_TAP - 1) * MAX_SB_SIZE]);
+  int im_h = h + filter_params_y->taps - 1;
+  int im_stride = MAX_SB_SIZE;
+  int i, j;
+  const int fo_vert = filter_params_y->taps / 2 - 1;
+  const int fo_horiz = filter_params_x->taps / 2 - 1;
+  const uint8_t *const src_ptr = src - fo_vert * src_stride - fo_horiz;
+
+  const __m128i zero = _mm_setzero_si128();
+
+  /* Horizontal filter */
+  {
+    const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
+        *filter_params_x, subpel_x_q4 & SUBPEL_MASK);
+    const __m128i coeffs_x = _mm_loadu_si128((__m128i *)x_filter);
+
+    // coeffs 0 1 0 1 2 3 2 3
+    const __m128i tmp_0 = _mm_unpacklo_epi32(coeffs_x, coeffs_x);
+    // coeffs 4 5 4 5 6 7 6 7
+    const __m128i tmp_1 = _mm_unpackhi_epi32(coeffs_x, coeffs_x);
+
+    // coeffs 0 1 0 1 0 1 0 1
+    const __m128i coeff_01 = _mm_unpacklo_epi64(tmp_0, tmp_0);
+    // coeffs 2 3 2 3 2 3 2 3
+    const __m128i coeff_23 = _mm_unpackhi_epi64(tmp_0, tmp_0);
+    // coeffs 4 5 4 5 4 5 4 5
+    const __m128i coeff_45 = _mm_unpacklo_epi64(tmp_1, tmp_1);
+    // coeffs 6 7 6 7 6 7 6 7
+    const __m128i coeff_67 = _mm_unpackhi_epi64(tmp_1, tmp_1);
+
+    const __m128i round_const =
+        _mm_set1_epi32((1 << conv_params->round_0) >> 1);
+    const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_0);
+
+    for (i = 0; i < im_h; ++i) {
+      for (j = 0; j < w; j += 8) {
+        const __m128i data =
+            _mm_loadu_si128((__m128i *)&src_ptr[i * src_stride + j]);
+
+        // Filter even-index pixels
+        const __m128i src_0 = _mm_unpacklo_epi8(data, zero);
+        const __m128i res_0 = _mm_madd_epi16(src_0, coeff_01);
+        const __m128i src_2 = _mm_unpacklo_epi8(_mm_srli_si128(data, 2), zero);
+        const __m128i res_2 = _mm_madd_epi16(src_2, coeff_23);
+        const __m128i src_4 = _mm_unpacklo_epi8(_mm_srli_si128(data, 4), zero);
+        const __m128i res_4 = _mm_madd_epi16(src_4, coeff_45);
+        const __m128i src_6 = _mm_unpacklo_epi8(_mm_srli_si128(data, 6), zero);
+        const __m128i res_6 = _mm_madd_epi16(src_6, coeff_67);
+
+        __m128i res_even = _mm_add_epi32(_mm_add_epi32(res_0, res_4),
+                                         _mm_add_epi32(res_2, res_6));
+        res_even =
+            _mm_sra_epi32(_mm_add_epi32(res_even, round_const), round_shift);
+
+        // Filter odd-index pixels
+        const __m128i src_1 = _mm_unpacklo_epi8(_mm_srli_si128(data, 1), zero);
+        const __m128i res_1 = _mm_madd_epi16(src_1, coeff_01);
+        const __m128i src_3 = _mm_unpacklo_epi8(_mm_srli_si128(data, 3), zero);
+        const __m128i res_3 = _mm_madd_epi16(src_3, coeff_23);
+        const __m128i src_5 = _mm_unpacklo_epi8(_mm_srli_si128(data, 5), zero);
+        const __m128i res_5 = _mm_madd_epi16(src_5, coeff_45);
+        const __m128i src_7 = _mm_unpacklo_epi8(_mm_srli_si128(data, 7), zero);
+        const __m128i res_7 = _mm_madd_epi16(src_7, coeff_67);
+
+        __m128i res_odd = _mm_add_epi32(_mm_add_epi32(res_1, res_5),
+                                        _mm_add_epi32(res_3, res_7));
+        res_odd =
+            _mm_sra_epi32(_mm_add_epi32(res_odd, round_const), round_shift);
+
+        // Pack in the column order 0, 2, 4, 6, 1, 3, 5, 7
+        __m128i res = _mm_packs_epi32(res_even, res_odd);
+        res = _mm_packus_epi16(res, res);
+        _mm_storel_epi64((__m128i *)&im_block[i * im_stride + j], res);
+      }
+    }
+  }
+
+  /* Vertical filter */
+  {
+    const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
+        *filter_params_y, subpel_y_q4 & SUBPEL_MASK);
+    const __m128i coeffs_y = _mm_loadu_si128((__m128i *)y_filter);
+
+    // coeffs 0 1 0 1 2 3 2 3
+    const __m128i tmp_0 = _mm_unpacklo_epi32(coeffs_y, coeffs_y);
+    // coeffs 4 5 4 5 6 7 6 7
+    const __m128i tmp_1 = _mm_unpackhi_epi32(coeffs_y, coeffs_y);
+
+    // coeffs 0 1 0 1 0 1 0 1
+    const __m128i coeff_01 = _mm_unpacklo_epi64(tmp_0, tmp_0);
+    // coeffs 2 3 2 3 2 3 2 3
+    const __m128i coeff_23 = _mm_unpackhi_epi64(tmp_0, tmp_0);
+    // coeffs 4 5 4 5 4 5 4 5
+    const __m128i coeff_45 = _mm_unpacklo_epi64(tmp_1, tmp_1);
+    // coeffs 6 7 6 7 6 7 6 7
+    const __m128i coeff_67 = _mm_unpackhi_epi64(tmp_1, tmp_1);
+
+    const __m128i round_const =
+        _mm_set1_epi32((1 << conv_params->round_1) >> 1);
+    const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_1);
+
+    for (i = 0; i < h; ++i) {
+      for (j = 0; j < w; j += 8) {
+        // Filter even-index pixels
+        const uint8_t *data = &im_block[i * im_stride + j];
+        const __m128i src_01 = _mm_unpacklo_epi8(
+            _mm_loadl_epi64((__m128i *)(data + 0 * im_stride)),
+            _mm_loadl_epi64((__m128i *)(data + 1 * im_stride)));
+        const __m128i src_23 = _mm_unpacklo_epi8(
+            _mm_loadl_epi64((__m128i *)(data + 2 * im_stride)),
+            _mm_loadl_epi64((__m128i *)(data + 3 * im_stride)));
+        const __m128i src_45 = _mm_unpacklo_epi8(
+            _mm_loadl_epi64((__m128i *)(data + 4 * im_stride)),
+            _mm_loadl_epi64((__m128i *)(data + 5 * im_stride)));
+        const __m128i src_67 = _mm_unpacklo_epi8(
+            _mm_loadl_epi64((__m128i *)(data + 6 * im_stride)),
+            _mm_loadl_epi64((__m128i *)(data + 7 * im_stride)));
+
+        const __m128i src_0 = _mm_unpacklo_epi8(src_01, zero);
+        const __m128i src_2 = _mm_unpacklo_epi8(src_23, zero);
+        const __m128i src_4 = _mm_unpacklo_epi8(src_45, zero);
+        const __m128i src_6 = _mm_unpacklo_epi8(src_67, zero);
+
+        const __m128i res_0 = _mm_madd_epi16(src_0, coeff_01);
+        const __m128i res_2 = _mm_madd_epi16(src_2, coeff_23);
+        const __m128i res_4 = _mm_madd_epi16(src_4, coeff_45);
+        const __m128i res_6 = _mm_madd_epi16(src_6, coeff_67);
+
+        const __m128i res_even = _mm_add_epi32(_mm_add_epi32(res_0, res_2),
+                                               _mm_add_epi32(res_4, res_6));
+
+        // Filter odd-index pixels
+        const __m128i src_1 = _mm_unpackhi_epi8(src_01, zero);
+        const __m128i src_3 = _mm_unpackhi_epi8(src_23, zero);
+        const __m128i src_5 = _mm_unpackhi_epi8(src_45, zero);
+        const __m128i src_7 = _mm_unpackhi_epi8(src_67, zero);
+
+        const __m128i res_1 = _mm_madd_epi16(src_1, coeff_01);
+        const __m128i res_3 = _mm_madd_epi16(src_3, coeff_23);
+        const __m128i res_5 = _mm_madd_epi16(src_5, coeff_45);
+        const __m128i res_7 = _mm_madd_epi16(src_7, coeff_67);
+
+        const __m128i res_odd = _mm_add_epi32(_mm_add_epi32(res_1, res_3),
+                                              _mm_add_epi32(res_5, res_7));
+
+        // Rearrange pixels back into the order 0 ... 7
+        const __m128i res_lo = _mm_unpacklo_epi32(res_even, res_odd);
+        const __m128i res_hi = _mm_unpackhi_epi32(res_even, res_odd);
+
+        const __m128i res_lo_round =
+            _mm_sra_epi32(_mm_add_epi32(res_lo, round_const), round_shift);
+        const __m128i res_hi_round =
+            _mm_sra_epi32(_mm_add_epi32(res_hi, round_const), round_shift);
+
+        // Accumulate values into the destination buffer
+        __m128i *const p = (__m128i *)&dst[i * dst_stride + j];
+        _mm_storeu_si128(p, _mm_add_epi32(_mm_loadu_si128(p), res_lo_round));
+        _mm_storeu_si128(p + 1,
+                         _mm_add_epi32(_mm_loadu_si128(p + 1), res_hi_round));
+      }
+    }
+  }
+}
+#else
+void av1_convolve_2d_sse2(const uint8_t *src, int src_stride,
+                          CONV_BUF_TYPE *dst, int dst_stride, int w, int h,
+                          InterpFilterParams *filter_params_x,
+                          InterpFilterParams *filter_params_y,
+                          const int subpel_x_q4, const int subpel_y_q4,
+                          ConvolveParams *conv_params) {
+  const int bd = 8;
+
+  DECLARE_ALIGNED(16, int16_t,
+                  im_block[(MAX_SB_SIZE + MAX_FILTER_TAP - 1) * MAX_SB_SIZE]);
+  int im_h = h + filter_params_y->taps - 1;
+  int im_stride = MAX_SB_SIZE;
+  int i, j;
+  const int fo_vert = filter_params_y->taps / 2 - 1;
+  const int fo_horiz = filter_params_x->taps / 2 - 1;
+  const uint8_t *const src_ptr = src - fo_vert * src_stride - fo_horiz;
+
+  const __m128i zero = _mm_setzero_si128();
+
+  /* Horizontal filter */
+  {
+    const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
+        *filter_params_x, subpel_x_q4 & SUBPEL_MASK);
+    const __m128i coeffs_x = _mm_loadu_si128((__m128i *)x_filter);
+
+    // coeffs 0 1 0 1 2 3 2 3
+    const __m128i tmp_0 = _mm_unpacklo_epi32(coeffs_x, coeffs_x);
+    // coeffs 4 5 4 5 6 7 6 7
+    const __m128i tmp_1 = _mm_unpackhi_epi32(coeffs_x, coeffs_x);
+
+    // coeffs 0 1 0 1 0 1 0 1
+    const __m128i coeff_01 = _mm_unpacklo_epi64(tmp_0, tmp_0);
+    // coeffs 2 3 2 3 2 3 2 3
+    const __m128i coeff_23 = _mm_unpackhi_epi64(tmp_0, tmp_0);
+    // coeffs 4 5 4 5 4 5 4 5
+    const __m128i coeff_45 = _mm_unpacklo_epi64(tmp_1, tmp_1);
+    // coeffs 6 7 6 7 6 7 6 7
+    const __m128i coeff_67 = _mm_unpackhi_epi64(tmp_1, tmp_1);
+
+    const __m128i round_const = _mm_set1_epi32(
+        ((1 << conv_params->round_0) >> 1) + (1 << (bd + FILTER_BITS - 1)));
+    const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_0);
+
+    for (i = 0; i < im_h; ++i) {
+      for (j = 0; j < w; j += 8) {
+        const __m128i data =
+            _mm_loadu_si128((__m128i *)&src_ptr[i * src_stride + j]);
+
+        // Filter even-index pixels
+        const __m128i src_0 = _mm_unpacklo_epi8(data, zero);
+        const __m128i res_0 = _mm_madd_epi16(src_0, coeff_01);
+        const __m128i src_2 = _mm_unpacklo_epi8(_mm_srli_si128(data, 2), zero);
+        const __m128i res_2 = _mm_madd_epi16(src_2, coeff_23);
+        const __m128i src_4 = _mm_unpacklo_epi8(_mm_srli_si128(data, 4), zero);
+        const __m128i res_4 = _mm_madd_epi16(src_4, coeff_45);
+        const __m128i src_6 = _mm_unpacklo_epi8(_mm_srli_si128(data, 6), zero);
+        const __m128i res_6 = _mm_madd_epi16(src_6, coeff_67);
+
+        __m128i res_even = _mm_add_epi32(_mm_add_epi32(res_0, res_4),
+                                         _mm_add_epi32(res_2, res_6));
+        res_even =
+            _mm_sra_epi32(_mm_add_epi32(res_even, round_const), round_shift);
+
+        // Filter odd-index pixels
+        const __m128i src_1 = _mm_unpacklo_epi8(_mm_srli_si128(data, 1), zero);
+        const __m128i res_1 = _mm_madd_epi16(src_1, coeff_01);
+        const __m128i src_3 = _mm_unpacklo_epi8(_mm_srli_si128(data, 3), zero);
+        const __m128i res_3 = _mm_madd_epi16(src_3, coeff_23);
+        const __m128i src_5 = _mm_unpacklo_epi8(_mm_srli_si128(data, 5), zero);
+        const __m128i res_5 = _mm_madd_epi16(src_5, coeff_45);
+        const __m128i src_7 = _mm_unpacklo_epi8(_mm_srli_si128(data, 7), zero);
+        const __m128i res_7 = _mm_madd_epi16(src_7, coeff_67);
+
+        __m128i res_odd = _mm_add_epi32(_mm_add_epi32(res_1, res_5),
+                                        _mm_add_epi32(res_3, res_7));
+        res_odd =
+            _mm_sra_epi32(_mm_add_epi32(res_odd, round_const), round_shift);
+
+        // Pack in the column order 0, 2, 4, 6, 1, 3, 5, 7
+        __m128i res = _mm_packs_epi32(res_even, res_odd);
+        _mm_storeu_si128((__m128i *)&im_block[i * im_stride + j], res);
+      }
+    }
+  }
+
+  /* Vertical filter */
+  {
+    const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
+        *filter_params_y, subpel_y_q4 & SUBPEL_MASK);
+    const __m128i coeffs_y = _mm_loadu_si128((__m128i *)y_filter);
+
+    // coeffs 0 1 0 1 2 3 2 3
+    const __m128i tmp_0 = _mm_unpacklo_epi32(coeffs_y, coeffs_y);
+    // coeffs 4 5 4 5 6 7 6 7
+    const __m128i tmp_1 = _mm_unpackhi_epi32(coeffs_y, coeffs_y);
+
+    // coeffs 0 1 0 1 0 1 0 1
+    const __m128i coeff_01 = _mm_unpacklo_epi64(tmp_0, tmp_0);
+    // coeffs 2 3 2 3 2 3 2 3
+    const __m128i coeff_23 = _mm_unpackhi_epi64(tmp_0, tmp_0);
+    // coeffs 4 5 4 5 4 5 4 5
+    const __m128i coeff_45 = _mm_unpacklo_epi64(tmp_1, tmp_1);
+    // coeffs 6 7 6 7 6 7 6 7
+    const __m128i coeff_67 = _mm_unpackhi_epi64(tmp_1, tmp_1);
+
+    const __m128i round_const = _mm_set1_epi32(
+        ((1 << conv_params->round_1) >> 1) -
+        (1 << (bd + 2 * FILTER_BITS - conv_params->round_0 - 1)));
+    const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_1);
+
+    for (i = 0; i < h; ++i) {
+      for (j = 0; j < w; j += 8) {
+        // Filter even-index pixels
+        const int16_t *data = &im_block[i * im_stride + j];
+        const __m128i src_0 =
+            _mm_unpacklo_epi16(*(__m128i *)(data + 0 * im_stride),
+                               *(__m128i *)(data + 1 * im_stride));
+        const __m128i src_2 =
+            _mm_unpacklo_epi16(*(__m128i *)(data + 2 * im_stride),
+                               *(__m128i *)(data + 3 * im_stride));
+        const __m128i src_4 =
+            _mm_unpacklo_epi16(*(__m128i *)(data + 4 * im_stride),
+                               *(__m128i *)(data + 5 * im_stride));
+        const __m128i src_6 =
+            _mm_unpacklo_epi16(*(__m128i *)(data + 6 * im_stride),
+                               *(__m128i *)(data + 7 * im_stride));
+
+        const __m128i res_0 = _mm_madd_epi16(src_0, coeff_01);
+        const __m128i res_2 = _mm_madd_epi16(src_2, coeff_23);
+        const __m128i res_4 = _mm_madd_epi16(src_4, coeff_45);
+        const __m128i res_6 = _mm_madd_epi16(src_6, coeff_67);
+
+        const __m128i res_even = _mm_add_epi32(_mm_add_epi32(res_0, res_2),
+                                               _mm_add_epi32(res_4, res_6));
+
+        // Filter odd-index pixels
+        const __m128i src_1 =
+            _mm_unpackhi_epi16(*(__m128i *)(data + 0 * im_stride),
+                               *(__m128i *)(data + 1 * im_stride));
+        const __m128i src_3 =
+            _mm_unpackhi_epi16(*(__m128i *)(data + 2 * im_stride),
+                               *(__m128i *)(data + 3 * im_stride));
+        const __m128i src_5 =
+            _mm_unpackhi_epi16(*(__m128i *)(data + 4 * im_stride),
+                               *(__m128i *)(data + 5 * im_stride));
+        const __m128i src_7 =
+            _mm_unpackhi_epi16(*(__m128i *)(data + 6 * im_stride),
+                               *(__m128i *)(data + 7 * im_stride));
+
+        const __m128i res_1 = _mm_madd_epi16(src_1, coeff_01);
+        const __m128i res_3 = _mm_madd_epi16(src_3, coeff_23);
+        const __m128i res_5 = _mm_madd_epi16(src_5, coeff_45);
+        const __m128i res_7 = _mm_madd_epi16(src_7, coeff_67);
+
+        const __m128i res_odd = _mm_add_epi32(_mm_add_epi32(res_1, res_3),
+                                              _mm_add_epi32(res_5, res_7));
+
+        // Rearrange pixels back into the order 0 ... 7
+        const __m128i res_lo = _mm_unpacklo_epi32(res_even, res_odd);
+        const __m128i res_hi = _mm_unpackhi_epi32(res_even, res_odd);
+
+        const __m128i res_lo_round =
+            _mm_sra_epi32(_mm_add_epi32(res_lo, round_const), round_shift);
+        const __m128i res_hi_round =
+            _mm_sra_epi32(_mm_add_epi32(res_hi, round_const), round_shift);
+
+        // Accumulate values into the destination buffer
+        __m128i *const p = (__m128i *)&dst[i * dst_stride + j];
+        _mm_storeu_si128(p, _mm_add_epi32(_mm_loadu_si128(p), res_lo_round));
+        _mm_storeu_si128(p + 1,
+                         _mm_add_epi32(_mm_loadu_si128(p + 1), res_hi_round));
+      }
+    }
+  }
+}
+#endif
new file mode 100644
--- /dev/null
+++ b/third_party/aom/av1/common/x86/highbd_convolve_2d_ssse3.c
@@ -0,0 +1,372 @@
+/*
+ * Copyright (c) 2016, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+#include <tmmintrin.h>
+#include <assert.h>
+
+#include "./aom_dsp_rtcd.h"
+#include "aom_dsp/aom_convolve.h"
+#include "aom_dsp/aom_dsp_common.h"
+#include "aom_dsp/aom_filter.h"
+#include "av1/common/convolve.h"
+
+#if CONFIG_COMPOUND_ROUND
+void av1_highbd_convolve_2d_ssse3(const uint16_t *src, int src_stride,
+                                  CONV_BUF_TYPE *dst, int dst_stride, int w,
+                                  int h, InterpFilterParams *filter_params_x,
+                                  InterpFilterParams *filter_params_y,
+                                  const int subpel_x_q4, const int subpel_y_q4,
+                                  ConvolveParams *conv_params, int bd) {
+  DECLARE_ALIGNED(16, int16_t,
+                  im_block[(MAX_SB_SIZE + MAX_FILTER_TAP - 1) * MAX_SB_SIZE]);
+  int im_h = h + filter_params_y->taps - 1;
+  int im_stride = MAX_SB_SIZE;
+  int i, j;
+  const int fo_vert = filter_params_y->taps / 2 - 1;
+  const int fo_horiz = filter_params_x->taps / 2 - 1;
+  const uint16_t *const src_ptr = src - fo_vert * src_stride - fo_horiz;
+
+  /* Horizontal filter */
+  {
+    const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
+        *filter_params_x, subpel_x_q4 & SUBPEL_MASK);
+    const __m128i coeffs_x = _mm_loadu_si128((__m128i *)x_filter);
+
+    // coeffs 0 1 0 1 2 3 2 3
+    const __m128i tmp_0 = _mm_unpacklo_epi32(coeffs_x, coeffs_x);
+    // coeffs 4 5 4 5 6 7 6 7
+    const __m128i tmp_1 = _mm_unpackhi_epi32(coeffs_x, coeffs_x);
+
+    // coeffs 0 1 0 1 0 1 0 1
+    const __m128i coeff_01 = _mm_unpacklo_epi64(tmp_0, tmp_0);
+    // coeffs 2 3 2 3 2 3 2 3
+    const __m128i coeff_23 = _mm_unpackhi_epi64(tmp_0, tmp_0);
+    // coeffs 4 5 4 5 4 5 4 5
+    const __m128i coeff_45 = _mm_unpacklo_epi64(tmp_1, tmp_1);
+    // coeffs 6 7 6 7 6 7 6 7
+    const __m128i coeff_67 = _mm_unpackhi_epi64(tmp_1, tmp_1);
+
+    const __m128i round_const =
+        _mm_set1_epi32((1 << conv_params->round_0) >> 1);
+    const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_0);
+
+    for (i = 0; i < im_h; ++i) {
+      for (j = 0; j < w; j += 8) {
+        const __m128i data =
+            _mm_loadu_si128((__m128i *)&src_ptr[i * src_stride + j]);
+        const __m128i data2 =
+            _mm_loadu_si128((__m128i *)&src_ptr[i * src_stride + j + 8]);
+
+        // Filter even-index pixels
+        const __m128i res_0 = _mm_madd_epi16(data, coeff_01);
+        const __m128i res_2 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 4), coeff_23);
+        const __m128i res_4 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 8), coeff_45);
+        const __m128i res_6 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 12), coeff_67);
+
+        __m128i res_even = _mm_add_epi32(_mm_add_epi32(res_0, res_4),
+                                         _mm_add_epi32(res_2, res_6));
+        res_even =
+            _mm_sra_epi32(_mm_add_epi32(res_even, round_const), round_shift);
+
+        // Filter odd-index pixels
+        const __m128i res_1 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 2), coeff_01);
+        const __m128i res_3 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 6), coeff_23);
+        const __m128i res_5 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 10), coeff_45);
+        const __m128i res_7 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 14), coeff_67);
+
+        __m128i res_odd = _mm_add_epi32(_mm_add_epi32(res_1, res_5),
+                                        _mm_add_epi32(res_3, res_7));
+        res_odd =
+            _mm_sra_epi32(_mm_add_epi32(res_odd, round_const), round_shift);
+
+        // Pack in the column order 0, 2, 4, 6, 1, 3, 5, 7
+        const __m128i maxval = _mm_set1_epi16((1 << bd) - 1);
+        __m128i res = _mm_packs_epi32(res_even, res_odd);
+        res = _mm_max_epi16(_mm_min_epi16(res, maxval), _mm_setzero_si128());
+        _mm_storeu_si128((__m128i *)&im_block[i * im_stride + j], res);
+      }
+    }
+  }
+
+  /* Vertical filter */
+  {
+    const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
+        *filter_params_y, subpel_y_q4 & SUBPEL_MASK);
+    const __m128i coeffs_y = _mm_loadu_si128((__m128i *)y_filter);
+
+    // coeffs 0 1 0 1 2 3 2 3
+    const __m128i tmp_0 = _mm_unpacklo_epi32(coeffs_y, coeffs_y);
+    // coeffs 4 5 4 5 6 7 6 7
+    const __m128i tmp_1 = _mm_unpackhi_epi32(coeffs_y, coeffs_y);
+
+    // coeffs 0 1 0 1 0 1 0 1
+    const __m128i coeff_01 = _mm_unpacklo_epi64(tmp_0, tmp_0);
+    // coeffs 2 3 2 3 2 3 2 3
+    const __m128i coeff_23 = _mm_unpackhi_epi64(tmp_0, tmp_0);
+    // coeffs 4 5 4 5 4 5 4 5
+    const __m128i coeff_45 = _mm_unpacklo_epi64(tmp_1, tmp_1);
+    // coeffs 6 7 6 7 6 7 6 7
+    const __m128i coeff_67 = _mm_unpackhi_epi64(tmp_1, tmp_1);
+
+    const __m128i round_const =
+        _mm_set1_epi32((1 << conv_params->round_1) >> 1);
+    const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_1);
+
+    for (i = 0; i < h; ++i) {
+      for (j = 0; j < w; j += 8) {
+        // Filter even-index pixels
+        const int16_t *data = &im_block[i * im_stride + j];
+        const __m128i src_0 =
+            _mm_unpacklo_epi16(*(__m128i *)(data + 0 * im_stride),
+                               *(__m128i *)(data + 1 * im_stride));
+        const __m128i src_2 =
+            _mm_unpacklo_epi16(*(__m128i *)(data + 2 * im_stride),
+                               *(__m128i *)(data + 3 * im_stride));
+        const __m128i src_4 =
+            _mm_unpacklo_epi16(*(__m128i *)(data + 4 * im_stride),
+                               *(__m128i *)(data + 5 * im_stride));
+        const __m128i src_6 =
+            _mm_unpacklo_epi16(*(__m128i *)(data + 6 * im_stride),
+                               *(__m128i *)(data + 7 * im_stride));
+
+        const __m128i res_0 = _mm_madd_epi16(src_0, coeff_01);
+        const __m128i res_2 = _mm_madd_epi16(src_2, coeff_23);
+        const __m128i res_4 = _mm_madd_epi16(src_4, coeff_45);
+        const __m128i res_6 = _mm_madd_epi16(src_6, coeff_67);
+
+        const __m128i res_even = _mm_add_epi32(_mm_add_epi32(res_0, res_2),
+                                               _mm_add_epi32(res_4, res_6));
+
+        // Filter odd-index pixels
+        const __m128i src_1 =
+            _mm_unpackhi_epi16(*(__m128i *)(data + 0 * im_stride),
+                               *(__m128i *)(data + 1 * im_stride));
+        const __m128i src_3 =
+            _mm_unpackhi_epi16(*(__m128i *)(data + 2 * im_stride),
+                               *(__m128i *)(data + 3 * im_stride));
+        const __m128i src_5 =
+            _mm_unpackhi_epi16(*(__m128i *)(data + 4 * im_stride),
+                               *(__m128i *)(data + 5 * im_stride));
+        const __m128i src_7 =
+            _mm_unpackhi_epi16(*(__m128i *)(data + 6 * im_stride),
+                               *(__m128i *)(data + 7 * im_stride));
+
+        const __m128i res_1 = _mm_madd_epi16(src_1, coeff_01);
+        const __m128i res_3 = _mm_madd_epi16(src_3, coeff_23);
+        const __m128i res_5 = _mm_madd_epi16(src_5, coeff_45);
+        const __m128i res_7 = _mm_madd_epi16(src_7, coeff_67);
+
+        const __m128i res_odd = _mm_add_epi32(_mm_add_epi32(res_1, res_3),
+                                              _mm_add_epi32(res_5, res_7));
+
+        // Rearrange pixels back into the order 0 ... 7
+        const __m128i res_lo = _mm_unpacklo_epi32(res_even, res_odd);
+        const __m128i res_hi = _mm_unpackhi_epi32(res_even, res_odd);
+
+        const __m128i res_lo_round =
+            _mm_sra_epi32(_mm_add_epi32(res_lo, round_const), round_shift);
+        const __m128i res_hi_round =
+            _mm_sra_epi32(_mm_add_epi32(res_hi, round_const), round_shift);
+
+        // Accumulate values into the destination buffer
+        __m128i *const p = (__m128i *)&dst[i * dst_stride + j];
+        _mm_storeu_si128(p, _mm_add_epi32(_mm_loadu_si128(p), res_lo_round));
+        _mm_storeu_si128(p + 1,
+                         _mm_add_epi32(_mm_loadu_si128(p + 1), res_hi_round));
+      }
+    }
+  }
+}
+#else
+void av1_highbd_convolve_2d_ssse3(const uint16_t *src, int src_stride,
+                                  CONV_BUF_TYPE *dst, int dst_stride, int w,
+                                  int h, InterpFilterParams *filter_params_x,
+                                  InterpFilterParams *filter_params_y,
+                                  const int subpel_x_q4, const int subpel_y_q4,
+                                  ConvolveParams *conv_params, int bd) {
+  DECLARE_ALIGNED(16, int16_t,
+                  im_block[(MAX_SB_SIZE + MAX_FILTER_TAP - 1) * MAX_SB_SIZE]);
+  int im_h = h + filter_params_y->taps - 1;
+  int im_stride = MAX_SB_SIZE;
+  int i, j;
+  const int fo_vert = filter_params_y->taps / 2 - 1;
+  const int fo_horiz = filter_params_x->taps / 2 - 1;
+  const uint16_t *const src_ptr = src - fo_vert * src_stride - fo_horiz;
+
+  // Check that, even with 12-bit input, the intermediate values will fit
+  // into an unsigned 15-bit intermediate array.
+  assert(conv_params->round_0 >= 5);
+
+  /* Horizontal filter */
+  {
+    const int16_t *x_filter = av1_get_interp_filter_subpel_kernel(
+        *filter_params_x, subpel_x_q4 & SUBPEL_MASK);
+    const __m128i coeffs_x = _mm_loadu_si128((__m128i *)x_filter);
+
+    // coeffs 0 1 0 1 2 3 2 3
+    const __m128i tmp_0 = _mm_unpacklo_epi32(coeffs_x, coeffs_x);
+    // coeffs 4 5 4 5 6 7 6 7
+    const __m128i tmp_1 = _mm_unpackhi_epi32(coeffs_x, coeffs_x);
+
+    // coeffs 0 1 0 1 0 1 0 1
+    const __m128i coeff_01 = _mm_unpacklo_epi64(tmp_0, tmp_0);
+    // coeffs 2 3 2 3 2 3 2 3
+    const __m128i coeff_23 = _mm_unpackhi_epi64(tmp_0, tmp_0);
+    // coeffs 4 5 4 5 4 5 4 5
+    const __m128i coeff_45 = _mm_unpacklo_epi64(tmp_1, tmp_1);
+    // coeffs 6 7 6 7 6 7 6 7
+    const __m128i coeff_67 = _mm_unpackhi_epi64(tmp_1, tmp_1);
+
+    const __m128i round_const = _mm_set1_epi32(
+        ((1 << conv_params->round_0) >> 1) + (1 << (bd + FILTER_BITS - 1)));
+    const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_0);
+
+    for (i = 0; i < im_h; ++i) {
+      for (j = 0; j < w; j += 8) {
+        const __m128i data =
+            _mm_loadu_si128((__m128i *)&src_ptr[i * src_stride + j]);
+        const __m128i data2 =
+            _mm_loadu_si128((__m128i *)&src_ptr[i * src_stride + j + 8]);
+
+        // Filter even-index pixels
+        const __m128i res_0 = _mm_madd_epi16(data, coeff_01);
+        const __m128i res_2 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 4), coeff_23);
+        const __m128i res_4 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 8), coeff_45);
+        const __m128i res_6 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 12), coeff_67);
+
+        __m128i res_even = _mm_add_epi32(_mm_add_epi32(res_0, res_4),
+                                         _mm_add_epi32(res_2, res_6));
+        res_even =
+            _mm_sra_epi32(_mm_add_epi32(res_even, round_const), round_shift);
+
+        // Filter odd-index pixels
+        const __m128i res_1 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 2), coeff_01);
+        const __m128i res_3 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 6), coeff_23);
+        const __m128i res_5 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 10), coeff_45);
+        const __m128i res_7 =
+            _mm_madd_epi16(_mm_alignr_epi8(data2, data, 14), coeff_67);
+
+        __m128i res_odd = _mm_add_epi32(_mm_add_epi32(res_1, res_5),
+                                        _mm_add_epi32(res_3, res_7));
+        res_odd =
+            _mm_sra_epi32(_mm_add_epi32(res_odd, round_const), round_shift);
+
+        // Pack in the column order 0, 2, 4, 6, 1, 3, 5, 7
+        __m128i res = _mm_packs_epi32(res_even, res_odd);
+        _mm_storeu_si128((__m128i *)&im_block[i * im_stride + j], res);
+      }
+    }
+  }
+
+  /* Vertical filter */
+  {
+    const int16_t *y_filter = av1_get_interp_filter_subpel_kernel(
+        *filter_params_y, subpel_y_q4 & SUBPEL_MASK);
+    const __m128i coeffs_y = _mm_loadu_si128((__m128i *)y_filter);
+
+    // coeffs 0 1 0 1 2 3 2 3
+    const __m128i tmp_0 = _mm_unpacklo_epi32(coeffs_y, coeffs_y);
+    // coeffs 4 5 4 5 6 7 6 7
+    const __m128i tmp_1 = _mm_unpackhi_epi32(coeffs_y, coeffs_y);
+
+    // coeffs 0 1 0 1 0 1 0 1
+    const __m128i coeff_01 = _mm_unpacklo_epi64(tmp_0, tmp_0);
+    // coeffs 2 3 2 3 2 3 2 3
+    const __m128i coeff_23 = _mm_unpackhi_epi64(tmp_0, tmp_0);
+    // coeffs 4 5 4 5 4 5 4 5
+    const __m128i coeff_45 = _mm_unpacklo_epi64(tmp_1, tmp_1);
+    // coeffs 6 7 6 7 6 7 6 7
+    const __m128i coeff_67 = _mm_unpackhi_epi64(tmp_1, tmp_1);
+
+    const __m128i round_const = _mm_set1_epi32(
+        ((1 << conv_params->round_1) >> 1) -
+        (1 << (bd + 2 * FILTER_BITS - conv_params->round_0 - 1)));
+    const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_1);
+
+    for (i = 0; i < h; ++i) {
+      for (j = 0; j < w; j += 8) {
+        // Filter even-index pixels
+        const int16_t *data = &im_block[i * im_stride + j];
+        const __m128i src_0 =
+            _mm_unpacklo_epi16(*(__m128i *)(data + 0 * im_stride),
+                               *(__m128i *)(data + 1 * im_stride));
+        const __m128i src_2 =
+            _mm_unpacklo_epi16(*(__m128i *)(data + 2 * im_stride),
+                               *(__m128i *)(data + 3 * im_stride));
+        const __m128i src_4 =
+            _mm_unpacklo_epi16(*(__m128i *)(data + 4 * im_stride),
+                               *(__m128i *)(data + 5 * im_stride));
+        const __m128i src_6 =
+            _mm_unpacklo_epi16(*(__m128i *)(data + 6 * im_stride),
+                               *(__m128i *)(data + 7 * im_stride));
+
+        const __m128i res_0 = _mm_madd_epi16(src_0, coeff_01);
+        const __m128i res_2 = _mm_madd_epi16(src_2, coeff_23);
+        const __m128i res_4 = _mm_madd_epi16(src_4, coeff_45);
+        const __m128i res_6 = _mm_madd_epi16(src_6, coeff_67);
+
+        const __m128i res_even = _mm_add_epi32(_mm_add_epi32(res_0, res_2),
+                                               _mm_add_epi32(res_4, res_6));
+
+        // Filter odd-index pixels
+        const __m128i src_1 =
+            _mm_unpackhi_epi16(*(__m128i *)(data + 0 * im_stride),
+                               *(__m128i *)(data + 1 * im_stride));
+        const __m128i src_3 =
+            _mm_unpackhi_epi16(*(__m128i *)(data + 2 * im_stride),
+                               *(__m128i *)(data + 3 * im_stride));
+        const __m128i src_5 =
+            _mm_unpackhi_epi16(*(__m128i *)(data + 4 * im_stride),
+                               *(__m128i *)(data + 5 * im_stride));
+        const __m128i src_7 =
+            _mm_unpackhi_epi16(*(__m128i *)(data + 6 * im_stride),
+                               *(__m128i *)(data + 7 * im_stride));
+
+        const __m128i res_1 = _mm_madd_epi16(src_1, coeff_01);
+        const __m128i res_3 = _mm_madd_epi16(src_3, coeff_23);
+        const __m128i res_5 = _mm_madd_epi16(src_5, coeff_45);
+        const __m128i res_7 = _mm_madd_epi16(src_7, coeff_67);
+
+        const __m128i res_odd = _mm_add_epi32(_mm_add_epi32(res_1, res_3),
+                                              _mm_add_epi32(res_5, res_7));
+
+        // Rearrange pixels back into the order 0 ... 7
+        const __m128i res_lo = _mm_unpacklo_epi32(res_even, res_odd);
+        const __m128i res_hi = _mm_unpackhi_epi32(res_even, res_odd);
+
+        const __m128i res_lo_round =
+            _mm_sra_epi32(_mm_add_epi32(res_lo, round_const), round_shift);
+        const __m128i res_hi_round =
+            _mm_sra_epi32(_mm_add_epi32(res_hi, round_const), round_shift);
+
+        // Accumulate values into the destination buffer
+        __m128i *const p = (__m128i *)&dst[i * dst_stride + j];
+        _mm_storeu_si128(p, _mm_add_epi32(_mm_loadu_si128(p), res_lo_round));
+        _mm_storeu_si128(p + 1,
+                         _mm_add_epi32(_mm_loadu_si128(p + 1), res_hi_round));
+      }
+    }
+  }
+}
+#endif
--- a/third_party/aom/av1/common/x86/highbd_warp_plane_ssse3.c
+++ b/third_party/aom/av1/common/x86/highbd_warp_plane_ssse3.c
@@ -14,18 +14,19 @@
 #include "./av1_rtcd.h"
 #include "av1/common/warped_motion.h"
 
 void av1_highbd_warp_affine_ssse3(const int32_t *mat, const uint16_t *ref,
                                   int width, int height, int stride,
                                   uint16_t *pred, int p_col, int p_row,
                                   int p_width, int p_height, int p_stride,
                                   int subsampling_x, int subsampling_y, int bd,
-                                  int comp_avg, int16_t alpha, int16_t beta,
-                                  int16_t gamma, int16_t delta) {
+                                  ConvolveParams *conv_params, int16_t alpha,
+                                  int16_t beta, int16_t gamma, int16_t delta) {
+  int comp_avg = conv_params->do_average;
 #if HORSHEAR_REDUCE_PREC_BITS >= 5
   __m128i tmp[15];
 #else
 #error "HORSHEAR_REDUCE_PREC_BITS < 5 not currently supported by SSSE3 filter"
 #endif
   int i, j, k;
 
   /* Note: For this code to work, the left/right frame borders need to be
--- a/third_party/aom/av1/common/x86/hybrid_inv_txfm_avx2.c
+++ b/third_party/aom/av1/common/x86/hybrid_inv_txfm_avx2.c
@@ -9,16 +9,17 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #include <immintrin.h>  // avx2
 
 #include "./aom_config.h"
 #include "./av1_rtcd.h"
 
+#include "av1/common/idct.h"
 #include "aom_dsp/x86/inv_txfm_common_avx2.h"
 
 void av1_idct16_avx2(__m256i *in) {
   const __m256i cospi_p30_m02 = pair256_set_epi16(cospi_30_64, -cospi_2_64);
   const __m256i cospi_p02_p30 = pair256_set_epi16(cospi_2_64, cospi_30_64);
   const __m256i cospi_p14_m18 = pair256_set_epi16(cospi_14_64, -cospi_18_64);
   const __m256i cospi_p18_p14 = pair256_set_epi16(cospi_18_64, cospi_14_64);
   const __m256i cospi_p22_m10 = pair256_set_epi16(cospi_22_64, -cospi_10_64);
@@ -359,18 +360,20 @@ static void flip_col(uint8_t **dest, int
 
 static void iidtx16(__m256i *in) {
   mm256_transpose_16x16(in, in);
   txfm_scaling16_avx2((int16_t)Sqrt2, in);
 }
 #endif
 
 void av1_iht16x16_256_add_avx2(const tran_low_t *input, uint8_t *dest,
-                               int stride, int tx_type) {
+                               int stride,
+                               const INV_TXFM_PARAM *inv_txfm_param) {
   __m256i in[16];
+  int tx_type = inv_txfm_param->tx_type;
 
   load_buffer_16x16(input, in);
   switch (tx_type) {
     case DCT_DCT:
       idct16(in);
       idct16(in);
       break;
     case ADST_DCT:
--- a/third_party/aom/av1/common/x86/idct_intrin_sse2.c
+++ b/third_party/aom/av1/common/x86/idct_intrin_sse2.c
@@ -10,16 +10,17 @@
  */
 
 #include "./av1_rtcd.h"
 #include "aom_dsp/x86/inv_txfm_sse2.h"
 #include "aom_dsp/x86/synonyms.h"
 #include "aom_dsp/x86/txfm_common_sse2.h"
 #include "aom_ports/mem.h"
 #include "av1/common/enums.h"
+#include "av1/common/idct.h"
 
 #if CONFIG_EXT_TX
 static INLINE void fliplr_4x4(__m128i *in /*in[2]*/) {
   in[0] = _mm_shufflelo_epi16(in[0], 0x1b);
   in[0] = _mm_shufflehi_epi16(in[0], 0x1b);
   in[1] = _mm_shufflelo_epi16(in[1], 0x1b);
   in[1] = _mm_shufflehi_epi16(in[1], 0x1b);
 }
@@ -54,20 +55,21 @@ static INLINE void fliplr_16x8(__m128i *
 #define FLIPUD_PTR(dest, stride, size)       \
   do {                                       \
     (dest) = (dest) + ((size)-1) * (stride); \
     (stride) = -(stride);                    \
   } while (0)
 #endif
 
 void av1_iht4x4_16_add_sse2(const tran_low_t *input, uint8_t *dest, int stride,
-                            int tx_type) {
+                            const INV_TXFM_PARAM *inv_txfm_param) {
   __m128i in[2];
   const __m128i zero = _mm_setzero_si128();
   const __m128i eight = _mm_set1_epi16(8);
+  int tx_type = inv_txfm_param->tx_type;
 
   in[0] = load_input_data(input);
   in[1] = load_input_data(input + 8);
 
   switch (tx_type) {
     case DCT_DCT:
       aom_idct4_sse2(in);
       aom_idct4_sse2(in);
@@ -145,20 +147,21 @@ void av1_iht4x4_16_add_sse2(const tran_l
     *(int *)(dest + stride * 2) = _mm_cvtsi128_si32(d0);
     // store result[3]
     d0 = _mm_srli_si128(d0, 4);
     *(int *)(dest + stride * 3) = _mm_cvtsi128_si32(d0);
   }
 }
 
 void av1_iht8x8_64_add_sse2(const tran_low_t *input, uint8_t *dest, int stride,
-                            int tx_type) {
+                            const INV_TXFM_PARAM *inv_txfm_param) {
   __m128i in[8];
   const __m128i zero = _mm_setzero_si128();
   const __m128i final_rounding = _mm_set1_epi16(1 << 4);
+  int tx_type = inv_txfm_param->tx_type;
 
   // load input data
   in[0] = load_input_data(input);
   in[1] = load_input_data(input + 8 * 1);
   in[2] = load_input_data(input + 8 * 2);
   in[3] = load_input_data(input + 8 * 3);
   in[4] = load_input_data(input + 8 * 4);
   in[5] = load_input_data(input + 8 * 5);
@@ -246,20 +249,22 @@ void av1_iht8x8_64_add_sse2(const tran_l
 static void iidtx16_sse2(__m128i *in0, __m128i *in1) {
   array_transpose_16x16(in0, in1);
   idtx16_8col(in0);
   idtx16_8col(in1);
 }
 #endif  // CONFIG_EXT_TX
 
 void av1_iht16x16_256_add_sse2(const tran_low_t *input, uint8_t *dest,
-                               int stride, int tx_type) {
+                               int stride,
+                               const INV_TXFM_PARAM *inv_txfm_param) {
   __m128i in[32];
   __m128i *in0 = &in[0];
   __m128i *in1 = &in[16];
+  int tx_type = inv_txfm_param->tx_type;
 
   load_buffer_8x16(input, in0);
   input += 8;
   load_buffer_8x16(input, in1);
 
   switch (tx_type) {
     case DCT_DCT:
       aom_idct16_sse2(in0, in1);
@@ -383,18 +388,20 @@ static INLINE void flip_buffer_lr_8x8(__
   in[4] = mm_reverse_epi16(in[4]);
   in[5] = mm_reverse_epi16(in[5]);
   in[6] = mm_reverse_epi16(in[6]);
   in[7] = mm_reverse_epi16(in[7]);
 }
 #endif  // CONFIG_EXT_TX
 
 void av1_iht8x16_128_add_sse2(const tran_low_t *input, uint8_t *dest,
-                              int stride, int tx_type) {
+                              int stride,
+                              const INV_TXFM_PARAM *inv_txfm_param) {
   __m128i in[16];
+  int tx_type = inv_txfm_param->tx_type;
 
   in[0] = load_input_data(input + 0 * 8);
   in[1] = load_input_data(input + 1 * 8);
   in[2] = load_input_data(input + 2 * 8);
   in[3] = load_input_data(input + 3 * 8);
   in[4] = load_input_data(input + 4 * 8);
   in[5] = load_input_data(input + 5 * 8);
   in[6] = load_input_data(input + 6 * 8);
@@ -548,18 +555,20 @@ static INLINE void write_buffer_8x8_roun
   RECON_AND_STORE(dest + 3 * stride, in[3]);
   RECON_AND_STORE(dest + 4 * stride, in[4]);
   RECON_AND_STORE(dest + 5 * stride, in[5]);
   RECON_AND_STORE(dest + 6 * stride, in[6]);
   RECON_AND_STORE(dest + 7 * stride, in[7]);
 }
 
 void av1_iht16x8_128_add_sse2(const tran_low_t *input, uint8_t *dest,
-                              int stride, int tx_type) {
+                              int stride,
+                              const INV_TXFM_PARAM *inv_txfm_param) {
   __m128i in[16];
+  int tx_type = inv_txfm_param->tx_type;
 
   // Transpose 16x8 input into in[]
   in[0] = load_input_data(input + 0 * 16);
   in[1] = load_input_data(input + 1 * 16);
   in[2] = load_input_data(input + 2 * 16);
   in[3] = load_input_data(input + 3 * 16);
   in[4] = load_input_data(input + 4 * 16);
   in[5] = load_input_data(input + 5 * 16);
@@ -708,18 +717,19 @@ static INLINE void write_buffer_8x4_roun
 
   RECON_AND_STORE(dest + 0 * stride, in[0]);
   RECON_AND_STORE(dest + 1 * stride, in[1]);
   RECON_AND_STORE(dest + 2 * stride, in[2]);
   RECON_AND_STORE(dest + 3 * stride, in[3]);
 }
 
 void av1_iht8x4_32_add_sse2(const tran_low_t *input, uint8_t *dest, int stride,
-                            int tx_type) {
+                            const INV_TXFM_PARAM *inv_txfm_param) {
   __m128i in[8];
+  int tx_type = inv_txfm_param->tx_type;
 
   in[0] = load_input_data(input + 0 * 8);
   in[1] = load_input_data(input + 1 * 8);
   in[2] = load_input_data(input + 2 * 8);
   in[3] = load_input_data(input + 3 * 8);
 
   // Row transform
   switch (tx_type) {
@@ -892,18 +902,19 @@ static INLINE void write_buffer_4x8_roun
     d0 = _mm_srli_si128(d0, 4);
     *(int *)(dest + stride * 6) = _mm_cvtsi128_si32(d0);
     d0 = _mm_srli_si128(d0, 4);
     *(int *)(dest + stride * 7) = _mm_cvtsi128_si32(d0);
   }
 }
 
 void av1_iht4x8_32_add_sse2(const tran_low_t *input, uint8_t *dest, int stride,
-                            int tx_type) {
+                            const INV_TXFM_PARAM *inv_txfm_param) {
   __m128i in[8];
+  int tx_type = inv_txfm_param->tx_type;
 
   // Load rows, packed two per element of 'in'.
   // We pack into the bottom half of 'in' so that the
   // later repacking stage can pack into the
   // top half without overwriting anything
   in[4] = load_input_data(input + 0 * 8);
   in[5] = load_input_data(input + 1 * 8);
   in[6] = load_input_data(input + 2 * 8);
@@ -1114,18 +1125,20 @@ static INLINE void write_buffer_16x32_ro
     RECON_AND_STORE(dest + i * stride + 0, intl[i]);
     RECON_AND_STORE(dest + i * stride + 8, intr[i]);
     RECON_AND_STORE(dest + (i + 16) * stride + 0, inbl[i]);
     RECON_AND_STORE(dest + (i + 16) * stride + 8, inbr[i]);
   }
 }
 
 void av1_iht16x32_512_add_sse2(const tran_low_t *input, uint8_t *dest,
-                               int stride, int tx_type) {
+                               int stride,
+                               const INV_TXFM_PARAM *inv_txfm_param) {
   __m128i intl[16], intr[16], inbl[16], inbr[16];
+  int tx_type = inv_txfm_param->tx_type;
 
   int i;
   for (i = 0; i < 16; ++i) {
     intl[i] = load_input_data(input + i * 16 + 0);
     intr[i] = load_input_data(input + i * 16 + 8);
     inbl[i] = load_input_data(input + (i + 16) * 16 + 0);
     inbr[i] = load_input_data(input + (i + 16) * 16 + 8);
   }
@@ -1267,18 +1280,20 @@ static INLINE void write_buffer_32x16_ro
     RECON_AND_STORE(dest + i * stride + 0, in0[i]);
     RECON_AND_STORE(dest + i * stride + 8, in1[i]);
     RECON_AND_STORE(dest + i * stride + 16, in2[i]);
     RECON_AND_STORE(dest + i * stride + 24, in3[i]);
   }
 }
 
 void av1_iht32x16_512_add_sse2(const tran_low_t *input, uint8_t *dest,
-                               int stride, int tx_type) {
+                               int stride,
+                               const INV_TXFM_PARAM *inv_txfm_param) {
   __m128i in0[16], in1[16], in2[16], in3[16];
+  int tx_type = inv_txfm_param->tx_type;
   int i;
 
   for (i = 0; i < 16; ++i) {
     in0[i] = load_input_data(input + i * 32 + 0);
     in1[i] = load_input_data(input + i * 32 + 8);
     in2[i] = load_input_data(input + i * 32 + 16);
     in3[i] = load_input_data(input + i * 32 + 24);
   }
--- a/third_party/aom/av1/common/x86/selfguided_sse4.c
+++ b/third_party/aom/av1/common/x86/selfguided_sse4.c
@@ -11,18 +11,18 @@
 static void calc_block(__m128i sum, __m128i sum_sq, __m128i n,
                        __m128i one_over_n, __m128i s, int bit_depth, int idx,
                        int32_t *A, int32_t *B) {
   __m128i a, b, p;
 #if CONFIG_HIGHBITDEPTH
   if (bit_depth > 8) {
     __m128i rounding_a = _mm_set1_epi32((1 << (2 * (bit_depth - 8))) >> 1);
     __m128i rounding_b = _mm_set1_epi32((1 << (bit_depth - 8)) >> 1);
-    __m128i shift_a = _mm_set_epi64x(0, 2 * (bit_depth - 8));
-    __m128i shift_b = _mm_set_epi64x(0, bit_depth - 8);
+    __m128i shift_a = _mm_cvtsi32_si128(2 * (bit_depth - 8));
+    __m128i shift_b = _mm_cvtsi32_si128(bit_depth - 8);
     a = _mm_srl_epi32(_mm_add_epi32(sum_sq, rounding_a), shift_a);
     b = _mm_srl_epi32(_mm_add_epi32(sum, rounding_b), shift_b);
     a = _mm_mullo_epi32(a, n);
     b = _mm_mullo_epi32(b, b);
     p = _mm_sub_epi32(_mm_max_epi32(a, b), b);
   } else {
 #endif
     (void)bit_depth;
--- a/third_party/aom/av1/common/x86/warp_plane_sse2.c
+++ b/third_party/aom/av1/common/x86/warp_plane_sse2.c
@@ -12,19 +12,20 @@
 #include <emmintrin.h>
 
 #include "./av1_rtcd.h"
 #include "av1/common/warped_motion.h"
 
 void av1_warp_affine_sse2(const int32_t *mat, const uint8_t *ref, int width,
                           int height, int stride, uint8_t *pred, int p_col,
                           int p_row, int p_width, int p_height, int p_stride,
-                          int subsampling_x, int subsampling_y, int comp_avg,
-                          int16_t alpha, int16_t beta, int16_t gamma,
-                          int16_t delta) {
+                          int subsampling_x, int subsampling_y,
+                          ConvolveParams *conv_params, int16_t alpha,
+                          int16_t beta, int16_t gamma, int16_t delta) {
+  int comp_avg = conv_params->do_average;
   __m128i tmp[15];
   int i, j, k;
   const int bd = 8;
 
   /* Note: For this code to work, the left/right frame borders need to be
      extended by at least 13 pixels each. By the time we get here, other
      code will have set up this border, but we allow an explicit check
      for debugging purposes.
--- a/third_party/aom/av1/common/x86/warp_plane_ssse3.c
+++ b/third_party/aom/av1/common/x86/warp_plane_ssse3.c
@@ -199,19 +199,20 @@ DECLARE_ALIGNED(8, static const int8_t,
 static const uint8_t even_mask[16] = { 0, 2,  2,  4,  4,  6,  6,  8,
                                        8, 10, 10, 12, 12, 14, 14, 0 };
 static const uint8_t odd_mask[16] = { 1, 3,  3,  5,  5,  7,  7,  9,
                                       9, 11, 11, 13, 13, 15, 15, 0 };
 
 void av1_warp_affine_ssse3(const int32_t *mat, const uint8_t *ref, int width,
                            int height, int stride, uint8_t *pred, int p_col,
                            int p_row, int p_width, int p_height, int p_stride,
-                           int subsampling_x, int subsampling_y, int comp_avg,
-                           int16_t alpha, int16_t beta, int16_t gamma,
-                           int16_t delta) {
+                           int subsampling_x, int subsampling_y,
+                           ConvolveParams *conv_params, int16_t alpha,
+                           int16_t beta, int16_t gamma, int16_t delta) {
+  int comp_avg = conv_params->do_average;
   __m128i tmp[15];
   int i, j, k;
   const int bd = 8;
 
   /* Note: For this code to work, the left/right frame borders need to be
      extended by at least 13 pixels each. By the time we get here, other
      code will have set up this border, but we allow an explicit check
      for debugging purposes.
--- a/third_party/aom/av1/decoder/decodeframe.c
+++ b/third_party/aom/av1/decoder/decodeframe.c
@@ -44,16 +44,19 @@
 #include "av1/common/entropy.h"
 #include "av1/common/entropymode.h"
 #include "av1/common/entropymv.h"
 #include "av1/common/idct.h"
 #include "av1/common/pred_common.h"
 #include "av1/common/quant_common.h"
 #include "av1/common/reconinter.h"
 #include "av1/common/reconintra.h"
+#if CONFIG_FRAME_SUPERRES
+#include "av1/common/resize.h"
+#endif  // CONFIG_FRAME_SUPERRES
 #include "av1/common/seg_common.h"
 #include "av1/common/thread_common.h"
 #include "av1/common/tile_common.h"
 
 #include "av1/decoder/decodeframe.h"
 #include "av1/decoder/decodemv.h"
 #include "av1/decoder/decoder.h"
 #if CONFIG_LV_MAP
@@ -87,26 +90,26 @@ static struct aom_read_bit_buffer *init_
     AV1Decoder *pbi, struct aom_read_bit_buffer *rb, const uint8_t *data,
     const uint8_t *data_end, uint8_t clear_data[MAX_AV1_HEADER_SIZE]);
 static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
                                   size_t partition_size);
 static size_t read_uncompressed_header(AV1Decoder *pbi,
                                        struct aom_read_bit_buffer *rb);
 
 static int is_compound_reference_allowed(const AV1_COMMON *cm) {
-#if CONFIG_ONE_SIDED_COMPOUND  // Normative in decoder
+#if CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS  // Normative in decoder
   return !frame_is_intra_only(cm);
 #else
   int i;
   if (frame_is_intra_only(cm)) return 0;
   for (i = 1; i < INTER_REFS_PER_FRAME; ++i)
     if (cm->ref_frame_sign_bias[i + 1] != cm->ref_frame_sign_bias[1]) return 1;
 
   return 0;
-#endif
+#endif  // CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS
 }
 
 static void setup_compound_reference_mode(AV1_COMMON *cm) {
 #if CONFIG_EXT_REFS
   cm->comp_fwd_ref[0] = LAST_FRAME;
   cm->comp_fwd_ref[1] = LAST2_FRAME;
   cm->comp_fwd_ref[2] = LAST3_FRAME;
   cm->comp_fwd_ref[3] = GOLDEN_FRAME;
@@ -136,42 +139,33 @@ static int read_is_valid(const uint8_t *
   return len != 0 && len <= (size_t)(end - start);
 }
 
 static int decode_unsigned_max(struct aom_read_bit_buffer *rb, int max) {
   const int data = aom_rb_read_literal(rb, get_unsigned_bits(max));
   return data > max ? max : data;
 }
 
-static TX_MODE read_tx_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
-                            struct aom_read_bit_buffer *rb) {
-  int i, all_lossless = 1;
+static TX_MODE read_tx_mode(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
 #if CONFIG_TX64X64
   TX_MODE tx_mode;
 #endif
-
-  if (cm->seg.enabled) {
-    for (i = 0; i < MAX_SEGMENTS; ++i) {
-      if (!xd->lossless[i]) {
-        all_lossless = 0;
-        break;
-      }
-    }
-  } else {
-    all_lossless = xd->lossless[0];
-  }
-
-  if (all_lossless) return ONLY_4X4;
+  if (cm->all_lossless) return ONLY_4X4;
+#if CONFIG_VAR_TX_NO_TX_MODE
+  (void)rb;
+  return TX_MODE_SELECT;
+#else
 #if CONFIG_TX64X64
   tx_mode = aom_rb_read_bit(rb) ? TX_MODE_SELECT : aom_rb_read_literal(rb, 2);
   if (tx_mode == ALLOW_32X32) tx_mode += aom_rb_read_bit(rb);
   return tx_mode;
 #else
   return aom_rb_read_bit(rb) ? TX_MODE_SELECT : aom_rb_read_literal(rb, 2);
 #endif  // CONFIG_TX64X64
+#endif  // CONFIG_VAR_TX_NO_TX_MODE
 }
 
 #if !CONFIG_EC_ADAPT
 static void read_tx_size_probs(FRAME_CONTEXT *fc, aom_reader *r) {
   int i, j, k;
   for (i = 0; i < MAX_TX_DEPTH; ++i)
     for (j = 0; j < TX_SIZE_CONTEXTS; ++j)
       for (k = 0; k < i + 1; ++k)
@@ -184,40 +178,60 @@ static void read_switchable_interp_probs
   int i, j;
   for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j) {
     for (i = 0; i < SWITCHABLE_FILTERS - 1; ++i)
       av1_diff_update_prob(r, &fc->switchable_interp_prob[j][i], ACCT_STR);
   }
 }
 #endif
 
+#if !CONFIG_NEW_MULTISYMBOL
 static void read_inter_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) {
   int i;
   for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i)
     av1_diff_update_prob(r, &fc->newmv_prob[i], ACCT_STR);
   for (i = 0; i < ZEROMV_MODE_CONTEXTS; ++i)
     av1_diff_update_prob(r, &fc->zeromv_prob[i], ACCT_STR);
   for (i = 0; i < REFMV_MODE_CONTEXTS; ++i)
     av1_diff_update_prob(r, &fc->refmv_prob[i], ACCT_STR);
   for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
     av1_diff_update_prob(r, &fc->drl_prob[i], ACCT_STR);
 }
+#endif
 
 #if CONFIG_EXT_INTER
+#if !CONFIG_EC_ADAPT
 static void read_inter_compound_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) {
   int i, j;
   if (aom_read(r, GROUP_DIFF_UPDATE_PROB, ACCT_STR)) {
     for (j = 0; j < INTER_MODE_CONTEXTS; ++j) {
       for (i = 0; i < INTER_COMPOUND_MODES - 1; ++i) {
         av1_diff_update_prob(r, &fc->inter_compound_mode_probs[j][i], ACCT_STR);
       }
     }
   }
 }
+#endif  // CONFIG_EC_ADAPT
+
+#if CONFIG_COMPOUND_SINGLEREF
+static void read_inter_singleref_comp_mode_probs(FRAME_CONTEXT *fc,
+                                                 aom_reader *r) {
+  int i, j;
+  if (aom_read(r, GROUP_DIFF_UPDATE_PROB, ACCT_STR)) {
+    for (j = 0; j < INTER_MODE_CONTEXTS; ++j) {
+      for (i = 0; i < INTER_SINGLEREF_COMP_MODES - 1; ++i) {
+        av1_diff_update_prob(r, &fc->inter_singleref_comp_mode_probs[j][i],
+                             ACCT_STR);
+      }
+    }
+  }
+}
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #endif  // CONFIG_EXT_INTER
+
 #if !CONFIG_EC_ADAPT
 #if !CONFIG_EXT_TX
 static void read_ext_tx_probs(FRAME_CONTEXT *fc, aom_reader *r) {
   int i, j, k;
   if (aom_read(r, GROUP_DIFF_UPDATE_PROB, ACCT_STR)) {
     for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
       for (j = 0; j < TX_TYPES; ++j) {
         for (k = 0; k < TX_TYPES - 1; ++k)
@@ -246,43 +260,64 @@ static REFERENCE_MODE read_frame_referen
                : (aom_rb_read_bit(rb) ? COMPOUND_REFERENCE : SINGLE_REFERENCE);
 #endif  // CONFIG_REF_ADAPT
   } else {
     return SINGLE_REFERENCE;
   }
 }
 
 static void read_frame_reference_mode_probs(AV1_COMMON *cm, aom_reader *r) {
+#if CONFIG_NEW_MULTISYMBOL && !CONFIG_EXT_COMP_REFS
+  (void)r;
+#else
   FRAME_CONTEXT *const fc = cm->fc;
-  int i, j;
-
+  int i;
+#endif
+
+#if !CONFIG_NEW_MULTISYMBOL
   if (cm->reference_mode == REFERENCE_MODE_SELECT)
     for (i = 0; i < COMP_INTER_CONTEXTS; ++i)
       av1_diff_update_prob(r, &fc->comp_inter_prob[i], ACCT_STR);
 
   if (cm->reference_mode != COMPOUND_REFERENCE) {
     for (i = 0; i < REF_CONTEXTS; ++i) {
+      int j;
       for (j = 0; j < (SINGLE_REFS - 1); ++j) {
         av1_diff_update_prob(r, &fc->single_ref_prob[i][j], ACCT_STR);
       }
     }
   }
+#endif
 
   if (cm->reference_mode != SINGLE_REFERENCE) {
+#if CONFIG_EXT_COMP_REFS
+    for (i = 0; i < COMP_REF_TYPE_CONTEXTS; ++i)
+      av1_diff_update_prob(r, &fc->comp_ref_type_prob[i], ACCT_STR);
+
+    for (i = 0; i < UNI_COMP_REF_CONTEXTS; ++i) {
+      int j;
+      for (j = 0; j < (UNIDIR_COMP_REFS - 1); ++j)
+        av1_diff_update_prob(r, &fc->uni_comp_ref_prob[i][j], ACCT_STR);
+    }
+#endif  // CONFIG_EXT_COMP_REFS
+
+#if !CONFIG_NEW_MULTISYMBOL
     for (i = 0; i < REF_CONTEXTS; ++i) {
+      int j;
 #if CONFIG_EXT_REFS
       for (j = 0; j < (FWD_REFS - 1); ++j)
         av1_diff_update_prob(r, &fc->comp_ref_prob[i][j], ACCT_STR);
       for (j = 0; j < (BWD_REFS - 1); ++j)
         av1_diff_update_prob(r, &fc->comp_bwdref_prob[i][j], ACCT_STR);
 #else
       for (j = 0; j < (COMP_REFS - 1); ++j)
         av1_diff_update_prob(r, &fc->comp_ref_prob[i][j], ACCT_STR);
 #endif  // CONFIG_EXT_REFS
     }
+#endif  // CONFIG_NEW_MULTISYMBOL
   }
 }
 
 static void update_mv_probs(aom_prob *p, int n, aom_reader *r) {
   int i;
   for (i = 0; i < n; ++i) av1_diff_update_prob(r, &p[i], ACCT_STR);
 }
 
@@ -314,22 +349,29 @@ static void read_mv_probs(nmv_context *c
       nmv_component *const comp_ctx = &ctx->comps[i];
       update_mv_probs(&comp_ctx->class0_hp, 1, r);
       update_mv_probs(&comp_ctx->hp, 1, r);
     }
   }
 }
 
 static void inverse_transform_block(MACROBLOCKD *xd, int plane,
+#if CONFIG_LGT
+                                    PREDICTION_MODE mode,
+#endif
                                     const TX_TYPE tx_type,
                                     const TX_SIZE tx_size, uint8_t *dst,
                                     int stride, int16_t scan_line, int eob) {
   struct macroblockd_plane *const pd = &xd->plane[plane];
   tran_low_t *const dqcoeff = pd->dqcoeff;
-  av1_inverse_transform_block(xd, dqcoeff, tx_type, tx_size, dst, stride, eob);
+  av1_inverse_transform_block(xd, dqcoeff,
+#if CONFIG_LGT
+                              mode,
+#endif
+                              tx_type, tx_size, dst, stride, eob);
   memset(dqcoeff, 0, (scan_line + 1) * sizeof(dqcoeff[0]));
 }
 
 #if CONFIG_PVQ
 static int av1_pvq_decode_helper(MACROBLOCKD *xd, tran_low_t *ref_coeff,
                                  tran_low_t *dqcoeff, int16_t *quant, int pli,
                                  int bs, TX_TYPE tx_type, int xdec,
                                  PVQ_SKIP_TYPE ac_dc_coded) {
@@ -468,16 +510,21 @@ static int av1_pvq_decode_helper2(AV1_CO
           pred[diff_stride * j + i] = dst[pd->dst.stride * j + i];
 #if CONFIG_HIGHBITDEPTH
     }
 #endif
 
     fwd_txfm_param.tx_type = tx_type;
     fwd_txfm_param.tx_size = tx_size;
     fwd_txfm_param.lossless = xd->lossless[seg_id];
+#if CONFIG_LGT
+    fwd_txfm_param.is_inter = is_inter_block(mbmi);
+    fwd_txfm_param.dst = dst;
+    fwd_txfm_param.mode = get_prediction_mode(xd->mi[0], plane, tx_size, block);
+#endif
 
 #if CONFIG_HIGHBITDEPTH
     if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
       fwd_txfm_param.bd = xd->bd;
       av1_highbd_fwd_txfm(pred, pvq_ref_coeff, diff_stride, &fwd_txfm_param);
     } else {
 #endif  // CONFIG_HIGHBITDEPTH
       av1_fwd_txfm(pred, pvq_ref_coeff, diff_stride, &fwd_txfm_param);
@@ -485,34 +532,36 @@ static int av1_pvq_decode_helper2(AV1_CO
     }
 #endif  // CONFIG_HIGHBITDEPTH
 
     quant = &pd->seg_dequant[seg_id][0];  // aom's quantizer
 
     eob = av1_pvq_decode_helper(xd, pvq_ref_coeff, dqcoeff, quant, plane,
                                 tx_size, tx_type, xdec, ac_dc_coded);
 
-    inverse_transform_block(xd, plane, tx_type, tx_size, dst, pd->dst.stride,
+    inverse_transform_block(xd, plane,
+#if CONFIG_LGT
+                            fwd_txfm_param.mode,
+#endif
+                            tx_type, tx_size, dst, pd->dst.stride,
                             max_scan_line, eob);
   }
 
   return eob;
 }
 #endif
 
 static int get_block_idx(const MACROBLOCKD *xd, int plane, int row, int col) {
   const int bsize = xd->mi[0]->mbmi.sb_type;
   const struct macroblockd_plane *pd = &xd->plane[plane];
-#if CONFIG_CB4X4
-#if CONFIG_CHROMA_2X2
-  const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
-#else
+#if CONFIG_CHROMA_SUB8X8
   const BLOCK_SIZE plane_bsize =
       AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
-#endif  // CONFIG_CHROMA_2X2
+#elif CONFIG_CB4X4
+  const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
 #else
   const BLOCK_SIZE plane_bsize =
       get_plane_block_size(AOMMAX(BLOCK_8X8, bsize), pd);
 #endif
   const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
   const TX_SIZE tx_size = get_tx_size(plane, xd);
   const uint8_t txh_unit = tx_size_high_unit[tx_size];
   return row * max_blocks_wide + col * txh_unit;
@@ -557,17 +606,17 @@ static void hbd_process_block_dpcm_vert(
                                         uint8_t *dst8, int dst_stride) {
   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
   const int tx1d_width = tx_size_wide[tx_size];
   const int tx1d_height = tx_size_high[tx_size];
   hbd_dpcm_inv_txfm_add_func inverse_tx =
       av1_get_hbd_dpcm_inv_txfm_add_func(tx1d_width);
   for (int r = 0; r < tx1d_height; ++r) {
     if (r > 0) memcpy(dst, dst - dst_stride, tx1d_width * sizeof(dst[0]));
-    inverse_tx(dqcoeff, 1, tx_type_1d, bd, dst);
+    inverse_tx(dqcoeff, 1, tx_type_1d, bd, dst, 1);
     dqcoeff += tx1d_width;
     dst += dst_stride;
   }
 }
 
 static void hbd_process_block_dpcm_horz(TX_SIZE tx_size, TX_TYPE_1D tx_type_1d,
                                         int bd, const tran_low_t *dqcoeff,
                                         uint8_t *dst8, int dst_stride) {
@@ -585,17 +634,17 @@ static void hbd_process_block_dpcm_horz(
     default: assert(0);
   }
 
   for (int c = 0; c < tx1d_width; ++c, ++dqcoeff, ++dst) {
     for (int r = 0; r < tx1d_height; ++r) {
       if (c > 0) dst[r * dst_stride] = dst[r * dst_stride - 1];
       tx_buff[r] = dqcoeff[r * tx1d_width];
     }
-    inverse_tx(tx_buff, dst_stride, tx_type_1d, bd, dst);
+    inverse_tx(tx_buff, dst_stride, tx_type_1d, bd, dst, 0);
   }
 }
 #endif  // CONFIG_HIGHBITDEPTH
 
 static void inverse_transform_block_dpcm(MACROBLOCKD *xd, int plane,
                                          PREDICTION_MODE mode, TX_SIZE tx_size,
                                          TX_TYPE tx_type, uint8_t *dst,
                                          int dst_stride, int16_t scan_line) {
@@ -657,120 +706,136 @@ static void predict_and_reconstruct_intr
 
   if (!mbmi->skip) {
 #if !CONFIG_PVQ
     struct macroblockd_plane *const pd = &xd->plane[plane];
 #if CONFIG_LV_MAP
     int16_t max_scan_line = 0;
     int eob;
     av1_read_coeffs_txb_facade(cm, xd, r, row, col, block_idx, plane,
-                               pd->dqcoeff, &max_scan_line, &eob);
+                               pd->dqcoeff, tx_size, &max_scan_line, &eob);
     // tx_type will be read out in av1_read_coeffs_txb_facade
     TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
 #else   // CONFIG_LV_MAP
     TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
-    const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 0);
+    const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi);
     int16_t max_scan_line = 0;
     const int eob =
         av1_decode_block_tokens(cm, xd, plane, scan_order, col, row, tx_size,
                                 tx_type, &max_scan_line, r, mbmi->segment_id);
 #endif  // CONFIG_LV_MAP
     if (eob) {
       uint8_t *dst =
           &pd->dst.buf[(row * pd->dst.stride + col) << tx_size_wide_log2[0]];
+#if CONFIG_DPCM_INTRA || CONFIG_LGT
+      const PREDICTION_MODE mode =
+          get_prediction_mode(xd->mi[0], plane, tx_size, block_idx);
 #if CONFIG_DPCM_INTRA
-      const int block_raster_idx =
-          av1_block_index_to_raster_order(tx_size, block_idx);
-      const PREDICTION_MODE mode = (plane == 0)
-                                       ? get_y_mode(xd->mi[0], block_raster_idx)
-                                       : mbmi->uv_mode;
       if (av1_use_dpcm_intra(plane, mode, tx_type, mbmi)) {
         inverse_transform_block_dpcm(xd, plane, mode, tx_size, tx_type, dst,
                                      pd->dst.stride, max_scan_line);
       } else {
 #endif  // CONFIG_DPCM_INTRA
-        inverse_transform_block(xd, plane, tx_type, tx_size, dst,
-                                pd->dst.stride, max_scan_line, eob);
+#endif  // CONFIG_DPCM_INTRA || CONFIG_LGT
+        inverse_transform_block(xd, plane,
+#if CONFIG_LGT
+                                mode,
+#endif
+                                tx_type, tx_size, dst, pd->dst.stride,
+                                max_scan_line, eob);
 #if CONFIG_DPCM_INTRA
       }
 #endif  // CONFIG_DPCM_INTRA
     }
-#else
+#else   // !CONFIG_PVQ
     TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
     av1_pvq_decode_helper2(cm, xd, mbmi, plane, row, col, tx_size, tx_type);
-#endif
+#endif  // !CONFIG_PVQ
   }
 #if CONFIG_CFL
   if (plane == AOM_PLANE_Y) {
     struct macroblockd_plane *const pd = &xd->plane[plane];
+#if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2
+    const BLOCK_SIZE plane_bsize =
+        AOMMAX(BLOCK_4X4, get_plane_block_size(mbmi->sb_type, pd));
+#else
+    const BLOCK_SIZE plane_bsize = get_plane_block_size(mbmi->sb_type, pd);
+#endif
     uint8_t *dst =
         &pd->dst.buf[(row * pd->dst.stride + col) << tx_size_wide_log2[0]];
-    cfl_store(xd->cfl, dst, pd->dst.stride, row, col, tx_size);
+    // TODO (ltrudeau) Store sub-8x8 inter blocks when bottom right block is
+    // intra predicted.
+    cfl_store(xd->cfl, dst, pd->dst.stride, row, col, tx_size, plane_bsize);
   }
 #endif
 }
 
 #if CONFIG_VAR_TX && !CONFIG_COEF_INTERLEAVE
 static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd,
                                   aom_reader *r, MB_MODE_INFO *const mbmi,
                                   int plane, BLOCK_SIZE plane_bsize,
-                                  int blk_row, int blk_col, TX_SIZE tx_size,
-                                  int *eob_total) {
+                                  int blk_row, int blk_col, int block,
+                                  TX_SIZE tx_size, int *eob_total) {
   const struct macroblockd_plane *const pd = &xd->plane[plane];
   const BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
   const int tx_row = blk_row >> (1 - pd->subsampling_y);
   const int tx_col = blk_col >> (1 - pd->subsampling_x);
   const TX_SIZE plane_tx_size =
       plane ? uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0]
             : mbmi->inter_tx_size[tx_row][tx_col];
   // Scale to match transform block unit.
   const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
   const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
 
   if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
 
   if (tx_size == plane_tx_size) {
     PLANE_TYPE plane_type = get_plane_type(plane);
-    int block_idx = get_block_idx(xd, plane, blk_row, blk_col);
 #if CONFIG_LV_MAP
     int16_t max_scan_line = 0;
     int eob;
-    av1_read_coeffs_txb_facade(cm, xd, r, blk_row, blk_col, block_idx, plane,
-                               pd->dqcoeff, &max_scan_line, &eob);
+    av1_read_coeffs_txb_facade(cm, xd, r, blk_row, blk_col, block, plane,
+                               pd->dqcoeff, tx_size, &max_scan_line, &eob);
     // tx_type will be read out in av1_read_coeffs_txb_facade
-    TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, plane_tx_size);
+    TX_TYPE tx_type = get_tx_type(plane_type, xd, block, plane_tx_size);
 #else   // CONFIG_LV_MAP
-    TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, plane_tx_size);
-    const SCAN_ORDER *sc = get_scan(cm, plane_tx_size, tx_type, 1);
+    TX_TYPE tx_type = get_tx_type(plane_type, xd, block, plane_tx_size);
+    const SCAN_ORDER *sc = get_scan(cm, plane_tx_size, tx_type, mbmi);
     int16_t max_scan_line = 0;
     const int eob = av1_decode_block_tokens(
         cm, xd, plane, sc, blk_col, blk_row, plane_tx_size, tx_type,
         &max_scan_line, r, mbmi->segment_id);
 #endif  // CONFIG_LV_MAP
-    inverse_transform_block(xd, plane, tx_type, plane_tx_size,
+    inverse_transform_block(xd, plane,
+#if CONFIG_LGT
+                            mbmi->mode,
+#endif
+                            tx_type, plane_tx_size,
                             &pd->dst.buf[(blk_row * pd->dst.stride + blk_col)
                                          << tx_size_wide_log2[0]],
                             pd->dst.stride, max_scan_line, eob);
     *eob_total += eob;
   } else {
     const TX_SIZE sub_txs = sub_tx_size_map[tx_size];
     const int bsl = tx_size_wide_unit[sub_txs];
+    int sub_step = tx_size_wide_unit[sub_txs] * tx_size_high_unit[sub_txs];
     assert(sub_txs < tx_size);
     int i;
 
     assert(bsl > 0);
 
     for (i = 0; i < 4; ++i) {
       const int offsetr = blk_row + (i >> 1) * bsl;
       const int offsetc = blk_col + (i & 0x01) * bsl;
 
       if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) continue;
 
       decode_reconstruct_tx(cm, xd, r, mbmi, plane, plane_bsize, offsetr,
-                            offsetc, sub_txs, eob_total);
+                            offsetc, block, sub_txs, eob_total);
+      block += sub_step;
     }
   }
 }
 #endif  // CONFIG_VAR_TX
 
 #if !CONFIG_VAR_TX || CONFIG_SUPERTX || CONFIG_COEF_INTERLEAVE || \
     (!CONFIG_VAR_TX && CONFIG_EXT_TX && CONFIG_RECT_TX)
 static int reconstruct_inter_block(AV1_COMMON *cm, MACROBLOCKD *const xd,
@@ -788,31 +853,36 @@ static int reconstruct_inter_block(AV1_C
 #endif
 
 #if !CONFIG_PVQ
 #if CONFIG_LV_MAP
   (void)segment_id;
   int16_t max_scan_line = 0;
   int eob;
   av1_read_coeffs_txb_facade(cm, xd, r, row, col, block_idx, plane, pd->dqcoeff,
-                             &max_scan_line, &eob);
+                             tx_size, &max_scan_line, &eob);
   // tx_type will be read out in av1_read_coeffs_txb_facade
   TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
 #else   // CONFIG_LV_MAP
   int16_t max_scan_line = 0;
   TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
-  const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 1);
+  const SCAN_ORDER *scan_order =
+      get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
   const int eob =
       av1_decode_block_tokens(cm, xd, plane, scan_order, col, row, tx_size,
                               tx_type, &max_scan_line, r, segment_id);
 #endif  // CONFIG_LV_MAP
   uint8_t *dst =
       &pd->dst.buf[(row * pd->dst.stride + col) << tx_size_wide_log2[0]];
   if (eob)
-    inverse_transform_block(xd, plane, tx_type, tx_size, dst, pd->dst.stride,
+    inverse_transform_block(xd, plane,
+#if CONFIG_LGT
+                            xd->mi[0]->mbmi.mode,
+#endif
+                            tx_type, tx_size, dst, pd->dst.stride,
                             max_scan_line, eob);
 #else
   TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
   eob = av1_pvq_decode_helper2(cm, xd, &xd->mi[0]->mbmi, plane, row, col,
                                tx_size, tx_type);
 #endif
   return eob;
 }
@@ -829,16 +899,20 @@ static void set_offsets(AV1_COMMON *cons
   xd->mi[0] = &cm->mi[offset];
   // TODO(slavarnway): Generate sb_type based on bwl and bhl, instead of
   // passing bsize from decode_partition().
   xd->mi[0]->mbmi.sb_type = bsize;
 #if CONFIG_RD_DEBUG
   xd->mi[0]->mbmi.mi_row = mi_row;
   xd->mi[0]->mbmi.mi_col = mi_col;
 #endif
+#if CONFIG_CFL
+  xd->cfl->mi_row = mi_row;
+  xd->cfl->mi_col = mi_col;
+#endif
   for (y = 0; y < y_mis; ++y)
     for (x = !y; x < x_mis; ++x) xd->mi[y * cm->mi_stride + x] = xd->mi[0];
 
   set_plane_n4(xd, bw, bh);
   set_skip_context(xd, mi_row, mi_col);
 
 #if CONFIG_VAR_TX
   xd->max_tx_size = max_txsize_lookup[bsize];
@@ -954,30 +1028,36 @@ static void set_param_topblock(AV1_COMMO
       xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK);
   set_txfm_ctxs(xd->mi[0]->mbmi.tx_size, bw, bh, skip, xd);
 #endif
 }
 
 static void set_ref(AV1_COMMON *const cm, MACROBLOCKD *const xd, int idx,
                     int mi_row, int mi_col) {
   MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  RefBuffer *ref_buffer =
+      has_second_ref(mbmi) ? &cm->frame_refs[mbmi->ref_frame[idx] - LAST_FRAME]
+                           : &cm->frame_refs[mbmi->ref_frame[0] - LAST_FRAME];
+#else
   RefBuffer *ref_buffer = &cm->frame_refs[mbmi->ref_frame[idx] - LAST_FRAME];
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   xd->block_refs[idx] = ref_buffer;
   if (!av1_is_valid_scale(&ref_buffer->sf))
     aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
                        "Invalid scale factors");
   av1_setup_pre_planes(xd, idx, ref_buffer->buf, mi_row, mi_col,
                        &ref_buffer->sf);
   aom_merge_corrupted_flag(&xd->corrupted, ref_buffer->buf->corrupted);
 }
 
 static void dec_predict_b_extend(
     AV1Decoder *const pbi, MACROBLOCKD *const xd, const TileInfo *const tile,
     int block, int mi_row_ori, int mi_col_ori, int mi_row_pred, int mi_col_pred,
-    int mi_row_top, int mi_col_top, uint8_t *dst_buf[3], int dst_stride[3],
+    int mi_row_top, int mi_col_top, int plane, uint8_t *dst_buf, int dst_stride,
     BLOCK_SIZE bsize_top, BLOCK_SIZE bsize_pred, int b_sub8x8, int bextend) {
   // Used in supertx
   // (mi_row_ori, mi_col_ori): location for mv
   // (mi_row_pred, mi_col_pred, bsize_pred): region to predict
   // (mi_row_top, mi_col_top, bsize_top): region of the top partition size
   // block: sub location of sub8x8 blocks
   // b_sub8x8: 1: ori is sub8x8; 0: ori is not sub8x8
   // bextend: 1: region to predict is an extension of ori; 0: not
@@ -992,54 +1072,52 @@ static void dec_predict_b_extend(
       mi_row_pred >= mi_row_top + mi_height_top ||
       mi_col_pred >= mi_col_top + mi_width_top || mi_row_pred >= cm->mi_rows ||
       mi_col_pred >= cm->mi_cols)
     return;
 
   mbmi = set_offsets_extend(cm, xd, tile, bsize_pred, mi_row_pred, mi_col_pred,
                             mi_row_ori, mi_col_ori);
   set_ref(cm, xd, 0, mi_row_pred, mi_col_pred);
-  if (has_second_ref(&xd->mi[0]->mbmi))
+  if (has_second_ref(&xd->mi[0]->mbmi)
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+      || is_inter_singleref_comp_mode(xd->mi[0]->mbmi.mode)
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+          )
     set_ref(cm, xd, 1, mi_row_pred, mi_col_pred);
-
   if (!bextend) mbmi->tx_size = max_txsize_lookup[bsize_top];
 
-  xd->plane[0].dst.stride = dst_stride[0];
-  xd->plane[1].dst.stride = dst_stride[1];
-  xd->plane[2].dst.stride = dst_stride[2];
-  xd->plane[0].dst.buf = dst_buf[0] +
-                         (r >> xd->plane[0].subsampling_y) * dst_stride[0] +
-                         (c >> xd->plane[0].subsampling_x);
-  xd->plane[1].dst.buf = dst_buf[1] +
-                         (r >> xd->plane[1].subsampling_y) * dst_stride[1] +
-                         (c >> xd->plane[1].subsampling_x);
-  xd->plane[2].dst.buf = dst_buf[2] +
-                         (r >> xd->plane[2].subsampling_y) * dst_stride[2] +
-                         (c >> xd->plane[2].subsampling_x);
+  xd->plane[plane].dst.stride = dst_stride;
+  xd->plane[plane].dst.buf =
+      dst_buf + (r >> xd->plane[plane].subsampling_y) * dst_stride +
+      (c >> xd->plane[plane].subsampling_x);
 
   if (!b_sub8x8)
-    av1_build_inter_predictors_sb_extend(&pbi->common, xd,
+    av1_build_inter_predictor_sb_extend(&pbi->common, xd,
 #if CONFIG_EXT_INTER
-                                         mi_row_ori, mi_col_ori,
+                                        mi_row_ori, mi_col_ori,
 #endif  // CONFIG_EXT_INTER
-                                         mi_row_pred, mi_col_pred, bsize_pred);
+                                        mi_row_pred, mi_col_pred, plane,
+                                        bsize_pred);
   else
-    av1_build_inter_predictors_sb_sub8x8_extend(&pbi->common, xd,
+    av1_build_inter_predictor_sb_sub8x8_extend(&pbi->common, xd,
 #if CONFIG_EXT_INTER
-                                                mi_row_ori, mi_col_ori,
+                                               mi_row_ori, mi_col_ori,
 #endif  // CONFIG_EXT_INTER
-                                                mi_row_pred, mi_col_pred,
-                                                bsize_pred, block);
+                                               mi_row_pred, mi_col_pred, plane,
+                                               bsize_pred, block);
 }
 
 static void dec_extend_dir(AV1Decoder *const pbi, MACROBLOCKD *const xd,
                            const TileInfo *const tile, int block,
-                           BLOCK_SIZE bsize, BLOCK_SIZE top_bsize, int mi_row,
+                           BLOCK_SIZE bsize, BLOCK_SIZE top_bsize,
+                           int mi_row_ori, int mi_col_ori, int mi_row,
                            int mi_col, int mi_row_top, int mi_col_top,
-                           uint8_t *dst_buf[3], int dst_stride[3], int dir) {
+                           int plane, uint8_t *dst_buf, int dst_stride,
+                           int dir) {
   // dir: 0-lower, 1-upper, 2-left, 3-right
   //      4-lowerleft, 5-upperleft, 6-lowerright, 7-upperright
   const int mi_width = mi_size_wide[bsize];
   const int mi_height = mi_size_high[bsize];
   int xss = xd->plane[1].subsampling_x;
   int yss = xd->plane[1].subsampling_y;
 #if CONFIG_CB4X4
   const int unify_bsize = 1;
@@ -1069,19 +1147,19 @@ static void dec_extend_dir(AV1Decoder *c
     wide_unit = mi_size_wide[extend_bsize];
     high_unit = mi_size_high[extend_bsize];
 
     mi_row_pred = mi_row + ((dir == 0) ? mi_height : -(mi_height + ext_offset));
     mi_col_pred = mi_col;
 
     for (j = 0; j < mi_height + ext_offset; j += high_unit)
       for (i = 0; i < mi_width + ext_offset; i += wide_unit)
-        dec_predict_b_extend(pbi, xd, tile, block, mi_row, mi_col,
+        dec_predict_b_extend(pbi, xd, tile, block, mi_row_ori, mi_col_ori,
                              mi_row_pred + j, mi_col_pred + i, mi_row_top,
-                             mi_col_top, dst_buf, dst_stride, top_bsize,
+                             mi_col_top, plane, dst_buf, dst_stride, top_bsize,
                              extend_bsize, b_sub8x8, 1);
   } else if (dir == 2 || dir == 3) {
     extend_bsize =
         (mi_height == mi_size_high[BLOCK_8X8] || bsize < BLOCK_8X8 || yss < xss)
             ? BLOCK_8X8
             : BLOCK_8X16;
 #if CONFIG_CB4X4
     if (bsize < BLOCK_8X8) {
@@ -1093,19 +1171,19 @@ static void dec_extend_dir(AV1Decoder *c
     wide_unit = mi_size_wide[extend_bsize];
     high_unit = mi_size_high[extend_bsize];
 
     mi_row_pred = mi_row;
     mi_col_pred = mi_col + ((dir == 3) ? mi_width : -(mi_width + ext_offset));
 
     for (j = 0; j < mi_height + ext_offset; j += high_unit)
       for (i = 0; i < mi_width + ext_offset; i += wide_unit)
-        dec_predict_b_extend(pbi, xd, tile, block, mi_row, mi_col,
+        dec_predict_b_extend(pbi, xd, tile, block, mi_row_ori, mi_col_ori,
                              mi_row_pred + j, mi_col_pred + i, mi_row_top,
-                             mi_col_top, dst_buf, dst_stride, top_bsize,
+                             mi_col_top, plane, dst_buf, dst_stride, top_bsize,
                              extend_bsize, b_sub8x8, 1);
   } else {
     extend_bsize = BLOCK_8X8;
 #if CONFIG_CB4X4
     if (bsize < BLOCK_8X8) {
       extend_bsize = BLOCK_4X4;
       ext_offset = mi_size_wide[BLOCK_8X8];
     }
@@ -1115,31 +1193,33 @@ static void dec_extend_dir(AV1Decoder *c
 
     mi_row_pred = mi_row + ((dir == 4 || dir == 6) ? mi_height
                                                    : -(mi_height + ext_offset));
     mi_col_pred =
         mi_col + ((dir == 6 || dir == 7) ? mi_width : -(mi_width + ext_offset));
 
     for (j = 0; j < mi_height + ext_offset; j += high_unit)
       for (i = 0; i < mi_width + ext_offset; i += wide_unit)
-        dec_predict_b_extend(pbi, xd, tile, block, mi_row, mi_col,
+        dec_predict_b_extend(pbi, xd, tile, block, mi_row_ori, mi_col_ori,
                              mi_row_pred + j, mi_col_pred + i, mi_row_top,
-                             mi_col_top, dst_buf, dst_stride, top_bsize,
+                             mi_col_top, plane, dst_buf, dst_stride, top_bsize,
                              extend_bsize, b_sub8x8, 1);
   }
 }
 
 static void dec_extend_all(AV1Decoder *const pbi, MACROBLOCKD *const xd,
                            const TileInfo *const tile, int block,
-                           BLOCK_SIZE bsize, BLOCK_SIZE top_bsize, int mi_row,
+                           BLOCK_SIZE bsize, BLOCK_SIZE top_bsize,
+                           int mi_row_ori, int mi_col_ori, int mi_row,
                            int mi_col, int mi_row_top, int mi_col_top,
-                           uint8_t *dst_buf[3], int dst_stride[3]) {
+                           int plane, uint8_t *dst_buf, int dst_stride) {
   for (int i = 0; i < 8; ++i) {
-    dec_extend_dir(pbi, xd, tile, block, bsize, top_bsize, mi_row, mi_col,
-                   mi_row_top, mi_col_top, dst_buf, dst_stride, i);
+    dec_extend_dir(pbi, xd, tile, block, bsize, top_bsize, mi_row_ori,
+                   mi_col_ori, mi_row, mi_col, mi_row_top, mi_col_top, plane,
+                   dst_buf, dst_stride, i);
   }
 }
 
 static void dec_predict_sb_complex(AV1Decoder *const pbi, MACROBLOCKD *const xd,
                                    const TileInfo *const tile, int mi_row,
                                    int mi_col, int mi_row_top, int mi_col_top,
                                    BLOCK_SIZE bsize, BLOCK_SIZE top_bsize,
                                    uint8_t *dst_buf[3], int dst_stride[3]) {
@@ -1201,173 +1281,307 @@ static void dec_predict_sb_complex(AV1De
   for (i = 0; i < MAX_MB_PLANE; i++) {
     xd->plane[i].dst.buf = dst_buf[i];
     xd->plane[i].dst.stride = dst_stride[i];
   }
 
   switch (partition) {
     case PARTITION_NONE:
       assert(bsize < top_bsize);
-      dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row, mi_col,
-                           mi_row_top, mi_col_top, dst_buf, dst_stride,
-                           top_bsize, bsize, 0, 0);
-      dec_extend_all(pbi, xd, tile, 0, bsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dst_buf, dst_stride);
+      for (i = 0; i < MAX_MB_PLANE; i++) {
+        dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row, mi_col,
+                             mi_row_top, mi_col_top, i, dst_buf[i],
+                             dst_stride[i], top_bsize, bsize, 0, 0);
+        dec_extend_all(pbi, xd, tile, 0, bsize, top_bsize, mi_row, mi_col,
+                       mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                       dst_stride[i]);
+      }
       break;
     case PARTITION_HORZ:
       if (bsize == BLOCK_8X8 && !unify_bsize) {
-        // For sub8x8, predict in 8x8 unit
-        // First half
-        dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row, mi_col,
-                             mi_row_top, mi_col_top, dst_buf, dst_stride,
-                             top_bsize, BLOCK_8X8, 1, 0);
-        if (bsize < top_bsize)
-          dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf, dst_stride);
-
-        // Second half
-        dec_predict_b_extend(pbi, xd, tile, 2, mi_row, mi_col, mi_row, mi_col,
-                             mi_row_top, mi_col_top, dst_buf1, dst_stride1,
-                             top_bsize, BLOCK_8X8, 1, 1);
-        if (bsize < top_bsize)
-          dec_extend_all(pbi, xd, tile, 2, subsize, top_bsize, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf1, dst_stride1);
+        for (i = 0; i < MAX_MB_PLANE; i++) {
+          // For sub8x8, predict in 8x8 unit
+          // First half
+          dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row, mi_col,
+                               mi_row_top, mi_col_top, i, dst_buf[i],
+                               dst_stride[i], top_bsize, BLOCK_8X8, 1, 0);
+          if (bsize < top_bsize)
+            dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row, mi_col,
+                           mi_row, mi_col, mi_row_top, mi_col_top, i,
+                           dst_buf[i], dst_stride[i]);
+
+          // Second half
+          dec_predict_b_extend(pbi, xd, tile, 2, mi_row, mi_col, mi_row, mi_col,
+                               mi_row_top, mi_col_top, i, dst_buf1[i],
+                               dst_stride1[i], top_bsize, BLOCK_8X8, 1, 1);
+          if (bsize < top_bsize)
+            dec_extend_all(pbi, xd, tile, 2, subsize, top_bsize, mi_row, mi_col,
+                           mi_row, mi_col, mi_row_top, mi_col_top, i,
+                           dst_buf1[i], dst_stride1[i]);
+        }
 
         // weighted average to smooth the boundary
         xd->plane[0].dst.buf = dst_buf[0];
         xd->plane[0].dst.stride = dst_stride[0];
         av1_build_masked_inter_predictor_complex(
             xd, dst_buf[0], dst_stride[0], dst_buf1[0], dst_stride1[0], mi_row,
             mi_col, mi_row_top, mi_col_top, bsize, top_bsize, PARTITION_HORZ,
             0);
       } else {
-        // First half
-        dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row, mi_col,
-                             mi_row_top, mi_col_top, dst_buf, dst_stride,
-                             top_bsize, subsize, 0, 0);
-        if (bsize < top_bsize)
-          dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf, dst_stride);
-        else
-          dec_extend_dir(pbi, xd, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf, dst_stride, 0);
-
-        if (mi_row + hbs < cm->mi_rows) {
-          // Second half
-          dec_predict_b_extend(pbi, xd, tile, 0, mi_row + hbs, mi_col,
-                               mi_row + hbs, mi_col, mi_row_top, mi_col_top,
-                               dst_buf1, dst_stride1, top_bsize, subsize, 0, 0);
-          if (bsize < top_bsize)
-            dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row + hbs,
-                           mi_col, mi_row_top, mi_col_top, dst_buf1,
-                           dst_stride1);
-          else
-            dec_extend_dir(pbi, xd, tile, 0, subsize, top_bsize, mi_row + hbs,
-                           mi_col, mi_row_top, mi_col_top, dst_buf1,
-                           dst_stride1, 1);
-
-          // weighted average to smooth the boundary
-          for (i = 0; i < MAX_MB_PLANE; i++) {
-            xd->plane[i].dst.buf = dst_buf[i];
-            xd->plane[i].dst.stride = dst_stride[i];
-            av1_build_masked_inter_predictor_complex(
-                xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i],
-                mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
-                PARTITION_HORZ, i);
+        for (i = 0; i < MAX_MB_PLANE; i++) {
+#if CONFIG_CB4X4
+          const struct macroblockd_plane *pd = &xd->plane[i];
+          int handle_chroma_sub8x8 = need_handle_chroma_sub8x8(
+              subsize, pd->subsampling_x, pd->subsampling_y);
+
+          if (handle_chroma_sub8x8) {
+            int mode_offset_row = CONFIG_CHROMA_SUB8X8 ? hbs : 0;
+
+            dec_predict_b_extend(pbi, xd, tile, 0, mi_row + mode_offset_row,
+                                 mi_col, mi_row, mi_col, mi_row_top, mi_col_top,
+                                 i, dst_buf[i], dst_stride[i], top_bsize, bsize,
+                                 0, 0);
+            if (bsize < top_bsize)
+              dec_extend_all(pbi, xd, tile, 0, bsize, top_bsize,
+                             mi_row + mode_offset_row, mi_col, mi_row, mi_col,
+                             mi_row_top, mi_col_top, i, dst_buf[i],
+                             dst_stride[i]);
+          } else {
+#endif
+            // First half
+            dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row,
+                                 mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                                 dst_stride[i], top_bsize, subsize, 0, 0);
+            if (bsize < top_bsize)
+              dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row,
+                             mi_col, mi_row, mi_col, mi_row_top, mi_col_top, i,
+                             dst_buf[i], dst_stride[i]);
+            else
+              dec_extend_dir(pbi, xd, tile, 0, subsize, top_bsize, mi_row,
+                             mi_col, mi_row, mi_col, mi_row_top, mi_col_top, i,
+                             dst_buf[i], dst_stride[i], 0);
+
+            if (mi_row + hbs < cm->mi_rows) {
+              // Second half
+              dec_predict_b_extend(pbi, xd, tile, 0, mi_row + hbs, mi_col,
+                                   mi_row + hbs, mi_col, mi_row_top, mi_col_top,
+                                   i, dst_buf1[i], dst_stride1[i], top_bsize,
+                                   subsize, 0, 0);
+              if (bsize < top_bsize)
+                dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize,
+                               mi_row + hbs, mi_col, mi_row + hbs, mi_col,
+                               mi_row_top, mi_col_top, i, dst_buf1[i],
+                               dst_stride1[i]);
+              else
+                dec_extend_dir(pbi, xd, tile, 0, subsize, top_bsize,
+                               mi_row + hbs, mi_col, mi_row + hbs, mi_col,
+                               mi_row_top, mi_col_top, i, dst_buf1[i],
+                               dst_stride1[i], 1);
+
+              // weighted average to smooth the boundary
+              xd->plane[i].dst.buf = dst_buf[i];
+              xd->plane[i].dst.stride = dst_stride[i];
+              av1_build_masked_inter_predictor_complex(
+                  xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i],
+                  mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
+                  PARTITION_HORZ, i);
+            }
+#if CONFIG_CB4X4
           }
+#endif
         }
       }
       break;
     case PARTITION_VERT:
       if (bsize == BLOCK_8X8 && !unify_bsize) {
-        // First half
-        dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row, mi_col,
-                             mi_row_top, mi_col_top, dst_buf, dst_stride,
-                             top_bsize, BLOCK_8X8, 1, 0);
-        if (bsize < top_bsize)
-          dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf, dst_stride);
-
-        // Second half
-        dec_predict_b_extend(pbi, xd, tile, 1, mi_row, mi_col, mi_row, mi_col,
-                             mi_row_top, mi_col_top, dst_buf1, dst_stride1,
-                             top_bsize, BLOCK_8X8, 1, 1);
-        if (bsize < top_bsize)
-          dec_extend_all(pbi, xd, tile, 1, subsize, top_bsize, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf1, dst_stride1);
+        for (i = 0; i < MAX_MB_PLANE; i++) {
+          // First half
+          dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row, mi_col,
+                               mi_row_top, mi_col_top, i, dst_buf[i],
+                               dst_stride[i], top_bsize, BLOCK_8X8, 1, 0);
+          if (bsize < top_bsize)
+            dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row, mi_col,
+                           mi_row, mi_col, mi_row_top, mi_col_top, i,
+                           dst_buf[i], dst_stride[i]);
+
+          // Second half
+          dec_predict_b_extend(pbi, xd, tile, 1, mi_row, mi_col, mi_row, mi_col,
+                               mi_row_top, mi_col_top, i, dst_buf1[i],
+                               dst_stride1[i], top_bsize, BLOCK_8X8, 1, 1);
+          if (bsize < top_bsize)
+            dec_extend_all(pbi, xd, tile, 1, subsize, top_bsize, mi_row, mi_col,
+                           mi_row, mi_col, mi_row_top, mi_col_top, i,
+                           dst_buf1[i], dst_stride1[i]);
+        }
 
         // Smooth
         xd->plane[0].dst.buf = dst_buf[0];
         xd->plane[0].dst.stride = dst_stride[0];
         av1_build_masked_inter_predictor_complex(
             xd, dst_buf[0], dst_stride[0], dst_buf1[0], dst_stride1[0], mi_row,
             mi_col, mi_row_top, mi_col_top, bsize, top_bsize, PARTITION_VERT,
             0);
       } else {
-        // First half
-        dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row, mi_col,
-                             mi_row_top, mi_col_top, dst_buf, dst_stride,
-                             top_bsize, subsize, 0, 0);
-        if (bsize < top_bsize)
-          dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf, dst_stride);
-        else
-          dec_extend_dir(pbi, xd, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf, dst_stride, 3);
-
-        // Second half
-        if (mi_col + hbs < cm->mi_cols) {
-          dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col + hbs, mi_row,
-                               mi_col + hbs, mi_row_top, mi_col_top, dst_buf1,
-                               dst_stride1, top_bsize, subsize, 0, 0);
-          if (bsize < top_bsize)
-            dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row,
-                           mi_col + hbs, mi_row_top, mi_col_top, dst_buf1,
-                           dst_stride1);
-          else
-            dec_extend_dir(pbi, xd, tile, 0, subsize, top_bsize, mi_row,
-                           mi_col + hbs, mi_row_top, mi_col_top, dst_buf1,
-                           dst_stride1, 2);
-
-          // Smooth
-          for (i = 0; i < MAX_MB_PLANE; i++) {
-            xd->plane[i].dst.buf = dst_buf[i];
-            xd->plane[i].dst.stride = dst_stride[i];
-            av1_build_masked_inter_predictor_complex(
-                xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i],
-                mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
-                PARTITION_VERT, i);
+        for (i = 0; i < MAX_MB_PLANE; i++) {
+#if CONFIG_CB4X4
+          const struct macroblockd_plane *pd = &xd->plane[i];
+          int handle_chroma_sub8x8 = need_handle_chroma_sub8x8(
+              subsize, pd->subsampling_x, pd->subsampling_y);
+
+          if (handle_chroma_sub8x8) {
+            int mode_offset_col = CONFIG_CHROMA_SUB8X8 ? hbs : 0;
+            assert(i > 0 && bsize == BLOCK_8X8);
+
+            dec_predict_b_extend(pbi, xd, tile, 0, mi_row,
+                                 mi_col + mode_offset_col, mi_row, mi_col,
+                                 mi_row_top, mi_col_top, i, dst_buf[i],
+                                 dst_stride[i], top_bsize, bsize, 0, 0);
+            if (bsize < top_bsize)
+              dec_extend_all(pbi, xd, tile, 0, bsize, top_bsize, mi_row,
+                             mi_col + mode_offset_col, mi_row, mi_col,
+                             mi_row_top, mi_col_top, i, dst_buf[i],
+                             dst_stride[i]);
+          } else {
+#endif
+            // First half
+            dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row,
+                                 mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                                 dst_stride[i], top_bsize, subsize, 0, 0);
+            if (bsize < top_bsize)
+              dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row,
+                             mi_col, mi_row, mi_col, mi_row_top, mi_col_top, i,
+                             dst_buf[i], dst_stride[i]);
+            else
+              dec_extend_dir(pbi, xd, tile, 0, subsize, top_bsize, mi_row,
+                             mi_col, mi_row, mi_col, mi_row_top, mi_col_top, i,
+                             dst_buf[i], dst_stride[i], 3);
+
+            // Second half
+            if (mi_col + hbs < cm->mi_cols) {
+              dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col + hbs,
+                                   mi_row, mi_col + hbs, mi_row_top, mi_col_top,
+                                   i, dst_buf1[i], dst_stride1[i], top_bsize,
+                                   subsize, 0, 0);
+              if (bsize < top_bsize)
+                dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row,
+                               mi_col + hbs, mi_row, mi_col + hbs, mi_row_top,
+                               mi_col_top, i, dst_buf1[i], dst_stride1[i]);
+              else
+                dec_extend_dir(pbi, xd, tile, 0, subsize, top_bsize, mi_row,
+                               mi_col + hbs, mi_row, mi_col + hbs, mi_row_top,
+                               mi_col_top, i, dst_buf1[i], dst_stride1[i], 2);
+
+              // Smooth
+              xd->plane[i].dst.buf = dst_buf[i];
+              xd->plane[i].dst.stride = dst_stride[i];
+              av1_build_masked_inter_predictor_complex(
+                  xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i],
+                  mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
+                  PARTITION_VERT, i);
+            }
+#if CONFIG_CB4X4
           }
+#endif
         }
       }
       break;
     case PARTITION_SPLIT:
       if (bsize == BLOCK_8X8 && !unify_bsize) {
-        dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row, mi_col,
-                             mi_row_top, mi_col_top, dst_buf, dst_stride,
-                             top_bsize, BLOCK_8X8, 1, 0);
-        dec_predict_b_extend(pbi, xd, tile, 1, mi_row, mi_col, mi_row, mi_col,
-                             mi_row_top, mi_col_top, dst_buf1, dst_stride1,
-                             top_bsize, BLOCK_8X8, 1, 1);
-        dec_predict_b_extend(pbi, xd, tile, 2, mi_row, mi_col, mi_row, mi_col,
-                             mi_row_top, mi_col_top, dst_buf2, dst_stride2,
-                             top_bsize, BLOCK_8X8, 1, 1);
-        dec_predict_b_extend(pbi, xd, tile, 3, mi_row, mi_col, mi_row, mi_col,
-                             mi_row_top, mi_col_top, dst_buf3, dst_stride3,
-                             top_bsize, BLOCK_8X8, 1, 1);
-        if (bsize < top_bsize) {
-          dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf, dst_stride);
-          dec_extend_all(pbi, xd, tile, 1, subsize, top_bsize, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf1, dst_stride1);
-          dec_extend_all(pbi, xd, tile, 2, subsize, top_bsize, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf2, dst_stride2);
-          dec_extend_all(pbi, xd, tile, 3, subsize, top_bsize, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf3, dst_stride3);
+        for (i = 0; i < MAX_MB_PLANE; i++) {
+          dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row, mi_col,
+                               mi_row_top, mi_col_top, i, dst_buf[i],
+                               dst_stride[i], top_bsize, BLOCK_8X8, 1, 0);
+          dec_predict_b_extend(pbi, xd, tile, 1, mi_row, mi_col, mi_row, mi_col,
+                               mi_row_top, mi_col_top, i, dst_buf1[i],
+                               dst_stride1[i], top_bsize, BLOCK_8X8, 1, 1);
+          dec_predict_b_extend(pbi, xd, tile, 2, mi_row, mi_col, mi_row, mi_col,
+                               mi_row_top, mi_col_top, i, dst_buf2[i],
+                               dst_stride2[i], top_bsize, BLOCK_8X8, 1, 1);
+          dec_predict_b_extend(pbi, xd, tile, 3, mi_row, mi_col, mi_row, mi_col,
+                               mi_row_top, mi_col_top, i, dst_buf3[i],
+                               dst_stride3[i], top_bsize, BLOCK_8X8, 1, 1);
+          if (bsize < top_bsize) {
+            dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row, mi_col,
+                           mi_row, mi_col, mi_row_top, mi_col_top, i,
+                           dst_buf[i], dst_stride[i]);
+            dec_extend_all(pbi, xd, tile, 1, subsize, top_bsize, mi_row, mi_col,
+                           mi_row, mi_col, mi_row_top, mi_col_top, i,
+                           dst_buf1[i], dst_stride1[i]);
+            dec_extend_all(pbi, xd, tile, 2, subsize, top_bsize, mi_row, mi_col,
+                           mi_row, mi_col, mi_row_top, mi_col_top, i,
+                           dst_buf2[i], dst_stride2[i]);
+            dec_extend_all(pbi, xd, tile, 3, subsize, top_bsize, mi_row, mi_col,
+                           mi_row, mi_col, mi_row_top, mi_col_top, i,
+                           dst_buf3[i], dst_stride3[i]);
+          }
         }
+#if CONFIG_CB4X4
+      } else if (bsize == BLOCK_8X8) {
+        for (i = 0; i < MAX_MB_PLANE; i++) {
+          const struct macroblockd_plane *pd = &xd->plane[i];
+          int handle_chroma_sub8x8 = need_handle_chroma_sub8x8(
+              subsize, pd->subsampling_x, pd->subsampling_y);
+
+          if (handle_chroma_sub8x8) {
+            int mode_offset_row =
+                CONFIG_CHROMA_SUB8X8 && mi_row + hbs < cm->mi_rows ? hbs : 0;
+            int mode_offset_col =
+                CONFIG_CHROMA_SUB8X8 && mi_col + hbs < cm->mi_cols ? hbs : 0;
+
+            dec_predict_b_extend(pbi, xd, tile, 0, mi_row + mode_offset_row,
+                                 mi_col + mode_offset_col, mi_row, mi_col,
+                                 mi_row_top, mi_col_top, i, dst_buf[i],
+                                 dst_stride[i], top_bsize, BLOCK_8X8, 0, 0);
+            if (bsize < top_bsize)
+              dec_extend_all(pbi, xd, tile, 0, BLOCK_8X8, top_bsize,
+                             mi_row + mode_offset_row, mi_col + mode_offset_col,
+                             mi_row, mi_col, mi_row_top, mi_col_top, i,
+                             dst_buf[i], dst_stride[i]);
+          } else {
+            dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row,
+                                 mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                                 dst_stride[i], top_bsize, subsize, 0, 0);
+            if (mi_row < cm->mi_rows && mi_col + hbs < cm->mi_cols)
+              dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col + hbs,
+                                   mi_row, mi_col + hbs, mi_row_top, mi_col_top,
+                                   i, dst_buf1[i], dst_stride1[i], top_bsize,
+                                   subsize, 0, 0);
+            if (mi_row + hbs < cm->mi_rows && mi_col < cm->mi_cols)
+              dec_predict_b_extend(pbi, xd, tile, 0, mi_row + hbs, mi_col,
+                                   mi_row + hbs, mi_col, mi_row_top, mi_col_top,
+                                   i, dst_buf2[i], dst_stride2[i], top_bsize,
+                                   subsize, 0, 0);
+            if (mi_row + hbs < cm->mi_rows && mi_col + hbs < cm->mi_cols)
+              dec_predict_b_extend(pbi, xd, tile, 0, mi_row + hbs, mi_col + hbs,
+                                   mi_row + hbs, mi_col + hbs, mi_row_top,
+                                   mi_col_top, i, dst_buf3[i], dst_stride3[i],
+                                   top_bsize, subsize, 0, 0);
+
+            if (bsize < top_bsize) {
+              dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row,
+                             mi_col, mi_row, mi_col, mi_row_top, mi_col_top, i,
+                             dst_buf[i], dst_stride[i]);
+              if (mi_row < cm->mi_rows && mi_col + hbs < cm->mi_cols)
+                dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize, mi_row,
+                               mi_col + hbs, mi_row, mi_col + hbs, mi_row_top,
+                               mi_col_top, i, dst_buf1[i], dst_stride1[i]);
+              if (mi_row + hbs < cm->mi_rows && mi_col < cm->mi_cols)
+                dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize,
+                               mi_row + hbs, mi_col, mi_row + hbs, mi_col,
+                               mi_row_top, mi_col_top, i, dst_buf2[i],
+                               dst_stride2[i]);
+              if (mi_row + hbs < cm->mi_rows && mi_col + hbs < cm->mi_cols)
+                dec_extend_all(pbi, xd, tile, 0, subsize, top_bsize,
+                               mi_row + hbs, mi_col + hbs, mi_row + hbs,
+                               mi_col + hbs, mi_row_top, mi_col_top, i,
+                               dst_buf3[i], dst_stride3[i]);
+            }
+          }
+        }
+#endif
       } else {
         dec_predict_sb_complex(pbi, xd, tile, mi_row, mi_col, mi_row_top,
                                mi_col_top, subsize, top_bsize, dst_buf,
                                dst_stride);
         if (mi_row < cm->mi_rows && mi_col + hbs < cm->mi_cols)
           dec_predict_sb_complex(pbi, xd, tile, mi_row, mi_col + hbs,
                                  mi_row_top, mi_col_top, subsize, top_bsize,
                                  dst_buf1, dst_stride1);
@@ -1376,17 +1590,22 @@ static void dec_predict_sb_complex(AV1De
                                  mi_row_top, mi_col_top, subsize, top_bsize,
                                  dst_buf2, dst_stride2);
         if (mi_row + hbs < cm->mi_rows && mi_col + hbs < cm->mi_cols)
           dec_predict_sb_complex(pbi, xd, tile, mi_row + hbs, mi_col + hbs,
                                  mi_row_top, mi_col_top, subsize, top_bsize,
                                  dst_buf3, dst_stride3);
       }
       for (i = 0; i < MAX_MB_PLANE; i++) {
-#if !CONFIG_CB4X4
+#if CONFIG_CB4X4
+        const struct macroblockd_plane *pd = &xd->plane[i];
+        int handle_chroma_sub8x8 = need_handle_chroma_sub8x8(
+            subsize, pd->subsampling_x, pd->subsampling_y);
+        if (handle_chroma_sub8x8) continue;  // Skip <4x4 chroma smoothing
+#else
         if (bsize == BLOCK_8X8 && i != 0)
           continue;  // Skip <4x4 chroma smoothing
 #endif
         if (mi_row < cm->mi_rows && mi_col + hbs < cm->mi_cols) {
           av1_build_masked_inter_predictor_complex(
               xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i],
               mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
               PARTITION_VERT, i);
@@ -1842,23 +2061,21 @@ static void decode_token_and_recon_block
         av1_decode_palette_tokens(xd, plane, r);
     }
 #endif  // CONFIG_PALETTE
     for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
       const struct macroblockd_plane *const pd = &xd->plane[plane];
       const TX_SIZE tx_size = get_tx_size(plane, xd);
       const int stepr = tx_size_high_unit[tx_size];
       const int stepc = tx_size_wide_unit[tx_size];
-#if CONFIG_CB4X4
-#if CONFIG_CHROMA_2X2
-      const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
-#else
+#if CONFIG_CHROMA_SUB8X8
       const BLOCK_SIZE plane_bsize =
           AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
-#endif  // CONFIG_CHROMA_2X2
+#elif CONFIG_CB4X4
+      const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
 #else
       const BLOCK_SIZE plane_bsize =
           get_plane_block_size(AOMMAX(BLOCK_8X8, bsize), pd);
 #endif
       int row, col;
       const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
       const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
 #if CONFIG_CB4X4
@@ -1870,18 +2087,24 @@ static void decode_token_and_recon_block
       for (row = 0; row < max_blocks_high; row += stepr)
         for (col = 0; col < max_blocks_wide; col += stepc)
           predict_and_reconstruct_intra_block(cm, xd, r, mbmi, plane, row, col,
                                               tx_size);
     }
   } else {
     int ref;
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    for (ref = 0; ref < 1 + is_inter_anyref_comp_mode(mbmi->mode); ++ref) {
+      const MV_REFERENCE_FRAME frame =
+          has_second_ref(mbmi) ? mbmi->ref_frame[ref] : mbmi->ref_frame[0];
+#else
     for (ref = 0; ref < 1 + has_second_ref(mbmi); ++ref) {
       const MV_REFERENCE_FRAME frame = mbmi->ref_frame[ref];
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
       if (frame < LAST_FRAME) {
 #if CONFIG_INTRABC
         assert(is_intrabc_block(mbmi));
         assert(frame == INTRA_FRAME);
         assert(ref == 0);
 #else
         assert(0);
 #endif  // CONFIG_INTRABC
@@ -1916,45 +2139,49 @@ static void decode_token_and_recon_block
 
     // Reconstruction
     if (!mbmi->skip) {
       int eobtotal = 0;
       int plane;
 
       for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
         const struct macroblockd_plane *const pd = &xd->plane[plane];
-#if CONFIG_CB4X4
-#if CONFIG_CHROMA_2X2
+#if CONFIG_CHROMA_SUB8X8
+        const BLOCK_SIZE plane_bsize =
+            AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
+#elif CONFIG_CB4X4
         const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
 #else
-        const BLOCK_SIZE plane_bsize =
-            AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
-#endif  // CONFIG_CHROMA_2X2
-#else
-        const BLOCK_SIZE plane_bsize =
-            get_plane_block_size(AOMMAX(BLOCK_8X8, bsize), pd);
+      const BLOCK_SIZE plane_bsize =
+          get_plane_block_size(AOMMAX(BLOCK_8X8, bsize), pd);
 #endif
         const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
         const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
         int row, col;
 
 #if CONFIG_CB4X4
         if (!is_chroma_reference(mi_row, mi_col, bsize, pd->subsampling_x,
                                  pd->subsampling_y))
           continue;
 #endif
 
 #if CONFIG_VAR_TX
         const TX_SIZE max_tx_size = get_vartx_max_txsize(mbmi, plane_bsize);
         const int bh_var_tx = tx_size_high_unit[max_tx_size];
         const int bw_var_tx = tx_size_wide_unit[max_tx_size];
-        for (row = 0; row < max_blocks_high; row += bh_var_tx)
-          for (col = 0; col < max_blocks_wide; col += bw_var_tx)
+        int block = 0;
+        int step =
+            tx_size_wide_unit[max_tx_size] * tx_size_high_unit[max_tx_size];
+        for (row = 0; row < max_blocks_high; row += bh_var_tx) {
+          for (col = 0; col < max_blocks_wide; col += bw_var_tx) {
             decode_reconstruct_tx(cm, xd, r, mbmi, plane, plane_bsize, row, col,
-                                  max_tx_size, &eobtotal);
+                                  block, max_tx_size, &eobtotal);
+            block += step;
+          }
+        }
 #else
         const TX_SIZE tx_size = get_tx_size(plane, xd);
         const int stepr = tx_size_high_unit[tx_size];
         const int stepc = tx_size_wide_unit[tx_size];
         for (row = 0; row < max_blocks_high; row += stepr)
           for (col = 0; col < max_blocks_wide; col += stepc)
             eobtotal += reconstruct_inter_block(cm, xd, r, mbmi->segment_id,
                                                 plane, row, col, tx_size);
@@ -1963,17 +2190,17 @@ static void decode_token_and_recon_block
     }
   }
 #endif  // CONFIG_COEF_INTERLEAVE
 
   int reader_corrupted_flag = aom_reader_has_error(r);
   aom_merge_corrupted_flag(&xd->corrupted, reader_corrupted_flag);
 }
 
-#if CONFIG_NCOBMC && CONFIG_MOTION_VAR
+#if (CONFIG_NCOBMC || CONFIG_NCOBMC_ADAPT_WEIGHT) && CONFIG_MOTION_VAR
 static void detoken_and_recon_sb(AV1Decoder *const pbi, MACROBLOCKD *const xd,
                                  int mi_row, int mi_col, aom_reader *r,
                                  BLOCK_SIZE bsize) {
   AV1_COMMON *const cm = &pbi->common;
   const int hbs = mi_size_wide[bsize] >> 1;
 #if CONFIG_CB4X4
   const int unify_bsize = 1;
 #else
@@ -2062,17 +2289,18 @@ static void decode_block(AV1Decoder *con
 #if CONFIG_SUPERTX
                     supertx_enabled,
 #endif
                     mi_row, mi_col, r,
 #if CONFIG_EXT_PARTITION_TYPES
                     partition,
 #endif
                     bsize);
-#if !(CONFIG_MOTION_VAR && CONFIG_NCOBMC)
+
+#if !(CONFIG_MOTION_VAR && (CONFIG_NCOBMC || CONFIG_NCOBMC_ADAPT_WEIGHT))
 #if CONFIG_SUPERTX
   if (!supertx_enabled)
 #endif  // CONFIG_SUPERTX
     decode_token_and_recon_block(pbi, xd, mi_row, mi_col, r, bsize);
 #endif
 }
 
 static PARTITION_TYPE read_partition(AV1_COMMON *cm, MACROBLOCKD *xd,
@@ -2126,17 +2354,22 @@ static PARTITION_TYPE read_partition(AV1
 
 #if CONFIG_SUPERTX
 static int read_skip(AV1_COMMON *cm, const MACROBLOCKD *xd, int segment_id,
                      aom_reader *r) {
   if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)) {
     return 1;
   } else {
     const int ctx = av1_get_skip_context(xd);
+#if CONFIG_NEW_MULTISYMBOL
+    FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
+    const int skip = aom_read_symbol(r, ec_ctx->skip_cdfs[ctx], 2, ACCT_STR);
+#else
     const int skip = aom_read(r, cm->fc->skip_probs[ctx], ACCT_STR);
+#endif
     FRAME_COUNTS *counts = xd->counts;
     if (counts) ++counts->skip[ctx][skip];
     return skip;
   }
 }
 #endif  // CONFIG_SUPERTX
 
 // TODO(slavarnway): eliminate bsize and subsize in future commits
@@ -2393,32 +2626,38 @@ static void decode_partition(AV1Decoder 
                    cm->dependent_horz_tiles,
 #endif  // CONFIG_DEPENDENT_HORZTILES
                    cm->mi_rows, cm->mi_cols);
     set_skip_context(xd, mi_row, mi_col);
     skip = read_skip(cm, xd, xd->mi[0]->mbmi.segment_id_supertx, r);
     if (skip) {
       av1_reset_skip_context(xd, mi_row, mi_col, bsize);
     } else {
+#if CONFIG_EC_ADAPT
+      FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
+#else
+      FRAME_CONTEXT *ec_ctx = cm->fc;
+#endif
 #if CONFIG_EXT_TX
       if (get_ext_tx_types(supertx_size, bsize, 1, cm->reduced_tx_set_used) >
           1) {
         const int eset =
             get_ext_tx_set(supertx_size, bsize, 1, cm->reduced_tx_set_used);
         if (eset > 0) {
-          txfm = aom_read_tree(r, av1_ext_tx_inter_tree[eset],
-                               cm->fc->inter_ext_tx_prob[eset][supertx_size],
-                               ACCT_STR);
+          const int packed_sym =
+              aom_read_symbol(r, ec_ctx->inter_ext_tx_cdf[eset][supertx_size],
+                              ext_tx_cnt_inter[eset], ACCT_STR);
+          txfm = av1_ext_tx_inter_inv[eset][packed_sym];
           if (xd->counts) ++xd->counts->inter_ext_tx[eset][supertx_size][txfm];
         }
       }
 #else
       if (supertx_size < TX_32X32) {
-        txfm = aom_read_tree(r, av1_ext_tx_tree,
-                             cm->fc->inter_ext_tx_prob[supertx_size], ACCT_STR);
+        txfm = aom_read_symbol(r, ec_ctx->inter_ext_tx_cdf[supertx_size],
+                               TX_TYPES, ACCT_STR);
         if (xd->counts) ++xd->counts->inter_ext_tx[supertx_size][txfm];
       }
 #endif  // CONFIG_EXT_TX
     }
 
     av1_setup_dst_planes(xd->plane, bsize, get_frame_new_buffer(cm), mi_row,
                          mi_col);
     for (i = 0; i < MAX_MB_PLANE; i++) {
@@ -2462,17 +2701,17 @@ static void decode_partition(AV1Decoder 
   // update partition context
   if (bsize >= BLOCK_8X8 &&
       (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT))
     update_partition_context(xd, mi_row, mi_col, subsize, bsize);
 #endif  // CONFIG_EXT_PARTITION_TYPES
 
 #if CONFIG_CDEF
   if (bsize == cm->sb_size) {
-    if (!sb_all_skip(cm, mi_row, mi_col)) {
+    if (!sb_all_skip(cm, mi_row, mi_col) && !cm->all_lossless) {
       cm->mi_grid_visible[mi_row * cm->mi_stride + mi_col]->mbmi.cdef_strength =
           aom_read_literal(r, cm->cdef_bits, ACCT_STR);
     } else {
       cm->mi_grid_visible[mi_row * cm->mi_stride + mi_col]->mbmi.cdef_strength =
           -1;
     }
   }
 #endif  // CONFIG_CDEF
@@ -2604,19 +2843,26 @@ static void decode_restoration_mode(AV1_
   if (cm->rst_info[0].frame_restoration_type != RESTORE_NONE ||
       cm->rst_info[1].frame_restoration_type != RESTORE_NONE ||
       cm->rst_info[2].frame_restoration_type != RESTORE_NONE) {
     rsi = &cm->rst_info[0];
     rsi->restoration_tilesize >>= aom_rb_read_bit(rb);
     if (rsi->restoration_tilesize != RESTORATION_TILESIZE_MAX) {
       rsi->restoration_tilesize >>= aom_rb_read_bit(rb);
     }
+  }
+  int s = AOMMIN(cm->subsampling_x, cm->subsampling_y);
+  if (s && (cm->rst_info[1].frame_restoration_type != RESTORE_NONE ||
+            cm->rst_info[2].frame_restoration_type != RESTORE_NONE)) {
+    cm->rst_info[1].restoration_tilesize =
+        cm->rst_info[0].restoration_tilesize >> (aom_rb_read_bit(rb) * s);
+  } else {
     cm->rst_info[1].restoration_tilesize = cm->rst_info[0].restoration_tilesize;
-    cm->rst_info[2].restoration_tilesize = cm->rst_info[0].restoration_tilesize;
   }
+  cm->rst_info[2].restoration_tilesize = cm->rst_info[1].restoration_tilesize;
 }
 
 static void read_wiener_filter(WienerInfo *wiener_info,
                                WienerInfo *ref_wiener_info, aom_reader *rb) {
   wiener_info->vfilter[0] = wiener_info->vfilter[WIENER_WIN - 1] =
       aom_read_primitive_refsubexpfin(
           rb, WIENER_FILT_TAP0_MAXV - WIENER_FILT_TAP0_MINV + 1,
           WIENER_FILT_TAP0_SUBEXP_K,
@@ -2677,26 +2923,33 @@ static void read_sgrproj_filter(SgrprojI
           rb, SGRPROJ_PRJ_MAX1 - SGRPROJ_PRJ_MIN1 + 1, SGRPROJ_PRJ_SUBEXP_K,
           ref_sgrproj_info->xqd[1] - SGRPROJ_PRJ_MIN1, ACCT_STR) +
       SGRPROJ_PRJ_MIN1;
   memcpy(ref_sgrproj_info, sgrproj_info, sizeof(*sgrproj_info));
 }
 
 static void decode_restoration(AV1_COMMON *cm, aom_reader *rb) {
   int i, p;
+#if CONFIG_FRAME_SUPERRES
+  const int width = cm->superres_upscaled_width;
+  const int height = cm->superres_upscaled_height;
+#else
+  const int width = cm->width;
+  const int height = cm->height;
+#endif  // CONFIG_FRAME_SUPERRES
   SgrprojInfo ref_sgrproj_info;
   WienerInfo ref_wiener_info;
   set_default_wiener(&ref_wiener_info);
   set_default_sgrproj(&ref_sgrproj_info);
-  const int ntiles = av1_get_rest_ntiles(cm->width, cm->height,
-                                         cm->rst_info[0].restoration_tilesize,
-                                         NULL, NULL, NULL, NULL);
+  const int ntiles =
+      av1_get_rest_ntiles(width, height, cm->rst_info[0].restoration_tilesize,
+                          NULL, NULL, NULL, NULL);
   const int ntiles_uv = av1_get_rest_ntiles(
-      ROUND_POWER_OF_TWO(cm->width, cm->subsampling_x),
-      ROUND_POWER_OF_TWO(cm->height, cm->subsampling_y),
+      ROUND_POWER_OF_TWO(width, cm->subsampling_x),
+      ROUND_POWER_OF_TWO(height, cm->subsampling_y),
       cm->rst_info[1].restoration_tilesize, NULL, NULL, NULL, NULL);
   RestorationInfo *rsi = &cm->rst_info[0];
   if (rsi->frame_restoration_type != RESTORE_NONE) {
     if (rsi->frame_restoration_type == RESTORE_SWITCHABLE) {
       for (i = 0; i < ntiles; ++i) {
         rsi->restoration_type[i] =
             aom_read_tree(rb, av1_switchable_restore_tree,
                           cm->fc->switchable_restore_prob, ACCT_STR);
@@ -2872,44 +3125,43 @@ static void setup_segmentation_dequant(A
 }
 
 static InterpFilter read_frame_interp_filter(struct aom_read_bit_buffer *rb) {
   return aom_rb_read_bit(rb) ? SWITCHABLE
                              : aom_rb_read_literal(rb, LOG_SWITCHABLE_FILTERS);
 }
 
 static void setup_render_size(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
+#if CONFIG_FRAME_SUPERRES
+  cm->render_width = cm->superres_upscaled_width;
+  cm->render_height = cm->superres_upscaled_height;
+#else
   cm->render_width = cm->width;
   cm->render_height = cm->height;
+#endif  // CONFIG_FRAME_SUPERRES
   if (aom_rb_read_bit(rb))
     av1_read_frame_size(rb, &cm->render_width, &cm->render_height);
 }
 
 #if CONFIG_FRAME_SUPERRES
 // TODO(afergs): make "struct aom_read_bit_buffer *const rb"?
-static void setup_superres_size(AV1_COMMON *const cm,
-                                struct aom_read_bit_buffer *rb, int *width,
-                                int *height) {
-  // TODO(afergs): Save input resolution - it's the upscaled resolution
+static void setup_superres(AV1_COMMON *const cm, struct aom_read_bit_buffer *rb,
+                           int *width, int *height) {
+  cm->superres_upscaled_width = *width;
+  cm->superres_upscaled_height = *height;
   if (aom_rb_read_bit(rb)) {
     cm->superres_scale_numerator =
         (uint8_t)aom_rb_read_literal(rb, SUPERRES_SCALE_BITS);
     cm->superres_scale_numerator += SUPERRES_SCALE_NUMERATOR_MIN;
     // Don't edit cm->width or cm->height directly, or the buffers won't get
     // resized correctly
-    // TODO(afergs): Should the render resolution not be modified? It's the same
-    // by default (ie. when it isn't sent)...
-    // resize_context_buffers() will change cm->width to equal cm->render_width,
-    // then they'll be the same again
-    *width = *width * cm->superres_scale_numerator / SUPERRES_SCALE_DENOMINATOR;
-    *height =
-        *width * cm->superres_scale_numerator / SUPERRES_SCALE_DENOMINATOR;
+    av1_calculate_scaled_size(width, height, cm->superres_scale_numerator);
   } else {
     // 1:1 scaling - ie. no scaling, scale not provided
-    cm->superres_scale_numerator = SUPERRES_SCALE_DENOMINATOR;
+    cm->superres_scale_numerator = SCALE_DENOMINATOR;
   }
 }
 #endif  // CONFIG_FRAME_SUPERRES
 
 static void resize_mv_buffer(AV1_COMMON *cm) {
   aom_free(cm->cur_frame->mvs);
   cm->cur_frame->mi_rows = cm->mi_rows;
   cm->cur_frame->mi_cols = cm->mi_cols;
@@ -2949,20 +3201,20 @@ static void resize_context_buffers(AV1_C
     resize_mv_buffer(cm);
   }
 }
 
 static void setup_frame_size(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
   int width, height;
   BufferPool *const pool = cm->buffer_pool;
   av1_read_frame_size(rb, &width, &height);
+#if CONFIG_FRAME_SUPERRES
+  setup_superres(cm, rb, &width, &height);
+#endif  // CONFIG_FRAME_SUPERRES
   setup_render_size(cm, rb);
-#if CONFIG_FRAME_SUPERRES
-  setup_superres_size(cm, rb, &width, &height);
-#endif  // CONFIG_FRAME_SUPERRES
   resize_context_buffers(cm, width, height);
 
   lock_buffer_pool(pool);
   if (aom_realloc_frame_buffer(
           get_frame_new_buffer(cm), cm->width, cm->height, cm->subsampling_x,
           cm->subsampling_y,
 #if CONFIG_HIGHBITDEPTH
           cm->use_highbitdepth,
@@ -2975,16 +3227,22 @@ static void setup_frame_size(AV1_COMMON 
                        "Failed to allocate frame buffer");
   }
   unlock_buffer_pool(pool);
 
   pool->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x;
   pool->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y;
   pool->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth;
   pool->frame_bufs[cm->new_fb_idx].buf.color_space = cm->color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  pool->frame_bufs[cm->new_fb_idx].buf.transfer_function =
+      cm->transfer_function;
+  pool->frame_bufs[cm->new_fb_idx].buf.chroma_sample_position =
+      cm->chroma_sample_position;
+#endif
   pool->frame_bufs[cm->new_fb_idx].buf.color_range = cm->color_range;
   pool->frame_bufs[cm->new_fb_idx].buf.render_width = cm->render_width;
   pool->frame_bufs[cm->new_fb_idx].buf.render_height = cm->render_height;
 }
 
 static INLINE int valid_ref_frame_img_fmt(aom_bit_depth_t ref_bit_depth,
                                           int ref_xss, int ref_yss,
                                           aom_bit_depth_t this_bit_depth,
@@ -3001,27 +3259,30 @@ static void setup_frame_size_with_refs(A
   BufferPool *const pool = cm->buffer_pool;
   for (i = 0; i < INTER_REFS_PER_FRAME; ++i) {
     if (aom_rb_read_bit(rb)) {
       YV12_BUFFER_CONFIG *const buf = cm->frame_refs[i].buf;
       width = buf->y_crop_width;
       height = buf->y_crop_height;
       cm->render_width = buf->render_width;
       cm->render_height = buf->render_height;
+#if CONFIG_FRAME_SUPERRES
+      setup_superres(cm, rb, &width, &height);
+#endif  // CONFIG_FRAME_SUPERRES
       found = 1;
       break;
     }
   }
 
   if (!found) {
     av1_read_frame_size(rb, &width, &height);
+#if CONFIG_FRAME_SUPERRES
+    setup_superres(cm, rb, &width, &height);
+#endif  // CONFIG_FRAME_SUPERRES
     setup_render_size(cm, rb);
-#if CONFIG_FRAME_SUPERRES
-    setup_superres_size(cm, rb, &width, &height);
-#endif  // CONFIG_FRAME_SUPERRES
   }
 
   if (width <= 0 || height <= 0)
     aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME,
                        "Invalid frame size");
 
   // Check to make sure at least one of frames that this frame references
   // has valid dimensions.
@@ -3061,16 +3322,22 @@ static void setup_frame_size_with_refs(A
                        "Failed to allocate frame buffer");
   }
   unlock_buffer_pool(pool);
 
   pool->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x;
   pool->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y;
   pool->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth;
   pool->frame_bufs[cm->new_fb_idx].buf.color_space = cm->color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  pool->frame_bufs[cm->new_fb_idx].buf.transfer_function =
+      cm->transfer_function;
+  pool->frame_bufs[cm->new_fb_idx].buf.chroma_sample_position =
+      cm->chroma_sample_position;
+#endif
   pool->frame_bufs[cm->new_fb_idx].buf.color_range = cm->color_range;
   pool->frame_bufs[cm->new_fb_idx].buf.render_width = cm->render_width;
   pool->frame_bufs[cm->new_fb_idx].buf.render_height = cm->render_height;
 }
 
 static void read_tile_info(AV1Decoder *const pbi,
                            struct aom_read_bit_buffer *const rb) {
   AV1_COMMON *const cm = &pbi->common;
@@ -3176,17 +3443,17 @@ static void read_tile_info(AV1Decoder *c
 }
 
 static int mem_get_varsize(const uint8_t *src, int sz) {
   switch (sz) {
     case 1: return src[0];
     case 2: return mem_get_le16(src);
     case 3: return mem_get_le24(src);
     case 4: return mem_get_le32(src);
-    default: assert("Invalid size" && 0); return -1;
+    default: assert(0 && "Invalid size"); return -1;
   }
 }
 
 #if CONFIG_EXT_TILE
 // Reads the next tile returning its size and adjusting '*data' accordingly
 // based on 'is_last'.
 static void get_tile_buffer(const uint8_t *const data_end,
                             struct aom_internal_error_info *error_info,
@@ -3653,17 +3920,17 @@ static const uint8_t *decode_tiles(AV1De
              mi_col += cm->mib_size) {
           av1_update_boundary_info(cm, &tile_info, mi_row, mi_col);
           decode_partition(pbi, &td->xd,
 #if CONFIG_SUPERTX
                            0,
 #endif  // CONFIG_SUPERTX
                            mi_row, mi_col, &td->bit_reader, cm->sb_size,
                            b_width_log2_lookup[cm->sb_size]);
-#if CONFIG_NCOBMC && CONFIG_MOTION_VAR
+#if (CONFIG_NCOBMC || CONFIG_NCOBMC_ADAPT_WEIGHT) && CONFIG_MOTION_VAR
           detoken_and_recon_sb(pbi, &td->xd, mi_row, mi_col, &td->bit_reader,
                                cm->sb_size);
 #endif
         }
         aom_merge_corrupted_flag(&pbi->mb.corrupted, td->xd.corrupted);
         if (pbi->mb.corrupted)
           aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME,
                              "Failed to decode tile data");
@@ -3794,17 +4061,17 @@ static int tile_worker_hook(TileWorkerDa
     for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
          mi_col += cm->mib_size) {
       decode_partition(pbi, &tile_data->xd,
 #if CONFIG_SUPERTX
                        0,
 #endif
                        mi_row, mi_col, &tile_data->bit_reader, cm->sb_size,
                        b_width_log2_lookup[cm->sb_size]);
-#if CONFIG_NCOBMC && CONFIG_MOTION_VAR
+#if (CONFIG_NCOBMC || CONFIG_NCOBMC_ADAPT_WEIGHT) && CONFIG_MOTION_VAR
       detoken_and_recon_sb(pbi, &tile_data->xd, mi_row, mi_col,
                            &tile_data->bit_reader, cm->sb_size);
 #endif
     }
   }
   return !tile_data->xd.corrupted;
 }
 
@@ -4018,43 +4285,55 @@ static const uint8_t *decode_tiles_mt(AV
 }
 
 static void error_handler(void *data) {
   AV1_COMMON *const cm = (AV1_COMMON *)data;
   aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME, "Truncated packet");
 }
 
 static void read_bitdepth_colorspace_sampling(AV1_COMMON *cm,
-                                              struct aom_read_bit_buffer *rb) {
+                                              struct aom_read_bit_buffer *rb,
+                                              int allow_lowbitdepth) {
   if (cm->profile >= PROFILE_2) {
     cm->bit_depth = aom_rb_read_bit(rb) ? AOM_BITS_12 : AOM_BITS_10;
   } else {
     cm->bit_depth = AOM_BITS_8;
   }
 
 #if CONFIG_HIGHBITDEPTH
-  cm->use_highbitdepth = cm->bit_depth > AOM_BITS_8 || !CONFIG_LOWBITDEPTH;
-#endif
-
+  cm->use_highbitdepth = cm->bit_depth > AOM_BITS_8 || !allow_lowbitdepth;
+#else
+  (void)allow_lowbitdepth;
+#endif
+#if CONFIG_COLORSPACE_HEADERS
+  cm->color_space = aom_rb_read_literal(rb, 5);
+  cm->transfer_function = aom_rb_read_literal(rb, 5);
+#else
   cm->color_space = aom_rb_read_literal(rb, 3);
+#endif
   if (cm->color_space != AOM_CS_SRGB) {
     // [16,235] (including xvycc) vs [0,255] range
     cm->color_range = aom_rb_read_bit(rb);
     if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) {
       cm->subsampling_x = aom_rb_read_bit(rb);
       cm->subsampling_y = aom_rb_read_bit(rb);
       if (cm->subsampling_x == 1 && cm->subsampling_y == 1)
         aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
                            "4:2:0 color not supported in profile 1 or 3");
       if (aom_rb_read_bit(rb))
         aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
                            "Reserved bit set");
     } else {
       cm->subsampling_y = cm->subsampling_x = 1;
     }
+#if CONFIG_COLORSPACE_HEADERS
+    if (cm->subsampling_x == 1 && cm->subsampling_y == 1) {
+      cm->chroma_sample_position = aom_rb_read_literal(rb, 2);
+    }
+#endif
   } else {
     if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) {
       // Note if colorspace is SRGB then 4:4:4 chroma sampling is assumed.
       // 4:2:2 or 4:4:0 chroma sampling is not allowed.
       cm->subsampling_y = cm->subsampling_x = 0;
       if (aom_rb_read_bit(rb))
         aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
                            "Reserved bit set");
@@ -4082,25 +4361,61 @@ static void read_compound_tools(AV1_COMM
 #if CONFIG_INTERINTRA
   if (!frame_is_intra_only(cm) && cm->reference_mode != COMPOUND_REFERENCE) {
     cm->allow_interintra_compound = aom_rb_read_bit(rb);
   } else {
     cm->allow_interintra_compound = 0;
   }
 #endif  // CONFIG_INTERINTRA
 #if CONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT
+#if CONFIG_COMPOUND_SINGLEREF
+  if (!frame_is_intra_only(cm)) {
+#else   // !CONFIG_COMPOUND_SINGLEREF
   if (!frame_is_intra_only(cm) && cm->reference_mode != SINGLE_REFERENCE) {
+#endif  // CONFIG_COMPOUND_SINGLEREF
     cm->allow_masked_compound = aom_rb_read_bit(rb);
   } else {
     cm->allow_masked_compound = 0;
   }
 #endif  // CONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT
 }
 #endif  // CONFIG_EXT_INTER
 
+#if CONFIG_VAR_REFS
+static void check_valid_ref_frames(AV1_COMMON *cm) {
+  MV_REFERENCE_FRAME ref_frame;
+  // TODO(zoeliu): To handle ALTREF_FRAME the same way as do with other
+  //               reference frames: Current encoder invalid ALTREF when ALTREF
+  //               is the same as LAST, but invalid all the other references
+  //               when they are the same as ALTREF.
+  for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
+    RefBuffer *const ref_buf = &cm->frame_refs[ref_frame - LAST_FRAME];
+
+    if (ref_buf->idx != INVALID_IDX) {
+      ref_buf->is_valid = 1;
+
+      MV_REFERENCE_FRAME ref;
+      for (ref = LAST_FRAME; ref < ref_frame; ++ref) {
+        RefBuffer *const buf = &cm->frame_refs[ref - LAST_FRAME];
+        if (buf->is_valid && buf->idx == ref_buf->idx) {
+          if (ref_frame != ALTREF_FRAME || ref == LAST_FRAME) {
+            ref_buf->is_valid = 0;
+            break;
+          } else {
+            buf->is_valid = 0;
+          }
+        }
+      }
+    } else {
+      ref_buf->is_valid = 0;
+    }
+  }
+}
+#endif  // CONFIG_VAR_REFS
+
 static size_t read_uncompressed_header(AV1Decoder *pbi,
                                        struct aom_read_bit_buffer *rb) {
   AV1_COMMON *const cm = &pbi->common;
   MACROBLOCKD *const xd = &pbi->mb;
   BufferPool *const pool = cm->buffer_pool;
   RefCntBuffer *const frame_bufs = pool->frame_bufs;
   int i, mask, ref_index = 0;
   size_t sz;
@@ -4216,22 +4531,25 @@ static size_t read_uncompressed_header(A
     }
   }
 #endif
   if (cm->frame_type == KEY_FRAME) {
     if (!av1_read_sync_code(rb))
       aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
                          "Invalid frame sync code");
 
-    read_bitdepth_colorspace_sampling(cm, rb);
+    read_bitdepth_colorspace_sampling(cm, rb, pbi->allow_lowbitdepth);
     pbi->refresh_frame_flags = (1 << REF_FRAMES) - 1;
 
     for (i = 0; i < INTER_REFS_PER_FRAME; ++i) {
       cm->frame_refs[i].idx = INVALID_IDX;
       cm->frame_refs[i].buf = NULL;
+#if CONFIG_VAR_REFS
+      cm->frame_refs[i].is_valid = 0;
+#endif  // CONFIG_VAR_REFS
     }
 
     setup_frame_size(cm, rb);
     if (pbi->need_resync) {
       memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
       pbi->need_resync = 0;
     }
 #if CONFIG_ANS && ANS_MAX_SYMBOLS
@@ -4269,17 +4587,17 @@ static size_t read_uncompressed_header(A
       }
     }
 
     if (cm->intra_only) {
       if (!av1_read_sync_code(rb))
         aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
                            "Invalid frame sync code");
 
-      read_bitdepth_colorspace_sampling(cm, rb);
+      read_bitdepth_colorspace_sampling(cm, rb, pbi->allow_lowbitdepth);
 
       pbi->refresh_frame_flags = aom_rb_read_literal(rb, REF_FRAMES);
       setup_frame_size(cm, rb);
       if (pbi->need_resync) {
         memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
         pbi->need_resync = 0;
       }
 #if CONFIG_ANS && ANS_MAX_SYMBOLS
@@ -4317,16 +4635,20 @@ static size_t read_uncompressed_header(A
           if (ref_frame_id != cm->ref_frame_id[ref] ||
               cm->valid_for_referencing[ref] == 0)
             aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME,
                                "Reference buffer frame ID mismatch");
         }
 #endif
       }
 
+#if CONFIG_VAR_REFS
+      check_valid_ref_frames(cm);
+#endif  // CONFIG_VAR_REFS
+
 #if CONFIG_FRAME_SIZE
       if (cm->error_resilient_mode == 0) {
         setup_frame_size_with_refs(cm, rb);
       } else {
         setup_frame_size(cm, rb);
       }
 #else
       setup_frame_size_with_refs(cm, rb);
@@ -4370,16 +4692,20 @@ static size_t read_uncompressed_header(A
         cm->valid_for_referencing[i] = 1;
       }
     }
   }
 #endif
 
   get_frame_new_buffer(cm)->bit_depth = cm->bit_depth;
   get_frame_new_buffer(cm)->color_space = cm->color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  get_frame_new_buffer(cm)->transfer_function = cm->transfer_function;
+  get_frame_new_buffer(cm)->chroma_sample_position = cm->chroma_sample_position;
+#endif
   get_frame_new_buffer(cm)->color_range = cm->color_range;
   get_frame_new_buffer(cm)->render_width = cm->render_width;
   get_frame_new_buffer(cm)->render_height = cm->render_height;
 
   if (pbi->need_resync) {
     aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME,
                        "Keyframe / intra-only frame required to reset decoder"
                        " state");
@@ -4427,22 +4753,16 @@ static size_t read_uncompressed_header(A
 
 #if CONFIG_EXT_PARTITION
   set_sb_size(cm, aom_rb_read_bit(rb) ? BLOCK_128X128 : BLOCK_64X64);
 #else
   set_sb_size(cm, BLOCK_64X64);
 #endif  // CONFIG_EXT_PARTITION
 
   setup_loopfilter(cm, rb);
-#if CONFIG_CDEF
-  setup_cdef(cm, rb);
-#endif
-#if CONFIG_LOOP_RESTORATION
-  decode_restoration_mode(cm, rb);
-#endif  // CONFIG_LOOP_RESTORATION
   setup_quantization(cm, rb);
   xd->bd = (int)cm->bit_depth;
 
 #if CONFIG_Q_ADAPT_PROBS
   av1_default_coef_probs(cm);
   if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode ||
       cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL) {
     for (i = 0; i < FRAME_CONTEXTS; ++i) cm->frame_contexts[i] = *cm->fc;
@@ -4471,42 +4791,46 @@ static size_t read_uncompressed_header(A
       cm->delta_q_present_flag = aom_rb_read_bit(rb);
     } else {
       cm->delta_q_present_flag = 0;
     }
     if (cm->delta_q_present_flag) {
       xd->prev_qindex = cm->base_qindex;
       cm->delta_q_res = 1 << aom_rb_read_literal(rb, 2);
 #if CONFIG_EXT_DELTA_Q
-      if (segment_quantizer_active) {
-        assert(seg->abs_delta == SEGMENT_DELTADATA);
-      }
+      assert(!segment_quantizer_active);
       cm->delta_lf_present_flag = aom_rb_read_bit(rb);
       if (cm->delta_lf_present_flag) {
         xd->prev_delta_lf_from_base = 0;
         cm->delta_lf_res = 1 << aom_rb_read_literal(rb, 2);
-      } else {
-        cm->delta_lf_present_flag = 0;
       }
 #endif  // CONFIG_EXT_DELTA_Q
     }
   }
 #endif
 
   for (i = 0; i < MAX_SEGMENTS; ++i) {
     const int qindex = cm->seg.enabled
                            ? av1_get_qindex(&cm->seg, i, cm->base_qindex)
                            : cm->base_qindex;
     xd->lossless[i] = qindex == 0 && cm->y_dc_delta_q == 0 &&
                       cm->uv_dc_delta_q == 0 && cm->uv_ac_delta_q == 0;
     xd->qindex[i] = qindex;
   }
-
+  cm->all_lossless = all_lossless(cm, xd);
   setup_segmentation_dequant(cm);
-  cm->tx_mode = read_tx_mode(cm, xd, rb);
+#if CONFIG_CDEF
+  if (!cm->all_lossless) {
+    setup_cdef(cm, rb);
+  }
+#endif
+#if CONFIG_LOOP_RESTORATION
+  decode_restoration_mode(cm, rb);
+#endif  // CONFIG_LOOP_RESTORATION
+  cm->tx_mode = read_tx_mode(cm, rb);
   cm->reference_mode = read_frame_reference_mode(cm, rb);
 #if CONFIG_EXT_INTER
   read_compound_tools(cm, rb);
 #endif  // CONFIG_EXT_INTER
 
 #if CONFIG_EXT_TX
   cm->reduced_tx_set_used = aom_rb_read_bit(rb);
 #endif  // CONFIG_EXT_TX
@@ -4562,20 +4886,19 @@ static void read_supertx_probs(FRAME_CON
     }
   }
 }
 #endif  // CONFIG_SUPERTX
 
 #if CONFIG_GLOBAL_MOTION
 static void read_global_motion_params(WarpedMotionParams *params,
                                       WarpedMotionParams *ref_params,
-                                      aom_prob *probs, aom_reader *r,
-                                      int allow_hp) {
-  TransformationType type =
-      aom_read_tree(r, av1_global_motion_types_tree, probs, ACCT_STR);
+                                      aom_reader *r, int allow_hp) {
+  TransformationType type = aom_read_bit(r, ACCT_STR);
+  if (type != IDENTITY) type += aom_read_literal(r, GLOBAL_TYPE_BITS, ACCT_STR);
   int trans_bits;
   int trans_dec_factor;
   int trans_prec_diff;
   set_default_warp_params(params);
   params->wmtype = type;
   switch (type) {
     case HOMOGRAPHY:
     case HORTRAPEZOID:
@@ -4650,19 +4973,19 @@ static void read_global_motion_params(Wa
   }
   if (params->wmtype <= AFFINE)
     if (!get_shear_params(params)) assert(0);
 }
 
 static void read_global_motion(AV1_COMMON *cm, aom_reader *r) {
   int frame;
   for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) {
-    read_global_motion_params(
-        &cm->global_motion[frame], &cm->prev_frame->global_motion[frame],
-        cm->fc->global_motion_types_prob, r, cm->allow_high_precision_mv);
+    read_global_motion_params(&cm->global_motion[frame],
+                              &cm->prev_frame->global_motion[frame], r,
+                              cm->allow_high_precision_mv);
     /*
     printf("Dec Ref %d [%d/%d]: %d %d %d %d\n",
            frame, cm->current_video_frame, cm->show_frame,
            cm->global_motion[frame].wmmat[0],
            cm->global_motion[frame].wmmat[1],
            cm->global_motion[frame].wmmat[2],
            cm->global_motion[frame].wmmat[3]);
            */
@@ -4675,17 +4998,17 @@ static void read_global_motion(AV1_COMMO
 static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
                                   size_t partition_size) {
   AV1_COMMON *const cm = &pbi->common;
 #if CONFIG_SUPERTX
   MACROBLOCKD *const xd = &pbi->mb;
 #endif
   FRAME_CONTEXT *const fc = cm->fc;
   aom_reader r;
-  int k, i;
+  int i;
 #if !CONFIG_EC_ADAPT || \
     (CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION || CONFIG_EXT_INTER)
   int j;
 #endif
 
 #if CONFIG_ANS && ANS_MAX_SYMBOLS
   r.window_size = 1 << cm->ans_window_size_log2;
 #endif
@@ -4717,46 +5040,48 @@ static int read_compressed_header(AV1Dec
 #if !CONFIG_PVQ
 #if !CONFIG_EC_ADAPT
   read_coef_probs(fc, cm->tx_mode, &r);
 #endif  // !CONFIG_EC_ADAPT
 #endif  // !CONFIG_PVQ
 #endif  // CONFIG_LV_MAP
 
 #if CONFIG_VAR_TX
-  for (k = 0; k < TXFM_PARTITION_CONTEXTS; ++k)
-    av1_diff_update_prob(&r, &fc->txfm_partition_prob[k], ACCT_STR);
+  for (i = 0; i < TXFM_PARTITION_CONTEXTS; ++i)
+    av1_diff_update_prob(&r, &fc->txfm_partition_prob[i], ACCT_STR);
 #endif  // CONFIG_VAR_TX
-  for (k = 0; k < SKIP_CONTEXTS; ++k)
-    av1_diff_update_prob(&r, &fc->skip_probs[k], ACCT_STR);
+#if !CONFIG_NEW_MULTISYMBOL
+  for (i = 0; i < SKIP_CONTEXTS; ++i)
+    av1_diff_update_prob(&r, &fc->skip_probs[i], ACCT_STR);
+#endif
 
 #if CONFIG_DELTA_Q && !CONFIG_EC_ADAPT
 #if CONFIG_EXT_DELTA_Q
   if (cm->delta_q_present_flag) {
-    for (k = 0; k < DELTA_Q_PROBS; ++k)
-      av1_diff_update_prob(&r, &fc->delta_q_prob[k], ACCT_STR);
+    for (i = 0; i < DELTA_Q_PROBS; ++i)
+      av1_diff_update_prob(&r, &fc->delta_q_prob[i], ACCT_STR);
   }
   if (cm->delta_lf_present_flag) {
-    for (k = 0; k < DELTA_LF_PROBS; ++k)
-      av1_diff_update_prob(&r, &fc->delta_lf_prob[k], ACCT_STR);
+    for (i = 0; i < DELTA_LF_PROBS; ++i)
+      av1_diff_update_prob(&r, &fc->delta_lf_prob[i], ACCT_STR);
   }
 #else
-  for (k = 0; k < DELTA_Q_PROBS; ++k)
-    av1_diff_update_prob(&r, &fc->delta_q_prob[k], ACCT_STR);
+  for (i = 0; i < DELTA_Q_PROBS; ++i)
+    av1_diff_update_prob(&r, &fc->delta_q_prob[i], ACCT_STR);
 #endif
 #endif
 
 #if !CONFIG_EC_ADAPT
   if (cm->seg.enabled && cm->seg.update_map) {
     if (cm->seg.temporal_update) {
-      for (k = 0; k < PREDICTION_PROBS; k++)
-        av1_diff_update_prob(&r, &cm->fc->seg.pred_probs[k], ACCT_STR);
+      for (i = 0; i < PREDICTION_PROBS; i++)
+        av1_diff_update_prob(&r, &cm->fc->seg.pred_probs[i], ACCT_STR);
     }
-    for (k = 0; k < MAX_SEGMENTS - 1; k++)
-      av1_diff_update_prob(&r, &cm->fc->seg.tree_probs[k], ACCT_STR);
+    for (i = 0; i < MAX_SEGMENTS - 1; i++)
+      av1_diff_update_prob(&r, &cm->fc->seg.tree_probs[i], ACCT_STR);
   }
 
   for (j = 0; j < INTRA_MODES; j++) {
     for (i = 0; i < INTRA_MODES - 1; ++i)
       av1_diff_update_prob(&r, &fc->uv_mode_prob[j][i], ACCT_STR);
   }
 
 #if CONFIG_EXT_PARTITION_TYPES
@@ -4782,84 +5107,118 @@ static int read_compressed_header(AV1Dec
 #if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
   for (i = 0; i < INTRA_FILTERS + 1; ++i)
     for (j = 0; j < INTRA_FILTERS - 1; ++j)
       av1_diff_update_prob(&r, &fc->intra_filter_probs[i][j], ACCT_STR);
 #endif  // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
 #endif  // !CONFIG_EC_ADAPT
 
   if (frame_is_intra_only(cm)) {
+#if !CONFIG_EC_ADAPT
     av1_copy(cm->kf_y_prob, av1_kf_y_mode_prob);
+#endif
     av1_copy(cm->fc->kf_y_cdf, av1_kf_y_mode_cdf);
 #if !CONFIG_EC_ADAPT
+    int k;
     for (k = 0; k < INTRA_MODES; k++)
       for (j = 0; j < INTRA_MODES; j++)
         for (i = 0; i < INTRA_MODES - 1; ++i)
           av1_diff_update_prob(&r, &cm->kf_y_prob[k][j][i], ACCT_STR);
 #endif
 #if CONFIG_INTRABC
     if (cm->allow_screen_content_tools) {
       av1_diff_update_prob(&r, &fc->intrabc_prob, ACCT_STR);
     }
 #endif
   } else {
+#if !CONFIG_NEW_MULTISYMBOL
     read_inter_mode_probs(fc, &r);
+#endif
 
 #if CONFIG_EXT_INTER
+#if !CONFIG_EC_ADAPT
     read_inter_compound_mode_probs(fc, &r);
+#endif
+#if CONFIG_COMPOUND_SINGLEREF
+    read_inter_singleref_comp_mode_probs(fc, &r);
+#endif  // CONFIG_COMPOUND_SINGLEREF
+
 #if CONFIG_INTERINTRA
     if (cm->reference_mode != COMPOUND_REFERENCE &&
         cm->allow_interintra_compound) {
+#if !CONFIG_NEW_MULTISYMBOL
       for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
         if (is_interintra_allowed_bsize_group(i)) {
           av1_diff_update_prob(&r, &fc->interintra_prob[i], ACCT_STR);
         }
       }
+#endif
+#if !CONFIG_EC_ADAPT
       for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
         for (j = 0; j < INTERINTRA_MODES - 1; j++)
           av1_diff_update_prob(&r, &fc->interintra_mode_prob[i][j], ACCT_STR);
       }
-#if CONFIG_WEDGE
+#endif
+#if CONFIG_WEDGE && !CONFIG_NEW_MULTISYMBOL
       for (i = 0; i < BLOCK_SIZES; i++) {
         if (is_interintra_allowed_bsize(i) && is_interintra_wedge_used(i)) {
           av1_diff_update_prob(&r, &fc->wedge_interintra_prob[i], ACCT_STR);
         }
       }
 #endif  // CONFIG_WEDGE
     }
 #endif  // CONFIG_INTERINTRA
-#if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
+#if !CONFIG_EC_ADAPT && (CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE)
+#if CONFIG_COMPOUND_SINGLEREF
+    if (cm->allow_masked_compound) {
+#else   // !CONFIG_COMPOUND_SINGLEREF
     if (cm->reference_mode != SINGLE_REFERENCE && cm->allow_masked_compound) {
+#endif  // CONFIG_COMPOUND_SINGLEREF
       for (i = 0; i < BLOCK_SIZES; i++) {
-        for (j = 0; j < COMPOUND_TYPES - 1; j++) {
-          av1_diff_update_prob(&r, &fc->compound_type_prob[i][j], ACCT_STR);
+        if (is_any_masked_compound_used(i)) {
+          for (j = 0; j < COMPOUND_TYPES - 1; j++) {
+            av1_diff_update_prob(&r, &fc->compound_type_prob[i][j], ACCT_STR);
+          }
         }
       }
     }
-#endif  // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
+#endif  // !CONFIG_EC_ADAPT && (CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE)
 #endif  // CONFIG_EXT_INTER
 
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
     for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i) {
       for (j = 0; j < MOTION_MODES - 1; ++j)
         av1_diff_update_prob(&r, &fc->motion_mode_prob[i][j], ACCT_STR);
     }
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
+#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
+    for (i = 0; i < ADAPT_OVERLAP_BLOCKS; ++i) {
+      for (j = 0; j < MAX_NCOBMC_MODES - 1; ++j)
+        av1_diff_update_prob(&r, &fc->ncobmc_mode_prob[i][j], ACCT_STR);
+    }
+#endif
+
 #if !CONFIG_EC_ADAPT
     if (cm->interp_filter == SWITCHABLE) read_switchable_interp_probs(fc, &r);
 #endif
-
+#if !CONFIG_NEW_MULTISYMBOL
     for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
       av1_diff_update_prob(&r, &fc->intra_inter_prob[i], ACCT_STR);
+#endif
 
     if (cm->reference_mode != SINGLE_REFERENCE)
       setup_compound_reference_mode(cm);
     read_frame_reference_mode_probs(cm, &r);
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    for (i = 0; i < COMP_INTER_MODE_CONTEXTS; i++)
+      av1_diff_update_prob(&r, &fc->comp_inter_mode_prob[i], ACCT_STR);
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
 #if !CONFIG_EC_ADAPT
     for (j = 0; j < BLOCK_SIZE_GROUPS; j++) {
       for (i = 0; i < INTRA_MODES - 1; ++i)
         av1_diff_update_prob(&r, &fc->y_mode_prob[j][i], ACCT_STR);
     }
 #endif
 
     for (i = 0; i < NMV_CONTEXTS; ++i)
@@ -4879,42 +5238,41 @@ static int read_compressed_header(AV1Dec
   /* Make tail distribution from head */
   av1_coef_pareto_cdfs(fc);
   for (i = 0; i < NMV_CONTEXTS; ++i) av1_set_mv_cdfs(&fc->nmvc[i]);
   av1_set_mode_cdfs(cm);
 #endif  // !CONFIG_EC_ADAPT
 
   return aom_reader_has_error(&r);
 }
-
 #ifdef NDEBUG
 #define debug_check_frame_counts(cm) (void)0
 #else  // !NDEBUG
 // Counts should only be incremented when frame_parallel_decoding_mode and
 // error_resilient_mode are disabled.
 static void debug_check_frame_counts(const AV1_COMMON *const cm) {
   FRAME_COUNTS zero_counts;
   av1_zero(zero_counts);
   assert(cm->refresh_frame_context != REFRESH_FRAME_CONTEXT_BACKWARD ||
          cm->error_resilient_mode);
+#if !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
   assert(!memcmp(cm->counts.y_mode, zero_counts.y_mode,
                  sizeof(cm->counts.y_mode)));
   assert(!memcmp(cm->counts.uv_mode, zero_counts.uv_mode,
                  sizeof(cm->counts.uv_mode)));
+#endif
   assert(!memcmp(cm->counts.partition, zero_counts.partition,
                  sizeof(cm->counts.partition)));
   assert(!memcmp(cm->counts.coef, zero_counts.coef, sizeof(cm->counts.coef)));
   assert(!memcmp(cm->counts.eob_branch, zero_counts.eob_branch,
                  sizeof(cm->counts.eob_branch)));
   assert(!memcmp(cm->counts.blockz_count, zero_counts.blockz_count,
                  sizeof(cm->counts.blockz_count)));
   assert(!memcmp(cm->counts.switchable_interp, zero_counts.switchable_interp,
                  sizeof(cm->counts.switchable_interp)));
-  assert(!memcmp(cm->counts.inter_mode, zero_counts.inter_mode,
-                 sizeof(cm->counts.inter_mode)));
 #if CONFIG_EXT_INTER
   assert(!memcmp(cm->counts.inter_compound_mode,
                  zero_counts.inter_compound_mode,
                  sizeof(cm->counts.inter_compound_mode)));
 #if CONFIG_INTERINTRA
   assert(!memcmp(cm->counts.interintra, zero_counts.interintra,
                  sizeof(cm->counts.interintra)));
 #if CONFIG_WEDGE
@@ -4925,20 +5283,34 @@ static void debug_check_frame_counts(con
   assert(!memcmp(cm->counts.compound_interinter,
                  zero_counts.compound_interinter,
                  sizeof(cm->counts.compound_interinter)));
 #endif  // CONFIG_EXT_INTER
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   assert(!memcmp(cm->counts.motion_mode, zero_counts.motion_mode,
                  sizeof(cm->counts.motion_mode)));
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
+#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
+  assert(!memcmp(cm->counts.ncobmc_mode, zero_counts.ncobmc_mode,
+                 sizeof(cm->counts.ncobmc_mode)));
+#endif
   assert(!memcmp(cm->counts.intra_inter, zero_counts.intra_inter,
                  sizeof(cm->counts.intra_inter)));
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  assert(!memcmp(cm->counts.comp_inter_mode, zero_counts.comp_inter_mode,
+                 sizeof(cm->counts.comp_inter_mode)));
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   assert(!memcmp(cm->counts.comp_inter, zero_counts.comp_inter,
                  sizeof(cm->counts.comp_inter)));
+#if CONFIG_EXT_COMP_REFS
+  assert(!memcmp(cm->counts.comp_ref_type, zero_counts.comp_ref_type,
+                 sizeof(cm->counts.comp_ref_type)));
+  assert(!memcmp(cm->counts.uni_comp_ref, zero_counts.uni_comp_ref,
+                 sizeof(cm->counts.uni_comp_ref)));
+#endif  // CONFIG_EXT_COMP_REFS
   assert(!memcmp(cm->counts.single_ref, zero_counts.single_ref,
                  sizeof(cm->counts.single_ref)));
   assert(!memcmp(cm->counts.comp_ref, zero_counts.comp_ref,
                  sizeof(cm->counts.comp_ref)));
 #if CONFIG_EXT_REFS
   assert(!memcmp(cm->counts.comp_bwdref, zero_counts.comp_bwdref,
                  sizeof(cm->counts.comp_bwdref)));
 #endif  // CONFIG_EXT_REFS
@@ -4999,16 +5371,29 @@ BITSTREAM_PROFILE av1_read_profile(struc
 static void make_update_tile_list_dec(AV1Decoder *pbi, int tile_rows,
                                       int tile_cols, FRAME_CONTEXT *ec_ctxs[]) {
   int i;
   for (i = 0; i < tile_rows * tile_cols; ++i)
     ec_ctxs[i] = &pbi->tile_data[i].tctx;
 }
 #endif
 
+#if CONFIG_FRAME_SUPERRES
+void superres_post_decode(AV1Decoder *pbi) {
+  AV1_COMMON *const cm = &pbi->common;
+  BufferPool *const pool = cm->buffer_pool;
+
+  if (av1_superres_unscaled(cm)) return;
+
+  lock_buffer_pool(pool);
+  av1_superres_upscale(cm, pool);
+  unlock_buffer_pool(pool);
+}
+#endif  // CONFIG_FRAME_SUPERRES
+
 void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data,
                       const uint8_t *data_end, const uint8_t **p_data_end) {
   AV1_COMMON *const cm = &pbi->common;
   MACROBLOCKD *const xd = &pbi->mb;
   struct aom_read_bit_buffer rb;
   int context_updated = 0;
   uint8_t clear_data[MAX_AV1_HEADER_SIZE];
   size_t first_partition_size;
@@ -5093,25 +5478,34 @@ void av1_decode_frame(AV1Decoder *pbi, c
     cm->prev_frame = last_fb_ref_buf->idx != INVALID_IDX
                          ? &cm->buffer_pool->frame_bufs[last_fb_ref_buf->idx]
                          : NULL;
   }
 #endif  // CONFIG_EXT_REFS || CONFIG_TEMPMV_SIGNALING
 
 #if CONFIG_TEMPMV_SIGNALING
   if (cm->use_prev_frame_mvs) {
-    assert(!cm->error_resilient_mode && cm->prev_frame &&
-           cm->width == last_fb_ref_buf->buf->y_width &&
-           cm->height == last_fb_ref_buf->buf->y_height &&
-           !cm->prev_frame->intra_only);
+    assert(!cm->error_resilient_mode && cm->prev_frame);
+#if CONFIG_FRAME_SUPERRES
+    assert(cm->width == cm->last_width && cm->height == cm->last_height);
+#else
+    assert(cm->width == last_fb_ref_buf->buf->y_crop_width &&
+           cm->height == last_fb_ref_buf->buf->y_crop_height);
+#endif  // CONFIG_FRAME_SUPERRES
+    assert(!cm->prev_frame->intra_only);
   }
 #else
   cm->use_prev_frame_mvs = !cm->error_resilient_mode && cm->prev_frame &&
+#if CONFIG_FRAME_SUPERRES
+                           cm->width == cm->last_width &&
+                           cm->height == cm->last_height &&
+#else
                            cm->width == cm->prev_frame->buf.y_crop_width &&
                            cm->height == cm->prev_frame->buf.y_crop_height &&
+#endif  // CONFIG_FRAME_SUPERRES
                            !cm->last_intra_only && cm->last_show_frame &&
                            (cm->last_frame_type != KEY_FRAME);
 #endif  // CONFIG_TEMPMV_SIGNALING
 
   av1_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y);
 
   *cm->fc = cm->frame_contexts[cm->frame_context_idx];
   cm->pre_fc = &cm->frame_contexts[cm->frame_context_idx];
@@ -5169,21 +5563,25 @@ void av1_decode_frame(AV1Decoder *pbi, c
       aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME,
                          "Decode failed. Frame data is corrupted.");
     }
   } else {
     *p_data_end = decode_tiles(pbi, data + first_partition_size, data_end);
   }
 
 #if CONFIG_CDEF
-  if (!cm->skip_loop_filter) {
+  if (!cm->skip_loop_filter && !cm->all_lossless) {
     av1_cdef_frame(&pbi->cur_buf->buf, cm, &pbi->mb);
   }
 #endif  // CONFIG_CDEF
 
+#if CONFIG_FRAME_SUPERRES
+  superres_post_decode(pbi);
+#endif  // CONFIG_FRAME_SUPERRES
+
 #if CONFIG_LOOP_RESTORATION
   if (cm->rst_info[0].frame_restoration_type != RESTORE_NONE ||
       cm->rst_info[1].frame_restoration_type != RESTORE_NONE ||
       cm->rst_info[2].frame_restoration_type != RESTORE_NONE) {
     av1_loop_restoration_frame(new_fb, cm, cm->rst_info, 7, 0, NULL);
   }
 #endif  // CONFIG_LOOP_RESTORATION
 
--- a/third_party/aom/av1/decoder/decodemv.c
+++ b/third_party/aom/av1/decoder/decodemv.c
@@ -27,16 +27,19 @@
 #endif  // CONFIG_WARPED_MOTION
 
 #include "av1/decoder/decodeframe.h"
 #include "av1/decoder/decodemv.h"
 
 #include "aom_dsp/aom_dsp_common.h"
 
 #define ACCT_STR __func__
+
+#define DEC_MISMATCH_DEBUG 0
+
 #if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
 static INLINE int read_uniform(aom_reader *r, int n) {
   const int l = get_unsigned_bits(n);
   const int m = (1 << l) - n;
   const int v = aom_read_literal(r, l - 1, ACCT_STR);
   assert(l != 0);
   if (v < m)
     return v;
@@ -137,168 +140,207 @@ static int read_delta_lflevel(AV1_COMMON
 }
 #endif
 #endif
 
 static PREDICTION_MODE read_intra_mode_y(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd,
                                          aom_reader *r, int size_group) {
   const PREDICTION_MODE y_mode =
       read_intra_mode(r, ec_ctx->y_mode_cdf[size_group]);
+#if !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
   FRAME_COUNTS *counts = xd->counts;
   if (counts) ++counts->y_mode[size_group][y_mode];
+#else
+  /* TODO(negge): Can we remove this parameter? */
+  (void)xd;
+#endif  // !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
   return y_mode;
 }
 
 static PREDICTION_MODE read_intra_mode_uv(FRAME_CONTEXT *ec_ctx,
                                           MACROBLOCKD *xd, aom_reader *r,
                                           PREDICTION_MODE y_mode) {
   const PREDICTION_MODE uv_mode =
       read_intra_mode(r, ec_ctx->uv_mode_cdf[y_mode]);
+#if !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
   FRAME_COUNTS *counts = xd->counts;
   if (counts) ++counts->uv_mode[y_mode][uv_mode];
+#else
+  /* TODO(negge): Can we remove this parameter? */
+  (void)xd;
+#endif  // !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
   return uv_mode;
 }
 
 #if CONFIG_CFL
-static int read_cfl_alphas(FRAME_CONTEXT *const ec_ctx, aom_reader *r, int skip,
+static int read_cfl_alphas(FRAME_CONTEXT *const ec_ctx, aom_reader *r,
                            CFL_SIGN_TYPE signs_out[CFL_PRED_PLANES]) {
-  if (skip) {
-    signs_out[CFL_PRED_U] = CFL_SIGN_POS;
-    signs_out[CFL_PRED_V] = CFL_SIGN_POS;
-    return 0;
-  } else {
-    const int ind = aom_read_symbol(r, ec_ctx->cfl_alpha_cdf, CFL_ALPHABET_SIZE,
-                                    "cfl:alpha");
-    // Signs are only coded for nonzero values
-    // sign == 0 implies negative alpha
-    // sign == 1 implies positive alpha
-    signs_out[CFL_PRED_U] = cfl_alpha_codes[ind][CFL_PRED_U]
-                                ? aom_read_bit(r, "cfl:sign")
-                                : CFL_SIGN_POS;
-    signs_out[CFL_PRED_V] = cfl_alpha_codes[ind][CFL_PRED_V]
-                                ? aom_read_bit(r, "cfl:sign")
-                                : CFL_SIGN_POS;
+  const int ind =
+      aom_read_symbol(r, ec_ctx->cfl_alpha_cdf, CFL_ALPHABET_SIZE, "cfl:alpha");
+  // Signs are only coded for nonzero values
+  // sign == 0 implies negative alpha
+  // sign == 1 implies positive alpha
+  signs_out[CFL_PRED_U] = cfl_alpha_codes[ind][CFL_PRED_U]
+                              ? aom_read_bit(r, "cfl:sign")
+                              : CFL_SIGN_POS;
+  signs_out[CFL_PRED_V] = cfl_alpha_codes[ind][CFL_PRED_V]
+                              ? aom_read_bit(r, "cfl:sign")
+                              : CFL_SIGN_POS;
 
-    return ind;
-  }
+  return ind;
 }
 #endif
 
 #if CONFIG_EXT_INTER && CONFIG_INTERINTRA
 static INTERINTRA_MODE read_interintra_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
                                             aom_reader *r, int size_group) {
+#if CONFIG_EC_ADAPT
+  (void)cm;
+  const INTERINTRA_MODE ii_mode = (INTERINTRA_MODE)aom_read_symbol(
+      r, xd->tile_ctx->interintra_mode_cdf[size_group], INTERINTRA_MODES,
+      ACCT_STR);
+#else
   const INTERINTRA_MODE ii_mode = (INTERINTRA_MODE)aom_read_tree(
       r, av1_interintra_mode_tree, cm->fc->interintra_mode_prob[size_group],
       ACCT_STR);
+#endif
   FRAME_COUNTS *counts = xd->counts;
   if (counts) ++counts->interintra_mode[size_group][ii_mode];
   return ii_mode;
 }
 #endif  // CONFIG_EXT_INTER && CONFIG_INTERINTRA
 
 static PREDICTION_MODE read_inter_mode(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd,
                                        aom_reader *r, int16_t ctx) {
   FRAME_COUNTS *counts = xd->counts;
   int16_t mode_ctx = ctx & NEWMV_CTX_MASK;
-  aom_prob mode_prob = ec_ctx->newmv_prob[mode_ctx];
+  int is_newmv, is_zeromv, is_refmv;
+#if CONFIG_NEW_MULTISYMBOL
+  is_newmv = aom_read_symbol(r, ec_ctx->newmv_cdf[mode_ctx], 2, ACCT_STR) == 0;
+#else
+  is_newmv = aom_read(r, ec_ctx->newmv_prob[mode_ctx], ACCT_STR) == 0;
+#endif
 
-  if (aom_read(r, mode_prob, ACCT_STR) == 0) {
+  if (is_newmv) {
     if (counts) ++counts->newmv_mode[mode_ctx][0];
     return NEWMV;
   }
   if (counts) ++counts->newmv_mode[mode_ctx][1];
 
   if (ctx & (1 << ALL_ZERO_FLAG_OFFSET)) return ZEROMV;
 
   mode_ctx = (ctx >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK;
 
-  mode_prob = ec_ctx->zeromv_prob[mode_ctx];
-  if (aom_read(r, mode_prob, ACCT_STR) == 0) {
+#if CONFIG_NEW_MULTISYMBOL
+  is_zeromv =
+      aom_read_symbol(r, ec_ctx->zeromv_cdf[mode_ctx], 2, ACCT_STR) == 0;
+#else
+  is_zeromv = aom_read(r, ec_ctx->zeromv_prob[mode_ctx], ACCT_STR) == 0;
+#endif
+  if (is_zeromv) {
     if (counts) ++counts->zeromv_mode[mode_ctx][0];
     return ZEROMV;
   }
   if (counts) ++counts->zeromv_mode[mode_ctx][1];
 
   mode_ctx = (ctx >> REFMV_OFFSET) & REFMV_CTX_MASK;
 
   if (ctx & (1 << SKIP_NEARESTMV_OFFSET)) mode_ctx = 6;
   if (ctx & (1 << SKIP_NEARMV_OFFSET)) mode_ctx = 7;
   if (ctx & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) mode_ctx = 8;
 
-  mode_prob = ec_ctx->refmv_prob[mode_ctx];
+#if CONFIG_NEW_MULTISYMBOL
+  is_refmv = aom_read_symbol(r, ec_ctx->refmv_cdf[mode_ctx], 2, ACCT_STR) == 0;
+#else
+  is_refmv = aom_read(r, ec_ctx->refmv_prob[mode_ctx], ACCT_STR) == 0;
+#endif
 
-  if (aom_read(r, mode_prob, ACCT_STR) == 0) {
+  if (is_refmv) {
     if (counts) ++counts->refmv_mode[mode_ctx][0];
 
     return NEARESTMV;
   } else {
     if (counts) ++counts->refmv_mode[mode_ctx][1];
     return NEARMV;
   }
 
   // Invalid prediction mode.
   assert(0);
 }
 
-static void read_drl_idx(const AV1_COMMON *cm, MACROBLOCKD *xd,
+static void read_drl_idx(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd,
                          MB_MODE_INFO *mbmi, aom_reader *r) {
   uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
   mbmi->ref_mv_idx = 0;
 
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+  if (mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV ||
+      mbmi->mode == SR_NEW_NEWMV) {
+#else   // !CONFIG_COMPOUND_SINGLEREF
   if (mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV) {
-#else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+#else   // !CONFIG_EXT_INTER
   if (mbmi->mode == NEWMV) {
-#endif
+#endif  // CONFIG_EXT_INTER
     int idx;
     for (idx = 0; idx < 2; ++idx) {
       if (xd->ref_mv_count[ref_frame_type] > idx + 1) {
         uint8_t drl_ctx = av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], idx);
-        aom_prob drl_prob = cm->fc->drl_prob[drl_ctx];
-        if (!aom_read(r, drl_prob, ACCT_STR)) {
-          mbmi->ref_mv_idx = idx;
-          if (xd->counts) ++xd->counts->drl_mode[drl_ctx][0];
-          return;
-        }
-        mbmi->ref_mv_idx = idx + 1;
-        if (xd->counts) ++xd->counts->drl_mode[drl_ctx][1];
+#if CONFIG_NEW_MULTISYMBOL
+        int drl_idx = aom_read_symbol(r, ec_ctx->drl_cdf[drl_ctx], 2, ACCT_STR);
+#else
+        int drl_idx = aom_read(r, ec_ctx->drl_prob[drl_ctx], ACCT_STR);
+#endif
+        mbmi->ref_mv_idx = idx + drl_idx;
+        if (xd->counts) ++xd->counts->drl_mode[drl_ctx][drl_idx];
+        if (!drl_idx) return;
       }
     }
   }
 
   if (have_nearmv_in_inter_mode(mbmi->mode)) {
     int idx;
     // Offset the NEARESTMV mode.
     // TODO(jingning): Unify the two syntax decoding loops after the NEARESTMV
     // mode is factored in.
     for (idx = 1; idx < 3; ++idx) {
       if (xd->ref_mv_count[ref_frame_type] > idx + 1) {
         uint8_t drl_ctx = av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], idx);
-        aom_prob drl_prob = cm->fc->drl_prob[drl_ctx];
-        if (!aom_read(r, drl_prob, ACCT_STR)) {
-          mbmi->ref_mv_idx = idx - 1;
-          if (xd->counts) ++xd->counts->drl_mode[drl_ctx][0];
-          return;
-        }
-        mbmi->ref_mv_idx = idx;
-        if (xd->counts) ++xd->counts->drl_mode[drl_ctx][1];
+#if CONFIG_NEW_MULTISYMBOL
+        int drl_idx = aom_read_symbol(r, ec_ctx->drl_cdf[drl_ctx], 2, ACCT_STR);
+#else
+        int drl_idx = aom_read(r, ec_ctx->drl_prob[drl_ctx], ACCT_STR);
+#endif
+        mbmi->ref_mv_idx = idx + drl_idx - 1;
+        if (xd->counts) ++xd->counts->drl_mode[drl_ctx][drl_idx];
+        if (!drl_idx) return;
       }
     }
   }
 }
 
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 static MOTION_MODE read_motion_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
                                     MODE_INFO *mi, aom_reader *r) {
   MB_MODE_INFO *mbmi = &mi->mbmi;
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+  const MOTION_MODE last_motion_mode_allowed =
+      motion_mode_allowed_wrapper(0,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                  0, xd->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                  mi);
+#else
   const MOTION_MODE last_motion_mode_allowed = motion_mode_allowed(
 #if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
       0, xd->global_motion,
 #endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
       mi);
+#endif  // CONFIG_NCOBMC_ADAPT_WEIGHT
   int motion_mode;
   FRAME_COUNTS *counts = xd->counts;
 
   if (last_motion_mode_allowed == SIMPLE_TRANSLATION) return SIMPLE_TRANSLATION;
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
   if (last_motion_mode_allowed == OBMC_CAUSAL) {
     motion_mode = aom_read(r, cm->fc->obmc_prob[mbmi->sb_type], ACCT_STR);
     if (counts) ++counts->obmc[mbmi->sb_type][motion_mode];
@@ -309,31 +351,81 @@ static MOTION_MODE read_motion_mode(AV1_
         aom_read_tree(r, av1_motion_mode_tree,
                       cm->fc->motion_mode_prob[mbmi->sb_type], ACCT_STR);
     if (counts) ++counts->motion_mode[mbmi->sb_type][motion_mode];
     return (MOTION_MODE)(SIMPLE_TRANSLATION + motion_mode);
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
   }
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
 }
+
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+static void read_ncobmc_mode(AV1_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *mi,
+                             NCOBMC_MODE ncobmc_mode[2], aom_reader *r) {
+  MB_MODE_INFO *mbmi = &mi->mbmi;
+  FRAME_COUNTS *counts = xd->counts;
+  MOTION_MODE last_motion_mode_allowed =
+      motion_mode_allowed_wrapper(0,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                  0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                  mi);
+  ADAPT_OVERLAP_BLOCK ao_block = adapt_overlap_block_lookup[mbmi->sb_type];
+  if (last_motion_mode_allowed < NCOBMC_ADAPT_WEIGHT) return;
+
+  ncobmc_mode[0] = aom_read_tree(r, av1_ncobmc_mode_tree,
+                                 cm->fc->ncobmc_mode_prob[ao_block], ACCT_STR);
+  if (counts) ++counts->ncobmc_mode[ao_block][ncobmc_mode[0]];
+
+  if (mi_size_wide[mbmi->sb_type] != mi_size_high[mbmi->sb_type]) {
+    ncobmc_mode[1] = aom_read_tree(
+        r, av1_ncobmc_mode_tree, cm->fc->ncobmc_mode_prob[ao_block], ACCT_STR);
+    if (counts) ++counts->ncobmc_mode[ao_block][ncobmc_mode[1]];
+  }
+}
+#endif
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
 #if CONFIG_EXT_INTER
 static PREDICTION_MODE read_inter_compound_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
                                                 aom_reader *r, int16_t ctx) {
+#if CONFIG_EC_ADAPT
+  (void)cm;
+  const int mode =
+      aom_read_symbol(r, xd->tile_ctx->inter_compound_mode_cdf[ctx],
+                      INTER_COMPOUND_MODES, ACCT_STR);
+#else
   const int mode =
       aom_read_tree(r, av1_inter_compound_mode_tree,
                     cm->fc->inter_compound_mode_probs[ctx], ACCT_STR);
+#endif
   FRAME_COUNTS *counts = xd->counts;
 
   if (counts) ++counts->inter_compound_mode[ctx][mode];
 
   assert(is_inter_compound_mode(NEAREST_NEARESTMV + mode));
   return NEAREST_NEARESTMV + mode;
 }
+
+#if CONFIG_COMPOUND_SINGLEREF
+static PREDICTION_MODE read_inter_singleref_comp_mode(AV1_COMMON *cm,
+                                                      MACROBLOCKD *xd,
+                                                      aom_reader *r,
+                                                      int16_t ctx) {
+  const int mode =
+      aom_read_tree(r, av1_inter_singleref_comp_mode_tree,
+                    cm->fc->inter_singleref_comp_mode_probs[ctx], ACCT_STR);
+  FRAME_COUNTS *counts = xd->counts;
+
+  if (counts) ++counts->inter_singleref_comp_mode[ctx][mode];
+
+  assert(is_inter_singleref_comp_mode(SR_NEAREST_NEARMV + mode));
+  return SR_NEAREST_NEARMV + mode;
+}
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #endif  // CONFIG_EXT_INTER
 
 static int read_segment_id(aom_reader *r, struct segmentation_probs *segp) {
   return aom_read_symbol(r, segp->tree_cdf, MAX_SEGMENTS, ACCT_STR);
 }
 
 #if CONFIG_VAR_TX
 static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd,
@@ -583,17 +675,22 @@ static int read_inter_segment_id(AV1_COM
 }
 
 static int read_skip(AV1_COMMON *cm, const MACROBLOCKD *xd, int segment_id,
                      aom_reader *r) {
   if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)) {
     return 1;
   } else {
     const int ctx = av1_get_skip_context(xd);
+#if CONFIG_NEW_MULTISYMBOL
+    FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
+    const int skip = aom_read_symbol(r, ec_ctx->skip_cdfs[ctx], 2, ACCT_STR);
+#else
     const int skip = aom_read(r, cm->fc->skip_probs[ctx], ACCT_STR);
+#endif
     FRAME_COUNTS *counts = xd->counts;
     if (counts) ++counts->skip[ctx][skip];
     return skip;
   }
 }
 
 #if CONFIG_PALETTE
 #if CONFIG_PALETTE_DELTA_ENCODING
@@ -817,17 +914,21 @@ static void read_intra_angle_info(AV1_CO
 #else
   FRAME_CONTEXT *const ec_ctx = cm->fc;
 #endif  // CONFIG_EC_ADAPT
   const int ctx = av1_get_pred_context_intra_interp(xd);
   int p_angle;
 #endif  // CONFIG_INTRA_INTERP
 
   (void)cm;
-  if (bsize < BLOCK_8X8) return;
+
+  mbmi->angle_delta[0] = 0;
+  mbmi->angle_delta[1] = 0;
+
+  if (!av1_use_angle_delta(bsize)) return;
 
   if (av1_is_directional_mode(mbmi->mode, bsize)) {
     mbmi->angle_delta[0] =
         read_uniform(r, 2 * MAX_ANGLE_DELTA + 1) - MAX_ANGLE_DELTA;
 #if CONFIG_INTRA_INTERP
     p_angle = mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP;
     if (av1_is_intra_filter_switchable(p_angle)) {
       FRAME_COUNTS *counts = xd->counts;
@@ -847,26 +948,28 @@ static void read_intra_angle_info(AV1_CO
 }
 #endif  // CONFIG_EXT_INTRA
 
 void av1_read_tx_type(const AV1_COMMON *const cm, MACROBLOCKD *xd,
 #if CONFIG_SUPERTX
                       int supertx_enabled,
 #endif
 #if CONFIG_TXK_SEL
-                      int block, int plane,
+                      int block, int plane, TX_SIZE tx_size,
 #endif
                       aom_reader *r) {
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   const int inter_block = is_inter_block(mbmi);
+#if !CONFIG_TXK_SEL
 #if CONFIG_VAR_TX
   const TX_SIZE tx_size = inter_block ? mbmi->min_tx_size : mbmi->tx_size;
 #else
   const TX_SIZE tx_size = mbmi->tx_size;
 #endif
+#endif  // !CONFIG_TXK_SEL
 #if CONFIG_EC_ADAPT
   FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
 #else
   FRAME_CONTEXT *ec_ctx = cm->fc;
 #endif
 
 #if !CONFIG_TXK_SEL
   TX_TYPE *tx_type = &mbmi->tx_type;
@@ -885,33 +988,32 @@ void av1_read_tx_type(const AV1_COMMON *
          (cm->seg.enabled && xd->qindex[mbmi->segment_id] > 0)) &&
         !mbmi->skip &&
 #if CONFIG_SUPERTX
         !supertx_enabled &&
 #endif  // CONFIG_SUPERTX
         !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
       const int eset = get_ext_tx_set(tx_size, mbmi->sb_type, inter_block,
                                       cm->reduced_tx_set_used);
+      // eset == 0 should correspond to a set with only DCT_DCT and
+      // there is no need to read the tx_type
+      assert(eset != 0);
       FRAME_COUNTS *counts = xd->counts;
 
       if (inter_block) {
-        if (eset > 0) {
-          *tx_type = av1_ext_tx_inter_inv[eset][aom_read_symbol(
-              r, ec_ctx->inter_ext_tx_cdf[eset][square_tx_size],
-              ext_tx_cnt_inter[eset], ACCT_STR)];
-          if (counts) ++counts->inter_ext_tx[eset][square_tx_size][*tx_type];
-        }
+        *tx_type = av1_ext_tx_inter_inv[eset][aom_read_symbol(
+            r, ec_ctx->inter_ext_tx_cdf[eset][square_tx_size],
+            ext_tx_cnt_inter[eset], ACCT_STR)];
+        if (counts) ++counts->inter_ext_tx[eset][square_tx_size][*tx_type];
       } else if (ALLOW_INTRA_EXT_TX) {
-        if (eset > 0) {
-          *tx_type = av1_ext_tx_intra_inv[eset][aom_read_symbol(
-              r, ec_ctx->intra_ext_tx_cdf[eset][square_tx_size][mbmi->mode],
-              ext_tx_cnt_intra[eset], ACCT_STR)];
-          if (counts)
-            ++counts->intra_ext_tx[eset][square_tx_size][mbmi->mode][*tx_type];
-        }
+        *tx_type = av1_ext_tx_intra_inv[eset][aom_read_symbol(
+            r, ec_ctx->intra_ext_tx_cdf[eset][square_tx_size][mbmi->mode],
+            ext_tx_cnt_intra[eset], ACCT_STR)];
+        if (counts)
+          ++counts->intra_ext_tx[eset][square_tx_size][mbmi->mode][*tx_type];
       }
     } else {
       *tx_type = DCT_DCT;
     }
 #else
 
     if (tx_size < TX_32X32 &&
         ((!cm->seg.enabled && cm->base_qindex > 0) ||
@@ -939,32 +1041,33 @@ void av1_read_tx_type(const AV1_COMMON *
     }
 #endif  // CONFIG_EXT_TX
   }
 }
 
 #if CONFIG_INTRABC
 static INLINE void read_mv(aom_reader *r, MV *mv, const MV *ref,
                            nmv_context *ctx, nmv_context_counts *counts,
-                           int allow_hp);
+                           MvSubpelPrecision precision);
 
 static INLINE int is_mv_valid(const MV *mv);
 
 static INLINE int assign_dv(AV1_COMMON *cm, MACROBLOCKD *xd, int_mv *mv,
                             const int_mv *ref_mv, int mi_row, int mi_col,
                             BLOCK_SIZE bsize, aom_reader *r) {
 #if CONFIG_EC_ADAPT
   FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
   (void)cm;
 #else
   FRAME_CONTEXT *ec_ctx = cm->fc;
 #endif
   FRAME_COUNTS *counts = xd->counts;
   nmv_context_counts *const dv_counts = counts ? &counts->dv : NULL;
-  read_mv(r, &mv->as_mv, &ref_mv->as_mv, &ec_ctx->ndvc, dv_counts, 0);
+  read_mv(r, &mv->as_mv, &ref_mv->as_mv, &ec_ctx->ndvc, dv_counts,
+          MV_SUBPEL_NONE);
   int valid = is_mv_valid(&mv->as_mv) &&
               is_dv_valid(mv->as_mv, &xd->tile, mi_row, mi_col, bsize);
   return valid;
 }
 #endif  // CONFIG_INTRABC
 
 static void read_intra_frame_mode_info(AV1_COMMON *const cm,
                                        MACROBLOCKD *const xd, int mi_row,
@@ -1008,22 +1111,22 @@ static void read_intra_frame_mode_info(A
       xd->prev_delta_lf_from_base = xd->current_delta_lf_from_base;
     }
 #endif
   }
 #endif
 
   mbmi->ref_frame[0] = INTRA_FRAME;
   mbmi->ref_frame[1] = NONE_FRAME;
-  mbmi->tx_size = read_tx_size(cm, xd, 0, 1, r);
 
 #if CONFIG_INTRABC
   if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools) {
     mbmi->use_intrabc = aom_read(r, ec_ctx->intrabc_prob, ACCT_STR);
     if (mbmi->use_intrabc) {
+      mbmi->tx_size = read_tx_size(cm, xd, 1, !mbmi->skip, r);
       mbmi->mode = mbmi->uv_mode = DC_PRED;
 #if CONFIG_DUAL_FILTER
       for (int idx = 0; idx < 4; ++idx) mbmi->interp_filter[idx] = BILINEAR;
 #else
       mbmi->interp_filter = BILINEAR;
 #endif
 
       int16_t inter_mode_ctx[MODE_CTX_REF_FRAMES];
@@ -1061,16 +1164,18 @@ static void read_intra_frame_mode_info(A
 #endif
                        r);
 #endif  // CONFIG_EXT_TX && !CONFIG_TXK_SEL
       return;
     }
   }
 #endif  // CONFIG_INTRABC
 
+  mbmi->tx_size = read_tx_size(cm, xd, 0, 1, r);
+
 #if CONFIG_CB4X4
   (void)i;
   mbmi->mode =
       read_intra_mode(r, get_y_mode_cdf(ec_ctx, mi, above_mi, left_mi, 0));
 #else
   switch (bsize) {
     case BLOCK_4X4:
       for (i = 0; i < 4; ++i)
@@ -1102,22 +1207,24 @@ static void read_intra_frame_mode_info(A
     mbmi->uv_mode = read_intra_mode_uv(ec_ctx, xd, r, mbmi->mode);
 #else
   mbmi->uv_mode = read_intra_mode_uv(ec_ctx, xd, r, mbmi->mode);
 #endif
 
 #if CONFIG_CFL
     // TODO(ltrudeau) support PALETTE
     if (mbmi->uv_mode == DC_PRED) {
-      mbmi->cfl_alpha_idx =
-          read_cfl_alphas(ec_ctx, r, mbmi->skip, mbmi->cfl_alpha_signs);
+      mbmi->cfl_alpha_idx = read_cfl_alphas(ec_ctx, r, mbmi->cfl_alpha_signs);
     }
 #endif  // CONFIG_CFL
 
 #if CONFIG_CB4X4
+  } else {
+    // Avoid decoding angle_info if there is is no chroma prediction
+    mbmi->uv_mode = DC_PRED;
   }
 #endif
 
 #if CONFIG_EXT_INTRA
   read_intra_angle_info(cm, xd, r);
 #endif  // CONFIG_EXT_INTRA
 #if CONFIG_PALETTE
   mbmi->palette_mode_info.palette_size[0] = 0;
@@ -1136,17 +1243,21 @@ static void read_intra_frame_mode_info(A
   av1_read_tx_type(cm, xd,
 #if CONFIG_SUPERTX
                    0,
 #endif
                    r);
 #endif  // !CONFIG_TXK_SEL
 }
 
-static int read_mv_component(aom_reader *r, nmv_component *mvcomp, int usehp) {
+static int read_mv_component(aom_reader *r, nmv_component *mvcomp,
+#if CONFIG_INTRABC
+                             int use_subpel,
+#endif  // CONFIG_INTRABC
+                             int usehp) {
   int mag, d, fr, hp;
   const int sign = aom_read(r, mvcomp->sign, ACCT_STR);
   const int mv_class =
       aom_read_symbol(r, mvcomp->class_cdf, MV_CLASSES, ACCT_STR);
   const int class0 = mv_class == MV_CLASS_0;
 
   // Integer part
   if (class0) {
@@ -1156,157 +1267,323 @@ static int read_mv_component(aom_reader 
     int i;
     const int n = mv_class + CLASS0_BITS - 1;  // number of bits
 
     d = 0;
     for (i = 0; i < n; ++i) d |= aom_read(r, mvcomp->bits[i], ACCT_STR) << i;
     mag = CLASS0_SIZE << (mv_class + 2);
   }
 
-  // Fractional part
-  fr = aom_read_symbol(r, class0 ? mvcomp->class0_fp_cdf[d] : mvcomp->fp_cdf,
-                       MV_FP_SIZE, ACCT_STR);
+#if CONFIG_INTRABC
+  if (use_subpel) {
+#endif  // CONFIG_INTRABC
+        // Fractional part
+    fr = aom_read_symbol(r, class0 ? mvcomp->class0_fp_cdf[d] : mvcomp->fp_cdf,
+                         MV_FP_SIZE, ACCT_STR);
 
-  // High precision part (if hp is not used, the default value of the hp is 1)
-  hp = usehp ? aom_read(r, class0 ? mvcomp->class0_hp : mvcomp->hp, ACCT_STR)
-             : 1;
+    // High precision part (if hp is not used, the default value of the hp is 1)
+    hp = usehp ? aom_read(r, class0 ? mvcomp->class0_hp : mvcomp->hp, ACCT_STR)
+               : 1;
+#if CONFIG_INTRABC
+  } else {
+    fr = 3;
+    hp = 1;
+  }
+#endif  // CONFIG_INTRABC
 
   // Result
   mag += ((d << 3) | (fr << 1) | hp) + 1;
   return sign ? -mag : mag;
 }
 
 static INLINE void read_mv(aom_reader *r, MV *mv, const MV *ref,
                            nmv_context *ctx, nmv_context_counts *counts,
-                           int allow_hp) {
+                           MvSubpelPrecision precision) {
   MV_JOINT_TYPE joint_type;
   MV diff = { 0, 0 };
   joint_type =
       (MV_JOINT_TYPE)aom_read_symbol(r, ctx->joint_cdf, MV_JOINTS, ACCT_STR);
 
   if (mv_joint_vertical(joint_type))
-    diff.row = read_mv_component(r, &ctx->comps[0], allow_hp);
+    diff.row = read_mv_component(r, &ctx->comps[0],
+#if CONFIG_INTRABC
+                                 precision > MV_SUBPEL_NONE,
+#endif  // CONFIG_INTRABC
+                                 precision > MV_SUBPEL_LOW_PRECISION);
 
   if (mv_joint_horizontal(joint_type))
-    diff.col = read_mv_component(r, &ctx->comps[1], allow_hp);
+    diff.col = read_mv_component(r, &ctx->comps[1],
+#if CONFIG_INTRABC
+                                 precision > MV_SUBPEL_NONE,
+#endif  // CONFIG_INTRABC
+                                 precision > MV_SUBPEL_LOW_PRECISION);
 
-  av1_inc_mv(&diff, counts, allow_hp);
+  av1_inc_mv(&diff, counts, precision);
 
   mv->row = ref->row + diff.row;
   mv->col = ref->col + diff.col;
 }
 
 static REFERENCE_MODE read_block_reference_mode(AV1_COMMON *cm,
                                                 const MACROBLOCKD *xd,
                                                 aom_reader *r) {
 #if !SUB8X8_COMP_REF
   if (xd->mi[0]->mbmi.sb_type == BLOCK_4X4) return SINGLE_REFERENCE;
 #endif
   if (cm->reference_mode == REFERENCE_MODE_SELECT) {
     const int ctx = av1_get_reference_mode_context(cm, xd);
+#if CONFIG_NEW_MULTISYMBOL
+    const REFERENCE_MODE mode = (REFERENCE_MODE)aom_read_symbol(
+        r, xd->tile_ctx->comp_inter_cdf[ctx], 2, ACCT_STR);
+#else
     const REFERENCE_MODE mode =
         (REFERENCE_MODE)aom_read(r, cm->fc->comp_inter_prob[ctx], ACCT_STR);
+#endif
     FRAME_COUNTS *counts = xd->counts;
     if (counts) ++counts->comp_inter[ctx][mode];
     return mode;  // SINGLE_REFERENCE or COMPOUND_REFERENCE
   } else {
     return cm->reference_mode;
   }
 }
 
+#if CONFIG_NEW_MULTISYMBOL
+#define READ_REF_BIT(pname) \
+  aom_read_symbol(r, av1_get_pred_cdf_##pname(cm, xd), 2, ACCT_STR)
+#else
+#define READ_REF_BIT(pname) \
+  aom_read(r, av1_get_pred_prob_##pname(cm, xd), ACCT_STR)
+#endif
+
+#if CONFIG_EXT_COMP_REFS
+static REFERENCE_MODE read_comp_reference_type(AV1_COMMON *cm,
+                                               const MACROBLOCKD *xd,
+                                               aom_reader *r) {
+  const int ctx = av1_get_comp_reference_type_context(cm, xd);
+#if USE_UNI_COMP_REFS
+  const COMP_REFERENCE_TYPE comp_ref_type = (COMP_REFERENCE_TYPE)aom_read(
+      r, cm->fc->comp_ref_type_prob[ctx], ACCT_STR);
+#else   // !USE_UNI_COMP_REFS
+  // TODO(zoeliu): Temporarily turn off uni-directional comp refs
+  const COMP_REFERENCE_TYPE comp_ref_type = BIDIR_COMP_REFERENCE;
+#endif  // USE_UNI_COMP_REFS
+  FRAME_COUNTS *counts = xd->counts;
+  if (counts) ++counts->comp_ref_type[ctx][comp_ref_type];
+  return comp_ref_type;  // UNIDIR_COMP_REFERENCE or BIDIR_COMP_REFERENCE
+}
+#endif  // CONFIG_EXT_COMP_REFS
+
 // Read the referncence frame
 static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
                             aom_reader *r, int segment_id,
                             MV_REFERENCE_FRAME ref_frame[2]) {
+#if CONFIG_EXT_COMP_REFS
   FRAME_CONTEXT *const fc = cm->fc;
+#endif
   FRAME_COUNTS *counts = xd->counts;
 
   if (segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
     ref_frame[0] = (MV_REFERENCE_FRAME)get_segdata(&cm->seg, segment_id,
                                                    SEG_LVL_REF_FRAME);
     ref_frame[1] = NONE_FRAME;
   } else {
     const REFERENCE_MODE mode = read_block_reference_mode(cm, xd, r);
     // FIXME(rbultje) I'm pretty sure this breaks segmentation ref frame coding
     if (mode == COMPOUND_REFERENCE) {
-#if CONFIG_ONE_SIDED_COMPOUND  // Normative in decoder (for low delay)
+#if CONFIG_EXT_COMP_REFS
+      const COMP_REFERENCE_TYPE comp_ref_type =
+          read_comp_reference_type(cm, xd, r);
+
+#if !USE_UNI_COMP_REFS
+      // TODO(zoeliu): Temporarily turn off uni-directional comp refs
+      assert(comp_ref_type == BIDIR_COMP_REFERENCE);
+#endif  // !USE_UNI_COMP_REFS
+
+      if (comp_ref_type == UNIDIR_COMP_REFERENCE) {
+        const int ctx = av1_get_pred_context_uni_comp_ref_p(cm, xd);
+        const int bit = aom_read(r, fc->uni_comp_ref_prob[ctx][0], ACCT_STR);
+        if (counts) ++counts->uni_comp_ref[ctx][0][bit];
+
+        if (bit) {
+          ref_frame[0] = BWDREF_FRAME;
+          ref_frame[1] = ALTREF_FRAME;
+        } else {
+          const int ctx1 = av1_get_pred_context_uni_comp_ref_p1(cm, xd);
+          const int bit1 =
+              aom_read(r, fc->uni_comp_ref_prob[ctx1][1], ACCT_STR);
+          if (counts) ++counts->uni_comp_ref[ctx1][1][bit1];
+
+          if (bit1) {
+            ref_frame[0] = LAST_FRAME;
+            ref_frame[1] = GOLDEN_FRAME;
+          } else {
+            ref_frame[0] = LAST_FRAME;
+            ref_frame[1] = LAST2_FRAME;
+          }
+        }
+
+        return;
+      }
+#endif  // CONFIG_EXT_COMP_REFS
+
+// Normative in decoder (for low delay)
+#if CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS
       const int idx = 1;
-#else
+#else  // !(CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS)
 #if CONFIG_EXT_REFS
       const int idx = cm->ref_frame_sign_bias[cm->comp_bwd_ref[0]];
-#else
+#else   // !CONFIG_EXT_REFS
       const int idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref];
 #endif  // CONFIG_EXT_REFS
-#endif
+#endif  // CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS
+
       const int ctx = av1_get_pred_context_comp_ref_p(cm, xd);
-
-      const int bit = aom_read(r, fc->comp_ref_prob[ctx][0], ACCT_STR);
+#if CONFIG_VAR_REFS
+      int bit;
+      // Test need to explicitly code (L,L2) vs (L3,G) branch node in tree
+      if (L_OR_L2(cm) && L3_OR_G(cm))
+        bit = READ_REF_BIT(comp_ref_p);
+      else
+        bit = L3_OR_G(cm);
+#else   // !CONFIG_VAR_REFS
+      const int bit = READ_REF_BIT(comp_ref_p);
+#endif  // CONFIG_VAR_REFS
       if (counts) ++counts->comp_ref[ctx][0][bit];
 
 #if CONFIG_EXT_REFS
       // Decode forward references.
       if (!bit) {
         const int ctx1 = av1_get_pred_context_comp_ref_p1(cm, xd);
-        const int bit1 = aom_read(r, fc->comp_ref_prob[ctx1][1], ACCT_STR);
+#if CONFIG_VAR_REFS
+        int bit1;
+        // Test need to explicitly code (L) vs (L2) branch node in tree
+        if (L_AND_L2(cm))
+          bit1 = READ_REF_BIT(comp_ref_p1);
+        else
+          bit1 = LAST_IS_VALID(cm);
+#else   // !CONFIG_VAR_REFS
+        const int bit1 = READ_REF_BIT(comp_ref_p1);
+#endif  // CONFIG_VAR_REFS
         if (counts) ++counts->comp_ref[ctx1][1][bit1];
         ref_frame[!idx] = cm->comp_fwd_ref[bit1 ? 0 : 1];
       } else {
         const int ctx2 = av1_get_pred_context_comp_ref_p2(cm, xd);
-        const int bit2 = aom_read(r, fc->comp_ref_prob[ctx2][2], ACCT_STR);
+#if CONFIG_VAR_REFS
+        int bit2;
+        // Test need to explicitly code (L3) vs (G) branch node in tree
+        if (L3_AND_G(cm))
+          bit2 = READ_REF_BIT(comp_ref_p2);
+        else
+          bit2 = GOLDEN_IS_VALID(cm);
+#else   // !CONFIG_VAR_REFS
+        const int bit2 = READ_REF_BIT(comp_ref_p2);
+#endif  // CONFIG_VAR_REFS
         if (counts) ++counts->comp_ref[ctx2][2][bit2];
         ref_frame[!idx] = cm->comp_fwd_ref[bit2 ? 3 : 2];
       }
 
       // Decode backward references.
-      {
-        const int ctx_bwd = av1_get_pred_context_comp_bwdref_p(cm, xd);
-        const int bit_bwd =
-            aom_read(r, fc->comp_bwdref_prob[ctx_bwd][0], ACCT_STR);
-        if (counts) ++counts->comp_bwdref[ctx_bwd][0][bit_bwd];
-        ref_frame[idx] = cm->comp_bwd_ref[bit_bwd];
-      }
-#else
+      const int ctx_bwd = av1_get_pred_context_comp_bwdref_p(cm, xd);
+#if CONFIG_VAR_REFS
+      int bit_bwd;
+      // Test need to explicitly code (BWD) vs (ALT) branch node in tree
+      if (BWD_AND_ALT(cm))
+        bit_bwd = READ_REF_BIT(comp_bwdref_p);
+      else
+        bit_bwd = ALTREF_IS_VALID(cm);
+#else  // !CONFIG_VAR_REFS
+      const int bit_bwd = READ_REF_BIT(comp_bwdref_p);
+#endif  // CONFIG_VAR_REFS
+      if (counts) ++counts->comp_bwdref[ctx_bwd][0][bit_bwd];
+      ref_frame[idx] = cm->comp_bwd_ref[bit_bwd];
+#else   // !CONFIG_EXT_REFS
       ref_frame[!idx] = cm->comp_var_ref[bit];
       ref_frame[idx] = cm->comp_fixed_ref;
 #endif  // CONFIG_EXT_REFS
     } else if (mode == SINGLE_REFERENCE) {
 #if CONFIG_EXT_REFS
       const int ctx0 = av1_get_pred_context_single_ref_p1(xd);
-      const int bit0 = aom_read(r, fc->single_ref_prob[ctx0][0], ACCT_STR);
+#if CONFIG_VAR_REFS
+      int bit0;
+      // Test need to explicitly code (L,L2,L3,G) vs (BWD,ALT) branch node in
+      // tree
+      if ((L_OR_L2(cm) || L3_OR_G(cm)) && BWD_OR_ALT(cm))
+        bit0 = READ_REF_BIT(single_ref_p1);
+      else
+        bit0 = BWD_OR_ALT(cm);
+#else   // !CONFIG_VAR_REFS
+      const int bit0 = READ_REF_BIT(single_ref_p1);
+#endif  // CONFIG_VAR_REFS
       if (counts) ++counts->single_ref[ctx0][0][bit0];
 
       if (bit0) {
         const int ctx1 = av1_get_pred_context_single_ref_p2(xd);
-        const int bit1 = aom_read(r, fc->single_ref_prob[ctx1][1], ACCT_STR);
+#if CONFIG_VAR_REFS
+        int bit1;
+        // Test need to explicitly code (BWD) vs (ALT) branch node in tree
+        if (BWD_AND_ALT(cm))
+          bit1 = READ_REF_BIT(single_ref_p2);
+        else
+          bit1 = ALTREF_IS_VALID(cm);
+#else  // !CONFIG_VAR_REFS
+        const int bit1 = READ_REF_BIT(single_ref_p2);
+#endif  // CONFIG_VAR_REFS
         if (counts) ++counts->single_ref[ctx1][1][bit1];
         ref_frame[0] = bit1 ? ALTREF_FRAME : BWDREF_FRAME;
       } else {
         const int ctx2 = av1_get_pred_context_single_ref_p3(xd);
-        const int bit2 = aom_read(r, fc->single_ref_prob[ctx2][2], ACCT_STR);
+#if CONFIG_VAR_REFS
+        int bit2;
+        // Test need to explicitly code (L,L2) vs (L3,G) branch node in tree
+        if (L_OR_L2(cm) && L3_OR_G(cm))
+          bit2 = READ_REF_BIT(single_ref_p3);
+        else
+          bit2 = L3_OR_G(cm);
+#else  // !CONFIG_VAR_REFS
+        const int bit2 = READ_REF_BIT(single_ref_p3);
+#endif  // CONFIG_VAR_REFS
         if (counts) ++counts->single_ref[ctx2][2][bit2];
         if (bit2) {
           const int ctx4 = av1_get_pred_context_single_ref_p5(xd);
-          const int bit4 = aom_read(r, fc->single_ref_prob[ctx4][4], ACCT_STR);
+#if CONFIG_VAR_REFS
+          int bit4;
+          // Test need to explicitly code (L3) vs (G) branch node in tree
+          if (L3_AND_G(cm))
+            bit4 = READ_REF_BIT(single_ref_p5);
+          else
+            bit4 = GOLDEN_IS_VALID(cm);
+#else  // !CONFIG_VAR_REFS
+          const int bit4 = READ_REF_BIT(single_ref_p5);
+#endif  // CONFIG_VAR_REFS
           if (counts) ++counts->single_ref[ctx4][4][bit4];
           ref_frame[0] = bit4 ? GOLDEN_FRAME : LAST3_FRAME;
         } else {
           const int ctx3 = av1_get_pred_context_single_ref_p4(xd);
-          const int bit3 = aom_read(r, fc->single_ref_prob[ctx3][3], ACCT_STR);
+#if CONFIG_VAR_REFS
+          int bit3;
+          // Test need to explicitly code (L) vs (L2) branch node in tree
+          if (L_AND_L2(cm))
+            bit3 = READ_REF_BIT(single_ref_p4);
+          else
+            bit3 = LAST2_IS_VALID(cm);
+#else  // !CONFIG_VAR_REFS
+          const int bit3 = READ_REF_BIT(single_ref_p4);
+#endif  // CONFIG_VAR_REFS
           if (counts) ++counts->single_ref[ctx3][3][bit3];
           ref_frame[0] = bit3 ? LAST2_FRAME : LAST_FRAME;
         }
       }
-#else
+#else   // !CONFIG_EXT_REFS
       const int ctx0 = av1_get_pred_context_single_ref_p1(xd);
-      const int bit0 = aom_read(r, fc->single_ref_prob[ctx0][0], ACCT_STR);
+      const int bit0 = READ_REF_BIT(single_ref_p1);
       if (counts) ++counts->single_ref[ctx0][0][bit0];
 
       if (bit0) {
         const int ctx1 = av1_get_pred_context_single_ref_p2(xd);
-        const int bit1 = aom_read(r, fc->single_ref_prob[ctx1][1], ACCT_STR);
+        const int bit1 = READ_REF_BIT(single_ref_p2);
         if (counts) ++counts->single_ref[ctx1][1][bit1];
         ref_frame[0] = bit1 ? ALTREF_FRAME : GOLDEN_FRAME;
       } else {
         ref_frame[0] = LAST_FRAME;
       }
 #endif  // CONFIG_EXT_REFS
 
       ref_frame[1] = NONE_FRAME;
@@ -1431,17 +1708,17 @@ static void read_intra_block_mode_info(A
     // TODO(ltrudeau) support PALETTE
     if (mbmi->uv_mode == DC_PRED) {
       mbmi->cfl_alpha_idx = read_cfl_alphas(
 #if CONFIG_EC_ADAPT
           xd->tile_ctx,
 #else
           cm->fc,
 #endif  // CONFIG_EC_ADAPT
-          r, mbmi->skip, mbmi->cfl_alpha_signs);
+          r, mbmi->cfl_alpha_signs);
     }
 #endif  // CONFIG_CFL
 
 #if CONFIG_CB4X4
   }
 #endif
 
 #if CONFIG_EXT_INTRA
@@ -1545,16 +1822,94 @@ static INLINE int assign_mv(AV1_COMMON *
       if (is_compound) mv[1].as_int = 0;
 #endif  // CONFIG_GLOBAL_MOTION
 
       pred_mv[0].as_int = mv[0].as_int;
       if (is_compound) pred_mv[1].as_int = mv[1].as_int;
       break;
     }
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+    case SR_NEAREST_NEARMV: {
+      assert(!is_compound);
+      mv[0].as_int = nearest_mv[0].as_int;
+      mv[1].as_int = near_mv[0].as_int;
+      break;
+    }
+    /*
+    case SR_NEAREST_NEWMV: {
+      assert(!is_compound);
+      mv[0].as_int = nearest_mv[0].as_int;
+
+      FRAME_COUNTS *counts = xd->counts;
+      int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
+      int nmv_ctx = av1_nmv_ctx(xd->ref_mv_count[rf_type],
+                                xd->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
+      nmv_context *const nmvc = &ec_ctx->nmvc[nmv_ctx];
+      nmv_context_counts *const mv_counts =
+          counts ? &counts->mv[nmv_ctx] : NULL;
+      read_mv(r, &mv[1].as_mv, &ref_mv[0].as_mv, nmvc, mv_counts, allow_hp);
+      ret = ret && is_mv_valid(&mv[1].as_mv);
+      break;
+    }*/
+    case SR_NEAR_NEWMV: {
+      assert(!is_compound);
+      mv[0].as_int = near_mv[0].as_int;
+
+      FRAME_COUNTS *counts = xd->counts;
+      int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
+      int nmv_ctx = av1_nmv_ctx(xd->ref_mv_count[rf_type],
+                                xd->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
+      nmv_context *const nmvc = &ec_ctx->nmvc[nmv_ctx];
+      nmv_context_counts *const mv_counts =
+          counts ? &counts->mv[nmv_ctx] : NULL;
+      read_mv(r, &mv[1].as_mv, &ref_mv[0].as_mv, nmvc, mv_counts, allow_hp);
+      ret = ret && is_mv_valid(&mv[1].as_mv);
+      break;
+    }
+    case SR_ZERO_NEWMV: {
+      assert(!is_compound);
+#if CONFIG_GLOBAL_MOTION
+      mv[0].as_int = gm_get_motion_vector(&cm->global_motion[ref_frame[0]],
+                                          cm->allow_high_precision_mv, bsize,
+                                          mi_col, mi_row, block)
+                         .as_int;
+#else
+      mv[0].as_int = 0;
+#endif  // CONFIG_GLOBAL_MOTION
+
+      FRAME_COUNTS *counts = xd->counts;
+      int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
+      int nmv_ctx = av1_nmv_ctx(xd->ref_mv_count[rf_type],
+                                xd->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
+      nmv_context *const nmvc = &ec_ctx->nmvc[nmv_ctx];
+      nmv_context_counts *const mv_counts =
+          counts ? &counts->mv[nmv_ctx] : NULL;
+      read_mv(r, &mv[1].as_mv, &ref_mv[0].as_mv, nmvc, mv_counts, allow_hp);
+      ret = ret && is_mv_valid(&mv[1].as_mv);
+      break;
+    }
+    case SR_NEW_NEWMV: {
+      assert(!is_compound);
+
+      FRAME_COUNTS *counts = xd->counts;
+      for (i = 0; i < 2; ++i) {
+        int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
+        int nmv_ctx =
+            av1_nmv_ctx(xd->ref_mv_count[rf_type], xd->ref_mv_stack[rf_type], 0,
+                        mbmi->ref_mv_idx);
+        nmv_context *const nmvc = &ec_ctx->nmvc[nmv_ctx];
+        nmv_context_counts *const mv_counts =
+            counts ? &counts->mv[nmv_ctx] : NULL;
+        read_mv(r, &mv[i].as_mv, &ref_mv[0].as_mv, nmvc, mv_counts, allow_hp);
+        ret = ret && is_mv_valid(&mv[i].as_mv);
+      }
+      break;
+    }
+#endif  // CONFIG_COMPOUND_SINGLEREF
     case NEW_NEWMV: {
       FRAME_COUNTS *counts = xd->counts;
       assert(is_compound);
       for (i = 0; i < 2; ++i) {
         int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
         int nmv_ctx =
             av1_nmv_ctx(xd->ref_mv_count[rf_type], xd->ref_mv_stack[rf_type], i,
                         mbmi->ref_mv_idx);
@@ -1659,29 +2014,118 @@ static INLINE int assign_mv(AV1_COMMON *
 }
 
 static int read_is_inter_block(AV1_COMMON *const cm, MACROBLOCKD *const xd,
                                int segment_id, aom_reader *r) {
   if (segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
     return get_segdata(&cm->seg, segment_id, SEG_LVL_REF_FRAME) != INTRA_FRAME;
   } else {
     const int ctx = av1_get_intra_inter_context(xd);
+#if CONFIG_NEW_MULTISYMBOL
+#if CONFIG_EC_ADAPT
+    FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
+#else
+    FRAME_CONTEXT *ec_ctx = cm->fc;
+#endif
+    const int is_inter =
+        aom_read_symbol(r, ec_ctx->intra_inter_cdf[ctx], 2, ACCT_STR);
+#else
     const int is_inter = aom_read(r, cm->fc->intra_inter_prob[ctx], ACCT_STR);
+#endif
     FRAME_COUNTS *counts = xd->counts;
     if (counts) ++counts->intra_inter[ctx][is_inter];
     return is_inter;
   }
 }
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+static int read_is_inter_singleref_comp_mode(AV1_COMMON *const cm,
+                                             MACROBLOCKD *const xd,
+                                             int segment_id, aom_reader *r) {
+  if (segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) return 0;
+
+  const int ctx = av1_get_inter_mode_context(xd);
+  const int is_singleref_comp_mode =
+      aom_read(r, cm->fc->comp_inter_mode_prob[ctx], ACCT_STR);
+  FRAME_COUNTS *counts = xd->counts;
+
+  if (counts) ++counts->comp_inter_mode[ctx][is_singleref_comp_mode];
+  return is_singleref_comp_mode;
+}
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
 static void fpm_sync(void *const data, int mi_row) {
   AV1Decoder *const pbi = (AV1Decoder *)data;
   av1_frameworker_wait(pbi->frame_worker_owner, pbi->common.prev_frame,
                        mi_row << pbi->common.mib_size_log2);
 }
 
+#if DEC_MISMATCH_DEBUG
+static void dec_dump_logs(AV1_COMMON *cm, MODE_INFO *const mi,
+                          MACROBLOCKD *const xd, int mi_row, int mi_col,
+                          int16_t inter_mode_ctx[MODE_CTX_REF_FRAMES],
+                          int16_t mode_ctx) {
+  int_mv mv[2] = { { 0 } };
+  int ref;
+  MB_MODE_INFO *const mbmi = &mi->mbmi;
+  for (ref = 0; ref < 1 + has_second_ref(mbmi); ++ref)
+    mv[ref].as_mv = mbmi->mv[ref].as_mv;
+
+  int interp_ctx[2] = { -1 };
+  int interp_filter[2] = { cm->interp_filter };
+  if (cm->interp_filter == SWITCHABLE) {
+    int dir;
+    for (dir = 0; dir < 2; ++dir) {
+      if (has_subpel_mv_component(xd->mi[0], xd, dir) ||
+          (mbmi->ref_frame[1] > INTRA_FRAME &&
+           has_subpel_mv_component(xd->mi[0], xd, dir + 2))) {
+        interp_ctx[dir] = av1_get_pred_context_switchable_interp(xd, dir);
+        interp_filter[dir] = mbmi->interp_filter[dir];
+      } else {
+        interp_filter[dir] = EIGHTTAP_REGULAR;
+      }
+    }
+  }
+
+  const int16_t newmv_ctx = mode_ctx & NEWMV_CTX_MASK;
+  int16_t zeromv_ctx = -1;
+  int16_t refmv_ctx = -1;
+  if (mbmi->mode != NEWMV) {
+    if (mode_ctx & (1 << ALL_ZERO_FLAG_OFFSET)) assert(mbmi->mode == ZEROMV);
+    zeromv_ctx = (mode_ctx >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK;
+    if (mbmi->mode != ZEROMV) {
+      refmv_ctx = (mode_ctx >> REFMV_OFFSET) & REFMV_CTX_MASK;
+      if (mode_ctx & (1 << SKIP_NEARESTMV_OFFSET)) refmv_ctx = 6;
+      if (mode_ctx & (1 << SKIP_NEARMV_OFFSET)) refmv_ctx = 7;
+      if (mode_ctx & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) refmv_ctx = 8;
+    }
+  }
+
+  int8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
+#define FRAME_TO_CHECK 1
+  if (cm->current_video_frame == FRAME_TO_CHECK
+      // && cm->show_frame == 0
+      ) {
+    printf(
+        "=== DECODER ===: "
+        "Frame=%d, (mi_row,mi_col)=(%d,%d), mode=%d, bsize=%d, "
+        "show_frame=%d, mv[0]=(%d,%d), mv[1]=(%d,%d), ref[0]=%d, "
+        "ref[1]=%d, motion_mode=%d, inter_mode_ctx=%d, mode_ctx=%d, "
+        "interp_ctx=(%d,%d), interp_filter=(%d,%d), newmv_ctx=%d, "
+        "zeromv_ctx=%d, refmv_ctx=%d\n",
+        cm->current_video_frame, mi_row, mi_col, mbmi->mode, mbmi->sb_type,
+        cm->show_frame, mv[0].as_mv.row, mv[0].as_mv.col, mv[1].as_mv.row,
+        mv[1].as_mv.col, mbmi->ref_frame[0], mbmi->ref_frame[1],
+        mbmi->motion_mode, inter_mode_ctx[ref_frame_type], mode_ctx,
+        interp_ctx[0], interp_ctx[1], interp_filter[0], interp_filter[1],
+        newmv_ctx, zeromv_ctx, refmv_ctx);
+  }
+}
+#endif  // DEC_MISMATCH_DEBUG
+
 static void read_inter_block_mode_info(AV1Decoder *const pbi,
                                        MACROBLOCKD *const xd,
                                        MODE_INFO *const mi,
 #if (CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION || CONFIG_EXT_INTER) && \
     CONFIG_SUPERTX
                                        int mi_row, int mi_col, aom_reader *r,
                                        int supertx_enabled) {
 #else
@@ -1690,16 +2134,19 @@ static void read_inter_block_mode_info(A
   AV1_COMMON *const cm = &pbi->common;
   MB_MODE_INFO *const mbmi = &mi->mbmi;
   const BLOCK_SIZE bsize = mbmi->sb_type;
   const int allow_hp = cm->allow_high_precision_mv;
   const int unify_bsize = CONFIG_CB4X4;
   int_mv nearestmv[2], nearmv[2];
   int_mv ref_mvs[MODE_CTX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
   int ref, is_compound;
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  int is_singleref_comp_mode = 0;
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   int16_t inter_mode_ctx[MODE_CTX_REF_FRAMES];
 #if CONFIG_EXT_INTER
   int16_t compound_inter_mode_ctx[MODE_CTX_REF_FRAMES];
 #endif  // CONFIG_EXT_INTER
   int16_t mode_ctx = 0;
 #if CONFIG_WARPED_MOTION
   int pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
 #endif  // CONFIG_WARPED_MOTION
@@ -1716,16 +2163,31 @@ static void read_inter_block_mode_info(A
   mbmi->palette_mode_info.palette_size[1] = 0;
 #endif  // CONFIG_PALETTE
 
   memset(ref_mvs, 0, sizeof(ref_mvs));
 
   read_ref_frames(cm, xd, r, mbmi->segment_id, mbmi->ref_frame);
   is_compound = has_second_ref(mbmi);
 
+#if CONFIG_EXT_COMP_REFS
+#if !USE_UNI_COMP_REFS
+  // NOTE: uni-directional comp refs disabled
+  if (is_compound)
+    assert(mbmi->ref_frame[0] < BWDREF_FRAME &&
+           mbmi->ref_frame[1] >= BWDREF_FRAME);
+#endif  // !USE_UNI_COMP_REFS
+#endif  // CONFIG_EXT_COMP_REFS
+
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  if (!is_compound)
+    is_singleref_comp_mode =
+        read_is_inter_singleref_comp_mode(cm, xd, mbmi->segment_id, r);
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
   for (ref = 0; ref < 1 + is_compound; ++ref) {
     MV_REFERENCE_FRAME frame = mbmi->ref_frame[ref];
 
     av1_find_mv_refs(
         cm, xd, mi, frame, &xd->ref_mv_count[frame], xd->ref_mv_stack[frame],
 #if CONFIG_EXT_INTER
         compound_inter_mode_ctx,
 #endif  // CONFIG_EXT_INTER
@@ -1767,46 +2229,57 @@ static void read_inter_block_mode_info(A
         if (ref_mvs[rf[ref]][0].as_int != zeromv[ref].as_int ||
             ref_mvs[rf[ref]][1].as_int != zeromv[ref].as_int)
           inter_mode_ctx[ref_frame] &= ~(1 << ALL_ZERO_FLAG_OFFSET);
       }
     }
   }
 
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+  if (is_compound || is_singleref_comp_mode)
+#else   // !CONFIG_COMPOUND_SINGLEREF
   if (is_compound)
+#endif  // CONFIG_COMPOUND_SINGLEREF
     mode_ctx = compound_inter_mode_ctx[mbmi->ref_frame[0]];
   else
 #endif  // CONFIG_EXT_INTER
     mode_ctx =
         av1_mode_context_analyzer(inter_mode_ctx, mbmi->ref_frame, bsize, -1);
   mbmi->ref_mv_idx = 0;
 
   if (segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
     mbmi->mode = ZEROMV;
     if (bsize < BLOCK_8X8 && !unify_bsize) {
       aom_internal_error(xd->error_info, AOM_CODEC_UNSUP_BITSTREAM,
-                         "Invalid usage of segement feature on small blocks");
+                         "Invalid usage of segment feature on small blocks");
       return;
     }
   } else {
     if (bsize >= BLOCK_8X8 || unify_bsize) {
 #if CONFIG_EXT_INTER
       if (is_compound)
         mbmi->mode = read_inter_compound_mode(cm, xd, r, mode_ctx);
+#if CONFIG_COMPOUND_SINGLEREF
+      else if (is_singleref_comp_mode)
+        mbmi->mode = read_inter_singleref_comp_mode(cm, xd, r, mode_ctx);
+#endif  // CONFIG_COMPOUND_SINGLEREF
       else
 #endif  // CONFIG_EXT_INTER
         mbmi->mode = read_inter_mode(ec_ctx, xd, r, mode_ctx);
 #if CONFIG_EXT_INTER
       if (mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV ||
+#if CONFIG_COMPOUND_SINGLEREF
+          mbmi->mode == SR_NEW_NEWMV ||
+#endif  // CONFIG_COMPOUND_SINGLEREF
           have_nearmv_in_inter_mode(mbmi->mode))
-#else
+#else  // !CONFIG_EXT_INTER
       if (mbmi->mode == NEARMV || mbmi->mode == NEWMV)
-#endif
-        read_drl_idx(cm, xd, mbmi, r);
+#endif  // CONFIG_EXT_INTER
+        read_drl_idx(ec_ctx, xd, mbmi, r);
     }
   }
 
 #if CONFIG_EXT_INTER
   if ((bsize < BLOCK_8X8 && unify_bsize) ||
       (mbmi->mode != ZEROMV && mbmi->mode != ZERO_ZEROMV)) {
 #else
   if ((bsize < BLOCK_8X8 && !unify_bsize) || mbmi->mode != ZEROMV) {
@@ -1819,19 +2292,24 @@ static void read_inter_block_mode_info(A
 
   if (mbmi->ref_mv_idx > 0) {
     int_mv cur_mv =
         xd->ref_mv_stack[mbmi->ref_frame[0]][1 + mbmi->ref_mv_idx].this_mv;
     nearmv[0] = cur_mv;
   }
 
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+  if ((is_compound || is_singleref_comp_mode) &&
+      (bsize >= BLOCK_8X8 || unify_bsize) && mbmi->mode != ZERO_ZEROMV) {
+#else   // !CONFIG_COMPOUND_SINGLEREF
   if (is_compound && (bsize >= BLOCK_8X8 || unify_bsize) &&
       mbmi->mode != ZERO_ZEROMV) {
-#else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+#else   // !CONFIG_EXT_INTER
   if (is_compound && (bsize >= BLOCK_8X8 || unify_bsize) &&
       mbmi->mode != NEWMV && mbmi->mode != ZEROMV) {
 #endif  // CONFIG_EXT_INTER
     uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
 
 #if CONFIG_EXT_INTER
     if (xd->ref_mv_count[ref_frame_type] > 0) {
 #else
@@ -1840,40 +2318,58 @@ static void read_inter_block_mode_info(A
 #if CONFIG_EXT_INTER
       if (mbmi->mode == NEAREST_NEARESTMV) {
 #endif  // CONFIG_EXT_INTER
         nearestmv[0] = xd->ref_mv_stack[ref_frame_type][0].this_mv;
         nearestmv[1] = xd->ref_mv_stack[ref_frame_type][0].comp_mv;
         lower_mv_precision(&nearestmv[0].as_mv, allow_hp);
         lower_mv_precision(&nearestmv[1].as_mv, allow_hp);
 #if CONFIG_EXT_INTER
-      } else if (mbmi->mode == NEAREST_NEWMV) {
+      } else if (mbmi->mode == NEAREST_NEWMV
+#if CONFIG_COMPOUND_SINGLEREF
+                 || mbmi->mode == SR_NEAREST_NEARMV
+// || mbmi->mode == SR_NEAREST_NEWMV
+#endif  // CONFIG_COMPOUND_SINGLEREF
+                 ) {
         nearestmv[0] = xd->ref_mv_stack[ref_frame_type][0].this_mv;
         lower_mv_precision(&nearestmv[0].as_mv, allow_hp);
       } else if (mbmi->mode == NEW_NEARESTMV) {
         nearestmv[1] = xd->ref_mv_stack[ref_frame_type][0].comp_mv;
         lower_mv_precision(&nearestmv[1].as_mv, allow_hp);
       }
 #endif  // CONFIG_EXT_INTER
     }
 
 #if CONFIG_EXT_INTER
     if (xd->ref_mv_count[ref_frame_type] > 1) {
       int ref_mv_idx = 1 + mbmi->ref_mv_idx;
-      if (compound_ref0_mode(mbmi->mode) == NEARMV) {
-        nearmv[0] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
-        lower_mv_precision(&nearmv[0].as_mv, allow_hp);
-      }
+#if CONFIG_COMPOUND_SINGLEREF
+      if (is_compound) {
+#endif  // CONFIG_COMPOUND_SINGLEREF
+        if (compound_ref0_mode(mbmi->mode) == NEARMV) {
+          nearmv[0] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
+          lower_mv_precision(&nearmv[0].as_mv, allow_hp);
+        }
 
-      if (compound_ref1_mode(mbmi->mode) == NEARMV) {
-        nearmv[1] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
-        lower_mv_precision(&nearmv[1].as_mv, allow_hp);
+        if (compound_ref1_mode(mbmi->mode) == NEARMV) {
+          nearmv[1] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
+          lower_mv_precision(&nearmv[1].as_mv, allow_hp);
+        }
+#if CONFIG_COMPOUND_SINGLEREF
+      } else {
+        assert(is_singleref_comp_mode);
+        if (compound_ref0_mode(mbmi->mode) == NEARMV ||
+            compound_ref1_mode(mbmi->mode) == NEARMV) {
+          nearmv[0] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
+          lower_mv_precision(&nearmv[0].as_mv, allow_hp);
+        }
       }
+#endif  // CONFIG_COMPOUND_SINGLEREF
     }
-#else
+#else   // !CONFIG_EXT_INTER
     if (xd->ref_mv_count[ref_frame_type] > 1) {
       int ref_mv_idx = 1 + mbmi->ref_mv_idx;
       nearestmv[0] = xd->ref_mv_stack[ref_frame_type][0].this_mv;
       nearestmv[1] = xd->ref_mv_stack[ref_frame_type][0].comp_mv;
       nearmv[0] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
       nearmv[1] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
     }
 #endif  // CONFIG_EXT_INTER
@@ -2003,16 +2499,36 @@ static void read_inter_block_mode_info(A
         uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
         if (xd->ref_mv_count[ref_frame_type] > 1) {
           ref_mv[1] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
           clamp_mv_ref(&ref_mv[1].as_mv, xd->n8_w << MI_SIZE_LOG2,
                        xd->n8_h << MI_SIZE_LOG2, xd);
         }
         nearestmv[1] = ref_mv[1];
       }
+#if CONFIG_COMPOUND_SINGLEREF
+    } else if (is_singleref_comp_mode) {
+      int ref_mv_idx = mbmi->ref_mv_idx;
+      // Special case: SR_NEAR_NEWMV use 1 + mbmi->ref_mv_idx (like NEARMV)
+      //               instead of mbmi->ref_mv_idx (like NEWMV)
+      if (mbmi->mode == SR_NEAR_NEWMV) ref_mv_idx = 1 + mbmi->ref_mv_idx;
+
+      if (compound_ref0_mode(mbmi->mode) == NEWMV ||
+          compound_ref1_mode(mbmi->mode) == NEWMV) {
+        uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
+        if (xd->ref_mv_count[ref_frame_type] > 1) {
+          ref_mv[0] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
+          clamp_mv_ref(&ref_mv[0].as_mv, xd->n8_w << MI_SIZE_LOG2,
+                       xd->n8_h << MI_SIZE_LOG2, xd);
+        }
+        // TODO(zoeliu): To further investigate why this would not cause a
+        //               mismatch for the mode of SR_NEAREST_NEWMV.
+        nearestmv[0] = ref_mv[0];
+      }
+#endif  // CONFIG_COMPOUND_SINGLEREF
     } else {
 #endif  // CONFIG_EXT_INTER
       if (mbmi->mode == NEWMV) {
         for (ref = 0; ref < 1 + is_compound; ++ref) {
           uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
           if (xd->ref_mv_count[ref_frame_type] > 1) {
             ref_mv[ref] =
                 (ref == 0)
@@ -2038,18 +2554,23 @@ static void read_inter_block_mode_info(A
 #if CONFIG_EXT_INTER && CONFIG_INTERINTRA
   mbmi->use_wedge_interintra = 0;
   if (cm->reference_mode != COMPOUND_REFERENCE &&
 #if CONFIG_SUPERTX
       !supertx_enabled &&
 #endif
       cm->allow_interintra_compound && is_interintra_allowed(mbmi)) {
     const int bsize_group = size_group_lookup[bsize];
+#if CONFIG_NEW_MULTISYMBOL
+    const int interintra =
+        aom_read_symbol(r, ec_ctx->interintra_cdf[bsize_group], 2, ACCT_STR);
+#else
     const int interintra =
         aom_read(r, cm->fc->interintra_prob[bsize_group], ACCT_STR);
+#endif
     if (xd->counts) xd->counts->interintra[bsize_group][interintra]++;
     assert(mbmi->ref_frame[1] == NONE_FRAME);
     if (interintra) {
       const INTERINTRA_MODE interintra_mode =
           read_interintra_mode(cm, xd, r, bsize_group);
       mbmi->ref_frame[1] = INTRA_FRAME;
       mbmi->interintra_mode = interintra_mode;
 #if CONFIG_EXT_INTRA
@@ -2059,18 +2580,23 @@ static void read_inter_block_mode_info(A
       mbmi->intra_filter = INTRA_FILTER_LINEAR;
 #endif  // CONFIG_INTRA_INTERP
 #endif  // CONFIG_EXT_INTRA
 #if CONFIG_FILTER_INTRA
       mbmi->filter_intra_mode_info.use_filter_intra_mode[0] = 0;
       mbmi->filter_intra_mode_info.use_filter_intra_mode[1] = 0;
 #endif  // CONFIG_FILTER_INTRA
       if (is_interintra_wedge_used(bsize)) {
+#if CONFIG_NEW_MULTISYMBOL
+        mbmi->use_wedge_interintra = aom_read_symbol(
+            r, ec_ctx->wedge_interintra_cdf[bsize], 2, ACCT_STR);
+#else
         mbmi->use_wedge_interintra =
             aom_read(r, cm->fc->wedge_interintra_prob[bsize], ACCT_STR);
+#endif
         if (xd->counts)
           xd->counts->wedge_interintra[bsize][mbmi->use_wedge_interintra]++;
         if (mbmi->use_wedge_interintra) {
           mbmi->interintra_wedge_index =
               aom_read_literal(r, get_wedge_bits_lookup(bsize), ACCT_STR);
           mbmi->interintra_wedge_sign = 0;
         }
       }
@@ -2090,45 +2616,63 @@ static void read_inter_block_mode_info(A
 
 #if CONFIG_SUPERTX
   if (!supertx_enabled) {
 #endif  // CONFIG_SUPERTX
 #if CONFIG_EXT_INTER
     if (mbmi->ref_frame[1] != INTRA_FRAME)
 #endif  // CONFIG_EXT_INTER
       mbmi->motion_mode = read_motion_mode(cm, xd, mi, r);
+
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+    read_ncobmc_mode(cm, xd, mi, mbmi->ncobmc_mode, r);
+#endif
+
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    if (is_singleref_comp_mode) assert(mbmi->motion_mode == SIMPLE_TRANSLATION);
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_WARPED_MOTION
     if (mbmi->motion_mode == WARPED_CAUSAL) {
       mbmi->wm_params[0].wmtype = DEFAULT_WMTYPE;
       if (find_projection(mbmi->num_proj_ref[0], pts, pts_inref, bsize,
                           mbmi->mv[0].as_mv.row, mbmi->mv[0].as_mv.col,
                           &mbmi->wm_params[0], mi_row, mi_col)) {
-        assert(0 && "Invalid Warped Model.");
+        aom_internal_error(&cm->error, AOM_CODEC_ERROR, "Invalid Warped Model");
       }
     }
 #endif  // CONFIG_WARPED_MOTION
 #if CONFIG_SUPERTX
   }
 #endif  // CONFIG_SUPERTX
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
 #if CONFIG_EXT_INTER
   mbmi->interinter_compound_type = COMPOUND_AVERAGE;
-  if (cm->reference_mode != SINGLE_REFERENCE &&
+  if (
+#if CONFIG_COMPOUND_SINGLEREF
+      is_inter_anyref_comp_mode(mbmi->mode)
+#else   // !CONFIG_COMPOUND_SINGLEREF
+      cm->reference_mode != SINGLE_REFERENCE &&
       is_inter_compound_mode(mbmi->mode)
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
       && mbmi->motion_mode == SIMPLE_TRANSLATION
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
       ) {
     if (is_any_masked_compound_used(bsize)) {
 #if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
       if (cm->allow_masked_compound) {
+#if CONFIG_EC_ADAPT
+        mbmi->interinter_compound_type = aom_read_symbol(
+            r, ec_ctx->compound_type_cdf[bsize], COMPOUND_TYPES, ACCT_STR);
+#else
         mbmi->interinter_compound_type =
             aom_read_tree(r, av1_compound_type_tree,
                           cm->fc->compound_type_prob[bsize], ACCT_STR);
+#endif
 #if CONFIG_WEDGE
         if (mbmi->interinter_compound_type == COMPOUND_WEDGE) {
           mbmi->wedge_index =
               aom_read_literal(r, get_wedge_bits_lookup(bsize), ACCT_STR);
           mbmi->wedge_sign = aom_read_bit(r, ACCT_STR);
         }
 #endif  // CONFIG_WEDGE
 #if CONFIG_COMPOUND_SEGMENT
@@ -2144,16 +2688,21 @@ static void read_inter_block_mode_info(A
     if (xd->counts)
       xd->counts->compound_interinter[bsize][mbmi->interinter_compound_type]++;
   }
 #endif  // CONFIG_EXT_INTER
 
 #if CONFIG_DUAL_FILTER || CONFIG_WARPED_MOTION || CONFIG_GLOBAL_MOTION
   read_mb_interp_filter(cm, xd, mbmi, r);
 #endif  // CONFIG_DUAL_FILTER || CONFIG_WARPED_MOTION
+
+#if DEC_MISMATCH_DEBUG
+  // NOTE(zoeliu): For debug
+  dec_dump_logs(cm, mi, xd, mi_row, mi_col, inter_mode_ctx, mode_ctx);
+#endif  // DEC_MISMATCH_DEBUG
 }
 
 static void read_inter_frame_mode_info(AV1Decoder *const pbi,
                                        MACROBLOCKD *const xd,
 #if CONFIG_SUPERTX
                                        int supertx_enabled,
 #endif  // CONFIG_SUPERTX
                                        int mi_row, int mi_col, aom_reader *r) {
--- a/third_party/aom/av1/decoder/decodemv.h
+++ b/third_party/aom/av1/decoder/decodemv.h
@@ -32,13 +32,13 @@ void av1_read_mode_info(AV1Decoder *cons
 }  // extern "C"
 #endif
 
 void av1_read_tx_type(const AV1_COMMON *const cm, MACROBLOCKD *xd,
 #if CONFIG_SUPERTX
                       int supertx_enabled,
 #endif
 #if CONFIG_TXK_SEL
-                      int block, int plane,
+                      int block, int plane, TX_SIZE tx_size,
 #endif
                       aom_reader *r);
 
 #endif  // AV1_DECODER_DECODEMV_H_
--- a/third_party/aom/av1/decoder/decoder.c
+++ b/third_party/aom/av1/decoder/decoder.c
@@ -45,33 +45,33 @@ static void initialize_dec(void) {
     av1_rtcd();
     aom_dsp_rtcd();
     aom_scale_rtcd();
     av1_init_intra_predictors();
 #if CONFIG_EXT_INTER
     av1_init_wedge_masks();
 #endif  // CONFIG_EXT_INTER
     init_done = 1;
+#if !CONFIG_EC_ADAPT
     av1_indices_from_tree(av1_intra_mode_ind, av1_intra_mode_inv,
                           av1_intra_mode_tree);
+#endif
     av1_indices_from_tree(av1_switchable_interp_ind, av1_switchable_interp_inv,
                           av1_switchable_interp_tree);
 #if CONFIG_EXT_TX
     int s;
     for (s = 1; s < EXT_TX_SETS_INTRA; ++s)
       av1_indices_from_tree(av1_ext_tx_intra_ind[s], av1_ext_tx_intra_inv[s],
                             av1_ext_tx_intra_tree[s]);
     for (s = 1; s < EXT_TX_SETS_INTER; ++s)
       av1_indices_from_tree(av1_ext_tx_inter_ind[s], av1_ext_tx_inter_inv[s],
                             av1_ext_tx_inter_tree[s]);
 #else
     av1_indices_from_tree(av1_ext_tx_ind, av1_ext_tx_inv, av1_ext_tx_tree);
 #endif
-    av1_indices_from_tree(av1_inter_mode_ind, av1_inter_mode_inv,
-                          av1_inter_mode_tree);
   }
 }
 
 static void av1_dec_setup_mi(AV1_COMMON *cm) {
   cm->mi = cm->mip + cm->mi_stride + 1;
   cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1;
   memset(cm->mi_grid_base, 0,
          cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mi_grid_base));
@@ -441,17 +441,20 @@ int av1_receive_compressed_data(AV1Decod
   swap_frame_buffers(pbi);
 
 #if CONFIG_EXT_TILE
   // For now, we only extend the frame borders when the whole frame is decoded.
   // Later, if needed, extend the border for the decoded tile on the frame
   // border.
   if (pbi->dec_tile_row == -1 && pbi->dec_tile_col == -1)
 #endif  // CONFIG_EXT_TILE
-    aom_extend_frame_inner_borders(cm->frame_to_show);
+    // TODO(debargha): Fix encoder side mv range, so that we can use the
+    // inner border extension. As of now use the larger extension.
+    // aom_extend_frame_inner_borders(cm->frame_to_show);
+    aom_extend_frame_borders(cm->frame_to_show);
 
   aom_clear_system_state();
 
   if (!cm->show_existing_frame) {
     cm->last_show_frame = cm->show_frame;
 
 #if CONFIG_EXT_REFS
     // NOTE: It is not supposed to ref to any frame not used as reference
@@ -495,17 +498,16 @@ int av1_get_raw_frame(AV1Decoder *pbi, Y
   int ret = -1;
   if (pbi->ready_for_new_data == 1) return ret;
 
   pbi->ready_for_new_data = 1;
 
   /* no raw frame to show!!! */
   if (!cm->show_frame) return ret;
 
-  pbi->ready_for_new_data = 1;
   *sd = *cm->frame_to_show;
   ret = 0;
   aom_clear_system_state();
   return ret;
 }
 
 int av1_get_frame_to_show(AV1Decoder *pbi, YV12_BUFFER_CONFIG *frame) {
   AV1_COMMON *const cm = &pbi->common;
@@ -513,54 +515,56 @@ int av1_get_frame_to_show(AV1Decoder *pb
   if (!cm->show_frame || !cm->frame_to_show) return -1;
 
   *frame = *cm->frame_to_show;
   return 0;
 }
 
 aom_codec_err_t av1_parse_superframe_index(const uint8_t *data, size_t data_sz,
                                            uint32_t sizes[8], int *count,
+                                           int *index_size,
                                            aom_decrypt_cb decrypt_cb,
                                            void *decrypt_state) {
   // A chunk ending with a byte matching 0xc0 is an invalid chunk unless
   // it is a super frame index. If the last byte of real video compression
   // data is 0xc0 the encoder must add a 0 byte. If we have the marker but
   // not the associated matching marker byte at the front of the index we have
   // an invalid bitstream and need to return an error.
 
   uint8_t marker;
   size_t frame_sz_sum = 0;
 
   assert(data_sz);
-  marker = read_marker(decrypt_cb, decrypt_state, data + data_sz - 1);
+  marker = read_marker(decrypt_cb, decrypt_state, data);
   *count = 0;
 
   if ((marker & 0xe0) == 0xc0) {
     const uint32_t frames = (marker & 0x7) + 1;
     const uint32_t mag = ((marker >> 3) & 0x3) + 1;
     const size_t index_sz = 2 + mag * (frames - 1);
+    *index_size = (int)index_sz;
 
     // This chunk is marked as having a superframe index but doesn't have
     // enough data for it, thus it's an invalid superframe index.
     if (data_sz < index_sz) return AOM_CODEC_CORRUPT_FRAME;
 
     {
       const uint8_t marker2 =
-          read_marker(decrypt_cb, decrypt_state, data + data_sz - index_sz);
+          read_marker(decrypt_cb, decrypt_state, data + index_sz - 1);
 
       // This chunk is marked as having a superframe index but doesn't have
       // the matching marker byte at the front of the index therefore it's an
       // invalid chunk.
       if (marker != marker2) return AOM_CODEC_CORRUPT_FRAME;
     }
 
     {
       // Found a valid superframe index.
       uint32_t i, j;
-      const uint8_t *x = &data[data_sz - index_sz + 1];
+      const uint8_t *x = &data[1];
 
       // Frames has a maximum of 8 and mag has a maximum of 4.
       uint8_t clear_buffer[28];
       assert(sizeof(clear_buffer) >= (frames - 1) * mag);
       if (decrypt_cb) {
         decrypt_cb(decrypt_state, x, clear_buffer, (frames - 1) * mag);
         x = clear_buffer;
       }
--- a/third_party/aom/av1/decoder/decoder.h
+++ b/third_party/aom/av1/decoder/decoder.h
@@ -117,16 +117,17 @@ typedef struct AV1Decoder {
 
   TileBufferDec tile_buffers[MAX_TILE_ROWS][MAX_TILE_COLS];
 
   AV1LfSync lf_row_sync;
 
   aom_decrypt_cb decrypt_cb;
   void *decrypt_state;
 
+  int allow_lowbitdepth;
   int max_threads;
   int inv_tile_order;
   int need_resync;   // wait for key/intra-only frame.
   int hold_ref_buf;  // hold the reference buffer.
 
   int tile_size_bytes;
 #if CONFIG_EXT_TILE
   int tile_col_size_bytes;
@@ -176,16 +177,17 @@ static INLINE uint8_t read_marker(aom_de
   }
   return *data;
 }
 
 // This function is exposed for use in tests, as well as the inlined function
 // "read_marker".
 aom_codec_err_t av1_parse_superframe_index(const uint8_t *data, size_t data_sz,
                                            uint32_t sizes[8], int *count,
+                                           int *index_size,
                                            aom_decrypt_cb decrypt_cb,
                                            void *decrypt_state);
 
 struct AV1Decoder *av1_decoder_create(BufferPool *const pool);
 
 void av1_decoder_remove(struct AV1Decoder *pbi);
 
 static INLINE void decrease_ref_count(int idx, RefCntBuffer *const frame_bufs,
--- a/third_party/aom/av1/decoder/decodetxb.c
+++ b/third_party/aom/av1/decoder/decodetxb.c
@@ -39,155 +39,156 @@ static int read_golomb(MACROBLOCKD *xd, 
   }
 
   return x - 1;
 }
 
 uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
                             aom_reader *r, int block, int plane,
                             tran_low_t *tcoeffs, TXB_CTX *txb_ctx,
-                            int16_t *max_scan_line, int *eob) {
+                            TX_SIZE tx_size, int16_t *max_scan_line, int *eob) {
   FRAME_COUNTS *counts = xd->counts;
-  TX_SIZE tx_size = get_tx_size(plane, xd);
+  TX_SIZE txs_ctx = get_txsize_context(tx_size);
   PLANE_TYPE plane_type = get_plane_type(plane);
-  aom_prob *nz_map = cm->fc->nz_map[tx_size][plane_type];
-  aom_prob *eob_flag = cm->fc->eob_flag[tx_size][plane_type];
+  aom_prob *nz_map = cm->fc->nz_map[txs_ctx][plane_type];
+  aom_prob *eob_flag = cm->fc->eob_flag[txs_ctx][plane_type];
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   const int seg_eob = tx_size_2d[tx_size];
   int c = 0;
   int update_eob = -1;
   const int16_t *const dequant = xd->plane[plane].seg_dequant[mbmi->segment_id];
   const int shift = av1_get_tx_scale(tx_size);
   const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
+  const int height = tx_size_high[tx_size];
   int cul_level = 0;
   unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2];
   uint8_t txb_mask[32 * 32] = { 0 };
 
-  nz_map_count = (counts) ? &counts->nz_map[tx_size][plane_type] : NULL;
+  nz_map_count = (counts) ? &counts->nz_map[txs_ctx][plane_type] : NULL;
 
   memset(tcoeffs, 0, sizeof(*tcoeffs) * seg_eob);
 
   int all_zero =
-      aom_read(r, cm->fc->txb_skip[tx_size][txb_ctx->txb_skip_ctx], ACCT_STR);
+      aom_read(r, cm->fc->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx], ACCT_STR);
   if (xd->counts)
-    ++xd->counts->txb_skip[tx_size][txb_ctx->txb_skip_ctx][all_zero];
+    ++xd->counts->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx][all_zero];
 
   *eob = 0;
   if (all_zero) {
     *max_scan_line = 0;
     return 0;
   }
 
 #if CONFIG_TXK_SEL
-  av1_read_tx_type(cm, xd, block, plane, r);
+  av1_read_tx_type(cm, xd, block, plane, get_min_tx_size(tx_size), r);
 #endif
   TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
-  const SCAN_ORDER *const scan_order =
-      get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
+  const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
   const int16_t *scan = scan_order->scan;
 
   for (c = 0; c < seg_eob; ++c) {
     int is_nz;
-    int coeff_ctx = get_nz_map_ctx(tcoeffs, txb_mask, scan[c], bwl);
-    int eob_ctx = get_eob_ctx(tcoeffs, scan[c], bwl);
+    int coeff_ctx = get_nz_map_ctx(tcoeffs, txb_mask, scan[c], bwl, height);
+    int eob_ctx = get_eob_ctx(tcoeffs, scan[c], txs_ctx);
 
     if (c < seg_eob - 1)
-      is_nz = aom_read(r, nz_map[coeff_ctx], tx_size);
+      is_nz = aom_read(r, nz_map[coeff_ctx], ACCT_STR);
     else
       is_nz = 1;
 
     // set non-zero coefficient map.
     tcoeffs[scan[c]] = is_nz;
 
     if (c == seg_eob - 1) {
       ++c;
       break;
     }
 
     if (counts) ++(*nz_map_count)[coeff_ctx][is_nz];
 
     if (is_nz) {
-      int is_eob = aom_read(r, eob_flag[eob_ctx], tx_size);
-      if (counts) ++counts->eob_flag[tx_size][plane_type][eob_ctx][is_eob];
+      int is_eob = aom_read(r, eob_flag[eob_ctx], ACCT_STR);
+      if (counts) ++counts->eob_flag[txs_ctx][plane_type][eob_ctx][is_eob];
       if (is_eob) break;
     }
     txb_mask[scan[c]] = 1;
   }
 
   *eob = AOMMIN(seg_eob, c + 1);
   *max_scan_line = *eob;
 
   int i;
   for (i = 0; i < NUM_BASE_LEVELS; ++i) {
-    aom_prob *coeff_base = cm->fc->coeff_base[tx_size][plane_type][i];
+    aom_prob *coeff_base = cm->fc->coeff_base[txs_ctx][plane_type][i];
 
     update_eob = 0;
     for (c = *eob - 1; c >= 0; --c) {
       tran_low_t *v = &tcoeffs[scan[c]];
       int sign;
       int ctx;
 
       if (*v <= i) continue;
 
-      ctx = get_base_ctx(tcoeffs, scan[c], bwl, i + 1);
+      ctx = get_base_ctx(tcoeffs, scan[c], bwl, height, i + 1);
 
-      if (aom_read(r, coeff_base[ctx], tx_size)) {
+      if (aom_read(r, coeff_base[ctx], ACCT_STR)) {
         *v = i + 1;
         cul_level += i + 1;
 
-        if (counts) ++counts->coeff_base[tx_size][plane_type][i][ctx][1];
+        if (counts) ++counts->coeff_base[txs_ctx][plane_type][i][ctx][1];
 
         if (c == 0) {
           int dc_sign_ctx = txb_ctx->dc_sign_ctx;
-          sign = aom_read(r, cm->fc->dc_sign[plane_type][dc_sign_ctx], tx_size);
+          sign =
+              aom_read(r, cm->fc->dc_sign[plane_type][dc_sign_ctx], ACCT_STR);
           if (counts) ++counts->dc_sign[plane_type][dc_sign_ctx][sign];
         } else {
           sign = aom_read_bit(r, ACCT_STR);
         }
         if (sign) *v = -(*v);
         continue;
       }
       *v = i + 2;
-      if (counts) ++counts->coeff_base[tx_size][plane_type][i][ctx][0];
+      if (counts) ++counts->coeff_base[txs_ctx][plane_type][i][ctx][0];
 
       // update the eob flag for coefficients with magnitude above 1.
       update_eob = AOMMAX(update_eob, c);
     }
   }
 
   for (c = update_eob; c >= 0; --c) {
     tran_low_t *v = &tcoeffs[scan[c]];
     int sign;
     int idx;
     int ctx;
 
     if (*v <= NUM_BASE_LEVELS) continue;
 
     if (c == 0) {
       int dc_sign_ctx = txb_ctx->dc_sign_ctx;
-      sign = aom_read(r, cm->fc->dc_sign[plane_type][dc_sign_ctx], tx_size);
+      sign = aom_read(r, cm->fc->dc_sign[plane_type][dc_sign_ctx], ACCT_STR);
       if (counts) ++counts->dc_sign[plane_type][dc_sign_ctx][sign];
     } else {
       sign = aom_read_bit(r, ACCT_STR);
     }
 
-    ctx = get_br_ctx(tcoeffs, scan[c], bwl);
+    ctx = get_br_ctx(tcoeffs, scan[c], bwl, height);
 
-    if (cm->fc->coeff_lps[tx_size][plane_type][ctx] == 0) exit(0);
+    if (cm->fc->coeff_lps[txs_ctx][plane_type][ctx] == 0) exit(0);
 
     for (idx = 0; idx < COEFF_BASE_RANGE; ++idx) {
-      if (aom_read(r, cm->fc->coeff_lps[tx_size][plane_type][ctx], tx_size)) {
+      if (aom_read(r, cm->fc->coeff_lps[txs_ctx][plane_type][ctx], ACCT_STR)) {
         *v = (idx + 1 + NUM_BASE_LEVELS);
         if (sign) *v = -(*v);
         cul_level += abs(*v);
 
-        if (counts) ++counts->coeff_lps[tx_size][plane_type][ctx][1];
+        if (counts) ++counts->coeff_lps[txs_ctx][plane_type][ctx][1];
         break;
       }
-      if (counts) ++counts->coeff_lps[tx_size][plane_type][ctx][0];
+      if (counts) ++counts->coeff_lps[txs_ctx][plane_type][ctx][0];
     }
     if (idx < COEFF_BASE_RANGE) continue;
 
     // decode 0-th order Golomb code
     *v = read_golomb(xd, r) + COEFF_BASE_RANGE + 1 + NUM_BASE_LEVELS;
     if (sign) *v = -(*v);
     cul_level += abs(*v);
   }
@@ -206,39 +207,37 @@ uint8_t av1_read_coeffs_txb(const AV1_CO
   set_dc_sign(&cul_level, tcoeffs[0]);
 
   return cul_level;
 }
 
 uint8_t av1_read_coeffs_txb_facade(AV1_COMMON *cm, MACROBLOCKD *xd,
                                    aom_reader *r, int row, int col, int block,
                                    int plane, tran_low_t *tcoeffs,
-                                   int16_t *max_scan_line, int *eob) {
+                                   TX_SIZE tx_size, int16_t *max_scan_line,
+                                   int *eob) {
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   struct macroblockd_plane *pd = &xd->plane[plane];
 
   const BLOCK_SIZE bsize = mbmi->sb_type;
-#if CONFIG_CB4X4
-#if CONFIG_CHROMA_2X2
-  const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
-#else
+#if CONFIG_CHROMA_SUB8X8
   const BLOCK_SIZE plane_bsize =
       AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
-#endif  // CONFIG_CHROMA_2X2
+#elif CONFIG_CB4X4
+  const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
 #else   // CONFIG_CB4X4
   const BLOCK_SIZE plane_bsize =
       get_plane_block_size(AOMMAX(BLOCK_8X8, bsize), pd);
 #endif  // CONFIG_CB4X4
 
-  TX_SIZE tx_size = get_tx_size(plane, xd);
   TXB_CTX txb_ctx;
   get_txb_ctx(plane_bsize, tx_size, plane, pd->above_context + col,
               pd->left_context + row, &txb_ctx);
-  uint8_t cul_level = av1_read_coeffs_txb(cm, xd, r, block, plane, tcoeffs,
-                                          &txb_ctx, max_scan_line, eob);
+  uint8_t cul_level = av1_read_coeffs_txb(
+      cm, xd, r, block, plane, tcoeffs, &txb_ctx, tx_size, max_scan_line, eob);
 #if CONFIG_ADAPT_SCAN
   PLANE_TYPE plane_type = get_plane_type(plane);
   TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
   if (xd->counts && *eob > 0)
     av1_update_scan_count_facade(cm, xd->counts, tx_size, tx_type, pd->dqcoeff,
                                  *eob);
 #endif
   av1_set_contexts(xd, pd, plane, tx_size, cul_level, col, row);
--- a/third_party/aom/av1/decoder/decodetxb.h
+++ b/third_party/aom/av1/decoder/decodetxb.h
@@ -16,16 +16,17 @@
 #include "av1/common/blockd.h"
 #include "av1/common/onyxc_int.h"
 #include "av1/common/txb_common.h"
 #include "aom_dsp/bitreader.h"
 
 uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
                             aom_reader *r, int block, int plane,
                             tran_low_t *tcoeffs, TXB_CTX *txb_ctx,
-                            int16_t *max_scan_line, int *eob);
+                            TX_SIZE tx_size, int16_t *max_scan_line, int *eob);
 
 uint8_t av1_read_coeffs_txb_facade(AV1_COMMON *cm, MACROBLOCKD *xd,
                                    aom_reader *r, int row, int col, int block,
                                    int plane, tran_low_t *tcoeffs,
-                                   int16_t *max_scan_line, int *eob);
+                                   TX_SIZE tx_size, int16_t *max_scan_line,
+                                   int *eob);
 void av1_read_txb_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode, aom_reader *r);
 #endif  //  DECODETXB_H_
--- a/third_party/aom/av1/decoder/detokenize.c
+++ b/third_party/aom/av1/decoder/detokenize.c
@@ -115,16 +115,18 @@ static int decode_coefs(MACROBLOCKD *xd,
   FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
 #else
   FRAME_CONTEXT *const ec_ctx = xd->fc;
 #endif
   const int max_eob = tx_size_2d[tx_size];
   const int ref = is_inter_block(&xd->mi[0]->mbmi);
 #if CONFIG_AOM_QM
   const qm_val_t *iqmatrix = iqm[!ref][tx_size];
+#else
+  (void)tx_type;
 #endif  // CONFIG_AOM_QM
   int band, c = 0;
   const int tx_size_ctx = txsize_sqr_map[tx_size];
   aom_cdf_prob(*coef_head_cdfs)[COEFF_CONTEXTS][CDF_SIZE(ENTROPY_TOKENS)] =
       ec_ctx->coef_head_cdfs[tx_size_ctx][type][ref];
   aom_cdf_prob(*coef_tail_cdfs)[COEFF_CONTEXTS][CDF_SIZE(ENTROPY_TOKENS)] =
       ec_ctx->coef_tail_cdfs[tx_size_ctx][type][ref];
   int val = 0;
@@ -137,17 +139,16 @@ static int decode_coefs(MACROBLOCKD *xd,
   uint8_t token_cache[MAX_TX_SQUARE];
   const uint8_t *band_translate = get_band_translate(tx_size);
   int dq_shift;
   int v, token;
   int16_t dqv = dq[0];
 #if CONFIG_NEW_QUANT
   const tran_low_t *dqv_val = &dq_val[0][0];
 #endif  // CONFIG_NEW_QUANT
-  (void)tx_type;
 
   if (counts) {
 #if !CONFIG_EC_ADAPT
     coef_counts = counts->coef[tx_size_ctx][type][ref];
     eob_branch_count = counts->eob_branch[tx_size_ctx][type][ref];
     blockz_count = counts->blockz_count[tx_size_ctx][type][ref][ctx];
 #endif
   }
@@ -221,26 +222,25 @@ static int decode_coefs(MACROBLOCKD *xd,
 
     val = token_to_value(r, token, tx_size, xd->bd);
 
 #if CONFIG_NEW_QUANT
     v = av1_dequant_abscoeff_nuq(val, dqv, dqv_val);
     v = dq_shift ? ROUND_POWER_OF_TWO(v, dq_shift) : v;
 #else
 #if CONFIG_AOM_QM
-    dqv = ((iqmatrix[scan[c]] * (int)dqv) + (1 << (AOM_QM_BITS - 1))) >>
-          AOM_QM_BITS;
+    // Apply quant matrix only for 2D transforms
+    if (IS_2D_TRANSFORM(tx_type))
+      dqv = ((iqmatrix[scan[c]] * (int)dqv) + (1 << (AOM_QM_BITS - 1))) >>
+            AOM_QM_BITS;
 #endif
     v = (val * dqv) >> dq_shift;
 #endif
 
-    v = aom_read_bit(r, ACCT_STR) ? -v : v;
-#if CONFIG_COEFFICIENT_RANGE_CHECKING
-    check_range(v, xd->bd);
-#endif  // CONFIG_COEFFICIENT_RANGE_CHECKING
+    v = (int)check_range(aom_read_bit(r, ACCT_STR) ? -v : v, xd->bd);
 
     dqcoeff[scan[c]] = v;
 
     ++c;
     more_data &= (c < max_eob);
     if (!more_data) break;
     dqv = dq[1];
     ctx = get_coef_context(nb, token_cache, c);
--- a/third_party/aom/av1/encoder/aq_cyclicrefresh.c
+++ b/third_party/aom/av1/encoder/aq_cyclicrefresh.c
@@ -347,20 +347,17 @@ void av1_cyclic_refresh_check_golden_upd
       // Accumulate low_content_frame.
       if (cr->map[mi_row * cols + mi_col] < 1) low_content_frame++;
     }
   }
 
   // For video conference clips, if the background has high motion in current
   // frame because of the camera movement, set this frame as the golden frame.
   // Use 70% and 5% as the thresholds for golden frame refreshing.
-  // Also, force this frame as a golden update frame if this frame will change
-  // the resolution (av1_resize_pending != 0).
-  if (av1_resize_pending(cpi) ||
-      (cnt1 * 10 > (70 * rows * cols) && cnt2 * 20 < cnt1)) {
+  if (cnt1 * 10 > (70 * rows * cols) && cnt2 * 20 < cnt1) {
     av1_cyclic_refresh_set_golden_update(cpi);
     rc->frames_till_gf_update_due = rc->baseline_gf_interval;
 
     if (rc->frames_till_gf_update_due > rc->frames_to_key)
       rc->frames_till_gf_update_due = rc->frames_to_key;
     cpi->refresh_golden_frame = 1;
     force_gf_refresh = 1;
   }
--- a/third_party/aom/av1/encoder/av1_quantize.c
+++ b/third_party/aom/av1/encoder/av1_quantize.c
@@ -840,17 +840,16 @@ void av1_quantize_dc_nuq_facade(const tr
                                dqcoeff_ptr, eob_ptr);
       break;
 #endif  // CONFIG_TX64X64
     default: assert(0);
   }
 }
 #endif  // CONFIG_NEW_QUANT
 
-#if CONFIG_HIGHBITDEPTH
 void av1_highbd_quantize_fp_facade(const tran_low_t *coeff_ptr,
                                    intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
                                    tran_low_t *qcoeff_ptr,
                                    const MACROBLOCKD_PLANE *pd,
                                    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
                                    const SCAN_ORDER *sc,
                                    const QUANT_PARAM *qparam) {
   // obsolete skip_block
@@ -894,24 +893,39 @@ void av1_highbd_quantize_b_facade(const 
   const int skip_block = 0;
 #if CONFIG_AOM_QM
   const qm_val_t *qm_ptr = qparam->qmatrix;
   const qm_val_t *iqm_ptr = qparam->iqmatrix;
 #endif  // CONFIG_AOM_QM
 
   switch (qparam->log_scale) {
     case 0:
-      aom_highbd_quantize_b(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round,
-                            p->quant, p->quant_shift, qcoeff_ptr, dqcoeff_ptr,
-                            pd->dequant, eob_ptr, sc->scan, sc->iscan
+      if (LIKELY(n_coeffs >= 8)) {
+        aom_highbd_quantize_b(coeff_ptr, n_coeffs, skip_block, p->zbin,
+                              p->round, p->quant, p->quant_shift, qcoeff_ptr,
+                              dqcoeff_ptr, pd->dequant, eob_ptr, sc->scan,
+                              sc->iscan
 #if CONFIG_AOM_QM
-                            ,
-                            qm_ptr, iqm_ptr
+                              ,
+                              qm_ptr, iqm_ptr
 #endif
-                            );
+                              );
+      } else {
+        // TODO(luoyi): Need SIMD (e.g. sse2) for smaller block size
+        // quantization
+        aom_highbd_quantize_b_c(coeff_ptr, n_coeffs, skip_block, p->zbin,
+                                p->round, p->quant, p->quant_shift, qcoeff_ptr,
+                                dqcoeff_ptr, pd->dequant, eob_ptr, sc->scan,
+                                sc->iscan
+#if CONFIG_AOM_QM
+                                ,
+                                qm_ptr, iqm_ptr
+#endif
+                                );
+      }
       break;
     case 1:
       aom_highbd_quantize_b_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin,
                                   p->round, p->quant, p->quant_shift,
                                   qcoeff_ptr, dqcoeff_ptr, pd->dequant, eob_ptr,
                                   sc->scan, sc->iscan
 #if CONFIG_AOM_QM
                                   ,
@@ -931,17 +945,16 @@ void av1_highbd_quantize_b_facade(const 
 #endif
                                   );
       break;
 #endif  // CONFIG_TX64X64
     default: assert(0);
   }
 }
 
-#if CONFIG_HIGHBITDEPTH
 static INLINE void highbd_quantize_dc(
     const tran_low_t *coeff_ptr, int n_coeffs, int skip_block,
     const int16_t *round_ptr, const int16_t quant, tran_low_t *qcoeff_ptr,
     tran_low_t *dqcoeff_ptr, const int16_t dequant_ptr, uint16_t *eob_ptr,
 #if CONFIG_AOM_QM
     const qm_val_t *qm_ptr, const qm_val_t *iqm_ptr,
 #endif
     const int log_scale) {
@@ -953,24 +966,23 @@ static INLINE void highbd_quantize_dc(
   (void)qm_ptr;
   (void)iqm_ptr;
 #endif
   if (!skip_block) {
     const int coeff = coeff_ptr[0];
     const int coeff_sign = (coeff >> 31);
     const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
     const int64_t tmp = abs_coeff + round_ptr[0];
-    const uint32_t abs_qcoeff = (uint32_t)((tmp * quant) >> (16 - log_scale));
+    const int abs_qcoeff = (int)((tmp * quant) >> (16 - log_scale));
     qcoeff_ptr[0] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
     dqcoeff_ptr[0] = qcoeff_ptr[0] * dequant_ptr / (1 << log_scale);
     if (abs_qcoeff) eob = 0;
   }
   *eob_ptr = eob + 1;
 }
-#endif  // CONFIG_HIGHBITDEPTH
 
 void av1_highbd_quantize_dc_facade(const tran_low_t *coeff_ptr,
                                    intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
                                    tran_low_t *qcoeff_ptr,
                                    const MACROBLOCKD_PLANE *pd,
                                    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
                                    const SCAN_ORDER *sc,
                                    const QUANT_PARAM *qparam) {
@@ -1499,19 +1511,17 @@ void av1_highbd_quantize_dc_nuq_facade(
           p->cuml_bins_nuq[dq][0], pd->dequant_val_nuq[dq][0], qcoeff_ptr,
           dqcoeff_ptr, eob_ptr);
       break;
 #endif  // CONFIG_TX64X64
     default: assert(0);
   }
 }
 #endif  // CONFIG_NEW_QUANT
-#endif  // CONFIG_HIGHBITDEPTH
 
-#if CONFIG_HIGHBITDEPTH
 void av1_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t count,
                               int skip_block, const int16_t *zbin_ptr,
                               const int16_t *round_ptr,
                               const int16_t *quant_ptr,
                               const int16_t *quant_shift_ptr,
                               tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
                               const int16_t *dequant_ptr, uint16_t *eob_ptr,
                               const int16_t *scan, const int16_t *iscan,
@@ -1542,36 +1552,33 @@ void av1_highbd_quantize_fp_c(const tran
       const qm_val_t wt = qm_ptr[rc];
       const qm_val_t iwt = iqm_ptr[rc];
       const int dequant =
           (dequant_ptr[rc != 0] * iwt + (1 << (AOM_QM_BITS - 1))) >>
           AOM_QM_BITS;
 #endif
       const int coeff_sign = (coeff >> 31);
       const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
-      const int64_t tmp = abs_coeff + round_ptr[rc != 0];
+      const int64_t tmp = abs_coeff + (round_ptr[rc != 0] >> log_scale);
 #if CONFIG_AOM_QM
-      const uint32_t abs_qcoeff =
-          (uint32_t)((tmp * quant_ptr[rc != 0] * wt) >> (shift + AOM_QM_BITS));
+      const int abs_qcoeff =
+          (int)((tmp * quant_ptr[rc != 0] * wt) >> (shift + AOM_QM_BITS));
       qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
       dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant / scale;
 #else
-      const uint32_t abs_qcoeff =
-          (uint32_t)((tmp * quant_ptr[rc != 0]) >> shift);
+      const int abs_qcoeff = (int)((tmp * quant_ptr[rc != 0]) >> shift);
       qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
       dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / scale;
 #endif
       if (abs_qcoeff) eob = i;
     }
   }
   *eob_ptr = eob + 1;
 }
 
-#endif  // CONFIG_HIGHBITDEPTH
-
 static void invert_quant(int16_t *quant, int16_t *shift, int d) {
   uint32_t t;
   int l, m;
   t = d;
   for (l = 0; t > 1; l++) t >>= 1;
   m = 1 + (1 << (16 + l)) / d;
   *quant = (int16_t)(m - (1 << 16));
   *shift = 1 << (16 - l);
--- a/third_party/aom/av1/encoder/av1_quantize.h
+++ b/third_party/aom/av1/encoder/av1_quantize.h
@@ -141,17 +141,16 @@ void av1_quantize_dc_nuq_facade(const tr
                                 const MACROBLOCK_PLANE *p,
                                 tran_low_t *qcoeff_ptr,
                                 const MACROBLOCKD_PLANE *pd,
                                 tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
                                 const SCAN_ORDER *sc,
                                 const QUANT_PARAM *qparam);
 #endif  // CONFIG_NEW_QUANT
 
-#if CONFIG_HIGHBITDEPTH
 void av1_highbd_quantize_fp_facade(const tran_low_t *coeff_ptr,
                                    intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
                                    tran_low_t *qcoeff_ptr,
                                    const MACROBLOCKD_PLANE *pd,
                                    tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
                                    const SCAN_ORDER *sc,
                                    const QUANT_PARAM *qparam);
 
@@ -185,15 +184,14 @@ void av1_highbd_quantize_b_nuq_facade(
     const QUANT_PARAM *qparam);
 
 void av1_highbd_quantize_dc_nuq_facade(
     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
     tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd,
     tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const SCAN_ORDER *sc,
     const QUANT_PARAM *qparam);
 #endif  // CONFIG_NEW_QUANT
-#endif  // CONFIG_HIGHBITDEPTH
 
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
 #endif  // AV1_ENCODER_QUANTIZE_H_
new file mode 100644
--- /dev/null
+++ b/third_party/aom/av1/encoder/bgsprite.c
@@ -0,0 +1,576 @@
+/*
+ * Copyright (c) 2017, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+#define _POSIX_C_SOURCE 200112L  // rand_r()
+#include <assert.h>
+#include <float.h>
+#include <limits.h>
+#include <math.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "av1/encoder/bgsprite.h"
+
+#include "aom_mem/aom_mem.h"
+#include "av1/common/mv.h"
+#include "av1/common/warped_motion.h"
+#include "av1/encoder/encoder.h"
+#include "av1/encoder/global_motion.h"
+#include "av1/encoder/mathutils.h"
+
+#define TRANSFORM_MAT_DIM 3
+
+typedef struct {
+#if CONFIG_HIGHBITDEPTH
+  uint16_t y;
+  uint16_t u;
+  uint16_t v;
+#else
+  uint8_t y;
+  uint8_t u;
+  uint8_t v;
+#endif  // CONFIG_HIGHBITDEPTH
+} YuvPixel;
+
+// Maps to convert from matrix form to param vector form.
+static const int params_to_matrix_map[] = { 2, 3, 0, 4, 5, 1, 6, 7 };
+static const int matrix_to_params_map[] = { 2, 5, 0, 1, 3, 4, 6, 7 };
+
+// Convert the parameter array to a 3x3 matrix form.
+static void params_to_matrix(const double *const params, double *target) {
+  for (int i = 0; i < MAX_PARAMDIM - 1; i++) {
+    assert(params_to_matrix_map[i] < MAX_PARAMDIM - 1);
+    target[i] = params[params_to_matrix_map[i]];
+  }
+  target[8] = 1;
+}
+
+// Convert a 3x3 matrix to a parameter array form.
+static void matrix_to_params(const double *const matrix, double *target) {
+  for (int i = 0; i < MAX_PARAMDIM - 1; i++) {
+    assert(matrix_to_params_map[i] < MAX_PARAMDIM - 1);
+    target[i] = matrix[matrix_to_params_map[i]];
+  }
+}
+
+// Do matrix multiplication on params.
+static void multiply_params(double *const m1, double *const m2,
+                            double *target) {
+  double m1_matrix[MAX_PARAMDIM];
+  double m2_matrix[MAX_PARAMDIM];
+  double result[MAX_PARAMDIM];
+
+  params_to_matrix(m1, m1_matrix);
+  params_to_matrix(m2, m2_matrix);
+  multiply_mat(m2_matrix, m1_matrix, result, TRANSFORM_MAT_DIM,
+               TRANSFORM_MAT_DIM, TRANSFORM_MAT_DIM);
+  matrix_to_params(result, target);
+}
+
+// Finds x and y limits of a single transformed image.
+// Width and height are the size of the input video.
+static void find_frame_limit(int width, int height,
+                             const double *const transform, int *x_min,
+                             int *x_max, int *y_min, int *y_max) {
+  double transform_matrix[MAX_PARAMDIM];
+  double xy_matrix[3] = { 0, 0, 1 };
+  double uv_matrix[3] = { 0 };
+// Macro used to update frame limits based on transformed coordinates.
+#define UPDATELIMITS(u, v, x_min, x_max, y_min, y_max) \
+  {                                                    \
+    if ((int)ceil(u) > *x_max) {                       \
+      *x_max = (int)ceil(u);                           \
+    }                                                  \
+    if ((int)floor(u) < *x_min) {                      \
+      *x_min = (int)floor(u);                          \
+    }                                                  \
+    if ((int)ceil(v) > *y_max) {                       \
+      *y_max = (int)ceil(v);                           \
+    }                                                  \
+    if ((int)floor(v) < *y_min) {                      \
+      *y_min = (int)floor(v);                          \
+    }                                                  \
+  }
+
+  params_to_matrix(transform, transform_matrix);
+  xy_matrix[0] = 0;
+  xy_matrix[1] = 0;
+  multiply_mat(transform_matrix, xy_matrix, uv_matrix, TRANSFORM_MAT_DIM,
+               TRANSFORM_MAT_DIM, 1);
+  *x_max = (int)ceil(uv_matrix[0]);
+  *x_min = (int)floor(uv_matrix[0]);
+  *y_max = (int)ceil(uv_matrix[1]);
+  *y_min = (int)floor(uv_matrix[1]);
+
+  xy_matrix[0] = width;
+  xy_matrix[1] = 0;
+  multiply_mat(transform_matrix, xy_matrix, uv_matrix, TRANSFORM_MAT_DIM,
+               TRANSFORM_MAT_DIM, 1);
+  UPDATELIMITS(uv_matrix[0], uv_matrix[1], x_min, x_max, y_min, y_max);
+
+  xy_matrix[0] = width;
+  xy_matrix[1] = height;
+  multiply_mat(transform_matrix, xy_matrix, uv_matrix, TRANSFORM_MAT_DIM,
+               TRANSFORM_MAT_DIM, 1);
+  UPDATELIMITS(uv_matrix[0], uv_matrix[1], x_min, x_max, y_min, y_max);
+
+  xy_matrix[0] = 0;
+  xy_matrix[1] = height;
+  multiply_mat(transform_matrix, xy_matrix, uv_matrix, TRANSFORM_MAT_DIM,
+               TRANSFORM_MAT_DIM, 1);
+  UPDATELIMITS(uv_matrix[0], uv_matrix[1], x_min, x_max, y_min, y_max);
+
+#undef UPDATELIMITS
+}
+
+// Finds x and y limits for arrays. Also finds the overall max and minimums
+static void find_limits(int width, int height, const double **const params,
+                        int num_frames, int *x_min, int *x_max, int *y_min,
+                        int *y_max, int *pano_x_min, int *pano_x_max,
+                        int *pano_y_min, int *pano_y_max) {
+  *pano_x_max = INT_MIN;
+  *pano_x_min = INT_MAX;
+  *pano_y_max = INT_MIN;
+  *pano_y_min = INT_MAX;
+  for (int i = 0; i < num_frames; ++i) {
+    find_frame_limit(width, height, (const double *const)params[i], &x_min[i],
+                     &x_max[i], &y_min[i], &y_max[i]);
+    if (x_max[i] > *pano_x_max) {
+      *pano_x_max = x_max[i];
+    }
+    if (x_min[i] < *pano_x_min) {
+      *pano_x_min = x_min[i];
+    }
+    if (y_max[i] > *pano_y_max) {
+      *pano_y_max = y_max[i];
+    }
+    if (y_min[i] < *pano_y_min) {
+      *pano_y_min = y_min[i];
+    }
+  }
+}
+
+// Inverts a 3x3 matrix that is in the parameter form.
+static void invert_params(const double *const params, double *target) {
+  double temp[MAX_PARAMDIM] = { 0 };
+  params_to_matrix(params, temp);
+
+  // Find determinant of matrix (expansion by minors).
+  const double det = temp[0] * ((temp[4] * temp[8]) - (temp[5] * temp[7])) -
+                     temp[1] * ((temp[3] * temp[8]) - (temp[5] * temp[6])) +
+                     temp[2] * ((temp[3] * temp[7]) - (temp[4] * temp[6]));
+  assert(det != 0);
+
+  // inverse is transpose of cofactor * 1/det.
+  double inverse[MAX_PARAMDIM] = { 0 };
+  inverse[0] = (temp[4] * temp[8] - temp[7] * temp[5]) / det;
+  inverse[1] = (temp[2] * temp[7] - temp[1] * temp[8]) / det;
+  inverse[2] = (temp[1] * temp[5] - temp[2] * temp[4]) / det;
+  inverse[3] = (temp[5] * temp[6] - temp[3] * temp[8]) / det;
+  inverse[4] = (temp[0] * temp[8] - temp[2] * temp[6]) / det;
+  inverse[5] = (temp[3] * temp[2] - temp[0] * temp[5]) / det;
+  inverse[6] = (temp[3] * temp[7] - temp[6] * temp[4]) / det;
+  inverse[7] = (temp[6] * temp[1] - temp[0] * temp[7]) / det;
+  inverse[8] = (temp[0] * temp[4] - temp[3] * temp[1]) / det;
+
+  matrix_to_params(inverse, target);
+}
+
+// swap_yuvs two YuvPixels.
+static void swap_yuv(YuvPixel *a, YuvPixel *b) {
+  const YuvPixel temp = *b;
+  *b = *a;
+  *a = temp;
+}
+
+// Partitions array to find pivot index in qselect.
+static int partition(YuvPixel arr[], int left, int right, int pivot_idx) {
+  YuvPixel pivot = arr[pivot_idx];
+
+  // Move pivot to the end.
+  swap_yuv(&arr[pivot_idx], &arr[right]);
+
+  int p_idx = left;
+  for (int i = left; i < right; ++i) {
+    if (arr[i].y <= pivot.y) {
+      swap_yuv(&arr[i], &arr[p_idx]);
+      p_idx++;
+    }
+  }
+
+  swap_yuv(&arr[p_idx], &arr[right]);
+
+  return p_idx;
+}
+
+// Returns the kth element in array, partially sorted in place (quickselect).
+static YuvPixel qselect(YuvPixel arr[], int left, int right, int k) {
+  if (left >= right) {
+    return arr[left];
+  }
+  unsigned int seed = time(NULL);
+  int pivot_idx = left + rand_r(&seed) % (right - left + 1);
+  pivot_idx = partition(arr, left, right, pivot_idx);
+
+  if (k == pivot_idx) {
+    return arr[k];
+  } else if (k < pivot_idx) {
+    return qselect(arr, left, pivot_idx - 1, k);
+  } else {
+    return qselect(arr, pivot_idx + 1, right, k);
+  }
+}
+
+// Stitches images together to create ARF and stores it in 'panorama'.
+static void stitch_images(YV12_BUFFER_CONFIG **const frames,
+                          const int num_frames, const double **const params,
+                          const int *const x_min, const int *const x_max,
+                          const int *const y_min, const int *const y_max,
+                          int pano_x_min, int pano_x_max, int pano_y_min,
+                          int pano_y_max, YV12_BUFFER_CONFIG *panorama) {
+  const int width = pano_x_max - pano_x_min + 1;
+  const int height = pano_y_max - pano_y_min + 1;
+
+  // Create temp_pano[y][x][num_frames] stack of pixel values
+  YuvPixel ***temp_pano = aom_malloc(height * sizeof(*temp_pano));
+  for (int i = 0; i < height; ++i) {
+    temp_pano[i] = aom_malloc(width * sizeof(**temp_pano));
+    for (int j = 0; j < width; ++j) {
+      temp_pano[i][j] = aom_malloc(num_frames * sizeof(***temp_pano));
+    }
+  }
+  // Create count[y][x] to count how many values in stack for median filtering
+  int **count = aom_malloc(height * sizeof(*count));
+  for (int i = 0; i < height; ++i) {
+    count[i] = aom_calloc(width, sizeof(**count));  // counts initialized to 0
+  }
+
+  // Re-sample images onto panorama (pre-median filtering).
+  const int x_offset = -pano_x_min;
+  const int y_offset = -pano_y_min;
+  const int frame_width = frames[0]->y_width;
+  const int frame_height = frames[0]->y_height;
+  for (int i = 0; i < num_frames; ++i) {
+    // Find transforms from panorama coordinate system back to single image
+    // coordinate system for sampling.
+    int transformed_width = x_max[i] - x_min[i] + 1;
+    int transformed_height = y_max[i] - y_min[i] + 1;
+
+    double transform_matrix[MAX_PARAMDIM];
+    double transform_params[MAX_PARAMDIM - 1];
+    invert_params(params[i], transform_params);
+    params_to_matrix(transform_params, transform_matrix);
+
+#if CONFIG_HIGHBITDEPTH
+    const uint16_t *y_buffer16 = CONVERT_TO_SHORTPTR(frames[i]->y_buffer);
+    const uint16_t *u_buffer16 = CONVERT_TO_SHORTPTR(frames[i]->u_buffer);
+    const uint16_t *v_buffer16 = CONVERT_TO_SHORTPTR(frames[i]->v_buffer);
+#endif
+
+    for (int y = 0; y < transformed_height; ++y) {
+      for (int x = 0; x < transformed_width; ++x) {
+        // Do transform.
+        double xy_matrix[3] = { x + x_min[i], y + y_min[i], 1 };
+        double uv_matrix[3] = { 0 };
+        multiply_mat(transform_matrix, xy_matrix, uv_matrix, TRANSFORM_MAT_DIM,
+                     TRANSFORM_MAT_DIM, 1);
+        int image_x = (int)round(uv_matrix[0]);
+        int image_y = (int)round(uv_matrix[1]);
+
+        // Check if valid point in original image.
+        if (image_x >= 0 && image_x < frame_width && image_y >= 0 &&
+            image_y < frame_height) {
+          // Place in panorama stack.
+          int pano_x = x + x_min[i] + x_offset;
+          int pano_y = y + y_min[i] + y_offset;
+
+          int ychannel_idx = image_y * frames[i]->y_stride + image_x;
+          int uvchannel_idx =
+              (image_y >> frames[i]->subsampling_y) * frames[i]->uv_stride +
+              (image_x >> frames[i]->subsampling_x);
+#if CONFIG_HIGHBITDEPTH
+          if (frames[i]->flags & YV12_FLAG_HIGHBITDEPTH) {
+            temp_pano[pano_y][pano_x][count[pano_y][pano_x]].y =
+                y_buffer16[ychannel_idx];
+            temp_pano[pano_y][pano_x][count[pano_y][pano_x]].u =
+                u_buffer16[uvchannel_idx];
+            temp_pano[pano_y][pano_x][count[pano_y][pano_x]].v =
+                v_buffer16[uvchannel_idx];
+          } else {
+#endif  // CONFIG_HIGHBITDEPTH
+            temp_pano[pano_y][pano_x][count[pano_y][pano_x]].y =
+                frames[i]->y_buffer[ychannel_idx];
+            temp_pano[pano_y][pano_x][count[pano_y][pano_x]].u =
+                frames[i]->u_buffer[uvchannel_idx];
+            temp_pano[pano_y][pano_x][count[pano_y][pano_x]].v =
+                frames[i]->v_buffer[uvchannel_idx];
+
+            // Update count.
+            count[pano_y][pano_x]++;
+#if CONFIG_HIGHBITDEPTH
+          }
+#endif  // CONFIG_HIGHBITDEPTH
+        }
+      }
+    }
+  }
+
+  // Apply median filtering using quickselect.
+  for (int y = 0; y < height; ++y) {
+    for (int x = 0; x < width; ++x) {
+      if (count[y][x] == 0) {
+        // Just make the pixel black.
+        // TODO(toddnguyen): Color the pixel with nearest neighbor
+      } else {
+        // Find
+        const int median_idx = (int)floor(count[y][x] / 2);
+        YuvPixel median =
+            qselect(temp_pano[y][x], 0, count[y][x] - 1, median_idx);
+
+        // Make the median value the 0th index for UV subsampling later
+        temp_pano[y][x][0] = median;
+        assert(median.y == temp_pano[y][x][0].y &&
+               median.u == temp_pano[y][x][0].u &&
+               median.v == temp_pano[y][x][0].v);
+      }
+    }
+  }
+
+  // NOTE(toddnguyen): Right now the ARF in the cpi struct is fixed size at the
+  // same size as the frames. For now, we crop the generated panorama.
+  assert(panorama->y_width < width && panorama->y_height < height);
+  const int crop_x_offset = (width - panorama->y_width) / 2;
+  const int crop_y_offset = (height - panorama->y_height) / 2;
+
+#if CONFIG_HIGHBITDEPTH
+  if (panorama->flags & YV12_FLAG_HIGHBITDEPTH) {
+    // Use median Y value.
+    uint16_t *pano_y_buffer16 = CONVERT_TO_SHORTPTR(panorama->y_buffer);
+    for (int y = 0; y < panorama->y_height; ++y) {
+      for (int x = 0; x < panorama->y_width; ++x) {
+        const int ychannel_idx = y * panorama->y_stride + x;
+        if (count[y + crop_y_offset][x + crop_x_offset] > 0) {
+          pano_y_buffer16[ychannel_idx] =
+              temp_pano[y + crop_y_offset][x + crop_x_offset][0].y;
+        } else {
+          pano_y_buffer16[ychannel_idx] = 0;
+        }
+      }
+    }
+
+    // UV subsampling with median UV values
+    uint16_t *pano_u_buffer16 = CONVERT_TO_SHORTPTR(panorama->u_buffer);
+    uint16_t *pano_v_buffer16 = CONVERT_TO_SHORTPTR(panorama->v_buffer);
+
+    for (int y = 0; y < panorama->uv_height; ++y) {
+      for (int x = 0; x < panorama->uv_width; ++x) {
+        uint32_t avg_count = 0;
+        uint32_t u_sum = 0;
+        uint32_t v_sum = 0;
+
+        // Look at surrounding pixels for subsampling
+        for (int s_x = 0; s_x < panorama->subsampling_x + 1; ++s_x) {
+          for (int s_y = 0; s_y < panorama->subsampling_y + 1; ++s_y) {
+            int y_sample = crop_y_offset + (y << panorama->subsampling_y) + s_y;
+            int x_sample = crop_x_offset + (x << panorama->subsampling_x) + s_x;
+            if (y_sample > 0 && y_sample < height && x_sample > 0 &&
+                x_sample < width && count[y_sample][x_sample] > 0) {
+              u_sum += temp_pano[y_sample][x_sample][0].u;
+              v_sum += temp_pano[y_sample][x_sample][0].v;
+              avg_count++;
+            }
+          }
+        }
+
+        const int uvchannel_idx = y * panorama->uv_stride + x;
+        if (avg_count != 0) {
+          pano_u_buffer16[uvchannel_idx] = (uint16_t)OD_DIVU(u_sum, avg_count);
+          pano_v_buffer16[uvchannel_idx] = (uint16_t)OD_DIVU(v_sum, avg_count);
+        } else {
+          pano_u_buffer16[uvchannel_idx] = 0;
+          pano_v_buffer16[uvchannel_idx] = 0;
+        }
+      }
+    }
+  } else {
+#endif  // CONFIG_HIGHBITDEPTH
+    // Use median Y value.
+    for (int y = 0; y < panorama->y_height; ++y) {
+      for (int x = 0; x < panorama->y_width; ++x) {
+        const int ychannel_idx = y * panorama->y_stride + x;
+        if (count[y + crop_y_offset][x + crop_x_offset] > 0) {
+          panorama->y_buffer[ychannel_idx] =
+              temp_pano[y + crop_y_offset][x + crop_x_offset][0].y;
+        } else {
+          panorama->y_buffer[ychannel_idx] = 0;
+        }
+      }
+    }
+
+    // UV subsampling with median UV values
+    for (int y = 0; y < panorama->uv_height; ++y) {
+      for (int x = 0; x < panorama->uv_width; ++x) {
+        uint16_t avg_count = 0;
+        uint16_t u_sum = 0;
+        uint16_t v_sum = 0;
+
+        // Look at surrounding pixels for subsampling
+        for (int s_x = 0; s_x < panorama->subsampling_x + 1; ++s_x) {
+          for (int s_y = 0; s_y < panorama->subsampling_y + 1; ++s_y) {
+            int y_sample = crop_y_offset + (y << panorama->subsampling_y) + s_y;
+            int x_sample = crop_x_offset + (x << panorama->subsampling_x) + s_x;
+            if (y_sample > 0 && y_sample < height && x_sample > 0 &&
+                x_sample < width && count[y_sample][x_sample] > 0) {
+              u_sum += temp_pano[y_sample][x_sample][0].u;
+              v_sum += temp_pano[y_sample][x_sample][0].v;
+              avg_count++;
+            }
+          }
+        }
+
+        const int uvchannel_idx = y * panorama->uv_stride + x;
+        if (avg_count != 0) {
+          panorama->u_buffer[uvchannel_idx] =
+              (uint8_t)OD_DIVU(u_sum, avg_count);
+          panorama->v_buffer[uvchannel_idx] =
+              (uint8_t)OD_DIVU(v_sum, avg_count);
+        } else {
+          panorama->u_buffer[uvchannel_idx] = 0;
+          panorama->v_buffer[uvchannel_idx] = 0;
+        }
+      }
+    }
+#if CONFIG_HIGHBITDEPTH
+  }
+#endif  // CONFIG_HIGHBITDEPTH
+
+  for (int i = 0; i < height; ++i) {
+    for (int j = 0; j < width; ++j) {
+      aom_free(temp_pano[i][j]);
+    }
+    aom_free(temp_pano[i]);
+    aom_free(count[i]);
+  }
+  aom_free(count);
+  aom_free(temp_pano);
+}
+
+int av1_background_sprite(AV1_COMP *cpi, int distance) {
+  YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS] = { NULL };
+  int inliers_by_motion[RANSAC_NUM_MOTIONS];
+  static const double identity_params[MAX_PARAMDIM - 1] = {
+    0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0
+  };
+
+  // Get frames to be included in background sprite.
+  frames[0] = cpi->source;
+  for (int frame = 0; frame < distance; ++frame) {
+    struct lookahead_entry *buf = av1_lookahead_peek(cpi->lookahead, frame);
+    frames[frame + 1] = &buf->img;
+  }
+
+  // Allocate empty arrays for parameters between frames.
+  double **params = aom_malloc((distance + 1) * sizeof(*params));
+  for (int i = 0; i < distance + 1; ++i) {
+    params[i] = aom_malloc(sizeof(identity_params));
+    memcpy(params[i], identity_params, sizeof(identity_params));
+  }
+
+  // Use global motion to find affine transformations between frames.
+  // params[i] will have the transform from frame[i] to frame[i-1].
+  // params[0] will have the identity matrix because it has no previous frame.
+  TransformationType model = AFFINE;
+  for (int frame = 0; frame < distance; ++frame) {
+    const int global_motion_ret = compute_global_motion_feature_based(
+        model, frames[frame + 1], frames[frame],
+#if CONFIG_HIGHBITDEPTH
+        cpi->common.bit_depth,
+#endif  // CONFIG_HIGHBITDEPTH
+        inliers_by_motion, params[frame + 1], RANSAC_NUM_MOTIONS);
+
+    // Quit if global motion had an error.
+    if (global_motion_ret == 0) {
+      for (int i = 0; i < distance + 1; ++i) {
+        aom_free(params[i]);
+      }
+      aom_free(params);
+      return 1;
+    }
+  }
+
+  // Compound the transformation parameters.
+  for (int i = 1; i < distance + 1; ++i) {
+    multiply_params(params[i - 1], params[i], params[i]);
+  }
+
+  // Compute frame limits for final stitched images.
+  int pano_x_max = INT_MIN;
+  int pano_x_min = INT_MAX;
+  int pano_y_max = INT_MIN;
+  int pano_y_min = INT_MAX;
+  int *x_max = aom_malloc((distance + 1) * sizeof(*x_max));
+  int *x_min = aom_malloc((distance + 1) * sizeof(*x_min));
+  int *y_max = aom_malloc((distance + 1) * sizeof(*y_max));
+  int *y_min = aom_malloc((distance + 1) * sizeof(*y_min));
+
+  find_limits(cpi->initial_width, cpi->initial_height,
+              (const double **const)params, distance + 1, x_min, x_max, y_min,
+              y_max, &pano_x_min, &pano_x_max, &pano_y_min, &pano_y_max);
+
+  // Estimate center image based on frame limits.
+  const double pano_center_x = (pano_x_max + pano_x_min) / 2;
+  const double pano_center_y = (pano_y_max + pano_y_min) / 2;
+  double nearest_distance = DBL_MAX;
+  int center_idx = -1;
+  for (int i = 0; i < distance + 1; ++i) {
+    const double image_center_x = (x_max[i] + x_min[i]) / 2;
+    const double image_center_y = (y_max[i] + y_min[i]) / 2;
+    const double distance_from_center = pow(pano_center_x - image_center_x, 2) +
+                                        pow(pano_center_y + image_center_y, 2);
+    if (distance_from_center < nearest_distance) {
+      center_idx = i;
+      nearest_distance = distance_from_center;
+    }
+  }
+  assert(center_idx != -1);
+
+  // Recompute transformations to adjust to center image.
+  // Invert center image's transform.
+  double inverse[MAX_PARAMDIM - 1] = { 0 };
+  invert_params(params[center_idx], inverse);
+
+  // Multiply the inverse to all transformation parameters.
+  for (int i = 0; i < distance + 1; ++i) {
+    multiply_params(inverse, params[i], params[i]);
+  }
+
+  // Recompute frame limits for new adjusted center.
+  find_limits(cpi->initial_width, cpi->initial_height,
+              (const double **const)params, distance + 1, x_min, x_max, y_min,
+              y_max, &pano_x_min, &pano_x_max, &pano_y_min, &pano_y_max);
+
+  // Stitch Images.
+  stitch_images(frames, distance + 1, (const double **const)params, x_min,
+                x_max, y_min, y_max, pano_x_min, pano_x_max, pano_y_min,
+                pano_y_max, &cpi->alt_ref_buffer);
+
+  // Free memory.
+  for (int i = 0; i < distance + 1; ++i) {
+    aom_free(params[i]);
+  }
+  aom_free(params);
+  aom_free(x_max);
+  aom_free(x_min);
+  aom_free(y_max);
+  aom_free(y_min);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/third_party/aom/av1/encoder/bgsprite.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+#ifndef AV1_ENCODER_BGSPRITE_H_
+#define AV1_ENCODER_BGSPRITE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "av1/encoder/encoder.h"
+
+// Creates alternate reference frame staring from source image + frames up to
+// 'distance' past source frame.
+// Returns 0 on success and 1 on failure.
+int av1_background_sprite(AV1_COMP *cpi, int distance);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#endif  // AV1_ENCODER_BGSPRITE_H_
--- a/third_party/aom/av1/encoder/bitstream.c
+++ b/third_party/aom/av1/encoder/bitstream.c
@@ -56,25 +56,30 @@
 #endif  // CONFIG_PALETTE && CONFIG_PALETTE_DELTA_ENCODING
 #include "av1/encoder/segmentation.h"
 #include "av1/encoder/subexp.h"
 #include "av1/encoder/tokenize.h"
 #if CONFIG_PVQ
 #include "av1/encoder/pvq_encoder.h"
 #endif
 
-static struct av1_token intra_mode_encodings[INTRA_MODES];
-static struct av1_token switchable_interp_encodings[SWITCHABLE_FILTERS];
-static struct av1_token partition_encodings[PARTITION_TYPES];
+#define ENC_MISMATCH_DEBUG 0
+
 #if CONFIG_EXT_INTER
+#if !CONFIG_EC_ADAPT
 static const struct av1_token
     inter_compound_mode_encodings[INTER_COMPOUND_MODES] = {
       { 2, 2 },  { 12, 4 }, { 52, 6 }, { 53, 6 },
       { 54, 6 }, { 55, 6 }, { 0, 1 },  { 7, 3 }
     };
+#endif
+#if CONFIG_COMPOUND_SINGLEREF
+static struct av1_token
+    inter_singleref_comp_mode_encodings[INTER_SINGLEREF_COMP_MODES];
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #endif  // CONFIG_EXT_INTER
 #if CONFIG_PALETTE
 static struct av1_token palette_size_encodings[PALETTE_SIZES];
 static struct av1_token palette_color_index_encodings[PALETTE_SIZES]
                                                      [PALETTE_COLORS];
 #endif  // CONFIG_PALETTE
 
 #if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
@@ -92,34 +97,34 @@ static INLINE void write_uniform(aom_wri
 #endif  // CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
 
 #if CONFIG_EXT_TX
 static struct av1_token ext_tx_inter_encodings[EXT_TX_SETS_INTER][TX_TYPES];
 static struct av1_token ext_tx_intra_encodings[EXT_TX_SETS_INTRA][TX_TYPES];
 #else
 static struct av1_token ext_tx_encodings[TX_TYPES];
 #endif  // CONFIG_EXT_TX
-#if CONFIG_GLOBAL_MOTION
-static struct av1_token global_motion_types_encodings[GLOBAL_TRANS_TYPES];
-#endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_EXT_INTRA
 #if CONFIG_INTRA_INTERP
 static struct av1_token intra_filter_encodings[INTRA_FILTERS];
 #endif  // CONFIG_INTRA_INTERP
 #endif  // CONFIG_EXT_INTRA
 #if CONFIG_EXT_INTER
 #if CONFIG_INTERINTRA
 static struct av1_token interintra_mode_encodings[INTERINTRA_MODES];
 #endif
 #if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
 static struct av1_token compound_type_encodings[COMPOUND_TYPES];
 #endif  // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
 #endif  // CONFIG_EXT_INTER
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 static struct av1_token motion_mode_encodings[MOTION_MODES];
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+static struct av1_token ncobmc_mode_encodings[MAX_NCOBMC_MODES];
+#endif
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 #if CONFIG_LOOP_RESTORATION
 static struct av1_token switchable_restore_encodings[RESTORE_SWITCHABLE_TYPES];
 #endif  // CONFIG_LOOP_RESTORATION
 static void write_uncompressed_header(AV1_COMP *cpi,
                                       struct aom_write_bit_buffer *wb);
 static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data);
 static int remux_tiles(const AV1_COMMON *const cm, uint8_t *dst,
@@ -137,46 +142,46 @@ void av1_encode_token_init(void) {
     av1_tokens_from_tree(ext_tx_inter_encodings[s], av1_ext_tx_inter_tree[s]);
   }
   for (s = 1; s < EXT_TX_SETS_INTRA; ++s) {
     av1_tokens_from_tree(ext_tx_intra_encodings[s], av1_ext_tx_intra_tree[s]);
   }
 #else
   av1_tokens_from_tree(ext_tx_encodings, av1_ext_tx_tree);
 #endif  // CONFIG_EXT_TX
-  av1_tokens_from_tree(intra_mode_encodings, av1_intra_mode_tree);
-  av1_tokens_from_tree(switchable_interp_encodings, av1_switchable_interp_tree);
-  av1_tokens_from_tree(partition_encodings, av1_partition_tree);
 
 #if CONFIG_PALETTE
   av1_tokens_from_tree(palette_size_encodings, av1_palette_size_tree);
   for (s = 0; s < PALETTE_SIZES; ++s) {
     av1_tokens_from_tree(palette_color_index_encodings[s],
                          av1_palette_color_index_tree[s]);
   }
 #endif  // CONFIG_PALETTE
 
 #if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
   av1_tokens_from_tree(intra_filter_encodings, av1_intra_filter_tree);
 #endif  // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
 #if CONFIG_EXT_INTER
 #if CONFIG_INTERINTRA
   av1_tokens_from_tree(interintra_mode_encodings, av1_interintra_mode_tree);
 #endif  // CONFIG_INTERINTRA
+#if CONFIG_COMPOUND_SINGLEREF
+  av1_tokens_from_tree(inter_singleref_comp_mode_encodings,
+                       av1_inter_singleref_comp_mode_tree);
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
   av1_tokens_from_tree(compound_type_encodings, av1_compound_type_tree);
 #endif  // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
 #endif  // CONFIG_EXT_INTER
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   av1_tokens_from_tree(motion_mode_encodings, av1_motion_mode_tree);
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+  av1_tokens_from_tree(ncobmc_mode_encodings, av1_ncobmc_mode_tree);
+#endif
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
-#if CONFIG_GLOBAL_MOTION
-  av1_tokens_from_tree(global_motion_types_encodings,
-                       av1_global_motion_types_tree);
-#endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_LOOP_RESTORATION
   av1_tokens_from_tree(switchable_restore_encodings,
                        av1_switchable_restore_tree);
 #endif  // CONFIG_LOOP_RESTORATION
 
   /* This hack is necessary when CONFIG_DUAL_FILTER is enabled because the five
       SWITCHABLE_FILTERS are not consecutive, e.g., 0, 1, 2, 3, 4, when doing
       an in-order traversal of the av1_switchable_interp_tree structure. */
@@ -190,154 +195,186 @@ void av1_encode_token_init(void) {
     av1_indices_from_tree(av1_ext_tx_intra_ind[s], av1_ext_tx_intra_inv[s],
                           av1_ext_tx_intra_tree[s]);
   for (s = 1; s < EXT_TX_SETS_INTER; ++s)
     av1_indices_from_tree(av1_ext_tx_inter_ind[s], av1_ext_tx_inter_inv[s],
                           av1_ext_tx_inter_tree[s]);
 #else
   av1_indices_from_tree(av1_ext_tx_ind, av1_ext_tx_inv, av1_ext_tx_tree);
 #endif
+#if !CONFIG_EC_ADAPT
   av1_indices_from_tree(av1_intra_mode_ind, av1_intra_mode_inv,
                         av1_intra_mode_tree);
-  av1_indices_from_tree(av1_inter_mode_ind, av1_inter_mode_inv,
-                        av1_inter_mode_tree);
+#endif
 }
 
 static void write_intra_mode_kf(const AV1_COMMON *cm, FRAME_CONTEXT *frame_ctx,
                                 const MODE_INFO *mi, const MODE_INFO *above_mi,
                                 const MODE_INFO *left_mi, int block,
                                 PREDICTION_MODE mode, aom_writer *w) {
 #if CONFIG_INTRABC
   assert(!is_intrabc_block(&mi->mbmi));
 #endif  // CONFIG_INTRABC
   aom_write_symbol(w, av1_intra_mode_ind[mode],
                    get_y_mode_cdf(frame_ctx, mi, above_mi, left_mi, block),
                    INTRA_MODES);
   (void)cm;
 }
 
-#if CONFIG_EXT_INTER && CONFIG_INTERINTRA
-static void write_interintra_mode(aom_writer *w, INTERINTRA_MODE mode,
-                                  const aom_prob *probs) {
-  av1_write_token(w, av1_interintra_mode_tree, probs,
-                  &interintra_mode_encodings[mode]);
-}
-#endif  // CONFIG_EXT_INTER && CONFIG_INTERINTRA
-
 static void write_inter_mode(aom_writer *w, PREDICTION_MODE mode,
                              FRAME_CONTEXT *ec_ctx, const int16_t mode_ctx) {
   const int16_t newmv_ctx = mode_ctx & NEWMV_CTX_MASK;
-  const aom_prob newmv_prob = ec_ctx->newmv_prob[newmv_ctx];
-
-  aom_write(w, mode != NEWMV, newmv_prob);
+
+#if CONFIG_NEW_MULTISYMBOL
+  aom_write_symbol(w, mode != NEWMV, ec_ctx->newmv_cdf[newmv_ctx], 2);
+#else
+  aom_write(w, mode != NEWMV, ec_ctx->newmv_prob[newmv_ctx]);
+#endif
 
   if (mode != NEWMV) {
-    const int16_t zeromv_ctx = (mode_ctx >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK;
-    const aom_prob zeromv_prob = ec_ctx->zeromv_prob[zeromv_ctx];
-
     if (mode_ctx & (1 << ALL_ZERO_FLAG_OFFSET)) {
       assert(mode == ZEROMV);
       return;
     }
 
-    aom_write(w, mode != ZEROMV, zeromv_prob);
+    const int16_t zeromv_ctx = (mode_ctx >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK;
+#if CONFIG_NEW_MULTISYMBOL
+    aom_write_symbol(w, mode != ZEROMV, ec_ctx->zeromv_cdf[zeromv_ctx], 2);
+#else
+    aom_write(w, mode != ZEROMV, ec_ctx->zeromv_prob[zeromv_ctx]);
+#endif
 
     if (mode != ZEROMV) {
       int16_t refmv_ctx = (mode_ctx >> REFMV_OFFSET) & REFMV_CTX_MASK;
-      aom_prob refmv_prob;
 
       if (mode_ctx & (1 << SKIP_NEARESTMV_OFFSET)) refmv_ctx = 6;
       if (mode_ctx & (1 << SKIP_NEARMV_OFFSET)) refmv_ctx = 7;
       if (mode_ctx & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) refmv_ctx = 8;
-
-      refmv_prob = ec_ctx->refmv_prob[refmv_ctx];
-      aom_write(w, mode != NEARESTMV, refmv_prob);
+#if CONFIG_NEW_MULTISYMBOL
+      aom_write_symbol(w, mode != NEARESTMV, ec_ctx->refmv_cdf[refmv_ctx], 2);
+#else
+      aom_write(w, mode != NEARESTMV, ec_ctx->refmv_prob[refmv_ctx]);
+#endif
     }
   }
 }
 
-static void write_drl_idx(const AV1_COMMON *cm, const MB_MODE_INFO *mbmi,
+static void write_drl_idx(FRAME_CONTEXT *ec_ctx, const MB_MODE_INFO *mbmi,
                           const MB_MODE_INFO_EXT *mbmi_ext, aom_writer *w) {
   uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
 
   assert(mbmi->ref_mv_idx < 3);
 
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+  if (mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV ||
+      mbmi->mode == SR_NEW_NEWMV) {
+#else   // !CONFIG_COMPOUND_SINGLEREF
   if (mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV) {
-#else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+#else   // !CONFIG_EXT_INTER
   if (mbmi->mode == NEWMV) {
-#endif
+#endif  // CONFIG_EXT_INTER
     int idx;
     for (idx = 0; idx < 2; ++idx) {
       if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1) {
         uint8_t drl_ctx =
             av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx);
-        aom_prob drl_prob = cm->fc->drl_prob[drl_ctx];
-
-        aom_write(w, mbmi->ref_mv_idx != idx, drl_prob);
+
+#if CONFIG_NEW_MULTISYMBOL
+        aom_write_symbol(w, mbmi->ref_mv_idx != idx, ec_ctx->drl_cdf[drl_ctx],
+                         2);
+#else
+        aom_write(w, mbmi->ref_mv_idx != idx, ec_ctx->drl_prob[drl_ctx]);
+#endif
         if (mbmi->ref_mv_idx == idx) return;
       }
     }
     return;
   }
 
   if (have_nearmv_in_inter_mode(mbmi->mode)) {
     int idx;
     // TODO(jingning): Temporary solution to compensate the NEARESTMV offset.
     for (idx = 1; idx < 3; ++idx) {
       if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1) {
         uint8_t drl_ctx =
             av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx);
-        aom_prob drl_prob = cm->fc->drl_prob[drl_ctx];
-
-        aom_write(w, mbmi->ref_mv_idx != (idx - 1), drl_prob);
+#if CONFIG_NEW_MULTISYMBOL
+        aom_write_symbol(w, mbmi->ref_mv_idx != (idx - 1),
+                         ec_ctx->drl_cdf[drl_ctx], 2);
+#else
+        aom_write(w, mbmi->ref_mv_idx != (idx - 1), ec_ctx->drl_prob[drl_ctx]);
+#endif
         if (mbmi->ref_mv_idx == (idx - 1)) return;
       }
     }
     return;
   }
 }
 
 #if CONFIG_EXT_INTER
-static void write_inter_compound_mode(AV1_COMMON *cm, aom_writer *w,
-                                      PREDICTION_MODE mode,
+static void write_inter_compound_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
+                                      aom_writer *w, PREDICTION_MODE mode,
                                       const int16_t mode_ctx) {
+  assert(is_inter_compound_mode(mode));
+#if CONFIG_EC_ADAPT
+  (void)cm;
+  aom_write_symbol(w, INTER_COMPOUND_OFFSET(mode),
+                   xd->tile_ctx->inter_compound_mode_cdf[mode_ctx],
+                   INTER_COMPOUND_MODES);
+#else
+  (void)xd;
   const aom_prob *const inter_compound_probs =
       cm->fc->inter_compound_mode_probs[mode_ctx];
 
-  assert(is_inter_compound_mode(mode));
   av1_write_token(w, av1_inter_compound_mode_tree, inter_compound_probs,
                   &inter_compound_mode_encodings[INTER_COMPOUND_OFFSET(mode)]);
+#endif
 }
+
+#if CONFIG_COMPOUND_SINGLEREF
+static void write_inter_singleref_comp_mode(AV1_COMMON *cm, aom_writer *w,
+                                            PREDICTION_MODE mode,
+                                            const int16_t mode_ctx) {
+  assert(is_inter_singleref_comp_mode(mode));
+  const aom_prob *const inter_singleref_comp_probs =
+      cm->fc->inter_singleref_comp_mode_probs[mode_ctx];
+
+  av1_write_token(
+      w, av1_inter_singleref_comp_mode_tree, inter_singleref_comp_probs,
+      &inter_singleref_comp_mode_encodings[INTER_SINGLEREF_COMP_OFFSET(mode)]);
+}
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #endif  // CONFIG_EXT_INTER
 
 static void encode_unsigned_max(struct aom_write_bit_buffer *wb, int data,
                                 int max) {
   aom_wb_write_literal(wb, data, get_unsigned_bits(max));
 }
 
 #if !CONFIG_EC_ADAPT || \
     (CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION || CONFIG_EXT_INTER)
 static void prob_diff_update(const aom_tree_index *tree,
                              aom_prob probs[/*n - 1*/],
-                             const unsigned int counts[/*n - 1*/], int n,
+                             const unsigned int counts[/* n */], int n,
                              int probwt, aom_writer *w) {
   int i;
   unsigned int branch_ct[32][2];
 
   // Assuming max number of probabilities <= 32
   assert(n <= 32);
 
   av1_tree_probs_from_distribution(tree, branch_ct, counts);
   for (i = 0; i < n - 1; ++i)
     av1_cond_prob_diff_update(w, &probs[i], branch_ct[i], probwt);
 }
 #endif
 
-#if CONFIG_EXT_INTER || !CONFIG_EC_ADAPT
+#if !CONFIG_EC_ADAPT || CONFIG_COMPOUND_SINGLEREF
 static int prob_diff_update_savings(const aom_tree_index *tree,
                                     aom_prob probs[/*n - 1*/],
                                     const unsigned int counts[/*n - 1*/], int n,
                                     int probwt) {
   int i;
   unsigned int branch_ct[32][2];
   int savings = 0;
 
@@ -345,17 +382,17 @@ static int prob_diff_update_savings(cons
   assert(n <= 32);
   av1_tree_probs_from_distribution(tree, branch_ct, counts);
   for (i = 0; i < n - 1; ++i) {
     savings +=
         av1_cond_prob_diff_update_savings(&probs[i], branch_ct[i], probwt);
   }
   return savings;
 }
-#endif  // CONFIG_EXT_INTER || !CONFIG_EC_ADAPT
+#endif  // !CONFIG_EC_ADAPT || CONFIG_COMPOUND_SINGLEREF
 
 #if CONFIG_VAR_TX
 static void write_tx_size_vartx(const AV1_COMMON *cm, const MACROBLOCKD *xd,
                                 const MB_MODE_INFO *mbmi, TX_SIZE tx_size,
                                 int depth, int blk_row, int blk_col,
                                 aom_writer *w) {
   const int tx_row = blk_row >> 1;
   const int tx_col = blk_col >> 1;
@@ -442,16 +479,17 @@ static void write_selected_tx_size(const
 #if CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
     if (is_quarter_tx_allowed(xd, mbmi, is_inter) && tx_size != coded_tx_size)
       aom_write(w, tx_size == quarter_txsize_lookup[bsize],
                 cm->fc->quarter_tx_size_prob);
 #endif  // CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
   }
 }
 
+#if !CONFIG_NEW_MULTISYMBOL
 static void update_inter_mode_probs(AV1_COMMON *cm, aom_writer *w,
                                     FRAME_COUNTS *counts) {
   int i;
 #if CONFIG_TILE_GROUPS
   const int probwt = cm->num_tg;
 #else
   const int probwt = 1;
 #endif
@@ -463,18 +501,20 @@ static void update_inter_mode_probs(AV1_
                               counts->zeromv_mode[i], probwt);
   for (i = 0; i < REFMV_MODE_CONTEXTS; ++i)
     av1_cond_prob_diff_update(w, &cm->fc->refmv_prob[i], counts->refmv_mode[i],
                               probwt);
   for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
     av1_cond_prob_diff_update(w, &cm->fc->drl_prob[i], counts->drl_mode[i],
                               probwt);
 }
+#endif
 
 #if CONFIG_EXT_INTER
+#if !CONFIG_EC_ADAPT
 static void update_inter_compound_mode_probs(AV1_COMMON *cm, int probwt,
                                              aom_writer *w) {
   const int savings_thresh = av1_cost_one(GROUP_DIFF_UPDATE_PROB) -
                              av1_cost_zero(GROUP_DIFF_UPDATE_PROB);
   int i;
   int savings = 0;
   int do_update = 0;
   for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
@@ -487,53 +527,132 @@ static void update_inter_compound_mode_p
   if (do_update) {
     for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
       prob_diff_update(
           av1_inter_compound_mode_tree, cm->fc->inter_compound_mode_probs[i],
           cm->counts.inter_compound_mode[i], INTER_COMPOUND_MODES, probwt, w);
     }
   }
 }
+#endif
+
+#if CONFIG_COMPOUND_SINGLEREF
+static void update_inter_singleref_comp_mode_probs(AV1_COMMON *cm, int probwt,
+                                                   aom_writer *w) {
+  const int savings_thresh = av1_cost_one(GROUP_DIFF_UPDATE_PROB) -
+                             av1_cost_zero(GROUP_DIFF_UPDATE_PROB);
+  int i;
+  int savings = 0;
+  int do_update = 0;
+  for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
+    savings +=
+        prob_diff_update_savings(av1_inter_singleref_comp_mode_tree,
+                                 cm->fc->inter_singleref_comp_mode_probs[i],
+                                 cm->counts.inter_singleref_comp_mode[i],
+                                 INTER_SINGLEREF_COMP_MODES, probwt);
+  }
+  do_update = savings > savings_thresh;
+  aom_write(w, do_update, GROUP_DIFF_UPDATE_PROB);
+  if (do_update) {
+    for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
+      prob_diff_update(av1_inter_singleref_comp_mode_tree,
+                       cm->fc->inter_singleref_comp_mode_probs[i],
+                       cm->counts.inter_singleref_comp_mode[i],
+                       INTER_SINGLEREF_COMP_MODES, probwt, w);
+    }
+  }
+}
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #endif  // CONFIG_EXT_INTER
 
 static int write_skip(const AV1_COMMON *cm, const MACROBLOCKD *xd,
                       int segment_id, const MODE_INFO *mi, aom_writer *w) {
   if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)) {
     return 1;
   } else {
     const int skip = mi->mbmi.skip;
+#if CONFIG_NEW_MULTISYMBOL
+    FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
+    const int ctx = av1_get_skip_context(xd);
+    aom_write_symbol(w, skip, ec_ctx->skip_cdfs[ctx], 2);
+#else
     aom_write(w, skip, av1_get_skip_prob(cm, xd));
+#endif
     return skip;
   }
 }
 
+static void write_is_inter(const AV1_COMMON *cm, const MACROBLOCKD *xd,
+                           int segment_id, aom_writer *w, const int is_inter) {
+  if (!segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
+#if CONFIG_NEW_MULTISYMBOL
+    FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
+    const int ctx = av1_get_intra_inter_context(xd);
+    aom_write_symbol(w, is_inter, ec_ctx->intra_inter_cdf[ctx], 2);
+#else
+    aom_write(w, is_inter, av1_get_intra_inter_prob(cm, xd));
+#endif
+  }
+}
+
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 static void write_motion_mode(const AV1_COMMON *cm, const MODE_INFO *mi,
                               aom_writer *w) {
   const MB_MODE_INFO *mbmi = &mi->mbmi;
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+  MOTION_MODE last_motion_mode_allowed =
+      motion_mode_allowed_wrapper(0,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                  0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                  mi);
+#else
   MOTION_MODE last_motion_mode_allowed = motion_mode_allowed(
 #if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
       0, cm->global_motion,
 #endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
       mi);
-
+#endif  // CONFIG_NCOBMC_ADAPT_WEIGHT
   if (last_motion_mode_allowed == SIMPLE_TRANSLATION) return;
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
   if (last_motion_mode_allowed == OBMC_CAUSAL) {
     aom_write(w, mbmi->motion_mode == OBMC_CAUSAL,
               cm->fc->obmc_prob[mbmi->sb_type]);
   } else {
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
     av1_write_token(w, av1_motion_mode_tree,
                     cm->fc->motion_mode_prob[mbmi->sb_type],
                     &motion_mode_encodings[mbmi->motion_mode]);
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
   }
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
 }
+
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+static void write_ncobmc_mode(const AV1_COMMON *cm, const MODE_INFO *mi,
+                              aom_writer *w) {
+  const MB_MODE_INFO *mbmi = &mi->mbmi;
+  MOTION_MODE last_motion_mode_allowed =
+      motion_mode_allowed_wrapper(0,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                  0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                  mi);
+  ADAPT_OVERLAP_BLOCK ao_block = adapt_overlap_block_lookup[mbmi->sb_type];
+  if (last_motion_mode_allowed < NCOBMC_ADAPT_WEIGHT) return;
+
+  av1_write_token(w, av1_ncobmc_mode_tree, cm->fc->ncobmc_mode_prob[ao_block],
+                  &ncobmc_mode_encodings[mbmi->ncobmc_mode[0]]);
+
+  if (mi_size_wide[mbmi->sb_type] != mi_size_high[mbmi->sb_type]) {
+    av1_write_token(w, av1_ncobmc_mode_tree, cm->fc->ncobmc_mode_prob[ao_block],
+                    &ncobmc_mode_encodings[mbmi->ncobmc_mode[1]]);
+  }
+}
+#endif
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
 #if CONFIG_DELTA_Q
 static void write_delta_qindex(const AV1_COMMON *cm, const MACROBLOCKD *xd,
                                int delta_qindex, aom_writer *w) {
   int sign = delta_qindex < 0;
   int abs = sign ? -delta_qindex : delta_qindex;
   int rem_bits, thr;
@@ -622,29 +741,31 @@ static void update_delta_lf_probs(AV1_CO
     av1_cond_prob_diff_update(w, &cm->fc->delta_lf_prob[k], counts->delta_lf[k],
                               probwt);
   }
 }
 #endif  // CONFIG_EC_ADAPT
 #endif  // CONFIG_EXT_DELTA_Q
 #endif  // CONFIG_DELTA_Q
 
+#if !CONFIG_NEW_MULTISYMBOL
 static void update_skip_probs(AV1_COMMON *cm, aom_writer *w,
                               FRAME_COUNTS *counts) {
   int k;
 #if CONFIG_TILE_GROUPS
   const int probwt = cm->num_tg;
 #else
   const int probwt = 1;
 #endif
   for (k = 0; k < SKIP_CONTEXTS; ++k) {
     av1_cond_prob_diff_update(w, &cm->fc->skip_probs[k], counts->skip[k],
                               probwt);
   }
 }
+#endif
 
 #if !CONFIG_EC_ADAPT
 static void update_switchable_interp_probs(AV1_COMMON *cm, aom_writer *w,
                                            FRAME_COUNTS *counts) {
   int j;
   for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j) {
 #if CONFIG_TILE_GROUPS
     const int probwt = cm->num_tg;
@@ -1025,17 +1146,18 @@ static void pack_txb_tokens(aom_writer *
     TOKEN_STATS tmp_token_stats;
     init_token_stats(&tmp_token_stats);
 
 #if !CONFIG_PVQ
     tran_low_t *tcoeff = BLOCK_OFFSET(x->mbmi_ext->tcoeff[plane], block);
     uint16_t eob = x->mbmi_ext->eobs[plane][block];
     TXB_CTX txb_ctx = { x->mbmi_ext->txb_skip_ctx[plane][block],
                         x->mbmi_ext->dc_sign_ctx[plane][block] };
-    av1_write_coeffs_txb(cm, xd, w, block, plane, tcoeff, eob, &txb_ctx);
+    av1_write_coeffs_txb(cm, xd, w, block, plane, tx_size, tcoeff, eob,
+                         &txb_ctx);
 #else
     pack_pvq_tokens(w, x, xd, plane, bsize, tx_size);
 #endif
 #if CONFIG_RD_DEBUG
     token_stats->txb_coeff_cost_map[blk_row][blk_col] = tmp_token_stats.cost;
     token_stats->cost += tmp_token_stats.cost;
 #endif
   } else {
@@ -1131,16 +1253,24 @@ static void pack_txb_tokens(aom_writer *
 
 static void write_segment_id(aom_writer *w, const struct segmentation *seg,
                              struct segmentation_probs *segp, int segment_id) {
   if (seg->enabled && seg->update_map) {
     aom_write_symbol(w, segment_id, segp->tree_cdf, MAX_SEGMENTS);
   }
 }
 
+#if CONFIG_NEW_MULTISYMBOL
+#define WRITE_REF_BIT(bname, pname) \
+  aom_write_symbol(w, bname, av1_get_pred_cdf_##pname(cm, xd), 2)
+#else
+#define WRITE_REF_BIT(bname, pname) \
+  aom_write(w, bname, av1_get_pred_prob_##pname(cm, xd))
+#endif
+
 // This function encodes the reference frame
 static void write_ref_frames(const AV1_COMMON *cm, const MACROBLOCKD *xd,
                              aom_writer *w) {
   const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
   const int is_compound = has_second_ref(mbmi);
   const int segment_id = mbmi->segment_id;
 
   // If segment level coding of this signal is disabled...
@@ -1148,76 +1278,157 @@ static void write_ref_frames(const AV1_C
   if (segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
     assert(!is_compound);
     assert(mbmi->ref_frame[0] ==
            get_segdata(&cm->seg, segment_id, SEG_LVL_REF_FRAME));
   } else {
     // does the feature use compound prediction or not
     // (if not specified at the frame/segment level)
     if (cm->reference_mode == REFERENCE_MODE_SELECT) {
-#if SUB8X8_COMP_REF
-      aom_write(w, is_compound, av1_get_reference_mode_prob(cm, xd));
+#if !SUB8X8_COMP_REF
+      if (mbmi->sb_type != BLOCK_4X4)
+#endif
+#if CONFIG_NEW_MULTISYMBOL
+        aom_write_symbol(w, is_compound, av1_get_reference_mode_cdf(cm, xd), 2);
 #else
-      if (mbmi->sb_type != BLOCK_4X4)
-        aom_write(w, is_compound, av1_get_reference_mode_prob(cm, xd));
+      aom_write(w, is_compound, av1_get_reference_mode_prob(cm, xd));
 #endif
     } else {
       assert((!is_compound) == (cm->reference_mode == SINGLE_REFERENCE));
     }
 
     if (is_compound) {
+#if CONFIG_EXT_COMP_REFS
+      const COMP_REFERENCE_TYPE comp_ref_type = has_uni_comp_refs(mbmi)
+                                                    ? UNIDIR_COMP_REFERENCE
+                                                    : BIDIR_COMP_REFERENCE;
+
+#if USE_UNI_COMP_REFS
+      aom_write(w, comp_ref_type, av1_get_comp_reference_type_prob(cm, xd));
+#else   // !USE_UNI_COMP_REFS
+      // NOTE: uni-directional comp refs disabled
+      assert(comp_ref_type == BIDIR_COMP_REFERENCE);
+#endif  // USE_UNI_COMP_REFS
+
+      if (comp_ref_type == UNIDIR_COMP_REFERENCE) {
+        const int bit = mbmi->ref_frame[0] == BWDREF_FRAME;
+        aom_write(w, bit, av1_get_pred_prob_uni_comp_ref_p(cm, xd));
+        if (!bit) {
+          const int bit1 = mbmi->ref_frame[1] == GOLDEN_FRAME;
+          aom_write(w, bit1, av1_get_pred_prob_uni_comp_ref_p1(cm, xd));
+        }
+
+        return;
+      }
+#endif  // CONFIG_EXT_COMP_REFS
+
 #if CONFIG_EXT_REFS
       const int bit = (mbmi->ref_frame[0] == GOLDEN_FRAME ||
                        mbmi->ref_frame[0] == LAST3_FRAME);
-      const int bit_bwd = mbmi->ref_frame[1] == ALTREF_FRAME;
-#else  // CONFIG_EXT_REFS
+#if CONFIG_VAR_REFS
+      // Test need to explicitly code (L,L2) vs (L3,G) branch node in tree
+      if (L_OR_L2(cm) && L3_OR_G(cm))
+#endif  // CONFIG_VAR_REFS
+        WRITE_REF_BIT(bit, comp_ref_p);
+
+      if (!bit) {
+#if CONFIG_VAR_REFS
+        // Test need to explicitly code (L) vs (L2) branch node in tree
+        if (L_AND_L2(cm)) {
+#endif  // CONFIG_VAR_REFS
+          const int bit1 = mbmi->ref_frame[0] == LAST_FRAME;
+          WRITE_REF_BIT(bit1, comp_ref_p1);
+#if CONFIG_VAR_REFS
+        }
+#endif  // CONFIG_VAR_REFS
+      } else {
+#if CONFIG_VAR_REFS
+        // Test need to explicitly code (L3) vs (G) branch node in tree
+        if (L3_AND_G(cm)) {
+#endif  // CONFIG_VAR_REFS
+          const int bit2 = mbmi->ref_frame[0] == GOLDEN_FRAME;
+          WRITE_REF_BIT(bit2, comp_ref_p2);
+#if CONFIG_VAR_REFS
+        }
+#endif  // CONFIG_VAR_REFS
+      }
+
+#if CONFIG_VAR_REFS
+      // Test need to explicitly code (BWD) vs (ALT) branch node in tree
+      if (BWD_AND_ALT(cm)) {
+#endif  // CONFIG_VAR_REFS
+        const int bit_bwd = mbmi->ref_frame[1] == ALTREF_FRAME;
+        WRITE_REF_BIT(bit_bwd, comp_bwdref_p);
+#if CONFIG_VAR_REFS
+      }
+#endif  // CONFIG_VAR_REFS
+
+#else   // !CONFIG_EXT_REFS
       const int bit = mbmi->ref_frame[0] == GOLDEN_FRAME;
-#endif  // CONFIG_EXT_REFS
-
-      aom_write(w, bit, av1_get_pred_prob_comp_ref_p(cm, xd));
-
-#if CONFIG_EXT_REFS
-      if (!bit) {
-        const int bit1 = mbmi->ref_frame[0] == LAST_FRAME;
-        aom_write(w, bit1, av1_get_pred_prob_comp_ref_p1(cm, xd));
-      } else {
-        const int bit2 = mbmi->ref_frame[0] == GOLDEN_FRAME;
-        aom_write(w, bit2, av1_get_pred_prob_comp_ref_p2(cm, xd));
-      }
-      aom_write(w, bit_bwd, av1_get_pred_prob_comp_bwdref_p(cm, xd));
+      WRITE_REF_BIT(bit, comp_ref_p);
 #endif  // CONFIG_EXT_REFS
     } else {
 #if CONFIG_EXT_REFS
       const int bit0 = (mbmi->ref_frame[0] == ALTREF_FRAME ||
                         mbmi->ref_frame[0] == BWDREF_FRAME);
-      aom_write(w, bit0, av1_get_pred_prob_single_ref_p1(cm, xd));
+#if CONFIG_VAR_REFS
+      // Test need to explicitly code (L,L2,L3,G) vs (BWD,ALT) branch node in
+      // tree
+      if ((L_OR_L2(cm) || L3_OR_G(cm)) && BWD_OR_ALT(cm))
+#endif  // CONFIG_VAR_REFS
+        WRITE_REF_BIT(bit0, single_ref_p1);
 
       if (bit0) {
-        const int bit1 = mbmi->ref_frame[0] == ALTREF_FRAME;
-        aom_write(w, bit1, av1_get_pred_prob_single_ref_p2(cm, xd));
+#if CONFIG_VAR_REFS
+        // Test need to explicitly code (BWD) vs (ALT) branch node in tree
+        if (BWD_AND_ALT(cm)) {
+#endif  // CONFIG_VAR_REFS
+          const int bit1 = mbmi->ref_frame[0] == ALTREF_FRAME;
+          WRITE_REF_BIT(bit1, single_ref_p2);
+#if CONFIG_VAR_REFS
+        }
+#endif  // CONFIG_VAR_REFS
       } else {
         const int bit2 = (mbmi->ref_frame[0] == LAST3_FRAME ||
                           mbmi->ref_frame[0] == GOLDEN_FRAME);
-        aom_write(w, bit2, av1_get_pred_prob_single_ref_p3(cm, xd));
+#if CONFIG_VAR_REFS
+        // Test need to explicitly code (L,L2) vs (L3,G) branch node in tree
+        if (L_OR_L2(cm) && L3_OR_G(cm))
+#endif  // CONFIG_VAR_REFS
+          WRITE_REF_BIT(bit2, single_ref_p3);
 
         if (!bit2) {
-          const int bit3 = mbmi->ref_frame[0] != LAST_FRAME;
-          aom_write(w, bit3, av1_get_pred_prob_single_ref_p4(cm, xd));
+#if CONFIG_VAR_REFS
+          // Test need to explicitly code (L) vs (L2) branch node in tree
+          if (L_AND_L2(cm)) {
+#endif  // CONFIG_VAR_REFS
+            const int bit3 = mbmi->ref_frame[0] != LAST_FRAME;
+            WRITE_REF_BIT(bit3, single_ref_p4);
+#if CONFIG_VAR_REFS
+          }
+#endif  // CONFIG_VAR_REFS
         } else {
-          const int bit4 = mbmi->ref_frame[0] != LAST3_FRAME;
-          aom_write(w, bit4, av1_get_pred_prob_single_ref_p5(cm, xd));
+#if CONFIG_VAR_REFS
+          // Test need to explicitly code (L3) vs (G) branch node in tree
+          if (L3_AND_G(cm)) {
+#endif  // CONFIG_VAR_REFS
+            const int bit4 = mbmi->ref_frame[0] != LAST3_FRAME;
+            WRITE_REF_BIT(bit4, single_ref_p5);
+#if CONFIG_VAR_REFS
+          }
+#endif  // CONFIG_VAR_REFS
         }
       }
-#else   // CONFIG_EXT_REFS
+#else   // !CONFIG_EXT_REFS
       const int bit0 = mbmi->ref_frame[0] != LAST_FRAME;
-      aom_write(w, bit0, av1_get_pred_prob_single_ref_p1(cm, xd));
+      WRITE_REF_BIT(bit0, single_ref_p1);
 
       if (bit0) {
         const int bit1 = mbmi->ref_frame[0] != GOLDEN_FRAME;
-        aom_write(w, bit1, av1_get_pred_prob_single_ref_p2(cm, xd));
+        WRITE_REF_BIT(bit1, single_ref_p2);
       }
 #endif  // CONFIG_EXT_REFS
     }
   }
 }
 
 #if CONFIG_FILTER_INTRA
 static void write_filter_intra_mode_info(const AV1_COMMON *const cm,
@@ -1272,17 +1483,17 @@ static void write_intra_angle_info(const
   const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
   const BLOCK_SIZE bsize = mbmi->sb_type;
 #if CONFIG_INTRA_INTERP
   const int intra_filter_ctx = av1_get_pred_context_intra_interp(xd);
   int p_angle;
 #endif  // CONFIG_INTRA_INTERP
 
   (void)ec_ctx;
-  if (bsize < BLOCK_8X8) return;
+  if (!av1_use_angle_delta(bsize)) return;
 
   if (av1_is_directional_mode(mbmi->mode, bsize)) {
     write_uniform(w, 2 * MAX_ANGLE_DELTA + 1,
                   MAX_ANGLE_DELTA + mbmi->angle_delta[0]);
 #if CONFIG_INTRA_INTERP
     p_angle = mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP;
     if (av1_is_intra_filter_switchable(p_angle)) {
       aom_write_symbol(w, mbmi->intra_filter,
@@ -1538,26 +1749,28 @@ static void write_palette_mode_info(cons
 }
 #endif  // CONFIG_PALETTE
 
 void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
 #if CONFIG_SUPERTX
                        const int supertx_enabled,
 #endif
 #if CONFIG_TXK_SEL
-                       int block, int plane,
+                       int block, int plane, TX_SIZE tx_size,
 #endif
                        aom_writer *w) {
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   const int is_inter = is_inter_block(mbmi);
+#if !CONFIG_TXK_SEL
 #if CONFIG_VAR_TX
   const TX_SIZE tx_size = is_inter ? mbmi->min_tx_size : mbmi->tx_size;
 #else
   const TX_SIZE tx_size = mbmi->tx_size;
 #endif  // CONFIG_VAR_TX
+#endif  // !CONFIG_TXK_SEL
 #if CONFIG_EC_ADAPT
   FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
 #else
   FRAME_CONTEXT *ec_ctx = cm->fc;
 #endif
 
 #if !CONFIG_TXK_SEL
   TX_TYPE tx_type = mbmi->tx_type;
@@ -1578,31 +1791,30 @@ void av1_write_tx_type(const AV1_COMMON 
          (cm->seg.enabled && xd->qindex[mbmi->segment_id] > 0)) &&
         !mbmi->skip &&
 #if CONFIG_SUPERTX
         !supertx_enabled &&
 #endif  // CONFIG_SUPERTX
         !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
       const int eset =
           get_ext_tx_set(tx_size, bsize, is_inter, cm->reduced_tx_set_used);
+      // eset == 0 should correspond to a set with only DCT_DCT and there
+      // is no need to send the tx_type
+      assert(eset > 0);
       if (is_inter) {
         assert(ext_tx_used_inter[eset][tx_type]);
-        if (eset > 0) {
-          aom_write_symbol(w, av1_ext_tx_inter_ind[eset][tx_type],
-                           ec_ctx->inter_ext_tx_cdf[eset][square_tx_size],
-                           ext_tx_cnt_inter[eset]);
-        }
+        aom_write_symbol(w, av1_ext_tx_inter_ind[eset][tx_type],
+                         ec_ctx->inter_ext_tx_cdf[eset][square_tx_size],
+                         ext_tx_cnt_inter[eset]);
       } else if (ALLOW_INTRA_EXT_TX) {
         assert(ext_tx_used_intra[eset][tx_type]);
-        if (eset > 0) {
-          aom_write_symbol(
-              w, av1_ext_tx_intra_ind[eset][tx_type],
-              ec_ctx->intra_ext_tx_cdf[eset][square_tx_size][mbmi->mode],
-              ext_tx_cnt_intra[eset]);
-        }
+        aom_write_symbol(
+            w, av1_ext_tx_intra_ind[eset][tx_type],
+            ec_ctx->intra_ext_tx_cdf[eset][square_tx_size][mbmi->mode],
+            ext_tx_cnt_intra[eset]);
       }
     }
 #else
     if (tx_size < TX_32X32 &&
         ((!cm->seg.enabled && cm->base_qindex > 0) ||
          (cm->seg.enabled && xd->qindex[mbmi->segment_id] > 0)) &&
         !mbmi->skip &&
 #if CONFIG_SUPERTX
@@ -1634,39 +1846,33 @@ static void write_intra_mode(FRAME_CONTE
 static void write_intra_uv_mode(FRAME_CONTEXT *frame_ctx,
                                 PREDICTION_MODE uv_mode, PREDICTION_MODE y_mode,
                                 aom_writer *w) {
   aom_write_symbol(w, av1_intra_mode_ind[uv_mode],
                    frame_ctx->uv_mode_cdf[y_mode], INTRA_MODES);
 }
 
 #if CONFIG_CFL
-static void write_cfl_alphas(FRAME_CONTEXT *const frame_ctx, int skip, int ind,
+static void write_cfl_alphas(FRAME_CONTEXT *const frame_ctx, int ind,
                              const CFL_SIGN_TYPE signs[CFL_SIGNS],
                              aom_writer *w) {
-  if (skip) {
-    assert(ind == 0);
+  // Check for uninitialized signs
+  if (cfl_alpha_codes[ind][CFL_PRED_U] == 0)
     assert(signs[CFL_PRED_U] == CFL_SIGN_POS);
+  if (cfl_alpha_codes[ind][CFL_PRED_V] == 0)
     assert(signs[CFL_PRED_V] == CFL_SIGN_POS);
-  } else {
-    // Check for uninitialized signs
-    if (cfl_alpha_codes[ind][CFL_PRED_U] == 0)
-      assert(signs[CFL_PRED_U] == CFL_SIGN_POS);
-    if (cfl_alpha_codes[ind][CFL_PRED_V] == 0)
-      assert(signs[CFL_PRED_V] == CFL_SIGN_POS);
-
-    // Write a symbol representing a combination of alpha Cb and alpha Cr.
-    aom_write_symbol(w, ind, frame_ctx->cfl_alpha_cdf, CFL_ALPHABET_SIZE);
-
-    // Signs are only signaled for nonzero codes.
-    if (cfl_alpha_codes[ind][CFL_PRED_U] != 0)
-      aom_write_bit(w, signs[CFL_PRED_U]);
-    if (cfl_alpha_codes[ind][CFL_PRED_V] != 0)
-      aom_write_bit(w, signs[CFL_PRED_V]);
-  }
+
+  // Write a symbol representing a combination of alpha Cb and alpha Cr.
+  aom_write_symbol(w, ind, frame_ctx->cfl_alpha_cdf, CFL_ALPHABET_SIZE);
+
+  // Signs are only signaled for nonzero codes.
+  if (cfl_alpha_codes[ind][CFL_PRED_U] != 0)
+    aom_write_bit(w, signs[CFL_PRED_U]);
+  if (cfl_alpha_codes[ind][CFL_PRED_V] != 0)
+    aom_write_bit(w, signs[CFL_PRED_V]);
 }
 #endif
 
 static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
                                 const int mi_col,
 #if CONFIG_SUPERTX
                                 int supertx_enabled,
 #endif
@@ -1745,18 +1951,17 @@ static void pack_inter_mode_mvs(AV1_COMP
 #endif  // CONFIG_EXT_DELTA_Q
     }
   }
 #endif
 
 #if CONFIG_SUPERTX
   if (!supertx_enabled)
 #endif  // CONFIG_SUPERTX
-    if (!segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME))
-      aom_write(w, is_inter, av1_get_intra_inter_prob(cm, xd));
+    write_is_inter(cm, xd, mbmi->segment_id, w, is_inter);
 
   if (cm->tx_mode == TX_MODE_SELECT &&
 #if CONFIG_CB4X4 && (CONFIG_VAR_TX || CONFIG_RECT_TX)
 #if CONFIG_RECT_TX
       bsize > BLOCK_4X4 &&
 #else
       (bsize >= BLOCK_8X8 || (bsize > BLOCK_4X4 && is_inter)) &&
 #endif  // CONFIG_RECT_TX
@@ -1809,18 +2014,17 @@ static void pack_inter_mode_mvs(AV1_COMP
                             xd->plane[1].subsampling_y)) {
       write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mode, w);
 #else  // !CONFIG_CB4X4
     write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mode, w);
 #endif  // CONFIG_CB4X4
 
 #if CONFIG_CFL
       if (mbmi->uv_mode == DC_PRED) {
-        write_cfl_alphas(ec_ctx, mbmi->skip, mbmi->cfl_alpha_idx,
-                         mbmi->cfl_alpha_signs, w);
+        write_cfl_alphas(ec_ctx, mbmi->cfl_alpha_idx, mbmi->cfl_alpha_signs, w);
       }
 #endif
 
 #if CONFIG_CB4X4
     }
 #endif
 
 #if CONFIG_EXT_INTRA
@@ -1833,66 +2037,91 @@ static void pack_inter_mode_mvs(AV1_COMP
 #if CONFIG_FILTER_INTRA
     if (bsize >= BLOCK_8X8 || unify_bsize)
       write_filter_intra_mode_info(cm, xd, mbmi, mi_row, mi_col, w);
 #endif  // CONFIG_FILTER_INTRA
   } else {
     int16_t mode_ctx;
     write_ref_frames(cm, xd, w);
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    if (!segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME)) {
+      // NOTE: Handle single ref comp mode
+      if (!is_compound)
+        aom_write(w, is_inter_singleref_comp_mode(mode),
+                  av1_get_inter_mode_prob(cm, xd));
+    }
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+    if (is_compound || is_inter_singleref_comp_mode(mode))
+#else   // !CONFIG_COMPOUND_SINGLEREF
     if (is_compound)
+#endif  // CONFIG_COMPOUND_SINGLEREF
       mode_ctx = mbmi_ext->compound_mode_context[mbmi->ref_frame[0]];
     else
 #endif  // CONFIG_EXT_INTER
+
       mode_ctx = av1_mode_context_analyzer(mbmi_ext->mode_context,
                                            mbmi->ref_frame, bsize, -1);
 
     // If segment skip is not enabled code the mode.
     if (!segfeature_active(seg, segment_id, SEG_LVL_SKIP)) {
       if (bsize >= BLOCK_8X8 || unify_bsize) {
 #if CONFIG_EXT_INTER
         if (is_inter_compound_mode(mode))
-          write_inter_compound_mode(cm, w, mode, mode_ctx);
+          write_inter_compound_mode(cm, xd, w, mode, mode_ctx);
+#if CONFIG_COMPOUND_SINGLEREF
+        else if (is_inter_singleref_comp_mode(mode))
+          write_inter_singleref_comp_mode(cm, w, mode, mode_ctx);
+#endif  // CONFIG_COMPOUND_SINGLEREF
         else if (is_inter_singleref_mode(mode))
 #endif  // CONFIG_EXT_INTER
           write_inter_mode(w, mode, ec_ctx, mode_ctx);
 
 #if CONFIG_EXT_INTER
         if (mode == NEWMV || mode == NEW_NEWMV ||
+#if CONFIG_COMPOUND_SINGLEREF
+            mbmi->mode == SR_NEW_NEWMV ||
+#endif  // CONFIG_COMPOUND_SINGLEREF
             have_nearmv_in_inter_mode(mode))
-#else
+#else   // !CONFIG_EXT_INTER
         if (mode == NEARMV || mode == NEWMV)
-#endif
-          write_drl_idx(cm, mbmi, mbmi_ext, w);
+#endif  // CONFIG_EXT_INTER
+          write_drl_idx(ec_ctx, mbmi, mbmi_ext, w);
         else
           assert(mbmi->ref_mv_idx == 0);
       }
     }
 
 #if !CONFIG_DUAL_FILTER && !CONFIG_WARPED_MOTION && !CONFIG_GLOBAL_MOTION
     write_mb_interp_filter(cpi, xd, w);
 #endif  // !CONFIG_DUAL_FILTER && !CONFIG_WARPED_MOTION
 
     if (bsize < BLOCK_8X8 && !unify_bsize) {
+#if CONFIG_COMPOUND_SINGLEREF
+      /// NOTE: Single ref comp mode does not support sub8x8.
+      assert(is_compound || !is_inter_singleref_comp_mode(mbmi->mode));
+#endif  // CONFIG_COMPOUND_SINGLEREF
       const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
       const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];
       int idx, idy;
       for (idy = 0; idy < 2; idy += num_4x4_h) {
         for (idx = 0; idx < 2; idx += num_4x4_w) {
           const int j = idy * 2 + idx;
           const PREDICTION_MODE b_mode = mi->bmi[j].as_mode;
 #if CONFIG_EXT_INTER
           if (!is_compound)
 #endif  // CONFIG_EXT_INTER
             mode_ctx = av1_mode_context_analyzer(mbmi_ext->mode_context,
                                                  mbmi->ref_frame, bsize, j);
 #if CONFIG_EXT_INTER
           if (is_inter_compound_mode(b_mode))
-            write_inter_compound_mode(cm, w, b_mode, mode_ctx);
+            write_inter_compound_mode(cm, xd, w, b_mode, mode_ctx);
           else if (is_inter_singleref_mode(b_mode))
 #endif  // CONFIG_EXT_INTER
             write_inter_mode(w, b_mode, ec_ctx, mode_ctx);
 
 #if CONFIG_EXT_INTER
           if (b_mode == NEWMV || b_mode == NEW_NEWMV) {
 #else
           if (b_mode == NEWMV) {
@@ -1964,35 +2193,67 @@ static void pack_inter_mode_mvs(AV1_COMP
         int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
         int nmv_ctx =
             av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                         mbmi_ext->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
         nmv_context *nmvc = &ec_ctx->nmvc[nmv_ctx];
         av1_encode_mv(cpi, w, &mbmi->mv[0].as_mv,
                       &mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0].as_mv, nmvc,
                       allow_hp);
+#if CONFIG_COMPOUND_SINGLEREF
+      } else if (  //  mode == SR_NEAREST_NEWMV ||
+          mode == SR_NEAR_NEWMV || mode == SR_ZERO_NEWMV ||
+          mode == SR_NEW_NEWMV) {
+        int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
+        int nmv_ctx =
+            av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
+                        mbmi_ext->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
+        nmv_context *nmvc = &ec_ctx->nmvc[nmv_ctx];
+        int_mv ref_mv = mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0];
+        if (mode == SR_NEW_NEWMV)
+          av1_encode_mv(cpi, w, &mbmi->mv[0].as_mv, &ref_mv.as_mv, nmvc,
+                        allow_hp);
+        av1_encode_mv(cpi, w, &mbmi->mv[1].as_mv, &ref_mv.as_mv, nmvc,
+                      allow_hp);
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #endif  // CONFIG_EXT_INTER
       }
     }
 
 #if CONFIG_EXT_INTER && CONFIG_INTERINTRA
     if (cpi->common.reference_mode != COMPOUND_REFERENCE &&
 #if CONFIG_SUPERTX
         !supertx_enabled &&
 #endif  // CONFIG_SUPERTX
         cpi->common.allow_interintra_compound && is_interintra_allowed(mbmi)) {
       const int interintra = mbmi->ref_frame[1] == INTRA_FRAME;
       const int bsize_group = size_group_lookup[bsize];
+#if CONFIG_NEW_MULTISYMBOL
+      aom_write_symbol(w, interintra, ec_ctx->interintra_cdf[bsize_group], 2);
+#else
       aom_write(w, interintra, cm->fc->interintra_prob[bsize_group]);
+#endif
       if (interintra) {
-        write_interintra_mode(w, mbmi->interintra_mode,
-                              cm->fc->interintra_mode_prob[bsize_group]);
+#if CONFIG_EC_ADAPT
+        aom_write_symbol(w, mbmi->interintra_mode,
+                         ec_ctx->interintra_mode_cdf[bsize_group],
+                         INTERINTRA_MODES);
+#else
+        av1_write_token(w, av1_interintra_mode_tree,
+                        cm->fc->interintra_mode_prob[bsize_group],
+                        &interintra_mode_encodings[mbmi->interintra_mode]);
+#endif
         if (is_interintra_wedge_used(bsize)) {
+#if CONFIG_NEW_MULTISYMBOL
+          aom_write_symbol(w, mbmi->use_wedge_interintra,
+                           ec_ctx->wedge_interintra_cdf[bsize], 2);
+#else
           aom_write(w, mbmi->use_wedge_interintra,
                     cm->fc->wedge_interintra_prob[bsize]);
+#endif
           if (mbmi->use_wedge_interintra) {
             aom_write_literal(w, mbmi->interintra_wedge_index,
                               get_wedge_bits_lookup(bsize));
             assert(mbmi->interintra_wedge_sign == 0);
           }
         }
       }
     }
@@ -2001,30 +2262,43 @@ static void pack_inter_mode_mvs(AV1_COMP
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 #if CONFIG_SUPERTX
     if (!supertx_enabled)
 #endif  // CONFIG_SUPERTX
 #if CONFIG_EXT_INTER
       if (mbmi->ref_frame[1] != INTRA_FRAME)
 #endif  // CONFIG_EXT_INTER
         write_motion_mode(cm, mi, w);
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+    write_ncobmc_mode(cm, mi, w);
+#endif
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
 #if CONFIG_EXT_INTER
-    if (cpi->common.reference_mode != SINGLE_REFERENCE &&
-        is_inter_compound_mode(mbmi->mode)
+    if (
+#if CONFIG_COMPOUND_SINGLEREF
+        is_inter_anyref_comp_mode(mbmi->mode) &&
+#else   // !CONFIG_COMPOUND_SINGLEREF
+        cpi->common.reference_mode != SINGLE_REFERENCE &&
+        is_inter_compound_mode(mbmi->mode) &&
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_MOTION_VAR
-        && mbmi->motion_mode == SIMPLE_TRANSLATION
+        mbmi->motion_mode == SIMPLE_TRANSLATION &&
 #endif  // CONFIG_MOTION_VAR
-        && is_any_masked_compound_used(bsize)) {
+        is_any_masked_compound_used(bsize)) {
 #if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
       if (cm->allow_masked_compound) {
+#if CONFIG_EC_ADAPT
+        aom_write_symbol(w, mbmi->interinter_compound_type,
+                         ec_ctx->compound_type_cdf[bsize], COMPOUND_TYPES);
+#else
         av1_write_token(
             w, av1_compound_type_tree, cm->fc->compound_type_prob[bsize],
             &compound_type_encodings[mbmi->interinter_compound_type]);
+#endif
 #if CONFIG_WEDGE
         if (mbmi->interinter_compound_type == COMPOUND_WEDGE) {
           aom_write_literal(w, mbmi->wedge_index, get_wedge_bits_lookup(bsize));
           aom_write_bit(w, mbmi->wedge_sign);
         }
 #endif  // CONFIG_WEDGE
 #if CONFIG_COMPOUND_SEGMENT
         if (mbmi->interinter_compound_type == COMPOUND_SEG) {
@@ -2105,49 +2379,50 @@ static void write_mb_modes_kf(AV1_COMMON
       }
 #endif  // CONFIG_EXT_DELTA_Q
     }
   }
 #else
   write_skip(cm, xd, mbmi->segment_id, mi, w);
 #endif
 
-  if (cm->tx_mode == TX_MODE_SELECT &&
+  int enable_tx_size = cm->tx_mode == TX_MODE_SELECT &&
 #if CONFIG_CB4X4 && (CONFIG_VAR_TX || CONFIG_RECT_TX)
 #if CONFIG_RECT_TX
-      bsize > BLOCK_4X4 &&
+                       bsize > BLOCK_4X4 &&
 #else
-      bsize >= BLOCK_8X8 &&
+                       bsize >= BLOCK_8X8 &&
 #endif  // CONFIG_RECT_TX
 #else
-      bsize >= BLOCK_8X8 &&
+                       bsize >= BLOCK_8X8 &&
 #endif
-      !xd->lossless[mbmi->segment_id])
-    write_selected_tx_size(cm, xd, w);
+                       !xd->lossless[mbmi->segment_id];
 
 #if CONFIG_INTRABC
   if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools) {
     int use_intrabc = is_intrabc_block(mbmi);
     aom_write(w, use_intrabc, ec_ctx->intrabc_prob);
     if (use_intrabc) {
       assert(mbmi->mode == DC_PRED);
       assert(mbmi->uv_mode == DC_PRED);
+      if (enable_tx_size && !mbmi->skip) write_selected_tx_size(cm, xd, w);
       int_mv dv_ref = mbmi_ext->ref_mvs[INTRA_FRAME][0];
       av1_encode_dv(w, &mbmi->mv[0].as_mv, &dv_ref.as_mv, &ec_ctx->ndvc);
 #if CONFIG_EXT_TX && !CONFIG_TXK_SEL
       av1_write_tx_type(cm, xd,
 #if CONFIG_SUPERTX
                         0,
 #endif
                         w);
 #endif  // CONFIG_EXT_TX && !CONFIG_TXK_SEL
       return;
     }
   }
 #endif  // CONFIG_INTRABC
+  if (enable_tx_size) write_selected_tx_size(cm, xd, w);
 
   if (bsize >= BLOCK_8X8 || unify_bsize) {
     write_intra_mode_kf(cm, ec_ctx, mi, above_mi, left_mi, 0, mbmi->mode, w);
   } else {
     const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
     const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];
     int idx, idy;
 
@@ -2165,18 +2440,17 @@ static void write_mb_modes_kf(AV1_COMMON
                           xd->plane[1].subsampling_y)) {
     write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mbmi->mode, w);
 #else  // !CONFIG_CB4X4
   write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mbmi->mode, w);
 #endif  // CONFIG_CB4X4
 
 #if CONFIG_CFL
     if (mbmi->uv_mode == DC_PRED) {
-      write_cfl_alphas(ec_ctx, mbmi->skip, mbmi->cfl_alpha_idx,
-                       mbmi->cfl_alpha_signs, w);
+      write_cfl_alphas(ec_ctx, mbmi->cfl_alpha_idx, mbmi->cfl_alpha_signs, w);
     }
 #endif
 
 #if CONFIG_CB4X4
   }
 #endif
 #if CONFIG_EXT_INTRA
   write_intra_angle_info(xd, ec_ctx, w);
@@ -2247,16 +2521,103 @@ static int rd_token_stats_mismatch(RD_ST
     }
 #endif
     return 1;
   }
   return 0;
 }
 #endif
 
+#if ENC_MISMATCH_DEBUG
+static void enc_dump_logs(AV1_COMP *cpi, int mi_row, int mi_col) {
+  AV1_COMMON *const cm = &cpi->common;
+  MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
+  MODE_INFO *m;
+  xd->mi = cm->mi_grid_visible + (mi_row * cm->mi_stride + mi_col);
+  m = xd->mi[0];
+  if (is_inter_block(&m->mbmi)) {
+#define FRAME_TO_CHECK 1
+    if (cm->current_video_frame == FRAME_TO_CHECK && cm->show_frame == 0) {
+      const MB_MODE_INFO *const mbmi = &m->mbmi;
+      const BLOCK_SIZE bsize = mbmi->sb_type;
+
+      int_mv mv[2];
+      int is_comp_ref = has_second_ref(&m->mbmi);
+      int ref;
+
+      for (ref = 0; ref < 1 + is_comp_ref; ++ref)
+        mv[ref].as_mv = m->mbmi.mv[ref].as_mv;
+
+      if (!is_comp_ref) {
+#if CONFIG_COMPOUND_SINGLEREF
+        if (is_inter_singleref_comp_mode(m->mbmi.mode))
+          mv[1].as_mv = m->mbmi.mv[1].as_mv;
+        else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+          mv[1].as_int = 0;
+      }
+      int interp_ctx[2] = { -1 };
+      int interp_filter[2] = { cm->interp_filter };
+      if (cm->interp_filter == SWITCHABLE) {
+        int dir;
+        for (dir = 0; dir < 2; ++dir) {
+          if (has_subpel_mv_component(xd->mi[0], xd, dir) ||
+              (mbmi->ref_frame[1] > INTRA_FRAME &&
+               has_subpel_mv_component(xd->mi[0], xd, dir + 2))) {
+            interp_ctx[dir] = av1_get_pred_context_switchable_interp(xd, dir);
+            interp_filter[dir] = mbmi->interp_filter[dir];
+          } else {
+            interp_filter[dir] = EIGHTTAP_REGULAR;
+          }
+        }
+      }
+
+#if CONFIG_DELTA_Q || CONFIG_EC_ADAPT
+      MACROBLOCK *const x = &cpi->td.mb;
+#else
+      const MACROBLOCK *x = &cpi->td.mb;
+#endif
+      const MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
+      const int16_t mode_ctx = av1_mode_context_analyzer(
+          mbmi_ext->mode_context, mbmi->ref_frame, bsize, -1);
+      const int16_t newmv_ctx = mode_ctx & NEWMV_CTX_MASK;
+      int16_t zeromv_ctx = -1;
+      int16_t refmv_ctx = -1;
+      if (mbmi->mode != NEWMV) {
+        zeromv_ctx = (mode_ctx >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK;
+        if (mode_ctx & (1 << ALL_ZERO_FLAG_OFFSET)) {
+          assert(mbmi->mode == ZEROMV);
+        }
+        if (mbmi->mode != ZEROMV) {
+          refmv_ctx = (mode_ctx >> REFMV_OFFSET) & REFMV_CTX_MASK;
+          if (mode_ctx & (1 << SKIP_NEARESTMV_OFFSET)) refmv_ctx = 6;
+          if (mode_ctx & (1 << SKIP_NEARMV_OFFSET)) refmv_ctx = 7;
+          if (mode_ctx & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) refmv_ctx = 8;
+        }
+      }
+
+      int8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
+      printf(
+          "=== ENCODER ===: "
+          "Frame=%d, (mi_row,mi_col)=(%d,%d), mode=%d, bsize=%d, "
+          "show_frame=%d, mv[0]=(%d,%d), mv[1]=(%d,%d), ref[0]=%d, "
+          "ref[1]=%d, motion_mode=%d, inter_mode_ctx=%d, mode_ctx=%d, "
+          "interp_ctx=(%d,%d), interp_filter=(%d,%d), newmv_ctx=%d, "
+          "zeromv_ctx=%d, refmv_ctx=%d\n",
+          cm->current_video_frame, mi_row, mi_col, mbmi->mode, bsize,
+          cm->show_frame, mv[0].as_mv.row, mv[0].as_mv.col, mv[1].as_mv.row,
+          mv[1].as_mv.col, mbmi->ref_frame[0], mbmi->ref_frame[1],
+          mbmi->motion_mode, mbmi_ext->mode_context[ref_frame_type], mode_ctx,
+          interp_ctx[0], interp_ctx[1], interp_filter[0], interp_filter[1],
+          newmv_ctx, zeromv_ctx, refmv_ctx);
+    }
+  }
+}
+#endif  // ENC_MISMATCH_DEBUG
+
 static void write_mbmi_b(AV1_COMP *cpi, const TileInfo *const tile,
                          aom_writer *w,
 #if CONFIG_SUPERTX
                          int supertx_enabled,
 #endif
                          int mi_row, int mi_col) {
   AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
@@ -2291,65 +2652,52 @@ static void write_mbmi_b(AV1_COMP *cpi, 
     xd->left_txfm_context = xd->left_txfm_context_buffer +
                             ((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2);
 #endif
 #if CONFIG_DUAL_FILTER
     // has_subpel_mv_component needs the ref frame buffers set up to look
     // up if they are scaled. has_subpel_mv_component is in turn needed by
     // write_switchable_interp_filter, which is called by pack_inter_mode_mvs.
     set_ref_ptrs(cm, xd, m->mbmi.ref_frame[0], m->mbmi.ref_frame[1]);
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    if (!has_second_ref(&m->mbmi) && is_inter_singleref_comp_mode(m->mbmi.mode))
+      xd->block_refs[1] = xd->block_refs[0];
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 #endif  // CONFIG_DUAL_FILTER
-#if 0
+
+#if ENC_MISMATCH_DEBUG
     // NOTE(zoeliu): For debug
-    if (cm->current_video_frame == FRAME_TO_CHECK && cm->show_frame == 1) {
-      const PREDICTION_MODE mode = m->mbmi.mode;
-      const int segment_id = m->mbmi.segment_id;
-      const BLOCK_SIZE bsize = m->mbmi.sb_type;
-
-      // For sub8x8, simply dump out the first sub8x8 block info
-      const PREDICTION_MODE b_mode =
-          (bsize < BLOCK_8X8) ? m->bmi[0].as_mode : -1;
-      const int mv_x = (bsize < BLOCK_8X8) ?
-          m->bmi[0].as_mv[0].as_mv.row : m->mbmi.mv[0].as_mv.row;
-      const int mv_y = (bsize < BLOCK_8X8) ?
-          m->bmi[0].as_mv[0].as_mv.col : m->mbmi.mv[0].as_mv.col;
-
-      printf("Before pack_inter_mode_mvs(): "
-             "Frame=%d, (mi_row,mi_col)=(%d,%d), "
-             "mode=%d, segment_id=%d, bsize=%d, b_mode=%d, "
-             "mv[0]=(%d, %d), ref[0]=%d, ref[1]=%d\n",
-             cm->current_video_frame, mi_row, mi_col,
-             mode, segment_id, bsize, b_mode, mv_x, mv_y,
-             m->mbmi.ref_frame[0], m->mbmi.ref_frame[1]);
-    }
-#endif  // 0
+    enc_dump_logs(cpi, mi_row, mi_col);
+#endif  // ENC_MISMATCH_DEBUG
+
     pack_inter_mode_mvs(cpi, mi_row, mi_col,
 #if CONFIG_SUPERTX
                         supertx_enabled,
 #endif
                         w);
   }
 }
 
 static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile,
                            aom_writer *w, const TOKENEXTRA **tok,
                            const TOKENEXTRA *const tok_end, int mi_row,
                            int mi_col) {
   AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
-  MODE_INFO *const m = xd->mi[0];
+  const int mi_offset = mi_row * cm->mi_stride + mi_col;
+  MODE_INFO *const m = *(cm->mi_grid_visible + mi_offset);
   MB_MODE_INFO *const mbmi = &m->mbmi;
   int plane;
   int bh, bw;
 #if CONFIG_PVQ || CONFIG_LV_MAP
   MACROBLOCK *const x = &cpi->td.mb;
   (void)tok;
   (void)tok_end;
 #endif
-  xd->mi = cm->mi_grid_visible + (mi_row * cm->mi_stride + mi_col);
+  xd->mi = cm->mi_grid_visible + mi_offset;
 
   assert(mbmi->sb_type <= cm->sb_size);
 
   bh = mi_size_high[mbmi->sb_type];
   bw = mi_size_wide[mbmi->sb_type];
   cpi->td.mb.mbmi_ext = cpi->mbmi_ext_base + (mi_row * cm->mi_cols + mi_col);
 
   set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw,
@@ -2464,23 +2812,21 @@ static void write_tokens_b(AV1_COMP *cpi
                                xd->plane[plane].subsampling_y)) {
         (*tok)++;
         continue;
       }
 #endif
 #if CONFIG_VAR_TX
       const struct macroblockd_plane *const pd = &xd->plane[plane];
       BLOCK_SIZE bsize = mbmi->sb_type;
-#if CONFIG_CB4X4
-#if CONFIG_CHROMA_2X2
-      const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
-#else
+#if CONFIG_CHROMA_SUB8X8
       const BLOCK_SIZE plane_bsize =
           AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
-#endif
+#elif CONFIG_CB4X4
+      const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
 #else
       const BLOCK_SIZE plane_bsize =
           get_plane_block_size(AOMMAX(bsize, BLOCK_8X8), pd);
 #endif
 
       const int num_4x4_w =
           block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
       const int num_4x4_h =
@@ -2565,17 +2911,17 @@ static void write_tokens_b(AV1_COMP *cpi
       assert(*tok < tok_end && (*tok)->token == EOSB_TOKEN);
       (*tok)++;
 #endif
     }
   }
 #endif  // CONFIG_COEF_INTERLEAVE
 }
 
-#if CONFIG_MOTION_VAR && CONFIG_NCOBMC
+#if CONFIG_MOTION_VAR && (CONFIG_NCOBMC || CONFIG_NCOBMC_ADAPT_WEIGHT)
 static void write_tokens_sb(AV1_COMP *cpi, const TileInfo *const tile,
                             aom_writer *w, const TOKENEXTRA **tok,
                             const TOKENEXTRA *const tok_end, int mi_row,
                             int mi_col, BLOCK_SIZE bsize) {
   const AV1_COMMON *const cm = &cpi->common;
   const int hbs = mi_size_wide[bsize] / 2;
   PARTITION_TYPE partition;
   BLOCK_SIZE subsize;
@@ -2651,17 +2997,17 @@ static void write_modes_b(AV1_COMP *cpi,
                           int supertx_enabled,
 #endif
                           int mi_row, int mi_col) {
   write_mbmi_b(cpi, tile, w,
 #if CONFIG_SUPERTX
                supertx_enabled,
 #endif
                mi_row, mi_col);
-#if CONFIG_MOTION_VAR && CONFIG_NCOBMC
+#if CONFIG_MOTION_VAR && (CONFIG_NCOBMC || CONFIG_NCOBMC_ADAPT_WEIGHT)
   (void)tok;
   (void)tok_end;
 #else
 #if !CONFIG_PVQ && CONFIG_SUPERTX
   if (!supertx_enabled)
 #endif
     write_tokens_b(cpi, tile, w, tok, tok_end, mi_row, mi_col);
 #endif
@@ -2860,37 +3206,38 @@ static void write_modes_sb(AV1_COMP *con
                    cm->dependent_horz_tiles,
 #endif  // CONFIG_DEPENDENT_HORZTILES
                    cm->mi_rows, cm->mi_cols);
 
     assert(IMPLIES(!cm->seg.enabled, mbmi->segment_id_supertx == 0));
     assert(mbmi->segment_id_supertx < MAX_SEGMENTS);
 
     skip = write_skip(cm, xd, mbmi->segment_id_supertx, xd->mi[0], w);
+
+#if CONFIG_EC_ADAPT
+    FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
+#else
+    FRAME_CONTEXT *ec_ctx = cm->fc;
+#endif
+
 #if CONFIG_EXT_TX
     if (get_ext_tx_types(supertx_size, bsize, 1, cm->reduced_tx_set_used) > 1 &&
         !skip) {
       const int eset =
           get_ext_tx_set(supertx_size, bsize, 1, cm->reduced_tx_set_used);
       if (eset > 0) {
-#if CONFIG_EC_ADAPT
-        FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
-#else
-        FRAME_CONTEXT *ec_ctx = cm->fc;
-#endif
         aom_write_symbol(w, av1_ext_tx_inter_ind[eset][mbmi->tx_type],
                          ec_ctx->inter_ext_tx_cdf[eset][supertx_size],
                          ext_tx_cnt_inter[eset]);
       }
     }
 #else
     if (supertx_size < TX_32X32 && !skip) {
-      av1_write_token(w, av1_ext_tx_tree,
-                      cm->fc->inter_ext_tx_prob[supertx_size],
-                      &ext_tx_encodings[mbmi->tx_type]);
+      aom_write_symbol(w, mbmi->tx_type, ec_ctx->inter_ext_tx_cdf[supertx_size],
+                       TX_TYPES);
     }
 #endif  // CONFIG_EXT_TX
 
     if (!skip) {
       assert(*tok < tok_end);
       for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
         const struct macroblockd_plane *const pd = &xd->plane[plane];
         const int mbmi_txb_size = txsize_to_bsize[mbmi->tx_size];
@@ -2930,17 +3277,17 @@ static void write_modes_sb(AV1_COMP *con
 #else
   if (bsize >= BLOCK_8X8 &&
       (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT))
     update_partition_context(xd, mi_row, mi_col, subsize, bsize);
 #endif  // CONFIG_EXT_PARTITION_TYPES
 
 #if CONFIG_CDEF
   if (bsize == cm->sb_size && !sb_all_skip(cm, mi_row, mi_col) &&
-      cm->cdef_bits != 0) {
+      cm->cdef_bits != 0 && !cm->all_lossless) {
     aom_write_literal(w, cm->mi_grid_visible[mi_row * cm->mi_stride + mi_col]
                              ->mbmi.cdef_strength,
                       cm->cdef_bits);
   }
 #endif
 }
 
 static void write_modes(AV1_COMP *const cpi, const TileInfo *const tile,
@@ -2981,17 +3328,17 @@ static void write_modes(AV1_COMP *const 
 #endif
 
   for (mi_row = mi_row_start; mi_row < mi_row_end; mi_row += cm->mib_size) {
     av1_zero_left_context(xd);
 
     for (mi_col = mi_col_start; mi_col < mi_col_end; mi_col += cm->mib_size) {
       write_modes_sb_wrapper(cpi, tile, w, tok, tok_end, 0, mi_row, mi_col,
                              cm->sb_size);
-#if CONFIG_MOTION_VAR && CONFIG_NCOBMC
+#if CONFIG_MOTION_VAR && (CONFIG_NCOBMC || CONFIG_NCOBMC_ADAPT_WEIGHT)
       write_tokens_sb(cpi, tile, w, tok, tok_end, mi_row, mi_col, cm->sb_size);
 #endif
     }
   }
 #if CONFIG_PVQ
   // Check that the number of PVQ blocks encoded and written to the bitstream
   // are the same
   assert(cpi->td.mb.pvq_q->curr_pos == cpi->td.mb.pvq_q->last_pos);
@@ -3252,16 +3599,33 @@ static void encode_restoration_mode(AV1_
       cm->rst_info[2].frame_restoration_type != RESTORE_NONE) {
     rsi = &cm->rst_info[0];
     aom_wb_write_bit(wb, rsi->restoration_tilesize != RESTORATION_TILESIZE_MAX);
     if (rsi->restoration_tilesize != RESTORATION_TILESIZE_MAX) {
       aom_wb_write_bit(
           wb, rsi->restoration_tilesize != (RESTORATION_TILESIZE_MAX >> 1));
     }
   }
+  int s = AOMMIN(cm->subsampling_x, cm->subsampling_y);
+  if (s && (cm->rst_info[1].frame_restoration_type != RESTORE_NONE ||
+            cm->rst_info[2].frame_restoration_type != RESTORE_NONE)) {
+    aom_wb_write_bit(wb, cm->rst_info[1].restoration_tilesize !=
+                             cm->rst_info[0].restoration_tilesize);
+    assert(cm->rst_info[1].restoration_tilesize ==
+               cm->rst_info[0].restoration_tilesize ||
+           cm->rst_info[1].restoration_tilesize ==
+               (cm->rst_info[0].restoration_tilesize >> s));
+    assert(cm->rst_info[2].restoration_tilesize ==
+           cm->rst_info[1].restoration_tilesize);
+  } else if (!s) {
+    assert(cm->rst_info[1].restoration_tilesize ==
+           cm->rst_info[0].restoration_tilesize);
+    assert(cm->rst_info[2].restoration_tilesize ==
+           cm->rst_info[1].restoration_tilesize);
+  }
 }
 
 static void write_wiener_filter(WienerInfo *wiener_info,
                                 WienerInfo *ref_wiener_info, aom_writer *wb) {
   aom_write_primitive_refsubexpfin(
       wb, WIENER_FILT_TAP0_MAXV - WIENER_FILT_TAP0_MINV + 1,
       WIENER_FILT_TAP0_SUBEXP_K,
       ref_wiener_info->vfilter[0] - WIENER_FILT_TAP0_MINV,
@@ -3306,26 +3670,33 @@ static void write_sgrproj_filter(Sgrproj
                                    SGRPROJ_PRJ_SUBEXP_K,
                                    ref_sgrproj_info->xqd[1] - SGRPROJ_PRJ_MIN1,
                                    sgrproj_info->xqd[1] - SGRPROJ_PRJ_MIN1);
   memcpy(ref_sgrproj_info, sgrproj_info, sizeof(*sgrproj_info));
 }
 
 static void encode_restoration(AV1_COMMON *cm, aom_writer *wb) {
   int i, p;
-  const int ntiles = av1_get_rest_ntiles(cm->width, cm->height,
-                                         cm->rst_info[0].restoration_tilesize,
-                                         NULL, NULL, NULL, NULL);
+#if CONFIG_FRAME_SUPERRES
+  const int width = cm->superres_upscaled_width;
+  const int height = cm->superres_upscaled_height;
+#else
+  const int width = cm->width;
+  const int height = cm->height;
+#endif  // CONFIG_FRAME_SUPERRES
+  const int ntiles =
+      av1_get_rest_ntiles(width, height, cm->rst_info[0].restoration_tilesize,
+                          NULL, NULL, NULL, NULL);
   WienerInfo ref_wiener_info;
   SgrprojInfo ref_sgrproj_info;
   set_default_wiener(&ref_wiener_info);
   set_default_sgrproj(&ref_sgrproj_info);
   const int ntiles_uv = av1_get_rest_ntiles(
-      ROUND_POWER_OF_TWO(cm->width, cm->subsampling_x),
-      ROUND_POWER_OF_TWO(cm->height, cm->subsampling_y),
+      ROUND_POWER_OF_TWO(width, cm->subsampling_x),
+      ROUND_POWER_OF_TWO(height, cm->subsampling_y),
       cm->rst_info[1].restoration_tilesize, NULL, NULL, NULL, NULL);
   RestorationInfo *rsi = &cm->rst_info[0];
   if (rsi->frame_restoration_type != RESTORE_NONE) {
     if (rsi->frame_restoration_type == RESTORE_SWITCHABLE) {
       // RESTORE_SWITCHABLE
       for (i = 0; i < ntiles; ++i) {
         av1_write_token(
             wb, av1_switchable_restore_tree, cm->fc->switchable_restore_prob,
@@ -3531,44 +3902,38 @@ static void update_seg_probs(AV1_COMP *c
                      cm->counts.seg.tree_mispred, MAX_SEGMENTS, probwt, w);
   } else {
     prob_diff_update(av1_segment_tree, cm->fc->seg.tree_probs,
                      cm->counts.seg.tree_total, MAX_SEGMENTS, probwt, w);
   }
 }
 #endif
 
-static void write_tx_mode(AV1_COMMON *cm, MACROBLOCKD *xd, TX_MODE *mode,
+static void write_tx_mode(AV1_COMMON *cm, TX_MODE *mode,
                           struct aom_write_bit_buffer *wb) {
-  int i, all_lossless = 1;
-
-  if (cm->seg.enabled) {
-    for (i = 0; i < MAX_SEGMENTS; ++i) {
-      if (!xd->lossless[i]) {
-        all_lossless = 0;
-        break;
-      }
-    }
-  } else {
-    all_lossless = xd->lossless[0];
-  }
-  if (all_lossless) {
+  if (cm->all_lossless) {
     *mode = ONLY_4X4;
     return;
   }
+#if CONFIG_VAR_TX_NO_TX_MODE
+  (void)wb;
+  *mode = TX_MODE_SELECT;
+  return;
+#else
 #if CONFIG_TX64X64
   aom_wb_write_bit(wb, *mode == TX_MODE_SELECT);
   if (*mode != TX_MODE_SELECT) {
     aom_wb_write_literal(wb, AOMMIN(*mode, ALLOW_32X32), 2);
     if (*mode >= ALLOW_32X32) aom_wb_write_bit(wb, *mode == ALLOW_64X64);
   }
 #else
   aom_wb_write_bit(wb, *mode == TX_MODE_SELECT);
   if (*mode != TX_MODE_SELECT) aom_wb_write_literal(wb, *mode, 2);
 #endif  // CONFIG_TX64X64
+#endif  // CONFIG_VAR_TX_NO_TX_MODE
 }
 
 #if !CONFIG_EC_ADAPT
 static void update_txfm_probs(AV1_COMMON *cm, aom_writer *w,
                               FRAME_COUNTS *counts) {
 #if CONFIG_TILE_GROUPS
   const int probwt = cm->num_tg;
 #else
@@ -3922,17 +4287,17 @@ static uint32_t write_tiles(AV1_COMP *co
       uint32_t col_size = total_size - col_offset - 4;
       mem_put_le32(dst + col_offset, col_size);
 
       // If it is not final packing, record the maximum tile column size we see,
       // otherwise, check if the tile size is out of the range.
       *max_tile_col_size = AOMMAX(*max_tile_col_size, col_size);
     }
   }
-#else
+#else  // !CONFIG_EXT_TILE
 #if CONFIG_TILE_GROUPS
   write_uncompressed_header(cpi, wb);
 
 #if CONFIG_EXT_REFS
   if (cm->show_existing_frame) {
     total_size = aom_wb_bytes_written(wb);
     return (uint32_t)total_size;
   }
@@ -4106,76 +4471,82 @@ static uint32_t write_tiles(AV1_COMP *co
 
 #endif
 #endif  // CONFIG_EXT_TILE
   return (uint32_t)total_size;
 }
 
 static void write_render_size(const AV1_COMMON *cm,
                               struct aom_write_bit_buffer *wb) {
-  const int scaling_active =
-      cm->width != cm->render_width || cm->height != cm->render_height;
+  const int scaling_active = !av1_resize_unscaled(cm);
   aom_wb_write_bit(wb, scaling_active);
   if (scaling_active) {
     aom_wb_write_literal(wb, cm->render_width - 1, 16);
     aom_wb_write_literal(wb, cm->render_height - 1, 16);
   }
 }
 
 #if CONFIG_FRAME_SUPERRES
 static void write_superres_scale(const AV1_COMMON *const cm,
                                  struct aom_write_bit_buffer *wb) {
   // First bit is whether to to scale or not
-  if (cm->superres_scale_numerator == SUPERRES_SCALE_DENOMINATOR) {
+  if (cm->superres_scale_numerator == SCALE_DENOMINATOR) {
     aom_wb_write_bit(wb, 0);  // no scaling
   } else {
     aom_wb_write_bit(wb, 1);  // scaling, write scale factor
-    // TODO(afergs): write factor to the compressed header instead
     aom_wb_write_literal(
         wb, cm->superres_scale_numerator - SUPERRES_SCALE_NUMERATOR_MIN,
         SUPERRES_SCALE_BITS);
   }
 }
 #endif  // CONFIG_FRAME_SUPERRES
 
 static void write_frame_size(const AV1_COMMON *cm,
                              struct aom_write_bit_buffer *wb) {
+#if CONFIG_FRAME_SUPERRES
+  aom_wb_write_literal(wb, cm->superres_upscaled_width - 1, 16);
+  aom_wb_write_literal(wb, cm->superres_upscaled_height - 1, 16);
+  write_superres_scale(cm, wb);
+#else
   aom_wb_write_literal(wb, cm->width - 1, 16);
   aom_wb_write_literal(wb, cm->height - 1, 16);
-
+#endif  // CONFIG_FRAME_SUPERRES
   write_render_size(cm, wb);
-#if CONFIG_FRAME_SUPERRES
-  write_superres_scale(cm, wb);
-#endif  // CONFIG_FRAME_SUPERRES
 }
 
 static void write_frame_size_with_refs(AV1_COMP *cpi,
                                        struct aom_write_bit_buffer *wb) {
   AV1_COMMON *const cm = &cpi->common;
   int found = 0;
 
   MV_REFERENCE_FRAME ref_frame;
   for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
     YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, ref_frame);
 
     if (cfg != NULL) {
+#if CONFIG_FRAME_SUPERRES
+      found = cm->superres_upscaled_width == cfg->y_crop_width &&
+              cm->superres_upscaled_height == cfg->y_crop_height;
+#else
       found =
           cm->width == cfg->y_crop_width && cm->height == cfg->y_crop_height;
+#endif
       found &= cm->render_width == cfg->render_width &&
                cm->render_height == cfg->render_height;
     }
     aom_wb_write_bit(wb, found);
     if (found) {
+#if CONFIG_FRAME_SUPERRES
+      write_superres_scale(cm, wb);
+#endif  // CONFIG_FRAME_SUPERRES
       break;
     }
   }
 
-  if (!found) {
-    write_frame_size(cm, wb);
-  }
+  if (!found) write_frame_size(cm, wb);
 }
 
 static void write_sync_code(struct aom_write_bit_buffer *wb) {
   aom_wb_write_literal(wb, AV1_SYNC_CODE_0, 8);
   aom_wb_write_literal(wb, AV1_SYNC_CODE_1, 8);
   aom_wb_write_literal(wb, AV1_SYNC_CODE_2, 8);
 }
 
@@ -4191,28 +4562,38 @@ static void write_profile(BITSTREAM_PROF
 }
 
 static void write_bitdepth_colorspace_sampling(
     AV1_COMMON *const cm, struct aom_write_bit_buffer *wb) {
   if (cm->profile >= PROFILE_2) {
     assert(cm->bit_depth > AOM_BITS_8);
     aom_wb_write_bit(wb, cm->bit_depth == AOM_BITS_10 ? 0 : 1);
   }
+#if CONFIG_COLORSPACE_HEADERS
+  aom_wb_write_literal(wb, cm->color_space, 5);
+  aom_wb_write_literal(wb, cm->transfer_function, 5);
+#else
   aom_wb_write_literal(wb, cm->color_space, 3);
+#endif
   if (cm->color_space != AOM_CS_SRGB) {
     // 0: [16, 235] (i.e. xvYCC), 1: [0, 255]
     aom_wb_write_bit(wb, cm->color_range);
     if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) {
       assert(cm->subsampling_x != 1 || cm->subsampling_y != 1);
       aom_wb_write_bit(wb, cm->subsampling_x);
       aom_wb_write_bit(wb, cm->subsampling_y);
       aom_wb_write_bit(wb, 0);  // unused
     } else {
       assert(cm->subsampling_x == 1 && cm->subsampling_y == 1);
     }
+#if CONFIG_COLORSPACE_HEADERS
+    if (cm->subsampling_x == 1 && cm->subsampling_y == 1) {
+      aom_wb_write_literal(wb, cm->chroma_sample_position, 2);
+    }
+#endif
   } else {
     assert(cm->profile == PROFILE_1 || cm->profile == PROFILE_3);
     aom_wb_write_bit(wb, 0);  // unused
   }
 }
 
 #if CONFIG_REFERENCE_BUFFER
 void write_sequence_header(SequenceHeader *seq_params) {
@@ -4231,17 +4612,21 @@ static void write_compound_tools(const A
 #if CONFIG_INTERINTRA
   if (!frame_is_intra_only(cm) && cm->reference_mode != COMPOUND_REFERENCE) {
     aom_wb_write_bit(wb, cm->allow_interintra_compound);
   } else {
     assert(cm->allow_interintra_compound == 0);
   }
 #endif  // CONFIG_INTERINTRA
 #if CONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT
+#if CONFIG_COMPOUND_SINGLEREF
+  if (!frame_is_intra_only(cm)) {
+#else   // !CONFIG_COMPOUND_SINGLEREF
   if (!frame_is_intra_only(cm) && cm->reference_mode != SINGLE_REFERENCE) {
+#endif  // CONFIG_COMPOUND_SINGLEREF
     aom_wb_write_bit(wb, cm->allow_masked_compound);
   } else {
     assert(cm->allow_masked_compound == 0);
   }
 #endif  // CONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT
 }
 #endif  // CONFIG_EXT_INTER
 
@@ -4304,21 +4689,16 @@ static void write_uncompressed_header(AV
 #if CONFIG_REFERENCE_BUFFER
   cm->invalid_delta_frame_id_minus1 = 0;
   if (cpi->seq_params.frame_id_numbers_present_flag) {
     int frame_id_len = cpi->seq_params.frame_id_length_minus7 + 7;
     aom_wb_write_literal(wb, cm->current_frame_id, frame_id_len);
   }
 #endif
 
-#if CONFIG_FRAME_SUPERRES
-  // TODO(afergs): Remove - this is just to stop superres from breaking
-  cm->superres_scale_numerator = SUPERRES_SCALE_DENOMINATOR;
-#endif  // CONFIG_FRAME_SUPERRES
-
   if (cm->frame_type == KEY_FRAME) {
     write_sync_code(wb);
     write_bitdepth_colorspace_sampling(cm, wb);
     write_frame_size(cm, wb);
 #if CONFIG_ANS && ANS_MAX_SYMBOLS
     assert(cpi->common.ans_window_size_log2 >= 8);
     assert(cpi->common.ans_window_size_log2 < 24);
     aom_wb_write_literal(wb, cpi->common.ans_window_size_log2 - 8, 4);
@@ -4442,22 +4822,16 @@ static void write_uncompressed_header(AV
 #if CONFIG_EXT_PARTITION
   assert(cm->sb_size == BLOCK_128X128 || cm->sb_size == BLOCK_64X64);
   aom_wb_write_bit(wb, cm->sb_size == BLOCK_128X128 ? 1 : 0);
 #else
   assert(cm->sb_size == BLOCK_64X64);
 #endif  // CONFIG_EXT_PARTITION
 
   encode_loopfilter(cm, wb);
-#if CONFIG_CDEF
-  encode_cdef(cm, wb);
-#endif
-#if CONFIG_LOOP_RESTORATION
-  encode_restoration_mode(cm, wb);
-#endif  // CONFIG_LOOP_RESTORATION
   encode_quantization(cm, wb);
   encode_segmentation(cm, xd, wb);
 #if CONFIG_DELTA_Q
   {
     int i;
     struct segmentation *const seg = &cm->seg;
     int segment_quantizer_active = 0;
     for (i = 0; i < MAX_SEGMENTS; i++) {
@@ -4480,18 +4854,25 @@ static void write_uncompressed_header(AV
           aom_wb_write_literal(wb, OD_ILOG_NZ(cm->delta_lf_res) - 1, 2);
           xd->prev_delta_lf_from_base = 0;
         }
 #endif  // CONFIG_EXT_DELTA_Q
       }
     }
   }
 #endif
-
-  write_tx_mode(cm, xd, &cm->tx_mode, wb);
+#if CONFIG_CDEF
+  if (!cm->all_lossless) {
+    encode_cdef(cm, wb);
+  }
+#endif
+#if CONFIG_LOOP_RESTORATION
+  encode_restoration_mode(cm, wb);
+#endif  // CONFIG_LOOP_RESTORATION
+  write_tx_mode(cm, &cm->tx_mode, wb);
 
   if (cpi->allow_comp_inter_inter) {
     const int use_hybrid_pred = cm->reference_mode == REFERENCE_MODE_SELECT;
 #if !CONFIG_REF_ADAPT
     const int use_compound_pred = cm->reference_mode != SINGLE_REFERENCE;
 #endif  // !CONFIG_REF_ADAPT
 
     aom_wb_write_bit(wb, use_hybrid_pred);
@@ -4508,23 +4889,23 @@ static void write_uncompressed_header(AV
 #endif  // CONFIG_EXT_TX
 
   write_tile_info(cm, wb);
 }
 
 #if CONFIG_GLOBAL_MOTION
 static void write_global_motion_params(WarpedMotionParams *params,
                                        WarpedMotionParams *ref_params,
-                                       aom_prob *probs, aom_writer *w,
-                                       int allow_hp) {
+                                       aom_writer *w, int allow_hp) {
   TransformationType type = params->wmtype;
   int trans_bits;
   int trans_prec_diff;
-  av1_write_token(w, av1_global_motion_types_tree, probs,
-                  &global_motion_types_encodings[type]);
+  aom_write_bit(w, type != IDENTITY);
+  if (type != IDENTITY) aom_write_literal(w, type - 1, GLOBAL_TYPE_BITS);
+
   switch (type) {
     case HOMOGRAPHY:
     case HORTRAPEZOID:
     case VERTRAPEZOID:
       if (type != HORTRAPEZOID)
         aom_write_signed_primitive_refsubexpfin(
             w, GM_ROW3HOMO_MAX + 1, SUBEXPFIN_K,
             (ref_params->wmmat[6] >> GM_ROW3HOMO_PREC_DIFF),
@@ -4580,19 +4961,19 @@ static void write_global_motion_params(W
     default: assert(0);
   }
 }
 
 static void write_global_motion(AV1_COMP *cpi, aom_writer *w) {
   AV1_COMMON *const cm = &cpi->common;
   int frame;
   for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) {
-    write_global_motion_params(
-        &cm->global_motion[frame], &cm->prev_frame->global_motion[frame],
-        cm->fc->global_motion_types_prob, w, cm->allow_high_precision_mv);
+    write_global_motion_params(&cm->global_motion[frame],
+                               &cm->prev_frame->global_motion[frame], w,
+                               cm->allow_high_precision_mv);
     /*
     printf("Frame %d/%d: Enc Ref %d (used %d): %d %d %d %d\n",
            cm->current_video_frame, cm->show_frame, frame,
            cpi->global_motion_used[frame], cm->global_motion[frame].wmmat[0],
            cm->global_motion[frame].wmmat[1], cm->global_motion[frame].wmmat[2],
            cm->global_motion[frame].wmmat[3]);
            */
   }
@@ -4602,17 +4983,20 @@ static void write_global_motion(AV1_COMP
 static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
   AV1_COMMON *const cm = &cpi->common;
 #if CONFIG_SUPERTX
   MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
 #endif  // CONFIG_SUPERTX
   FRAME_CONTEXT *const fc = cm->fc;
   FRAME_COUNTS *counts = cpi->td.counts;
   aom_writer *header_bc;
-  int i, j;
+  int i;
+#if !CONFIG_NEW_MULTISYMBOL
+  int j;
+#endif
 
 #if CONFIG_TILE_GROUPS
   const int probwt = cm->num_tg;
 #else
   const int probwt = 1;
 #endif
 
 #if CONFIG_ANS
@@ -4645,17 +5029,19 @@ static uint32_t write_compressed_header(
 #endif  // !CONFIG_EC_ADAPT
 #endif  // CONFIG_PVQ
 #endif  // CONFIG_LV_MAP
 
 #if CONFIG_VAR_TX
   update_txfm_partition_probs(cm, header_bc, counts, probwt);
 #endif
 
+#if !CONFIG_NEW_MULTISYMBOL
   update_skip_probs(cm, header_bc, counts);
+#endif
 #if !CONFIG_EC_ADAPT && CONFIG_DELTA_Q
   update_delta_q_probs(cm, header_bc, counts);
 #if CONFIG_EXT_DELTA_Q
   update_delta_lf_probs(cm, header_bc, counts);
 #endif
 #endif
 #if !CONFIG_EC_ADAPT
   update_seg_probs(cpi, header_bc);
@@ -4703,100 +5089,144 @@ static uint32_t write_compressed_header(
 #if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
   for (i = 0; i < INTRA_FILTERS + 1; ++i)
     prob_diff_update(av1_intra_filter_tree, fc->intra_filter_probs[i],
                      counts->intra_filter[i], INTRA_FILTERS, probwt, header_bc);
 #endif  // CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
 #endif  // !CONFIG_EC_ADAPT
 
   if (frame_is_intra_only(cm)) {
+#if !CONFIG_EC_ADAPT
     av1_copy(cm->kf_y_prob, av1_kf_y_mode_prob);
+#endif
     av1_copy(cm->fc->kf_y_cdf, av1_kf_y_mode_cdf);
 
 #if !CONFIG_EC_ADAPT
     for (i = 0; i < INTRA_MODES; ++i)
       for (j = 0; j < INTRA_MODES; ++j)
         prob_diff_update(av1_intra_mode_tree, cm->kf_y_prob[i][j],
                          counts->kf_y_mode[i][j], INTRA_MODES, probwt,
                          header_bc);
 #endif  // CONFIG_EC_ADAPT
 #if CONFIG_INTRABC
     if (cm->allow_screen_content_tools) {
       av1_cond_prob_diff_update(header_bc, &fc->intrabc_prob,
                                 cm->counts.intrabc, probwt);
     }
 #endif
   } else {
+#if !CONFIG_NEW_MULTISYMBOL
     update_inter_mode_probs(cm, header_bc, counts);
+#endif
 #if CONFIG_EXT_INTER
+#if !CONFIG_EC_ADAPT
     update_inter_compound_mode_probs(cm, probwt, header_bc);
+#endif
+#if CONFIG_COMPOUND_SINGLEREF
+    update_inter_singleref_comp_mode_probs(cm, probwt, header_bc);
+#endif  // CONFIG_COMPOUND_SINGLEREF
+
 #if CONFIG_INTERINTRA
     if (cm->reference_mode != COMPOUND_REFERENCE &&
         cm->allow_interintra_compound) {
+#if !CONFIG_NEW_MULTISYMBOL
       for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
         if (is_interintra_allowed_bsize_group(i)) {
           av1_cond_prob_diff_update(header_bc, &fc->interintra_prob[i],
                                     cm->counts.interintra[i], probwt);
         }
       }
+#endif
+#if !CONFIG_EC_ADAPT
       for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
         prob_diff_update(
             av1_interintra_mode_tree, cm->fc->interintra_mode_prob[i],
             counts->interintra_mode[i], INTERINTRA_MODES, probwt, header_bc);
       }
-#if CONFIG_WEDGE
+#endif
+#if CONFIG_WEDGE && !CONFIG_NEW_MULTISYMBOL
       for (i = 0; i < BLOCK_SIZES; i++) {
         if (is_interintra_allowed_bsize(i) && is_interintra_wedge_used(i))
           av1_cond_prob_diff_update(header_bc, &fc->wedge_interintra_prob[i],
                                     cm->counts.wedge_interintra[i], probwt);
       }
-#endif  // CONFIG_WEDGE
+#endif  // CONFIG_WEDGE && CONFIG_NEW_MULTISYMBOL
     }
 #endif  // CONFIG_INTERINTRA
-#if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
+#if !CONFIG_EC_ADAPT && (CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE)
+#if CONFIG_COMPOUND_SINGLEREF
+    if (cm->allow_masked_compound) {
+#else   // !CONFIG_COMPOUND_SINGLEREF
     if (cm->reference_mode != SINGLE_REFERENCE && cm->allow_masked_compound) {
-      for (i = 0; i < BLOCK_SIZES; i++)
-        prob_diff_update(av1_compound_type_tree, fc->compound_type_prob[i],
-                         cm->counts.compound_interinter[i], COMPOUND_TYPES,
-                         probwt, header_bc);
+#endif  // CONFIG_COMPOUND_SINGLEREF
+      for (i = 0; i < BLOCK_SIZES; i++) {
+        if (is_any_masked_compound_used(i)) {
+          prob_diff_update(av1_compound_type_tree, fc->compound_type_prob[i],
+                           cm->counts.compound_interinter[i], COMPOUND_TYPES,
+                           probwt, header_bc);
+        }
+      }
     }
-#endif  // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
+#endif  // !CONFIG_EC_ADAPT && (CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE)
 #endif  // CONFIG_EXT_INTER
 
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
     for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
       prob_diff_update(av1_motion_mode_tree, fc->motion_mode_prob[i],
                        counts->motion_mode[i], MOTION_MODES, probwt, header_bc);
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+    for (i = ADAPT_OVERLAP_BLOCK_8X8; i < ADAPT_OVERLAP_BLOCKS; ++i) {
+      prob_diff_update(av1_ncobmc_mode_tree, fc->ncobmc_mode_prob[i],
+                       counts->ncobmc_mode[i], MAX_NCOBMC_MODES, probwt,
+                       header_bc);
+    }
+#endif
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 #if !CONFIG_EC_ADAPT
     if (cm->interp_filter == SWITCHABLE)
       update_switchable_interp_probs(cm, header_bc, counts);
 #endif
 
+#if !CONFIG_NEW_MULTISYMBOL
     for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
       av1_cond_prob_diff_update(header_bc, &fc->intra_inter_prob[i],
                                 counts->intra_inter[i], probwt);
-
+#endif
+
+#if !CONFIG_NEW_MULTISYMBOL
     if (cpi->allow_comp_inter_inter) {
       const int use_hybrid_pred = cm->reference_mode == REFERENCE_MODE_SELECT;
       if (use_hybrid_pred)
         for (i = 0; i < COMP_INTER_CONTEXTS; i++)
           av1_cond_prob_diff_update(header_bc, &fc->comp_inter_prob[i],
                                     counts->comp_inter[i], probwt);
     }
 
     if (cm->reference_mode != COMPOUND_REFERENCE) {
       for (i = 0; i < REF_CONTEXTS; i++) {
         for (j = 0; j < (SINGLE_REFS - 1); j++) {
           av1_cond_prob_diff_update(header_bc, &fc->single_ref_prob[i][j],
                                     counts->single_ref[i][j], probwt);
         }
       }
     }
+#endif
     if (cm->reference_mode != SINGLE_REFERENCE) {
+#if CONFIG_EXT_COMP_REFS
+      for (i = 0; i < COMP_REF_TYPE_CONTEXTS; i++)
+        av1_cond_prob_diff_update(header_bc, &fc->comp_ref_type_prob[i],
+                                  counts->comp_ref_type[i], probwt);
+
+      for (i = 0; i < UNI_COMP_REF_CONTEXTS; i++)
+        for (j = 0; j < (UNIDIR_COMP_REFS - 1); j++)
+          av1_cond_prob_diff_update(header_bc, &fc->uni_comp_ref_prob[i][j],
+                                    counts->uni_comp_ref[i][j], probwt);
+#endif  // CONFIG_EXT_COMP_REFS
+
+#if !CONFIG_NEW_MULTISYMBOL
       for (i = 0; i < REF_CONTEXTS; i++) {
 #if CONFIG_EXT_REFS
         for (j = 0; j < (FWD_REFS - 1); j++) {
           av1_cond_prob_diff_update(header_bc, &fc->comp_ref_prob[i][j],
                                     counts->comp_ref[i][j], probwt);
         }
         for (j = 0; j < (BWD_REFS - 1); j++) {
           av1_cond_prob_diff_update(header_bc, &fc->comp_bwdref_prob[i][j],
@@ -4804,18 +5234,25 @@ static uint32_t write_compressed_header(
         }
 #else
         for (j = 0; j < (COMP_REFS - 1); j++) {
           av1_cond_prob_diff_update(header_bc, &fc->comp_ref_prob[i][j],
                                     counts->comp_ref[i][j], probwt);
         }
 #endif  // CONFIG_EXT_REFS
       }
+#endif  // CONFIG_NEW_MULTISYMBOL
     }
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    for (i = 0; i < COMP_INTER_MODE_CONTEXTS; i++)
+      av1_cond_prob_diff_update(header_bc, &fc->comp_inter_mode_prob[i],
+                                counts->comp_inter_mode[i], probwt);
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
 #if !CONFIG_EC_ADAPT
     for (i = 0; i < BLOCK_SIZE_GROUPS; ++i) {
       prob_diff_update(av1_intra_mode_tree, cm->fc->y_mode_prob[i],
                        counts->y_mode[i], INTRA_MODES, probwt, header_bc);
     }
 #endif
 
     av1_write_nmv_probs(cm, cm->allow_high_precision_mv, header_bc, counts->mv);
--- a/third_party/aom/av1/encoder/bitstream.h
+++ b/third_party/aom/av1/encoder/bitstream.h
@@ -37,17 +37,17 @@ static INLINE int av1_preserve_existing_
 #endif  // CONFIG_EXT_REFS
 }
 
 void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
 #if CONFIG_SUPERTX
                        const int supertx_enabled,
 #endif
 #if CONFIG_TXK_SEL
-                       int block, int plane,
+                       int block, int plane, TX_SIZE tx_size,
 #endif
                        aom_writer *w);
 
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
 #endif  // AV1_ENCODER_BITSTREAM_H_
--- a/third_party/aom/av1/encoder/block.h
+++ b/third_party/aom/av1/encoder/block.h
@@ -111,17 +111,16 @@ struct macroblock {
   // bitcost unit).
   int errorperbit;
   // The equivalend SAD error of one (whole) bit at the current quantizer
   // for large blocks.
   int sadperbit16;
   // The equivalend SAD error of one (whole) bit at the current quantizer
   // for sub-8x8 blocks.
   int sadperbit4;
-  int rddiv;
   int rdmult;
   int mb_energy;
   int *m_search_count_ptr;
   int *ex_search_count_ptr;
 
 #if CONFIG_VAR_TX
   unsigned int txb_split_count;
 #endif
@@ -202,23 +201,22 @@ struct macroblock {
   // TODO(yushin) : The memory usage could be improved a lot, since this has
   // storage for 10 bands and 128 coefficients for every 4x4 block,
   PVQ_INFO pvq[MAX_PVQ_BLOCKS_IN_SB][MAX_MB_PLANE];
   daala_enc_ctx daala_enc;
   int pvq_speed;
   int pvq_coded;  // Indicates whether pvq_info needs be stored to tokenize
 #endif
 #if CONFIG_DAALA_DIST
-  // Keep rate of each 4x4 block in the current macroblock during RDO
-  // This is needed when using the 8x8 Daala distortion metric during RDO,
-  // because it evaluates distortion in a different order than the underlying
-  // 4x4 blocks are coded.
-  int rate_4x4[MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)];
 #if CONFIG_CB4X4
+#if CONFIG_HIGHBITDEPTH
+  DECLARE_ALIGNED(16, uint16_t, decoded_8x8[8 * 8]);
+#else
   DECLARE_ALIGNED(16, uint8_t, decoded_8x8[8 * 8]);
+#endif
 #endif  // CONFIG_CB4X4
 #endif  // CONFIG_DAALA_DIST
 #if CONFIG_CFL
   // Whether luma needs to be stored during RDO.
   int cfl_store_y;
 #endif
 };
 
--- a/third_party/aom/av1/encoder/context_tree.c
+++ b/third_party/aom/av1/encoder/context_tree.c
@@ -136,17 +136,17 @@ static void alloc_tree_contexts(AV1_COMM
   alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_VERT_A,
                      &tree->verticala[2]);
   alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_VERT_B,
                      &tree->verticalb[0]);
   alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_VERT_B,
                      &tree->verticalb[1]);
   alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_VERT_B,
                      &tree->verticalb[2]);
-#ifdef CONFIG_SUPERTX
+#if CONFIG_SUPERTX
   alloc_mode_context(cm, num_4x4_blk, PARTITION_HORZ,
                      &tree->horizontal_supertx);
   alloc_mode_context(cm, num_4x4_blk, PARTITION_VERT, &tree->vertical_supertx);
   alloc_mode_context(cm, num_4x4_blk, PARTITION_SPLIT, &tree->split_supertx);
   alloc_mode_context(cm, num_4x4_blk, PARTITION_HORZ_A,
                      &tree->horizontala_supertx);
   alloc_mode_context(cm, num_4x4_blk, PARTITION_HORZ_B,
                      &tree->horizontalb_supertx);
@@ -154,17 +154,17 @@ static void alloc_tree_contexts(AV1_COMM
                      &tree->verticala_supertx);
   alloc_mode_context(cm, num_4x4_blk, PARTITION_VERT_B,
                      &tree->verticalb_supertx);
 #endif  // CONFIG_SUPERTX
 #else
   alloc_mode_context(cm, num_4x4_blk, &tree->none);
   alloc_mode_context(cm, num_4x4_blk / 2, &tree->horizontal[0]);
   alloc_mode_context(cm, num_4x4_blk / 2, &tree->vertical[0]);
-#ifdef CONFIG_SUPERTX
+#if CONFIG_SUPERTX
   alloc_mode_context(cm, num_4x4_blk, &tree->horizontal_supertx);
   alloc_mode_context(cm, num_4x4_blk, &tree->vertical_supertx);
   alloc_mode_context(cm, num_4x4_blk, &tree->split_supertx);
 #endif
 
   if (num_4x4_blk > 4) {
     alloc_mode_context(cm, num_4x4_blk / 2, &tree->horizontal[1]);
     alloc_mode_context(cm, num_4x4_blk / 2, &tree->vertical[1]);
@@ -185,17 +185,17 @@ static void free_tree_contexts(PC_TREE *
     free_mode_context(&tree->verticalb[i]);
   }
 #endif  // CONFIG_EXT_PARTITION_TYPES
   free_mode_context(&tree->none);
   free_mode_context(&tree->horizontal[0]);
   free_mode_context(&tree->horizontal[1]);
   free_mode_context(&tree->vertical[0]);
   free_mode_context(&tree->vertical[1]);
-#ifdef CONFIG_SUPERTX
+#if CONFIG_SUPERTX
   free_mode_context(&tree->horizontal_supertx);
   free_mode_context(&tree->vertical_supertx);
   free_mode_context(&tree->split_supertx);
 #if CONFIG_EXT_PARTITION_TYPES
   free_mode_context(&tree->horizontala_supertx);
   free_mode_context(&tree->horizontalb_supertx);
   free_mode_context(&tree->verticala_supertx);
   free_mode_context(&tree->verticalb_supertx);
--- a/third_party/aom/av1/encoder/context_tree.h
+++ b/third_party/aom/av1/encoder/context_tree.h
@@ -81,17 +81,17 @@ typedef struct PC_TREE {
   PICK_MODE_CONTEXT horizontalb[3];
   PICK_MODE_CONTEXT verticala[3];
   PICK_MODE_CONTEXT verticalb[3];
 #endif
   union {
     struct PC_TREE *split[4];
     PICK_MODE_CONTEXT *leaf_split[4];
   };
-#ifdef CONFIG_SUPERTX
+#if CONFIG_SUPERTX
   PICK_MODE_CONTEXT horizontal_supertx;
   PICK_MODE_CONTEXT vertical_supertx;
   PICK_MODE_CONTEXT split_supertx;
 #if CONFIG_EXT_PARTITION_TYPES
   PICK_MODE_CONTEXT horizontala_supertx;
   PICK_MODE_CONTEXT horizontalb_supertx;
   PICK_MODE_CONTEXT verticala_supertx;
   PICK_MODE_CONTEXT verticalb_supertx;
--- a/third_party/aom/av1/encoder/cost.c
+++ b/third_party/aom/av1/encoder/cost.c
@@ -60,8 +60,26 @@ void av1_cost_tokens(int *costs, const a
 }
 
 void av1_cost_tokens_skip(int *costs, const aom_prob *probs, aom_tree tree) {
   assert(tree[0] <= 0 && tree[1] > 0);
 
   costs[-tree[0]] = av1_cost_bit(probs[0], 0);
   cost(costs, tree, probs, 2, 0);
 }
+
+void av1_cost_tokens_from_cdf(int *costs, const aom_cdf_prob *cdf,
+                              const int *inv_map) {
+  int i;
+  aom_cdf_prob prev_cdf = 0;
+  for (i = 0;; ++i) {
+    const aom_cdf_prob p15 = AOM_ICDF(cdf[i]) - prev_cdf;
+    prev_cdf = AOM_ICDF(cdf[i]);
+
+    if (inv_map)
+      costs[inv_map[i]] = av1_cost_symbol(p15);
+    else
+      costs[i] = av1_cost_symbol(p15);
+
+    // Stop once we reach the end of the CDF
+    if (cdf[i] == AOM_ICDF(CDF_PROB_TOP)) break;
+  }
+}
--- a/third_party/aom/av1/encoder/cost.h
+++ b/third_party/aom/av1/encoder/cost.h
@@ -29,16 +29,24 @@ extern const uint16_t av1_prob_cost[256]
 #define av1_cost_one(prob) av1_cost_zero(256 - (prob))
 
 #define av1_cost_bit(prob, bit) av1_cost_zero((bit) ? 256 - (prob) : (prob))
 
 // Cost of coding an n bit literal, using 128 (i.e. 50%) probability
 // for each bit.
 #define av1_cost_literal(n) ((n) * (1 << AV1_PROB_COST_SHIFT))
 
+// Calculate the cost of a symbol with probability p15 / 2^15
+static INLINE int av1_cost_symbol(aom_cdf_prob p15) {
+  assert(0 < p15 && p15 < CDF_PROB_TOP);
+  const int shift = CDF_PROB_BITS - 1 - get_msb(p15);
+  return av1_cost_zero(get_prob(p15 << shift, CDF_PROB_TOP)) +
+         av1_cost_literal(shift);
+}
+
 static INLINE unsigned int cost_branch256(const unsigned int ct[2],
                                           aom_prob p) {
   return ct[0] * av1_cost_zero(p) + ct[1] * av1_cost_one(p);
 }
 
 static INLINE int treed_cost(aom_tree tree, const aom_prob *probs, int bits,
                              int len) {
   int cost = 0;
@@ -50,14 +58,16 @@ static INLINE int treed_cost(aom_tree tr
     i = tree[i + bit];
   } while (len);
 
   return cost;
 }
 
 void av1_cost_tokens(int *costs, const aom_prob *probs, aom_tree tree);
 void av1_cost_tokens_skip(int *costs, const aom_prob *probs, aom_tree tree);
+void av1_cost_tokens_from_cdf(int *costs, const aom_cdf_prob *cdf,
+                              const int *inv_map);
 
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
 #endif  // AV1_ENCODER_COST_H_
--- a/third_party/aom/av1/encoder/dct.c
+++ b/third_party/aom/av1/encoder/dct.c
@@ -1016,16 +1016,66 @@ static void fhalfright32(const tran_low_
   // Multiply input by sqrt(2)
   for (i = 0; i < 16; ++i) {
     inputhalf[i] = (tran_low_t)fdct_round_shift(input[i + 16] * Sqrt2);
   }
   fdct16(inputhalf, output);
   // Note overall scaling factor is 4 times orthogonal
 }
 
+#if CONFIG_LGT
+static void flgt4(const tran_low_t *input, tran_low_t *output,
+                  const tran_high_t *lgtmtx) {
+  if (!(input[0] | input[1] | input[2] | input[3])) {
+    output[0] = output[1] = output[2] = output[3] = 0;
+    return;
+  }
+
+  // evaluate s[j] = sum of all lgtmtx[j][i]*input[i] over i=1,...,4
+  tran_high_t s[4] = { 0 };
+  for (int i = 0; i < 4; ++i)
+    for (int j = 0; j < 4; ++j) s[j] += lgtmtx[j * 4 + i] * input[i];
+
+  for (int i = 0; i < 4; ++i) output[i] = (tran_low_t)fdct_round_shift(s[i]);
+}
+
+static void flgt8(const tran_low_t *input, tran_low_t *output,
+                  const tran_high_t *lgtmtx) {
+  // evaluate s[j] = sum of all lgtmtx[j][i]*input[i] over i=1,...,8
+  tran_high_t s[8] = { 0 };
+  for (int i = 0; i < 8; ++i)
+    for (int j = 0; j < 8; ++j) s[j] += lgtmtx[j * 8 + i] * input[i];
+
+  for (int i = 0; i < 8; ++i) output[i] = (tran_low_t)fdct_round_shift(s[i]);
+}
+
+// The get_fwd_lgt functions return 1 if LGT is chosen to apply, and 0 otherwise
+int get_fwd_lgt4(transform_1d tx_orig, FWD_TXFM_PARAM *fwd_txfm_param,
+                 const tran_high_t *lgtmtx[], int ntx) {
+  // inter/intra split
+  if (tx_orig == &fadst4) {
+    for (int i = 0; i < ntx; ++i)
+      lgtmtx[i] = fwd_txfm_param->is_inter ? &lgt4_170[0][0] : &lgt4_140[0][0];
+    return 1;
+  }
+  return 0;
+}
+
+int get_fwd_lgt8(transform_1d tx_orig, FWD_TXFM_PARAM *fwd_txfm_param,
+                 const tran_high_t *lgtmtx[], int ntx) {
+  // inter/intra split
+  if (tx_orig == &fadst8) {
+    for (int i = 0; i < ntx; ++i)
+      lgtmtx[i] = fwd_txfm_param->is_inter ? &lgt8_170[0][0] : &lgt8_150[0][0];
+    return 1;
+  }
+  return 0;
+}
+#endif  // CONFIG_LGT
+
 #if CONFIG_EXT_TX
 // TODO(sarahparker) these functions will be removed once the highbitdepth
 // codepath works properly for rectangular transforms. They have almost
 // identical versions in av1_fwd_txfm1d.c, but those are currently only
 // being used for square transforms.
 static void fidtx4(const tran_low_t *input, tran_low_t *output) {
   int i;
   for (i = 0; i < 4; ++i)
@@ -1139,17 +1189,18 @@ static void maybe_flip_input(const int16
       *src_stride = w;
       break;
     default: assert(0); break;
   }
 }
 #endif  // CONFIG_EXT_TX
 
 void av1_fht4x4_c(const int16_t *input, tran_low_t *output, int stride,
-                  int tx_type) {
+                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   if (tx_type == DCT_DCT) {
     aom_fdct4x4_c(input, output, stride);
   } else {
     static const transform_2d FHT[] = {
       { fdct4, fdct4 },    // DCT_DCT
       { fadst4, fdct4 },   // ADST_DCT
       { fdct4, fadst4 },   // DCT_ADST
       { fadst4, fadst4 },  // ADST_ADST
@@ -1161,47 +1212,67 @@ void av1_fht4x4_c(const int16_t *input, 
       { fadst4, fadst4 },  // FLIPADST_ADST
       { fidtx4, fidtx4 },  // IDTX
       { fdct4, fidtx4 },   // V_DCT
       { fidtx4, fdct4 },   // H_DCT
       { fadst4, fidtx4 },  // V_ADST
       { fidtx4, fadst4 },  // H_ADST
       { fadst4, fidtx4 },  // V_FLIPADST
       { fidtx4, fadst4 },  // H_FLIPADST
-#endif                     // CONFIG_EXT_TX
+#endif
     };
     const transform_2d ht = FHT[tx_type];
     tran_low_t out[4 * 4];
     int i, j;
     tran_low_t temp_in[4], temp_out[4];
 
 #if CONFIG_EXT_TX
     int16_t flipped_input[4 * 4];
     maybe_flip_input(&input, &stride, 4, 4, flipped_input, tx_type);
 #endif
 
+#if CONFIG_LGT
+    // Choose LGT adaptive to the prediction. We may apply different LGTs for
+    // different rows/columns, indicated by the pointers to 2D arrays
+    const tran_high_t *lgtmtx_col[4];
+    const tran_high_t *lgtmtx_row[4];
+    int use_lgt_col = get_fwd_lgt4(ht.cols, fwd_txfm_param, lgtmtx_col, 4);
+    int use_lgt_row = get_fwd_lgt4(ht.rows, fwd_txfm_param, lgtmtx_row, 4);
+#endif
+
     // Columns
     for (i = 0; i < 4; ++i) {
       for (j = 0; j < 4; ++j) temp_in[j] = input[j * stride + i] * 16;
       if (i == 0 && temp_in[0]) temp_in[0] += 1;
-      ht.cols(temp_in, temp_out);
+#if CONFIG_LGT
+      if (use_lgt_col)
+        flgt4(temp_in, temp_out, lgtmtx_col[i]);
+      else
+#endif
+        ht.cols(temp_in, temp_out);
       for (j = 0; j < 4; ++j) out[j * 4 + i] = temp_out[j];
     }
 
     // Rows
     for (i = 0; i < 4; ++i) {
       for (j = 0; j < 4; ++j) temp_in[j] = out[j + i * 4];
-      ht.rows(temp_in, temp_out);
+#if CONFIG_LGT
+      if (use_lgt_row)
+        flgt4(temp_in, temp_out, lgtmtx_row[i]);
+      else
+#endif
+        ht.rows(temp_in, temp_out);
       for (j = 0; j < 4; ++j) output[j + i * 4] = (temp_out[j] + 1) >> 2;
     }
   }
 }
 
 void av1_fht4x8_c(const int16_t *input, tran_low_t *output, int stride,
-                  int tx_type) {
+                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct8, fdct4 },    // DCT_DCT
     { fadst8, fdct4 },   // ADST_DCT
     { fdct8, fadst4 },   // DCT_ADST
     { fadst8, fadst4 },  // ADST_ADST
 #if CONFIG_EXT_TX
     { fadst8, fdct4 },   // FLIPADST_DCT
     { fdct8, fadst4 },   // DCT_FLIPADST
@@ -1223,37 +1294,55 @@ void av1_fht4x8_c(const int16_t *input, 
   tran_low_t out[8 * 4];
   tran_low_t temp_in[8], temp_out[8];
   int i, j;
 #if CONFIG_EXT_TX
   int16_t flipped_input[8 * 4];
   maybe_flip_input(&input, &stride, n2, n, flipped_input, tx_type);
 #endif
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_col[4];
+  const tran_high_t *lgtmtx_row[8];
+  int use_lgt_col = get_fwd_lgt8(ht.cols, fwd_txfm_param, lgtmtx_col, 4);
+  int use_lgt_row = get_fwd_lgt4(ht.rows, fwd_txfm_param, lgtmtx_row, 8);
+#endif
+
   // Rows
   for (i = 0; i < n2; ++i) {
     for (j = 0; j < n; ++j)
       temp_in[j] =
           (tran_low_t)fdct_round_shift(input[i * stride + j] * 4 * Sqrt2);
-    ht.rows(temp_in, temp_out);
+#if CONFIG_LGT
+    if (use_lgt_row)
+      flgt4(temp_in, temp_out, lgtmtx_row[i]);
+    else
+#endif
+      ht.rows(temp_in, temp_out);
     for (j = 0; j < n; ++j) out[j * n2 + i] = temp_out[j];
   }
 
   // Columns
   for (i = 0; i < n; ++i) {
     for (j = 0; j < n2; ++j) temp_in[j] = out[j + i * n2];
-    ht.cols(temp_in, temp_out);
+#if CONFIG_LGT
+    if (use_lgt_col)
+      flgt8(temp_in, temp_out, lgtmtx_col[i]);
+    else
+#endif
+      ht.cols(temp_in, temp_out);
     for (j = 0; j < n2; ++j)
       output[i + j * n] = (temp_out[j] + (temp_out[j] < 0)) >> 1;
   }
   // Note: overall scale factor of transform is 8 times unitary
 }
 
 void av1_fht8x4_c(const int16_t *input, tran_low_t *output, int stride,
-                  int tx_type) {
+                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct4, fdct8 },    // DCT_DCT
     { fadst4, fdct8 },   // ADST_DCT
     { fdct4, fadst8 },   // DCT_ADST
     { fadst4, fadst8 },  // ADST_ADST
 #if CONFIG_EXT_TX
     { fadst4, fdct8 },   // FLIPADST_DCT
     { fdct4, fadst8 },   // DCT_FLIPADST
@@ -1275,37 +1364,55 @@ void av1_fht8x4_c(const int16_t *input, 
   tran_low_t out[8 * 4];
   tran_low_t temp_in[8], temp_out[8];
   int i, j;
 #if CONFIG_EXT_TX
   int16_t flipped_input[8 * 4];
   maybe_flip_input(&input, &stride, n, n2, flipped_input, tx_type);
 #endif
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_col[8];
+  const tran_high_t *lgtmtx_row[4];
+  int use_lgt_col = get_fwd_lgt4(ht.cols, fwd_txfm_param, lgtmtx_col, 8);
+  int use_lgt_row = get_fwd_lgt8(ht.rows, fwd_txfm_param, lgtmtx_row, 4);
+#endif
+
   // Columns
   for (i = 0; i < n2; ++i) {
     for (j = 0; j < n; ++j)
       temp_in[j] =
           (tran_low_t)fdct_round_shift(input[j * stride + i] * 4 * Sqrt2);
-    ht.cols(temp_in, temp_out);
+#if CONFIG_LGT
+    if (use_lgt_col)
+      flgt4(temp_in, temp_out, lgtmtx_col[i]);
+    else
+#endif
+      ht.cols(temp_in, temp_out);
     for (j = 0; j < n; ++j) out[j * n2 + i] = temp_out[j];
   }
 
   // Rows
   for (i = 0; i < n; ++i) {
     for (j = 0; j < n2; ++j) temp_in[j] = out[j + i * n2];
-    ht.rows(temp_in, temp_out);
+#if CONFIG_LGT
+    if (use_lgt_row)
+      flgt8(temp_in, temp_out, lgtmtx_row[i]);
+    else
+#endif
+      ht.rows(temp_in, temp_out);
     for (j = 0; j < n2; ++j)
       output[j + i * n2] = (temp_out[j] + (temp_out[j] < 0)) >> 1;
   }
   // Note: overall scale factor of transform is 8 times unitary
 }
 
 void av1_fht4x16_c(const int16_t *input, tran_low_t *output, int stride,
-                   int tx_type) {
+                   FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct16, fdct4 },    // DCT_DCT
     { fadst16, fdct4 },   // ADST_DCT
     { fdct16, fadst4 },   // DCT_ADST
     { fadst16, fadst4 },  // ADST_ADST
 #if CONFIG_EXT_TX
     { fadst16, fdct4 },   // FLIPADST_DCT
     { fdct16, fadst4 },   // DCT_FLIPADST
@@ -1327,35 +1434,46 @@ void av1_fht4x16_c(const int16_t *input,
   tran_low_t out[16 * 4];
   tran_low_t temp_in[16], temp_out[16];
   int i, j;
 #if CONFIG_EXT_TX
   int16_t flipped_input[16 * 4];
   maybe_flip_input(&input, &stride, n4, n, flipped_input, tx_type);
 #endif
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_row[16];
+  int use_lgt_row = get_fwd_lgt4(ht.rows, fwd_txfm_param, lgtmtx_row, 16);
+#endif
+
   // Rows
   for (i = 0; i < n4; ++i) {
     for (j = 0; j < n; ++j) temp_in[j] = input[i * stride + j] * 4;
-    ht.rows(temp_in, temp_out);
+#if CONFIG_LGT
+    if (use_lgt_row)
+      flgt4(temp_in, temp_out, lgtmtx_row[i]);
+    else
+#endif
+      ht.rows(temp_in, temp_out);
     for (j = 0; j < n; ++j) out[j * n4 + i] = temp_out[j];
   }
 
   // Columns
   for (i = 0; i < n; ++i) {
     for (j = 0; j < n4; ++j) temp_in[j] = out[j + i * n4];
     ht.cols(temp_in, temp_out);
     for (j = 0; j < n4; ++j)
       output[i + j * n] = (temp_out[j] + (temp_out[j] < 0)) >> 1;
   }
   // Note: overall scale factor of transform is 8 times unitary
 }
 
 void av1_fht16x4_c(const int16_t *input, tran_low_t *output, int stride,
-                   int tx_type) {
+                   FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct4, fdct16 },    // DCT_DCT
     { fadst4, fdct16 },   // ADST_DCT
     { fdct4, fadst16 },   // DCT_ADST
     { fadst4, fadst16 },  // ADST_ADST
 #if CONFIG_EXT_TX
     { fadst4, fdct16 },   // FLIPADST_DCT
     { fdct4, fadst16 },   // DCT_FLIPADST
@@ -1377,35 +1495,46 @@ void av1_fht16x4_c(const int16_t *input,
   tran_low_t out[16 * 4];
   tran_low_t temp_in[16], temp_out[16];
   int i, j;
 #if CONFIG_EXT_TX
   int16_t flipped_input[16 * 4];
   maybe_flip_input(&input, &stride, n, n4, flipped_input, tx_type);
 #endif
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_col[16];
+  int use_lgt_col = get_fwd_lgt4(ht.cols, fwd_txfm_param, lgtmtx_col, 16);
+#endif
+
   // Columns
   for (i = 0; i < n4; ++i) {
     for (j = 0; j < n; ++j) temp_in[j] = input[j * stride + i] * 4;
-    ht.cols(temp_in, temp_out);
+#if CONFIG_LGT
+    if (use_lgt_col)
+      flgt4(temp_in, temp_out, lgtmtx_col[i]);
+    else
+#endif
+      ht.cols(temp_in, temp_out);
     for (j = 0; j < n; ++j) out[j * n4 + i] = temp_out[j];
   }
 
   // Rows
   for (i = 0; i < n; ++i) {
     for (j = 0; j < n4; ++j) temp_in[j] = out[j + i * n4];
     ht.rows(temp_in, temp_out);
     for (j = 0; j < n4; ++j)
       output[j + i * n4] = (temp_out[j] + (temp_out[j] < 0)) >> 1;
   }
   // Note: overall scale factor of transform is 8 times unitary
 }
 
 void av1_fht8x16_c(const int16_t *input, tran_low_t *output, int stride,
-                   int tx_type) {
+                   FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct16, fdct8 },    // DCT_DCT
     { fadst16, fdct8 },   // ADST_DCT
     { fdct16, fadst8 },   // DCT_ADST
     { fadst16, fadst8 },  // ADST_ADST
 #if CONFIG_EXT_TX
     { fadst16, fdct8 },   // FLIPADST_DCT
     { fdct16, fadst8 },   // DCT_FLIPADST
@@ -1427,37 +1556,48 @@ void av1_fht8x16_c(const int16_t *input,
   tran_low_t out[16 * 8];
   tran_low_t temp_in[16], temp_out[16];
   int i, j;
 #if CONFIG_EXT_TX
   int16_t flipped_input[16 * 8];
   maybe_flip_input(&input, &stride, n2, n, flipped_input, tx_type);
 #endif
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_row[16];
+  int use_lgt_row = get_fwd_lgt8(ht.rows, fwd_txfm_param, lgtmtx_row, 16);
+#endif
+
   // Rows
   for (i = 0; i < n2; ++i) {
     for (j = 0; j < n; ++j)
       temp_in[j] =
           (tran_low_t)fdct_round_shift(input[i * stride + j] * 4 * Sqrt2);
-    ht.rows(temp_in, temp_out);
+#if CONFIG_LGT
+    if (use_lgt_row)
+      flgt8(temp_in, temp_out, lgtmtx_row[i]);
+    else
+#endif
+      ht.rows(temp_in, temp_out);
     for (j = 0; j < n; ++j)
       out[j * n2 + i] = ROUND_POWER_OF_TWO_SIGNED(temp_out[j], 2);
   }
 
   // Columns
   for (i = 0; i < n; ++i) {
     for (j = 0; j < n2; ++j) temp_in[j] = out[j + i * n2];
     ht.cols(temp_in, temp_out);
     for (j = 0; j < n2; ++j) output[i + j * n] = temp_out[j];
   }
   // Note: overall scale factor of transform is 8 times unitary
 }
 
 void av1_fht16x8_c(const int16_t *input, tran_low_t *output, int stride,
-                   int tx_type) {
+                   FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct8, fdct16 },    // DCT_DCT
     { fadst8, fdct16 },   // ADST_DCT
     { fdct8, fadst16 },   // DCT_ADST
     { fadst8, fadst16 },  // ADST_ADST
 #if CONFIG_EXT_TX
     { fadst8, fdct16 },   // FLIPADST_DCT
     { fdct8, fadst16 },   // DCT_FLIPADST
@@ -1479,37 +1619,48 @@ void av1_fht16x8_c(const int16_t *input,
   tran_low_t out[16 * 8];
   tran_low_t temp_in[16], temp_out[16];
   int i, j;
 #if CONFIG_EXT_TX
   int16_t flipped_input[16 * 8];
   maybe_flip_input(&input, &stride, n, n2, flipped_input, tx_type);
 #endif
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_col[16];
+  int use_lgt_col = get_fwd_lgt8(ht.cols, fwd_txfm_param, lgtmtx_col, 16);
+#endif
+
   // Columns
   for (i = 0; i < n2; ++i) {
     for (j = 0; j < n; ++j)
       temp_in[j] =
           (tran_low_t)fdct_round_shift(input[j * stride + i] * 4 * Sqrt2);
-    ht.cols(temp_in, temp_out);
+#if CONFIG_LGT
+    if (use_lgt_col)
+      flgt8(temp_in, temp_out, lgtmtx_col[i]);
+    else
+#endif
+      ht.cols(temp_in, temp_out);
     for (j = 0; j < n; ++j)
       out[j * n2 + i] = ROUND_POWER_OF_TWO_SIGNED(temp_out[j], 2);
   }
 
   // Rows
   for (i = 0; i < n; ++i) {
     for (j = 0; j < n2; ++j) temp_in[j] = out[j + i * n2];
     ht.rows(temp_in, temp_out);
     for (j = 0; j < n2; ++j) output[j + i * n2] = temp_out[j];
   }
   // Note: overall scale factor of transform is 8 times unitary
 }
 
 void av1_fht8x32_c(const int16_t *input, tran_low_t *output, int stride,
-                   int tx_type) {
+                   FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct32, fdct8 },         // DCT_DCT
     { fhalfright32, fdct8 },   // ADST_DCT
     { fdct32, fadst8 },        // DCT_ADST
     { fhalfright32, fadst8 },  // ADST_ADST
 #if CONFIG_EXT_TX
     { fhalfright32, fdct8 },   // FLIPADST_DCT
     { fdct32, fadst8 },        // DCT_FLIPADST
@@ -1531,35 +1682,46 @@ void av1_fht8x32_c(const int16_t *input,
   tran_low_t out[32 * 8];
   tran_low_t temp_in[32], temp_out[32];
   int i, j;
 #if CONFIG_EXT_TX
   int16_t flipped_input[32 * 8];
   maybe_flip_input(&input, &stride, n4, n, flipped_input, tx_type);
 #endif
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_row[32];
+  int use_lgt_row = get_fwd_lgt8(ht.rows, fwd_txfm_param, lgtmtx_row, 32);
+#endif
+
   // Rows
   for (i = 0; i < n4; ++i) {
     for (j = 0; j < n; ++j) temp_in[j] = input[i * stride + j] * 4;
-    ht.rows(temp_in, temp_out);
+#if CONFIG_LGT
+    if (use_lgt_row)
+      flgt8(temp_in, temp_out, lgtmtx_row[i]);
+    else
+#endif
+      ht.rows(temp_in, temp_out);
     for (j = 0; j < n; ++j) out[j * n4 + i] = temp_out[j];
   }
 
   // Columns
   for (i = 0; i < n; ++i) {
     for (j = 0; j < n4; ++j) temp_in[j] = out[j + i * n4];
     ht.cols(temp_in, temp_out);
     for (j = 0; j < n4; ++j)
       output[i + j * n] = ROUND_POWER_OF_TWO_SIGNED(temp_out[j], 2);
   }
   // Note: overall scale factor of transform is 4 times unitary
 }
 
 void av1_fht32x8_c(const int16_t *input, tran_low_t *output, int stride,
-                   int tx_type) {
+                   FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct8, fdct32 },         // DCT_DCT
     { fadst8, fdct32 },        // ADST_DCT
     { fdct8, fhalfright32 },   // DCT_ADST
     { fadst8, fhalfright32 },  // ADST_ADST
 #if CONFIG_EXT_TX
     { fadst8, fdct32 },        // FLIPADST_DCT
     { fdct8, fhalfright32 },   // DCT_FLIPADST
@@ -1581,35 +1743,46 @@ void av1_fht32x8_c(const int16_t *input,
   tran_low_t out[32 * 8];
   tran_low_t temp_in[32], temp_out[32];
   int i, j;
 #if CONFIG_EXT_TX
   int16_t flipped_input[32 * 8];
   maybe_flip_input(&input, &stride, n, n4, flipped_input, tx_type);
 #endif
 
+#if CONFIG_LGT
+  const tran_high_t *lgtmtx_col[32];
+  int use_lgt_col = get_fwd_lgt8(ht.cols, fwd_txfm_param, lgtmtx_col, 32);
+#endif
+
   // Columns
   for (i = 0; i < n4; ++i) {
     for (j = 0; j < n; ++j) temp_in[j] = input[j * stride + i] * 4;
-    ht.cols(temp_in, temp_out);
+#if CONFIG_LGT
+    if (use_lgt_col)
+      flgt8(temp_in, temp_out, lgtmtx_col[i]);
+    else
+#endif
+      ht.cols(temp_in, temp_out);
     for (j = 0; j < n; ++j) out[j * n4 + i] = temp_out[j];
   }
 
   // Rows
   for (i = 0; i < n; ++i) {
     for (j = 0; j < n4; ++j) temp_in[j] = out[j + i * n4];
     ht.rows(temp_in, temp_out);
     for (j = 0; j < n4; ++j)
       output[j + i * n4] = ROUND_POWER_OF_TWO_SIGNED(temp_out[j], 2);
   }
   // Note: overall scale factor of transform is 4 times unitary
 }
 
 void av1_fht16x32_c(const int16_t *input, tran_low_t *output, int stride,
-                    int tx_type) {
+                    FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct32, fdct16 },         // DCT_DCT
     { fhalfright32, fdct16 },   // ADST_DCT
     { fdct32, fadst16 },        // DCT_ADST
     { fhalfright32, fadst16 },  // ADST_ADST
 #if CONFIG_EXT_TX
     { fhalfright32, fdct16 },   // FLIPADST_DCT
     { fdct32, fadst16 },        // DCT_FLIPADST
@@ -1651,17 +1824,18 @@ void av1_fht16x32_c(const int16_t *input
     for (j = 0; j < n2; ++j) temp_in[j] = out[j + i * n2];
     ht.cols(temp_in, temp_out);
     for (j = 0; j < n2; ++j) output[i + j * n] = temp_out[j];
   }
   // Note: overall scale factor of transform is 4 times unitary
 }
 
 void av1_fht32x16_c(const int16_t *input, tran_low_t *output, int stride,
-                    int tx_type) {
+                    FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct16, fdct32 },         // DCT_DCT
     { fadst16, fdct32 },        // ADST_DCT
     { fdct16, fhalfright32 },   // DCT_ADST
     { fadst16, fhalfright32 },  // ADST_ADST
 #if CONFIG_EXT_TX
     { fadst16, fdct32 },        // FLIPADST_DCT
     { fdct16, fhalfright32 },   // DCT_FLIPADST
@@ -1828,17 +2002,18 @@ void av1_fdct8x8_quant_c(const int16_t *
 
       if (tmp32) eob = i;
     }
   }
   *eob_ptr = eob + 1;
 }
 
 void av1_fht8x8_c(const int16_t *input, tran_low_t *output, int stride,
-                  int tx_type) {
+                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   if (tx_type == DCT_DCT) {
     aom_fdct8x8_c(input, output, stride);
   } else {
     static const transform_2d FHT[] = {
       { fdct8, fdct8 },    // DCT_DCT
       { fadst8, fdct8 },   // ADST_DCT
       { fdct8, fadst8 },   // DCT_ADST
       { fadst8, fadst8 },  // ADST_ADST
@@ -1850,39 +2025,56 @@ void av1_fht8x8_c(const int16_t *input, 
       { fadst8, fadst8 },  // FLIPADST_ADST
       { fidtx8, fidtx8 },  // IDTX
       { fdct8, fidtx8 },   // V_DCT
       { fidtx8, fdct8 },   // H_DCT
       { fadst8, fidtx8 },  // V_ADST
       { fidtx8, fadst8 },  // H_ADST
       { fadst8, fidtx8 },  // V_FLIPADST
       { fidtx8, fadst8 },  // H_FLIPADST
-#endif                     // CONFIG_EXT_TX
+#endif
     };
     const transform_2d ht = FHT[tx_type];
     tran_low_t out[64];
     int i, j;
     tran_low_t temp_in[8], temp_out[8];
 
 #if CONFIG_EXT_TX
     int16_t flipped_input[8 * 8];
     maybe_flip_input(&input, &stride, 8, 8, flipped_input, tx_type);
 #endif
 
+#if CONFIG_LGT
+    const tran_high_t *lgtmtx_col[8];
+    const tran_high_t *lgtmtx_row[8];
+    int use_lgt_col = get_fwd_lgt8(ht.cols, fwd_txfm_param, lgtmtx_col, 8);
+    int use_lgt_row = get_fwd_lgt8(ht.rows, fwd_txfm_param, lgtmtx_row, 8);
+#endif
+
     // Columns
     for (i = 0; i < 8; ++i) {
       for (j = 0; j < 8; ++j) temp_in[j] = input[j * stride + i] * 4;
-      ht.cols(temp_in, temp_out);
+#if CONFIG_LGT
+      if (use_lgt_col)
+        flgt8(temp_in, temp_out, lgtmtx_col[i]);
+      else
+#endif
+        ht.cols(temp_in, temp_out);
       for (j = 0; j < 8; ++j) out[j * 8 + i] = temp_out[j];
     }
 
     // Rows
     for (i = 0; i < 8; ++i) {
       for (j = 0; j < 8; ++j) temp_in[j] = out[j + i * 8];
-      ht.rows(temp_in, temp_out);
+#if CONFIG_LGT
+      if (use_lgt_row)
+        flgt8(temp_in, temp_out, lgtmtx_row[i]);
+      else
+#endif
+        ht.rows(temp_in, temp_out);
       for (j = 0; j < 8; ++j)
         output[j + i * 8] = (temp_out[j] + (temp_out[j] < 0)) >> 1;
     }
   }
 }
 
 /* 4-point reversible, orthonormal Walsh-Hadamard in 3.5 adds, 0.5 shifts per
    pixel. */
@@ -1936,17 +2128,18 @@ void av1_fwht4x4_c(const int16_t *input,
     op[3] = (tran_low_t)(b1 * UNIT_QUANT_FACTOR);
 
     ip += 4;
     op += 4;
   }
 }
 
 void av1_fht16x16_c(const int16_t *input, tran_low_t *output, int stride,
-                    int tx_type) {
+                    FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct16, fdct16 },    // DCT_DCT
     { fadst16, fdct16 },   // ADST_DCT
     { fdct16, fadst16 },   // DCT_ADST
     { fadst16, fadst16 },  // ADST_ADST
 #if CONFIG_EXT_TX
     { fadst16, fdct16 },   // FLIPADST_DCT
     { fdct16, fadst16 },   // DCT_FLIPADST
@@ -1955,19 +2148,18 @@ void av1_fht16x16_c(const int16_t *input
     { fadst16, fadst16 },  // FLIPADST_ADST
     { fidtx16, fidtx16 },  // IDTX
     { fdct16, fidtx16 },   // V_DCT
     { fidtx16, fdct16 },   // H_DCT
     { fadst16, fidtx16 },  // V_ADST
     { fidtx16, fadst16 },  // H_ADST
     { fadst16, fidtx16 },  // V_FLIPADST
     { fidtx16, fadst16 },  // H_FLIPADST
-#endif                     // CONFIG_EXT_TX
+#endif
   };
-
   const transform_2d ht = FHT[tx_type];
   tran_low_t out[256];
   int i, j;
   tran_low_t temp_in[16], temp_out[16];
 
 #if CONFIG_EXT_TX
   int16_t flipped_input[16 * 16];
   maybe_flip_input(&input, &stride, 16, 16, flipped_input, tx_type);
@@ -1984,90 +2176,24 @@ void av1_fht16x16_c(const int16_t *input
   // Rows
   for (i = 0; i < 16; ++i) {
     for (j = 0; j < 16; ++j) temp_in[j] = out[j + i * 16];
     ht.rows(temp_in, temp_out);
     for (j = 0; j < 16; ++j) output[j + i * 16] = temp_out[j];
   }
 }
 
-#if CONFIG_HIGHBITDEPTH
-void av1_highbd_fht4x4_c(const int16_t *input, tran_low_t *output, int stride,
-                         int tx_type) {
-  av1_fht4x4_c(input, output, stride, tx_type);
-}
-
-void av1_highbd_fht4x8_c(const int16_t *input, tran_low_t *output, int stride,
-                         int tx_type) {
-  av1_fht4x8_c(input, output, stride, tx_type);
-}
-
-void av1_highbd_fht8x4_c(const int16_t *input, tran_low_t *output, int stride,
-                         int tx_type) {
-  av1_fht8x4_c(input, output, stride, tx_type);
-}
-
-void av1_highbd_fht8x16_c(const int16_t *input, tran_low_t *output, int stride,
-                          int tx_type) {
-  av1_fht8x16_c(input, output, stride, tx_type);
-}
-
-void av1_highbd_fht16x8_c(const int16_t *input, tran_low_t *output, int stride,
-                          int tx_type) {
-  av1_fht16x8_c(input, output, stride, tx_type);
-}
-
-void av1_highbd_fht16x32_c(const int16_t *input, tran_low_t *output, int stride,
-                           int tx_type) {
-  av1_fht16x32_c(input, output, stride, tx_type);
-}
-
-void av1_highbd_fht32x16_c(const int16_t *input, tran_low_t *output, int stride,
-                           int tx_type) {
-  av1_fht32x16_c(input, output, stride, tx_type);
-}
-
-void av1_highbd_fht4x16_c(const int16_t *input, tran_low_t *output, int stride,
-                          int tx_type) {
-  av1_fht4x16_c(input, output, stride, tx_type);
-}
-
-void av1_highbd_fht16x4_c(const int16_t *input, tran_low_t *output, int stride,
-                          int tx_type) {
-  av1_fht16x4_c(input, output, stride, tx_type);
-}
-
-void av1_highbd_fht8x32_c(const int16_t *input, tran_low_t *output, int stride,
-                          int tx_type) {
-  av1_fht8x32_c(input, output, stride, tx_type);
-}
-
-void av1_highbd_fht32x8_c(const int16_t *input, tran_low_t *output, int stride,
-                          int tx_type) {
-  av1_fht32x8_c(input, output, stride, tx_type);
-}
-
-void av1_highbd_fht8x8_c(const int16_t *input, tran_low_t *output, int stride,
-                         int tx_type) {
-  av1_fht8x8_c(input, output, stride, tx_type);
-}
-
 void av1_highbd_fwht4x4_c(const int16_t *input, tran_low_t *output,
                           int stride) {
   av1_fwht4x4_c(input, output, stride);
 }
 
-void av1_highbd_fht16x16_c(const int16_t *input, tran_low_t *output, int stride,
-                           int tx_type) {
-  av1_fht16x16_c(input, output, stride, tx_type);
-}
-#endif  // CONFIG_HIGHBITDEPTH
-
 void av1_fht32x32_c(const int16_t *input, tran_low_t *output, int stride,
-                    int tx_type) {
+                    FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct32, fdct32 },  // DCT_DCT
 #if CONFIG_EXT_TX
     { fhalfright32, fdct32 },        // ADST_DCT
     { fdct32, fhalfright32 },        // DCT_ADST
     { fhalfright32, fhalfright32 },  // ADST_ADST
     { fhalfright32, fdct32 },        // FLIPADST_DCT
     { fdct32, fhalfright32 },        // DCT_FLIPADST
@@ -2145,17 +2271,18 @@ static void fdct64_row(const tran_low_t 
   int32_t in[64], out[64];
   int i;
   for (i = 0; i < 64; ++i) in[i] = (int32_t)input[i];
   av1_fdct64_new(in, out, fwd_cos_bit_row_dct_64, fwd_stage_range_row_dct_64);
   for (i = 0; i < 64; ++i) output[i] = (tran_low_t)out[i];
 }
 
 void av1_fht64x64_c(const int16_t *input, tran_low_t *output, int stride,
-                    int tx_type) {
+                    FWD_TXFM_PARAM *fwd_txfm_param) {
+  int tx_type = fwd_txfm_param->tx_type;
   static const transform_2d FHT[] = {
     { fdct64_col, fdct64_row },  // DCT_DCT
 #if CONFIG_EXT_TX
     { fhalfright64, fdct64_row },    // ADST_DCT
     { fdct64_col, fhalfright64 },    // DCT_ADST
     { fhalfright64, fhalfright64 },  // ADST_ADST
     { fhalfright64, fdct64_row },    // FLIPADST_DCT
     { fdct64_col, fhalfright64 },    // DCT_FLIPADST
@@ -2174,16 +2301,17 @@ void av1_fht64x64_c(const int16_t *input
   const transform_2d ht = FHT[tx_type];
   tran_low_t out[4096];
   int i, j;
   tran_low_t temp_in[64], temp_out[64];
 #if CONFIG_EXT_TX
   int16_t flipped_input[64 * 64];
   maybe_flip_input(&input, &stride, 64, 64, flipped_input, tx_type);
 #endif
+
   // Columns
   for (i = 0; i < 64; ++i) {
     for (j = 0; j < 64; ++j) temp_in[j] = input[j * stride + i];
     ht.cols(temp_in, temp_out);
     for (j = 0; j < 64; ++j)
       out[j * 64 + i] = (temp_out[j] + 1 + (temp_out[j] > 0)) >> 2;
   }
 
@@ -2209,30 +2337,16 @@ void av1_fwd_idtx_c(const int16_t *src_d
       for (c = 0; c < bs; ++c) coeff[c] = src_diff[c] * (1 << shift);
       src_diff += stride;
       coeff += bs;
     }
   }
 }
 #endif  // CONFIG_EXT_TX
 
-#if CONFIG_HIGHBITDEPTH
-void av1_highbd_fht32x32_c(const int16_t *input, tran_low_t *output, int stride,
-                           int tx_type) {
-  av1_fht32x32_c(input, output, stride, tx_type);
-}
-
-#if CONFIG_TX64X64
-void av1_highbd_fht64x64_c(const int16_t *input, tran_low_t *output, int stride,
-                           int tx_type) {
-  av1_fht64x64_c(input, output, stride, tx_type);
-}
-#endif  // CONFIG_TX64X64
-#endif  // CONFIG_HIGHBITDEPTH
-
 #if CONFIG_DPCM_INTRA
 void av1_dpcm_ft4_c(const int16_t *input, int stride, TX_TYPE_1D tx_type,
                     tran_low_t *output) {
   assert(tx_type < TX_TYPES_1D);
   static const transform_1d FHT[] = { fdct4, fadst4, fadst4, fidtx4 };
   const transform_1d ft = FHT[tx_type];
   tran_low_t temp_in[4];
   for (int i = 0; i < 4; ++i)
@@ -2266,10 +2380,59 @@ void av1_dpcm_ft32_c(const int16_t *inpu
   assert(tx_type < TX_TYPES_1D);
   static const transform_1d FHT[] = { fdct32, fhalfright32, fhalfright32,
                                       fidtx32 };
   const transform_1d ft = FHT[tx_type];
   tran_low_t temp_in[32];
   for (int i = 0; i < 32; ++i) temp_in[i] = input[i * stride];
   ft(temp_in, output);
 }
+
+#if CONFIG_HIGHBITDEPTH
+void av1_hbd_dpcm_ft4_c(const int16_t *input, int stride, TX_TYPE_1D tx_type,
+                        tran_low_t *output, int dir) {
+  (void)dir;
+  assert(tx_type < TX_TYPES_1D);
+  static const transform_1d FHT[] = { fdct4, fadst4, fadst4, fidtx4 };
+  const transform_1d ft = FHT[tx_type];
+  tran_low_t temp_in[4];
+  for (int i = 0; i < 4; ++i)
+    temp_in[i] = (tran_low_t)fdct_round_shift(input[i * stride] * 4 * Sqrt2);
+  ft(temp_in, output);
+}
+
+void av1_hbd_dpcm_ft8_c(const int16_t *input, int stride, TX_TYPE_1D tx_type,
+                        tran_low_t *output, int dir) {
+  (void)dir;
+  assert(tx_type < TX_TYPES_1D);
+  static const transform_1d FHT[] = { fdct8, fadst8, fadst8, fidtx8 };
+  const transform_1d ft = FHT[tx_type];
+  tran_low_t temp_in[8];
+  for (int i = 0; i < 8; ++i) temp_in[i] = input[i * stride] * 4;
+  ft(temp_in, output);
+}
+
+void av1_hbd_dpcm_ft16_c(const int16_t *input, int stride, TX_TYPE_1D tx_type,
+                         tran_low_t *output, int dir) {
+  (void)dir;
+  assert(tx_type < TX_TYPES_1D);
+  static const transform_1d FHT[] = { fdct16, fadst16, fadst16, fidtx16 };
+  const transform_1d ft = FHT[tx_type];
+  tran_low_t temp_in[16];
+  for (int i = 0; i < 16; ++i)
+    temp_in[i] = (tran_low_t)fdct_round_shift(input[i * stride] * 2 * Sqrt2);
+  ft(temp_in, output);
+}
+
+void av1_hbd_dpcm_ft32_c(const int16_t *input, int stride, TX_TYPE_1D tx_type,
+                         tran_low_t *output, int dir) {
+  (void)dir;
+  assert(tx_type < TX_TYPES_1D);
+  static const transform_1d FHT[] = { fdct32, fhalfright32, fhalfright32,
+                                      fidtx32 };
+  const transform_1d ft = FHT[tx_type];
+  tran_low_t temp_in[32];
+  for (int i = 0; i < 32; ++i) temp_in[i] = input[i * stride];
+  ft(temp_in, output);
+}
+#endif  // CONFIG_HIGHBITDEPTH
 #endif  // CONFIG_DPCM_INTRA
 #endif  // !AV1_DCT_GTEST
--- a/third_party/aom/av1/encoder/encodeframe.c
+++ b/third_party/aom/av1/encoder/encodeframe.c
@@ -79,17 +79,17 @@ static int check_intra_b(PICK_MODE_CONTE
 
 static int check_intra_sb(const AV1_COMP *cpi, const TileInfo *const tile,
                           int mi_row, int mi_col, BLOCK_SIZE bsize,
                           PC_TREE *pc_tree);
 static void predict_superblock(const AV1_COMP *const cpi, ThreadData *td,
 #if CONFIG_EXT_INTER
                                int mi_row_ori, int mi_col_ori,
 #endif  // CONFIG_EXT_INTER
-                               int mi_row_pred, int mi_col_pred,
+                               int mi_row_pred, int mi_col_pred, int plane,
                                BLOCK_SIZE bsize_pred, int b_sub8x8, int block);
 static int check_supertx_sb(BLOCK_SIZE bsize, TX_SIZE supertx_size,
                             PC_TREE *pc_tree);
 static void predict_sb_complex(const AV1_COMP *const cpi, ThreadData *td,
                                const TileInfo *const tile, int mi_row,
                                int mi_col, int mi_row_ori, int mi_col_ori,
                                RUN_TYPE dry_run, BLOCK_SIZE bsize,
                                BLOCK_SIZE top_bsize, uint8_t *dst_buf[3],
@@ -303,17 +303,16 @@ static void set_offsets_without_segment_
                  cm->dependent_horz_tiles,
 #endif  // CONFIG_DEPENDENT_HORZTILES
                  cm->mi_rows, cm->mi_cols);
 
   // Set up source buffers.
   av1_setup_src_planes(x, cpi->source, mi_row, mi_col);
 
   // R/D setup.
-  x->rddiv = cpi->rd.RDDIV;
   x->rdmult = cpi->rd.RDMULT;
 
   // required by av1_append_sub8x8_mvs_for_idx() and av1_find_best_ref_mvs()
   xd->tile = *tile;
 }
 
 static void set_offsets(const AV1_COMP *const cpi, const TileInfo *const tile,
                         MACROBLOCK *const x, int mi_row, int mi_col,
@@ -321,16 +320,20 @@ static void set_offsets(const AV1_COMP *
   const AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *const xd = &x->e_mbd;
   MB_MODE_INFO *mbmi;
   const struct segmentation *const seg = &cm->seg;
 
   set_offsets_without_segment_id(cpi, tile, x, mi_row, mi_col, bsize);
 
   mbmi = &xd->mi[0]->mbmi;
+#if CONFIG_CFL
+  xd->cfl->mi_row = mi_row;
+  xd->cfl->mi_col = mi_col;
+#endif
 
   // Setup segment ID.
   if (seg->enabled) {
     if (!cpi->vaq_refresh) {
       const uint8_t *const map =
           seg->update_map ? cpi->segmentation_map : cm->last_frame_seg_map;
       mbmi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
     }
@@ -408,17 +411,16 @@ static void set_offsets_extend(const AV1
 #if CONFIG_DEPENDENT_HORZTILES
                  cm->dependent_horz_tiles,
 #endif  // CONFIG_DEPENDENT_HORZTILES
                  cm->mi_rows, cm->mi_cols);
   xd->up_available = (mi_row_ori > tile->mi_row_start);
   xd->left_available = (mi_col_ori > tile->mi_col_start);
 
   // R/D setup.
-  x->rddiv = cpi->rd.RDDIV;
   x->rdmult = cpi->rd.RDMULT;
 }
 
 static void set_segment_id_supertx(const AV1_COMP *const cpi,
                                    MACROBLOCK *const x, const int mi_row,
                                    const int mi_col, const BLOCK_SIZE bsize) {
   const AV1_COMMON *cm = &cpi->common;
   const struct segmentation *seg = &cm->seg;
@@ -534,16 +536,31 @@ static void set_ref_and_pred_mvs(MACROBL
     }
     if (compound_ref1_mode(mbmi->mode) == NEWMV) {
       int_mv this_mv = curr_ref_mv_stack[ref_mv_idx].comp_mv;
       clamp_mv_ref(&this_mv.as_mv, bw, bh, xd);
       mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0] = this_mv;
       mbmi->pred_mv[1] = this_mv;
       mi_pred_mv[1] = this_mv;
     }
+#if CONFIG_COMPOUND_SINGLEREF
+  } else if (is_inter_singleref_comp_mode(mbmi->mode)) {
+    // Special case: SR_NEAR_NEWMV uses 1 + mbmi->ref_mv_idx
+    // (like NEARMV) instead
+    if (mbmi->mode == SR_NEAR_NEWMV) ref_mv_idx += 1;
+
+    if (compound_ref0_mode(mbmi->mode) == NEWMV ||
+        compound_ref1_mode(mbmi->mode) == NEWMV) {
+      int_mv this_mv = curr_ref_mv_stack[ref_mv_idx].this_mv;
+      clamp_mv_ref(&this_mv.as_mv, bw, bh, xd);
+      mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0] = this_mv;
+      mbmi->pred_mv[0] = this_mv;
+      mi_pred_mv[0] = this_mv;
+    }
+#endif  // CONFIG_COMPOUND_SINGLEREF
   } else {
 #endif  // CONFIG_EXT_INTER
     if (mbmi->mode == NEWMV) {
       int i;
       for (i = 0; i < 1 + has_second_ref(mbmi); ++i) {
         int_mv this_mv = (i == 0) ? curr_ref_mv_stack[ref_mv_idx].this_mv
                                   : curr_ref_mv_stack[ref_mv_idx].comp_mv;
         clamp_mv_ref(&this_mv.as_mv, bw, bh, xd);
@@ -630,17 +647,16 @@ static void update_state(const AV1_COMP 
     p[i].eobs = ctx->eobs[i];
 #if CONFIG_LV_MAP
     p[i].txb_entropy_ctx = ctx->txb_entropy_ctx[i];
 #endif  // CONFIG_LV_MAP
   }
 #if CONFIG_PALETTE
   for (i = 0; i < 2; ++i) pd[i].color_index_map = ctx->color_index_map[i];
 #endif  // CONFIG_PALETTE
-
   // Restore the coding context of the MB to that that was in place
   // when the mode was picked for it
   for (y = 0; y < mi_height; y++)
     for (x_idx = 0; x_idx < mi_width; x_idx++)
       if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > x_idx &&
           (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) {
         xd->mi[x_idx + y * mis] = mi_addr;
       }
@@ -809,17 +825,16 @@ static void update_state_supertx(const A
     } else {
       // Otherwise just set the segment id based on the current segment map
       const uint8_t *const map =
           seg->update_map ? cpi->segmentation_map : cm->last_frame_seg_map;
       mi_addr->mbmi.segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
     }
     mi_addr->mbmi.segment_id_supertx = MAX_SEGMENTS;
   }
-
   // Restore the coding context of the MB to that that was in place
   // when the mode was picked for it
   for (y = 0; y < mi_height; y++)
     for (x_idx = 0; x_idx < mi_width; x_idx++)
       if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > x_idx &&
           (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) {
         xd->mi[x_idx + y * mis] = mi_addr;
       }
@@ -1142,17 +1157,17 @@ static void update_supertx_param_sb(cons
         update_supertx_param(td, &pc_tree->verticalb[i], best_tx, supertx_size);
       break;
 #endif  // CONFIG_EXT_PARTITION_TYPES
     default: assert(0);
   }
 }
 #endif  // CONFIG_SUPERTX
 
-#if CONFIG_MOTION_VAR && CONFIG_NCOBMC
+#if CONFIG_MOTION_VAR && (CONFIG_NCOBMC || CONFIG_NCOBMC_ADAPT_WEIGHT)
 static void set_mode_info_b(const AV1_COMP *const cpi,
                             const TileInfo *const tile, ThreadData *td,
                             int mi_row, int mi_col, BLOCK_SIZE bsize,
                             PICK_MODE_CONTEXT *ctx) {
   MACROBLOCK *const x = &td->mb;
   set_offsets(cpi, tile, x, mi_row, mi_col, bsize);
   update_state(cpi, td, ctx, mi_row, mi_col, bsize, 1);
 }
@@ -1289,22 +1304,34 @@ static void daala_dist_set_sub8x8_dst(MA
   struct macroblockd_plane *const pd = &xd->plane[0];
   const int dst_stride = pd->dst.stride;
   uint8_t *dst = pd->dst.buf;
 
   assert(bsize < BLOCK_8X8);
 
   if (bsize < BLOCK_8X8) {
     int i, j;
-    uint8_t *dst_sub8x8 = &dst8x8[((mi_row & 1) * 8 + (mi_col & 1)) << 2];
-
-    for (j = 0; j < bh; ++j)
-      for (i = 0; i < bw; ++i) {
-        dst_sub8x8[j * 8 + i] = dst[j * dst_stride + i];
-      }
+#if CONFIG_HIGHBITDEPTH
+    if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
+      uint16_t *dst8x8_16 = (uint16_t *)dst8x8;
+      uint16_t *dst_sub8x8 = &dst8x8_16[((mi_row & 1) * 8 + (mi_col & 1)) << 2];
+
+      for (j = 0; j < bh; ++j)
+        for (i = 0; i < bw; ++i)
+          dst_sub8x8[j * 8 + i] = CONVERT_TO_SHORTPTR(dst)[j * dst_stride + i];
+    } else {
+#endif
+      uint8_t *dst_sub8x8 = &dst8x8[((mi_row & 1) * 8 + (mi_col & 1)) << 2];
+
+      for (j = 0; j < bh; ++j)
+        for (i = 0; i < bw; ++i)
+          dst_sub8x8[j * 8 + i] = dst[j * dst_stride + i];
+#if CONFIG_HIGHBITDEPTH
+    }
+#endif
   }
 }
 #endif
 
 static void rd_pick_sb_modes(const AV1_COMP *const cpi, TileDataEnc *tile_data,
                              MACROBLOCK *const x, int mi_row, int mi_col,
                              RD_STATS *rd_cost,
 #if CONFIG_SUPERTX
@@ -1325,28 +1352,28 @@ static void rd_pick_sb_modes(const AV1_C
   int i, orig_rdmult;
 
   aom_clear_system_state();
 
 #if CONFIG_PVQ
   x->pvq_speed = 1;
   x->pvq_coded = 0;
 #endif
-#if CONFIG_CFL
-  // Don't store luma during RDO (we will store the best mode later).
-  x->cfl_store_y = 0;
-#endif
 
   set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize);
   mbmi = &xd->mi[0]->mbmi;
   mbmi->sb_type = bsize;
 #if CONFIG_RD_DEBUG
   mbmi->mi_row = mi_row;
   mbmi->mi_col = mi_col;
 #endif
+#if CONFIG_CFL
+  // Don't store luma during RDO. Only store luma when best luma is known
+  x->cfl_store_y = 0;
+#endif
 #if CONFIG_SUPERTX
   // We set tx_size here as skip blocks would otherwise not set it.
   // tx_size needs to be set at this point as supertx_enable in
   // write_modes_sb is computed based on this, and if the garbage in memory
   // just happens to be the supertx_size, then the packer will code this
   // block as a supertx block, even if rdopt did not pick it as such.
   mbmi->tx_size = max_txsize_lookup[bsize];
 #endif
@@ -1537,16 +1564,17 @@ static void update_stats(const AV1_COMMO
 #endif
   }
 #else
   (void)mi_row;
   (void)mi_col;
 #endif
   if (!frame_is_intra_only(cm)) {
     FRAME_COUNTS *const counts = td->counts;
+    RD_COUNTS *rdc = &td->rd_counts;
     const int inter_block = is_inter_block(mbmi);
     const int seg_ref_active =
         segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_REF_FRAME);
     if (!seg_ref_active) {
 #if CONFIG_SUPERTX
       if (!supertx_enabled)
 #endif
         counts->intra_inter[av1_get_intra_inter_context(xd)][inter_block]++;
@@ -1555,45 +1583,76 @@ static void update_stats(const AV1_COMMO
       // the reference frame counts used to work out probabilities.
       if (inter_block) {
         const MV_REFERENCE_FRAME ref0 = mbmi->ref_frame[0];
 #if CONFIG_EXT_REFS
         const MV_REFERENCE_FRAME ref1 = mbmi->ref_frame[1];
 #endif  // CONFIG_EXT_REFS
 
         if (cm->reference_mode == REFERENCE_MODE_SELECT) {
+          if (has_second_ref(mbmi))
+            // This flag is also updated for 4x4 blocks
+            rdc->compound_ref_used_flag = 1;
+          else
+            // This flag is also updated for 4x4 blocks
+            rdc->single_ref_used_flag = 1;
 #if !SUB8X8_COMP_REF
           if (mbmi->sb_type != BLOCK_4X4)
             counts->comp_inter[av1_get_reference_mode_context(cm, xd)]
                               [has_second_ref(mbmi)]++;
 #else
           counts->comp_inter[av1_get_reference_mode_context(cm, xd)]
                             [has_second_ref(mbmi)]++;
 #endif
         }
 
         if (has_second_ref(mbmi)) {
-#if CONFIG_EXT_REFS
-          const int bit = (ref0 == GOLDEN_FRAME || ref0 == LAST3_FRAME);
-
-          counts->comp_ref[av1_get_pred_context_comp_ref_p(cm, xd)][0][bit]++;
-          if (!bit) {
-            counts->comp_ref[av1_get_pred_context_comp_ref_p1(cm, xd)][1]
-                            [ref0 == LAST_FRAME]++;
+#if CONFIG_EXT_COMP_REFS
+          const COMP_REFERENCE_TYPE comp_ref_type = has_uni_comp_refs(mbmi)
+                                                        ? UNIDIR_COMP_REFERENCE
+                                                        : BIDIR_COMP_REFERENCE;
+#if !USE_UNI_COMP_REFS
+          // TODO(zoeliu): Temporarily turn off uni-directional comp refs
+          assert(comp_ref_type == BIDIR_COMP_REFERENCE);
+#endif  // !USE_UNI_COMP_REFS
+          counts->comp_ref_type[av1_get_comp_reference_type_context(cm, xd)]
+                               [comp_ref_type]++;
+
+          if (comp_ref_type == UNIDIR_COMP_REFERENCE) {
+            const int bit = (ref0 == BWDREF_FRAME);
+            counts->uni_comp_ref[av1_get_pred_context_uni_comp_ref_p(cm, xd)][0]
+                                [bit]++;
+            if (!bit) {
+              const int bit1 = (ref1 == GOLDEN_FRAME);
+              counts->uni_comp_ref[av1_get_pred_context_uni_comp_ref_p1(cm, xd)]
+                                  [1][bit1]++;
+            }
           } else {
-            counts->comp_ref[av1_get_pred_context_comp_ref_p2(cm, xd)][2]
-                            [ref0 == GOLDEN_FRAME]++;
-          }
-
-          counts->comp_bwdref[av1_get_pred_context_comp_bwdref_p(cm, xd)][0]
-                             [ref1 == ALTREF_FRAME]++;
-#else
+#endif  // CONFIG_EXT_COMP_REFS
+#if CONFIG_EXT_REFS
+            const int bit = (ref0 == GOLDEN_FRAME || ref0 == LAST3_FRAME);
+
+            counts->comp_ref[av1_get_pred_context_comp_ref_p(cm, xd)][0][bit]++;
+            if (!bit) {
+              counts->comp_ref[av1_get_pred_context_comp_ref_p1(cm, xd)][1]
+                              [ref0 == LAST_FRAME]++;
+            } else {
+              counts->comp_ref[av1_get_pred_context_comp_ref_p2(cm, xd)][2]
+                              [ref0 == GOLDEN_FRAME]++;
+            }
+
+            counts->comp_bwdref[av1_get_pred_context_comp_bwdref_p(cm, xd)][0]
+                               [ref1 == ALTREF_FRAME]++;
+#else   // !CONFIG_EXT_REFS
           counts->comp_ref[av1_get_pred_context_comp_ref_p(cm, xd)][0]
                           [ref0 == GOLDEN_FRAME]++;
 #endif  // CONFIG_EXT_REFS
+#if CONFIG_EXT_COMP_REFS
+          }
+#endif  // CONFIG_EXT_COMP_REFS
         } else {
 #if CONFIG_EXT_REFS
           const int bit = (ref0 == ALTREF_FRAME || ref0 == BWDREF_FRAME);
 
           counts->single_ref[av1_get_pred_context_single_ref_p1(xd)][0][bit]++;
           if (bit) {
             counts->single_ref[av1_get_pred_context_single_ref_p2(xd)][1]
                               [ref0 != BWDREF_FRAME]++;
@@ -1604,50 +1663,67 @@ static void update_stats(const AV1_COMMO
             if (!bit1) {
               counts->single_ref[av1_get_pred_context_single_ref_p4(xd)][3]
                                 [ref0 != LAST_FRAME]++;
             } else {
               counts->single_ref[av1_get_pred_context_single_ref_p5(xd)][4]
                                 [ref0 != LAST3_FRAME]++;
             }
           }
-#else
+#else   // !CONFIG_EXT_REFS
           counts->single_ref[av1_get_pred_context_single_ref_p1(xd)][0]
                             [ref0 != LAST_FRAME]++;
           if (ref0 != LAST_FRAME) {
             counts->single_ref[av1_get_pred_context_single_ref_p2(xd)][1]
                               [ref0 != GOLDEN_FRAME]++;
           }
 #endif  // CONFIG_EXT_REFS
         }
 
-#if CONFIG_EXT_INTER && CONFIG_INTERINTRA
+#if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+        if (!has_second_ref(mbmi))
+          counts->comp_inter_mode[av1_get_inter_mode_context(xd)]
+                                 [is_inter_singleref_comp_mode(mbmi->mode)]++;
+#endif  // CONFIG_COMPOUND_SINGLEREF
+
+#if CONFIG_INTERINTRA
         if (cm->reference_mode != COMPOUND_REFERENCE &&
 #if CONFIG_SUPERTX
             !supertx_enabled &&
 #endif
             cm->allow_interintra_compound && is_interintra_allowed(mbmi)) {
           const int bsize_group = size_group_lookup[bsize];
           if (mbmi->ref_frame[1] == INTRA_FRAME) {
             counts->interintra[bsize_group][1]++;
             counts->interintra_mode[bsize_group][mbmi->interintra_mode]++;
             if (is_interintra_wedge_used(bsize))
               counts->wedge_interintra[bsize][mbmi->use_wedge_interintra]++;
           } else {
             counts->interintra[bsize_group][0]++;
           }
         }
-#endif  // CONFIG_EXT_INTER && CONFIG_INTERINTRA
+#endif  // CONFIG_INTERINTRA
+#endif  // CONFIG_EXT_INTER
 
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+        const MOTION_MODE motion_allowed =
+            motion_mode_allowed_wrapper(0,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                        0, xd->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                        mi);
+#else
         const MOTION_MODE motion_allowed = motion_mode_allowed(
 #if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
             0, xd->global_motion,
 #endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
             mi);
+#endif  // CONFIG_NCOBMC_ADAPT_WEIGHT
 #if CONFIG_SUPERTX
         if (!supertx_enabled)
 #endif  // CONFIG_SUPERTX
 #if CONFIG_EXT_INTER
           if (mbmi->ref_frame[1] != INTRA_FRAME)
 #endif  // CONFIG_EXT_INTER
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
           {
@@ -1655,21 +1731,38 @@ static void update_stats(const AV1_COMMO
               counts->motion_mode[mbmi->sb_type][mbmi->motion_mode]++;
             else if (motion_allowed == OBMC_CAUSAL)
               counts->obmc[mbmi->sb_type][mbmi->motion_mode == OBMC_CAUSAL]++;
           }
 #else
         if (motion_allowed > SIMPLE_TRANSLATION)
           counts->motion_mode[mbmi->sb_type][mbmi->motion_mode]++;
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
+
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+        if (motion_allowed == NCOBMC_ADAPT_WEIGHT) {
+          ADAPT_OVERLAP_BLOCK ao_block =
+              adapt_overlap_block_lookup[mbmi->sb_type];
+          ++counts->ncobmc_mode[ao_block][mbmi->ncobmc_mode[0]];
+          if (mi_size_wide[mbmi->sb_type] != mi_size_high[mbmi->sb_type]) {
+            ++counts->ncobmc_mode[ao_block][mbmi->ncobmc_mode[1]];
+          }
+        }
+#endif
+
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
 #if CONFIG_EXT_INTER
-        if (cm->reference_mode != SINGLE_REFERENCE &&
+        if (
+#if CONFIG_COMPOUND_SINGLEREF
+            is_inter_anyref_comp_mode(mbmi->mode)
+#else   // !CONFIG_COMPOUND_SINGLEREF
+            cm->reference_mode != SINGLE_REFERENCE &&
             is_inter_compound_mode(mbmi->mode)
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
             && mbmi->motion_mode == SIMPLE_TRANSLATION
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
             ) {
           counts->compound_interinter[bsize][mbmi->interinter_compound_type]++;
         }
 #endif  // CONFIG_EXT_INTER
       }
@@ -1678,30 +1771,41 @@ static void update_stats(const AV1_COMMO
     if (inter_block &&
         !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
       int16_t mode_ctx;
       const PREDICTION_MODE mode = mbmi->mode;
 #if CONFIG_EXT_INTER
       if (has_second_ref(mbmi)) {
         mode_ctx = mbmi_ext->compound_mode_context[mbmi->ref_frame[0]];
         ++counts->inter_compound_mode[mode_ctx][INTER_COMPOUND_OFFSET(mode)];
+#if CONFIG_COMPOUND_SINGLEREF
+      } else if (is_inter_singleref_comp_mode(mode)) {
+        mode_ctx = mbmi_ext->compound_mode_context[mbmi->ref_frame[0]];
+        ++counts->inter_singleref_comp_mode[mode_ctx]
+                                           [INTER_SINGLEREF_COMP_OFFSET(mode)];
+#endif  // CONFIG_COMPOUND_SINGLEREF
       } else {
 #endif  // CONFIG_EXT_INTER
         mode_ctx = av1_mode_context_analyzer(mbmi_ext->mode_context,
                                              mbmi->ref_frame, bsize, -1);
         update_inter_mode_stats(counts, mode, mode_ctx);
 #if CONFIG_EXT_INTER
       }
 #endif  // CONFIG_EXT_INTER
 
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+      if (mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV ||
+          mbmi->mode == SR_NEW_NEWMV) {
+#else   // !CONFIG_COMPOUND_SINGLEREF
       if (mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV) {
-#else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+#else   // !CONFIG_EXT_INTER
       if (mbmi->mode == NEWMV) {
-#endif
+#endif  // CONFIG_EXT_INTER
         uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
         int idx;
 
         for (idx = 0; idx < 2; ++idx) {
           if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1) {
             uint8_t drl_ctx =
                 av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx);
             ++counts->drl_mode[drl_ctx][mbmi->ref_mv_idx != idx];
@@ -1928,16 +2032,21 @@ static void encode_sb(const AV1_COMP *co
   const int unify_bsize = 1;
 #else
   const int unify_bsize = 0;
   assert(bsize >= BLOCK_8X8);
 #endif
 
   if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return;
 
+#if CONFIG_SPEED_REFS
+  // First scanning pass of an SB is dry run only.
+  if (cpi->sb_scanning_pass_idx == 0) assert(dry_run == DRY_RUN_NORMAL);
+#endif  // CONFIG_SPEED_REFS
+
   if (!dry_run && ctx >= 0) td->counts->partition[ctx][partition]++;
 
 #if CONFIG_SUPERTX
   if (!frame_is_intra_only(cm) && bsize <= MAX_SUPERTX_BLOCK_SIZE &&
       partition != PARTITION_NONE && !xd->lossless[0]) {
     int supertx_enabled;
     TX_SIZE supertx_size = max_txsize_lookup[bsize];
     supertx_enabled = check_supertx_sb(bsize, supertx_size, pc_tree);
@@ -2297,18 +2406,17 @@ static void rd_use_partition(AV1_COMP *c
 #endif
 #if CONFIG_EXT_PARTITION_TYPES
                        PARTITION_NONE,
 #endif
                        bsize, ctx_none, INT64_MAX);
 
       if (none_rdc.rate < INT_MAX) {
         none_rdc.rate += cpi->partition_cost[pl][PARTITION_NONE];
-        none_rdc.rdcost =
-            RDCOST(x->rdmult, x->rddiv, none_rdc.rate, none_rdc.dist);
+        none_rdc.rdcost = RDCOST(x->rdmult, none_rdc.rate, none_rdc.dist);
 #if CONFIG_SUPERTX
         none_rate_nocoef += cpi->partition_cost[pl][PARTITION_NONE];
 #endif
       }
 
 #if !CONFIG_PVQ
       restore_context(x, &x_ctx, mi_row, mi_col, bsize);
 #else
@@ -2476,17 +2584,17 @@ static void rd_use_partition(AV1_COMP *c
     case PARTITION_HORZ_B: assert(0 && "Cannot handle extended partiton types");
 #endif  //  CONFIG_EXT_PARTITION_TYPES
     default: assert(0); break;
   }
 
   if (last_part_rdc.rate < INT_MAX) {
     last_part_rdc.rate += cpi->partition_cost[pl][partition];
     last_part_rdc.rdcost =
-        RDCOST(x->rdmult, x->rddiv, last_part_rdc.rate, last_part_rdc.dist);
+        RDCOST(x->rdmult, last_part_rdc.rate, last_part_rdc.dist);
 #if CONFIG_SUPERTX
     last_part_rate_nocoef += cpi->partition_cost[pl][partition];
 #endif
   }
 
   if (do_partition_search && cpi->sf.adjust_partitioning_from_last_frame &&
       cpi->sf.partition_search_type == SEARCH_PARTITION &&
       partition != PARTITION_SPLIT && bsize > BLOCK_8X8 &&
@@ -2560,18 +2668,17 @@ static void rd_use_partition(AV1_COMP *c
 
       chosen_rdc.rate += cpi->partition_cost[pl][PARTITION_NONE];
 #if CONFIG_SUPERTX
       chosen_rate_nocoef += cpi->partition_cost[pl][PARTITION_SPLIT];
 #endif
     }
     if (chosen_rdc.rate < INT_MAX) {
       chosen_rdc.rate += cpi->partition_cost[pl][PARTITION_SPLIT];
-      chosen_rdc.rdcost =
-          RDCOST(x->rdmult, x->rddiv, chosen_rdc.rate, chosen_rdc.dist);
+      chosen_rdc.rdcost = RDCOST(x->rdmult, chosen_rdc.rate, chosen_rdc.dist);
 #if CONFIG_SUPERTX
       chosen_rate_nocoef += cpi->partition_cost[pl][PARTITION_NONE];
 #endif
     }
   }
 
   // If last_part is better set the partitioning to that.
   if (last_part_rdc.rdcost < chosen_rdc.rdcost) {
@@ -2620,46 +2727,46 @@ static void rd_use_partition(AV1_COMP *c
   *dist = chosen_rdc.dist;
 #if CONFIG_SUPERTX
   *rate_nocoef = chosen_rate_nocoef;
 #endif
 }
 
 /* clang-format off */
 static const BLOCK_SIZE min_partition_size[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   BLOCK_2X2,   BLOCK_2X2,   BLOCK_2X2,    //    2x2,    2x4,     4x2
 #endif
                             BLOCK_4X4,    //                     4x4
   BLOCK_4X4,   BLOCK_4X4,   BLOCK_4X4,    //    4x8,    8x4,     8x8
   BLOCK_4X4,   BLOCK_4X4,   BLOCK_8X8,    //   8x16,   16x8,   16x16
   BLOCK_8X8,   BLOCK_8X8,   BLOCK_16X16,  //  16x32,  32x16,   32x32
   BLOCK_16X16, BLOCK_16X16, BLOCK_16X16,  //  32x64,  64x32,   64x64
 #if CONFIG_EXT_PARTITION
   BLOCK_16X16, BLOCK_16X16, BLOCK_16X16   // 64x128, 128x64, 128x128
 #endif  // CONFIG_EXT_PARTITION
 };
 
 static const BLOCK_SIZE max_partition_size[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   BLOCK_4X4,     BLOCK_4X4,       BLOCK_4X4,    //    2x2,    2x4,     4x2
 #endif
                                   BLOCK_8X8,    //                     4x4
   BLOCK_16X16,   BLOCK_16X16,   BLOCK_16X16,    //    4x8,    8x4,     8x8
   BLOCK_32X32,   BLOCK_32X32,   BLOCK_32X32,    //   8x16,   16x8,   16x16
   BLOCK_64X64,   BLOCK_64X64,   BLOCK_64X64,    //  16x32,  32x16,   32x32
   BLOCK_LARGEST, BLOCK_LARGEST, BLOCK_LARGEST,  //  32x64,  64x32,   64x64
 #if CONFIG_EXT_PARTITION
   BLOCK_LARGEST, BLOCK_LARGEST, BLOCK_LARGEST   // 64x128, 128x64, 128x128
 #endif  // CONFIG_EXT_PARTITION
 };
 
 // Next square block size less or equal than current block size.
 static const BLOCK_SIZE next_square_size[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   BLOCK_2X2,   BLOCK_2X2,     BLOCK_2X2,    //    2x2,    2x4,     4x2
 #endif
                               BLOCK_4X4,    //                     4x4
   BLOCK_4X4,   BLOCK_4X4,     BLOCK_8X8,    //    4x8,    8x4,     8x8
   BLOCK_8X8,   BLOCK_8X8,     BLOCK_16X16,  //   8x16,   16x8,   16x16
   BLOCK_16X16, BLOCK_16X16,   BLOCK_32X32,  //  16x32,  32x16,   32x32
   BLOCK_32X32, BLOCK_32X32,   BLOCK_64X64,  //  32x64,  64x32,   64x64
 #if CONFIG_EXT_PARTITION
@@ -3050,34 +3157,32 @@ static void rd_test_partition3(
       if (supertx_allowed && !abort_flag && sum_rdc.rdcost < INT64_MAX) {
         TX_SIZE supertx_size = max_txsize_lookup[bsize];
         const PARTITION_TYPE best_partition = pc_tree->partitioning;
         pc_tree->partitioning = partition;
         sum_rdc.rate += av1_cost_bit(
             cm->fc->supertx_prob[partition_supertx_context_lookup[partition]]
                                 [supertx_size],
             0);
-        sum_rdc.rdcost =
-            RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+        sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
 
         if (!check_intra_sb(cpi, tile_info, mi_row, mi_col, bsize, pc_tree)) {
           TX_TYPE best_tx = DCT_DCT;
           RD_STATS tmp_rdc = { sum_rate_nocoef, 0, 0 };
 
           restore_context(x, x_ctx, mi_row, mi_col, bsize);
 
           rd_supertx_sb(cpi, td, tile_info, mi_row, mi_col, bsize,
                         &tmp_rdc.rate, &tmp_rdc.dist, &best_tx, pc_tree);
 
           tmp_rdc.rate += av1_cost_bit(
               cm->fc->supertx_prob[partition_supertx_context_lookup[partition]]
                                   [supertx_size],
               1);
-          tmp_rdc.rdcost =
-              RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist);
+          tmp_rdc.rdcost = RDCOST(x->rdmult, tmp_rdc.rate, tmp_rdc.dist);
           if (tmp_rdc.rdcost < sum_rdc.rdcost) {
             sum_rdc = tmp_rdc;
             update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx,
                                     supertx_size, pc_tree);
           }
         }
 
         pc_tree->partitioning = best_partition;
@@ -3086,18 +3191,17 @@ static void rd_test_partition3(
 
       if (sum_rdc.rdcost < best_rdc->rdcost) {
         int pl = partition_plane_context(xd, mi_row, mi_col,
 #if CONFIG_UNPOISON_PARTITION_CTX
                                          has_rows, has_cols,
 #endif
                                          bsize);
         sum_rdc.rate += cpi->partition_cost[pl][partition];
-        sum_rdc.rdcost =
-            RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+        sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
 #if CONFIG_SUPERTX
         sum_rate_nocoef += cpi->partition_cost[pl][partition];
 #endif
         if (sum_rdc.rdcost < best_rdc->rdcost) {
 #if CONFIG_SUPERTX
           *best_rate_nocoef = sum_rate_nocoef;
           assert(*best_rate_nocoef >= 0);
 #endif
@@ -3156,17 +3260,17 @@ static void rd_pick_partition(const AV1_
                                          has_rows, has_cols,
 #endif
                                          bsize);
 #endif  // CONFIG_CB4X4
   const int *partition_cost = cpi->partition_cost[pl];
 #if CONFIG_SUPERTX
   int this_rate_nocoef, sum_rate_nocoef = 0, best_rate_nocoef = INT_MAX;
   int abort_flag;
-  const int supertx_allowed = !frame_is_intra_only(cm) &&
+  const int supertx_allowed = !frame_is_intra_only(cm) && bsize >= BLOCK_8X8 &&
                               bsize <= MAX_SUPERTX_BLOCK_SIZE &&
                               !xd->lossless[0];
 #endif  // CONFIG_SUPERTX
 
   int do_rectangular_split = 1;
 #if CONFIG_EXT_PARTITION_TYPES
   BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT);
 #endif
@@ -3336,31 +3440,41 @@ static void rd_pick_partition(const AV1_
     }
 
     if (none_complexity > complexity_16x16_blocks_threshold[bsize]) {
       partition_none_allowed = 0;
     }
   }
 #endif
 
+#if CONFIG_SPEED_REFS
+  if (cpi->sb_scanning_pass_idx == 0) {
+    // NOTE: For the 1st pass of scanning, check all the subblocks of equal size
+    //       only.
+    partition_none_allowed = (bsize == MIN_SPEED_REFS_BLKSIZE);
+    partition_horz_allowed = 0;
+    partition_vert_allowed = 0;
+    do_square_split = (bsize > MIN_SPEED_REFS_BLKSIZE);
+  }
+#endif  // CONFIG_SPEED_REFS
+
   // PARTITION_NONE
   if (partition_none_allowed) {
     rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &this_rdc,
 #if CONFIG_SUPERTX
                      &this_rate_nocoef,
 #endif
 #if CONFIG_EXT_PARTITION_TYPES
                      PARTITION_NONE,
 #endif
                      bsize, ctx_none, best_rdc.rdcost);
     if (this_rdc.rate != INT_MAX) {
       if (bsize_at_least_8x8) {
         this_rdc.rate += partition_cost[PARTITION_NONE];
-        this_rdc.rdcost =
-            RDCOST(x->rdmult, x->rddiv, this_rdc.rate, this_rdc.dist);
+        this_rdc.rdcost = RDCOST(x->rdmult, this_rdc.rate, this_rdc.dist);
 #if CONFIG_SUPERTX
         this_rate_nocoef += partition_cost[PARTITION_NONE];
 #endif
       }
 
       if (this_rdc.rdcost < best_rdc.rdcost) {
         // Adjust dist breakout threshold according to the partition size.
         const int64_t dist_breakout_thr =
@@ -3489,36 +3603,34 @@ static void rd_pick_partition(const AV1_
         const PARTITION_TYPE best_partition = pc_tree->partitioning;
 
         pc_tree->partitioning = PARTITION_SPLIT;
 
         sum_rdc.rate += av1_cost_bit(
             cm->fc->supertx_prob[partition_supertx_context_lookup
                                      [PARTITION_SPLIT]][supertx_size],
             0);
-        sum_rdc.rdcost =
-            RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+        sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
 
         if (is_inter_mode(pc_tree->leaf_split[0]->mic.mbmi.mode)) {
           TX_TYPE best_tx = DCT_DCT;
           RD_STATS tmp_rdc;
           av1_init_rd_stats(&tmp_rdc);
           tmp_rdc.rate = sum_rate_nocoef;
 
           restore_context(x, &x_ctx, mi_row, mi_col, bsize);
 
           rd_supertx_sb(cpi, td, tile_info, mi_row, mi_col, bsize,
                         &tmp_rdc.rate, &tmp_rdc.dist, &best_tx, pc_tree);
 
           tmp_rdc.rate += av1_cost_bit(
               cm->fc->supertx_prob[partition_supertx_context_lookup
                                        [PARTITION_SPLIT]][supertx_size],
               1);
-          tmp_rdc.rdcost =
-              RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist);
+          tmp_rdc.rdcost = RDCOST(x->rdmult, tmp_rdc.rate, tmp_rdc.dist);
           if (tmp_rdc.rdcost < sum_rdc.rdcost) {
             sum_rdc = tmp_rdc;
             update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx,
                                     supertx_size, pc_tree);
           }
         }
 
         pc_tree->partitioning = best_partition;
@@ -3546,98 +3658,117 @@ static void rd_pick_partition(const AV1_
                           mi_col + x_idx, subsize, &this_rdc, &this_rate_nocoef,
                           INT64_MAX - sum_rdc.rdcost, pc_tree->split[idx]);
 #else
         rd_pick_partition(
             cpi, td, tile_data, tp, mi_row + y_idx, mi_col + x_idx, subsize,
             &this_rdc, best_rdc.rdcost - sum_rdc.rdcost, pc_tree->split[idx]);
 #endif  // CONFIG_SUPERTX
 
+#if CONFIG_DAALA_DIST && CONFIG_CB4X4
+        if (bsize == BLOCK_8X8 && this_rdc.rate != INT_MAX) {
+          assert(this_rdc.dist_y < INT64_MAX);
+        }
+#endif
         if (this_rdc.rate == INT_MAX) {
           sum_rdc.rdcost = INT64_MAX;
 #if CONFIG_SUPERTX
           sum_rate_nocoef = INT_MAX;
 #endif  // CONFIG_SUPERTX
           break;
         } else {
           sum_rdc.rate += this_rdc.rate;
           sum_rdc.dist += this_rdc.dist;
           sum_rdc.rdcost += this_rdc.rdcost;
 #if CONFIG_SUPERTX
           sum_rate_nocoef += this_rate_nocoef;
 #endif  // CONFIG_SUPERTX
 #if CONFIG_DAALA_DIST && CONFIG_CB4X4
-          sum_rdc.dist_y += this_rdc.dist_y;
+          if (bsize == BLOCK_8X8) {
+            assert(this_rdc.dist_y < INT64_MAX);
+            sum_rdc.dist_y += this_rdc.dist_y;
+          }
 #endif
         }
       }
       reached_last_index = (idx == 4);
 
 #if CONFIG_DAALA_DIST && CONFIG_CB4X4
       if (reached_last_index && sum_rdc.rdcost != INT64_MAX &&
           bsize == BLOCK_8X8) {
         int use_activity_masking = 0;
         int64_t daala_dist;
         const int src_stride = x->plane[0].src.stride;
-        daala_dist = av1_daala_dist(x->plane[0].src.buf - 4 * src_stride - 4,
-                                    src_stride, x->decoded_8x8, 8, 8, 8, 1,
-                                    use_activity_masking, x->qindex)
-                     << 4;
+        uint8_t *decoded_8x8;
+
+#if CONFIG_HIGHBITDEPTH
+        if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
+          decoded_8x8 = CONVERT_TO_BYTEPTR(x->decoded_8x8);
+        else
+#endif
+          decoded_8x8 = (uint8_t *)x->decoded_8x8;
+
+#if CONFIG_PVQ
+        use_activity_masking = x->daala_enc.use_activity_masking;
+#endif
+        daala_dist =
+            av1_daala_dist(xd, x->plane[0].src.buf - 4 * src_stride - 4,
+                           src_stride, decoded_8x8, 8, 8, 8, 8, 8, 1,
+                           use_activity_masking, x->qindex)
+            << 4;
+        assert(sum_rdc.dist_y < INT64_MAX);
         sum_rdc.dist = sum_rdc.dist - sum_rdc.dist_y + daala_dist;
-        sum_rdc.rdcost =
-            RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+        sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
       }
 #endif  // CONFIG_DAALA_DIST && CONFIG_CB4X4
 
 #if CONFIG_SUPERTX
       if (supertx_allowed && sum_rdc.rdcost < INT64_MAX && reached_last_index) {
         TX_SIZE supertx_size = max_txsize_lookup[bsize];
         const PARTITION_TYPE best_partition = pc_tree->partitioning;
 
         pc_tree->partitioning = PARTITION_SPLIT;
 
         sum_rdc.rate += av1_cost_bit(
             cm->fc->supertx_prob[partition_supertx_context_lookup
                                      [PARTITION_SPLIT]][supertx_size],
             0);
-        sum_rdc.rdcost =
-            RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+        sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
 
         if (!check_intra_sb(cpi, tile_info, mi_row, mi_col, bsize, pc_tree)) {
           TX_TYPE best_tx = DCT_DCT;
           RD_STATS tmp_rdc;
           av1_init_rd_stats(&tmp_rdc);
           tmp_rdc.rate = sum_rate_nocoef;
 
           restore_context(x, &x_ctx, mi_row, mi_col, bsize);
 
           rd_supertx_sb(cpi, td, tile_info, mi_row, mi_col, bsize,
                         &tmp_rdc.rate, &tmp_rdc.dist, &best_tx, pc_tree);
 
           tmp_rdc.rate += av1_cost_bit(
               cm->fc->supertx_prob[partition_supertx_context_lookup
                                        [PARTITION_SPLIT]][supertx_size],
               1);
-          tmp_rdc.rdcost =
-              RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist);
+          tmp_rdc.rdcost = RDCOST(x->rdmult, tmp_rdc.rate, tmp_rdc.dist);
           if (tmp_rdc.rdcost < sum_rdc.rdcost) {
             sum_rdc = tmp_rdc;
             update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx,
                                     supertx_size, pc_tree);
           }
         }
 
         pc_tree->partitioning = best_partition;
       }
 #endif  // CONFIG_SUPERTX
     }
 
     if (reached_last_index && sum_rdc.rdcost < best_rdc.rdcost) {
       sum_rdc.rate += partition_cost[PARTITION_SPLIT];
-      sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+      sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
 #if CONFIG_SUPERTX
       sum_rate_nocoef += partition_cost[PARTITION_SPLIT];
 #endif  // CONFIG_SUPERTX
 
       if (sum_rdc.rdcost < best_rdc.rdcost) {
         best_rdc = sum_rdc;
 #if CONFIG_SUPERTX
         best_rate_nocoef = sum_rate_nocoef;
@@ -3750,39 +3881,50 @@ static void rd_pick_partition(const AV1_
         sum_rdc.dist_y += this_rdc.dist_y;
 #endif
       }
 #if CONFIG_DAALA_DIST && CONFIG_CB4X4
       if (sum_rdc.rdcost != INT64_MAX && bsize == BLOCK_8X8) {
         int use_activity_masking = 0;
         int64_t daala_dist;
         const int src_stride = x->plane[0].src.stride;
-        daala_dist = av1_daala_dist(x->plane[0].src.buf - 4 * src_stride,
-                                    src_stride, x->decoded_8x8, 8, 8, 8, 1,
+        uint8_t *decoded_8x8;
+
+#if CONFIG_HIGHBITDEPTH
+        if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
+          decoded_8x8 = CONVERT_TO_BYTEPTR(x->decoded_8x8);
+        else
+#endif
+          decoded_8x8 = (uint8_t *)x->decoded_8x8;
+
+#if CONFIG_PVQ
+        use_activity_masking = x->daala_enc.use_activity_masking;
+#endif
+        daala_dist = av1_daala_dist(xd, x->plane[0].src.buf - 4 * src_stride,
+                                    src_stride, decoded_8x8, 8, 8, 8, 8, 8, 1,
                                     use_activity_masking, x->qindex)
                      << 4;
         sum_rdc.dist = sum_rdc.dist - sum_rdc.dist_y + daala_dist;
-        sum_rdc.rdcost =
-            RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+        sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
       }
 #endif  // CONFIG_DAALA_DIST && CONFIG_CB4X4
     }
 
 #if CONFIG_SUPERTX
     if (supertx_allowed && sum_rdc.rdcost < INT64_MAX && !abort_flag) {
       TX_SIZE supertx_size = max_txsize_lookup[bsize];
       const PARTITION_TYPE best_partition = pc_tree->partitioning;
 
       pc_tree->partitioning = PARTITION_HORZ;
 
       sum_rdc.rate += av1_cost_bit(
           cm->fc->supertx_prob[partition_supertx_context_lookup[PARTITION_HORZ]]
                               [supertx_size],
           0);
-      sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+      sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
 
       if (!check_intra_sb(cpi, tile_info, mi_row, mi_col, bsize, pc_tree)) {
         TX_TYPE best_tx = DCT_DCT;
         RD_STATS tmp_rdc;
         av1_init_rd_stats(&tmp_rdc);
         tmp_rdc.rate = sum_rate_nocoef;
 
         restore_context(x, &x_ctx, mi_row, mi_col, bsize);
@@ -3790,32 +3932,31 @@ static void rd_pick_partition(const AV1_
         rd_supertx_sb(cpi, td, tile_info, mi_row, mi_col, bsize, &tmp_rdc.rate,
                       &tmp_rdc.dist, &best_tx, pc_tree);
 
         tmp_rdc.rate += av1_cost_bit(
             cm->fc
                 ->supertx_prob[partition_supertx_context_lookup[PARTITION_HORZ]]
                               [supertx_size],
             1);
-        tmp_rdc.rdcost =
-            RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist);
+        tmp_rdc.rdcost = RDCOST(x->rdmult, tmp_rdc.rate, tmp_rdc.dist);
         if (tmp_rdc.rdcost < sum_rdc.rdcost) {
           sum_rdc = tmp_rdc;
           update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx,
                                   supertx_size, pc_tree);
         }
       }
 
       pc_tree->partitioning = best_partition;
     }
 #endif  // CONFIG_SUPERTX
 
     if (sum_rdc.rdcost < best_rdc.rdcost) {
       sum_rdc.rate += partition_cost[PARTITION_HORZ];
-      sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+      sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
 #if CONFIG_SUPERTX
       sum_rate_nocoef += partition_cost[PARTITION_HORZ];
 #endif  // CONFIG_SUPERTX
       if (sum_rdc.rdcost < best_rdc.rdcost) {
         best_rdc = sum_rdc;
 #if CONFIG_SUPERTX
         best_rate_nocoef = sum_rate_nocoef;
         assert(best_rate_nocoef >= 0);
@@ -3924,38 +4065,49 @@ static void rd_pick_partition(const AV1_
         sum_rdc.dist_y += this_rdc.dist_y;
 #endif
       }
 #if CONFIG_DAALA_DIST && CONFIG_CB4X4
       if (sum_rdc.rdcost != INT64_MAX && bsize == BLOCK_8X8) {
         int use_activity_masking = 0;
         int64_t daala_dist;
         const int src_stride = x->plane[0].src.stride;
+        uint8_t *decoded_8x8;
+
+#if CONFIG_HIGHBITDEPTH
+        if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
+          decoded_8x8 = CONVERT_TO_BYTEPTR(x->decoded_8x8);
+        else
+#endif
+          decoded_8x8 = (uint8_t *)x->decoded_8x8;
+
+#if CONFIG_PVQ
+        use_activity_masking = x->daala_enc.use_activity_masking;
+#endif
         daala_dist =
-            av1_daala_dist(x->plane[0].src.buf - 4, src_stride, x->decoded_8x8,
-                           8, 8, 8, 1, use_activity_masking, x->qindex)
+            av1_daala_dist(xd, x->plane[0].src.buf - 4, src_stride, decoded_8x8,
+                           8, 8, 8, 8, 8, 1, use_activity_masking, x->qindex)
             << 4;
         sum_rdc.dist = sum_rdc.dist - sum_rdc.dist_y + daala_dist;
-        sum_rdc.rdcost =
-            RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+        sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
       }
 #endif  // CONFIG_DAALA_DIST && CONFIG_CB4X4
     }
 #if CONFIG_SUPERTX
     if (supertx_allowed && sum_rdc.rdcost < INT64_MAX && !abort_flag) {
       TX_SIZE supertx_size = max_txsize_lookup[bsize];
       const PARTITION_TYPE best_partition = pc_tree->partitioning;
 
       pc_tree->partitioning = PARTITION_VERT;
 
       sum_rdc.rate += av1_cost_bit(
           cm->fc->supertx_prob[partition_supertx_context_lookup[PARTITION_VERT]]
                               [supertx_size],
           0);
-      sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+      sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
 
       if (!check_intra_sb(cpi, tile_info, mi_row, mi_col, bsize, pc_tree)) {
         TX_TYPE best_tx = DCT_DCT;
         RD_STATS tmp_rdc;
         av1_init_rd_stats(&tmp_rdc);
         tmp_rdc.rate = sum_rate_nocoef;
 
         restore_context(x, &x_ctx, mi_row, mi_col, bsize);
@@ -3963,32 +4115,31 @@ static void rd_pick_partition(const AV1_
         rd_supertx_sb(cpi, td, tile_info, mi_row, mi_col, bsize, &tmp_rdc.rate,
                       &tmp_rdc.dist, &best_tx, pc_tree);
 
         tmp_rdc.rate += av1_cost_bit(
             cm->fc
                 ->supertx_prob[partition_supertx_context_lookup[PARTITION_VERT]]
                               [supertx_size],
             1);
-        tmp_rdc.rdcost =
-            RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist);
+        tmp_rdc.rdcost = RDCOST(x->rdmult, tmp_rdc.rate, tmp_rdc.dist);
         if (tmp_rdc.rdcost < sum_rdc.rdcost) {
           sum_rdc = tmp_rdc;
           update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx,
                                   supertx_size, pc_tree);
         }
       }
 
       pc_tree->partitioning = best_partition;
     }
 #endif  // CONFIG_SUPERTX
 
     if (sum_rdc.rdcost < best_rdc.rdcost) {
       sum_rdc.rate += partition_cost[PARTITION_VERT];
-      sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
+      sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
 #if CONFIG_SUPERTX
       sum_rate_nocoef += partition_cost[PARTITION_VERT];
 #endif  // CONFIG_SUPERTX
       if (sum_rdc.rdcost < best_rdc.rdcost) {
         best_rdc = sum_rdc;
 #if CONFIG_SUPERTX
         best_rate_nocoef = sum_rate_nocoef;
         assert(best_rate_nocoef >= 0);
@@ -4057,22 +4208,33 @@ static void rd_pick_partition(const AV1_
                        best_rd, &best_rate_nocoef, &x_ctx,
 #endif
                        mi_row, mi_col, subsize, mi_row, mi_col + mi_step,
                        bsize2, mi_row + mi_step, mi_col + mi_step, bsize2);
     restore_context(x, &x_ctx, mi_row, mi_col, bsize);
   }
 #endif  // CONFIG_EXT_PARTITION_TYPES
 
+#if CONFIG_SPEED_REFS
+  // First scanning is done.
+  if (cpi->sb_scanning_pass_idx == 0 && bsize == cm->sb_size) return;
+#endif  // CONFIG_SPEED_REFS
+
   // TODO(jbb): This code added so that we avoid static analysis
   // warning related to the fact that best_rd isn't used after this
   // point.  This code should be refactored so that the duplicate
   // checks occur in some sub function and thus are used...
   (void)best_rd;
   *rd_cost = best_rdc;
+
+#if CONFIG_DAALA_DIST && CONFIG_CB4X4
+  if (bsize <= BLOCK_8X8 && rd_cost->rate != INT_MAX) {
+    assert(rd_cost->dist_y < INT64_MAX);
+  }
+#endif  // CONFIG_DAALA_DIST && CONFIG_CB4X4
 #if CONFIG_SUPERTX
   *rate_nocoef = best_rate_nocoef;
 #endif  // CONFIG_SUPERTX
 
 #if CONFIG_CFL
   // Store the luma for the best mode
   x->cfl_store_y = 1;
 #endif
@@ -4107,16 +4269,32 @@ static void rd_pick_partition(const AV1_
 #endif
     assert(best_rdc.rate < INT_MAX);
     assert(best_rdc.dist < INT64_MAX);
   } else {
     assert(tp_orig == *tp);
   }
 }
 
+#if CONFIG_SPEED_REFS
+static void restore_mi(const AV1_COMP *const cpi, MACROBLOCK *const x,
+                       int mi_row, int mi_col) {
+  const AV1_COMMON *cm = &cpi->common;
+  MACROBLOCKD *const xd = &x->e_mbd;
+  set_mode_info_offsets(cpi, x, xd, mi_row, mi_col);
+  int x_idx, y;
+  for (y = 0; y < mi_size_high[cm->sb_size]; y++)
+    for (x_idx = 0; x_idx < mi_size_wide[cm->sb_size]; x_idx++)
+      if (mi_col + x_idx < cm->mi_cols && mi_row + y < cm->mi_rows) {
+        memset(xd->mi + y * cm->mi_stride + x_idx, 0, sizeof(*xd->mi));
+        memset(x->mbmi_ext + y * cm->mi_cols + x_idx, 0, sizeof(*x->mbmi_ext));
+      }
+}
+#endif  // CONFIG_SPEED_REFS
+
 static void encode_rd_sb_row(AV1_COMP *cpi, ThreadData *td,
                              TileDataEnc *tile_data, int mi_row,
                              TOKENEXTRA **tp) {
   AV1_COMMON *const cm = &cpi->common;
   const TileInfo *const tile_info = &tile_data->tile_info;
   MACROBLOCK *const x = &td->mb;
   MACROBLOCKD *const xd = &x->e_mbd;
   SPEED_FEATURES *const sf = &cpi->sf;
@@ -4253,22 +4431,45 @@ static void encode_rd_sb_row(AV1_COMP *c
                        1, pc_root);
     } else {
       // If required set upper and lower partition size limits
       if (sf->auto_min_max_partition_size) {
         set_offsets(cpi, tile_info, x, mi_row, mi_col, cm->sb_size);
         rd_auto_partition_range(cpi, tile_info, xd, mi_row, mi_col,
                                 &x->min_partition_size, &x->max_partition_size);
       }
+#if CONFIG_SPEED_REFS
+      // NOTE: Two scanning passes for the current superblock - the first pass
+      //       is only targeted to collect stats.
+      int m_search_count_backup = *(x->m_search_count_ptr);
+      for (int sb_pass_idx = 0; sb_pass_idx < 2; ++sb_pass_idx) {
+        cpi->sb_scanning_pass_idx = sb_pass_idx;
+        if (frame_is_intra_only(cm) && sb_pass_idx == 0) continue;
+
+        rd_pick_partition(cpi, td, tile_data, tp, mi_row, mi_col, cm->sb_size,
+                          &dummy_rdc,
+#if CONFIG_SUPERTX
+                          &dummy_rate_nocoef,
+#endif  // CONFIG_SUPERTX
+                          INT64_MAX, pc_root);
+        if (sb_pass_idx == 0) {
+          av1_zero(x->pred_mv);
+          pc_root->index = 0;
+          restore_mi(cpi, x, mi_row, mi_col);
+          *(x->m_search_count_ptr) = m_search_count_backup;
+        }
+      }
+#else  // !CONFIG_SPEED_REFS
       rd_pick_partition(cpi, td, tile_data, tp, mi_row, mi_col, cm->sb_size,
                         &dummy_rdc,
 #if CONFIG_SUPERTX
                         &dummy_rate_nocoef,
 #endif  // CONFIG_SUPERTX
                         INT64_MAX, pc_root);
+#endif  // CONFIG_SPEED_REFS
     }
   }
 }
 
 static void init_encode_frame_mb_context(AV1_COMP *cpi) {
   MACROBLOCK *const x = &cpi->td.mb;
   AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *const xd = &x->e_mbd;
@@ -4324,37 +4525,29 @@ static MV_REFERENCE_FRAME get_frame_type
   else if (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)
     return GOLDEN_FRAME;
   else
     // TODO(zoeliu): To investigate whether a frame_type other than
     // INTRA/ALTREF/GOLDEN/LAST needs to be specified seperately.
     return LAST_FRAME;
 }
 
-static TX_MODE select_tx_mode(const AV1_COMP *cpi, MACROBLOCKD *const xd) {
-  int i, all_lossless = 1;
-
-  if (cpi->common.seg.enabled) {
-    for (i = 0; i < MAX_SEGMENTS; ++i) {
-      if (!xd->lossless[i]) {
-        all_lossless = 0;
-        break;
-      }
-    }
-  } else {
-    all_lossless = xd->lossless[0];
-  }
-  if (all_lossless) return ONLY_4X4;
+static TX_MODE select_tx_mode(const AV1_COMP *cpi) {
+  if (cpi->common.all_lossless) return ONLY_4X4;
+#if CONFIG_VAR_TX_NO_TX_MODE
+  return TX_MODE_SELECT;
+#else
   if (cpi->sf.tx_size_search_method == USE_LARGESTALL)
     return ALLOW_32X32 + CONFIG_TX64X64;
   else if (cpi->sf.tx_size_search_method == USE_FULL_RD ||
            cpi->sf.tx_size_search_method == USE_TX_8X8)
     return TX_MODE_SELECT;
   else
     return cpi->common.tx_mode;
+#endif  // CONFIG_VAR_TX_NO_TX_MODE
 }
 
 void av1_init_tile_data(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
   const int tile_cols = cm->tile_cols;
   const int tile_rows = cm->tile_rows;
   int tile_col, tile_row;
   TOKENEXTRA *pre_tok = cpi->tile_tok[0][0];
@@ -4507,18 +4700,17 @@ void av1_encode_tile(AV1_COMP *cpi, Thre
 #if CONFIG_EC_ADAPT
   this_tile->tctx = *cm->fc;
   td->mb.e_mbd.tile_ctx = &this_tile->tctx;
 #endif  // #if CONFIG_EC_ADAPT
 
 #if CONFIG_CFL
   MACROBLOCKD *const xd = &td->mb.e_mbd;
   xd->cfl = &this_tile->cfl;
-  cfl_init(xd->cfl, cm, xd->plane[AOM_PLANE_U].subsampling_x,
-           xd->plane[AOM_PLANE_U].subsampling_y);
+  cfl_init(xd->cfl, cm);
 #endif
 
 #if CONFIG_PVQ
   td->mb.daala_enc.state.adapt = &this_tile->tctx.pvq_context;
 #endif  // CONFIG_PVQ
 
   for (mi_row = tile_info->mi_row_start; mi_row < tile_info->mi_row_end;
        mi_row += cm->mib_size) {
@@ -4711,18 +4903,18 @@ static void encode_frame_internal(AV1_CO
       } else if (ref_buf[frame] &&
                  do_gm_search_logic(&cpi->sf, num_refs_using_gm, frame)) {
         TransformationType model;
         const int64_t ref_frame_error = av1_frame_error(
 #if CONFIG_HIGHBITDEPTH
             xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
 #endif  // CONFIG_HIGHBITDEPTH
             ref_buf[frame]->y_buffer, ref_buf[frame]->y_stride,
-            cpi->source->y_buffer, 0, 0, cpi->source->y_width,
-            cpi->source->y_height, cpi->source->y_stride);
+            cpi->source->y_buffer, cpi->source->y_width, cpi->source->y_height,
+            cpi->source->y_stride);
 
         if (ref_frame_error == 0) continue;
 
         aom_clear_system_state();
         for (model = ROTZOOM; model < GLOBAL_TRANS_TYPES_ENC; ++model) {
           int64_t best_warp_error = INT64_MAX;
           // Initially set all params to identity.
           for (i = 0; i < RANSAC_NUM_MOTIONS; ++i) {
@@ -4747,17 +4939,18 @@ static void encode_frame_internal(AV1_CO
               const int64_t warp_error = refine_integerized_param(
                   &tmp_wm_params, tmp_wm_params.wmtype,
 #if CONFIG_HIGHBITDEPTH
                   xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
 #endif  // CONFIG_HIGHBITDEPTH
                   ref_buf[frame]->y_buffer, ref_buf[frame]->y_width,
                   ref_buf[frame]->y_height, ref_buf[frame]->y_stride,
                   cpi->source->y_buffer, cpi->source->y_width,
-                  cpi->source->y_height, cpi->source->y_stride, 3);
+                  cpi->source->y_height, cpi->source->y_stride, 5,
+                  best_warp_error);
               if (warp_error < best_warp_error) {
                 best_warp_error = warp_error;
                 // Save the wm_params modified by refine_integerized_param()
                 // rather than motion index to avoid rerunning refine() below.
                 memcpy(&(cm->global_motion[frame]), &tmp_wm_params,
                        sizeof(WarpedMotionParams));
               }
             }
@@ -4807,20 +5000,20 @@ static void encode_frame_internal(AV1_CO
   for (i = 0; i < MAX_SEGMENTS; ++i) {
     const int qindex = cm->seg.enabled
                            ? av1_get_qindex(&cm->seg, i, cm->base_qindex)
                            : cm->base_qindex;
     xd->lossless[i] = qindex == 0 && cm->y_dc_delta_q == 0 &&
                       cm->uv_dc_delta_q == 0 && cm->uv_ac_delta_q == 0;
     xd->qindex[i] = qindex;
   }
-
+  cm->all_lossless = all_lossless(cm, xd);
   if (!cm->seg.enabled && xd->lossless[0]) x->optimize = 0;
 
-  cm->tx_mode = select_tx_mode(cpi, xd);
+  cm->tx_mode = select_tx_mode(cpi);
 
 #if CONFIG_DELTA_Q
   // Fix delta q resolution for the moment
   cm->delta_q_res = DEFAULT_DELTA_Q_RES;
 // Set delta_q_present_flag before it is used for the first time
 #if CONFIG_EXT_DELTA_Q
   cm->delta_lf_res = DEFAULT_DELTA_LF_RES;
   // update delta_q_present_flag and delta_lf_present_flag based on base_qindex
@@ -4854,28 +5047,42 @@ static void encode_frame_internal(AV1_CO
     cm->prev_frame = last_fb_buf_idx != INVALID_IDX
                          ? &cm->buffer_pool->frame_bufs[last_fb_buf_idx]
                          : NULL;
   }
 #endif  // CONFIG_EXT_REFS || CONFIG_TEMPMV_SIGNALING
 
 #if CONFIG_TEMPMV_SIGNALING
   if (cm->prev_frame) {
-    cm->use_prev_frame_mvs &= !cm->error_resilient_mode &&
-                              cm->width == cm->prev_frame->buf.y_width &&
-                              cm->height == cm->prev_frame->buf.y_height &&
-                              !cm->intra_only && !cm->prev_frame->intra_only;
+    cm->use_prev_frame_mvs &=
+        !cm->error_resilient_mode &&
+#if CONFIG_FRAME_SUPERRES
+        cm->width == cm->last_width && cm->height == cm->last_height &&
+#else
+        cm->width == cm->prev_frame->buf.y_crop_width &&
+        cm->height == cm->prev_frame->buf.y_crop_height &&
+#endif  // CONFIG_FRAME_SUPERRES
+        !cm->intra_only && !cm->prev_frame->intra_only && cm->last_show_frame;
   } else {
     cm->use_prev_frame_mvs = 0;
   }
 #else
-  cm->use_prev_frame_mvs = !cm->error_resilient_mode && cm->prev_frame &&
-                           cm->width == cm->prev_frame->buf.y_crop_width &&
-                           cm->height == cm->prev_frame->buf.y_crop_height &&
-                           !cm->intra_only && cm->last_show_frame;
+  if (cm->prev_frame) {
+    cm->use_prev_frame_mvs = !cm->error_resilient_mode &&
+#if CONFIG_FRAME_SUPERRES
+                             cm->width == cm->last_width &&
+                             cm->height == cm->last_height &&
+#else
+                             cm->width == cm->prev_frame->buf.y_crop_width &&
+                             cm->height == cm->prev_frame->buf.y_crop_height &&
+#endif  // CONFIG_FRAME_SUPERRES
+                             !cm->intra_only && cm->last_show_frame;
+  } else {
+    cm->use_prev_frame_mvs = 0;
+  }
 #endif  // CONFIG_TEMPMV_SIGNALING
 
   // Special case: set prev_mi to NULL when the previous mode info
   // context cannot be used.
   cm->prev_mi =
       cm->use_prev_frame_mvs ? cm->prev_mip + cm->mi_stride + 1 : NULL;
 
 #if CONFIG_VAR_TX
@@ -4916,17 +5123,21 @@ static void encode_frame_internal(AV1_CO
 #if CONFIG_EXT_INTER
 static void make_consistent_compound_tools(AV1_COMMON *cm) {
   (void)cm;
 #if CONFIG_INTERINTRA
   if (frame_is_intra_only(cm) || cm->reference_mode == COMPOUND_REFERENCE)
     cm->allow_interintra_compound = 0;
 #endif  // CONFIG_INTERINTRA
 #if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
+#if CONFIG_COMPOUND_SINGLEREF
+  if (frame_is_intra_only(cm))
+#else   // !CONFIG_COMPOUND_SINGLEREF
   if (frame_is_intra_only(cm) || cm->reference_mode == SINGLE_REFERENCE)
+#endif  // CONFIG_COMPOUND_SINGLEREF
     cm->allow_masked_compound = 0;
 #endif  // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
 }
 #endif  // CONFIG_EXT_INTER
 
 void av1_encode_frame(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
 #if CONFIG_EXT_TX
@@ -4937,40 +5148,41 @@ void av1_encode_frame(AV1_COMP *cpi) {
 
   // In the longer term the encoder should be generalized to match the
   // decoder such that we allow compound where one of the 3 buffers has a
   // different sign bias and that buffer is then the fixed ref. However, this
   // requires further work in the rd loop. For now the only supported encoder
   // side behavior is where the ALT ref buffer has opposite sign bias to
   // the other two.
   if (!frame_is_intra_only(cm)) {
-#if !CONFIG_ONE_SIDED_COMPOUND
+#if !(CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS)
     if ((cm->ref_frame_sign_bias[ALTREF_FRAME] ==
          cm->ref_frame_sign_bias[GOLDEN_FRAME]) ||
         (cm->ref_frame_sign_bias[ALTREF_FRAME] ==
          cm->ref_frame_sign_bias[LAST_FRAME])) {
       cpi->allow_comp_inter_inter = 0;
     } else {
-#endif
+#endif  // !(CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS)
       cpi->allow_comp_inter_inter = 1;
 #if CONFIG_EXT_REFS
       cm->comp_fwd_ref[0] = LAST_FRAME;
       cm->comp_fwd_ref[1] = LAST2_FRAME;
       cm->comp_fwd_ref[2] = LAST3_FRAME;
       cm->comp_fwd_ref[3] = GOLDEN_FRAME;
       cm->comp_bwd_ref[0] = BWDREF_FRAME;
       cm->comp_bwd_ref[1] = ALTREF_FRAME;
 #else
     cm->comp_fixed_ref = ALTREF_FRAME;
     cm->comp_var_ref[0] = LAST_FRAME;
     cm->comp_var_ref[1] = GOLDEN_FRAME;
-#endif                          // CONFIG_EXT_REFS
-#if !CONFIG_ONE_SIDED_COMPOUND  // Normative in encoder
+#endif  // CONFIG_EXT_REFS
+#if !(CONFIG_ONE_SIDED_COMPOUND || \
+      CONFIG_EXT_COMP_REFS)  // Normative in encoder
     }
-#endif
+#endif  // !(CONFIG_ONE_SIDED_COMPOUND || CONFIG_EXT_COMP_REFS)
   } else {
     cpi->allow_comp_inter_inter = 0;
   }
 
   if (cpi->sf.frame_parameter_update) {
     int i;
     RD_OPT *const rd_opt = &cpi->rd;
     FRAME_COUNTS *counts = cpi->td.counts;
@@ -5012,35 +5224,33 @@ void av1_encode_frame(AV1_COMP *cpi) {
 
 #if CONFIG_DUAL_FILTER
     cm->interp_filter = SWITCHABLE;
 #endif
 
 #if CONFIG_EXT_INTER
     make_consistent_compound_tools(cm);
 #endif  // CONFIG_EXT_INTER
+
+    rdc->single_ref_used_flag = 0;
+    rdc->compound_ref_used_flag = 0;
+
     encode_frame_internal(cpi);
 
     for (i = 0; i < REFERENCE_MODES; ++i)
       mode_thrs[i] = (mode_thrs[i] + rdc->comp_pred_diff[i] / cm->MBs) / 2;
 
     if (cm->reference_mode == REFERENCE_MODE_SELECT) {
-      int single_count_zero = 0;
-      int comp_count_zero = 0;
-
-      for (i = 0; i < COMP_INTER_CONTEXTS; i++) {
-        single_count_zero += counts->comp_inter[i][0];
-        comp_count_zero += counts->comp_inter[i][1];
-      }
-
-      if (comp_count_zero == 0) {
+      // Use a flag that includes 4x4 blocks
+      if (rdc->compound_ref_used_flag == 0) {
         cm->reference_mode = SINGLE_REFERENCE;
         av1_zero(counts->comp_inter);
 #if !CONFIG_REF_ADAPT
-      } else if (single_count_zero == 0) {
+        // Use a flag that includes 4x4 blocks
+      } else if (rdc->single_ref_used_flag == 0) {
         cm->reference_mode = COMPOUND_REFERENCE;
         av1_zero(counts->comp_inter);
 #endif  // !CONFIG_REF_ADAPT
       }
     }
 #if CONFIG_EXT_INTER
     make_consistent_compound_tools(cm);
 #endif  // CONFIG_EXT_INTER
@@ -5227,45 +5437,56 @@ void av1_encode_frame(AV1_COMP *cpi) {
   }
 }
 
 static void sum_intra_stats(FRAME_COUNTS *counts, MACROBLOCKD *xd,
                             const MODE_INFO *mi, const MODE_INFO *above_mi,
                             const MODE_INFO *left_mi, const int intraonly,
                             const int mi_row, const int mi_col) {
   const MB_MODE_INFO *const mbmi = &mi->mbmi;
+#if !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
   const PREDICTION_MODE y_mode = mbmi->mode;
   const PREDICTION_MODE uv_mode = mbmi->uv_mode;
+#else
+  (void)counts;
+  (void)above_mi;
+  (void)left_mi;
+  (void)intraonly;
+#endif  // !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
   const BLOCK_SIZE bsize = mbmi->sb_type;
   const int unify_bsize = CONFIG_CB4X4;
 
   if (bsize < BLOCK_8X8 && !unify_bsize) {
+#if !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
     int idx, idy;
     const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
     const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];
     for (idy = 0; idy < 2; idy += num_4x4_h)
       for (idx = 0; idx < 2; idx += num_4x4_w) {
         const int bidx = idy * 2 + idx;
         const PREDICTION_MODE bmode = mi->bmi[bidx].as_mode;
         if (intraonly) {
           const PREDICTION_MODE a = av1_above_block_mode(mi, above_mi, bidx);
           const PREDICTION_MODE l = av1_left_block_mode(mi, left_mi, bidx);
           ++counts->kf_y_mode[a][l][bmode];
         } else {
           ++counts->y_mode[0][bmode];
         }
       }
+#endif  // !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
   } else {
+#if !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
     if (intraonly) {
       const PREDICTION_MODE above = av1_above_block_mode(mi, above_mi, 0);
       const PREDICTION_MODE left = av1_left_block_mode(mi, left_mi, 0);
       ++counts->kf_y_mode[above][left][y_mode];
     } else {
       ++counts->y_mode[size_group_lookup[bsize]][y_mode];
     }
+#endif  // !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
 #if CONFIG_FILTER_INTRA
     if (mbmi->mode == DC_PRED
 #if CONFIG_PALETTE
         && mbmi->palette_mode_info.palette_size[0] == 0
 #endif  // CONFIG_PALETTE
         ) {
       const int use_filter_intra_mode =
           mbmi->filter_intra_mode_info.use_filter_intra_mode[0];
@@ -5301,17 +5522,19 @@ static void sum_intra_stats(FRAME_COUNTS
   if (!is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
                            xd->plane[1].subsampling_y))
     return;
 #else
   (void)mi_row;
   (void)mi_col;
   (void)xd;
 #endif
+#if !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
   ++counts->uv_mode[y_mode][uv_mode];
+#endif  // !CONFIG_EC_ADAPT || CONFIG_ENTROPY_STATS
 }
 
 #if CONFIG_VAR_TX
 static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd,
                               FRAME_COUNTS *counts, TX_SIZE tx_size, int depth,
                               int blk_row, int blk_col) {
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   const int tx_row = blk_row >> 1;
@@ -5439,16 +5662,17 @@ static void tx_partition_set_contexts(co
 void av1_update_tx_type_count(const AV1_COMMON *cm, MACROBLOCKD *xd,
 #if CONFIG_TXK_SEL
                               int block, int plane,
 #endif
                               BLOCK_SIZE bsize, TX_SIZE tx_size,
                               FRAME_COUNTS *counts) {
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   int is_inter = is_inter_block(mbmi);
+
 #if !CONFIG_TXK_SEL
   TX_TYPE tx_type = mbmi->tx_type;
 #else
   // Only y plane's tx_type is updated
   if (plane > 0) return;
   TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, tx_size);
 #endif
 #if CONFIG_EXT_TX
@@ -5504,17 +5728,17 @@ static void encode_superblock(const AV1_
   const BLOCK_SIZE block_size = AOMMAX(bsize, BLOCK_8X8);
 #endif
 
 #if CONFIG_PVQ
   x->pvq_speed = 0;
   x->pvq_coded = (dry_run == OUTPUT_ENABLED) ? 1 : 0;
 #endif
 #if CONFIG_CFL
-  x->cfl_store_y = (dry_run == OUTPUT_ENABLED) ? 1 : 0;
+  x->cfl_store_y = 1;
 #endif
 
   if (!is_inter) {
     int plane;
     mbmi->skip = 1;
     for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
       av1_encode_intra_block_plane((AV1_COMMON *)cm, x, block_size, plane, 1,
                                    mi_row, mi_col);
@@ -5554,18 +5778,31 @@ static void encode_superblock(const AV1_
 #if CONFIG_INTRABC
       assert(IMPLIES(!is_intrabc_block(mbmi), cfg));
 #else
       assert(cfg != NULL);
 #endif  // !CONFIG_INTRABC
       av1_setup_pre_planes(xd, ref, cfg, mi_row, mi_col,
                            &xd->block_refs[ref]->sf);
     }
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    // Single ref compound mode
+    if (!is_compound && is_inter_singleref_comp_mode(mbmi->mode)) {
+      xd->block_refs[1] = xd->block_refs[0];
+      YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, mbmi->ref_frame[0]);
+#if CONFIG_INTRABC
+      assert(IMPLIES(!is_intrabc_block(mbmi), cfg));
+#else
+      assert(cfg != NULL);
+#endif  // !CONFIG_INTRABC
+      av1_setup_pre_planes(xd, 1, cfg, mi_row, mi_col, &xd->block_refs[1]->sf);
+    }
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
     av1_build_inter_predictors_sby(cm, xd, mi_row, mi_col, NULL, block_size);
-
     av1_build_inter_predictors_sbuv(cm, xd, mi_row, mi_col, NULL, block_size);
 #if CONFIG_MOTION_VAR
     if (mbmi->motion_mode == OBMC_CAUSAL) {
 #if CONFIG_NCOBMC
       if (dry_run == OUTPUT_ENABLED)
         av1_build_ncobmc_inter_predictors_sb(cm, xd, mi_row, mi_col);
       else
 #endif
@@ -5584,18 +5821,19 @@ static void encode_superblock(const AV1_
 #else   // CONFIG_LV_MAP
     av1_tokenize_sb(cpi, td, t, dry_run, block_size, rate, mi_row, mi_col);
 #endif  // CONFIG_LV_MAP
 #endif
   }
 
 #if CONFIG_DAALA_DIST && CONFIG_CB4X4
   if (bsize < BLOCK_8X8) {
-    daala_dist_set_sub8x8_dst(x, x->decoded_8x8, bsize, block_size_wide[bsize],
-                              block_size_high[bsize], mi_row, mi_col);
+    daala_dist_set_sub8x8_dst(x, (uint8_t *)x->decoded_8x8, bsize,
+                              block_size_wide[bsize], block_size_high[bsize],
+                              mi_row, mi_col);
   }
 #endif
 
   if (!dry_run) {
 #if CONFIG_VAR_TX
     TX_SIZE tx_size =
         is_inter && !mbmi->skip ? mbmi->min_tx_size : mbmi->tx_size;
 #else
@@ -5832,17 +6070,17 @@ static int check_supertx_sb(BLOCK_SIZE b
     default: assert(0); return 0;
   }
 }
 
 static void predict_superblock(const AV1_COMP *const cpi, ThreadData *td,
 #if CONFIG_EXT_INTER
                                int mi_row_ori, int mi_col_ori,
 #endif  // CONFIG_EXT_INTER
-                               int mi_row_pred, int mi_col_pred,
+                               int mi_row_pred, int mi_col_pred, int plane,
                                BLOCK_SIZE bsize_pred, int b_sub8x8, int block) {
   // Used in supertx
   // (mi_row_ori, mi_col_ori): location for mv
   // (mi_row_pred, mi_col_pred, bsize_pred): region to predict
   const AV1_COMMON *const cm = &cpi->common;
   MACROBLOCK *const x = &td->mb;
   MACROBLOCKD *const xd = &x->e_mbd;
   MODE_INFO *mi_8x8 = xd->mi[0];
@@ -5854,38 +6092,49 @@ static void predict_superblock(const AV1
   set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]);
 
   for (ref = 0; ref < 1 + is_compound; ++ref) {
     YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, mbmi->ref_frame[ref]);
     av1_setup_pre_planes(xd, ref, cfg, mi_row_pred, mi_col_pred,
                          &xd->block_refs[ref]->sf);
   }
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  // Single ref compound mode
+  if (!is_compound && is_inter_singleref_comp_mode(mbmi->mode)) {
+    xd->block_refs[1] = xd->block_refs[0];
+    YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, mbmi->ref_frame[0]);
+    av1_setup_pre_planes(xd, 1, cfg, mi_row_pred, mi_col_pred,
+                         &xd->block_refs[1]->sf);
+  }
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
   if (!b_sub8x8)
-    av1_build_inter_predictors_sb_extend(cm, xd,
+    av1_build_inter_predictor_sb_extend(cm, xd,
 #if CONFIG_EXT_INTER
-                                         mi_row_ori, mi_col_ori,
+                                        mi_row_ori, mi_col_ori,
 #endif  // CONFIG_EXT_INTER
-                                         mi_row_pred, mi_col_pred, bsize_pred);
+                                        mi_row_pred, mi_col_pred, plane,
+                                        bsize_pred);
   else
-    av1_build_inter_predictors_sb_sub8x8_extend(cm, xd,
+    av1_build_inter_predictor_sb_sub8x8_extend(cm, xd,
 #if CONFIG_EXT_INTER
-                                                mi_row_ori, mi_col_ori,
+                                               mi_row_ori, mi_col_ori,
 #endif  // CONFIG_EXT_INTER
-                                                mi_row_pred, mi_col_pred,
-                                                bsize_pred, block);
+                                               mi_row_pred, mi_col_pred, plane,
+                                               bsize_pred, block);
 }
 
 static void predict_b_extend(const AV1_COMP *const cpi, ThreadData *td,
                              const TileInfo *const tile, int block,
                              int mi_row_ori, int mi_col_ori, int mi_row_pred,
                              int mi_col_pred, int mi_row_top, int mi_col_top,
-                             uint8_t *dst_buf[3], int dst_stride[3],
+                             int plane, uint8_t *dst_buf, int dst_stride,
                              BLOCK_SIZE bsize_top, BLOCK_SIZE bsize_pred,
-                             RUN_TYPE dry_run, int b_sub8x8, int bextend) {
+                             RUN_TYPE dry_run, int b_sub8x8) {
   // Used in supertx
   // (mi_row_ori, mi_col_ori): location for mv
   // (mi_row_pred, mi_col_pred, bsize_pred): region to predict
   // (mi_row_top, mi_col_top, bsize_top): region of the top partition size
   // block: sub location of sub8x8 blocks
   // b_sub8x8: 1: ori is sub8x8; 0: ori is not sub8x8
   // bextend: 1: region to predict is an extension of ori; 0: not
 
@@ -5900,44 +6149,37 @@ static void predict_b_extend(const AV1_C
   if (mi_row_pred < mi_row_top || mi_col_pred < mi_col_top ||
       mi_row_pred >= mi_row_top + mi_height_top ||
       mi_col_pred >= mi_col_top + mi_width_top || mi_row_pred >= cm->mi_rows ||
       mi_col_pred >= cm->mi_cols)
     return;
 
   set_offsets_extend(cpi, td, tile, mi_row_pred, mi_col_pred, mi_row_ori,
                      mi_col_ori, bsize_pred);
-  xd->plane[0].dst.stride = dst_stride[0];
-  xd->plane[1].dst.stride = dst_stride[1];
-  xd->plane[2].dst.stride = dst_stride[2];
-  xd->plane[0].dst.buf = dst_buf[0] +
-                         (r >> xd->plane[0].subsampling_y) * dst_stride[0] +
-                         (c >> xd->plane[0].subsampling_x);
-  xd->plane[1].dst.buf = dst_buf[1] +
-                         (r >> xd->plane[1].subsampling_y) * dst_stride[1] +
-                         (c >> xd->plane[1].subsampling_x);
-  xd->plane[2].dst.buf = dst_buf[2] +
-                         (r >> xd->plane[2].subsampling_y) * dst_stride[2] +
-                         (c >> xd->plane[2].subsampling_x);
+  xd->plane[plane].dst.stride = dst_stride;
+  xd->plane[plane].dst.buf =
+      dst_buf + (r >> xd->plane[plane].subsampling_y) * dst_stride +
+      (c >> xd->plane[plane].subsampling_x);
 
   predict_superblock(cpi, td,
 #if CONFIG_EXT_INTER
                      mi_row_ori, mi_col_ori,
 #endif  // CONFIG_EXT_INTER
-                     mi_row_pred, mi_col_pred, bsize_pred, b_sub8x8, block);
-
-  if (!dry_run && !bextend)
+                     mi_row_pred, mi_col_pred, plane, bsize_pred, b_sub8x8,
+                     block);
+
+  if (!dry_run && (plane == 0) && (block == 0 || !b_sub8x8))
     update_stats(&cpi->common, td, mi_row_pred, mi_col_pred, 1);
 }
 
 static void extend_dir(const AV1_COMP *const cpi, ThreadData *td,
                        const TileInfo *const tile, int block, BLOCK_SIZE bsize,
-                       BLOCK_SIZE top_bsize, int mi_row, int mi_col,
-                       int mi_row_top, int mi_col_top, RUN_TYPE dry_run,
-                       uint8_t *dst_buf[3], int dst_stride[3], int dir) {
+                       BLOCK_SIZE top_bsize, int mi_row_ori, int mi_col_ori,
+                       int mi_row, int mi_col, int mi_row_top, int mi_col_top,
+                       int plane, uint8_t *dst_buf, int dst_stride, int dir) {
   // dir: 0-lower, 1-upper, 2-left, 3-right
   //      4-lowerleft, 5-upperleft, 6-lowerright, 7-upperright
   MACROBLOCKD *xd = &td->mb.e_mbd;
   const int mi_width = mi_size_wide[bsize];
   const int mi_height = mi_size_high[bsize];
   int xss = xd->plane[1].subsampling_x;
   int yss = xd->plane[1].subsampling_y;
 #if CONFIG_CB4X4
@@ -5968,20 +6210,20 @@ static void extend_dir(const AV1_COMP *c
     wide_unit = mi_size_wide[extend_bsize];
     high_unit = mi_size_high[extend_bsize];
 
     mi_row_pred = mi_row + ((dir == 0) ? mi_height : -(mi_height + ext_offset));
     mi_col_pred = mi_col;
 
     for (j = 0; j < mi_height + ext_offset; j += high_unit)
       for (i = 0; i < mi_width + ext_offset; i += wide_unit)
-        predict_b_extend(cpi, td, tile, block, mi_row, mi_col, mi_row_pred + j,
-                         mi_col_pred + i, mi_row_top, mi_col_top, dst_buf,
-                         dst_stride, top_bsize, extend_bsize, dry_run, b_sub8x8,
-                         1);
+        predict_b_extend(cpi, td, tile, block, mi_row_ori, mi_col_ori,
+                         mi_row_pred + j, mi_col_pred + i, mi_row_top,
+                         mi_col_top, plane, dst_buf, dst_stride, top_bsize,
+                         extend_bsize, 1, b_sub8x8);
   } else if (dir == 2 || dir == 3) {  // left and right
     extend_bsize =
         (mi_height == mi_size_high[BLOCK_8X8] || bsize < BLOCK_8X8 || yss < xss)
             ? BLOCK_8X8
             : BLOCK_8X16;
 #if CONFIG_CB4X4
     if (bsize < BLOCK_8X8) {
       extend_bsize = BLOCK_4X4;
@@ -5991,20 +6233,20 @@ static void extend_dir(const AV1_COMP *c
     wide_unit = mi_size_wide[extend_bsize];
     high_unit = mi_size_high[extend_bsize];
 
     mi_row_pred = mi_row;
     mi_col_pred = mi_col + ((dir == 3) ? mi_width : -(mi_width + ext_offset));
 
     for (j = 0; j < mi_height + ext_offset; j += high_unit)
       for (i = 0; i < mi_width + ext_offset; i += wide_unit)
-        predict_b_extend(cpi, td, tile, block, mi_row, mi_col, mi_row_pred + j,
-                         mi_col_pred + i, mi_row_top, mi_col_top, dst_buf,
-                         dst_stride, top_bsize, extend_bsize, dry_run, b_sub8x8,
-                         1);
+        predict_b_extend(cpi, td, tile, block, mi_row_ori, mi_col_ori,
+                         mi_row_pred + j, mi_col_pred + i, mi_row_top,
+                         mi_col_top, plane, dst_buf, dst_stride, top_bsize,
+                         extend_bsize, 1, b_sub8x8);
   } else {
     extend_bsize = BLOCK_8X8;
 #if CONFIG_CB4X4
     if (bsize < BLOCK_8X8) {
       extend_bsize = BLOCK_4X4;
       ext_offset = mi_size_wide[BLOCK_8X8];
     }
 #endif
@@ -6013,45 +6255,34 @@ static void extend_dir(const AV1_COMP *c
 
     mi_row_pred = mi_row + ((dir == 4 || dir == 6) ? mi_height
                                                    : -(mi_height + ext_offset));
     mi_col_pred =
         mi_col + ((dir == 6 || dir == 7) ? mi_width : -(mi_width + ext_offset));
 
     for (j = 0; j < mi_height + ext_offset; j += high_unit)
       for (i = 0; i < mi_width + ext_offset; i += wide_unit)
-        predict_b_extend(cpi, td, tile, block, mi_row, mi_col, mi_row_pred + j,
-                         mi_col_pred + i, mi_row_top, mi_col_top, dst_buf,
-                         dst_stride, top_bsize, extend_bsize, dry_run, b_sub8x8,
-                         1);
+        predict_b_extend(cpi, td, tile, block, mi_row_ori, mi_col_ori,
+                         mi_row_pred + j, mi_col_pred + i, mi_row_top,
+                         mi_col_top, plane, dst_buf, dst_stride, top_bsize,
+                         extend_bsize, 1, b_sub8x8);
   }
 }
 
 static void extend_all(const AV1_COMP *const cpi, ThreadData *td,
                        const TileInfo *const tile, int block, BLOCK_SIZE bsize,
-                       BLOCK_SIZE top_bsize, int mi_row, int mi_col,
-                       int mi_row_top, int mi_col_top, RUN_TYPE dry_run,
-                       uint8_t *dst_buf[3], int dst_stride[3]) {
+                       BLOCK_SIZE top_bsize, int mi_row_ori, int mi_col_ori,
+                       int mi_row, int mi_col, int mi_row_top, int mi_col_top,
+                       int plane, uint8_t *dst_buf, int dst_stride) {
   assert(block >= 0 && block < 4);
-  extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top,
-             mi_col_top, dry_run, dst_buf, dst_stride, 0);
-  extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top,
-             mi_col_top, dry_run, dst_buf, dst_stride, 1);
-  extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top,
-             mi_col_top, dry_run, dst_buf, dst_stride, 2);
-  extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top,
-             mi_col_top, dry_run, dst_buf, dst_stride, 3);
-  extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top,
-             mi_col_top, dry_run, dst_buf, dst_stride, 4);
-  extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top,
-             mi_col_top, dry_run, dst_buf, dst_stride, 5);
-  extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top,
-             mi_col_top, dry_run, dst_buf, dst_stride, 6);
-  extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top,
-             mi_col_top, dry_run, dst_buf, dst_stride, 7);
+  for (int i = 0; i < 8; ++i) {
+    extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row_ori, mi_col_ori,
+               mi_row, mi_col, mi_row_top, mi_col_top, plane, dst_buf,
+               dst_stride, i);
+  }
 }
 
 // This function generates prediction for multiple blocks, between which
 // discontinuity around boundary is reduced by smoothing masks. The basic
 // smoothing mask is a soft step function along horz/vert direction. In more
 // complicated case when a block is split into 4 subblocks, the basic mask is
 // first applied to neighboring subblocks (2 pairs) in horizontal direction and
 // then applied to the 2 masked prediction mentioned above in vertical direction
@@ -6135,171 +6366,301 @@ static void predict_sb_complex(const AV1
   for (i = 0; i < MAX_MB_PLANE; i++) {
     xd->plane[i].dst.buf = dst_buf[i];
     xd->plane[i].dst.stride = dst_stride[i];
   }
 
   switch (partition) {
     case PARTITION_NONE:
       assert(bsize < top_bsize);
-      predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
-                       mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize,
-                       bsize, dry_run, 0, 0);
-      extend_all(cpi, td, tile, 0, bsize, top_bsize, mi_row, mi_col, mi_row_top,
-                 mi_col_top, dry_run, dst_buf, dst_stride);
+      for (i = 0; i < MAX_MB_PLANE; ++i) {
+        predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
+                         mi_row_top, mi_col_top, i, dst_buf[i], dst_stride[i],
+                         top_bsize, bsize, dry_run, 0);
+        extend_all(cpi, td, tile, 0, bsize, top_bsize, mi_row, mi_col, mi_row,
+                   mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                   dst_stride[i]);
+      }
       break;
     case PARTITION_HORZ:
       if (bsize == BLOCK_8X8 && !unify_bsize) {
-        // Fisrt half
-        predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize,
-                         BLOCK_8X8, dry_run, 1, 0);
-        if (bsize < top_bsize)
-          extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dry_run, dst_buf, dst_stride);
-
-        // Second half
-        predict_b_extend(cpi, td, tile, 2, mi_row, mi_col, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf1, dst_stride1,
-                         top_bsize, BLOCK_8X8, dry_run, 1, 1);
-        if (bsize < top_bsize)
-          extend_all(cpi, td, tile, 2, subsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dry_run, dst_buf1, dst_stride1);
+        for (i = 0; i < MAX_MB_PLANE; ++i) {
+          // First half
+          predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
+                           mi_row_top, mi_col_top, i, dst_buf[i], dst_stride[i],
+                           top_bsize, BLOCK_8X8, dry_run, 1);
+          if (bsize < top_bsize)
+            extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
+                       mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                       dst_stride[i]);
+
+          // Second half
+          predict_b_extend(cpi, td, tile, 2, mi_row, mi_col, mi_row, mi_col,
+                           mi_row_top, mi_col_top, i, dst_buf1[i],
+                           dst_stride1[i], top_bsize, BLOCK_8X8, dry_run, 1);
+          if (bsize < top_bsize)
+            extend_all(cpi, td, tile, 2, subsize, top_bsize, mi_row, mi_col,
+                       mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf1[i],
+                       dst_stride1[i]);
+        }
 
         // Smooth
         xd->plane[0].dst.buf = dst_buf[0];
         xd->plane[0].dst.stride = dst_stride[0];
         av1_build_masked_inter_predictor_complex(
             xd, dst_buf[0], dst_stride[0], dst_buf1[0], dst_stride1[0], mi_row,
             mi_col, mi_row_top, mi_col_top, bsize, top_bsize, PARTITION_HORZ,
             0);
       } else {
-        // First half
-        predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize,
-                         subsize, dry_run, 0, 0);
-        if (bsize < top_bsize)
-          extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dry_run, dst_buf, dst_stride);
-        else
-          extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dry_run, dst_buf, dst_stride, 0);
-
-        if (mi_row + hbs < cm->mi_rows) {
-          // Second half
-          predict_b_extend(cpi, td, tile, 0, mi_row + hbs, mi_col, mi_row + hbs,
-                           mi_col, mi_row_top, mi_col_top, dst_buf1,
-                           dst_stride1, top_bsize, subsize, dry_run, 0, 0);
-          if (bsize < top_bsize)
-            extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row + hbs,
-                       mi_col, mi_row_top, mi_col_top, dry_run, dst_buf1,
-                       dst_stride1);
-          else
-            extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row + hbs,
-                       mi_col, mi_row_top, mi_col_top, dry_run, dst_buf1,
-                       dst_stride1, 1);
-
-          // Smooth
-          for (i = 0; i < MAX_MB_PLANE; i++) {
+        for (i = 0; i < MAX_MB_PLANE; ++i) {
+#if CONFIG_CB4X4
+          const struct macroblockd_plane *pd = &xd->plane[i];
+          int handle_chroma_sub8x8 = need_handle_chroma_sub8x8(
+              subsize, pd->subsampling_x, pd->subsampling_y);
+
+          if (handle_chroma_sub8x8) {
+            int mode_offset_row = CONFIG_CHROMA_SUB8X8 ? hbs : 0;
+
+            predict_b_extend(cpi, td, tile, 0, mi_row + mode_offset_row, mi_col,
+                             mi_row, mi_col, mi_row_top, mi_col_top, i,
+                             dst_buf[i], dst_stride[i], top_bsize, bsize,
+                             dry_run, 0);
+            if (bsize < top_bsize)
+              extend_all(cpi, td, tile, 0, bsize, top_bsize,
+                         mi_row + mode_offset_row, mi_col, mi_row, mi_col,
+                         mi_row_top, mi_col_top, i, dst_buf[i], dst_stride[i]);
+          } else {
+#endif
+            // First half
+            predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
+                             mi_row_top, mi_col_top, i, dst_buf[i],
+                             dst_stride[i], top_bsize, subsize, dry_run, 0);
+            if (bsize < top_bsize)
+              extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
+                         mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                         dst_stride[i]);
+            else
+              extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
+                         mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                         dst_stride[i], 0);
             xd->plane[i].dst.buf = dst_buf[i];
             xd->plane[i].dst.stride = dst_stride[i];
-            av1_build_masked_inter_predictor_complex(
-                xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i],
-                mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
-                PARTITION_HORZ, i);
+
+            if (mi_row + hbs < cm->mi_rows) {
+              // Second half
+              predict_b_extend(cpi, td, tile, 0, mi_row + hbs, mi_col,
+                               mi_row + hbs, mi_col, mi_row_top, mi_col_top, i,
+                               dst_buf1[i], dst_stride1[i], top_bsize, subsize,
+                               dry_run, 0);
+              if (bsize < top_bsize)
+                extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row + hbs,
+                           mi_col, mi_row + hbs, mi_col, mi_row_top, mi_col_top,
+                           i, dst_buf1[i], dst_stride1[i]);
+              else
+                extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row + hbs,
+                           mi_col, mi_row + hbs, mi_col, mi_row_top, mi_col_top,
+                           i, dst_buf1[i], dst_stride1[i], 1);
+              // Smooth
+              xd->plane[i].dst.buf = dst_buf[i];
+              xd->plane[i].dst.stride = dst_stride[i];
+              av1_build_masked_inter_predictor_complex(
+                  xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i],
+                  mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
+                  PARTITION_HORZ, i);
+            }
+#if CONFIG_CB4X4
           }
+#endif
         }
       }
       break;
     case PARTITION_VERT:
       if (bsize == BLOCK_8X8 && !unify_bsize) {
-        // First half
-        predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize,
-                         BLOCK_8X8, dry_run, 1, 0);
-        if (bsize < top_bsize)
-          extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dry_run, dst_buf, dst_stride);
-
-        // Second half
-        predict_b_extend(cpi, td, tile, 1, mi_row, mi_col, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf1, dst_stride1,
-                         top_bsize, BLOCK_8X8, dry_run, 1, 1);
-        if (bsize < top_bsize)
-          extend_all(cpi, td, tile, 1, subsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dry_run, dst_buf1, dst_stride1);
+        for (i = 0; i < MAX_MB_PLANE; ++i) {
+          // First half
+          predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
+                           mi_row_top, mi_col_top, i, dst_buf[i], dst_stride[i],
+                           top_bsize, BLOCK_8X8, dry_run, 1);
+          if (bsize < top_bsize)
+            extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
+                       mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                       dst_stride[i]);
+
+          // Second half
+          predict_b_extend(cpi, td, tile, 1, mi_row, mi_col, mi_row, mi_col,
+                           mi_row_top, mi_col_top, i, dst_buf1[i],
+                           dst_stride1[i], top_bsize, BLOCK_8X8, dry_run, 1);
+          if (bsize < top_bsize)
+            extend_all(cpi, td, tile, 1, subsize, top_bsize, mi_row, mi_col,
+                       mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf1[i],
+                       dst_stride1[i]);
+        }
 
         // Smooth
         xd->plane[0].dst.buf = dst_buf[0];
         xd->plane[0].dst.stride = dst_stride[0];
         av1_build_masked_inter_predictor_complex(
             xd, dst_buf[0], dst_stride[0], dst_buf1[0], dst_stride1[0], mi_row,
             mi_col, mi_row_top, mi_col_top, bsize, top_bsize, PARTITION_VERT,
             0);
       } else {
-        // bsize: not important, not useful
-        predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize,
-                         subsize, dry_run, 0, 0);
-        if (bsize < top_bsize)
-          extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dry_run, dst_buf, dst_stride);
-        else
-          extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dry_run, dst_buf, dst_stride, 3);
-
-        if (mi_col + hbs < cm->mi_cols) {
-          predict_b_extend(cpi, td, tile, 0, mi_row, mi_col + hbs, mi_row,
-                           mi_col + hbs, mi_row_top, mi_col_top, dst_buf1,
-                           dst_stride1, top_bsize, subsize, dry_run, 0, 0);
-          if (bsize < top_bsize)
-            extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row,
-                       mi_col + hbs, mi_row_top, mi_col_top, dry_run, dst_buf1,
-                       dst_stride1);
-          else
-            extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row,
-                       mi_col + hbs, mi_row_top, mi_col_top, dry_run, dst_buf1,
-                       dst_stride1, 2);
-
-          for (i = 0; i < MAX_MB_PLANE; i++) {
+        for (i = 0; i < MAX_MB_PLANE; ++i) {
+#if CONFIG_CB4X4
+          const struct macroblockd_plane *pd = &xd->plane[i];
+          int handle_chroma_sub8x8 = need_handle_chroma_sub8x8(
+              subsize, pd->subsampling_x, pd->subsampling_y);
+
+          if (handle_chroma_sub8x8) {
+            int mode_offset_col = CONFIG_CHROMA_SUB8X8 ? hbs : 0;
+
+            predict_b_extend(cpi, td, tile, 0, mi_row, mi_col + mode_offset_col,
+                             mi_row, mi_col, mi_row_top, mi_col_top, i,
+                             dst_buf[i], dst_stride[i], top_bsize, bsize,
+                             dry_run, 0);
+            if (bsize < top_bsize)
+              extend_all(cpi, td, tile, 0, bsize, top_bsize, mi_row,
+                         mi_col + mode_offset_col, mi_row, mi_col, mi_row_top,
+                         mi_col_top, i, dst_buf[i], dst_stride[i]);
+          } else {
+#endif
+            predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
+                             mi_row_top, mi_col_top, i, dst_buf[i],
+                             dst_stride[i], top_bsize, subsize, dry_run, 0);
+            if (bsize < top_bsize)
+              extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
+                         mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                         dst_stride[i]);
+            else
+              extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
+                         mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                         dst_stride[i], 3);
             xd->plane[i].dst.buf = dst_buf[i];
             xd->plane[i].dst.stride = dst_stride[i];
-            av1_build_masked_inter_predictor_complex(
-                xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i],
-                mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
-                PARTITION_VERT, i);
+
+            if (mi_col + hbs < cm->mi_cols) {
+              predict_b_extend(cpi, td, tile, 0, mi_row, mi_col + hbs, mi_row,
+                               mi_col + hbs, mi_row_top, mi_col_top, i,
+                               dst_buf1[i], dst_stride1[i], top_bsize, subsize,
+                               dry_run, 0);
+              if (bsize < top_bsize)
+                extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row,
+                           mi_col + hbs, mi_row, mi_col + hbs, mi_row_top,
+                           mi_col_top, i, dst_buf1[i], dst_stride1[i]);
+              else
+                extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row,
+                           mi_col + hbs, mi_row, mi_col + hbs, mi_row_top,
+                           mi_col_top, i, dst_buf1[i], dst_stride1[i], 2);
+
+              // smooth
+              xd->plane[i].dst.buf = dst_buf[i];
+              xd->plane[i].dst.stride = dst_stride[i];
+              av1_build_masked_inter_predictor_complex(
+                  xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i],
+                  mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
+                  PARTITION_VERT, i);
+            }
+#if CONFIG_CB4X4
           }
+#endif
         }
       }
       break;
     case PARTITION_SPLIT:
       if (bsize == BLOCK_8X8 && !unify_bsize) {
-        predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize,
-                         BLOCK_8X8, dry_run, 1, 0);
-        predict_b_extend(cpi, td, tile, 1, mi_row, mi_col, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf1, dst_stride1,
-                         top_bsize, BLOCK_8X8, dry_run, 1, 1);
-        predict_b_extend(cpi, td, tile, 2, mi_row, mi_col, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf2, dst_stride2,
-                         top_bsize, BLOCK_8X8, dry_run, 1, 1);
-        predict_b_extend(cpi, td, tile, 3, mi_row, mi_col, mi_row, mi_col,
-                         mi_row_top, mi_col_top, dst_buf3, dst_stride3,
-                         top_bsize, BLOCK_8X8, dry_run, 1, 1);
-
-        if (bsize < top_bsize) {
-          extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dry_run, dst_buf, dst_stride);
-          extend_all(cpi, td, tile, 1, subsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dry_run, dst_buf1, dst_stride1);
-          extend_all(cpi, td, tile, 2, subsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dry_run, dst_buf2, dst_stride2);
-          extend_all(cpi, td, tile, 3, subsize, top_bsize, mi_row, mi_col,
-                     mi_row_top, mi_col_top, dry_run, dst_buf3, dst_stride3);
+        for (i = 0; i < MAX_MB_PLANE; i++) {
+          predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
+                           mi_row_top, mi_col_top, i, dst_buf[i], dst_stride[i],
+                           top_bsize, BLOCK_8X8, dry_run, 1);
+          predict_b_extend(cpi, td, tile, 1, mi_row, mi_col, mi_row, mi_col,
+                           mi_row_top, mi_col_top, i, dst_buf1[i],
+                           dst_stride1[i], top_bsize, BLOCK_8X8, dry_run, 1);
+          predict_b_extend(cpi, td, tile, 2, mi_row, mi_col, mi_row, mi_col,
+                           mi_row_top, mi_col_top, i, dst_buf2[i],
+                           dst_stride2[i], top_bsize, BLOCK_8X8, dry_run, 1);
+          predict_b_extend(cpi, td, tile, 3, mi_row, mi_col, mi_row, mi_col,
+                           mi_row_top, mi_col_top, i, dst_buf3[i],
+                           dst_stride3[i], top_bsize, BLOCK_8X8, dry_run, 1);
+
+          if (bsize < top_bsize) {
+            extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
+                       mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                       dst_stride[i]);
+            extend_all(cpi, td, tile, 1, subsize, top_bsize, mi_row, mi_col,
+                       mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf1[i],
+                       dst_stride1[i]);
+            extend_all(cpi, td, tile, 2, subsize, top_bsize, mi_row, mi_col,
+                       mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf2[i],
+                       dst_stride2[i]);
+            extend_all(cpi, td, tile, 3, subsize, top_bsize, mi_row, mi_col,
+                       mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf3[i],
+                       dst_stride3[i]);
+          }
         }
+#if CONFIG_CB4X4
+      } else if (bsize == BLOCK_8X8) {
+        for (i = 0; i < MAX_MB_PLANE; i++) {
+          const struct macroblockd_plane *pd = &xd->plane[i];
+          int handle_chroma_sub8x8 = need_handle_chroma_sub8x8(
+              subsize, pd->subsampling_x, pd->subsampling_y);
+
+          if (handle_chroma_sub8x8) {
+            int mode_offset_row =
+                CONFIG_CHROMA_SUB8X8 && mi_row + hbs < cm->mi_rows ? hbs : 0;
+            int mode_offset_col =
+                CONFIG_CHROMA_SUB8X8 && mi_col + hbs < cm->mi_cols ? hbs : 0;
+
+            predict_b_extend(cpi, td, tile, 0, mi_row + mode_offset_row,
+                             mi_col + mode_offset_col, mi_row, mi_col,
+                             mi_row_top, mi_col_top, i, dst_buf[i],
+                             dst_stride[i], top_bsize, BLOCK_8X8, dry_run, 0);
+            if (bsize < top_bsize)
+              extend_all(cpi, td, tile, 0, BLOCK_8X8, top_bsize,
+                         mi_row + mode_offset_row, mi_col + mode_offset_col,
+                         mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                         dst_stride[i]);
+          } else {
+            predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
+                             mi_row_top, mi_col_top, i, dst_buf[i],
+                             dst_stride[i], top_bsize, subsize, dry_run, 0);
+            if (mi_row < cm->mi_rows && mi_col + hbs < cm->mi_cols)
+              predict_b_extend(cpi, td, tile, 0, mi_row, mi_col + hbs, mi_row,
+                               mi_col + hbs, mi_row_top, mi_col_top, i,
+                               dst_buf1[i], dst_stride1[i], top_bsize, subsize,
+                               dry_run, 0);
+            if (mi_row + hbs < cm->mi_rows && mi_col < cm->mi_cols)
+              predict_b_extend(cpi, td, tile, 0, mi_row + hbs, mi_col,
+                               mi_row + hbs, mi_col, mi_row_top, mi_col_top, i,
+                               dst_buf2[i], dst_stride2[i], top_bsize, subsize,
+                               dry_run, 0);
+            if (mi_row + hbs < cm->mi_rows && mi_col + hbs < cm->mi_cols)
+              predict_b_extend(cpi, td, tile, 0, mi_row + hbs, mi_col + hbs,
+                               mi_row + hbs, mi_col + hbs, mi_row_top,
+                               mi_col_top, i, dst_buf3[i], dst_stride3[i],
+                               top_bsize, subsize, dry_run, 0);
+
+            if (bsize < top_bsize) {
+              extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col,
+                         mi_row, mi_col, mi_row_top, mi_col_top, i, dst_buf[i],
+                         dst_stride[i]);
+              if (mi_row < cm->mi_rows && mi_col + hbs < cm->mi_cols)
+                extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row,
+                           mi_col + hbs, mi_row, mi_col + hbs, mi_row_top,
+                           mi_col_top, i, dst_buf1[i], dst_stride1[i]);
+              if (mi_row + hbs < cm->mi_rows && mi_col < cm->mi_cols)
+                extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row + hbs,
+                           mi_col, mi_row + hbs, mi_col, mi_row_top, mi_col_top,
+                           i, dst_buf2[i], dst_stride2[i]);
+              if (mi_row + hbs < cm->mi_rows && mi_col + hbs < cm->mi_cols)
+                extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row + hbs,
+                           mi_col + hbs, mi_row + hbs, mi_col + hbs, mi_row_top,
+                           mi_col_top, i, dst_buf3[i], dst_stride3[i]);
+            }
+          }
+        }
+#endif
       } else {
         predict_sb_complex(cpi, td, tile, mi_row, mi_col, mi_row_top,
                            mi_col_top, dry_run, subsize, top_bsize, dst_buf,
                            dst_stride, pc_tree->split[0]);
         if (mi_row < cm->mi_rows && mi_col + hbs < cm->mi_cols)
           predict_sb_complex(cpi, td, tile, mi_row, mi_col + hbs, mi_row_top,
                              mi_col_top, dry_run, subsize, top_bsize, dst_buf1,
                              dst_stride1, pc_tree->split[1]);
@@ -6309,39 +6670,42 @@ static void predict_sb_complex(const AV1
                              dst_stride2, pc_tree->split[2]);
         if (mi_row + hbs < cm->mi_rows && mi_col + hbs < cm->mi_cols)
           predict_sb_complex(cpi, td, tile, mi_row + hbs, mi_col + hbs,
                              mi_row_top, mi_col_top, dry_run, subsize,
                              top_bsize, dst_buf3, dst_stride3,
                              pc_tree->split[3]);
       }
       for (i = 0; i < MAX_MB_PLANE; i++) {
-#if !CONFIG_CB4X4
+#if CONFIG_CB4X4
+        const struct macroblockd_plane *pd = &xd->plane[i];
+        int handle_chroma_sub8x8 = need_handle_chroma_sub8x8(
+            subsize, pd->subsampling_x, pd->subsampling_y);
+        if (handle_chroma_sub8x8) continue;  // Skip <4x4 chroma smoothing
+#else
         if (bsize == BLOCK_8X8 && i != 0)
           continue;  // Skip <4x4 chroma smoothing
 #endif
+
         if (mi_row < cm->mi_rows && mi_col + hbs < cm->mi_cols) {
           av1_build_masked_inter_predictor_complex(
               xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i],
               mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
               PARTITION_VERT, i);
           if (mi_row + hbs < cm->mi_rows) {
             av1_build_masked_inter_predictor_complex(
                 xd, dst_buf2[i], dst_stride2[i], dst_buf3[i], dst_stride3[i],
                 mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
                 PARTITION_VERT, i);
             av1_build_masked_inter_predictor_complex(
                 xd, dst_buf[i], dst_stride[i], dst_buf2[i], dst_stride2[i],
                 mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
                 PARTITION_HORZ, i);
           }
         } else if (mi_row + hbs < cm->mi_rows && mi_col < cm->mi_cols) {
-          if (bsize == BLOCK_8X8 && i != 0)
-            continue;  // Skip <4x4 chroma smoothing
-
           av1_build_masked_inter_predictor_complex(
               xd, dst_buf[i], dst_stride[i], dst_buf2[i], dst_stride2[i],
               mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize,
               PARTITION_HORZ, i);
         }
       }
       break;
 #if CONFIG_EXT_PARTITION_TYPES
@@ -6655,28 +7019,27 @@ static void rd_supertx_sb(const AV1_COMP
     *tmp_rate = rate_uv + this_rate;
     *tmp_dist = dist_uv + this_dist;
     sse = sse_uv + pnsse;
     skippable = skippable_uv && pnskip;
     if (skippable) {
       *tmp_rate = av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
       x->skip = 1;
     } else {
-      if (RDCOST(x->rdmult, x->rddiv, *tmp_rate, *tmp_dist) <
-          RDCOST(x->rdmult, x->rddiv, 0, sse)) {
+      if (RDCOST(x->rdmult, *tmp_rate, *tmp_dist) < RDCOST(x->rdmult, 0, sse)) {
         *tmp_rate += av1_cost_bit(av1_get_skip_prob(cm, xd), 0);
         x->skip = 0;
       } else {
         *tmp_dist = sse;
         *tmp_rate = av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
         x->skip = 1;
       }
     }
     *tmp_rate += base_rate;
-    rd_tx = RDCOST(x->rdmult, x->rddiv, *tmp_rate, *tmp_dist);
+    rd_tx = RDCOST(x->rdmult, *tmp_rate, *tmp_dist);
     if (rd_tx < bestrd_tx * 0.99 || tx_type == DCT_DCT) {
       *best_tx = tx_type;
       bestrd_tx = rd_tx;
       tmp_rate_tx = *tmp_rate;
       tmp_dist_tx = *tmp_dist;
       skip_tx = x->skip;
     }
   }
--- a/third_party/aom/av1/encoder/encodemb.c
+++ b/third_party/aom/av1/encoder/encodemb.c
@@ -114,72 +114,59 @@ void av1_subtract_plane(MACROBLOCK *x, B
 static const int plane_rd_mult[REF_TYPES][PLANE_TYPES] = {
 #if CONFIG_EC_ADAPT
   { 10, 7 }, { 8, 5 },
 #else
   { 10, 6 }, { 8, 6 },
 #endif
 };
 
-#define UPDATE_RD_COST()                             \
-  {                                                  \
-    rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0); \
-    rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1); \
-  }
-
 static INLINE unsigned int get_token_bit_costs(
     unsigned int token_costs[2][COEFF_CONTEXTS][ENTROPY_TOKENS], int skip_eob,
     int ctx, int token) {
   (void)skip_eob;
   return token_costs[token == ZERO_TOKEN || token == EOB_TOKEN][ctx][token];
 }
 
 #if !CONFIG_LV_MAP
-#define USE_GREEDY_OPTIMIZE_B 0
-
-#if USE_GREEDY_OPTIMIZE_B
-
-typedef struct av1_token_state_greedy {
-  int16_t token;
-  tran_low_t qc;
-  tran_low_t dqc;
-} av1_token_state_greedy;
 
 static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
                              int block, TX_SIZE tx_size, int ctx) {
   MACROBLOCKD *const xd = &mb->e_mbd;
   struct macroblock_plane *const p = &mb->plane[plane];
   struct macroblockd_plane *const pd = &xd->plane[plane];
   const int ref = is_inter_block(&xd->mi[0]->mbmi);
-  av1_token_state_greedy tokens[MAX_TX_SQUARE + 1][2];
   uint8_t token_cache[MAX_TX_SQUARE];
   const tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
   tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
   tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
   const int eob = p->eobs[block];
   const PLANE_TYPE plane_type = pd->plane_type;
   const int16_t *const dequant_ptr = pd->dequant;
   const uint8_t *const band_translate = get_band_translate(tx_size);
   TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
   const SCAN_ORDER *const scan_order =
-      get_scan(cm, tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
+      get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
   const int16_t *const scan = scan_order->scan;
   const int16_t *const nb = scan_order->neighbors;
   int dqv;
   const int shift = av1_get_tx_scale(tx_size);
 #if CONFIG_AOM_QM
   int seg_id = xd->mi[0]->mbmi.segment_id;
-  const qm_val_t *iqmatrix = pd->seg_iqmatrix[seg_id][!ref][tx_size];
+  // Use a flat matrix (i.e. no weighting) for 1D and Identity transforms
+  const qm_val_t *iqmatrix =
+      IS_2D_TRANSFORM(tx_type)
+          ? pd->seg_iqmatrix[seg_id][!ref][tx_size]
+          : cm->giqmatrix[NUM_QM_LEVELS - 1][0][0][tx_size];
 #endif
 #if CONFIG_NEW_QUANT
   int dq = get_dq_profile_from_ctx(mb->qindex, ctx, ref, plane_type);
   const dequant_val_type_nuq *dequant_val = pd->dequant_val_nuq[dq];
 #endif  // CONFIG_NEW_QUANT
   int sz = 0;
-  const int64_t rddiv = mb->rddiv;
   int64_t rd_cost0, rd_cost1;
   int16_t t0, t1;
   int i, final_eob;
   const int cat6_bits = av1_get_cat6_extrabits_size(tx_size, xd->bd);
   unsigned int(*token_costs)[2][COEFF_CONTEXTS][ENTROPY_TOKENS] =
       mb->token_costs[txsize_sqr_map[tx_size]][plane_type][ref];
   const int default_eob = tx_size_2d[tx_size];
 
@@ -188,73 +175,64 @@ static int optimize_b_greedy(const AV1_C
   assert((!plane_type && !plane) || (plane_type && plane));
   assert(eob <= default_eob);
 
   int64_t rdmult = (mb->rdmult * plane_rd_mult[ref][plane_type]) >> 1;
 
   int64_t rate0, rate1;
   for (i = 0; i < eob; i++) {
     const int rc = scan[i];
-    int x = qcoeff[rc];
-    t0 = av1_get_token(x);
-
-    tokens[i][0].qc = x;
-    tokens[i][0].token = t0;
-    tokens[i][0].dqc = dqcoeff[rc];
-
-    token_cache[rc] = av1_pt_energy_class[t0];
+    token_cache[rc] = av1_pt_energy_class[av1_get_token(qcoeff[rc])];
   }
-  tokens[eob][0].token = EOB_TOKEN;
-  tokens[eob][0].qc = 0;
-  tokens[eob][0].dqc = 0;
-  tokens[eob][1] = tokens[eob][0];
 
   unsigned int(*token_costs_ptr)[2][COEFF_CONTEXTS][ENTROPY_TOKENS] =
       token_costs;
 
   final_eob = 0;
 
   int64_t eob_cost0, eob_cost1;
+  tran_low_t before_best_eob_qc = 0;
+  tran_low_t before_best_eob_dqc = 0;
 
   const int ctx0 = ctx;
   /* Record the r-d cost */
   int64_t accu_rate = 0;
-  int64_t accu_error = 0;
+  // Initialized to the worst possible error for the largest transform size.
+  // This ensures that it never goes negative.
+  int64_t accu_error = ((int64_t)1) << 50;
 
   rate0 = get_token_bit_costs(*(token_costs_ptr + band_translate[0]), 0, ctx0,
                               EOB_TOKEN);
-  int64_t best_block_rd_cost = RDCOST(rdmult, rddiv, rate0, accu_error);
+  int64_t best_block_rd_cost = RDCOST(rdmult, rate0, accu_error);
 
   // int64_t best_block_rd_cost_all0 = best_block_rd_cost;
-
   int x_prev = 1;
-
   for (i = 0; i < eob; i++) {
     const int rc = scan[i];
     int x = qcoeff[rc];
     sz = -(x < 0);
 
     int band_cur = band_translate[i];
     int ctx_cur = (i == 0) ? ctx : get_coef_context(nb, token_cache, i);
     int token_tree_sel_cur = (x_prev == 0);
 
     if (x == 0) {
       // no need to search when x == 0
-      rate0 =
-          get_token_bit_costs(*(token_costs_ptr + band_cur), token_tree_sel_cur,
-                              ctx_cur, tokens[i][0].token);
+      int token = av1_get_token(x);
+      rate0 = get_token_bit_costs(*(token_costs_ptr + band_cur),
+                                  token_tree_sel_cur, ctx_cur, token);
       accu_rate += rate0;
       x_prev = 0;
       // accu_error does not change when x==0
     } else {
       /*  Computing distortion
        */
       // compute the distortion for the first candidate
       // and the distortion for quantizing to 0.
-      int dx0 = (-coeff[rc]) * (1 << shift);
+      int dx0 = abs(coeff[rc]) * (1 << shift);
 #if CONFIG_HIGHBITDEPTH
       if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
         dx0 >>= xd->bd - 8;
       }
 #endif
       int64_t d0 = (int64_t)dx0 * dx0;
 
       int x_a = x - 2 * sz - 1;
@@ -268,17 +246,19 @@ static int optimize_b_greedy(const AV1_C
       dqv = ((iwt * (int)dqv) + (1 << (AOM_QM_BITS - 1))) >> AOM_QM_BITS;
 #else
       dqv = dequant_ptr[rc != 0];
 #endif
 
       dx = (dqcoeff[rc] - coeff[rc]) * (1 << shift);
 #if CONFIG_HIGHBITDEPTH
       if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-        dx >>= xd->bd - 8;
+        int dx_sign = dx < 0 ? 1 : 0;
+        dx = abs(dx) >> (xd->bd - 8);
+        if (dx_sign) dx = -dx;
       }
 #endif  // CONFIG_HIGHBITDEPTH
       d2 = (int64_t)dx * dx;
 
       /* compute the distortion for the second candidate
        * x_a = x - 2 * sz + 1;
        */
       if (x_a != 0) {
@@ -324,53 +304,55 @@ static int optimize_b_greedy(const AV1_C
       next_bits0 = 0;
       next_bits1 = 0;
       next_eob_bits0 = 0;
       next_eob_bits1 = 0;
 
       if (i < default_eob - 1) {
         int ctx_next, token_tree_sel_next;
         int band_next = band_translate[i + 1];
+        int token_next =
+            i + 1 != eob ? av1_get_token(qcoeff[scan[i + 1]]) : EOB_TOKEN;
 
         token_cache[rc] = av1_pt_energy_class[t0];
         ctx_next = get_coef_context(nb, token_cache, i + 1);
         token_tree_sel_next = (x == 0);
 
-        next_bits0 = get_token_bit_costs(*(token_costs_ptr + band_next),
-                                         token_tree_sel_next, ctx_next,
-                                         tokens[i + 1][0].token);
+        next_bits0 =
+            get_token_bit_costs(*(token_costs_ptr + band_next),
+                                token_tree_sel_next, ctx_next, token_next);
         next_eob_bits0 =
             get_token_bit_costs(*(token_costs_ptr + band_next),
                                 token_tree_sel_next, ctx_next, EOB_TOKEN);
 
         token_cache[rc] = av1_pt_energy_class[t1];
         ctx_next = get_coef_context(nb, token_cache, i + 1);
         token_tree_sel_next = (x_a == 0);
 
-        next_bits1 = get_token_bit_costs(*(token_costs_ptr + band_next),
-                                         token_tree_sel_next, ctx_next,
-                                         tokens[i + 1][0].token);
+        next_bits1 =
+            get_token_bit_costs(*(token_costs_ptr + band_next),
+                                token_tree_sel_next, ctx_next, token_next);
 
         if (x_a != 0) {
           next_eob_bits1 =
               get_token_bit_costs(*(token_costs_ptr + band_next),
                                   token_tree_sel_next, ctx_next, EOB_TOKEN);
         }
       }
 
-      rd_cost0 = RDCOST(rdmult, rddiv, (rate0 + next_bits0), d2);
-      rd_cost1 = RDCOST(rdmult, rddiv, (rate1 + next_bits1), d2_a);
+      rd_cost0 = RDCOST(rdmult, (rate0 + next_bits0), d2);
+      rd_cost1 = RDCOST(rdmult, (rate1 + next_bits1), d2_a);
 
       best_x = (rd_cost1 < rd_cost0);
 
-      eob_cost0 = RDCOST(rdmult, rddiv, (accu_rate + rate0 + next_eob_bits0),
+      eob_cost0 = RDCOST(rdmult, (accu_rate + rate0 + next_eob_bits0),
                          (accu_error + d2 - d0));
       eob_cost1 = eob_cost0;
       if (x_a != 0) {
-        eob_cost1 = RDCOST(rdmult, rddiv, (accu_rate + rate1 + next_eob_bits1),
+        eob_cost1 = RDCOST(rdmult, (accu_rate + rate1 + next_eob_bits1),
                            (accu_error + d2_a - d0));
         best_eob_x = (eob_cost1 < eob_cost0);
       } else {
         best_eob_x = 0;
       }
 
       int dqc, dqc_a = 0;
 
@@ -405,449 +387,92 @@ static int optimize_b_greedy(const AV1_C
         token_cache[rc] = av1_pt_energy_class[t1];
       } else {
         accu_rate += rate0;
         accu_error += d2 - d0;
         assert(d2 <= d0);
 
         token_cache[rc] = av1_pt_energy_class[t0];
       }
+      assert(accu_error >= 0);
 
       x_prev = qcoeff[rc];
 
       // determine whether to move the eob position to i+1
-      int64_t best_eob_cost_i = eob_cost0;
-
-      tokens[i][1].token = t0;
-      tokens[i][1].qc = x;
-      tokens[i][1].dqc = dqc;
-
-      if ((x_a != 0) && (best_eob_x)) {
-        best_eob_cost_i = eob_cost1;
-
-        tokens[i][1].token = t1;
-        tokens[i][1].qc = x_a;
-        tokens[i][1].dqc = dqc_a;
-      }
+      int use_a = (x_a != 0) && (best_eob_x);
+      int64_t best_eob_cost_i = use_a ? eob_cost1 : eob_cost0;
 
       if (best_eob_cost_i < best_block_rd_cost) {
         best_block_rd_cost = best_eob_cost_i;
         final_eob = i + 1;
+        if (use_a) {
+          before_best_eob_qc = x_a;
+          before_best_eob_dqc = dqc_a;
+        } else {
+          before_best_eob_qc = x;
+          before_best_eob_dqc = dqc;
+        }
       }
     }  // if (x==0)
   }    // for (i)
 
   assert(final_eob <= eob);
   if (final_eob > 0) {
-    assert(tokens[final_eob - 1][1].qc != 0);
+    assert(before_best_eob_qc != 0);
     i = final_eob - 1;
     int rc = scan[i];
-    qcoeff[rc] = tokens[i][1].qc;
-    dqcoeff[rc] = tokens[i][1].dqc;
+    qcoeff[rc] = before_best_eob_qc;
+    dqcoeff[rc] = before_best_eob_dqc;
   }
 
   for (i = final_eob; i < eob; i++) {
     int rc = scan[i];
     qcoeff[rc] = 0;
     dqcoeff[rc] = 0;
   }
 
   mb->plane[plane].eobs[block] = final_eob;
   return final_eob;
 }
-
-#else  // USE_GREEDY_OPTIMIZE_B
-
-typedef struct av1_token_state_org {
-  int64_t error;
-  int rate;
-  int16_t next;
-  int16_t token;
-  tran_low_t qc;
-  tran_low_t dqc;
-  uint8_t best_index;
-} av1_token_state_org;
-
-static int optimize_b_org(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
-                          int block, TX_SIZE tx_size, int ctx) {
-  MACROBLOCKD *const xd = &mb->e_mbd;
-  struct macroblock_plane *const p = &mb->plane[plane];
-  struct macroblockd_plane *const pd = &xd->plane[plane];
-  const int ref = is_inter_block(&xd->mi[0]->mbmi);
-  av1_token_state_org tokens[MAX_TX_SQUARE + 1][2];
-  uint8_t token_cache[MAX_TX_SQUARE];
-  const tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
-  tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
-  tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
-  const int eob = p->eobs[block];
-  const PLANE_TYPE plane_type = pd->plane_type;
-  const int default_eob = tx_size_2d[tx_size];
-  const int16_t *const dequant_ptr = pd->dequant;
-  const uint8_t *const band_translate = get_band_translate(tx_size);
-  TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
-  const SCAN_ORDER *const scan_order =
-      get_scan(cm, tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
-  const int16_t *const scan = scan_order->scan;
-  const int16_t *const nb = scan_order->neighbors;
-  int dqv;
-  const int shift = av1_get_tx_scale(tx_size);
-#if CONFIG_AOM_QM
-  int seg_id = xd->mi[0]->mbmi.segment_id;
-  const qm_val_t *iqmatrix = pd->seg_iqmatrix[seg_id][!ref][tx_size];
-#endif
-#if CONFIG_NEW_QUANT
-  int dq = get_dq_profile_from_ctx(mb->qindex, ctx, ref, plane_type);
-  const dequant_val_type_nuq *dequant_val = pd->dequant_val_nuq[dq];
-#endif  // CONFIG_NEW_QUANT
-  int next = eob, sz = 0;
-  const int64_t rdmult = (mb->rdmult * plane_rd_mult[ref][plane_type]) >> 1;
-  const int64_t rddiv = mb->rddiv;
-  int64_t rd_cost0, rd_cost1;
-  int rate0, rate1;
-  int64_t error0, error1;
-  int16_t t0, t1;
-  int best, band = (eob < default_eob) ? band_translate[eob]
-                                       : band_translate[eob - 1];
-  int pt, i, final_eob;
-  const int cat6_bits = av1_get_cat6_extrabits_size(tx_size, xd->bd);
-  unsigned int(*token_costs)[2][COEFF_CONTEXTS][ENTROPY_TOKENS] =
-      mb->token_costs[txsize_sqr_map[tx_size]][plane_type][ref];
-  const uint16_t *band_counts = &band_count_table[tx_size][band];
-  uint16_t band_left = eob - band_cum_count_table[tx_size][band] + 1;
-  int shortcut = 0;
-  int next_shortcut = 0;
-
-#if CONFIG_EXT_DELTA_Q
-  const int qindex = cm->seg.enabled
-                         ? av1_get_qindex(&cm->seg, xd->mi[0]->mbmi.segment_id,
-                                          cm->base_qindex)
-                         : cm->base_qindex;
-  assert(qindex > 0);
-  (void)qindex;
-#else
-  assert(mb->qindex > 0);
-#endif
-
-  token_costs += band;
-
-  assert((!plane_type && !plane) || (plane_type && plane));
-  assert(eob <= default_eob);
-
-  /* Now set up a Viterbi trellis to evaluate alternative roundings. */
-  /* Initialize the sentinel node of the trellis. */
-  tokens[eob][0].rate = 0;
-  tokens[eob][0].error = 0;
-  tokens[eob][0].next = default_eob;
-  tokens[eob][0].token = EOB_TOKEN;
-  tokens[eob][0].qc = 0;
-  tokens[eob][1] = tokens[eob][0];
-
-  for (i = 0; i < eob; i++) {
-    const int rc = scan[i];
-    tokens[i][0].rate = av1_get_token_cost(qcoeff[rc], &t0, cat6_bits);
-    tokens[i][0].token = t0;
-    token_cache[rc] = av1_pt_energy_class[t0];
-  }
-
-  for (i = eob; i-- > 0;) {
-    int base_bits, dx;
-    int64_t d2;
-    const int rc = scan[i];
-    int x = qcoeff[rc];
-#if CONFIG_AOM_QM
-    int iwt = iqmatrix[rc];
-    dqv = dequant_ptr[rc != 0];
-    dqv = ((iwt * (int)dqv) + (1 << (AOM_QM_BITS - 1))) >> AOM_QM_BITS;
-#else
-    dqv = dequant_ptr[rc != 0];
-#endif
-    next_shortcut = shortcut;
-
-    /* Only add a trellis state for non-zero coefficients. */
-    if (UNLIKELY(x)) {
-      error0 = tokens[next][0].error;
-      error1 = tokens[next][1].error;
-      /* Evaluate the first possibility for this state. */
-      rate0 = tokens[next][0].rate;
-      rate1 = tokens[next][1].rate;
-
-      if (next_shortcut) {
-        /* Consider both possible successor states. */
-        if (next < default_eob) {
-          pt = get_coef_context(nb, token_cache, i + 1);
-          rate0 +=
-              get_token_bit_costs(*token_costs, 0, pt, tokens[next][0].token);
-          rate1 +=
-              get_token_bit_costs(*token_costs, 0, pt, tokens[next][1].token);
-        }
-        UPDATE_RD_COST();
-        /* And pick the best. */
-        best = rd_cost1 < rd_cost0;
-      } else {
-        if (next < default_eob) {
-          pt = get_coef_context(nb, token_cache, i + 1);
-          rate0 +=
-              get_token_bit_costs(*token_costs, 0, pt, tokens[next][0].token);
-        }
-        best = 0;
-      }
-
-      dx = (dqcoeff[rc] - coeff[rc]) * (1 << shift);
-#if CONFIG_HIGHBITDEPTH
-      if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-        dx >>= xd->bd - 8;
-      }
-#endif  // CONFIG_HIGHBITDEPTH
-      d2 = (int64_t)dx * dx;
-      tokens[i][0].rate += (best ? rate1 : rate0);
-      tokens[i][0].error = d2 + (best ? error1 : error0);
-      tokens[i][0].next = next;
-      tokens[i][0].qc = x;
-      tokens[i][0].dqc = dqcoeff[rc];
-      tokens[i][0].best_index = best;
-
-      /* Evaluate the second possibility for this state. */
-      rate0 = tokens[next][0].rate;
-      rate1 = tokens[next][1].rate;
-
-      // The threshold of 3 is empirically obtained.
-      if (UNLIKELY(abs(x) > 3)) {
-        shortcut = 0;
-      } else {
-#if CONFIG_NEW_QUANT
-        shortcut = ((av1_dequant_abscoeff_nuq(abs(x), dqv,
-                                              dequant_val[band_translate[i]]) >
-                     (abs(coeff[rc]) << shift)) &&
-                    (av1_dequant_abscoeff_nuq(abs(x) - 1, dqv,
-                                              dequant_val[band_translate[i]]) <
-                     (abs(coeff[rc]) << shift)));
-#else  // CONFIG_NEW_QUANT
-#if CONFIG_AOM_QM
-        if ((abs(x) * dequant_ptr[rc != 0] * iwt >
-             ((abs(coeff[rc]) << shift) << AOM_QM_BITS)) &&
-            (abs(x) * dequant_ptr[rc != 0] * iwt <
-             (((abs(coeff[rc]) << shift) + dequant_ptr[rc != 0])
-              << AOM_QM_BITS)))
-#else
-        if ((abs(x) * dequant_ptr[rc != 0] > (abs(coeff[rc]) << shift)) &&
-            (abs(x) * dequant_ptr[rc != 0] <
-             (abs(coeff[rc]) << shift) + dequant_ptr[rc != 0]))
-#endif  // CONFIG_AOM_QM
-          shortcut = 1;
-        else
-          shortcut = 0;
-#endif  // CONFIG_NEW_QUANT
-      }
-
-      if (shortcut) {
-        sz = -(x < 0);
-        x -= 2 * sz + 1;
-      } else {
-        tokens[i][1] = tokens[i][0];
-        next = i;
-
-        if (UNLIKELY(!(--band_left))) {
-          --band_counts;
-          band_left = *band_counts;
-          --token_costs;
-        }
-        continue;
-      }
-
-      /* Consider both possible successor states. */
-      if (!x) {
-        /* If we reduced this coefficient to zero, check to see if
-         *  we need to move the EOB back here.
-         */
-        t0 = tokens[next][0].token == EOB_TOKEN ? EOB_TOKEN : ZERO_TOKEN;
-        t1 = tokens[next][1].token == EOB_TOKEN ? EOB_TOKEN : ZERO_TOKEN;
-        base_bits = 0;
-      } else {
-        base_bits = av1_get_token_cost(x, &t0, cat6_bits);
-        t1 = t0;
-      }
-
-      if (next_shortcut) {
-        if (LIKELY(next < default_eob)) {
-          if (t0 != EOB_TOKEN) {
-            token_cache[rc] = av1_pt_energy_class[t0];
-            pt = get_coef_context(nb, token_cache, i + 1);
-            rate0 += get_token_bit_costs(*token_costs, !x, pt,
-                                         tokens[next][0].token);
-          }
-          if (t1 != EOB_TOKEN) {
-            token_cache[rc] = av1_pt_energy_class[t1];
-            pt = get_coef_context(nb, token_cache, i + 1);
-            rate1 += get_token_bit_costs(*token_costs, !x, pt,
-                                         tokens[next][1].token);
-          }
-        }
-
-        UPDATE_RD_COST();
-        /* And pick the best. */
-        best = rd_cost1 < rd_cost0;
-      } else {
-        // The two states in next stage are identical.
-        if (next < default_eob && t0 != EOB_TOKEN) {
-          token_cache[rc] = av1_pt_energy_class[t0];
-          pt = get_coef_context(nb, token_cache, i + 1);
-          rate0 +=
-              get_token_bit_costs(*token_costs, !x, pt, tokens[next][0].token);
-        }
-        best = 0;
-      }
-
-#if CONFIG_NEW_QUANT
-      dx = av1_dequant_coeff_nuq(x, dqv, dequant_val[band_translate[i]]) -
-           (coeff[rc] << shift);
-#if CONFIG_HIGHBITDEPTH
-      if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-        dx >>= xd->bd - 8;
-      }
-#endif  // CONFIG_HIGHBITDEPTH
-#else   // CONFIG_NEW_QUANT
-#if CONFIG_HIGHBITDEPTH
-      if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-        dx -= ((dqv >> (xd->bd - 8)) + sz) ^ sz;
-      } else {
-        dx -= (dqv + sz) ^ sz;
-      }
-#else
-      dx -= (dqv + sz) ^ sz;
-#endif  // CONFIG_HIGHBITDEPTH
-#endif  // CONFIG_NEW_QUANT
-      d2 = (int64_t)dx * dx;
-
-      tokens[i][1].rate = base_bits + (best ? rate1 : rate0);
-      tokens[i][1].error = d2 + (best ? error1 : error0);
-      tokens[i][1].next = next;
-      tokens[i][1].token = best ? t1 : t0;
-      tokens[i][1].qc = x;
-
-      if (x) {
-#if CONFIG_NEW_QUANT
-        tokens[i][1].dqc = av1_dequant_abscoeff_nuq(
-            abs(x), dqv, dequant_val[band_translate[i]]);
-        tokens[i][1].dqc = shift ? ROUND_POWER_OF_TWO(tokens[i][1].dqc, shift)
-                                 : tokens[i][1].dqc;
-        if (sz) tokens[i][1].dqc = -tokens[i][1].dqc;
-#else
-        if (x < 0)
-          tokens[i][1].dqc = -((-x * dqv) >> shift);
-        else
-          tokens[i][1].dqc = (x * dqv) >> shift;
-#endif  // CONFIG_NEW_QUANT
-      } else {
-        tokens[i][1].dqc = 0;
-      }
-
-      tokens[i][1].best_index = best;
-      /* Finally, make this the new head of the trellis. */
-      next = i;
-    } else {
-      /* There's no choice to make for a zero coefficient, so we don't
-       *  add a new trellis node, but we do need to update the costs.
-       */
-      t0 = tokens[next][0].token;
-      t1 = tokens[next][1].token;
-      pt = get_coef_context(nb, token_cache, i + 1);
-      /* Update the cost of each path if we're past the EOB token. */
-      if (t0 != EOB_TOKEN) {
-        tokens[next][0].rate += get_token_bit_costs(*token_costs, 1, pt, t0);
-        tokens[next][0].token = ZERO_TOKEN;
-      }
-      if (t1 != EOB_TOKEN) {
-        tokens[next][1].rate += get_token_bit_costs(*token_costs, 1, pt, t1);
-        tokens[next][1].token = ZERO_TOKEN;
-      }
-      tokens[i][0].best_index = tokens[i][1].best_index = 0;
-      shortcut = (tokens[next][0].rate != tokens[next][1].rate);
-      /* Don't update next, because we didn't add a new node. */
-    }
-
-    if (UNLIKELY(!(--band_left))) {
-      --band_counts;
-      band_left = *band_counts;
-      --token_costs;
-    }
-  }
-
-  /* Now pick the best path through the whole trellis. */
-  rate0 = tokens[next][0].rate;
-  rate1 = tokens[next][1].rate;
-  error0 = tokens[next][0].error;
-  error1 = tokens[next][1].error;
-  t0 = tokens[next][0].token;
-  t1 = tokens[next][1].token;
-  rate0 += get_token_bit_costs(*token_costs, 0, ctx, t0);
-  rate1 += get_token_bit_costs(*token_costs, 0, ctx, t1);
-  UPDATE_RD_COST();
-  best = rd_cost1 < rd_cost0;
-
-  final_eob = -1;
-
-  for (i = next; i < eob; i = next) {
-    const int x = tokens[i][best].qc;
-    const int rc = scan[i];
-    if (x) final_eob = i;
-    qcoeff[rc] = x;
-    dqcoeff[rc] = tokens[i][best].dqc;
-
-    next = tokens[i][best].next;
-    best = tokens[i][best].best_index;
-  }
-  final_eob++;
-
-  mb->plane[plane].eobs[block] = final_eob;
-  assert(final_eob <= default_eob);
-  return final_eob;
-}
-
-#endif  // USE_GREEDY_OPTIMIZE_B
 #endif  // !CONFIG_LV_MAP
 
 int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int block,
                    BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
                    const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l) {
   MACROBLOCKD *const xd = &mb->e_mbd;
   struct macroblock_plane *const p = &mb->plane[plane];
   const int eob = p->eobs[block];
   assert((mb->qindex == 0) ^ (xd->lossless[xd->mi[0]->mbmi.segment_id] == 0));
   if (eob == 0) return eob;
   if (xd->lossless[xd->mi[0]->mbmi.segment_id]) return eob;
+
 #if CONFIG_PVQ
   (void)cm;
   (void)tx_size;
   (void)a;
   (void)l;
   return eob;
 #endif
 
 #if !CONFIG_LV_MAP
   (void)plane_bsize;
 #if CONFIG_VAR_TX
   int ctx = get_entropy_context(tx_size, a, l);
 #else
   int ctx = combine_entropy_contexts(*a, *l);
-#endif
-
-#if USE_GREEDY_OPTIMIZE_B
+#endif  // CONFIG_VAR_TX
   return optimize_b_greedy(cm, mb, plane, block, tx_size, ctx);
-#else   // USE_GREEDY_OPTIMIZE_B
-  return optimize_b_org(cm, mb, plane, block, tx_size, ctx);
-#endif  // USE_GREEDY_OPTIMIZE_B
 #else   // !CONFIG_LV_MAP
   TXB_CTX txb_ctx;
   get_txb_ctx(plane_bsize, tx_size, plane, a, l, &txb_ctx);
   return av1_optimize_txb(cm, mb, plane, block, tx_size, &txb_ctx);
 #endif  // !CONFIG_LV_MAP
 }
 
 #if !CONFIG_PVQ
-#if CONFIG_HIGHBITDEPTH
 typedef enum QUANT_FUNC {
   QUANT_FUNC_LOWBD = 0,
   QUANT_FUNC_HIGHBD = 1,
   QUANT_FUNC_TYPES = 2
 } QUANT_FUNC;
 
 static AV1_QUANT_FACADE
     quant_func_list[AV1_XFORM_QUANT_TYPES][QUANT_FUNC_TYPES] = {
@@ -857,77 +482,73 @@ static AV1_QUANT_FACADE
       { av1_quantize_dc_facade, av1_highbd_quantize_dc_facade },
 #else   // !CONFIG_NEW_QUANT
       { av1_quantize_fp_nuq_facade, av1_highbd_quantize_fp_nuq_facade },
       { av1_quantize_b_nuq_facade, av1_highbd_quantize_b_nuq_facade },
       { av1_quantize_dc_nuq_facade, av1_highbd_quantize_dc_nuq_facade },
 #endif  // !CONFIG_NEW_QUANT
       { NULL, NULL }
     };
-
-#else
-
-typedef enum QUANT_FUNC {
-  QUANT_FUNC_LOWBD = 0,
-  QUANT_FUNC_TYPES = 1
-} QUANT_FUNC;
+#endif  // !CONFIG_PVQ
 
-static AV1_QUANT_FACADE quant_func_list[AV1_XFORM_QUANT_TYPES]
-                                       [QUANT_FUNC_TYPES] = {
-#if !CONFIG_NEW_QUANT
-                                         { av1_quantize_fp_facade },
-                                         { av1_quantize_b_facade },
-                                         { av1_quantize_dc_facade },
-#else   // !CONFIG_NEW_QUANT
-                                         { av1_quantize_fp_nuq_facade },
-                                         { av1_quantize_b_nuq_facade },
-                                         { av1_quantize_dc_nuq_facade },
-#endif  // !CONFIG_NEW_QUANT
-                                         { NULL }
-                                       };
-#endif  // CONFIG_HIGHBITDEPTH
-#endif  // CONFIG_PVQ
+typedef void (*fwdTxfmFunc)(const int16_t *diff, tran_low_t *coeff, int stride,
+                            FWD_TXFM_PARAM *param);
+static const fwdTxfmFunc fwd_txfm_func[2] = { av1_fwd_txfm,
+                                              av1_highbd_fwd_txfm };
 
 void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
                      int blk_row, int blk_col, BLOCK_SIZE plane_bsize,
                      TX_SIZE tx_size, int ctx,
                      AV1_XFORM_QUANT xform_quant_idx) {
   MACROBLOCKD *const xd = &x->e_mbd;
   MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
 #if !(CONFIG_PVQ || CONFIG_DAALA_DIST)
   const struct macroblock_plane *const p = &x->plane[plane];
   const struct macroblockd_plane *const pd = &xd->plane[plane];
 #else
   struct macroblock_plane *const p = &x->plane[plane];
   struct macroblockd_plane *const pd = &xd->plane[plane];
 #endif
   PLANE_TYPE plane_type = get_plane_type(plane);
   TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
+
+#if CONFIG_AOM_QM || CONFIG_NEW_QUANT
   const int is_inter = is_inter_block(mbmi);
-  const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, is_inter);
+#endif
+
+  const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
   tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
   tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
   tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
   uint16_t *const eob = &p->eobs[block];
   const int diff_stride = block_size_wide[plane_bsize];
 #if CONFIG_AOM_QM
   int seg_id = mbmi->segment_id;
-  const qm_val_t *qmatrix = pd->seg_qmatrix[seg_id][!is_inter][tx_size];
-  const qm_val_t *iqmatrix = pd->seg_iqmatrix[seg_id][!is_inter][tx_size];
+  // Use a flat matrix (i.e. no weighting) for 1D and Identity transforms
+  const qm_val_t *qmatrix =
+      IS_2D_TRANSFORM(tx_type) ? pd->seg_qmatrix[seg_id][!is_inter][tx_size]
+                               : cm->gqmatrix[NUM_QM_LEVELS - 1][0][0][tx_size];
+  const qm_val_t *iqmatrix =
+      IS_2D_TRANSFORM(tx_type)
+          ? pd->seg_iqmatrix[seg_id][!is_inter][tx_size]
+          : cm->giqmatrix[NUM_QM_LEVELS - 1][0][0][tx_size];
 #endif
 
   FWD_TXFM_PARAM fwd_txfm_param;
 
+#if CONFIG_PVQ || CONFIG_DAALA_DIST || CONFIG_LGT
+  uint8_t *dst;
+  const int dst_stride = pd->dst.stride;
 #if CONFIG_PVQ || CONFIG_DAALA_DIST
-  uint8_t *dst;
   int16_t *pred;
-  const int dst_stride = pd->dst.stride;
-  int tx_blk_size;
+  const int txw = tx_size_wide[tx_size];
+  const int txh = tx_size_high[tx_size];
   int i, j;
 #endif
+#endif
 
 #if !CONFIG_PVQ
   const int tx2d_size = tx_size_2d[tx_size];
   QUANT_PARAM qparam;
   const int16_t *src_diff;
 
   src_diff =
       &p->src_diff[(blk_row * diff_stride + blk_col) << tx_size_wide_log2[0]];
@@ -955,99 +576,87 @@ void av1_xform_quant(const AV1_COMMON *c
   if (x->pvq_coded) {
     assert(block < MAX_PVQ_BLOCKS_IN_SB);
     pvq_info = &x->pvq[block][plane];
   }
   src = &p->src.buf[(blk_row * src_stride + blk_col) << tx_size_wide_log2[0]];
   src_int16 =
       &p->src_int16[(blk_row * diff_stride + blk_col) << tx_size_wide_log2[0]];
 
-  // transform block size in pixels
-  tx_blk_size = tx_size_wide[tx_size];
 #if CONFIG_HIGHBITDEPTH
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-    for (j = 0; j < tx_blk_size; j++)
-      for (i = 0; i < tx_blk_size; i++)
+    for (j = 0; j < txh; j++)
+      for (i = 0; i < txw; i++)
         src_int16[diff_stride * j + i] =
             CONVERT_TO_SHORTPTR(src)[src_stride * j + i];
   } else {
 #endif  // CONFIG_HIGHBITDEPTH
-    for (j = 0; j < tx_blk_size; j++)
-      for (i = 0; i < tx_blk_size; i++)
+    for (j = 0; j < txh; j++)
+      for (i = 0; i < txw; i++)
         src_int16[diff_stride * j + i] = src[src_stride * j + i];
 #if CONFIG_HIGHBITDEPTH
   }
 #endif  // CONFIG_HIGHBITDEPTH
 #endif
 
+#if CONFIG_PVQ || CONFIG_DAALA_DIST || CONFIG_LGT
+  dst = &pd->dst.buf[(blk_row * dst_stride + blk_col) << tx_size_wide_log2[0]];
 #if CONFIG_PVQ || CONFIG_DAALA_DIST
-  dst = &pd->dst.buf[(blk_row * dst_stride + blk_col) << tx_size_wide_log2[0]];
   pred = &pd->pred[(blk_row * diff_stride + blk_col) << tx_size_wide_log2[0]];
 
-  // transform block size in pixels
-  tx_blk_size = tx_size_wide[tx_size];
-
 // copy uint8 orig and predicted block to int16 buffer
 // in order to use existing VP10 transform functions
 #if CONFIG_HIGHBITDEPTH
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-    for (j = 0; j < tx_blk_size; j++)
-      for (i = 0; i < tx_blk_size; i++)
+    for (j = 0; j < txh; j++)
+      for (i = 0; i < txw; i++)
         pred[diff_stride * j + i] =
             CONVERT_TO_SHORTPTR(dst)[dst_stride * j + i];
   } else {
 #endif  // CONFIG_HIGHBITDEPTH
-    for (j = 0; j < tx_blk_size; j++)
-      for (i = 0; i < tx_blk_size; i++)
+    for (j = 0; j < txh; j++)
+      for (i = 0; i < txw; i++)
         pred[diff_stride * j + i] = dst[dst_stride * j + i];
 #if CONFIG_HIGHBITDEPTH
   }
 #endif  // CONFIG_HIGHBITDEPTH
-#endif
+#endif  // CONFIG_PVQ || CONFIG_DAALA_DIST
+#endif  // CONFIG_PVQ || CONFIG_DAALA_DIST || CONFIG_LGT
 
   (void)ctx;
 
   fwd_txfm_param.tx_type = tx_type;
   fwd_txfm_param.tx_size = tx_size;
   fwd_txfm_param.lossless = xd->lossless[mbmi->segment_id];
+#if CONFIG_LGT
+  fwd_txfm_param.is_inter = is_inter_block(mbmi);
+  fwd_txfm_param.dst = dst;
+  fwd_txfm_param.stride = dst_stride;
+  fwd_txfm_param.mode = get_prediction_mode(xd->mi[0], plane, tx_size, block);
+#endif
 
 #if !CONFIG_PVQ
-#if CONFIG_HIGHBITDEPTH
   fwd_txfm_param.bd = xd->bd;
-  if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-    av1_highbd_fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param);
-    if (xform_quant_idx != AV1_XFORM_QUANT_SKIP_QUANT) {
-      if (LIKELY(!x->skip_block)) {
-        quant_func_list[xform_quant_idx][QUANT_FUNC_HIGHBD](
-            coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order, &qparam);
-      } else {
-        av1_quantize_skip(tx2d_size, qcoeff, dqcoeff, eob);
-      }
-    }
-#if CONFIG_LV_MAP
-    p->txb_entropy_ctx[block] =
-        (uint8_t)av1_get_txb_entropy_context(qcoeff, scan_order, *eob);
-#endif  // CONFIG_LV_MAP
-    return;
-  }
-#endif  // CONFIG_HIGHBITDEPTH
-  av1_fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param);
+  const int is_hbd = get_bitdepth_data_path_index(xd);
+  fwd_txfm_func[is_hbd](src_diff, coeff, diff_stride, &fwd_txfm_param);
+
   if (xform_quant_idx != AV1_XFORM_QUANT_SKIP_QUANT) {
     if (LIKELY(!x->skip_block)) {
-      quant_func_list[xform_quant_idx][QUANT_FUNC_LOWBD](
+      quant_func_list[xform_quant_idx][is_hbd](
           coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order, &qparam);
     } else {
       av1_quantize_skip(tx2d_size, qcoeff, dqcoeff, eob);
     }
   }
 #if CONFIG_LV_MAP
   p->txb_entropy_ctx[block] =
       (uint8_t)av1_get_txb_entropy_context(qcoeff, scan_order, *eob);
 #endif  // CONFIG_LV_MAP
-#else   // #if !CONFIG_PVQ
+  return;
+#else  // CONFIG_PVQ
   (void)xform_quant_idx;
 #if CONFIG_HIGHBITDEPTH
   fwd_txfm_param.bd = xd->bd;
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
     av1_highbd_fwd_txfm(src_int16, coeff, diff_stride, &fwd_txfm_param);
     av1_highbd_fwd_txfm(pred, ref_coeff, diff_stride, &fwd_txfm_param);
   } else {
 #endif
@@ -1139,18 +748,24 @@ static void encode_block(int plane, int 
   if (p->eobs[block] == 0) return;
 #else
   (void)ctx;
   if (!x->pvq_skip[plane]) *(args->skip) = 0;
 
   if (x->pvq_skip[plane]) return;
 #endif
   TX_TYPE tx_type = get_tx_type(pd->plane_type, xd, block, tx_size);
+#if CONFIG_LGT
+  PREDICTION_MODE mode = get_prediction_mode(xd->mi[0], plane, tx_size, block);
+  av1_inverse_transform_block(xd, dqcoeff, mode, tx_type, tx_size, dst,
+                              pd->dst.stride, p->eobs[block]);
+#else
   av1_inverse_transform_block(xd, dqcoeff, tx_type, tx_size, dst,
                               pd->dst.stride, p->eobs[block]);
+#endif
 }
 
 #if CONFIG_VAR_TX
 static void encode_block_inter(int plane, int block, int blk_row, int blk_col,
                                BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
                                void *arg) {
   struct encode_b_args *const args = arg;
   MACROBLOCK *const x = args->x;
@@ -1242,24 +857,24 @@ static void encode_block_pass1(int plane
         for (j = 0; j < tx_blk_size; j++)
           for (i = 0; i < tx_blk_size; i++) dst[j * pd->dst.stride + i] = 0;
 #if CONFIG_HIGHBITDEPTH
       }
 #endif  // CONFIG_HIGHBITDEPTH
     }
 #endif  // !CONFIG_PVQ
 #if CONFIG_HIGHBITDEPTH
+    INV_TXFM_PARAM inv_txfm_param;
+    inv_txfm_param.bd = xd->bd;
+    inv_txfm_param.tx_type = DCT_DCT;
+    inv_txfm_param.eob = p->eobs[block];
+    inv_txfm_param.lossless = xd->lossless[xd->mi[0]->mbmi.segment_id];
     if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-      if (xd->lossless[xd->mi[0]->mbmi.segment_id]) {
-        av1_highbd_iwht4x4_add(dqcoeff, dst, pd->dst.stride, p->eobs[block],
-                               xd->bd);
-      } else {
-        av1_highbd_idct4x4_add(dqcoeff, dst, pd->dst.stride, p->eobs[block],
-                               xd->bd);
-      }
+      av1_highbd_inv_txfm_add_4x4(dqcoeff, dst, pd->dst.stride,
+                                  &inv_txfm_param);
       return;
     }
 #endif  //  CONFIG_HIGHBITDEPTH
     if (xd->lossless[xd->mi[0]->mbmi.segment_id]) {
       av1_iwht4x4_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
     } else {
       av1_idct4x4_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
     }
@@ -1430,16 +1045,34 @@ static void quantize_scaler(int coeff, i
   if (abs_coeff >= zbin) {
     int tmp = clamp(abs_coeff + round_value, INT16_MIN, INT16_MAX);
     tmp = ((((tmp * quant) >> 16) + tmp) * quant_shift) >> (16 - log_scale);
     *qcoeff = (tmp ^ coeff_sign) - coeff_sign;
     *dqcoeff = (*qcoeff * dequant) / (1 << log_scale);
   }
 }
 
+#if CONFIG_HIGHBITDEPTH
+typedef void (*hbd_dpcm_fwd_tx_func)(const int16_t *input, int stride,
+                                     TX_TYPE_1D tx_type, tran_low_t *output,
+                                     int dir);
+
+static hbd_dpcm_fwd_tx_func get_hbd_dpcm_fwd_tx_func(int tx_length) {
+  switch (tx_length) {
+    case 4: return av1_hbd_dpcm_ft4_c;
+    case 8: return av1_hbd_dpcm_ft8_c;
+    case 16: return av1_hbd_dpcm_ft16_c;
+    case 32:
+      return av1_hbd_dpcm_ft32_c;
+    // TODO(huisu): add support for TX_64X64.
+    default: assert(0); return NULL;
+  }
+}
+#endif  // CONFIG_HIGHBITDEPTH
+
 typedef void (*dpcm_fwd_tx_func)(const int16_t *input, int stride,
                                  TX_TYPE_1D tx_type, tran_low_t *output);
 
 static dpcm_fwd_tx_func get_dpcm_fwd_tx_func(int tx_length) {
   switch (tx_length) {
     case 4: return av1_dpcm_ft4_c;
     case 8: return av1_dpcm_ft8_c;
     case 16: return av1_dpcm_ft16_c;
@@ -1534,40 +1167,40 @@ static void process_block_dpcm_horz(TX_S
 #if CONFIG_HIGHBITDEPTH
 static void hbd_process_block_dpcm_vert(
     TX_SIZE tx_size, TX_TYPE_1D tx_type_1d, int bd,
     struct macroblockd_plane *const pd, struct macroblock_plane *const p,
     uint8_t *src8, int src_stride, uint8_t *dst8, int dst_stride,
     int16_t *src_diff, int diff_stride, tran_low_t *coeff, tran_low_t *qcoeff,
     tran_low_t *dqcoeff) {
   const int tx1d_width = tx_size_wide[tx_size];
-  dpcm_fwd_tx_func forward_tx = get_dpcm_fwd_tx_func(tx1d_width);
+  hbd_dpcm_fwd_tx_func forward_tx = get_hbd_dpcm_fwd_tx_func(tx1d_width);
   hbd_dpcm_inv_txfm_add_func inverse_tx =
       av1_get_hbd_dpcm_inv_txfm_add_func(tx1d_width);
   uint16_t *src = CONVERT_TO_SHORTPTR(src8);
   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
   const int tx1d_height = tx_size_high[tx_size];
   const int log_scale = av1_get_tx_scale(tx_size);
   int q_idx = 0;
   for (int r = 0; r < tx1d_height; ++r) {
     // Update prediction.
     if (r > 0) memcpy(dst, dst - dst_stride, tx1d_width * sizeof(dst[0]));
     // Subtraction.
     for (int c = 0; c < tx1d_width; ++c) src_diff[c] = src[c] - dst[c];
     // Forward transform.
-    forward_tx(src_diff, 1, tx_type_1d, coeff);
+    forward_tx(src_diff, 1, tx_type_1d, coeff, 1);
     // Quantization.
     for (int c = 0; c < tx1d_width; ++c) {
       quantize_scaler(coeff[c], p->zbin[q_idx], p->round[q_idx],
                       p->quant[q_idx], p->quant_shift[q_idx],
                       pd->dequant[q_idx], log_scale, &qcoeff[c], &dqcoeff[c]);
       q_idx = 1;
     }
     // Inverse transform.
-    inverse_tx(dqcoeff, 1, tx_type_1d, bd, dst);
+    inverse_tx(dqcoeff, 1, tx_type_1d, bd, dst, 1);
     // Move to the next row.
     coeff += tx1d_width;
     qcoeff += tx1d_width;
     dqcoeff += tx1d_width;
     src_diff += diff_stride;
     dst += dst_stride;
     src += src_stride;
   }
@@ -1575,46 +1208,46 @@ static void hbd_process_block_dpcm_vert(
 
 static void hbd_process_block_dpcm_horz(
     TX_SIZE tx_size, TX_TYPE_1D tx_type_1d, int bd,
     struct macroblockd_plane *const pd, struct macroblock_plane *const p,
     uint8_t *src8, int src_stride, uint8_t *dst8, int dst_stride,
     int16_t *src_diff, int diff_stride, tran_low_t *coeff, tran_low_t *qcoeff,
     tran_low_t *dqcoeff) {
   const int tx1d_height = tx_size_high[tx_size];
-  dpcm_fwd_tx_func forward_tx = get_dpcm_fwd_tx_func(tx1d_height);
+  hbd_dpcm_fwd_tx_func forward_tx = get_hbd_dpcm_fwd_tx_func(tx1d_height);
   hbd_dpcm_inv_txfm_add_func inverse_tx =
       av1_get_hbd_dpcm_inv_txfm_add_func(tx1d_height);
   uint16_t *src = CONVERT_TO_SHORTPTR(src8);
   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
   const int tx1d_width = tx_size_wide[tx_size];
   const int log_scale = av1_get_tx_scale(tx_size);
   int q_idx = 0;
   for (int c = 0; c < tx1d_width; ++c) {
     for (int r = 0; r < tx1d_height; ++r) {
       // Update prediction.
       if (c > 0) dst[r * dst_stride] = dst[r * dst_stride - 1];
       // Subtraction.
       src_diff[r * diff_stride] = src[r * src_stride] - dst[r * dst_stride];
     }
     // Forward transform.
     tran_low_t tx_buff[64];
-    forward_tx(src_diff, diff_stride, tx_type_1d, tx_buff);
+    forward_tx(src_diff, diff_stride, tx_type_1d, tx_buff, 0);
     for (int r = 0; r < tx1d_height; ++r) coeff[r * tx1d_width] = tx_buff[r];
     // Quantization.
     for (int r = 0; r < tx1d_height; ++r) {
       quantize_scaler(coeff[r * tx1d_width], p->zbin[q_idx], p->round[q_idx],
                       p->quant[q_idx], p->quant_shift[q_idx],
                       pd->dequant[q_idx], log_scale, &qcoeff[r * tx1d_width],
                       &dqcoeff[r * tx1d_width]);
       q_idx = 1;
     }
     // Inverse transform.
     for (int r = 0; r < tx1d_height; ++r) tx_buff[r] = dqcoeff[r * tx1d_width];
-    inverse_tx(tx_buff, dst_stride, tx_type_1d, bd, dst);
+    inverse_tx(tx_buff, dst_stride, tx_type_1d, bd, dst, 0);
     // Move to the next column.
     ++coeff, ++qcoeff, ++dqcoeff, ++src_diff, ++dst, ++src;
   }
 }
 #endif  // CONFIG_HIGHBITDEPTH
 
 void av1_encode_block_intra_dpcm(const AV1_COMMON *cm, MACROBLOCK *x,
                                  PREDICTION_MODE mode, int plane, int block,
@@ -1626,17 +1259,18 @@ void av1_encode_block_intra_dpcm(const A
   struct macroblock_plane *const p = &x->plane[plane];
   struct macroblockd_plane *const pd = &xd->plane[plane];
   tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
   const int diff_stride = block_size_wide[plane_bsize];
   const int src_stride = p->src.stride;
   const int dst_stride = pd->dst.stride;
   const int tx1d_width = tx_size_wide[tx_size];
   const int tx1d_height = tx_size_high[tx_size];
-  const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, 0);
+  const SCAN_ORDER *const scan_order =
+      get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
   tran_low_t *coeff = BLOCK_OFFSET(p->coeff, block);
   tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
   uint8_t *dst =
       &pd->dst.buf[(blk_row * dst_stride + blk_col) << tx_size_wide_log2[0]];
   uint8_t *src =
       &p->src.buf[(blk_row * src_stride + blk_col) << tx_size_wide_log2[0]];
   int16_t *src_diff =
       &p->src_diff[(blk_row * diff_stride + blk_col) << tx_size_wide_log2[0]];
@@ -1719,34 +1353,49 @@ void av1_encode_block_intra(int plane, i
 #if CONFIG_CFL
 
 #if CONFIG_EC_ADAPT
   FRAME_CONTEXT *const ec_ctx = xd->tile_ctx;
 #else
   FRAME_CONTEXT *const ec_ctx = cm->fc;
 #endif  // CONFIG_EC_ADAPT
 
+#if CONFIG_DEBUG
+  const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+// av1_predict_intra_block_facade does not pass plane_bsize, we need to validate
+// that we will get the same value of plane_bsize on the other side.
+#if CONFIG_CHROMA_SUB8X8
+  const BLOCK_SIZE plane_bsize_val =
+      AOMMAX(BLOCK_4X4, get_plane_block_size(mbmi->sb_type, &xd->plane[plane]));
+#else
+  const BLOCK_SIZE plane_bsize_val =
+      get_plane_block_size(mbmi->sb_type, &xd->plane[plane]);
+#endif  // CONFIG_CHROMA_SUB8X8
+  assert(plane_bsize == plane_bsize_val);
+#endif  // CONFIG_DEBUG
+
   av1_predict_intra_block_encoder_facade(x, ec_ctx, plane, block, blk_col,
-                                         blk_row, tx_size, plane_bsize);
+                                         blk_row, tx_size);
 #else
   av1_predict_intra_block_facade(xd, plane, block, blk_col, blk_row, tx_size);
 #endif
 
+#if CONFIG_DPCM_INTRA || CONFIG_LGT
+  const PREDICTION_MODE mode =
+      get_prediction_mode(xd->mi[0], plane, tx_size, block);
 #if CONFIG_DPCM_INTRA
-  const int block_raster_idx = av1_block_index_to_raster_order(tx_size, block);
   const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
-  const PREDICTION_MODE mode =
-      (plane == 0) ? get_y_mode(xd->mi[0], block_raster_idx) : mbmi->uv_mode;
   if (av1_use_dpcm_intra(plane, mode, tx_type, mbmi)) {
     av1_encode_block_intra_dpcm(cm, x, mode, plane, block, blk_row, blk_col,
                                 plane_bsize, tx_size, tx_type, args->ta,
                                 args->tl, args->skip);
     return;
   }
 #endif  // CONFIG_DPCM_INTRA
+#endif  // CONFIG_DPCM_INTRA || CONFIG_LGT
 
   av1_subtract_txb(x, plane, plane_bsize, blk_col, blk_row, tx_size);
 
   const ENTROPY_CONTEXT *a = &args->ta[blk_col];
   const ENTROPY_CONTEXT *l = &args->tl[blk_row];
   int ctx = combine_entropy_contexts(*a, *l);
   if (args->enable_optimize_b) {
     av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
@@ -1758,191 +1407,103 @@ void av1_encode_block_intra(int plane, i
   }
 
 #if CONFIG_PVQ
   // *(args->skip) == mbmi->skip
   if (!x->pvq_skip[plane]) *(args->skip) = 0;
 
   if (x->pvq_skip[plane]) return;
 #endif  // CONFIG_PVQ
-  av1_inverse_transform_block(xd, dqcoeff, tx_type, tx_size, dst, dst_stride,
-                              *eob);
+  av1_inverse_transform_block(xd, dqcoeff,
+#if CONFIG_LGT
+                              mode,
+#endif
+                              tx_type, tx_size, dst, dst_stride, *eob);
 #if !CONFIG_PVQ
   if (*eob) *(args->skip) = 0;
 #else
 // Note : *(args->skip) == mbmi->skip
 #endif
 #if CONFIG_CFL
-  MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   if (plane == AOM_PLANE_Y && x->cfl_store_y) {
-    cfl_store(xd->cfl, dst, dst_stride, blk_row, blk_col, tx_size);
-  }
-
-  if (mbmi->uv_mode == DC_PRED) {
-    // TODO(ltrudeau) find a cleaner way to detect last transform block
-    if (plane == AOM_PLANE_U) {
-      xd->cfl->num_tx_blk[CFL_PRED_U] =
-          (blk_row == 0 && blk_col == 0) ? 1
-                                         : xd->cfl->num_tx_blk[CFL_PRED_U] + 1;
-    }
-
-    if (plane == AOM_PLANE_V) {
-      xd->cfl->num_tx_blk[CFL_PRED_V] =
-          (blk_row == 0 && blk_col == 0) ? 1
-                                         : xd->cfl->num_tx_blk[CFL_PRED_V] + 1;
-
-      if (mbmi->skip &&
-          xd->cfl->num_tx_blk[CFL_PRED_U] == xd->cfl->num_tx_blk[CFL_PRED_V]) {
-        assert(plane_bsize != BLOCK_INVALID);
-        const int block_width = block_size_wide[plane_bsize];
-        const int block_height = block_size_high[plane_bsize];
-
-        // if SKIP is chosen at the block level, and ind != 0, we must change
-        // the prediction
-        if (mbmi->cfl_alpha_idx != 0) {
-          const struct macroblockd_plane *const pd_cb = &xd->plane[AOM_PLANE_U];
-          uint8_t *const dst_cb = pd_cb->dst.buf;
-          const int dst_stride_cb = pd_cb->dst.stride;
-          uint8_t *const dst_cr = pd->dst.buf;
-          const int dst_stride_cr = pd->dst.stride;
-          for (int j = 0; j < block_height; j++) {
-            for (int i = 0; i < block_width; i++) {
-              dst_cb[dst_stride_cb * j + i] =
-                  (uint8_t)(xd->cfl->dc_pred[CFL_PRED_U] + 0.5);
-              dst_cr[dst_stride_cr * j + i] =
-                  (uint8_t)(xd->cfl->dc_pred[CFL_PRED_V] + 0.5);
-            }
-          }
-          mbmi->cfl_alpha_idx = 0;
-          mbmi->cfl_alpha_signs[CFL_PRED_U] = CFL_SIGN_POS;
-          mbmi->cfl_alpha_signs[CFL_PRED_V] = CFL_SIGN_POS;
-        }
-      }
-    }
+    // TODO (ltrudeau) Store sub-8x8 inter blocks when bottom right block is
+    // intra predicted.
+    cfl_store(xd->cfl, dst, dst_stride, blk_row, blk_col, tx_size, plane_bsize);
   }
 #endif
 }
 
 #if CONFIG_CFL
-static int cfl_alpha_dist(const uint8_t *y_pix, int y_stride, double y_avg,
-                          const uint8_t *src, int src_stride, int blk_width,
-                          int blk_height, double dc_pred, double alpha,
-                          int *dist_neg_out) {
-  const double dc_pred_bias = dc_pred + 0.5;
+static int cfl_alpha_dist(const uint8_t *y_pix, int y_stride,
+                          const int y_averages_q3[MAX_NUM_TXB],
+                          const uint8_t *src, int src_stride, int width,
+                          int height, TX_SIZE tx_size, int dc_pred,
+                          double alpha, int *dist_neg_out) {
   int dist = 0;
   int diff;
 
   if (alpha == 0.0) {
-    const int dc_pred_i = (int)dc_pred_bias;
-    for (int j = 0; j < blk_height; j++) {
-      for (int i = 0; i < blk_width; i++) {
-        diff = src[i] - dc_pred_i;
+    for (int j = 0; j < height; j++) {
+      for (int i = 0; i < width; i++) {
+        diff = src[i] - dc_pred;
         dist += diff * diff;
       }
       src += src_stride;
     }
 
     if (dist_neg_out) *dist_neg_out = dist;
 
     return dist;
   }
 
+  // TODO(ltrudeau) Convert alpha to fixed point
+  const int alpha_q3 = (int)(alpha * 8);
   int dist_neg = 0;
-  for (int j = 0; j < blk_height; j++) {
-    for (int i = 0; i < blk_width; i++) {
-      const double scaled_luma = alpha * (y_pix[i] - y_avg);
-      const int uv = src[i];
-      diff = uv - (int)(scaled_luma + dc_pred_bias);
-      dist += diff * diff;
-      diff = uv + (int)(scaled_luma - dc_pred_bias);
-      dist_neg += diff * diff;
+  const int tx_height = tx_size_high[tx_size];
+  const int tx_width = tx_size_wide[tx_size];
+  const int y_block_row_off = y_stride * tx_height;
+  const int src_block_row_off = src_stride * tx_height;
+  const uint8_t *t_y_pix;
+  const uint8_t *t_src;
+  int a = 0;
+  for (int b_j = 0; b_j < height; b_j += tx_height) {
+    const int h = b_j + tx_height;
+    for (int b_i = 0; b_i < width; b_i += tx_width) {
+      const int w = b_i + tx_width;
+      const int tx_avg_q3 = y_averages_q3[a++];
+      t_y_pix = y_pix;
+      t_src = src;
+      for (int t_j = b_j; t_j < h; t_j++) {
+        for (int t_i = b_i; t_i < w; t_i++) {
+          const int uv = t_src[t_i];
+
+          const int scaled_luma =
+              get_scaled_luma_q0(alpha_q3, t_y_pix[t_i], tx_avg_q3);
+
+          // TODO(ltrudeau) add support for HBD.
+          diff = uv - clamp(scaled_luma + dc_pred, 0, 255);
+          dist += diff * diff;
+
+          // TODO(ltrudeau) add support for HBD.
+          diff = uv - clamp(-scaled_luma + dc_pred, 0, 255);
+          dist_neg += diff * diff;
+        }
+        t_y_pix += y_stride;
+        t_src += src_stride;
+      }
     }
-    y_pix += y_stride;
-    src += src_stride;
+    y_pix += y_block_row_off;
+    src += src_block_row_off;
   }
 
   if (dist_neg_out) *dist_neg_out = dist_neg;
 
   return dist;
 }
 
-static int cfl_compute_alpha_ind(MACROBLOCK *const x, const CFL_CTX *const cfl,
-                                 BLOCK_SIZE bsize,
-                                 CFL_SIGN_TYPE signs_out[CFL_SIGNS]) {
-  const struct macroblock_plane *const p_u = &x->plane[AOM_PLANE_U];
-  const struct macroblock_plane *const p_v = &x->plane[AOM_PLANE_V];
-  const uint8_t *const src_u = p_u->src.buf;
-  const uint8_t *const src_v = p_v->src.buf;
-  const int src_stride_u = p_u->src.stride;
-  const int src_stride_v = p_v->src.stride;
-  const int block_width = block_size_wide[bsize];
-  const int block_height = block_size_high[bsize];
-  const double dc_pred_u = cfl->dc_pred[CFL_PRED_U];
-  const double dc_pred_v = cfl->dc_pred[CFL_PRED_V];
-
-  // Temporary pixel buffer used to store the CfL prediction when we compute the
-  // alpha index.
-  uint8_t tmp_pix[MAX_SB_SQUARE];
-  // Load CfL Prediction over the entire block
-  const double y_avg =
-      cfl_load(cfl, tmp_pix, MAX_SB_SIZE, 0, 0, block_width, block_height);
-
-  int sse[CFL_PRED_PLANES][CFL_MAGS_SIZE];
-  sse[CFL_PRED_U][0] =
-      cfl_alpha_dist(tmp_pix, MAX_SB_SIZE, y_avg, src_u, src_stride_u,
-                     block_width, block_height, dc_pred_u, 0, NULL);
-  sse[CFL_PRED_V][0] =
-      cfl_alpha_dist(tmp_pix, MAX_SB_SIZE, y_avg, src_v, src_stride_v,
-                     block_width, block_height, dc_pred_v, 0, NULL);
-  for (int m = 1; m < CFL_MAGS_SIZE; m += 2) {
-    assert(cfl_alpha_mags[m + 1] == -cfl_alpha_mags[m]);
-    sse[CFL_PRED_U][m] = cfl_alpha_dist(
-        tmp_pix, MAX_SB_SIZE, y_avg, src_u, src_stride_u, block_width,
-        block_height, dc_pred_u, cfl_alpha_mags[m], &sse[CFL_PRED_U][m + 1]);
-    sse[CFL_PRED_V][m] = cfl_alpha_dist(
-        tmp_pix, MAX_SB_SIZE, y_avg, src_v, src_stride_v, block_width,
-        block_height, dc_pred_v, cfl_alpha_mags[m], &sse[CFL_PRED_V][m + 1]);
-  }
-
-  int dist;
-  int64_t cost;
-  int64_t best_cost;
-
-  // Compute least squares parameter of the entire block
-  // IMPORTANT: We assume that the first code is 0,0
-  int ind = 0;
-  signs_out[CFL_PRED_U] = CFL_SIGN_POS;
-  signs_out[CFL_PRED_V] = CFL_SIGN_POS;
-
-  dist = sse[CFL_PRED_U][0] + sse[CFL_PRED_V][0];
-  dist *= 16;
-  best_cost = RDCOST(x->rdmult, x->rddiv, cfl->costs[0], dist);
-
-  for (int c = 1; c < CFL_ALPHABET_SIZE; c++) {
-    const int idx_u = cfl_alpha_codes[c][CFL_PRED_U];
-    const int idx_v = cfl_alpha_codes[c][CFL_PRED_V];
-    for (CFL_SIGN_TYPE sign_u = idx_u == 0; sign_u < CFL_SIGNS; sign_u++) {
-      for (CFL_SIGN_TYPE sign_v = idx_v == 0; sign_v < CFL_SIGNS; sign_v++) {
-        dist = sse[CFL_PRED_U][idx_u + (sign_u == CFL_SIGN_NEG)] +
-               sse[CFL_PRED_V][idx_v + (sign_v == CFL_SIGN_NEG)];
-        dist *= 16;
-        cost = RDCOST(x->rdmult, x->rddiv, cfl->costs[c], dist);
-        if (cost < best_cost) {
-          best_cost = cost;
-          ind = c;
-          signs_out[CFL_PRED_U] = sign_u;
-          signs_out[CFL_PRED_V] = sign_v;
-        }
-      }
-    }
-  }
-
-  return ind;
-}
-
 static inline void cfl_update_costs(CFL_CTX *cfl, FRAME_CONTEXT *ec_ctx) {
   assert(ec_ctx->cfl_alpha_cdf[CFL_ALPHABET_SIZE - 1] ==
          AOM_ICDF(CDF_PROB_TOP));
   const int prob_den = CDF_PROB_TOP;
 
   int prob_num = AOM_ICDF(ec_ctx->cfl_alpha_cdf[0]);
   cfl->costs[0] = av1_cost_zero(get_prob(prob_num, prob_den));
 
@@ -1951,30 +1512,104 @@ static inline void cfl_update_costs(CFL_
                         (cfl_alpha_codes[c][CFL_PRED_V] != 0);
     prob_num = AOM_ICDF(ec_ctx->cfl_alpha_cdf[c]) -
                AOM_ICDF(ec_ctx->cfl_alpha_cdf[c - 1]);
     cfl->costs[c] = av1_cost_zero(get_prob(prob_num, prob_den)) +
                     av1_cost_literal(sign_bit_cost);
   }
 }
 
+static void cfl_compute_alpha_ind(MACROBLOCK *const x, FRAME_CONTEXT *ec_ctx,
+                                  TX_SIZE tx_size) {
+  const struct macroblock_plane *const p_u = &x->plane[AOM_PLANE_U];
+  const struct macroblock_plane *const p_v = &x->plane[AOM_PLANE_V];
+  const uint8_t *const src_u = p_u->src.buf;
+  const uint8_t *const src_v = p_v->src.buf;
+  const int src_stride_u = p_u->src.stride;
+  const int src_stride_v = p_v->src.stride;
+
+  MACROBLOCKD *const xd = &x->e_mbd;
+  MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+
+  CFL_CTX *const cfl = xd->cfl;
+  cfl_compute_parameters(xd, tx_size);
+  const int width = cfl->uv_width;
+  const int height = cfl->uv_height;
+  const int dc_pred_u = cfl->dc_pred[CFL_PRED_U];
+  const int dc_pred_v = cfl->dc_pred[CFL_PRED_V];
+  const int *y_averages_q3 = cfl->y_averages_q3;
+  const uint8_t *y_pix = cfl->y_down_pix;
+
+  CFL_SIGN_TYPE *signs = mbmi->cfl_alpha_signs;
+
+  cfl_update_costs(cfl, ec_ctx);
+
+  int sse[CFL_PRED_PLANES][CFL_MAGS_SIZE];
+  sse[CFL_PRED_U][0] =
+      cfl_alpha_dist(y_pix, MAX_SB_SIZE, y_averages_q3, src_u, src_stride_u,
+                     width, height, tx_size, dc_pred_u, 0, NULL);
+  sse[CFL_PRED_V][0] =
+      cfl_alpha_dist(y_pix, MAX_SB_SIZE, y_averages_q3, src_v, src_stride_v,
+                     width, height, tx_size, dc_pred_v, 0, NULL);
+
+  for (int m = 1; m < CFL_MAGS_SIZE; m += 2) {
+    assert(cfl_alpha_mags[m + 1] == -cfl_alpha_mags[m]);
+    sse[CFL_PRED_U][m] = cfl_alpha_dist(
+        y_pix, MAX_SB_SIZE, y_averages_q3, src_u, src_stride_u, width, height,
+        tx_size, dc_pred_u, cfl_alpha_mags[m], &sse[CFL_PRED_U][m + 1]);
+    sse[CFL_PRED_V][m] = cfl_alpha_dist(
+        y_pix, MAX_SB_SIZE, y_averages_q3, src_v, src_stride_v, width, height,
+        tx_size, dc_pred_v, cfl_alpha_mags[m], &sse[CFL_PRED_V][m + 1]);
+  }
+
+  int dist;
+  int64_t cost;
+  int64_t best_cost;
+
+  // Compute least squares parameter of the entire block
+  // IMPORTANT: We assume that the first code is 0,0
+  int ind = 0;
+  signs[CFL_PRED_U] = CFL_SIGN_POS;
+  signs[CFL_PRED_V] = CFL_SIGN_POS;
+
+  dist = sse[CFL_PRED_U][0] + sse[CFL_PRED_V][0];
+  dist *= 16;
+  best_cost = RDCOST(x->rdmult, cfl->costs[0], dist);
+
+  for (int c = 1; c < CFL_ALPHABET_SIZE; c++) {
+    const int idx_u = cfl_alpha_codes[c][CFL_PRED_U];
+    const int idx_v = cfl_alpha_codes[c][CFL_PRED_V];
+    for (CFL_SIGN_TYPE sign_u = idx_u == 0; sign_u < CFL_SIGNS; sign_u++) {
+      for (CFL_SIGN_TYPE sign_v = idx_v == 0; sign_v < CFL_SIGNS; sign_v++) {
+        dist = sse[CFL_PRED_U][idx_u + (sign_u == CFL_SIGN_NEG)] +
+               sse[CFL_PRED_V][idx_v + (sign_v == CFL_SIGN_NEG)];
+        dist *= 16;
+        cost = RDCOST(x->rdmult, cfl->costs[c], dist);
+        if (cost < best_cost) {
+          best_cost = cost;
+          ind = c;
+          signs[CFL_PRED_U] = sign_u;
+          signs[CFL_PRED_V] = sign_v;
+        }
+      }
+    }
+  }
+
+  mbmi->cfl_alpha_idx = ind;
+}
+
 void av1_predict_intra_block_encoder_facade(MACROBLOCK *x,
                                             FRAME_CONTEXT *ec_ctx, int plane,
                                             int block_idx, int blk_col,
-                                            int blk_row, TX_SIZE tx_size,
-                                            BLOCK_SIZE plane_bsize) {
+                                            int blk_row, TX_SIZE tx_size) {
   MACROBLOCKD *const xd = &x->e_mbd;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   if (plane != AOM_PLANE_Y && mbmi->uv_mode == DC_PRED) {
     if (blk_col == 0 && blk_row == 0 && plane == AOM_PLANE_U) {
-      CFL_CTX *const cfl = xd->cfl;
-      cfl_update_costs(cfl, ec_ctx);
-      cfl_dc_pred(xd, plane_bsize, tx_size);
-      mbmi->cfl_alpha_idx =
-          cfl_compute_alpha_ind(x, cfl, plane_bsize, mbmi->cfl_alpha_signs);
+      cfl_compute_alpha_ind(x, ec_ctx, tx_size);
     }
   }
   av1_predict_intra_block_facade(xd, plane, block_idx, blk_col, blk_row,
                                  tx_size);
 }
 #endif
 
 void av1_encode_intra_block_plane(AV1_COMMON *cm, MACROBLOCK *x,
--- a/third_party/aom/av1/encoder/encodemb.h
+++ b/third_party/aom/av1/encoder/encodemb.h
@@ -85,18 +85,17 @@ void av1_store_pvq_enc_info(PVQ_INFO *pv
                             od_coeff *y, int nb_bands, const int *off,
                             int *size, int skip_rest, int skip_dir, int bs);
 #endif
 
 #if CONFIG_CFL
 void av1_predict_intra_block_encoder_facade(MACROBLOCK *x,
                                             FRAME_CONTEXT *ec_ctx, int plane,
                                             int block_idx, int blk_col,
-                                            int blk_row, TX_SIZE tx_size,
-                                            BLOCK_SIZE plane_bsize);
+                                            int blk_row, TX_SIZE tx_size);
 #endif
 
 #if CONFIG_DPCM_INTRA
 void av1_encode_block_intra_dpcm(const AV1_COMMON *cm, MACROBLOCK *x,
                                  PREDICTION_MODE mode, int plane, int block,
                                  int blk_row, int blk_col,
                                  BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
                                  TX_TYPE tx_type, ENTROPY_CONTEXT *ta,
--- a/third_party/aom/av1/encoder/encodemv.c
+++ b/third_party/aom/av1/encoder/encodemv.c
@@ -26,17 +26,17 @@ static struct av1_token mv_fp_encodings[
 
 void av1_entropy_mv_init(void) {
   av1_tokens_from_tree(mv_joint_encodings, av1_mv_joint_tree);
   av1_tokens_from_tree(mv_class_encodings, av1_mv_class_tree);
   av1_tokens_from_tree(mv_fp_encodings, av1_mv_fp_tree);
 }
 
 static void encode_mv_component(aom_writer *w, int comp, nmv_component *mvcomp,
-                                int usehp) {
+                                MvSubpelPrecision precision) {
   int offset;
   const int sign = comp < 0;
   const int mag = sign ? -comp : comp;
   const int mv_class = av1_get_mv_class(mag - 1, &offset);
   const int d = offset >> 3;         // int mv data
   const int fr = (offset >> 1) & 3;  // fractional mv data
   const int hp = offset & 1;         // high precision mv data
 
@@ -52,29 +52,34 @@ static void encode_mv_component(aom_writ
   if (mv_class == MV_CLASS_0) {
     aom_write(w, d, mvcomp->class0[0]);
   } else {
     int i;
     const int n = mv_class + CLASS0_BITS - 1;  // number of bits
     for (i = 0; i < n; ++i) aom_write(w, (d >> i) & 1, mvcomp->bits[i]);
   }
 
-  // Fractional bits
-  aom_write_symbol(
-      w, fr, mv_class == MV_CLASS_0 ? mvcomp->class0_fp_cdf[d] : mvcomp->fp_cdf,
-      MV_FP_SIZE);
+// Fractional bits
+#if CONFIG_INTRABC
+  if (precision > MV_SUBPEL_NONE)
+#endif  // CONFIG_INTRABC
+  {
+    aom_write_symbol(w, fr, mv_class == MV_CLASS_0 ? mvcomp->class0_fp_cdf[d]
+                                                   : mvcomp->fp_cdf,
+                     MV_FP_SIZE);
+  }
 
   // High precision bit
-  if (usehp)
+  if (precision > MV_SUBPEL_LOW_PRECISION)
     aom_write(w, hp, mv_class == MV_CLASS_0 ? mvcomp->class0_hp : mvcomp->hp);
 }
 
 static void build_nmv_component_cost_table(int *mvcost,
                                            const nmv_component *const mvcomp,
-                                           int usehp) {
+                                           MvSubpelPrecision precision) {
   int i, v;
   int sign_cost[2], class_cost[MV_CLASSES], class0_cost[CLASS0_SIZE];
   int bits_cost[MV_OFFSET_BITS][2];
   int class0_fp_cost[CLASS0_SIZE][MV_FP_SIZE], fp_cost[MV_FP_SIZE];
   int class0_hp_cost[2], hp_cost[2];
 
   sign_cost[0] = av1_cost_zero(mvcomp->sign);
   sign_cost[1] = av1_cost_one(mvcomp->sign);
@@ -84,17 +89,17 @@ static void build_nmv_component_cost_tab
     bits_cost[i][0] = av1_cost_zero(mvcomp->bits[i]);
     bits_cost[i][1] = av1_cost_one(mvcomp->bits[i]);
   }
 
   for (i = 0; i < CLASS0_SIZE; ++i)
     av1_cost_tokens(class0_fp_cost[i], mvcomp->class0_fp[i], av1_mv_fp_tree);
   av1_cost_tokens(fp_cost, mvcomp->fp, av1_mv_fp_tree);
 
-  if (usehp) {
+  if (precision > MV_SUBPEL_LOW_PRECISION) {
     class0_hp_cost[0] = av1_cost_zero(mvcomp->class0_hp);
     class0_hp_cost[1] = av1_cost_one(mvcomp->class0_hp);
     hp_cost[0] = av1_cost_zero(mvcomp->hp);
     hp_cost[1] = av1_cost_one(mvcomp->hp);
   }
   mvcost[0] = 0;
   for (v = 1; v <= MV_MAX; ++v) {
     int z, c, o, d, e, f, cost = 0;
@@ -105,26 +110,31 @@ static void build_nmv_component_cost_tab
     f = (o >> 1) & 3; /* fractional pel mv data */
     e = (o & 1);      /* high precision mv data */
     if (c == MV_CLASS_0) {
       cost += class0_cost[d];
     } else {
       const int b = c + CLASS0_BITS - 1; /* number of bits */
       for (i = 0; i < b; ++i) cost += bits_cost[i][((d >> i) & 1)];
     }
-    if (c == MV_CLASS_0) {
-      cost += class0_fp_cost[d][f];
-    } else {
-      cost += fp_cost[f];
-    }
-    if (usehp) {
+#if CONFIG_INTRABC
+    if (precision > MV_SUBPEL_NONE)
+#endif  // CONFIG_INTRABC
+    {
       if (c == MV_CLASS_0) {
-        cost += class0_hp_cost[e];
+        cost += class0_fp_cost[d][f];
       } else {
-        cost += hp_cost[e];
+        cost += fp_cost[f];
+      }
+      if (precision > MV_SUBPEL_LOW_PRECISION) {
+        if (c == MV_CLASS_0) {
+          cost += class0_hp_cost[e];
+        } else {
+          cost += hp_cost[e];
+        }
       }
     }
     mvcost[v] = cost + sign_cost[0];
     mvcost[-v] = cost + sign_cost[1];
   }
 }
 
 static void update_mv(aom_writer *w, const unsigned int ct[2], aom_prob *cur_p,
@@ -225,28 +235,29 @@ void av1_encode_mv(AV1_COMP *cpi, aom_wr
 #if CONFIG_INTRABC
 void av1_encode_dv(aom_writer *w, const MV *mv, const MV *ref,
                    nmv_context *mvctx) {
   const MV diff = { mv->row - ref->row, mv->col - ref->col };
   const MV_JOINT_TYPE j = av1_get_mv_joint(&diff);
 
   aom_write_symbol(w, j, mvctx->joint_cdf, MV_JOINTS);
   if (mv_joint_vertical(j))
-    encode_mv_component(w, diff.row, &mvctx->comps[0], 0);
+    encode_mv_component(w, diff.row, &mvctx->comps[0], MV_SUBPEL_NONE);
 
   if (mv_joint_horizontal(j))
-    encode_mv_component(w, diff.col, &mvctx->comps[1], 0);
+    encode_mv_component(w, diff.col, &mvctx->comps[1], MV_SUBPEL_NONE);
 }
 #endif  // CONFIG_INTRABC
 
 void av1_build_nmv_cost_table(int *mvjoint, int *mvcost[2],
-                              const nmv_context *ctx, int usehp) {
+                              const nmv_context *ctx,
+                              MvSubpelPrecision precision) {
   av1_cost_tokens(mvjoint, ctx->joints, av1_mv_joint_tree);
-  build_nmv_component_cost_table(mvcost[0], &ctx->comps[0], usehp);
-  build_nmv_component_cost_table(mvcost[1], &ctx->comps[1], usehp);
+  build_nmv_component_cost_table(mvcost[0], &ctx->comps[0], precision);
+  build_nmv_component_cost_table(mvcost[1], &ctx->comps[1], precision);
 }
 
 #if CONFIG_EXT_INTER
 static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext,
                     const int_mv mvs[2], const int_mv pred_mvs[2],
                     nmv_context_counts *nmv_counts) {
   int i;
   PREDICTION_MODE mode = mbmi->mode;
@@ -279,16 +290,37 @@ static void inc_mvs(const MB_MODE_INFO *
     const MV diff = { mvs[0].as_mv.row - ref->row,
                       mvs[0].as_mv.col - ref->col };
     int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
     int nmv_ctx =
         av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                     mbmi_ext->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
     nmv_context_counts *counts = &nmv_counts[nmv_ctx];
     av1_inc_mv(&diff, counts, 1);
+#if CONFIG_COMPOUND_SINGLEREF
+  } else {
+    assert(  // mode == SR_NEAREST_NEWMV ||
+        mode == SR_NEAR_NEWMV || mode == SR_ZERO_NEWMV || mode == SR_NEW_NEWMV);
+    const MV *ref = &mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0].as_mv;
+    int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
+    int nmv_ctx =
+        av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
+                    mbmi_ext->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
+    nmv_context_counts *counts = &nmv_counts[nmv_ctx];
+    (void)pred_mvs;
+    MV diff;
+    if (mode == SR_NEW_NEWMV) {
+      diff.row = mvs[0].as_mv.row - ref->row;
+      diff.col = mvs[0].as_mv.col - ref->col;
+      av1_inc_mv(&diff, counts, 1);
+    }
+    diff.row = mvs[1].as_mv.row - ref->row;
+    diff.col = mvs[1].as_mv.col - ref->col;
+    av1_inc_mv(&diff, counts, 1);
+#endif  // CONFIG_COMPOUND_SINGLEREF
   }
 }
 
 static void inc_mvs_sub8x8(const MODE_INFO *mi, int block, const int_mv mvs[2],
                            const MB_MODE_INFO_EXT *mbmi_ext,
                            nmv_context_counts *nmv_counts) {
   int i;
   PREDICTION_MODE mode = mi->bmi[block].as_mode;
@@ -323,17 +355,17 @@ static void inc_mvs_sub8x8(const MODE_IN
     int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
     int nmv_ctx =
         av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                     mbmi_ext->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
     nmv_context_counts *counts = &nmv_counts[nmv_ctx];
     av1_inc_mv(&diff, counts, 1);
   }
 }
-#else
+#else   // !CONFIG_EXT_INTER
 static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext,
                     const int_mv mvs[2], const int_mv pred_mvs[2],
                     nmv_context_counts *nmv_counts) {
   int i;
 
   for (i = 0; i < 1 + has_second_ref(mbmi); ++i) {
     int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
     int nmv_ctx =
--- a/third_party/aom/av1/encoder/encodemv.h
+++ b/third_party/aom/av1/encoder/encodemv.h
@@ -22,17 +22,18 @@ void av1_entropy_mv_init(void);
 
 void av1_write_nmv_probs(AV1_COMMON *cm, int usehp, aom_writer *w,
                          nmv_context_counts *const counts);
 
 void av1_encode_mv(AV1_COMP *cpi, aom_writer *w, const MV *mv, const MV *ref,
                    nmv_context *mvctx, int usehp);
 
 void av1_build_nmv_cost_table(int *mvjoint, int *mvcost[2],
-                              const nmv_context *mvctx, int usehp);
+                              const nmv_context *mvctx,
+                              MvSubpelPrecision precision);
 
 void av1_update_mv_count(ThreadData *td);
 
 #if CONFIG_INTRABC
 void av1_encode_dv(aom_writer *w, const MV *mv, const MV *ref,
                    nmv_context *mvctx);
 #endif  // CONFIG_INTRABC
 
--- a/third_party/aom/av1/encoder/encoder.c
+++ b/third_party/aom/av1/encoder/encoder.c
@@ -26,16 +26,19 @@
 #include "av1/common/reconintra.h"
 #include "av1/common/resize.h"
 #include "av1/common/tile_common.h"
 
 #include "av1/encoder/aq_complexity.h"
 #include "av1/encoder/aq_cyclicrefresh.h"
 #include "av1/encoder/aq_variance.h"
 #include "av1/encoder/bitstream.h"
+#if CONFIG_BGSPRITE
+#include "av1/encoder/bgsprite.h"
+#endif  // CONFIG_BGSPRITE
 #if CONFIG_ANS
 #include "aom_dsp/buf_ans.h"
 #endif
 #include "av1/encoder/context_tree.h"
 #include "av1/encoder/encodeframe.h"
 #include "av1/encoder/encodemv.h"
 #include "av1/encoder/encoder.h"
 #if CONFIG_LV_MAP
@@ -68,16 +71,18 @@
 #include "aom_ports/system_state.h"
 #include "aom_scale/aom_scale.h"
 #if CONFIG_BITSTREAM_DEBUG
 #include "aom_util/debug_util.h"
 #endif  // CONFIG_BITSTREAM_DEBUG
 
 #if CONFIG_ENTROPY_STATS
 FRAME_COUNTS aggregate_fc;
+// Aggregate frame counts per frame context type
+FRAME_COUNTS aggregate_fc_per_type[FRAME_CONTEXTS];
 #endif  // CONFIG_ENTROPY_STATS
 
 #define AM_SEGMENT_ID_INACTIVE 7
 #define AM_SEGMENT_ID_ACTIVE 0
 
 #define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */
 
 #define ALTREF_HIGH_PRECISION_MV 1     // Whether to use high precision mv
@@ -416,17 +421,16 @@ void av1_initialize_enc(void) {
     av1_init_wedge_masks();
 #endif
     init_done = 1;
   }
 }
 
 static void dealloc_compressor_data(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
-  int i;
 
   aom_free(cpi->mbmi_ext_base);
   cpi->mbmi_ext_base = NULL;
 
 #if CONFIG_PVQ
   if (cpi->oxcf.pass != 1) {
     const int tile_cols = cm->tile_cols;
     const int tile_rows = cm->tile_rows;
@@ -462,34 +466,33 @@ static void dealloc_compressor_data(AV1_
 
   aom_free(cpi->td.mb.wsrc_buf);
   cpi->td.mb.wsrc_buf = NULL;
 
   aom_free(cpi->td.mb.mask_buf);
   cpi->td.mb.mask_buf = NULL;
 #endif
 
-  // Free up-sampled reference buffers.
-  for (i = 0; i < (REF_FRAMES + 1); i++)
-    aom_free_frame_buffer(&cpi->upsampled_ref_bufs[i].buf);
-
   av1_free_ref_frame_buffers(cm->buffer_pool);
 #if CONFIG_LV_MAP
   av1_free_txb_buf(cpi);
 #endif
   av1_free_context_buffers(cm);
 
   aom_free_frame_buffer(&cpi->last_frame_uf);
 #if CONFIG_LOOP_RESTORATION
   av1_free_restoration_buffers(cm);
   aom_free_frame_buffer(&cpi->last_frame_db);
   aom_free_frame_buffer(&cpi->trial_frame_rst);
   aom_free(cpi->extra_rstbuf);
-  for (i = 0; i < MAX_MB_PLANE; ++i)
-    av1_free_restoration_struct(&cpi->rst_search[i]);
+  {
+    int i;
+    for (i = 0; i < MAX_MB_PLANE; ++i)
+      av1_free_restoration_struct(&cpi->rst_search[i]);
+  }
 #endif  // CONFIG_LOOP_RESTORATION
   aom_free_frame_buffer(&cpi->scaled_source);
   aom_free_frame_buffer(&cpi->scaled_last_source);
   aom_free_frame_buffer(&cpi->alt_ref_buffer);
   av1_lookahead_destroy(cpi->lookahead);
 
   aom_free(cpi->tile_tok[0][0]);
   cpi->tile_tok[0][0] = 0;
@@ -730,23 +733,28 @@ static void alloc_util_frame_buffers(AV1
                                cm->subsampling_x, cm->subsampling_y,
 #if CONFIG_HIGHBITDEPTH
                                cm->use_highbitdepth,
 #endif
                                AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL,
                                NULL, NULL))
     aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
                        "Failed to allocate last frame deblocked buffer");
-  if (aom_realloc_frame_buffer(&cpi->trial_frame_rst, cm->width, cm->height,
-                               cm->subsampling_x, cm->subsampling_y,
+  if (aom_realloc_frame_buffer(
+          &cpi->trial_frame_rst,
+#if CONFIG_FRAME_SUPERRES
+          cm->superres_upscaled_width, cm->superres_upscaled_height,
+#else
+          cm->width, cm->height,
+#endif  // CONFIG_FRAME_SUPERRES
+          cm->subsampling_x, cm->subsampling_y,
 #if CONFIG_HIGHBITDEPTH
-                               cm->use_highbitdepth,
+          cm->use_highbitdepth,
 #endif
-                               AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL,
-                               NULL, NULL))
+          AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL, NULL, NULL))
     aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
                        "Failed to allocate trial restored frame buffer");
   int extra_rstbuf_sz = RESTORATION_EXTBUF_SIZE;
   if (extra_rstbuf_sz > 0) {
     aom_free(cpi->extra_rstbuf);
     CHECK_MEM_ERROR(cm, cpi->extra_rstbuf,
                     (uint8_t *)aom_malloc(extra_rstbuf_sz));
   } else {
@@ -960,16 +968,20 @@ static void init_config(struct AV1_COMP 
   cpi->framerate = oxcf->init_framerate;
 
   cm->profile = oxcf->profile;
   cm->bit_depth = oxcf->bit_depth;
 #if CONFIG_HIGHBITDEPTH
   cm->use_highbitdepth = oxcf->use_highbitdepth;
 #endif
   cm->color_space = oxcf->color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  cm->transfer_function = oxcf->transfer_function;
+  cm->chroma_sample_position = oxcf->chroma_sample_position;
+#endif
   cm->color_range = oxcf->color_range;
 
   cm->width = oxcf->width;
   cm->height = oxcf->height;
   av1_alloc_compressor_data(cpi);
 
   // Single thread case: use counts in common.
   cpi->td.counts = &cm->counts;
@@ -1349,17 +1361,17 @@ static void highbd_set_var_fns(AV1_COMP 
                    aom_highbd_sad4x8x8_bits8, aom_highbd_sad4x8x4d_bits8)
 
         HIGHBD_BFP(
             BLOCK_4X4, aom_highbd_sad4x4_bits8, aom_highbd_sad4x4_avg_bits8,
             aom_highbd_8_variance4x4, aom_highbd_8_sub_pixel_variance4x4,
             aom_highbd_8_sub_pixel_avg_variance4x4, aom_highbd_sad4x4x3_bits8,
             aom_highbd_sad4x4x8_bits8, aom_highbd_sad4x4x4d_bits8)
 
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
         HIGHBD_BFP(BLOCK_2X2, NULL, NULL, aom_highbd_8_variance2x2, NULL, NULL,
                    NULL, NULL, NULL)
         HIGHBD_BFP(BLOCK_4X2, NULL, NULL, aom_highbd_8_variance4x2, NULL, NULL,
                    NULL, NULL, NULL)
         HIGHBD_BFP(BLOCK_2X4, NULL, NULL, aom_highbd_8_variance2x4, NULL, NULL,
                    NULL, NULL, NULL)
 #endif
 
@@ -1554,17 +1566,17 @@ static void highbd_set_var_fns(AV1_COMP 
                    aom_highbd_sad4x8x8_bits10, aom_highbd_sad4x8x4d_bits10)
 
         HIGHBD_BFP(
             BLOCK_4X4, aom_highbd_sad4x4_bits10, aom_highbd_sad4x4_avg_bits10,
             aom_highbd_10_variance4x4, aom_highbd_10_sub_pixel_variance4x4,
             aom_highbd_10_sub_pixel_avg_variance4x4, aom_highbd_sad4x4x3_bits10,
             aom_highbd_sad4x4x8_bits10, aom_highbd_sad4x4x4d_bits10)
 
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
         HIGHBD_BFP(BLOCK_2X2, NULL, NULL, aom_highbd_10_variance2x2, NULL, NULL,
                    NULL, NULL, NULL)
         HIGHBD_BFP(BLOCK_4X2, NULL, NULL, aom_highbd_10_variance4x2, NULL, NULL,
                    NULL, NULL, NULL)
         HIGHBD_BFP(BLOCK_2X4, NULL, NULL, aom_highbd_10_variance2x4, NULL, NULL,
                    NULL, NULL, NULL)
 #endif
 
@@ -1761,17 +1773,17 @@ static void highbd_set_var_fns(AV1_COMP 
                    aom_highbd_sad4x8x8_bits12, aom_highbd_sad4x8x4d_bits12)
 
         HIGHBD_BFP(
             BLOCK_4X4, aom_highbd_sad4x4_bits12, aom_highbd_sad4x4_avg_bits12,
             aom_highbd_12_variance4x4, aom_highbd_12_sub_pixel_variance4x4,
             aom_highbd_12_sub_pixel_avg_variance4x4, aom_highbd_sad4x4x3_bits12,
             aom_highbd_sad4x4x8_bits12, aom_highbd_sad4x4x4d_bits12)
 
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
         HIGHBD_BFP(BLOCK_2X2, NULL, NULL, aom_highbd_12_variance2x2, NULL, NULL,
                    NULL, NULL, NULL)
         HIGHBD_BFP(BLOCK_4X2, NULL, NULL, aom_highbd_12_variance4x2, NULL, NULL,
                    NULL, NULL, NULL)
         HIGHBD_BFP(BLOCK_2X4, NULL, NULL, aom_highbd_12_variance2x4, NULL, NULL,
                    NULL, NULL, NULL)
 #endif
 
@@ -1932,16 +1944,20 @@ void set_compound_tools(AV1_COMMON *cm) 
 
 void av1_change_config(struct AV1_COMP *cpi, const AV1EncoderConfig *oxcf) {
   AV1_COMMON *const cm = &cpi->common;
   RATE_CONTROL *const rc = &cpi->rc;
 
   if (cm->profile != oxcf->profile) cm->profile = oxcf->profile;
   cm->bit_depth = oxcf->bit_depth;
   cm->color_space = oxcf->color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  cm->transfer_function = oxcf->transfer_function;
+  cm->chroma_sample_position = oxcf->chroma_sample_position;
+#endif
   cm->color_range = oxcf->color_range;
 
   if (cm->profile <= PROFILE_1)
     assert(cm->bit_depth == AOM_BITS_8);
   else
     assert(cm->bit_depth > AOM_BITS_8);
 
   cpi->oxcf = *oxcf;
@@ -2053,25 +2069,16 @@ void av1_change_config(struct AV1_COMP *
   if (cpi->buf_ans.size != (1 << cpi->common.ans_window_size_log2)) {
     aom_buf_ans_free(&cpi->buf_ans);
     aom_buf_ans_alloc(&cpi->buf_ans, &cpi->common.error,
                       1 << cpi->common.ans_window_size_log2);
   }
 #endif  // CONFIG_ANS && ANS_MAX_SYMBOLS
 }
 
-static INLINE void init_upsampled_ref_frame_bufs(AV1_COMP *cpi) {
-  int i;
-
-  for (i = 0; i < (REF_FRAMES + 1); ++i) {
-    cpi->upsampled_ref_bufs[i].ref_count = 0;
-    cpi->upsampled_ref_idx[i] = INVALID_IDX;
-  }
-}
-
 AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf,
                                 BufferPool *const pool) {
   unsigned int i;
   AV1_COMP *volatile const cpi = aom_memalign(32, sizeof(AV1_COMP));
   AV1_COMMON *volatile const cm = cpi != NULL ? &cpi->common : NULL;
 
   if (!cm) return NULL;
 
@@ -2094,20 +2101,16 @@ AV1_COMP *av1_create_compressor(AV1Encod
                   (FRAME_CONTEXT *)aom_memalign(
                       32, FRAME_CONTEXTS * sizeof(*cm->frame_contexts)));
   memset(cm->fc, 0, sizeof(*cm->fc));
   memset(cm->frame_contexts, 0, FRAME_CONTEXTS * sizeof(*cm->frame_contexts));
 
   cpi->resize_state = 0;
   cpi->resize_avg_qp = 0;
   cpi->resize_buffer_underflow = 0;
-  cpi->resize_scale_num = 16;
-  cpi->resize_scale_den = 16;
-  cpi->resize_next_scale_num = 16;
-  cpi->resize_next_scale_den = 16;
 
   cpi->common.buffer_pool = pool;
 
   init_config(cpi, oxcf);
 #if CONFIG_XIPHRC
   cpi->od_rc.framerate = cpi->framerate;
   cpi->od_rc.frame_width = cm->render_width;
   cpi->od_rc.frame_height = cm->render_height;
@@ -2192,16 +2195,17 @@ AV1_COMP *av1_create_compressor(AV1Encod
     CHECK_MEM_ERROR(cm, cpi->ssim_vars,
                     aom_malloc(sizeof(*cpi->ssim_vars) * 4 *
                                cpi->common.mi_rows * cpi->common.mi_cols));
     cpi->worst_consistency = 100.0;
   }
 #endif
 #if CONFIG_ENTROPY_STATS
   av1_zero(aggregate_fc);
+  av1_zero_array(aggregate_fc_per_type, FRAME_CONTEXTS);
 #endif  // CONFIG_ENTROPY_STATS
 
   cpi->first_time_stamp_ever = INT64_MAX;
 
   for (i = 0; i < NMV_CONTEXTS; ++i) {
     cpi->td.mb.nmvcost[i][0] = &cpi->nmv_costs[i][0][MV_MAX];
     cpi->td.mb.nmvcost[i][1] = &cpi->nmv_costs[i][1][MV_MAX];
     cpi->td.mb.nmvcost_hp[i][0] = &cpi->nmv_costs_hp[i][0][MV_MAX];
@@ -2273,18 +2277,16 @@ AV1_COMP *av1_create_compressor(AV1Encod
                       16, MAX_SB_SQUARE * sizeof(*cpi->td.mb.wsrc_buf)));
 
   CHECK_MEM_ERROR(cm, cpi->td.mb.mask_buf,
                   (int32_t *)aom_memalign(
                       16, MAX_SB_SQUARE * sizeof(*cpi->td.mb.mask_buf)));
 
 #endif
 
-  init_upsampled_ref_frame_bufs(cpi);
-
   av1_set_speed_features_framesize_independent(cpi);
   av1_set_speed_features_framesize_dependent(cpi);
 
 #define BFP(BT, SDF, SDAF, VF, SVF, SVAF, SDX3F, SDX8F, SDX4DF) \
   cpi->fn_ptr[BT].sdf = SDF;                                    \
   cpi->fn_ptr[BT].sdaf = SDAF;                                  \
   cpi->fn_ptr[BT].vf = VF;                                      \
   cpi->fn_ptr[BT].svf = SVF;                                    \
@@ -2354,17 +2356,17 @@ AV1_COMP *av1_create_compressor(AV1Encod
   BFP(BLOCK_4X8, aom_sad4x8, aom_sad4x8_avg, aom_variance4x8,
       aom_sub_pixel_variance4x8, aom_sub_pixel_avg_variance4x8, NULL,
       aom_sad4x8x8, aom_sad4x8x4d)
 
   BFP(BLOCK_4X4, aom_sad4x4, aom_sad4x4_avg, aom_variance4x4,
       aom_sub_pixel_variance4x4, aom_sub_pixel_avg_variance4x4, aom_sad4x4x3,
       aom_sad4x4x8, aom_sad4x4x4d)
 
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   BFP(BLOCK_2X2, NULL, NULL, aom_variance2x2, NULL, NULL, NULL, NULL, NULL)
   BFP(BLOCK_2X4, NULL, NULL, aom_variance2x4, NULL, NULL, NULL, NULL, NULL)
   BFP(BLOCK_4X2, NULL, NULL, aom_variance4x2, NULL, NULL, NULL, NULL, NULL)
 #endif
 
 #if CONFIG_MOTION_VAR
 #define OBFP(BT, OSDF, OVF, OSVF) \
   cpi->fn_ptr[BT].osdf = OSDF;    \
@@ -2444,17 +2446,19 @@ AV1_COMP *av1_create_compressor(AV1Encod
    */
   av1_init_quantizer(cpi);
 #if CONFIG_AOM_QM
   aom_qm_init(cm);
 #endif
 
   av1_loop_filter_init(cm);
 #if CONFIG_FRAME_SUPERRES
-  cm->superres_scale_numerator = SUPERRES_SCALE_DENOMINATOR;
+  cm->superres_scale_numerator = SCALE_DENOMINATOR;
+  cm->superres_upscaled_width = oxcf->width;
+  cm->superres_upscaled_height = oxcf->height;
 #endif  // CONFIG_FRAME_SUPERRES
 #if CONFIG_LOOP_RESTORATION
   av1_loop_restoration_precal();
 #endif  // CONFIG_LOOP_RESTORATION
 
   cm->error.setjmp = 0;
 
   return cpi;
@@ -2474,16 +2478,18 @@ void av1_remove_compressor(AV1_COMP *cpi
 
   cm = &cpi->common;
   if (cm->current_video_frame > 0) {
 #if CONFIG_ENTROPY_STATS
     if (cpi->oxcf.pass != 1) {
       fprintf(stderr, "Writing counts.stt\n");
       FILE *f = fopen("counts.stt", "wb");
       fwrite(&aggregate_fc, sizeof(aggregate_fc), 1, f);
+      fwrite(aggregate_fc_per_type, sizeof(aggregate_fc_per_type[0]),
+             FRAME_CONTEXTS, f);
       fclose(f);
     }
 #endif  // CONFIG_ENTROPY_STATS
 #if CONFIG_INTERNAL_STATS
     aom_clear_system_state();
 
     if (cpi->oxcf.pass != 1) {
       char headings[512] = { 0 };
@@ -2854,46 +2860,49 @@ static void scale_and_extend_frame(const
   const int dst_strides[3] = { dst->y_stride, dst->uv_stride, dst->uv_stride };
   const InterpFilterParams interp_filter_params =
       av1_get_interp_filter_params(EIGHTTAP_REGULAR);
   const int16_t *kernel = interp_filter_params.filter_ptr;
   const int taps = interp_filter_params.taps;
   int x, y, i;
 
   assert(planes <= 3);
+  assert(src->subsampling_x == dst->subsampling_x);
+  assert(src->subsampling_y == dst->subsampling_y);
   for (y = 0; y < dst_h; y += 16) {
     for (x = 0; x < dst_w; x += 16) {
       for (i = 0; i < planes; ++i) {
-        const int factor = (i == 0 || i == 3 ? 1 : 2);
-        const int x_q4 = x * (16 / factor) * src_w / dst_w;
-        const int y_q4 = y * (16 / factor) * src_h / dst_h;
+        int ss_x = i == AOM_PLANE_Y ? 0 : src->subsampling_x;
+        int ss_y = i == AOM_PLANE_Y ? 0 : src->subsampling_y;
+        const int x_q4 = x * (16 >> ss_x) * src_w / dst_w;
+        const int y_q4 = y * (16 >> ss_y) * src_h / dst_h;
         const int src_stride = src_strides[i];
         const int dst_stride = dst_strides[i];
         const uint8_t *src_ptr = srcs[i] +
-                                 (y / factor) * src_h / dst_h * src_stride +
-                                 (x / factor) * src_w / dst_w;
-        uint8_t *dst_ptr = dsts[i] + (y / factor) * dst_stride + (x / factor);
+                                 (y >> ss_y) * src_h / dst_h * src_stride +
+                                 (x >> ss_x) * src_w / dst_w;
+        uint8_t *dst_ptr = dsts[i] + (y >> ss_y) * dst_stride + (x >> ss_x);
 
 #if CONFIG_HIGHBITDEPTH
         if (src->flags & YV12_FLAG_HIGHBITDEPTH) {
           aom_highbd_convolve8(src_ptr, src_stride, dst_ptr, dst_stride,
                                &kernel[(x_q4 & 0xf) * taps], 16 * src_w / dst_w,
                                &kernel[(y_q4 & 0xf) * taps], 16 * src_h / dst_h,
-                               16 / factor, 16 / factor, bd);
+                               16 >> ss_x, 16 >> ss_y, bd);
         } else {
           aom_scaled_2d(src_ptr, src_stride, dst_ptr, dst_stride,
                         &kernel[(x_q4 & 0xf) * taps], 16 * src_w / dst_w,
                         &kernel[(y_q4 & 0xf) * taps], 16 * src_h / dst_h,
-                        16 / factor, 16 / factor);
+                        16 >> ss_x, 16 >> ss_y);
         }
 #else
         aom_scaled_2d(src_ptr, src_stride, dst_ptr, dst_stride,
                       &kernel[(x_q4 & 0xf) * taps], 16 * src_w / dst_w,
                       &kernel[(y_q4 & 0xf) * taps], 16 * src_h / dst_h,
-                      16 / factor, 16 / factor);
+                      16 >> ss_x, 16 >> ss_y);
 #endif  // CONFIG_HIGHBITDEPTH
       }
     }
   }
 
   if (planes == 1)
     aom_extend_frame_borders_y(dst);
   else
@@ -2944,62 +2953,16 @@ static int recode_loop_test(AV1_COMP *cp
           rc->projected_frame_size < ((rc->this_frame_target * 7) >> 3)) {
         force_recode = 1;
       }
     }
   }
   return force_recode;
 }
 
-static INLINE int get_free_upsampled_ref_buf(EncRefCntBuffer *ubufs) {
-  int i;
-
-  for (i = 0; i < (REF_FRAMES + 1); i++) {
-    if (!ubufs[i].ref_count) {
-      return i;
-    }
-  }
-  return INVALID_IDX;
-}
-
-// Up-sample 1 reference frame.
-static INLINE int upsample_ref_frame(AV1_COMP *cpi,
-                                     const YV12_BUFFER_CONFIG *const ref) {
-  AV1_COMMON *const cm = &cpi->common;
-  EncRefCntBuffer *ubufs = cpi->upsampled_ref_bufs;
-  int new_uidx = get_free_upsampled_ref_buf(ubufs);
-
-  if (new_uidx == INVALID_IDX) {
-    return INVALID_IDX;
-  } else {
-    YV12_BUFFER_CONFIG *upsampled_ref = &ubufs[new_uidx].buf;
-
-    // Can allocate buffer for Y plane only.
-    if (upsampled_ref->buffer_alloc_sz < (ref->buffer_alloc_sz << 6))
-      if (aom_realloc_frame_buffer(upsampled_ref, (cm->width << 3),
-                                   (cm->height << 3), cm->subsampling_x,
-                                   cm->subsampling_y,
-#if CONFIG_HIGHBITDEPTH
-                                   cm->use_highbitdepth,
-#endif
-                                   (AOM_BORDER_IN_PIXELS << 3),
-                                   cm->byte_alignment, NULL, NULL, NULL))
-        aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
-                           "Failed to allocate up-sampled frame buffer");
-
-// Currently, only Y plane is up-sampled, U, V are not used.
-#if CONFIG_HIGHBITDEPTH
-    scale_and_extend_frame(ref, upsampled_ref, 1, (int)cm->bit_depth);
-#else
-    scale_and_extend_frame(ref, upsampled_ref, 1);
-#endif
-    return new_uidx;
-  }
-}
-
 #define DUMP_REF_FRAME_IMAGES 0
 
 #if DUMP_REF_FRAME_IMAGES == 1
 static int dump_one_image(AV1_COMMON *cm,
                           const YV12_BUFFER_CONFIG *const ref_buf,
                           char *file_name) {
   int h;
   FILE *f_ref = NULL;
@@ -3063,83 +3026,84 @@ static INLINE void shift_last_ref_frames
       memcpy(cpi->interp_filter_selected[ref_frame + LAST_FRAME],
              cpi->interp_filter_selected[ref_frame - 1 + LAST_FRAME],
              sizeof(cpi->interp_filter_selected[ref_frame - 1 + LAST_FRAME]));
     }
   }
 }
 #endif  // CONFIG_EXT_REFS
 
+#if CONFIG_VAR_REFS
+static void enc_check_valid_ref_frames(AV1_COMP *const cpi) {
+  AV1_COMMON *const cm = &cpi->common;
+  MV_REFERENCE_FRAME ref_frame;
+
+  // TODO(zoeliu): To handle ALTREF_FRAME the same way as do with other
+  //               reference frames. Current encoder invalid ALTREF when ALTREF
+  //               is the same as LAST, but invalid all the other references
+  //               when they are the same as ALTREF.
+  for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
+    int ref_buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
+    RefBuffer *const ref_buf = &cm->frame_refs[ref_frame - LAST_FRAME];
+
+    if (ref_buf_idx != INVALID_IDX) {
+      ref_buf->is_valid = 1;
+
+      MV_REFERENCE_FRAME ref;
+      for (ref = LAST_FRAME; ref < ref_frame; ++ref) {
+        int buf_idx = get_ref_frame_buf_idx(cpi, ref);
+        RefBuffer *const buf = &cm->frame_refs[ref - LAST_FRAME];
+        if (buf->is_valid && buf_idx == ref_buf_idx) {
+          if (ref_frame != ALTREF_FRAME || ref == LAST_FRAME) {
+            ref_buf->is_valid = 0;
+            break;
+          } else {
+            buf->is_valid = 0;
+          }
+        }
+      }
+    } else {
+      ref_buf->is_valid = 0;
+    }
+  }
+}
+#endif  // CONFIG_VAR_REFS
+
 void av1_update_reference_frames(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
   BufferPool *const pool = cm->buffer_pool;
-  const int use_upsampled_ref = cpi->sf.use_upsampled_references;
-  int new_uidx = 0;
 
   // NOTE: Save the new show frame buffer index for --test-code=warn, i.e.,
   //       for the purpose to verify no mismatch between encoder and decoder.
   if (cm->show_frame) cpi->last_show_frame_buf_idx = cm->new_fb_idx;
 
-  if (use_upsampled_ref) {
-#if CONFIG_EXT_REFS
-    if (cm->show_existing_frame) {
-      new_uidx = cpi->upsampled_ref_idx[cpi->existing_fb_idx_to_show];
-      // TODO(zoeliu): Once following is confirmed, remove it.
-      assert(cpi->upsampled_ref_bufs[new_uidx].ref_count > 0);
-    } else {
-#endif  // CONFIG_EXT_REFS
-      // Up-sample the current encoded frame.
-      RefCntBuffer *bufs = pool->frame_bufs;
-      const YV12_BUFFER_CONFIG *const ref = &bufs[cm->new_fb_idx].buf;
-
-      new_uidx = upsample_ref_frame(cpi, ref);
-#if CONFIG_EXT_REFS
-      assert(new_uidx != INVALID_IDX);
-    }
-#endif  // CONFIG_EXT_REFS
-  }
   // At this point the new frame has been encoded.
   // If any buffer copy / swapping is signaled it should be done here.
   if (cm->frame_type == KEY_FRAME) {
     ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->gld_fb_idx],
                cm->new_fb_idx);
 #if CONFIG_EXT_REFS
     ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->bwd_fb_idx],
                cm->new_fb_idx);
 #endif  // CONFIG_EXT_REFS
     ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->alt_fb_idx],
                cm->new_fb_idx);
-
-    if (use_upsampled_ref) {
-      uref_cnt_fb(cpi->upsampled_ref_bufs,
-                  &cpi->upsampled_ref_idx[cpi->gld_fb_idx], new_uidx);
-#if CONFIG_EXT_REFS
-      uref_cnt_fb(cpi->upsampled_ref_bufs,
-                  &cpi->upsampled_ref_idx[cpi->bwd_fb_idx], new_uidx);
-#endif  // CONFIG_EXT_REFS
-      uref_cnt_fb(cpi->upsampled_ref_bufs,
-                  &cpi->upsampled_ref_idx[cpi->alt_fb_idx], new_uidx);
-    }
   } else if (av1_preserve_existing_gf(cpi)) {
     // We have decided to preserve the previously existing golden frame as our
     // new ARF frame. However, in the short term in function
     // av1_bitstream.c::get_refresh_mask() we left it in the GF slot and, if
     // we're updating the GF with the current decoded frame, we save it to the
     // ARF slot instead.
     // We now have to update the ARF with the current frame and swap gld_fb_idx
     // and alt_fb_idx so that, overall, we've stored the old GF in the new ARF
     // slot and, if we're updating the GF, the current frame becomes the new GF.
     int tmp;
 
     ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->alt_fb_idx],
                cm->new_fb_idx);
-    if (use_upsampled_ref)
-      uref_cnt_fb(cpi->upsampled_ref_bufs,
-                  &cpi->upsampled_ref_idx[cpi->alt_fb_idx], new_uidx);
-
     tmp = cpi->alt_fb_idx;
     cpi->alt_fb_idx = cpi->gld_fb_idx;
     cpi->gld_fb_idx = tmp;
 
 #if CONFIG_EXT_REFS
     // We need to modify the mapping accordingly
     cpi->arf_map[0] = cpi->alt_fb_idx;
 #endif
@@ -3190,31 +3154,25 @@ void av1_update_reference_frames(AV1_COM
       }
 #else
       if ((cpi->oxcf.pass == 2) && cpi->multi_arf_allowed) {
         const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
         arf_idx = gf_group->arf_update_idx[gf_group->index];
       }
 #endif  // CONFIG_EXT_REFS
       ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[arf_idx], cm->new_fb_idx);
-      if (use_upsampled_ref)
-        uref_cnt_fb(cpi->upsampled_ref_bufs, &cpi->upsampled_ref_idx[arf_idx],
-                    new_uidx);
 
       memcpy(cpi->interp_filter_selected[ALTREF_FRAME + which_arf],
              cpi->interp_filter_selected[0],
              sizeof(cpi->interp_filter_selected[0]));
     }
 
     if (cpi->refresh_golden_frame) {
       ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->gld_fb_idx],
                  cm->new_fb_idx);
-      if (use_upsampled_ref)
-        uref_cnt_fb(cpi->upsampled_ref_bufs,
-                    &cpi->upsampled_ref_idx[cpi->gld_fb_idx], new_uidx);
 
 #if !CONFIG_EXT_REFS
       if (!cpi->rc.is_src_frame_alt_ref)
 #endif  // !CONFIG_EXT_REFS
         memcpy(cpi->interp_filter_selected[GOLDEN_FRAME],
                cpi->interp_filter_selected[0],
                sizeof(cpi->interp_filter_selected[0]));
     }
@@ -3229,19 +3187,16 @@ void av1_update_reference_frames(AV1_COM
         int tmp = cpi->arf_map[0];
         cpi->arf_map[0] = cpi->alt_fb_idx;
         cpi->alt_fb_idx = cpi->bwd_fb_idx;
         cpi->bwd_fb_idx = tmp;
       }
 
       ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->bwd_fb_idx],
                  cm->new_fb_idx);
-      if (use_upsampled_ref)
-        uref_cnt_fb(cpi->upsampled_ref_bufs,
-                    &cpi->upsampled_ref_idx[cpi->bwd_fb_idx], new_uidx);
 
       memcpy(cpi->interp_filter_selected[BWDREF_FRAME],
              cpi->interp_filter_selected[0],
              sizeof(cpi->interp_filter_selected[0]));
     }
 #endif  // CONFIG_EXT_REFS
   }
 
@@ -3288,122 +3243,55 @@ void av1_update_reference_frames(AV1_COM
       cpi->bwd_fb_idx = tmp;
     }
 
     if (cm->frame_type == KEY_FRAME) {
       for (ref_frame = 0; ref_frame < LAST_REF_FRAMES; ++ref_frame) {
         ref_cnt_fb(pool->frame_bufs,
                    &cm->ref_frame_map[cpi->lst_fb_idxes[ref_frame]],
                    cm->new_fb_idx);
-
-        if (use_upsampled_ref)
-          uref_cnt_fb(cpi->upsampled_ref_bufs,
-                      &cpi->upsampled_ref_idx[cpi->lst_fb_idxes[ref_frame]],
-                      new_uidx);
       }
     } else {
       int tmp;
 
       ref_cnt_fb(pool->frame_bufs,
                  &cm->ref_frame_map[cpi->lst_fb_idxes[LAST_REF_FRAMES - 1]],
                  cm->new_fb_idx);
 
-      if (use_upsampled_ref)
-        uref_cnt_fb(
-            cpi->upsampled_ref_bufs,
-            &cpi->upsampled_ref_idx[cpi->lst_fb_idxes[LAST_REF_FRAMES - 1]],
-            new_uidx);
-
       tmp = cpi->lst_fb_idxes[LAST_REF_FRAMES - 1];
 
       shift_last_ref_frames(cpi);
       cpi->lst_fb_idxes[0] = tmp;
 
       assert(cm->show_existing_frame == 0);
       // NOTE: Currently only LF_UPDATE and INTNL_OVERLAY_UPDATE frames are to
       //       refresh the LAST_FRAME.
       memcpy(cpi->interp_filter_selected[LAST_FRAME],
              cpi->interp_filter_selected[0],
              sizeof(cpi->interp_filter_selected[0]));
     }
 #else
     ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->lst_fb_idx],
                cm->new_fb_idx);
-    if (use_upsampled_ref)
-      uref_cnt_fb(cpi->upsampled_ref_bufs,
-                  &cpi->upsampled_ref_idx[cpi->lst_fb_idx], new_uidx);
     if (!cpi->rc.is_src_frame_alt_ref) {
       memcpy(cpi->interp_filter_selected[LAST_FRAME],
              cpi->interp_filter_selected[0],
              sizeof(cpi->interp_filter_selected[0]));
     }
 #endif  // CONFIG_EXT_REFS
   }
 
 #if DUMP_REF_FRAME_IMAGES == 1
   // Dump out all reference frame images.
   dump_ref_frame_images(cpi);
 #endif  // DUMP_REF_FRAME_IMAGES
 }
 
-static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
-  MACROBLOCKD *xd = &cpi->td.mb.e_mbd;
-  struct loopfilter *lf = &cm->lf;
-  if (is_lossless_requested(&cpi->oxcf)) {
-    lf->filter_level = 0;
-  } else {
-    struct aom_usec_timer timer;
-
-    aom_clear_system_state();
-
-    aom_usec_timer_start(&timer);
-
-    av1_pick_filter_level(cpi->source, cpi, cpi->sf.lpf_pick);
-
-    aom_usec_timer_mark(&timer);
-    cpi->time_pick_lpf += aom_usec_timer_elapsed(&timer);
-  }
-
-  if (lf->filter_level > 0) {
-#if CONFIG_VAR_TX || CONFIG_EXT_PARTITION || CONFIG_CB4X4
-    av1_loop_filter_frame(cm->frame_to_show, cm, xd, lf->filter_level, 0, 0);
-#else
-    if (cpi->num_workers > 1)
-      av1_loop_filter_frame_mt(cm->frame_to_show, cm, xd->plane,
-                               lf->filter_level, 0, 0, cpi->workers,
-                               cpi->num_workers, &cpi->lf_row_sync);
-    else
-      av1_loop_filter_frame(cm->frame_to_show, cm, xd, lf->filter_level, 0, 0);
-#endif
-  }
-#if CONFIG_CDEF
-  if (is_lossless_requested(&cpi->oxcf)) {
-    cm->cdef_bits = 0;
-    cm->cdef_strengths[0] = 0;
-    cm->nb_cdef_strengths = 1;
-  } else {
-    // Find cm->dering_level, cm->clpf_strength_u and cm->clpf_strength_v
-    av1_cdef_search(cm->frame_to_show, cpi->source, cm, xd);
-
-    // Apply the filter
-    av1_cdef_frame(cm->frame_to_show, cm, xd);
-  }
-#endif
-#if CONFIG_LOOP_RESTORATION
-  av1_pick_filter_restoration(cpi->source, cpi, cpi->sf.lpf_pick);
-  if (cm->rst_info[0].frame_restoration_type != RESTORE_NONE ||
-      cm->rst_info[1].frame_restoration_type != RESTORE_NONE ||
-      cm->rst_info[2].frame_restoration_type != RESTORE_NONE) {
-    av1_loop_restoration_frame(cm->frame_to_show, cm, cm->rst_info, 7, 0, NULL);
-  }
-#endif  // CONFIG_LOOP_RESTORATION
-  aom_extend_frame_inner_borders(cm->frame_to_show);
-}
-
 static INLINE void alloc_frame_mvs(AV1_COMMON *const cm, int buffer_idx) {
+  assert(buffer_idx != INVALID_IDX);
   RefCntBuffer *const new_fb_ptr = &cm->buffer_pool->frame_bufs[buffer_idx];
   if (new_fb_ptr->mvs == NULL || new_fb_ptr->mi_rows < cm->mi_rows ||
       new_fb_ptr->mi_cols < cm->mi_cols) {
     aom_free(new_fb_ptr->mvs);
     CHECK_MEM_ERROR(cm, new_fb_ptr->mvs,
                     (MV_REF *)aom_calloc(cm->mi_rows * cm->mi_cols,
                                          sizeof(*new_fb_ptr->mvs)));
     new_fb_ptr->mi_rows = cm->mi_rows;
@@ -3482,41 +3370,16 @@ void av1_scale_references(AV1_COMP *cpi)
                                        NULL, NULL, NULL))
             aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
                                "Failed to allocate frame buffer");
           scale_and_extend_frame(ref, &new_fb_ptr->buf, MAX_MB_PLANE);
           cpi->scaled_ref_idx[ref_frame - 1] = new_fb;
           alloc_frame_mvs(cm, new_fb);
         }
 #endif  // CONFIG_HIGHBITDEPTH
-
-        if (cpi->sf.use_upsampled_references &&
-            (force_scaling || new_fb_ptr->buf.y_crop_width != cm->width ||
-             new_fb_ptr->buf.y_crop_height != cm->height)) {
-          const int map_idx = get_ref_frame_map_idx(cpi, ref_frame);
-          EncRefCntBuffer *ubuf =
-              &cpi->upsampled_ref_bufs[cpi->upsampled_ref_idx[map_idx]];
-
-          if (aom_realloc_frame_buffer(&ubuf->buf, (cm->width << 3),
-                                       (cm->height << 3), cm->subsampling_x,
-                                       cm->subsampling_y,
-#if CONFIG_HIGHBITDEPTH
-                                       cm->use_highbitdepth,
-#endif
-                                       (AOM_BORDER_IN_PIXELS << 3),
-                                       cm->byte_alignment, NULL, NULL, NULL))
-            aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
-                               "Failed to allocate up-sampled frame buffer");
-#if CONFIG_HIGHBITDEPTH
-          scale_and_extend_frame(&new_fb_ptr->buf, &ubuf->buf, 1,
-                                 (int)cm->bit_depth);
-#else
-          scale_and_extend_frame(&new_fb_ptr->buf, &ubuf->buf, 1);
-#endif
-        }
       } else {
         const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
         RefCntBuffer *const buf = &pool->frame_bufs[buf_idx];
         buf->buf.y_crop_width = ref->y_crop_width;
         buf->buf.y_crop_height = ref->y_crop_height;
         cpi->scaled_ref_idx[ref_frame - 1] = buf_idx;
         ++buf->ref_count;
       }
@@ -3737,76 +3600,48 @@ static void init_motion_estimation(AV1_C
   if (cpi->sf.mv.search_method == NSTEP) {
     av1_init3smotion_compensation(&cpi->ss_cfg, y_stride);
   } else if (cpi->sf.mv.search_method == DIAMOND) {
     av1_init_dsmotion_compensation(&cpi->ss_cfg, y_stride);
   }
 }
 
 #if CONFIG_LOOP_RESTORATION
-static void set_restoration_tilesize(int width, int height,
+#define COUPLED_CHROMA_FROM_LUMA_RESTORATION 0
+static void set_restoration_tilesize(int width, int height, int sx, int sy,
                                      RestorationInfo *rst) {
   (void)width;
   (void)height;
+  (void)sx;
+  (void)sy;
+#if COUPLED_CHROMA_FROM_LUMA_RESTORATION
+  int s = AOMMIN(sx, sy);
+#else
+  int s = 0;
+#endif  // !COUPLED_CHROMA_FROM_LUMA_RESTORATION
+
   rst[0].restoration_tilesize = (RESTORATION_TILESIZE_MAX >> 1);
-  rst[1].restoration_tilesize = rst[0].restoration_tilesize;
-  rst[2].restoration_tilesize = rst[0].restoration_tilesize;
+  rst[1].restoration_tilesize = rst[0].restoration_tilesize >> s;
+  rst[2].restoration_tilesize = rst[1].restoration_tilesize;
 }
 #endif  // CONFIG_LOOP_RESTORATION
 
-static void set_scaled_size(AV1_COMP *cpi) {
+static void set_frame_size(AV1_COMP *cpi, int width, int height) {
   AV1_COMMON *const cm = &cpi->common;
-  AV1EncoderConfig *const oxcf = &cpi->oxcf;
-
-  // TODO(afergs): Replace with call to av1_resize_pending? Could replace
-  //               scaled_size_set as well.
-  // TODO(afergs): Realistically, if resize_pending is true, then the other
-  //               conditions must already be satisfied.
-  //               Try this first:
-  //                 av1_resize_pending &&
-  //                 (DYNAMIC && (1 Pass CBR || 2 Pass VBR)
-  //                  STATIC  && FIRST_FRAME)
-  //               Really, av1_resize_pending should just reflect the above.
-  // TODO(afergs): Allow fixed resizing in AOM_CBR mode?
-  // 2 Pass VBR: Resize if fixed resize and first frame, or dynamic resize and
-  //             a resize is pending.
-  // 1 Pass CBR: Resize if dynamic resize and resize pending.
-  if ((oxcf->pass == 2 && oxcf->rc_mode == AOM_VBR &&
-       ((oxcf->resize_mode == RESIZE_FIXED && cm->current_video_frame == 0) ||
-        (oxcf->resize_mode == RESIZE_DYNAMIC && av1_resize_pending(cpi)))) ||
-      (oxcf->pass == 0 && oxcf->rc_mode == AOM_CBR &&
-       oxcf->resize_mode == RESIZE_DYNAMIC && av1_resize_pending(cpi))) {
-    // TODO(afergs): This feels hacky... Should it just set? Should
-    //               av1_set_next_scaled_size be a library function?
-    av1_calculate_next_scaled_size(cpi, &oxcf->scaled_frame_width,
-                                   &oxcf->scaled_frame_height);
-  }
-}
-
-static void set_frame_size(AV1_COMP *cpi, int width, int height) {
+  MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
   int ref_frame;
-  AV1_COMMON *const cm = &cpi->common;
-  AV1EncoderConfig *const oxcf = &cpi->oxcf;
-  MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
 
   if (width != cm->width || height != cm->height) {
     // There has been a change in the encoded frame size
     av1_set_size_literal(cpi, width, height);
-
-    // TODO(agrange) Scale cpi->max_mv_magnitude if frame-size has changed.
-    // TODO(afergs): Make condition just (pass == 0) or (rc_mode == CBR) -
-    //               UNLESS CBR starts allowing FIXED resizing. Then the resize
-    //               mode will need to get checked too.
-    if (oxcf->pass == 0 && oxcf->rc_mode == AOM_CBR &&
-        oxcf->resize_mode == RESIZE_DYNAMIC)
-      set_mv_search_params(cpi);  // TODO(afergs): Needed? Caller calls after...
+    set_mv_search_params(cpi);
   }
 
 #if !CONFIG_XIPHRC
-  if (oxcf->pass == 2) {
+  if (cpi->oxcf.pass == 2) {
     av1_set_target_rate(cpi);
   }
 #endif
 
   alloc_frame_mvs(cm, cm->new_fb_idx);
 
   // Reset the frame pointers to the current frame size.
   if (aom_realloc_frame_buffer(get_frame_new_buffer(cm), cm->width, cm->height,
@@ -3815,28 +3650,39 @@ static void set_frame_size(AV1_COMP *cpi
                                cm->use_highbitdepth,
 #endif
                                AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL,
                                NULL, NULL))
     aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
                        "Failed to allocate frame buffer");
 
 #if CONFIG_LOOP_RESTORATION
-  set_restoration_tilesize(cm->width, cm->height, cm->rst_info);
+  set_restoration_tilesize(
+#if CONFIG_FRAME_SUPERRES
+      cm->superres_upscaled_width, cm->superres_upscaled_height,
+#else
+      cm->width, cm->height,
+#endif  // CONFIG_FRAME_SUPERRES
+      cm->subsampling_x, cm->subsampling_y, cm->rst_info);
   for (int i = 0; i < MAX_MB_PLANE; ++i)
     cm->rst_info[i].frame_restoration_type = RESTORE_NONE;
   av1_alloc_restoration_buffers(cm);
   for (int i = 0; i < MAX_MB_PLANE; ++i) {
     cpi->rst_search[i].restoration_tilesize =
         cm->rst_info[i].restoration_tilesize;
-    av1_alloc_restoration_struct(cm, &cpi->rst_search[i], cm->width,
-                                 cm->height);
+    av1_alloc_restoration_struct(cm, &cpi->rst_search[i],
+#if CONFIG_FRAME_SUPERRES
+                                 cm->superres_upscaled_width,
+                                 cm->superres_upscaled_height);
+#else
+                                 cm->width, cm->height);
+#endif  // CONFIG_FRAME_SUPERRES
   }
-#endif  // CONFIG_LOOP_RESTORATION
-  alloc_util_frame_buffers(cpi);
+#endif                            // CONFIG_LOOP_RESTORATION
+  alloc_util_frame_buffers(cpi);  // TODO(afergs): Remove? Gets called anyways.
   init_motion_estimation(cpi);
 
   for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
     RefBuffer *const ref_buf = &cm->frame_refs[ref_frame - LAST_FRAME];
     const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
 
     ref_buf->idx = buf_idx;
 
@@ -3852,109 +3698,182 @@ static void set_frame_size(AV1_COMP *cpi
                                         buf->y_crop_height, cm->width,
                                         cm->height);
 #endif  // CONFIG_HIGHBITDEPTH
       if (av1_is_scaled(&ref_buf->sf)) aom_extend_frame_borders(buf);
     } else {
       ref_buf->buf = NULL;
     }
   }
+
+#if CONFIG_VAR_REFS
+  // Check duplicate reference frames
+  enc_check_valid_ref_frames(cpi);
+#endif  // CONFIG_VAR_REFS
+
 #if CONFIG_INTRABC
 #if CONFIG_HIGHBITDEPTH
   av1_setup_scale_factors_for_frame(&xd->sf_identity, cm->width, cm->height,
                                     cm->width, cm->height,
                                     cm->use_highbitdepth);
 #else
   av1_setup_scale_factors_for_frame(&xd->sf_identity, cm->width, cm->height,
                                     cm->width, cm->height);
 #endif  // CONFIG_HIGHBITDEPTH
 #endif  // CONFIG_INTRABC
 
   set_ref_ptrs(cm, xd, LAST_FRAME, LAST_FRAME);
 }
 
 static void setup_frame_size(AV1_COMP *cpi) {
-  set_scaled_size(cpi);
+  int encode_width = cpi->oxcf.width;
+  int encode_height = cpi->oxcf.height;
+
+  uint8_t resize_num = av1_calculate_next_resize_scale(cpi);
+  av1_calculate_scaled_size(&encode_width, &encode_height, resize_num);
+
+#if CONFIG_FRAME_SUPERRES
+  AV1_COMMON *cm = &cpi->common;
+  cm->superres_upscaled_width = encode_width;
+  cm->superres_upscaled_height = encode_height;
+  cm->superres_scale_numerator =
+      av1_calculate_next_superres_scale(cpi, encode_width, encode_width);
+  av1_calculate_scaled_size(&encode_width, &encode_height,
+                            cm->superres_scale_numerator);
+#endif  // CONFIG_FRAME_SUPERRES
+
+  set_frame_size(cpi, encode_width, encode_height);
+}
+
 #if CONFIG_FRAME_SUPERRES
-  int encode_width;
-  int encode_height;
-  av1_calculate_superres_size(cpi, &encode_width, &encode_height);
-  set_frame_size(cpi, encode_width, encode_height);
+static void superres_post_encode(AV1_COMP *cpi) {
+  AV1_COMMON *cm = &cpi->common;
+
+  if (av1_superres_unscaled(cm)) return;
+
+  av1_superres_upscale(cm, NULL);
+
+  // If regular resizing is occurring the source will need to be downscaled to
+  // match the upscaled superres resolution. Otherwise the original source is
+  // used.
+  if (av1_resize_unscaled(cm)) {
+    cpi->source = cpi->unscaled_source;
+    if (cpi->last_source != NULL) cpi->last_source = cpi->unscaled_last_source;
+  } else {
+    assert(cpi->unscaled_source->y_crop_width != cm->superres_upscaled_width);
+    assert(cpi->unscaled_source->y_crop_height != cm->superres_upscaled_height);
+    // Do downscale. cm->(width|height) has been updated by av1_superres_upscale
+    if (aom_realloc_frame_buffer(
+            &cpi->scaled_source, cm->superres_upscaled_width,
+            cm->superres_upscaled_height, cm->subsampling_x, cm->subsampling_y,
+#if CONFIG_HIGHBITDEPTH
+            cm->use_highbitdepth,
+#endif  // CONFIG_HIGHBITDEPTH
+            AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL, NULL, NULL))
+      aom_internal_error(
+          &cm->error, AOM_CODEC_MEM_ERROR,
+          "Failed to reallocate scaled source buffer for superres");
+    assert(cpi->scaled_source.y_crop_width == cm->superres_upscaled_width);
+    assert(cpi->scaled_source.y_crop_height == cm->superres_upscaled_height);
+#if CONFIG_HIGHBITDEPTH
+    av1_resize_and_extend_frame(cpi->unscaled_source, &cpi->scaled_source,
+                                (int)cm->bit_depth);
 #else
-  set_frame_size(cpi, cpi->oxcf.scaled_frame_width,
-                 cpi->oxcf.scaled_frame_height);
-#endif  // CONFIG_FRAME_SUPERRES
+    av1_resize_and_extend_frame(cpi->unscaled_source, &cpi->scaled_source);
+#endif  // CONFIG_HIGHBITDEPTH
+    cpi->source = &cpi->scaled_source;
+  }
 }
-
-static void reset_use_upsampled_references(AV1_COMP *cpi) {
-  MV_REFERENCE_FRAME ref_frame;
-
-  // reset up-sampled reference buffer structure.
-  init_upsampled_ref_frame_bufs(cpi);
-
-  for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
-    const YV12_BUFFER_CONFIG *const ref = get_ref_frame_buffer(cpi, ref_frame);
-    int new_uidx = upsample_ref_frame(cpi, ref);
-
-    // Update the up-sampled reference index.
-    cpi->upsampled_ref_idx[get_ref_frame_map_idx(cpi, ref_frame)] = new_uidx;
-    cpi->upsampled_ref_bufs[new_uidx].ref_count++;
+#endif  // CONFIG_FRAME_SUPERRES
+
+static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
+  MACROBLOCKD *xd = &cpi->td.mb.e_mbd;
+  struct loopfilter *lf = &cm->lf;
+  if (is_lossless_requested(&cpi->oxcf)) {
+    lf->filter_level = 0;
+  } else {
+    struct aom_usec_timer timer;
+
+    aom_clear_system_state();
+
+    aom_usec_timer_start(&timer);
+
+    av1_pick_filter_level(cpi->source, cpi, cpi->sf.lpf_pick);
+
+    aom_usec_timer_mark(&timer);
+    cpi->time_pick_lpf += aom_usec_timer_elapsed(&timer);
   }
+
+  if (lf->filter_level > 0) {
+#if CONFIG_VAR_TX || CONFIG_EXT_PARTITION || CONFIG_CB4X4
+    av1_loop_filter_frame(cm->frame_to_show, cm, xd, lf->filter_level, 0, 0);
+#else
+    if (cpi->num_workers > 1)
+      av1_loop_filter_frame_mt(cm->frame_to_show, cm, xd->plane,
+                               lf->filter_level, 0, 0, cpi->workers,
+                               cpi->num_workers, &cpi->lf_row_sync);
+    else
+      av1_loop_filter_frame(cm->frame_to_show, cm, xd, lf->filter_level, 0, 0);
+#endif
+  }
+#if CONFIG_CDEF
+  if (is_lossless_requested(&cpi->oxcf)) {
+    cm->cdef_bits = 0;
+    cm->cdef_strengths[0] = 0;
+    cm->nb_cdef_strengths = 1;
+  } else {
+    // Find cm->dering_level, cm->clpf_strength_u and cm->clpf_strength_v
+    av1_cdef_search(cm->frame_to_show, cpi->source, cm, xd,
+                    cpi->oxcf.speed > 0);
+
+    // Apply the filter
+    av1_cdef_frame(cm->frame_to_show, cm, xd);
+  }
+#endif
+
+#if CONFIG_FRAME_SUPERRES
+  superres_post_encode(cpi);
+#endif  // CONFIG_FRAME_SUPERRES
+
+#if CONFIG_LOOP_RESTORATION
+  av1_pick_filter_restoration(cpi->source, cpi, cpi->sf.lpf_pick);
+  if (cm->rst_info[0].frame_restoration_type != RESTORE_NONE ||
+      cm->rst_info[1].frame_restoration_type != RESTORE_NONE ||
+      cm->rst_info[2].frame_restoration_type != RESTORE_NONE) {
+    av1_loop_restoration_frame(cm->frame_to_show, cm, cm->rst_info, 7, 0, NULL);
+  }
+#endif  // CONFIG_LOOP_RESTORATION
+  // TODO(debargha): Fix mv search range on encoder side
+  // aom_extend_frame_inner_borders(cm->frame_to_show);
+  aom_extend_frame_borders(cm->frame_to_show);
 }
 
 static void encode_without_recode_loop(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
   int q = 0, bottom_index = 0, top_index = 0;  // Dummy variables.
-  const int use_upsampled_ref = cpi->sf.use_upsampled_references;
 
   aom_clear_system_state();
 
-#if CONFIG_FRAME_SUPERRES
-  // TODO(afergs): Figure out when is actually a good time to do superres
-  cm->superres_scale_numerator = SUPERRES_SCALE_DENOMINATOR;
-  // (uint8_t)(rand() % 9 + SUPERRES_SCALE_NUMERATOR_MIN);
-  cpi->superres_pending = cpi->oxcf.superres_enabled && 0;
-#endif  // CONFIG_FRAME_SUPERRES
-
+  set_size_independent_vars(cpi);
   setup_frame_size(cpi);
-  av1_resize_step(cpi);
-
-  // For 1 pass CBR under dynamic resize mode: use faster scaling for source.
-  // Only for 2x2 scaling for now.
-  if (cpi->oxcf.pass == 0 && cpi->oxcf.rc_mode == AOM_CBR &&
-      cpi->oxcf.resize_mode == RESIZE_DYNAMIC &&
-      cpi->un_scaled_source->y_width == (cm->width << 1) &&
-      cpi->un_scaled_source->y_height == (cm->height << 1)) {
-    cpi->source = av1_scale_if_required_fast(cm, cpi->un_scaled_source,
-                                             &cpi->scaled_source);
-    if (cpi->unscaled_last_source != NULL)
-      cpi->last_source = av1_scale_if_required_fast(
-          cm, cpi->unscaled_last_source, &cpi->scaled_last_source);
-  } else {
-    cpi->source =
-        av1_scale_if_required(cm, cpi->un_scaled_source, &cpi->scaled_source);
-    if (cpi->unscaled_last_source != NULL)
-      cpi->last_source = av1_scale_if_required(cm, cpi->unscaled_last_source,
-                                               &cpi->scaled_last_source);
-  }
+  assert(cm->width == cpi->scaled_source.y_crop_width);
+  assert(cm->height == cpi->scaled_source.y_crop_height);
+
+  set_size_dependent_vars(cpi, &q, &bottom_index, &top_index);
+
+  cpi->source =
+      av1_scale_if_required(cm, cpi->unscaled_source, &cpi->scaled_source);
+  if (cpi->unscaled_last_source != NULL)
+    cpi->last_source = av1_scale_if_required(cm, cpi->unscaled_last_source,
+                                             &cpi->scaled_last_source);
 
   if (frame_is_intra_only(cm) == 0) {
     av1_scale_references(cpi);
   }
 
-  set_size_independent_vars(cpi);
-  set_size_dependent_vars(cpi, &q, &bottom_index, &top_index);
-
-  // cpi->sf.use_upsampled_references can be different from frame to frame.
-  // Every time when cpi->sf.use_upsampled_references is changed from 0 to 1.
-  // The reference frames for this frame have to be up-sampled before encoding.
-  if (!use_upsampled_ref && cpi->sf.use_upsampled_references &&
-      cm->frame_type != KEY_FRAME)
-    reset_use_upsampled_references(cpi);
-
   av1_set_quantizer(cm, q);
   setup_frame(cpi);
   suppress_active_map(cpi);
 
   // Variance adaptive and in frame q adjustment experiments are mutually
   // exclusive.
   if (cpi->oxcf.aq_mode == VARIANCE_AQ) {
     av1_vaq_frame_setup(cpi);
@@ -3963,21 +3882,16 @@ static void encode_without_recode_loop(A
   } else if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) {
     av1_cyclic_refresh_setup(cpi);
   }
   apply_active_map(cpi);
 
   // transform / motion compensation build reconstruction frame
   av1_encode_frame(cpi);
 
-#if CONFIG_FRAME_SUPERRES
-  // TODO(afergs): Upscale the frame to show
-  cpi->superres_pending = 0;
-#endif  // CONFIG_FRAME_SUPERRES
-
   // Update some stats from cyclic refresh, and check if we should not update
   // golden reference, for 1 pass CBR.
   if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->frame_type != KEY_FRAME &&
       (cpi->oxcf.pass == 0 && cpi->oxcf.rc_mode == AOM_CBR))
     av1_cyclic_refresh_check_golden_update(cpi);
 
   // Update the skip mb flag probabilities based on the distribution
   // seen in the last encoder iteration.
@@ -3995,69 +3909,51 @@ static void encode_with_recode_loop(AV1_
   int loop = 0;
 #if !CONFIG_XIPHRC
   int overshoot_seen = 0;
   int undershoot_seen = 0;
 #endif
   int frame_over_shoot_limit;
   int frame_under_shoot_limit;
   int q = 0, q_low = 0, q_high = 0;
-  const int use_upsampled_ref = cpi->sf.use_upsampled_references;
 
   set_size_independent_vars(cpi);
 
   do {
     aom_clear_system_state();
 
     setup_frame_size(cpi);
 
-#if CONFIG_FRAME_SUPERRES
-    if (loop_count == 0 || av1_resize_pending(cpi) || cpi->superres_pending) {
-#else
-    if (loop_count == 0 || av1_resize_pending(cpi)) {
-#endif  // CONFIG_FRAME_SUPERRES
+    if (loop_count == 0) {
       set_size_dependent_vars(cpi, &q, &bottom_index, &top_index);
 
-      // cpi->sf.use_upsampled_references can be different from frame to frame.
-      // Every time when cpi->sf.use_upsampled_references is changed from 0 to
-      // 1.
-      // The reference frames for this frame have to be up-sampled before
-      // encoding.
-      if (!use_upsampled_ref && cpi->sf.use_upsampled_references &&
-          cm->frame_type != KEY_FRAME)
-        reset_use_upsampled_references(cpi);
-
       // TODO(agrange) Scale cpi->max_mv_magnitude if frame-size has changed.
       set_mv_search_params(cpi);
 
 #if !CONFIG_XIPHRC
       // Reset the loop state for new frame size.
       overshoot_seen = 0;
       undershoot_seen = 0;
 #endif
 
-      // Advance resize to next state now that updates are done
-      av1_resize_step(cpi);
-
       q_low = bottom_index;
       q_high = top_index;
 
       loop_at_this_size = 0;
     }
 
     // Decide frame size bounds first time through.
     if (loop_count == 0) {
       av1_rc_compute_frame_size_bounds(cpi, rc->this_frame_target,
                                        &frame_under_shoot_limit,
                                        &frame_over_shoot_limit);
     }
 
     cpi->source =
-        av1_scale_if_required(cm, cpi->un_scaled_source, &cpi->scaled_source);
-
+        av1_scale_if_required(cm, cpi->unscaled_source, &cpi->scaled_source);
     if (cpi->unscaled_last_source != NULL)
       cpi->last_source = av1_scale_if_required(cm, cpi->unscaled_last_source,
                                                &cpi->scaled_last_source);
 
     if (frame_is_intra_only(cm) == 0) {
       if (loop_count > 0) {
         release_scaled_references(cpi);
       }
@@ -4169,18 +4065,16 @@ static void encode_with_recode_loop(AV1_
                                   frame_under_shoot_limit, q,
                                   AOMMAX(q_high, top_index), bottom_index)) {
         // Is the projected frame size out of range and are we allowed
         // to attempt to recode.
         int last_q = q;
 #if !CONFIG_XIPHRC
         int retries = 0;
 
-        // TODO(afergs): Replace removed recode when av1_resize_pending is true
-
         // Frame size out of permitted range:
         // Update correction factor & compute new Q to try...
         // Frame is too large
         if (rc->projected_frame_size > rc->this_frame_target) {
           // Special case if the projected size is > the max allowed.
           if (rc->projected_frame_size >= rc->max_frame_bandwidth)
             q_high = rc->worst_quality;
 
@@ -4325,17 +4219,22 @@ static int get_ref_frame_flags(const AV1
 
   if (alt_is_last) flags &= ~AOM_ALT_FLAG;
 
 #if CONFIG_EXT_REFS
   if (last2_is_last || last2_is_alt) flags &= ~AOM_LAST2_FLAG;
 
   if (last3_is_last || last3_is_last2 || last3_is_alt) flags &= ~AOM_LAST3_FLAG;
 
+#if CONFIG_EXT_COMP_REFS
+  if (gld_is_last2) flags &= ~AOM_GOLD_FLAG;
+  if (gld_is_last3) flags &= ~AOM_LAST3_FLAG;
+#else
   if (gld_is_last2 || gld_is_last3) flags &= ~AOM_GOLD_FLAG;
+#endif  // CONFIG_EXT_COMP_REFS
 
 #if CONFIG_ONE_SIDED_COMPOUND  // Changes LL & HL bitstream
   /* Allow biprediction between two identical frames (e.g. bwd_is_last = 1) */
   if (bwd_is_alt && (flags & AOM_BWD_FLAG)) flags &= ~AOM_BWD_FLAG;
 #else
   if ((bwd_is_last || bwd_is_last2 || bwd_is_last3 || bwd_is_gld ||
        bwd_is_alt) &&
       (flags & AOM_BWD_FLAG))
@@ -4605,19 +4504,16 @@ static void encode_frame_to_data_rate(AV
       drop_this_frame = od_enc_rc_update_state(
           &cpi->od_rc, *size << 3, cpi->refresh_golden_frame,
           cpi->refresh_alt_ref_frame, frame_type, cpi->droppable);
 #else
       av1_rc_postencode_update(cpi, *size);
 #endif
     }
 
-    cm->last_width = cm->width;
-    cm->last_height = cm->height;
-
     ++cm->current_video_frame;
 
 #if CONFIG_EC_ADAPT
     aom_free(tile_ctxs);
     aom_free(cdf_ptrs);
 #endif
     return;
   }
@@ -4765,16 +4661,20 @@ static void encode_frame_to_data_rate(AV
 
   // If the encoder forced a KEY_FRAME decision
   if (cm->frame_type == KEY_FRAME) {
     cpi->refresh_last_frame = 1;
   }
 
   cm->frame_to_show = get_frame_new_buffer(cm);
   cm->frame_to_show->color_space = cm->color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  cm->frame_to_show->transfer_function = cm->transfer_function;
+  cm->frame_to_show->chroma_sample_position = cm->chroma_sample_position;
+#endif
   cm->frame_to_show->color_range = cm->color_range;
   cm->frame_to_show->render_width = cm->render_width;
   cm->frame_to_show->render_height = cm->render_height;
 
 #if CONFIG_EXT_REFS
 // TODO(zoeliu): For non-ref frames, loop filtering may need to be turned
 // off.
 #endif  // CONFIG_EXT_REFS
@@ -4818,16 +4718,19 @@ static void encode_frame_to_data_rate(AV
 
   av1_update_reference_frames(cpi);
 
   for (t = 0; t < TX_SIZES; t++)
     av1_full_to_model_counts(cpi->td.counts->coef[t],
                              cpi->td.rd_counts.coef_counts[t]);
 #if CONFIG_ENTROPY_STATS
   av1_accumulate_frame_counts(&aggregate_fc, &cm->counts);
+  assert(cm->frame_context_idx < FRAME_CONTEXTS);
+  av1_accumulate_frame_counts(&aggregate_fc_per_type[cm->frame_context_idx],
+                              &cm->counts);
 #endif  // CONFIG_ENTROPY_STATS
   if (cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
     av1_adapt_coef_probs(cm);
     av1_adapt_intra_frame_probs(cm);
 #if CONFIG_EC_ADAPT
     make_update_tile_list_enc(cpi, cm->tile_rows, cm->tile_cols, tile_ctxs);
     av1_average_tile_coef_cdfs(cpi->common.fc, tile_ctxs, cdf_ptrs,
                                cm->tile_rows * cm->tile_cols);
@@ -4910,39 +4813,41 @@ static void encode_frame_to_data_rate(AV
   }
 
   // Clear the one shot update flags for segmentation map and mode/ref loop
   // filter deltas.
   cm->seg.update_map = 0;
   cm->seg.update_data = 0;
   cm->lf.mode_ref_delta_update = 0;
 
-  // keep track of the last coded dimensions
-  cm->last_width = cm->width;
-  cm->last_height = cm->height;
-
-  // reset to normal state now that we are done.
-  if (!cm->show_existing_frame) cm->last_show_frame = cm->show_frame;
-
   if (cm->show_frame) {
 #if CONFIG_EXT_REFS
 // TODO(zoeliu): We may only swamp mi and prev_mi for those frames that are
 // being used as reference.
 #endif  // CONFIG_EXT_REFS
     av1_swap_mi_and_prev_mi(cm);
     // Don't increment frame counters if this was an altref buffer
     // update not a real frame
     ++cm->current_video_frame;
   }
 
 #if CONFIG_EXT_REFS
   // NOTE: Shall not refer to any frame not used as reference.
-  if (cm->is_reference_frame)
+  if (cm->is_reference_frame) {
 #endif  // CONFIG_EXT_REFS
     cm->prev_frame = cm->cur_frame;
+    // keep track of the last coded dimensions
+    cm->last_width = cm->width;
+    cm->last_height = cm->height;
+
+    // reset to normal state now that we are done.
+    cm->last_show_frame = cm->show_frame;
+#if CONFIG_EXT_REFS
+  }
+#endif  // CONFIG_EXT_REFS
 #if CONFIG_EC_ADAPT
   aom_free(tile_ctxs);
   aom_free(cdf_ptrs);
 #endif
 }
 
 static void Pass0Encode(AV1_COMP *cpi, size_t *size, uint8_t *dest,
                         int skip_adapt, unsigned int *frame_flags) {
@@ -5443,18 +5348,25 @@ int av1_get_compressed_data(AV1_COMP *cp
 
   if (arf_src_index) {
     assert(arf_src_index <= rc->frames_to_key);
 
     if ((source = av1_lookahead_peek(cpi->lookahead, arf_src_index)) != NULL) {
       cpi->alt_ref_source = source;
 
       if (oxcf->arnr_max_frames > 0) {
-        // Produce the filtered ARF frame.
+// Produce the filtered ARF frame.
+#if CONFIG_BGSPRITE
+        int bgsprite_ret = av1_background_sprite(cpi, arf_src_index);
+        if (bgsprite_ret != EXIT_SUCCESS) {
+          av1_temporal_filter(cpi, arf_src_index);
+        }
+#else
         av1_temporal_filter(cpi, arf_src_index);
+#endif  // CONFIG_BGSPRITE
         aom_extend_frame_borders(&cpi->alt_ref_buffer);
         force_src_buffer = &cpi->alt_ref_buffer;
       }
 
       cm->show_frame = 0;
       cm->intra_only = 0;
       cpi->refresh_alt_ref_frame = 1;
       cpi->refresh_golden_frame = 0;
@@ -5484,33 +5396,31 @@ int av1_get_compressed_data(AV1_COMP *cp
 #endif  // CONFIG_EXT_REFS
 
   if (!source) {
     // Get last frame source.
     if (cm->current_video_frame > 0) {
       if ((last_source = av1_lookahead_peek(cpi->lookahead, -1)) == NULL)
         return -1;
     }
-
+    if (cm->current_video_frame > 0) assert(last_source != NULL);
     // Read in the source frame.
     source = av1_lookahead_pop(cpi->lookahead, flush);
 
     if (source != NULL) {
       cm->show_frame = 1;
       cm->intra_only = 0;
 
       // Check to see if the frame should be encoded as an arf overlay.
       check_src_altref(cpi, source);
     }
   }
-
   if (source) {
-    cpi->un_scaled_source = cpi->source =
+    cpi->unscaled_source = cpi->source =
         force_src_buffer ? force_src_buffer : &source->img;
-
     cpi->unscaled_last_source = last_source != NULL ? &last_source->img : NULL;
 
     *time_stamp = source->ts_start;
     *time_end = source->ts_end;
     *frame_flags = (source->flags & AOM_EFLAG_FORCE_KF) ? FRAMEFLAGS_KEY : 0;
 
   } else {
     *size = 0;
@@ -5571,17 +5481,16 @@ int av1_get_compressed_data(AV1_COMP *cp
   if (oxcf->pass == 2) {
 #if CONFIG_XIPHRC
     if (od_enc_rc_2pass_in(&cpi->od_rc) < 0) return -1;
   }
 #else
     av1_rc_get_second_pass_params(cpi);
   } else if (oxcf->pass == 1) {
     setup_frame_size(cpi);
-    av1_resize_step(cpi);
   }
 #endif
 
   if (cpi->oxcf.pass != 0 || frame_is_intra_only(cm) == 1) {
     for (i = 0; i < TOTAL_REFS_PER_FRAME; ++i)
       cpi->scaled_ref_idx[i] = INVALID_IDX;
   }
 
@@ -5707,19 +5616,20 @@ int av1_set_internal_size(AV1_COMP *cpi,
   update_frame_size(cpi);
 
   return 0;
 }
 
 int av1_set_size_literal(AV1_COMP *cpi, int width, int height) {
   AV1_COMMON *cm = &cpi->common;
 #if CONFIG_HIGHBITDEPTH
-  check_initial_width(cpi, cm->use_highbitdepth, 1, 1);
+  check_initial_width(cpi, cm->use_highbitdepth, cm->subsampling_x,
+                      cm->subsampling_y);
 #else
-  check_initial_width(cpi, 1, 1);
+  check_initial_width(cpi, cm->subsampling_x, cm->subsampling_y);
 #endif  // CONFIG_HIGHBITDEPTH
 
   if (width <= 0 || height <= 0) return 1;
 
   cm->width = width;
   if (cm->width > cpi->initial_width) {
     cm->width = cpi->initial_width;
     printf("Warning: Desired width too large, changed to %d\n", cm->width);
--- a/third_party/aom/av1/encoder/encoder.h
+++ b/third_party/aom/av1/encoder/encoder.h
@@ -16,16 +16,17 @@
 
 #include "./aom_config.h"
 #include "aom/aomcx.h"
 
 #include "av1/common/alloccommon.h"
 #include "av1/common/entropymode.h"
 #include "av1/common/thread_common.h"
 #include "av1/common/onyxc_int.h"
+#include "av1/common/resize.h"
 #include "av1/encoder/aq_cyclicrefresh.h"
 #if CONFIG_ANS
 #include "aom_dsp/ans.h"
 #include "aom_dsp/buf_ans.h"
 #endif
 #include "av1/encoder/av1_quantize.h"
 #include "av1/encoder/context_tree.h"
 #include "av1/encoder/encodemb.h"
@@ -47,16 +48,20 @@
 #include "aom_dsp/variance.h"
 #include "aom/internal/aom_codec_internal.h"
 #include "aom_util/aom_thread.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#if CONFIG_SPEED_REFS
+#define MIN_SPEED_REFS_BLKSIZE BLOCK_16X16
+#endif  // CONFIG_SPEED_REFS
+
 typedef struct {
   int nmv_vec_cost[NMV_CONTEXTS][MV_JOINTS];
   int nmv_costs[NMV_CONTEXTS][2][MV_VALS];
   int nmv_costs_hp[NMV_CONTEXTS][2][MV_VALS];
 
   // 0 = Intra, Last, GF, ARF
   signed char last_ref_lf_deltas[TOTAL_REFS_PER_FRAME];
   // 0 = ZERO_MV, MV
@@ -123,17 +128,24 @@ typedef enum {
   DELTA_Q_LF = 2,
   DELTAQ_MODE_COUNT  // This should always be the last member of the enum
 } DELTAQ_MODE;
 #endif
 typedef enum {
   RESIZE_NONE = 0,    // No frame resizing allowed.
   RESIZE_FIXED = 1,   // All frames are coded at the specified dimension.
   RESIZE_DYNAMIC = 2  // Coded size of each frame is determined by the codec.
-} RESIZE_TYPE;
+} RESIZE_MODE;
+#if CONFIG_FRAME_SUPERRES
+typedef enum {
+  SUPERRES_NONE = 0,
+  SUPERRES_FIXED = 1,
+  SUPERRES_DYNAMIC = 2
+} SUPERRES_MODE;
+#endif  // CONFIG_FRAME_SUPERRES
 
 typedef struct AV1EncoderConfig {
   BITSTREAM_PROFILE profile;
   aom_bit_depth_t bit_depth;     // Codec bit-depth.
   int width;                     // width of data passed to the compressor
   int height;                    // height of data passed to the compressor
   unsigned int input_bit_depth;  // Input bit depth.
   double init_framerate;         // set to passed in framerate
@@ -194,23 +206,25 @@ typedef struct AV1EncoderConfig {
   unsigned int num_tile_groups;
   unsigned int mtu;
 #endif
 
 #if CONFIG_TEMPMV_SIGNALING
   unsigned int disable_tempmv;
 #endif
   // Internal frame size scaling.
-  RESIZE_TYPE resize_mode;
-  int scaled_frame_width;
-  int scaled_frame_height;
+  RESIZE_MODE resize_mode;
+  uint8_t resize_scale_numerator;
+  uint8_t resize_kf_scale_numerator;
 
 #if CONFIG_FRAME_SUPERRES
-  // Frame Super-Resolution size scaling
-  int superres_enabled;
+  // Frame Super-Resolution size scaling.
+  SUPERRES_MODE superres_mode;
+  uint8_t superres_scale_numerator;
+  uint8_t superres_kf_scale_numerator;
 #endif  // CONFIG_FRAME_SUPERRES
 
   // Enable feature to reduce the frame quantization every x frames.
   int frame_periodic_boost;
 
   // two pass datarate control
   int two_pass_vbrbias;  // two pass datarate control tweaks
   int two_pass_vbrmin_section;
@@ -260,16 +274,20 @@ typedef struct AV1EncoderConfig {
 #endif
 
   aom_tune_metric tuning;
   aom_tune_content content;
 #if CONFIG_HIGHBITDEPTH
   int use_highbitdepth;
 #endif
   aom_color_space_t color_space;
+#if CONFIG_COLORSPACE_HEADERS
+  aom_transfer_function_t transfer_function;
+  aom_chroma_sample_position_t chroma_sample_position;
+#endif
   int color_range;
   int render_width;
   int render_height;
 
 #if CONFIG_EXT_PARTITION
   aom_superblock_size_t superblock_size;
 #endif  // CONFIG_EXT_PARTITION
 #if CONFIG_ANS && ANS_MAX_SYMBOLS
@@ -306,16 +324,18 @@ typedef struct TileDataEnc {
 
 typedef struct RD_COUNTS {
   av1_coeff_count coef_counts[TX_SIZES][PLANE_TYPES];
   int64_t comp_pred_diff[REFERENCE_MODES];
 #if CONFIG_GLOBAL_MOTION
   // Stores number of 4x4 blocks using global motion per reference frame.
   int global_motion_used[TOTAL_REFS_PER_FRAME];
 #endif  // CONFIG_GLOBAL_MOTION
+  int single_ref_used_flag;
+  int compound_ref_used_flag;
 } RD_COUNTS;
 
 typedef struct ThreadData {
   MACROBLOCK mb;
   RD_COUNTS rd_counts;
   FRAME_COUNTS *counts;
 
   PICK_MODE_CONTEXT *leaf_tree;
@@ -367,28 +387,21 @@ typedef struct AV1_COMP {
   Dequants dequants;
   AV1_COMMON common;
   AV1EncoderConfig oxcf;
   struct lookahead_ctx *lookahead;
   struct lookahead_entry *alt_ref_source;
 
   YV12_BUFFER_CONFIG *source;
   YV12_BUFFER_CONFIG *last_source;  // NULL for first frame and alt_ref frames
-  YV12_BUFFER_CONFIG *un_scaled_source;
+  YV12_BUFFER_CONFIG *unscaled_source;
   YV12_BUFFER_CONFIG scaled_source;
   YV12_BUFFER_CONFIG *unscaled_last_source;
   YV12_BUFFER_CONFIG scaled_last_source;
 
-  // Up-sampled reference buffers
-  // NOTE(zoeliu): It is needed to allocate sufficient space to the up-sampled
-  // reference buffers, which should include the up-sampled version of all the
-  // possibly stored references plus the currently coded frame itself.
-  EncRefCntBuffer upsampled_ref_bufs[REF_FRAMES + 1];
-  int upsampled_ref_idx[REF_FRAMES + 1];
-
   // For a still frame, this flag is set to 1 to skip partition search.
   int partition_search_skippable_frame;
 
   int scaled_ref_idx[TOTAL_REFS_PER_FRAME];
 #if CONFIG_EXT_REFS
   int lst_fb_idxes[LAST_REF_FRAMES];
 #else
   int lst_fb_idx;
@@ -533,16 +546,20 @@ typedef struct AV1_COMP {
   int zeromv_mode_cost[ZEROMV_MODE_CONTEXTS][2];
   int refmv_mode_cost[REFMV_MODE_CONTEXTS][2];
   int drl_mode_cost0[DRL_MODE_CONTEXTS][2];
 
   unsigned int inter_mode_cost[INTER_MODE_CONTEXTS][INTER_MODES];
 #if CONFIG_EXT_INTER
   unsigned int inter_compound_mode_cost[INTER_MODE_CONTEXTS]
                                        [INTER_COMPOUND_MODES];
+#if CONFIG_COMPOUND_SINGLEREF
+  unsigned int inter_singleref_comp_mode_cost[INTER_MODE_CONTEXTS]
+                                             [INTER_SINGLEREF_COMP_MODES];
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_INTERINTRA
   unsigned int interintra_mode_cost[BLOCK_SIZE_GROUPS][INTERINTRA_MODES];
 #endif  // CONFIG_INTERINTRA
 #endif  // CONFIG_EXT_INTER
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   int motion_mode_cost[BLOCK_SIZES][MOTION_MODES];
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
   int motion_mode_cost1[BLOCK_SIZES][2];
@@ -596,28 +613,20 @@ typedef struct AV1_COMP {
   int allocated_tiles;  // Keep track of memory allocated for tiles.
 
   TOKENEXTRA *tile_tok[MAX_TILE_ROWS][MAX_TILE_COLS];
   unsigned int tok_count[MAX_TILE_ROWS][MAX_TILE_COLS];
 
   TileBufferEnc tile_buffers[MAX_TILE_ROWS][MAX_TILE_COLS];
 
   int resize_state;
-  int resize_scale_num;
-  int resize_scale_den;
-  int resize_next_scale_num;
-  int resize_next_scale_den;
   int resize_avg_qp;
   int resize_buffer_underflow;
   int resize_count;
 
-#if CONFIG_FRAME_SUPERRES
-  int superres_pending;
-#endif  // CONFIG_FRAME_SUPERRES
-
   // VARIANCE_AQ segment map refresh
   int vaq_refresh;
 
   // Multi-threading
   int num_workers;
   AVxWorker *workers;
   struct EncWorkerData *tile_thr_data;
   AV1LfSync lf_row_sync;
@@ -635,16 +644,20 @@ typedef struct AV1_COMP {
   int global_motion_search_done;
 #endif
 #if CONFIG_REFERENCE_BUFFER
   SequenceHeader seq_params;
 #endif
 #if CONFIG_LV_MAP
   tran_low_t *tcoeff_buf[MAX_MB_PLANE];
 #endif
+
+#if CONFIG_SPEED_REFS
+  int sb_scanning_pass_idx;
+#endif  // CONFIG_SPEED_REFS
 } AV1_COMP;
 
 void av1_initialize_enc(void);
 
 struct AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf,
                                        BufferPool *const pool);
 void av1_remove_compressor(AV1_COMP *cpi);
 
@@ -724,24 +737,16 @@ static INLINE int get_ref_frame_buf_idx(
 static INLINE YV12_BUFFER_CONFIG *get_ref_frame_buffer(
     const AV1_COMP *cpi, MV_REFERENCE_FRAME ref_frame) {
   const AV1_COMMON *const cm = &cpi->common;
   const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
   return buf_idx != INVALID_IDX ? &cm->buffer_pool->frame_bufs[buf_idx].buf
                                 : NULL;
 }
 
-static INLINE const YV12_BUFFER_CONFIG *get_upsampled_ref(
-    const AV1_COMP *cpi, const MV_REFERENCE_FRAME ref_frame) {
-  // Use up-sampled reference frames.
-  const int buf_idx =
-      cpi->upsampled_ref_idx[get_ref_frame_map_idx(cpi, ref_frame)];
-  return &cpi->upsampled_ref_bufs[buf_idx].buf;
-}
-
 #if CONFIG_EXT_REFS || CONFIG_TEMPMV_SIGNALING
 static INLINE int enc_is_ref_frame_buf(AV1_COMP *cpi, RefCntBuffer *frame_buf) {
   MV_REFERENCE_FRAME ref_frame;
   AV1_COMMON *const cm = &cpi->common;
   for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
     const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
     if (buf_idx == INVALID_IDX) continue;
     if (frame_buf == &cm->buffer_pool->frame_bufs[buf_idx]) break;
@@ -826,32 +831,31 @@ static INLINE void uref_cnt_fb(EncRefCnt
 
   if (ref_index >= 0 && ubufs[ref_index].ref_count > 0)
     ubufs[ref_index].ref_count--;
 
   *uidx = new_uidx;
   ubufs[new_uidx].ref_count++;
 }
 
-// Returns 1 if a resize is pending and 0 otherwise.
-static INLINE int av1_resize_pending(const struct AV1_COMP *cpi) {
-  return cpi->resize_scale_num != cpi->resize_next_scale_num ||
-         cpi->resize_scale_den != cpi->resize_next_scale_den;
+// Returns 1 if a frame is unscaled and 0 otherwise.
+static INLINE int av1_resize_unscaled(const AV1_COMMON *cm) {
+#if CONFIG_FRAME_SUPERRES
+  return cm->superres_upscaled_width == cm->render_width &&
+         cm->superres_upscaled_height == cm->render_height;
+#else
+  return cm->width == cm->render_width && cm->height == cm->render_height;
+#endif  // CONFIG_FRAME_SUPERRES
 }
 
-// Returns 1 if a frame is unscaled and 0 otherwise.
-static INLINE int av1_resize_unscaled(const struct AV1_COMP *cpi) {
-  return cpi->resize_scale_num == cpi->resize_scale_den;
-}
-
-// Moves resizing to the next state. This is just setting the numerator and
-// denominator to the next numerator and denominator, causing
-// av1_resize_pending to subsequently return false.
-static INLINE void av1_resize_step(struct AV1_COMP *cpi) {
-  cpi->resize_scale_num = cpi->resize_next_scale_num;
-  cpi->resize_scale_den = cpi->resize_next_scale_den;
+static INLINE int av1_frame_unscaled(const AV1_COMMON *cm) {
+#if CONFIG_FRAME_SUPERRES
+  return av1_superres_unscaled(cm) && av1_resize_unscaled(cm);
+#else
+  return av1_resize_unscaled(cm);
+#endif  // CONFIG_FRAME_SUPERRES
 }
 
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
 #endif  // AV1_ENCODER_ENCODER_H_
--- a/third_party/aom/av1/encoder/encodetxb.c
+++ b/third_party/aom/av1/encoder/encodetxb.c
@@ -65,76 +65,76 @@ static void write_golomb(aom_writer *w, 
   assert(length > 0);
 
   for (i = 0; i < length - 1; ++i) aom_write_bit(w, 0);
 
   for (i = length - 1; i >= 0; --i) aom_write_bit(w, (x >> i) & 0x01);
 }
 
 void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
-                          aom_writer *w, int block, int plane,
+                          aom_writer *w, int block, int plane, TX_SIZE tx_size,
                           const tran_low_t *tcoeff, uint16_t eob,
                           TXB_CTX *txb_ctx) {
   aom_prob *nz_map;
   aom_prob *eob_flag;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   const PLANE_TYPE plane_type = get_plane_type(plane);
-  const TX_SIZE tx_size = get_tx_size(plane, xd);
+  const TX_SIZE txs_ctx = get_txsize_context(tx_size);
   const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
-  const SCAN_ORDER *const scan_order =
-      get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
+  const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
   const int16_t *scan = scan_order->scan;
   int c;
   int is_nz;
   const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
+  const int height = tx_size_high[tx_size];
   const int seg_eob = tx_size_2d[tx_size];
   uint8_t txb_mask[32 * 32] = { 0 };
   uint16_t update_eob = 0;
 
-  aom_write(w, eob == 0, cm->fc->txb_skip[tx_size][txb_ctx->txb_skip_ctx]);
+  aom_write(w, eob == 0, cm->fc->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx]);
 
   if (eob == 0) return;
 #if CONFIG_TXK_SEL
-  av1_write_tx_type(cm, xd, block, plane, w);
+  av1_write_tx_type(cm, xd, block, plane, get_min_tx_size(tx_size), w);
 #endif
 
-  nz_map = cm->fc->nz_map[tx_size][plane_type];
-  eob_flag = cm->fc->eob_flag[tx_size][plane_type];
+  nz_map = cm->fc->nz_map[txs_ctx][plane_type];
+  eob_flag = cm->fc->eob_flag[txs_ctx][plane_type];
 
   for (c = 0; c < eob; ++c) {
-    int coeff_ctx = get_nz_map_ctx(tcoeff, txb_mask, scan[c], bwl);
-    int eob_ctx = get_eob_ctx(tcoeff, scan[c], bwl);
+    int coeff_ctx = get_nz_map_ctx(tcoeff, txb_mask, scan[c], bwl, height);
+    int eob_ctx = get_eob_ctx(tcoeff, scan[c], txs_ctx);
 
     tran_low_t v = tcoeff[scan[c]];
     is_nz = (v != 0);
 
     if (c == seg_eob - 1) break;
 
     aom_write(w, is_nz, nz_map[coeff_ctx]);
 
     if (is_nz) {
       aom_write(w, c == (eob - 1), eob_flag[eob_ctx]);
     }
     txb_mask[scan[c]] = 1;
   }
 
   int i;
   for (i = 0; i < NUM_BASE_LEVELS; ++i) {
-    aom_prob *coeff_base = cm->fc->coeff_base[tx_size][plane_type][i];
+    aom_prob *coeff_base = cm->fc->coeff_base[txs_ctx][plane_type][i];
 
     update_eob = 0;
     for (c = eob - 1; c >= 0; --c) {
       tran_low_t v = tcoeff[scan[c]];
       tran_low_t level = abs(v);
       int sign = (v < 0) ? 1 : 0;
       int ctx;
 
       if (level <= i) continue;
 
-      ctx = get_base_ctx(tcoeff, scan[c], bwl, i + 1);
+      ctx = get_base_ctx(tcoeff, scan[c], bwl, height, i + 1);
 
       if (level == i + 1) {
         aom_write(w, 1, coeff_base[ctx]);
         if (c == 0) {
           aom_write(w, sign, cm->fc->dc_sign[plane_type][txb_ctx->dc_sign_ctx]);
         } else {
           aom_write_bit(w, sign);
         }
@@ -156,39 +156,42 @@ void av1_write_coeffs_txb(const AV1_COMM
 
     if (c == 0) {
       aom_write(w, sign, cm->fc->dc_sign[plane_type][txb_ctx->dc_sign_ctx]);
     } else {
       aom_write_bit(w, sign);
     }
 
     // level is above 1.
-    ctx = get_br_ctx(tcoeff, scan[c], bwl);
+    ctx = get_br_ctx(tcoeff, scan[c], bwl, height);
     for (idx = 0; idx < COEFF_BASE_RANGE; ++idx) {
       if (level == (idx + 1 + NUM_BASE_LEVELS)) {
-        aom_write(w, 1, cm->fc->coeff_lps[tx_size][plane_type][ctx]);
+        aom_write(w, 1, cm->fc->coeff_lps[txs_ctx][plane_type][ctx]);
         break;
       }
-      aom_write(w, 0, cm->fc->coeff_lps[tx_size][plane_type][ctx]);
+      aom_write(w, 0, cm->fc->coeff_lps[txs_ctx][plane_type][ctx]);
     }
     if (idx < COEFF_BASE_RANGE) continue;
 
     // use 0-th order Golomb code to handle the residual level.
     write_golomb(w, level - COEFF_BASE_RANGE - 1 - NUM_BASE_LEVELS);
   }
 }
 
 void av1_write_coeffs_mb(const AV1_COMMON *const cm, MACROBLOCK *x,
                          aom_writer *w, int plane) {
   MACROBLOCKD *xd = &x->e_mbd;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   BLOCK_SIZE bsize = mbmi->sb_type;
   struct macroblockd_plane *pd = &xd->plane[plane];
 
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_SUB8X8
+  const BLOCK_SIZE plane_bsize =
+      AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
+#elif CONFIG_CB4X4
   const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
 #else
   const BLOCK_SIZE plane_bsize =
       get_plane_block_size(AOMMAX(bsize, BLOCK_8X8), pd);
 #endif
   const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
   const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
   TX_SIZE tx_size = get_tx_size(plane, xd);
@@ -198,40 +201,41 @@ void av1_write_coeffs_mb(const AV1_COMMO
   int row, col;
   int block = 0;
   for (row = 0; row < max_blocks_high; row += bkh) {
     for (col = 0; col < max_blocks_wide; col += bkw) {
       tran_low_t *tcoeff = BLOCK_OFFSET(x->mbmi_ext->tcoeff[plane], block);
       uint16_t eob = x->mbmi_ext->eobs[plane][block];
       TXB_CTX txb_ctx = { x->mbmi_ext->txb_skip_ctx[plane][block],
                           x->mbmi_ext->dc_sign_ctx[plane][block] };
-      av1_write_coeffs_txb(cm, xd, w, block, plane, tcoeff, eob, &txb_ctx);
+      av1_write_coeffs_txb(cm, xd, w, block, plane, tx_size, tcoeff, eob,
+                           &txb_ctx);
       block += step;
     }
   }
 }
 
 static INLINE void get_base_ctx_set(const tran_low_t *tcoeffs,
                                     int c,  // raster order
-                                    const int bwl,
+                                    const int bwl, const int height,
                                     int ctx_set[NUM_BASE_LEVELS]) {
   const int row = c >> bwl;
   const int col = c - (row << bwl);
   const int stride = 1 << bwl;
   int mag[NUM_BASE_LEVELS] = { 0 };
   int idx;
   tran_low_t abs_coeff;
   int i;
 
   for (idx = 0; idx < BASE_CONTEXT_POSITION_NUM; ++idx) {
     int ref_row = row + base_ref_offset[idx][0];
     int ref_col = col + base_ref_offset[idx][1];
     int pos = (ref_row << bwl) + ref_col;
 
-    if (ref_row < 0 || ref_col < 0 || ref_row >= stride || ref_col >= stride)
+    if (ref_row < 0 || ref_col < 0 || ref_row >= height || ref_col >= stride)
       continue;
 
     abs_coeff = abs(tcoeffs[pos]);
 
     for (i = 0; i < NUM_BASE_LEVELS; ++i) {
       ctx_set[i] += abs_coeff > i;
       if (base_ref_offset[idx][0] >= 0 && base_ref_offset[idx][1] >= 0)
         mag[i] |= abs_coeff > (i + 1);
@@ -275,104 +279,105 @@ static INLINE int get_base_cost(tran_low
   const int level = base_idx + 1;
   if (abs_qc < level)
     return 0;
   else
     return av1_cost_bit(coeff_base[base_idx][ctx], abs_qc == level);
 }
 
 int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
-                        int block, TXB_CTX *txb_ctx) {
+                        int block, TX_SIZE tx_size, TXB_CTX *txb_ctx) {
   const AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *const xd = &x->e_mbd;
-  const TX_SIZE tx_size = get_tx_size(plane, xd);
+  TX_SIZE txs_ctx = get_txsize_context(tx_size);
   const PLANE_TYPE plane_type = get_plane_type(plane);
   const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   const struct macroblock_plane *p = &x->plane[plane];
   const int eob = p->eobs[block];
   const tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
   int c, cost;
   const int seg_eob = AOMMIN(eob, tx_size_2d[tx_size] - 1);
   int txb_skip_ctx = txb_ctx->txb_skip_ctx;
-  aom_prob *nz_map = xd->fc->nz_map[tx_size][plane_type];
+  aom_prob *nz_map = xd->fc->nz_map[txs_ctx][plane_type];
 
   const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
+  const int height = tx_size_high[tx_size];
+
   // txb_mask is only initialized for once here. After that, it will be set when
   // coding zero map and then reset when coding level 1 info.
   uint8_t txb_mask[32 * 32] = { 0 };
   aom_prob(*coeff_base)[COEFF_BASE_CONTEXTS] =
-      xd->fc->coeff_base[tx_size][plane_type];
+      xd->fc->coeff_base[txs_ctx][plane_type];
 
-  const SCAN_ORDER *const scan_order =
-      get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
+  const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
   const int16_t *scan = scan_order->scan;
 
   cost = 0;
 
   if (eob == 0) {
-    cost = av1_cost_bit(xd->fc->txb_skip[tx_size][txb_skip_ctx], 1);
+    cost = av1_cost_bit(xd->fc->txb_skip[txs_ctx][txb_skip_ctx], 1);
     return cost;
   }
 
-  cost = av1_cost_bit(xd->fc->txb_skip[tx_size][txb_skip_ctx], 0);
+  cost = av1_cost_bit(xd->fc->txb_skip[txs_ctx][txb_skip_ctx], 0);
 
 #if CONFIG_TXK_SEL
   cost += av1_tx_type_cost(cpi, xd, mbmi->sb_type, plane, tx_size, tx_type);
 #endif
 
   for (c = 0; c < eob; ++c) {
     tran_low_t v = qcoeff[scan[c]];
     int is_nz = (v != 0);
     int level = abs(v);
 
     if (c < seg_eob) {
-      int coeff_ctx = get_nz_map_ctx(qcoeff, txb_mask, scan[c], bwl);
+      int coeff_ctx = get_nz_map_ctx(qcoeff, txb_mask, scan[c], bwl, height);
       cost += av1_cost_bit(nz_map[coeff_ctx], is_nz);
     }
 
     if (is_nz) {
       int ctx_ls[NUM_BASE_LEVELS] = { 0 };
       int sign = (v < 0) ? 1 : 0;
 
       // sign bit cost
       if (c == 0) {
         int dc_sign_ctx = txb_ctx->dc_sign_ctx;
 
         cost += av1_cost_bit(xd->fc->dc_sign[plane_type][dc_sign_ctx], sign);
       } else {
         cost += av1_cost_bit(128, sign);
       }
 
-      get_base_ctx_set(qcoeff, scan[c], bwl, ctx_ls);
+      get_base_ctx_set(qcoeff, scan[c], bwl, height, ctx_ls);
 
       int i;
       for (i = 0; i < NUM_BASE_LEVELS; ++i) {
         if (level <= i) continue;
 
         if (level == i + 1) {
           cost += av1_cost_bit(coeff_base[i][ctx_ls[i]], 1);
           continue;
         }
         cost += av1_cost_bit(coeff_base[i][ctx_ls[i]], 0);
       }
 
       if (level > NUM_BASE_LEVELS) {
         int idx;
         int ctx;
 
-        ctx = get_br_ctx(qcoeff, scan[c], bwl);
+        ctx = get_br_ctx(qcoeff, scan[c], bwl, height);
 
         for (idx = 0; idx < COEFF_BASE_RANGE; ++idx) {
           if (level == (idx + 1 + NUM_BASE_LEVELS)) {
             cost +=
-                av1_cost_bit(xd->fc->coeff_lps[tx_size][plane_type][ctx], 1);
+                av1_cost_bit(xd->fc->coeff_lps[txs_ctx][plane_type][ctx], 1);
             break;
           }
-          cost += av1_cost_bit(xd->fc->coeff_lps[tx_size][plane_type][ctx], 0);
+          cost += av1_cost_bit(xd->fc->coeff_lps[txs_ctx][plane_type][ctx], 0);
         }
 
         if (idx >= COEFF_BASE_RANGE) {
           // residual cost
           int r = level - COEFF_BASE_RANGE - NUM_BASE_LEVELS;
           int ri = r;
           int length = 0;
 
@@ -384,18 +389,18 @@ int av1_cost_coeffs_txb(const AV1_COMP *
           for (ri = 0; ri < length - 1; ++ri) cost += av1_cost_bit(128, 0);
 
           for (ri = length - 1; ri >= 0; --ri)
             cost += av1_cost_bit(128, (r >> ri) & 0x01);
         }
       }
 
       if (c < seg_eob) {
-        int eob_ctx = get_eob_ctx(qcoeff, scan[c], bwl);
-        cost += av1_cost_bit(xd->fc->eob_flag[tx_size][plane_type][eob_ctx],
+        int eob_ctx = get_eob_ctx(qcoeff, scan[c], txs_ctx);
+        cost += av1_cost_bit(xd->fc->eob_flag[txs_ctx][plane_type][eob_ctx],
                              c == (eob - 1));
       }
     }
 
     txb_mask[scan[c]] = 1;
   }
 
   return cost;
@@ -404,44 +409,45 @@ int av1_cost_coeffs_txb(const AV1_COMP *
 static INLINE int has_base(tran_low_t qc, int base_idx) {
   const int level = base_idx + 1;
   return abs(qc) >= level;
 }
 
 static void gen_base_count_mag_arr(int (*base_count_arr)[MAX_TX_SQUARE],
                                    int (*base_mag_arr)[2],
                                    const tran_low_t *qcoeff, int stride,
-                                   int eob, const int16_t *scan) {
+                                   int height, int eob, const int16_t *scan) {
   for (int c = 0; c < eob; ++c) {
     const int coeff_idx = scan[c];  // raster order
     if (!has_base(qcoeff[coeff_idx], 0)) continue;
     const int row = coeff_idx / stride;
     const int col = coeff_idx % stride;
     int *mag = base_mag_arr[coeff_idx];
-    get_mag(mag, qcoeff, stride, row, col, base_ref_offset,
+    get_mag(mag, qcoeff, stride, height, row, col, base_ref_offset,
             BASE_CONTEXT_POSITION_NUM);
     for (int i = 0; i < NUM_BASE_LEVELS; ++i) {
       if (!has_base(qcoeff[coeff_idx], i)) continue;
       int *count = base_count_arr[i] + coeff_idx;
-      *count = get_level_count(qcoeff, stride, row, col, i, base_ref_offset,
-                               BASE_CONTEXT_POSITION_NUM);
+      *count = get_level_count(qcoeff, stride, height, row, col, i,
+                               base_ref_offset, BASE_CONTEXT_POSITION_NUM);
     }
   }
 }
 
 static void gen_nz_count_arr(int(*nz_count_arr), const tran_low_t *qcoeff,
-                             int stride, int eob,
+                             int stride, int height, int eob,
                              const SCAN_ORDER *scan_order) {
   const int16_t *scan = scan_order->scan;
   const int16_t *iscan = scan_order->iscan;
   for (int c = 0; c < eob; ++c) {
     const int coeff_idx = scan[c];  // raster order
     const int row = coeff_idx / stride;
     const int col = coeff_idx % stride;
-    nz_count_arr[coeff_idx] = get_nz_count(qcoeff, stride, row, col, iscan);
+    nz_count_arr[coeff_idx] =
+        get_nz_count(qcoeff, stride, height, row, col, iscan);
   }
 }
 
 static void gen_nz_ctx_arr(int (*nz_ctx_arr)[2], int(*nz_count_arr),
                            const tran_low_t *qcoeff, int bwl, int eob,
                            const SCAN_ORDER *scan_order) {
   const int16_t *scan = scan_order->scan;
   const int16_t *iscan = scan_order->iscan;
@@ -473,28 +479,28 @@ static void gen_base_ctx_arr(int (*base_
   }
 }
 
 static INLINE int has_br(tran_low_t qc) {
   return abs(qc) >= 1 + NUM_BASE_LEVELS;
 }
 
 static void gen_br_count_mag_arr(int *br_count_arr, int (*br_mag_arr)[2],
-                                 const tran_low_t *qcoeff, int stride, int eob,
-                                 const int16_t *scan) {
+                                 const tran_low_t *qcoeff, int stride,
+                                 int height, int eob, const int16_t *scan) {
   for (int c = 0; c < eob; ++c) {
     const int coeff_idx = scan[c];  // raster order
     if (!has_br(qcoeff[coeff_idx])) continue;
     const int row = coeff_idx / stride;
     const int col = coeff_idx % stride;
     int *count = br_count_arr + coeff_idx;
     int *mag = br_mag_arr[coeff_idx];
-    *count = get_level_count(qcoeff, stride, row, col, NUM_BASE_LEVELS,
+    *count = get_level_count(qcoeff, stride, height, row, col, NUM_BASE_LEVELS,
                              br_ref_offset, BR_CONTEXT_POSITION_NUM);
-    get_mag(mag, qcoeff, stride, row, col, br_ref_offset,
+    get_mag(mag, qcoeff, stride, height, row, col, br_ref_offset,
             BR_CONTEXT_POSITION_NUM);
   }
 }
 
 static void gen_br_ctx_arr(int (*br_ctx_arr)[2], const int *br_count_arr,
                            int (*br_mag_arr)[2], const tran_low_t *qcoeff,
                            int stride, int eob, const int16_t *scan) {
   (void)qcoeff;
@@ -538,28 +544,29 @@ static INLINE int get_golomb_cost(int ab
     return 0;
   }
 }
 
 // TODO(angiebird): add static once this function is called
 void gen_txb_cache(TxbCache *txb_cache, TxbInfo *txb_info) {
   const int16_t *scan = txb_info->scan_order->scan;
   gen_nz_count_arr(txb_cache->nz_count_arr, txb_info->qcoeff, txb_info->stride,
-                   txb_info->eob, txb_info->scan_order);
+                   txb_info->height, txb_info->eob, txb_info->scan_order);
   gen_nz_ctx_arr(txb_cache->nz_ctx_arr, txb_cache->nz_count_arr,
                  txb_info->qcoeff, txb_info->bwl, txb_info->eob,
                  txb_info->scan_order);
   gen_base_count_mag_arr(txb_cache->base_count_arr, txb_cache->base_mag_arr,
-                         txb_info->qcoeff, txb_info->stride, txb_info->eob,
-                         scan);
+                         txb_info->qcoeff, txb_info->stride, txb_info->height,
+                         txb_info->eob, scan);
   gen_base_ctx_arr(txb_cache->base_ctx_arr, txb_cache->base_count_arr,
                    txb_cache->base_mag_arr, txb_info->qcoeff, txb_info->stride,
                    txb_info->eob, scan);
   gen_br_count_mag_arr(txb_cache->br_count_arr, txb_cache->br_mag_arr,
-                       txb_info->qcoeff, txb_info->stride, txb_info->eob, scan);
+                       txb_info->qcoeff, txb_info->stride, txb_info->height,
+                       txb_info->eob, scan);
   gen_br_ctx_arr(txb_cache->br_ctx_arr, txb_cache->br_count_arr,
                  txb_cache->br_mag_arr, txb_info->qcoeff, txb_info->stride,
                  txb_info->eob, scan);
 }
 
 static INLINE aom_prob get_level_prob(int level, int coeff_idx,
                                       const TxbCache *txb_cache,
                                       const TxbProbs *txb_probs) {
@@ -776,17 +783,17 @@ static int try_self_level_down(tran_low_
                   av1_cost_bit(low_level_prob, 0) -
                   av1_cost_bit(low_level_prob, 1);
     } else {
       cost_diff = -av1_cost_bit(level_prob, 1);
     }
 
     if (scan_idx < txb_info->seg_eob) {
       const int eob_ctx =
-          get_eob_ctx(txb_info->qcoeff, coeff_idx, txb_info->bwl);
+          get_eob_ctx(txb_info->qcoeff, coeff_idx, txb_info->txs_ctx);
       cost_diff -= av1_cost_bit(txb_probs->eob_flag[eob_ctx],
                                 scan_idx == (txb_info->eob - 1));
     }
 
     const int sign_cost = get_sign_bit_cost(
         qc, coeff_idx, txb_probs->dc_sign_prob, txb_info->txb_ctx->dc_sign_ctx);
     cost_diff -= sign_cost;
   } else if (abs_qc < 1 + NUM_BASE_LEVELS + COEFF_BASE_RANGE) {
@@ -848,55 +855,67 @@ int try_level_down(int coeff_idx, const 
 
   const int row = coeff_idx >> txb_info->bwl;
   const int col = coeff_idx - (row << txb_info->bwl);
   if (check_nz_neighbor(qc)) {
     for (int i = 0; i < SIG_REF_OFFSET_NUM; ++i) {
       const int nb_row = row - sig_ref_offset[i][0];
       const int nb_col = col - sig_ref_offset[i][1];
       const int nb_coeff_idx = nb_row * txb_info->stride + nb_col;
+
+      if (!(nb_row >= 0 && nb_col >= 0 && nb_row < txb_info->height &&
+            nb_col < txb_info->stride))
+        continue;
+
       const int nb_scan_idx = iscan[nb_coeff_idx];
-      if (nb_scan_idx < eob && nb_row >= 0 && nb_col >= 0 &&
-          nb_row < txb_info->stride && nb_col < txb_info->stride) {
+      if (nb_scan_idx < eob) {
         const int cost_diff = try_neighbor_level_down_nz(
             nb_coeff_idx, coeff_idx, txb_cache, txb_probs, txb_info);
         if (cost_map)
           cost_map[nb_row - row + COST_MAP_OFFSET]
                   [nb_col - col + COST_MAP_OFFSET] += cost_diff;
         accu_cost_diff += cost_diff;
       }
     }
   }
 
   if (check_base_neighbor(qc)) {
     for (int i = 0; i < BASE_CONTEXT_POSITION_NUM; ++i) {
       const int nb_row = row - base_ref_offset[i][0];
       const int nb_col = col - base_ref_offset[i][1];
       const int nb_coeff_idx = nb_row * txb_info->stride + nb_col;
+
+      if (!(nb_row >= 0 && nb_col >= 0 && nb_row < txb_info->height &&
+            nb_col < txb_info->stride))
+        continue;
+
       const int nb_scan_idx = iscan[nb_coeff_idx];
-      if (nb_scan_idx < eob && nb_row >= 0 && nb_col >= 0 &&
-          nb_row < txb_info->stride && nb_col < txb_info->stride) {
+      if (nb_scan_idx < eob) {
         const int cost_diff = try_neighbor_level_down_base(
             nb_coeff_idx, coeff_idx, txb_cache, txb_probs, txb_info);
         if (cost_map)
           cost_map[nb_row - row + COST_MAP_OFFSET]
                   [nb_col - col + COST_MAP_OFFSET] += cost_diff;
         accu_cost_diff += cost_diff;
       }
     }
   }
 
   if (check_br_neighbor(qc)) {
     for (int i = 0; i < BR_CONTEXT_POSITION_NUM; ++i) {
       const int nb_row = row - br_ref_offset[i][0];
       const int nb_col = col - br_ref_offset[i][1];
       const int nb_coeff_idx = nb_row * txb_info->stride + nb_col;
+
+      if (!(nb_row >= 0 && nb_col >= 0 && nb_row < txb_info->height &&
+            nb_col < txb_info->stride))
+        continue;
+
       const int nb_scan_idx = iscan[nb_coeff_idx];
-      if (nb_scan_idx < eob && nb_row >= 0 && nb_col >= 0 &&
-          nb_row < txb_info->stride && nb_col < txb_info->stride) {
+      if (nb_scan_idx < eob) {
         const int cost_diff = try_neighbor_level_down_br(
             nb_coeff_idx, coeff_idx, txb_cache, txb_probs, txb_info);
         if (cost_map)
           cost_map[nb_row - row + COST_MAP_OFFSET]
                   [nb_col - col + COST_MAP_OFFSET] += cost_diff;
         accu_cost_diff += cost_diff;
       }
     }
@@ -920,17 +939,17 @@ static int get_low_coeff_cost(int coeff_
   }
 
   if (qc != 0) {
     const int base_idx = 0;
     const int ctx = txb_cache->base_ctx_arr[base_idx][coeff_idx][0];
     cost += get_base_cost(abs_qc, ctx, txb_probs->coeff_base, base_idx);
     if (scan_idx < txb_info->seg_eob) {
       const int eob_ctx =
-          get_eob_ctx(txb_info->qcoeff, coeff_idx, txb_info->bwl);
+          get_eob_ctx(txb_info->qcoeff, coeff_idx, txb_info->txs_ctx);
       cost += av1_cost_bit(txb_probs->eob_flag[eob_ctx],
                            scan_idx == (txb_info->eob - 1));
     }
     cost += get_sign_bit_cost(qc, coeff_idx, txb_probs->dc_sign_prob,
                               txb_info->txb_ctx->dc_sign_ctx);
   }
   return cost;
 }
@@ -977,17 +996,17 @@ int try_change_eob(int *new_eob, int coe
   set_eob(txb_info, *new_eob);
   cost_diff += try_level_down(coeff_idx, txb_cache, txb_probs, txb_info, NULL);
   set_eob(txb_info, org_eob);
 
   if (*new_eob > 0) {
     // Note that get_eob_ctx does NOT actually account for qcoeff, so we don't
     // need to lower down the qcoeff here
     const int eob_ctx =
-        get_eob_ctx(txb_info->qcoeff, scan[*new_eob - 1], txb_info->bwl);
+        get_eob_ctx(txb_info->qcoeff, scan[*new_eob - 1], txb_info->txs_ctx);
     cost_diff -= av1_cost_bit(txb_probs->eob_flag[eob_ctx], 0);
     cost_diff += av1_cost_bit(txb_probs->eob_flag[eob_ctx], 1);
   } else {
     const int txb_skip_ctx = txb_info->txb_ctx->txb_skip_ctx;
     cost_diff -= av1_cost_bit(txb_probs->txb_skip[txb_skip_ctx], 0);
     cost_diff += av1_cost_bit(txb_probs->txb_skip[txb_skip_ctx], 1);
   }
   return cost_diff;
@@ -1011,20 +1030,24 @@ void update_level_down(int coeff_idx, Tx
 
   const int row = coeff_idx >> txb_info->bwl;
   const int col = coeff_idx - (row << txb_info->bwl);
   const int eob = txb_info->eob;
   const int16_t *iscan = txb_info->scan_order->iscan;
   for (int i = 0; i < SIG_REF_OFFSET_NUM; ++i) {
     const int nb_row = row - sig_ref_offset[i][0];
     const int nb_col = col - sig_ref_offset[i][1];
+
+    if (!(nb_row >= 0 && nb_col >= 0 && nb_row < txb_info->height &&
+          nb_col < txb_info->stride))
+      continue;
+
     const int nb_coeff_idx = nb_row * txb_info->stride + nb_col;
     const int nb_scan_idx = iscan[nb_coeff_idx];
-    if (nb_scan_idx < eob && nb_row >= 0 && nb_col >= 0 &&
-        nb_row < txb_info->stride && nb_col < txb_info->stride) {
+    if (nb_scan_idx < eob) {
       const int scan_idx = iscan[coeff_idx];
       if (scan_idx < nb_scan_idx) {
         const int level = 1;
         if (abs_qc == level) {
           txb_cache->nz_count_arr[nb_coeff_idx] -= 1;
           assert(txb_cache->nz_count_arr[nb_coeff_idx] >= 0);
         }
         const int count = txb_cache->nz_count_arr[nb_coeff_idx];
@@ -1038,21 +1061,25 @@ void update_level_down(int coeff_idx, Tx
       }
     }
   }
 
   for (int i = 0; i < BASE_CONTEXT_POSITION_NUM; ++i) {
     const int nb_row = row - base_ref_offset[i][0];
     const int nb_col = col - base_ref_offset[i][1];
     const int nb_coeff_idx = nb_row * txb_info->stride + nb_col;
+
+    if (!(nb_row >= 0 && nb_col >= 0 && nb_row < txb_info->height &&
+          nb_col < txb_info->stride))
+      continue;
+
     const tran_low_t nb_coeff = txb_info->qcoeff[nb_coeff_idx];
     if (!has_base(nb_coeff, 0)) continue;
     const int nb_scan_idx = iscan[nb_coeff_idx];
-    if (nb_scan_idx < eob && nb_row >= 0 && nb_col >= 0 &&
-        nb_row < txb_info->stride && nb_col < txb_info->stride) {
+    if (nb_scan_idx < eob) {
       if (row >= nb_row && col >= nb_col)
         update_mag_arr(txb_cache->base_mag_arr[nb_coeff_idx], abs_qc);
       const int mag =
           get_mag_from_mag_arr(txb_cache->base_mag_arr[nb_coeff_idx]);
       for (int base_idx = 0; base_idx < NUM_BASE_LEVELS; ++base_idx) {
         if (!has_base(nb_coeff, base_idx)) continue;
         const int level = base_idx + 1;
         if (abs_qc == level) {
@@ -1071,21 +1098,25 @@ void update_level_down(int coeff_idx, Tx
       }
     }
   }
 
   for (int i = 0; i < BR_CONTEXT_POSITION_NUM; ++i) {
     const int nb_row = row - br_ref_offset[i][0];
     const int nb_col = col - br_ref_offset[i][1];
     const int nb_coeff_idx = nb_row * txb_info->stride + nb_col;
+
+    if (!(nb_row >= 0 && nb_col >= 0 && nb_row < txb_info->height &&
+          nb_col < txb_info->stride))
+      continue;
+
     const int nb_scan_idx = iscan[nb_coeff_idx];
     const tran_low_t nb_coeff = txb_info->qcoeff[nb_coeff_idx];
     if (!has_br(nb_coeff)) continue;
-    if (nb_scan_idx < eob && nb_row >= 0 && nb_col >= 0 &&
-        nb_row < txb_info->stride && nb_col < txb_info->stride) {
+    if (nb_scan_idx < eob) {
       const int level = 1 + NUM_BASE_LEVELS;
       if (abs_qc == level) {
         txb_cache->br_count_arr[nb_coeff_idx] -= 1;
         assert(txb_cache->br_count_arr[nb_coeff_idx] >= 0);
       }
       if (row >= nb_row && col >= nb_col)
         update_mag_arr(txb_cache->br_mag_arr[nb_coeff_idx], abs_qc);
       const int count = txb_cache->br_count_arr[nb_coeff_idx];
@@ -1107,42 +1138,44 @@ static int get_coeff_cost(tran_low_t qc,
   const TXB_CTX *txb_ctx = txb_info->txb_ctx;
   const int is_nz = (qc != 0);
   const tran_low_t abs_qc = abs(qc);
   int cost = 0;
   const int16_t *scan = txb_info->scan_order->scan;
   const int16_t *iscan = txb_info->scan_order->iscan;
 
   if (scan_idx < txb_info->seg_eob) {
-    int coeff_ctx =
-        get_nz_map_ctx2(txb_info->qcoeff, scan[scan_idx], txb_info->bwl, iscan);
+    int coeff_ctx = get_nz_map_ctx2(txb_info->qcoeff, scan[scan_idx],
+                                    txb_info->bwl, txb_info->height, iscan);
     cost += av1_cost_bit(txb_probs->nz_map[coeff_ctx], is_nz);
   }
 
   if (is_nz) {
     cost += get_sign_bit_cost(qc, scan_idx, txb_probs->dc_sign_prob,
                               txb_ctx->dc_sign_ctx);
 
     int ctx_ls[NUM_BASE_LEVELS] = { 0 };
-    get_base_ctx_set(txb_info->qcoeff, scan[scan_idx], txb_info->bwl, ctx_ls);
+    get_base_ctx_set(txb_info->qcoeff, scan[scan_idx], txb_info->bwl,
+                     txb_info->height, ctx_ls);
 
     int i;
     for (i = 0; i < NUM_BASE_LEVELS; ++i) {
       cost += get_base_cost(abs_qc, ctx_ls[i], txb_probs->coeff_base, i);
     }
 
     if (abs_qc > NUM_BASE_LEVELS) {
-      int ctx = get_br_ctx(txb_info->qcoeff, scan[scan_idx], txb_info->bwl);
+      int ctx = get_br_ctx(txb_info->qcoeff, scan[scan_idx], txb_info->bwl,
+                           txb_info->height);
       cost += get_br_cost(abs_qc, ctx, txb_probs->coeff_lps);
       cost += get_golomb_cost(abs_qc);
     }
 
     if (scan_idx < txb_info->seg_eob) {
       int eob_ctx =
-          get_eob_ctx(txb_info->qcoeff, scan[scan_idx], txb_info->bwl);
+          get_eob_ctx(txb_info->qcoeff, scan[scan_idx], txb_info->txs_ctx);
       cost += av1_cost_bit(txb_probs->eob_flag[eob_ctx],
                            scan_idx == (txb_info->eob - 1));
     }
   }
   return cost;
 }
 
 #if TEST_OPTIMIZE_TXB
@@ -1318,18 +1351,17 @@ void try_level_down_facade(LevelDownStat
                                       txb_probs, txb_info);
   } else {
     stats->cost_diff =
         try_level_down(coeff_idx, txb_cache, txb_probs, txb_info, NULL);
 #if TEST_OPTIMIZE_TXB
     test_level_down(coeff_idx, txb_cache, txb_probs, txb_info);
 #endif
   }
-  stats->rd_diff = RDCOST(txb_info->rdmult, txb_info->rddiv, stats->cost_diff,
-                          stats->dist_diff);
+  stats->rd_diff = RDCOST(txb_info->rdmult, stats->cost_diff, stats->dist_diff);
   if (stats->rd_diff < 0) stats->update = 1;
   return;
 }
 
 static int optimize_txb(TxbInfo *txb_info, const TxbProbs *txb_probs,
                         TxbCache *txb_cache, int dry_run) {
   int update = 0;
   if (txb_info->eob == 0) return update;
@@ -1430,54 +1462,55 @@ static const int plane_rd_mult[REF_TYPES
   { 20, 12 }, { 16, 12 },
 #endif
 };
 
 int av1_optimize_txb(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
                      TX_SIZE tx_size, TXB_CTX *txb_ctx) {
   MACROBLOCKD *const xd = &x->e_mbd;
   const PLANE_TYPE plane_type = get_plane_type(plane);
+  const TX_SIZE txs_ctx = get_txsize_context(tx_size);
   const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
   const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   const struct macroblock_plane *p = &x->plane[plane];
   struct macroblockd_plane *pd = &xd->plane[plane];
   const int eob = p->eobs[block];
   tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
   tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
   const tran_low_t *tcoeff = BLOCK_OFFSET(p->coeff, block);
   const int16_t *dequant = pd->dequant;
   const int seg_eob = AOMMIN(eob, tx_size_2d[tx_size] - 1);
-  const aom_prob *nz_map = xd->fc->nz_map[tx_size][plane_type];
+  const aom_prob *nz_map = xd->fc->nz_map[txs_ctx][plane_type];
 
   const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
   const int stride = 1 << bwl;
+  const int height = tx_size_high[tx_size];
   aom_prob(*coeff_base)[COEFF_BASE_CONTEXTS] =
-      xd->fc->coeff_base[tx_size][plane_type];
+      xd->fc->coeff_base[txs_ctx][plane_type];
 
-  const aom_prob *coeff_lps = xd->fc->coeff_lps[tx_size][plane_type];
+  const aom_prob *coeff_lps = xd->fc->coeff_lps[txs_ctx][plane_type];
 
   const int is_inter = is_inter_block(mbmi);
-  const SCAN_ORDER *const scan_order =
-      get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
+  const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
 
   const TxbProbs txb_probs = { xd->fc->dc_sign[plane_type],
                                nz_map,
                                coeff_base,
                                coeff_lps,
-                               xd->fc->eob_flag[tx_size][plane_type],
-                               xd->fc->txb_skip[tx_size] };
+                               xd->fc->eob_flag[txs_ctx][plane_type],
+                               xd->fc->txb_skip[txs_ctx] };
 
   const int shift = av1_get_tx_scale(tx_size);
   const int64_t rdmult =
       (x->rdmult * plane_rd_mult[is_inter][plane_type] + 2) >> 2;
-  const int64_t rddiv = x->rddiv;
 
-  TxbInfo txb_info = { qcoeff,     dqcoeff, tcoeff, dequant, shift,
-                       tx_size,    bwl,     stride, eob,     seg_eob,
-                       scan_order, txb_ctx, rdmult, rddiv };
+  TxbInfo txb_info = { qcoeff,  dqcoeff, tcoeff,     dequant, shift,
+                       tx_size, txs_ctx, bwl,        stride,  height,
+                       eob,     seg_eob, scan_order, txb_ctx, rdmult };
+
   TxbCache txb_cache;
   gen_txb_cache(&txb_cache, &txb_info);
 
   const int update = optimize_txb(&txb_info, &txb_probs, &txb_cache, 0);
   if (update) p->eobs[block] = txb_info.eob;
   return txb_info.eob;
 }
 int av1_get_txb_entropy_context(const tran_low_t *qcoeff,
@@ -1506,18 +1539,17 @@ void av1_update_txb_context_b(int plane,
   MACROBLOCKD *const xd = &x->e_mbd;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   struct macroblock_plane *p = &x->plane[plane];
   struct macroblockd_plane *pd = &xd->plane[plane];
   const uint16_t eob = p->eobs[block];
   const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
   const PLANE_TYPE plane_type = pd->plane_type;
   const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
-  const SCAN_ORDER *const scan_order =
-      get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
+  const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
   (void)plane_bsize;
 
   int cul_level = av1_get_txb_entropy_context(qcoeff, scan_order, eob);
   av1_set_contexts(xd, pd, plane, tx_size, cul_level, blk_col, blk_row);
 }
 
 void av1_update_and_record_txb_context(int plane, int block, int blk_row,
                                        int blk_col, BLOCK_SIZE plane_bsize,
@@ -1532,88 +1564,90 @@ void av1_update_and_record_txb_context(i
   struct macroblockd_plane *pd = &xd->plane[plane];
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   int eob = p->eobs[block], update_eob = 0;
   const PLANE_TYPE plane_type = pd->plane_type;
   const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
   tran_low_t *tcoeff = BLOCK_OFFSET(x->mbmi_ext->tcoeff[plane], block);
   const int segment_id = mbmi->segment_id;
   const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
-  const SCAN_ORDER *const scan_order =
-      get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
+  const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
   const int16_t *scan = scan_order->scan;
   const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size);
   int c, i;
   TXB_CTX txb_ctx;
   get_txb_ctx(plane_bsize, tx_size, plane, pd->above_context + blk_col,
               pd->left_context + blk_row, &txb_ctx);
   const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
+  const int height = tx_size_high[tx_size];
   int cul_level = 0;
   unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2];
   uint8_t txb_mask[32 * 32] = { 0 };
 
-  nz_map_count = &td->counts->nz_map[tx_size][plane_type];
+  TX_SIZE txsize_ctx = get_txsize_context(tx_size);
+
+  nz_map_count = &td->counts->nz_map[txsize_ctx][plane_type];
 
   memcpy(tcoeff, qcoeff, sizeof(*tcoeff) * seg_eob);
 
-  ++td->counts->txb_skip[tx_size][txb_ctx.txb_skip_ctx][eob == 0];
+  ++td->counts->txb_skip[txsize_ctx][txb_ctx.txb_skip_ctx][eob == 0];
   x->mbmi_ext->txb_skip_ctx[plane][block] = txb_ctx.txb_skip_ctx;
 
   x->mbmi_ext->eobs[plane][block] = eob;
 
   if (eob == 0) {
     av1_set_contexts(xd, pd, plane, tx_size, 0, blk_col, blk_row);
     return;
   }
 
 #if CONFIG_TXK_SEL
-  av1_update_tx_type_count(cm, xd, block, plane, mbmi->sb_type, tx_size,
-                           td->counts);
+  av1_update_tx_type_count(cm, xd, block, plane, mbmi->sb_type,
+                           get_min_tx_size(tx_size), td->counts);
 #endif
 
   for (c = 0; c < eob; ++c) {
     tran_low_t v = qcoeff[scan[c]];
     int is_nz = (v != 0);
-    int coeff_ctx = get_nz_map_ctx(tcoeff, txb_mask, scan[c], bwl);
-    int eob_ctx = get_eob_ctx(tcoeff, scan[c], bwl);
+    int coeff_ctx = get_nz_map_ctx(tcoeff, txb_mask, scan[c], bwl, height);
+    int eob_ctx = get_eob_ctx(tcoeff, scan[c], txsize_ctx);
 
     if (c == seg_eob - 1) break;
 
     ++(*nz_map_count)[coeff_ctx][is_nz];
 
     if (is_nz) {
-      ++td->counts->eob_flag[tx_size][plane_type][eob_ctx][c == (eob - 1)];
+      ++td->counts->eob_flag[txsize_ctx][plane_type][eob_ctx][c == (eob - 1)];
     }
     txb_mask[scan[c]] = 1;
   }
 
   // Reverse process order to handle coefficient level and sign.
   for (i = 0; i < NUM_BASE_LEVELS; ++i) {
     update_eob = 0;
     for (c = eob - 1; c >= 0; --c) {
       tran_low_t v = qcoeff[scan[c]];
       tran_low_t level = abs(v);
       int ctx;
 
       if (level <= i) continue;
 
-      ctx = get_base_ctx(tcoeff, scan[c], bwl, i + 1);
+      ctx = get_base_ctx(tcoeff, scan[c], bwl, height, i + 1);
 
       if (level == i + 1) {
-        ++td->counts->coeff_base[tx_size][plane_type][i][ctx][1];
+        ++td->counts->coeff_base[txsize_ctx][plane_type][i][ctx][1];
         if (c == 0) {
           int dc_sign_ctx = txb_ctx.dc_sign_ctx;
 
           ++td->counts->dc_sign[plane_type][dc_sign_ctx][v < 0];
           x->mbmi_ext->dc_sign_ctx[plane][block] = dc_sign_ctx;
         }
         cul_level += level;
         continue;
       }
-      ++td->counts->coeff_base[tx_size][plane_type][i][ctx][0];
+      ++td->counts->coeff_base[txsize_ctx][plane_type][i][ctx][0];
       update_eob = AOMMAX(update_eob, c);
     }
   }
 
   for (c = update_eob; c >= 0; --c) {
     tran_low_t v = qcoeff[scan[c]];
     tran_low_t level = abs(v);
     int idx;
@@ -1625,23 +1659,23 @@ void av1_update_and_record_txb_context(i
     if (c == 0) {
       int dc_sign_ctx = txb_ctx.dc_sign_ctx;
 
       ++td->counts->dc_sign[plane_type][dc_sign_ctx][v < 0];
       x->mbmi_ext->dc_sign_ctx[plane][block] = dc_sign_ctx;
     }
 
     // level is above 1.
-    ctx = get_br_ctx(tcoeff, scan[c], bwl);
+    ctx = get_br_ctx(tcoeff, scan[c], bwl, height);
     for (idx = 0; idx < COEFF_BASE_RANGE; ++idx) {
       if (level == (idx + 1 + NUM_BASE_LEVELS)) {
-        ++td->counts->coeff_lps[tx_size][plane_type][ctx][1];
+        ++td->counts->coeff_lps[txsize_ctx][plane_type][ctx][1];
         break;
       }
-      ++td->counts->coeff_lps[tx_size][plane_type][ctx][0];
+      ++td->counts->coeff_lps[txsize_ctx][plane_type][ctx][0];
     }
     if (idx < COEFF_BASE_RANGE) continue;
 
     // use 0-th order Golomb code to handle the residual level.
   }
 
   cul_level = AOMMIN(COEFF_CONTEXT_MASK, cul_level);
 
@@ -1830,54 +1864,72 @@ int64_t av1_search_txk_type(const AV1_CO
                             int use_fast_coef_costing, RD_STATS *rd_stats) {
   const AV1_COMMON *cm = &cpi->common;
   MACROBLOCKD *xd = &x->e_mbd;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   TX_TYPE txk_start = DCT_DCT;
   TX_TYPE txk_end = TX_TYPES - 1;
   TX_TYPE best_tx_type = txk_start;
   int64_t best_rd = INT64_MAX;
+  uint8_t best_eob = 0;
   const int coeff_ctx = combine_entropy_contexts(*a, *l);
+  RD_STATS best_rd_stats;
   TX_TYPE tx_type;
+
+  av1_invalid_rd_stats(&best_rd_stats);
+
   for (tx_type = txk_start; tx_type <= txk_end; ++tx_type) {
     if (plane == 0) mbmi->txk_type[block] = tx_type;
     TX_TYPE ref_tx_type =
         get_tx_type(get_plane_type(plane), xd, block, tx_size);
     if (tx_type != ref_tx_type) {
       // use get_tx_type() to check if the tx_type is valid for the current mode
       // if it's not, we skip it here.
       continue;
     }
+
+#if CONFIG_EXT_TX
+    int is_inter = is_inter_block(mbmi);
+    int ext_tx_set = get_ext_tx_set(get_min_tx_size(tx_size), mbmi->sb_type,
+                                    is_inter, cm->reduced_tx_set_used);
+    if (!(is_inter && ext_tx_used_inter[ext_tx_set][tx_type]) &&
+        !(!is_inter && ext_tx_used_intra[ext_tx_set][tx_type]))
+      continue;
+#endif  // CONFIG_EXT_TX
+
     RD_STATS this_rd_stats;
     av1_invalid_rd_stats(&this_rd_stats);
     av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
                     coeff_ctx, AV1_XFORM_QUANT_FP);
     av1_optimize_b(cm, x, plane, block, plane_bsize, tx_size, a, l);
     av1_dist_block(cpi, x, plane, plane_bsize, block, blk_row, blk_col, tx_size,
                    &this_rd_stats.dist, &this_rd_stats.sse,
                    OUTPUT_HAS_PREDICTED_PIXELS);
-    const SCAN_ORDER *scan_order =
-        get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
+    const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi);
     this_rd_stats.rate = av1_cost_coeffs(
         cpi, x, plane, block, tx_size, scan_order, a, l, use_fast_coef_costing);
-    int rd =
-        RDCOST(x->rdmult, x->rddiv, this_rd_stats.rate, this_rd_stats.dist);
+    int rd = RDCOST(x->rdmult, this_rd_stats.rate, this_rd_stats.dist);
     if (rd < best_rd) {
       best_rd = rd;
-      *rd_stats = this_rd_stats;
+      best_rd_stats = this_rd_stats;
       best_tx_type = tx_type;
+      best_eob = x->plane[plane].txb_entropy_ctx[block];
     }
   }
+
+  av1_merge_rd_stats(rd_stats, &best_rd_stats);
+
   if (plane == 0) mbmi->txk_type[block] = best_tx_type;
-  // TODO(angiebird): Instead of re-call av1_xform_quant and av1_optimize_b,
-  // copy the best result in the above tx_type search for loop
-  av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
-                  coeff_ctx, AV1_XFORM_QUANT_FP);
-  av1_optimize_b(cm, x, plane, block, plane_bsize, tx_size, a, l);
+  x->plane[plane].txb_entropy_ctx[block] = best_eob;
+
   if (!is_inter_block(mbmi)) {
     // intra mode needs decoded result such that the next transform block
     // can use it for prediction.
+    av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
+                    coeff_ctx, AV1_XFORM_QUANT_FP);
+    av1_optimize_b(cm, x, plane, block, plane_bsize, tx_size, a, l);
+
     av1_inverse_transform_block_facade(xd, plane, block, blk_row, blk_col,
                                        x->plane[plane].eobs[block]);
   }
   return best_rd;
 }
 #endif  // CONFIG_TXK_SEL
--- a/third_party/aom/av1/encoder/encodetxb.h
+++ b/third_party/aom/av1/encoder/encodetxb.h
@@ -25,24 +25,25 @@ extern "C" {
 
 typedef struct TxbInfo {
   tran_low_t *qcoeff;
   tran_low_t *dqcoeff;
   const tran_low_t *tcoeff;
   const int16_t *dequant;
   int shift;
   TX_SIZE tx_size;
+  TX_SIZE txs_ctx;
   int bwl;
   int stride;
+  int height;
   int eob;
   int seg_eob;
   const SCAN_ORDER *scan_order;
   TXB_CTX *txb_ctx;
   int64_t rdmult;
-  int64_t rddiv;
 } TxbInfo;
 
 typedef struct TxbCache {
   int nz_count_arr[MAX_TX_SQUARE];
   int nz_ctx_arr[MAX_TX_SQUARE][2];
   int base_count_arr[NUM_BASE_LEVELS][MAX_TX_SQUARE];
   int base_mag_arr[MAX_TX_SQUARE]
                   [2];  // [0]: max magnitude [1]: num of max magnitude
@@ -61,19 +62,19 @@ typedef struct TxbProbs {
   const aom_prob *coeff_lps;
   const aom_prob *eob_flag;
   const aom_prob *txb_skip;
 } TxbProbs;
 
 void av1_alloc_txb_buf(AV1_COMP *cpi);
 void av1_free_txb_buf(AV1_COMP *cpi);
 int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
-                        int block, TXB_CTX *txb_ctx);
+                        int block, TX_SIZE tx_size, TXB_CTX *txb_ctx);
 void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
-                          aom_writer *w, int block, int plane,
+                          aom_writer *w, int block, int plane, TX_SIZE tx_size,
                           const tran_low_t *tcoeff, uint16_t eob,
                           TXB_CTX *txb_ctx);
 void av1_write_coeffs_mb(const AV1_COMMON *const cm, MACROBLOCK *x,
                          aom_writer *w, int plane);
 int av1_get_txb_entropy_context(const tran_low_t *qcoeff,
                                 const SCAN_ORDER *scan_order, int eob);
 void av1_update_txb_context(const AV1_COMP *cpi, ThreadData *td,
                             RUN_TYPE dry_run, BLOCK_SIZE bsize, int *rate,
--- a/third_party/aom/av1/encoder/ethread.c
+++ b/third_party/aom/av1/encoder/ethread.c
@@ -21,16 +21,20 @@ static void accumulate_rd_opt(ThreadData
     td->rd_counts.comp_pred_diff[i] += td_t->rd_counts.comp_pred_diff[i];
 
 #if CONFIG_GLOBAL_MOTION
   for (i = 0; i < TOTAL_REFS_PER_FRAME; i++)
     td->rd_counts.global_motion_used[i] +=
         td_t->rd_counts.global_motion_used[i];
 #endif  // CONFIG_GLOBAL_MOTION
 
+  td->rd_counts.compound_ref_used_flag |=
+      td_t->rd_counts.compound_ref_used_flag;
+  td->rd_counts.single_ref_used_flag |= td_t->rd_counts.single_ref_used_flag;
+
   for (i = 0; i < TX_SIZES; i++)
     for (j = 0; j < PLANE_TYPES; j++)
       for (k = 0; k < REF_TYPES; k++)
         for (l = 0; l < COEF_BANDS; l++)
           for (m = 0; m < COEFF_CONTEXTS; m++)
             for (n = 0; n < ENTROPY_TOKENS; n++)
               td->rd_counts.coef_counts[i][j][k][l][m][n] +=
                   td_t->rd_counts.coef_counts[i][j][k][l][m][n];
--- a/third_party/aom/av1/encoder/firstpass.c
+++ b/third_party/aom/av1/encoder/firstpass.c
@@ -1226,37 +1226,16 @@ static void setup_rf_level_maxq(AV1_COMP
   int i;
   RATE_CONTROL *const rc = &cpi->rc;
   for (i = INTER_NORMAL; i < RATE_FACTOR_LEVELS; ++i) {
     int qdelta = av1_frame_type_qdelta(cpi, i, rc->worst_quality);
     rc->rf_level_maxq[i] = AOMMAX(rc->worst_quality + qdelta, rc->best_quality);
   }
 }
 
-void av1_calculate_next_scaled_size(const AV1_COMP *cpi,
-                                    int *scaled_frame_width,
-                                    int *scaled_frame_height) {
-  *scaled_frame_width =
-      cpi->oxcf.width * cpi->resize_next_scale_num / cpi->resize_next_scale_den;
-  *scaled_frame_height = cpi->oxcf.height * cpi->resize_next_scale_num /
-                         cpi->resize_next_scale_den;
-}
-
-#if CONFIG_FRAME_SUPERRES
-void av1_calculate_superres_size(const AV1_COMP *cpi, int *encoded_width,
-                                 int *encoded_height) {
-  *encoded_width = cpi->oxcf.scaled_frame_width *
-                   cpi->common.superres_scale_numerator /
-                   SUPERRES_SCALE_DENOMINATOR;
-  *encoded_height = cpi->oxcf.scaled_frame_height *
-                    cpi->common.superres_scale_numerator /
-                    SUPERRES_SCALE_DENOMINATOR;
-}
-#endif  // CONFIG_FRAME_SUPERRES
-
 void av1_init_second_pass(AV1_COMP *cpi) {
   const AV1EncoderConfig *const oxcf = &cpi->oxcf;
   TWO_PASS *const twopass = &cpi->twopass;
   double frame_rate;
   FIRSTPASS_STATS *stats;
 
   zero_stats(&twopass->total_stats);
   zero_stats(&twopass->total_left_stats);
@@ -2286,22 +2265,16 @@ static void define_gf_group(AV1_COMP *cp
   // Reset the file position.
   reset_fpf_position(twopass, start_pos);
 
   // Calculate a section intra ratio used in setting max loop filter.
   if (cpi->common.frame_type != KEY_FRAME) {
     twopass->section_intra_rating = calculate_section_intra_ratio(
         start_pos, twopass->stats_in_end, rc->baseline_gf_interval);
   }
-
-  if (oxcf->resize_mode == RESIZE_DYNAMIC) {
-    // Default to starting GF groups at normal frame size.
-    // TODO(afergs): Make a function for this
-    cpi->resize_next_scale_num = cpi->resize_next_scale_den;
-  }
 }
 
 // Threshold for use of the lagging second reference frame. High second ref
 // usage may point to a transient event like a flash or occlusion rather than
 // a real scene cut.
 #define SECOND_REF_USEAGE_THRESH 0.1
 // Minimum % intra coding observed in first pass (1.0 = 100%)
 #define MIN_INTRA_LEVEL 0.25
@@ -2633,22 +2606,16 @@ static void find_next_key_frame(AV1_COMP
 
   // Note the total error score of the kf group minus the key frame itself.
   twopass->kf_group_error_left = (int)(kf_group_err - kf_mod_err);
 
   // Adjust the count of total modified error left.
   // The count of bits left is adjusted elsewhere based on real coded frame
   // sizes.
   twopass->modified_error_left -= kf_group_err;
-
-  if (oxcf->resize_mode == RESIZE_DYNAMIC) {
-    // Default to normal-sized frame on keyframes.
-    // TODO(afergs): Make a function for this
-    cpi->resize_next_scale_num = cpi->resize_next_scale_den;
-  }
 }
 
 // Define the reference buffers that will be updated post encode.
 static void configure_buffer_updates(AV1_COMP *cpi) {
   TWO_PASS *const twopass = &cpi->twopass;
 
   // Wei-Ting: Should we define another function to take care of
   // cpi->rc.is_$Source_Type to make this function as it is in the comment?
--- a/third_party/aom/av1/encoder/firstpass.h
+++ b/third_party/aom/av1/encoder/firstpass.h
@@ -172,28 +172,16 @@ void av1_end_first_pass(struct AV1_COMP 
 
 void av1_init_second_pass(struct AV1_COMP *cpi);
 void av1_rc_get_second_pass_params(struct AV1_COMP *cpi);
 void av1_twopass_postencode_update(struct AV1_COMP *cpi);
 
 // Post encode update of the rate control parameters for 2-pass
 void av1_twopass_postencode_update(struct AV1_COMP *cpi);
 
-void av1_calculate_next_scaled_size(const struct AV1_COMP *cpi,
-                                    int *scaled_frame_width,
-                                    int *scaled_frame_height);
-
-#if CONFIG_FRAME_SUPERRES
-// This is the size after superress scaling, which could be 1:1.
-// Superres scaling happens after regular downscaling.
-// TODO(afergs): Limit overall reduction to 1/2 of the original size
-void av1_calculate_superres_size(const struct AV1_COMP *cpi, int *encoded_width,
-                                 int *encoded_height);
-#endif  // CONFIG_FRAME_SUPERRES
-
 #if CONFIG_EXT_REFS
 static INLINE int get_number_of_extra_arfs(int interval, int arf_pending) {
   if (arf_pending && MAX_EXT_ARFS > 0)
     return interval >= MIN_EXT_ARF_INTERVAL * (MAX_EXT_ARFS + 1)
                ? MAX_EXT_ARFS
                : interval >= MIN_EXT_ARF_INTERVAL * MAX_EXT_ARFS
                      ? MAX_EXT_ARFS - 1
                      : 0;
--- a/third_party/aom/av1/encoder/global_motion.c
+++ b/third_party/aom/av1/encoder/global_motion.c
@@ -126,18 +126,18 @@ static void force_wmtype(WarpedMotionPar
 
 int64_t refine_integerized_param(WarpedMotionParams *wm,
                                  TransformationType wmtype,
 #if CONFIG_HIGHBITDEPTH
                                  int use_hbd, int bd,
 #endif  // CONFIG_HIGHBITDEPTH
                                  uint8_t *ref, int r_width, int r_height,
                                  int r_stride, uint8_t *dst, int d_width,
-                                 int d_height, int d_stride,
-                                 int n_refinements) {
+                                 int d_height, int d_stride, int n_refinements,
+                                 int64_t best_frame_error) {
   static const int max_trans_model_params[TRANS_TYPES] = {
     0, 2, 4, 6, 8, 8, 8
   };
   const int border = ERRORADV_BORDER;
   int i = 0, p;
   int n_params = max_trans_model_params[wmtype];
   int32_t *param_mat = wm->wmmat;
   int64_t step_error, best_error;
@@ -149,18 +149,19 @@ int64_t refine_integerized_param(WarpedM
   force_wmtype(wm, wmtype);
   best_error = av1_warp_error(wm,
 #if CONFIG_HIGHBITDEPTH
                               use_hbd, bd,
 #endif  // CONFIG_HIGHBITDEPTH
                               ref, r_width, r_height, r_stride,
                               dst + border * d_stride + border, border, border,
                               d_width - 2 * border, d_height - 2 * border,
-                              d_stride, 0, 0, 16, 16);
-  step = 1 << (n_refinements + 1);
+                              d_stride, 0, 0, 16, 16, best_frame_error);
+  best_error = AOMMIN(best_error, best_frame_error);
+  step = 1 << (n_refinements - 1);
   for (i = 0; i < n_refinements; i++, step >>= 1) {
     for (p = 0; p < n_params; ++p) {
       int step_dir = 0;
       // Skip searches for parameters that are forced to be 0
       if (wmtype == HORTRAPEZOID && (p == 4 || p == 6)) continue;
       if (wmtype == VERTRAPEZOID && (p == 3 || p == 7)) continue;
       param = param_mat + p;
       curr_param = *param;
@@ -169,33 +170,33 @@ int64_t refine_integerized_param(WarpedM
       *param = add_param_offset(p, curr_param, -step);
       step_error = av1_warp_error(
           wm,
 #if CONFIG_HIGHBITDEPTH
           use_hbd, bd,
 #endif  // CONFIG_HIGHBITDEPTH
           ref, r_width, r_height, r_stride, dst + border * d_stride + border,
           border, border, d_width - 2 * border, d_height - 2 * border, d_stride,
-          0, 0, 16, 16);
+          0, 0, 16, 16, best_error);
       if (step_error < best_error) {
         best_error = step_error;
         best_param = *param;
         step_dir = -1;
       }
 
       // look to the right
       *param = add_param_offset(p, curr_param, step);
       step_error = av1_warp_error(
           wm,
 #if CONFIG_HIGHBITDEPTH
           use_hbd, bd,
 #endif  // CONFIG_HIGHBITDEPTH
           ref, r_width, r_height, r_stride, dst + border * d_stride + border,
           border, border, d_width - 2 * border, d_height - 2 * border, d_stride,
-          0, 0, 16, 16);
+          0, 0, 16, 16, best_error);
       if (step_error < best_error) {
         best_error = step_error;
         best_param = *param;
         step_dir = 1;
       }
       *param = best_param;
 
       // look to the direction chosen above repeatedly until error increases
@@ -204,17 +205,17 @@ int64_t refine_integerized_param(WarpedM
         *param = add_param_offset(p, best_param, step * step_dir);
         step_error = av1_warp_error(
             wm,
 #if CONFIG_HIGHBITDEPTH
             use_hbd, bd,
 #endif  // CONFIG_HIGHBITDEPTH
             ref, r_width, r_height, r_stride, dst + border * d_stride + border,
             border, border, d_width - 2 * border, d_height - 2 * border,
-            d_stride, 0, 0, 16, 16);
+            d_stride, 0, 0, 16, 16, best_error);
         if (step_error < best_error) {
           best_error = step_error;
           best_param = *param;
         } else {
           *param = best_param;
           step_dir = 0;
         }
       }
--- a/third_party/aom/av1/encoder/global_motion.h
+++ b/third_party/aom/av1/encoder/global_motion.h
@@ -31,17 +31,18 @@ int is_enough_erroradvantage(double erro
 // modified in place.
 int64_t refine_integerized_param(WarpedMotionParams *wm,
                                  TransformationType wmtype,
 #if CONFIG_HIGHBITDEPTH
                                  int use_hbd, int bd,
 #endif  // CONFIG_HIGHBITDEPTH
                                  uint8_t *ref, int r_width, int r_height,
                                  int r_stride, uint8_t *dst, int d_width,
-                                 int d_height, int d_stride, int n_refinements);
+                                 int d_height, int d_stride, int n_refinements,
+                                 int64_t best_frame_error);
 
 /*
   Computes "num_motions" candidate global motion parameters between two frames.
   The array "params_by_motion" should be length 8 * "num_motions". The ordering
   of each set of parameters is best described  by the homography:
 
         [x'     (m2 m3 m0   [x
     z .  y'  =   m4 m5 m1 *  y
--- a/third_party/aom/av1/encoder/hybrid_fwd_txfm.c
+++ b/third_party/aom/av1/encoder/hybrid_fwd_txfm.c
@@ -13,17 +13,17 @@
 #include "./aom_config.h"
 #include "./aom_dsp_rtcd.h"
 
 #include "av1/common/idct.h"
 #include "av1/encoder/hybrid_fwd_txfm.h"
 
 #if CONFIG_CHROMA_2X2
 static void fwd_txfm_2x2(const int16_t *src_diff, tran_low_t *coeff,
-                         int diff_stride, TX_TYPE tx_type, int lossless) {
+                         int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
   tran_high_t a1 = src_diff[0];
   tran_high_t b1 = src_diff[1];
   tran_high_t c1 = src_diff[diff_stride];
   tran_high_t d1 = src_diff[1 + diff_stride];
 
   tran_high_t a2 = a1 + c1;
   tran_high_t b2 = b1 + d1;
   tran_high_t c2 = a1 - c1;
@@ -34,144 +34,155 @@ static void fwd_txfm_2x2(const int16_t *
   c1 = c2 + d2;
   d1 = c2 - d2;
 
   coeff[0] = (tran_low_t)(4 * a1);
   coeff[1] = (tran_low_t)(4 * b1);
   coeff[2] = (tran_low_t)(4 * c1);
   coeff[3] = (tran_low_t)(4 * d1);
 
-  (void)tx_type;
-  (void)lossless;
+  (void)fwd_txfm_param;
 }
 #endif
 
 static void fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
-                         int diff_stride, TX_TYPE tx_type, int lossless) {
-  if (lossless) {
-    assert(tx_type == DCT_DCT);
+                         int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+  if (fwd_txfm_param->lossless) {
+    assert(fwd_txfm_param->tx_type == DCT_DCT);
     av1_fwht4x4(src_diff, coeff, diff_stride);
     return;
   }
 
-  av1_fht4x4(src_diff, coeff, diff_stride, tx_type);
+#if CONFIG_LGT
+  // only C version has LGTs
+  av1_fht4x4_c(src_diff, coeff, diff_stride, fwd_txfm_param);
+#else
+  av1_fht4x4(src_diff, coeff, diff_stride, fwd_txfm_param);
+#endif
 }
 
 static void fwd_txfm_4x8(const int16_t *src_diff, tran_low_t *coeff,
-                         int diff_stride, TX_TYPE tx_type,
-                         FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht4x8(src_diff, coeff, diff_stride, tx_type);
+                         int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+#if CONFIG_LGT
+  av1_fht4x8_c(src_diff, coeff, diff_stride, fwd_txfm_param);
+#else
+  av1_fht4x8(src_diff, coeff, diff_stride, fwd_txfm_param);
+#endif
 }
 
 static void fwd_txfm_8x4(const int16_t *src_diff, tran_low_t *coeff,
-                         int diff_stride, TX_TYPE tx_type,
-                         FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht8x4(src_diff, coeff, diff_stride, tx_type);
+                         int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+#if CONFIG_LGT
+  av1_fht8x4_c(src_diff, coeff, diff_stride, fwd_txfm_param);
+#else
+  av1_fht8x4(src_diff, coeff, diff_stride, fwd_txfm_param);
+#endif
 }
 
 static void fwd_txfm_8x16(const int16_t *src_diff, tran_low_t *coeff,
-                          int diff_stride, TX_TYPE tx_type,
-                          FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht8x16(src_diff, coeff, diff_stride, tx_type);
+                          int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+#if CONFIG_LGT
+  av1_fht8x16_c(src_diff, coeff, diff_stride, fwd_txfm_param);
+#else
+  av1_fht8x16(src_diff, coeff, diff_stride, fwd_txfm_param);
+#endif
 }
 
 static void fwd_txfm_16x8(const int16_t *src_diff, tran_low_t *coeff,
-                          int diff_stride, TX_TYPE tx_type,
-                          FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht16x8(src_diff, coeff, diff_stride, tx_type);
+                          int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+#if CONFIG_LGT
+  av1_fht16x8_c(src_diff, coeff, diff_stride, fwd_txfm_param);
+#else
+  av1_fht16x8(src_diff, coeff, diff_stride, fwd_txfm_param);
+#endif
 }
 
 static void fwd_txfm_16x32(const int16_t *src_diff, tran_low_t *coeff,
-                           int diff_stride, TX_TYPE tx_type,
-                           FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht16x32(src_diff, coeff, diff_stride, tx_type);
+                           int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht16x32(src_diff, coeff, diff_stride, fwd_txfm_param);
 }
 
 static void fwd_txfm_32x16(const int16_t *src_diff, tran_low_t *coeff,
-                           int diff_stride, TX_TYPE tx_type,
-                           FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht32x16(src_diff, coeff, diff_stride, tx_type);
+                           int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht32x16(src_diff, coeff, diff_stride, fwd_txfm_param);
 }
 
 static void fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff,
-                         int diff_stride, TX_TYPE tx_type,
-                         FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht8x8(src_diff, coeff, diff_stride, tx_type);
+                         int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+#if CONFIG_LGT
+  av1_fht8x8_c(src_diff, coeff, diff_stride, fwd_txfm_param);
+#else
+  av1_fht8x8(src_diff, coeff, diff_stride, fwd_txfm_param);
+#endif
 }
 
 static void fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff,
-                           int diff_stride, TX_TYPE tx_type,
-                           FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht16x16(src_diff, coeff, diff_stride, tx_type);
+                           int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht16x16(src_diff, coeff, diff_stride, fwd_txfm_param);
 }
 
 static void fwd_txfm_32x32(const int16_t *src_diff, tran_low_t *coeff,
-                           int diff_stride, TX_TYPE tx_type,
-                           FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht32x32(src_diff, coeff, diff_stride, tx_type);
+                           int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht32x32(src_diff, coeff, diff_stride, fwd_txfm_param);
 }
 
 #if CONFIG_TX64X64
 static void fwd_txfm_64x64(const int16_t *src_diff, tran_low_t *coeff,
-                           int diff_stride, TX_TYPE tx_type,
-                           FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
+                           int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
 #if CONFIG_EXT_TX
-  if (tx_type == IDTX)
-    av1_fwd_idtx_c(src_diff, coeff, diff_stride, 64, tx_type);
+  if (fwd_txfm_param->tx_type == IDTX)
+    av1_fwd_idtx_c(src_diff, coeff, diff_stride, 64, fwd_txfm_param->tx_type);
   else
 #endif
-    av1_fht64x64(src_diff, coeff, diff_stride, tx_type);
+    av1_fht64x64(src_diff, coeff, diff_stride, fwd_txfm_param);
 }
 #endif  // CONFIG_TX64X64
 
 #if CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
 static void fwd_txfm_16x4(const int16_t *src_diff, tran_low_t *coeff,
-                          int diff_stride, TX_TYPE tx_type,
-                          FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht16x4(src_diff, coeff, diff_stride, tx_type);
+                          int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+#if CONFIG_LGT
+  av1_fht16x4_c(src_diff, coeff, diff_stride, fwd_txfm_param);
+#else
+  av1_fht16x4(src_diff, coeff, diff_stride, fwd_txfm_param);
+#endif
 }
 
 static void fwd_txfm_4x16(const int16_t *src_diff, tran_low_t *coeff,
-                          int diff_stride, TX_TYPE tx_type,
-                          FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht4x16(src_diff, coeff, diff_stride, tx_type);
+                          int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+#if CONFIG_LGT
+  av1_fht4x16_c(src_diff, coeff, diff_stride, fwd_txfm_param);
+#else
+  av1_fht4x16(src_diff, coeff, diff_stride, fwd_txfm_param);
+#endif
 }
 
 static void fwd_txfm_32x8(const int16_t *src_diff, tran_low_t *coeff,
-                          int diff_stride, TX_TYPE tx_type,
-                          FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht32x8(src_diff, coeff, diff_stride, tx_type);
+                          int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+#if CONFIG_LGT
+  av1_fht32x8_c(src_diff, coeff, diff_stride, fwd_txfm_param);
+#else
+  av1_fht32x8(src_diff, coeff, diff_stride, fwd_txfm_param);
+#endif
 }
 
 static void fwd_txfm_8x32(const int16_t *src_diff, tran_low_t *coeff,
-                          int diff_stride, TX_TYPE tx_type,
-                          FWD_TXFM_OPT fwd_txfm_opt) {
-  (void)fwd_txfm_opt;
-  av1_fht8x32(src_diff, coeff, diff_stride, tx_type);
+                          int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
+#if CONFIG_LGT
+  av1_fht8x32_c(src_diff, coeff, diff_stride, fwd_txfm_param);
+#else
+  av1_fht8x32(src_diff, coeff, diff_stride, fwd_txfm_param);
+#endif
 }
 #endif  // CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
 
-#if CONFIG_HIGHBITDEPTH
 #if CONFIG_CHROMA_2X2
 static void highbd_fwd_txfm_2x2(const int16_t *src_diff, tran_low_t *coeff,
-                                int diff_stride, TX_TYPE tx_type, int lossless,
-                                const int bd) {
+                                int diff_stride,
+                                FWD_TXFM_PARAM *fwd_txfm_param) {
   tran_high_t a1 = src_diff[0];
   tran_high_t b1 = src_diff[1];
   tran_high_t c1 = src_diff[diff_stride];
   tran_high_t d1 = src_diff[1 + diff_stride];
 
   tran_high_t a2 = a1 + c1;
   tran_high_t b2 = b1 + d1;
   tran_high_t c2 = a1 - c1;
@@ -182,362 +193,373 @@ static void highbd_fwd_txfm_2x2(const in
   c1 = c2 + d2;
   d1 = c2 - d2;
 
   coeff[0] = (tran_low_t)(4 * a1);
   coeff[1] = (tran_low_t)(4 * b1);
   coeff[2] = (tran_low_t)(4 * c1);
   coeff[3] = (tran_low_t)(4 * d1);
 
-  (void)tx_type;
-  (void)lossless;
-  (void)bd;
+  (void)fwd_txfm_param;
 }
 #endif
 
 static void highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
-                                int diff_stride, TX_TYPE tx_type, int lossless,
-                                const int bd) {
-  if (lossless) {
+                                int diff_stride,
+                                FWD_TXFM_PARAM *fwd_txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  const int tx_type = fwd_txfm_param->tx_type;
+  const int bd = fwd_txfm_param->bd;
+  if (fwd_txfm_param->lossless) {
     assert(tx_type == DCT_DCT);
     av1_highbd_fwht4x4(src_diff, coeff, diff_stride);
     return;
   }
-
   switch (tx_type) {
     case DCT_DCT:
     case ADST_DCT:
     case DCT_ADST:
     case ADST_ADST:
-      av1_fwd_txfm2d_4x4(src_diff, coeff, diff_stride, tx_type, bd);
+      // fallthrough intended
+      av1_fwd_txfm2d_4x4(src_diff, dst_coeff, diff_stride, tx_type, bd);
       break;
 #if CONFIG_EXT_TX
     case FLIPADST_DCT:
     case DCT_FLIPADST:
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
     case FLIPADST_ADST:
-      av1_fwd_txfm2d_4x4(src_diff, coeff, diff_stride, tx_type, bd);
+      // fallthrough intended
+      av1_fwd_txfm2d_4x4(src_diff, dst_coeff, diff_stride, tx_type, bd);
       break;
+    // use the c version for anything including identity for now
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
     case H_FLIPADST:
-      av1_highbd_fht4x4_c(src_diff, coeff, diff_stride, tx_type);
+    case IDTX:
+      // fallthrough intended
+      av1_fwd_txfm2d_4x4_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
       break;
-    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 4, tx_type); break;
 #endif  // CONFIG_EXT_TX
     default: assert(0);
   }
 }
 
 static void highbd_fwd_txfm_4x8(const int16_t *src_diff, tran_low_t *coeff,
-                                int diff_stride, TX_TYPE tx_type,
-                                FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
-  (void)fwd_txfm_opt;
-  (void)bd;
-  av1_highbd_fht4x8(src_diff, coeff, diff_stride, tx_type);
+                                int diff_stride,
+                                FWD_TXFM_PARAM *fwd_txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  av1_fwd_txfm2d_4x8_c(src_diff, dst_coeff, diff_stride,
+                       fwd_txfm_param->tx_type, fwd_txfm_param->bd);
 }
 
 static void highbd_fwd_txfm_8x4(const int16_t *src_diff, tran_low_t *coeff,
-                                int diff_stride, TX_TYPE tx_type,
-                                FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
-  (void)fwd_txfm_opt;
-  (void)bd;
-  av1_highbd_fht8x4(src_diff, coeff, diff_stride, tx_type);
+                                int diff_stride,
+                                FWD_TXFM_PARAM *fwd_txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  av1_fwd_txfm2d_8x4_c(src_diff, dst_coeff, diff_stride,
+                       fwd_txfm_param->tx_type, fwd_txfm_param->bd);
 }
 
 static void highbd_fwd_txfm_8x16(const int16_t *src_diff, tran_low_t *coeff,
-                                 int diff_stride, TX_TYPE tx_type,
-                                 FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
-  (void)fwd_txfm_opt;
-  (void)bd;
-  av1_highbd_fht8x16(src_diff, coeff, diff_stride, tx_type);
+                                 int diff_stride,
+                                 FWD_TXFM_PARAM *fwd_txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  av1_fwd_txfm2d_8x16_c(src_diff, dst_coeff, diff_stride,
+                        fwd_txfm_param->tx_type, fwd_txfm_param->bd);
 }
 
 static void highbd_fwd_txfm_16x8(const int16_t *src_diff, tran_low_t *coeff,
-                                 int diff_stride, TX_TYPE tx_type,
-                                 FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
-  (void)fwd_txfm_opt;
-  (void)bd;
-  av1_highbd_fht16x8(src_diff, coeff, diff_stride, tx_type);
+                                 int diff_stride,
+                                 FWD_TXFM_PARAM *fwd_txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  av1_fwd_txfm2d_16x8_c(src_diff, dst_coeff, diff_stride,
+                        fwd_txfm_param->tx_type, fwd_txfm_param->bd);
 }
 
 static void highbd_fwd_txfm_16x32(const int16_t *src_diff, tran_low_t *coeff,
-                                  int diff_stride, TX_TYPE tx_type,
-                                  FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
-  (void)fwd_txfm_opt;
-  (void)bd;
-  av1_highbd_fht16x32(src_diff, coeff, diff_stride, tx_type);
+                                  int diff_stride,
+                                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  av1_fwd_txfm2d_16x32_c(src_diff, dst_coeff, diff_stride,
+                         fwd_txfm_param->tx_type, fwd_txfm_param->bd);
 }
 
 static void highbd_fwd_txfm_32x16(const int16_t *src_diff, tran_low_t *coeff,
-                                  int diff_stride, TX_TYPE tx_type,
-                                  FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
-  (void)fwd_txfm_opt;
-  (void)bd;
-  av1_highbd_fht32x16(src_diff, coeff, diff_stride, tx_type);
+                                  int diff_stride,
+                                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  av1_fwd_txfm2d_32x16_c(src_diff, dst_coeff, diff_stride,
+                         fwd_txfm_param->tx_type, fwd_txfm_param->bd);
 }
 
 static void highbd_fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff,
-                                int diff_stride, TX_TYPE tx_type,
-                                FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
-  (void)fwd_txfm_opt;
+                                int diff_stride,
+                                FWD_TXFM_PARAM *fwd_txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  const int tx_type = fwd_txfm_param->tx_type;
+  const int bd = fwd_txfm_param->bd;
   switch (tx_type) {
     case DCT_DCT:
     case ADST_DCT:
     case DCT_ADST:
     case ADST_ADST:
-      av1_fwd_txfm2d_8x8(src_diff, coeff, diff_stride, tx_type, bd);
+      // fallthrough intended
+      av1_fwd_txfm2d_8x8(src_diff, dst_coeff, diff_stride, tx_type, bd);
       break;
 #if CONFIG_EXT_TX
     case FLIPADST_DCT:
     case DCT_FLIPADST:
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
     case FLIPADST_ADST:
-      av1_fwd_txfm2d_8x8(src_diff, coeff, diff_stride, tx_type, bd);
+      // fallthrough intended
+      av1_fwd_txfm2d_8x8(src_diff, dst_coeff, diff_stride, tx_type, bd);
       break;
+    // use the c version for anything including identity for now
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
     case H_FLIPADST:
-      // Use C version since DST exists only in C
-      av1_highbd_fht8x8_c(src_diff, coeff, diff_stride, tx_type);
+    case IDTX:
+      // fallthrough intended
+      av1_fwd_txfm2d_8x8_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
       break;
-    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 8, tx_type); break;
 #endif  // CONFIG_EXT_TX
     default: assert(0);
   }
 }
 
 static void highbd_fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff,
-                                  int diff_stride, TX_TYPE tx_type,
-                                  FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
-  (void)fwd_txfm_opt;
+                                  int diff_stride,
+                                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  const int tx_type = fwd_txfm_param->tx_type;
+  const int bd = fwd_txfm_param->bd;
   switch (tx_type) {
     case DCT_DCT:
     case ADST_DCT:
     case DCT_ADST:
     case ADST_ADST:
-      av1_fwd_txfm2d_16x16(src_diff, coeff, diff_stride, tx_type, bd);
+      // fallthrough intended
+      av1_fwd_txfm2d_16x16(src_diff, dst_coeff, diff_stride, tx_type, bd);
       break;
 #if CONFIG_EXT_TX
     case FLIPADST_DCT:
     case DCT_FLIPADST:
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
     case FLIPADST_ADST:
-      av1_fwd_txfm2d_16x16(src_diff, coeff, diff_stride, tx_type, bd);
+      // fallthrough intended
+      av1_fwd_txfm2d_16x16(src_diff, dst_coeff, diff_stride, tx_type, bd);
       break;
+    // use the c version for anything including identity for now
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
     case H_FLIPADST:
-      // Use C version since DST exists only in C
-      av1_highbd_fht16x16_c(src_diff, coeff, diff_stride, tx_type);
+    case IDTX:
+      // fallthrough intended
+      av1_fwd_txfm2d_16x16_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
       break;
-    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 16, tx_type); break;
 #endif  // CONFIG_EXT_TX
     default: assert(0);
   }
 }
 
 static void highbd_fwd_txfm_32x32(const int16_t *src_diff, tran_low_t *coeff,
-                                  int diff_stride, TX_TYPE tx_type,
-                                  FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
-  (void)fwd_txfm_opt;
+                                  int diff_stride,
+                                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  const int tx_type = fwd_txfm_param->tx_type;
+  const int bd = fwd_txfm_param->bd;
   switch (tx_type) {
     case DCT_DCT:
-      av1_fwd_txfm2d_32x32(src_diff, coeff, diff_stride, tx_type, bd);
+    case ADST_DCT:
+    case DCT_ADST:
+    case ADST_ADST:
+      // fallthrough intended
+      av1_fwd_txfm2d_32x32(src_diff, dst_coeff, diff_stride, tx_type, bd);
+      break;
+#if CONFIG_EXT_TX
+    case FLIPADST_DCT:
+    case DCT_FLIPADST:
+    case FLIPADST_FLIPADST:
+    case ADST_FLIPADST:
+    case FLIPADST_ADST:
+      // fallthrough intended
+      av1_fwd_txfm2d_32x32(src_diff, dst_coeff, diff_stride, tx_type, bd);
+      break;
+    // use the c version for anything including identity for now
+    case V_DCT:
+    case H_DCT:
+    case V_ADST:
+    case H_ADST:
+    case V_FLIPADST:
+    case H_FLIPADST:
+    case IDTX:
+      // fallthrough intended
+      av1_fwd_txfm2d_32x32_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
+      break;
+#endif  // CONFIG_EXT_TX
+    default: assert(0);
+  }
+}
+
+#if CONFIG_TX64X64
+static void highbd_fwd_txfm_64x64(const int16_t *src_diff, tran_low_t *coeff,
+                                  int diff_stride,
+                                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  int32_t *dst_coeff = (int32_t *)coeff;
+  const int tx_type = fwd_txfm_param->tx_type;
+  const int bd = fwd_txfm_param->bd;
+  switch (tx_type) {
+    case DCT_DCT:
+      av1_fwd_txfm2d_64x64(src_diff, dst_coeff, diff_stride, tx_type, bd);
       break;
 #if CONFIG_EXT_TX
     case ADST_DCT:
     case DCT_ADST:
     case ADST_ADST:
     case FLIPADST_DCT:
     case DCT_FLIPADST:
     case FLIPADST_FLIPADST:
     case ADST_FLIPADST:
     case FLIPADST_ADST:
     case V_DCT:
     case H_DCT:
     case V_ADST:
     case H_ADST:
     case V_FLIPADST:
     case H_FLIPADST:
-      av1_highbd_fht32x32_c(src_diff, coeff, diff_stride, tx_type);
-      break;
-    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 32, tx_type); break;
-#endif  // CONFIG_EXT_TX
-    default: assert(0); break;
-  }
-}
-
-#if CONFIG_TX64X64
-static void highbd_fwd_txfm_64x64(const int16_t *src_diff, tran_low_t *coeff,
-                                  int diff_stride, TX_TYPE tx_type,
-                                  FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
-  (void)fwd_txfm_opt;
-  (void)bd;
-  switch (tx_type) {
-    case DCT_DCT:
-      av1_highbd_fht64x64(src_diff, coeff, diff_stride, tx_type);
+      // TODO(sarahparker)
+      // I've deleted the 64x64 implementations that existed in lieu
+      // of adst, flipadst and identity for simplicity but will bring back
+      // in a later change. This shouldn't impact performance since
+      // DCT_DCT is the only extended type currently allowed for 64x64,
+      // as dictated by get_ext_tx_set_type in blockd.h.
+      av1_fwd_txfm2d_64x64_c(src_diff, dst_coeff, diff_stride, DCT_DCT, bd);
       break;
-#if CONFIG_EXT_TX
-    case ADST_DCT:
-    case DCT_ADST:
-    case ADST_ADST:
-    case FLIPADST_DCT:
-    case DCT_FLIPADST:
-    case FLIPADST_FLIPADST:
-    case ADST_FLIPADST:
-    case FLIPADST_ADST:
-    case V_DCT:
-    case H_DCT:
-    case V_ADST:
-    case H_ADST:
-    case V_FLIPADST:
-    case H_FLIPADST:
-      av1_highbd_fht64x64(src_diff, coeff, diff_stride, tx_type);
+    case IDTX:
+      av1_fwd_idtx_c(src_diff, dst_coeff, diff_stride, 64, tx_type);
       break;
-    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 64, tx_type); break;
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
   }
 }
 #endif  // CONFIG_TX64X64
-#endif  // CONFIG_HIGHBITDEPTH
 
 void av1_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, int diff_stride,
                   FWD_TXFM_PARAM *fwd_txfm_param) {
-  const int fwd_txfm_opt = FWD_TXFM_OPT_NORMAL;
-  const TX_TYPE tx_type = fwd_txfm_param->tx_type;
   const TX_SIZE tx_size = fwd_txfm_param->tx_size;
-  const int lossless = fwd_txfm_param->lossless;
   switch (tx_size) {
 #if CONFIG_TX64X64
     case TX_64X64:
-      fwd_txfm_64x64(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_64x64(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
 #endif  // CONFIG_TX64X64
     case TX_32X32:
-      fwd_txfm_32x32(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_32x32(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_16X16:
-      fwd_txfm_16x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_16x16(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_8X8:
-      fwd_txfm_8x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_8x8(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_4X8:
-      fwd_txfm_4x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_4x8(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_8X4:
-      fwd_txfm_8x4(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_8x4(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_8X16:
-      fwd_txfm_8x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_8x16(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_16X8:
-      fwd_txfm_16x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_16x8(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_16X32:
-      fwd_txfm_16x32(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_16x32(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_32X16:
-      fwd_txfm_32x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_32x16(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_4X4:
-      fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, lossless);
+      fwd_txfm_4x4(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
 #if CONFIG_CHROMA_2X2
     case TX_2X2:
-      fwd_txfm_2x2(src_diff, coeff, diff_stride, tx_type, lossless);
+      fwd_txfm_2x2(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
 #endif
 #if CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
     case TX_4X16:
-      fwd_txfm_4x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_4x16(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_16X4:
-      fwd_txfm_16x4(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_16x4(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_8X32:
-      fwd_txfm_8x32(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_8x32(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_32X8:
-      fwd_txfm_32x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
+      fwd_txfm_32x8(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
 #endif  // CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
     default: assert(0); break;
   }
 }
 
-#if CONFIG_HIGHBITDEPTH
 void av1_highbd_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff,
                          int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
-  const int fwd_txfm_opt = FWD_TXFM_OPT_NORMAL;
-  const TX_TYPE tx_type = fwd_txfm_param->tx_type;
   const TX_SIZE tx_size = fwd_txfm_param->tx_size;
-  const int lossless = fwd_txfm_param->lossless;
-  const int bd = fwd_txfm_param->bd;
   switch (tx_size) {
 #if CONFIG_TX64X64
     case TX_64X64:
-      highbd_fwd_txfm_64x64(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
-                            bd);
+      highbd_fwd_txfm_64x64(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
 #endif  // CONFIG_TX64X64
     case TX_32X32:
-      highbd_fwd_txfm_32x32(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
-                            bd);
+      highbd_fwd_txfm_32x32(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_16X16:
-      highbd_fwd_txfm_16x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
-                            bd);
+      highbd_fwd_txfm_16x16(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_8X8:
-      highbd_fwd_txfm_8x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
-                          bd);
+      highbd_fwd_txfm_8x8(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_4X8:
-      highbd_fwd_txfm_4x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
-                          bd);
+      highbd_fwd_txfm_4x8(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_8X4:
-      highbd_fwd_txfm_8x4(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
-                          bd);
+      highbd_fwd_txfm_8x4(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_8X16:
-      highbd_fwd_txfm_8x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
-                           bd);
+      highbd_fwd_txfm_8x16(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_16X8:
-      highbd_fwd_txfm_16x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
-                           bd);
+      highbd_fwd_txfm_16x8(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_16X32:
-      highbd_fwd_txfm_16x32(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
-                            bd);
+      highbd_fwd_txfm_16x32(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_32X16:
-      highbd_fwd_txfm_32x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
-                            bd);
+      highbd_fwd_txfm_32x16(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
     case TX_4X4:
-      highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, lossless, bd);
+      highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
 #if CONFIG_CHROMA_2X2
     case TX_2X2:
-      highbd_fwd_txfm_2x2(src_diff, coeff, diff_stride, tx_type, lossless, bd);
+      highbd_fwd_txfm_2x2(src_diff, coeff, diff_stride, fwd_txfm_param);
       break;
 #endif
     default: assert(0); break;
   }
 }
-#endif  // CONFIG_HIGHBITDEPTH
--- a/third_party/aom/av1/encoder/hybrid_fwd_txfm.h
+++ b/third_party/aom/av1/encoder/hybrid_fwd_txfm.h
@@ -9,36 +9,23 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #ifndef AV1_ENCODER_HYBRID_FWD_TXFM_H_
 #define AV1_ENCODER_HYBRID_FWD_TXFM_H_
 
 #include "./aom_config.h"
 
-typedef enum FWD_TXFM_OPT { FWD_TXFM_OPT_NORMAL } FWD_TXFM_OPT;
-
-typedef struct FWD_TXFM_PARAM {
-  TX_TYPE tx_type;
-  TX_SIZE tx_size;
-  int lossless;
-#if CONFIG_HIGHBITDEPTH
-  int bd;
-#endif  // CONFIG_HIGHBITDEPTH
-} FWD_TXFM_PARAM;
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 void av1_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, int diff_stride,
                   FWD_TXFM_PARAM *fwd_txfm_param);
 
-#if CONFIG_HIGHBITDEPTH
 void av1_highbd_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff,
                          int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param);
-#endif  // CONFIG_HIGHBITDEPTH
 
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
 #endif  // AV1_ENCODER_HYBRID_FWD_TXFM_H_
--- a/third_party/aom/av1/encoder/mcomp.c
+++ b/third_party/aom/av1/encoder/mcomp.c
@@ -223,59 +223,55 @@ static INLINE const uint8_t *pre(const u
     }                                                                     \
   } else {                                                                \
     v = INT_MAX;                                                          \
   }
 #endif  // CONFIG_EXT_INTER
 
 #define CHECK_BETTER0(v, r, c) CHECK_BETTER(v, r, c)
 
-static INLINE const uint8_t *upre(const uint8_t *buf, int stride, int r,
-                                  int c) {
-  return &buf[(r)*stride + (c)];
-}
-
 /* checks if (r, c) has better score than previous best */
 #if CONFIG_EXT_INTER
-#define CHECK_BETTER1(v, r, c)                                               \
-  if (c >= minc && c <= maxc && r >= minr && r <= maxr) {                    \
-    MV this_mv = { r, c };                                                   \
-    thismse = upsampled_pref_error(                                          \
-        xd, vfp, src_address, src_stride, upre(y, y_stride, r, c), y_stride, \
-        second_pred, mask, mask_stride, invert_mask, w, h, &sse);            \
-    v = mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit);       \
-    v += thismse;                                                            \
-    if (v < besterr) {                                                       \
-      besterr = v;                                                           \
-      br = r;                                                                \
-      bc = c;                                                                \
-      *distortion = thismse;                                                 \
-      *sse1 = sse;                                                           \
-    }                                                                        \
-  } else {                                                                   \
-    v = INT_MAX;                                                             \
+#define CHECK_BETTER1(v, r, c)                                              \
+  if (c >= minc && c <= maxc && r >= minr && r <= maxr) {                   \
+    MV this_mv = { r, c };                                                  \
+    thismse = upsampled_pref_error(xd, vfp, src_address, src_stride,        \
+                                   pre(y, y_stride, r, c), y_stride, sp(c), \
+                                   sp(r), second_pred, mask, mask_stride,   \
+                                   invert_mask, w, h, &sse);                \
+    v = mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit);      \
+    v += thismse;                                                           \
+    if (v < besterr) {                                                      \
+      besterr = v;                                                          \
+      br = r;                                                               \
+      bc = c;                                                               \
+      *distortion = thismse;                                                \
+      *sse1 = sse;                                                          \
+    }                                                                       \
+  } else {                                                                  \
+    v = INT_MAX;                                                            \
   }
 #else
-#define CHECK_BETTER1(v, r, c)                                         \
-  if (c >= minc && c <= maxc && r >= minr && r <= maxr) {              \
-    MV this_mv = { r, c };                                             \
-    thismse = upsampled_pref_error(xd, vfp, src_address, src_stride,   \
-                                   upre(y, y_stride, r, c), y_stride,  \
-                                   second_pred, w, h, &sse);           \
-    v = mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); \
-    v += thismse;                                                      \
-    if (v < besterr) {                                                 \
-      besterr = v;                                                     \
-      br = r;                                                          \
-      bc = c;                                                          \
-      *distortion = thismse;                                           \
-      *sse1 = sse;                                                     \
-    }                                                                  \
-  } else {                                                             \
-    v = INT_MAX;                                                       \
+#define CHECK_BETTER1(v, r, c)                                              \
+  if (c >= minc && c <= maxc && r >= minr && r <= maxr) {                   \
+    MV this_mv = { r, c };                                                  \
+    thismse = upsampled_pref_error(xd, vfp, src_address, src_stride,        \
+                                   pre(y, y_stride, r, c), y_stride, sp(c), \
+                                   sp(r), second_pred, w, h, &sse);         \
+    v = mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit);      \
+    v += thismse;                                                           \
+    if (v < besterr) {                                                      \
+      besterr = v;                                                          \
+      br = r;                                                               \
+      bc = c;                                                               \
+      *distortion = thismse;                                                \
+      *sse1 = sse;                                                          \
+    }                                                                       \
+  } else {                                                                  \
+    v = INT_MAX;                                                            \
   }
 #endif  // CONFIG_EXT_INTER
 
 #define FIRST_LEVEL_CHECKS                                       \
   {                                                              \
     unsigned int left, right, up, down, diag;                    \
     CHECK_BETTER(left, tr, tc - hstep);                          \
     CHECK_BETTER(right, tr, tc + hstep);                         \
@@ -695,61 +691,63 @@ int av1_find_best_sub_pixel_tree_pruned(
 static const MV search_step_table[12] = {
   // left, right, up, down
   { 0, -4 }, { 0, 4 }, { -4, 0 }, { 4, 0 },
   { 0, -2 }, { 0, 2 }, { -2, 0 }, { 2, 0 },
   { 0, -1 }, { 0, 1 }, { -1, 0 }, { 1, 0 }
 };
 /* clang-format on */
 
-static int upsampled_pref_error(const MACROBLOCKD *xd,
-                                const aom_variance_fn_ptr_t *vfp,
-                                const uint8_t *const src, const int src_stride,
-                                const uint8_t *const y, int y_stride,
-                                const uint8_t *second_pred,
+static int upsampled_pref_error(
+    const MACROBLOCKD *xd, const aom_variance_fn_ptr_t *vfp,
+    const uint8_t *const src, const int src_stride, const uint8_t *const y,
+    int y_stride, int subpel_x_q3, int subpel_y_q3, const uint8_t *second_pred,
 #if CONFIG_EXT_INTER
-                                const uint8_t *mask, int mask_stride,
-                                int invert_mask,
+    const uint8_t *mask, int mask_stride, int invert_mask,
 #endif
-                                int w, int h, unsigned int *sse) {
+    int w, int h, unsigned int *sse) {
   unsigned int besterr;
 #if CONFIG_HIGHBITDEPTH
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
     DECLARE_ALIGNED(16, uint16_t, pred16[MAX_SB_SQUARE]);
     if (second_pred != NULL) {
 #if CONFIG_EXT_INTER
       if (mask)
-        aom_highbd_comp_mask_upsampled_pred(pred16, second_pred, w, h, y,
-                                            y_stride, mask, mask_stride,
-                                            invert_mask);
+        aom_highbd_comp_mask_upsampled_pred(
+            pred16, second_pred, w, h, subpel_x_q3, subpel_y_q3, y, y_stride,
+            mask, mask_stride, invert_mask, xd->cur_buf->bit_depth);
       else
 #endif
-        aom_highbd_comp_avg_upsampled_pred(pred16, second_pred, w, h, y,
-                                           y_stride);
+        aom_highbd_comp_avg_upsampled_pred(pred16, second_pred, w, h,
+                                           subpel_x_q3, subpel_y_q3, y,
+                                           y_stride, xd->cur_buf->bit_depth);
     } else {
-      aom_highbd_upsampled_pred(pred16, w, h, y, y_stride);
+      aom_highbd_upsampled_pred(pred16, w, h, subpel_x_q3, subpel_y_q3, y,
+                                y_stride, xd->cur_buf->bit_depth);
     }
 
     besterr = vfp->vf(CONVERT_TO_BYTEPTR(pred16), w, src, src_stride, sse);
   } else {
     DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]);
 #else
   DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]);
   (void)xd;
 #endif  // CONFIG_HIGHBITDEPTH
     if (second_pred != NULL) {
 #if CONFIG_EXT_INTER
       if (mask)
-        aom_comp_mask_upsampled_pred(pred, second_pred, w, h, y, y_stride, mask,
+        aom_comp_mask_upsampled_pred(pred, second_pred, w, h, subpel_x_q3,
+                                     subpel_y_q3, y, y_stride, mask,
                                      mask_stride, invert_mask);
       else
 #endif
-        aom_comp_avg_upsampled_pred(pred, second_pred, w, h, y, y_stride);
+        aom_comp_avg_upsampled_pred(pred, second_pred, w, h, subpel_x_q3,
+                                    subpel_y_q3, y, y_stride);
     } else {
-      aom_upsampled_pred(pred, w, h, y, y_stride);
+      aom_upsampled_pred(pred, w, h, subpel_x_q3, subpel_y_q3, y, y_stride);
     }
 
     besterr = vfp->vf(pred, w, src, src_stride, sse);
 #if CONFIG_HIGHBITDEPTH
   }
 #endif
   return besterr;
 }
@@ -759,22 +757,22 @@ static unsigned int upsampled_setup_cent
     int error_per_bit, const aom_variance_fn_ptr_t *vfp,
     const uint8_t *const src, const int src_stride, const uint8_t *const y,
     int y_stride, const uint8_t *second_pred,
 #if CONFIG_EXT_INTER
     const uint8_t *mask, int mask_stride, int invert_mask,
 #endif
     int w, int h, int offset, int *mvjcost, int *mvcost[2], unsigned int *sse1,
     int *distortion) {
-  unsigned int besterr = upsampled_pref_error(xd, vfp, src, src_stride,
-                                              y + offset, y_stride, second_pred,
+  unsigned int besterr = upsampled_pref_error(
+      xd, vfp, src, src_stride, y + offset, y_stride, 0, 0, second_pred,
 #if CONFIG_EXT_INTER
-                                              mask, mask_stride, invert_mask,
+      mask, mask_stride, invert_mask,
 #endif
-                                              w, h, sse1);
+      w, h, sse1);
   *distortion = besterr;
   besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
   return besterr;
 }
 
 int av1_find_best_sub_pixel_tree(
     MACROBLOCK *x, const MV *ref_mv, int allow_hp, int error_per_bit,
     const aom_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step,
@@ -819,17 +817,17 @@ int av1_find_best_sub_pixel_tree(
   // use_upsampled_ref can be 0 or 1
   if (use_upsampled_ref)
     besterr = upsampled_setup_center_error(
         xd, bestmv, ref_mv, error_per_bit, vfp, src_address, src_stride, y,
         y_stride, second_pred,
 #if CONFIG_EXT_INTER
         mask, mask_stride, invert_mask,
 #endif
-        w, h, (offset * 8), mvjcost, mvcost, sse1, distortion);
+        w, h, offset, mvjcost, mvcost, sse1, distortion);
   else
     besterr =
         setup_center_error(xd, bestmv, ref_mv, error_per_bit, vfp, src_address,
                            src_stride, y, y_stride, second_pred,
 #if CONFIG_EXT_INTER
                            mask, mask_stride, invert_mask,
 #endif
                            w, h, offset, mvjcost, mvcost, sse1, distortion);
@@ -840,27 +838,25 @@ int av1_find_best_sub_pixel_tree(
     // Check vertical and horizontal sub-pixel positions.
     for (idx = 0; idx < 4; ++idx) {
       tr = br + search_step[idx].row;
       tc = bc + search_step[idx].col;
       if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) {
         MV this_mv = { tr, tc };
 
         if (use_upsampled_ref) {
-          const uint8_t *const pre_address = y + tr * y_stride + tc;
-
           thismse = upsampled_pref_error(xd, vfp, src_address, src_stride,
-                                         pre_address, y_stride, second_pred,
+                                         pre(y, y_stride, tr, tc), y_stride,
+                                         sp(tc), sp(tr), second_pred,
 #if CONFIG_EXT_INTER
                                          mask, mask_stride, invert_mask,
 #endif
                                          w, h, &sse);
         } else {
-          const uint8_t *const pre_address =
-              y + (tr >> 3) * y_stride + (tc >> 3);
+          const uint8_t *const pre_address = pre(y, y_stride, tr, tc);
           if (second_pred == NULL)
             thismse = vfp->svf(pre_address, y_stride, sp(tc), sp(tr),
                                src_address, src_stride, &sse);
 #if CONFIG_EXT_INTER
           else if (mask)
             thismse = vfp->msvf(pre_address, y_stride, sp(tc), sp(tr),
                                 src_address, src_stride, second_pred, mask,
                                 mask_stride, invert_mask, &sse);
@@ -889,26 +885,25 @@ int av1_find_best_sub_pixel_tree(
     kr = (cost_array[2] <= cost_array[3] ? -hstep : hstep);
 
     tc = bc + kc;
     tr = br + kr;
     if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) {
       MV this_mv = { tr, tc };
 
       if (use_upsampled_ref) {
-        const uint8_t *const pre_address = y + tr * y_stride + tc;
-
         thismse = upsampled_pref_error(xd, vfp, src_address, src_stride,
-                                       pre_address, y_stride, second_pred,
+                                       pre(y, y_stride, tr, tc), y_stride,
+                                       sp(tc), sp(tr), second_pred,
 #if CONFIG_EXT_INTER
                                        mask, mask_stride, invert_mask,
 #endif
                                        w, h, &sse);
       } else {
-        const uint8_t *const pre_address = y + (tr >> 3) * y_stride + (tc >> 3);
+        const uint8_t *const pre_address = pre(y, y_stride, tr, tc);
 
         if (second_pred == NULL)
           thismse = vfp->svf(pre_address, y_stride, sp(tc), sp(tr), src_address,
                              src_stride, &sse);
 #if CONFIG_EXT_INTER
         else if (mask)
           thismse = vfp->msvf(pre_address, y_stride, sp(tc), sp(tr),
                               src_address, src_stride, second_pred, mask,
@@ -2648,29 +2643,30 @@ int av1_full_pixel_search(const AV1_COMP
   } else {                                                \
     v = INT_MAX;                                          \
   }
 
 #undef CHECK_BETTER0
 #define CHECK_BETTER0(v, r, c) CHECK_BETTER(v, r, c)
 
 #undef CHECK_BETTER1
-#define CHECK_BETTER1(v, r, c)                                            \
-  if (c >= minc && c <= maxc && r >= minr && r <= maxr) {                 \
-    thismse = upsampled_obmc_pref_error(                                  \
-        xd, mask, vfp, z, upre(y, y_stride, r, c), y_stride, w, h, &sse); \
-    if ((v = MVC(r, c) + thismse) < besterr) {                            \
-      besterr = v;                                                        \
-      br = r;                                                             \
-      bc = c;                                                             \
-      *distortion = thismse;                                              \
-      *sse1 = sse;                                                        \
-    }                                                                     \
-  } else {                                                                \
-    v = INT_MAX;                                                          \
+#define CHECK_BETTER1(v, r, c)                                              \
+  if (c >= minc && c <= maxc && r >= minr && r <= maxr) {                   \
+    thismse =                                                               \
+        upsampled_obmc_pref_error(xd, mask, vfp, z, pre(y, y_stride, r, c), \
+                                  y_stride, sp(c), sp(r), w, h, &sse);      \
+    if ((v = MVC(r, c) + thismse) < besterr) {                              \
+      besterr = v;                                                          \
+      br = r;                                                               \
+      bc = c;                                                               \
+      *distortion = thismse;                                                \
+      *sse1 = sse;                                                          \
+    }                                                                       \
+  } else {                                                                  \
+    v = INT_MAX;                                                            \
   }
 
 static unsigned int setup_obmc_center_error(
     const int32_t *mask, const MV *bestmv, const MV *ref_mv, int error_per_bit,
     const aom_variance_fn_ptr_t *vfp, const int32_t *const wsrc,
     const uint8_t *const y, int y_stride, int offset, int *mvjcost,
     int *mvcost[2], unsigned int *sse1, int *distortion) {
   unsigned int besterr;
@@ -2679,58 +2675,59 @@ static unsigned int setup_obmc_center_er
   besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
   return besterr;
 }
 
 static int upsampled_obmc_pref_error(const MACROBLOCKD *xd, const int32_t *mask,
                                      const aom_variance_fn_ptr_t *vfp,
                                      const int32_t *const wsrc,
                                      const uint8_t *const y, int y_stride,
-                                     int w, int h, unsigned int *sse) {
+                                     int subpel_x_q3, int subpel_y_q3, int w,
+                                     int h, unsigned int *sse) {
   unsigned int besterr;
 #if CONFIG_HIGHBITDEPTH
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
     DECLARE_ALIGNED(16, uint16_t, pred16[MAX_SB_SQUARE]);
-    aom_highbd_upsampled_pred(pred16, w, h, y, y_stride);
+    aom_highbd_upsampled_pred(pred16, w, h, subpel_x_q3, subpel_y_q3, y,
+                              y_stride, xd->cur_buf->bit_depth);
 
     besterr = vfp->ovf(CONVERT_TO_BYTEPTR(pred16), w, wsrc, mask, sse);
   } else {
     DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]);
 #else
   DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]);
   (void)xd;
 #endif  // CONFIG_HIGHBITDEPTH
-    aom_upsampled_pred(pred, w, h, y, y_stride);
+    aom_upsampled_pred(pred, w, h, subpel_x_q3, subpel_y_q3, y, y_stride);
 
     besterr = vfp->ovf(pred, w, wsrc, mask, sse);
 #if CONFIG_HIGHBITDEPTH
   }
 #endif
   return besterr;
 }
 
 static unsigned int upsampled_setup_obmc_center_error(
     const MACROBLOCKD *xd, const int32_t *mask, const MV *bestmv,
     const MV *ref_mv, int error_per_bit, const aom_variance_fn_ptr_t *vfp,
     const int32_t *const wsrc, const uint8_t *const y, int y_stride, int w,
     int h, int offset, int *mvjcost, int *mvcost[2], unsigned int *sse1,
     int *distortion) {
   unsigned int besterr = upsampled_obmc_pref_error(
-      xd, mask, vfp, wsrc, y + offset, y_stride, w, h, sse1);
+      xd, mask, vfp, wsrc, y + offset, y_stride, 0, 0, w, h, sse1);
   *distortion = besterr;
   besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
   return besterr;
 }
 
 int av1_find_best_obmc_sub_pixel_tree_up(
-    const AV1_COMP *cpi, MACROBLOCK *x, int mi_row, int mi_col, MV *bestmv,
-    const MV *ref_mv, int allow_hp, int error_per_bit,
-    const aom_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step,
-    int *mvjcost, int *mvcost[2], int *distortion, unsigned int *sse1,
-    int is_second, int use_upsampled_ref) {
+    MACROBLOCK *x, MV *bestmv, const MV *ref_mv, int allow_hp,
+    int error_per_bit, const aom_variance_fn_ptr_t *vfp, int forced_stop,
+    int iters_per_step, int *mvjcost, int *mvcost[2], int *distortion,
+    unsigned int *sse1, int is_second, int use_upsampled_ref) {
   const int32_t *wsrc = x->wsrc_buf;
   const int32_t *mask = x->mask_buf;
   const int *const z = wsrc;
   const int *const src_address = z;
   MACROBLOCKD *xd = &x->e_mbd;
   struct macroblockd_plane *const pd = &xd->plane[0];
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   unsigned int besterr = INT_MAX;
@@ -2751,66 +2748,54 @@ int av1_find_best_obmc_sub_pixel_tree_up
   unsigned int cost_array[5];
   int kr, kc;
   const int w = block_size_wide[mbmi->sb_type];
   const int h = block_size_high[mbmi->sb_type];
   int offset;
   int y_stride;
   const uint8_t *y;
 
-  const struct buf_2d backup_pred = pd->pre[is_second];
   int minc, maxc, minr, maxr;
 
   av1_set_subpel_mv_search_range(&x->mv_limits, &minc, &maxc, &minr, &maxr,
                                  ref_mv);
 
-  if (use_upsampled_ref) {
-    int ref = xd->mi[0]->mbmi.ref_frame[is_second];
-    const YV12_BUFFER_CONFIG *upsampled_ref = get_upsampled_ref(cpi, ref);
-    setup_pred_plane(&pd->pre[is_second], mbmi->sb_type,
-                     upsampled_ref->y_buffer, upsampled_ref->y_crop_width,
-                     upsampled_ref->y_crop_height, upsampled_ref->y_stride,
-                     (mi_row << 3), (mi_col << 3), NULL, pd->subsampling_x,
-                     pd->subsampling_y);
-  }
   y = pd->pre[is_second].buf;
   y_stride = pd->pre[is_second].stride;
   offset = bestmv->row * y_stride + bestmv->col;
 
   if (!allow_hp)
     if (round == 3) round = 2;
 
   bestmv->row *= 8;
   bestmv->col *= 8;
   // use_upsampled_ref can be 0 or 1
   if (use_upsampled_ref)
     besterr = upsampled_setup_obmc_center_error(
         xd, mask, bestmv, ref_mv, error_per_bit, vfp, z, y, y_stride, w, h,
-        (offset * 8), mvjcost, mvcost, sse1, distortion);
+        offset, mvjcost, mvcost, sse1, distortion);
   else
     besterr = setup_obmc_center_error(mask, bestmv, ref_mv, error_per_bit, vfp,
                                       z, y, y_stride, offset, mvjcost, mvcost,
                                       sse1, distortion);
 
   for (iter = 0; iter < round; ++iter) {
     // Check vertical and horizontal sub-pixel positions.
     for (idx = 0; idx < 4; ++idx) {
       tr = br + search_step[idx].row;
       tc = bc + search_step[idx].col;
       if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) {
         MV this_mv = { tr, tc };
+        const uint8_t *const pre_address = pre(y, y_stride, tr, tc);
 
         if (use_upsampled_ref) {
-          const uint8_t *const pre_address = y + tr * y_stride + tc;
-
-          thismse = upsampled_obmc_pref_error(
-              xd, mask, vfp, src_address, pre_address, y_stride, w, h, &sse);
+          thismse =
+              upsampled_obmc_pref_error(xd, mask, vfp, src_address, pre_address,
+                                        y_stride, sp(tc), sp(tr), w, h, &sse);
         } else {
-          const uint8_t *const pre_address =
-              y + (tr >> 3) * y_stride + (tc >> 3);
           thismse = vfp->osvf(pre_address, y_stride, sp(tc), sp(tr),
                               src_address, mask, &sse);
         }
 
         cost_array[idx] = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost,
                                                 mvcost, error_per_bit);
         if (cost_array[idx] < besterr) {
           best_idx = idx;
@@ -2828,25 +2813,22 @@ int av1_find_best_obmc_sub_pixel_tree_up
     kr = (cost_array[2] <= cost_array[3] ? -hstep : hstep);
 
     tc = bc + kc;
     tr = br + kr;
     if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) {
       MV this_mv = { tr, tc };
 
       if (use_upsampled_ref) {
-        const uint8_t *const pre_address = y + tr * y_stride + tc;
-
         thismse = upsampled_obmc_pref_error(xd, mask, vfp, src_address,
-                                            pre_address, y_stride, w, h, &sse);
+                                            pre(y, y_stride, tr, tc), y_stride,
+                                            sp(tc), sp(tr), w, h, &sse);
       } else {
-        const uint8_t *const pre_address = y + (tr >> 3) * y_stride + (tc >> 3);
-
-        thismse = vfp->osvf(pre_address, y_stride, sp(tc), sp(tr), src_address,
-                            mask, &sse);
+        thismse = vfp->osvf(pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr),
+                            src_address, mask, &sse);
       }
 
       cost_array[4] = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost,
                                             error_per_bit);
 
       if (cost_array[4] < besterr) {
         best_idx = 4;
         besterr = cost_array[4];
@@ -2884,20 +2866,16 @@ int av1_find_best_obmc_sub_pixel_tree_up
   // These lines insure static analysis doesn't warn that
   // tr and tc aren't used after the above point.
   (void)tr;
   (void)tc;
 
   bestmv->row = br;
   bestmv->col = bc;
 
-  if (use_upsampled_ref) {
-    pd->pre[is_second] = backup_pred;
-  }
-
   return besterr;
 }
 
 #undef DIST
 #undef MVC
 #undef CHECK_BETTER
 
 static int get_obmc_mvpred_var(const MACROBLOCK *x, const int32_t *wsrc,
--- a/third_party/aom/av1/encoder/mcomp.h
+++ b/third_party/aom/av1/encoder/mcomp.h
@@ -138,21 +138,20 @@ int av1_full_pixel_search(const struct A
 
 #if CONFIG_MOTION_VAR
 int av1_obmc_full_pixel_diamond(const struct AV1_COMP *cpi, MACROBLOCK *x,
                                 MV *mvp_full, int step_param, int sadpb,
                                 int further_steps, int do_refine,
                                 const aom_variance_fn_ptr_t *fn_ptr,
                                 const MV *ref_mv, MV *dst_mv, int is_second);
 int av1_find_best_obmc_sub_pixel_tree_up(
-    const struct AV1_COMP *cpi, MACROBLOCK *x, int mi_row, int mi_col,
-    MV *bestmv, const MV *ref_mv, int allow_hp, int error_per_bit,
-    const aom_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step,
-    int *mvjcost, int *mvcost[2], int *distortion, unsigned int *sse1,
-    int is_second, int use_upsampled_ref);
+    MACROBLOCK *x, MV *bestmv, const MV *ref_mv, int allow_hp,
+    int error_per_bit, const aom_variance_fn_ptr_t *vfp, int forced_stop,
+    int iters_per_step, int *mvjcost, int *mvcost[2], int *distortion,
+    unsigned int *sse1, int is_second, int use_upsampled_ref);
 #endif  // CONFIG_MOTION_VAR
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
 #if CONFIG_WARPED_MOTION
 unsigned int av1_compute_motion_cost(const struct AV1_COMP *cpi,
                                      MACROBLOCK *const x, BLOCK_SIZE bsize,
--- a/third_party/aom/av1/encoder/pickcdef.c
+++ b/third_party/aom/av1/encoder/pickcdef.c
@@ -14,59 +14,66 @@
 
 #include "./aom_scale_rtcd.h"
 #include "aom/aom_integer.h"
 #include "av1/common/cdef.h"
 #include "av1/common/onyxc_int.h"
 #include "av1/common/reconinter.h"
 #include "av1/encoder/encoder.h"
 
+#define REDUCED_STRENGTHS 8
+#define REDUCED_TOTAL_STRENGTHS (REDUCED_STRENGTHS * CLPF_STRENGTHS)
 #define TOTAL_STRENGTHS (DERING_STRENGTHS * CLPF_STRENGTHS)
 
+static int priconv[REDUCED_STRENGTHS] = { 0, 1, 2, 3, 4, 7, 12, 25 };
+
 /* Search for the best strength to add as an option, knowing we
    already selected nb_strengths options. */
 static uint64_t search_one(int *lev, int nb_strengths,
-                           uint64_t mse[][TOTAL_STRENGTHS], int sb_count) {
+                           uint64_t mse[][TOTAL_STRENGTHS], int sb_count,
+                           int fast) {
   uint64_t tot_mse[TOTAL_STRENGTHS];
+  const int total_strengths = fast ? REDUCED_TOTAL_STRENGTHS : TOTAL_STRENGTHS;
   int i, j;
   uint64_t best_tot_mse = (uint64_t)1 << 63;
   int best_id = 0;
   memset(tot_mse, 0, sizeof(tot_mse));
   for (i = 0; i < sb_count; i++) {
     int gi;
     uint64_t best_mse = (uint64_t)1 << 63;
     /* Find best mse among already selected options. */
     for (gi = 0; gi < nb_strengths; gi++) {
       if (mse[i][lev[gi]] < best_mse) {
         best_mse = mse[i][lev[gi]];
       }
     }
     /* Find best mse when adding each possible new option. */
-    for (j = 0; j < TOTAL_STRENGTHS; j++) {
+    for (j = 0; j < total_strengths; j++) {
       uint64_t best = best_mse;
       if (mse[i][j] < best) best = mse[i][j];
       tot_mse[j] += best;
     }
   }
-  for (j = 0; j < TOTAL_STRENGTHS; j++) {
+  for (j = 0; j < total_strengths; j++) {
     if (tot_mse[j] < best_tot_mse) {
       best_tot_mse = tot_mse[j];
       best_id = j;
     }
   }
   lev[nb_strengths] = best_id;
   return best_tot_mse;
 }
 
 /* Search for the best luma+chroma strength to add as an option, knowing we
    already selected nb_strengths options. */
 static uint64_t search_one_dual(int *lev0, int *lev1, int nb_strengths,
-                                uint64_t (**mse)[TOTAL_STRENGTHS],
-                                int sb_count) {
+                                uint64_t (**mse)[TOTAL_STRENGTHS], int sb_count,
+                                int fast) {
   uint64_t tot_mse[TOTAL_STRENGTHS][TOTAL_STRENGTHS];
+  const int total_strengths = fast ? REDUCED_TOTAL_STRENGTHS : TOTAL_STRENGTHS;
   int i, j;
   uint64_t best_tot_mse = (uint64_t)1 << 63;
   int best_id0 = 0;
   int best_id1 = 0;
   memset(tot_mse, 0, sizeof(tot_mse));
   for (i = 0; i < sb_count; i++) {
     int gi;
     uint64_t best_mse = (uint64_t)1 << 63;
@@ -74,85 +81,89 @@ static uint64_t search_one_dual(int *lev
     for (gi = 0; gi < nb_strengths; gi++) {
       uint64_t curr = mse[0][i][lev0[gi]];
       curr += mse[1][i][lev1[gi]];
       if (curr < best_mse) {
         best_mse = curr;
       }
     }
     /* Find best mse when adding each possible new option. */
-    for (j = 0; j < TOTAL_STRENGTHS; j++) {
+    for (j = 0; j < total_strengths; j++) {
       int k;
-      for (k = 0; k < TOTAL_STRENGTHS; k++) {
+      for (k = 0; k < total_strengths; k++) {
         uint64_t best = best_mse;
         uint64_t curr = mse[0][i][j];
         curr += mse[1][i][k];
         if (curr < best) best = curr;
         tot_mse[j][k] += best;
       }
     }
   }
-  for (j = 0; j < TOTAL_STRENGTHS; j++) {
+  for (j = 0; j < total_strengths; j++) {
     int k;
-    for (k = 0; k < TOTAL_STRENGTHS; k++) {
+    for (k = 0; k < total_strengths; k++) {
       if (tot_mse[j][k] < best_tot_mse) {
         best_tot_mse = tot_mse[j][k];
         best_id0 = j;
         best_id1 = k;
       }
     }
   }
   lev0[nb_strengths] = best_id0;
   lev1[nb_strengths] = best_id1;
   return best_tot_mse;
 }
 
 /* Search for the set of strengths that minimizes mse. */
 static uint64_t joint_strength_search(int *best_lev, int nb_strengths,
                                       uint64_t mse[][TOTAL_STRENGTHS],
-                                      int sb_count) {
+                                      int sb_count, int fast) {
   uint64_t best_tot_mse;
   int i;
   best_tot_mse = (uint64_t)1 << 63;
   /* Greedy search: add one strength options at a time. */
   for (i = 0; i < nb_strengths; i++) {
-    best_tot_mse = search_one(best_lev, i, mse, sb_count);
+    best_tot_mse = search_one(best_lev, i, mse, sb_count, fast);
   }
   /* Trying to refine the greedy search by reconsidering each
      already-selected option. */
-  for (i = 0; i < 4 * nb_strengths; i++) {
-    int j;
-    for (j = 0; j < nb_strengths - 1; j++) best_lev[j] = best_lev[j + 1];
-    best_tot_mse = search_one(best_lev, nb_strengths - 1, mse, sb_count);
+  if (!fast) {
+    for (i = 0; i < 4 * nb_strengths; i++) {
+      int j;
+      for (j = 0; j < nb_strengths - 1; j++) best_lev[j] = best_lev[j + 1];
+      best_tot_mse =
+          search_one(best_lev, nb_strengths - 1, mse, sb_count, fast);
+    }
   }
   return best_tot_mse;
 }
 
 /* Search for the set of luma+chroma strengths that minimizes mse. */
 static uint64_t joint_strength_search_dual(int *best_lev0, int *best_lev1,
                                            int nb_strengths,
                                            uint64_t (**mse)[TOTAL_STRENGTHS],
-                                           int sb_count) {
+                                           int sb_count, int fast) {
   uint64_t best_tot_mse;
   int i;
   best_tot_mse = (uint64_t)1 << 63;
   /* Greedy search: add one strength options at a time. */
   for (i = 0; i < nb_strengths; i++) {
-    best_tot_mse = search_one_dual(best_lev0, best_lev1, i, mse, sb_count);
+    best_tot_mse =
+        search_one_dual(best_lev0, best_lev1, i, mse, sb_count, fast);
   }
   /* Trying to refine the greedy search by reconsidering each
      already-selected option. */
   for (i = 0; i < 4 * nb_strengths; i++) {
     int j;
     for (j = 0; j < nb_strengths - 1; j++) {
       best_lev0[j] = best_lev0[j + 1];
       best_lev1[j] = best_lev1[j + 1];
     }
-    best_tot_mse =
-        search_one_dual(best_lev0, best_lev1, nb_strengths - 1, mse, sb_count);
+    best_tot_mse = search_one_dual(best_lev0, best_lev1, nb_strengths - 1, mse,
+                                   sb_count, fast);
   }
   return best_tot_mse;
 }
 
 /* FIXME: SSE-optimize this. */
 static void copy_sb16_16(uint16_t *dst, int dstride, const uint16_t *src,
                          int src_voffset, int src_hoffset, int sstride,
                          int vsize, int hsize) {
@@ -264,17 +275,17 @@ uint64_t compute_dering_dist(uint16_t *d
       sum += mse_4x4_16bit(&dst[(by << 2) * dstride + (bx << 2)], dstride,
                            &src[bi << (2 + 2)], 4);
     }
   }
   return sum >> 2 * coeff_shift;
 }
 
 void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
-                     AV1_COMMON *cm, MACROBLOCKD *xd) {
+                     AV1_COMMON *cm, MACROBLOCKD *xd, int fast) {
   int r, c;
   int sbr, sbc;
   uint16_t *src[3];
   uint16_t *ref_coeff[3];
   dering_list dlist[MAX_MIB_SIZE * MAX_MIB_SIZE];
   int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS] = { { 0 } };
   int var[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS] = { { 0 } };
   int stride[3];
@@ -297,16 +308,17 @@ void av1_cdef_search(YV12_BUFFER_CONFIG 
   int clpf_damping = 3 + (cm->base_qindex >> 6);
   int dering_damping = 6;
   int i;
   int nb_strengths;
   int nb_strength_bits;
   int quantizer;
   double lambda;
   int nplanes = 3;
+  const int total_strengths = fast ? REDUCED_TOTAL_STRENGTHS : TOTAL_STRENGTHS;
   DECLARE_ALIGNED(32, uint16_t, inbuf[OD_DERING_INBUF_SIZE]);
   uint16_t *in;
   DECLARE_ALIGNED(32, uint16_t, tmp_dst[MAX_SB_SQUARE]);
   int chroma_dering =
       xd->plane[1].subsampling_x == xd->plane[1].subsampling_y &&
       xd->plane[2].subsampling_x == xd->plane[2].subsampling_y;
   quantizer =
       av1_ac_quant(cm->base_qindex, 0, cm->bit_depth) >> (cm->bit_depth - 8);
@@ -381,21 +393,22 @@ void av1_cdef_search(YV12_BUFFER_CONFIG 
                           MAX_MIB_SIZE * sbc]
           ->mbmi.cdef_strength = -1;
       if (sb_all_skip(cm, sbr * MAX_MIB_SIZE, sbc * MAX_MIB_SIZE)) continue;
       dering_count = sb_compute_dering_list(cm, sbr * MAX_MIB_SIZE,
                                             sbc * MAX_MIB_SIZE, dlist, 1);
       for (pli = 0; pli < nplanes; pli++) {
         for (i = 0; i < OD_DERING_INBUF_SIZE; i++)
           inbuf[i] = OD_DERING_VERY_LARGE;
-        for (gi = 0; gi < TOTAL_STRENGTHS; gi++) {
+        for (gi = 0; gi < total_strengths; gi++) {
           int threshold;
           uint64_t curr_mse;
           int clpf_strength;
           threshold = gi / CLPF_STRENGTHS;
+          if (fast) threshold = priconv[threshold];
           if (pli > 0 && !chroma_dering) threshold = 0;
           /* We avoid filtering the pixels for which some of the pixels to
              average
              are outside the frame. We could change the filter instead, but it
              would add special cases for any future vectorization. */
           int yoff = OD_FILT_VBORDER * (sbr != 0);
           int xoff = OD_FILT_HBORDER * (sbc != 0);
           int ysize = (nvb << mi_high_l2[pli]) +
@@ -435,20 +448,20 @@ void av1_cdef_search(YV12_BUFFER_CONFIG 
   /* Search for different number of signalling bits. */
   for (i = 0; i <= 3; i++) {
     int j;
     int best_lev0[CDEF_MAX_STRENGTHS];
     int best_lev1[CDEF_MAX_STRENGTHS] = { 0 };
     nb_strengths = 1 << i;
     if (nplanes >= 3)
       tot_mse = joint_strength_search_dual(best_lev0, best_lev1, nb_strengths,
-                                           mse, sb_count);
+                                           mse, sb_count, fast);
     else
-      tot_mse =
-          joint_strength_search(best_lev0, nb_strengths, mse[0], sb_count);
+      tot_mse = joint_strength_search(best_lev0, nb_strengths, mse[0], sb_count,
+                                      fast);
     /* Count superblock signalling cost. */
     tot_mse += (uint64_t)(sb_count * lambda * i);
     /* Count header signalling cost. */
     tot_mse += (uint64_t)(nb_strengths * lambda * CDEF_STRENGTH_BITS);
     if (tot_mse < best_tot_mse) {
       best_tot_mse = tot_mse;
       nb_strength_bits = i;
       for (j = 0; j < 1 << nb_strength_bits; j++) {
@@ -472,16 +485,27 @@ void av1_cdef_search(YV12_BUFFER_CONFIG 
       if (curr < best_mse) {
         best_gi = gi;
         best_mse = curr;
       }
     }
     selected_strength[i] = best_gi;
     cm->mi_grid_visible[sb_index[i]]->mbmi.cdef_strength = best_gi;
   }
+
+  if (fast) {
+    for (int j = 0; j < nb_strengths; j++) {
+      cm->cdef_strengths[j] =
+          priconv[cm->cdef_strengths[j] / CLPF_STRENGTHS] * CLPF_STRENGTHS +
+          (cm->cdef_strengths[j] % CLPF_STRENGTHS);
+      cm->cdef_uv_strengths[j] =
+          priconv[cm->cdef_uv_strengths[j] / CLPF_STRENGTHS] * CLPF_STRENGTHS +
+          (cm->cdef_uv_strengths[j] % CLPF_STRENGTHS);
+    }
+  }
   cm->cdef_dering_damping = dering_damping;
   cm->cdef_clpf_damping = clpf_damping;
   aom_free(mse[0]);
   aom_free(mse[1]);
   for (pli = 0; pli < nplanes; pli++) {
     aom_free(src[pli]);
     aom_free(ref_coeff[pli]);
   }
--- a/third_party/aom/av1/encoder/picklpf.c
+++ b/third_party/aom/av1/encoder/picklpf.c
@@ -149,18 +149,17 @@ int av1_search_filter_level(const YV12_B
       filt_direction = (filt_best < filt_mid) ? -1 : 1;
       filt_mid = filt_best;
     }
   }
 
   // Update best error
   best_err = ss_err[filt_best];
 
-  if (best_cost_ret)
-    *best_cost_ret = RDCOST_DBL(x->rdmult, x->rddiv, 0, best_err);
+  if (best_cost_ret) *best_cost_ret = RDCOST_DBL(x->rdmult, 0, best_err);
   return filt_best;
 }
 
 void av1_pick_filter_level(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi,
                            LPF_PICK_METHOD method) {
   AV1_COMMON *const cm = &cpi->common;
   struct loopfilter *const lf = &cm->lf;
 
--- a/third_party/aom/av1/encoder/pickrst.c
+++ b/third_party/aom/av1/encoder/pickrst.c
@@ -432,18 +432,18 @@ static double search_sgrproj(const YV12_
   AV1_COMMON *const cm = &cpi->common;
   const YV12_BUFFER_CONFIG *dgd = cm->frame_to_show;
   RestorationInfo *rsi = &cpi->rst_search[0];
   int tile_idx, tile_width, tile_height, nhtiles, nvtiles;
   int h_start, h_end, v_start, v_end;
   int width, height, src_stride, dgd_stride;
   uint8_t *dgd_buffer, *src_buffer;
   if (plane == AOM_PLANE_Y) {
-    width = cm->width;
-    height = cm->height;
+    width = src->y_crop_width;
+    height = src->y_crop_height;
     src_buffer = src->y_buffer;
     src_stride = src->y_stride;
     dgd_buffer = dgd->y_buffer;
     dgd_stride = dgd->y_stride;
     assert(width == dgd->y_crop_width);
     assert(height == dgd->y_crop_height);
     assert(width == src->y_crop_width);
     assert(height == src->y_crop_height);
@@ -473,17 +473,17 @@ static double search_sgrproj(const YV12_
     av1_get_rest_tile_limits(tile_idx, 0, 0, nhtiles, nvtiles, tile_width,
                              tile_height, width, height, 0, 0, &h_start, &h_end,
                              &v_start, &v_end);
     err = sse_restoration_tile(src, cm->frame_to_show, cm, h_start,
                                h_end - h_start, v_start, v_end - v_start,
                                (1 << plane));
     // #bits when a tile is not restored
     bits = av1_cost_bit(RESTORE_NONE_SGRPROJ_PROB, 0);
-    cost_norestore = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
+    cost_norestore = RDCOST_DBL(x->rdmult, (bits >> 4), err);
     best_tile_cost[tile_idx] = DBL_MAX;
     search_selfguided_restoration(
         dgd_buffer + v_start * dgd_stride + h_start, h_end - h_start,
         v_end - v_start, dgd_stride,
         src_buffer + v_start * src_stride + h_start, src_stride,
 #if CONFIG_HIGHBITDEPTH
         cm->bit_depth,
 #else
@@ -493,17 +493,17 @@ static double search_sgrproj(const YV12_
         rsi[plane].sgrproj_info[tile_idx].xqd, cm->rst_internal.tmpbuf);
     rsi[plane].restoration_type[tile_idx] = RESTORE_SGRPROJ;
     err = try_restoration_tile(src, cpi, rsi, (1 << plane), partial_frame,
                                tile_idx, 0, 0, dst_frame);
     bits = count_sgrproj_bits(&rsi[plane].sgrproj_info[tile_idx],
                               &ref_sgrproj_info)
            << AV1_PROB_COST_SHIFT;
     bits += av1_cost_bit(RESTORE_NONE_SGRPROJ_PROB, 1);
-    cost_sgrproj = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
+    cost_sgrproj = RDCOST_DBL(x->rdmult, (bits >> 4), err);
     if (cost_sgrproj >= cost_norestore) {
       type[tile_idx] = RESTORE_NONE;
     } else {
       type[tile_idx] = RESTORE_SGRPROJ;
       memcpy(&sgrproj_info[tile_idx], &rsi[plane].sgrproj_info[tile_idx],
              sizeof(sgrproj_info[tile_idx]));
       memcpy(&ref_sgrproj_info, &sgrproj_info[tile_idx],
              sizeof(ref_sgrproj_info));
@@ -526,17 +526,17 @@ static double search_sgrproj(const YV12_
               << AV1_PROB_COST_SHIFT;
       memcpy(&ref_sgrproj_info, &rsi[plane].sgrproj_info[tile_idx],
              sizeof(ref_sgrproj_info));
     }
     rsi[plane].restoration_type[tile_idx] = type[tile_idx];
   }
   err = try_restoration_frame(src, cpi, rsi, (1 << plane), partial_frame,
                               dst_frame);
-  cost_sgrproj = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
+  cost_sgrproj = RDCOST_DBL(x->rdmult, (bits >> 4), err);
 
   return cost_sgrproj;
 }
 
 static double find_average(uint8_t *src, int h_start, int h_end, int v_start,
                            int v_end, int stride) {
   uint64_t sum = 0;
   double avg = 0;
@@ -980,18 +980,18 @@ static double search_wiener(const YV12_B
   MACROBLOCK *x = &cpi->td.mb;
   double M[WIENER_WIN2];
   double H[WIENER_WIN2 * WIENER_WIN2];
   double vfilterd[WIENER_WIN], hfilterd[WIENER_WIN];
   const YV12_BUFFER_CONFIG *dgd = cm->frame_to_show;
   int width, height, src_stride, dgd_stride;
   uint8_t *dgd_buffer, *src_buffer;
   if (plane == AOM_PLANE_Y) {
-    width = cm->width;
-    height = cm->height;
+    width = src->y_crop_width;
+    height = src->y_crop_height;
     src_buffer = src->y_buffer;
     src_stride = src->y_stride;
     dgd_buffer = dgd->y_buffer;
     dgd_stride = dgd->y_stride;
     assert(width == dgd->y_crop_width);
     assert(height == dgd->y_crop_height);
     assert(width == src->y_crop_width);
     assert(height == src->y_crop_height);
@@ -1034,17 +1034,17 @@ static double search_wiener(const YV12_B
     av1_get_rest_tile_limits(tile_idx, 0, 0, nhtiles, nvtiles, tile_width,
                              tile_height, width, height, 0, 0, &h_start, &h_end,
                              &v_start, &v_end);
     err = sse_restoration_tile(src, cm->frame_to_show, cm, h_start,
                                h_end - h_start, v_start, v_end - v_start,
                                (1 << plane));
     // #bits when a tile is not restored
     bits = av1_cost_bit(RESTORE_NONE_WIENER_PROB, 0);
-    cost_norestore = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
+    cost_norestore = RDCOST_DBL(x->rdmult, (bits >> 4), err);
     best_tile_cost[tile_idx] = DBL_MAX;
 
     av1_get_rest_tile_limits(tile_idx, 0, 0, nhtiles, nvtiles, tile_width,
                              tile_height, width, height, 0, 0, &h_start, &h_end,
                              &v_start, &v_end);
 #if CONFIG_HIGHBITDEPTH
     if (cm->use_highbitdepth)
       compute_stats_highbd(dgd_buffer, src_buffer, h_start, h_end, v_start,
@@ -1076,17 +1076,17 @@ static double search_wiener(const YV12_B
 
     rsi[plane].restoration_type[tile_idx] = RESTORE_WIENER;
     err = finer_tile_search_wiener(src, cpi, rsi, 4, plane, tile_idx,
                                    partial_frame, dst_frame);
     bits =
         count_wiener_bits(&rsi[plane].wiener_info[tile_idx], &ref_wiener_info)
         << AV1_PROB_COST_SHIFT;
     bits += av1_cost_bit(RESTORE_NONE_WIENER_PROB, 1);
-    cost_wiener = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
+    cost_wiener = RDCOST_DBL(x->rdmult, (bits >> 4), err);
     if (cost_wiener >= cost_norestore) {
       type[tile_idx] = RESTORE_NONE;
     } else {
       type[tile_idx] = RESTORE_WIENER;
       memcpy(&wiener_info[tile_idx], &rsi[plane].wiener_info[tile_idx],
              sizeof(wiener_info[tile_idx]));
       memcpy(&ref_wiener_info, &rsi[plane].wiener_info[tile_idx],
              sizeof(ref_wiener_info));
@@ -1109,17 +1109,17 @@ static double search_wiener(const YV12_B
           << AV1_PROB_COST_SHIFT;
       memcpy(&ref_wiener_info, &rsi[plane].wiener_info[tile_idx],
              sizeof(ref_wiener_info));
     }
     rsi[plane].restoration_type[tile_idx] = type[tile_idx];
   }
   err = try_restoration_frame(src, cpi, rsi, 1 << plane, partial_frame,
                               dst_frame);
-  cost_wiener = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
+  cost_wiener = RDCOST_DBL(x->rdmult, (bits >> 4), err);
 
   return cost_wiener;
 }
 
 static double search_norestore(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi,
                                int partial_frame, int plane,
                                RestorationInfo *info, RestorationType *type,
                                double *best_tile_cost,
@@ -1128,18 +1128,18 @@ static double search_norestore(const YV1
   double cost_norestore;
   int bits;
   MACROBLOCK *x = &cpi->td.mb;
   AV1_COMMON *const cm = &cpi->common;
   int tile_idx, tile_width, tile_height, nhtiles, nvtiles;
   int h_start, h_end, v_start, v_end;
   int width, height;
   if (plane == AOM_PLANE_Y) {
-    width = cm->width;
-    height = cm->height;
+    width = src->y_crop_width;
+    height = src->y_crop_height;
   } else {
     width = src->uv_crop_width;
     height = src->uv_crop_height;
   }
   const int ntiles = av1_get_rest_ntiles(
       width, height, cm->rst_info[plane].restoration_tilesize, &tile_width,
       &tile_height, &nhtiles, &nvtiles);
   (void)info;
@@ -1155,68 +1155,70 @@ static double search_norestore(const YV1
                                h_end - h_start, v_start, v_end - v_start,
                                1 << plane);
     type[tile_idx] = RESTORE_NONE;
     best_tile_cost[tile_idx] = err;
   }
   // RD cost associated with no restoration
   err = sse_restoration_frame(cm, src, cm->frame_to_show, (1 << plane));
   bits = frame_level_restore_bits[RESTORE_NONE] << AV1_PROB_COST_SHIFT;
-  cost_norestore = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
+  cost_norestore = RDCOST_DBL(x->rdmult, (bits >> 4), err);
   return cost_norestore;
 }
 
 static double search_switchable_restoration(
-    AV1_COMP *cpi, int partial_frame, int plane, RestorationInfo *rsi,
-    double *tile_cost[RESTORE_SWITCHABLE_TYPES]) {
+    const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi, int partial_frame, int plane,
+    RestorationType *const restore_types[RESTORE_SWITCHABLE_TYPES],
+    double *const tile_cost[RESTORE_SWITCHABLE_TYPES], RestorationInfo *rsi) {
   AV1_COMMON *const cm = &cpi->common;
   MACROBLOCK *x = &cpi->td.mb;
   double cost_switchable = 0;
   int bits, tile_idx;
   RestorationType r;
   int width, height;
   if (plane == AOM_PLANE_Y) {
-    width = cm->width;
-    height = cm->height;
+    width = src->y_crop_width;
+    height = src->y_crop_height;
   } else {
-    width = ROUND_POWER_OF_TWO(cm->width, cm->subsampling_x);
-    height = ROUND_POWER_OF_TWO(cm->height, cm->subsampling_y);
+    width = src->uv_crop_width;
+    height = src->uv_crop_height;
   }
   const int ntiles = av1_get_rest_ntiles(
       width, height, cm->rst_info[plane].restoration_tilesize, NULL, NULL, NULL,
       NULL);
   SgrprojInfo ref_sgrproj_info;
   set_default_sgrproj(&ref_sgrproj_info);
   WienerInfo ref_wiener_info;
   set_default_wiener(&ref_wiener_info);
   (void)partial_frame;
 
   rsi->frame_restoration_type = RESTORE_SWITCHABLE;
   bits = frame_level_restore_bits[rsi->frame_restoration_type]
          << AV1_PROB_COST_SHIFT;
-  cost_switchable = RDCOST_DBL(x->rdmult, x->rddiv, bits >> 4, 0);
+  cost_switchable = RDCOST_DBL(x->rdmult, bits >> 4, 0);
   for (tile_idx = 0; tile_idx < ntiles; ++tile_idx) {
-    double best_cost = RDCOST_DBL(
-        x->rdmult, x->rddiv, (cpi->switchable_restore_cost[RESTORE_NONE] >> 4),
-        tile_cost[RESTORE_NONE][tile_idx]);
+    double best_cost =
+        RDCOST_DBL(x->rdmult, (cpi->switchable_restore_cost[RESTORE_NONE] >> 4),
+                   tile_cost[RESTORE_NONE][tile_idx]);
     rsi->restoration_type[tile_idx] = RESTORE_NONE;
     for (r = 1; r < RESTORE_SWITCHABLE_TYPES; r++) {
       if (force_restore_type != 0)
         if (r != force_restore_type) continue;
       int tilebits = 0;
+      if (restore_types[r][tile_idx] != r) continue;
       if (r == RESTORE_WIENER)
         tilebits +=
             count_wiener_bits(&rsi->wiener_info[tile_idx], &ref_wiener_info);
       else if (r == RESTORE_SGRPROJ)
         tilebits +=
             count_sgrproj_bits(&rsi->sgrproj_info[tile_idx], &ref_sgrproj_info);
       tilebits <<= AV1_PROB_COST_SHIFT;
       tilebits += cpi->switchable_restore_cost[r];
-      double cost = RDCOST_DBL(x->rdmult, x->rddiv, tilebits >> 4,
-                               tile_cost[r][tile_idx]);
+      double cost =
+          RDCOST_DBL(x->rdmult, tilebits >> 4, tile_cost[r][tile_idx]);
 
       if (cost < best_cost) {
         rsi->restoration_type[tile_idx] = r;
         best_cost = cost;
       }
     }
     if (rsi->restoration_type[tile_idx] == RESTORE_WIENER)
       memcpy(&ref_wiener_info, &rsi->wiener_info[tile_idx],
@@ -1238,24 +1240,27 @@ void av1_pick_filter_restoration(const Y
     search_norestore, search_wiener, search_sgrproj,
   };
   AV1_COMMON *const cm = &cpi->common;
   double cost_restore[RESTORE_TYPES];
   double *tile_cost[RESTORE_SWITCHABLE_TYPES];
   RestorationType *restore_types[RESTORE_SWITCHABLE_TYPES];
   double best_cost_restore;
   RestorationType r, best_restore;
+  const int ywidth = src->y_crop_width;
+  const int yheight = src->y_crop_height;
+  const int uvwidth = src->uv_crop_width;
+  const int uvheight = src->uv_crop_height;
 
-  const int ntiles_y = av1_get_rest_ntiles(cm->width, cm->height,
-                                           cm->rst_info[0].restoration_tilesize,
-                                           NULL, NULL, NULL, NULL);
+  const int ntiles_y =
+      av1_get_rest_ntiles(ywidth, yheight, cm->rst_info[0].restoration_tilesize,
+                          NULL, NULL, NULL, NULL);
   const int ntiles_uv = av1_get_rest_ntiles(
-      ROUND_POWER_OF_TWO(cm->width, cm->subsampling_x),
-      ROUND_POWER_OF_TWO(cm->height, cm->subsampling_y),
-      cm->rst_info[1].restoration_tilesize, NULL, NULL, NULL, NULL);
+      uvwidth, uvheight, cm->rst_info[1].restoration_tilesize, NULL, NULL, NULL,
+      NULL);
 
   // Assume ntiles_uv is never larger that ntiles_y and so the same arrays work.
   for (r = 0; r < RESTORE_SWITCHABLE_TYPES; r++) {
     tile_cost[r] = (double *)aom_malloc(sizeof(*tile_cost[0]) * ntiles_y);
     restore_types[r] =
         (RestorationType *)aom_malloc(sizeof(*restore_types[0]) * ntiles_y);
   }
 
@@ -1265,19 +1270,19 @@ void av1_pick_filter_restoration(const Y
       if (force_restore_type != 0)
         if (r != RESTORE_NONE && r != force_restore_type) continue;
       cost_restore[r] =
           search_restore_fun[r](src, cpi, method == LPF_PICK_FROM_SUBIMAGE,
                                 plane, &cm->rst_info[plane], restore_types[r],
                                 tile_cost[r], &cpi->trial_frame_rst);
     }
     if (plane == AOM_PLANE_Y)
-      cost_restore[RESTORE_SWITCHABLE] =
-          search_switchable_restoration(cpi, method == LPF_PICK_FROM_SUBIMAGE,
-                                        plane, &cm->rst_info[plane], tile_cost);
+      cost_restore[RESTORE_SWITCHABLE] = search_switchable_restoration(
+          src, cpi, method == LPF_PICK_FROM_SUBIMAGE, plane, restore_types,
+          tile_cost, &cm->rst_info[plane]);
     else
       cost_restore[RESTORE_SWITCHABLE] = DBL_MAX;
     best_cost_restore = DBL_MAX;
     best_restore = 0;
     for (r = 0; r < RESTORE_TYPES; ++r) {
       if (force_restore_type != 0)
         if (r != RESTORE_NONE && r != force_restore_type) continue;
       if (cost_restore[r] < best_cost_restore) {
--- a/third_party/aom/av1/encoder/ransac.c
+++ b/third_party/aom/av1/encoder/ransac.c
@@ -134,16 +134,18 @@ static void project_points_double_homogr
 }
 
 static void normalize_homography(double *pts, int n, double *T) {
   double *p = pts;
   double mean[2] = { 0, 0 };
   double msqe = 0;
   double scale;
   int i;
+
+  assert(n > 0);
   for (i = 0; i < n; ++i, p += 2) {
     mean[0] += p[0];
     mean[1] += p[1];
   }
   mean[0] /= n;
   mean[1] /= n;
   for (p = pts, i = 0; i < n; ++i, p += 2) {
     p[0] -= mean[0];
@@ -816,23 +818,25 @@ static int ransac(const int *matched_poi
     trial_count++;
   }
 
   // Sort the motions, best first.
   qsort(motions, num_desired_motions, sizeof(RANSAC_MOTION), compare_motions);
 
   // Recompute the motions using only the inliers.
   for (i = 0; i < num_desired_motions; ++i) {
-    copy_points_at_indices(points1, corners1, motions[i].inlier_indices,
-                           motions[i].num_inliers);
-    copy_points_at_indices(points2, corners2, motions[i].inlier_indices,
-                           motions[i].num_inliers);
+    if (motions[i].num_inliers >= minpts) {
+      copy_points_at_indices(points1, corners1, motions[i].inlier_indices,
+                             motions[i].num_inliers);
+      copy_points_at_indices(points2, corners2, motions[i].inlier_indices,
+                             motions[i].num_inliers);
 
-    find_transformation(motions[i].num_inliers, points1, points2,
-                        params_by_motion + (MAX_PARAMDIM - 1) * i);
+      find_transformation(motions[i].num_inliers, points1, points2,
+                          params_by_motion + (MAX_PARAMDIM - 1) * i);
+    }
     num_inliers_by_motion[i] = motions[i].num_inliers;
   }
 
 finish_ransac:
   aom_free(points1);
   aom_free(points2);
   aom_free(corners1);
   aom_free(corners2);
--- a/third_party/aom/av1/encoder/ratectrl.c
+++ b/third_party/aom/av1/encoder/ratectrl.c
@@ -89,18 +89,18 @@ static int rtc_minq_12[QINDEX_RANGE];
 #endif
 
 static int gf_high = 2000;
 static int gf_low = 400;
 static int kf_high = 5000;
 static int kf_low = 400;
 
 double av1_resize_rate_factor(const AV1_COMP *cpi) {
-  return (double)(cpi->resize_scale_den * cpi->resize_scale_den) /
-         (cpi->resize_scale_num * cpi->resize_scale_num);
+  return (double)(cpi->oxcf.width * cpi->oxcf.height) /
+         (cpi->common.width * cpi->common.height);
 }
 
 // Functions to compute the active minq lookup table entries based on a
 // formulaic approach to facilitate easier adjustment of the Q tables.
 // The formulae were derived from computing a 3rd order polynomial best
 // fit to the original data (after plotting real maxq vs minq (not q index))
 static int get_minq_index(double maxq, double x3, double x2, double x1,
                           aom_bit_depth_t bit_depth) {
@@ -1076,17 +1076,17 @@ static int rc_pick_q_and_bounds_two_pass
       (cpi->twopass.last_kfgroup_zeromotion_pct < STATIC_MOTION_THRESH)) {
     int qdelta = av1_frame_type_qdelta(cpi, gf_group->rf_level[gf_group->index],
                                        active_worst_quality);
     active_worst_quality =
         AOMMAX(active_worst_quality + qdelta, active_best_quality);
   }
 
   // Modify active_best_quality for downscaled normal frames.
-  if (!av1_resize_unscaled(cpi) && !frame_is_kf_gf_arf(cpi)) {
+  if (!av1_frame_unscaled(cm) && !frame_is_kf_gf_arf(cpi)) {
     int qdelta = av1_compute_qdelta_by_rate(
         rc, cm->frame_type, active_best_quality, 2.0, cm->bit_depth);
     active_best_quality =
         AOMMAX(active_best_quality + qdelta, rc->best_quality);
   }
 
   active_best_quality =
       clamp(active_best_quality, rc->best_quality, rc->worst_quality);
@@ -1159,17 +1159,17 @@ void av1_rc_compute_frame_size_bounds(co
 
 void av1_rc_set_frame_target(AV1_COMP *cpi, int target) {
   const AV1_COMMON *const cm = &cpi->common;
   RATE_CONTROL *const rc = &cpi->rc;
 
   rc->this_frame_target = target;
 
   // Modify frame size target when down-scaled.
-  if (cpi->oxcf.resize_mode == RESIZE_DYNAMIC && !av1_resize_unscaled(cpi))
+  if (!av1_frame_unscaled(cm))
     rc->this_frame_target =
         (int)(rc->this_frame_target * av1_resize_rate_factor(cpi));
 
   // Target rate per SB64 (including partial SB64s.
   rc->sb64_target_rate = (int)((int64_t)rc->this_frame_target * 64 * 64) /
                          (cm->width * cm->height);
 }
 
@@ -1658,8 +1658,69 @@ void av1_set_target_rate(AV1_COMP *cpi) 
   RATE_CONTROL *const rc = &cpi->rc;
   int target_rate = rc->base_frame_target;
 
   // Correction to rate target based on prior over or under shoot.
   if (cpi->oxcf.rc_mode == AOM_VBR || cpi->oxcf.rc_mode == AOM_CQ)
     vbr_rate_correction(cpi, &target_rate);
   av1_rc_set_frame_target(cpi, target_rate);
 }
+
+static unsigned int lcg_rand16(unsigned int *state) {
+  *state = (unsigned int)(*state * 1103515245ULL + 12345);
+  return *state / 65536 % 32768;
+}
+
+uint8_t av1_calculate_next_resize_scale(const AV1_COMP *cpi) {
+  static unsigned int seed = 56789;
+  const AV1EncoderConfig *oxcf = &cpi->oxcf;
+  if (oxcf->pass == 1) return SCALE_DENOMINATOR;
+  uint8_t new_num = SCALE_DENOMINATOR;
+
+  switch (oxcf->resize_mode) {
+    case RESIZE_NONE: new_num = SCALE_DENOMINATOR; break;
+    case RESIZE_FIXED:
+      if (cpi->common.frame_type == KEY_FRAME)
+        new_num = oxcf->resize_kf_scale_numerator;
+      else
+        new_num = oxcf->resize_scale_numerator;
+      break;
+    case RESIZE_DYNAMIC:
+      // RESIZE_DYNAMIC: Just random for now.
+      new_num = lcg_rand16(&seed) % 4 + 13;
+      break;
+    default: assert(0);
+  }
+  return new_num;
+}
+
+#if CONFIG_FRAME_SUPERRES
+// TODO(afergs): Rename av1_rc_update_superres_scale(...)?
+uint8_t av1_calculate_next_superres_scale(const AV1_COMP *cpi, int width,
+                                          int height) {
+  static unsigned int seed = 34567;
+  const AV1EncoderConfig *oxcf = &cpi->oxcf;
+  if (oxcf->pass == 1) return SCALE_DENOMINATOR;
+  uint8_t new_num = SCALE_DENOMINATOR;
+
+  switch (oxcf->superres_mode) {
+    case SUPERRES_NONE: new_num = SCALE_DENOMINATOR; break;
+    case SUPERRES_FIXED:
+      if (cpi->common.frame_type == KEY_FRAME)
+        new_num = oxcf->superres_kf_scale_numerator;
+      else
+        new_num = oxcf->superres_scale_numerator;
+      break;
+    case SUPERRES_DYNAMIC:
+      // SUPERRES_DYNAMIC: Just random for now.
+      new_num = lcg_rand16(&seed) % 9 + 8;
+      break;
+    default: assert(0);
+  }
+
+  // Make sure overall reduction is no more than 1/2 of the source size.
+  av1_calculate_scaled_size(&width, &height, new_num);
+  if (width * 2 < oxcf->width || height * 2 < oxcf->height)
+    new_num = SCALE_DENOMINATOR;
+
+  return new_num;
+}
+#endif  // CONFIG_FRAME_SUPERRES
--- a/third_party/aom/av1/encoder/ratectrl.h
+++ b/third_party/aom/av1/encoder/ratectrl.h
@@ -251,13 +251,18 @@ void av1_rc_update_framerate(struct AV1_
 
 void av1_rc_set_gf_interval_range(const struct AV1_COMP *const cpi,
                                   RATE_CONTROL *const rc);
 
 void av1_set_target_rate(struct AV1_COMP *cpi);
 
 int av1_resize_one_pass_cbr(struct AV1_COMP *cpi);
 
+uint8_t av1_calculate_next_resize_scale(const struct AV1_COMP *cpi);
+#if CONFIG_FRAME_SUPERRES
+uint8_t av1_calculate_next_superres_scale(const struct AV1_COMP *cpi, int width,
+                                          int height);
+#endif  // CONFIG_FRAME_SUPERRES
 #ifdef __cplusplus
 }  // extern "C"
 #endif
 
 #endif  // AV1_ENCODER_RATECTRL_H_
--- a/third_party/aom/av1/encoder/rd.c
+++ b/third_party/aom/av1/encoder/rd.c
@@ -46,41 +46,56 @@
 // Factor to weigh the rate for switchable interp filters.
 #define SWITCHABLE_INTERP_RATE_FACTOR 1
 
 // The baseline rd thresholds for breaking out of the rd loop for
 // certain modes are assumed to be based on 8x8 blocks.
 // This table is used to correct for block size.
 // The factors here are << 2 (2 = x0.5, 32 = x8 etc).
 static const uint8_t rd_thresh_block_size_factor[BLOCK_SIZES] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   2,  2,  2,
 #endif
   2,  3,  3, 4, 6, 6, 8, 12, 12, 16, 24, 24, 32,
 #if CONFIG_EXT_PARTITION
   48, 48, 64
 #endif  // CONFIG_EXT_PARTITION
 };
 
 static void fill_mode_costs(AV1_COMP *cpi) {
   const FRAME_CONTEXT *const fc = cpi->common.fc;
   int i, j;
 
   for (i = 0; i < INTRA_MODES; ++i)
     for (j = 0; j < INTRA_MODES; ++j)
+#if CONFIG_EC_ADAPT
+      av1_cost_tokens_from_cdf(cpi->y_mode_costs[i][j], av1_kf_y_mode_cdf[i][j],
+                               av1_intra_mode_inv);
+#else
       av1_cost_tokens(cpi->y_mode_costs[i][j], av1_kf_y_mode_prob[i][j],
                       av1_intra_mode_tree);
+#endif
 
   for (i = 0; i < BLOCK_SIZE_GROUPS; ++i)
+#if CONFIG_EC_ADAPT
+    av1_cost_tokens_from_cdf(cpi->mbmode_cost[i], fc->y_mode_cdf[i],
+                             av1_intra_mode_inv);
+#else
     av1_cost_tokens(cpi->mbmode_cost[i], fc->y_mode_prob[i],
                     av1_intra_mode_tree);
+#endif
 
   for (i = 0; i < INTRA_MODES; ++i)
+#if CONFIG_EC_ADAPT
+    av1_cost_tokens_from_cdf(cpi->intra_uv_mode_cost[i], fc->uv_mode_cdf[i],
+                             av1_intra_mode_inv);
+#else
     av1_cost_tokens(cpi->intra_uv_mode_cost[i], fc->uv_mode_prob[i],
                     av1_intra_mode_tree);
+#endif
 
   for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i)
     av1_cost_tokens(cpi->switchable_interp_costs[i],
                     fc->switchable_interp_prob[i], av1_switchable_interp_tree);
 
 #if CONFIG_PALETTE
   for (i = 0; i < PALETTE_BLOCK_SIZES; ++i) {
     av1_cost_tokens(cpi->palette_y_size_cost[i],
@@ -142,18 +157,19 @@ static void fill_mode_costs(AV1_COMP *cp
                     av1_intra_filter_tree);
 #endif  // CONFIG_INTRA_INTERP
 #endif  // CONFIG_EXT_INTRA
 #if CONFIG_LOOP_RESTORATION
   av1_cost_tokens(cpi->switchable_restore_cost, fc->switchable_restore_prob,
                   av1_switchable_restore_tree);
 #endif  // CONFIG_LOOP_RESTORATION
 #if CONFIG_GLOBAL_MOTION
-  av1_cost_tokens(cpi->gmtype_cost, fc->global_motion_types_prob,
-                  av1_global_motion_types_tree);
+  for (i = 0; i < TRANS_TYPES; ++i)
+    cpi->gmtype_cost[i] = (1 + (i > 0 ? GLOBAL_TYPE_BITS : 0))
+                          << AV1_PROB_COST_SHIFT;
 #endif  // CONFIG_GLOBAL_MOTION
 }
 
 void av1_fill_token_costs(av1_coeff_cost *c,
                           av1_coeff_probs_model (*p)[PLANE_TYPES]) {
   int i, j, k, l;
   TX_SIZE t;
   for (t = 0; t < TX_SIZES; ++t)
@@ -345,33 +361,42 @@ void av1_initialize_rd_consts(AV1_COMP *
   AV1_COMMON *const cm = &cpi->common;
   MACROBLOCK *const x = &cpi->td.mb;
   RD_OPT *const rd = &cpi->rd;
   int i;
   int nmv_ctx;
 
   aom_clear_system_state();
 
-  rd->RDDIV = RDDIV_BITS;  // In bits (to multiply D by 128).
   rd->RDMULT = av1_compute_rd_mult(cpi, cm->base_qindex + cm->y_dc_delta_q);
 
   set_error_per_bit(x, rd->RDMULT);
 
   set_block_thresholds(cm, rd);
 
   for (nmv_ctx = 0; nmv_ctx < NMV_CONTEXTS; ++nmv_ctx) {
     av1_build_nmv_cost_table(
         x->nmv_vec_cost[nmv_ctx],
         cm->allow_high_precision_mv ? x->nmvcost_hp[nmv_ctx]
                                     : x->nmvcost[nmv_ctx],
         &cm->fc->nmvc[nmv_ctx], cm->allow_high_precision_mv);
   }
   x->mvcost = x->mv_cost_stack[0];
   x->nmvjointcost = x->nmv_vec_cost[0];
 
+#if CONFIG_INTRABC
+  if (frame_is_intra_only(cm) && cm->allow_screen_content_tools &&
+      cpi->oxcf.pass != 1) {
+    av1_build_nmv_cost_table(
+        x->nmv_vec_cost[0],
+        cm->allow_high_precision_mv ? x->nmvcost_hp[0] : x->nmvcost[0],
+        &cm->fc->ndvc, MV_SUBPEL_NONE);
+  }
+#endif
+
   if (cpi->oxcf.pass != 1) {
     av1_fill_token_costs(x->token_costs, cm->fc->coef_probs);
 
     if (cm->frame_type == KEY_FRAME) {
 #if CONFIG_EXT_PARTITION_TYPES
       for (i = 0; i < PARTITION_PLOFFSET; ++i)
         av1_cost_tokens(cpi->partition_cost[i], cm->fc->partition_prob[i],
                         av1_partition_tree);
@@ -429,16 +454,22 @@ void av1_initialize_rd_consts(AV1_COMP *
         cpi->drl_mode_cost0[i][0] = av1_cost_bit(cm->fc->drl_prob[i], 0);
         cpi->drl_mode_cost0[i][1] = av1_cost_bit(cm->fc->drl_prob[i], 1);
       }
 #if CONFIG_EXT_INTER
       for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
         av1_cost_tokens((int *)cpi->inter_compound_mode_cost[i],
                         cm->fc->inter_compound_mode_probs[i],
                         av1_inter_compound_mode_tree);
+#if CONFIG_COMPOUND_SINGLEREF
+      for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
+        av1_cost_tokens((int *)cpi->inter_singleref_comp_mode_cost[i],
+                        cm->fc->inter_singleref_comp_mode_probs[i],
+                        av1_inter_singleref_comp_mode_tree);
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_INTERINTRA
       for (i = 0; i < BLOCK_SIZE_GROUPS; ++i)
         av1_cost_tokens((int *)cpi->interintra_mode_cost[i],
                         cm->fc->interintra_mode_prob[i],
                         av1_interintra_mode_tree);
 #endif  // CONFIG_INTERINTRA
 #endif  // CONFIG_EXT_INTER
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
@@ -776,17 +807,17 @@ static void get_entropy_contexts_plane(
     default: assert(0 && "Invalid transform size."); break;
   }
 }
 
 void av1_get_entropy_contexts(BLOCK_SIZE bsize, TX_SIZE tx_size,
                               const struct macroblockd_plane *pd,
                               ENTROPY_CONTEXT t_above[2 * MAX_MIB_SIZE],
                               ENTROPY_CONTEXT t_left[2 * MAX_MIB_SIZE]) {
-#if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2
+#if CONFIG_CHROMA_SUB8X8
   const BLOCK_SIZE plane_bsize =
       AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
 #else
   const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
 #endif
   get_entropy_contexts_plane(plane_bsize, tx_size, pd, t_above, t_left);
 }
 
@@ -978,42 +1009,101 @@ void av1_set_rd_speed_thresholds(AV1_COM
 #endif  // CONFIG_EXT_REFS
   rd->thresh_mult[THR_ZEROG] += 2000;
   rd->thresh_mult[THR_ZEROA] += 2000;
 
   rd->thresh_mult[THR_TM] += 1000;
 
 #if CONFIG_EXT_INTER
 
+#if CONFIG_COMPOUND_SINGLEREF
+  rd->thresh_mult[THR_SR_NEAREST_NEARMV] += 1200;
+#if CONFIG_EXT_REFS
+  rd->thresh_mult[THR_SR_NEAREST_NEARL2] += 1200;
+  rd->thresh_mult[THR_SR_NEAREST_NEARL3] += 1200;
+  rd->thresh_mult[THR_SR_NEAREST_NEARB] += 1200;
+#endif  // CONFIG_EXT_REFS
+  rd->thresh_mult[THR_SR_NEAREST_NEARA] += 1200;
+  rd->thresh_mult[THR_SR_NEAREST_NEARG] += 1200;
+
+  /*
+  rd->thresh_mult[THR_SR_NEAREST_NEWMV] += 1200;
+#if CONFIG_EXT_REFS
+  rd->thresh_mult[THR_SR_NEAREST_NEWL2] += 1200;
+  rd->thresh_mult[THR_SR_NEAREST_NEWL3] += 1200;
+  rd->thresh_mult[THR_SR_NEAREST_NEWB] += 1200;
+#endif  // CONFIG_EXT_REFS
+  rd->thresh_mult[THR_SR_NEAREST_NEWA] += 1200;
+  rd->thresh_mult[THR_SR_NEAREST_NEWG] += 1200;*/
+
+  rd->thresh_mult[THR_SR_NEAR_NEWMV] += 1500;
+#if CONFIG_EXT_REFS
+  rd->thresh_mult[THR_SR_NEAR_NEWL2] += 1500;
+  rd->thresh_mult[THR_SR_NEAR_NEWL3] += 1500;
+  rd->thresh_mult[THR_SR_NEAR_NEWB] += 1500;
+#endif  // CONFIG_EXT_REFS
+  rd->thresh_mult[THR_SR_NEAR_NEWA] += 1500;
+  rd->thresh_mult[THR_SR_NEAR_NEWG] += 1500;
+
+  rd->thresh_mult[THR_SR_ZERO_NEWMV] += 2000;
+#if CONFIG_EXT_REFS
+  rd->thresh_mult[THR_SR_ZERO_NEWL2] += 2000;
+  rd->thresh_mult[THR_SR_ZERO_NEWL3] += 2000;
+  rd->thresh_mult[THR_SR_ZERO_NEWB] += 2000;
+#endif  // CONFIG_EXT_REFS
+  rd->thresh_mult[THR_SR_ZERO_NEWA] += 2000;
+  rd->thresh_mult[THR_SR_ZERO_NEWG] += 2000;
+
+  rd->thresh_mult[THR_SR_NEW_NEWMV] += 1700;
+#if CONFIG_EXT_REFS
+  rd->thresh_mult[THR_SR_NEW_NEWL2] += 1700;
+  rd->thresh_mult[THR_SR_NEW_NEWL3] += 1700;
+  rd->thresh_mult[THR_SR_NEW_NEWB] += 1700;
+#endif  // CONFIG_EXT_REFS
+  rd->thresh_mult[THR_SR_NEW_NEWA] += 1700;
+  rd->thresh_mult[THR_SR_NEW_NEWG] += 1700;
+#endif  // CONFIG_COMPOUND_SINGLEREF
+
   rd->thresh_mult[THR_COMP_NEAREST_NEARESTLA] += 1000;
 #if CONFIG_EXT_REFS
   rd->thresh_mult[THR_COMP_NEAREST_NEARESTL2A] += 1000;
   rd->thresh_mult[THR_COMP_NEAREST_NEARESTL3A] += 1000;
 #endif  // CONFIG_EXT_REFS
   rd->thresh_mult[THR_COMP_NEAREST_NEARESTGA] += 1000;
 #if CONFIG_EXT_REFS
   rd->thresh_mult[THR_COMP_NEAREST_NEARESTLB] += 1000;
   rd->thresh_mult[THR_COMP_NEAREST_NEARESTL2B] += 1000;
   rd->thresh_mult[THR_COMP_NEAREST_NEARESTL3B] += 1000;
   rd->thresh_mult[THR_COMP_NEAREST_NEARESTGB] += 1000;
+
+#if CONFIG_EXT_COMP_REFS
+  rd->thresh_mult[THR_COMP_NEAREST_NEARESTLL2] += 1000;
+  rd->thresh_mult[THR_COMP_NEAREST_NEARESTLG] += 1000;
+  rd->thresh_mult[THR_COMP_NEAREST_NEARESTBA] += 1000;
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
 #else  // CONFIG_EXT_INTER
 
   rd->thresh_mult[THR_COMP_NEARESTLA] += 1000;
 #if CONFIG_EXT_REFS
   rd->thresh_mult[THR_COMP_NEARESTL2A] += 1000;
   rd->thresh_mult[THR_COMP_NEARESTL3A] += 1000;
 #endif  // CONFIG_EXT_REFS
   rd->thresh_mult[THR_COMP_NEARESTGA] += 1000;
 #if CONFIG_EXT_REFS
   rd->thresh_mult[THR_COMP_NEARESTLB] += 1000;
   rd->thresh_mult[THR_COMP_NEARESTL2B] += 1000;
   rd->thresh_mult[THR_COMP_NEARESTL3B] += 1000;
   rd->thresh_mult[THR_COMP_NEARESTGB] += 1000;
+#if CONFIG_EXT_COMP_REFS
+  rd->thresh_mult[THR_COMP_NEARESTLL2] += 1000;
+  rd->thresh_mult[THR_COMP_NEARESTLG] += 1000;
+  rd->thresh_mult[THR_COMP_NEARESTBA] += 1000;
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
 #endif  // CONFIG_EXT_INTER
 
 #if CONFIG_EXT_INTER
 
   rd->thresh_mult[THR_COMP_NEAR_NEARLA] += 1200;
   rd->thresh_mult[THR_COMP_NEAREST_NEWLA] += 1500;
@@ -1076,16 +1166,48 @@ void av1_set_rd_speed_thresholds(AV1_COM
 
   rd->thresh_mult[THR_COMP_NEAR_NEARGB] += 1200;
   rd->thresh_mult[THR_COMP_NEAREST_NEWGB] += 1500;
   rd->thresh_mult[THR_COMP_NEW_NEARESTGB] += 1500;
   rd->thresh_mult[THR_COMP_NEAR_NEWGB] += 1700;
   rd->thresh_mult[THR_COMP_NEW_NEARGB] += 1700;
   rd->thresh_mult[THR_COMP_NEW_NEWGB] += 2000;
   rd->thresh_mult[THR_COMP_ZERO_ZEROGB] += 2500;
+
+#if CONFIG_EXT_COMP_REFS
+  rd->thresh_mult[THR_COMP_NEAREST_NEARLL2] += 1200;
+  rd->thresh_mult[THR_COMP_NEAR_NEARESTLL2] += 1200;
+  rd->thresh_mult[THR_COMP_NEAR_NEARLL2] += 1200;
+  rd->thresh_mult[THR_COMP_NEAREST_NEWLL2] += 1500;
+  rd->thresh_mult[THR_COMP_NEW_NEARESTLL2] += 1500;
+  rd->thresh_mult[THR_COMP_NEAR_NEWLL2] += 1700;
+  rd->thresh_mult[THR_COMP_NEW_NEARLL2] += 1700;
+  rd->thresh_mult[THR_COMP_NEW_NEWLL2] += 2000;
+  rd->thresh_mult[THR_COMP_ZERO_ZEROLL2] += 2500;
+
+  rd->thresh_mult[THR_COMP_NEAREST_NEARLG] += 1200;
+  rd->thresh_mult[THR_COMP_NEAR_NEARESTLG] += 1200;
+  rd->thresh_mult[THR_COMP_NEAR_NEARLG] += 1200;
+  rd->thresh_mult[THR_COMP_NEAREST_NEWLG] += 1500;
+  rd->thresh_mult[THR_COMP_NEW_NEARESTLG] += 1500;
+  rd->thresh_mult[THR_COMP_NEAR_NEWLG] += 1700;
+  rd->thresh_mult[THR_COMP_NEW_NEARLG] += 1700;
+  rd->thresh_mult[THR_COMP_NEW_NEWLG] += 2000;
+  rd->thresh_mult[THR_COMP_ZERO_ZEROLG] += 2500;
+
+  rd->thresh_mult[THR_COMP_NEAREST_NEARBA] += 1200;
+  rd->thresh_mult[THR_COMP_NEAR_NEARESTBA] += 1200;
+  rd->thresh_mult[THR_COMP_NEAR_NEARBA] += 1200;
+  rd->thresh_mult[THR_COMP_NEAREST_NEWBA] += 1500;
+  rd->thresh_mult[THR_COMP_NEW_NEARESTBA] += 1500;
+  rd->thresh_mult[THR_COMP_NEAR_NEWBA] += 1700;
+  rd->thresh_mult[THR_COMP_NEW_NEARBA] += 1700;
+  rd->thresh_mult[THR_COMP_NEW_NEWBA] += 2000;
+  rd->thresh_mult[THR_COMP_ZERO_ZEROBA] += 2500;
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
 #else  // CONFIG_EXT_INTER
 
   rd->thresh_mult[THR_COMP_NEARLA] += 1500;
   rd->thresh_mult[THR_COMP_NEWLA] += 2000;
 #if CONFIG_EXT_REFS
   rd->thresh_mult[THR_COMP_NEARL2A] += 1500;
@@ -1100,30 +1222,45 @@ void av1_set_rd_speed_thresholds(AV1_COM
   rd->thresh_mult[THR_COMP_NEARLB] += 1500;
   rd->thresh_mult[THR_COMP_NEWLB] += 2000;
   rd->thresh_mult[THR_COMP_NEARL2B] += 1500;
   rd->thresh_mult[THR_COMP_NEWL2B] += 2000;
   rd->thresh_mult[THR_COMP_NEARL3B] += 1500;
   rd->thresh_mult[THR_COMP_NEWL3B] += 2000;
   rd->thresh_mult[THR_COMP_NEARGB] += 1500;
   rd->thresh_mult[THR_COMP_NEWGB] += 2000;
+
+#if CONFIG_EXT_COMP_REFS
+  rd->thresh_mult[THR_COMP_NEARLL2] += 1500;
+  rd->thresh_mult[THR_COMP_NEWLL2] += 2000;
+  rd->thresh_mult[THR_COMP_NEARLG] += 1500;
+  rd->thresh_mult[THR_COMP_NEWLG] += 2000;
+  rd->thresh_mult[THR_COMP_NEARBA] += 1500;
+  rd->thresh_mult[THR_COMP_NEWBA] += 2000;
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
   rd->thresh_mult[THR_COMP_ZEROLA] += 2500;
 #if CONFIG_EXT_REFS
   rd->thresh_mult[THR_COMP_ZEROL2A] += 2500;
   rd->thresh_mult[THR_COMP_ZEROL3A] += 2500;
 #endif  // CONFIG_EXT_REFS
   rd->thresh_mult[THR_COMP_ZEROGA] += 2500;
 
 #if CONFIG_EXT_REFS
   rd->thresh_mult[THR_COMP_ZEROLB] += 2500;
   rd->thresh_mult[THR_COMP_ZEROL2B] += 2500;
   rd->thresh_mult[THR_COMP_ZEROL3B] += 2500;
   rd->thresh_mult[THR_COMP_ZEROGB] += 2500;
+
+#if CONFIG_EXT_COMP_REFS
+  rd->thresh_mult[THR_COMP_ZEROLL2] += 2500;
+  rd->thresh_mult[THR_COMP_ZEROLG] += 2500;
+  rd->thresh_mult[THR_COMP_ZEROBA] += 2500;
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
 #endif  // CONFIG_EXT_INTER
 
   rd->thresh_mult[THR_H_PRED] += 2000;
   rd->thresh_mult[THR_V_PRED] += 2000;
   rd->thresh_mult[THR_D135_PRED] += 2500;
   rd->thresh_mult[THR_D207_PRED] += 2500;
--- a/third_party/aom/av1/encoder/rd.h
+++ b/third_party/aom/av1/encoder/rd.h
@@ -25,22 +25,23 @@
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 #define RDDIV_BITS 7
 #define RD_EPB_SHIFT 6
 
-#define RDCOST(RM, DM, R, D) \
-  (ROUND_POWER_OF_TWO(((int64_t)R) * (RM), AV1_PROB_COST_SHIFT) + (D << DM))
+#define RDCOST(RM, R, D)                                          \
+  (ROUND_POWER_OF_TWO(((int64_t)R) * (RM), AV1_PROB_COST_SHIFT) + \
+   (D << RDDIV_BITS))
 
-#define RDCOST_DBL(RM, DM, R, D)                                   \
+#define RDCOST_DBL(RM, R, D)                                       \
   (((((double)(R)) * (RM)) / (double)(1 << AV1_PROB_COST_SHIFT)) + \
-   ((double)(D) * (1 << (DM))))
+   ((double)(D) * (1 << RDDIV_BITS)))
 
 #define QIDX_SKIP_THRESH 115
 
 #define MV_COST_WEIGHT 108
 #define MV_COST_WEIGHT_SUB 120
 
 #define INVALID_MV 0x80008000
 
@@ -91,140 +92,214 @@ typedef enum {
   THR_ZEROL3,
   THR_ZEROB,
 #endif  // CONFIG_EXT_REFS
   THR_ZEROG,
   THR_ZEROA,
 
 #if CONFIG_EXT_INTER
 
+#if CONFIG_COMPOUND_SINGLEREF
+  THR_SR_NEAREST_NEARMV,
+#if CONFIG_EXT_REFS
+  THR_SR_NEAREST_NEARL2,
+  THR_SR_NEAREST_NEARL3,
+  THR_SR_NEAREST_NEARB,
+#endif  // CONFIG_EXT_REFS
+  THR_SR_NEAREST_NEARG,
+  THR_SR_NEAREST_NEARA,
+
+  /*
+  THR_SR_NEAREST_NEWMV,
+#if CONFIG_EXT_REFS
+  THR_SR_NEAREST_NEWL2,
+  THR_SR_NEAREST_NEWL3,
+  THR_SR_NEAREST_NEWB,
+#endif  // CONFIG_EXT_REFS
+  THR_SR_NEAREST_NEWG,
+  THR_SR_NEAREST_NEWA,*/
+
+  THR_SR_NEAR_NEWMV,
+#if CONFIG_EXT_REFS
+  THR_SR_NEAR_NEWL2,
+  THR_SR_NEAR_NEWL3,
+  THR_SR_NEAR_NEWB,
+#endif  // CONFIG_EXT_REFS
+  THR_SR_NEAR_NEWG,
+  THR_SR_NEAR_NEWA,
+
+  THR_SR_ZERO_NEWMV,
+#if CONFIG_EXT_REFS
+  THR_SR_ZERO_NEWL2,
+  THR_SR_ZERO_NEWL3,
+  THR_SR_ZERO_NEWB,
+#endif  // CONFIG_EXT_REFS
+  THR_SR_ZERO_NEWG,
+  THR_SR_ZERO_NEWA,
+
+  THR_SR_NEW_NEWMV,
+#if CONFIG_EXT_REFS
+  THR_SR_NEW_NEWL2,
+  THR_SR_NEW_NEWL3,
+  THR_SR_NEW_NEWB,
+#endif  // CONFIG_EXT_REFS
+  THR_SR_NEW_NEWG,
+  THR_SR_NEW_NEWA,
+#endif  // CONFIG_COMPOUND_SINGLEREF
+
   THR_COMP_NEAREST_NEARESTLA,
 #if CONFIG_EXT_REFS
   THR_COMP_NEAREST_NEARESTL2A,
   THR_COMP_NEAREST_NEARESTL3A,
 #endif  // CONFIG_EXT_REFS
   THR_COMP_NEAREST_NEARESTGA,
 #if CONFIG_EXT_REFS
   THR_COMP_NEAREST_NEARESTLB,
   THR_COMP_NEAREST_NEARESTL2B,
   THR_COMP_NEAREST_NEARESTL3B,
   THR_COMP_NEAREST_NEARESTGB,
+#if CONFIG_EXT_COMP_REFS
+  THR_COMP_NEAREST_NEARESTLL2,
+  THR_COMP_NEAREST_NEARESTLG,
+  THR_COMP_NEAREST_NEARESTBA,
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
 #else  // CONFIG_EXT_INTER
 
   THR_COMP_NEARESTLA,
 #if CONFIG_EXT_REFS
   THR_COMP_NEARESTL2A,
   THR_COMP_NEARESTL3A,
 #endif  // CONFIG_EXT_REFS
   THR_COMP_NEARESTGA,
 #if CONFIG_EXT_REFS
   THR_COMP_NEARESTLB,
   THR_COMP_NEARESTL2B,
   THR_COMP_NEARESTL3B,
   THR_COMP_NEARESTGB,
+#if CONFIG_EXT_COMP_REFS
+  THR_COMP_NEARESTLL2,
+  THR_COMP_NEARESTLG,
+  THR_COMP_NEARESTBA,
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
 #endif  // CONFIG_EXT_INTER
 
   THR_TM,
 
 #if CONFIG_ALT_INTRA
   THR_SMOOTH,
 #if CONFIG_SMOOTH_HV
   THR_SMOOTH_V,
   THR_SMOOTH_H,
 #endif  // CONFIG_SMOOTH_HV
 #endif  // CONFIG_ALT_INTRA
 
 #if CONFIG_EXT_INTER
 
-  THR_COMP_NEAR_NEARESTLA,
-  THR_COMP_NEAREST_NEARLA,
   THR_COMP_NEAR_NEARLA,
   THR_COMP_NEW_NEARESTLA,
   THR_COMP_NEAREST_NEWLA,
   THR_COMP_NEW_NEARLA,
   THR_COMP_NEAR_NEWLA,
   THR_COMP_NEW_NEWLA,
   THR_COMP_ZERO_ZEROLA,
 
 #if CONFIG_EXT_REFS
-  THR_COMP_NEAR_NEARESTL2A,
-  THR_COMP_NEAREST_NEARL2A,
   THR_COMP_NEAR_NEARL2A,
   THR_COMP_NEW_NEARESTL2A,
   THR_COMP_NEAREST_NEWL2A,
   THR_COMP_NEW_NEARL2A,
   THR_COMP_NEAR_NEWL2A,
   THR_COMP_NEW_NEWL2A,
   THR_COMP_ZERO_ZEROL2A,
 
-  THR_COMP_NEAR_NEARESTL3A,
-  THR_COMP_NEAREST_NEARL3A,
   THR_COMP_NEAR_NEARL3A,
   THR_COMP_NEW_NEARESTL3A,
   THR_COMP_NEAREST_NEWL3A,
   THR_COMP_NEW_NEARL3A,
   THR_COMP_NEAR_NEWL3A,
   THR_COMP_NEW_NEWL3A,
   THR_COMP_ZERO_ZEROL3A,
 #endif  // CONFIG_EXT_REFS
 
-  THR_COMP_NEAR_NEARESTGA,
-  THR_COMP_NEAREST_NEARGA,
   THR_COMP_NEAR_NEARGA,
   THR_COMP_NEW_NEARESTGA,
   THR_COMP_NEAREST_NEWGA,
   THR_COMP_NEW_NEARGA,
   THR_COMP_NEAR_NEWGA,
   THR_COMP_NEW_NEWGA,
   THR_COMP_ZERO_ZEROGA,
 
 #if CONFIG_EXT_REFS
-  THR_COMP_NEAR_NEARESTLB,
-  THR_COMP_NEAREST_NEARLB,
   THR_COMP_NEAR_NEARLB,
   THR_COMP_NEW_NEARESTLB,
   THR_COMP_NEAREST_NEWLB,
   THR_COMP_NEW_NEARLB,
   THR_COMP_NEAR_NEWLB,
   THR_COMP_NEW_NEWLB,
   THR_COMP_ZERO_ZEROLB,
 
-  THR_COMP_NEAR_NEARESTL2B,
-  THR_COMP_NEAREST_NEARL2B,
   THR_COMP_NEAR_NEARL2B,
   THR_COMP_NEW_NEARESTL2B,
   THR_COMP_NEAREST_NEWL2B,
   THR_COMP_NEW_NEARL2B,
   THR_COMP_NEAR_NEWL2B,
   THR_COMP_NEW_NEWL2B,
   THR_COMP_ZERO_ZEROL2B,
 
-  THR_COMP_NEAR_NEARESTL3B,
-  THR_COMP_NEAREST_NEARL3B,
   THR_COMP_NEAR_NEARL3B,
   THR_COMP_NEW_NEARESTL3B,
   THR_COMP_NEAREST_NEWL3B,
   THR_COMP_NEW_NEARL3B,
   THR_COMP_NEAR_NEWL3B,
   THR_COMP_NEW_NEWL3B,
   THR_COMP_ZERO_ZEROL3B,
 
-  THR_COMP_NEAR_NEARESTGB,
-  THR_COMP_NEAREST_NEARGB,
   THR_COMP_NEAR_NEARGB,
   THR_COMP_NEW_NEARESTGB,
   THR_COMP_NEAREST_NEWGB,
   THR_COMP_NEW_NEARGB,
   THR_COMP_NEAR_NEWGB,
   THR_COMP_NEW_NEWGB,
   THR_COMP_ZERO_ZEROGB,
+
+#if CONFIG_EXT_COMP_REFS
+  THR_COMP_NEAR_NEARESTLL2,
+  THR_COMP_NEAREST_NEARLL2,
+  THR_COMP_NEAR_NEARLL2,
+  THR_COMP_NEW_NEARESTLL2,
+  THR_COMP_NEAREST_NEWLL2,
+  THR_COMP_NEW_NEARLL2,
+  THR_COMP_NEAR_NEWLL2,
+  THR_COMP_NEW_NEWLL2,
+  THR_COMP_ZERO_ZEROLL2,
+
+  THR_COMP_NEAR_NEARESTLG,
+  THR_COMP_NEAREST_NEARLG,
+  THR_COMP_NEAR_NEARLG,
+  THR_COMP_NEW_NEARESTLG,
+  THR_COMP_NEAREST_NEWLG,
+  THR_COMP_NEW_NEARLG,
+  THR_COMP_NEAR_NEWLG,
+  THR_COMP_NEW_NEWLG,
+  THR_COMP_ZERO_ZEROLG,
+
+  THR_COMP_NEAR_NEARESTBA,
+  THR_COMP_NEAREST_NEARBA,
+  THR_COMP_NEAR_NEARBA,
+  THR_COMP_NEW_NEARESTBA,
+  THR_COMP_NEAREST_NEWBA,
+  THR_COMP_NEW_NEARBA,
+  THR_COMP_NEAR_NEWBA,
+  THR_COMP_NEW_NEWBA,
+  THR_COMP_ZERO_ZEROBA,
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
 #else  // CONFIG_EXT_INTER
 
   THR_COMP_NEARLA,
   THR_COMP_NEWLA,
 #if CONFIG_EXT_REFS
   THR_COMP_NEARL2A,
@@ -239,30 +314,45 @@ typedef enum {
   THR_COMP_NEARLB,
   THR_COMP_NEWLB,
   THR_COMP_NEARL2B,
   THR_COMP_NEWL2B,
   THR_COMP_NEARL3B,
   THR_COMP_NEWL3B,
   THR_COMP_NEARGB,
   THR_COMP_NEWGB,
+
+#if CONFIG_EXT_COMP_REFS
+  THR_COMP_NEARLL2,
+  THR_COMP_NEWLL2,
+  THR_COMP_NEARLG,
+  THR_COMP_NEWLG,
+  THR_COMP_NEARBA,
+  THR_COMP_NEWBA,
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
   THR_COMP_ZEROLA,
 #if CONFIG_EXT_REFS
   THR_COMP_ZEROL2A,
   THR_COMP_ZEROL3A,
 #endif  // CONFIG_EXT_REFS
   THR_COMP_ZEROGA,
 
 #if CONFIG_EXT_REFS
   THR_COMP_ZEROLB,
   THR_COMP_ZEROL2B,
   THR_COMP_ZEROL3B,
   THR_COMP_ZEROGB,
+
+#if CONFIG_EXT_COMP_REFS
+  THR_COMP_ZEROLL2,
+  THR_COMP_ZEROLG,
+  THR_COMP_ZEROBA,
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
 #endif  // CONFIG_EXT_INTER
 
   THR_H_PRED,
   THR_V_PRED,
   THR_D135_PRED,
   THR_D207_PRED,
@@ -344,17 +434,16 @@ typedef struct RD_OPT {
   int thresh_mult[MAX_MODES];
   int thresh_mult_sub8x8[MAX_REFS];
 
   int threshes[MAX_SEGMENTS][BLOCK_SIZES][MAX_MODES];
 
   int64_t prediction_type_threshes[TOTAL_REFS_PER_FRAME][REFERENCE_MODES];
 
   int RDMULT;
-  int RDDIV;
 } RD_OPT;
 
 static INLINE void av1_init_rd_stats(RD_STATS *rd_stats) {
 #if CONFIG_RD_DEBUG
   int plane;
 #endif
   rd_stats->rate = 0;
   rd_stats->dist = 0;
--- a/third_party/aom/av1/encoder/rdopt.c
+++ b/third_party/aom/av1/encoder/rdopt.c
@@ -108,29 +108,40 @@ static const int filter_sets[DUAL_FILTER
 #define GOLDEN_FRAME_MODE_MASK \
   ((1 << LAST_FRAME) | (1 << ALTREF_FRAME) | (1 << INTRA_FRAME))
 #define ALTREF_FRAME_MODE_MASK \
   ((1 << LAST_FRAME) | (1 << GOLDEN_FRAME) | (1 << INTRA_FRAME))
 
 #endif  // CONFIG_EXT_REFS
 
 #if CONFIG_EXT_REFS
+#if CONFIG_EXT_COMP_REFS
+#define SECOND_REF_FRAME_MASK                                        \
+  ((1 << ALTREF_FRAME) | (1 << BWDREF_FRAME) | (1 << GOLDEN_FRAME) | \
+   (1 << LAST2_FRAME) | 0x01)  // NOLINT
+#else                          // !CONFIG_EXT_COMP_REFS
 #define SECOND_REF_FRAME_MASK ((1 << ALTREF_FRAME) | (1 << BWDREF_FRAME) | 0x01)
-#else
+#endif  // CONFIG_EXT_COMP_REFS
+#else   // !CONFIG_EXT_REFS
 #define SECOND_REF_FRAME_MASK ((1 << ALTREF_FRAME) | 0x01)
 #endif  // CONFIG_EXT_REFS
 
 #define MIN_EARLY_TERM_INDEX 3
 #define NEW_MV_DISCOUNT_FACTOR 8
 
 #if CONFIG_EXT_INTRA
 #define ANGLE_SKIP_THRESH 10
 #define FILTER_FAST_SEARCH 1
 #endif  // CONFIG_EXT_INTRA
 
+// Setting this to 1 will disable trellis optimization within the
+// transform search. Trellis optimization will still be applied
+// in the final encode.
+#define DISABLE_TRELLISQ_SEARCH 0
+
 const double ADST_FLIP_SVM[8] = { -6.6623, -2.8062, -3.2531, 3.1671,    // vert
                                   -7.7051, -3.2234, -3.6193, 3.4533 };  // horz
 
 typedef struct {
   PREDICTION_MODE mode;
   MV_REFERENCE_FRAME ref_frame[2];
 } MODE_DEFINITION;
 
@@ -186,42 +197,104 @@ static const MODE_DEFINITION av1_mode_or
   { ZEROMV, { BWDREF_FRAME, NONE_FRAME } },
 #endif  // CONFIG_EXT_REFS
   { ZEROMV, { GOLDEN_FRAME, NONE_FRAME } },
   { ZEROMV, { ALTREF_FRAME, NONE_FRAME } },
 
 // TODO(zoeliu): May need to reconsider the order on the modes to check
 
 #if CONFIG_EXT_INTER
+
+#if CONFIG_COMPOUND_SINGLEREF
+  // Single ref comp mode
+  { SR_NEAREST_NEARMV, { LAST_FRAME, NONE_FRAME } },
+#if CONFIG_EXT_REFS
+  { SR_NEAREST_NEARMV, { LAST2_FRAME, NONE_FRAME } },
+  { SR_NEAREST_NEARMV, { LAST3_FRAME, NONE_FRAME } },
+  { SR_NEAREST_NEARMV, { BWDREF_FRAME, NONE_FRAME } },
+#endif  // CONFIG_EXT_REFS
+  { SR_NEAREST_NEARMV, { GOLDEN_FRAME, NONE_FRAME } },
+  { SR_NEAREST_NEARMV, { ALTREF_FRAME, NONE_FRAME } },
+
+  /*
+  { SR_NEAREST_NEWMV, { LAST_FRAME, NONE_FRAME } },
+#if CONFIG_EXT_REFS
+  { SR_NEAREST_NEWMV, { LAST2_FRAME, NONE_FRAME } },
+  { SR_NEAREST_NEWMV, { LAST3_FRAME, NONE_FRAME } },
+  { SR_NEAREST_NEWMV, { BWDREF_FRAME, NONE_FRAME } },
+#endif  // CONFIG_EXT_REFS
+  { SR_NEAREST_NEWMV, { GOLDEN_FRAME, NONE_FRAME } },
+  { SR_NEAREST_NEWMV, { ALTREF_FRAME, NONE_FRAME } },*/
+
+  { SR_NEAR_NEWMV, { LAST_FRAME, NONE_FRAME } },
+#if CONFIG_EXT_REFS
+  { SR_NEAR_NEWMV, { LAST2_FRAME, NONE_FRAME } },
+  { SR_NEAR_NEWMV, { LAST3_FRAME, NONE_FRAME } },
+  { SR_NEAR_NEWMV, { BWDREF_FRAME, NONE_FRAME } },
+#endif  // CONFIG_EXT_REFS
+  { SR_NEAR_NEWMV, { GOLDEN_FRAME, NONE_FRAME } },
+  { SR_NEAR_NEWMV, { ALTREF_FRAME, NONE_FRAME } },
+
+  { SR_ZERO_NEWMV, { LAST_FRAME, NONE_FRAME } },
+#if CONFIG_EXT_REFS
+  { SR_ZERO_NEWMV, { LAST2_FRAME, NONE_FRAME } },
+  { SR_ZERO_NEWMV, { LAST3_FRAME, NONE_FRAME } },
+  { SR_ZERO_NEWMV, { BWDREF_FRAME, NONE_FRAME } },
+#endif  // CONFIG_EXT_REFS
+  { SR_ZERO_NEWMV, { GOLDEN_FRAME, NONE_FRAME } },
+  { SR_ZERO_NEWMV, { ALTREF_FRAME, NONE_FRAME } },
+
+  { SR_NEW_NEWMV, { LAST_FRAME, NONE_FRAME } },
+#if CONFIG_EXT_REFS
+  { SR_NEW_NEWMV, { LAST2_FRAME, NONE_FRAME } },
+  { SR_NEW_NEWMV, { LAST3_FRAME, NONE_FRAME } },
+  { SR_NEW_NEWMV, { BWDREF_FRAME, NONE_FRAME } },
+#endif  // CONFIG_EXT_REFS
+  { SR_NEW_NEWMV, { GOLDEN_FRAME, NONE_FRAME } },
+  { SR_NEW_NEWMV, { ALTREF_FRAME, NONE_FRAME } },
+#endif  // CONFIG_COMPOUND_SINGLEREF
+
   { NEAREST_NEARESTMV, { LAST_FRAME, ALTREF_FRAME } },
 #if CONFIG_EXT_REFS
   { NEAREST_NEARESTMV, { LAST2_FRAME, ALTREF_FRAME } },
   { NEAREST_NEARESTMV, { LAST3_FRAME, ALTREF_FRAME } },
 #endif  // CONFIG_EXT_REFS
   { NEAREST_NEARESTMV, { GOLDEN_FRAME, ALTREF_FRAME } },
 #if CONFIG_EXT_REFS
   { NEAREST_NEARESTMV, { LAST_FRAME, BWDREF_FRAME } },
   { NEAREST_NEARESTMV, { LAST2_FRAME, BWDREF_FRAME } },
   { NEAREST_NEARESTMV, { LAST3_FRAME, BWDREF_FRAME } },
   { NEAREST_NEARESTMV, { GOLDEN_FRAME, BWDREF_FRAME } },
+
+#if CONFIG_EXT_COMP_REFS
+  { NEAREST_NEARESTMV, { LAST_FRAME, LAST2_FRAME } },
+  { NEAREST_NEARESTMV, { LAST_FRAME, GOLDEN_FRAME } },
+  { NEAREST_NEARESTMV, { BWDREF_FRAME, ALTREF_FRAME } },
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
 #else  // CONFIG_EXT_INTER
 
   { NEARESTMV, { LAST_FRAME, ALTREF_FRAME } },
 #if CONFIG_EXT_REFS
   { NEARESTMV, { LAST2_FRAME, ALTREF_FRAME } },
   { NEARESTMV, { LAST3_FRAME, ALTREF_FRAME } },
 #endif  // CONFIG_EXT_REFS
   { NEARESTMV, { GOLDEN_FRAME, ALTREF_FRAME } },
 #if CONFIG_EXT_REFS
   { NEARESTMV, { LAST_FRAME, BWDREF_FRAME } },
   { NEARESTMV, { LAST2_FRAME, BWDREF_FRAME } },
   { NEARESTMV, { LAST3_FRAME, BWDREF_FRAME } },
   { NEARESTMV, { GOLDEN_FRAME, BWDREF_FRAME } },
+
+#if CONFIG_EXT_COMP_REFS
+  { NEARESTMV, { LAST_FRAME, LAST2_FRAME } },
+  { NEARESTMV, { LAST_FRAME, GOLDEN_FRAME } },
+  { NEARESTMV, { BWDREF_FRAME, ALTREF_FRAME } },
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 #endif  // CONFIG_EXT_INTER
 
   { TM_PRED, { INTRA_FRAME, NONE_FRAME } },
 
 #if CONFIG_ALT_INTRA
   { SMOOTH_PRED, { INTRA_FRAME, NONE_FRAME } },
 #if CONFIG_SMOOTH_HV
@@ -292,19 +365,45 @@ static const MODE_DEFINITION av1_mode_or
 
   { NEAR_NEARMV, { GOLDEN_FRAME, BWDREF_FRAME } },
   { NEW_NEARESTMV, { GOLDEN_FRAME, BWDREF_FRAME } },
   { NEAREST_NEWMV, { GOLDEN_FRAME, BWDREF_FRAME } },
   { NEW_NEARMV, { GOLDEN_FRAME, BWDREF_FRAME } },
   { NEAR_NEWMV, { GOLDEN_FRAME, BWDREF_FRAME } },
   { NEW_NEWMV, { GOLDEN_FRAME, BWDREF_FRAME } },
   { ZERO_ZEROMV, { GOLDEN_FRAME, BWDREF_FRAME } },
+
+#if CONFIG_EXT_COMP_REFS
+  { NEAR_NEARMV, { LAST_FRAME, LAST2_FRAME } },
+  { NEW_NEARESTMV, { LAST_FRAME, LAST2_FRAME } },
+  { NEAREST_NEWMV, { LAST_FRAME, LAST2_FRAME } },
+  { NEW_NEARMV, { LAST_FRAME, LAST2_FRAME } },
+  { NEAR_NEWMV, { LAST_FRAME, LAST2_FRAME } },
+  { NEW_NEWMV, { LAST_FRAME, LAST2_FRAME } },
+  { ZERO_ZEROMV, { LAST_FRAME, LAST2_FRAME } },
+
+  { NEAR_NEARMV, { LAST_FRAME, GOLDEN_FRAME } },
+  { NEW_NEARESTMV, { LAST_FRAME, GOLDEN_FRAME } },
+  { NEAREST_NEWMV, { LAST_FRAME, GOLDEN_FRAME } },
+  { NEW_NEARMV, { LAST_FRAME, GOLDEN_FRAME } },
+  { NEAR_NEWMV, { LAST_FRAME, GOLDEN_FRAME } },
+  { NEW_NEWMV, { LAST_FRAME, GOLDEN_FRAME } },
+  { ZERO_ZEROMV, { LAST_FRAME, GOLDEN_FRAME } },
+
+  { NEAR_NEARMV, { BWDREF_FRAME, ALTREF_FRAME } },
+  { NEW_NEARESTMV, { BWDREF_FRAME, ALTREF_FRAME } },
+  { NEAREST_NEWMV, { BWDREF_FRAME, ALTREF_FRAME } },
+  { NEW_NEARMV, { BWDREF_FRAME, ALTREF_FRAME } },
+  { NEAR_NEWMV, { BWDREF_FRAME, ALTREF_FRAME } },
+  { NEW_NEWMV, { BWDREF_FRAME, ALTREF_FRAME } },
+  { ZERO_ZEROMV, { BWDREF_FRAME, ALTREF_FRAME } },
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
-#else  // CONFIG_EXT_INTER
+#else  // !CONFIG_EXT_INTER
 
   { NEARMV, { LAST_FRAME, ALTREF_FRAME } },
   { NEWMV, { LAST_FRAME, ALTREF_FRAME } },
 #if CONFIG_EXT_REFS
   { NEARMV, { LAST2_FRAME, ALTREF_FRAME } },
   { NEWMV, { LAST2_FRAME, ALTREF_FRAME } },
   { NEARMV, { LAST3_FRAME, ALTREF_FRAME } },
   { NEWMV, { LAST3_FRAME, ALTREF_FRAME } },
@@ -316,30 +415,45 @@ static const MODE_DEFINITION av1_mode_or
   { NEARMV, { LAST_FRAME, BWDREF_FRAME } },
   { NEWMV, { LAST_FRAME, BWDREF_FRAME } },
   { NEARMV, { LAST2_FRAME, BWDREF_FRAME } },
   { NEWMV, { LAST2_FRAME, BWDREF_FRAME } },
   { NEARMV, { LAST3_FRAME, BWDREF_FRAME } },
   { NEWMV, { LAST3_FRAME, BWDREF_FRAME } },
   { NEARMV, { GOLDEN_FRAME, BWDREF_FRAME } },
   { NEWMV, { GOLDEN_FRAME, BWDREF_FRAME } },
+
+#if CONFIG_EXT_COMP_REFS
+  { NEARMV, { LAST_FRAME, LAST2_FRAME } },
+  { NEWMV, { LAST_FRAME, LAST2_FRAME } },
+  { NEARMV, { LAST_FRAME, GOLDEN_FRAME } },
+  { NEWMV, { LAST_FRAME, GOLDEN_FRAME } },
+  { NEARMV, { BWDREF_FRAME, ALTREF_FRAME } },
+  { NEWMV, { BWDREF_FRAME, ALTREF_FRAME } },
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
   { ZEROMV, { LAST_FRAME, ALTREF_FRAME } },
 #if CONFIG_EXT_REFS
   { ZEROMV, { LAST2_FRAME, ALTREF_FRAME } },
   { ZEROMV, { LAST3_FRAME, ALTREF_FRAME } },
 #endif  // CONFIG_EXT_REFS
   { ZEROMV, { GOLDEN_FRAME, ALTREF_FRAME } },
 
 #if CONFIG_EXT_REFS
   { ZEROMV, { LAST_FRAME, BWDREF_FRAME } },
   { ZEROMV, { LAST2_FRAME, BWDREF_FRAME } },
   { ZEROMV, { LAST3_FRAME, BWDREF_FRAME } },
   { ZEROMV, { GOLDEN_FRAME, BWDREF_FRAME } },
+
+#if CONFIG_EXT_COMP_REFS
+  { ZEROMV, { LAST_FRAME, LAST2_FRAME } },
+  { ZEROMV, { LAST_FRAME, GOLDEN_FRAME } },
+  { ZEROMV, { BWDREF_FRAME, ALTREF_FRAME } },
+#endif  // CONFIG_EXT_COMP_REFS
 #endif  // CONFIG_EXT_REFS
 
 #endif  // CONFIG_EXT_INTER
 
   { H_PRED, { INTRA_FRAME, NONE_FRAME } },
   { V_PRED, { INTRA_FRAME, NONE_FRAME } },
   { D135_PRED, { INTRA_FRAME, NONE_FRAME } },
   { D207_PRED, { INTRA_FRAME, NONE_FRAME } },
@@ -380,16 +494,28 @@ static const MODE_DEFINITION av1_mode_or
 
   { ZEROMV, { ALTREF_FRAME, INTRA_FRAME } },
   { NEARESTMV, { ALTREF_FRAME, INTRA_FRAME } },
   { NEARMV, { ALTREF_FRAME, INTRA_FRAME } },
   { NEWMV, { ALTREF_FRAME, INTRA_FRAME } },
 #endif  // CONFIG_EXT_INTER
 };
 
+static const PREDICTION_MODE intra_rd_search_mode_order[INTRA_MODES] = {
+  DC_PRED,       H_PRED,        V_PRED,
+#if CONFIG_ALT_INTRA
+  SMOOTH_PRED,
+#endif  // CONFIG_ALT_INTRA
+  TM_PRED,
+#if CONFIG_ALT_INTRA && CONFIG_SMOOTH_HV
+  SMOOTH_V_PRED, SMOOTH_H_PRED,
+#endif  // CONFIG_ALT_INTRA && CONFIG_SMOOTH_HV
+  D135_PRED,     D207_PRED,     D153_PRED, D63_PRED, D117_PRED, D45_PRED,
+};
+
 #if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
 static INLINE int write_uniform_cost(int n, int v) {
   const int l = get_unsigned_bits(n);
   const int m = (1 << l) - n;
   if (l == 0) return 0;
   if (v < m)
     return (l - 1) * av1_cost_bit(128, 0);
   else
@@ -485,16 +611,57 @@ static double od_compute_dist_8x8(int qm
   }
   /* Normalize the filter to unit DC response. */
   sum *= 1. / (OD_DIST_LP_NORM * OD_DIST_LP_NORM * OD_DIST_LP_NORM *
                OD_DIST_LP_NORM);
   return activity * activity * (sum + vardist);
 }
 
 // Note : Inputs x and y are in a pixel domain
+static double od_compute_dist_common(int qm, int activity_masking, od_coeff *x,
+                                     od_coeff *y, int bsize_w, int bsize_h,
+                                     int qindex, od_coeff *tmp,
+                                     od_coeff *e_lp) {
+  int i, j;
+  double sum = 0;
+  const int mid = OD_DIST_LP_MID;
+
+  for (j = 0; j < bsize_w; j++) {
+    e_lp[j] = mid * tmp[j] + 2 * tmp[bsize_w + j];
+    e_lp[(bsize_h - 1) * bsize_w + j] = mid * tmp[(bsize_h - 1) * bsize_w + j] +
+                                        2 * tmp[(bsize_h - 2) * bsize_w + j];
+  }
+  for (i = 1; i < bsize_h - 1; i++) {
+    for (j = 0; j < bsize_w; j++) {
+      e_lp[i * bsize_w + j] = mid * tmp[i * bsize_w + j] +
+                              tmp[(i - 1) * bsize_w + j] +
+                              tmp[(i + 1) * bsize_w + j];
+    }
+  }
+  for (i = 0; i < bsize_h; i += 8) {
+    for (j = 0; j < bsize_w; j += 8) {
+      sum += od_compute_dist_8x8(qm, activity_masking, &x[i * bsize_w + j],
+                                 &y[i * bsize_w + j], &e_lp[i * bsize_w + j],
+                                 bsize_w);
+    }
+  }
+  /* Scale according to linear regression against SSE, for 8x8 blocks. */
+  if (activity_masking) {
+    sum *= 2.2 + (1.7 - 2.2) * (qindex - 99) / (210 - 99) +
+           (qindex < 99 ? 2.5 * (qindex - 99) / 99 * (qindex - 99) / 99 : 0);
+  } else {
+    sum *= qindex >= 128
+               ? 1.4 + (0.9 - 1.4) * (qindex - 128) / (209 - 128)
+               : qindex <= 43 ? 1.5 + (2.0 - 1.5) * (qindex - 43) / (16 - 43)
+                              : 1.5 + (1.4 - 1.5) * (qindex - 43) / (128 - 43);
+  }
+
+  return sum;
+}
+
 static double od_compute_dist(int qm, int activity_masking, od_coeff *x,
                               od_coeff *y, int bsize_w, int bsize_h,
                               int qindex) {
   int i;
   double sum;
   sum = 0;
 
   assert(bsize_w >= 8 && bsize_h >= 8);
@@ -520,71 +687,188 @@ static double od_compute_dist(int qm, in
       tmp[i * bsize_w] = mid * e[i * bsize_w] + 2 * e[i * bsize_w + 1];
       tmp[i * bsize_w + bsize_w - 1] =
           mid * e[i * bsize_w + bsize_w - 1] + 2 * e[i * bsize_w + bsize_w - 2];
       for (j = 1; j < bsize_w - 1; j++) {
         tmp[i * bsize_w + j] = mid * e[i * bsize_w + j] +
                                e[i * bsize_w + j - 1] + e[i * bsize_w + j + 1];
       }
     }
-    for (j = 0; j < bsize_w; j++) {
-      e_lp[j] = mid * tmp[j] + 2 * tmp[bsize_w + j];
-      e_lp[(bsize_h - 1) * bsize_w + j] =
-          mid * tmp[(bsize_h - 1) * bsize_w + j] +
-          2 * tmp[(bsize_h - 2) * bsize_w + j];
-    }
-    for (i = 1; i < bsize_h - 1; i++) {
-      for (j = 0; j < bsize_w; j++) {
-        e_lp[i * bsize_w + j] = mid * tmp[i * bsize_w + j] +
-                                tmp[(i - 1) * bsize_w + j] +
-                                tmp[(i + 1) * bsize_w + j];
-      }
-    }
-    for (i = 0; i < bsize_h; i += 8) {
-      for (j = 0; j < bsize_w; j += 8) {
-        sum += od_compute_dist_8x8(qm, activity_masking, &x[i * bsize_w + j],
-                                   &y[i * bsize_w + j], &e_lp[i * bsize_w + j],
-                                   bsize_w);
-      }
-    }
-    /* Scale according to linear regression against SSE, for 8x8 blocks. */
-    if (activity_masking) {
-      sum *= 2.2 + (1.7 - 2.2) * (qindex - 99) / (210 - 99) +
-             (qindex < 99 ? 2.5 * (qindex - 99) / 99 * (qindex - 99) / 99 : 0);
-    } else {
-      sum *= qindex >= 128
-                 ? 1.4 + (0.9 - 1.4) * (qindex - 128) / (209 - 128)
-                 : qindex <= 43
-                       ? 1.5 + (2.0 - 1.5) * (qindex - 43) / (16 - 43)
-                       : 1.5 + (1.4 - 1.5) * (qindex - 43) / (128 - 43);
-    }
+    sum = od_compute_dist_common(qm, activity_masking, x, y, bsize_w, bsize_h,
+                                 qindex, tmp, e_lp);
   }
   return sum;
 }
 
-int64_t av1_daala_dist(const uint8_t *src, int src_stride, const uint8_t *dst,
-                       int dst_stride, int bsw, int bsh, int qm,
+static double od_compute_dist_diff(int qm, int activity_masking, od_coeff *x,
+                                   od_coeff *e, int bsize_w, int bsize_h,
+                                   int qindex) {
+  int i;
+  double sum;
+  sum = 0;
+
+  assert(bsize_w >= 8 && bsize_h >= 8);
+
+  if (qm == OD_FLAT_QM) {
+    for (i = 0; i < bsize_w * bsize_h; i++) {
+      double tmp;
+      tmp = e[i];
+      sum += tmp * tmp;
+    }
+  } else {
+    int j;
+    DECLARE_ALIGNED(16, od_coeff, y[MAX_TX_SQUARE]);
+    DECLARE_ALIGNED(16, od_coeff, tmp[MAX_TX_SQUARE]);
+    DECLARE_ALIGNED(16, od_coeff, e_lp[MAX_TX_SQUARE]);
+    int mid = OD_DIST_LP_MID;
+    for (i = 0; i < bsize_h; i++) {
+      for (j = 0; j < bsize_w; j++) {
+        y[i * bsize_w + j] = x[i * bsize_w + j] - e[i * bsize_w + j];
+      }
+    }
+    for (i = 0; i < bsize_h; i++) {
+      tmp[i * bsize_w] = mid * e[i * bsize_w] + 2 * e[i * bsize_w + 1];
+      tmp[i * bsize_w + bsize_w - 1] =
+          mid * e[i * bsize_w + bsize_w - 1] + 2 * e[i * bsize_w + bsize_w - 2];
+      for (j = 1; j < bsize_w - 1; j++) {
+        tmp[i * bsize_w + j] = mid * e[i * bsize_w + j] +
+                               e[i * bsize_w + j - 1] + e[i * bsize_w + j + 1];
+      }
+    }
+
+    sum = od_compute_dist_common(qm, activity_masking, x, y, bsize_w, bsize_h,
+                                 qindex, tmp, e_lp);
+  }
+  return sum;
+}
+
+int64_t av1_daala_dist(const MACROBLOCKD *xd, const uint8_t *src,
+                       int src_stride, const uint8_t *dst, int dst_stride,
+                       int bsw, int bsh, int visible_w, int visible_h, int qm,
                        int use_activity_masking, int qindex) {
   int i, j;
   int64_t d;
   DECLARE_ALIGNED(16, od_coeff, orig[MAX_TX_SQUARE]);
   DECLARE_ALIGNED(16, od_coeff, rec[MAX_TX_SQUARE]);
-
+#if !CONFIG_HIGHBITDEPTH
+  (void)xd;
+#endif
   assert(qm == OD_HVS_QM);
 
-  for (j = 0; j < bsh; j++)
-    for (i = 0; i < bsw; i++) orig[j * bsw + i] = src[j * src_stride + i];
-
-  for (j = 0; j < bsh; j++)
-    for (i = 0; i < bsw; i++) rec[j * bsw + i] = dst[j * dst_stride + i];
+#if CONFIG_HIGHBITDEPTH
+  if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
+    for (j = 0; j < bsh; j++)
+      for (i = 0; i < bsw; i++)
+        orig[j * bsw + i] = CONVERT_TO_SHORTPTR(src)[j * src_stride + i];
+
+    if ((bsw == visible_w) && (bsh == visible_h)) {
+      for (j = 0; j < bsh; j++)
+        for (i = 0; i < bsw; i++)
+          rec[j * bsw + i] = CONVERT_TO_SHORTPTR(dst)[j * dst_stride + i];
+    } else {
+      for (j = 0; j < visible_h; j++)
+        for (i = 0; i < visible_w; i++)
+          rec[j * bsw + i] = CONVERT_TO_SHORTPTR(dst)[j * dst_stride + i];
+
+      if (visible_w < bsw) {
+        for (j = 0; j < bsh; j++)
+          for (i = visible_w; i < bsw; i++)
+            rec[j * bsw + i] = CONVERT_TO_SHORTPTR(src)[j * src_stride + i];
+      }
+
+      if (visible_h < bsh) {
+        for (j = visible_h; j < bsh; j++)
+          for (i = 0; i < bsw; i++)
+            rec[j * bsw + i] = CONVERT_TO_SHORTPTR(src)[j * src_stride + i];
+      }
+    }
+  } else {
+#endif
+    for (j = 0; j < bsh; j++)
+      for (i = 0; i < bsw; i++) orig[j * bsw + i] = src[j * src_stride + i];
+
+    if ((bsw == visible_w) && (bsh == visible_h)) {
+      for (j = 0; j < bsh; j++)
+        for (i = 0; i < bsw; i++) rec[j * bsw + i] = dst[j * dst_stride + i];
+    } else {
+      for (j = 0; j < visible_h; j++)
+        for (i = 0; i < visible_w; i++)
+          rec[j * bsw + i] = dst[j * dst_stride + i];
+
+      if (visible_w < bsw) {
+        for (j = 0; j < bsh; j++)
+          for (i = visible_w; i < bsw; i++)
+            rec[j * bsw + i] = src[j * src_stride + i];
+      }
+
+      if (visible_h < bsh) {
+        for (j = visible_h; j < bsh; j++)
+          for (i = 0; i < bsw; i++) rec[j * bsw + i] = src[j * src_stride + i];
+      }
+    }
+#if CONFIG_HIGHBITDEPTH
+  }
+#endif  // CONFIG_HIGHBITDEPTH
 
   d = (int64_t)od_compute_dist(qm, use_activity_masking, orig, rec, bsw, bsh,
                                qindex);
   return d;
 }
+
+static int64_t av1_daala_dist_diff(const MACROBLOCKD *xd, const uint8_t *src,
+                                   int src_stride, const int16_t *diff,
+                                   int dst_stride, int bsw, int bsh,
+                                   int visible_w, int visible_h, int qm,
+                                   int use_activity_masking, int qindex) {
+  int i, j;
+  int64_t d;
+  DECLARE_ALIGNED(16, od_coeff, orig[MAX_TX_SQUARE]);
+  DECLARE_ALIGNED(16, od_coeff, diff32[MAX_TX_SQUARE]);
+#if !CONFIG_HIGHBITDEPTH
+  (void)xd;
+#endif
+  assert(qm == OD_HVS_QM);
+
+#if CONFIG_HIGHBITDEPTH
+  if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
+    for (j = 0; j < bsh; j++)
+      for (i = 0; i < bsw; i++)
+        orig[j * bsw + i] = CONVERT_TO_SHORTPTR(src)[j * src_stride + i];
+  } else {
+#endif
+    for (j = 0; j < bsh; j++)
+      for (i = 0; i < bsw; i++) orig[j * bsw + i] = src[j * src_stride + i];
+#if CONFIG_HIGHBITDEPTH
+  }
+#endif  // CONFIG_HIGHBITDEPTH
+
+  if ((bsw == visible_w) && (bsh == visible_h)) {
+    for (j = 0; j < bsh; j++)
+      for (i = 0; i < bsw; i++) diff32[j * bsw + i] = diff[j * dst_stride + i];
+  } else {
+    for (j = 0; j < visible_h; j++)
+      for (i = 0; i < visible_w; i++)
+        diff32[j * bsw + i] = diff[j * dst_stride + i];
+
+    if (visible_w < bsw) {
+      for (j = 0; j < bsh; j++)
+        for (i = visible_w; i < bsw; i++) diff32[j * bsw + i] = 0;
+    }
+
+    if (visible_h < bsh) {
+      for (j = visible_h; j < bsh; j++)
+        for (i = 0; i < bsw; i++) diff32[j * bsw + i] = 0;
+    }
+  }
+
+  d = (int64_t)od_compute_dist_diff(qm, use_activity_masking, orig, diff32, bsw,
+                                    bsh, qindex);
+
+  return d;
+}
 #endif  // CONFIG_DAALA_DIST
 
 static void get_energy_distribution_fine(const AV1_COMP *cpi, BLOCK_SIZE bsize,
                                          const uint8_t *src, int src_stride,
                                          const uint8_t *dst, int dst_stride,
                                          double *hordist, double *verdist) {
   const int bw = block_size_wide[bsize];
   const int bh = block_size_high[bsize];
@@ -887,21 +1171,21 @@ static void model_rd_for_sb(const AV1_CO
   int64_t dist_sum = 0;
   int64_t total_sse = 0;
 
   x->pred_sse[ref] = 0;
 
   for (plane = plane_from; plane <= plane_to; ++plane) {
     struct macroblock_plane *const p = &x->plane[plane];
     struct macroblockd_plane *const pd = &xd->plane[plane];
-#if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2
+#if CONFIG_CHROMA_SUB8X8
     const BLOCK_SIZE bs = AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
 #else
     const BLOCK_SIZE bs = get_plane_block_size(bsize, pd);
-#endif  // CONFIG_CB4X4 && !CONFIG_CHROMA_2X2
+#endif  // CONFIG_CHROMA_SUB8X8
 
     unsigned int sse;
     int rate;
     int64_t dist;
 
 #if CONFIG_CB4X4
     if (x->skip_chroma_rd && plane) continue;
 #endif  // CONFIG_CB4X4
@@ -1153,31 +1437,29 @@ int av1_cost_coeffs(const AV1_COMP *cons
                      use_fast_coef_costing);
 #else  // !CONFIG_LV_MAP
   (void)scan_order;
   (void)use_fast_coef_costing;
   const MACROBLOCKD *xd = &x->e_mbd;
   const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   const struct macroblockd_plane *pd = &xd->plane[plane];
   const BLOCK_SIZE bsize = mbmi->sb_type;
-#if CONFIG_CB4X4
-#if CONFIG_CHROMA_2X2
-  const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
-#else
+#if CONFIG_CHROMA_SUB8X8
   const BLOCK_SIZE plane_bsize =
       AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
-#endif  // CONFIG_CHROMA_2X2
+#elif CONFIG_CB4X4
+  const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
 #else   // CONFIG_CB4X4
   const BLOCK_SIZE plane_bsize =
       get_plane_block_size(AOMMAX(BLOCK_8X8, bsize), pd);
 #endif  // CONFIG_CB4X4
 
   TXB_CTX txb_ctx;
   get_txb_ctx(plane_bsize, tx_size, plane, a, l, &txb_ctx);
-  return av1_cost_coeffs_txb(cpi, x, plane, block, &txb_ctx);
+  return av1_cost_coeffs_txb(cpi, x, plane, block, tx_size, &txb_ctx);
 #endif  // !CONFIG_LV_MAP
 }
 #endif  // !CONFIG_PVQ || CONFIG_VAR_TX
 
 // Get transform block visible dimensions cropped to the MI units.
 static void get_txb_dimensions(const MACROBLOCKD *xd, int plane,
                                BLOCK_SIZE plane_bsize, int blk_row, int blk_col,
                                BLOCK_SIZE tx_bsize, int *width, int *height,
@@ -1203,28 +1485,46 @@ static void get_txb_dimensions(const MAC
   const int tx_unit_size = tx_size_wide_log2[0];
   if (width) *width = txb_width;
   if (height) *height = txb_height;
   *visible_width = clamp(block_cols - (blk_col << tx_unit_size), 0, txb_width);
   *visible_height =
       clamp(block_rows - (blk_row << tx_unit_size), 0, txb_height);
 }
 
-// Compute the pixel domain sum square error on all visible 4x4s in the
+// Compute the pixel domain distortion from src and dst on all visible 4x4s in
+// the
 // transform block.
-static unsigned pixel_sse(const AV1_COMP *const cpi, const MACROBLOCKD *xd,
-                          int plane, const uint8_t *src, const int src_stride,
-                          const uint8_t *dst, const int dst_stride, int blk_row,
-                          int blk_col, const BLOCK_SIZE plane_bsize,
-                          const BLOCK_SIZE tx_bsize) {
+static unsigned pixel_dist(const AV1_COMP *const cpi, const MACROBLOCK *x,
+                           int plane, const uint8_t *src, const int src_stride,
+                           const uint8_t *dst, const int dst_stride,
+                           int blk_row, int blk_col,
+                           const BLOCK_SIZE plane_bsize,
+                           const BLOCK_SIZE tx_bsize) {
   int txb_rows, txb_cols, visible_rows, visible_cols;
+  const MACROBLOCKD *xd = &x->e_mbd;
+#if CONFIG_DAALA_DIST
+  int qm = OD_HVS_QM;
+  int use_activity_masking = 0;
+#if CONFIG_PVQ
+  use_activity_masking = x->daala_enc.use_activity_masking;
+#endif  // CONFIG_PVQ
+#endif  // CONFIG_DAALA_DIST
   get_txb_dimensions(xd, plane, plane_bsize, blk_row, blk_col, tx_bsize,
                      &txb_cols, &txb_rows, &visible_cols, &visible_rows);
   assert(visible_rows > 0);
   assert(visible_cols > 0);
+
+#if CONFIG_DAALA_DIST
+  if (plane == 0 && txb_cols >= 8 && txb_rows >= 8)
+    return av1_daala_dist(xd, src, src_stride, dst, dst_stride, txb_cols,
+                          txb_rows, visible_cols, visible_rows, qm,
+                          use_activity_masking, x->qindex);
+#endif  // CONFIG_DAALA_DIST
+
 #if CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
   if ((txb_rows == visible_rows && txb_cols == visible_cols) &&
       tx_bsize < BLOCK_SIZES) {
 #else
   if (txb_rows == visible_rows && txb_cols == visible_cols) {
 #endif
     unsigned sse;
     cpi->fn_ptr[tx_bsize].vf(src, src_stride, dst, dst_stride, &sse);
@@ -1237,40 +1537,59 @@ static unsigned pixel_sse(const AV1_COMP
     return (unsigned int)ROUND_POWER_OF_TWO(sse, (xd->bd - 8) * 2);
   }
 #endif  // CONFIG_HIGHBITDEPTH
   unsigned sse = aom_sse_odd_size(src, src_stride, dst, dst_stride,
                                   visible_cols, visible_rows);
   return sse;
 }
 
-// Compute the squares sum squares on all visible 4x4s in the transform block.
-static int64_t sum_squares_visible(const MACROBLOCKD *xd, int plane,
-                                   const int16_t *diff, const int diff_stride,
-                                   int blk_row, int blk_col,
-                                   const BLOCK_SIZE plane_bsize,
-                                   const BLOCK_SIZE tx_bsize) {
+// Compute the pixel domain distortion from diff on all visible 4x4s in the
+// transform block.
+static int64_t pixel_diff_dist(const MACROBLOCK *x, int plane,
+                               const int16_t *diff, const int diff_stride,
+                               int blk_row, int blk_col,
+                               const BLOCK_SIZE plane_bsize,
+                               const BLOCK_SIZE tx_bsize) {
   int visible_rows, visible_cols;
+  const MACROBLOCKD *xd = &x->e_mbd;
+#if CONFIG_DAALA_DIST
+  int txb_height = block_size_high[tx_bsize];
+  int txb_width = block_size_wide[tx_bsize];
+  const int src_stride = x->plane[plane].src.stride;
+  const int src_idx = (blk_row * src_stride + blk_col) << tx_size_wide_log2[0];
+  const uint8_t *src = &x->plane[plane].src.buf[src_idx];
+  int qm = OD_HVS_QM;
+  int use_activity_masking = 0;
+#if CONFIG_PVQ
+  use_activity_masking = x->daala_enc.use_activity_masking;
+#endif  // CONFIG_PVQ
+#endif
+
   get_txb_dimensions(xd, plane, plane_bsize, blk_row, blk_col, tx_bsize, NULL,
                      NULL, &visible_cols, &visible_rows);
-  return aom_sum_squares_2d_i16(diff, diff_stride, visible_cols, visible_rows);
+
+#if CONFIG_DAALA_DIST
+  if (plane == 0 && txb_width >= 8 && txb_height >= 8)
+    return av1_daala_dist_diff(
+        xd, src, src_stride, diff, diff_stride, txb_width, txb_height,
+        visible_cols, visible_rows, qm, use_activity_masking, x->qindex);
+  else
+#endif
+    return aom_sum_squares_2d_i16(diff, diff_stride, visible_cols,
+                                  visible_rows);
 }
 
 void av1_dist_block(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
                     BLOCK_SIZE plane_bsize, int block, int blk_row, int blk_col,
                     TX_SIZE tx_size, int64_t *out_dist, int64_t *out_sse,
                     OUTPUT_STATUS output_status) {
   MACROBLOCKD *const xd = &x->e_mbd;
   const struct macroblock_plane *const p = &x->plane[plane];
 #if CONFIG_DAALA_DIST
-  int qm = OD_HVS_QM;
-  int use_activity_masking = 0;
-#if CONFIG_PVQ
-  use_activity_masking = x->daala_enc.use_activity_masking;
-#endif  // CONFIG_PVQ
   struct macroblockd_plane *const pd = &xd->plane[plane];
 #else   // CONFIG_DAALA_DIST
   const struct macroblockd_plane *const pd = &xd->plane[plane];
 #endif  // CONFIG_DAALA_DIST
 
   if (cpi->sf.use_transform_domain_distortion && !CONFIG_DAALA_DIST) {
     // Transform domain distortion computation is more efficient as it does
     // not involve an inverse transform, but it is less accurate.
@@ -1287,24 +1606,26 @@ void av1_dist_block(const AV1_COMP *cpi,
     *out_dist = av1_highbd_block_error2_c(coeff, dqcoeff, ref_coeff,
                                           buffer_length, &this_sse, bd) >>
                 shift;
 #else
     *out_dist = av1_block_error2_c(coeff, dqcoeff, ref_coeff, buffer_length,
                                    &this_sse) >>
                 shift;
 #endif  // CONFIG_HIGHBITDEPTH
-#elif CONFIG_HIGHBITDEPTH
-    const int bd = (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) ? xd->bd : 8;
-    *out_dist =
-        av1_highbd_block_error(coeff, dqcoeff, buffer_length, &this_sse, bd) >>
-        shift;
-#else
-    *out_dist =
-        av1_block_error(coeff, dqcoeff, buffer_length, &this_sse) >> shift;
+#else   // !CONFIG_PVQ
+#if CONFIG_HIGHBITDEPTH
+    if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
+      *out_dist = av1_highbd_block_error(coeff, dqcoeff, buffer_length,
+                                         &this_sse, xd->bd) >>
+                  shift;
+    else
+#endif
+      *out_dist =
+          av1_block_error(coeff, dqcoeff, buffer_length, &this_sse) >> shift;
 #endif  // CONFIG_PVQ
     *out_sse = this_sse >> shift;
   } else {
     const BLOCK_SIZE tx_bsize = txsize_to_bsize[tx_size];
 #if !CONFIG_PVQ || CONFIG_DAALA_DIST
     const int bsw = block_size_wide[tx_bsize];
     const int bsh = block_size_high[tx_bsize];
 #endif
@@ -1318,62 +1639,34 @@ void av1_dist_block(const AV1_COMP *cpi,
     const uint8_t *src = &x->plane[plane].src.buf[src_idx];
     const uint8_t *dst = &xd->plane[plane].dst.buf[dst_idx];
     const tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
     const uint16_t eob = p->eobs[block];
 
     assert(cpi != NULL);
     assert(tx_size_wide_log2[0] == tx_size_high_log2[0]);
 
-#if CONFIG_DAALA_DIST
-    if (plane == 0 && bsw >= 8 && bsh >= 8) {
-      if (output_status == OUTPUT_HAS_DECODED_PIXELS) {
-        const int pred_stride = block_size_wide[plane_bsize];
-        const int pred_idx = (blk_row * pred_stride + blk_col)
-                             << tx_size_wide_log2[0];
-        const int16_t *pred = &pd->pred[pred_idx];
-        int i, j;
-        DECLARE_ALIGNED(16, uint8_t, pred8[MAX_TX_SQUARE]);
-
-        for (j = 0; j < bsh; j++)
-          for (i = 0; i < bsw; i++)
-            pred8[j * bsw + i] = pred[j * pred_stride + i];
-        *out_sse = av1_daala_dist(src, src_stride, pred8, bsw, bsw, bsh, qm,
-                                  use_activity_masking, x->qindex);
-      } else {
-        *out_sse = av1_daala_dist(src, src_stride, dst, dst_stride, bsw, bsh,
-                                  qm, use_activity_masking, x->qindex);
-      }
-    } else
-#endif  // CONFIG_DAALA_DIST
     {
       const int diff_stride = block_size_wide[plane_bsize];
       const int diff_idx = (blk_row * diff_stride + blk_col)
                            << tx_size_wide_log2[0];
       const int16_t *diff = &p->src_diff[diff_idx];
-      *out_sse = sum_squares_visible(xd, plane, diff, diff_stride, blk_row,
-                                     blk_col, plane_bsize, tx_bsize);
+      *out_sse = pixel_diff_dist(x, plane, diff, diff_stride, blk_row, blk_col,
+                                 plane_bsize, tx_bsize);
 #if CONFIG_HIGHBITDEPTH
       if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
         *out_sse = ROUND_POWER_OF_TWO(*out_sse, (xd->bd - 8) * 2);
 #endif  // CONFIG_HIGHBITDEPTH
     }
     *out_sse *= 16;
 
     if (eob) {
       if (output_status == OUTPUT_HAS_DECODED_PIXELS) {
-#if CONFIG_DAALA_DIST
-        if (plane == 0 && bsw >= 8 && bsh >= 8)
-          *out_dist = av1_daala_dist(src, src_stride, dst, dst_stride, bsw, bsh,
-                                     qm, use_activity_masking, x->qindex);
-        else
-#endif  // CONFIG_DAALA_DIST
-          *out_dist =
-              pixel_sse(cpi, xd, plane, src, src_stride, dst, dst_stride,
-                        blk_row, blk_col, plane_bsize, tx_bsize);
+        *out_dist = pixel_dist(cpi, x, plane, src, src_stride, dst, dst_stride,
+                               blk_row, blk_col, plane_bsize, tx_bsize);
       } else {
 #if CONFIG_HIGHBITDEPTH
         uint8_t *recon;
         DECLARE_ALIGNED(16, uint16_t, recon16[MAX_TX_SQUARE]);
 
         if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
           recon = CONVERT_TO_BYTEPTR(recon16);
         else
@@ -1396,45 +1689,52 @@ void av1_dist_block(const AV1_COMP *cpi,
 #endif  // CONFIG_HIGHBITDEPTH
 #else
         (void)dst;
 #endif  // !CONFIG_PVQ
 
         const PLANE_TYPE plane_type = get_plane_type(plane);
         TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
 
-        av1_inverse_transform_block(xd, dqcoeff, tx_type, tx_size, recon,
-                                    MAX_TX_SIZE, eob);
+        av1_inverse_transform_block(xd, dqcoeff,
+#if CONFIG_LGT
+                                    xd->mi[0]->mbmi.mode,
+#endif
+                                    tx_type, tx_size, recon, MAX_TX_SIZE, eob);
 
 #if CONFIG_DAALA_DIST
-        if (plane == 0 && bsw >= 8 && bsh >= 8) {
-          *out_dist = av1_daala_dist(src, src_stride, recon, MAX_TX_SIZE, bsw,
-                                     bsh, qm, use_activity_masking, x->qindex);
-        } else {
-          if (plane == 0) {
-            // Save decoded pixels for inter block in pd->pred to avoid
-            // block_8x8_rd_txfm_daala_dist() need to produce them
-            // by calling av1_inverse_transform_block() again.
-            const int pred_stride = block_size_wide[plane_bsize];
-            const int pred_idx = (blk_row * pred_stride + blk_col)
-                                 << tx_size_wide_log2[0];
-            int16_t *pred = &pd->pred[pred_idx];
-            int i, j;
-
+        if (plane == 0 && (bsw < 8 || bsh < 8)) {
+          // Save decoded pixels for inter block in pd->pred to avoid
+          // block_8x8_rd_txfm_daala_dist() need to produce them
+          // by calling av1_inverse_transform_block() again.
+          const int pred_stride = block_size_wide[plane_bsize];
+          const int pred_idx = (blk_row * pred_stride + blk_col)
+                               << tx_size_wide_log2[0];
+          int16_t *pred = &pd->pred[pred_idx];
+          int i, j;
+
+#if CONFIG_HIGHBITDEPTH
+          if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
+            for (j = 0; j < bsh; j++)
+              for (i = 0; i < bsw; i++)
+                pred[j * pred_stride + i] =
+                    CONVERT_TO_SHORTPTR(recon)[j * MAX_TX_SIZE + i];
+          } else {
+#endif
             for (j = 0; j < bsh; j++)
               for (i = 0; i < bsw; i++)
                 pred[j * pred_stride + i] = recon[j * MAX_TX_SIZE + i];
+#if CONFIG_HIGHBITDEPTH
           }
-#endif  // CONFIG_DAALA_DIST
-          *out_dist =
-              pixel_sse(cpi, xd, plane, src, src_stride, recon, MAX_TX_SIZE,
-                        blk_row, blk_col, plane_bsize, tx_bsize);
-#if CONFIG_DAALA_DIST
+#endif  // CONFIG_HIGHBITDEPTH
         }
 #endif  // CONFIG_DAALA_DIST
+        *out_dist =
+            pixel_dist(cpi, x, plane, src, src_stride, recon, MAX_TX_SIZE,
+                       blk_row, blk_col, plane_bsize, tx_bsize);
       }
       *out_dist *= 16;
     } else {
       *out_dist = *out_sse;
     }
   }
 }
 
@@ -1448,33 +1748,47 @@ static void block_rd_txfm(int plane, int
   ENTROPY_CONTEXT *a = args->t_above + blk_col;
   ENTROPY_CONTEXT *l = args->t_left + blk_row;
 #if !CONFIG_TXK_SEL
   const AV1_COMMON *cm = &cpi->common;
 #endif
   int64_t rd1, rd2, rd;
   RD_STATS this_rd_stats;
 
+#if !CONFIG_SUPERTX && !CONFIG_VAR_TX
   assert(tx_size == get_tx_size(plane, xd));
+#endif  // !CONFIG_SUPERTX
 
   av1_init_rd_stats(&this_rd_stats);
 
   if (args->exit_early) return;
 
   if (!is_inter_block(mbmi)) {
 #if CONFIG_CFL
 
 #if CONFIG_EC_ADAPT
     FRAME_CONTEXT *const ec_ctx = xd->tile_ctx;
 #else
     FRAME_CONTEXT *const ec_ctx = cm->fc;
 #endif  // CONFIG_EC_ADAPT
 
+#if CONFIG_DEBUG
+// av1_predict_intra_block_facade does not pass plane_bsize, we need to validate
+// that we will get the same value of plane_bsize on the other side.
+#if CONFIG_CHROMA_SUB8X8
+    const BLOCK_SIZE plane_bsize_val = AOMMAX(
+        BLOCK_4X4, get_plane_block_size(mbmi->sb_type, &xd->plane[plane]));
+#else
+    const BLOCK_SIZE plane_bsize_val =
+        get_plane_block_size(mbmi->sb_type, &xd->plane[plane]);
+#endif  // CONFIG_CHROMA_SUB8X8
+    assert(plane_bsize == plane_bsize_val);
+#endif  // CONFIG_DEBUG
     av1_predict_intra_block_encoder_facade(x, ec_ctx, plane, block, blk_col,
-                                           blk_row, tx_size, plane_bsize);
+                                           blk_row, tx_size);
 #else
     av1_predict_intra_block_facade(xd, plane, block, blk_col, blk_row, tx_size);
 #endif
 #if CONFIG_DPCM_INTRA
     const int block_raster_idx =
         av1_block_index_to_raster_order(tx_size, block);
     const PREDICTION_MODE mode =
         (plane == 0) ? get_y_mode(xd->mi[0], block_raster_idx) : mbmi->uv_mode;
@@ -1491,19 +1805,24 @@ static void block_rd_txfm(int plane, int
     }
 #endif  // CONFIG_DPCM_INTRA
     av1_subtract_txb(x, plane, plane_bsize, blk_col, blk_row, tx_size);
   }
 
 #if !CONFIG_TXK_SEL
   // full forward transform and quantization
   const int coeff_ctx = combine_entropy_contexts(*a, *l);
+#if DISABLE_TRELLISQ_SEARCH
+  av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
+                  coeff_ctx, AV1_XFORM_QUANT_B);
+#else
   av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
                   coeff_ctx, AV1_XFORM_QUANT_FP);
   av1_optimize_b(cm, x, plane, block, plane_bsize, tx_size, a, l);
+#endif  // DISABLE_TRELLISQ_SEARCH
 
   if (!is_inter_block(mbmi)) {
     struct macroblock_plane *const p = &x->plane[plane];
     av1_inverse_transform_block_facade(xd, plane, block, blk_row, blk_col,
                                        p->eobs[block]);
     av1_dist_block(args->cpi, x, plane, plane_bsize, block, blk_row, blk_col,
                    tx_size, &this_rd_stats.dist, &this_rd_stats.sse,
                    OUTPUT_HAS_DECODED_PIXELS);
@@ -1513,32 +1832,33 @@ static void block_rd_txfm(int plane, int
                    OUTPUT_HAS_PREDICTED_PIXELS);
   }
 #if CONFIG_CFL
   if (plane == AOM_PLANE_Y && x->cfl_store_y) {
     struct macroblockd_plane *const pd = &xd->plane[plane];
     const int dst_stride = pd->dst.stride;
     uint8_t *dst =
         &pd->dst.buf[(blk_row * dst_stride + blk_col) << tx_size_wide_log2[0]];
-    cfl_store(xd->cfl, dst, dst_stride, blk_row, blk_col, tx_size);
+    // TODO (ltrudeau) Store sub-8x8 inter blocks when bottom right block is
+    // intra predicted.
+    cfl_store(xd->cfl, dst, dst_stride, blk_row, blk_col, tx_size, plane_bsize);
   }
 #endif
 #if CONFIG_DPCM_INTRA
 CALCULATE_RD : {}
 #endif  // CONFIG_DPCM_INTRA
-  rd = RDCOST(x->rdmult, x->rddiv, 0, this_rd_stats.dist);
+  rd = RDCOST(x->rdmult, 0, this_rd_stats.dist);
   if (args->this_rd + rd > args->best_rd) {
     args->exit_early = 1;
     return;
   }
 #if !CONFIG_PVQ
   const PLANE_TYPE plane_type = get_plane_type(plane);
   const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
-  const SCAN_ORDER *scan_order =
-      get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
+  const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi);
   this_rd_stats.rate =
       av1_cost_coeffs(cpi, x, plane, block, tx_size, scan_order, a, l,
                       args->use_fast_coef_costing);
 #else   // !CONFIG_PVQ
   this_rd_stats.rate = x->rate;
 #endif  // !CONFIG_PVQ
 #else   // !CONFIG_TXK_SEL
   av1_search_txk_type(cpi, x, plane, block, blk_row, blk_col, plane_bsize,
@@ -1549,146 +1869,120 @@ CALCULATE_RD : {}
 #if !CONFIG_PVQ
 #if CONFIG_RD_DEBUG
   av1_update_txb_coeff_cost(&this_rd_stats, plane, tx_size, blk_row, blk_col,
                             this_rd_stats.rate);
 #endif  // CONFIG_RD_DEBUG
   av1_set_txb_context(x, plane, block, tx_size, a, l);
 #endif  // !CONFIG_PVQ
 
-  rd1 = RDCOST(x->rdmult, x->rddiv, this_rd_stats.rate, this_rd_stats.dist);
-  rd2 = RDCOST(x->rdmult, x->rddiv, 0, this_rd_stats.sse);
+  rd1 = RDCOST(x->rdmult, this_rd_stats.rate, this_rd_stats.dist);
+  rd2 = RDCOST(x->rdmult, 0, this_rd_stats.sse);
 
   // TODO(jingning): temporarily enabled only for luma component
   rd = AOMMIN(rd1, rd2);
 
-#if CONFIG_DAALA_DIST
-  if (plane == 0 && plane_bsize >= BLOCK_8X8 &&
-      (tx_size == TX_4X4 || tx_size == TX_4X8 || tx_size == TX_8X4)) {
-    this_rd_stats.dist = 0;
-    this_rd_stats.sse = 0;
-    rd = 0;
-    x->rate_4x4[block] = this_rd_stats.rate;
-  }
-#endif  // CONFIG_DAALA_DIST
-
 #if !CONFIG_PVQ
   this_rd_stats.skip &= !x->plane[plane].eobs[block];
 #else
   this_rd_stats.skip &= x->pvq_skip[plane];
 #endif  // !CONFIG_PVQ
   av1_merge_rd_stats(&args->rd_stats, &this_rd_stats);
 
   args->this_rd += rd;
 
-  if (args->this_rd > args->best_rd) {
-    args->exit_early = 1;
-    return;
-  }
+#if CONFIG_DAALA_DIST
+  if (!(plane == 0 && plane_bsize >= BLOCK_8X8 &&
+        (tx_size == TX_4X4 || tx_size == TX_4X8 || tx_size == TX_8X4))) {
+#endif
+    if (args->this_rd > args->best_rd) {
+      args->exit_early = 1;
+      return;
+    }
+#if CONFIG_DAALA_DIST
+  }
+#endif
 }
 
 #if CONFIG_DAALA_DIST
-static void block_8x8_rd_txfm_daala_dist(int plane, int block, int blk_row,
-                                         int blk_col, BLOCK_SIZE plane_bsize,
-                                         TX_SIZE tx_size, void *arg) {
-  struct rdcost_block_args *args = arg;
-  MACROBLOCK *const x = args->x;
+static void daala_dist_sub8x8_txfm_rd(MACROBLOCK *x, BLOCK_SIZE bsize,
+                                      struct rdcost_block_args *args) {
   MACROBLOCKD *const xd = &x->e_mbd;
+  const struct macroblockd_plane *const pd = &xd->plane[0];
+  const struct macroblock_plane *const p = &x->plane[0];
   MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+  const int src_stride = p->src.stride;
+  const int dst_stride = pd->dst.stride;
+  const uint8_t *src = &p->src.buf[0];
+  const uint8_t *dst = &pd->dst.buf[0];
+  const int16_t *pred = &pd->pred[0];
+  const int bw = block_size_wide[bsize];
+  const int bh = block_size_high[bsize];
+
+  int i, j;
   int64_t rd, rd1, rd2;
-  RD_STATS this_rd_stats;
   int qm = OD_HVS_QM;
   int use_activity_masking = 0;
-
-  (void)tx_size;
-
-  assert(plane == 0);
-  assert(plane_bsize >= BLOCK_8X8);
+  unsigned int tmp1, tmp2;
+  int qindex = x->qindex;
 #if CONFIG_PVQ
   use_activity_masking = x->daala_enc.use_activity_masking;
-#endif  // CONFIG_PVQ
-  av1_init_rd_stats(&this_rd_stats);
-
-  if (args->exit_early) return;
-
-  {
-    const struct macroblock_plane *const p = &x->plane[plane];
-    struct macroblockd_plane *const pd = &xd->plane[plane];
-
-    const int src_stride = p->src.stride;
-    const int dst_stride = pd->dst.stride;
-    const int diff_stride = block_size_wide[plane_bsize];
-
-    const uint8_t *src =
-        &p->src.buf[(blk_row * src_stride + blk_col) << tx_size_wide_log2[0]];
-    const uint8_t *dst =
-        &pd->dst.buf[(blk_row * dst_stride + blk_col) << tx_size_wide_log2[0]];
-
-    unsigned int tmp1, tmp2;
-    int qindex = x->qindex;
-    const int pred_stride = block_size_wide[plane_bsize];
-    const int pred_idx = (blk_row * pred_stride + blk_col)
-                         << tx_size_wide_log2[0];
-    int16_t *pred = &pd->pred[pred_idx];
-    int i, j;
-    const int tx_blk_size = 8;
-
-    DECLARE_ALIGNED(16, uint8_t, pred8[8 * 8]);
-
-    for (j = 0; j < tx_blk_size; j++)
-      for (i = 0; i < tx_blk_size; i++)
-        pred8[j * tx_blk_size + i] = pred[j * diff_stride + i];
-
-    tmp1 = av1_daala_dist(src, src_stride, pred8, tx_blk_size, 8, 8, qm,
-                          use_activity_masking, qindex);
-    tmp2 = av1_daala_dist(src, src_stride, dst, dst_stride, 8, 8, qm,
-                          use_activity_masking, qindex);
-
-    if (!is_inter_block(mbmi)) {
-      this_rd_stats.sse = (int64_t)tmp1 * 16;
-      this_rd_stats.dist = (int64_t)tmp2 * 16;
-    } else {
-      // For inter mode, the decoded pixels are provided in pd->pred,
-      // while the predicted pixels are in dst.
-      this_rd_stats.sse = (int64_t)tmp2 * 16;
-      this_rd_stats.dist = (int64_t)tmp1 * 16;
-    }
-  }
-
-  rd = RDCOST(x->rdmult, x->rddiv, 0, this_rd_stats.dist);
-  if (args->this_rd + rd > args->best_rd) {
-    args->exit_early = 1;
-    return;
-  }
-
-  {
-    const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
-    const uint8_t txw_unit = tx_size_wide_unit[tx_size];
-    const uint8_t txh_unit = tx_size_high_unit[tx_size];
-    const int step = txw_unit * txh_unit;
-    int offset_h = tx_size_high_unit[TX_4X4];
-    // The rate of the current 8x8 block is the sum of four 4x4 blocks in it.
-    this_rd_stats.rate =
-        x->rate_4x4[block - max_blocks_wide * offset_h - step] +
-        x->rate_4x4[block - max_blocks_wide * offset_h] +
-        x->rate_4x4[block - step] + x->rate_4x4[block];
-  }
-  rd1 = RDCOST(x->rdmult, x->rddiv, this_rd_stats.rate, this_rd_stats.dist);
-  rd2 = RDCOST(x->rdmult, x->rddiv, 0, this_rd_stats.sse);
+#endif
+
+  assert((bw & 0x07) == 0);
+  assert((bh & 0x07) == 0);
+
+#if CONFIG_HIGHBITDEPTH
+  uint8_t *pred8;
+  DECLARE_ALIGNED(16, uint16_t, pred16[MAX_TX_SQUARE]);
+
+  if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
+    pred8 = CONVERT_TO_BYTEPTR(pred16);
+  else
+    pred8 = (uint8_t *)pred16;
+#else
+  DECLARE_ALIGNED(16, uint8_t, pred8[MAX_TX_SQUARE]);
+#endif  // CONFIG_HIGHBITDEPTH
+
+#if CONFIG_HIGHBITDEPTH
+  if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
+    for (j = 0; j < bh; j++)
+      for (i = 0; i < bw; i++)
+        CONVERT_TO_SHORTPTR(pred8)[j * bw + i] = pred[j * bw + i];
+  } else {
+#endif
+    for (j = 0; j < bh; j++)
+      for (i = 0; i < bw; i++) pred8[j * bw + i] = pred[j * bw + i];
+#if CONFIG_HIGHBITDEPTH
+  }
+#endif  // CONFIG_HIGHBITDEPTH
+
+  tmp1 = av1_daala_dist(xd, src, src_stride, pred8, bw, bw, bh, bw, bh, qm,
+                        use_activity_masking, qindex);
+  tmp2 = av1_daala_dist(xd, src, src_stride, dst, dst_stride, bw, bh, bw, bh,
+                        qm, use_activity_masking, qindex);
+
+  if (!is_inter_block(mbmi)) {
+    args->rd_stats.sse = (int64_t)tmp1 * 16;
+    args->rd_stats.dist = (int64_t)tmp2 * 16;
+  } else {
+    // For inter mode, the decoded pixels are provided in pd->pred,
+    // while the predicted pixels are in dst.
+    args->rd_stats.sse = (int64_t)tmp2 * 16;
+    args->rd_stats.dist = (int64_t)tmp1 * 16;
+  }
+
+  rd1 = RDCOST(x->rdmult, args->rd_stats.rate, args->rd_stats.dist);
+  rd2 = RDCOST(x->rdmult, 0, args->rd_stats.sse);
   rd = AOMMIN(rd1, rd2);
 
-  args->rd_stats.dist += this_rd_stats.dist;
-  args->rd_stats.sse += this_rd_stats.sse;
-
-  args->this_rd += rd;
-
-  if (args->this_rd > args->best_rd) {
-    args->exit_early = 1;
-    return;
-  }
+  args->rd_stats.rdcost = rd;
+  args->this_rd = rd;
+
+  if (args->this_rd > args->best_rd) args->exit_early = 1;
 }
 #endif  // CONFIG_DAALA_DIST
 
 static void txfm_rd_in_plane(MACROBLOCK *x, const AV1_COMP *cpi,
                              RD_STATS *rd_stats, int64_t ref_best_rd, int plane,
                              BLOCK_SIZE bsize, TX_SIZE tx_size,
                              int use_fast_coef_casting) {
   MACROBLOCKD *const xd = &x->e_mbd;
@@ -1700,25 +1994,23 @@ static void txfm_rd_in_plane(MACROBLOCK 
   args.best_rd = ref_best_rd;
   args.use_fast_coef_costing = use_fast_coef_casting;
   av1_init_rd_stats(&args.rd_stats);
 
   if (plane == 0) xd->mi[0]->mbmi.tx_size = tx_size;
 
   av1_get_entropy_contexts(bsize, tx_size, pd, args.t_above, args.t_left);
 
+  av1_foreach_transformed_block_in_plane(xd, bsize, plane, block_rd_txfm,
+                                         &args);
 #if CONFIG_DAALA_DIST
-  if (plane == 0 && bsize >= BLOCK_8X8 &&
+  if (!args.exit_early && plane == 0 && bsize >= BLOCK_8X8 &&
       (tx_size == TX_4X4 || tx_size == TX_4X8 || tx_size == TX_8X4))
-    av1_foreach_8x8_transformed_block_in_yplane(
-        xd, bsize, block_rd_txfm, block_8x8_rd_txfm_daala_dist, &args);
-  else
-#endif  // CONFIG_DAALA_DIST
-    av1_foreach_transformed_block_in_plane(xd, bsize, plane, block_rd_txfm,
-                                           &args);
+    daala_dist_sub8x8_txfm_rd(x, bsize, &args);
+#endif
 
   if (args.exit_early) {
     av1_invalid_rd_stats(rd_stats);
   } else {
     *rd_stats = args.rd_stats;
   }
 }
 
@@ -1791,16 +2083,20 @@ static int tx_size_cost(const AV1_COMP *
 }
 
 // #TODO(angiebird): use this function whenever it's possible
 int av1_tx_type_cost(const AV1_COMP *cpi, const MACROBLOCKD *xd,
                      BLOCK_SIZE bsize, int plane, TX_SIZE tx_size,
                      TX_TYPE tx_type) {
   if (plane > 0) return 0;
 
+#if CONFIG_VAR_TX
+  tx_size = get_min_tx_size(tx_size);
+#endif
+
   const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   const int is_inter = is_inter_block(mbmi);
 #if CONFIG_EXT_TX
   const AV1_COMMON *cm = &cpi->common;
   if (get_ext_tx_types(tx_size, bsize, is_inter, cm->reduced_tx_set_used) > 1 &&
       !xd->lossless[xd->mi[0]->mbmi.segment_id]) {
     const int ext_tx_set =
         get_ext_tx_set(tx_size, bsize, is_inter, cm->reduced_tx_set_used);
@@ -1859,31 +2155,30 @@ static int64_t txfm_yrd(const AV1_COMP *
   if (rd_stats->rate == INT_MAX) return INT64_MAX;
 #if !CONFIG_TXK_SEL
   int plane = 0;
   rd_stats->rate += av1_tx_type_cost(cpi, xd, bs, plane, tx_size, tx_type);
 #endif
 
   if (rd_stats->skip) {
     if (is_inter) {
-      rd = RDCOST(x->rdmult, x->rddiv, s1, rd_stats->sse);
+      rd = RDCOST(x->rdmult, s1, rd_stats->sse);
     } else {
-      rd = RDCOST(x->rdmult, x->rddiv, s1 + r_tx_size * tx_select,
-                  rd_stats->sse);
+      rd = RDCOST(x->rdmult, s1 + r_tx_size * tx_select, rd_stats->sse);
     }
   } else {
-    rd = RDCOST(x->rdmult, x->rddiv,
-                rd_stats->rate + s0 + r_tx_size * tx_select, rd_stats->dist);
+    rd = RDCOST(x->rdmult, rd_stats->rate + s0 + r_tx_size * tx_select,
+                rd_stats->dist);
   }
 
   if (tx_select) rd_stats->rate += r_tx_size;
 
   if (is_inter && !xd->lossless[xd->mi[0]->mbmi.segment_id] &&
       !(rd_stats->skip))
-    rd = AOMMIN(rd, RDCOST(x->rdmult, x->rddiv, s1, rd_stats->sse));
+    rd = AOMMIN(rd, RDCOST(x->rdmult, s1, rd_stats->sse));
 
   return rd;
 }
 
 static int skip_txfm_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs,
                             TX_TYPE tx_type, TX_SIZE tx_size) {
   const MACROBLOCKD *const xd = &x->e_mbd;
   const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
@@ -1924,17 +2219,18 @@ static int skip_txfm_search(const AV1_CO
   if (tx_size >= TX_32X32 && tx_type != DCT_DCT) return 1;
   if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE &&
       !do_tx_type_search(tx_type, prune))
     return 1;
 #endif  // CONFIG_EXT_TX
   return 0;
 }
 
-#if CONFIG_EXT_INTER && (CONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT)
+#if CONFIG_EXT_INTER && \
+    (CONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT || CONFIG_INTERINTRA)
 static int64_t estimate_yrd_for_sb(const AV1_COMP *const cpi, BLOCK_SIZE bs,
                                    MACROBLOCK *x, int *r, int64_t *d, int *s,
                                    int64_t *sse, int64_t ref_best_rd) {
   RD_STATS rd_stats;
   int64_t rd = txfm_yrd(cpi, x, &rd_stats, ref_best_rd, bs, DCT_DCT,
                         max_txsize_lookup[bs]);
   *r = rd_stats.rate;
   *d = rd_stats.dist;
@@ -2015,24 +2311,23 @@ static void choose_largest_tx_size(const
                        mbmi->tx_size, cpi->sf.use_fast_coef_costing);
 #if CONFIG_PVQ
       od_encode_rollback(&x->daala_enc, &pre_buf);
 #endif  // CONFIG_PVQ
       if (this_rd_stats.rate == INT_MAX) continue;
       av1_tx_type_cost(cpi, xd, bs, plane, mbmi->tx_size, tx_type);
 
       if (this_rd_stats.skip)
-        this_rd = RDCOST(x->rdmult, x->rddiv, s1, this_rd_stats.sse);
+        this_rd = RDCOST(x->rdmult, s1, this_rd_stats.sse);
       else
-        this_rd = RDCOST(x->rdmult, x->rddiv, this_rd_stats.rate + s0,
-                         this_rd_stats.dist);
+        this_rd =
+            RDCOST(x->rdmult, this_rd_stats.rate + s0, this_rd_stats.dist);
       if (is_inter_block(mbmi) && !xd->lossless[mbmi->segment_id] &&
           !this_rd_stats.skip)
-        this_rd =
-            AOMMIN(this_rd, RDCOST(x->rdmult, x->rddiv, s1, this_rd_stats.sse));
+        this_rd = AOMMIN(this_rd, RDCOST(x->rdmult, s1, this_rd_stats.sse));
 
       if (this_rd < best_rd) {
         best_rd = this_rd;
         best_tx_type = mbmi->tx_type;
         *rd_stats = this_rd_stats;
 #if CONFIG_PVQ
         od_encode_checkpoint(&x->daala_enc, &post_buf);
 #endif  // CONFIG_PVQ
@@ -2063,23 +2358,22 @@ static void choose_largest_tx_size(const
 
       av1_tx_type_cost(cpi, xd, bs, plane, mbmi->tx_size, tx_type);
       if (is_inter) {
         if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE &&
             !do_tx_type_search(tx_type, prune))
           continue;
       }
       if (this_rd_stats.skip)
-        this_rd = RDCOST(x->rdmult, x->rddiv, s1, this_rd_stats.sse);
+        this_rd = RDCOST(x->rdmult, s1, this_rd_stats.sse);
       else
-        this_rd = RDCOST(x->rdmult, x->rddiv, this_rd_stats.rate + s0,
-                         this_rd_stats.dist);
+        this_rd =
+            RDCOST(x->rdmult, this_rd_stats.rate + s0, this_rd_stats.dist);
       if (is_inter && !xd->lossless[mbmi->segment_id] && !this_rd_stats.skip)
-        this_rd =
-            AOMMIN(this_rd, RDCOST(x->rdmult, x->rddiv, s1, this_rd_stats.sse));
+        this_rd = AOMMIN(this_rd, RDCOST(x->rdmult, s1, this_rd_stats.sse));
 
       if (this_rd < best_rd) {
         best_rd = this_rd;
         best_tx_type = mbmi->tx_type;
         *rd_stats = this_rd_stats;
       }
     }
   } else {
@@ -2362,56 +2656,54 @@ static int64_t intra_model_yrd(const AV1
   const int max_blocks_high = max_block_high(xd, bsize, 0);
   mbmi->tx_size = tx_size;
   // Prediction.
   const int step = stepr * stepc;
   int block = 0;
   for (row = 0; row < max_blocks_high; row += stepr) {
     for (col = 0; col < max_blocks_wide; col += stepc) {
 #if CONFIG_CFL
-      const struct macroblockd_plane *const pd = &xd->plane[0];
-      const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
-
 #if CONFIG_EC_ADAPT
       FRAME_CONTEXT *const ec_ctx = xd->tile_ctx;
 #else
       FRAME_CONTEXT *const ec_ctx = cpi->common.fc;
 #endif  // CONFIG_EC_ADAPT
 
       av1_predict_intra_block_encoder_facade(x, ec_ctx, 0, block, col, row,
-                                             tx_size, plane_bsize);
+                                             tx_size);
 #else
       av1_predict_intra_block_facade(xd, 0, block, col, row, tx_size);
 #endif
       block += step;
     }
   }
   // RD estimation.
   model_rd_for_sb(cpi, bsize, x, xd, 0, 0, &this_rd_stats.rate,
                   &this_rd_stats.dist, &this_rd_stats.skip, &temp_sse);
 #if CONFIG_EXT_INTRA
-  if (av1_is_directional_mode(mbmi->mode, bsize)) {
+  if (av1_is_directional_mode(mbmi->mode, bsize) &&
+      av1_use_angle_delta(bsize)) {
     mode_cost += write_uniform_cost(2 * MAX_ANGLE_DELTA + 1,
                                     MAX_ANGLE_DELTA + mbmi->angle_delta[0]);
   }
 #endif  // CONFIG_EXT_INTRA
 #if CONFIG_FILTER_INTRA
   if (mbmi->mode == DC_PRED) {
     const aom_prob prob = cpi->common.fc->filter_intra_probs[0];
     if (mbmi->filter_intra_mode_info.use_filter_intra_mode[0]) {
       const int mode = mbmi->filter_intra_mode_info.filter_intra_mode[0];
       mode_cost += (av1_cost_bit(prob, 1) +
                     write_uniform_cost(FILTER_INTRA_MODES, mode));
     } else {
       mode_cost += av1_cost_bit(prob, 0);
     }
   }
 #endif  // CONFIG_FILTER_INTRA
-  this_rd = RDCOST(x->rdmult, x->rddiv, this_rd_stats.rate + mode_cost,
-                   this_rd_stats.dist);
+  this_rd =
+      RDCOST(x->rdmult, this_rd_stats.rate + mode_cost, this_rd_stats.dist);
   return this_rd;
 }
 
 #if CONFIG_PALETTE
 // Extends 'color_map' array from 'orig_width x orig_height' to 'new_width x
 // new_height'. Extra rows and columns are filled in by copying last valid
 // row/column.
 static void extend_palette_color_map(uint8_t *const color_map, int orig_width,
@@ -2615,17 +2907,17 @@ static int rd_pick_palette_intra_sby(con
       this_model_rd = intra_model_yrd(cpi, x, bsize, palette_mode_cost);
       if (*best_model_rd != INT64_MAX &&
           this_model_rd > *best_model_rd + (*best_model_rd >> 1))
         continue;
       if (this_model_rd < *best_model_rd) *best_model_rd = this_model_rd;
       super_block_yrd(cpi, x, &tokenonly_rd_stats, bsize, *best_rd);
       if (tokenonly_rd_stats.rate == INT_MAX) continue;
       this_rate = tokenonly_rd_stats.rate + palette_mode_cost;
-      this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, tokenonly_rd_stats.dist);
+      this_rd = RDCOST(x->rdmult, this_rate, tokenonly_rd_stats.dist);
       if (!xd->lossless[mbmi->segment_id] && mbmi->sb_type >= BLOCK_8X8) {
         tokenonly_rd_stats.rate -= tx_size_cost(cpi, x, bsize, mbmi->tx_size);
       }
       if (this_rd < *best_rd) {
         *best_rd = this_rd;
         memcpy(best_palette_color_map, color_map,
                block_width * block_height * sizeof(color_map[0]));
         *best_mbmi = *mbmi;
@@ -2769,17 +3061,18 @@ static int64_t rd_pick_intra_sub_8x8_y_s
               xd, pd->width, pd->height, txsize_to_bsize[tx_size], mode, dst,
               dst_stride, dst, dst_stride, col + idx, row + idy, 0);
 #if !CONFIG_PVQ
           aom_highbd_subtract_block(tx_height, tx_width, src_diff, 8, src,
                                     src_stride, dst, dst_stride, xd->bd);
 #endif
           if (is_lossless) {
             TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, tx_size);
-            const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 0);
+            const SCAN_ORDER *scan_order =
+                get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
             const int coeff_ctx =
                 combine_entropy_contexts(tempa[idx], templ[idy]);
 #if !CONFIG_PVQ
             av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8,
                             tx_size, coeff_ctx, AV1_XFORM_QUANT_FP);
             ratey += av1_cost_coeffs(cpi, x, 0, block, tx_size, scan_order,
                                      tempa + idx, templ + idy,
                                      cpi->sf.use_fast_coef_costing);
@@ -2801,36 +3094,45 @@ static int64_t rd_pick_intra_sub_8x8_y_s
                             tx_size, coeff_ctx, AV1_XFORM_QUANT_B);
 
             ratey += x->rate;
             skip = x->pvq_skip[0];
             tempa[idx] = !skip;
             templ[idy] = !skip;
             can_skip &= skip;
 #endif
-            if (RDCOST(x->rdmult, x->rddiv, ratey, distortion) >= best_rd)
+            if (RDCOST(x->rdmult, ratey, distortion) >= best_rd)
               goto next_highbd;
 #if CONFIG_PVQ
             if (!skip)
 #endif
               av1_inverse_transform_block(xd, BLOCK_OFFSET(pd->dqcoeff, block),
+#if CONFIG_LGT
+                                          mode,
+#endif
                                           DCT_DCT, tx_size, dst, dst_stride,
                                           p->eobs[block]);
           } else {
             int64_t dist;
             unsigned int tmp;
             TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, tx_size);
-            const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 0);
+            const SCAN_ORDER *scan_order =
+                get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
             const int coeff_ctx =
                 combine_entropy_contexts(tempa[idx], templ[idy]);
 #if !CONFIG_PVQ
+#if DISABLE_TRELLISQ_SEARCH
+            av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8,
+                            tx_size, coeff_ctx, AV1_XFORM_QUANT_B);
+#else
             av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8,
                             tx_size, coeff_ctx, AV1_XFORM_QUANT_FP);
             av1_optimize_b(cm, x, 0, block, BLOCK_8X8, tx_size, tempa + idx,
                            templ + idy);
+#endif  // DISABLE_TRELLISQ_SEARCH
             ratey += av1_cost_coeffs(cpi, x, 0, block, tx_size, scan_order,
                                      tempa + idx, templ + idy,
                                      cpi->sf.use_fast_coef_costing);
             skip = (p->eobs[block] == 0);
             can_skip &= skip;
             tempa[idx] = !skip;
             templ[idy] = !skip;
 #if CONFIG_EXT_TX
@@ -2850,29 +3152,32 @@ static int64_t rd_pick_intra_sub_8x8_y_s
             tempa[idx] = !skip;
             templ[idy] = !skip;
             can_skip &= skip;
 #endif
 #if CONFIG_PVQ
             if (!skip)
 #endif
               av1_inverse_transform_block(xd, BLOCK_OFFSET(pd->dqcoeff, block),
+#if CONFIG_LGT
+                                          mode,
+#endif
                                           tx_type, tx_size, dst, dst_stride,
                                           p->eobs[block]);
             cpi->fn_ptr[sub_bsize].vf(src, src_stride, dst, dst_stride, &tmp);
             dist = (int64_t)tmp << 4;
             distortion += dist;
-            if (RDCOST(x->rdmult, x->rddiv, ratey, distortion) >= best_rd)
+            if (RDCOST(x->rdmult, ratey, distortion) >= best_rd)
               goto next_highbd;
           }
         }
       }
 
       rate += ratey;
-      this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
+      this_rd = RDCOST(x->rdmult, rate, distortion);
 
       if (this_rd < best_rd) {
         *bestrate = rate;
         *bestratey = ratey;
         *bestdistortion = distortion;
         best_rd = this_rd;
         best_can_skip = can_skip;
         *best_mode = mode;
@@ -2963,35 +3268,45 @@ static int64_t rd_pick_intra_sub_8x8_y_s
 #endif  // CONFIG_CB4X4
                                 0);
 #if !CONFIG_PVQ
         aom_subtract_block(tx_height, tx_width, src_diff, 8, src, src_stride,
                            dst, dst_stride);
 #endif  // !CONFIG_PVQ
 
         TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, tx_size);
-        const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 0);
+        const SCAN_ORDER *scan_order =
+            get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
         const int coeff_ctx = combine_entropy_contexts(tempa[idx], templ[idy]);
 #if CONFIG_CB4X4
         block = 4 * block;
 #endif  // CONFIG_CB4X4
 #if !CONFIG_PVQ
+#if DISABLE_TRELLISQ_SEARCH
+        av1_xform_quant(cm, x, 0, block,
+#if CONFIG_CB4X4
+                        2 * (row + idy), 2 * (col + idx),
+#else
+                        row + idy, col + idx,
+#endif  // CONFIG_CB4X4
+                        BLOCK_8X8, tx_size, coeff_ctx, AV1_XFORM_QUANT_B);
+#else
         const AV1_XFORM_QUANT xform_quant =
             is_lossless ? AV1_XFORM_QUANT_B : AV1_XFORM_QUANT_FP;
         av1_xform_quant(cm, x, 0, block,
 #if CONFIG_CB4X4
                         2 * (row + idy), 2 * (col + idx),
 #else
                         row + idy, col + idx,
 #endif  // CONFIG_CB4X4
                         BLOCK_8X8, tx_size, coeff_ctx, xform_quant);
 
         av1_optimize_b(cm, x, 0, block, BLOCK_8X8, tx_size, tempa + idx,
                        templ + idy);
-
+#endif  // DISABLE_TRELLISQ_SEARCH
         ratey +=
             av1_cost_coeffs(cpi, x, 0, block, tx_size, scan_order, tempa + idx,
                             templ + idy, cpi->sf.use_fast_coef_costing);
         skip = (p->eobs[block] == 0);
         can_skip &= skip;
         tempa[idx] = !skip;
         templ[idy] = !skip;
 #if CONFIG_EXT_TX
@@ -3023,40 +3338,45 @@ static int64_t rd_pick_intra_sub_8x8_y_s
                              // calculate inverse txfm *before* calculating RD
                              // cost. Compared to calculating the distortion in
                              // the frequency domain, the overhead of encoding
                              // effort is low.
 #if CONFIG_PVQ
           if (!skip)
 #endif  // CONFIG_PVQ
             av1_inverse_transform_block(xd, BLOCK_OFFSET(pd->dqcoeff, block),
+#if CONFIG_LGT
+                                        mode,
+#endif
                                         tx_type, tx_size, dst, dst_stride,
                                         p->eobs[block]);
           unsigned int tmp;
           cpi->fn_ptr[sub_bsize].vf(src, src_stride, dst, dst_stride, &tmp);
           const int64_t dist = (int64_t)tmp << 4;
           distortion += dist;
         }
 
-        if (RDCOST(x->rdmult, x->rddiv, ratey, distortion) >= best_rd)
-          goto next;
+        if (RDCOST(x->rdmult, ratey, distortion) >= best_rd) goto next;
 
         if (is_lossless) {  // Calculate inverse txfm *after* RD cost.
 #if CONFIG_PVQ
           if (!skip)
 #endif  // CONFIG_PVQ
             av1_inverse_transform_block(xd, BLOCK_OFFSET(pd->dqcoeff, block),
+#if CONFIG_LGT
+                                        mode,
+#endif
                                         DCT_DCT, tx_size, dst, dst_stride,
                                         p->eobs[block]);
         }
       }
     }
 
     rate += ratey;
-    this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
+    this_rd = RDCOST(x->rdmult, rate, distortion);
 
     if (this_rd < best_rd) {
       *bestrate = rate;
       *bestratey = ratey;
       *bestdistortion = distortion;
       best_rd = this_rd;
       best_can_skip = can_skip;
       *best_mode = mode;
@@ -3182,19 +3502,20 @@ static int64_t rd_pick_intra_sub_8x8_y_m
     uint8_t *dst = pd->dst.buf;
     int use_activity_masking = 0;
     int qm = OD_HVS_QM;
 
 #if CONFIG_PVQ
     use_activity_masking = mb->daala_enc.use_activity_masking;
 #endif  // CONFIG_PVQ
     // Daala-defined distortion computed for the block of 8x8 pixels
-    total_distortion = av1_daala_dist(src, src_stride, dst, dst_stride, 8, 8,
-                                      qm, use_activity_masking, mb->qindex)
-                       << 4;
+    total_distortion =
+        av1_daala_dist(xd, src, src_stride, dst, dst_stride, 8, 8, 8, 8, qm,
+                       use_activity_masking, mb->qindex)
+        << 4;
   }
 #endif  // CONFIG_DAALA_DIST
   // Add in the cost of the transform type
   if (!is_lossless) {
     int rate_tx_type = 0;
 #if CONFIG_EXT_TX
     if (get_ext_tx_types(tx_size, bsize, 0, cpi->common.reduced_tx_set_used) >
         1) {
@@ -3213,17 +3534,17 @@ static int64_t rd_pick_intra_sub_8x8_y_m
     cost += rate_tx_type;
     tot_rate_y += rate_tx_type;
   }
 
   *rate = cost;
   *rate_y = tot_rate_y;
   *distortion = total_distortion;
 
-  return RDCOST(mb->rdmult, mb->rddiv, cost, total_distortion);
+  return RDCOST(mb->rdmult, cost, total_distortion);
 }
 
 #if CONFIG_FILTER_INTRA
 // Return 1 if an filter intra mode is selected; return 0 otherwise.
 static int rd_pick_filter_intra_sby(const AV1_COMP *const cpi, MACROBLOCK *x,
                                     int *rate, int *rate_tokenonly,
                                     int64_t *distortion, int *skippable,
                                     BLOCK_SIZE bsize, int mode_cost,
@@ -3256,17 +3577,17 @@ static int rd_pick_filter_intra_sby(cons
         this_model_rd > *best_model_rd + (*best_model_rd >> 1))
       continue;
     if (this_model_rd < *best_model_rd) *best_model_rd = this_model_rd;
     super_block_yrd(cpi, x, &tokenonly_rd_stats, bsize, *best_rd);
     if (tokenonly_rd_stats.rate == INT_MAX) continue;
     this_rate = tokenonly_rd_stats.rate +
                 av1_cost_bit(cpi->common.fc->filter_intra_probs[0], 1) +
                 write_uniform_cost(FILTER_INTRA_MODES, mode) + mode_cost;
-    this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, tokenonly_rd_stats.dist);
+    this_rd = RDCOST(x->rdmult, this_rate, tokenonly_rd_stats.dist);
 
     if (this_rd < *best_rd) {
       *best_rd = this_rd;
       best_tx_size = mic->mbmi.tx_size;
       filter_intra_mode_info = mbmi->filter_intra_mode_info;
       best_tx_type = mic->mbmi.tx_type;
       *rate = this_rate;
       *rate_tokenonly = tokenonly_rd_stats.rate;
@@ -3316,17 +3637,17 @@ static int64_t calc_rd_given_intra_angle
     return INT64_MAX;
   if (this_model_rd < *best_model_rd) *best_model_rd = this_model_rd;
   super_block_yrd(cpi, x, &tokenonly_rd_stats, bsize, best_rd_in);
   if (tokenonly_rd_stats.rate == INT_MAX) return INT64_MAX;
 
   this_rate = tokenonly_rd_stats.rate + mode_cost +
               write_uniform_cost(2 * max_angle_delta + 1,
                                  mbmi->angle_delta[0] + max_angle_delta);
-  this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, tokenonly_rd_stats.dist);
+  this_rd = RDCOST(x->rdmult, this_rate, tokenonly_rd_stats.dist);
 
   if (this_rd < *best_rd) {
     *best_rd = this_rd;
     *best_angle_delta = mbmi->angle_delta[0];
     *best_tx_size = mbmi->tx_size;
 #if CONFIG_INTRA_INTERP
     *best_filter = mbmi->intra_filter;
 #endif  // CONFIG_INTRA_INTERP
@@ -3491,18 +3812,18 @@ static const uint8_t mode_to_angle_bin[I
 };
 /* clang-format on */
 
 static void angle_estimation(const uint8_t *src, int src_stride, int rows,
                              int cols, BLOCK_SIZE bsize,
                              uint8_t *directional_mode_skip_mask) {
   memset(directional_mode_skip_mask, 0,
          INTRA_MODES * sizeof(*directional_mode_skip_mask));
-  // Sub-8x8 blocks do not use extra directions.
-  if (bsize < BLOCK_8X8) return;
+  // Check if angle_delta is used
+  if (!av1_use_angle_delta(bsize)) return;
   uint64_t hist[DIRECTIONAL_MODES];
   memset(hist, 0, DIRECTIONAL_MODES * sizeof(hist[0]));
   src += src_stride;
   int r, c, dx, dy;
   for (r = 1; r < rows; ++r) {
     for (c = 1; c < cols; ++c) {
       dx = src[c] - src[c - 1];
       dy = src[c] - src[c - src_stride];
@@ -3546,18 +3867,18 @@ static void angle_estimation(const uint8
 }
 
 #if CONFIG_HIGHBITDEPTH
 static void highbd_angle_estimation(const uint8_t *src8, int src_stride,
                                     int rows, int cols, BLOCK_SIZE bsize,
                                     uint8_t *directional_mode_skip_mask) {
   memset(directional_mode_skip_mask, 0,
          INTRA_MODES * sizeof(*directional_mode_skip_mask));
-  // Sub-8x8 blocks do not use extra directions.
-  if (bsize < BLOCK_8X8) return;
+  // Check if angle_delta is used
+  if (!av1_use_angle_delta(bsize)) return;
   uint16_t *src = CONVERT_TO_SHORTPTR(src8);
   uint64_t hist[DIRECTIONAL_MODES];
   memset(hist, 0, DIRECTIONAL_MODES * sizeof(hist[0]));
   src += src_stride;
   int r, c, dx, dy;
   for (r = 1; r < rows; ++r) {
     for (c = 1; c < cols; ++c) {
       dx = src[c] - src[c - 1];
@@ -3603,17 +3924,16 @@ static void highbd_angle_estimation(cons
 #endif  // CONFIG_HIGHBITDEPTH
 #endif  // CONFIG_EXT_INTRA
 
 // This function is used only for intra_only frames
 static int64_t rd_pick_intra_sby_mode(const AV1_COMP *const cpi, MACROBLOCK *x,
                                       int *rate, int *rate_tokenonly,
                                       int64_t *distortion, int *skippable,
                                       BLOCK_SIZE bsize, int64_t best_rd) {
-  uint8_t mode_idx;
   MACROBLOCKD *const xd = &x->e_mbd;
   MODE_INFO *const mic = xd->mi[0];
   MB_MODE_INFO *const mbmi = &mic->mbmi;
   assert(!is_inter_block(mbmi));
   MB_MODE_INFO best_mbmi = *mbmi;
   int64_t best_model_rd = INT64_MAX;
 #if CONFIG_EXT_INTRA
   const int rows = block_size_high[bsize];
@@ -3678,42 +3998,43 @@ static int64_t rd_pick_intra_sby_mode(co
 #endif  // CONFIG_PALETTE
 
   if (cpi->sf.tx_type_search.fast_intra_tx_type_search)
     x->use_default_intra_tx_type = 1;
   else
     x->use_default_intra_tx_type = 0;
 
   /* Y Search for intra prediction mode */
-  for (mode_idx = DC_PRED; mode_idx <= FINAL_MODE_SEARCH; ++mode_idx) {
+  for (int mode_idx = DC_PRED; mode_idx <= FINAL_MODE_SEARCH; ++mode_idx) {
     RD_STATS this_rd_stats;
     int this_rate, this_rate_tokenonly, s;
     int64_t this_distortion, this_rd, this_model_rd;
     if (mode_idx == FINAL_MODE_SEARCH) {
       if (x->use_default_intra_tx_type == 0) break;
       mbmi->mode = best_mbmi.mode;
       x->use_default_intra_tx_type = 0;
     } else {
-      mbmi->mode = mode_idx;
+      assert(mode_idx < INTRA_MODES);
+      mbmi->mode = intra_rd_search_mode_order[mode_idx];
     }
 #if CONFIG_PVQ
     od_encode_rollback(&x->daala_enc, &pre_buf);
 #endif  // CONFIG_PVQ
 #if CONFIG_EXT_INTRA
     mbmi->angle_delta[0] = 0;
 #endif  // CONFIG_EXT_INTRA
     this_model_rd = intra_model_yrd(cpi, x, bsize, bmode_costs[mbmi->mode]);
     if (best_model_rd != INT64_MAX &&
         this_model_rd > best_model_rd + (best_model_rd >> 1))
       continue;
     if (this_model_rd < best_model_rd) best_model_rd = this_model_rd;
 #if CONFIG_EXT_INTRA
     is_directional_mode = av1_is_directional_mode(mbmi->mode, bsize);
     if (is_directional_mode && directional_mode_skip_mask[mbmi->mode]) continue;
-    if (is_directional_mode) {
+    if (is_directional_mode && av1_use_angle_delta(bsize)) {
       this_rd_stats.rate = INT_MAX;
       rd_pick_intra_angle_sby(cpi, x, &this_rate, &this_rd_stats, bsize,
                               bmode_costs[mbmi->mode], best_rd, &best_model_rd);
     } else {
       super_block_yrd(cpi, x, &this_rd_stats, bsize, best_rd);
     }
 #else
     super_block_yrd(cpi, x, &this_rd_stats, bsize, best_rd);
@@ -3749,21 +4070,23 @@ static int64_t rd_pick_intra_sby_mode(co
     if (is_directional_mode) {
 #if CONFIG_INTRA_INTERP
       const int p_angle =
           mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP;
       if (av1_is_intra_filter_switchable(p_angle))
         this_rate +=
             cpi->intra_filter_cost[intra_filter_ctx][mbmi->intra_filter];
 #endif  // CONFIG_INTRA_INTERP
-      this_rate += write_uniform_cost(2 * MAX_ANGLE_DELTA + 1,
-                                      MAX_ANGLE_DELTA + mbmi->angle_delta[0]);
+      if (av1_use_angle_delta(bsize)) {
+        this_rate += write_uniform_cost(2 * MAX_ANGLE_DELTA + 1,
+                                        MAX_ANGLE_DELTA + mbmi->angle_delta[0]);
+      }
     }
 #endif  // CONFIG_EXT_INTRA
-    this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion);
+    this_rd = RDCOST(x->rdmult, this_rate, this_distortion);
 #if CONFIG_FILTER_INTRA
     if (best_rd == INT64_MAX || this_rd - best_rd < (best_rd >> 4)) {
       filter_intra_mode_skip_mask ^= (1 << mbmi->mode);
     }
 #endif  // CONFIG_FILTER_INTRA
 
     if (this_rd < best_rd) {
       best_mbmi = *mbmi;
@@ -3780,26 +4103,16 @@ static int64_t rd_pick_intra_sby_mode(co
 #endif  // CONFIG_PVQ
     }
   }
 
 #if CONFIG_PVQ
   od_encode_rollback(&x->daala_enc, &post_buf);
 #endif  // CONFIG_PVQ
 
-#if CONFIG_CFL
-  // Perform one extra txfm_rd_in_plane() call, this time with the best value so
-  // we can store reconstructed luma values
-  RD_STATS this_rd_stats;
-  x->cfl_store_y = 1;
-  txfm_rd_in_plane(x, cpi, &this_rd_stats, INT64_MAX, 0, bsize,
-                   mic->mbmi.tx_size, cpi->sf.use_fast_coef_costing);
-  x->cfl_store_y = 0;
-#endif
-
 #if CONFIG_PALETTE
   if (try_palette) {
     rd_pick_palette_intra_sby(cpi, x, bsize, palette_y_mode_ctx,
                               bmode_costs[DC_PRED], &best_mbmi,
                               best_palette_color_map, &best_rd, &best_model_rd,
                               rate, rate_tokenonly, distortion, skippable);
   }
 #endif  // CONFIG_PALETTE
@@ -3852,96 +4165,88 @@ static int super_block_uvrd(const AV1_CO
       RD_STATS pn_rd_stats;
       txfm_rd_in_plane(x, cpi, &pn_rd_stats, ref_best_rd, plane, bsize,
                        uv_tx_size, cpi->sf.use_fast_coef_costing);
       if (pn_rd_stats.rate == INT_MAX) {
         is_cost_valid = 0;
         break;
       }
       av1_merge_rd_stats(rd_stats, &pn_rd_stats);
-      if (RDCOST(x->rdmult, x->rddiv, rd_stats->rate, rd_stats->dist) >
-              ref_best_rd &&
-          RDCOST(x->rdmult, x->rddiv, 0, rd_stats->sse) > ref_best_rd) {
+      if (RDCOST(x->rdmult, rd_stats->rate, rd_stats->dist) > ref_best_rd &&
+          RDCOST(x->rdmult, 0, rd_stats->sse) > ref_best_rd) {
         is_cost_valid = 0;
         break;
       }
     }
   }
 
   if (!is_cost_valid) {
     // reset cost value
     av1_invalid_rd_stats(rd_stats);
   }
 
   return is_cost_valid;
 }
 
 #if CONFIG_VAR_TX
-// FIXME crop these calls
-static uint64_t sum_squares_2d(const int16_t *diff, int diff_stride,
-                               TX_SIZE tx_size) {
-  return aom_sum_squares_2d_i16(diff, diff_stride, tx_size_wide[tx_size],
-                                tx_size_high[tx_size]);
-}
-
 void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
                        int blk_row, int blk_col, int plane, int block,
                        int plane_bsize, const ENTROPY_CONTEXT *a,
                        const ENTROPY_CONTEXT *l, RD_STATS *rd_stats) {
   const AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *xd = &x->e_mbd;
   const struct macroblock_plane *const p = &x->plane[plane];
   struct macroblockd_plane *const pd = &xd->plane[plane];
+
+#if CONFIG_TXK_SEL
+  av1_search_txk_type(cpi, x, plane, block, blk_row, blk_col, plane_bsize,
+                      tx_size, a, l, 0, rd_stats);
+  return;
+#endif
+
   int64_t tmp;
   tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
   PLANE_TYPE plane_type = get_plane_type(plane);
   TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
   const SCAN_ORDER *const scan_order =
-      get_scan(cm, tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
+      get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
   BLOCK_SIZE txm_bsize = txsize_to_bsize[tx_size];
   int bh = block_size_high[txm_bsize];
   int bw = block_size_wide[txm_bsize];
-  int txb_h = tx_size_high_unit[tx_size];
-  int txb_w = tx_size_wide_unit[tx_size];
-
   int src_stride = p->src.stride;
   uint8_t *src =
       &p->src.buf[(blk_row * src_stride + blk_col) << tx_size_wide_log2[0]];
   uint8_t *dst =
       &pd->dst
            .buf[(blk_row * pd->dst.stride + blk_col) << tx_size_wide_log2[0]];
 #if CONFIG_HIGHBITDEPTH
   DECLARE_ALIGNED(16, uint16_t, rec_buffer16[MAX_TX_SQUARE]);
   uint8_t *rec_buffer;
 #else
   DECLARE_ALIGNED(16, uint8_t, rec_buffer[MAX_TX_SQUARE]);
 #endif  // CONFIG_HIGHBITDEPTH
-  int max_blocks_high = block_size_high[plane_bsize];
-  int max_blocks_wide = block_size_wide[plane_bsize];
-  const int diff_stride = max_blocks_wide;
+  const int diff_stride = block_size_wide[plane_bsize];
   const int16_t *diff =
       &p->src_diff[(blk_row * diff_stride + blk_col) << tx_size_wide_log2[0]];
   int txb_coeff_cost;
 
   assert(tx_size < TX_SIZES_ALL);
 
-  if (xd->mb_to_bottom_edge < 0)
-    max_blocks_high += xd->mb_to_bottom_edge >> (3 + pd->subsampling_y);
-  if (xd->mb_to_right_edge < 0)
-    max_blocks_wide += xd->mb_to_right_edge >> (3 + pd->subsampling_x);
-
-  max_blocks_high >>= tx_size_wide_log2[0];
-  max_blocks_wide >>= tx_size_wide_log2[0];
-
   int coeff_ctx = get_entropy_context(tx_size, a, l);
 
+#if DISABLE_TRELLISQ_SEARCH
+  av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
+                  coeff_ctx, AV1_XFORM_QUANT_B);
+
+#else
   av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
                   coeff_ctx, AV1_XFORM_QUANT_FP);
 
   av1_optimize_b(cm, x, plane, block, plane_bsize, tx_size, a, l);
+#endif  // DISABLE_TRELLISQ_SEARCH
 
 // TODO(any): Use av1_dist_block to compute distortion
 #if CONFIG_HIGHBITDEPTH
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
     rec_buffer = CONVERT_TO_BYTEPTR(rec_buffer16);
     aom_highbd_convolve_copy(dst, pd->dst.stride, rec_buffer, MAX_TX_SIZE, NULL,
                              0, NULL, 0, bw, bh, xd->bd);
   } else {
@@ -3949,65 +4254,64 @@ void av1_tx_block_rd_b(const AV1_COMP *c
     aom_convolve_copy(dst, pd->dst.stride, rec_buffer, MAX_TX_SIZE, NULL, 0,
                       NULL, 0, bw, bh);
   }
 #else
   aom_convolve_copy(dst, pd->dst.stride, rec_buffer, MAX_TX_SIZE, NULL, 0, NULL,
                     0, bw, bh);
 #endif  // CONFIG_HIGHBITDEPTH
 
-  if (blk_row + txb_h > max_blocks_high || blk_col + txb_w > max_blocks_wide) {
-    int idx, idy;
-    int blocks_height = AOMMIN(txb_h, max_blocks_high - blk_row);
-    int blocks_width = AOMMIN(txb_w, max_blocks_wide - blk_col);
-    tmp = 0;
-    for (idy = 0; idy < blocks_height; ++idy) {
-      for (idx = 0; idx < blocks_width; ++idx) {
-        const int16_t *d =
-            diff + ((idy * diff_stride + idx) << tx_size_wide_log2[0]);
-        tmp += sum_squares_2d(d, diff_stride, 0);
-      }
-    }
-  } else {
-    tmp = sum_squares_2d(diff, diff_stride, tx_size);
-  }
+  tmp = pixel_diff_dist(x, plane, diff, diff_stride, blk_row, blk_col,
+                        plane_bsize, txm_bsize);
 
 #if CONFIG_HIGHBITDEPTH
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
     tmp = ROUND_POWER_OF_TWO(tmp, (xd->bd - 8) * 2);
 #endif  // CONFIG_HIGHBITDEPTH
   rd_stats->sse += tmp * 16;
   const int eob = p->eobs[block];
 
+#if CONFIG_LGT
+  PREDICTION_MODE mode = get_prediction_mode(xd->mi[0], plane, tx_size, block);
+  av1_inverse_transform_block(xd, dqcoeff, mode, tx_type, tx_size, rec_buffer,
+                              MAX_TX_SIZE, eob);
+#else
   av1_inverse_transform_block(xd, dqcoeff, tx_type, tx_size, rec_buffer,
                               MAX_TX_SIZE, eob);
+#endif
   if (eob > 0) {
-    if (txb_w + blk_col > max_blocks_wide ||
-        txb_h + blk_row > max_blocks_high) {
-      int idx, idy;
-      unsigned int this_dist;
-      int blocks_height = AOMMIN(txb_h, max_blocks_high - blk_row);
-      int blocks_width = AOMMIN(txb_w, max_blocks_wide - blk_col);
-      tmp = 0;
-      for (idy = 0; idy < blocks_height; ++idy) {
-        for (idx = 0; idx < blocks_width; ++idx) {
-          uint8_t *const s =
-              src + ((idy * src_stride + idx) << tx_size_wide_log2[0]);
-          uint8_t *const r =
-              rec_buffer + ((idy * MAX_TX_SIZE + idx) << tx_size_wide_log2[0]);
-          cpi->fn_ptr[0].vf(s, src_stride, r, MAX_TX_SIZE, &this_dist);
-          tmp += this_dist;
-        }
-      }
-    } else {
-      uint32_t this_dist;
-      cpi->fn_ptr[txm_bsize].vf(src, src_stride, rec_buffer, MAX_TX_SIZE,
-                                &this_dist);
-      tmp = this_dist;
-    }
+#if CONFIG_DAALA_DIST
+    if (plane == 0 && (bw < 8 && bh < 8)) {
+      // Save sub8x8 luma decoded pixels
+      // since 8x8 luma decoded pixels are not available for daala-dist
+      // after recursive split of BLOCK_8x8 is done.
+      const int pred_stride = block_size_wide[plane_bsize];
+      const int pred_idx = (blk_row * pred_stride + blk_col)
+                           << tx_size_wide_log2[0];
+      int16_t *decoded = &pd->pred[pred_idx];
+      int i, j;
+
+#if CONFIG_HIGHBITDEPTH
+      if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
+        for (j = 0; j < bh; j++)
+          for (i = 0; i < bw; i++)
+            decoded[j * pred_stride + i] =
+                CONVERT_TO_SHORTPTR(rec_buffer)[j * MAX_TX_SIZE + i];
+      } else {
+#endif
+        for (j = 0; j < bh; j++)
+          for (i = 0; i < bw; i++)
+            decoded[j * pred_stride + i] = rec_buffer[j * MAX_TX_SIZE + i];
+#if CONFIG_HIGHBITDEPTH
+      }
+#endif  // CONFIG_HIGHBITDEPTH
+    }
+#endif  // CONFIG_DAALA_DIST
+    tmp = pixel_dist(cpi, x, plane, src, src_stride, rec_buffer, MAX_TX_SIZE,
+                     blk_row, blk_col, plane_bsize, txm_bsize);
   }
   rd_stats->dist += tmp * 16;
   txb_coeff_cost =
       av1_cost_coeffs(cpi, x, plane, block, tx_size, scan_order, a, l, 0);
   rd_stats->rate += txb_coeff_cost;
   rd_stats->skip &= (eob == 0);
 
 #if CONFIG_RD_DEBUG
@@ -4033,42 +4337,53 @@ static void select_tx_block(const AV1_CO
   [MAX_MIB_SIZE] =
       (TX_SIZE(*)[MAX_MIB_SIZE]) & mbmi->inter_tx_size[tx_row][tx_col];
   const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
   const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
   const int bw = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
   int64_t this_rd = INT64_MAX;
   ENTROPY_CONTEXT *pta = ta + blk_col;
   ENTROPY_CONTEXT *ptl = tl + blk_row;
-  int coeff_ctx, i;
+  int i;
   int ctx = txfm_partition_context(tx_above + blk_col, tx_left + blk_row,
                                    mbmi->sb_type, tx_size);
   int64_t sum_rd = INT64_MAX;
   int tmp_eob = 0;
   int zero_blk_rate;
   RD_STATS sum_rd_stats;
-  const int tx_size_ctx = txsize_sqr_map[tx_size];
+#if CONFIG_TXK_SEL
+  TX_TYPE best_tx_type = TX_TYPES;
+  int txk_idx = block;
+#endif
 
   av1_init_rd_stats(&sum_rd_stats);
 
   assert(tx_size < TX_SIZES_ALL);
 
   if (ref_best_rd < 0) {
     *is_cost_valid = 0;
     return;
   }
 
-  coeff_ctx = get_entropy_context(tx_size, pta, ptl);
-
   av1_init_rd_stats(rd_stats);
 
   if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
 
+#if CONFIG_LV_MAP
+  TX_SIZE txs_ctx = get_txsize_context(tx_size);
+  TXB_CTX txb_ctx;
+  get_txb_ctx(plane_bsize, tx_size, plane, pta, ptl, &txb_ctx);
+  zero_blk_rate =
+      av1_cost_bit(xd->fc->txb_skip[txs_ctx][txb_ctx.txb_skip_ctx], 1);
+#else
+  const int tx_size_ctx = txsize_sqr_map[tx_size];
+  int coeff_ctx = get_entropy_context(tx_size, pta, ptl);
   zero_blk_rate = x->token_costs[tx_size_ctx][pd->plane_type][1][0][0]
                                 [coeff_ctx][EOB_TOKEN];
+#endif
 
   if (cpi->common.tx_mode == TX_MODE_SELECT || tx_size == TX_4X4) {
     inter_tx_size[0][0] = tx_size;
 
     if (tx_size == TX_32X32 && mbmi->tx_type != DCT_DCT &&
         rd_stats_stack[block32].rate != INT_MAX) {
       *rd_stats = rd_stats_stack[block32];
       p->eobs[block] = !rd_stats->skip;
@@ -4076,18 +4391,18 @@ static void select_tx_block(const AV1_CO
     } else {
       av1_tx_block_rd_b(cpi, x, tx_size, blk_row, blk_col, plane, block,
                         plane_bsize, pta, ptl, rd_stats);
       if (tx_size == TX_32X32) {
         rd_stats_stack[block32] = *rd_stats;
       }
     }
 
-    if ((RDCOST(x->rdmult, x->rddiv, rd_stats->rate, rd_stats->dist) >=
-             RDCOST(x->rdmult, x->rddiv, zero_blk_rate, rd_stats->sse) ||
+    if ((RDCOST(x->rdmult, rd_stats->rate, rd_stats->dist) >=
+             RDCOST(x->rdmult, zero_blk_rate, rd_stats->sse) ||
          rd_stats->skip == 1) &&
         !xd->lossless[mbmi->segment_id]) {
 #if CONFIG_RD_DEBUG
       av1_update_txb_coeff_cost(rd_stats, plane, tx_size, blk_row, blk_col,
                                 zero_blk_rate - rd_stats->rate);
 #endif  // CONFIG_RD_DEBUG
       rd_stats->rate = zero_blk_rate;
       rd_stats->dist = rd_stats->sse;
@@ -4097,65 +4412,186 @@ static void select_tx_block(const AV1_CO
     } else {
       x->blk_skip[plane][blk_row * bw + blk_col] = 0;
       rd_stats->skip = 0;
     }
 
     if (tx_size > TX_4X4 && depth < MAX_VARTX_DEPTH)
       rd_stats->rate +=
           av1_cost_bit(cpi->common.fc->txfm_partition_prob[ctx], 0);
-    this_rd = RDCOST(x->rdmult, x->rddiv, rd_stats->rate, rd_stats->dist);
+    this_rd = RDCOST(x->rdmult, rd_stats->rate, rd_stats->dist);
+#if CONFIG_LV_MAP
+    tmp_eob = p->txb_entropy_ctx[block];
+#else
     tmp_eob = p->eobs[block];
+#endif
+
+#if CONFIG_TXK_SEL
+    best_tx_type = mbmi->txk_type[txk_idx];
+#endif
   }
 
   if (tx_size > TX_4X4 && depth < MAX_VARTX_DEPTH) {
     const TX_SIZE sub_txs = sub_tx_size_map[tx_size];
     const int bsl = tx_size_wide_unit[sub_txs];
     int sub_step = tx_size_wide_unit[sub_txs] * tx_size_high_unit[sub_txs];
     RD_STATS this_rd_stats;
     int this_cost_valid = 1;
     int64_t tmp_rd = 0;
-
+#if CONFIG_DAALA_DIST
+    int sub8x8_eob[4];
+#endif
     sum_rd_stats.rate =
         av1_cost_bit(cpi->common.fc->txfm_partition_prob[ctx], 1);
 
     assert(tx_size < TX_SIZES_ALL);
 
     for (i = 0; i < 4 && this_cost_valid; ++i) {
       int offsetr = blk_row + (i >> 1) * bsl;
       int offsetc = blk_col + (i & 0x01) * bsl;
 
       if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) continue;
 
       select_tx_block(cpi, x, offsetr, offsetc, plane, block, block32, sub_txs,
                       depth + 1, plane_bsize, ta, tl, tx_above, tx_left,
                       &this_rd_stats, ref_best_rd - tmp_rd, &this_cost_valid,
                       rd_stats_stack);
-
+#if CONFIG_DAALA_DIST
+      if (plane == 0 && tx_size == TX_8X8) {
+        sub8x8_eob[i] = p->eobs[block];
+      }
+#endif  // CONFIG_DAALA_DIST
       av1_merge_rd_stats(&sum_rd_stats, &this_rd_stats);
 
-      tmp_rd =
-          RDCOST(x->rdmult, x->rddiv, sum_rd_stats.rate, sum_rd_stats.dist);
+      tmp_rd = RDCOST(x->rdmult, sum_rd_stats.rate, sum_rd_stats.dist);
+#if !CONFIG_DAALA_DIST
       if (this_rd < tmp_rd) break;
+#endif
       block += sub_step;
     }
+#if CONFIG_DAALA_DIST
+    if (this_cost_valid && plane == 0 && tx_size == TX_8X8) {
+      const int src_stride = p->src.stride;
+      const int dst_stride = pd->dst.stride;
+
+      const uint8_t *src =
+          &p->src.buf[(blk_row * src_stride + blk_col) << tx_size_wide_log2[0]];
+      const uint8_t *dst =
+          &pd->dst
+               .buf[(blk_row * dst_stride + blk_col) << tx_size_wide_log2[0]];
+
+      int64_t daala_dist;
+      int qindex = x->qindex;
+      const int pred_stride = block_size_wide[plane_bsize];
+      const int pred_idx = (blk_row * pred_stride + blk_col)
+                           << tx_size_wide_log2[0];
+      int16_t *pred = &pd->pred[pred_idx];
+      int j;
+      int qm = OD_HVS_QM;
+      int use_activity_masking = 0;
+      int row, col;
+
+#if CONFIG_HIGHBITDEPTH
+      uint8_t *pred8;
+      DECLARE_ALIGNED(16, uint16_t, pred8_16[8 * 8]);
+#else
+      DECLARE_ALIGNED(16, uint8_t, pred8[8 * 8]);
+#endif  // CONFIG_HIGHBITDEPTH
+
+#if CONFIG_PVQ
+      use_activity_masking = x->daala_enc.use_activity_masking;
+#endif
+      daala_dist = av1_daala_dist(xd, src, src_stride, dst, dst_stride, 8, 8, 8,
+                                  8, qm, use_activity_masking, qindex) *
+                   16;
+      sum_rd_stats.sse = daala_dist;
+
+#if CONFIG_HIGHBITDEPTH
+      if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
+        pred8 = CONVERT_TO_BYTEPTR(pred8_16);
+      else
+        pred8 = (uint8_t *)pred8_16;
+#endif
+
+#if CONFIG_HIGHBITDEPTH
+      if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
+        for (row = 0; row < 2; ++row) {
+          for (col = 0; col < 2; ++col) {
+            int idx = row * 2 + col;
+            int eob = sub8x8_eob[idx];
+
+            if (eob > 0) {
+              for (j = 0; j < 4; j++)
+                for (i = 0; i < 4; i++)
+                  CONVERT_TO_SHORTPTR(pred8)
+                  [(row * 4 + j) * 8 + 4 * col + i] =
+                      pred[(row * 4 + j) * pred_stride + 4 * col + i];
+            } else {
+              for (j = 0; j < 4; j++)
+                for (i = 0; i < 4; i++)
+                  CONVERT_TO_SHORTPTR(pred8)
+                  [(row * 4 + j) * 8 + 4 * col + i] = CONVERT_TO_SHORTPTR(
+                      dst)[(row * 4 + j) * dst_stride + 4 * col + i];
+            }
+          }
+        }
+      } else {
+#endif
+        for (row = 0; row < 2; ++row) {
+          for (col = 0; col < 2; ++col) {
+            int idx = row * 2 + col;
+            int eob = sub8x8_eob[idx];
+
+            if (eob > 0) {
+              for (j = 0; j < 4; j++)
+                for (i = 0; i < 4; i++)
+                  pred8[(row * 4 + j) * 8 + 4 * col + i] =
+                      pred[(row * 4 + j) * pred_stride + 4 * col + i];
+            } else {
+              for (j = 0; j < 4; j++)
+                for (i = 0; i < 4; i++)
+                  pred8[(row * 4 + j) * 8 + 4 * col + i] =
+                      dst[(row * 4 + j) * dst_stride + 4 * col + i];
+            }
+          }
+        }
+#if CONFIG_HIGHBITDEPTH
+      }
+#endif  // CONFIG_HIGHBITDEPTH
+      daala_dist = av1_daala_dist(xd, src, src_stride, pred8, 8, 8, 8, 8, 8, qm,
+                                  use_activity_masking, qindex) *
+                   16;
+      sum_rd_stats.dist = daala_dist;
+      tmp_rd = RDCOST(x->rdmult, sum_rd_stats.rate, sum_rd_stats.dist);
+    }
+#endif  // CONFIG_DAALA_DIST
     if (this_cost_valid) sum_rd = tmp_rd;
   }
 
   if (this_rd < sum_rd) {
     int idx, idy;
-    for (i = 0; i < tx_size_wide_unit[tx_size]; ++i) pta[i] = !(tmp_eob == 0);
-    for (i = 0; i < tx_size_high_unit[tx_size]; ++i) ptl[i] = !(tmp_eob == 0);
+
+#if CONFIG_LV_MAP
+    p->txb_entropy_ctx[block] = tmp_eob;
+#else
+    p->eobs[block] = tmp_eob;
+#endif
+
+    av1_set_txb_context(x, plane, block, tx_size, pta, ptl);
+
     txfm_partition_update(tx_above + blk_col, tx_left + blk_row, tx_size,
                           tx_size);
     inter_tx_size[0][0] = tx_size;
     for (idy = 0; idy < tx_size_high_unit[tx_size] / 2; ++idy)
       for (idx = 0; idx < tx_size_wide_unit[tx_size] / 2; ++idx)
         inter_tx_size[idy][idx] = tx_size;
     mbmi->tx_size = tx_size;
+#if CONFIG_TXK_SEL
+    mbmi->txk_type[txk_idx] = best_tx_type;
+#endif
     if (this_rd == INT64_MAX) *is_cost_valid = 0;
     x->blk_skip[plane][blk_row * bw + blk_col] = rd_stats->skip;
   } else {
     *rd_stats = sum_rd_stats;
     if (sum_rd == INT64_MAX) *is_cost_valid = 0;
   }
 }
 
@@ -4196,27 +4632,26 @@ static void inter_block_yrd(const AV1_CO
 
     for (idy = 0; idy < mi_height; idy += bh) {
       for (idx = 0; idx < mi_width; idx += bw) {
         select_tx_block(cpi, x, idy, idx, 0, block, block32, max_tx_size,
                         mi_height != mi_width, plane_bsize, ctxa, ctxl,
                         tx_above, tx_left, &pn_rd_stats, ref_best_rd - this_rd,
                         &is_cost_valid, rd_stats_stack);
         av1_merge_rd_stats(rd_stats, &pn_rd_stats);
-        this_rd += AOMMIN(
-            RDCOST(x->rdmult, x->rddiv, pn_rd_stats.rate, pn_rd_stats.dist),
-            RDCOST(x->rdmult, x->rddiv, 0, pn_rd_stats.sse));
+        this_rd += AOMMIN(RDCOST(x->rdmult, pn_rd_stats.rate, pn_rd_stats.dist),
+                          RDCOST(x->rdmult, 0, pn_rd_stats.sse));
         block += step;
         ++block32;
       }
     }
   }
 
-  this_rd = AOMMIN(RDCOST(x->rdmult, x->rddiv, rd_stats->rate, rd_stats->dist),
-                   RDCOST(x->rdmult, x->rddiv, 0, rd_stats->sse));
+  this_rd = AOMMIN(RDCOST(x->rdmult, rd_stats->rate, rd_stats->dist),
+                   RDCOST(x->rdmult, 0, rd_stats->sse));
   if (this_rd > ref_best_rd) is_cost_valid = 0;
 
   if (!is_cost_valid) {
     // reset cost value
     av1_invalid_rd_stats(rd_stats);
   }
 }
 
@@ -4242,16 +4677,17 @@ static int64_t select_tx_size_fix_type(c
 
   if (rd_stats->rate == INT_MAX) return INT64_MAX;
 
   for (row = 0; row < max_blocks_high / 2; ++row)
     for (col = 0; col < max_blocks_wide / 2; ++col)
       mbmi->min_tx_size = AOMMIN(
           mbmi->min_tx_size, get_min_tx_size(mbmi->inter_tx_size[row][col]));
 
+#if !CONFIG_TXK_SEL
 #if CONFIG_EXT_TX
   if (get_ext_tx_types(mbmi->min_tx_size, bsize, is_inter,
                        cm->reduced_tx_set_used) > 1 &&
       !xd->lossless[xd->mi[0]->mbmi.segment_id]) {
     const int ext_tx_set = get_ext_tx_set(mbmi->min_tx_size, bsize, is_inter,
                                           cm->reduced_tx_set_used);
     if (is_inter) {
       if (ext_tx_set > 0)
@@ -4261,30 +4697,31 @@ static int64_t select_tx_size_fix_type(c
                                     [mbmi->tx_type];
     } else {
       if (ext_tx_set > 0 && ALLOW_INTRA_EXT_TX)
         rd_stats->rate +=
             cpi->intra_tx_type_costs[ext_tx_set][mbmi->min_tx_size][mbmi->mode]
                                     [mbmi->tx_type];
     }
   }
-#else   // CONFIG_EXT_TX
+#else
   if (mbmi->min_tx_size < TX_32X32 && !xd->lossless[xd->mi[0]->mbmi.segment_id])
     rd_stats->rate +=
         cpi->inter_tx_type_costs[mbmi->min_tx_size][mbmi->tx_type];
 #endif  // CONFIG_EXT_TX
+#endif  // CONFIG_TXK_SEL
 
   if (rd_stats->skip)
-    rd = RDCOST(x->rdmult, x->rddiv, s1, rd_stats->sse);
+    rd = RDCOST(x->rdmult, s1, rd_stats->sse);
   else
-    rd = RDCOST(x->rdmult, x->rddiv, rd_stats->rate + s0, rd_stats->dist);
+    rd = RDCOST(x->rdmult, rd_stats->rate + s0, rd_stats->dist);
 
   if (is_inter && !xd->lossless[xd->mi[0]->mbmi.segment_id] &&
       !(rd_stats->skip))
-    rd = AOMMIN(rd, RDCOST(x->rdmult, x->rddiv, s1, rd_stats->sse));
+    rd = AOMMIN(rd, RDCOST(x->rdmult, s1, rd_stats->sse));
 
   return rd;
 }
 
 static void select_tx_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
                                RD_STATS *rd_stats, BLOCK_SIZE bsize,
                                int64_t ref_best_rd) {
   const AV1_COMMON *cm = &cpi->common;
@@ -4294,16 +4731,22 @@ static void select_tx_type_yrd(const AV1
   int64_t rd = INT64_MAX;
   int64_t best_rd = INT64_MAX;
   TX_TYPE tx_type, best_tx_type = DCT_DCT;
   const int is_inter = is_inter_block(mbmi);
   TX_SIZE best_tx_size[MAX_MIB_SIZE][MAX_MIB_SIZE];
   TX_SIZE best_tx = max_txsize_lookup[bsize];
   TX_SIZE best_min_tx_size = TX_SIZES_ALL;
   uint8_t best_blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE * 8];
+  TX_TYPE txk_start = DCT_DCT;
+#if CONFIG_TXK_SEL
+  TX_TYPE txk_end = DCT_DCT + 1;
+#else
+  TX_TYPE txk_end = TX_TYPES;
+#endif
   const int n4 = bsize_to_num_blk(bsize);
   int idx, idy;
   int prune = 0;
   const int count32 =
       1 << (2 * (cm->mib_size_log2 - mi_width_log2_lookup[BLOCK_32X32]));
 #if CONFIG_EXT_PARTITION
   RD_STATS rd_stats_stack[16];
 #else
@@ -4321,17 +4764,17 @@ static void select_tx_type_yrd(const AV1
     prune = prune_tx_types(cpi, bsize, x, xd, 0);
 #endif  // CONFIG_EXT_TX
 
   av1_invalid_rd_stats(rd_stats);
 
   for (idx = 0; idx < count32; ++idx)
     av1_invalid_rd_stats(&rd_stats_stack[idx]);
 
-  for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
+  for (tx_type = txk_start; tx_type < txk_end; ++tx_type) {
     RD_STATS this_rd_stats;
     av1_init_rd_stats(&this_rd_stats);
 #if CONFIG_EXT_TX
     if (is_inter) {
       if (!ext_tx_used_inter[ext_tx_set][tx_type]) continue;
       if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE) {
         if (!do_tx_type_search(tx_type, prune)) continue;
       }
@@ -4493,19 +4936,18 @@ static int inter_block_uvrd(const AV1_CO
 
     if (pn_rd_stats.rate == INT_MAX) {
       is_cost_valid = 0;
       break;
     }
 
     av1_merge_rd_stats(rd_stats, &pn_rd_stats);
 
-    this_rd =
-        AOMMIN(RDCOST(x->rdmult, x->rddiv, rd_stats->rate, rd_stats->dist),
-               RDCOST(x->rdmult, x->rddiv, 0, rd_stats->sse));
+    this_rd = AOMMIN(RDCOST(x->rdmult, rd_stats->rate, rd_stats->dist),
+                     RDCOST(x->rdmult, 0, rd_stats->sse));
 
     if (this_rd > ref_best_rd) {
       is_cost_valid = 0;
       break;
     }
   }
 
   if (!is_cost_valid) {
@@ -4684,17 +5126,17 @@ static void rd_pick_palette_intra_sbuv(c
           const int color_ctx = av1_get_palette_color_index_context(
               color_map, plane_block_width, i, j, n, color_order, &color_idx);
           assert(color_idx >= 0 && color_idx < n);
           this_rate += cpi->palette_uv_color_cost[n - PALETTE_MIN_SIZE]
                                                  [color_ctx][color_idx];
         }
       }
 
-      this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, tokenonly_rd_stats.dist);
+      this_rd = RDCOST(x->rdmult, this_rate, tokenonly_rd_stats.dist);
       if (this_rd < *best_rd) {
         *best_rd = this_rd;
         *best_mbmi = *mbmi;
         memcpy(best_palette_color_map, color_map,
                plane_block_width * plane_block_height *
                    sizeof(best_palette_color_map[0]));
         *rate = this_rate;
         *distortion = tokenonly_rd_stats.dist;
@@ -4736,17 +5178,17 @@ static int rd_pick_filter_intra_sbuv(con
     mbmi->filter_intra_mode_info.filter_intra_mode[1] = mode;
     if (!super_block_uvrd(cpi, x, &tokenonly_rd_stats, bsize, *best_rd))
       continue;
 
     this_rate = tokenonly_rd_stats.rate +
                 av1_cost_bit(cpi->common.fc->filter_intra_probs[1], 1) +
                 cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode] +
                 write_uniform_cost(FILTER_INTRA_MODES, mode);
-    this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, tokenonly_rd_stats.dist);
+    this_rd = RDCOST(x->rdmult, this_rate, tokenonly_rd_stats.dist);
     if (this_rd < *best_rd) {
       *best_rd = this_rd;
       *rate = this_rate;
       *rate_tokenonly = tokenonly_rd_stats.rate;
       *distortion = tokenonly_rd_stats.dist;
       *skippable = tokenonly_rd_stats.skip;
       filter_intra_mode_info = mbmi->filter_intra_mode_info;
       filter_intra_selected_flag = 1;
@@ -4777,17 +5219,17 @@ static int64_t pick_intra_angle_routine_
   assert(!is_inter_block(mbmi));
   int this_rate;
   int64_t this_rd;
   RD_STATS tokenonly_rd_stats;
 
   if (!super_block_uvrd(cpi, x, &tokenonly_rd_stats, bsize, best_rd_in))
     return INT64_MAX;
   this_rate = tokenonly_rd_stats.rate + rate_overhead;
-  this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, tokenonly_rd_stats.dist);
+  this_rd = RDCOST(x->rdmult, this_rate, tokenonly_rd_stats.dist);
   if (this_rd < *best_rd) {
     *best_rd = this_rd;
     *best_angle_delta = mbmi->angle_delta[1];
     *rate = this_rate;
     rd_stats->rate = tokenonly_rd_stats.rate;
     rd_stats->dist = tokenonly_rd_stats.dist;
     rd_stats->skip = tokenonly_rd_stats.skip;
   }
@@ -4865,42 +5307,41 @@ static void init_sbuv_mode(MB_MODE_INFO 
 static int64_t rd_pick_intra_sbuv_mode(const AV1_COMP *const cpi, MACROBLOCK *x,
                                        int *rate, int *rate_tokenonly,
                                        int64_t *distortion, int *skippable,
                                        BLOCK_SIZE bsize, TX_SIZE max_tx_size) {
   MACROBLOCKD *xd = &x->e_mbd;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   assert(!is_inter_block(mbmi));
   MB_MODE_INFO best_mbmi = *mbmi;
-  PREDICTION_MODE mode;
   int64_t best_rd = INT64_MAX, this_rd;
-  int this_rate;
-  RD_STATS tokenonly_rd_stats;
 #if CONFIG_PVQ
   od_rollback_buffer buf;
   od_encode_checkpoint(&x->daala_enc, &buf);
 #endif  // CONFIG_PVQ
 #if CONFIG_PALETTE
   PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
-  uint8_t *best_palette_color_map = NULL;
 #endif  // CONFIG_PALETTE
 
-  for (mode = DC_PRED; mode <= TM_PRED; ++mode) {
+  for (int mode_idx = DC_PRED; mode_idx < INTRA_MODES; ++mode_idx) {
+    int this_rate;
+    RD_STATS tokenonly_rd_stats;
+    PREDICTION_MODE mode = intra_rd_search_mode_order[mode_idx];
 #if CONFIG_EXT_INTRA
     const int is_directional_mode =
         av1_is_directional_mode(mode, mbmi->sb_type);
 #endif  // CONFIG_EXT_INTRA
     if (!(cpi->sf.intra_uv_mode_mask[txsize_sqr_up_map[max_tx_size]] &
           (1 << mode)))
       continue;
 
     mbmi->uv_mode = mode;
 #if CONFIG_EXT_INTRA
     mbmi->angle_delta[1] = 0;
-    if (is_directional_mode) {
+    if (is_directional_mode && av1_use_angle_delta(mbmi->sb_type)) {
       const int rate_overhead = cpi->intra_uv_mode_cost[mbmi->mode][mode] +
                                 write_uniform_cost(2 * MAX_ANGLE_DELTA + 1, 0);
       if (!rd_pick_intra_angle_sbuv(cpi, x, bsize, rate_overhead, best_rd,
                                     &this_rate, &tokenonly_rd_stats))
         continue;
     } else {
 #endif  // CONFIG_EXT_INTRA
       if (!super_block_uvrd(cpi, x, &tokenonly_rd_stats, bsize, best_rd)) {
@@ -4911,17 +5352,17 @@ static int64_t rd_pick_intra_sbuv_mode(c
       }
 #if CONFIG_EXT_INTRA
     }
 #endif  // CONFIG_EXT_INTRA
     this_rate =
         tokenonly_rd_stats.rate + cpi->intra_uv_mode_cost[mbmi->mode][mode];
 
 #if CONFIG_EXT_INTRA
-    if (is_directional_mode) {
+    if (is_directional_mode && av1_use_angle_delta(mbmi->sb_type)) {
       this_rate += write_uniform_cost(2 * MAX_ANGLE_DELTA + 1,
                                       MAX_ANGLE_DELTA + mbmi->angle_delta[1]);
     }
 #endif  // CONFIG_EXT_INTRA
 #if CONFIG_FILTER_INTRA
     if (mbmi->sb_type >= BLOCK_8X8 && mode == DC_PRED)
       this_rate += av1_cost_bit(cpi->common.fc->filter_intra_probs[1], 0);
 #endif  // CONFIG_FILTER_INTRA
@@ -4930,31 +5371,31 @@ static int64_t rd_pick_intra_sbuv_mode(c
         mode == DC_PRED)
       this_rate += av1_cost_bit(
           av1_default_palette_uv_mode_prob[pmi->palette_size[0] > 0], 0);
 #endif  // CONFIG_PALETTE
 
 #if CONFIG_PVQ
     od_encode_rollback(&x->daala_enc, &buf);
 #endif  // CONFIG_PVQ
-    this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, tokenonly_rd_stats.dist);
+    this_rd = RDCOST(x->rdmult, this_rate, tokenonly_rd_stats.dist);
 
     if (this_rd < best_rd) {
       best_mbmi = *mbmi;
       best_rd = this_rd;
       *rate = this_rate;
       *rate_tokenonly = tokenonly_rd_stats.rate;
       *distortion = tokenonly_rd_stats.dist;
       *skippable = tokenonly_rd_stats.skip;
     }
   }
 
 #if CONFIG_PALETTE
   if (cpi->common.allow_screen_content_tools && mbmi->sb_type >= BLOCK_8X8) {
-    best_palette_color_map = x->palette_buffer->best_palette_color_map;
+    uint8_t *best_palette_color_map = x->palette_buffer->best_palette_color_map;
     rd_pick_palette_intra_sbuv(cpi, x,
                                cpi->intra_uv_mode_cost[mbmi->mode][DC_PRED],
                                best_palette_color_map, &best_mbmi, &best_rd,
                                rate, rate_tokenonly, distortion, skippable);
   }
 #endif  // CONFIG_PALETTE
 
 #if CONFIG_FILTER_INTRA
@@ -5006,16 +5447,22 @@ static void choose_intra_uv_mode(const A
 }
 
 static int cost_mv_ref(const AV1_COMP *const cpi, PREDICTION_MODE mode,
                        int16_t mode_context) {
 #if CONFIG_EXT_INTER
   if (is_inter_compound_mode(mode)) {
     return cpi
         ->inter_compound_mode_cost[mode_context][INTER_COMPOUND_OFFSET(mode)];
+#if CONFIG_COMPOUND_SINGLEREF
+  } else if (is_inter_singleref_comp_mode(mode)) {
+    return cpi
+        ->inter_singleref_comp_mode_cost[mode_context]
+                                        [INTER_SINGLEREF_COMP_OFFSET(mode)];
+#endif  // CONFIG_COMPOUND_SINGLEREF
   }
 #endif
 
   int mode_cost = 0;
   int16_t mode_ctx = mode_context & NEWMV_CTX_MASK;
   int16_t is_all_zero_mv = mode_context & (1 << ALL_ZERO_FLAG_OFFSET);
 
   assert(is_inter_mode(mode));
@@ -5091,18 +5538,23 @@ typedef struct {
 
   int64_t segment_rd;
   int r;
   int64_t d;
   int64_t sse;
   int segment_yrate;
   PREDICTION_MODE modes[4];
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+  SEG_RDSTAT rdstat[4][INTER_MODES + INTER_SINGLEREF_COMP_MODES +
+                       INTER_COMPOUND_MODES];
+#else   // !CONFIG_COMPOUND_SINGLEREF
   SEG_RDSTAT rdstat[4][INTER_MODES + INTER_COMPOUND_MODES];
-#else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+#else   // !CONFIG_EXT_INTER
   SEG_RDSTAT rdstat[4][INTER_MODES];
 #endif  // CONFIG_EXT_INTER
   int mvthresh;
 } BEST_SEG_INFO;
 
 static INLINE int mv_check_bounds(const MvLimits *mv_limits, const MV *mv) {
   return (mv->row >> 3) < mv_limits->row_min ||
          (mv->row >> 3) > mv_limits->row_max ||
@@ -5115,37 +5567,38 @@ static INLINE int mv_check_bounds(const 
 static int check_best_zero_mv(
     const AV1_COMP *const cpi, const int16_t mode_context[TOTAL_REFS_PER_FRAME],
 #if CONFIG_EXT_INTER
     const int16_t compound_mode_context[TOTAL_REFS_PER_FRAME],
 #endif  // CONFIG_EXT_INTER
     int_mv frame_mv[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME], int this_mode,
     const MV_REFERENCE_FRAME ref_frames[2], const BLOCK_SIZE bsize, int block,
     int mi_row, int mi_col) {
-  int_mv zeromv[2];
+  int_mv zeromv[2] = { {.as_int = 0 } };
+#if CONFIG_GLOBAL_MOTION
   int comp_pred_mode = ref_frames[1] > INTRA_FRAME;
-  int cur_frm;
+#endif
   (void)mi_row;
   (void)mi_col;
-  for (cur_frm = 0; cur_frm < 1 + comp_pred_mode; cur_frm++) {
 #if CONFIG_GLOBAL_MOTION
-    if (this_mode == ZEROMV
+  if (this_mode == ZEROMV
 #if CONFIG_EXT_INTER
-        || this_mode == ZERO_ZEROMV
+      || this_mode == ZERO_ZEROMV
 #endif  // CONFIG_EXT_INTER
-        )
+      ) {
+    for (int cur_frm = 0; cur_frm < 1 + comp_pred_mode; cur_frm++) {
       zeromv[cur_frm].as_int =
           gm_get_motion_vector(&cpi->common.global_motion[ref_frames[cur_frm]],
                                cpi->common.allow_high_precision_mv, bsize,
                                mi_col, mi_row, block)
               .as_int;
-    else
+    }
+  }
 #endif  // CONFIG_GLOBAL_MOTION
-      zeromv[cur_frm].as_int = 0;
-  }
+
 #if !CONFIG_EXT_INTER
   assert(ref_frames[1] != INTRA_FRAME);  // Just sanity check
 #endif                                   // !CONFIG_EXT_INTER
   if ((this_mode == NEARMV || this_mode == NEARESTMV || this_mode == ZEROMV) &&
       frame_mv[this_mode][ref_frames[0]].as_int == zeromv[0].as_int &&
       (ref_frames[1] <= INTRA_FRAME ||
        frame_mv[this_mode][ref_frames[1]].as_int == zeromv[1].as_int)) {
     int16_t rfc =
@@ -5196,57 +5649,72 @@ static int check_best_zero_mv(
         return 0;
     }
   }
 #endif  // CONFIG_EXT_INTER
   return 1;
 }
 
 static void joint_motion_search(const AV1_COMP *cpi, MACROBLOCK *x,
-                                BLOCK_SIZE bsize, int_mv *frame_mv, int mi_row,
-                                int mi_col,
+                                BLOCK_SIZE bsize, int_mv *frame_mv,
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+                                int_mv *frame_comp_mv,
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+                                int mi_row, int mi_col,
 #if CONFIG_EXT_INTER
                                 int_mv *ref_mv_sub8x8[2], const uint8_t *mask,
                                 int mask_stride,
 #endif  // CONFIG_EXT_INTER
                                 int *rate_mv, const int block) {
   const AV1_COMMON *const cm = &cpi->common;
   const int pw = block_size_wide[bsize];
   const int ph = block_size_high[bsize];
   MACROBLOCKD *xd = &x->e_mbd;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
-  // This function should only ever be called for compound modes
+// This function should only ever be called for compound modes
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  if (!has_second_ref(mbmi)) {
+    assert(is_inter_singleref_comp_mode(mbmi->mode));
+    assert(frame_comp_mv);
+  }
+  assert(has_second_ref(mbmi) || is_inter_singleref_comp_mode(mbmi->mode));
+  const int refs[2] = { mbmi->ref_frame[0], has_second_ref(mbmi)
+                                                ? mbmi->ref_frame[1]
+                                                : mbmi->ref_frame[0] };
+#else
   assert(has_second_ref(mbmi));
   const int refs[2] = { mbmi->ref_frame[0], mbmi->ref_frame[1] };
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   int_mv ref_mv[2];
   int ite, ref;
-#if CONFIG_DUAL_FILTER
-  InterpFilter interp_filter[4] = {
-    mbmi->interp_filter[0], mbmi->interp_filter[1], mbmi->interp_filter[2],
-    mbmi->interp_filter[3],
-  };
-#else
-  const InterpFilter interp_filter = mbmi->interp_filter;
-#endif  // CONFIG_DUAL_FILTER
   struct scale_factors sf;
-  struct macroblockd_plane *const pd = &xd->plane[0];
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
   // ic and ir are the 4x4 coordiantes of the sub8x8 at index "block"
   const int ic = block & 1;
   const int ir = (block - ic) >> 1;
+  struct macroblockd_plane *const pd = &xd->plane[0];
   const int p_col = ((mi_col * MI_SIZE) >> pd->subsampling_x) + 4 * ic;
   const int p_row = ((mi_row * MI_SIZE) >> pd->subsampling_y) + 4 * ir;
 #if CONFIG_GLOBAL_MOTION
   int is_global[2];
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  for (ref = 0; ref < 1 + has_second_ref(mbmi); ++ref) {
+#else
   for (ref = 0; ref < 2; ++ref) {
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
     WarpedMotionParams *const wm =
         &xd->global_motion[xd->mi[0]->mbmi.ref_frame[ref]];
     is_global[ref] = is_global_mv_block(xd->mi[0], block, wm->wmtype);
   }
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  if (!has_second_ref(mbmi)) is_global[1] = is_global[0];
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 #endif  // CONFIG_GLOBAL_MOTION
+#else   // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
+  (void)block;
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 
   // Do joint motion search in compound mode to get more accurate mv.
   struct buf_2d backup_yv12[2][MAX_MB_PLANE];
   int last_besterr[2] = { INT_MAX, INT_MAX };
   const YV12_BUFFER_CONFIG *const scaled_ref_frame[2] = {
     av1_get_scaled_ref_frame(cpi, refs[0]),
     av1_get_scaled_ref_frame(cpi, refs[1])
@@ -5259,17 +5727,21 @@ static void joint_motion_search(const AV
 #else
   DECLARE_ALIGNED(16, uint8_t, second_pred[MAX_SB_SQUARE]);
 #endif  // CONFIG_HIGHBITDEPTH
 
 #if CONFIG_EXT_INTER && CONFIG_CB4X4
   (void)ref_mv_sub8x8;
 #endif  // CONFIG_EXT_INTER && CONFIG_CB4X4
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  for (ref = 0; ref < 1 + has_second_ref(mbmi); ++ref) {
+#else
   for (ref = 0; ref < 2; ++ref) {
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_EXT_INTER && !CONFIG_CB4X4
     if (bsize < BLOCK_8X8 && ref_mv_sub8x8 != NULL)
       ref_mv[ref].as_int = ref_mv_sub8x8[ref]->as_int;
     else
 #endif  // CONFIG_EXT_INTER && !CONFIG_CB4X4
       ref_mv[ref] = x->mbmi_ext->ref_mvs[refs[ref]][0];
 
     if (scaled_ref_frame[ref]) {
@@ -5279,99 +5751,143 @@ static void joint_motion_search(const AV
       // motion search code to be used without additional modifications.
       for (i = 0; i < MAX_MB_PLANE; i++)
         backup_yv12[ref][i] = xd->plane[i].pre[ref];
       av1_setup_pre_planes(xd, ref, scaled_ref_frame[ref], mi_row, mi_col,
                            NULL);
     }
   }
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  if (!has_second_ref(mbmi)) {
+    assert(is_inter_singleref_comp_mode(mbmi->mode));
+    // NOTE: For single ref comp mode, set up the 2nd set of ref_mv/pre_planes
+    //       all from the 1st reference frame, i.e. refs[0].
+    ref_mv[1] = x->mbmi_ext->ref_mvs[refs[0]][0];
+    if (scaled_ref_frame[0]) {
+      int i;
+      // Swap out the reference frame for a version that's been scaled to
+      // match the resolution of the current frame, allowing the existing
+      // motion search code to be used without additional modifications.
+      for (i = 0; i < MAX_MB_PLANE; i++)
+        backup_yv12[1][i] = xd->plane[i].pre[1];
+      av1_setup_pre_planes(xd, 1, scaled_ref_frame[0], mi_row, mi_col, NULL);
+    }
+  }
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
 // Since we have scaled the reference frames to match the size of the current
 // frame we must use a unit scaling factor during mode selection.
 #if CONFIG_HIGHBITDEPTH
   av1_setup_scale_factors_for_frame(&sf, cm->width, cm->height, cm->width,
                                     cm->height, cm->use_highbitdepth);
 #else
   av1_setup_scale_factors_for_frame(&sf, cm->width, cm->height, cm->width,
                                     cm->height);
 #endif  // CONFIG_HIGHBITDEPTH
 
-  // Allow joint search multiple times iteratively for each reference frame
-  // and break out of the search loop if it couldn't find a better mv.
+// Allow joint search multiple times iteratively for each reference frame
+// and break out of the search loop if it couldn't find a better mv.
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  const int num_ites =
+      (has_second_ref(mbmi) || mbmi->mode == SR_NEW_NEWMV) ? 4 : 1;
+  const int start_ite = has_second_ref(mbmi) ? 0 : 1;
+  for (ite = start_ite; ite < (start_ite + num_ites); ite++) {
+#else
   for (ite = 0; ite < 4; ite++) {
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
     struct buf_2d ref_yv12[2];
     int bestsme = INT_MAX;
     int sadpb = x->sadperbit16;
     MV *const best_mv = &x->best_mv.as_mv;
     int search_range = 3;
 
     MvLimits tmp_mv_limits = x->mv_limits;
     int id = ite % 2;  // Even iterations search in the first reference frame,
                        // odd iterations search in the second. The predictor
                        // found for the 'other' reference frame is factored in.
     const int plane = 0;
-    ConvolveParams conv_params = get_conv_params(0, plane);
+    ConvolveParams conv_params = get_conv_params(!id, 0, plane);
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
     WarpTypesAllowed warp_types;
 #if CONFIG_GLOBAL_MOTION
     warp_types.global_warp_allowed = is_global[!id];
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_WARPED_MOTION
     warp_types.local_warp_allowed = mbmi->motion_mode == WARPED_CAUSAL;
 #endif  // CONFIG_WARPED_MOTION
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 
     // Initialized here because of compiler problem in Visual Studio.
     ref_yv12[0] = xd->plane[plane].pre[0];
     ref_yv12[1] = xd->plane[plane].pre[1];
 
-#if CONFIG_DUAL_FILTER
-    // reload the filter types
-    interp_filter[0] =
-        (id == 0) ? mbmi->interp_filter[2] : mbmi->interp_filter[0];
-    interp_filter[1] =
-        (id == 0) ? mbmi->interp_filter[3] : mbmi->interp_filter[1];
-#endif  // CONFIG_DUAL_FILTER
-
 // Get the prediction block from the 'other' reference frame.
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    MV *const the_other_mv = (has_second_ref(mbmi) || id)
+                                 ? &frame_mv[refs[!id]].as_mv
+                                 : &frame_comp_mv[refs[0]].as_mv;
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
 #if CONFIG_HIGHBITDEPTH
     if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
       second_pred = CONVERT_TO_BYTEPTR(second_pred_alloc_16);
       av1_highbd_build_inter_predictor(
           ref_yv12[!id].buf, ref_yv12[!id].stride, second_pred, pw,
-          &frame_mv[refs[!id]].as_mv, &sf, pw, ph, 0, interp_filter,
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+          the_other_mv,
+#else   // !(CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF)
+          &frame_mv[refs[!id]].as_mv,
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+          &sf, pw, ph, 0, mbmi->interp_filter,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
           &warp_types, p_col, p_row,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
           plane, MV_PRECISION_Q3, mi_col * MI_SIZE, mi_row * MI_SIZE, xd);
     } else {
       second_pred = (uint8_t *)second_pred_alloc_16;
 #endif  // CONFIG_HIGHBITDEPTH
       av1_build_inter_predictor(
           ref_yv12[!id].buf, ref_yv12[!id].stride, second_pred, pw,
-          &frame_mv[refs[!id]].as_mv, &sf, pw, ph, &conv_params, interp_filter,
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+          the_other_mv,
+#else   // !(CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF)
+        &frame_mv[refs[!id]].as_mv,
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+          &sf, pw, ph, &conv_params, mbmi->interp_filter,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
           &warp_types, p_col, p_row, plane, !id,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
           MV_PRECISION_Q3, mi_col * MI_SIZE, mi_row * MI_SIZE, xd);
 #if CONFIG_HIGHBITDEPTH
     }
 #endif  // CONFIG_HIGHBITDEPTH
 
     // Do compound motion search on the current reference frame.
     if (id) xd->plane[plane].pre[0] = ref_yv12[id];
     av1_set_mv_search_range(&x->mv_limits, &ref_mv[id].as_mv);
 
-    // Use the mv result from the single mode as mv predictor.
-    *best_mv = frame_mv[refs[id]].as_mv;
+// Use the mv result from the single mode as mv predictor.
+// Use the mv result from the single mode as mv predictor.
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    if (!has_second_ref(mbmi) && id)
+      *best_mv = frame_comp_mv[refs[0]].as_mv;
+    else
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+      *best_mv = frame_mv[refs[id]].as_mv;
 
     best_mv->col >>= 3;
     best_mv->row >>= 3;
 
-    av1_set_mvcost(x, refs[id], id, mbmi->ref_mv_idx);
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    if (!has_second_ref(mbmi))
+      av1_set_mvcost(x, refs[0], 0, mbmi->ref_mv_idx);
+    else
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+      av1_set_mvcost(x, refs[id], id, mbmi->ref_mv_idx);
 
     // Small-range full-pixel motion search.
     bestsme =
         av1_refining_search_8p_c(x, sadpb, search_range, &cpi->fn_ptr[bsize],
 #if CONFIG_EXT_INTER
                                  mask, mask_stride, id,
 #endif
                                  &ref_mv[id].as_mv, second_pred);
@@ -5387,111 +5903,136 @@ static void joint_motion_search(const AV
                                         second_pred, &cpi->fn_ptr[bsize], 1);
     }
 
     x->mv_limits = tmp_mv_limits;
 
     if (bestsme < INT_MAX) {
       int dis; /* TODO: use dis in distortion calculation later. */
       unsigned int sse;
-      if (cpi->sf.use_upsampled_references) {
-        // Use up-sampled reference frames.
-        struct buf_2d backup_pred = pd->pre[0];
-        const YV12_BUFFER_CONFIG *upsampled_ref =
-            get_upsampled_ref(cpi, refs[id]);
-
-        // Set pred for Y plane
-        setup_pred_plane(&pd->pre[0], bsize, upsampled_ref->y_buffer,
-                         upsampled_ref->y_crop_width,
-                         upsampled_ref->y_crop_height, upsampled_ref->y_stride,
-                         (mi_row << 3), (mi_col << 3), NULL, pd->subsampling_x,
-                         pd->subsampling_y);
-
-// If bsize < BLOCK_8X8, adjust pred pointer for this block
-#if !CONFIG_CB4X4
-        if (bsize < BLOCK_8X8)
-          pd->pre[0].buf =
-              &pd->pre[0].buf[(av1_raster_block_offset(BLOCK_8X8, block,
-                                                       pd->pre[0].stride))
-                              << 3];
-#endif  // !CONFIG_CB4X4
-
-        bestsme = cpi->find_fractional_mv_step(
-            x, &ref_mv[id].as_mv, cpi->common.allow_high_precision_mv,
-            x->errorperbit, &cpi->fn_ptr[bsize], 0,
-            cpi->sf.mv.subpel_iters_per_step, NULL, x->nmvjointcost, x->mvcost,
-            &dis, &sse, second_pred,
+      bestsme = cpi->find_fractional_mv_step(
+          x, &ref_mv[id].as_mv, cpi->common.allow_high_precision_mv,
+          x->errorperbit, &cpi->fn_ptr[bsize], 0,
+          cpi->sf.mv.subpel_iters_per_step, NULL, x->nmvjointcost, x->mvcost,
+          &dis, &sse, second_pred,
 #if CONFIG_EXT_INTER
-            mask, mask_stride, id,
-#endif
-            pw, ph, 1);
-
-        // Restore the reference frames.
-        pd->pre[0] = backup_pred;
-      } else {
-        (void)block;
-        bestsme = cpi->find_fractional_mv_step(
-            x, &ref_mv[id].as_mv, cpi->common.allow_high_precision_mv,
-            x->errorperbit, &cpi->fn_ptr[bsize], 0,
-            cpi->sf.mv.subpel_iters_per_step, NULL, x->nmvjointcost, x->mvcost,
-            &dis, &sse, second_pred,
-#if CONFIG_EXT_INTER
-            mask, mask_stride, id,
-#endif
-            pw, ph, 0);
-      }
+          mask, mask_stride, id,
+#endif
+          pw, ph, cpi->sf.use_upsampled_references);
     }
 
     // Restore the pointer to the first (possibly scaled) prediction buffer.
     if (id) xd->plane[plane].pre[0] = ref_yv12[0];
 
     if (bestsme < last_besterr[id]) {
-      frame_mv[refs[id]].as_mv = *best_mv;
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+      // NOTE: For single ref comp mode, frame_mv stores the first mv and
+      //       frame_comp_mv stores the second mv.
+      if (!has_second_ref(mbmi) && id)
+        frame_comp_mv[refs[0]].as_mv = *best_mv;
+      else
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+        frame_mv[refs[id]].as_mv = *best_mv;
       last_besterr[id] = bestsme;
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+      if (!has_second_ref(mbmi)) last_besterr[!id] = last_besterr[id];
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
     } else {
       break;
     }
   }
 
   *rate_mv = 0;
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  for (ref = 0; ref < 1 + has_second_ref(mbmi); ++ref) {
+#else
   for (ref = 0; ref < 2; ++ref) {
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
     if (scaled_ref_frame[ref]) {
       // Restore the prediction frame pointers to their unscaled versions.
       int i;
       for (i = 0; i < MAX_MB_PLANE; i++)
         xd->plane[i].pre[ref] = backup_yv12[ref][i];
     }
-    av1_set_mvcost(x, refs[ref], ref, mbmi->ref_mv_idx);
-#if CONFIG_EXT_INTER && !CONFIG_CB4X4
-    if (bsize >= BLOCK_8X8)
-#endif  // CONFIG_EXT_INTER && !CONFIG_CB4X4
-      *rate_mv += av1_mv_bit_cost(&frame_mv[refs[ref]].as_mv,
-                                  &x->mbmi_ext->ref_mvs[refs[ref]][0].as_mv,
-                                  x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
-#if CONFIG_EXT_INTER && !CONFIG_CB4X4
+
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    if (!has_second_ref(mbmi))
+      av1_set_mvcost(x, refs[0], 0, mbmi->ref_mv_idx);
     else
-      *rate_mv += av1_mv_bit_cost(&frame_mv[refs[ref]].as_mv,
-                                  &ref_mv_sub8x8[ref]->as_mv, x->nmvjointcost,
-                                  x->mvcost, MV_COST_WEIGHT);
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+      av1_set_mvcost(x, refs[ref], ref, mbmi->ref_mv_idx);
+
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    if (!has_second_ref(mbmi)) {
+      // NOTE: For single ref comp mode, i.e. !has_second_ref(mbmi) is true, the
+      //       first mv is stored in frame_mv[] and the second mv is stored in
+      //       frame_comp_mv[].
+      if (compound_ref0_mode(mbmi->mode) == NEWMV)  // SR_NEW_NEWMV
+        *rate_mv += av1_mv_bit_cost(&frame_mv[refs[0]].as_mv,
+                                    &x->mbmi_ext->ref_mvs[refs[0]][0].as_mv,
+                                    x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
+      assert(compound_ref1_mode(mbmi->mode) == NEWMV);
+      *rate_mv += av1_mv_bit_cost(&frame_comp_mv[refs[0]].as_mv,
+                                  &x->mbmi_ext->ref_mvs[refs[0]][0].as_mv,
+                                  x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
+    } else {
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+#if CONFIG_EXT_INTER && !CONFIG_CB4X4
+      if (bsize >= BLOCK_8X8)
 #endif  // CONFIG_EXT_INTER && !CONFIG_CB4X4
-  }
-}
-
-static void estimate_ref_frame_costs(const AV1_COMMON *cm,
-                                     const MACROBLOCKD *xd, int segment_id,
-                                     unsigned int *ref_costs_single,
-                                     unsigned int *ref_costs_comp,
-                                     aom_prob *comp_mode_p) {
+        *rate_mv += av1_mv_bit_cost(&frame_mv[refs[ref]].as_mv,
+                                    &x->mbmi_ext->ref_mvs[refs[ref]][0].as_mv,
+                                    x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
+#if CONFIG_EXT_INTER && !CONFIG_CB4X4
+      else
+        *rate_mv += av1_mv_bit_cost(&frame_mv[refs[ref]].as_mv,
+                                    &ref_mv_sub8x8[ref]->as_mv, x->nmvjointcost,
+                                    x->mvcost, MV_COST_WEIGHT);
+#endif  // CONFIG_EXT_INTER && !CONFIG_CB4X4
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    }
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  }
+
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  if (!has_second_ref(mbmi)) {
+    if (scaled_ref_frame[0]) {
+      // Restore the prediction frame pointers to their unscaled versions.
+      int i;
+      for (i = 0; i < MAX_MB_PLANE; i++)
+        xd->plane[i].pre[1] = backup_yv12[1][i];
+    }
+  }
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+}
+
+static void estimate_ref_frame_costs(
+    const AV1_COMMON *cm, const MACROBLOCKD *xd, int segment_id,
+    unsigned int *ref_costs_single,
+#if CONFIG_EXT_COMP_REFS
+    unsigned int (*ref_costs_comp)[TOTAL_REFS_PER_FRAME],
+#else
+    unsigned int *ref_costs_comp,
+#endif  // CONFIG_EXT_COMP_REFS
+    aom_prob *comp_mode_p) {
   int seg_ref_active =
       segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME);
   if (seg_ref_active) {
     memset(ref_costs_single, 0,
            TOTAL_REFS_PER_FRAME * sizeof(*ref_costs_single));
+#if CONFIG_EXT_COMP_REFS
+    int ref_frame;
+    for (ref_frame = 0; ref_frame < TOTAL_REFS_PER_FRAME; ++ref_frame)
+      memset(ref_costs_comp[ref_frame], 0,
+             TOTAL_REFS_PER_FRAME * sizeof((*ref_costs_comp)[0]));
+#else
     memset(ref_costs_comp, 0, TOTAL_REFS_PER_FRAME * sizeof(*ref_costs_comp));
+#endif  // CONFIG_EXT_COMP_REFS
+
     *comp_mode_p = 128;
   } else {
     aom_prob intra_inter_p = av1_get_intra_inter_prob(cm, xd);
     aom_prob comp_inter_p = 128;
 
     if (cm->reference_mode == REFERENCE_MODE_SELECT) {
       comp_inter_p = av1_get_reference_mode_prob(cm, xd);
       *comp_mode_p = comp_inter_p;
@@ -5516,37 +6057,73 @@ static void estimate_ref_frame_costs(con
 #if CONFIG_EXT_REFS
           ref_costs_single[LAST2_FRAME] = ref_costs_single[LAST3_FRAME] =
               ref_costs_single[BWDREF_FRAME] =
 #endif  // CONFIG_EXT_REFS
                   ref_costs_single[GOLDEN_FRAME] =
                       ref_costs_single[ALTREF_FRAME] = base_cost;
 
 #if CONFIG_EXT_REFS
-      ref_costs_single[LAST_FRAME] += av1_cost_bit(ref_single_p1, 0);
-      ref_costs_single[LAST2_FRAME] += av1_cost_bit(ref_single_p1, 0);
-      ref_costs_single[LAST3_FRAME] += av1_cost_bit(ref_single_p1, 0);
-      ref_costs_single[GOLDEN_FRAME] += av1_cost_bit(ref_single_p1, 0);
-      ref_costs_single[BWDREF_FRAME] += av1_cost_bit(ref_single_p1, 1);
-      ref_costs_single[ALTREF_FRAME] += av1_cost_bit(ref_single_p1, 1);
-
-      ref_costs_single[LAST_FRAME] += av1_cost_bit(ref_single_p3, 0);
-      ref_costs_single[LAST2_FRAME] += av1_cost_bit(ref_single_p3, 0);
-      ref_costs_single[LAST3_FRAME] += av1_cost_bit(ref_single_p3, 1);
-      ref_costs_single[GOLDEN_FRAME] += av1_cost_bit(ref_single_p3, 1);
-
-      ref_costs_single[BWDREF_FRAME] += av1_cost_bit(ref_single_p2, 0);
-      ref_costs_single[ALTREF_FRAME] += av1_cost_bit(ref_single_p2, 1);
-
-      ref_costs_single[LAST_FRAME] += av1_cost_bit(ref_single_p4, 0);
-      ref_costs_single[LAST2_FRAME] += av1_cost_bit(ref_single_p4, 1);
-
-      ref_costs_single[LAST3_FRAME] += av1_cost_bit(ref_single_p5, 0);
-      ref_costs_single[GOLDEN_FRAME] += av1_cost_bit(ref_single_p5, 1);
-#else
+#if CONFIG_VAR_REFS
+      // Test need to explicitly code (L,L2,L3,G) vs (BWD,ALT) branch node in
+      // tree
+      if ((L_OR_L2(cm) || L3_OR_G(cm)) && BWD_OR_ALT(cm)) {
+#endif  // CONFIG_VAR_REFS
+        ref_costs_single[LAST_FRAME] += av1_cost_bit(ref_single_p1, 0);
+        ref_costs_single[LAST2_FRAME] += av1_cost_bit(ref_single_p1, 0);
+        ref_costs_single[LAST3_FRAME] += av1_cost_bit(ref_single_p1, 0);
+        ref_costs_single[GOLDEN_FRAME] += av1_cost_bit(ref_single_p1, 0);
+        ref_costs_single[BWDREF_FRAME] += av1_cost_bit(ref_single_p1, 1);
+        ref_costs_single[ALTREF_FRAME] += av1_cost_bit(ref_single_p1, 1);
+#if CONFIG_VAR_REFS
+      }
+#endif  // CONFIG_VAR_REFS
+
+#if CONFIG_VAR_REFS
+      // Test need to explicitly code (L,L2) vs (L3,G) branch node in tree
+      if (L_OR_L2(cm) && L3_OR_G(cm)) {
+#endif  // CONFIG_VAR_REFS
+        ref_costs_single[LAST_FRAME] += av1_cost_bit(ref_single_p3, 0);
+        ref_costs_single[LAST2_FRAME] += av1_cost_bit(ref_single_p3, 0);
+        ref_costs_single[LAST3_FRAME] += av1_cost_bit(ref_single_p3, 1);
+        ref_costs_single[GOLDEN_FRAME] += av1_cost_bit(ref_single_p3, 1);
+#if CONFIG_VAR_REFS
+      }
+#endif  // CONFIG_VAR_REFS
+
+#if CONFIG_VAR_REFS
+      // Test need to explicitly code (BWD) vs (ALT) branch node in tree
+      if (BWD_AND_ALT(cm)) {
+#endif  // CONFIG_VAR_REFS
+        ref_costs_single[BWDREF_FRAME] += av1_cost_bit(ref_single_p2, 0);
+        ref_costs_single[ALTREF_FRAME] += av1_cost_bit(ref_single_p2, 1);
+#if CONFIG_VAR_REFS
+      }
+#endif  // CONFIG_VAR_REFS
+
+#if CONFIG_VAR_REFS
+      // Test need to explicitly code (L) vs (L2) branch node in tree
+      if (L_AND_L2(cm)) {
+#endif  // CONFIG_VAR_REFS
+        ref_costs_single[LAST_FRAME] += av1_cost_bit(ref_single_p4, 0);
+        ref_costs_single[LAST2_FRAME] += av1_cost_bit(ref_single_p4, 1);
+#if CONFIG_VAR_REFS
+      }
+#endif  // CONFIG_VAR_REFS
+
+#if CONFIG_VAR_REFS
+      // Test need to explicitly code (L3) vs (G) branch node in tree
+      if (L3_AND_G(cm)) {
+#endif  // CONFIG_VAR_REFS
+        ref_costs_single[LAST3_FRAME] += av1_cost_bit(ref_single_p5, 0);
+        ref_costs_single[GOLDEN_FRAME] += av1_cost_bit(ref_single_p5, 1);
+#if CONFIG_VAR_REFS
+      }
+#endif  // CONFIG_VAR_REFS
+#else   // !CONFIG_EXT_REFS
       ref_costs_single[LAST_FRAME] += av1_cost_bit(ref_single_p1, 0);
       ref_costs_single[GOLDEN_FRAME] += av1_cost_bit(ref_single_p1, 1);
       ref_costs_single[ALTREF_FRAME] += av1_cost_bit(ref_single_p1, 1);
 
       ref_costs_single[GOLDEN_FRAME] += av1_cost_bit(ref_single_p2, 0);
       ref_costs_single[ALTREF_FRAME] += av1_cost_bit(ref_single_p2, 1);
 #endif  // CONFIG_EXT_REFS
     } else {
@@ -5565,55 +6142,146 @@ static void estimate_ref_frame_costs(con
 #if CONFIG_EXT_REFS
       aom_prob ref_comp_p1 = av1_get_pred_prob_comp_ref_p1(cm, xd);
       aom_prob ref_comp_p2 = av1_get_pred_prob_comp_ref_p2(cm, xd);
       aom_prob bwdref_comp_p = av1_get_pred_prob_comp_bwdref_p(cm, xd);
 #endif  // CONFIG_EXT_REFS
 
       unsigned int base_cost = av1_cost_bit(intra_inter_p, 1);
 
+#if CONFIG_EXT_COMP_REFS
+      aom_prob comp_ref_type_p = av1_get_comp_reference_type_prob(cm, xd);
+      unsigned int ref_bicomp_costs[TOTAL_REFS_PER_FRAME] = { 0 };
+
+      ref_bicomp_costs[LAST_FRAME] = ref_bicomp_costs[LAST2_FRAME] =
+          ref_bicomp_costs[LAST3_FRAME] = ref_bicomp_costs[GOLDEN_FRAME] =
+#if USE_UNI_COMP_REFS
+              base_cost + av1_cost_bit(comp_ref_type_p, 1);
+#else
+              base_cost;
+#endif  // USE_UNI_COMP_REFS
+      ref_bicomp_costs[BWDREF_FRAME] = ref_bicomp_costs[ALTREF_FRAME] = 0;
+
+      ref_bicomp_costs[LAST_FRAME] += av1_cost_bit(ref_comp_p, 0);
+      ref_bicomp_costs[LAST2_FRAME] += av1_cost_bit(ref_comp_p, 0);
+      ref_bicomp_costs[LAST3_FRAME] += av1_cost_bit(ref_comp_p, 1);
+      ref_bicomp_costs[GOLDEN_FRAME] += av1_cost_bit(ref_comp_p, 1);
+
+      ref_bicomp_costs[LAST_FRAME] += av1_cost_bit(ref_comp_p1, 1);
+      ref_bicomp_costs[LAST2_FRAME] += av1_cost_bit(ref_comp_p1, 0);
+
+      ref_bicomp_costs[LAST3_FRAME] += av1_cost_bit(ref_comp_p2, 0);
+      ref_bicomp_costs[GOLDEN_FRAME] += av1_cost_bit(ref_comp_p2, 1);
+
+      ref_bicomp_costs[BWDREF_FRAME] += av1_cost_bit(bwdref_comp_p, 0);
+      ref_bicomp_costs[ALTREF_FRAME] += av1_cost_bit(bwdref_comp_p, 1);
+
+      int ref0;
+      for (ref0 = LAST_FRAME; ref0 <= GOLDEN_FRAME; ++ref0) {
+        ref_costs_comp[ref0][BWDREF_FRAME] =
+            ref_bicomp_costs[ref0] + ref_bicomp_costs[BWDREF_FRAME];
+        ref_costs_comp[ref0][ALTREF_FRAME] =
+            ref_bicomp_costs[ref0] + ref_bicomp_costs[ALTREF_FRAME];
+      }
+
+      aom_prob uni_comp_ref_p = av1_get_pred_prob_uni_comp_ref_p(cm, xd);
+      aom_prob uni_comp_ref_p1 = av1_get_pred_prob_uni_comp_ref_p1(cm, xd);
+
+      ref_costs_comp[LAST_FRAME][LAST2_FRAME] =
+          base_cost + av1_cost_bit(comp_ref_type_p, 0) +
+          av1_cost_bit(uni_comp_ref_p, 0) + av1_cost_bit(uni_comp_ref_p1, 0);
+      ref_costs_comp[LAST_FRAME][GOLDEN_FRAME] =
+          base_cost + av1_cost_bit(comp_ref_type_p, 0) +
+          av1_cost_bit(uni_comp_ref_p, 0) + av1_cost_bit(uni_comp_ref_p1, 1);
+
+      ref_costs_comp[BWDREF_FRAME][ALTREF_FRAME] =
+          base_cost + av1_cost_bit(comp_ref_type_p, 0) +
+          av1_cost_bit(uni_comp_ref_p, 1);
+
+#else  // !CONFIG_EXT_COMP_REFS
+
       ref_costs_comp[LAST_FRAME] =
 #if CONFIG_EXT_REFS
           ref_costs_comp[LAST2_FRAME] = ref_costs_comp[LAST3_FRAME] =
 #endif  // CONFIG_EXT_REFS
               ref_costs_comp[GOLDEN_FRAME] = base_cost;
 
 #if CONFIG_EXT_REFS
       ref_costs_comp[BWDREF_FRAME] = ref_costs_comp[ALTREF_FRAME] = 0;
 #endif  // CONFIG_EXT_REFS
 
 #if CONFIG_EXT_REFS
-      ref_costs_comp[LAST_FRAME] += av1_cost_bit(ref_comp_p, 0);
-      ref_costs_comp[LAST2_FRAME] += av1_cost_bit(ref_comp_p, 0);
-      ref_costs_comp[LAST3_FRAME] += av1_cost_bit(ref_comp_p, 1);
-      ref_costs_comp[GOLDEN_FRAME] += av1_cost_bit(ref_comp_p, 1);
-
-      ref_costs_comp[LAST_FRAME] += av1_cost_bit(ref_comp_p1, 1);
-      ref_costs_comp[LAST2_FRAME] += av1_cost_bit(ref_comp_p1, 0);
-
-      ref_costs_comp[LAST3_FRAME] += av1_cost_bit(ref_comp_p2, 0);
-      ref_costs_comp[GOLDEN_FRAME] += av1_cost_bit(ref_comp_p2, 1);
-
-      // NOTE(zoeliu): BWDREF and ALTREF each add an extra cost by coding 1
-      //               more bit.
-      ref_costs_comp[BWDREF_FRAME] += av1_cost_bit(bwdref_comp_p, 0);
-      ref_costs_comp[ALTREF_FRAME] += av1_cost_bit(bwdref_comp_p, 1);
-#else
+#if CONFIG_VAR_REFS
+      // Test need to explicitly code (L,L2) vs (L3,G) branch node in tree
+      if (L_OR_L2(cm) && L3_OR_G(cm)) {
+#endif  // CONFIG_VAR_REFS
+        ref_costs_comp[LAST_FRAME] += av1_cost_bit(ref_comp_p, 0);
+        ref_costs_comp[LAST2_FRAME] += av1_cost_bit(ref_comp_p, 0);
+        ref_costs_comp[LAST3_FRAME] += av1_cost_bit(ref_comp_p, 1);
+        ref_costs_comp[GOLDEN_FRAME] += av1_cost_bit(ref_comp_p, 1);
+#if CONFIG_VAR_REFS
+      }
+#endif  // CONFIG_VAR_REFS
+
+#if CONFIG_VAR_REFS
+      // Test need to explicitly code (L) vs (L2) branch node in tree
+      if (L_AND_L2(cm)) {
+#endif  // CONFIG_VAR_REFS
+        ref_costs_comp[LAST_FRAME] += av1_cost_bit(ref_comp_p1, 1);
+        ref_costs_comp[LAST2_FRAME] += av1_cost_bit(ref_comp_p1, 0);
+#if CONFIG_VAR_REFS
+      }
+#endif  // CONFIG_VAR_REFS
+
+#if CONFIG_VAR_REFS
+      // Test need to explicitly code (L3) vs (G) branch node in tree
+      if (L3_AND_G(cm)) {
+#endif  // CONFIG_VAR_REFS
+        ref_costs_comp[LAST3_FRAME] += av1_cost_bit(ref_comp_p2, 0);
+        ref_costs_comp[GOLDEN_FRAME] += av1_cost_bit(ref_comp_p2, 1);
+#if CONFIG_VAR_REFS
+      }
+#endif  // CONFIG_VAR_REFS
+
+// NOTE(zoeliu): BWDREF and ALTREF each add an extra cost by coding 1
+//               more bit.
+#if CONFIG_VAR_REFS
+      // Test need to explicitly code (BWD) vs (ALT) branch node in tree
+      if (BWD_AND_ALT(cm)) {
+#endif  // CONFIG_VAR_REFS
+        ref_costs_comp[BWDREF_FRAME] += av1_cost_bit(bwdref_comp_p, 0);
+        ref_costs_comp[ALTREF_FRAME] += av1_cost_bit(bwdref_comp_p, 1);
+#if CONFIG_VAR_REFS
+      }
+#endif  // CONFIG_VAR_REFS
+#else   // !CONFIG_EXT_REFS
       ref_costs_comp[LAST_FRAME] += av1_cost_bit(ref_comp_p, 0);
       ref_costs_comp[GOLDEN_FRAME] += av1_cost_bit(ref_comp_p, 1);
 #endif  // CONFIG_EXT_REFS
+#endif  // CONFIG_EXT_COMP_REFS
     } else {
+#if CONFIG_EXT_COMP_REFS
+      int ref0;
+      for (ref0 = LAST_FRAME; ref0 <= GOLDEN_FRAME; ++ref0) {
+        ref_costs_comp[ref0][BWDREF_FRAME] = 512;
+        ref_costs_comp[ref0][ALTREF_FRAME] = 512;
+      }
+      ref_costs_comp[LAST_FRAME][LAST2_FRAME] = 512;
+      ref_costs_comp[LAST_FRAME][GOLDEN_FRAME] = 512;
+      ref_costs_comp[BWDREF_FRAME][ALTREF_FRAME] = 512;
+#else  // !CONFIG_EXT_COMP_REFS
       ref_costs_comp[LAST_FRAME] = 512;
 #if CONFIG_EXT_REFS
       ref_costs_comp[LAST2_FRAME] = 512;
       ref_costs_comp[LAST3_FRAME] = 512;
       ref_costs_comp[BWDREF_FRAME] = 512;
       ref_costs_comp[ALTREF_FRAME] = 512;
 #endif  // CONFIG_EXT_REFS
       ref_costs_comp[GOLDEN_FRAME] = 512;
+#endif  // CONFIG_EXT_COMP_REFS
     }
   }
 }
 
 static void store_coding_context(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx,
                                  int mode_index,
                                  int64_t comp_pred_diff[REFERENCE_MODES],
                                  int skippable) {
@@ -5688,18 +6356,23 @@ static void single_motion_search(const A
   const AV1_COMMON *cm = &cpi->common;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   struct buf_2d backup_yv12[MAX_MB_PLANE] = { { 0, 0, 0, 0, 0 } };
   int bestsme = INT_MAX;
   int step_param;
   int sadpb = x->sadperbit16;
   MV mvp_full;
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+  int ref =
+      has_second_ref(mbmi) ? mbmi->ref_frame[ref_idx] : mbmi->ref_frame[0];
+#else   // !CONFIG_COMPOUND_SINGLEREF
   int ref = mbmi->ref_frame[ref_idx];
-#else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+#else   // !CONFIG_EXT_INTER
   int ref = mbmi->ref_frame[0];
   int ref_idx = 0;
 #endif  // CONFIG_EXT_INTER
   MV ref_mv = x->mbmi_ext->ref_mvs[ref][0].as_mv;
 
   MvLimits tmp_mv_limits = x->mv_limits;
   int cost_list[5];
 
@@ -5797,17 +6470,17 @@ static void single_motion_search(const A
 #if CONFIG_MOTION_VAR
       break;
     case OBMC_CAUSAL:
       bestsme = av1_obmc_full_pixel_diamond(
           cpi, x, &mvp_full, step_param, sadpb,
           MAX_MVSEARCH_STEPS - 1 - step_param, 1, &cpi->fn_ptr[bsize], &ref_mv,
           &(x->best_mv.as_mv), 0);
       break;
-    default: assert("Invalid motion mode!\n");
+    default: assert(0 && "Invalid motion mode!\n");
   }
 #endif  // CONFIG_MOTION_VAR
 
   x->mv_limits = tmp_mv_limits;
 
   if (bestsme < INT_MAX) {
     int dis; /* TODO: use dis in distortion calculation later. */
 #if CONFIG_MOTION_VAR
@@ -5815,27 +6488,16 @@ static void single_motion_search(const A
       case SIMPLE_TRANSLATION:
 #endif  // CONFIG_MOTION_VAR
         if (cpi->sf.use_upsampled_references) {
           int best_mv_var;
           const int try_second = x->second_best_mv.as_int != INVALID_MV &&
                                  x->second_best_mv.as_int != x->best_mv.as_int;
           const int pw = block_size_wide[bsize];
           const int ph = block_size_high[bsize];
-          // Use up-sampled reference frames.
-          struct macroblockd_plane *const pd = &xd->plane[0];
-          struct buf_2d backup_pred = pd->pre[ref_idx];
-          const YV12_BUFFER_CONFIG *upsampled_ref = get_upsampled_ref(cpi, ref);
-
-          // Set pred for Y plane
-          setup_pred_plane(
-              &pd->pre[ref_idx], bsize, upsampled_ref->y_buffer,
-              upsampled_ref->y_crop_width, upsampled_ref->y_crop_height,
-              upsampled_ref->y_stride, (mi_row << 3), (mi_col << 3), NULL,
-              pd->subsampling_x, pd->subsampling_y);
 
           best_mv_var = cpi->find_fractional_mv_step(
               x, &ref_mv, cm->allow_high_precision_mv, x->errorperbit,
               &cpi->fn_ptr[bsize], cpi->sf.mv.subpel_force_stop,
               cpi->sf.mv.subpel_iters_per_step, cond_cost_list(cpi, cost_list),
               x->nmvjointcost, x->mvcost, &dis, &x->pred_sse[ref], NULL,
 #if CONFIG_EXT_INTER
               NULL, 0, 0,
@@ -5868,41 +6530,37 @@ static void single_motion_search(const A
 #if CONFIG_EXT_INTER
                   NULL, 0, 0,
 #endif
                   pw, ph, 1);
               if (this_var < best_mv_var) best_mv = x->best_mv.as_mv;
               x->best_mv.as_mv = best_mv;
             }
           }
-
-          // Restore the reference frames.
-          pd->pre[ref_idx] = backup_pred;
         } else {
           cpi->find_fractional_mv_step(
               x, &ref_mv, cm->allow_high_precision_mv, x->errorperbit,
               &cpi->fn_ptr[bsize], cpi->sf.mv.subpel_force_stop,
               cpi->sf.mv.subpel_iters_per_step, cond_cost_list(cpi, cost_list),
               x->nmvjointcost, x->mvcost, &dis, &x->pred_sse[ref], NULL,
 #if CONFIG_EXT_INTER
               NULL, 0, 0,
 #endif
               0, 0, 0);
         }
 #if CONFIG_MOTION_VAR
         break;
       case OBMC_CAUSAL:
         av1_find_best_obmc_sub_pixel_tree_up(
-            cpi, x, mi_row, mi_col, &x->best_mv.as_mv, &ref_mv,
-            cm->allow_high_precision_mv, x->errorperbit, &cpi->fn_ptr[bsize],
-            cpi->sf.mv.subpel_force_stop, cpi->sf.mv.subpel_iters_per_step,
-            x->nmvjointcost, x->mvcost, &dis, &x->pred_sse[ref], 0,
-            cpi->sf.use_upsampled_references);
+            x, &x->best_mv.as_mv, &ref_mv, cm->allow_high_precision_mv,
+            x->errorperbit, &cpi->fn_ptr[bsize], cpi->sf.mv.subpel_force_stop,
+            cpi->sf.mv.subpel_iters_per_step, x->nmvjointcost, x->mvcost, &dis,
+            &x->pred_sse[ref], 0, cpi->sf.use_upsampled_references);
         break;
-      default: assert("Invalid motion mode!\n");
+      default: assert(0 && "Invalid motion mode!\n");
     }
 #endif  // CONFIG_MOTION_VAR
   }
   *rate_mv = av1_mv_bit_cost(&x->best_mv.as_mv, &ref_mv, x->nmvjointcost,
                              x->mvcost, MV_COST_WEIGHT);
 
 #if CONFIG_MOTION_VAR
   if (cpi->sf.adaptive_motion_search && mbmi->motion_mode == SIMPLE_TRANSLATION)
@@ -5931,43 +6589,44 @@ static void build_second_inter_pred(cons
                                     BLOCK_SIZE bsize, const MV *other_mv,
                                     int mi_row, int mi_col, const int block,
                                     int ref_idx, uint8_t *second_pred) {
   const AV1_COMMON *const cm = &cpi->common;
   const int pw = block_size_wide[bsize];
   const int ph = block_size_high[bsize];
   MACROBLOCKD *xd = &x->e_mbd;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+#if CONFIG_COMPOUND_SINGLEREF
+  const int other_ref =
+      has_second_ref(mbmi) ? mbmi->ref_frame[!ref_idx] : mbmi->ref_frame[0];
+#else  // !CONFIG_COMPOUND_SINGLEREF
   const int other_ref = mbmi->ref_frame[!ref_idx];
-#if CONFIG_DUAL_FILTER
-  InterpFilter interp_filter[2] = {
-    (ref_idx == 0) ? mbmi->interp_filter[2] : mbmi->interp_filter[0],
-    (ref_idx == 0) ? mbmi->interp_filter[3] : mbmi->interp_filter[1]
-  };
-#else
-  const InterpFilter interp_filter = mbmi->interp_filter;
-#endif  // CONFIG_DUAL_FILTER
+#endif  // CONFIG_COMPOUND_SINGLEREF
   struct scale_factors sf;
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
   struct macroblockd_plane *const pd = &xd->plane[0];
   // ic and ir are the 4x4 coordiantes of the sub8x8 at index "block"
   const int ic = block & 1;
   const int ir = (block - ic) >> 1;
   const int p_col = ((mi_col * MI_SIZE) >> pd->subsampling_x) + 4 * ic;
   const int p_row = ((mi_row * MI_SIZE) >> pd->subsampling_y) + 4 * ir;
 #if CONFIG_GLOBAL_MOTION
   WarpedMotionParams *const wm = &xd->global_motion[other_ref];
   int is_global = is_global_mv_block(xd->mi[0], block, wm->wmtype);
 #endif  // CONFIG_GLOBAL_MOTION
 #else
   (void)block;
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 
-  // This function should only ever be called for compound modes
+// This function should only ever be called for compound modes
+#if CONFIG_COMPOUND_SINGLEREF
+  assert(has_second_ref(mbmi) || is_inter_singleref_comp_mode(mbmi->mode));
+#else   // !CONFIG_COMPOUND_SINGLEREF
   assert(has_second_ref(mbmi));
+#endif  // CONFIG_COMPOUND_SINGLEREF
 
   struct buf_2d backup_yv12[MAX_MB_PLANE];
   const YV12_BUFFER_CONFIG *const scaled_ref_frame =
       av1_get_scaled_ref_frame(cpi, other_ref);
 
   if (scaled_ref_frame) {
     int i;
     // Swap out the reference frame for a version that's been scaled to
@@ -5986,17 +6645,17 @@ static void build_second_inter_pred(cons
 #else
   av1_setup_scale_factors_for_frame(&sf, cm->width, cm->height, cm->width,
                                     cm->height);
 #endif  // CONFIG_HIGHBITDEPTH
 
   struct buf_2d ref_yv12;
 
   const int plane = 0;
-  ConvolveParams conv_params = get_conv_params(0, plane);
+  ConvolveParams conv_params = get_conv_params(!ref_idx, 0, plane);
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
   WarpTypesAllowed warp_types;
 #if CONFIG_GLOBAL_MOTION
   warp_types.global_warp_allowed = is_global;
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_WARPED_MOTION
   warp_types.local_warp_allowed = mbmi->motion_mode == WARPED_CAUSAL;
 #endif  // CONFIG_WARPED_MOTION
@@ -6005,26 +6664,26 @@ static void build_second_inter_pred(cons
   // Initialized here because of compiler problem in Visual Studio.
   ref_yv12 = xd->plane[plane].pre[!ref_idx];
 
 // Get the prediction block from the 'other' reference frame.
 #if CONFIG_HIGHBITDEPTH
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
     av1_highbd_build_inter_predictor(
         ref_yv12.buf, ref_yv12.stride, second_pred, pw, other_mv, &sf, pw, ph,
-        0, interp_filter,
+        0, mbmi->interp_filter,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
         &warp_types, p_col, p_row,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
         plane, MV_PRECISION_Q3, mi_col * MI_SIZE, mi_row * MI_SIZE, xd);
   } else {
 #endif  // CONFIG_HIGHBITDEPTH
     av1_build_inter_predictor(
         ref_yv12.buf, ref_yv12.stride, second_pred, pw, other_mv, &sf, pw, ph,
-        &conv_params, interp_filter,
+        &conv_params, mbmi->interp_filter,
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
         &warp_types, p_col, p_row, plane, !ref_idx,
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
         MV_PRECISION_Q3, mi_col * MI_SIZE, mi_row * MI_SIZE, xd);
 #if CONFIG_HIGHBITDEPTH
   }
 #endif  // CONFIG_HIGHBITDEPTH
 
@@ -6033,35 +6692,49 @@ static void build_second_inter_pred(cons
     int i;
     for (i = 0; i < MAX_MB_PLANE; i++)
       xd->plane[i].pre[!ref_idx] = backup_yv12[i];
   }
 }
 
 // Search for the best mv for one component of a compound,
 // given that the other component is fixed.
-static void compound_single_motion_search(
-    const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, MV *this_mv,
-    int mi_row, int mi_col, const uint8_t *second_pred, const uint8_t *mask,
-    int mask_stride, int *rate_mv, const int block, int ref_idx) {
+static void compound_single_motion_search(const AV1_COMP *cpi, MACROBLOCK *x,
+                                          BLOCK_SIZE bsize, MV *this_mv,
+                                          int mi_row, int mi_col,
+                                          const uint8_t *second_pred,
+                                          const uint8_t *mask, int mask_stride,
+                                          int *rate_mv, int ref_idx) {
   const int pw = block_size_wide[bsize];
   const int ph = block_size_high[bsize];
   MACROBLOCKD *xd = &x->e_mbd;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+#if CONFIG_COMPOUND_SINGLEREF
+  const int ref =
+      has_second_ref(mbmi) ? mbmi->ref_frame[ref_idx] : mbmi->ref_frame[0];
+#else
   const int ref = mbmi->ref_frame[ref_idx];
+#endif  // CONFIG_COMPOUND_SINGLEREF
   int_mv ref_mv = x->mbmi_ext->ref_mvs[ref][0];
   struct macroblockd_plane *const pd = &xd->plane[0];
 
   struct buf_2d backup_yv12[MAX_MB_PLANE];
   const YV12_BUFFER_CONFIG *const scaled_ref_frame =
       av1_get_scaled_ref_frame(cpi, ref);
 
-  // Check that this is either an interinter or an interintra block
+// Check that this is either an interinter or an interintra block
+#if CONFIG_COMPOUND_SINGLEREF
+  assert(has_second_ref(mbmi) ||
+         // or a single ref comp pred mode
+         is_inter_singleref_comp_mode(mbmi->mode) ||
+         (ref_idx == 0 && mbmi->ref_frame[1] == INTRA_FRAME));
+#else
   assert(has_second_ref(mbmi) ||
          (ref_idx == 0 && mbmi->ref_frame[1] == INTRA_FRAME));
+#endif  // CONFIG_COMPOUND_SINGLEREF
 
   if (scaled_ref_frame) {
     int i;
     // Swap out the reference frame for a version that's been scaled to
     // match the resolution of the current frame, allowing the existing
     // motion search code to be used without additional modifications.
     for (i = 0; i < MAX_MB_PLANE; i++)
       backup_yv12[i] = xd->plane[i].pre[ref_idx];
@@ -6086,17 +6759,22 @@ static void compound_single_motion_searc
   av1_set_mv_search_range(&x->mv_limits, &ref_mv.as_mv);
 
   // Use the mv result from the single mode as mv predictor.
   *best_mv = *this_mv;
 
   best_mv->col >>= 3;
   best_mv->row >>= 3;
 
-  av1_set_mvcost(x, ref, ref_idx, mbmi->ref_mv_idx);
+#if CONFIG_COMPOUND_SINGLEREF
+  if (!has_second_ref(mbmi))
+    av1_set_mvcost(x, ref, 0, mbmi->ref_mv_idx);
+  else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+    av1_set_mvcost(x, ref, ref_idx, mbmi->ref_mv_idx);
 
   // Small-range full-pixel motion search.
   bestsme = av1_refining_search_8p_c(x, sadpb, search_range,
                                      &cpi->fn_ptr[bsize], mask, mask_stride,
                                      ref_idx, &ref_mv.as_mv, second_pred);
   if (bestsme < INT_MAX) {
     if (mask)
       bestsme =
@@ -6107,106 +6785,101 @@ static void compound_single_motion_searc
                                       &cpi->fn_ptr[bsize], 1);
   }
 
   x->mv_limits = tmp_mv_limits;
 
   if (bestsme < INT_MAX) {
     int dis; /* TODO: use dis in distortion calculation later. */
     unsigned int sse;
-    if (cpi->sf.use_upsampled_references) {
-      // Use up-sampled reference frames.
-      struct buf_2d backup_pred = pd->pre[0];
-      const YV12_BUFFER_CONFIG *upsampled_ref = get_upsampled_ref(cpi, ref);
-
-      // Set pred for Y plane
-      setup_pred_plane(&pd->pre[0], bsize, upsampled_ref->y_buffer,
-                       upsampled_ref->y_crop_width,
-                       upsampled_ref->y_crop_height, upsampled_ref->y_stride,
-                       (mi_row << 3), (mi_col << 3), NULL, pd->subsampling_x,
-                       pd->subsampling_y);
-
-// If bsize < BLOCK_8X8, adjust pred pointer for this block
-#if !CONFIG_CB4X4
-      if (bsize < BLOCK_8X8)
-        pd->pre[0].buf =
-            &pd->pre[0].buf[(av1_raster_block_offset(BLOCK_8X8, block,
-                                                     pd->pre[0].stride))
-                            << 3];
-#endif  // !CONFIG_CB4X4
-
-      bestsme = cpi->find_fractional_mv_step(
-          x, &ref_mv.as_mv, cpi->common.allow_high_precision_mv, x->errorperbit,
-          &cpi->fn_ptr[bsize], 0, cpi->sf.mv.subpel_iters_per_step, NULL,
-          x->nmvjointcost, x->mvcost, &dis, &sse, second_pred, mask,
-          mask_stride, ref_idx, pw, ph, 1);
-
-      // Restore the reference frames.
-      pd->pre[0] = backup_pred;
-    } else {
-      (void)block;
-      bestsme = cpi->find_fractional_mv_step(
-          x, &ref_mv.as_mv, cpi->common.allow_high_precision_mv, x->errorperbit,
-          &cpi->fn_ptr[bsize], 0, cpi->sf.mv.subpel_iters_per_step, NULL,
-          x->nmvjointcost, x->mvcost, &dis, &sse, second_pred, mask,
-          mask_stride, ref_idx, pw, ph, 0);
-    }
+    bestsme = cpi->find_fractional_mv_step(
+        x, &ref_mv.as_mv, cpi->common.allow_high_precision_mv, x->errorperbit,
+        &cpi->fn_ptr[bsize], 0, cpi->sf.mv.subpel_iters_per_step, NULL,
+        x->nmvjointcost, x->mvcost, &dis, &sse, second_pred, mask, mask_stride,
+        ref_idx, pw, ph, cpi->sf.use_upsampled_references);
   }
 
   // Restore the pointer to the first (possibly scaled) prediction buffer.
   if (ref_idx) pd->pre[0] = orig_yv12;
 
   if (bestsme < INT_MAX) *this_mv = *best_mv;
 
   *rate_mv = 0;
 
   if (scaled_ref_frame) {
     // Restore the prediction frame pointers to their unscaled versions.
     int i;
     for (i = 0; i < MAX_MB_PLANE; i++)
       xd->plane[i].pre[ref_idx] = backup_yv12[i];
   }
 
-  av1_set_mvcost(x, ref, ref_idx, mbmi->ref_mv_idx);
+#if CONFIG_COMPOUND_SINGLEREF
+  if (!has_second_ref(mbmi))
+    av1_set_mvcost(x, ref, 0, mbmi->ref_mv_idx);
+  else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+    av1_set_mvcost(x, ref, ref_idx, mbmi->ref_mv_idx);
   *rate_mv += av1_mv_bit_cost(this_mv, &ref_mv.as_mv, x->nmvjointcost,
                               x->mvcost, MV_COST_WEIGHT);
 }
 
 // Wrapper for compound_single_motion_search, for the common case
 // where the second prediction is also an inter mode.
 static void compound_single_motion_search_interinter(
     const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int_mv *frame_mv,
+#if CONFIG_COMPOUND_SINGLEREF
+    int_mv *frame_comp_mv,
+#endif  // CONFIG_COMPOUND_SINGLEREF
     int mi_row, int mi_col, const uint8_t *mask, int mask_stride, int *rate_mv,
     const int block, int ref_idx) {
   MACROBLOCKD *xd = &x->e_mbd;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
 
-  // This function should only ever be called for compound modes
+// This function should only ever be called for compound modes
+#if CONFIG_COMPOUND_SINGLEREF
+  int is_singleref_comp_mode =
+      !has_second_ref(mbmi) && is_inter_singleref_comp_mode(mbmi->mode);
+  assert(has_second_ref(mbmi) || is_singleref_comp_mode);
+  if (is_singleref_comp_mode && ref_idx) assert(frame_comp_mv);
+#else   // !CONFIG_COMPOUND_SINGLEREF
   assert(has_second_ref(mbmi));
+#endif  // CONFIG_COMPOUND_SINGLEREF
 
 // Prediction buffer from second frame.
 #if CONFIG_HIGHBITDEPTH
   DECLARE_ALIGNED(16, uint16_t, second_pred_alloc_16[MAX_SB_SQUARE]);
   uint8_t *second_pred;
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
     second_pred = CONVERT_TO_BYTEPTR(second_pred_alloc_16);
   else
     second_pred = (uint8_t *)second_pred_alloc_16;
 #else
   DECLARE_ALIGNED(16, uint8_t, second_pred[MAX_SB_SQUARE]);
 #endif  // CONFIG_HIGHBITDEPTH
 
+#if CONFIG_COMPOUND_SINGLEREF
+  MV *this_mv = has_second_ref(mbmi)
+                    ? &frame_mv[mbmi->ref_frame[ref_idx]].as_mv
+                    : (ref_idx ? &frame_comp_mv[mbmi->ref_frame[0]].as_mv
+                               : &frame_mv[mbmi->ref_frame[0]].as_mv);
+  const MV *other_mv =
+      has_second_ref(mbmi)
+          ? &frame_mv[mbmi->ref_frame[!ref_idx]].as_mv
+          : (ref_idx ? &frame_mv[mbmi->ref_frame[0]].as_mv
+                     : &frame_comp_mv[mbmi->ref_frame[0]].as_mv);
+#else   // !CONFIG_COMPOUND_SINGLEREF
   MV *this_mv = &frame_mv[mbmi->ref_frame[ref_idx]].as_mv;
   const MV *other_mv = &frame_mv[mbmi->ref_frame[!ref_idx]].as_mv;
+#endif  // CONFIG_COMPOUND_SINGLEREF
 
   build_second_inter_pred(cpi, x, bsize, other_mv, mi_row, mi_col, block,
                           ref_idx, second_pred);
 
   compound_single_motion_search(cpi, x, bsize, this_mv, mi_row, mi_col,
-                                second_pred, mask, mask_stride, rate_mv, block,
+                                second_pred, mask, mask_stride, rate_mv,
                                 ref_idx);
 }
 
 #if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
 static void do_masked_motion_search_indexed(
     const AV1_COMP *const cpi, MACROBLOCK *x, const int_mv *const cur_mv,
     const INTERINTER_COMPOUND_DATA *const comp_data, BLOCK_SIZE bsize,
     int mi_row, int mi_col, int_mv *tmp_mv, int *rate_mv, int which) {
@@ -6215,31 +6888,50 @@ static void do_masked_motion_search_inde
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   BLOCK_SIZE sb_type = mbmi->sb_type;
   const uint8_t *mask;
   const int mask_stride = block_size_wide[bsize];
 
   mask = av1_get_compound_type_mask(comp_data, sb_type);
 
   int_mv frame_mv[TOTAL_REFS_PER_FRAME];
+#if CONFIG_COMPOUND_SINGLEREF
+  int_mv frame_comp_mv[TOTAL_REFS_PER_FRAME];
+#endif  // CONFIG_COMPOUND_SINGLEREF
   MV_REFERENCE_FRAME rf[2] = { mbmi->ref_frame[0], mbmi->ref_frame[1] };
   assert(bsize >= BLOCK_8X8 || CONFIG_CB4X4);
 
   frame_mv[rf[0]].as_int = cur_mv[0].as_int;
-  frame_mv[rf[1]].as_int = cur_mv[1].as_int;
+#if CONFIG_COMPOUND_SINGLEREF
+  if (!has_second_ref(mbmi))
+    frame_comp_mv[rf[0]].as_int = cur_mv[1].as_int;
+  else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+    frame_mv[rf[1]].as_int = cur_mv[1].as_int;
   if (which == 0 || which == 1) {
-    compound_single_motion_search_interinter(cpi, x, bsize, frame_mv, mi_row,
-                                             mi_col, mask, mask_stride, rate_mv,
-                                             0, which);
+    compound_single_motion_search_interinter(
+        cpi, x, bsize, frame_mv,
+#if CONFIG_COMPOUND_SINGLEREF
+        has_second_ref(mbmi) ? NULL : frame_comp_mv,
+#endif  // CONFIG_COMPOUND_SINGLEREF
+        mi_row, mi_col, mask, mask_stride, rate_mv, 0, which);
   } else if (which == 2) {
-    joint_motion_search(cpi, x, bsize, frame_mv, mi_row, mi_col, NULL, mask,
-                        mask_stride, rate_mv, 0);
+    joint_motion_search(cpi, x, bsize, frame_mv,
+#if CONFIG_COMPOUND_SINGLEREF
+                        has_second_ref(mbmi) ? NULL : frame_comp_mv,
+#endif  // CONFIG_COMPOUND_SINGLEREF
+                        mi_row, mi_col, NULL, mask, mask_stride, rate_mv, 0);
   }
   tmp_mv[0].as_int = frame_mv[rf[0]].as_int;
-  tmp_mv[1].as_int = frame_mv[rf[1]].as_int;
+#if CONFIG_COMPOUND_SINGLEREF
+  if (!has_second_ref(mbmi))
+    tmp_mv[1].as_int = frame_comp_mv[rf[0]].as_int;
+  else  // comp ref
+#endif  // CONFIG_COMPOUND_SINGLEREF
+    tmp_mv[1].as_int = frame_mv[rf[1]].as_int;
 }
 #endif  // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
 #endif  // CONFIG_EXT_INTER
 
 // In some situations we want to discount tha pparent cost of a new motion
 // vector. Where there is a subtle motion field and especially where there is
 // low spatial complexity then it can be hard to cover the cost of a new motion
 // vector in a single block, even if that motion vector reduces distortion.
@@ -6478,17 +7170,17 @@ static int64_t pick_wedge(const AV1_COMP
     mask = av1_get_contiguous_soft_mask(wedge_index, wedge_sign, bsize);
     if (N < 64)
       sse = av1_wedge_sse_from_residuals_c(r1, d10, mask, N);
     else
       sse = av1_wedge_sse_from_residuals(r1, d10, mask, N);
     sse = ROUND_POWER_OF_TWO(sse, bd_round);
 
     model_rd_from_sse(cpi, xd, bsize, 0, sse, &rate, &dist);
-    rd = RDCOST(x->rdmult, x->rddiv, rate, dist);
+    rd = RDCOST(x->rdmult, rate, dist);
 
     if (rd < best_rd) {
       *best_wedge_index = wedge_index;
       *best_wedge_sign = wedge_sign;
       best_rd = rd;
     }
   }
 
@@ -6539,17 +7231,17 @@ static int64_t pick_wedge_fixed_sign(
     mask = av1_get_contiguous_soft_mask(wedge_index, wedge_sign, bsize);
     if (N < 64)
       sse = av1_wedge_sse_from_residuals_c(r1, d10, mask, N);
     else
       sse = av1_wedge_sse_from_residuals(r1, d10, mask, N);
     sse = ROUND_POWER_OF_TWO(sse, bd_round);
 
     model_rd_from_sse(cpi, xd, bsize, 0, sse, &rate, &dist);
-    rd = RDCOST(x->rdmult, x->rddiv, rate, dist);
+    rd = RDCOST(x->rdmult, rate, dist);
 
     if (rd < best_rd) {
       *best_wedge_index = wedge_index;
       best_rd = rd;
     }
   }
 
   return best_rd;
@@ -6641,17 +7333,17 @@ static int64_t pick_interinter_seg(const
       build_compound_seg_mask(xd->seg_mask, cur_mask_type, p0, bw, p1, bw,
                               bsize, bh, bw);
 
     // compute rd for mask
     sse = av1_wedge_sse_from_residuals(r1, d10, xd->seg_mask, N);
     sse = ROUND_POWER_OF_TWO(sse, bd_round);
 
     model_rd_from_sse(cpi, xd, bsize, 0, sse, &rate, &dist);
-    rd0 = RDCOST(x->rdmult, x->rddiv, rate, dist);
+    rd0 = RDCOST(x->rdmult, rate, dist);
 
     if (rd0 < best_rd) {
       best_mask_type = cur_mask_type;
       best_rd = rd0;
     }
   }
 
   // make final mask
@@ -6724,26 +7416,41 @@ static int interinter_compound_motion_se
     mbmi->wedge_sign,
 #endif  // CONFIG_WEDGE
 #if CONFIG_COMPOUND_SEGMENT
     mbmi->mask_type,
     xd->seg_mask,
 #endif  // CONFIG_COMPOUND_SEGMENT
     mbmi->interinter_compound_type
   };
-  if (this_mode == NEW_NEWMV) {
+#if CONFIG_COMPOUND_SINGLEREF
+  // NOTE: Mode is needed to identify the compound mode prediction, regardless
+  //       of comp refs or single ref.
+  mbmi->mode = this_mode;
+#endif  // CONFIG_COMPOUND_SINGLEREF
+
+  if (this_mode == NEW_NEWMV
+#if CONFIG_COMPOUND_SINGLEREF
+      || this_mode == SR_NEW_NEWMV
+#endif  // CONFIG_COMPOUND_SINGLEREF
+      ) {
     do_masked_motion_search_indexed(cpi, x, cur_mv, &compound_data, bsize,
                                     mi_row, mi_col, tmp_mv, &tmp_rate_mv, 2);
     mbmi->mv[0].as_int = tmp_mv[0].as_int;
     mbmi->mv[1].as_int = tmp_mv[1].as_int;
   } else if (this_mode == NEW_NEARESTMV || this_mode == NEW_NEARMV) {
     do_masked_motion_search_indexed(cpi, x, cur_mv, &compound_data, bsize,
                                     mi_row, mi_col, tmp_mv, &tmp_rate_mv, 0);
     mbmi->mv[0].as_int = tmp_mv[0].as_int;
-  } else if (this_mode == NEAREST_NEWMV || this_mode == NEAR_NEWMV) {
+  } else if (this_mode == NEAREST_NEWMV || this_mode == NEAR_NEWMV
+#if CONFIG_COMPOUND_SINGLEREF
+             // || this_mode == SR_NEAREST_NEWMV
+             || this_mode == SR_NEAR_NEWMV || this_mode == SR_ZERO_NEWMV
+#endif  // CONFIG_COMPOUND_SINGLEREF
+             ) {
     do_masked_motion_search_indexed(cpi, x, cur_mv, &compound_data, bsize,
                                     mi_row, mi_col, tmp_mv, &tmp_rate_mv, 1);
     mbmi->mv[1].as_int = tmp_mv[1].as_int;
   }
   return tmp_rate_mv;
 }
 
 static int64_t build_and_cost_compound_type(
@@ -6758,55 +7465,55 @@ static int64_t build_and_cost_compound_t
   int64_t dist_sum;
   int64_t best_rd_cur = INT64_MAX;
   int64_t rd = INT64_MAX;
   int tmp_skip_txfm_sb;
   int64_t tmp_skip_sse_sb;
   const COMPOUND_TYPE compound_type = mbmi->interinter_compound_type;
 
   best_rd_cur = pick_interinter_mask(cpi, x, bsize, *preds0, *preds1);
-  best_rd_cur += RDCOST(x->rdmult, x->rddiv, rs2 + rate_mv, 0);
+  best_rd_cur += RDCOST(x->rdmult, rs2 + rate_mv, 0);
 
   if (have_newmv_in_inter_mode(this_mode) &&
       use_masked_motion_search(compound_type)) {
     *out_rate_mv = interinter_compound_motion_search(cpi, x, cur_mv, bsize,
                                                      this_mode, mi_row, mi_col);
     av1_build_inter_predictors_sby(cm, xd, mi_row, mi_col, ctx, bsize);
     model_rd_for_sb(cpi, bsize, x, xd, 0, 0, &rate_sum, &dist_sum,
                     &tmp_skip_txfm_sb, &tmp_skip_sse_sb);
-    rd = RDCOST(x->rdmult, x->rddiv, rs2 + *out_rate_mv + rate_sum, dist_sum);
+    rd = RDCOST(x->rdmult, rs2 + *out_rate_mv + rate_sum, dist_sum);
     if (rd >= best_rd_cur) {
       mbmi->mv[0].as_int = cur_mv[0].as_int;
       mbmi->mv[1].as_int = cur_mv[1].as_int;
       *out_rate_mv = rate_mv;
       av1_build_wedge_inter_predictor_from_buf(xd, bsize, 0, 0,
 #if CONFIG_SUPERTX
                                                0, 0,
 #endif  // CONFIG_SUPERTX
                                                preds0, strides, preds1,
                                                strides);
     }
     av1_subtract_plane(x, bsize, 0);
     rd = estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum,
                              &tmp_skip_txfm_sb, &tmp_skip_sse_sb, INT64_MAX);
     if (rd != INT64_MAX)
-      rd = RDCOST(x->rdmult, x->rddiv, rs2 + *out_rate_mv + rate_sum, dist_sum);
+      rd = RDCOST(x->rdmult, rs2 + *out_rate_mv + rate_sum, dist_sum);
     best_rd_cur = rd;
 
   } else {
     av1_build_wedge_inter_predictor_from_buf(xd, bsize, 0, 0,
 #if CONFIG_SUPERTX
                                              0, 0,
 #endif  // CONFIG_SUPERTX
                                              preds0, strides, preds1, strides);
     av1_subtract_plane(x, bsize, 0);
     rd = estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum,
                              &tmp_skip_txfm_sb, &tmp_skip_sse_sb, INT64_MAX);
     if (rd != INT64_MAX)
-      rd = RDCOST(x->rdmult, x->rddiv, rs2 + rate_mv + rate_sum, dist_sum);
+      rd = RDCOST(x->rdmult, rs2 + rate_mv + rate_sum, dist_sum);
     best_rd_cur = rd;
   }
   return best_rd_cur;
 }
 #endif  // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
 #endif  // CONFIG_EXT_INTER
 
 typedef struct {
@@ -6827,28 +7534,34 @@ typedef struct {
   int64_t (*modelled_rd)[TOTAL_REFS_PER_FRAME];
 #endif  // CONFIG_EXT_INTER
   InterpFilter single_filter[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME];
 } HandleInterModeArgs;
 
 static int64_t handle_newmv(const AV1_COMP *const cpi, MACROBLOCK *const x,
                             const BLOCK_SIZE bsize,
                             int_mv (*const mode_mv)[TOTAL_REFS_PER_FRAME],
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+                            int_mv (*const mode_comp_mv)[TOTAL_REFS_PER_FRAME],
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
                             const int mi_row, const int mi_col,
                             int *const rate_mv, int_mv *const single_newmv,
                             HandleInterModeArgs *const args) {
   const MACROBLOCKD *const xd = &x->e_mbd;
   const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
   const MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
   const int is_comp_pred = has_second_ref(mbmi);
   const PREDICTION_MODE this_mode = mbmi->mode;
 #if CONFIG_EXT_INTER
   const int is_comp_interintra_pred = (mbmi->ref_frame[1] == INTRA_FRAME);
 #endif  // CONFIG_EXT_INTER
   int_mv *const frame_mv = mode_mv[this_mode];
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  int_mv *const frame_comp_mv = mode_comp_mv[this_mode];
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   const int refs[2] = { mbmi->ref_frame[0],
                         mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1] };
   int i;
 
   (void)args;
 
   if (is_comp_pred) {
 #if CONFIG_EXT_INTER
@@ -6856,72 +7569,118 @@ static int64_t handle_newmv(const AV1_CO
       single_newmv[refs[i]].as_int = args->single_newmv[refs[i]].as_int;
     }
 
     if (this_mode == NEW_NEWMV) {
       frame_mv[refs[0]].as_int = single_newmv[refs[0]].as_int;
       frame_mv[refs[1]].as_int = single_newmv[refs[1]].as_int;
 
       if (cpi->sf.comp_inter_joint_search_thresh <= bsize) {
-        joint_motion_search(cpi, x, bsize, frame_mv, mi_row, mi_col, NULL, NULL,
-                            0, rate_mv, 0);
+        joint_motion_search(cpi, x, bsize, frame_mv,
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+                            NULL,  // int_mv *frame_comp_mv
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+                            mi_row, mi_col, NULL, NULL, 0, rate_mv, 0);
       } else {
         *rate_mv = 0;
         for (i = 0; i < 2; ++i) {
           av1_set_mvcost(x, refs[i], i, mbmi->ref_mv_idx);
           *rate_mv += av1_mv_bit_cost(
               &frame_mv[refs[i]].as_mv, &mbmi_ext->ref_mvs[refs[i]][0].as_mv,
               x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
         }
       }
     } else if (this_mode == NEAREST_NEWMV || this_mode == NEAR_NEWMV) {
       frame_mv[refs[1]].as_int = single_newmv[refs[1]].as_int;
       if (cpi->sf.comp_inter_joint_search_thresh <= bsize) {
         frame_mv[refs[0]].as_int =
             mode_mv[compound_ref0_mode(this_mode)][refs[0]].as_int;
-        compound_single_motion_search_interinter(
-            cpi, x, bsize, frame_mv, mi_row, mi_col, NULL, 0, rate_mv, 0, 1);
+        compound_single_motion_search_interinter(cpi, x, bsize, frame_mv,
+#if CONFIG_COMPOUND_SINGLEREF
+                                                 NULL,
+#endif  // CONFIG_COMPOUND_SINGLEREF
+                                                 mi_row, mi_col, NULL, 0,
+                                                 rate_mv, 0, 1);
       } else {
         av1_set_mvcost(x, refs[1], 1, mbmi->ref_mv_idx);
         *rate_mv = av1_mv_bit_cost(&frame_mv[refs[1]].as_mv,
                                    &mbmi_ext->ref_mvs[refs[1]][0].as_mv,
                                    x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
       }
     } else {
       assert(this_mode == NEW_NEARESTMV || this_mode == NEW_NEARMV);
       frame_mv[refs[0]].as_int = single_newmv[refs[0]].as_int;
       if (cpi->sf.comp_inter_joint_search_thresh <= bsize) {
         frame_mv[refs[1]].as_int =
             mode_mv[compound_ref1_mode(this_mode)][refs[1]].as_int;
-        compound_single_motion_search_interinter(
-            cpi, x, bsize, frame_mv, mi_row, mi_col, NULL, 0, rate_mv, 0, 0);
+        compound_single_motion_search_interinter(cpi, x, bsize, frame_mv,
+#if CONFIG_COMPOUND_SINGLEREF
+                                                 NULL,
+#endif  // CONFIG_COMPOUND_SINGLEREF
+                                                 mi_row, mi_col, NULL, 0,
+                                                 rate_mv, 0, 0);
       } else {
         av1_set_mvcost(x, refs[0], 0, mbmi->ref_mv_idx);
         *rate_mv = av1_mv_bit_cost(&frame_mv[refs[0]].as_mv,
                                    &mbmi_ext->ref_mvs[refs[0]][0].as_mv,
                                    x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
       }
     }
-#else
+#else   // !CONFIG_EXT_INTER
     // Initialize mv using single prediction mode result.
     frame_mv[refs[0]].as_int = single_newmv[refs[0]].as_int;
     frame_mv[refs[1]].as_int = single_newmv[refs[1]].as_int;
 
     if (cpi->sf.comp_inter_joint_search_thresh <= bsize) {
       joint_motion_search(cpi, x, bsize, frame_mv, mi_row, mi_col, rate_mv, 0);
     } else {
       *rate_mv = 0;
       for (i = 0; i < 2; ++i) {
         av1_set_mvcost(x, refs[i], i, mbmi->ref_mv_idx);
         *rate_mv += av1_mv_bit_cost(&frame_mv[refs[i]].as_mv,
                                     &mbmi_ext->ref_mvs[refs[i]][0].as_mv,
                                     x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
       }
     }
 #endif  // CONFIG_EXT_INTER
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  } else if (is_inter_singleref_comp_mode(this_mode)) {
+    // Single ref comp mode
+    const int mode0 = compound_ref0_mode(this_mode);
+
+    single_newmv[refs[0]].as_int = args->single_newmv[refs[0]].as_int;
+    frame_mv[refs[0]].as_int = (mode0 == NEWMV)
+                                   ? single_newmv[refs[0]].as_int
+                                   : mode_mv[mode0][refs[0]].as_int;
+    assert(compound_ref1_mode(this_mode) == NEWMV);
+    frame_comp_mv[refs[0]].as_int = single_newmv[refs[0]].as_int;
+
+    if (cpi->sf.comp_inter_joint_search_thresh <= bsize) {
+      if (this_mode == SR_NEW_NEWMV) {
+        joint_motion_search(cpi, x, bsize, frame_mv, frame_comp_mv, mi_row,
+                            mi_col, NULL, NULL, 0, rate_mv, 0);
+      } else {
+        assert(  // this_mode == SR_NEAREST_NEWMV ||
+            this_mode == SR_NEAR_NEWMV || this_mode == SR_ZERO_NEWMV);
+        compound_single_motion_search_interinter(cpi, x, bsize, frame_mv,
+                                                 frame_comp_mv, mi_row, mi_col,
+                                                 NULL, 0, rate_mv, 0, 1);
+      }
+    } else {
+      *rate_mv = 0;
+      av1_set_mvcost(x, refs[0], 0, mbmi->ref_mv_idx);
+      if (mode0 == NEWMV)
+        *rate_mv += av1_mv_bit_cost(&frame_mv[refs[0]].as_mv,
+                                    &mbmi_ext->ref_mvs[refs[0]][0].as_mv,
+                                    x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
+      *rate_mv += av1_mv_bit_cost(&frame_comp_mv[refs[0]].as_mv,
+                                  &mbmi_ext->ref_mvs[refs[0]][0].as_mv,
+                                  x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
+    }
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   } else {
 #if CONFIG_EXT_INTER
     if (is_comp_interintra_pred) {
       x->best_mv = args->single_newmv[refs[0]];
       *rate_mv = args->single_newmv_rate[refs[0]];
     } else {
       single_motion_search(cpi, x, bsize, mi_row, mi_col, 0, rate_mv);
       args->single_newmv[refs[0]] = x->best_mv;
@@ -6979,17 +7738,17 @@ int64_t interpolation_filter_search(
   }
 
   set_default_interp_filters(mbmi, assign_filter);
 
   *switchable_rate = av1_get_switchable_rate(cpi, xd);
   av1_build_inter_predictors_sb(cm, xd, mi_row, mi_col, orig_dst, bsize);
   model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, &tmp_rate, &tmp_dist,
                   skip_txfm_sb, skip_sse_sb);
-  *rd = RDCOST(x->rdmult, x->rddiv, *switchable_rate + tmp_rate, tmp_dist);
+  *rd = RDCOST(x->rdmult, *switchable_rate + tmp_rate, tmp_dist);
 
   if (assign_filter == SWITCHABLE) {
     // do interp_filter search
     if (av1_is_interp_needed(xd) && av1_is_interp_search_needed(xd)) {
 #if CONFIG_DUAL_FILTER
       const int filter_set_size = DUAL_FILTER_SET_SIZE;
 #else
       const int filter_set_size = SWITCHABLE_FILTERS;
@@ -7015,17 +7774,17 @@ int64_t interpolation_filter_search(
         mbmi->interp_filter[3] = filter_sets[i][1];
 #else
         mbmi->interp_filter = (InterpFilter)i;
 #endif  // CONFIG_DUAL_FILTER
         tmp_rs = av1_get_switchable_rate(cpi, xd);
         av1_build_inter_predictors_sb(cm, xd, mi_row, mi_col, orig_dst, bsize);
         model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, &tmp_rate,
                         &tmp_dist, &tmp_skip_sb, &tmp_skip_sse);
-        tmp_rd = RDCOST(x->rdmult, x->rddiv, tmp_rs + tmp_rate, tmp_dist);
+        tmp_rd = RDCOST(x->rdmult, tmp_rs + tmp_rate, tmp_dist);
 
         if (tmp_rd < *rd) {
           *rd = tmp_rd;
           *switchable_rate = av1_get_switchable_rate(cpi, xd);
 #if CONFIG_DUAL_FILTER
           av1_copy(best_filter, mbmi->interp_filter);
 #else
           best_filter = mbmi->interp_filter;
@@ -7067,22 +7826,20 @@ int64_t interpolation_filter_search(
 // TODO(afergs): Refactor optional args - add them to a struct or remove
 static int64_t motion_mode_rd(
     const AV1_COMP *const cpi, MACROBLOCK *const x, BLOCK_SIZE bsize,
     RD_STATS *rd_stats, RD_STATS *rd_stats_y, RD_STATS *rd_stats_uv,
     int *disable_skip, int_mv (*mode_mv)[TOTAL_REFS_PER_FRAME], int mi_row,
     int mi_col, HandleInterModeArgs *const args, const int64_t ref_best_rd,
     const int *refs, int rate_mv,
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
+    // only used when WARPED_MOTION is on?
     int_mv *const single_newmv,
 #if CONFIG_EXT_INTER
-    int rate2_bmc_nocoeff, MB_MODE_INFO *best_bmc_mbmi,
-#if CONFIG_MOTION_VAR
-    int rate_mv_bmc,
-#endif  // CONFIG_MOTION_VAR
+    int rate2_bmc_nocoeff, MB_MODE_INFO *best_bmc_mbmi, int rate_mv_bmc,
 #endif  // CONFIG_EXT_INTER
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
     int rs, int *skip_txfm_sb, int64_t *skip_sse_sb, BUFFER_SET *orig_dst) {
   const AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *xd = &x->e_mbd;
   MODE_INFO *mi = xd->mi[0];
   MB_MODE_INFO *mbmi = &mi->mbmi;
   const int is_comp_pred = has_second_ref(mbmi);
@@ -7120,21 +7877,33 @@ static int64_t motion_mode_rd(
   aom_clear_system_state();
   mbmi->num_proj_ref[0] = findSamples(cm, xd, mi_row, mi_col, pts, pts_inref);
 #if CONFIG_EXT_INTER
   best_bmc_mbmi->num_proj_ref[0] = mbmi->num_proj_ref[0];
 #endif  // CONFIG_EXT_INTER
 #endif  // CONFIG_WARPED_MOTION
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   rate2_nocoeff = rd_stats->rate;
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+  // We cannot estimate the rd cost for the motion mode NCOBMC_ADAPT_WEIGHT
+  // right now since it requires mvs from all neighboring blocks. We will
+  // check if this mode is beneficial after all the mv's in the current
+  // superblock are selected.
+  last_motion_mode_allowed = motion_mode_allowed_wrapper(1,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                                         0, xd->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                                         mi);
+#else
   last_motion_mode_allowed = motion_mode_allowed(
 #if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
       0, xd->global_motion,
 #endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
       mi);
+#endif  // CONFIG_NCOBMC_ADAPT_WEIGHT
   base_mbmi = *mbmi;
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   int64_t best_rd = INT64_MAX;
   for (motion_mode = SIMPLE_TRANSLATION;
        motion_mode <= last_motion_mode_allowed; motion_mode++) {
     int64_t tmp_rd = INT64_MAX;
@@ -7150,17 +7919,21 @@ static int64_t motion_mode_rd(
     *mbmi = base_mbmi;
     mbmi->motion_mode = motion_mode;
 #if CONFIG_MOTION_VAR
     if (mbmi->motion_mode == OBMC_CAUSAL) {
 #if CONFIG_EXT_INTER
       *mbmi = *best_bmc_mbmi;
       mbmi->motion_mode = OBMC_CAUSAL;
 #endif  // CONFIG_EXT_INTER
-      if (!is_comp_pred && have_newmv_in_inter_mode(this_mode)) {
+      if (!is_comp_pred &&
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+          !is_inter_singleref_comp_mode(this_mode) &&
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+          have_newmv_in_inter_mode(this_mode)) {
         int tmp_rate_mv = 0;
 
         single_motion_search(cpi, x, bsize, mi_row, mi_col,
 #if CONFIG_EXT_INTER
                              0,
 #endif  // CONFIG_EXT_INTER
                              &tmp_rate_mv);
         mbmi->mv[0].as_int = x->best_mv.as_int;
@@ -7323,18 +8096,18 @@ static int64_t motion_mode_rd(
           return INT64_MAX;
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
         }
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
       }
 
       av1_merge_rd_stats(rd_stats, rd_stats_y);
 
-      rdcosty = RDCOST(x->rdmult, x->rddiv, rd_stats->rate, rd_stats->dist);
-      rdcosty = AOMMIN(rdcosty, RDCOST(x->rdmult, x->rddiv, 0, rd_stats->sse));
+      rdcosty = RDCOST(x->rdmult, rd_stats->rate, rd_stats->dist);
+      rdcosty = AOMMIN(rdcosty, RDCOST(x->rdmult, 0, rd_stats->sse));
 /* clang-format off */
 #if CONFIG_VAR_TX
       is_cost_valid_uv =
           inter_block_uvrd(cpi, x, rd_stats_uv, bsize, ref_best_rd - rdcosty);
 #else
       is_cost_valid_uv =
           super_block_uvrd(cpi, x, rd_stats_uv, bsize, ref_best_rd - rdcosty);
 #endif  // CONFIG_VAR_TX
@@ -7360,22 +8133,21 @@ static int64_t motion_mode_rd(
       if (rd_stats->skip) {
         rd_stats->rate -= rd_stats_uv->rate + rd_stats_y->rate;
         rd_stats_y->rate = 0;
         rd_stats_uv->rate = 0;
         rd_stats->rate += av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
         mbmi->skip = 0;
         // here mbmi->skip temporarily plays a role as what this_skip2 does
       } else if (!xd->lossless[mbmi->segment_id] &&
-                 (RDCOST(x->rdmult, x->rddiv,
+                 (RDCOST(x->rdmult,
                          rd_stats_y->rate + rd_stats_uv->rate +
                              av1_cost_bit(av1_get_skip_prob(cm, xd), 0),
                          rd_stats->dist) >=
-                  RDCOST(x->rdmult, x->rddiv,
-                         av1_cost_bit(av1_get_skip_prob(cm, xd), 1),
+                  RDCOST(x->rdmult, av1_cost_bit(av1_get_skip_prob(cm, xd), 1),
                          rd_stats->sse))) {
         rd_stats->rate -= rd_stats_uv->rate + rd_stats_y->rate;
         rd_stats->rate += av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
         rd_stats->dist = rd_stats->sse;
         rd_stats_y->rate = 0;
         rd_stats_uv->rate = 0;
         mbmi->skip = 1;
       } else {
@@ -7422,17 +8194,17 @@ static int64_t motion_mode_rd(
                                   ? EIGHTTAP_REGULAR
                                   : cm->interp_filter;
 #endif  // CONFIG_DUAL_FILTER
       }
     }
 #endif  // CONFIG_GLOBAL_MOTION
 
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
-    tmp_rd = RDCOST(x->rdmult, x->rddiv, rd_stats->rate, rd_stats->dist);
+    tmp_rd = RDCOST(x->rdmult, rd_stats->rate, rd_stats->dist);
     if (mbmi->motion_mode == SIMPLE_TRANSLATION || (tmp_rd < best_rd)) {
       best_mbmi = *mbmi;
       best_rd = tmp_rd;
       best_rd_stats = *rd_stats;
       best_rd_stats_y = *rd_stats_y;
       best_rd_stats_uv = *rd_stats_uv;
 #if CONFIG_VAR_TX
       for (int i = 0; i < MAX_MB_PLANE; ++i)
@@ -7461,38 +8233,51 @@ static int64_t motion_mode_rd(
   x->skip = best_xskip;
   *disable_skip = best_disable_skip;
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
   restore_dst_buf(xd, *orig_dst);
   return 0;
 }
 
-static int64_t handle_inter_mode(
-    const AV1_COMP *const cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
-    RD_STATS *rd_stats, RD_STATS *rd_stats_y, RD_STATS *rd_stats_uv,
-    int *disable_skip, int_mv (*mode_mv)[TOTAL_REFS_PER_FRAME], int mi_row,
-    int mi_col, HandleInterModeArgs *args, const int64_t ref_best_rd) {
+static int64_t handle_inter_mode(const AV1_COMP *const cpi, MACROBLOCK *x,
+                                 BLOCK_SIZE bsize, RD_STATS *rd_stats,
+                                 RD_STATS *rd_stats_y, RD_STATS *rd_stats_uv,
+                                 int *disable_skip,
+                                 int_mv (*mode_mv)[TOTAL_REFS_PER_FRAME],
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+                                 int_mv (*mode_comp_mv)[TOTAL_REFS_PER_FRAME],
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+                                 int mi_row, int mi_col,
+                                 HandleInterModeArgs *args,
+                                 const int64_t ref_best_rd) {
   const AV1_COMMON *cm = &cpi->common;
   (void)cm;
   MACROBLOCKD *xd = &x->e_mbd;
   MODE_INFO *mi = xd->mi[0];
   MB_MODE_INFO *mbmi = &mi->mbmi;
   MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
   const int is_comp_pred = has_second_ref(mbmi);
   const int this_mode = mbmi->mode;
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  const int is_singleref_comp_mode = is_inter_singleref_comp_mode(this_mode);
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   int_mv *frame_mv = mode_mv[this_mode];
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  // The comp mv for the compound mode in single ref
+  int_mv *frame_comp_mv = mode_comp_mv[this_mode];
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   int i;
   int refs[2] = { mbmi->ref_frame[0],
                   (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) };
   int_mv cur_mv[2];
   int rate_mv = 0;
 #if CONFIG_EXT_INTER
   int pred_exists = 1;
-#if CONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT
+#if CONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT || CONFIG_INTERINTRA
   const int bw = block_size_wide[bsize];
 #endif  // ONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT
   int_mv single_newmv[TOTAL_REFS_PER_FRAME];
 #if CONFIG_INTERINTRA
   const unsigned int *const interintra_mode_cost =
       cpi->interintra_mode_cost[size_group_lookup[bsize]];
 #endif  // CONFIG_INTERINTRA
   const int is_comp_interintra_pred = (mbmi->ref_frame[1] == INTRA_FRAME);
@@ -7506,28 +8291,31 @@ static int64_t handle_inter_mode(
   DECLARE_ALIGNED(16, uint8_t, tmp_buf_[MAX_MB_PLANE * MAX_SB_SQUARE]);
 #endif  // CONFIG_HIGHBITDEPTH
   uint8_t *tmp_buf;
 
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 #if CONFIG_EXT_INTER
   int rate2_bmc_nocoeff;
   MB_MODE_INFO best_bmc_mbmi;
-#if CONFIG_MOTION_VAR
   int rate_mv_bmc;
-#endif  // CONFIG_MOTION_VAR
 #endif  // CONFIG_EXT_INTER
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   int64_t rd = INT64_MAX;
   BUFFER_SET orig_dst, tmp_dst;
   int rs = 0;
 
   int skip_txfm_sb = 0;
   int64_t skip_sse_sb = INT64_MAX;
   int16_t mode_ctx;
+#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
+  // dummy fillers
+  mbmi->ncobmc_mode[0] = NO_OVERLAP;
+  mbmi->ncobmc_mode[1] = NO_OVERLAP;
+#endif
 
 #if CONFIG_EXT_INTER
 #if CONFIG_INTERINTRA
   int compmode_interintra_cost = 0;
   mbmi->use_wedge_interintra = 0;
 #endif
 #if CONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT
   int compmode_interinter_cost = 0;
@@ -7541,17 +8329,21 @@ static int64_t handle_inter_mode(
 
   // is_comp_interintra_pred implies !is_comp_pred
   assert(!is_comp_interintra_pred || (!is_comp_pred));
   // is_comp_interintra_pred implies is_interintra_allowed(mbmi->sb_type)
   assert(!is_comp_interintra_pred || is_interintra_allowed(mbmi));
 #endif  // CONFIG_EXT_INTER
 
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+  if (is_comp_pred || is_singleref_comp_mode)
+#else   // !CONFIG_COMPOUND_SINGLEREF
   if (is_comp_pred)
+#endif  // CONFIG_COMPOUND_SINGLEREF
     mode_ctx = mbmi_ext->compound_mode_context[refs[0]];
   else
 #endif  // CONFIG_EXT_INTER
     mode_ctx = av1_mode_context_analyzer(mbmi_ext->mode_context,
                                          mbmi->ref_frame, bsize, -1);
 
 #if CONFIG_HIGHBITDEPTH
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
@@ -7567,35 +8359,55 @@ static int64_t handle_inter_mode(
   mbmi->num_proj_ref[0] = 0;
   mbmi->num_proj_ref[1] = 0;
 #endif  // CONFIG_WARPED_MOTION
 
   if (is_comp_pred) {
     if (frame_mv[refs[0]].as_int == INVALID_MV ||
         frame_mv[refs[1]].as_int == INVALID_MV)
       return INT64_MAX;
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  } else if (is_singleref_comp_mode) {
+    if (frame_mv[refs[0]].as_int == INVALID_MV ||
+        frame_comp_mv[refs[0]].as_int == INVALID_MV)
+      return INT64_MAX;
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   }
 
   mbmi->motion_mode = SIMPLE_TRANSLATION;
   if (have_newmv_in_inter_mode(this_mode)) {
-    const int64_t ret_val = handle_newmv(cpi, x, bsize, mode_mv, mi_row, mi_col,
-                                         &rate_mv, single_newmv, args);
+    const int64_t ret_val =
+        handle_newmv(cpi, x, bsize, mode_mv,
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+                     mode_comp_mv,
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+                     mi_row, mi_col, &rate_mv, single_newmv, args);
     if (ret_val != 0)
       return ret_val;
     else
       rd_stats->rate += rate_mv;
   }
   for (i = 0; i < is_comp_pred + 1; ++i) {
     cur_mv[i] = frame_mv[refs[i]];
     // Clip "next_nearest" so that it does not extend to far out of image
     if (this_mode != NEWMV) clamp_mv2(&cur_mv[i].as_mv, xd);
     if (mv_check_bounds(&x->mv_limits, &cur_mv[i].as_mv)) return INT64_MAX;
     mbmi->mv[i].as_int = cur_mv[i].as_int;
   }
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  if (!is_comp_pred && is_singleref_comp_mode) {
+    cur_mv[1] = frame_comp_mv[refs[0]];
+    // Clip "next_nearest" so that it does not extend to far out of image
+    if (this_mode != NEWMV) clamp_mv2(&cur_mv[1].as_mv, xd);
+    if (mv_check_bounds(&x->mv_limits, &cur_mv[1].as_mv)) return INT64_MAX;
+    mbmi->mv[1].as_int = cur_mv[1].as_int;
+  }
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
 #if CONFIG_EXT_INTER
   if (this_mode == NEAREST_NEARESTMV)
 #else
   if (this_mode == NEARESTMV && is_comp_pred)
 #endif  // CONFIG_EXT_INTER
   {
 #if !CONFIG_EXT_INTER
     uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
@@ -7609,17 +8421,22 @@ static int64_t handle_inter_mode(
         if (mv_check_bounds(&x->mv_limits, &cur_mv[i].as_mv)) return INT64_MAX;
         mbmi->mv[i].as_int = cur_mv[i].as_int;
       }
     }
   }
 
 #if CONFIG_EXT_INTER
   if (mbmi_ext->ref_mv_count[ref_frame_type] > 0) {
+#if CONFIG_COMPOUND_SINGLEREF
+    if (this_mode == NEAREST_NEWMV ||  // this_mode == SR_NEAREST_NEWMV ||
+        this_mode == SR_NEAREST_NEARMV) {
+#else   // !CONFIG_COMPOUND_SINGLEREF
     if (this_mode == NEAREST_NEWMV) {
+#endif  // CONFIG_COMPOUND_SINGLEREF
       cur_mv[0] = mbmi_ext->ref_mv_stack[ref_frame_type][0].this_mv;
 
       lower_mv_precision(&cur_mv[0].as_mv, cm->allow_high_precision_mv);
       clamp_mv2(&cur_mv[0].as_mv, xd);
       if (mv_check_bounds(&x->mv_limits, &cur_mv[0].as_mv)) return INT64_MAX;
       mbmi->mv[0].as_int = cur_mv[0].as_int;
     }
 
@@ -7630,35 +8447,48 @@ static int64_t handle_inter_mode(
       clamp_mv2(&cur_mv[1].as_mv, xd);
       if (mv_check_bounds(&x->mv_limits, &cur_mv[1].as_mv)) return INT64_MAX;
       mbmi->mv[1].as_int = cur_mv[1].as_int;
     }
   }
 
   if (mbmi_ext->ref_mv_count[ref_frame_type] > 1) {
     int ref_mv_idx = mbmi->ref_mv_idx + 1;
-    if (this_mode == NEAR_NEWMV || this_mode == NEAR_NEARMV) {
+    if (this_mode == NEAR_NEWMV ||
+#if CONFIG_COMPOUND_SINGLEREF
+        this_mode == SR_NEAR_NEWMV ||
+#endif  // CONFIG_COMPOUND_SINGLEREF
+        this_mode == NEAR_NEARMV) {
       cur_mv[0] = mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
 
       lower_mv_precision(&cur_mv[0].as_mv, cm->allow_high_precision_mv);
       clamp_mv2(&cur_mv[0].as_mv, xd);
       if (mv_check_bounds(&x->mv_limits, &cur_mv[0].as_mv)) return INT64_MAX;
       mbmi->mv[0].as_int = cur_mv[0].as_int;
     }
 
-    if (this_mode == NEW_NEARMV || this_mode == NEAR_NEARMV) {
-      cur_mv[1] = mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
+    if (this_mode == NEW_NEARMV ||
+#if CONFIG_COMPOUND_SINGLEREF
+        this_mode == SR_NEAREST_NEARMV ||
+#endif  // CONFIG_COMPOUND_SINGLEREF
+        this_mode == NEAR_NEARMV) {
+#if CONFIG_COMPOUND_SINGLEREF
+      if (this_mode == SR_NEAREST_NEARMV)
+        cur_mv[1] = mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
+      else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+        cur_mv[1] = mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
 
       lower_mv_precision(&cur_mv[1].as_mv, cm->allow_high_precision_mv);
       clamp_mv2(&cur_mv[1].as_mv, xd);
       if (mv_check_bounds(&x->mv_limits, &cur_mv[1].as_mv)) return INT64_MAX;
       mbmi->mv[1].as_int = cur_mv[1].as_int;
     }
   }
-#else
+#else   // !CONFIG_EXT_INTER
   if (this_mode == NEARMV && is_comp_pred) {
     uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
     if (mbmi_ext->ref_mv_count[ref_frame_type] > 1) {
       int ref_mv_idx = mbmi->ref_mv_idx + 1;
       cur_mv[0] = mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
       cur_mv[1] = mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
 
       for (i = 0; i < 2; ++i) {
@@ -7701,17 +8531,17 @@ static int64_t handle_inter_mode(
 #else
     rd_stats->rate += AOMMIN(cost_mv_ref(cpi, this_mode, mode_ctx),
                              cost_mv_ref(cpi, NEARESTMV, mode_ctx));
 #endif  // CONFIG_EXT_INTER
   } else {
     rd_stats->rate += cost_mv_ref(cpi, this_mode, mode_ctx);
   }
 
-  if (RDCOST(x->rdmult, x->rddiv, rd_stats->rate, 0) > ref_best_rd &&
+  if (RDCOST(x->rdmult, rd_stats->rate, 0) > ref_best_rd &&
 #if CONFIG_EXT_INTER
       mbmi->mode != NEARESTMV && mbmi->mode != NEAREST_NEARESTMV
 #else
       mbmi->mode != NEARESTMV
 #endif  // CONFIG_EXT_INTER
       )
     return INT64_MAX;
 
@@ -7720,34 +8550,36 @@ static int64_t handle_inter_mode(
       &rd, &rs, &skip_txfm_sb, &skip_sse_sb);
   if (ret_val != 0) return ret_val;
 
 #if CONFIG_EXT_INTER
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   best_bmc_mbmi = *mbmi;
   rate2_bmc_nocoeff = rd_stats->rate;
   if (cm->interp_filter == SWITCHABLE) rate2_bmc_nocoeff += rs;
-#if CONFIG_MOTION_VAR
   rate_mv_bmc = rate_mv;
-#endif  // CONFIG_MOTION_VAR
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
 #if CONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT
+#if CONFIG_COMPOUND_SINGLEREF
+  if (is_comp_pred || is_singleref_comp_mode) {
+#else
   if (is_comp_pred) {
+#endif  // CONFIG_COMPOUND_SINGLEREF
     int rate_sum, rs2;
     int64_t dist_sum;
     int64_t best_rd_compound = INT64_MAX, best_rd_cur = INT64_MAX;
     INTERINTER_COMPOUND_DATA best_compound_data;
     int_mv best_mv[2];
     int best_tmp_rate_mv = rate_mv;
     int tmp_skip_txfm_sb;
     int64_t tmp_skip_sse_sb;
     int compound_type_cost[COMPOUND_TYPES];
-    uint8_t pred0[2 * MAX_SB_SQUARE];
-    uint8_t pred1[2 * MAX_SB_SQUARE];
+    DECLARE_ALIGNED(16, uint8_t, pred0[2 * MAX_SB_SQUARE]);
+    DECLARE_ALIGNED(16, uint8_t, pred1[2 * MAX_SB_SQUARE]);
     uint8_t *preds0[1] = { pred0 };
     uint8_t *preds1[1] = { pred1 };
     int strides[1] = { bw };
     int tmp_rate_mv;
     int masked_compound_used = is_any_masked_compound_used(bsize);
 #if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
     masked_compound_used = masked_compound_used && cm->allow_masked_compound;
 #endif  // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
@@ -7756,29 +8588,40 @@ static int64_t handle_inter_mode(
     best_mv[0].as_int = cur_mv[0].as_int;
     best_mv[1].as_int = cur_mv[1].as_int;
     memset(&best_compound_data, 0, sizeof(best_compound_data));
 #if CONFIG_COMPOUND_SEGMENT
     uint8_t tmp_mask_buf[2 * MAX_SB_SQUARE];
     best_compound_data.seg_mask = tmp_mask_buf;
 #endif  // CONFIG_COMPOUND_SEGMENT
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    // TODO(zoeliu): To further check whether the following setups are needed.
+    // Single ref compound mode: Prepare the 2nd ref frame predictor the same as
+    // the 1st one.
+    if (!is_comp_pred && is_singleref_comp_mode) {
+      xd->block_refs[1] = xd->block_refs[0];
+      for (i = 0; i < MAX_MB_PLANE; i++)
+        xd->plane[i].pre[1] = xd->plane[i].pre[0];
+    }
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
     if (masked_compound_used) {
       av1_cost_tokens(compound_type_cost, cm->fc->compound_type_prob[bsize],
                       av1_compound_type_tree);
       // get inter predictors to use for masked compound modes
       av1_build_inter_predictors_for_planes_single_buf(
           xd, bsize, 0, 0, mi_row, mi_col, 0, preds0, strides);
       av1_build_inter_predictors_for_planes_single_buf(
           xd, bsize, 0, 0, mi_row, mi_col, 1, preds1, strides);
     }
 
     for (cur_type = COMPOUND_AVERAGE; cur_type < COMPOUND_TYPES; cur_type++) {
       if (cur_type != COMPOUND_AVERAGE && !masked_compound_used) break;
-      if (!is_interinter_compound_used(cur_type, bsize)) break;
+      if (!is_interinter_compound_used(cur_type, bsize)) continue;
       tmp_rate_mv = rate_mv;
       best_rd_cur = INT64_MAX;
       mbmi->interinter_compound_type = cur_type;
       rs2 = av1_cost_literal(get_interinter_compound_type_bits(
                 bsize, mbmi->interinter_compound_type)) +
             (masked_compound_used
                  ? compound_type_cost[mbmi->interinter_compound_type]
                  : 0);
@@ -7787,18 +8630,17 @@ static int64_t handle_inter_mode(
         case COMPOUND_AVERAGE:
           av1_build_inter_predictors_sby(cm, xd, mi_row, mi_col, &orig_dst,
                                          bsize);
           av1_subtract_plane(x, bsize, 0);
           rd = estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum,
                                    &tmp_skip_txfm_sb, &tmp_skip_sse_sb,
                                    INT64_MAX);
           if (rd != INT64_MAX)
-            best_rd_cur =
-                RDCOST(x->rdmult, x->rddiv, rs2 + rate_mv + rate_sum, dist_sum);
+            best_rd_cur = RDCOST(x->rdmult, rs2 + rate_mv + rate_sum, dist_sum);
           best_rd_compound = best_rd_cur;
           break;
 #if CONFIG_WEDGE
         case COMPOUND_WEDGE:
           if (x->source_variance > cpi->sf.disable_wedge_search_var_thresh &&
               best_rd_compound / 3 < ref_best_rd) {
             best_rd_cur = build_and_cost_compound_type(
                 cpi, x, cur_mv, bsize, this_mode, rs2, rate_mv, &orig_dst,
@@ -7918,95 +8760,93 @@ static int64_t handle_inter_mode(
     for (j = 0; j < INTERINTRA_MODES; ++j) {
       mbmi->interintra_mode = (INTERINTRA_MODE)j;
       rmode = interintra_mode_cost[mbmi->interintra_mode];
       av1_build_intra_predictors_for_interintra(xd, bsize, 0, &orig_dst,
                                                 intrapred, bw);
       av1_combine_interintra(xd, bsize, 0, tmp_buf, bw, intrapred, bw);
       model_rd_for_sb(cpi, bsize, x, xd, 0, 0, &rate_sum, &dist_sum,
                       &tmp_skip_txfm_sb, &tmp_skip_sse_sb);
-      rd =
-          RDCOST(x->rdmult, x->rddiv, tmp_rate_mv + rate_sum + rmode, dist_sum);
+      rd = RDCOST(x->rdmult, tmp_rate_mv + rate_sum + rmode, dist_sum);
       if (rd < best_interintra_rd) {
         best_interintra_rd = rd;
         best_interintra_mode = mbmi->interintra_mode;
       }
     }
     mbmi->interintra_mode = best_interintra_mode;
     rmode = interintra_mode_cost[mbmi->interintra_mode];
     av1_build_intra_predictors_for_interintra(xd, bsize, 0, &orig_dst,
                                               intrapred, bw);
     av1_combine_interintra(xd, bsize, 0, tmp_buf, bw, intrapred, bw);
     av1_subtract_plane(x, bsize, 0);
     rd = estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum,
                              &tmp_skip_txfm_sb, &tmp_skip_sse_sb, INT64_MAX);
     if (rd != INT64_MAX)
-      rd = RDCOST(x->rdmult, x->rddiv, rate_mv + rmode + rate_sum, dist_sum);
+      rd = RDCOST(x->rdmult, rate_mv + rmode + rate_sum, dist_sum);
     best_interintra_rd = rd;
 
     if (ref_best_rd < INT64_MAX && best_interintra_rd > 2 * ref_best_rd) {
       // Don't need to call restore_dst_buf here
       return INT64_MAX;
     }
 #if CONFIG_WEDGE
     if (is_interintra_wedge_used(bsize)) {
       int64_t best_interintra_rd_nowedge = INT64_MAX;
       int64_t best_interintra_rd_wedge = INT64_MAX;
       int_mv tmp_mv;
       int rwedge = av1_cost_bit(cm->fc->wedge_interintra_prob[bsize], 0);
       if (rd != INT64_MAX)
-        rd = RDCOST(x->rdmult, x->rddiv, rmode + rate_mv + rwedge + rate_sum,
-                    dist_sum);
+        rd = RDCOST(x->rdmult, rmode + rate_mv + rwedge + rate_sum, dist_sum);
       best_interintra_rd_nowedge = best_interintra_rd;
 
       // Disable wedge search if source variance is small
       if (x->source_variance > cpi->sf.disable_wedge_search_var_thresh) {
         mbmi->use_wedge_interintra = 1;
 
         rwedge = av1_cost_literal(get_interintra_wedge_bits(bsize)) +
                  av1_cost_bit(cm->fc->wedge_interintra_prob[bsize], 1);
 
         best_interintra_rd_wedge =
             pick_interintra_wedge(cpi, x, bsize, intrapred_, tmp_buf_);
 
         best_interintra_rd_wedge +=
-            RDCOST(x->rdmult, x->rddiv, rmode + rate_mv + rwedge, 0);
+            RDCOST(x->rdmult, rmode + rate_mv + rwedge, 0);
         // Refine motion vector.
         if (have_newmv_in_inter_mode(this_mode)) {
           // get negative of mask
           const uint8_t *mask = av1_get_contiguous_soft_mask(
               mbmi->interintra_wedge_index, 1, bsize);
           tmp_mv.as_int = x->mbmi_ext->ref_mvs[refs[0]][0].as_int;
           compound_single_motion_search(cpi, x, bsize, &tmp_mv.as_mv, mi_row,
                                         mi_col, intrapred, mask, bw,
-                                        &tmp_rate_mv, 0, 0);
+                                        &tmp_rate_mv, 0);
           mbmi->mv[0].as_int = tmp_mv.as_int;
           av1_build_inter_predictors_sby(cm, xd, mi_row, mi_col, &orig_dst,
                                          bsize);
           model_rd_for_sb(cpi, bsize, x, xd, 0, 0, &rate_sum, &dist_sum,
                           &tmp_skip_txfm_sb, &tmp_skip_sse_sb);
-          rd = RDCOST(x->rdmult, x->rddiv,
-                      rmode + tmp_rate_mv + rwedge + rate_sum, dist_sum);
+          rd = RDCOST(x->rdmult, rmode + tmp_rate_mv + rwedge + rate_sum,
+                      dist_sum);
           if (rd >= best_interintra_rd_wedge) {
             tmp_mv.as_int = cur_mv[0].as_int;
             tmp_rate_mv = rate_mv;
           }
         } else {
           tmp_mv.as_int = cur_mv[0].as_int;
           tmp_rate_mv = rate_mv;
           av1_combine_interintra(xd, bsize, 0, tmp_buf, bw, intrapred, bw);
         }
         // Evaluate closer to true rd
         av1_subtract_plane(x, bsize, 0);
         rd =
             estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum,
                                 &tmp_skip_txfm_sb, &tmp_skip_sse_sb, INT64_MAX);
         if (rd != INT64_MAX)
-          rd = RDCOST(x->rdmult, x->rddiv,
-                      rmode + tmp_rate_mv + rwedge + rate_sum, dist_sum);
+          rd = RDCOST(x->rdmult, rmode + tmp_rate_mv + rwedge + rate_sum,
+                      dist_sum);
         best_interintra_rd_wedge = rd;
         if (best_interintra_rd_wedge < best_interintra_rd_nowedge) {
           mbmi->use_wedge_interintra = 1;
           mbmi->mv[0].as_int = tmp_mv.as_int;
           rd_stats->rate += tmp_rate_mv - rate_mv;
           rate_mv = tmp_rate_mv;
         } else {
           mbmi->use_wedge_interintra = 0;
@@ -8037,17 +8877,17 @@ static int64_t handle_inter_mode(
 #endif  // CONFIG_INTERINTRA
 
   if (pred_exists == 0) {
     int tmp_rate;
     int64_t tmp_dist;
     av1_build_inter_predictors_sb(cm, xd, mi_row, mi_col, &orig_dst, bsize);
     model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, &tmp_rate,
                     &tmp_dist, &skip_txfm_sb, &skip_sse_sb);
-    rd = RDCOST(x->rdmult, x->rddiv, rs + tmp_rate, tmp_dist);
+    rd = RDCOST(x->rdmult, rs + tmp_rate, tmp_dist);
   }
 #endif  // CONFIG_EXT_INTER
 
   if (!is_comp_pred)
 #if CONFIG_DUAL_FILTER
     args->single_filter[this_mode][refs[0]] = mbmi->interp_filter[0];
 #else
     args->single_filter[this_mode][refs[0]] = mbmi->interp_filter;
@@ -8092,20 +8932,17 @@ static int64_t handle_inter_mode(
 #endif
 
   ret_val = motion_mode_rd(cpi, x, bsize, rd_stats, rd_stats_y, rd_stats_uv,
                            disable_skip, mode_mv, mi_row, mi_col, args,
                            ref_best_rd, refs, rate_mv,
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
                            single_newmv,
 #if CONFIG_EXT_INTER
-                           rate2_bmc_nocoeff, &best_bmc_mbmi,
-#if CONFIG_MOTION_VAR
-                           rate_mv_bmc,
-#endif  // CONFIG_MOTION_VAR
+                           rate2_bmc_nocoeff, &best_bmc_mbmi, rate_mv_bmc,
 #endif  // CONFIG_EXT_INTER
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
                            rs, &skip_txfm_sb, &skip_sse_sb, &orig_dst);
   if (ret_val != 0) return ret_val;
 
   return 0;  // The rate-distortion cost will be re-calculated by caller.
 }
 
@@ -8228,22 +9065,22 @@ static int64_t rd_pick_intrabc_mode_sb(c
     for (int idx = 0; idx < 4; ++idx) mbmi->interp_filter[idx] = BILINEAR;
 #else
     mbmi->interp_filter = BILINEAR;
 #endif
     mbmi->skip = 0;
     x->skip = 0;
     av1_build_inter_predictors_sb(cm, xd, mi_row, mi_col, NULL, bsize);
 
+    assert(x->mvcost == x->mv_cost_stack[0]);
+    // TODO(aconverse@google.com): The full motion field defining discount
+    // in MV_COST_WEIGHT is too large. Explore other values.
     int rate_mv = av1_mv_bit_cost(&dv, &dv_ref.as_mv, x->nmvjointcost,
-                                  x->mvcost, MV_COST_WEIGHT);
-    const PREDICTION_MODE A = av1_above_block_mode(mi, xd->above_mi, 0);
-    const PREDICTION_MODE L = av1_left_block_mode(mi, xd->left_mi, 0);
-    const int rate_mode = cpi->y_mode_costs[A][L][DC_PRED] +
-                          av1_cost_bit(ec_ctx->intrabc_prob, 1);
+                                  x->mvcost, MV_COST_WEIGHT_SUB);
+    const int rate_mode = av1_cost_bit(ec_ctx->intrabc_prob, 1);
 
     RD_STATS rd_stats, rd_stats_uv;
     av1_subtract_plane(x, bsize, 0);
     super_block_yrd(cpi, x, &rd_stats, bsize, INT64_MAX);
     super_block_uvrd(cpi, x, &rd_stats_uv, bsize, INT64_MAX);
     av1_merge_rd_stats(&rd_stats, &rd_stats_uv);
 #if CONFIG_RD_DEBUG
     mbmi->rd_stats = rd_stats;
@@ -8262,32 +9099,31 @@ static int64_t rd_pick_intrabc_mode_sb(c
 
     const aom_prob skip_prob = av1_get_skip_prob(cm, xd);
 
     RD_STATS rdc_noskip;
     av1_init_rd_stats(&rdc_noskip);
     rdc_noskip.rate =
         rate_mode + rate_mv + rd_stats.rate + av1_cost_bit(skip_prob, 0);
     rdc_noskip.dist = rd_stats.dist;
-    rdc_noskip.rdcost =
-        RDCOST(x->rdmult, x->rddiv, rdc_noskip.rate, rdc_noskip.dist);
+    rdc_noskip.rdcost = RDCOST(x->rdmult, rdc_noskip.rate, rdc_noskip.dist);
     if (rdc_noskip.rdcost < best_rd) {
       best_rd = rdc_noskip.rdcost;
       best_mbmi = *mbmi;
       best_skip = x->skip;
       best_rdcost = rdc_noskip;
     }
 
     x->skip = 1;
     mbmi->skip = 1;
     RD_STATS rdc_skip;
     av1_init_rd_stats(&rdc_skip);
     rdc_skip.rate = rate_mode + rate_mv + av1_cost_bit(skip_prob, 1);
     rdc_skip.dist = rd_stats.sse;
-    rdc_skip.rdcost = RDCOST(x->rdmult, x->rddiv, rdc_skip.rate, rdc_skip.dist);
+    rdc_skip.rdcost = RDCOST(x->rdmult, rdc_skip.rate, rdc_skip.dist);
     if (rdc_skip.rdcost < best_rd) {
       best_rd = rdc_skip.rdcost;
       best_mbmi = *mbmi;
       best_skip = x->skip;
       best_rdcost = rdc_skip;
     }
   }
   *mbmi = best_mbmi;
@@ -8297,42 +9133,63 @@ static int64_t rd_pick_intrabc_mode_sb(c
 }
 #endif  // CONFIG_INTRABC
 
 void av1_rd_pick_intra_mode_sb(const AV1_COMP *cpi, MACROBLOCK *x,
                                RD_STATS *rd_cost, BLOCK_SIZE bsize,
                                PICK_MODE_CONTEXT *ctx, int64_t best_rd) {
   const AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *const xd = &x->e_mbd;
+  MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
   struct macroblockd_plane *const pd = xd->plane;
   int rate_y = 0, rate_uv = 0, rate_y_tokenonly = 0, rate_uv_tokenonly = 0;
   int y_skip = 0, uv_skip = 0;
   int64_t dist_y = 0, dist_uv = 0;
   TX_SIZE max_uv_tx_size;
   const int unify_bsize = CONFIG_CB4X4;
 
   ctx->skip = 0;
-  xd->mi[0]->mbmi.ref_frame[0] = INTRA_FRAME;
-  xd->mi[0]->mbmi.ref_frame[1] = NONE_FRAME;
+  mbmi->ref_frame[0] = INTRA_FRAME;
+  mbmi->ref_frame[1] = NONE_FRAME;
 #if CONFIG_INTRABC
-  xd->mi[0]->mbmi.use_intrabc = 0;
-  xd->mi[0]->mbmi.mv[0].as_int = 0;
+  mbmi->use_intrabc = 0;
+  mbmi->mv[0].as_int = 0;
 #endif  // CONFIG_INTRABC
 
   const int64_t intra_yrd =
       (bsize >= BLOCK_8X8 || unify_bsize)
           ? rd_pick_intra_sby_mode(cpi, x, &rate_y, &rate_y_tokenonly, &dist_y,
                                    &y_skip, bsize, best_rd)
           : rd_pick_intra_sub_8x8_y_mode(cpi, x, &rate_y, &rate_y_tokenonly,
                                          &dist_y, &y_skip, best_rd);
 
   if (intra_yrd < best_rd) {
-    max_uv_tx_size = uv_txsize_lookup[bsize][xd->mi[0]->mbmi.tx_size]
-                                     [pd[1].subsampling_x][pd[1].subsampling_y];
-    init_sbuv_mode(&xd->mi[0]->mbmi);
+#if CONFIG_CFL
+    // Perform one extra txfm_rd_in_plane() call, this time with the best value
+    // so we can store reconstructed luma values
+    RD_STATS this_rd_stats;
+
+#if CONFIG_CB4X4
+    // Don't store the luma value if no chroma is associated.
+    // Don't worry, we will store this reconstructed luma in the following
+    // encode dry-run the chroma plane will never know.
+    x->cfl_store_y = !x->skip_chroma_rd;
+#else
+    x->cfl_store_y = 1;
+#endif
+
+    txfm_rd_in_plane(x, cpi, &this_rd_stats, INT64_MAX, AOM_PLANE_Y,
+                     mbmi->sb_type, mbmi->tx_size,
+                     cpi->sf.use_fast_coef_costing);
+
+    x->cfl_store_y = 0;
+#endif
+    max_uv_tx_size = uv_txsize_lookup[bsize][mbmi->tx_size][pd[1].subsampling_x]
+                                     [pd[1].subsampling_y];
+    init_sbuv_mode(mbmi);
 #if CONFIG_CB4X4
     if (!x->skip_chroma_rd)
       rd_pick_intra_sbuv_mode(cpi, x, &rate_uv, &rate_uv_tokenonly, &dist_uv,
                               &uv_skip, bsize, max_uv_tx_size);
 #else
     rd_pick_intra_sbuv_mode(cpi, x, &rate_uv, &rate_uv_tokenonly, &dist_uv,
                             &uv_skip, AOMMAX(BLOCK_8X8, bsize), max_uv_tx_size);
 #endif  // CONFIG_CB4X4
@@ -8341,31 +9198,31 @@ void av1_rd_pick_intra_mode_sb(const AV1
       rd_cost->rate = rate_y + rate_uv - rate_y_tokenonly - rate_uv_tokenonly +
                       av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
       rd_cost->dist = dist_y + dist_uv;
     } else {
       rd_cost->rate =
           rate_y + rate_uv + av1_cost_bit(av1_get_skip_prob(cm, xd), 0);
       rd_cost->dist = dist_y + dist_uv;
     }
-    rd_cost->rdcost = RDCOST(x->rdmult, x->rddiv, rd_cost->rate, rd_cost->dist);
+    rd_cost->rdcost = RDCOST(x->rdmult, rd_cost->rate, rd_cost->dist);
 #if CONFIG_DAALA_DIST && CONFIG_CB4X4
     rd_cost->dist_y = dist_y;
 #endif
   } else {
     rd_cost->rate = INT_MAX;
   }
 
 #if CONFIG_INTRABC
   if (rd_cost->rate != INT_MAX && rd_cost->rdcost < best_rd)
     best_rd = rd_cost->rdcost;
   if (rd_pick_intrabc_mode_sb(cpi, x, rd_cost, bsize, best_rd) < best_rd) {
     ctx->skip = x->skip;  // FIXME where is the proper place to set this?!
     assert(rd_cost->rate != INT_MAX);
-    rd_cost->rdcost = RDCOST(x->rdmult, x->rddiv, rd_cost->rate, rd_cost->dist);
+    rd_cost->rdcost = RDCOST(x->rdmult, rd_cost->rate, rd_cost->dist);
   }
 #endif
   if (rd_cost->rate == INT_MAX) return;
 
   ctx->mic = *xd->mi[0];
   ctx->mbmi_ext = *x->mbmi_ext;
 }
 
@@ -8595,17 +9452,18 @@ static void pick_filter_intra_interframe
     rate_y -= tx_size_cost(cpi, x, bsize, mbmi->tx_size);
   }
 
   rate2 += av1_cost_bit(cm->fc->filter_intra_probs[0],
                         mbmi->filter_intra_mode_info.use_filter_intra_mode[0]);
   rate2 += write_uniform_cost(
       FILTER_INTRA_MODES, mbmi->filter_intra_mode_info.filter_intra_mode[0]);
 #if CONFIG_EXT_INTRA
-  if (av1_is_directional_mode(mbmi->uv_mode, bsize)) {
+  if (av1_is_directional_mode(mbmi->uv_mode, bsize) &&
+      av1_use_angle_delta(bsize)) {
     rate2 += write_uniform_cost(2 * MAX_ANGLE_DELTA + 1,
                                 MAX_ANGLE_DELTA + mbmi->angle_delta[1]);
   }
 #endif  // CONFIG_EXT_INTRA
   if (mbmi->mode == DC_PRED) {
     rate2 +=
         av1_cost_bit(cpi->common.fc->filter_intra_probs[1],
                      mbmi->filter_intra_mode_info.use_filter_intra_mode[1]);
@@ -8623,17 +9481,17 @@ static void pick_filter_intra_interframe
   if (skippable) {
     rate2 -= (rate_y + rate_uv);
     rate_y = 0;
     rate_uv = 0;
     rate2 += av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
   } else {
     rate2 += av1_cost_bit(av1_get_skip_prob(cm, xd), 0);
   }
-  this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
+  this_rd = RDCOST(x->rdmult, rate2, distortion2);
 
   if (this_rd < *best_intra_rd) {
     *best_intra_rd = this_rd;
     *best_intra_mode = mbmi->mode;
   }
   for (i = 0; i < REFERENCE_MODES; ++i)
     best_pred_rd[i] = AOMMIN(best_pred_rd[i], this_rd);
 
@@ -8688,16 +9546,19 @@ void av1_rd_pick_inter_mode_sb(const AV1
 #endif  // CONFIG_PALETTE
   MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
   const struct segmentation *const seg = &cm->seg;
   PREDICTION_MODE this_mode;
   MV_REFERENCE_FRAME ref_frame, second_ref_frame;
   unsigned char segment_id = mbmi->segment_id;
   int comp_pred, i, k;
   int_mv frame_mv[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME];
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  int_mv frame_comp_mv[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME];
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   struct buf_2d yv12_mb[TOTAL_REFS_PER_FRAME][MAX_MB_PLANE];
   int_mv single_newmv[TOTAL_REFS_PER_FRAME] = { { 0 } };
 #if CONFIG_EXT_INTER
   int single_newmv_rate[TOTAL_REFS_PER_FRAME] = { 0 };
   int64_t modelled_rd[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME];
 #endif  // CONFIG_EXT_INTER
   static const int flag_list[TOTAL_REFS_PER_FRAME] = {
     0,
@@ -8717,17 +9578,21 @@ void av1_rd_pick_inter_mode_sb(const AV1
   int64_t best_pred_diff[REFERENCE_MODES];
   int64_t best_pred_rd[REFERENCE_MODES];
   MB_MODE_INFO best_mbmode;
   int rate_skip0 = av1_cost_bit(av1_get_skip_prob(cm, xd), 0);
   int rate_skip1 = av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
   int best_mode_skippable = 0;
   int midx, best_mode_index = -1;
   unsigned int ref_costs_single[TOTAL_REFS_PER_FRAME];
+#if CONFIG_EXT_COMP_REFS
+  unsigned int ref_costs_comp[TOTAL_REFS_PER_FRAME][TOTAL_REFS_PER_FRAME];
+#else
   unsigned int ref_costs_comp[TOTAL_REFS_PER_FRAME];
+#endif  // CONFIG_EXT_COMP_REFS
   aom_prob comp_mode_p;
   int64_t best_intra_rd = INT64_MAX;
   unsigned int best_pred_sse = UINT_MAX;
   PREDICTION_MODE best_intra_mode = DC_PRED;
   int rate_uv_intra[TX_SIZES_ALL], rate_uv_tokenonly[TX_SIZES_ALL];
   int64_t dist_uvs[TX_SIZES_ALL];
   int skip_uvs[TX_SIZES_ALL];
   PREDICTION_MODE mode_uv[TX_SIZES_ALL];
@@ -8845,16 +9710,20 @@ void av1_rd_pick_inter_mode_sb(const AV1
     }
   }
 
   rd_cost->rate = INT_MAX;
 #if CONFIG_SUPERTX
   *returnrate_nocoef = INT_MAX;
 #endif  // CONFIG_SUPERTX
 
+#if CONFIG_SPEED_REFS
+  memset(x->mbmi_ext->ref_mvs, 0, sizeof(x->mbmi_ext->ref_mvs));
+#endif  // CONFIG_SPEED_REFS
+
   for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
     x->pred_mv_sad[ref_frame] = INT_MAX;
     x->mbmi_ext->mode_context[ref_frame] = 0;
 #if CONFIG_EXT_INTER
     x->mbmi_ext->compound_mode_context[ref_frame] = 0;
 #endif  // CONFIG_EXT_INTER
     if (cpi->ref_frame_flags & flag_list[ref_frame]) {
       assert(get_ref_frame_buffer(cpi, ref_frame) != NULL);
@@ -8868,16 +9737,20 @@ void av1_rd_pick_inter_mode_sb(const AV1
                              cm->allow_high_precision_mv, bsize, mi_col, mi_row,
                              0)
             .as_int;
 #else   // CONFIG_GLOBAL_MOTION
     frame_mv[ZEROMV][ref_frame].as_int = 0;
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_EXT_INTER
     frame_mv[NEW_NEWMV][ref_frame].as_int = INVALID_MV;
+#if CONFIG_COMPOUND_SINGLEREF
+    frame_mv[SR_NEW_NEWMV][ref_frame].as_int = INVALID_MV;
+    frame_comp_mv[SR_NEW_NEWMV][ref_frame].as_int = INVALID_MV;
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #if CONFIG_GLOBAL_MOTION
     frame_mv[ZERO_ZEROMV][ref_frame].as_int =
         gm_get_motion_vector(&cm->global_motion[ref_frame],
                              cm->allow_high_precision_mv, bsize, mi_col, mi_row,
                              0)
             .as_int;
 #else   // CONFIG_GLOBAL_MOTION
     frame_mv[ZERO_ZEROMV][ref_frame].as_int = 0;
@@ -8929,27 +9802,32 @@ void av1_rd_pick_inter_mode_sb(const AV1
   }
 #endif  // CONFIG_MOTION_VAR
 
   for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
     if (!(cpi->ref_frame_flags & flag_list[ref_frame])) {
 // Skip checking missing references in both single and compound reference
 // modes. Note that a mode will be skipped iff both reference frames
 // are masked out.
+#if CONFIG_EXT_COMP_REFS
+      ref_frame_skip_mask[0] |= (1 << ref_frame);
+      ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK;
+#else  // !CONFIG_EXT_COMP_REFS
 #if CONFIG_EXT_REFS
       if (ref_frame == BWDREF_FRAME || ref_frame == ALTREF_FRAME) {
         ref_frame_skip_mask[0] |= (1 << ref_frame);
         ref_frame_skip_mask[1] |= ((1 << ref_frame) | 0x01);
       } else {
 #endif  // CONFIG_EXT_REFS
         ref_frame_skip_mask[0] |= (1 << ref_frame);
         ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK;
 #if CONFIG_EXT_REFS
       }
 #endif  // CONFIG_EXT_REFS
+#endif  // CONFIG_EXT_COMP_REFS
     } else {
       for (i = LAST_FRAME; i <= ALTREF_FRAME; ++i) {
         // Skip fixed mv modes for poor references
         if ((x->pred_mv_sad[ref_frame] >> 2) > x->pred_mv_sad[i]) {
           mode_skip_mask[ref_frame] |= INTER_NEAREST_NEAR_ZERO;
           break;
         }
       }
@@ -8995,16 +9873,22 @@ void av1_rd_pick_inter_mode_sb(const AV1
         mode_skip_mask[ALTREF_FRAME] |= (1 << NEARMV);
       if (frame_mv[NEARESTMV][ALTREF_FRAME].as_int != zeromv.as_int)
         mode_skip_mask[ALTREF_FRAME] |= (1 << NEARESTMV);
 #if CONFIG_EXT_INTER
       if (frame_mv[NEAREST_NEARESTMV][ALTREF_FRAME].as_int != zeromv.as_int)
         mode_skip_mask[ALTREF_FRAME] |= (1 << NEAREST_NEARESTMV);
       if (frame_mv[NEAR_NEARMV][ALTREF_FRAME].as_int != zeromv.as_int)
         mode_skip_mask[ALTREF_FRAME] |= (1 << NEAR_NEARMV);
+#if CONFIG_COMPOUND_SINGLEREF
+      if (frame_mv[SR_NEAREST_NEARMV][ALTREF_FRAME].as_int != zeromv.as_int ||
+          frame_comp_mv[SR_NEAREST_NEARMV][ALTREF_FRAME].as_int !=
+              zeromv.as_int)
+        mode_skip_mask[ALTREF_FRAME] |= (1 << SR_NEAREST_NEARMV);
+#endif  // CONFIG_COMPOUND_SINGLEREF
 #endif  // CONFIG_EXT_INTER
     }
   }
 
   if (cpi->rc.is_src_frame_alt_ref) {
     if (sf->alt_ref_search_fp) {
       assert(cpi->ref_frame_flags & flag_list[ALTREF_FRAME]);
       mode_skip_mask[ALTREF_FRAME] = 0;
@@ -9101,16 +9985,23 @@ void av1_rd_pick_inter_mode_sb(const AV1
       if (!is_interintra_allowed_bsize(bsize)) continue;
     }
 
     if (is_inter_compound_mode(this_mode)) {
       frame_mv[this_mode][ref_frame].as_int =
           frame_mv[compound_ref0_mode(this_mode)][ref_frame].as_int;
       frame_mv[this_mode][second_ref_frame].as_int =
           frame_mv[compound_ref1_mode(this_mode)][second_ref_frame].as_int;
+#if CONFIG_COMPOUND_SINGLEREF
+    } else if (is_inter_singleref_comp_mode(this_mode)) {
+      frame_mv[this_mode][ref_frame].as_int =
+          frame_mv[compound_ref0_mode(this_mode)][ref_frame].as_int;
+      frame_comp_mv[this_mode][ref_frame].as_int =
+          frame_mv[compound_ref1_mode(this_mode)][ref_frame].as_int;
+#endif  // CONFIG_COMPOUND_SINGLEREF
     }
 #endif  // CONFIG_EXT_INTER
 
     // Look at the reference frame of the best mode so far and set the
     // skip mask to look at a subset of the remaining modes.
     if (midx == mode_skip_start && best_mode_index >= 0) {
       switch (best_mbmode.ref_frame[0]) {
         case INTRA_FRAME: break;
@@ -9149,16 +10040,44 @@ void av1_rd_pick_inter_mode_sb(const AV1
           break;
       }
     }
 
     if ((ref_frame_skip_mask[0] & (1 << ref_frame)) &&
         (ref_frame_skip_mask[1] & (1 << AOMMAX(0, second_ref_frame))))
       continue;
 
+#if CONFIG_EXT_COMP_REFS
+// TODO(zoeliu): Following toggle between #if 0/1 and the bug will manifest
+// itself.
+#if 0
+    if (!(cpi->ref_frame_flags & flag_list[ref_frame]) ||
+        (second_ref_frame > INTRA_FRAME &&
+         (!(cpi->ref_frame_flags & flag_list[second_ref_frame]))))
+      printf("Frame=%d, bsize=%d, (mi_row,mi_col)=(%d,%d), ref_frame=%d, "
+             "second_ref_frame=%d\n", cm->current_video_frame, bsize, mi_row,
+             mi_col, ref_frame, second_ref_frame);
+
+    if (!(cpi->ref_frame_flags & flag_list[ref_frame])) continue;
+    if (second_ref_frame > INTRA_FRAME &&
+        (!(cpi->ref_frame_flags & flag_list[second_ref_frame])))
+      continue;
+#endif  // 0
+
+#if !USE_UNI_COMP_REFS
+    // NOTE(zoeliu): Temporarily disable uni-directional comp refs
+    if (second_ref_frame > INTRA_FRAME) {
+      if (!((ref_frame < BWDREF_FRAME) ^ (second_ref_frame < BWDREF_FRAME)))
+        continue;
+    }
+    assert(second_ref_frame <= INTRA_FRAME ||
+           ((ref_frame < BWDREF_FRAME) ^ (second_ref_frame < BWDREF_FRAME)));
+#endif  // !USE_UNI_COMP_REFS
+#endif  // CONFIG_EXT_COMP_REFS
+
     if (mode_skip_mask[ref_frame] & (1 << this_mode)) continue;
 
     // Test best rd so far against threshold for trying this mode.
     if (best_mode_skippable && sf->schedule_mode_search)
       mode_threshold[mode_index] <<= 1;
 
     if (best_rd < mode_threshold[mode_index]) continue;
 
@@ -9262,27 +10181,36 @@ void av1_rd_pick_inter_mode_sb(const AV1
     set_ref_ptrs(cm, xd, ref_frame, second_ref_frame);
 
     // Select prediction reference frames.
     for (i = 0; i < MAX_MB_PLANE; i++) {
       xd->plane[i].pre[0] = yv12_mb[ref_frame][i];
       if (comp_pred) xd->plane[i].pre[1] = yv12_mb[second_ref_frame][i];
     }
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    // Single ref compound mode
+    if (!comp_pred && is_inter_singleref_comp_mode(mbmi->mode)) {
+      xd->block_refs[1] = xd->block_refs[0];
+      for (i = 0; i < MAX_MB_PLANE; i++)
+        xd->plane[i].pre[1] = xd->plane[i].pre[0];
+    }
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
 #if CONFIG_EXT_INTER && CONFIG_INTERINTRA
     mbmi->interintra_mode = (INTERINTRA_MODE)(II_DC_PRED - 1);
 #endif  // CONFIG_EXT_INTER && CONFIG_INTERINTRA
 
     if (ref_frame == INTRA_FRAME) {
       RD_STATS rd_stats_y;
       TX_SIZE uv_tx;
       struct macroblockd_plane *const pd = &xd->plane[1];
 #if CONFIG_EXT_INTRA
       is_directional_mode = av1_is_directional_mode(mbmi->mode, bsize);
-      if (is_directional_mode) {
+      if (is_directional_mode && av1_use_angle_delta(bsize)) {
         int rate_dummy;
         int64_t model_rd = INT64_MAX;
         if (!angle_stats_ready) {
           const int src_stride = x->plane[0].src.stride;
           const uint8_t *src = x->plane[0].src.buf;
 #if CONFIG_HIGHBITDEPTH
           if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
             highbd_angle_estimation(src, src_stride, rows, cols, bsize,
@@ -9385,20 +10313,23 @@ void av1_rd_pick_inter_mode_sb(const AV1
       if (is_directional_mode) {
 #if CONFIG_INTRA_INTERP
         const int intra_filter_ctx = av1_get_pred_context_intra_interp(xd);
         const int p_angle =
             mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP;
         if (av1_is_intra_filter_switchable(p_angle))
           rate2 += cpi->intra_filter_cost[intra_filter_ctx][mbmi->intra_filter];
 #endif  // CONFIG_INTRA_INTERP
-        rate2 += write_uniform_cost(2 * MAX_ANGLE_DELTA + 1,
-                                    MAX_ANGLE_DELTA + mbmi->angle_delta[0]);
-      }
-      if (mbmi->uv_mode != DC_PRED && mbmi->uv_mode != TM_PRED) {
+        if (av1_use_angle_delta(bsize)) {
+          rate2 += write_uniform_cost(2 * MAX_ANGLE_DELTA + 1,
+                                      MAX_ANGLE_DELTA + mbmi->angle_delta[0]);
+        }
+      }
+      if (av1_is_directional_mode(mbmi->uv_mode, bsize) &&
+          av1_use_angle_delta(bsize)) {
         rate2 += write_uniform_cost(2 * MAX_ANGLE_DELTA + 1,
                                     MAX_ANGLE_DELTA + mbmi->angle_delta[1]);
       }
 #endif  // CONFIG_EXT_INTRA
 #if CONFIG_FILTER_INTRA
       if (mbmi->mode == DC_PRED) {
         rate2 +=
             av1_cost_bit(cm->fc->filter_intra_probs[0],
@@ -9476,16 +10407,37 @@ void av1_rd_pick_inter_mode_sb(const AV1
           if (compound_ref1_mode(mbmi->mode) == NEWMV) {
             int_mv this_mv =
                 mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
             clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
                          xd->n8_h << MI_SIZE_LOG2, xd);
             mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0] = this_mv;
           }
         }
+#if CONFIG_COMPOUND_SINGLEREF
+      } else if (is_inter_singleref_comp_mode(mbmi->mode)) {
+        if (mbmi_ext->ref_mv_count[ref_frame_type] > 1) {
+          // TODO(zoeliu): To further investigate which ref_mv_idx should be
+          //               chosen for the mode of SR_NEAR_NEWMV.
+          int ref_mv_idx = 0;
+          // Special case: SR_NEAR_NEWMV mode use
+          // 1 + mbmi->ref_mv_idx (like NEARMV) instead of
+          // mbmi->ref_mv_idx (like NEWMV)
+          if (mbmi->mode == SR_NEAR_NEWMV) ref_mv_idx = 1;
+
+          if (compound_ref0_mode(mbmi->mode) == NEWMV ||
+              compound_ref1_mode(mbmi->mode) == NEWMV) {
+            int_mv this_mv =
+                mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
+            clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
+                         xd->n8_h << MI_SIZE_LOG2, xd);
+            mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0] = this_mv;
+          }
+        }
+#endif  // CONFIG_COMPOUND_SINGLEREF
       } else {
 #endif  // CONFIG_EXT_INTER
         if (mbmi->mode == NEWMV && mbmi_ext->ref_mv_count[ref_frame_type] > 1) {
           int ref;
           for (ref = 0; ref < 1 + comp_pred; ++ref) {
             int_mv this_mv =
                 (ref == 0) ? mbmi_ext->ref_mv_stack[ref_frame_type][0].this_mv
                            : mbmi_ext->ref_mv_stack[ref_frame_type][0].comp_mv;
@@ -9495,51 +10447,82 @@ void av1_rd_pick_inter_mode_sb(const AV1
           }
         }
 #if CONFIG_EXT_INTER
       }
 #endif  // CONFIG_EXT_INTER
       {
         RD_STATS rd_stats, rd_stats_y, rd_stats_uv;
         av1_init_rd_stats(&rd_stats);
+#if CONFIG_DAALA_DIST && CONFIG_CB4X4
+        // While av1 master uses rd_stats_y.rate through out the codebase,
+        // which is set when handle_inter_moden is called, the daala-dist code
+        // in rd_pick_partition() for cb4x4 and sub8x8 blocks need to know
+        // .dist_y which comes from rd_stats_y.dist and rd_stats_y.sse.
+        // The problem is rd_stats_y.dist and rd_stats_y.sse are sometimes not
+        // initialized when rd_stats.skip = 1,
+        // then instead rd_stats.dist and rd_stats.sse have the
+        // combined luma and chroma dist and sse.
+        // This can be seen inside motion_mode_rd(), which is called by
+        // handle_inter_mode().
+        if (bsize < BLOCK_8X8) av1_init_rd_stats(&rd_stats_y);
+#endif
         rd_stats.rate = rate2;
 
         // Point to variables that are maintained between loop iterations
         args.single_newmv = single_newmv;
 #if CONFIG_EXT_INTER
         args.single_newmv_rate = single_newmv_rate;
         args.modelled_rd = modelled_rd;
 #endif  // CONFIG_EXT_INTER
         this_rd = handle_inter_mode(cpi, x, bsize, &rd_stats, &rd_stats_y,
                                     &rd_stats_uv, &disable_skip, frame_mv,
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+                                    frame_comp_mv,
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
                                     mi_row, mi_col, &args, best_rd);
 
         rate2 = rd_stats.rate;
         skippable = rd_stats.skip;
         distortion2 = rd_stats.dist;
         total_sse = rd_stats.sse;
         rate_y = rd_stats_y.rate;
         rate_uv = rd_stats_uv.rate;
 #if CONFIG_DAALA_DIST && CONFIG_CB4X4
-        if (bsize < BLOCK_8X8) distortion2_y = rd_stats_y.dist;
+        if (bsize < BLOCK_8X8) {
+          if (rd_stats_y.rate != INT_MAX) {
+            assert(rd_stats_y.sse < INT64_MAX);
+            assert(rd_stats_y.dist < INT64_MAX);
+          }
+          total_sse_y = rd_stats_y.sse;
+          distortion2_y = rd_stats_y.dist;
+        }
 #endif
       }
 
 // TODO(jingning): This needs some refactoring to improve code quality
 // and reduce redundant steps.
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+      if ((have_nearmv_in_inter_mode(mbmi->mode) &&
+           mbmi_ext->ref_mv_count[ref_frame_type] > 2) ||
+          ((mbmi->mode == NEWMV || mbmi->mode == SR_NEW_NEWMV ||
+            mbmi->mode == NEW_NEWMV) &&
+           mbmi_ext->ref_mv_count[ref_frame_type] > 1)) {
+#else   // !CONFIG_COMPOUND_SINGLEREF
       if ((have_nearmv_in_inter_mode(mbmi->mode) &&
            mbmi_ext->ref_mv_count[ref_frame_type] > 2) ||
           ((mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV) &&
            mbmi_ext->ref_mv_count[ref_frame_type] > 1)) {
-#else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+#else   // !CONFIG_EXT_INTER
       if ((mbmi->mode == NEARMV &&
            mbmi_ext->ref_mv_count[ref_frame_type] > 2) ||
           (mbmi->mode == NEWMV && mbmi_ext->ref_mv_count[ref_frame_type] > 1)) {
-#endif
+#endif  // CONFIG_EXT_INTER
         int_mv backup_mv = frame_mv[NEARMV][ref_frame];
         MB_MODE_INFO backup_mbmi = *mbmi;
         int backup_skip = x->skip;
         int64_t tmp_ref_rd = this_rd;
         int ref_idx;
 
 // TODO(jingning): This should be deprecated shortly.
 #if CONFIG_EXT_INTER
@@ -9555,43 +10538,42 @@ void av1_rd_pick_inter_mode_sb(const AV1
         // Dummy
         int_mv backup_fmv[2];
         backup_fmv[0] = frame_mv[NEWMV][ref_frame];
         if (comp_pred) backup_fmv[1] = frame_mv[NEWMV][second_ref_frame];
 
         rate2 += (rate2 < INT_MAX ? cpi->drl_mode_cost0[drl_ctx][0] : 0);
 
         if (this_rd < INT64_MAX) {
-          if (RDCOST(x->rdmult, x->rddiv, rate_y + rate_uv, distortion2) <
-              RDCOST(x->rdmult, x->rddiv, 0, total_sse))
-            tmp_ref_rd =
-                RDCOST(x->rdmult, x->rddiv,
-                       rate2 + av1_cost_bit(av1_get_skip_prob(cm, xd), 0),
-                       distortion2);
+          if (RDCOST(x->rdmult, rate_y + rate_uv, distortion2) <
+              RDCOST(x->rdmult, 0, total_sse))
+            tmp_ref_rd = RDCOST(
+                x->rdmult, rate2 + av1_cost_bit(av1_get_skip_prob(cm, xd), 0),
+                distortion2);
           else
-            tmp_ref_rd =
-                RDCOST(x->rdmult, x->rddiv,
-                       rate2 + av1_cost_bit(av1_get_skip_prob(cm, xd), 1) -
-                           rate_y - rate_uv,
-                       total_sse);
+            tmp_ref_rd = RDCOST(
+                x->rdmult, rate2 + av1_cost_bit(av1_get_skip_prob(cm, xd), 1) -
+                               rate_y - rate_uv,
+                total_sse);
         }
 #if CONFIG_VAR_TX
         for (i = 0; i < MAX_MB_PLANE; ++i)
           memcpy(x->blk_skip_drl[i], x->blk_skip[i],
                  sizeof(uint8_t) * ctx->num_4x4_blk);
 #endif  // CONFIG_VAR_TX
 
         for (ref_idx = 0; ref_idx < ref_set; ++ref_idx) {
           int64_t tmp_alt_rd = INT64_MAX;
           int dummy_disable_skip = 0;
           int ref;
           int_mv cur_mv;
           RD_STATS tmp_rd_stats, tmp_rd_stats_y, tmp_rd_stats_uv;
 
           av1_invalid_rd_stats(&tmp_rd_stats);
+
           x->skip = 0;
 
           mbmi->ref_mv_idx = 1 + ref_idx;
 
 #if CONFIG_EXT_INTER
           if (comp_pred) {
             int ref_mv_idx = mbmi->ref_mv_idx;
             // Special case: NEAR_NEWMV and NEW_NEARMV modes use
@@ -9622,16 +10604,44 @@ void av1_rd_pick_inter_mode_sb(const AV1
               mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0] = this_mv;
             } else if (compound_ref1_mode(mbmi->mode) == NEARESTMV) {
               int_mv this_mv =
                   mbmi_ext->ref_mv_stack[ref_frame_type][0].comp_mv;
               clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
                            xd->n8_h << MI_SIZE_LOG2, xd);
               mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0] = this_mv;
             }
+#if CONFIG_COMPOUND_SINGLEREF
+          } else if (is_inter_singleref_comp_mode(mbmi->mode)) {
+            int ref_mv_idx = mbmi->ref_mv_idx;
+            // Special case: SR_NEAR_NEWMV mode use
+            // 1 + mbmi->ref_mv_idx (like NEARMV) instead of
+            // mbmi->ref_mv_idx (like NEWMV)
+            if (mbmi->mode == SR_NEAR_NEWMV) ref_mv_idx = 1 + mbmi->ref_mv_idx;
+
+            // TODO(zoeliu): For the mode of SR_NEAREST_NEWMV, as it only runs
+            //               the "if", not the "else if",
+            //               mbmi_ext->ref_mvs[mbmi->ref_frame[0]] takes the
+            //               value for "NEWMV", instead of "NEARESTMV".
+            if (compound_ref0_mode(mbmi->mode) == NEWMV ||
+                compound_ref1_mode(mbmi->mode) == NEWMV) {
+              int_mv this_mv =
+                  mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
+              clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
+                           xd->n8_h << MI_SIZE_LOG2, xd);
+              mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0] = this_mv;
+            } else if (compound_ref0_mode(mbmi->mode) == NEARESTMV ||
+                       compound_ref1_mode(mbmi->mode) == NEARESTMV) {
+              int_mv this_mv =
+                  mbmi_ext->ref_mv_stack[ref_frame_type][0].this_mv;
+              clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
+                           xd->n8_h << MI_SIZE_LOG2, xd);
+              mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0] = this_mv;
+            }
+#endif  // CONFIG_COMPOUND_SINGLEREF
           } else {
 #endif  // CONFIG_EXT_INTER
             for (ref = 0; ref < 1 + comp_pred; ++ref) {
               int_mv this_mv =
                   (ref == 0)
                       ? mbmi_ext->ref_mv_stack[ref_frame_type][mbmi->ref_mv_idx]
                             .this_mv
                       : mbmi_ext->ref_mv_stack[ref_frame_type][mbmi->ref_mv_idx]
@@ -9652,26 +10662,38 @@ void av1_rd_pick_inter_mode_sb(const AV1
           if (!mv_check_bounds(&x->mv_limits, &cur_mv.as_mv)) {
             int_mv dummy_single_newmv[TOTAL_REFS_PER_FRAME] = { { 0 } };
 #if CONFIG_EXT_INTER
             int dummy_single_newmv_rate[TOTAL_REFS_PER_FRAME] = { 0 };
 #endif  // CONFIG_EXT_INTER
 
             frame_mv[NEARMV][ref_frame] = cur_mv;
             av1_init_rd_stats(&tmp_rd_stats);
-
+#if CONFIG_DAALA_DIST && CONFIG_CB4X4
+            // With the same reason as 'rd_stats_y' passed to above
+            // handle_inter_mode(), tmp_rd_stats_y.dist and
+            // tmp_rd_stats_y.sse are sometimes not initialized, esp. when
+            // tmp_rd_stats.skip = 1 and tmp_rd_stats.dist and .sse
+            // represent combined luma and chroma .dist and .sse,
+            // we should initialized tmp_rd_stats_y.
+            if (bsize < BLOCK_8X8) av1_init_rd_stats(&tmp_rd_stats_y);
+#endif
             // Point to variables that are not maintained between iterations
             args.single_newmv = dummy_single_newmv;
 #if CONFIG_EXT_INTER
             args.single_newmv_rate = dummy_single_newmv_rate;
             args.modelled_rd = NULL;
 #endif  // CONFIG_EXT_INTER
-            tmp_alt_rd = handle_inter_mode(
-                cpi, x, bsize, &tmp_rd_stats, &tmp_rd_stats_y, &tmp_rd_stats_uv,
-                &dummy_disable_skip, frame_mv, mi_row, mi_col, &args, best_rd);
+            tmp_alt_rd = handle_inter_mode(cpi, x, bsize, &tmp_rd_stats,
+                                           &tmp_rd_stats_y, &tmp_rd_stats_uv,
+                                           &dummy_disable_skip, frame_mv,
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+                                           frame_comp_mv,
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+                                           mi_row, mi_col, &args, best_rd);
             // Prevent pointers from escaping local scope
             args.single_newmv = NULL;
 #if CONFIG_EXT_INTER
             args.single_newmv_rate = NULL;
 #endif  // CONFIG_EXT_INTER
           }
 
           for (i = 0; i < mbmi->ref_mv_idx; ++i) {
@@ -9691,35 +10713,32 @@ void av1_rd_pick_inter_mode_sb(const AV1
                             mbmi->ref_mv_idx + idx_offset);
             tmp_rd_stats.rate +=
                 (tmp_rd_stats.rate < INT_MAX ? cpi->drl_mode_cost0[drl1_ctx][0]
                                              : 0);
           }
 
           if (tmp_alt_rd < INT64_MAX) {
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
-            tmp_alt_rd = RDCOST(x->rdmult, x->rddiv, tmp_rd_stats.rate,
-                                tmp_rd_stats.dist);
-#else
-            if (RDCOST(x->rdmult, x->rddiv,
-                       tmp_rd_stats_y.rate + tmp_rd_stats_uv.rate,
+            tmp_alt_rd =
+                RDCOST(x->rdmult, tmp_rd_stats.rate, tmp_rd_stats.dist);
+#else
+            if (RDCOST(x->rdmult, tmp_rd_stats_y.rate + tmp_rd_stats_uv.rate,
                        tmp_rd_stats.dist) <
-                RDCOST(x->rdmult, x->rddiv, 0, tmp_rd_stats.sse))
-              tmp_alt_rd =
-                  RDCOST(x->rdmult, x->rddiv,
-                         tmp_rd_stats.rate +
-                             av1_cost_bit(av1_get_skip_prob(cm, xd), 0),
-                         tmp_rd_stats.dist);
+                RDCOST(x->rdmult, 0, tmp_rd_stats.sse))
+              tmp_alt_rd = RDCOST(
+                  x->rdmult, tmp_rd_stats.rate +
+                                 av1_cost_bit(av1_get_skip_prob(cm, xd), 0),
+                  tmp_rd_stats.dist);
             else
-              tmp_alt_rd =
-                  RDCOST(x->rdmult, x->rddiv,
-                         tmp_rd_stats.rate +
-                             av1_cost_bit(av1_get_skip_prob(cm, xd), 1) -
-                             tmp_rd_stats_y.rate - tmp_rd_stats_uv.rate,
-                         tmp_rd_stats.sse);
+              tmp_alt_rd = RDCOST(
+                  x->rdmult, tmp_rd_stats.rate +
+                                 av1_cost_bit(av1_get_skip_prob(cm, xd), 1) -
+                                 tmp_rd_stats_y.rate - tmp_rd_stats_uv.rate,
+                  tmp_rd_stats.sse);
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
           }
 
           if (tmp_ref_rd > tmp_alt_rd) {
             rate2 = tmp_rd_stats.rate;
             disable_skip = dummy_disable_skip;
             distortion2 = tmp_rd_stats.dist;
             skippable = tmp_rd_stats.skip;
@@ -9727,16 +10746,20 @@ void av1_rd_pick_inter_mode_sb(const AV1
             rate_uv = tmp_rd_stats_uv.rate;
             total_sse = tmp_rd_stats.sse;
             this_rd = tmp_alt_rd;
             tmp_ref_rd = tmp_alt_rd;
             backup_mbmi = *mbmi;
             backup_skip = x->skip;
 #if CONFIG_DAALA_DIST && CONFIG_CB4X4
             if (bsize < BLOCK_8X8) {
+              if (tmp_rd_stats_y.rate != INT_MAX) {
+                assert(tmp_rd_stats_y.sse < INT64_MAX);
+                assert(tmp_rd_stats_y.dist < INT64_MAX);
+              }
               total_sse_y = tmp_rd_stats_y.sse;
               distortion2_y = tmp_rd_stats_y.dist;
             }
 #endif
 #if CONFIG_VAR_TX
             for (i = 0; i < MAX_MB_PLANE; ++i)
               memcpy(x->blk_skip_drl[i], x->blk_skip[i],
                      sizeof(uint8_t) * ctx->num_4x4_blk);
@@ -9769,73 +10792,94 @@ void av1_rd_pick_inter_mode_sb(const AV1
 #endif  // SUB8X8_COMP_REF
 
       if (cm->reference_mode == REFERENCE_MODE_SELECT) rate2 += compmode_cost;
     }
 
     // Estimate the reference frame signaling cost and add it
     // to the rolling cost variable.
     if (comp_pred) {
+#if CONFIG_EXT_COMP_REFS
+      rate2 += ref_costs_comp[ref_frame][second_ref_frame];
+#else  // !CONFIG_EXT_COMP_REFS
       rate2 += ref_costs_comp[ref_frame];
 #if CONFIG_EXT_REFS
       rate2 += ref_costs_comp[second_ref_frame];
 #endif  // CONFIG_EXT_REFS
+#endif  // CONFIG_EXT_COMP_REFS
     } else {
       rate2 += ref_costs_single[ref_frame];
     }
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    // Add the cost to signal single/comp mode in single ref.
+    if (!comp_pred && cm->reference_mode != COMPOUND_REFERENCE) {
+      aom_prob singleref_comp_mode_p = av1_get_inter_mode_prob(cm, xd);
+      rate2 += av1_cost_bit(singleref_comp_mode_p,
+                            is_inter_singleref_comp_mode(mbmi->mode));
+    }
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
     if (ref_frame == INTRA_FRAME) {
 #else
     if (!disable_skip) {
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
       if (skippable) {
         // Back out the coefficient coding costs
         rate2 -= (rate_y + rate_uv);
         rate_y = 0;
         rate_uv = 0;
         // Cost the skip mb case
         rate2 += av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
       } else if (ref_frame != INTRA_FRAME && !xd->lossless[mbmi->segment_id]) {
-        if (RDCOST(x->rdmult, x->rddiv, rate_y + rate_uv + rate_skip0,
-                   distortion2) <
-            RDCOST(x->rdmult, x->rddiv, rate_skip1, total_sse)) {
+        if (RDCOST(x->rdmult, rate_y + rate_uv + rate_skip0, distortion2) <
+            RDCOST(x->rdmult, rate_skip1, total_sse)) {
           // Add in the cost of the no skip flag.
           rate2 += av1_cost_bit(av1_get_skip_prob(cm, xd), 0);
         } else {
           // FIXME(rbultje) make this work for splitmv also
           rate2 += av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
           distortion2 = total_sse;
           assert(total_sse >= 0);
           rate2 -= (rate_y + rate_uv);
           this_skip2 = 1;
           rate_y = 0;
           rate_uv = 0;
 #if CONFIG_DAALA_DIST && CONFIG_CB4X4
-          if (bsize < BLOCK_8X8) distortion2_y = total_sse_y;
+          if (bsize < BLOCK_8X8) {
+            assert(total_sse_y < INT64_MAX);
+            distortion2_y = total_sse_y;
+          }
 #endif
         }
       } else {
         // Add in the cost of the no skip flag.
         rate2 += av1_cost_bit(av1_get_skip_prob(cm, xd), 0);
       }
 
       // Calculate the final RD estimate for this mode.
-      this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
+      this_rd = RDCOST(x->rdmult, rate2, distortion2);
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
     } else {
       this_skip2 = mbmi->skip;
-      this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
+      this_rd = RDCOST(x->rdmult, rate2, distortion2);
       if (this_skip2) {
         rate_y = 0;
         rate_uv = 0;
       }
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
     }
 
+#if CONFIG_DAALA_DIST && CONFIG_CB4X4
+    if ((bsize < BLOCK_8X8) && (rate2 != INT_MAX)) {
+      assert(distortion2_y < INT64_MAX);
+    }
+#endif
+
     if (ref_frame == INTRA_FRAME) {
       // Keep record of best intra rd
       if (this_rd < best_intra_rd) {
         best_intra_rd = this_rd;
         best_intra_mode = mbmi->mode;
       }
 #if CONFIG_EXT_INTER && CONFIG_INTERINTRA
     } else if (second_ref_frame == NONE_FRAME) {
@@ -9897,40 +10941,47 @@ void av1_rd_pick_inter_mode_sb(const AV1
         best_rd = this_rd;
         best_mbmode = *mbmi;
         best_skip2 = this_skip2;
         best_mode_skippable = skippable;
         best_rate_y = rate_y + av1_cost_bit(av1_get_skip_prob(cm, xd),
                                             this_skip2 || skippable);
         best_rate_uv = rate_uv;
 #if CONFIG_DAALA_DIST && CONFIG_CB4X4
-        if (bsize < BLOCK_8X8) rd_cost->dist_y = distortion2_y;
+        if (bsize < BLOCK_8X8) {
+          assert(distortion2_y < INT64_MAX);
+          rd_cost->dist_y = distortion2_y;
+        }
 #endif
 #if CONFIG_VAR_TX
         for (i = 0; i < MAX_MB_PLANE; ++i)
           memcpy(ctx->blk_skip[i], x->blk_skip[i],
                  sizeof(uint8_t) * ctx->num_4x4_blk);
 #endif  // CONFIG_VAR_TX
       }
     }
-
+#if CONFIG_DAALA_DIST && CONFIG_CB4X4
+    if ((bsize < BLOCK_8X8) && (rd_cost->rate != INT_MAX)) {
+      assert(rd_cost->dist_y < INT64_MAX);
+    }
+#endif
     /* keep record of best compound/single-only prediction */
     if (!disable_skip && ref_frame != INTRA_FRAME) {
       int64_t single_rd, hybrid_rd, single_rate, hybrid_rate;
 
       if (cm->reference_mode == REFERENCE_MODE_SELECT) {
         single_rate = rate2 - compmode_cost;
         hybrid_rate = rate2;
       } else {
         single_rate = rate2;
         hybrid_rate = rate2 + compmode_cost;
       }
 
-      single_rd = RDCOST(x->rdmult, x->rddiv, single_rate, distortion2);
-      hybrid_rd = RDCOST(x->rdmult, x->rddiv, hybrid_rate, distortion2);
+      single_rd = RDCOST(x->rdmult, single_rate, distortion2);
+      hybrid_rd = RDCOST(x->rdmult, hybrid_rate, distortion2);
 
       if (!comp_pred) {
         if (single_rd < best_pred_rd[SINGLE_REFERENCE])
           best_pred_rd[SINGLE_REFERENCE] = single_rd;
       } else {
         if (single_rd < best_pred_rd[COMPOUND_REFERENCE])
           best_pred_rd[COMPOUND_REFERENCE] = single_rd;
       }
@@ -9958,16 +11009,25 @@ void av1_rd_pick_inter_mode_sb(const AV1
 
     // Select prediction reference frames.
     for (i = 0; i < MAX_MB_PLANE; i++) {
       xd->plane[i].pre[0] = yv12_mb[mbmi->ref_frame[0]][i];
       if (has_second_ref(mbmi))
         xd->plane[i].pre[1] = yv12_mb[mbmi->ref_frame[1]][i];
     }
 
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+    // Single ref compound mode
+    if (!has_second_ref(mbmi) && is_inter_singleref_comp_mode(mbmi->mode)) {
+      xd->block_refs[1] = xd->block_refs[0];
+      for (i = 0; i < MAX_MB_PLANE; i++)
+        xd->plane[i].pre[1] = xd->plane[i].pre[0];
+    }
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+
     if (is_inter_mode(mbmi->mode)) {
       av1_build_inter_predictors_sb(cm, xd, mi_row, mi_col, NULL, bsize);
 #if CONFIG_MOTION_VAR
       if (mbmi->motion_mode == OBMC_CAUSAL) {
         av1_build_obmc_inter_prediction(
             cm, xd, mi_row, mi_col, args.above_pred_buf, args.above_pred_stride,
             args.left_pred_buf, args.left_pred_stride);
       }
@@ -9991,31 +11051,31 @@ void av1_rd_pick_inter_mode_sb(const AV1
       super_block_yrd(cpi, x, &rd_stats_y, bsize, INT64_MAX);
       super_block_uvrd(cpi, x, &rd_stats_uv, bsize, INT64_MAX);
 #endif  // CONFIG_VAR_TX
     } else {
       super_block_yrd(cpi, x, &rd_stats_y, bsize, INT64_MAX);
       super_block_uvrd(cpi, x, &rd_stats_uv, bsize, INT64_MAX);
     }
 
-    if (RDCOST(x->rdmult, x->rddiv, rd_stats_y.rate + rd_stats_uv.rate,
+    if (RDCOST(x->rdmult, rd_stats_y.rate + rd_stats_uv.rate,
                (rd_stats_y.dist + rd_stats_uv.dist)) >
-        RDCOST(x->rdmult, x->rddiv, 0, (rd_stats_y.sse + rd_stats_uv.sse))) {
+        RDCOST(x->rdmult, 0, (rd_stats_y.sse + rd_stats_uv.sse))) {
       skip_blk = 1;
       rd_stats_y.rate = av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
       rd_stats_uv.rate = 0;
       rd_stats_y.dist = rd_stats_y.sse;
       rd_stats_uv.dist = rd_stats_uv.sse;
     } else {
       skip_blk = 0;
       rd_stats_y.rate += av1_cost_bit(av1_get_skip_prob(cm, xd), 0);
     }
 
-    if (RDCOST(x->rdmult, x->rddiv, best_rate_y + best_rate_uv, rd_cost->dist) >
-        RDCOST(x->rdmult, x->rddiv, rd_stats_y.rate + rd_stats_uv.rate,
+    if (RDCOST(x->rdmult, best_rate_y + best_rate_uv, rd_cost->dist) >
+        RDCOST(x->rdmult, rd_stats_y.rate + rd_stats_uv.rate,
                (rd_stats_y.dist + rd_stats_uv.dist))) {
 #if CONFIG_VAR_TX
       int idx, idy;
 #endif  // CONFIG_VAR_TX
       best_mbmode.tx_type = mbmi->tx_type;
       best_mbmode.tx_size = mbmi->tx_size;
 #if CONFIG_VAR_TX
       for (idy = 0; idy < xd->n8_h; ++idy)
@@ -10026,24 +11086,33 @@ void av1_rd_pick_inter_mode_sb(const AV1
         memcpy(ctx->blk_skip[i], x->blk_skip[i],
                sizeof(uint8_t) * ctx->num_4x4_blk);
 
       best_mbmode.min_tx_size = mbmi->min_tx_size;
 #endif  // CONFIG_VAR_TX
       rd_cost->rate +=
           (rd_stats_y.rate + rd_stats_uv.rate - best_rate_y - best_rate_uv);
       rd_cost->dist = rd_stats_y.dist + rd_stats_uv.dist;
+      rd_cost->rdcost = RDCOST(x->rdmult, rd_cost->rate, rd_cost->dist);
+      best_skip2 = skip_blk;
 #if CONFIG_DAALA_DIST && CONFIG_CB4X4
-      if (bsize < BLOCK_8X8) rd_cost->dist_y = rd_stats_y.dist;
-#endif
-      rd_cost->rdcost =
-          RDCOST(x->rdmult, x->rddiv, rd_cost->rate, rd_cost->dist);
-      best_skip2 = skip_blk;
-    }
-  }
+      if (bsize < BLOCK_8X8) {
+        assert(rd_cost->rate != INT_MAX);
+        assert(rd_cost->dist_y < INT64_MAX);
+        rd_cost->dist_y = rd_stats_y.dist;
+      }
+#endif
+    }
+  }
+
+#if CONFIG_DAALA_DIST && CONFIG_CB4X4
+  if ((bsize < BLOCK_8X8) && (rd_cost->rate != INT_MAX)) {
+    assert(rd_cost->dist_y < INT64_MAX);
+  }
+#endif
 
 #if CONFIG_PALETTE
   // Only try palette mode when the best mode so far is an intra mode.
   if (try_palette && !is_inter_mode(best_mbmode.mode)) {
     int rate2 = 0;
 #if CONFIG_SUPERTX
     int best_rate_nocoef;
 #endif  // CONFIG_SUPERTX
@@ -10114,17 +11183,17 @@ void av1_rd_pick_inter_mode_sb(const AV1
 #endif  // CONFIG_SUPERTX
       rate2 += av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
     } else {
 #if CONFIG_SUPERTX
       best_rate_nocoef = rate2 - (rd_stats_y.rate + rate_uv_tokenonly[uv_tx]);
 #endif  // CONFIG_SUPERTX
       rate2 += av1_cost_bit(av1_get_skip_prob(cm, xd), 0);
     }
-    this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
+    this_rd = RDCOST(x->rdmult, rate2, distortion2);
     if (this_rd < best_rd) {
       best_mode_index = 3;
       mbmi->mv[0].as_int = 0;
       rd_cost->rate = rate2;
 #if CONFIG_SUPERTX
       *returnrate_nocoef = best_rate_nocoef;
 #endif  // CONFIG_SUPERTX
       rd_cost->dist = distortion2;
@@ -10160,20 +11229,24 @@ PALETTE_EXIT:
         &best_mode_index, &best_skip2, &best_mode_skippable,
 #if CONFIG_SUPERTX
         returnrate_nocoef,
 #endif  // CONFIG_SUPERTX
         best_pred_rd, &best_mbmode, rd_cost);
   }
 #endif  // CONFIG_FILTER_INTRA
 
-  // The inter modes' rate costs are not calculated precisely in some cases.
-  // Therefore, sometimes, NEWMV is chosen instead of NEARESTMV, NEARMV, and
-  // ZEROMV. Here, checks are added for those cases, and the mode decisions
-  // are corrected.
+// The inter modes' rate costs are not calculated precisely in some cases.
+// Therefore, sometimes, NEWMV is chosen instead of NEARESTMV, NEARMV, and
+// ZEROMV. Here, checks are added for those cases, and the mode decisions
+// are corrected.
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+// NOTE: For SR_NEW_NEWMV, no need to check as the two mvs from the same ref
+//       are surely different from each other.
+#endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
   if (best_mbmode.mode == NEWMV
 #if CONFIG_EXT_INTER
       || best_mbmode.mode == NEW_NEWMV
 #endif  // CONFIG_EXT_INTER
       ) {
     const MV_REFERENCE_FRAME refs[2] = { best_mbmode.ref_frame[0],
                                          best_mbmode.ref_frame[1] };
     int comp_pred_mode = refs[1] > INTRA_FRAME;
@@ -10282,21 +11355,27 @@ PALETTE_EXIT:
 #endif  // CONFIG_EXT_INTER
     }
   }
 
   // Make sure that the ref_mv_idx is only nonzero when we're
   // using a mode which can support ref_mv_idx
   if (best_mbmode.ref_mv_idx != 0 &&
 #if CONFIG_EXT_INTER
+#if CONFIG_COMPOUND_SINGLEREF
+      !(best_mbmode.mode == NEWMV || best_mbmode.mode == SR_NEW_NEWMV ||
+        best_mbmode.mode == NEW_NEWMV ||
+        have_nearmv_in_inter_mode(best_mbmode.mode))) {
+#else   // !CONFIG_COMPOUND_SINGLEREF
       !(best_mbmode.mode == NEWMV || best_mbmode.mode == NEW_NEWMV ||
         have_nearmv_in_inter_mode(best_mbmode.mode))) {
-#else
+#endif  // CONFIG_COMPOUND_SINGLEREF
+#else   // !CONFIG_EXT_INTER
       !(best_mbmode.mode == NEARMV || best_mbmode.mode == NEWMV)) {
-#endif
+#endif  // CONFIG_EXT_INTER
     best_mbmode.ref_mv_idx = 0;
   }
 
   {
     int8_t ref_frame_type = av1_ref_frame_type(best_mbmode.ref_frame);
     int16_t mode_ctx = mbmi_ext->mode_context[ref_frame_type];
     if (mode_ctx & (1 << ALL_ZERO_FLAG_OFFSET)) {
       int_mv zeromv[2];
@@ -10440,17 +11519,21 @@ void av1_rd_pick_inter_mode_sb_seg_skip(
   const AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *const xd = &x->e_mbd;
   MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
   unsigned char segment_id = mbmi->segment_id;
   const int comp_pred = 0;
   int i;
   int64_t best_pred_diff[REFERENCE_MODES];
   unsigned int ref_costs_single[TOTAL_REFS_PER_FRAME];
+#if CONFIG_EXT_COMP_REFS
+  unsigned int ref_costs_comp[TOTAL_REFS_PER_FRAME][TOTAL_REFS_PER_FRAME];
+#else
   unsigned int ref_costs_comp[TOTAL_REFS_PER_FRAME];
+#endif  // CONFIG_EXT_COMP_REFS
   aom_prob comp_mode_p;
   InterpFilter best_filter = SWITCHABLE;
   int64_t this_rd = INT64_MAX;
   int rate2 = 0;
   const int64_t distortion2 = 0;
   (void)mi_row;
   (void)mi_col;
 
@@ -10543,17 +11626,17 @@ void av1_rd_pick_inter_mode_sb_seg_skip(
   rate2 += av1_get_switchable_rate(cpi, xd);
 
   if (cm->reference_mode == REFERENCE_MODE_SELECT)
     rate2 += av1_cost_bit(comp_mode_p, comp_pred);
 
   // Estimate the reference frame signaling cost and add it
   // to the rolling cost variable.
   rate2 += ref_costs_single[LAST_FRAME];
-  this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
+  this_rd = RDCOST(x->rdmult, rate2, distortion2);
 
   rd_cost->rate = rate2;
   rd_cost->dist = distortion2;
   rd_cost->rdcost = this_rd;
 #if CONFIG_DAALA_DIST && CONFIG_CB4X4
   if (bsize < BLOCK_8X8) rd_cost->dist_y = distortion2;
 #endif
   if (this_rd >= best_rd_so_far) {
@@ -10849,79 +11932,108 @@ void av1_check_ncobmc_rd(const struct AV
                          &xd->block_refs[ref]->sf);
   }
   av1_setup_dst_planes(x->e_mbd.plane, bsize,
                        get_frame_new_buffer(&cpi->common), mi_row, mi_col);
 
   av1_build_inter_predictors_sb(cm, xd, mi_row, mi_col, NULL, bsize);
 
   av1_subtract_plane(x, bsize, 0);
+#if CONFIG_VAR_TX
+  if (cm->tx_mode == TX_MODE_SELECT && !xd->lossless[mbmi->segment_id]) {
+    select_tx_type_yrd(cpi, x, &rd_stats_y, bsize, INT64_MAX);
+  } else {
+    int idx, idy;
+    super_block_yrd(cpi, x, &rd_stats_y, bsize, INT64_MAX);
+    for (idy = 0; idy < xd->n8_h; ++idy)
+      for (idx = 0; idx < xd->n8_w; ++idx)
+        mbmi->inter_tx_size[idy][idx] = mbmi->tx_size;
+    memset(x->blk_skip[0], rd_stats_y.skip,
+           sizeof(uint8_t) * xd->n8_h * xd->n8_w * 4);
+  }
+  inter_block_uvrd(cpi, x, &rd_stats_uv, bsize, INT64_MAX);
+#else
   super_block_yrd(cpi, x, &rd_stats_y, bsize, INT64_MAX);
   super_block_uvrd(cpi, x, &rd_stats_uv, bsize, INT64_MAX);
+#endif
   assert(rd_stats_y.rate != INT_MAX && rd_stats_uv.rate != INT_MAX);
   if (rd_stats_y.skip && rd_stats_uv.skip) {
     rd_stats_y.rate = rate_skip1;
     rd_stats_uv.rate = 0;
     rd_stats_y.dist = rd_stats_y.sse;
     rd_stats_uv.dist = rd_stats_uv.sse;
     skip_blk = 0;
-  } else if (RDCOST(x->rdmult, x->rddiv,
+  } else if (RDCOST(x->rdmult,
                     (rd_stats_y.rate + rd_stats_uv.rate + rate_skip0),
                     (rd_stats_y.dist + rd_stats_uv.dist)) >
-             RDCOST(x->rdmult, x->rddiv, rate_skip1,
+             RDCOST(x->rdmult, rate_skip1,
                     (rd_stats_y.sse + rd_stats_uv.sse))) {
     rd_stats_y.rate = rate_skip1;
     rd_stats_uv.rate = 0;
     rd_stats_y.dist = rd_stats_y.sse;
     rd_stats_uv.dist = rd_stats_uv.sse;
     skip_blk = 1;
   } else {
     rd_stats_y.rate += rate_skip0;
     skip_blk = 0;
   }
   backup_skip = skip_blk;
   backup_mbmi = *mbmi;
-  rd_causal = RDCOST(x->rdmult, x->rddiv, (rd_stats_y.rate + rd_stats_uv.rate),
+  rd_causal = RDCOST(x->rdmult, (rd_stats_y.rate + rd_stats_uv.rate),
                      (rd_stats_y.dist + rd_stats_uv.dist));
-  rd_causal += RDCOST(x->rdmult, x->rddiv,
-                      av1_cost_bit(cm->fc->motion_mode_prob[bsize][0], 0), 0);
+  rd_causal +=
+      RDCOST(x->rdmult, av1_cost_bit(cm->fc->motion_mode_prob[bsize][0], 0), 0);
 
   // Check non-causal mode
   mbmi->motion_mode = OBMC_CAUSAL;
   av1_build_ncobmc_inter_predictors_sb(cm, xd, mi_row, mi_col);
 
   av1_subtract_plane(x, bsize, 0);
+#if CONFIG_VAR_TX
+  if (cm->tx_mode == TX_MODE_SELECT && !xd->lossless[mbmi->segment_id]) {
+    select_tx_type_yrd(cpi, x, &rd_stats_y, bsize, INT64_MAX);
+  } else {
+    int idx, idy;
+    super_block_yrd(cpi, x, &rd_stats_y, bsize, INT64_MAX);
+    for (idy = 0; idy < xd->n8_h; ++idy)
+      for (idx = 0; idx < xd->n8_w; ++idx)
+        mbmi->inter_tx_size[idy][idx] = mbmi->tx_size;
+    memset(x->blk_skip[0], rd_stats_y.skip,
+           sizeof(uint8_t) * xd->n8_h * xd->n8_w * 4);
+  }
+  inter_block_uvrd(cpi, x, &rd_stats_uv, bsize, INT64_MAX);
+#else
   super_block_yrd(cpi, x, &rd_stats_y, bsize, INT64_MAX);
   super_block_uvrd(cpi, x, &rd_stats_uv, bsize, INT64_MAX);
+#endif
   assert(rd_stats_y.rate != INT_MAX && rd_stats_uv.rate != INT_MAX);
   if (rd_stats_y.skip && rd_stats_uv.skip) {
     rd_stats_y.rate = rate_skip1;
     rd_stats_uv.rate = 0;
     rd_stats_y.dist = rd_stats_y.sse;
     rd_stats_uv.dist = rd_stats_uv.sse;
     skip_blk = 0;
-  } else if (RDCOST(x->rdmult, x->rddiv,
+  } else if (RDCOST(x->rdmult,
                     (rd_stats_y.rate + rd_stats_uv.rate + rate_skip0),
                     (rd_stats_y.dist + rd_stats_uv.dist)) >
-             RDCOST(x->rdmult, x->rddiv, rate_skip1,
+             RDCOST(x->rdmult, rate_skip1,
                     (rd_stats_y.sse + rd_stats_uv.sse))) {
     rd_stats_y.rate = rate_skip1;
     rd_stats_uv.rate = 0;
     rd_stats_y.dist = rd_stats_y.sse;
     rd_stats_uv.dist = rd_stats_uv.sse;
     skip_blk = 1;
   } else {
     rd_stats_y.rate += rate_skip0;
     skip_blk = 0;
   }
 
   if (rd_causal >
-      RDCOST(x->rdmult, x->rddiv,
-             rd_stats_y.rate + rd_stats_uv.rate +
-                 av1_cost_bit(cm->fc->motion_mode_prob[bsize][0], 1),
+      RDCOST(x->rdmult, rd_stats_y.rate + rd_stats_uv.rate +
+                            av1_cost_bit(cm->fc->motion_mode_prob[bsize][0], 1),
              (rd_stats_y.dist + rd_stats_uv.dist))) {
     x->skip = skip_blk;
   } else {
     *mbmi = backup_mbmi;
     x->skip = backup_skip;
   }
 }
 #endif  // CONFIG_NCOBMC
--- a/third_party/aom/av1/encoder/rdopt.h
+++ b/third_party/aom/av1/encoder/rdopt.h
@@ -58,18 +58,19 @@ typedef enum OUTPUT_STATUS {
 } OUTPUT_STATUS;
 
 void av1_dist_block(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
                     BLOCK_SIZE plane_bsize, int block, int blk_row, int blk_col,
                     TX_SIZE tx_size, int64_t *out_dist, int64_t *out_sse,
                     OUTPUT_STATUS output_status);
 
 #if CONFIG_DAALA_DIST
-int64_t av1_daala_dist(const uint8_t *src, int src_stride, const uint8_t *dst,
-                       int dst_stride, int bsw, int bsh, int qm,
+int64_t av1_daala_dist(const MACROBLOCKD *xd, const uint8_t *src,
+                       int src_stride, const uint8_t *dst, int dst_stride,
+                       int bsw, int bsh, int visible_w, int visible_h, int qm,
                        int use_activity_masking, int qindex);
 #endif
 
 #if !CONFIG_PVQ || CONFIG_VAR_TX
 int av1_cost_coeffs(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
                     int block, TX_SIZE tx_size, const SCAN_ORDER *scan_order,
                     const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l,
                     int use_fast_coef_costing);
--- a/third_party/aom/av1/encoder/speed_features.c
+++ b/third_party/aom/av1/encoder/speed_features.c
@@ -30,17 +30,17 @@ static MESH_PATTERN
 static unsigned char good_quality_max_mesh_pct[MAX_MESH_SPEED + 1] = {
   50, 25, 15, 5, 1, 1
 };
 
 #if CONFIG_INTRABC
 // TODO(aconverse@google.com): These settings are pretty relaxed, tune them for
 // each speed setting
 static MESH_PATTERN intrabc_mesh_patterns[MAX_MESH_SPEED + 1][MAX_MESH_STEP] = {
-  { { 64, 1 }, { 64, 1 }, { 0, 0 }, { 0, 0 } },
+  { { 256, 1 }, { 256, 1 }, { 0, 0 }, { 0, 0 } },
   { { 64, 1 }, { 64, 1 }, { 0, 0 }, { 0, 0 } },
   { { 64, 1 }, { 64, 1 }, { 0, 0 }, { 0, 0 } },
   { { 64, 4 }, { 16, 1 }, { 0, 0 }, { 0, 0 } },
   { { 64, 4 }, { 16, 1 }, { 0, 0 }, { 0, 0 } },
   { { 64, 4 }, { 16, 1 }, { 0, 0 }, { 0, 0 } },
 };
 static uint8_t intrabc_max_mesh_pct[MAX_MESH_SPEED + 1] = { 100, 100, 100,
                                                             25,  25,  10 };
--- a/third_party/aom/av1/encoder/speed_features.h
+++ b/third_party/aom/av1/encoder/speed_features.h
@@ -33,16 +33,21 @@ enum {
   INTRA_DC_TM = (1 << DC_PRED) | (1 << TM_PRED),
   INTRA_DC_H_V = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED),
   INTRA_DC_TM_H_V =
       (1 << DC_PRED) | (1 << TM_PRED) | (1 << V_PRED) | (1 << H_PRED)
 };
 
 #if CONFIG_EXT_INTER
 enum {
+#if CONFIG_COMPOUND_SINGLEREF
+// TODO(zoeliu): To further consider following single ref comp modes:
+//               SR_NEAREST_NEARMV, SR_NEAREST_NEWMV, SR_NEAR_NEWMV,
+//               SR_ZERO_NEWMV, and SR_NEW_NEWMV.
+#endif  // CONFIG_COMPOUND_SINGLEREF
   INTER_ALL = (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV) | (1 << NEWMV) |
               (1 << NEAREST_NEARESTMV) | (1 << NEAR_NEARMV) | (1 << NEW_NEWMV) |
               (1 << NEAREST_NEWMV) | (1 << NEAR_NEWMV) | (1 << NEW_NEARMV) |
               (1 << NEW_NEARESTMV) | (1 << ZERO_ZEROMV),
   INTER_NEAREST = (1 << NEARESTMV) | (1 << NEAREST_NEARESTMV) |
                   (1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV),
   INTER_NEAREST_NEW = (1 << NEARESTMV) | (1 << NEWMV) |
                       (1 << NEAREST_NEARESTMV) | (1 << NEW_NEWMV) |
@@ -62,17 +67,17 @@ enum {
                            (1 << NEW_NEARMV) | (1 << NEAR_NEWMV) |
                            (1 << NEAR_NEARMV),
   INTER_NEAREST_NEAR_ZERO = (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV) |
                             (1 << NEAREST_NEARESTMV) | (1 << ZERO_ZEROMV) |
                             (1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV) |
                             (1 << NEW_NEARMV) | (1 << NEAR_NEWMV) |
                             (1 << NEAR_NEARMV),
 };
-#else
+#else   // !CONFIG_EXT_INTER
 enum {
   INTER_ALL = (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV) | (1 << NEWMV),
   INTER_NEAREST = (1 << NEARESTMV),
   INTER_NEAREST_NEW = (1 << NEARESTMV) | (1 << NEWMV),
   INTER_NEAREST_ZERO = (1 << NEARESTMV) | (1 << ZEROMV),
   INTER_NEAREST_NEW_ZERO = (1 << NEARESTMV) | (1 << ZEROMV) | (1 << NEWMV),
   INTER_NEAREST_NEAR_NEW = (1 << NEARESTMV) | (1 << NEARMV) | (1 << NEWMV),
   INTER_NEAREST_NEAR_ZERO = (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV),
@@ -394,20 +399,16 @@ typedef struct SPEED_FEATURES {
   int fast_wedge_sign_estimate;
 #endif  // CONFIG_EXT_INTER
 
   // These bit masks allow you to enable or disable intra modes for each
   // transform size separately.
   int intra_y_mode_mask[TX_SIZES];
   int intra_uv_mode_mask[TX_SIZES];
 
-  // These bit masks allow you to enable or disable intra modes for each
-  // prediction block size separately.
-  int intra_y_mode_bsize_mask[BLOCK_SIZES];
-
   // This variable enables an early break out of mode testing if the model for
   // rd built from the prediction signal indicates a value that's much
   // higher than the best rd we've seen so far.
   int use_rd_breakout;
 
   // This feature controls how the loop filter level is determined.
   LPF_PICK_METHOD lpf_pick;
 
--- a/third_party/aom/av1/encoder/temporal_filter.c
+++ b/third_party/aom/av1/encoder/temporal_filter.c
@@ -36,17 +36,17 @@ static void temporal_filter_predictors_m
     MACROBLOCKD *xd, uint8_t *y_mb_ptr, uint8_t *u_mb_ptr, uint8_t *v_mb_ptr,
     int stride, int uv_block_width, int uv_block_height, int mv_row, int mv_col,
     uint8_t *pred, struct scale_factors *scale, int x, int y) {
   const int which_mv = 0;
   const MV mv = { mv_row, mv_col };
   enum mv_precision mv_precision_uv;
   int uv_stride;
   // TODO(angiebird): change plane setting accordingly
-  ConvolveParams conv_params = get_conv_params(which_mv, 0);
+  ConvolveParams conv_params = get_conv_params(which_mv, which_mv, 0);
 
 #if USE_TEMPORALFILTER_12TAP
 #if CONFIG_DUAL_FILTER
   const InterpFilter interp_filter[4] = { TEMPORALFILTER_12TAP,
                                           TEMPORALFILTER_12TAP,
                                           TEMPORALFILTER_12TAP,
                                           TEMPORALFILTER_12TAP };
 #else
@@ -408,67 +408,55 @@ static void temporal_filter_iterate_c(AV
           temporal_filter_predictors_mb_c(
               mbd, frames[frame]->y_buffer + mb_y_offset,
               frames[frame]->u_buffer + mb_uv_offset,
               frames[frame]->v_buffer + mb_uv_offset, frames[frame]->y_stride,
               mb_uv_width, mb_uv_height, mbd->mi[0]->bmi[0].as_mv[0].as_mv.row,
               mbd->mi[0]->bmi[0].as_mv[0].as_mv.col, predictor, scale,
               mb_col * 16, mb_row * 16);
 
+// Apply the filter (YUV)
 #if CONFIG_HIGHBITDEPTH
           if (mbd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
             int adj_strength = strength + 2 * (mbd->bd - 8);
-            // Apply the filter (YUV)
             av1_highbd_temporal_filter_apply(
                 f->y_buffer + mb_y_offset, f->y_stride, predictor, 16, 16,
                 adj_strength, filter_weight, accumulator, count);
             av1_highbd_temporal_filter_apply(
                 f->u_buffer + mb_uv_offset, f->uv_stride, predictor + 256,
                 mb_uv_width, mb_uv_height, adj_strength, filter_weight,
                 accumulator + 256, count + 256);
             av1_highbd_temporal_filter_apply(
                 f->v_buffer + mb_uv_offset, f->uv_stride, predictor + 512,
                 mb_uv_width, mb_uv_height, adj_strength, filter_weight,
                 accumulator + 512, count + 512);
           } else {
-            // Apply the filter (YUV)
+#endif  // CONFIG_HIGHBITDEPTH
             av1_temporal_filter_apply_c(f->y_buffer + mb_y_offset, f->y_stride,
                                         predictor, 16, 16, strength,
                                         filter_weight, accumulator, count);
             av1_temporal_filter_apply_c(
                 f->u_buffer + mb_uv_offset, f->uv_stride, predictor + 256,
                 mb_uv_width, mb_uv_height, strength, filter_weight,
                 accumulator + 256, count + 256);
             av1_temporal_filter_apply_c(
                 f->v_buffer + mb_uv_offset, f->uv_stride, predictor + 512,
                 mb_uv_width, mb_uv_height, strength, filter_weight,
                 accumulator + 512, count + 512);
+#if CONFIG_HIGHBITDEPTH
           }
-#else
-          // Apply the filter (YUV)
-          av1_temporal_filter_apply_c(f->y_buffer + mb_y_offset, f->y_stride,
-                                      predictor, 16, 16, strength,
-                                      filter_weight, accumulator, count);
-          av1_temporal_filter_apply_c(f->u_buffer + mb_uv_offset, f->uv_stride,
-                                      predictor + 256, mb_uv_width,
-                                      mb_uv_height, strength, filter_weight,
-                                      accumulator + 256, count + 256);
-          av1_temporal_filter_apply_c(f->v_buffer + mb_uv_offset, f->uv_stride,
-                                      predictor + 512, mb_uv_width,
-                                      mb_uv_height, strength, filter_weight,
-                                      accumulator + 512, count + 512);
 #endif  // CONFIG_HIGHBITDEPTH
         }
       }
 
+// Normalize filter output to produce AltRef frame
 #if CONFIG_HIGHBITDEPTH
       if (mbd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
         uint16_t *dst1_16;
         uint16_t *dst2_16;
-        // Normalize filter output to produce AltRef frame
         dst1 = cpi->alt_ref_buffer.y_buffer;
         dst1_16 = CONVERT_TO_SHORTPTR(dst1);
         stride = cpi->alt_ref_buffer.y_stride;
         byte = mb_y_offset;
         for (i = 0, k = 0; i < 16; i++) {
           for (j = 0; j < 16; j++, k++) {
             dst1_16[byte] =
                 (uint16_t)OD_DIVU(accumulator[k] + (count[k] >> 1), count[k]);
@@ -500,17 +488,17 @@ static void temporal_filter_iterate_c(AV
 
             // move to next pixel
             byte++;
           }
 
           byte += stride - mb_uv_width;
         }
       } else {
-        // Normalize filter output to produce AltRef frame
+#endif  // CONFIG_HIGHBITDEPTH
         dst1 = cpi->alt_ref_buffer.y_buffer;
         stride = cpi->alt_ref_buffer.y_stride;
         byte = mb_y_offset;
         for (i = 0, k = 0; i < 16; i++) {
           for (j = 0; j < 16; j++, k++) {
             dst1[byte] =
                 (uint8_t)OD_DIVU(accumulator[k] + (count[k] >> 1), count[k]);
 
@@ -536,53 +524,17 @@ static void temporal_filter_iterate_c(AV
             dst2[byte] =
                 (uint8_t)OD_DIVU(accumulator[m] + (count[m] >> 1), count[m]);
 
             // move to next pixel
             byte++;
           }
           byte += stride - mb_uv_width;
         }
-      }
-#else
-      // Normalize filter output to produce AltRef frame
-      dst1 = cpi->alt_ref_buffer.y_buffer;
-      stride = cpi->alt_ref_buffer.y_stride;
-      byte = mb_y_offset;
-      for (i = 0, k = 0; i < 16; i++) {
-        for (j = 0; j < 16; j++, k++) {
-          dst1[byte] =
-              (uint8_t)OD_DIVU(accumulator[k] + (count[k] >> 1), count[k]);
-
-          // move to next pixel
-          byte++;
-        }
-        byte += stride - 16;
-      }
-
-      dst1 = cpi->alt_ref_buffer.u_buffer;
-      dst2 = cpi->alt_ref_buffer.v_buffer;
-      stride = cpi->alt_ref_buffer.uv_stride;
-      byte = mb_uv_offset;
-      for (i = 0, k = 256; i < mb_uv_height; i++) {
-        for (j = 0; j < mb_uv_width; j++, k++) {
-          int m = k + 256;
-
-          // U
-          dst1[byte] =
-              (uint8_t)OD_DIVU(accumulator[k] + (count[k] >> 1), count[k]);
-
-          // V
-          dst2[byte] =
-              (uint8_t)OD_DIVU(accumulator[m] + (count[m] >> 1), count[m]);
-
-          // move to next pixel
-          byte++;
-        }
-        byte += stride - mb_uv_width;
+#if CONFIG_HIGHBITDEPTH
       }
 #endif  // CONFIG_HIGHBITDEPTH
       mb_y_offset += 16;
       mb_uv_offset += mb_uv_width;
     }
     mb_y_offset += 16 * (f->y_stride - mb_cols);
     mb_uv_offset += mb_uv_height * f->uv_stride - mb_uv_width * mb_cols;
   }
--- a/third_party/aom/av1/encoder/tokenize.c
+++ b/third_party/aom/av1/encoder/tokenize.c
@@ -272,19 +272,18 @@ static void cost_coeffs_b(int plane, int
   const AV1_COMMON *cm = &cpi->common;
   ThreadData *const td = args->td;
   MACROBLOCK *const x = &td->mb;
   MACROBLOCKD *const xd = &x->e_mbd;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   struct macroblock_plane *p = &x->plane[plane];
   struct macroblockd_plane *pd = &xd->plane[plane];
   const PLANE_TYPE type = pd->plane_type;
-  const int ref = is_inter_block(mbmi);
   const TX_TYPE tx_type = get_tx_type(type, xd, block, tx_size);
-  const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, ref);
+  const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
   const int rate = av1_cost_coeffs(cpi, x, plane, block, tx_size, scan_order,
                                    pd->above_context + blk_col,
                                    pd->left_context + blk_row, 0);
   args->this_rate += rate;
   (void)plane_bsize;
   av1_set_contexts(xd, pd, plane, tx_size, p->eobs[block] > 0, blk_col,
                    blk_row);
 }
@@ -430,18 +429,17 @@ static void tokenize_b(int plane, int bl
   const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
 #if CONFIG_SUPERTX
   const int segment_id = AOMMIN(mbmi->segment_id, mbmi->segment_id_supertx);
 #else
   const int segment_id = mbmi->segment_id;
 #endif  // CONFIG_SUEPRTX
   const int16_t *scan, *nb;
   const TX_TYPE tx_type = get_tx_type(type, xd, block, tx_size);
-  const SCAN_ORDER *const scan_order =
-      get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
+  const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
   const int ref = is_inter_block(mbmi);
   unsigned int(*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
       td->rd_counts.coef_counts[txsize_sqr_map[tx_size]][type][ref];
 #if CONFIG_EC_ADAPT
   FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
 #else
   FRAME_CONTEXT *ec_ctx = cpi->common.fc;
 #endif
@@ -661,17 +659,17 @@ void av1_tokenize_sb_vartx(const AV1_COM
         (*t)->token = EOSB_TOKEN;
         (*t)++;
       }
 #endif
       continue;
     }
 #endif
     const struct macroblockd_plane *const pd = &xd->plane[plane];
-#if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2
+#if CONFIG_CHROMA_SUB8X8
     const BLOCK_SIZE plane_bsize =
         AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
 #else
     const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
 #endif
     const int mi_width = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
     const int mi_height = block_size_high[plane_bsize] >> tx_size_wide_log2[0];
     const TX_SIZE max_tx_size = get_vartx_max_txsize(mbmi, plane_bsize);
new file mode 100644
--- /dev/null
+++ b/third_party/aom/av1/encoder/x86/av1_highbd_quantize_avx2.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2017, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+#include <immintrin.h>
+
+#include "./av1_rtcd.h"
+#include "aom/aom_integer.h"
+#include "aom_dsp/aom_dsp_common.h"
+
+static INLINE void init_one_qp(const __m128i *p, __m256i *qp) {
+  const __m128i zero = _mm_setzero_si128();
+  const __m128i dc = _mm_unpacklo_epi16(*p, zero);
+  const __m128i ac = _mm_unpackhi_epi16(*p, zero);
+  *qp = _mm256_insertf128_si256(_mm256_castsi128_si256(dc), ac, 1);
+}
+
+static INLINE void update_qp(__m256i *qp) {
+  qp[0] = _mm256_permute2x128_si256(qp[0], qp[0], 0x11);
+  qp[1] = _mm256_permute2x128_si256(qp[1], qp[1], 0x11);
+  qp[2] = _mm256_permute2x128_si256(qp[2], qp[2], 0x11);
+}
+
+static INLINE void init_qp(const int16_t *round_ptr, const int16_t *quant_ptr,
+                           const int16_t *dequant_ptr, int log_scale,
+                           __m256i *qp) {
+  __m128i round = _mm_loadu_si128((const __m128i *)round_ptr);
+  round = _mm_srai_epi16(round, log_scale);
+  const __m128i quant = _mm_loadu_si128((const __m128i *)quant_ptr);
+  const __m128i dequant = _mm_loadu_si128((const __m128i *)dequant_ptr);
+
+  init_one_qp(&round, &qp[0]);
+  init_one_qp(&quant, &qp[1]);
+  init_one_qp(&dequant, &qp[2]);
+}
+
+static INLINE void quantize(const __m256i *qp, __m256i *c,
+                            const int16_t *iscan_ptr, int log_scale,
+                            tran_low_t *qcoeff, tran_low_t *dqcoeff,
+                            __m256i *eob) {
+  const __m256i abs = _mm256_abs_epi32(*c);
+  __m256i q = _mm256_add_epi32(abs, qp[0]);
+
+  __m256i q_lo = _mm256_mul_epi32(q, qp[1]);
+  __m256i q_hi = _mm256_srli_epi64(q, 32);
+  const __m256i qp_hi = _mm256_srli_epi64(qp[1], 32);
+  q_hi = _mm256_mul_epi32(q_hi, qp_hi);
+  q_lo = _mm256_srli_epi64(q_lo, 16 - log_scale);
+  q_hi = _mm256_srli_epi64(q_hi, 16 - log_scale);
+  q_hi = _mm256_slli_epi64(q_hi, 32);
+  q = _mm256_or_si256(q_lo, q_hi);
+
+  __m256i dq = _mm256_mullo_epi32(q, qp[2]);
+  dq = _mm256_srai_epi32(dq, log_scale);
+  q = _mm256_sign_epi32(q, *c);
+  dq = _mm256_sign_epi32(dq, *c);
+
+  _mm256_storeu_si256((__m256i *)qcoeff, q);
+  _mm256_storeu_si256((__m256i *)dqcoeff, dq);
+
+  const __m128i isc = _mm_loadu_si128((const __m128i *)iscan_ptr);
+  const __m128i zr = _mm_setzero_si128();
+  const __m128i lo = _mm_unpacklo_epi16(isc, zr);
+  const __m128i hi = _mm_unpackhi_epi16(isc, zr);
+  const __m256i iscan =
+      _mm256_insertf128_si256(_mm256_castsi128_si256(lo), hi, 1);
+
+  const __m256i zero = _mm256_setzero_si256();
+  const __m256i zc = _mm256_cmpeq_epi32(dq, zero);
+  const __m256i nz = _mm256_cmpeq_epi32(zc, zero);
+  __m256i cur_eob = _mm256_sub_epi32(iscan, nz);
+  cur_eob = _mm256_and_si256(cur_eob, nz);
+  *eob = _mm256_max_epi32(cur_eob, *eob);
+}
+
+void av1_highbd_quantize_fp_avx2(
+    const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block,
+    const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr,
+    const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
+    tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
+    const int16_t *scan, const int16_t *iscan, int log_scale) {
+  (void)scan;
+  (void)zbin_ptr;
+  (void)quant_shift_ptr;
+  const unsigned int step = 8;
+
+  if (LIKELY(!skip_block)) {
+    __m256i qp[3], coeff;
+
+    init_qp(round_ptr, quant_ptr, dequant_ptr, log_scale, qp);
+    coeff = _mm256_loadu_si256((const __m256i *)coeff_ptr);
+
+    __m256i eob = _mm256_setzero_si256();
+    quantize(qp, &coeff, iscan, log_scale, qcoeff_ptr, dqcoeff_ptr, &eob);
+
+    coeff_ptr += step;
+    qcoeff_ptr += step;
+    dqcoeff_ptr += step;
+    iscan += step;
+    n_coeffs -= step;
+
+    update_qp(qp);
+    while (n_coeffs > 0) {
+      coeff = _mm256_loadu_si256((const __m256i *)coeff_ptr);
+      quantize(qp, &coeff, iscan, log_scale, qcoeff_ptr, dqcoeff_ptr, &eob);
+
+      coeff_ptr += step;
+      qcoeff_ptr += step;
+      dqcoeff_ptr += step;
+      iscan += step;
+      n_coeffs -= step;
+    }
+    {
+      __m256i eob_s;
+      eob_s = _mm256_shuffle_epi32(eob, 0xe);
+      eob = _mm256_max_epi16(eob, eob_s);
+      eob_s = _mm256_shufflelo_epi16(eob, 0xe);
+      eob = _mm256_max_epi16(eob, eob_s);
+      eob_s = _mm256_shufflelo_epi16(eob, 1);
+      eob = _mm256_max_epi16(eob, eob_s);
+      const __m128i final_eob = _mm_max_epi16(_mm256_castsi256_si128(eob),
+                                              _mm256_extractf128_si256(eob, 1));
+      *eob_ptr = _mm_extract_epi16(final_eob, 0);
+    }
+  } else {
+    do {
+      const __m256i zero = _mm256_setzero_si256();
+      _mm256_storeu_si256((__m256i *)qcoeff_ptr, zero);
+      _mm256_storeu_si256((__m256i *)dqcoeff_ptr, zero);
+      qcoeff_ptr += step;
+      dqcoeff_ptr += step;
+      n_coeffs -= step;
+    } while (n_coeffs > 0);
+    *eob_ptr = 0;
+  }
+}
--- a/third_party/aom/av1/encoder/x86/av1_highbd_quantize_sse4.c
+++ b/third_party/aom/av1/encoder/x86/av1_highbd_quantize_sse4.c
@@ -128,28 +128,29 @@ void av1_highbd_quantize_fp_sse4_1(
 
   memset(quanAddr, 0, count * sizeof(quanAddr[0]));
   memset(dquanAddr, 0, count * sizeof(dquanAddr[0]));
 
   if (!skip_block) {
     coeff[0] = _mm_loadu_si128((__m128i const *)src);
 
     qparam[0] =
-        _mm_set_epi32(round_ptr[1], round_ptr[1], round_ptr[1], round_ptr[0]);
-    qparam[1] = _mm_set_epi64x(quant_ptr[1], quant_ptr[0]);
-    qparam[2] = _mm_set_epi64x(dequant_ptr[1], dequant_ptr[0]);
+        _mm_set_epi32(round_ptr[1] >> log_scale, round_ptr[1] >> log_scale,
+                      round_ptr[1] >> log_scale, round_ptr[0] >> log_scale);
+    qparam[1] = _mm_set_epi32(0, quant_ptr[1], 0, quant_ptr[0]);
+    qparam[2] = _mm_set_epi32(0, dequant_ptr[1], 0, dequant_ptr[0]);
 
     // DC and first 3 AC
     quantize_coeff_phase1(&coeff[0], qparam, shift, log_scale, qcoeff, dequant,
                           &coeff_sign);
 
     // update round/quan/dquan for AC
     qparam[0] = _mm_unpackhi_epi64(qparam[0], qparam[0]);
-    qparam[1] = _mm_set_epi64x(quant_ptr[1], quant_ptr[1]);
-    qparam[2] = _mm_set_epi64x(dequant_ptr[1], dequant_ptr[1]);
+    qparam[1] = _mm_set_epi32(0, quant_ptr[1], 0, quant_ptr[1]);
+    qparam[2] = _mm_set_epi32(0, dequant_ptr[1], 0, dequant_ptr[1]);
 
     quantize_coeff_phase2(qcoeff, dequant, &coeff_sign, qparam, shift,
                           log_scale, quanAddr, dquanAddr);
 
     // next 4 AC
     coeff[1] = _mm_loadu_si128((__m128i const *)(src + coeff_stride));
     quantize_coeff_phase1(&coeff[1], qparam, shift, log_scale, qcoeff, dequant,
                           &coeff_sign);
new file mode 100644
--- /dev/null
+++ b/third_party/aom/av1/encoder/x86/av1_quantize_avx2.c
@@ -0,0 +1,289 @@
+/*
+ * Copyright (c) 2017, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+#include <immintrin.h>
+
+#include "./av1_rtcd.h"
+#include "aom/aom_integer.h"
+#include "aom_dsp/aom_dsp_common.h"
+
+static INLINE void read_coeff(const tran_low_t *coeff, __m256i *c) {
+#if CONFIG_HIGHBITDEPTH
+  const __m256i x0 = _mm256_loadu_si256((const __m256i *)coeff);
+  const __m256i x1 = _mm256_loadu_si256((const __m256i *)coeff + 1);
+  *c = _mm256_packs_epi32(x0, x1);
+  *c = _mm256_permute4x64_epi64(*c, 0xD8);
+#else
+  *c = _mm256_loadu_si256((const __m256i *)coeff);
+#endif
+}
+
+static INLINE void write_zero(tran_low_t *qcoeff) {
+  const __m256i zero = _mm256_setzero_si256();
+#if CONFIG_HIGHBITDEPTH
+  _mm256_storeu_si256((__m256i *)qcoeff, zero);
+  _mm256_storeu_si256((__m256i *)qcoeff + 1, zero);
+#else
+  _mm256_storeu_si256((__m256i *)qcoeff, zero);
+#endif
+}
+
+static INLINE void init_one_qp(const __m128i *p, __m256i *qp) {
+  const __m128i ac = _mm_unpackhi_epi64(*p, *p);
+  *qp = _mm256_insertf128_si256(_mm256_castsi128_si256(*p), ac, 1);
+}
+
+static INLINE void init_qp(const int16_t *round_ptr, const int16_t *quant_ptr,
+                           const int16_t *dequant_ptr, int log_scale,
+                           __m256i *thr, __m256i *qp) {
+  __m128i round = _mm_loadu_si128((const __m128i *)round_ptr);
+  const __m128i quant = _mm_loadu_si128((const __m128i *)quant_ptr);
+  const __m128i dequant = _mm_loadu_si128((const __m128i *)dequant_ptr);
+
+  if (log_scale > 0) {
+    const __m128i rnd = _mm_set1_epi16((int16_t)1 << (log_scale - 1));
+    round = _mm_add_epi16(round, rnd);
+    round = _mm_srai_epi16(round, log_scale);
+  }
+
+  init_one_qp(&round, &qp[0]);
+  init_one_qp(&quant, &qp[1]);
+
+  if (log_scale > 0) {
+    qp[1] = _mm256_slli_epi16(qp[1], log_scale);
+  }
+
+  init_one_qp(&dequant, &qp[2]);
+  *thr = _mm256_srai_epi16(qp[2], 1 + log_scale);
+}
+
+static INLINE void update_qp(int log_scale, __m256i *thr, __m256i *qp) {
+  qp[0] = _mm256_permute2x128_si256(qp[0], qp[0], 0x11);
+  qp[1] = _mm256_permute2x128_si256(qp[1], qp[1], 0x11);
+  qp[2] = _mm256_permute2x128_si256(qp[2], qp[2], 0x11);
+  *thr = _mm256_srai_epi16(qp[2], 1 + log_scale);
+}
+
+#define store_quan(q, addr)                               \
+  do {                                                    \
+    __m256i sign_bits = _mm256_srai_epi16(q, 15);         \
+    __m256i y0 = _mm256_unpacklo_epi16(q, sign_bits);     \
+    __m256i y1 = _mm256_unpackhi_epi16(q, sign_bits);     \
+    __m256i x0 = _mm256_permute2x128_si256(y0, y1, 0x20); \
+    __m256i x1 = _mm256_permute2x128_si256(y0, y1, 0x31); \
+    _mm256_storeu_si256((__m256i *)addr, x0);             \
+    _mm256_storeu_si256((__m256i *)addr + 1, x1);         \
+  } while (0)
+
+#if CONFIG_HIGHBITDEPTH
+#define store_two_quan(q, addr1, dq, addr2) \
+  do {                                      \
+    store_quan(q, addr1);                   \
+    store_quan(dq, addr2);                  \
+  } while (0)
+#else
+#define store_two_quan(q, addr1, dq, addr2)    \
+  do {                                         \
+    _mm256_storeu_si256((__m256i *)addr1, q);  \
+    _mm256_storeu_si256((__m256i *)addr2, dq); \
+  } while (0)
+#endif
+
+static INLINE void quantize(const __m256i *thr, const __m256i *qp, __m256i *c,
+                            const int16_t *iscan_ptr, tran_low_t *qcoeff,
+                            tran_low_t *dqcoeff, __m256i *eob) {
+  const __m256i abs = _mm256_abs_epi16(*c);
+  __m256i mask = _mm256_cmpgt_epi16(abs, *thr);
+  mask = _mm256_or_si256(mask, _mm256_cmpeq_epi16(abs, *thr));
+  const int nzflag = _mm256_movemask_epi8(mask);
+
+  if (nzflag) {
+    __m256i q = _mm256_adds_epi16(abs, qp[0]);
+    q = _mm256_mulhi_epi16(q, qp[1]);
+    q = _mm256_sign_epi16(q, *c);
+    const __m256i dq = _mm256_mullo_epi16(q, qp[2]);
+
+    store_two_quan(q, qcoeff, dq, dqcoeff);
+    const __m256i zero = _mm256_setzero_si256();
+    const __m256i iscan = _mm256_loadu_si256((const __m256i *)iscan_ptr);
+    const __m256i zero_coeff = _mm256_cmpeq_epi16(dq, zero);
+    const __m256i nzero_coeff = _mm256_cmpeq_epi16(zero_coeff, zero);
+    __m256i cur_eob = _mm256_sub_epi16(iscan, nzero_coeff);
+    cur_eob = _mm256_and_si256(cur_eob, nzero_coeff);
+    *eob = _mm256_max_epi16(*eob, cur_eob);
+  } else {
+    write_zero(qcoeff);
+    write_zero(dqcoeff);
+  }
+}
+
+void av1_quantize_fp_avx2(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
+                          int skip_block, const int16_t *zbin_ptr,
+                          const int16_t *round_ptr, const int16_t *quant_ptr,
+                          const int16_t *quant_shift_ptr,
+                          tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
+                          const int16_t *dequant_ptr, uint16_t *eob_ptr,
+                          const int16_t *scan_ptr, const int16_t *iscan_ptr) {
+  (void)scan_ptr;
+  (void)zbin_ptr;
+  (void)quant_shift_ptr;
+  const unsigned int step = 16;
+
+  if (LIKELY(!skip_block)) {
+    __m256i qp[3];
+    __m256i coeff, thr;
+    const int log_scale = 0;
+
+    init_qp(round_ptr, quant_ptr, dequant_ptr, log_scale, &thr, qp);
+    read_coeff(coeff_ptr, &coeff);
+
+    __m256i eob = _mm256_setzero_si256();
+    quantize(&thr, qp, &coeff, iscan_ptr, qcoeff_ptr, dqcoeff_ptr, &eob);
+
+    coeff_ptr += step;
+    qcoeff_ptr += step;
+    dqcoeff_ptr += step;
+    iscan_ptr += step;
+    n_coeffs -= step;
+
+    update_qp(log_scale, &thr, qp);
+
+    while (n_coeffs > 0) {
+      read_coeff(coeff_ptr, &coeff);
+      quantize(&thr, qp, &coeff, iscan_ptr, qcoeff_ptr, dqcoeff_ptr, &eob);
+
+      coeff_ptr += step;
+      qcoeff_ptr += step;
+      dqcoeff_ptr += step;
+      iscan_ptr += step;
+      n_coeffs -= step;
+    }
+    {
+      __m256i eob_s;
+      eob_s = _mm256_shuffle_epi32(eob, 0xe);
+      eob = _mm256_max_epi16(eob, eob_s);
+      eob_s = _mm256_shufflelo_epi16(eob, 0xe);
+      eob = _mm256_max_epi16(eob, eob_s);
+      eob_s = _mm256_shufflelo_epi16(eob, 1);
+      eob = _mm256_max_epi16(eob, eob_s);
+      const __m128i final_eob = _mm_max_epi16(_mm256_castsi256_si128(eob),
+                                              _mm256_extractf128_si256(eob, 1));
+      *eob_ptr = _mm_extract_epi16(final_eob, 0);
+    }
+  } else {
+    do {
+      write_zero(qcoeff_ptr);
+      write_zero(dqcoeff_ptr);
+      qcoeff_ptr += step;
+      dqcoeff_ptr += step;
+      n_coeffs -= step;
+    } while (n_coeffs > 0);
+    *eob_ptr = 0;
+  }
+}
+
+static INLINE void quantize_32x32(const __m256i *thr, const __m256i *qp,
+                                  __m256i *c, const int16_t *iscan_ptr,
+                                  tran_low_t *qcoeff, tran_low_t *dqcoeff,
+                                  __m256i *eob) {
+  const __m256i abs = _mm256_abs_epi16(*c);
+  __m256i mask = _mm256_cmpgt_epi16(abs, *thr);
+  mask = _mm256_or_si256(mask, _mm256_cmpeq_epi16(abs, *thr));
+  const int nzflag = _mm256_movemask_epi8(mask);
+
+  if (nzflag) {
+    __m256i q = _mm256_adds_epi16(abs, qp[0]);
+    q = _mm256_mulhi_epu16(q, qp[1]);
+
+    __m256i dq = _mm256_mullo_epi16(q, qp[2]);
+    dq = _mm256_srli_epi16(dq, 1);
+
+    q = _mm256_sign_epi16(q, *c);
+    dq = _mm256_sign_epi16(dq, *c);
+
+    store_two_quan(q, qcoeff, dq, dqcoeff);
+    const __m256i zero = _mm256_setzero_si256();
+    const __m256i iscan = _mm256_loadu_si256((const __m256i *)iscan_ptr);
+    const __m256i zero_coeff = _mm256_cmpeq_epi16(dq, zero);
+    const __m256i nzero_coeff = _mm256_cmpeq_epi16(zero_coeff, zero);
+    __m256i cur_eob = _mm256_sub_epi16(iscan, nzero_coeff);
+    cur_eob = _mm256_and_si256(cur_eob, nzero_coeff);
+    *eob = _mm256_max_epi16(*eob, cur_eob);
+  } else {
+    write_zero(qcoeff);
+    write_zero(dqcoeff);
+  }
+}
+
+void av1_quantize_fp_32x32_avx2(
+    const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block,
+    const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr,
+    const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
+    tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
+    const int16_t *scan_ptr, const int16_t *iscan_ptr) {
+  (void)scan_ptr;
+  (void)zbin_ptr;
+  (void)quant_shift_ptr;
+  const unsigned int step = 16;
+
+  if (LIKELY(!skip_block)) {
+    __m256i qp[3];
+    __m256i coeff, thr;
+    const int log_scale = 1;
+
+    init_qp(round_ptr, quant_ptr, dequant_ptr, log_scale, &thr, qp);
+    read_coeff(coeff_ptr, &coeff);
+
+    __m256i eob = _mm256_setzero_si256();
+    quantize_32x32(&thr, qp, &coeff, iscan_ptr, qcoeff_ptr, dqcoeff_ptr, &eob);
+
+    coeff_ptr += step;
+    qcoeff_ptr += step;
+    dqcoeff_ptr += step;
+    iscan_ptr += step;
+    n_coeffs -= step;
+
+    update_qp(log_scale, &thr, qp);
+
+    while (n_coeffs > 0) {
+      read_coeff(coeff_ptr, &coeff);
+      quantize_32x32(&thr, qp, &coeff, iscan_ptr, qcoeff_ptr, dqcoeff_ptr,
+                     &eob);
+
+      coeff_ptr += step;
+      qcoeff_ptr += step;
+      dqcoeff_ptr += step;
+      iscan_ptr += step;
+      n_coeffs -= step;
+    }
+    {
+      __m256i eob_s;
+      eob_s = _mm256_shuffle_epi32(eob, 0xe);
+      eob = _mm256_max_epi16(eob, eob_s);
+      eob_s = _mm256_shufflelo_epi16(eob, 0xe);
+      eob = _mm256_max_epi16(eob, eob_s);
+      eob_s = _mm256_shufflelo_epi16(eob, 1);
+      eob = _mm256_max_epi16(eob, eob_s);
+      const __m128i final_eob = _mm_max_epi16(_mm256_castsi256_si128(eob),
+                                              _mm256_extractf128_si256(eob, 1));
+      *eob_ptr = _mm_extract_epi16(final_eob, 0);
+    }
+  } else {
+    do {
+      write_zero(qcoeff_ptr);
+      write_zero(dqcoeff_ptr);
+      qcoeff_ptr += step;
+      dqcoeff_ptr += step;
+      n_coeffs -= step;
+    } while (n_coeffs > 0);
+    *eob_ptr = 0;
+  }
+}
--- a/third_party/aom/av1/encoder/x86/dct_intrin_sse2.c
+++ b/third_party/aom/av1/encoder/x86/dct_intrin_sse2.c
@@ -9,16 +9,17 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #include <assert.h>
 #include <emmintrin.h>  // SSE2
 
 #include "./aom_dsp_rtcd.h"
 #include "./av1_rtcd.h"
+#include "av1/common/idct.h"
 #include "aom_dsp/txfm_common.h"
 #include "aom_dsp/x86/fwd_txfm_sse2.h"
 #include "aom_dsp/x86/synonyms.h"
 #include "aom_dsp/x86/txfm_common_sse2.h"
 #include "aom_ports/mem.h"
 
 static INLINE void load_buffer_4x4(const int16_t *input, __m128i *in,
                                    int stride, int flipud, int fliplr) {
@@ -198,18 +199,19 @@ static void fidtx4_sse2(__m128i *in) {
 
   in[0] = _mm_packs_epi32(u0, u2);
   in[1] = _mm_packs_epi32(u1, u3);
   transpose_4x4(in);
 }
 #endif  // CONFIG_EXT_TX
 
 void av1_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride,
-                     int tx_type) {
+                     FWD_TXFM_PARAM *fwd_txfm_param) {
   __m128i in[4];
+  int tx_type = fwd_txfm_param->tx_type;
 
   switch (tx_type) {
     case DCT_DCT: aom_fdct4x4_sse2(input, output, stride); break;
     case ADST_DCT:
       load_buffer_4x4(input, in, stride, 0, 0);
       fadst4_sse2(in);
       fdct4_sse2(in);
       write_buffer_4x4(output, in);
@@ -1296,18 +1298,19 @@ static void fidtx8_sse2(__m128i *in) {
   in[6] = _mm_slli_epi16(in[6], 1);
   in[7] = _mm_slli_epi16(in[7], 1);
 
   array_transpose_8x8(in, in);
 }
 #endif  // CONFIG_EXT_TX
 
 void av1_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride,
-                     int tx_type) {
+                     FWD_TXFM_PARAM *fwd_txfm_param) {
   __m128i in[8];
+  int tx_type = fwd_txfm_param->tx_type;
 
   switch (tx_type) {
     case DCT_DCT: aom_fdct8x8_sse2(input, output, stride); break;
     case ADST_DCT:
       load_buffer_8x8(input, in, stride, 0, 0);
       fadst8_sse2(in);
       fdct8_sse2(in);
       right_shift_8x8(in, 1);
@@ -2329,18 +2332,19 @@ static void fadst16_sse2(__m128i *in0, _
 static void fidtx16_sse2(__m128i *in0, __m128i *in1) {
   idtx16_8col(in0);
   idtx16_8col(in1);
   array_transpose_16x16(in0, in1);
 }
 #endif  // CONFIG_EXT_TX
 
 void av1_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride,
-                       int tx_type) {
+                       FWD_TXFM_PARAM *fwd_txfm_param) {
   __m128i in0[16], in1[16];
+  int tx_type = fwd_txfm_param->tx_type;
 
   switch (tx_type) {
     case DCT_DCT:
       load_buffer_16x16(input, in0, in1, stride, 0, 0);
       fdct16_sse2(in0, in1);
       right_shift_16x16(in0, in1);
       fdct16_sse2(in0, in1);
       write_buffer_16x16(output, in0, in1, 16);
@@ -2545,18 +2549,19 @@ static INLINE void write_buffer_4x8(tran
 
   store_output(&in01, (output + 0 * 8));
   store_output(&in23, (output + 1 * 8));
   store_output(&in45, (output + 2 * 8));
   store_output(&in67, (output + 3 * 8));
 }
 
 void av1_fht4x8_sse2(const int16_t *input, tran_low_t *output, int stride,
-                     int tx_type) {
+                     FWD_TXFM_PARAM *fwd_txfm_param) {
   __m128i in[8];
+  int tx_type = fwd_txfm_param->tx_type;
 
   switch (tx_type) {
     case DCT_DCT:
       load_buffer_4x8(input, in, stride, 0, 0);
       fdct4_sse2(in);
       fdct4_sse2(in + 4);
       fdct8_sse2(in);
       break;
@@ -2719,18 +2724,19 @@ static INLINE void write_buffer_8x4(tran
 
   store_output(&out0, (output + 0 * 8));
   store_output(&out1, (output + 1 * 8));
   store_output(&out2, (output + 2 * 8));
   store_output(&out3, (output + 3 * 8));
 }
 
 void av1_fht8x4_sse2(const int16_t *input, tran_low_t *output, int stride,
-                     int tx_type) {
+                     FWD_TXFM_PARAM *fwd_txfm_param) {
   __m128i in[8];
+  int tx_type = fwd_txfm_param->tx_type;
 
   switch (tx_type) {
     case DCT_DCT:
       load_buffer_8x4(input, in, stride, 0, 0);
       fdct4_sse2(in);
       fdct4_sse2(in + 4);
       fdct8_sse2(in);
       break;
@@ -2859,18 +2865,19 @@ static INLINE void round_power_of_two_si
 static void row_8x16_rounding(__m128i *in, int bits) {
   int i;
   for (i = 0; i < 16; i++) {
     round_power_of_two_signed(&in[i], bits);
   }
 }
 
 void av1_fht8x16_sse2(const int16_t *input, tran_low_t *output, int stride,
-                      int tx_type) {
+                      FWD_TXFM_PARAM *fwd_txfm_param) {
   __m128i in[16];
+  int tx_type = fwd_txfm_param->tx_type;
 
   __m128i *const t = in;      // Alias to top 8x8 sub block
   __m128i *const b = in + 8;  // Alias to bottom 8x8 sub block
 
   switch (tx_type) {
     case DCT_DCT:
       load_buffer_8x16(input, in, stride, 0, 0);
       array_transpose_8x8(t, t);
@@ -3040,18 +3047,19 @@ static INLINE void load_buffer_16x8(cons
   scale_sqrt2_8x8(in);
   load_buffer_8x8(r, in + 8, stride, flipud, fliplr);
   scale_sqrt2_8x8(in + 8);
 }
 
 #define col_16x8_rounding row_8x16_rounding
 
 void av1_fht16x8_sse2(const int16_t *input, tran_low_t *output, int stride,
-                      int tx_type) {
+                      FWD_TXFM_PARAM *fwd_txfm_param) {
   __m128i in[16];
+  int tx_type = fwd_txfm_param->tx_type;
 
   __m128i *const l = in;      // Alias to left 8x8 sub block
   __m128i *const r = in + 8;  // Alias to right 8x8 sub block, which we store
                               // in the second half of the array
 
   switch (tx_type) {
     case DCT_DCT:
       load_buffer_16x8(input, in, stride, 0, 0);
@@ -3350,18 +3358,19 @@ static INLINE void fhalfright32_16col(__
 }
 
 // Note on data layout, for both this and the 32x16 transforms:
 // So that we can reuse the 16-element transforms easily,
 // we want to split the input into 8x16 blocks.
 // For 16x32, this means the input is a 2x2 grid of such blocks.
 // For 32x16, it means the input is a 4x1 grid.
 void av1_fht16x32_sse2(const int16_t *input, tran_low_t *output, int stride,
-                       int tx_type) {
+                       FWD_TXFM_PARAM *fwd_txfm_param) {
   __m128i intl[16], intr[16], inbl[16], inbr[16];
+  int tx_type = fwd_txfm_param->tx_type;
 
   switch (tx_type) {
     case DCT_DCT:
       load_buffer_16x32(input, intl, intr, inbl, inbr, stride, 0, 0);
       fdct16t_sse2(intl, intr);
       fdct16t_sse2(inbl, inbr);
       round_signed_16x16(intl, intr);
       round_signed_16x16(inbl, inbr);
@@ -3539,18 +3548,19 @@ static INLINE void write_buffer_32x16(tr
     store_output(&res0[i], output + i * 32 + 0);
     store_output(&res1[i], output + i * 32 + 8);
     store_output(&res2[i], output + i * 32 + 16);
     store_output(&res3[i], output + i * 32 + 24);
   }
 }
 
 void av1_fht32x16_sse2(const int16_t *input, tran_low_t *output, int stride,
-                       int tx_type) {
+                       FWD_TXFM_PARAM *fwd_txfm_param) {
   __m128i in0[16], in1[16], in2[16], in3[16];
+  int tx_type = fwd_txfm_param->tx_type;
 
   load_buffer_32x16(input, in0, in1, in2, in3, stride, 0, 0);
   switch (tx_type) {
     case DCT_DCT:
       fdct16_sse2(in0, in1);
       fdct16_sse2(in2, in3);
       round_signed_16x16(in0, in1);
       round_signed_16x16(in2, in3);
@@ -3779,18 +3789,19 @@ static INLINE void write_buffer_32x32(__
     store_output(&in0[i], output + i * 32 + 0);
     store_output(&in1[i], output + i * 32 + 8);
     store_output(&in2[i], output + i * 32 + 16);
     store_output(&in3[i], output + i * 32 + 24);
   }
 }
 
 void av1_fht32x32_sse2(const int16_t *input, tran_low_t *output, int stride,
-                       int tx_type) {
+                       FWD_TXFM_PARAM *fwd_txfm_param) {
   __m128i in0[32], in1[32], in2[32], in3[32];
+  int tx_type = fwd_txfm_param->tx_type;
 
   load_buffer_32x32(input, in0, in1, in2, in3, stride, 0, 0);
   switch (tx_type) {
     case DCT_DCT:
       fdct32(in0, in1, in2, in3);
       round_signed_32x32(in0, in1, in2, in3);
       fdct32(in0, in1, in2, in3);
       break;
--- a/third_party/aom/av1/encoder/x86/error_intrin_avx2.c
+++ b/third_party/aom/av1/encoder/x86/error_intrin_avx2.c
@@ -9,34 +9,47 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #include <immintrin.h>  // AVX2
 
 #include "./av1_rtcd.h"
 #include "aom/aom_integer.h"
 
-int64_t av1_block_error_avx2(const int16_t *coeff, const int16_t *dqcoeff,
+static INLINE void read_coeff(const tran_low_t *coeff, intptr_t offset,
+                              __m256i *c) {
+  const tran_low_t *addr = coeff + offset;
+#if CONFIG_HIGHBITDEPTH
+  const __m256i x0 = _mm256_loadu_si256((const __m256i *)addr);
+  const __m256i x1 = _mm256_loadu_si256((const __m256i *)addr + 1);
+  const __m256i y = _mm256_packs_epi32(x0, x1);
+  *c = _mm256_permute4x64_epi64(y, 0xD8);
+#else
+  *c = _mm256_loadu_si256((const __m256i *)addr);
+#endif
+}
+
+int64_t av1_block_error_avx2(const tran_low_t *coeff, const tran_low_t *dqcoeff,
                              intptr_t block_size, int64_t *ssz) {
   __m256i sse_reg, ssz_reg, coeff_reg, dqcoeff_reg;
   __m256i exp_dqcoeff_lo, exp_dqcoeff_hi, exp_coeff_lo, exp_coeff_hi;
   __m256i sse_reg_64hi, ssz_reg_64hi;
   __m128i sse_reg128, ssz_reg128;
   int64_t sse;
   int i;
-  const __m256i zero_reg = _mm256_set1_epi16(0);
+  const __m256i zero_reg = _mm256_setzero_si256();
 
   // init sse and ssz registerd to zero
-  sse_reg = _mm256_set1_epi16(0);
-  ssz_reg = _mm256_set1_epi16(0);
+  sse_reg = _mm256_setzero_si256();
+  ssz_reg = _mm256_setzero_si256();
 
   for (i = 0; i < block_size; i += 16) {
     // load 32 bytes from coeff and dqcoeff
-    coeff_reg = _mm256_loadu_si256((const __m256i *)(coeff + i));
-    dqcoeff_reg = _mm256_loadu_si256((const __m256i *)(dqcoeff + i));
+    read_coeff(coeff, i, &coeff_reg);
+    read_coeff(dqcoeff, i, &dqcoeff_reg);
     // dqcoeff - coeff
     dqcoeff_reg = _mm256_sub_epi16(dqcoeff_reg, coeff_reg);
     // madd (dqcoeff - coeff)
     dqcoeff_reg = _mm256_madd_epi16(dqcoeff_reg, dqcoeff_reg);
     // madd coeff
     coeff_reg = _mm256_madd_epi16(coeff_reg, coeff_reg);
     // expand each double word of madd (dqcoeff - coeff) to quad word
     exp_dqcoeff_lo = _mm256_unpacklo_epi32(dqcoeff_reg, zero_reg);
--- a/third_party/aom/av1/encoder/x86/highbd_fwd_txfm_sse4.c
+++ b/third_party/aom/av1/encoder/x86/highbd_fwd_txfm_sse4.c
@@ -108,35 +108,23 @@ static void fdct4x4_sse4_1(__m128i *in, 
   v3 = _mm_unpackhi_epi32(u2, u3);
 
   in[0] = _mm_unpacklo_epi64(v0, v2);
   in[1] = _mm_unpackhi_epi64(v0, v2);
   in[2] = _mm_unpacklo_epi64(v1, v3);
   in[3] = _mm_unpackhi_epi64(v1, v3);
 }
 
-static INLINE void write_buffer_4x4(__m128i *res, tran_low_t *output) {
+static INLINE void write_buffer_4x4(__m128i *res, int32_t *output) {
   _mm_store_si128((__m128i *)(output + 0 * 4), res[0]);
   _mm_store_si128((__m128i *)(output + 1 * 4), res[1]);
   _mm_store_si128((__m128i *)(output + 2 * 4), res[2]);
   _mm_store_si128((__m128i *)(output + 3 * 4), res[3]);
 }
 
-// Note:
-//  We implement av1_fwd_txfm2d_4x4(). This function is kept here since
-//  av1_highbd_fht4x4_c() is not removed yet
-void av1_highbd_fht4x4_sse4_1(const int16_t *input, tran_low_t *output,
-                              int stride, int tx_type) {
-  (void)input;
-  (void)output;
-  (void)stride;
-  (void)tx_type;
-  assert(0);
-}
-
 static void fadst4x4_sse4_1(__m128i *in, int bit) {
   const int32_t *cospi = cospi_arr(bit);
   const __m128i cospi8 = _mm_set1_epi32(cospi[8]);
   const __m128i cospi56 = _mm_set1_epi32(cospi[56]);
   const __m128i cospi40 = _mm_set1_epi32(cospi[40]);
   const __m128i cospi24 = _mm_set1_epi32(cospi[24]);
   const __m128i cospi32 = _mm_set1_epi32(cospi[32]);
   const __m128i rnding = _mm_set1_epi32(1 << (bit - 1));
@@ -411,17 +399,17 @@ static INLINE void col_txfm_8x8_rounding
   in[10] = _mm_srai_epi32(in[10], shift);
   in[11] = _mm_srai_epi32(in[11], shift);
   in[12] = _mm_srai_epi32(in[12], shift);
   in[13] = _mm_srai_epi32(in[13], shift);
   in[14] = _mm_srai_epi32(in[14], shift);
   in[15] = _mm_srai_epi32(in[15], shift);
 }
 
-static INLINE void write_buffer_8x8(const __m128i *res, tran_low_t *output) {
+static INLINE void write_buffer_8x8(const __m128i *res, int32_t *output) {
   _mm_store_si128((__m128i *)(output + 0 * 4), res[0]);
   _mm_store_si128((__m128i *)(output + 1 * 4), res[1]);
   _mm_store_si128((__m128i *)(output + 2 * 4), res[2]);
   _mm_store_si128((__m128i *)(output + 3 * 4), res[3]);
 
   _mm_store_si128((__m128i *)(output + 4 * 4), res[4]);
   _mm_store_si128((__m128i *)(output + 5 * 4), res[5]);
   _mm_store_si128((__m128i *)(output + 6 * 4), res[6]);
@@ -1795,17 +1783,17 @@ static void col_txfm_16x16_rounding(__m1
   //  We split 16x16 rounding into 4 sections of 8x8 rounding,
   //  instead of 4 columns
   col_txfm_8x8_rounding(&in[0], shift);
   col_txfm_8x8_rounding(&in[16], shift);
   col_txfm_8x8_rounding(&in[32], shift);
   col_txfm_8x8_rounding(&in[48], shift);
 }
 
-static void write_buffer_16x16(const __m128i *in, tran_low_t *output) {
+static void write_buffer_16x16(const __m128i *in, int32_t *output) {
   const int size_8x8 = 16 * 4;
   write_buffer_8x8(&in[0], output);
   output += size_8x8;
   write_buffer_8x8(&in[16], output);
   output += size_8x8;
   write_buffer_8x8(&in[32], output);
   output += size_8x8;
   write_buffer_8x8(&in[48], output);
--- a/third_party/aom/av1/encoder/x86/hybrid_fwd_txfm_avx2.c
+++ b/third_party/aom/av1/encoder/x86/hybrid_fwd_txfm_avx2.c
@@ -9,65 +9,21 @@
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #include <immintrin.h>  // avx2
 
 #include "./av1_rtcd.h"
 #include "./aom_dsp_rtcd.h"
 
+#include "av1/common/idct.h"
 #include "aom_dsp/x86/fwd_txfm_avx2.h"
 #include "aom_dsp/txfm_common.h"
 #include "aom_dsp/x86/txfm_common_avx2.h"
 
-static int32_t get_16x16_sum(const int16_t *input, int stride) {
-  __m256i r0, r1, r2, r3, u0, u1;
-  __m256i zero = _mm256_setzero_si256();
-  __m256i sum = _mm256_setzero_si256();
-  const int16_t *blockBound = input + (stride << 4);
-  __m128i v0, v1;
-
-  while (input < blockBound) {
-    r0 = _mm256_loadu_si256((__m256i const *)input);
-    r1 = _mm256_loadu_si256((__m256i const *)(input + stride));
-    r2 = _mm256_loadu_si256((__m256i const *)(input + 2 * stride));
-    r3 = _mm256_loadu_si256((__m256i const *)(input + 3 * stride));
-
-    u0 = _mm256_add_epi16(r0, r1);
-    u1 = _mm256_add_epi16(r2, r3);
-    sum = _mm256_add_epi16(sum, u0);
-    sum = _mm256_add_epi16(sum, u1);
-
-    input += stride << 2;
-  }
-
-  // unpack 16 int16_t into 2x8 int32_t
-  u0 = _mm256_unpacklo_epi16(zero, sum);
-  u1 = _mm256_unpackhi_epi16(zero, sum);
-  u0 = _mm256_srai_epi32(u0, 16);
-  u1 = _mm256_srai_epi32(u1, 16);
-  sum = _mm256_add_epi32(u0, u1);
-
-  u0 = _mm256_srli_si256(sum, 8);
-  u1 = _mm256_add_epi32(sum, u0);
-
-  v0 = _mm_add_epi32(_mm256_extracti128_si256(u1, 1),
-                     _mm256_castsi256_si128(u1));
-  v1 = _mm_srli_si128(v0, 4);
-  v0 = _mm_add_epi32(v0, v1);
-  return (int32_t)_mm_extract_epi32(v0, 0);
-}
-
-void aom_fdct16x16_1_avx2(const int16_t *input, tran_low_t *output,
-                          int stride) {
-  int32_t dc = get_16x16_sum(input, stride);
-  output[0] = (tran_low_t)(dc >> 1);
-  _mm256_zeroupper();
-}
-
 static INLINE void load_buffer_16x16(const int16_t *input, int stride,
                                      int flipud, int fliplr, __m256i *in) {
   if (!flipud) {
     in[0] = _mm256_loadu_si256((const __m256i *)(input + 0 * stride));
     in[1] = _mm256_loadu_si256((const __m256i *)(input + 1 * stride));
     in[2] = _mm256_loadu_si256((const __m256i *)(input + 2 * stride));
     in[3] = _mm256_loadu_si256((const __m256i *)(input + 3 * stride));
     in[4] = _mm256_loadu_si256((const __m256i *)(input + 4 * stride));
@@ -954,18 +910,19 @@ void fadst16_avx2(__m256i *in) {
 
 #if CONFIG_EXT_TX
 static void fidtx16_avx2(__m256i *in) {
   txfm_scaling16_avx2((int16_t)Sqrt2, in);
 }
 #endif
 
 void av1_fht16x16_avx2(const int16_t *input, tran_low_t *output, int stride,
-                       int tx_type) {
+                       FWD_TXFM_PARAM *fwd_txfm_param) {
   __m256i in[16];
+  int tx_type = fwd_txfm_param->tx_type;
 
   switch (tx_type) {
     case DCT_DCT:
       load_buffer_16x16(input, stride, 0, 0, in);
       fdct16_avx2(in);
       mm256_transpose_16x16(in, in);
       right_shift_16x16(in);
       fdct16_avx2(in);
@@ -1079,32 +1036,16 @@ void av1_fht16x16_avx2(const int16_t *in
 #endif  // CONFIG_EXT_TX
     default: assert(0); break;
   }
   mm256_transpose_16x16(in, in);
   write_buffer_16x16(in, output);
   _mm256_zeroupper();
 }
 
-void aom_fdct32x32_1_avx2(const int16_t *input, tran_low_t *output,
-                          int stride) {
-  // left and upper corner
-  int32_t sum = get_16x16_sum(input, stride);
-  // right and upper corner
-  sum += get_16x16_sum(input + 16, stride);
-  // left and lower corner
-  sum += get_16x16_sum(input + (stride << 4), stride);
-  // right and lower corner
-  sum += get_16x16_sum(input + (stride << 4) + 16, stride);
-
-  sum >>= 3;
-  output[0] = (tran_low_t)sum;
-  _mm256_zeroupper();
-}
-
 static void mm256_vectors_swap(__m256i *a0, __m256i *a1, const int size) {
   int i = 0;
   __m256i temp;
   while (i < size) {
     temp = a0[i];
     a0[i] = a1[i];
     a1[i] = temp;
     i++;
@@ -1565,19 +1506,20 @@ static void fidtx32_avx2(__m256i *in0, _
     in1[i] = _mm256_slli_epi16(in1[i], 2);
     i += 1;
   }
   mm256_transpose_32x32(in0, in1);
 }
 #endif
 
 void av1_fht32x32_avx2(const int16_t *input, tran_low_t *output, int stride,
-                       int tx_type) {
+                       FWD_TXFM_PARAM *fwd_txfm_param) {
   __m256i in0[32];  // left 32 columns
   __m256i in1[32];  // right 32 columns
+  int tx_type = fwd_txfm_param->tx_type;
 
   switch (tx_type) {
     case DCT_DCT:
       load_buffer_32x32(input, stride, 0, 0, in0, in1);
       fdct32_avx2(in0, in1);
       right_shift_32x32(in0, in1);
       fdct32_avx2(in0, in1);
       break;
--- a/third_party/aom/build/cmake/aom_config_defaults.cmake
+++ b/third_party/aom/build/cmake/aom_config_defaults.cmake
@@ -10,155 +10,164 @@
 ##
 
 # Defaults for every libaom configuration variable. Here we add all libaom
 # config variables to the cmake variable cache, but omit the FORCE parameter to
 # allow users to specify values when executing cmake to generate build files.
 # Values here are used only if not set by the user.
 set(RESTRICT "" CACHE STRING "Sets RESTRICT value for current target.")
 set(INLINE "" CACHE STRING "Sets INLINE value for current target.")
-set(ARCH_ARM 0 CACHE BOOL "Enables ARM architecture.")
-set(ARCH_MIPS 0 CACHE BOOL "Enables MIPS architecture.")
-set(ARCH_X86 0 CACHE BOOL "Enables X86 architecture.")
-set(ARCH_X86_64 0 CACHE BOOL "Enables X86_64 architecture.")
-set(HAVE_EDSP 0 CACHE BOOL "Enables EDSP optimizations.")
-set(HAVE_NEON 0 CACHE BOOL "Enables NEON intrinsics optimizations.")
-set(HAVE_NEON_ASM 0 CACHE BOOL "Enables NEON assembly optimizations.")
-set(HAVE_MIPS32 0 CACHE BOOL "Enables MIPS32 optimizations.")
-set(HAVE_DSPR2 0 CACHE BOOL "Enables DSPR2 optimizations.")
-set(HAVE_MSA 0 CACHE BOOL "Enables MSA optimizations.")
-set(HAVE_MIPS64 0 CACHE BOOL "Enables MIPS64 optimizations. ")
-set(HAVE_MMX 0 CACHE BOOL "Enables MMX optimizations. ")
-set(HAVE_SSE 0 CACHE BOOL "Enables SSE optimizations.")
-set(HAVE_SSE2 0 CACHE BOOL "Enables SSE2 optimizations.")
-set(HAVE_SSE3 0 CACHE BOOL "Enables SSE3 optimizations.")
-set(HAVE_SSSE3 0 CACHE BOOL "Enables SSSE3 optimizations.")
-set(HAVE_SSE4_1 0 CACHE BOOL "Enables SSE 4.1 optimizations.")
-set(HAVE_AVX 0 CACHE BOOL "Enables AVX optimizations.")
-set(HAVE_AVX2 0 CACHE BOOL "Enables AVX2 optimizations.")
-set(HAVE_AOM_PORTS 0 CACHE BOOL "Internal flag, deprecated.")
-set(HAVE_FEXCEPT 0 CACHE BOOL "Internal flag, GNU fenv.h present for target.")
-set(HAVE_PTHREAD_H 0 CACHE BOOL "Internal flag, target pthread support.")
-set(HAVE_UNISTD_H 0 CACHE BOOL "Internal flag, unistd.h present for target.")
-set(HAVE_WXWIDGETS 0 CACHE BOOL "WxWidgets present.")
-set(CONFIG_DEPENDENCY_TRACKING 1 CACHE BOOL "Internal flag.")
-set(CONFIG_EXTERNAL_BUILD 0 CACHE BOOL "Internal flag.")
-set(CONFIG_INSTALL_BINS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_INSTALL_LIBS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_INSTALL_SRCS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_DEBUG 0 CACHE BOOL "Internal flag.")
-set(CONFIG_GPROF 0 CACHE BOOL "Internal flag.")
-set(CONFIG_GCOV 0 CACHE BOOL "Internal flag.")
-set(CONFIG_RVCT 0 CACHE BOOL "Internal flag.")
-set(CONFIG_GCC 0 CACHE BOOL "Internal flag.")
-set(CONFIG_MSVS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_PIC 0 CACHE BOOL "Internal flag.")
-set(CONFIG_BIG_ENDIAN 0 CACHE BOOL "Internal flag.")
-set(CONFIG_CODEC_SRCS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_DEBUG_LIBS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_RUNTIME_CPU_DETECT 1 CACHE BOOL "Internal flag.")
-set(CONFIG_POSTPROC 1 CACHE BOOL "Internal flag.")
-set(CONFIG_MULTITHREAD 1 CACHE BOOL "Internal flag.")
-set(CONFIG_INTERNAL_STATS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_AV1_ENCODER 1 CACHE BOOL "Enable AV1 encoder.")
-set(CONFIG_AV1_DECODER 1 CACHE BOOL "Enable AV1 decoder.")
-set(CONFIG_AV1 1 CACHE BOOL "Internal flag.")
-set(CONFIG_STATIC_MSVCRT 0 CACHE BOOL "Internal flag.")
-set(CONFIG_SPATIAL_RESAMPLING 1 CACHE BOOL "Internal flag.")
-set(CONFIG_REALTIME_ONLY 0 CACHE BOOL "Internal flag.")
-set(CONFIG_ONTHEFLY_BITPACKING 0 CACHE BOOL "Internal flag.")
-set(CONFIG_ERROR_CONCEALMENT 0 CACHE BOOL "Internal flag.")
-set(CONFIG_SHARED 0 CACHE BOOL "Internal flag.")
-set(CONFIG_STATIC 1 CACHE BOOL "Internal flag.")
-set(CONFIG_SMALL 0 CACHE BOOL "Internal flag.")
-set(CONFIG_POSTPROC_VISUALIZER 0 CACHE BOOL "Internal flag.")
-set(CONFIG_OS_SUPPORT 0 CACHE BOOL "Internal flag.")
-set(CONFIG_UNIT_TESTS 1 CACHE BOOL "Internal flag.")
-set(CONFIG_WEBM_IO 1 CACHE BOOL "Enables WebM support.")
-set(CONFIG_LIBYUV 1 CACHE BOOL "Enables libyuv scaling and conversion support.")
-set(CONFIG_ACCOUNTING 0 CACHE BOOL "Enables bit accounting.")
-set(CONFIG_INSPECTION 0 CACHE BOOL "Enables bitstream inspection.")
-set(CONFIG_DECODE_PERF_TESTS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_ENCODE_PERF_TESTS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_COEFFICIENT_RANGE_CHECKING 0 CACHE BOOL "Internal flag.")
-set(CONFIG_LOWBITDEPTH 1 CACHE BOOL "Internal flag.")
-set(CONFIG_HIGHBITDEPTH 1 CACHE BOOL "Internal flag.")
-set(CONFIG_EXPERIMENTAL 0 CACHE BOOL "Internal flag.")
-set(CONFIG_SIZE_LIMIT 0 CACHE BOOL "Internal flag.")
-set(CONFIG_FP_MB_STATS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_CDEF 1 CACHE BOOL "Internal flag.")
-set(CONFIG_VAR_TX 1 CACHE BOOL "Internal flag.")
-set(CONFIG_RECT_TX 1 CACHE BOOL "Internal flag.")
-set(CONFIG_RECT_TX_EXT 0 CACHE BOOL "Internal flag.")
-set(CONFIG_TPL_MV 0 CACHE BOOL "Internal flag.")
-set(CONFIG_DUAL_FILTER 1 CACHE BOOL "Internal flag.")
-set(CONFIG_CONVOLVE_ROUND 0 CACHE BOOL "Internal flag.")
-set(CONFIG_COMPOUND_ROUND 0 CACHE BOOL "Internal flag.")
-set(CONFIG_EXT_TX 1 CACHE BOOL "Internal flag.")
-set(CONFIG_DPCM_INTRA 0 CACHE BOOL "Internal flag.")
-set(CONFIG_TX64X64 0 CACHE BOOL "Internal flag.")
-set(CONFIG_EXT_INTRA 1 CACHE BOOL "Internal flag.")
-set(CONFIG_INTRA_INTERP 0 CACHE BOOL "Internal flag.")
-set(CONFIG_FILTER_INTRA 0 CACHE BOOL "Internal flag.")
-set(CONFIG_INTRA_EDGE 0 CACHE BOOL "Internal flag.")
-set(CONFIG_INTRABC 0 CACHE BOOL "Internal flag.")
-set(CONFIG_EXT_INTER 0 CACHE BOOL "Internal flag.")
-set(CONFIG_INTERINTRA 0 CACHE BOOL "Internal flag.")
-set(CONFIG_WEDGE 0 CACHE BOOL "Internal flag.")
-set(CONFIG_COMPOUND_SEGMENT 0 CACHE BOOL "Internal flag.")
-set(CONFIG_EXT_REFS 1 CACHE BOOL "Internal flag.")
-set(CONFIG_GLOBAL_MOTION 1 CACHE BOOL "Internal flag.")
-set(CONFIG_NEW_QUANT 0 CACHE BOOL "Internal flag.")
-set(CONFIG_SUPERTX 0 CACHE BOOL "Internal flag.")
-set(CONFIG_ANS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_LOOP_RESTORATION 0 CACHE BOOL "Internal flag.")
-set(CONFIG_EXT_PARTITION 0 CACHE BOOL "Internal flag.")
-set(CONFIG_EXT_PARTITION_TYPES 0 CACHE BOOL "Internal flag.")
-set(CONFIG_UNPOISON_PARTITION_CTX 0 CACHE BOOL "Internal flag.")
-set(CONFIG_EXT_TILE 0 CACHE BOOL "Internal flag.")
-set(CONFIG_MOTION_VAR 1 CACHE BOOL "Internal flag.")
-set(CONFIG_NCOBMC 0 CACHE BOOL "Internal flag.")
-set(CONFIG_WARPED_MOTION 1 CACHE BOOL "Internal flag.")
-set(CONFIG_Q_ADAPT_PROBS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_BITSTREAM_DEBUG 0 CACHE BOOL "Internal flag.")
-set(CONFIG_ALT_INTRA 1 CACHE BOOL "Internal flag.")
-set(CONFIG_PALETTE 1 CACHE BOOL "Internal flag.")
-set(CONFIG_PALETTE_DELTA_ENCODING 0 CACHE BOOL "Internal flag.")
-set(CONFIG_RAWBITS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_EC_SMALLMUL 1 CACHE BOOL "Internal flag.")
-set(CONFIG_PVQ 0 CACHE BOOL "Internal flag.")
-set(CONFIG_CFL 0 CACHE BOOL "Internal flag.")
-set(CONFIG_XIPHRC 0 CACHE BOOL "Internal flag.")
-set(CONFIG_CB4X4 1 CACHE BOOL "Internal flag.")
-set(CONFIG_CHROMA_2X2 0 CACHE BOOL "Internal flag.")
-set(CONFIG_CHROMA_SUB8X8 1 CACHE BOOL "Internal flag.")
-set(CONFIG_FRAME_SIZE 0 CACHE BOOL "Internal flag.")
-set(CONFIG_DELTA_Q 1 CACHE BOOL "Internal flag.")
-set(CONFIG_EXT_DELTA_Q 1 CACHE BOOL "Internal flag.")
-set(CONFIG_ADAPT_SCAN 0 CACHE BOOL "Internal flag.")
-set(CONFIG_FILTER_7BIT 1 CACHE BOOL "Internal flag.")
-set(CONFIG_PARALLEL_DEBLOCKING 0 CACHE BOOL "Internal flag.")
-set(CONFIG_PARALLEL_DEBLOCKING_15TAP 0 CACHE BOOL "Internal flag.")
-set(CONFIG_LOOPFILTERING_ACROSS_TILES 1 CACHE BOOL "Internal flag.")
-set(CONFIG_TILE_GROUPS 1 CACHE BOOL "Internal flag.")
-set(CONFIG_EC_ADAPT 1 CACHE BOOL "Internal flag.")
-set(CONFIG_TEMPMV_SIGNALING 1 CACHE BOOL "Internal flag.")
-set(CONFIG_RD_DEBUG 0 CACHE BOOL "Internal flag.")
-set(CONFIG_REFERENCE_BUFFER 1 CACHE BOOL "Internal flag.")
-set(CONFIG_COEF_INTERLEAVE 0 CACHE BOOL "Internal flag.")
-set(CONFIG_ENTROPY_STATS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_MASKED_TX 0 CACHE BOOL "Internal flag.")
-set(CONFIG_DEPENDENT_HORZTILES 0 CACHE BOOL "Internal flag.")
-set(CONFIG_DAALA_DIST 0 CACHE BOOL "Internal flag.")
-set(CONFIG_TRIPRED 0 CACHE BOOL "Internal flag.")
-set(CONFIG_PALETTE_THROUGHPUT 1 CACHE BOOL "Internal flag.")
-set(CONFIG_REF_ADAPT 0 CACHE BOOL "Internal flag.")
-set(CONFIG_LV_MAP 0 CACHE BOOL "Internal flag.")
-set(CONFIG_TXK_SEL 0 CACHE BOOL "Internal flag.")
-set(CONFIG_MV_COMPRESS 1 CACHE BOOL "Internal flag.")
-set(CONFIG_FRAME_SUPERRES 0 CACHE BOOL "Internal flag.")
-set(CONFIG_NEW_MULTISYMBOL 0 CACHE BOOL "Internal flag.")
-set(CONFIG_COMPOUND_SINGLEREF 0 CACHE BOOL "Internal flag.")
-set(CONFIG_AOM_QM 0 CACHE BOOL "Internal flag.")
-set(CONFIG_ONE_SIDED_COMPOUND 1 CACHE BOOL "Internal flag.")
-set(CONFIG_SMOOTH_HV 0 CACHE BOOL "Internal flag.")
-set(CONFIG_VAR_REFS 0 CACHE BOOL "Internal flag.")
-set(CONFIG_ANALYZER 0 CACHE BOOL "Internal flag.")
+set(ARCH_ARM 0 CACHE NUMBER "Enables ARM architecture.")
+set(ARCH_MIPS 0 CACHE NUMBER "Enables MIPS architecture.")
+set(ARCH_X86 0 CACHE NUMBER "Enables X86 architecture.")
+set(ARCH_X86_64 0 CACHE NUMBER "Enables X86_64 architecture.")
+set(HAVE_EDSP 0 CACHE NUMBER "Enables EDSP optimizations.")
+set(HAVE_NEON 0 CACHE NUMBER "Enables NEON intrinsics optimizations.")
+set(HAVE_NEON_ASM 0 CACHE NUMBER "Enables NEON assembly optimizations.")
+set(HAVE_MIPS32 0 CACHE NUMBER "Enables MIPS32 optimizations.")
+set(HAVE_DSPR2 0 CACHE NUMBER "Enables DSPR2 optimizations.")
+set(HAVE_MSA 0 CACHE NUMBER "Enables MSA optimizations.")
+set(HAVE_MIPS64 0 CACHE NUMBER "Enables MIPS64 optimizations. ")
+set(HAVE_MMX 0 CACHE NUMBER "Enables MMX optimizations. ")
+set(HAVE_SSE 0 CACHE NUMBER "Enables SSE optimizations.")
+set(HAVE_SSE2 0 CACHE NUMBER "Enables SSE2 optimizations.")
+set(HAVE_SSE3 0 CACHE NUMBER "Enables SSE3 optimizations.")
+set(HAVE_SSSE3 0 CACHE NUMBER "Enables SSSE3 optimizations.")
+set(HAVE_SSE4_1 0 CACHE NUMBER "Enables SSE 4.1 optimizations.")
+set(HAVE_AVX 0 CACHE NUMBER "Enables AVX optimizations.")
+set(HAVE_AVX2 0 CACHE NUMBER "Enables AVX2 optimizations.")
+set(HAVE_AOM_PORTS 0 CACHE NUMBER "Internal flag, deprecated.")
+set(HAVE_FEXCEPT 0 CACHE NUMBER "Internal flag, GNU fenv.h present for target.")
+set(HAVE_PTHREAD_H 0 CACHE NUMBER "Internal flag, target pthread support.")
+set(HAVE_UNISTD_H 0 CACHE NUMBER "Internal flag, unistd.h present for target.")
+set(HAVE_WXWIDGETS 0 CACHE NUMBER "WxWidgets present.")
+set(CONFIG_DEPENDENCY_TRACKING 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_EXTERNAL_BUILD 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_INSTALL_BINS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_INSTALL_LIBS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_INSTALL_SRCS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_DEBUG 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_GPROF 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_GCOV 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_RVCT 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_GCC 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_MSVS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_PIC 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_BIG_ENDIAN 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_CODEC_SRCS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_DEBUG_LIBS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_RUNTIME_CPU_DETECT 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_POSTPROC 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_MULTITHREAD 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_INTERNAL_STATS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_AV1_ENCODER 1 CACHE NUMBER "Enable AV1 encoder.")
+set(CONFIG_AV1_DECODER 1 CACHE NUMBER "Enable AV1 decoder.")
+set(CONFIG_AV1 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_STATIC_MSVCRT 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_SPATIAL_RESAMPLING 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_REALTIME_ONLY 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_ONTHEFLY_BITPACKING 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_ERROR_CONCEALMENT 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_SHARED 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_STATIC 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_SMALL 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_POSTPROC_VISUALIZER 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_OS_SUPPORT 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_UNIT_TESTS 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_WEBM_IO 1 CACHE NUMBER "Enables WebM support.")
+set(CONFIG_LIBYUV 1 CACHE NUMBER "Enables libyuv scaling and conversion support.")
+set(CONFIG_ACCOUNTING 0 CACHE NUMBER "Enables bit accounting.")
+set(CONFIG_INSPECTION 0 CACHE NUMBER "Enables bitstream inspection.")
+set(CONFIG_DECODE_PERF_TESTS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_ENCODE_PERF_TESTS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_COEFFICIENT_RANGE_CHECKING 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_LOWBITDEPTH 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_HIGHBITDEPTH 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_EXPERIMENTAL 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_SIZE_LIMIT 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_COLORSPACE_HEADERS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_FP_MB_STATS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_CDEF 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_VAR_TX 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_RECT_TX 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_RECT_TX_EXT 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_TPL_MV 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_DUAL_FILTER 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_CONVOLVE_ROUND 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_COMPOUND_ROUND 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_EXT_TX 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_DPCM_INTRA 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_TX64X64 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_EXT_INTRA 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_INTRA_INTERP 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_FILTER_INTRA 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_INTRA_EDGE 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_INTRABC 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_EXT_INTER 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_INTERINTRA 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_WEDGE 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_COMPOUND_SEGMENT 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_EXT_REFS 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_SPEED_REFS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_GLOBAL_MOTION 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_NEW_QUANT 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_SUPERTX 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_ANS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_LOOP_RESTORATION 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_EXT_PARTITION 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_EXT_PARTITION_TYPES 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_UNPOISON_PARTITION_CTX 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_EXT_TILE 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_MOTION_VAR 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_NCOBMC 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_WARPED_MOTION 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_Q_ADAPT_PROBS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_BITSTREAM_DEBUG 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_ALT_INTRA 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_PALETTE 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_PALETTE_DELTA_ENCODING 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_RAWBITS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_EC_SMALLMUL 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_PVQ 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_CFL 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_XIPHRC 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_CB4X4 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_CHROMA_2X2 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_CHROMA_SUB8X8 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_FRAME_SIZE 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_DELTA_Q 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_EXT_DELTA_Q 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_ADAPT_SCAN 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_FILTER_7BIT 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_PARALLEL_DEBLOCKING 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_PARALLEL_DEBLOCKING_15TAP 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_LOOPFILTERING_ACROSS_TILES 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_TILE_GROUPS 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_EC_ADAPT 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_TEMPMV_SIGNALING 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_RD_DEBUG 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_REFERENCE_BUFFER 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_COEF_INTERLEAVE 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_ENTROPY_STATS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_MASKED_TX 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_DEPENDENT_HORZTILES 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_DAALA_DIST 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_TRIPRED 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_PALETTE_THROUGHPUT 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_REF_ADAPT 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_LV_MAP 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_TXK_SEL 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_MV_COMPRESS 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_FRAME_SUPERRES 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_NEW_MULTISYMBOL 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_COMPOUND_SINGLEREF 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_AOM_QM 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_ONE_SIDED_COMPOUND 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_EXT_COMP_REFS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_SMOOTH_HV 1 CACHE NUMBER "Internal flag.")
+set(CONFIG_VAR_REFS 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_RECT_INTRA_PRED 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_LGT 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_SBL_SYMBOL 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_NCOBMC_ADAPT_WEIGHT 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_BGSPRITE 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_VAR_TX_NO_TX_MODE 0 CACHE NUMBER "Internal flag.")
+set(CONFIG_ANALYZER 0 CACHE NUMBER "Internal flag.")
--- a/third_party/aom/build/cmake/aom_configure.cmake
+++ b/third_party/aom/build/cmake/aom_configure.cmake
@@ -78,27 +78,39 @@ else ()
   set(AOM_CMAKE_CONFIG "-DAOM_TARGET_CPU=${AOM_TARGET_CPU} ${AOM_CMAKE_CONFIG}")
 endif ()
 set(AOM_CMAKE_CONFIG "-G \\\"${CMAKE_GENERATOR}\\\" ${AOM_CMAKE_CONFIG}")
 string(STRIP "${AOM_CMAKE_CONFIG}" AOM_CMAKE_CONFIG)
 
 message("--- aom_configure: Detected CPU: ${AOM_TARGET_CPU}")
 set(AOM_TARGET_SYSTEM ${CMAKE_SYSTEM_NAME})
 
+if (BUILD_SHARED_LIBS)
+  set(CONFIG_PIC 1)
+  set(CONFIG_SHARED 1)
+  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+  if ("${AOM_TARGET_SYSTEM}" STREQUAL "Linux" AND
+      "${AOM_TARGET_CPU}" MATCHES "^armv7")
+    set(AOM_AS_FLAGS ${AOM_AS_FLAGS} --defsym PIC=1)
+  else ()
+    set(AOM_AS_FLAGS ${AOM_AS_FLAGS} -DPIC)
+  endif ()
+endif ()
+
 if (NOT "${AOM_SUPPORTED_CPU_TARGETS}" MATCHES "${AOM_TARGET_CPU}")
   message(FATAL_ERROR "No RTCD support for ${AOM_TARGET_CPU}. Create it, or "
           "add -DAOM_TARGET_CPU=generic to your cmake command line for a "
           "generic build of libaom and tools.")
 endif ()
 
 if ("${AOM_TARGET_CPU}" STREQUAL "x86" OR "${AOM_TARGET_CPU}" STREQUAL "x86_64")
-  # TODO(tomfinegan): Support nasm at least as well as the existing build
-  # system.
   if (ENABLE_NASM)
     find_program(AS_EXECUTABLE nasm $ENV{NASM_PATH})
+    test_nasm()
     set(AOM_AS_FLAGS ${AOM_AS_FLAGS} -Ox)
   else ()
     find_program(AS_EXECUTABLE yasm $ENV{YASM_PATH})
   endif ()
 
   if (NOT AS_EXECUTABLE)
     message(FATAL_ERROR "Unable to find yasm. To build without optimizations, "
             "add -DAOM_TARGET_CPU=generic to your cmake command line.")
@@ -160,16 +172,17 @@ else ()
   require_c_flag("-std=c99" YES)
   add_compiler_flag_if_supported("-Wall")
   add_compiler_flag_if_supported("-Wdisabled-optimization")
   add_compiler_flag_if_supported("-Wextra")
   add_compiler_flag_if_supported("-Wfloat-conversion")
   add_compiler_flag_if_supported("-Wimplicit-function-declaration")
   add_compiler_flag_if_supported("-Wpointer-arith")
   add_compiler_flag_if_supported("-Wsign-compare")
+  add_compiler_flag_if_supported("-Wstring-conversion")
   add_compiler_flag_if_supported("-Wtype-limits")
   add_compiler_flag_if_supported("-Wuninitialized")
   add_compiler_flag_if_supported("-Wunused")
   add_compiler_flag_if_supported("-Wvla")
   # TODO(jzern): this could be added as a cxx flags for test/*.cc only,
   # avoiding third_party.
   add_c_flag_if_supported("-Wshorten-64-to-32")
 
@@ -219,16 +232,22 @@ if (CONFIG_ANALYZER)
 
   if (NOT CONFIG_INSPECTION)
     set(CONFIG_INSPECTION 1)
     message(WARNING
             "--- Enabled CONFIG_INSPECTION, required for CONFIG_ANALYZER.")
   endif ()
 endif ()
 
+if (CONFIG_VAR_TX_NO_TX_MODE AND NOT CONFIG_VAR_TX)
+   message(WARNING
+     "--- CONFIG_VAR_TX_NO_TX_MODE requires CONFIG_VAR_TX, disabling.")
+   set(CONFIG_VAR_TX_NO_TX_MODE 0)
+endif()
+
 if (NOT MSVC)
   aom_push_var(CMAKE_REQUIRED_LIBRARIES "m")
   aom_check_c_compiles("fenv_check"
                        "#define _GNU_SOURCE
                         #include <fenv.h>
                         void unused(void) {
                           (void)feenableexcept(FE_DIVBYZERO | FE_INVALID);
                         }" HAVE_FEXCEPT)
--- a/third_party/aom/build/cmake/aom_optimization.cmake
+++ b/third_party/aom/build/cmake/aom_optimization.cmake
@@ -6,16 +6,18 @@
 ## was not distributed with this source code in the LICENSE file, you can
 ## obtain it at www.aomedia.org/license/software. If the Alliance for Open
 ## Media Patent License 1.0 was not distributed with this source code in the
 ## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 ##
 if (NOT AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_)
 set(AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_ 1)
 
+include("${AOM_ROOT}/build/cmake/util.cmake")
+
 # Translate $flag to one which MSVC understands, and write the new flag to the
 # variable named by $translated_flag (or unset it, when MSVC needs no flag).
 function (get_msvc_intrinsic_flag flag translated_flag)
   if ("${flag}" STREQUAL "-mavx")
     set(${translated_flag} "/arch:AVX" PARENT_SCOPE)
   elseif ("${flag}" STREQUAL "-mavx2")
     set(${translated_flag} "/arch:AVX2" PARENT_SCOPE)
   else ()
@@ -28,39 +30,40 @@ endfunction ()
 # by the current compiler. $flag is the intrinsics flag required by the current
 # compiler, and is added to the compile flags for all sources in $sources.
 # $opt_name is used to name the target. $target_to_update is made
 # dependent upon the created target.
 #
 # Note: the libaom target is always updated because OBJECT libraries have rules
 # that disallow the direct addition of .o files to them as dependencies. Static
 # libraries do not have this limitation.
-function (add_intrinsics_object_library flag opt_name target_to_update sources)
+function (add_intrinsics_object_library flag opt_name target_to_update sources
+          dependent_target)
   set(target_name ${target_to_update}_${opt_name}_intrinsics)
   add_library(${target_name} OBJECT ${${sources}})
 
   if (MSVC)
     get_msvc_intrinsic_flag(${flag} "flag")
   endif ()
 
   if (flag)
     target_compile_options(${target_name} PUBLIC ${flag})
   endif ()
 
-  target_sources(aom PUBLIC $<TARGET_OBJECTS:${target_name}>)
+  target_sources(${dependent_target} PRIVATE $<TARGET_OBJECTS:${target_name}>)
 
   # Add the new lib target to the global list of aom library targets.
   list(APPEND AOM_LIB_TARGETS ${target_name})
   set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
 endfunction ()
 
 # Adds sources in list named by $sources to $target and adds $flag to the
 # compile flags for each source file.
 function (add_intrinsics_source_to_target flag target sources)
-  target_sources(${target} PUBLIC ${${sources}})
+  target_sources(${target} PRIVATE ${${sources}})
   if (MSVC)
     get_msvc_intrinsic_flag(${flag} "flag")
   endif ()
   if (flag)
     foreach (source ${${sources}})
       set_property(SOURCE ${source} APPEND PROPERTY COMPILE_FLAGS ${flag})
     endforeach ()
   endif ()
@@ -123,32 +126,25 @@ function (add_asm_library lib_name asm_s
                        COMMAND ${AS_EXECUTABLE}
                        ARGS ${AOM_AS_FLAGS}
                             -I${AOM_ROOT}/ -I${AOM_CONFIG_DIR}/
                             -o "${asm_object}" "${asm_source}"
                        DEPENDS "${asm_source}"
                        COMMENT "Building ASM object ${asm_object}"
                        WORKING_DIRECTORY "${AOM_CONFIG_DIR}"
                        VERBATIM)
-    target_sources(${lib_name} PRIVATE "${asm_object}")
+    target_sources(aom PRIVATE "${asm_object}")
   endforeach ()
 
   # The above created a target containing only ASM sources. Cmake needs help
   # here to determine the linker language. Add a dummy C file to force the
   # linker language to C. We don't bother with setting the LINKER_LANGUAGE
   # property on the library target because not all generators obey it (looking
   # at you, xcode generator).
-  set(dummy_c_file "${AOM_CONFIG_DIR}/${lib_name}_dummy.c")
-  file(WRITE "${dummy_c_file}"
-       "// Generated file. DO NOT EDIT!\n"
-       "// ${lib_name} needs C file to force link language, ignore me.\n"
-       "void ${lib_name}_dummy_function(void) {}\n")
-  target_sources(${lib_name} PUBLIC ${dummy_c_file})
-
-  target_link_libraries(${dependent_target} ${AOM_LIB_LINK_TYPE} ${lib_name})
+  add_dummy_source_file_to_target("${lib_name}" "c")
 
   # Add the new lib target to the global list of aom library targets.
   list(APPEND AOM_LIB_TARGETS ${lib_name})
   set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
 endfunction ()
 
 # Converts asm sources in $asm_sources using $AOM_ADS2GAS and calls
 # add_asm_library() to create a library from the converted sources. At
@@ -198,9 +194,48 @@ function (add_gas_asm_library lib_name a
         VERBATIM)
   endforeach ()
 
   # Update the sources list passed in to include the converted asm source files.
   list(APPEND asm_sources ${gas_target_sources})
   set(${asm_sources} ${${asm_sources}} PARENT_SCOPE)
 endfunction ()
 
+# Terminates generation if nasm found in PATH does not meet requirements.
+# Currently checks only for presence of required object formats and support for
+# the -Ox argument (multipass optimization).
+function (test_nasm)
+  execute_process(COMMAND ${AS_EXECUTABLE} -hf
+                  OUTPUT_VARIABLE nasm_helptext)
+
+  if (NOT "${nasm_helptext}" MATCHES "-Ox")
+    message(FATAL_ERROR
+            "Unsupported nasm: multipass optimization not supported.")
+  endif ()
+
+  if ("${AOM_TARGET_CPU}" STREQUAL "x86")
+    if ("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+      if (NOT "${nasm_helptext}" MATCHES "macho32")
+        message(FATAL_ERROR
+                "Unsupported nasm: macho32 object format not supported.")
+      endif ()
+    elseif ("${AOM_TARGET_SYSTEM}" STREQUAL "Linux")
+      if (NOT "${nasm_helptext}" MATCHES "elf32")
+        message(FATAL_ERROR
+                "Unsupported nasm: elf32 object format not supported.")
+      endif ()
+    endif ()
+  else ()
+    if ("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+      if (NOT "${nasm_helptext}" MATCHES "macho64")
+        message(FATAL_ERROR
+                "Unsupported nasm: macho64 object format not supported.")
+      endif ()
+    elseif ("${AOM_TARGET_SYSTEM}" STREQUAL "Linux")
+      if (NOT "${nasm_helptext}" MATCHES "elf64")
+        message(FATAL_ERROR
+                "Unsupported nasm: elf64 object format not supported.")
+      endif ()
+    endif ()
+  endif ()
+endfunction ()
+
 endif ()  # AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_
--- a/third_party/aom/build/cmake/compiler_flags.cmake
+++ b/third_party/aom/build/cmake/compiler_flags.cmake
@@ -215,9 +215,30 @@ function (append_exe_linker_flag flag)
   string(FIND "${CMAKE_EXE_LINKER_FLAGS}" "${flag}" LINKER_FLAG_FOUND)
 
   if (${LINKER_FLAG_FOUND} EQUAL -1)
     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}" CACHE STRING
         "" FORCE)
   endif ()
 endfunction ()
 
+# Adds $flag to the link flags for $target.
+function (append_link_flag_to_target target flags)
+  unset(target_link_flags)
+  get_target_property(target_link_flags ${target} LINK_FLAGS)
+
+  if (target_link_flags)
+    unset(link_flag_found)
+    string(FIND "${target_link_flags}" "${flags}" link_flag_found)
+
+    if (NOT ${link_flag_found} EQUAL -1)
+      return()
+    endif ()
+
+    set(target_link_flags "${target_link_flags} ${flags}")
+  else ()
+    set(target_link_flags "${flags}")
+  endif ()
+
+  set_target_properties(${target} PROPERTIES LINK_FLAGS ${target_link_flags})
+endfunction ()
+
 endif ()  # AOM_BUILD_CMAKE_COMPILER_FLAGS_CMAKE_
new file mode 100644
--- /dev/null
+++ b/third_party/aom/build/cmake/exports.cmake
@@ -0,0 +1,65 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_EXPORTS_CMAKE_)
+set(AOM_BUILD_CMAKE_EXPORTS_CMAKE_ 1)
+
+include("${AOM_ROOT}/build/cmake/exports_sources.cmake")
+
+# Creates the custom target which handles generation of the symbol export lists.
+function (setup_exports_target)
+  if ("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+    set(symbol_file_ext "syms")
+  elseif ("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND MSVC)
+    set(symbol_file_ext "def")
+  else ()
+    set(symbol_file_ext "ver")
+  endif ()
+
+  set(aom_sym_file "${AOM_CONFIG_DIR}/libaom.${symbol_file_ext}")
+
+  add_custom_target(generate_exports
+                    COMMAND ${CMAKE_COMMAND}
+                      -DAOM_ROOT="${AOM_ROOT}"
+                      -DAOM_CONFIG_DIR="${AOM_CONFIG_DIR}"
+                      -DAOM_TARGET_SYSTEM=${AOM_TARGET_SYSTEM}
+                      -DAOM_SYM_FILE="${aom_sym_file}"
+                      -DAOM_MSVC=${MSVC}
+                      -DAOM_XCODE=${XCODE}
+                      -DCONFIG_NAME=$<CONFIG>
+                      -DCONFIG_AV1_DECODER=${CONFIG_AV1_DECODER}
+                      -DCONFIG_AV1_ENCODER=${CONFIG_AV1_ENCODER}
+                      -P "${AOM_ROOT}/build/cmake/generate_exports.cmake"
+                    SOURCES ${AOM_EXPORTS_SOURCES}
+                    DEPENDS ${AOM_EXPORTS_SOURCES})
+
+  # Make libaom depend on the exports file, and set flags to pick it up when
+  # creating the dylib.
+  add_dependencies(aom generate_exports)
+
+  if (APPLE)
+    set_property(TARGET aom APPEND_STRING PROPERTY LINK_FLAGS
+                 "-exported_symbols_list ${aom_sym_file}")
+  elseif (WIN32)
+    message(FATAL_ERROR "Windows DLL builds not supported yet.")
+    if (NOT MSVC)
+      set_property(TARGET aom APPEND_STRING PROPERTY LINK_FLAGS
+                   "-Wl,--version-script ${aom_sym_file}")
+    endif ()
+
+    # TODO(tomfinegan): Sort out the import lib situation and flags for MSVC.
+
+  else ()
+    set_property(TARGET aom APPEND_STRING PROPERTY LINK_FLAGS
+                 "-Wl,--version-script,${aom_sym_file}")
+  endif ()
+endfunction ()
+
+endif ()  # AOM_BUILD_CMAKE_EXPORTS_CMAKE_
new file mode 100644
--- /dev/null
+++ b/third_party/aom/build/cmake/exports_sources.cmake
@@ -0,0 +1,30 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_EXPORTS_SOURCES_CMAKE_)
+set(AOM_BUILD_CMAKE_EXPORTS_SOURCES_CMAKE_ 1)
+
+set(AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_com")
+
+if (CONFIG_AV1_DECODER)
+  set(AOM_EXPORTS_SOURCES
+      ${AOM_EXPORTS_SOURCES}
+      "${AOM_ROOT}/aom/exports_dec"
+      "${AOM_ROOT}/av1/exports_dec")
+endif ()
+
+if (CONFIG_AV1_ENCODER)
+  set(AOM_EXPORTS_SOURCES
+      ${AOM_EXPORTS_SOURCES}
+      "${AOM_ROOT}/aom/exports_enc"
+      "${AOM_ROOT}/av1/exports_enc")
+endif ()
+
+endif ()  # AOM_BUILD_CMAKE_EXPORTS_SOURCES_CMAKE_
new file mode 100644
--- /dev/null
+++ b/third_party/aom/build/cmake/generate_exports.cmake
@@ -0,0 +1,64 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+cmake_minimum_required(VERSION 3.5)
+
+set(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "AOM_TARGET_SYSTEM" "AOM_SYM_FILE"
+    "CONFIG_AV1_DECODER" "CONFIG_AV1_ENCODER")
+
+foreach (arg ${REQUIRED_ARGS})
+  if ("${${arg}}" STREQUAL "")
+    message(FATAL_ERROR "${arg} must not be empty.")
+  endif ()
+endforeach ()
+
+include("${AOM_ROOT}/build/cmake/exports_sources.cmake")
+
+if ("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+  set(symbol_prefix "_")
+elseif ("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS" AND AOM_MSVC)
+  set(symbol_prefix "_")
+  file(WRITE "${AOM_SYM_FILE}"
+       "LIBRARY libaom INITINSTANCE TERMINSTANCE\n"
+       "DATA MULTIPLE NONSHARED\n"
+       "EXPORTS\n")
+else ()
+  set(symbol_suffix ";")
+endif ()
+
+set(aom_sym_file "${AOM_SYM_FILE}")
+
+if ("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+  file(REMOVE "${aom_sym_file}")
+elseif ("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS")
+  file(WRITE "${aom_sym_file}"
+       "LIBRARY libaom INITINSTANCE TERMINSTANCE\n"
+       "DATA MULTIPLE NONSHARED\n"
+       "EXPORTS\n")
+else ()
+  file(WRITE "${aom_sym_file}" "{ global:\n")
+endif ()
+
+foreach (export_file ${AOM_EXPORTS_SOURCES})
+  file(STRINGS "${export_file}" exported_file_data)
+  set(exported_symbols "${exported_symbols} ${exported_file_data};")
+  string(STRIP "${exported_symbols}" exported_symbols)
+endforeach ()
+
+foreach (exported_symbol ${exported_symbols})
+  string(STRIP "${exported_symbol}" exported_symbol)
+  string(REGEX REPLACE "text \|data " "" "exported_symbol" "${exported_symbol}")
+  set(exported_symbol "${symbol_prefix}${exported_symbol}${symbol_suffix}")
+  file(APPEND "${aom_sym_file}" "${exported_symbol}\n")
+endforeach ()
+
+if ("${aom_sym_file}" MATCHES "ver$")
+  file(APPEND "${aom_sym_file}" " };")
+endif ()
--- a/third_party/aom/build/cmake/toolchains/arm-ios-common.cmake
+++ b/third_party/aom/build/cmake/toolchains/arm-ios-common.cmake
@@ -19,13 +19,13 @@ set(CMAKE_CXX_COMPILER clang++)
 set(CMAKE_CXX_COMPILER_ARG1 "-arch ${CMAKE_SYSTEM_PROCESSOR}")
 
 # Assembler sources must be converted for ARM iOS targets.
 set(AOM_ADS2GAS_REQUIRED 1)
 set(AOM_ADS2GAS "${CMAKE_CURRENT_SOURCE_DIR}/build/make/ads2gas_apple.pl")
 set(AOM_GAS_EXT "S")
 
 # No runtime cpu detect for arm*-ios targets.
-set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "")
 
 # TODO(tomfinegan): Handle bit code embedding.
 
 endif ()  # AOM_BUILD_CMAKE_TOOLCHAINS_ARM_IOS_COMMON_CMAKE_
--- a/third_party/aom/build/cmake/toolchains/arm64-linux-gcc.cmake
+++ b/third_party/aom/build/cmake/toolchains/arm64-linux-gcc.cmake
@@ -25,11 +25,11 @@ set(CMAKE_C_COMPILER_ARG1 "-march=armv8-
 set(CMAKE_CXX_COMPILER_ARG1 "-march=armv8-a")
 set(AOM_AS_FLAGS "-march=armv8-a")
 set(CMAKE_SYSTEM_PROCESSOR "arm64")
 
 # No intrinsics flag required for arm64-linux-gcc.
 set(AOM_NEON_INTRIN_FLAG "")
 
 # No runtime cpu detect for arm64-linux-gcc.
-set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "")
 
 endif ()  # AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_
--- a/third_party/aom/build/cmake/toolchains/armv7-ios.cmake
+++ b/third_party/aom/build/cmake/toolchains/armv7-ios.cmake
@@ -20,11 +20,11 @@ set(CMAKE_SYSTEM_PROCESSOR "armv7")
 set(CMAKE_OSX_ARCHITECTURES "armv7")
 
 include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake")
 
 # No intrinsics flag required for armv7s-ios.
 set(AOM_NEON_INTRIN_FLAG "")
 
 # No runtime cpu detect for armv7s-ios.
-set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "")
 
 endif ()  # AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_
--- a/third_party/aom/build/cmake/toolchains/armv7-linux-gcc.cmake
+++ b/third_party/aom/build/cmake/toolchains/armv7-linux-gcc.cmake
@@ -38,11 +38,11 @@ set(CMAKE_SYSTEM_PROCESSOR "armv7")
 set(AOM_NEON_INTRIN_FLAG "")
 
 # Assembler sources must be converted for armv7-linux-gcc targets.
 set(AOM_ADS2GAS_REQUIRED 1)
 set(AOM_ADS2GAS "${CMAKE_CURRENT_SOURCE_DIR}/build/make/ads2gas.pl")
 set(AOM_GAS_EXT "S")
 
 # No runtime cpu detect for armv7-linux-gcc.
-set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "")
 
 endif ()  # AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_
--- a/third_party/aom/build/cmake/toolchains/armv7s-ios.cmake
+++ b/third_party/aom/build/cmake/toolchains/armv7s-ios.cmake
@@ -20,11 +20,11 @@ set(CMAKE_SYSTEM_PROCESSOR "armv7s")
 set(CMAKE_OSX_ARCHITECTURES "armv7s")
 
 include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake")
 
 # No intrinsics flag required for armv7s-ios.
 set(AOM_NEON_INTRIN_FLAG "")
 
 # No runtime cpu detect for armv7s-ios.
-set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "")
 
 endif ()  # AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_
--- a/third_party/aom/build/cmake/toolchains/mips32-linux-gcc.cmake
+++ b/third_party/aom/build/cmake/toolchains/mips32-linux-gcc.cmake
@@ -61,11 +61,11 @@ endif ()
 set(CMAKE_C_COMPILER ${CROSS}gcc)
 set(CMAKE_CXX_COMPILER ${CROSS}g++)
 set(AS_EXECUTABLE ${CROSS}as)
 set(CMAKE_C_COMPILER_ARG1 "-EL ${MIPS_CFLAGS}")
 set(CMAKE_CXX_COMPILER_ARG1 "-EL ${MIPS_CXXFLAGS}")
 set(CMAKE_SYSTEM_PROCESSOR "mips32")
 
 # No runtime cpu detect for mips32-linux-gcc.
-set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "")
 
 endif ()  # AOM_BUILD_CMAKE_TOOLCHAINS_MIPS32_LINUX_GCC_CMAKE_
--- a/third_party/aom/build/cmake/toolchains/mips64-linux-gcc.cmake
+++ b/third_party/aom/build/cmake/toolchains/mips64-linux-gcc.cmake
@@ -38,11 +38,11 @@ endif ()
 set(CMAKE_C_COMPILER ${CROSS}gcc)
 set(CMAKE_CXX_COMPILER ${CROSS}g++)
 set(AS_EXECUTABLE ${CROSS}as)
 set(CMAKE_C_COMPILER_ARG1 "-EL ${MIPS_CFLAGS}")
 set(CMAKE_CXX_COMPILER_ARG1 "-EL ${MIPS_CXXFLAGS}")
 set(CMAKE_SYSTEM_PROCESSOR "mips64")
 
 # No runtime cpu detect for mips64-linux-gcc.
-set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE BOOL "")
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE NUMBER "")
 
 endif ()  # AOM_BUILD_CMAKE_TOOLCHAINS_MIPS64_LINUX_GCC_CMAKE_
--- a/third_party/aom/build/cmake/toolchains/x86-ios-simulator.cmake
+++ b/third_party/aom/build/cmake/toolchains/x86-ios-simulator.cmake
@@ -15,13 +15,13 @@ if (XCODE)
   # TODO(tomfinegan): Handle ios sim builds in Xcode.
   message(FATAL_ERROR "This toolchain does not support Xcode.")
 endif ()
 
 set(CMAKE_SYSTEM_PROCESSOR "i386")
 set(CMAKE_OSX_ARCHITECTURES "i386")
 
 # Avoid noisy PIC/PIE warnings.
-set(CONFIG_PIC 1 CACHE BOOL "")
+set(CONFIG_PIC 1 CACHE NUMBER "")
 
 include("${CMAKE_CURRENT_LIST_DIR}/ios-simulator-common.cmake")
 
 endif ()  # AOM_BUILD_CMAKE_TOOLCHAINS_X86_IOS_SIMULATOR_CMAKE_
--- a/third_party/aom/build/cmake/toolchains/x86-macos.cmake
+++ b/third_party/aom/build/cmake/toolchains/x86-macos.cmake
@@ -10,9 +10,9 @@
 ##
 set(CMAKE_SYSTEM_PROCESSOR "x86")
 set(CMAKE_SYSTEM_NAME "Darwin")
 set(CMAKE_OSX_ARCHITECTURES "i386")
 set(CMAKE_C_COMPILER_ARG1 "-arch i386")
 set(CMAKE_CXX_COMPILER_ARG1 "-arch i386")
 
 # Apple tools always complain in 32 bit mode without PIC.
-set(CONFIG_PIC 1 CACHE STRING "")
+set(CONFIG_PIC 1 CACHE NUMBER "")
new file mode 100644
--- /dev/null
+++ b/third_party/aom/build/cmake/util.cmake
@@ -0,0 +1,30 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+if (NOT AOM_BUILD_CMAKE_UTIL_CMAKE_)
+set(AOM_BUILD_CMAKE_UTIL_CMAKE_ 1)
+
+function (create_dummy_source_file basename extension out_file_path)
+  set(dummy_source_file "${AOM_CONFIG_DIR}/${basename}.${extension}")
+   file(WRITE "${dummy_source_file}"
+       "// Generated file. DO NOT EDIT!\n"
+       "// ${target_name} needs a ${extension} file to force link language, \n"
+       "// or to silence a harmless CMake warning: Ignore me.\n"
+       "void ${target_name}_dummy_function(void) {}\n")
+  set(${out_file_path} ${dummy_source_file} PARENT_SCOPE)
+endfunction ()
+
+function (add_dummy_source_file_to_target target_name extension)
+  create_dummy_source_file("${target_name}" "${extension}" "dummy_source_file")
+  target_sources(${target_name} PRIVATE ${dummy_source_file})
+endfunction ()
+
+endif()  # AOM_BUILD_CMAKE_UTIL_CMAKE_
+
--- a/third_party/aom/build/make/gen_msvs_sln.sh
+++ b/third_party/aom/build/make/gen_msvs_sln.sh
@@ -20,17 +20,17 @@ show_help() {
 Usage: ${self_basename} [options] file1 [file2 ...]
 
 This script generates a Visual Studio solution file from a list of project
 files.
 
 Options:
     --help                      Print this message
     --out=outfile               Redirect output to a file
-    --ver=version               Version (12,14) of visual studio to generate for
+    --ver=version               Version (12,14,15) of visual studio to generate for
     --target=isa-os-cc          Target specifier
 EOF
     exit 1
 }
 
 die() {
     echo "${self_basename}: $@" >&2
     [ -f "${outfile}" ] && rm -f ${outfile}{,.mk}
@@ -210,17 +210,17 @@ for opt in "$@"; do
     --help|-h) show_help
     ;;
     --out=*) outfile="${optval}"; mkoutfile="${optval}".mk
     ;;
     --dep=*) eval "${optval%%:*}_deps=\"\${${optval%%:*}_deps} ${optval##*:}\""
     ;;
     --ver=*) vs_ver="$optval"
              case $optval in
-             12|14)
+             12|14|15)
              ;;
              *) die Unrecognized Visual Studio Version in $opt
              ;;
              esac
     ;;
     --target=*) target="${optval}"
     ;;
     -*) die_unknown $opt
@@ -229,19 +229,22 @@ for opt in "$@"; do
     esac
 done
 outfile=${outfile:-/dev/stdout}
 mkoutfile=${mkoutfile:-/dev/stdout}
 case "${vs_ver:-12}" in
     12) sln_vers="12.00"
        sln_vers_str="Visual Studio 2013"
     ;;
-    14) sln_vers="14.00"
+    14) sln_vers="12.00"
        sln_vers_str="Visual Studio 2015"
     ;;
+    15) sln_vers="12.00"
+       sln_vers_str="Visual Studio 2017"
+    ;;
 esac
 sfx=vcxproj
 
 for f in "${file_list[@]}"; do
     parse_project $f
 done
 cat  >${outfile} <<EOF
 Microsoft Visual Studio Solution File, Format Version $sln_vers${EOLDOS}
--- a/third_party/aom/build/make/gen_msvs_vcxproj.sh
+++ b/third_party/aom/build/make/gen_msvs_vcxproj.sh
@@ -29,17 +29,17 @@ Options:
     --dll                       Generate a project for creating a dll
     --static-crt                Use the static C runtime (/MT)
     --enable-werror             Treat warnings as errors (/WX)
     --target=isa-os-cc          Target specifier (required)
     --out=filename              Write output to a file [stdout]
     --name=project_name         Name of the project (required)
     --proj-guid=GUID            GUID to use for the project
     --module-def=filename       File containing export definitions (for DLLs)
-    --ver=version               Version (12,14) of visual studio to generate for
+    --ver=version               Version (12,14,15) of visual studio to generate for
     --src-path-bare=dir         Path to root of source tree
     -Ipath/to/include           Additional include directories
     -DFLAG[=value]              Preprocessor macros to define
     -Lpath/to/lib               Additional library search paths
     -llibname                   Library to link against
 EOF
     exit 1
 }
@@ -163,17 +163,17 @@ for opt in "$@"; do
         ;;
         --static-crt) use_static_runtime=true
         ;;
         --enable-werror) werror=true
         ;;
         --ver=*)
             vs_ver="$optval"
             case "$optval" in
-                12|14)
+                12|14|15)
                 ;;
                 *) die Unrecognized Visual Studio Version in $opt
                 ;;
             esac
         ;;
         -I*)
             opt=${opt##-I}
             opt=$(fix_path "$opt")
@@ -213,17 +213,17 @@ done
 # Make one call to fix_path for file_list to improve performance.
 fix_file_list file_list
 
 outfile=${outfile:-/dev/stdout}
 guid=${guid:-`generate_uuid`}
 asm_use_custom_step=false
 uses_asm=${uses_asm:-false}
 case "${vs_ver:-12}" in
-    12|14)
+    12|14|15)
        asm_use_custom_step=$uses_asm
     ;;
 esac
 
 [ -n "$name" ] || die "Project name (--name) must be specified!"
 [ -n "$target" ] || die "Target (--target) must be specified!"
 
 if ${use_static_runtime:-false}; then
@@ -328,16 +328,19 @@ generate_vcxproj() {
                 # Setting a PlatformToolset indicating windows phone isn't
                 # enough to build code for arm with MSVC 2013, one strictly
                 # has to enable AppContainerApplication as well.
                 tag_content PlatformToolset v120
             fi
             if [ "$vs_ver" = "14" ]; then
                 tag_content PlatformToolset v140
             fi
+            if [ "$vs_ver" = "15" ]; then
+                tag_content PlatformToolset v141
+            fi
             tag_content CharacterSet Unicode
             if [ "$config" = "Release" ]; then
                 tag_content WholeProgramOptimization true
             fi
             close_tag PropertyGroup
         done
     done
 
--- a/third_party/aom/configure
+++ b/third_party/aom/configure
@@ -20,16 +20,17 @@ show_help(){
     show_help_pre
     cat << EOF
 Advanced options:
   ${toggle_libs}                  libraries
   ${toggle_examples}              examples
   ${toggle_analyzer}              analyzer
   ${toggle_docs}                  documentation
   ${toggle_unit_tests}            unit tests
+  ${toggle_tools}                 tools
   ${toggle_decode_perf_tests}     build decoder perf tests with unit tests
   ${toggle_encode_perf_tests}     build encoder perf tests with unit tests
   --cpu=CPU                       tune for the specified CPU (ARM: cortex-a8, X86: sse3)
   --libc=PATH                     path to alternate libc
   --size-limit=WxH                max size to allow in the decoder
   --as={yasm|nasm|auto}           use specified assembler [auto, yasm preferred]
   --sdk-path=PATH                 path to root of sdk (android builds only)
   ${toggle_codec_srcs}            in/exclude codec library source code
@@ -96,16 +97,17 @@ all_platforms="${all_platforms} arm64-da
 all_platforms="${all_platforms} arm64-linux-gcc"
 all_platforms="${all_platforms} armv7-android-gcc"   #neon Cortex-A8
 all_platforms="${all_platforms} armv7-darwin-gcc"    #neon Cortex-A8
 all_platforms="${all_platforms} armv7-linux-rvct"    #neon Cortex-A8
 all_platforms="${all_platforms} armv7-linux-gcc"     #neon Cortex-A8
 all_platforms="${all_platforms} armv7-none-rvct"     #neon Cortex-A8
 all_platforms="${all_platforms} armv7-win32-vs12"
 all_platforms="${all_platforms} armv7-win32-vs14"
+all_platforms="${all_platforms} armv7-win32-vs15"
 all_platforms="${all_platforms} armv7s-darwin-gcc"
 all_platforms="${all_platforms} armv8-linux-gcc"
 all_platforms="${all_platforms} mips32-linux-gcc"
 all_platforms="${all_platforms} mips64-linux-gcc"
 all_platforms="${all_platforms} sparc-solaris-gcc"
 all_platforms="${all_platforms} x86-android-gcc"
 all_platforms="${all_platforms} x86-darwin8-gcc"
 all_platforms="${all_platforms} x86-darwin8-icc"
@@ -121,37 +123,39 @@ all_platforms="${all_platforms} x86-darw
 all_platforms="${all_platforms} x86-iphonesimulator-gcc"
 all_platforms="${all_platforms} x86-linux-gcc"
 all_platforms="${all_platforms} x86-linux-icc"
 all_platforms="${all_platforms} x86-os2-gcc"
 all_platforms="${all_platforms} x86-solaris-gcc"
 all_platforms="${all_platforms} x86-win32-gcc"
 all_platforms="${all_platforms} x86-win32-vs12"
 all_platforms="${all_platforms} x86-win32-vs14"
+all_platforms="${all_platforms} x86-win32-vs15"
 all_platforms="${all_platforms} x86_64-android-gcc"
 all_platforms="${all_platforms} x86_64-darwin9-gcc"
 all_platforms="${all_platforms} x86_64-darwin10-gcc"
 all_platforms="${all_platforms} x86_64-darwin11-gcc"
 all_platforms="${all_platforms} x86_64-darwin12-gcc"
 all_platforms="${all_platforms} x86_64-darwin13-gcc"
 all_platforms="${all_platforms} x86_64-darwin14-gcc"
 all_platforms="${all_platforms} x86_64-darwin15-gcc"
 all_platforms="${all_platforms} x86_64-darwin16-gcc"
 all_platforms="${all_platforms} x86_64-iphonesimulator-gcc"
 all_platforms="${all_platforms} x86_64-linux-gcc"
 all_platforms="${all_platforms} x86_64-linux-icc"
 all_platforms="${all_platforms} x86_64-solaris-gcc"
 all_platforms="${all_platforms} x86_64-win64-gcc"
 all_platforms="${all_platforms} x86_64-win64-vs12"
 all_platforms="${all_platforms} x86_64-win64-vs14"
+all_platforms="${all_platforms} x86_64-win64-vs15"
 all_platforms="${all_platforms} generic-gnu"
 
 # all_targets is a list of all targets that can be configured
 # note that these should be in dependency order for now.
-all_targets="libs examples docs"
+all_targets="libs examples docs tools"
 
 # all targets available are enabled, by default.
 for t in ${all_targets}; do
     [ -f "${source_path}/${t}.mk" ] && enable_feature ${t}
 done
 
 if ! perl --version >/dev/null; then
     die "Perl is required to build"
@@ -257,16 +261,18 @@ EXPERIMENT_LIST="
     filter_intra
     intra_edge
     intrabc
     ext_inter
     interintra
     wedge
     compound_segment
     ext_refs
+    speed_refs
+    gf_groups
     global_motion
     new_quant
     supertx
     ans
     loop_restoration
     ext_partition
     ext_partition_types
     unpoison_partition_ctx
@@ -311,18 +317,25 @@ EXPERIMENT_LIST="
     lv_map
     txk_sel
     mv_compress
     frame_superres
     new_multisymbol
     compound_singleref
     aom_qm
     one_sided_compound
+    ext_comp_refs
     smooth_hv
     var_refs
+    rect_intra_pred
+    lgt
+    sbl_symbol
+    ncobmc_adapt_weight
+    bgsprite
+    var_tx_no_tx_mode
 "
 CONFIG_LIST="
     dependency_tracking
     external_build
     install_docs
     install_bins
     install_libs
     install_srcs
@@ -361,16 +374,17 @@ CONFIG_LIST="
     inspection
     decode_perf_tests
     encode_perf_tests
     coefficient_range_checking
     lowbitdepth
     highbitdepth
     experimental
     size_limit
+    colorspace_headers
     ${EXPERIMENT_LIST}
     analyzer
 "
 CMDLINE_SELECT="
     dependency_tracking
     external_build
     extra_warnings
     werror
@@ -386,16 +400,17 @@ CMDLINE_SELECT="
     ccache
     runtime_cpu_detect
     thumb
 
     libs
     examples
     analyzer
     docs
+    tools
     libc
     as
     size_limit
     codec_srcs
     debug_libs
 
     postproc
     multithread
@@ -418,16 +433,18 @@ CMDLINE_SELECT="
     inspection
     decode_perf_tests
     encode_perf_tests
     coefficient_range_checking
     lowbitdepth
     aom_highbitdepth
     highbitdepth
     experimental
+    colorspace_headers
+    tile_groups
 "
 
 process_cmdline() {
     for opt do
         optval="${opt#*=}"
         case "$opt" in
         --disable-codecs)
           for c in ${CODEC_FAMILIES}; do disable_codec $c; done
@@ -471,35 +488,39 @@ post_process_cmdline() {
     # Enable adopted experiments by default
     soft_enable cb4x4
     soft_enable chroma_sub8x8
     soft_enable filter_7bit
     soft_enable reference_buffer
     soft_enable delta_q
     soft_enable tile_groups
     soft_enable rect_tx
-    soft_enable global_motion
-    soft_enable ext_tx
+    #soft_enable global_motion
+    #soft_enable ext_tx
     soft_enable cdef
     soft_enable ec_adapt
     soft_enable ext_intra
     soft_enable mv_compress
-    soft_enable ext_refs
-    soft_enable dual_filter
+    #soft_enable ext_refs
+    #soft_enable dual_filter
     soft_enable motion_var
-    soft_enable warped_motion
+    #soft_enable warped_motion
     soft_enable ext_delta_q
     soft_enable loopfiltering_across_tiles
     soft_enable ec_smallmul
     soft_enable var_tx
+    #soft_enable ext_inter
+    #soft_enable wedge
+    #soft_enable compound_segment
+    #soft_enable interintra
     soft_enable one_sided_compound
-    soft_enable ext_inter
-    soft_enable wedge
-    soft_enable compound_segment
-    soft_enable interintra
+    soft_enable smooth_hv
+
+    # enable perceptual rate control
+    soft_enable xiphrc
 
     # Backwards/jenkins compatibility with --enable-aom-highbitdepth
     enabled aom_highbitdepth && enable_feature highbitdepth
 
     # Enable low-bitdepth pixel pipeline by default
     soft_enable lowbitdepth
 
     soft_enable palette
@@ -518,16 +539,21 @@ post_process_cmdline() {
     enabled ext_delta_q && soft_enable delta_q
     enabled txk_sel && soft_enable lv_map
     enabled compound_round && soft_enable convolve_round
     enabled smooth_hv && soft_enable alt_intra
     enabled intra_edge && enable_feature ext_intra
     enabled chroma_2x2 && disable_feature chroma_sub8x8
     enabled dpcm_intra && enable_feature ext_tx
     enabled chroma_sub8x8 && enable_feature cb4x4
+    enabled compound_singleref && enable_feature ext_inter
+    enabled new_multisymbol && enable_feature ec_adapt
+    enabled warped_motion && disable_feature ncobmc_adapt_weight
+    enabled ncobmc_adapt_weight && enable_feature motion_var
+    enabled bgsprite && enable_feature global_motion
 
     if ! enabled delta_q && enabled ext_delta_q; then
       log_echo "ext_delta_q requires delta_q, so disabling ext_delta_q"
       disable_feature ext_delta_q
     fi
     if enabled rawbits && enabled ans; then
       log_echo "rawbits requires not ans, so disabling rawbits"
       disable_feature rawbits
@@ -536,16 +562,20 @@ post_process_cmdline() {
       log_echo "ec_smallmul requires not ans, so disabling ec_smallmul"
       disable_feature ec_smallmul
     fi
     if enabled ext_tile; then
       log_echo "ext_tile not compatible with reference_buffer, so"
       log_echo "disabling reference_buffer"
       disable_feature reference_buffer
     fi
+    if enabled var_tx_no_tx_mode && ! enabled var_tx; then
+      log_echo "var_tx_no_tx_mode requires var_tx, so disabling var_tx_no_tx_mode"
+      disable_feature var_tx_no_tx_mode
+    fi
     if enabled ext_tile; then
       log_echo "ext_tile not compatible with tile_groups, so"
       log_echo "disabling tile_groups"
       disable_feature tile_groups
     fi
     # Enable accounting and inspection when building the analyzer
     if enabled analyzer; then
       soft_enable accounting
@@ -615,17 +645,17 @@ VERSION_PATCH=${VERSION_PATCH}
 
 CONFIGURE_ARGS=${CONFIGURE_ARGS}
 EOF
     enabled child || echo "CONFIGURE_ARGS?=${CONFIGURE_ARGS}" >> config.mk
 
     #
     # Write makefiles for all enabled targets
     #
-    for tgt in libs examples docs solution; do
+    for tgt in libs examples docs tools solution; do
         tgt_fn="$tgt-$toolchain.mk"
 
         if enabled $tgt; then
             echo "Creating makefiles for ${toolchain} ${tgt}"
             write_common_target_config_mk $tgt_fn ${BUILD_PFX}aom_config.h
             #write_${tgt}_config
         fi
     done
@@ -719,16 +749,17 @@ process_toolchain() {
         check_add_cflags -Wfloat-conversion
         check_add_cflags -Wpointer-arith
         check_add_cflags -Wtype-limits
         check_add_cflags -Wvla
         check_add_cflags -Wimplicit-function-declaration
         check_add_cflags -Wuninitialized
         check_add_cflags -Wunused
         check_add_cflags -Wsign-compare
+        check_add_cflags -Wstring-conversion
         check_add_cflags -Wlogical-op
         check_add_cflags -Wstack-usage=320000
         # Enabling the following warning (in combination with -Wunused above)
         # for C++ generates errors in third_party code including googletest and
         # libyuv. So enable it only for C code.
         check_cflags "-Wextra" && add_cflags_only "-Wextra"
         # Enabling the following warning for C++ generates some useless warnings
         # about some function parameters shadowing class member function names.
--- a/third_party/aom/docs.cmake
+++ b/third_party/aom/docs.cmake
@@ -49,17 +49,17 @@ if (CONFIG_AV1_DECODER)
       ${AOM_DOXYGEN_SOURCES}
       "${AOM_ROOT}/aom/aom_decoder.h"
       "${AOM_ROOT}/aom/aomdx.h"
       "${AOM_ROOT}/usage_dx.dox")
 
   if (CONFIG_ANALYZER)
     set(AOM_DOXYGEN_EXAMPLE_SOURCES
         ${AOM_DOXYGEN_EXAMPLE_SOURCES}
-        "${AOM_ROOT}examples/analyzer.cc")
+        "${AOM_ROOT}/examples/analyzer.cc")
 
     set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
         ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
         "Bitstream analyzer.")
   endif ()
 
   if (CONFIG_INSPECTION)
      set(AOM_DOXYGEN_EXAMPLE_SOURCES
@@ -197,32 +197,33 @@ reference. The following utilities are i
   endforeach ()
   file(APPEND "${samples_dox}" "*/")
 
   # Add $samples_dox to the doxygen inputs.
   get_filename_component(samples_dox ${samples_dox} NAME)
   set(AOM_DOXYGEN_SOURCES ${AOM_DOXYGEN_SOURCES} ${samples_dox})
 
   # Generate libaom's doxyfile.
-  file(COPY "${AOM_ROOT}/${AOM_DOXYGEN_CONFIG_TEMPLATE}"
-       DESTINATION "${AOM_CONFIG_DIR}")
-  file(RENAME
-       "${AOM_CONFIG_DIR}/${AOM_DOXYGEN_CONFIG_TEMPLATE}" "${AOM_DOXYFILE}")
+  file(WRITE "${AOM_DOXYFILE}" "##\n## GENERATED FILE. DO NOT EDIT\n##\n")
+  file(READ "${AOM_ROOT}/${AOM_DOXYGEN_CONFIG_TEMPLATE}" doxygen_template_data)
+  file(APPEND "${AOM_DOXYFILE}" ${doxygen_template_data})
   file(APPEND "${AOM_DOXYFILE}"
        "EXAMPLE_PATH += ${AOM_ROOT} ${AOM_ROOT}/examples\n")
   file(APPEND
        "${AOM_DOXYFILE}" "INCLUDE_PATH += ${AOM_CONFIG_DIR} ${AOM_ROOT}\n")
   file(APPEND "${AOM_DOXYFILE}"
        "STRIP_FROM_PATH += ${AOM_ROOT} ${AOM_CONFIG_DIR}\n")
   write_cmake_list_to_doxygen_config_var("INPUT" "AOM_DOXYGEN_SOURCES")
   write_cmake_list_to_doxygen_config_var("ENABLED_SECTIONS"
                                          "AOM_DOXYGEN_SECTIONS")
 
   # Add the doxygen generation rule.
   add_custom_target(docs ALL
                     COMMAND "${DOXYGEN_EXECUTABLE}" "${AOM_DOXYFILE}"
                     DEPENDS "${AOM_DOXYFILE}" ${AOM_DOXYGEN_SOURCES}
                              ${AOM_DOXYGEN_EXAMPLE_SOURCES}
+                             "${AOM_DOXYGEN_CONFIG_TEMPLATE}"
                     SOURCES "${AOM_DOXYFILE}" ${AOM_DOXYGEN_SOURCES}
-                             ${AOM_DOXYGEN_EXAMPLE_SOURCES})
+                             ${AOM_DOXYGEN_EXAMPLE_SOURCES}
+                             "${AOM_DOXYGEN_CONFIG_TEMPLATE}")
 endfunction ()
 
 endif ()  # AOM_DOCS_CMAKE_
--- a/third_party/aom/examples/analyzer.cc
+++ b/third_party/aom/examples/analyzer.cc
@@ -228,46 +228,59 @@ void AnalyzerPanel::setShowPlane(bool sh
     plane_mask |= mask;
   } else {
     plane_mask &= ~mask;
   }
 }
 
 void AnalyzerPanel::render() {
   aom_image_t *img = decoder.image;
-  int y_stride = img->stride[0];
-  int cb_stride = img->stride[1];
-  int cr_stride = img->stride[2];
+  const int hbd = !!(img->fmt & AOM_IMG_FMT_HIGHBITDEPTH);
+  int y_stride = img->stride[0] >> hbd;
+  int cb_stride = img->stride[1] >> hbd;
+  int cr_stride = img->stride[2] >> hbd;
   int p_stride = 3 * getDisplayWidth();
   unsigned char *y_row = img->planes[0];
   unsigned char *cb_row = img->planes[1];
   unsigned char *cr_row = img->planes[2];
+  uint16_t *y_row16 = reinterpret_cast<uint16_t *>(y_row);
+  uint16_t *cb_row16 = reinterpret_cast<uint16_t *>(cb_row);
+  uint16_t *cr_row16 = reinterpret_cast<uint16_t *>(cr_row);
   unsigned char *p_row = pixels;
   int y_width_padding = decoder.getWidthPadding();
   int cb_width_padding = y_width_padding >> 1;
   int cr_width_padding = y_width_padding >> 1;
   int y_height_padding = decoder.getHeightPadding();
   int cb_height_padding = y_height_padding >> 1;
   int cr_height_padding = y_height_padding >> 1;
   for (int j = 0; j < decoder.getHeight(); j++) {
     unsigned char *y = y_row - y_stride * y_height_padding;
     unsigned char *cb = cb_row - cb_stride * cb_height_padding;
     unsigned char *cr = cr_row - cr_stride * cr_height_padding;
+    uint16_t *y16 = y_row16 - y_stride * y_height_padding;
+    uint16_t *cb16 = cb_row16 - cb_stride * cb_height_padding;
+    uint16_t *cr16 = cr_row16 - cr_stride * cr_height_padding;
     unsigned char *p = p_row;
     for (int i = 0; i < decoder.getWidth(); i++) {
       int64_t yval;
       int64_t cbval;
       int64_t crval;
       int pmask;
       unsigned rval;
       unsigned gval;
       unsigned bval;
-      yval = *(y - y_width_padding);
-      cbval = *(cb - cb_width_padding);
-      crval = *(cr - cr_width_padding);
+      if (hbd) {
+        yval = *(y16 - y_width_padding);
+        cbval = *(cb16 - cb_width_padding);
+        crval = *(cr16 - cr_width_padding);
+      } else {
+        yval = *(y - y_width_padding);
+        cbval = *(cb - cb_width_padding);
+        crval = *(cr - cr_width_padding);
+      }
       pmask = plane_mask;
       if (pmask & OD_LUMA_MASK) {
         yval -= 16;
       } else {
         yval = 128;
       }
       cbval = ((pmask & OD_CB_MASK) >> 1) * (cbval - 128);
       crval = ((pmask & OD_CR_MASK) >> 2) * (crval - 128);
@@ -291,26 +304,39 @@ void AnalyzerPanel::render() {
         for (int u = 0; u < zoom; u++) {
           *(px + 0) = (unsigned char)(rval >> 8);
           *(px + 1) = (unsigned char)(gval >> 8);
           *(px + 2) = (unsigned char)(bval >> 8);
           px += 3;
         }
         px_row += p_stride;
       }
-      int dc = ((y - y_row) & 1) | (1 - img->x_chroma_shift);
-      y++;
-      cb += dc;
-      cr += dc;
+      if (hbd) {
+        int dc = ((y16 - y_row16) & 1) | (1 - img->x_chroma_shift);
+        y16++;
+        cb16 += dc;
+        cr16 += dc;
+      } else {
+        int dc = ((y - y_row) & 1) | (1 - img->x_chroma_shift);
+        y++;
+        cb += dc;
+        cr += dc;
+      }
       p += zoom * 3;
     }
     int dc = -((j & 1) | (1 - img->y_chroma_shift));
-    y_row += y_stride;
-    cb_row += dc & cb_stride;
-    cr_row += dc & cr_stride;
+    if (hbd) {
+      y_row16 += y_stride;
+      cb_row16 += dc & cb_stride;
+      cr_row16 += dc & cr_stride;
+    } else {
+      y_row += y_stride;
+      cb_row += dc & cb_stride;
+      cr_row += dc & cr_stride;
+    }
     p_row += zoom * p_stride;
   }
 }
 
 void AnalyzerPanel::computeBitsPerPixel() {
   Accounting *acct;
   double bpp_total;
   int totals_q3[MAX_SYMBOL_TYPES] = { 0 };
--- a/third_party/aom/examples/inspect.c
+++ b/third_party/aom/examples/inspect.c
@@ -133,17 +133,17 @@ const map_entry refs_map[] = { ENUM(INTR
                                ENUM(GOLDEN_FRAME), ENUM(BWDREF_FRAME),
                                ENUM(ALTREF_FRAME),
 #else
                                ENUM(GOLDEN_FRAME), ENUM(ALTREF_FRAME),
 #endif
                                LAST_ENUM };
 
 const map_entry block_size_map[] = {
-#if CONFIG_CB4X4
+#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
   ENUM(BLOCK_2X2),    ENUM(BLOCK_2X4),    ENUM(BLOCK_4X2),
 #endif
   ENUM(BLOCK_4X4),    ENUM(BLOCK_4X8),    ENUM(BLOCK_8X4),
   ENUM(BLOCK_8X8),    ENUM(BLOCK_8X16),   ENUM(BLOCK_16X8),
   ENUM(BLOCK_16X16),  ENUM(BLOCK_16X32),  ENUM(BLOCK_32X16),
   ENUM(BLOCK_32X32),  ENUM(BLOCK_32X64),  ENUM(BLOCK_64X32),
   ENUM(BLOCK_64X64),
 #if CONFIG_EXT_PARTITION
@@ -249,16 +249,28 @@ void on_frame_decoded_dump(char *json) {
 int put_str(char *buffer, const char *str) {
   int i;
   for (i = 0; str[i] != '\0'; i++) {
     buffer[i] = str[i];
   }
   return i;
 }
 
+int put_str_with_escape(char *buffer, const char *str) {
+  int i;
+  int j = 0;
+  for (i = 0; str[i] != '\0'; i++) {
+    if (str[i] == '"') {
+      buffer[j++] = '\\';
+    }
+    buffer[j++] = str[i];
+  }
+  return j;
+}
+
 int put_num(char *buffer, char prefix, int num, char suffix) {
   int i = 0;
   char *buf = buffer;
   int is_neg = 0;
   if (prefix) {
     buf[i++] = prefix;
   }
   if (num == 0) {
@@ -536,18 +548,19 @@ void inspect(void *pbi, void *data) {
                   frame_data.base_qindex);
   buf += snprintf(buf, MAX_BUFFER, "  \"tileCols\": %d,\n",
                   frame_data.tile_mi_cols);
   buf += snprintf(buf, MAX_BUFFER, "  \"tileRows\": %d,\n",
                   frame_data.tile_mi_rows);
   buf += put_str(buf, "  \"config\": {");
   buf += put_map(buf, config_map);
   buf += put_str(buf, "},\n");
-  buf += snprintf(buf, MAX_BUFFER, "  \"configString\": \"%s\"\n",
-                  aom_codec_build_config());
+  buf += put_str(buf, "  \"configString\": \"");
+  buf += put_str_with_escape(buf, aom_codec_build_config());
+  buf += put_str(buf, "\"\n");
   decoded_frame_count++;
   buf += put_str(buf, "},\n");
   *(buf++) = 0;
   on_frame_decoded_dump(buffer);
   aom_free(buffer);
 }
 
 void ifd_init_cb() {
@@ -598,16 +611,22 @@ int read_frame() {
 
 EMSCRIPTEN_KEEPALIVE
 const char *get_aom_codec_build_config() { return aom_codec_build_config(); }
 
 EMSCRIPTEN_KEEPALIVE
 int get_bit_depth() { return img->bit_depth; }
 
 EMSCRIPTEN_KEEPALIVE
+int get_bits_per_sample() { return img->bps; }
+
+EMSCRIPTEN_KEEPALIVE
+int get_image_format() { return img->fmt; }
+
+EMSCRIPTEN_KEEPALIVE
 unsigned char *get_plane(int plane) { return img->planes[plane]; }
 
 EMSCRIPTEN_KEEPALIVE
 int get_plane_stride(int plane) { return img->stride[plane]; }
 
 EMSCRIPTEN_KEEPALIVE
 int get_plane_width(int plane) { return aom_img_plane_width(img, plane); }
 
--- a/third_party/aom/test/active_map_refresh_test.cc
+++ b/third_party/aom/test/active_map_refresh_test.cc
@@ -54,18 +54,18 @@ void GenerateMap(int mb_rows, int mb_col
       map[mb_r * mb_cols + mb_c] = CheckMb(current, previous, mb_r, mb_c);
     }
   }
 }
 
 const int kAqModeCyclicRefresh = 3;
 
 class ActiveMapRefreshTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> {
+    : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
+      public ::libaom_test::EncoderTest {
  protected:
   ActiveMapRefreshTest() : EncoderTest(GET_PARAM(0)) {}
   virtual ~ActiveMapRefreshTest() {}
 
   virtual void SetUp() {
     InitializeConfig();
     SetMode(GET_PARAM(1));
     cpu_used_ = GET_PARAM(2);
@@ -103,17 +103,17 @@ class ActiveMapRefreshTest
   int cpu_used_;
   ::libaom_test::Y4mVideoSource *y4m_holder_;
 };
 
 TEST_P(ActiveMapRefreshTest, Test) {
   cfg_.g_lag_in_frames = 0;
   cfg_.g_profile = 1;
   cfg_.rc_target_bitrate = 600;
-  cfg_.rc_resize_allowed = 0;
+  cfg_.rc_resize_mode = 0;
   cfg_.rc_min_quantizer = 8;
   cfg_.rc_max_quantizer = 30;
   cfg_.g_pass = AOM_RC_ONE_PASS;
   cfg_.rc_end_usage = AOM_CBR;
   cfg_.kf_max_dist = 90000;
 
   ::libaom_test::Y4mVideoSource video("desktop_credits.y4m", 0, 10);
   ::libaom_test::Y4mVideoSource video_holder("desktop_credits.y4m", 0, 10);
--- a/third_party/aom/test/active_map_test.cc
+++ b/third_party/aom/test/active_map_test.cc
@@ -15,18 +15,18 @@
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
 #include "test/util.h"
 
 namespace {
 
 class ActiveMapTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> {
+    : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
+      public ::libaom_test::EncoderTest {
  protected:
   static const int kWidth = 208;
   static const int kHeight = 144;
 
   ActiveMapTest() : EncoderTest(GET_PARAM(0)) {}
   virtual ~ActiveMapTest() {}
 
   virtual void SetUp() {
@@ -68,17 +68,17 @@ class ActiveMapTest
       encoder->Control(AOME_SET_ACTIVEMAP, &map);
     }
   }
 
   void DoTest() {
     // Validate that this non multiple of 64 wide clip encodes
     cfg_.g_lag_in_frames = 0;
     cfg_.rc_target_bitrate = 400;
-    cfg_.rc_resize_allowed = 0;
+    cfg_.rc_resize_mode = 0;
     cfg_.g_pass = AOM_RC_ONE_PASS;
     cfg_.rc_end_usage = AOM_CBR;
     cfg_.kf_max_dist = 90000;
     ::libaom_test::I420VideoSource video("hantro_odd.yuv", kWidth, kHeight, 30,
                                          1, 0, 20);
 
     ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
   }
--- a/third_party/aom/test/altref_test.cc
+++ b/third_party/aom/test/altref_test.cc
@@ -12,18 +12,18 @@
 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
 #include "test/util.h"
 namespace {
 
 class AltRefForcedKeyTestLarge
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> {
+    : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
+      public ::libaom_test::EncoderTest {
  protected:
   AltRefForcedKeyTestLarge()
       : EncoderTest(GET_PARAM(0)), encoding_mode_(GET_PARAM(1)),
         cpu_used_(GET_PARAM(2)), forced_kf_frame_num_(1), frame_num_(0) {}
   virtual ~AltRefForcedKeyTestLarge() {}
 
   virtual void SetUp() {
     InitializeConfig();
--- a/third_party/aom/test/ans_codec_test.cc
+++ b/third_party/aom/test/ans_codec_test.cc
@@ -23,18 +23,18 @@
 // single iteration and don't try to check the window size if we are unwindowed.
 // [1] https://github.com/google/googletest/issues/356
 
 namespace {
 
 const char kTestVideoName[] = "niklas_1280_720_30.y4m";
 const int kTestVideoFrames = 10;
 
-class AnsCodecTest : public ::libaom_test::EncoderTest,
-                     public ::libaom_test::CodecTestWithParam<int> {
+class AnsCodecTest : public ::libaom_test::CodecTestWithParam<int>,
+                     public ::libaom_test::EncoderTest {
  protected:
   AnsCodecTest()
       : EncoderTest(GET_PARAM(0)), ans_window_size_log2_(GET_PARAM(1)) {}
 
   virtual ~AnsCodecTest() {}
 
   virtual void SetUp() {
     InitializeConfig();
--- a/third_party/aom/test/aq_segment_test.cc
+++ b/third_party/aom/test/aq_segment_test.cc
@@ -14,18 +14,18 @@
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
 #include "test/util.h"
 
 namespace {
 
 class AqSegmentTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> {
+    : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
+      public ::libaom_test::EncoderTest {
  protected:
   AqSegmentTest() : EncoderTest(GET_PARAM(0)) {}
   virtual ~AqSegmentTest() {}
 
   virtual void SetUp() {
     InitializeConfig();
     SetMode(GET_PARAM(1));
     set_cpu_used_ = GET_PARAM(2);
--- a/third_party/aom/test/arf_freq_test.cc
+++ b/third_party/aom/test/arf_freq_test.cc
@@ -71,19 +71,19 @@ int is_extension_y4m(const char *filenam
   const char *dot = strrchr(filename, '.');
   if (!dot || dot == filename)
     return 0;
   else
     return !strcmp(dot, ".y4m");
 }
 
 class ArfFreqTestLarge
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith3Params<TestVideoParam,
-                                                 TestEncodeParam, int> {
+    : public ::libaom_test::CodecTestWith3Params<TestVideoParam,
+                                                 TestEncodeParam, int>,
+      public ::libaom_test::EncoderTest {
  protected:
   ArfFreqTestLarge()
       : EncoderTest(GET_PARAM(0)), test_video_param_(GET_PARAM(1)),
         test_encode_param_(GET_PARAM(2)), min_arf_requested_(GET_PARAM(3)) {}
 
   virtual ~ArfFreqTestLarge() {}
 
   virtual void SetUp() {
@@ -94,17 +94,16 @@ class ArfFreqTestLarge
       cfg_.rc_end_usage = AOM_VBR;
     } else {
       cfg_.g_lag_in_frames = 0;
       cfg_.rc_end_usage = AOM_CBR;
       cfg_.rc_buf_sz = 1000;
       cfg_.rc_buf_initial_sz = 500;
       cfg_.rc_buf_optimal_sz = 600;
     }
-    dec_cfg_.threads = 4;
   }
 
   virtual void BeginPassHook(unsigned int) {
     min_run_ = ARF_NOT_SEEN;
     run_of_visible_frames_ = 0;
   }
 
   int GetNumFramesInPkt(const aom_codec_cx_pkt_t *pkt) {
new file mode 100644
--- /dev/null
+++ b/third_party/aom/test/av1_convolve_2d_test.cc
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
+#include "test/av1_convolve_2d_test_util.h"
+
+using std::tr1::tuple;
+using std::tr1::make_tuple;
+using libaom_test::ACMRandom;
+using libaom_test::AV1Convolve2D::AV1Convolve2DTest;
+#if CONFIG_HIGHBITDEPTH
+using libaom_test::AV1HighbdConvolve2D::AV1HighbdConvolve2DTest;
+#endif
+
+namespace {
+
+TEST_P(AV1Convolve2DTest, CheckOutput) { RunCheckOutput(GET_PARAM(3)); }
+
+INSTANTIATE_TEST_CASE_P(
+    SSE2, AV1Convolve2DTest,
+    libaom_test::AV1Convolve2D::BuildParams(av1_convolve_2d_sse2));
+
+#if CONFIG_HIGHBITDEPTH && HAVE_SSSE3
+TEST_P(AV1HighbdConvolve2DTest, CheckOutput) { RunCheckOutput(GET_PARAM(4)); }
+
+INSTANTIATE_TEST_CASE_P(SSSE3, AV1HighbdConvolve2DTest,
+                        libaom_test::AV1HighbdConvolve2D::BuildParams(
+                            av1_highbd_convolve_2d_ssse3));
+
+#endif
+
+}  // namespace
new file mode 100644
--- /dev/null
+++ b/third_party/aom/test/av1_convolve_2d_test_util.cc
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2016, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+#include "test/av1_convolve_2d_test_util.h"
+
+#include "av1/common/convolve.h"
+
+using std::tr1::tuple;
+using std::tr1::make_tuple;
+
+namespace libaom_test {
+
+namespace AV1Convolve2D {
+
+::testing::internal::ParamGenerator<Convolve2DParam> BuildParams(
+    convolve_2d_func filter) {
+  const Convolve2DParam params[] = {
+    make_tuple(4, 4, 20, filter),  make_tuple(8, 8, 10, filter),
+    make_tuple(64, 64, 1, filter), make_tuple(4, 16, 10, filter),
+    make_tuple(32, 8, 5, filter),
+  };
+  return ::testing::ValuesIn(params);
+}
+
+AV1Convolve2DTest::~AV1Convolve2DTest() {}
+void AV1Convolve2DTest::SetUp() { rnd_.Reset(ACMRandom::DeterministicSeed()); }
+
+void AV1Convolve2DTest::TearDown() { libaom_test::ClearSystemState(); }
+
+void AV1Convolve2DTest::RunCheckOutput(convolve_2d_func test_impl) {
+  const int w = 128, h = 128;
+  const int out_w = GET_PARAM(0), out_h = GET_PARAM(1);
+  const int num_iters = GET_PARAM(2);
+  int i, j, k;
+
+  uint8_t *input = new uint8_t[h * w];
+
+  int output_n = out_h * MAX_SB_SIZE;
+  CONV_BUF_TYPE *output = new CONV_BUF_TYPE[output_n];
+  CONV_BUF_TYPE *output2 = new CONV_BUF_TYPE[output_n];
+
+  for (i = 0; i < h; ++i)
+    for (j = 0; j < w; ++j) input[i * w + j] = rnd_.Rand8();
+
+  memset(output, 0, output_n * sizeof(CONV_BUF_TYPE));
+  memset(output2, 0, output_n * sizeof(CONV_BUF_TYPE));
+
+  int hfilter, vfilter, subx, suby;
+  for (hfilter = EIGHTTAP_REGULAR; hfilter < INTERP_FILTERS_ALL; ++hfilter) {
+    for (vfilter = EIGHTTAP_REGULAR; vfilter < INTERP_FILTERS_ALL; ++vfilter) {
+      InterpFilterParams filter_params_x =
+          av1_get_interp_filter_params((InterpFilter)hfilter);
+      InterpFilterParams filter_params_y =
+          av1_get_interp_filter_params((InterpFilter)vfilter);
+      ConvolveParams conv_params1 =
+          get_conv_params_no_round(0, 0, 0, output, MAX_SB_SIZE);
+      ConvolveParams conv_params2 =
+          get_conv_params_no_round(0, 0, 0, output2, MAX_SB_SIZE);
+
+      for (subx = 0; subx < 16; ++subx)
+        for (suby = 0; suby < 16; ++suby) {
+          for (i = 0; i < num_iters; ++i) {
+            // Choose random locations within the source block
+            int offset_r = 3 + rnd_.PseudoUniform(h - out_h - 7);
+            int offset_c = 3 + rnd_.PseudoUniform(w - out_w - 7);
+            av1_convolve_2d_c(input + offset_r * w + offset_c, w, output,
+                              MAX_SB_SIZE, out_w, out_h, &filter_params_x,
+                              &filter_params_y, subx, suby, &conv_params1);
+            test_impl(input + offset_r * w + offset_c, w, output2, MAX_SB_SIZE,
+                      out_w, out_h, &filter_params_x, &filter_params_y, subx,
+                      suby, &conv_params2);
+
+            for (j = 0; j < out_h; ++j)
+              for (k = 0; k < out_w; ++k) {
+                int idx = j * MAX_SB_SIZE + k;
+                ASSERT_EQ(output[idx], output2[idx])
+                    << "Pixel mismatch at index " << idx << " = (" << j << ", "
+                    << k << "), sub pixel offset = (" << suby << ", " << subx
+                    << ")";
+              }
+          }
+        }
+    }
+  }
+  delete[] input;
+  delete[] output;
+  delete[] output2;
+}
+}  // namespace AV1Convolve2D
+
+#if CONFIG_HIGHBITDEPTH
+namespace AV1HighbdConvolve2D {
+
+::testing::internal::ParamGenerator<HighbdConvolve2DParam> BuildParams(
+    highbd_convolve_2d_func filter) {
+  const HighbdConvolve2DParam params[] = {
+    make_tuple(4, 4, 20, 8, filter),   make_tuple(8, 8, 10, 8, filter),
+    make_tuple(64, 64, 1, 8, filter),  make_tuple(4, 16, 10, 8, filter),
+    make_tuple(32, 8, 10, 8, filter),  make_tuple(4, 4, 20, 10, filter),
+    make_tuple(8, 8, 10, 10, filter),  make_tuple(64, 64, 1, 10, filter),
+    make_tuple(4, 16, 10, 10, filter), make_tuple(32, 8, 10, 10, filter),
+    make_tuple(4, 4, 20, 12, filter),  make_tuple(8, 8, 10, 12, filter),
+    make_tuple(64, 64, 1, 12, filter), make_tuple(4, 16, 10, 12, filter),
+    make_tuple(32, 8, 10, 12, filter),
+  };
+  return ::testing::ValuesIn(params);
+}
+
+AV1HighbdConvolve2DTest::~AV1HighbdConvolve2DTest() {}
+void AV1HighbdConvolve2DTest::SetUp() {
+  rnd_.Reset(ACMRandom::DeterministicSeed());
+}
+
+void AV1HighbdConvolve2DTest::TearDown() { libaom_test::ClearSystemState(); }
+
+void AV1HighbdConvolve2DTest::RunCheckOutput(
+    highbd_convolve_2d_func test_impl) {
+  const int w = 128, h = 128;
+  const int out_w = GET_PARAM(0), out_h = GET_PARAM(1);
+  const int num_iters = GET_PARAM(2);
+  const int bd = GET_PARAM(3);
+  int i, j, k;
+
+  uint16_t *input = new uint16_t[h * w];
+
+  int output_n = out_h * MAX_SB_SIZE;
+  CONV_BUF_TYPE *output = new CONV_BUF_TYPE[output_n];
+  CONV_BUF_TYPE *output2 = new CONV_BUF_TYPE[output_n];
+
+  for (i = 0; i < h; ++i)
+    for (j = 0; j < w; ++j) input[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
+
+  memset(output, 0, output_n * sizeof(CONV_BUF_TYPE));
+  memset(output2, 0, output_n * sizeof(CONV_BUF_TYPE));
+
+  int hfilter, vfilter, subx, suby;
+  for (hfilter = EIGHTTAP_REGULAR; hfilter < INTERP_FILTERS_ALL; ++hfilter) {
+    for (vfilter = EIGHTTAP_REGULAR; vfilter < INTERP_FILTERS_ALL; ++vfilter) {
+      InterpFilterParams filter_params_x =
+          av1_get_interp_filter_params((InterpFilter)hfilter);
+      InterpFilterParams filter_params_y =
+          av1_get_interp_filter_params((InterpFilter)vfilter);
+      ConvolveParams conv_params1 =
+          get_conv_params_no_round(0, 0, 0, output, MAX_SB_SIZE);
+      ConvolveParams conv_params2 =
+          get_conv_params_no_round(0, 0, 0, output2, MAX_SB_SIZE);
+
+      for (subx = 0; subx < 16; ++subx)
+        for (suby = 0; suby < 16; ++suby) {
+          for (i = 0; i < num_iters; ++i) {
+            // Choose random locations within the source block
+            int offset_r = 3 + rnd_.PseudoUniform(h - out_h - 7);
+            int offset_c = 3 + rnd_.PseudoUniform(w - out_w - 7);
+            av1_highbd_convolve_2d_c(input + offset_r * w + offset_c, w, output,
+                                     MAX_SB_SIZE, out_w, out_h,
+                                     &filter_params_x, &filter_params_y, subx,
+                                     suby, &conv_params1, bd);
+            test_impl(input + offset_r * w + offset_c, w, output2, MAX_SB_SIZE,
+                      out_w, out_h, &filter_params_x, &filter_params_y, subx,
+                      suby, &conv_params2, bd);
+
+            for (j = 0; j < out_h; ++j)
+              for (k = 0; k < out_w; ++k) {
+                int idx = j * MAX_SB_SIZE + k;
+                ASSERT_EQ(output[idx], output2[idx])
+                    << "Pixel mismatch at index " << idx << " = (" << j << ", "
+                    << k << "), sub pixel offset = (" << suby << ", " << subx
+                    << ")";
+              }
+          }
+        }
+    }
+  }
+  delete[] input;
+  delete[] output;
+  delete[] output2;
+}
+}  // namespace AV1HighbdConvolve2D
+#endif  // CONFIG_HIGHBITDEPTH
+}  // namespace libaom_test
new file mode 100644
--- /dev/null
+++ b/third_party/aom/test/av1_convolve_2d_test_util.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2016, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+#ifndef TEST_HIPREC_CONVOLVE_TEST_UTIL_H_
+#define TEST_HIPREC_CONVOLVE_TEST_UTIL_H_
+
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
+#include "test/acm_random.h"
+#include "test/util.h"
+#include "./av1_rtcd.h"
+#include "./aom_dsp_rtcd.h"
+#include "test/clear_system_state.h"
+#include "test/register_state_check.h"
+
+namespace libaom_test {
+
+namespace AV1Convolve2D {
+
+typedef void (*convolve_2d_func)(const uint8_t *src, int src_stride,
+                                 CONV_BUF_TYPE *dst, int dst_stride, int w,
+                                 int h, InterpFilterParams *filter_params_x,
+                                 InterpFilterParams *filter_params_y,
+                                 const int subpel_x_q4, const int subpel_y_q4,
+                                 ConvolveParams *conv_params);
+
+typedef std::tr1::tuple<int, int, int, convolve_2d_func> Convolve2DParam;
+
+::testing::internal::ParamGenerator<Convolve2DParam> BuildParams(
+    convolve_2d_func filter);
+
+class AV1Convolve2DTest : public ::testing::TestWithParam<Convolve2DParam> {
+ public:
+  virtual ~AV1Convolve2DTest();
+  virtual void SetUp();
+
+  virtual void TearDown();
+
+ protected:
+  void RunCheckOutput(convolve_2d_func test_impl);
+
+  libaom_test::ACMRandom rnd_;
+};
+
+}  // namespace AV1Convolve2D
+
+#if CONFIG_HIGHBITDEPTH
+namespace AV1HighbdConvolve2D {
+typedef void (*highbd_convolve_2d_func)(
+    const uint16_t *src, int src_stride, CONV_BUF_TYPE *dst, int dst_stride,
+    int w, int h, InterpFilterParams *filter_params_x,
+    InterpFilterParams *filter_params_y, const int subpel_x_q4,
+    const int subpel_y_q4, ConvolveParams *conv_params, int bd);
+
+typedef std::tr1::tuple<int, int, int, int, highbd_convolve_2d_func>
+    HighbdConvolve2DParam;
+
+::testing::internal::ParamGenerator<HighbdConvolve2DParam> BuildParams(
+    highbd_convolve_2d_func filter);
+
+class AV1HighbdConvolve2DTest
+    : public ::testing::TestWithParam<HighbdConvolve2DParam> {
+ public:
+  virtual ~AV1HighbdConvolve2DTest();
+  virtual void SetUp();
+
+  virtual void TearDown();
+
+ protected:
+  void RunCheckOutput(highbd_convolve_2d_func test_impl);
+
+  libaom_test::ACMRandom rnd_;
+};
+
+}  // namespace AV1HighbdConvolve2D
+#endif  // CONFIG_HIGHBITDEPTH
+
+}  // namespace libaom_test
+
+#endif  // TEST_HIPREC_CONVOLVE_TEST_UTIL_H_
--- a/third_party/aom/test/av1_convolve_optimz_test.cc
+++ b/third_party/aom/test/av1_convolve_optimz_test.cc
@@ -69,17 +69,17 @@ class AV1ConvolveOptimzTest : public ::t
     conv_vert_ = GET_PARAM(2);
     BlockDimension block = GET_PARAM(3);
     width_ = std::tr1::get<0>(block);
     height_ = std::tr1::get<1>(block);
     filter_ = GET_PARAM(4);
     subpel_ = GET_PARAM(5);
     int ref = GET_PARAM(6);
     const int plane = 0;
-    conv_params_ = get_conv_params(ref, plane);
+    conv_params_ = get_conv_params(ref, ref, plane);
 
     alloc_ = new uint8_t[maxBlockSize * 4];
     src_ = alloc_ + (vertiOffset * maxWidth);
     src_ += horizOffset;
     src_ref_ = src_ + maxBlockSize;
 
     dst_ = alloc_ + 2 * maxBlockSize;
     dst_ref_ = alloc_ + 3 * maxBlockSize;
--- a/third_party/aom/test/av1_convolve_test.cc
+++ b/third_party/aom/test/av1_convolve_test.cc
@@ -144,17 +144,17 @@ class Av1ConvolveTest : public ::testing
   ACMRandom rnd_;
 };
 
 int bsize_ls[] = { 1, 2, 4, 8, 16, 32, 64, 3, 7, 15, 31, 63 };
 int bsize_num = sizeof(bsize_ls) / sizeof(bsize_ls[0]);
 
 TEST_P(Av1ConvolveTest, av1_convolve_vert) {
   const int y_step_q4 = 16;
-  ConvolveParams conv_params = get_conv_params(0, 0);
+  ConvolveParams conv_params = get_conv_params(0, 0, 0);
 
   int in_stride, out_stride, ref_out_stride, avg_out_stride, ref_avg_out_stride;
   uint8_t *in = add_input(MAX_SB_SIZE, MAX_SB_SIZE, &in_stride);
   uint8_t *out = add_output(MAX_SB_SIZE, MAX_SB_SIZE, &out_stride);
   uint8_t *ref_out = add_output(MAX_SB_SIZE, MAX_SB_SIZE, &ref_out_stride);
   uint8_t *avg_out = add_output(MAX_SB_SIZE, MAX_SB_SIZE, &avg_out_stride);
   uint8_t *ref_avg_out =
       add_output(MAX_SB_SIZE, MAX_SB_SIZE, &ref_avg_out_stride);
@@ -167,45 +167,47 @@ TEST_P(Av1ConvolveTest, av1_convolve_ver
         InterpFilterParams param_vert = av1_get_interp_filter_params(filter_y);
         const int16_t *filter_vert =
             av1_get_interp_filter_subpel_kernel(param_vert, subpel_y_q4);
 
         filter_block1d_vert_c(in, in_stride, filter_vert, param_vert.taps,
                               ref_out, ref_out_stride, w, h);
 
         conv_params.ref = 0;
+        conv_params.do_average = 0;
         cfs_->vf_(in, in_stride, out, out_stride, w, h, param_vert, subpel_y_q4,
                   y_step_q4, &conv_params);
         EXPECT_EQ(match(out, out_stride, ref_out, ref_out_stride, w, h), 1)
             << " hb_idx " << hb_idx << " vb_idx " << vb_idx << " filter_y "
             << filter_y << " subpel_y_q4 " << subpel_y_q4;
 
         random_init_buf(avg_out, w, h, avg_out_stride);
         for (int r = 0; r < h; ++r) {
           for (int c = 0; c < w; ++c) {
             ref_avg_out[r * ref_avg_out_stride + c] = ROUND_POWER_OF_TWO(
                 avg_out[r * avg_out_stride + c] + out[r * out_stride + c], 1);
           }
         }
         conv_params.ref = 1;
+        conv_params.do_average = 1;
         cfs_->vf_(in, in_stride, avg_out, avg_out_stride, w, h, param_vert,
                   subpel_y_q4, y_step_q4, &conv_params);
         EXPECT_EQ(match(avg_out, avg_out_stride, ref_avg_out,
                         ref_avg_out_stride, w, h),
                   1)
             << " hb_idx " << hb_idx << " vb_idx " << vb_idx << " filter_y "
             << filter_y << " subpel_y_q4 " << subpel_y_q4;
       }
     }
   }
 };
 
 TEST_P(Av1ConvolveTest, av1_convolve_horiz) {
   const int x_step_q4 = 16;
-  ConvolveParams conv_params = get_conv_params(0, 0);
+  ConvolveParams conv_params = get_conv_params(0, 0, 0);
 
   int in_stride, out_stride, ref_out_stride, avg_out_stride, ref_avg_out_stride;
   uint8_t *in = add_input(MAX_SB_SIZE, MAX_SB_SIZE, &in_stride);
   uint8_t *out = add_output(MAX_SB_SIZE, MAX_SB_SIZE, &out_stride);
   uint8_t *ref_out = add_output(MAX_SB_SIZE, MAX_SB_SIZE, &ref_out_stride);
   uint8_t *avg_out = add_output(MAX_SB_SIZE, MAX_SB_SIZE, &avg_out_stride);
   uint8_t *ref_avg_out =
       add_output(MAX_SB_SIZE, MAX_SB_SIZE, &ref_avg_out_stride);
@@ -218,30 +220,32 @@ TEST_P(Av1ConvolveTest, av1_convolve_hor
         InterpFilterParams param_horiz = av1_get_interp_filter_params(filter_x);
         const int16_t *filter_horiz =
             av1_get_interp_filter_subpel_kernel(param_horiz, subpel_x_q4);
 
         filter_block1d_horiz_c(in, in_stride, filter_horiz, param_horiz.taps,
                                ref_out, ref_out_stride, w, h);
 
         conv_params.ref = 0;
+        conv_params.do_average = 0;
         cfs_->hf_(in, in_stride, out, out_stride, w, h, param_horiz,
                   subpel_x_q4, x_step_q4, &conv_params);
         EXPECT_EQ(match(out, out_stride, ref_out, ref_out_stride, w, h), 1)
             << " hb_idx " << hb_idx << " vb_idx " << vb_idx << " filter_x "
             << filter_x << " subpel_x_q4 " << subpel_x_q4;
 
         random_init_buf(avg_out, w, h, avg_out_stride);
         for (int r = 0; r < h; ++r) {
           for (int c = 0; c < w; ++c) {
             ref_avg_out[r * ref_avg_out_stride + c] = ROUND_POWER_OF_TWO(
                 avg_out[r * avg_out_stride + c] + out[r * out_stride + c], 1);
           }
         }
         conv_params.ref = 1;
+        conv_params.do_average = 1;
         cfs_->hf_(in, in_stride, avg_out, avg_out_stride, w, h, param_horiz,
                   subpel_x_q4, x_step_q4, &conv_params);
         EXPECT_EQ(match(avg_out, avg_out_stride, ref_avg_out,
                         ref_avg_out_stride, w, h),
                   1)
             << "hb_idx " << hb_idx << "vb_idx" << vb_idx << " filter_x "
             << filter_x << "subpel_x_q4 " << subpel_x_q4;
       }
--- a/third_party/aom/test/av1_ext_tile_test.cc
+++ b/third_party/aom/test/av1_ext_tile_test.cc
@@ -28,26 +28,27 @@ const int kTileSize = 1;
 const int kTIleSizeInPixels = (kTileSize << 6);
 // Fake width and height so that they can be multiples of the tile size.
 const int kImgWidth = 704;
 const int kImgHeight = 576;
 
 // This test tests "tile_encoding_mode = TILE_VR" case. The TILE_NORMAL case is
 // tested by the tile_independence test.
 class AV1ExtTileTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> {
+    : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
+      public ::libaom_test::EncoderTest {
  protected:
   AV1ExtTileTest()
       : EncoderTest(GET_PARAM(0)), encoding_mode_(GET_PARAM(1)),
         set_cpu_used_(GET_PARAM(2)) {
     init_flags_ = AOM_CODEC_USE_PSNR;
     aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t();
     cfg.w = kImgWidth;
     cfg.h = kImgHeight;
+    cfg.allow_lowbitdepth = 1;
 
     decoder_ = codec_->CreateDecoder(cfg, 0);
     decoder_->Control(AV1_SET_DECODE_TILE_ROW, -1);
     decoder_->Control(AV1_SET_DECODE_TILE_COL, -1);
 
     // Allocate buffer to store tile image.
     aom_img_alloc(&tile_img_, AOM_IMG_FMT_I420, kImgWidth, kImgHeight, 32);
 
@@ -83,16 +84,19 @@ class AV1ExtTileTest
       // The tile size is 64x64.
       encoder->Control(AV1E_SET_TILE_COLUMNS, kTileSize);
       encoder->Control(AV1E_SET_TILE_ROWS, kTileSize);
       encoder->Control(AV1E_SET_TILE_ENCODING_MODE, 1);  // TILE_VR
 #if CONFIG_EXT_PARTITION
       // Always use 64x64 max partition.
       encoder->Control(AV1E_SET_SUPERBLOCK_SIZE, AOM_SUPERBLOCK_SIZE_64X64);
 #endif
+#if CONFIG_LOOPFILTERING_ACROSS_TILES
+      encoder->Control(AV1E_SET_TILE_LOOPFILTER, 0);
+#endif
     }
 
     if (video->frame() == 1) {
       frame_flags_ =
           AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF | AOM_EFLAG_NO_UPD_ARF;
     }
   }
 
--- a/third_party/aom/test/av1_fht16x16_test.cc
+++ b/third_party/aom/test/av1_fht16x16_test.cc
@@ -20,28 +20,29 @@
 #include "test/transform_test_base.h"
 #include "test/util.h"
 #include "aom_ports/mem.h"
 
 using libaom_test::ACMRandom;
 
 namespace {
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 using std::tr1::tuple;
 using libaom_test::FhtFunc;
 typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht16x16Param;
 
-void fht16x16_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht16x16_c(in, out, stride, tx_type);
+void fht16x16_ref(const int16_t *in, tran_low_t *out, int stride,
+                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht16x16_c(in, out, stride, fwd_txfm_param);
 }
 
 void iht16x16_ref(const tran_low_t *in, uint8_t *dest, int stride,
-                  int tx_type) {
-  av1_iht16x16_256_add_c(in, dest, stride, tx_type);
+                  const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_iht16x16_256_add_c(in, dest, stride, inv_txfm_param);
 }
 
 #if CONFIG_HIGHBITDEPTH
 typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
                            int tx_type, int bd);
 typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride,
                           int tx_type, int bd);
 
@@ -57,34 +58,35 @@ void highbd_fht16x16_ref(const int16_t *
 class AV1Trans16x16HT : public libaom_test::TransformTestBase,
                         public ::testing::TestWithParam<Ht16x16Param> {
  public:
   virtual ~AV1Trans16x16HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 16;
     height_ = 16;
     fwd_txfm_ref = fht16x16_ref;
     inv_txfm_ref = iht16x16_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
 
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(AV1Trans16x16HT, MemCheck) { RunMemCheck(); }
 TEST_P(AV1Trans16x16HT, AccuracyCheck) { RunAccuracyCheck(1, 0.001); }
--- a/third_party/aom/test/av1_fht16x32_test.cc
+++ b/third_party/aom/test/av1_fht16x32_test.cc
@@ -20,55 +20,58 @@
 #include "test/register_state_check.h"
 #include "test/transform_test_base.h"
 #include "test/util.h"
 
 using libaom_test::ACMRandom;
 
 namespace {
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 using std::tr1::tuple;
 using libaom_test::FhtFunc;
 typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht16x32Param;
 
-void fht16x32_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht16x32_c(in, out, stride, tx_type);
+void fht16x32_ref(const int16_t *in, tran_low_t *out, int stride,
+                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht16x32_c(in, out, stride, fwd_txfm_param);
 }
 
-void iht16x32_ref(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_iht16x32_512_add_c(in, out, stride, tx_type);
+void iht16x32_ref(const tran_low_t *in, uint8_t *out, int stride,
+                  const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_iht16x32_512_add_c(in, out, stride, inv_txfm_param);
 }
 
 class AV1Trans16x32HT : public libaom_test::TransformTestBase,
                         public ::testing::TestWithParam<Ht16x32Param> {
  public:
   virtual ~AV1Trans16x32HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 16;
     height_ = 32;
     fwd_txfm_ref = fht16x32_ref;
     inv_txfm_ref = iht16x32_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
 
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(AV1Trans16x32HT, AccuracyCheck) { RunAccuracyCheck(4, 0.2); }
 TEST_P(AV1Trans16x32HT, CoeffCheck) { RunCoeffCheck(); }
--- a/third_party/aom/test/av1_fht16x8_test.cc
+++ b/third_party/aom/test/av1_fht16x8_test.cc
@@ -20,55 +20,58 @@
 #include "test/register_state_check.h"
 #include "test/transform_test_base.h"
 #include "test/util.h"
 
 using libaom_test::ACMRandom;
 
 namespace {
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 using std::tr1::tuple;
 using libaom_test::FhtFunc;
 typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht16x8Param;
 
-void fht16x8_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht16x8_c(in, out, stride, tx_type);
+void fht16x8_ref(const int16_t *in, tran_low_t *out, int stride,
+                 FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht16x8_c(in, out, stride, fwd_txfm_param);
 }
 
-void iht16x8_ref(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_iht16x8_128_add_c(in, out, stride, tx_type);
+void iht16x8_ref(const tran_low_t *in, uint8_t *out, int stride,
+                 const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_iht16x8_128_add_c(in, out, stride, inv_txfm_param);
 }
 
 class AV1Trans16x8HT : public libaom_test::TransformTestBase,
                        public ::testing::TestWithParam<Ht16x8Param> {
  public:
   virtual ~AV1Trans16x8HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 16;
     height_ = 8;
     inv_txfm_ref = iht16x8_ref;
     fwd_txfm_ref = fht16x8_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
 
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(AV1Trans16x8HT, AccuracyCheck) { RunAccuracyCheck(1, 0.001); }
 TEST_P(AV1Trans16x8HT, CoeffCheck) { RunCoeffCheck(); }
--- a/third_party/aom/test/av1_fht32x16_test.cc
+++ b/third_party/aom/test/av1_fht32x16_test.cc
@@ -20,55 +20,58 @@
 #include "test/register_state_check.h"
 #include "test/transform_test_base.h"
 #include "test/util.h"
 
 using libaom_test::ACMRandom;
 
 namespace {
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 using std::tr1::tuple;
 using libaom_test::FhtFunc;
 typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht32x16Param;
 
-void fht32x16_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht32x16_c(in, out, stride, tx_type);
+void fht32x16_ref(const int16_t *in, tran_low_t *out, int stride,
+                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht32x16_c(in, out, stride, fwd_txfm_param);
 }
 
-void iht32x16_ref(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_iht32x16_512_add_c(in, out, stride, tx_type);
+void iht32x16_ref(const tran_low_t *in, uint8_t *out, int stride,
+                  const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_iht32x16_512_add_c(in, out, stride, inv_txfm_param);
 }
 
 class AV1Trans32x16HT : public libaom_test::TransformTestBase,
                         public ::testing::TestWithParam<Ht32x16Param> {
  public:
   virtual ~AV1Trans32x16HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 32;
     height_ = 16;
     fwd_txfm_ref = fht32x16_ref;
     inv_txfm_ref = iht32x16_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
 
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(AV1Trans32x16HT, MemCheck) { RunMemCheck(); }
 TEST_P(AV1Trans32x16HT, AccuracyCheck) { RunAccuracyCheck(4, 0.2); }
--- a/third_party/aom/test/av1_fht32x32_test.cc
+++ b/third_party/aom/test/av1_fht32x32_test.cc
@@ -20,23 +20,24 @@
 #include "test/transform_test_base.h"
 #include "test/util.h"
 #include "aom_ports/mem.h"
 
 using libaom_test::ACMRandom;
 
 namespace {
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 using std::tr1::tuple;
 using libaom_test::FhtFunc;
 typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht32x32Param;
 
-void fht32x32_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht32x32_c(in, out, stride, tx_type);
+void fht32x32_ref(const int16_t *in, tran_low_t *out, int stride,
+                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht32x32_c(in, out, stride, fwd_txfm_param);
 }
 
 #if CONFIG_HIGHBITDEPTH
 typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
                            int tx_type, int bd);
 typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride,
                           int tx_type, int bd);
 
@@ -46,49 +47,50 @@ typedef tuple<HbdHtFunc, int, int> Highb
 void highbd_fht32x32_ref(const int16_t *in, int32_t *out, int stride,
                          int tx_type, int bd) {
   av1_fwd_txfm2d_32x32_c(in, out, stride, tx_type, bd);
 }
 #endif  // CONFIG_HIGHBITDEPTH
 
 #if HAVE_SSE2 || HAVE_AVX2
 void dummy_inv_txfm(const tran_low_t *in, uint8_t *out, int stride,
-                    int tx_type) {
+                    const INV_TXFM_PARAM *inv_txfm_param) {
   (void)in;
   (void)out;
   (void)stride;
-  (void)tx_type;
+  (void)inv_txfm_param;
 }
 #endif
 
 class AV1Trans32x32HT : public libaom_test::TransformTestBase,
                         public ::testing::TestWithParam<Ht32x32Param> {
  public:
   virtual ~AV1Trans32x32HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 32;
     height_ = 32;
     fwd_txfm_ref = fht32x32_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
 
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(AV1Trans32x32HT, CoeffCheck) { RunCoeffCheck(); }
 TEST_P(AV1Trans32x32HT, MemCheck) { RunMemCheck(); }
--- a/third_party/aom/test/av1_fht4x4_test.cc
+++ b/third_party/aom/test/av1_fht4x4_test.cc
@@ -20,27 +20,29 @@
 #include "test/transform_test_base.h"
 #include "test/util.h"
 #include "aom_ports/mem.h"
 
 using libaom_test::ACMRandom;
 
 namespace {
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 using std::tr1::tuple;
 using libaom_test::FhtFunc;
 typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht4x4Param;
 
-void fht4x4_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht4x4_c(in, out, stride, tx_type);
+void fht4x4_ref(const int16_t *in, tran_low_t *out, int stride,
+                FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht4x4_c(in, out, stride, fwd_txfm_param);
 }
 
-void iht4x4_ref(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_iht4x4_16_add_c(in, out, stride, tx_type);
+void iht4x4_ref(const tran_low_t *in, uint8_t *out, int stride,
+                const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_iht4x4_16_add_c(in, out, stride, inv_txfm_param);
 }
 
 #if CONFIG_HIGHBITDEPTH
 typedef void (*IhighbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
                               int tx_type, int bd);
 typedef void (*HBDFhtFunc)(const int16_t *input, int32_t *output, int stride,
                            int tx_type, int bd);
 
@@ -57,34 +59,35 @@ void highbe_fht4x4_ref(const int16_t *in
 class AV1Trans4x4HT : public libaom_test::TransformTestBase,
                       public ::testing::TestWithParam<Ht4x4Param> {
  public:
   virtual ~AV1Trans4x4HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 4;
     height_ = 4;
     fwd_txfm_ref = fht4x4_ref;
     inv_txfm_ref = iht4x4_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
 
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(AV1Trans4x4HT, MemCheck) { RunMemCheck(); }
 TEST_P(AV1Trans4x4HT, CoeffCheck) { RunCoeffCheck(); }
--- a/third_party/aom/test/av1_fht4x8_test.cc
+++ b/third_party/aom/test/av1_fht4x8_test.cc
@@ -20,55 +20,58 @@
 #include "test/register_state_check.h"
 #include "test/transform_test_base.h"
 #include "test/util.h"
 
 using libaom_test::ACMRandom;
 
 namespace {
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 using std::tr1::tuple;
 using libaom_test::FhtFunc;
 typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht4x8Param;
 
-void fht4x8_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht4x8_c(in, out, stride, tx_type);
+void fht4x8_ref(const int16_t *in, tran_low_t *out, int stride,
+                FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht4x8_c(in, out, stride, fwd_txfm_param);
 }
 
-void iht4x8_ref(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_iht4x8_32_add_c(in, out, stride, tx_type);
+void iht4x8_ref(const tran_low_t *in, uint8_t *out, int stride,
+                const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_iht4x8_32_add_c(in, out, stride, inv_txfm_param);
 }
 
 class AV1Trans4x8HT : public libaom_test::TransformTestBase,
                       public ::testing::TestWithParam<Ht4x8Param> {
  public:
   virtual ~AV1Trans4x8HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 4;
     height_ = 8;
     fwd_txfm_ref = fht4x8_ref;
     inv_txfm_ref = iht4x8_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
 
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(AV1Trans4x8HT, AccuracyCheck) { RunAccuracyCheck(0, 0.00001); }
 TEST_P(AV1Trans4x8HT, CoeffCheck) { RunCoeffCheck(); }
--- a/third_party/aom/test/av1_fht64x64_test.cc
+++ b/third_party/aom/test/av1_fht64x64_test.cc
@@ -21,56 +21,58 @@
 #include "test/util.h"
 
 #if CONFIG_TX64X64
 
 using libaom_test::ACMRandom;
 
 namespace {
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 using std::tr1::tuple;
 using libaom_test::FhtFunc;
 typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht64x64Param;
 
-void fht64x64_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht64x64_c(in, out, stride, tx_type);
+void fht64x64_ref(const int16_t *in, tran_low_t *out, int stride,
+                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht64x64_c(in, out, stride, fwd_txfm_param);
 }
 
 void iht64x64_ref(const tran_low_t *in, uint8_t *dest, int stride,
-                  int tx_type) {
-  av1_iht64x64_4096_add_c(in, dest, stride, tx_type);
+                  const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_iht64x64_4096_add_c(in, dest, stride, inv_txfm_param);
 }
 
 class AV1Trans64x64HT : public libaom_test::TransformTestBase,
                         public ::testing::TestWithParam<Ht64x64Param> {
  public:
   virtual ~AV1Trans64x64HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 64;
     height_ = 64;
     fwd_txfm_ref = fht64x64_ref;
     inv_txfm_ref = iht64x64_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
 
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(AV1Trans64x64HT, AccuracyCheck) { RunAccuracyCheck(4, 0.2); }
 TEST_P(AV1Trans64x64HT, CoeffCheck) { RunCoeffCheck(); }
--- a/third_party/aom/test/av1_fht8x16_test.cc
+++ b/third_party/aom/test/av1_fht8x16_test.cc
@@ -19,55 +19,58 @@
 #include "test/register_state_check.h"
 #include "test/transform_test_base.h"
 #include "test/util.h"
 
 using libaom_test::ACMRandom;
 
 namespace {
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 using std::tr1::tuple;
 using libaom_test::FhtFunc;
 typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht8x16Param;
 
-void fht8x16_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht8x16_c(in, out, stride, tx_type);
+void fht8x16_ref(const int16_t *in, tran_low_t *out, int stride,
+                 FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht8x16_c(in, out, stride, fwd_txfm_param);
 }
 
-void iht8x16_ref(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_iht8x16_128_add_c(in, out, stride, tx_type);
+void iht8x16_ref(const tran_low_t *in, uint8_t *out, int stride,
+                 const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_iht8x16_128_add_c(in, out, stride, inv_txfm_param);
 }
 
 class AV1Trans8x16HT : public libaom_test::TransformTestBase,
                        public ::testing::TestWithParam<Ht8x16Param> {
  public:
   virtual ~AV1Trans8x16HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 8;
     height_ = 16;
     inv_txfm_ref = iht8x16_ref;
     fwd_txfm_ref = fht8x16_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
 
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(AV1Trans8x16HT, AccuracyCheck) { RunAccuracyCheck(1, 0.001); }
 TEST_P(AV1Trans8x16HT, MemCheck) { RunMemCheck(); }
--- a/third_party/aom/test/av1_fht8x4_test.cc
+++ b/third_party/aom/test/av1_fht8x4_test.cc
@@ -19,55 +19,58 @@
 #include "test/register_state_check.h"
 #include "test/transform_test_base.h"
 #include "test/util.h"
 
 using libaom_test::ACMRandom;
 
 namespace {
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 using std::tr1::tuple;
 using libaom_test::FhtFunc;
 typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht8x4Param;
 
-void fht8x4_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht8x4_c(in, out, stride, tx_type);
+void fht8x4_ref(const int16_t *in, tran_low_t *out, int stride,
+                FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht8x4_c(in, out, stride, fwd_txfm_param);
 }
 
-void iht8x4_ref(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_iht8x4_32_add_c(in, out, stride, tx_type);
+void iht8x4_ref(const tran_low_t *in, uint8_t *out, int stride,
+                const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_iht8x4_32_add_c(in, out, stride, inv_txfm_param);
 }
 
 class AV1Trans8x4HT : public libaom_test::TransformTestBase,
                       public ::testing::TestWithParam<Ht8x4Param> {
  public:
   virtual ~AV1Trans8x4HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 8;
     height_ = 4;
     fwd_txfm_ref = fht8x4_ref;
     inv_txfm_ref = iht8x4_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
 
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(AV1Trans8x4HT, AccuracyCheck) { RunAccuracyCheck(0, 0.00001); }
 TEST_P(AV1Trans8x4HT, CoeffCheck) { RunCoeffCheck(); }
--- a/third_party/aom/test/av1_fht8x8_test.cc
+++ b/third_party/aom/test/av1_fht8x8_test.cc
@@ -20,28 +20,30 @@
 #include "test/transform_test_base.h"
 #include "test/util.h"
 #include "aom_ports/mem.h"
 
 using libaom_test::ACMRandom;
 
 namespace {
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 
 using libaom_test::FhtFunc;
 using std::tr1::tuple;
 typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht8x8Param;
 
-void fht8x8_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht8x8_c(in, out, stride, tx_type);
+void fht8x8_ref(const int16_t *in, tran_low_t *out, int stride,
+                FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht8x8_c(in, out, stride, fwd_txfm_param);
 }
 
-void iht8x8_ref(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_iht8x8_64_add_c(in, out, stride, tx_type);
+void iht8x8_ref(const tran_low_t *in, uint8_t *out, int stride,
+                const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_iht8x8_64_add_c(in, out, stride, inv_txfm_param);
 }
 
 #if CONFIG_HIGHBITDEPTH
 typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
                            int tx_type, int bd);
 typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride,
                           int tx_type, int bd);
 // Target optimized function, tx_type, bit depth
@@ -56,34 +58,35 @@ void highbd_fht8x8_ref(const int16_t *in
 class AV1Trans8x8HT : public libaom_test::TransformTestBase,
                       public ::testing::TestWithParam<Ht8x8Param> {
  public:
   virtual ~AV1Trans8x8HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 8;
     height_ = 8;
     fwd_txfm_ref = fht8x8_ref;
     inv_txfm_ref = iht8x8_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
 
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(AV1Trans8x8HT, MemCheck) { RunMemCheck(); }
 TEST_P(AV1Trans8x8HT, CoeffCheck) { RunCoeffCheck(); }
--- a/third_party/aom/test/av1_fwd_txfm1d_test.cc
+++ b/third_party/aom/test/av1_fwd_txfm1d_test.cc
@@ -77,17 +77,17 @@ TEST(av1_fwd_txfm1d, clamp_block) {
                               { 7, -4, 2, -3, 9 },
                               { 7, -4, 2, -3, 9 },
                               { 7, -4, 2, -3, 9 } };
 
   int row = 2;
   int col = 1;
   int block_size = 3;
   int stride = 5;
-  clamp_block(block[row] + col, block_size, stride, -4, 2);
+  clamp_block(block[row] + col, block_size, block_size, stride, -4, 2);
   for (int r = 0; r < stride; r++) {
     for (int c = 0; c < stride; c++) {
       EXPECT_EQ(block[r][c], ref_block[r][c]);
     }
   }
 }
 
 TEST(av1_fwd_txfm1d, accuracy) {
--- a/third_party/aom/test/av1_inv_txfm1d_test.cc
+++ b/third_party/aom/test/av1_inv_txfm1d_test.cc
@@ -5,16 +5,17 @@
  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
  * was not distributed with this source code in the LICENSE file, you can
  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #include "test/av1_txfm_test.h"
+#include "test/util.h"
 #include "av1/common/av1_fwd_txfm1d.h"
 #include "av1/common/av1_inv_txfm1d.h"
 
 using libaom_test::ACMRandom;
 using libaom_test::input_base;
 
 namespace {
 const int txfm_type_num = 2;
@@ -36,21 +37,19 @@ const TxfmFunc inv_txfm_func_ls[][2] = {
   { av1_idct16_new, av1_iadst16_new },
   { av1_idct32_new, av1_iadst32_new },
 #if CONFIG_TX64X64
   { av1_idct64_new, NULL },
 #endif
 };
 
 // the maximum stage number of fwd/inv 1d dct/adst txfm is 12
-const int8_t cos_bit[12] = { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 };
+const int8_t cos_bit[12] = { 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 };
 const int8_t range_bit[12] = { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 };
 
-#define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0]))
-
 TEST(av1_inv_txfm1d, round_trip) {
   ACMRandom rnd(ACMRandom::DeterministicSeed());
   for (int si = 0; si < ARRAY_SIZE(fwd_txfm_func_ls); ++si) {
     int txfm_size = txfm_size_ls[si];
 
     for (int ti = 0; ti < txfm_type_num; ++ti) {
       TxfmFunc fwd_txfm_func = fwd_txfm_func_ls[si][ti];
       TxfmFunc inv_txfm_func = inv_txfm_func_ls[si][ti];
--- a/third_party/aom/test/av1_inv_txfm2d_test.cc
+++ b/third_party/aom/test/av1_inv_txfm2d_test.cc
@@ -37,79 +37,70 @@ class AV1InvTxfm2d : public ::testing::T
  public:
   virtual void SetUp() {
     tx_type_ = GET_PARAM(0);
     tx_size_ = GET_PARAM(1);
     max_error_ = GET_PARAM(2);
     max_avg_error_ = GET_PARAM(3);
     txfm1d_size_ = libaom_test::get_txfm1d_size(tx_size_);
     txfm2d_size_ = txfm1d_size_ * txfm1d_size_;
-    count_ = 500;
-
-    input_ = reinterpret_cast<int16_t *>(
-        aom_memalign(16, sizeof(int16_t) * txfm2d_size_));
-    ref_input_ = reinterpret_cast<uint16_t *>(
-        aom_memalign(16, sizeof(uint16_t) * txfm2d_size_));
-    output_ = reinterpret_cast<int32_t *>(
-        aom_memalign(16, sizeof(int32_t) * txfm2d_size_));
   }
 
   void RunRoundtripCheck() {
     const Fwd_Txfm2d_Func fwd_txfm_func =
         libaom_test::fwd_txfm_func_ls[tx_size_];
     const Inv_Txfm2d_Func inv_txfm_func =
         libaom_test::inv_txfm_func_ls[tx_size_];
     double avg_abs_error = 0;
     ACMRandom rnd(ACMRandom::DeterministicSeed());
-    for (int ci = 0; ci < count_; ci++) {
+
+    const int count = 500;
+
+    for (int ci = 0; ci < count; ci++) {
+      int16_t expected[64 * 64] = { 0 };
+      assert(txfm2d_size_ < ARRAY_SIZE(expected));
+
       for (int ni = 0; ni < txfm2d_size_; ++ni) {
         if (ci == 0) {
           int extreme_input = input_base - 1;
-          input_[ni] = extreme_input;  // extreme case
-          ref_input_[ni] = 0;
+          expected[ni] = extreme_input;  // extreme case
         } else {
-          input_[ni] = rnd.Rand16() % input_base;
-          ref_input_[ni] = 0;
+          expected[ni] = rnd.Rand16() % input_base;
         }
       }
 
-      fwd_txfm_func(input_, output_, txfm1d_size_, tx_type_, bd);
-      inv_txfm_func(output_, ref_input_, txfm1d_size_, tx_type_, bd);
+      int32_t coeffs[64 * 64] = { 0 };
+      assert(txfm2d_size_ < ARRAY_SIZE(coeffs));
+      fwd_txfm_func(expected, coeffs, txfm1d_size_, tx_type_, bd);
+
+      uint16_t actual[64 * 64] = { 0 };
+      assert(txfm2d_size_ < ARRAY_SIZE(actual));
+      inv_txfm_func(coeffs, actual, txfm1d_size_, tx_type_, bd);
 
       for (int ni = 0; ni < txfm2d_size_; ++ni) {
-        EXPECT_GE(max_error_, abs(input_[ni] - ref_input_[ni]));
+        EXPECT_GE(max_error_, abs(expected[ni] - actual[ni]));
       }
       avg_abs_error += compute_avg_abs_error<int16_t, uint16_t>(
-          input_, ref_input_, txfm2d_size_);
+          expected, actual, txfm2d_size_);
     }
 
-    avg_abs_error /= count_;
+    avg_abs_error /= count;
     // max_abs_avg_error comes from upper bound of
     // printf("txfm1d_size: %d accuracy_avg_abs_error: %f\n",
     // txfm1d_size_, avg_abs_error);
     EXPECT_GE(max_avg_error_, avg_abs_error);
   }
 
-  virtual void TearDown() {
-    aom_free(input_);
-    aom_free(output_);
-    aom_free(ref_input_);
-  }
-
  private:
-  int count_;
   int max_error_;
   double max_avg_error_;
   TX_TYPE tx_type_;
   TX_SIZE tx_size_;
   int txfm1d_size_;
   int txfm2d_size_;
-  int16_t *input_;
-  uint16_t *ref_input_;
-  int32_t *output_;
 };
 
 TEST_P(AV1InvTxfm2d, RunRoundtripCheck) { RunRoundtripCheck(); }
 
 const AV1InvTxfm2dParam av1_inv_txfm2d_param[] = {
 #if CONFIG_EXT_TX
   AV1InvTxfm2dParam(FLIPADST_DCT, TX_4X4, 2, 0.002),
   AV1InvTxfm2dParam(DCT_FLIPADST, TX_4X4, 2, 0.002),
--- a/third_party/aom/test/av1_inv_txfm_test.cc
+++ b/third_party/aom/test/av1_inv_txfm_test.cc
@@ -38,81 +38,72 @@ void reference_idct_1d(const double *in,
       if (k == 0)
         out[n] += kInvSqrt2 * in[k] * cos(PI * (2 * n + 1) * k / (2 * size));
       else
         out[n] += in[k] * cos(PI * (2 * n + 1) * k / (2 * size));
     }
   }
 }
 
-typedef void (*IdctFuncRef)(const double *in, double *out, int size);
 typedef void (*IdctFunc)(const tran_low_t *in, tran_low_t *out);
 
 class TransTestBase {
  public:
   virtual ~TransTestBase() {}
 
  protected:
   void RunInvAccuracyCheck() {
-    tran_low_t *input = new tran_low_t[txfm_size_];
-    tran_low_t *output = new tran_low_t[txfm_size_];
-    double *ref_input = new double[txfm_size_];
-    double *ref_output = new double[txfm_size_];
+    tran_low_t input[64];
+    tran_low_t output[64];
+    double ref_input[64];
+    double ref_output[64];
 
     ACMRandom rnd(ACMRandom::DeterministicSeed());
     const int count_test_block = 5000;
     for (int ti = 0; ti < count_test_block; ++ti) {
       for (int ni = 0; ni < txfm_size_; ++ni) {
         input[ni] = rnd.Rand8() - rnd.Rand8();
         ref_input[ni] = static_cast<double>(input[ni]);
       }
 
-      fwd_txfm_(input, output);
-      fwd_txfm_ref_(ref_input, ref_output, txfm_size_);
+      inv_txfm_(input, output);
+      reference_idct_1d(ref_input, ref_output, txfm_size_);
 
       for (int ni = 0; ni < txfm_size_; ++ni) {
         EXPECT_LE(
             abs(output[ni] - static_cast<tran_low_t>(round(ref_output[ni]))),
             max_error_);
       }
     }
-
-    delete[] input;
-    delete[] output;
-    delete[] ref_input;
-    delete[] ref_output;
   }
 
   double max_error_;
   int txfm_size_;
-  IdctFunc fwd_txfm_;
-  IdctFuncRef fwd_txfm_ref_;
+  IdctFunc inv_txfm_;
 };
 
-typedef std::tr1::tuple<IdctFunc, IdctFuncRef, int, int> IdctParam;
+typedef std::tr1::tuple<IdctFunc, int, int> IdctParam;
 class AV1InvTxfm : public TransTestBase,
                    public ::testing::TestWithParam<IdctParam> {
  public:
   virtual void SetUp() {
-    fwd_txfm_ = GET_PARAM(0);
-    fwd_txfm_ref_ = GET_PARAM(1);
-    txfm_size_ = GET_PARAM(2);
-    max_error_ = GET_PARAM(3);
+    inv_txfm_ = GET_PARAM(0);
+    txfm_size_ = GET_PARAM(1);
+    max_error_ = GET_PARAM(2);
   }
   virtual void TearDown() {}
 };
 
 TEST_P(AV1InvTxfm, RunInvAccuracyCheck) { RunInvAccuracyCheck(); }
 
-INSTANTIATE_TEST_CASE_P(
-    C, AV1InvTxfm,
-    ::testing::Values(IdctParam(&aom_idct4_c, &reference_idct_1d, 4, 1),
-                      IdctParam(&aom_idct8_c, &reference_idct_1d, 8, 2),
-                      IdctParam(&aom_idct16_c, &reference_idct_1d, 16, 4),
-                      IdctParam(&aom_idct32_c, &reference_idct_1d, 32, 6)));
+INSTANTIATE_TEST_CASE_P(C, AV1InvTxfm,
+                        ::testing::Values(IdctParam(&aom_idct4_c, 4, 1),
+                                          IdctParam(&aom_idct8_c, 8, 2),
+                                          IdctParam(&aom_idct16_c, 16, 4),
+                                          IdctParam(&aom_idct32_c, 32, 6)));
 
 #if CONFIG_AV1_ENCODER
 typedef void (*FwdTxfmFunc)(const int16_t *in, tran_low_t *out, int stride);
 typedef void (*InvTxfmFunc)(const tran_low_t *in, uint8_t *out, int stride);
 typedef std::tr1::tuple<FwdTxfmFunc, InvTxfmFunc, InvTxfmFunc, TX_SIZE, int>
     PartialInvTxfmParam;
 #if !CONFIG_ADAPT_SCAN
 const int kMaxNumCoeffs = 1024;
@@ -135,16 +126,23 @@ class AV1PartialIDctTest
   int last_nonzero_;
   TX_SIZE tx_size_;
   FwdTxfmFunc ftxfm_;
   InvTxfmFunc full_itxfm_;
   InvTxfmFunc partial_itxfm_;
 };
 
 #if !CONFIG_ADAPT_SCAN
+static MB_MODE_INFO get_mbmi() {
+  MB_MODE_INFO mbmi;
+  mbmi.ref_frame[0] = LAST_FRAME;
+  assert(is_inter_block(&mbmi));
+  return mbmi;
+}
+
 TEST_P(AV1PartialIDctTest, RunQuantCheck) {
   int size;
   switch (tx_size_) {
     case TX_4X4: size = 4; break;
     case TX_8X8: size = 8; break;
     case TX_16X16: size = 16; break;
     case TX_32X32: size = 32; break;
     default: FAIL() << "Wrong Size!"; break;
@@ -181,19 +179,20 @@ TEST_P(AV1PartialIDctTest, RunQuantCheck
           input_extreme_block[j] = rnd.Rand8() % 2 ? 255 : -255;
         }
       }
 
       ftxfm_(input_extreme_block, output_ref_block, size);
 
       // quantization with maximum allowed step sizes
       test_coef_block1[0] = (output_ref_block[0] / 1336) * 1336;
+      MB_MODE_INFO mbmi = get_mbmi();
       for (int j = 1; j < last_nonzero_; ++j)
         test_coef_block1[get_scan((const AV1_COMMON *)NULL, tx_size_, DCT_DCT,
-                                  0)
+                                  &mbmi)
                              ->scan[j]] = (output_ref_block[j] / 1828) * 1828;
     }
 
     ASM_REGISTER_STATE_CHECK(full_itxfm_(test_coef_block1, dst1, size));
     ASM_REGISTER_STATE_CHECK(partial_itxfm_(test_coef_block1, dst2, size));
 
     for (int j = 0; j < block_size; ++j) {
       const int diff = dst1[j] - dst2[j];
@@ -234,17 +233,19 @@ TEST_P(AV1PartialIDctTest, ResultsMatch)
     for (int j = 0; j < last_nonzero_; ++j) {
       int16_t coef = static_cast<int16_t>(sqrt(1.0 * max_energy_leftover) *
                                           (rnd.Rand16() - 32768) / 65536);
       max_energy_leftover -= coef * coef;
       if (max_energy_leftover < 0) {
         max_energy_leftover = 0;
         coef = 0;
       }
-      test_coef_block1[get_scan((const AV1_COMMON *)NULL, tx_size_, DCT_DCT, 0)
+      MB_MODE_INFO mbmi = get_mbmi();
+      test_coef_block1[get_scan((const AV1_COMMON *)NULL, tx_size_, DCT_DCT,
+                                &mbmi)
                            ->scan[j]] = coef;
     }
 
     memcpy(test_coef_block2, test_coef_block1,
            sizeof(*test_coef_block2) * block_size);
 
     ASM_REGISTER_STATE_CHECK(full_itxfm_(test_coef_block1, dst1, size));
     ASM_REGISTER_STATE_CHECK(partial_itxfm_(test_coef_block2, dst2, size));
new file mode 100644
--- /dev/null
+++ b/third_party/aom/test/block_error_test.cc
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2017, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
+
+#include "./aom_config.h"
+#include "./av1_rtcd.h"
+
+#include "test/acm_random.h"
+#include "test/clear_system_state.h"
+#include "test/register_state_check.h"
+#include "test/util.h"
+
+namespace {
+using libaom_test::ACMRandom;
+
+typedef int64_t (*BlockErrorFunc)(const tran_low_t *coeff,
+                                  const tran_low_t *dqcoeff, intptr_t size,
+                                  int64_t *ssz);
+#if CONFIG_HIGHBITDEPTH
+typedef int64_t (*HbdBlockErrorFunc)(const tran_low_t *coeff,
+                                     const tran_low_t *dqcoeff, intptr_t size,
+                                     int64_t *ssz, int bd);
+#endif
+
+typedef std::tr1::tuple<BlockErrorFunc, BlockErrorFunc, TX_SIZE,
+                        aom_bit_depth_t>
+    BlockErrorParam;
+
+const int kTestNum = 10000;
+
+class BlockErrorTest : public ::testing::TestWithParam<BlockErrorParam> {
+ public:
+  BlockErrorTest()
+      : blk_err_ref_(GET_PARAM(0)), blk_err_(GET_PARAM(1)),
+        tx_size_(GET_PARAM(2)), bd_(GET_PARAM(3)) {}
+
+  virtual ~BlockErrorTest() {}
+
+  virtual void SetUp() {
+    const intptr_t block_size = getCoeffNum();
+    coeff_ = reinterpret_cast<tran_low_t *>(
+        aom_memalign(16, 2 * block_size * sizeof(tran_low_t)));
+  }
+
+  virtual void TearDown() {
+    aom_free(coeff_);
+    coeff_ = NULL;
+    libaom_test::ClearSystemState();
+  }
+
+  void BlockErrorRun(int testNum) {
+    int i;
+    int64_t error_ref, error;
+    int64_t sse_ref, sse;
+    const intptr_t block_size = getCoeffNum();
+    tran_low_t *dqcoeff = coeff_ + block_size;
+    for (i = 0; i < testNum; ++i) {
+      FillRandomData();
+
+      error_ref = blk_err_ref_(coeff_, dqcoeff, block_size, &sse_ref);
+      ASM_REGISTER_STATE_CHECK(error =
+                                   blk_err_(coeff_, dqcoeff, block_size, &sse));
+
+      EXPECT_EQ(error_ref, error) << "Error doesn't match on test: " << i;
+      EXPECT_EQ(sse_ref, sse) << "SSE doesn't match on test: " << i;
+    }
+  }
+
+  intptr_t getCoeffNum() { return tx_size_2d[tx_size_]; }
+
+  void FillRandomData() {
+    const intptr_t block_size = getCoeffNum();
+    tran_low_t *dqcoeff = coeff_ + block_size;
+    intptr_t i;
+    int16_t margin = 512;
+    for (i = 0; i < block_size; ++i) {
+      coeff_[i] = GetRandomNumWithRange(INT16_MIN + margin, INT16_MAX - margin);
+      dqcoeff[i] = coeff_[i] + GetRandomDeltaWithRange(margin);
+    }
+  }
+
+  void FillConstantData() {
+    const intptr_t block_size = getCoeffNum();
+    tran_low_t *dqcoeff = coeff_ + block_size;
+    intptr_t i;
+    for (i = 0; i < block_size; ++i) {
+      coeff_[i] = 5;
+      dqcoeff[i] = 7;
+    }
+  }
+
+  tran_low_t GetRandomNumWithRange(int16_t min, int16_t max) {
+    return clamp((int16_t)rnd_.Rand16(), min, max);
+  }
+
+  tran_low_t GetRandomDeltaWithRange(int16_t delta) {
+    tran_low_t value = (int16_t)rnd_.Rand16();
+    value %= delta;
+    return value;
+  }
+
+  BlockErrorFunc blk_err_ref_;
+  BlockErrorFunc blk_err_;
+  TX_SIZE tx_size_;
+  aom_bit_depth_t bd_;
+  ACMRandom rnd_;
+  tran_low_t *coeff_;
+};
+
+TEST_P(BlockErrorTest, BitExact) { BlockErrorRun(kTestNum); }
+
+using std::tr1::make_tuple;
+
+#if !CONFIG_HIGHBITDEPTH && HAVE_SSE2
+const BlockErrorParam kBlkErrParamArraySse2[] = { make_tuple(
+    &av1_block_error_c, &av1_block_error_sse2, TX_32X32, AOM_BITS_8) };
+INSTANTIATE_TEST_CASE_P(SSE2, BlockErrorTest,
+                        ::testing::ValuesIn(kBlkErrParamArraySse2));
+#endif
+
+#if HAVE_AVX2
+const BlockErrorParam kBlkErrParamArrayAvx2[] = { make_tuple(
+    &av1_block_error_c, &av1_block_error_avx2, TX_32X32, AOM_BITS_8) };
+INSTANTIATE_TEST_CASE_P(AVX2, BlockErrorTest,
+                        ::testing::ValuesIn(kBlkErrParamArrayAvx2));
+#endif
+}  // namespace
--- a/third_party/aom/test/borders_test.cc
+++ b/third_party/aom/test/borders_test.cc
@@ -15,18 +15,18 @@
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
 #include "test/util.h"
 
 namespace {
 
 class BordersTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWithParam<libaom_test::TestMode> {
+    : public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>,
+      public ::libaom_test::EncoderTest {
  protected:
   BordersTest() : EncoderTest(GET_PARAM(0)) {}
   virtual ~BordersTest() {}
 
   virtual void SetUp() {
     InitializeConfig();
     SetMode(GET_PARAM(1));
   }
--- a/third_party/aom/test/cpu_speed_test.cc
+++ b/third_party/aom/test/cpu_speed_test.cc
@@ -16,18 +16,18 @@
 #include "test/util.h"
 #include "test/y4m_video_source.h"
 
 namespace {
 
 const int kMaxPSNR = 100;
 
 class CpuSpeedTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> {
+    : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
+      public ::libaom_test::EncoderTest {
  protected:
   CpuSpeedTest()
       : EncoderTest(GET_PARAM(0)), encoding_mode_(GET_PARAM(1)),
         set_cpu_used_(GET_PARAM(2)), min_psnr_(kMaxPSNR),
         tune_content_(AOM_CONTENT_DEFAULT) {}
   virtual ~CpuSpeedTest() {}
 
   virtual void SetUp() {
--- a/third_party/aom/test/datarate_test.cc
+++ b/third_party/aom/test/datarate_test.cc
@@ -16,18 +16,18 @@
 #include "test/i420_video_source.h"
 #include "test/util.h"
 #include "test/y4m_video_source.h"
 #include "aom/aom_codec.h"
 
 namespace {
 
 class DatarateTestLarge
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> {
+    : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
+      public ::libaom_test::EncoderTest {
  public:
   DatarateTestLarge() : EncoderTest(GET_PARAM(0)) {}
 
  protected:
   virtual ~DatarateTestLarge() {}
 
   virtual void SetUp() {
     InitializeConfig();
--- a/third_party/aom/test/dct16x16_test.cc
+++ b/third_party/aom/test/dct16x16_test.cc
@@ -221,51 +221,66 @@ void reference_16x16_dct_2d(int16_t inpu
     // Scale by some magic number
     for (int j = 0; j < 16; ++j) output[j + i * 16] = temp_out[j] / 2;
   }
 }
 
 typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride);
 typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride);
 typedef void (*FhtFunc)(const int16_t *in, tran_low_t *out, int stride,
-                        int tx_type);
+                        FWD_TXFM_PARAM *fwd_txfm_param);
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 
 typedef std::tr1::tuple<FdctFunc, IdctFunc, int, aom_bit_depth_t> Dct16x16Param;
 typedef std::tr1::tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t> Ht16x16Param;
 typedef std::tr1::tuple<IdctFunc, IdctFunc, int, aom_bit_depth_t>
     Idct16x16Param;
 
 void fdct16x16_ref(const int16_t *in, tran_low_t *out, int stride,
-                   int /*tx_type*/) {
+                   FWD_TXFM_PARAM *fwd_txfm_param) {
   aom_fdct16x16_c(in, out, stride);
 }
 
 void idct16x16_ref(const tran_low_t *in, uint8_t *dest, int stride,
-                   int /*tx_type*/) {
+                   const INV_TXFM_PARAM *inv_txfm_param) {
   aom_idct16x16_256_add_c(in, dest, stride);
 }
 
-void fht16x16_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht16x16_c(in, out, stride, tx_type);
+void fht16x16_ref(const int16_t *in, tran_low_t *out, int stride,
+                  FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht16x16_c(in, out, stride, fwd_txfm_param);
 }
 
 void iht16x16_ref(const tran_low_t *in, uint8_t *dest, int stride,
-                  int tx_type) {
-  av1_iht16x16_256_add_c(in, dest, stride, tx_type);
+                  const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_iht16x16_256_add_c(in, dest, stride, inv_txfm_param);
 }
 
 #if CONFIG_HIGHBITDEPTH
-void iht16x16_10(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_highbd_iht16x16_256_add_c(in, out, stride, tx_type, 10);
+void fht16x16_10(const int16_t *in, tran_low_t *out, int stride,
+                 FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fwd_txfm2d_16x16_c(in, out, stride, fwd_txfm_param->tx_type, 10);
+}
+
+void fht16x16_12(const int16_t *in, tran_low_t *out, int stride,
+                 FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fwd_txfm2d_16x16_c(in, out, stride, fwd_txfm_param->tx_type, 12);
 }
 
-void iht16x16_12(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_highbd_iht16x16_256_add_c(in, out, stride, tx_type, 12);
+void iht16x16_10(const tran_low_t *in, uint8_t *out, int stride,
+                 const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_inv_txfm2d_add_16x16_c(in, CONVERT_TO_SHORTPTR(out), stride,
+                             inv_txfm_param->tx_type, 10);
+}
+
+void iht16x16_12(const tran_low_t *in, uint8_t *out, int stride,
+                 const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_inv_txfm2d_add_16x16_c(in, CONVERT_TO_SHORTPTR(out), stride,
+                             inv_txfm_param->tx_type, 12);
 }
 #endif  // CONFIG_HIGHBITDEPTH
 
 class Trans16x16TestBase {
  public:
   virtual ~Trans16x16TestBase() {}
 
  protected:
@@ -341,17 +356,17 @@ class Trans16x16TestBase {
     DECLARE_ALIGNED(16, tran_low_t, output_ref_block[kNumCoeffs]);
     DECLARE_ALIGNED(16, tran_low_t, output_block[kNumCoeffs]);
 
     for (int i = 0; i < count_test_block; ++i) {
       // Initialize a test block with input range [-mask_, mask_].
       for (int j = 0; j < kNumCoeffs; ++j)
         input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
 
-      fwd_txfm_ref(input_block, output_ref_block, pitch_, tx_type_);
+      fwd_txfm_ref(input_block, output_ref_block, pitch_, &fwd_txfm_param_);
       ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_block, output_block, pitch_));
 
       // The minimum quant value is 4.
       for (int j = 0; j < kNumCoeffs; ++j)
         EXPECT_EQ(output_block[j], output_ref_block[j]);
     }
   }
 
@@ -368,17 +383,18 @@ class Trans16x16TestBase {
         input_extreme_block[j] = rnd.Rand8() % 2 ? mask_ : -mask_;
       }
       if (i == 0) {
         for (int j = 0; j < kNumCoeffs; ++j) input_extreme_block[j] = mask_;
       } else if (i == 1) {
         for (int j = 0; j < kNumCoeffs; ++j) input_extreme_block[j] = -mask_;
       }
 
-      fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_, tx_type_);
+      fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_,
+                   &fwd_txfm_param_);
       ASM_REGISTER_STATE_CHECK(
           RunFwdTxfm(input_extreme_block, output_block, pitch_));
 
       // The minimum quant value is 4.
       for (int j = 0; j < kNumCoeffs; ++j) {
         EXPECT_EQ(output_block[j], output_ref_block[j]);
         EXPECT_GE(4 * DCT_MAX_VALUE << (bit_depth_ - 8), abs(output_block[j]))
             << "Error: 16x16 FDCT has coefficient larger than 4*DCT_MAX_VALUE";
@@ -404,37 +420,38 @@ class Trans16x16TestBase {
       for (int j = 0; j < kNumCoeffs; ++j) {
         input_extreme_block[j] = rnd.Rand8() % 2 ? mask_ : -mask_;
       }
       if (i == 0)
         for (int j = 0; j < kNumCoeffs; ++j) input_extreme_block[j] = mask_;
       if (i == 1)
         for (int j = 0; j < kNumCoeffs; ++j) input_extreme_block[j] = -mask_;
 
-      fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_, tx_type_);
+      fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_,
+                   &fwd_txfm_param_);
 
       // clear reconstructed pixel buffers
       memset(dst, 0, kNumCoeffs * sizeof(uint8_t));
       memset(ref, 0, kNumCoeffs * sizeof(uint8_t));
 #if CONFIG_HIGHBITDEPTH
       memset(dst16, 0, kNumCoeffs * sizeof(uint16_t));
       memset(ref16, 0, kNumCoeffs * sizeof(uint16_t));
 #endif
 
       // quantization with maximum allowed step sizes
       output_ref_block[0] = (output_ref_block[0] / dc_thred) * dc_thred;
       for (int j = 1; j < kNumCoeffs; ++j)
         output_ref_block[j] = (output_ref_block[j] / ac_thred) * ac_thred;
       if (bit_depth_ == AOM_BITS_8) {
-        inv_txfm_ref(output_ref_block, ref, pitch_, tx_type_);
+        inv_txfm_ref(output_ref_block, ref, pitch_, &inv_txfm_param_);
         ASM_REGISTER_STATE_CHECK(RunInvTxfm(output_ref_block, dst, pitch_));
 #if CONFIG_HIGHBITDEPTH
       } else {
         inv_txfm_ref(output_ref_block, CONVERT_TO_BYTEPTR(ref16), pitch_,
-                     tx_type_);
+                     &inv_txfm_param_);
         ASM_REGISTER_STATE_CHECK(
             RunInvTxfm(output_ref_block, CONVERT_TO_BYTEPTR(dst16), pitch_));
 #endif
       }
       if (bit_depth_ == AOM_BITS_8) {
         for (int j = 0; j < kNumCoeffs; ++j) EXPECT_EQ(ref[j], dst[j]);
 #if CONFIG_HIGHBITDEPTH
       } else {
@@ -553,38 +570,40 @@ class Trans16x16TestBase {
         const uint32_t error = diff * diff;
         EXPECT_EQ(0u, error) << "Error: 16x16 IDCT Comparison has error "
                              << error << " at index " << j;
       }
     }
   }
 
   int pitch_;
-  int tx_type_;
   aom_bit_depth_t bit_depth_;
   int mask_;
   FhtFunc fwd_txfm_ref;
   IhtFunc inv_txfm_ref;
+  FWD_TXFM_PARAM fwd_txfm_param_;
+  INV_TXFM_PARAM inv_txfm_param_;
 };
 
 class Trans16x16DCT : public Trans16x16TestBase,
                       public ::testing::TestWithParam<Dct16x16Param> {
  public:
   virtual ~Trans16x16DCT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     bit_depth_ = GET_PARAM(3);
     pitch_ = 16;
     fwd_txfm_ref = fdct16x16_ref;
     inv_txfm_ref = idct16x16_ref;
     mask_ = (1 << bit_depth_) - 1;
     inv_txfm_ref = idct16x16_ref;
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(int16_t *in, tran_low_t *out, int stride) {
     fwd_txfm_(in, out, stride);
   }
   void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) {
@@ -612,40 +631,49 @@ TEST_P(Trans16x16DCT, InvAccuracyCheck) 
 class Trans16x16HT : public Trans16x16TestBase,
                      public ::testing::TestWithParam<Ht16x16Param> {
  public:
   virtual ~Trans16x16HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     bit_depth_ = GET_PARAM(3);
     pitch_ = 16;
-    fwd_txfm_ref = fht16x16_ref;
-    inv_txfm_ref = iht16x16_ref;
     mask_ = (1 << bit_depth_) - 1;
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
 #if CONFIG_HIGHBITDEPTH
     switch (bit_depth_) {
-      case AOM_BITS_10: inv_txfm_ref = iht16x16_10; break;
-      case AOM_BITS_12: inv_txfm_ref = iht16x16_12; break;
-      default: inv_txfm_ref = iht16x16_ref; break;
+      case AOM_BITS_10:
+        fwd_txfm_ref = fht16x16_10;
+        inv_txfm_ref = iht16x16_10;
+        break;
+      case AOM_BITS_12:
+        fwd_txfm_ref = fht16x16_12;
+        inv_txfm_ref = iht16x16_12;
+        break;
+      default:
+        fwd_txfm_ref = fht16x16_ref;
+        inv_txfm_ref = iht16x16_ref;
+        break;
     }
 #else
+    fwd_txfm_ref = fht16x16_ref;
     inv_txfm_ref = iht16x16_ref;
 #endif
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
   void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(Trans16x16HT, AccuracyCheck) { RunAccuracyCheck(); }
 
@@ -762,44 +790,36 @@ INSTANTIATE_TEST_CASE_P(C, Trans16x16DCT
                                                      &aom_idct16x16_256_add_c,
                                                      0, AOM_BITS_8)));
 #endif  // CONFIG_HIGHBITDEPTH
 
 #if CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(
     C, Trans16x16HT,
     ::testing::Values(
-        make_tuple(&av1_highbd_fht16x16_c, &iht16x16_10, 0, AOM_BITS_10),
-        make_tuple(&av1_highbd_fht16x16_c, &iht16x16_10, 1, AOM_BITS_10),
-        make_tuple(&av1_highbd_fht16x16_c, &iht16x16_10, 2, AOM_BITS_10),
-        make_tuple(&av1_highbd_fht16x16_c, &iht16x16_10, 3, AOM_BITS_10),
-        make_tuple(&av1_highbd_fht16x16_c, &iht16x16_12, 0, AOM_BITS_12),
-        make_tuple(&av1_highbd_fht16x16_c, &iht16x16_12, 1, AOM_BITS_12),
-        make_tuple(&av1_highbd_fht16x16_c, &iht16x16_12, 2, AOM_BITS_12),
-        make_tuple(&av1_highbd_fht16x16_c, &iht16x16_12, 3, AOM_BITS_12),
+        make_tuple(&fht16x16_10, &iht16x16_10, 0, AOM_BITS_10),
+        make_tuple(&fht16x16_10, &iht16x16_10, 1, AOM_BITS_10),
+        make_tuple(&fht16x16_10, &iht16x16_10, 2, AOM_BITS_10),
+        make_tuple(&fht16x16_10, &iht16x16_10, 3, AOM_BITS_10),
+        make_tuple(&fht16x16_12, &iht16x16_12, 0, AOM_BITS_12),
+        make_tuple(&fht16x16_12, &iht16x16_12, 1, AOM_BITS_12),
+        make_tuple(&fht16x16_12, &iht16x16_12, 2, AOM_BITS_12),
+        make_tuple(&fht16x16_12, &iht16x16_12, 3, AOM_BITS_12),
         make_tuple(&av1_fht16x16_c, &av1_iht16x16_256_add_c, 0, AOM_BITS_8),
         make_tuple(&av1_fht16x16_c, &av1_iht16x16_256_add_c, 1, AOM_BITS_8),
         make_tuple(&av1_fht16x16_c, &av1_iht16x16_256_add_c, 2, AOM_BITS_8),
         make_tuple(&av1_fht16x16_c, &av1_iht16x16_256_add_c, 3, AOM_BITS_8)));
-INSTANTIATE_TEST_CASE_P(
-    C, PartialTrans16x16Test,
-    ::testing::Values(make_tuple(&aom_highbd_fdct16x16_1_c, AOM_BITS_8),
-                      make_tuple(&aom_highbd_fdct16x16_1_c, AOM_BITS_10),
-                      make_tuple(&aom_highbd_fdct16x16_1_c, AOM_BITS_12)));
 #else
 INSTANTIATE_TEST_CASE_P(
     C, Trans16x16HT,
     ::testing::Values(
         make_tuple(&av1_fht16x16_c, &av1_iht16x16_256_add_c, 0, AOM_BITS_8),
         make_tuple(&av1_fht16x16_c, &av1_iht16x16_256_add_c, 1, AOM_BITS_8),
         make_tuple(&av1_fht16x16_c, &av1_iht16x16_256_add_c, 2, AOM_BITS_8),
         make_tuple(&av1_fht16x16_c, &av1_iht16x16_256_add_c, 3, AOM_BITS_8)));
-INSTANTIATE_TEST_CASE_P(C, PartialTrans16x16Test,
-                        ::testing::Values(make_tuple(&aom_fdct16x16_1_c,
-                                                     AOM_BITS_8)));
 #endif  // CONFIG_HIGHBITDEPTH
 
 #if HAVE_NEON_ASM && !CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(
     NEON, Trans16x16DCT,
     ::testing::Values(make_tuple(&aom_fdct16x16_c, &aom_idct16x16_256_add_neon,
                                  0, AOM_BITS_8)));
 #endif
@@ -814,48 +834,31 @@ INSTANTIATE_TEST_CASE_P(
     ::testing::Values(make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2,
                                  0, AOM_BITS_8),
                       make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2,
                                  1, AOM_BITS_8),
                       make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2,
                                  2, AOM_BITS_8),
                       make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2,
                                  3, AOM_BITS_8)));
-INSTANTIATE_TEST_CASE_P(SSE2, PartialTrans16x16Test,
-                        ::testing::Values(make_tuple(&aom_fdct16x16_1_sse2,
-                                                     AOM_BITS_8)));
 #endif  // HAVE_SSE2 && !CONFIG_HIGHBITDEPTH
 
-#if HAVE_AVX2 && !CONFIG_HIGHBITDEPTH
-INSTANTIATE_TEST_CASE_P(AVX2, PartialTrans16x16Test,
-                        ::testing::Values(make_tuple(&aom_fdct16x16_1_avx2,
-                                                     AOM_BITS_8)));
-#endif  // HAVE_AVX2 && !CONFIG_HIGHBITDEPTH
-
 #if HAVE_SSE2 && CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(SSE2, Trans16x16DCT,
                         ::testing::Values(make_tuple(&aom_fdct16x16_sse2,
                                                      &aom_idct16x16_256_add_c,
                                                      0, AOM_BITS_8)));
 INSTANTIATE_TEST_CASE_P(
     SSE2, Trans16x16HT,
     ::testing::Values(
         make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_c, 0, AOM_BITS_8),
         make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_c, 1, AOM_BITS_8),
         make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_c, 2, AOM_BITS_8),
         make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_c, 3,
                    AOM_BITS_8)));
-// TODO(luoyi):
-// For this test case, we should test function: aom_highbd_fdct16x16_1_sse2.
-// However this function is not available yet. if we mistakely test
-// aom_fdct16x16_1_sse2, it could only pass AOM_BITS_8/AOM_BITS_10 but not
-// AOM_BITS_12.
-INSTANTIATE_TEST_CASE_P(SSE2, PartialTrans16x16Test,
-                        ::testing::Values(make_tuple(&aom_fdct16x16_1_sse2,
-                                                     AOM_BITS_8)));
 #endif  // HAVE_SSE2 && CONFIG_HIGHBITDEPTH
 
 #if HAVE_MSA && !CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(MSA, Trans16x16DCT,
                         ::testing::Values(make_tuple(&aom_fdct16x16_msa,
                                                      &aom_idct16x16_256_add_msa,
                                                      0, AOM_BITS_8)));
 #if !CONFIG_EXT_TX
@@ -864,13 +867,10 @@ INSTANTIATE_TEST_CASE_P(
     DISABLED_MSA, Trans16x16HT,
     ::testing::Values(
         make_tuple(&av1_fht16x16_msa, &av1_iht16x16_256_add_msa, 0, AOM_BITS_8),
         make_tuple(&av1_fht16x16_msa, &av1_iht16x16_256_add_msa, 1, AOM_BITS_8),
         make_tuple(&av1_fht16x16_msa, &av1_iht16x16_256_add_msa, 2, AOM_BITS_8),
         make_tuple(&av1_fht16x16_msa, &av1_iht16x16_256_add_msa, 3,
                    AOM_BITS_8)));
 #endif  // !CONFIG_EXT_TX
-INSTANTIATE_TEST_CASE_P(MSA, PartialTrans16x16Test,
-                        ::testing::Values(make_tuple(&aom_fdct16x16_1_msa,
-                                                     AOM_BITS_8)));
 #endif  // HAVE_MSA && !CONFIG_HIGHBITDEPTH
 }  // namespace
--- a/third_party/aom/test/dct32x32_test.cc
+++ b/third_party/aom/test/dct32x32_test.cc
@@ -345,31 +345,23 @@ using std::tr1::make_tuple;
 
 #if CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(
     C, Trans32x32Test,
     ::testing::Values(make_tuple(&aom_fdct32x32_c, &aom_idct32x32_1024_add_c, 0,
                                  AOM_BITS_8),
                       make_tuple(&aom_fdct32x32_rd_c, &aom_idct32x32_1024_add_c,
                                  1, AOM_BITS_8)));
-INSTANTIATE_TEST_CASE_P(
-    C, PartialTrans32x32Test,
-    ::testing::Values(make_tuple(&aom_highbd_fdct32x32_1_c, AOM_BITS_8),
-                      make_tuple(&aom_highbd_fdct32x32_1_c, AOM_BITS_10),
-                      make_tuple(&aom_highbd_fdct32x32_1_c, AOM_BITS_12)));
 #else
 INSTANTIATE_TEST_CASE_P(
     C, Trans32x32Test,
     ::testing::Values(make_tuple(&aom_fdct32x32_c, &aom_idct32x32_1024_add_c, 0,
                                  AOM_BITS_8),
                       make_tuple(&aom_fdct32x32_rd_c, &aom_idct32x32_1024_add_c,
                                  1, AOM_BITS_8)));
-INSTANTIATE_TEST_CASE_P(C, PartialTrans32x32Test,
-                        ::testing::Values(make_tuple(&aom_fdct32x32_1_c,
-                                                     AOM_BITS_8)));
 #endif  // CONFIG_HIGHBITDEPTH
 
 #if HAVE_NEON && !CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(
     NEON, Trans32x32Test,
     ::testing::Values(make_tuple(&aom_fdct32x32_c, &aom_idct32x32_1024_add_neon,
                                  0, AOM_BITS_8),
                       make_tuple(&aom_fdct32x32_rd_c,
@@ -378,37 +370,25 @@ INSTANTIATE_TEST_CASE_P(
 
 #if HAVE_SSE2 && !CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(
     SSE2, Trans32x32Test,
     ::testing::Values(make_tuple(&aom_fdct32x32_sse2,
                                  &aom_idct32x32_1024_add_sse2, 0, AOM_BITS_8),
                       make_tuple(&aom_fdct32x32_rd_sse2,
                                  &aom_idct32x32_1024_add_sse2, 1, AOM_BITS_8)));
-INSTANTIATE_TEST_CASE_P(SSE2, PartialTrans32x32Test,
-                        ::testing::Values(make_tuple(&aom_fdct32x32_1_sse2,
-                                                     AOM_BITS_8)));
 #endif  // HAVE_SSE2 && !CONFIG_HIGHBITDEPTH
 
-#if HAVE_AVX2 && !CONFIG_HIGHBITDEPTH
-INSTANTIATE_TEST_CASE_P(AVX2, PartialTrans32x32Test,
-                        ::testing::Values(make_tuple(&aom_fdct32x32_1_avx2,
-                                                     AOM_BITS_8)));
-#endif  // HAVE_AVX2 && !CONFIG_HIGHBITDEPTH
-
 #if HAVE_SSE2 && CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(
     SSE2, Trans32x32Test,
     ::testing::Values(make_tuple(&aom_fdct32x32_sse2, &aom_idct32x32_1024_add_c,
                                  0, AOM_BITS_8),
                       make_tuple(&aom_fdct32x32_rd_sse2,
                                  &aom_idct32x32_1024_add_c, 1, AOM_BITS_8)));
-INSTANTIATE_TEST_CASE_P(SSE2, PartialTrans32x32Test,
-                        ::testing::Values(make_tuple(&aom_fdct32x32_1_sse2,
-                                                     AOM_BITS_8)));
 #endif  // HAVE_SSE2 && CONFIG_HIGHBITDEPTH
 
 #if HAVE_AVX2 && !CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(
     AVX2, Trans32x32Test,
     ::testing::Values(make_tuple(&aom_fdct32x32_avx2,
                                  &aom_idct32x32_1024_add_sse2, 0, AOM_BITS_8),
                       make_tuple(&aom_fdct32x32_rd_avx2,
@@ -426,13 +406,10 @@ INSTANTIATE_TEST_CASE_P(
 
 #if HAVE_MSA && !CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(
     MSA, Trans32x32Test,
     ::testing::Values(make_tuple(&aom_fdct32x32_msa,
                                  &aom_idct32x32_1024_add_msa, 0, AOM_BITS_8),
                       make_tuple(&aom_fdct32x32_rd_msa,
                                  &aom_idct32x32_1024_add_msa, 1, AOM_BITS_8)));
-INSTANTIATE_TEST_CASE_P(MSA, PartialTrans32x32Test,
-                        ::testing::Values(make_tuple(&aom_fdct32x32_1_msa,
-                                                     AOM_BITS_8)));
 #endif  // HAVE_MSA && !CONFIG_HIGHBITDEPTH
 }  // namespace
--- a/third_party/aom/test/decode_perf_test.cc
+++ b/third_party/aom/test/decode_perf_test.cc
@@ -58,16 +58,17 @@ TEST_P(DecodePerfTest, PerfTest) {
   const char *const video_name = GET_PARAM(VIDEO_NAME);
   const unsigned threads = GET_PARAM(THREADS);
 
   libaom_test::WebMVideoSource video(video_name);
   video.Init();
 
   aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t();
   cfg.threads = threads;
+  cfg.allow_lowbitdepth = 1;
   libaom_test::AV1Decoder decoder(cfg, 0);
 
   aom_usec_timer t;
   aom_usec_timer_start(&t);
 
   for (video.Begin(); video.cxdata() != NULL; video.Next()) {
     decoder.DecodeFrame(video.cxdata(), video.frame_size());
   }
@@ -88,18 +89,18 @@ TEST_P(DecodePerfTest, PerfTest) {
   printf("}\n");
 }
 
 // TODO(jimbankoski): Enabled when we have actual AV1 Decode vectors.
 // INSTANTIATE_TEST_CASE_P(AV1, DecodePerfTest,
 //                        ::testing::ValuesIn(kAV1DecodePerfVectors));
 
 class AV1NewEncodeDecodePerfTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWithParam<libaom_test::TestMode> {
+    : public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>,
+      public ::libaom_test::EncoderTest {
  protected:
   AV1NewEncodeDecodePerfTest()
       : EncoderTest(GET_PARAM(0)), encoding_mode_(GET_PARAM(1)), speed_(0),
         outfile_(0), out_frames_(0) {}
 
   virtual ~AV1NewEncodeDecodePerfTest() {}
 
   virtual void SetUp() {
@@ -110,17 +111,16 @@ class AV1NewEncodeDecodePerfTest
     cfg_.rc_min_quantizer = 2;
     cfg_.rc_max_quantizer = 56;
     cfg_.rc_dropframe_thresh = 0;
     cfg_.rc_undershoot_pct = 50;
     cfg_.rc_overshoot_pct = 50;
     cfg_.rc_buf_sz = 1000;
     cfg_.rc_buf_initial_sz = 500;
     cfg_.rc_buf_optimal_sz = 600;
-    cfg_.rc_resize_allowed = 0;
     cfg_.rc_end_usage = AOM_VBR;
   }
 
   virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
                                   ::libaom_test::Encoder *encoder) {
     if (video->frame() == 1) {
       encoder->Control(AOME_SET_CPUUSED, speed_);
       encoder->Control(AV1E_SET_FRAME_PARALLEL_DECODING, 1);
@@ -206,16 +206,17 @@ TEST_P(AV1NewEncodeDecodePerfTest, PerfT
 
   const uint32_t threads = 4;
 
   libaom_test::IVFVideoSource decode_video(kNewEncodeOutputFile);
   decode_video.Init();
 
   aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t();
   cfg.threads = threads;
+  cfg.allow_lowbitdepth = 1;
   libaom_test::AV1Decoder decoder(cfg, 0);
 
   aom_usec_timer t;
   aom_usec_timer_start(&t);
 
   for (decode_video.Begin(); decode_video.cxdata() != NULL;
        decode_video.Next()) {
     decoder.DecodeFrame(decode_video.cxdata(), decode_video.frame_size());
--- a/third_party/aom/test/encode_perf_test.cc
+++ b/third_party/aom/test/encode_perf_test.cc
@@ -51,18 +51,18 @@ const EncodePerfTestVideo kAV1EncodePerf
 };
 
 const int kEncodePerfTestSpeeds[] = { 5, 6, 7, 8 };
 const int kEncodePerfTestThreads[] = { 1, 2, 4 };
 
 #define NELEMENTS(x) (sizeof((x)) / sizeof((x)[0]))
 
 class AV1EncodePerfTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWithParam<libaom_test::TestMode> {
+    : public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>,
+      public ::libaom_test::EncoderTest {
  protected:
   AV1EncodePerfTest()
       : EncoderTest(GET_PARAM(0)), min_psnr_(kMaxPsnr), nframes_(0),
         encoding_mode_(GET_PARAM(1)), speed_(0), threads_(1) {}
 
   virtual ~AV1EncodePerfTest() {}
 
   virtual void SetUp() {
@@ -73,17 +73,16 @@ class AV1EncodePerfTest
     cfg_.rc_min_quantizer = 2;
     cfg_.rc_max_quantizer = 56;
     cfg_.rc_dropframe_thresh = 0;
     cfg_.rc_undershoot_pct = 50;
     cfg_.rc_overshoot_pct = 50;
     cfg_.rc_buf_sz = 1000;
     cfg_.rc_buf_initial_sz = 500;
     cfg_.rc_buf_optimal_sz = 600;
-    cfg_.rc_resize_allowed = 0;
     cfg_.rc_end_usage = AOM_CBR;
     cfg_.g_error_resilient = 1;
     cfg_.g_threads = threads_;
   }
 
   virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
                                   ::libaom_test::Encoder *encoder) {
     if (video->frame() == 0) {
--- a/third_party/aom/test/encode_test_driver.cc
+++ b/third_party/aom/test/encode_test_driver.cc
@@ -94,17 +94,16 @@ void Encoder::Flush() {
   if (!encoder_.priv)
     ASSERT_EQ(AOM_CODEC_ERROR, res) << EncoderError();
   else
     ASSERT_EQ(AOM_CODEC_OK, res) << EncoderError();
 }
 
 void EncoderTest::InitializeConfig() {
   const aom_codec_err_t res = codec_->DefaultEncoderConfig(&cfg_, 0);
-  dec_cfg_ = aom_codec_dec_cfg_t();
   ASSERT_EQ(AOM_CODEC_OK, res);
 }
 
 void EncoderTest::SetMode(TestMode mode) {
   switch (mode) {
     case kOnePassGood:
     case kTwoPassGood: deadline_ = AOM_DL_GOOD_QUALITY; break;
     case kRealTime:
@@ -206,16 +205,17 @@ void EncoderTest::MismatchHook(const aom
                << mismatch_pix_dec << std::endl
                << "                plane: " << mismatch_plane << std::endl
                << "              row/col: " << mismatch_row << "/"
                << mismatch_col << std::endl;
 }
 
 void EncoderTest::RunLoop(VideoSource *video) {
   aom_codec_dec_cfg_t dec_cfg = aom_codec_dec_cfg_t();
+  dec_cfg.allow_lowbitdepth = 1;
 
   stats_.Reset();
 
   ASSERT_TRUE(passes_ == 1 || passes_ == 2);
   for (unsigned int pass = 0; pass < passes_; pass++) {
     last_pts_ = 0;
 
     if (passes_ == 1)
--- a/third_party/aom/test/encode_test_driver.h
+++ b/third_party/aom/test/encode_test_driver.h
@@ -227,17 +227,16 @@ class EncoderTest {
   // Hook that can modify the encoder's output data
   virtual const aom_codec_cx_pkt_t *MutateEncoderOutputHook(
       const aom_codec_cx_pkt_t *pkt) {
     return pkt;
   }
 
   bool abort_;
   aom_codec_enc_cfg_t cfg_;
-  aom_codec_dec_cfg_t dec_cfg_;
   unsigned int passes_;
   unsigned long deadline_;
   TwopassStatsStore stats_;
   unsigned long init_flags_;
   unsigned long frame_flags_;
   aom_codec_pts_t last_pts_;
   TestMode mode_;
 };
--- a/third_party/aom/test/encoder_parms_get_to_decoder.cc
+++ b/third_party/aom/test/encoder_parms_get_to_decoder.cc
@@ -36,32 +36,41 @@ const EncodePerfTestVideo kAV1EncodePerf
 struct EncodeParameters {
   int32_t tile_rows;
   int32_t tile_cols;
   int32_t lossless;
   int32_t error_resilient;
   int32_t frame_parallel;
   aom_color_range_t color_range;
   aom_color_space_t cs;
+#if CONFIG_COLORSPACE_HEADERS
+  aom_transfer_function_t tf;
+  aom_chroma_sample_position_t csp;
+#endif
   int render_size[2];
   // TODO(JBB): quantizers / bitrate
 };
 
 const EncodeParameters kAV1EncodeParameterSet[] = {
   { 0, 0, 0, 1, 0, AOM_CR_STUDIO_RANGE, AOM_CS_BT_601, { 0, 0 } },
   { 0, 0, 0, 0, 0, AOM_CR_FULL_RANGE, AOM_CS_BT_709, { 0, 0 } },
+#if CONFIG_COLORSPACE_HEADERS
+  { 0, 0, 1, 0, 0, AOM_CR_FULL_RANGE, AOM_CS_BT_2020_NCL, { 0, 0 } },
+#else
   { 0, 0, 1, 0, 0, AOM_CR_FULL_RANGE, AOM_CS_BT_2020, { 0, 0 } },
+#endif
   { 0, 2, 0, 0, 1, AOM_CR_STUDIO_RANGE, AOM_CS_UNKNOWN, { 640, 480 } },
   // TODO(JBB): Test profiles (requires more work).
 };
 
 class AvxEncoderParmsGetToDecoder
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith2Params<EncodeParameters,
-                                                 EncodePerfTestVideo> {
+    : public ::libaom_test::CodecTestWith2Params<EncodeParameters,
+                                                 EncodePerfTestVideo>,
+      public ::libaom_test::EncoderTest,
+{
  protected:
   AvxEncoderParmsGetToDecoder()
       : EncoderTest(GET_PARAM(0)), encode_parms(GET_PARAM(1)) {}
 
   virtual ~AvxEncoderParmsGetToDecoder() {}
 
   virtual void SetUp() {
     InitializeConfig();
@@ -72,16 +81,20 @@ class AvxEncoderParmsGetToDecoder
     test_video_ = GET_PARAM(2);
     cfg_.rc_target_bitrate = test_video_.bitrate;
   }
 
   virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
                                   ::libaom_test::Encoder *encoder) {
     if (video->frame() == 1) {
       encoder->Control(AV1E_SET_COLOR_SPACE, encode_parms.cs);
+#if CONFIG_COLORSPACE_HEADERS
+      encoder->Control(AV1E_SET_TRANSFER_FUNCTION, encode_parms.tf);
+      encoder->Control(AV1E_SET_CHROMA_SAMPLE_POSITION, encode_parms.csp);
+#endif
       encoder->Control(AV1E_SET_COLOR_RANGE, encode_parms.color_range);
       encoder->Control(AV1E_SET_LOSSLESS, encode_parms.lossless);
       encoder->Control(AV1E_SET_FRAME_PARALLEL_DECODING,
                        encode_parms.frame_parallel);
       encoder->Control(AV1E_SET_TILE_ROWS, encode_parms.tile_rows);
       encoder->Control(AV1E_SET_TILE_COLUMNS, encode_parms.tile_cols);
       encoder->Control(AOME_SET_CPUUSED, kCpuUsed);
       encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1);
@@ -109,16 +122,20 @@ class AvxEncoderParmsGetToDecoder
       EXPECT_EQ(ONLY_4X4, common->tx_mode);
     }
     EXPECT_EQ(encode_parms.error_resilient, common->error_resilient_mode);
     if (encode_parms.error_resilient) {
       EXPECT_EQ(0, common->use_prev_frame_mvs);
     }
     EXPECT_EQ(encode_parms.color_range, common->color_range);
     EXPECT_EQ(encode_parms.cs, common->color_space);
+#if CONFIG_COLORSPACE_HEADERS
+    EXPECT_EQ(encode_parms.tf, common->transfer_function);
+    EXPECT_EQ(encode_parms.csp, common->chroma_sample_position);
+#endif
     if (encode_parms.render_size[0] > 0 && encode_parms.render_size[1] > 0) {
       EXPECT_EQ(encode_parms.render_size[0], common->render_width);
       EXPECT_EQ(encode_parms.render_size[1], common->render_height);
     }
     EXPECT_EQ(encode_parms.tile_cols, common->log2_tile_cols);
     EXPECT_EQ(encode_parms.tile_rows, common->log2_tile_rows);
 
     EXPECT_EQ(AOM_CODEC_OK, res_dec) << decoder->DecodeError();
--- a/third_party/aom/test/end_to_end_test.cc
+++ b/third_party/aom/test/end_to_end_test.cc
@@ -81,19 +81,19 @@ int is_extension_y4m(const char *filenam
   const char *dot = strrchr(filename, '.');
   if (!dot || dot == filename)
     return 0;
   else
     return !strcmp(dot, ".y4m");
 }
 
 class EndToEndTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith3Params<libaom_test::TestMode,
-                                                 TestVideoParam, int> {
+    : public ::libaom_test::CodecTestWith3Params<libaom_test::TestMode,
+                                                 TestVideoParam, int>,
+      public ::libaom_test::EncoderTest {
  protected:
   EndToEndTest()
       : EncoderTest(GET_PARAM(0)), test_video_param_(GET_PARAM(2)),
         cpu_used_(GET_PARAM(3)), psnr_(0.0), nframes_(0),
         encoding_mode_(GET_PARAM(1)) {}
 
   virtual ~EndToEndTest() {}
 
@@ -105,17 +105,16 @@ class EndToEndTest
       cfg_.rc_end_usage = AOM_VBR;
     } else {
       cfg_.g_lag_in_frames = 0;
       cfg_.rc_end_usage = AOM_CBR;
       cfg_.rc_buf_sz = 1000;
       cfg_.rc_buf_initial_sz = 500;
       cfg_.rc_buf_optimal_sz = 600;
     }
-    dec_cfg_.threads = 4;
   }
 
   virtual void BeginPassHook(unsigned int) {
     psnr_ = 0.0;
     nframes_ = 0;
   }
 
   virtual void PSNRPktHook(const aom_codec_cx_pkt_t *pkt) {
--- a/third_party/aom/test/error_resilience_test.cc
+++ b/third_party/aom/test/error_resilience_test.cc
@@ -16,18 +16,18 @@
 #include "test/util.h"
 
 namespace {
 
 const int kMaxErrorFrames = 12;
 const int kMaxDroppableFrames = 12;
 
 class ErrorResilienceTestLarge
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWithParam<libaom_test::TestMode> {
+    : public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>,
+      public ::libaom_test::EncoderTest {
  protected:
   ErrorResilienceTestLarge()
       : EncoderTest(GET_PARAM(0)), psnr_(0.0), nframes_(0), mismatch_psnr_(0.0),
         mismatch_nframes_(0), encoding_mode_(GET_PARAM(1)) {
     Reset();
   }
 
   virtual ~ErrorResilienceTestLarge() {}
--- a/third_party/aom/test/ethread_test.cc
+++ b/third_party/aom/test/ethread_test.cc
@@ -15,26 +15,27 @@
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/md5_helper.h"
 #include "test/util.h"
 #include "test/y4m_video_source.h"
 
 namespace {
 class AVxEncoderThreadTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> {
+    : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
+      public ::libaom_test::EncoderTest {
  protected:
   AVxEncoderThreadTest()
       : EncoderTest(GET_PARAM(0)), encoder_initialized_(false),
         encoding_mode_(GET_PARAM(1)), set_cpu_used_(GET_PARAM(2)) {
     init_flags_ = AOM_CODEC_USE_PSNR;
     aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t();
     cfg.w = 1280;
     cfg.h = 720;
+    cfg.allow_lowbitdepth = 1;
     decoder_ = codec_->CreateDecoder(cfg, 0);
 #if CONFIG_AV1 && CONFIG_EXT_TILE
     if (decoder_->IsAV1()) {
       decoder_->Control(AV1_SET_DECODE_TILE_ROW, -1);
       decoder_->Control(AV1_SET_DECODE_TILE_COL, -1);
     }
 #endif
 
--- a/third_party/aom/test/fdct4x4_test.cc
+++ b/third_party/aom/test/fdct4x4_test.cc
@@ -28,88 +28,86 @@
 #include "aom_ports/mem.h"
 
 using libaom_test::ACMRandom;
 
 namespace {
 typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride);
 typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride);
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 using libaom_test::FhtFunc;
 
 typedef std::tr1::tuple<FdctFunc, IdctFunc, int, aom_bit_depth_t, int>
     Dct4x4Param;
 typedef std::tr1::tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht4x4Param;
 
 void fdct4x4_ref(const int16_t *in, tran_low_t *out, int stride,
-                 int /*tx_type*/) {
+                 FWD_TXFM_PARAM *fwd_txfm_param) {
   aom_fdct4x4_c(in, out, stride);
 }
 
-void fht4x4_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht4x4_c(in, out, stride, tx_type);
+void fht4x4_ref(const int16_t *in, tran_low_t *out, int stride,
+                FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht4x4_c(in, out, stride, fwd_txfm_param);
 }
 
 void fwht4x4_ref(const int16_t *in, tran_low_t *out, int stride,
-                 int /*tx_type*/) {
+                 FWD_TXFM_PARAM *fwd_txfm_param) {
   av1_fwht4x4_c(in, out, stride);
 }
 
 #if CONFIG_HIGHBITDEPTH
-void idct4x4_10(const tran_low_t *in, uint8_t *out, int stride) {
-  aom_highbd_idct4x4_16_add_c(in, out, stride, 10);
+void fht4x4_10(const int16_t *in, tran_low_t *out, int stride,
+               FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fwd_txfm2d_4x4_c(in, out, stride, fwd_txfm_param->tx_type, 10);
+}
+
+void fht4x4_12(const int16_t *in, tran_low_t *out, int stride,
+               FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fwd_txfm2d_4x4_c(in, out, stride, fwd_txfm_param->tx_type, 12);
 }
 
-void idct4x4_12(const tran_low_t *in, uint8_t *out, int stride) {
-  aom_highbd_idct4x4_16_add_c(in, out, stride, 12);
+void iht4x4_10(const tran_low_t *in, uint8_t *out, int stride,
+               const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_inv_txfm2d_add_4x4_c(in, CONVERT_TO_SHORTPTR(out), stride,
+                           inv_txfm_param->tx_type, 10);
 }
 
-void iht4x4_10(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_highbd_iht4x4_16_add_c(in, out, stride, tx_type, 10);
-}
-
-void iht4x4_12(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_highbd_iht4x4_16_add_c(in, out, stride, tx_type, 12);
+void iht4x4_12(const tran_low_t *in, uint8_t *out, int stride,
+               const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_inv_txfm2d_add_4x4_c(in, CONVERT_TO_SHORTPTR(out), stride,
+                           inv_txfm_param->tx_type, 12);
 }
 
 void iwht4x4_10(const tran_low_t *in, uint8_t *out, int stride) {
   aom_highbd_iwht4x4_16_add_c(in, out, stride, 10);
 }
 
 void iwht4x4_12(const tran_low_t *in, uint8_t *out, int stride) {
   aom_highbd_iwht4x4_16_add_c(in, out, stride, 12);
 }
-
-#if HAVE_SSE2
-void idct4x4_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
-  aom_highbd_idct4x4_16_add_sse2(in, out, stride, 10);
-}
-
-void idct4x4_12_sse2(const tran_low_t *in, uint8_t *out, int stride) {
-  aom_highbd_idct4x4_16_add_sse2(in, out, stride, 12);
-}
-#endif  // HAVE_SSE2
 #endif  // CONFIG_HIGHBITDEPTH
 
 class Trans4x4DCT : public libaom_test::TransformTestBase,
                     public ::testing::TestWithParam<Dct4x4Param> {
  public:
   virtual ~Trans4x4DCT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 4;
     height_ = 4;
     fwd_txfm_ref = fdct4x4_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
     fwd_txfm_(in, out, stride);
   }
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
@@ -131,33 +129,41 @@ TEST_P(Trans4x4DCT, InvAccuracyCheck) { 
 class Trans4x4HT : public libaom_test::TransformTestBase,
                    public ::testing::TestWithParam<Ht4x4Param> {
  public:
   virtual ~Trans4x4HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 4;
     height_ = 4;
     fwd_txfm_ref = fht4x4_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+#if CONFIG_HIGHBITDEPTH
+    switch (bit_depth_) {
+      case AOM_BITS_10: fwd_txfm_ref = fht4x4_10; break;
+      case AOM_BITS_12: fwd_txfm_ref = fht4x4_12; break;
+      default: fwd_txfm_ref = fht4x4_ref; break;
+    }
+#endif
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
 
   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(Trans4x4HT, AccuracyCheck) { RunAccuracyCheck(1, 0.005); }
 
@@ -170,17 +176,16 @@ TEST_P(Trans4x4HT, InvAccuracyCheck) { R
 class Trans4x4WHT : public libaom_test::TransformTestBase,
                     public ::testing::TestWithParam<Dct4x4Param> {
  public:
   virtual ~Trans4x4WHT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 4;
     height_ = 4;
     fwd_txfm_ref = fwht4x4_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
     num_coeffs_ = GET_PARAM(4);
   }
   virtual void TearDown() { libaom_test::ClearSystemState(); }
@@ -201,42 +206,36 @@ TEST_P(Trans4x4WHT, AccuracyCheck) { Run
 
 TEST_P(Trans4x4WHT, CoeffCheck) { RunCoeffCheck(); }
 
 TEST_P(Trans4x4WHT, MemCheck) { RunMemCheck(); }
 
 TEST_P(Trans4x4WHT, InvAccuracyCheck) { RunInvAccuracyCheck(0); }
 using std::tr1::make_tuple;
 
-#if CONFIG_HIGHBITDEPTH
-INSTANTIATE_TEST_CASE_P(
-    C, Trans4x4DCT,
-    ::testing::Values(
-        make_tuple(&aom_highbd_fdct4x4_c, &idct4x4_10, 0, AOM_BITS_10, 16),
-        make_tuple(&aom_highbd_fdct4x4_c, &idct4x4_12, 0, AOM_BITS_12, 16),
-        make_tuple(&aom_fdct4x4_c, &aom_idct4x4_16_add_c, 0, AOM_BITS_8, 16)));
-#else
 INSTANTIATE_TEST_CASE_P(C, Trans4x4DCT,
                         ::testing::Values(make_tuple(&aom_fdct4x4_c,
                                                      &aom_idct4x4_16_add_c, 0,
                                                      AOM_BITS_8, 16)));
-#endif  // CONFIG_HIGHBITDEPTH
 
 #if CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(
+    DISABLED_C, Trans4x4HT,
+    ::testing::Values(make_tuple(&fht4x4_12, &iht4x4_12, 0, AOM_BITS_12, 16),
+                      make_tuple(&fht4x4_12, &iht4x4_12, 1, AOM_BITS_12, 16),
+                      make_tuple(&fht4x4_12, &iht4x4_12, 2, AOM_BITS_12, 16),
+                      make_tuple(&fht4x4_12, &iht4x4_12, 3, AOM_BITS_12, 16)));
+
+INSTANTIATE_TEST_CASE_P(
     C, Trans4x4HT,
     ::testing::Values(
-        make_tuple(&av1_highbd_fht4x4_c, &iht4x4_10, 0, AOM_BITS_10, 16),
-        make_tuple(&av1_highbd_fht4x4_c, &iht4x4_10, 1, AOM_BITS_10, 16),
-        make_tuple(&av1_highbd_fht4x4_c, &iht4x4_10, 2, AOM_BITS_10, 16),
-        make_tuple(&av1_highbd_fht4x4_c, &iht4x4_10, 3, AOM_BITS_10, 16),
-        make_tuple(&av1_highbd_fht4x4_c, &iht4x4_12, 0, AOM_BITS_12, 16),
-        make_tuple(&av1_highbd_fht4x4_c, &iht4x4_12, 1, AOM_BITS_12, 16),
-        make_tuple(&av1_highbd_fht4x4_c, &iht4x4_12, 2, AOM_BITS_12, 16),
-        make_tuple(&av1_highbd_fht4x4_c, &iht4x4_12, 3, AOM_BITS_12, 16),
+        make_tuple(&fht4x4_10, &iht4x4_10, 0, AOM_BITS_10, 16),
+        make_tuple(&fht4x4_10, &iht4x4_10, 1, AOM_BITS_10, 16),
+        make_tuple(&fht4x4_10, &iht4x4_10, 2, AOM_BITS_10, 16),
+        make_tuple(&fht4x4_10, &iht4x4_10, 3, AOM_BITS_10, 16),
         make_tuple(&av1_fht4x4_c, &av1_iht4x4_16_add_c, 0, AOM_BITS_8, 16),
         make_tuple(&av1_fht4x4_c, &av1_iht4x4_16_add_c, 1, AOM_BITS_8, 16),
         make_tuple(&av1_fht4x4_c, &av1_iht4x4_16_add_c, 2, AOM_BITS_8, 16),
         make_tuple(&av1_fht4x4_c, &av1_iht4x4_16_add_c, 3, AOM_BITS_8, 16)));
 #else
 INSTANTIATE_TEST_CASE_P(
     C, Trans4x4HT,
     ::testing::Values(
@@ -300,28 +299,16 @@ INSTANTIATE_TEST_CASE_P(
                       make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 2,
                                  AOM_BITS_8, 16),
                       make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 3,
                                  AOM_BITS_8, 16)));
 #endif  // HAVE_SSE2 && !CONFIG_HIGHBITDEPTH
 
 #if HAVE_SSE2 && CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(
-    SSE2, Trans4x4DCT,
-    ::testing::Values(
-        make_tuple(&aom_highbd_fdct4x4_c, &idct4x4_10_sse2, 0, AOM_BITS_10, 16),
-        make_tuple(&aom_highbd_fdct4x4_sse2, &idct4x4_10_sse2, 0, AOM_BITS_10,
-                   16),
-        make_tuple(&aom_highbd_fdct4x4_c, &idct4x4_12_sse2, 0, AOM_BITS_12, 16),
-        make_tuple(&aom_highbd_fdct4x4_sse2, &idct4x4_12_sse2, 0, AOM_BITS_12,
-                   16),
-        make_tuple(&aom_fdct4x4_sse2, &aom_idct4x4_16_add_c, 0, AOM_BITS_8,
-                   16)));
-
-INSTANTIATE_TEST_CASE_P(
     SSE2, Trans4x4HT,
     ::testing::Values(
         make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_c, 0, AOM_BITS_8, 16),
         make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_c, 1, AOM_BITS_8, 16),
         make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_c, 2, AOM_BITS_8, 16),
         make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_c, 3, AOM_BITS_8, 16)));
 #endif  // HAVE_SSE2 && CONFIG_HIGHBITDEPTH
 
--- a/third_party/aom/test/fdct8x8_test.cc
+++ b/third_party/aom/test/fdct8x8_test.cc
@@ -2,17 +2,17 @@
  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
  *
  * This source code is subject to the terms of the BSD 2 Clause License and
  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
  * was not distributed with this source code in the LICENSE file, you can
  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
-*/
+ */
 
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./av1_rtcd.h"
@@ -35,19 +35,19 @@ const int kNumCoeffs = 64;
 const double kPi = 3.141592653589793238462643383279502884;
 
 const int kSignBiasMaxDiff255 = 1500;
 const int kSignBiasMaxDiff15 = 10000;
 
 typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride);
 typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride);
 typedef void (*FhtFunc)(const int16_t *in, tran_low_t *out, int stride,
-                        int tx_type);
+                        FWD_TXFM_PARAM *fwd_txfm_param);
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 
 typedef std::tr1::tuple<FdctFunc, IdctFunc, int, aom_bit_depth_t> Dct8x8Param;
 typedef std::tr1::tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t> Ht8x8Param;
 typedef std::tr1::tuple<IdctFunc, IdctFunc, int, aom_bit_depth_t> Idct8x8Param;
 
 void reference_8x8_dct_1d(const double in[8], double out[8]) {
   const double kInvSqrt2 = 0.707106781186547524400844362104;
   for (int k = 0; k < 8; k++) {
@@ -73,31 +73,46 @@ void reference_8x8_dct_2d(const int16_t 
     for (int j = 0; j < 8; ++j) temp_in[j] = output[j + i * 8];
     reference_8x8_dct_1d(temp_in, temp_out);
     // Scale by some magic number
     for (int j = 0; j < 8; ++j) output[j + i * 8] = temp_out[j] * 2;
   }
 }
 
 void fdct8x8_ref(const int16_t *in, tran_low_t *out, int stride,
-                 int /*tx_type*/) {
+                 FWD_TXFM_PARAM *fwd_txfm_param) {
   aom_fdct8x8_c(in, out, stride);
 }
 
-void fht8x8_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
-  av1_fht8x8_c(in, out, stride, tx_type);
+void fht8x8_ref(const int16_t *in, tran_low_t *out, int stride,
+                FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fht8x8_c(in, out, stride, fwd_txfm_param);
 }
 
 #if CONFIG_HIGHBITDEPTH
-void iht8x8_10(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_highbd_iht8x8_64_add_c(in, out, stride, tx_type, 10);
+void fht8x8_10(const int16_t *in, tran_low_t *out, int stride,
+               FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fwd_txfm2d_8x8_c(in, out, stride, fwd_txfm_param->tx_type, 10);
+}
+
+void fht8x8_12(const int16_t *in, tran_low_t *out, int stride,
+               FWD_TXFM_PARAM *fwd_txfm_param) {
+  av1_fwd_txfm2d_8x8_c(in, out, stride, fwd_txfm_param->tx_type, 12);
 }
 
-void iht8x8_12(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
-  av1_highbd_iht8x8_64_add_c(in, out, stride, tx_type, 12);
+void iht8x8_10(const tran_low_t *in, uint8_t *out, int stride,
+               const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_inv_txfm2d_add_8x8_c(in, CONVERT_TO_SHORTPTR(out), stride,
+                           inv_txfm_param->tx_type, 10);
+}
+
+void iht8x8_12(const tran_low_t *in, uint8_t *out, int stride,
+               const INV_TXFM_PARAM *inv_txfm_param) {
+  av1_inv_txfm2d_add_8x8_c(in, CONVERT_TO_SHORTPTR(out), stride,
+                           inv_txfm_param->tx_type, 12);
 }
 
 #endif  // CONFIG_HIGHBITDEPTH
 
 class FwdTrans8x8TestBase {
  public:
   virtual ~FwdTrans8x8TestBase() {}
 
@@ -290,18 +305,18 @@ class FwdTrans8x8TestBase {
           }
           test_input_block[j] = src16[j] - dst16[j];
 #endif
         }
       }
 
       ASM_REGISTER_STATE_CHECK(
           RunFwdTxfm(test_input_block, test_temp_block, pitch_));
-      ASM_REGISTER_STATE_CHECK(
-          fwd_txfm_ref(test_input_block, ref_temp_block, pitch_, tx_type_));
+      ASM_REGISTER_STATE_CHECK(fwd_txfm_ref(test_input_block, ref_temp_block,
+                                            pitch_, &fwd_txfm_param_));
       if (bit_depth_ == AOM_BITS_8) {
         ASM_REGISTER_STATE_CHECK(RunInvTxfm(test_temp_block, dst, pitch_));
 #if CONFIG_HIGHBITDEPTH
       } else {
         ASM_REGISTER_STATE_CHECK(
             RunInvTxfm(test_temp_block, CONVERT_TO_BYTEPTR(dst16), pitch_));
 #endif
       }
@@ -471,35 +486,37 @@ class FwdTrans8x8TestBase {
 #endif
         const uint32_t error = diff * diff;
         EXPECT_EQ(0u, error) << "Error: 8x8 IDCT has error " << error
                              << " at index " << j;
       }
     }
   }
   int pitch_;
-  int tx_type_;
   FhtFunc fwd_txfm_ref;
   aom_bit_depth_t bit_depth_;
   int mask_;
+  FWD_TXFM_PARAM fwd_txfm_param_;
+  INV_TXFM_PARAM inv_txfm_param_;
 };
 
 class FwdTrans8x8DCT : public FwdTrans8x8TestBase,
                        public ::testing::TestWithParam<Dct8x8Param> {
  public:
   virtual ~FwdTrans8x8DCT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 8;
     fwd_txfm_ref = fdct8x8_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
   }
 
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(int16_t *in, tran_low_t *out, int stride) {
     fwd_txfm_(in, out, stride);
   }
@@ -524,31 +541,39 @@ TEST_P(FwdTrans8x8DCT, InvAccuracyCheck)
 class FwdTrans8x8HT : public FwdTrans8x8TestBase,
                       public ::testing::TestWithParam<Ht8x8Param> {
  public:
   virtual ~FwdTrans8x8HT() {}
 
   virtual void SetUp() {
     fwd_txfm_ = GET_PARAM(0);
     inv_txfm_ = GET_PARAM(1);
-    tx_type_ = GET_PARAM(2);
     pitch_ = 8;
     fwd_txfm_ref = fht8x8_ref;
     bit_depth_ = GET_PARAM(3);
     mask_ = (1 << bit_depth_) - 1;
+    fwd_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+    inv_txfm_param_.tx_type = (TX_TYPE)GET_PARAM(2);
+#if CONFIG_HIGHBITDEPTH
+    switch (bit_depth_) {
+      case AOM_BITS_10: fwd_txfm_ref = fht8x8_10; break;
+      case AOM_BITS_12: fwd_txfm_ref = fht8x8_12; break;
+      default: fwd_txfm_ref = fht8x8_ref; break;
+    }
+#endif
   }
 
   virtual void TearDown() { libaom_test::ClearSystemState(); }
 
  protected:
   void RunFwdTxfm(int16_t *in, tran_low_t *out, int stride) {
-    fwd_txfm_(in, out, stride, tx_type_);
+    fwd_txfm_(in, out, stride, &fwd_txfm_param_);
   }
   void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) {
-    inv_txfm_(out, dst, stride, tx_type_);
+    inv_txfm_(out, dst, stride, &inv_txfm_param_);
   }
 
   FhtFunc fwd_txfm_;
   IhtFunc inv_txfm_;
 };
 
 TEST_P(FwdTrans8x8HT, SignBiasCheck) { RunSignBiasCheck(); }
 
@@ -601,24 +626,24 @@ INSTANTIATE_TEST_CASE_P(C, FwdTrans8x8DC
                                                      AOM_BITS_8)));
 #endif  // CONFIG_HIGHBITDEPTH
 
 #if CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(
     C, FwdTrans8x8HT,
     ::testing::Values(
         make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 0, AOM_BITS_8),
-        make_tuple(&av1_highbd_fht8x8_c, &iht8x8_10, 0, AOM_BITS_10),
-        make_tuple(&av1_highbd_fht8x8_c, &iht8x8_10, 1, AOM_BITS_10),
-        make_tuple(&av1_highbd_fht8x8_c, &iht8x8_10, 2, AOM_BITS_10),
-        make_tuple(&av1_highbd_fht8x8_c, &iht8x8_10, 3, AOM_BITS_10),
-        make_tuple(&av1_highbd_fht8x8_c, &iht8x8_12, 0, AOM_BITS_12),
-        make_tuple(&av1_highbd_fht8x8_c, &iht8x8_12, 1, AOM_BITS_12),
-        make_tuple(&av1_highbd_fht8x8_c, &iht8x8_12, 2, AOM_BITS_12),
-        make_tuple(&av1_highbd_fht8x8_c, &iht8x8_12, 3, AOM_BITS_12),
+        make_tuple(&fht8x8_10, &iht8x8_10, 0, AOM_BITS_10),
+        make_tuple(&fht8x8_10, &iht8x8_10, 1, AOM_BITS_10),
+        make_tuple(&fht8x8_10, &iht8x8_10, 2, AOM_BITS_10),
+        make_tuple(&fht8x8_10, &iht8x8_10, 3, AOM_BITS_10),
+        make_tuple(&fht8x8_12, &iht8x8_12, 0, AOM_BITS_12),
+        make_tuple(&fht8x8_12, &iht8x8_12, 1, AOM_BITS_12),
+        make_tuple(&fht8x8_12, &iht8x8_12, 2, AOM_BITS_12),
+        make_tuple(&fht8x8_12, &iht8x8_12, 3, AOM_BITS_12),
         make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 1, AOM_BITS_8),
         make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 2, AOM_BITS_8),
         make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 3, AOM_BITS_8)));
 #else
 INSTANTIATE_TEST_CASE_P(
     C, FwdTrans8x8HT,
     ::testing::Values(
         make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 0, AOM_BITS_8),
--- a/third_party/aom/test/frame_size_tests.cc
+++ b/third_party/aom/test/frame_size_tests.cc
@@ -10,18 +10,18 @@
 */
 
 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/video_source.h"
 
 namespace {
 
-class AV1FrameSizeTests : public ::libaom_test::EncoderTest,
-                          public ::testing::Test {
+class AV1FrameSizeTests : public ::testing::Test,
+                          public ::libaom_test::EncoderTest {
  protected:
   AV1FrameSizeTests()
       : EncoderTest(&::libaom_test::kAV1), expected_res_(AOM_CODEC_OK) {}
   virtual ~AV1FrameSizeTests() {}
 
   virtual void SetUp() {
     InitializeConfig();
     SetMode(::libaom_test::kRealTime);
--- a/third_party/aom/test/hiprec_convolve_test_util.cc
+++ b/third_party/aom/test/hiprec_convolve_test_util.cc
@@ -87,18 +87,18 @@ void AV1HiprecConvolveTest::RunCheckOutp
 
   generate_kernels(&rnd_, hkernel, vkernel);
 
   for (i = 0; i < h; ++i)
     for (j = 0; j < w; ++j) input[i * w + j] = rnd_.Rand8();
 
   for (i = 0; i < num_iters; ++i) {
     // Choose random locations within the source block
-    int offset_r = 3 + rnd_.PseudoUniform(w - out_w - 7);
-    int offset_c = 3 + rnd_.PseudoUniform(h - out_h - 7);
+    int offset_r = 3 + rnd_.PseudoUniform(h - out_h - 7);
+    int offset_c = 3 + rnd_.PseudoUniform(w - out_w - 7);
     aom_convolve8_add_src_hip_c(input + offset_r * w + offset_c, w, output,
                                 out_w, hkernel, 16, vkernel, 16, out_w, out_h);
     test_impl(input + offset_r * w + offset_c, w, output2, out_w, hkernel, 16,
               vkernel, 16, out_w, out_h);
 
     for (j = 0; j < out_w * out_h; ++j)
       ASSERT_EQ(output[j], output2[j]) << "Pixel mismatch at index " << j
                                        << " = (" << (j % out_w) << ", "
@@ -161,18 +161,18 @@ void AV1HighbdHiprecConvolveTest::RunChe
     for (j = 0; j < w; ++j) input[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
 
   uint8_t *input_ptr = CONVERT_TO_BYTEPTR(input);
   uint8_t *output_ptr = CONVERT_TO_BYTEPTR(output);
   uint8_t *output2_ptr = CONVERT_TO_BYTEPTR(output2);
 
   for (i = 0; i < num_iters; ++i) {
     // Choose random locations within the source block
-    int offset_r = 3 + rnd_.PseudoUniform(w - out_w - 7);
-    int offset_c = 3 + rnd_.PseudoUniform(h - out_h - 7);
+    int offset_r = 3 + rnd_.PseudoUniform(h - out_h - 7);
+    int offset_c = 3 + rnd_.PseudoUniform(w - out_w - 7);
     aom_highbd_convolve8_add_src_hip_c(input_ptr + offset_r * w + offset_c, w,
                                        output_ptr, out_w, hkernel, 16, vkernel,
                                        16, out_w, out_h, bd);
     test_impl(input_ptr + offset_r * w + offset_c, w, output2_ptr, out_w,
               hkernel, 16, vkernel, 16, out_w, out_h, bd);
 
     for (j = 0; j < out_w * out_h; ++j)
       ASSERT_EQ(output[j], output2[j]) << "Pixel mismatch at index " << j
--- a/third_party/aom/test/level_test.cc
+++ b/third_party/aom/test/level_test.cc
@@ -12,18 +12,18 @@
 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/codec_factory.h"
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
 #include "test/util.h"
 
 namespace {
 class LevelTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> {
+    : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
+      public ::libaom_test::EncoderTest {
  protected:
   LevelTest()
       : EncoderTest(GET_PARAM(0)), encoding_mode_(GET_PARAM(1)),
         cpu_used_(GET_PARAM(2)), min_gf_internal_(24), target_level_(0),
         level_(0) {}
   virtual ~LevelTest() {}
 
   virtual void SetUp() {
--- a/third_party/aom/test/lossless_test.cc
+++ b/third_party/aom/test/lossless_test.cc
@@ -18,18 +18,18 @@
 #include "test/util.h"
 #include "test/y4m_video_source.h"
 
 namespace {
 
 const int kMaxPsnr = 100;
 
 class LosslessTestLarge
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWithParam<libaom_test::TestMode> {
+    : public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>,
+      public ::libaom_test::EncoderTest {
  protected:
   LosslessTestLarge()
       : EncoderTest(GET_PARAM(0)), psnr_(kMaxPsnr), nframes_(0),
         encoding_mode_(GET_PARAM(1)) {}
 
   virtual ~LosslessTestLarge() {}
 
   virtual void SetUp() {
--- a/third_party/aom/test/lpf_8_test.cc
+++ b/third_party/aom/test/lpf_8_test.cc
@@ -407,132 +407,132 @@ TEST_P(Loop8Test9Param, ValueCheck) {
          "loopfilter output. "
       << "First failed at test case " << first_failure;
 }
 
 using std::tr1::make_tuple;
 
 #if HAVE_SSE2
 #if CONFIG_HIGHBITDEPTH
-INSTANTIATE_TEST_CASE_P(
-    SSE2, Loop8Test6Param,
-    ::testing::Values(make_tuple(&aom_highbd_lpf_horizontal_4_sse2,
-                                 &aom_highbd_lpf_horizontal_4_c, 8),
-                      make_tuple(&aom_highbd_lpf_vertical_4_sse2,
-                                 &aom_highbd_lpf_vertical_4_c, 8),
-                      make_tuple(&aom_highbd_lpf_horizontal_8_sse2,
-                                 &aom_highbd_lpf_horizontal_8_c, 8),
-                      make_tuple(&aom_highbd_lpf_horizontal_edge_8_sse2,
-                                 &aom_highbd_lpf_horizontal_edge_8_c, 8),
-                      make_tuple(&aom_highbd_lpf_horizontal_edge_16_sse2,
-                                 &aom_highbd_lpf_horizontal_edge_16_c, 8),
-                      make_tuple(&aom_highbd_lpf_vertical_8_sse2,
-                                 &aom_highbd_lpf_vertical_8_c, 8),
-                      make_tuple(&aom_highbd_lpf_vertical_16_sse2,
-                                 &aom_highbd_lpf_vertical_16_c, 8),
-                      make_tuple(&aom_highbd_lpf_horizontal_4_sse2,
-                                 &aom_highbd_lpf_horizontal_4_c, 10),
-                      make_tuple(&aom_highbd_lpf_vertical_4_sse2,
-                                 &aom_highbd_lpf_vertical_4_c, 10),
-                      make_tuple(&aom_highbd_lpf_horizontal_8_sse2,
-                                 &aom_highbd_lpf_horizontal_8_c, 10),
-                      make_tuple(&aom_highbd_lpf_horizontal_edge_8_sse2,
-                                 &aom_highbd_lpf_horizontal_edge_8_c, 10),
-                      make_tuple(&aom_highbd_lpf_horizontal_edge_16_sse2,
-                                 &aom_highbd_lpf_horizontal_edge_16_c, 10),
-                      make_tuple(&aom_highbd_lpf_vertical_8_sse2,
-                                 &aom_highbd_lpf_vertical_8_c, 10),
-                      make_tuple(&aom_highbd_lpf_vertical_16_sse2,
-                                 &aom_highbd_lpf_vertical_16_c, 10),
-                      make_tuple(&aom_highbd_lpf_horizontal_4_sse2,
-                                 &aom_highbd_lpf_horizontal_4_c, 12),
-                      make_tuple(&aom_highbd_lpf_vertical_4_sse2,
-                                 &aom_highbd_lpf_vertical_4_c, 12),
-                      make_tuple(&aom_highbd_lpf_horizontal_8_sse2,
-                                 &aom_highbd_lpf_horizontal_8_c, 12),
-                      make_tuple(&aom_highbd_lpf_horizontal_edge_8_sse2,
-                                 &aom_highbd_lpf_horizontal_edge_8_c, 12),
-                      make_tuple(&aom_highbd_lpf_horizontal_edge_16_sse2,
-                                 &aom_highbd_lpf_horizontal_edge_16_c, 12),
-                      make_tuple(&aom_highbd_lpf_vertical_8_sse2,
-                                 &aom_highbd_lpf_vertical_8_c, 12),
-                      make_tuple(&aom_highbd_lpf_vertical_16_sse2,
-                                 &aom_highbd_lpf_vertical_16_c, 12),
-                      make_tuple(&aom_highbd_lpf_vertical_16_dual_sse2,
-                                 &aom_highbd_lpf_vertical_16_dual_c, 8),
-                      make_tuple(&aom_highbd_lpf_vertical_16_dual_sse2,
-                                 &aom_highbd_lpf_vertical_16_dual_c, 10),
-                      make_tuple(&aom_highbd_lpf_vertical_16_dual_sse2,
-                                 &aom_highbd_lpf_vertical_16_dual_c, 12)));
+
+const loop8_param_t kHbdLoop8Test6[] = {
+  make_tuple(&aom_highbd_lpf_horizontal_4_sse2, &aom_highbd_lpf_horizontal_4_c,
+             8),
+  make_tuple(&aom_highbd_lpf_vertical_4_sse2, &aom_highbd_lpf_vertical_4_c, 8),
+  make_tuple(&aom_highbd_lpf_horizontal_8_sse2, &aom_highbd_lpf_horizontal_8_c,
+             8),
+  make_tuple(&aom_highbd_lpf_horizontal_edge_8_sse2,
+             &aom_highbd_lpf_horizontal_edge_8_c, 8),
+  make_tuple(&aom_highbd_lpf_horizontal_edge_16_sse2,
+             &aom_highbd_lpf_horizontal_edge_16_c, 8),
+  make_tuple(&aom_highbd_lpf_vertical_8_sse2, &aom_highbd_lpf_vertical_8_c, 8),
+  make_tuple(&aom_highbd_lpf_vertical_16_sse2, &aom_highbd_lpf_vertical_16_c,
+             8),
+  make_tuple(&aom_highbd_lpf_horizontal_4_sse2, &aom_highbd_lpf_horizontal_4_c,
+             10),
+  make_tuple(&aom_highbd_lpf_vertical_4_sse2, &aom_highbd_lpf_vertical_4_c, 10),
+  make_tuple(&aom_highbd_lpf_horizontal_8_sse2, &aom_highbd_lpf_horizontal_8_c,
+             10),
+  make_tuple(&aom_highbd_lpf_horizontal_edge_8_sse2,
+             &aom_highbd_lpf_horizontal_edge_8_c, 10),
+  make_tuple(&aom_highbd_lpf_horizontal_edge_16_sse2,
+             &aom_highbd_lpf_horizontal_edge_16_c, 10),
+  make_tuple(&aom_highbd_lpf_vertical_8_sse2, &aom_highbd_lpf_vertical_8_c, 10),
+  make_tuple(&aom_highbd_lpf_vertical_16_sse2, &aom_highbd_lpf_vertical_16_c,
+             10),
+  make_tuple(&aom_highbd_lpf_horizontal_4_sse2, &aom_highbd_lpf_horizontal_4_c,
+             12),
+  make_tuple(&aom_highbd_lpf_vertical_4_sse2, &aom_highbd_lpf_vertical_4_c, 12),
+  make_tuple(&aom_highbd_lpf_horizontal_8_sse2, &aom_highbd_lpf_horizontal_8_c,
+             12),
+  make_tuple(&aom_highbd_lpf_horizontal_edge_8_sse2,
+             &aom_highbd_lpf_horizontal_edge_8_c, 12),
+  make_tuple(&aom_highbd_lpf_horizontal_edge_16_sse2,
+             &aom_highbd_lpf_horizontal_edge_16_c, 12),
+  make_tuple(&aom_highbd_lpf_vertical_8_sse2, &aom_highbd_lpf_vertical_8_c, 12),
+  make_tuple(&aom_highbd_lpf_vertical_16_sse2, &aom_highbd_lpf_vertical_16_c,
+             12),
+  make_tuple(&aom_highbd_lpf_vertical_16_dual_sse2,
+             &aom_highbd_lpf_vertical_16_dual_c, 8),
+  make_tuple(&aom_highbd_lpf_vertical_16_dual_sse2,
+             &aom_highbd_lpf_vertical_16_dual_c, 10),
+  make_tuple(&aom_highbd_lpf_vertical_16_dual_sse2,
+             &aom_highbd_lpf_vertical_16_dual_c, 12)
+};
+
+INSTANTIATE_TEST_CASE_P(SSE2, Loop8Test6Param,
+                        ::testing::ValuesIn(kHbdLoop8Test6));
 #else
-INSTANTIATE_TEST_CASE_P(
-    SSE2, Loop8Test6Param,
-    ::testing::Values(
-        make_tuple(&aom_lpf_horizontal_4_sse2, &aom_lpf_horizontal_4_c, 8),
-        make_tuple(&aom_lpf_horizontal_8_sse2, &aom_lpf_horizontal_8_c, 8),
-        make_tuple(&aom_lpf_horizontal_edge_8_sse2,
-                   &aom_lpf_horizontal_edge_8_c, 8),
-        make_tuple(&aom_lpf_horizontal_edge_16_sse2,
-                   &aom_lpf_horizontal_edge_16_c, 8),
-        make_tuple(&aom_lpf_vertical_4_sse2, &aom_lpf_vertical_4_c, 8),
-        make_tuple(&aom_lpf_vertical_8_sse2, &aom_lpf_vertical_8_c, 8),
-        make_tuple(&aom_lpf_vertical_16_sse2, &aom_lpf_vertical_16_c, 8),
-        make_tuple(&aom_lpf_vertical_16_dual_sse2, &aom_lpf_vertical_16_dual_c,
-                   8)));
+const loop8_param_t kLoop8Test6[] = {
+  make_tuple(&aom_lpf_horizontal_4_sse2, &aom_lpf_horizontal_4_c, 8),
+  make_tuple(&aom_lpf_horizontal_8_sse2, &aom_lpf_horizontal_8_c, 8),
+  make_tuple(&aom_lpf_horizontal_edge_8_sse2, &aom_lpf_horizontal_edge_8_c, 8),
+  make_tuple(&aom_lpf_horizontal_edge_16_sse2, &aom_lpf_horizontal_edge_16_c,
+             8),
+  make_tuple(&aom_lpf_vertical_4_sse2, &aom_lpf_vertical_4_c, 8),
+  make_tuple(&aom_lpf_vertical_8_sse2, &aom_lpf_vertical_8_c, 8),
+  make_tuple(&aom_lpf_vertical_16_sse2, &aom_lpf_vertical_16_c, 8),
+  make_tuple(&aom_lpf_vertical_16_dual_sse2, &aom_lpf_vertical_16_dual_c, 8)
+};
+
+INSTANTIATE_TEST_CASE_P(SSE2, Loop8Test6Param,
+                        ::testing::ValuesIn(kLoop8Test6));
 #endif  // CONFIG_HIGHBITDEPTH
 #endif
 
 #if HAVE_AVX2 && (!CONFIG_HIGHBITDEPTH)
 INSTANTIATE_TEST_CASE_P(
     AVX2, Loop8Test6Param,
     ::testing::Values(make_tuple(&aom_lpf_horizontal_edge_8_avx2,
                                  &aom_lpf_horizontal_edge_8_c, 8),
                       make_tuple(&aom_lpf_horizontal_edge_16_avx2,
                                  &aom_lpf_horizontal_edge_16_c, 8)));
 #endif
 
 #if HAVE_SSE2
 #if CONFIG_HIGHBITDEPTH
-INSTANTIATE_TEST_CASE_P(
-    SSE2, Loop8Test9Param,
-    ::testing::Values(make_tuple(&aom_highbd_lpf_horizontal_4_dual_sse2,
-                                 &aom_highbd_lpf_horizontal_4_dual_c, 8),
-                      make_tuple(&aom_highbd_lpf_horizontal_8_dual_sse2,
-                                 &aom_highbd_lpf_horizontal_8_dual_c, 8),
-                      make_tuple(&aom_highbd_lpf_vertical_4_dual_sse2,
-                                 &aom_highbd_lpf_vertical_4_dual_c, 8),
-                      make_tuple(&aom_highbd_lpf_vertical_8_dual_sse2,
-                                 &aom_highbd_lpf_vertical_8_dual_c, 8),
-                      make_tuple(&aom_highbd_lpf_horizontal_4_dual_sse2,
-                                 &aom_highbd_lpf_horizontal_4_dual_c, 10),
-                      make_tuple(&aom_highbd_lpf_horizontal_8_dual_sse2,
-                                 &aom_highbd_lpf_horizontal_8_dual_c, 10),
-                      make_tuple(&aom_highbd_lpf_vertical_4_dual_sse2,
-                                 &aom_highbd_lpf_vertical_4_dual_c, 10),
-                      make_tuple(&aom_highbd_lpf_vertical_8_dual_sse2,
-                                 &aom_highbd_lpf_vertical_8_dual_c, 10),
-                      make_tuple(&aom_highbd_lpf_horizontal_4_dual_sse2,
-                                 &aom_highbd_lpf_horizontal_4_dual_c, 12),
-                      make_tuple(&aom_highbd_lpf_horizontal_8_dual_sse2,
-                                 &aom_highbd_lpf_horizontal_8_dual_c, 12),
-                      make_tuple(&aom_highbd_lpf_vertical_4_dual_sse2,
-                                 &aom_highbd_lpf_vertical_4_dual_c, 12),
-                      make_tuple(&aom_highbd_lpf_vertical_8_dual_sse2,
-                                 &aom_highbd_lpf_vertical_8_dual_c, 12)));
+const dualloop8_param_t kHbdLoop8Test9[] = {
+  make_tuple(&aom_highbd_lpf_horizontal_4_dual_sse2,
+             &aom_highbd_lpf_horizontal_4_dual_c, 8),
+  make_tuple(&aom_highbd_lpf_horizontal_8_dual_sse2,
+             &aom_highbd_lpf_horizontal_8_dual_c, 8),
+  make_tuple(&aom_highbd_lpf_vertical_4_dual_sse2,
+             &aom_highbd_lpf_vertical_4_dual_c, 8),
+  make_tuple(&aom_highbd_lpf_vertical_8_dual_sse2,
+             &aom_highbd_lpf_vertical_8_dual_c, 8),
+  make_tuple(&aom_highbd_lpf_horizontal_4_dual_sse2,
+             &aom_highbd_lpf_horizontal_4_dual_c, 10),
+  make_tuple(&aom_highbd_lpf_horizontal_8_dual_sse2,
+             &aom_highbd_lpf_horizontal_8_dual_c, 10),
+  make_tuple(&aom_highbd_lpf_vertical_4_dual_sse2,
+             &aom_highbd_lpf_vertical_4_dual_c, 10),
+  make_tuple(&aom_highbd_lpf_vertical_8_dual_sse2,
+             &aom_highbd_lpf_vertical_8_dual_c, 10),
+  make_tuple(&aom_highbd_lpf_horizontal_4_dual_sse2,
+             &aom_highbd_lpf_horizontal_4_dual_c, 12),
+  make_tuple(&aom_highbd_lpf_horizontal_8_dual_sse2,
+             &aom_highbd_lpf_horizontal_8_dual_c, 12),
+  make_tuple(&aom_highbd_lpf_vertical_4_dual_sse2,
+             &aom_highbd_lpf_vertical_4_dual_c, 12),
+  make_tuple(&aom_highbd_lpf_vertical_8_dual_sse2,
+             &aom_highbd_lpf_vertical_8_dual_c, 12)
+};
+
+INSTANTIATE_TEST_CASE_P(SSE2, Loop8Test9Param,
+                        ::testing::ValuesIn(kHbdLoop8Test9));
 #else
-INSTANTIATE_TEST_CASE_P(
-    SSE2, Loop8Test9Param,
-    ::testing::Values(make_tuple(&aom_lpf_horizontal_4_dual_sse2,
-                                 &aom_lpf_horizontal_4_dual_c, 8),
-                      make_tuple(&aom_lpf_horizontal_8_dual_sse2,
-                                 &aom_lpf_horizontal_8_dual_c, 8),
-                      make_tuple(&aom_lpf_vertical_4_dual_sse2,
-                                 &aom_lpf_vertical_4_dual_c, 8),
-                      make_tuple(&aom_lpf_vertical_8_dual_sse2,
-                                 &aom_lpf_vertical_8_dual_c, 8)));
+const dualloop8_param_t kLoop8Test9[] = {
+  make_tuple(&aom_lpf_horizontal_4_dual_sse2, &aom_lpf_horizontal_4_dual_c, 8),
+  make_tuple(&aom_lpf_horizontal_8_dual_sse2, &aom_lpf_horizontal_8_dual_c, 8),
+  make_tuple(&aom_lpf_vertical_4_dual_sse2, &aom_lpf_vertical_4_dual_c, 8),
+  make_tuple(&aom_lpf_vertical_8_dual_sse2, &aom_lpf_vertical_8_dual_c, 8)
+};
+
+INSTANTIATE_TEST_CASE_P(SSE2, Loop8Test9Param,
+                        ::testing::ValuesIn(kLoop8Test9));
 #endif  // CONFIG_HIGHBITDEPTH
 #endif
 
 #if HAVE_NEON
 #if CONFIG_HIGHBITDEPTH
 // No neon high bitdepth functions.
 #else
 INSTANTIATE_TEST_CASE_P(
--- a/third_party/aom/test/masked_sad_test.cc
+++ b/third_party/aom/test/masked_sad_test.cc
@@ -155,69 +155,61 @@ TEST_P(HighbdMaskedSADTest, OperationChe
       << "Error: High BD Masked SAD Test, C output doesn't match SSSE3 output. "
       << "First failed at test case " << first_failure;
 }
 #endif  // CONFIG_HIGHBITDEPTH
 
 using std::tr1::make_tuple;
 
 #if HAVE_SSSE3
-INSTANTIATE_TEST_CASE_P(
-    SSSE3_C_COMPARE, MaskedSADTest,
-    ::testing::Values(
-#if CONFIG_EXT_PARTITION
-        make_tuple(&aom_masked_sad128x128_ssse3, &aom_masked_sad128x128_c),
-        make_tuple(&aom_masked_sad128x64_ssse3, &aom_masked_sad128x64_c),
-        make_tuple(&aom_masked_sad64x128_ssse3, &aom_masked_sad64x128_c),
-#endif  // CONFIG_EXT_PARTITION
-        make_tuple(&aom_masked_sad64x64_ssse3, &aom_masked_sad64x64_c),
-        make_tuple(&aom_masked_sad64x32_ssse3, &aom_masked_sad64x32_c),
-        make_tuple(&aom_masked_sad32x64_ssse3, &aom_masked_sad32x64_c),
-        make_tuple(&aom_masked_sad32x32_ssse3, &aom_masked_sad32x32_c),
-        make_tuple(&aom_masked_sad32x16_ssse3, &aom_masked_sad32x16_c),
-        make_tuple(&aom_masked_sad16x32_ssse3, &aom_masked_sad16x32_c),
-        make_tuple(&aom_masked_sad16x16_ssse3, &aom_masked_sad16x16_c),
-        make_tuple(&aom_masked_sad16x8_ssse3, &aom_masked_sad16x8_c),
-        make_tuple(&aom_masked_sad8x16_ssse3, &aom_masked_sad8x16_c),
-        make_tuple(&aom_masked_sad8x8_ssse3, &aom_masked_sad8x8_c),
-        make_tuple(&aom_masked_sad8x4_ssse3, &aom_masked_sad8x4_c),
-        make_tuple(&aom_masked_sad4x8_ssse3, &aom_masked_sad4x8_c),
-        make_tuple(&aom_masked_sad4x4_ssse3, &aom_masked_sad4x4_c)));
-#if CONFIG_HIGHBITDEPTH
-INSTANTIATE_TEST_CASE_P(SSSE3_C_COMPARE, HighbdMaskedSADTest,
-                        ::testing::Values(
+const MaskedSADParam msad_test[] = {
 #if CONFIG_EXT_PARTITION
-                            make_tuple(&aom_highbd_masked_sad128x128_ssse3,
-                                       &aom_highbd_masked_sad128x128_c),
-                            make_tuple(&aom_highbd_masked_sad128x64_ssse3,
-                                       &aom_highbd_masked_sad128x64_c),
-                            make_tuple(&aom_highbd_masked_sad64x128_ssse3,
-                                       &aom_highbd_masked_sad64x128_c),
+  make_tuple(&aom_masked_sad128x128_ssse3, &aom_masked_sad128x128_c),
+  make_tuple(&aom_masked_sad128x64_ssse3, &aom_masked_sad128x64_c),
+  make_tuple(&aom_masked_sad64x128_ssse3, &aom_masked_sad64x128_c),
 #endif  // CONFIG_EXT_PARTITION
-                            make_tuple(&aom_highbd_masked_sad64x64_ssse3,
-                                       &aom_highbd_masked_sad64x64_c),
-                            make_tuple(&aom_highbd_masked_sad64x32_ssse3,
-                                       &aom_highbd_masked_sad64x32_c),
-                            make_tuple(&aom_highbd_masked_sad32x64_ssse3,
-                                       &aom_highbd_masked_sad32x64_c),
-                            make_tuple(&aom_highbd_masked_sad32x32_ssse3,
-                                       &aom_highbd_masked_sad32x32_c),
-                            make_tuple(&aom_highbd_masked_sad32x16_ssse3,
-                                       &aom_highbd_masked_sad32x16_c),
-                            make_tuple(&aom_highbd_masked_sad16x32_ssse3,
-                                       &aom_highbd_masked_sad16x32_c),
-                            make_tuple(&aom_highbd_masked_sad16x16_ssse3,
-                                       &aom_highbd_masked_sad16x16_c),
-                            make_tuple(&aom_highbd_masked_sad16x8_ssse3,
-                                       &aom_highbd_masked_sad16x8_c),
-                            make_tuple(&aom_highbd_masked_sad8x16_ssse3,
-                                       &aom_highbd_masked_sad8x16_c),
-                            make_tuple(&aom_highbd_masked_sad8x8_ssse3,
-                                       &aom_highbd_masked_sad8x8_c),
-                            make_tuple(&aom_highbd_masked_sad8x4_ssse3,
-                                       &aom_highbd_masked_sad8x4_c),
-                            make_tuple(&aom_highbd_masked_sad4x8_ssse3,
-                                       &aom_highbd_masked_sad4x8_c),
-                            make_tuple(&aom_highbd_masked_sad4x4_ssse3,
-                                       &aom_highbd_masked_sad4x4_c)));
+  make_tuple(&aom_masked_sad64x64_ssse3, &aom_masked_sad64x64_c),
+  make_tuple(&aom_masked_sad64x32_ssse3, &aom_masked_sad64x32_c),
+  make_tuple(&aom_masked_sad32x64_ssse3, &aom_masked_sad32x64_c),
+  make_tuple(&aom_masked_sad32x32_ssse3, &aom_masked_sad32x32_c),
+  make_tuple(&aom_masked_sad32x16_ssse3, &aom_masked_sad32x16_c),
+  make_tuple(&aom_masked_sad16x32_ssse3, &aom_masked_sad16x32_c),
+  make_tuple(&aom_masked_sad16x16_ssse3, &aom_masked_sad16x16_c),
+  make_tuple(&aom_masked_sad16x8_ssse3, &aom_masked_sad16x8_c),
+  make_tuple(&aom_masked_sad8x16_ssse3, &aom_masked_sad8x16_c),
+  make_tuple(&aom_masked_sad8x8_ssse3, &aom_masked_sad8x8_c),
+  make_tuple(&aom_masked_sad8x4_ssse3, &aom_masked_sad8x4_c),
+  make_tuple(&aom_masked_sad4x8_ssse3, &aom_masked_sad4x8_c),
+  make_tuple(&aom_masked_sad4x4_ssse3, &aom_masked_sad4x4_c)
+};
+
+INSTANTIATE_TEST_CASE_P(SSSE3_C_COMPARE, MaskedSADTest,
+                        ::testing::ValuesIn(msad_test));
+#if CONFIG_HIGHBITDEPTH
+const HighbdMaskedSADParam hbd_msad_test[] = {
+#if CONFIG_EXT_PARTITION
+  make_tuple(&aom_highbd_masked_sad128x128_ssse3,
+             &aom_highbd_masked_sad128x128_c),
+  make_tuple(&aom_highbd_masked_sad128x64_ssse3,
+             &aom_highbd_masked_sad128x64_c),
+  make_tuple(&aom_highbd_masked_sad64x128_ssse3,
+             &aom_highbd_masked_sad64x128_c),
+#endif  // CONFIG_EXT_PARTITION
+  make_tuple(&aom_highbd_masked_sad64x64_ssse3, &aom_highbd_masked_sad64x64_c),
+  make_tuple(&aom_highbd_masked_sad64x32_ssse3, &aom_highbd_masked_sad64x32_c),
+  make_tuple(&aom_highbd_masked_sad32x64_ssse3, &aom_highbd_masked_sad32x64_c),
+  make_tuple(&aom_highbd_masked_sad32x32_ssse3, &aom_highbd_masked_sad32x32_c),
+  make_tuple(&aom_highbd_masked_sad32x16_ssse3, &aom_highbd_masked_sad32x16_c),
+  make_tuple(&aom_highbd_masked_sad16x32_ssse3, &aom_highbd_masked_sad16x32_c),
+  make_tuple(&aom_highbd_masked_sad16x16_ssse3, &aom_highbd_masked_sad16x16_c),
+  make_tuple(&aom_highbd_masked_sad16x8_ssse3, &aom_highbd_masked_sad16x8_c),
+  make_tuple(&aom_highbd_masked_sad8x16_ssse3, &aom_highbd_masked_sad8x16_c),
+  make_tuple(&aom_highbd_masked_sad8x8_ssse3, &aom_highbd_masked_sad8x8_c),
+  make_tuple(&aom_highbd_masked_sad8x4_ssse3, &aom_highbd_masked_sad8x4_c),
+  make_tuple(&aom_highbd_masked_sad4x8_ssse3, &aom_highbd_masked_sad4x8_c),
+  make_tuple(&aom_highbd_masked_sad4x4_ssse3, &aom_highbd_masked_sad4x4_c)
+};
+
+INSTANTIATE_TEST_CASE_P(SSSE3_C_COMPARE, HighbdMaskedSADTest,
+                        ::testing::ValuesIn(hbd_msad_test));
 #endif  // CONFIG_HIGHBITDEPTH
 #endif  // HAVE_SSSE3
 }  // namespace
--- a/third_party/aom/test/masked_variance_test.cc
+++ b/third_party/aom/test/masked_variance_test.cc
@@ -54,40 +54,35 @@ class MaskedSubPixelVarianceTest
   MaskedSubPixelVarianceFunc opt_func_;
   MaskedSubPixelVarianceFunc ref_func_;
 };
 
 TEST_P(MaskedSubPixelVarianceTest, OperationCheck) {
   unsigned int ref_ret, opt_ret;
   unsigned int ref_sse, opt_sse;
   ACMRandom rnd(ACMRandom::DeterministicSeed());
-  // Note: We pad the input arrays out with 15 extra elements, since the SSE
-  // implementations can read up to 15 elements off the end of the main data.
-  // The extra data is never actually used, but it simplifies the code
-  // if we can do this.
+  // Note: We pad out the input array to a multiple of 16 bytes wide, so that
+  // consecutive rows keep the 16-byte alignment.
+  DECLARE_ALIGNED(16, uint8_t, src_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16)]);
+  DECLARE_ALIGNED(16, uint8_t, ref_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16)]);
   DECLARE_ALIGNED(16, uint8_t,
-                  src_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 15]);
-  DECLARE_ALIGNED(16, uint8_t,
-                  ref_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 15]);
-  DECLARE_ALIGNED(16, uint8_t,
-                  second_pred_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 15]);
-  DECLARE_ALIGNED(16, uint8_t,
-                  msk_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 15]);
+                  second_pred_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16)]);
+  DECLARE_ALIGNED(16, uint8_t, msk_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16)]);
   int err_count = 0;
   int first_failure = -1;
-  int src_stride = (MAX_SB_SIZE + 1);
-  int ref_stride = (MAX_SB_SIZE + 1);
-  int msk_stride = (MAX_SB_SIZE + 1);
+  int src_stride = (MAX_SB_SIZE + 16);
+  int ref_stride = (MAX_SB_SIZE + 16);
+  int msk_stride = (MAX_SB_SIZE + 16);
   int xoffset;
   int yoffset;
 
   for (int i = 0; i < number_of_iterations; ++i) {
     int xoffsets[] = { 0, 4, rnd(BIL_SUBPEL_SHIFTS) };
     int yoffsets[] = { 0, 4, rnd(BIL_SUBPEL_SHIFTS) };
-    for (int j = 0; j < (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1); j++) {
+    for (int j = 0; j < (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16); j++) {
       src_ptr[j] = rnd.Rand8();
       ref_ptr[j] = rnd.Rand8();
       second_pred_ptr[j] = rnd.Rand8();
       msk_ptr[j] = rnd(65);
     }
     for (int k = 0; k < 3; k++) {
       for (int l = 0; l < 3; l++) {
         xoffset = xoffsets[k];
@@ -115,43 +110,40 @@ TEST_P(MaskedSubPixelVarianceTest, Opera
       << "C output doesn't match SSSE3 output. "
       << "First failed at test case " << first_failure;
 }
 
 TEST_P(MaskedSubPixelVarianceTest, ExtremeValues) {
   unsigned int ref_ret, opt_ret;
   unsigned int ref_sse, opt_sse;
   ACMRandom rnd(ACMRandom::DeterministicSeed());
-  DECLARE_ALIGNED(16, uint8_t,
-                  src_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 15]);
+  DECLARE_ALIGNED(16, uint8_t, src_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16)]);
+  DECLARE_ALIGNED(16, uint8_t, ref_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16)]);
   DECLARE_ALIGNED(16, uint8_t,
-                  ref_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 15]);
-  DECLARE_ALIGNED(16, uint8_t,
-                  second_pred_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 15]);
-  DECLARE_ALIGNED(16, uint8_t,
-                  msk_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 15]);
+                  second_pred_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16)]);
+  DECLARE_ALIGNED(16, uint8_t, msk_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16)]);
   int first_failure_x = -1;
   int first_failure_y = -1;
   int err_count = 0;
   int first_failure = -1;
-  int src_stride = (MAX_SB_SIZE + 1);
-  int ref_stride = (MAX_SB_SIZE + 1);
-  int msk_stride = (MAX_SB_SIZE + 1);
+  int src_stride = (MAX_SB_SIZE + 16);
+  int ref_stride = (MAX_SB_SIZE + 16);
+  int msk_stride = (MAX_SB_SIZE + 16);
 
   for (int xoffset = 0; xoffset < BIL_SUBPEL_SHIFTS; xoffset++) {
     for (int yoffset = 0; yoffset < BIL_SUBPEL_SHIFTS; yoffset++) {
       for (int i = 0; i < 16; ++i) {
         memset(src_ptr, (i & 0x1) ? 255 : 0,
-               (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1));
+               (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16));
         memset(ref_ptr, (i & 0x2) ? 255 : 0,
-               (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1));
+               (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16));
         memset(second_pred_ptr, (i & 0x4) ? 255 : 0,
-               (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1));
+               (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16));
         memset(msk_ptr, (i & 0x8) ? 64 : 0,
-               (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1));
+               (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 16));
 
         for (int invert_mask = 0; invert_mask < 2; ++invert_mask) {
           ref_ret = ref_func_(src_ptr, src_stride, xoffset, yoffset, ref_ptr,
                               ref_stride, second_pred_ptr, msk_ptr, msk_stride,
                               invert_mask, &ref_sse);
           ASM_REGISTER_STATE_CHECK(
               opt_ret = opt_func_(src_ptr, src_stride, xoffset, yoffset,
                                   ref_ptr, ref_stride, second_pred_ptr, msk_ptr,
@@ -199,42 +191,35 @@ class HighbdMaskedSubPixelVarianceTest
   MaskedSubPixelVarianceFunc ref_func_;
   aom_bit_depth_t bit_depth_;
 };
 
 TEST_P(HighbdMaskedSubPixelVarianceTest, OperationCheck) {
   unsigned int ref_ret, opt_ret;
   unsigned int ref_sse, opt_sse;
   ACMRandom rnd(ACMRandom::DeterministicSeed());
-  // Note: We pad the input arrays out with 7 extra elements, since the SSE
-  // implementations can read up to 7 elements off the end of the main data.
-  // The extra data is never actually used, but it simplifies the code
-  // if we can do this.
+  DECLARE_ALIGNED(16, uint16_t, src_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8)]);
+  DECLARE_ALIGNED(16, uint16_t, ref_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8)]);
   DECLARE_ALIGNED(16, uint16_t,
-                  src_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 7]);
-  DECLARE_ALIGNED(16, uint16_t,
-                  ref_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 7]);
-  DECLARE_ALIGNED(16, uint16_t,
-                  second_pred_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 7]);
-  DECLARE_ALIGNED(16, uint8_t,
-                  msk_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 7]);
+                  second_pred_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8)]);
+  DECLARE_ALIGNED(16, uint8_t, msk_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8)]);
   uint8_t *src8_ptr = CONVERT_TO_BYTEPTR(src_ptr);
   uint8_t *ref8_ptr = CONVERT_TO_BYTEPTR(ref_ptr);
   uint8_t *second_pred8_ptr = CONVERT_TO_BYTEPTR(second_pred_ptr);
   int err_count = 0;
   int first_failure = -1;
   int first_failure_x = -1;
   int first_failure_y = -1;
-  int src_stride = (MAX_SB_SIZE + 1);
-  int ref_stride = (MAX_SB_SIZE + 1);
-  int msk_stride = (MAX_SB_SIZE + 1);
+  int src_stride = (MAX_SB_SIZE + 8);
+  int ref_stride = (MAX_SB_SIZE + 8);
+  int msk_stride = (MAX_SB_SIZE + 8);
   int xoffset, yoffset;
 
   for (int i = 0; i < number_of_iterations; ++i) {
-    for (int j = 0; j < (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1); j++) {
+    for (int j = 0; j < (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8); j++) {
       src_ptr[j] = rnd.Rand16() & ((1 << bit_depth_) - 1);
       ref_ptr[j] = rnd.Rand16() & ((1 << bit_depth_) - 1);
       second_pred_ptr[j] = rnd.Rand16() & ((1 << bit_depth_) - 1);
       msk_ptr[j] = rnd(65);
     }
     for (xoffset = 0; xoffset < BIL_SUBPEL_SHIFTS; xoffset++) {
       for (yoffset = 0; yoffset < BIL_SUBPEL_SHIFTS; yoffset++) {
         for (int invert_mask = 0; invert_mask < 2; ++invert_mask) {
@@ -265,46 +250,43 @@ TEST_P(HighbdMaskedSubPixelVarianceTest,
       << "First failed at test case " << first_failure
       << " x_offset = " << first_failure_x << " y_offset = " << first_failure_y;
 }
 
 TEST_P(HighbdMaskedSubPixelVarianceTest, ExtremeValues) {
   unsigned int ref_ret, opt_ret;
   unsigned int ref_sse, opt_sse;
   ACMRandom rnd(ACMRandom::DeterministicSeed());
-  DECLARE_ALIGNED(16, uint16_t,
-                  src_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 7]);
+  DECLARE_ALIGNED(16, uint16_t, src_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8)]);
+  DECLARE_ALIGNED(16, uint16_t, ref_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8)]);
+  DECLARE_ALIGNED(16, uint8_t, msk_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8)]);
   DECLARE_ALIGNED(16, uint16_t,
-                  ref_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 7]);
-  DECLARE_ALIGNED(16, uint8_t,
-                  msk_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 7]);
-  DECLARE_ALIGNED(16, uint16_t,
-                  second_pred_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1) + 7]);
+                  second_pred_ptr[(MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8)]);
   uint8_t *src8_ptr = CONVERT_TO_BYTEPTR(src_ptr);
   uint8_t *ref8_ptr = CONVERT_TO_BYTEPTR(ref_ptr);
   uint8_t *second_pred8_ptr = CONVERT_TO_BYTEPTR(second_pred_ptr);
   int first_failure_x = -1;
   int first_failure_y = -1;
   int err_count = 0;
   int first_failure = -1;
-  int src_stride = (MAX_SB_SIZE + 1);
-  int ref_stride = (MAX_SB_SIZE + 1);
-  int msk_stride = (MAX_SB_SIZE + 1);
+  int src_stride = (MAX_SB_SIZE + 8);
+  int ref_stride = (MAX_SB_SIZE + 8);
+  int msk_stride = (MAX_SB_SIZE + 8);
 
   for (int xoffset = 0; xoffset < BIL_SUBPEL_SHIFTS; xoffset++) {
     for (int yoffset = 0; yoffset < BIL_SUBPEL_SHIFTS; yoffset++) {
       for (int i = 0; i < 16; ++i) {
         aom_memset16(src_ptr, (i & 0x1) ? ((1 << bit_depth_) - 1) : 0,
-                     (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1));
+                     (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8));
         aom_memset16(ref_ptr, (i & 0x2) ? ((1 << bit_depth_) - 1) : 0,
-                     (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1));
+                     (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8));
         aom_memset16(second_pred_ptr, (i & 0x4) ? ((1 << bit_depth_) - 1) : 0,
-                     (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1));
+                     (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8));
         memset(msk_ptr, (i & 0x8) ? 64 : 0,
-               (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 1));
+               (MAX_SB_SIZE + 1) * (MAX_SB_SIZE + 8));
 
         for (int invert_mask = 0; invert_mask < 2; ++invert_mask) {
           ref_ret = ref_func_(src8_ptr, src_stride, xoffset, yoffset, ref8_ptr,
                               ref_stride, second_pred8_ptr, msk_ptr, msk_stride,
                               invert_mask, &ref_sse);
           ASM_REGISTER_STATE_CHECK(
               opt_ret = opt_func_(src8_ptr, src_stride, xoffset, yoffset,
                                   ref8_ptr, ref_stride, second_pred8_ptr,
@@ -329,178 +311,161 @@ TEST_P(HighbdMaskedSubPixelVarianceTest,
                           << " x_offset = " << first_failure_x
                           << " y_offset = " << first_failure_y;
 }
 #endif  // CONFIG_HIGHBITDEPTH
 
 using std::tr1::make_tuple;
 
 #if HAVE_SSSE3
-INSTANTIATE_TEST_CASE_P(
-    SSSE3_C_COMPARE, MaskedSubPixelVarianceTest,
-    ::testing::Values(
+
+const MaskedSubPixelVarianceParam sub_pel_var_test[] = {
 #if CONFIG_EXT_PARTITION
-        make_tuple(&aom_masked_sub_pixel_variance128x128_ssse3,
-                   &aom_masked_sub_pixel_variance128x128_c),
-        make_tuple(&aom_masked_sub_pixel_variance128x64_ssse3,
-                   &aom_masked_sub_pixel_variance128x64_c),
-        make_tuple(&aom_masked_sub_pixel_variance64x128_ssse3,
-                   &aom_masked_sub_pixel_variance64x128_c),
+  make_tuple(&aom_masked_sub_pixel_variance128x128_ssse3,
+             &aom_masked_sub_pixel_variance128x128_c),
+  make_tuple(&aom_masked_sub_pixel_variance128x64_ssse3,
+             &aom_masked_sub_pixel_variance128x64_c),
+  make_tuple(&aom_masked_sub_pixel_variance64x128_ssse3,
+             &aom_masked_sub_pixel_variance64x128_c),
 #endif  // CONFIG_EXT_PARTITION
-        make_tuple(&aom_masked_sub_pixel_variance64x64_ssse3,
-                   &aom_masked_sub_pixel_variance64x64_c),
-        make_tuple(&aom_masked_sub_pixel_variance64x32_ssse3,
-                   &aom_masked_sub_pixel_variance64x32_c),
-        make_tuple(&aom_masked_sub_pixel_variance32x64_ssse3,
-                   &aom_masked_sub_pixel_variance32x64_c),
-        make_tuple(&aom_masked_sub_pixel_variance32x32_ssse3,
-                   &aom_masked_sub_pixel_variance32x32_c),
-        make_tuple(&aom_masked_sub_pixel_variance32x16_ssse3,
-                   &aom_masked_sub_pixel_variance32x16_c),
-        make_tuple(&aom_masked_sub_pixel_variance16x32_ssse3,
-                   &aom_masked_sub_pixel_variance16x32_c),
-        make_tuple(&aom_masked_sub_pixel_variance16x16_ssse3,
-                   &aom_masked_sub_pixel_variance16x16_c),
-        make_tuple(&aom_masked_sub_pixel_variance16x8_ssse3,
-                   &aom_masked_sub_pixel_variance16x8_c),
-        make_tuple(&aom_masked_sub_pixel_variance8x16_ssse3,
-                   &aom_masked_sub_pixel_variance8x16_c),
-        make_tuple(&aom_masked_sub_pixel_variance8x8_ssse3,
-                   &aom_masked_sub_pixel_variance8x8_c),
-        make_tuple(&aom_masked_sub_pixel_variance8x4_ssse3,
-                   &aom_masked_sub_pixel_variance8x4_c),
-        make_tuple(&aom_masked_sub_pixel_variance4x8_ssse3,
-                   &aom_masked_sub_pixel_variance4x8_c),
-        make_tuple(&aom_masked_sub_pixel_variance4x4_ssse3,
-                   &aom_masked_sub_pixel_variance4x4_c)));
+  make_tuple(&aom_masked_sub_pixel_variance64x64_ssse3,
+             &aom_masked_sub_pixel_variance64x64_c),
+  make_tuple(&aom_masked_sub_pixel_variance64x32_ssse3,
+             &aom_masked_sub_pixel_variance64x32_c),
+  make_tuple(&aom_masked_sub_pixel_variance32x64_ssse3,
+             &aom_masked_sub_pixel_variance32x64_c),
+  make_tuple(&aom_masked_sub_pixel_variance32x32_ssse3,
+             &aom_masked_sub_pixel_variance32x32_c),
+  make_tuple(&aom_masked_sub_pixel_variance32x16_ssse3,
+             &aom_masked_sub_pixel_variance32x16_c),
+  make_tuple(&aom_masked_sub_pixel_variance16x32_ssse3,
+             &aom_masked_sub_pixel_variance16x32_c),
+  make_tuple(&aom_masked_sub_pixel_variance16x16_ssse3,
+             &aom_masked_sub_pixel_variance16x16_c),
+  make_tuple(&aom_masked_sub_pixel_variance16x8_ssse3,
+             &aom_masked_sub_pixel_variance16x8_c),
+  make_tuple(&aom_masked_sub_pixel_variance8x16_ssse3,
+             &aom_masked_sub_pixel_variance8x16_c),
+  make_tuple(&aom_masked_sub_pixel_variance8x8_ssse3,
+             &aom_masked_sub_pixel_variance8x8_c),
+  make_tuple(&aom_masked_sub_pixel_variance8x4_ssse3,
+             &aom_masked_sub_pixel_variance8x4_c),
+  make_tuple(&aom_masked_sub_pixel_variance4x8_ssse3,
+             &aom_masked_sub_pixel_variance4x8_c),
+  make_tuple(&aom_masked_sub_pixel_variance4x4_ssse3,
+             &aom_masked_sub_pixel_variance4x4_c)
+};
+
+INSTANTIATE_TEST_CASE_P(SSSE3_C_COMPARE, MaskedSubPixelVarianceTest,
+                        ::testing::ValuesIn(sub_pel_var_test));
 
 #if CONFIG_HIGHBITDEPTH
-INSTANTIATE_TEST_CASE_P(
-    SSSE3_C_COMPARE, HighbdMaskedSubPixelVarianceTest,
-    ::testing::Values(
+const HighbdMaskedSubPixelVarianceParam hbd_sub_pel_var_test[] = {
 #if CONFIG_EXT_PARTITION
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance128x128_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance128x128_c,
-                   AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance128x64_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance128x64_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance64x128_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance64x128_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance128x128_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance128x128_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance128x64_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance128x64_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance64x128_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance64x128_c, AOM_BITS_8),
 #endif  // CONFIG_EXT_PARTITION
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance64x64_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance64x64_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance64x32_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance64x32_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance32x64_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance32x64_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance32x32_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance32x32_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance32x16_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance32x16_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance16x32_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance16x32_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance16x16_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance16x16_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance16x8_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance16x8_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance8x16_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance8x16_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance8x8_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance8x8_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance8x4_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance8x4_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance4x8_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance4x8_c, AOM_BITS_8),
-        make_tuple(&aom_highbd_8_masked_sub_pixel_variance4x4_ssse3,
-                   &aom_highbd_8_masked_sub_pixel_variance4x4_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance64x64_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance64x64_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance64x32_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance64x32_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance32x64_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance32x64_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance32x32_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance32x32_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance32x16_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance32x16_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance16x32_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance16x32_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance16x16_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance16x16_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance16x8_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance16x8_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance8x16_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance8x16_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance8x8_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance8x8_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance8x4_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance8x4_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance4x8_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance4x8_c, AOM_BITS_8),
+  make_tuple(&aom_highbd_8_masked_sub_pixel_variance4x4_ssse3,
+             &aom_highbd_8_masked_sub_pixel_variance4x4_c, AOM_BITS_8),
 #if CONFIG_EXT_PARTITION
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance128x128_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance128x128_c,
-                   AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance128x64_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance128x64_c,
-                   AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance64x128_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance64x128_c,
-                   AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance128x128_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance128x128_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance128x64_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance128x64_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance64x128_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance64x128_c, AOM_BITS_10),
 #endif  // CONFIG_EXT_PARTITION
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance64x64_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance64x64_c,
-                   AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance64x32_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance64x32_c,
-                   AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance32x64_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance32x64_c,
-                   AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance32x32_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance32x32_c,
-                   AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance32x16_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance32x16_c,
-                   AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance16x32_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance16x32_c,
-                   AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance16x16_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance16x16_c,
-                   AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance16x8_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance16x8_c, AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance8x16_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance8x16_c, AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance8x8_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance8x8_c, AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance8x4_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance8x4_c, AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance4x8_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance4x8_c, AOM_BITS_10),
-        make_tuple(&aom_highbd_10_masked_sub_pixel_variance4x4_ssse3,
-                   &aom_highbd_10_masked_sub_pixel_variance4x4_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance64x64_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance64x64_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance64x32_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance64x32_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance32x64_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance32x64_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance32x32_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance32x32_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance32x16_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance32x16_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance16x32_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance16x32_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance16x16_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance16x16_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance16x8_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance16x8_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance8x16_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance8x16_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance8x8_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance8x8_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance8x4_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance8x4_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance4x8_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance4x8_c, AOM_BITS_10),
+  make_tuple(&aom_highbd_10_masked_sub_pixel_variance4x4_ssse3,
+             &aom_highbd_10_masked_sub_pixel_variance4x4_c, AOM_BITS_10),
 #if CONFIG_EXT_PARTITION
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance128x128_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance128x128_c,
-                   AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance128x64_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance128x64_c,
-                   AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance64x128_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance64x128_c,
-                   AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance128x128_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance128x128_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance128x64_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance128x64_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance64x128_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance64x128_c, AOM_BITS_12),
 #endif  // CONFIG_EXT_PARTITION
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance64x64_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance64x64_c,
-                   AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance64x32_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance64x32_c,
-                   AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance32x64_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance32x64_c,
-                   AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance32x32_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance32x32_c,
-                   AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance32x16_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance32x16_c,
-                   AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance16x32_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance16x32_c,
-                   AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance16x16_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance16x16_c,
-                   AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance16x8_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance16x8_c, AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance8x16_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance8x16_c, AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance8x8_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance8x8_c, AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance8x4_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance8x4_c, AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance4x8_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance4x8_c, AOM_BITS_12),
-        make_tuple(&aom_highbd_12_masked_sub_pixel_variance4x4_ssse3,
-                   &aom_highbd_12_masked_sub_pixel_variance4x4_c,
-                   AOM_BITS_12)));
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance64x64_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance64x64_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance64x32_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance64x32_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance32x64_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance32x64_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance32x32_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance32x32_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance32x16_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance32x16_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance16x32_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance16x32_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance16x16_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance16x16_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance16x8_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance16x8_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance8x16_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance8x16_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance8x8_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance8x8_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance8x4_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance8x4_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance4x8_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance4x8_c, AOM_BITS_12),
+  make_tuple(&aom_highbd_12_masked_sub_pixel_variance4x4_ssse3,
+             &aom_highbd_12_masked_sub_pixel_variance4x4_c, AOM_BITS_12)
+};
+
+INSTANTIATE_TEST_CASE_P(SSSE3_C_COMPARE, HighbdMaskedSubPixelVarianceTest,
+                        ::testing::ValuesIn(hbd_sub_pel_var_test));
 #endif  // CONFIG_HIGHBITDEPTH
 
 #endif  // HAVE_SSSE3
 }  // namespace
--- a/third_party/aom/test/motion_vector_test.cc
+++ b/third_party/aom/test/motion_vector_test.cc
@@ -27,19 +27,19 @@ const libaom_test::TestMode kEncodingMod
 
 // Encoding speeds
 const int kCpuUsedVectors[] = { 1, 5 };
 
 // MV test modes: 1 - always use maximum MV; 2 - always use minimum MV.
 const int kMVTestModes[] = { MAX_EXTREME_MV, MIN_EXTREME_MV };
 
 class MotionVectorTestLarge
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith3Params<libaom_test::TestMode, int,
-                                                 int> {
+    : public ::libaom_test::CodecTestWith3Params<libaom_test::TestMode, int,
+                                                 int>,
+      public ::libaom_test::EncoderTest {
  protected:
   MotionVectorTestLarge()
       : EncoderTest(GET_PARAM(0)), encoding_mode_(GET_PARAM(1)),
         cpu_used_(GET_PARAM(2)), mv_test_mode_(GET_PARAM(3)) {}
 
   virtual ~MotionVectorTestLarge() {}
 
   virtual void SetUp() {
--- a/third_party/aom/test/partial_idct_test.cc
+++ b/third_party/aom/test/partial_idct_test.cc
@@ -36,23 +36,16 @@ typedef void (*InvTxfmWithBdFunc)(const 
                                   int stride, int bd);
 
 template <InvTxfmFunc fn>
 void wrapper(const tran_low_t *in, uint8_t *out, int stride, int bd) {
   (void)bd;
   fn(in, out, stride);
 }
 
-#if CONFIG_HIGHBITDEPTH
-template <InvTxfmWithBdFunc fn>
-void highbd_wrapper(const tran_low_t *in, uint8_t *out, int stride, int bd) {
-  fn(in, CONVERT_TO_BYTEPTR(out), stride, bd);
-}
-#endif
-
 typedef std::tr1::tuple<FwdTxfmFunc, InvTxfmWithBdFunc, InvTxfmWithBdFunc,
                         TX_SIZE, int, int, int>
     PartialInvTxfmParam;
 const int kMaxNumCoeffs = 1024;
 const int kCountTestBlock = 10000;
 
 class PartialIDctTest : public ::testing::TestWithParam<PartialInvTxfmParam> {
  public:
@@ -280,36 +273,16 @@ TEST_P(PartialIDctTest, DISABLED_Speed) 
   ASSERT_EQ(0, memcmp(output_block_ref_, output_block_,
                       pixel_size_ * output_block_size_))
       << "Error: partial inverse transform produces different results";
 }
 
 using std::tr1::make_tuple;
 
 const PartialInvTxfmParam c_partial_idct_tests[] = {
-#if CONFIG_HIGHBITDEPTH
-  make_tuple(&aom_highbd_fdct4x4_c,
-             &highbd_wrapper<aom_highbd_idct4x4_16_add_c>,
-             &highbd_wrapper<aom_highbd_idct4x4_16_add_c>, TX_4X4, 16, 8, 2),
-  make_tuple(&aom_highbd_fdct4x4_c,
-             &highbd_wrapper<aom_highbd_idct4x4_16_add_c>,
-             &highbd_wrapper<aom_highbd_idct4x4_16_add_c>, TX_4X4, 16, 10, 2),
-  make_tuple(&aom_highbd_fdct4x4_c,
-             &highbd_wrapper<aom_highbd_idct4x4_16_add_c>,
-             &highbd_wrapper<aom_highbd_idct4x4_16_add_c>, TX_4X4, 16, 12, 2),
-  make_tuple(&aom_highbd_fdct4x4_c,
-             &highbd_wrapper<aom_highbd_idct4x4_16_add_c>,
-             &highbd_wrapper<aom_highbd_idct4x4_1_add_c>, TX_4X4, 1, 8, 2),
-  make_tuple(&aom_highbd_fdct4x4_c,
-             &highbd_wrapper<aom_highbd_idct4x4_16_add_c>,
-             &highbd_wrapper<aom_highbd_idct4x4_1_add_c>, TX_4X4, 1, 10, 2),
-  make_tuple(&aom_highbd_fdct4x4_c,
-             &highbd_wrapper<aom_highbd_idct4x4_16_add_c>,
-             &highbd_wrapper<aom_highbd_idct4x4_1_add_c>, TX_4X4, 1, 12, 2),
-#endif  // CONFIG_HIGHBITDEPTH
   make_tuple(&aom_fdct32x32_c, &wrapper<aom_idct32x32_1024_add_c>,
              &wrapper<aom_idct32x32_1024_add_c>, TX_32X32, 1024, 8, 1),
   make_tuple(&aom_fdct32x32_c, &wrapper<aom_idct32x32_1024_add_c>,
              &wrapper<aom_idct32x32_135_add_c>, TX_32X32, 135, 8, 1),
   make_tuple(&aom_fdct32x32_c, &wrapper<aom_idct32x32_1024_add_c>,
              &wrapper<aom_idct32x32_34_add_c>, TX_32X32, 34, 8, 1),
   make_tuple(&aom_fdct32x32_c, &wrapper<aom_idct32x32_1024_add_c>,
              &wrapper<aom_idct32x32_1_add_c>, TX_32X32, 1, 8, 1),
@@ -353,27 +326,16 @@ const PartialInvTxfmParam neon_partial_i
 };
 
 INSTANTIATE_TEST_CASE_P(NEON, PartialIDctTest,
                         ::testing::ValuesIn(neon_partial_idct_tests));
 #endif  // HAVE_NEON && !CONFIG_HIGHBITDEPTH
 
 #if HAVE_SSE2
 const PartialInvTxfmParam sse2_partial_idct_tests[] = {
-#if CONFIG_HIGHBITDEPTH
-  make_tuple(&aom_highbd_fdct4x4_c,
-             &highbd_wrapper<aom_highbd_idct4x4_16_add_c>,
-             &highbd_wrapper<aom_highbd_idct4x4_16_add_sse2>, TX_4X4, 16, 8, 2),
-  make_tuple(
-      &aom_highbd_fdct4x4_c, &highbd_wrapper<aom_highbd_idct4x4_16_add_c>,
-      &highbd_wrapper<aom_highbd_idct4x4_16_add_sse2>, TX_4X4, 16, 10, 2),
-  make_tuple(
-      &aom_highbd_fdct4x4_c, &highbd_wrapper<aom_highbd_idct4x4_16_add_c>,
-      &highbd_wrapper<aom_highbd_idct4x4_16_add_sse2>, TX_4X4, 16, 12, 2),
-#endif  // CONFIG_HIGHBITDEPTH
   make_tuple(&aom_fdct32x32_c, &wrapper<aom_idct32x32_1024_add_c>,
              &wrapper<aom_idct32x32_1024_add_sse2>, TX_32X32, 1024, 8, 1),
   make_tuple(&aom_fdct32x32_c, &wrapper<aom_idct32x32_1024_add_c>,
              &wrapper<aom_idct32x32_1024_add_sse2>, TX_32X32, 135, 8, 1),
   make_tuple(&aom_fdct32x32_c, &wrapper<aom_idct32x32_1024_add_c>,
              &wrapper<aom_idct32x32_34_add_sse2>, TX_32X32, 34, 8, 1),
   make_tuple(&aom_fdct32x32_c, &wrapper<aom_idct32x32_1024_add_c>,
              &wrapper<aom_idct32x32_1_add_sse2>, TX_32X32, 1, 8, 1),
--- a/third_party/aom/test/quantize_func_test.cc
+++ b/third_party/aom/test/quantize_func_test.cc
@@ -7,230 +7,382 @@
  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
  * Media Patent License 1.0 was not distributed with this source code in the
  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  */
 
 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 
 #include "./aom_config.h"
+#include "./aom_dsp_rtcd.h"
 #include "./av1_rtcd.h"
 #include "aom/aom_codec.h"
+#include "aom_ports/aom_timer.h"
 #include "av1/encoder/encoder.h"
 #include "av1/encoder/av1_quantize.h"
 #include "test/acm_random.h"
 #include "test/clear_system_state.h"
 #include "test/register_state_check.h"
 #include "test/util.h"
 
 namespace {
 using libaom_test::ACMRandom;
 
-#if !CONFIG_AOM_QM
-typedef void (*QuantizeFunc)(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
-                             int skip_block, const int16_t *zbin_ptr,
-                             const int16_t *round_ptr, const int16_t *quant_ptr,
-                             const int16_t *quant_shift_ptr,
-                             tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
-                             const int16_t *dequant_ptr, uint16_t *eob_ptr,
-                             const int16_t *scan, const int16_t *iscan);
-#else
-typedef void (*QuantizeFunc)(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
-                             int skip_block, const int16_t *zbin_ptr,
-                             const int16_t *round_ptr, const int16_t *quant_ptr,
-                             const int16_t *quant_shift_ptr,
-                             tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
-                             const int16_t *dequant_ptr, uint16_t *eob_ptr,
-                             const int16_t *scan, const int16_t *iscan,
-                             const qm_val_t *qm_ptr, const qm_val_t *iqm_ptr);
-#endif
+#define QUAN_PARAM_LIST                                                   \
+  const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block,         \
+      const int16_t *zbin_ptr, const int16_t *round_ptr,                  \
+      const int16_t *quant_ptr, const int16_t *quant_shift_ptr,           \
+      tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,                    \
+      const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, \
+      const int16_t *iscan
+
+typedef void (*QuantizeFunc)(QUAN_PARAM_LIST);
+typedef void (*QuantizeFuncHbd)(QUAN_PARAM_LIST, int log_scale);
+
+#define HBD_QUAN_FUNC                                                      \
+  fn(coeff_ptr, n_coeffs, skip_block, zbin_ptr, round_ptr, quant_ptr,      \
+     quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr, eob_ptr, scan, \
+     iscan, log_scale)
 
-typedef std::tr1::tuple<QuantizeFunc, QuantizeFunc, TX_SIZE, aom_bit_depth_t>
+template <QuantizeFuncHbd fn>
+void highbd_quan16x16_wrapper(QUAN_PARAM_LIST) {
+  const int log_scale = 0;
+  HBD_QUAN_FUNC;
+}
+
+template <QuantizeFuncHbd fn>
+void highbd_quan32x32_wrapper(QUAN_PARAM_LIST) {
+  const int log_scale = 1;
+  HBD_QUAN_FUNC;
+}
+
+template <QuantizeFuncHbd fn>
+void highbd_quan64x64_wrapper(QUAN_PARAM_LIST) {
+  const int log_scale = 2;
+  HBD_QUAN_FUNC;
+}
+
+typedef enum { TYPE_B, TYPE_DC, TYPE_FP } QuantType;
+
+typedef std::tr1::tuple<QuantizeFunc, QuantizeFunc, TX_SIZE, QuantType,
+                        aom_bit_depth_t>
     QuantizeParam;
 
 typedef struct {
   QUANTS quant;
   Dequants dequant;
 } QuanTable;
 
 const int kTestNum = 1000;
 
 class QuantizeTest : public ::testing::TestWithParam<QuantizeParam> {
  protected:
   QuantizeTest()
       : quant_ref_(GET_PARAM(0)), quant_(GET_PARAM(1)), tx_size_(GET_PARAM(2)),
-        bd_(GET_PARAM(3)) {}
+        type_(GET_PARAM(3)), bd_(GET_PARAM(4)) {}
 
   virtual ~QuantizeTest() {}
 
   virtual void SetUp() {
-    qtab_ = reinterpret_cast<QuanTable *>(aom_memalign(16, sizeof(*qtab_)));
-    const int n_coeffs = getCoeffNum();
+    qtab_ = reinterpret_cast<QuanTable *>(aom_memalign(32, sizeof(*qtab_)));
+    const int n_coeffs = coeff_num();
     coeff_ = reinterpret_cast<tran_low_t *>(
-        aom_memalign(16, 6 * n_coeffs * sizeof(tran_low_t)));
+        aom_memalign(32, 6 * n_coeffs * sizeof(tran_low_t)));
     InitQuantizer();
   }
 
   virtual void TearDown() {
     aom_free(qtab_);
     qtab_ = NULL;
     aom_free(coeff_);
     coeff_ = NULL;
     libaom_test::ClearSystemState();
   }
 
   void InitQuantizer() {
     av1_build_quantizer(bd_, 0, 0, 0, &qtab_->quant, &qtab_->dequant);
   }
 
-  void QuantizeRun(bool isLoop, int q = 0, int testNum = 1) {
+  void QuantizeRun(bool is_loop, int q = 0, int test_num = 1) {
     tran_low_t *coeff_ptr = coeff_;
-    const intptr_t n_coeffs = getCoeffNum();
+    const intptr_t n_coeffs = coeff_num();
     const int skip_block = 0;
 
     tran_low_t *qcoeff_ref = coeff_ptr + n_coeffs;
     tran_low_t *dqcoeff_ref = qcoeff_ref + n_coeffs;
 
     tran_low_t *qcoeff = dqcoeff_ref + n_coeffs;
     tran_low_t *dqcoeff = qcoeff + n_coeffs;
     uint16_t *eob = (uint16_t *)(dqcoeff + n_coeffs);
 
     // Testing uses 2-D DCT scan order table
     const SCAN_ORDER *const sc = get_default_scan(tx_size_, DCT_DCT, 0);
 
     // Testing uses luminance quantization table
     const int16_t *zbin = qtab_->quant.y_zbin[q];
-    const int16_t *round_fp = qtab_->quant.y_round_fp[q];
-    const int16_t *quant_fp = qtab_->quant.y_quant_fp[q];
+
+    const int16_t *round = 0;
+    const int16_t *quant = 0;
+    if (type_ == TYPE_B) {
+      round = qtab_->quant.y_round[q];
+      quant = qtab_->quant.y_quant[q];
+    } else if (type_ == TYPE_FP) {
+      round = qtab_->quant.y_round_fp[q];
+      quant = qtab_->quant.y_quant_fp[q];
+    }
+
     const int16_t *quant_shift = qtab_->quant.y_quant_shift[q];
     const int16_t *dequant = qtab_->dequant.y_dequant[q];
-    const size_t bufferSize = n_coeffs;
 
-    int i = 0;
-    while (i < testNum) {
-      if (isLoop) FillCoeffRandom();
+    for (int i = 0; i < test_num; ++i) {
+      if (is_loop) FillCoeffRandom();
 
       memset(qcoeff_ref, 0, 5 * n_coeffs * sizeof(*qcoeff_ref));
 
-      quant_ref_(coeff_ptr, n_coeffs, skip_block, zbin, round_fp, quant_fp,
+      quant_ref_(coeff_ptr, n_coeffs, skip_block, zbin, round, quant,
                  quant_shift, qcoeff_ref, dqcoeff_ref, dequant, &eob[0],
                  sc->scan, sc->iscan);
 
       ASM_REGISTER_STATE_CHECK(quant_(
-          coeff_ptr, n_coeffs, skip_block, zbin, round_fp, quant_fp,
-          quant_shift, qcoeff, dqcoeff, dequant, &eob[1], sc->scan, sc->iscan));
+          coeff_ptr, n_coeffs, skip_block, zbin, round, quant, quant_shift,
+          qcoeff, dqcoeff, dequant, &eob[1], sc->scan, sc->iscan));
+
+      for (int j = 0; j < n_coeffs; ++j) {
+        ASSERT_EQ(qcoeff_ref[j], qcoeff[j])
+            << "Q mismatch on test: " << i << " at position: " << j
+            << " Q: " << q << " coeff: " << coeff_ptr[j];
+      }
 
-      CompareResults(qcoeff_ref, qcoeff, bufferSize, "Qcoeff", q, i);
-      CompareResults(dqcoeff_ref, dqcoeff, bufferSize, "Dqcoeff", q, i);
-      ASSERT_EQ(eob[0], eob[1]) << "eobs mismatch on test: " << i;
+      for (int j = 0; j < n_coeffs; ++j) {
+        ASSERT_EQ(dqcoeff_ref[j], dqcoeff[j])
+            << "Dq mismatch on test: " << i << " at position: " << j
+            << " Q: " << q << " coeff: " << coeff_ptr[j];
+      }
 
-      i++;
+      ASSERT_EQ(eob[0], eob[1]) << "eobs mismatch on test: " << i
+                                << " Q: " << q;
     }
   }
 
   void CompareResults(const tran_low_t *buf_ref, const tran_low_t *buf,
                       int size, const char *text, int q, int number) {
     int i;
     for (i = 0; i < size; ++i) {
       ASSERT_EQ(buf_ref[i], buf[i]) << text << " mismatch on test: " << number
                                     << " at position: " << i << " Q: " << q;
     }
   }
 
-  int getCoeffNum() { return tx_size_2d[tx_size_]; }
+  int coeff_num() const { return tx_size_2d[tx_size_]; }
 
-  void FillCoeffGeneric(bool isConstant, tran_low_t c = 0) {
-    const int n_coeffs = getCoeffNum();
-    int i;
-    if (isConstant) {
-      for (i = 0; i < n_coeffs; ++i) {
-        coeff_[i] = c;
-      }
-    } else {
-      FillCoeffZero();
-      int num = rnd_.Rand16() % n_coeffs;
-      for (i = 0; i < num; ++i) {
-        coeff_[i] = GetRandomCoeff();
-      }
+  void FillCoeff(tran_low_t c) {
+    const int n_coeffs = coeff_num();
+    for (int i = 0; i < n_coeffs; ++i) {
+      coeff_[i] = c;
     }
   }
 
-  void FillCoeffZero() { FillCoeffGeneric(true); }
+  void FillCoeffRandom() {
+    const int n_coeffs = coeff_num();
+    FillCoeffZero();
+    int num = rnd_.Rand16() % n_coeffs;
+    for (int i = 0; i < num; ++i) {
+      coeff_[i] = GetRandomCoeff();
+    }
+  }
+
+  void FillCoeffZero() { FillCoeff(0); }
 
   void FillCoeffConstant() {
     tran_low_t c = GetRandomCoeff();
-    FillCoeffGeneric(true, c);
+    FillCoeff(c);
   }
 
   void FillDcOnly() {
     FillCoeffZero();
     coeff_[0] = GetRandomCoeff();
   }
 
   void FillDcLargeNegative() {
     FillCoeffZero();
     // Generate a qcoeff which contains 512/-512 (0x0100/0xFE00) to catch issues
     // like BUG=883 where the constant being compared was incorrectly
     // initialized.
     coeff_[0] = -8191;
   }
 
-  void FillCoeffRandom() { FillCoeffGeneric(false); }
-
   tran_low_t GetRandomCoeff() {
-    return clamp((int16_t)rnd_.Rand16(), INT16_MIN + 1, INT16_MAX);
+    tran_low_t coeff;
+    if (bd_ == AOM_BITS_8) {
+      coeff =
+          clamp(static_cast<int16_t>(rnd_.Rand16()), INT16_MIN + 1, INT16_MAX);
+    } else {
+      tran_low_t min = -(1 << (7 + bd_));
+      tran_low_t max = -min - 1;
+      coeff = clamp(static_cast<tran_low_t>(rnd_.Rand31()), min, max);
+    }
+    return coeff;
   }
 
   ACMRandom rnd_;
   QuanTable *qtab_;
   tran_low_t *coeff_;
   QuantizeFunc quant_ref_;
   QuantizeFunc quant_;
   TX_SIZE tx_size_;
+  QuantType type_;
   aom_bit_depth_t bd_;
 };
 
 TEST_P(QuantizeTest, ZeroInput) {
   FillCoeffZero();
   QuantizeRun(false);
 }
 
 TEST_P(QuantizeTest, LargeNegativeInput) {
   FillDcLargeNegative();
-  QuantizeRun(false);
+  QuantizeRun(false, 0, 1);
 }
 
 TEST_P(QuantizeTest, DcOnlyInput) {
   FillDcOnly();
-  QuantizeRun(false);
+  QuantizeRun(false, 0, 1);
 }
 
 TEST_P(QuantizeTest, RandomInput) { QuantizeRun(true, 0, kTestNum); }
 
 TEST_P(QuantizeTest, MultipleQ) {
   for (int q = 0; q < QINDEX_RANGE; ++q) {
     QuantizeRun(true, q, kTestNum);
   }
 }
 
+TEST_P(QuantizeTest, DISABLED_Speed) {
+  tran_low_t *coeff_ptr = coeff_;
+  const intptr_t n_coeffs = coeff_num();
+  const int skip_block = 0;
+
+  tran_low_t *qcoeff_ref = coeff_ptr + n_coeffs;
+  tran_low_t *dqcoeff_ref = qcoeff_ref + n_coeffs;
+
+  tran_low_t *qcoeff = dqcoeff_ref + n_coeffs;
+  tran_low_t *dqcoeff = qcoeff + n_coeffs;
+  uint16_t *eob = (uint16_t *)(dqcoeff + n_coeffs);
+
+  // Testing uses 2-D DCT scan order table
+  const SCAN_ORDER *const sc = get_default_scan(tx_size_, DCT_DCT, 0);
+
+  // Testing uses luminance quantization table
+  const int q = 22;
+  const int16_t *zbin = qtab_->quant.y_zbin[q];
+  const int16_t *round_fp = qtab_->quant.y_round_fp[q];
+  const int16_t *quant_fp = qtab_->quant.y_quant_fp[q];
+  const int16_t *quant_shift = qtab_->quant.y_quant_shift[q];
+  const int16_t *dequant = qtab_->dequant.y_dequant[q];
+  const int kNumTests = 5000000;
+  aom_usec_timer timer;
+
+  FillCoeffRandom();
+
+  aom_usec_timer_start(&timer);
+  for (int n = 0; n < kNumTests; ++n) {
+    quant_(coeff_ptr, n_coeffs, skip_block, zbin, round_fp, quant_fp,
+           quant_shift, qcoeff, dqcoeff, dequant, eob, sc->scan, sc->iscan);
+  }
+  aom_usec_timer_mark(&timer);
+
+  const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
+  printf("Elapsed time: %d us\n", elapsed_time);
+}
+
 using std::tr1::make_tuple;
 
+#if HAVE_AVX2
+const QuantizeParam kQParamArrayAvx2[] = {
+  make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_avx2, TX_16X16, TYPE_FP,
+             AOM_BITS_8),
+  make_tuple(&av1_quantize_fp_32x32_c, &av1_quantize_fp_32x32_avx2, TX_32X32,
+             TYPE_FP, AOM_BITS_8),
+#if CONFIG_HIGHBITDEPTH
+  make_tuple(&highbd_quan16x16_wrapper<av1_highbd_quantize_fp_c>,
+             &highbd_quan16x16_wrapper<av1_highbd_quantize_fp_avx2>, TX_16X16,
+             TYPE_FP, AOM_BITS_8),
+  make_tuple(&highbd_quan16x16_wrapper<av1_highbd_quantize_fp_c>,
+             &highbd_quan16x16_wrapper<av1_highbd_quantize_fp_avx2>, TX_16X16,
+             TYPE_FP, AOM_BITS_10),
+  make_tuple(&highbd_quan16x16_wrapper<av1_highbd_quantize_fp_c>,
+             &highbd_quan16x16_wrapper<av1_highbd_quantize_fp_avx2>, TX_16X16,
+             TYPE_FP, AOM_BITS_12),
+  make_tuple(&highbd_quan32x32_wrapper<av1_highbd_quantize_fp_c>,
+             &highbd_quan32x32_wrapper<av1_highbd_quantize_fp_avx2>, TX_32X32,
+             TYPE_FP, AOM_BITS_8),
+  make_tuple(&highbd_quan32x32_wrapper<av1_highbd_quantize_fp_c>,
+             &highbd_quan32x32_wrapper<av1_highbd_quantize_fp_avx2>, TX_32X32,
+             TYPE_FP, AOM_BITS_10),
+  make_tuple(&highbd_quan32x32_wrapper<av1_highbd_quantize_fp_c>,
+             &highbd_quan32x32_wrapper<av1_highbd_quantize_fp_avx2>, TX_32X32,
+             TYPE_FP, AOM_BITS_12),
+#if CONFIG_TX64X64
+  make_tuple(&highbd_quan64x64_wrapper<av1_highbd_quantize_fp_c>,
+             &highbd_quan64x64_wrapper<av1_highbd_quantize_fp_avx2>, TX_64X64,
+             TYPE_FP, AOM_BITS_8),
+  make_tuple(&highbd_quan64x64_wrapper<av1_highbd_quantize_fp_c>,
+             &highbd_quan64x64_wrapper<av1_highbd_quantize_fp_avx2>, TX_64X64,
+             TYPE_FP, AOM_BITS_10),
+  make_tuple(&highbd_quan64x64_wrapper<av1_highbd_quantize_fp_c>,
+             &highbd_quan64x64_wrapper<av1_highbd_quantize_fp_avx2>, TX_64X64,
+             TYPE_FP, AOM_BITS_12),
+#endif  // CONFIG_TX64X64
+  make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_avx2, TX_16X16,
+             TYPE_B, AOM_BITS_8),
+  make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_avx2, TX_16X16,
+             TYPE_B, AOM_BITS_10),
+  make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_avx2, TX_16X16,
+             TYPE_B, AOM_BITS_12),
+#endif  // CONFIG_HIGHBITDEPTH
+};
+
+INSTANTIATE_TEST_CASE_P(AVX2, QuantizeTest,
+                        ::testing::ValuesIn(kQParamArrayAvx2));
+#endif  // HAVE_AVX2
+
 #if HAVE_SSE2
-const QuantizeParam kQParamArraySSE2[] = { make_tuple(
-    &av1_quantize_fp_c, &av1_quantize_fp_sse2, TX_16X16, AOM_BITS_8) };
+const QuantizeParam kQParamArraySSE2[] = {
+  make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_sse2, TX_16X16, TYPE_FP,
+             AOM_BITS_8),
+#if CONFIG_HIGHBITDEPTH
+  make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_sse2, TX_16X16,
+             TYPE_B, AOM_BITS_8),
+  make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_sse2, TX_16X16,
+             TYPE_B, AOM_BITS_10),
+  make_tuple(&aom_highbd_quantize_b_c, &aom_highbd_quantize_b_sse2, TX_16X16,
+             TYPE_B, AOM_BITS_12),
+  make_tuple(&aom_highbd_quantize_b_32x32_c, &aom_highbd_quantize_b_32x32_sse2,
+             TX_32X32, TYPE_B, AOM_BITS_8),
+  make_tuple(&aom_highbd_quantize_b_32x32_c, &aom_highbd_quantize_b_32x32_sse2,
+             TX_32X32, TYPE_B, AOM_BITS_10),
+  make_tuple(&aom_highbd_quantize_b_32x32_c, &aom_highbd_quantize_b_32x32_sse2,
+             TX_32X32, TYPE_B, AOM_BITS_12),
+#endif
+};
 
 INSTANTIATE_TEST_CASE_P(SSE2, QuantizeTest,
                         ::testing::ValuesIn(kQParamArraySSE2));
 #endif
 
 #if !CONFIG_HIGHBITDEPTH && HAVE_SSSE3 && ARCH_X86_64
-const QuantizeParam kQParamArraySSSE3[] = {
-  make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_ssse3, TX_16X16, AOM_BITS_8),
-  // TODO(any):
-  //  The following test couldn't pass yet
-  // make_tuple(av1_quantize_fp_c, av1_quantize_fp_32x32_ssse3, TX_32X32,
-  // AOM_BITS_8)
+const QuantizeParam kQ16x16ParamArraySSSE3[] = {
+  make_tuple(&av1_quantize_fp_c, &av1_quantize_fp_ssse3, TX_16X16, TYPE_FP,
+             AOM_BITS_8),
 };
 INSTANTIATE_TEST_CASE_P(SSSE3, QuantizeTest,
-                        ::testing::ValuesIn(kQParamArraySSSE3));
+                        ::testing::ValuesIn(kQ16x16ParamArraySSSE3));
+
+// TODO(any):
+//  The following test does not pass yet
+const QuantizeParam kQ32x32ParamArraySSSE3[] = { make_tuple(
+    av1_quantize_fp_32x32_c, av1_quantize_fp_32x32_ssse3, TX_32X32, TYPE_FP,
+    AOM_BITS_8) };
+INSTANTIATE_TEST_CASE_P(DISABLED_SSSE3, QuantizeTest,
+                        ::testing::ValuesIn(kQ32x32ParamArraySSSE3));
 #endif
 
 }  // namespace
--- a/third_party/aom/test/realtime_test.cc
+++ b/third_party/aom/test/realtime_test.cc
@@ -17,18 +17,18 @@
 
 namespace {
 
 const int kVideoSourceWidth = 320;
 const int kVideoSourceHeight = 240;
 const int kFramesToEncode = 2;
 
 class RealtimeTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWithParam<libaom_test::TestMode> {
+    : public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>,
+      public ::libaom_test::EncoderTest {
  protected:
   RealtimeTest() : EncoderTest(GET_PARAM(0)), frame_packets_(0) {}
   virtual ~RealtimeTest() {}
 
   virtual void SetUp() {
     InitializeConfig();
     cfg_.g_lag_in_frames = 0;
     SetMode(::libaom_test::kRealTime);
--- a/third_party/aom/test/resize_test.cc
+++ b/third_party/aom/test/resize_test.cc
@@ -260,18 +260,18 @@ class ResizingVideoSource : public ::lib
     ScaleForFrameNumber(frame_, kInitialWidth, kInitialHeight, &width, &height,
                         flag_codec_);
     SetSize(width, height);
     FillFrame();
   }
 };
 
 class ResizeTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWithParam<libaom_test::TestMode> {
+    : public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>,
+      public ::libaom_test::EncoderTest {
  protected:
   ResizeTest() : EncoderTest(GET_PARAM(0)) {}
 
   virtual ~ResizeTest() {}
 
   virtual void SetUp() {
     InitializeConfig();
     SetMode(GET_PARAM(1));
@@ -422,18 +422,18 @@ TEST_P(ResizeInternalTest, TestInternalR
                                        30, 1, 0, 10);
   cfg_.g_w = 352;
   cfg_.g_h = 288;
   change_config_ = true;
   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
 }
 
 class ResizeRealtimeTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int> {
+    : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
+      public ::libaom_test::EncoderTest {
  protected:
   ResizeRealtimeTest() : EncoderTest(GET_PARAM(0)) {}
   virtual ~ResizeRealtimeTest() {}
 
   virtual void PreEncodeFrameHook(libaom_test::VideoSource *video,
                                   libaom_test::Encoder *encoder) {
     if (video->frame() == 0) {
       encoder->Control(AV1E_SET_AQ_MODE, 3);
@@ -477,35 +477,31 @@ class ResizeRealtimeTest
     cfg_.rc_end_usage = AOM_CBR;
     cfg_.kf_mode = AOM_KF_AUTO;
     cfg_.g_lag_in_frames = 0;
     cfg_.kf_min_dist = cfg_.kf_max_dist = 3000;
     // Enable dropped frames.
     cfg_.rc_dropframe_thresh = 1;
     // Enable error_resilience mode.
     cfg_.g_error_resilient = 1;
-    // Enable dynamic resizing.
-    cfg_.rc_resize_allowed = 1;
     // Run at low bitrate.
     cfg_.rc_target_bitrate = 200;
   }
 
   std::vector<FrameInfo> frame_info_list_;
   int set_cpu_used_;
   bool change_bitrate_;
   double mismatch_psnr_;
   int mismatch_nframes_;
 };
 
 TEST_P(ResizeRealtimeTest, TestExternalResizeWorks) {
   ResizingVideoSource video;
   video.flag_codec_ = 1;
   DefaultConfig();
-  // Disable internal resize for this test.
-  cfg_.rc_resize_allowed = 0;
   change_bitrate_ = false;
   mismatch_psnr_ = 0.0;
   mismatch_nframes_ = 0;
   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
 
   for (std::vector<FrameInfo>::const_iterator info = frame_info_list_.begin();
        info != frame_info_list_.end(); ++info) {
     const unsigned int frame = static_cast<unsigned>(info->pts);
--- a/third_party/aom/test/sad_test.cc
+++ b/third_party/aom/test/sad_test.cc
@@ -226,18 +226,18 @@ class SADTestBase : public ::testing::Te
   static uint16_t *source_data16_;
   static uint16_t *reference_data16_;
   static uint16_t *second_pred16_;
   int reference_stride_;
 
   ACMRandom rnd_;
 };
 
-class SADx4Test : public SADTestBase,
-                  public ::testing::WithParamInterface<SadMxNx4Param> {
+class SADx4Test : public ::testing::WithParamInterface<SadMxNx4Param>,
+                  public SADTestBase {
  public:
   SADx4Test() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
 
  protected:
   void SADs(unsigned int *results) {
     const uint8_t *references[] = { GetReference(0), GetReference(1),
                                     GetReference(2), GetReference(3) };
 
@@ -252,18 +252,18 @@ class SADx4Test : public SADTestBase,
     for (int block = 0; block < 4; ++block) {
       reference_sad = ReferenceSAD(block);
 
       EXPECT_EQ(reference_sad, exp_sad[block]) << "block " << block;
     }
   }
 };
 
-class SADTest : public SADTestBase,
-                public ::testing::WithParamInterface<SadMxNParam> {
+class SADTest : public ::testing::WithParamInterface<SadMxNParam>,
+                public SADTestBase {
  public:
   SADTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
 
  protected:
   unsigned int SAD(int block_idx) {
     unsigned int ret;
     const uint8_t *const reference = GetReference(block_idx);
 
@@ -283,18 +283,18 @@ class SADTest : public SADTestBase,
     int test_count = 20000000;
     while (test_count > 0) {
       SAD(0);
       test_count -= 1;
     }
   }
 };
 
-class SADavgTest : public SADTestBase,
-                   public ::testing::WithParamInterface<SadMxNAvgParam> {
+class SADavgTest : public ::testing::WithParamInterface<SadMxNAvgParam>,
+                   public SADTestBase {
  public:
   SADavgTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
 
  protected:
   unsigned int SAD_avg(int block_idx) {
     unsigned int ret;
     const uint8_t *const reference = GetReference(block_idx);
 
--- a/third_party/aom/test/simd_cmp_impl.h
+++ b/third_party/aom/test/simd_cmp_impl.h
@@ -1585,20 +1585,20 @@ void TestSimd2Args(uint32_t iterations, 
           reinterpret_cast<fptr>(c_v256_load_aligned),
           reinterpret_cast<fptr>(c_v256_load_aligned),
           reinterpret_cast<fptr>(ref_simd), ref_d, s1, s2);
     } else if (typeid(CRet) == typeid(int64_t) &&
                typeid(CArg1) == typeid(c_v256) &&
                typeid(CArg2) == typeid(c_v256)) {
       // S64_V256V256
       error = CompareSimd2Args<int64_t, v256, v256, CRet, CArg1, CArg2>(
-          reinterpret_cast<fptr>(u64_store_aligned),
+          reinterpret_cast<fptr>(s64_store_aligned),
           reinterpret_cast<fptr>(v256_load_aligned),
           reinterpret_cast<fptr>(v256_load_aligned), simd, d,
-          reinterpret_cast<fptr>(c_u64_store_aligned),
+          reinterpret_cast<fptr>(c_s64_store_aligned),
           reinterpret_cast<fptr>(c_v256_load_aligned),
           reinterpret_cast<fptr>(c_v256_load_aligned),
           reinterpret_cast<fptr>(ref_simd), ref_d, s1, s2);
     } else if (typeid(CRet) == typeid(uint32_t) &&
                typeid(CArg1) == typeid(c_v256) &&
                typeid(CArg2) == typeid(c_v256)) {
       // U32_V256V256
       error = CompareSimd2Args<uint32_t, v256, v256, CRet, CArg1, CArg2>(
--- a/third_party/aom/test/subtract_test.cc
+++ b/third_party/aom/test/subtract_test.cc
@@ -208,45 +208,49 @@ void AV1HBDSubtractBlockTest::CheckResul
 
 TEST_P(AV1HBDSubtractBlockTest, CheckResult) { CheckResult(); }
 
 #if USE_SPEED_TEST
 TEST_P(AV1HBDSubtractBlockTest, CheckSpeed) { RunForSpeed(); }
 #endif  // USE_SPEED_TEST
 
 #if HAVE_SSE2
-INSTANTIATE_TEST_CASE_P(
-    SSE2, AV1HBDSubtractBlockTest,
-    ::testing::Values(make_tuple(4, 4, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(4, 4, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(4, 8, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(4, 8, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(8, 4, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(8, 4, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(8, 8, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(8, 8, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(8, 16, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(8, 16, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(16, 8, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(16, 8, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(16, 16, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(16, 16, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(16, 32, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(16, 32, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(32, 16, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(32, 16, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(32, 32, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(32, 32, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(32, 64, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(32, 64, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(64, 32, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(64, 32, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(64, 64, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(64, 64, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(64, 128, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(64, 128, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(128, 64, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(128, 64, 12, &aom_highbd_subtract_block_c),
-                      make_tuple(128, 128, 12, &aom_highbd_subtract_block_sse2),
-                      make_tuple(128, 128, 12, &aom_highbd_subtract_block_c)));
+
+const Params kAV1HBDSubtractBlock_sse2[] = {
+  make_tuple(4, 4, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(4, 4, 12, &aom_highbd_subtract_block_c),
+  make_tuple(4, 8, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(4, 8, 12, &aom_highbd_subtract_block_c),
+  make_tuple(8, 4, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(8, 4, 12, &aom_highbd_subtract_block_c),
+  make_tuple(8, 8, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(8, 8, 12, &aom_highbd_subtract_block_c),
+  make_tuple(8, 16, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(8, 16, 12, &aom_highbd_subtract_block_c),
+  make_tuple(16, 8, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(16, 8, 12, &aom_highbd_subtract_block_c),
+  make_tuple(16, 16, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(16, 16, 12, &aom_highbd_subtract_block_c),
+  make_tuple(16, 32, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(16, 32, 12, &aom_highbd_subtract_block_c),
+  make_tuple(32, 16, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(32, 16, 12, &aom_highbd_subtract_block_c),
+  make_tuple(32, 32, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(32, 32, 12, &aom_highbd_subtract_block_c),
+  make_tuple(32, 64, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(32, 64, 12, &aom_highbd_subtract_block_c),
+  make_tuple(64, 32, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(64, 32, 12, &aom_highbd_subtract_block_c),
+  make_tuple(64, 64, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(64, 64, 12, &aom_highbd_subtract_block_c),
+  make_tuple(64, 128, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(64, 128, 12, &aom_highbd_subtract_block_c),
+  make_tuple(128, 64, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(128, 64, 12, &aom_highbd_subtract_block_c),
+  make_tuple(128, 128, 12, &aom_highbd_subtract_block_sse2),
+  make_tuple(128, 128, 12, &aom_highbd_subtract_block_c)
+};
+
+INSTANTIATE_TEST_CASE_P(SSE2, AV1HBDSubtractBlockTest,
+                        ::testing::ValuesIn(kAV1HBDSubtractBlock_sse2));
 #endif  // HAVE_SSE2
 #endif  // CONFIG_HIGHBITDEPTH
 }  // namespace
--- a/third_party/aom/test/superframe_test.cc
+++ b/third_party/aom/test/superframe_test.cc
@@ -20,18 +20,18 @@ namespace {
 
 const int kTestMode = 0;
 const int kTileCols = 1;
 const int kTileRows = 2;
 
 typedef std::tr1::tuple<libaom_test::TestMode, int, int> SuperframeTestParam;
 
 class SuperframeTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWithParam<SuperframeTestParam> {
+    : public ::libaom_test::CodecTestWithParam<SuperframeTestParam>,
+      public ::libaom_test::EncoderTest {
  protected:
   SuperframeTest()
       : EncoderTest(GET_PARAM(0)), modified_buf_(NULL), last_sf_pts_(0) {}
   virtual ~SuperframeTest() {}
 
   virtual void SetUp() {
     InitializeConfig();
     const SuperframeTestParam input = GET_PARAM(1);
@@ -58,26 +58,27 @@ class SuperframeTest
     }
   }
 
   virtual const aom_codec_cx_pkt_t *MutateEncoderOutputHook(
       const aom_codec_cx_pkt_t *pkt) {
     if (pkt->kind != AOM_CODEC_CX_FRAME_PKT) return pkt;
 
     const uint8_t *buffer = reinterpret_cast<uint8_t *>(pkt->data.frame.buf);
-    const uint8_t marker = buffer[pkt->data.frame.sz - 1];
+    const uint8_t marker = buffer[0];
     const int frames = (marker & 0x7) + 1;
     const int mag = ((marker >> 3) & 3) + 1;
     const unsigned int index_sz = 2 + mag * (frames - 1);
     if ((marker & 0xe0) == 0xc0 && pkt->data.frame.sz >= index_sz &&
-        buffer[pkt->data.frame.sz - index_sz] == marker) {
+        buffer[index_sz - 1] == marker) {
       // frame is a superframe. strip off the index.
-      if (modified_buf_) delete[] modified_buf_;
+      delete[] modified_buf_;
       modified_buf_ = new uint8_t[pkt->data.frame.sz - index_sz];
-      memcpy(modified_buf_, pkt->data.frame.buf, pkt->data.frame.sz - index_sz);
+      memcpy(modified_buf_, (uint8_t *)pkt->data.frame.buf + index_sz,
+             pkt->data.frame.sz - index_sz);
       modified_pkt_ = *pkt;
       modified_pkt_.data.frame.buf = modified_buf_;
       modified_pkt_.data.frame.sz -= index_sz;
 
       sf_count_++;
       last_sf_pts_ = pkt->data.frame.pts;
       return &modified_pkt_;
     }
--- a/third_party/aom/test/test.cmake
+++ b/third_party/aom/test/test.cmake
@@ -6,317 +6,383 @@
 ## was not distributed with this source code in the LICENSE file, you can
 ## obtain it at www.aomedia.org/license/software. If the Alliance for Open
 ## Media Patent License 1.0 was not distributed with this source code in the
 ## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 ##
 if (NOT AOM_TEST_TEST_CMAKE_)
 set(AOM_TEST_TEST_CMAKE_ 1)
 
+include(FindPythonInterp)
 include(ProcessorCount)
 
 include("${AOM_ROOT}/test/test_data_util.cmake")
 
 set(AOM_UNIT_TEST_DATA_LIST_FILE "${AOM_ROOT}/test/test-data.sha1")
 
 set(AOM_UNIT_TEST_WRAPPER_SOURCES
     "${AOM_CONFIG_DIR}/usage_exit.c"
     "${AOM_ROOT}/test/test_libaom.cc")
 
 set(AOM_UNIT_TEST_COMMON_SOURCES
     "${AOM_ROOT}/test/acm_random.h"
     "${AOM_ROOT}/test/clear_system_state.h"
     "${AOM_ROOT}/test/codec_factory.h"
-    "${AOM_ROOT}/test/convolve_test.cc"
     "${AOM_ROOT}/test/decode_test_driver.cc"
     "${AOM_ROOT}/test/decode_test_driver.h"
     "${AOM_ROOT}/test/function_equivalence_test.h"
     "${AOM_ROOT}/test/md5_helper.h"
     "${AOM_ROOT}/test/register_state_check.h"
     "${AOM_ROOT}/test/transform_test_base.h"
     "${AOM_ROOT}/test/util.h"
     "${AOM_ROOT}/test/video_source.h")
 
-if (CONFIG_ACCOUNTING)
-  set(AOM_UNIT_TEST_COMMON_SOURCES
-      ${AOM_UNIT_TEST_COMMON_SOURCES}
-      "${AOM_ROOT}/test/accounting_test.cc")
-endif ()
-
-if (CONFIG_ADAPT_SCAN)
+if (NOT BUILD_SHARED_LIBS)
   set(AOM_UNIT_TEST_COMMON_SOURCES
       ${AOM_UNIT_TEST_COMMON_SOURCES}
-      "${AOM_ROOT}/test/scan_test.cc")
-endif ()
+      "${AOM_ROOT}/test/convolve_test.cc"
+      "${AOM_ROOT}/test/simd_impl.h")
 
-if (CONFIG_GLOBAL_MOTION OR CONFIG_WARPED_MOTION)
-  if (HAVE_SSE2)
+  if (CONFIG_ACCOUNTING)
+    set(AOM_UNIT_TEST_COMMON_SOURCES
+        ${AOM_UNIT_TEST_COMMON_SOURCES}
+        "${AOM_ROOT}/test/accounting_test.cc")
+  endif ()
+
+  if (CONFIG_ADAPT_SCAN)
     set(AOM_UNIT_TEST_COMMON_SOURCES
         ${AOM_UNIT_TEST_COMMON_SOURCES}
-        "${AOM_ROOT}/test/warp_filter_test.cc"
-        "${AOM_ROOT}/test/warp_filter_test_util.cc"
-        "${AOM_ROOT}/test/warp_filter_test_util.h")
+        "${AOM_ROOT}/test/scan_test.cc")
+  endif ()
+
+  if (CONFIG_GLOBAL_MOTION OR CONFIG_WARPED_MOTION)
+    if (HAVE_SSE2)
+      set(AOM_UNIT_TEST_COMMON_SOURCES
+          ${AOM_UNIT_TEST_COMMON_SOURCES}
+          "${AOM_ROOT}/test/warp_filter_test.cc"
+          "${AOM_ROOT}/test/warp_filter_test_util.cc"
+          "${AOM_ROOT}/test/warp_filter_test_util.h")
+    endif ()
   endif ()
 endif ()
 
 set(AOM_UNIT_TEST_DECODER_SOURCES
     "${AOM_ROOT}/test/decode_api_test.cc"
     "${AOM_ROOT}/test/ivf_video_source.h")
 
 set(AOM_UNIT_TEST_ENCODER_SOURCES
     "${AOM_ROOT}/test/altref_test.cc"
     "${AOM_ROOT}/test/aq_segment_test.cc"
     "${AOM_ROOT}/test/datarate_test.cc"
-    "${AOM_ROOT}/test/dct16x16_test.cc"
-    "${AOM_ROOT}/test/dct32x32_test.cc"
     "${AOM_ROOT}/test/encode_api_test.cc"
     "${AOM_ROOT}/test/encode_test_driver.cc"
     "${AOM_ROOT}/test/encode_test_driver.h"
     "${AOM_ROOT}/test/error_resilience_test.cc"
     "${AOM_ROOT}/test/i420_video_source.h"
-    "${AOM_ROOT}/test/sad_test.cc"
     "${AOM_ROOT}/test/y4m_test.cc"
     "${AOM_ROOT}/test/y4m_video_source.h"
     "${AOM_ROOT}/test/yuv_video_source.h")
 
+if (NOT BUILD_SHARED_LIBS)
+  set(AOM_UNIT_TEST_ENCODER_SOURCES
+      ${AOM_UNIT_TEST_ENCODER_SOURCES}
+      "${AOM_ROOT}/test/dct16x16_test.cc"
+      "${AOM_ROOT}/test/dct32x32_test.cc"
+      "${AOM_ROOT}/test/sad_test.cc")
+endif ()
+
 set(AOM_DECODE_PERF_TEST_SOURCES "${AOM_ROOT}/test/decode_perf_test.cc")
 set(AOM_ENCODE_PERF_TEST_SOURCES "${AOM_ROOT}/test/encode_perf_test.cc")
 set(AOM_UNIT_TEST_WEBM_SOURCES "${AOM_ROOT}/test/webm_video_source.h")
 
 set(AOM_TEST_INTRA_PRED_SPEED_SOURCES
     "${AOM_CONFIG_DIR}/usage_exit.c"
     "${AOM_ROOT}/test/test_intra_pred_speed.cc")
 
-if (CONFIG_AV1)
-  set(AOM_UNIT_TEST_COMMON_SOURCES
-      ${AOM_UNIT_TEST_COMMON_SOURCES}
-      "${AOM_ROOT}/test/av1_convolve_optimz_test.cc"
-      "${AOM_ROOT}/test/av1_convolve_test.cc"
-      "${AOM_ROOT}/test/av1_txfm_test.cc"
-      "${AOM_ROOT}/test/av1_txfm_test.h"
-      "${AOM_ROOT}/test/intrapred_test.cc"
-      "${AOM_ROOT}/test/lpf_8_test.cc"
-      "${AOM_ROOT}/test/simd_cmp_impl.h")
-
-  if (CONFIG_CDEF)
+if (NOT BUILD_SHARED_LIBS)
+  if (CONFIG_AV1_DECODER OR CONFIG_AV1_ENCODER)
     set(AOM_UNIT_TEST_COMMON_SOURCES
         ${AOM_UNIT_TEST_COMMON_SOURCES}
-        "${AOM_ROOT}/test/clpf_test.cc")
-  endif ()
+        "${AOM_ROOT}/test/av1_convolve_optimz_test.cc"
+        "${AOM_ROOT}/test/av1_convolve_test.cc"
+        "${AOM_ROOT}/test/av1_txfm_test.cc"
+        "${AOM_ROOT}/test/av1_txfm_test.h"
+        "${AOM_ROOT}/test/intrapred_test.cc"
+        "${AOM_ROOT}/test/lpf_8_test.cc"
+        "${AOM_ROOT}/test/motion_vector_test.cc"
+        "${AOM_ROOT}/test/simd_cmp_impl.h")
 
-  if (CONFIG_FILTER_INTRA)
-    if (HAVE_SSE4_1)
+    if (CONFIG_CDEF)
       set(AOM_UNIT_TEST_COMMON_SOURCES
           ${AOM_UNIT_TEST_COMMON_SOURCES}
-          "${AOM_ROOT}/test/filterintra_predictors_test.cc")
+          "${AOM_ROOT}/test/clpf_test.cc"
+          "${AOM_ROOT}/test/dering_test.cc")
     endif ()
-  endif ()
+
+    if (CONFIG_FILTER_INTRA)
+      if (HAVE_SSE4_1)
+        set(AOM_UNIT_TEST_COMMON_SOURCES
+            ${AOM_UNIT_TEST_COMMON_SOURCES}
+            "${AOM_ROOT}/test/filterintra_predictors_test.cc")
+      endif ()
+    endif ()
+
+    if (CONFIG_INTRABC)
+        set(AOM_UNIT_TEST_COMMON_SOURCES
+            ${AOM_UNIT_TEST_COMMON_SOURCES}
+            "${AOM_ROOT}/test/intrabc_test.cc")
+    endif ()
 
-  set(AOM_UNIT_TEST_COMMON_INTRIN_NEON
-    ${AOM_UNIT_TEST_COMMON_INTRIN_NEON}
-      "${AOM_ROOT}/test/simd_cmp_neon.cc"
-      "${AOM_ROOT}/test/simd_neon_test.cc")
-  set(AOM_UNIT_TEST_COMMON_INTRIN_SSE2
-      ${AOM_UNIT_TEST_COMMON_INTRIN_SSE2}
-      "${AOM_ROOT}/test/simd_cmp_sse2.cc")
-  set(AOM_UNIT_TEST_COMMON_INTRIN_SSSE3
-      ${AOM_UNIT_TEST_COMMON_INTRIN_SSSE3}
-      "${AOM_ROOT}/test/simd_cmp_ssse3.cc")
-  set(AOM_UNIT_TEST_COMMON_INTRIN_SSE4_1
-      ${AOM_UNIT_TEST_COMMON_INTRIN_SSE4_1}
-      "${AOM_ROOT}/test/simd_cmp_sse4.cc")
+    if (CONFIG_LOOP_RESTORATION)
+      set(AOM_UNIT_TEST_COMMON_SOURCES
+          ${AOM_UNIT_TEST_COMMON_SOURCES}
+           "${AOM_ROOT}/test/hiprec_convolve_test.cc"
+            "${AOM_ROOT}/test/hiprec_convolve_test_util.cc"
+            "${AOM_ROOT}/test/hiprec_convolve_test_util.h"
+            "${AOM_ROOT}/test/selfguided_filter_test.cc")
+    endif ()
+
+    set(AOM_UNIT_TEST_COMMON_INTRIN_NEON
+        ${AOM_UNIT_TEST_COMMON_INTRIN_NEON}
+        "${AOM_ROOT}/test/simd_cmp_neon.cc"
+        "${AOM_ROOT}/test/simd_neon_test.cc")
+    set(AOM_UNIT_TEST_COMMON_INTRIN_SSE2
+        ${AOM_UNIT_TEST_COMMON_INTRIN_SSE2}
+        "${AOM_ROOT}/test/simd_sse2_test.cc"
+        "${AOM_ROOT}/test/simd_cmp_sse2.cc")
+    set(AOM_UNIT_TEST_COMMON_INTRIN_SSSE3
+        ${AOM_UNIT_TEST_COMMON_INTRIN_SSSE3}
+        "${AOM_ROOT}/test/simd_ssse3_test.cc"
+        "${AOM_ROOT}/test/simd_cmp_ssse3.cc")
+    set(AOM_UNIT_TEST_COMMON_INTRIN_SSE4_1
+        ${AOM_UNIT_TEST_COMMON_INTRIN_SSE4_1}
+        "${AOM_ROOT}/test/simd_sse4_test.cc"
+        "${AOM_ROOT}/test/simd_cmp_sse4.cc")
+    set(AOM_UNIT_TEST_COMMON_INTRIN_AVX2
+        ${AOM_UNIT_TEST_COMMON_INTRIN_AVX2}
+        "${AOM_ROOT}/test/simd_avx2_test.cc"
+        "${AOM_ROOT}/test/simd_cmp_avx2.cc")
+  endif ()
 endif ()
 
 if (CONFIG_AV1_ENCODER)
   set(AOM_UNIT_TEST_ENCODER_SOURCES
       ${AOM_UNIT_TEST_ENCODER_SOURCES}
       "${AOM_ROOT}/test/active_map_test.cc"
-      "${AOM_ROOT}/test/arf_freq_test.cc"
-      "${AOM_ROOT}/test/av1_dct_test.cc"
-      "${AOM_ROOT}/test/av1_fht16x16_test.cc"
-      "${AOM_ROOT}/test/av1_fht32x32_test.cc"
-      "${AOM_ROOT}/test/av1_fht8x8_test.cc"
-      "${AOM_ROOT}/test/av1_inv_txfm_test.cc"
-      "${AOM_ROOT}/test/av1_fwd_txfm1d_test.cc"
-      "${AOM_ROOT}/test/av1_fwd_txfm2d_test.cc"
-      "${AOM_ROOT}/test/av1_inv_txfm1d_test.cc"
-      "${AOM_ROOT}/test/av1_inv_txfm2d_test.cc"
-      "${AOM_ROOT}/test/avg_test.cc"
-      "${AOM_ROOT}/test/blend_a64_mask_1d_test.cc"
-      "${AOM_ROOT}/test/blend_a64_mask_test.cc"
       "${AOM_ROOT}/test/borders_test.cc"
       "${AOM_ROOT}/test/cpu_speed_test.cc"
       "${AOM_ROOT}/test/end_to_end_test.cc"
-      "${AOM_ROOT}/test/error_block_test.cc"
-      "${AOM_ROOT}/test/fdct4x4_test.cc"
-      "${AOM_ROOT}/test/fdct8x8_test.cc"
       "${AOM_ROOT}/test/frame_size_tests.cc"
-      "${AOM_ROOT}/test/hadamard_test.cc"
-      "${AOM_ROOT}/test/lossless_test.cc"
-      "${AOM_ROOT}/test/minmax_test.cc"
-      "${AOM_ROOT}/test/subtract_test.cc"
-      "${AOM_ROOT}/test/sum_squares_test.cc"
-      "${AOM_ROOT}/test/variance_test.cc")
+      "${AOM_ROOT}/test/lossless_test.cc")
 
-  if (CONFIG_EXT_INTER)
-    set(AOM_UNIT_TEST_ENCODER_SOURCES
-        ${AOM_UNIT_TEST_ENCODER_SOURCES}
-        "${AOM_ROOT}/test/av1_wedge_utils_test.cc"
-        "${AOM_ROOT}/test/masked_sad_test.cc"
-        "${AOM_ROOT}/test/masked_variance_test.cc")
-  endif ()
-
-  if (CONFIG_EXT_TX)
+  if (NOT BUILD_SHARED_LIBS)
     set(AOM_UNIT_TEST_ENCODER_SOURCES
         ${AOM_UNIT_TEST_ENCODER_SOURCES}
-        "${AOM_ROOT}/test/av1_fht16x32_test.cc"
-        "${AOM_ROOT}/test/av1_fht16x8_test.cc"
-        "${AOM_ROOT}/test/av1_fht32x16_test.cc"
-        "${AOM_ROOT}/test/av1_fht4x4_test.cc"
-        "${AOM_ROOT}/test/av1_fht4x8_test.cc"
-        "${AOM_ROOT}/test/av1_fht8x16_test.cc"
-        "${AOM_ROOT}/test/av1_fht8x4_test.cc")
-        
-  endif ()
+        "${AOM_ROOT}/test/arf_freq_test.cc"
+        "${AOM_ROOT}/test/av1_dct_test.cc"
+        "${AOM_ROOT}/test/av1_fht16x16_test.cc"
+        "${AOM_ROOT}/test/av1_fht32x32_test.cc"
+        "${AOM_ROOT}/test/av1_fht8x8_test.cc"
+        "${AOM_ROOT}/test/av1_inv_txfm_test.cc"
+        "${AOM_ROOT}/test/av1_fwd_txfm1d_test.cc"
+        "${AOM_ROOT}/test/av1_fwd_txfm2d_test.cc"
+        "${AOM_ROOT}/test/av1_inv_txfm1d_test.cc"
+        "${AOM_ROOT}/test/av1_inv_txfm2d_test.cc"
+        "${AOM_ROOT}/test/avg_test.cc"
+        "${AOM_ROOT}/test/blend_a64_mask_1d_test.cc"
+        "${AOM_ROOT}/test/blend_a64_mask_test.cc"
+        "${AOM_ROOT}/test/error_block_test.cc"
+        "${AOM_ROOT}/test/fdct4x4_test.cc"
+        "${AOM_ROOT}/test/fdct8x8_test.cc"
+        "${AOM_ROOT}/test/hadamard_test.cc"
+        "${AOM_ROOT}/test/minmax_test.cc"
+        "${AOM_ROOT}/test/quantize_func_test.cc"
+        "${AOM_ROOT}/test/subtract_test.cc"
+        "${AOM_ROOT}/test/sum_squares_test.cc"
+        "${AOM_ROOT}/test/variance_test.cc")
+
+    if (CONFIG_CONVOLVE_ROUND)
+      set(AOM_UNIT_TEST_ENCODER_SOURCES
+          ${AOM_UNIT_TEST_ENCODER_SOURCES}
+          "${AOM_ROOT}/test/av1_convolve_2d_test.cc"
+          "${AOM_ROOT}/test/av1_convolve_2d_test_util.cc"
+          "${AOM_ROOT}/test/av1_convolve_2d_test_util.h")
+    endif ()
 
-  if (CONFIG_GLOBAL_MOTION)
-    set(AOM_UNIT_TEST_ENCODER_INTRIN_SSE4_1
-        ${AOM_UNIT_TEST_ENCODER_INTRIN_SSE4_1}
-        "${AOM_ROOT}/test/corner_match_test.cc")
-  endif ()
+    if (CONFIG_EXT_INTER)
+      set(AOM_UNIT_TEST_ENCODER_SOURCES
+          ${AOM_UNIT_TEST_ENCODER_SOURCES}
+          "${AOM_ROOT}/test/av1_wedge_utils_test.cc"
+          "${AOM_ROOT}/test/masked_sad_test.cc"
+          "${AOM_ROOT}/test/masked_variance_test.cc")
+    endif ()
 
-  if (CONFIG_MOTION_VAR)
-    set(AOM_UNIT_TEST_ENCODER_SOURCES
-        ${AOM_UNIT_TEST_ENCODER_SOURCES}
-        "${AOM_ROOT}/test/obmc_sad_test.cc"
-        "${AOM_ROOT}/test/obmc_variance_test.cc")
-  endif ()
+    if (CONFIG_EXT_TX)
+      set(AOM_UNIT_TEST_ENCODER_SOURCES
+          ${AOM_UNIT_TEST_ENCODER_SOURCES}
+          "${AOM_ROOT}/test/av1_fht16x32_test.cc"
+          "${AOM_ROOT}/test/av1_fht16x8_test.cc"
+          "${AOM_ROOT}/test/av1_fht32x16_test.cc"
+          "${AOM_ROOT}/test/av1_fht4x4_test.cc"
+          "${AOM_ROOT}/test/av1_fht4x8_test.cc"
+          "${AOM_ROOT}/test/av1_fht8x16_test.cc"
+          "${AOM_ROOT}/test/av1_fht8x4_test.cc")
+    endif ()
 
-  if (CONFIG_TX64X64)
-    set(AOM_UNIT_TEST_ENCODER_SOURCES
-        ${AOM_UNIT_TEST_ENCODER_SOURCES}
-        "${AOM_ROOT}/test/av1_fht64x64_test.cc")
+    if (CONFIG_GLOBAL_MOTION)
+      set(AOM_UNIT_TEST_ENCODER_INTRIN_SSE4_1
+          ${AOM_UNIT_TEST_ENCODER_INTRIN_SSE4_1}
+          "${AOM_ROOT}/test/corner_match_test.cc")
+    endif ()
+
+    if (CONFIG_MOTION_VAR)
+      set(AOM_UNIT_TEST_ENCODER_SOURCES
+          ${AOM_UNIT_TEST_ENCODER_SOURCES}
+          "${AOM_ROOT}/test/obmc_sad_test.cc"
+          "${AOM_ROOT}/test/obmc_variance_test.cc")
+    endif ()
+
+    if (CONFIG_TX64X64)
+      set(AOM_UNIT_TEST_ENCODER_SOURCES
+          ${AOM_UNIT_TEST_ENCODER_SOURCES}
+          "${AOM_ROOT}/test/av1_fht64x64_test.cc")
+    endif ()
   endif ()
 endif ()
 
-if (CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
-  set(AOM_UNIT_TEST_COMMON_SOURCES
-      ${AOM_UNIT_TEST_COMMON_SOURCES}
-      "${AOM_ROOT}/test/divu_small_test.cc"
-      "${AOM_ROOT}/test/ethread_test.cc"
-      "${AOM_ROOT}/test/idct8x8_test.cc"
-      "${AOM_ROOT}/test/partial_idct_test.cc"
-      "${AOM_ROOT}/test/superframe_test.cc"
-      "${AOM_ROOT}/test/binary_codes_test.cc"
-      "${AOM_ROOT}/test/tile_independence_test.cc")
-
-  if (CONFIG_ANS)
+if (NOT BUILD_SHARED_LIBS)
+  if (CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
     set(AOM_UNIT_TEST_COMMON_SOURCES
         ${AOM_UNIT_TEST_COMMON_SOURCES}
-        "${AOM_ROOT}/test/ans_codec_test.cc"
-        "${AOM_ROOT}/test/ans_test.cc")
-  else ()
-    set(AOM_UNIT_TEST_COMMON_SOURCES
-        ${AOM_UNIT_TEST_COMMON_SOURCES}
-        "${AOM_ROOT}/test/boolcoder_test.cc")
-  endif ()
+        "${AOM_ROOT}/test/binary_codes_test.cc"
+        "${AOM_ROOT}/test/divu_small_test.cc"
+        "${AOM_ROOT}/test/ethread_test.cc"
+        "${AOM_ROOT}/test/idct8x8_test.cc"
+        "${AOM_ROOT}/test/partial_idct_test.cc"
+        "${AOM_ROOT}/test/superframe_test.cc"
+        "${AOM_ROOT}/test/tile_independence_test.cc")
 
-  if (CONFIG_EXT_TILE)
-    set(AOM_UNIT_TEST_COMMON_SOURCES
-        ${AOM_UNIT_TEST_COMMON_SOURCES}
-        "${AOM_ROOT}/test/av1_ext_tile_test.cc")
+    if (CONFIG_ANS)
+      set(AOM_UNIT_TEST_COMMON_SOURCES
+          ${AOM_UNIT_TEST_COMMON_SOURCES}
+          "${AOM_ROOT}/test/ans_codec_test.cc"
+          "${AOM_ROOT}/test/ans_test.cc")
+    else ()
+      set(AOM_UNIT_TEST_COMMON_SOURCES
+          ${AOM_UNIT_TEST_COMMON_SOURCES}
+          "${AOM_ROOT}/test/boolcoder_test.cc")
+    endif ()
+
+    if (CONFIG_EXT_TILE)
+      set(AOM_UNIT_TEST_COMMON_SOURCES
+          ${AOM_UNIT_TEST_COMMON_SOURCES}
+          "${AOM_ROOT}/test/av1_ext_tile_test.cc")
+    endif ()
   endif ()
 endif ()
 
 if (CONFIG_HIGHBITDEPTH)
-  if (CONFIG_AV1_ENCODER)
+  if (CONFIG_AV1_ENCODER AND NOT BUILD_SHARED_LIBS)
     set(AOM_UNIT_TEST_COMMON_INTRIN_SSE4_1
         ${AOM_UNIT_TEST_COMMON_INTRIN_SSE4_1}
         "${AOM_ROOT}/test/av1_highbd_iht_test.cc"
         "${AOM_ROOT}/test/av1_quantize_test.cc")
   endif ()
 
   if (CONFIG_INTERNAL_STATS)
     set(AOM_UNIT_TEST_COMMON_SOURCES
         ${AOM_UNIT_TEST_COMMON_SOURCES}
         "${AOM_ROOT}/test/hbd_metrics_test.cc")
   endif ()
 endif ()
 
 if (CONFIG_UNIT_TESTS)
+  find_package(PythonInterp)
+  if (NOT PYTHONINTERP_FOUND)
+    message(WARNING "--- Unit tests disabled: Python not found.")
+    set(CONFIG_UNIT_TESTS 0)
+  endif ()
+
   if (MSVC)
     # Force static run time to avoid collisions with googletest.
     include("${AOM_ROOT}/build/cmake/msvc_runtime.cmake")
   endif ()
   include_directories(
     "${AOM_ROOT}/third_party/googletest/src/googletest/src"
     "${AOM_ROOT}/third_party/googletest/src/googletest/include")
+
+  if (BUILD_SHARED_LIBS AND APPLE)
+    # Silence an RPATH warning.
+    set(CMAKE_MACOSX_RPATH 1)
+  endif ()
   add_subdirectory("${AOM_ROOT}/third_party/googletest/src/googletest"
                    EXCLUDE_FROM_ALL)
 
   # Generate a stub file containing the C function usage_exit(); this is
   # required because of the test dependency on aom_common_app_util.
   # Specifically, the function die() in tools_common.c calls usage_exit() to
   # terminate the program on the caller's behalf.
   file(WRITE "${AOM_CONFIG_DIR}/usage_exit.c" "void usage_exit(void) {}")
 endif ()
 
 # Setup the targets for CONFIG_UNIT_TESTS. The libaom and app util targets must
 # exist before this function is called.
 function (setup_aom_test_targets)
   add_library(test_aom_common OBJECT ${AOM_UNIT_TEST_COMMON_SOURCES})
+  add_dependencies(test_aom_common aom)
 
   if (CONFIG_AV1_DECODER)
     add_library(test_aom_decoder OBJECT ${AOM_UNIT_TEST_DECODER_SOURCES})
+    add_dependencies(test_aom_decoder aom)
   endif ()
 
   if (CONFIG_AV1_ENCODER)
     add_library(test_aom_encoder OBJECT ${AOM_UNIT_TEST_ENCODER_SOURCES})
+    add_dependencies(test_aom_encoder aom)
   endif ()
 
-  set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} test_aom_common test_aom_decoder
-      test_aom_encoder PARENT_SCOPE)
-
   add_executable(test_libaom ${AOM_UNIT_TEST_WRAPPER_SOURCES}
                  $<TARGET_OBJECTS:aom_common_app_util>
                  $<TARGET_OBJECTS:test_aom_common>)
 
   if (CONFIG_AV1_DECODER)
-    target_sources(test_libaom PUBLIC
+    target_sources(test_libaom PRIVATE
                    $<TARGET_OBJECTS:aom_decoder_app_util>
                    $<TARGET_OBJECTS:test_aom_decoder>)
 
     if (CONFIG_DECODE_PERF_TESTS AND CONFIG_WEBM_IO)
-      target_sources(test_libaom PUBLIC ${AOM_DECODE_PERF_TEST_SOURCES})
+      target_sources(test_libaom PRIVATE ${AOM_DECODE_PERF_TEST_SOURCES})
     endif ()
   endif ()
 
   if (CONFIG_AV1_ENCODER)
-    target_sources(test_libaom PUBLIC
+    target_sources(test_libaom PRIVATE
                    $<TARGET_OBJECTS:test_aom_encoder>
                    $<TARGET_OBJECTS:aom_encoder_app_util>)
 
     if (CONFIG_ENCODE_PERF_TESTS)
-      target_sources(test_libaom PUBLIC ${AOM_ENCODE_PERF_TEST_SOURCES})
+      target_sources(test_libaom PRIVATE ${AOM_ENCODE_PERF_TEST_SOURCES})
     endif ()
 
-    add_executable(test_intra_pred_speed
-                   ${AOM_TEST_INTRA_PRED_SPEED_SOURCES}
-                   $<TARGET_OBJECTS:aom_common_app_util>)
-    target_link_libraries(test_intra_pred_speed ${AOM_LIB_LINK_TYPE} aom gtest)
+    if (NOT BUILD_SHARED_LIBS)
+      add_executable(test_intra_pred_speed
+                     ${AOM_TEST_INTRA_PRED_SPEED_SOURCES}
+                     $<TARGET_OBJECTS:aom_common_app_util>)
+      target_link_libraries(test_intra_pred_speed ${AOM_LIB_LINK_TYPE}
+                            aom gtest)
+    endif ()
   endif ()
 
   target_link_libraries(test_libaom ${AOM_LIB_LINK_TYPE} aom gtest)
 
   if (CONFIG_LIBYUV)
-    target_sources(test_libaom PUBLIC $<TARGET_OBJECTS:yuv>)
+    target_sources(test_libaom PRIVATE $<TARGET_OBJECTS:yuv>)
   endif ()
   if (CONFIG_WEBM_IO)
-    target_sources(test_libaom PUBLIC ${AOM_UNIT_TEST_WEBM_SOURCES}
-                   $<TARGET_OBJECTS:webm>)
+    target_sources(test_libaom PRIVATE $<TARGET_OBJECTS:webm>)
   endif ()
   if (HAVE_SSE2)
     add_intrinsics_source_to_target("-msse2" "test_libaom"
                                     "AOM_UNIT_TEST_COMMON_INTRIN_SSE2")
   endif ()
   if (HAVE_SSSE3)
     add_intrinsics_source_to_target("-mssse3" "test_libaom"
                                     "AOM_UNIT_TEST_COMMON_INTRIN_SSSE3")
@@ -326,21 +392,36 @@ function (setup_aom_test_targets)
                                     "AOM_UNIT_TEST_COMMON_INTRIN_SSE4_1")
     if (CONFIG_AV1_ENCODER)
       if (AOM_UNIT_TEST_ENCODER_INTRIN_SSE4_1)
         add_intrinsics_source_to_target("-msse4.1" "test_libaom"
                                         "AOM_UNIT_TEST_ENCODER_INTRIN_SSE4_1")
       endif ()
     endif ()
   endif ()
+  if (HAVE_AVX2)
+    add_intrinsics_source_to_target("-mavx2" "test_libaom"
+                                    "AOM_UNIT_TEST_COMMON_INTRIN_AVX2")
+  endif ()
   if (HAVE_NEON)
     add_intrinsics_source_to_target("${AOM_NEON_INTRIN_FLAG}" "test_libaom"
                                     "AOM_UNIT_TEST_COMMON_INTRIN_NEON")
   endif ()
 
+  if (NOT ENABLE_IDE_TEST_HOSTING)
+    if (MSVC OR XCODE)
+      # Skip creation of test data download and test run targets when generating
+      # for Visual Studio and Xcode unless the user explicitly requests IDE test
+      # hosting. This is done to make build cycles in the IDE tolerable when the
+      # IDE command for build project is used to build AOM. Default behavior in
+      # IDEs is to build all targets, and the test run takes hours.
+      return ()
+    endif ()
+  endif ()
+
   make_test_data_lists("${AOM_UNIT_TEST_DATA_LIST_FILE}"
                        test_files test_file_checksums)
   list(LENGTH test_files num_test_files)
   list(LENGTH test_file_checksums num_test_file_checksums)
 
   math(EXPR max_file_index "${num_test_files} - 1")
   foreach (test_index RANGE ${max_file_index})
     list(GET test_files ${test_index} test_file)
@@ -361,36 +442,25 @@ function (setup_aom_test_targets)
 
   # Pick a reasonable number of targets (this controls parallelization).
   ProcessorCount(num_test_targets)
   if (num_test_targets EQUAL 0)
     # Just default to 10 targets when there's no processor count available.
     set(num_test_targets 10)
   endif ()
 
-  # TODO(tomfinegan): This needs some work for MSVC and Xcode. Executable suffix
-  # and config based executable output paths are the obvious issues.
   math(EXPR max_shard_index "${num_test_targets} - 1")
   foreach (shard_index RANGE ${max_shard_index})
     set(test_name "test_${shard_index}")
     add_custom_target(${test_name}
                       COMMAND ${CMAKE_COMMAND}
                       -DGTEST_SHARD_INDEX=${shard_index}
                       -DGTEST_TOTAL_SHARDS=${num_test_targets}
                       -DTEST_LIBAOM=$<TARGET_FILE:test_libaom>
                       -P "${AOM_ROOT}/test/test_runner.cmake"
                       DEPENDS testdata test_libaom)
     set(test_targets ${test_targets} ${test_name})
   endforeach ()
   add_custom_target(runtests)
   add_dependencies(runtests ${test_targets})
-
-  if (MSVC)
-    set_target_properties(${testdata_targets} PROPERTIES
-                          EXCLUDE_FROM_DEFAULT_BUILD TRUE)
-    set_target_properties(${test_targets} PROPERTIES
-                          EXCLUDE_FROM_DEFAULT_BUILD TRUE)
-    set_target_properties(testdata runtests PROPERTIES
-                          EXCLUDE_FROM_DEFAULT_BUILD TRUE)
-  endif ()
 endfunction ()
 
 endif ()  # AOM_TEST_TEST_CMAKE_
--- a/third_party/aom/test/test.mk
+++ b/third_party/aom/test/test.mk
@@ -162,16 +162,17 @@ LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) +
 #LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += av1_quantize_test.cc
 LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += subtract_test.cc
 LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += arf_freq_test.cc
 ifneq ($(CONFIG_AOM_QM), yes)
 ifneq ($(CONFIG_NEW_QUANT), yes)
 LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += quantize_func_test.cc
 endif
 endif
+LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += block_error_test.cc
 
 LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += av1_inv_txfm_test.cc
 LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += av1_dct_test.cc
 LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += av1_fht4x4_test.cc
 LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += av1_fht8x8_test.cc
 LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += av1_fht16x16_test.cc
 LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += av1_fht32x32_test.cc
 ifeq ($(CONFIG_TX64X64),yes)
@@ -238,16 +239,21 @@ LIBAOM_TEST_SRCS-$(HAVE_SSE2) += warp_fi
 LIBAOM_TEST_SRCS-$(HAVE_SSE2) += warp_filter_test.cc warp_filter_test_util.cc
 endif
 ifeq ($(CONFIG_LOOP_RESTORATION),yes)
 LIBAOM_TEST_SRCS-$(HAVE_SSE2) += hiprec_convolve_test_util.h
 LIBAOM_TEST_SRCS-$(HAVE_SSE2) += hiprec_convolve_test.cc
 LIBAOM_TEST_SRCS-$(HAVE_SSE2) += hiprec_convolve_test_util.cc
 LIBAOM_TEST_SRCS-$(HAVE_SSE4_1) += selfguided_filter_test.cc
 endif
+ifeq ($(CONFIG_CONVOLVE_ROUND),yes)
+LIBAOM_TEST_SRCS-$(HAVE_SSE2) += av1_convolve_2d_test_util.h
+LIBAOM_TEST_SRCS-$(HAVE_SSE2) += av1_convolve_2d_test.cc
+LIBAOM_TEST_SRCS-$(HAVE_SSE2) += av1_convolve_2d_test_util.cc
+endif
 
 ifeq ($(CONFIG_GLOBAL_MOTION)$(CONFIG_AV1_ENCODER),yesyes)
 LIBAOM_TEST_SRCS-$(HAVE_SSE4_1) += corner_match_test.cc
 endif
 
 TEST_INTRA_PRED_SPEED_SRCS-yes := test_intra_pred_speed.cc
 TEST_INTRA_PRED_SPEED_SRCS-yes += ../md5_utils.h ../md5_utils.c
 
--- a/third_party/aom/test/tile_independence_test.cc
+++ b/third_party/aom/test/tile_independence_test.cc
@@ -17,27 +17,28 @@
 #include "test/encode_test_driver.h"
 #include "test/i420_video_source.h"
 #include "test/util.h"
 #include "test/md5_helper.h"
 #include "aom_mem/aom_mem.h"
 
 namespace {
 class TileIndependenceTest
-    : public ::libaom_test::EncoderTest,
-      public ::libaom_test::CodecTestWith2Params<int, int> {
+    : public ::libaom_test::CodecTestWith2Params<int, int>,
+      public ::libaom_test::EncoderTest {
  protected:
   TileIndependenceTest()
       : EncoderTest(GET_PARAM(0)), md5_fw_order_(), md5_inv_order_(),
         n_tile_cols_(GET_PARAM(1)), n_tile_rows_(GET_PARAM(2)) {
     init_flags_ = AOM_CODEC_USE_PSNR;
     aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t();
     cfg.w = 704;
     cfg.h = 144;
     cfg.threads = 1;
+    cfg.allow_lowbitdepth = 1;
     fw_dec_ = codec_->CreateDecoder(cfg, 0);
     inv_dec_ = codec_->CreateDecoder(cfg, 0);
     inv_dec_->Control(AV1_INVERT_TILE_DECODE_ORDER, 1);
 
 #if CONFIG_AV1 && CONFIG_EXT_TILE
     if (fw_dec_->IsAV1() && inv_dec_->IsAV1()) {
       fw_dec_->Control(AV1_SET_DECODE_TILE_ROW, -1);
       fw_dec_->Control(AV1_SET_DECODE_TILE_COL, -1);
--- a/third_party/aom/test/tools_common.sh
+++ b/third_party/aom/test/tools_common.sh
@@ -43,16 +43,31 @@ test_end() {
     return 1
   fi
   AOM_TOOL_TEST='<unset>'
 }
 
 # Echoes the target configuration being tested.
 test_configuration_target() {
   aom_config_mk="${LIBAOM_CONFIG_PATH}/config.mk"
+  # TODO(tomfinegan): Remove the parts requiring config.mk when the configure
+  # script is removed from the repository.
+  if [ ! -f "${aom_config_mk}" ]; then
+    aom_config_c="${LIBAOM_CONFIG_PATH}/aom_config.c"
+    # Clean up the cfg pointer line from aom_config.c for easier re-use by
+    # someone examining a failure in the example tests.
+    # 1. Run grep on aom_config.c for cfg and limit the results to 1.
+    # 2. Split the line using ' = ' as separator.
+    # 3. Abuse sed to consume the leading " and trailing "; from the assignment
+    #    to the cfg pointer.
+    cmake_config=$(awk -F ' = ' '/cfg/ { print $NF; exit }' "${aom_config_c}" \
+      | sed -e s/\"// -e s/\"\;//)
+    echo cmake generated via command: cmake path/to/aom ${cmake_config}
+    return
+  fi
   # Find the TOOLCHAIN line, split it using ':=' as the field separator, and
   # print the last field to get the value. Then pipe the value to tr to consume
   # any leading/trailing spaces while allowing tr to echo the output to stdout.
   awk -F ':=' '/TOOLCHAIN/ { print $NF }' "${aom_config_mk}" | tr -d ' '
 }
 
 # Trap function used for failure reports and tool output directory removal.
 # When the contents of $AOM_TOOL_TEST do not match the string '<unset>', reports
@@ -66,48 +81,61 @@ cleanup() {
   fi
 }
 
 # Echoes the git hash portion of the VERSION_STRING variable defined in
 # $LIBAOM_CONFIG_PATH/config.mk to stdout, or the version number string when
 # no git hash is contained in VERSION_STRING.
 config_hash() {
   aom_config_mk="${LIBAOM_CONFIG_PATH}/config.mk"
+  if [ ! -f "${aom_config_mk}" ]; then
+    aom_config_c="${LIBAOM_CONFIG_PATH}/aom_config.c"
+    # Clean up the aom_git_hash pointer line from aom_config.c.
+    # 1. Run grep on aom_config.c for aom_git_hash and limit results to 1.
+    # 2. Split the line using ' = "' as separator.
+    # 3. Abuse sed to consume the trailing "; from the assignment to the
+    #    aom_git_hash pointer.
+    awk -F ' = "' '/aom_git_hash/ { print $NF; exit }' "${aom_config_c}" \
+      | sed s/\"\;//
+    return
+  fi
+
   # Find VERSION_STRING line, split it with "-g" and print the last field to
   # output the git hash to stdout.
   aom_version=$(awk -F -g '/VERSION_STRING/ {print $NF}' "${aom_config_mk}")
   # Handle two situations here:
   # 1. The default case: $aom_version is a git hash, so echo it unchanged.
   # 2. When being run a non-dev tree, the -g portion is not present in the
   #    version string: It's only the version number.
   #    In this case $aom_version is something like 'VERSION_STRING=v1.3.0', so
   #    we echo only what is after the '='.
   echo "${aom_version##*=}"
 }
 
 # Echoes the short form of the current git hash.
 current_hash() {
   if git --version > /dev/null 2>&1; then
     (cd "$(dirname "${0}")"
-    git rev-parse --short HEAD)
+    git rev-parse HEAD)
   else
     # Return the config hash if git is unavailable: Fail silently, git hashes
     # are used only for warnings.
     config_hash
   fi
 }
 
 # Echoes warnings to stdout when git hash in aom_config.h does not match the
 # current git hash.
 check_git_hashes() {
   hash_at_configure_time=$(config_hash)
   hash_now=$(current_hash)
 
   if [ "${hash_at_configure_time}" != "${hash_now}" ]; then
     echo "Warning: git hash has changed since last configure."
+    vlog "  config hash: ${hash_at_configure_time} hash now: ${hash_now}"
   fi
 }
 
 # $1 is the name of an environment variable containing a directory name to
 # test.
 test_env_var_dir() {
   local dir=$(eval echo "\${$1}")
   if [ ! -d "${dir}" ]; then
--- a/third_party/aom/test/transform_test_base.h
+++ b/third_party/aom/test/transform_test_base.h
@@ -10,33 +10,34 @@
  */
 
 #ifndef TEST_TRANSFORM_TEST_BASE_H_
 #define TEST_TRANSFORM_TEST_BASE_H_
 
 #include "./aom_config.h"
 #include "aom_mem/aom_mem.h"
 #include "aom/aom_codec.h"
+#include "av1/common/idct.h"
 
 namespace libaom_test {
 
 //  Note:
 //   Same constant are defined in av1/common/av1_entropy.h and
 //   av1/common/entropy.h.  Goal is to make this base class
 //   to use for future codec transform testing.  But including
 //   either of them would lead to compiling error when we do
 //   unit test for another codec. Suggest to move the definition
 //   to a aom header file.
 const int kDctMaxValue = 16384;
 
 typedef void (*FhtFunc)(const int16_t *in, tran_low_t *out, int stride,
-                        int tx_type);
+                        FWD_TXFM_PARAM *fwd_txfm_param);
 
 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
-                        int tx_type);
+                        const INV_TXFM_PARAM *inv_txfm_param);
 
 class TransformTestBase {
  public:
   virtual ~TransformTestBase() {}
 
  protected:
   virtual void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) = 0;
 
@@ -152,17 +153,17 @@ class TransformTestBase {
           } else {
             output_block[out_idx] = output_ref_block[out_idx] =
                 rnd.Rand16() & mask_;
 #endif
           }
         }
       }
 
-      fwd_txfm_ref(input_block, output_ref_block, stride, tx_type_);
+      fwd_txfm_ref(input_block, output_ref_block, stride, &fwd_txfm_param_);
       ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_block, output_block, stride));
 
       // The minimum quant value is 4.
       for (j = 0; j < height_; ++j) {
         for (k = 0; k < pitch_; ++k) {
           int out_idx = j * pitch_ + k;
           ASSERT_EQ(output_block[out_idx], output_ref_block[out_idx])
               << "Error: not bit-exact result at index: " << out_idx
@@ -200,19 +201,19 @@ class TransformTestBase {
           int in_idx = j * pitch_ + k;
           int out_idx = j * stride + k;
           input_block[in_idx] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
           output_ref_block[out_idx] = rnd.Rand16() & mask_;
           output_block[out_idx] = output_ref_block[out_idx];
         }
       }
 
-      fwd_txfm_ref(input_block, trans_block, pitch_, tx_type_);
+      fwd_txfm_ref(input_block, trans_block, pitch_, &fwd_txfm_param_);
 
-      inv_txfm_ref(trans_block, output_ref_block, stride, tx_type_);
+      inv_txfm_ref(trans_block, output_ref_block, stride, &inv_txfm_param_);
       ASM_REGISTER_STATE_CHECK(RunInvTxfm(trans_block, output_block, stride));
 
       for (j = 0; j < height_; ++j) {
         for (k = 0; k < pitch_; ++k) {
           int out_idx = j * stride + k;
           ASSERT_EQ(output_block[out_idx], output_ref_block[out_idx])
               << "Error: not bit-exact result at index: " << out_idx
               << " j = " << j << " k = " << k << " at test block: " << i;
@@ -242,17 +243,18 @@ class TransformTestBase {
         input_extreme_block[j] = rnd.Rand8() % 2 ? mask_ : -mask_;
       }
       if (i == 0) {
         for (int j = 0; j < num_coeffs_; ++j) input_extreme_block[j] = mask_;
       } else if (i == 1) {
         for (int j = 0; j < num_coeffs_; ++j) input_extreme_block[j] = -mask_;
       }
 
-      fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_, tx_type_);
+      fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_,
+                   &fwd_txfm_param_);
       ASM_REGISTER_STATE_CHECK(
           RunFwdTxfm(input_extreme_block, output_block, pitch_));
 
       int row_length = FindRowLength();
       // The minimum quant value is 4.
       for (int j = 0; j < num_coeffs_; ++j) {
         EXPECT_EQ(output_block[j], output_ref_block[j])
             << "Not bit-exact at test index: " << i << ", "
@@ -298,17 +300,17 @@ class TransformTestBase {
         } else {
           src16[j] = rnd.Rand16() & mask_;
           dst16[j] = rnd.Rand16() & mask_;
           in[j] = src16[j] - dst16[j];
 #endif
         }
       }
 
-      fwd_txfm_ref(in, coeff, pitch_, tx_type_);
+      fwd_txfm_ref(in, coeff, pitch_, &fwd_txfm_param_);
 
       if (bit_depth_ == AOM_BITS_8) {
         ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, dst, pitch_));
 #if CONFIG_HIGHBITDEPTH
       } else {
         ASM_REGISTER_STATE_CHECK(
             RunInvTxfm(coeff, CONVERT_TO_BYTEPTR(dst16), pitch_));
 #endif
@@ -333,22 +335,23 @@ class TransformTestBase {
 #if CONFIG_HIGHBITDEPTH
     aom_free(src16);
     aom_free(dst16);
 #endif
   }
 
   int pitch_;
   int height_;
-  int tx_type_;
   FhtFunc fwd_txfm_ref;
   IhtFunc inv_txfm_ref;
   aom_bit_depth_t bit_depth_;
   int mask_;
   int num_coeffs_;
+  FWD_TXFM_PARAM fwd_txfm_param_;
+  INV_TXFM_PARAM inv_txfm_param_;
 
  private:
   //  Assume transform size is 4x4, 8x8, 16x16,...
   int FindRowLength() const {
     int row = 4;
     if (16 == num_coeffs_) {
       row = 4;
     } else if (64 == num_coeffs_) {
--- a/third_party/aom/test/user_priv_test.cc
+++ b/third_party/aom/test/user_priv_test.cc
@@ -44,16 +44,17 @@ void CheckUserPrivateData(void *user_pri
 // they match. Both the pointer values and the values inside the addresses
 // should match.
 string DecodeFile(const string &filename) {
   ACMRandom rnd(ACMRandom::DeterministicSeed());
   libaom_test::WebMVideoSource video(filename);
   video.Init();
 
   aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t();
+  cfg.allow_lowbitdepth = 1;
   libaom_test::AV1Decoder decoder(cfg, 0);
 
   libaom_test::MD5 md5;
   int frame_num = 0;
   for (video.Begin(); !::testing::Test::HasFailure() && video.cxdata();
        video.Next()) {
     void *user_priv = reinterpret_cast<void *>(&frame_num);
     const aom_codec_err_t res =
--- a/third_party/aom/test/util.h
+++ b/third_party/aom/test/util.h
@@ -12,16 +12,18 @@
 #ifndef TEST_UTIL_H_
 #define TEST_UTIL_H_
 
 #include <stdio.h>
 #include <math.h>
 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "aom/aom_image.h"
 
+#define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0]))
+
 // Macros
 #define GET_PARAM(k) std::tr1::get<k>(GetParam())
 
 inline double compute_psnr(const aom_image_t *img1, const aom_image_t *img2) {
   assert((img1->fmt == img2->fmt) && (img1->d_w == img2->d_w) &&
          (img1->d_h == img2->d_h));
 
   const unsigned int width_y = img1->d_w;
--- a/third_party/aom/test/variance_test.cc
+++ b/third_party/aom/test/variance_test.cc
@@ -526,61 +526,45 @@ void MainTestClass<FunctionType>::MaxTes
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 using ::std::tr1::get;
 using ::std::tr1::make_tuple;
 using ::std::tr1::tuple;
 
-template <typename SubpelVarianceFunctionType>
+template <typename FunctionType>
 class SubpelVarianceTest
-    : public ::testing::TestWithParam<
-          tuple<int, int, SubpelVarianceFunctionType, int> > {
+    : public ::testing::TestWithParam<TestParams<FunctionType> > {
  public:
   virtual void SetUp() {
-    const tuple<int, int, SubpelVarianceFunctionType, int> &params =
-        this->GetParam();
-    log2width_ = get<0>(params);
-    width_ = 1 << log2width_;
-    log2height_ = get<1>(params);
-    height_ = 1 << log2height_;
-    subpel_variance_ = get<2>(params);
-    if (get<3>(params)) {
-      bit_depth_ = (aom_bit_depth_t)get<3>(params);
-      use_high_bit_depth_ = true;
-    } else {
-      bit_depth_ = AOM_BITS_8;
-      use_high_bit_depth_ = false;
-    }
-    mask_ = (1 << bit_depth_) - 1;
+    params_ = this->GetParam();
 
     rnd_.Reset(ACMRandom::DeterministicSeed());
-    block_size_ = width_ * height_;
-    if (!use_high_bit_depth_) {
-      src_ = reinterpret_cast<uint8_t *>(aom_memalign(16, block_size_));
-      sec_ = reinterpret_cast<uint8_t *>(aom_memalign(16, block_size_));
-      ref_ = new uint8_t[block_size_ + width_ + height_ + 1];
+    if (!use_high_bit_depth()) {
+      src_ = reinterpret_cast<uint8_t *>(aom_memalign(16, block_size()));
+      sec_ = reinterpret_cast<uint8_t *>(aom_memalign(16, block_size()));
+      ref_ = new uint8_t[block_size() + width() + height() + 1];
 #if CONFIG_HIGHBITDEPTH
     } else {
       src_ = CONVERT_TO_BYTEPTR(reinterpret_cast<uint16_t *>(
-          aom_memalign(16, block_size_ * sizeof(uint16_t))));
+          aom_memalign(16, block_size() * sizeof(uint16_t))));
       sec_ = CONVERT_TO_BYTEPTR(reinterpret_cast<uint16_t *>(
-          aom_memalign(16, block_size_ * sizeof(uint16_t))));
+          aom_memalign(16, block_size() * sizeof(uint16_t))));
       ref_ = CONVERT_TO_BYTEPTR(aom_memalign(
-          16, (block_size_ + width_ + height_ + 1) * sizeof(uint16_t)));
+          16, (block_size() + width() + height() + 1) * sizeof(uint16_t)));
 #endif  // CONFIG_HIGHBITDEPTH
     }
     ASSERT_TRUE(src_ != NULL);
     ASSERT_TRUE(sec_ != NULL);
     ASSERT_TRUE(ref_ != NULL);
   }
 
   virtual void TearDown() {
-    if (!use_high_bit_depth_) {
+    if (!use_high_bit_depth()) {
       aom_free(src_);
       delete[] ref_;
       aom_free(sec_);
 #if CONFIG_HIGHBITDEPTH
     } else {
       aom_free(CONVERT_TO_SHORTPTR(src_));
       aom_free(CONVERT_TO_SHORTPTR(ref_));
       aom_free(CONVERT_TO_SHORTPTR(sec_));
@@ -592,124 +576,126 @@ class SubpelVarianceTest
  protected:
   void RefTest();
   void ExtremeRefTest();
 
   ACMRandom rnd_;
   uint8_t *src_;
   uint8_t *ref_;
   uint8_t *sec_;
-  bool use_high_bit_depth_;
-  aom_bit_depth_t bit_depth_;
-  int width_, log2width_;
-  int height_, log2height_;
-  int block_size_, mask_;
-  SubpelVarianceFunctionType subpel_variance_;
+  TestParams<FunctionType> params_;
+
+  // some relay helpers
+  bool use_high_bit_depth() const { return params_.use_high_bit_depth; }
+  int byte_shift() const { return params_.bit_depth - 8; }
+  int block_size() const { return params_.block_size; }
+  int width() const { return params_.width; }
+  int height() const { return params_.height; }
+  uint32_t mask() const { return params_.mask; }
 };
 
 template <typename SubpelVarianceFunctionType>
 void SubpelVarianceTest<SubpelVarianceFunctionType>::RefTest() {
   for (int x = 0; x < 8; ++x) {
     for (int y = 0; y < 8; ++y) {
-      if (!use_high_bit_depth_) {
-        for (int j = 0; j < block_size_; j++) {
+      if (!use_high_bit_depth()) {
+        for (int j = 0; j < block_size(); j++) {
           src_[j] = rnd_.Rand8();
         }
-        for (int j = 0; j < block_size_ + width_ + height_ + 1; j++) {
+        for (int j = 0; j < block_size() + width() + height() + 1; j++) {
           ref_[j] = rnd_.Rand8();
         }
 #if CONFIG_HIGHBITDEPTH
       } else {
-        for (int j = 0; j < block_size_; j++) {
-          CONVERT_TO_SHORTPTR(src_)[j] = rnd_.Rand16() & mask_;
+        for (int j = 0; j < block_size(); j++) {
+          CONVERT_TO_SHORTPTR(src_)[j] = rnd_.Rand16() & mask();
         }
-        for (int j = 0; j < block_size_ + width_ + height_ + 1; j++) {
-          CONVERT_TO_SHORTPTR(ref_)[j] = rnd_.Rand16() & mask_;
+        for (int j = 0; j < block_size() + width() + height() + 1; j++) {
+          CONVERT_TO_SHORTPTR(ref_)[j] = rnd_.Rand16() & mask();
         }
 #endif  // CONFIG_HIGHBITDEPTH
       }
       unsigned int sse1, sse2;
       unsigned int var1;
       ASM_REGISTER_STATE_CHECK(
-          var1 = subpel_variance_(ref_, width_ + 1, x, y, src_, width_, &sse1));
-      const unsigned int var2 =
-          subpel_variance_ref(ref_, src_, log2width_, log2height_, x, y, &sse2,
-                              use_high_bit_depth_, bit_depth_);
+          var1 = params_.func(ref_, width() + 1, x, y, src_, width(), &sse1));
+      const unsigned int var2 = subpel_variance_ref(
+          ref_, src_, params_.log2width, params_.log2height, x, y, &sse2,
+          use_high_bit_depth(), params_.bit_depth);
       EXPECT_EQ(sse1, sse2) << "at position " << x << ", " << y;
       EXPECT_EQ(var1, var2) << "at position " << x << ", " << y;
     }
   }
 }
 
 template <typename SubpelVarianceFunctionType>
 void SubpelVarianceTest<SubpelVarianceFunctionType>::ExtremeRefTest() {
   // Compare against reference.
   // Src: Set the first half of values to 0, the second half to the maximum.
   // Ref: Set the first half of values to the maximum, the second half to 0.
   for (int x = 0; x < 8; ++x) {
     for (int y = 0; y < 8; ++y) {
-      const int half = block_size_ / 2;
-      if (!use_high_bit_depth_) {
+      const int half = block_size() / 2;
+      if (!use_high_bit_depth()) {
         memset(src_, 0, half);
         memset(src_ + half, 255, half);
         memset(ref_, 255, half);
-        memset(ref_ + half, 0, half + width_ + height_ + 1);
+        memset(ref_ + half, 0, half + width() + height() + 1);
 #if CONFIG_HIGHBITDEPTH
       } else {
-        aom_memset16(CONVERT_TO_SHORTPTR(src_), mask_, half);
+        aom_memset16(CONVERT_TO_SHORTPTR(src_), mask(), half);
         aom_memset16(CONVERT_TO_SHORTPTR(src_) + half, 0, half);
         aom_memset16(CONVERT_TO_SHORTPTR(ref_), 0, half);
-        aom_memset16(CONVERT_TO_SHORTPTR(ref_) + half, mask_,
-                     half + width_ + height_ + 1);
+        aom_memset16(CONVERT_TO_SHORTPTR(ref_) + half, mask(),
+                     half + width() + height() + 1);
 #endif  // CONFIG_HIGHBITDEPTH
       }
       unsigned int sse1, sse2;
       unsigned int var1;
       ASM_REGISTER_STATE_CHECK(
-          var1 = subpel_variance_(ref_, width_ + 1, x, y, src_, width_, &sse1));
-      const unsigned int var2 =
-          subpel_variance_ref(ref_, src_, log2width_, log2height_, x, y, &sse2,
-                              use_high_bit_depth_, bit_depth_);
+          var1 = params_.func(ref_, width() + 1, x, y, src_, width(), &sse1));
+      const unsigned int var2 = subpel_variance_ref(
+          ref_, src_, params_.log2width, params_.log2height, x, y, &sse2,
+          use_high_bit_depth(), params_.bit_depth);
       EXPECT_EQ(sse1, sse2) << "for xoffset " << x << " and yoffset " << y;
       EXPECT_EQ(var1, var2) << "for xoffset " << x << " and yoffset " << y;
     }
   }
 }
 
 template <>
 void SubpelVarianceTest<SubpixAvgVarMxNFunc>::RefTest() {
   for (int x = 0; x < 8; ++x) {
     for (int y = 0; y < 8; ++y) {
-      if (!use_high_bit_depth_) {
-        for (int j = 0; j < block_size_; j++) {
+      if (!use_high_bit_depth()) {
+        for (int j = 0; j < block_size(); j++) {
           src_[j] = rnd_.Rand8();
           sec_[j] = rnd_.Rand8();
         }
-        for (int j = 0; j < block_size_ + width_ + height_ + 1; j++) {
+        for (int j = 0; j < block_size() + width() + height() + 1; j++) {
           ref_[j] = rnd_.Rand8();
         }
 #if CONFIG_HIGHBITDEPTH
       } else {
-        for (int j = 0; j < block_size_; j++) {
-          CONVERT_TO_SHORTPTR(src_)[j] = rnd_.Rand16() & mask_;
-          CONVERT_TO_SHORTPTR(sec_)[j] = rnd_.Rand16() & mask_;
+        for (int j = 0; j < block_size(); j++) {
+          CONVERT_TO_SHORTPTR(src_)[j] = rnd_.Rand16() & mask();
+          CONVERT_TO_SHORTPTR(sec_)[j] = rnd_.Rand16() & mask();
         }
-        for (int j = 0; j < block_size_ + width_ + height_ + 1; j++) {
-          CONVERT_TO_SHORTPTR(ref_)[j] = rnd_.Rand16() & mask_;
+        for (int j = 0; j < block_size() + width() + height() + 1; j++) {
+          CONVERT_TO_SHORTPTR(ref_)[j] = rnd_.Rand16() & mask();
         }
 #endif  // CONFIG_HIGHBITDEPTH
       }
       uint32_t sse1, sse2;
       uint32_t var1, var2;
-      ASM_REGISTER_STATE_CHECK(var1 =
-                                   subpel_variance_(ref_, width_ + 1, x, y,
-                                                    src_, width_, &sse1, sec_));
-      var2 = subpel_avg_variance_ref(ref_, src_, sec_, log2width_, log2height_,
-                                     x, y, &sse2, use_high_bit_depth_,
-                                     static_cast<aom_bit_depth_t>(bit_depth_));
+      ASM_REGISTER_STATE_CHECK(var1 = params_.func(ref_, width() + 1, x, y,
+                                                   src_, width(), &sse1, sec_));
+      var2 = subpel_avg_variance_ref(ref_, src_, sec_, params_.log2width,
+                                     params_.log2height, x, y, &sse2,
+                                     use_high_bit_depth(), params_.bit_depth);
       EXPECT_EQ(sse1, sse2) << "at position " << x << ", " << y;
       EXPECT_EQ(var1, var2) << "at position " << x << ", " << y;
     }
   }
 }
 
 typedef MainTestClass<Get4x4SseFunc> AvxSseTest;
 typedef MainTestClass<VarianceMxNFunc> AvxMseTest;
@@ -758,47 +744,51 @@ INSTANTIATE_TEST_CASE_P(
                       VarianceParams(4, 4, &aom_variance16x16_c),
                       VarianceParams(4, 3, &aom_variance16x8_c),
                       VarianceParams(3, 4, &aom_variance8x16_c),
                       VarianceParams(3, 3, &aom_variance8x8_c),
                       VarianceParams(3, 2, &aom_variance8x4_c),
                       VarianceParams(2, 3, &aom_variance4x8_c),
                       VarianceParams(2, 2, &aom_variance4x4_c)));
 
+typedef TestParams<SubpixVarMxNFunc> SubpelVarianceParams;
 INSTANTIATE_TEST_CASE_P(
     C, AvxSubpelVarianceTest,
-    ::testing::Values(make_tuple(6, 6, &aom_sub_pixel_variance64x64_c, 0),
-                      make_tuple(6, 5, &aom_sub_pixel_variance64x32_c, 0),
-                      make_tuple(5, 6, &aom_sub_pixel_variance32x64_c, 0),
-                      make_tuple(5, 5, &aom_sub_pixel_variance32x32_c, 0),
-                      make_tuple(5, 4, &aom_sub_pixel_variance32x16_c, 0),
-                      make_tuple(4, 5, &aom_sub_pixel_variance16x32_c, 0),
-                      make_tuple(4, 4, &aom_sub_pixel_variance16x16_c, 0),
-                      make_tuple(4, 3, &aom_sub_pixel_variance16x8_c, 0),
-                      make_tuple(3, 4, &aom_sub_pixel_variance8x16_c, 0),
-                      make_tuple(3, 3, &aom_sub_pixel_variance8x8_c, 0),
-                      make_tuple(3, 2, &aom_sub_pixel_variance8x4_c, 0),
-                      make_tuple(2, 3, &aom_sub_pixel_variance4x8_c, 0),
-                      make_tuple(2, 2, &aom_sub_pixel_variance4x4_c, 0)));
+    ::testing::Values(
+        SubpelVarianceParams(6, 6, &aom_sub_pixel_variance64x64_c, 0),
+        SubpelVarianceParams(6, 5, &aom_sub_pixel_variance64x32_c, 0),
+        SubpelVarianceParams(5, 6, &aom_sub_pixel_variance32x64_c, 0),
+        SubpelVarianceParams(5, 5, &aom_sub_pixel_variance32x32_c, 0),
+        SubpelVarianceParams(5, 4, &aom_sub_pixel_variance32x16_c, 0),
+        SubpelVarianceParams(4, 5, &aom_sub_pixel_variance16x32_c, 0),
+        SubpelVarianceParams(4, 4, &aom_sub_pixel_variance16x16_c, 0),
+        SubpelVarianceParams(4, 3, &aom_sub_pixel_variance16x8_c, 0),
+        SubpelVarianceParams(3, 4, &aom_sub_pixel_variance8x16_c, 0),
+        SubpelVarianceParams(3, 3, &aom_sub_pixel_variance8x8_c, 0),
+        SubpelVarianceParams(3, 2, &aom_sub_pixel_variance8x4_c, 0),
+        SubpelVarianceParams(2, 3, &aom_sub_pixel_variance4x8_c, 0),
+        SubpelVarianceParams(2, 2, &aom_sub_pixel_variance4x4_c, 0)));
 
+typedef TestParams<SubpixAvgVarMxNFunc> SubpelAvgVarianceParams;
 INSTANTIATE_TEST_CASE_P(
     C, AvxSubpelAvgVarianceTest,
-    ::testing::Values(make_tuple(6, 6, &aom_sub_pixel_avg_variance64x64_c, 0),
-                      make_tuple(6, 5, &aom_sub_pixel_avg_variance64x32_c, 0),
-                      make_tuple(5, 6, &aom_sub_pixel_avg_variance32x64_c, 0),
-                      make_tuple(5, 5, &aom_sub_pixel_avg_variance32x32_c, 0),
-                      make_tuple(5, 4, &aom_sub_pixel_avg_variance32x16_c, 0),
-                      make_tuple(4, 5, &aom_sub_pixel_avg_variance16x32_c, 0),
-                      make_tuple(4, 4, &aom_sub_pixel_avg_variance16x16_c, 0),
-                      make_tuple(4, 3, &aom_sub_pixel_avg_variance16x8_c, 0),
-                      make_tuple(3, 4, &aom_sub_pixel_avg_variance8x16_c, 0),
-                      make_tuple(3, 3, &aom_sub_pixel_avg_variance8x8_c, 0),
-                      make_tuple(3, 2, &aom_sub_pixel_avg_variance8x4_c, 0),
-                      make_tuple(2, 3, &aom_sub_pixel_avg_variance4x8_c, 0),
-                      make_tuple(2, 2, &aom_sub_pixel_avg_variance4x4_c, 0)));
+    ::testing::Values(
+        SubpelAvgVarianceParams(6, 6, &aom_sub_pixel_avg_variance64x64_c, 0),
+        SubpelAvgVarianceParams(6, 5, &aom_sub_pixel_avg_variance64x32_c, 0),
+        SubpelAvgVarianceParams(5, 6, &aom_sub_pixel_avg_variance32x64_c, 0),
+        SubpelAvgVarianceParams(5, 5, &aom_sub_pixel_avg_variance32x32_c, 0),
+        SubpelAvgVarianceParams(5, 4, &aom_sub_pixel_avg_variance32x16_c, 0),
+        SubpelAvgVarianceParams(4, 5, &aom_sub_pixel_avg_variance16x32_c, 0),
+        SubpelAvgVarianceParams(4, 4, &aom_sub_pixel_avg_variance16x16_c, 0),
+        SubpelAvgVarianceParams(4, 3, &aom_sub_pixel_avg_variance16x8_c, 0),
+        SubpelAvgVarianceParams(3, 4, &aom_sub_pixel_avg_variance8x16_c, 0),
+        SubpelAvgVarianceParams(3, 3, &aom_sub_pixel_avg_variance8x8_c, 0),
+        SubpelAvgVarianceParams(3, 2, &aom_sub_pixel_avg_variance8x4_c, 0),
+        SubpelAvgVarianceParams(2, 3, &aom_sub_pixel_avg_variance4x8_c, 0),
+        SubpelAvgVarianceParams(2, 2, &aom_sub_pixel_avg_variance4x4_c, 0)));
 
 #if CONFIG_HIGHBITDEPTH
 typedef MainTestClass<VarianceMxNFunc> AvxHBDMseTest;
 typedef MainTestClass<VarianceMxNFunc> AvxHBDVarianceTest;
 typedef SubpelVarianceTest<SubpixVarMxNFunc> AvxHBDSubpelVarianceTest;
 typedef SubpelVarianceTest<SubpixAvgVarMxNFunc> AvxHBDSubpelAvgVarianceTest;
 
 TEST_P(AvxHBDMseTest, RefMse) { RefTestMse(); }
@@ -891,130 +881,157 @@ INSTANTIATE_TEST_CASE_P(C, AvxHBDVarianc
 INSTANTIATE_TEST_CASE_P(
     SSE4_1, AvxHBDVarianceTest,
     ::testing::Values(
         VarianceParams(2, 2, &aom_highbd_8_variance4x4_sse4_1, 8),
         VarianceParams(2, 2, &aom_highbd_10_variance4x4_sse4_1, 10),
         VarianceParams(2, 2, &aom_highbd_12_variance4x4_sse4_1, 12)));
 #endif  // HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH
 
-const AvxHBDSubpelVarianceTest::ParamType kArrayHBDSubpelVariance_c[] = {
+const SubpelVarianceParams kArrayHBDSubpelVariance_c[] = {
 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
-  make_tuple(7, 7, &aom_highbd_8_sub_pixel_variance128x128_c, 8),
-  make_tuple(7, 6, &aom_highbd_8_sub_pixel_variance128x64_c, 8),
-  make_tuple(6, 7, &aom_highbd_8_sub_pixel_variance64x128_c, 8),
+  SubpelVarianceParams(7, 7, &aom_highbd_8_sub_pixel_variance128x128_c, 8),
+  SubpelVarianceParams(7, 6, &aom_highbd_8_sub_pixel_variance128x64_c, 8),
+  SubpelVarianceParams(6, 7, &aom_highbd_8_sub_pixel_variance64x128_c, 8),
 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
-  make_tuple(6, 6, &aom_highbd_8_sub_pixel_variance64x64_c, 8),
-  make_tuple(6, 5, &aom_highbd_8_sub_pixel_variance64x32_c, 8),
-  make_tuple(5, 6, &aom_highbd_8_sub_pixel_variance32x64_c, 8),
-  make_tuple(5, 5, &aom_highbd_8_sub_pixel_variance32x32_c, 8),
-  make_tuple(5, 4, &aom_highbd_8_sub_pixel_variance32x16_c, 8),
-  make_tuple(4, 5, &aom_highbd_8_sub_pixel_variance16x32_c, 8),
-  make_tuple(4, 4, &aom_highbd_8_sub_pixel_variance16x16_c, 8),
-  make_tuple(4, 3, &aom_highbd_8_sub_pixel_variance16x8_c, 8),
-  make_tuple(3, 4, &aom_highbd_8_sub_pixel_variance8x16_c, 8),
-  make_tuple(3, 3, &aom_highbd_8_sub_pixel_variance8x8_c, 8),
-  make_tuple(3, 2, &aom_highbd_8_sub_pixel_variance8x4_c, 8),
-  make_tuple(2, 3, &aom_highbd_8_sub_pixel_variance4x8_c, 8),
-  make_tuple(2, 2, &aom_highbd_8_sub_pixel_variance4x4_c, 8),
+  SubpelVarianceParams(6, 6, &aom_highbd_8_sub_pixel_variance64x64_c, 8),
+  SubpelVarianceParams(6, 5, &aom_highbd_8_sub_pixel_variance64x32_c, 8),
+  SubpelVarianceParams(5, 6, &aom_highbd_8_sub_pixel_variance32x64_c, 8),
+  SubpelVarianceParams(5, 5, &aom_highbd_8_sub_pixel_variance32x32_c, 8),
+  SubpelVarianceParams(5, 4, &aom_highbd_8_sub_pixel_variance32x16_c, 8),
+  SubpelVarianceParams(4, 5, &aom_highbd_8_sub_pixel_variance16x32_c, 8),
+  SubpelVarianceParams(4, 4, &aom_highbd_8_sub_pixel_variance16x16_c, 8),
+  SubpelVarianceParams(4, 3, &aom_highbd_8_sub_pixel_variance16x8_c, 8),
+  SubpelVarianceParams(3, 4, &aom_highbd_8_sub_pixel_variance8x16_c, 8),
+  SubpelVarianceParams(3, 3, &aom_highbd_8_sub_pixel_variance8x8_c, 8),
+  SubpelVarianceParams(3, 2, &aom_highbd_8_sub_pixel_variance8x4_c, 8),
+  SubpelVarianceParams(2, 3, &aom_highbd_8_sub_pixel_variance4x8_c, 8),
+  SubpelVarianceParams(2, 2, &aom_highbd_8_sub_pixel_variance4x4_c, 8),
 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
-  make_tuple(7, 7, &aom_highbd_10_sub_pixel_variance128x128_c, 10),
-  make_tuple(7, 6, &aom_highbd_10_sub_pixel_variance128x64_c, 10),
-  make_tuple(6, 7, &aom_highbd_10_sub_pixel_variance64x128_c, 10),
+  SubpelVarianceParams(7, 7, &aom_highbd_10_sub_pixel_variance128x128_c, 10),
+  SubpelVarianceParams(7, 6, &aom_highbd_10_sub_pixel_variance128x64_c, 10),
+  SubpelVarianceParams(6, 7, &aom_highbd_10_sub_pixel_variance64x128_c, 10),
 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
-  make_tuple(6, 6, &aom_highbd_10_sub_pixel_variance64x64_c, 10),
-  make_tuple(6, 5, &aom_highbd_10_sub_pixel_variance64x32_c, 10),
-  make_tuple(5, 6, &aom_highbd_10_sub_pixel_variance32x64_c, 10),
-  make_tuple(5, 5, &aom_highbd_10_sub_pixel_variance32x32_c, 10),
-  make_tuple(5, 4, &aom_highbd_10_sub_pixel_variance32x16_c, 10),
-  make_tuple(4, 5, &aom_highbd_10_sub_pixel_variance16x32_c, 10),
-  make_tuple(4, 4, &aom_highbd_10_sub_pixel_variance16x16_c, 10),
-  make_tuple(4, 3, &aom_highbd_10_sub_pixel_variance16x8_c, 10),
-  make_tuple(3, 4, &aom_highbd_10_sub_pixel_variance8x16_c, 10),
-  make_tuple(3, 3, &aom_highbd_10_sub_pixel_variance8x8_c, 10),
-  make_tuple(3, 2, &aom_highbd_10_sub_pixel_variance8x4_c, 10),
-  make_tuple(2, 3, &aom_highbd_10_sub_pixel_variance4x8_c, 10),
-  make_tuple(2, 2, &aom_highbd_10_sub_pixel_variance4x4_c, 10),
+  SubpelVarianceParams(6, 6, &aom_highbd_10_sub_pixel_variance64x64_c, 10),
+  SubpelVarianceParams(6, 5, &aom_highbd_10_sub_pixel_variance64x32_c, 10),
+  SubpelVarianceParams(5, 6, &aom_highbd_10_sub_pixel_variance32x64_c, 10),
+  SubpelVarianceParams(5, 5, &aom_highbd_10_sub_pixel_variance32x32_c, 10),
+  SubpelVarianceParams(5, 4, &aom_highbd_10_sub_pixel_variance32x16_c, 10),
+  SubpelVarianceParams(4, 5, &aom_highbd_10_sub_pixel_variance16x32_c, 10),
+  SubpelVarianceParams(4, 4, &aom_highbd_10_sub_pixel_variance16x16_c, 10),
+  SubpelVarianceParams(4, 3, &aom_highbd_10_sub_pixel_variance16x8_c, 10),
+  SubpelVarianceParams(3, 4, &aom_highbd_10_sub_pixel_variance8x16_c, 10),
+  SubpelVarianceParams(3, 3, &aom_highbd_10_sub_pixel_variance8x8_c, 10),
+  SubpelVarianceParams(3, 2, &aom_highbd_10_sub_pixel_variance8x4_c, 10),
+  SubpelVarianceParams(2, 3, &aom_highbd_10_sub_pixel_variance4x8_c, 10),
+  SubpelVarianceParams(2, 2, &aom_highbd_10_sub_pixel_variance4x4_c, 10),
 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
-  make_tuple(7, 7, &aom_highbd_12_sub_pixel_variance128x128_c, 12),
-  make_tuple(7, 6, &aom_highbd_12_sub_pixel_variance128x64_c, 12),
-  make_tuple(6, 7, &aom_highbd_12_sub_pixel_variance64x128_c, 12),
+  SubpelVarianceParams(7, 7, &aom_highbd_12_sub_pixel_variance128x128_c, 12),
+  SubpelVarianceParams(7, 6, &aom_highbd_12_sub_pixel_variance128x64_c, 12),
+  SubpelVarianceParams(6, 7, &aom_highbd_12_sub_pixel_variance64x128_c, 12),
 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
-  make_tuple(6, 6, &aom_highbd_12_sub_pixel_variance64x64_c, 12),
-  make_tuple(6, 5, &aom_highbd_12_sub_pixel_variance64x32_c, 12),
-  make_tuple(5, 6, &aom_highbd_12_sub_pixel_variance32x64_c, 12),
-  make_tuple(5, 5, &aom_highbd_12_sub_pixel_variance32x32_c, 12),
-  make_tuple(5, 4, &aom_highbd_12_sub_pixel_variance32x16_c, 12),
-  make_tuple(4, 5, &aom_highbd_12_sub_pixel_variance16x32_c, 12),
-  make_tuple(4, 4, &aom_highbd_12_sub_pixel_variance16x16_c, 12),
-  make_tuple(4, 3, &aom_highbd_12_sub_pixel_variance16x8_c, 12),
-  make_tuple(3, 4, &aom_highbd_12_sub_pixel_variance8x16_c, 12),
-  make_tuple(3, 3, &aom_highbd_12_sub_pixel_variance8x8_c, 12),
-  make_tuple(3, 2, &aom_highbd_12_sub_pixel_variance8x4_c, 12),
-  make_tuple(2, 3, &aom_highbd_12_sub_pixel_variance4x8_c, 12),
-  make_tuple(2, 2, &aom_highbd_12_sub_pixel_variance4x4_c, 12),
+  SubpelVarianceParams(6, 6, &aom_highbd_12_sub_pixel_variance64x64_c, 12),
+  SubpelVarianceParams(6, 5, &aom_highbd_12_sub_pixel_variance64x32_c, 12),
+  SubpelVarianceParams(5, 6, &aom_highbd_12_sub_pixel_variance32x64_c, 12),
+  SubpelVarianceParams(5, 5, &aom_highbd_12_sub_pixel_variance32x32_c, 12),
+  SubpelVarianceParams(5, 4, &aom_highbd_12_sub_pixel_variance32x16_c, 12),
+  SubpelVarianceParams(4, 5, &aom_highbd_12_sub_pixel_variance16x32_c, 12),
+  SubpelVarianceParams(4, 4, &aom_highbd_12_sub_pixel_variance16x16_c, 12),
+  SubpelVarianceParams(4, 3, &aom_highbd_12_sub_pixel_variance16x8_c, 12),
+  SubpelVarianceParams(3, 4, &aom_highbd_12_sub_pixel_variance8x16_c, 12),
+  SubpelVarianceParams(3, 3, &aom_highbd_12_sub_pixel_variance8x8_c, 12),
+  SubpelVarianceParams(3, 2, &aom_highbd_12_sub_pixel_variance8x4_c, 12),
+  SubpelVarianceParams(2, 3, &aom_highbd_12_sub_pixel_variance4x8_c, 12),
+  SubpelVarianceParams(2, 2, &aom_highbd_12_sub_pixel_variance4x4_c, 12),
 };
 INSTANTIATE_TEST_CASE_P(C, AvxHBDSubpelVarianceTest,
                         ::testing::ValuesIn(kArrayHBDSubpelVariance_c));
 
-const AvxHBDSubpelAvgVarianceTest::ParamType kArrayHBDSubpelAvgVariance_c[] = {
+const SubpelAvgVarianceParams kArrayHBDSubpelAvgVariance_c[] = {
 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
-  make_tuple(7, 7, &aom_highbd_8_sub_pixel_avg_variance128x128_c, 8),
-  make_tuple(7, 6, &aom_highbd_8_sub_pixel_avg_variance128x64_c, 8),
-  make_tuple(6, 7, &aom_highbd_8_sub_pixel_avg_variance64x128_c, 8),
+  SubpelAvgVarianceParams(7, 7, &aom_highbd_8_sub_pixel_avg_variance128x128_c,
+                          8),
+  SubpelAvgVarianceParams(7, 6, &aom_highbd_8_sub_pixel_avg_variance128x64_c,
+                          8),
+  SubpelAvgVarianceParams(6, 7, &aom_highbd_8_sub_pixel_avg_variance64x128_c,
+                          8),
 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
-  make_tuple(6, 6, &aom_highbd_8_sub_pixel_avg_variance64x64_c, 8),
-  make_tuple(6, 5, &aom_highbd_8_sub_pixel_avg_variance64x32_c, 8),
-  make_tuple(5, 6, &aom_highbd_8_sub_pixel_avg_variance32x64_c, 8),
-  make_tuple(5, 5, &aom_highbd_8_sub_pixel_avg_variance32x32_c, 8),
-  make_tuple(5, 4, &aom_highbd_8_sub_pixel_avg_variance32x16_c, 8),
-  make_tuple(4, 5, &aom_highbd_8_sub_pixel_avg_variance16x32_c, 8),
-  make_tuple(4, 4, &aom_highbd_8_sub_pixel_avg_variance16x16_c, 8),
-  make_tuple(4, 3, &aom_highbd_8_sub_pixel_avg_variance16x8_c, 8),
-  make_tuple(3, 4, &aom_highbd_8_sub_pixel_avg_variance8x16_c, 8),
-  make_tuple(3, 3, &aom_highbd_8_sub_pixel_avg_variance8x8_c, 8),
-  make_tuple(3, 2, &aom_highbd_8_sub_pixel_avg_variance8x4_c, 8),
-  make_tuple(2, 3, &aom_highbd_8_sub_pixel_avg_variance4x8_c, 8),
-  make_tuple(2, 2, &aom_highbd_8_sub_pixel_avg_variance4x4_c, 8),
+  SubpelAvgVarianceParams(6, 6, &aom_highbd_8_sub_pixel_avg_variance64x64_c, 8),
+  SubpelAvgVarianceParams(6, 5, &aom_highbd_8_sub_pixel_avg_variance64x32_c, 8),
+  SubpelAvgVarianceParams(5, 6, &aom_highbd_8_sub_pixel_avg_variance32x64_c, 8),
+  SubpelAvgVarianceParams(5, 5, &aom_highbd_8_sub_pixel_avg_variance32x32_c, 8),
+  SubpelAvgVarianceParams(5, 4, &aom_highbd_8_sub_pixel_avg_variance32x16_c, 8),
+  SubpelAvgVarianceParams(4, 5, &aom_highbd_8_sub_pixel_avg_variance16x32_c, 8),
+  SubpelAvgVarianceParams(4, 4, &aom_highbd_8_sub_pixel_avg_variance16x16_c, 8),
+  SubpelAvgVarianceParams(4, 3, &aom_highbd_8_sub_pixel_avg_variance16x8_c, 8),
+  SubpelAvgVarianceParams(3, 4, &aom_highbd_8_sub_pixel_avg_variance8x16_c, 8),
+  SubpelAvgVarianceParams(3, 3, &aom_highbd_8_sub_pixel_avg_variance8x8_c, 8),
+  SubpelAvgVarianceParams(3, 2, &aom_highbd_8_sub_pixel_avg_variance8x4_c, 8),
+  SubpelAvgVarianceParams(2, 3, &aom_highbd_8_sub_pixel_avg_variance4x8_c, 8),
+  SubpelAvgVarianceParams(2, 2, &aom_highbd_8_sub_pixel_avg_variance4x4_c, 8),
 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
-  make_tuple(7, 7, &aom_highbd_10_sub_pixel_avg_variance128x128_c, 10),
-  make_tuple(7, 6, &aom_highbd_10_sub_pixel_avg_variance128x64_c, 10),
-  make_tuple(6, 7, &aom_highbd_10_sub_pixel_avg_variance64x128_c, 10),
+  SubpelAvgVarianceParams(7, 7, &aom_highbd_10_sub_pixel_avg_variance128x128_c,
+                          10),
+  SubpelAvgVarianceParams(7, 6, &aom_highbd_10_sub_pixel_avg_variance128x64_c,
+                          10),
+  SubpelAvgVarianceParams(6, 7, &aom_highbd_10_sub_pixel_avg_variance64x128_c,
+                          10),
 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
-  make_tuple(6, 6, &aom_highbd_10_sub_pixel_avg_variance64x64_c, 10),
-  make_tuple(6, 5, &aom_highbd_10_sub_pixel_avg_variance64x32_c, 10),
-  make_tuple(5, 6, &aom_highbd_10_sub_pixel_avg_variance32x64_c, 10),
-  make_tuple(5, 5, &aom_highbd_10_sub_pixel_avg_variance32x32_c, 10),
-  make_tuple(5, 4, &aom_highbd_10_sub_pixel_avg_variance32x16_c, 10),
-  make_tuple(4, 5, &aom_highbd_10_sub_pixel_avg_variance16x32_c, 10),
-  make_tuple(4, 4, &aom_highbd_10_sub_pixel_avg_variance16x16_c, 10),
-  make_tuple(4, 3, &aom_highbd_10_sub_pixel_avg_variance16x8_c, 10),
-  make_tuple(3, 4, &aom_highbd_10_sub_pixel_avg_variance8x16_c, 10),
-  make_tuple(3, 3, &aom_highbd_10_sub_pixel_avg_variance8x8_c, 10),
-  make_tuple(3, 2, &aom_highbd_10_sub_pixel_avg_variance8x4_c, 10),
-  make_tuple(2, 3, &aom_highbd_10_sub_pixel_avg_variance4x8_c, 10),
-  make_tuple(2, 2, &aom_highbd_10_sub_pixel_avg_variance4x4_c, 10),
+  SubpelAvgVarianceParams(6, 6, &aom_highbd_10_sub_pixel_avg_variance64x64_c,
+                          10),
+  SubpelAvgVarianceParams(6, 5, &aom_highbd_10_sub_pixel_avg_variance64x32_c,
+                          10),
+  SubpelAvgVarianceParams(5, 6, &aom_highbd_10_sub_pixel_avg_variance32x64_c,
+                          10),
+  SubpelAvgVarianceParams(5, 5, &aom_highbd_10_sub_pixel_avg_variance32x32_c,
+                          10),
+  SubpelAvgVarianceParams(5, 4, &aom_highbd_10_sub_pixel_avg_variance32x16_c,
+                          10),
+  SubpelAvgVarianceParams(4, 5, &aom_highbd_10_sub_pixel_avg_variance16x32_c,
+                          10),
+  SubpelAvgVarianceParams(4, 4, &aom_highbd_10_sub_pixel_avg_variance16x16_c,
+                          10),
+  SubpelAvgVarianceParams(4, 3, &aom_highbd_10_sub_pixel_avg_variance16x8_c,
+                          10),
+  SubpelAvgVarianceParams(3, 4, &aom_highbd_10_sub_pixel_avg_variance8x16_c,
+                          10),
+  SubpelAvgVarianceParams(3, 3, &aom_highbd_10_sub_pixel_avg_variance8x8_c, 10),
+  SubpelAvgVarianceParams(3, 2, &aom_highbd_10_sub_pixel_avg_variance8x4_c, 10),
+  SubpelAvgVarianceParams(2, 3, &aom_highbd_10_sub_pixel_avg_variance4x8_c, 10),
+  SubpelAvgVarianceParams(2, 2, &aom_highbd_10_sub_pixel_avg_variance4x4_c, 10),
 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
-  make_tuple(7, 7, &aom_highbd_12_sub_pixel_avg_variance128x128_c, 12),
-  make_tuple(7, 6, &aom_highbd_12_sub_pixel_avg_variance128x64_c, 12),
-  make_tuple(6, 7, &aom_highbd_12_sub_pixel_avg_variance64x128_c, 12),
+  SubpelAvgVarianceParams(7, 7, &aom_highbd_12_sub_pixel_avg_variance128x128_c,
+                          12),
+  SubpelAvgVarianceParams(7, 6, &aom_highbd_12_sub_pixel_avg_variance128x64_c,
+                          12),
+  SubpelAvgVarianceParams(6, 7, &aom_highbd_12_sub_pixel_avg_variance64x128_c,
+                          12),
 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
-  make_tuple(6, 6, &aom_highbd_12_sub_pixel_avg_variance64x64_c, 12),
-  make_tuple(6, 5, &aom_highbd_12_sub_pixel_avg_variance64x32_c, 12),
-  make_tuple(5, 6, &aom_highbd_12_sub_pixel_avg_variance32x64_c, 12),
-  make_tuple(5, 5, &aom_highbd_12_sub_pixel_avg_variance32x32_c, 12),
-  make_tuple(5, 4, &aom_highbd_12_sub_pixel_avg_variance32x16_c, 12),
-  make_tuple(4, 5, &aom_highbd_12_sub_pixel_avg_variance16x32_c, 12),
-  make_tuple(4, 4, &aom_highbd_12_sub_pixel_avg_variance16x16_c, 12),
-  make_tuple(4, 3, &aom_highbd_12_sub_pixel_avg_variance16x8_c, 12),
-  make_tuple(3, 4, &aom_highbd_12_sub_pixel_avg_variance8x16_c, 12),
-  make_tuple(3, 3, &aom_highbd_12_sub_pixel_avg_variance8x8_c, 12),
-  make_tuple(3, 2, &aom_highbd_12_sub_pixel_avg_variance8x4_c, 12),
-  make_tuple(2, 3, &aom_highbd_12_sub_pixel_avg_variance4x8_c, 12),
-  make_tuple(2, 2, &aom_highbd_12_sub_pixel_avg_variance4x4_c, 12)
+  SubpelAvgVarianceParams(6, 6, &aom_highbd_12_sub_pixel_avg_variance64x64_c,
+                          12),
+  SubpelAvgVarianceParams(6, 5, &aom_highbd_12_sub_pixel_avg_variance64x32_c,
+                          12),
+  SubpelAvgVarianceParams(5, 6, &aom_highbd_12_sub_pixel_avg_variance32x64_c,
+                          12),
+  SubpelAvgVarianceParams(5, 5, &aom_highbd_12_sub_pixel_avg_variance32x32_c,
+                          12),
+  SubpelAvgVarianceParams(5, 4, &aom_highbd_12_sub_pixel_avg_variance32x16_c,
+                          12),
+  SubpelAvgVarianceParams(4, 5, &aom_highbd_12_sub_pixel_avg_variance16x32_c,
+                          12),
+  SubpelAvgVarianceParams(4, 4, &aom_highbd_12_sub_pixel_avg_variance16x16_c,
+                          12),
+  SubpelAvgVarianceParams(4, 3, &aom_highbd_12_sub_pixel_avg_variance16x8_c,
+                          12),
+  SubpelAvgVarianceParams(3, 4, &aom_highbd_12_sub_pixel_avg_variance8x16_c,
+                          12),
+  SubpelAvgVarianceParams(3, 3, &aom_highbd_12_sub_pixel_avg_variance8x8_c, 12),
+  SubpelAvgVarianceParams(3, 2, &aom_highbd_12_sub_pixel_avg_variance8x4_c, 12),
+  SubpelAvgVarianceParams(2, 3, &aom_highbd_12_sub_pixel_avg_variance4x8_c, 12),
+  SubpelAvgVarianceParams(2, 2, &aom_highbd_12_sub_pixel_avg_variance4x4_c, 12)
 };
 INSTANTIATE_TEST_CASE_P(C, AvxHBDSubpelAvgVarianceTest,
                         ::testing::ValuesIn(kArrayHBDSubpelAvgVariance_c));
 #endif  // CONFIG_HIGHBITDEPTH
 
 #if HAVE_SSE2
 INSTANTIATE_TEST_CASE_P(SSE2, SumOfSquaresTest,
                         ::testing::Values(aom_get_mb_ss_sse2));
@@ -1038,61 +1055,71 @@ INSTANTIATE_TEST_CASE_P(
                       VarianceParams(3, 4, &aom_variance8x16_sse2),
                       VarianceParams(3, 3, &aom_variance8x8_sse2),
                       VarianceParams(3, 2, &aom_variance8x4_sse2),
                       VarianceParams(2, 3, &aom_variance4x8_sse2),
                       VarianceParams(2, 2, &aom_variance4x4_sse2)));
 
 INSTANTIATE_TEST_CASE_P(
     SSE2, AvxSubpelVarianceTest,
-    ::testing::Values(make_tuple(6, 6, &aom_sub_pixel_variance64x64_sse2, 0),
-                      make_tuple(6, 5, &aom_sub_pixel_variance64x32_sse2, 0),
-                      make_tuple(5, 6, &aom_sub_pixel_variance32x64_sse2, 0),
-                      make_tuple(5, 5, &aom_sub_pixel_variance32x32_sse2, 0),
-                      make_tuple(5, 4, &aom_sub_pixel_variance32x16_sse2, 0),
-                      make_tuple(4, 5, &aom_sub_pixel_variance16x32_sse2, 0),
-                      make_tuple(4, 4, &aom_sub_pixel_variance16x16_sse2, 0),
-                      make_tuple(4, 3, &aom_sub_pixel_variance16x8_sse2, 0),
-                      make_tuple(3, 4, &aom_sub_pixel_variance8x16_sse2, 0),
-                      make_tuple(3, 3, &aom_sub_pixel_variance8x8_sse2, 0),
-                      make_tuple(3, 2, &aom_sub_pixel_variance8x4_sse2, 0),
-                      make_tuple(2, 3, &aom_sub_pixel_variance4x8_sse2, 0),
-                      make_tuple(2, 2, &aom_sub_pixel_variance4x4_sse2, 0)));
+    ::testing::Values(
+        SubpelVarianceParams(6, 6, &aom_sub_pixel_variance64x64_sse2, 0),
+        SubpelVarianceParams(6, 5, &aom_sub_pixel_variance64x32_sse2, 0),
+        SubpelVarianceParams(5, 6, &aom_sub_pixel_variance32x64_sse2, 0),
+        SubpelVarianceParams(5, 5, &aom_sub_pixel_variance32x32_sse2, 0),
+        SubpelVarianceParams(5, 4, &aom_sub_pixel_variance32x16_sse2, 0),
+        SubpelVarianceParams(4, 5, &aom_sub_pixel_variance16x32_sse2, 0),
+        SubpelVarianceParams(4, 4, &aom_sub_pixel_variance16x16_sse2, 0),
+        SubpelVarianceParams(4, 3, &aom_sub_pixel_variance16x8_sse2, 0),
+        SubpelVarianceParams(3, 4, &aom_sub_pixel_variance8x16_sse2, 0),
+        SubpelVarianceParams(3, 3, &aom_sub_pixel_variance8x8_sse2, 0),
+        SubpelVarianceParams(3, 2, &aom_sub_pixel_variance8x4_sse2, 0),
+        SubpelVarianceParams(2, 3, &aom_sub_pixel_variance4x8_sse2, 0),
+        SubpelVarianceParams(2, 2, &aom_sub_pixel_variance4x4_sse2, 0)));
 
 INSTANTIATE_TEST_CASE_P(
     SSE2, AvxSubpelAvgVarianceTest,
     ::testing::Values(
-        make_tuple(6, 6, &aom_sub_pixel_avg_variance64x64_sse2, 0),
-        make_tuple(6, 5, &aom_sub_pixel_avg_variance64x32_sse2, 0),
-        make_tuple(5, 6, &aom_sub_pixel_avg_variance32x64_sse2, 0),
-        make_tuple(5, 5, &aom_sub_pixel_avg_variance32x32_sse2, 0),
-        make_tuple(5, 4, &aom_sub_pixel_avg_variance32x16_sse2, 0),
-        make_tuple(4, 5, &aom_sub_pixel_avg_variance16x32_sse2, 0),
-        make_tuple(4, 4, &aom_sub_pixel_avg_variance16x16_sse2, 0),
-        make_tuple(4, 3, &aom_sub_pixel_avg_variance16x8_sse2, 0),
-        make_tuple(3, 4, &aom_sub_pixel_avg_variance8x16_sse2, 0),
-        make_tuple(3, 3, &aom_sub_pixel_avg_variance8x8_sse2, 0),
-        make_tuple(3, 2, &aom_sub_pixel_avg_variance8x4_sse2, 0),
-        make_tuple(2, 3, &aom_sub_pixel_avg_variance4x8_sse2, 0),
-        make_tuple(2, 2, &aom_sub_pixel_avg_variance4x4_sse2, 0)));
+        SubpelAvgVarianceParams(6, 6, &aom_sub_pixel_avg_variance64x64_sse2, 0),
+        SubpelAvgVarianceParams(6, 5, &aom_sub_pixel_avg_variance64x32_sse2, 0),
+        SubpelAvgVarianceParams(5, 6, &aom_sub_pixel_avg_variance32x64_sse2, 0),
+        SubpelAvgVarianceParams(5, 5, &aom_sub_pixel_avg_variance32x32_sse2, 0),
+        SubpelAvgVarianceParams(5, 4, &aom_sub_pixel_avg_variance32x16_sse2, 0),
+        SubpelAvgVarianceParams(4, 5, &aom_sub_pixel_avg_variance16x32_sse2, 0),
+        SubpelAvgVarianceParams(4, 4, &aom_sub_pixel_avg_variance16x16_sse2, 0),
+        SubpelAvgVarianceParams(4, 3, &aom_sub_pixel_avg_variance16x8_sse2, 0),
+        SubpelAvgVarianceParams(3, 4, &aom_sub_pixel_avg_variance8x16_sse2, 0),
+        SubpelAvgVarianceParams(3, 3, &aom_sub_pixel_avg_variance8x8_sse2, 0),
+        SubpelAvgVarianceParams(3, 2, &aom_sub_pixel_avg_variance8x4_sse2, 0),
+        SubpelAvgVarianceParams(2, 3, &aom_sub_pixel_avg_variance4x8_sse2, 0),
+        SubpelAvgVarianceParams(2, 2, &aom_sub_pixel_avg_variance4x4_sse2, 0)));
 
 #if HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH
 INSTANTIATE_TEST_CASE_P(
     SSE4_1, AvxSubpelVarianceTest,
     ::testing::Values(
-        make_tuple(2, 2, &aom_highbd_8_sub_pixel_variance4x4_sse4_1, 8),
-        make_tuple(2, 2, &aom_highbd_10_sub_pixel_variance4x4_sse4_1, 10),
-        make_tuple(2, 2, &aom_highbd_12_sub_pixel_variance4x4_sse4_1, 12)));
+        SubpelVarianceParams(2, 2, &aom_highbd_8_sub_pixel_variance4x4_sse4_1,
+                             8),
+        SubpelVarianceParams(2, 2, &aom_highbd_10_sub_pixel_variance4x4_sse4_1,
+                             10),
+        SubpelVarianceParams(2, 2, &aom_highbd_12_sub_pixel_variance4x4_sse4_1,
+                             12)));
 
 INSTANTIATE_TEST_CASE_P(
     SSE4_1, AvxSubpelAvgVarianceTest,
     ::testing::Values(
-        make_tuple(2, 2, &aom_highbd_8_sub_pixel_avg_variance4x4_sse4_1, 8),
-        make_tuple(2, 2, &aom_highbd_10_sub_pixel_avg_variance4x4_sse4_1, 10),
-        make_tuple(2, 2, &aom_highbd_12_sub_pixel_avg_variance4x4_sse4_1, 12)));
+        SubpelAvgVarianceParams(2, 2,
+                                &aom_highbd_8_sub_pixel_avg_variance4x4_sse4_1,
+                                8),
+        SubpelAvgVarianceParams(2, 2,
+                                &aom_highbd_10_sub_pixel_avg_variance4x4_sse4_1,
+                                10),
+        SubpelAvgVarianceParams(2, 2,
+                                &aom_highbd_12_sub_pixel_avg_variance4x4_sse4_1,
+                                12)));
 #endif  // HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH
 
 #if CONFIG_HIGHBITDEPTH
 /* TODO(debargha): This test does not support the highbd version
 INSTANTIATE_TEST_CASE_P(
     SSE2, AvxHBDMseTest,
     ::testing::Values(MseParams(4, 4, &aom_highbd_12_mse16x16_sse2),
                       MseParams(4, 3, &aom_highbd_12_mse16x8_sse2),
@@ -1137,149 +1164,196 @@ INSTANTIATE_TEST_CASE_P(
         VarianceParams(5, 5, &aom_highbd_8_variance32x32_sse2, 8),
         VarianceParams(5, 4, &aom_highbd_8_variance32x16_sse2, 8),
         VarianceParams(4, 5, &aom_highbd_8_variance16x32_sse2, 8),
         VarianceParams(4, 4, &aom_highbd_8_variance16x16_sse2, 8),
         VarianceParams(4, 3, &aom_highbd_8_variance16x8_sse2, 8),
         VarianceParams(3, 4, &aom_highbd_8_variance8x16_sse2, 8),
         VarianceParams(3, 3, &aom_highbd_8_variance8x8_sse2, 8)));
 
-INSTANTIATE_TEST_CASE_P(
-    SSE2, AvxHBDSubpelVarianceTest,
-    ::testing::Values(
-        make_tuple(6, 6, &aom_highbd_12_sub_pixel_variance64x64_sse2, 12),
-        make_tuple(6, 5, &aom_highbd_12_sub_pixel_variance64x32_sse2, 12),
-        make_tuple(5, 6, &aom_highbd_12_sub_pixel_variance32x64_sse2, 12),
-        make_tuple(5, 5, &aom_highbd_12_sub_pixel_variance32x32_sse2, 12),
-        make_tuple(5, 4, &aom_highbd_12_sub_pixel_variance32x16_sse2, 12),
-        make_tuple(4, 5, &aom_highbd_12_sub_pixel_variance16x32_sse2, 12),
-        make_tuple(4, 4, &aom_highbd_12_sub_pixel_variance16x16_sse2, 12),
-        make_tuple(4, 3, &aom_highbd_12_sub_pixel_variance16x8_sse2, 12),
-        make_tuple(3, 4, &aom_highbd_12_sub_pixel_variance8x16_sse2, 12),
-        make_tuple(3, 3, &aom_highbd_12_sub_pixel_variance8x8_sse2, 12),
-        make_tuple(3, 2, &aom_highbd_12_sub_pixel_variance8x4_sse2, 12),
-        make_tuple(6, 6, &aom_highbd_10_sub_pixel_variance64x64_sse2, 10),
-        make_tuple(6, 5, &aom_highbd_10_sub_pixel_variance64x32_sse2, 10),
-        make_tuple(5, 6, &aom_highbd_10_sub_pixel_variance32x64_sse2, 10),
-        make_tuple(5, 5, &aom_highbd_10_sub_pixel_variance32x32_sse2, 10),
-        make_tuple(5, 4, &aom_highbd_10_sub_pixel_variance32x16_sse2, 10),
-        make_tuple(4, 5, &aom_highbd_10_sub_pixel_variance16x32_sse2, 10),
-        make_tuple(4, 4, &aom_highbd_10_sub_pixel_variance16x16_sse2, 10),
-        make_tuple(4, 3, &aom_highbd_10_sub_pixel_variance16x8_sse2, 10),
-        make_tuple(3, 4, &aom_highbd_10_sub_pixel_variance8x16_sse2, 10),
-        make_tuple(3, 3, &aom_highbd_10_sub_pixel_variance8x8_sse2, 10),
-        make_tuple(3, 2, &aom_highbd_10_sub_pixel_variance8x4_sse2, 10),
-        make_tuple(6, 6, &aom_highbd_8_sub_pixel_variance64x64_sse2, 8),
-        make_tuple(6, 5, &aom_highbd_8_sub_pixel_variance64x32_sse2, 8),
-        make_tuple(5, 6, &aom_highbd_8_sub_pixel_variance32x64_sse2, 8),
-        make_tuple(5, 5, &aom_highbd_8_sub_pixel_variance32x32_sse2, 8),
-        make_tuple(5, 4, &aom_highbd_8_sub_pixel_variance32x16_sse2, 8),
-        make_tuple(4, 5, &aom_highbd_8_sub_pixel_variance16x32_sse2, 8),
-        make_tuple(4, 4, &aom_highbd_8_sub_pixel_variance16x16_sse2, 8),
-        make_tuple(4, 3, &aom_highbd_8_sub_pixel_variance16x8_sse2, 8),
-        make_tuple(3, 4, &aom_highbd_8_sub_pixel_variance8x16_sse2, 8),
-        make_tuple(3, 3, &aom_highbd_8_sub_pixel_variance8x8_sse2, 8),
-        make_tuple(3, 2, &aom_highbd_8_sub_pixel_variance8x4_sse2, 8)));
+const SubpelVarianceParams kArrayHBDSubpelVariance_sse2[] = {
+  SubpelVarianceParams(6, 6, &aom_highbd_12_sub_pixel_variance64x64_sse2, 12),
+  SubpelVarianceParams(6, 5, &aom_highbd_12_sub_pixel_variance64x32_sse2, 12),
+  SubpelVarianceParams(5, 6, &aom_highbd_12_sub_pixel_variance32x64_sse2, 12),
+  SubpelVarianceParams(5, 5, &aom_highbd_12_sub_pixel_variance32x32_sse2, 12),
+  SubpelVarianceParams(5, 4, &aom_highbd_12_sub_pixel_variance32x16_sse2, 12),
+  SubpelVarianceParams(4, 5, &aom_highbd_12_sub_pixel_variance16x32_sse2, 12),
+  SubpelVarianceParams(4, 4, &aom_highbd_12_sub_pixel_variance16x16_sse2, 12),
+  SubpelVarianceParams(4, 3, &aom_highbd_12_sub_pixel_variance16x8_sse2, 12),
+  SubpelVarianceParams(3, 4, &aom_highbd_12_sub_pixel_variance8x16_sse2, 12),
+  SubpelVarianceParams(3, 3, &aom_highbd_12_sub_pixel_variance8x8_sse2, 12),
+  SubpelVarianceParams(3, 2, &aom_highbd_12_sub_pixel_variance8x4_sse2, 12),
+  SubpelVarianceParams(6, 6, &aom_highbd_10_sub_pixel_variance64x64_sse2, 10),
+  SubpelVarianceParams(6, 5, &aom_highbd_10_sub_pixel_variance64x32_sse2, 10),
+  SubpelVarianceParams(5, 6, &aom_highbd_10_sub_pixel_variance32x64_sse2, 10),
+  SubpelVarianceParams(5, 5, &aom_highbd_10_sub_pixel_variance32x32_sse2, 10),
+  SubpelVarianceParams(5, 4, &aom_highbd_10_sub_pixel_variance32x16_sse2, 10),
+  SubpelVarianceParams(4, 5, &aom_highbd_10_sub_pixel_variance16x32_sse2, 10),
+  SubpelVarianceParams(4, 4, &aom_highbd_10_sub_pixel_variance16x16_sse2, 10),
+  SubpelVarianceParams(4, 3, &aom_highbd_10_sub_pixel_variance16x8_sse2, 10),
+  SubpelVarianceParams(3, 4, &aom_highbd_10_sub_pixel_variance8x16_sse2, 10),
+  SubpelVarianceParams(3, 3, &aom_highbd_10_sub_pixel_variance8x8_sse2, 10),
+  SubpelVarianceParams(3, 2, &aom_highbd_10_sub_pixel_variance8x4_sse2, 10),
+  SubpelVarianceParams(6, 6, &aom_highbd_8_sub_pixel_variance64x64_sse2, 8),
+  SubpelVarianceParams(6, 5, &aom_highbd_8_sub_pixel_variance64x32_sse2, 8),
+  SubpelVarianceParams(5, 6, &aom_highbd_8_sub_pixel_variance32x64_sse2, 8),
+  SubpelVarianceParams(5, 5, &aom_highbd_8_sub_pixel_variance32x32_sse2, 8),
+  SubpelVarianceParams(5, 4, &aom_highbd_8_sub_pixel_variance32x16_sse2, 8),
+  SubpelVarianceParams(4, 5, &aom_highbd_8_sub_pixel_variance16x32_sse2, 8),
+  SubpelVarianceParams(4, 4, &aom_highbd_8_sub_pixel_variance16x16_sse2, 8),
+  SubpelVarianceParams(4, 3, &aom_highbd_8_sub_pixel_variance16x8_sse2, 8),
+  SubpelVarianceParams(3, 4, &aom_highbd_8_sub_pixel_variance8x16_sse2, 8),
+  SubpelVarianceParams(3, 3, &aom_highbd_8_sub_pixel_variance8x8_sse2, 8),
+  SubpelVarianceParams(3, 2, &aom_highbd_8_sub_pixel_variance8x4_sse2, 8)
+};
+
+INSTANTIATE_TEST_CASE_P(SSE2, AvxHBDSubpelVarianceTest,
+                        ::testing::ValuesIn(kArrayHBDSubpelVariance_sse2));
 
-INSTANTIATE_TEST_CASE_P(
-    SSE2, AvxHBDSubpelAvgVarianceTest,
-    ::testing::Values(
-        make_tuple(6, 6, &aom_highbd_12_sub_pixel_avg_variance64x64_sse2, 12),
-        make_tuple(6, 5, &aom_highbd_12_sub_pixel_avg_variance64x32_sse2, 12),
-        make_tuple(5, 6, &aom_highbd_12_sub_pixel_avg_variance32x64_sse2, 12),
-        make_tuple(5, 5, &aom_highbd_12_sub_pixel_avg_variance32x32_sse2, 12),
-        make_tuple(5, 4, &aom_highbd_12_sub_pixel_avg_variance32x16_sse2, 12),
-        make_tuple(4, 5, &aom_highbd_12_sub_pixel_avg_variance16x32_sse2, 12),
-        make_tuple(4, 4, &aom_highbd_12_sub_pixel_avg_variance16x16_sse2, 12),
-        make_tuple(4, 3, &aom_highbd_12_sub_pixel_avg_variance16x8_sse2, 12),
-        make_tuple(3, 4, &aom_highbd_12_sub_pixel_avg_variance8x16_sse2, 12),
-        make_tuple(3, 3, &aom_highbd_12_sub_pixel_avg_variance8x8_sse2, 12),
-        make_tuple(3, 2, &aom_highbd_12_sub_pixel_avg_variance8x4_sse2, 12),
-        make_tuple(6, 6, &aom_highbd_10_sub_pixel_avg_variance64x64_sse2, 10),
-        make_tuple(6, 5, &aom_highbd_10_sub_pixel_avg_variance64x32_sse2, 10),
-        make_tuple(5, 6, &aom_highbd_10_sub_pixel_avg_variance32x64_sse2, 10),
-        make_tuple(5, 5, &aom_highbd_10_sub_pixel_avg_variance32x32_sse2, 10),
-        make_tuple(5, 4, &aom_highbd_10_sub_pixel_avg_variance32x16_sse2, 10),
-        make_tuple(4, 5, &aom_highbd_10_sub_pixel_avg_variance16x32_sse2, 10),
-        make_tuple(4, 4, &aom_highbd_10_sub_pixel_avg_variance16x16_sse2, 10),
-        make_tuple(4, 3, &aom_highbd_10_sub_pixel_avg_variance16x8_sse2, 10),
-        make_tuple(3, 4, &aom_highbd_10_sub_pixel_avg_variance8x16_sse2, 10),
-        make_tuple(3, 3, &aom_highbd_10_sub_pixel_avg_variance8x8_sse2, 10),
-        make_tuple(3, 2, &aom_highbd_10_sub_pixel_avg_variance8x4_sse2, 10),
-        make_tuple(6, 6, &aom_highbd_8_sub_pixel_avg_variance64x64_sse2, 8),
-        make_tuple(6, 5, &aom_highbd_8_sub_pixel_avg_variance64x32_sse2, 8),
-        make_tuple(5, 6, &aom_highbd_8_sub_pixel_avg_variance32x64_sse2, 8),
-        make_tuple(5, 5, &aom_highbd_8_sub_pixel_avg_variance32x32_sse2, 8),
-        make_tuple(5, 4, &aom_highbd_8_sub_pixel_avg_variance32x16_sse2, 8),
-        make_tuple(4, 5, &aom_highbd_8_sub_pixel_avg_variance16x32_sse2, 8),
-        make_tuple(4, 4, &aom_highbd_8_sub_pixel_avg_variance16x16_sse2, 8),
-        make_tuple(4, 3, &aom_highbd_8_sub_pixel_avg_variance16x8_sse2, 8),
-        make_tuple(3, 4, &aom_highbd_8_sub_pixel_avg_variance8x16_sse2, 8),
-        make_tuple(3, 3, &aom_highbd_8_sub_pixel_avg_variance8x8_sse2, 8),
-        make_tuple(3, 2, &aom_highbd_8_sub_pixel_avg_variance8x4_sse2, 8)));
+const SubpelAvgVarianceParams kArrayHBDSubpelAvgVariance_sse2[] = {
+  SubpelAvgVarianceParams(6, 6, &aom_highbd_12_sub_pixel_avg_variance64x64_sse2,
+                          12),
+  SubpelAvgVarianceParams(6, 5, &aom_highbd_12_sub_pixel_avg_variance64x32_sse2,
+                          12),
+  SubpelAvgVarianceParams(5, 6, &aom_highbd_12_sub_pixel_avg_variance32x64_sse2,
+                          12),
+  SubpelAvgVarianceParams(5, 5, &aom_highbd_12_sub_pixel_avg_variance32x32_sse2,
+                          12),
+  SubpelAvgVarianceParams(5, 4, &aom_highbd_12_sub_pixel_avg_variance32x16_sse2,
+                          12),
+  SubpelAvgVarianceParams(4, 5, &aom_highbd_12_sub_pixel_avg_variance16x32_sse2,
+                          12),
+  SubpelAvgVarianceParams(4, 4, &aom_highbd_12_sub_pixel_avg_variance16x16_sse2,
+                          12),
+  SubpelAvgVarianceParams(4, 3, &aom_highbd_12_sub_pixel_avg_variance16x8_sse2,
+                          12),
+  SubpelAvgVarianceParams(3, 4, &aom_highbd_12_sub_pixel_avg_variance8x16_sse2,
+                          12),
+  SubpelAvgVarianceParams(3, 3, &aom_highbd_12_sub_pixel_avg_variance8x8_sse2,
+                          12),
+  SubpelAvgVarianceParams(3, 2, &aom_highbd_12_sub_pixel_avg_variance8x4_sse2,
+                          12),
+  SubpelAvgVarianceParams(6, 6, &aom_highbd_10_sub_pixel_avg_variance64x64_sse2,
+                          10),
+  SubpelAvgVarianceParams(6, 5, &aom_highbd_10_sub_pixel_avg_variance64x32_sse2,
+                          10),
+  SubpelAvgVarianceParams(5, 6, &aom_highbd_10_sub_pixel_avg_variance32x64_sse2,
+                          10),
+  SubpelAvgVarianceParams(5, 5, &aom_highbd_10_sub_pixel_avg_variance32x32_sse2,
+                          10),
+  SubpelAvgVarianceParams(5, 4, &aom_highbd_10_sub_pixel_avg_variance32x16_sse2,
+                          10),
+  SubpelAvgVarianceParams(4, 5, &aom_highbd_10_sub_pixel_avg_variance16x32_sse2,
+                          10),
+  SubpelAvgVarianceParams(4, 4, &aom_highbd_10_sub_pixel_avg_variance16x16_sse2,
+                          10),
+  SubpelAvgVarianceParams(4, 3, &aom_highbd_10_sub_pixel_avg_variance16x8_sse2,
+                          10),
+  SubpelAvgVarianceParams(3, 4, &aom_highbd_10_sub_pixel_avg_variance8x16_sse2,
+                          10),
+  SubpelAvgVarianceParams(3, 3, &aom_highbd_10_sub_pixel_avg_variance8x8_sse2,
+                          10),
+  SubpelAvgVarianceParams(3, 2, &aom_highbd_10_sub_pixel_avg_variance8x4_sse2,
+                          10),
+  SubpelAvgVarianceParams(6, 6, &aom_highbd_8_sub_pixel_avg_variance64x64_sse2,
+                          8),
+  SubpelAvgVarianceParams(6, 5, &aom_highbd_8_sub_pixel_avg_variance64x32_sse2,
+                          8),
+  SubpelAvgVarianceParams(5, 6, &aom_highbd_8_sub_pixel_avg_variance32x64_sse2,
+                          8),
+  SubpelAvgVarianceParams(5, 5, &aom_highbd_8_sub_pixel_avg_variance32x32_sse2,
+                          8),
+  SubpelAvgVarianceParams(5, 4, &aom_highbd_8_sub_pixel_avg_variance32x16_sse2,
+                          8),
+  SubpelAvgVarianceParams(4, 5, &aom_highbd_8_sub_pixel_avg_variance16x32_sse2,
+                          8),
+  SubpelAvgVarianceParams(4, 4, &aom_highbd_8_sub_pixel_avg_variance16x16_sse2,
+                          8),
+  SubpelAvgVarianceParams(4, 3, &aom_highbd_8_sub_pixel_avg_variance16x8_sse2,
+                          8),
+  SubpelAvgVarianceParams(3, 4, &aom_highbd_8_sub_pixel_avg_variance8x16_sse2,
+                          8),
+  SubpelAvgVarianceParams(3, 3, &aom_highbd_8_sub_pixel_avg_variance8x8_sse2,
+                          8),
+  SubpelAvgVarianceParams(3, 2, &aom_highbd_8_sub_pixel_avg_variance8x4_sse2, 8)
+};
+
+INSTANTIATE_TEST_CASE_P(SSE2, AvxHBDSubpelAvgVarianceTest,
+                        ::testing::ValuesIn(kArrayHBDSubpelAvgVariance_sse2));
 #endif  // CONFIG_HIGHBITDEPTH
 #endif  // HAVE_SSE2
 
 #if HAVE_SSSE3
 INSTANTIATE_TEST_CASE_P(
     SSSE3, AvxSubpelVarianceTest,
-    ::testing::Values(make_tuple(6, 6, &aom_sub_pixel_variance64x64_ssse3, 0),
-                      make_tuple(6, 5, &aom_sub_pixel_variance64x32_ssse3, 0),
-                      make_tuple(5, 6, &aom_sub_pixel_variance32x64_ssse3, 0),
-                      make_tuple(5, 5, &aom_sub_pixel_variance32x32_ssse3, 0),
-                      make_tuple(5, 4, &aom_sub_pixel_variance32x16_ssse3, 0),
-                      make_tuple(4, 5, &aom_sub_pixel_variance16x32_ssse3, 0),
-                      make_tuple(4, 4, &aom_sub_pixel_variance16x16_ssse3, 0),
-                      make_tuple(4, 3, &aom_sub_pixel_variance16x8_ssse3, 0),
-                      make_tuple(3, 4, &aom_sub_pixel_variance8x16_ssse3, 0),
-                      make_tuple(3, 3, &aom_sub_pixel_variance8x8_ssse3, 0),
-                      make_tuple(3, 2, &aom_sub_pixel_variance8x4_ssse3, 0),
-                      make_tuple(2, 3, &aom_sub_pixel_variance4x8_ssse3, 0),
-                      make_tuple(2, 2, &aom_sub_pixel_variance4x4_ssse3, 0)));
+    ::testing::Values(
+        SubpelVarianceParams(6, 6, &aom_sub_pixel_variance64x64_ssse3, 0),
+        SubpelVarianceParams(6, 5, &aom_sub_pixel_variance64x32_ssse3, 0),
+        SubpelVarianceParams(5, 6, &aom_sub_pixel_variance32x64_ssse3, 0),
+        SubpelVarianceParams(5, 5, &aom_sub_pixel_variance32x32_ssse3, 0),
+        SubpelVarianceParams(5, 4, &aom_sub_pixel_variance32x16_ssse3, 0),
+        SubpelVarianceParams(4, 5, &aom_sub_pixel_variance16x32_ssse3, 0),
+        SubpelVarianceParams(4, 4, &aom_sub_pixel_variance16x16_ssse3, 0),
+        SubpelVarianceParams(4, 3, &aom_sub_pixel_variance16x8_ssse3, 0),
+        SubpelVarianceParams(3, 4, &aom_sub_pixel_variance8x16_ssse3, 0),
+        SubpelVarianceParams(3, 3, &aom_sub_pixel_variance8x8_ssse3, 0),
+        SubpelVarianceParams(3, 2, &aom_sub_pixel_variance8x4_ssse3, 0),
+        SubpelVarianceParams(2, 3, &aom_sub_pixel_variance4x8_ssse3, 0),
+        SubpelVarianceParams(2, 2, &aom_sub_pixel_variance4x4_ssse3, 0)));
 
 INSTANTIATE_TEST_CASE_P(
     SSSE3, AvxSubpelAvgVarianceTest,
     ::testing::Values(
-        make_tuple(6, 6, &aom_sub_pixel_avg_variance64x64_ssse3, 0),
-        make_tuple(6, 5, &aom_sub_pixel_avg_variance64x32_ssse3, 0),
-        make_tuple(5, 6, &aom_sub_pixel_avg_variance32x64_ssse3, 0),
-        make_tuple(5, 5, &aom_sub_pixel_avg_variance32x32_ssse3, 0),
-        make_tuple(5, 4, &aom_sub_pixel_avg_variance32x16_ssse3, 0),
-        make_tuple(4, 5, &aom_sub_pixel_avg_variance16x32_ssse3, 0),
-        make_tuple(4, 4, &aom_sub_pixel_avg_variance16x16_ssse3, 0),
-        make_tuple(4, 3, &aom_sub_pixel_avg_variance16x8_ssse3, 0),
-        make_tuple(3, 4, &aom_sub_pixel_avg_variance8x16_ssse3, 0),
-        make_tuple(3, 3, &aom_sub_pixel_avg_variance8x8_ssse3, 0),
-        make_tuple(3, 2, &aom_sub_pixel_avg_variance8x4_ssse3, 0),
-        make_tuple(2, 3, &aom_sub_pixel_avg_variance4x8_ssse3, 0),
-        make_tuple(2, 2, &aom_sub_pixel_avg_variance4x4_ssse3, 0)));
+        SubpelAvgVarianceParams(6, 6, &aom_sub_pixel_avg_variance64x64_ssse3,
+                                0),
+        SubpelAvgVarianceParams(6, 5, &aom_sub_pixel_avg_variance64x32_ssse3,
+                                0),
+        SubpelAvgVarianceParams(5, 6, &aom_sub_pixel_avg_variance32x64_ssse3,
+                                0),
+        SubpelAvgVarianceParams(5, 5, &aom_sub_pixel_avg_variance32x32_ssse3,
+                                0),
+        SubpelAvgVarianceParams(5, 4, &aom_sub_pixel_avg_variance32x16_ssse3,
+                                0),
+        SubpelAvgVarianceParams(4, 5, &aom_sub_pixel_avg_variance16x32_ssse3,
+                                0),
+        SubpelAvgVarianceParams(4, 4, &aom_sub_pixel_avg_variance16x16_ssse3,
+                                0),
+        SubpelAvgVarianceParams(4, 3, &aom_sub_pixel_avg_variance16x8_ssse3, 0),
+        SubpelAvgVarianceParams(3, 4, &aom_sub_pixel_avg_variance8x16_ssse3, 0),
+        SubpelAvgVarianceParams(3, 3, &aom_sub_pixel_avg_variance8x8_ssse3, 0),
+        SubpelAvgVarianceParams(3, 2, &aom_sub_pixel_avg_variance8x4_ssse3, 0),
+        SubpelAvgVarianceParams(2, 3, &aom_sub_pixel_avg_variance4x8_ssse3, 0),
+        SubpelAvgVarianceParams(2, 2, &aom_sub_pixel_avg_variance4x4_ssse3,
+                                0)));
 #endif  // HAVE_SSSE3
 
 #if HAVE_AVX2
 INSTANTIATE_TEST_CASE_P(AVX2, AvxMseTest,
                         ::testing::Values(MseParams(4, 4, &aom_mse16x16_avx2)));
 
 INSTANTIATE_TEST_CASE_P(
     AVX2, AvxVarianceTest,
     ::testing::Values(VarianceParams(6, 6, &aom_variance64x64_avx2),
                       VarianceParams(6, 5, &aom_variance64x32_avx2),
                       VarianceParams(5, 5, &aom_variance32x32_avx2),
                       VarianceParams(5, 4, &aom_variance32x16_avx2),
                       VarianceParams(4, 4, &aom_variance16x16_avx2)));
 
 INSTANTIATE_TEST_CASE_P(
     AVX2, AvxSubpelVarianceTest,
-    ::testing::Values(make_tuple(6, 6, &aom_sub_pixel_variance64x64_avx2, 0),
-                      make_tuple(5, 5, &aom_sub_pixel_variance32x32_avx2, 0)));
+    ::testing::Values(
+        SubpelVarianceParams(6, 6, &aom_sub_pixel_variance64x64_avx2, 0),
+        SubpelVarianceParams(5, 5, &aom_sub_pixel_variance32x32_avx2, 0)));
 
 INSTANTIATE_TEST_CASE_P(
     AVX2, AvxSubpelAvgVarianceTest,
     ::testing::Values(
-        make_tuple(6, 6, &aom_sub_pixel_avg_variance64x64_avx2, 0),
-        make_tuple(5, 5, &aom_sub_pixel_avg_variance32x32_avx2, 0)));
+        SubpelAvgVarianceParams(6, 6, &aom_sub_pixel_avg_variance64x64_avx2, 0),
+        SubpelAvgVarianceParams(5, 5, &aom_sub_pixel_avg_variance32x32_avx2,
+                                0)));
 #endif  // HAVE_AVX2
 
 #if HAVE_NEON
 INSTANTIATE_TEST_CASE_P(NEON, AvxSseTest,
                         ::testing::Values(SseParams(2, 2,
                                                     &aom_get4x4sse_cs_neon)));
 
 INSTANTIATE_TEST_CASE_P(NEON, AvxMseTest,
@@ -1293,20 +1367,21 @@ INSTANTIATE_TEST_CASE_P(
                       VarianceParams(5, 5, &aom_variance32x32_neon),
                       VarianceParams(4, 4, &aom_variance16x16_neon),
                       VarianceParams(4, 3, &aom_variance16x8_neon),
                       VarianceParams(3, 4, &aom_variance8x16_neon),
                       VarianceParams(3, 3, &aom_variance8x8_neon)));
 
 INSTANTIATE_TEST_CASE_P(
     NEON, AvxSubpelVarianceTest,
-    ::testing::Values(make_tuple(6, 6, &aom_sub_pixel_variance64x64_neon, 0),
-                      make_tuple(5, 5, &aom_sub_pixel_variance32x32_neon, 0),
-                      make_tuple(4, 4, &aom_sub_pixel_variance16x16_neon, 0),
-                      make_tuple(3, 3, &aom_sub_pixel_variance8x8_neon, 0)));
+    ::testing::Values(
+        SubpelVarianceParams(6, 6, &aom_sub_pixel_variance64x64_neon, 0),
+        SubpelVarianceParams(5, 5, &aom_sub_pixel_variance32x32_neon, 0),
+        SubpelVarianceParams(4, 4, &aom_sub_pixel_variance16x16_neon, 0),
+        SubpelVarianceParams(3, 3, &aom_sub_pixel_variance8x8_neon, 0)));
 #endif  // HAVE_NEON
 
 #if HAVE_MSA
 INSTANTIATE_TEST_CASE_P(MSA, SumOfSquaresTest,
                         ::testing::Values(aom_get_mb_ss_msa));
 
 INSTANTIATE_TEST_CASE_P(MSA, AvxSseTest,
                         ::testing::Values(SseParams(2, 2,
@@ -1331,39 +1406,41 @@ INSTANTIATE_TEST_CASE_P(
                       VarianceParams(3, 4, &aom_variance8x16_msa),
                       VarianceParams(3, 3, &aom_variance8x8_msa),
                       VarianceParams(3, 2, &aom_variance8x4_msa),
                       VarianceParams(2, 3, &aom_variance4x8_msa),
                       VarianceParams(2, 2, &aom_variance4x4_msa)));
 
 INSTANTIATE_TEST_CASE_P(
     MSA, AvxSubpelVarianceTest,
-    ::testing::Values(make_tuple(2, 2, &aom_sub_pixel_variance4x4_msa, 0),
-                      make_tuple(2, 3, &aom_sub_pixel_variance4x8_msa, 0),
-                      make_tuple(3, 2, &aom_sub_pixel_variance8x4_msa, 0),
-                      make_tuple(3, 3, &aom_sub_pixel_variance8x8_msa, 0),
-                      make_tuple(3, 4, &aom_sub_pixel_variance8x16_msa, 0),
-                      make_tuple(4, 3, &aom_sub_pixel_variance16x8_msa, 0),
-                      make_tuple(4, 4, &aom_sub_pixel_variance16x16_msa, 0),
-                      make_tuple(4, 5, &aom_sub_pixel_variance16x32_msa, 0),
-                      make_tuple(5, 4, &aom_sub_pixel_variance32x16_msa, 0),
-                      make_tuple(5, 5, &aom_sub_pixel_variance32x32_msa, 0),
-                      make_tuple(5, 6, &aom_sub_pixel_variance32x64_msa, 0),
-                      make_tuple(6, 5, &aom_sub_pixel_variance64x32_msa, 0),
-                      make_tuple(6, 6, &aom_sub_pixel_variance64x64_msa, 0)));
+    ::testing::Values(
+        SubpelVarianceParams(2, 2, &aom_sub_pixel_variance4x4_msa, 0),
+        SubpelVarianceParams(2, 3, &aom_sub_pixel_variance4x8_msa, 0),
+        SubpelVarianceParams(3, 2, &aom_sub_pixel_variance8x4_msa, 0),
+        SubpelVarianceParams(3, 3, &aom_sub_pixel_variance8x8_msa, 0),
+        SubpelVarianceParams(3, 4, &aom_sub_pixel_variance8x16_msa, 0),
+        SubpelVarianceParams(4, 3, &aom_sub_pixel_variance16x8_msa, 0),
+        SubpelVarianceParams(4, 4, &aom_sub_pixel_variance16x16_msa, 0),
+        SubpelVarianceParams(4, 5, &aom_sub_pixel_variance16x32_msa, 0),
+        SubpelVarianceParams(5, 4, &aom_sub_pixel_variance32x16_msa, 0),
+        SubpelVarianceParams(5, 5, &aom_sub_pixel_variance32x32_msa, 0),
+        SubpelVarianceParams(5, 6, &aom_sub_pixel_variance32x64_msa, 0),
+        SubpelVarianceParams(6, 5, &aom_sub_pixel_variance64x32_msa, 0),
+        SubpelVarianceParams(6, 6, &aom_sub_pixel_variance64x64_msa, 0)));
 
 INSTANTIATE_TEST_CASE_P(
     MSA, AvxSubpelAvgVarianceTest,
-    ::testing::Values(make_tuple(6, 6, &aom_sub_pixel_avg_variance64x64_msa, 0),
-                      make_tuple(6, 5, &aom_sub_pixel_avg_variance64x32_msa, 0),
-                      make_tuple(5, 6, &aom_sub_pixel_avg_variance32x64_msa, 0),
-                      make_tuple(5, 5, &aom_sub_pixel_avg_variance32x32_msa, 0),
-                      make_tuple(5, 4, &aom_sub_pixel_avg_variance32x16_msa, 0),
-                      make_tuple(4, 5, &aom_sub_pixel_avg_variance16x32_msa, 0),
-                      make_tuple(4, 4, &aom_sub_pixel_avg_variance16x16_msa, 0),
-                      make_tuple(4, 3, &aom_sub_pixel_avg_variance16x8_msa, 0),
-                      make_tuple(3, 4, &aom_sub_pixel_avg_variance8x16_msa, 0),
-                      make_tuple(3, 3, &aom_sub_pixel_avg_variance8x8_msa, 0),
-                      make_tuple(3, 2, &aom_sub_pixel_avg_variance8x4_msa, 0),
-                      make_tuple(2, 3, &aom_sub_pixel_avg_variance4x8_msa, 0),
-                      make_tuple(2, 2, &aom_sub_pixel_avg_variance4x4_msa, 0)));
+    ::testing::Values(
+        SubpelAvgVarianceParams(6, 6, &aom_sub_pixel_avg_variance64x64_msa, 0),
+        SubpelAvgVarianceParams(6, 5, &aom_sub_pixel_avg_variance64x32_msa, 0),
+        SubpelAvgVarianceParams(5, 6, &aom_sub_pixel_avg_variance32x64_msa, 0),
+        SubpelAvgVarianceParams(5, 5, &aom_sub_pixel_avg_variance32x32_msa, 0),
+        SubpelAvgVarianceParams(5, 4, &aom_sub_pixel_avg_variance32x16_msa, 0),
+        SubpelAvgVarianceParams(4, 5, &aom_sub_pixel_avg_variance16x32_msa, 0),
+        SubpelAvgVarianceParams(4, 4, &aom_sub_pixel_avg_variance16x16_msa, 0),
+        SubpelAvgVarianceParams(4, 3, &aom_sub_pixel_avg_variance16x8_msa, 0),
+        SubpelAvgVarianceParams(3, 4, &aom_sub_pixel_avg_variance8x16_msa, 0),
+        SubpelAvgVarianceParams(3, 3, &aom_sub_pixel_avg_variance8x8_msa, 0),
+        SubpelAvgVarianceParams(3, 2, &aom_sub_pixel_avg_variance8x4_msa, 0),
+        SubpelAvgVarianceParams(2, 3, &aom_sub_pixel_avg_variance4x8_msa, 0),
+        SubpelAvgVarianceParams(2, 2, &aom_sub_pixel_avg_variance4x4_msa, 0)));
 #endif  // HAVE_MSA
 }  // namespace
--- a/third_party/aom/test/warp_filter_test.cc
+++ b/third_party/aom/test/warp_filter_test.cc
@@ -23,19 +23,21 @@ using libaom_test::AV1HighbdWarpFilter::
 namespace {
 
 TEST_P(AV1WarpFilterTest, CheckOutput) { RunCheckOutput(GET_PARAM(3)); }
 
 INSTANTIATE_TEST_CASE_P(
     SSE2, AV1WarpFilterTest,
     libaom_test::AV1WarpFilter::BuildParams(av1_warp_affine_sse2));
 
+#if HAVE_SSSE3
 INSTANTIATE_TEST_CASE_P(
     SSSE3, AV1WarpFilterTest,
     libaom_test::AV1WarpFilter::BuildParams(av1_warp_affine_ssse3));
+#endif
 
 #if CONFIG_HIGHBITDEPTH && HAVE_SSSE3
 TEST_P(AV1HighbdWarpFilterTest, CheckOutput) {
   RunCheckOutput(av1_highbd_warp_affine_ssse3);
 }
 
 INSTANTIATE_TEST_CASE_P(SSSE3, AV1HighbdWarpFilterTest,
                         libaom_test::AV1HighbdWarpFilter::GetDefaultParams());
--- a/third_party/aom/test/warp_filter_test_util.cc
+++ b/third_party/aom/test/warp_filter_test_util.cc
@@ -107,34 +107,35 @@ void AV1WarpFilterTest::RunCheckOutput(w
 
   // The warp functions always write rows with widths that are multiples of 8.
   // So to avoid a buffer overflow, we may need to pad rows to a multiple of 8.
   int output_n = ((out_w + 7) & ~7) * out_h;
   uint8_t *output = new uint8_t[output_n];
   uint8_t *output2 = new uint8_t[output_n];
   int32_t mat[8];
   int16_t alpha, beta, gamma, delta;
+  ConvolveParams conv_params = get_conv_params(0, 0, 0);
 
   // Generate an input block and extend its borders horizontally
   for (i = 0; i < h; ++i)
     for (j = 0; j < w; ++j) input[i * stride + j] = rnd_.Rand8();
   for (i = 0; i < h; ++i) {
     memset(input + i * stride - border, input[i * stride], border);
     memset(input + i * stride + w, input[i * stride + (w - 1)], border);
   }
 
   for (i = 0; i < num_iters; ++i) {
     for (sub_x = 0; sub_x < 2; ++sub_x)
       for (sub_y = 0; sub_y < 2; ++sub_y) {
         generate_model(mat, &alpha, &beta, &gamma, &delta);
         av1_warp_affine_c(mat, input, w, h, stride, output, 32, 32, out_w,
-                          out_h, out_w, sub_x, sub_y, 0, alpha, beta, gamma,
-                          delta);
+                          out_h, out_w, sub_x, sub_y, &conv_params, alpha, beta,
+                          gamma, delta);
         test_impl(mat, input, w, h, stride, output2, 32, 32, out_w, out_h,
-                  out_w, sub_x, sub_y, 0, alpha, beta, gamma, delta);
+                  out_w, sub_x, sub_y, &conv_params, alpha, beta, gamma, delta);
 
         for (j = 0; j < out_w * out_h; ++j)
           ASSERT_EQ(output[j], output2[j])
               << "Pixel mismatch at index " << j << " = (" << (j % out_w)
               << ", " << (j / out_w) << ") on iteration " << i;
       }
   }
   delete[] input_;
@@ -243,16 +244,17 @@ void AV1HighbdWarpFilterTest::RunCheckOu
   // So to avoid a buffer overflow, we may need to pad rows to a multiple of 8.
   int output_n = ((out_w + 7) & ~7) * out_h;
   uint16_t *input_ = new uint16_t[h * stride];
   uint16_t *input = input_ + border;
   uint16_t *output = new uint16_t[output_n];
   uint16_t *output2 = new uint16_t[output_n];
   int32_t mat[8];
   int16_t alpha, beta, gamma, delta;
+  ConvolveParams conv_params = get_conv_params(0, 0, 0);
 
   // Generate an input block and extend its borders horizontally
   for (i = 0; i < h; ++i)
     for (j = 0; j < w; ++j) input[i * stride + j] = rnd_.Rand16() & mask;
   for (i = 0; i < h; ++i) {
     for (j = 0; j < border; ++j) {
       input[i * stride - border + j] = input[i * stride];
       input[i * stride + w + j] = input[i * stride + (w - 1)];
@@ -260,20 +262,21 @@ void AV1HighbdWarpFilterTest::RunCheckOu
   }
 
   for (i = 0; i < num_iters; ++i) {
     for (sub_x = 0; sub_x < 2; ++sub_x)
       for (sub_y = 0; sub_y < 2; ++sub_y) {
         generate_model(mat, &alpha, &beta, &gamma, &delta);
 
         av1_highbd_warp_affine_c(mat, input, w, h, stride, output, 32, 32,
-                                 out_w, out_h, out_w, sub_x, sub_y, bd, 0,
-                                 alpha, beta, gamma, delta);
+                                 out_w, out_h, out_w, sub_x, sub_y, bd,
+                                 &conv_params, alpha, beta, gamma, delta);
         test_impl(mat, input, w, h, stride, output2, 32, 32, out_w, out_h,
-                  out_w, sub_x, sub_y, bd, 0, alpha, beta, gamma, delta);
+                  out_w, sub_x, sub_y, bd, &conv_params, alpha, beta, gamma,
+                  delta);
 
         for (j = 0; j < out_w * out_h; ++j)
           ASSERT_EQ(output[j], output2[j])
               << "Pixel mismatch at index " << j << " = (" << (j % out_w)
               << ", " << (j / out_w) << ") on iteration " << i;
       }
   }
 
--- a/third_party/aom/test/warp_filter_test_util.h
+++ b/third_party/aom/test/warp_filter_test_util.h
@@ -26,18 +26,18 @@ namespace libaom_test {
 
 namespace AV1WarpFilter {
 
 typedef void (*warp_affine_func)(const int32_t *mat, const uint8_t *ref,
                                  int width, int height, int stride,
                                  uint8_t *pred, int p_col, int p_row,
                                  int p_width, int p_height, int p_stride,
                                  int subsampling_x, int subsampling_y,
-                                 int ref_frm, int16_t alpha, int16_t beta,
-                                 int16_t gamma, int16_t delta);
+                                 ConvolveParams *conv_params, int16_t alpha,
+                                 int16_t beta, int16_t gamma, int16_t delta);
 
 typedef std::tr1::tuple<int, int, int, warp_affine_func> WarpTestParam;
 
 ::testing::internal::ParamGenerator<WarpTestParam> BuildParams(
     warp_affine_func filter);
 
 class AV1WarpFilterTest : public ::testing::TestWithParam<WarpTestParam> {
  public:
@@ -55,21 +55,24 @@ class AV1WarpFilterTest : public ::testi
 
   libaom_test::ACMRandom rnd_;
 };
 
 }  // namespace AV1WarpFilter
 
 #if CONFIG_HIGHBITDEPTH
 namespace AV1HighbdWarpFilter {
-typedef void (*highbd_warp_affine_func)(
-    const int32_t *mat, const uint16_t *ref, int width, int height, int stride,
-    uint16_t *pred, int p_col, int p_row, int p_width, int p_height,
-    int p_stride, int subsampling_x, int subsampling_y, int bd, int ref_frm,
-    int16_t alpha, int16_t beta, int16_t gamma, int16_t delta);
+typedef void (*highbd_warp_affine_func)(const int32_t *mat, const uint16_t *ref,
+                                        int width, int height, int stride,
+                                        uint16_t *pred, int p_col, int p_row,
+                                        int p_width, int p_height, int p_stride,
+                                        int subsampling_x, int subsampling_y,
+                                        int bd, ConvolveParams *conv_params,
+                                        int16_t alpha, int16_t beta,
+                                        int16_t gamma, int16_t delta);
 
 typedef std::tr1::tuple<int, int, int, int> HighbdWarpTestParam;
 
 ::testing::internal::ParamGenerator<HighbdWarpTestParam> GetDefaultParams();
 
 class AV1HighbdWarpFilterTest
     : public ::testing::TestWithParam<HighbdWarpTestParam> {
  public:
--- a/third_party/aom/third_party/libwebm/README.libaom
+++ b/third_party/aom/third_party/libwebm/README.libaom
@@ -1,10 +1,10 @@
 URL: https://chromium.googlesource.com/webm/libwebm
-Version: 32d5ac49414a8914ec1e1f285f3f927c6e8ec29d
+Version: a97c484bfd6b5de4b1b61efe33089b55d810b412
 License: BSD
 License File: LICENSE.txt
 
 Description:
 libwebm is used to handle WebM container I/O.
 
 Local Changes:
 * <none>
--- a/third_party/aom/third_party/libwebm/common/file_util.cc
+++ b/third_party/aom/third_party/libwebm/common/file_util.cc
@@ -9,30 +9,41 @@
 
 #include <sys/stat.h>
 #ifndef _MSC_VER
 #include <unistd.h>  // close()
 #endif
 
 #include <cstdio>
 #include <cstdlib>
+#include <cstring>
 #include <fstream>
 #include <ios>
 
 namespace libwebm {
 
 std::string GetTempFileName() {
 #if !defined _MSC_VER && !defined __MINGW32__
-  char temp_file_name_template[] = "libwebm_temp.XXXXXX";
+  std::string temp_file_name_template_str =
+      std::string(std::getenv("TEST_TMPDIR") ? std::getenv("TEST_TMPDIR") :
+                                               ".") +
+      "/libwebm_temp.XXXXXX";
+  char* temp_file_name_template =
+      new char[temp_file_name_template_str.length() + 1];
+  memset(temp_file_name_template, 0, temp_file_name_template_str.length() + 1);
+  temp_file_name_template_str.copy(temp_file_name_template,
+                                   temp_file_name_template_str.length(), 0);
   int fd = mkstemp(temp_file_name_template);
+  std::string temp_file_name =
+      (fd != -1) ? std::string(temp_file_name_template) : std::string();
+  delete[] temp_file_name_template;
   if (fd != -1) {
     close(fd);
-    return std::string(temp_file_name_template);
   }
-  return std::string();
+  return temp_file_name;
 #else
   char tmp_file_name[_MAX_PATH];
   errno_t err = tmpnam_s(tmp_file_name);
   if (err == 0) {
     return std::string(tmp_file_name);
   }
   return std::string();
 #endif
--- a/third_party/aom/third_party/libwebm/common/hdr_util.cc
+++ b/third_party/aom/third_party/libwebm/common/hdr_util.cc
@@ -2,41 +2,44 @@
 //
 // Use of this source code is governed by a BSD-style license
 // that can be found in the LICENSE file in the root of the source
 // tree. An additional intellectual property rights grant can be found
 // in the file PATENTS.  All contributing project authors may
 // be found in the AUTHORS file in the root of the source tree.
 #include "hdr_util.h"
 
+#include <climits>
 #include <cstddef>
 #include <new>
 
 #include "mkvparser/mkvparser.h"
 
 namespace libwebm {
+const int Vp9CodecFeatures::kValueNotPresent = INT_MAX;
+
 bool CopyPrimaryChromaticity(const mkvparser::PrimaryChromaticity& parser_pc,
                              PrimaryChromaticityPtr* muxer_pc) {
   muxer_pc->reset(new (std::nothrow)
                       mkvmuxer::PrimaryChromaticity(parser_pc.x, parser_pc.y));
   if (!muxer_pc->get())
     return false;
   return true;
 }
 
 bool MasteringMetadataValuePresent(double value) {
   return value != mkvparser::MasteringMetadata::kValueNotPresent;
 }
 
 bool CopyMasteringMetadata(const mkvparser::MasteringMetadata& parser_mm,
                            mkvmuxer::MasteringMetadata* muxer_mm) {
   if (MasteringMetadataValuePresent(parser_mm.luminance_max))
-    muxer_mm->luminance_max = parser_mm.luminance_max;
+    muxer_mm->set_luminance_max(parser_mm.luminance_max);
   if (MasteringMetadataValuePresent(parser_mm.luminance_min))
-    muxer_mm->luminance_min = parser_mm.luminance_min;
+    muxer_mm->set_luminance_min(parser_mm.luminance_min);
 
   PrimaryChromaticityPtr r_ptr(NULL);
   PrimaryChromaticityPtr g_ptr(NULL);
   PrimaryChromaticityPtr b_ptr(NULL);
   PrimaryChromaticityPtr wp_ptr(NULL);
 
   if (parser_mm.r) {
     if (!CopyPrimaryChromaticity(*parser_mm.r, &r_ptr))
@@ -68,115 +71,150 @@ bool ColourValuePresent(long long value)
 }
 
 bool CopyColour(const mkvparser::Colour& parser_colour,
                 mkvmuxer::Colour* muxer_colour) {
   if (!muxer_colour)
     return false;
 
   if (ColourValuePresent(parser_colour.matrix_coefficients))
-    muxer_colour->matrix_coefficients = parser_colour.matrix_coefficients;
+    muxer_colour->set_matrix_coefficients(parser_colour.matrix_coefficients);
   if (ColourValuePresent(parser_colour.bits_per_channel))
-    muxer_colour->bits_per_channel = parser_colour.bits_per_channel;
-  if (ColourValuePresent(parser_colour.chroma_subsampling_horz))
-    muxer_colour->chroma_subsampling_horz =
-        parser_colour.chroma_subsampling_horz;
-  if (ColourValuePresent(parser_colour.chroma_subsampling_vert))
-    muxer_colour->chroma_subsampling_vert =
-        parser_colour.chroma_subsampling_vert;
+    muxer_colour->set_bits_per_channel(parser_colour.bits_per_channel);
+  if (ColourValuePresent(parser_colour.chroma_subsampling_horz)) {
+    muxer_colour->set_chroma_subsampling_horz(
+        parser_colour.chroma_subsampling_horz);
+  }
+  if (ColourValuePresent(parser_colour.chroma_subsampling_vert)) {
+    muxer_colour->set_chroma_subsampling_vert(
+        parser_colour.chroma_subsampling_vert);
+  }
   if (ColourValuePresent(parser_colour.cb_subsampling_horz))
-    muxer_colour->cb_subsampling_horz = parser_colour.cb_subsampling_horz;
+    muxer_colour->set_cb_subsampling_horz(parser_colour.cb_subsampling_horz);
   if (ColourValuePresent(parser_colour.cb_subsampling_vert))
-    muxer_colour->cb_subsampling_vert = parser_colour.cb_subsampling_vert;
+    muxer_colour->set_cb_subsampling_vert(parser_colour.cb_subsampling_vert);
   if (ColourValuePresent(parser_colour.chroma_siting_horz))
-    muxer_colour->chroma_siting_horz = parser_colour.chroma_siting_horz;
+    muxer_colour->set_chroma_siting_horz(parser_colour.chroma_siting_horz);
   if (ColourValuePresent(parser_colour.chroma_siting_vert))
-    muxer_colour->chroma_siting_vert = parser_colour.chroma_siting_vert;
+    muxer_colour->set_chroma_siting_vert(parser_colour.chroma_siting_vert);
   if (ColourValuePresent(parser_colour.range))
-    muxer_colour->range = parser_colour.range;
-  if (ColourValuePresent(parser_colour.transfer_characteristics))
-    muxer_colour->transfer_characteristics =
-        parser_colour.transfer_characteristics;
+    muxer_colour->set_range(parser_colour.range);
+  if (ColourValuePresent(parser_colour.transfer_characteristics)) {
+    muxer_colour->set_transfer_characteristics(
+        parser_colour.transfer_characteristics);
+  }
   if (ColourValuePresent(parser_colour.primaries))
-    muxer_colour->primaries = parser_colour.primaries;
+    muxer_colour->set_primaries(parser_colour.primaries);
   if (ColourValuePresent(parser_colour.max_cll))
-    muxer_colour->max_cll = parser_colour.max_cll;
+    muxer_colour->set_max_cll(parser_colour.max_cll);
   if (ColourValuePresent(parser_colour.max_fall))
-    muxer_colour->max_fall = parser_colour.max_fall;
+    muxer_colour->set_max_fall(parser_colour.max_fall);
 
   if (parser_colour.mastering_metadata) {
     mkvmuxer::MasteringMetadata muxer_mm;
     if (!CopyMasteringMetadata(*parser_colour.mastering_metadata, &muxer_mm))
       return false;
     if (!muxer_colour->SetMasteringMetadata(muxer_mm))
       return false;
   }
   return true;
 }
 
 // Format of VPx private data:
 //
 //   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 //  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-//  |    ID Byte    |             Length            |               |
-//  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               |
+//  |    ID Byte    |   Length      |                               |
+//  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               |
 //  |                                                               |
 //  :               Bytes 1..Length of Codec Feature                :
 //  |                                                               |
 //  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 //
 // ID Byte Format
 // ID byte is an unsigned byte.
 //   0 1 2 3 4 5 6 7
 //  +-+-+-+-+-+-+-+-+
 //  |X|    ID       |
 //  +-+-+-+-+-+-+-+-+
 //
 // The X bit is reserved.
 //
-// Currently only profile level is supported. ID byte must be set to 1, and
-// length must be 1. Supported values are:
-//
-//   10: Level 1
-//   11: Level 1.1
-//   20: Level 2
-//   21: Level 2.1
-//   30: Level 3
-//   31: Level 3.1
-//   40: Level 4
-//   41: Level 4.1
-//   50: Level 5
-//   51: Level 5.1
-//   52: Level 5.2
-//   60: Level 6
-//   61: Level 6.1
-//   62: Level 6.2
-//
 // See the following link for more information:
 // http://www.webmproject.org/vp9/profiles/
-int ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length) {
-  const int kVpxCodecPrivateLength = 3;
-  if (!private_data || length != kVpxCodecPrivateLength)
-    return 0;
+bool ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length,
+                          Vp9CodecFeatures* features) {
+  const int kVpxCodecPrivateMinLength = 3;
+  if (!private_data || !features || length < kVpxCodecPrivateMinLength)
+    return false;
+
+  const uint8_t kVp9ProfileId = 1;
+  const uint8_t kVp9LevelId = 2;
+  const uint8_t kVp9BitDepthId = 3;
+  const uint8_t kVp9ChromaSubsamplingId = 4;
+  const int kVpxFeatureLength = 1;
+  int offset = 0;
 
-  const uint8_t id_byte = *private_data;
-  if (id_byte != 1)
-    return 0;
+  // Set features to not set.
+  features->profile = Vp9CodecFeatures::kValueNotPresent;
+  features->level = Vp9CodecFeatures::kValueNotPresent;
+  features->bit_depth = Vp9CodecFeatures::kValueNotPresent;
+  features->chroma_subsampling = Vp9CodecFeatures::kValueNotPresent;
+  do {
+    const uint8_t id_byte = private_data[offset++];
+    const uint8_t length_byte = private_data[offset++];
+    if (length_byte != kVpxFeatureLength)
+      return false;
+    if (id_byte == kVp9ProfileId) {
+      const int priv_profile = static_cast<int>(private_data[offset++]);
+      if (priv_profile < 0 || priv_profile > 3)
+        return false;
+      if (features->profile != Vp9CodecFeatures::kValueNotPresent &&
+          features->profile != priv_profile) {
+        return false;
+      }
+      features->profile = priv_profile;
+    } else if (id_byte == kVp9LevelId) {
+      const int priv_level = static_cast<int>(private_data[offset++]);
 
-  const int kVpxProfileLength = 1;
-  const uint8_t length_byte = private_data[1];
-  if (length_byte != kVpxProfileLength)
-    return 0;
-
-  const int level = static_cast<int>(private_data[2]);
+      const int kNumLevels = 14;
+      const int levels[kNumLevels] = {10, 11, 20, 21, 30, 31, 40,
+                                      41, 50, 51, 52, 60, 61, 62};
 
-  const int kNumLevels = 14;
-  const int levels[kNumLevels] = {10, 11, 20, 21, 30, 31, 40,
-                                  41, 50, 51, 52, 60, 61, 62};
+      for (int i = 0; i < kNumLevels; ++i) {
+        if (priv_level == levels[i]) {
+          if (features->level != Vp9CodecFeatures::kValueNotPresent &&
+              features->level != priv_level) {
+            return false;
+          }
+          features->level = priv_level;
+          break;
+        }
+      }
+      if (features->level == Vp9CodecFeatures::kValueNotPresent)
+        return false;
+    } else if (id_byte == kVp9BitDepthId) {
+      const int priv_profile = static_cast<int>(private_data[offset++]);
+      if (priv_profile != 8 && priv_profile != 10 && priv_profile != 12)
+        return false;
+      if (features->bit_depth != Vp9CodecFeatures::kValueNotPresent &&
+          features->bit_depth != priv_profile) {
+        return false;
+      }
+      features->bit_depth = priv_profile;
+    } else if (id_byte == kVp9ChromaSubsamplingId) {
+      const int priv_profile = static_cast<int>(private_data[offset++]);
+      if (priv_profile != 0 && priv_profile != 2 && priv_profile != 3)
+        return false;
+      if (features->chroma_subsampling != Vp9CodecFeatures::kValueNotPresent &&
+          features->chroma_subsampling != priv_profile) {
+        return false;
+      }
+      features->chroma_subsampling = priv_profile;
+    } else {
+      // Invalid ID.
+      return false;
+    }
+  } while (offset + kVpxCodecPrivateMinLength <= length);
 
-  for (int i = 0; i < kNumLevels; ++i) {
-    if (level == levels[i])
-      return level;
-  }
-
-  return 0;
+  return true;
 }
 }  // namespace libwebm
--- a/third_party/aom/third_party/libwebm/common/hdr_util.h
+++ b/third_party/aom/third_party/libwebm/common/hdr_util.h
@@ -23,29 +23,57 @@ struct PrimaryChromaticity;
 namespace libwebm {
 // Utility types and functions for working with the Colour element and its
 // children. Copiers return true upon success. Presence functions return true
 // when the specified element is present.
 
 // TODO(tomfinegan): These should be moved to libwebm_utils once c++11 is
 // required by libwebm.
 
+// Features of the VP9 codec that may be set in the CodecPrivate of a VP9 video
+// stream. A value of kValueNotPresent represents that the value was not set in
+// the CodecPrivate.
+struct Vp9CodecFeatures {
+  static const int kValueNotPresent;
+
+  Vp9CodecFeatures()
+      : profile(kValueNotPresent),
+        level(kValueNotPresent),
+        bit_depth(kValueNotPresent),
+        chroma_subsampling(kValueNotPresent) {}
+  ~Vp9CodecFeatures() {}
+
+  int profile;
+  int level;
+  int bit_depth;
+  int chroma_subsampling;
+};
+
+// disable deprecation warnings for auto_ptr
+#if defined(__GNUC__) && __GNUC__ >= 5
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
 typedef std::auto_ptr<mkvmuxer::PrimaryChromaticity> PrimaryChromaticityPtr;
+#if defined(__GNUC__) && __GNUC__ >= 5
+#pragma GCC diagnostic pop
+#endif
 
 bool CopyPrimaryChromaticity(const mkvparser::PrimaryChromaticity& parser_pc,
                              PrimaryChromaticityPtr* muxer_pc);
 
 bool MasteringMetadataValuePresent(double value);
 
 bool CopyMasteringMetadata(const mkvparser::MasteringMetadata& parser_mm,
                            mkvmuxer::MasteringMetadata* muxer_mm);
 
 bool ColourValuePresent(long long value);
 
 bool CopyColour(const mkvparser::Colour& parser_colour,
                 mkvmuxer::Colour* muxer_colour);
 
-// Returns VP9 profile upon success or 0 upon failure.
-int ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length);
+// Returns true if |features| is set to one or more valid values.
+bool ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length,
+                          Vp9CodecFeatures* features);
 
 }  // namespace libwebm
 
 #endif  // LIBWEBM_COMMON_HDR_UTIL_H_
--- a/third_party/aom/third_party/libwebm/common/webmids.h
+++ b/third_party/aom/third_party/libwebm/common/webmids.h
@@ -119,16 +119,24 @@ enum MkvId {
   kMkvPrimaryBChromaticityX = 0x55D5,
   kMkvPrimaryBChromaticityY = 0x55D6,
   kMkvWhitePointChromaticityX = 0x55D7,
   kMkvWhitePointChromaticityY = 0x55D8,
   kMkvLuminanceMax = 0x55D9,
   kMkvLuminanceMin = 0x55DA,
   // end mastering metadata
   // end colour
+  // projection
+  kMkvProjection = 0x7670,
+  kMkvProjectionType = 0x7671,
+  kMkvProjectionPrivate = 0x7672,
+  kMkvProjectionPoseYaw = 0x7673,
+  kMkvProjectionPosePitch = 0x7674,
+  kMkvProjectionPoseRoll = 0x7675,
+  // end projection
   // audio
   kMkvAudio = 0xE1,
   kMkvSamplingFrequency = 0xB5,
   kMkvOutputSamplingFrequency = 0x78B5,
   kMkvChannels = 0x9F,
   kMkvBitDepth = 0x6264,
   // end audio
   // ContentEncodings
--- a/third_party/aom/third_party/libwebm/mkvmuxer/mkvmuxer.cc
+++ b/third_party/aom/third_party/libwebm/mkvmuxer/mkvmuxer.cc
@@ -11,29 +11,44 @@
 #include <cfloat>
 #include <climits>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
 #include <ctime>
 #include <memory>
 #include <new>
+#include <string>
 #include <vector>
 
 #include "common/webmids.h"
 #include "mkvmuxer/mkvmuxerutil.h"
 #include "mkvmuxer/mkvwriter.h"
 #include "mkvparser/mkvparser.h"
 
+// disable deprecation warnings for auto_ptr
+#if defined(__GNUC__) && __GNUC__ >= 5
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 namespace mkvmuxer {
 
+const float PrimaryChromaticity::kChromaticityMin = 0.0f;
+const float PrimaryChromaticity::kChromaticityMax = 1.0f;
+const float MasteringMetadata::kMinLuminance = 0.0f;
+const float MasteringMetadata::kMinLuminanceMax = 999.99f;
+const float MasteringMetadata::kMaxLuminanceMax = 9999.99f;
 const float MasteringMetadata::kValueNotPresent = FLT_MAX;
 const uint64_t Colour::kValueNotPresent = UINT64_MAX;
 
 namespace {
+
+const char kDocTypeWebm[] = "webm";
+const char kDocTypeMatroska[] = "matroska";
+
 // Deallocate the string designated by |dst|, and then copy the |src|
 // string to |dst|.  The caller owns both the |src| string and the
 // |dst| copy (hence the caller is responsible for eventually
 // deallocating the strings, either directly, or indirectly via
 // StrCpy).  Returns true if the source string was successfully copied
 // to the destination.
 bool StrCpy(const char* src, char** dst_ptr) {
   if (dst_ptr == NULL)
@@ -58,63 +73,84 @@ bool StrCpy(const char* src, char** dst_
 }
 
 typedef std::auto_ptr<PrimaryChromaticity> PrimaryChromaticityPtr;
 bool CopyChromaticity(const PrimaryChromaticity* src,
                       PrimaryChromaticityPtr* dst) {
   if (!dst)
     return false;
 
-  dst->reset(new (std::nothrow) PrimaryChromaticity(src->x, src->y));
+  dst->reset(new (std::nothrow) PrimaryChromaticity(src->x(), src->y()));
   if (!dst->get())
     return false;
 
   return true;
 }
 
 }  // namespace
 
 ///////////////////////////////////////////////////////////////
 //
 // IMkvWriter Class
 
 IMkvWriter::IMkvWriter() {}
 
 IMkvWriter::~IMkvWriter() {}
 
-bool WriteEbmlHeader(IMkvWriter* writer, uint64_t doc_type_version) {
+bool WriteEbmlHeader(IMkvWriter* writer, uint64_t doc_type_version,
+                     const char* const doc_type) {
   // Level 0
-  uint64_t size = EbmlElementSize(libwebm::kMkvEBMLVersion, UINT64_C(1));
-  size += EbmlElementSize(libwebm::kMkvEBMLReadVersion, UINT64_C(1));
-  size += EbmlElementSize(libwebm::kMkvEBMLMaxIDLength, UINT64_C(4));
-  size += EbmlElementSize(libwebm::kMkvEBMLMaxSizeLength, UINT64_C(8));
-  size += EbmlElementSize(libwebm::kMkvDocType, "webm");
-  size += EbmlElementSize(libwebm::kMkvDocTypeVersion, doc_type_version);
-  size += EbmlElementSize(libwebm::kMkvDocTypeReadVersion, UINT64_C(2));
+  uint64_t size =
+      EbmlElementSize(libwebm::kMkvEBMLVersion, static_cast<uint64>(1));
+  size += EbmlElementSize(libwebm::kMkvEBMLReadVersion, static_cast<uint64>(1));
+  size += EbmlElementSize(libwebm::kMkvEBMLMaxIDLength, static_cast<uint64>(4));
+  size +=
+      EbmlElementSize(libwebm::kMkvEBMLMaxSizeLength, static_cast<uint64>(8));
+  size += EbmlElementSize(libwebm::kMkvDocType, doc_type);
+  size += EbmlElementSize(libwebm::kMkvDocTypeVersion,
+                          static_cast<uint64>(doc_type_version));
+  size +=
+      EbmlElementSize(libwebm::kMkvDocTypeReadVersion, static_cast<uint64>(2));
 
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvEBML, size))
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvEBMLVersion, UINT64_C(1)))
+  if (!WriteEbmlElement(writer, libwebm::kMkvEBMLVersion,
+                        static_cast<uint64>(1))) {
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvEBMLReadVersion, UINT64_C(1)))
+  }
+  if (!WriteEbmlElement(writer, libwebm::kMkvEBMLReadVersion,
+                        static_cast<uint64>(1))) {
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvEBMLMaxIDLength, UINT64_C(4)))
+  }
+  if (!WriteEbmlElement(writer, libwebm::kMkvEBMLMaxIDLength,
+                        static_cast<uint64>(4))) {
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvEBMLMaxSizeLength, UINT64_C(8)))
+  }
+  if (!WriteEbmlElement(writer, libwebm::kMkvEBMLMaxSizeLength,
+                        static_cast<uint64>(8))) {
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvDocType, "webm"))
+  }
+  if (!WriteEbmlElement(writer, libwebm::kMkvDocType, doc_type))
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvDocTypeVersion, doc_type_version))
+  if (!WriteEbmlElement(writer, libwebm::kMkvDocTypeVersion,
+                        static_cast<uint64>(doc_type_version))) {
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvDocTypeReadVersion, UINT64_C(2)))
+  }
+  if (!WriteEbmlElement(writer, libwebm::kMkvDocTypeReadVersion,
+                        static_cast<uint64>(2))) {
     return false;
+  }
 
   return true;
 }
 
+bool WriteEbmlHeader(IMkvWriter* writer, uint64_t doc_type_version) {
+  return WriteEbmlHeader(writer, doc_type_version, kDocTypeWebm);
+}
+
 bool WriteEbmlHeader(IMkvWriter* writer) {
   return WriteEbmlHeader(writer, mkvmuxer::Segment::kDefaultDocTypeVersion);
 }
 
 bool ChunkedCopy(mkvparser::IMkvReader* source, mkvmuxer::IMkvWriter* dst,
                  int64_t start, int64_t size) {
   // TODO(vigneshv): Check if this is a reasonable value.
   const uint32_t kBufSize = 2048;
@@ -257,66 +293,79 @@ CuePoint::CuePoint()
       output_block_number_(true) {}
 
 CuePoint::~CuePoint() {}
 
 bool CuePoint::Write(IMkvWriter* writer) const {
   if (!writer || track_ < 1 || cluster_pos_ < 1)
     return false;
 
-  uint64_t size =
-      EbmlElementSize(libwebm::kMkvCueClusterPosition, cluster_pos_);
-  size += EbmlElementSize(libwebm::kMkvCueTrack, track_);
+  uint64_t size = EbmlElementSize(libwebm::kMkvCueClusterPosition,
+                                  static_cast<uint64>(cluster_pos_));
+  size += EbmlElementSize(libwebm::kMkvCueTrack, static_cast<uint64>(track_));
   if (output_block_number_ && block_number_ > 1)
-    size += EbmlElementSize(libwebm::kMkvCueBlockNumber, block_number_);
+    size += EbmlElementSize(libwebm::kMkvCueBlockNumber,
+                            static_cast<uint64>(block_number_));
   const uint64_t track_pos_size =
       EbmlMasterElementSize(libwebm::kMkvCueTrackPositions, size) + size;
   const uint64_t payload_size =
-      EbmlElementSize(libwebm::kMkvCueTime, time_) + track_pos_size;
+      EbmlElementSize(libwebm::kMkvCueTime, static_cast<uint64>(time_)) +
+      track_pos_size;
 
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvCuePoint, payload_size))
     return false;
 
   const int64_t payload_position = writer->Position();
   if (payload_position < 0)
     return false;
 
-  if (!WriteEbmlElement(writer, libwebm::kMkvCueTime, time_))
+  if (!WriteEbmlElement(writer, libwebm::kMkvCueTime,
+                        static_cast<uint64>(time_))) {
     return false;
+  }
 
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvCueTrackPositions, size))
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvCueTrack, track_))
+  if (!WriteEbmlElement(writer, libwebm::kMkvCueTrack,
+                        static_cast<uint64>(track_))) {
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvCueClusterPosition, cluster_pos_))
+  }
+  if (!WriteEbmlElement(writer, libwebm::kMkvCueClusterPosition,
+                        static_cast<uint64>(cluster_pos_))) {
     return false;
-  if (output_block_number_ && block_number_ > 1)
-    if (!WriteEbmlElement(writer, libwebm::kMkvCueBlockNumber, block_number_))
+  }
+  if (output_block_number_ && block_number_ > 1) {
+    if (!WriteEbmlElement(writer, libwebm::kMkvCueBlockNumber,
+                          static_cast<uint64>(block_number_))) {
       return false;
+    }
+  }
 
   const int64_t stop_position = writer->Position();
   if (stop_position < 0)
     return false;
 
   if (stop_position - payload_position != static_cast<int64_t>(payload_size))
     return false;
 
   return true;
 }
 
 uint64_t CuePoint::PayloadSize() const {
-  uint64_t size =
-      EbmlElementSize(libwebm::kMkvCueClusterPosition, cluster_pos_);
-  size += EbmlElementSize(libwebm::kMkvCueTrack, track_);
+  uint64_t size = EbmlElementSize(libwebm::kMkvCueClusterPosition,
+                                  static_cast<uint64>(cluster_pos_));
+  size += EbmlElementSize(libwebm::kMkvCueTrack, static_cast<uint64>(track_));
   if (output_block_number_ && block_number_ > 1)
-    size += EbmlElementSize(libwebm::kMkvCueBlockNumber, block_number_);
+    size += EbmlElementSize(libwebm::kMkvCueBlockNumber,
+                            static_cast<uint64>(block_number_));
   const uint64_t track_pos_size =
       EbmlMasterElementSize(libwebm::kMkvCueTrackPositions, size) + size;
   const uint64_t payload_size =
-      EbmlElementSize(libwebm::kMkvCueTime, time_) + track_pos_size;
+      EbmlElementSize(libwebm::kMkvCueTime, static_cast<uint64>(time_)) +
+      track_pos_size;
 
   return payload_size;
 }
 
 uint64_t CuePoint::Size() const {
   const uint64_t payload_size = PayloadSize();
   return EbmlMasterElementSize(libwebm::kMkvCuePoint, payload_size) +
          payload_size;
@@ -451,30 +500,31 @@ bool ContentEncAESSettings::Write(IMkvWr
                               payload))
     return false;
 
   const int64_t payload_position = writer->Position();
   if (payload_position < 0)
     return false;
 
   if (!WriteEbmlElement(writer, libwebm::kMkvAESSettingsCipherMode,
-                        cipher_mode_))
+                        static_cast<uint64>(cipher_mode_))) {
     return false;
+  }
 
   const int64_t stop_position = writer->Position();
   if (stop_position < 0 ||
       stop_position - payload_position != static_cast<int64_t>(payload))
     return false;
 
   return true;
 }
 
 uint64_t ContentEncAESSettings::PayloadSize() const {
-  uint64_t size =
-      EbmlElementSize(libwebm::kMkvAESSettingsCipherMode, cipher_mode_);
+  uint64_t size = EbmlElementSize(libwebm::kMkvAESSettingsCipherMode,
+                                  static_cast<uint64>(cipher_mode_));
   return size;
 }
 
 ///////////////////////////////////////////////////////////////
 //
 // ContentEncoding Class
 
 ContentEncoding::ContentEncoding()
@@ -524,30 +574,32 @@ bool ContentEncoding::Write(IMkvWriter* 
   const int64_t payload_position = writer->Position();
   if (payload_position < 0)
     return false;
 
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvContentEncoding,
                               encoding_size))
     return false;
   if (!WriteEbmlElement(writer, libwebm::kMkvContentEncodingOrder,
-                        encoding_order_))
+                        static_cast<uint64>(encoding_order_)))
     return false;
   if (!WriteEbmlElement(writer, libwebm::kMkvContentEncodingScope,
-                        encoding_scope_))
+                        static_cast<uint64>(encoding_scope_)))
     return false;
   if (!WriteEbmlElement(writer, libwebm::kMkvContentEncodingType,
-                        encoding_type_))
+                        static_cast<uint64>(encoding_type_)))
     return false;
 
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvContentEncryption,
                               encryption_size))
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvContentEncAlgo, enc_algo_))
+  if (!WriteEbmlElement(writer, libwebm::kMkvContentEncAlgo,
+                        static_cast<uint64>(enc_algo_))) {
     return false;
+  }
   if (!WriteEbmlElement(writer, libwebm::kMkvContentEncKeyID, enc_key_id_,
                         enc_key_id_length_))
     return false;
 
   if (!enc_aes_settings_.Write(writer))
     return false;
 
   const int64_t stop_position = writer->Position();
@@ -566,32 +618,33 @@ uint64_t ContentEncoding::EncodingSize(u
 
   uint64_t encoding_size = 0;
 
   if (encryption_size > 0) {
     encoding_size +=
         EbmlMasterElementSize(libwebm::kMkvContentEncryption, encryption_size) +
         encryption_size;
   }
-  encoding_size +=
-      EbmlElementSize(libwebm::kMkvContentEncodingType, encoding_type_);
-  encoding_size +=
-      EbmlElementSize(libwebm::kMkvContentEncodingScope, encoding_scope_);
-  encoding_size +=
-      EbmlElementSize(libwebm::kMkvContentEncodingOrder, encoding_order_);
+  encoding_size += EbmlElementSize(libwebm::kMkvContentEncodingType,
+                                   static_cast<uint64>(encoding_type_));
+  encoding_size += EbmlElementSize(libwebm::kMkvContentEncodingScope,
+                                   static_cast<uint64>(encoding_scope_));
+  encoding_size += EbmlElementSize(libwebm::kMkvContentEncodingOrder,
+                                   static_cast<uint64>(encoding_order_));
 
   return encoding_size;
 }
 
 uint64_t ContentEncoding::EncryptionSize() const {
   const uint64_t aes_size = enc_aes_settings_.Size();
 
   uint64_t encryption_size = EbmlElementSize(libwebm::kMkvContentEncKeyID,
                                              enc_key_id_, enc_key_id_length_);
-  encryption_size += EbmlElementSize(libwebm::kMkvContentEncAlgo, enc_algo_);
+  encryption_size += EbmlElementSize(libwebm::kMkvContentEncAlgo,
+                                     static_cast<uint64>(enc_algo_));
 
   return encryption_size + aes_size;
 }
 
 ///////////////////////////////////////////////////////////////
 //
 // Track Class
 
@@ -659,37 +712,45 @@ ContentEncoding* Track::GetContentEncodi
 
   if (index >= content_encoding_entries_size_)
     return NULL;
 
   return content_encoding_entries_[index];
 }
 
 uint64_t Track::PayloadSize() const {
-  uint64_t size = EbmlElementSize(libwebm::kMkvTrackNumber, number_);
-  size += EbmlElementSize(libwebm::kMkvTrackUID, uid_);
-  size += EbmlElementSize(libwebm::kMkvTrackType, type_);
+  uint64_t size =
+      EbmlElementSize(libwebm::kMkvTrackNumber, static_cast<uint64>(number_));
+  size += EbmlElementSize(libwebm::kMkvTrackUID, static_cast<uint64>(uid_));
+  size += EbmlElementSize(libwebm::kMkvTrackType, static_cast<uint64>(type_));
   if (codec_id_)
     size += EbmlElementSize(libwebm::kMkvCodecID, codec_id_);
   if (codec_private_)
     size += EbmlElementSize(libwebm::kMkvCodecPrivate, codec_private_,
                             codec_private_length_);
   if (language_)
     size += EbmlElementSize(libwebm::kMkvLanguage, language_);
   if (name_)
     size += EbmlElementSize(libwebm::kMkvName, name_);
-  if (max_block_additional_id_)
+  if (max_block_additional_id_) {
     size += EbmlElementSize(libwebm::kMkvMaxBlockAdditionID,
-                            max_block_additional_id_);
-  if (codec_delay_)
-    size += EbmlElementSize(libwebm::kMkvCodecDelay, codec_delay_);
-  if (seek_pre_roll_)
-    size += EbmlElementSize(libwebm::kMkvSeekPreRoll, seek_pre_roll_);
-  if (default_duration_)
-    size += EbmlElementSize(libwebm::kMkvDefaultDuration, default_duration_);
+                            static_cast<uint64>(max_block_additional_id_));
+  }
+  if (codec_delay_) {
+    size += EbmlElementSize(libwebm::kMkvCodecDelay,
+                            static_cast<uint64>(codec_delay_));
+  }
+  if (seek_pre_roll_) {
+    size += EbmlElementSize(libwebm::kMkvSeekPreRoll,
+                            static_cast<uint64>(seek_pre_roll_));
+  }
+  if (default_duration_) {
+    size += EbmlElementSize(libwebm::kMkvDefaultDuration,
+                            static_cast<uint64>(default_duration_));
+  }
 
   if (content_encoding_entries_size_ > 0) {
     uint64_t content_encodings_size = 0;
     for (uint32_t i = 0; i < content_encoding_entries_size_; ++i) {
       ContentEncoding* const encoding = content_encoding_entries_[i];
       content_encodings_size += encoding->Size();
     }
 
@@ -717,74 +778,83 @@ bool Track::Write(IMkvWriter* writer) co
 
   // |size| may be bigger than what is written out in this function because
   // derived classes may write out more data in the Track element.
   const uint64_t payload_size = PayloadSize();
 
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvTrackEntry, payload_size))
     return false;
 
-  uint64_t size = EbmlElementSize(libwebm::kMkvTrackNumber, number_);
-  size += EbmlElementSize(libwebm::kMkvTrackUID, uid_);
-  size += EbmlElementSize(libwebm::kMkvTrackType, type_);
+  uint64_t size =
+      EbmlElementSize(libwebm::kMkvTrackNumber, static_cast<uint64>(number_));
+  size += EbmlElementSize(libwebm::kMkvTrackUID, static_cast<uint64>(uid_));
+  size += EbmlElementSize(libwebm::kMkvTrackType, static_cast<uint64>(type_));
   if (codec_id_)
     size += EbmlElementSize(libwebm::kMkvCodecID, codec_id_);
   if (codec_private_)
     size += EbmlElementSize(libwebm::kMkvCodecPrivate, codec_private_,
-                            codec_private_length_);
+                            static_cast<uint64>(codec_private_length_));
   if (language_)
     size += EbmlElementSize(libwebm::kMkvLanguage, language_);
   if (name_)
     size += EbmlElementSize(libwebm::kMkvName, name_);
   if (max_block_additional_id_)
     size += EbmlElementSize(libwebm::kMkvMaxBlockAdditionID,
-                            max_block_additional_id_);
+                            static_cast<uint64>(max_block_additional_id_));
   if (codec_delay_)
-    size += EbmlElementSize(libwebm::kMkvCodecDelay, codec_delay_);
+    size += EbmlElementSize(libwebm::kMkvCodecDelay,
+                            static_cast<uint64>(codec_delay_));
   if (seek_pre_roll_)
-    size += EbmlElementSize(libwebm::kMkvSeekPreRoll, seek_pre_roll_);
+    size += EbmlElementSize(libwebm::kMkvSeekPreRoll,
+                            static_cast<uint64>(seek_pre_roll_));
   if (default_duration_)
-    size += EbmlElementSize(libwebm::kMkvDefaultDuration, default_duration_);
+    size += EbmlElementSize(libwebm::kMkvDefaultDuration,
+                            static_cast<uint64>(default_duration_));
 
   const int64_t payload_position = writer->Position();
   if (payload_position < 0)
     return false;
 
-  if (!WriteEbmlElement(writer, libwebm::kMkvTrackNumber, number_))
+  if (!WriteEbmlElement(writer, libwebm::kMkvTrackNumber,
+                        static_cast<uint64>(number_)))
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvTrackUID, uid_))
+  if (!WriteEbmlElement(writer, libwebm::kMkvTrackUID,
+                        static_cast<uint64>(uid_)))
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvTrackType, type_))
+  if (!WriteEbmlElement(writer, libwebm::kMkvTrackType,
+                        static_cast<uint64>(type_)))
     return false;
   if (max_block_additional_id_) {
     if (!WriteEbmlElement(writer, libwebm::kMkvMaxBlockAdditionID,
-                          max_block_additional_id_)) {
+                          static_cast<uint64>(max_block_additional_id_))) {
       return false;
     }
   }
   if (codec_delay_) {
-    if (!WriteEbmlElement(writer, libwebm::kMkvCodecDelay, codec_delay_))
+    if (!WriteEbmlElement(writer, libwebm::kMkvCodecDelay,
+                          static_cast<uint64>(codec_delay_)))
       return false;
   }
   if (seek_pre_roll_) {
-    if (!WriteEbmlElement(writer, libwebm::kMkvSeekPreRoll, seek_pre_roll_))
+    if (!WriteEbmlElement(writer, libwebm::kMkvSeekPreRoll,
+                          static_cast<uint64>(seek_pre_roll_)))
       return false;
   }
   if (default_duration_) {
     if (!WriteEbmlElement(writer, libwebm::kMkvDefaultDuration,
-                          default_duration_))
+                          static_cast<uint64>(default_duration_)))
       return false;
   }
   if (codec_id_) {
     if (!WriteEbmlElement(writer, libwebm::kMkvCodecID, codec_id_))
       return false;
   }
   if (codec_private_) {
     if (!WriteEbmlElement(writer, libwebm::kMkvCodecPrivate, codec_private_,
-                          codec_private_length_))
+                          static_cast<uint64>(codec_private_length_)))
       return false;
   }
   if (language_) {
     if (!WriteEbmlElement(writer, libwebm::kMkvLanguage, language_))
       return false;
   }
   if (name_) {
     if (!WriteEbmlElement(writer, libwebm::kMkvName, name_))
@@ -885,50 +955,84 @@ void Track::set_name(const char* name) {
     }
   }
 }
 
 ///////////////////////////////////////////////////////////////
 //
 // Colour and its child elements
 
-uint64_t PrimaryChromaticity::PrimaryChromaticityPayloadSize(
+uint64_t PrimaryChromaticity::PrimaryChromaticitySize(
     libwebm::MkvId x_id, libwebm::MkvId y_id) const {
-  return EbmlElementSize(x_id, x) + EbmlElementSize(y_id, y);
+  return EbmlElementSize(x_id, x_) + EbmlElementSize(y_id, y_);
 }
 
 bool PrimaryChromaticity::Write(IMkvWriter* writer, libwebm::MkvId x_id,
                                 libwebm::MkvId y_id) const {
-  return WriteEbmlElement(writer, x_id, x) && WriteEbmlElement(writer, y_id, y);
+  if (!Valid()) {
+    return false;
+  }
+  return WriteEbmlElement(writer, x_id, x_) &&
+         WriteEbmlElement(writer, y_id, y_);
+}
+
+bool PrimaryChromaticity::Valid() const {
+  return (x_ >= kChromaticityMin && x_ <= kChromaticityMax &&
+          y_ >= kChromaticityMin && y_ <= kChromaticityMax);
 }
 
 uint64_t MasteringMetadata::MasteringMetadataSize() const {
   uint64_t size = PayloadSize();
 
   if (size > 0)
     size += EbmlMasterElementSize(libwebm::kMkvMasteringMetadata, size);
 
   return size;
 }
 
+bool MasteringMetadata::Valid() const {
+  if (luminance_min_ != kValueNotPresent) {
+    if (luminance_min_ < kMinLuminance || luminance_min_ > kMinLuminanceMax ||
+        luminance_min_ > luminance_max_) {
+      return false;
+    }
+  }
+  if (luminance_max_ != kValueNotPresent) {
+    if (luminance_max_ < kMinLuminance || luminance_max_ > kMaxLuminanceMax ||
+        luminance_max_ < luminance_min_) {
+      return false;
+    }
+  }
+  if (r_ && !r_->Valid())
+    return false;
+  if (g_ && !g_->Valid())
+    return false;
+  if (b_ && !b_->Valid())
+    return false;
+  if (white_point_ && !white_point_->Valid())
+    return false;
+
+  return true;
+}
+
 bool MasteringMetadata::Write(IMkvWriter* writer) const {
   const uint64_t size = PayloadSize();
 
   // Don't write an empty element.
   if (size == 0)
     return true;
 
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvMasteringMetadata, size))
     return false;
-  if (luminance_max != kValueNotPresent &&
-      !WriteEbmlElement(writer, libwebm::kMkvLuminanceMax, luminance_max)) {
+  if (luminance_max_ != kValueNotPresent &&
+      !WriteEbmlElement(writer, libwebm::kMkvLuminanceMax, luminance_max_)) {
     return false;
   }
-  if (luminance_min != kValueNotPresent &&
-      !WriteEbmlElement(writer, libwebm::kMkvLuminanceMin, luminance_min)) {
+  if (luminance_min_ != kValueNotPresent &&
+      !WriteEbmlElement(writer, libwebm::kMkvLuminanceMin, luminance_min_)) {
     return false;
   }
   if (r_ &&
       !r_->Write(writer, libwebm::kMkvPrimaryRChromaticityX,
                  libwebm::kMkvPrimaryRChromaticityY)) {
     return false;
   }
   if (g_ &&
@@ -979,211 +1083,359 @@ bool MasteringMetadata::SetChromaticity(
   b_ = b_ptr.release();
   white_point_ = wp_ptr.release();
   return true;
 }
 
 uint64_t MasteringMetadata::PayloadSize() const {
   uint64_t size = 0;
 
-  if (luminance_max != kValueNotPresent)
-    size += EbmlElementSize(libwebm::kMkvLuminanceMax, luminance_max);
-  if (luminance_min != kValueNotPresent)
-    size += EbmlElementSize(libwebm::kMkvLuminanceMin, luminance_min);
+  if (luminance_max_ != kValueNotPresent)
+    size += EbmlElementSize(libwebm::kMkvLuminanceMax, luminance_max_);
+  if (luminance_min_ != kValueNotPresent)
+    size += EbmlElementSize(libwebm::kMkvLuminanceMin, luminance_min_);
 
   if (r_) {
-    size += r_->PrimaryChromaticityPayloadSize(
-        libwebm::kMkvPrimaryRChromaticityX, libwebm::kMkvPrimaryRChromaticityY);
+    size += r_->PrimaryChromaticitySize(libwebm::kMkvPrimaryRChromaticityX,
+                                        libwebm::kMkvPrimaryRChromaticityY);
   }
   if (g_) {
-    size += g_->PrimaryChromaticityPayloadSize(
-        libwebm::kMkvPrimaryGChromaticityX, libwebm::kMkvPrimaryGChromaticityY);
+    size += g_->PrimaryChromaticitySize(libwebm::kMkvPrimaryGChromaticityX,
+                                        libwebm::kMkvPrimaryGChromaticityY);
   }
   if (b_) {
-    size += b_->PrimaryChromaticityPayloadSize(
-        libwebm::kMkvPrimaryBChromaticityX, libwebm::kMkvPrimaryBChromaticityY);
+    size += b_->PrimaryChromaticitySize(libwebm::kMkvPrimaryBChromaticityX,
+                                        libwebm::kMkvPrimaryBChromaticityY);
   }
   if (white_point_) {
-    size += white_point_->PrimaryChromaticityPayloadSize(
+    size += white_point_->PrimaryChromaticitySize(
         libwebm::kMkvWhitePointChromaticityX,
         libwebm::kMkvWhitePointChromaticityY);
   }
 
   return size;
 }
 
 uint64_t Colour::ColourSize() const {
   uint64_t size = PayloadSize();
 
   if (size > 0)
     size += EbmlMasterElementSize(libwebm::kMkvColour, size);
 
   return size;
 }
 
+bool Colour::Valid() const {
+  if (mastering_metadata_ && !mastering_metadata_->Valid())
+    return false;
+  if (matrix_coefficients_ != kValueNotPresent &&
+      !IsMatrixCoefficientsValueValid(matrix_coefficients_)) {
+    return false;
+  }
+  if (chroma_siting_horz_ != kValueNotPresent &&
+      !IsChromaSitingHorzValueValid(chroma_siting_horz_)) {
+    return false;
+  }
+  if (chroma_siting_vert_ != kValueNotPresent &&
+      !IsChromaSitingVertValueValid(chroma_siting_vert_)) {
+    return false;
+  }
+  if (range_ != kValueNotPresent && !IsColourRangeValueValid(range_))
+    return false;
+  if (transfer_characteristics_ != kValueNotPresent &&
+      !IsTransferCharacteristicsValueValid(transfer_characteristics_)) {
+    return false;
+  }
+  if (primaries_ != kValueNotPresent && !IsPrimariesValueValid(primaries_))
+    return false;
+
+  return true;
+}
+
 bool Colour::Write(IMkvWriter* writer) const {
   const uint64_t size = PayloadSize();
 
   // Don't write an empty element.
   if (size == 0)
     return true;
 
+  // Don't write an invalid element.
+  if (!Valid())
+    return false;
+
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvColour, size))
     return false;
 
-  if (matrix_coefficients != kValueNotPresent &&
+  if (matrix_coefficients_ != kValueNotPresent &&
       !WriteEbmlElement(writer, libwebm::kMkvMatrixCoefficients,
-                        matrix_coefficients)) {
-    return false;
-  }
-  if (bits_per_channel != kValueNotPresent &&
-      !WriteEbmlElement(writer, libwebm::kMkvBitsPerChannel,
-                        bits_per_channel)) {
+                        static_cast<uint64>(matrix_coefficients_))) {
     return false;
   }
-  if (chroma_subsampling_horz != kValueNotPresent &&
+  if (bits_per_channel_ != kValueNotPresent &&
+      !WriteEbmlElement(writer, libwebm::kMkvBitsPerChannel,
+                        static_cast<uint64>(bits_per_channel_))) {
+    return false;
+  }
+  if (chroma_subsampling_horz_ != kValueNotPresent &&
       !WriteEbmlElement(writer, libwebm::kMkvChromaSubsamplingHorz,
-                        chroma_subsampling_horz)) {
+                        static_cast<uint64>(chroma_subsampling_horz_))) {
     return false;
   }
-  if (chroma_subsampling_vert != kValueNotPresent &&
+  if (chroma_subsampling_vert_ != kValueNotPresent &&
       !WriteEbmlElement(writer, libwebm::kMkvChromaSubsamplingVert,
-                        chroma_subsampling_vert)) {
+                        static_cast<uint64>(chroma_subsampling_vert_))) {
     return false;
   }
 
-  if (cb_subsampling_horz != kValueNotPresent &&
+  if (cb_subsampling_horz_ != kValueNotPresent &&
       !WriteEbmlElement(writer, libwebm::kMkvCbSubsamplingHorz,
-                        cb_subsampling_horz)) {
+                        static_cast<uint64>(cb_subsampling_horz_))) {
     return false;
   }
-  if (cb_subsampling_vert != kValueNotPresent &&
+  if (cb_subsampling_vert_ != kValueNotPresent &&
       !WriteEbmlElement(writer, libwebm::kMkvCbSubsamplingVert,
-                        cb_subsampling_vert)) {
+                        static_cast<uint64>(cb_subsampling_vert_))) {
     return false;
   }
-  if (chroma_siting_horz != kValueNotPresent &&
+  if (chroma_siting_horz_ != kValueNotPresent &&
       !WriteEbmlElement(writer, libwebm::kMkvChromaSitingHorz,
-                        chroma_siting_horz)) {
+                        static_cast<uint64>(chroma_siting_horz_))) {
     return false;
   }
-  if (chroma_siting_vert != kValueNotPresent &&
+  if (chroma_siting_vert_ != kValueNotPresent &&
       !WriteEbmlElement(writer, libwebm::kMkvChromaSitingVert,
-                        chroma_siting_vert)) {
+                        static_cast<uint64>(chroma_siting_vert_))) {
     return false;
   }
-  if (range != kValueNotPresent &&
-      !WriteEbmlElement(writer, libwebm::kMkvRange, range)) {
+  if (range_ != kValueNotPresent &&
+      !WriteEbmlElement(writer, libwebm::kMkvRange,
+                        static_cast<uint64>(range_))) {
     return false;
   }
-  if (transfer_characteristics != kValueNotPresent &&
+  if (transfer_characteristics_ != kValueNotPresent &&
       !WriteEbmlElement(writer, libwebm::kMkvTransferCharacteristics,
-                        transfer_characteristics)) {
+                        static_cast<uint64>(transfer_characteristics_))) {
     return false;
   }
-  if (primaries != kValueNotPresent &&
-      !WriteEbmlElement(writer, libwebm::kMkvPrimaries, primaries)) {
+  if (primaries_ != kValueNotPresent &&
+      !WriteEbmlElement(writer, libwebm::kMkvPrimaries,
+                        static_cast<uint64>(primaries_))) {
     return false;
   }
-  if (max_cll != kValueNotPresent &&
-      !WriteEbmlElement(writer, libwebm::kMkvMaxCLL, max_cll)) {
+  if (max_cll_ != kValueNotPresent &&
+      !WriteEbmlElement(writer, libwebm::kMkvMaxCLL,
+                        static_cast<uint64>(max_cll_))) {
     return false;
   }
-  if (max_fall != kValueNotPresent &&
-      !WriteEbmlElement(writer, libwebm::kMkvMaxFALL, max_fall)) {
+  if (max_fall_ != kValueNotPresent &&
+      !WriteEbmlElement(writer, libwebm::kMkvMaxFALL,
+                        static_cast<uint64>(max_fall_))) {
     return false;
   }
 
   if (mastering_metadata_ && !mastering_metadata_->Write(writer))
     return false;
 
   return true;
 }
 
 bool Colour::SetMasteringMetadata(const MasteringMetadata& mastering_metadata) {
   std::auto_ptr<MasteringMetadata> mm_ptr(new MasteringMetadata());
   if (!mm_ptr.get())
     return false;
 
-  mm_ptr->luminance_max = mastering_metadata.luminance_max;
-  mm_ptr->luminance_min = mastering_metadata.luminance_min;
+  mm_ptr->set_luminance_max(mastering_metadata.luminance_max());
+  mm_ptr->set_luminance_min(mastering_metadata.luminance_min());
 
   if (!mm_ptr->SetChromaticity(mastering_metadata.r(), mastering_metadata.g(),
                                mastering_metadata.b(),
                                mastering_metadata.white_point())) {
     return false;
   }
 
   delete mastering_metadata_;
   mastering_metadata_ = mm_ptr.release();
   return true;
 }
 
 uint64_t Colour::PayloadSize() const {
   uint64_t size = 0;
 
-  if (matrix_coefficients != kValueNotPresent)
-    size +=
-        EbmlElementSize(libwebm::kMkvMatrixCoefficients, matrix_coefficients);
-  if (bits_per_channel != kValueNotPresent)
-    size += EbmlElementSize(libwebm::kMkvBitsPerChannel, bits_per_channel);
-  if (chroma_subsampling_horz != kValueNotPresent)
+  if (matrix_coefficients_ != kValueNotPresent) {
+    size += EbmlElementSize(libwebm::kMkvMatrixCoefficients,
+                            static_cast<uint64>(matrix_coefficients_));
+  }
+  if (bits_per_channel_ != kValueNotPresent) {
+    size += EbmlElementSize(libwebm::kMkvBitsPerChannel,
+                            static_cast<uint64>(bits_per_channel_));
+  }
+  if (chroma_subsampling_horz_ != kValueNotPresent) {
     size += EbmlElementSize(libwebm::kMkvChromaSubsamplingHorz,
-                            chroma_subsampling_horz);
-  if (chroma_subsampling_vert != kValueNotPresent)
+                            static_cast<uint64>(chroma_subsampling_horz_));
+  }
+  if (chroma_subsampling_vert_ != kValueNotPresent) {
     size += EbmlElementSize(libwebm::kMkvChromaSubsamplingVert,
-                            chroma_subsampling_vert);
-  if (cb_subsampling_horz != kValueNotPresent)
-    size +=
-        EbmlElementSize(libwebm::kMkvCbSubsamplingHorz, cb_subsampling_horz);
-  if (cb_subsampling_vert != kValueNotPresent)
+                            static_cast<uint64>(chroma_subsampling_vert_));
+  }
+  if (cb_subsampling_horz_ != kValueNotPresent) {
+    size += EbmlElementSize(libwebm::kMkvCbSubsamplingHorz,
+                            static_cast<uint64>(cb_subsampling_horz_));
+  }
+  if (cb_subsampling_vert_ != kValueNotPresent) {
+    size += EbmlElementSize(libwebm::kMkvCbSubsamplingVert,
+                            static_cast<uint64>(cb_subsampling_vert_));
+  }
+  if (chroma_siting_horz_ != kValueNotPresent) {
+    size += EbmlElementSize(libwebm::kMkvChromaSitingHorz,
+                            static_cast<uint64>(chroma_siting_horz_));
+  }
+  if (chroma_siting_vert_ != kValueNotPresent) {
+    size += EbmlElementSize(libwebm::kMkvChromaSitingVert,
+                            static_cast<uint64>(chroma_siting_vert_));
+  }
+  if (range_ != kValueNotPresent) {
+    size += EbmlElementSize(libwebm::kMkvRange, static_cast<uint64>(range_));
+  }
+  if (transfer_characteristics_ != kValueNotPresent) {
+    size += EbmlElementSize(libwebm::kMkvTransferCharacteristics,
+                            static_cast<uint64>(transfer_characteristics_));
+  }
+  if (primaries_ != kValueNotPresent) {
+    size += EbmlElementSize(libwebm::kMkvPrimaries,
+                            static_cast<uint64>(primaries_));
+  }
+  if (max_cll_ != kValueNotPresent) {
+    size += EbmlElementSize(libwebm::kMkvMaxCLL, static_cast<uint64>(max_cll_));
+  }
+  if (max_fall_ != kValueNotPresent) {
     size +=
-        EbmlElementSize(libwebm::kMkvCbSubsamplingVert, cb_subsampling_vert);
-  if (chroma_siting_horz != kValueNotPresent)
-    size += EbmlElementSize(libwebm::kMkvChromaSitingHorz, chroma_siting_horz);
-  if (chroma_siting_vert != kValueNotPresent)
-    size += EbmlElementSize(libwebm::kMkvChromaSitingVert, chroma_siting_vert);
-  if (range != kValueNotPresent)
-    size += EbmlElementSize(libwebm::kMkvRange, range);
-  if (transfer_characteristics != kValueNotPresent)
-    size += EbmlElementSize(libwebm::kMkvTransferCharacteristics,
-                            transfer_characteristics);
-  if (primaries != kValueNotPresent)
-    size += EbmlElementSize(libwebm::kMkvPrimaries, primaries);
-  if (max_cll != kValueNotPresent)
-    size += EbmlElementSize(libwebm::kMkvMaxCLL, max_cll);
-  if (max_fall != kValueNotPresent)
-    size += EbmlElementSize(libwebm::kMkvMaxFALL, max_fall);
+        EbmlElementSize(libwebm::kMkvMaxFALL, static_cast<uint64>(max_fall_));
+  }
 
   if (mastering_metadata_)
     size += mastering_metadata_->MasteringMetadataSize();
 
   return size;
 }
 
 ///////////////////////////////////////////////////////////////
 //
+// Projection element
+
+uint64_t Projection::ProjectionSize() const {
+  uint64_t size = PayloadSize();
+
+  if (size > 0)
+    size += EbmlMasterElementSize(libwebm::kMkvProjection, size);
+
+  return size;
+}
+
+bool Projection::Write(IMkvWriter* writer) const {
+  const uint64_t size = PayloadSize();
+
+  // Don't write an empty element.
+  if (size == 0)
+    return true;
+
+  if (!WriteEbmlMasterElement(writer, libwebm::kMkvProjection, size))
+    return false;
+
+  if (!WriteEbmlElement(writer, libwebm::kMkvProjectionType,
+                        static_cast<uint64>(type_))) {
+    return false;
+  }
+
+  if (private_data_length_ > 0 && private_data_ != NULL &&
+      !WriteEbmlElement(writer, libwebm::kMkvProjectionPrivate, private_data_,
+                        private_data_length_)) {
+    return false;
+  }
+
+  if (!WriteEbmlElement(writer, libwebm::kMkvProjectionPoseYaw, pose_yaw_))
+    return false;
+
+  if (!WriteEbmlElement(writer, libwebm::kMkvProjectionPosePitch,
+                        pose_pitch_)) {
+    return false;
+  }
+
+  if (!WriteEbmlElement(writer, libwebm::kMkvProjectionPoseRoll, pose_roll_)) {
+    return false;
+  }
+
+  return true;
+}
+
+bool Projection::SetProjectionPrivate(const uint8_t* data,
+                                      uint64_t data_length) {
+  if (data == NULL || data_length == 0) {
+    return false;
+  }
+
+  if (data_length != static_cast<size_t>(data_length)) {
+    return false;
+  }
+
+  uint8_t* new_private_data =
+      new (std::nothrow) uint8_t[static_cast<size_t>(data_length)];
+  if (new_private_data == NULL) {
+    return false;
+  }
+
+  delete[] private_data_;
+  private_data_ = new_private_data;
+  private_data_length_ = data_length;
+  memcpy(private_data_, data, static_cast<size_t>(data_length));
+
+  return true;
+}
+
+uint64_t Projection::PayloadSize() const {
+  uint64_t size =
+      EbmlElementSize(libwebm::kMkvProjection, static_cast<uint64>(type_));
+
+  if (private_data_length_ > 0 && private_data_ != NULL) {
+    size += EbmlElementSize(libwebm::kMkvProjectionPrivate, private_data_,
+                            private_data_length_);
+  }
+
+  size += EbmlElementSize(libwebm::kMkvProjectionPoseYaw, pose_yaw_);
+  size += EbmlElementSize(libwebm::kMkvProjectionPosePitch, pose_pitch_);
+  size += EbmlElementSize(libwebm::kMkvProjectionPoseRoll, pose_roll_);
+
+  return size;
+}
+
+///////////////////////////////////////////////////////////////
+//
 // VideoTrack Class
 
 VideoTrack::VideoTrack(unsigned int* seed)
     : Track(seed),
       display_height_(0),
       display_width_(0),
+      pixel_height_(0),
+      pixel_width_(0),
       crop_left_(0),
       crop_right_(0),
       crop_top_(0),
       crop_bottom_(0),
       frame_rate_(0.0),
       height_(0),
       stereo_mode_(0),
       alpha_mode_(0),
       width_(0),
-      colour_(NULL) {}
-
-VideoTrack::~VideoTrack() { delete colour_; }
+      colour_(NULL),
+      projection_(NULL) {}
+
+VideoTrack::~VideoTrack() {
+  delete colour_;
+  delete projection_;
+}
 
 bool VideoTrack::SetStereoMode(uint64_t stereo_mode) {
   if (stereo_mode != kMono && stereo_mode != kSideBySideLeftIsFirst &&
       stereo_mode != kTopBottomRightIsFirst &&
       stereo_mode != kTopBottomLeftIsFirst &&
       stereo_mode != kSideBySideRightIsFirst)
     return false;
 
@@ -1216,62 +1468,78 @@ bool VideoTrack::Write(IMkvWriter* write
 
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvVideo, size))
     return false;
 
   const int64_t payload_position = writer->Position();
   if (payload_position < 0)
     return false;
 
-  if (!WriteEbmlElement(writer, libwebm::kMkvPixelWidth, width_))
+  if (!WriteEbmlElement(
+          writer, libwebm::kMkvPixelWidth,
+          static_cast<uint64>((pixel_width_ > 0) ? pixel_width_ : width_)))
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvPixelHeight, height_))
+  if (!WriteEbmlElement(
+          writer, libwebm::kMkvPixelHeight,
+          static_cast<uint64>((pixel_height_ > 0) ? pixel_height_ : height_)))
     return false;
   if (display_width_ > 0) {
-    if (!WriteEbmlElement(writer, libwebm::kMkvDisplayWidth, display_width_))
+    if (!WriteEbmlElement(writer, libwebm::kMkvDisplayWidth,
+                          static_cast<uint64>(display_width_)))
       return false;
   }
   if (display_height_ > 0) {
-    if (!WriteEbmlElement(writer, libwebm::kMkvDisplayHeight, display_height_))
+    if (!WriteEbmlElement(writer, libwebm::kMkvDisplayHeight,
+                          static_cast<uint64>(display_height_)))
       return false;
   }
   if (crop_left_ > 0) {
-    if (!WriteEbmlElement(writer, libwebm::kMkvPixelCropLeft, crop_left_))
+    if (!WriteEbmlElement(writer, libwebm::kMkvPixelCropLeft,
+                          static_cast<uint64>(crop_left_)))
       return false;
   }
   if (crop_right_ > 0) {
-    if (!WriteEbmlElement(writer, libwebm::kMkvPixelCropRight, crop_right_))
+    if (!WriteEbmlElement(writer, libwebm::kMkvPixelCropRight,
+                          static_cast<uint64>(crop_right_)))
       return false;
   }
   if (crop_top_ > 0) {
-    if (!WriteEbmlElement(writer, libwebm::kMkvPixelCropTop, crop_top_))
+    if (!WriteEbmlElement(writer, libwebm::kMkvPixelCropTop,
+                          static_cast<uint64>(crop_top_)))
       return false;
   }
   if (crop_bottom_ > 0) {
-    if (!WriteEbmlElement(writer, libwebm::kMkvPixelCropBottom, crop_bottom_))
+    if (!WriteEbmlElement(writer, libwebm::kMkvPixelCropBottom,
+                          static_cast<uint64>(crop_bottom_)))
       return false;
   }
   if (stereo_mode_ > kMono) {
-    if (!WriteEbmlElement(writer, libwebm::kMkvStereoMode, stereo_mode_))
+    if (!WriteEbmlElement(writer, libwebm::kMkvStereoMode,
+                          static_cast<uint64>(stereo_mode_)))
       return false;
   }
   if (alpha_mode_ > kNoAlpha) {
-    if (!WriteEbmlElement(writer, libwebm::kMkvAlphaMode, alpha_mode_))
+    if (!WriteEbmlElement(writer, libwebm::kMkvAlphaMode,
+                          static_cast<uint64>(alpha_mode_)))
       return false;
   }
   if (frame_rate_ > 0.0) {
     if (!WriteEbmlElement(writer, libwebm::kMkvFrameRate,
                           static_cast<float>(frame_rate_))) {
       return false;
     }
   }
   if (colour_) {
     if (!colour_->Write(writer))
       return false;
   }
+  if (projection_) {
+    if (!projection_->Write(writer))
+      return false;
+  }
 
   const int64_t stop_position = writer->Position();
   if (stop_position < 0 ||
       stop_position - payload_position != static_cast<int64_t>(size)) {
     return false;
   }
 
   return true;
@@ -1282,57 +1550,93 @@ bool VideoTrack::SetColour(const Colour&
   if (!colour_ptr.get())
     return false;
 
   if (colour.mastering_metadata()) {
     if (!colour_ptr->SetMasteringMetadata(*colour.mastering_metadata()))
       return false;
   }
 
-  colour_ptr->matrix_coefficients = colour.matrix_coefficients;
-  colour_ptr->bits_per_channel = colour.bits_per_channel;
-  colour_ptr->chroma_subsampling_horz = colour.chroma_subsampling_horz;
-  colour_ptr->chroma_subsampling_vert = colour.chroma_subsampling_vert;
-  colour_ptr->cb_subsampling_horz = colour.cb_subsampling_horz;
-  colour_ptr->cb_subsampling_vert = colour.cb_subsampling_vert;
-  colour_ptr->chroma_siting_horz = colour.chroma_siting_horz;
-  colour_ptr->chroma_siting_vert = colour.chroma_siting_vert;
-  colour_ptr->range = colour.range;
-  colour_ptr->transfer_characteristics = colour.transfer_characteristics;
-  colour_ptr->primaries = colour.primaries;
-  colour_ptr->max_cll = colour.max_cll;
-  colour_ptr->max_fall = colour.max_fall;
+  colour_ptr->set_matrix_coefficients(colour.matrix_coefficients());
+  colour_ptr->set_bits_per_channel(colour.bits_per_channel());
+  colour_ptr->set_chroma_subsampling_horz(colour.chroma_subsampling_horz());
+  colour_ptr->set_chroma_subsampling_vert(colour.chroma_subsampling_vert());
+  colour_ptr->set_cb_subsampling_horz(colour.cb_subsampling_horz());
+  colour_ptr->set_cb_subsampling_vert(colour.cb_subsampling_vert());
+  colour_ptr->set_chroma_siting_horz(colour.chroma_siting_horz());
+  colour_ptr->set_chroma_siting_vert(colour.chroma_siting_vert());
+  colour_ptr->set_range(colour.range());
+  colour_ptr->set_transfer_characteristics(colour.transfer_characteristics());
+  colour_ptr->set_primaries(colour.primaries());
+  colour_ptr->set_max_cll(colour.max_cll());
+  colour_ptr->set_max_fall(colour.max_fall());
+  delete colour_;
   colour_ = colour_ptr.release();
   return true;
 }
 
+bool VideoTrack::SetProjection(const Projection& projection) {
+  std::auto_ptr<Projection> projection_ptr(new Projection());
+  if (!projection_ptr.get())
+    return false;
+
+  if (projection.private_data()) {
+    if (!projection_ptr->SetProjectionPrivate(
+            projection.private_data(), projection.private_data_length())) {
+      return false;
+    }
+  }
+
+  projection_ptr->set_type(projection.type());
+  projection_ptr->set_pose_yaw(projection.pose_yaw());
+  projection_ptr->set_pose_pitch(projection.pose_pitch());
+  projection_ptr->set_pose_roll(projection.pose_roll());
+  delete projection_;
+  projection_ = projection_ptr.release();
+  return true;
+}
+
 uint64_t VideoTrack::VideoPayloadSize() const {
-  uint64_t size = EbmlElementSize(libwebm::kMkvPixelWidth, width_);
-  size += EbmlElementSize(libwebm::kMkvPixelHeight, height_);
+  uint64_t size = EbmlElementSize(
+      libwebm::kMkvPixelWidth,
+      static_cast<uint64>((pixel_width_ > 0) ? pixel_width_ : width_));
+  size += EbmlElementSize(
+      libwebm::kMkvPixelHeight,
+      static_cast<uint64>((pixel_height_ > 0) ? pixel_height_ : height_));
   if (display_width_ > 0)
-    size += EbmlElementSize(libwebm::kMkvDisplayWidth, display_width_);
+    size += EbmlElementSize(libwebm::kMkvDisplayWidth,
+                            static_cast<uint64>(display_width_));
   if (display_height_ > 0)
-    size += EbmlElementSize(libwebm::kMkvDisplayHeight, display_height_);
+    size += EbmlElementSize(libwebm::kMkvDisplayHeight,
+                            static_cast<uint64>(display_height_));
   if (crop_left_ > 0)
-    size += EbmlElementSize(libwebm::kMkvPixelCropLeft, crop_left_);
+    size += EbmlElementSize(libwebm::kMkvPixelCropLeft,
+                            static_cast<uint64>(crop_left_));
   if (crop_right_ > 0)
-    size += EbmlElementSize(libwebm::kMkvPixelCropRight, crop_right_);
+    size += EbmlElementSize(libwebm::kMkvPixelCropRight,
+                            static_cast<uint64>(crop_right_));
   if (crop_top_ > 0)
-    size += EbmlElementSize(libwebm::kMkvPixelCropTop, crop_top_);
+    size += EbmlElementSize(libwebm::kMkvPixelCropTop,
+                            static_cast<uint64>(crop_top_));
   if (crop_bottom_ > 0)
-    size += EbmlElementSize(libwebm::kMkvPixelCropBottom, crop_bottom_);
+    size += EbmlElementSize(libwebm::kMkvPixelCropBottom,
+                            static_cast<uint64>(crop_bottom_));
   if (stereo_mode_ > kMono)
-    size += EbmlElementSize(libwebm::kMkvStereoMode, stereo_mode_);
+    size += EbmlElementSize(libwebm::kMkvStereoMode,
+                            static_cast<uint64>(stereo_mode_));
   if (alpha_mode_ > kNoAlpha)
-    size += EbmlElementSize(libwebm::kMkvAlphaMode, alpha_mode_);
+    size += EbmlElementSize(libwebm::kMkvAlphaMode,
+                            static_cast<uint64>(alpha_mode_));
   if (frame_rate_ > 0.0)
     size += EbmlElementSize(libwebm::kMkvFrameRate,
                             static_cast<float>(frame_rate_));
   if (colour_)
     size += colour_->ColourSize();
+  if (projection_)
+    size += projection_->ProjectionSize();
 
   return size;
 }
 
 ///////////////////////////////////////////////////////////////
 //
 // AudioTrack Class
 
@@ -1341,49 +1645,55 @@ AudioTrack::AudioTrack(unsigned int* see
 
 AudioTrack::~AudioTrack() {}
 
 uint64_t AudioTrack::PayloadSize() const {
   const uint64_t parent_size = Track::PayloadSize();
 
   uint64_t size = EbmlElementSize(libwebm::kMkvSamplingFrequency,
                                   static_cast<float>(sample_rate_));
-  size += EbmlElementSize(libwebm::kMkvChannels, channels_);
+  size +=
+      EbmlElementSize(libwebm::kMkvChannels, static_cast<uint64>(channels_));
   if (bit_depth_ > 0)
-    size += EbmlElementSize(libwebm::kMkvBitDepth, bit_depth_);
+    size +=
+        EbmlElementSize(libwebm::kMkvBitDepth, static_cast<uint64>(bit_depth_));
   size += EbmlMasterElementSize(libwebm::kMkvAudio, size);
 
   return parent_size + size;
 }
 
 bool AudioTrack::Write(IMkvWriter* writer) const {
   if (!Track::Write(writer))
     return false;
 
   // Calculate AudioSettings size.
   uint64_t size = EbmlElementSize(libwebm::kMkvSamplingFrequency,
                                   static_cast<float>(sample_rate_));
-  size += EbmlElementSize(libwebm::kMkvChannels, channels_);
+  size +=
+      EbmlElementSize(libwebm::kMkvChannels, static_cast<uint64>(channels_));
   if (bit_depth_ > 0)
-    size += EbmlElementSize(libwebm::kMkvBitDepth, bit_depth_);
+    size +=
+        EbmlElementSize(libwebm::kMkvBitDepth, static_cast<uint64>(bit_depth_));
 
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvAudio, size))
     return false;
 
   const int64_t payload_position = writer->Position();
   if (payload_position < 0)
     return false;
 
   if (!WriteEbmlElement(writer, libwebm::kMkvSamplingFrequency,
                         static_cast<float>(sample_rate_)))
     return false;
-  if (!WriteEbmlElement(writer, libwebm::kMkvChannels, channels_))
+  if (!WriteEbmlElement(writer, libwebm::kMkvChannels,
+                        static_cast<uint64>(channels_)))
     return false;
   if (bit_depth_ > 0)
-    if (!WriteEbmlElement(writer, libwebm::kMkvBitDepth, bit_depth_))
+    if (!WriteEbmlElement(writer, libwebm::kMkvBitDepth,
+                          static_cast<uint64>(bit_depth_)))
       return false;
 
   const int64_t stop_position = writer->Position();
   if (stop_position < 0 ||
       stop_position - payload_position != static_cast<int64_t>(size))
     return false;
 
   return true;
@@ -1392,17 +1702,21 @@ bool AudioTrack::Write(IMkvWriter* write
 ///////////////////////////////////////////////////////////////
 //
 // Tracks Class
 
 const char Tracks::kOpusCodecId[] = "A_OPUS";
 const char Tracks::kVorbisCodecId[] = "A_VORBIS";
 const char Tracks::kVp8CodecId[] = "V_VP8";
 const char Tracks::kVp9CodecId[] = "V_VP9";
-const char Tracks::kAv1CodecId[] = "V_AV1";
+const char Tracks::kVp10CodecId[] = "V_VP10";
+const char Tracks::kWebVttCaptionsId[] = "D_WEBVTT/CAPTIONS";
+const char Tracks::kWebVttDescriptionsId[] = "D_WEBVTT/DESCRIPTIONS";
+const char Tracks::kWebVttMetadataId[] = "D_WEBVTT/METADATA";
+const char Tracks::kWebVttSubtitlesId[] = "D_WEBVTT/SUBTITLES";
 
 Tracks::Tracks()
     : track_entries_(NULL), track_entries_size_(0), wrote_tracks_(false) {}
 
 Tracks::~Tracks() {
   if (track_entries_) {
     for (uint32_t i = 0; i < track_entries_size_; ++i) {
       Track* const track = track_entries_[i];
@@ -1645,19 +1959,21 @@ bool Chapter::ExpandDisplaysArray() {
   displays_size_ = size;
 
   return true;
 }
 
 uint64_t Chapter::WriteAtom(IMkvWriter* writer) const {
   uint64_t payload_size =
       EbmlElementSize(libwebm::kMkvChapterStringUID, id_) +
-      EbmlElementSize(libwebm::kMkvChapterUID, uid_) +
-      EbmlElementSize(libwebm::kMkvChapterTimeStart, start_timecode_) +
-      EbmlElementSize(libwebm::kMkvChapterTimeEnd, end_timecode_);
+      EbmlElementSize(libwebm::kMkvChapterUID, static_cast<uint64>(uid_)) +
+      EbmlElementSize(libwebm::kMkvChapterTimeStart,
+                      static_cast<uint64>(start_timecode_)) +
+      EbmlElementSize(libwebm::kMkvChapterTimeEnd,
+                      static_cast<uint64>(end_timecode_));
 
   for (int idx = 0; idx < displays_count_; ++idx) {
     const Display& d = displays_[idx];
     payload_size += d.WriteDisplay(NULL);
   }
 
   const uint64_t atom_size =
       EbmlMasterElementSize(libwebm::kMkvChapterAtom, payload_size) +
@@ -1669,23 +1985,26 @@ uint64_t Chapter::WriteAtom(IMkvWriter* 
   const int64_t start = writer->Position();
 
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvChapterAtom, payload_size))
     return 0;
 
   if (!WriteEbmlElement(writer, libwebm::kMkvChapterStringUID, id_))
     return 0;
 
-  if (!WriteEbmlElement(writer, libwebm::kMkvChapterUID, uid_))
+  if (!WriteEbmlElement(writer, libwebm::kMkvChapterUID,
+                        static_cast<uint64>(uid_)))
     return 0;
 
-  if (!WriteEbmlElement(writer, libwebm::kMkvChapterTimeStart, start_timecode_))
+  if (!WriteEbmlElement(writer, libwebm::kMkvChapterTimeStart,
+                        static_cast<uint64>(start_timecode_)))
     return 0;
 
-  if (!WriteEbmlElement(writer, libwebm::kMkvChapterTimeEnd, end_timecode_))
+  if (!WriteEbmlElement(writer, libwebm::kMkvChapterTimeEnd,
+                        static_cast<uint64>(end_timecode_)))
     return 0;
 
   for (int idx = 0; idx < displays_count_; ++idx) {
     const Display& d = displays_[idx];
 
     if (!d.WriteDisplay(writer))
       return 0;
   }
@@ -2120,17 +2439,27 @@ Cluster::Cluster(uint64_t timecode, int6
       payload_size_(0),
       position_for_cues_(cues_pos),
       size_position_(-1),
       timecode_(timecode),
       timecode_scale_(timecode_scale),
       write_last_frame_with_duration_(write_last_frame_with_duration),
       writer_(NULL) {}
 
-Cluster::~Cluster() {}
+Cluster::~Cluster() {
+  // Delete any stored frames that are left behind. This will happen if the
+  // Cluster was not Finalized for whatever reason.
+  while (!stored_frames_.empty()) {
+    while (!stored_frames_.begin()->second.empty()) {
+      delete stored_frames_.begin()->second.front();
+      stored_frames_.begin()->second.pop_front();
+    }
+    stored_frames_.erase(stored_frames_.begin()->first);
+  }
+}
 
 bool Cluster::Init(IMkvWriter* ptr_writer) {
   if (!ptr_writer) {
     return false;
   }
   writer_ = ptr_writer;
   return true;
 }
@@ -2416,20 +2745,20 @@ bool SeekHead::Finalize(IMkvWriter* writ
     if (start_pos_ == -1)
       return false;
 
     uint64_t payload_size = 0;
     uint64_t entry_size[kSeekEntryCount];
 
     for (int32_t i = 0; i < kSeekEntryCount; ++i) {
       if (seek_entry_id_[i] != 0) {
-        entry_size[i] = EbmlElementSize(
-            libwebm::kMkvSeekID, static_cast<uint64_t>(seek_entry_id_[i]));
-        entry_size[i] +=
-            EbmlElementSize(libwebm::kMkvSeekPosition, seek_entry_pos_[i]);
+        entry_size[i] = EbmlElementSize(libwebm::kMkvSeekID,
+                                        static_cast<uint64>(seek_entry_id_[i]));
+        entry_size[i] += EbmlElementSize(
+            libwebm::kMkvSeekPosition, static_cast<uint64>(seek_entry_pos_[i]));
 
         payload_size +=
             EbmlMasterElementSize(libwebm::kMkvSeek, entry_size[i]) +
             entry_size[i];
       }
     }
 
     // No SeekHead elements
@@ -2444,21 +2773,21 @@ bool SeekHead::Finalize(IMkvWriter* writ
       return false;
 
     for (int32_t i = 0; i < kSeekEntryCount; ++i) {
       if (seek_entry_id_[i] != 0) {
         if (!WriteEbmlMasterElement(writer, libwebm::kMkvSeek, entry_size[i]))
           return false;
 
         if (!WriteEbmlElement(writer, libwebm::kMkvSeekID,
-                              static_cast<uint64_t>(seek_entry_id_[i])))
+                              static_cast<uint64>(seek_entry_id_[i])))
           return false;
 
         if (!WriteEbmlElement(writer, libwebm::kMkvSeekPosition,
-                              seek_entry_pos_[i]))
+                              static_cast<uint64>(seek_entry_pos_[i])))
           return false;
       }
     }
 
     const uint64_t total_entry_size = kSeekEntryCount * MaxEntrySize();
     const uint64_t total_size =
         EbmlMasterElementSize(libwebm::kMkvSeekHead, total_entry_size) +
         total_entry_size;
@@ -2517,18 +2846,20 @@ bool SeekHead::SetSeekEntry(int index, u
     return false;
   seek_entry_id_[index] = id;
   seek_entry_pos_[index] = position;
   return true;
 }
 
 uint64_t SeekHead::MaxEntrySize() const {
   const uint64_t max_entry_payload_size =
-      EbmlElementSize(libwebm::kMkvSeekID, UINT64_C(0xffffffff)) +
-      EbmlElementSize(libwebm::kMkvSeekPosition, UINT64_C(0xffffffffffffffff));
+      EbmlElementSize(libwebm::kMkvSeekID,
+                      static_cast<uint64>(UINT64_C(0xffffffff))) +
+      EbmlElementSize(libwebm::kMkvSeekPosition,
+                      static_cast<uint64>(UINT64_C(0xffffffffffffffff)));
   const uint64_t max_entry_size =
       EbmlMasterElementSize(libwebm::kMkvSeek, max_entry_payload_size) +
       max_entry_payload_size;
 
   return max_entry_size;
 }
 
 ///////////////////////////////////////////////////////////////
@@ -2608,33 +2939,35 @@ bool SegmentInfo::Finalize(IMkvWriter* w
 
   return true;
 }
 
 bool SegmentInfo::Write(IMkvWriter* writer) {
   if (!writer || !muxing_app_ || !writing_app_)
     return false;
 
-  uint64_t size = EbmlElementSize(libwebm::kMkvTimecodeScale, timecode_scale_);
+  uint64_t size = EbmlElementSize(libwebm::kMkvTimecodeScale,
+                                  static_cast<uint64>(timecode_scale_));
   if (duration_ > 0.0)
     size +=
         EbmlElementSize(libwebm::kMkvDuration, static_cast<float>(duration_));
   if (date_utc_ != LLONG_MIN)
     size += EbmlDateElementSize(libwebm::kMkvDateUTC);
   size += EbmlElementSize(libwebm::kMkvMuxingApp, muxing_app_);
   size += EbmlElementSize(libwebm::kMkvWritingApp, writing_app_);
 
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvInfo, size))
     return false;
 
   const int64_t payload_position = writer->Position();
   if (payload_position < 0)
     return false;
 
-  if (!WriteEbmlElement(writer, libwebm::kMkvTimecodeScale, timecode_scale_))
+  if (!WriteEbmlElement(writer, libwebm::kMkvTimecodeScale,
+                        static_cast<uint64>(timecode_scale_)))
     return false;
 
   if (duration_ > 0.0) {
     // Save for later
     duration_pos_ = writer->Position();
 
     if (!WriteEbmlElement(writer, libwebm::kMkvDuration,
                           static_cast<float>(duration_)))
@@ -2720,20 +3053,22 @@ Segment::Segment()
       last_timestamp_(0),
       max_cluster_duration_(kDefaultMaxClusterDuration),
       max_cluster_size_(0),
       mode_(kFile),
       new_cuepoint_(false),
       output_cues_(true),
       accurate_cluster_duration_(false),
       fixed_size_cluster_timecode_(false),
+      estimate_file_duration_(false),
       payload_pos_(0),
       size_position_(0),
       doc_type_version_(kDefaultDocTypeVersion),
       doc_type_version_written_(0),
+      duration_(0.0),
       writer_cluster_(NULL),
       writer_cues_(NULL),
       writer_header_(NULL) {
   const time_t curr_time = time(NULL);
   seed_ = static_cast<unsigned int>(curr_time);
 #ifdef _WIN32
   srand(seed_);
 #endif
@@ -2828,16 +3163,20 @@ void Segment::MoveCuesBeforeClusters() {
 
 bool Segment::Init(IMkvWriter* ptr_writer) {
   if (!ptr_writer) {
     return false;
   }
   writer_cluster_ = ptr_writer;
   writer_cues_ = ptr_writer;
   writer_header_ = ptr_writer;
+  memset(&track_frames_written_, 0,
+         sizeof(track_frames_written_[0]) * kMaxTrackNumber);
+  memset(&last_track_timestamp_, 0,
+         sizeof(last_track_timestamp_[0]) * kMaxTrackNumber);
   return segment_info_.Init();
 }
 
 bool Segment::CopyAndMoveCuesBeforeClusters(mkvparser::IMkvReader* reader,
                                             IMkvWriter* writer) {
   if (!writer->Seekable() || chunking_)
     return false;
   const int64_t cluster_offset =
@@ -2871,35 +3210,59 @@ bool Segment::CopyAndMoveCuesBeforeClust
     return false;
   return true;
 }
 
 bool Segment::Finalize() {
   if (WriteFramesAll() < 0)
     return false;
 
-  if (cluster_list_size_ > 0) {
+  // In kLive mode, call Cluster::Finalize only if |accurate_cluster_duration_|
+  // is set. In all other modes, always call Cluster::Finalize.
+  if ((mode_ == kLive ? accurate_cluster_duration_ : true) &&
+      cluster_list_size_ > 0) {
     // Update last cluster's size
     Cluster* const old_cluster = cluster_list_[cluster_list_size_ - 1];
 
     // For the last frame of the last Cluster, we don't write it as a BlockGroup
     // with Duration unless the frame itself has duration set explicitly.
     if (!old_cluster || !old_cluster->Finalize(false, 0))
       return false;
   }
 
   if (mode_ == kFile) {
     if (chunking_ && chunk_writer_cluster_) {
       chunk_writer_cluster_->Close();
       chunk_count_++;
     }
 
-    const double duration =
+    double duration =
         (static_cast<double>(last_timestamp_) + last_block_duration_) /
         segment_info_.timecode_scale();
+    if (duration_ > 0.0) {
+      duration = duration_;
+    } else {
+      if (last_block_duration_ == 0 && estimate_file_duration_) {
+        const int num_tracks = static_cast<int>(tracks_.track_entries_size());
+        for (int i = 0; i < num_tracks; ++i) {
+          if (track_frames_written_[i] < 2)
+            continue;
+
+          // Estimate the duration for the last block of a Track.
+          const double nano_per_frame =
+              static_cast<double>(last_track_timestamp_[i]) /
+              (track_frames_written_[i] - 1);
+          const double track_duration =
+              (last_track_timestamp_[i] + nano_per_frame) /
+              segment_info_.timecode_scale();
+          if (track_duration > duration)
+            duration = track_duration;
+        }
+      }
+    }
     segment_info_.set_duration(duration);
     if (!segment_info_.Finalize(writer_header_))
       return false;
 
     if (output_cues_)
       if (!seek_head_.AddSeekEntry(libwebm::kMkvCues, MaxOffset()))
         return false;
 
@@ -2936,17 +3299,19 @@ bool Segment::Finalize() {
         return false;
 
       const int64_t pos = writer_header_->Position();
       UpdateDocTypeVersion();
       if (doc_type_version_ != doc_type_version_written_) {
         if (writer_header_->Position(0))
           return false;
 
-        if (!WriteEbmlHeader(writer_header_, doc_type_version_))
+        const char* const doc_type =
+            DocTypeIsWebm() ? kDocTypeWebm : kDocTypeMatroska;
+        if (!WriteEbmlHeader(writer_header_, doc_type_version_, doc_type))
           return false;
         if (writer_header_->Position() != ebml_header_size_)
           return false;
 
         doc_type_version_written_ = doc_type_version_;
       }
 
       if (writer_header_->Position(size_position_))
@@ -2996,17 +3361,20 @@ uint64_t Segment::AddVideoTrack(int32_t 
   if (!track)
     return 0;
 
   track->set_type(Tracks::kVideo);
   track->set_codec_id(Tracks::kVp8CodecId);
   track->set_width(width);
   track->set_height(height);
 
-  tracks_.AddTrack(track, number);
+  if (!tracks_.AddTrack(track, number)) {
+    delete track;
+    return 0;
+  }
   has_video_ = true;
 
   return track->number();
 }
 
 bool Segment::AddCuePoint(uint64_t timestamp, uint64_t track) {
   if (cluster_list_size_ < 1)
     return false;
@@ -3018,35 +3386,40 @@ bool Segment::AddCuePoint(uint64_t times
   CuePoint* const cue = new (std::nothrow) CuePoint();  // NOLINT
   if (!cue)
     return false;
 
   cue->set_time(timestamp / segment_info_.timecode_scale());
   cue->set_block_number(cluster->blocks_added());
   cue->set_cluster_pos(cluster->position_for_cues());
   cue->set_track(track);
-  if (!cues_.AddCue(cue))
+  if (!cues_.AddCue(cue)) {
+    delete cue;
     return false;
+  }
 
   new_cuepoint_ = false;
   return true;
 }
 
 uint64_t Segment::AddAudioTrack(int32_t sample_rate, int32_t channels,
                                 int32_t number) {
   AudioTrack* const track = new (std::nothrow) AudioTrack(&seed_);  // NOLINT
   if (!track)
     return 0;
 
   track->set_type(Tracks::kAudio);
   track->set_codec_id(Tracks::kVorbisCodecId);
   track->set_sample_rate(sample_rate);
   track->set_channels(channels);
 
-  tracks_.AddTrack(track, number);
+  if (!tracks_.AddTrack(track, number)) {
+    delete track;
+    return 0;
+  }
 
   return track->number();
 }
 
 bool Segment::AddFrame(const uint8_t* data, uint64_t length,
                        uint64_t track_number, uint64_t timestamp, bool is_key) {
   if (!data)
     return false;
@@ -3125,25 +3498,45 @@ bool Segment::AddGenericFrame(const Fram
 
   // Check if the track number is valid.
   if (!tracks_.GetTrackByNumber(frame->track_number()))
     return false;
 
   if (frame->discard_padding() != 0)
     doc_type_version_ = 4;
 
+  if (cluster_list_size_ > 0) {
+    const uint64_t timecode_scale = segment_info_.timecode_scale();
+    const uint64_t frame_timecode = frame->timestamp() / timecode_scale;
+
+    const Cluster* const last_cluster = cluster_list_[cluster_list_size_ - 1];
+    const uint64_t last_cluster_timecode = last_cluster->timecode();
+
+    const uint64_t rel_timecode = frame_timecode - last_cluster_timecode;
+    if (rel_timecode > kMaxBlockTimecode) {
+      force_new_cluster_ = true;
+    }
+  }
+
   // If the segment has a video track hold onto audio frames to make sure the
   // audio that is associated with the start time of a video key-frame is
   // muxed into the same cluster.
   if (has_video_ && tracks_.TrackIsAudio(frame->track_number()) &&
       !force_new_cluster_) {
     Frame* const new_frame = new (std::nothrow) Frame();
-    if (!new_frame || !new_frame->CopyFrom(*frame))
+    if (!new_frame || !new_frame->CopyFrom(*frame)) {
+      delete new_frame;
       return false;
-    return QueueFrame(new_frame);
+    }
+    if (!QueueFrame(new_frame)) {
+      delete new_frame;
+      return false;
+    }
+    track_frames_written_[frame->track_number() - 1]++;
+    return true;
   }
 
   if (!DoNewClusterProcessing(frame->track_number(), frame->timestamp(),
                               frame->is_key())) {
     return false;
   }
 
   if (cluster_list_size_ < 1)
@@ -3154,18 +3547,20 @@ bool Segment::AddGenericFrame(const Fram
     return false;
 
   // If the Frame is not a SimpleBlock, then set the reference_block_timestamp
   // if it is not set already.
   bool frame_created = false;
   if (!frame->CanBeSimpleBlock() && !frame->is_key() &&
       !frame->reference_block_timestamp_set()) {
     Frame* const new_frame = new (std::nothrow) Frame();
-    if (!new_frame->CopyFrom(*frame))
+    if (!new_frame || !new_frame->CopyFrom(*frame)) {
+      delete new_frame;
       return false;
+    }
     new_frame->set_reference_block_timestamp(
         last_track_timestamp_[frame->track_number() - 1]);
     frame = new_frame;
     frame_created = true;
   }
 
   if (!cluster->AddFrame(frame))
     return false;
@@ -3173,20 +3568,20 @@ bool Segment::AddGenericFrame(const Fram
   if (new_cuepoint_ && cues_track_ == frame->track_number()) {
     if (!AddCuePoint(frame->timestamp(), cues_track_))
       return false;
   }
 
   last_timestamp_ = frame->timestamp();
   last_track_timestamp_[frame->track_number() - 1] = frame->timestamp();
   last_block_duration_ = frame->duration();
+  track_frames_written_[frame->track_number() - 1]++;
 
   if (frame_created)
     delete frame;
-
   return true;
 }
 
 void Segment::OutputCues(bool output_cues) { output_cues_ = output_cues; }
 
 void Segment::AccurateClusterDuration(bool accurate_cluster_duration) {
   accurate_cluster_duration_ = accurate_cluster_duration;
 }
@@ -3287,18 +3682,19 @@ void Segment::ForceNewClusterOnNextFrame
 
 Track* Segment::GetTrackByNumber(uint64_t track_number) const {
   return tracks_.GetTrackByNumber(track_number);
 }
 
 bool Segment::WriteSegmentHeader() {
   UpdateDocTypeVersion();
 
-  // TODO(fgalligan): Support more than one segment.
-  if (!WriteEbmlHeader(writer_header_, doc_type_version_))
+  const char* const doc_type =
+      DocTypeIsWebm() ? kDocTypeWebm : kDocTypeMatroska;
+  if (!WriteEbmlHeader(writer_header_, doc_type_version_, doc_type))
     return false;
   doc_type_version_written_ = doc_type_version_;
   ebml_header_size_ = static_cast<int32_t>(writer_header_->Position());
 
   // Write "unknown" (-1) as segment size value. If mode is kFile, Segment
   // will write over duration when the file is finalized.
   if (WriteID(writer_header_, libwebm::kMkvSegment))
     return false;
@@ -3761,9 +4157,40 @@ bool Segment::WriteFramesLessThan(uint64
 
       frames_size_ = new_frames_size;
     }
   }
 
   return true;
 }
 
+bool Segment::DocTypeIsWebm() const {
+  const int kNumCodecIds = 9;
+
+  // TODO(vigneshv): Tweak .clang-format.
+  const char* kWebmCodecIds[kNumCodecIds] = {
+      Tracks::kOpusCodecId,          Tracks::kVorbisCodecId,
+      Tracks::kVp8CodecId,           Tracks::kVp9CodecId,
+      Tracks::kVp10CodecId,          Tracks::kWebVttCaptionsId,
+      Tracks::kWebVttDescriptionsId, Tracks::kWebVttMetadataId,
+      Tracks::kWebVttSubtitlesId};
+
+  const int num_tracks = static_cast<int>(tracks_.track_entries_size());
+  for (int track_index = 0; track_index < num_tracks; ++track_index) {
+    const Track* const track = tracks_.GetTrackByIndex(track_index);
+    const std::string codec_id = track->codec_id();
+
+    bool id_is_webm = false;
+    for (int id_index = 0; id_index < kNumCodecIds; ++id_index) {
+      if (codec_id == kWebmCodecIds[id_index]) {
+        id_is_webm = true;
+        break;
+      }
+    }
+
+    if (!id_is_webm)
+      return false;
+  }
+
+  return true;
+}
+
 }  // namespace mkvmuxer
--- a/third_party/aom/third_party/libwebm/mkvmuxer/mkvmuxer.h
+++ b/third_party/aom/third_party/libwebm/mkvmuxer/mkvmuxer.h
@@ -59,16 +59,22 @@ class IMkvWriter {
  protected:
   IMkvWriter();
   virtual ~IMkvWriter();
 
  private:
   LIBWEBM_DISALLOW_COPY_AND_ASSIGN(IMkvWriter);
 };
 
+// Writes out the EBML header for a WebM file, but allows caller to specify
+// DocType. This function must be called before any other libwebm writing
+// functions are called.
+bool WriteEbmlHeader(IMkvWriter* writer, uint64_t doc_type_version,
+                     const char* const doc_type);
+
 // Writes out the EBML header for a WebM file. This function must be called
 // before any other libwebm writing functions are called.
 bool WriteEbmlHeader(IMkvWriter* writer, uint64_t doc_type_version);
 
 // Deprecated. Writes out EBML header with doc_type_version as
 // kDefaultDocTypeVersion. Exists for backward compatibility.
 bool WriteEbmlHeader(IMkvWriter* writer);
 
@@ -343,127 +349,313 @@ class ContentEncoding {
   // Size of the ContentEncKeyID data in bytes.
   uint64_t enc_key_id_length_;
 
   LIBWEBM_DISALLOW_COPY_AND_ASSIGN(ContentEncoding);
 };
 
 ///////////////////////////////////////////////////////////////
 // Colour element.
-struct PrimaryChromaticity {
-  PrimaryChromaticity(float x_val, float y_val) : x(x_val), y(y_val) {}
-  PrimaryChromaticity() : x(0), y(0) {}
+class PrimaryChromaticity {
+ public:
+  static const float kChromaticityMin;
+  static const float kChromaticityMax;
+
+  PrimaryChromaticity(float x_val, float y_val) : x_(x_val), y_(y_val) {}
+  PrimaryChromaticity() : x_(0), y_(0) {}
   ~PrimaryChromaticity() {}
-  uint64_t PrimaryChromaticityPayloadSize(libwebm::MkvId x_id,
-                                          libwebm::MkvId y_id) const;
+
+  // Returns sum of |x_id| and |y_id| element id sizes and payload sizes.
+  uint64_t PrimaryChromaticitySize(libwebm::MkvId x_id,
+                                   libwebm::MkvId y_id) const;
+  bool Valid() const;
   bool Write(IMkvWriter* writer, libwebm::MkvId x_id,
              libwebm::MkvId y_id) const;
 
-  float x;
-  float y;
+  float x() const { return x_; }
+  void set_x(float new_x) { x_ = new_x; }
+  float y() const { return y_; }
+  void set_y(float new_y) { y_ = new_y; }
+
+ private:
+  float x_;
+  float y_;
 };
 
 class MasteringMetadata {
  public:
   static const float kValueNotPresent;
+  static const float kMinLuminance;
+  static const float kMinLuminanceMax;
+  static const float kMaxLuminanceMax;
 
   MasteringMetadata()
-      : luminance_max(kValueNotPresent),
-        luminance_min(kValueNotPresent),
+      : luminance_max_(kValueNotPresent),
+        luminance_min_(kValueNotPresent),
         r_(NULL),
         g_(NULL),
         b_(NULL),
         white_point_(NULL) {}
   ~MasteringMetadata() {
     delete r_;
     delete g_;
     delete b_;
     delete white_point_;
   }
 
   // Returns total size of the MasteringMetadata element.
   uint64_t MasteringMetadataSize() const;
+  bool Valid() const;
   bool Write(IMkvWriter* writer) const;
 
   // Copies non-null chromaticity.
   bool SetChromaticity(const PrimaryChromaticity* r,
                        const PrimaryChromaticity* g,
                        const PrimaryChromaticity* b,
                        const PrimaryChromaticity* white_point);
   const PrimaryChromaticity* r() const { return r_; }
   const PrimaryChromaticity* g() const { return g_; }
   const PrimaryChromaticity* b() const { return b_; }
   const PrimaryChromaticity* white_point() const { return white_point_; }
 
-  float luminance_max;
-  float luminance_min;
+  float luminance_max() const { return luminance_max_; }
+  void set_luminance_max(float luminance_max) {
+    luminance_max_ = luminance_max;
+  }
+  float luminance_min() const { return luminance_min_; }
+  void set_luminance_min(float luminance_min) {
+    luminance_min_ = luminance_min;
+  }
 
  private:
   // Returns size of MasteringMetadata child elements.
   uint64_t PayloadSize() const;
 
+  float luminance_max_;
+  float luminance_min_;
   PrimaryChromaticity* r_;
   PrimaryChromaticity* g_;
   PrimaryChromaticity* b_;
   PrimaryChromaticity* white_point_;
 };
 
 class Colour {
  public:
+  enum MatrixCoefficients {
+    kGbr = 0,
+    kBt709 = 1,
+    kUnspecifiedMc = 2,
+    kReserved = 3,
+    kFcc = 4,
+    kBt470bg = 5,
+    kSmpte170MMc = 6,
+    kSmpte240MMc = 7,
+    kYcocg = 8,
+    kBt2020NonConstantLuminance = 9,
+    kBt2020ConstantLuminance = 10,
+  };
+  enum ChromaSitingHorz {
+    kUnspecifiedCsh = 0,
+    kLeftCollocated = 1,
+    kHalfCsh = 2,
+  };
+  enum ChromaSitingVert {
+    kUnspecifiedCsv = 0,
+    kTopCollocated = 1,
+    kHalfCsv = 2,
+  };
+  enum Range {
+    kUnspecifiedCr = 0,
+    kBroadcastRange = 1,
+    kFullRange = 2,
+    kMcTcDefined = 3,  // Defined by MatrixCoefficients/TransferCharacteristics.
+  };
+  enum TransferCharacteristics {
+    kIturBt709Tc = 1,
+    kUnspecifiedTc = 2,
+    kReservedTc = 3,
+    kGamma22Curve = 4,
+    kGamma28Curve = 5,
+    kSmpte170MTc = 6,
+    kSmpte240MTc = 7,
+    kLinear = 8,
+    kLog = 9,
+    kLogSqrt = 10,
+    kIec6196624 = 11,
+    kIturBt1361ExtendedColourGamut = 12,
+    kIec6196621 = 13,
+    kIturBt202010bit = 14,
+    kIturBt202012bit = 15,
+    kSmpteSt2084 = 16,
+    kSmpteSt4281Tc = 17,
+    kAribStdB67Hlg = 18,
+  };
+  enum Primaries {
+    kReservedP0 = 0,
+    kIturBt709P = 1,
+    kUnspecifiedP = 2,
+    kReservedP3 = 3,
+    kIturBt470M = 4,
+    kIturBt470Bg = 5,
+    kSmpte170MP = 6,
+    kSmpte240MP = 7,
+    kFilm = 8,
+    kIturBt2020 = 9,
+    kSmpteSt4281P = 10,
+    kJedecP22Phosphors = 22,
+  };
   static const uint64_t kValueNotPresent;
   Colour()
-      : matrix_coefficients(kValueNotPresent),
-        bits_per_channel(kValueNotPresent),
-        chroma_subsampling_horz(kValueNotPresent),
-        chroma_subsampling_vert(kValueNotPresent),
-        cb_subsampling_horz(kValueNotPresent),
-        cb_subsampling_vert(kValueNotPresent),
-        chroma_siting_horz(kValueNotPresent),
-        chroma_siting_vert(kValueNotPresent),
-        range(kValueNotPresent),
-        transfer_characteristics(kValueNotPresent),
-        primaries(kValueNotPresent),
-        max_cll(kValueNotPresent),
-        max_fall(kValueNotPresent),
+      : matrix_coefficients_(kValueNotPresent),
+        bits_per_channel_(kValueNotPresent),
+        chroma_subsampling_horz_(kValueNotPresent),
+        chroma_subsampling_vert_(kValueNotPresent),
+        cb_subsampling_horz_(kValueNotPresent),
+        cb_subsampling_vert_(kValueNotPresent),
+        chroma_siting_horz_(kValueNotPresent),
+        chroma_siting_vert_(kValueNotPresent),
+        range_(kValueNotPresent),
+        transfer_characteristics_(kValueNotPresent),
+        primaries_(kValueNotPresent),
+        max_cll_(kValueNotPresent),
+        max_fall_(kValueNotPresent),
         mastering_metadata_(NULL) {}
   ~Colour() { delete mastering_metadata_; }
 
   // Returns total size of the Colour element.
   uint64_t ColourSize() const;
+  bool Valid() const;
   bool Write(IMkvWriter* writer) const;
 
   // Deep copies |mastering_metadata|.
   bool SetMasteringMetadata(const MasteringMetadata& mastering_metadata);
 
   const MasteringMetadata* mastering_metadata() const {
     return mastering_metadata_;
   }
 
-  uint64_t matrix_coefficients;
-  uint64_t bits_per_channel;
-  uint64_t chroma_subsampling_horz;
-  uint64_t chroma_subsampling_vert;
-  uint64_t cb_subsampling_horz;
-  uint64_t cb_subsampling_vert;
-  uint64_t chroma_siting_horz;
-  uint64_t chroma_siting_vert;
-  uint64_t range;
-  uint64_t transfer_characteristics;
-  uint64_t primaries;
-  uint64_t max_cll;
-  uint64_t max_fall;
+  uint64_t matrix_coefficients() const { return matrix_coefficients_; }
+  void set_matrix_coefficients(uint64_t matrix_coefficients) {
+    matrix_coefficients_ = matrix_coefficients;
+  }
+  uint64_t bits_per_channel() const { return bits_per_channel_; }
+  void set_bits_per_channel(uint64_t bits_per_channel) {
+    bits_per_channel_ = bits_per_channel;
+  }
+  uint64_t chroma_subsampling_horz() const { return chroma_subsampling_horz_; }
+  void set_chroma_subsampling_horz(uint64_t chroma_subsampling_horz) {
+    chroma_subsampling_horz_ = chroma_subsampling_horz;
+  }
+  uint64_t chroma_subsampling_vert() const { return chroma_subsampling_vert_; }
+  void set_chroma_subsampling_vert(uint64_t chroma_subsampling_vert) {
+    chroma_subsampling_vert_ = chroma_subsampling_vert;
+  }
+  uint64_t cb_subsampling_horz() const { return cb_subsampling_horz_; }
+  void set_cb_subsampling_horz(uint64_t cb_subsampling_horz) {
+    cb_subsampling_horz_ = cb_subsampling_horz;
+  }
+  uint64_t cb_subsampling_vert() const { return cb_subsampling_vert_; }
+  void set_cb_subsampling_vert(uint64_t cb_subsampling_vert) {
+    cb_subsampling_vert_ = cb_subsampling_vert;
+  }
+  uint64_t chroma_siting_horz() const { return chroma_siting_horz_; }
+  void set_chroma_siting_horz(uint64_t chroma_siting_horz) {
+    chroma_siting_horz_ = chroma_siting_horz;
+  }
+  uint64_t chroma_siting_vert() const { return chroma_siting_vert_; }
+  void set_chroma_siting_vert(uint64_t chroma_siting_vert) {
+    chroma_siting_vert_ = chroma_siting_vert;
+  }
+  uint64_t range() const { return range_; }
+  void set_range(uint64_t range) { range_ = range; }
+  uint64_t transfer_characteristics() const {
+    return transfer_characteristics_;
+  }
+  void set_transfer_characteristics(uint64_t transfer_characteristics) {
+    transfer_characteristics_ = transfer_characteristics;
+  }
+  uint64_t primaries() const { return primaries_; }
+  void set_primaries(uint64_t primaries) { primaries_ = primaries; }
+  uint64_t max_cll() const { return max_cll_; }
+  void set_max_cll(uint64_t max_cll) { max_cll_ = max_cll; }
+  uint64_t max_fall() const { return max_fall_; }
+  void set_max_fall(uint64_t max_fall) { max_fall_ = max_fall; }
 
  private:
   // Returns size of Colour child elements.
   uint64_t PayloadSize() const;
 
+  uint64_t matrix_coefficients_;
+  uint64_t bits_per_channel_;
+  uint64_t chroma_subsampling_horz_;
+  uint64_t chroma_subsampling_vert_;
+  uint64_t cb_subsampling_horz_;
+  uint64_t cb_subsampling_vert_;
+  uint64_t chroma_siting_horz_;
+  uint64_t chroma_siting_vert_;
+  uint64_t range_;
+  uint64_t transfer_characteristics_;
+  uint64_t primaries_;
+  uint64_t max_cll_;
+  uint64_t max_fall_;
+
   MasteringMetadata* mastering_metadata_;
 };
 
 ///////////////////////////////////////////////////////////////
+// Projection element.
+class Projection {
+ public:
+  enum ProjectionType {
+    kTypeNotPresent = -1,
+    kRectangular = 0,
+    kEquirectangular = 1,
+    kCubeMap = 2,
+    kMesh = 3,
+  };
+  static const uint64_t kValueNotPresent;
+  Projection()
+      : type_(kRectangular),
+        pose_yaw_(0.0),
+        pose_pitch_(0.0),
+        pose_roll_(0.0),
+        private_data_(NULL),
+        private_data_length_(0) {}
+  ~Projection() { delete[] private_data_; }
+
+  uint64_t ProjectionSize() const;
+  bool Write(IMkvWriter* writer) const;
+
+  bool SetProjectionPrivate(const uint8_t* private_data,
+                            uint64_t private_data_length);
+
+  ProjectionType type() const { return type_; }
+  void set_type(ProjectionType type) { type_ = type; }
+  float pose_yaw() const { return pose_yaw_; }
+  void set_pose_yaw(float pose_yaw) { pose_yaw_ = pose_yaw; }
+  float pose_pitch() const { return pose_pitch_; }
+  void set_pose_pitch(float pose_pitch) { pose_pitch_ = pose_pitch; }
+  float pose_roll() const { return pose_roll_; }
+  void set_pose_roll(float pose_roll) { pose_roll_ = pose_roll; }
+  uint8_t* private_data() const { return private_data_; }
+  uint64_t private_data_length() const { return private_data_length_; }
+
+ private:
+  // Returns size of VideoProjection child elements.
+  uint64_t PayloadSize() const;
+
+  ProjectionType type_;
+  float pose_yaw_;
+  float pose_pitch_;
+  float pose_roll_;
+  uint8_t* private_data_;
+  uint64_t private_data_length_;
+};
+
+///////////////////////////////////////////////////////////////
 // Track element.
 class Track {
  public:
   // The |seed| parameter is used to synthesize a UID for the track.
   explicit Track(unsigned int* seed);
   virtual ~Track();
 
   // Adds a ContentEncoding element to the Track. Returns true on success.
@@ -576,16 +768,20 @@ class VideoTrack : public Track {
 
   // Sets the video's alpha mode. Returns true on success.
   bool SetAlphaMode(uint64_t alpha_mode);
 
   void set_display_height(uint64_t height) { display_height_ = height; }
   uint64_t display_height() const { return display_height_; }
   void set_display_width(uint64_t width) { display_width_ = width; }
   uint64_t display_width() const { return display_width_; }
+  void set_pixel_height(uint64_t height) { pixel_height_ = height; }
+  uint64_t pixel_height() const { return pixel_height_; }
+  void set_pixel_width(uint64_t width) { pixel_width_ = width; }
+  uint64_t pixel_width() const { return pixel_width_; }
 
   void set_crop_left(uint64_t crop_left) { crop_left_ = crop_left; }
   uint64_t crop_left() const { return crop_left_; }
   void set_crop_right(uint64_t crop_right) { crop_right_ = crop_right; }
   uint64_t crop_right() const { return crop_right_; }
   void set_crop_top(uint64_t crop_top) { crop_top_ = crop_top; }
   uint64_t crop_top() const { return crop_top_; }
   void set_crop_bottom(uint64_t crop_bottom) { crop_bottom_ = crop_bottom; }
@@ -600,34 +796,42 @@ class VideoTrack : public Track {
   void set_width(uint64_t width) { width_ = width; }
   uint64_t width() const { return width_; }
 
   Colour* colour() { return colour_; }
 
   // Deep copies |colour|.
   bool SetColour(const Colour& colour);
 
+  Projection* projection() { return projection_; }
+
+  // Deep copies |projection|.
+  bool SetProjection(const Projection& projection);
+
  private:
   // Returns the size in bytes of the Video element.
   uint64_t VideoPayloadSize() const;
 
   // Video track element names.
   uint64_t display_height_;
   uint64_t display_width_;
+  uint64_t pixel_height_;
+  uint64_t pixel_width_;
   uint64_t crop_left_;
   uint64_t crop_right_;
   uint64_t crop_top_;
   uint64_t crop_bottom_;
   double frame_rate_;
   uint64_t height_;
   uint64_t stereo_mode_;
   uint64_t alpha_mode_;
   uint64_t width_;
 
   Colour* colour_;
+  Projection* projection_;
 
   LIBWEBM_DISALLOW_COPY_AND_ASSIGN(VideoTrack);
 };
 
 ///////////////////////////////////////////////////////////////
 // Track that has audio specific elements.
 class AudioTrack : public Track {
  public:
@@ -664,17 +868,21 @@ class Tracks {
  public:
   // Audio and video type defined by the Matroska specs.
   enum { kVideo = 0x1, kAudio = 0x2 };
 
   static const char kOpusCodecId[];
   static const char kVorbisCodecId[];
   static const char kVp8CodecId[];
   static const char kVp9CodecId[];
-  static const char kAv1CodecId[];
+  static const char kVp10CodecId[];
+  static const char kWebVttCaptionsId[];
+  static const char kWebVttDescriptionsId[];
+  static const char kWebVttMetadataId[];
+  static const char kWebVttSubtitlesId[];
 
   Tracks();
   ~Tracks();
 
   // Adds a Track element to the Tracks object. |track| will be owned and
   // deleted by the Tracks object. Returns true on success. |number| is the
   // number to use for the track. |number| must be >= 0. If |number| == 0
   // then the muxer will decide on the track number.
@@ -1289,18 +1497,18 @@ class Segment {
  public:
   enum Mode { kLive = 0x1, kFile = 0x2 };
 
   enum CuesPosition {
     kAfterClusters = 0x0,  // Position Cues after Clusters - Default
     kBeforeClusters = 0x1  // Position Cues before Clusters
   };
 
-  const static uint32_t kDefaultDocTypeVersion = 2;
-  const static uint64_t kDefaultMaxClusterDuration = 30000000000ULL;
+  static const uint32_t kDefaultDocTypeVersion = 4;
+  static const uint64_t kDefaultMaxClusterDuration = 30000000000ULL;
 
   Segment();
   ~Segment();
 
   // Initializes |SegmentInfo| and returns result. Always returns false when
   // |ptr_writer| is NULL.
   bool Init(IMkvWriter* ptr_writer);
 
@@ -1476,17 +1684,26 @@ class Segment {
   void set_max_cluster_size(uint64_t max_cluster_size) {
     max_cluster_size_ = max_cluster_size;
   }
   uint64_t max_cluster_size() const { return max_cluster_size_; }
   void set_mode(Mode mode) { mode_ = mode; }
   Mode mode() const { return mode_; }
   CuesPosition cues_position() const { return cues_position_; }
   bool output_cues() const { return output_cues_; }
+  void set_estimate_file_duration(bool estimate_duration) {
+    estimate_file_duration_ = estimate_duration;
+  }
+  bool estimate_file_duration() const { return estimate_file_duration_; }
   const SegmentInfo* segment_info() const { return &segment_info_; }
+  void set_duration(double duration) { duration_ = duration; }
+  double duration() const { return duration_; }
+
+  // Returns true when codec IDs are valid for WebM.
+  bool DocTypeIsWebm() const;
 
  private:
   // Checks if header information has been output and initialized. If not it
   // will output the Segment element and initialize the SeekHead elment and
   // Cues elements.
   bool CheckHeaderInfo();
 
   // Sets |doc_type_version_| based on the current element requirements.
@@ -1632,16 +1849,19 @@ class Segment {
   uint64_t last_block_duration_;
 
   // Last timestamp in nanoseconds added to a cluster.
   uint64_t last_timestamp_;
 
   // Last timestamp in nanoseconds by track number added to a cluster.
   uint64_t last_track_timestamp_[kMaxTrackNumber];
 
+  // Number of frames written per track.
+  uint64_t track_frames_written_[kMaxTrackNumber];
+
   // Maximum time in nanoseconds for a cluster duration. This variable is a
   // guideline and some clusters may have a longer duration. Default is 30
   // seconds.
   uint64_t max_cluster_duration_;
 
   // Maximum size in bytes for a cluster. This variable is a guideline and
   // some clusters may have a larger size. Default is 0 which signifies that
   // the muxer will decide the size.
@@ -1660,16 +1880,19 @@ class Segment {
 
   // Flag whether or not the last frame in each Cluster will have a Duration
   // element in it.
   bool accurate_cluster_duration_;
 
   // Flag whether or not to write the Cluster Timecode using exactly 8 bytes.
   bool fixed_size_cluster_timecode_;
 
+  // Flag whether or not to estimate the file duration.
+  bool estimate_file_duration_;
+
   // The size of the EBML header, used to validate the header if
   // WriteEbmlHeader() is called more than once.
   int32_t ebml_header_size_;
 
   // The file position of the segment's payload.
   int64_t payload_pos_;
 
   // The file position of the element's size.
@@ -1677,16 +1900,19 @@ class Segment {
 
   // Current DocTypeVersion (|doc_type_version_|) and that written in
   // WriteSegmentHeader().
   // WriteEbmlHeader() will be called from Finalize() if |doc_type_version_|
   // differs from |doc_type_version_written_|.
   uint32_t doc_type_version_;
   uint32_t doc_type_version_written_;
 
+  // If |duration_| is > 0, then explicitly set the duration of the segment.
+  double duration_;
+
   // Pointer to the writer objects. Not owned by this class.
   IMkvWriter* writer_cluster_;
   IMkvWriter* writer_cues_;
   IMkvWriter* writer_header_;
 
   LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Segment);
 };
 
--- a/third_party/aom/third_party/libwebm/mkvmuxer/mkvmuxerutil.cc
+++ b/third_party/aom/third_party/libwebm/mkvmuxer/mkvmuxerutil.cc
@@ -26,69 +26,70 @@
 
 namespace mkvmuxer {
 
 namespace {
 
 // Date elements are always 8 octets in size.
 const int kDateElementSize = 8;
 
-uint64_t WriteBlock(IMkvWriter* writer, const Frame* const frame,
-                    int64_t timecode, uint64_t timecode_scale) {
-  uint64_t block_additional_elem_size = 0;
-  uint64_t block_addid_elem_size = 0;
-  uint64_t block_more_payload_size = 0;
-  uint64_t block_more_elem_size = 0;
-  uint64_t block_additions_payload_size = 0;
-  uint64_t block_additions_elem_size = 0;
+uint64 WriteBlock(IMkvWriter* writer, const Frame* const frame, int64 timecode,
+                  uint64 timecode_scale) {
+  uint64 block_additional_elem_size = 0;
+  uint64 block_addid_elem_size = 0;
+  uint64 block_more_payload_size = 0;
+  uint64 block_more_elem_size = 0;
+  uint64 block_additions_payload_size = 0;
+  uint64 block_additions_elem_size = 0;
   if (frame->additional()) {
     block_additional_elem_size =
         EbmlElementSize(libwebm::kMkvBlockAdditional, frame->additional(),
                         frame->additional_length());
-    block_addid_elem_size =
-        EbmlElementSize(libwebm::kMkvBlockAddID, frame->add_id());
+    block_addid_elem_size = EbmlElementSize(
+        libwebm::kMkvBlockAddID, static_cast<uint64>(frame->add_id()));
 
     block_more_payload_size =
         block_addid_elem_size + block_additional_elem_size;
     block_more_elem_size =
         EbmlMasterElementSize(libwebm::kMkvBlockMore, block_more_payload_size) +
         block_more_payload_size;
     block_additions_payload_size = block_more_elem_size;
     block_additions_elem_size =
         EbmlMasterElementSize(libwebm::kMkvBlockAdditions,
                               block_additions_payload_size) +
         block_additions_payload_size;
   }
 
-  uint64_t discard_padding_elem_size = 0;
+  uint64 discard_padding_elem_size = 0;
   if (frame->discard_padding() != 0) {
     discard_padding_elem_size =
-        EbmlElementSize(libwebm::kMkvDiscardPadding, frame->discard_padding());
+        EbmlElementSize(libwebm::kMkvDiscardPadding,
+                        static_cast<int64>(frame->discard_padding()));
   }
 
-  const uint64_t reference_block_timestamp =
+  const uint64 reference_block_timestamp =
       frame->reference_block_timestamp() / timecode_scale;
-  uint64_t reference_block_elem_size = 0;
+  uint64 reference_block_elem_size = 0;
   if (!frame->is_key()) {
     reference_block_elem_size =
         EbmlElementSize(libwebm::kMkvReferenceBlock, reference_block_timestamp);
   }
 
-  const uint64_t duration = frame->duration() / timecode_scale;
-  uint64_t block_duration_elem_size = 0;
+  const uint64 duration = frame->duration() / timecode_scale;
+  uint64 block_duration_elem_size = 0;
   if (duration > 0)
     block_duration_elem_size =
         EbmlElementSize(libwebm::kMkvBlockDuration, duration);
 
-  const uint64_t block_payload_size = 4 + frame->length();
-  const uint64_t block_elem_size =
+  const uint64 block_payload_size = 4 + frame->length();
+  const uint64 block_elem_size =
       EbmlMasterElementSize(libwebm::kMkvBlock, block_payload_size) +
       block_payload_size;
 
-  const uint64_t block_group_payload_size =
+  const uint64 block_group_payload_size =
       block_elem_size + block_additions_elem_size + block_duration_elem_size +
       discard_padding_elem_size + reference_block_elem_size;
 
   if (!WriteEbmlMasterElement(writer, libwebm::kMkvBlockGroup,
                               block_group_payload_size)) {
     return 0;
   }
 
@@ -100,41 +101,42 @@ uint64_t WriteBlock(IMkvWriter* writer, 
 
   if (SerializeInt(writer, timecode, 2))
     return 0;
 
   // For a Block, flags is always 0.
   if (SerializeInt(writer, 0, 1))
     return 0;
 
-  if (writer->Write(frame->frame(), static_cast<uint32_t>(frame->length())))
+  if (writer->Write(frame->frame(), static_cast<uint32>(frame->length())))
     return 0;
 
   if (frame->additional()) {
     if (!WriteEbmlMasterElement(writer, libwebm::kMkvBlockAdditions,
                                 block_additions_payload_size)) {
       return 0;
     }
 
     if (!WriteEbmlMasterElement(writer, libwebm::kMkvBlockMore,
                                 block_more_payload_size))
       return 0;
 
-    if (!WriteEbmlElement(writer, libwebm::kMkvBlockAddID, frame->add_id()))
+    if (!WriteEbmlElement(writer, libwebm::kMkvBlockAddID,
+                          static_cast<uint64>(frame->add_id())))
       return 0;
 
     if (!WriteEbmlElement(writer, libwebm::kMkvBlockAdditional,
                           frame->additional(), frame->additional_length())) {
       return 0;
     }
   }
 
   if (frame->discard_padding() != 0 &&
       !WriteEbmlElement(writer, libwebm::kMkvDiscardPadding,
-                        frame->discard_padding())) {
+                        static_cast<int64>(frame->discard_padding()))) {
     return false;
   }
 
   if (!frame->is_key() &&
       !WriteEbmlElement(writer, libwebm::kMkvReferenceBlock,
                         reference_block_timestamp)) {
     return false;
   }
@@ -143,48 +145,48 @@ uint64_t WriteBlock(IMkvWriter* writer, 
       !WriteEbmlElement(writer, libwebm::kMkvBlockDuration, duration)) {
     return false;
   }
   return EbmlMasterElementSize(libwebm::kMkvBlockGroup,
                                block_group_payload_size) +
          block_group_payload_size;
 }
 
-uint64_t WriteSimpleBlock(IMkvWriter* writer, const Frame* const frame,
-                          int64_t timecode) {
+uint64 WriteSimpleBlock(IMkvWriter* writer, const Frame* const frame,
+                        int64 timecode) {
   if (WriteID(writer, libwebm::kMkvSimpleBlock))
     return 0;
 
-  const int32_t size = static_cast<int32_t>(frame->length()) + 4;
+  const int32 size = static_cast<int32>(frame->length()) + 4;
   if (WriteUInt(writer, size))
     return 0;
 
-  if (WriteUInt(writer, static_cast<uint64_t>(frame->track_number())))
+  if (WriteUInt(writer, static_cast<uint64>(frame->track_number())))
     return 0;
 
   if (SerializeInt(writer, timecode, 2))
     return 0;
 
-  uint64_t flags = 0;
+  uint64 flags = 0;
   if (frame->is_key())
     flags |= 0x80;
 
   if (SerializeInt(writer, flags, 1))
     return 0;
 
-  if (writer->Write(frame->frame(), static_cast<uint32_t>(frame->length())))
+  if (writer->Write(frame->frame(), static_cast<uint32>(frame->length())))
     return 0;
 
-  return static_cast<uint64_t>(GetUIntSize(libwebm::kMkvSimpleBlock) +
-                               GetCodedUIntSize(size) + 4 + frame->length());
+  return GetUIntSize(libwebm::kMkvSimpleBlock) + GetCodedUIntSize(size) + 4 +
+         frame->length();
 }
 
 }  // namespace
 
-int32_t GetCodedUIntSize(uint64_t value) {
+int32 GetCodedUIntSize(uint64 value) {
   if (value < 0x000000000000007FULL)
     return 1;
   else if (value < 0x0000000000003FFFULL)
     return 2;
   else if (value < 0x00000000001FFFFFULL)
     return 3;
   else if (value < 0x000000000FFFFFFFULL)
     return 4;
@@ -192,17 +194,17 @@ int32_t GetCodedUIntSize(uint64_t value)
     return 5;
   else if (value < 0x000003FFFFFFFFFFULL)
     return 6;
   else if (value < 0x0001FFFFFFFFFFFFULL)
     return 7;
   return 8;
 }
 
-int32_t GetUIntSize(uint64_t value) {
+int32 GetUIntSize(uint64 value) {
   if (value < 0x0000000000000100ULL)
     return 1;
   else if (value < 0x0000000000010000ULL)
     return 2;
   else if (value < 0x0000000001000000ULL)
     return 3;
   else if (value < 0x0000000100000000ULL)
     return 4;
@@ -210,441 +212,532 @@ int32_t GetUIntSize(uint64_t value) {
     return 5;
   else if (value < 0x0001000000000000ULL)
     return 6;
   else if (value < 0x0100000000000000ULL)
     return 7;
   return 8;
 }
 
-int32_t GetIntSize(int64_t value) {
+int32 GetIntSize(int64 value) {
   // Doubling the requested value ensures positive values with their high bit
   // set are written with 0-padding to avoid flipping the signedness.
-  const uint64_t v = (value < 0) ? value ^ -1LL : value;
+  const uint64 v = (value < 0) ? value ^ -1LL : value;
   return GetUIntSize(2 * v);
 }
 
-uint64_t EbmlMasterElementSize(uint64_t type, uint64_t value) {
+uint64 EbmlMasterElementSize(uint64 type, uint64 value) {
   // Size of EBML ID
-  int32_t ebml_size = GetUIntSize(type);
+  int32 ebml_size = GetUIntSize(type);
 
   // Datasize
   ebml_size += GetCodedUIntSize(value);
 
-  return static_cast<uint64_t>(ebml_size);
+  return ebml_size;
 }
 
-uint64_t EbmlElementSize(uint64_t type, int64_t value) {
+uint64 EbmlElementSize(uint64 type, int64 value) {
   // Size of EBML ID
-  int32_t ebml_size = GetUIntSize(type);
+  int32 ebml_size = GetUIntSize(type);
 
   // Datasize
   ebml_size += GetIntSize(value);
 
   // Size of Datasize
   ebml_size++;
 
-  return static_cast<uint64_t>(ebml_size);
+  return ebml_size;
 }
 
-uint64_t EbmlElementSize(uint64_t type, uint64_t value) {
+uint64 EbmlElementSize(uint64 type, uint64 value) {
   return EbmlElementSize(type, value, 0);
 }
 
-uint64_t EbmlElementSize(uint64_t type, uint64_t value, uint64_t fixed_size) {
+uint64 EbmlElementSize(uint64 type, uint64 value, uint64 fixed_size) {
   // Size of EBML ID
-  uint64_t ebml_size = static_cast<uint64_t>(GetUIntSize(type));
+  uint64 ebml_size = GetUIntSize(type);
 
   // Datasize
-  ebml_size +=
-      (fixed_size > 0) ? fixed_size : static_cast<uint64_t>(GetUIntSize(value));
+  ebml_size += (fixed_size > 0) ? fixed_size : GetUIntSize(value);
 
   // Size of Datasize
   ebml_size++;
 
   return ebml_size;
 }
 
-uint64_t EbmlElementSize(uint64_t type, float /* value */) {
+uint64 EbmlElementSize(uint64 type, float /* value */) {
   // Size of EBML ID
-  uint64_t ebml_size = static_cast<uint64_t>(GetUIntSize(type));
+  uint64 ebml_size = GetUIntSize(type);
 
   // Datasize
   ebml_size += sizeof(float);
 
   // Size of Datasize
   ebml_size++;
 
   return ebml_size;
 }
 
-uint64_t EbmlElementSize(uint64_t type, const char* value) {
+uint64 EbmlElementSize(uint64 type, const char* value) {
   if (!value)
     return 0;
 
   // Size of EBML ID
-  uint64_t ebml_size = static_cast<uint64_t>(GetUIntSize(type));
+  uint64 ebml_size = GetUIntSize(type);
 
   // Datasize
   ebml_size += strlen(value);
 
   // Size of Datasize
-  ebml_size++;
+  ebml_size += GetCodedUIntSize(strlen(value));
 
   return ebml_size;
 }
 
-uint64_t EbmlElementSize(uint64_t type, const uint8_t* value, uint64_t size) {
+uint64 EbmlElementSize(uint64 type, const uint8* value, uint64 size) {
   if (!value)
     return 0;
 
   // Size of EBML ID
-  uint64_t ebml_size = static_cast<uint64_t>(GetUIntSize(type));
+  uint64 ebml_size = GetUIntSize(type);
 
   // Datasize
   ebml_size += size;
 
   // Size of Datasize
   ebml_size += GetCodedUIntSize(size);
 
   return ebml_size;
 }
 
-uint64_t EbmlDateElementSize(uint64_t type) {
+uint64 EbmlDateElementSize(uint64 type) {
   // Size of EBML ID
-  uint64_t ebml_size = static_cast<uint64_t>(GetUIntSize(type));
+  uint64 ebml_size = GetUIntSize(type);
 
   // Datasize
   ebml_size += kDateElementSize;
 
   // Size of Datasize
   ebml_size++;
 
   return ebml_size;
 }
 
-int32_t SerializeInt(IMkvWriter* writer, int64_t value, int32_t size) {
+int32 SerializeInt(IMkvWriter* writer, int64 value, int32 size) {
   if (!writer || size < 1 || size > 8)
     return -1;
 
-  for (int32_t i = 1; i <= size; ++i) {
-    const int32_t byte_count = size - i;
-    const int32_t bit_count = byte_count * 8;
+  for (int32 i = 1; i <= size; ++i) {
+    const int32 byte_count = size - i;
+    const int32 bit_count = byte_count * 8;
 
-    const int64_t bb = value >> bit_count;
-    const uint8_t b = static_cast<uint8_t>(bb);
+    const int64 bb = value >> bit_count;
+    const uint8 b = static_cast<uint8>(bb);
 
-    const int32_t status = writer->Write(&b, 1);
+    const int32 status = writer->Write(&b, 1);
 
     if (status < 0)
       return status;
   }
 
   return 0;
 }
 
-int32_t SerializeFloat(IMkvWriter* writer, float f) {
+int32 SerializeFloat(IMkvWriter* writer, float f) {
   if (!writer)
     return -1;
 
-  assert(sizeof(uint32_t) == sizeof(float));
+  assert(sizeof(uint32) == sizeof(float));
   // This union is merely used to avoid a reinterpret_cast from float& to
   // uint32& which will result in violation of strict aliasing.
   union U32 {
-    uint32_t u32;
+    uint32 u32;
     float f;
   } value;
   value.f = f;
 
-  for (int32_t i = 1; i <= 4; ++i) {
-    const int32_t byte_count = 4 - i;
-    const int32_t bit_count = byte_count * 8;
+  for (int32 i = 1; i <= 4; ++i) {
+    const int32 byte_count = 4 - i;
+    const int32 bit_count = byte_count * 8;
 
-    const uint8_t byte = static_cast<uint8_t>(value.u32 >> bit_count);
+    const uint8 byte = static_cast<uint8>(value.u32 >> bit_count);
 
-    const int32_t status = writer->Write(&byte, 1);
+    const int32 status = writer->Write(&byte, 1);
 
     if (status < 0)
       return status;
   }
 
   return 0;
 }
 
-int32_t WriteUInt(IMkvWriter* writer, uint64_t value) {
+int32 WriteUInt(IMkvWriter* writer, uint64 value) {
   if (!writer)
     return -1;
 
-  int32_t size = GetCodedUIntSize(value);
+  int32 size = GetCodedUIntSize(value);
 
   return WriteUIntSize(writer, value, size);
 }
 
-int32_t WriteUIntSize(IMkvWriter* writer, uint64_t value, int32_t size) {
+int32 WriteUIntSize(IMkvWriter* writer, uint64 value, int32 size) {
   if (!writer || size < 0 || size > 8)
     return -1;
 
   if (size > 0) {
-    const uint64_t bit = 1LL << (size * 7);
+    const uint64 bit = 1LL << (size * 7);
 
     if (value > (bit - 2))
       return -1;
 
     value |= bit;
   } else {
     size = 1;
-    int64_t bit;
+    int64 bit;
 
     for (;;) {
       bit = 1LL << (size * 7);
-      const uint64_t max = bit - 2;
+      const uint64 max = bit - 2;
 
       if (value <= max)
         break;
 
       ++size;
     }
 
     if (size > 8)
       return false;
 
     value |= bit;
   }
 
   return SerializeInt(writer, value, size);
 }
 
-int32_t WriteID(IMkvWriter* writer, uint64_t type) {
+int32 WriteID(IMkvWriter* writer, uint64 type) {
   if (!writer)
     return -1;
 
   writer->ElementStartNotify(type, writer->Position());
 
-  const int32_t size = GetUIntSize(type);
+  const int32 size = GetUIntSize(type);
 
   return SerializeInt(writer, type, size);
 }
 
-bool WriteEbmlMasterElement(IMkvWriter* writer, uint64_t type, uint64_t size) {
+bool WriteEbmlMasterElement(IMkvWriter* writer, uint64 type, uint64 size) {
   if (!writer)
     return false;
 
   if (WriteID(writer, type))
     return false;
 
   if (WriteUInt(writer, size))
     return false;
 
   return true;
 }
 
-bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, uint64_t value) {
+bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value) {
   return WriteEbmlElement(writer, type, value, 0);
 }
 
-bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, uint64_t value,
-                      uint64_t fixed_size) {
+bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value,
+                      uint64 fixed_size) {
   if (!writer)
     return false;
 
   if (WriteID(writer, type))
     return false;
 
-  uint64_t size = static_cast<uint64_t>(GetUIntSize(value));
+  uint64 size = GetUIntSize(value);
   if (fixed_size > 0) {
     if (size > fixed_size)
       return false;
     size = fixed_size;
   }
   if (WriteUInt(writer, size))
     return false;
 
-  if (SerializeInt(writer, value, static_cast<int32_t>(size)))
+  if (SerializeInt(writer, value, static_cast<int32>(size)))
     return false;
 
   return true;
 }
 
-bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, int64_t value) {
+bool WriteEbmlElement(IMkvWriter* writer, uint64 type, int64 value) {
   if (!writer)
     return false;
 
   if (WriteID(writer, type))
     return 0;
 
-  const uint64_t size = GetIntSize(value);
+  const uint64 size = GetIntSize(value);
   if (WriteUInt(writer, size))
     return false;
 
-  if (SerializeInt(writer, value, static_cast<int32_t>(size)))
+  if (SerializeInt(writer, value, static_cast<int32>(size)))
     return false;
 
   return true;
 }
 
-bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, float value) {
+bool WriteEbmlElement(IMkvWriter* writer, uint64 type, float value) {
   if (!writer)
     return false;
 
   if (WriteID(writer, type))
     return false;
 
   if (WriteUInt(writer, 4))
     return false;
 
   if (SerializeFloat(writer, value))
     return false;
 
   return true;
 }
 
-bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, const char* value) {
+bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const char* value) {
   if (!writer || !value)
     return false;
 
   if (WriteID(writer, type))
     return false;
 
-  const uint64_t length = strlen(value);
+  const uint64 length = strlen(value);
   if (WriteUInt(writer, length))
     return false;
 
-  if (writer->Write(value, static_cast<const uint32_t>(length)))
+  if (writer->Write(value, static_cast<const uint32>(length)))
     return false;
 
   return true;
 }
 
-bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, const uint8_t* value,
-                      uint64_t size) {
+bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const uint8* value,
+                      uint64 size) {
   if (!writer || !value || size < 1)
     return false;
 
   if (WriteID(writer, type))
     return false;
 
   if (WriteUInt(writer, size))
     return false;
 
-  if (writer->Write(value, static_cast<uint32_t>(size)))
+  if (writer->Write(value, static_cast<uint32>(size)))
     return false;
 
   return true;
 }
 
-bool WriteEbmlDateElement(IMkvWriter* writer, uint64_t type, int64_t value) {
+bool WriteEbmlDateElement(IMkvWriter* writer, uint64 type, int64 value) {
   if (!writer)
     return false;
 
   if (WriteID(writer, type))
     return false;
 
   if (WriteUInt(writer, kDateElementSize))
     return false;
 
   if (SerializeInt(writer, value, kDateElementSize))
     return false;
 
   return true;
 }
 
-uint64_t WriteFrame(IMkvWriter* writer, const Frame* const frame,
-                    Cluster* cluster) {
+uint64 WriteFrame(IMkvWriter* writer, const Frame* const frame,
+                  Cluster* cluster) {
   if (!writer || !frame || !frame->IsValid() || !cluster ||
       !cluster->timecode_scale())
     return 0;
 
   //  Technically the timecode for a block can be less than the
   //  timecode for the cluster itself (remember that block timecode
   //  is a signed, 16-bit integer).  However, as a simplification we
   //  only permit non-negative cluster-relative timecodes for blocks.
-  const int64_t relative_timecode = cluster->GetRelativeTimecode(
+  const int64 relative_timecode = cluster->GetRelativeTimecode(
       frame->timestamp() / cluster->timecode_scale());
   if (relative_timecode < 0 || relative_timecode > kMaxBlockTimecode)
     return 0;
 
   return frame->CanBeSimpleBlock() ?
              WriteSimpleBlock(writer, frame, relative_timecode) :
              WriteBlock(writer, frame, relative_timecode,
                         cluster->timecode_scale());
 }
 
-uint64_t WriteVoidElement(IMkvWriter* writer, uint64_t size) {
+uint64 WriteVoidElement(IMkvWriter* writer, uint64 size) {
   if (!writer)
     return false;
 
   // Subtract one for the void ID and the coded size.
-  uint64_t void_entry_size = size - 1 - GetCodedUIntSize(size - 1);
-  uint64_t void_size =
-      EbmlMasterElementSize(libwebm::kMkvVoid, void_entry_size) +
-      void_entry_size;
+  uint64 void_entry_size = size - 1 - GetCodedUIntSize(size - 1);
+  uint64 void_size = EbmlMasterElementSize(libwebm::kMkvVoid, void_entry_size) +
+                     void_entry_size;
 
   if (void_size != size)
     return 0;
 
-  const int64_t payload_position = writer->Position();
+  const int64 payload_position = writer->Position();
   if (payload_position < 0)
     return 0;
 
   if (WriteID(writer, libwebm::kMkvVoid))
     return 0;
 
   if (WriteUInt(writer, void_entry_size))
     return 0;
 
-  const uint8_t value = 0;
-  for (int32_t i = 0; i < static_cast<int32_t>(void_entry_size); ++i) {
+  const uint8 value = 0;
+  for (int32 i = 0; i < static_cast<int32>(void_entry_size); ++i) {
     if (writer->Write(&value, 1))
       return 0;
   }
 
-  const int64_t stop_position = writer->Position();
+  const int64 stop_position = writer->Position();
   if (stop_position < 0 ||
-      stop_position - payload_position != static_cast<int64_t>(void_size))
+      stop_position - payload_position != static_cast<int64>(void_size))
     return 0;
 
   return void_size;
 }
 
-void GetVersion(int32_t* major, int32_t* minor, int32_t* build,
-                int32_t* revision) {
+void GetVersion(int32* major, int32* minor, int32* build, int32* revision) {
   *major = 0;
   *minor = 2;
   *build = 1;
   *revision = 0;
 }
 
-uint64_t MakeUID(unsigned int* seed) {
-  uint64_t uid = 0;
+uint64 MakeUID(unsigned int* seed) {
+  uint64 uid = 0;
 
 #ifdef __MINGW32__
   srand(*seed);
 #endif
 
   for (int i = 0; i < 7; ++i) {  // avoid problems with 8-byte values
     uid <<= 8;
 
 // TODO(fgalligan): Move random number generation to platform specific code.
 #ifdef _MSC_VER
     (void)seed;
-    const int32_t nn = rand();
+    const int32 nn = rand();
 #elif __ANDROID__
-    int32_t temp_num = 1;
+    (void)seed;
+    int32 temp_num = 1;
     int fd = open("/dev/urandom", O_RDONLY);
     if (fd != -1) {
       read(fd, &temp_num, sizeof(temp_num));
       close(fd);
     }
-    const int32_t nn = temp_num;
+    const int32 nn = temp_num;
 #elif defined __MINGW32__
-    const int32_t nn = rand();
+    const int32 nn = rand();
 #else
-    const int32_t nn = rand_r(seed);
+    const int32 nn = rand_r(seed);
 #endif
-    const int32_t n = 0xFF & (nn >> 4);  // throw away low-order bits
+    const int32 n = 0xFF & (nn >> 4);  // throw away low-order bits
 
     uid |= n;
   }
 
   return uid;
 }
 
+bool IsMatrixCoefficientsValueValid(uint64_t value) {
+  switch (value) {
+    case mkvmuxer::Colour::kGbr:
+    case mkvmuxer::Colour::kBt709:
+    case mkvmuxer::Colour::kUnspecifiedMc:
+    case mkvmuxer::Colour::kReserved:
+    case mkvmuxer::Colour::kFcc:
+    case mkvmuxer::Colour::kBt470bg:
+    case mkvmuxer::Colour::kSmpte170MMc:
+    case mkvmuxer::Colour::kSmpte240MMc:
+    case mkvmuxer::Colour::kYcocg:
+    case mkvmuxer::Colour::kBt2020NonConstantLuminance:
+    case mkvmuxer::Colour::kBt2020ConstantLuminance:
+      return true;
+  }
+  return false;
+}
+
+bool IsChromaSitingHorzValueValid(uint64_t value) {
+  switch (value) {
+    case mkvmuxer::Colour::kUnspecifiedCsh:
+    case mkvmuxer::Colour::kLeftCollocated:
+    case mkvmuxer::Colour::kHalfCsh:
+      return true;
+  }
+  return false;
+}
+
+bool IsChromaSitingVertValueValid(uint64_t value) {
+  switch (value) {
+    case mkvmuxer::Colour::kUnspecifiedCsv:
+    case mkvmuxer::Colour::kTopCollocated:
+    case mkvmuxer::Colour::kHalfCsv:
+      return true;
+  }
+  return false;
+}
+
+bool IsColourRangeValueValid(uint64_t value) {
+  switch (value) {
+    case mkvmuxer::Colour::kUnspecifiedCr:
+    case mkvmuxer::Colour::kBroadcastRange:
+    case mkvmuxer::Colour::kFullRange:
+    case mkvmuxer::Colour::kMcTcDefined:
+      return true;
+  }
+  return false;
+}
+
+bool IsTransferCharacteristicsValueValid(uint64_t value) {
+  switch (value) {
+    case mkvmuxer::Colour::kIturBt709Tc:
+    case mkvmuxer::Colour::kUnspecifiedTc:
+    case mkvmuxer::Colour::kReservedTc:
+    case mkvmuxer::Colour::kGamma22Curve:
+    case mkvmuxer::Colour::kGamma28Curve:
+    case mkvmuxer::Colour::kSmpte170MTc:
+    case mkvmuxer::Colour::kSmpte240MTc:
+    case mkvmuxer::Colour::kLinear:
+    case mkvmuxer::Colour::kLog:
+    case mkvmuxer::Colour::kLogSqrt:
+    case mkvmuxer::Colour::kIec6196624:
+    case mkvmuxer::Colour::kIturBt1361ExtendedColourGamut:
+    case mkvmuxer::Colour::kIec6196621:
+    case mkvmuxer::Colour::kIturBt202010bit:
+    case mkvmuxer::Colour::kIturBt202012bit:
+    case mkvmuxer::Colour::kSmpteSt2084:
+    case mkvmuxer::Colour::kSmpteSt4281Tc:
+    case mkvmuxer::Colour::kAribStdB67Hlg:
+      return true;
+  }
+  return false;
+}
+
+bool IsPrimariesValueValid(uint64_t value) {
+  switch (value) {
+    case mkvmuxer::Colour::kReservedP0:
+    case mkvmuxer::Colour::kIturBt709P:
+    case mkvmuxer::Colour::kUnspecifiedP:
+    case mkvmuxer::Colour::kReservedP3:
+    case mkvmuxer::Colour::kIturBt470M:
+    case mkvmuxer::Colour::kIturBt470Bg:
+    case mkvmuxer::Colour::kSmpte170MP:
+    case mkvmuxer::Colour::kSmpte240MP:
+    case mkvmuxer::Colour::kFilm:
+    case mkvmuxer::Colour::kIturBt2020:
+    case mkvmuxer::Colour::kSmpteSt4281P:
+    case mkvmuxer::Colour::kJedecP22Phosphors:
+      return true;
+  }
+  return false;
+}
+
 }  // namespace mkvmuxer
--- a/third_party/aom/third_party/libwebm/mkvmuxer/mkvmuxerutil.h
+++ b/third_party/aom/third_party/libwebm/mkvmuxer/mkvmuxerutil.h
@@ -3,93 +3,110 @@
 // Use of this source code is governed by a BSD-style license
 // that can be found in the LICENSE file in the root of the source
 // tree. An additional intellectual property rights grant can be found
 // in the file PATENTS.  All contributing project authors may
 // be found in the AUTHORS file in the root of the source tree.
 #ifndef MKVMUXER_MKVMUXERUTIL_H_
 #define MKVMUXER_MKVMUXERUTIL_H_
 
-#include <stdint.h>
+#include "mkvmuxertypes.h"
+
+#include "stdint.h"
 
 namespace mkvmuxer {
 class Cluster;
 class Frame;
 class IMkvWriter;
 
-const uint64_t kEbmlUnknownValue = 0x01FFFFFFFFFFFFFFULL;
-const int64_t kMaxBlockTimecode = 0x07FFFLL;
+// TODO(tomfinegan): mkvmuxer:: integer types continue to be used here because
+// changing them causes pain for downstream projects. It would be nice if a
+// solution that allows removal of the mkvmuxer:: integer types while avoiding
+// pain for downstream users of libwebm. Considering that mkvmuxerutil.{cc,h}
+// are really, for the great majority of cases, EBML size calculation and writer
+// functions, perhaps a more EBML focused utility would be the way to go as a
+// first step.
+
+const uint64 kEbmlUnknownValue = 0x01FFFFFFFFFFFFFFULL;
+const int64 kMaxBlockTimecode = 0x07FFFLL;
 
 // Writes out |value| in Big Endian order. Returns 0 on success.
-int32_t SerializeInt(IMkvWriter* writer, int64_t value, int32_t size);
+int32 SerializeInt(IMkvWriter* writer, int64 value, int32 size);
 
 // Returns the size in bytes of the element.
-int32_t GetUIntSize(uint64_t value);
-int32_t GetIntSize(int64_t value);
-int32_t GetCodedUIntSize(uint64_t value);
-uint64_t EbmlMasterElementSize(uint64_t type, uint64_t value);
-uint64_t EbmlElementSize(uint64_t type, int64_t value);
-uint64_t EbmlElementSize(uint64_t type, uint64_t value);
-uint64_t EbmlElementSize(uint64_t type, float value);
-uint64_t EbmlElementSize(uint64_t type, const char* value);
-uint64_t EbmlElementSize(uint64_t type, const uint8_t* value, uint64_t size);
-uint64_t EbmlDateElementSize(uint64_t type);
+int32 GetUIntSize(uint64 value);
+int32 GetIntSize(int64 value);
+int32 GetCodedUIntSize(uint64 value);
+uint64 EbmlMasterElementSize(uint64 type, uint64 value);
+uint64 EbmlElementSize(uint64 type, int64 value);
+uint64 EbmlElementSize(uint64 type, uint64 value);
+uint64 EbmlElementSize(uint64 type, float value);
+uint64 EbmlElementSize(uint64 type, const char* value);
+uint64 EbmlElementSize(uint64 type, const uint8* value, uint64 size);
+uint64 EbmlDateElementSize(uint64 type);
 
 // Returns the size in bytes of the element assuming that the element was
 // written using |fixed_size| bytes. If |fixed_size| is set to zero, then it
 // computes the necessary number of bytes based on |value|.
-uint64_t EbmlElementSize(uint64_t type, uint64_t value, uint64_t fixed_size);
+uint64 EbmlElementSize(uint64 type, uint64 value, uint64 fixed_size);
 
 // Creates an EBML coded number from |value| and writes it out. The size of
 // the coded number is determined by the value of |value|. |value| must not
 // be in a coded form. Returns 0 on success.
-int32_t WriteUInt(IMkvWriter* writer, uint64_t value);
+int32 WriteUInt(IMkvWriter* writer, uint64 value);
 
 // Creates an EBML coded number from |value| and writes it out. The size of
 // the coded number is determined by the value of |size|. |value| must not
 // be in a coded form. Returns 0 on success.
-int32_t WriteUIntSize(IMkvWriter* writer, uint64_t value, int32_t size);
+int32 WriteUIntSize(IMkvWriter* writer, uint64 value, int32 size);
 
 // Output an Mkv master element. Returns true if the element was written.
-bool WriteEbmlMasterElement(IMkvWriter* writer, uint64_t value, uint64_t size);
+bool WriteEbmlMasterElement(IMkvWriter* writer, uint64 value, uint64 size);
 
 // Outputs an Mkv ID, calls |IMkvWriter::ElementStartNotify|, and passes the
 // ID to |SerializeInt|. Returns 0 on success.
-int32_t WriteID(IMkvWriter* writer, uint64_t type);
+int32 WriteID(IMkvWriter* writer, uint64 type);
 
 // Output an Mkv non-master element. Returns true if the element was written.
-bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, uint64_t value);
-bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, int64_t value);
-bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, float value);
-bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, const char* value);
-bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, const uint8_t* value,
-                      uint64_t size);
-bool WriteEbmlDateElement(IMkvWriter* writer, uint64_t type, int64_t value);
+bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value);
+bool WriteEbmlElement(IMkvWriter* writer, uint64 type, int64 value);
+bool WriteEbmlElement(IMkvWriter* writer, uint64 type, float value);
+bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const char* value);
+bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const uint8* value,
+                      uint64 size);
+bool WriteEbmlDateElement(IMkvWriter* writer, uint64 type, int64 value);
 
 // Output an Mkv non-master element using fixed size. The element will be
 // written out using exactly |fixed_size| bytes. If |fixed_size| is set to zero
 // then it computes the necessary number of bytes based on |value|. Returns true
 // if the element was written.
-bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, uint64_t value,
-                      uint64_t fixed_size);
+bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value,
+                      uint64 fixed_size);
 
 // Output a Mkv Frame. It decides the correct element to write (Block vs
 // SimpleBlock) based on the parameters of the Frame.
-uint64_t WriteFrame(IMkvWriter* writer, const Frame* const frame,
-                    Cluster* cluster);
+uint64 WriteFrame(IMkvWriter* writer, const Frame* const frame,
+                  Cluster* cluster);
 
 // Output a void element. |size| must be the entire size in bytes that will be
 // void. The function will calculate the size of the void header and subtract
 // it from |size|.
-uint64_t WriteVoidElement(IMkvWriter* writer, uint64_t size);
+uint64 WriteVoidElement(IMkvWriter* writer, uint64 size);
 
 // Returns the version number of the muxer in |major|, |minor|, |build|,
 // and |revision|.
-void GetVersion(int32_t* major, int32_t* minor, int32_t* build,
-                int32_t* revision);
+void GetVersion(int32* major, int32* minor, int32* build, int32* revision);
 
 // Returns a random number to be used for UID, using |seed| to seed
 // the random-number generator (see POSIX rand_r() for semantics).
-uint64_t MakeUID(unsigned int* seed);
+uint64 MakeUID(unsigned int* seed);
+
+// Colour field validation helpers. All return true when |value| is valid.
+bool IsMatrixCoefficientsValueValid(uint64_t value);
+bool IsChromaSitingHorzValueValid(uint64_t value);
+bool IsChromaSitingVertValueValid(uint64_t value);
+bool IsColourRangeValueValid(uint64_t value);
+bool IsTransferCharacteristicsValueValid(uint64_t value);
+bool IsPrimariesValueValid(uint64_t value);
 
 }  // namespace mkvmuxer
 
 #endif  // MKVMUXER_MKVMUXERUTIL_H_
--- a/third_party/aom/third_party/libwebm/mkvmuxer/mkvwriter.cc
+++ b/third_party/aom/third_party/libwebm/mkvmuxer/mkvwriter.cc
@@ -3,16 +3,18 @@
 // Use of this source code is governed by a BSD-style license
 // that can be found in the LICENSE file in the root of the source
 // tree. An additional intellectual property rights grant can be found
 // in the file PATENTS.  All contributing project authors may
 // be found in the AUTHORS file in the root of the source tree.
 
 #include "mkvmuxer/mkvwriter.h"
 
+#include <sys/types.h>
+
 #ifdef _MSC_VER
 #include <share.h>  // for _SH_DENYWR
 #endif
 
 namespace mkvmuxer {
 
 MkvWriter::MkvWriter() : file_(NULL), writer_owns_file_(true) {}
 
@@ -72,17 +74,17 @@ int64 MkvWriter::Position() const {
 
 int32 MkvWriter::Position(int64 position) {
   if (!file_)
     return -1;
 
 #ifdef _MSC_VER
   return _fseeki64(file_, position, SEEK_SET);
 #else
-  return fseek(file_, position, SEEK_SET);
+  return fseeko(file_, static_cast<off_t>(position), SEEK_SET);
 #endif
 }
 
 bool MkvWriter::Seekable() const { return true; }
 
 void MkvWriter::ElementStartNotify(uint64, int64) {}
 
 }  // namespace mkvmuxer
--- a/third_party/aom/third_party/libwebm/mkvparser/mkvparser.cc
+++ b/third_party/aom/third_party/libwebm/mkvparser/mkvparser.cc
@@ -17,19 +17,25 @@
 #include <climits>
 #include <cmath>
 #include <cstring>
 #include <memory>
 #include <new>
 
 #include "common/webmids.h"
 
+// disable deprecation warnings for auto_ptr
+#if defined(__GNUC__) && __GNUC__ >= 5
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 namespace mkvparser {
 const float MasteringMetadata::kValueNotPresent = FLT_MAX;
 const long long Colour::kValueNotPresent = LLONG_MAX;
+const float Projection::kValueNotPresent = FLT_MAX;
 
 #ifdef MSC_COMPAT
 inline bool isnan(double val) { return !!_isnan(val); }
 inline bool isinf(double val) { return !_finite(val); }
 #else
 inline bool isnan(double val) { return std::isnan(val); }
 inline bool isinf(double val) { return std::isinf(val); }
 #endif  // MSC_COMPAT
@@ -1470,16 +1476,18 @@ long Segment::Load() {
     if (status < 0)  // error
       return status;
 
     if (status >= 1)  // no more clusters
       return 0;
   }
 }
 
+SeekHead::Entry::Entry() : id(0), pos(0), element_start(0), element_size(0) {}
+
 SeekHead::SeekHead(Segment* pSegment, long long start, long long size_,
                    long long element_start, long long element_size)
     : m_pSegment(pSegment),
       m_start(start),
       m_size(size_),
       m_element_start(element_start),
       m_element_size(element_size),
       m_entries(0),
@@ -1520,25 +1528,29 @@ long SeekHead::Parse() {
 
     if (pos > stop)
       return E_FILE_FORMAT_INVALID;
   }
 
   if (pos != stop)
     return E_FILE_FORMAT_INVALID;
 
-  m_entries = new (std::nothrow) Entry[entry_count];
-
-  if (m_entries == NULL)
-    return -1;
-
-  m_void_elements = new (std::nothrow) VoidElement[void_element_count];
-
-  if (m_void_elements == NULL)
-    return -1;
+  if (entry_count > 0) {
+    m_entries = new (std::nothrow) Entry[entry_count];
+
+    if (m_entries == NULL)
+      return -1;
+  }
+
+  if (void_element_count > 0) {
+    m_void_elements = new (std::nothrow) VoidElement[void_element_count];
+
+    if (m_void_elements == NULL)
+      return -1;
+  }
 
   // now parse the entries and void elements
 
   Entry* pEntry = m_entries;
   VoidElement* pVoidElement = m_void_elements;
 
   pos = m_start;
 
@@ -1547,24 +1559,24 @@ long SeekHead::Parse() {
 
     long long id, size;
 
     const long status = ParseElementHeader(pReader, pos, stop, id, size);
 
     if (status < 0)  // error
       return status;
 
-    if (id == libwebm::kMkvSeek) {
+    if (id == libwebm::kMkvSeek && entry_count > 0) {
       if (ParseEntry(pReader, pos, size, pEntry)) {
         Entry& e = *pEntry++;
 
         e.element_start = idpos;
         e.element_size = (pos + size) - idpos;
       }
-    } else if (id == libwebm::kMkvVoid) {
+    } else if (id == libwebm::kMkvVoid && void_element_count > 0) {
       VoidElement& e = *pVoidElement++;
 
       e.element_start = idpos;
       e.element_size = (pos + size) - idpos;
     }
 
     pos += size;  // consume payload
     if (pos > stop)
@@ -1761,28 +1773,17 @@ bool SeekHead::ParseEntry(IMkvReader* pR
   if ((pos + len) > stop)
     return false;
 
   pos += len;  // consume size of field
 
   if ((pos + seekIdSize) > stop)
     return false;
 
-  // Note that the SeekId payload really is serialized
-  // as a "Matroska integer", not as a plain binary value.
-  // In fact, Matroska requires that ID values in the
-  // stream exactly match the binary representation as listed
-  // in the Matroska specification.
-  //
-  // This parser is more liberal, and permits IDs to have
-  // any width.  (This could make the representation in the stream
-  // different from what's in the spec, but it doesn't matter here,
-  // since we always normalize "Matroska integer" values.)
-
-  pEntry->id = ReadUInt(pReader, pos, len);  // payload
+  pEntry->id = ReadID(pReader, pos, len);  // payload
 
   if (pEntry->id <= 0)
     return false;
 
   if (len != seekIdSize)
     return false;
 
   pos += seekIdSize;  // consume SeekID payload
@@ -2429,17 +2430,19 @@ bool CuePoint::TrackPosition::Parse(IMkv
   if ((m_pos < 0) || (m_track <= 0)) {
     return false;
   }
 
   return true;
 }
 
 const CuePoint::TrackPosition* CuePoint::Find(const Track* pTrack) const {
-  assert(pTrack);
+  if (pTrack == NULL) {
+    return NULL;
+  }
 
   const long long n = pTrack->GetNumber();
 
   const TrackPosition* i = m_track_positions;
   const TrackPosition* const j = i + m_track_positions_count;
 
   while (i != j) {
     const TrackPosition& p = *i++;
@@ -4029,17 +4032,17 @@ long SegmentInfo::Parse() {
 
     pos += size;
 
     if (pos > stop)
       return E_FILE_FORMAT_INVALID;
   }
 
   const double rollover_check = m_duration * m_timecodeScale;
-  if (rollover_check > LLONG_MAX)
+  if (rollover_check > static_cast<double>(LLONG_MAX))
     return E_FILE_FORMAT_INVALID;
 
   if (pos != stop)
     return E_FILE_FORMAT_INVALID;
 
   return 0;
 }
 
@@ -4120,17 +4123,17 @@ ContentEncoding::~ContentEncoding() {
     ContentEncryption* const enc = *enc_i++;
     delete enc;
   }
 
   delete[] encryption_entries_;
 }
 
 const ContentEncoding::ContentCompression*
-    ContentEncoding::GetCompressionByIndex(unsigned long idx) const {
+ContentEncoding::GetCompressionByIndex(unsigned long idx) const {
   const ptrdiff_t count = compression_entries_end_ - compression_entries_;
   assert(count >= 0);
 
   if (idx >= static_cast<unsigned long>(count))
     return NULL;
 
   return compression_entries_[idx];
 }
@@ -4978,39 +4981,37 @@ BlockEntry::Kind Track::EOSBlock::GetKin
 const Block* Track::EOSBlock::GetBlock() const { return NULL; }
 
 bool PrimaryChromaticity::Parse(IMkvReader* reader, long long read_pos,
                                 long long value_size, bool is_x,
                                 PrimaryChromaticity** chromaticity) {
   if (!reader)
     return false;
 
-  std::auto_ptr<PrimaryChromaticity> chromaticity_ptr;
-
-  if (!*chromaticity) {
-    chromaticity_ptr.reset(new PrimaryChromaticity());
-  } else {
-    chromaticity_ptr.reset(*chromaticity);
-  }
-
-  if (!chromaticity_ptr.get())
+  if (!*chromaticity)
+    *chromaticity = new PrimaryChromaticity();
+
+  if (!*chromaticity)
     return false;
 
-  float* value = is_x ? &chromaticity_ptr->x : &chromaticity_ptr->y;
+  PrimaryChromaticity* pc = *chromaticity;
+  float* value = is_x ? &pc->x : &pc->y;
 
   double parser_value = 0;
-  const long long value_parse_status =
+  const long long parse_status =
       UnserializeFloat(reader, read_pos, value_size, parser_value);
 
+  // Valid range is [0, 1]. Make sure the double is representable as a float
+  // before casting.
+  if (parse_status < 0 || parser_value < 0.0 || parser_value > 1.0 ||
+      (parser_value > 0.0 && parser_value < FLT_MIN))
+    return false;
+
   *value = static_cast<float>(parser_value);
 
-  if (value_parse_status < 0 || *value < 0.0 || *value > 1.0)
-    return false;
-
-  *chromaticity = chromaticity_ptr.release();
   return true;
 }
 
 bool MasteringMetadata::Parse(IMkvReader* reader, long long mm_start,
                               long long mm_size, MasteringMetadata** mm) {
   if (!reader || *mm)
     return false;
 
@@ -5183,21 +5184,104 @@ bool Colour::Parse(IMkvReader* reader, l
     read_pos += child_size;
     if (read_pos > colour_end)
       return false;
   }
   *colour = colour_ptr.release();
   return true;
 }
 
+bool Projection::Parse(IMkvReader* reader, long long start, long long size,
+                       Projection** projection) {
+  if (!reader || *projection)
+    return false;
+
+  std::auto_ptr<Projection> projection_ptr(new Projection());
+  if (!projection_ptr.get())
+    return false;
+
+  const long long end = start + size;
+  long long read_pos = start;
+
+  while (read_pos < end) {
+    long long child_id = 0;
+    long long child_size = 0;
+
+    const long long status =
+        ParseElementHeader(reader, read_pos, end, child_id, child_size);
+    if (status < 0)
+      return false;
+
+    if (child_id == libwebm::kMkvProjectionType) {
+      long long projection_type = kTypeNotPresent;
+      projection_type = UnserializeUInt(reader, read_pos, child_size);
+      if (projection_type < 0)
+        return false;
+
+      projection_ptr->type = static_cast<ProjectionType>(projection_type);
+    } else if (child_id == libwebm::kMkvProjectionPrivate) {
+      unsigned char* data = SafeArrayAlloc<unsigned char>(1, child_size);
+
+      if (data == NULL)
+        return false;
+
+      const int status =
+          reader->Read(read_pos, static_cast<long>(child_size), data);
+
+      if (status) {
+        delete[] data;
+        return false;
+      }
+
+      projection_ptr->private_data = data;
+      projection_ptr->private_data_length = static_cast<size_t>(child_size);
+    } else {
+      double value = 0;
+      const long long value_parse_status =
+          UnserializeFloat(reader, read_pos, child_size, value);
+      // Make sure value is representable as a float before casting.
+      if (value_parse_status < 0 || value < -FLT_MAX || value > FLT_MAX ||
+          (value > 0.0 && value < FLT_MIN)) {
+        return false;
+      }
+
+      switch (child_id) {
+        case libwebm::kMkvProjectionPoseYaw:
+          projection_ptr->pose_yaw = static_cast<float>(value);
+          break;
+        case libwebm::kMkvProjectionPosePitch:
+          projection_ptr->pose_pitch = static_cast<float>(value);
+          break;
+        case libwebm::kMkvProjectionPoseRoll:
+          projection_ptr->pose_roll = static_cast<float>(value);
+          break;
+        default:
+          return false;
+      }
+    }
+
+    read_pos += child_size;
+    if (read_pos > end)
+      return false;
+  }
+
+  *projection = projection_ptr.release();
+  return true;
+}
+
 VideoTrack::VideoTrack(Segment* pSegment, long long element_start,
                        long long element_size)
-    : Track(pSegment, element_start, element_size), m_colour(NULL) {}
-
-VideoTrack::~VideoTrack() { delete m_colour; }
+    : Track(pSegment, element_start, element_size),
+      m_colour(NULL),
+      m_projection(NULL) {}
+
+VideoTrack::~VideoTrack() {
+  delete m_colour;
+  delete m_projection;
+}
 
 long VideoTrack::Parse(Segment* pSegment, const Info& info,
                        long long element_start, long long element_size,
                        VideoTrack*& pResult) {
   if (pResult)
     return -1;
 
   if (info.type != Track::kVideo)
@@ -5219,16 +5303,17 @@ long VideoTrack::Parse(Segment* pSegment
   assert(s.size >= 0);
 
   long long pos = s.start;
   assert(pos >= 0);
 
   const long long stop = pos + s.size;
 
   Colour* colour = NULL;
+  Projection* projection = NULL;
 
   while (pos < stop) {
     long long id, size;
 
     const long status = ParseElementHeader(pReader, pos, stop, id, size);
 
     if (status < 0)  // error
       return status;
@@ -5269,16 +5354,19 @@ long VideoTrack::Parse(Segment* pSegment
       if (status < 0)
         return status;
 
       if (rate <= 0)
         return E_FILE_FORMAT_INVALID;
     } else if (id == libwebm::kMkvColour) {
       if (!Colour::Parse(pReader, pos, size, &colour))
         return E_FILE_FORMAT_INVALID;
+    } else if (id == libwebm::kMkvProjection) {
+      if (!Projection::Parse(pReader, pos, size, &projection))
+        return E_FILE_FORMAT_INVALID;
     }
 
     pos += size;  // consume payload
     if (pos > stop)
       return E_FILE_FORMAT_INVALID;
   }
 
   if (pos != stop)
@@ -5300,16 +5388,17 @@ long VideoTrack::Parse(Segment* pSegment
   pTrack->m_width = width;
   pTrack->m_height = height;
   pTrack->m_display_width = display_width;
   pTrack->m_display_height = display_height;
   pTrack->m_display_unit = display_unit;
   pTrack->m_stereo_mode = stereo_mode;
   pTrack->m_rate = rate;
   pTrack->m_colour = colour;
+  pTrack->m_projection = projection;
 
   pResult = pTrack;
   return 0;  // success
 }
 
 bool VideoTrack::VetEntry(const BlockEntry* pBlockEntry) const {
   return Track::VetEntry(pBlockEntry) && pBlockEntry->GetBlock()->IsKey();
 }
@@ -5400,16 +5489,18 @@ long VideoTrack::Seek(long long time_ns,
   // should never happen but we must return something anyway
 
   pResult = GetEOS();
   return 0;
 }
 
 Colour* VideoTrack::GetColour() const { return m_colour; }
 
+Projection* VideoTrack::GetProjection() const { return m_projection; }
+
 long long VideoTrack::GetWidth() const { return m_width; }
 
 long long VideoTrack::GetHeight() const { return m_height; }
 
 long long VideoTrack::GetDisplayWidth() const {
   return m_display_width > 0 ? m_display_width : GetWidth();
 }
 
@@ -6693,18 +6784,20 @@ Cluster::Cluster(Segment* pSegment, long
       m_element_size(-1 /* element_size */),
       m_timecode(-1),
       m_entries(NULL),
       m_entries_size(0),
       m_entries_count(-1)  // means "has not been parsed yet"
 {}
 
 Cluster::~Cluster() {
-  if (m_entries_count <= 0)
+  if (m_entries_count <= 0) {
+    delete[] m_entries;
     return;
+  }
 
   BlockEntry** i = m_entries;
   BlockEntry** const j = m_entries + m_entries_count;
 
   while (i != j) {
     BlockEntry* p = *i++;
     assert(p);
 
@@ -7845,17 +7938,16 @@ long Block::Parse(const Cluster* pCluste
         return E_FILE_FORMAT_INVALID;
 
       curr.len = static_cast<long>(frame_size);
     }
 
     pf = m_frames;
     while (pf != pf_end) {
       Frame& f = *pf++;
-      assert((pos + f.len) <= stop);
       if ((pos + f.len) > stop)
         return E_FILE_FORMAT_INVALID;
 
       f.pos = pos;
       pos += f.len;
     }
 
     if (pos != stop)
--- a/third_party/aom/third_party/libwebm/mkvparser/mkvparser.h
+++ b/third_party/aom/third_party/libwebm/mkvparser/mkvparser.h
@@ -468,16 +468,44 @@ struct Colour {
   long long transfer_characteristics;
   long long primaries;
   long long max_cll;
   long long max_fall;
 
   MasteringMetadata* mastering_metadata;
 };
 
+struct Projection {
+  enum ProjectionType {
+    kTypeNotPresent = -1,
+    kRectangular = 0,
+    kEquirectangular = 1,
+    kCubeMap = 2,
+    kMesh = 3,
+  };
+  static const float kValueNotPresent;
+  Projection()
+      : type(kTypeNotPresent),
+        private_data(NULL),
+        private_data_length(0),
+        pose_yaw(kValueNotPresent),
+        pose_pitch(kValueNotPresent),
+        pose_roll(kValueNotPresent) {}
+  ~Projection() { delete[] private_data; }
+  static bool Parse(IMkvReader* reader, long long element_start,
+                    long long element_size, Projection** projection);
+
+  ProjectionType type;
+  unsigned char* private_data;
+  size_t private_data_length;
+  float pose_yaw;
+  float pose_pitch;
+  float pose_roll;
+};
+
 class VideoTrack : public Track {
   VideoTrack(const VideoTrack&);
   VideoTrack& operator=(const VideoTrack&);
 
   VideoTrack(Segment*, long long element_start, long long element_size);
 
  public:
   virtual ~VideoTrack();
@@ -492,27 +520,30 @@ class VideoTrack : public Track {
   long long GetStereoMode() const;
   double GetFrameRate() const;
 
   bool VetEntry(const BlockEntry*) const;
   long Seek(long long time_ns, const BlockEntry*&) const;
 
   Colour* GetColour() const;
 
+  Projection* GetProjection() const;
+
  private:
   long long m_width;
   long long m_height;
   long long m_display_width;
   long long m_display_height;
   long long m_display_unit;
   long long m_stereo_mode;
 
   double m_rate;
 
   Colour* m_colour;
+  Projection* m_projection;
 };
 
 class AudioTrack : public Track {
   AudioTrack(const AudioTrack&);
   AudioTrack& operator=(const AudioTrack&);
 
   AudioTrack(Segment*, long long element_start, long long element_size);
 
@@ -808,16 +839,18 @@ class SeekHead {
   SeekHead(Segment*, long long start, long long size, long long element_start,
            long long element_size);
 
   ~SeekHead();
 
   long Parse();
 
   struct Entry {
+    Entry();
+
     // the SeekHead entry payload
     long long id;
     long long pos;
 
     // absolute pos of SeekEntry ID
     long long element_start;
 
     // SeekEntry ID size + size size + payload
--- a/third_party/aom/third_party/libwebm/mkvparser/mkvreader.cc
+++ b/third_party/aom/third_party/libwebm/mkvparser/mkvreader.cc
@@ -2,16 +2,18 @@
 //
 // Use of this source code is governed by a BSD-style license
 // that can be found in the LICENSE file in the root of the source
 // tree. An additional intellectual property rights grant can be found
 // in the file PATENTS.  All contributing project authors may
 // be found in the AUTHORS file in the root of the source tree.
 #include "mkvparser/mkvreader.h"
 
+#include <sys/types.h>
+
 #include <cassert>
 
 namespace mkvparser {
 
 MkvReader::MkvReader() : m_file(NULL), reader_owns_file_(true) {}
 
 MkvReader::MkvReader(FILE* fp) : m_file(fp), reader_owns_file_(false) {
   GetFileSize();
@@ -112,20 +114,20 @@ int MkvReader::Read(long long offset, lo
     return -1;
 
 #ifdef _MSC_VER
   const int status = _fseeki64(m_file, offset, SEEK_SET);
 
   if (status)
     return -1;  // error
 #else
-  fseek(m_file, offset, SEEK_SET);
+  fseeko(m_file, static_cast<off_t>(offset), SEEK_SET);
 #endif
 
   const size_t size = fread(buffer, 1, len, m_file);
 
   if (size < size_t(len))
     return -1;  // error
 
   return 0;  // success
 }
 
-}  // namespace mkvparser
\ No newline at end of file
+}  // namespace mkvparser
new file mode 100644
--- /dev/null
+++ b/third_party/aom/tools.mk
@@ -0,0 +1,126 @@
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+
+# List of tools to build.
+ifeq ($(CONFIG_ENTROPY_STATS), yes)
+TOOLS-$(CONFIG_AV1_ENCODER)      += aom_entropy_optimizer.c
+aom_entropy_optimizer.GUID        = 3afa9b05-940b-4d68-b5aa-55157d8ed7b4
+aom_entropy_optimizer.DESCRIPTION = Offline default probability optimizer
+endif
+
+#
+# End of specified files. The rest of the build rules should happen
+# automagically from here.
+#
+
+# Tools need different flags based on whether we're building
+# from an installed tree or a version controlled tree. Determine
+# the proper paths.
+ifeq ($(HAVE_ALT_TREE_LAYOUT),yes)
+    LIB_PATH-yes := $(SRC_PATH_BARE)/../lib
+    INC_PATH-yes := $(SRC_PATH_BARE)/../include
+else
+    LIB_PATH-yes                     += $(if $(BUILD_PFX),$(BUILD_PFX),.)
+    INC_PATH-$(CONFIG_AV1_DECODER)   += $(SRC_PATH_BARE)/av1
+    INC_PATH-$(CONFIG_AV1_ENCODER)   += $(SRC_PATH_BARE)/av1
+endif
+INC_PATH-$(CONFIG_LIBYUV) += $(SRC_PATH_BARE)/third_party/libyuv/include
+LIB_PATH := $(call enabled,LIB_PATH)
+INC_PATH := $(call enabled,INC_PATH)
+INTERNAL_CFLAGS = $(addprefix -I,$(INC_PATH))
+INTERNAL_LDFLAGS += $(addprefix -L,$(LIB_PATH))
+
+# Expand list of selected tools to build (as specified above)
+TOOLS           = $(addprefix tools/,$(call enabled,TOOLS))
+ALL_SRCS        = $(foreach ex,$(TOOLS),$($(notdir $(ex:.c=)).SRCS))
+CFLAGS += -I../include
+CODEC_EXTRA_LIBS=$(sort $(call enabled,CODEC_EXTRA_LIBS))
+
+ifneq ($(CONFIG_CODEC_SRCS), yes)
+  CFLAGS += -I../include/vpx
+endif
+
+# Expand all tools sources into a variable containing all sources
+# for that tools (not just them main one specified in TOOLS)
+# and add this file to the list (for MSVS workspace generation)
+$(foreach ex,$(TOOLS),$(eval $(notdir $(ex:.c=)).SRCS += $(ex) tools.mk))
+
+
+# Create build/install dependencies for all tools. The common case
+# is handled here. The MSVS case is handled below.
+NOT_MSVS = $(if $(CONFIG_MSVS),,yes)
+DIST-BINS-$(NOT_MSVS)      += $(addprefix bin/,$(TOOLS:.c=$(EXE_SFX)))
+DIST-SRCS-yes              += $(ALL_SRCS)
+OBJS-$(NOT_MSVS)           += $(call objs,$(ALL_SRCS))
+BINS-$(NOT_MSVS)           += $(addprefix $(BUILD_PFX),$(TOOLS:.c=$(EXE_SFX)))
+
+# Instantiate linker template for all tools.
+ifeq ($(CONFIG_OS_SUPPORT), yes)
+CODEC_EXTRA_LIBS-$(CONFIG_AV1)            += m
+else
+    ifeq ($(CONFIG_GCC), yes)
+    CODEC_EXTRA_LIBS-$(CONFIG_AV1)        += m
+    endif
+endif
+
+CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),aom_g,aom)
+ifneq ($(filter darwin%,$(TGT_OS)),)
+SHARED_LIB_SUF=.dylib
+else
+ifneq ($(filter os2%,$(TGT_OS)),)
+SHARED_LIB_SUF=_dll.a
+else
+SHARED_LIB_SUF=.so
+endif
+endif
+CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a)
+$(foreach bin,$(BINS-yes),\
+    $(eval $(bin):$(LIB_PATH)/lib$(CODEC_LIB)$(CODEC_LIB_SUF))\
+    $(eval $(call linker_template,$(bin),\
+        $(call objs,$($(notdir $(bin:$(EXE_SFX)=)).SRCS)) \
+        -l$(CODEC_LIB) $(addprefix -l,$(CODEC_EXTRA_LIBS))\
+        )))
+
+# The following pairs define a mapping of locations in the distribution
+# tree to locations in the source/build trees.
+INSTALL_MAPS += src/%.c   %.c
+INSTALL_MAPS += src/%     $(SRC_PATH_BARE)/%
+INSTALL_MAPS += bin/%     %
+INSTALL_MAPS += %         %
+
+
+# Build Visual Studio Projects. We use a template here to instantiate
+# explicit rules rather than using an implicit rule because we want to
+# leverage make's VPATH searching rather than specifying the paths on
+# each file in TOOLS. This has the unfortunate side effect that
+# touching the source files trigger a rebuild of the project files
+# even though there is no real dependency there (the dependency is on
+# the makefiles). We may want to revisit this.
+define vcproj_template
+$(1): $($(1:.$(VCPROJ_SFX)=).SRCS) vpx.$(VCPROJ_SFX)
+	$(if $(quiet),@echo "    [vcproj] $$@")
+	$(qexec)$$(GEN_VCPROJ)\
+            --exe\
+            --target=$$(TOOLCHAIN)\
+            --name=$$(@:.$(VCPROJ_SFX)=)\
+            --ver=$$(CONFIG_VS_VERSION)\
+            --proj-guid=$$($$(@:.$(VCPROJ_SFX)=).GUID)\
+            --src-path-bare="$(SRC_PATH_BARE)" \
+            $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \
+            --out=$$@ $$(INTERNAL_CFLAGS) $$(CFLAGS) \
+            $$(INTERNAL_LDFLAGS) $$(LDFLAGS) $$^
+endef
+TOOLS_BASENAME := $(notdir $(TOOLS))
+PROJECTS-$(CONFIG_MSVS) += $(TOOLS_BASENAME:.c=.$(VCPROJ_SFX))
+INSTALL-BINS-$(CONFIG_MSVS) += $(foreach p,$(VS_PLATFORMS),\
+                               $(addprefix bin/$(p)/,$(TOOLS_BASENAME:.c=.exe)))
+$(foreach proj,$(call enabled,PROJECTS),\
+    $(eval $(call vcproj_template,$(proj))))
new file mode 100644
--- /dev/null
+++ b/third_party/aom/tools/aom_entropy_optimizer.c
@@ -0,0 +1,570 @@
+/*
+ * Copyright (c) 2017, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+
+// This tool is a gadget for offline probability training.
+// A binary executable aom_entropy_optimizer will be generated in tools/. It
+// parses a binary file consisting of counts written in the format of
+// FRAME_COUNTS in entropymode.h, and computes the optimized probability table,
+// which will be written to a new c file optimized_probs.c according to format
+// of entropymode.c file.
+//
+// Command line: ./aom_entropy_optimizer [directory of the count file]
+//
+// The input file can either be generated by encoding a single clip by
+// turning on entropy_stats experiment, or be collected at a larger scale at
+// which a python script which will be provided soon can be used to aggregate
+// multiple stats output.
+
+#include <assert.h>
+#include <stdio.h>
+#include "./aom_config.h"
+#include "av1/common/entropymode.h"
+
+#if CONFIG_EC_ADAPT
+#if CONFIG_ALT_INTRA
+#if CONFIG_SMOOTH_HV
+const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
+  -DC_PRED,
+  2, /* 0 = DC_NODE */
+  -TM_PRED,
+  4, /* 1 = TM_NODE */
+  -V_PRED,
+  6, /* 2 = V_NODE */
+  8,
+  12, /* 3 = COM_NODE */
+  -H_PRED,
+  10, /* 4 = H_NODE */
+  -D135_PRED,
+  -D117_PRED, /* 5 = D135_NODE */
+  -D45_PRED,
+  14, /* 6 = D45_NODE */
+  -D63_PRED,
+  16, /* 7 = D63_NODE */
+  -D153_PRED,
+  18, /* 8 = D153_NODE */
+  -D207_PRED,
+  20, /* 9 = D207_NODE */
+  -SMOOTH_PRED,
+  22, /* 10 = SMOOTH_NODE */
+  -SMOOTH_V_PRED,
+  -SMOOTH_H_PRED /* 11 = SMOOTH_V_NODE */
+};
+#else
+const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
+  -DC_PRED,   2,            /* 0 = DC_NODE */
+  -TM_PRED,   4,            /* 1 = TM_NODE */
+  -V_PRED,    6,            /* 2 = V_NODE */
+  8,          12,           /* 3 = COM_NODE */
+  -H_PRED,    10,           /* 4 = H_NODE */
+  -D135_PRED, -D117_PRED,   /* 5 = D135_NODE */
+  -D45_PRED,  14,           /* 6 = D45_NODE */
+  -D63_PRED,  16,           /* 7 = D63_NODE */
+  -D153_PRED, 18,           /* 8 = D153_NODE */
+  -D207_PRED, -SMOOTH_PRED, /* 9 = D207_NODE */
+};
+#endif  // CONFIG_SMOOTH_HV
+#else
+const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
+  -DC_PRED,   2,          /* 0 = DC_NODE */
+  -TM_PRED,   4,          /* 1 = TM_NODE */
+  -V_PRED,    6,          /* 2 = V_NODE */
+  8,          12,         /* 3 = COM_NODE */
+  -H_PRED,    10,         /* 4 = H_NODE */
+  -D135_PRED, -D117_PRED, /* 5 = D135_NODE */
+  -D45_PRED,  14,         /* 6 = D45_NODE */
+  -D63_PRED,  16,         /* 7 = D63_NODE */
+  -D153_PRED, -D207_PRED  /* 8 = D153_NODE */
+};
+#endif  // CONFIG_ALT_INTRA
+#endif
+
+#define SPACES_PER_TAB 2
+
+typedef unsigned int aom_count_type;
+// A log file recording parsed counts
+static FILE *logfile;  // TODO(yuec): make it a command line option
+
+// Optimized probabilities will be stored in probs[].
+static INLINE unsigned int optimize_tree_probs(const aom_tree_index *tree,
+                                               unsigned int idx,
+                                               const unsigned int *counts,
+                                               aom_prob *probs) {
+  const int l = tree[idx];
+  const unsigned int left_count =
+      (l <= 0) ? counts[-l] : optimize_tree_probs(tree, l, counts, probs);
+  const int r = tree[idx + 1];
+  const unsigned int right_count =
+      (r <= 0) ? counts[-r] : optimize_tree_probs(tree, r, counts, probs);
+  probs[idx >> 1] = get_binary_prob(left_count, right_count);
+  return left_count + right_count;
+}
+
+static int parse_stats(aom_count_type **ct_ptr, FILE *const probsfile, int tabs,
+                       int dim_of_cts, int *cts_each_dim,
+                       const aom_tree_index *tree, int flatten_last_dim) {
+  if (dim_of_cts < 1) {
+    fprintf(stderr, "The dimension of a counts vector should be at least 1!\n");
+    return 1;
+  }
+  if (dim_of_cts == 1) {
+    const int total_modes = cts_each_dim[0];
+    aom_count_type *counts1d = *ct_ptr;
+    aom_prob *probs = aom_malloc(sizeof(*probs) * (total_modes - 1));
+
+    if (probs == NULL) {
+      fprintf(stderr, "Allocating prob array failed!\n");
+      return 1;
+    }
+
+    (*ct_ptr) += total_modes;
+    if (tree != NULL) {
+      optimize_tree_probs(tree, 0, counts1d, probs);
+    } else {
+      assert(total_modes == 2);
+      probs[0] = get_binary_prob(counts1d[0], counts1d[1]);
+    }
+    if (tabs > 0) fprintf(probsfile, "%*c", tabs * SPACES_PER_TAB, ' ');
+    for (int k = 0; k < total_modes - 1; ++k) {
+      fprintf(probsfile, " %3d,", probs[k]);
+      fprintf(logfile, "%d ", counts1d[k]);
+    }
+    fprintf(logfile, "%d\n", counts1d[total_modes - 1]);
+  } else if (dim_of_cts == 2 && flatten_last_dim) {
+    assert(cts_each_dim[1] == 2);
+
+    for (int k = 0; k < cts_each_dim[0]; ++k) {
+      fprintf(probsfile, " %3d,", get_binary_prob((*ct_ptr)[0], (*ct_ptr)[1]));
+      fprintf(logfile, "%d %d\n", (*ct_ptr)[0], (*ct_ptr)[1]);
+      (*ct_ptr) += 2;
+    }
+  } else {
+    for (int k = 0; k < cts_each_dim[0]; ++k) {
+      int tabs_next_level;
+      if (dim_of_cts == 2 || (dim_of_cts == 3 && flatten_last_dim)) {
+        fprintf(probsfile, "%*c{", tabs * SPACES_PER_TAB, ' ');
+        tabs_next_level = 0;
+      } else {
+        fprintf(probsfile, "%*c{\n", tabs * SPACES_PER_TAB, ' ');
+        tabs_next_level = tabs + 1;
+      }
+      if (parse_stats(ct_ptr, probsfile, tabs_next_level, dim_of_cts - 1,
+                      cts_each_dim + 1, tree, flatten_last_dim)) {
+        return 1;
+      }
+      if (dim_of_cts == 2 || (dim_of_cts == 3 && flatten_last_dim)) {
+        fprintf(probsfile, "},\n");
+      } else {
+        fprintf(probsfile, "%*c},\n", tabs * SPACES_PER_TAB, ' ');
+      }
+    }
+  }
+  return 0;
+}
+
+// This function parses the stats of a syntax, either binary or multi-symbol,
+// in different contexts, and writes the optimized probability table to
+// probsfile.
+//   counts: pointer of the first count element in counts array
+//   probsfile: output file
+//   dim_of_cts: number of dimensions of counts array
+//   cts_each_dim: an array storing size of each dimension of counts array
+//   tree: binary tree for a multi-symbol syntax, or NULL for a binary one
+//   flatten_last_dim: for a binary syntax, if flatten_last_dim is 0, probs in
+//                     different contexts will be written separately, e.g.,
+//                     {{p1}, {p2}, ...};
+//                     otherwise will be grouped together at the second last
+//                     dimension, i.e.,
+//                     {p1, p2, ...}.
+//   prefix: declaration header for the entropy table
+static void optimize_entropy_table(aom_count_type *counts,
+                                   FILE *const probsfile, int dim_of_cts,
+                                   int *cts_each_dim,
+                                   const aom_tree_index *tree,
+                                   int flatten_last_dim, char *prefix) {
+  aom_count_type *ct_ptr = counts;
+
+  assert(!flatten_last_dim || cts_each_dim[dim_of_cts - 1] == 2);
+
+  fprintf(probsfile, "%s = {\n", prefix);
+  if (parse_stats(&ct_ptr, probsfile, 1, dim_of_cts, cts_each_dim, tree,
+                  flatten_last_dim)) {
+    fprintf(probsfile, "Optimizer failed!\n");
+  }
+  fprintf(probsfile, "};\n\n");
+  fprintf(logfile, "\n");
+}
+
+int main(int argc, const char **argv) {
+  if (argc < 2) {
+    fprintf(stderr, "Please specify the input stats file!\n");
+    exit(EXIT_FAILURE);
+  }
+
+  FILE *const statsfile = fopen(argv[1], "rb");
+  if (statsfile == NULL) {
+    fprintf(stderr, "Failed to open input file!\n");
+    exit(EXIT_FAILURE);
+  }
+
+  FRAME_COUNTS fc;
+  fread(&fc, sizeof(FRAME_COUNTS), 1, statsfile);
+
+  FILE *const probsfile = fopen("optimized_probs.c", "w");
+  if (probsfile == NULL) {
+    fprintf(stderr,
+            "Failed to create output file for optimized entropy tables!\n");
+    exit(EXIT_FAILURE);
+  }
+
+  logfile = fopen("aom_entropy_optimizer_parsed_counts.log", "w");
+  if (logfile == NULL) {
+    fprintf(stderr, "Failed to create log file for parsed counts!\n");
+    exit(EXIT_FAILURE);
+  }
+
+  int cts_each_dim[10];
+
+  /* Intra mode (keyframe luma) */
+  cts_each_dim[0] = INTRA_MODES;
+  cts_each_dim[1] = INTRA_MODES;
+  cts_each_dim[2] = INTRA_MODES;
+  optimize_entropy_table(
+      &(fc.kf_y_mode[0][0][0]), probsfile, 3, cts_each_dim, av1_intra_mode_tree,
+      0,
+      "const aom_prob av1_kf_y_mode_prob[INTRA_MODES][INTRA_MODES]"
+      "[INTRA_MODES - 1]");
+
+  /* Intra mode (non-keyframe luma) */
+  cts_each_dim[0] = BLOCK_SIZE_GROUPS;
+  cts_each_dim[1] = INTRA_MODES;
+  optimize_entropy_table(
+      &(fc.y_mode[0][0]), probsfile, 2, cts_each_dim, av1_intra_mode_tree, 0,
+      "static const aom_prob default_if_y_probs[BLOCK_SIZE_GROUPS]"
+      "[INTRA_MODES - 1]");
+
+  /* Intra mode (chroma) */
+  cts_each_dim[0] = INTRA_MODES;
+  cts_each_dim[1] = INTRA_MODES;
+  optimize_entropy_table(&(fc.uv_mode[0][0]), probsfile, 2, cts_each_dim,
+                         av1_intra_mode_tree, 0,
+                         "static const aom_prob default_uv_probs[INTRA_MODES]"
+                         "[INTRA_MODES - 1]");
+
+  /* Partition */
+  cts_each_dim[0] = PARTITION_CONTEXTS;
+#if CONFIG_EXT_PARTITION_TYPES
+  cts_each_dim[1] = EXT_PARTITION_TYPES;
+  // TODO(yuec): Wrong prob for context = 0, because the old tree is used
+  optimize_entropy_table(&(fc.partition[0][0]), probsfile, 2, cts_each_dim,
+                         av1_ext_partition_tree, 0,
+                         "static const aom_prob default_partition_probs"
+                         "[PARTITION_CONTEXTS][EXT_PARTITION_TYPES - 1]");
+#else
+  cts_each_dim[1] = PARTITION_TYPES;
+  optimize_entropy_table(&(fc.partition[0][0]), probsfile, 2, cts_each_dim,
+                         av1_partition_tree, 0,
+                         "static const aom_prob default_partition_probs"
+                         "[PARTITION_CONTEXTS][PARTITION_TYPES - 1]");
+#endif
+
+  /* Interpolation filter */
+  cts_each_dim[0] = SWITCHABLE_FILTER_CONTEXTS;
+  cts_each_dim[1] = SWITCHABLE_FILTERS;
+  optimize_entropy_table(
+      &(fc.switchable_interp[0][0]), probsfile, 2, cts_each_dim,
+      av1_switchable_interp_tree, 0,
+      "static const aom_prob \n"
+      "default_switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]"
+      "[SWITCHABLE_FILTERS - 1]");
+
+  /* Blockzero */
+  cts_each_dim[0] = TX_SIZES;
+  cts_each_dim[1] = PLANE_TYPES;
+  cts_each_dim[2] = REF_TYPES;
+  cts_each_dim[3] = BLOCKZ_CONTEXTS;
+  cts_each_dim[4] = 2;
+  optimize_entropy_table(
+      &(fc.blockz_count[0][0][0][0][0]), probsfile, 5, cts_each_dim, NULL, 1,
+      "static const aom_prob av1_default_blockzero_probs[TX_SIZES]"
+      "[PLANE_TYPES][REF_TYPES][BLOCKZ_CONTEXTS]");
+
+  /* Motion vector referencing */
+  cts_each_dim[0] = NEWMV_MODE_CONTEXTS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(
+      &(fc.newmv_mode[0][0]), probsfile, 2, cts_each_dim, NULL, 1,
+      "static const aom_prob default_newmv_prob[NEWMV_MODE_CONTEXTS]");
+
+  cts_each_dim[0] = ZEROMV_MODE_CONTEXTS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(
+      &(fc.zeromv_mode[0][0]), probsfile, 2, cts_each_dim, NULL, 1,
+      "static const aom_prob default_zeromv_prob[ZEROMV_MODE_CONTEXTS]");
+
+  cts_each_dim[0] = REFMV_MODE_CONTEXTS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(
+      &(fc.refmv_mode[0][0]), probsfile, 2, cts_each_dim, NULL, 1,
+      "static const aom_prob default_refmv_prob[REFMV_MODE_CONTEXTS]");
+
+  cts_each_dim[0] = DRL_MODE_CONTEXTS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(
+      &(fc.drl_mode[0][0]), probsfile, 2, cts_each_dim, NULL, 1,
+      "static const aom_prob default_drl_prob[DRL_MODE_CONTEXTS]");
+
+/* ext_inter experiment */
+#if CONFIG_EXT_INTER
+  /* New compound mode */
+  cts_each_dim[0] = INTER_MODE_CONTEXTS;
+  cts_each_dim[1] = INTER_COMPOUND_MODES;
+  optimize_entropy_table(
+      &(fc.inter_compound_mode[0][0]), probsfile, 2, cts_each_dim,
+      av1_inter_compound_mode_tree, 0,
+      "static const aom_prob default_inter_compound_mode_probs\n"
+      "[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES - 1]");
+#if CONFIG_COMPOUND_SINGLEREF
+  /* Compound singleref mode */
+  cts_each_dim[0] = INTER_MODE_CONTEXTS;
+  cts_each_dim[1] = INTER_SINGLEREF_COMP_MODES;
+  optimize_entropy_table(
+      &(fc.inter_singleref_comp_mode[0][0]), probsfile, 2, cts_each_dim,
+      av1_inter_singleref_comp_mode_tree, 0,
+      "static const aom_prob default_inter_singleref_comp_mode_probs\n"
+      "[INTER_MODE_CONTEXTS][INTER_SINGLEREF_COMP_MODES - 1]");
+#endif
+#if CONFIG_INTERINTRA
+  /* Interintra */
+  cts_each_dim[0] = BLOCK_SIZE_GROUPS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(
+      &(fc.interintra[0][0]), probsfile, 2, cts_each_dim, NULL, 1,
+      "static const aom_prob default_interintra_prob[BLOCK_SIZE_GROUPS]");
+
+  cts_each_dim[0] = BLOCK_SIZE_GROUPS;
+  cts_each_dim[1] = INTERINTRA_MODES;
+  optimize_entropy_table(
+      &(fc.interintra_mode[0][0]), probsfile, 2, cts_each_dim,
+      av1_interintra_mode_tree, 0,
+      "static const aom_prob "
+      "default_interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1]");
+
+  cts_each_dim[0] = BLOCK_SIZES;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(
+      &(fc.wedge_interintra[0][0]), probsfile, 2, cts_each_dim, NULL, 1,
+      "static const aom_prob default_wedge_interintra_prob[BLOCK_SIZES]");
+#endif
+  /* Compound type */
+  cts_each_dim[0] = BLOCK_SIZES;
+  cts_each_dim[1] = COMPOUND_TYPES;
+  optimize_entropy_table(&(fc.compound_interinter[0][0]), probsfile, 2,
+                         cts_each_dim, av1_compound_type_tree, 0,
+                         "static const aom_prob default_compound_type_probs"
+                         "[BLOCK_SIZES][COMPOUND_TYPES - 1]");
+#endif
+
+/* motion_var and warped_motion experiments */
+#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
+  cts_each_dim[0] = BLOCK_SIZES;
+  cts_each_dim[1] = MOTION_MODES;
+  optimize_entropy_table(
+      &(fc.motion_mode[0][0]), probsfile, 2, cts_each_dim, av1_motion_mode_tree,
+      0,
+      "static const aom_prob default_motion_mode_prob[BLOCK_SIZES]"
+      "[MOTION_MODES - 1]");
+#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
+  cts_each_dim[0] = BLOCK_SIZES;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(
+      &(fc.obmc[0][0]), probsfile, 2, cts_each_dim, NULL, 1,
+      "static const aom_prob default_obmc_prob[BLOCK_SIZES]");
+#endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
+#endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
+
+  /* Intra/inter flag */
+  cts_each_dim[0] = INTRA_INTER_CONTEXTS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(&(fc.intra_inter[0][0]), probsfile, 2, cts_each_dim,
+                         NULL, 1,
+                         "static const aom_prob default_intra_inter_p"
+                         "[INTRA_INTER_CONTEXTS]");
+
+  /* Single/comp ref flag */
+  cts_each_dim[0] = COMP_INTER_CONTEXTS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(&(fc.comp_inter[0][0]), probsfile, 2, cts_each_dim,
+                         NULL, 1,
+                         "static const aom_prob default_comp_inter_p"
+                         "[COMP_INTER_CONTEXTS]");
+
+/* ext_comp_refs experiment */
+#if CONFIG_EXT_COMP_REFS
+  cts_each_dim[0] = COMP_REF_TYPE_CONTEXTS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(
+      &(fc.comp_ref_type[0][0]), probsfile, 2, cts_each_dim, NULL, 1,
+      "static const aom_prob default_comp_ref_type_p[COMP_REF_TYPE_CONTEXTS]");
+
+  cts_each_dim[0] = UNI_COMP_REF_CONTEXTS;
+  cts_each_dim[1] = UNIDIR_COMP_REFS - 1;
+  cts_each_dim[2] = 2;
+  optimize_entropy_table(
+      &(fc.uni_comp_ref[0][0][0]), probsfile, 3, cts_each_dim, NULL, 1,
+      "static const aom_prob\n"
+      "default_uni_comp_ref_p[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1]");
+#endif
+
+  /* Reference frame (single ref) */
+  cts_each_dim[0] = REF_CONTEXTS;
+  cts_each_dim[1] = SINGLE_REFS - 1;
+  cts_each_dim[2] = 2;
+  optimize_entropy_table(
+      &(fc.single_ref[0][0][0]), probsfile, 3, cts_each_dim, NULL, 1,
+      "static const aom_prob default_single_ref_p[REF_CONTEXTS]"
+      "[SINGLE_REFS - 1]");
+
+#if CONFIG_EXT_REFS
+  /* ext_refs experiment */
+  cts_each_dim[0] = REF_CONTEXTS;
+  cts_each_dim[1] = FWD_REFS - 1;
+  cts_each_dim[2] = 2;
+  optimize_entropy_table(
+      &(fc.comp_ref[0][0][0]), probsfile, 3, cts_each_dim, NULL, 1,
+      "static const aom_prob default_comp_ref_p[REF_CONTEXTS][FWD_REFS - 1]");
+
+  cts_each_dim[0] = REF_CONTEXTS;
+  cts_each_dim[1] = BWD_REFS - 1;
+  cts_each_dim[2] = 2;
+  optimize_entropy_table(&(fc.comp_bwdref[0][0][0]), probsfile, 3, cts_each_dim,
+                         NULL, 1,
+                         "static const aom_prob "
+                         "default_comp_bwdref_p[REF_CONTEXTS][BWD_REFS - 1]");
+#else
+  /* Reference frame (compound refs) */
+  cts_each_dim[0] = REF_CONTEXTS;
+  cts_each_dim[1] = COMP_REFS - 1;
+  cts_each_dim[2] = 2;
+  optimize_entropy_table(
+      &(fc.comp_ref[0][0][0]), probsfile, 3, cts_each_dim, NULL, 1,
+      "static const aom_prob default_comp_ref_p[REF_CONTEXTS]"
+      "[COMP_REFS - 1]");
+#endif  // CONFIG_EXT_REFS
+
+/* Compound single ref inter mode */
+#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
+  cts_each_dim[0] = COMP_INTER_MODE_CONTEXTS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(&(fc.comp_inter_mode[0][0]), probsfile, 2,
+                         cts_each_dim, NULL, 1,
+                         "static const aom_prob "
+                         "default_comp_inter_mode_p[COMP_INTER_MODE_CONTEXTS]");
+#endif
+
+/* Transform size */
+// TODO(yuec): av1_tx_size_tree has variable sizes, so needs special handling
+#if CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT
+  cts_each_dim[0] = 2;
+  optimize_entropy_table(&(fc.quarter_tx_size[0]), probsfile, 1, cts_each_dim,
+                         NULL, 1,
+                         "static const aom_prob default_quarter_tx_size_prob");
+#endif
+#if CONFIG_VAR_TX
+  cts_each_dim[0] = TXFM_PARTITION_CONTEXTS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(
+      &(fc.txfm_partition[0][0]), probsfile, 2, cts_each_dim, NULL, 1,
+      "static const aom_prob "
+      "default_txfm_partition_probs[TXFM_PARTITION_CONTEXTS]");
+#endif
+
+  /* Skip flag */
+  cts_each_dim[0] = SKIP_CONTEXTS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(
+      &(fc.skip[0][0]), probsfile, 2, cts_each_dim, NULL, 1,
+      "static const aom_prob default_skip_probs[SKIP_CONTEXTS]");
+
+/* intrabc experiment */
+#if CONFIG_INTRABC
+  cts_each_dim[0] = 2;
+  optimize_entropy_table(&(fc.intrabc[0]), probsfile, 1, cts_each_dim, NULL, 1,
+                         "INTRABC_PROB_DEFAULT");
+#endif
+
+/* delta_q experiment */
+#if CONFIG_DELTA_Q
+  cts_each_dim[0] = DELTA_Q_PROBS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(
+      &(fc.delta_q[0][0]), probsfile, 2, cts_each_dim, NULL, 1,
+      "static const aom_prob default_delta_q_probs[DELTA_Q_PROBS]");
+#if CONFIG_EXT_DELTA_Q
+  cts_each_dim[0] = DELTA_LF_PROBS;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(
+      &(fc.delta_lf[0][0]), probsfile, 2, cts_each_dim, NULL, 1,
+      "static const aom_prob default_delta_lf_probs[DELTA_LF_PROBS]");
+#endif
+#endif
+
+/* Transform type */
+#if CONFIG_EXT_TX
+// TODO(yuec): different trees are used depending on selected ext tx set
+#else
+  // TODO(yuec): intra_ext_tx use different trees depending on the context
+  cts_each_dim[0] = EXT_TX_SIZES;
+  cts_each_dim[1] = TX_TYPES;
+  optimize_entropy_table(&(fc.inter_ext_tx[0][0]), probsfile, 2, cts_each_dim,
+                         av1_ext_tx_tree, 0,
+                         "static const aom_prob default_inter_ext_tx_prob"
+                         "[EXT_TX_SIZES][TX_TYPES - 1]");
+#endif
+
+/* supertx experiment */
+#if CONFIG_SUPERTX
+  cts_each_dim[0] = PARTITION_SUPERTX_CONTEXTS;
+  cts_each_dim[1] = TX_SIZES;
+  cts_each_dim[2] = 2;
+  optimize_entropy_table(
+      &(fc.supertx[0][0][0]), probsfile, 3, cts_each_dim, NULL, 1,
+      "static const aom_prob\n"
+      "default_supertx_prob[PARTITION_SUPERTX_CONTEXTS][TX_SIZES]");
+#endif
+
+/* ext_intra experiment */
+#if CONFIG_EXT_INTRA
+#if CONFIG_INTRA_INTERP
+  cts_each_dim[0] = INTRA_FILTERS + 1;
+  cts_each_dim[1] = INTRA_FILTERS;
+  optimize_entropy_table(
+      &(fc.intra_filter[0][0]), probsfile, 2, cts_each_dim,
+      av1_intra_filter_tree, 0,
+      "static const aom_prob\n"
+      "default_intra_filter_probs[INTRA_FILTERS + 1][INTRA_FILTERS - 1]");
+#endif
+#endif
+
+/* filter_intra experiment */
+#if CONFIG_FILTER_INTRA
+  cts_each_dim[0] = PLANE_TYPES;
+  cts_each_dim[1] = 2;
+  optimize_entropy_table(&(fc.filter_intra[0][0]), probsfile, 2, cts_each_dim,
+                         NULL, 1,
+                         "static const aom_prob default_filter_intra_probs[2]");
+#endif
+
+  fclose(statsfile);
+  fclose(logfile);
+  fclose(probsfile);
+
+  return 0;
+}
--- a/third_party/aom/tools/build_inspector.sh
+++ b/third_party/aom/tools/build_inspector.sh
@@ -1,16 +1,50 @@
-if ! [ -x "$(command -v emcc)" ] || ! [ -x "$(command -v emconfigure)" ] || ! [ -x "$(command -v emmake)" ]; then
-  echo 'Emscripten SDK is not available (emcc, emconfigure or emmake is missing). Install it from https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html and try again.' >&2
+#!/bin/sh
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+
+if ! [ -x "$(command -v emcc)" ] \
+    || ! [ -x "$(command -v emconfigure)" ] \
+    || ! [ -x "$(command -v emmake)" ]; then
+  cat << EOF >& 2
+Emscripten SDK is not available (emcc, emconfigure or emmake is missing).
+Install it from
+https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html
+and try again.
+EOF
   exit 1
 fi
 
 echo 'Building JS Inspector'
 if [ ! -d ".inspect" ]; then
   mkdir .inspect
-  cd .inspect && emconfigure ../../configure --disable-multithread --disable-runtime-cpu-detect --target=generic-gnu --enable-accounting --disable-docs --disable-unit-tests --enable-inspection --enable-highbitdepth --extra-cflags="-D_POSIX_SOURCE"
+  cd .inspect && emconfigure ../../configure \
+    --disable-multithread \
+    --disable-runtime-cpu-detect \
+    --target=generic-gnu \
+    --enable-accounting \
+    --disable-docs \
+    --disable-unit-tests \
+    --enable-inspection \
+    --enable-highbitdepth \
+    --extra-cflags="-D_POSIX_SOURCE"
+  cd ..
 fi
 
 cd .inspect
 emmake make -j 8
 cp examples/inspect inspect.bc
-emcc -O3 inspect.bc -o inspect.js -s TOTAL_MEMORY=134217728 -s MODULARIZE=1 -s EXPORT_NAME="'DecoderModule'" --post-js "../inspect-post.js" --memory-init-file 0
+emcc -O3 inspect.bc -o inspect.js \
+  -s TOTAL_MEMORY=134217728 \
+  -s MODULARIZE=1 \
+  -s EXPORT_NAME="'DecoderModule'" \
+  --post-js "../inspect-post.js" \
+  --memory-init-file 0
 cp inspect.js ../inspect.js