/work/vvenc/source/Lib/CommonLib/Slice.h
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 | | /** \file Slice.h |
43 | | \brief slice header and SPS class (header) |
44 | | */ |
45 | | |
46 | | #pragma once |
47 | | |
48 | | #include "CommonDef.h" |
49 | | #include "Rom.h" |
50 | | #include "AlfParameters.h" |
51 | | #include "Common.h" |
52 | | #include "MotionInfo.h" |
53 | | #include "HRD.h" |
54 | | |
55 | | #include "vvenc/vvencCfg.h" |
56 | | |
57 | | |
58 | | #include <cstring> |
59 | | #include <list> |
60 | | #include <map> |
61 | | #include <vector> |
62 | | #include <cstdint> |
63 | | |
64 | | //! \ingroup CommonLib |
65 | | //! \{ |
66 | | |
67 | | namespace vvenc { |
68 | | |
69 | | struct MotionInfo; |
70 | | struct Picture; |
71 | | class Pic; |
72 | | class TrQuant; |
73 | | class PreCalcValues; |
74 | | typedef std::list<Picture*> PicList; |
75 | | |
76 | | // ==================================================================================================================== |
77 | | // Constants |
78 | | // ==================================================================================================================== |
79 | | static const uint32_t REF_PIC_LIST_NUM_IDX=32; |
80 | | |
81 | | |
82 | | // ==================================================================================================================== |
83 | | // Class definition |
84 | | // ==================================================================================================================== |
85 | | struct DpbParameters |
86 | | { |
87 | | int maxDecPicBuffering [VVENC_MAX_TLAYER] = { 0 }; |
88 | | int numReorderPics [VVENC_MAX_TLAYER] = { 0 }; |
89 | | int maxLatencyIncreasePlus1[VVENC_MAX_TLAYER] = { 0 }; |
90 | | }; |
91 | | |
92 | | struct ReferencePictureList |
93 | | { |
94 | | int numberOfShorttermPictures; |
95 | | int numberOfLongtermPictures; |
96 | | int numberOfActivePictures; |
97 | | bool isLongtermRefPic[VVENC_MAX_NUM_REF_PICS]; |
98 | | int refPicIdentifier[VVENC_MAX_NUM_REF_PICS]; //This can be delta POC for STRP or POC LSB for LTRP |
99 | | int POC[VVENC_MAX_NUM_REF_PICS]; |
100 | | uint32_t deltaPocMSBCycleLT[VVENC_MAX_NUM_REF_PICS]; |
101 | | bool deltaPocMSBPresent[VVENC_MAX_NUM_REF_PICS]; |
102 | | bool ltrpInSliceHeader; |
103 | | bool interLayerPresent; |
104 | | bool isInterLayerRefPic[VVENC_MAX_NUM_REF_PICS]; |
105 | | int interLayerRefPicIdx[VVENC_MAX_NUM_REF_PICS]; |
106 | | int numberOfInterLayerPictures; |
107 | | |
108 | | ReferencePictureList(); |
109 | | |
110 | | void initFromGopEntry ( const GOPEntry& gopEntry, int l ); |
111 | | void setRefPicIdentifier ( int idx, int identifier, bool isLongterm, bool isInterLayerRefPic, int interLayerIdx ); |
112 | 8.40k | int getNumRefEntries () const { return numberOfShorttermPictures + numberOfLongtermPictures; } |
113 | | bool isPOCInRefPicList ( const int poc, const int currPoc ) const; |
114 | | }; |
115 | | |
116 | | /// Reference Picture List set class |
117 | | typedef std::vector<ReferencePictureList> RPLList; |
118 | | |
119 | | struct ConstraintInfo |
120 | | { |
121 | | bool gciPresent; |
122 | | bool noRprConstraintFlag; |
123 | | bool noResChangeInClvsConstraintFlag; |
124 | | bool oneTilePerPicConstraintFlag; |
125 | | bool picHeaderInSliceHeaderConstraintFlag; |
126 | | bool oneSlicePerPicConstraintFlag; |
127 | | bool noIdrRplConstraintFlag; |
128 | | bool noRectSliceConstraintFlag; |
129 | | bool oneSlicePerSubpicConstraintFlag; |
130 | | bool noSubpicInfoConstraintFlag; |
131 | | bool intraOnlyConstraintFlag; |
132 | | uint32_t maxBitDepthConstraintIdc; |
133 | | int maxChromaFormatConstraintIdc; |
134 | | bool onePictureOnlyConstraintFlag; |
135 | | bool lowerBitRateConstraintFlag; |
136 | | bool allLayersIndependentConstraintFlag; |
137 | | bool noMrlConstraintFlag; |
138 | | bool noIspConstraintFlag; |
139 | | bool noMipConstraintFlag; |
140 | | bool noLfnstConstraintFlag; |
141 | | bool noMmvdConstraintFlag; |
142 | | bool noSmvdConstraintFlag; |
143 | | bool noProfConstraintFlag; |
144 | | bool noPaletteConstraintFlag; |
145 | | bool noActConstraintFlag; |
146 | | bool noLmcsConstraintFlag; |
147 | | bool noExplicitScaleListConstraintFlag; |
148 | | bool noVirtualBoundaryConstraintFlag; |
149 | | bool noMttConstraintFlag; |
150 | | bool noChromaQpOffsetConstraintFlag; |
151 | | bool noQtbttDualTreeIntraConstraintFlag; |
152 | | int maxLog2CtuSizeConstraintIdc; |
153 | | bool noPartitionConstraintsOverrideConstraintFlag; |
154 | | bool noSaoConstraintFlag; |
155 | | bool noAlfConstraintFlag; |
156 | | bool noCCAlfConstraintFlag; |
157 | | bool noWeightedPredictionConstraintFlag; |
158 | | bool noRefWraparoundConstraintFlag; |
159 | | bool noTemporalMvpConstraintFlag; |
160 | | bool noSbtmvpConstraintFlag; |
161 | | bool noAmvrConstraintFlag; |
162 | | bool noBdofConstraintFlag; |
163 | | bool noDmvrConstraintFlag; |
164 | | bool noCclmConstraintFlag; |
165 | | bool noMtsConstraintFlag; |
166 | | bool noSbtConstraintFlag; |
167 | | bool noAffineMotionConstraintFlag; |
168 | | bool noBcwConstraintFlag; |
169 | | bool noIbcConstraintFlag; |
170 | | bool noCiipConstraintFlag; |
171 | | bool noGeoConstraintFlag; |
172 | | bool noLadfConstraintFlag; |
173 | | bool noTransformSkipConstraintFlag; |
174 | | bool noLumaTransformSize64ConstraintFlag; |
175 | | bool noBDPCMConstraintFlag; |
176 | | bool noJointCbCrConstraintFlag; |
177 | | bool noQpDeltaConstraintFlag; |
178 | | bool noDepQuantConstraintFlag; |
179 | | bool noSignDataHidingConstraintFlag; |
180 | | bool noMixedNaluTypesInPicConstraintFlag; |
181 | | bool noTrailConstraintFlag; |
182 | | bool noStsaConstraintFlag; |
183 | | bool noRaslConstraintFlag; |
184 | | bool noRadlConstraintFlag; |
185 | | bool noIdrConstraintFlag; |
186 | | bool noCraConstraintFlag; |
187 | | bool noGdrConstraintFlag; |
188 | | bool noApsConstraintFlag; |
189 | | |
190 | | |
191 | | ConstraintInfo() |
192 | 3.60k | : gciPresent ( false ) |
193 | 3.60k | , noRprConstraintFlag ( false ) |
194 | 3.60k | , noResChangeInClvsConstraintFlag ( false ) |
195 | 3.60k | , oneTilePerPicConstraintFlag ( false ) |
196 | 3.60k | , picHeaderInSliceHeaderConstraintFlag ( false ) |
197 | 3.60k | , oneSlicePerPicConstraintFlag ( false ) |
198 | 3.60k | , noIdrRplConstraintFlag ( false ) |
199 | 3.60k | , noRectSliceConstraintFlag ( false ) |
200 | 3.60k | , oneSlicePerSubpicConstraintFlag ( false ) |
201 | 3.60k | , noSubpicInfoConstraintFlag ( false ) |
202 | 3.60k | , intraOnlyConstraintFlag ( false ) |
203 | 3.60k | , maxBitDepthConstraintIdc ( false ) |
204 | 3.60k | , maxChromaFormatConstraintIdc ( CHROMA_420 ) |
205 | 3.60k | , onePictureOnlyConstraintFlag ( false ) |
206 | 3.60k | , lowerBitRateConstraintFlag ( false ) |
207 | 3.60k | , allLayersIndependentConstraintFlag ( false ) |
208 | 3.60k | , noMrlConstraintFlag ( false ) |
209 | 3.60k | , noIspConstraintFlag ( false ) |
210 | 3.60k | , noMipConstraintFlag ( false ) |
211 | 3.60k | , noLfnstConstraintFlag ( false ) |
212 | 3.60k | , noMmvdConstraintFlag ( false ) |
213 | 3.60k | , noSmvdConstraintFlag ( false ) |
214 | 3.60k | , noProfConstraintFlag ( false ) |
215 | 3.60k | , noPaletteConstraintFlag ( false ) |
216 | 3.60k | , noActConstraintFlag ( false ) |
217 | 3.60k | , noLmcsConstraintFlag ( false ) |
218 | 3.60k | , noExplicitScaleListConstraintFlag ( false ) |
219 | 3.60k | , noVirtualBoundaryConstraintFlag ( false ) |
220 | 3.60k | , noMttConstraintFlag ( false ) |
221 | 3.60k | , noChromaQpOffsetConstraintFlag ( false ) |
222 | 3.60k | , noQtbttDualTreeIntraConstraintFlag ( false ) |
223 | 3.60k | , maxLog2CtuSizeConstraintIdc ( 0 ) |
224 | 3.60k | , noPartitionConstraintsOverrideConstraintFlag ( false ) |
225 | 3.60k | , noSaoConstraintFlag ( false ) |
226 | 3.60k | , noAlfConstraintFlag ( false ) |
227 | 3.60k | , noCCAlfConstraintFlag ( false ) |
228 | 3.60k | , noWeightedPredictionConstraintFlag ( false ) |
229 | 3.60k | , noRefWraparoundConstraintFlag ( false ) |
230 | 3.60k | , noTemporalMvpConstraintFlag ( false ) |
231 | 3.60k | , noSbtmvpConstraintFlag ( false ) |
232 | 3.60k | , noAmvrConstraintFlag ( false ) |
233 | 3.60k | , noBdofConstraintFlag ( false ) |
234 | 3.60k | , noDmvrConstraintFlag ( false ) |
235 | 3.60k | , noCclmConstraintFlag ( false ) |
236 | 3.60k | , noMtsConstraintFlag ( false ) |
237 | 3.60k | , noSbtConstraintFlag ( false ) |
238 | 3.60k | , noAffineMotionConstraintFlag ( false ) |
239 | 3.60k | , noBcwConstraintFlag ( false ) |
240 | 3.60k | , noIbcConstraintFlag ( false ) |
241 | 3.60k | , noCiipConstraintFlag ( false ) |
242 | 3.60k | , noGeoConstraintFlag ( false ) |
243 | 3.60k | , noLadfConstraintFlag ( false ) |
244 | 3.60k | , noTransformSkipConstraintFlag ( false ) |
245 | 3.60k | , noLumaTransformSize64ConstraintFlag ( false ) |
246 | 3.60k | , noBDPCMConstraintFlag ( false ) |
247 | 3.60k | , noJointCbCrConstraintFlag ( false ) |
248 | 3.60k | , noQpDeltaConstraintFlag ( false ) |
249 | 3.60k | , noDepQuantConstraintFlag ( false ) |
250 | 3.60k | , noSignDataHidingConstraintFlag ( false ) |
251 | 3.60k | , noMixedNaluTypesInPicConstraintFlag ( false ) |
252 | 3.60k | , noTrailConstraintFlag ( false ) |
253 | 3.60k | , noStsaConstraintFlag ( false ) |
254 | 3.60k | , noRaslConstraintFlag ( false ) |
255 | 3.60k | , noRadlConstraintFlag ( false ) |
256 | 3.60k | , noIdrConstraintFlag ( false ) |
257 | 3.60k | , noCraConstraintFlag ( false ) |
258 | 3.60k | , noGdrConstraintFlag ( false ) |
259 | 3.60k | , noApsConstraintFlag ( false ) |
260 | 3.60k | {} |
261 | | }; |
262 | | |
263 | | struct ProfileTierLevel |
264 | | { |
265 | | vvencTier tierFlag; |
266 | | vvencProfile profileIdc; |
267 | | uint8_t numSubProfile; |
268 | | std::vector<uint32_t> subProfileIdc; |
269 | | vvencLevel levelIdc; |
270 | | bool frameOnlyConstraintFlag; |
271 | | bool multiLayerEnabledFlag; |
272 | | ConstraintInfo constraintInfo; |
273 | | bool subLayerLevelPresent[VVENC_MAX_TLAYER - 1]; |
274 | | vvencLevel subLayerLevelIdc[VVENC_MAX_TLAYER - 1]; |
275 | | |
276 | | ProfileTierLevel() |
277 | 3.60k | : tierFlag ( VVENC_TIER_MAIN ) |
278 | 3.60k | , profileIdc ( VVENC_PROFILE_AUTO ) |
279 | 3.60k | , numSubProfile (0) |
280 | 3.60k | , subProfileIdc (0) |
281 | 3.60k | , levelIdc ( VVENC_LEVEL_AUTO ) |
282 | 3.60k | , frameOnlyConstraintFlag ( true ) |
283 | 3.60k | , multiLayerEnabledFlag ( false ) |
284 | 3.60k | { |
285 | 3.60k | ::memset( subLayerLevelPresent, 0, sizeof(subLayerLevelPresent )); |
286 | 3.60k | ::memset( subLayerLevelIdc, 0, sizeof(subLayerLevelIdc )); |
287 | 3.60k | } |
288 | | }; |
289 | | |
290 | | |
291 | | struct ChromaQpAdj |
292 | | { |
293 | | union |
294 | | { |
295 | | struct { |
296 | | int CbOffset; |
297 | | int CrOffset; |
298 | | int JointCbCrOffset; |
299 | | } comp; |
300 | | int offset[3]; |
301 | | } u; |
302 | | }; |
303 | | |
304 | | struct ChromaQpMappingTable : vvencChromaQpMappingTableParams |
305 | | { |
306 | 6.25M | int getMappedChromaQpValue(ComponentID compID, const int qpVal) const { return m_chromaQpMappingTables[m_sameCQPTableForAllChromaFlag ? 0 : (int)compID - 1].at(qpVal + m_qpBdOffset); } |
307 | | void derivedChromaQPMappingTables(); |
308 | | void setParams(const vvencChromaQpMappingTableParams ¶ms, const int qpBdOffset); |
309 | | private: |
310 | | std::vector<int> m_chromaQpMappingTables[VVENC_MAX_NUM_CQP_MAPPING_TABLES]; |
311 | | }; |
312 | | |
313 | | struct SliceMap |
314 | | { |
315 | | uint32_t sliceID; //!< slice identifier (slice index for rectangular slices, slice address for raser-scan slices) |
316 | | uint32_t numTilesInSlice; //!< number of tiles in slice (raster-scan slices only) |
317 | | uint32_t numCtuInSlice; //!< number of CTUs in the slice |
318 | | std::vector<int> ctuAddrInSlice; //!< raster-scan addresses of all the CTUs in the slice |
319 | | |
320 | | SliceMap() |
321 | 2.40k | : sliceID ( 0 ) |
322 | 2.40k | , numTilesInSlice ( 0 ) |
323 | 2.40k | , numCtuInSlice ( 0 ) |
324 | 2.40k | , ctuAddrInSlice ( ) |
325 | 2.40k | { |
326 | 2.40k | } |
327 | | |
328 | | void initSliceMap() |
329 | 0 | { |
330 | 0 | sliceID = 0; |
331 | 0 | numTilesInSlice = 0; |
332 | 0 | numCtuInSlice = 0; |
333 | 0 | ctuAddrInSlice.clear(); |
334 | 0 | } |
335 | | |
336 | | void addCtusToSlice( uint32_t startX, uint32_t stopX, uint32_t startY, uint32_t stopY, uint32_t picWidthInCtbsY ) |
337 | 2.40k | { |
338 | 2.40k | CHECK( startX >= stopX || startY >= stopY, "Invalid slice definition"); |
339 | 6.67k | for( uint32_t ctbY = startY; ctbY < stopY; ctbY++ ) |
340 | 4.27k | { |
341 | 11.9k | for( uint32_t ctbX = startX; ctbX < stopX; ctbX++ ) |
342 | 7.69k | { |
343 | 7.69k | ctuAddrInSlice.push_back( ctbY * picWidthInCtbsY + ctbX ); |
344 | 7.69k | numCtuInSlice++; |
345 | 7.69k | } |
346 | 4.27k | } |
347 | 2.40k | } |
348 | | }; |
349 | | |
350 | | struct RectSlice |
351 | | { |
352 | | uint32_t tileIdx; //!< tile index corresponding to the first CTU in the slice |
353 | | uint32_t sliceWidthInTiles; //!< slice width in units of tiles |
354 | | uint32_t sliceHeightInTiles; //!< slice height in units of tiles |
355 | | uint32_t numSlicesInTile; //!< number of slices in current tile for the special case of multiple slices inside a single tile |
356 | | uint32_t sliceHeightInCtu; //!< slice height in units of CTUs for the special case of multiple slices inside a single tile |
357 | | |
358 | 0 | RectSlice() {} |
359 | | }; |
360 | | |
361 | | struct SubPic |
362 | | { |
363 | | uint32_t subPicID; //!< ID of subpicture |
364 | | uint32_t subPicIdx; //!< Index of subpicture |
365 | | uint32_t numCTUsInSubPic; //!< number of CTUs contained in this sub-picture |
366 | | uint32_t subPicCtuTopLeftX; //!< horizontal position of top left CTU of the subpicture in unit of CTU |
367 | | uint32_t subPicCtuTopLeftY; //!< vertical position of top left CTU of the subpicture in unit of CTU |
368 | | uint32_t subPicWidth; //!< the width of subpicture in units of CTU |
369 | | uint32_t subPicHeight; //!< the height of subpicture in units of CTU |
370 | | uint32_t subPicWidthInLumaSample; //!< the width of subpicture in units of luma sample |
371 | | uint32_t subPicHeightInLumaSample; //!< the height of subpicture in units of luma sample |
372 | | uint32_t firstCtuInSubPic; //!< the raster scan index of the first CTU in a subpicture |
373 | | uint32_t lastCtuInSubPic; //!< the raster scan index of the last CTU in a subpicture |
374 | | uint32_t subPicLeft; //!< the position of left boundary |
375 | | uint32_t subPicRight; //!< the position of right boundary |
376 | | uint32_t subPicTop; //!< the position of top boundary |
377 | | uint32_t subPicBottom; //!< the position of bottom boundary |
378 | | std::vector<uint32_t> ctuAddrInSubPic; //!< raster scan addresses of all the CTUs in the slice |
379 | | |
380 | | bool treatedAsPic; //!< whether the subpicture is treated as a picture in the decoding process excluding in-loop filtering operations |
381 | | bool loopFilterAcrossSubPicEnabled; //!< whether in-loop filtering operations may be performed across the boundaries of the subpicture |
382 | | uint32_t numSlicesInSubPic; //!< Number of slices contained in this subpicture |
383 | | |
384 | | bool isContainingPos(const Position& pos) const |
385 | 0 | { |
386 | 0 | return pos.x >= subPicLeft && pos.x <= subPicRight && pos.y >= subPicTop && pos.y <= subPicBottom; |
387 | 0 | } |
388 | | |
389 | | void init( unsigned picWithInCtu, unsigned picHeightInCtu, unsigned picWithInSamples, unsigned picHeighthInSamples ) |
390 | 1.20k | { |
391 | 1.20k | unsigned numCtus = picWithInCtu * picHeightInCtu; |
392 | 1.20k | numCTUsInSubPic = numCtus; |
393 | 1.20k | subPicWidth = picWithInCtu; |
394 | 1.20k | subPicHeight = picHeightInCtu; |
395 | 1.20k | subPicWidthInLumaSample = picWithInSamples; |
396 | 1.20k | subPicHeightInLumaSample = picHeighthInSamples; |
397 | 1.20k | lastCtuInSubPic = numCtus; |
398 | 1.20k | subPicRight = picWithInSamples-1; |
399 | 1.20k | subPicBottom = picHeighthInSamples-1; |
400 | 1.20k | ctuAddrInSubPic.resize( numCtus ); |
401 | 5.04k | for( unsigned i = 0; i < numCtus; i++) |
402 | 3.84k | { |
403 | 3.84k | ctuAddrInSubPic[i] = i; |
404 | 3.84k | } |
405 | 1.20k | } |
406 | | |
407 | | SubPic() |
408 | 1.20k | : subPicID(0) |
409 | 1.20k | , subPicIdx(0) |
410 | 1.20k | , numCTUsInSubPic(UINT32_MAX) |
411 | 1.20k | , subPicCtuTopLeftX(0) |
412 | 1.20k | , subPicCtuTopLeftY(0) |
413 | 1.20k | , subPicWidth(UINT32_MAX) |
414 | 1.20k | , subPicHeight(UINT32_MAX) |
415 | 1.20k | , subPicWidthInLumaSample(UINT32_MAX) |
416 | 1.20k | , subPicHeightInLumaSample(UINT32_MAX) |
417 | 1.20k | , firstCtuInSubPic(0) |
418 | 1.20k | , lastCtuInSubPic(UINT32_MAX) |
419 | 1.20k | , subPicLeft(0) |
420 | 1.20k | , subPicRight(0) |
421 | 1.20k | , subPicTop(0) |
422 | 1.20k | , subPicBottom(0) |
423 | 1.20k | , treatedAsPic(true) |
424 | 1.20k | , loopFilterAcrossSubPicEnabled(true) |
425 | 1.20k | , numSlicesInSubPic(1) |
426 | 1.20k | { |
427 | 1.20k | } |
428 | | }; |
429 | | |
430 | | struct DCI |
431 | | { |
432 | | uint32_t dciId; |
433 | | std::vector<ProfileTierLevel> profileTierLevel; |
434 | | |
435 | 1.20k | DCI() : dciId(0) {} |
436 | | }; |
437 | | |
438 | | struct VPS |
439 | | { |
440 | | uint32_t vpsId; |
441 | | uint32_t maxLayers; |
442 | | uint32_t maxSubLayers; |
443 | | uint32_t layerId[MAX_VPS_LAYERS]; |
444 | | bool defaultPtlDpbHrdMaxTidFlag; |
445 | | bool allLayersSameNumSubLayers; |
446 | | bool allIndependentLayers; |
447 | | uint32_t vpsCfgPredDirection[MAX_VPS_SUBLAYERS]; |
448 | | bool independentLayer[MAX_VPS_LAYERS]; |
449 | | bool directRefLayer[MAX_VPS_LAYERS][MAX_VPS_LAYERS]; |
450 | | uint8_t maxTidIlRefPicsPlus1[MAX_VPS_LAYERS][MAX_VPS_LAYERS]; |
451 | | bool eachLayerIsAnOls; |
452 | | uint32_t olsModeIdc; |
453 | | uint32_t numOutputLayerSets; |
454 | | bool olsOutputLayer[MAX_NUM_OLSS][MAX_VPS_LAYERS]; |
455 | | uint32_t directRefLayerIdx[MAX_VPS_LAYERS][MAX_VPS_LAYERS]; |
456 | | uint32_t generalLayerIdx[MAX_VPS_LAYERS]; |
457 | | uint32_t numPtls; |
458 | | bool ptPresent[MAX_NUM_OLSS]; |
459 | | uint32_t ptlMaxTemporalId[MAX_NUM_OLSS]; |
460 | | std::vector<ProfileTierLevel> profileTierLevel; |
461 | | uint32_t olsPtlIdx[MAX_NUM_OLSS]; |
462 | | |
463 | | // stores index ( ilrp_idx within 0 .. NumDirectRefLayers ) of the dependent reference layers |
464 | | uint32_t interLayerRefIdx[MAX_VPS_LAYERS][MAX_VPS_LAYERS]; |
465 | | bool extension; |
466 | | |
467 | | bool generalHrdParamsPresent; |
468 | | bool sublayerCpbParamsPresent; |
469 | | uint32_t numOlsHrdParamsMinus1; |
470 | | uint32_t hrdMaxTid[MAX_NUM_OLSS]; |
471 | | uint32_t olsHrdIdx[MAX_NUM_OLSS]; |
472 | | GeneralHrdParams generalHrdParams; |
473 | | OlsHrdParams olsHrdParams[VVENC_MAX_TLAYER]; |
474 | | std::vector<Size> olsDpbPicSize; |
475 | | std::vector<int> olsDpbParamsIdx; |
476 | | std::vector<std::vector<int>> outputLayerIdInOls; |
477 | | std::vector<std::vector<int>> numSubLayersInLayerInOLS; |
478 | | |
479 | | std::vector<int> olsDpbChromaFormatIdc; |
480 | | std::vector<int> olsDpbBitDepthMinus8; |
481 | | |
482 | | int totalNumOLSs; |
483 | | int numMultiLayeredOlss; |
484 | | uint32_t multiLayerOlsIdx[MAX_NUM_OLSS]; |
485 | | int numDpbParams; |
486 | | std::vector<DpbParameters> dpbParameters; |
487 | | bool sublayerDpbParamsPresent; |
488 | | std::vector<int> dpbMaxTemporalId; |
489 | | std::vector<int> targetOutputLayerIdSet; ///< set of LayerIds to be outputted |
490 | | std::vector<int> targetLayerIdSet; ///< set of LayerIds to be included in the sub-bitstream extraction process. |
491 | | int targetOlsIdx; |
492 | | std::vector<int> numOutputLayersInOls; |
493 | | std::vector<int> numLayersInOls; |
494 | | std::vector<std::vector<int>> layerIdInOls; |
495 | | |
496 | | VPS() |
497 | 1.20k | : vpsId ( 0 ) |
498 | 1.20k | , maxLayers ( 0 ) |
499 | 1.20k | , maxSubLayers ( 0 ) |
500 | 1.20k | , defaultPtlDpbHrdMaxTidFlag ( false ) |
501 | 1.20k | , allLayersSameNumSubLayers ( false ) |
502 | 1.20k | , allIndependentLayers ( false ) |
503 | 1.20k | , eachLayerIsAnOls ( false ) |
504 | 1.20k | , olsModeIdc ( 0 ) |
505 | 1.20k | , numOutputLayerSets ( 0 ) |
506 | 1.20k | , numPtls ( 0 ) |
507 | 1.20k | , extension ( false ) |
508 | 1.20k | , totalNumOLSs ( 0 ) |
509 | 1.20k | , numDpbParams ( 0 ) |
510 | 1.20k | , sublayerDpbParamsPresent ( false) |
511 | 1.20k | , targetOlsIdx ( 0 ) |
512 | 1.20k | { |
513 | 1.20k | memset( layerId, 0, sizeof(layerId)); |
514 | 1.20k | memset( independentLayer, 0, sizeof(independentLayer)); |
515 | 1.20k | memset( directRefLayer, 0, sizeof(directRefLayer)); |
516 | 1.20k | memset( maxTidIlRefPicsPlus1, 7, sizeof(maxTidIlRefPicsPlus1)); |
517 | 1.20k | memset( olsOutputLayer, 0, sizeof(olsOutputLayer)); |
518 | 1.20k | memset( directRefLayerIdx, 0, sizeof(directRefLayerIdx)); |
519 | 1.20k | memset( generalLayerIdx, 0, sizeof(generalLayerIdx)); |
520 | 1.20k | memset( ptPresent, 0, sizeof(ptPresent)); |
521 | 1.20k | memset( ptlMaxTemporalId, 0, sizeof(ptlMaxTemporalId)); |
522 | 1.20k | memset( olsPtlIdx, 0, sizeof(olsPtlIdx)); |
523 | 1.20k | memset( interLayerRefIdx, 0, sizeof(interLayerRefIdx)); |
524 | 1.20k | } |
525 | | void deriveOutputLayerSets(); |
526 | 0 | int getMaxDecPicBuffering( int temporalId ) const { return dpbParameters[olsDpbParamsIdx[targetOlsIdx]].maxDecPicBuffering[temporalId]; } |
527 | 0 | int getNumReorderPics( int temporalId ) const { return dpbParameters[olsDpbParamsIdx[targetOlsIdx]].numReorderPics[temporalId]; } |
528 | | |
529 | | }; |
530 | | |
531 | | struct Window |
532 | | { |
533 | | bool enabledFlag; |
534 | | int winLeftOffset; |
535 | | int winRightOffset; |
536 | | int winTopOffset; |
537 | | int winBottomOffset; |
538 | | |
539 | | Window() |
540 | 3.60k | : enabledFlag (false) |
541 | 3.60k | , winLeftOffset (0) |
542 | 3.60k | , winRightOffset (0) |
543 | 3.60k | , winTopOffset (0) |
544 | 3.60k | , winBottomOffset(0) |
545 | 3.60k | { } |
546 | | |
547 | | void setWindow(int offsetLeft, int offsetLRight, int offsetLTop, int offsetLBottom) |
548 | 1.20k | { |
549 | 1.20k | enabledFlag = offsetLeft || offsetLRight || offsetLTop || offsetLBottom; |
550 | 1.20k | winLeftOffset = offsetLeft; |
551 | 1.20k | winRightOffset = offsetLRight; |
552 | 1.20k | winTopOffset = offsetLTop; |
553 | 1.20k | winBottomOffset = offsetLBottom; |
554 | 1.20k | } |
555 | | |
556 | | bool operator!=( const Window& other ) const |
557 | 0 | { |
558 | 0 | return (winLeftOffset != other.winLeftOffset |
559 | 0 | || winRightOffset != other.winRightOffset |
560 | 0 | || winTopOffset != other.winTopOffset |
561 | 0 | || winBottomOffset != other.winBottomOffset); |
562 | 0 | } |
563 | | |
564 | | }; |
565 | | |
566 | | |
567 | | struct VUI |
568 | | { |
569 | | bool progressiveSourceFlag; |
570 | | bool interlacedSourceFlag; |
571 | | bool nonPackedFlag; |
572 | | bool nonProjectedFlag; |
573 | | bool aspectRatioInfoPresent; |
574 | | bool aspectRatioConstantFlag; |
575 | | uint32_t aspectRatioIdc; |
576 | | uint32_t sarWidth; |
577 | | uint32_t sarHeight; |
578 | | bool overscanInfoPresent; |
579 | | bool overscanAppropriateFlag; |
580 | | bool colourDescriptionPresent; |
581 | | uint32_t colourPrimaries; |
582 | | uint32_t transferCharacteristics; |
583 | | uint32_t matrixCoefficients; |
584 | | bool videoFullRangeFlag; |
585 | | bool chromaLocInfoPresent; |
586 | | uint32_t chromaSampleLocTypeTopField; |
587 | | uint32_t chromaSampleLocTypeBottomField; |
588 | | uint32_t chromaSampleLocType; |
589 | | |
590 | | VUI() |
591 | 1.20k | : progressiveSourceFlag (true) |
592 | 1.20k | , interlacedSourceFlag (false) |
593 | 1.20k | , nonPackedFlag (true) |
594 | 1.20k | , nonProjectedFlag (true) |
595 | 1.20k | , aspectRatioInfoPresent (false) //TODO: This initialiser list contains magic numbers |
596 | 1.20k | , aspectRatioConstantFlag (false) |
597 | 1.20k | , aspectRatioIdc (0) |
598 | 1.20k | , sarWidth (0) |
599 | 1.20k | , sarHeight (0) |
600 | 1.20k | , overscanInfoPresent (false) |
601 | 1.20k | , overscanAppropriateFlag (false) |
602 | 1.20k | , colourDescriptionPresent (false) |
603 | 1.20k | , colourPrimaries (2) |
604 | 1.20k | , transferCharacteristics (2) |
605 | 1.20k | , matrixCoefficients (2) |
606 | 1.20k | , videoFullRangeFlag (false) |
607 | 1.20k | , chromaLocInfoPresent (false) |
608 | 1.20k | , chromaSampleLocTypeTopField (0) |
609 | 1.20k | , chromaSampleLocTypeBottomField (0) |
610 | 1.20k | , chromaSampleLocType (0) |
611 | 1.20k | {} |
612 | | }; |
613 | | |
614 | | |
615 | | /// SPS class |
616 | | struct SPS |
617 | | { |
618 | | int spsId; |
619 | | int dciId; |
620 | | int vpsId; |
621 | | int layerId; |
622 | | |
623 | | bool AffineAmvr; |
624 | | bool DMVR; |
625 | | bool MMVD; |
626 | | bool SBT; |
627 | | bool ISP; |
628 | | ChromaFormat chromaFormatIdc; |
629 | | bool separateColourPlane; //!< separate colour plane |
630 | | uint32_t maxTLayers; // maximum number of temporal layers |
631 | | bool ptlDpbHrdParamsPresent; |
632 | | bool subLayerDpbParams; |
633 | | |
634 | | // Structure |
635 | | uint32_t maxPicWidthInLumaSamples; |
636 | | uint32_t maxPicHeightInLumaSamples; |
637 | | Window conformanceWindow; |
638 | | bool subPicInfoPresent; |
639 | | uint8_t numSubPics; //!< number of sub-pictures used |
640 | | bool independentSubPicsFlag; |
641 | | uint32_t subPicCtuTopLeftX[MAX_NUM_SUB_PICS]; |
642 | | uint32_t subPicCtuTopLeftY[MAX_NUM_SUB_PICS]; |
643 | | uint32_t subPicWidth[MAX_NUM_SUB_PICS]; |
644 | | uint32_t subPicHeight[MAX_NUM_SUB_PICS]; |
645 | | bool subPicTreatedAsPic[MAX_NUM_SUB_PICS]; |
646 | | bool loopFilterAcrossSubpicEnabled[MAX_NUM_SUB_PICS]; |
647 | | bool subPicIdMappingExplicitlySignalled; |
648 | | uint32_t subPicIdLen; //!< sub-picture ID length in bits |
649 | | uint8_t subPicId[MAX_NUM_SUB_PICS]; //!< sub-picture ID for each sub-picture in the sequence |
650 | | |
651 | | int log2MinCodingBlockSize; |
652 | | unsigned CTUSize; |
653 | | unsigned partitionOverrideEnabled; // enable partition constraints override function |
654 | | unsigned minQTSize[3]; // 0: I slice luma; 1: P/B slice; 2: I slice chroma |
655 | | unsigned maxMTTDepth[3]; |
656 | | unsigned maxBTSize[3]; |
657 | | unsigned maxTTSize[3]; |
658 | | bool idrRefParamList; |
659 | | unsigned dualITree; |
660 | | |
661 | | RPLList rplList[NUM_REF_PIC_LIST_01]; |
662 | | bool rpl1CopyFromRpl0; |
663 | | bool rpl1IdxPresent; |
664 | | bool allRplEntriesHasSameSign; |
665 | | bool longTermRefsPresent; |
666 | | bool temporalMVPEnabled; |
667 | | int numReorderPics[VVENC_MAX_TLAYER]; |
668 | | |
669 | | // Tool list |
670 | | bool transformSkip; |
671 | | int log2MaxTransformSkipBlockSize; |
672 | | bool BDPCM; |
673 | | bool jointCbCr; |
674 | | // Parameter |
675 | | BitDepths bitDepths; |
676 | | bool entropyCodingSyncEnabled; |
677 | | bool entryPointsPresent; |
678 | | int qpBDOffset[MAX_NUM_CH]; |
679 | | int internalMinusInputBitDepth[MAX_NUM_CH]; // max(0, internal bitdepth - input bitdepth); |
680 | | |
681 | | bool SbtMvp; |
682 | | bool BDOF; |
683 | | bool fpelMmvd; |
684 | | bool BdofPresent; |
685 | | bool DmvrPresent; |
686 | | bool ProfPresent; |
687 | | uint32_t bitsForPOC; |
688 | | |
689 | | bool pocMsbFlag; |
690 | | uint32_t pocMsbLen; |
691 | | int numExtraPHBitsBytes; |
692 | | int numExtraSHBitsBytes; |
693 | | std::vector<bool> extraPHBitPresent; |
694 | | std::vector<bool> extraSHBitPresent; |
695 | | |
696 | | uint32_t numLongTermRefPicSPS; |
697 | | uint32_t ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS]; |
698 | | bool usedByCurrPicLtSPS[MAX_NUM_LONG_TERM_REF_PICS]; |
699 | | uint32_t log2MaxTbSize; |
700 | | bool weightPred; //!< Use of Weighting Prediction (P_SLICE) |
701 | | bool weightedBiPred; //!< Use of Weighting Bi-Prediction (B_SLICE) |
702 | | |
703 | | bool saoEnabled; |
704 | | |
705 | | bool temporalIdNesting; // temporal_id_nesting_flag |
706 | | |
707 | | bool scalingListEnabled; |
708 | | bool depQuantEnabled; //!< dependent quantization enabled flag |
709 | | bool signDataHidingEnabled; //!< sign data hiding enabled flag |
710 | | bool virtualBoundariesEnabled; //!< Enable virtual boundaries tool |
711 | | bool virtualBoundariesPresent ; //!< disable loop filtering across virtual boundaries |
712 | | unsigned numVerVirtualBoundaries; //!< number of vertical virtual boundaries |
713 | | unsigned numHorVirtualBoundaries; //!< number of horizontal virtual boundaries |
714 | | unsigned virtualBoundariesPosX[3]; //!< horizontal position of each vertical virtual boundary |
715 | | unsigned virtualBoundariesPosY[3]; //!< vertical position of each horizontal virtual boundary |
716 | | uint32_t maxDecPicBuffering[VVENC_MAX_TLAYER]; |
717 | | uint32_t maxLatencyIncreasePlus1[VVENC_MAX_TLAYER]; |
718 | | |
719 | | |
720 | | bool hrdParametersPresent; |
721 | | bool subLayerParametersPresent; |
722 | | GeneralHrdParams generalHrdParams; |
723 | | OlsHrdParams olsHrdParams[VVENC_MAX_TLAYER]; |
724 | | bool fieldSeqFlag; |
725 | | bool vuiParametersPresent; |
726 | | unsigned vuiPayloadSize; |
727 | | VUI vuiParameters; |
728 | | |
729 | | // TimingInfo timingInfo; |
730 | | ProfileTierLevel profileTierLevel; |
731 | | |
732 | | bool alfEnabled; |
733 | | bool ccalfEnabled; |
734 | | bool wrapAroundEnabled; |
735 | | bool IBC; |
736 | | bool useColorTrans; |
737 | | bool PLT; |
738 | | |
739 | | bool AMVR; |
740 | | bool LMChroma; |
741 | | bool horCollocatedChroma; |
742 | | bool verCollocatedChroma; |
743 | | bool MTS; |
744 | | bool MTSIntra; // 18 |
745 | | bool MTSInter; // 19 |
746 | | bool LFNST; |
747 | | bool SMVD; |
748 | | bool Affine; |
749 | | bool AffineType; |
750 | | bool PROF; |
751 | | bool BCW; |
752 | | bool CIIP; |
753 | | bool GEO; |
754 | | bool LADF; |
755 | | bool MRL; |
756 | | bool MIP; |
757 | | ChromaQpMappingTable chromaQpMappingTable; |
758 | | bool GDR; |
759 | | bool subLayerCbpParametersPresent; |
760 | | |
761 | | bool rprEnabled; |
762 | | bool resChangeInClvsEnabled; |
763 | | bool interLayerPresent; |
764 | | |
765 | | uint32_t log2ParallelMergeLevelMinus2; // th fix this |
766 | | uint32_t maxNumMergeCand; |
767 | | uint32_t maxNumAffineMergeCand; |
768 | | uint32_t maxNumIBCMergeCand; |
769 | | uint32_t maxNumGeoCand; |
770 | | bool scalingMatrixAlternativeColourSpaceDisabled; |
771 | | bool scalingMatrixDesignatedColourSpace; |
772 | | bool disableScalingMatrixForLfnstBlks; |
773 | | |
774 | | SPS(); |
775 | 2.40k | int getNumRPL( int idx) const { return (int)rplList[idx].size()-1;} |
776 | 6.61M | int getMaxLog2TrDynamicRange() const { return 15; } |
777 | 8.56M | uint32_t getMaxTbSize() const { return 1 << log2MaxTbSize; } |
778 | 196k | bool getUseImplicitMTS () const { return MTS && !MTSIntra; } |
779 | | |
780 | | static int getWinUnitX (int chromaFormatIdc) |
781 | 6.00k | { |
782 | 6.00k | CHECK(chromaFormatIdc < 0 || chromaFormatIdc >= NUM_CHROMA_FORMAT, "Invalid chroma format parameter"); |
783 | 6.00k | return (chromaFormatIdc == 1 || chromaFormatIdc == 2) ? 2 : 1; |
784 | 6.00k | } |
785 | | static int getWinUnitY (int chromaFormatIdc) |
786 | 6.00k | { |
787 | 6.00k | CHECK(chromaFormatIdc < 0 || chromaFormatIdc >= NUM_CHROMA_FORMAT, "Invalid chroma format parameter"); |
788 | 6.00k | return (chromaFormatIdc == 1) ? 2 : 1; |
789 | 6.00k | } |
790 | | |
791 | | private: |
792 | | static const int m_winUnitX[NUM_CHROMA_FORMAT]; |
793 | | static const int m_winUnitY[NUM_CHROMA_FORMAT]; |
794 | | }; |
795 | | |
796 | | |
797 | | /// Reference Picture Lists class |
798 | | |
799 | | /// PPS class |
800 | | struct PPS |
801 | | { |
802 | | int ppsId; // pic_parameter_set_id |
803 | | int spsId; // seq_parameter_set_id |
804 | | int picInitQPMinus26; |
805 | | bool useDQP; |
806 | | bool usePPSChromaTool; |
807 | | bool sliceChromaQpFlag; // slicelevel_chroma_qp_flag |
808 | | int layerId; |
809 | | int temporalId; |
810 | | |
811 | | // access channel |
812 | | int chromaQpOffset[MAX_NUM_COMP+1]; //also includes JointCbCr |
813 | | bool jointCbCrQpOffsetPresent; |
814 | | ChromaQpAdj chromaQpAdjTableIncludingNullEntry[1+MAX_QP_OFFSET_LIST_SIZE]; //!< Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise |
815 | | |
816 | | // Chroma QP Adjustments |
817 | | int chromaQpOffsetListLen; // size (excludes the null entry used in the following array). |
818 | | ChromaQpAdj ChromaQpAdjTableIncludingNullEntry[1+MAX_QP_OFFSET_LIST_SIZE]; //!< Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise |
819 | | |
820 | | uint32_t numRefIdxL0DefaultActive; |
821 | | uint32_t numRefIdxL1DefaultActive; |
822 | | |
823 | | bool rpl1IdxPresent; |
824 | | |
825 | | bool weightPred; //!< Use of Weighting Prediction (P_SLICE) |
826 | | bool weightedBiPred; //!< Use of Weighting Bi-Prediction (B_SLICE) |
827 | | bool outputFlagPresent; //!< Indicates the presence of output_flag in slice header |
828 | | uint8_t numSubPics; //!< number of sub-p |
829 | | bool subPicIdMappingInPps; |
830 | | uint32_t subPicIdLen; //!< sub-picture ID length in bits |
831 | | uint8_t subPicId[MAX_NUM_SUB_PICS]; //!< sub-picture ID for each sub-picture in the sequence |
832 | | bool noPicPartition; //!< no picture partitioning flag - single slice, single tile |
833 | | uint8_t log2CtuSize; //!< log2 of the CTU size - required to match corresponding value in SPS |
834 | | uint8_t ctuSize; //!< CTU size |
835 | | uint32_t picWidthInCtu; //!< picture width in units of CTUs |
836 | | uint32_t picHeightInCtu; //!< picture height in units of CTUs |
837 | | uint32_t numExpTileCols; //!< number of explicitly specified tile columns |
838 | | uint32_t numExpTileRows; //!< number of explicitly specified tile rows |
839 | | uint32_t numTileCols; //!< number of tile columns |
840 | | uint32_t numTileRows; //!< number of tile rows |
841 | | |
842 | | std::vector<uint32_t> tileColWidth; //!< tile column widths in units of CTUs |
843 | | std::vector<uint32_t> tileRowHeight; //!< tile row heights in units of CTUs |
844 | | std::vector<uint32_t> tileColBd; //!< tile column left-boundaries in units of CTUs |
845 | | std::vector<uint32_t> tileRowBd; //!< tile row top-boundaries in units of CTUs |
846 | | std::vector<uint32_t> tileColBdRgt; //!< tile column right-boundaries in luma samples |
847 | | std::vector<uint32_t> tileRowBdBot; //!< tile row bottom-boundaries in luma samples |
848 | | std::vector<uint32_t> ctuToTileCol; //!< mapping between CTU horizontal address and tile column index |
849 | | std::vector<uint32_t> ctuToTileRow; //!< mapping between CTU vertical address and tile row index |
850 | | bool rectSlice; //!< rectangular slice flag |
851 | | bool singleSlicePerSubPic; //!< single slice per sub-picture flag |
852 | | std::vector<uint32_t> ctuToSubPicIdx; //!< mapping between CTU and Sub-picture index |
853 | | uint32_t numSlicesInPic; //!< number of rectangular slices in the picture (raster-scan slice specified at slice level) |
854 | | bool tileIdxDeltaPresent; //!< tile index delta present flag |
855 | | |
856 | | std::vector<SliceMap> sliceMap; //!< list of CTU maps for each slice in the picture |
857 | | std::vector<SubPic> subPics; //!< list of subpictures in the picture |
858 | | |
859 | | bool loopFilterAcrossTilesEnabled; //!< loop filtering applied across tiles flag |
860 | | bool loopFilterAcrossSlicesEnabled; //!< loop filtering applied across slices flag |
861 | | |
862 | | bool cabacInitPresent; |
863 | | bool pictureHeaderExtensionPresent; //< picture header extension flags present in picture headers or not |
864 | | |
865 | | bool sliceHeaderExtensionPresent; |
866 | | bool deblockingFilterControlPresent; |
867 | | bool deblockingFilterOverrideEnabled; |
868 | | bool deblockingFilterDisabled; |
869 | | int deblockingFilterBetaOffsetDiv2[MAX_NUM_COMP]; //< beta offset for deblocking filter |
870 | | int deblockingFilterTcOffsetDiv2[MAX_NUM_COMP]; //< tc offset for deblocking filter |
871 | | bool listsModificationPresent; |
872 | | bool rplInfoInPh; |
873 | | bool dbfInfoInPh; |
874 | | bool saoInfoInPh; |
875 | | bool alfInfoInPh; |
876 | | bool wpInfoInPh; |
877 | | bool qpDeltaInfoInPh; |
878 | | bool mixedNaluTypesInPic; |
879 | | uint32_t picWidthInLumaSamples; |
880 | | uint32_t picHeightInLumaSamples; |
881 | | Window conformanceWindow; |
882 | | Window scalingWindow; |
883 | | bool wrapAroundEnabled; //< reference wrap around enabled or not |
884 | | unsigned picWidthMinusWrapAroundOffset; // <pic_width_in_minCbSizeY - wraparound_offset_in_minCbSizeY |
885 | | unsigned wrapAroundOffset; //< reference wrap around offset in luma samples |
886 | | |
887 | | PreCalcValues *pcv; |
888 | | |
889 | | public: |
890 | | |
891 | | PPS(); |
892 | | virtual ~PPS(); |
893 | | uint32_t getSubPicIdxFromSubPicId( uint32_t subPicId ) const; |
894 | | const ChromaQpAdj& getChromaQpOffsetListEntry( int cuChromaQpOffsetIdxPlus1 ) const |
895 | 6.22M | { |
896 | 6.22M | CHECK(cuChromaQpOffsetIdxPlus1 >= chromaQpOffsetListLen+1, "Invalid chroma QP offset"); |
897 | 6.22M | return chromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1]; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise |
898 | 6.22M | } |
899 | | |
900 | | |
901 | | void setChromaQpOffsetListEntry( int cuChromaQpOffsetIdxPlus1, int cbOffset, int crOffset, int jointCbCrOffset ) |
902 | 0 | { |
903 | 0 | CHECK(cuChromaQpOffsetIdxPlus1 == 0 || cuChromaQpOffsetIdxPlus1 > MAX_QP_OFFSET_LIST_SIZE, "Invalid chroma QP offset"); |
904 | 0 | chromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.CbOffset = cbOffset; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise |
905 | 0 | chromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.CrOffset = crOffset; |
906 | 0 | chromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.JointCbCrOffset = jointCbCrOffset; |
907 | 0 | chromaQpOffsetListLen = std::max(chromaQpOffsetListLen, cuChromaQpOffsetIdxPlus1); |
908 | 0 | } |
909 | | |
910 | | |
911 | 0 | bool isRefScaled( const PPS& pps ) const { return picWidthInLumaSamples != pps.picWidthInLumaSamples || |
912 | 0 | picHeightInLumaSamples != pps.picHeightInLumaSamples || |
913 | 0 | scalingWindow != pps.scalingWindow; } |
914 | | |
915 | 16.0M | uint32_t getNumTiles() const { return numTileCols * numTileRows; } |
916 | 183M | uint32_t getTileIdx( uint32_t ctuX, uint32_t ctuY ) const { return (ctuToTileRow[ctuY] * numTileCols) + ctuToTileCol[ctuX]; } |
917 | 5.29k | uint32_t getTileIdx( uint32_t ctuRsAddr ) const { return getTileIdx( ctuRsAddr % picWidthInCtu, ctuRsAddr / picWidthInCtu ); } |
918 | 11.1M | uint32_t getTileIdx( const Position& pos ) const { return getTileIdx( pos.x >> log2CtuSize, pos.y >> log2CtuSize ); } |
919 | 6.00k | uint32_t getTileHeight( const int tileIdx ) const { return tileRowHeight[tileIdx / numTileCols]; } |
920 | 0 | uint32_t getTileWidth( const int tileIdx ) const { return tileColWidth[tileIdx % numTileCols]; } |
921 | | uint32_t getNumTileLineIds() const // number of lines in all the tiles (each tile consisting of indepdent rows |
922 | 6.00k | { |
923 | 6.00k | int countTileRows = 0; |
924 | 12.0k | for( int tileIdx = 0; tileIdx < getNumTiles(); tileIdx++ ) countTileRows += getTileHeight( tileIdx ); |
925 | 6.00k | return countTileRows; |
926 | 6.00k | } |
927 | | uint32_t getTileLineId( uint32_t ctuX, uint32_t ctuY ) const // unique id for a tile line at the given position |
928 | 25.2k | { |
929 | 25.2k | if( numTileCols == 1 ) return ctuY; |
930 | | |
931 | 0 | const int currTileIdx = getTileIdx( ctuX, ctuY ); |
932 | 0 | int tileRowResIdx = 0; |
933 | 0 | for( int tileIdx = 0; tileIdx < currTileIdx; tileIdx++ ) tileRowResIdx += getTileHeight( tileIdx ); |
934 | |
|
935 | 0 | const int tileRowResIdxRest = ctuY - tileRowBd[ctuToTileRow[ctuY]]; |
936 | |
|
937 | 0 | return tileRowResIdx + tileRowResIdxRest; |
938 | 25.2k | } |
939 | 24.9M | bool canFilterCtuBdry( int ctuX, int ctuY, int offX, int offY ) const { return loopFilterAcrossTilesEnabled || getTileIdx( ctuX, ctuY ) == getTileIdx( ctuX + offX, ctuY + offY ); } |
940 | | |
941 | | const SubPic& getSubPicFromPos(const Position& pos) const; |
942 | | const SubPic& getSubPicFromCU (const CodingUnit& cu) const; |
943 | | |
944 | | void initTiles(); |
945 | | void initRectSliceMap( const SPS* sps ); |
946 | | void checkSliceMap(); |
947 | | |
948 | | }; |
949 | | |
950 | | struct APS |
951 | | { |
952 | | uint32_t apsId; // adaptation_parameter_set_id |
953 | | int temporalId; |
954 | | int layerId; |
955 | | uint32_t apsType; // aps_params_type |
956 | | AlfParam alfParam; |
957 | | CcAlfFilterParam ccAlfParam; |
958 | | bool hasPrefixNalUnitType; |
959 | | bool chromaPresent; |
960 | | int poc; |
961 | 0 | APS() : apsId(MAX_UINT), temporalId( 0 ), layerId( 0 ), apsType(0), hasPrefixNalUnitType(false), chromaPresent( false ), poc(-1) |
962 | 0 | { } |
963 | | }; |
964 | | |
965 | | struct WPScalingParam |
966 | | { |
967 | | // Explicit weighted prediction parameters parsed in slice header, |
968 | | // or Implicit weighted prediction parameters (8 bits depth values). |
969 | | bool presentFlag; |
970 | | uint32_t log2WeightDenom; |
971 | | int iWeight; |
972 | | int iOffset; |
973 | | |
974 | | // Weighted prediction scaling values built from above parameters (bitdepth scaled): |
975 | | int w; |
976 | | int o; |
977 | | int offset; |
978 | | int shift; |
979 | | int round; |
980 | | }; |
981 | | |
982 | | struct WPACDCParam |
983 | | { |
984 | | int64_t iAC; |
985 | | int64_t iDC; |
986 | | }; |
987 | | |
988 | | // picture header class |
989 | | struct PicHeader |
990 | | { |
991 | | Picture* pic; //!< pointer to picture structure |
992 | | int pocLsb; //!< least significant bits of picture order count |
993 | | bool nonRefPic; //!< non-reference picture flag |
994 | | bool gdrOrIrapPic; //!< gdr or irap picture flag |
995 | | bool gdrPic; //!< gradual decoding refresh picture flag |
996 | | bool noOutputOfPriorPics; //!< no output of prior pictures flag |
997 | | uint32_t recoveryPocCnt; //!< recovery POC count |
998 | | bool noOutputBeforeRecovery; //!< NoOutputBeforeRecoveryFlag |
999 | | bool handleCraAsCvsStart; //!< HandleCraAsCvsStartFlag |
1000 | | bool handleGdrAsCvsStart; //!< HandleGdrAsCvsStartFlag |
1001 | | int spsId; //!< sequence parameter set ID |
1002 | | int ppsId; //!< picture parameter set ID |
1003 | | bool pocMsbPresent; //!< ph_poc_msb_present_flag |
1004 | | int pocMsbVal; //!< poc_msb_val |
1005 | | bool virtualBoundariesEnabled; //!< loop filtering across virtual boundaries disabled |
1006 | | bool virtualBoundariesPresent; //!< loop filtering across virtual boundaries disabled |
1007 | | unsigned numVerVirtualBoundaries; //!< number of vertical virtual boundaries |
1008 | | unsigned numHorVirtualBoundaries; //!< number of horizontal virtual boundaries |
1009 | | unsigned virtualBoundariesPosX[3]; //!< horizontal virtual boundary positions |
1010 | | unsigned virtualBoundariesPosY[3]; //!< vertical virtual boundary positions |
1011 | | bool picOutputFlag; //!< picture output flag |
1012 | | const ReferencePictureList* pRPL[NUM_REF_PIC_LIST_01]; //!< pointer to RPL for L0, either in the SPS or the local RPS in the picture header |
1013 | | ReferencePictureList localRPL[NUM_REF_PIC_LIST_01]; //!< RPL for L0 when present in picture header |
1014 | | int rplIdx[NUM_REF_PIC_LIST_01]; //!< index of used RPL in the SPS or -1 for local RPL in the picture header |
1015 | | bool picInterSliceAllowed; //!< inter slice allowed flag in PH |
1016 | | bool picIntraSliceAllowed; //!< intra slice allowed flag in PH |
1017 | | bool splitConsOverride; //!< partitioning constraint override flag |
1018 | | uint32_t cuQpDeltaSubdivIntra; //!< CU QP delta maximum subdivision for intra slices |
1019 | | uint32_t cuQpDeltaSubdivInter; //!< CU QP delta maximum subdivision for inter slices |
1020 | | uint32_t cuChromaQpOffsetSubdivIntra; //!< CU chroma QP offset maximum subdivision for intra slices |
1021 | | uint32_t cuChromaQpOffsetSubdivInter; //!< CU chroma QP offset maximum subdivision for inter slices |
1022 | | bool enableTMVP; //!< enable temporal motion vector prediction |
1023 | | bool picColFromL0; //!< syntax element collocated_from_l0_flag |
1024 | | uint32_t colRefIdx; |
1025 | | bool mvdL1Zero; //!< L1 MVD set to zero flag |
1026 | | uint32_t maxNumAffineMergeCand; //!< max number of sub-block merge candidates |
1027 | | bool disFracMMVD; //!< fractional MMVD offsets disabled flag |
1028 | | bool disBdofFlag; //!< picture level BDOF disable flag |
1029 | | bool disDmvrFlag; //!< picture level DMVR disable flag |
1030 | | bool disProfFlag; //!< picture level PROF disable flag |
1031 | | bool jointCbCrSign; //!< joint Cb/Cr residual sign flag |
1032 | | int qpDelta; //!< value of Qp delta |
1033 | | bool saoEnabled[MAX_NUM_CH]; //!< sao enabled flags for each channel |
1034 | | bool alfEnabled[MAX_NUM_COMP]; //!< alf enabled flags for each component |
1035 | | int numAlfAps; //!< number of alf aps active for the picture |
1036 | | std::vector<int> alfApsId; //!< list of alf aps for the picture |
1037 | | int alfChromaApsId; //!< chroma alf aps ID |
1038 | | bool ccalfEnabled[MAX_NUM_COMP]; |
1039 | | int ccalfCbApsId; |
1040 | | int ccalfCrApsId; |
1041 | | bool deblockingFilterOverride; //!< deblocking filter override controls enabled |
1042 | | bool deblockingFilterDisable; //!< deblocking filter disabled flag |
1043 | | int deblockingFilterBetaOffsetDiv2[MAX_NUM_COMP]; //!< beta offset for deblocking filter |
1044 | | int deblockingFilterTcOffsetDiv2[MAX_NUM_COMP]; //!< tc offset for deblocking filter |
1045 | | bool explicitScalingListEnabled; //!< quantization scaling lists present |
1046 | | int scalingListApsId; //!< quantization scaling list APS ID |
1047 | | APS* scalingListAps; //!< quantization scaling list APS |
1048 | | unsigned minQTSize[3]; //!< minimum quad-tree size 0: I slice luma; 1: P/B slice; 2: I slice chroma |
1049 | | unsigned maxMTTDepth[3]; //!< maximum MTT depth |
1050 | | unsigned maxBTSize[3]; //!< maximum BT size |
1051 | | unsigned maxTTSize[3]; //!< maximum TT size |
1052 | | |
1053 | | WPScalingParam weightPredTable[NUM_REF_PIC_LIST_01][MAX_NUM_REF][MAX_NUM_COMP]; // [REF_PIC_LIST_0 or REF_PIC_LIST_1][refIdx][0:Y, 1:U, 2:V] |
1054 | | int numL0Weights; //!< number of weights for L0 list |
1055 | | int numL1Weights; //!< number of weights for L1 list |
1056 | | |
1057 | 1.20k | PicHeader() { initPicHeader(); } |
1058 | | void getWpScaling(RefPicList e, int iRefIdx, WPScalingParam *&wp) const; |
1059 | | |
1060 | | void copyPicInfo( const PicHeader* other, bool cpyAll); |
1061 | | |
1062 | | void initPicHeader() |
1063 | 1.20k | { |
1064 | 1.20k | pic = nullptr; |
1065 | 1.20k | nonRefPic = false; |
1066 | 1.20k | gdrPic = 0; |
1067 | 1.20k | noOutputOfPriorPics = 0; |
1068 | 1.20k | recoveryPocCnt = UINT32_MAX; |
1069 | 1.20k | noOutputBeforeRecovery = false; |
1070 | 1.20k | handleCraAsCvsStart = false; |
1071 | 1.20k | handleGdrAsCvsStart = false; |
1072 | 1.20k | spsId = -1; |
1073 | 1.20k | ppsId = -1; |
1074 | 1.20k | pocMsbPresent = 0; |
1075 | 1.20k | pocMsbVal = 0; |
1076 | 1.20k | virtualBoundariesEnabled = 0; |
1077 | 1.20k | virtualBoundariesPresent = 0; |
1078 | 1.20k | numVerVirtualBoundaries = 0; |
1079 | 1.20k | numHorVirtualBoundaries = 0; |
1080 | 1.20k | picOutputFlag = true; |
1081 | 1.20k | splitConsOverride = false; |
1082 | 1.20k | cuQpDeltaSubdivIntra = 0; |
1083 | 1.20k | cuQpDeltaSubdivInter = 0; |
1084 | 1.20k | cuChromaQpOffsetSubdivIntra = 0; |
1085 | 1.20k | cuChromaQpOffsetSubdivInter = 0; |
1086 | 1.20k | enableTMVP = false; |
1087 | 1.20k | picColFromL0 = true; |
1088 | 1.20k | colRefIdx = 0; |
1089 | 1.20k | mvdL1Zero = 0; |
1090 | 1.20k | maxNumAffineMergeCand = 0; |
1091 | 1.20k | disFracMMVD = 0; |
1092 | 1.20k | disBdofFlag = 0; |
1093 | 1.20k | disDmvrFlag = 0; |
1094 | 1.20k | disProfFlag = 0; |
1095 | 1.20k | jointCbCrSign = 0; |
1096 | 1.20k | qpDelta = 0; |
1097 | 1.20k | numAlfAps = 0; |
1098 | 1.20k | alfChromaApsId = -1; |
1099 | 1.20k | ccalfCbApsId = -1; |
1100 | 1.20k | ccalfCrApsId = -1; |
1101 | 1.20k | deblockingFilterOverride = 0; |
1102 | 1.20k | deblockingFilterDisable = 0; |
1103 | 1.20k | deblockingFilterBetaOffsetDiv2[COMP_Y] = 0; |
1104 | 1.20k | deblockingFilterTcOffsetDiv2[COMP_Y] = 0; |
1105 | 1.20k | deblockingFilterBetaOffsetDiv2[COMP_Cb] = 0; |
1106 | 1.20k | deblockingFilterTcOffsetDiv2[COMP_Cb] = 0; |
1107 | 1.20k | deblockingFilterBetaOffsetDiv2[COMP_Cr] = 0; |
1108 | 1.20k | deblockingFilterTcOffsetDiv2[COMP_Cr] = 0; |
1109 | 1.20k | explicitScalingListEnabled = 0; |
1110 | 1.20k | scalingListApsId = -1; |
1111 | 1.20k | scalingListAps = nullptr; |
1112 | 1.20k | numL0Weights = 0; |
1113 | 1.20k | numL1Weights = 0; |
1114 | | |
1115 | 3.60k | for( int i = 0; i < 2; i++) |
1116 | 2.40k | { |
1117 | 2.40k | pRPL[i] = nullptr; |
1118 | 2.40k | rplIdx[i] = 0; |
1119 | | |
1120 | 2.40k | localRPL[i].numberOfActivePictures = (0); |
1121 | 2.40k | localRPL[i].numberOfShorttermPictures = (0); |
1122 | 2.40k | localRPL[i].numberOfLongtermPictures = (0); |
1123 | 2.40k | localRPL[i].ltrpInSliceHeader = false; |
1124 | 2.40k | } |
1125 | | |
1126 | 1.20k | alfApsId.resize(0); |
1127 | | |
1128 | 1.20k | memset(virtualBoundariesPosX, 0, sizeof(virtualBoundariesPosX)); |
1129 | 1.20k | memset(virtualBoundariesPosY, 0, sizeof(virtualBoundariesPosY)); |
1130 | 1.20k | memset(saoEnabled, 0, sizeof(saoEnabled)); |
1131 | 1.20k | memset(alfEnabled, 0, sizeof(alfEnabled)); |
1132 | 1.20k | memset(ccalfEnabled, 0, sizeof(ccalfEnabled)); |
1133 | | |
1134 | 1.20k | memset(minQTSize, 0, sizeof(minQTSize)); |
1135 | 1.20k | memset(maxMTTDepth, 0, sizeof(maxMTTDepth)); |
1136 | 1.20k | memset(maxBTSize, 0, sizeof(maxBTSize)); |
1137 | 1.20k | memset(maxTTSize, 0, sizeof(maxTTSize)); |
1138 | 1.20k | } |
1139 | | |
1140 | | }; |
1141 | | |
1142 | | /// slice header class |
1143 | | class Slice |
1144 | | { |
1145 | | |
1146 | | public: |
1147 | | // Bitstream writing |
1148 | | bool saoEnabled[MAX_NUM_CH]; |
1149 | | int ppsId; ///< picture parameter set ID |
1150 | | int poc; |
1151 | | int lastIDR; |
1152 | | int prevGDRInSameLayerPOC; //< the previous GDR in the same layer |
1153 | | int associatedIRAP; |
1154 | | vvencNalUnitType associatedIRAPType; |
1155 | | bool enableDRAPSEI; |
1156 | | bool useLTforDRAP; |
1157 | | bool isDRAP; |
1158 | | int latestDRAPPOC; |
1159 | | |
1160 | | const ReferencePictureList* rpl[NUM_REF_PIC_LIST_01]; //< pointer to RPL for L0, either in the SPS or the local RPS in the same slice header |
1161 | | ReferencePictureList rplLocal[NUM_REF_PIC_LIST_01]; //< RPL for L0 when present in slice header |
1162 | | int rplIdx[NUM_REF_PIC_LIST_01]; //< index of used RPL in the SPS or -1 for local RPL in the slice header |
1163 | | int colourPlaneId; //!< 4:4:4 colour plane ID |
1164 | | bool pictureHeaderInSliceHeader; |
1165 | | uint32_t nuhLayerId; |
1166 | | vvencNalUnitType nalUnitType; ///< Nal unit type for the slice |
1167 | | SliceType sliceType; |
1168 | | int sliceQp; |
1169 | | bool chromaQpAdjEnabled; |
1170 | | bool explicitScalingListUsed; |
1171 | | bool deblockingFilterDisable; |
1172 | | bool deblockingFilterOverride; //< offsets for deblocking filter inherit from PPS |
1173 | | int deblockingFilterBetaOffsetDiv2[MAX_NUM_COMP]; //< beta offset for deblocking filter |
1174 | | int deblockingFilterTcOffsetDiv2[MAX_NUM_COMP]; //< tc offset for deblocking filter |
1175 | | bool depQuantEnabled; //!< dependent quantization enabled flag |
1176 | | bool signDataHidingEnabled; //!< sign data hiding enabled flag |
1177 | | bool tsResidualCodingDisabled; |
1178 | | int list1IdxToList0Idx[MAX_NUM_REF]; |
1179 | | int numRefIdx [NUM_REF_PIC_LIST_01]; // for multiple reference of current slice |
1180 | | bool pendingRasInit; |
1181 | | bool checkLDC; |
1182 | | bool biDirPred; |
1183 | | bool lmChromaCheckDisable; |
1184 | | int symRefIdx[2]; |
1185 | | |
1186 | | // Data |
1187 | | int sliceChromaQpDelta[MAX_NUM_COMP+1]; |
1188 | | Picture* refPicList [NUM_REF_PIC_LIST_01][MAX_NUM_REF+1]; |
1189 | | int refPOCList [NUM_REF_PIC_LIST_01][MAX_NUM_REF+1]; |
1190 | | bool isUsedAsLongTerm[NUM_REF_PIC_LIST_01][MAX_NUM_REF+1]; |
1191 | | |
1192 | | // access channel |
1193 | | const VPS* vps; |
1194 | | const DCI* dci; |
1195 | | const SPS* sps; |
1196 | | const PPS* pps; |
1197 | | Picture* pic; |
1198 | | PicHeader* picHeader; //!< pointer to picture header structure |
1199 | | bool colFromL0Flag; // collocated picture from List0 flag |
1200 | | uint32_t colRefIdx; |
1201 | | double lambdas[MAX_NUM_COMP]; |
1202 | | uint32_t TLayer; |
1203 | | bool TLayerSwitchingFlag; |
1204 | | SliceMap sliceMap; |
1205 | | uint32_t independentSliceIdx; |
1206 | | WPScalingParam weightPredTable[NUM_REF_PIC_LIST_01][MAX_NUM_REF][MAX_NUM_COMP]; |
1207 | | WPACDCParam weightACDCParam[MAX_NUM_COMP]; |
1208 | | ClpRngs clpRngs; |
1209 | | std::vector<uint32_t> substreamSizes; |
1210 | | bool cabacInitFlag; |
1211 | | uint32_t sliceSubPicId; |
1212 | | SliceType encCABACTableIdx; // Used to transmit table selection across slices. |
1213 | | APS* alfAps[ALF_CTB_MAX_NUM_APS]; |
1214 | | bool alfEnabled[MAX_NUM_COMP]; |
1215 | | int numAps; |
1216 | | std::vector<int> lumaApsId; |
1217 | | int chromaApsId; |
1218 | | bool ccAlfCbEnabled; |
1219 | | bool ccAlfCrEnabled; |
1220 | | int ccAlfCbApsId; |
1221 | | int ccAlfCrApsId; |
1222 | | |
1223 | | bool isLossless; |
1224 | | CcAlfFilterParam ccAlfFilterParam; |
1225 | | uint8_t* ccAlfFilterControl[2]; |
1226 | | |
1227 | | public: |
1228 | | Slice(); |
1229 | | virtual ~Slice(); |
1230 | | void resetSlicePart(); |
1231 | | void constructRefPicList(const PicList& rcListPic, bool extBorder, const bool usingLongTerm = true); |
1232 | | void updateRefPicCounter( int step ); |
1233 | | bool checkAllRefPicsAccessible() const; |
1234 | | bool checkAllRefPicsReconstructed() const; |
1235 | | void setRefPOCList(); |
1236 | | void setSMVDParam(); |
1237 | | void checkColRefIdx(uint32_t curSliceSegmentIdx, const Picture* pic) const; |
1238 | 0 | void setAlfAPSs(APS** apss) { memcpy(alfAps, apss, sizeof(alfAps)); } |
1239 | | |
1240 | 2.40k | const Picture* getRefPic( RefPicList e, int iRefIdx) const { return refPicList[e][iRefIdx]; } |
1241 | 0 | int getRefPOC( RefPicList e, int iRefIdx) const { return refPOCList[e][iRefIdx]; } |
1242 | | int getNumEntryPoints(const SPS& sps, const PPS& pps) const; |
1243 | | |
1244 | | bool getRapPicFlag() const; |
1245 | 1.20k | bool getIdrPicFlag() const { return nalUnitType == VVENC_NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalUnitType == VVENC_NAL_UNIT_CODED_SLICE_IDR_N_LP; } |
1246 | 112k | bool isIRAP() const { return (nalUnitType >= VVENC_NAL_UNIT_CODED_SLICE_IDR_W_RADL) && (nalUnitType <= VVENC_NAL_UNIT_CODED_SLICE_CRA); } |
1247 | 3.60k | bool isIDRorBLA() const { return (nalUnitType == VVENC_NAL_UNIT_CODED_SLICE_IDR_W_RADL) || (nalUnitType == VVENC_NAL_UNIT_CODED_SLICE_IDR_N_LP); } |
1248 | | void checkCRA(const ReferencePictureList* pRPL0, const ReferencePictureList* pRPL1, int& pocCRA, vvencNalUnitType& associatedIRAPType, PicList& rcListPic); |
1249 | | void setDecodingRefreshMarking(int& pocCRA, bool& bRefreshPending, const PicList& rcListPic); |
1250 | | |
1251 | 14.7M | bool isIntra() const { return sliceType == VVENC_I_SLICE; } |
1252 | 2.40k | bool isInterB() const { return sliceType == VVENC_B_SLICE; } |
1253 | 1.20k | bool isInterP() const { return sliceType == VVENC_P_SLICE; } |
1254 | | |
1255 | 19.2k | void setLambdas( const double lambdas_[MAX_NUM_COMP] ) { for (int component = 0; component < MAX_NUM_COMP; component++) lambdas[component] = lambdas_[component]; } |
1256 | 14.1k | const double* getLambdas() const { return lambdas; } |
1257 | | |
1258 | | static void sortPicList( PicList& rcListPic ); |
1259 | | void setList1IdxToList0Idx(); |
1260 | | |
1261 | | void copySliceInfo( const Slice* slice, bool cpyAlmostAll = true); |
1262 | | |
1263 | | void checkLeadingPictureRestrictions( const PicList& rcListPic ) const; |
1264 | | void applyReferencePictureListBasedMarking( const PicList& rcListPic, const ReferencePictureList* pRPL0, const ReferencePictureList* pRPL1, const int layerId, const PPS& pps, const bool usingLongTerm = true ) const; |
1265 | | bool isStepwiseTemporalLayerSwitchingPointCandidate( const PicList& rcListPic ) const; |
1266 | | bool isRplPicMissing( const PicList& rcListPic, const RefPicList refList, int& missingPoc, int ip ) const; |
1267 | | void createExplicitReferencePictureSetFromReference( const PicList& rcListPic, const ReferencePictureList* pRPL0, const ReferencePictureList* pRPL1, int ip ); |
1268 | | void getWpScaling( RefPicList e, int iRefIdx, WPScalingParam *&wp) const; |
1269 | | |
1270 | | void resetWpScaling(); |
1271 | | |
1272 | 1.20k | void clearSubstreamSizes( ) { return substreamSizes.clear(); } |
1273 | 2.40k | uint32_t getNumberOfSubstreamSizes( ) { return (uint32_t) substreamSizes.size(); } |
1274 | 0 | void addSubstreamSize( uint32_t size ) { substreamSizes.push_back(size); } |
1275 | 0 | uint32_t getSubstreamSize( uint32_t idx ) { CHECK(idx>=getNumberOfSubstreamSizes(),"Invalid index"); return substreamSizes[idx]; } |
1276 | | |
1277 | | void setDefaultClpRng( const SPS& sps ); |
1278 | | unsigned getMinPictureDistance() const ; |
1279 | | |
1280 | | bool isPocRestrictedByDRAP( int poc, bool precedingDRAPInDecodingOrder ) const; |
1281 | | bool refPicIsFutureIDRnoLP( int candPoc, int ipc ) const; |
1282 | | |
1283 | | void setAlfApsIds( const std::vector<int>& ApsIDs); |
1284 | | private: |
1285 | | Picture* xGetLongTermRefPic(const PicList& rcListPic, int poc, bool pocHasMsb); |
1286 | | };// END CLASS DEFINITION Slice |
1287 | | |
1288 | | void calculateParameterSetChangedFlag(bool& bChanged, const std::vector<uint8_t>* pOldData, const std::vector<uint8_t>* pNewData); |
1289 | | |
1290 | | template <class T> class ParameterSetMap |
1291 | | { |
1292 | | public: |
1293 | | template <class Tm> |
1294 | | struct MapData |
1295 | | { |
1296 | | bool bChanged; |
1297 | | std::vector<uint8_t>* pNaluData; |
1298 | | Tm* parameterSet; |
1299 | | }; |
1300 | | |
1301 | | |
1302 | | private: |
1303 | | std::map<int,MapData<T> > m_paramsetMap; |
1304 | | int m_maxId; |
1305 | | std::vector<int> m_activePsId; |
1306 | | T* m_lastActiveParameterSet; |
1307 | | int m_apsIdStart; |
1308 | | |
1309 | | public: |
1310 | | ParameterSetMap() |
1311 | | : m_maxId ( MAX_NUM_APS * MAX_NUM_APS_TYPE ) |
1312 | | , m_activePsId () |
1313 | | , m_lastActiveParameterSet( nullptr ) |
1314 | | , m_apsIdStart ( ALF_CTB_MAX_NUM_APS ) |
1315 | | { |
1316 | | } |
1317 | | |
1318 | | ParameterSetMap( int maxId ) |
1319 | 7.20k | : m_maxId ( maxId ) |
1320 | 7.20k | , m_activePsId () |
1321 | 7.20k | , m_lastActiveParameterSet( nullptr ) |
1322 | 7.20k | , m_apsIdStart ( ALF_CTB_MAX_NUM_APS ) |
1323 | 7.20k | { |
1324 | 7.20k | } vvenc::ParameterSetMap<vvenc::APS>::ParameterSetMap(int) Line | Count | Source | 1319 | 4.80k | : m_maxId ( maxId ) | 1320 | 4.80k | , m_activePsId () | 1321 | 4.80k | , m_lastActiveParameterSet( nullptr ) | 1322 | 4.80k | , m_apsIdStart ( ALF_CTB_MAX_NUM_APS ) | 1323 | 4.80k | { | 1324 | 4.80k | } |
vvenc::ParameterSetMap<vvenc::SPS>::ParameterSetMap(int) Line | Count | Source | 1319 | 1.20k | : m_maxId ( maxId ) | 1320 | 1.20k | , m_activePsId () | 1321 | 1.20k | , m_lastActiveParameterSet( nullptr ) | 1322 | 1.20k | , m_apsIdStart ( ALF_CTB_MAX_NUM_APS ) | 1323 | 1.20k | { | 1324 | 1.20k | } |
vvenc::ParameterSetMap<vvenc::PPS>::ParameterSetMap(int) Line | Count | Source | 1319 | 1.20k | : m_maxId ( maxId ) | 1320 | 1.20k | , m_activePsId () | 1321 | 1.20k | , m_lastActiveParameterSet( nullptr ) | 1322 | 1.20k | , m_apsIdStart ( ALF_CTB_MAX_NUM_APS ) | 1323 | 1.20k | { | 1324 | 1.20k | } |
Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::DCI>::ParameterSetMap(int) Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::VPS>::ParameterSetMap(int) |
1325 | | |
1326 | | ~ParameterSetMap() |
1327 | 7.20k | { |
1328 | 7.20k | clearMap(); |
1329 | 7.20k | } vvenc::ParameterSetMap<vvenc::APS>::~ParameterSetMap() Line | Count | Source | 1327 | 4.80k | { | 1328 | 4.80k | clearMap(); | 1329 | 4.80k | } |
vvenc::ParameterSetMap<vvenc::SPS>::~ParameterSetMap() Line | Count | Source | 1327 | 1.20k | { | 1328 | 1.20k | clearMap(); | 1329 | 1.20k | } |
vvenc::ParameterSetMap<vvenc::PPS>::~ParameterSetMap() Line | Count | Source | 1327 | 1.20k | { | 1328 | 1.20k | clearMap(); | 1329 | 1.20k | } |
Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::DCI>::~ParameterSetMap() Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::VPS>::~ParameterSetMap() |
1330 | | |
1331 | | T *allocatePS( const int psId ) |
1332 | 2.40k | { |
1333 | 2.40k | CHECK( psId >= m_maxId, "Invalid PS id" ); |
1334 | 2.40k | if ( m_paramsetMap.find(psId) == m_paramsetMap.end() ) |
1335 | 2.40k | { |
1336 | 2.40k | m_paramsetMap[psId].bChanged = true; |
1337 | 2.40k | m_paramsetMap[psId].pNaluData = nullptr; |
1338 | 2.40k | m_paramsetMap[psId].parameterSet = new T; |
1339 | 2.40k | setID( m_paramsetMap[ psId ].parameterSet, psId ); |
1340 | 2.40k | } |
1341 | 2.40k | return m_paramsetMap[ psId ].parameterSet; |
1342 | 2.40k | } vvenc::ParameterSetMap<vvenc::SPS>::allocatePS(int) Line | Count | Source | 1332 | 1.20k | { | 1333 | 1.20k | CHECK( psId >= m_maxId, "Invalid PS id" ); | 1334 | 1.20k | if ( m_paramsetMap.find(psId) == m_paramsetMap.end() ) | 1335 | 1.20k | { | 1336 | 1.20k | m_paramsetMap[psId].bChanged = true; | 1337 | 1.20k | m_paramsetMap[psId].pNaluData = nullptr; | 1338 | 1.20k | m_paramsetMap[psId].parameterSet = new T; | 1339 | 1.20k | setID( m_paramsetMap[ psId ].parameterSet, psId ); | 1340 | 1.20k | } | 1341 | 1.20k | return m_paramsetMap[ psId ].parameterSet; | 1342 | 1.20k | } |
vvenc::ParameterSetMap<vvenc::PPS>::allocatePS(int) Line | Count | Source | 1332 | 1.20k | { | 1333 | 1.20k | CHECK( psId >= m_maxId, "Invalid PS id" ); | 1334 | 1.20k | if ( m_paramsetMap.find(psId) == m_paramsetMap.end() ) | 1335 | 1.20k | { | 1336 | 1.20k | m_paramsetMap[psId].bChanged = true; | 1337 | 1.20k | m_paramsetMap[psId].pNaluData = nullptr; | 1338 | 1.20k | m_paramsetMap[psId].parameterSet = new T; | 1339 | 1.20k | setID( m_paramsetMap[ psId ].parameterSet, psId ); | 1340 | 1.20k | } | 1341 | 1.20k | return m_paramsetMap[ psId ].parameterSet; | 1342 | 1.20k | } |
Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::APS>::allocatePS(int) |
1343 | | |
1344 | | void clearMap() |
1345 | 9.60k | { |
1346 | 12.0k | for( typename std::map<int,MapData<T> >::iterator i = m_paramsetMap.begin(); i != m_paramsetMap.end(); i++ ) |
1347 | 2.40k | { |
1348 | 2.40k | delete (*i).second.pNaluData; |
1349 | 2.40k | delete (*i).second.parameterSet; |
1350 | 2.40k | } |
1351 | 9.60k | delete m_lastActiveParameterSet; m_lastActiveParameterSet = nullptr; |
1352 | 9.60k | m_paramsetMap.clear(); |
1353 | 9.60k | m_activePsId.clear(); |
1354 | 9.60k | } vvenc::ParameterSetMap<vvenc::APS>::clearMap() Line | Count | Source | 1345 | 4.80k | { | 1346 | 4.80k | for( typename std::map<int,MapData<T> >::iterator i = m_paramsetMap.begin(); i != m_paramsetMap.end(); i++ ) | 1347 | 0 | { | 1348 | 0 | delete (*i).second.pNaluData; | 1349 | 0 | delete (*i).second.parameterSet; | 1350 | 0 | } | 1351 | 4.80k | delete m_lastActiveParameterSet; m_lastActiveParameterSet = nullptr; | 1352 | 4.80k | m_paramsetMap.clear(); | 1353 | 4.80k | m_activePsId.clear(); | 1354 | 4.80k | } |
vvenc::ParameterSetMap<vvenc::SPS>::clearMap() Line | Count | Source | 1345 | 2.40k | { | 1346 | 3.60k | for( typename std::map<int,MapData<T> >::iterator i = m_paramsetMap.begin(); i != m_paramsetMap.end(); i++ ) | 1347 | 1.20k | { | 1348 | 1.20k | delete (*i).second.pNaluData; | 1349 | 1.20k | delete (*i).second.parameterSet; | 1350 | 1.20k | } | 1351 | 2.40k | delete m_lastActiveParameterSet; m_lastActiveParameterSet = nullptr; | 1352 | 2.40k | m_paramsetMap.clear(); | 1353 | 2.40k | m_activePsId.clear(); | 1354 | 2.40k | } |
vvenc::ParameterSetMap<vvenc::PPS>::clearMap() Line | Count | Source | 1345 | 2.40k | { | 1346 | 3.60k | for( typename std::map<int,MapData<T> >::iterator i = m_paramsetMap.begin(); i != m_paramsetMap.end(); i++ ) | 1347 | 1.20k | { | 1348 | 1.20k | delete (*i).second.pNaluData; | 1349 | 1.20k | delete (*i).second.parameterSet; | 1350 | 1.20k | } | 1351 | 2.40k | delete m_lastActiveParameterSet; m_lastActiveParameterSet = nullptr; | 1352 | 2.40k | m_paramsetMap.clear(); | 1353 | 2.40k | m_activePsId.clear(); | 1354 | 2.40k | } |
Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::DCI>::clearMap() Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::VPS>::clearMap() |
1355 | | |
1356 | | void storePS( int psId, T *ps ) |
1357 | | { |
1358 | | CHECK( psId >= m_maxId, "Invalid PS id" ); |
1359 | | if( m_paramsetMap.find( psId ) != m_paramsetMap.end() ) |
1360 | | { |
1361 | | delete m_paramsetMap[psId].parameterSet; |
1362 | | } |
1363 | | m_paramsetMap[psId].parameterSet = ps; |
1364 | | m_paramsetMap[psId].bChanged = true; |
1365 | | } |
1366 | | |
1367 | | void storePS(int psId, T *ps, const std::vector<uint8_t> *pNaluData) |
1368 | 0 | { |
1369 | 0 | CHECK( psId >= m_maxId, "Invalid PS id" ); |
1370 | 0 | if ( m_paramsetMap.find(psId) != m_paramsetMap.end() ) |
1371 | 0 | { |
1372 | 0 | MapData<T> &mapData=m_paramsetMap[psId]; |
1373 | 0 |
|
1374 | 0 | // work out changed flag |
1375 | 0 | calculateParameterSetChangedFlag(mapData.bChanged, mapData.pNaluData, pNaluData); |
1376 | 0 |
|
1377 | 0 | if( ! mapData.bChanged ) |
1378 | 0 | { |
1379 | 0 | // just keep the old one |
1380 | 0 | delete ps; |
1381 | 0 | return; |
1382 | 0 | } |
1383 | 0 |
|
1384 | 0 | if (find(m_activePsId.begin(), m_activePsId.end(), psId) != m_activePsId.end()) |
1385 | 0 | { |
1386 | 0 | std::swap( m_paramsetMap[psId].parameterSet, m_lastActiveParameterSet ); |
1387 | 0 | } |
1388 | 0 | delete m_paramsetMap[psId].pNaluData; |
1389 | 0 | delete m_paramsetMap[psId].parameterSet; |
1390 | 0 |
|
1391 | 0 | m_paramsetMap[psId].parameterSet = ps; |
1392 | 0 | } |
1393 | 0 | else |
1394 | 0 | { |
1395 | 0 | m_paramsetMap[psId].parameterSet = ps; |
1396 | 0 | m_paramsetMap[psId].bChanged = false; |
1397 | 0 | } |
1398 | 0 | if (pNaluData != 0) |
1399 | 0 | { |
1400 | 0 | m_paramsetMap[psId].pNaluData=new std::vector<uint8_t>; |
1401 | 0 | *(m_paramsetMap[psId].pNaluData) = *pNaluData; |
1402 | 0 | } |
1403 | 0 | else |
1404 | 0 | { |
1405 | 0 | m_paramsetMap[psId].pNaluData=0; |
1406 | 0 | } |
1407 | 0 | } Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::VPS>::storePS(int, vvenc::VPS*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const*) Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::DCI>::storePS(int, vvenc::DCI*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const*) Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::SPS>::storePS(int, vvenc::SPS*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const*) Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::PPS>::storePS(int, vvenc::PPS*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const*) Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::APS>::storePS(int, vvenc::APS*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const*) |
1408 | | |
1409 | | void setChangedFlag(int psId, bool bChanged=true) |
1410 | 0 | { |
1411 | 0 | if ( m_paramsetMap.find(psId) != m_paramsetMap.end() ) |
1412 | 0 | { |
1413 | 0 | m_paramsetMap[psId].bChanged=bChanged; |
1414 | 0 | } |
1415 | 0 | } |
1416 | | |
1417 | | void clearChangedFlag(int psId) |
1418 | 9.60k | { |
1419 | 9.60k | if ( m_paramsetMap.find(psId) != m_paramsetMap.end() ) |
1420 | 0 | { |
1421 | 0 | m_paramsetMap[psId].bChanged=false; |
1422 | 0 | } |
1423 | 9.60k | } Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::SPS>::clearChangedFlag(int) Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::PPS>::clearChangedFlag(int) vvenc::ParameterSetMap<vvenc::APS>::clearChangedFlag(int) Line | Count | Source | 1418 | 9.60k | { | 1419 | 9.60k | if ( m_paramsetMap.find(psId) != m_paramsetMap.end() ) | 1420 | 0 | { | 1421 | 0 | m_paramsetMap[psId].bChanged=false; | 1422 | 0 | } | 1423 | 9.60k | } |
|
1424 | | |
1425 | | bool getChangedFlag(int psId) const |
1426 | 0 | { |
1427 | 0 | const typename std::map<int,MapData<T> >::const_iterator constit=m_paramsetMap.find(psId); |
1428 | 0 | if ( constit != m_paramsetMap.end() ) |
1429 | 0 | { |
1430 | 0 | return constit->second.bChanged; |
1431 | 0 | } |
1432 | 0 | return false; |
1433 | 0 | } Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::SPS>::getChangedFlag(int) const Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::PPS>::getChangedFlag(int) const Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::APS>::getChangedFlag(int) const |
1434 | | |
1435 | | T* getPS(int psId) |
1436 | 21.6k | { |
1437 | 21.6k | typename std::map<int,MapData<T> >::iterator it=m_paramsetMap.find(psId); |
1438 | 21.6k | return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet; |
1439 | 21.6k | } Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::VPS>::getPS(int) vvenc::ParameterSetMap<vvenc::SPS>::getPS(int) Line | Count | Source | 1436 | 2.40k | { | 1437 | 2.40k | typename std::map<int,MapData<T> >::iterator it=m_paramsetMap.find(psId); | 1438 | 2.40k | return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet; | 1439 | 2.40k | } |
Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::PPS>::getPS(int) vvenc::ParameterSetMap<vvenc::APS>::getPS(int) Line | Count | Source | 1436 | 19.2k | { | 1437 | 19.2k | typename std::map<int,MapData<T> >::iterator it=m_paramsetMap.find(psId); | 1438 | 19.2k | return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet; | 1439 | 19.2k | } |
Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::DCI>::getPS(int) |
1440 | | |
1441 | | const T* getPS(int psId) const |
1442 | 9.60k | { |
1443 | 9.60k | typename std::map<int,MapData<T> >::const_iterator it=m_paramsetMap.find(psId); |
1444 | 9.60k | return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet; |
1445 | 9.60k | } Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::VPS>::getPS(int) const Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::SPS>::getPS(int) const Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::DCI>::getPS(int) const vvenc::ParameterSetMap<vvenc::APS>::getPS(int) const Line | Count | Source | 1442 | 9.60k | { | 1443 | 9.60k | typename std::map<int,MapData<T> >::const_iterator it=m_paramsetMap.find(psId); | 1444 | 9.60k | return ( it == m_paramsetMap.end() ) ? NULL : (it)->second.parameterSet; | 1445 | 9.60k | } |
|
1446 | | |
1447 | | T* getFirstPS() |
1448 | 3.60k | { |
1449 | 3.60k | return (m_paramsetMap.begin() == m_paramsetMap.end() ) ? NULL : m_paramsetMap.begin()->second.parameterSet; |
1450 | 3.60k | } Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::SPS>::getFirstPS() vvenc::ParameterSetMap<vvenc::PPS>::getFirstPS() Line | Count | Source | 1448 | 3.60k | { | 1449 | 3.60k | return (m_paramsetMap.begin() == m_paramsetMap.end() ) ? NULL : m_paramsetMap.begin()->second.parameterSet; | 1450 | 3.60k | } |
|
1451 | | |
1452 | 0 | void setActive(int psId) { m_activePsId.push_back(psId); }Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::DCI>::setActive(int) Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::SPS>::setActive(int) Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::PPS>::setActive(int) Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::APS>::setActive(int) |
1453 | 2.40k | void clearActive() { m_activePsId.clear(); m_apsIdStart = ALF_CTB_MAX_NUM_APS; }Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::SPS>::clearActive() Unexecuted instantiation: vvenc::ParameterSetMap<vvenc::PPS>::clearActive() vvenc::ParameterSetMap<vvenc::APS>::clearActive() Line | Count | Source | 1453 | 2.40k | void clearActive() { m_activePsId.clear(); m_apsIdStart = ALF_CTB_MAX_NUM_APS; } |
|
1454 | 1.20k | int getApsIdStart() { return m_apsIdStart; } |
1455 | 1.20k | const int getApsIdStart() const { return m_apsIdStart; } |
1456 | 3.60k | void setApsIdStart( const int id ) { m_apsIdStart = id; } |
1457 | | // void reset() |
1458 | | // { |
1459 | | // m_apsIdStart = m_apsIdStart = ALF_CTB_MAX_NUM_APS; |
1460 | | // for( typename std::map<int,MapData<T> >::iterator i = m_paramsetMap.begin(); i != m_paramsetMap.end(); i++ ) |
1461 | | // { |
1462 | | // (*i).second.bChanged = false; |
1463 | | // } |
1464 | | // } |
1465 | | |
1466 | | private: |
1467 | | static void setID(T* parameterSet, const int psId); |
1468 | | }; |
1469 | | |
1470 | | class ParameterSetManager |
1471 | | { |
1472 | | public: |
1473 | | enum PPSErrCodes |
1474 | | { |
1475 | | PPS_OK = 0, |
1476 | | PPS_ERR_INACTIVE_SPS = -1, |
1477 | | PPS_ERR_NO_SPS = -2, |
1478 | | PPS_ERR_NO_PPS = -3, |
1479 | | PPS_WARN_DCI_ID = 1, |
1480 | | PPS_WARN_NO_DCI = 2, |
1481 | | }; |
1482 | | |
1483 | | public: |
1484 | | ParameterSetManager(); |
1485 | | virtual ~ParameterSetManager(); |
1486 | 0 | void storeVPS(VPS *vps, const std::vector<uint8_t> &naluData) { m_vpsMap.storePS(vps->vpsId, vps, &naluData); } |
1487 | 0 | VPS* getVPS( int vpsId ) { return m_vpsMap.getPS( vpsId ); }; |
1488 | | |
1489 | 0 | void storeDCI(DCI *dci, const std::vector<uint8_t> &naluData) { m_dciMap.storePS( dci->dciId, dci, &naluData); }; |
1490 | | //DCI* getDCI(int dciId) { return m_dciMap.getPS(dciId); }; |
1491 | | |
1492 | 0 | void storeSPS(SPS *sps, const std::vector<uint8_t> &naluData) { m_spsMap.storePS( sps->spsId, sps, &naluData); }; |
1493 | 0 | SPS* getSPS(int spsId) { return m_spsMap.getPS(spsId); }; |
1494 | 0 | bool getSPSChangedFlag(int spsId) const { return m_spsMap.getChangedFlag(spsId); } |
1495 | 0 | void clearSPSChangedFlag(int spsId) { m_spsMap.clearChangedFlag(spsId); } |
1496 | 0 | SPS* getFirstSPS() { return m_spsMap.getFirstPS(); }; |
1497 | | |
1498 | 0 | void storePPS(PPS *pps, const std::vector<uint8_t> &naluData) { m_ppsMap.storePS( pps->ppsId, pps, &naluData); }; |
1499 | 0 | PPS* getPPS(int ppsId) { return m_ppsMap.getPS(ppsId); }; |
1500 | 0 | bool getPPSChangedFlag(int ppsId) const { return m_ppsMap.getChangedFlag(ppsId); } |
1501 | 0 | void clearPPSChangedFlag(int ppsId) { m_ppsMap.clearChangedFlag(ppsId); } |
1502 | 0 | PPS* getFirstPPS() { return m_ppsMap.getFirstPS(); }; |
1503 | | |
1504 | | PPSErrCodes activatePPS(int ppsId, bool isIRAP); |
1505 | 0 | APS** getAPSs() { return &m_apss[0]; } |
1506 | 0 | ParameterSetMap<APS>* getApsMap() { return &m_apsMap; } |
1507 | 0 | void storeAPS(APS *aps, const std::vector<uint8_t> &naluData) { m_apsMap.storePS((aps->apsId << NUM_APS_TYPE_LEN) + aps->apsType, aps, &naluData); }; |
1508 | 0 | APS* getAPS(int apsId, int apsType) { return m_apsMap.getPS((apsId << NUM_APS_TYPE_LEN) + apsType); }; |
1509 | 0 | bool getAPSChangedFlag(int apsId, int apsType) const { return m_apsMap.getChangedFlag((apsId << NUM_APS_TYPE_LEN) + apsType); } |
1510 | 0 | void clearAPSChangedFlag(int apsId, int apsType) { m_apsMap.clearChangedFlag((apsId << NUM_APS_TYPE_LEN) + apsType); } |
1511 | | bool activateAPS(int apsId, int apsType); |
1512 | 0 | const VPS* getActiveVPS()const { return m_vpsMap.getPS(m_activeVPSId); }; |
1513 | 0 | const SPS* getActiveSPS()const { return m_spsMap.getPS(m_activeSPSId); }; |
1514 | 0 | const DCI* getActiveDCI()const { return m_dciMap.getPS(m_activeDCIId); }; |
1515 | | |
1516 | | protected: |
1517 | | ParameterSetMap<SPS> m_spsMap; |
1518 | | ParameterSetMap<PPS> m_ppsMap; |
1519 | | ParameterSetMap<APS> m_apsMap; |
1520 | | ParameterSetMap<DCI> m_dciMap; |
1521 | | ParameterSetMap<VPS> m_vpsMap; |
1522 | | |
1523 | | APS* m_apss[ALF_CTB_MAX_NUM_APS]; |
1524 | | |
1525 | | int m_activeDCIId; // -1 for nothing active |
1526 | | int m_activeSPSId; // -1 for nothing active |
1527 | | int m_activeVPSId; // -1 for nothing active |
1528 | | }; |
1529 | | |
1530 | | class PreCalcValues |
1531 | | { |
1532 | | public: |
1533 | | PreCalcValues( const SPS& sps, const PPS& pps, const unsigned _maxQtSize[3] ) |
1534 | 1.20k | : chrFormat ( sps.chromaFormatIdc ) |
1535 | 1.20k | , maxCUSize ( sps.CTUSize ) |
1536 | 1.20k | , maxCUSizeMask ( maxCUSize - 1 ) |
1537 | 1.20k | , maxCUSizeLog2 ( Log2( maxCUSize ) ) |
1538 | 1.20k | , minCUSize ( 1 << MIN_CU_LOG2 ) |
1539 | 1.20k | , minCUSizeLog2 ( MIN_CU_LOG2 ) |
1540 | 1.20k | , partsInCtuWidth ( maxCUSize >> MIN_CU_LOG2 ) |
1541 | 1.20k | , partsInCtu ( partsInCtuWidth*partsInCtuWidth ) |
1542 | 1.20k | , widthInCtus ( (pps.picWidthInLumaSamples + sps.CTUSize - 1) / sps.CTUSize ) |
1543 | 1.20k | , heightInCtus ( (pps.picHeightInLumaSamples + sps.CTUSize - 1) / sps.CTUSize ) |
1544 | 1.20k | , sizeInCtus ( widthInCtus * heightInCtus ) |
1545 | 1.20k | , lumaWidth ( pps.picWidthInLumaSamples ) |
1546 | 1.20k | , lumaHeight ( pps.picHeightInLumaSamples ) |
1547 | 1.20k | , fastDeltaQPCuMaxSize( Clip3<unsigned>( (1 << sps.log2MinCodingBlockSize), sps.CTUSize, 32u) ) |
1548 | 1.20k | , ISingleTree ( !sps.dualITree ) |
1549 | 1.20k | , maxMTTDepth { sps.maxMTTDepth[0], sps.maxMTTDepth[1], sps.maxMTTDepth[2] } |
1550 | 1.20k | , minTSize { 1u << sps.log2MinCodingBlockSize, 1u << sps.log2MinCodingBlockSize, 1u << sps.log2MinCodingBlockSize } |
1551 | 1.20k | , maxBtSize { sps.maxBTSize[0], sps.maxBTSize[1], sps.maxBTSize[2] } |
1552 | 1.20k | , maxTtSize { sps.maxTTSize[0], sps.maxTTSize[1], sps.maxTTSize[2] } |
1553 | 1.20k | , minQtSize { sps.minQTSize[0], sps.minQTSize[1], sps.minQTSize[2] } |
1554 | 1.20k | , maxQtSize { _maxQtSize[0], _maxQtSize[1], _maxQtSize[2] } |
1555 | 1.20k | { |
1556 | 1.20k | } |
1557 | | |
1558 | | const ChromaFormat chrFormat; |
1559 | | const unsigned maxCUSize; |
1560 | | // to get CTU position, use (x & maxCUWidthMask) rather than (x % maxCUWidth) |
1561 | | const unsigned maxCUSizeMask; |
1562 | | const unsigned maxCUSizeLog2; |
1563 | | const unsigned minCUSize; |
1564 | | const unsigned minCUSizeLog2; |
1565 | | const unsigned partsInCtuWidth; |
1566 | | const unsigned partsInCtu; |
1567 | | const unsigned widthInCtus; |
1568 | | const unsigned heightInCtus; |
1569 | | const unsigned sizeInCtus; |
1570 | | const unsigned lumaWidth; |
1571 | | const unsigned lumaHeight; |
1572 | | const unsigned fastDeltaQPCuMaxSize; |
1573 | | const bool ISingleTree; |
1574 | | |
1575 | | private: |
1576 | | const unsigned maxMTTDepth[3]; |
1577 | | const unsigned minTSize [3]; |
1578 | | const unsigned maxBtSize [3]; |
1579 | | const unsigned maxTtSize [3]; |
1580 | | const unsigned minQtSize [3]; |
1581 | | const unsigned maxQtSize [3]; |
1582 | | |
1583 | | unsigned getValIdx ( const Slice &slice, const ChannelType chType ) const; |
1584 | | |
1585 | | public: |
1586 | | unsigned getMaxMTTDepth ( const Slice &slice, const ChannelType chType ) const; |
1587 | | unsigned getMinTSize ( const Slice &slice, const ChannelType chType ) const; |
1588 | | unsigned getMaxBtSize ( const Slice &slice, const ChannelType chType ) const; |
1589 | | unsigned getMaxTtSize ( const Slice &slice, const ChannelType chType ) const; |
1590 | | unsigned getMinQtSize ( const Slice &slice, const ChannelType chType ) const; |
1591 | 130k | unsigned getMinDepth ( const SliceType slicetype, const ChannelType chType ) const { return maxCUSizeLog2 - Log2(slicetype == VVENC_I_SLICE ? (chType == CH_L ? maxQtSize[0] : maxQtSize[2]) : maxQtSize[1]); } |
1592 | 392k | unsigned getMaxDepth ( const SliceType slicetype, const ChannelType chType ) const { return maxCUSizeLog2 - Log2(slicetype == VVENC_I_SLICE ? (chType == CH_L ? minQtSize[0] : minQtSize[2]) : minQtSize[1]); } |
1593 | | Area getCtuArea ( const int ctuPosX, const int ctuPosY ) const; |
1594 | | }; |
1595 | | |
1596 | | } // namespace vvenc |
1597 | | |
1598 | | //! \} |
1599 | | |