Changeset 608 in 3DVCSoftware for trunk/source/App/TAppEncoder/TAppEncTop.cpp


Ignore:
Timestamp:
1 Sep 2013, 22:47:26 (12 years ago)
Author:
tech
Message:

Merged DEV-2.0-dev0@604.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r443 r608  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5757TAppEncTop::TAppEncTop()
    5858{
     59#if !H_MV
     60  m_iFrameRcvd = 0;
     61#endif
    5962  m_totalBytes = 0;
    6063  m_essentialBytes = 0;
     
    6770Void TAppEncTop::xInitLibCfg()
    6871{
    69 #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
    70 #if !QC_MVHEVC_B0046
    71   UInt layerId = 0;
    72 #endif
    73   // TODO: fix the assumption here that the temporal structures are all equal across all layers???
    74   m_cVPS.setMaxTLayers( m_maxTempLayer[0] );
    75 #if QC_MVHEVC_B0046
    76   m_cVPS.setMaxLayers( m_iNumberOfViews );
    77 #else
    78   m_cVPS.setMaxLayers( m_iNumberOfViews * (m_bUsingDepthMaps ? 2:1) );
    79 #endif
     72#if H_MV
     73  TComVPS& vps = m_vps;   
     74#else
     75  TComVPS vps;
     76#endif
     77 
     78#if H_MV
     79  Int maxTempLayer = -1;
     80  for (Int j = 0; j < m_numberOfLayers; j++)
     81  {
     82    maxTempLayer = max( m_maxTempLayerMvc[ j ], maxTempLayer );
     83  }
     84
     85  vps.setMaxTLayers                       ( maxTempLayer );
     86  if ( maxTempLayer )
     87  {
     88    vps.setTemporalNestingFlag(true);
     89  }
     90  vps.setMaxLayers( m_numberOfLayers );
    8091  for(Int i = 0; i < MAX_TLAYER; i++)
    8192  {
    82     m_cVPS.setNumReorderPics( m_numReorderPics[0][i], i );
    83     m_cVPS.setMaxDecPicBuffering( m_maxDecPicBuffering[0][i], i );
    84   }
    85 #endif
    86  
    87   for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    88   {
    89     m_frameRcvd.push_back(0);
    90     m_acTEncTopList.push_back(new TEncTop);
     93    Int maxNumReOrderPics  = 0;
     94    Int maxDecPicBuffering = 0;
     95    for (Int j = 0; j < m_numberOfLayers; j++)
     96    {
     97      maxNumReOrderPics  = max( maxNumReOrderPics,  m_numReorderPicsMvc    [ j ][ i ] );     
     98      maxDecPicBuffering = max( maxDecPicBuffering, m_maxDecPicBufferingMvc[ j ][ i ] );     
     99    }
     100
     101    vps.setNumReorderPics                 ( maxNumReOrderPics  ,i );
     102    vps.setMaxDecPicBuffering             ( maxDecPicBuffering ,i );
     103  }
     104#else
     105  vps.setMaxTLayers                       ( m_maxTempLayer );
     106  if (m_maxTempLayer == 1)
     107  {
     108    vps.setTemporalNestingFlag(true);
     109  }
     110  vps.setMaxLayers                        ( 1 );
     111  for(Int i = 0; i < MAX_TLAYER; i++)
     112  {
     113    vps.setNumReorderPics                 ( m_numReorderPics[i], i );
     114    vps.setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
     115  }
     116#endif
     117#if H_MV
     118  xSetLayerIds             ( vps );   
     119  xSetDimensionIdAndLength ( vps );
     120  xSetDependencies( vps );
     121  xSetProfileTierLevel     ( vps );
     122  xSetLayerSets            ( vps );
     123#if H_3D
     124  vps.initViewIndex();
     125  xSetVPSExtension2        ( vps );
     126  m_ivPicLists.setVPS      ( &vps );
     127#endif
     128
     129  for(Int layer = 0; layer < m_numberOfLayers; layer++)
     130  {
     131    m_frameRcvd                 .push_back(0);
     132    m_acTEncTopList             .push_back(new TEncTop);
    91133    m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
    92134    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
    93     m_picYuvRec.push_back(new TComList<TComPicYuv*>) ;
    94 
    95     m_acTEncTopList[iViewIdx]->setFrameRate                    ( m_iFrameRate );
    96     m_acTEncTopList[iViewIdx]->setFrameSkip                    ( m_FrameSkip );
    97     m_acTEncTopList[iViewIdx]->setSourceWidth                  ( m_iSourceWidth );
    98     m_acTEncTopList[iViewIdx]->setSourceHeight                 ( m_iSourceHeight );
    99     m_acTEncTopList[iViewIdx]->setCroppingMode                 ( m_croppingMode );
    100     m_acTEncTopList[iViewIdx]->setCropLeft                     ( m_cropLeft );
    101     m_acTEncTopList[iViewIdx]->setCropRight                    ( m_cropRight );
    102     m_acTEncTopList[iViewIdx]->setCropTop                      ( m_cropTop );
    103     m_acTEncTopList[iViewIdx]->setCropBottom                   ( m_cropBottom );
    104     m_acTEncTopList[iViewIdx]->setFrameToBeEncoded             ( m_iFrameToBeEncoded );
    105     m_acTEncTopList[iViewIdx]->setViewId                       ( iViewIdx );
    106     m_acTEncTopList[iViewIdx]->setIsDepth                      ( false );
    107 #if QC_MVHEVC_B0046
    108     m_acTEncTopList[iViewIdx]->setLayerId                      ( iViewIdx );
    109     m_cVPS.setViewId                                           ( m_aiVId[ iViewIdx ], iViewIdx );
    110 #else
    111     m_acTEncTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
    112 #if VIDYO_VPS_INTEGRATION
    113     layerId = iViewIdx * (m_bUsingDepthMaps ? 2:1);
    114     m_acTEncTopList[iViewIdx]->setLayerId                      ( layerId );
    115     m_cVPS.setDepthFlag                                        ( false, layerId );
    116     m_cVPS.setViewId                                           ( iViewIdx, layerId );
    117     m_cVPS.setViewOrderIdx                                     ( m_cCameraData.getViewOrderIndex()[ iViewIdx ], layerId );
    118     // TODO: set correct dependentFlag and dependentLayer
    119     m_cVPS.setDependentFlag                                    ( iViewIdx ? true:false, layerId );
    120     m_cVPS.setDependentLayer                                   ( layerId - (m_bUsingDepthMaps ? 2:1), layerId );
    121 #if INTER_VIEW_VECTOR_SCALING_C0115
    122     m_cVPS.setIVScalingFlag                                    ( m_bUseIVS );
    123 #endif
    124 #endif
     135    m_picYuvRec                 .push_back(new TComList<TComPicYuv*>) ;
     136
     137    m_ivPicLists.push_back( m_acTEncTopList[ layer ]->getListPic()  );
     138    TEncTop& m_cTEncTop = *m_acTEncTopList[ layer ];  // It is not a member, but this name helps avoiding code duplication !!!
    125139   
    126     m_acTEncTopList[iViewIdx]->setCamParPrecision              ( m_cCameraData.getCamParsCodedPrecision  () );
    127     m_acTEncTopList[iViewIdx]->setCamParInSliceHeader          ( m_cCameraData.getVaryingCameraParameters() );
    128     m_acTEncTopList[iViewIdx]->setCodedScale                   ( m_cCameraData.getCodedScale             () );
    129     m_acTEncTopList[iViewIdx]->setCodedOffset                  ( m_cCameraData.getCodedOffset            () );
    130 #endif   
    131 
     140    m_cTEncTop.setLayerIdInVps                 ( layer );
     141    m_cTEncTop.setLayerId                      ( vps.getLayerIdInNuh( layer ) );   
     142    m_cTEncTop.setViewId                       ( vps.getViewId      ( layer ) );
     143#if H_3D
     144    Bool isDepth = ( vps.getDepthId     ( layer ) != 0 ) ;
     145    m_cTEncTop.setViewIndex                    ( vps.getViewIndex   ( layer ) );
     146    m_cTEncTop.setIsDepth                      ( isDepth );
     147    //====== Camera Parameters =========
     148    m_cTEncTop.setCameraParameters             ( &m_cCameraData );     
     149    m_cTEncTop.setCamParPrecision              ( isDepth ? false : m_cCameraData.getCamParsCodedPrecision  () );
     150    m_cTEncTop.setCamParInSliceHeader          ( isDepth ? 0     : m_cCameraData.getVaryingCameraParameters() );
     151    m_cTEncTop.setCodedScale                   ( isDepth ? 0     : m_cCameraData.getCodedScale             () );
     152    m_cTEncTop.setCodedOffset                  ( isDepth ? 0     : m_cCameraData.getCodedOffset            () );
     153#if H_3D_VSO
     154    //====== VSO =========
     155    m_cTEncTop.setRenderModelParameters        ( &m_cRenModStrParser );
     156    m_cTEncTop.setForceLambdaScaleVSO          ( isDepth ? m_bForceLambdaScaleVSO : false );
     157    m_cTEncTop.setLambdaScaleVSO               ( isDepth ? m_dLambdaScaleVSO      : 1     );
     158    m_cTEncTop.setVSOMode                      ( isDepth ? m_uiVSOMode            : 0     );
     159
     160    m_cTEncTop.setAllowNegDist                 ( isDepth ? m_bAllowNegDist        : false );
     161
     162    // SAIT_VSO_EST_A0033
     163    m_cTEncTop.setUseEstimatedVSD              ( isDepth ? m_bUseEstimatedVSD     : false );
     164
     165    // LGE_WVSO_A0119
     166    m_cTEncTop.setUseWVSO                      ( isDepth ? m_bUseWVSO             : false );   
     167    m_cTEncTop.setVSOWeight                    ( isDepth ? m_iVSOWeight           : 0     );
     168    m_cTEncTop.setVSDWeight                    ( isDepth ? m_iVSDWeight           : 0     );
     169    m_cTEncTop.setDWeight                      ( isDepth ? m_iDWeight             : 0     );
     170#endif // H_3D_VSO
     171#if H_3D_ARP
     172    //====== Advanced Inter-view Residual Prediction =========
     173    m_cTEncTop.setUseAdvRP                     ( ( isDepth || 0==layer ) ? 0 : m_uiUseAdvResPred );
     174    m_cTEncTop.setARPStepNum                   ( ( isDepth || 0==layer ) ? 1 : H_3D_ARP_WFNR     );
     175#endif
     176#if H_3D_IC
     177    m_cTEncTop.setUseIC                        ( vps.getViewIndex( layer ) == 0 ? false : m_abUseIC[isDepth ? 1 : 0] );
     178#endif
     179  //========== Depth intra modes ==========
     180#if H_3D_DIM
     181    m_cTEncTop.setUseDMM                       ( isDepth ? m_useDMM               : false );
     182    m_cTEncTop.setUseRBC                       ( isDepth ? m_useRBC               : false );
     183    m_cTEncTop.setUseSDC                       ( isDepth ? m_useSDC               : false );
     184    m_cTEncTop.setUseDLT                       ( isDepth ? m_useDLT               : false );
     185#endif
     186#if H_3D_QTLPC
     187    m_cTEncTop.setUseQTL                       ( isDepth ? m_bUseQTL               : false );
     188    m_cTEncTop.setUsePC                        ( isDepth ? m_bUsePC                : false );
     189#endif
     190    //====== Depth Inter SDC =========
     191#if LGE_INTER_SDC_E0156
     192    m_cTEncTop.setInterSDCEnable               ( isDepth ? m_bDepthInterSDCFlag    : false );
     193#endif
     194#endif // H_3D
     195
     196    m_cTEncTop.setIvPicLists                   ( &m_ivPicLists );
     197#endif // H_MV
     198  m_cTEncTop.setVPS(&vps);
     199
     200  m_cTEncTop.setProfile(m_profile);
     201  m_cTEncTop.setLevel(m_levelTier, m_level);
     202  m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag);
     203  m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag);
     204  m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
     205  m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
     206 
     207  m_cTEncTop.setFrameRate                    ( m_iFrameRate );
     208  m_cTEncTop.setFrameSkip                    ( m_FrameSkip );
     209  m_cTEncTop.setSourceWidth                  ( m_iSourceWidth );
     210  m_cTEncTop.setSourceHeight                 ( m_iSourceHeight );
     211  m_cTEncTop.setConformanceWindow            ( m_confLeft, m_confRight, m_confTop, m_confBottom );
     212  m_cTEncTop.setFramesToBeEncoded            ( m_framesToBeEncoded );
     213 
    132214  //====== Coding Structure ========
    133     m_acTEncTopList[iViewIdx]->setIntraPeriod                  ( m_iIntraPeriod );
    134     m_acTEncTopList[iViewIdx]->setDecodingRefreshType          ( m_iDecodingRefreshType );
    135     m_acTEncTopList[iViewIdx]->setGOPSize                      ( m_iGOPSize );
    136     m_acTEncTopList[iViewIdx]->setGopList                      ( m_GOPListsMvc[iViewIdx] );
    137     m_acTEncTopList[iViewIdx]->setExtraRPSs                    ( m_extraRPSs[iViewIdx] );
    138     for(Int i = 0; i < MAX_TLAYER; i++)
    139     {
    140       m_acTEncTopList[iViewIdx]->setNumReorderPics             ( m_numReorderPics[iViewIdx][i], i );
    141       m_acTEncTopList[iViewIdx]->setMaxDecPicBuffering         ( m_maxDecPicBuffering[iViewIdx][i], i );
    142     }
    143     for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
    144     {
    145       m_acTEncTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
    146     }
    147     m_acTEncTopList[iViewIdx]->setQP                           ( m_aiQP[0] );
    148  
    149     m_acTEncTopList[iViewIdx]->setTemporalLayerQPOffset        ( m_aiTLayerQPOffset );
    150     m_acTEncTopList[iViewIdx]->setPad                          ( m_aiPad );
    151    
    152     m_acTEncTopList[iViewIdx]->setMaxTempLayer                 ( m_maxTempLayer[iViewIdx] );
    153 
    154     m_acTEncTopList[iViewIdx]->setDisInter4x4                  ( m_bDisInter4x4);
    155  
    156     m_acTEncTopList[iViewIdx]->setUseNSQT( m_enableNSQT );
    157     m_acTEncTopList[iViewIdx]->setUseAMP( m_enableAMP );
     215  m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod );
     216  m_cTEncTop.setDecodingRefreshType          ( m_iDecodingRefreshType );
     217  m_cTEncTop.setGOPSize                      ( m_iGOPSize );
     218#if H_MV
     219  m_cTEncTop.setGopList                      ( m_GOPListMvc[layer] );
     220  m_cTEncTop.setExtraRPSs                    ( m_extraRPSsMvc[layer] );
     221  for(Int i = 0; i < MAX_TLAYER; i++)
     222  {
     223    m_cTEncTop.setNumReorderPics             ( m_numReorderPicsMvc[layer][i], i );
     224    m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBufferingMvc[layer][i], i );
     225  }
     226#else
     227  m_cTEncTop.setGopList                      ( m_GOPList );
     228  m_cTEncTop.setExtraRPSs                    ( m_extraRPSs );
     229  for(Int i = 0; i < MAX_TLAYER; i++)
     230  {
     231    m_cTEncTop.setNumReorderPics             ( m_numReorderPics[i], i );
     232    m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBuffering[i], i );
     233  }
     234#endif
     235  for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
     236  {
     237    m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
     238  }
     239#if H_MV
     240  m_cTEncTop.setQP                           ( m_iQP[layer] );
     241#else
     242  m_cTEncTop.setQP                           ( m_iQP );
     243#endif
     244
     245  m_cTEncTop.setPad                          ( m_aiPad );
     246
     247#if H_MV
     248  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayerMvc[layer] );
     249#else
     250  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayer );
     251#endif
     252  m_cTEncTop.setUseAMP( m_enableAMP );
    158253 
    159254  //===== Slice ========
    160255 
    161256  //====== Loop/Deblock Filter ========
    162     m_acTEncTopList[iViewIdx]->setLoopFilterDisable            ( m_abLoopFilterDisable[0]       );
    163     m_acTEncTopList[iViewIdx]->setLoopFilterOffsetInAPS        ( m_loopFilterOffsetInAPS );
    164     m_acTEncTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
    165     m_acTEncTopList[iViewIdx]->setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
    166     m_acTEncTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
     257#if H_MV
     258  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable[layer]);
     259#else
     260  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable       );
     261#endif
     262  m_cTEncTop.setLoopFilterOffsetInPPS        ( m_loopFilterOffsetInPPS );
     263  m_cTEncTop.setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
     264  m_cTEncTop.setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
     265  m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
     266  m_cTEncTop.setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
    167267
    168268  //====== Motion search ========
    169     m_acTEncTopList[iViewIdx]->setFastSearch                   ( m_iFastSearch  );
    170     m_acTEncTopList[iViewIdx]->setSearchRange                  ( m_iSearchRange );
    171     m_acTEncTopList[iViewIdx]->setBipredSearchRange            ( m_bipredSearchRange );
    172 #if DV_V_RESTRICTION_B0037
    173     m_acTEncTopList[iViewIdx]->setUseDisparitySearchRangeRestriction ( m_bUseDisparitySearchRangeRestriction );
    174     m_acTEncTopList[iViewIdx]->setVerticalDisparitySearchRange( m_iVerticalDisparitySearchRange );
    175 #endif
     269  m_cTEncTop.setFastSearch                   ( m_iFastSearch  );
     270  m_cTEncTop.setSearchRange                  ( m_iSearchRange );
     271  m_cTEncTop.setBipredSearchRange            ( m_bipredSearchRange );
     272
    176273  //====== Quality control ========
    177     m_acTEncTopList[iViewIdx]->setMaxDeltaQP                   ( m_iMaxDeltaQP  );
    178     m_acTEncTopList[iViewIdx]->setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
    179 
    180     m_acTEncTopList[iViewIdx]->setChromaQpOffset               ( m_iChromaQpOffset     );
    181     m_acTEncTopList[iViewIdx]->setChromaQpOffset2nd            ( m_iChromaQpOffset2nd  );
     274  m_cTEncTop.setMaxDeltaQP                   ( m_iMaxDeltaQP  );
     275  m_cTEncTop.setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
     276
     277  m_cTEncTop.setChromaCbQpOffset               ( m_cbQpOffset     );
     278  m_cTEncTop.setChromaCrQpOffset            ( m_crQpOffset  );
    182279
    183280#if ADAPTIVE_QP_SELECTION
    184     m_acTEncTopList[iViewIdx]->setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
    185 #endif
    186 
    187 #if LOSSLESS_CODING
    188     Int lowestQP;
    189     lowestQP =  - ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) );
    190     if ((m_iMaxDeltaQP == 0 ) && (m_aiQP[0] == lowestQP) && (m_useLossless == true))
    191     {
    192       m_bUseAdaptiveQP = false;
    193     }
    194 #endif
    195 
    196     m_acTEncTopList[iViewIdx]->setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
    197     m_acTEncTopList[iViewIdx]->setQPAdaptationRange            ( m_iQPAdaptationRange );
    198  
    199 #if HHI_VSO
    200     //====== VSO =========
    201     m_acTEncTopList[iViewIdx]->setForceLambdaScaleVSO          ( false );
    202     m_acTEncTopList[iViewIdx]->setLambdaScaleVSO               ( 1     );
    203     m_acTEncTopList[iViewIdx]->setVSOMode                      ( 0     );
    204     m_acTEncTopList[iViewIdx]->setUseVSO                       ( false );
    205 #if SAIT_VSO_EST_A0033
    206     m_acTEncTopList[iViewIdx]->setUseEstimatedVSD              ( false );
    207 #endif
    208 #if LGE_WVSO_A0119
    209     m_acTEncTopList[iViewIdx]->setUseWVSO                      ( false );
    210 #endif
    211 #endif
    212 
    213 #if DEPTH_MAP_GENERATION
    214     m_acTEncTopList[iViewIdx]->setPredDepthMapGeneration       ( m_uiPredDepthMapGeneration );
    215     m_acTEncTopList[iViewIdx]->setPdmPrecision                 ( (UInt)m_cCameraData.getPdmPrecision     () );
    216     m_acTEncTopList[iViewIdx]->setPdmScaleNomDelta             (       m_cCameraData.getPdmScaleNomDelta () );
    217     m_acTEncTopList[iViewIdx]->setPdmOffset                    (       m_cCameraData.getPdmOffset        () );
    218 #endif
    219 #if H3D_IVMP
    220     m_acTEncTopList[iViewIdx]->setMultiviewMvPredMode          ( m_uiMultiviewMvPredMode );
    221     m_acTEncTopList[iViewIdx]->setMultiviewMvRegMode           ( iViewIdx ? m_uiMultiviewMvRegMode       : 0   );
    222     m_acTEncTopList[iViewIdx]->setMultiviewMvRegLambdaScale    ( iViewIdx ? m_dMultiviewMvRegLambdaScale : 0.0 );
    223 #endif
    224 #if H3D_IVRP
    225 #if QC_ARP_D0177
    226     m_acTEncTopList[iViewIdx]->setUseAdvRP                     ( iViewIdx ? m_nUseAdvResPred             : 0   );
    227     m_acTEncTopList[iViewIdx]->setARPStepNum                   ( iViewIdx ? QC_ARP_WFNR                  : 1   );
    228 #else
    229     m_acTEncTopList[iViewIdx]->setMultiviewResPredMode         ( m_uiMultiviewResPredMode );
    230 #endif
    231 #endif
    232 #if MTK_D0156
    233 #if MERL_VSP_COMPENSATION_C0152
    234     m_acTEncTopList[iViewIdx]->setUseVSPCompensation           ( iViewIdx ? m_bUseVSPCompensation : 0 );
    235 #endif
    236     m_acTEncTopList[iViewIdx]->setUseDVPRefine                  ( iViewIdx ? m_bUseDVPRefine : 0 );
    237 #endif
    238 
     281  m_cTEncTop.setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
     282#endif
     283
     284  Int lowestQP;
     285  lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
     286
     287#if H_MV
     288  if ((m_iMaxDeltaQP == 0 ) && (m_iQP[layer] == lowestQP) && (m_useLossless == true))
     289#else
     290  if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true))
     291#endif
     292  {
     293    m_bUseAdaptiveQP = false;
     294  }
     295  m_cTEncTop.setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
     296  m_cTEncTop.setQPAdaptationRange            ( m_iQPAdaptationRange );
     297 
    239298  //====== Tool list ========
    240     m_acTEncTopList[iViewIdx]->setUseSBACRD                    ( m_bUseSBACRD   );
    241     m_acTEncTopList[iViewIdx]->setDeltaQpRD                    ( m_uiDeltaQpRD  );
    242     m_acTEncTopList[iViewIdx]->setUseASR                       ( m_bUseASR      );
    243     m_acTEncTopList[iViewIdx]->setUseHADME                     ( m_bUseHADME    );
    244     m_acTEncTopList[iViewIdx]->setUseALF                       ( m_abUseALF[0]  );
    245     m_acTEncTopList[iViewIdx]->setALFEncodePassReduction       ( m_iALFEncodePassReduction );
    246 #if LOSSLESS_CODING
    247     m_acTEncTopList[iViewIdx]->setUseLossless                  ( m_useLossless );
    248 #endif
    249     m_acTEncTopList[iViewIdx]->setALFMaxNumberFilters          ( m_iALFMaxNumberFilters ) ;
    250 
    251     m_acTEncTopList[iViewIdx]->setUseLComb                     ( m_bUseLComb    );
    252     m_acTEncTopList[iViewIdx]->setLCMod                        ( m_bLCMod         );
    253     m_acTEncTopList[iViewIdx]->setdQPs                         ( m_aidQP        );
    254     m_acTEncTopList[iViewIdx]->setUseRDOQ                      ( m_abUseRDOQ[0] );
    255     m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
    256     m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
    257     m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
    258     m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
    259     m_acTEncTopList[iViewIdx]->setUseFastEnc                   ( m_bUseFastEnc  );
    260     m_acTEncTopList[iViewIdx]->setUseEarlyCU                   ( m_bUseEarlyCU  );
    261     m_acTEncTopList[iViewIdx]->setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
    262     m_acTEncTopList[iViewIdx]->setUseCbfFastMode               ( m_bUseCbfFastMode  );
    263 #if HHI_INTERVIEW_SKIP
    264     m_acTEncTopList[iViewIdx]->setInterViewSkip            ( iViewIdx>0 ? m_bInterViewSkip : false );
    265 #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    266     m_acTEncTopList[iViewIdx]->setInterViewSkipLambdaScale ( iViewIdx>0 ? (UInt)m_dInterViewSkipLambdaScale : 1 );
    267 #endif
    268 #endif
    269     m_acTEncTopList[iViewIdx]->setUseLMChroma                  ( m_bUseLMChroma );
    270     m_acTEncTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
    271     m_acTEncTopList[iViewIdx]->setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
    272     m_acTEncTopList[iViewIdx]->setUsePCM                       ( m_usePCM );
    273     m_acTEncTopList[iViewIdx]->setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
     299  m_cTEncTop.setUseSBACRD                    ( m_bUseSBACRD   );
     300  m_cTEncTop.setDeltaQpRD                    ( m_uiDeltaQpRD  );
     301  m_cTEncTop.setUseASR                       ( m_bUseASR      );
     302  m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
     303  m_cTEncTop.setUseLossless                  ( m_useLossless );
     304#if H_MV
     305  m_cTEncTop.setdQPs                         ( m_aidQP[layer]   );
     306#else
     307  m_cTEncTop.setdQPs                         ( m_aidQP        );
     308#endif
     309  m_cTEncTop.setUseRDOQ                      ( m_useRDOQ     );
     310  m_cTEncTop.setUseRDOQTS                    ( m_useRDOQTS   );
     311  m_cTEncTop.setRDpenalty                 ( m_rdPenalty );
     312  m_cTEncTop.setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
     313  m_cTEncTop.setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
     314  m_cTEncTop.setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
     315  m_cTEncTop.setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
     316  m_cTEncTop.setUseFastEnc                   ( m_bUseFastEnc  );
     317  m_cTEncTop.setUseEarlyCU                   ( m_bUseEarlyCU  );
     318  m_cTEncTop.setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
     319  m_cTEncTop.setUseCbfFastMode            ( m_bUseCbfFastMode  );
     320  m_cTEncTop.setUseEarlySkipDetection            ( m_useEarlySkipDetection );
     321
     322  m_cTEncTop.setUseTransformSkip             ( m_useTransformSkip      );
     323  m_cTEncTop.setUseTransformSkipFast         ( m_useTransformSkipFast  );
     324  m_cTEncTop.setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
     325  m_cTEncTop.setPCMLog2MinSize          ( m_uiPCMLog2MinSize);
     326  m_cTEncTop.setUsePCM                       ( m_usePCM );
     327  m_cTEncTop.setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
     328  m_cTEncTop.setMaxNumMergeCand              ( m_maxNumMergeCand );
     329 
    274330
    275331  //====== Weighted Prediction ========
    276     m_acTEncTopList[iViewIdx]->setUseWP                        ( m_bUseWeightPred      );
    277     m_acTEncTopList[iViewIdx]->setWPBiPredIdc                  ( m_uiBiPredIdc         );
     332  m_cTEncTop.setUseWP                   ( m_useWeightedPred      );
     333  m_cTEncTop.setWPBiPred                ( m_useWeightedBiPred   );
     334  //====== Parallel Merge Estimation ========
     335  m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 );
     336
    278337  //====== Slice ========
    279     m_acTEncTopList[iViewIdx]->setSliceMode                    ( m_iSliceMode                );
    280     m_acTEncTopList[iViewIdx]->setSliceArgument                ( m_iSliceArgument            );
    281 
    282   //====== Entropy Slice ========
    283     m_acTEncTopList[iViewIdx]->setEntropySliceMode             ( m_iEntropySliceMode         );
    284     m_acTEncTopList[iViewIdx]->setEntropySliceArgument         ( m_iEntropySliceArgument     );
    285     int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
    286     if(m_iEntropySliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE)
    287     {
    288       m_acTEncTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
    289     }
    290     if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)
    291     {
    292       m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
    293     }
    294     if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE)
    295     {
    296       m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument );
    297     }
    298     m_acTEncTopList[iViewIdx]->setSliceGranularity        ( m_iSliceGranularity         );
    299     if(m_iSliceMode == 0 )
    300     {
    301       m_bLFCrossSliceBoundaryFlag = true;
    302     }
    303     m_acTEncTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
    304     m_acTEncTopList[iViewIdx]->setUseSAO               ( m_abUseSAO[0]     );
    305 #if LGE_ILLUCOMP_B0045
    306 #if LGE_ILLUCOMP_DEPTH_C0046
    307     m_acTEncTopList[iViewIdx]->setUseIC                ( m_abUseIC[0]      );
    308 #else
    309     m_acTEncTopList[iViewIdx]->setUseIC                ( m_bUseIC          );
    310 #endif
    311 #endif
    312 #if INTER_VIEW_VECTOR_SCALING_C0115
    313     m_acTEncTopList[iViewIdx]->setUseIVS               ( m_bUseIVS          );
    314 #endif
    315     m_acTEncTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
    316 #if LGE_SAO_MIGRATION_D0091
    317     m_acTEncTopList[iViewIdx]->setSaoLcuBoundary (m_saoLcuBoundary);
    318     m_acTEncTopList[iViewIdx]->setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
    319 #else
    320     m_acTEncTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag);
    321 #endif
    322     m_acTEncTopList[iViewIdx]->setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
    323     m_acTEncTopList[iViewIdx]->setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
    324 
    325     m_acTEncTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
    326 
    327     m_acTEncTopList[iViewIdx]->setColumnRowInfoPresent       ( m_iColumnRowInfoPresent );
    328     m_acTEncTopList[iViewIdx]->setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    329     m_acTEncTopList[iViewIdx]->setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
    330     m_acTEncTopList[iViewIdx]->setNumRowsMinus1              ( m_iNumRowsMinus1 );
    331     if(m_iUniformSpacingIdr==0)
    332     {
    333       m_acTEncTopList[iViewIdx]->setColumnWidth              ( m_pchColumnWidth );
    334       m_acTEncTopList[iViewIdx]->setRowHeight                ( m_pchRowHeight );
    335     }
    336     m_acTEncTopList[iViewIdx]->xCheckGSParameters();
    337     m_acTEncTopList[iViewIdx]->setTileLocationInSliceHeaderFlag ( m_iTileLocationInSliceHeaderFlag );
    338     m_acTEncTopList[iViewIdx]->setTileMarkerFlag              ( m_iTileMarkerFlag );
    339     m_acTEncTopList[iViewIdx]->setMaxTileMarkerEntryPoints    ( m_iMaxTileMarkerEntryPoints );
    340  
    341     Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
    342     m_dMaxTileMarkerOffset    = ((Double)uiTilesCount) / m_iMaxTileMarkerEntryPoints;
    343     m_acTEncTopList[iViewIdx]->setMaxTileMarkerOffset         ( m_dMaxTileMarkerOffset );
    344     m_acTEncTopList[iViewIdx]->setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag );
    345     if(uiTilesCount == 1)
    346     {
    347       m_bLFCrossTileBoundaryFlag = true;
    348     }
    349     m_acTEncTopList[iViewIdx]->setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
    350     m_acTEncTopList[iViewIdx]->setWaveFrontSynchro           ( m_iWaveFrontSynchro );
    351     m_acTEncTopList[iViewIdx]->setWaveFrontFlush             ( m_iWaveFrontFlush );
    352     m_acTEncTopList[iViewIdx]->setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
    353 #if TMVP_DEPTH_SWITCH
    354     m_acTEncTopList[iViewIdx]->setEnableTMVP                 ( m_enableTMVP[0] );
    355 #else
    356     m_acTEncTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP );
    357 #endif
    358     m_acTEncTopList[iViewIdx]->setUseScalingListId           ( m_useScalingListId  );
    359     m_acTEncTopList[iViewIdx]->setScalingListFile            ( m_scalingListFile   );
    360     m_acTEncTopList[iViewIdx]->setSignHideFlag(m_signHideFlag);
    361     m_acTEncTopList[iViewIdx]->setTSIG(m_signHidingThreshold);
    362 
    363     if(uiTilesCount > 1)
    364     {
    365       m_bALFParamInSlice = false;
    366       m_bALFPicBasedEncode = true;
    367     }
    368     m_acTEncTopList[iViewIdx]->setALFParamInSlice              ( m_bALFParamInSlice);
    369     m_acTEncTopList[iViewIdx]->setALFPicBasedEncode            ( m_bALFPicBasedEncode);
    370 
    371     //====== Depth tools ========
    372 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    373     m_acTEncTopList[iViewIdx]->setUseDMM                     ( false );
    374 #endif
    375 #if H3D_QTL
    376     m_acTEncTopList[iViewIdx]->setUseQTLPC                   ( false );
    377 #endif
    378 #if HHI_MPI
    379     m_acTEncTopList[iViewIdx]->setUseMVI( false );
    380 #endif
    381 #if RWTH_SDC_DLT_B0036
    382     m_acTEncTopList[iViewIdx]->setUseDLT                      ( false );
    383     m_acTEncTopList[iViewIdx]->setUseSDC                      ( false );
    384 #endif
    385   }
    386   if( m_bUsingDepthMaps )
    387   {
    388     for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    389     {
    390 
    391 #if FLEX_CODING_ORDER_M23723
    392       // Detect whether depth comes before than texture for this view
    393       Bool isDepthFirst = false;
    394       if ( m_b3DVFlexOrder )
     338  m_cTEncTop.setSliceMode               ( m_sliceMode                );
     339  m_cTEncTop.setSliceArgument           ( m_sliceArgument            );
     340
     341  //====== Dependent Slice ========
     342  m_cTEncTop.setSliceSegmentMode        ( m_sliceSegmentMode         );
     343  m_cTEncTop.setSliceSegmentArgument    ( m_sliceSegmentArgument     );
     344  Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
     345  if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU)
     346  {
     347    m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU );
     348  }
     349  if(m_sliceMode==FIXED_NUMBER_OF_LCU)
     350  {
     351    m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU );
     352  }
     353  if(m_sliceMode==FIXED_NUMBER_OF_TILES)
     354  {
     355    m_cTEncTop.setSliceArgument ( m_sliceArgument );
     356  }
     357 
     358  if(m_sliceMode == 0 )
     359  {
     360    m_bLFCrossSliceBoundaryFlag = true;
     361  }
     362  m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
     363#if H_MV
     364  m_cTEncTop.setUseSAO ( m_bUseSAO[layer] );
     365#else
     366  m_cTEncTop.setUseSAO ( m_bUseSAO );
     367#endif
     368  m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
     369
     370  m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary);
     371  m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
     372  m_cTEncTop.setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
     373  m_cTEncTop.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
     374
     375  m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     376  m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled );
     377  m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
     378  m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
     379  m_cTEncTop.setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
     380  m_cTEncTop.setTMISEIToneMapId                           ( m_toneMapId );
     381  m_cTEncTop.setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
     382  m_cTEncTop.setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
     383  m_cTEncTop.setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
     384  m_cTEncTop.setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
     385  m_cTEncTop.setTMISEIModelID                             ( m_toneMapModelId );
     386  m_cTEncTop.setTMISEIMinValue                            ( m_toneMapMinValue );
     387  m_cTEncTop.setTMISEIMaxValue                            ( m_toneMapMaxValue );
     388  m_cTEncTop.setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
     389  m_cTEncTop.setTMISEISigmoidWidth                        ( m_sigmoidWidth );
     390  m_cTEncTop.setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
     391  m_cTEncTop.setTMISEINumPivots                           ( m_numPivots );
     392  m_cTEncTop.setTMISEICodedPivotValue                     ( m_codedPivotValue );
     393  m_cTEncTop.setTMISEITargetPivotValue                    ( m_targetPivotValue );
     394  m_cTEncTop.setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
     395  m_cTEncTop.setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
     396  m_cTEncTop.setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
     397  m_cTEncTop.setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
     398  m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
     399  m_cTEncTop.setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
     400  m_cTEncTop.setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
     401  m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
     402  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
     403  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
     404  m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
     405  m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType );
     406  m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId );
     407  m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx );
     408  m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation );
     409  m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle );
     410  m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled );
     411  m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
     412  m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
     413  m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
     414  m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
     415  m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
     416  m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     417  m_cTEncTop.setNumRowsMinus1              ( m_iNumRowsMinus1 );
     418  if(m_iUniformSpacingIdr==0)
     419  {
     420    m_cTEncTop.setColumnWidth              ( m_pColumnWidth );
     421    m_cTEncTop.setRowHeight                ( m_pRowHeight );
     422  }
     423  m_cTEncTop.xCheckGSParameters();
     424  Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
     425  if(uiTilesCount == 1)
     426  {
     427    m_bLFCrossTileBoundaryFlag = true;
     428  }
     429  m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
     430  m_cTEncTop.setWaveFrontSynchro           ( m_iWaveFrontSynchro );
     431  m_cTEncTop.setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
     432  m_cTEncTop.setTMVPModeId ( m_TMVPModeId );
     433  m_cTEncTop.setUseScalingListId           ( m_useScalingListId  );
     434  m_cTEncTop.setScalingListFile            ( m_scalingListFile   );
     435  m_cTEncTop.setSignHideFlag(m_signHideFlag);
     436#if RATE_CONTROL_LAMBDA_DOMAIN
     437  m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
     438  m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
     439  m_cTEncTop.setKeepHierBit         ( m_RCKeepHierarchicalBit );
     440  m_cTEncTop.setLCULevelRC          ( m_RCLCULevelRC );
     441  m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel );
     442  m_cTEncTop.setInitialQP           ( m_RCInitialQP );
     443  m_cTEncTop.setForceIntraQP        ( m_RCForceIntraQP );
     444#else
     445  m_cTEncTop.setUseRateCtrl     ( m_enableRateCtrl);
     446  m_cTEncTop.setTargetBitrate   ( m_targetBitrate);
     447  m_cTEncTop.setNumLCUInUnit    ( m_numLCUInUnit);
     448#endif
     449  m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
     450  m_cTEncTop.setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue);
     451  m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
     452  m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
     453  m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
     454  m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
     455  m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc );
     456  m_cTEncTop.setSarWidth( m_sarWidth );
     457  m_cTEncTop.setSarHeight( m_sarHeight );
     458  m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag );
     459  m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag );
     460  m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag );
     461  m_cTEncTop.setVideoFormat( m_videoFormat );
     462  m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag );
     463  m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag );
     464  m_cTEncTop.setColourPrimaries( m_colourPrimaries );
     465  m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics );
     466  m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients );
     467  m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag );
     468  m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField );
     469  m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField );
     470  m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag );
     471  m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
     472  m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag );
     473  m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag );
     474  m_cTEncTop.setNumTicksPocDiffOneMinus1   ( m_numTicksPocDiffOneMinus1    );
     475  m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag );
     476  m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag );
     477  m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag );
     478  m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc );
     479  m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom );
     480  m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom );
     481  m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
     482  m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
     483#if H_MV
     484  }
     485#endif
     486#if H_3D_VSO
     487  if ( m_bUseVSO )
     488  {
     489    if ( m_uiVSOMode == 4 )
     490    {
     491#if H_3D_VSO_EARLY_SKIP
     492      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip );
     493#else
     494      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 );
     495#endif
     496      for ( Int layer = 0; layer < m_numberOfLayers ; layer++ )
    395497      {
    396         for ( Int ii=1; ii<12; ii+=2 )
     498        TEncTop* pcEncTop =  m_acTEncTopList[ layer ];
     499        Int iViewNum      = pcEncTop->getViewIndex();
     500        Int iContent      = pcEncTop->getIsDepth() ? 1 : 0;
     501        Int iNumOfModels  = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent);
     502
     503        Bool bUseVSO      = (iNumOfModels != 0);
     504
     505        pcEncTop->setUseVSO( bUseVSO );
     506        pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL );
     507
     508        for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ )
    397509        {
    398           Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0');
    399           if ( iViewIdxCfg == iViewIdx )
    400           {
    401             if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view
    402             {
    403               isDepthFirst = true;
    404             }
    405             else
    406             {
    407               assert(m_pchMVCJointCodingOrder[ii-1]=='T');
    408             }
    409             break;
    410           }
    411         }
     510          Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode;
     511
     512          m_cRenModStrParser.getSingleModelData  ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ;
     513          m_cRendererModel  .createSingleModel   ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode );
     514        }           
    412515      }
    413 #endif
    414 
    415       m_depthFrameRcvd.push_back(0);
    416       m_acTEncDepthTopList.push_back(new TEncTop);
    417       m_acTVideoIOYuvDepthInputFileList.push_back(new TVideoIOYuv);
    418       m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv);
    419       m_picYuvDepthRec.push_back(new TComList<TComPicYuv*>) ;
    420 
    421       m_acTEncDepthTopList[iViewIdx]->setFrameRate                    ( m_iFrameRate );
    422       m_acTEncDepthTopList[iViewIdx]->setFrameSkip                    ( m_FrameSkip );
    423       m_acTEncDepthTopList[iViewIdx]->setSourceWidth                  ( m_iSourceWidth );
    424       m_acTEncDepthTopList[iViewIdx]->setSourceHeight                 ( m_iSourceHeight );
    425       m_acTEncDepthTopList[iViewIdx]->setCroppingMode                 ( m_croppingMode );
    426       m_acTEncDepthTopList[iViewIdx]->setCropLeft                     ( m_cropLeft );
    427       m_acTEncDepthTopList[iViewIdx]->setCropRight                    ( m_cropRight );
    428       m_acTEncDepthTopList[iViewIdx]->setCropTop                      ( m_cropTop );
    429       m_acTEncDepthTopList[iViewIdx]->setCropBottom                   ( m_cropBottom );
    430       m_acTEncDepthTopList[iViewIdx]->setFrameToBeEncoded             ( m_iFrameToBeEncoded );
    431       m_acTEncDepthTopList[iViewIdx]->setViewId                       ( iViewIdx );
    432       m_acTEncDepthTopList[iViewIdx]->setIsDepth                      ( true );
    433 #if QC_MVHEVC_B0046
    434       m_acTEncDepthTopList[iViewIdx]->setLayerId                      ( iViewIdx );
    435 #else
    436       m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
    437 #endif
    438 #if VIDYO_VPS_INTEGRATION
    439       layerId = iViewIdx * 2 + 1;
    440       m_acTEncDepthTopList[iViewIdx]->setLayerId                      ( layerId );
    441       m_cVPS.setDepthFlag                                             ( true, layerId );
    442       m_cVPS.setViewId                                                ( iViewIdx, layerId );
    443       m_cVPS.setViewOrderIdx                                          ( m_cCameraData.getViewOrderIndex()[ iViewIdx ], layerId );
    444       m_cVPS.setDependentFlag                                         ( true, layerId );
    445       m_cVPS.setDependentLayer                                        ( layerId-1, layerId);
    446 #endif
    447 #if FCO_FIX_SPS_CHANGE
    448       m_acTEncDepthTopList[iViewIdx]->setCamParPrecision              ( m_cCameraData.getCamParsCodedPrecision  () );
    449       m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader          ( m_cCameraData.getVaryingCameraParameters() );
    450       m_acTEncDepthTopList[iViewIdx]->setCodedScale                   ( m_cCameraData.getCodedScale             () );
    451       m_acTEncDepthTopList[iViewIdx]->setCodedOffset                  ( m_cCameraData.getCodedOffset            () );
    452 #else
    453       m_acTEncDepthTopList[iViewIdx]->setCamParPrecision              ( 0 );
    454       m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader          ( false );
    455       m_acTEncDepthTopList[iViewIdx]->setCodedScale                   ( 0 );
    456       m_acTEncDepthTopList[iViewIdx]->setCodedOffset                  ( 0 );
    457 #endif
    458 
    459       //====== Coding Structure ========
    460       m_acTEncDepthTopList[iViewIdx]->setIntraPeriod                  ( m_iIntraPeriod );
    461       m_acTEncDepthTopList[iViewIdx]->setDecodingRefreshType          ( m_iDecodingRefreshType );
    462       m_acTEncDepthTopList[iViewIdx]->setGOPSize                      ( m_iGOPSize );
    463       m_acTEncDepthTopList[iViewIdx]->setGopList                      ( m_GOPListsMvc[iViewIdx] );
    464       m_acTEncDepthTopList[iViewIdx]->setExtraRPSs                    ( m_extraRPSs[iViewIdx] );
    465       for(Int i = 0; i < MAX_TLAYER; i++)
    466       {
    467         m_acTEncDepthTopList[iViewIdx]->setNumReorderPics             ( m_numReorderPics[iViewIdx][i], i );
    468         m_acTEncDepthTopList[iViewIdx]->setMaxDecPicBuffering         ( m_maxDecPicBuffering[iViewIdx][i], i );
    469       }
    470       for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
    471       {
    472         m_acTEncDepthTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
    473       }
    474       m_acTEncDepthTopList[iViewIdx]->setQP                           ( m_aiQP[1] );
    475 
    476       m_acTEncDepthTopList[iViewIdx]->setTemporalLayerQPOffset        ( m_aiTLayerQPOffset );
    477       m_acTEncDepthTopList[iViewIdx]->setPad                          ( m_aiPad );
    478 
    479       m_acTEncDepthTopList[iViewIdx]->setMaxTempLayer                 ( m_maxTempLayer[iViewIdx] );
    480 
    481       m_acTEncDepthTopList[iViewIdx]->setDisInter4x4                  ( m_bDisInter4x4);
    482 
    483       m_acTEncDepthTopList[iViewIdx]->setUseNSQT( m_enableNSQT );
    484       m_acTEncDepthTopList[iViewIdx]->setUseAMP( m_enableAMP );
    485 
    486       //===== Slice ========
    487 
    488       //====== Loop/Deblock Filter ========
    489       m_acTEncDepthTopList[iViewIdx]->setLoopFilterDisable            ( m_abLoopFilterDisable[1]   );
    490       m_acTEncDepthTopList[iViewIdx]->setLoopFilterOffsetInAPS        ( m_loopFilterOffsetInAPS );
    491       m_acTEncDepthTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
    492       m_acTEncDepthTopList[iViewIdx]->setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
    493       m_acTEncDepthTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
    494 
    495       //====== Motion search ========
    496       m_acTEncDepthTopList[iViewIdx]->setFastSearch                   ( m_iFastSearch  );
    497       m_acTEncDepthTopList[iViewIdx]->setSearchRange                  ( m_iSearchRange );
    498       m_acTEncDepthTopList[iViewIdx]->setBipredSearchRange            ( m_bipredSearchRange );
    499 #if DV_V_RESTRICTION_B0037
    500       m_acTEncDepthTopList[iViewIdx]->setUseDisparitySearchRangeRestriction ( m_bUseDisparitySearchRangeRestriction );
    501       m_acTEncDepthTopList[iViewIdx]->setVerticalDisparitySearchRange( m_iVerticalDisparitySearchRange );
    502 #endif
    503       //====== Quality control ========
    504       m_acTEncDepthTopList[iViewIdx]->setMaxDeltaQP                   ( m_iMaxDeltaQP  );
    505       m_acTEncDepthTopList[iViewIdx]->setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
    506 
    507       m_acTEncDepthTopList[iViewIdx]->setChromaQpOffset               ( m_iChromaQpOffset     );
    508       m_acTEncDepthTopList[iViewIdx]->setChromaQpOffset2nd            ( m_iChromaQpOffset2nd  );
    509 
    510 #if ADAPTIVE_QP_SELECTION
    511       m_acTEncDepthTopList[iViewIdx]->setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
    512 #endif
    513 
    514       m_acTEncDepthTopList[iViewIdx]->setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
    515       m_acTEncDepthTopList[iViewIdx]->setQPAdaptationRange            ( m_iQPAdaptationRange );
    516 
    517       //====== Tool list ========
    518       m_acTEncDepthTopList[iViewIdx]->setUseSBACRD                    ( m_bUseSBACRD   );
    519       m_acTEncDepthTopList[iViewIdx]->setDeltaQpRD                    ( m_uiDeltaQpRD  );
    520       m_acTEncDepthTopList[iViewIdx]->setUseASR                       ( m_bUseASR      );
    521       m_acTEncDepthTopList[iViewIdx]->setUseHADME                     ( m_bUseHADME    );
    522       m_acTEncDepthTopList[iViewIdx]->setUseALF                       ( m_abUseALF[1]  );
    523       m_acTEncDepthTopList[iViewIdx]->setALFEncodePassReduction       ( m_iALFEncodePassReduction );
    524 #if LOSSLESS_CODING
    525       m_acTEncDepthTopList[iViewIdx]->setUseLossless                  ( m_useLossless );
    526 #endif
    527       m_acTEncDepthTopList[iViewIdx]->setALFMaxNumberFilters          ( m_iALFMaxNumberFilters ) ;
    528 
    529       m_acTEncDepthTopList[iViewIdx]->setUseLComb                     ( m_bUseLComb    );
    530       m_acTEncDepthTopList[iViewIdx]->setLCMod                        ( m_bLCMod       );
    531       m_acTEncDepthTopList[iViewIdx]->setdQPs                         ( m_aidQPdepth   );
    532       m_acTEncDepthTopList[iViewIdx]->setUseRDOQ                      ( m_abUseRDOQ[1] );
    533       m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
    534       m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
    535       m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
    536       m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
    537       m_acTEncDepthTopList[iViewIdx]->setUseFastEnc                   ( m_bUseFastEnc  );
    538       m_acTEncDepthTopList[iViewIdx]->setUseEarlyCU                   ( m_bUseEarlyCU  );
    539       m_acTEncDepthTopList[iViewIdx]->setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
    540       m_acTEncDepthTopList[iViewIdx]->setUseCbfFastMode               ( m_bUseCbfFastMode  );
    541 #if HHI_INTERVIEW_SKIP
    542       m_acTEncDepthTopList[iViewIdx]->setInterViewSkip            ( 0 );
    543 #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    544       m_acTEncDepthTopList[iViewIdx]->setInterViewSkipLambdaScale ( 1 );
    545 #endif
    546 #endif
    547       m_acTEncDepthTopList[iViewIdx]->setUseLMChroma                  ( m_bUseLMChroma );
    548       m_acTEncDepthTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
    549       m_acTEncDepthTopList[iViewIdx]->setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
    550       m_acTEncDepthTopList[iViewIdx]->setUsePCM                       ( m_usePCM );
    551       m_acTEncDepthTopList[iViewIdx]->setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
    552       //====== VSO ========
    553 #if HHI_VSO
    554       m_acTEncDepthTopList[iViewIdx]->setUseVSO                       ( m_bUseVSO      ); //GT: might be enabled/disabled later for VSO Mode 4
    555       m_acTEncDepthTopList[iViewIdx]->setForceLambdaScaleVSO          ( m_bForceLambdaScaleVSO );
    556       m_acTEncDepthTopList[iViewIdx]->setLambdaScaleVSO               ( m_dLambdaScaleVSO );
    557 #if HHI_VSO_DIST_INT
    558       m_acTEncDepthTopList[iViewIdx]->setAllowNegDist                 ( m_bAllowNegDist );
    559 #endif
    560       m_acTEncDepthTopList[iViewIdx]->setVSOMode                      ( m_uiVSOMode );
    561 
    562 #if SAIT_VSO_EST_A0033
    563       m_acTEncDepthTopList[iViewIdx]->setUseEstimatedVSD              ( m_bUseEstimatedVSD );
    564 #endif
    565 #if LGE_WVSO_A0119
    566       m_acTEncDepthTopList[iViewIdx]->setUseWVSO                      ( m_bUseWVSO         );
    567 #endif
    568 #endif
    569 
    570 #if DEPTH_MAP_GENERATION
    571       m_acTEncDepthTopList[iViewIdx]->setPredDepthMapGeneration       ( 0 );
    572 #endif
    573 #if H3D_IVMP
    574       m_acTEncDepthTopList[iViewIdx]->setMultiviewMvPredMode          ( 0 );
    575       m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegMode           ( 0 );
    576       m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegLambdaScale    ( 0.0 );
    577 #endif
    578 #if H3D_IVRP
    579 #if QC_ARP_D0177
    580     m_acTEncDepthTopList[iViewIdx]->setUseAdvRP                          ( 0 );
    581     m_acTEncDepthTopList[iViewIdx]->setARPStepNum                        ( 1 );
    582 #else
    583     m_acTEncDepthTopList[iViewIdx]->setMultiviewResPredMode         ( 0 );
    584 #endif
    585 #endif
    586 #if MTK_D0156
    587 
    588 #if MERL_VSP_COMPENSATION_C0152
    589       m_acTEncDepthTopList[iViewIdx]->setUseVSPCompensation           ( iViewIdx ? true : false );
    590 #endif
    591 
    592       m_acTEncDepthTopList[iViewIdx]->setUseDVPRefine                 ( iViewIdx ? true : false );
    593 #endif
    594 
    595       //====== Weighted Prediction ========
    596       m_acTEncDepthTopList[iViewIdx]->setUseWP                        ( m_bUseWeightPred      );
    597       m_acTEncDepthTopList[iViewIdx]->setWPBiPredIdc                  ( m_uiBiPredIdc         );
    598       //====== Slice ========
    599       m_acTEncDepthTopList[iViewIdx]->setSliceMode                    ( m_iSliceMode                );
    600       m_acTEncDepthTopList[iViewIdx]->setSliceArgument                ( m_iSliceArgument            );
    601 
    602       //====== Entropy Slice ========
    603       m_acTEncDepthTopList[iViewIdx]->setEntropySliceMode             ( m_iEntropySliceMode         );
    604       m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument         ( m_iEntropySliceArgument     );
    605       int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
    606       if(m_iEntropySliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE)
    607       {
    608         m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
    609       }
    610       if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)
    611       {
    612         m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
    613       }
    614       if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE)
    615       {
    616         m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument );
    617       }
    618       m_acTEncDepthTopList[iViewIdx]->setSliceGranularity        ( m_iSliceGranularity         );
    619       if(m_iSliceMode == 0 )
    620       {
    621         m_bLFCrossSliceBoundaryFlag = true;
    622       }
    623       m_acTEncDepthTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
    624       m_acTEncDepthTopList[iViewIdx]->setUseSAO               ( m_abUseSAO[1]     );
    625 #if LGE_ILLUCOMP_B0045
    626 #if LGE_ILLUCOMP_DEPTH_C0046
    627       m_acTEncDepthTopList[iViewIdx]->setUseIC                ( m_abUseIC[1] );
    628 #else
    629       m_acTEncDepthTopList[iViewIdx]->setUseIC                ( false     );
    630 #endif
    631 #endif
    632 #if INTER_VIEW_VECTOR_SCALING_C0115
    633      m_acTEncDepthTopList[iViewIdx]->setUseIVS                ( m_bUseIVS );
    634 #endif
    635       m_acTEncDepthTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
    636 #if LGE_SAO_MIGRATION_D0091
    637       m_acTEncDepthTopList[iViewIdx]->setSaoLcuBoundary (m_saoLcuBoundary);
    638       m_acTEncDepthTopList[iViewIdx]->setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
    639 #else
    640       m_acTEncDepthTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag);
    641 #endif
    642       m_acTEncDepthTopList[iViewIdx]->setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
    643       m_acTEncDepthTopList[iViewIdx]->setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
    644 
    645       m_acTEncDepthTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
    646 
    647       m_acTEncDepthTopList[iViewIdx]->setColumnRowInfoPresent       ( m_iColumnRowInfoPresent );
    648       m_acTEncDepthTopList[iViewIdx]->setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    649       m_acTEncDepthTopList[iViewIdx]->setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
    650       m_acTEncDepthTopList[iViewIdx]->setNumRowsMinus1              ( m_iNumRowsMinus1 );
    651       if(m_iUniformSpacingIdr==0)
    652       {
    653         m_acTEncDepthTopList[iViewIdx]->setColumnWidth              ( m_pchColumnWidth );
    654         m_acTEncDepthTopList[iViewIdx]->setRowHeight                ( m_pchRowHeight );
    655       }
    656       m_acTEncDepthTopList[iViewIdx]->xCheckGSParameters();
    657       m_acTEncDepthTopList[iViewIdx]->setTileLocationInSliceHeaderFlag ( m_iTileLocationInSliceHeaderFlag );
    658       m_acTEncDepthTopList[iViewIdx]->setTileMarkerFlag              ( m_iTileMarkerFlag );
    659       m_acTEncDepthTopList[iViewIdx]->setMaxTileMarkerEntryPoints    ( m_iMaxTileMarkerEntryPoints );
    660 
    661       Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
    662       m_dMaxTileMarkerOffset    = ((Double)uiTilesCount) / m_iMaxTileMarkerEntryPoints;
    663       m_acTEncDepthTopList[iViewIdx]->setMaxTileMarkerOffset         ( m_dMaxTileMarkerOffset );
    664       m_acTEncDepthTopList[iViewIdx]->setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag );
    665       if(uiTilesCount == 1)
    666       {
    667         m_bLFCrossTileBoundaryFlag = true;
    668       }
    669       m_acTEncDepthTopList[iViewIdx]->setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
    670       m_acTEncDepthTopList[iViewIdx]->setWaveFrontSynchro           ( m_iWaveFrontSynchro );
    671       m_acTEncDepthTopList[iViewIdx]->setWaveFrontFlush             ( m_iWaveFrontFlush );
    672       m_acTEncDepthTopList[iViewIdx]->setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
    673 #if TMVP_DEPTH_SWITCH
    674       m_acTEncDepthTopList[iViewIdx]->setEnableTMVP                 ( m_enableTMVP[1] );
    675 #else
    676       m_acTEncDepthTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP );
    677 #endif
    678       m_acTEncDepthTopList[iViewIdx]->setUseScalingListId           ( m_useScalingListId  );
    679       m_acTEncDepthTopList[iViewIdx]->setScalingListFile            ( m_scalingListFile   );
    680       m_acTEncDepthTopList[iViewIdx]->setSignHideFlag(m_signHideFlag);
    681       m_acTEncDepthTopList[iViewIdx]->setTSIG(m_signHidingThreshold);
    682 
    683       if(uiTilesCount > 1)
    684       {
    685         m_bALFParamInSlice = false;
    686         m_bALFPicBasedEncode = true;
    687       }
    688       m_acTEncDepthTopList[iViewIdx]->setALFParamInSlice              ( m_bALFParamInSlice);
    689       m_acTEncDepthTopList[iViewIdx]->setALFPicBasedEncode            ( m_bALFPicBasedEncode);
    690 
    691   //====== Depth tools ========
    692 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    693     m_acTEncDepthTopList[iViewIdx]->setUseDMM                     ( m_bUseDMM );
    694 #endif
    695 #if FLEX_CODING_ORDER_M23723 && HHI_DMM_PRED_TEX
    696     m_acTEncDepthTopList[iViewIdx]->setUseDMM34( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseDMM );
    697 #endif
    698 
    699 #if H3D_QTL
    700     m_acTEncDepthTopList[iViewIdx]->setUseQTLPC                   (m_bUseQTLPC);
    701 #endif
    702 #if HHI_MPI
    703 #if FLEX_CODING_ORDER_M23723
    704     m_acTEncDepthTopList[iViewIdx]->setUseMVI( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseMVI );
    705 #else
    706      m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
    707 #endif
    708 #endif
    709 #if RWTH_SDC_DLT_B0036
    710       m_acTEncDepthTopList[iViewIdx]->setUseDLT                   ( m_bUseDLT );
    711       m_acTEncDepthTopList[iViewIdx]->setUseSDC                   ( m_bUseSDC );
    712 #endif
    713     }
    714   }
    715 
    716 #if H3D_IVMP
    717   else if( m_uiMultiviewMvRegMode )
    718   {
    719     for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    720     {
    721       m_acTVideoIOYuvDepthInputFileList.push_back( new TVideoIOYuv );
    722     }
    723   }
    724 #endif
    725 
    726 #if HHI_VSO
    727   if ( m_bUseVSO )
    728   {
    729     if ( m_uiVSOMode == 4 )
    730     {
    731 #if LGE_VSO_EARLY_SKIP_A0093
    732       m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip );
    733 #else
    734       m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 );
    735 #endif
    736 
    737       for ( Int iViewNum = 0; iViewNum < m_iNumberOfViews; iViewNum++ )
    738       {
    739         for (Int iContent = 0; iContent < 2; iContent++ )
    740         {
    741           Int iNumOfModels   = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent);
    742           Bool bUseVSO = (iNumOfModels != 0);
    743 
    744           TEncTop* pcEncTop = ( iContent == 0 ) ? m_acTEncTopList[iViewNum] : m_acTEncDepthTopList[iViewNum];
    745           pcEncTop->setUseVSO( bUseVSO );
    746           pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL );
    747 
    748           for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ )
    749           {
    750             Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode;
    751 
    752             m_cRenModStrParser.getSingleModelData  ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ;
    753             m_cRendererModel  .createSingleModel   ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode );
    754           }
    755         }
    756       }
    757516    }
    758517    else
     
    760519      AOT(true);
    761520    }
    762 #if LGE_WVSO_A0119
    763     for ( Int iViewNum = 0; iViewNum < m_iNumberOfViews; iViewNum++ )
    764     {
    765       for (Int iContent = 0; iContent < 2; iContent++ )
    766       {
    767         TEncTop* pcEncTop = ( iContent == 0 ) ? m_acTEncTopList[iViewNum] : m_acTEncDepthTopList[iViewNum];
    768         pcEncTop->setUseWVSO  ( m_bUseWVSO );
    769         pcEncTop->setVSOWeight( m_iVSOWeight );
    770         pcEncTop->setVSDWeight( m_iVSDWeight );
    771         pcEncTop->setDWeight  ( m_iDWeight );
    772       }
    773     }
    774 #endif
    775   }
    776 #endif
    777 
    778 #if HHI_INTERVIEW_SKIP
    779   m_cUsedPelsRenderer.init(m_iSourceWidth, m_iSourceHeight, true, 0, LOG2_DISP_PREC_LUT, true, 0, 0, 0, 0, 0, 6, 4, 1, 0, 6 );
    780 #endif
    781 
     521  }
     522#endif
    782523}
    783524
    784525Void TAppEncTop::xCreateLib()
    785526{
    786   for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    787   {
    788     m_acTVideoIOYuvInputFileList[iViewIdx]->open( m_pchInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
    789     m_acTVideoIOYuvInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
    790 
    791     if (m_pchReconFileList[iViewIdx])
    792       m_acTVideoIOYuvReconFileList[iViewIdx]->open(m_pchReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
    793     m_acTEncTopList[iViewIdx]->create();
    794     if( m_bUsingDepthMaps )
    795     {
    796       m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
    797       m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
    798 
    799       if (m_pchDepthReconFileList[iViewIdx])
    800         m_acTVideoIOYuvDepthReconFileList[iViewIdx]->open(m_pchDepthReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
    801       m_acTEncDepthTopList[iViewIdx]->create();
    802     }
    803 #if H3D_IVMP
    804     else if( m_uiMultiviewMvRegMode )
    805     {
    806       m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
    807       m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight);
    808     }
    809 #endif
    810   }
     527#if H_MV
     528  // initialize global variables
     529  initROM();
     530#if H_3D_DIM_DMM
     531  initWedgeLists( true );
     532#endif
     533
     534  for( Int layer=0; layer < m_numberOfLayers; layer++)
     535  {
     536    m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer],     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
     537    m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
     538
     539    if (m_pchReconFileList[layer])
     540    {
     541      m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
     542    }
     543    m_acTEncTopList[layer]->create();
     544  }
     545#else
     546  // Video I/O
     547  m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
     548  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
     549
     550  if (m_pchReconFile)
     551    m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
     552 
     553  // Neo Decoder
     554  m_cTEncTop.create();
     555#endif
    811556}
    812557
    813558Void TAppEncTop::xDestroyLib()
    814559{
     560#if H_MV
     561  // destroy ROM
     562  destroyROM();
     563
     564  for(Int layer=0; layer<m_numberOfLayers; layer++)
     565  {
     566    m_acTVideoIOYuvInputFileList[layer]->close();
     567    m_acTVideoIOYuvReconFileList[layer]->close();
     568    delete m_acTVideoIOYuvInputFileList[layer] ;
     569    m_acTVideoIOYuvInputFileList[layer] = NULL;
     570    delete m_acTVideoIOYuvReconFileList[layer] ;
     571    m_acTVideoIOYuvReconFileList[layer] = NULL;
     572    m_acTEncTopList[layer]->deletePicBuffer();
     573    m_acTEncTopList[layer]->destroy();
     574    delete m_acTEncTopList[layer] ;
     575    m_acTEncTopList[layer] = NULL;
     576    delete m_picYuvRec[layer] ;
     577    m_picYuvRec[layer] = NULL;
     578  }
     579#else
    815580  // Video I/O
    816   for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    817   {
    818     m_acTVideoIOYuvInputFileList[iViewIdx]->close();
    819     m_acTVideoIOYuvReconFileList[iViewIdx]->close();
    820     delete m_acTVideoIOYuvInputFileList[iViewIdx] ;
    821     m_acTVideoIOYuvInputFileList[iViewIdx] = NULL;
    822     delete m_acTVideoIOYuvReconFileList[iViewIdx] ;
    823     m_acTVideoIOYuvReconFileList[iViewIdx] = NULL;
    824     m_acTEncTopList[iViewIdx]->deletePicBuffer();
    825     m_acTEncTopList[iViewIdx]->destroy();
    826     delete m_acTEncTopList[iViewIdx] ;
    827     m_acTEncTopList[iViewIdx] = NULL;
    828     delete m_picYuvRec[iViewIdx] ;
    829     m_picYuvRec[iViewIdx] = NULL;
    830 
    831     if( iViewIdx < Int( m_acTVideoIOYuvDepthInputFileList.size() ) && m_acTVideoIOYuvDepthInputFileList[iViewIdx] )
    832     {
    833       m_acTVideoIOYuvDepthInputFileList[iViewIdx]->close( );
    834       delete m_acTVideoIOYuvDepthInputFileList[iViewIdx];
    835       m_acTVideoIOYuvDepthInputFileList[iViewIdx] = NULL;
    836     }
    837     if( iViewIdx < Int( m_acTVideoIOYuvDepthReconFileList.size() ) && m_acTVideoIOYuvDepthReconFileList[iViewIdx] )
    838     {
    839       m_acTVideoIOYuvDepthReconFileList[iViewIdx]->close () ;
    840       delete m_acTVideoIOYuvDepthReconFileList[iViewIdx];
    841       m_acTVideoIOYuvDepthReconFileList[iViewIdx] = NULL;
    842     }
    843     if( iViewIdx < Int( m_acTEncDepthTopList.size() ) && m_acTEncDepthTopList[iViewIdx] )
    844     {
    845       m_acTEncDepthTopList[iViewIdx]->deletePicBuffer();
    846       m_acTEncDepthTopList[iViewIdx]->destroy();
    847       delete m_acTEncDepthTopList[iViewIdx];
    848       m_acTEncDepthTopList[iViewIdx] = NULL;
    849     }
    850     if( iViewIdx < Int( m_picYuvDepthRec.size() ) && m_picYuvDepthRec[iViewIdx] )
    851     {
    852       delete m_picYuvDepthRec[iViewIdx] ;
    853       m_picYuvDepthRec[iViewIdx] = NULL;
    854     }
    855   }
     581  m_cTVideoIOYuvInputFile.close();
     582  m_cTVideoIOYuvReconFile.close();
     583 
     584  // Neo Decoder
     585  m_cTEncTop.destroy();
     586#endif
    856587}
    857588
    858589Void TAppEncTop::xInitLib()
    859590{
    860   for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    861   {
    862     m_acTEncTopList[iViewIdx]->init( this );
    863 #if QC_MVHEVC_B0046
    864   //set setNumDirectRefLayer
    865   Int iNumDirectRef = m_acTEncTopList[iViewIdx]->getSPS()->getNumberOfUsableInterViewRefs();
    866   m_acTEncTopList[iViewIdx]->getEncTop()->getVPS()->setNumDirectRefLayer(iNumDirectRef, iViewIdx);
    867   for(Int iNumIvRef = 0; iNumIvRef < iNumDirectRef; iNumIvRef ++)
    868   {
    869     Int iLayerId = m_acTEncTopList[iViewIdx]->getSPS()->getUsableInterViewRef(iNumIvRef);
    870     m_acTEncTopList[iViewIdx]->getEncTop()->getVPS()->setDirectRefLayerId( iLayerId + iViewIdx, iViewIdx, iNumIvRef);
    871   }
    872 #endif
    873   }
    874   for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    875   {
    876     m_acTEncTopList[iViewIdx]->setTEncTopList( &m_acTEncTopList  );
    877   }
    878   if ( m_bUsingDepthMaps )
    879   {
    880     for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    881     {
    882       m_acTEncDepthTopList[iViewIdx]->init( this );
    883     }
    884     for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    885     {
    886       m_acTEncDepthTopList[iViewIdx]->setTEncTopList( &m_acTEncDepthTopList  );
    887     }
    888   }
     591#if H_MV
     592  for(Int layer=0; layer<m_numberOfLayers; layer++)
     593  {
     594    m_acTEncTopList[layer]->init( );
     595  }
     596#else
     597  m_cTEncTop.init();
     598#endif
    889599}
    890600
     
    911621
    912622  TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
    913   TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
    914 #if !QC_MVHEVC_B0046
    915   TComPicYuv*       pcPdmDepthOrg    = new TComPicYuv;
    916 #endif
    917623  TComPicYuv*       pcPicYuvRec = NULL;
    918   TComPicYuv*       pcDepthPicYuvRec = NULL;
    919 
     624 
    920625  // initialize internal class & member variables
    921626  xInitLibCfg();
     
    924629 
    925630  // main encoder loop
     631#if H_MV
    926632  Bool  allEos = false;
    927633  std::vector<Bool>  eos ;
    928   std::vector<Bool>  depthEos ;
     634  std::vector<Bool>  flush ; 
     635 
     636  Int gopSize    = 1;
    929637  Int maxGopSize = 0;
    930   Int gopSize = 1;
    931  
     638  maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize()); 
     639 
     640  for(Int layer=0; layer < m_numberOfLayers; layer++ )
     641  {
     642    eos  .push_back( false );
     643    flush.push_back( false );
     644  }
     645#else
     646  Int   iNumEncoded = 0;
     647  Bool  bEos = false;
     648#endif
     649 
    932650  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
    933   maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize());   
    934 
    935   for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
    936   {
    937     eos.push_back( false );
    938     depthEos.push_back( false );
    939    
    940 #if RWTH_SDC_DLT_B0036
    941     if( m_bUsingDepthMaps && m_bUseDLT )
    942       xAnalyzeInputBaseDepth(iViewIdx, m_iIntraPeriod);
    943 #endif
    944   }
    945651
    946652  // allocate original YUV buffer
    947653  pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    948   pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    949 
    950 #if H3D_IVMP
    951   if( m_uiMultiviewMvRegMode )
    952   {
    953     pcPdmDepthOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    954   }
    955 #endif
    956 
     654 
     655#if H_MV
    957656  while ( !allEos )
    958657  {
    959     for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
     658    for(Int layer=0; layer < m_numberOfLayers; layer++ )
    960659    {
    961660      Int frmCnt = 0;
    962       while ( !eos[iViewIdx] && !(frmCnt == gopSize))
     661      while ( !eos[layer] && !(frmCnt == gopSize))
    963662      {
    964663        // get buffers
    965         xGetBuffer(pcPicYuvRec, iViewIdx, false);
     664        xGetBuffer(pcPicYuvRec, layer);
    966665
    967666        // read input YUV file
    968         m_acTVideoIOYuvInputFileList[iViewIdx]->read( pcPicYuvOrg, m_aiPad );
    969      
    970 #if H3D_IVMP
    971         if( m_uiMultiviewMvRegMode && iViewIdx )
     667        m_acTVideoIOYuvInputFileList[layer]->read      ( pcPicYuvOrg, m_aiPad );
     668        m_acTEncTopList             [layer]->initNewPic( pcPicYuvOrg );
     669
     670        // increase number of received frames
     671        m_frameRcvd[layer]++;
     672       
     673        frmCnt++;
     674
     675        eos[layer] = (m_frameRcvd[layer] == m_framesToBeEncoded);
     676        allEos = allEos||eos[layer];
     677
     678        // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
     679        if (m_acTVideoIOYuvInputFileList[layer]->isEof())
    972680        {
    973           m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcPdmDepthOrg, m_aiPad, m_bUsingDepthMaps );
    974         }
    975 #endif
    976 
    977 #if H3D_IVMP
    978         m_acTEncTopList[iViewIdx]->initNewPic( pcPicYuvOrg, ( m_uiMultiviewMvRegMode && iViewIdx ? pcPdmDepthOrg : 0 ) );
    979 #else
    980         m_acTEncTopList[iViewIdx]->initNewPic( pcPicYuvOrg );
    981 #endif
    982 
    983         // increase number of received frames
    984         m_frameRcvd[iViewIdx]++;
    985         frmCnt++;
    986         // check end of file
    987         eos[iViewIdx] = ( m_acTVideoIOYuvInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
    988         eos[iViewIdx] = ( m_frameRcvd[iViewIdx] == m_iFrameToBeEncoded ?    true : eos[iViewIdx]   );
    989         allEos = allEos|eos[iViewIdx] ;
    990       }
    991       if( m_bUsingDepthMaps )
    992       {
    993         Int frmCntDepth = 0;
    994         while ( !depthEos[iViewIdx] && !(frmCntDepth == gopSize))
    995         {
    996           // get buffers
    997           xGetBuffer(pcDepthPicYuvRec, iViewIdx, true);
    998 
    999           // read input YUV file
    1000           m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad );
    1001 
    1002           m_acTEncDepthTopList[iViewIdx]->initNewPic( pcDepthPicYuvOrg );
    1003 
    1004           // increase number of received frames
    1005           m_depthFrameRcvd[iViewIdx]++;
    1006           frmCntDepth++;
    1007           // check end of file
    1008           depthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
    1009           depthEos[iViewIdx] = ( m_depthFrameRcvd[iViewIdx] == m_iFrameToBeEncoded ?    true : depthEos[iViewIdx]   );
    1010           allEos = allEos|depthEos[iViewIdx] ;
     681          flush          [layer] = true;
     682          eos            [layer] = true;
     683          m_frameRcvd    [layer]--;
     684          m_acTEncTopList[layer]->setFramesToBeEncoded(m_frameRcvd[layer]);
    1011685        }
    1012686      }
     
    1014688    for ( Int gopId=0; gopId < gopSize; gopId++ )
    1015689    {
    1016       Int  iNumEncoded = 0;
    1017 
    1018 #if !QC_MVHEVC_B0046
     690#if H_3D
    1019691      UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId );
    1020       if ( iNextPoc < m_iFrameToBeEncoded )
     692      if ( iNextPoc < m_framesToBeEncoded )
    1021693      {
    1022694        m_cCameraData.update( iNextPoc );
    1023695      }
    1024696#endif
    1025 
    1026 
    1027 #if FLEX_CODING_ORDER_M23723
    1028       if (m_b3DVFlexOrder)
     697      for(Int layer=0; layer < m_numberOfLayers; layer++ )
    1029698      {
    1030         Int  iNumDepthEncoded = 0;
    1031         iNumEncoded = 0;
    1032         Int i=0;
    1033         Int iViewIdx=0;
    1034         Int iNumberofDepthViews = m_bUsingDepthMaps?m_iNumberOfViews:0;
    1035         for (Int j=0; j < (m_iNumberOfViews+ iNumberofDepthViews); j++ )
    1036         {
    1037           if (m_pchMVCJointCodingOrder[i]=='T')
     699#if H_3D_VSO       
     700          if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded )
    1038701          {
    1039 
    1040             i++;
    1041             assert(isdigit(m_pchMVCJointCodingOrder[i]));
    1042             iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0');
    1043 #if (FCO_FIX && MERL_VSP_C0152)
    1044             Int iCurPoc = m_acTEncTopList[iViewIdx]->getFrameId(gopId);
    1045             if( iCurPoc < m_acTEncTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 )
    1046             {
    1047               TComPic* pcBaseTxtPic   = getPicFromView(  0, m_acTEncTopList[iViewIdx]->getFrameId(gopId), false ); //get base view reconstructed texture
    1048               TComPic* pcBaseDepthPic = getPicFromView(  0, m_acTEncTopList[iViewIdx]->getFrameId(gopId), true );  //get base view reconstructed depth
    1049               TEncSlice* pEncSlice = m_acTEncTopList[iViewIdx]->getSliceEncoder();
    1050               pEncSlice->setRefPicBaseTxt(pcBaseTxtPic);
    1051               pEncSlice->setRefPicBaseDepth(pcBaseDepthPic);
    1052             }
    1053             setBWVSPLUT( iViewIdx, gopId, false);           
    1054 #endif
    1055 
    1056             m_acTEncTopList[iViewIdx]->encode( eos[iViewIdx], pcPicYuvOrg, *m_picYuvRec[iViewIdx], outputAccessUnits, iNumEncoded, gopId );
    1057             xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, iViewIdx, false);
    1058             outputAccessUnits.clear();
    1059             i++;
     702            m_cCameraData.setDispCoeff( iNextPoc, m_acTEncTopList[layer]->getViewIndex() );
     703            m_acTEncTopList[layer]  ->setDispCoeff( m_cCameraData.getDispCoeff() );
    1060704          }
    1061           else if ( m_pchMVCJointCodingOrder[i] == 'D')
    1062           {
    1063 
    1064             i++;
    1065             if( m_bUsingDepthMaps )
    1066             {
    1067               assert(isdigit(m_pchMVCJointCodingOrder[i]));
    1068               iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0');
    1069 
    1070 #if SAIT_VSO_EST_A0033
    1071               if( m_bUseVSO && iNextPoc < m_iFrameToBeEncoded )
    1072               {
    1073                 m_cCameraData.xSetDispCoeff( iNextPoc, iViewIdx );
    1074                 m_acTEncDepthTopList[iViewIdx]->setDispCoeff( m_cCameraData.getDispCoeff() );
    1075               }
    1076 #endif
    1077 #if (FCO_FIX && MERL_VSP_C0152)
    1078               Int iCurPocDepth = m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId);
    1079               if( iCurPocDepth < m_acTEncDepthTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 )
    1080               {
    1081                 TComPic* pcBaseDepthPic = getPicFromView(  0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), true );
    1082                 TEncSlice* pcSlice = (TEncSlice*) m_acTEncDepthTopList[iViewIdx]->getSliceEncoder();
    1083                 pcSlice->setRefPicBaseDepth(pcBaseDepthPic);
    1084               }
    1085               setBWVSPLUT( iViewIdx, gopId, true);
    1086 #endif
    1087               m_acTEncDepthTopList[iViewIdx]->encode( depthEos[iViewIdx], pcDepthPicYuvOrg, *m_picYuvDepthRec[iViewIdx], outputAccessUnits, iNumDepthEncoded, gopId );
    1088               xWriteOutput(bitstreamFile, iNumDepthEncoded, outputAccessUnits, iViewIdx, true);
    1089               outputAccessUnits.clear();
    1090               i++;
    1091             }
    1092           }
    1093         }
     705#endif
     706        Int   iNumEncoded = 0;
     707
     708        // call encoding function for one frame         
     709        m_acTEncTopList[layer]->encode( eos[layer], flush[layer] ? 0 : pcPicYuvOrg, *m_picYuvRec[layer], outputAccessUnits, iNumEncoded, gopId );       
     710        xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, layer);
     711        outputAccessUnits.clear();
    1094712      }
    1095       else
    1096       {
    1097 
    1098 #endif
    1099       for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
    1100       {
    1101 #if SAIT_VSO_EST_A0033
    1102         if( m_bUseVSO && iNextPoc < m_iFrameToBeEncoded )
    1103         {
    1104           m_cCameraData.xSetDispCoeff( iNextPoc, iViewIdx );
    1105           m_acTEncDepthTopList[iViewIdx]->setDispCoeff( m_cCameraData.getDispCoeff() );
    1106         }
    1107 #endif
    1108         iNumEncoded = 0;
    1109 
    1110 #if MERL_VSP_C0152
    1111 #if MERL_VSP_C0152_BugFix_ForNoDepthCase
    1112         if(m_bUsingDepthMaps) // VSP can be used only when depth is available as input
    1113         {
    1114 #endif
    1115         Int iCurPoc = m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId);
    1116         if( iCurPoc < m_acTEncDepthTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 )
    1117         {
    1118           TComPic* pcBaseTxtPic   = getPicFromView(  0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), false ); //get base view reconstructed texture
    1119           TComPic* pcBaseDepthPic = getPicFromView(  0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), true );  //get base view reconstructed depth
    1120           TEncSlice* pEncSlice = m_acTEncTopList[iViewIdx]->getSliceEncoder();
    1121           pEncSlice->setRefPicBaseTxt(pcBaseTxtPic);
    1122           pEncSlice->setRefPicBaseDepth(pcBaseDepthPic);
    1123 #if MERL_VSP_NBDV_RefVId_Fix_D0166
    1124           for (Int refViewId=0; refViewId < iViewIdx; refViewId++ )
    1125           {
    1126             pEncSlice->setListDepthPic(m_acTEncDepthTopList[refViewId]->getListPic(), refViewId ); // The list will store only the depth pictures
    1127             setBWVSPLUT(refViewId, iViewIdx, gopId, false);
    1128           }
    1129 #endif
    1130         }
    1131 #if !MERL_VSP_NBDV_RefVId_Fix_D0166
    1132         setBWVSPLUT( iViewIdx, gopId, false);
    1133 #endif
    1134 #endif
    1135 
    1136 #if MERL_VSP_C0152_BugFix_ForNoDepthCase
    1137         }
    1138         else
    1139         {
    1140           Int iCurPoc = m_acTEncTopList[iViewIdx]->getFrameId(gopId);
    1141           if( iCurPoc < m_acTEncTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 )
    1142           {
    1143             TEncSlice* pEncSlice = m_acTEncTopList[iViewIdx]->getSliceEncoder();
    1144             pEncSlice->setRefPicBaseTxt(NULL);//Initialize the base view reconstructed texture buffer
    1145             pEncSlice->setRefPicBaseDepth(NULL);//Initialize the base view reconstructed depth buffer
    1146           }
    1147         }
    1148 #endif
    1149 
    1150         // call encoding function for one frame
    1151         m_acTEncTopList[iViewIdx]->encode( eos[iViewIdx], pcPicYuvOrg, *m_picYuvRec[iViewIdx], outputAccessUnits, iNumEncoded, gopId );
    1152         xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, iViewIdx, false);
    1153         outputAccessUnits.clear();
    1154         if( m_bUsingDepthMaps )
    1155         {
    1156           Int  iNumDepthEncoded = 0;
    1157 #if MERL_VSP_C0152
    1158         Int iCurPocDepth = m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId);
    1159         if( iCurPocDepth < m_acTEncDepthTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 )
    1160         {
    1161           TComPic* pcBaseDepthPic = getPicFromView(  0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), true );
    1162           TEncSlice* pcSlice = (TEncSlice*) m_acTEncDepthTopList[iViewIdx]->getSliceEncoder();
    1163           pcSlice->setRefPicBaseDepth(pcBaseDepthPic);
    1164 #if  MERL_VSP_NBDV_RefVId_Fix_D0166
    1165           for (Int refViewId=0; refViewId < iViewIdx; refViewId++ )
    1166           {
    1167             pcSlice->setListDepthPic(m_acTEncDepthTopList[refViewId]->getListPic(), refViewId ); // The list will store only the depth pictures
    1168             setBWVSPLUT( refViewId, iViewIdx, gopId, true);
    1169           }
    1170 #endif
    1171         }
    1172 #if !MERL_VSP_NBDV_RefVId_Fix_D0166
    1173         setBWVSPLUT( iViewIdx, gopId, true);
    1174 #endif
    1175 #endif
    1176 
    1177           // call encoding function for one depth frame
    1178           m_acTEncDepthTopList[iViewIdx]->encode( depthEos[iViewIdx], pcDepthPicYuvOrg, *m_picYuvDepthRec[iViewIdx], outputAccessUnits, iNumDepthEncoded, gopId );
    1179           xWriteOutput(bitstreamFile, iNumDepthEncoded, outputAccessUnits, iViewIdx, true);
    1180           outputAccessUnits.clear();
    1181         }
    1182       }
    1183  
    1184 #if FLEX_CODING_ORDER_M23723
    1185       }
    1186 #endif
    1187 
    1188 #if HHI_INTERVIEW_SKIP || H3D_IVMP || H3D_IVRP
    1189       for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
    1190       {
    1191         if( iViewIdx < (Int)m_acTEncTopList.size() && m_acTEncTopList[iViewIdx] )
    1192         {
    1193           m_acTEncTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
    1194         }
    1195         if( iViewIdx < (Int)m_acTEncDepthTopList.size() && m_acTEncDepthTopList[iViewIdx] )
    1196         {
    1197           m_acTEncDepthTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
    1198         }
    1199       }
    1200 #endif
    1201       for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
    1202       {
    1203         m_acTEncTopList[iViewIdx]->compressMotion( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
    1204         if( m_bUsingDepthMaps )
    1205         {
    1206           m_acTEncDepthTopList[iViewIdx]->compressMotion( m_acTEncDepthTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
    1207         }
    1208       }
    1209713    }
    1210714    gopSize = maxGopSize;
    1211715  }
     716  for(Int layer=0; layer < m_numberOfLayers; layer++ )
     717  {
     718    m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded() );
     719  }
     720#else
     721  while ( !bEos )
     722  {
     723    // get buffers
     724    xGetBuffer(pcPicYuvRec);
     725
     726    // read input YUV file
     727    m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad );
     728
     729    // increase number of received frames
     730    m_iFrameRcvd++;
     731
     732    bEos = (m_iFrameRcvd == m_framesToBeEncoded);
     733
     734    Bool flush = 0;
     735    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
     736    if (m_cTVideoIOYuvInputFile.isEof())
     737    {
     738      flush = true;
     739      bEos = true;
     740      m_iFrameRcvd--;
     741      m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd);
     742    }
     743
     744    // call encoding function for one frame
     745    m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
     746   
     747    // write bistream to file if necessary
     748    if ( iNumEncoded > 0 )
     749    {
     750      xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits);
     751      outputAccessUnits.clear();
     752    }
     753  }
     754
     755  m_cTEncTop.printSummary();
     756#endif
     757
    1212758  // delete original YUV buffer
    1213759  pcPicYuvOrg->destroy();
    1214760  delete pcPicYuvOrg;
    1215761  pcPicYuvOrg = NULL;
    1216   pcDepthPicYuvOrg->destroy();
    1217   delete pcDepthPicYuvOrg;
    1218   pcDepthPicYuvOrg = NULL;
    1219  
    1220 #if !QC_MVHEVC_B0046
    1221   if ( pcPdmDepthOrg != NULL && m_uiMultiviewMvRegMode )
    1222   {
    1223     pcPdmDepthOrg->destroy();
    1224     delete pcPdmDepthOrg;     
    1225     pcPdmDepthOrg = NULL;
    1226   };
    1227 #endif
    1228  
    1229   for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
    1230   {
    1231     m_acTEncTopList[iViewIdx]->printOutSummary(m_acTEncTopList[iViewIdx]->getNumAllPicCoded());
    1232     if ( m_bUsingDepthMaps )
    1233     {
    1234       m_acTEncDepthTopList[iViewIdx]->printOutSummary(m_acTEncDepthTopList[iViewIdx]->getNumAllPicCoded());
    1235     }
    1236   }
     762 
     763#if !H_MV
     764  // delete used buffers in encoder class
     765  m_cTEncTop.deletePicBuffer();
     766#endif
    1237767
    1238768  // delete buffers & classes
    1239769  xDeleteBuffer();
    1240770  xDestroyLib();
     771 
     772  printRateSummary();
     773
     774#if H_3D_REN_MAX_DEV_OUT
     775  Double dMaxDispDiff = m_cCameraData.getMaxShiftDeviation();
     776
     777  if ( !(dMaxDispDiff < 0) )
     778  { 
     779    printf("\n Max. possible shift error: %12.3f samples.\n", dMaxDispDiff );
     780  }
     781#endif
    1241782
    1242783  return;
    1243784}
    1244 
    1245 TEncTop*  TAppEncTop::getTEncTop( Int viewId, Bool isDepth )   
    1246 {
    1247   if ( isDepth ) 
    1248   {
    1249     return m_acTEncDepthTopList[viewId];
    1250   }
    1251   else
    1252   {
    1253     return m_acTEncTopList[viewId];
    1254   }
    1255 }
    1256 
    1257785
    1258786// ====================================================================================================================
     
    1266794 .
    1267795 */
    1268 Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, Int iViewIdx, Bool isDepth)
     796#if H_MV
     797Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
     798#else
     799Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec)
     800#endif
    1269801{
    1270802  assert( m_iGOPSize > 0 );
    1271803 
    1272   if( !isDepth )
    1273   {
    1274     if ( m_picYuvRec[iViewIdx]->size() == (UInt)m_iGOPSize )
    1275     {
    1276       rpcPicYuvRec = m_picYuvRec[iViewIdx]->popFront();
    1277     }
    1278     else
    1279     {
    1280       rpcPicYuvRec = new TComPicYuv;
    1281       rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    1282     }
    1283     m_picYuvRec[iViewIdx]->pushBack( rpcPicYuvRec );
     804  // org. buffer
     805#if H_MV
     806  if ( m_picYuvRec[layer]->size() == (UInt)m_iGOPSize )
     807  {
     808    rpcPicYuvRec = m_picYuvRec[layer]->popFront();
     809#else
     810  if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize )
     811  {
     812    rpcPicYuvRec = m_cListPicYuvRec.popFront();
     813#endif
     814
    1284815  }
    1285816  else
    1286817  {
    1287     if ( m_picYuvDepthRec[iViewIdx]->size() == (UInt)m_iGOPSize )
    1288     {
    1289       rpcPicYuvRec = m_picYuvDepthRec[iViewIdx]->popFront();
    1290     }
    1291     else
    1292     {
    1293       rpcPicYuvRec = new TComPicYuv;
    1294       rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    1295     }
    1296     m_picYuvDepthRec[iViewIdx]->pushBack( rpcPicYuvRec );
    1297   }
     818    rpcPicYuvRec = new TComPicYuv;
     819   
     820    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     821
     822  }
     823#if H_MV
     824  m_picYuvRec[layer]->pushBack( rpcPicYuvRec );
     825#else
     826  m_cListPicYuvRec.pushBack( rpcPicYuvRec );
     827#endif
    1298828}
    1299829
    1300830Void TAppEncTop::xDeleteBuffer( )
    1301831{
    1302   for(Int iViewIdx=0; iViewIdx<m_picYuvRec.size(); iViewIdx++)
    1303   {
    1304     if(m_picYuvRec[iViewIdx])
    1305     {
    1306       TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvRec[iViewIdx]->begin();
    1307       Int iSize = Int( m_picYuvRec[iViewIdx]->size() );
    1308       for ( Int i = 0; i < iSize; i++ )
    1309       {
    1310         TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
    1311         if(pcPicYuvRec)
    1312         {
    1313           pcPicYuvRec->destroy();
    1314           delete pcPicYuvRec;
    1315           pcPicYuvRec = NULL;
    1316         }
    1317       }
    1318     }
    1319   }
    1320   for(Int iViewIdx=0; iViewIdx<m_picYuvDepthRec.size(); iViewIdx++)
    1321   {
    1322     if(m_picYuvDepthRec[iViewIdx])
    1323     {
    1324       TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvDepthRec[iViewIdx]->begin();
    1325       Int iSize = Int( m_picYuvDepthRec[iViewIdx]->size() );
    1326       for ( Int i = 0; i < iSize; i++ )
    1327       {
    1328         TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
    1329         if(pcPicYuvRec)
    1330         {
    1331           pcPicYuvRec->destroy();
    1332           delete pcPicYuvRec;
    1333           pcPicYuvRec = NULL;
    1334         }
    1335       }
    1336     }
    1337   }
     832#if H_MV
     833  for(Int layer=0; layer<m_picYuvRec.size(); layer++)
     834  {
     835    if(m_picYuvRec[layer])
     836    {
     837      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvRec[layer]->begin();
     838      Int iSize = Int( m_picYuvRec[layer]->size() );
     839#else
     840  TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec.begin();
     841 
     842  Int iSize = Int( m_cListPicYuvRec.size() );
     843#endif
     844
     845  for ( Int i = 0; i < iSize; i++ )
     846  {
     847    TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     848    pcPicYuvRec->destroy();
     849    delete pcPicYuvRec; pcPicYuvRec = NULL;
     850  }
     851
     852#if H_MV
     853    }
     854  }
     855#endif 
    1338856}
    1339857
    1340858/** \param iNumEncoded  number of encoded frames
    1341859 */
    1342 Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, Int iViewIdx, Bool isDepth )
     860#if H_MV
     861Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId)
     862#else
     863Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
     864#endif
    1343865{
    1344866  Int i;
    1345867 
     868#if H_MV
    1346869  if( iNumEncoded > 0 )
    1347870  {
    1348     TComList<TComPicYuv*>::iterator iterPicYuvRec = !isDepth ? m_picYuvRec[iViewIdx]->end() : m_picYuvDepthRec[iViewIdx]->end();
    1349  
    1350     for ( i = 0; i < iNumEncoded; i++ )
    1351     {
    1352       --iterPicYuvRec;
    1353     }
    1354  
    1355     for ( i = 0; i < iNumEncoded; i++ )
    1356     {
    1357       TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
    1358       if( !isDepth )
     871    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end();
     872#else
     873  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     874  list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     875#endif
     876
     877  for ( i = 0; i < iNumEncoded; i++ )
     878  {
     879    --iterPicYuvRec;
     880  }
     881 
     882  for ( i = 0; i < iNumEncoded; i++ )
     883  {
     884    TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     885#if H_MV
     886      if (m_pchReconFileList[layerId])
    1359887      {
    1360         if (m_pchReconFileList[iViewIdx])
    1361         {
    1362           m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom );
    1363         }
    1364       }
    1365       else
    1366       {
    1367         if (m_pchDepthReconFileList[iViewIdx])
    1368         {
    1369           m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom );
    1370         }
     888        m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
    1371889      }
    1372890    }
     
    1381899    }
    1382900  }
    1383 }
    1384 
    1385 
    1386 TComPicYuv* TAppEncTop::xGetPicYuvFromView( Int iViewIdx, Int iPoc, Bool bDepth, Bool bRecon )
    1387 {
    1388   TComPic*    pcPic = xGetPicFromView( iViewIdx, iPoc, bDepth);
    1389   TComPicYuv* pcPicYuv = NULL;
    1390 
    1391   if (pcPic != NULL)
    1392   {
    1393     if( bRecon )
    1394     {
    1395       if ( pcPic->getReconMark() )
    1396       {
    1397         pcPicYuv = pcPic->getPicYuvRec();
    1398       }
    1399     }
    1400     else
    1401     {
    1402       pcPicYuv = pcPic->getPicYuvOrg();
    1403     }
    1404   };
    1405 
    1406   return pcPicYuv;
    1407 };
     901#else
     902    if (m_pchReconFile)
     903    {
     904      m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
     905    }
     906
     907    const AccessUnit& au = *(iterBitstream++);
     908    const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     909    rateStatsAccum(au, stats);
     910  }
     911#endif
     912}
    1408913
    1409914/**
    1410915 *
    1411916 */
    1412 void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<unsigned>& annexBsizes)
     917void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
    1413918{
    1414919  AccessUnit::const_iterator it_au = au.begin();
    1415   vector<unsigned>::const_iterator it_stats = annexBsizes.begin();
     920  vector<UInt>::const_iterator it_stats = annexBsizes.begin();
    1416921
    1417922  for (; it_au != au.end(); it_au++, it_stats++)
     
    1419924    switch ((*it_au)->m_nalUnitType)
    1420925    {
    1421     case NAL_UNIT_CODED_SLICE:
    1422 #if !QC_REM_IDV_B0046
    1423     case NAL_UNIT_CODED_SLICE_IDV:
    1424 #endif
    1425     case NAL_UNIT_CODED_SLICE_TLA:
     926    case NAL_UNIT_CODED_SLICE_TRAIL_R:
     927    case NAL_UNIT_CODED_SLICE_TRAIL_N:
     928    case NAL_UNIT_CODED_SLICE_TLA_R:
     929    case NAL_UNIT_CODED_SLICE_TSA_N:
     930    case NAL_UNIT_CODED_SLICE_STSA_R:
     931    case NAL_UNIT_CODED_SLICE_STSA_N:
     932    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
     933    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
     934    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
     935    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
     936    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
    1426937    case NAL_UNIT_CODED_SLICE_CRA:
    1427     case NAL_UNIT_CODED_SLICE_IDR:
     938    case NAL_UNIT_CODED_SLICE_RADL_N:
     939    case NAL_UNIT_CODED_SLICE_RADL_R:
     940    case NAL_UNIT_CODED_SLICE_RASL_N:
     941    case NAL_UNIT_CODED_SLICE_RASL_R:
     942    case NAL_UNIT_VPS:
    1428943    case NAL_UNIT_SPS:
    1429944    case NAL_UNIT_PPS:
    1430 #if VIDYO_VPS_INTEGRATION
    1431     case NAL_UNIT_VPS:
    1432 #endif
    1433945      m_essentialBytes += *it_stats;
    1434946      break;
     
    1441953}
    1442954
    1443 #if HHI_INTERVIEW_SKIP
    1444 Void TAppEncTop::getUsedPelsMap( Int iViewIdx, Int iPoc, TComPicYuv* pcPicYuvUsedSplsMap )
    1445 {
    1446   AOT( iViewIdx <= 0);
    1447   AOT( iViewIdx >= m_iNumberOfViews );
    1448   AOF( m_cCameraData.getCurFrameId() == iPoc );
    1449   Int iViewSIdx      = m_cCameraData.getBaseId2SortedId()[iViewIdx];
    1450   Int iFirstViewSIdx = m_cCameraData.getBaseId2SortedId()[0];
    1451 
    1452   AOT( iViewSIdx == iFirstViewSIdx );
    1453 
    1454   Bool bFirstIsLeft = (iFirstViewSIdx < iViewSIdx);
    1455 
    1456   m_cUsedPelsRenderer.setShiftLUTs(
    1457       m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx],
    1458       m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
    1459       m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
    1460       m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx],
    1461       m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
    1462       m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
    1463       -1
    1464       );
    1465 
    1466   TComPicYuv* pcPicYuvDepth = xGetPicYuvFromView(0, iPoc, true, true );
    1467   AOF( pcPicYuvDepth);
    1468 
    1469   m_cUsedPelsRenderer.getUsedSamplesMap( pcPicYuvDepth, pcPicYuvUsedSplsMap, bFirstIsLeft );
    1470 }
    1471 #endif
    1472 #if HHI_VSO
    1473 Void TAppEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset )
    1474 {
    1475   m_cRendererModel.setupPart( iHorOffset, Min( g_uiMaxCUHeight, m_iSourceHeight - iHorOffset ) );
    1476   Int iEncViewSIdx = m_cCameraData.getBaseId2SortedId()[ iEncViewIdx ];
    1477 
    1478   // setup base views
    1479   Int iNumOfBV = m_cRenModStrParser.getNumOfBaseViewsForView( iEncViewSIdx, iEncContent );
    1480 
    1481   for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ )
    1482   {
    1483     Int iBaseViewSIdx;
    1484     Int iVideoDistMode;
    1485     Int iDepthDistMode;
    1486 
    1487     m_cRenModStrParser.getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode );
    1488 
    1489     AOT( iVideoDistMode < 0 || iVideoDistMode > 2 );
    1490 
    1491     Int iBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iBaseViewSIdx ];
    1492 
    1493     TComPicYuv* pcPicYuvVideoRec  = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, true  );
    1494     TComPicYuv* pcPicYuvDepthRec  = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , true  );
    1495     TComPicYuv* pcPicYuvVideoOrg  = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, false );
    1496     TComPicYuv* pcPicYuvDepthOrg  = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , false );
    1497 
    1498     TComPicYuv* pcPicYuvVideoRef  = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg  : NULL;
    1499     TComPicYuv* pcPicYuvDepthRef  = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg  : NULL;
    1500 
    1501     TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg  : pcPicYuvVideoRec;
    1502     TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg  : pcPicYuvDepthRec;
    1503 
    1504     AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) );
    1505     AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) );
    1506     AOT( pcPicYuvDepthTest == NULL );
    1507     AOT( pcPicYuvVideoTest == NULL );
    1508 
    1509     m_cRendererModel.setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef );
    1510   }
    1511 
    1512   m_cRendererModel.setErrorMode( iEncViewSIdx, iEncContent, 0 );
    1513   // setup virtual views
    1514   Int iNumOfSV  = m_cRenModStrParser.getNumOfModelsForView( iEncViewSIdx, iEncContent );
    1515   for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ )
    1516   {
    1517     Int iOrgRefBaseViewSIdx;
    1518     Int iLeftBaseViewSIdx;
    1519     Int iRightBaseViewSIdx;
    1520     Int iSynthViewRelNum;
    1521     Int iModelNum;
    1522     Int iBlendMode;
    1523     m_cRenModStrParser.getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum );
    1524 
    1525     Int iLeftBaseViewIdx    = -1;
    1526     Int iRightBaseViewIdx   = -1;
    1527 
    1528     TComPicYuv* pcPicYuvOrgRef  = NULL;
    1529     Int**      ppiShiftLUTLeft  = NULL;
    1530     Int**      ppiShiftLUTRight = NULL;
    1531     Int**      ppiBaseShiftLUTLeft  = NULL;
    1532     Int**      ppiBaseShiftLUTRight = NULL;
    1533 
    1534 
    1535     Int        iDistToLeft      = -1;
    1536 
    1537     Int iSynthViewIdx = m_cCameraData.synthRelNum2Idx( iSynthViewRelNum );
    1538 
    1539     if ( iLeftBaseViewSIdx != -1 )
    1540     {
    1541       iLeftBaseViewIdx   = m_cCameraData.getBaseSortedId2Id()   [ iLeftBaseViewSIdx ];
    1542       ppiShiftLUTLeft    = m_cCameraData.getSynthViewShiftLUTI()[ iLeftBaseViewIdx  ][ iSynthViewIdx  ];
    1543     }
    1544 
    1545     if ( iRightBaseViewSIdx != -1 )
    1546     {
    1547       iRightBaseViewIdx  = m_cCameraData.getBaseSortedId2Id()   [iRightBaseViewSIdx ];
    1548       ppiShiftLUTRight   = m_cCameraData.getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ];
    1549     }
    1550 
    1551     if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 )
    1552     {
    1553       iDistToLeft    = m_cCameraData.getRelDistLeft(  iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx);
    1554       ppiBaseShiftLUTLeft  = m_cCameraData.getBaseViewShiftLUTI() [ iLeftBaseViewIdx  ][ iRightBaseViewIdx ];
    1555       ppiBaseShiftLUTRight = m_cCameraData.getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx  ];
    1556 
    1557     }
    1558 
    1559     if ( iOrgRefBaseViewSIdx != -1 )
    1560     {
    1561       pcPicYuvOrgRef = xGetPicYuvFromView( m_cCameraData.getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , iPoc, false, false );
    1562       AOF ( pcPicYuvOrgRef );
    1563     }
    1564 
    1565     m_cRendererModel.setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef );
    1566   }
    1567 }
    1568 #endif
    1569 
    1570 
    1571 
    1572 /*
    1573955void TAppEncTop::printRateSummary()
    1574956{
    1575   double time = (double) m_iFrameRcvd / m_iFrameRate;
     957#if H_MV
     958  Double time = (Double) m_frameRcvd[0] / m_iFrameRate;
     959  printf("\n");
     960#else
     961  Double time = (Double) m_iFrameRcvd / m_iFrameRate;
     962#endif
    1576963  printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
    1577964#if VERBOSE_RATE
     
    1579966#endif
    1580967}
    1581 */
    1582 
    1583 std::vector<TComPic*> TAppEncTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps )
    1584 {
    1585   std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL );
    1586   for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ )
    1587   {
    1588     TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth );
    1589     assert( pcRefPic != NULL );
    1590     apcRefPics[k] = pcRefPic;
    1591   }
    1592   return apcRefPics;
    1593 }
    1594 
    1595 TComPic* TAppEncTop::xGetPicFromView( Int viewIdx, Int poc, Bool isDepth )
    1596 {
    1597   assert( ( viewIdx >= 0 ) && ( viewIdx < m_iNumberOfViews ) );
    1598 
    1599   TComList<TComPic*>* apcListPic = (isDepth ?  m_acTEncDepthTopList[viewIdx] : m_acTEncTopList[viewIdx])->getListPic() ;
    1600 
    1601   TComPic* pcPic = NULL;
    1602   for(TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++)
    1603   {
    1604     if( (*it)->getPOC() == poc )
    1605     {
    1606       pcPic = *it ;
    1607       break ;
    1608     }
    1609   }
    1610 
    1611   return pcPic;
    1612 };
    1613  
    1614 #if RWTH_SDC_DLT_B0036
    1615 Void TAppEncTop::xAnalyzeInputBaseDepth(Int iViewIdx, UInt uiNumFrames)
     968
     969#if H_3D_DIM_DLT
     970Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps)
    1616971{
    1617972  TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
     
    1621976  TVideoIOYuv* depthVideoFile = new TVideoIOYuv;
    1622977 
    1623   UInt uiMaxDepthValue = g_uiIBDI_MAX;
     978  UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1);
    1624979 
    1625980  Bool abValidDepths[256];
    1626981 
    1627   depthVideoFile->open( m_pchDepthInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
     982  depthVideoFile->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
    1628983 
    1629984  // initialize boolean array
     
    1639994  for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ )
    1640995  {
    1641     depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad, false );
     996    depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad );
    1642997   
    1643998    // check all pixel values
     
    16551010 
    16561011  depthVideoFile->close();
     1012  delete depthVideoFile;
    16571013 
    16581014  pcDepthPicYuvOrg->destroy();
     
    16601016 
    16611017  // convert boolean array to idx2Depth LUT
    1662   UInt* auiIdx2DepthValue = (UInt*) calloc(uiMaxDepthValue, sizeof(UInt));
    1663   UInt uiNumDepthValues = 0;
    1664   for(UInt p=0; p<=uiMaxDepthValue; p++)
     1018  Int* aiIdx2DepthValue = (Int*) calloc(uiMaxDepthValue, sizeof(Int));
     1019  Int iNumDepthValues = 0;
     1020  for(Int p=0; p<=uiMaxDepthValue; p++)
    16651021  {
    16661022    if( abValidDepths[p] == true)
    16671023    {
    1668       auiIdx2DepthValue[uiNumDepthValues++] = p;
    1669     }
    1670   }
    1671  
    1672   if( uiNumFrames == 0 || ceil(Log2(uiNumDepthValues)) == ceil(Log2(g_uiIBDI_MAX)) )
     1024      aiIdx2DepthValue[iNumDepthValues++] = p;
     1025    }
     1026  }
     1027 
     1028  if( uiNumFrames == 0 || numBitsForValue(iNumDepthValues) == g_bitDepthY )
    16731029  {
    16741030    // don't use DLT
    1675     m_acTEncDepthTopList[iViewIdx]->setUseDLT(false);
    1676     m_acTEncDepthTopList[iViewIdx]->getSPS()->setUseDLT(false);
     1031    vps->setUseDLTFlag(layer, false);
    16771032  }
    16781033 
    16791034  // assign LUT
    1680   if( m_acTEncDepthTopList[iViewIdx]->getUseDLT() )
    1681     m_acTEncDepthTopList[iViewIdx]->getSPS()->setDepthLUTs(auiIdx2DepthValue, uiNumDepthValues);
    1682   else
    1683     m_acTEncDepthTopList[iViewIdx]->getSPS()->setDepthLUTs();
     1035  if( vps->getUseDLTFlag(layer) )
     1036    vps->setDepthLUTs(layer, aiIdx2DepthValue, iNumDepthValues);
    16841037 
    16851038  // free temporary memory
    1686   free(auiIdx2DepthValue);
    1687 }
    1688 #endif
    1689 
    1690 #if MERL_VSP_C0152
    1691 
    1692 Void TAppEncTop::setBWVSPLUT(
    1693 #if MERL_VSP_NBDV_RefVId_Fix_D0166
    1694         Int iNeighborViewId,
    1695 #endif
    1696         Int iCodedViewIdx, Int gopId, Bool isDepth)
    1697 {
    1698   //first view does not have VSP
    1699   if((iCodedViewIdx == 0)) return;
    1700 
    1701   AOT( iCodedViewIdx <= 0);
    1702   AOT( iCodedViewIdx >= m_iNumberOfViews );
    1703 #if !MERL_VSP_NBDV_RefVId_Fix_D0166
    1704   Int iNeighborViewId = 0;
    1705 #endif
    1706   //setting look-up table
    1707   Int* piShiftLUT = m_cCameraData.getBaseViewShiftLUTI()[iNeighborViewId][iCodedViewIdx][0];
    1708 
    1709   if(isDepth)
    1710   {
    1711     TEncSlice* pcEncSlice = (TEncSlice*) m_acTEncDepthTopList[iCodedViewIdx]->getSliceEncoder();
    1712 #if MERL_VSP_NBDV_RefVId_Fix_D0166
    1713     pcEncSlice->setBWVSPLUTParam(  piShiftLUT, LOG2_DISP_PREC_LUT, iNeighborViewId );
    1714 #else
    1715     pcEncSlice->setBWVSPLUTParam(  piShiftLUT, LOG2_DISP_PREC_LUT );
    1716 #endif
    1717   }
    1718   else
    1719   {
    1720     TEncSlice* pcEncSlice = (TEncSlice*) m_acTEncTopList[iCodedViewIdx]->getSliceEncoder();
    1721 #if MERL_VSP_NBDV_RefVId_Fix_D0166
    1722     pcEncSlice->setBWVSPLUTParam(  piShiftLUT, LOG2_DISP_PREC_LUT, iNeighborViewId );
    1723 #else
    1724     pcEncSlice->setBWVSPLUTParam(  piShiftLUT, LOG2_DISP_PREC_LUT );
    1725 #endif
    1726   }
    1727 
    1728 }
    1729 #endif
    1730 
     1039  free(aiIdx2DepthValue);
     1040}
     1041#endif
     1042
     1043#if H_MV
     1044Void TAppEncTop::xSetDimensionIdAndLength( TComVPS& vps )
     1045{   
     1046  vps.setScalabilityMask( m_scalabilityMask );
     1047  for( Int dim = 0; dim < m_dimIds.size(); dim++ )
     1048  {
     1049    vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] );
     1050    for( Int layer = 0; layer < vps.getMaxLayers(); layer++ )
     1051    {       
     1052      vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] );       
     1053    } 
     1054  }
     1055}
     1056
     1057Void TAppEncTop::xSetDependencies( TComVPS& vps )
     1058{
     1059  // Direct dependency flags + dependency types
     1060  for( Int depLayer = 1; depLayer < MAX_NUM_LAYERS; depLayer++ )
     1061  {
     1062    for( Int refLayer = 0; refLayer < MAX_NUM_LAYERS; refLayer++ )
     1063    {
     1064      vps.setDirectDependencyFlag( depLayer, refLayer, false);
     1065      vps.setDirectDependencyType( depLayer, refLayer,    -1 );
     1066    }
     1067    }
     1068  for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ )
     1069  {
     1070    Int numRefLayers = (Int) m_directRefLayers[depLayer].size();
     1071    assert(  numRefLayers == (Int) m_dependencyTypes[depLayer].size() );
     1072    for( Int i = 0; i < numRefLayers; i++ )
     1073    {
     1074      Int refLayer = m_directRefLayers[depLayer][i];
     1075      vps.setDirectDependencyFlag( depLayer, refLayer, true);
     1076      vps.setDirectDependencyType( depLayer, refLayer,m_dependencyTypes[depLayer][i]);
     1077    }
     1078  }
     1079
     1080  // Max temporal id for inter layer reference pictures
     1081  for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++)
     1082    {
     1083    Int maxTid = -1;
     1084    for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++)
     1085      {
     1086      for( Int i = 0; i < getGOPSize(); i++ )
     1087      {       
     1088        GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][i];
     1089        GOPEntry geRef =  m_GOPListMvc[refLayerIdInVps][i];
     1090       
     1091        for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++)
     1092        {       
     1093          if ( m_directRefLayers[ curLayerIdInVps ][ geCur.m_interLayerPredLayerIdc[ j ]] == refLayerIdInVps )
     1094          {
     1095            maxTid = std::max( maxTid, geRef.m_temporalId );
     1096          }
     1097        }
     1098      }
     1099    }
     1100    vps.setMaxTidIlRefPicPlus1( refLayerIdInVps, maxTid + 1 );
     1101  }
     1102
     1103  // Max one active ref layer flag
     1104  Bool maxOneActiveRefLayerFlag = true; 
     1105  for ( Int currLayerIdInVps = 1; currLayerIdInVps < m_numberOfLayers && maxOneActiveRefLayerFlag; currLayerIdInVps++)
     1106  {
     1107    for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ )
     1108    {       
     1109      GOPEntry ge =  m_GOPListMvc[currLayerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ];
     1110      maxOneActiveRefLayerFlag =  maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1);
     1111    }           
     1112}
     1113
     1114  vps.setMaxOneActiveRefLayerFlag( maxOneActiveRefLayerFlag );
     1115  vps.setRefLayers();
     1116};
     1117
     1118Void TAppEncTop::xSetLayerIds( TComVPS& vps )
     1119{
     1120  vps.setSplittingFlag     ( m_splittingFlag );
     1121
     1122  Bool nuhLayerIdPresentFlag = !( m_layerIdInNuh.size() == 1 );
     1123  Int  maxNuhLayerId = nuhLayerIdPresentFlag ? xGetMax( m_layerIdInNuh ) : ( m_numberOfLayers - 1 ) ;
     1124
     1125  vps.setVpsMaxLayerId( maxNuhLayerId );
     1126  vps.setVpsNuhLayerIdPresentFlag( nuhLayerIdPresentFlag );
     1127
     1128  for (Int layer = 0; layer < m_numberOfLayers; layer++ )
     1129  {
     1130    vps.setLayerIdInNuh( layer, nuhLayerIdPresentFlag ? m_layerIdInNuh[ layer ] : layer );
     1131    vps.setLayerIdInVps( vps.getLayerIdInNuh( layer ), layer );
     1132  }
     1133}
     1134
     1135Int TAppEncTop::xGetMax( std::vector<Int>& vec )
     1136{
     1137  Int maxVec = 0;
     1138  for ( Int i = 0; i < vec.size(); i++)   
     1139    maxVec = max( vec[i], maxVec );
     1140  return maxVec;
     1141}
     1142
     1143Void TAppEncTop::xSetProfileTierLevel( TComVPS& vps )
     1144{
     1145  const Int vpsNumProfileTierLevelMinus1 = 0; //TBD
     1146  vps.setVpsNumProfileTierLevelMinus1( vpsNumProfileTierLevelMinus1 );
     1147 
     1148  for (Int i = 0; i <= vps.getVpsNumProfileTierLevelMinus1(); i++ )
     1149  {
     1150    vps.setVpsProfilePresentFlag( i, true );
     1151  }
     1152}
     1153
     1154
     1155Void TAppEncTop::xSetLayerSets( TComVPS& vps )
     1156{   
     1157  // Layer sets
     1158  vps.setVpsNumLayerSetsMinus1   ( m_vpsNumLayerSets - 1 );
     1159  vps.setVpsNumberLayerSetsMinus1( vps.getVpsNumLayerSetsMinus1() );
     1160   
     1161  for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ )
     1162  {
     1163    for( Int layerId = 0; layerId < MAX_NUM_LAYER_IDS; layerId++ )
     1164    {
     1165      vps.setLayerIdIncludedFlag( false, lsIdx, layerId );
     1166    }
     1167    for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++)
     1168    {       
     1169      vps.setLayerIdIncludedFlag( true, lsIdx, vps.getLayerIdInNuh( m_layerIdsInSets[lsIdx][i] ) );
     1170    }
     1171  }
     1172
     1173  Int numAddOuputLayerSets = (Int) m_outputLayerSetIdx.size();
     1174  // Additional output layer sets + profileLevelTierIdx
     1175  vps.setDefaultOneTargetOutputLayerFlag   ( m_defaultOneTargetOutputLayerFlag );
     1176  vps.setMoreOutputLayerSetsThanDefaultFlag( numAddOuputLayerSets       != 0 );   
     1177  vps.setNumAddOutputLayerSetsMinus1       ( numAddOuputLayerSets - 1        );
     1178
     1179  for (Int lsIdx = 1; lsIdx < m_vpsNumLayerSets; lsIdx++)
     1180  {
     1181    vps.setProfileLevelTierIdx( lsIdx, m_profileLevelTierIdx[ lsIdx ] );
     1182  }
     1183
     1184  for (Int addOutLs = 0; addOutLs < numAddOuputLayerSets; addOutLs++ )
     1185  {
     1186    vps.setProfileLevelTierIdx( m_vpsNumLayerSets + addOutLs, m_profileLevelTierIdx[ addOutLs ] );
     1187
     1188    Int refLayerSetIdx = m_outputLayerSetIdx[ addOutLs ];     
     1189    vps.setOutputLayerSetIdxMinus1( m_vpsNumLayerSets + addOutLs, refLayerSetIdx - 1 );
     1190
     1191    for (Int i = 0; i < m_layerIdsInSets[ refLayerSetIdx].size(); i++ )
     1192    {
     1193      Bool outputLayerFlag = false;
     1194      for (Int j = 0; j < m_layerIdsInAddOutputLayerSet[ addOutLs ].size(); j++ )
     1195      {
     1196        if (  m_layerIdsInAddOutputLayerSet[addOutLs][ j ] == m_layerIdsInSets[ refLayerSetIdx][ i ] )
     1197        {
     1198          outputLayerFlag = true;
     1199          break;
     1200        }
     1201      }
     1202      vps.setOutputLayerFlag( m_vpsNumLayerSets + addOutLs, i, outputLayerFlag );       
     1203    }
     1204  }
     1205}
     1206#endif
     1207#if H_3D
     1208Void TAppEncTop::xSetVPSExtension2( TComVPS& vps )
     1209{
     1210  for ( Int layer = 0; layer < vps.getMaxLayers(); layer++ )
     1211  {
     1212    Bool isDepth      = ( vps.getDepthId( layer ) == 1 ) ;
     1213    Bool isLayerZero  = ( layer == 0 );
     1214
     1215#if H_3D_ARP
     1216    vps.setUseAdvRP        ( layer, ( isDepth || isLayerZero ) ? 0 : m_uiUseAdvResPred );
     1217    vps.setARPStepNum      ( layer, ( isDepth || isLayerZero ) ? 1 : H_3D_ARP_WFNR     );
     1218#endif 
     1219
     1220#if H_3D_DIM
     1221    vps.setVpsDepthModesFlag( layer, isDepth && !isLayerZero && (m_useDMM || m_useRBC || m_useSDC || m_useDLT ) );
     1222#if H_3D_DIM_DLT
     1223    vps.setUseDLTFlag( layer , isDepth && m_useDLT );
     1224    if( vps.getUseDLTFlag( layer ) )
     1225    {
     1226      xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod, 24), &vps);
     1227    }
     1228#endif
     1229#endif
     1230
     1231#if H_3D_IV_MERGE
     1232    vps.setIvMvPredFlag         ( layer, !isLayerZero && !isDepth && m_ivMvPredFlag );
     1233#endif
     1234#if H_3D_NBDV_REF
     1235    vps.setDepthRefinementFlag  ( layer, !isLayerZero && !isDepth && m_depthRefinementFlag );         
     1236#endif
     1237#if H_3D_VSP
     1238    vps.setViewSynthesisPredFlag( layer, !isLayerZero && !isDepth && m_viewSynthesisPredFlag );         
     1239#endif     
     1240#if LGE_INTER_SDC_E0156
     1241    vps.setInterSDCFlag( layer, !isLayerZero && isDepth && m_bDepthInterSDCFlag );
     1242#endif
     1243  } 
     1244#if H_3D_TMVP
     1245  vps.setIvMvScalingFlag( m_ivMvScalingFlag );   
     1246#endif
     1247}
     1248#endif
    17311249//! \}
Note: See TracChangeset for help on using the changeset viewer.