Changeset 494 in SHVCSoftware for trunk/source/App/TAppEncoder/TAppEncTop.cpp


Ignore:
Timestamp:
16 Nov 2013, 22:09:25 (11 years ago)
Author:
seregin
Message:

reintegrate branch SHM-4.0-dev

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/source

  • TabularUnified trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r442 r494  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2013, ITU/ISO/IEC
     
    9898    // Auto generation of the format index
    9999    if( m_acLayerCfg[layer].getRepFormatIdx() == -1 )
    100     {
    101       // Currently only picture width and height are considred. It has to be updated if different chroma format and bit-depth will are used.
     100    {     
    102101      Bool found = false;
    103102      for( UInt idx = 0; idx < layer; idx++ )
    104103      {
    105         if( m_acLayerCfg[layer].getSourceWidth() == m_acLayerCfg[idx].getSourceWidth() && m_acLayerCfg[layer].getSourceHeight() == m_acLayerCfg[idx].getSourceHeight() )
     104        if( m_acLayerCfg[layer].getSourceWidth() == m_acLayerCfg[idx].getSourceWidth() && m_acLayerCfg[layer].getSourceHeight() == m_acLayerCfg[idx].getSourceHeight()
     105#if AUXILIARY_PICTURES
     106          && m_acLayerCfg[layer].getChromaFormatIDC() == m_acLayerCfg[idx].getChromaFormatIDC()
     107#endif
     108#if O0194_DIFFERENT_BITDEPTH_EL_BL
     109          && m_acLayerCfg[layer].m_internalBitDepthY == m_acLayerCfg[idx].m_internalBitDepthY && m_acLayerCfg[layer].m_internalBitDepthC == m_acLayerCfg[idx].m_internalBitDepthC
     110#endif
     111          )
    106112        {
    107113          found = true;
     
    117123    }
    118124
    119     assert( m_acLayerCfg[layer].getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" );   
     125    assert( m_acLayerCfg[layer].getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" );
    120126    vps->setVpsRepFormatIdx( layer, m_acLayerCfg[layer].getRepFormatIdx() );
    121127    maxRepFormatIdx = std::max( m_acLayerCfg[layer].getRepFormatIdx(), maxRepFormatIdx );
     
    141147  for(UInt idx=0; idx < vps->getVpsNumRepFormats(); idx++)
    142148  {
    143     RepFormat *repFormat = vps->getVpsRepFormat( idx );   
     149    RepFormat *repFormat = vps->getVpsRepFormat( idx );
    144150    repFormat->setPicWidthVpsInLumaSamples  ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceWidth()   );
    145151    repFormat->setPicHeightVpsInLumaSamples ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceHeight()  );
     152#if AUXILIARY_PICTURES
     153    repFormat->setChromaFormatVpsIdc        ( m_acLayerCfg[mapIdxToLayer[idx]].getChromaFormatIDC() );
     154#else
    146155    repFormat->setChromaFormatVpsIdc        ( 1                                             );  // Need modification to change for each layer - corresponds to 420
     156#endif
    147157    repFormat->setSeparateColourPlaneVpsFlag( 0                                             );  // Need modification to change for each layer
     158#if O0194_DIFFERENT_BITDEPTH_EL_BL
     159    repFormat->setBitDepthVpsLuma           ( getInternalBitDepthY(mapIdxToLayer[idx])      );  // Need modification to change for each layer
     160    repFormat->setBitDepthVpsChroma         ( getInternalBitDepthC(mapIdxToLayer[idx])      );  // Need modification to change for each layer
     161#else
    148162    repFormat->setBitDepthVpsLuma           ( getInternalBitDepthY()                        );  // Need modification to change for each layer
    149163    repFormat->setBitDepthVpsChroma         ( getInternalBitDepthC()                        );  // Need modification to change for each layer
     164#endif
    150165  }
    151166  delete [] mapIdxToLayer;
     
    153168  for(UInt layer=0; layer<m_numLayers; layer++)
    154169  {
     170#if O0194_DIFFERENT_BITDEPTH_EL_BL
     171    //1
     172    g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
     173    g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
     174
     175    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
     176    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
     177
     178    // Set this to be used in Upsampling filter in function "TComUpsampleFilter::upsampleBasePic"
     179    g_bitDepthYLayer[layer] = g_bitDepthY;
     180    g_bitDepthCLayer[layer] = g_bitDepthC;
     181#endif
    155182    //m_acTEncTop[layer].setVPS(&vps);
    156183    m_acTEncTop[layer].setFrameRate                    ( m_acLayerCfg[layer].getFrameRate() );
     
    187214#endif
    188215#endif
    189     // set layer ID 
    190     m_acTEncTop[layer].setLayerId ( layer ); 
     216    // set layer ID
     217    m_acTEncTop[layer].setLayerId ( layer );
    191218    m_acTEncTop[layer].setNumLayer ( m_numLayers );
    192219    m_acTEncTop[layer].setLayerEnc(m_apcTEncTop);
     
    196223    m_acTEncTop[layer].setDecodingRefreshType          ( m_iDecodingRefreshType );
    197224    m_acTEncTop[layer].setGOPSize                      ( m_iGOPSize );
    198 #if FINAL_RPL_CHANGE_N0082
    199     m_acTEncTop[layer].setGopList                      ( m_acLayerCfg[layer].m_GOPListLayer );
    200 #else
    201225    m_acTEncTop[layer].setGopList                      ( m_GOPList );
    202 #endif
     226
    203227    m_acTEncTop[layer].setExtraRPSs                    ( m_extraRPSs );
    204228    for(Int i = 0; i < MAX_TLAYER; i++)
     
    220244    if (layer<m_numLayers-1)
    221245    {
    222        m_acTEncTop[layer].setMaxTidIlRefPicsPlus1 ( m_acLayerCfg[layer].getMaxTidIlRefPicsPlus1()); 
    223     }
    224 #endif 
     246       m_acTEncTop[layer].setMaxTidIlRefPicsPlus1 ( m_acLayerCfg[layer].getMaxTidIlRefPicsPlus1());
     247    }
     248#endif
    225249#if VPS_EXTN_DIRECT_REF_LAYERS
    226250    if(layer)
     
    241265      else
    242266      {
    243         m_acTEncTop[layer].setNumSamplePredRefLayers   ( m_acLayerCfg[layer].getNumSamplePredRefLayers() );     
     267        m_acTEncTop[layer].setNumSamplePredRefLayers   ( m_acLayerCfg[layer].getNumSamplePredRefLayers() );
    244268        for(Int i = 0; i < m_acTEncTop[layer].getNumSamplePredRefLayers(); i++)
    245269        {
    246270          m_acTEncTop[layer].setSamplePredRefLayerId   ( i, m_acLayerCfg[layer].getSamplePredRefLayerId(i));
    247271          m_acTEncTop[layer].setSamplePredEnabledFlag  (m_acLayerCfg[layer].getSamplePredRefLayerId(i), true);
    248         }       
     272        }
    249273      }
    250274      if(m_acLayerCfg[layer].getNumMotionPredRefLayers() == -1)
     
    257281      else
    258282      {
    259         m_acTEncTop[layer].setNumMotionPredRefLayers   ( m_acLayerCfg[layer].getNumMotionPredRefLayers() );     
     283        m_acTEncTop[layer].setNumMotionPredRefLayers   ( m_acLayerCfg[layer].getNumMotionPredRefLayers() );
    260284        for(Int i = 0; i < m_acTEncTop[layer].getNumMotionPredRefLayers(); i++)
    261285        {
    262286          m_acTEncTop[layer].setMotionPredRefLayerId   ( i, m_acLayerCfg[layer].getMotionPredRefLayerId(i));
    263287          m_acTEncTop[layer].setMotionPredEnabledFlag  (m_acLayerCfg[layer].getMotionPredRefLayerId(i), true);
    264         }       
     288        }
    265289      }
    266290      Int numDirectRefLayers = 0;
     
    283307      else
    284308      {
    285         m_acTEncTop[layer].setNumDirectRefLayers       ( m_acLayerCfg[layer].getNumDirectRefLayers() );     
     309        m_acTEncTop[layer].setNumDirectRefLayers       ( m_acLayerCfg[layer].getNumDirectRefLayers() );
    286310        for(Int i = 0; i < m_acTEncTop[layer].getNumDirectRefLayers(); i++)
    287311        {
     
    304328      else
    305329      {
    306         m_acTEncTop[layer].setNumActiveRefLayers       ( m_acLayerCfg[layer].getNumActiveRefLayers() );     
     330        m_acTEncTop[layer].setNumActiveRefLayers       ( m_acLayerCfg[layer].getNumActiveRefLayers() );
    307331        for(Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++)
    308332        {
     
    358382    m_acTEncTop[layer].setUseRDOQTS                    ( m_useRDOQTS   );
    359383    m_acTEncTop[layer].setRDpenalty                    ( m_rdPenalty );
     384#if LAYER_CTB
     385    m_acTEncTop[layer].setQuadtreeTULog2MaxSize        ( m_acLayerCfg[layer].m_uiQuadtreeTULog2MaxSize );
     386    m_acTEncTop[layer].setQuadtreeTULog2MinSize        ( m_acLayerCfg[layer].m_uiQuadtreeTULog2MinSize );
     387    m_acTEncTop[layer].setQuadtreeTUMaxDepthInter      ( m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthInter );
     388    m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra      ( m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthIntra );
     389#else
    360390    m_acTEncTop[layer].setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
    361391    m_acTEncTop[layer].setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
    362392    m_acTEncTop[layer].setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
    363393    m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
     394#endif
    364395    m_acTEncTop[layer].setUseFastEnc                   ( m_bUseFastEnc  );
    365     m_acTEncTop[layer].setUseEarlyCU                   ( m_bUseEarlyCU  ); 
     396    m_acTEncTop[layer].setUseEarlyCU                   ( m_bUseEarlyCU  );
    366397    m_acTEncTop[layer].setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
    367398    m_acTEncTop[layer].setUseCbfFastMode               ( m_bUseCbfFastMode  );
     
    383414    m_acTEncTop[layer].setUseWP                   ( m_useWeightedPred      );
    384415    m_acTEncTop[layer].setWPBiPred                ( m_useWeightedBiPred   );
     416#if O0194_WEIGHTED_PREDICTION_CGS
     417    if (layer!=0)
     418    {
     419      // Enable weighted prediction for enhancement layer
     420      m_acTEncTop[layer].setUseWP                 ( true   );
     421      m_acTEncTop[layer].setWPBiPred              ( true   );
     422    }
     423#endif
    385424    //====== Parallel Merge Estimation ========
    386425    m_acTEncTop[layer].setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 );
     
    393432    m_acTEncTop[layer].setSliceSegmentMode        ( m_sliceSegmentMode         );
    394433    m_acTEncTop[layer].setSliceSegmentArgument    ( m_sliceSegmentArgument     );
     434#if LAYER_CTB
     435    Int iNumPartInCU = 1<<(m_acLayerCfg[layer].m_uiMaxCUDepth<<1);
     436#else
    395437    Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
     438#endif
    396439    if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU)
    397440    {
     
    417460    m_acTEncTop[layer].setSaoLcuBoundary (m_saoLcuBoundary);
    418461    m_acTEncTop[layer].setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
    419     m_acTEncTop[layer].setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag); 
    420     m_acTEncTop[layer].setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag); 
     462    m_acTEncTop[layer].setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
     463    m_acTEncTop[layer].setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
    421464
    422465    m_acTEncTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     
    483526    if(uiTilesCount == 1)
    484527    {
    485       m_bLFCrossTileBoundaryFlag = true; 
     528      m_bLFCrossTileBoundaryFlag = true;
    486529    }
    487530    m_acTEncTop[layer].setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
     
    519562    m_acTEncTop[layer].setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
    520563    m_acTEncTop[layer].setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
    521     m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); 
     564    m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
    522565    m_acTEncTop[layer].setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
    523566    m_acTEncTop[layer].setAspectRatioIdc( m_aspectRatioIdc );
     
    550593    m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
    551594    m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled);
    552 #if SCALED_REF_LAYER_OFFSETS
    553595    if( layer > 0 )
    554596    {
     
    557599      {
    558600        m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i],
    559                                                   2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]); 
    560       }
    561     }
    562 #endif
     601                                                  2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]);
     602      }
     603    }
    563604#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    564605    m_acTEncTop[layer].setAdaptiveResolutionChange( m_adaptiveResolutionChange );
    565606#endif
     607#if AUXILIARY_PICTURES
     608    m_acTEncTop[layer].setChromaFormatIDC( m_acLayerCfg[layer].m_chromaFormatIDC );
     609#endif
    566610  }
    567611}
    568 #else
     612#else //SVC_EXTENSION
    569613Void TAppEncTop::xInitLibCfg()
    570614{
     
    671715  m_cTEncTop.setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
    672716  m_cTEncTop.setUseFastEnc                   ( m_bUseFastEnc  );
    673   m_cTEncTop.setUseEarlyCU                   ( m_bUseEarlyCU  ); 
     717  m_cTEncTop.setUseEarlyCU                   ( m_bUseEarlyCU  );
    674718  m_cTEncTop.setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
    675719  m_cTEncTop.setUseCbfFastMode            ( m_bUseCbfFastMode  );
     
    725769  m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary);
    726770  m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
    727   m_cTEncTop.setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag); 
    728   m_cTEncTop.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag); 
     771  m_cTEncTop.setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
     772  m_cTEncTop.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
    729773
    730774  m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     
    783827  if(uiTilesCount == 1)
    784828  {
    785     m_bLFCrossTileBoundaryFlag = true; 
     829    m_bLFCrossTileBoundaryFlag = true;
    786830  }
    787831  m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
     
    809853  m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
    810854  m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
    811   m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); 
     855  m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
    812856  m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
    813857  m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc );
     
    840884  m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
    841885}
    842 #endif
     886#endif //SVC_EXTENSION
    843887
    844888Void TAppEncTop::xCreateLib()
     
    851895  for(UInt layer=0; layer<m_numLayers; layer++)
    852896  {
     897#if O0194_DIFFERENT_BITDEPTH_EL_BL
     898    //2
     899    g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
     900    g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
     901
     902    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
     903    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
     904#endif
     905#if LAYER_CTB
     906    g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
     907    g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer];
     908    g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
     909    g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
     910#endif
     911#if O0194_DIFFERENT_BITDEPTH_EL_BL
     912    m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(),  false, m_acLayerCfg[layer].m_inputBitDepthY, m_acLayerCfg[layer].m_inputBitDepthC, m_acLayerCfg[layer].m_internalBitDepthY, m_acLayerCfg[layer].m_internalBitDepthC );  // read  mode
     913#else
    853914    m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(),  false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
     915#endif
    854916    m_acTVideoIOYuvInputFile[layer].skipFrames(m_FrameSkip, m_acLayerCfg[layer].getSourceWidth() - m_acLayerCfg[layer].getPad()[0], m_acLayerCfg[layer].getSourceHeight() - m_acLayerCfg[layer].getPad()[1]);
    855917
    856918    if (!m_acLayerCfg[layer].getReconFile().empty())
    857919    {
     920#if O0194_DIFFERENT_BITDEPTH_EL_BL
     921      m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_acLayerCfg[layer].m_outputBitDepthY, m_acLayerCfg[layer].m_outputBitDepthC, m_acLayerCfg[layer].m_internalBitDepthY, m_acLayerCfg[layer].m_internalBitDepthC );  // write mode
     922#else
    858923      m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // write mode
     924#endif
    859925    }
    860926
    861927    m_acTEncTop[layer].create();
    862928  }
    863 #else
     929#else //SVC_EXTENSION
    864930  m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
    865931  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
     
    870936  // Neo Decoder
    871937  m_cTEncTop.create();
    872 #endif
     938#endif //SVC_EXTENSION
    873939}
    874940
     
    882948  for(UInt layer=0; layer<m_numLayers; layer++)
    883949  {
     950#if LAYER_CTB
     951    g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
     952    g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer];
     953    g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
     954    g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
     955#endif
     956
    884957    m_acTVideoIOYuvInputFile[layer].close();
    885958    m_acTVideoIOYuvReconFile[layer].close();
     
    887960    m_acTEncTop[layer].destroy();
    888961  }
    889 #else
     962#else //SVC_EXTENSION
    890963  m_cTVideoIOYuvInputFile.close();
    891964  m_cTVideoIOYuvReconFile.close();
     
    893966  // Neo Decoder
    894967  m_cTEncTop.destroy();
    895 #endif
     968#endif //SVC_EXTENSION
    896969}
    897970
     
    901974  for(UInt layer=0; layer<m_numLayers; layer++)
    902975  {
     976#if O0194_DIFFERENT_BITDEPTH_EL_BL
     977    //3
     978    g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
     979    g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
     980
     981    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
     982    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
     983#endif
     984#if LAYER_CTB
     985    g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
     986    g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer];
     987    g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
     988    g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
     989
     990    memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) );
     991    memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) );
     992    memcpy( g_auiRasterToPelX,  g_auiLayerRasterToPelX[layer],  sizeof( g_auiRasterToPelX ) );
     993    memcpy( g_auiRasterToPelY,  g_auiLayerRasterToPelY[layer],  sizeof( g_auiRasterToPelY ) );
     994#endif
    903995    m_acTEncTop[layer].init(isFieldCoding);
    904996  }
     
    9151007    for(Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++)
    9161008    {
     1009#if O0194_DIFFERENT_BITDEPTH_EL_BL
     1010      //4
     1011      g_bitDepthY = m_acLayerCfg[layerId].m_internalBitDepthY;
     1012      g_bitDepthC = m_acLayerCfg[layerId].m_internalBitDepthC;
     1013
     1014      g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthY : m_acLayerCfg[layerId].m_internalBitDepthY;
     1015      g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthC : m_acLayerCfg[layerId].m_internalBitDepthC;
     1016#endif
    9171017      vps->setLayerIdIncludedFlag(true, setId, layerId);
    9181018    }
     
    9301030    vps->setScalabilityMask(i, false);
    9311031  }
    932   if(m_numLayers > 1) 
     1032  if(m_numLayers > 1)
    9331033  {
    9341034    Int scalabilityTypes = 0;
     
    9381038      scalabilityTypes += m_scalabilityMask[i];
    9391039    }
     1040#if AUXILIARY_PICTURES
     1041    assert( scalabilityTypes <= 2 );
     1042#else
    9401043    assert( scalabilityTypes == 1 );
     1044#endif
    9411045    vps->setNumScalabilityTypes(scalabilityTypes);
    9421046  }
     
    9591063    vps->setDimensionId(i, 0, i);
    9601064  }
     1065#if AUXILIARY_PICTURES
     1066  if (m_scalabilityMask[3])
     1067  {
     1068    UInt maxAuxId = 0;
     1069    UInt auxDimIdLen = 0;
     1070    for(i = 1; i < vps->getMaxLayers(); i++)
     1071    {
     1072      if (m_acLayerCfg[i].getAuxId() > maxAuxId)
     1073      {
     1074        maxAuxId = m_acLayerCfg[i].getAuxId();
     1075      }
     1076    }
     1077    while((1 << auxDimIdLen) < (maxAuxId + 1))
     1078    {
     1079      auxDimIdLen++;
     1080    }
     1081    vps->setDimensionIdLen(1, auxDimIdLen);
     1082    for(i = 1; i < vps->getMaxLayers(); i++)
     1083    {
     1084      vps->setDimensionId(i, 1, m_acLayerCfg[i].getAuxId());
     1085    }
     1086  }
     1087#endif
    9611088#endif
    9621089#if N0120_MAX_TID_REF_PRESENT_FLAG
    9631090#if N0120_MAX_TID_REF_CFG
    9641091  vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag);
    965 #else 
     1092#else
    9661093  vps->setMaxTidRefPresentFlag(true);
     1094#endif
     1095  if (vps->getMaxTidRefPresentFlag())
     1096  {
     1097    for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
     1098    {
     1099#if N0120_MAX_TID_REF_CFG
     1100#if O0225_MAX_TID_FOR_REF_LAYERS
     1101      for( Int j = i+1; j <= MAX_VPS_LAYER_ID_PLUS1 - 1; j++)
     1102      {
     1103        vps->setMaxTidIlRefPicsPlus1(i, j, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
     1104      }
     1105#else
     1106      vps->setMaxTidIlRefPicsPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
    9671107#endif
    968   if (vps->getMaxTidRefPresentFlag())
     1108#else
     1109#if O0225_MAX_TID_FOR_REF_LAYERS
     1110      for( Int j = i+1; j <= MAX_VPS_LAYER_ID_PLUS1 - 1; j++)
     1111      {
     1112        vps->setMaxTidIlRefPicsPlus1(i, j, vps->getMaxTLayers()+1);
     1113      }
     1114#else
     1115      vps->setMaxTidIlRefPicsPlus1(i, vps->getMaxTLayers()+1);
     1116#endif
     1117#endif
     1118    }
     1119  }
     1120  else
    9691121  {
    9701122    for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
    9711123    {
    972 #if N0120_MAX_TID_REF_CFG
    973       vps->setMaxTidIlRefPicsPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
    974 #else
    975       vps->setMaxTidIlRefPicsPlus1(i, vps->getMaxTLayers()+1);
     1124#if O0225_MAX_TID_FOR_REF_LAYERS
     1125      for( Int j = i+1; j <= MAX_VPS_LAYER_ID_PLUS1 - 1; j++)
     1126      {
     1127        vps->setMaxTidIlRefPicsPlus1(i, j, 7);
     1128      }
     1129#else
     1130      vps->setMaxTidIlRefPicsPlus1(i, 7);
    9761131#endif
    9771132    }
    9781133  }
    979   else
    980   {
    981     for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
    982     {
    983       vps->setMaxTidIlRefPicsPlus1(i, 7);
    984     }
    985   }
    986 #endif
     1134#endif
    9871135#if ILP_SSH_SIG
     1136#if ILP_SSH_SIG_FIX
     1137    vps->setIlpSshSignalingEnabledFlag(false);
     1138#else
    9881139    vps->setIlpSshSignalingEnabledFlag(true);
     1140#endif
    9891141#endif
    9901142#if VPS_EXTN_PROFILE_INFO
     
    9981150#endif
    9991151  // Target output layer
    1000 #if VPS_PROFILE_OUTPUT_LAYERS
    1001   vps->setNumOutputLayerSets(vps->getNumLayerSets());   
    1002   vps->setNumProfileTierLevel(vps->getNumLayerSets());   
     1152  vps->setNumOutputLayerSets(vps->getNumLayerSets());
     1153  vps->setNumProfileTierLevel(vps->getNumLayerSets());
    10031154  vps->setDefaultOneTargetOutputLayerFlag(true);
    10041155  for(i = 1; i < vps->getNumLayerSets(); i++)
    10051156  {
    10061157    vps->setProfileLevelTierIdx(i, i);
    1007     vps->setOutputLayerSetIdx(i, i);
    1008   }
    1009 #else
    1010   vps->setNumOutputLayerSets(1);
    1011   Int lsIdx = 1;
    1012   vps->setOutputLayerSetIdx(0, lsIdx); // Because only one layer set
    1013 #endif
     1158    vps->setOutputLayerSetIdx(i, i);
     1159  }
     1160
    10141161  for(Int lsIdx = 1; lsIdx < vps->getNumLayerSets(); lsIdx++)
    10151162  {
    1016     // Include the highest layer as output layer 
     1163    // Include the highest layer as output layer
    10171164    for(UInt layer=0; layer <= vps->getMaxLayerId() ; layer++)
    10181165    {
     
    10731220#endif
    10741221#endif
    1075 #if JCTVC_M0458_INTERLAYER_RPS_SIG       
    1076     vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true);
    1077 #endif
    1078 #if N0147_IRAP_ALIGN_FLAG   
    1079     vps->setCrossLayerIrapAlignFlag(true);
     1222#if JCTVC_M0458_INTERLAYER_RPS_SIG
     1223    vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true);
     1224#endif
     1225#if O0062_POC_LSB_NOT_PRESENT_FLAG
     1226    for(i = 1; i< vps->getMaxLayers(); i++)
     1227    {
     1228      if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0  )
     1229      {
     1230        vps->setPocLsbNotPresentFlag(i, false);
     1231      }
     1232    }
     1233#endif
     1234#if N0147_IRAP_ALIGN_FLAG
     1235    vps->setCrossLayerIrapAlignFlag(true);
    10801236    for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
    10811237    {
     
    10831239      {
    10841240        if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr))
    1085         {         
     1241        {
    10861242          if(m_acTEncTop[layerCtr].getIntraPeriod() !=  m_acTEncTop[refLayerCtr].getIntraPeriod())
    10871243          {
     
    10971253      vps->setCrossLayerIrapAlignFlag(false);
    10981254    }
    1099 #endif 
     1255#endif
    11001256#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    11011257  vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false);
    11021258#endif
     1259#if !VPS_EXTN_OFFSET_CALC
    11031260#if VPS_EXTN_OFFSET
    11041261  // to be updated according to the current semantics
    11051262  vps->setExtensionOffset( 0xffff );
    11061263#endif
     1264#endif
     1265
     1266#if O0215_PHASE_ALIGNMENT
     1267  vps->setPhaseAlignFlag( m_phaseAlignFlag );
     1268#endif
     1269
    11071270#else //SVC_EXTENSION
    11081271  m_cTEncTop.init(isFieldCoding);
     
    11481311  for(UInt layer=0; layer<m_numLayers; layer++)
    11491312  {
     1313#if O0194_DIFFERENT_BITDEPTH_EL_BL
     1314    //5
     1315    g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
     1316    g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
     1317
     1318    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
     1319    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
     1320#endif
    11501321    // allocate original YUV buffer
    11511322    pcPicYuvOrg[layer] = new TComPicYuv;
     
    11531324    {
    11541325#if SVC_UPSAMPLING
     1326#if LAYER_CTB
     1327#if AUXILIARY_PICTURES
     1328      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL );
     1329#else
     1330      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL );
     1331#endif
     1332#else
     1333#if AUXILIARY_PICTURES
     1334      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1335#else
    11551336      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1337#endif
     1338#endif
    11561339#else
    11571340      pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     
    11611344    {
    11621345#if SVC_UPSAMPLING
     1346#if LAYER_CTB
     1347#if AUXILIARY_PICTURES
     1348      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL );
     1349#else
     1350      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL );
     1351#endif
     1352#else
     1353#if AUXILIARY_PICTURES
     1354      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1355#else
    11631356      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1357#endif
     1358#endif
    11641359#else
    11651360      pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     
    11901385  while ( !bEos )
    11911386  {
    1192     // Read enough frames 
     1387    // Read enough frames
    11931388    Bool bFramesReadyToCode = false;
    11941389    while(!bFramesReadyToCode)
     
    11961391      for(UInt layer=0; layer<m_numLayers; layer++)
    11971392      {
     1393#if O0194_DIFFERENT_BITDEPTH_EL_BL
     1394        //6
     1395        g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
     1396        g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
     1397
     1398        g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
     1399        g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
     1400#endif
     1401#if LAYER_CTB
     1402        g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
     1403        g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer];
     1404        g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
     1405        g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
     1406#endif
     1407
    11981408        // get buffers
    11991409        xGetBuffer(pcPicYuvRec, layer);
     
    12011411        // read input YUV file
    12021412        m_acTVideoIOYuvInputFile[layer].read( pcPicYuvOrg[layer], m_acLayerCfg[layer].getPad() );
     1413
     1414#if AUXILIARY_PICTURES
     1415        if (m_acLayerCfg[layer].getChromaFormatIDC() == CHROMA_400)
     1416        {
     1417          pcPicYuvOrg[layer]->convertToMonochrome();
     1418        }
     1419#endif
    12031420
    12041421        if(layer == m_numLayers-1)
     
    12571474#endif
    12581475
    1259     // loop through frames in one GOP 
     1476    // loop through frames in one GOP
    12601477    for ( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ )
    12611478    {
     
    12631480      for(UInt layer=0; layer<m_numLayers; layer++)
    12641481      {
     1482#if O0194_DIFFERENT_BITDEPTH_EL_BL
     1483        //7
     1484        g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
     1485        g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
     1486
     1487        g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
     1488        g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
     1489#endif
     1490#if LAYER_CTB
     1491        g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
     1492        g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer];
     1493        g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
     1494        g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
     1495
     1496        memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) );
     1497        memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) );
     1498        memcpy( g_auiRasterToPelX,  g_auiLayerRasterToPelX[layer],  sizeof( g_auiRasterToPelX ) );
     1499        memcpy( g_auiRasterToPelY,  g_auiLayerRasterToPelY[layer],  sizeof( g_auiRasterToPelY ) );
     1500#endif
    12651501        // call encoding function for one frame
    12661502        if ( m_isField )
     
    12881524    for(UInt layer=0; layer<m_numLayers; layer++)
    12891525    {
     1526#if O0194_DIFFERENT_BITDEPTH_EL_BL
     1527      //8
     1528      g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
     1529      g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
     1530
     1531      g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
     1532      g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
     1533#endif
    12901534      // write bistream to file if necessary
    12911535      iNumEncoded = m_acTEncTop[layer].getNumPicRcvd();
     
    15281772
    15291773#if SVC_UPSAMPLING
     1774#if LAYER_CTB
     1775#if AUXILIARY_PICTURES
     1776    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL );
     1777#else
     1778    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL );
     1779#endif
     1780#else
     1781#if AUXILIARY_PICTURES
     1782    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1783#else
    15301784    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1785#endif
     1786#endif
    15311787#else
    15321788    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     
    15511807      delete pcPicYuvRec; pcPicYuvRec = NULL;
    15521808    }
    1553   } 
     1809  }
    15541810}
    15551811
     
    16021858#endif
    16031859      {
    1604         m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), 
     1860        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
    16051861          m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
    16061862      }
     
    16221878    for ( i = 0; i < iNumEncoded/2; i++ )
    16231879#endif
    1624     {     
     1880    {
    16251881      const AccessUnit& auTop = *(iterBitstream++);
    16261882      const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
Note: See TracChangeset for help on using the changeset viewer.