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