Changeset 310 in SHVCSoftware for trunk/source/Lib/TLibEncoder/TEncSlice.cpp


Ignore:
Timestamp:
22 Jul 2013, 21:40:00 (11 years ago)
Author:
seregin
Message:

reintegrate SHM-2.1-dev branch

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/source

  • trunk/source/Lib/TLibEncoder/TEncSlice.cpp

    r191 r310  
    425425  rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
    426426 
    427 #if L0386_DB_METRIC
    428427  if ( m_pcCfg->getDeblockingFilterMetric() )
    429428  {
     
    433432    rpcSlice->setDeblockingFilterTcOffsetDiv2( 0 );
    434433  } else
    435 #endif
    436434  if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
    437435  {
     
    491489  {
    492490#if JCTVC_M0458_INTERLAYER_RPS_SIG
    493   // currently only one reference layer is supported in software and no decision logic to select yet.
    494   // hence num of active inter layer references is set to one always
    495491    if( rpcSlice->getNumILRRefIdx() > 0 )
    496492    {
    497       rpcSlice->setActiveNumILRRefIdx(1);
     493      rpcSlice->setActiveNumILRRefIdx( m_ppcTEncTop[layerId]->getNumActiveRefLayers() );
     494      for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
     495      {
     496        rpcSlice->setInterLayerPredLayerIdc( m_ppcTEncTop[layerId]->getPredLayerId(i), i );
     497      }
    498498      rpcSlice->setInterLayerPredEnabledFlag(1);
    499499    }
    500500#else
    501501    rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( layerId ) );
    502 #endif
     502#endif
     503#if M0457_COL_PICTURE_SIGNALING
     504    rpcSlice->setMFMEnabledFlag(m_ppcTEncTop[layerId]->getMFMEnabledFlag());
     505    rpcSlice->setAltColIndicationFlag(rpcSlice->getMFMEnabledFlag());
     506#endif
    503507  }
    504508
     
    513517  // store lambda
    514518  slice->setSliceQp( sliceQP );
    515 #if L0033_RC_BUGFIX
    516519  slice->setSliceQpBase ( sliceQP );
    517 #endif
    518520  m_pcRdCost ->setLambda( lambda );
    519521#if WEIGHTED_CHROMA_DISTORTION
     
    822824/** \param rpcPic   picture class
    823825 */
     826#if RATE_CONTROL_INTRA
     827Void TEncSlice::calCostSliceI(TComPic*& rpcPic)
     828{
     829  UInt    uiCUAddr;
     830  UInt    uiStartCUAddr;
     831  UInt    uiBoundingCUAddr;
     832  Int     iSumHad, shift = g_bitDepthY-8, offset = (shift>0)?(1<<(shift-1)):0;;
     833  Double  iSumHadSlice = 0;
     834
     835  rpcPic->getSlice(getSliceIdx())->setSliceSegmentBits(0);
     836  TComSlice* pcSlice            = rpcPic->getSlice(getSliceIdx());
     837  xDetermineStartAndBoundingCUAddr ( uiStartCUAddr, uiBoundingCUAddr, rpcPic, false );
     838
     839  UInt uiEncCUOrder;
     840  uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
     841  for( uiEncCUOrder = uiStartCUAddr/rpcPic->getNumPartInCU();
     842       uiEncCUOrder < (uiBoundingCUAddr+(rpcPic->getNumPartInCU()-1))/rpcPic->getNumPartInCU();
     843       uiCUAddr = rpcPic->getPicSym()->getCUOrderMap(++uiEncCUOrder) )
     844  {
     845    // initialize CU encoder
     846    TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );
     847    pcCU->initCU( rpcPic, uiCUAddr );
     848
     849    Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
     850    Int width   = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );
     851
     852    iSumHad = m_pcCuEncoder->updateLCUDataISlice(pcCU, uiCUAddr, width, height);
     853
     854    (m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr)).m_costIntra=(iSumHad+offset)>>shift;
     855    iSumHadSlice += (m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr)).m_costIntra;
     856
     857  }
     858  m_pcRateCtrl->getRCPic()->setTotalIntraCost(iSumHadSlice);
     859}
     860#endif
     861
    824862Void TEncSlice::compressSlice( TComPic*& rpcPic )
    825863{
     
    943981
    944982#if INTRA_BL
    945   m_pcCuEncoder->setBaseRecPic( rpcPic->getLayerId() > 0 ? rpcPic->getFullPelBaseRec() : NULL);
     983  m_pcCuEncoder->setBaseRecPic( rpcPic->getLayerId() > 0 ? rpcPic->getFullPelBaseRec(rpcPic->getLayerId()-1) : NULL);
    946984#endif
    947985
     
    9931031    TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );
    9941032    pcCU->initCU( rpcPic, uiCUAddr );
    995 #if SVC_EXTENSION
    996     pcCU->setLayerId(m_pcCfg->getLayerId());
    997 #endif
    9981033
    9991034#if !RATE_CONTROL_LAMBDA_DOMAIN
     
    10881123        Double bpp       = -1.0;
    10891124
     1125#if M0036_RC_IMPROVEMENT
     1126        if ( ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE && m_pcCfg->getForceIntraQP() ) || !m_pcCfg->getLCULevelRC() )
     1127#else
    10901128        if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE || !m_pcCfg->getLCULevelRC() )
     1129#endif
    10911130        {
    10921131          estQP = pcSlice->getSliceQp();
     
    10941133        else
    10951134        {
     1135#if RATE_CONTROL_INTRA
     1136          bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType());
     1137          if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE)
     1138          {
     1139            estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambdaAndQP(bpp, pcSlice->getSliceQp(), &estQP);
     1140          }
     1141          else
     1142          {
     1143            estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp );
     1144            estQP     = m_pcRateCtrl->getRCPic()->getLCUEstQP    ( estLambda, pcSlice->getSliceQp() );
     1145          }
     1146#else
    10961147          bpp       = m_pcRateCtrl->getRCPic()->getLCUTargetBpp();
    10971148          estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp );
    10981149          estQP     = m_pcRateCtrl->getRCPic()->getLCUEstQP    ( estLambda, pcSlice->getSliceQp() );
     1150#endif
     1151
    10991152          estQP     = Clip3( -pcSlice->getSPS()->getQpBDOffsetY(), MAX_QP, estQP );
    11001153
    11011154          m_pcRdCost->setLambda(estLambda);
     1155#if M0036_RC_IMPROVEMENT
     1156#if RDOQ_CHROMA_LAMBDA
     1157          // set lambda for RDOQ
     1158          Double weight=m_pcRdCost->getChromaWeight();
     1159          m_pcTrQuant->setLambda( estLambda, estLambda / weight );
     1160#else
     1161          m_pcTrQuant->setLambda( estLambda );
     1162#endif
     1163#endif
    11021164        }
    11031165
    11041166        m_pcRateCtrl->setRCQP( estQP );
    1105 #if L0033_RC_BUGFIX
    11061167        pcCU->getSlice()->setSliceQpBase( estQP );
    1107 #endif
    11081168      }
    11091169#endif
     
    11121172      m_pcCuEncoder->compressCU( pcCU );
    11131173
     1174#if !TICKET_1090_FIX
    11141175#if RATE_CONTROL_LAMBDA_DOMAIN
    11151176      if ( m_pcCfg->getUseRateCtrl() )
    11161177      {
     1178#if !M0036_RC_IMPROVEMENT
    11171179        UInt SAD    = m_pcCuEncoder->getLCUPredictionSAD();
    11181180        Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
     
    11211183        MAD = MAD * MAD;
    11221184        ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD;
     1185#endif
    11231186
    11241187        Int actualQP        = g_RCInvalidQPValue;
     
    11441207        }
    11451208        m_pcRdCost->setLambda(oldLambda);
    1146 
     1209#if RATE_CONTROL_INTRA
     1210        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
     1211          pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
     1212#else
    11471213        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() );
    1148       }
     1214#endif
     1215      }
     1216#endif
    11491217#endif
    11501218     
     
    11801248        }
    11811249      }
     1250
     1251#if TICKET_1090_FIX
     1252#if RATE_CONTROL_LAMBDA_DOMAIN
     1253      if ( m_pcCfg->getUseRateCtrl() )
     1254      {
     1255#if !M0036_RC_IMPROVEMENT
     1256        UInt SAD    = m_pcCuEncoder->getLCUPredictionSAD();
     1257        Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
     1258        Int width   = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );
     1259        Double MAD = (Double)SAD / (Double)(height * width);
     1260        MAD = MAD * MAD;
     1261        ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD;
     1262#endif
     1263
     1264        Int actualQP        = g_RCInvalidQPValue;
     1265        Double actualLambda = m_pcRdCost->getLambda();
     1266        Int actualBits      = pcCU->getTotalBits();
     1267        Int numberOfEffectivePixels    = 0;
     1268        for ( Int idx = 0; idx < rpcPic->getNumPartInCU(); idx++ )
     1269        {
     1270          if ( pcCU->getPredictionMode( idx ) != MODE_NONE && ( !pcCU->isSkipped( idx ) ) )
     1271          {
     1272            numberOfEffectivePixels = numberOfEffectivePixels + 16;
     1273            break;
     1274          }
     1275        }
     1276
     1277        if ( numberOfEffectivePixels == 0 )
     1278        {
     1279          actualQP = g_RCInvalidQPValue;
     1280        }
     1281        else
     1282        {
     1283          actualQP = pcCU->getQP( 0 );
     1284        }
     1285        m_pcRdCost->setLambda(oldLambda);
     1286
     1287#if RATE_CONTROL_INTRA
     1288        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
     1289          pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
     1290#else
     1291        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() );
     1292#endif
     1293      }
     1294#endif
     1295#endif
    11821296    }
    11831297    // other case: encodeCU is not called
Note: See TracChangeset for help on using the changeset viewer.