Ignore:
Timestamp:
20 Jul 2015, 14:13:33 (9 years ago)
Author:
tech
Message:

Upgrade to HM-16.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncCu.cpp

    r1285 r1287  
    122122  m_stillToCodeChromaQpOffsetFlag  = false;
    123123  m_cuChromaQpOffsetIdxPlus1       = 0;
     124  m_bFastDeltaQP                   = false;
    124125
    125126  // initialize partition order.
     
    406407*/
    407408#if AMP_ENC_SPEEDUP
    408 Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth DEBUG_STRING_FN_DECLARE(sDebug_), PartSize eParentPartSize )
    409 #else
    410 Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth )
     409Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, const UInt uiDepth DEBUG_STRING_FN_DECLARE(sDebug_), PartSize eParentPartSize )
     410#else
     411Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, const UInt uiDepth )
    411412#endif
    412413{
     
    415416  const TComPPS &pps=*(rpcTempCU->getSlice()->getPPS());
    416417  const TComSPS &sps=*(rpcTempCU->getSlice()->getSPS());
     418 
     419  // These are only used if getFastDeltaQp() is true
     420  const UInt fastDeltaQPCuMaxSize    = Clip3(sps.getMaxCUHeight()>>sps.getLog2DiffMaxMinCodingBlockSize(), sps.getMaxCUHeight(), 32u);
    417421
    418422
     
    437441  Bool    bTrySplitDQP  = true;
    438442#endif
    439 
    440     // variable for Early CU determination
    441   Bool    bSubBranch = true;
    442 
    443443  // variable for Cbf fast mode PU decision
    444444  Bool    doNotBlockPu = true;
     
    453453#endif
    454454#endif
    455   Bool bBoundary = false;
    456   UInt uiLPelX   = rpcBestCU->getCUPelX();
    457   UInt uiRPelX   = uiLPelX + rpcBestCU->getWidth(0)  - 1;
    458   UInt uiTPelY   = rpcBestCU->getCUPelY();
    459   UInt uiBPelY   = uiTPelY + rpcBestCU->getHeight(0) - 1;
     455  const UInt uiLPelX   = rpcBestCU->getCUPelX();
     456  const UInt uiRPelX   = uiLPelX + rpcBestCU->getWidth(0)  - 1;
     457  const UInt uiTPelY   = rpcBestCU->getCUPelY();
     458  const UInt uiBPelY   = uiTPelY + rpcBestCU->getHeight(0) - 1;
     459  const UInt uiWidth   = rpcBestCU->getWidth(0);
    460460
    461461#if H_MV_ENC_DEC_TRAC
     
    515515
    516516  TComSlice * pcSlice = rpcTempCU->getPic()->getSlice(rpcTempCU->getPic()->getCurrSliceIdx());
    517   // We need to split, so don't try these modes.
    518   if ( ( uiRPelX < sps.getPicWidthInLumaSamples() ) &&
    519        ( uiBPelY < sps.getPicHeightInLumaSamples() ) )
     517
     518  const Bool bBoundary = !( uiRPelX < sps.getPicWidthInLumaSamples() && uiBPelY < sps.getPicHeightInLumaSamples() );
     519
     520  if ( !bBoundary )
    520521  {
    521522#if  H_3D_FAST_TEXTURE_ENCODING
     
    11871188    }
    11881189
    1189     m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]);
    1190     m_pcEntropyCoder->resetBits();
    1191     m_pcEntropyCoder->encodeSplitFlag( rpcBestCU, 0, uiDepth, true );
    1192     rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits
    1193     rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
     1190    if( rpcBestCU->getTotalCost()!=MAX_DOUBLE )
     1191    {
     1192      m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]);
     1193      m_pcEntropyCoder->resetBits();
     1194      m_pcEntropyCoder->encodeSplitFlag( rpcBestCU, 0, uiDepth, true );
     1195      rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits
     1196      rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
    11941197#if NH_3D_VSO // M8
    11951198    if ( m_pcRdCost->getUseVSO() )   
     
    12001203#endif
    12011204      rpcBestCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() );
    1202     m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]);
    1203 
    1204     // Early CU determination
    1205     if( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->isSkipped(0) )
    1206     {
    1207       bSubBranch = false;
    1208     }
    1209     else
    1210     {
    1211       bSubBranch = true;
     1205      m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]);
    12121206    }
    12131207#if  H_3D_FAST_TEXTURE_ENCODING
     
    12181212#endif
    12191213  }
    1220   else
    1221   {
    1222     bBoundary = true;
    1223   }
    1224 
    1225   // copy orginal YUV samples to PCM buffer
    1226   if( rpcBestCU->isLosslessCoded(0) && (rpcBestCU->getIPCMFlag(0) == false))
     1214
     1215  // copy original YUV samples to PCM buffer
     1216  if( rpcBestCU->getTotalCost()!=MAX_DOUBLE && rpcBestCU->isLosslessCoded(0) && (rpcBestCU->getIPCMFlag(0) == false))
    12271217  {
    12281218    xFillPCMBuffer(rpcBestCU, m_ppcOrigYuv[uiDepth]);
     
    12581248  }
    12591249
    1260   for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
    1261   {
    1262     const Bool bIsLosslessMode = false; // False at this level. Next level down may set it to true.
    1263 
    1264     rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    1265 
     1250  const Bool bSubBranch = bBoundary || !( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->getTotalCost()!=MAX_DOUBLE && rpcBestCU->isSkipped(0) );
     1251#if NH_3D_QTLPC
     1252  if( bSubBranch && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() && (!getFastDeltaQp() || uiWidth > fastDeltaQPCuMaxSize || bBoundary) && bTrySplitDQP )
     1253#else
     1254  if( bSubBranch && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() && (!getFastDeltaQp() || uiWidth > fastDeltaQPCuMaxSize || bBoundary))
     1255#endif
     1256  {
    12661257    // further split
    1267 #if NH_3D_QTLPC
    1268 
    1269     if( bSubBranch && bTrySplitDQP && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() )
    1270 #else
    1271     if( bSubBranch && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() )
    1272 #endif
    1273     {
     1258    for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
     1259    {
     1260      const Bool bIsLosslessMode = false; // False at this level. Next level down may set it to true.
     1261
     1262      rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
     1263
    12741264#if NH_3D_VSO // M9
    12751265      // reset Model
     
    13101300#if AMP_ENC_SPEEDUP
    13111301          DEBUG_STRING_NEW(sChild)
    1312           if ( !rpcBestCU->isInter(0) )
     1302          if ( !(rpcBestCU->getTotalCost()!=MAX_DOUBLE && rpcBestCU->isInter(0)) )
    13131303          {
    13141304            xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth DEBUG_STRING_PASS_INTO(sChild), NUMBER_OF_PART_SIZES );
     
    13661356        }
    13671357
    1368         UInt uiTargetPartIdx = 0;
    13691358        if ( hasResidual )
    13701359        {
    13711360          m_pcEntropyCoder->resetBits();
    1372           m_pcEntropyCoder->encodeQP( rpcTempCU, uiTargetPartIdx, false );
     1361          m_pcEntropyCoder->encodeQP( rpcTempCU, 0, false );
    13731362          rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits
    13741363          rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
     
    13831372
    13841373          Bool foundNonZeroCbf = false;
    1385           rpcTempCU->setQPSubCUs( rpcTempCU->getRefQP( uiTargetPartIdx ), 0, uiDepth, foundNonZeroCbf );
     1374          rpcTempCU->setQPSubCUs( rpcTempCU->getRefQP( 0 ), 0, uiDepth, foundNonZeroCbf );
    13861375          assert( foundNonZeroCbf );
    13871376        }
    13881377        else
    13891378        {
    1390           rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( uiTargetPartIdx ), 0, uiDepth ); // set QP to default QP
     1379          rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( 0 ), 0, uiDepth ); // set QP to default QP
    13911380        }
    13921381      }
     
    13991388      // This can be achieved by forcing the decision to be that of the rpcTempCU.
    14001389      // The exception is each slice / slice-segment must have at least one CTU.
    1401       const Bool isEndOfSlice        =    pcSlice->getSliceMode()==FIXED_NUMBER_OF_BYTES
    1402                                        && ((pcSlice->getSliceBits()+rpcBestCU->getTotalBits())>pcSlice->getSliceArgument()<<3)
    1403                                        && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceCurStartCtuTsAddr())
    1404                                        && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr());
    1405       const Bool isEndOfSliceSegment =    pcSlice->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES
    1406                                        && ((pcSlice->getSliceSegmentBits()+rpcBestCU->getTotalBits()) > pcSlice->getSliceSegmentArgument()<<3)
    1407                                        && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr());
    1408                                            // Do not need to check slice condition for slice-segment since a slice-segment is a subset of a slice.
    1409       if(isEndOfSlice||isEndOfSliceSegment)
     1390      if (rpcBestCU->getTotalCost()!=MAX_DOUBLE)
    14101391      {
    1411         rpcBestCU->getTotalCost()=MAX_DOUBLE;
     1392        const Bool isEndOfSlice        =    pcSlice->getSliceMode()==FIXED_NUMBER_OF_BYTES
     1393                                         && ((pcSlice->getSliceBits()+rpcBestCU->getTotalBits())>pcSlice->getSliceArgument()<<3)
     1394                                         && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceCurStartCtuTsAddr())
     1395                                         && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr());
     1396        const Bool isEndOfSliceSegment =    pcSlice->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES
     1397                                         && ((pcSlice->getSliceSegmentBits()+rpcBestCU->getTotalBits()) > pcSlice->getSliceSegmentArgument()<<3)
     1398                                         && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr());
     1399                                             // Do not need to check slice condition for slice-segment since a slice-segment is a subset of a slice.
     1400        if(isEndOfSlice||isEndOfSliceSegment)
     1401        {
     1402          rpcBestCU->getTotalCost()=MAX_DOUBLE;
     1403        }
    14121404      }
    14131405
    14141406      xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTempDebug) DEBUG_STRING_PASS_INTO(false) ); // RD compare current larger prediction
    1415                                                                                        // with sub partitioned prediction.
     1407                                                                                                                                                       // with sub partitioned prediction.
    14161408    }
    14171409  }
     
    17851777{
    17861778  assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE );
     1779  if(getFastDeltaQp())
     1780  {
     1781    return;   // never check merge in fast deltaqp mode
     1782  }
    17871783#if NH_3D_MLC
    17881784  TComMvField  cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
     
    22472243  DEBUG_STRING_NEW(sTest)
    22482244
     2245  if(getFastDeltaQp())
     2246  {
     2247    const TComSPS &sps=*(rpcTempCU->getSlice()->getSPS());
     2248    const UInt fastDeltaQPCuMaxSize = Clip3(sps.getMaxCUHeight()>>(sps.getLog2DiffMaxMinCodingBlockSize()), sps.getMaxCUHeight(), 32u);
     2249    if(ePartSize != SIZE_2Nx2N || rpcTempCU->getWidth( 0 ) > fastDeltaQPCuMaxSize)
     2250    {
     2251      return; // only check necessary 2Nx2N Inter in fast deltaqp mode
     2252    }
     2253  }
     2254
    22492255  // prior to this, rpcTempCU will have just been reset using rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    22502256#if H_3D || NH_3D_ARP
     
    27402746  DEBUG_STRING_NEW(sTest)
    27412747
     2748  if(getFastDeltaQp())
     2749  {
     2750    const TComSPS &sps=*(rpcTempCU->getSlice()->getSPS());
     2751    const UInt fastDeltaQPCuMaxSize = Clip3(sps.getMaxCUHeight()>>(sps.getLog2DiffMaxMinCodingBlockSize()), sps.getMaxCUHeight(), 32u);
     2752    if(rpcTempCU->getWidth( 0 ) > fastDeltaQPCuMaxSize)
     2753    {
     2754      return; // only check necessary 2Nx2N Intra in fast deltaqp mode
     2755    }
     2756  }
     2757
    27422758  UInt uiDepth = rpcTempCU->getDepth( 0 );
    27432759#if NH_3D_VSO // M5
     
    28442860Void TEncCu::xCheckIntraPCM( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU )
    28452861{
     2862  if(getFastDeltaQp())
     2863  {
     2864    const TComSPS &sps=*(rpcTempCU->getSlice()->getSPS());
     2865    const UInt fastDeltaQPCuMaxPCMSize = Clip3((UInt)1<<sps.getPCMLog2MinSize(), (UInt)1<<sps.getPCMLog2MaxSize(), 32u);
     2866    if (rpcTempCU->getWidth( 0 ) > fastDeltaQPCuMaxPCMSize)
     2867    {
     2868      return;   // only check necessary PCM in fast deltaqp mode
     2869    }
     2870  }
     2871 
    28462872  UInt uiDepth = rpcTempCU->getDepth( 0 );
    28472873
Note: See TracChangeset for help on using the changeset viewer.