| 1 |
/* |
| 2 |
* Copyright (c) 2017, 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 codechal_mmc_encode_hevc.cpp |
| 24 |
//! \brief Impelements the public interface for CodecHal Media Memory Compression |
| 25 |
//! |
| 26 |
|
| 27 |
#include "codechal_mmc_encode_hevc.h" |
| 28 |
|
| 29 |
CodechalMmcEncodeHevc::CodechalMmcEncodeHevc( |
| 30 |
CodechalHwInterface *hwInterface, |
| 31 |
void *standardState): |
| 32 |
CodecHalMmcState(hwInterface) |
| 33 |
{ |
| 34 |
CODECHAL_ENCODE_FUNCTION_ENTER; |
| 35 |
|
| 36 |
m_hevcState = (CodechalEncodeHevcBase *)standardState; |
| 37 |
CODECHAL_ENCODE_CHK_NULL_NO_STATUS_RETURN(m_hevcState); |
| 38 |
|
| 39 |
CODECHAL_ENCODE_CHK_NULL_NO_STATUS_RETURN(hwInterface); |
| 40 |
CODECHAL_ENCODE_CHK_NULL_NO_STATUS_RETURN(hwInterface->GetSkuTable()); |
| 41 |
if (MEDIA_IS_SKU(hwInterface->GetSkuTable(), FtrMemoryCompression)) |
| 42 |
{ |
| 43 |
MOS_USER_FEATURE_VALUE_DATA userFeatureData; |
| 44 |
MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData)); |
| 45 |
userFeatureData.i32Data = m_mmcEnabled; |
| 46 |
userFeatureData.i32DataFlag = MOS_USER_FEATURE_VALUE_DATA_FLAG_CUSTOM_DEFAULT_VALUE_TYPE; |
| 47 |
|
| 48 |
MOS_UserFeature_ReadValue_ID( |
| 49 |
nullptr, |
| 50 |
__MEDIA_USER_FEATURE_VALUE_ENCODE_MMC_ENABLE_ID, |
| 51 |
&userFeatureData, |
| 52 |
m_osInterface->pOsContext); |
| 53 |
m_mmcEnabled = (userFeatureData.i32Data) ? true : false; |
| 54 |
|
| 55 |
MOS_USER_FEATURE_VALUE_WRITE_DATA userFeatureWriteData; |
| 56 |
MOS_ZeroMemory(&userFeatureWriteData, sizeof(userFeatureWriteData)); |
| 57 |
userFeatureWriteData.Value.i32Data = m_mmcEnabled; |
| 58 |
userFeatureWriteData.ValueID = __MEDIA_USER_FEATURE_VALUE_ENCODE_MMC_IN_USE_ID; |
| 59 |
MOS_UserFeature_WriteValues_ID(nullptr, &userFeatureWriteData, 1, m_osInterface->pOsContext); |
| 60 |
} |
| 61 |
|
| 62 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 63 |
m_compressibleId = __MEDIA_USER_FEATURE_VALUE_MMC_ENC_RECON_COMPRESSIBLE_ID; |
| 64 |
m_compressModeId = __MEDIA_USER_FEATURE_VALUE_MMC_ENC_RECON_COMPRESSMODE_ID; |
| 65 |
#endif |
| 66 |
} |
| 67 |
|
| 68 |
MOS_STATUS CodechalMmcEncodeHevc::SetPipeBufAddr( |
| 69 |
PMHW_VDBOX_PIPE_BUF_ADDR_PARAMS pipeBufAddrParams, |
| 70 |
PMOS_COMMAND_BUFFER cmdBuffer) |
| 71 |
{ |
| 72 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 73 |
|
| 74 |
CODECHAL_ENCODE_FUNCTION_ENTER; |
| 75 |
|
| 76 |
CODECHAL_ENCODE_CHK_NULL_RETURN(m_hevcState->m_hevcSeqParams); |
| 77 |
|
| 78 |
if (m_mmcEnabled && |
| 79 |
m_hevcState->m_reconSurface.bCompressible && |
| 80 |
m_hcpMmcEnabled && |
| 81 |
!m_hevcState->m_disableReconMMCD) |
| 82 |
{ |
| 83 |
pipeBufAddrParams->PreDeblockSurfMmcState = MOS_MEMCOMP_HORIZONTAL; |
| 84 |
|
| 85 |
// SAO 1st pass can always be executed as 1st pass even with 3 pass SAO |
| 86 |
// memory compression of reconstructed pixels should be disabled during SAO First Pass |
| 87 |
if (m_hevcState->m_hevcSeqParams->SAO_enabled_flag && |
| 88 |
m_hevcState->IsFirstPass() && |
| 89 |
m_hevcState->m_b2NdSaoPassNeeded) |
| 90 |
{ |
| 91 |
pipeBufAddrParams->PreDeblockSurfMmcState = MOS_MEMCOMP_DISABLED; |
| 92 |
} |
| 93 |
} |
| 94 |
else |
| 95 |
{ |
| 96 |
pipeBufAddrParams->PreDeblockSurfMmcState = MOS_MEMCOMP_DISABLED; |
| 97 |
} |
| 98 |
|
| 99 |
CODECHAL_DEBUG_TOOL( |
| 100 |
m_hevcState->m_reconSurface.MmcState = pipeBufAddrParams->PreDeblockSurfMmcState; |
| 101 |
) |
| 102 |
|
| 103 |
return eStatus; |
| 104 |
} |
| 105 |
|