Ignore:
Timestamp:
10 Jun 2014, 01:10:15 (11 years ago)
Author:
qualcomm
Message:

JCTVC-P0041: Signalling and decoding of POC (Several macros)

The following macros describe the code each contains:

  1. POC_RESET_IDC_SIGNALLING - signalling of POC-related syntax elements
  2. POC_RESET_IDC_ENCODER - support for POC reset at encoder
  3. POC_RESET_IDC_DECODER - support for POC reset at decoder

In addition two bugfixes, under macros ALIGN_IRAP_BUGFIX and UNAVAILABLE_PIC_BUGFIX are also submitted.

From: Adarsh K. Ramasubramonian <aramasub@…>

File:
1 edited

Legend:

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

    r780 r798  
    9292  m_bRefreshPending     = 0;
    9393  m_pocCRA            = 0;
     94#if POC_RESET_IDC_ENCODER
     95  m_pocCraWithoutReset = 0;
     96  m_associatedIrapPocBeforeReset = 0;
     97#endif
    9498  m_numLongTermRefPicSPS = 0;
    9599  ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps));
     
    108112  m_temp = NULL;
    109113  m_pColorMappedPic = NULL;
     114#endif
     115#if POC_RESET_IDC_ENCODER
     116  m_lastPocPeriodId = -1;
    110117#endif
    111118#endif //SVC_EXTENSION
     
    903910    }
    904911#endif
     912#if POC_RESET_IDC_ENCODER
     913    pcSlice->setPocValueBeforeReset( pocCurr );
     914    // Check if the current picture is to be assigned as a reset picture
     915    determinePocResetIdc(pocCurr, pcSlice);
     916
     917    // If reset, do the following steps:
     918    if( pcSlice->getPocResetIdc() )
     919    {
     920      updatePocValuesOfPics(pocCurr, pcSlice);
     921    }
     922    else
     923    {
     924      // Check the base layer picture is IDR. If so, just set current POC equal to 0 (alignment of POC)
     925      if( ( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 2) && ( pocCurr % m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshInterval() == 0 ) )       
     926      {
     927        m_pcEncTop->setPocAdjustmentValue( pocCurr );
     928      }
     929      // else
     930      {
     931        // Just subtract POC by the current cumulative POC delta
     932        pcSlice->setPOC( pocCurr - m_pcEncTop->getPocAdjustmentValue() );
     933      }
     934
     935      Int maxPocLsb = 1 << pcSlice->getSPS()->getBitsForPOC();
     936      pcSlice->setPocMsbVal( pcSlice->getPOC() - ( pcSlice->getPOC() & (maxPocLsb-1) ) );
     937    }
     938    // Update the POC of current picture, pictures in the DPB, including references inside the reference pictures
     939
     940#endif
     941
    905942#if O0149_CROSS_LAYER_BLA_FLAG
    906943    if( m_layerId == 0 && (getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_N_LP) )
     
    12251262        else
    12261263        {
     1264#if ALIGN_IRAP_BUGFIX
     1265#if 0
    12271266          pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA);
     1267#endif
     1268#endif
    12281269        }
    12291270      }
     
    12721313    {
    12731314      m_associatedIRAPType = pcSlice->getNalUnitType();
     1315#if POC_RESET_IDC_ENCODER
     1316      m_associatedIRAPPOC = pcSlice->getPOC();
     1317      m_associatedIrapPocBeforeReset = pocCurr;
     1318#else
    12741319      m_associatedIRAPPOC = pocCurr;
     1320#endif
    12751321    }
    12761322    pcSlice->setAssociatedIRAPType(m_associatedIRAPType);
    12771323    pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC);
     1324    pcSlice->setAssociatedIrapPocBeforeReset(m_associatedIrapPocBeforeReset);
    12781325#endif
    12791326#endif
     
    12831330#else
    12841331    pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic);
     1332#endif
     1333#if POC_RESET_IDC_ENCODER
     1334    // m_pocCRA may have been update here; update m_pocCraWithoutReset
     1335    m_pocCraWithoutReset = m_pocCRA + m_pcEncTop->getPocAdjustmentValue();
    12851336#endif
    12861337    m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
     
    13201371#endif
    13211372#if ALIGNED_BUMPING
     1373#if POC_RESET_IDC_ENCODER
     1374    pcSlice->checkLeadingPictureRestrictions(rcListPic, true);
     1375#else
    13221376    pcSlice->checkLeadingPictureRestrictions(rcListPic);
     1377#endif
    13231378#endif
    13241379    pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS());
     
    15131568    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
    15141569    {
    1515 #if POC_RESET_FLAG
     1570#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    15161571      if ( pocCurr > 0          && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL())
    15171572#else
     
    18531908
    18541909      Int sliceQP = m_pcCfg->getInitialQP();
    1855 #if POC_RESET_FLAG
     1910#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    18561911      if ( ( pocCurr == 0 && m_pcCfg->getInitialQP() > 0 ) || ( frameLevel == 0 && m_pcCfg->getForceIntraQP() ) ) // QP is specified
    18571912#else
     
    23852440      }
    23862441      pictureTimingSEI.m_auCpbRemovalDelay = std::min<Int>(std::max<Int>(1, m_totalCoded - m_lastBPSEI), static_cast<Int>(pow(2, static_cast<double>(pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getCpbRemovalDelayLengthMinus1()+1)))); // Syntax element signalled as minus, hence the .
    2387 #if POC_RESET_FLAG
     2442#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    23882443      pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(pcSlice->getSPS()->getMaxTLayers()-1) + pocCurr - m_totalCoded;
    23892444#else
     
    25132568      SEIRecoveryPoint sei_recovery_point;
    25142569      sei_recovery_point.m_recoveryPocCnt    = 0;
    2515 #if POC_RESET_FLAG
     2570#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    25162571      sei_recovery_point.m_exactMatchingFlag = ( pocCurr == 0 ) ? (true) : (false);
    25172572#else
     
    32683323#endif
    32693324}
     3325
     3326#if POC_RESET_IDC_ENCODER
     3327Void TEncGOP::determinePocResetIdc(Int const pocCurr, TComSlice *const slice)
     3328{
     3329  // If one picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 1 or 2
     3330  // If BL picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 2
     3331  // If BL picture is IRAP, and another picture is non-IRAP, then the poc_reset_idc is equal to 1 or 2.
     3332  if( slice->getSliceIdx() == 0 ) // First slice - compute, copy for other slices
     3333  {
     3334    Int needReset = false;
     3335    Int resetDueToBL = false;
     3336    if( slice->getVPS()->getMaxLayers() > 1 )
     3337    {
     3338      // If IRAP is refreshed in this access unit for base layer
     3339      if( (m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 1 || m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 2)
     3340        && ( pocCurr % m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
     3341        )
     3342      {
     3343        // Check if the IRAP refresh interval of any layer does not match that of the base layer
     3344        for(Int i = 1; i < slice->getVPS()->getMaxLayers(); i++)
     3345        {
     3346          Bool refreshIntervalFlag = ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 );
     3347          Bool refreshTypeFlag     = ( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshType() );
     3348          if( !(refreshIntervalFlag && refreshTypeFlag) )
     3349          {
     3350            needReset = true;
     3351            resetDueToBL = true;
     3352            break;
     3353          }
     3354        }
     3355      }
     3356    }
     3357   
     3358    if( !needReset )// No need reset due to base layer IRAP
     3359    {
     3360      // Check if EL IDRs results in POC Reset
     3361      for(Int i = 1; i < slice->getVPS()->getMaxLayers() && !needReset; i++)
     3362      {
     3363        Bool idrFlag = ( (m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshType() == 2)
     3364                        && ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
     3365                        );
     3366        for(Int j = 0; j < slice->getVPS()->getMaxLayers(); j++)
     3367        {
     3368          if( j == i )
     3369          {
     3370            continue;
     3371          }
     3372          Bool idrOtherPicFlag = ( (m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshType() == 2)
     3373                                  && ( pocCurr % m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
     3374                                  );
     3375
     3376          if( idrFlag != idrOtherPicFlag )
     3377          {
     3378            needReset = true;
     3379            break;
     3380          }
     3381        }
     3382      }
     3383    }
     3384    if( needReset )
     3385    {
     3386      if( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 2 )  // BL IDR refresh, assuming BL picture present
     3387      {
     3388        if( resetDueToBL )
     3389        {
     3390          slice->setPocResetIdc( 2 ); // Full reset needed
     3391        }
     3392        else
     3393        {
     3394          slice->setPocResetIdc( 1 ); // Due to IDR in EL
     3395        }
     3396      }
     3397      else
     3398      {
     3399        slice->setPocResetIdc( 1 ); // Only MSB reset
     3400      }
     3401
     3402      // Start a new POC reset period
     3403      if (m_layerId == 0)   // Assuming BL picture is always present at encoder; for other AU structures, need to change this
     3404      {
     3405        Int periodId = rand() % 64;
     3406        m_lastPocPeriodId = (periodId == m_lastPocPeriodId) ? (periodId + 1) % 64 : periodId ;
     3407      }
     3408      else
     3409      {
     3410        m_lastPocPeriodId = m_ppcTEncTop[0]->getGOPEncoder()->getLastPocPeriodId();
     3411      }
     3412      slice->setPocResetPeriodId(m_lastPocPeriodId);
     3413    }
     3414    else
     3415    {
     3416      slice->setPocResetIdc( 0 );
     3417    }
     3418  }
     3419}
     3420
     3421Void TEncGOP::updatePocValuesOfPics(Int const pocCurr, TComSlice *const slice)
     3422{
     3423
     3424  Int pocAdjustValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3425
     3426  // New POC reset period
     3427  Int maxPocLsb, pocLsbVal, pocMsbDelta, pocLsbDelta, deltaPocVal;
     3428
     3429  maxPocLsb   = 1 << slice->getSPS()->getBitsForPOC();
     3430  pocLsbVal   = (slice->getPocResetIdc() == 3)
     3431                ? slice->getPocLsbVal()
     3432                : pocAdjustValue % maxPocLsb;
     3433  pocMsbDelta = pocAdjustValue - pocLsbVal;
     3434  pocLsbDelta = (slice->getPocResetIdc() == 2 || ( slice->getPocResetIdc() == 3 && slice->getFullPocResetFlag() ))
     3435                ? pocLsbVal
     3436                : 0;
     3437  deltaPocVal = pocMsbDelta  + pocLsbDelta;
     3438 
     3439  // Decrement value of associatedIrapPoc of the TEncGop object
     3440  this->m_associatedIRAPPOC -= deltaPocVal;
     3441
     3442  // Decrememnt the value of m_pocCRA
     3443  this->m_pocCRA -= deltaPocVal;
     3444
     3445  // Iterate through all pictures in the DPB
     3446  TComList<TComPic*>::iterator  iterPic = getListPic()->begin(); 
     3447  while( iterPic != getListPic()->end() )
     3448  {
     3449    TComPic *dpbPic = *iterPic;
     3450   
     3451    if( dpbPic->getReconMark() )
     3452    {
     3453      for(Int i = dpbPic->getNumAllocatedSlice() - 1; i >= 0; i--)
     3454      {
     3455        TComSlice *dpbPicSlice = dpbPic->getSlice( i );
     3456        TComReferencePictureSet *dpbPicRps = dpbPicSlice->getRPS();
     3457
     3458        // Decrement POC of slice
     3459        dpbPicSlice->setPOC( dpbPicSlice->getPOC() - deltaPocVal );
     3460
     3461        // Decrement POC value stored in the RPS of each such slice
     3462        for( Int j = dpbPicRps->getNumberOfPictures() - 1; j >= 0; j-- )
     3463        {
     3464          dpbPicRps->setPOC( j, dpbPicRps->getPOC(j) - deltaPocVal );
     3465        }
     3466
     3467        // Decrement value of refPOC
     3468        dpbPicSlice->decrementRefPocValues( deltaPocVal );
     3469
     3470        // Update value of associatedIrapPoc of each slice
     3471        dpbPicSlice->setAssociatedIRAPPOC( dpbPicSlice->getAssociatedIRAPPOC() - deltaPocVal );
     3472      }
     3473    }
     3474    iterPic++;
     3475  }
     3476 
     3477  // Actual POC value before reset
     3478  Int adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3479
     3480  // Set MSB value before reset
     3481  Int tempLsbVal = adjustedPocValue & (maxPocLsb - 1);
     3482  slice->setPocMsbVal( adjustedPocValue - tempLsbVal);
     3483
     3484  // Set LSB value before reset - this is needed in the case of resetIdc = 2
     3485  slice->setPicOrderCntLsb( tempLsbVal );
     3486
     3487  // Cumulative delta
     3488  m_pcEncTop->setPocAdjustmentValue( m_pcEncTop->getPocAdjustmentValue() + deltaPocVal );
     3489
     3490  // New LSB value, after reset
     3491  adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3492  Int newLsbVal = adjustedPocValue & (maxPocLsb - 1);
     3493
     3494  // Set value of POC current picture after RESET
     3495  if( slice->getPocResetIdc() == 1 )
     3496  {
     3497    slice->setPOC( newLsbVal );
     3498  }
     3499  else if( slice->getPocResetIdc() == 2 )
     3500  {
     3501    slice->setPOC( 0 );
     3502  }
     3503  else if( slice->getPocResetIdc() == 3 )
     3504  {
     3505    Int picOrderCntMsb = slice->getCurrMsb( newLsbVal,
     3506                                        slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(),
     3507                                        0,
     3508                                        maxPocLsb );
     3509    slice->setPOC( picOrderCntMsb + newLsbVal );
     3510  }
     3511  else
     3512  {
     3513    assert(0);
     3514  }
     3515}
     3516#endif
     3517
    32703518
    32713519#if !SVC_EXTENSION
     
    37163964      if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR(m_layerId) )
    37173965      {
     3966#if POC_RESET_IDC_ENCODER
     3967        printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     3968#else
    37183969        printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR(), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     3970#endif
    37193971      }
    37203972      else
    37213973      {
     3974#if POC_RESET_IDC_ENCODER
     3975        printf ("%d", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex));
     3976#else
    37223977        printf ("%d", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR());
     3978#endif
    37233979      }
    37243980#endif
     
    39474203    }
    39484204  }
     4205
     4206#if POC_RESET_IDC_ENCODER
     4207  if(m_pocCraWithoutReset > 0 && this->m_associatedIRAPType == NAL_UNIT_CODED_SLICE_CRA)
     4208  {
     4209    if(pocCurr < m_pocCraWithoutReset)
     4210#else
    39494211  if(m_pocCRA>0)
    39504212  {
    39514213    if(pocCurr<m_pocCRA)
     4214#endif
    39524215    {
    39534216      // All leading pictures are being marked as TFD pictures here since current encoder uses all
Note: See TracChangeset for help on using the changeset viewer.