1// Copyright 2019 The libgav1 Authors 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// This file contains all the scan order tables. 16 17constexpr uint16_t kDefaultScan4x4[16] = {0, 1, 4, 8, 5, 2, 3, 6, 18 9, 12, 13, 10, 7, 11, 14, 15}; 19 20constexpr uint16_t kColumnScan4x4[16] = {0, 4, 8, 12, 1, 5, 9, 13, 21 2, 6, 10, 14, 3, 7, 11, 15}; 22 23constexpr uint16_t kRowScan4x4[16] = {0, 1, 2, 3, 4, 5, 6, 7, 24 8, 9, 10, 11, 12, 13, 14, 15}; 25 26constexpr uint16_t kDefaultScan4x8[32] = { 27 0, 1, 4, 2, 5, 8, 3, 6, 9, 12, 7, 10, 13, 16, 11, 14, 28 17, 20, 15, 18, 21, 24, 19, 22, 25, 28, 23, 26, 29, 27, 30, 31}; 29 30constexpr uint16_t kColumnScan4x8[32] = { 31 0, 4, 8, 12, 16, 20, 24, 28, 1, 5, 9, 13, 17, 21, 25, 29, 32 2, 6, 10, 14, 18, 22, 26, 30, 3, 7, 11, 15, 19, 23, 27, 31}; 33 34constexpr uint16_t kRowScan4x8[32] = { 35 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 36 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; 37 38constexpr uint16_t kDefaultScan8x4[32] = { 39 0, 8, 1, 16, 9, 2, 24, 17, 10, 3, 25, 18, 11, 4, 26, 19, 40 12, 5, 27, 20, 13, 6, 28, 21, 14, 7, 29, 22, 15, 30, 23, 31}; 41 42constexpr uint16_t kColumnScan8x4[32] = { 43 0, 8, 16, 24, 1, 9, 17, 25, 2, 10, 18, 26, 3, 11, 19, 27, 44 4, 12, 20, 28, 5, 13, 21, 29, 6, 14, 22, 30, 7, 15, 23, 31}; 45 46constexpr uint16_t kRowScan8x4[32] = { 47 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 48 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; 49 50constexpr uint16_t kDefaultScan8x8[64] = { 51 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 52 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 53 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 54 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63}; 55 56constexpr uint16_t kColumnScan8x8[64] = { 57 0, 8, 16, 24, 32, 40, 48, 56, 1, 9, 17, 25, 33, 41, 49, 57, 58 2, 10, 18, 26, 34, 42, 50, 58, 3, 11, 19, 27, 35, 43, 51, 59, 59 4, 12, 20, 28, 36, 44, 52, 60, 5, 13, 21, 29, 37, 45, 53, 61, 60 6, 14, 22, 30, 38, 46, 54, 62, 7, 15, 23, 31, 39, 47, 55, 63}; 61 62constexpr uint16_t kRowScan8x8[64] = { 63 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 64 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 65 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 66 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}; 67 68constexpr uint16_t kDefaultScan8x16[128] = { 69 0, 1, 8, 2, 9, 16, 3, 10, 17, 24, 4, 11, 18, 25, 32, 70 5, 12, 19, 26, 33, 40, 6, 13, 20, 27, 34, 41, 48, 7, 14, 71 21, 28, 35, 42, 49, 56, 15, 22, 29, 36, 43, 50, 57, 64, 23, 72 30, 37, 44, 51, 58, 65, 72, 31, 38, 45, 52, 59, 66, 73, 80, 73 39, 46, 53, 60, 67, 74, 81, 88, 47, 54, 61, 68, 75, 82, 89, 74 96, 55, 62, 69, 76, 83, 90, 97, 104, 63, 70, 77, 84, 91, 98, 75 105, 112, 71, 78, 85, 92, 99, 106, 113, 120, 79, 86, 93, 100, 107, 76 114, 121, 87, 94, 101, 108, 115, 122, 95, 102, 109, 116, 123, 103, 110, 77 117, 124, 111, 118, 125, 119, 126, 127}; 78 79constexpr uint16_t kColumnScan8x16[128] = { 80 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 81 1, 9, 17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97, 105, 113, 121, 82 2, 10, 18, 26, 34, 42, 50, 58, 66, 74, 82, 90, 98, 106, 114, 122, 83 3, 11, 19, 27, 35, 43, 51, 59, 67, 75, 83, 91, 99, 107, 115, 123, 84 4, 12, 20, 28, 36, 44, 52, 60, 68, 76, 84, 92, 100, 108, 116, 124, 85 5, 13, 21, 29, 37, 45, 53, 61, 69, 77, 85, 93, 101, 109, 117, 125, 86 6, 14, 22, 30, 38, 46, 54, 62, 70, 78, 86, 94, 102, 110, 118, 126, 87 7, 15, 23, 31, 39, 47, 55, 63, 71, 79, 87, 95, 103, 111, 119, 127}; 88 89constexpr uint16_t kRowScan8x16[128] = { 90 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 91 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 92 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 93 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 94 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 95 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 96 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 97 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 98 120, 121, 122, 123, 124, 125, 126, 127}; 99 100constexpr uint16_t kDefaultScan16x8[128] = { 101 0, 16, 1, 32, 17, 2, 48, 33, 18, 3, 64, 49, 34, 19, 4, 80, 102 65, 50, 35, 20, 5, 96, 81, 66, 51, 36, 21, 6, 112, 97, 82, 67, 103 52, 37, 22, 7, 113, 98, 83, 68, 53, 38, 23, 8, 114, 99, 84, 69, 104 54, 39, 24, 9, 115, 100, 85, 70, 55, 40, 25, 10, 116, 101, 86, 71, 105 56, 41, 26, 11, 117, 102, 87, 72, 57, 42, 27, 12, 118, 103, 88, 73, 106 58, 43, 28, 13, 119, 104, 89, 74, 59, 44, 29, 14, 120, 105, 90, 75, 107 60, 45, 30, 15, 121, 106, 91, 76, 61, 46, 31, 122, 107, 92, 77, 62, 108 47, 123, 108, 93, 78, 63, 124, 109, 94, 79, 125, 110, 95, 126, 111, 127}; 109 110constexpr uint16_t kColumnScan16x8[128] = { 111 0, 16, 32, 48, 64, 80, 96, 112, 1, 17, 33, 49, 65, 81, 97, 113, 112 2, 18, 34, 50, 66, 82, 98, 114, 3, 19, 35, 51, 67, 83, 99, 115, 113 4, 20, 36, 52, 68, 84, 100, 116, 5, 21, 37, 53, 69, 85, 101, 117, 114 6, 22, 38, 54, 70, 86, 102, 118, 7, 23, 39, 55, 71, 87, 103, 119, 115 8, 24, 40, 56, 72, 88, 104, 120, 9, 25, 41, 57, 73, 89, 105, 121, 116 10, 26, 42, 58, 74, 90, 106, 122, 11, 27, 43, 59, 75, 91, 107, 123, 117 12, 28, 44, 60, 76, 92, 108, 124, 13, 29, 45, 61, 77, 93, 109, 125, 118 14, 30, 46, 62, 78, 94, 110, 126, 15, 31, 47, 63, 79, 95, 111, 127}; 119 120constexpr uint16_t kRowScan16x8[128] = { 121 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 122 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 123 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 124 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 125 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 126 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 127 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 128 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 129 120, 121, 122, 123, 124, 125, 126, 127}; 130 131constexpr uint16_t kDefaultScan16x16[256] = { 132 0, 1, 16, 32, 17, 2, 3, 18, 33, 48, 64, 49, 34, 19, 4, 133 5, 20, 35, 50, 65, 80, 96, 81, 66, 51, 36, 21, 6, 7, 22, 134 37, 52, 67, 82, 97, 112, 128, 113, 98, 83, 68, 53, 38, 23, 8, 135 9, 24, 39, 54, 69, 84, 99, 114, 129, 144, 160, 145, 130, 115, 100, 136 85, 70, 55, 40, 25, 10, 11, 26, 41, 56, 71, 86, 101, 116, 131, 137 146, 161, 176, 192, 177, 162, 147, 132, 117, 102, 87, 72, 57, 42, 27, 138 12, 13, 28, 43, 58, 73, 88, 103, 118, 133, 148, 163, 178, 193, 208, 139 224, 209, 194, 179, 164, 149, 134, 119, 104, 89, 74, 59, 44, 29, 14, 140 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 141 240, 241, 226, 211, 196, 181, 166, 151, 136, 121, 106, 91, 76, 61, 46, 142 31, 47, 62, 77, 92, 107, 122, 137, 152, 167, 182, 197, 212, 227, 242, 143 243, 228, 213, 198, 183, 168, 153, 138, 123, 108, 93, 78, 63, 79, 94, 144 109, 124, 139, 154, 169, 184, 199, 214, 229, 244, 245, 230, 215, 200, 185, 145 170, 155, 140, 125, 110, 95, 111, 126, 141, 156, 171, 186, 201, 216, 231, 146 246, 247, 232, 217, 202, 187, 172, 157, 142, 127, 143, 158, 173, 188, 203, 147 218, 233, 248, 249, 234, 219, 204, 189, 174, 159, 175, 190, 205, 220, 235, 148 250, 251, 236, 221, 206, 191, 207, 222, 237, 252, 253, 238, 223, 239, 254, 149 255}; 150 151constexpr uint16_t kColumnScan16x16[256] = { 152 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 153 1, 17, 33, 49, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241, 154 2, 18, 34, 50, 66, 82, 98, 114, 130, 146, 162, 178, 194, 210, 226, 242, 155 3, 19, 35, 51, 67, 83, 99, 115, 131, 147, 163, 179, 195, 211, 227, 243, 156 4, 20, 36, 52, 68, 84, 100, 116, 132, 148, 164, 180, 196, 212, 228, 244, 157 5, 21, 37, 53, 69, 85, 101, 117, 133, 149, 165, 181, 197, 213, 229, 245, 158 6, 22, 38, 54, 70, 86, 102, 118, 134, 150, 166, 182, 198, 214, 230, 246, 159 7, 23, 39, 55, 71, 87, 103, 119, 135, 151, 167, 183, 199, 215, 231, 247, 160 8, 24, 40, 56, 72, 88, 104, 120, 136, 152, 168, 184, 200, 216, 232, 248, 161 9, 25, 41, 57, 73, 89, 105, 121, 137, 153, 169, 185, 201, 217, 233, 249, 162 10, 26, 42, 58, 74, 90, 106, 122, 138, 154, 170, 186, 202, 218, 234, 250, 163 11, 27, 43, 59, 75, 91, 107, 123, 139, 155, 171, 187, 203, 219, 235, 251, 164 12, 28, 44, 60, 76, 92, 108, 124, 140, 156, 172, 188, 204, 220, 236, 252, 165 13, 29, 45, 61, 77, 93, 109, 125, 141, 157, 173, 189, 205, 221, 237, 253, 166 14, 30, 46, 62, 78, 94, 110, 126, 142, 158, 174, 190, 206, 222, 238, 254, 167 15, 31, 47, 63, 79, 95, 111, 127, 143, 159, 175, 191, 207, 223, 239, 255}; 168 169constexpr uint16_t kRowScan16x16[256] = { 170 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 171 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 172 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 173 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 174 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 175 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 176 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 177 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 178 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 179 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 180 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 181 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 182 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 183 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 184 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 185 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 186 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 187 255}; 188 189constexpr uint16_t kDefaultScan16x32[512] = { 190 0, 1, 16, 2, 17, 32, 3, 18, 33, 48, 4, 19, 34, 49, 64, 191 5, 20, 35, 50, 65, 80, 6, 21, 36, 51, 66, 81, 96, 7, 22, 192 37, 52, 67, 82, 97, 112, 8, 23, 38, 53, 68, 83, 98, 113, 128, 193 9, 24, 39, 54, 69, 84, 99, 114, 129, 144, 10, 25, 40, 55, 70, 194 85, 100, 115, 130, 145, 160, 11, 26, 41, 56, 71, 86, 101, 116, 131, 195 146, 161, 176, 12, 27, 42, 57, 72, 87, 102, 117, 132, 147, 162, 177, 196 192, 13, 28, 43, 58, 73, 88, 103, 118, 133, 148, 163, 178, 193, 208, 197 14, 29, 44, 59, 74, 89, 104, 119, 134, 149, 164, 179, 194, 209, 224, 198 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 199 240, 31, 46, 61, 76, 91, 106, 121, 136, 151, 166, 181, 196, 211, 226, 200 241, 256, 47, 62, 77, 92, 107, 122, 137, 152, 167, 182, 197, 212, 227, 201 242, 257, 272, 63, 78, 93, 108, 123, 138, 153, 168, 183, 198, 213, 228, 202 243, 258, 273, 288, 79, 94, 109, 124, 139, 154, 169, 184, 199, 214, 229, 203 244, 259, 274, 289, 304, 95, 110, 125, 140, 155, 170, 185, 200, 215, 230, 204 245, 260, 275, 290, 305, 320, 111, 126, 141, 156, 171, 186, 201, 216, 231, 205 246, 261, 276, 291, 306, 321, 336, 127, 142, 157, 172, 187, 202, 217, 232, 206 247, 262, 277, 292, 307, 322, 337, 352, 143, 158, 173, 188, 203, 218, 233, 207 248, 263, 278, 293, 308, 323, 338, 353, 368, 159, 174, 189, 204, 219, 234, 208 249, 264, 279, 294, 309, 324, 339, 354, 369, 384, 175, 190, 205, 220, 235, 209 250, 265, 280, 295, 310, 325, 340, 355, 370, 385, 400, 191, 206, 221, 236, 210 251, 266, 281, 296, 311, 326, 341, 356, 371, 386, 401, 416, 207, 222, 237, 211 252, 267, 282, 297, 312, 327, 342, 357, 372, 387, 402, 417, 432, 223, 238, 212 253, 268, 283, 298, 313, 328, 343, 358, 373, 388, 403, 418, 433, 448, 239, 213 254, 269, 284, 299, 314, 329, 344, 359, 374, 389, 404, 419, 434, 449, 464, 214 255, 270, 285, 300, 315, 330, 345, 360, 375, 390, 405, 420, 435, 450, 465, 215 480, 271, 286, 301, 316, 331, 346, 361, 376, 391, 406, 421, 436, 451, 466, 216 481, 496, 287, 302, 317, 332, 347, 362, 377, 392, 407, 422, 437, 452, 467, 217 482, 497, 303, 318, 333, 348, 363, 378, 393, 408, 423, 438, 453, 468, 483, 218 498, 319, 334, 349, 364, 379, 394, 409, 424, 439, 454, 469, 484, 499, 335, 219 350, 365, 380, 395, 410, 425, 440, 455, 470, 485, 500, 351, 366, 381, 396, 220 411, 426, 441, 456, 471, 486, 501, 367, 382, 397, 412, 427, 442, 457, 472, 221 487, 502, 383, 398, 413, 428, 443, 458, 473, 488, 503, 399, 414, 429, 444, 222 459, 474, 489, 504, 415, 430, 445, 460, 475, 490, 505, 431, 446, 461, 476, 223 491, 506, 447, 462, 477, 492, 507, 463, 478, 493, 508, 479, 494, 509, 495, 224 510, 511}; 225 226constexpr uint16_t kDefaultScan32x16[512] = { 227 0, 32, 1, 64, 33, 2, 96, 65, 34, 3, 128, 97, 66, 35, 4, 228 160, 129, 98, 67, 36, 5, 192, 161, 130, 99, 68, 37, 6, 224, 193, 229 162, 131, 100, 69, 38, 7, 256, 225, 194, 163, 132, 101, 70, 39, 8, 230 288, 257, 226, 195, 164, 133, 102, 71, 40, 9, 320, 289, 258, 227, 196, 231 165, 134, 103, 72, 41, 10, 352, 321, 290, 259, 228, 197, 166, 135, 104, 232 73, 42, 11, 384, 353, 322, 291, 260, 229, 198, 167, 136, 105, 74, 43, 233 12, 416, 385, 354, 323, 292, 261, 230, 199, 168, 137, 106, 75, 44, 13, 234 448, 417, 386, 355, 324, 293, 262, 231, 200, 169, 138, 107, 76, 45, 14, 235 480, 449, 418, 387, 356, 325, 294, 263, 232, 201, 170, 139, 108, 77, 46, 236 15, 481, 450, 419, 388, 357, 326, 295, 264, 233, 202, 171, 140, 109, 78, 237 47, 16, 482, 451, 420, 389, 358, 327, 296, 265, 234, 203, 172, 141, 110, 238 79, 48, 17, 483, 452, 421, 390, 359, 328, 297, 266, 235, 204, 173, 142, 239 111, 80, 49, 18, 484, 453, 422, 391, 360, 329, 298, 267, 236, 205, 174, 240 143, 112, 81, 50, 19, 485, 454, 423, 392, 361, 330, 299, 268, 237, 206, 241 175, 144, 113, 82, 51, 20, 486, 455, 424, 393, 362, 331, 300, 269, 238, 242 207, 176, 145, 114, 83, 52, 21, 487, 456, 425, 394, 363, 332, 301, 270, 243 239, 208, 177, 146, 115, 84, 53, 22, 488, 457, 426, 395, 364, 333, 302, 244 271, 240, 209, 178, 147, 116, 85, 54, 23, 489, 458, 427, 396, 365, 334, 245 303, 272, 241, 210, 179, 148, 117, 86, 55, 24, 490, 459, 428, 397, 366, 246 335, 304, 273, 242, 211, 180, 149, 118, 87, 56, 25, 491, 460, 429, 398, 247 367, 336, 305, 274, 243, 212, 181, 150, 119, 88, 57, 26, 492, 461, 430, 248 399, 368, 337, 306, 275, 244, 213, 182, 151, 120, 89, 58, 27, 493, 462, 249 431, 400, 369, 338, 307, 276, 245, 214, 183, 152, 121, 90, 59, 28, 494, 250 463, 432, 401, 370, 339, 308, 277, 246, 215, 184, 153, 122, 91, 60, 29, 251 495, 464, 433, 402, 371, 340, 309, 278, 247, 216, 185, 154, 123, 92, 61, 252 30, 496, 465, 434, 403, 372, 341, 310, 279, 248, 217, 186, 155, 124, 93, 253 62, 31, 497, 466, 435, 404, 373, 342, 311, 280, 249, 218, 187, 156, 125, 254 94, 63, 498, 467, 436, 405, 374, 343, 312, 281, 250, 219, 188, 157, 126, 255 95, 499, 468, 437, 406, 375, 344, 313, 282, 251, 220, 189, 158, 127, 500, 256 469, 438, 407, 376, 345, 314, 283, 252, 221, 190, 159, 501, 470, 439, 408, 257 377, 346, 315, 284, 253, 222, 191, 502, 471, 440, 409, 378, 347, 316, 285, 258 254, 223, 503, 472, 441, 410, 379, 348, 317, 286, 255, 504, 473, 442, 411, 259 380, 349, 318, 287, 505, 474, 443, 412, 381, 350, 319, 506, 475, 444, 413, 260 382, 351, 507, 476, 445, 414, 383, 508, 477, 446, 415, 509, 478, 447, 510, 261 479, 511}; 262 263constexpr uint16_t kDefaultScan32x32[1024] = { 264 0, 1, 32, 64, 33, 2, 3, 34, 65, 96, 128, 97, 66, 265 35, 4, 5, 36, 67, 98, 129, 160, 192, 161, 130, 99, 68, 266 37, 6, 7, 38, 69, 100, 131, 162, 193, 224, 256, 225, 194, 267 163, 132, 101, 70, 39, 8, 9, 40, 71, 102, 133, 164, 195, 268 226, 257, 288, 320, 289, 258, 227, 196, 165, 134, 103, 72, 41, 269 10, 11, 42, 73, 104, 135, 166, 197, 228, 259, 290, 321, 352, 270 384, 353, 322, 291, 260, 229, 198, 167, 136, 105, 74, 43, 12, 271 13, 44, 75, 106, 137, 168, 199, 230, 261, 292, 323, 354, 385, 272 416, 448, 417, 386, 355, 324, 293, 262, 231, 200, 169, 138, 107, 273 76, 45, 14, 15, 46, 77, 108, 139, 170, 201, 232, 263, 294, 274 325, 356, 387, 418, 449, 480, 512, 481, 450, 419, 388, 357, 326, 275 295, 264, 233, 202, 171, 140, 109, 78, 47, 16, 17, 48, 79, 276 110, 141, 172, 203, 234, 265, 296, 327, 358, 389, 420, 451, 482, 277 513, 544, 576, 545, 514, 483, 452, 421, 390, 359, 328, 297, 266, 278 235, 204, 173, 142, 111, 80, 49, 18, 19, 50, 81, 112, 143, 279 174, 205, 236, 267, 298, 329, 360, 391, 422, 453, 484, 515, 546, 280 577, 608, 640, 609, 578, 547, 516, 485, 454, 423, 392, 361, 330, 281 299, 268, 237, 206, 175, 144, 113, 82, 51, 20, 21, 52, 83, 282 114, 145, 176, 207, 238, 269, 300, 331, 362, 393, 424, 455, 486, 283 517, 548, 579, 610, 641, 672, 704, 673, 642, 611, 580, 549, 518, 284 487, 456, 425, 394, 363, 332, 301, 270, 239, 208, 177, 146, 115, 285 84, 53, 22, 23, 54, 85, 116, 147, 178, 209, 240, 271, 302, 286 333, 364, 395, 426, 457, 488, 519, 550, 581, 612, 643, 674, 705, 287 736, 768, 737, 706, 675, 644, 613, 582, 551, 520, 489, 458, 427, 288 396, 365, 334, 303, 272, 241, 210, 179, 148, 117, 86, 55, 24, 289 25, 56, 87, 118, 149, 180, 211, 242, 273, 304, 335, 366, 397, 290 428, 459, 490, 521, 552, 583, 614, 645, 676, 707, 738, 769, 800, 291 832, 801, 770, 739, 708, 677, 646, 615, 584, 553, 522, 491, 460, 292 429, 398, 367, 336, 305, 274, 243, 212, 181, 150, 119, 88, 57, 293 26, 27, 58, 89, 120, 151, 182, 213, 244, 275, 306, 337, 368, 294 399, 430, 461, 492, 523, 554, 585, 616, 647, 678, 709, 740, 771, 295 802, 833, 864, 896, 865, 834, 803, 772, 741, 710, 679, 648, 617, 296 586, 555, 524, 493, 462, 431, 400, 369, 338, 307, 276, 245, 214, 297 183, 152, 121, 90, 59, 28, 29, 60, 91, 122, 153, 184, 215, 298 246, 277, 308, 339, 370, 401, 432, 463, 494, 525, 556, 587, 618, 299 649, 680, 711, 742, 773, 804, 835, 866, 897, 928, 960, 929, 898, 300 867, 836, 805, 774, 743, 712, 681, 650, 619, 588, 557, 526, 495, 301 464, 433, 402, 371, 340, 309, 278, 247, 216, 185, 154, 123, 92, 302 61, 30, 31, 62, 93, 124, 155, 186, 217, 248, 279, 310, 341, 303 372, 403, 434, 465, 496, 527, 558, 589, 620, 651, 682, 713, 744, 304 775, 806, 837, 868, 899, 930, 961, 992, 993, 962, 931, 900, 869, 305 838, 807, 776, 745, 714, 683, 652, 621, 590, 559, 528, 497, 466, 306 435, 404, 373, 342, 311, 280, 249, 218, 187, 156, 125, 94, 63, 307 95, 126, 157, 188, 219, 250, 281, 312, 343, 374, 405, 436, 467, 308 498, 529, 560, 591, 622, 653, 684, 715, 746, 777, 808, 839, 870, 309 901, 932, 963, 994, 995, 964, 933, 902, 871, 840, 809, 778, 747, 310 716, 685, 654, 623, 592, 561, 530, 499, 468, 437, 406, 375, 344, 311 313, 282, 251, 220, 189, 158, 127, 159, 190, 221, 252, 283, 314, 312 345, 376, 407, 438, 469, 500, 531, 562, 593, 624, 655, 686, 717, 313 748, 779, 810, 841, 872, 903, 934, 965, 996, 997, 966, 935, 904, 314 873, 842, 811, 780, 749, 718, 687, 656, 625, 594, 563, 532, 501, 315 470, 439, 408, 377, 346, 315, 284, 253, 222, 191, 223, 254, 285, 316 316, 347, 378, 409, 440, 471, 502, 533, 564, 595, 626, 657, 688, 317 719, 750, 781, 812, 843, 874, 905, 936, 967, 998, 999, 968, 937, 318 906, 875, 844, 813, 782, 751, 720, 689, 658, 627, 596, 565, 534, 319 503, 472, 441, 410, 379, 348, 317, 286, 255, 287, 318, 349, 380, 320 411, 442, 473, 504, 535, 566, 597, 628, 659, 690, 721, 752, 783, 321 814, 845, 876, 907, 938, 969, 1000, 1001, 970, 939, 908, 877, 846, 322 815, 784, 753, 722, 691, 660, 629, 598, 567, 536, 505, 474, 443, 323 412, 381, 350, 319, 351, 382, 413, 444, 475, 506, 537, 568, 599, 324 630, 661, 692, 723, 754, 785, 816, 847, 878, 909, 940, 971, 1002, 325 1003, 972, 941, 910, 879, 848, 817, 786, 755, 724, 693, 662, 631, 326 600, 569, 538, 507, 476, 445, 414, 383, 415, 446, 477, 508, 539, 327 570, 601, 632, 663, 694, 725, 756, 787, 818, 849, 880, 911, 942, 328 973, 1004, 1005, 974, 943, 912, 881, 850, 819, 788, 757, 726, 695, 329 664, 633, 602, 571, 540, 509, 478, 447, 479, 510, 541, 572, 603, 330 634, 665, 696, 727, 758, 789, 820, 851, 882, 913, 944, 975, 1006, 331 1007, 976, 945, 914, 883, 852, 821, 790, 759, 728, 697, 666, 635, 332 604, 573, 542, 511, 543, 574, 605, 636, 667, 698, 729, 760, 791, 333 822, 853, 884, 915, 946, 977, 1008, 1009, 978, 947, 916, 885, 854, 334 823, 792, 761, 730, 699, 668, 637, 606, 575, 607, 638, 669, 700, 335 731, 762, 793, 824, 855, 886, 917, 948, 979, 1010, 1011, 980, 949, 336 918, 887, 856, 825, 794, 763, 732, 701, 670, 639, 671, 702, 733, 337 764, 795, 826, 857, 888, 919, 950, 981, 1012, 1013, 982, 951, 920, 338 889, 858, 827, 796, 765, 734, 703, 735, 766, 797, 828, 859, 890, 339 921, 952, 983, 1014, 1015, 984, 953, 922, 891, 860, 829, 798, 767, 340 799, 830, 861, 892, 923, 954, 985, 1016, 1017, 986, 955, 924, 893, 341 862, 831, 863, 894, 925, 956, 987, 1018, 1019, 988, 957, 926, 895, 342 927, 958, 989, 1020, 1021, 990, 959, 991, 1022, 1023}; 343 344constexpr uint16_t kDefaultScan4x16[64] = { 345 0, 1, 4, 2, 5, 8, 3, 6, 9, 12, 7, 10, 13, 16, 11, 14, 346 17, 20, 15, 18, 21, 24, 19, 22, 25, 28, 23, 26, 29, 32, 27, 30, 347 33, 36, 31, 34, 37, 40, 35, 38, 41, 44, 39, 42, 45, 48, 43, 46, 348 49, 52, 47, 50, 53, 56, 51, 54, 57, 60, 55, 58, 61, 59, 62, 63}; 349 350constexpr uint16_t kColumnScan4x16[64] = { 351 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 352 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 353 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 354 3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63}; 355 356constexpr uint16_t kRowScan4x16[64] = { 357 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 358 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 359 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 360 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}; 361 362constexpr uint16_t kDefaultScan16x4[64] = { 363 0, 16, 1, 32, 17, 2, 48, 33, 18, 3, 49, 34, 19, 4, 50, 35, 364 20, 5, 51, 36, 21, 6, 52, 37, 22, 7, 53, 38, 23, 8, 54, 39, 365 24, 9, 55, 40, 25, 10, 56, 41, 26, 11, 57, 42, 27, 12, 58, 43, 366 28, 13, 59, 44, 29, 14, 60, 45, 30, 15, 61, 46, 31, 62, 47, 63}; 367 368constexpr uint16_t kColumnScan16x4[64] = { 369 0, 16, 32, 48, 1, 17, 33, 49, 2, 18, 34, 50, 3, 19, 35, 51, 370 4, 20, 36, 52, 5, 21, 37, 53, 6, 22, 38, 54, 7, 23, 39, 55, 371 8, 24, 40, 56, 9, 25, 41, 57, 10, 26, 42, 58, 11, 27, 43, 59, 372 12, 28, 44, 60, 13, 29, 45, 61, 14, 30, 46, 62, 15, 31, 47, 63}; 373 374constexpr uint16_t kRowScan16x4[64] = { 375 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 376 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 377 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 378 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}; 379 380constexpr uint16_t kDefaultScan8x32[256] = { 381 0, 1, 8, 2, 9, 16, 3, 10, 17, 24, 4, 11, 18, 25, 32, 382 5, 12, 19, 26, 33, 40, 6, 13, 20, 27, 34, 41, 48, 7, 14, 383 21, 28, 35, 42, 49, 56, 15, 22, 29, 36, 43, 50, 57, 64, 23, 384 30, 37, 44, 51, 58, 65, 72, 31, 38, 45, 52, 59, 66, 73, 80, 385 39, 46, 53, 60, 67, 74, 81, 88, 47, 54, 61, 68, 75, 82, 89, 386 96, 55, 62, 69, 76, 83, 90, 97, 104, 63, 70, 77, 84, 91, 98, 387 105, 112, 71, 78, 85, 92, 99, 106, 113, 120, 79, 86, 93, 100, 107, 388 114, 121, 128, 87, 94, 101, 108, 115, 122, 129, 136, 95, 102, 109, 116, 389 123, 130, 137, 144, 103, 110, 117, 124, 131, 138, 145, 152, 111, 118, 125, 390 132, 139, 146, 153, 160, 119, 126, 133, 140, 147, 154, 161, 168, 127, 134, 391 141, 148, 155, 162, 169, 176, 135, 142, 149, 156, 163, 170, 177, 184, 143, 392 150, 157, 164, 171, 178, 185, 192, 151, 158, 165, 172, 179, 186, 193, 200, 393 159, 166, 173, 180, 187, 194, 201, 208, 167, 174, 181, 188, 195, 202, 209, 394 216, 175, 182, 189, 196, 203, 210, 217, 224, 183, 190, 197, 204, 211, 218, 395 225, 232, 191, 198, 205, 212, 219, 226, 233, 240, 199, 206, 213, 220, 227, 396 234, 241, 248, 207, 214, 221, 228, 235, 242, 249, 215, 222, 229, 236, 243, 397 250, 223, 230, 237, 244, 251, 231, 238, 245, 252, 239, 246, 253, 247, 254, 398 255}; 399 400constexpr uint16_t kDefaultScan32x8[256] = { 401 0, 32, 1, 64, 33, 2, 96, 65, 34, 3, 128, 97, 66, 35, 4, 402 160, 129, 98, 67, 36, 5, 192, 161, 130, 99, 68, 37, 6, 224, 193, 403 162, 131, 100, 69, 38, 7, 225, 194, 163, 132, 101, 70, 39, 8, 226, 404 195, 164, 133, 102, 71, 40, 9, 227, 196, 165, 134, 103, 72, 41, 10, 405 228, 197, 166, 135, 104, 73, 42, 11, 229, 198, 167, 136, 105, 74, 43, 406 12, 230, 199, 168, 137, 106, 75, 44, 13, 231, 200, 169, 138, 107, 76, 407 45, 14, 232, 201, 170, 139, 108, 77, 46, 15, 233, 202, 171, 140, 109, 408 78, 47, 16, 234, 203, 172, 141, 110, 79, 48, 17, 235, 204, 173, 142, 409 111, 80, 49, 18, 236, 205, 174, 143, 112, 81, 50, 19, 237, 206, 175, 410 144, 113, 82, 51, 20, 238, 207, 176, 145, 114, 83, 52, 21, 239, 208, 411 177, 146, 115, 84, 53, 22, 240, 209, 178, 147, 116, 85, 54, 23, 241, 412 210, 179, 148, 117, 86, 55, 24, 242, 211, 180, 149, 118, 87, 56, 25, 413 243, 212, 181, 150, 119, 88, 57, 26, 244, 213, 182, 151, 120, 89, 58, 414 27, 245, 214, 183, 152, 121, 90, 59, 28, 246, 215, 184, 153, 122, 91, 415 60, 29, 247, 216, 185, 154, 123, 92, 61, 30, 248, 217, 186, 155, 124, 416 93, 62, 31, 249, 218, 187, 156, 125, 94, 63, 250, 219, 188, 157, 126, 417 95, 251, 220, 189, 158, 127, 252, 221, 190, 159, 253, 222, 191, 254, 223, 418 255}; 419 420// 5.11.41 (implemented as a simple look up of transform class and transform 421// size). 422const uint16_t* kScan[3][kNumTransformSizes] = { 423 // kTransformClass2D 424 {kDefaultScan4x4, kDefaultScan4x8, kDefaultScan4x16, kDefaultScan8x4, 425 kDefaultScan8x8, kDefaultScan8x16, kDefaultScan8x32, kDefaultScan16x4, 426 kDefaultScan16x8, kDefaultScan16x16, kDefaultScan16x32, kDefaultScan16x32, 427 kDefaultScan32x8, kDefaultScan32x16, kDefaultScan32x32, kDefaultScan32x32, 428 kDefaultScan32x16, kDefaultScan32x32, kDefaultScan32x32}, 429 // kTransformClassHorizontal 430 {kColumnScan4x4, kColumnScan4x8, kColumnScan4x16, kColumnScan8x4, 431 kColumnScan8x8, kColumnScan8x16, kColumnScan16x4, kColumnScan16x4, 432 kColumnScan16x8, kColumnScan16x16, kColumnScan16x4, kDefaultScan16x32, 433 kColumnScan16x4, kColumnScan16x4, kColumnScan16x4, kDefaultScan32x32, 434 kDefaultScan32x16, kDefaultScan32x32, kDefaultScan32x32}, 435 // kTransformClassVertical 436 {kRowScan4x4, kRowScan4x8, kRowScan4x16, kRowScan8x4, kRowScan8x8, 437 kRowScan8x16, kRowScan16x4, kRowScan16x4, kRowScan16x8, kRowScan16x16, 438 kRowScan16x4, kDefaultScan16x32, kRowScan16x4, kRowScan16x4, kRowScan16x4, 439 kDefaultScan32x32, kDefaultScan32x16, kDefaultScan32x32, 440 kDefaultScan32x32}}; 441