1 /* 2 * Copyright (c) 2018-2020, 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 encode_tile.cpp 24 //! \brief Defines the common interface for encode tile 25 //! 26 27 #include "encode_tile.h" 28 #include "codec_def_common.h" 29 #include "encode_pipeline.h" 30 31 namespace encode 32 { EncodeTile(MediaFeatureManager * featureManager,EncodeAllocator * allocator,CodechalHwInterfaceNext * hwInterface,void * constSettings)33 EncodeTile::EncodeTile( 34 MediaFeatureManager *featureManager, 35 EncodeAllocator *allocator, 36 CodechalHwInterfaceNext *hwInterface, 37 void *constSettings) : 38 MediaFeature(constSettings, hwInterface ? hwInterface->GetOsInterface() : nullptr), 39 m_allocator(allocator) 40 { 41 m_hwInterface = hwInterface; 42 m_featureManager = featureManager; 43 m_currentThirdLevelBatchBuffer = m_thirdLevelBatchBuffers.begin(); 44 } 45 ~EncodeTile()46 EncodeTile::~EncodeTile() 47 { 48 if (m_hwInterface != nullptr) 49 { 50 for(auto& iter : m_thirdLevelBatchBuffers){ 51 Mhw_FreeBb(m_hwInterface->GetOsInterface(), &iter, nullptr); 52 } 53 } 54 FreeTileLevelBatch(); 55 FreeTileRowLevelBRCBatch(); 56 57 if (m_allocator != nullptr) 58 { 59 if(!Mos_ResourceIsNull(m_resTileBasedStatisticsBuffer)) 60 { 61 for (auto i = 0; i < CODECHAL_GET_ARRAY_LENGTH(m_resTileBasedStatisticsBuffer); i++) 62 { 63 if(!Mos_ResourceIsNull(&m_resTileBasedStatisticsBuffer[i])) 64 { 65 m_allocator->DestroyResource(&m_resTileBasedStatisticsBuffer[i]); 66 } 67 } 68 } 69 if (!Mos_ResourceIsNull(m_tileRecordBuffer)) 70 { 71 for (auto i = 0; i < CODECHAL_GET_ARRAY_LENGTH(m_tileRecordBuffer); i++) 72 { 73 if (!Mos_ResourceIsNull(&m_tileRecordBuffer[i])) 74 { 75 m_allocator->DestroyResource(&m_tileRecordBuffer[i]); 76 } 77 } 78 } 79 if (!Mos_ResourceIsNull(&m_resHuCPakAggregatedFrameStatsBuffer)) 80 { 81 m_allocator->DestroyResource(&m_resHuCPakAggregatedFrameStatsBuffer); 82 } 83 84 } 85 86 for (auto i = 0; i < CODECHAL_GET_ARRAY_LENGTH(m_reportTileData); i++) 87 { 88 MOS_FreeMemory(m_reportTileData[i]); 89 } 90 91 if (m_tileData != nullptr) 92 { 93 MOS_FreeMemory(m_tileData); 94 } 95 96 } 97 Init(void * settings)98 MOS_STATUS EncodeTile::Init(void *settings) 99 { 100 ENCODE_FUNC_CALL(); 101 ENCODE_CHK_NULL_RETURN(settings); 102 103 ENCODE_CHK_STATUS_RETURN(AllocateResources()); 104 105 return MOS_STATUS_SUCCESS; 106 } 107 Update(void * params)108 MOS_STATUS EncodeTile::Update(void *params) 109 { 110 ENCODE_FUNC_CALL(); 111 ENCODE_CHK_NULL_RETURN(params); 112 113 if (m_maxTileNumber > m_maxTileNumberUsed) 114 { 115 if (m_tileData) 116 { 117 MOS_FreeMemory(m_tileData); 118 } 119 m_tileData = nullptr; 120 m_maxTileNumberUsed = m_maxTileNumber; 121 } 122 123 // create the tile data parameters 124 if (!m_tileData) 125 { 126 m_tileData = (EncodeTileData *)MOS_AllocAndZeroMemory( 127 sizeof(EncodeTileData) * m_maxTileNumber); 128 } 129 130 m_prevStatisticsBufIndex = m_statisticsBufIndex; 131 m_statisticsBufIndex = m_basicFeature->m_currOriginalPic.FrameIdx; 132 133 if (!m_enabled) 134 { 135 if (m_reportTileData[m_statisticsBufIndex] != nullptr) 136 { 137 MOS_FreeMemory(m_reportTileData[m_statisticsBufIndex]); 138 m_reportTileData[m_statisticsBufIndex] = nullptr; 139 } 140 return MOS_STATUS_SUCCESS; 141 } 142 143 m_tileBatchBufferIndex = (m_tileBatchBufferIndex + 1) % m_codecHalNumTileLevelBatchBuffers; 144 145 // Setup tile data 146 ENCODE_CHK_STATUS_RETURN(SetTileData(params)); 147 148 // Setup tile report data 149 ENCODE_CHK_STATUS_RETURN(SetTileReportData()); 150 151 ENCODE_CHK_STATUS_RETURN(AllocateTileLevelBatch()); 152 ENCODE_CHK_STATUS_RETURN(AllocateTileRowLevelBRCBatch()); 153 ENCODE_CHK_STATUS_RETURN(AllocateTileStatistics(params)); 154 155 return MOS_STATUS_SUCCESS; 156 } 157 AllocateResources()158 MOS_STATUS EncodeTile::AllocateResources() 159 { 160 ENCODE_FUNC_CALL(); 161 162 m_thirdLevelBatchSize = MOS_ALIGN_CEIL(1024, CODECHAL_PAGE_SIZE); 163 164 // 3rd level batch buffer 165 // To be moved to a more proper place later 166 for(auto& iter: m_thirdLevelBatchBuffers){ 167 MOS_ZeroMemory(&iter, sizeof(iter)); 168 iter.bSecondLevel = true; 169 ENCODE_CHK_STATUS_RETURN(Mhw_AllocateBb( 170 m_hwInterface->GetOsInterface(), 171 &iter, 172 nullptr, 173 m_thirdLevelBatchSize)); 174 } 175 m_currentThirdLevelBatchBuffer = m_thirdLevelBatchBuffers.begin(); 176 177 return MOS_STATUS_SUCCESS; 178 } 179 IncrementThirdLevelBatchBuffer()180 MOS_STATUS EncodeTile::IncrementThirdLevelBatchBuffer() 181 { 182 ENCODE_FUNC_CALL(); 183 184 if (!m_enabled) 185 { 186 return MOS_STATUS_SUCCESS; 187 } 188 189 if(++m_currentThirdLevelBatchBuffer == m_thirdLevelBatchBuffers.end()){ 190 m_currentThirdLevelBatchBuffer = m_thirdLevelBatchBuffers.begin(); 191 } 192 193 return MOS_STATUS_SUCCESS; 194 } 195 GetThirdLevelBatchBuffer(PMHW_BATCH_BUFFER & thirdLevelBatchBuffer)196 MOS_STATUS EncodeTile::GetThirdLevelBatchBuffer( 197 PMHW_BATCH_BUFFER &thirdLevelBatchBuffer) 198 { 199 ENCODE_FUNC_CALL(); 200 201 if (!m_enabled) 202 { 203 return MOS_STATUS_SUCCESS; 204 } 205 206 thirdLevelBatchBuffer = &(*m_currentThirdLevelBatchBuffer); 207 208 return MOS_STATUS_SUCCESS; 209 } 210 GetTileLevelBatchBuffer(PMHW_BATCH_BUFFER & tileLevelBatchBuffer)211 MOS_STATUS EncodeTile::GetTileLevelBatchBuffer( 212 PMHW_BATCH_BUFFER &tileLevelBatchBuffer) 213 { 214 ENCODE_FUNC_CALL(); 215 if (!m_enabled) 216 { 217 return MOS_STATUS_SUCCESS; 218 } 219 220 tileLevelBatchBuffer = &m_tileLevelBatchBuffer[m_tileBatchBufferIndex][m_tileRowPass][m_tileIdx]; 221 return MOS_STATUS_SUCCESS; 222 } 223 GetCurrentTile(EncodeTileData & tileData)224 MOS_STATUS EncodeTile::GetCurrentTile( 225 EncodeTileData &tileData) 226 { 227 ENCODE_FUNC_CALL(); 228 if (!m_enabled) 229 { 230 return MOS_STATUS_SUCCESS; 231 } 232 233 tileData = m_tileData[m_tileIdx]; 234 return MOS_STATUS_SUCCESS; 235 } 236 GetTileByIndex(EncodeTileData & tileData,uint32_t index)237 MOS_STATUS EncodeTile::GetTileByIndex( 238 EncodeTileData &tileData, 239 uint32_t index) 240 { 241 ENCODE_FUNC_CALL(); 242 if (!m_enabled) 243 { 244 return MOS_STATUS_SUCCESS; 245 } 246 247 tileData = m_tileData[index]; 248 return MOS_STATUS_SUCCESS; 249 } 250 SetCurrentTile(uint32_t tileRow,uint32_t tileCol,EncodePipeline * pipeline)251 MOS_STATUS EncodeTile::SetCurrentTile( 252 uint32_t tileRow, 253 uint32_t tileCol, 254 EncodePipeline *pipeline) 255 { 256 ENCODE_FUNC_CALL(); 257 if (!m_enabled) 258 { 259 return MOS_STATUS_SUCCESS; 260 } 261 262 m_tileIdx = tileRow * m_numTileColumns + tileCol; 263 264 m_tileData[m_tileIdx].isFirstPass = pipeline->IsFirstPass(); 265 m_tileData[m_tileIdx].isLastPass = pipeline->IsLastPass(); 266 m_tileData[m_tileIdx].tileReplayEnable = m_enableTileReplay; 267 268 MOS_ZeroMemory(&m_curTileCodingParams, sizeof(EncodeTileCodingParams)); 269 270 m_curTileCodingParams.NumOfTilesInFrame = m_tileData[m_tileIdx].numOfTilesInFrame; 271 m_curTileCodingParams.NumOfTileColumnsInFrame = m_tileData[m_tileIdx].numOfTileColumnsInFrame; 272 m_curTileCodingParams.TileStartLCUX = m_tileData[m_tileIdx].tileStartX; 273 m_curTileCodingParams.TileStartLCUY = m_tileData[m_tileIdx].tileStartY; 274 m_curTileCodingParams.TileHeightInMinCbMinus1 = m_tileData[m_tileIdx].tileHeightInMinMinus1; 275 m_curTileCodingParams.TileWidthInMinCbMinus1 = m_tileData[m_tileIdx].tileWidthInMinCbMinus1; 276 m_curTileCodingParams.IsLastTileofColumn = m_tileData[m_tileIdx].isLastTileofColumn; 277 m_curTileCodingParams.IsLastTileofRow = m_tileData[m_tileIdx].isLastTileofRow; 278 m_curTileCodingParams.TileRowStoreSelect = m_tileData[m_tileIdx].tileRowStoreSelect; 279 m_curTileCodingParams.TileColumnStoreSelect = m_tileData[m_tileIdx].tileColumnStoreSelect; 280 m_curTileCodingParams.Mode = m_tileData[m_tileIdx].mode; 281 m_curTileCodingParams.IsFirstPass = m_tileData[m_tileIdx].isFirstPass; 282 m_curTileCodingParams.IsLastPass = m_tileData[m_tileIdx].isLastPass; 283 m_curTileCodingParams.bTileReplayEnable = m_tileData[m_tileIdx].tileReplayEnable; 284 285 m_curTileCodingParams.BitstreamByteOffset = m_tileData[m_tileIdx].bitstreamByteOffset; 286 m_curTileCodingParams.PakTileStatisticsOffset = m_tileData[m_tileIdx].pakTileStatisticsOffset; 287 m_curTileCodingParams.CuLevelStreamoutOffset = m_tileData[m_tileIdx].cuLevelStreamoutOffset; 288 m_curTileCodingParams.SliceSizeStreamoutOffset = m_tileData[m_tileIdx].sliceSizeStreamoutOffset; 289 m_curTileCodingParams.CuRecordOffset = m_tileData[m_tileIdx].cuRecordOffset; 290 m_curTileCodingParams.SseRowstoreOffset = m_tileData[m_tileIdx].sseRowstoreOffset; 291 m_curTileCodingParams.SaoRowstoreOffset = m_tileData[m_tileIdx].saoRowstoreOffset; 292 m_curTileCodingParams.TileSizeStreamoutOffset = m_tileData[m_tileIdx].tileSizeStreamoutOffset; 293 m_curTileCodingParams.TileStreaminOffset = m_tileData[m_tileIdx].tileStreaminOffset; 294 295 m_curTileCodingParams.CumulativeCUTileOffset = m_tileData[m_tileIdx].cumulativeCUTileOffset; 296 m_curTileCodingParams.TileLCUStreamOutOffset = m_tileData[m_tileIdx].tileLCUStreamOutOffset; 297 298 return MOS_STATUS_SUCCESS; 299 } 300 BeginPatch3rdLevelBatch(MOS_COMMAND_BUFFER & cmdBuffer)301 MOS_STATUS EncodeTile::BeginPatch3rdLevelBatch( 302 MOS_COMMAND_BUFFER &cmdBuffer) 303 { 304 ENCODE_FUNC_CALL(); 305 306 uint8_t *data = (uint8_t *)m_allocator->LockResourceForWrite(&(m_currentThirdLevelBatchBuffer->OsResource)); 307 ENCODE_CHK_NULL_RETURN(data); 308 m_currentThirdLevelBatchBuffer->pData = data; 309 310 MOS_ZeroMemory(&cmdBuffer, sizeof(cmdBuffer)); 311 cmdBuffer.pCmdBase = cmdBuffer.pCmdPtr = (uint32_t *)data; 312 cmdBuffer.iRemaining = m_thirdLevelBatchSize; 313 cmdBuffer.OsResource = m_currentThirdLevelBatchBuffer->OsResource; 314 315 return MOS_STATUS_SUCCESS; 316 } 317 EndPatch3rdLevelBatch()318 MOS_STATUS EncodeTile::EndPatch3rdLevelBatch() 319 { 320 ENCODE_FUNC_CALL(); 321 322 ENCODE_CHK_STATUS_RETURN(m_allocator->UnLock(&(m_currentThirdLevelBatchBuffer->OsResource))); 323 m_currentThirdLevelBatchBuffer->pData = nullptr; 324 325 return MOS_STATUS_SUCCESS; 326 } 327 BeginPatchTileLevelBatch(uint32_t tileRowPass,MOS_COMMAND_BUFFER & cmdBuffer)328 MOS_STATUS EncodeTile::BeginPatchTileLevelBatch( 329 uint32_t tileRowPass, 330 MOS_COMMAND_BUFFER &cmdBuffer) 331 { 332 ENCODE_FUNC_CALL(); 333 334 m_tileRowPass = tileRowPass; 335 336 uint8_t *data = (uint8_t *)m_allocator->LockResourceForWrite( 337 &(m_tileLevelBatchBuffer[m_tileBatchBufferIndex][m_tileRowPass][m_tileIdx].OsResource)); 338 ENCODE_CHK_NULL_RETURN(data); 339 340 m_tileLevelBatchBuffer[m_tileBatchBufferIndex][m_tileRowPass][m_tileIdx].pData = data; 341 342 MOS_ZeroMemory(&cmdBuffer, sizeof(cmdBuffer)); 343 cmdBuffer.pCmdBase = cmdBuffer.pCmdPtr = (uint32_t *)data; 344 cmdBuffer.iRemaining = m_tileLevelBatchSize; 345 cmdBuffer.OsResource = m_tileLevelBatchBuffer[m_tileBatchBufferIndex][m_tileRowPass][m_tileIdx].OsResource; 346 347 return MOS_STATUS_SUCCESS; 348 } 349 EndPatchTileLevelBatch()350 MOS_STATUS EncodeTile::EndPatchTileLevelBatch() 351 { 352 ENCODE_FUNC_CALL(); 353 354 ENCODE_CHK_STATUS_RETURN(m_allocator->UnLock( 355 &(m_tileLevelBatchBuffer[m_tileBatchBufferIndex][m_tileRowPass][m_tileIdx].OsResource))); 356 357 m_tileLevelBatchBuffer[m_tileBatchBufferIndex][m_tileRowPass][m_tileIdx].pData = nullptr; 358 359 return MOS_STATUS_SUCCESS; 360 } 361 AllocateTileLevelBatch()362 MOS_STATUS EncodeTile::AllocateTileLevelBatch() 363 { 364 ENCODE_FUNC_CALL(); 365 366 MOS_STATUS eStatus = MOS_STATUS_SUCCESS; 367 368 // Only allocate when the number of tile changed 369 if (m_numTileBatchAllocated[m_tileBatchBufferIndex] >= m_numTiles) 370 { 371 return eStatus; 372 } 373 374 // Make it simple, free first if need reallocate 375 if (m_numTileBatchAllocated[m_tileBatchBufferIndex] > 0) 376 { 377 ENCODE_CHK_STATUS_RETURN(FreeTileLevelBatch()); 378 } 379 380 // Caculate the batch buffer size for each tile 381 // To add the MHW interface later, can be fine tuned 382 m_tileLevelBatchSize = m_hwInterface->m_vdenc2ndLevelBatchBufferSize; 383 384 // First allocate the batch buffer array 385 for (int32_t idx = 0; idx < EncodeBasicFeature::m_vdencBrcPassNum; idx++) 386 { 387 if (m_tileLevelBatchBuffer[m_tileBatchBufferIndex][idx] == nullptr) 388 { 389 m_tileLevelBatchBuffer[m_tileBatchBufferIndex][idx] = (PMHW_BATCH_BUFFER)MOS_AllocAndZeroMemory(sizeof(MHW_BATCH_BUFFER) * m_numTiles); 390 391 if (nullptr == m_tileLevelBatchBuffer[m_tileBatchBufferIndex][idx]) 392 { 393 ENCODE_ASSERTMESSAGE("Allocate memory for tile batch buffer failed"); 394 return MOS_STATUS_NO_SPACE; 395 } 396 } 397 398 // Allocate the batch buffer for each tile 399 uint32_t i = 0; 400 for (i = 0; i < m_numTiles; i++) 401 { 402 MOS_ZeroMemory(&m_tileLevelBatchBuffer[m_tileBatchBufferIndex][idx][i], sizeof(MHW_BATCH_BUFFER)); 403 m_tileLevelBatchBuffer[m_tileBatchBufferIndex][idx][i].bSecondLevel = true; 404 ENCODE_CHK_STATUS_RETURN(Mhw_AllocateBb( 405 m_hwInterface->GetOsInterface(), 406 &m_tileLevelBatchBuffer[m_tileBatchBufferIndex][idx][i], 407 nullptr, 408 m_tileLevelBatchSize)); 409 } 410 } 411 412 // Record the number of allocated batch buffer for tiles 413 m_numTileBatchAllocated[m_tileBatchBufferIndex] = m_numTiles; 414 415 return eStatus; 416 } 417 FreeTileLevelBatch()418 MOS_STATUS EncodeTile::FreeTileLevelBatch() 419 { 420 ENCODE_FUNC_CALL(); 421 422 MOS_STATUS eStatus = MOS_STATUS_SUCCESS; 423 424 // Free the batch buffer for each tile 425 uint32_t i = 0; 426 uint32_t j = 0; 427 for(int idx = 0; idx < m_codecHalNumTileLevelBatchBuffers; idx++) 428 { 429 for (i = 0; i < EncodeBasicFeature::m_vdencBrcPassNum; i++) 430 { 431 if (m_hwInterface != nullptr) 432 { 433 for (j = 0; j < m_numTileBatchAllocated[idx]; j++) 434 { 435 ENCODE_CHK_STATUS_RETURN(Mhw_FreeBb(m_hwInterface->GetOsInterface(), &m_tileLevelBatchBuffer[idx][i][j], nullptr)); 436 } 437 } 438 439 MOS_FreeMemory(m_tileLevelBatchBuffer[idx][i]); 440 m_tileLevelBatchBuffer[idx][i] = nullptr; 441 } 442 443 // Reset the number of tile batch allocated 444 m_numTileBatchAllocated[idx] = 0; 445 } 446 447 return eStatus; 448 } 449 SetTileReportData()450 MOS_STATUS EncodeTile::SetTileReportData() 451 { 452 ENCODE_FUNC_CALL(); 453 454 MOS_STATUS eStatus = MOS_STATUS_SUCCESS; 455 456 if (!m_enabled) 457 { 458 return eStatus; 459 } 460 461 if (m_reportTileData[m_statisticsBufIndex] != nullptr) 462 { 463 MOS_FreeMemory(m_reportTileData[m_statisticsBufIndex]); 464 m_reportTileData[m_statisticsBufIndex] = nullptr; 465 } 466 m_reportTileData[m_statisticsBufIndex] = (EncodeReportTileData *)MOS_AllocAndZeroMemory( 467 sizeof(EncodeReportTileData) * m_numTiles); 468 469 for (uint32_t i = 0; i < m_numTileRows; i++) 470 { 471 for (uint32_t j = 0; j < m_numTileColumns; j++) 472 { 473 uint32_t idx = i * m_numTileColumns + j; 474 m_reportTileData[m_statisticsBufIndex][idx].bitstreamByteOffset = m_tileData[idx].bitstreamByteOffset; 475 m_reportTileData[m_statisticsBufIndex][idx].tileHeightInMinCbMinus1 = m_tileData[idx].tileHeightInMinCbMinus1; 476 m_reportTileData[m_statisticsBufIndex][idx].tileWidthInMinCbMinus1 = m_tileData[idx].tileWidthInMinCbMinus1; 477 m_reportTileData[m_statisticsBufIndex][idx].numTileColumns = m_numTileColumns; 478 } 479 } 480 481 return eStatus; 482 } 483 SetTileReportDataVaild(bool isValid)484 MOS_STATUS EncodeTile::SetTileReportDataVaild(bool isValid) 485 { 486 ENCODE_FUNC_CALL(); 487 488 MOS_STATUS eStatus = MOS_STATUS_SUCCESS; 489 490 if (!m_enabled) 491 { 492 return eStatus; 493 } 494 495 if (m_reportTileData[m_statisticsBufIndex] == nullptr) 496 { 497 return MOS_STATUS_NULL_POINTER; 498 } 499 for (uint32_t i = 0; i < m_numTileRows; i++) 500 { 501 for (uint32_t j = 0; j < m_numTileColumns; j++) 502 { 503 uint32_t idx = i * m_numTileColumns + j; 504 m_reportTileData[m_statisticsBufIndex][idx].reportValid = isValid; 505 } 506 } 507 508 return eStatus; 509 } 510 GetTileBasedStatisticsBuffer(uint32_t idx,MOS_RESOURCE * & buffer) const511 MOS_STATUS EncodeTile::GetTileBasedStatisticsBuffer(uint32_t idx, MOS_RESOURCE *&buffer) const 512 { 513 ENCODE_FUNC_CALL(); 514 515 if (idx >= EncodeBasicFeature::m_uncompressedSurfaceNum) 516 { 517 ENCODE_ASSERTMESSAGE("Index exceeds the max number, when try to get TileBasedStatisticsBuffer"); 518 return MOS_STATUS_INVALID_PARAMETER; 519 } 520 521 buffer = const_cast<MOS_RESOURCE *>(&m_resTileBasedStatisticsBuffer[idx]); 522 523 return MOS_STATUS_SUCCESS; 524 } 525 GetTileRecordBuffer(uint32_t idx,MOS_RESOURCE * & buffer)526 MOS_STATUS EncodeTile::GetTileRecordBuffer(uint32_t idx, MOS_RESOURCE *&buffer) 527 { 528 ENCODE_FUNC_CALL(); 529 530 if (idx >= EncodeBasicFeature::m_uncompressedSurfaceNum) 531 { 532 ENCODE_ASSERTMESSAGE("Index exceeds the max number, when try to get TileBasedStatisticsBuffer"); 533 return MOS_STATUS_INVALID_PARAMETER; 534 } 535 536 buffer = &m_tileRecordBuffer[idx]; 537 538 return MOS_STATUS_SUCCESS; 539 } 540 GetHucPakAggregatedFrameStatsBuffer(MOS_RESOURCE * & buffer)541 MOS_STATUS EncodeTile::GetHucPakAggregatedFrameStatsBuffer(MOS_RESOURCE *&buffer) 542 { 543 ENCODE_FUNC_CALL(); 544 545 buffer = &m_resHuCPakAggregatedFrameStatsBuffer; 546 547 return MOS_STATUS_SUCCESS; 548 } 549 GetStatisticsBufferIndex(uint32_t & idx)550 MOS_STATUS EncodeTile::GetStatisticsBufferIndex(uint32_t &idx) 551 { 552 ENCODE_FUNC_CALL(); 553 554 idx = m_statisticsBufIndex; 555 556 return MOS_STATUS_SUCCESS; 557 } 558 GetPrevStatisticsBufferIndex(uint32_t & idx)559 MOS_STATUS EncodeTile::GetPrevStatisticsBufferIndex(uint32_t& idx) 560 { 561 ENCODE_FUNC_CALL(); 562 563 idx = m_prevStatisticsBufIndex; 564 565 return MOS_STATUS_SUCCESS; 566 } 567 GetReportTileData(uint32_t idx,const EncodeReportTileData * & reportTileData)568 MOS_STATUS EncodeTile::GetReportTileData(uint32_t idx, const EncodeReportTileData *&reportTileData) 569 { 570 ENCODE_FUNC_CALL(); 571 572 if (idx >= EncodeBasicFeature::m_uncompressedSurfaceNum) 573 { 574 ENCODE_ASSERTMESSAGE("Index exceeds the max number, when try to get tile report data"); 575 return MOS_STATUS_INVALID_PARAMETER; 576 } 577 578 reportTileData = m_reportTileData[idx]; 579 580 return MOS_STATUS_SUCCESS; 581 } 582 GetTileRowColumns(uint16_t & row,uint16_t & col)583 MOS_STATUS EncodeTile::GetTileRowColumns(uint16_t &row, uint16_t &col) 584 { 585 ENCODE_FUNC_CALL(); 586 587 if (!m_enabled) 588 { 589 row = col = 1; 590 return MOS_STATUS_SUCCESS; 591 } 592 593 row = m_numTileRows; 594 col = m_numTileColumns; 595 596 return MOS_STATUS_SUCCESS; 597 } 598 } // namespace encode 599