chromium/third_party/libgav1/src/src/utils/constants.h

/*
 * Copyright 2019 The libgav1 Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef LIBGAV1_SRC_UTILS_CONSTANTS_H_
#define LIBGAV1_SRC_UTILS_CONSTANTS_H_

#include <cstdint>
#include <cstdlib>

#include "src/utils/bit_mask_set.h"

namespace libgav1 {

// Returns the number of elements between begin (inclusive) and end (inclusive).
constexpr int EnumRangeLength(int begin, int end) {}

enum {};  // anonymous enum

enum {};  // anonymous enum

enum FrameType : uint8_t {};

enum Plane : uint8_t {};
enum : uint8_t {};

// The plane types, called luma and chroma in the spec.
enum PlaneType : uint8_t {};

enum ReferenceFrameType : int8_t {};

enum {};  // anonymous enum

enum BlockSize : uint8_t {};

//  Partition types.  R: Recursive
//
//  None          Horizontal    Vertical      Split
//  +-------+     +-------+     +---+---+     +---+---+
//  |       |     |       |     |   |   |     | R | R |
//  |       |     +-------+     |   |   |     +---+---+
//  |       |     |       |     |   |   |     | R | R |
//  +-------+     +-------+     +---+---+     +---+---+
//
//  Horizontal    Horizontal    Vertical      Vertical
//  with top      with bottom   with left     with right
//  split         split         split         split
//  +---+---+     +-------+     +---+---+     +---+---+
//  |   |   |     |       |     |   |   |     |   |   |
//  +---+---+     +---+---+     +---+   |     |   +---+
//  |       |     |   |   |     |   |   |     |   |   |
//  +-------+     +---+---+     +---+---+     +---+---+
//
//  Horizontal4   Vertical4
//  +-----+       +-+-+-+
//  +-----+       | | | |
//  +-----+       | | | |
//  +-----+       +-+-+-+
enum Partition : uint8_t {};
enum : uint8_t {};

enum PredictionMode : uint8_t {};

enum InterIntraMode : uint8_t {};

enum MotionMode : uint8_t {};

enum TxMode : uint8_t {};

// These enums are named as kType1Type2 where Type1 is the transform type for
// the rows and Type2 is the transform type for the columns.
enum TransformType : uint8_t {};

constexpr BitMaskSet kTransformFlipColumnsMask(kTransformTypeFlipadstDct,
                                               kTransformTypeFlipadstAdst,
                                               kTransformTypeFlipadstIdentity,
                                               kTransformTypeFlipadstFlipadst);
constexpr BitMaskSet kTransformFlipRowsMask(kTransformTypeDctFlipadst,
                                            kTransformTypeAdstFlipadst,
                                            kTransformTypeIdentityFlipadst,
                                            kTransformTypeFlipadstFlipadst);

enum TransformSize : uint8_t {};

enum TransformSet : uint8_t {};

enum TransformClass : uint8_t {};

enum FilterIntraPredictor : uint8_t {};

enum ObmcDirection : uint8_t {};

// In AV1 the name of the filter refers to the direction of filter application.
// Horizontal refers to the column edge and vertical the row edge.
enum LoopFilterType : uint8_t {};

enum LoopFilterTransformSizeId : uint8_t {};

enum LoopRestorationType : uint8_t {};

enum CompoundReferenceType : uint8_t {};

enum CompoundPredictionType : uint8_t {};

enum InterpolationFilter : uint8_t {};

enum MvJointType : uint8_t {};

enum ObuType : int8_t {};

constexpr BitMaskSet kPredictionModeSmoothMask(kPredictionModeSmooth,
                                               kPredictionModeSmoothHorizontal,
                                               kPredictionModeSmoothVertical);

//------------------------------------------------------------------------------
// ToString()
//
// These functions are meant to be used only in debug logging and within tests.
// They are defined inline to avoid including the strings in the release
// library when logging is disabled; unreferenced functions will not be added to
// any object file in that case.

inline const char* ToString(const BlockSize size) {}

inline const char* ToString(const InterIntraMode mode) {}

inline const char* ToString(const ObmcDirection direction) {}

inline const char* ToString(const LoopRestorationType type) {}

inline const char* ToString(const TransformSize size) {}

inline const char* ToString(const TransformType type) {}

//------------------------------------------------------------------------------

extern const uint8_t k4x4WidthLog2[kMaxBlockSizes];

extern const uint8_t k4x4HeightLog2[kMaxBlockSizes];

extern const uint8_t kNum4x4BlocksWide[kMaxBlockSizes];

extern const uint8_t kNum4x4BlocksHigh[kMaxBlockSizes];

extern const uint8_t kBlockWidthPixels[kMaxBlockSizes];

extern const uint8_t kBlockHeightPixels[kMaxBlockSizes];

extern const BlockSize kSubSize[kMaxPartitionTypes][kMaxBlockSizes];

extern const BlockSize kPlaneResidualSize[kMaxBlockSizes][2][2];

extern const int16_t kProjectionMvDivisionLookup[kMaxFrameDistance + 1];

extern const uint8_t kTransformWidth[kNumTransformSizes];

extern const uint8_t kTransformHeight[kNumTransformSizes];

extern const uint8_t kTransformWidth4x4[kNumTransformSizes];

extern const uint8_t kTransformHeight4x4[kNumTransformSizes];

extern const uint8_t kTransformWidthLog2[kNumTransformSizes];

extern const uint8_t kTransformHeightLog2[kNumTransformSizes];

extern const TransformSize kSplitTransformSize[kNumTransformSizes];

// Square transform of size min(w,h).
extern const TransformSize kTransformSizeSquareMin[kNumTransformSizes];

// Square transform of size max(w,h).
extern const TransformSize kTransformSizeSquareMax[kNumTransformSizes];

extern const uint8_t kNumTransformTypesInSet[kNumTransformSets];

extern const uint8_t kSgrProjParams[1 << kSgrProjParamsBits][4];

extern const int8_t kSgrProjMultiplierMin[2];

extern const int8_t kSgrProjMultiplierMax[2];

extern const int8_t kWienerTapsMin[3];

extern const int8_t kWienerTapsMax[3];

extern const uint8_t kUpscaleFilterUnsigned[kSuperResFilterShifts]
                                           [kSuperResFilterTaps];

// An int8_t version of the kWarpedFilters array.
// Note: The array could be removed with a performance penalty.
extern const int8_t kWarpedFilters8[3 * kWarpedPixelPrecisionShifts + 1][8];

extern const int16_t kWarpedFilters[3 * kWarpedPixelPrecisionShifts + 1][8];

extern const int8_t kHalfSubPixelFilters[6][16][8];

extern const uint8_t kAbsHalfSubPixelFilters[6][16][8];

extern const int16_t kDirectionalIntraPredictorDerivative[44];

extern const uint8_t kDeblockFilterLevelIndex[kMaxPlanes][kNumLoopFilterTypes];

extern const uint16_t kBlockWeight[kMaxBlockSizes];

}  // namespace libgav1

#endif  // LIBGAV1_SRC_UTILS_CONSTANTS_H_