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