Ignore:
Timestamp:
26 Sep 2014, 18:34:05 (10 years ago)
Author:
tech
Message:

Integration of various MV-HEVC HLS changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-12.0-dev1/source/App/TAppEncoder/TAppEncTop.cpp

    r1048 r1054  
    133133  xSetLayerIds             ( vps );   
    134134  xSetDimensionIdAndLength ( vps );
    135   xSetDependencies( vps );
     135  xSetDependencies         ( vps );
     136  xSetRepFormat            ( vps );
    136137  xSetProfileTierLevel     ( vps );
    137   xSetRepFormat            ( vps );
    138138  xSetLayerSets            ( vps );
    139139  xSetDpbSize              ( vps );
     
    144144  xDeriveDltArray          ( vps, dlt );
    145145#endif
    146 
     146#if H_MV_HLS10_GEN_FIX
     147  Bool wasEmpty = true;
     148  if ( m_targetEncLayerIdList.size() == 0 )
     149  {
     150    for (Int i = 0; i < m_numberOfLayers; i++ )
     151    {
     152      m_targetEncLayerIdList.push_back( m_layerIdInNuh[ i ] );
     153    }
     154  }
     155  for( Int i = (Int) m_targetEncLayerIdList.size()-1 ; i >= 0 ; i--)
     156  {
     157    Int iNuhLayerId = m_targetEncLayerIdList[i];
     158    Bool allRefLayersPresent = true;
     159    for( Int j = 0; j < vps.getNumRefLayers( iNuhLayerId ); j++)
     160    {
     161      allRefLayersPresent = allRefLayersPresent && xLayerIdInTargetEncLayerIdList( vps.getIdRefLayer( iNuhLayerId, j) );
     162    }
     163    if ( !allRefLayersPresent )
     164    {
     165      printf("\nCannot encode layer with nuh_layer_id equal to %d since not all reference layers are in TargetEncLayerIdList\n", iNuhLayerId);
     166      m_targetEncLayerIdList.erase( m_targetEncLayerIdList.begin() + i  );
     167    }
     168  }
     169#endif
     170
     171#if H_MV_HLS10_ADD_LAYERSETS
     172  if ( m_outputVpsInfo )
     173  { 
     174    vps.printLayerDependencies();
     175    vps.printLayerSets();
     176    vps.printPTL();
     177  }
     178#endif
    147179
    148180  for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++)
     
    248280#endif
    249281
     282#if H_MV
     283  m_cTEncTop.setProfile(m_profile[0]);
     284  m_cTEncTop.setLevel  (m_levelTier[0], m_level[0]);
     285#else
    250286  m_cTEncTop.setProfile(m_profile);
    251287  m_cTEncTop.setLevel(m_levelTier, m_level);
     288#endif
    252289  m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag);
    253290  m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag);
     
    801838 
    802839#if H_MV
     840#if H_MV_HLS10_GEN_FIX
     841  while ( (m_targetEncLayerIdList.size() != 0 ) && !allEos )
     842#else
    803843  while ( !allEos )
     844#endif
    804845  {
    805846    for(Int layer=0; layer < m_numberOfLayers; layer++ )
    806847    {
     848#if H_MV_HLS10_GEN_FIX
     849      if (!xLayerIdInTargetEncLayerIdList( m_layerIdInNuh[ layer ] ))
     850      {
     851        continue;
     852      }
     853#endif
     854
    807855      Int frmCnt = 0;
    808856      while ( !eos[layer] && !(frmCnt == gopSize))
     
    844892      for(Int layer=0; layer < m_numberOfLayers; layer++ )
    845893      {
     894#if H_MV_HLS10_GEN_FIX
     895        if (!xLayerIdInTargetEncLayerIdList( m_layerIdInNuh[ layer ] ))
     896        {
     897          continue;
     898        }
     899#endif
     900
    846901#if H_3D_VSO       
    847902          if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded )
     
    870925  for(Int layer=0; layer < m_numberOfLayers; layer++ )
    871926  {
     927#if H_MV_HLS10_GEN_FIX
     928    if (!xLayerIdInTargetEncLayerIdList( m_layerIdInNuh[ layer ] ))
     929    {
     930      continue;
     931    }
     932#endif
    872933    m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded(), m_isField );
    873934  }
     
    14991560Void TAppEncTop::xSetProfileTierLevel( TComVPS& vps )
    15001561{
     1562#if H_MV_HLS10_PTL
     1563
     1564  // SET PTL
     1565  assert( m_profile.size() == m_level.size() && m_profile.size() == m_levelTier.size() );
     1566  vps.setVpsNumProfileTierLevelMinus1( (Int) m_profile.size() - 1 );
     1567  for ( Int ptlIdx = 0; ptlIdx <= vps.getVpsNumProfileTierLevelMinus1(); ptlIdx++ )
     1568  {
     1569    if ( ptlIdx > 1 )
     1570    {
     1571      Bool vpsProfilePresentFlag = ( m_profile[ptlIdx] != m_profile[ptlIdx - 1] )
     1572        || ( m_inblFlag[ptlIdx ] != m_inblFlag[ptlIdx - 1] );
     1573      vps.setVpsProfilePresentFlag( ptlIdx, vpsProfilePresentFlag );
     1574    }
     1575
     1576    xSetProfileTierLevel( vps, ptlIdx, -1, m_profile[ptlIdx], m_level[ptlIdx],
     1577      m_levelTier[ ptlIdx ], m_progressiveSourceFlag, m_interlacedSourceFlag,
     1578      m_nonPackedConstraintFlag, m_frameOnlyConstraintFlag,  m_inblFlag[ptlIdx] );     
     1579  } 
     1580#else
    15011581  const Int vpsNumProfileTierLevelMinus1 = 0; //TBD
    15021582  vps.setVpsNumProfileTierLevelMinus1( vpsNumProfileTierLevelMinus1 );
     
    15061586    vps.setVpsProfilePresentFlag( i, true );
    15071587  }
     1588#endif
    15081589}
    15091590
     
    15251606  //repFormat->setSeparateColourPlaneVpsFlag( );
    15261607
     1608#if H_MV_HLS10_GEN_VSP_CONF_WIN
     1609  repFormat->setConformanceWindowVpsFlag( true );
     1610  repFormat->setConfWinVpsLeftOffset    ( m_confLeft   / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) );
     1611  repFormat->setConfWinVpsRightOffset   ( m_confRight  / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() )  );
     1612  repFormat->setConfWinVpsTopOffset     ( m_confTop    / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() )  );
     1613  repFormat->setConfWinVpsBottomOffset  ( m_confBottom / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) );
     1614#endif
     1615
    15271616  assert( vps.getRepFormat( 0 ) == NULL );
    15281617  vps.setRepFormat( 0 , repFormat );
     
    15401629  { 
    15411630    Int currLsIdx = vps.olsIdxToLsIdx( i );
     1631#if !H_MV_HLS10_ADD_LAYERSETS
    15421632    std::vector<Int> targetDecLayerIdList = vps.getTargetDecLayerIdList( i );
     1633#endif
    15431634    Bool subLayerFlagInfoPresentFlag = false;
    15441635
     
    15461637    {   
    15471638      Bool subLayerDpbInfoPresentFlag = false;
     1639#if !H_MV_HLS10_ADD_LAYERSETS
    15481640      assert( vps.getNumLayersInIdList( currLsIdx ) == targetDecLayerIdList.size() );
     1641#endif
    15491642      for( Int k = 0; k < vps.getNumLayersInIdList( currLsIdx ); k++ )   
    15501643      {
     1644#if H_MV_HLS10_DBP_SIZE
     1645        Int layerIdInVps = vps.getLayerIdInVps( vps.getLayerSetLayerIdList( currLsIdx, k ) );
     1646        if ( vps.getNecessaryLayerFlag( i,k ) && ( vps.getVpsBaseLayerInternalFlag() || vps.getLayerSetLayerIdList( currLsIdx, k ) != 0 ) )
     1647        {       
     1648          dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, m_maxDecPicBufferingMvc[ layerIdInVps ][ j ] - 1 );
     1649          if ( j > 0 )
     1650          {
     1651            subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ) != dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) );
     1652          }
     1653        }
     1654        else
     1655        {
     1656          if (vps.getNecessaryLayerFlag(i,k) && j == 0 && k == 0 )
     1657          {         
     1658            dpbSize->setMaxVpsDecPicBufferingMinus1(i, k ,j, 0 );
     1659          }
     1660        }
     1661#else
    15511662        Int layerIdInVps = vps.getLayerIdInVps( targetDecLayerIdList[k] );           
    15521663        dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, m_maxDecPicBufferingMvc[ layerIdInVps ][ j ] - 1 );
     1664
    15531665        if ( j > 0 )
    15541666        {
    15551667          subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ) != dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) );
    15561668        }
     1669#endif
    15571670      }       
    15581671
    15591672      Int maxNumReorderPics = MIN_INT;
     1673#if H_MV_HLS10_DBP_SIZE
     1674      for ( Int idx = 0; idx < vps.getNumLayersInIdList( currLsIdx ); idx++ )
     1675      {
     1676        if (vps.getNecessaryLayerFlag(i, idx ))
     1677        {       
     1678          Int layerIdInVps = vps.getLayerIdInVps( vps.getLayerSetLayerIdList(currLsIdx, idx) );       
     1679          maxNumReorderPics = std::max( maxNumReorderPics, m_numReorderPicsMvc[ layerIdInVps ][ j ] );
     1680        }
     1681      }
     1682#else
    15601683      for ( Int idx = 0; idx < targetDecLayerIdList.size(); idx++ )
    15611684      {
     
    15631686        maxNumReorderPics = std::max( maxNumReorderPics, m_numReorderPicsMvc[ layerIdInVps ][ j ] );
    15641687      }
     1688#endif
    15651689      assert( maxNumReorderPics != MIN_INT );
    15661690
     
    15881712}
    15891713
    1590 
    15911714Void TAppEncTop::xSetLayerSets( TComVPS& vps )
    15921715{   
     
    16101733  // Additional output layer sets + profileLevelTierIdx
    16111734  vps.setDefaultOutputLayerIdc      ( m_defaultOutputLayerIdc );   
     1735#if H_MV_HLS10_ADD_LAYERSETS
     1736  if( vps.getNumIndependentLayers() == 0 && m_numAddLayerSets > 0  )
     1737  {
     1738    fprintf( stderr, "\nWarning: Ignoring additional layer sets since NumIndependentLayers is equal to 0.\n");           
     1739  }
     1740  else
     1741  {
     1742    vps.setNumAddLayerSets( m_numAddLayerSets );
     1743    if ( m_highestLayerIdxPlus1.size() < vps.getNumAddLayerSets() )
     1744    {
     1745      fprintf(stderr, "\nError: Number of highestLayerIdxPlus1 parameters must be greater than or equal to NumAddLayerSets\n");
     1746      exit(EXIT_FAILURE);
     1747    }
     1748
     1749    for (Int i = 0; i < vps.getNumAddLayerSets(); i++)
     1750    {
     1751      if ( m_highestLayerIdxPlus1[ i ].size() < vps.getNumIndependentLayers() )
     1752      {
     1753        fprintf(stderr, "Error: Number of elements in highestLayerIdxPlus1[ %d ] parameters must be greater than or equal to NumIndependentLayers(= %d)\n", i, vps.getNumIndependentLayers());
     1754        exit(EXIT_FAILURE);
     1755      }
     1756
     1757      for (Int j = 1; j < vps.getNumIndependentLayers(); j++)
     1758      {
     1759        if ( m_highestLayerIdxPlus1[ i ][ j ]  < 0 || m_highestLayerIdxPlus1[ i ][ j ] > vps.getNumLayersInTreePartition( j ) )
     1760        {
     1761          fprintf(stderr, "Error: highestLayerIdxPlus1[ %d ][ %d ] shall be in the range of 0 to NumLayersInTreePartition[ %d ] (= %d ), inclusive. \n", i, j, j, vps.getNumLayersInTreePartition( j ) );
     1762          exit(EXIT_FAILURE);
     1763        }
     1764        vps.setHighestLayerIdxPlus1( i, j, m_highestLayerIdxPlus1[ i ][ j ] );
     1765      }
     1766      vps.deriveAddLayerSetLayerIdList( i );
     1767    }       
     1768  } 
     1769#else
    16121770  vps.setNumAddLayerSets            ( 0                             ); 
     1771#endif
    16131772  vps.setNumAddOlss                 ( numAddOuputLayerSets          );
    16141773  vps.initTargetLayerIdLists();
    16151774
     1775#if H_MV_HLS10_ADD_LAYERSETS
     1776  for (Int olsIdx = 0; olsIdx < vps.getNumLayerSets() + numAddOuputLayerSets; olsIdx++)
     1777  {
     1778    Int addOutLsIdx = olsIdx - vps.getNumLayerSets();     
     1779#else
    16161780  for (Int olsIdx = 0; olsIdx < m_vpsNumLayerSets + numAddOuputLayerSets; olsIdx++)
    16171781  {
    16181782    Int addOutLsIdx = olsIdx - m_vpsNumLayerSets;     
    1619    
     1783#endif   
    16201784    vps.setLayerSetIdxForOlsMinus1( olsIdx, ( ( addOutLsIdx < 0 ) ?  olsIdx  : m_outputLayerSetIdx[ addOutLsIdx ] ) - 1 );
    16211785
     1786#if H_MV_HLS10_ADD_LAYERSETS
     1787    Int lsIdx = vps.olsIdxToLsIdx( olsIdx );
     1788#else
    16221789    std::vector<Int>& layerIdList    = m_layerIdsInSets[ vps.olsIdxToLsIdx( olsIdx ) ];
    1623 
     1790#endif
    16241791    if (vps.getDefaultOutputLayerIdc() == 2 || addOutLsIdx >= 0 )
    16251792    {
     1793#if H_MV_HLS10_ADD_LAYERSETS
     1794      for ( Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++)
     1795#else
    16261796      for ( Int i = 0; i < layerIdList.size(); i++)
     1797#endif
    16271798      {
    16281799        vps.setOutputLayerFlag( olsIdx, i, ( olsIdx == 0 && i == 0 ) ? vps.inferOutputLayerFlag(olsIdx, i ) : false ); // This is a software only fix for a bug in the spec. In spec outputLayerFlag neither present nor inferred for this case !
     
    16341805      for (Int j = 0; j < outLayerIdList.size(); j++)
    16351806      {   
     1807#if H_MV_HLS10_ADD_LAYERSETS
     1808        for ( Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++)
     1809        {
     1810          if ( vps.getLayerSetLayerIdList( lsIdx, i ) == outLayerIdList[ j ] )
     1811#else
    16361812        for (Int i = 0; i < layerIdList.size(); i++ )
    16371813        {
    16381814          if ( layerIdList[ i ] == outLayerIdList[ j ] )
     1815#endif
    16391816          {
    16401817            vps.setOutputLayerFlag( olsIdx, i, true );       
     
    16431820          }
    16441821        }
    1645         assert( outputLayerInLayerSetFlag ); // The output layer is not not in the layer set.
     1822#if H_MV_HLS10_ADD_LAYERSETS
     1823        if ( !outputLayerInLayerSetFlag )
     1824        {
     1825          fprintf(stderr, "Error: Output layer %d in output layer set %d not in corresponding layer set %d \n", outLayerIdList[ j ], olsIdx , lsIdx );
     1826          exit(EXIT_FAILURE);
     1827        }
     1828#else
     1829        assert( outputLayerInLayerSetFlag ); // The output layer is not in the layer set.
     1830#endif
    16461831      }
    16471832    }
    16481833    else
    16491834    {
     1835#if H_MV_HLS10_ADD_LAYERSETS
     1836      for ( Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++)
     1837#else
    16501838      for ( Int i = 0; i < layerIdList.size(); i++)
     1839#endif
    16511840      {
    16521841        vps.setOutputLayerFlag( olsIdx, i, vps.inferOutputLayerFlag( olsIdx, i ) );       
     
    16541843    }
    16551844
     1845#if H_MV_HLS10_NESSECARY_LAYER
     1846    vps.deriveNecessaryLayerFlags( olsIdx );
     1847#endif
    16561848    vps.deriveTargetLayerIdList(  olsIdx );
    16571849
     1850#if H_MV_HLS10_PTL
     1851    // SET profile_tier_level_index.
     1852    if ( olsIdx == 0 )
     1853    {   
     1854      vps.setProfileTierLevelIdx( 0, 0 , vps.getMaxLayersMinus1() > 0 ? 1 : 0 );
     1855    }
     1856    else
     1857    {
     1858      Int lsIdx = vps.olsIdxToLsIdx( olsIdx );
     1859      if( (Int) m_profileTierLevelIdx[ olsIdx ].size() < vps.getNumLayersInIdList( lsIdx ) )
     1860      {
     1861        fprintf( stderr, "Warning: Not enough profileTierLevelIdx values given for the %d-th OLS. Inferring default values.\n", olsIdx );
     1862      }
     1863      for (Int j = 0; j < vps.getNumLayersInIdList( lsIdx ); j++)
     1864      {
     1865        if( j < (Int) m_profileTierLevelIdx[ olsIdx ].size() )
     1866        {
     1867          vps.setProfileTierLevelIdx(olsIdx, j, m_profileTierLevelIdx[olsIdx][j] );
     1868        }
     1869        else
     1870        {
     1871          // setting default values
     1872          if ( j == 0 || vps.getVpsNumProfileTierLevelMinus1() < 1 )
     1873          {
     1874            // set base layer as default
     1875            vps.setProfileTierLevelIdx(olsIdx, j, 1 );
     1876          }
     1877          else
     1878          {
     1879            // set VpsProfileTierLevel[2] as default
     1880            vps.setProfileTierLevelIdx(olsIdx, j, 2 );
     1881          }
     1882        }
     1883      }
     1884    }
     1885#else
    16581886    if ( olsIdx > 0 )
    16591887    {
    16601888      vps.setProfileLevelTierIdx( olsIdx, m_profileLevelTierIdx[ olsIdx ] );
    16611889    }
     1890#endif
    16621891   
    16631892    if ( vps.getNumOutputLayersInOutputLayerSet( olsIdx ) == 1 &&
     
    16971926    if( pcVPSVUI->getBitRatePresentVpsFlag( )  ||  pcVPSVUI->getPicRatePresentVpsFlag( ) )
    16981927    {
     1928#if H_MV_HLS10_VPS_VUI
     1929      for( Int i = 0; i  <  vps.getNumLayerSets(); i++ )
     1930#else
    16991931      for( Int i = 0; i  <=  vps.getVpsNumLayerSetsMinus1(); i++ )
     1932#endif
    17001933      {
    17011934        for( Int j = 0; j  <=  vps.getMaxTLayers(); j++ )
     
    17461979        for( Int j = 0; j < vps.getNumDirectRefLayers( vps.getLayerIdInNuh( i ) ) ; j++ )
    17471980        { 
     1981#if H_MV_HLS10_REF_PRED_LAYERS
     1982          Int layerIdx = vps.getLayerIdInVps( vps.getIdDirectRefLayer(vps.getLayerIdInNuh( i ) , j  )); 
     1983#else
    17481984          Int layerIdx = vps.getLayerIdInVps( vps.getRefLayerId(vps.getLayerIdInNuh( i ) , j  )); 
     1985#endif
    17491986          if( pcVPSVUI->getTilesInUseFlag( i )  &&  pcVPSVUI->getTilesInUseFlag( layerIdx ) ) 
    17501987          {
     
    17642001      }
    17652002    }
     2003
     2004#if H_MV_HLS10_VPS_VUI
     2005  pcVPSVUI->setSingleLayerForNonIrapFlag( m_singleLayerForNonIrapFlag );
     2006  pcVPSVUI->setHigherLayerIrapSkipFlag( m_higherLayerIrapSkipFlag );
     2007#endif
    17662008
    17672009    pcVPSVUI->setIlpRestrictedRefLayersFlag( m_ilpRestrictedRefLayersFlag );
Note: See TracChangeset for help on using the changeset viewer.