Changeset 1298 in SHVCSoftware


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

port rev 4334

Location:
branches/SHM-dev/source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r1290 r1298  
    13251325  ("RDOQ",                                            m_useRDOQ,                                         true)
    13261326  ("RDOQTS",                                          m_useRDOQTS,                                       true)
     1327#if T0196_SELECTIVE_RDOQ
     1328  ("SelectiveRDOQ",                                   m_useSelectiveRDOQ,                               false, "Enable selective RDOQ")
     1329#endif
    13271330  ("RDpenalty",                                       m_rdPenalty,                                          0,  "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disabled  1:RD-penalty  2:maximum RD-penalty")
    13281331
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h

    r1290 r1298  
    268268  Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
    269269  Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
     270#if T0196_SELECTIVE_RDOQ
     271  Bool      m_useSelectiveRDOQ;                               ///< flag for using selective RDOQ
     272#endif
    270273  Int       m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty)
    271274  Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r1292 r1298  
    435435    m_acTEncTop[layer].setUseRDOQ                                          ( m_useRDOQ     );
    436436    m_acTEncTop[layer].setUseRDOQTS                                        ( m_useRDOQTS   );
     437#if T0196_SELECTIVE_RDOQ
     438    m_acTEncTop[layer].setUseSelectiveRDOQ                                 ( m_useSelectiveRDOQ );
     439#endif
    437440    m_acTEncTop[layer].setRDpenalty                                        ( m_rdPenalty );
    438441    m_acTEncTop[layer].setMaxCUWidth                                       ( m_acLayerCfg[layer].m_uiMaxCUWidth );
     
    867870  m_cTEncTop.setUseRDOQ                                           ( m_useRDOQ     );
    868871  m_cTEncTop.setUseRDOQTS                                         ( m_useRDOQTS   );
     872#if T0196_SELECTIVE_RDOQ
     873  m_cTEncTop.setUseSelectiveRDOQ                                  ( m_useSelectiveRDOQ );
     874#endif
    869875  m_cTEncTop.setRDpenalty                                         ( m_rdPenalty );
    870876  m_cTEncTop.setMaxCUWidth                                        ( m_uiMaxCUWidth );
  • 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
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h

    r1290 r1298  
    196196  Bool      m_useRDOQ;
    197197  Bool      m_useRDOQTS;
     198#if T0196_SELECTIVE_RDOQ
     199  Bool      m_useSelectiveRDOQ;
     200#endif
    198201  UInt      m_rdPenalty;
    199202  Bool      m_bUseFastEnc;
     
    618621  Void      setUseRDOQ                      ( Bool  b )     { m_useRDOQ    = b; }
    619622  Void      setUseRDOQTS                    ( Bool  b )     { m_useRDOQTS  = b; }
     623#if T0196_SELECTIVE_RDOQ
     624  Void      setUseSelectiveRDOQ             ( Bool b )      { m_useSelectiveRDOQ = b; }
     625#endif
    620626  Void      setRDpenalty                 ( UInt  b )     { m_rdPenalty  = b; }
    621627  Void      setUseFastEnc                   ( Bool  b )     { m_bUseFastEnc = b; }
     
    637643  Bool      getUseRDOQ                      ()      { return m_useRDOQ;    }
    638644  Bool      getUseRDOQTS                    ()      { return m_useRDOQTS;  }
     645#if T0196_SELECTIVE_RDOQ
     646  Bool      getUseSelectiveRDOQ             ()      { return m_useSelectiveRDOQ; }
     647#endif
    639648  Int       getRDpenalty                    ()      { return m_rdPenalty;  }
    640649  Bool      getUseFastEnc                   ()      { return m_bUseFastEnc; }
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r1290 r1298  
    250250                   m_useRDOQ,
    251251                   m_useRDOQTS,
     252#if T0196_SELECTIVE_RDOQ
     253                   m_useSelectiveRDOQ,
     254#endif
    252255                   true
    253256                  ,m_useTransformSkipFast
Note: See TracChangeset for help on using the changeset viewer.