Ignore:
Timestamp:
11 Dec 2015, 00:05:48 (8 years ago)
Author:
seregin
Message:

infer parameters in SPS after activation, fixing chroma scaling for non 4:2:0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r1475 r1502  
    184184  {
    185185    UInt prevLayerIdx = 0;
    186     UInt prevLayerId  = 0;
    187 
    188     if (pcTEncTop->getNumActiveRefLayers() > 0)
     186
     187    if( pcTEncTop->getNumActiveRefLayers() > 0 )
    189188    {
    190189      prevLayerIdx = pcTEncTop->getPredLayerIdx( pcTEncTop->getNumActiveRefLayers() - 1);
    191       prevLayerId  = pcTEncTop->getRefLayerId(prevLayerIdx);     
    192     }
    193 
    194     const TComVPS *vps = pcTEncTop->getVPS();
     190    }
     191
    195192    const TComSPS *sps = pcTEncTop->getSPS();
    196193
    197     const Int bitDepthLuma = vps->getBitDepth(CHANNEL_TYPE_LUMA, sps, pcTEncTop->getLayerId());
    198     const Int bitDepthChroma = vps->getBitDepth(CHANNEL_TYPE_CHROMA, sps, pcTEncTop->getLayerId());
    199     const Int prevBitDepthLuma = vps->getBitDepth(CHANNEL_TYPE_LUMA, m_ppcTEncTop[prevLayerIdx]->getSPS(), prevLayerId);
    200     const Int prevBitDepthChroma = vps->getBitDepth(CHANNEL_TYPE_CHROMA, m_ppcTEncTop[prevLayerIdx]->getSPS(), prevLayerId);
     194    const Int bitDepthLuma = sps->getBitDepth(CHANNEL_TYPE_LUMA);
     195    const Int bitDepthChroma = sps->getBitDepth(CHANNEL_TYPE_CHROMA);
     196    const Int prevBitDepthLuma = m_ppcTEncTop[prevLayerIdx]->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
     197    const Int prevBitDepthChroma = m_ppcTEncTop[prevLayerIdx]->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA);
    201198
    202199    m_Enc3DAsymLUTPicUpdate.create( m_pcCfg->getCGSMaxOctantDepth() , prevBitDepthLuma, prevBitDepthChroma, bitDepthLuma, bitDepthChroma , m_pcCfg->getCGSMaxYPartNumLog2() );
    203     m_Enc3DAsymLUTPPS.create( m_pcCfg->getCGSMaxOctantDepth(), prevBitDepthLuma, prevBitDepthChroma, bitDepthLuma, bitDepthChroma , m_pcCfg->getCGSMaxYPartNumLog2() );
     200    m_Enc3DAsymLUTPPS.create( m_pcCfg->getCGSMaxOctantDepth(), prevBitDepthLuma, prevBitDepthChroma, bitDepthLuma, bitDepthChroma, m_pcCfg->getCGSMaxYPartNumLog2() );
    204201
    205202    if(!m_pColorMappedPic)
     
    10711068cabac_zero_word_padding(TComSlice *const pcSlice, TComPic *const pcPic, const std::size_t binCountsInNalUnits, const std::size_t numBytesInVclNalUnits, std::ostringstream &nalUnitData, const Bool cabacZeroWordPaddingEnabled)
    10721069{
    1073 #if !SVC_EXTENSION
    10741070  const TComSPS &sps=*(pcSlice->getSPS());
    1075 #endif
    10761071  const Int log2subWidthCxsubHeightC = (pcPic->getComponentScaleX(COMPONENT_Cb)+pcPic->getComponentScaleY(COMPONENT_Cb));
    10771072  const Int minCuWidth  = pcPic->getMinCUWidth();
    10781073  const Int minCuHeight = pcPic->getMinCUHeight();
    1079 #if SVC_EXTENSION
    1080   const Int paddedWidth = ((pcSlice->getPicWidthInLumaSamples()  + minCuWidth  - 1) / minCuWidth) * minCuWidth;
    1081   const Int paddedHeight= ((pcSlice->getPicHeightInLumaSamples() + minCuHeight - 1) / minCuHeight) * minCuHeight;
    1082   const Int rawBits = paddedWidth * paddedHeight *
    1083                          (pcSlice->getBitDepth(CHANNEL_TYPE_LUMA) + 2*(pcSlice->getBitDepth(CHANNEL_TYPE_CHROMA)>>log2subWidthCxsubHeightC));
    1084 #else
    10851074  const Int paddedWidth = ((sps.getPicWidthInLumaSamples()  + minCuWidth  - 1) / minCuWidth) * minCuWidth;
    10861075  const Int paddedHeight= ((sps.getPicHeightInLumaSamples() + minCuHeight - 1) / minCuHeight) * minCuHeight;
    10871076  const Int rawBits = paddedWidth * paddedHeight *
    10881077                         (sps.getBitDepth(CHANNEL_TYPE_LUMA) + 2*(sps.getBitDepth(CHANNEL_TYPE_CHROMA)>>log2subWidthCxsubHeightC));
    1089 #endif
    10901078  const std::size_t threshold = (32/3)*numBytesInVclNalUnits + (rawBits/32);
    10911079  if (binCountsInNalUnits >= threshold)
     
    16671655          {
    16681656            //downsampling
    1669             xDownScalePic(pcPic->getPicYuvOrg(), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg(), pcSlice->getBitDepths(), pcPic->getPosScalingFactor(refLayerIdc, 0));
     1657            xDownScalePic(pcPic->getPicYuvOrg(), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg(), pcSlice->getSPS()->getBitDepths(), pcPic->getPosScalingFactor(refLayerIdc, 0));
    16701658           
    16711659            m_Enc3DAsymLUTPPS.setDsOrigPic(pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg());
     
    16981686          if( pcSlice->getVPS()->isSamplePredictionType( pcSlice->getVPS()->getLayerIdxInVps(m_layerId), pcSlice->getVPS()->getLayerIdxInVps(refLayerId) ) )
    16991687          {
    1700             m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getBitDepth(CHANNEL_TYPE_LUMA), pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getBitDepth(CHANNEL_TYPE_CHROMA) );
     1688            m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA), pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) );
    17011689          }
    17021690        }
     
    23832371      }
    23842372
    2385 #if SVC_EXTENSION
    2386       sliceQP = Clip3( -pcSlice->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, sliceQP );
    2387 #else
    23882373      sliceQP = Clip3( -pcSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, sliceQP );
    2389 #endif
    23902374      m_pcRateCtrl->getRCPic()->setPicEstQP( sliceQP );
    23912375
     
    27002684    {
    27012685      SEIDecodedPictureHash *decodedPictureHashSei = new SEIDecodedPictureHash();
    2702 #if SVC_EXTENSION
    2703       m_seiEncoder.initDecodedPictureHashSEI(decodedPictureHashSei, pcPic, digestStr, pcSlice->getBitDepths());
    2704 #else
    27052686      m_seiEncoder.initDecodedPictureHashSEI(decodedPictureHashSei, pcPic, digestStr, pcSlice->getSPS()->getBitDepths());
    2706 #endif
    27072687      trailingSeiMessages.push_back(decodedPictureHashSei);
    27082688    }
     
    28822862  if (!bCalcDist)
    28832863  {
    2884 #if SVC_EXTENSION
    2885     ruiDist = xFindDistortionFrame(pcPic->getPicYuvOrg(), pcPic->getPicYuvRec(), pcPic->getSlice(0)->getBitDepths());
    2886 #else
    28872864    ruiDist = xFindDistortionFrame(pcPic->getPicYuvOrg(), pcPic->getPicYuvRec(), pcPic->getPicSym()->getSPS().getBitDepths());
    2888 #endif
    28892865  }
    28902866}
     
    30983074      pRec += iRecStride;
    30993075    }
    3100 #if SVC_EXTENSION
    3101     const Int maxval = 255 << (pcPic->getSlice(0)->getBitDepth(toChannelType(ch)) - 8);
    3102 #else
    31033076    const Int maxval = 255 << (pcPic->getPicSym()->getSPS().getBitDepth(toChannelType(ch)) - 8);
    3104 #endif
    31053077    const Double fRefValue = (Double) maxval * maxval * iSize;
    31063078    dPSNR[ch]         = ( uiSSDtemp ? 10.0 * log10( fRefValue / (Double)uiSSDtemp ) : 999.99 );
     
    32543226                                           const InputColourSpaceConversion conversion, const Bool printFrameMSE )
    32553227{
    3256 #if !SVC_EXTENSION
    32573228  const TComSPS &sps=pcPicOrgFirstField->getPicSym()->getSPS();
    3258 #endif
    32593229  Double  dPSNR[MAX_NUM_COMPONENT];
    32603230  TComPic    *apcPicOrgFields[2]={pcPicOrgFirstField, pcPicOrgSecondField};
     
    33173287      }
    33183288    }
    3319 #if SVC_EXTENSION
    3320     const Int maxval = 255 << (pcPicOrgFirstField->getSlice(0)->getBitDepth(toChannelType(ch)) - 8);
    3321 #else
    33223289    const Int maxval = 255 << (sps.getBitDepth(toChannelType(ch)) - 8);
    3323 #endif
    33243290    const Double fRefValue = (Double) maxval * maxval * iSize*2;
    33253291    dPSNR[ch]         = ( uiSSDtemp ? 10.0 * log10( fRefValue / (Double)uiSSDtemp ) : 999.99 );
     
    36013567
    36023568  Int qp = pcPic->getSlice(0)->getSliceQp();
    3603 #if SVC_EXTENSION
    3604   const Int bitDepthLuma=pcPic->getSlice(0)->getBitDepth(CHANNEL_TYPE_LUMA);
    3605 #else
    36063569  const Int bitDepthLuma=pcPic->getSlice(0)->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
    3607 #endif
    36083570  Int bitdepthScale = 1 << (bitDepthLuma-8);
    36093571  Int beta = TComLoopFilter::getBeta( qp ) * bitdepthScale;
     
    40964058}
    40974059
    4098 Void TEncGOP::xDownScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest, BitDepths& bitDepth, const Int posScalingFactorX)
     4060Void TEncGOP::xDownScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest, const BitDepths& bitDepth, const Int posScalingFactorX)
    40994061{
    41004062  pcYuvSrc->setBorderExtension(false);
     
    41584120#endif
    41594121#endif
    4160 Void TEncGOP::xFilterImg( Pel *src, Int iSrcStride, Pel *dst, Int iDstStride, Int height, Int width, BitDepths& bitDepth, ComponentID comp )
     4122Void TEncGOP::xFilterImg( Pel *src, Int iSrcStride, Pel *dst, Int iDstStride, Int height, Int width, const BitDepths& bitDepth, ComponentID comp )
    41614123{
    41624124  Int height2, width2;
Note: See TracChangeset for help on using the changeset viewer.