Changeset 1298 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibCommon


Ignore:
Timestamp:
20 Jul 2015, 21:06:06 (10 years ago)
Author:
seregin
Message:

port rev 4334

Location:
branches/SHM-dev/source/Lib/TLibCommon
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/Lib/TLibCommon/TComTrQuant.cpp

    r1292 r1298  
    11611161  if ( useRDOQ && (isLuma(compID) || RDOQ_CHROMA) )
    11621162  {
     1163#if T0196_SELECTIVE_RDOQ
     1164    if ( !m_useSelectiveRDOQ || xNeedRDOQ( rTu, piCoef, compID, cQP ) )
     1165    {
     1166#endif
    11631167#if ADAPTIVE_QP_SELECTION
    1164     xRateDistOptQuant( rTu, piCoef, pDes, pArlDes, uiAbsSum, compID, cQP );
     1168      xRateDistOptQuant( rTu, piCoef, pDes, pArlDes, uiAbsSum, compID, cQP );
    11651169#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    }
    11671179#endif
    11681180  }
     
    12491261  //return;
    12501262}
     1263
     1264#if T0196_SELECTIVE_RDOQ
     1265Bool 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
    12511322
    12521323Void TComTrQuant::xDeQuant(       TComTU        &rTu,
     
    13761447                          Bool  bUseRDOQ,
    13771448                          Bool  bUseRDOQTS,
     1449#if T0196_SELECTIVE_RDOQ
     1450                          Bool  useSelectiveRDOQ,
     1451#endif
    13781452                          Bool  bEnc,
    13791453                          Bool  useTransformSkipFast
     
    13871461  m_useRDOQ      = bUseRDOQ;
    13881462  m_useRDOQTS    = bUseRDOQTS;
     1463#if T0196_SELECTIVE_RDOQ
     1464  m_useSelectiveRDOQ = useSelectiveRDOQ;
     1465#endif
    13891466#if ADAPTIVE_QP_SELECTION
    13901467  m_bUseAdaptQpSelect = bUseAdaptQpSelect;
  • branches/SHM-dev/source/Lib/TLibCommon/TComTrQuant.h

    r1287 r1298  
    106106                              Bool useRDOQ                = false,
    107107                              Bool useRDOQTS              = false,
     108#if T0196_SELECTIVE_RDOQ
     109                              Bool useSelectiveRDOQ       = false,
     110#endif
    108111                              Bool bEnc                   = false,
    109112                              Bool useTransformSkipFast   = false
     
    216219  Bool     m_useRDOQ;
    217220  Bool     m_useRDOQTS;
     221#if T0196_SELECTIVE_RDOQ
     222  Bool     m_useSelectiveRDOQ;
     223#endif
    218224#if ADAPTIVE_QP_SELECTION
    219225  Bool     m_bUseAdaptQpSelect;
     
    247253               const ComponentID   compID,
    248254               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
    249262
    250263  // RDOQ functions
  • branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h

    r1287 r1298  
    162162// Tool Switches
    163163// ====================================================================================================================
     164#define T0196_SELECTIVE_RDOQ                              1 ///< selective RDOQ
    164165
    165166#define HARMONIZE_GOP_FIRST_FIELD_COUPLE                  1
Note: See TracChangeset for help on using the changeset viewer.