Changeset 964 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/TEncGOP.cpp


Ignore:
Timestamp:
5 Jul 2014, 05:16:45 (10 years ago)
Author:
tech
Message:
  • Merged 11.0-dev0@963. (Update to HM 14.0 + MV-HEVC Draft 8 HLS)
  • Added coding results.
  • Changed version number.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibEncoder/TEncGOP.cpp

    r884 r964  
    7575  m_iNumPicCoded        = 0; //Niko
    7676  m_bFirst              = true;
     77#if ALLOW_RECOVERY_POINT_AS_RAP
     78  m_iLastRecoveryPicPOC = 0;
     79#endif
    7780 
    7881  m_pcCfg               = NULL;
     
    167170  SEIActiveParameterSets *seiActiveParameterSets = new SEIActiveParameterSets();
    168171  seiActiveParameterSets->activeVPSId = m_pcCfg->getVPS()->getVPSId();
    169   seiActiveParameterSets->m_fullRandomAccessFlag = false;
    170   seiActiveParameterSets->m_noParamSetUpdateFlag = false;
     172  seiActiveParameterSets->m_selfContainedCvsFlag = false;
     173  seiActiveParameterSets->m_noParameterSetUpdateFlag = false;
    171174  seiActiveParameterSets->numSpsIdsMinus1 = 0;
    172   seiActiveParameterSets->activeSeqParamSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
    173   seiActiveParameterSets->activeSeqParamSetId[0] = sps->getSPSId();
     175  seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
     176  seiActiveParameterSets->activeSeqParameterSetId[0] = sps->getSPSId();
    174177  return seiActiveParameterSets;
    175178}
     
    274277       seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue();
    275278       assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 );
     279       seiToneMappingInfo->m_exposureIndexIdc = m_pcCfg->getTMISEIExposurIndexIdc();
     280       seiToneMappingInfo->m_exposureIndexValue = m_pcCfg->getTMISEIExposurIndexValue();
     281       assert( seiToneMappingInfo->m_exposureIndexValue !=0 );
    276282       seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag();
    277283       seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator();
     
    428434  UInt *accumNalsDU = NULL;
    429435  SEIDecodingUnitInfo decodingUnitInfoSEI;
     436#if EFFICIENT_FIELD_IRAP
     437  Int IRAPGOPid = -1;
     438  Bool IRAPtoReorder = false;
     439  Bool swapIRAPForward = false;
     440  if(isField)
     441  {
     442    Int pocCurr;
     443#if !H_MV
     444    for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
     445#endif
     446    {
     447      // determine actual POC
     448      if(iPOCLast == 0) //case first frame or first top field
     449      {
     450        pocCurr=0;
     451      }
     452      else if(iPOCLast == 1 && isField) //case first bottom field, just like the first frame, the poc computation is not right anymore, we set the right value
     453      {
     454        pocCurr = 1;
     455      }
     456      else
     457      {
     458        pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField;
     459      }
     460
     461      // check if POC corresponds to IRAP
     462      NalUnitType tmpUnitType = getNalUnitType(pocCurr, m_iLastIDR, isField);
     463      if(tmpUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && tmpUnitType <= NAL_UNIT_CODED_SLICE_CRA) // if picture is an IRAP
     464      {
     465        if(pocCurr%2 == 0 && iGOPid < m_iGopSize-1 && m_pcCfg->getGOPEntry(iGOPid).m_POC == m_pcCfg->getGOPEntry(iGOPid+1).m_POC-1)
     466        { // if top field and following picture in enc order is associated bottom field
     467          IRAPGOPid = iGOPid;
     468          IRAPtoReorder = true;
     469          swapIRAPForward = true;
     470          break;
     471        }
     472        if(pocCurr%2 != 0 && iGOPid > 0 && m_pcCfg->getGOPEntry(iGOPid).m_POC == m_pcCfg->getGOPEntry(iGOPid-1).m_POC+1)
     473        {
     474          // if picture is an IRAP remember to process it first
     475          IRAPGOPid = iGOPid;
     476          IRAPtoReorder = true;
     477          swapIRAPForward = false;
     478          break;
     479        }
     480      }
     481    }
     482  }
     483#endif
    430484#if !H_MV
    431485  for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
    432486#endif
    433487  {
     488#if EFFICIENT_FIELD_IRAP
     489    if(IRAPtoReorder)
     490    {
     491      if(swapIRAPForward)
     492      {
     493        if(iGOPid == IRAPGOPid)
     494        {
     495          iGOPid = IRAPGOPid +1;
     496        }
     497        else if(iGOPid == IRAPGOPid +1)
     498        {
     499          iGOPid = IRAPGOPid;
     500        }
     501      }
     502      else
     503      {
     504        if(iGOPid == IRAPGOPid -1)
     505        {
     506          iGOPid = IRAPGOPid;
     507        }
     508        else if(iGOPid == IRAPGOPid)
     509        {
     510          iGOPid = IRAPGOPid -1;
     511        }
     512      }
     513    }
     514#endif
    434515    UInt uiColDir = 1;
    435516    //-- For time output for each slice
     
    500581    if(pocCurr>=m_pcCfg->getFramesToBeEncoded())
    501582    {
     583#if EFFICIENT_FIELD_IRAP
     584      if(IRAPtoReorder)
     585      {
     586        if(swapIRAPForward)
     587        {
     588          if(iGOPid == IRAPGOPid)
     589          {
     590            iGOPid = IRAPGOPid +1;
     591            IRAPtoReorder = false;
     592          }
     593          else if(iGOPid == IRAPGOPid +1)
     594          {
     595            iGOPid --;
     596          }
     597        }
     598        else
     599        {
     600          if(iGOPid == IRAPGOPid)
     601          {
     602            iGOPid = IRAPGOPid -1;
     603          }
     604          else if(iGOPid == IRAPGOPid -1)
     605          {
     606            iGOPid = IRAPGOPid;
     607            IRAPtoReorder = false;
     608          }
     609        }
     610      }
     611#endif
    502612#if H_MV
    503613      delete pcBitstreamRedirect;
     
    635745    }
    636746
    637     // Do decoding refresh marking if any
    638     pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic);
    639     m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
    640     pcSlice->getRPS()->setNumberOfLongtermPictures(0);
     747#if EFFICIENT_FIELD_IRAP
    641748#if FIX1172
    642749    if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     
    653760    pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC);
    654761#endif
    655 
     762#endif
     763    // Do decoding refresh marking if any
     764    pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic);
     765    m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
     766    pcSlice->getRPS()->setNumberOfLongtermPictures(0);
     767#if EFFICIENT_FIELD_IRAP
     768#else
     769#if FIX1172
     770    if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     771      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     772      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
     773      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
     774      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP
     775      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA )  // IRAP picture
     776    {
     777      m_associatedIRAPType = pcSlice->getNalUnitType();
     778      m_associatedIRAPPOC = pocCurr;
     779    }
     780    pcSlice->setAssociatedIRAPType(m_associatedIRAPType);
     781    pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC);
     782#endif
     783#endif
     784
     785#if ALLOW_RECOVERY_POINT_AS_RAP
     786    if ((pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false, m_iLastRecoveryPicPOC, m_pcCfg->getDecodingRefreshType() == 3) != 0) || (pcSlice->isIRAP())
     787#if EFFICIENT_FIELD_IRAP
     788      || (isField && pcSlice->getAssociatedIRAPType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getAssociatedIRAPType() <= NAL_UNIT_CODED_SLICE_CRA && pcSlice->getAssociatedIRAPPOC() == pcSlice->getPOC()+1)
     789#endif
     790      )
     791    {
     792      pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS(), pcSlice->isIRAP(), m_iLastRecoveryPicPOC, m_pcCfg->getDecodingRefreshType() == 3);
     793    }
     794#else
    656795    if ((pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0) || (pcSlice->isIRAP()))
    657796    {
    658797      pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS(), pcSlice->isIRAP());
    659798    }
     799#endif
    660800    pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS());
    661801
     
    14111551      }
    14121552      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 .
    1413       pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pcSlice->getPOC() - m_totalCoded;
     1553      pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(pcSlice->getSPS()->getMaxTLayers()-1) + pcSlice->getPOC() - m_totalCoded;
     1554#if EFFICIENT_FIELD_IRAP
     1555      if(IRAPGOPid > 0 && IRAPGOPid < m_iGopSize)
     1556      {
     1557        // if pictures have been swapped there is likely one more picture delay on their tid. Very rough approximation
     1558        pictureTimingSEI.m_picDpbOutputDelay ++;
     1559      }
     1560#endif
    14141561      Int factor = pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2;
    14151562      pictureTimingSEI.m_picDpbOutputDuDelay = factor * pictureTimingSEI.m_picDpbOutputDelay;
     
    15181665      sei_recovery_point.m_exactMatchingFlag = ( pcSlice->getPOC() == 0 ) ? (true) : (false);
    15191666      sei_recovery_point.m_brokenLinkFlag    = false;
     1667#if ALLOW_RECOVERY_POINT_AS_RAP
     1668      if(m_pcCfg->getDecodingRefreshType() == 3)
     1669      {
     1670        m_iLastRecoveryPicPOC = pocCurr;
     1671      }
     1672#endif
    15201673
    15211674      m_seiWriter.writeSEImessage( nalu.m_Bitstream, sei_recovery_point, pcSlice->getSPS() );
     
    16411794          }
    16421795          m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     1796
     1797#if SETTING_NO_OUT_PIC_PRIOR
     1798          if (pcSlice->isIRAP())
     1799          {
     1800            if (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP)
     1801            {
     1802              pcSlice->setNoRaslOutputFlag(true);
     1803            }
     1804            //the inference for NoOutputPriorPicsFlag
     1805            if (!m_bFirst && pcSlice->isIRAP() && pcSlice->getNoRaslOutputFlag())
     1806            {
     1807              if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
     1808              {
     1809                pcSlice->setNoOutputPriorPicsFlag(true);
     1810              }
     1811            }
     1812          }
     1813#endif
     1814
    16431815          tmpBitsBeforeWriting = m_pcEntropyCoder->getNumberOfWrittenBits();
    16441816          m_pcEntropyCoder->encodeSliceHeader(pcSlice);
     
    21532325      std::vector<Int> temp;
    21542326      TComSlice::markCurrPic( pcPic );
     2327#if !H_MV_HLS_8_DBP_NODOC_42
    21552328      TComSlice::markIvRefPicsAsUnused   ( m_ivPicLists, temp, pcPic->getSlice(0)->getVPS(), m_layerId, pcPic->getPOC() );
     2329#endif
    21562330#endif
    21572331      m_bFirst = false;
     
    21632337
    21642338      delete[] pcSubstreamsOut;
     2339
     2340#if EFFICIENT_FIELD_IRAP
     2341    if(IRAPtoReorder)
     2342    {
     2343      if(swapIRAPForward)
     2344      {
     2345        if(iGOPid == IRAPGOPid)
     2346        {
     2347          iGOPid = IRAPGOPid +1;
     2348          IRAPtoReorder = false;
     2349        }
     2350        else if(iGOPid == IRAPGOPid +1)
     2351        {
     2352          iGOPid --;
     2353        }
     2354      }
     2355      else
     2356      {
     2357        if(iGOPid == IRAPGOPid)
     2358        {
     2359          iGOPid = IRAPGOPid -1;
     2360        }
     2361        else if(iGOPid == IRAPGOPid -1)
     2362        {
     2363          iGOPid = IRAPGOPid;
     2364          IRAPtoReorder = false;
     2365        }
     2366      }
     2367    }
     2368#endif
    21652369  }
    21662370  delete pcBitstreamRedirect;
     
    24352639    case NAL_UNIT_CODED_SLICE_CRA: return "CRA";
    24362640    case NAL_UNIT_CODED_SLICE_RADL_R:     return "RADL_R";
     2641    case NAL_UNIT_CODED_SLICE_RADL_N:     return "RADL_N";
    24372642    case NAL_UNIT_CODED_SLICE_RASL_R:     return "RASL_R";
     2643    case NAL_UNIT_CODED_SLICE_RASL_N:     return "RASL_N";
    24382644    case NAL_UNIT_VPS: return "VPS";
    24392645    case NAL_UNIT_SPS: return "SPS";
     
    28383044    return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
    28393045  }
     3046#if EFFICIENT_FIELD_IRAP
     3047  if(isField && pocCurr == 1)
     3048  {
     3049    // to avoid the picture becoming an IRAP
     3050    return NAL_UNIT_CODED_SLICE_TRAIL_R;
     3051  }
     3052#endif
     3053
     3054#if ALLOW_RECOVERY_POINT_AS_RAP
     3055  if(m_pcCfg->getDecodingRefreshType() != 3 && (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0)
     3056#else
    28403057  if ((pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0)
     3058#endif
    28413059  {
    28423060    if (m_pcCfg->getDecodingRefreshType() == 1)
Note: See TracChangeset for help on using the changeset viewer.