Changeset 1298 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibCommon
- Timestamp:
- 20 Jul 2015, 21:06:06 (10 years ago)
- Location:
- branches/SHM-dev/source/Lib/TLibCommon
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibCommon/TComTrQuant.cpp
r1292 r1298 1161 1161 if ( useRDOQ && (isLuma(compID) || RDOQ_CHROMA) ) 1162 1162 { 1163 #if T0196_SELECTIVE_RDOQ 1164 if ( !m_useSelectiveRDOQ || xNeedRDOQ( rTu, piCoef, compID, cQP ) ) 1165 { 1166 #endif 1163 1167 #if ADAPTIVE_QP_SELECTION 1164 xRateDistOptQuant( rTu, piCoef, pDes, pArlDes, uiAbsSum, compID, cQP );1168 xRateDistOptQuant( rTu, piCoef, pDes, pArlDes, uiAbsSum, compID, cQP ); 1165 1169 #else 1166 xRateDistOptQuant( rTu, piCoef, pDes, uiAbsSum, compID, cQP ); 1170 xRateDistOptQuant( rTu, piCoef, pDes, uiAbsSum, compID, cQP ); 1171 #endif 1172 #if T0196_SELECTIVE_RDOQ 1173 } 1174 else 1175 { 1176 memset( pDes, 0, sizeof( TCoeff ) * uiWidth *uiHeight ); 1177 uiAbsSum = 0; 1178 } 1167 1179 #endif 1168 1180 } … … 1249 1261 //return; 1250 1262 } 1263 1264 #if T0196_SELECTIVE_RDOQ 1265 Bool TComTrQuant::xNeedRDOQ( TComTU &rTu, TCoeff * pSrc, const ComponentID compID, const QpParam &cQP ) 1266 { 1267 const TComRectangle &rect = rTu.getRect(compID); 1268 const UInt uiWidth = rect.width; 1269 const UInt uiHeight = rect.height; 1270 TComDataCU* pcCU = rTu.getCU(); 1271 const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); 1272 const Int channelBitDepth = pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)); 1273 1274 TCoeff* piCoef = pSrc; 1275 1276 const Bool useTransformSkip = pcCU->getTransformSkip(uiAbsPartIdx, compID); 1277 const Int maxLog2TrDynamicRange = pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID)); 1278 1279 const UInt uiLog2TrSize = rTu.GetEquivalentLog2TrSize(compID); 1280 1281 Int scalingListType = getScalingListType(pcCU->getPredictionMode(uiAbsPartIdx), compID); 1282 assert(scalingListType < SCALING_LIST_NUM); 1283 Int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem, uiLog2TrSize-2); 1284 1285 const Bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, (pcCU->getTransformSkip(uiAbsPartIdx, compID) != 0)); 1286 const Int defaultQuantisationCoefficient = g_quantScales[cQP.rem]; 1287 1288 /* for 422 chroma blocks, the effective scaling applied during transformation is not a power of 2, hence it cannot be 1289 * implemented as a bit-shift (the quantised result will be sqrt(2) * larger than required). Alternatively, adjust the 1290 * uiLog2TrSize applied in iTransformShift, such that the result is 1/sqrt(2) the required result (i.e. smaller) 1291 * Then a QP+3 (sqrt(2)) or QP-3 (1/sqrt(2)) method could be used to get the required result 1292 */ 1293 1294 // Represents scaling through forward transform 1295 Int iTransformShift = getTransformShift(channelBitDepth, uiLog2TrSize, maxLog2TrDynamicRange); 1296 if (useTransformSkip && pcCU->getSlice()->getSPS()->getUseExtendedPrecision()) 1297 { 1298 iTransformShift = std::max<Int>(0, iTransformShift); 1299 } 1300 1301 const Int iQBits = QUANT_SHIFT + cQP.per + iTransformShift; 1302 // QBits will be OK for any internal bit depth as the reduction in transform shift is balanced by an increase in Qp_per due to QpBDOffset 1303 1304 // iAdd is different from the iAdd used in normal quantization 1305 const Int iAdd = (compID == COMPONENT_Y ? 171 : 256) << (iQBits-9); 1306 const Int qBits8 = iQBits - 8; 1307 1308 for( Int uiBlockPos = 0; uiBlockPos < uiWidth*uiHeight; uiBlockPos++ ) 1309 { 1310 const TCoeff iLevel = piCoef[uiBlockPos]; 1311 const Int64 tmpLevel = (Int64)abs(iLevel) * (enableScalingLists ? piQuantCoeff[uiBlockPos] : defaultQuantisationCoefficient); 1312 const TCoeff quantisedMagnitude = TCoeff((tmpLevel + iAdd ) >> iQBits); 1313 1314 if ( quantisedMagnitude != 0 ) 1315 { 1316 return true; 1317 } 1318 } // for n 1319 return false; 1320 } 1321 #endif 1251 1322 1252 1323 Void TComTrQuant::xDeQuant( TComTU &rTu, … … 1376 1447 Bool bUseRDOQ, 1377 1448 Bool bUseRDOQTS, 1449 #if T0196_SELECTIVE_RDOQ 1450 Bool useSelectiveRDOQ, 1451 #endif 1378 1452 Bool bEnc, 1379 1453 Bool useTransformSkipFast … … 1387 1461 m_useRDOQ = bUseRDOQ; 1388 1462 m_useRDOQTS = bUseRDOQTS; 1463 #if T0196_SELECTIVE_RDOQ 1464 m_useSelectiveRDOQ = useSelectiveRDOQ; 1465 #endif 1389 1466 #if ADAPTIVE_QP_SELECTION 1390 1467 m_bUseAdaptQpSelect = bUseAdaptQpSelect; -
branches/SHM-dev/source/Lib/TLibCommon/TComTrQuant.h
r1287 r1298 106 106 Bool useRDOQ = false, 107 107 Bool useRDOQTS = false, 108 #if T0196_SELECTIVE_RDOQ 109 Bool useSelectiveRDOQ = false, 110 #endif 108 111 Bool bEnc = false, 109 112 Bool useTransformSkipFast = false … … 216 219 Bool m_useRDOQ; 217 220 Bool m_useRDOQTS; 221 #if T0196_SELECTIVE_RDOQ 222 Bool m_useSelectiveRDOQ; 223 #endif 218 224 #if ADAPTIVE_QP_SELECTION 219 225 Bool m_bUseAdaptQpSelect; … … 247 253 const ComponentID compID, 248 254 const QpParam &cQP ); 255 256 #if T0196_SELECTIVE_RDOQ 257 Bool xNeedRDOQ( TComTU &rTu, 258 TCoeff * pSrc, 259 const ComponentID compID, 260 const QpParam &cQP ); 261 #endif 249 262 250 263 // RDOQ functions -
branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
r1287 r1298 162 162 // Tool Switches 163 163 // ==================================================================================================================== 164 #define T0196_SELECTIVE_RDOQ 1 ///< selective RDOQ 164 165 165 166 #define HARMONIZE_GOP_FIRST_FIELD_COUPLE 1
Note: See TracChangeset for help on using the changeset viewer.