/src/vvenc/source/Lib/CommonLib/Contexts.cpp
Line | Count | Source |
1 | | /* ----------------------------------------------------------------------------- |
2 | | The copyright in this software is being made available under the Clear BSD |
3 | | License, included below. No patent rights, trademark rights and/or |
4 | | other Intellectual Property Rights other than the copyrights concerning |
5 | | the Software are granted under this license. |
6 | | |
7 | | The Clear BSD License |
8 | | |
9 | | Copyright (c) 2019-2026, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVenC Authors. |
10 | | All rights reserved. |
11 | | |
12 | | Redistribution and use in source and binary forms, with or without modification, |
13 | | are permitted (subject to the limitations in the disclaimer below) provided that |
14 | | the following conditions are met: |
15 | | |
16 | | * Redistributions of source code must retain the above copyright notice, |
17 | | this list of conditions and the following disclaimer. |
18 | | |
19 | | * Redistributions in binary form must reproduce the above copyright |
20 | | notice, this list of conditions and the following disclaimer in the |
21 | | documentation and/or other materials provided with the distribution. |
22 | | |
23 | | * Neither the name of the copyright holder nor the names of its |
24 | | contributors may be used to endorse or promote products derived from this |
25 | | software without specific prior written permission. |
26 | | |
27 | | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY |
28 | | THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
29 | | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
30 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
31 | | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
32 | | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
33 | | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
34 | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
35 | | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
36 | | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
37 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
38 | | POSSIBILITY OF SUCH DAMAGE. |
39 | | |
40 | | |
41 | | ------------------------------------------------------------------------------------------- */ |
42 | | |
43 | | |
44 | | /** \file Contexts.cpp |
45 | | * \brief Classes providing probability descriptions and contexts (also contains context initialization values) |
46 | | */ |
47 | | |
48 | | #include "Contexts.h" |
49 | | |
50 | | #include <algorithm> |
51 | | #include <cstring> |
52 | | |
53 | | //! \ingroup CommonLib |
54 | | //! \{ |
55 | | |
56 | | namespace vvenc { |
57 | | |
58 | | const uint8_t ProbModelTables::m_RenormTable_32[32] = |
59 | | { |
60 | | 6, 5, 4, 4, |
61 | | 3, 3, 3, 3, |
62 | | 2, 2, 2, 2, |
63 | | 2, 2, 2, 2, |
64 | | 1, 1, 1, 1, |
65 | | 1, 1, 1, 1, |
66 | | 1, 1, 1, 1, |
67 | | 1, 1, 1, 1 |
68 | | }; |
69 | | |
70 | | const BinFracBits ProbModelTables::m_binFracBits[256] = { |
71 | | { { 0x0005c, 0x48000 } }, { { 0x00116, 0x3b520 } }, { { 0x001d0, 0x356cb } }, { { 0x0028b, 0x318a9 } }, |
72 | | { { 0x00346, 0x2ea40 } }, { { 0x00403, 0x2c531 } }, { { 0x004c0, 0x2a658 } }, { { 0x0057e, 0x28beb } }, |
73 | | { { 0x0063c, 0x274ce } }, { { 0x006fc, 0x26044 } }, { { 0x007bc, 0x24dc9 } }, { { 0x0087d, 0x23cfc } }, |
74 | | { { 0x0093f, 0x22d96 } }, { { 0x00a01, 0x21f60 } }, { { 0x00ac4, 0x2122e } }, { { 0x00b89, 0x205dd } }, |
75 | | { { 0x00c4e, 0x1fa51 } }, { { 0x00d13, 0x1ef74 } }, { { 0x00dda, 0x1e531 } }, { { 0x00ea2, 0x1db78 } }, |
76 | | { { 0x00f6a, 0x1d23c } }, { { 0x01033, 0x1c970 } }, { { 0x010fd, 0x1c10b } }, { { 0x011c8, 0x1b903 } }, |
77 | | { { 0x01294, 0x1b151 } }, { { 0x01360, 0x1a9ee } }, { { 0x0142e, 0x1a2d4 } }, { { 0x014fc, 0x19bfc } }, |
78 | | { { 0x015cc, 0x19564 } }, { { 0x0169c, 0x18f06 } }, { { 0x0176d, 0x188de } }, { { 0x0183f, 0x182e8 } }, |
79 | | { { 0x01912, 0x17d23 } }, { { 0x019e6, 0x1778a } }, { { 0x01abb, 0x1721c } }, { { 0x01b91, 0x16cd5 } }, |
80 | | { { 0x01c68, 0x167b4 } }, { { 0x01d40, 0x162b6 } }, { { 0x01e19, 0x15dda } }, { { 0x01ef3, 0x1591e } }, |
81 | | { { 0x01fcd, 0x15480 } }, { { 0x020a9, 0x14fff } }, { { 0x02186, 0x14b99 } }, { { 0x02264, 0x1474e } }, |
82 | | { { 0x02343, 0x1431b } }, { { 0x02423, 0x13f01 } }, { { 0x02504, 0x13afd } }, { { 0x025e6, 0x1370f } }, |
83 | | { { 0x026ca, 0x13336 } }, { { 0x027ae, 0x12f71 } }, { { 0x02894, 0x12bc0 } }, { { 0x0297a, 0x12821 } }, |
84 | | { { 0x02a62, 0x12494 } }, { { 0x02b4b, 0x12118 } }, { { 0x02c35, 0x11dac } }, { { 0x02d20, 0x11a51 } }, |
85 | | { { 0x02e0c, 0x11704 } }, { { 0x02efa, 0x113c7 } }, { { 0x02fe9, 0x11098 } }, { { 0x030d9, 0x10d77 } }, |
86 | | { { 0x031ca, 0x10a63 } }, { { 0x032bc, 0x1075c } }, { { 0x033b0, 0x10461 } }, { { 0x034a5, 0x10173 } }, |
87 | | { { 0x0359b, 0x0fe90 } }, { { 0x03693, 0x0fbb9 } }, { { 0x0378c, 0x0f8ed } }, { { 0x03886, 0x0f62b } }, |
88 | | { { 0x03981, 0x0f374 } }, { { 0x03a7e, 0x0f0c7 } }, { { 0x03b7c, 0x0ee23 } }, { { 0x03c7c, 0x0eb89 } }, |
89 | | { { 0x03d7d, 0x0e8f9 } }, { { 0x03e7f, 0x0e671 } }, { { 0x03f83, 0x0e3f2 } }, { { 0x04088, 0x0e17c } }, |
90 | | { { 0x0418e, 0x0df0e } }, { { 0x04297, 0x0dca8 } }, { { 0x043a0, 0x0da4a } }, { { 0x044ab, 0x0d7f3 } }, |
91 | | { { 0x045b8, 0x0d5a5 } }, { { 0x046c6, 0x0d35d } }, { { 0x047d6, 0x0d11c } }, { { 0x048e7, 0x0cee3 } }, |
92 | | { { 0x049fa, 0x0ccb0 } }, { { 0x04b0e, 0x0ca84 } }, { { 0x04c24, 0x0c85e } }, { { 0x04d3c, 0x0c63f } }, |
93 | | { { 0x04e55, 0x0c426 } }, { { 0x04f71, 0x0c212 } }, { { 0x0508d, 0x0c005 } }, { { 0x051ac, 0x0bdfe } }, |
94 | | { { 0x052cc, 0x0bbfc } }, { { 0x053ee, 0x0b9ff } }, { { 0x05512, 0x0b808 } }, { { 0x05638, 0x0b617 } }, |
95 | | { { 0x0575f, 0x0b42a } }, { { 0x05888, 0x0b243 } }, { { 0x059b4, 0x0b061 } }, { { 0x05ae1, 0x0ae83 } }, |
96 | | { { 0x05c10, 0x0acaa } }, { { 0x05d41, 0x0aad6 } }, { { 0x05e74, 0x0a907 } }, { { 0x05fa9, 0x0a73c } }, |
97 | | { { 0x060e0, 0x0a575 } }, { { 0x06219, 0x0a3b3 } }, { { 0x06354, 0x0a1f5 } }, { { 0x06491, 0x0a03b } }, |
98 | | { { 0x065d1, 0x09e85 } }, { { 0x06712, 0x09cd4 } }, { { 0x06856, 0x09b26 } }, { { 0x0699c, 0x0997c } }, |
99 | | { { 0x06ae4, 0x097d6 } }, { { 0x06c2f, 0x09634 } }, { { 0x06d7c, 0x09495 } }, { { 0x06ecb, 0x092fa } }, |
100 | | { { 0x0701d, 0x09162 } }, { { 0x07171, 0x08fce } }, { { 0x072c7, 0x08e3e } }, { { 0x07421, 0x08cb0 } }, |
101 | | { { 0x0757c, 0x08b26 } }, { { 0x076da, 0x089a0 } }, { { 0x0783b, 0x0881c } }, { { 0x0799f, 0x0869c } }, |
102 | | { { 0x07b05, 0x0851f } }, { { 0x07c6e, 0x083a4 } }, { { 0x07dd9, 0x0822d } }, { { 0x07f48, 0x080b9 } }, |
103 | | { { 0x080b9, 0x07f48 } }, { { 0x0822d, 0x07dd9 } }, { { 0x083a4, 0x07c6e } }, { { 0x0851f, 0x07b05 } }, |
104 | | { { 0x0869c, 0x0799f } }, { { 0x0881c, 0x0783b } }, { { 0x089a0, 0x076da } }, { { 0x08b26, 0x0757c } }, |
105 | | { { 0x08cb0, 0x07421 } }, { { 0x08e3e, 0x072c7 } }, { { 0x08fce, 0x07171 } }, { { 0x09162, 0x0701d } }, |
106 | | { { 0x092fa, 0x06ecb } }, { { 0x09495, 0x06d7c } }, { { 0x09634, 0x06c2f } }, { { 0x097d6, 0x06ae4 } }, |
107 | | { { 0x0997c, 0x0699c } }, { { 0x09b26, 0x06856 } }, { { 0x09cd4, 0x06712 } }, { { 0x09e85, 0x065d1 } }, |
108 | | { { 0x0a03b, 0x06491 } }, { { 0x0a1f5, 0x06354 } }, { { 0x0a3b3, 0x06219 } }, { { 0x0a575, 0x060e0 } }, |
109 | | { { 0x0a73c, 0x05fa9 } }, { { 0x0a907, 0x05e74 } }, { { 0x0aad6, 0x05d41 } }, { { 0x0acaa, 0x05c10 } }, |
110 | | { { 0x0ae83, 0x05ae1 } }, { { 0x0b061, 0x059b4 } }, { { 0x0b243, 0x05888 } }, { { 0x0b42a, 0x0575f } }, |
111 | | { { 0x0b617, 0x05638 } }, { { 0x0b808, 0x05512 } }, { { 0x0b9ff, 0x053ee } }, { { 0x0bbfc, 0x052cc } }, |
112 | | { { 0x0bdfe, 0x051ac } }, { { 0x0c005, 0x0508d } }, { { 0x0c212, 0x04f71 } }, { { 0x0c426, 0x04e55 } }, |
113 | | { { 0x0c63f, 0x04d3c } }, { { 0x0c85e, 0x04c24 } }, { { 0x0ca84, 0x04b0e } }, { { 0x0ccb0, 0x049fa } }, |
114 | | { { 0x0cee3, 0x048e7 } }, { { 0x0d11c, 0x047d6 } }, { { 0x0d35d, 0x046c6 } }, { { 0x0d5a5, 0x045b8 } }, |
115 | | { { 0x0d7f3, 0x044ab } }, { { 0x0da4a, 0x043a0 } }, { { 0x0dca8, 0x04297 } }, { { 0x0df0e, 0x0418e } }, |
116 | | { { 0x0e17c, 0x04088 } }, { { 0x0e3f2, 0x03f83 } }, { { 0x0e671, 0x03e7f } }, { { 0x0e8f9, 0x03d7d } }, |
117 | | { { 0x0eb89, 0x03c7c } }, { { 0x0ee23, 0x03b7c } }, { { 0x0f0c7, 0x03a7e } }, { { 0x0f374, 0x03981 } }, |
118 | | { { 0x0f62b, 0x03886 } }, { { 0x0f8ed, 0x0378c } }, { { 0x0fbb9, 0x03693 } }, { { 0x0fe90, 0x0359b } }, |
119 | | { { 0x10173, 0x034a5 } }, { { 0x10461, 0x033b0 } }, { { 0x1075c, 0x032bc } }, { { 0x10a63, 0x031ca } }, |
120 | | { { 0x10d77, 0x030d9 } }, { { 0x11098, 0x02fe9 } }, { { 0x113c7, 0x02efa } }, { { 0x11704, 0x02e0c } }, |
121 | | { { 0x11a51, 0x02d20 } }, { { 0x11dac, 0x02c35 } }, { { 0x12118, 0x02b4b } }, { { 0x12494, 0x02a62 } }, |
122 | | { { 0x12821, 0x0297a } }, { { 0x12bc0, 0x02894 } }, { { 0x12f71, 0x027ae } }, { { 0x13336, 0x026ca } }, |
123 | | { { 0x1370f, 0x025e6 } }, { { 0x13afd, 0x02504 } }, { { 0x13f01, 0x02423 } }, { { 0x1431b, 0x02343 } }, |
124 | | { { 0x1474e, 0x02264 } }, { { 0x14b99, 0x02186 } }, { { 0x14fff, 0x020a9 } }, { { 0x15480, 0x01fcd } }, |
125 | | { { 0x1591e, 0x01ef3 } }, { { 0x15dda, 0x01e19 } }, { { 0x162b6, 0x01d40 } }, { { 0x167b4, 0x01c68 } }, |
126 | | { { 0x16cd5, 0x01b91 } }, { { 0x1721c, 0x01abb } }, { { 0x1778a, 0x019e6 } }, { { 0x17d23, 0x01912 } }, |
127 | | { { 0x182e8, 0x0183f } }, { { 0x188de, 0x0176d } }, { { 0x18f06, 0x0169c } }, { { 0x19564, 0x015cc } }, |
128 | | { { 0x19bfc, 0x014fc } }, { { 0x1a2d4, 0x0142e } }, { { 0x1a9ee, 0x01360 } }, { { 0x1b151, 0x01294 } }, |
129 | | { { 0x1b903, 0x011c8 } }, { { 0x1c10b, 0x010fd } }, { { 0x1c970, 0x01033 } }, { { 0x1d23c, 0x00f6a } }, |
130 | | { { 0x1db78, 0x00ea2 } }, { { 0x1e531, 0x00dda } }, { { 0x1ef74, 0x00d13 } }, { { 0x1fa51, 0x00c4e } }, |
131 | | { { 0x205dd, 0x00b89 } }, { { 0x2122e, 0x00ac4 } }, { { 0x21f60, 0x00a01 } }, { { 0x22d96, 0x0093f } }, |
132 | | { { 0x23cfc, 0x0087d } }, { { 0x24dc9, 0x007bc } }, { { 0x26044, 0x006fc } }, { { 0x274ce, 0x0063c } }, |
133 | | { { 0x28beb, 0x0057e } }, { { 0x2a658, 0x004c0 } }, { { 0x2c531, 0x00403 } }, { { 0x2ea40, 0x00346 } }, |
134 | | { { 0x318a9, 0x0028b } }, { { 0x356cb, 0x001d0 } }, { { 0x3b520, 0x00116 } }, { { 0x48000, 0x0005c } }, |
135 | | }; |
136 | | void BinProbModel::init( int qp, int initId ) |
137 | 0 | { |
138 | 0 | int slope = (initId >> 3) - 4; |
139 | 0 | int offset = ((initId & 7) * 18) + 1; |
140 | 0 | int inistate = ((slope * (qp - 16)) >> 1) + offset; |
141 | 0 | int state_clip = inistate < 1 ? 1 : inistate > 127 ? 127 : inistate; |
142 | 0 | const int p1 = (state_clip << 8); |
143 | 0 | m_state[0] = p1 & MASK_0; |
144 | 0 | m_state[1] = p1 & MASK_1; |
145 | 0 | } |
146 | | |
147 | | |
148 | | |
149 | | |
150 | | CtxSet::CtxSet( std::initializer_list<CtxSet> ctxSets ) |
151 | 512 | { |
152 | 512 | uint16_t minOffset = std::numeric_limits<uint16_t>::max(); |
153 | 512 | uint16_t maxOffset = 0; |
154 | 1.79k | for( auto iter = ctxSets.begin(); iter != ctxSets.end(); iter++ ) |
155 | 1.28k | { |
156 | 1.28k | minOffset = std::min<uint16_t>( minOffset, (*iter).Offset ); |
157 | 1.28k | maxOffset = std::max<uint16_t>( maxOffset, (*iter).Offset+(*iter).Size ); |
158 | 1.28k | } |
159 | 512 | Offset = minOffset; |
160 | 512 | Size = maxOffset - minOffset; |
161 | 512 | } |
162 | | |
163 | | |
164 | | |
165 | | |
166 | | |
167 | | const std::vector<uint8_t>& ContextSetCfg::getInitTable( unsigned initId ) |
168 | 0 | { |
169 | 0 | CHECK( initId >= (unsigned)sm_InitTables.size(), |
170 | 0 | "Invalid initId (" << initId << "), only " << sm_InitTables.size() << " tables defined." ); |
171 | 0 | return sm_InitTables[initId]; |
172 | 0 | } |
173 | | |
174 | | |
175 | | CtxSet ContextSetCfg::addCtxSet( std::initializer_list<std::initializer_list<uint8_t>> initSet2d ) |
176 | 20.9k | { |
177 | 20.9k | const std::size_t startIdx = sm_InitTables[0].size(); |
178 | 20.9k | const std::size_t numValues = ( *initSet2d.begin() ).size(); |
179 | 20.9k | std::size_t setId = 0; |
180 | 104k | for( auto setIter = initSet2d.begin(); setIter != initSet2d.end() && setId < sm_InitTables.size(); setIter++, setId++ ) |
181 | 83.9k | { |
182 | 83.9k | const std::initializer_list<uint8_t>& initSet = *setIter; |
183 | 83.9k | std::vector<uint8_t>& initTable = sm_InitTables[setId]; |
184 | 83.9k | CHECK( initSet.size() != numValues, |
185 | 83.9k | "Number of init values do not match for all sets (" << initSet.size() << " != " << numValues << ")." ); |
186 | 83.9k | initTable.resize( startIdx + numValues ); |
187 | 83.9k | std::size_t elemId = startIdx; |
188 | 461k | for( auto elemIter = ( *setIter ).begin(); elemIter != ( *setIter ).end(); elemIter++, elemId++ ) |
189 | 377k | { |
190 | 377k | initTable[elemId] = *elemIter; |
191 | 377k | } |
192 | 83.9k | } |
193 | 20.9k | return CtxSet( (uint16_t)startIdx, (uint16_t)numValues ); |
194 | 20.9k | } |
195 | | |
196 | | |
197 | | #define CNU 35 |
198 | | std::vector<std::vector<uint8_t>> ContextSetCfg::sm_InitTables(VVENC_NUMBER_OF_SLICE_TYPES + 1); |
199 | | |
200 | | // clang-format off |
201 | | const CtxSet ContextSetCfg::SplitFlag = ContextSetCfg::addCtxSet |
202 | | ({ |
203 | | { 18, 27, 15, 18, 28, 45, 26, 7, 23, }, |
204 | | { 11, 35, 53, 12, 6, 30, 13, 15, 31, }, |
205 | | { 19, 28, 38, 27, 29, 38, 20, 30, 31, }, |
206 | | { 12, 13, 8, 8, 13, 12, 5, 9, 9, }, |
207 | | }); |
208 | | |
209 | | const CtxSet ContextSetCfg::SplitQtFlag = ContextSetCfg::addCtxSet |
210 | | ({ |
211 | | { 26, 36, 38, 18, 34, 21, }, |
212 | | { 20, 14, 23, 18, 19, 6, }, |
213 | | { 27, 6, 15, 25, 19, 37, }, |
214 | | { 0, 8, 8, 12, 12, 8, }, |
215 | | }); |
216 | | |
217 | | const CtxSet ContextSetCfg::SplitHvFlag = ContextSetCfg::addCtxSet |
218 | | ({ |
219 | | { 43, 42, 37, 42, 44, }, |
220 | | { 43, 35, 37, 34, 52, }, |
221 | | { 43, 42, 29, 27, 44, }, |
222 | | { 9, 8, 9, 8, 5, }, |
223 | | }); |
224 | | |
225 | | const CtxSet ContextSetCfg::Split12Flag = ContextSetCfg::addCtxSet |
226 | | ({ |
227 | | { 28, 29, 28, 29, }, |
228 | | { 43, 37, 21, 22, }, |
229 | | { 36, 45, 36, 45, }, |
230 | | { 12, 13, 12, 13, }, |
231 | | }); |
232 | | |
233 | | const CtxSet ContextSetCfg::ModeConsFlag = ContextSetCfg::addCtxSet |
234 | | ({ |
235 | | { 25, 20, }, |
236 | | { 25, 12, }, |
237 | | { CNU, CNU, }, |
238 | | { 1, 0, }, |
239 | | }); |
240 | | |
241 | | const CtxSet ContextSetCfg::SkipFlag = ContextSetCfg::addCtxSet |
242 | | ({ |
243 | | { 57, 60, 46, }, |
244 | | { 57, 59, 45, }, |
245 | | { 0, 26, 28, }, |
246 | | { 5, 4, 8, }, |
247 | | }); |
248 | | |
249 | | const CtxSet ContextSetCfg::MergeFlag = ContextSetCfg::addCtxSet |
250 | | ({ |
251 | | { 6, }, |
252 | | { 21, }, |
253 | | { 26, }, |
254 | | { 4, }, |
255 | | }); |
256 | | |
257 | | const CtxSet ContextSetCfg::RegularMergeFlag = ContextSetCfg::addCtxSet |
258 | | ({ |
259 | | { 46, 15, }, |
260 | | { 38, 7, }, |
261 | | { CNU, CNU, }, |
262 | | { 5, 5, }, |
263 | | }); |
264 | | |
265 | | const CtxSet ContextSetCfg::MergeIdx = ContextSetCfg::addCtxSet |
266 | | ({ |
267 | | { 18, }, |
268 | | { 20, }, |
269 | | { 34, }, |
270 | | { 4, }, |
271 | | }); |
272 | | |
273 | | const CtxSet ContextSetCfg::MmvdFlag = ContextSetCfg::addCtxSet |
274 | | ({ |
275 | | { 25, }, |
276 | | { 26, }, |
277 | | { CNU, }, |
278 | | { 4, }, |
279 | | }); |
280 | | |
281 | | const CtxSet ContextSetCfg::MmvdMergeIdx = ContextSetCfg::addCtxSet |
282 | | ({ |
283 | | { 43, }, |
284 | | { 43, }, |
285 | | { CNU, }, |
286 | | { 10, }, |
287 | | }); |
288 | | |
289 | | const CtxSet ContextSetCfg::MmvdStepMvpIdx = ContextSetCfg::addCtxSet |
290 | | ({ |
291 | | { 59, }, |
292 | | { 60, }, |
293 | | { CNU, }, |
294 | | { 0, }, |
295 | | }); |
296 | | |
297 | | const CtxSet ContextSetCfg::SubblockMergeFlag = ContextSetCfg::addCtxSet |
298 | | ({ |
299 | | { 25, 58, 45, }, |
300 | | { 48, 57, 44, }, |
301 | | { CNU, CNU, CNU, }, |
302 | | { 4, 4, 4, }, |
303 | | }); |
304 | | |
305 | | const CtxSet ContextSetCfg::AffMergeIdx = ContextSetCfg::addCtxSet |
306 | | ({ |
307 | | { 4, }, |
308 | | { 5, }, |
309 | | { CNU, }, |
310 | | { 0, }, |
311 | | }); |
312 | | |
313 | | const CtxSet ContextSetCfg::CiipFlag = ContextSetCfg::addCtxSet |
314 | | ({ |
315 | | { 57, }, |
316 | | { 57, }, |
317 | | { CNU, }, |
318 | | { 1, }, |
319 | | }); |
320 | | |
321 | | |
322 | | |
323 | | const CtxSet ContextSetCfg::PredMode = ContextSetCfg::addCtxSet |
324 | | ({ |
325 | | { 40, 35, }, |
326 | | { 40, 35, }, |
327 | | { CNU, CNU, }, |
328 | | { 5, 1, }, |
329 | | }); |
330 | | |
331 | | const CtxSet ContextSetCfg::IntraLumaMpmFlag = ContextSetCfg::addCtxSet |
332 | | ({ |
333 | | { 44, }, |
334 | | { 36, }, |
335 | | { 45, }, |
336 | | { 6, }, |
337 | | }); |
338 | | |
339 | | const CtxSet ContextSetCfg::IntraLumaPlanarFlag = ContextSetCfg::addCtxSet |
340 | | ({ |
341 | | { 13, 6, }, |
342 | | { 12, 20, }, |
343 | | { 13, 28, }, |
344 | | { 1, 5, }, |
345 | | }); |
346 | | |
347 | | |
348 | | const CtxSet ContextSetCfg::MultiRefLineIdx = ContextSetCfg::addCtxSet |
349 | | ({ |
350 | | { 25, 59, }, |
351 | | { 25, 58, }, |
352 | | { 25, 60, }, |
353 | | { 5, 8, }, |
354 | | }); |
355 | | |
356 | | const CtxSet ContextSetCfg::MipFlag = ContextSetCfg::addCtxSet |
357 | | ({ |
358 | | { 56, 57, 50, 26, }, |
359 | | { 41, 57, 58, 26, }, |
360 | | { 33, 49, 50, 25, }, |
361 | | { 9, 10, 9, 6, }, |
362 | | }); |
363 | | |
364 | | const CtxSet ContextSetCfg::ISPMode = ContextSetCfg::addCtxSet |
365 | | ({ |
366 | | { 33, 43, }, |
367 | | { 33, 36, }, |
368 | | { 33, 43, }, |
369 | | { 9, 2, }, |
370 | | }); |
371 | | |
372 | | const CtxSet ContextSetCfg::CclmModeFlag = ContextSetCfg::addCtxSet |
373 | | ({ |
374 | | { 26, }, |
375 | | { 34, }, |
376 | | { 59, }, |
377 | | { 4, }, |
378 | | }); |
379 | | |
380 | | const CtxSet ContextSetCfg::CclmModeIdx = ContextSetCfg::addCtxSet |
381 | | ({ |
382 | | { 27, }, |
383 | | { 27, }, |
384 | | { 27, }, |
385 | | { 9, }, |
386 | | }); |
387 | | |
388 | | const CtxSet ContextSetCfg::IntraChromaPredMode = ContextSetCfg::addCtxSet |
389 | | ({ |
390 | | { 25, }, |
391 | | { 25, }, |
392 | | { 34, }, |
393 | | { 5, }, |
394 | | }); |
395 | | |
396 | | const CtxSet ContextSetCfg::DeltaQP = ContextSetCfg::addCtxSet |
397 | | ({ |
398 | | { CNU, CNU, }, |
399 | | { CNU, CNU, }, |
400 | | { CNU, CNU, }, |
401 | | { DWS, DWS, }, |
402 | | }); |
403 | | |
404 | | const CtxSet ContextSetCfg::InterDir = ContextSetCfg::addCtxSet |
405 | | ({ |
406 | | { 14, 13, 5, 4, 3, 40, }, |
407 | | { 7, 6, 5, 12, 4, 40, }, |
408 | | { CNU, CNU, CNU, CNU, CNU, CNU, }, |
409 | | { 0, 0, 1, 4, 4, 0, }, |
410 | | }); |
411 | | |
412 | | const CtxSet ContextSetCfg::RefPic = ContextSetCfg::addCtxSet |
413 | | ({ |
414 | | { 5, 35, }, |
415 | | { 20, 35, }, |
416 | | { CNU, CNU, }, |
417 | | { 0, 4, }, |
418 | | }); |
419 | | |
420 | | const CtxSet ContextSetCfg::AffineFlag = ContextSetCfg::addCtxSet |
421 | | ({ |
422 | | { 19, 13, 6, }, |
423 | | { 12, 13, 14, }, |
424 | | { CNU, CNU, CNU, }, |
425 | | { 4, 0, 0, }, |
426 | | }); |
427 | | |
428 | | const CtxSet ContextSetCfg::AffineType = ContextSetCfg::addCtxSet |
429 | | ({ |
430 | | { 35, }, |
431 | | { 35, }, |
432 | | { CNU, }, |
433 | | { 4, }, |
434 | | }); |
435 | | |
436 | | const CtxSet ContextSetCfg::BcwIdx = ContextSetCfg::addCtxSet |
437 | | ({ |
438 | | { 5, }, |
439 | | { 4, }, |
440 | | { CNU, }, |
441 | | { 1, }, |
442 | | }); |
443 | | |
444 | | const CtxSet ContextSetCfg::Mvd = ContextSetCfg::addCtxSet |
445 | | ({ |
446 | | { 51, 36, }, |
447 | | { 44, 43, }, |
448 | | { 14, 45, }, |
449 | | { 9, 5, }, |
450 | | }); |
451 | | |
452 | | const CtxSet ContextSetCfg::BDPCMMode = ContextSetCfg::addCtxSet |
453 | | ({ |
454 | | { 19, 21, 0, 28, }, |
455 | | { 40, 36, 0, 13, }, |
456 | | { 19, 35, 1, 27, }, |
457 | | { 1, 4, 1, 0, }, |
458 | | }); |
459 | | |
460 | | const CtxSet ContextSetCfg::QtRootCbf = ContextSetCfg::addCtxSet |
461 | | ({ |
462 | | { 12, }, |
463 | | { 5, }, |
464 | | { 6, }, |
465 | | { 4, }, |
466 | | }); |
467 | | |
468 | | const CtxSet ContextSetCfg::ACTFlag = ContextSetCfg::addCtxSet |
469 | | ({ |
470 | | { CNU, }, |
471 | | { CNU, }, |
472 | | { CNU, }, |
473 | | { DWS, }, |
474 | | }); |
475 | | |
476 | | const CtxSet ContextSetCfg::QtCbf[] = |
477 | | { |
478 | | ContextSetCfg::addCtxSet |
479 | | ({ |
480 | | { 15, 6, 5, 14, }, |
481 | | { 23, 5, 20, 7, }, |
482 | | { 15, 12, 5, 7, }, |
483 | | { 5, 1, 8, 9, }, |
484 | | }), |
485 | | ContextSetCfg::addCtxSet |
486 | | ({ |
487 | | { 25, 37, }, |
488 | | { 25, 28, }, |
489 | | { 12, 21, }, |
490 | | { 5, 0, }, |
491 | | }), |
492 | | ContextSetCfg::addCtxSet |
493 | | ({ |
494 | | { 9, 36, 45, }, |
495 | | { 25, 29, 45, }, |
496 | | { 33, 28, 36, }, |
497 | | { 2, 1, 0, }, |
498 | | }) |
499 | | }; |
500 | | |
501 | | const CtxSet ContextSetCfg::SigCoeffGroup[] = |
502 | | { |
503 | | ContextSetCfg::addCtxSet |
504 | | ({ |
505 | | { 25, 45, }, |
506 | | { 25, 30, }, |
507 | | { 18, 31, }, |
508 | | { 8, 5, }, |
509 | | }), |
510 | | ContextSetCfg::addCtxSet |
511 | | ({ |
512 | | { 25, 14, }, |
513 | | { 25, 45, }, |
514 | | { 25, 15, }, |
515 | | { 5, 8, }, |
516 | | }) |
517 | | }; |
518 | | |
519 | | const CtxSet ContextSetCfg::SigFlag[] = |
520 | | { |
521 | | ContextSetCfg::addCtxSet |
522 | | ({ |
523 | | { 17, 41, 49, 36, 1, 49, 50, 37, 48, 51, 58, 45, }, |
524 | | { 17, 41, 42, 29, 25, 49, 43, 37, 33, 58, 51, 30, }, |
525 | | { 25, 19, 28, 14, 25, 20, 29, 30, 19, 37, 30, 38, }, |
526 | | { 12, 9, 9, 10, 9, 9, 9, 10, 8, 8, 8, 10, }, |
527 | | }), |
528 | | ContextSetCfg::addCtxSet |
529 | | ({ |
530 | | { 9, 49, 50, 36, 48, 59, 59, 38, }, |
531 | | { 17, 34, 35, 21, 41, 59, 60, 38, }, |
532 | | { 25, 27, 28, 37, 34, 53, 53, 46, }, |
533 | | { 12, 12, 9, 13, 4, 5, 8, 9, }, |
534 | | }), |
535 | | ContextSetCfg::addCtxSet |
536 | | ({ |
537 | | { 26, 45, 53, 46, 49, 54, 61, 39, 35, 39, 39, 39, }, |
538 | | { 19, 38, 38, 46, 34, 54, 54, 39, 6, 39, 39, 39, }, |
539 | | { 11, 38, 46, 54, 27, 39, 39, 39, 44, 39, 39, 39, }, |
540 | | { 9, 13, 8, 8, 8, 8, 8, 5, 8, 0, 0, 0, }, |
541 | | }), |
542 | | ContextSetCfg::addCtxSet |
543 | | ({ |
544 | | { 34, 45, 38, 31, 58, 39, 39, 39, }, |
545 | | { 35, 45, 53, 54, 44, 39, 39, 39, }, |
546 | | { 19, 46, 38, 39, 52, 39, 39, 39, }, |
547 | | { 8, 12, 12, 8, 4, 0, 0, 0, }, |
548 | | }), |
549 | | ContextSetCfg::addCtxSet |
550 | | ({ |
551 | | { 19, 54, 39, 39, 50, 39, 39, 39, 0, 39, 39, 39, }, |
552 | | { 19, 39, 54, 39, 19, 39, 39, 39, 56, 39, 39, 39, }, |
553 | | { 18, 39, 39, 39, 27, 39, 39, 39, 0, 39, 39, 39, }, |
554 | | { 8, 8, 8, 8, 8, 0, 4, 4, 0, 0, 0, 0, }, |
555 | | }), |
556 | | ContextSetCfg::addCtxSet |
557 | | ({ |
558 | | { 34, 38, 54, 39, 41, 39, 39, 39, }, |
559 | | { 34, 38, 62, 39, 26, 39, 39, 39, }, |
560 | | { 11, 39, 39, 39, 19, 39, 39, 39, }, |
561 | | { 8, 8, 8, 8, 4, 0, 0, 0, }, |
562 | | }) |
563 | | }; |
564 | | |
565 | | const CtxSet ContextSetCfg::ParFlag[] = |
566 | | { |
567 | | ContextSetCfg::addCtxSet |
568 | | ({ |
569 | | { 33, 40, 25, 41, 26, 42, 25, 33, 26, 34, 27, 25, 41, 42, 42, 35, 33, 27, 35, 42, 43, }, |
570 | | { 18, 17, 33, 18, 26, 42, 25, 33, 26, 42, 27, 25, 34, 42, 42, 35, 26, 27, 42, 20, 20, }, |
571 | | { 33, 25, 18, 26, 34, 27, 25, 26, 19, 42, 35, 33, 19, 27, 35, 35, 34, 42, 20, 43, 20, }, |
572 | | { 8, 9, 12, 13, 13, 13, 10, 13, 13, 13, 13, 13, 13, 13, 13, 13, 10, 13, 13, 13, 13, }, |
573 | | }), |
574 | | ContextSetCfg::addCtxSet |
575 | | ({ |
576 | | { 33, 25, 26, 34, 19, 27, 33, 42, 43, 35, 43, }, |
577 | | { 25, 25, 26, 11, 19, 27, 33, 42, 35, 35, 43, }, |
578 | | { 33, 25, 26, 42, 19, 27, 26, 50, 35, 20, 43, }, |
579 | | { 8, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, }, |
580 | | }) |
581 | | }; |
582 | | |
583 | | const CtxSet ContextSetCfg::GtxFlag[] = |
584 | | { |
585 | | ContextSetCfg::addCtxSet |
586 | | ({ |
587 | | { 25, 0, 0, 17, 25, 26, 0, 9, 25, 33, 19, 0, 25, 33, 26, 20, 25, 33, 27, 35, 22, }, |
588 | | { 17, 0, 1, 17, 25, 18, 0, 9, 25, 33, 34, 9, 25, 18, 26, 20, 25, 18, 19, 27, 29, }, |
589 | | { 25, 1, 40, 25, 33, 11, 17, 25, 25, 18, 4, 17, 33, 26, 19, 13, 33, 19, 20, 28, 22, }, |
590 | | { 1, 5, 9, 9, 9, 6, 5, 9, 10, 10, 9, 9, 9, 9, 9, 9, 6, 8, 9, 9, 10, }, |
591 | | }), |
592 | | ContextSetCfg::addCtxSet |
593 | | ({ |
594 | | { 25, 1, 25, 33, 26, 12, 25, 33, 27, 28, 37, }, |
595 | | { 17, 9, 25, 10, 18, 4, 17, 33, 19, 20, 29, }, |
596 | | { 40, 9, 25, 18, 26, 35, 25, 26, 35, 28, 37, }, |
597 | | { 1, 5, 8, 8, 9, 6, 6, 9, 8, 8, 9, }, |
598 | | }), |
599 | | ContextSetCfg::addCtxSet |
600 | | ({ |
601 | | { 0, 0, 33, 34, 35, 21, 25, 34, 35, 28, 29, 40, 42, 43, 29, 30, 49, 36, 37, 45, 38, }, |
602 | | { 0, 17, 26, 19, 35, 21, 25, 34, 20, 28, 29, 33, 27, 28, 29, 22, 34, 28, 44, 37, 38, }, |
603 | | { 25, 25, 11, 27, 20, 21, 33, 12, 28, 21, 22, 34, 28, 29, 29, 30, 36, 29, 45, 30, 23, }, |
604 | | { 9, 5, 10, 13, 13, 10, 9, 10, 13, 13, 13, 9, 10, 10, 10, 13, 8, 9, 10, 10, 13, }, |
605 | | }), |
606 | | ContextSetCfg::addCtxSet |
607 | | ({ |
608 | | { 0, 40, 34, 43, 36, 37, 57, 52, 45, 38, 46, }, |
609 | | { 0, 25, 19, 20, 13, 14, 57, 44, 30, 30, 23, }, |
610 | | { 40, 33, 27, 28, 21, 37, 36, 37, 45, 38, 46, }, |
611 | | { 8, 8, 9, 12, 12, 10, 5, 9, 9, 9, 13, }, |
612 | | }) |
613 | | }; |
614 | | |
615 | | const CtxSet ContextSetCfg::LastX[] = |
616 | | { |
617 | | ContextSetCfg::addCtxSet |
618 | | ({ |
619 | | { 6, 6, 12, 14, 6, 4, 14, 7, 6, 4, 29, 7, 6, 6, 12, 28, 7, 13, 13, 35, }, |
620 | | { 6, 13, 12, 6, 6, 12, 14, 14, 13, 12, 29, 7, 6, 13, 36, 28, 14, 13, 5, 26, }, |
621 | | { 13, 5, 4, 21, 14, 4, 6, 14, 21, 11, 14, 7, 14, 5, 11, 21, 30, 22, 13, 42, }, |
622 | | { 8, 5, 4, 5, 4, 4, 5, 4, 1, 0, 4, 1, 0, 0, 0, 0, 1, 0, 0, 0, }, |
623 | | }), |
624 | | ContextSetCfg::addCtxSet |
625 | | ({ |
626 | | { 19, 5, 4, }, |
627 | | { 12, 4, 18, }, |
628 | | { 12, 4, 3, }, |
629 | | { 5, 4, 4, }, |
630 | | }) |
631 | | }; |
632 | | |
633 | | const CtxSet ContextSetCfg::LastY[] = |
634 | | { |
635 | | ContextSetCfg::addCtxSet |
636 | | ({ |
637 | | { 5, 5, 20, 13, 13, 19, 21, 6, 12, 12, 14, 14, 5, 4, 12, 13, 7, 13, 12, 41, }, |
638 | | { 5, 5, 12, 6, 6, 4, 6, 14, 5, 12, 14, 7, 13, 5, 13, 21, 14, 20, 12, 34, }, |
639 | | { 13, 5, 4, 6, 13, 11, 14, 6, 5, 3, 14, 22, 6, 4, 3, 6, 22, 29, 20, 34, }, |
640 | | { 8, 5, 8, 5, 5, 4, 5, 5, 4, 0, 5, 4, 1, 0, 0, 1, 4, 0, 0, 0, }, |
641 | | }), |
642 | | ContextSetCfg::addCtxSet |
643 | | ({ |
644 | | { 11, 5, 27, }, |
645 | | { 11, 4, 18, }, |
646 | | { 12, 4, 3, }, |
647 | | { 6, 5, 5, }, |
648 | | }) |
649 | | }; |
650 | | |
651 | | const CtxSet ContextSetCfg::MVPIdx = ContextSetCfg::addCtxSet |
652 | | ({ |
653 | | { 34, }, |
654 | | { 34, }, |
655 | | { 42, }, |
656 | | { 12, }, |
657 | | }); |
658 | | |
659 | | const CtxSet ContextSetCfg::SmvdFlag = ContextSetCfg::addCtxSet |
660 | | ({ |
661 | | { 28, }, |
662 | | { 28, }, |
663 | | { CNU, }, |
664 | | { 5, }, |
665 | | }); |
666 | | |
667 | | const CtxSet ContextSetCfg::SaoMergeFlag = ContextSetCfg::addCtxSet |
668 | | ({ |
669 | | { 2, }, |
670 | | { 60, }, |
671 | | { 60, }, |
672 | | { 0, }, |
673 | | }); |
674 | | |
675 | | const CtxSet ContextSetCfg::SaoTypeIdx = ContextSetCfg::addCtxSet |
676 | | ({ |
677 | | { 2, }, |
678 | | { 5, }, |
679 | | { 13, }, |
680 | | { 4, }, |
681 | | }); |
682 | | |
683 | | const CtxSet ContextSetCfg::LFNSTIdx = ContextSetCfg::addCtxSet |
684 | | ({ |
685 | | { 52, 37, 27, }, |
686 | | { 37, 45, 27, }, |
687 | | { 28, 52, 42, }, |
688 | | { 9, 9, 10, }, |
689 | | }); |
690 | | |
691 | | const CtxSet ContextSetCfg::PLTFlag = ContextSetCfg::addCtxSet |
692 | | ({ |
693 | | { 17, }, |
694 | | { 0, }, |
695 | | { 25, }, |
696 | | { 1, }, |
697 | | }); |
698 | | |
699 | | |
700 | | const CtxSet ContextSetCfg::TransformSkipFlag = ContextSetCfg::addCtxSet |
701 | | ({ |
702 | | { 25, 17, }, |
703 | | { 25, 9, }, |
704 | | { 25, 9, }, |
705 | | { 1, 1, }, |
706 | | }); |
707 | | |
708 | | const CtxSet ContextSetCfg::MTSIdx = ContextSetCfg::addCtxSet |
709 | | ({ |
710 | | { 45, 25, 27, 0, }, |
711 | | { 45, 40, 27, 0, }, |
712 | | { 29, 0, 28, 0, }, |
713 | | { 8, 0, 9, 0, }, |
714 | | }); |
715 | | |
716 | | |
717 | | const CtxSet ContextSetCfg::SbtFlag = ContextSetCfg::addCtxSet |
718 | | ({ |
719 | | { 41, 57, }, |
720 | | { 56, 57, }, |
721 | | { CNU, CNU, }, |
722 | | { 1, 5, }, |
723 | | }); |
724 | | |
725 | | const CtxSet ContextSetCfg::SbtQuadFlag = ContextSetCfg::addCtxSet |
726 | | ({ |
727 | | { 42, }, |
728 | | { 42, }, |
729 | | { CNU, }, |
730 | | { 10, }, |
731 | | }); |
732 | | |
733 | | const CtxSet ContextSetCfg::SbtHorFlag = ContextSetCfg::addCtxSet |
734 | | ({ |
735 | | { 35, 51, 27, }, |
736 | | { 20, 43, 12, }, |
737 | | { CNU, CNU, CNU, }, |
738 | | { 8, 4, 1, }, |
739 | | }); |
740 | | |
741 | | const CtxSet ContextSetCfg::SbtPosFlag = ContextSetCfg::addCtxSet |
742 | | ({ |
743 | | { 28, }, |
744 | | { 28, }, |
745 | | { CNU, }, |
746 | | { 13, }, |
747 | | }); |
748 | | |
749 | | const CtxSet ContextSetCfg::ChromaQpAdjFlag = ContextSetCfg::addCtxSet |
750 | | ({ |
751 | | { CNU, }, |
752 | | { CNU, }, |
753 | | { CNU, }, |
754 | | { DWS, }, |
755 | | }); |
756 | | |
757 | | const CtxSet ContextSetCfg::ChromaQpAdjIdc = ContextSetCfg::addCtxSet |
758 | | ({ |
759 | | { CNU, }, |
760 | | { CNU, }, |
761 | | { CNU, }, |
762 | | { DWS, }, |
763 | | }); |
764 | | |
765 | | const CtxSet ContextSetCfg::ImvFlag = ContextSetCfg::addCtxSet |
766 | | ({ |
767 | | { 59, 26, 50, 60, 38, }, |
768 | | { 59, 48, 58, 60, 60, }, |
769 | | { CNU, 34, CNU, CNU, CNU, }, |
770 | | { 0, 5, 0, 0, 4, }, |
771 | | }); |
772 | | |
773 | | const CtxSet ContextSetCfg::ctbAlfFlag = ContextSetCfg::addCtxSet |
774 | | ({ |
775 | | { 33, 52, 46, 25, 61, 54, 25, 61, 54, }, |
776 | | { 13, 23, 46, 4, 61, 54, 19, 46, 54, }, |
777 | | { 62, 39, 39, 54, 39, 39, 31, 39, 39, }, |
778 | | { 0, 0, 0, 4, 0, 0, 1, 0, 0, }, |
779 | | }); |
780 | | |
781 | | const CtxSet ContextSetCfg::ctbAlfAlternative = ContextSetCfg::addCtxSet |
782 | | ({ |
783 | | { 11, 26, }, |
784 | | { 20, 12, }, |
785 | | { 11, 11, }, |
786 | | { 0, 0, }, |
787 | | }); |
788 | | |
789 | | const CtxSet ContextSetCfg::AlfUseTemporalFilt = ContextSetCfg::addCtxSet |
790 | | ({ |
791 | | { 46, }, |
792 | | { 46, }, |
793 | | { 46, }, |
794 | | { 0, }, |
795 | | }); |
796 | | |
797 | | const CtxSet ContextSetCfg::CcAlfFilterControlFlag = ContextSetCfg::addCtxSet |
798 | | ({ |
799 | | { 25, 35, 38, 25, 28, 38, }, |
800 | | { 18, 21, 38, 18, 21, 38, }, |
801 | | { 18, 30, 31, 18, 30, 31, }, |
802 | | { 4, 1, 4, 4, 1, 4, }, |
803 | | }); |
804 | | |
805 | | const CtxSet ContextSetCfg::IBCFlag = ContextSetCfg::addCtxSet |
806 | | ({ |
807 | | { 0, 43, 45, }, |
808 | | { 0, 57, 44, }, |
809 | | { 17, 42, 36, }, |
810 | | { 1, 5, 8, }, |
811 | | }); |
812 | | |
813 | | const CtxSet ContextSetCfg::JointCbCrFlag = ContextSetCfg::addCtxSet |
814 | | ({ |
815 | | { 42, 43, 52, }, |
816 | | { 27, 36, 45, }, |
817 | | { 12, 21, 35, }, |
818 | | { 1, 1, 0, }, |
819 | | }); |
820 | | |
821 | | const CtxSet ContextSetCfg::TsSigCoeffGroup = ContextSetCfg::addCtxSet |
822 | | ({ |
823 | | { 18, 35, 45, }, |
824 | | { 18, 12, 29, }, |
825 | | { 18, 20, 38, }, |
826 | | { 5, 8, 8, }, |
827 | | }); |
828 | | |
829 | | const CtxSet ContextSetCfg::TsSigFlag = ContextSetCfg::addCtxSet |
830 | | ({ |
831 | | { 25, 50, 37, }, |
832 | | { 40, 35, 44, }, |
833 | | { 25, 28, 38, }, |
834 | | { 13, 13, 8, }, |
835 | | }); |
836 | | |
837 | | const CtxSet ContextSetCfg::TsParFlag = ContextSetCfg::addCtxSet |
838 | | ({ |
839 | | { 11, }, |
840 | | { 3, }, |
841 | | { 11, }, |
842 | | { 6, }, |
843 | | }); |
844 | | |
845 | | const CtxSet ContextSetCfg::TsGtxFlag = ContextSetCfg::addCtxSet |
846 | | ({ |
847 | | { CNU, 3, 4, 4, 5, }, |
848 | | { CNU, 2, 10, 3, 3, }, |
849 | | { CNU, 10, 3, 3, 3, }, |
850 | | { DWS, 1, 1, 1, 1, }, |
851 | | }); |
852 | | |
853 | | const CtxSet ContextSetCfg::TsLrg1Flag = ContextSetCfg::addCtxSet |
854 | | ({ |
855 | | { 19, 11, 4, 6, }, |
856 | | { 18, 11, 4, 28, }, |
857 | | { 11, 5, 5, 14, }, |
858 | | { 4, 2, 1, 6, }, |
859 | | }); |
860 | | |
861 | | const CtxSet ContextSetCfg::TsResidualSign = ContextSetCfg::addCtxSet |
862 | | ({ |
863 | | { 35, 25, 46, 28, 33, 38, }, |
864 | | { 5, 10, 53, 43, 25, 46, }, |
865 | | { 12, 17, 46, 28, 25, 46, }, |
866 | | { 1, 4, 4, 5, 8, 8, }, |
867 | | }); |
868 | | // clang-format on |
869 | | |
870 | | const unsigned ContextSetCfg::NumberOfContexts = (unsigned)ContextSetCfg::sm_InitTables[0].size(); |
871 | | |
872 | | |
873 | | // combined sets |
874 | | const CtxSet ContextSetCfg::Sao = { ContextSetCfg::SaoMergeFlag, ContextSetCfg::SaoTypeIdx }; |
875 | | |
876 | | const CtxSet ContextSetCfg::Alf = { ContextSetCfg::ctbAlfFlag, ContextSetCfg::ctbAlfAlternative, ContextSetCfg::AlfUseTemporalFilt }; |
877 | | |
878 | | CtxStore::CtxStore() |
879 | 0 | : m_CtxBuffer () |
880 | 0 | , m_Ctx ( nullptr ) |
881 | 0 | {} |
882 | | |
883 | | CtxStore::CtxStore( bool dummy ) |
884 | 0 | : m_CtxBuffer ( ContextSetCfg::NumberOfContexts ) |
885 | 0 | , m_Ctx ( m_CtxBuffer.data() ) |
886 | 0 | {} |
887 | | |
888 | | CtxStore::CtxStore( const CtxStore& ctxStore ) |
889 | 0 | : m_CtxBuffer ( ctxStore.m_CtxBuffer ) |
890 | 0 | , m_Ctx ( m_CtxBuffer.data() ) |
891 | 0 | {} |
892 | | |
893 | | void CtxStore::init( int qp, int initId ) |
894 | 0 | { |
895 | 0 | const std::vector<uint8_t>& initTable = ContextSetCfg::getInitTable( initId ); |
896 | 0 | CHECK( m_CtxBuffer.size() != initTable.size(), |
897 | 0 | "Size of init table (" << initTable.size() << ") does not match size of context buffer (" << m_CtxBuffer.size() << ")." ); |
898 | 0 | const std::vector<uint8_t> &rateInitTable = ContextSetCfg::getInitTable(VVENC_NUMBER_OF_SLICE_TYPES); |
899 | 0 | CHECK(m_CtxBuffer.size() != rateInitTable.size(), |
900 | 0 | "Size of rate init table (" << rateInitTable.size() << ") does not match size of context buffer (" |
901 | 0 | << m_CtxBuffer.size() << ")."); |
902 | 0 | int clippedQP = Clip3( 0, MAX_QP, qp ); |
903 | 0 | for( std::size_t k = 0; k < m_CtxBuffer.size(); k++ ) |
904 | 0 | { |
905 | 0 | m_CtxBuffer[k].init( clippedQP, initTable[k] ); |
906 | 0 | m_CtxBuffer[k].setLog2WindowSize(rateInitTable[k]); |
907 | 0 | } |
908 | 0 | } |
909 | | |
910 | | void CtxStore::setWinSizes( const std::vector<uint8_t>& log2WindowSizes ) |
911 | 0 | { |
912 | 0 | CHECK( m_CtxBuffer.size() != log2WindowSizes.size(), |
913 | 0 | "Size of window size table (" << log2WindowSizes.size() << ") does not match size of context buffer (" << m_CtxBuffer.size() << ")." ); |
914 | 0 | for( std::size_t k = 0; k < m_CtxBuffer.size(); k++ ) |
915 | 0 | { |
916 | 0 | m_CtxBuffer[k].setLog2WindowSize( log2WindowSizes[k] ); |
917 | 0 | } |
918 | 0 | } |
919 | | |
920 | | void CtxStore::loadPStates( const std::vector<uint16_t>& probStates ) |
921 | 0 | { |
922 | 0 | CHECK( m_CtxBuffer.size() != probStates.size(), |
923 | 0 | "Size of prob states table (" << probStates.size() << ") does not match size of context buffer (" << m_CtxBuffer.size() << ")." ); |
924 | 0 | for( std::size_t k = 0; k < m_CtxBuffer.size(); k++ ) |
925 | 0 | { |
926 | 0 | m_CtxBuffer[k].setState( probStates[k] ); |
927 | 0 | } |
928 | 0 | } |
929 | | |
930 | | void CtxStore::savePStates( std::vector<uint16_t>& probStates ) const |
931 | 0 | { |
932 | 0 | probStates.resize( m_CtxBuffer.size(), uint16_t(0) ); |
933 | 0 | for( std::size_t k = 0; k < m_CtxBuffer.size(); k++ ) |
934 | 0 | { |
935 | 0 | probStates[k] = m_CtxBuffer[k].getState(); |
936 | 0 | } |
937 | 0 | } |
938 | | |
939 | | |
940 | | |
941 | | |
942 | | |
943 | 0 | Ctx::Ctx() {} |
944 | 0 | Ctx::Ctx( const BinProbModel* dummy ) : m_CtxStore ( true ) {} |
945 | | |
946 | | Ctx::Ctx( const Ctx& ctx ) |
947 | 0 | : m_CtxStore ( ctx.m_CtxStore ) |
948 | 0 | { |
949 | 0 | } |
950 | | |
951 | | } // namespace vvenc |
952 | | |
953 | | //! \} |
954 | | |