| 1 |
/* |
| 2 |
* Copyright (c) 2021, 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_hevc_cqp.cpp |
| 24 |
//! \brief Defines the common interface for hevc encode cqp features |
| 25 |
//! |
| 26 |
|
| 27 |
#include "encode_hevc_basic_feature.h" |
| 28 |
#include "encode_hevc_cqp.h" |
| 29 |
#include "encode_hevc_vdenc_feature_manager.h" |
| 30 |
#include "encode_hevc_vdenc_const_settings.h" |
| 31 |
|
| 32 |
using namespace mhw::vdbox; |
| 33 |
namespace encode |
| 34 |
{ |
| 35 |
HevcEncodeCqp::HevcEncodeCqp( |
| 36 |
MediaFeatureManager *featureManager, |
| 37 |
EncodeAllocator *allocator, |
| 38 |
CodechalHwInterfaceNext *hwInterface, |
| 39 |
void *constSettings) : |
| 40 |
MediaFeature(constSettings, hwInterface ? hwInterface->GetOsInterface():nullptr), |
| 41 |
m_allocator(allocator) |
| 42 |
{ |
| 43 |
ENCODE_FUNC_CALL(); |
| 44 |
m_featureManager = featureManager; |
| 45 |
ENCODE_CHK_NULL_NO_STATUS_RETURN(hwInterface); |
| 46 |
m_mosCtx = hwInterface->GetOsInterface()->pOsContext; |
| 47 |
// can be optimized after move encode parameter to feature manager. |
| 48 |
auto encFeatureManager = dynamic_cast<EncodeHevcVdencFeatureManager *>(featureManager); |
| 49 |
ENCODE_CHK_NULL_NO_STATUS_RETURN(encFeatureManager); |
| 50 |
|
| 51 |
m_basicFeature = dynamic_cast<EncodeBasicFeature *>(encFeatureManager->GetFeature(FeatureIDs::basicFeature)); |
| 52 |
ENCODE_CHK_NULL_NO_STATUS_RETURN(m_basicFeature); |
| 53 |
|
| 54 |
m_hcpItf = std::static_pointer_cast<mhw::vdbox::hcp::Itf>(hwInterface->GetHcpInterfaceNext()); |
| 55 |
ENCODE_CHK_NULL_NO_STATUS_RETURN(m_hcpItf); |
| 56 |
} |
| 57 |
|
| 58 |
MOS_STATUS HevcEncodeCqp::Init(void *settings) |
| 59 |
{ |
| 60 |
ENCODE_FUNC_CALL(); |
| 61 |
|
| 62 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 63 |
MediaUserSetting::Value outValue; |
| 64 |
ReadUserSetting( |
| 65 |
m_userSettingPtr, |
| 66 |
outValue, |
| 67 |
"HEVC RDOQ Enable", |
| 68 |
MediaUserSetting::Group::Sequence); |
| 69 |
m_rdoqEnable = outValue.Get<bool>(); |
| 70 |
#else |
| 71 |
m_rdoqEnable = true; |
| 72 |
#endif |
| 73 |
|
| 74 |
ENCODE_CHK_STATUS_RETURN(AllocateResources()); |
| 75 |
|
| 76 |
return MOS_STATUS_SUCCESS; |
| 77 |
} |
| 78 |
|
| 79 |
MOS_STATUS HevcEncodeCqp::Update(void *params) |
| 80 |
{ |
| 81 |
ENCODE_FUNC_CALL(); |
| 82 |
ENCODE_CHK_NULL_RETURN(params); |
| 83 |
|
| 84 |
EncoderParams *encodeParams = (EncoderParams *)params; |
| 85 |
|
| 86 |
PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS hevcSeqParams = |
| 87 |
static_cast<PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS>(encodeParams->pSeqParams); |
| 88 |
ENCODE_CHK_NULL_RETURN(hevcSeqParams); |
| 89 |
PCODEC_HEVC_ENCODE_PICTURE_PARAMS hevcPicParams = |
| 90 |
static_cast<PCODEC_HEVC_ENCODE_PICTURE_PARAMS>(encodeParams->pPicParams); |
| 91 |
ENCODE_CHK_NULL_RETURN(hevcPicParams); |
| 92 |
|
| 93 |
////Livia: Legacy driver won't care about PPS parameters for deblocking, it only care about slice parameter. |
| 94 |
////As it set pps_deblocking_filter_disabled_flag=0, it's ok for enable/disable all slices DB |
| 95 |
////But it maybe a potential issue with App set this as 1 and set enable/disable DB differently for each slices. |
| 96 |
////hevcPictureParams->deblocking_filter_override_enabled_flag; |
| 97 |
////hevcPictureParams->pps_deblocking_filter_disabled_flag; |
| 98 |
|
| 99 |
if (m_basicFeature->m_newSeq) |
| 100 |
{ |
| 101 |
ENCODE_CHK_STATUS_RETURN(SetConstSettings()); |
| 102 |
} |
| 103 |
m_picQPY = hevcPicParams->QpY; |
| 104 |
m_transformSkipEnable = hevcPicParams->transform_skip_enabled_flag; |
| 105 |
|
| 106 |
m_saoEnable = hevcSeqParams->SAO_enabled_flag; |
| 107 |
if (m_saoEnable) |
| 108 |
{ |
| 109 |
ENCODE_CHK_STATUS_RETURN(VerifySliceSAOState()); |
| 110 |
} |
| 111 |
|
| 112 |
UpdateRDOQCfg(); |
| 113 |
|
| 114 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 115 |
ReportUserSettingForDebug( |
| 116 |
m_userSettingPtr, |
| 117 |
"HEVC RDOQ Enable", |
| 118 |
m_rdoqEnable, |
| 119 |
MediaUserSetting::Group::Sequence); |
| 120 |
#endif |
| 121 |
|
| 122 |
return MOS_STATUS_SUCCESS; |
| 123 |
} |
| 124 |
|
| 125 |
void HevcEncodeCqp::UpdateRDOQCfg() |
| 126 |
{ |
| 127 |
ENCODE_FUNC_CALL(); |
| 128 |
|
| 129 |
// RDOQ disable for SCC palette mode |
| 130 |
auto hevcFeature = dynamic_cast<HevcBasicFeature *>(m_basicFeature); |
| 131 |
ENCODE_CHK_NULL_NO_STATUS_RETURN(hevcFeature); |
| 132 |
|
| 133 |
if (hevcFeature->m_hevcSeqParams->palette_mode_enabled_flag) |
| 134 |
{ |
| 135 |
m_rdoqEnable = false; |
| 136 |
} |
| 137 |
|
| 138 |
m_rdoqIntraTuThreshold = 0; |
| 139 |
if (m_rdoqEnable) |
| 140 |
{ |
| 141 |
if (1 == m_basicFeature->m_targetUsage || 2 == m_basicFeature->m_targetUsage || 4 == m_basicFeature->m_targetUsage || 6 == m_basicFeature->m_targetUsage) |
| 142 |
{ |
| 143 |
m_rdoqIntraTuThreshold = 0xffff; |
| 144 |
} |
| 145 |
else if (7 == m_basicFeature->m_targetUsage) |
| 146 |
{ |
| 147 |
uint32_t frameSize = m_basicFeature->m_oriFrameWidth * m_basicFeature->m_oriFrameHeight; |
| 148 |
m_rdoqIntraTuThreshold = MOS_MIN(((frameSize * 30) / 100) >> 8, 0xffff); |
| 149 |
} |
| 150 |
} |
| 151 |
} |
| 152 |
|
| 153 |
MOS_STATUS HevcEncodeCqp::SetConstSettings() |
| 154 |
{ |
| 155 |
ENCODE_FUNC_CALL(); |
| 156 |
ENCODE_CHK_NULL_RETURN(m_basicFeature); |
| 157 |
ENCODE_CHK_NULL_RETURN(m_constSettings); |
| 158 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 159 |
auto setting = static_cast<HevcVdencFeatureSettings *>(m_constSettings); |
| 160 |
ENCODE_CHK_NULL_RETURN(setting); |
| 161 |
|
| 162 |
m_rdoqEnable = m_rdoqEnable ? (setting->rdoqEnable[m_basicFeature->m_targetUsage]) : m_rdoqEnable; |
| 163 |
|
| 164 |
return eStatus; |
| 165 |
} |
| 166 |
|
| 167 |
MOS_STATUS HevcEncodeCqp::AllocateResources() |
| 168 |
{ |
| 169 |
ENCODE_FUNC_CALL(); |
| 170 |
ENCODE_CHK_NULL_RETURN(m_basicFeature); |
| 171 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 172 |
|
| 173 |
MOS_ALLOC_GFXRES_PARAMS allocParamsForBufferLinear; |
| 174 |
MOS_ZeroMemory(&allocParamsForBufferLinear, sizeof(MOS_ALLOC_GFXRES_PARAMS)); |
| 175 |
allocParamsForBufferLinear.Type = MOS_GFXRES_BUFFER; |
| 176 |
allocParamsForBufferLinear.TileType = MOS_TILE_LINEAR; |
| 177 |
allocParamsForBufferLinear.Format = Format_Buffer; |
| 178 |
|
| 179 |
uint32_t bufSize = 0; |
| 180 |
hcp::HcpBufferSizePar hcpBufSizePar = {}; |
| 181 |
hcpBufSizePar.ucMaxBitDepth = m_basicFeature->m_bitDepth; |
| 182 |
hcpBufSizePar.ucChromaFormat = m_basicFeature->m_chromaFormat; |
| 183 |
// We should move the buffer allocation to picture level if the size is dependent on LCU size |
| 184 |
hcpBufSizePar.dwCtbLog2SizeY = 6; //assume Max LCU size |
| 185 |
hcpBufSizePar.dwPicWidth = MOS_ALIGN_CEIL(m_basicFeature->m_frameWidth, ((HevcBasicFeature *)m_basicFeature)->m_maxLCUSize); |
| 186 |
hcpBufSizePar.dwPicHeight = MOS_ALIGN_CEIL(m_basicFeature->m_frameHeight, ((HevcBasicFeature *)m_basicFeature)->m_maxLCUSize); |
| 187 |
|
| 188 |
auto AllocateResource = [&](PMOS_RESOURCE &res, const hcp::HCP_INTERNAL_BUFFER_TYPE bufferType, const char *bufferName, bool usecache) { |
| 189 |
hcpBufSizePar.bufferType = bufferType; |
| 190 |
eStatus = m_hcpItf->GetHcpBufSize(hcpBufSizePar, bufSize); |
| 191 |
if (eStatus != MOS_STATUS_SUCCESS) |
| 192 |
{ |
| 193 |
ENCODE_ASSERTMESSAGE("Failed to get the size for Deblocking Filter Buffer."); |
| 194 |
return eStatus; |
| 195 |
} |
| 196 |
allocParamsForBufferLinear.dwBytes = bufSize; |
| 197 |
allocParamsForBufferLinear.pBufName = bufferName; |
| 198 |
if (usecache) |
| 199 |
{ |
| 200 |
allocParamsForBufferLinear.ResUsageType = MOS_HW_RESOURCE_USAGE_ENCODE_INTERNAL_READ_WRITE_CACHE; |
| 201 |
} |
| 202 |
else |
| 203 |
{ |
| 204 |
allocParamsForBufferLinear.ResUsageType = MOS_HW_RESOURCE_USAGE_ENCODE_INTERNAL_READ_WRITE_NOCACHE; |
| 205 |
} |
| 206 |
res = m_allocator->AllocateResource(allocParamsForBufferLinear, false); |
| 207 |
return MOS_STATUS_SUCCESS; |
| 208 |
}; |
| 209 |
|
| 210 |
// Deblocking Filter Row Store Scratch data surface |
| 211 |
ENCODE_CHK_STATUS_RETURN(AllocateResource(m_resDeblockingFilterRowStoreScratchBuffer, hcp::HCP_INTERNAL_BUFFER_TYPE::DBLK_LINE, "DeblockingScratchBuffer", true)); |
| 212 |
// Deblocking Filter Tile Row Store Scratch data surface |
| 213 |
ENCODE_CHK_STATUS_RETURN(AllocateResource(m_resDeblockingFilterTileRowStoreScratchBuffer, hcp::HCP_INTERNAL_BUFFER_TYPE::DBLK_TILE_LINE, "DeblockingTileRowScratchBuffer", true)); |
| 214 |
// Deblocking Filter Column Row Store Scratch data surface |
| 215 |
ENCODE_CHK_STATUS_RETURN(AllocateResource(m_resDeblockingFilterColumnRowStoreScratchBuffer, hcp::HCP_INTERNAL_BUFFER_TYPE::DBLK_TILE_COL, "DeblockingColumnScratchBuffer", true)); |
| 216 |
|
| 217 |
// SAO Line buffer |
| 218 |
ENCODE_CHK_STATUS_RETURN(AllocateResource(m_resSAOLineBuffer, hcp::HCP_INTERNAL_BUFFER_TYPE::SAO_LINE, "SaoLineBuffer", false)); |
| 219 |
// SAO Tile Line buffer |
| 220 |
ENCODE_CHK_STATUS_RETURN(AllocateResource(m_resSAOTileLineBuffer, hcp::HCP_INTERNAL_BUFFER_TYPE::SAO_TILE_LINE, "SaoTileLineBuffer", false)); |
| 221 |
|
| 222 |
// SAO Tile Column buffer |
| 223 |
ENCODE_CHK_STATUS_RETURN(AllocateResource(m_resSAOTileColumnBuffer, hcp::HCP_INTERNAL_BUFFER_TYPE::SAO_TILE_COL, "SaoTileColumnBuffer", false)); |
| 224 |
|
| 225 |
// SAO StreamOut buffer |
| 226 |
uint32_t size = MOS_ALIGN_CEIL(((HevcBasicFeature *)m_basicFeature)->m_picWidthInMinLCU, 4) * m_hevcSAOStreamoutSizePerLCU; |
| 227 |
//extra added size to cover tile enabled case, per tile width aligned to 4. 20: max tile column No. |
| 228 |
size += 3 * 20 * m_hevcSAOStreamoutSizePerLCU; |
| 229 |
allocParamsForBufferLinear.dwBytes = size; |
| 230 |
allocParamsForBufferLinear.pBufName = "SaoStreamOutBuffer"; |
| 231 |
allocParamsForBufferLinear.ResUsageType = MOS_HW_RESOURCE_USAGE_ENCODE_INTERNAL_READ; |
| 232 |
m_resSAOStreamOutBuffer = m_allocator->AllocateResource(allocParamsForBufferLinear, false); |
| 233 |
|
| 234 |
const uint32_t minLCUSize = 16; |
| 235 |
const uint32_t picWidthInMinLCU = MOS_ROUNDUP_DIVIDE(m_basicFeature->m_frameWidth, minLCUSize); //assume smallest LCU to get max width |
| 236 |
const uint32_t picHeightInMinLCU = MOS_ROUNDUP_DIVIDE(m_basicFeature->m_frameHeight, minLCUSize); //assume smallest LCU to get max height |
| 237 |
// Aligned to 4 for each tile column |
| 238 |
uint32_t maxTileColumn = MOS_ROUNDUP_DIVIDE(m_basicFeature->m_frameWidth, CODECHAL_HEVC_MIN_TILE_SIZE); |
| 239 |
allocParamsForBufferLinear.dwBytes = MOS_ALIGN_CEIL(picWidthInMinLCU + 3 * maxTileColumn, 4) * 16; |
| 240 |
allocParamsForBufferLinear.pBufName = "SaoRowStoreBuffer"; |
| 241 |
allocParamsForBufferLinear.ResUsageType = MOS_HW_RESOURCE_USAGE_ENCODE_INTERNAL_READ; |
| 242 |
MOS_RESOURCE *allocatedresource = m_allocator->AllocateResource(allocParamsForBufferLinear, false); |
| 243 |
ENCODE_CHK_NULL_RETURN(allocatedresource); |
| 244 |
m_vdencSAORowStoreBuffer = *allocatedresource; |
| 245 |
if (eStatus != MOS_STATUS_SUCCESS) |
| 246 |
{ |
| 247 |
ENCODE_ASSERTMESSAGE("Failed to allocate SAO row store Buffer."); |
| 248 |
return eStatus; |
| 249 |
} |
| 250 |
|
| 251 |
return eStatus; |
| 252 |
} |
| 253 |
|
| 254 |
MOS_STATUS HevcEncodeCqp::VerifySliceSAOState() |
| 255 |
{ |
| 256 |
ENCODE_FUNC_CALL(); |
| 257 |
ENCODE_CHK_NULL_RETURN(m_basicFeature); |
| 258 |
|
| 259 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 260 |
|
| 261 |
if (m_saoEnable) |
| 262 |
{ |
| 263 |
auto hevcFeature = dynamic_cast<HevcBasicFeature *>(m_basicFeature); |
| 264 |
ENCODE_CHK_NULL_RETURN(hevcFeature); |
| 265 |
|
| 266 |
PCODEC_HEVC_ENCODE_SLICE_PARAMS hevcSliceParams = hevcFeature->m_hevcSliceParams; |
| 267 |
ENCODE_CHK_NULL_RETURN(hevcSliceParams); |
| 268 |
|
| 269 |
uint32_t slcSaoLumaCount = 0, slcSaoChromaCount = 0; |
| 270 |
|
| 271 |
for (uint32_t slcCount = 0; slcCount < m_basicFeature->m_numSlices; slcCount++, hevcSliceParams++) |
| 272 |
{ |
| 273 |
slcSaoLumaCount += hevcSliceParams->slice_sao_luma_flag; |
| 274 |
slcSaoChromaCount += hevcSliceParams->slice_sao_chroma_flag; |
| 275 |
} |
| 276 |
|
| 277 |
// For HCP_SLICE_STATE command, slices must have the same SAO setting within a picture for encoder. |
| 278 |
// And SAO should be disabled in HCP_SLICE_STATE command if luma and chroma sao disabled. |
| 279 |
if (((slcSaoLumaCount > 0) && (slcSaoLumaCount != m_basicFeature->m_numSlices)) || |
| 280 |
((slcSaoChromaCount > 0) && (slcSaoChromaCount != m_basicFeature->m_numSlices)) || |
| 281 |
((slcSaoLumaCount == 0) && (slcSaoChromaCount == 0))) |
| 282 |
{ |
| 283 |
m_saoEnable = false; |
| 284 |
ENCODE_ASSERTMESSAGE("Invalid SAO parameters in slice. All slices must have the same SAO setting within a picture."); |
| 285 |
} |
| 286 |
} |
| 287 |
|
| 288 |
return eStatus; |
| 289 |
} |
| 290 |
|
| 291 |
MHW_SETPAR_DECL_SRC(HCP_PIC_STATE, HevcEncodeCqp) |
| 292 |
{ |
| 293 |
ENCODE_FUNC_CALL(); |
| 294 |
auto hevcFeature = dynamic_cast<HevcBasicFeature *>(m_basicFeature); |
| 295 |
ENCODE_CHK_NULL_RETURN(hevcFeature); |
| 296 |
|
| 297 |
PCODEC_HEVC_ENCODE_PICTURE_PARAMS hevcPicParams = hevcFeature->m_hevcPicParams; |
| 298 |
ENCODE_CHK_NULL_RETURN(hevcPicParams); |
| 299 |
|
| 300 |
params.transformSkipEnabled = m_transformSkipEnable; |
| 301 |
params.sampleAdaptiveOffsetEnabled = m_saoEnable; |
| 302 |
params.rdoqEnable = m_rdoqEnable; |
| 303 |
params.rhodomainframelevelqp = params.rhodomainRateControlEnable ? hevcPicParams->QpY : 0; |
| 304 |
params.intratucountbasedrdoqdisable = m_rdoqEnable && (7 == m_basicFeature->m_targetUsage); |
| 305 |
params.rdoqintratuthreshold = (uint16_t)m_rdoqIntraTuThreshold; |
| 306 |
|
| 307 |
return MOS_STATUS_SUCCESS; |
| 308 |
} |
| 309 |
|
| 310 |
MHW_SETPAR_DECL_SRC(HCP_PIPE_MODE_SELECT, HevcEncodeCqp) |
| 311 |
{ |
| 312 |
ENCODE_FUNC_CALL(); |
| 313 |
|
| 314 |
params.bRdoqEnable = m_rdoqEnable; |
| 315 |
|
| 316 |
return MOS_STATUS_SUCCESS; |
| 317 |
} |
| 318 |
|
| 319 |
MHW_SETPAR_DECL_SRC(HCP_PIPE_BUF_ADDR_STATE, HevcEncodeCqp) |
| 320 |
{ |
| 321 |
ENCODE_FUNC_CALL(); |
| 322 |
|
| 323 |
params.presDeblockingFilterTileRowStoreScratchBuffer = m_resDeblockingFilterTileRowStoreScratchBuffer; |
| 324 |
params.presDeblockingFilterColumnRowStoreScratchBuffer = m_resDeblockingFilterColumnRowStoreScratchBuffer; |
| 325 |
params.presMfdDeblockingFilterRowStoreScratchBuffer = m_resDeblockingFilterRowStoreScratchBuffer; |
| 326 |
|
| 327 |
params.presSaoLineBuffer = m_resSAOLineBuffer; |
| 328 |
params.presSaoTileLineBuffer = m_resSAOTileLineBuffer; |
| 329 |
params.presSaoTileColumnBuffer = m_resSAOTileColumnBuffer; |
| 330 |
params.presSaoStreamOutBuffer = m_resSAOStreamOutBuffer; |
| 331 |
params.presSaoRowStoreBuffer = const_cast<PMOS_RESOURCE>(&m_vdencSAORowStoreBuffer); |
| 332 |
|
| 333 |
return MOS_STATUS_SUCCESS; |
| 334 |
} |
| 335 |
|
| 336 |
MHW_SETPAR_DECL_SRC(HCP_SLICE_STATE, HevcEncodeCqp) |
| 337 |
{ |
| 338 |
ENCODE_FUNC_CALL(); |
| 339 |
auto hevcFeature = dynamic_cast<HevcBasicFeature *>(m_basicFeature); |
| 340 |
ENCODE_CHK_NULL_RETURN(hevcFeature); |
| 341 |
|
| 342 |
PCODEC_HEVC_ENCODE_SLICE_PARAMS hevcSliceParams = hevcFeature->m_hevcSliceParams; |
| 343 |
ENCODE_CHK_NULL_RETURN(hevcSliceParams); |
| 344 |
PCODEC_HEVC_ENCODE_SLICE_PARAMS pEncodeHevcSliceParams = (CODEC_HEVC_ENCODE_SLICE_PARAMS *)&hevcSliceParams[hevcFeature->m_curNumSlices]; |
| 345 |
params.deblockingFilterDisable = pEncodeHevcSliceParams->slice_deblocking_filter_disable_flag; |
| 346 |
params.tcOffsetDiv2 = pEncodeHevcSliceParams->tc_offset_div2; |
| 347 |
params.betaOffsetDiv2 = pEncodeHevcSliceParams->beta_offset_div2; |
| 348 |
|
| 349 |
//SAO |
| 350 |
params.saoLumaFlag = (m_saoEnable) ? pEncodeHevcSliceParams->slice_sao_luma_flag : 0; |
| 351 |
params.saoChromaFlag = (m_saoEnable) ? pEncodeHevcSliceParams->slice_sao_chroma_flag : 0; |
| 352 |
|
| 353 |
if (m_transformSkipEnable) |
| 354 |
{ |
| 355 |
int slcQP = m_picQPY + pEncodeHevcSliceParams->slice_qp_delta; |
| 356 |
ENCODE_ASSERT(slcQP >= 0 && slcQP < HevcBasicFeature::m_qpNum); |
| 357 |
|
| 358 |
int qpIdx = 0; |
| 359 |
if (slcQP <= 22) |
| 360 |
{ |
| 361 |
qpIdx = 0; |
| 362 |
} |
| 363 |
else if (slcQP <= 27) |
| 364 |
{ |
| 365 |
qpIdx = 1; |
| 366 |
} |
| 367 |
else if (slcQP <= 32) |
| 368 |
{ |
| 369 |
qpIdx = 2; |
| 370 |
} |
| 371 |
else |
| 372 |
{ |
| 373 |
qpIdx = 3; |
| 374 |
} |
| 375 |
|
| 376 |
auto setting = static_cast<HevcVdencFeatureSettings *>(m_constSettings); |
| 377 |
ENCODE_CHK_NULL_RETURN(setting); |
| 378 |
|
| 379 |
params.transformskiplambda = setting->transformSkipLambdaTable[slcQP]; |
| 380 |
|
| 381 |
if (m_basicFeature->m_pictureCodingType == I_TYPE) |
| 382 |
{ |
| 383 |
params.transformskipNumzerocoeffsFactor0 = setting->transformSkipCoeffsTable[qpIdx][0][0][0][0]; |
| 384 |
params.transformskipNumzerocoeffsFactor1 = setting->transformSkipCoeffsTable[qpIdx][0][0][1][0]; |
| 385 |
params.transformskipNumnonzerocoeffsFactor0 = setting->transformSkipCoeffsTable[qpIdx][0][0][0][1] + 32; |
| 386 |
params.transformskipNumnonzerocoeffsFactor1 = setting->transformSkipCoeffsTable[qpIdx][0][0][1][1] + 32; |
| 387 |
} |
| 388 |
else |
| 389 |
{ |
| 390 |
params.transformskipNumzerocoeffsFactor0 = setting->transformSkipCoeffsTable[qpIdx][1][0][0][0]; |
| 391 |
params.transformskipNumzerocoeffsFactor1 = setting->transformSkipCoeffsTable[qpIdx][1][0][1][0]; |
| 392 |
params.transformskipNumnonzerocoeffsFactor0 = setting->transformSkipCoeffsTable[qpIdx][1][0][0][1] + 32; |
| 393 |
params.transformskipNumnonzerocoeffsFactor1 = setting->transformSkipCoeffsTable[qpIdx][1][0][1][1] + 32; |
| 394 |
} |
| 395 |
} |
| 396 |
|
| 397 |
return MOS_STATUS_SUCCESS; |
| 398 |
} |
| 399 |
|
| 400 |
} // namespace encode |