1 /* 2 * Copyright (c) 2022-2023, Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, 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 decode_vvc_s2l_packet.h 24 //! \brief Defines the implementation of VVC decode S2L packet 25 //! 26 27 #ifndef __DECODE_VVC_S2L_PACKET_H__ 28 #define __DECODE_VVC_S2L_PACKET_H__ 29 30 #include "media_cmd_packet.h" 31 #include "decode_huc.h" 32 #include "media_pipeline.h" 33 #include "codec_hw_next.h" 34 #include "decode_utils.h" 35 #include "decode_vvc_pipeline.h" 36 #include "decode_vvc_basic_feature.h" 37 38 #include "mhw_vdbox_huc_cmdpar.h" 39 #include "mhw_vdbox_huc_itf.h" 40 #include "mhw_cmdpar.h" 41 #include "decode_vvc_packet.h" 42 43 namespace decode 44 { 45 46 enum DMAReadWriteStatus 47 { 48 DMAReadWriteDisabled = 0, 49 DMAReadWriteEnabled = 1, 50 }; 51 52 struct VvcS2lSliceBsParam 53 { 54 uint32_t BSNALunitDataLocation; 55 uint32_t SliceBytesInBuffer; 56 57 struct 58 { 59 uint32_t reserve_0; 60 uint32_t reserve_1; 61 uint32_t reserve_2; 62 uint32_t reserve_3; 63 } reserve; 64 }; 65 66 struct VvcS2lSliceBbParam 67 { 68 uint32_t SliceCmdBatchOffset; 69 }; 70 struct PicHeaderRplParam 71 { 72 uint8_t numRefForList0 = 0; 73 uint8_t numRefForList1 = 0; 74 uint8_t refPicListFrameIdx[2][vvcMaxNumRefFrame] = {}; 75 uint16_t refPicListFrameFlag[2][vvcMaxNumRefFrame] = {}; 76 uint8_t stRefPicFlag[2][vvcMaxNumRefFrame] = {}; 77 uint8_t rprConstraintsActiveFlag[2][vvcMaxNumRefFrame] = {}; 78 uint8_t unavailableRefPic[2][vvcMaxNumRefFrame] = {}; 79 int16_t diffPicOrderCnt[2][vvcMaxNumRefFrame] = {}; 80 }; 81 82 struct VvcS2lSubpicParam 83 { 84 uint16_t m_spsSubpicCtuTopLeftX; // [0..526] 85 uint16_t m_spsSubpicCtuTopLeftY; // [0..526] 86 uint16_t m_spsSubpicWidthMinus1; // [0..511] 87 uint16_t m_spsSubpicHeightMinus1; // [0..511] 88 uint16_t m_subpicIdVal; // [0..2^16-1] 89 90 union 91 { 92 struct 93 { 94 uint16_t m_spsSubpicTreatedAsPicFlag : 1; // [0..1] 95 uint16_t m_spsLoopFilterAcrossSubpicEnabledFlag : 1; // [0..1] 96 uint16_t m_reserved14bits : 14; // [0] 97 } m_fields; 98 uint16_t m_value; 99 } m_subPicFlags; 100 101 //Additional params to reconstruct partition for Rect slice mode and none-single slice per subpic case 102 uint16_t m_endCtbX; //SubPic range right border in CTU column 103 uint16_t m_endCtbY; //SubPic range bottom border in CTU row 104 int16_t m_numSlices; //Accumulated slice number in current subpic 105 //uint16_t *m_sliceIdx; //Pointer to an array of slice index in scan order in picture 106 }; 107 108 struct HucVvcS2lPicBss 109 { 110 // SPS info 111 uint16_t m_spsPicWidthMaxInLumaSamples; // [8..16888] 112 uint16_t m_spsPicHeightMaxInLumaSamples; // [8..16888] 113 114 uint16_t m_spsNumSubpicsMinus1; // [0..599] 115 uint8_t m_spsSubpicIdLenMinus1; // [0..15] 116 uint8_t m_spsChromaFormatIdc; // [1] 117 uint8_t m_spsBitdepthMinus8; // [0..2] 118 uint8_t m_spsLog2CtuSizeMinus5; // [0..2] 119 uint8_t m_spsLog2MaxPicOrderCntLsbMinus4; // [0..12] 120 uint8_t m_spsLog2MinLumaCodingBlockSizeMinus2; // [0..4] 121 uint8_t m_spsPocMsbCycleLenMinus1; // [0..27] 122 uint8_t m_numExtraPhBits; // [0..15] 123 uint8_t m_numExtraShBits; // [0..15] 124 uint8_t m_spsLog2TransformSkipMaxSizeMinus2; // [0..3] 125 126 int8_t m_chromaQpTable[3][76]; // [-12..63] 127 128 uint8_t m_spsNumRefPicLists[2]; // [0..64] 129 uint8_t m_spsSixMinusMaxNumMergeCand; // [0..5] 130 uint8_t m_spsFiveMinusMaxNumSubblockMergeCand; // [0..5] 131 uint8_t m_spsMaxNumMergeCandMinusMaxNumGpmCand; // [0..4] 132 uint8_t m_spsLog2ParallelMergeLevelMinus2; // [0..5] 133 uint8_t m_spsMinQpPrimeTs; // [0..8] 134 uint8_t m_spsSixMinusMaxNumIbcMergeCand; // [0..5] 135 uint8_t m_spsNumLadfIntervalsMinus2; // [0..3] 136 int8_t m_spsLadfLowestIntervalQpOffset; // [-63..63] 137 int8_t m_spsLadfQpOffset[4]; // [-63..63] 138 uint16_t m_spsLadfDeltaThresholdMinus1[4]; // [0..1021] 139 uint8_t m_spsNumVerVirtualBoundaries; // [0..3] 140 uint8_t m_spsNumHorVirtualBoundaries; // [0..3] 141 uint8_t m_spsLog2DiffMinQtMinCbIntraSliceLuma; // [0..4] 142 uint8_t m_spsMaxMttHierarchyDepthIntraSliceLuma; // [0..10] 143 uint16_t m_spsVirtualBoundaryPosXMinus1[3]; // [0..2109] 144 uint16_t m_spsVirtualBoundaryPosYMinus1[3]; // [0..2109] 145 uint8_t m_spsLog2DiffMaxBtMinQtIntraSliceLuma; // [0..5] 146 uint8_t m_spsLog2DiffMaxTtMinQtIntraSliceLuma; // [0..4] 147 uint8_t m_spsLog2DiffMinQtMinCbIntraSliceChroma; // [0..4] 148 uint8_t m_spsMaxMttHierarchyDepthIntraSliceChroma; // [0..10] 149 uint8_t m_spsLog2DiffMaxBtMinQtIntraSliceChroma; // [0..4] 150 uint8_t m_spsLog2DiffMaxTtMinQtIntraSliceChroma; // [0..4] 151 uint8_t m_spsLog2DiffMinQtMinCbInterSlice; // [0..4] 152 uint8_t m_spsMaxMttHierarchyDepthInterSlice; // [0..10] 153 uint8_t m_spsLog2DiffMaxBtMinQtInterSlice; // [0..5] 154 uint8_t m_spsLog2DiffMaxTtMinQtInterSlice; // [0..4] 155 union 156 { 157 struct 158 { 159 uint32_t m_spsSubpicInfoPresentFlag : 1; // [0..1] 160 uint32_t m_spsIndependentSubpicsFlag : 1; // [0..1] 161 uint32_t m_spsSubpicSameSizeFlag : 1; // [0..1] 162 uint32_t m_spsEntropyCodingSyncEnabledFlag : 1; // [0..1] 163 uint32_t m_spsEntryPointOffsetsPresentFlag : 1; // [0..1] 164 uint32_t m_spsPocMsbCycleFlag : 1; // [0..1] 165 uint32_t m_spsPartitionConstraintsOverrideEnabledFlag : 1; // [0..1] 166 uint32_t m_spsQtbttDualTreeIntraFlag : 1; // [0..1] 167 uint32_t m_spsMaxLumaTransformSize64Flag : 1; // [0..1] 168 uint32_t m_spsTransformSkipEnabledFlag : 1; // [0..1] 169 uint32_t m_spsBdpcmEnabledFlag : 1; // [0..1] 170 uint32_t m_spsMtsEnabledFlag : 1; // [0..1] 171 uint32_t m_spsExplicitMtsIntraEnabledFlag : 1; // [0..1] 172 uint32_t m_spsExplicitMtsInterEnabledFlag : 1; // [0..1] 173 uint32_t m_spsLfnstEnabledFlag : 1; // [0..1] 174 uint32_t m_spsJointCbcrEnabledFlag : 1; // [0..1] 175 uint32_t m_spsSameQpTableForChromaFlag : 1; // [0..1] 176 uint32_t m_spsSaoEnabledFlag : 1; // [0..1] 177 uint32_t m_spsAlfEnabledFlag : 1; // [0..1] 178 uint32_t m_spsCcalfEnabledFlag : 1; // [0..1] 179 uint32_t m_spsLmcsEnabledFlag : 1; // [0..1] 180 uint32_t m_spsLongTermRefPicsFlag : 1; // [0..1] 181 uint32_t m_spsInterLayerPredictionEnabledFlag : 1; // [0..1] 182 uint32_t m_spsIdrRplPresentFlag : 1; // [0..1] 183 184 uint32_t m_spsTemporalMvpEnabledFlag : 1; // [0..1] 185 uint32_t m_spsSbtmvpEnabledFlag : 1; // [0..1] 186 uint32_t m_spsAmvrEnabledFlag : 1; // [0..1] 187 uint32_t m_spsBdofEnabledFlag : 1; // [0..1] 188 uint32_t m_spsBdofControlPresentInPhFlag : 1; // [0..1] 189 uint32_t m_spsSmvdEnabledFlag : 1; // [0..1] 190 uint32_t m_spsDmvrEnabledFlag : 1; // [0..1] 191 uint32_t m_spsDmvrControlPresentInPhFlag : 1; // [0..1] 192 uint32_t m_spsMmvdEnabledFlag : 1; // [0..1] 193 uint32_t m_spsMmvdFullpelOnlyEnabledFlag : 1; // [0..1] 194 uint32_t m_spsSbtEnabledFlag : 1; // [0..1] 195 uint32_t m_spsAffineEnabledFlag : 1; // [0..1] 196 uint32_t m_sps6paramAffineEnabledFlag : 1; // [0..1] 197 uint32_t m_spsAffineAmvrEnabledFlag : 1; // [0..1] 198 uint32_t m_spsAffineProfEnabledFlag : 1; // [0..1] 199 uint32_t m_spsProfControlPresentInPhFlag : 1; // [0..1] 200 uint32_t m_spsBcwEnabledFlag : 1; // [0..1] 201 uint32_t m_spsCiipEnabledFlag : 1; // [0..1] 202 uint32_t m_spsGpmEnabledFlag : 1; // [0..1] 203 uint32_t m_spsIspEnabledFlag : 1; // [0..1] 204 uint32_t m_spsMrlEnabledFlag : 1; // [0..1] 205 uint32_t m_spsMipEnabledFlag : 1; // [0..1] 206 uint32_t m_spsCclmEnabledFlag : 1; // [0..1] 207 uint32_t m_spsChromaHorizontalCollocatedFlag : 1; // [0..1] 208 uint32_t m_spsChromaVerticalCollocatedFlag : 1; // [0..1] 209 210 uint32_t m_spsPaletteEnabledFlag : 1; // [0..1] 211 uint32_t m_spsActEnabledFlag : 1; // [0..1] 212 uint32_t m_spsIbcEnabledFlag : 1; // [0..1] 213 uint32_t m_spsLadfEnabledFlag : 1; // [0..1] 214 uint32_t m_spsExplicitScalingListEnabledFlag : 1; // [0..1] 215 uint32_t m_spsScalingMatrixForLfnstDisabledFlag : 1; // [0..1] 216 uint32_t m_spsScalingMatrixForAlternativeColourSpaceDisabledFlag : 1; // [0..1] 217 uint32_t m_spsScalingMatrixDesignatedColourSpaceFlag : 1; // [0..1] 218 uint32_t m_spsDepQuantEnabledFlag : 1; // [0..1] 219 uint32_t m_spsSignDataHidingEnabledFlag : 1; // [0..1] 220 uint32_t m_spsVirtualBoundariesEnabledFlag : 1; // [0..1] 221 uint32_t m_spsVirtualBoundariesPresentFlag : 1; // [0..1] 222 uint32_t m_spsWeightedPredFlag : 1; // [0..1] 223 uint32_t m_spsWeightedBipredFlag : 1; // [0..1] 224 uint32_t m_spsExtensionFlag : 1; // [0..1] 225 }; 226 uint32_t value[2]; 227 }m_picSpsFlags; 228 229 230 // PPS info 231 uint16_t m_ppsPicWidthInLumaSamples; // [8..16888] 232 uint16_t m_ppsPicHeightInLumaSamples; // [8..16888] 233 uint8_t m_numVerVirtualBoundaries; // [0..3] 234 uint8_t m_numHorVirtualBoundaries; // [0..3] 235 uint16_t m_virtualBoundaryPosX[3]; // [0..16880] 236 uint16_t m_virtualBoundaryPosY[3]; // [0..16880] 237 238 int32_t m_ppsScalingWinLeftOffset; 239 int32_t m_ppsScalingWinRightOffset; 240 int32_t m_ppsScalingWinTopOffset; 241 int32_t m_ppsScalingWinBottomOffset; 242 243 uint8_t m_ppsNumExpTileColumnsMinus1; // [0..19] 244 uint16_t m_ppsNumExpTileRowsMinus1; // [0..439] 245 uint16_t m_ppsNumSlicesInPicMinus1; // [0..599] 246 uint8_t m_ppsNumRefIdxDefaultActiveMinus1[2]; // [0..14] 247 uint16_t m_ppsPicWidthMinusWraparoundOffset; // [0..4188] 248 int8_t m_ppsInitQpMinus26; // [-38..37] 249 int8_t m_ppsCbQpOffset; // [-12..12] 250 int8_t m_ppsCrQpOffset; // [-12..12] 251 int8_t m_ppsJointCbcrQpOffsetValue; // [-12..12] 252 uint8_t m_ppsChromaQpOffsetListLenMinus1; // [0..5] 253 int8_t m_ppsCbQpOffsetList[6]; // [-12..12] 254 int8_t m_ppsCrQpOffsetList[6]; // [-12..12] 255 int8_t m_ppsJointCbcrQpOffsetList[6]; // [-12..12] 256 int8_t m_ppsLumaBetaOffsetDiv2; // [-12..12] 257 int8_t m_ppsLumaTcOffsetDiv2; // [-12..12] 258 int8_t m_ppsCbBetaOffsetDiv2; // [-12..12] 259 int8_t m_ppsCbTcOffsetDiv2; // [-12..12] 260 int8_t m_ppsCrBetaOffsetDiv2; // [-12..12] 261 int8_t m_ppsCrTcOffsetDiv2; // [-12..12] 262 uint16_t m_reserved16b; // [0] 263 uint8_t m_numScalingMatrixBuffers; // [0..8] 264 uint8_t m_numAlfBuffers; // [0..8] 265 uint8_t m_numLmcsBuffers; // [0..4] 266 uint8_t m_numRefPicListStructs; // [0..128] 267 uint16_t m_numSliceStructsMinus1; // [0..599] 268 269 union 270 { 271 struct 272 { 273 uint32_t m_ppsOutputFlagPresentFlag : 1; // [0..1] 274 uint32_t m_ppsLoopFilterAcrossTilesEnabledFlag : 1; // [0..1] 275 uint32_t m_ppsRectSliceFlag : 1; // [0..1] 276 uint32_t m_ppsSingleSlicePerSubpicFlag : 1; // [0..1] 277 uint32_t m_ppsLoopFilterAcrossSlicesEnabledFlag : 1; // [0..1] 278 uint32_t m_ppsCabacInitPresentFlag : 1; // [0..1] 279 uint32_t m_ppsRpl1IdxPresentFlag : 1; // [0..1] 280 uint32_t m_ppsWeightedPredFlag : 1; // [0..1] 281 uint32_t m_ppsWeightedBipredFlag : 1; // [0..1] 282 uint32_t m_ppsRefWraparoundEnabledFlag : 1; // [0..1] 283 uint32_t m_ppsCuQpDeltaEnabledFlag : 1; // [0..1] 284 uint32_t m_ppsChroma_toolOffsetsPresentFlag : 1; // [0..1] 285 uint32_t m_ppsSliceChromaQpOffsetsPresentFlag : 1; // [0..1] 286 uint32_t m_ppsCuChromaQpOffsetListEnabledFlag : 1; // [0..1] 287 uint32_t m_ppsDeblockingFilterOverrideEnabledFlag : 1; // [0..1] 288 uint32_t m_ppsDeblockingFilterDisabledFlag : 1; // [0..1] 289 uint32_t m_ppsDbfInfoInPhFlag : 1; // [0..1] 290 uint32_t m_ppsRplInfoInPhFlag : 1; // [0..1] 291 uint32_t m_ppsSaoInfoInPhFlag : 1; // [0..1] 292 uint32_t m_ppsAlfInfoInPhFlag : 1; // [0..1] 293 uint32_t m_ppsWpInfoInPhFlag : 1; // [0..1] 294 uint32_t m_ppsQpDeltaInfoInPhFlag : 1; // [0..1] 295 uint32_t m_ppsPictureHeaderExtensionPresentFlag : 1; // [0..1] 296 uint32_t m_ppsSliceHeaderExtensionPresentFlag : 1; // [0..1] 297 }; 298 uint32_t value; 299 }m_picPpsFlags; 300 301 // PH info 302 uint8_t m_phNumAlfApsIdsLuma; // [0..7] 303 uint8_t m_phAlfApsIdLuma[7]; // [0..7] 304 uint8_t m_phAlfApsIdChroma; // [0..7] 305 uint8_t m_phAlfCcCbApsId; // [0..7] 306 uint8_t m_phAlfCcCrApsId; // [0..7] 307 uint8_t m_phLmcsApsId; // [0..3] 308 uint8_t m_phScalingListApsId; // [0..7] 309 uint8_t m_phLog2DiffMinQtMinCbIntraSliceLuma; // [0..4] 310 uint8_t m_phMaxMtt_hierarchyDepthIntraSliceLuma; // [0..10] 311 uint8_t m_phLog2DiffMaxBtMinQtIntraSliceLuma; // [0..5] 312 uint8_t m_phLog2DiffMax_ttMinQtIntraSliceLuma; // [0..4] 313 uint8_t m_phLog2DiffMinQtMinCbIntraSliceChroma; // [0..4] 314 uint8_t m_phMaxMtt_hierarchyDepthIntraSliceChroma; // [0..10] 315 uint8_t m_phLog2DiffMaxBtMinQtIntraSliceChroma; // [0..4] 316 uint8_t m_phLog2DiffMax_ttMinQtIntraSliceChroma; // [0..4] 317 uint8_t m_phCuQpDeltaSubdivIntraSlice; // [0..30] 318 uint8_t m_phCuChromaQpOffsetSubdivIntraSlice; // [0..30] 319 uint8_t m_phLog2DiffMinQtMinCbInterSlice; // [0..4] 320 uint8_t m_phMaxMtt_hierarchyDepthInterSlice; // [0..10] 321 uint8_t m_phLog2DiffMaxBtMinQtInterSlice; // [0..5] 322 uint8_t m_phLog2DiffMax_ttMinQtInterSlice; // [0..4] 323 uint8_t m_phCuQpDeltaSubdivInterSlice; // [0..30] 324 uint8_t m_phCuChromaQpOffsetSubdivInterSlice; // [0..30] 325 uint8_t m_phCollocatedRefIdx; // [0..14] 326 int8_t m_phQpDelta; // [-75..75] 327 int8_t m_phLumaBetaOffsetDiv2; // [-12..12] 328 int8_t m_phLumaTcOffsetDiv2; // [-12..12] 329 int8_t m_phCbBetaOffsetDiv2; // [-12..12] 330 int8_t m_phCbTcOffsetDiv2; // [-12..12] 331 int8_t m_phCrBetaOffsetDiv2; // [-12..12] 332 int8_t m_phCrTcOffsetDiv2; // [-12..12] 333 334 union 335 { 336 struct 337 { 338 uint32_t m_phNonRefPicFlag : 1; // [0..1] 339 uint32_t m_phInterSliceAllowedFlag : 1; // [0..1] 340 uint32_t m_phAlfEnabledFlag : 1; // [0..1] 341 uint32_t m_phAlfCbEnabledFlag : 1; // [0..1] 342 uint32_t m_phAlfCrEnabledFlag : 1; // [0..1] 343 uint32_t m_phAlfCcCbEnabledFlag : 1; // [0..1] 344 uint32_t m_phAlfCcCrEnabledFlag : 1; // [0..1] 345 uint32_t m_phLmcsEnabledFlag : 1; // [0..1] 346 uint32_t m_phChromaResidualScaleFlag : 1; // [0..1] 347 uint32_t m_phExplicitScalingListEnabledFlag : 1; // [0..1] 348 uint32_t m_phVirtualBoundariesPresentFlag : 1; // [0..1] 349 uint32_t m_phTemporalMvpEnabledFlag : 1; // [0..1] 350 uint32_t m_numRefEntries0RplIdx0LargerThan0 : 1; // [0..1] 351 uint32_t m_numRefEntries1RplIdx1LargerThan0 : 1; // [0..1] 352 uint32_t m_phCollocatedFromL0Flag : 1; // [0..1] 353 uint32_t m_phMmvdFullpelOnlyFlag : 1; // [0..1] 354 uint32_t m_phMvdL1ZeroFlag : 1; // [0..1] 355 uint32_t m_phBdofDisabledFlag : 1; // [0..1] 356 uint32_t m_phDmvrDisabledFlag : 1; // [0..1] 357 uint32_t m_phProfDisabledFlag : 1; // [0..1] 358 uint32_t m_phJointCbcrSignFlag : 1; // [0..1] 359 uint32_t m_phSaoLumaEnabledFlag : 1; // [0..1] 360 uint32_t m_phSaoChromaEnabledFlag : 1; // [0..1] 361 uint32_t m_phDeblockingFilterDisabledFlag : 1; // [0..1] 362 }; 363 uint32_t value; 364 } m_picPhFlags; 365 366 // reference lists 367 int32_t m_picOrderCntVal; // [-2^31 .. 2^31-1] 368 int32_t m_refFramePocList[15]; // [-2^31 .. 2^31-1] 369 uint32_t m_rprConstraintsActiveFlag[2][15]; 370 uint32_t unavailableRefPic[2][15]; 371 372 uint32_t m_numSlices; //Slice Num of each Pic [1...600] 373 uint16_t m_picWidthInCtu; 374 uint16_t m_picHeightInCtu; 375 376 struct 377 { 378 uint16_t m_tileRows; 379 uint16_t m_tileCols; 380 TileRowDesc m_tileRow[440]; 381 TileColDesc m_tileCol[20]; 382 } tileCodingParam; 383 384 struct 385 { 386 uint8_t m_apsAdaptationParameterSetId; // [0..7] 387 uint8_t m_reserved8b; // [0] 388 uint8_t m_lmcsMinBinIdx; // [0..15] 389 uint8_t m_lmcsDeltaMaxBinIdx; // [0..15] 390 int16_t m_lmcsDeltaCW[16]; // [-32767..32767] 391 int8_t m_lmcsDeltaCrs; // [-7..7] 392 uint32_t m_reserved32b[8]; // [0] 393 } m_vvcLmcsData; 394 395 struct 396 { 397 uint16_t m_lmcsCW[16]; 398 int32_t m_scaleCoeff[16]; 399 int32_t m_invScaleCoeff[16]; 400 int32_t m_chromaScaleCoeff[16]; 401 int16_t m_lmcsPivot[17]; 402 } m_vvcLmcsShapeInfo; 403 404 PicHeaderRplParam m_phRplInfoParam; 405 406 uint8_t m_alfChromaNumAltFiltersMinus1[8]; 407 uint8_t m_alfCcCbFiltersSignalledMinus1[8]; 408 uint8_t m_alfCcCrFiltersSignalledMinus1[8]; 409 uint8_t m_isMultiSubPicParam; 410 411 struct 412 { 413 uint8_t reserve_0; 414 uint16_t reserve_1; 415 uint32_t reserve_2; 416 uint32_t reserve_3; 417 } reserve; 418 }; 419 420 struct VvcS2lBss 421 { 422 uint32_t m_dmemSize; 423 // Platfrom information 424 uint32_t ProductFamily; 425 uint16_t RevId; 426 427 uint8_t Reserved; 428 uint8_t isDmaCopyEnable; 429 uint8_t isCp; 430 431 // Picture level DMEM data 432 HucVvcS2lPicBss VvcPictureBss; 433 434 uint32_t sliceBsParamOffset; // offset for slice bitstream param in sliceLvlParam 435 uint32_t sliceBsParamNumber; // number of slice bitstream param in sliceLvlParam 436 uint32_t sliceBbParamOffset; // offset for slice batch buffer param in sliceLvlParam 437 uint32_t sliceBbParamNumber; // number of slice batch buffer param in sliceLvlParam 438 uint32_t subPicParamOffset; // offset for sub pic param in sliceLvlParam 439 uint32_t subPicParamNumber; // number of sub pic param in sliceLvlParam 440 uint32_t slicePartitionParamNumber; // number of slice partition param in sliceLvlParam 441 442 // Slice level DMEM data, includes below data in order 443 // 1. slice bitstream param 444 // 2. slice batch buffer param 445 // 3. sub picture param 446 // 4. slice partition praram 447 uint32_t sliceLvlParam[1]; 448 }; 449 450 struct VvcS2lExtraBss 451 { 452 union 453 { 454 struct VvcS2lBssRplInfo 455 { 456 uint8_t m_listIdx; // [0..1] 457 uint8_t m_rplsIdx; // [0.. spsNumRefPicLists[listIdx]] 458 uint8_t m_numRefEntries; // [0..29] 459 uint8_t m_ltrpInHeaderFlag; // [0..1] 460 uint8_t m_stRefPicFlag[29]; // [0..1] 461 uint16_t m_absDeltaPocSt[29]; // [0.. 2^15 - 1] 462 uint8_t m_strpEntrySignFlag[29]; // [0..1] 463 uint16_t m_rplsPocLsbLt[29]; // [0..2^16-1] 464 465 uint32_t m_reserved32b[16]; // [0] leave space for multilayer enabling 466 } rplInfo; 467 uint8_t align64[MOS_ALIGN_CEIL(sizeof(struct VvcS2lBssRplInfo), 64)]; 468 } m_rplInfo[vvcMaxRplNum]; 469 470 union 471 { 472 struct VvcS2lBssPartitionInfo 473 { 474 int32_t m_numCtusInCurrSlice; //!< number of CTUs in current slice 475 476 //Rect slices params 477 uint16_t m_tileIdx; //!< tile index corresponding to the first CTU in the slice 478 uint32_t m_numSlicesInTile; //!< number of slices in current tile for the special case of multiple slices inside a single tile 479 uint16_t m_sliceWidthInTiles; //!< slice width in units of tiles 480 uint16_t m_sliceHeightInTiles; //!< slice height in units of tiles 481 uint16_t m_sliceHeightInCtu; //!< slice height in units of CTUs for the special case of multiple slices inside a single tile 482 483 //Additional params on SubPic v.s. Slice 484 uint32_t m_sliceStartCtbx; 485 uint32_t m_sliceStartCtby; 486 uint16_t m_subPicIdx; 487 uint16_t m_sliceIdxInSubPic; 488 uint32_t m_sliceEndCtbx; //! valid only for rect slice mode 489 uint32_t m_sliceEndCtby; //! valid only for rect slice mode 490 491 //Only used for rec slice mode 492 uint32_t m_multiSlicesInTileFlag; 493 uint16_t m_startTileX; 494 uint16_t m_startTileY; 495 496 //for command programming 497 uint32_t m_topSliceInTileFlag; //! valid only for multiple slices in one tile case, others ignore 498 uint32_t m_bottomSliceInTileFlag; //! valid only for multiple slices in one tile case, others ignore 499 }partitionInfo; 500 uint8_t align64[MOS_ALIGN_CEIL(sizeof(struct VvcS2lBssPartitionInfo), 64)]; 501 } m_slicePartitionParam[CODECHAL_VVC_MAX_NUM_SLICES_LVL_6]; 502 503 union 504 { 505 struct VvcWeightedPredInfoInPH 506 { 507 uint8_t m_lumaLog2WeightDenom; // [0..7] 508 int8_t m_deltaChromaLog2WeightDenom; // [-7..7] 509 uint8_t m_numL0Weights; // [0..15] 510 uint8_t m_lumaWeightL0Flag[15]; // [0..1] 511 uint8_t m_chromaWeightL0Flag[15]; // [0..1] 512 int8_t m_deltaLumaWeightL0[15]; // [-128..127] 513 int8_t m_lumaOffsetL0[15]; // [-128..127] 514 int8_t m_deltaChromaWeightL0[15][2]; // [-128..127] 515 int16_t m_deltaChromaOffsetL0[15][2]; // [-512..508] 516 uint8_t m_numL1Weights; // [0..15] 517 uint8_t m_lumaWeightL1Flag[15]; // [0..1] 518 uint8_t m_chromaWeightL1Flag[15]; // [0..1] 519 int8_t m_deltaLumaWeightL1[15]; // [-128..127] 520 int8_t m_lumaOffsetL1[15]; // [-128..127] 521 int8_t m_deltaChromaWeightL1[15][2]; // [-128..127] 522 int16_t m_deltaChromaOffsetL1[15][2]; // [-512..508] 523 }paramField; 524 uint8_t align64[MOS_ALIGN_CEIL(sizeof(struct VvcWeightedPredInfoInPH), 64)]; 525 }m_wpInfoinPH; 526 }; 527 528 class VvcDecodeS2LPkt : public DecodeHucBasic, public mhw::vdbox::huc::Itf::ParSetting 529 { 530 public: VvcDecodeS2LPkt(MediaPipeline * pipeline,MediaTask * task,CodechalHwInterfaceNext * hwInterface)531 VvcDecodeS2LPkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface) 532 : DecodeHucBasic(pipeline, task, hwInterface) 533 { 534 if (pipeline != nullptr) 535 { 536 m_statusReport = pipeline->GetStatusReportInstance(); 537 m_vvcPipeline = dynamic_cast<VvcPipeline *>(pipeline); 538 } 539 if (m_vvcPipeline != nullptr) 540 { 541 m_featureManager = m_vvcPipeline->GetFeatureManager(); 542 m_allocator = m_vvcPipeline->GetDecodeAllocator(); 543 m_decodecp = m_vvcPipeline->GetDecodeCp(); 544 } 545 546 if (hwInterface != nullptr) 547 { 548 m_hwInterface = hwInterface; 549 m_osInterface = hwInterface->GetOsInterface(); 550 m_miItf = std::static_pointer_cast<mhw::mi::Itf>(hwInterface->GetMiInterfaceNext()); 551 m_vdencItf = std::static_pointer_cast<mhw::vdbox::vdenc::Itf>(hwInterface->GetVdencInterfaceNext()); 552 m_hucItf = std::static_pointer_cast<mhw::vdbox::huc::Itf>(hwInterface->GetHucInterfaceNext()); 553 554 if (m_hwInterface != nullptr) 555 { 556 m_vvcpItf = std::static_pointer_cast<mhw::vdbox::vvcp::Itf>(m_hwInterface->GetVvcpInterfaceNext()); 557 } 558 } 559 } ~VvcDecodeS2LPkt()560 virtual ~VvcDecodeS2LPkt() {} 561 562 //! 563 //! \brief Add the command sequence into the commandBuffer and 564 //! and return to the caller task 565 //! \param [in] commandBuffer 566 //! Pointer to the command buffer which is allocated by caller 567 //! \return MOS_STATUS 568 //! MOS_STATUS_SUCCESS if success, else fail reason 569 //! 570 virtual MOS_STATUS Submit(MOS_COMMAND_BUFFER *commandBuffer, uint8_t packetPhase = otherPacket) override; 571 572 //! 573 //! \brief Initialize the media packet, allocate required resources 574 //! \return MOS_STATUS 575 //! MOS_STATUS_SUCCESS if success, else fail reason 576 //! 577 virtual MOS_STATUS Init() override; 578 579 //! 580 //! \brief Prepare interal parameters, should be invoked for each frame 581 //! \return MOS_STATUS 582 //! MOS_STATUS_SUCCESS if success, else fail reason 583 //! 584 virtual MOS_STATUS Prepare() override; 585 586 //! 587 //! \brief Calculate Command Size 588 //! 589 //! \param [in, out] commandBufferSize 590 //! requested size 591 //! \param [in, out] requestedPatchListSize 592 //! requested size 593 //! \return MOS_STATUS 594 //! status 595 //! 596 virtual MOS_STATUS CalculateCommandSize( 597 uint32_t &commandBufferSize, 598 uint32_t &requestedPatchListSize) override; 599 600 uint32_t GetSliceBatchOffset(uint32_t sliceNum); 601 602 //! 603 //! \brief Get Packet Name 604 //! \return std::string 605 //! GetPacketName()606 virtual std::string GetPacketName() override 607 { 608 return "VVC_S2L"; 609 } 610 611 virtual MHW_SETPAR_DECL_HDR(HUC_DMEM_STATE); 612 virtual MHW_SETPAR_DECL_HDR(HUC_IND_OBJ_BASE_ADDR_STATE); 613 virtual MHW_SETPAR_DECL_HDR(HUC_VIRTUAL_ADDR_STATE); 614 615 virtual MOS_STATUS AddCmd_HUC_STREAM_OBJECT(MOS_COMMAND_BUFFER &cmdBuffer, CodecVvcSliceParams sliceParams); 616 virtual MOS_STATUS AddCmd_HUC_START(MOS_COMMAND_BUFFER &cmdBuffer, bool laststreamobject); 617 virtual MOS_STATUS AddCmd_HUC_PIPE_MODE_SELECT(MOS_COMMAND_BUFFER &cmdBuffer); 618 virtual MOS_STATUS AddCmd_HUC_IMEM_STATE(MOS_COMMAND_BUFFER &cmdBuffer); 619 620 virtual MOS_STATUS Execute(MOS_COMMAND_BUFFER &cmdBuffer, bool prologNeeded) = 0; 621 622 virtual MOS_STATUS AllocateResources(); 623 624 virtual MOS_STATUS PackPictureLevelCmds(MOS_COMMAND_BUFFER &cmdBuffer); 625 626 virtual MOS_STATUS PackSliceLevelCmds(MOS_COMMAND_BUFFER &cmdBuffer); 627 628 virtual MOS_STATUS ConstructLmcsReshaper() const; 629 630 MOS_STATUS VdPipelineFlush(MOS_COMMAND_BUFFER &cmdBuffer); 631 632 MOS_STATUS SetDmemBuffer(); 633 634 virtual MOS_STATUS Destroy() override; 635 GetHucStatusVvcS2lFailureMask()636 virtual uint32_t GetHucStatusVvcS2lFailureMask() 637 { 638 return m_hucStatusVvcS2lFailureMask; 639 } 640 641 PMOS_BUFFER GetS2lDmemBuffer(); 642 643 protected: 644 //! 645 //! \brief Calculate Command Buffer Size 646 //! 647 //! \return uint32_t 648 //! Command buffer size calculated 649 //! 650 virtual uint32_t CalculateCommandBufferSize(); 651 652 //! 653 //! \brief Calculate Patch List Size 654 //! 655 //! \return uint32_t 656 //! Patchlist size calculated 657 //! 658 virtual uint32_t CalculatePatchListSize(); 659 660 MOS_STATUS SetRefIdxStateCmd(PicHeaderRplParam& phRplInfo); //This Only Used in RPL info in PH mode in S2L 661 662 void CalculateVvcSliceLvlCmdSize(); 663 664 virtual MOS_STATUS SetHucDmemPictureBss(HucVvcS2lPicBss &hucVvcS2LPicBss); 665 virtual MOS_STATUS SetHucDmemSliceBss( 666 VvcS2lBss* VvcS2lBss); 667 virtual MOS_STATUS SetExtraDataBuffer(); 668 MOS_STATUS AddHucCpState(MOS_COMMAND_BUFFER &cmdBuffer, uint32_t index, CodecVvcSliceParams &sliceParams); 669 MOS_STATUS FillPhRplInfoArray(uint8_t listIdx, uint8_t entryCounts, PicHeaderRplParam &phRplInfo); 670 671 #if USE_CODECHAL_DEBUG_TOOL 672 virtual MOS_STATUS DumpHucS2l(); 673 #endif 674 675 VvcPipeline *m_vvcPipeline = nullptr; 676 VvcBasicFeature *m_vvcBasicFeature = nullptr; 677 const CodecVvcPicParams *m_vvcPicParams = nullptr; //!< Pointer to picture parameter 678 CodecVvcSliceParams *m_vvcSliceParams = nullptr; 679 MediaFeatureManager *m_featureManager = nullptr; 680 DecodeAllocator *m_allocator = nullptr; 681 PMOS_INTERFACE m_osInterface = nullptr; 682 CodechalHwInterfaceNext *m_hwInterface = nullptr; 683 DecodeBasicFeature *m_basicFeature = nullptr; 684 DecodeCpInterface *m_decodecp = nullptr; 685 std::shared_ptr<mhw::vdbox::huc::Itf> m_hucItf = nullptr; 686 687 uint32_t m_dmemBufferSize = 0; //!< Size of DMEM buffer 688 uint32_t m_dmemTransferSize = 0; //!< Transfer size of current DMEM buffer 689 690 uint32_t m_pictureStatesSize = 0; 691 uint32_t m_picturePatchListSize = 0; 692 uint32_t m_sliceStatesSize = 0; 693 uint32_t m_slicePatchListSize = 0; 694 695 MOS_BUFFER *m_vvcS2lExtraDataBuffer = nullptr; 696 697 BufferArray *m_vvcS2lExtraBufferArray = nullptr; 698 BufferArray *m_vvcS2lDmemBufferArray = nullptr; 699 700 static constexpr uint32_t m_vdboxHucVvcS2lKernelDescriptor = 20; //!< Huc VVC S2L Kernel descriptor 701 702 static const uint32_t m_hucStatusInvalidMask = 0; //!< Invalid mask of Huc status MMIO 703 uint32_t m_hucStatusMask = m_hucStatusInvalidMask; //!< MMIO mask for HuC status 704 uint32_t m_hucStatus2Mask = m_hucStatusInvalidMask; //!< MMIO mask for HuC status2 705 706 static const uint32_t m_hucStatusVvcS2lFailureMask = 0x8000; //!< HuC Status VVC short to long failure mask 707 //!< bit14: uKernal uOS Status, FW will write 0 if has critical error 708 709 710 uint32_t m_sliceBsParamOffset = 0; // offset for slice bitstream param in sliceLvlParam 711 uint32_t m_sliceBsParamNumber = 0; // number of slice bitstream param in sliceLvlParam 712 uint32_t m_sliceBbParamOffset = 0; // offset for slice batch buffer param in sliceLvlParam 713 uint32_t m_sliceBbParamNumber = 0; // number of slice batch buffer param in sliceLvlParam 714 uint32_t m_subPicParamOffset = 0; // offset for sub pic param in sliceLvlParam 715 uint32_t m_subPicParamNumber = 0; // number of sub pic param in sliceLvlParam 716 uint32_t m_slicePartitionParamNumber = 0; // number of slice partition param in sliceLvlParam 717 uint32_t m_sliceParamDynamicSize = 0; 718 719 uint32_t m_vvcpSliceCmdSize = 0; //Slice Lvl Command Size 720 uint32_t m_tailingBsReadSize = 0; //SW WA for HuC Emu Byte Removal HW issue 721 722 bool m_isMultiSubPicParam = false; 723 724 std::shared_ptr<mhw::vdbox::vvcp::Itf> m_vvcpItf = nullptr; 725 726 MEDIA_CLASS_DEFINE_END(decode__VvcDecodeS2LPkt) 727 }; 728 729 730 731 } // namespace decode 732 #endif // !__DECODE_VVC_S2L_PACKET_H__ 733