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


Ignore:
Timestamp:
13 May 2013, 16:58:44 (12 years ago)
Author:
seregin
Message:

merge with SHM-2.0-dev branch

Location:
trunk/source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source

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

    r125 r189  
    178178 \param pPPS          PPS associated with the slice
    179179 */
     180#if SVC_EXTENSION
     181//\param vps          VPS associated with the slice
     182Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps )
     183#else
    180184Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS )
     185#endif
    181186{
    182187  Double dQP;
     
    189194  rpcSlice->setPic( pcPic );
    190195#if SVC_EXTENSION
    191   rpcSlice->initSlice( pcPic->getLayerId() );
     196  UInt layerId = pcPic->getLayerId();
     197  rpcSlice->setVPS( vps );
     198  rpcSlice->initSlice( layerId );
    192199#else
    193200  rpcSlice->initSlice();
     
    337344  }
    338345
     346#if JCTVC_M0259_LAMBDAREFINEMENT
     347  if( rpcSlice->getLayerId() > 0 && depth >= 3 && m_pcCfg->getGOPSize() == ( 1 << depth ) )
     348  {
     349    Int nCurLayer = rpcSlice->getLayerId();
     350    Double gamma = xCalEnhLambdaFactor( m_ppcTEncTop[nCurLayer-1]->getQP() - m_ppcTEncTop[nCurLayer]->getQP() ,
     351      1.0 * m_ppcTEncTop[nCurLayer]->getSourceWidth() * m_ppcTEncTop[nCurLayer]->getSourceHeight()
     352      / m_ppcTEncTop[nCurLayer-1]->getSourceWidth() / m_ppcTEncTop[nCurLayer-1]->getSourceHeight() );
     353    dLambda *= gamma;
     354  }
     355#endif
     356
    339357  // store lambda
    340358  m_pcRdCost ->setLambda( dLambda );
     
    354372  qpc = Clip3( 0, 57, iQP + chromaQPOffset);
    355373  weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
     374#if JCTVC_M0259_LAMBDAREFINEMENT
     375  if( rpcSlice->getLayerId() > 0 && m_pcCfg->getGOPSize() >= 8 && rpcSlice->isIntra() == false && depth == 0 )
     376  {
     377    dLambda *= 1.1;
     378    weight *= 1.15;
     379  }
     380#endif
    356381  m_pcRdCost->setCrDistortionWeight(weight);
    357382#endif
     
    400425  rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
    401426 
     427#if L0386_DB_METRIC
     428  if ( m_pcCfg->getDeblockingFilterMetric() )
     429  {
     430    rpcSlice->setDeblockingFilterOverrideFlag(true);
     431    rpcSlice->setDeblockingFilterDisable(false);
     432    rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 );
     433    rpcSlice->setDeblockingFilterTcOffsetDiv2( 0 );
     434  } else
     435#endif
    402436  if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
    403437  {
     
    452486  rpcSlice->setMaxNumMergeCand        ( m_pcCfg->getMaxNumMergeCand()        );
    453487  xStoreWPparam( pPPS->getUseWP(), pPPS->getWPBiPred() );
     488
     489#if SVC_EXTENSION && REF_IDX_FRAMEWORK
     490  if( layerId > 0 )
     491  {
     492#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
     495    if( rpcSlice->getNumILRRefIdx() > 0 )
     496    {
     497      rpcSlice->setActiveNumILRRefIdx(1);
     498      rpcSlice->setInterLayerPredEnabledFlag(1);
     499    }
     500#else
     501    rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( layerId ) );
     502#endif
     503  }
     504
     505#endif
    454506}
    455507
     
    11821234 \retval rpcBitstream  bitstream class
    11831235 */
    1184 Void TEncSlice::encodeSlice   ( TComPic*& rpcPic, TComOutputBitstream* pcBitstream, TComOutputBitstream* pcSubstreams )
     1236Void TEncSlice::encodeSlice   ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams )
    11851237{
    11861238  UInt       uiCUAddr;
     
    13621414      }
    13631415      {
    1364           UInt uiCounter = 0;
    1365           vector<uint8_t>& rbsp   = pcSubstreams[uiSubStrm].getFIFO();
    1366           for (vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end();)
    1367           {
    1368             /* 1) find the next emulated 00 00 {00,01,02,03}
    1369              * 2a) if not found, write all remaining bytes out, stop.
    1370              * 2b) otherwise, write all non-emulated bytes out
    1371              * 3) insert emulation_prevention_three_byte
    1372              */
    1373             vector<uint8_t>::iterator found = it;
    1374             do
    1375             {
    1376               /* NB, end()-1, prevents finding a trailing two byte sequence */
    1377               found = search_n(found, rbsp.end()-1, 2, 0);
    1378               found++;
    1379               /* if not found, found == end, otherwise found = second zero byte */
    1380               if (found == rbsp.end())
    1381               {
    1382                 break;
    1383               }
    1384               if (*(++found) <= 3)
    1385               {
    1386                 break;
    1387               }
    1388             } while (true);
    1389             it = found;
    1390             if (found != rbsp.end())
    1391             {
    1392               it++;
    1393               uiCounter++;
    1394             }
    1395           }
    1396        
     1416        UInt numStartCodeEmulations = pcSubstreams[uiSubStrm].countStartCodeEmulations();
    13971417        UInt uiAccumulatedSubstreamLength = 0;
    13981418        for (Int iSubstrmIdx=0; iSubstrmIdx < iNumSubstreams; iSubstrmIdx++)
     
    14021422        // add bits coded in previous dependent slices + bits coded so far
    14031423        // add number of emulation prevention byte count in the tile
    1404         pcSlice->addTileLocation( ((pcSlice->getTileOffstForMultES() + uiAccumulatedSubstreamLength - uiBitsOriginallyInSubstreams) >> 3) + uiCounter );
     1424        pcSlice->addTileLocation( ((pcSlice->getTileOffstForMultES() + uiAccumulatedSubstreamLength - uiBitsOriginallyInSubstreams) >> 3) + numStartCodeEmulations );
    14051425      }
    14061426    }
     
    18751895}
    18761896
     1897#if JCTVC_M0259_LAMBDAREFINEMENT
     1898Double TEncSlice::xCalEnhLambdaFactor( Double deltaQP , Double beta )
     1899{
     1900  double tmp = beta * pow( 2.0 , deltaQP / 6 );
     1901  double gamma = tmp / ( tmp + 1 );
     1902  return( gamma );
     1903}
     1904#endif
    18771905//! \}
Note: See TracChangeset for help on using the changeset viewer.