blob: af2c701b82b18c9ce3114c646373e38c2993be47 [file] [log] [blame]
Erik Språnge57a4932021-08-17 19:58:52 +02001/*
2 * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef MODULES_VIDEO_CODING_UTILITY_VP9_CONSTANTS_H_
12#define MODULES_VIDEO_CODING_UTILITY_VP9_CONSTANTS_H_
13
14#include <stddef.h>
15#include <stdint.h>
16
17#include <string>
18
19namespace webrtc {
20
21// Number of frames that can be stored for future reference.
22constexpr size_t kVp9NumRefFrames = 8;
23// Number of frame contexts that can be store for future reference.
24constexpr size_t kVp9NumFrameContexts = 4;
25// Each inter frame can use up to 3 frames for reference.
26constexpr size_t kVp9RefsPerFrame = 3;
27// Number of values that can be decoded for mv_fr.
28constexpr size_t kVp9MvFrSize = 4;
29// Number of positions to search in motion vector prediction.
30constexpr size_t kVp9MvrefNeighbours = 8;
31// Number of contexts when decoding intra_mode .
32constexpr size_t kVp9BlockSizeGroups = 4;
33// Number of different block sizes used.
34constexpr size_t kVp9BlockSizes = 13;
35// Sentinel value to mark partition choices that are illegal.
36constexpr size_t kVp9BlockInvalid = 14;
37// Number of contexts when decoding partition.
38constexpr size_t kVp9PartitionContexts = 16;
39// Smallest size of a mode info block.
40constexpr size_t kVp9MiSize = 8;
41// Minimum width of a tile in units of superblocks (although tiles on
42// the right hand edge can be narrower).
43constexpr size_t kVp9MinTileWidth_B64 = 4;
44// Maximum width of a tile in units of superblocks.
45constexpr size_t kVp9MaxTileWidth_B64 = 64;
46// Number of motion vectors returned by find_mv_refs process.
47constexpr size_t kVp9MaxMvRefCandidates = 2;
48// Number of values that can be derived for ref_frame.
49constexpr size_t kVp9MaxRefFrames = 4;
50// Number of contexts for is_inter.
51constexpr size_t kVp9IsInterContexts = 4;
52// Number of contexts for comp_mode.
53constexpr size_t kVp9CompModeContexts = 5;
54// Number of contexts for single_ref and comp_ref.
55constexpr size_t kVp9RefContexts = 5;
56// Number of segments allowed in segmentation map.
57constexpr size_t kVp9MaxSegments = 8;
58// Index for quantizer segment feature.
59constexpr size_t kVp9SegLvlAlt_Q = 0;
60// Index for loop filter segment feature.
61constexpr size_t kVp9SegLvlAlt_L = 1;
62// Index for reference frame segment feature.
63constexpr size_t kVp9SegLvlRefFrame = 2;
64// Index for skip segment feature.
65constexpr size_t kVp9SegLvlSkip = 3;
66// Number of segment features.
67constexpr size_t kVp9SegLvlMax = 4;
68// Number of different plane types (Y or UV).
69constexpr size_t kVp9BlockTypes = 2;
70// Number of different prediction types (intra or inter).
71constexpr size_t kVp9RefTypes = 2;
72// Number of coefficient bands.
73constexpr size_t kVp9CoefBands = 6;
74// Number of contexts for decoding coefficients.
75constexpr size_t kVp9PrevCoefContexts = 6;
76// Number of coefficient probabilities that are directly transmitted.
77constexpr size_t kVp9UnconstrainedNodes = 3;
78// Number of contexts for transform size.
79constexpr size_t kVp9TxSizeContexts = 2;
80// Number of values for interp_filter.
81constexpr size_t kVp9SwitchableFilters = 3;
82// Number of contexts for interp_filter.
83constexpr size_t kVp9InterpFilterContexts = 4;
84// Number of contexts for decoding skip.
85constexpr size_t kVp9SkipContexts = 3;
86// Number of values for partition.
87constexpr size_t kVp9PartitionTypes = 4;
88// Number of values for tx_size.
89constexpr size_t kVp9TxSizes = 4;
90// Number of values for tx_mode.
91constexpr size_t kVp9TxModes = 5;
92// Inverse transform rows with DCT and columns with DCT.
93constexpr size_t kVp9DctDct = 0;
94// Inverse transform rows with DCT and columns with ADST.
95constexpr size_t kVp9AdstDct = 1;
96// Inverse transform rows with ADST and columns with DCT.
97constexpr size_t kVp9DctAdst = 2;
98// Inverse transform rows with ADST and columns with ADST.
99constexpr size_t kVp9AdstAdst = 3;
100// Number of values for y_mode.
101constexpr size_t kVp9MbModeCount = 14;
102// Number of values for intra_mode.
103constexpr size_t kVp9IntraModes = 10;
104// Number of values for inter_mode.
105constexpr size_t kVp9InterModes = 4;
106// Number of contexts for inter_mode.
107constexpr size_t kVp9InterModeContexts = 7;
108// Number of values for mv_joint.
109constexpr size_t kVp9MvJoints = 4;
110// Number of values for mv_class.
111constexpr size_t kVp9MvClasses = 11;
112// Number of values for mv_class0_bit.
113constexpr size_t kVp9Class0Size = 2;
114// Maximum number of bits for decoding motion vectors.
115constexpr size_t kVp9MvOffsetBits = 10;
116// Number of values allowed for a probability adjustment.
117constexpr size_t kVp9MaxProb = 255;
118// Number of different mode types for loop filtering.
119constexpr size_t kVp9MaxModeLfDeltas = 2;
120// Threshold at which motion vectors are considered large.
121constexpr size_t kVp9CompandedMvrefThresh = 8;
122// Maximum value used for loop filtering.
123constexpr size_t kVp9MaxLoopFilter = 63;
124// Number of bits of precision when scaling reference frames.
125constexpr size_t kVp9RefScaleShift = 14;
126// Number of bits of precision when performing inter prediction.
127constexpr size_t kVp9SubpelBits = 4;
128// 1 << kVp9SubpelBits.
129constexpr size_t kVp9SubpelShifts = 16;
130// kVp9SubpelShifts - 1.
131constexpr size_t kVp9SubpelMask = 15;
132// Value used when clipping motion vectors.
133constexpr size_t kVp9MvBorder = 128;
134// Value used when clipping motion vectors.
135constexpr size_t kVp9InterpExtend = 4;
136// Value used when clipping motion vectors.
137constexpr size_t kVp9Borderinpixels = 160;
138// Value used in adapting probabilities.
139constexpr size_t kVp9MaxUpdateFactor = 128;
140// Value used in adapting probabilities.
141constexpr size_t kVp9CountSat = 20;
142// Both candidates use ZEROMV.
143constexpr size_t kVp9BothZero = 0;
144// One candidate uses ZEROMV, one uses NEARMV or NEARESTMV.
145constexpr size_t kVp9ZeroPlusPredicted = 1;
146// Both candidates use NEARMV or NEARESTMV.
147constexpr size_t kVp9BothPredicted = 2;
148// One candidate uses NEWMV, one uses ZEROMV.
149constexpr size_t kVp9NewPlusNonIntra = 3;
150// Both candidates use NEWMV.
151constexpr size_t kVp9BothNew = 4;
152// One candidate uses intra prediction, one uses inter prediction.
153constexpr size_t kVp9IntraPlusNonIntra = 5;
154// Both candidates use intra prediction.
155constexpr size_t kVp9BothIntra = 6;
156// Sentinel value marking a case that can never occur.
157constexpr size_t kVp9InvalidCase = 9;
158
159enum class Vp9TxMode : uint8_t {
160 kOnly4X4 = 0,
161 kAllow8X8 = 1,
162 kAllow16x16 = 2,
163 kAllow32x32 = 3,
164 kTxModeSelect = 4
165};
166
167enum Vp9BlockSize : uint8_t {
168 kBlock4X4 = 0,
169 kBlock4X8 = 1,
170 kBlock8X4 = 2,
171 kBlock8X8 = 3,
172 kBlock8X16 = 4,
173 kBlock16X8 = 5,
174 kBlock16X16 = 6,
175 kBlock16X32 = 7,
176 kBlock32X16 = 8,
177 kBlock32X32 = 9,
178 kBlock32X64 = 10,
179 kBlock64X32 = 11,
180 kBlock64X64 = 12
181};
182
183enum Vp9Partition : uint8_t {
184 kPartitionNone = 0,
185 kPartitionHorizontal = 1,
186 kPartitionVertical = 2,
187 kPartitionSplit = 3
188};
189
190enum class Vp9ReferenceMode : uint8_t {
191 kSingleReference = 0,
192 kCompoundReference = 1,
193 kReferenceModeSelect = 2,
194};
195
196} // namespace webrtc
197
198#endif // MODULES_VIDEO_CODING_UTILITY_VP9_CONSTANTS_H_