Changeset 979 in SHVCSoftware for branches/SHM-upgrade/source/Lib/TLibEncoder


Ignore:
Timestamp:
13 Jan 2015, 17:32:39 (10 years ago)
Author:
seregin
Message:

port implementation of JCTVC-R0071 - IRAP and EOS cross-layer impacts (rev 978)

Location:
branches/SHM-upgrade/source/Lib/TLibEncoder
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-upgrade/source/Lib/TLibEncoder/TEncCfg.h

    r916 r979  
    372372#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    373373  Int       m_adaptiveResolutionChange;
     374#endif
     375#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     376  int       m_layerSwitchOffBegin;
     377  int       m_layerSwitchOffEnd;
    374378#endif
    375379#if O0153_ALT_OUTPUT_LAYER_FLAG
     
    10481052  Int       getAdaptiveResolutionChange()      { return m_adaptiveResolutionChange; }
    10491053#endif
     1054#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     1055  Void      setLayerSwitchOffBegin(Int x)    { m_layerSwitchOffBegin = x;    }
     1056  Int       getLayerSwitchOffBegin()         { return m_layerSwitchOffBegin; }
     1057  Void      setLayerSwitchOffEnd(Int x)      { m_layerSwitchOffEnd = x;      }
     1058  Int       getLayerSwitchOffEnd()           { return m_layerSwitchOffEnd;   }
     1059#endif
    10501060#if HIGHER_LAYER_IRAP_SKIP_FLAG
    10511061  Void      setSkipPictureAtArcSwitch(Int x) { m_skipPictureAtArcSwitch = x;    }
  • branches/SHM-upgrade/source/Lib/TLibEncoder/TEncGOP.cpp

    r946 r979  
    122122  m_lastPocPeriodId = -1;
    123123#endif
     124#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     125  m_noRaslOutputFlag = false;
     126  m_prevPicHasEos    = false;
     127#endif
    124128#endif //SVC_EXTENSION
    125129  return;
     
    946950    }
    947951#endif
     952#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     953    if (pocCurr > m_pcEncTop->getLayerSwitchOffBegin() && pocCurr < m_pcEncTop->getLayerSwitchOffEnd())
     954    {
     955      continue;
     956    }
     957#endif
    948958
    949959    if( getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     
    11001110    }
    11011111#endif
     1112#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     1113    // Set the nal unit type
     1114    pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR, isField));
     1115#endif
    11021116#if NO_CLRAS_OUTPUT_FLAG
    11031117    if (m_layerId == 0 &&
     
    11131127        m_pcEncTop->setNoClrasOutputFlag(true);
    11141128      }
     1129#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     1130      else if (m_prevPicHasEos)
     1131      {
     1132        m_pcEncTop->setNoClrasOutputFlag(true);
     1133      }
     1134#endif
    11151135      else if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    11161136            || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     
    11391159      }
    11401160    }
     1161#endif
     1162#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     1163    xCheckLayerReset(pcSlice);
     1164    xSetNoRaslOutputFlag(pcSlice);
     1165    xSetLayerInitializedFlag(pcSlice);
    11411166#endif
    11421167#if M0040_ADAPTIVE_RESOLUTION_CHANGE
     
    12521277    }
    12531278   
     1279#if !R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
    12541280    // Set the nal unit type
    12551281    pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR, isField));
     1282#endif
    12561283#if SVC_EXTENSION
    12571284    if (m_layerId > 0)
     
    28532880      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    28542881
    2855       pcSlice->setNoRaslOutputFlag(false);
     2882#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
    28562883      if (pcSlice->isIRAP())
    28572884      {
    2858         if (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP)
    2859         {
    2860           pcSlice->setNoRaslOutputFlag(true);
    2861         }
    28622885        //the inference for NoOutputPriorPicsFlag
    28632886        // KJS: This cannot happen at the encoder
    2864         if (!m_bFirst && pcSlice->isIRAP() && pcSlice->getNoRaslOutputFlag())
     2887        if (!m_bFirst && pcSlice->isIRAP() && m_noRaslOutputFlag)
    28652888        {
    28662889          if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
     
    28702893        }
    28712894      }
     2895#else
     2896      pcSlice->setNoRaslOutputFlag(false);
     2897      if (pcSlice->isIRAP())
     2898      {
     2899        if (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP)
     2900        {
     2901          pcSlice->setNoRaslOutputFlag(true);
     2902        }
     2903        //the inference for NoOutputPriorPicsFlag
     2904        // KJS: This cannot happen at the encoder
     2905        if (!m_bFirst && pcSlice->isIRAP() && pcSlice->getNoRaslOutputFlag())
     2906        {
     2907          if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
     2908          {
     2909            pcSlice->setNoOutputPriorPicsFlag(true);
     2910          }
     2911        }
     2912      }
     2913#endif
    28722914
    28732915      tmpBitsBeforeWriting = m_pcEntropyCoder->getNumberOfWrittenBits();
     
    33623404      }
    33633405    }
     3406
     3407#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     3408    m_prevPicHasEos = false;
     3409    if (m_pcCfg->getLayerSwitchOffBegin() < m_pcCfg->getLayerSwitchOffEnd())
     3410    {
     3411      Int pocNext;
     3412      if (iGOPid == m_iGopSize - 1)
     3413      {
     3414        pocNext = iPOCLast - iNumPicRcvd + m_iGopSize + m_pcCfg->getGOPEntry(0).m_POC;
     3415      }
     3416      else
     3417      {
     3418        pocNext = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid + 1).m_POC;
     3419      }
     3420
     3421      if (pocNext > m_pcCfg->getLayerSwitchOffBegin() && pocCurr < m_pcCfg->getLayerSwitchOffEnd())
     3422      {
     3423        OutputNALUnit nalu(NAL_UNIT_EOS, pcSlice->getTLayer(), pcSlice->getLayerId());
     3424        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     3425        accessUnit.push_back(new NALUnitEBSP(nalu));
     3426        m_prevPicHasEos = true;
     3427      }
     3428    }
     3429#endif
    33643430
    33653431    xResetNonNestedSEIPresentFlags();
     
    52055271}
    52065272#endif
     5273
     5274#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     5275Void TEncGOP::xCheckLayerReset(TComSlice *slice)
     5276{
     5277  Bool layerResetFlag;
     5278  Int dolLayerId;
     5279
     5280  if (slice->isIRAP() && slice->getLayerId() > 0)
     5281  {
     5282    if (m_prevPicHasEos)
     5283    {
     5284      layerResetFlag = true;
     5285      dolLayerId = slice->getLayerId();
     5286    }
     5287    else if ((slice->isCRA() && slice->getHandleCraAsBlaFlag()) || (slice->isIDR() && slice->getCrossLayerBLAFlag()) || slice->isBLA())
     5288    {
     5289      layerResetFlag = true;
     5290      dolLayerId = slice->getLayerId();
     5291    }
     5292    else
     5293    {
     5294      layerResetFlag = false;
     5295    }
     5296
     5297    if (layerResetFlag)
     5298    {
     5299      for (Int i = 0; i < slice->getVPS()->getNumPredictedLayers(dolLayerId); i++)
     5300      {
     5301        Int iLayerId = slice->getVPS()->getPredictedLayerId(dolLayerId, i);
     5302        m_ppcTEncTop[iLayerId]->setLayerInitializedFlag(false);
     5303        m_ppcTEncTop[iLayerId]->setFirstPicInLayerDecodedFlag(false);
     5304      }
     5305
     5306      // Each picture that is in the DPB and has nuh_layer_id equal to dolLayerId is marked as "unused for reference".
     5307      for (TComList<TComPic*>::iterator pic = m_ppcTEncTop[dolLayerId]->getListPic()->begin(); pic != m_ppcTEncTop[dolLayerId]->getListPic()->end(); pic++)
     5308      {
     5309        if ((*pic)->getSlice(0)->getPOC() != slice->getPOC())
     5310        {
     5311          (*pic)->getSlice(0)->setReferenced(false);
     5312        }
     5313      }
     5314
     5315      // Each picture that is in DPB and has nuh_layer_id equal to any value of IdPredictedLayer[dolLayerId][i]
     5316      // for the values of i in range of 0 to NumPredictedLayers[dolLayerId] - 1, inclusive, is marked as "unused for reference"
     5317      for (UInt i = 0; i < slice->getVPS()->getNumPredictedLayers(dolLayerId); i++)
     5318      {
     5319        UInt predLId = slice->getVPS()->getPredictedLayerId(dolLayerId, i);
     5320        for (TComList<TComPic*>::iterator pic = m_ppcTEncTop[predLId]->getListPic()->begin(); pic != m_ppcTEncTop[predLId]->getListPic()->end(); pic++)
     5321        {
     5322          if ((*pic)->getSlice(0)->getPOC() != slice->getPOC())
     5323          {
     5324            (*pic)->getSlice(0)->setReferenced(false);
     5325          }
     5326        }
     5327      }
     5328    }
     5329  }
     5330}
     5331
     5332Void TEncGOP::xSetNoRaslOutputFlag(TComSlice *slice)
     5333{
     5334  if (slice->isIRAP())
     5335  {
     5336    m_noRaslOutputFlag = slice->getHandleCraAsBlaFlag();  // default value
     5337    if (slice->isIDR() || slice->isBLA() || m_bFirst || m_prevPicHasEos)
     5338    {
     5339      m_noRaslOutputFlag = true;
     5340    }
     5341    else if (!m_ppcTEncTop[m_layerId]->getLayerInitializedFlag())
     5342    {
     5343      Bool refLayersInitialized = true;
     5344      for (UInt j = 0; j < slice->getVPS()->getNumDirectRefLayers(m_layerId); j++)
     5345      {
     5346        UInt refLayerId = slice->getVPS()->getRefLayerId(m_layerId, j);
     5347        if (!m_ppcTEncTop[refLayerId]->getLayerInitializedFlag())
     5348        {
     5349          refLayersInitialized = false;
     5350        }
     5351      }
     5352      if (refLayersInitialized)
     5353      {
     5354        m_noRaslOutputFlag = true;
     5355      }
     5356    }
     5357  }
     5358}
     5359
     5360Void TEncGOP::xSetLayerInitializedFlag(TComSlice *slice)
     5361{
     5362  if (slice->isIRAP() && m_noRaslOutputFlag)
     5363  {
     5364    if (m_layerId == 0)
     5365    {
     5366      m_ppcTEncTop[m_layerId]->setLayerInitializedFlag(true);
     5367    }
     5368    else if (!m_ppcTEncTop[m_layerId]->getLayerInitializedFlag() && slice->getVPS()->getNumDirectRefLayers(m_layerId) == 0)
     5369    {
     5370      m_ppcTEncTop[m_layerId]->setLayerInitializedFlag(true);
     5371    }
     5372    else if (!m_ppcTEncTop[m_layerId]->getLayerInitializedFlag())
     5373    {
     5374      Bool refLayersInitialized = true;
     5375      for (UInt j = 0; j < slice->getVPS()->getNumDirectRefLayers(m_layerId); j++)
     5376      {
     5377        UInt refLayerId = slice->getVPS()->getRefLayerId(m_layerId, j);
     5378        if (!m_ppcTEncTop[refLayerId]->getLayerInitializedFlag())
     5379        {
     5380          refLayersInitialized = false;
     5381        }
     5382      }
     5383      if (refLayersInitialized)
     5384      {
     5385        m_ppcTEncTop[m_layerId]->setLayerInitializedFlag(true);
     5386      }
     5387    }
     5388  }
     5389}
     5390#endif // R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     5391
    52075392#endif //SVC_EXTENSION
    52085393
  • branches/SHM-upgrade/source/Lib/TLibEncoder/TEncGOP.h

    r916 r979  
    153153  Int   m_lastPocPeriodId;
    154154#endif
     155#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     156  Bool  m_noRaslOutputFlag;
     157  Bool  m_prevPicHasEos;
     158#endif
    155159#endif
    156160 
     
    280284  Void free_mem2DintWithPad(Int **array2D, Int iPadY, Int iPadX);
    281285#endif
     286#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     287  Void xCheckLayerReset(TComSlice *slice);
     288  Void xSetNoRaslOutputFlag(TComSlice *slice);
     289  Void xSetLayerInitializedFlag(TComSlice *slice);
     290#endif
    282291#endif //SVC_EXTENSION
    283292};// END CLASS DEFINITION TEncGOP
  • branches/SHM-upgrade/source/Lib/TLibEncoder/TEncTop.h

    r916 r979  
    163163  Int                     m_currPocMsb;
    164164#endif
     165#if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS
     166  Bool                    m_prevPicHasEos;
     167#endif
    165168#endif //SVC_EXTENSION
    166169protected:
Note: See TracChangeset for help on using the changeset viewer.