Changeset 903 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibEncoder


Ignore:
Timestamp:
10 Oct 2014, 18:22:03 (11 years ago)
Author:
nokia
Message:

Integration of JCTVC-P0297 (poc_lsb_aligned_flag)

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

Legend:

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

    r902 r903  
    14891489
    14901490  WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag");
     1491#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1492  WRITE_FLAG(vps->getVpsPocLsbAlignedFlag(), "vps_poc_lsb_aligned_flag");
     1493#endif
    14911494#if O0062_POC_LSB_NOT_PRESENT_FLAG
    14921495  for(i = 1; i< vps->getMaxLayers(); i++)
     
    27012704  {
    27022705    // Derive the value of PocMsbValRequiredFlag
    2703     slice->setPocMsbValRequiredFlag( slice->getCraPicFlag() || slice->getBlaPicFlag()
    2704                                           /* || related to vps_poc_lsb_aligned_flag */
    2705                                           );
     2706#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2707    slice->setPocMsbValRequiredFlag( (slice->getCraPicFlag() || slice->getBlaPicFlag())
     2708                                  && (!slice->getVPS()->getVpsPocLsbAlignedFlag() ||
     2709                                      (slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0))
     2710                                   );
     2711#else
     2712    slice->setPocMsbValRequiredFlag( slice->getCraPicFlag() || slice->getBlaPicFlag() );
     2713#endif
    27062714
    27072715    // Determine value of SH extension length.
     
    27212729
    27222730
    2723     if( !slice->getPocMsbValRequiredFlag() /* &&  vps_poc_lsb_aligned_flag */ )
     2731#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2732    if (!slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag())
     2733#else
     2734    if (!slice->getPocMsbValRequiredFlag() /* &&  vps_poc_lsb_aligned_flag */)
     2735#endif
    27242736    {
    27252737      shExtnLengthInBit++;
     
    27372749    }
    27382750
    2739     if( slice->getPocMsbValPresentFlag() )
     2751#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2752    if (slice->getPocMsbNeeded())
     2753    {
     2754      slice->setPocMsbValPresentFlag(true);
     2755    }
     2756#endif
     2757
     2758    if (slice->getPocMsbValPresentFlag())
    27402759    {
    27412760      UInt lengthVal = 1;
     
    27712790    }
    27722791
    2773     if( !slice->getPocMsbValRequiredFlag() /* &&  vps_poc_lsb_aligned_flag */ )
    2774     {
     2792#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2793    if (!slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag())
     2794#else
     2795    if (!slice->getPocMsbValRequiredFlag() /* &&  vps_poc_lsb_aligned_flag */)
     2796#endif
     2797    {
     2798#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2799      WRITE_FLAG( slice->getPocMsbValPresentFlag(),                           "poc_msb_cycle_val_present_flag" );
     2800#else
    27752801      WRITE_FLAG( slice->getPocMsbValPresentFlag(),                           "poc_msb_val_present_flag" );
    2776     }
    2777     if( slice->getPocMsbValPresentFlag() )
    2778     {
    2779       assert( slice->getPocMsbVal() % maxPocLsb == 0 );
    2780       WRITE_UVLC( slice->getPocMsbVal() / maxPocLsb,                                      "poc_msb_val" );
     2802#endif
     2803    }
     2804    if (slice->getPocMsbValPresentFlag())
     2805    {
     2806      assert(slice->getPocMsbVal() % maxPocLsb == 0);
     2807#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2808      WRITE_UVLC(slice->getPocMsbVal() / maxPocLsb, "poc_msb_cycle_val");
     2809#else
     2810      WRITE_UVLC(slice->getPocMsbVal() / maxPocLsb, "poc_msb_val");
     2811#endif
    27812812    }
    27822813    for (Int i = 0; i < shExtnAdditionalBits; i++)
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r899 r903  
    909909    determinePocResetIdc(pocCurr, pcSlice);
    910910
     911#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     912    Bool pocResettingFlag = false;
     913
     914    if (pcSlice->getPocResetIdc() != 0)
     915    {
     916      if (pcSlice->getVPS()->getVpsPocLsbAlignedFlag())
     917      {
     918        pocResettingFlag = true;
     919      }
     920      else if (m_pcEncTop->getPocDecrementedInDPBFlag())
     921      {
     922        pocResettingFlag = false;
     923      }
     924      else
     925      {
     926        pocResettingFlag = true;
     927      }
     928    }
     929#endif
     930
    911931    // If reset, do the following steps:
     932#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     933    if( pocResettingFlag )
     934#else
    912935    if( pcSlice->getPocResetIdc() )
     936#endif
    913937    {
    914938      updatePocValuesOfPics(pocCurr, pcSlice);
     
    33973421      pcPicYuvRecOut->setReconstructed(true);
    33983422#endif
    3399 
     3423#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3424      m_pcEncTop->setFirstPicInLayerDecodedFlag(true);
     3425#endif
    34003426      pcPic->setReconMark   ( true );
    34013427      m_bFirst = false;
     
    34563482  // If BL picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 2
    34573483  // If BL picture is IRAP, and another picture is non-IRAP, then the poc_reset_idc is equal to 1 or 2.
     3484#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3485  slice->setPocMsbNeeded(false);
     3486#endif
    34583487  if( slice->getSliceIdx() == 0 ) // First slice - compute, copy for other slices
    34593488  {
     
    35153544        {
    35163545          slice->setPocResetIdc( 2 ); // Full reset needed
     3546#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3547          if (slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0)
     3548          {
     3549            slice->setPocMsbNeeded(true);  // Force msb writing
     3550          }
     3551#endif
    35173552        }
    35183553        else
     
    35313566        Int periodId = rand() % 64;
    35323567        m_lastPocPeriodId = (periodId == m_lastPocPeriodId) ? (periodId + 1) % 64 : periodId ;
     3568
     3569#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3570        for (UInt i = 0; i < MAX_LAYERS; i++)
     3571        {
     3572          m_ppcTEncTop[i]->setPocDecrementedInDPBFlag(false);
     3573        }
     3574#endif
    35333575      }
    35343576      else
     
    35473589Void TEncGOP::updatePocValuesOfPics(Int const pocCurr, TComSlice *const slice)
    35483590{
     3591#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3592  UInt affectedLayerList[MAX_NUM_LAYER_IDS];
     3593  Int  numAffectedLayers;
     3594
     3595  affectedLayerList[0] = m_layerId;
     3596  numAffectedLayers = 1;
     3597
     3598  if (m_pcEncTop->getVPS()->getVpsPocLsbAlignedFlag())
     3599  {
     3600    for (UInt j = 0; j < m_pcEncTop->getVPS()->getNumPredictedLayers(m_layerId); j++)
     3601    {
     3602      affectedLayerList[j + 1] = m_pcEncTop->getVPS()->getPredictedLayerId(m_layerId, j);
     3603    }
     3604    numAffectedLayers = m_pcEncTop->getVPS()->getNumPredictedLayers(m_layerId) + 1;
     3605  }
     3606#endif
    35493607
    35503608  Int pocAdjustValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     
    35543612
    35553613  maxPocLsb   = 1 << slice->getSPS()->getBitsForPOC();
     3614
     3615#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3616  Int adjustedPocValue = pocCurr;
     3617
     3618  if (m_pcEncTop->getFirstPicInLayerDecodedFlag())
     3619  {
     3620#endif
     3621
    35563622  pocLsbVal   = (slice->getPocResetIdc() == 3)
    35573623                ? slice->getPocLsbVal()
     
    35623628                : 0;
    35633629  deltaPocVal = pocMsbDelta  + pocLsbDelta;
    3564  
     3630
     3631#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3632  Int origDeltaPocVal = deltaPocVal;  // original value needed when updating POC adjustment value
     3633
     3634  if (slice->getPocMsbNeeded())  // IDR picture in base layer, non-IDR picture in other layers, poc_lsb_aligned_flag = 1
     3635  {
     3636    if (slice->getLayerId() == 0)
     3637    {
     3638      int highestPoc = INT_MIN;
     3639      // Find greatest POC in DPB for layer 0
     3640      for (TComList<TComPic*>::iterator iterPic = m_pcEncTop->getListPic()->begin(); iterPic != m_pcEncTop->getListPic()->end(); ++iterPic)
     3641      {
     3642        TComPic *dpbPic = *iterPic;
     3643        if (dpbPic->getReconMark() && dpbPic->getLayerId() == 0 && dpbPic->getPOC() > highestPoc)
     3644        {
     3645          highestPoc = dpbPic->getPOC();
     3646        }
     3647      }
     3648      deltaPocVal = (highestPoc - (highestPoc & (maxPocLsb - 1))) + 1*maxPocLsb;
     3649      m_pcEncTop->setCurrPocMsb(deltaPocVal);
     3650    }
     3651    else
     3652    {
     3653      deltaPocVal = m_ppcTEncTop[0]->getCurrPocMsb();  // copy from base layer
     3654    }
     3655    slice->setPocMsbVal(deltaPocVal);
     3656  }
     3657#endif
     3658
     3659#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3660  for (UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++)
     3661  {
     3662    if (!m_ppcTEncTop[affectedLayerList[layerIdx]]->getPocDecrementedInDPBFlag())
     3663    {
     3664      m_ppcTEncTop[affectedLayerList[layerIdx]]->setPocDecrementedInDPBFlag(true);
     3665
     3666      // Decrement value of associatedIrapPoc of the TEncGop object
     3667      m_ppcTEncTop[affectedLayerList[layerIdx]]->getGOPEncoder()->m_associatedIRAPPOC -= deltaPocVal;
     3668
     3669      // Decrememnt the value of m_pocCRA
     3670      m_ppcTEncTop[affectedLayerList[layerIdx]]->getGOPEncoder()->m_pocCRA -= deltaPocVal;
     3671
     3672      TComList<TComPic*>::iterator  iterPic = m_ppcTEncTop[affectedLayerList[layerIdx]]->getListPic()->begin();
     3673      while (iterPic != m_ppcTEncTop[affectedLayerList[layerIdx]]->getListPic()->end())
     3674#else
    35653675  // Decrement value of associatedIrapPoc of the TEncGop object
    35663676  this->m_associatedIRAPPOC -= deltaPocVal;
     
    35723682  TComList<TComPic*>::iterator  iterPic = getListPic()->begin(); 
    35733683  while( iterPic != getListPic()->end() )
     3684#endif
    35743685  {
    35753686    TComPic *dpbPic = *iterPic;
     
    35963707        // Update value of associatedIrapPoc of each slice
    35973708        dpbPicSlice->setAssociatedIRAPPOC( dpbPicSlice->getAssociatedIRAPPOC() - deltaPocVal );
     3709
     3710#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3711        if (slice->getPocMsbNeeded())
     3712        {
     3713          // this delta value is needed when computing delta POCs in reference picture set initialization
     3714          dpbPicSlice->setPocResetDeltaPoc(dpbPicSlice->getPocResetDeltaPoc() + (deltaPocVal - pocLsbVal));
     3715        }
     3716#endif
    35983717      }
    35993718    }
    36003719    iterPic++;
    36013720  }
    3602  
     3721#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3722    }
     3723  }
     3724#endif
     3725
    36033726  // Actual POC value before reset
     3727#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3728  adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3729#else
    36043730  Int adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3731#endif
    36053732
    36063733  // Set MSB value before reset
    36073734  Int tempLsbVal = adjustedPocValue & (maxPocLsb - 1);
    3608   slice->setPocMsbVal( adjustedPocValue - tempLsbVal);
     3735#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3736  if (!slice->getPocMsbNeeded())  // set poc msb normally if special msb handling is not needed
     3737  {
     3738#endif
     3739    slice->setPocMsbVal(adjustedPocValue - tempLsbVal);
     3740#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3741  }
     3742#endif
    36093743
    36103744  // Set LSB value before reset - this is needed in the case of resetIdc = 2
     
    36123746
    36133747  // Cumulative delta
     3748#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3749  deltaPocVal = origDeltaPocVal;  // restore deltaPoc for correct adjustment value update
     3750#endif
    36143751  m_pcEncTop->setPocAdjustmentValue( m_pcEncTop->getPocAdjustmentValue() + deltaPocVal );
     3752
     3753#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3754  }
     3755#endif
    36153756
    36163757  // New LSB value, after reset
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r901 r903  
    9898  m_noOutputOfPriorPicsFlags   = false;
    9999#endif
     100#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     101  m_pocDecrementedInDPBFlag    = false;
     102#endif
    100103#endif //SVC_EXTENSION
    101104}
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.h

    r849 r903  
    168168  int                     m_numAddLayerSets;
    169169#endif
     170#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     171  Bool                    m_pocDecrementedInDPBFlag;
     172  Int                     m_currPocMsb;
     173#endif
    170174#endif //SVC_EXTENSION
    171175protected:
     
    306310  Int  getNumAddLayerSets()                  { return m_numAddLayerSets; }
    307311#endif
     312#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     313  Void setPocDecrementedInDPBFlag(Bool x)    { m_pocDecrementedInDPBFlag = x; }
     314  Bool getPocDecrementedInDPBFlag()          { return m_pocDecrementedInDPBFlag; }
     315  Void setCurrPocMsb(Int poc)                { m_currPocMsb = poc; }
     316  Int  getCurrPocMsb()                       { return m_currPocMsb; }
     317#endif
    308318#else //SVC_EXTENSION
    309319  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
Note: See TracChangeset for help on using the changeset viewer.