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