| 1 | /* |
| 2 | * Copyright (c) 2018-2022, 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_hevc_pipeline.cpp |
| 24 | //! \brief Defines the interface for hevc decode pipeline |
| 25 | //! |
| 26 | #include "decode_hevc_pipeline.h" |
| 27 | #include "decode_utils.h" |
| 28 | #include "codechal_setting.h" |
| 29 | #include "decode_hevc_phase_s2l.h" |
| 30 | #include "decode_hevc_phase_long.h" |
| 31 | #include "decode_hevc_phase_front_end.h" |
| 32 | #include "decode_hevc_phase_back_end.h" |
| 33 | #include "decode_hevc_phase_real_tile.h" |
| 34 | #include "decode_hevc_feature_manager.h" |
| 35 | #include "decode_hevc_downsampling_packet.h" |
| 36 | #include "media_debug_fast_dump.h" |
| 37 | #include "decode_hevc_debug_packet.h" |
| 38 | |
| 39 | namespace decode { |
| 40 | |
| 41 | HevcPipeline::HevcPipeline(CodechalHwInterfaceNext *hwInterface, CodechalDebugInterface *debugInterface) |
| 42 | : DecodePipeline(hwInterface, debugInterface) |
| 43 | { |
| 44 | MOS_STATUS m_status = InitUserSetting(m_userSettingPtr); |
| 45 | } |
| 46 | |
| 47 | MOS_STATUS HevcPipeline::Initialize(void *settings) |
| 48 | { |
| 49 | DECODE_FUNC_CALL(); |
| 50 | DECODE_CHK_STATUS(DecodePipeline::Initialize(settings)); |
| 51 | |
| 52 | auto *codecSettings = (CodechalSetting*)settings; |
| 53 | DECODE_CHK_NULL(codecSettings); |
| 54 | |
| 55 | // Create basic GPU context |
| 56 | DecodeScalabilityPars scalPars; |
| 57 | MOS_ZeroMemory(&scalPars, sizeof(scalPars)); |
| 58 | DECODE_CHK_STATUS(m_mediaContext->SwitchContext(VdboxDecodeFunc, &scalPars, &m_scalability)); |
| 59 | m_decodeContext = m_osInterface->pfnGetGpuContext(m_osInterface); |
| 60 | m_decodeContextHandle = m_osInterface->CurrentGpuContextHandle; |
| 61 | |
| 62 | m_basicFeature = dynamic_cast<HevcBasicFeature*>(m_featureManager->GetFeature(FeatureIDs::basicFeature)); |
| 63 | DECODE_CHK_NULL(m_basicFeature); |
| 64 | |
| 65 | return MOS_STATUS_SUCCESS; |
| 66 | } |
| 67 | |
| 68 | MOS_STATUS HevcPipeline::Uninitialize() |
| 69 | { |
| 70 | DECODE_FUNC_CALL(); |
| 71 | DECODE_CHK_STATUS(DestoryPhaseList()); |
| 72 | return DecodePipeline::Uninitialize(); |
| 73 | } |
| 74 | |
| 75 | MOS_STATUS HevcPipeline::UserFeatureReport() |
| 76 | { |
| 77 | DECODE_FUNC_CALL(); |
| 78 | DECODE_CHK_STATUS(DecodePipeline::UserFeatureReport()); |
| 79 | |
| 80 | #if (_DEBUG || _RELEASE_INTERNAL) |
| 81 | WriteUserFeature(__MEDIA_USER_FEATURE_VALUE_APOGEIOS_HEVCD_ENABLE_ID, 1, m_osInterface->pOsContext); |
| 82 | #endif |
| 83 | |
| 84 | CODECHAL_DEBUG_TOOL( |
| 85 | if (m_mmcState != nullptr) |
| 86 | { |
| 87 | m_mmcState->UpdateUserFeatureKey(&(m_basicFeature->m_destSurface)); |
| 88 | } |
| 89 | ); |
| 90 | |
| 91 | return MOS_STATUS_SUCCESS; |
| 92 | } |
| 93 | |
| 94 | MOS_STATUS HevcPipeline::Execute() |
| 95 | { |
| 96 | DECODE_FUNC_CALL(); |
| 97 | |
| 98 | #if (_DEBUG || _RELEASE_INTERNAL) |
| 99 | if (GetDecodeMode() == realTileDecodeMode) |
| 100 | { |
| 101 | m_rtFrameCount++; |
| 102 | } |
| 103 | else if (GetDecodeMode() == virtualTileDecodeMode) |
| 104 | { |
| 105 | m_vtFrameCount++; |
| 106 | } |
| 107 | else if (GetDecodeMode() == separateTileDecodeMode) |
| 108 | { |
| 109 | m_spFrameCount++; |
| 110 | } |
| 111 | #endif |
| 112 | |
| 113 | for (auto &phase : m_phaseList) |
| 114 | { |
| 115 | DECODE_ASSERT(phase != nullptr); |
| 116 | if (phase->RequiresContextSwitch()) |
| 117 | { |
| 118 | // switch context |
| 119 | DecodeScalabilityOption *scalabOption = phase->GetDecodeScalabilityOption(); |
| 120 | DECODE_CHK_NULL(scalabOption); |
| 121 | if (m_allowVirtualNodeReassign) |
| 122 | { |
| 123 | // reassign decoder virtual node at the first frame for each stream |
| 124 | DECODE_CHK_STATUS(m_mediaContext->ReassignContextForDecoder(m_basicFeature->m_frameNum, *scalabOption, &m_scalability)); |
| 125 | m_mediaContext->SetLatestDecoderVirtualNode(); |
| 126 | } |
| 127 | else |
| 128 | { |
| 129 | DECODE_CHK_STATUS(m_mediaContext->SwitchContext(VdboxDecodeFunc, *scalabOption, &m_scalability)); |
| 130 | } |
| 131 | if (scalabOption->IsScalabilityOptionMatched(m_scalabOption)) |
| 132 | { |
| 133 | m_decodeContext = m_osInterface->pfnGetGpuContext(m_osInterface); |
| 134 | m_decodeContextHandle = m_osInterface->CurrentGpuContextHandle; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | StateParams stateProperty; |
| 139 | stateProperty.currentPipe = phase->GetPipe(); |
| 140 | stateProperty.currentPass = phase->GetPass(); |
| 141 | stateProperty.pipeIndexForSubmit = phase->GetPipe() + 1; |
| 142 | stateProperty.componentState = phase; |
| 143 | DECODE_CHK_STATUS(ActivatePacket(phase->GetPktId(), phase->ImmediateSubmit(), stateProperty)); |
| 144 | |
| 145 | if (phase->ImmediateSubmit()) |
| 146 | { |
| 147 | m_scalability->SetPassNumber(phase->GetPass() + 1); |
| 148 | DECODE_CHK_STATUS(ExecuteActivePackets()); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | return MOS_STATUS_SUCCESS; |
| 153 | } |
| 154 | |
| 155 | MOS_STATUS HevcPipeline::CreateFeatureManager() |
| 156 | { |
| 157 | DECODE_FUNC_CALL(); |
| 158 | m_featureManager = MOS_New(DecodeHevcFeatureManager, m_allocator, m_hwInterface, m_osInterface); |
| 159 | DECODE_CHK_NULL(m_featureManager); |
| 160 | return MOS_STATUS_SUCCESS; |
| 161 | } |
| 162 | |
| 163 | MOS_STATUS HevcPipeline::CreateSubPackets(DecodeSubPacketManager& subPacketManager, CodechalSetting &codecSettings) |
| 164 | { |
| 165 | DECODE_FUNC_CALL(); |
| 166 | |
| 167 | DECODE_CHK_STATUS(DecodePipeline::CreateSubPackets(subPacketManager, codecSettings)); |
| 168 | |
| 169 | #ifdef _DECODE_PROCESSING_SUPPORTED |
| 170 | HevcDownSamplingPkt *downSamplingPkt = MOS_New(HevcDownSamplingPkt, this, m_hwInterface); |
| 171 | DECODE_CHK_NULL(downSamplingPkt); |
| 172 | DECODE_CHK_STATUS(subPacketManager.Register( |
| 173 | DecodePacketId(this, downSamplingSubPacketId), *downSamplingPkt)); |
| 174 | #endif |
| 175 | |
| 176 | return MOS_STATUS_SUCCESS; |
| 177 | } |
| 178 | |
| 179 | MOS_STATUS HevcPipeline::InitContexOption(HevcScalabilityPars& scalPars) |
| 180 | { |
| 181 | scalPars.usingHcp = true; |
| 182 | scalPars.enableVE = MOS_VE_SUPPORTED(m_osInterface); |
| 183 | scalPars.disableScalability = m_hwInterface->IsDisableScalability(); |
| 184 | if (m_osInterface->pfnIsMultipleCodecDevicesInUse(m_osInterface)) |
| 185 | { |
| 186 | scalPars.disableScalability = true; |
| 187 | } |
| 188 | #if (_DEBUG || _RELEASE_INTERNAL) |
| 189 | if (m_osInterface->bHcpDecScalabilityMode == MOS_SCALABILITY_ENABLE_MODE_FALSE) |
| 190 | { |
| 191 | scalPars.disableScalability = true; |
| 192 | } |
| 193 | else if (m_osInterface->bHcpDecScalabilityMode == MOS_SCALABILITY_ENABLE_MODE_USER_FORCE) |
| 194 | { |
| 195 | scalPars.disableScalability = false; |
| 196 | } |
| 197 | scalPars.modeSwithThreshold1 = |
| 198 | ReadUserFeature(m_userSettingPtr, "HCP Decode Mode Switch TH1", MediaUserSetting::Group::Sequence).Get<uint32_t>(); |
| 199 | scalPars.modeSwithThreshold2 = |
| 200 | ReadUserFeature(m_userSettingPtr, "HCP Decode Mode Switch TH2", MediaUserSetting::Group::Sequence).Get<uint32_t>(); |
| 201 | scalPars.forceMultiPipe = |
| 202 | ReadUserFeature(m_userSettingPtr, "HCP Decode Always Frame Split", MediaUserSetting::Group::Sequence).Get<bool>(); |
| 203 | #endif |
| 204 | return MOS_STATUS_SUCCESS; |
| 205 | } |
| 206 | |
| 207 | MOS_STATUS HevcPipeline::InitDecodeMode(ScalabilityMode scalabMode, HevcBasicFeature &basicFeature) |
| 208 | { |
| 209 | if (scalabMode == scalabilityVirtualTileMode) |
| 210 | { |
| 211 | m_decodeMode = virtualTileDecodeMode; |
| 212 | } |
| 213 | else if (scalabMode == scalabilityRealTileMode) |
| 214 | { |
| 215 | m_decodeMode = realTileDecodeMode; |
| 216 | } |
| 217 | else |
| 218 | { |
| 219 | PCODEC_HEVC_PIC_PARAMS picParams = basicFeature.m_hevcPicParams; |
| 220 | DECODE_CHK_NULL(picParams); |
| 221 | |
| 222 | if (picParams->tiles_enabled_flag && |
| 223 | (basicFeature.m_isSCCIBCMode || basicFeature.m_isSCCPLTMode || basicFeature.m_isWPPMode)) |
| 224 | { |
| 225 | m_decodeMode = separateTileDecodeMode; |
| 226 | } |
| 227 | else |
| 228 | { |
| 229 | m_decodeMode = baseDecodeMode; |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | return MOS_STATUS_SUCCESS; |
| 234 | } |
| 235 | |
| 236 | template<typename T> |
| 237 | MOS_STATUS HevcPipeline::CreatePhase(uint8_t pass, uint8_t pipe, uint8_t activePipeNum) |
| 238 | { |
| 239 | DECODE_FUNC_CALL(); |
| 240 | T *phase = MOS_New(T, *this, m_scalabOption); |
| 241 | DECODE_CHK_NULL(phase); |
| 242 | MOS_STATUS estatus = phase->Initialize(pass, pipe, activePipeNum); |
| 243 | if (estatus != MOS_STATUS_SUCCESS) |
| 244 | { |
| 245 | MOS_Delete(phase); |
| 246 | return estatus; |
| 247 | } |
| 248 | m_phaseList.push_back(phase); |
| 249 | return MOS_STATUS_SUCCESS; |
| 250 | } |
| 251 | |
| 252 | MOS_STATUS HevcPipeline::CreatePhaseList(HevcBasicFeature &basicFeature, const ScalabilityMode scalabMode, const uint8_t numPipe) |
| 253 | { |
| 254 | DECODE_FUNC_CALL(); |
| 255 | DECODE_ASSERT(m_phaseList.empty()); |
| 256 | |
| 257 | if (basicFeature.m_shortFormatInUse) |
| 258 | { |
| 259 | DECODE_CHK_STATUS(CreatePhase<HevcPhaseS2L>()); |
| 260 | } |
| 261 | |
| 262 | if (scalabMode == scalabilityVirtualTileMode) |
| 263 | { |
| 264 | DECODE_CHK_STATUS(CreatePhase<HevcPhaseFrontEnd>()); |
| 265 | for (uint8_t i = 0; i < numPipe; i++) |
| 266 | { |
| 267 | DECODE_CHK_STATUS(CreatePhase<HevcPhaseBackEnd>(0, i, numPipe)); |
| 268 | } |
| 269 | } |
| 270 | else if (scalabMode == scalabilityRealTileMode) |
| 271 | { |
| 272 | PCODEC_HEVC_PIC_PARAMS picParams = basicFeature.m_hevcPicParams; |
| 273 | DECODE_CHK_NULL(picParams); |
| 274 | uint8_t pass = 0; |
| 275 | uint8_t pipe = 0; |
| 276 | uint8_t activePipeNum = numPipe; |
| 277 | uint32_t numTileCol = picParams->num_tile_columns_minus1 + 1; |
| 278 | for (uint32_t i = 0; i < numTileCol; i++) |
| 279 | { |
| 280 | DECODE_CHK_STATUS(CreatePhase<HevcPhaseRealTile>(pass, pipe, activePipeNum)); |
| 281 | pipe++; |
| 282 | if (pipe >= numPipe) |
| 283 | { |
| 284 | pipe = 0; |
| 285 | pass++; |
| 286 | uint32_t remainingCols = numTileCol - i - 1; |
| 287 | activePipeNum = (remainingCols >= numPipe) ? numPipe : remainingCols; |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | else |
| 292 | { |
| 293 | DECODE_CHK_STATUS(CreatePhase<HevcPhaseLong>()); |
| 294 | } |
| 295 | |
| 296 | return MOS_STATUS_SUCCESS; |
| 297 | } |
| 298 | |
| 299 | MOS_STATUS HevcPipeline::DestoryPhaseList() |
| 300 | { |
| 301 | for (auto &phase : m_phaseList) |
| 302 | { |
| 303 | MOS_Delete(phase); |
| 304 | } |
| 305 | m_phaseList.clear(); |
| 306 | return MOS_STATUS_SUCCESS; |
| 307 | } |
| 308 | |
| 309 | MOS_STATUS HevcPipeline::StoreDestToRefList(HevcBasicFeature &basicFeature) |
| 310 | { |
| 311 | DECODE_CHK_NULL(basicFeature.m_hevcPicParams); |
| 312 | DECODE_CHK_STATUS(basicFeature.m_refFrames.UpdateCurResource( |
| 313 | *basicFeature.m_hevcPicParams, false)); |
| 314 | return MOS_STATUS_SUCCESS; |
| 315 | } |
| 316 | |
| 317 | #if (_DEBUG || _RELEASE_INTERNAL) |
| 318 | MOS_STATUS HevcPipeline::HwStatusCheck(const DecodeStatusMfx &status) |
| 319 | { |
| 320 | DECODE_FUNC_CALL(); |
| 321 | |
| 322 | if (m_basicFeature->m_shortFormatInUse) |
| 323 | { |
| 324 | // Check HuC_status2 Imem loaded bit, if 0, return error |
| 325 | if (((status.m_hucErrorStatus2 >> 32) && (m_hwInterface->GetHucInterfaceNext()->GetHucStatus2ImemLoadedMask())) == 0) |
| 326 | { |
| 327 | if (!m_reportHucStatus) |
| 328 | { |
| 329 | WriteUserFeature(__MEDIA_USER_FEATURE_VALUE_HUC_LOAD_STATUS_ID, 1, m_osInterface->pOsContext); |
| 330 | m_reportHucStatus = true; |
| 331 | } |
| 332 | DECODE_ASSERTMESSAGE("Huc IMEM Loaded fails"); |
| 333 | MT_ERR1(MT_DEC_HEVC, MT_DEC_HUC_ERROR_STATUS2, (status.m_hucErrorStatus2 >> 32)); |
| 334 | } |
| 335 | |
| 336 | // Check Huc_status None Critical Error bit, bit 15. If 0, return error. |
| 337 | if (((status.m_hucErrorStatus >> 32) & m_hwInterface->GetHucInterfaceNext()->GetHucStatusHevcS2lFailureMask()) == 0) |
| 338 | { |
| 339 | if (!m_reportHucCriticalError) |
| 340 | { |
| 341 | WriteUserFeature(__MEDIA_USER_FEATURE_VALUE_HUC_REPORT_CRITICAL_ERROR_ID, 1, m_osInterface->pOsContext); |
| 342 | m_reportHucCriticalError = true; |
| 343 | } |
| 344 | DECODE_ASSERTMESSAGE("Huc Report Critical Error!"); |
| 345 | MT_ERR1(MT_DEC_HEVC, MT_DEC_HUC_STATUS_CRITICAL_ERROR, (status.m_hucErrorStatus >> 32)); |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | return MOS_STATUS_SUCCESS; |
| 350 | } |
| 351 | #endif |
| 352 | |
| 353 | bool HevcPipeline::IsShortFormat() |
| 354 | { |
| 355 | return m_basicFeature->m_shortFormatInUse; |
| 356 | } |
| 357 | |
| 358 | HevcPipeline::HevcDecodeMode HevcPipeline::GetDecodeMode() |
| 359 | { |
| 360 | return m_decodeMode; |
| 361 | } |
| 362 | |
| 363 | bool HevcPipeline::IsFESeparateSubmission() |
| 364 | { |
| 365 | return m_scalabOption.IsFESeparateSubmission(); |
| 366 | } |
| 367 | |
| 368 | MHW_BATCH_BUFFER* HevcPipeline::GetSliceLvlCmdBuffer() |
| 369 | { |
| 370 | if (m_secondLevelBBArray == nullptr) |
| 371 | { |
| 372 | return nullptr; |
| 373 | } |
| 374 | return m_secondLevelBBArray->Peek(); |
| 375 | } |
| 376 | |
| 377 | #if USE_CODECHAL_DEBUG_TOOL |
| 378 | MOS_STATUS HevcPipeline::DumpPicParams( |
| 379 | PCODEC_HEVC_PIC_PARAMS picParams, |
| 380 | PCODEC_HEVC_EXT_PIC_PARAMS extPicParams, |
| 381 | PCODEC_HEVC_SCC_PIC_PARAMS sccPicParams) |
| 382 | { |
| 383 | CODECHAL_DEBUG_FUNCTION_ENTER; |
| 384 | |
| 385 | if (picParams == nullptr) |
| 386 | { |
| 387 | return MOS_STATUS_SUCCESS; |
| 388 | } |
| 389 | |
| 390 | if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrPicParams)) |
| 391 | { |
| 392 | const char *picFileName = nullptr; |
| 393 | const char *extFileName = nullptr; |
| 394 | const char *sccFileName = nullptr; |
| 395 | |
| 396 | picFileName = m_debugInterface->CreateFileName( |
| 397 | "_DEC", |
| 398 | CodechalDbgBufferType::bufPicParams, |
| 399 | CodechalDbgExtType::txt); |
| 400 | |
| 401 | if (extPicParams) |
| 402 | { |
| 403 | extFileName = m_debugInterface->CreateFileName( |
| 404 | "_DEC_EXT", |
| 405 | CodechalDbgBufferType::bufPicParams, |
| 406 | CodechalDbgExtType::txt); |
| 407 | } |
| 408 | |
| 409 | if (sccPicParams) |
| 410 | { |
| 411 | sccFileName = m_debugInterface->CreateFileName( |
| 412 | "_DEC_SCC", |
| 413 | CodechalDbgBufferType::bufPicParams, |
| 414 | CodechalDbgExtType::txt); |
| 415 | } |
| 416 | |
| 417 | if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrEnableFastDump)) |
| 418 | { |
| 419 | MediaDebugFastDump::Dump( |
| 420 | (uint8_t *)picParams, |
| 421 | picFileName, |
| 422 | sizeof(CODEC_HEVC_PIC_PARAMS), |
| 423 | 0, |
| 424 | MediaDebugSerializer<CODEC_HEVC_PIC_PARAMS>()); |
| 425 | |
| 426 | if (extPicParams) |
| 427 | { |
| 428 | MediaDebugFastDump::Dump( |
| 429 | (uint8_t *)extPicParams, |
| 430 | extFileName, |
| 431 | sizeof(CODEC_HEVC_EXT_PIC_PARAMS), |
| 432 | 0, |
| 433 | MediaDebugSerializer<CODEC_HEVC_EXT_PIC_PARAMS>()); |
| 434 | } |
| 435 | |
| 436 | if (sccPicParams) |
| 437 | { |
| 438 | MediaDebugFastDump::Dump( |
| 439 | (uint8_t *)sccPicParams, |
| 440 | sccFileName, |
| 441 | sizeof(CODEC_HEVC_SCC_PIC_PARAMS), |
| 442 | 0, |
| 443 | MediaDebugSerializer<CODEC_HEVC_SCC_PIC_PARAMS>()); |
| 444 | } |
| 445 | } |
| 446 | else |
| 447 | { |
| 448 | DumpDecodeHevcPicParams(picParams, picFileName); |
| 449 | |
| 450 | if (extPicParams) |
| 451 | { |
| 452 | DumpDecodeHevcExtPicParams(extPicParams, extFileName); |
| 453 | } |
| 454 | |
| 455 | if (sccPicParams) |
| 456 | { |
| 457 | DumpDecodeHevcSccPicParams(sccPicParams, sccFileName); |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | return MOS_STATUS_SUCCESS; |
| 463 | } |
| 464 | |
| 465 | MOS_STATUS HevcPipeline::DumpSliceParams( |
| 466 | PCODEC_HEVC_SLICE_PARAMS sliceParams, |
| 467 | PCODEC_HEVC_EXT_SLICE_PARAMS extSliceParams, |
| 468 | uint32_t numSlices, |
| 469 | bool shortFormatInUse) |
| 470 | { |
| 471 | CODECHAL_DEBUG_FUNCTION_ENTER; |
| 472 | |
| 473 | if (sliceParams == nullptr) |
| 474 | { |
| 475 | return MOS_STATUS_SUCCESS; |
| 476 | } |
| 477 | |
| 478 | if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrSlcParams)) |
| 479 | { |
| 480 | const char *slcFileName = nullptr; |
| 481 | const char *extSlcFileName = nullptr; |
| 482 | bool hasExtSliceParams = false; |
| 483 | |
| 484 | if (extSliceParams && !shortFormatInUse) |
| 485 | { |
| 486 | hasExtSliceParams = true; |
| 487 | } |
| 488 | |
| 489 | slcFileName = m_debugInterface->CreateFileName( |
| 490 | "_DEC", |
| 491 | CodechalDbgBufferType::bufSlcParams, |
| 492 | CodechalDbgExtType::txt); |
| 493 | |
| 494 | if (hasExtSliceParams) |
| 495 | { |
| 496 | extSlcFileName = m_debugInterface->CreateFileName( |
| 497 | "_DEC_EXT", |
| 498 | CodechalDbgBufferType::bufSlcParams, |
| 499 | CodechalDbgExtType::txt); |
| 500 | } |
| 501 | |
| 502 | if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrEnableFastDump)) |
| 503 | { |
| 504 | if (shortFormatInUse) |
| 505 | { |
| 506 | PCODEC_HEVC_SF_SLICE_PARAMS slcParamsSF = |
| 507 | (PCODEC_HEVC_SF_SLICE_PARAMS)MOS_AllocMemory(sizeof(CODEC_HEVC_SF_SLICE_PARAMS) * numSlices); |
| 508 | |
| 509 | for (uint16_t i = 0; i < numSlices; i++) |
| 510 | { |
| 511 | slcParamsSF[i] = reinterpret_cast<CODEC_HEVC_SF_SLICE_PARAMS &>(sliceParams[i]); |
| 512 | } |
| 513 | |
| 514 | MediaDebugFastDump::Dump( |
| 515 | (uint8_t *)slcParamsSF, |
| 516 | slcFileName, |
| 517 | sizeof(CODEC_HEVC_SF_SLICE_PARAMS) * numSlices, |
| 518 | 0, |
| 519 | MediaDebugSerializer<CODEC_HEVC_SF_SLICE_PARAMS>()); |
| 520 | } |
| 521 | else |
| 522 | { |
| 523 | MediaDebugFastDump::Dump( |
| 524 | (uint8_t *)sliceParams, |
| 525 | slcFileName, |
| 526 | sizeof(CODEC_HEVC_SLICE_PARAMS) * numSlices, |
| 527 | 0, |
| 528 | MediaDebugSerializer<CODEC_HEVC_SLICE_PARAMS>()); |
| 529 | |
| 530 | if (extSliceParams) |
| 531 | { |
| 532 | MediaDebugFastDump::Dump( |
| 533 | (uint8_t *)extSliceParams, |
| 534 | extSlcFileName, |
| 535 | sizeof(CODEC_HEVC_EXT_SLICE_PARAMS) * numSlices, |
| 536 | 0, |
| 537 | MediaDebugSerializer<CODEC_HEVC_EXT_SLICE_PARAMS>()); |
| 538 | } |
| 539 | } |
| 540 | } |
| 541 | else |
| 542 | { |
| 543 | DumpDecodeHevcSliceParams(sliceParams, numSlices, slcFileName, shortFormatInUse); |
| 544 | |
| 545 | if (hasExtSliceParams) |
| 546 | { |
| 547 | DumpDecodeHevcExtSliceParams(extSliceParams, numSlices, extSlcFileName); |
| 548 | } |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | return MOS_STATUS_SUCCESS; |
| 553 | } |
| 554 | |
| 555 | MOS_STATUS HevcPipeline::DumpIQParams( |
| 556 | PCODECHAL_HEVC_IQ_MATRIX_PARAMS iqParams) |
| 557 | { |
| 558 | DECODE_FUNC_CALL(); |
| 559 | |
| 560 | if (iqParams == nullptr) |
| 561 | { |
| 562 | return MOS_STATUS_SUCCESS; |
| 563 | } |
| 564 | |
| 565 | if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrIqParams)) |
| 566 | { |
| 567 | const char *fileName = m_debugInterface->CreateFileName( |
| 568 | "_DEC", |
| 569 | CodechalDbgBufferType::bufIqParams, |
| 570 | CodechalDbgExtType::txt); |
| 571 | |
| 572 | if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrEnableFastDump)) |
| 573 | { |
| 574 | MediaDebugFastDump::Dump( |
| 575 | (uint8_t *)iqParams, |
| 576 | fileName, |
| 577 | sizeof(CODECHAL_HEVC_IQ_MATRIX_PARAMS), |
| 578 | 0, |
| 579 | MediaDebugSerializer<CODECHAL_HEVC_IQ_MATRIX_PARAMS>()); |
| 580 | } |
| 581 | else |
| 582 | { |
| 583 | DumpDecodeHevcIQParams(iqParams, fileName); |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | return MOS_STATUS_SUCCESS; |
| 588 | } |
| 589 | |
| 590 | MOS_STATUS HevcPipeline::DumpSubsetsParams( |
| 591 | PCODEC_HEVC_SUBSET_PARAMS subsetsParams) |
| 592 | { |
| 593 | DECODE_FUNC_CALL(); |
| 594 | |
| 595 | if (subsetsParams == nullptr) |
| 596 | { |
| 597 | return MOS_STATUS_SUCCESS; |
| 598 | } |
| 599 | |
| 600 | if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrSubsetsParams)) |
| 601 | { |
| 602 | const char *fileName = m_debugInterface->CreateFileName( |
| 603 | "_DEC", |
| 604 | CodechalDbgBufferType::bufSubsetsParams, |
| 605 | CodechalDbgExtType::txt); |
| 606 | |
| 607 | if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrEnableFastDump)) |
| 608 | { |
| 609 | MediaDebugFastDump::Dump( |
| 610 | (uint8_t *)subsetsParams, |
| 611 | fileName, |
| 612 | sizeof(CODEC_HEVC_SUBSET_PARAMS), |
| 613 | 0, |
| 614 | MediaDebugSerializer<CODEC_HEVC_SUBSET_PARAMS>()); |
| 615 | } |
| 616 | else |
| 617 | { |
| 618 | DumpDecodeHevcSubsetParams(subsetsParams, fileName); |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | return MOS_STATUS_SUCCESS; |
| 623 | } |
| 624 | |
| 625 | MOS_STATUS HevcPipeline::DumpSecondLevelBatchBuffer() |
| 626 | { |
| 627 | DECODE_FUNC_CALL(); |
| 628 | |
| 629 | PMHW_BATCH_BUFFER batchBuffer = GetSliceLvlCmdBuffer(); |
| 630 | DECODE_CHK_NULL(batchBuffer); |
| 631 | |
| 632 | batchBuffer->iLastCurrent = batchBuffer->iSize * batchBuffer->count; |
| 633 | batchBuffer->dwOffset = 0; |
| 634 | DECODE_CHK_STATUS(m_debugInterface->Dump2ndLvlBatch( |
| 635 | batchBuffer, |
| 636 | CODECHAL_NUM_MEDIA_STATES, |
| 637 | "_DEC")); |
| 638 | |
| 639 | return MOS_STATUS_SUCCESS; |
| 640 | } |
| 641 | #endif |
| 642 | |
| 643 | } |