1 /*
2 * Copyright 2019 The libgav1 Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef LIBGAV1_SRC_UTILS_CONSTANTS_H_
18 #define LIBGAV1_SRC_UTILS_CONSTANTS_H_
19
20 #include <cstdint>
21 #include <cstdlib>
22
23 #include "src/utils/bit_mask_set.h"
24
25 namespace libgav1 {
26
27 // Returns the number of elements between begin (inclusive) and end (inclusive).
EnumRangeLength(int begin,int end)28 constexpr int EnumRangeLength(int begin, int end) { return end - begin + 1; }
29
30 enum {
31 // Maximum number of threads that the library will ever create.
32 #if defined(LIBGAV1_MAX_THREADS) && LIBGAV1_MAX_THREADS > 0
33 kMaxThreads = LIBGAV1_MAX_THREADS
34 #else
35 kMaxThreads = 128
36 #endif
37 }; // anonymous enum
38
39 enum {
40 // Documentation variables.
41 kBitdepth8 = 8,
42 kBitdepth10 = 10,
43 kBitdepth12 = 12,
44 kInvalidMvValue = -32768,
45 kCdfMaxProbability = 32768,
46 kBlockWidthCount = 5,
47 kMaxSegments = 8,
48 kMinQuantizer = 0,
49 kMinLossyQuantizer = 1,
50 kMaxQuantizer = 255,
51 // Quantizer matrix is used only when level < 15.
52 kNumQuantizerLevelsForQuantizerMatrix = 15,
53 kFrameLfCount = 4,
54 kMaxLoopFilterValue = 63,
55 kNum4x4In64x64 = 256,
56 kMaxAngleDelta = 3,
57 kDirectionalIntraModes = 8,
58 kMaxSuperBlockSizeLog2 = 7,
59 kMinSuperBlockSizeLog2 = 6,
60 kGlobalMotionReadControl = 3,
61 kSuperResScaleNumerator = 8,
62 kBooleanSymbolCount = 2,
63 kRestorationTypeSymbolCount = 3,
64 kSgrProjParamsBits = 4,
65 kSgrProjPrecisionBits = 7,
66 // Precision of a division table (mtable)
67 kSgrProjScaleBits = 20,
68 kSgrProjReciprocalBits = 12,
69 // Core self-guided restoration precision bits.
70 kSgrProjSgrBits = 8,
71 // Precision bits of generated values higher than source before projection.
72 kSgrProjRestoreBits = 4,
73 // Padding on left and right side of a restoration block.
74 // 3 is enough, but padding to 4 is more efficient, and makes the temporary
75 // source buffer 8-pixel aligned.
76 kRestorationHorizontalBorder = 4,
77 // Padding on top and bottom side of a restoration block.
78 kRestorationVerticalBorder = 2,
79 kCdefBorder = 2, // Padding on each side of a cdef block.
80 kConvolveBorderLeftTop = 3, // Left/top padding of a convolve block.
81 // Right/bottom padding of a convolve block. This needs to be 4 at minimum,
82 // but was increased to simplify the SIMD loads in
83 // ConvolveCompoundScale2D_NEON() and ConvolveScale2D_NEON().
84 kConvolveBorderRight = 8,
85 kConvolveScaleBorderRight = 15,
86 kConvolveBorderBottom = 4,
87 kSubPixelTaps = 8,
88 kWienerFilterBits = 7,
89 kWienerFilterTaps = 7,
90 kMaxPaletteSize = 8,
91 kMinPaletteSize = 2,
92 kMaxPaletteSquare = 64,
93 kBorderPixels = 64,
94 // The final blending process for film grain needs room to overwrite and read
95 // with SIMD instructions. The maximum overwrite is 7 pixels, but the border
96 // is required to be a multiple of 32 by YuvBuffer::Realloc, so that
97 // subsampled chroma borders are 16-aligned.
98 kBorderPixelsFilmGrain = 32,
99 // These constants are the minimum left, right, top, and bottom border sizes
100 // in pixels as an extension of the frame boundary. The minimum border sizes
101 // are derived from the following requirements:
102 // - Warp_C() may read up to 13 pixels before or after a row.
103 // - Warp_NEON() may read up to 13 pixels before a row. It may read up to 14
104 // pixels after a row, but the value of the last read pixel is not used.
105 // - Warp_C() and Warp_NEON() may read up to 13 pixels above the top row and
106 // 13 pixels below the bottom row.
107 kMinLeftBorderPixels = 13,
108 kMinRightBorderPixels = 13,
109 kMinTopBorderPixels = 13,
110 kMinBottomBorderPixels = 13,
111 kWarpedModelPrecisionBits = 16,
112 kMaxRefMvStackSize = 8,
113 kMaxLeastSquaresSamples = 8,
114 kMaxTemporalMvCandidates = 19,
115 // The SIMD implementations of motion vection projection functions always
116 // process 2 or 4 elements together, so we pad the corresponding buffers to
117 // size 20.
118 kMaxTemporalMvCandidatesWithPadding = 20,
119 kMaxSuperBlockSizeInPixels = 128,
120 kMaxScaledSuperBlockSizeInPixels = 128 * 2,
121 kMaxSuperBlockSizeSquareInPixels = 128 * 128,
122 kNum4x4InLoopFilterUnit = 16,
123 kNum4x4InLoopRestorationUnit = 16,
124 kProjectionMvClamp = (1 << 14) - 1, // == 16383
125 kProjectionMvMaxHorizontalOffset = 8,
126 kCdefUnitSize = 64,
127 kCdefUnitSizeWithBorders = kCdefUnitSize + 2 * kCdefBorder,
128 kRestorationUnitOffset = 8,
129 // Loop restoration's processing unit size is fixed as 64x64.
130 kRestorationUnitHeight = 64,
131 kRestorationUnitWidth = 256,
132 kRestorationUnitHeightWithBorders =
133 kRestorationUnitHeight + 2 * kRestorationVerticalBorder,
134 kRestorationUnitWidthWithBorders =
135 kRestorationUnitWidth + 2 * kRestorationHorizontalBorder,
136 kSuperResFilterBits = 6,
137 kSuperResFilterShifts = 1 << kSuperResFilterBits,
138 kSuperResFilterTaps = 8,
139 kSuperResScaleBits = 14,
140 kSuperResExtraBits = kSuperResScaleBits - kSuperResFilterBits,
141 kSuperResScaleMask = (1 << 14) - 1,
142 kSuperResHorizontalBorder = 4,
143 kSuperResVerticalBorder = 1,
144 // The SIMD implementations of superres calculate up to 15 extra upscaled
145 // pixels which will over-read up to 15 downscaled pixels in the end of each
146 // row. Set the padding to 16 for alignment purposes.
147 kSuperResHorizontalPadding = 16,
148 // TODO(chengchen): consider merging these constants:
149 // kFilterBits, kWienerFilterBits, and kSgrProjPrecisionBits, which are all 7,
150 // They are designed to match AV1 convolution, which increases coeff
151 // values up to 7 bits. We could consider to combine them and use kFilterBits
152 // only.
153 kFilterBits = 7,
154 // Sub pixel is used in AV1 to represent a pixel location that is not at
155 // integer position. Sub pixel is in 1/16 (1 << kSubPixelBits) unit of
156 // integer pixel. Sub pixel values are interpolated using adjacent integer
157 // pixel values. The interpolation is a filtering process.
158 kSubPixelBits = 4,
159 kSubPixelMask = (1 << kSubPixelBits) - 1,
160 // Precision bits when computing inter prediction locations.
161 kScaleSubPixelBits = 10,
162 kWarpParamRoundingBits = 6,
163 // Number of fractional bits of lookup in divisor lookup table.
164 kDivisorLookupBits = 8,
165 // Number of fractional bits of entries in divisor lookup table.
166 kDivisorLookupPrecisionBits = 14,
167 // Number of phases used in warped filtering.
168 kWarpedPixelPrecisionShifts = 1 << 6,
169 kResidualPaddingVertical = 4,
170 kWedgeMaskMasterSize = 64,
171 kMaxFrameDistance = 31,
172 kReferenceFrameScalePrecision = 14,
173 kNumWienerCoefficients = 3,
174 kLoopFilterMaxModeDeltas = 2,
175 kMaxCdefStrengths = 8,
176 kCdefLargeValue = 0x4000, // Used to indicate where CDEF is not available.
177 kMaxTileColumns = 64,
178 kMaxTileRows = 64,
179 kMaxOperatingPoints = 32,
180 // There can be a maximum of 4 spatial layers and 8 temporal layers.
181 kMaxLayers = 32,
182 // The cache line size should ideally be queried at run time. 64 is a common
183 // cache line size of x86 CPUs. Web searches showed the cache line size of ARM
184 // CPUs is 32 or 64 bytes. So aligning to 64-byte boundary will work for all
185 // CPUs that we care about, even though it is excessive for some ARM
186 // CPUs.
187 //
188 // On Linux, the cache line size can be looked up with the command:
189 // getconf LEVEL1_DCACHE_LINESIZE
190 kCacheLineSize = 64,
191 // InterRound0, Section 7.11.3.2.
192 kInterRoundBitsHorizontal = 3, // 8 & 10-bit.
193 kInterRoundBitsHorizontal12bpp = 5,
194 kInterRoundBitsCompoundVertical = 7, // 8, 10 & 12-bit compound prediction.
195 kInterRoundBitsVertical = 11, // 8 & 10-bit, single prediction.
196 kInterRoundBitsVertical12bpp = 9,
197 // Offset applied to 10bpp and 12bpp predictors to allow storing them in
198 // uint16_t. Removed before blending.
199 kCompoundOffset = (1 << 14) + (1 << 13),
200 }; // anonymous enum
201
202 enum FrameType : uint8_t {
203 kFrameKey,
204 kFrameInter,
205 kFrameIntraOnly,
206 kFrameSwitch
207 };
208
209 enum Plane : uint8_t { kPlaneY, kPlaneU, kPlaneV };
210 enum : uint8_t { kMaxPlanesMonochrome = kPlaneY + 1, kMaxPlanes = kPlaneV + 1 };
211
212 // The plane types, called luma and chroma in the spec.
213 enum PlaneType : uint8_t { kPlaneTypeY, kPlaneTypeUV, kNumPlaneTypes };
214
215 enum ReferenceFrameType : int8_t {
216 kReferenceFrameNone = -1,
217 kReferenceFrameIntra,
218 kReferenceFrameLast,
219 kReferenceFrameLast2,
220 kReferenceFrameLast3,
221 kReferenceFrameGolden,
222 kReferenceFrameBackward,
223 kReferenceFrameAlternate2,
224 kReferenceFrameAlternate,
225 kNumReferenceFrameTypes,
226 kNumInterReferenceFrameTypes =
227 EnumRangeLength(kReferenceFrameLast, kReferenceFrameAlternate),
228 kNumForwardReferenceTypes =
229 EnumRangeLength(kReferenceFrameLast, kReferenceFrameGolden),
230 kNumBackwardReferenceTypes =
231 EnumRangeLength(kReferenceFrameBackward, kReferenceFrameAlternate)
232 };
233
234 enum {
235 // Unidirectional compound reference pairs that are signaled explicitly:
236 // {kReferenceFrameLast, kReferenceFrameLast2},
237 // {kReferenceFrameLast, kReferenceFrameLast3},
238 // {kReferenceFrameLast, kReferenceFrameGolden},
239 // {kReferenceFrameBackward, kReferenceFrameAlternate}
240 kExplicitUnidirectionalCompoundReferences = 4,
241 // Other unidirectional compound reference pairs:
242 // {kReferenceFrameLast2, kReferenceFrameLast3},
243 // {kReferenceFrameLast2, kReferenceFrameGolden},
244 // {kReferenceFrameLast3, kReferenceFrameGolden},
245 // {kReferenceFrameBackward, kReferenceFrameAlternate2},
246 // {kReferenceFrameAlternate2, kReferenceFrameAlternate}
247 kUnidirectionalCompoundReferences =
248 kExplicitUnidirectionalCompoundReferences + 5,
249 }; // anonymous enum
250
251 enum BlockSize : uint8_t {
252 kBlock4x4,
253 kBlock4x8,
254 kBlock4x16,
255 kBlock8x4,
256 kBlock8x8,
257 kBlock8x16,
258 kBlock8x32,
259 kBlock16x4,
260 kBlock16x8,
261 kBlock16x16,
262 kBlock16x32,
263 kBlock16x64,
264 kBlock32x8,
265 kBlock32x16,
266 kBlock32x32,
267 kBlock32x64,
268 kBlock64x16,
269 kBlock64x32,
270 kBlock64x64,
271 kBlock64x128,
272 kBlock128x64,
273 kBlock128x128,
274 kMaxBlockSizes,
275 kBlockInvalid
276 };
277
278 // Partition types. R: Recursive
279 //
280 // None Horizontal Vertical Split
281 // +-------+ +-------+ +---+---+ +---+---+
282 // | | | | | | | | R | R |
283 // | | +-------+ | | | +---+---+
284 // | | | | | | | | R | R |
285 // +-------+ +-------+ +---+---+ +---+---+
286 //
287 // Horizontal Horizontal Vertical Vertical
288 // with top with bottom with left with right
289 // split split split split
290 // +---+---+ +-------+ +---+---+ +---+---+
291 // | | | | | | | | | | |
292 // +---+---+ +---+---+ +---+ | | +---+
293 // | | | | | | | | | | |
294 // +-------+ +---+---+ +---+---+ +---+---+
295 //
296 // Horizontal4 Vertical4
297 // +-----+ +-+-+-+
298 // +-----+ | | | |
299 // +-----+ | | | |
300 // +-----+ +-+-+-+
301 enum Partition : uint8_t {
302 kPartitionNone,
303 kPartitionHorizontal,
304 kPartitionVertical,
305 kPartitionSplit,
306 kPartitionHorizontalWithTopSplit,
307 kPartitionHorizontalWithBottomSplit,
308 kPartitionVerticalWithLeftSplit,
309 kPartitionVerticalWithRightSplit,
310 kPartitionHorizontal4,
311 kPartitionVertical4
312 };
313 enum : uint8_t { kMaxPartitionTypes = kPartitionVertical4 + 1 };
314
315 enum PredictionMode : uint8_t {
316 // Intra prediction modes.
317 kPredictionModeDc,
318 kPredictionModeVertical,
319 kPredictionModeHorizontal,
320 kPredictionModeD45,
321 kPredictionModeD135,
322 kPredictionModeD113,
323 kPredictionModeD157,
324 kPredictionModeD203,
325 kPredictionModeD67,
326 kPredictionModeSmooth,
327 kPredictionModeSmoothVertical,
328 kPredictionModeSmoothHorizontal,
329 kPredictionModePaeth,
330 kPredictionModeChromaFromLuma,
331 // Single inter prediction modes.
332 kPredictionModeNearestMv,
333 kPredictionModeNearMv,
334 kPredictionModeGlobalMv,
335 kPredictionModeNewMv,
336 // Compound inter prediction modes.
337 kPredictionModeNearestNearestMv,
338 kPredictionModeNearNearMv,
339 kPredictionModeNearestNewMv,
340 kPredictionModeNewNearestMv,
341 kPredictionModeNearNewMv,
342 kPredictionModeNewNearMv,
343 kPredictionModeGlobalGlobalMv,
344 kPredictionModeNewNewMv,
345 kNumPredictionModes,
346 kNumCompoundInterPredictionModes =
347 EnumRangeLength(kPredictionModeNearestNearestMv, kPredictionModeNewNewMv),
348 kIntraPredictionModesY =
349 EnumRangeLength(kPredictionModeDc, kPredictionModePaeth),
350 kIntraPredictionModesUV =
351 EnumRangeLength(kPredictionModeDc, kPredictionModeChromaFromLuma),
352 kPredictionModeInvalid = 255
353 };
354
355 enum InterIntraMode : uint8_t {
356 kInterIntraModeDc,
357 kInterIntraModeVertical,
358 kInterIntraModeHorizontal,
359 kInterIntraModeSmooth,
360 kNumInterIntraModes
361 };
362
363 enum MotionMode : uint8_t {
364 kMotionModeSimple,
365 kMotionModeObmc, // Overlapped block motion compensation.
366 kMotionModeLocalWarp,
367 kNumMotionModes
368 };
369
370 enum TxMode : uint8_t {
371 kTxModeOnly4x4,
372 kTxModeLargest,
373 kTxModeSelect,
374 kNumTxModes
375 };
376
377 // These enums are named as kType1Type2 where Type1 is the transform type for
378 // the rows and Type2 is the transform type for the columns.
379 enum TransformType : uint8_t {
380 kTransformTypeDctDct,
381 kTransformTypeAdstDct,
382 kTransformTypeDctAdst,
383 kTransformTypeAdstAdst,
384 kTransformTypeFlipadstDct,
385 kTransformTypeDctFlipadst,
386 kTransformTypeFlipadstFlipadst,
387 kTransformTypeAdstFlipadst,
388 kTransformTypeFlipadstAdst,
389 kTransformTypeIdentityIdentity,
390 kTransformTypeIdentityDct,
391 kTransformTypeDctIdentity,
392 kTransformTypeIdentityAdst,
393 kTransformTypeAdstIdentity,
394 kTransformTypeIdentityFlipadst,
395 kTransformTypeFlipadstIdentity,
396 kNumTransformTypes
397 };
398
399 constexpr BitMaskSet kTransformFlipColumnsMask(kTransformTypeFlipadstDct,
400 kTransformTypeFlipadstAdst,
401 kTransformTypeFlipadstIdentity,
402 kTransformTypeFlipadstFlipadst);
403 constexpr BitMaskSet kTransformFlipRowsMask(kTransformTypeDctFlipadst,
404 kTransformTypeAdstFlipadst,
405 kTransformTypeIdentityFlipadst,
406 kTransformTypeFlipadstFlipadst);
407
408 enum TransformSize : uint8_t {
409 kTransformSize4x4,
410 kTransformSize4x8,
411 kTransformSize4x16,
412 kTransformSize8x4,
413 kTransformSize8x8,
414 kTransformSize8x16,
415 kTransformSize8x32,
416 kTransformSize16x4,
417 kTransformSize16x8,
418 kTransformSize16x16,
419 kTransformSize16x32,
420 kTransformSize16x64,
421 kTransformSize32x8,
422 kTransformSize32x16,
423 kTransformSize32x32,
424 kTransformSize32x64,
425 kTransformSize64x16,
426 kTransformSize64x32,
427 kTransformSize64x64,
428 kNumTransformSizes
429 };
430
431 enum TransformSet : uint8_t {
432 // DCT Only (1).
433 kTransformSetDctOnly,
434 // 2D-DCT and 2D-ADST without flip (4) + Identity (1) + 1D Horizontal/Vertical
435 // DCT (2) = Total (7).
436 kTransformSetIntra1,
437 // 2D-DCT and 2D-ADST without flip (4) + Identity (1) = Total (5).
438 kTransformSetIntra2,
439 // All transforms = Total (16).
440 kTransformSetInter1,
441 // 2D-DCT and 2D-ADST with flip (9) + Identity (1) + 1D Horizontal/Vertical
442 // DCT (2) = Total (12).
443 kTransformSetInter2,
444 // DCT (1) + Identity (1) = Total (2).
445 kTransformSetInter3,
446 kNumTransformSets
447 };
448
449 enum TransformClass : uint8_t {
450 kTransformClass2D,
451 kTransformClassHorizontal,
452 kTransformClassVertical,
453 kNumTransformClasses
454 };
455
456 enum FilterIntraPredictor : uint8_t {
457 kFilterIntraPredictorDc,
458 kFilterIntraPredictorVertical,
459 kFilterIntraPredictorHorizontal,
460 kFilterIntraPredictorD157,
461 kFilterIntraPredictorPaeth,
462 kNumFilterIntraPredictors
463 };
464
465 enum ObmcDirection : uint8_t {
466 kObmcDirectionVertical,
467 kObmcDirectionHorizontal,
468 kNumObmcDirections
469 };
470
471 // In AV1 the name of the filter refers to the direction of filter application.
472 // Horizontal refers to the column edge and vertical the row edge.
473 enum LoopFilterType : uint8_t {
474 kLoopFilterTypeVertical,
475 kLoopFilterTypeHorizontal,
476 kNumLoopFilterTypes
477 };
478
479 enum LoopFilterTransformSizeId : uint8_t {
480 kLoopFilterTransformSizeId4x4,
481 kLoopFilterTransformSizeId8x8,
482 kLoopFilterTransformSizeId16x16,
483 kNumLoopFilterTransformSizeIds
484 };
485
486 enum LoopRestorationType : uint8_t {
487 kLoopRestorationTypeNone,
488 kLoopRestorationTypeSwitchable,
489 kLoopRestorationTypeWiener,
490 kLoopRestorationTypeSgrProj, // self guided projection filter.
491 kNumLoopRestorationTypes
492 };
493
494 enum CompoundReferenceType : uint8_t {
495 kCompoundReferenceUnidirectional,
496 kCompoundReferenceBidirectional,
497 kNumCompoundReferenceTypes
498 };
499
500 enum CompoundPredictionType : uint8_t {
501 kCompoundPredictionTypeWedge,
502 kCompoundPredictionTypeDiffWeighted,
503 kCompoundPredictionTypeAverage,
504 kCompoundPredictionTypeIntra,
505 kCompoundPredictionTypeDistance,
506 kNumCompoundPredictionTypes,
507 // Number of compound prediction types that are explicitly signaled in the
508 // bitstream (in the compound_type syntax element).
509 kNumExplicitCompoundPredictionTypes = 2
510 };
511
512 enum InterpolationFilter : uint8_t {
513 kInterpolationFilterEightTap,
514 kInterpolationFilterEightTapSmooth,
515 kInterpolationFilterEightTapSharp,
516 kInterpolationFilterBilinear,
517 kInterpolationFilterSwitchable,
518 kNumInterpolationFilters,
519 // Number of interpolation filters that can be explicitly signaled in the
520 // compressed headers (when the uncompressed headers allow switchable
521 // interpolation filters) of the bitstream.
522 kNumExplicitInterpolationFilters = EnumRangeLength(
523 kInterpolationFilterEightTap, kInterpolationFilterEightTapSharp)
524 };
525
526 enum MvJointType : uint8_t {
527 kMvJointTypeZero,
528 kMvJointTypeHorizontalNonZeroVerticalZero,
529 kMvJointTypeHorizontalZeroVerticalNonZero,
530 kMvJointTypeNonZero,
531 kNumMvJointTypes
532 };
533
534 enum ObuType : int8_t {
535 kObuInvalid = -1,
536 kObuSequenceHeader = 1,
537 kObuTemporalDelimiter = 2,
538 kObuFrameHeader = 3,
539 kObuTileGroup = 4,
540 kObuMetadata = 5,
541 kObuFrame = 6,
542 kObuRedundantFrameHeader = 7,
543 kObuTileList = 8,
544 kObuPadding = 15,
545 };
546
547 constexpr BitMaskSet kPredictionModeSmoothMask(kPredictionModeSmooth,
548 kPredictionModeSmoothHorizontal,
549 kPredictionModeSmoothVertical);
550
551 //------------------------------------------------------------------------------
552 // ToString()
553 //
554 // These functions are meant to be used only in debug logging and within tests.
555 // They are defined inline to avoid including the strings in the release
556 // library when logging is disabled; unreferenced functions will not be added to
557 // any object file in that case.
558
ToString(const BlockSize size)559 inline const char* ToString(const BlockSize size) {
560 switch (size) {
561 case kBlock4x4:
562 return "kBlock4x4";
563 case kBlock4x8:
564 return "kBlock4x8";
565 case kBlock4x16:
566 return "kBlock4x16";
567 case kBlock8x4:
568 return "kBlock8x4";
569 case kBlock8x8:
570 return "kBlock8x8";
571 case kBlock8x16:
572 return "kBlock8x16";
573 case kBlock8x32:
574 return "kBlock8x32";
575 case kBlock16x4:
576 return "kBlock16x4";
577 case kBlock16x8:
578 return "kBlock16x8";
579 case kBlock16x16:
580 return "kBlock16x16";
581 case kBlock16x32:
582 return "kBlock16x32";
583 case kBlock16x64:
584 return "kBlock16x64";
585 case kBlock32x8:
586 return "kBlock32x8";
587 case kBlock32x16:
588 return "kBlock32x16";
589 case kBlock32x32:
590 return "kBlock32x32";
591 case kBlock32x64:
592 return "kBlock32x64";
593 case kBlock64x16:
594 return "kBlock64x16";
595 case kBlock64x32:
596 return "kBlock64x32";
597 case kBlock64x64:
598 return "kBlock64x64";
599 case kBlock64x128:
600 return "kBlock64x128";
601 case kBlock128x64:
602 return "kBlock128x64";
603 case kBlock128x128:
604 return "kBlock128x128";
605 case kMaxBlockSizes:
606 return "kMaxBlockSizes";
607 case kBlockInvalid:
608 return "kBlockInvalid";
609 }
610 abort();
611 }
612
ToString(const InterIntraMode mode)613 inline const char* ToString(const InterIntraMode mode) {
614 switch (mode) {
615 case kInterIntraModeDc:
616 return "kInterIntraModeDc";
617 case kInterIntraModeVertical:
618 return "kInterIntraModeVertical";
619 case kInterIntraModeHorizontal:
620 return "kInterIntraModeHorizontal";
621 case kInterIntraModeSmooth:
622 return "kInterIntraModeSmooth";
623 case kNumInterIntraModes:
624 return "kNumInterIntraModes";
625 }
626 abort();
627 }
628
ToString(const ObmcDirection direction)629 inline const char* ToString(const ObmcDirection direction) {
630 switch (direction) {
631 case kObmcDirectionVertical:
632 return "kObmcDirectionVertical";
633 case kObmcDirectionHorizontal:
634 return "kObmcDirectionHorizontal";
635 case kNumObmcDirections:
636 return "kNumObmcDirections";
637 }
638 abort();
639 }
640
ToString(const LoopRestorationType type)641 inline const char* ToString(const LoopRestorationType type) {
642 switch (type) {
643 case kLoopRestorationTypeNone:
644 return "kLoopRestorationTypeNone";
645 case kLoopRestorationTypeSwitchable:
646 return "kLoopRestorationTypeSwitchable";
647 case kLoopRestorationTypeWiener:
648 return "kLoopRestorationTypeWiener";
649 case kLoopRestorationTypeSgrProj:
650 return "kLoopRestorationTypeSgrProj";
651 case kNumLoopRestorationTypes:
652 return "kNumLoopRestorationTypes";
653 }
654 abort();
655 }
656
ToString(const TransformSize size)657 inline const char* ToString(const TransformSize size) {
658 switch (size) {
659 case kTransformSize4x4:
660 return "kTransformSize4x4";
661 case kTransformSize4x8:
662 return "kTransformSize4x8";
663 case kTransformSize4x16:
664 return "kTransformSize4x16";
665 case kTransformSize8x4:
666 return "kTransformSize8x4";
667 case kTransformSize8x8:
668 return "kTransformSize8x8";
669 case kTransformSize8x16:
670 return "kTransformSize8x16";
671 case kTransformSize8x32:
672 return "kTransformSize8x32";
673 case kTransformSize16x4:
674 return "kTransformSize16x4";
675 case kTransformSize16x8:
676 return "kTransformSize16x8";
677 case kTransformSize16x16:
678 return "kTransformSize16x16";
679 case kTransformSize16x32:
680 return "kTransformSize16x32";
681 case kTransformSize16x64:
682 return "kTransformSize16x64";
683 case kTransformSize32x8:
684 return "kTransformSize32x8";
685 case kTransformSize32x16:
686 return "kTransformSize32x16";
687 case kTransformSize32x32:
688 return "kTransformSize32x32";
689 case kTransformSize32x64:
690 return "kTransformSize32x64";
691 case kTransformSize64x16:
692 return "kTransformSize64x16";
693 case kTransformSize64x32:
694 return "kTransformSize64x32";
695 case kTransformSize64x64:
696 return "kTransformSize64x64";
697 case kNumTransformSizes:
698 return "kNumTransformSizes";
699 }
700 abort();
701 }
702
ToString(const TransformType type)703 inline const char* ToString(const TransformType type) {
704 switch (type) {
705 case kTransformTypeDctDct:
706 return "kTransformTypeDctDct";
707 case kTransformTypeAdstDct:
708 return "kTransformTypeAdstDct";
709 case kTransformTypeDctAdst:
710 return "kTransformTypeDctAdst";
711 case kTransformTypeAdstAdst:
712 return "kTransformTypeAdstAdst";
713 case kTransformTypeFlipadstDct:
714 return "kTransformTypeFlipadstDct";
715 case kTransformTypeDctFlipadst:
716 return "kTransformTypeDctFlipadst";
717 case kTransformTypeFlipadstFlipadst:
718 return "kTransformTypeFlipadstFlipadst";
719 case kTransformTypeAdstFlipadst:
720 return "kTransformTypeAdstFlipadst";
721 case kTransformTypeFlipadstAdst:
722 return "kTransformTypeFlipadstAdst";
723 case kTransformTypeIdentityIdentity:
724 return "kTransformTypeIdentityIdentity";
725 case kTransformTypeIdentityDct:
726 return "kTransformTypeIdentityDct";
727 case kTransformTypeDctIdentity:
728 return "kTransformTypeDctIdentity";
729 case kTransformTypeIdentityAdst:
730 return "kTransformTypeIdentityAdst";
731 case kTransformTypeAdstIdentity:
732 return "kTransformTypeAdstIdentity";
733 case kTransformTypeIdentityFlipadst:
734 return "kTransformTypeIdentityFlipadst";
735 case kTransformTypeFlipadstIdentity:
736 return "kTransformTypeFlipadstIdentity";
737 // case to quiet compiler
738 case kNumTransformTypes:
739 return "kNumTransformTypes";
740 }
741 abort();
742 }
743
744 //------------------------------------------------------------------------------
745
746 extern const uint8_t k4x4WidthLog2[kMaxBlockSizes];
747
748 extern const uint8_t k4x4HeightLog2[kMaxBlockSizes];
749
750 extern const uint8_t kNum4x4BlocksWide[kMaxBlockSizes];
751
752 extern const uint8_t kNum4x4BlocksHigh[kMaxBlockSizes];
753
754 extern const uint8_t kBlockWidthPixels[kMaxBlockSizes];
755
756 extern const uint8_t kBlockHeightPixels[kMaxBlockSizes];
757
758 extern const BlockSize kSubSize[kMaxPartitionTypes][kMaxBlockSizes];
759
760 extern const BlockSize kPlaneResidualSize[kMaxBlockSizes][2][2];
761
762 extern const int16_t kProjectionMvDivisionLookup[kMaxFrameDistance + 1];
763
764 extern const uint8_t kTransformWidth[kNumTransformSizes];
765
766 extern const uint8_t kTransformHeight[kNumTransformSizes];
767
768 extern const uint8_t kTransformWidth4x4[kNumTransformSizes];
769
770 extern const uint8_t kTransformHeight4x4[kNumTransformSizes];
771
772 extern const uint8_t kTransformWidthLog2[kNumTransformSizes];
773
774 extern const uint8_t kTransformHeightLog2[kNumTransformSizes];
775
776 extern const TransformSize kSplitTransformSize[kNumTransformSizes];
777
778 // Square transform of size min(w,h).
779 extern const TransformSize kTransformSizeSquareMin[kNumTransformSizes];
780
781 // Square transform of size max(w,h).
782 extern const TransformSize kTransformSizeSquareMax[kNumTransformSizes];
783
784 extern const uint8_t kNumTransformTypesInSet[kNumTransformSets];
785
786 extern const uint8_t kSgrProjParams[1 << kSgrProjParamsBits][4];
787
788 extern const int8_t kSgrProjMultiplierMin[2];
789
790 extern const int8_t kSgrProjMultiplierMax[2];
791
792 extern const int8_t kWienerTapsMin[3];
793
794 extern const int8_t kWienerTapsMax[3];
795
796 extern const uint8_t kUpscaleFilterUnsigned[kSuperResFilterShifts]
797 [kSuperResFilterTaps];
798
799 // An int8_t version of the kWarpedFilters array.
800 // Note: The array could be removed with a performance penalty.
801 extern const int8_t kWarpedFilters8[3 * kWarpedPixelPrecisionShifts + 1][8];
802
803 extern const int16_t kWarpedFilters[3 * kWarpedPixelPrecisionShifts + 1][8];
804
805 extern const int8_t kHalfSubPixelFilters[6][16][8];
806
807 extern const uint8_t kAbsHalfSubPixelFilters[6][16][8];
808
809 extern const int16_t kDirectionalIntraPredictorDerivative[44];
810
811 extern const uint8_t kDeblockFilterLevelIndex[kMaxPlanes][kNumLoopFilterTypes];
812
813 } // namespace libgav1
814
815 #endif // LIBGAV1_SRC_UTILS_CONSTANTS_H_
816