| 1 |
/* |
| 2 |
* Copyright (c) 2019-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 |
//! |
| 24 |
//! \file decode_scalability_option.cpp |
| 25 |
//! \brief Defines the common interface for decode scalability option. |
| 26 |
//! |
| 27 |
|
| 28 |
#include "decode_scalability_option.h" |
| 29 |
#include "media_scalability_defs.h" |
| 30 |
|
| 31 |
namespace decode |
| 32 |
{ |
| 33 |
DecodeScalabilityOption::DecodeScalabilityOption(const DecodeScalabilityOption &option) |
| 34 |
{ |
| 35 |
m_numPipe = option.m_numPipe; |
| 36 |
m_mode = option.m_mode; |
| 37 |
m_usingSFC = option.m_usingSFC; |
| 38 |
m_usingSlimVdbox = option.m_usingSlimVdbox; |
| 39 |
m_FESeparateSubmission = option.m_FESeparateSubmission; |
| 40 |
m_raMode = option.m_raMode; |
| 41 |
m_protectMode = option.m_protectMode; |
| 42 |
} |
| 43 |
|
| 44 |
MOS_STATUS DecodeScalabilityOption::SetScalabilityOption(ScalabilityPars *params) |
| 45 |
{ |
| 46 |
SCALABILITY_CHK_NULL_RETURN(params); |
| 47 |
|
| 48 |
DecodeScalabilityPars *decPars = (DecodeScalabilityPars *)params; |
| 49 |
|
| 50 |
m_numPipe = 1; |
| 51 |
m_mode = scalabilitySingleMode; |
| 52 |
m_usingSFC = decPars->usingSfc; |
| 53 |
m_usingSlimVdbox = decPars->usingSlimVdbox; |
| 54 |
m_raMode = decPars->raMode; |
| 55 |
m_protectMode = decPars->protectMode; |
| 56 |
|
| 57 |
if (IsSinglePipeDecode(*decPars)) |
| 58 |
{ |
| 59 |
return MOS_STATUS_SUCCESS; |
| 60 |
} |
| 61 |
|
| 62 |
bool isRealTileDecode = IsRealTileDecode(*decPars); |
| 63 |
if (!isRealTileDecode && decPars->disableVirtualTile) |
| 64 |
{ |
| 65 |
//If Not Real Tile Decode and Virtual tile was disabled, use single pipe. |
| 66 |
return MOS_STATUS_SUCCESS; |
| 67 |
} |
| 68 |
|
| 69 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 70 |
if (decPars->forceMultiPipe) |
| 71 |
{ |
| 72 |
m_numPipe = GetUserPipeNum(decPars->numVdbox, decPars->userPipeNum); |
| 73 |
} |
| 74 |
else if (decPars->modeSwithThreshold2 > 0 && decPars->frameWidth >= decPars->modeSwithThreshold2) |
| 75 |
{ |
| 76 |
m_numPipe = (decPars->numVdbox >= m_maxNumMultiPipe) ? m_maxNumMultiPipe : m_typicalNumMultiPipe; |
| 77 |
} |
| 78 |
else if (decPars->modeSwithThreshold1 > 0 && decPars->frameWidth >= decPars->modeSwithThreshold1) |
| 79 |
{ |
| 80 |
m_numPipe = m_typicalNumMultiPipe; |
| 81 |
} |
| 82 |
else |
| 83 |
#endif |
| 84 |
if (!decPars->disableVirtualTile && IsResolutionMatchMultiPipeThreshold2(decPars->frameWidth, decPars->frameHeight)) |
| 85 |
{ |
| 86 |
m_numPipe = (decPars->numVdbox >= m_maxNumMultiPipe) ? m_maxNumMultiPipe : m_typicalNumMultiPipe; |
| 87 |
} |
| 88 |
else if (isRealTileDecode || |
| 89 |
(!decPars->disableVirtualTile && |
| 90 |
IsResolutionMatchMultiPipeThreshold1(decPars->frameWidth, decPars->frameHeight, decPars->surfaceFormat))) |
| 91 |
{ |
| 92 |
m_numPipe = m_typicalNumMultiPipe; |
| 93 |
} |
| 94 |
|
| 95 |
if (m_numPipe >= m_typicalNumMultiPipe) |
| 96 |
{ |
| 97 |
m_mode = isRealTileDecode ? scalabilityRealTileMode : scalabilityVirtualTileMode; |
| 98 |
} |
| 99 |
|
| 100 |
if (m_mode == scalabilityVirtualTileMode && decPars->numVdbox >= m_maxNumMultiPipe) |
| 101 |
{ |
| 102 |
m_FESeparateSubmission = true; |
| 103 |
} |
| 104 |
else |
| 105 |
{ |
| 106 |
m_FESeparateSubmission = false; |
| 107 |
} |
| 108 |
|
| 109 |
SCALABILITY_VERBOSEMESSAGE( |
| 110 |
"Tile Column = %d, System VDBOX Num = %d, Decided Pipe Num = %d, " |
| 111 |
"Using SFC = %d, Using Slim Vdbox = %d, Scalability Mode = %d, FE separate submission = %d.", |
| 112 |
decPars->numTileColumns, decPars->numVdbox, m_numPipe, |
| 113 |
m_usingSFC, m_usingSlimVdbox, m_mode, m_FESeparateSubmission); |
| 114 |
return MOS_STATUS_SUCCESS; |
| 115 |
} |
| 116 |
|
| 117 |
bool DecodeScalabilityOption::IsScalabilityOptionMatched(ScalabilityPars *params) |
| 118 |
{ |
| 119 |
if (params == nullptr) |
| 120 |
{ |
| 121 |
return false; |
| 122 |
} |
| 123 |
|
| 124 |
bool matched = false; |
| 125 |
DecodeScalabilityPars *decPars = (DecodeScalabilityPars *)params; |
| 126 |
|
| 127 |
DecodeScalabilityOption newOption; |
| 128 |
if(MOS_STATUS_SUCCESS != newOption.SetScalabilityOption(params)) |
| 129 |
{ |
| 130 |
return false; |
| 131 |
} |
| 132 |
|
| 133 |
if (m_numPipe != newOption.GetNumPipe() || |
| 134 |
m_usingSFC != newOption.IsUsingSFC() || |
| 135 |
m_usingSlimVdbox != newOption.IsUsingSlimVdbox() || |
| 136 |
m_mode != newOption.GetMode() || |
| 137 |
m_FESeparateSubmission != newOption.IsFESeparateSubmission() || |
| 138 |
m_raMode != newOption.GetRAMode() || |
| 139 |
m_protectMode != newOption.GetProtectMode()) |
| 140 |
{ |
| 141 |
matched = false; |
| 142 |
} |
| 143 |
else |
| 144 |
{ |
| 145 |
matched = true; |
| 146 |
} |
| 147 |
return matched; |
| 148 |
} |
| 149 |
|
| 150 |
bool DecodeScalabilityOption::IsScalabilityOptionMatched(MediaScalabilityOption &scalabOption) |
| 151 |
{ |
| 152 |
auto decodeOption = dynamic_cast<DecodeScalabilityOption *>(&scalabOption); |
| 153 |
if (decodeOption == nullptr) |
| 154 |
{ |
| 155 |
return false; |
| 156 |
} |
| 157 |
|
| 158 |
if (m_numPipe != decodeOption->GetNumPipe() || |
| 159 |
m_usingSFC != decodeOption->IsUsingSFC() || |
| 160 |
m_usingSlimVdbox != decodeOption->IsUsingSlimVdbox() || |
| 161 |
m_mode != decodeOption->GetMode() || |
| 162 |
m_FESeparateSubmission != decodeOption->IsFESeparateSubmission() || |
| 163 |
m_raMode != decodeOption->GetRAMode() || |
| 164 |
m_protectMode != decodeOption->GetProtectMode()) |
| 165 |
{ |
| 166 |
return false; |
| 167 |
} |
| 168 |
|
| 169 |
return true; |
| 170 |
} |
| 171 |
|
| 172 |
bool DecodeScalabilityOption::IsSinglePipeDecode(DecodeScalabilityPars ¶ms) |
| 173 |
{ |
| 174 |
// multipipe depends on VE |
| 175 |
if (!params.enableVE) |
| 176 |
{ |
| 177 |
return true; |
| 178 |
} |
| 179 |
|
| 180 |
if (params.disableScalability) |
| 181 |
{ |
| 182 |
return true; |
| 183 |
} |
| 184 |
|
| 185 |
if (params.numVdbox <= 1) |
| 186 |
{ |
| 187 |
return true; |
| 188 |
} |
| 189 |
|
| 190 |
return false; |
| 191 |
} |
| 192 |
|
| 193 |
bool DecodeScalabilityOption::IsRealTileDecode(DecodeScalabilityPars ¶ms) |
| 194 |
{ |
| 195 |
if (params.disableRealTile) |
| 196 |
{ |
| 197 |
return false; |
| 198 |
} |
| 199 |
|
| 200 |
if (params.numTileColumns <= 1) |
| 201 |
{ |
| 202 |
return false; |
| 203 |
} |
| 204 |
|
| 205 |
return (params.numTileColumns <= params.maxTileColumn && |
| 206 |
params.numTileRows <= params.maxTileRow); |
| 207 |
} |
| 208 |
|
| 209 |
bool DecodeScalabilityOption::IsResolutionMatchMultiPipeThreshold1( |
| 210 |
uint32_t frameWidth, uint32_t frameHeight, MOS_FORMAT surfaceFormat) |
| 211 |
{ |
| 212 |
uint32_t frameWidthTh = m_4KFrameWdithTh; |
| 213 |
uint32_t frameHeightTh = m_4KFrameHeightTh; |
| 214 |
if (!IsRextFormat(surfaceFormat)) |
| 215 |
{ |
| 216 |
frameWidthTh = m_5KFrameWdithTh; |
| 217 |
frameHeightTh = m_5KFrameHeightTh; |
| 218 |
} |
| 219 |
|
| 220 |
return (frameWidth >= frameWidthTh && frameHeight >= frameHeightTh) || |
| 221 |
(frameWidth * frameHeight >= frameWidthTh * frameHeightTh); |
| 222 |
} |
| 223 |
|
| 224 |
bool DecodeScalabilityOption::IsResolutionMatchMultiPipeThreshold2( |
| 225 |
uint32_t frameWidth, uint32_t frameHeight) |
| 226 |
{ |
| 227 |
return ((frameWidth * frameHeight) >= (m_8KFrameWdithTh * m_8KFrameHeightTh)); |
| 228 |
} |
| 229 |
|
| 230 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 231 |
uint8_t DecodeScalabilityOption::GetUserPipeNum(uint8_t numVdbox, uint8_t userPipeNum) |
| 232 |
{ |
| 233 |
if (numVdbox >= m_maxNumMultiPipe) |
| 234 |
{ |
| 235 |
if (userPipeNum >= m_typicalNumMultiPipe && userPipeNum <= numVdbox) |
| 236 |
{ |
| 237 |
return userPipeNum; |
| 238 |
} |
| 239 |
} |
| 240 |
return m_typicalNumMultiPipe; |
| 241 |
} |
| 242 |
#endif |
| 243 |
|
| 244 |
uint32_t DecodeScalabilityOption::GetLRCACount() |
| 245 |
{ |
| 246 |
// on GT2 or debug override enabled, FE separate submission = false, FE run on the same engine of BEs; |
| 247 |
// on GT3, FE separate submission = true, scalability submission includes only BEs. |
| 248 |
if (m_numPipe == m_typicalNumMultiPipe) |
| 249 |
{ |
| 250 |
return m_numPipe; |
| 251 |
} |
| 252 |
else if (m_numPipe >= m_maxNumMultiPipe) |
| 253 |
{ |
| 254 |
// in release driver bFESeparateSubmission is always false since this is on GT3 or GT4. |
| 255 |
// bFESeparateSubmission could be false if debug override enabled. |
| 256 |
if (m_FESeparateSubmission || m_mode == scalabilityRealTileMode) |
| 257 |
{ |
| 258 |
return m_numPipe; |
| 259 |
} |
| 260 |
else |
| 261 |
{ |
| 262 |
return m_numPipe + 1; |
| 263 |
} |
| 264 |
} |
| 265 |
|
| 266 |
return m_numPipe; |
| 267 |
} |
| 268 |
|
| 269 |
} |