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 #include "src/utils/constants.h" 16 17 namespace libgav1 { 18 19 const uint8_t k4x4WidthLog2[kMaxBlockSizes] = {0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 20 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5}; 21 22 const uint8_t k4x4HeightLog2[kMaxBlockSizes] = { 23 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 4, 2, 3, 4, 5, 4, 5}; 24 25 const uint8_t kNum4x4BlocksWide[kMaxBlockSizes] = { 26 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 32, 32}; 27 28 const uint8_t kNum4x4BlocksHigh[kMaxBlockSizes] = { 29 1, 2, 4, 1, 2, 4, 8, 1, 2, 4, 8, 16, 2, 4, 8, 16, 4, 8, 16, 32, 16, 32}; 30 31 const uint8_t kBlockWidthPixels[kMaxBlockSizes] = { 32 4, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 33 16, 32, 32, 32, 32, 64, 64, 64, 64, 128, 128}; 34 35 const uint8_t kBlockHeightPixels[kMaxBlockSizes] = { 36 4, 8, 16, 4, 8, 16, 32, 4, 8, 16, 32, 37 64, 8, 16, 32, 64, 16, 32, 64, 128, 64, 128}; 38 39 // 9.3 -- Partition_Subsize[] 40 const BlockSize kSubSize[kMaxPartitionTypes][kMaxBlockSizes] = { 41 // kPartitionNone 42 {kBlock4x4, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock8x8, 43 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock16x16, 44 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock32x32, 45 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock64x64, kBlockInvalid, 46 kBlockInvalid, kBlock128x128}, 47 // kPartitionHorizontal 48 {kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock8x4, 49 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock16x8, 50 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock32x16, 51 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock64x32, kBlockInvalid, 52 kBlockInvalid, kBlock128x64}, 53 // kPartitionVertical 54 {kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock4x8, 55 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock8x16, 56 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock16x32, 57 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock32x64, kBlockInvalid, 58 kBlockInvalid, kBlock64x128}, 59 // kPartitionSplit 60 {kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock4x4, 61 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock8x8, 62 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock16x16, 63 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock32x32, kBlockInvalid, 64 kBlockInvalid, kBlock64x64}, 65 // kPartitionHorizontalWithTopSplit 66 {kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock8x4, 67 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock16x8, 68 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock32x16, 69 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock64x32, kBlockInvalid, 70 kBlockInvalid, kBlock128x64}, 71 // kPartitionHorizontalWithBottomSplit 72 {kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock8x4, 73 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock16x8, 74 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock32x16, 75 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock64x32, kBlockInvalid, 76 kBlockInvalid, kBlock128x64}, 77 // kPartitionVerticalWithLeftSplit 78 {kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock4x8, 79 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock8x16, 80 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock16x32, 81 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock32x64, kBlockInvalid, 82 kBlockInvalid, kBlock64x128}, 83 // kPartitionVerticalWithRightSplit 84 {kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock4x8, 85 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock8x16, 86 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock16x32, 87 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock32x64, kBlockInvalid, 88 kBlockInvalid, kBlock64x128}, 89 // kPartitionHorizontal4 90 {kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, 91 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock16x4, 92 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock32x8, 93 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock64x16, kBlockInvalid, 94 kBlockInvalid, kBlockInvalid}, 95 // kPartitionVertical4 96 {kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, 97 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock4x16, 98 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock8x32, 99 kBlockInvalid, kBlockInvalid, kBlockInvalid, kBlock16x64, kBlockInvalid, 100 kBlockInvalid, kBlockInvalid}}; 101 102 // 5.11.38 (implemented as a simple look up. first dimension is block size, 103 // second and third are subsampling_x and subsampling_y). 104 const BlockSize kPlaneResidualSize[kMaxBlockSizes][2][2] = { 105 {{kBlock4x4, kBlock4x4}, {kBlock4x4, kBlock4x4}}, 106 {{kBlock4x8, kBlock4x4}, {kBlockInvalid, kBlock4x4}}, 107 {{kBlock4x16, kBlock4x8}, {kBlockInvalid, kBlock4x8}}, 108 {{kBlock8x4, kBlockInvalid}, {kBlock4x4, kBlock4x4}}, 109 {{kBlock8x8, kBlock8x4}, {kBlock4x8, kBlock4x4}}, 110 {{kBlock8x16, kBlock8x8}, {kBlockInvalid, kBlock4x8}}, 111 {{kBlock8x32, kBlock8x16}, {kBlockInvalid, kBlock4x16}}, 112 {{kBlock16x4, kBlockInvalid}, {kBlock8x4, kBlock8x4}}, 113 {{kBlock16x8, kBlockInvalid}, {kBlock8x8, kBlock8x4}}, 114 {{kBlock16x16, kBlock16x8}, {kBlock8x16, kBlock8x8}}, 115 {{kBlock16x32, kBlock16x16}, {kBlockInvalid, kBlock8x16}}, 116 {{kBlock16x64, kBlock16x32}, {kBlockInvalid, kBlock8x32}}, 117 {{kBlock32x8, kBlockInvalid}, {kBlock16x8, kBlock16x4}}, 118 {{kBlock32x16, kBlockInvalid}, {kBlock16x16, kBlock16x8}}, 119 {{kBlock32x32, kBlock32x16}, {kBlock16x32, kBlock16x16}}, 120 {{kBlock32x64, kBlock32x32}, {kBlockInvalid, kBlock16x32}}, 121 {{kBlock64x16, kBlockInvalid}, {kBlock32x16, kBlock32x8}}, 122 {{kBlock64x32, kBlockInvalid}, {kBlock32x32, kBlock32x16}}, 123 {{kBlock64x64, kBlock64x32}, {kBlock32x64, kBlock32x32}}, 124 {{kBlock64x128, kBlock64x64}, {kBlockInvalid, kBlock32x64}}, 125 {{kBlock128x64, kBlockInvalid}, {kBlock64x64, kBlock64x32}}, 126 {{kBlock128x128, kBlock128x64}, {kBlock64x128, kBlock64x64}}}; 127 128 const int16_t kProjectionMvDivisionLookup[kMaxFrameDistance + 1] = { 129 0, 16384, 8192, 5461, 4096, 3276, 2730, 2340, 2048, 1820, 1638, 130 1489, 1365, 1260, 1170, 1092, 1024, 963, 910, 862, 819, 780, 131 744, 712, 682, 655, 630, 606, 585, 564, 546, 528}; 132 133 const uint8_t kTransformWidth[kNumTransformSizes] = { 134 4, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 16, 32, 32, 32, 32, 64, 64, 64}; 135 136 const uint8_t kTransformHeight[kNumTransformSizes] = { 137 4, 8, 16, 4, 8, 16, 32, 4, 8, 16, 32, 64, 8, 16, 32, 64, 16, 32, 64}; 138 139 const uint8_t kTransformWidth4x4[kNumTransformSizes] = { 140 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 8, 8, 8, 8, 16, 16, 16}; 141 142 const uint8_t kTransformHeight4x4[kNumTransformSizes] = { 143 1, 2, 4, 1, 2, 4, 8, 1, 2, 4, 8, 16, 2, 4, 8, 16, 4, 8, 16}; 144 145 const uint8_t kTransformWidthLog2[kNumTransformSizes] = { 146 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6}; 147 148 const uint8_t kTransformHeightLog2[kNumTransformSizes] = { 149 2, 3, 4, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 4, 5, 6}; 150 151 // 9.3 -- Split_Tx_Size[] 152 const TransformSize kSplitTransformSize[kNumTransformSizes] = { 153 kTransformSize4x4, kTransformSize4x4, kTransformSize4x8, 154 kTransformSize4x4, kTransformSize4x4, kTransformSize8x8, 155 kTransformSize8x16, kTransformSize8x4, kTransformSize8x8, 156 kTransformSize8x8, kTransformSize16x16, kTransformSize16x32, 157 kTransformSize16x8, kTransformSize16x16, kTransformSize16x16, 158 kTransformSize32x32, kTransformSize32x16, kTransformSize32x32, 159 kTransformSize32x32}; 160 161 // Square transform of size min(w,h). 162 const TransformSize kTransformSizeSquareMin[kNumTransformSizes] = { 163 kTransformSize4x4, kTransformSize4x4, kTransformSize4x4, 164 kTransformSize4x4, kTransformSize8x8, kTransformSize8x8, 165 kTransformSize8x8, kTransformSize4x4, kTransformSize8x8, 166 kTransformSize16x16, kTransformSize16x16, kTransformSize16x16, 167 kTransformSize8x8, kTransformSize16x16, kTransformSize32x32, 168 kTransformSize32x32, kTransformSize16x16, kTransformSize32x32, 169 kTransformSize64x64}; 170 171 // Square transform of size max(w,h). 172 const TransformSize kTransformSizeSquareMax[kNumTransformSizes] = { 173 kTransformSize4x4, kTransformSize8x8, kTransformSize16x16, 174 kTransformSize8x8, kTransformSize8x8, kTransformSize16x16, 175 kTransformSize32x32, kTransformSize16x16, kTransformSize16x16, 176 kTransformSize16x16, kTransformSize32x32, kTransformSize64x64, 177 kTransformSize32x32, kTransformSize32x32, kTransformSize32x32, 178 kTransformSize64x64, kTransformSize64x64, kTransformSize64x64, 179 kTransformSize64x64}; 180 181 const uint8_t kNumTransformTypesInSet[kNumTransformSets] = {1, 7, 5, 16, 12, 2}; 182 183 const uint8_t kSgrProjParams[1 << kSgrProjParamsBits][4] = { 184 {2, 12, 1, 4}, {2, 15, 1, 6}, {2, 18, 1, 8}, {2, 21, 1, 9}, 185 {2, 24, 1, 10}, {2, 29, 1, 11}, {2, 36, 1, 12}, {2, 45, 1, 13}, 186 {2, 56, 1, 14}, {2, 68, 1, 15}, {0, 0, 1, 5}, {0, 0, 1, 8}, 187 {0, 0, 1, 11}, {0, 0, 1, 14}, {2, 30, 0, 0}, {2, 75, 0, 0}}; 188 189 const int8_t kSgrProjMultiplierMin[2] = {-96, -32}; 190 191 const int8_t kSgrProjMultiplierMax[2] = {31, 95}; 192 193 const int8_t kWienerTapsMin[3] = {-5, -23, -17}; 194 195 const int8_t kWienerTapsMax[3] = {10, 8, 46}; 196 197 // This was modified from Upscale_Filter as defined in AV1 Section 7.16, in 198 // order to support 16-bit packed NEON operations. 199 // The sign of each tap is: - + - + + - + - 200 alignas(16) const uint8_t 201 kUpscaleFilterUnsigned[kSuperResFilterShifts][kSuperResFilterTaps] = { 202 {0, 0, 0, 128, 0, 0, 0, 0}, {0, 0, 1, 128, 2, 1, 0, 0}, 203 {0, 1, 3, 127, 4, 2, 1, 0}, {0, 1, 4, 127, 6, 3, 1, 0}, 204 {0, 2, 6, 126, 8, 3, 1, 0}, {0, 2, 7, 125, 11, 4, 1, 0}, 205 {1, 2, 8, 125, 13, 5, 2, 0}, {1, 3, 9, 124, 15, 6, 2, 0}, 206 {1, 3, 10, 123, 18, 6, 2, 1}, {1, 3, 11, 122, 20, 7, 3, 1}, 207 {1, 4, 12, 121, 22, 8, 3, 1}, {1, 4, 13, 120, 25, 9, 3, 1}, 208 {1, 4, 14, 118, 28, 9, 3, 1}, {1, 4, 15, 117, 30, 10, 4, 1}, 209 {1, 5, 16, 116, 32, 11, 4, 1}, {1, 5, 16, 114, 35, 12, 4, 1}, 210 {1, 5, 17, 112, 38, 12, 4, 1}, {1, 5, 18, 111, 40, 13, 5, 1}, 211 {1, 5, 18, 109, 43, 14, 5, 1}, {1, 6, 19, 107, 45, 14, 5, 1}, 212 {1, 6, 19, 105, 48, 15, 5, 1}, {1, 6, 19, 103, 51, 16, 5, 1}, 213 {1, 6, 20, 101, 53, 16, 6, 1}, {1, 6, 20, 99, 56, 17, 6, 1}, 214 {1, 6, 20, 97, 58, 17, 6, 1}, {1, 6, 20, 95, 61, 18, 6, 1}, 215 {2, 7, 20, 93, 64, 18, 6, 2}, {2, 7, 20, 91, 66, 19, 6, 1}, 216 {2, 7, 20, 88, 69, 19, 6, 1}, {2, 7, 20, 86, 71, 19, 6, 1}, 217 {2, 7, 20, 84, 74, 20, 7, 2}, {2, 7, 20, 81, 76, 20, 7, 1}, 218 {2, 7, 20, 79, 79, 20, 7, 2}, {1, 7, 20, 76, 81, 20, 7, 2}, 219 {2, 7, 20, 74, 84, 20, 7, 2}, {1, 6, 19, 71, 86, 20, 7, 2}, 220 {1, 6, 19, 69, 88, 20, 7, 2}, {1, 6, 19, 66, 91, 20, 7, 2}, 221 {2, 6, 18, 64, 93, 20, 7, 2}, {1, 6, 18, 61, 95, 20, 6, 1}, 222 {1, 6, 17, 58, 97, 20, 6, 1}, {1, 6, 17, 56, 99, 20, 6, 1}, 223 {1, 6, 16, 53, 101, 20, 6, 1}, {1, 5, 16, 51, 103, 19, 6, 1}, 224 {1, 5, 15, 48, 105, 19, 6, 1}, {1, 5, 14, 45, 107, 19, 6, 1}, 225 {1, 5, 14, 43, 109, 18, 5, 1}, {1, 5, 13, 40, 111, 18, 5, 1}, 226 {1, 4, 12, 38, 112, 17, 5, 1}, {1, 4, 12, 35, 114, 16, 5, 1}, 227 {1, 4, 11, 32, 116, 16, 5, 1}, {1, 4, 10, 30, 117, 15, 4, 1}, 228 {1, 3, 9, 28, 118, 14, 4, 1}, {1, 3, 9, 25, 120, 13, 4, 1}, 229 {1, 3, 8, 22, 121, 12, 4, 1}, {1, 3, 7, 20, 122, 11, 3, 1}, 230 {1, 2, 6, 18, 123, 10, 3, 1}, {0, 2, 6, 15, 124, 9, 3, 1}, 231 {0, 2, 5, 13, 125, 8, 2, 1}, {0, 1, 4, 11, 125, 7, 2, 0}, 232 {0, 1, 3, 8, 126, 6, 2, 0}, {0, 1, 3, 6, 127, 4, 1, 0}, 233 {0, 1, 2, 4, 127, 3, 1, 0}, {0, 0, 1, 2, 128, 1, 0, 0}, 234 }; 235 236 alignas(8) const int8_t 237 kWarpedFilters8[3 * kWarpedPixelPrecisionShifts + 1][8] = { 238 // [-1, 0). 239 {0, 0, 127, 1, 0, 0, 0, 0}, 240 {0, -1, 127, 2, 0, 0, 0, 0}, 241 {1, -3, 127, 4, -1, 0, 0, 0}, 242 {1, -4, 126, 6, -2, 1, 0, 0}, 243 {1, -5, 126, 8, -3, 1, 0, 0}, 244 {1, -6, 125, 11, -4, 1, 0, 0}, 245 {1, -7, 124, 13, -4, 1, 0, 0}, 246 {2, -8, 123, 15, -5, 1, 0, 0}, 247 {2, -9, 122, 18, -6, 1, 0, 0}, 248 {2, -10, 121, 20, -6, 1, 0, 0}, 249 {2, -11, 120, 22, -7, 2, 0, 0}, 250 {2, -12, 119, 25, -8, 2, 0, 0}, 251 {3, -13, 117, 27, -8, 2, 0, 0}, 252 {3, -13, 116, 29, -9, 2, 0, 0}, 253 {3, -14, 114, 32, -10, 3, 0, 0}, 254 {3, -15, 113, 35, -10, 2, 0, 0}, 255 {3, -15, 111, 37, -11, 3, 0, 0}, 256 {3, -16, 109, 40, -11, 3, 0, 0}, 257 {3, -16, 108, 42, -12, 3, 0, 0}, 258 {4, -17, 106, 45, -13, 3, 0, 0}, 259 {4, -17, 104, 47, -13, 3, 0, 0}, 260 {4, -17, 102, 50, -14, 3, 0, 0}, 261 {4, -17, 100, 52, -14, 3, 0, 0}, 262 {4, -18, 98, 55, -15, 4, 0, 0}, 263 {4, -18, 96, 58, -15, 3, 0, 0}, 264 {4, -18, 94, 60, -16, 4, 0, 0}, 265 {4, -18, 91, 63, -16, 4, 0, 0}, 266 {4, -18, 89, 65, -16, 4, 0, 0}, 267 {4, -18, 87, 68, -17, 4, 0, 0}, 268 {4, -18, 85, 70, -17, 4, 0, 0}, 269 {4, -18, 82, 73, -17, 4, 0, 0}, 270 {4, -18, 80, 75, -17, 4, 0, 0}, 271 {4, -18, 78, 78, -18, 4, 0, 0}, 272 {4, -17, 75, 80, -18, 4, 0, 0}, 273 {4, -17, 73, 82, -18, 4, 0, 0}, 274 {4, -17, 70, 85, -18, 4, 0, 0}, 275 {4, -17, 68, 87, -18, 4, 0, 0}, 276 {4, -16, 65, 89, -18, 4, 0, 0}, 277 {4, -16, 63, 91, -18, 4, 0, 0}, 278 {4, -16, 60, 94, -18, 4, 0, 0}, 279 {3, -15, 58, 96, -18, 4, 0, 0}, 280 {4, -15, 55, 98, -18, 4, 0, 0}, 281 {3, -14, 52, 100, -17, 4, 0, 0}, 282 {3, -14, 50, 102, -17, 4, 0, 0}, 283 {3, -13, 47, 104, -17, 4, 0, 0}, 284 {3, -13, 45, 106, -17, 4, 0, 0}, 285 {3, -12, 42, 108, -16, 3, 0, 0}, 286 {3, -11, 40, 109, -16, 3, 0, 0}, 287 {3, -11, 37, 111, -15, 3, 0, 0}, 288 {2, -10, 35, 113, -15, 3, 0, 0}, 289 {3, -10, 32, 114, -14, 3, 0, 0}, 290 {2, -9, 29, 116, -13, 3, 0, 0}, 291 {2, -8, 27, 117, -13, 3, 0, 0}, 292 {2, -8, 25, 119, -12, 2, 0, 0}, 293 {2, -7, 22, 120, -11, 2, 0, 0}, 294 {1, -6, 20, 121, -10, 2, 0, 0}, 295 {1, -6, 18, 122, -9, 2, 0, 0}, 296 {1, -5, 15, 123, -8, 2, 0, 0}, 297 {1, -4, 13, 124, -7, 1, 0, 0}, 298 {1, -4, 11, 125, -6, 1, 0, 0}, 299 {1, -3, 8, 126, -5, 1, 0, 0}, 300 {1, -2, 6, 126, -4, 1, 0, 0}, 301 {0, -1, 4, 127, -3, 1, 0, 0}, 302 {0, 0, 2, 127, -1, 0, 0, 0}, 303 // [0, 1). 304 {0, 0, 0, 127, 1, 0, 0, 0}, 305 {0, 0, -1, 127, 2, 0, 0, 0}, 306 {0, 1, -3, 127, 4, -2, 1, 0}, 307 {0, 1, -5, 127, 6, -2, 1, 0}, 308 {0, 2, -6, 126, 8, -3, 1, 0}, 309 {-1, 2, -7, 126, 11, -4, 2, -1}, 310 {-1, 3, -8, 125, 13, -5, 2, -1}, 311 {-1, 3, -10, 124, 16, -6, 3, -1}, 312 {-1, 4, -11, 123, 18, -7, 3, -1}, 313 {-1, 4, -12, 122, 20, -7, 3, -1}, 314 {-1, 4, -13, 121, 23, -8, 3, -1}, 315 {-2, 5, -14, 120, 25, -9, 4, -1}, 316 {-1, 5, -15, 119, 27, -10, 4, -1}, 317 {-1, 5, -16, 118, 30, -11, 4, -1}, 318 {-2, 6, -17, 116, 33, -12, 5, -1}, 319 {-2, 6, -17, 114, 35, -12, 5, -1}, 320 {-2, 6, -18, 113, 38, -13, 5, -1}, 321 {-2, 7, -19, 111, 41, -14, 6, -2}, 322 {-2, 7, -19, 110, 43, -15, 6, -2}, 323 {-2, 7, -20, 108, 46, -15, 6, -2}, 324 {-2, 7, -20, 106, 49, -16, 6, -2}, 325 {-2, 7, -21, 104, 51, -16, 7, -2}, 326 {-2, 7, -21, 102, 54, -17, 7, -2}, 327 {-2, 8, -21, 100, 56, -18, 7, -2}, 328 {-2, 8, -22, 98, 59, -18, 7, -2}, 329 {-2, 8, -22, 96, 62, -19, 7, -2}, 330 {-2, 8, -22, 94, 64, -19, 7, -2}, 331 {-2, 8, -22, 91, 67, -20, 8, -2}, 332 {-2, 8, -22, 89, 69, -20, 8, -2}, 333 {-2, 8, -22, 87, 72, -21, 8, -2}, 334 {-2, 8, -21, 84, 74, -21, 8, -2}, 335 {-2, 8, -22, 82, 77, -21, 8, -2}, 336 {-2, 8, -21, 79, 79, -21, 8, -2}, 337 {-2, 8, -21, 77, 82, -22, 8, -2}, 338 {-2, 8, -21, 74, 84, -21, 8, -2}, 339 {-2, 8, -21, 72, 87, -22, 8, -2}, 340 {-2, 8, -20, 69, 89, -22, 8, -2}, 341 {-2, 8, -20, 67, 91, -22, 8, -2}, 342 {-2, 7, -19, 64, 94, -22, 8, -2}, 343 {-2, 7, -19, 62, 96, -22, 8, -2}, 344 {-2, 7, -18, 59, 98, -22, 8, -2}, 345 {-2, 7, -18, 56, 100, -21, 8, -2}, 346 {-2, 7, -17, 54, 102, -21, 7, -2}, 347 {-2, 7, -16, 51, 104, -21, 7, -2}, 348 {-2, 6, -16, 49, 106, -20, 7, -2}, 349 {-2, 6, -15, 46, 108, -20, 7, -2}, 350 {-2, 6, -15, 43, 110, -19, 7, -2}, 351 {-2, 6, -14, 41, 111, -19, 7, -2}, 352 {-1, 5, -13, 38, 113, -18, 6, -2}, 353 {-1, 5, -12, 35, 114, -17, 6, -2}, 354 {-1, 5, -12, 33, 116, -17, 6, -2}, 355 {-1, 4, -11, 30, 118, -16, 5, -1}, 356 {-1, 4, -10, 27, 119, -15, 5, -1}, 357 {-1, 4, -9, 25, 120, -14, 5, -2}, 358 {-1, 3, -8, 23, 121, -13, 4, -1}, 359 {-1, 3, -7, 20, 122, -12, 4, -1}, 360 {-1, 3, -7, 18, 123, -11, 4, -1}, 361 {-1, 3, -6, 16, 124, -10, 3, -1}, 362 {-1, 2, -5, 13, 125, -8, 3, -1}, 363 {-1, 2, -4, 11, 126, -7, 2, -1}, 364 {0, 1, -3, 8, 126, -6, 2, 0}, 365 {0, 1, -2, 6, 127, -5, 1, 0}, 366 {0, 1, -2, 4, 127, -3, 1, 0}, 367 {0, 0, 0, 2, 127, -1, 0, 0}, 368 // [1, 2). 369 {0, 0, 0, 1, 127, 0, 0, 0}, 370 {0, 0, 0, -1, 127, 2, 0, 0}, 371 {0, 0, 1, -3, 127, 4, -1, 0}, 372 {0, 0, 1, -4, 126, 6, -2, 1}, 373 {0, 0, 1, -5, 126, 8, -3, 1}, 374 {0, 0, 1, -6, 125, 11, -4, 1}, 375 {0, 0, 1, -7, 124, 13, -4, 1}, 376 {0, 0, 2, -8, 123, 15, -5, 1}, 377 {0, 0, 2, -9, 122, 18, -6, 1}, 378 {0, 0, 2, -10, 121, 20, -6, 1}, 379 {0, 0, 2, -11, 120, 22, -7, 2}, 380 {0, 0, 2, -12, 119, 25, -8, 2}, 381 {0, 0, 3, -13, 117, 27, -8, 2}, 382 {0, 0, 3, -13, 116, 29, -9, 2}, 383 {0, 0, 3, -14, 114, 32, -10, 3}, 384 {0, 0, 3, -15, 113, 35, -10, 2}, 385 {0, 0, 3, -15, 111, 37, -11, 3}, 386 {0, 0, 3, -16, 109, 40, -11, 3}, 387 {0, 0, 3, -16, 108, 42, -12, 3}, 388 {0, 0, 4, -17, 106, 45, -13, 3}, 389 {0, 0, 4, -17, 104, 47, -13, 3}, 390 {0, 0, 4, -17, 102, 50, -14, 3}, 391 {0, 0, 4, -17, 100, 52, -14, 3}, 392 {0, 0, 4, -18, 98, 55, -15, 4}, 393 {0, 0, 4, -18, 96, 58, -15, 3}, 394 {0, 0, 4, -18, 94, 60, -16, 4}, 395 {0, 0, 4, -18, 91, 63, -16, 4}, 396 {0, 0, 4, -18, 89, 65, -16, 4}, 397 {0, 0, 4, -18, 87, 68, -17, 4}, 398 {0, 0, 4, -18, 85, 70, -17, 4}, 399 {0, 0, 4, -18, 82, 73, -17, 4}, 400 {0, 0, 4, -18, 80, 75, -17, 4}, 401 {0, 0, 4, -18, 78, 78, -18, 4}, 402 {0, 0, 4, -17, 75, 80, -18, 4}, 403 {0, 0, 4, -17, 73, 82, -18, 4}, 404 {0, 0, 4, -17, 70, 85, -18, 4}, 405 {0, 0, 4, -17, 68, 87, -18, 4}, 406 {0, 0, 4, -16, 65, 89, -18, 4}, 407 {0, 0, 4, -16, 63, 91, -18, 4}, 408 {0, 0, 4, -16, 60, 94, -18, 4}, 409 {0, 0, 3, -15, 58, 96, -18, 4}, 410 {0, 0, 4, -15, 55, 98, -18, 4}, 411 {0, 0, 3, -14, 52, 100, -17, 4}, 412 {0, 0, 3, -14, 50, 102, -17, 4}, 413 {0, 0, 3, -13, 47, 104, -17, 4}, 414 {0, 0, 3, -13, 45, 106, -17, 4}, 415 {0, 0, 3, -12, 42, 108, -16, 3}, 416 {0, 0, 3, -11, 40, 109, -16, 3}, 417 {0, 0, 3, -11, 37, 111, -15, 3}, 418 {0, 0, 2, -10, 35, 113, -15, 3}, 419 {0, 0, 3, -10, 32, 114, -14, 3}, 420 {0, 0, 2, -9, 29, 116, -13, 3}, 421 {0, 0, 2, -8, 27, 117, -13, 3}, 422 {0, 0, 2, -8, 25, 119, -12, 2}, 423 {0, 0, 2, -7, 22, 120, -11, 2}, 424 {0, 0, 1, -6, 20, 121, -10, 2}, 425 {0, 0, 1, -6, 18, 122, -9, 2}, 426 {0, 0, 1, -5, 15, 123, -8, 2}, 427 {0, 0, 1, -4, 13, 124, -7, 1}, 428 {0, 0, 1, -4, 11, 125, -6, 1}, 429 {0, 0, 1, -3, 8, 126, -5, 1}, 430 {0, 0, 1, -2, 6, 126, -4, 1}, 431 {0, 0, 0, -1, 4, 127, -3, 1}, 432 {0, 0, 0, 0, 2, 127, -1, 0}, 433 // dummy, replicate row index 191. 434 {0, 0, 0, 0, 2, 127, -1, 0}}; 435 436 alignas(16) const int16_t 437 kWarpedFilters[3 * kWarpedPixelPrecisionShifts + 1][8] = { 438 // [-1, 0). 439 {0, 0, 127, 1, 0, 0, 0, 0}, 440 {0, -1, 127, 2, 0, 0, 0, 0}, 441 {1, -3, 127, 4, -1, 0, 0, 0}, 442 {1, -4, 126, 6, -2, 1, 0, 0}, 443 {1, -5, 126, 8, -3, 1, 0, 0}, 444 {1, -6, 125, 11, -4, 1, 0, 0}, 445 {1, -7, 124, 13, -4, 1, 0, 0}, 446 {2, -8, 123, 15, -5, 1, 0, 0}, 447 {2, -9, 122, 18, -6, 1, 0, 0}, 448 {2, -10, 121, 20, -6, 1, 0, 0}, 449 {2, -11, 120, 22, -7, 2, 0, 0}, 450 {2, -12, 119, 25, -8, 2, 0, 0}, 451 {3, -13, 117, 27, -8, 2, 0, 0}, 452 {3, -13, 116, 29, -9, 2, 0, 0}, 453 {3, -14, 114, 32, -10, 3, 0, 0}, 454 {3, -15, 113, 35, -10, 2, 0, 0}, 455 {3, -15, 111, 37, -11, 3, 0, 0}, 456 {3, -16, 109, 40, -11, 3, 0, 0}, 457 {3, -16, 108, 42, -12, 3, 0, 0}, 458 {4, -17, 106, 45, -13, 3, 0, 0}, 459 {4, -17, 104, 47, -13, 3, 0, 0}, 460 {4, -17, 102, 50, -14, 3, 0, 0}, 461 {4, -17, 100, 52, -14, 3, 0, 0}, 462 {4, -18, 98, 55, -15, 4, 0, 0}, 463 {4, -18, 96, 58, -15, 3, 0, 0}, 464 {4, -18, 94, 60, -16, 4, 0, 0}, 465 {4, -18, 91, 63, -16, 4, 0, 0}, 466 {4, -18, 89, 65, -16, 4, 0, 0}, 467 {4, -18, 87, 68, -17, 4, 0, 0}, 468 {4, -18, 85, 70, -17, 4, 0, 0}, 469 {4, -18, 82, 73, -17, 4, 0, 0}, 470 {4, -18, 80, 75, -17, 4, 0, 0}, 471 {4, -18, 78, 78, -18, 4, 0, 0}, 472 {4, -17, 75, 80, -18, 4, 0, 0}, 473 {4, -17, 73, 82, -18, 4, 0, 0}, 474 {4, -17, 70, 85, -18, 4, 0, 0}, 475 {4, -17, 68, 87, -18, 4, 0, 0}, 476 {4, -16, 65, 89, -18, 4, 0, 0}, 477 {4, -16, 63, 91, -18, 4, 0, 0}, 478 {4, -16, 60, 94, -18, 4, 0, 0}, 479 {3, -15, 58, 96, -18, 4, 0, 0}, 480 {4, -15, 55, 98, -18, 4, 0, 0}, 481 {3, -14, 52, 100, -17, 4, 0, 0}, 482 {3, -14, 50, 102, -17, 4, 0, 0}, 483 {3, -13, 47, 104, -17, 4, 0, 0}, 484 {3, -13, 45, 106, -17, 4, 0, 0}, 485 {3, -12, 42, 108, -16, 3, 0, 0}, 486 {3, -11, 40, 109, -16, 3, 0, 0}, 487 {3, -11, 37, 111, -15, 3, 0, 0}, 488 {2, -10, 35, 113, -15, 3, 0, 0}, 489 {3, -10, 32, 114, -14, 3, 0, 0}, 490 {2, -9, 29, 116, -13, 3, 0, 0}, 491 {2, -8, 27, 117, -13, 3, 0, 0}, 492 {2, -8, 25, 119, -12, 2, 0, 0}, 493 {2, -7, 22, 120, -11, 2, 0, 0}, 494 {1, -6, 20, 121, -10, 2, 0, 0}, 495 {1, -6, 18, 122, -9, 2, 0, 0}, 496 {1, -5, 15, 123, -8, 2, 0, 0}, 497 {1, -4, 13, 124, -7, 1, 0, 0}, 498 {1, -4, 11, 125, -6, 1, 0, 0}, 499 {1, -3, 8, 126, -5, 1, 0, 0}, 500 {1, -2, 6, 126, -4, 1, 0, 0}, 501 {0, -1, 4, 127, -3, 1, 0, 0}, 502 {0, 0, 2, 127, -1, 0, 0, 0}, 503 // [0, 1). 504 {0, 0, 0, 127, 1, 0, 0, 0}, 505 {0, 0, -1, 127, 2, 0, 0, 0}, 506 {0, 1, -3, 127, 4, -2, 1, 0}, 507 {0, 1, -5, 127, 6, -2, 1, 0}, 508 {0, 2, -6, 126, 8, -3, 1, 0}, 509 {-1, 2, -7, 126, 11, -4, 2, -1}, 510 {-1, 3, -8, 125, 13, -5, 2, -1}, 511 {-1, 3, -10, 124, 16, -6, 3, -1}, 512 {-1, 4, -11, 123, 18, -7, 3, -1}, 513 {-1, 4, -12, 122, 20, -7, 3, -1}, 514 {-1, 4, -13, 121, 23, -8, 3, -1}, 515 {-2, 5, -14, 120, 25, -9, 4, -1}, 516 {-1, 5, -15, 119, 27, -10, 4, -1}, 517 {-1, 5, -16, 118, 30, -11, 4, -1}, 518 {-2, 6, -17, 116, 33, -12, 5, -1}, 519 {-2, 6, -17, 114, 35, -12, 5, -1}, 520 {-2, 6, -18, 113, 38, -13, 5, -1}, 521 {-2, 7, -19, 111, 41, -14, 6, -2}, 522 {-2, 7, -19, 110, 43, -15, 6, -2}, 523 {-2, 7, -20, 108, 46, -15, 6, -2}, 524 {-2, 7, -20, 106, 49, -16, 6, -2}, 525 {-2, 7, -21, 104, 51, -16, 7, -2}, 526 {-2, 7, -21, 102, 54, -17, 7, -2}, 527 {-2, 8, -21, 100, 56, -18, 7, -2}, 528 {-2, 8, -22, 98, 59, -18, 7, -2}, 529 {-2, 8, -22, 96, 62, -19, 7, -2}, 530 {-2, 8, -22, 94, 64, -19, 7, -2}, 531 {-2, 8, -22, 91, 67, -20, 8, -2}, 532 {-2, 8, -22, 89, 69, -20, 8, -2}, 533 {-2, 8, -22, 87, 72, -21, 8, -2}, 534 {-2, 8, -21, 84, 74, -21, 8, -2}, 535 {-2, 8, -22, 82, 77, -21, 8, -2}, 536 {-2, 8, -21, 79, 79, -21, 8, -2}, 537 {-2, 8, -21, 77, 82, -22, 8, -2}, 538 {-2, 8, -21, 74, 84, -21, 8, -2}, 539 {-2, 8, -21, 72, 87, -22, 8, -2}, 540 {-2, 8, -20, 69, 89, -22, 8, -2}, 541 {-2, 8, -20, 67, 91, -22, 8, -2}, 542 {-2, 7, -19, 64, 94, -22, 8, -2}, 543 {-2, 7, -19, 62, 96, -22, 8, -2}, 544 {-2, 7, -18, 59, 98, -22, 8, -2}, 545 {-2, 7, -18, 56, 100, -21, 8, -2}, 546 {-2, 7, -17, 54, 102, -21, 7, -2}, 547 {-2, 7, -16, 51, 104, -21, 7, -2}, 548 {-2, 6, -16, 49, 106, -20, 7, -2}, 549 {-2, 6, -15, 46, 108, -20, 7, -2}, 550 {-2, 6, -15, 43, 110, -19, 7, -2}, 551 {-2, 6, -14, 41, 111, -19, 7, -2}, 552 {-1, 5, -13, 38, 113, -18, 6, -2}, 553 {-1, 5, -12, 35, 114, -17, 6, -2}, 554 {-1, 5, -12, 33, 116, -17, 6, -2}, 555 {-1, 4, -11, 30, 118, -16, 5, -1}, 556 {-1, 4, -10, 27, 119, -15, 5, -1}, 557 {-1, 4, -9, 25, 120, -14, 5, -2}, 558 {-1, 3, -8, 23, 121, -13, 4, -1}, 559 {-1, 3, -7, 20, 122, -12, 4, -1}, 560 {-1, 3, -7, 18, 123, -11, 4, -1}, 561 {-1, 3, -6, 16, 124, -10, 3, -1}, 562 {-1, 2, -5, 13, 125, -8, 3, -1}, 563 {-1, 2, -4, 11, 126, -7, 2, -1}, 564 {0, 1, -3, 8, 126, -6, 2, 0}, 565 {0, 1, -2, 6, 127, -5, 1, 0}, 566 {0, 1, -2, 4, 127, -3, 1, 0}, 567 {0, 0, 0, 2, 127, -1, 0, 0}, 568 // [1, 2). 569 {0, 0, 0, 1, 127, 0, 0, 0}, 570 {0, 0, 0, -1, 127, 2, 0, 0}, 571 {0, 0, 1, -3, 127, 4, -1, 0}, 572 {0, 0, 1, -4, 126, 6, -2, 1}, 573 {0, 0, 1, -5, 126, 8, -3, 1}, 574 {0, 0, 1, -6, 125, 11, -4, 1}, 575 {0, 0, 1, -7, 124, 13, -4, 1}, 576 {0, 0, 2, -8, 123, 15, -5, 1}, 577 {0, 0, 2, -9, 122, 18, -6, 1}, 578 {0, 0, 2, -10, 121, 20, -6, 1}, 579 {0, 0, 2, -11, 120, 22, -7, 2}, 580 {0, 0, 2, -12, 119, 25, -8, 2}, 581 {0, 0, 3, -13, 117, 27, -8, 2}, 582 {0, 0, 3, -13, 116, 29, -9, 2}, 583 {0, 0, 3, -14, 114, 32, -10, 3}, 584 {0, 0, 3, -15, 113, 35, -10, 2}, 585 {0, 0, 3, -15, 111, 37, -11, 3}, 586 {0, 0, 3, -16, 109, 40, -11, 3}, 587 {0, 0, 3, -16, 108, 42, -12, 3}, 588 {0, 0, 4, -17, 106, 45, -13, 3}, 589 {0, 0, 4, -17, 104, 47, -13, 3}, 590 {0, 0, 4, -17, 102, 50, -14, 3}, 591 {0, 0, 4, -17, 100, 52, -14, 3}, 592 {0, 0, 4, -18, 98, 55, -15, 4}, 593 {0, 0, 4, -18, 96, 58, -15, 3}, 594 {0, 0, 4, -18, 94, 60, -16, 4}, 595 {0, 0, 4, -18, 91, 63, -16, 4}, 596 {0, 0, 4, -18, 89, 65, -16, 4}, 597 {0, 0, 4, -18, 87, 68, -17, 4}, 598 {0, 0, 4, -18, 85, 70, -17, 4}, 599 {0, 0, 4, -18, 82, 73, -17, 4}, 600 {0, 0, 4, -18, 80, 75, -17, 4}, 601 {0, 0, 4, -18, 78, 78, -18, 4}, 602 {0, 0, 4, -17, 75, 80, -18, 4}, 603 {0, 0, 4, -17, 73, 82, -18, 4}, 604 {0, 0, 4, -17, 70, 85, -18, 4}, 605 {0, 0, 4, -17, 68, 87, -18, 4}, 606 {0, 0, 4, -16, 65, 89, -18, 4}, 607 {0, 0, 4, -16, 63, 91, -18, 4}, 608 {0, 0, 4, -16, 60, 94, -18, 4}, 609 {0, 0, 3, -15, 58, 96, -18, 4}, 610 {0, 0, 4, -15, 55, 98, -18, 4}, 611 {0, 0, 3, -14, 52, 100, -17, 4}, 612 {0, 0, 3, -14, 50, 102, -17, 4}, 613 {0, 0, 3, -13, 47, 104, -17, 4}, 614 {0, 0, 3, -13, 45, 106, -17, 4}, 615 {0, 0, 3, -12, 42, 108, -16, 3}, 616 {0, 0, 3, -11, 40, 109, -16, 3}, 617 {0, 0, 3, -11, 37, 111, -15, 3}, 618 {0, 0, 2, -10, 35, 113, -15, 3}, 619 {0, 0, 3, -10, 32, 114, -14, 3}, 620 {0, 0, 2, -9, 29, 116, -13, 3}, 621 {0, 0, 2, -8, 27, 117, -13, 3}, 622 {0, 0, 2, -8, 25, 119, -12, 2}, 623 {0, 0, 2, -7, 22, 120, -11, 2}, 624 {0, 0, 1, -6, 20, 121, -10, 2}, 625 {0, 0, 1, -6, 18, 122, -9, 2}, 626 {0, 0, 1, -5, 15, 123, -8, 2}, 627 {0, 0, 1, -4, 13, 124, -7, 1}, 628 {0, 0, 1, -4, 11, 125, -6, 1}, 629 {0, 0, 1, -3, 8, 126, -5, 1}, 630 {0, 0, 1, -2, 6, 126, -4, 1}, 631 {0, 0, 0, -1, 4, 127, -3, 1}, 632 {0, 0, 0, 0, 2, 127, -1, 0}, 633 // dummy, replicate row index 191. 634 {0, 0, 0, 0, 2, 127, -1, 0}}; 635 636 // Every value in |kSubPixelFilters| is even. Divide by 2 to simplify 637 // calculations by reducing the range by 1 bit. 638 alignas(8) const int8_t kHalfSubPixelFilters[6][16][8] = { 639 {{0, 0, 0, 64, 0, 0, 0, 0}, 640 {0, 1, -3, 63, 4, -1, 0, 0}, 641 {0, 1, -5, 61, 9, -2, 0, 0}, 642 {0, 1, -6, 58, 14, -4, 1, 0}, 643 {0, 1, -7, 55, 19, -5, 1, 0}, 644 {0, 1, -7, 51, 24, -6, 1, 0}, 645 {0, 1, -8, 47, 29, -6, 1, 0}, 646 {0, 1, -7, 42, 33, -6, 1, 0}, 647 {0, 1, -7, 38, 38, -7, 1, 0}, 648 {0, 1, -6, 33, 42, -7, 1, 0}, 649 {0, 1, -6, 29, 47, -8, 1, 0}, 650 {0, 1, -6, 24, 51, -7, 1, 0}, 651 {0, 1, -5, 19, 55, -7, 1, 0}, 652 {0, 1, -4, 14, 58, -6, 1, 0}, 653 {0, 0, -2, 9, 61, -5, 1, 0}, 654 {0, 0, -1, 4, 63, -3, 1, 0}}, 655 {{0, 0, 0, 64, 0, 0, 0, 0}, 656 {0, 1, 14, 31, 17, 1, 0, 0}, 657 {0, 0, 13, 31, 18, 2, 0, 0}, 658 {0, 0, 11, 31, 20, 2, 0, 0}, 659 {0, 0, 10, 30, 21, 3, 0, 0}, 660 {0, 0, 9, 29, 22, 4, 0, 0}, 661 {0, 0, 8, 28, 23, 5, 0, 0}, 662 {0, -1, 8, 27, 24, 6, 0, 0}, 663 {0, -1, 7, 26, 26, 7, -1, 0}, 664 {0, 0, 6, 24, 27, 8, -1, 0}, 665 {0, 0, 5, 23, 28, 8, 0, 0}, 666 {0, 0, 4, 22, 29, 9, 0, 0}, 667 {0, 0, 3, 21, 30, 10, 0, 0}, 668 {0, 0, 2, 20, 31, 11, 0, 0}, 669 {0, 0, 2, 18, 31, 13, 0, 0}, 670 {0, 0, 1, 17, 31, 14, 1, 0}}, 671 {{0, 0, 0, 64, 0, 0, 0, 0}, 672 {-1, 1, -3, 63, 4, -1, 1, 0}, 673 {-1, 3, -6, 62, 8, -3, 2, -1}, 674 {-1, 4, -9, 60, 13, -5, 3, -1}, 675 {-2, 5, -11, 58, 19, -7, 3, -1}, 676 {-2, 5, -11, 54, 24, -9, 4, -1}, 677 {-2, 5, -12, 50, 30, -10, 4, -1}, 678 {-2, 5, -12, 45, 35, -11, 5, -1}, 679 {-2, 6, -12, 40, 40, -12, 6, -2}, 680 {-1, 5, -11, 35, 45, -12, 5, -2}, 681 {-1, 4, -10, 30, 50, -12, 5, -2}, 682 {-1, 4, -9, 24, 54, -11, 5, -2}, 683 {-1, 3, -7, 19, 58, -11, 5, -2}, 684 {-1, 3, -5, 13, 60, -9, 4, -1}, 685 {-1, 2, -3, 8, 62, -6, 3, -1}, 686 {0, 1, -1, 4, 63, -3, 1, -1}}, 687 {{0, 0, 0, 64, 0, 0, 0, 0}, 688 {0, 0, 0, 60, 4, 0, 0, 0}, 689 {0, 0, 0, 56, 8, 0, 0, 0}, 690 {0, 0, 0, 52, 12, 0, 0, 0}, 691 {0, 0, 0, 48, 16, 0, 0, 0}, 692 {0, 0, 0, 44, 20, 0, 0, 0}, 693 {0, 0, 0, 40, 24, 0, 0, 0}, 694 {0, 0, 0, 36, 28, 0, 0, 0}, 695 {0, 0, 0, 32, 32, 0, 0, 0}, 696 {0, 0, 0, 28, 36, 0, 0, 0}, 697 {0, 0, 0, 24, 40, 0, 0, 0}, 698 {0, 0, 0, 20, 44, 0, 0, 0}, 699 {0, 0, 0, 16, 48, 0, 0, 0}, 700 {0, 0, 0, 12, 52, 0, 0, 0}, 701 {0, 0, 0, 8, 56, 0, 0, 0}, 702 {0, 0, 0, 4, 60, 0, 0, 0}}, 703 {{0, 0, 0, 64, 0, 0, 0, 0}, 704 {0, 0, -2, 63, 4, -1, 0, 0}, 705 {0, 0, -4, 61, 9, -2, 0, 0}, 706 {0, 0, -5, 58, 14, -3, 0, 0}, 707 {0, 0, -6, 55, 19, -4, 0, 0}, 708 {0, 0, -6, 51, 24, -5, 0, 0}, 709 {0, 0, -7, 47, 29, -5, 0, 0}, 710 {0, 0, -6, 42, 33, -5, 0, 0}, 711 {0, 0, -6, 38, 38, -6, 0, 0}, 712 {0, 0, -5, 33, 42, -6, 0, 0}, 713 {0, 0, -5, 29, 47, -7, 0, 0}, 714 {0, 0, -5, 24, 51, -6, 0, 0}, 715 {0, 0, -4, 19, 55, -6, 0, 0}, 716 {0, 0, -3, 14, 58, -5, 0, 0}, 717 {0, 0, -2, 9, 61, -4, 0, 0}, 718 {0, 0, -1, 4, 63, -2, 0, 0}}, 719 {{0, 0, 0, 64, 0, 0, 0, 0}, 720 {0, 0, 15, 31, 17, 1, 0, 0}, 721 {0, 0, 13, 31, 18, 2, 0, 0}, 722 {0, 0, 11, 31, 20, 2, 0, 0}, 723 {0, 0, 10, 30, 21, 3, 0, 0}, 724 {0, 0, 9, 29, 22, 4, 0, 0}, 725 {0, 0, 8, 28, 23, 5, 0, 0}, 726 {0, 0, 7, 27, 24, 6, 0, 0}, 727 {0, 0, 6, 26, 26, 6, 0, 0}, 728 {0, 0, 6, 24, 27, 7, 0, 0}, 729 {0, 0, 5, 23, 28, 8, 0, 0}, 730 {0, 0, 4, 22, 29, 9, 0, 0}, 731 {0, 0, 3, 21, 30, 10, 0, 0}, 732 {0, 0, 2, 20, 31, 11, 0, 0}, 733 {0, 0, 2, 18, 31, 13, 0, 0}, 734 {0, 0, 1, 17, 31, 15, 0, 0}}}; 735 736 // Absolute values of |kHalfSubPixelFilters|. Used in situations where we know 737 // the pattern of the signs and account for it in other ways. 738 const uint8_t kAbsHalfSubPixelFilters[6][16][8] = { 739 {{0, 0, 0, 64, 0, 0, 0, 0}, 740 {0, 1, 3, 63, 4, 1, 0, 0}, 741 {0, 1, 5, 61, 9, 2, 0, 0}, 742 {0, 1, 6, 58, 14, 4, 1, 0}, 743 {0, 1, 7, 55, 19, 5, 1, 0}, 744 {0, 1, 7, 51, 24, 6, 1, 0}, 745 {0, 1, 8, 47, 29, 6, 1, 0}, 746 {0, 1, 7, 42, 33, 6, 1, 0}, 747 {0, 1, 7, 38, 38, 7, 1, 0}, 748 {0, 1, 6, 33, 42, 7, 1, 0}, 749 {0, 1, 6, 29, 47, 8, 1, 0}, 750 {0, 1, 6, 24, 51, 7, 1, 0}, 751 {0, 1, 5, 19, 55, 7, 1, 0}, 752 {0, 1, 4, 14, 58, 6, 1, 0}, 753 {0, 0, 2, 9, 61, 5, 1, 0}, 754 {0, 0, 1, 4, 63, 3, 1, 0}}, 755 {{0, 0, 0, 64, 0, 0, 0, 0}, 756 {0, 1, 14, 31, 17, 1, 0, 0}, 757 {0, 0, 13, 31, 18, 2, 0, 0}, 758 {0, 0, 11, 31, 20, 2, 0, 0}, 759 {0, 0, 10, 30, 21, 3, 0, 0}, 760 {0, 0, 9, 29, 22, 4, 0, 0}, 761 {0, 0, 8, 28, 23, 5, 0, 0}, 762 {0, 1, 8, 27, 24, 6, 0, 0}, 763 {0, 1, 7, 26, 26, 7, 1, 0}, 764 {0, 0, 6, 24, 27, 8, 1, 0}, 765 {0, 0, 5, 23, 28, 8, 0, 0}, 766 {0, 0, 4, 22, 29, 9, 0, 0}, 767 {0, 0, 3, 21, 30, 10, 0, 0}, 768 {0, 0, 2, 20, 31, 11, 0, 0}, 769 {0, 0, 2, 18, 31, 13, 0, 0}, 770 {0, 0, 1, 17, 31, 14, 1, 0}}, 771 {{0, 0, 0, 64, 0, 0, 0, 0}, 772 {1, 1, 3, 63, 4, 1, 1, 0}, 773 {1, 3, 6, 62, 8, 3, 2, 1}, 774 {1, 4, 9, 60, 13, 5, 3, 1}, 775 {2, 5, 11, 58, 19, 7, 3, 1}, 776 {2, 5, 11, 54, 24, 9, 4, 1}, 777 {2, 5, 12, 50, 30, 10, 4, 1}, 778 {2, 5, 12, 45, 35, 11, 5, 1}, 779 {2, 6, 12, 40, 40, 12, 6, 2}, 780 {1, 5, 11, 35, 45, 12, 5, 2}, 781 {1, 4, 10, 30, 50, 12, 5, 2}, 782 {1, 4, 9, 24, 54, 11, 5, 2}, 783 {1, 3, 7, 19, 58, 11, 5, 2}, 784 {1, 3, 5, 13, 60, 9, 4, 1}, 785 {1, 2, 3, 8, 62, 6, 3, 1}, 786 {0, 1, 1, 4, 63, 3, 1, 1}}, 787 {{0, 0, 0, 64, 0, 0, 0, 0}, 788 {0, 0, 0, 60, 4, 0, 0, 0}, 789 {0, 0, 0, 56, 8, 0, 0, 0}, 790 {0, 0, 0, 52, 12, 0, 0, 0}, 791 {0, 0, 0, 48, 16, 0, 0, 0}, 792 {0, 0, 0, 44, 20, 0, 0, 0}, 793 {0, 0, 0, 40, 24, 0, 0, 0}, 794 {0, 0, 0, 36, 28, 0, 0, 0}, 795 {0, 0, 0, 32, 32, 0, 0, 0}, 796 {0, 0, 0, 28, 36, 0, 0, 0}, 797 {0, 0, 0, 24, 40, 0, 0, 0}, 798 {0, 0, 0, 20, 44, 0, 0, 0}, 799 {0, 0, 0, 16, 48, 0, 0, 0}, 800 {0, 0, 0, 12, 52, 0, 0, 0}, 801 {0, 0, 0, 8, 56, 0, 0, 0}, 802 {0, 0, 0, 4, 60, 0, 0, 0}}, 803 {{0, 0, 0, 64, 0, 0, 0, 0}, 804 {0, 0, 2, 63, 4, 1, 0, 0}, 805 {0, 0, 4, 61, 9, 2, 0, 0}, 806 {0, 0, 5, 58, 14, 3, 0, 0}, 807 {0, 0, 6, 55, 19, 4, 0, 0}, 808 {0, 0, 6, 51, 24, 5, 0, 0}, 809 {0, 0, 7, 47, 29, 5, 0, 0}, 810 {0, 0, 6, 42, 33, 5, 0, 0}, 811 {0, 0, 6, 38, 38, 6, 0, 0}, 812 {0, 0, 5, 33, 42, 6, 0, 0}, 813 {0, 0, 5, 29, 47, 7, 0, 0}, 814 {0, 0, 5, 24, 51, 6, 0, 0}, 815 {0, 0, 4, 19, 55, 6, 0, 0}, 816 {0, 0, 3, 14, 58, 5, 0, 0}, 817 {0, 0, 2, 9, 61, 4, 0, 0}, 818 {0, 0, 1, 4, 63, 2, 0, 0}}, 819 {{0, 0, 0, 64, 0, 0, 0, 0}, 820 {0, 0, 15, 31, 17, 1, 0, 0}, 821 {0, 0, 13, 31, 18, 2, 0, 0}, 822 {0, 0, 11, 31, 20, 2, 0, 0}, 823 {0, 0, 10, 30, 21, 3, 0, 0}, 824 {0, 0, 9, 29, 22, 4, 0, 0}, 825 {0, 0, 8, 28, 23, 5, 0, 0}, 826 {0, 0, 7, 27, 24, 6, 0, 0}, 827 {0, 0, 6, 26, 26, 6, 0, 0}, 828 {0, 0, 6, 24, 27, 7, 0, 0}, 829 {0, 0, 5, 23, 28, 8, 0, 0}, 830 {0, 0, 4, 22, 29, 9, 0, 0}, 831 {0, 0, 3, 21, 30, 10, 0, 0}, 832 {0, 0, 2, 20, 31, 11, 0, 0}, 833 {0, 0, 2, 18, 31, 13, 0, 0}, 834 {0, 0, 1, 17, 31, 15, 0, 0}}}; 835 836 // 9.3 -- Dr_Intra_Derivative[] 837 // This is a more compact version of the table from the spec. angle / 2 - 1 is 838 // used as the lookup. Note angle / 3 - 1 would work too, but the calculation 839 // becomes more costly. 840 const int16_t kDirectionalIntraPredictorDerivative[44] = { 841 // Approx angle 842 1023, 0, // 3, ... 843 547, // 6, ... 844 372, 0, 0, // 9, ... 845 273, // 14, ... 846 215, 0, // 17, ... 847 178, // 20, ... 848 151, 0, // 23, ... (113 & 203 are base angles) 849 132, // 26, ... 850 116, 0, // 29, ... 851 102, 0, // 32, ... 852 90, // 36, ... 853 80, 0, // 39, ... 854 71, // 42, ... 855 64, 0, // 45, ... (45 & 135 are base angles) 856 57, // 48, ... 857 51, 0, // 51, ... 858 45, 0, // 54, ... 859 40, // 58, ... 860 35, 0, // 61, ... 861 31, // 64, ... 862 27, 0, // 67, ... (67 & 157 are base angles) 863 23, // 70, ... 864 19, 0, // 73, ... 865 15, 0, // 76, ... 866 11, 0, // 81, ... 867 7, // 84, ... 868 3, // 87, ... 869 }; 870 871 const uint8_t kDeblockFilterLevelIndex[kMaxPlanes][kNumLoopFilterTypes] = { 872 {0, 1}, {2, 2}, {3, 3}}; 873 874 } // namespace libgav1 875