1 /* 2 * Copyright (c) 2021-2023, Intel Corporation 3 * 4 * Permission is hereby granted, free of int8_tge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 //! 23 //! \file codec_def_decode_vvc.h 24 //! \brief Defines decode VVC types and macros shared by CodecHal, MHW, and DDI layer 25 //! \details Applies to VVC decode only. Should not contain any DDI specific code. 26 //! 27 #ifndef __CODEC_DEF_DECODE_VVC_H__ 28 #define __CODEC_DEF_DECODE_VVC_H__ 29 30 #include "codec_def_common_vvc.h" 31 #include "codec_def_common.h" 32 33 #define CODEC_MAX_DPB_NUM_VVC 127 // Maximum number of uncompressed decoded buffers 34 #define CODEC_VVC_BUFFER_ARRAY_SIZE 32 35 #define CODEC_BITSTREAM_ALIGN_SIZE_VVC 128 // Total quantity of data in Bitstream buffer shall be an integer multiple of 128 bytes 36 #define CODECHAL_VVC_MAX_NUM_SLICES_LVL_6 600 37 #define CODECHAL_VVC_MAX_NUM_SLICES_LVL_5 200 38 #define CODECHAL_VVC_NUM_DMEM_BUFFERS 32 39 40 #define CODEC_16K_VVC_MAX_PIC_WIDTH 16888 41 #define CODEC_16K_VVC_MAX_PIC_HEIGHT 16888 42 43 #define Pack4Bytes2DW(byte0, byte1, byte2, byte3) (((byte0)&0xff) | (((byte1)&0xff)<<8) | (((byte2)&0xff)<<16) | (((byte3)&0xff)<<24)) 44 #define CHECK_RANGE(var, minVal, maxVal) \ 45 if((var) < (minVal) || (var) > (maxVal))\ 46 {\ 47 DECODE_ASSERTMESSAGE("Error detected: %s = %d out of range [%d, %d].\n", #var, var, minVal, maxVal);\ 48 res = MOS_STATUS_INVALID_PARAMETER;\ 49 }\ 50 51 static const uint32_t vvcMaxSliceNum = 600; // Max slice number per frame, level 6.2 52 static const uint32_t vvcMaxSubpicNum = 600; // Per Spec, same with MaxSlicesPerAu =vvcMaxSliceNum 53 static const uint32_t vvcMaxLmcsNum = 4; // Max LMCS structures 54 static const uint32_t vvcMaxAlfNum = 8; // Max ALF structures 55 static const uint32_t vvcMaxScalingMatrixNum = 8; // Max Scaling Matrix structures 56 static const uint32_t vvcMaxTileParamsNum = 441; // Max Tile Params structures 57 static const uint32_t vvcMaxRplNum = 130; // Max RPL structures 128 sps rpls + 2 PH rpls 58 static const uint32_t vvcSpsCandidateRpl1Offset = 64; // vvcSpsCandidateRpl0(64) + vvcSpsCandidateRpl1(64) + PH rpl0(1) + PH rpl1(1) = 130 59 static const uint32_t vvcPhRpl0Offset = 128; 60 static const uint32_t vvcPhRpl1Offset = 129; // vvcPhRpl1Offset must be vvcPhRpl0Offset + 1 61 static const uint32_t vvcMaxNumRefFrame = 15; // Max reference frame number 62 static const uint32_t vvcPicCodeCwBins = 16; // PIC_CODE_CW_BINS 63 static const uint32_t vvcFpPrec = 11; // FP_PREC 64 static const uint32_t vvcCscaleFpPrec = 11; // CSCALE_FP_PREC 65 static const uint32_t vvcNumInitialMvBuffers = 6; // initial MV buffer number to allocate 66 static const uint32_t vvcMaxTileColNum = 20; // Max number of tile columns in a picture 67 static const uint32_t vvcMaxTileRowNum = 440; // Max number of tile rows in a picture 68 static const uint32_t vvcMaxTileNum = 440; // Max number of tiles in a picture 69 70 71 //VVC parameters definition 72 73 //! 74 //! \struct TileColDesc 75 //! \brief Define the Tile Column descriptor for VVC 76 //! 77 struct TileColDesc 78 { 79 uint16_t m_startCtbX; 80 uint16_t m_endCtbX; 81 uint16_t m_widthInCtb; 82 }; 83 84 //! 85 //! \struct TileRowDesc 86 //! \brief Define the Tile Row descriptor for VVC 87 //! 88 struct TileRowDesc 89 { 90 uint16_t m_startCtbY; 91 uint16_t m_endCtbY; 92 uint16_t m_heightInCtb; 93 }; 94 95 //! 96 //! \struct SliceDescriptor 97 //! \brief Define the Slice descriptor for VVC 98 //! 99 struct SliceDescriptor 100 { 101 int32_t m_numCtusInCurrSlice; //!< number of CTUs in current slice 102 103 //Rect slices params 104 uint16_t m_tileIdx; //!< tile index corresponding to the first CTU in the slice 105 uint32_t m_numSlicesInTile; //!< number of slices in current tile for the special case of multiple slices inside a single tile 106 int16_t m_sliceWidthInTiles; //!< slice width in units of tiles 107 int16_t m_sliceHeightInTiles; //!< slice height in units of tiles 108 uint16_t m_sliceHeightInCtu; //!< slice height in units of CTUs for the special case of multiple slices inside a single tile 109 110 //Additional params on SubPic v.s. Slice 111 uint32_t m_sliceStartCtbx; 112 uint32_t m_sliceStartCtby; 113 uint16_t m_subPicIdx; 114 uint16_t m_sliceIdxInSubPic; 115 uint32_t m_sliceEndCtbx; //! valid only for rect slice mode 116 uint32_t m_sliceEndCtby; //! valid only for rect slice mode 117 118 //Only used for single slice per subpic 119 uint32_t m_multiSlicesInTileFlag; 120 uint16_t m_startTileX; 121 uint16_t m_startTileY; 122 123 //for command programming 124 uint32_t m_topSliceInTileFlag; //! valid only for multiple slices in one tile case, others ignore 125 uint32_t m_bottomSliceInTileFlag; //! valid only for multiple slices in one tile case, others ignore 126 127 //for error handling 128 int16_t m_sliceCtrlIdx; //! index of slice control params that current slice corresponds to 129 bool m_sliceAvailableFlag; //! flag to indicate if current slice is available 130 }; 131 132 //! 133 //! \struct ApsLmcsReshapeInfo 134 //! \brief Define the APS LMCS Reshape info for VVC 135 //! 136 struct ApsLmcsReshapeInfo 137 { 138 uint16_t m_lmcsCW[16]; 139 int32_t m_scaleCoeff[16]; 140 int32_t m_invScaleCoeff[16]; 141 int32_t m_chromaScaleCoeff[16]; 142 int16_t m_lmcsPivot[17]; 143 }; 144 145 //! 146 //! \struct VvcWeightedPredInfo 147 //! \brief Define the weighted prediction info for VVC 148 //! 149 struct VvcWeightedPredInfo 150 { 151 uint8_t m_lumaLog2WeightDenom; // [0..7] 152 int8_t m_deltaChromaLog2WeightDenom; // [-7..7] 153 uint8_t m_numL0Weights; // [0..15] 154 uint8_t m_lumaWeightL0Flag[15]; // [0..1] 155 uint8_t m_chromaWeightL0Flag[15]; // [0..1] 156 int8_t m_deltaLumaWeightL0[15]; // [-128..127] 157 int8_t m_lumaOffsetL0[15]; // [-128..127] 158 int8_t m_deltaChromaWeightL0[15][2]; // [-128..127] 159 int16_t m_deltaChromaOffsetL0[15][2]; // [-512..508] 160 uint8_t m_numL1Weights; // [0..15] 161 uint8_t m_lumaWeightL1Flag[15]; // [0..1] 162 uint8_t m_chromaWeightL1Flag[15]; // [0..1] 163 int8_t m_deltaLumaWeightL1[15]; // [-128..127] 164 int8_t m_lumaOffsetL1[15]; // [-128..127] 165 int8_t m_deltaChromaWeightL1[15][2]; // [-128..127] 166 int16_t m_deltaChromaOffsetL1[15][2]; // [-512..508] 167 uint32_t m_reserved32b[4]; 168 }; 169 170 //! 171 //! \struct CodecVvcPicParams 172 //! \brief Define VVC picture parameters 173 //! 174 struct CodecVvcPicParams 175 { 176 // SPS info 177 uint16_t m_spsPicWidthMaxInLumaSamples; // [8..16888] 178 uint16_t m_spsPicHeightMaxInLumaSamples; // [8..16888] 179 180 uint16_t m_spsNumSubpicsMinus1; // [0..599] 181 uint8_t m_spsSubpicIdLenMinus1; // [0..15] 182 uint8_t m_spsChromaFormatIdc; // [1] 183 uint8_t m_spsBitdepthMinus8; // [0..2] 184 uint8_t m_spsLog2CtuSizeMinus5; // [0..2] 185 uint8_t m_spsLog2MaxPicOrderCntLsbMinus4; // [0..12] 186 uint8_t m_spsLog2MinLumaCodingBlockSizeMinus2; // [0..4] 187 uint8_t m_spsPocMsbCycleLenMinus1; // [0..27] 188 uint8_t m_numExtraPhBits; // [0..15] 189 uint8_t m_numExtraShBits; // [0..15] 190 uint8_t m_spsLog2TransformSkipMaxSizeMinus2; // [0..3] 191 192 int8_t m_chromaQpTable[3][112]; // [-12..63] 193 194 uint8_t m_spsNumRefPicLists[2]; // [0..64] 195 uint8_t m_spsSixMinusMaxNumMergeCand; // [0..5] 196 uint8_t m_spsFiveMinusMaxNumSubblockMergeCand; // [0..5] 197 uint8_t m_spsMaxNumMergeCandMinusMaxNumGpmCand; // [0..4] 198 uint8_t m_spsLog2ParallelMergeLevelMinus2; // [0..5] 199 uint8_t m_spsMinQpPrimeTs; // [0..8] 200 uint8_t m_spsSixMinusMaxNumIbcMergeCand; // [0..5] 201 uint8_t m_spsNumLadfIntervalsMinus2; // [0..3] 202 int8_t m_spsLadfLowestIntervalQpOffset; // [-63..63] 203 int8_t m_spsLadfQpOffset[4]; // [-63..63] 204 uint16_t m_spsLadfDeltaThresholdMinus1[4]; // [0..1021] 205 uint8_t m_spsNumVerVirtualBoundaries; // [0..3] 206 uint8_t m_spsNumHorVirtualBoundaries; // [0..3] 207 uint8_t m_spsLog2DiffMinQtMinCbIntraSliceLuma; // [0..4] 208 uint8_t m_spsMaxMttHierarchyDepthIntraSliceLuma; // [0..10] 209 uint16_t m_spsVirtualBoundaryPosXMinus1[3]; // [0..2109] 210 uint16_t m_spsVirtualBoundaryPosYMinus1[3]; // [0..2109] 211 uint8_t m_spsLog2DiffMaxBtMinQtIntraSliceLuma; // [0..5] 212 uint8_t m_spsLog2DiffMaxTtMinQtIntraSliceLuma; // [0..4] 213 uint8_t m_spsLog2DiffMinQtMinCbIntraSliceChroma; // [0..4] 214 uint8_t m_spsMaxMttHierarchyDepthIntraSliceChroma; // [0..10] 215 uint8_t m_spsLog2DiffMaxBtMinQtIntraSliceChroma; // [0..4] 216 uint8_t m_spsLog2DiffMaxTtMinQtIntraSliceChroma; // [0..4] 217 uint8_t m_spsLog2DiffMinQtMinCbInterSlice; // [0..4] 218 uint8_t m_spsMaxMttHierarchyDepthInterSlice; // [0..10] 219 uint8_t m_spsLog2DiffMaxBtMinQtInterSlice; // [0..5] 220 uint8_t m_spsLog2DiffMaxTtMinQtInterSlice; // [0..4] 221 uint32_t m_reserved32b0; 222 223 union 224 { 225 struct 226 { 227 uint32_t m_spsSubpicInfoPresentFlag : 1; // [0..1] 228 uint32_t m_spsIndependentSubpicsFlag : 1; // [0..1] 229 uint32_t m_spsSubpicSameSizeFlag : 1; // [0..1] 230 uint32_t m_spsEntropyCodingSyncEnabledFlag : 1; // [0..1] 231 uint32_t m_spsEntryPointOffsetsPresentFlag : 1; // [0..1] 232 uint32_t m_spsPocMsbCycleFlag : 1; // [0..1] 233 uint32_t m_spsPartitionConstraintsOverrideEnabledFlag : 1; // [0..1] 234 uint32_t m_spsQtbttDualTreeIntraFlag : 1; // [0..1] 235 uint32_t m_spsMaxLumaTransformSize64Flag : 1; // [0..1] 236 uint32_t m_spsTransformSkipEnabledFlag : 1; // [0..1] 237 uint32_t m_spsBdpcmEnabledFlag : 1; // [0..1] 238 uint32_t m_spsMtsEnabledFlag : 1; // [0..1] 239 uint32_t m_spsExplicitMtsIntraEnabledFlag : 1; // [0..1] 240 uint32_t m_spsExplicitMtsInterEnabledFlag : 1; // [0..1] 241 uint32_t m_spsLfnstEnabledFlag : 1; // [0..1] 242 uint32_t m_spsJointCbcrEnabledFlag : 1; // [0..1] 243 uint32_t m_spsSameQpTableForChromaFlag : 1; // [0..1] 244 uint32_t m_spsSaoEnabledFlag : 1; // [0..1] 245 uint32_t m_spsAlfEnabledFlag : 1; // [0..1] 246 uint32_t m_spsCcalfEnabledFlag : 1; // [0..1] 247 uint32_t m_spsLmcsEnabledFlag : 1; // [0..1] 248 uint32_t m_spsLongTermRefPicsFlag : 1; // [0..1] 249 uint32_t m_spsInterLayerPredictionEnabledFlag : 1; // [0..1] 250 uint32_t m_spsIdrRplPresentFlag : 1; // [0..1] 251 uint32_t m_reservedBits : 8; // [0] 252 } m_fields; 253 uint32_t m_value; 254 } m_spsFlags0; 255 256 union 257 { 258 struct 259 { 260 uint32_t m_spsTemporalMvpEnabledFlag : 1; // [0..1] 261 uint32_t m_spsSbtmvpEnabledFlag : 1; // [0..1] 262 uint32_t m_spsAmvrEnabledFlag : 1; // [0..1] 263 uint32_t m_spsBdofEnabledFlag : 1; // [0..1] 264 uint32_t m_spsBdofControlPresentInPhFlag : 1; // [0..1] 265 uint32_t m_spsSmvdEnabledFlag : 1; // [0..1] 266 uint32_t m_spsDmvrEnabledFlag : 1; // [0..1] 267 uint32_t m_spsDmvrControlPresentInPhFlag : 1; // [0..1] 268 uint32_t m_spsMmvdEnabledFlag : 1; // [0..1] 269 uint32_t m_spsMmvdFullpelOnlyEnabledFlag : 1; // [0..1] 270 uint32_t m_spsSbtEnabledFlag : 1; // [0..1] 271 uint32_t m_spsAffineEnabledFlag : 1; // [0..1] 272 uint32_t m_sps6paramAffineEnabledFlag : 1; // [0..1] 273 uint32_t m_spsAffineAmvrEnabledFlag : 1; // [0..1] 274 uint32_t m_spsAffineProfEnabledFlag : 1; // [0..1] 275 uint32_t m_spsProfControlPresentInPhFlag : 1; // [0..1] 276 uint32_t m_spsBcwEnabledFlag : 1; // [0..1] 277 uint32_t m_spsCiipEnabledFlag : 1; // [0..1] 278 uint32_t m_spsGpmEnabledFlag : 1; // [0..1] 279 uint32_t m_spsIspEnabledFlag : 1; // [0..1] 280 uint32_t m_spsMrlEnabledFlag : 1; // [0..1] 281 uint32_t m_spsMipEnabledFlag : 1; // [0..1] 282 uint32_t m_spsCclmEnabledFlag : 1; // [0..1] 283 uint32_t m_spsChromaHorizontalCollocatedFlag : 1; // [0..1] 284 uint32_t m_spsChromaVerticalCollocatedFlag : 1; // [0..1] 285 286 uint32_t m_reservedBits : 7; // [0] 287 } m_fields; 288 uint32_t m_value; 289 } m_spsFlags1; 290 291 union 292 { 293 struct 294 { 295 uint32_t m_spsPaletteEnabledFlag : 1; // [0..1] 296 uint32_t m_spsActEnabledFlag : 1; // [0..1] 297 uint32_t m_spsIbcEnabledFlag : 1; // [0..1] 298 uint32_t m_spsLadfEnabledFlag : 1; // [0..1] 299 uint32_t m_spsExplicitScalingListEnabledFlag : 1; // [0..1] 300 uint32_t m_spsScalingMatrixForLfnstDisabledFlag : 1; // [0..1] 301 uint32_t m_spsScalingMatrixForAlternativeColourSpaceDisabledFlag : 1; // [0..1] 302 uint32_t m_spsScalingMatrixDesignatedColourSpaceFlag : 1; // [0..1] 303 uint32_t m_spsDepQuantEnabledFlag : 1; // [0..1] 304 uint32_t m_spsSignDataHidingEnabledFlag : 1; // [0..1] 305 uint32_t m_spsVirtualBoundariesEnabledFlag : 1; // [0..1] 306 uint32_t m_spsVirtualBoundariesPresentFlag : 1; // [0..1] 307 uint32_t m_spsWeightedPredFlag : 1; // [0..1] 308 uint32_t m_spsWeightedBipredFlag : 1; // [0..1] 309 uint32_t m_reservedBits : 18; // [0] 310 } m_fields; 311 uint32_t m_value; 312 } m_spsFlags2; 313 314 // PPS info 315 uint16_t m_ppsPicWidthInLumaSamples; // [8..16888] 316 uint16_t m_ppsPicHeightInLumaSamples; // [8..16888] 317 uint8_t m_numVerVirtualBoundaries; // [0..3] 318 uint8_t m_numHorVirtualBoundaries; // [0..3] 319 uint16_t m_virtualBoundaryPosX[3]; // [0..16880] 320 uint16_t m_virtualBoundaryPosY[3]; // [0..16880] 321 322 int32_t m_ppsScalingWinLeftOffset; 323 int32_t m_ppsScalingWinRightOffset; 324 int32_t m_ppsScalingWinTopOffset; 325 int32_t m_ppsScalingWinBottomOffset; 326 327 uint8_t m_ppsNumExpTileColumnsMinus1; // [0..19] 328 uint16_t m_ppsNumExpTileRowsMinus1; // [0..439] 329 uint16_t m_ppsNumSlicesInPicMinus1; // [0..599] 330 uint8_t m_ppsNumRefIdxDefaultActiveMinus1[2]; // [0..14] 331 uint16_t m_ppsPicWidthMinusWraparoundOffset; // [0..4188] 332 int8_t m_ppsInitQpMinus26; // [-38..37] 333 int8_t m_ppsCbQpOffset; // [-12..12] 334 int8_t m_ppsCrQpOffset; // [-12..12] 335 int8_t m_ppsJointCbcrQpOffsetValue; // [-12..12] 336 uint8_t m_ppsChromaQpOffsetListLenMinus1; // [0..5] 337 int8_t m_ppsCbQpOffsetList[ 6 ]; // [-12..12] 338 int8_t m_ppsCrQpOffsetList[ 6 ]; // [-12..12] 339 int8_t m_ppsJointCbcrQpOffsetList[ 6 ]; // [-12..12] 340 int8_t m_ppsLumaBetaOffsetDiv2; // [-12..12] 341 int8_t m_ppsLumaTcOffsetDiv2; // [-12..12] 342 int8_t m_ppsCbBetaOffsetDiv2; // [-12..12] 343 int8_t m_ppsCbTcOffsetDiv2; // [-12..12] 344 int8_t m_ppsCrBetaOffsetDiv2; // [-12..12] 345 int8_t m_ppsCrTcOffsetDiv2; // [-12..12] 346 uint16_t m_reserved16b; // [0] 347 uint8_t m_numScalingMatrixBuffers; // [0..8] 348 uint8_t m_numAlfBuffers; // [0..8] 349 uint8_t m_numLmcsBuffers; // [0..4] 350 uint8_t m_numRefPicListStructs; // [0..128] 351 uint16_t m_numSliceStructsMinus1; // [0..599] 352 353 union 354 { 355 struct 356 { 357 uint32_t m_ppsOutputFlagPresentFlag : 1; // [0..1] 358 uint32_t m_ppsLoopFilterAcrossTilesEnabledFlag : 1; // [0..1] 359 uint32_t m_ppsRectSliceFlag : 1; // [0..1] 360 uint32_t m_ppsSingleSlicePerSubpicFlag : 1; // [0..1] 361 uint32_t m_ppsLoopFilterAcrossSlicesEnabledFlag : 1; // [0..1] 362 uint32_t m_ppsCabacInitPresentFlag : 1; // [0..1] 363 uint32_t m_ppsRpl1IdxPresentFlag : 1; // [0..1] 364 uint32_t m_ppsWeightedPredFlag : 1; // [0..1] 365 uint32_t m_ppsWeightedBipredFlag : 1; // [0..1] 366 uint32_t m_ppsRefWraparoundEnabledFlag : 1; // [0..1] 367 uint32_t m_ppsCuQpDeltaEnabledFlag : 1; // [0..1] 368 uint32_t m_ppsChroma_toolOffsetsPresentFlag : 1; // [0..1] 369 uint32_t m_ppsSliceChromaQpOffsetsPresentFlag : 1; // [0..1] 370 uint32_t m_ppsCuChromaQpOffsetListEnabledFlag : 1; // [0..1] 371 uint32_t m_ppsDeblockingFilterOverrideEnabledFlag : 1; // [0..1] 372 uint32_t m_ppsDeblockingFilterDisabledFlag : 1; // [0..1] 373 uint32_t m_ppsDbfInfoInPhFlag : 1; // [0..1] 374 uint32_t m_ppsRplInfoInPhFlag : 1; // [0..1] 375 uint32_t m_ppsSaoInfoInPhFlag : 1; // [0..1] 376 uint32_t m_ppsAlfInfoInPhFlag : 1; // [0..1] 377 uint32_t m_ppsWpInfoInPhFlag : 1; // [0..1] 378 uint32_t m_ppsQpDeltaInfoInPhFlag : 1; // [0..1] 379 uint32_t m_ppsPictureHeaderExtensionPresentFlag : 1; // [0..1] 380 uint32_t m_ppsSliceHeaderExtensionPresentFlag : 1; // [0..1] 381 uint32_t m_reservedBits : 8; // [0] 382 } m_fields; 383 uint32_t m_value; 384 } m_ppsFlags; 385 386 // PH info 387 uint8_t m_phNumAlfApsIdsLuma; // [0..7] 388 uint8_t m_phAlfApsIdLuma[7]; // [0..7] 389 uint8_t m_phAlfApsIdChroma; // [0..7] 390 uint8_t m_phAlfCcCbApsId; // [0..7] 391 uint8_t m_phAlfCcCrApsId; // [0..7] 392 uint8_t m_phLmcsApsId; // [0..3] 393 uint8_t m_phScalingListApsId; // [0..7] 394 uint8_t m_phLog2DiffMinQtMinCbIntraSliceLuma; // [0..4] 395 uint8_t m_phMaxMtt_hierarchyDepthIntraSliceLuma; // [0..10] 396 uint8_t m_phLog2DiffMaxBtMinQtIntraSliceLuma; // [0..5] 397 uint8_t m_phLog2DiffMax_ttMinQtIntraSliceLuma; // [0..4] 398 uint8_t m_phLog2DiffMinQtMinCbIntraSliceChroma; // [0..4] 399 uint8_t m_phMaxMtt_hierarchyDepthIntraSliceChroma; // [0..10] 400 uint8_t m_phLog2DiffMaxBtMinQtIntraSliceChroma; // [0..4] 401 uint8_t m_phLog2DiffMax_ttMinQtIntraSliceChroma; // [0..4] 402 uint8_t m_phCuQpDeltaSubdivIntraSlice; // [0..30] 403 uint8_t m_phCuChromaQpOffsetSubdivIntraSlice; // [0..30] 404 uint8_t m_phLog2DiffMinQtMinCbInterSlice; // [0..4] 405 uint8_t m_phMaxMtt_hierarchyDepthInterSlice; // [0..10] 406 uint8_t m_phLog2DiffMaxBtMinQtInterSlice; // [0..5] 407 uint8_t m_phLog2DiffMax_ttMinQtInterSlice; // [0..4] 408 uint8_t m_phCuQpDeltaSubdivInterSlice; // [0..30] 409 uint8_t m_phCuChromaQpOffsetSubdivInterSlice; // [0..30] 410 uint8_t m_phCollocatedRefIdx; // [0..14] 411 int8_t m_phQpDelta; // [-75..75] 412 int8_t m_phLumaBetaOffsetDiv2; // [-12..12] 413 int8_t m_phLumaTcOffsetDiv2; // [-12..12] 414 int8_t m_phCbBetaOffsetDiv2; // [-12..12] 415 int8_t m_phCbTcOffsetDiv2; // [-12..12] 416 int8_t m_phCrBetaOffsetDiv2; // [-12..12] 417 int8_t m_phCrTcOffsetDiv2; // [-12..12] 418 419 // weighted prediction info 420 VvcWeightedPredInfo m_wpInfo; 421 422 union 423 { 424 struct 425 { 426 uint32_t m_phNonRefPicFlag : 1; // [0..1] 427 uint32_t m_phInterSliceAllowedFlag : 1; // [0..1] 428 uint32_t m_phAlfEnabledFlag : 1; // [0..1] 429 uint32_t m_phAlfCbEnabledFlag : 1; // [0..1] 430 uint32_t m_phAlfCrEnabledFlag : 1; // [0..1] 431 uint32_t m_phAlfCcCbEnabledFlag : 1; // [0..1] 432 uint32_t m_phAlfCcCrEnabledFlag : 1; // [0..1] 433 uint32_t m_phLmcsEnabledFlag : 1; // [0..1] 434 uint32_t m_phChromaResidualScaleFlag : 1; // [0..1] 435 uint32_t m_phExplicitScalingListEnabledFlag : 1; // [0..1] 436 uint32_t m_phVirtualBoundariesPresentFlag : 1; // [0..1] 437 uint32_t m_reserved1b : 1; // [0..1] 438 uint32_t m_phTemporalMvpEnabledFlag : 1; // [0..1] 439 uint32_t m_numRefEntries0RplIdx0LargerThan0 : 1; // [0..1] 440 uint32_t m_numRefEntries1RplIdx1LargerThan0 : 1; // [0..1] 441 uint32_t m_phCollocatedFromL0Flag : 1; // [0..1] 442 uint32_t m_phMmvdFullpelOnlyFlag : 1; // [0..1] 443 uint32_t m_phMvdL1ZeroFlag : 1; // [0..1] 444 uint32_t m_phBdofDisabledFlag : 1; // [0..1] 445 uint32_t m_phDmvrDisabledFlag : 1; // [0..1] 446 uint32_t m_phProfDisabledFlag : 1; // [0..1] 447 uint32_t m_phJointCbcrSignFlag : 1; // [0..1] 448 uint32_t m_phSaoLumaEnabledFlag : 1; // [0..1] 449 uint32_t m_phSaoChromaEnabledFlag : 1; // [0..1] 450 uint32_t m_phDeblockingFilterDisabledFlag : 1; // [0..1] 451 uint32_t m_rplSpsFlag0 : 1; // [0..1] 452 uint32_t m_rplSpsFlag1 : 1; // [0..1] 453 uint32_t m_reservedBits : 5; // [0] 454 } m_fields; 455 uint32_t m_value; 456 } m_phFlags; 457 458 // reference lists 459 CODEC_PICTURE m_currPic; 460 int32_t m_picOrderCntVal; // [-2^31 .. 2^31-1] 461 int32_t m_refFramePocList [vvcMaxNumRefFrame]; // [-2^31 .. 2^31-1] 462 CODEC_PICTURE m_refFrameList [vvcMaxNumRefFrame]; 463 CODEC_PICTURE m_refPicList [2][vvcMaxNumRefFrame]; 464 465 union 466 { 467 struct 468 { 469 uint32_t m_intraPicFlag : 1; // [0..1] 470 uint32_t m_reservedBits3 : 31; 471 } m_fields; 472 uint32_t m_value; 473 } m_picMiscFlags; 474 475 uint32_t m_statusReportFeedbackNumber; 476 uint32_t m_rplSpsIndex0; 477 uint32_t m_rplSpsIndex1; 478 uint32_t m_reserved32b[16]; 479 480 // MultiLayer params 481 uint8_t m_refFrameListNuhLayerId[15]; // [0..55] 482 uint8_t m_nuhLayerId; // [0..55] 483 uint8_t m_vpsMaxLayersMinus1; // [0..55] 484 uint8_t m_reserved[3]; 485 uint8_t m_vpsLayerId[56]; // [0..55] 486 uint8_t m_vpsDirectRefLayerFlag[56][7]; 487 uint32_t m_multilayerReserved32b[16]; // [0] 488 }; 489 490 //! 491 //! \struct CodecVvcAlfData 492 //! \brief Define the ALF data for VVC 493 //! 494 struct CodecVvcAlfData 495 { 496 uint8_t m_apsAdaptationParameterSetId; // [0..7] 497 uint8_t m_alfLumaNumFiltersSignalledMinus1; // [0..24] 498 uint8_t m_alfLumaCoeffDeltaIdx[25]; // [0..24] 499 int8_t m_alfCoeffL[25][12]; // [-128..127] 500 uint8_t m_alfLumaClipIdx[25][12]; // [0..3] 501 uint8_t m_alfChromaNumAltFiltersMinus1; // [0..7] 502 int8_t m_alfCoeffC[8][6]; // [-128..127] 503 uint8_t m_alfChromaClipIdx[8][6]; // [0..3] 504 uint8_t m_alfCcCbFiltersSignalledMinus1; // [0..3] 505 int8_t m_ccAlfApsCoeffCb[4][7]; // [-64..64] 506 uint8_t m_alfCcCrFiltersSignalledMinus1; // [0..3] 507 int8_t m_ccAlfApsCoeffCr[4][7]; // [-64..64] 508 509 union 510 { 511 struct 512 { 513 uint32_t m_alfLumaFilterSignalFlag : 1; // [0..1] 514 uint32_t m_alfChromaFilterSignalFlag : 1; // [0..1] 515 uint32_t m_alfCcCbFilterSignalFlag : 1; // [0..1] 516 uint32_t m_alfCcCrFilterSignalFlag : 1; // [0..1] 517 uint32_t m_alfLumaClipFlag : 1; // [0..1] 518 uint32_t m_alfChromaClipFlag : 1; // [0..1] 519 uint32_t m_reservedBits : 26; // [0] 520 } m_fields; 521 uint32_t m_value; 522 } m_alfFlags; 523 524 uint32_t m_reserved32b[8]; // [0] 525 }; 526 527 //! 528 //! \struct CodecVvcLmcsData 529 //! \brief Define the LMCS data for VVC 530 //! 531 struct CodecVvcLmcsData 532 { 533 uint8_t m_apsAdaptationParameterSetId; // [0..7] 534 uint8_t m_reserved8b; // [0] 535 uint8_t m_lmcsMinBinIdx; // [0..15] 536 uint8_t m_lmcsDeltaMaxBinIdx; // [0..15] 537 int16_t m_lmcsDeltaCW[16]; // [-32767..32767] 538 int8_t m_lmcsDeltaCrs; // [-7..7] 539 uint32_t m_reserved32b[8]; // [0] 540 }; 541 542 //! 543 //! \struct CodecVvcQmData 544 //! \brief Define the Quantization Matrix data for VVC 545 //! 546 struct CodecVvcQmData 547 { 548 uint8_t m_apsAdaptationParameterSetId; // [0..7] 549 uint8_t m_reserved8b; 550 uint8_t m_scalingMatrixDCRec[14]; // [1..255] 551 uint8_t m_scalingMatrixRec2x2[2][2][2]; // [1..255] 552 uint8_t m_scalingMatrixRec4x4[6][4][4]; // [1..255] 553 uint8_t m_scalingMatrixRec8x8[20][8][8]; // [1..255] 554 uint32_t m_reserved32b[8]; 555 }; 556 557 //! 558 //! \struct CodecVvcTileParam 559 //! \brief Define the Tile Parameter for VVC 560 //! 561 struct CodecVvcTileParam 562 { 563 uint16_t m_tileDimension; // [0..262] 564 }; 565 566 //! 567 //! \struct CodecVvcSubpicParam 568 //! \brief Define the SubPic Parameter for VVC 569 //! 570 struct CodecVvcSubpicParam 571 { 572 uint16_t m_spsSubpicCtuTopLeftX; // [0..526] 573 uint16_t m_spsSubpicCtuTopLeftY; // [0..526] 574 uint16_t m_spsSubpicWidthMinus1; // [0..511] 575 uint16_t m_spsSubpicHeightMinus1; // [0..511] 576 uint16_t m_subpicIdVal; // [0..2^16-1] 577 578 union 579 { 580 struct 581 { 582 uint16_t m_spsSubpicTreatedAsPicFlag : 1; // [0..1] 583 uint16_t m_spsLoopFilterAcrossSubpicEnabledFlag : 1; // [0..1] 584 uint16_t m_reserved14bits : 14; // [0] 585 } m_fields; 586 uint16_t m_value; 587 } m_subPicFlags; 588 589 //Additional params to reconstruct partition for Rect slice mode and none-single slice per subpic case 590 uint16_t m_endCtbX; //SubPic range right border in CTU column 591 uint16_t m_endCtbY; //SubPic range bottom border in CTU row 592 int16_t m_numSlices; //Accumulated slice number in current subpic 593 uint16_t *m_sliceIdx; //Pointer to an array of slice index in scan order in picture 594 }; 595 596 //! 597 //! \struct CodecVvcSliceStructure 598 //! \brief Define the Slice Structure for VVC 599 //! 600 struct CodecVvcSliceStructure 601 { 602 uint16_t m_sliceTopLeftTileIdx; // [0..439] 603 uint16_t m_ppsSliceWidthInTilesMinus1; // [0..19] 604 uint16_t m_ppsSliceHeightInTilesMinus1; // [0..439] 605 uint16_t m_ppsExpSliceHeightInCtusMinus1; // [0..526] 606 uint16_t m_reserved16b; // [0] 607 uint32_t m_reserved32b[4]; // [0] 608 }; 609 610 //! 611 //! \struct CodecVvcRplStructure 612 //! \brief Define the RPL Structure for VVC 613 //! 614 struct CodecVvcRplStructure 615 { 616 uint8_t m_listIdx; // [0..1] 617 uint8_t m_rplsIdx; // [0.. spsNumRefPicLists[listIdx]] 618 uint8_t m_numRefEntries; // [0..29] 619 uint8_t m_ltrpInHeaderFlag; // [0..1] 620 uint8_t m_stRefPicFlag[29]; // [0..1] 621 uint8_t m_reserved8b[3]; // [0] 622 int16_t m_deltaPocSt[29]; // [-2^15..2^15 - 1] 623 uint16_t m_rplsPocLsbLt[29]; // [0..2^16-1] 624 uint8_t m_interLayerRefPicFlag[29]; // [0..1] 625 uint8_t m_ilrpIdx[29]; // [0..55] 626 uint16_t m_reserved16b; // [0] 627 uint32_t m_reserved32b[8]; // [0] leave space for multilayer enabling 628 }; 629 630 //! 631 //! \struct CodecVvcSliceParams 632 //! \brief Define the Slice Parameters for VVC 633 //! 634 struct CodecVvcSliceParams 635 { 636 uint32_t m_bSNALunitDataLocation; 637 uint32_t m_sliceBytesInBuffer; 638 uint16_t m_wBadSliceChopping; 639 640 uint16_t m_shSubpicId; // [0..65535] 641 uint16_t m_shSliceAddress; // [0..599] 642 uint16_t m_shNumTilesInSliceMinus1; // [0..439] 643 uint8_t m_shSliceType; // [0..2] 644 uint8_t m_shNumAlfApsIdsLuma; // [0..7] 645 uint8_t m_shAlfApsIdLuma[ 7 ]; // [0..7] 646 uint8_t m_shAlfApsIdChroma; // [0..7] 647 uint8_t m_shAlfCcCbApsId; // [0..7] 648 uint8_t m_shAlfCcCrApsId; // [0..7] 649 int8_t m_numRefIdxActive[ 2 ]; // [0..14] 650 uint8_t m_shCollocatedRefIdx; // [0..14] 651 int8_t m_sliceQpY; // [-12..63] 652 int8_t m_shCbQpOffset; // [-12..12] 653 int8_t m_shCrQpOffset; // [-12..12] 654 int8_t m_shJointCbcrQpOffset; // [-12..12] 655 int8_t m_shLumaBetaOffsetDiv2; // [-12..12] 656 int8_t m_shLumaTcOffsetDiv2; // [-12..12] 657 int8_t m_shCbBetaOffsetDiv2; // [-12..12] 658 int8_t m_shCbTcOffsetDiv2; // [-12..12] 659 int8_t m_shCrBetaOffsetDiv2; // [-12..12] 660 int8_t m_shCrTcOffsetDiv2; // [-12..12] 661 662 uint32_t m_byteOffsetToSliceData; 663 uint16_t m_numEntryPoints; // [0..512] 664 665 CODEC_PICTURE m_refPicList[2][15]; 666 VvcWeightedPredInfo m_wpInfo; 667 668 union 669 { 670 struct 671 { 672 uint32_t m_shAlfEnabledFlag : 1; // [0..1] 673 uint32_t m_shAlfCbEnabledFlag : 1; // [0..1] 674 uint32_t m_shAlfCrEnabledFlag : 1; // [0..1] 675 uint32_t m_shAlfCcCbEnabledFlag : 1; // [0..1] 676 uint32_t m_shAlfCcCrEnabledFlag : 1; // [0..1] 677 uint32_t m_shLmcsUsedFlag : 1; // [0..1] 678 uint32_t m_shExplicitScalingListUsedFlag : 1; // [0..1] 679 uint32_t m_shCabacInitFlag : 1; // [0..1] 680 uint32_t m_shCollocatedFromL0Flag : 1; // [0..1] 681 uint32_t m_shCuChromaQpOffsetEnabledFlag : 1; // [0..1] 682 uint32_t m_shSaoLumaUsedFlag : 1; // [0..1] 683 uint32_t m_shSaoChromaUsedFlag : 1; // [0..1] 684 uint32_t m_shDeblockingFilterDisabledFlag : 1; // [0..1] 685 uint32_t m_shDepQuantUsedFlag : 1; // [0..1] 686 uint32_t m_shSignDataHidingUsedFlag : 1; // [0..1] 687 uint32_t m_shTsResidualCodingDisabledFlag : 1; // [0..1] 688 uint32_t m_lastSliceOfPic : 1; // [0..1] 689 uint32_t m_noBackwardPredFlag : 1; // [0..1] 690 uint32_t m_reserved : 15; // [0] 691 } m_fields; 692 uint32_t m_value; 693 } m_longSliceFlags; 694 695 uint32_t m_reserved32b[8]; 696 }; 697 698 #endif // __CODEC_DEF_DECODE_VVC_H__ 699 700