source: 3DVCSoftware/trunk/source/App/TAppEncoder/TAppEncTop.cpp

Last change on this file was 1413, checked in by tech, 7 years ago

Merged HTM-16.2-dev@1412

  • Property svn:eol-style set to native
File size: 108.6 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2017, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TAppEncTop.cpp
35    \brief    Encoder application class
36*/
37
38#include <list>
39#include <fstream>
40#include <stdlib.h>
41#include <stdio.h>
42#include <fcntl.h>
43#include <assert.h>
44#include <iomanip>
45
46#include "TAppEncTop.h"
47#include "TLibEncoder/AnnexBwrite.h"
48
49#if EXTENSION_360_VIDEO
50#include "TAppEncHelper360/TExt360AppEncTop.h"
51#endif
52
53using namespace std;
54
55//! \ingroup TAppEncoder
56//! \{
57
58// ====================================================================================================================
59// Constructor / destructor / initialization / destroy
60// ====================================================================================================================
61
62TAppEncTop::TAppEncTop()
63#if NH_MV
64  : m_spsMap( MAX_NUM_SPS ),
65    m_ppsMap( MAX_NUM_PPS )
66#endif
67{
68#if NH_MV
69  m_vps = new TComVPS; 
70#else
71  m_iFrameRcvd = 0;
72#endif
73  m_totalBytes = 0;
74  m_essentialBytes = 0;
75}
76
77TAppEncTop::~TAppEncTop()
78{
79#if NH_MV
80  if (m_vps)
81  {
82   delete m_vps; 
83  };
84#endif
85
86}
87
88Void TAppEncTop::xInitLibCfg()
89{
90#if NH_MV
91  TComVPS& vps = (*m_vps);   
92#else
93  TComVPS vps;
94#endif
95 
96#if NH_3D
97  vps.createCamPars(m_iNumberOfViews);   
98#endif
99
100#if NH_MV
101  Int maxTempLayer = -1; 
102  for (Int j = 0; j < m_numberOfLayers; j++)
103  {
104    maxTempLayer = max( m_maxTempLayerMvc[ j ], maxTempLayer ); 
105  }
106
107  vps.setMaxTLayers                       ( maxTempLayer );
108  if ( maxTempLayer )
109  {
110    vps.setTemporalNestingFlag(true);
111  }
112  vps.setMaxLayersMinus1( m_numberOfLayers - 1);
113  for(Int i = 0; i < MAX_TLAYER; i++)
114  {
115    Int maxNumReOrderPics  = 0; 
116    Int maxDecPicBuffering = 0;
117    for (Int j = 0; j < m_numberOfLayers; j++)
118    {
119      maxNumReOrderPics  = max( maxNumReOrderPics,  m_numReorderPicsMvc    [ j ][ i ] );     
120      maxDecPicBuffering = max( maxDecPicBuffering, m_maxDecPicBufferingMvc[ j ][ i ] );     
121    }
122
123    vps.setNumReorderPics                 ( maxNumReOrderPics  ,i );
124    vps.setMaxDecPicBuffering             ( maxDecPicBuffering ,i );
125  }
126#else
127  vps.setMaxTLayers                                               ( m_maxTempLayer );
128  if (m_maxTempLayer == 1)
129  {
130    vps.setTemporalNestingFlag(true);
131  }
132  vps.setMaxLayers                                                ( 1 );
133  for(Int i = 0; i < MAX_TLAYER; i++)
134  {
135    vps.setNumReorderPics                                         ( m_numReorderPics[i], i );
136    vps.setMaxDecPicBuffering                                     ( m_maxDecPicBuffering[i], i );
137  }
138#endif
139#if NH_MV
140  xSetTimingInfo           ( vps );
141  xSetHrdParameters        ( vps ); 
142  xSetLayerIds             ( vps );   
143  xSetDimensionIdAndLength ( vps );
144  xSetDependencies         ( vps );
145  xSetRepFormat            ( vps );   
146  xSetLayerSets            ( vps );   
147  xSetProfileTierLevel     ( vps );   
148  xSetDpbSize              ( vps ); 
149  xSetVPSVUI               ( vps ); 
150#if NH_3D
151  xSetCamPara              ( vps ); 
152#endif
153#if NH_3D_VSO || NH_3D
154  m_ivPicLists.setVPS      ( &vps );
155#endif
156#if NH_3D
157  TComDLT dlt = TComDLT();
158  xDeriveDltArray          ( vps, &dlt );
159#endif
160
161
162  xDeriveParameterSetIds( vps );
163
164  if ( m_targetEncLayerIdList.size() == 0 )
165  {
166    for (Int i = 0; i < m_numberOfLayers; i++ )
167    {
168      m_targetEncLayerIdList.push_back( vps.getLayerIdInNuh( i ) );
169    }
170  }
171  for( Int i = (Int) m_targetEncLayerIdList.size()-1 ; i >= 0 ; i--)
172  {
173    Int iNuhLayerId = m_targetEncLayerIdList[i]; 
174    Bool allRefLayersPresent = true; 
175    for( Int j = 0; j < vps.getNumRefLayers( iNuhLayerId ); j++)
176    {
177      allRefLayersPresent = allRefLayersPresent && xLayerIdInTargetEncLayerIdList( vps.getIdRefLayer( iNuhLayerId, j) );
178    }
179    if ( !allRefLayersPresent )
180    {
181      printf("\nCannot encode layer with nuh_layer_id equal to %d since not all reference layers are in TargetEncLayerIdList\n", iNuhLayerId);
182      m_targetEncLayerIdList.erase( m_targetEncLayerIdList.begin() + i  );
183    }
184  }
185
186  if ( m_outputVpsInfo )
187  { 
188    vps.printScalabilityId();
189    vps.printLayerDependencies();
190    vps.printLayerSets(); 
191    vps.printPTL(); 
192    vps.printRepFormat();
193  }
194
195#if NH_3D
196  // Set 3d tool parameters
197  for (Int d = 0; d < 2; d++)
198  { 
199    m_sps3dExtension.setIvDiMcEnabledFlag             ( d, m_ivMvPredFlag[d]       );
200    m_sps3dExtension.setIvMvScalEnabledFlag           ( d, m_ivMvScalingFlag[d]    );
201    if (d == 0 )
202    {   
203      m_sps3dExtension.setLog2IvmcSubPbSizeMinus3     ( d, m_log2SubPbSizeMinus3   );
204      m_sps3dExtension.setIvResPredEnabledFlag        ( d, m_ivResPredFlag         );
205      m_sps3dExtension.setDepthRefEnabledFlag         ( d, m_depthRefinementFlag   );
206      m_sps3dExtension.setVspMcEnabledFlag            ( d, m_viewSynthesisPredFlag );
207      m_sps3dExtension.setDbbpEnabledFlag             ( d, m_depthBasedBlkPartFlag );
208    }
209    else
210    {   
211      m_sps3dExtension.setTexMcEnabledFlag            ( d, m_mpiFlag               );
212      m_sps3dExtension.setLog2TexmcSubPbSizeMinus3    ( d, m_log2MpiSubPbSizeMinus3);
213      m_sps3dExtension.setIntraContourEnabledFlag     ( d, m_intraContourFlag      );
214      m_sps3dExtension.setIntraDcOnlyWedgeEnabledFlag ( d, m_intraSdcFlag || m_intraWedgeFlag     );
215      m_sps3dExtension.setCqtCuPartPredEnabledFlag    ( d, m_qtPredFlag            );
216      m_sps3dExtension.setInterDcOnlyEnabledFlag      ( d, m_interSdcFlag          );
217      m_sps3dExtension.setSkipIntraEnabledFlag        ( d, m_depthIntraSkipFlag    ); 
218    }
219  }
220#endif
221
222
223  /// Create encoders and set profiles profiles
224  for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++)
225  {
226    m_frameRcvd                 .push_back(0);
227#if NH_MV
228    m_acTEncTopList             .push_back(new TEncTop( m_spsMap, m_ppsMap ) ); 
229#else
230    m_acTEncTopList             .push_back(new TEncTop); 
231#endif
232    m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
233    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
234#if NH_3D   
235    Int profileIdc = -1; 
236    for (Int olsIdx = 0; olsIdx < vps.getNumOutputLayerSets(); olsIdx++ )
237    {   
238      Int lsIdx = vps.olsIdxToLsIdx( olsIdx );
239      for(Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++ )
240      {
241        if( vps.getLayerIdInNuh( layerIdInVps) == vps.getLayerSetLayerIdList(lsIdx, i) )
242        {
243          Int ptlIdx = vps.getProfileTierLevelIdx( olsIdx, i );
244          if ( ptlIdx != -1 )
245          {
246            Int curProfileIdc = vps.getPTL(ptlIdx)->getGeneralPTL()->getProfileIdc(); 
247            if (profileIdc == -1)   
248            {
249              profileIdc = curProfileIdc; 
250            }
251            else
252            {   
253              if ( profileIdc != curProfileIdc )
254              {             
255                fprintf(stderr, "Error: ProfileIdc for layer with index %d in VPS not equal in all OLSs. \n", layerIdInVps );
256                exit(EXIT_FAILURE);
257              }
258            }
259          }
260        }
261      }
262    }
263
264    if (profileIdc == -1 )
265    {
266      fprintf(stderr, "Error: No profile given for layer with index %d in VPS not equal in all OLS. \n", layerIdInVps );
267      exit(EXIT_FAILURE);
268    }
269    m_acTEncTopList[ layerIdInVps ]->setProfileIdc( profileIdc ); 
270#endif
271  }
272
273
274  for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++)
275  {
276    Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layerIdInVps];
277    m_cListPicYuvRec            .push_back(new TComList<TComPicYuv*>) ;
278    TEncTop& m_cTEncTop = *m_acTEncTopList[ layerIdInVps ];  // It is not a member, but this name helps avoiding code duplication !!!
279
280    Int layerId = vps.getLayerIdInNuh          ( layerIdInVps );
281    m_ivPicLists.getSubDpb( layerId, true ); 
282
283    m_cTEncTop.setLayerIdInVps                 ( layerIdInVps ); 
284    m_cTEncTop.setLayerId                      ( layerId );   
285    m_cTEncTop.setViewId                       ( vps.getViewId      (  layerId ) );
286    m_cTEncTop.setViewIndex                    ( vps.getViewIndex   (  layerId ) );
287    m_cTEncTop.setSendParameterSets            ( m_sendParameterSets[ layerIdInVps ]  );
288    m_cTEncTop.setParameterSetId               ( m_parameterSetId   [ layerIdInVps ]  );
289#if NH_3D_VSO || NH_3D
290    Bool isDepth    = ( vps.getDepthId     ( layerId ) != 0  ) ;
291    Bool isAuxDepth = ( vps.getAuxId       ( layerId ) ==  2 ) ; // TBD: define 2 as AUX_DEPTH
292    m_cTEncTop.setIsDepth                  ( isDepth    );
293    m_cTEncTop.setIsAuxDepth               ( isAuxDepth ); 
294    //====== Camera Parameters =========
295    m_cTEncTop.setCameraParameters         ( &m_cCameraData );     
296#endif
297#if NH_3D_VSO
298    //====== VSO =========
299    m_cTEncTop.setRenderModelParameters        ( &m_cRenModStrParser ); 
300    m_cTEncTop.setForceLambdaScaleVSO          ( isDepth || isAuxDepth ? m_bForceLambdaScaleVSO : false );
301    m_cTEncTop.setLambdaScaleVSO               ( isDepth || isAuxDepth ? m_dLambdaScaleVSO      : 1     );
302    m_cTEncTop.setVSOMode                      ( isDepth || isAuxDepth ? m_uiVSOMode            : 0     );
303
304    m_cTEncTop.setAllowNegDist                 ( isDepth || isAuxDepth ? m_bAllowNegDist        : false );
305
306    // SAIT_VSO_EST_A0033
307    m_cTEncTop.setUseEstimatedVSD              ( isDepth || isAuxDepth ? m_bUseEstimatedVSD     : false );
308
309    // LGE_WVSO_A0119
310    m_cTEncTop.setUseWVSO                      ( isDepth || isAuxDepth ? m_bUseWVSO             : false );   
311    m_cTEncTop.setVSOWeight                    ( isDepth || isAuxDepth ? m_iVSOWeight           : 0     );
312    m_cTEncTop.setVSDWeight                    ( isDepth || isAuxDepth ? m_iVSDWeight           : 0     );
313    m_cTEncTop.setDWeight                      ( isDepth || isAuxDepth ? m_iDWeight             : 0     );
314#endif // H_3D_VSO
315#if NH_3D
316    m_cTEncTop.setUseIC                        ( vps.getViewIndex( layerId ) == 0 || isDepth ? false : m_abUseIC );
317    m_cTEncTop.setUseICLowLatencyEnc           ( m_bUseLowLatencyICEnc );
318
319    m_cTEncTop.setUseDMM                       ( isDepth ? m_intraWedgeFlag   : false );
320    m_cTEncTop.setUseSDC                       ( isDepth ? m_intraSdcFlag     : false );
321    m_cTEncTop.setUseDLT                       ( isDepth ? m_useDLT   : false );
322
323    m_cTEncTop.setUseQTL                       ( isDepth || isAuxDepth ? m_bUseQTL  : false );
324
325    m_cTEncTop.setSps3dExtension               ( m_sps3dExtension );
326#endif // NH_3D
327
328    m_cTEncTop.setIvPicLists                   ( &m_ivPicLists ); 
329#endif  // NH_MV
330  m_cTEncTop.setVPS(&vps);
331
332#if NH_3D
333  m_cTEncTop.setDLT(dlt);
334#endif
335
336#if NH_MV
337  // These values go to the SPS of the base layer only and should apply as follows:
338  // –  If the profile_tier_level( ) syntax structure is included in an active SPS for the base layer
339  //    or is the profile_tier_level( ) syntax structure VpsProfileTierLevel[ 0 ],
340  //    it applies to the OLS containing all layers in the bitstream but with only the base layer being the output layer.
341  // –  Otherwise, if the profile_tier_level( ) syntax structure is included in an active SPS
342  //    for an independent non-base layer with nuh_layer_id equal to layerId, it applies to the output bitstream
343  //    of the independent non-base layer rewriting process of clause F.10.2 with the input variables assignedBaseLayerId equal to layerId and tIdTarget equal to 6.
344
345  m_cTEncTop.setProfile                                           ( m_profiles[0]                       );
346  m_cTEncTop.setLevel                                             ( m_levelTier[0], m_level[0]          );
347  m_cTEncTop.setProgressiveSourceFlag                             ( m_progressiveSourceFlags        [0] );
348  m_cTEncTop.setInterlacedSourceFlag                              ( m_interlacedSourceFlags         [0] );
349  m_cTEncTop.setNonPackedConstraintFlag                           ( m_nonPackedConstraintFlags      [0] );
350  m_cTEncTop.setFrameOnlyConstraintFlag                           ( m_frameOnlyConstraintFlags      [0] );
351  m_cTEncTop.setBitDepthConstraintValue                           ( m_bitDepthConstraints           [0] );
352  m_cTEncTop.setChromaFormatConstraintValue                       ( m_chromaFormatConstraints       [0] );
353  m_cTEncTop.setIntraConstraintFlag                               ( m_intraConstraintFlags          [0] );
354  m_cTEncTop.setOnePictureOnlyConstraintFlag                      ( m_onePictureOnlyConstraintFlags [0] );
355  m_cTEncTop.setLowerBitRateConstraintFlag                        ( m_lowerBitRateConstraintFlags   [0] );
356#else
357  m_cTEncTop.setProfile                                           ( m_profile);
358  m_cTEncTop.setLevel                                             ( m_levelTier, m_level);
359  m_cTEncTop.setProgressiveSourceFlag                             ( m_progressiveSourceFlag);
360  m_cTEncTop.setInterlacedSourceFlag                              ( m_interlacedSourceFlag);
361  m_cTEncTop.setNonPackedConstraintFlag                           ( m_nonPackedConstraintFlag);
362  m_cTEncTop.setFrameOnlyConstraintFlag                           ( m_frameOnlyConstraintFlag);
363  m_cTEncTop.setBitDepthConstraintValue                           ( m_bitDepthConstraint );
364  m_cTEncTop.setChromaFormatConstraintValue                       ( m_chromaFormatConstraint );
365  m_cTEncTop.setIntraConstraintFlag                               ( m_intraConstraintFlag );
366  m_cTEncTop.setOnePictureOnlyConstraintFlag                      ( m_onePictureOnlyConstraintFlag );
367  m_cTEncTop.setLowerBitRateConstraintFlag                        ( m_lowerBitRateConstraintFlag );
368
369#endif
370
371  m_cTEncTop.setPrintMSEBasedSequencePSNR                         ( m_printMSEBasedSequencePSNR);
372  m_cTEncTop.setPrintFrameMSE                                     ( m_printFrameMSE);
373  m_cTEncTop.setPrintSequenceMSE                                  ( m_printSequenceMSE);
374#if JVET_F0064_MSSSIM
375  m_cTEncTop.setPrintMSSSIM                                       ( m_printMSSSIM );
376#endif
377  m_cTEncTop.setCabacZeroWordPaddingEnabled                       ( m_cabacZeroWordPaddingEnabled );
378
379  m_cTEncTop.setFrameRate                                         ( m_iFrameRate );
380  m_cTEncTop.setFrameSkip                                         ( m_FrameSkip );
381  m_cTEncTop.setTemporalSubsampleRatio                            ( m_temporalSubsampleRatio );
382#if NH_MV
383  m_cTEncTop.setSourceWidth                                       ( m_iSourceWidths [repFormatIdx] );
384  m_cTEncTop.setSourceHeight                                      ( m_iSourceHeights[repFormatIdx] );
385
386  m_cTEncTop.setConformanceWindow                                 ( m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx] );
387#else
388  m_cTEncTop.setSourceWidth                                       ( m_iSourceWidth );
389  m_cTEncTop.setSourceHeight                                      ( m_iSourceHeight );
390  m_cTEncTop.setConformanceWindow                                 ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
391#endif
392  m_cTEncTop.setFramesToBeEncoded                                 ( m_framesToBeEncoded );
393
394  //====== Coding Structure ========
395#if NH_MV
396  m_cTEncTop.setIntraPeriod                                       ( m_iIntraPeriod[ layerIdInVps ] );
397#else
398  m_cTEncTop.setIntraPeriod                                       ( m_iIntraPeriod );
399#endif
400  m_cTEncTop.setDecodingRefreshType                               ( m_iDecodingRefreshType );
401  m_cTEncTop.setGOPSize                                           ( m_iGOPSize );
402#if JCTVC_Y0038_PARAMS
403  m_cTEncTop.setReWriteParamSetsFlag                              ( m_bReWriteParamSetsFlag );
404#endif
405#if NH_MV
406  m_cTEncTop.setGopList                                           ( xGetGopEntries(layerIdInVps) );
407  m_cTEncTop.setExtraRPSs                                         ( m_extraRPSsMvc[layerIdInVps] );
408  for(Int i = 0; i < MAX_TLAYER; i++)
409  {
410    m_cTEncTop.setNumReorderPics                                  ( m_numReorderPicsMvc[layerIdInVps][i], i );
411    m_cTEncTop.setMaxDecPicBuffering                              ( m_maxDecPicBufferingMvc[layerIdInVps][i], i );
412  }
413#else
414  m_cTEncTop.setGopList                                           ( m_GOPList );
415  m_cTEncTop.setExtraRPSs                                         ( m_extraRPSs );
416  for(Int i = 0; i < MAX_TLAYER; i++)
417  {
418    m_cTEncTop.setNumReorderPics                                  ( m_numReorderPics[i], i );
419    m_cTEncTop.setMaxDecPicBuffering                              ( m_maxDecPicBuffering[i], i );
420  }
421#endif
422  for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
423  {
424    m_cTEncTop.setLambdaModifier                                  ( uiLoop, m_adLambdaModifier[ uiLoop ] );
425  }
426  m_cTEncTop.setIntraLambdaModifier                               ( m_adIntraLambdaModifier );
427  m_cTEncTop.setIntraQpFactor                                     ( m_dIntraQpFactor );
428
429#if NH_MV
430  m_cTEncTop.setQP                                                ( m_iQP[layerIdInVps] );
431#else
432  m_cTEncTop.setQP                                                ( m_iQP );
433#endif
434
435#if X0038_LAMBDA_FROM_QP_CAPABILITY
436  m_cTEncTop.setIntraQPOffset                                     ( m_intraQPOffset );
437  m_cTEncTop.setLambdaFromQPEnable                                ( m_lambdaFromQPEnable );
438#endif
439#if NH_MV
440  m_cTEncTop.setPad                                               ( &m_aiPads[ repFormatIdx ][0] );
441#else
442  m_cTEncTop.setPad                                               ( m_aiPad );
443#endif
444
445  m_cTEncTop.setAccessUnitDelimiter                               ( m_AccessUnitDelimiter );
446#if NH_MV
447  m_cTEncTop.setMaxTempLayer                                      ( m_maxTempLayerMvc[layerIdInVps] );
448#else
449  m_cTEncTop.setMaxTempLayer                                      ( m_maxTempLayer );
450#endif
451  m_cTEncTop.setUseAMP( m_enableAMP );
452
453  //===== Slice ========
454
455  //====== Loop/Deblock Filter ========
456#if NH_MV
457  m_cTEncTop.setLoopFilterDisable                                 ( m_bLoopFilterDisable[layerIdInVps]);
458#else
459  m_cTEncTop.setLoopFilterDisable                                 ( m_bLoopFilterDisable       );
460#endif
461  m_cTEncTop.setLoopFilterOffsetInPPS                             ( m_loopFilterOffsetInPPS );
462  m_cTEncTop.setLoopFilterBetaOffset                              ( m_loopFilterBetaOffsetDiv2  );
463  m_cTEncTop.setLoopFilterTcOffset                                ( m_loopFilterTcOffsetDiv2    );
464  m_cTEncTop.setDeblockingFilterMetric                            ( m_deblockingFilterMetric );
465
466  //====== Motion search ========
467  m_cTEncTop.setDisableIntraPUsInInterSlices                      ( m_bDisableIntraPUsInInterSlices );
468  m_cTEncTop.setMotionEstimationSearchMethod                      ( m_motionEstimationSearchMethod  );
469  m_cTEncTop.setSearchRange                                       ( m_iSearchRange );
470  m_cTEncTop.setBipredSearchRange                                 ( m_bipredSearchRange );
471  m_cTEncTop.setClipForBiPredMeEnabled                            ( m_bClipForBiPredMeEnabled );
472  m_cTEncTop.setFastMEAssumingSmootherMVEnabled                   ( m_bFastMEAssumingSmootherMVEnabled );
473  m_cTEncTop.setMinSearchWindow                                   ( m_minSearchWindow );
474  m_cTEncTop.setRestrictMESampling                                ( m_bRestrictMESampling );
475
476#if NH_MV
477  m_cTEncTop.setUseDisparitySearchRangeRestriction                ( m_bUseDisparitySearchRangeRestriction );
478  m_cTEncTop.setVerticalDisparitySearchRange                      ( m_iVerticalDisparitySearchRange );
479#endif
480  //====== Quality control ========
481  m_cTEncTop.setMaxDeltaQP                                        ( m_iMaxDeltaQP  );
482  m_cTEncTop.setMaxCuDQPDepth                                     ( m_iMaxCuDQPDepth  );
483  m_cTEncTop.setDiffCuChromaQpOffsetDepth                         ( m_diffCuChromaQpOffsetDepth );
484  m_cTEncTop.setChromaCbQpOffset                                  ( m_cbQpOffset     );
485  m_cTEncTop.setChromaCrQpOffset                                  ( m_crQpOffset  );
486  m_cTEncTop.setWCGChromaQpControl                                ( m_wcgChromaQpControl );
487  m_cTEncTop.setSliceChromaOffsetQpIntraOrPeriodic                ( m_sliceChromaQpOffsetPeriodicity, m_sliceChromaQpOffsetIntraOrPeriodic );
488
489#if NH_MV
490  m_cTEncTop.setChromaFormatIdc                                   ( m_chromaFormatIDCs[ repFormatIdx ] );
491#else
492  m_cTEncTop.setChromaFormatIdc                                   ( m_chromaFormatIDC  );
493#endif
494
495#if ADAPTIVE_QP_SELECTION
496  m_cTEncTop.setUseAdaptQpSelect                                  ( m_bUseAdaptQpSelect   );
497#endif
498
499  m_cTEncTop.setUseAdaptiveQP                                     ( m_bUseAdaptiveQP  );
500  m_cTEncTop.setQPAdaptationRange                                 ( m_iQPAdaptationRange );
501  m_cTEncTop.setExtendedPrecisionProcessingFlag                   ( m_extendedPrecisionProcessingFlag );
502  m_cTEncTop.setHighPrecisionOffsetsEnabledFlag                   ( m_highPrecisionOffsetsEnabledFlag );
503
504  m_cTEncTop.setWeightedPredictionMethod( m_weightedPredictionMethod );
505
506  //====== Tool list ========
507  m_cTEncTop.setLumaLevelToDeltaQPControls                        ( m_lumaLevelToDeltaQPMapping );
508#if X0038_LAMBDA_FROM_QP_CAPABILITY
509  m_cTEncTop.setDeltaQpRD( (m_costMode==COST_LOSSLESS_CODING) ? 0 : m_uiDeltaQpRD );
510#else
511  m_cTEncTop.setDeltaQpRD                                         ( m_uiDeltaQpRD  );
512#endif
513  m_cTEncTop.setFastDeltaQp                                       ( m_bFastDeltaQP  );
514  m_cTEncTop.setUseASR                                            ( m_bUseASR      );
515  m_cTEncTop.setUseHADME                                          ( m_bUseHADME    );
516#if NH_MV
517  m_cTEncTop.setdQPs                                              ( m_aidQP[layerIdInVps]   );
518#else
519  m_cTEncTop.setdQPs                                              ( m_aidQP        );
520#endif
521  m_cTEncTop.setUseRDOQ                                           ( m_useRDOQ     );
522  m_cTEncTop.setUseRDOQTS                                         ( m_useRDOQTS   );
523  m_cTEncTop.setUseSelectiveRDOQ                                  ( m_useSelectiveRDOQ );
524  m_cTEncTop.setRDpenalty                                         ( m_rdPenalty );
525  m_cTEncTop.setMaxCUWidth                                        ( m_uiMaxCUWidth );
526  m_cTEncTop.setMaxCUHeight                                       ( m_uiMaxCUHeight );
527#if NH_MV
528  m_cTEncTop.setMaxTotalCUDepth                                   ( m_uiMaxTotalCUDepth[ repFormatIdx] );
529#else
530  m_cTEncTop.setMaxTotalCUDepth                                   ( m_uiMaxTotalCUDepth );
531#endif
532  m_cTEncTop.setLog2DiffMaxMinCodingBlockSize                     ( m_uiLog2DiffMaxMinCodingBlockSize );
533  m_cTEncTop.setQuadtreeTULog2MaxSize                             ( m_uiQuadtreeTULog2MaxSize );
534  m_cTEncTop.setQuadtreeTULog2MinSize                             ( m_uiQuadtreeTULog2MinSize );
535  m_cTEncTop.setQuadtreeTUMaxDepthInter                           ( m_uiQuadtreeTUMaxDepthInter );
536  m_cTEncTop.setQuadtreeTUMaxDepthIntra                           ( m_uiQuadtreeTUMaxDepthIntra );
537  m_cTEncTop.setFastInterSearchMode                               ( m_fastInterSearchMode );
538  m_cTEncTop.setUseEarlyCU                                        ( m_bUseEarlyCU  );
539  m_cTEncTop.setUseFastDecisionForMerge                           ( m_useFastDecisionForMerge  );
540  m_cTEncTop.setUseCbfFastMode                                    ( m_bUseCbfFastMode  );
541  m_cTEncTop.setUseEarlySkipDetection                             ( m_useEarlySkipDetection );
542  m_cTEncTop.setCrossComponentPredictionEnabledFlag               ( m_crossComponentPredictionEnabledFlag );
543  m_cTEncTop.setUseReconBasedCrossCPredictionEstimate             ( m_reconBasedCrossCPredictionEstimate );
544#if NH_MV
545  m_cTEncTop.setLog2SaoOffsetScale                                ( CHANNEL_TYPE_LUMA  , m_log2SaoOffsetScale[layerIdInVps][CHANNEL_TYPE_LUMA]   );
546  m_cTEncTop.setLog2SaoOffsetScale                                ( CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[layerIdInVps][CHANNEL_TYPE_CHROMA] );
547#else
548  m_cTEncTop.setLog2SaoOffsetScale                                ( CHANNEL_TYPE_LUMA  , m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA]   );
549  m_cTEncTop.setLog2SaoOffsetScale                                ( CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] );
550#endif
551  m_cTEncTop.setUseTransformSkip                                  ( m_useTransformSkip      );
552  m_cTEncTop.setUseTransformSkipFast                              ( m_useTransformSkipFast  );
553  m_cTEncTop.setTransformSkipRotationEnabledFlag                  ( m_transformSkipRotationEnabledFlag );
554  m_cTEncTop.setTransformSkipContextEnabledFlag                   ( m_transformSkipContextEnabledFlag   );
555  m_cTEncTop.setPersistentRiceAdaptationEnabledFlag               ( m_persistentRiceAdaptationEnabledFlag );
556  m_cTEncTop.setCabacBypassAlignmentEnabledFlag                   ( m_cabacBypassAlignmentEnabledFlag );
557  m_cTEncTop.setLog2MaxTransformSkipBlockSize                     ( m_log2MaxTransformSkipBlockSize  );
558  for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++)
559  {
560    m_cTEncTop.setRdpcmEnabledFlag                                ( RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]);
561  }
562  m_cTEncTop.setUseConstrainedIntraPred                           ( m_bUseConstrainedIntraPred );
563  m_cTEncTop.setFastUDIUseMPMEnabled                              ( m_bFastUDIUseMPMEnabled );
564  m_cTEncTop.setFastMEForGenBLowDelayEnabled                      ( m_bFastMEForGenBLowDelayEnabled );
565  m_cTEncTop.setUseBLambdaForNonKeyLowDelayPictures               ( m_bUseBLambdaForNonKeyLowDelayPictures );
566  m_cTEncTop.setPCMLog2MinSize                                    ( m_uiPCMLog2MinSize);
567  m_cTEncTop.setUsePCM                                            ( m_usePCM );
568
569  // set internal bit-depth and constants
570  for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
571  {
572#if NH_MV
573    m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepths[repFormatIdx][channelType]);
574    m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepths[repFormatIdx][channelType] : m_internalBitDepths[repFormatIdx][channelType]);
575#else
576    m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepth[channelType]);
577    m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[channelType] : m_internalBitDepth[channelType]);
578#endif
579  }
580
581  m_cTEncTop.setPCMLog2MaxSize                                    ( m_pcmLog2MaxSize);
582  m_cTEncTop.setMaxNumMergeCand                                   ( m_maxNumMergeCand );
583
584
585  //====== Weighted Prediction ========
586  m_cTEncTop.setUseWP                                             ( m_useWeightedPred      );
587  m_cTEncTop.setWPBiPred                                          ( m_useWeightedBiPred   );
588  //====== Parallel Merge Estimation ========
589  m_cTEncTop.setLog2ParallelMergeLevelMinus2                      ( m_log2ParallelMergeLevel - 2 );
590
591  //====== Slice ========
592  m_cTEncTop.setSliceMode                                         ( m_sliceMode );
593  m_cTEncTop.setSliceArgument                                     ( m_sliceArgument            );
594
595  //====== Dependent Slice ========
596  m_cTEncTop.setSliceSegmentMode                                  ( m_sliceSegmentMode );
597  m_cTEncTop.setSliceSegmentArgument                              ( m_sliceSegmentArgument     );
598
599  if(m_sliceMode == NO_SLICES )
600  {
601    m_bLFCrossSliceBoundaryFlag = true;
602  }
603  m_cTEncTop.setLFCrossSliceBoundaryFlag                          ( m_bLFCrossSliceBoundaryFlag );
604#if NH_MV
605  m_cTEncTop.setUseSAO ( m_bUseSAO[layerIdInVps] );
606#else
607  m_cTEncTop.setUseSAO                                            ( m_bUseSAO );
608#endif
609  m_cTEncTop.setTestSAODisableAtPictureLevel                      ( m_bTestSAODisableAtPictureLevel );
610  m_cTEncTop.setSaoEncodingRate                                   ( m_saoEncodingRate );
611  m_cTEncTop.setSaoEncodingRateChroma                             ( m_saoEncodingRateChroma );
612  m_cTEncTop.setMaxNumOffsetsPerPic                               ( m_maxNumOffsetsPerPic);
613
614  m_cTEncTop.setSaoCtuBoundary                                    ( m_saoCtuBoundary);
615  m_cTEncTop.setSaoResetEncoderStateAfterIRAP                     ( m_saoResetEncoderStateAfterIRAP);
616  m_cTEncTop.setPCMInputBitDepthFlag                              ( m_bPCMInputBitDepthFlag);
617  m_cTEncTop.setPCMFilterDisableFlag                              ( m_bPCMFilterDisableFlag);
618
619  m_cTEncTop.setIntraSmoothingDisabledFlag                        (!m_enableIntraReferenceSmoothing );
620  m_cTEncTop.setDecodedPictureHashSEIType                         ( m_decodedPictureHashSEIType );
621  m_cTEncTop.setRecoveryPointSEIEnabled                           ( m_recoveryPointSEIEnabled );
622  m_cTEncTop.setBufferingPeriodSEIEnabled                         ( m_bufferingPeriodSEIEnabled );
623  m_cTEncTop.setPictureTimingSEIEnabled                           ( m_pictureTimingSEIEnabled );
624  m_cTEncTop.setToneMappingInfoSEIEnabled                         ( m_toneMappingInfoSEIEnabled );
625  m_cTEncTop.setTMISEIToneMapId                                   ( m_toneMapId );
626  m_cTEncTop.setTMISEIToneMapCancelFlag                           ( m_toneMapCancelFlag );
627  m_cTEncTop.setTMISEIToneMapPersistenceFlag                      ( m_toneMapPersistenceFlag );
628  m_cTEncTop.setTMISEICodedDataBitDepth                           ( m_toneMapCodedDataBitDepth );
629  m_cTEncTop.setTMISEITargetBitDepth                              ( m_toneMapTargetBitDepth );
630  m_cTEncTop.setTMISEIModelID                                     ( m_toneMapModelId );
631  m_cTEncTop.setTMISEIMinValue                                    ( m_toneMapMinValue );
632  m_cTEncTop.setTMISEIMaxValue                                    ( m_toneMapMaxValue );
633  m_cTEncTop.setTMISEISigmoidMidpoint                             ( m_sigmoidMidpoint );
634  m_cTEncTop.setTMISEISigmoidWidth                                ( m_sigmoidWidth );
635  m_cTEncTop.setTMISEIStartOfCodedInterva                         ( m_startOfCodedInterval );
636  m_cTEncTop.setTMISEINumPivots                                   ( m_numPivots );
637  m_cTEncTop.setTMISEICodedPivotValue                             ( m_codedPivotValue );
638  m_cTEncTop.setTMISEITargetPivotValue                            ( m_targetPivotValue );
639  m_cTEncTop.setTMISEICameraIsoSpeedIdc                           ( m_cameraIsoSpeedIdc );
640  m_cTEncTop.setTMISEICameraIsoSpeedValue                         ( m_cameraIsoSpeedValue );
641  m_cTEncTop.setTMISEIExposureIndexIdc                            ( m_exposureIndexIdc );
642  m_cTEncTop.setTMISEIExposureIndexValue                          ( m_exposureIndexValue );
643  m_cTEncTop.setTMISEIExposureCompensationValueSignFlag           ( m_exposureCompensationValueSignFlag );
644  m_cTEncTop.setTMISEIExposureCompensationValueNumerator          ( m_exposureCompensationValueNumerator );
645  m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc           ( m_exposureCompensationValueDenomIdc );
646  m_cTEncTop.setTMISEIRefScreenLuminanceWhite                     ( m_refScreenLuminanceWhite );
647  m_cTEncTop.setTMISEIExtendedRangeWhiteLevel                     ( m_extendedRangeWhiteLevel );
648  m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue              ( m_nominalBlackLevelLumaCodeValue );
649  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue              ( m_nominalWhiteLevelLumaCodeValue );
650  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue             ( m_extendedWhiteLevelLumaCodeValue );
651  m_cTEncTop.setChromaResamplingFilterHintEnabled                 ( m_chromaResamplingFilterSEIenabled );
652  m_cTEncTop.setChromaResamplingHorFilterIdc                      ( m_chromaResamplingHorFilterIdc );
653  m_cTEncTop.setChromaResamplingVerFilterIdc                      ( m_chromaResamplingVerFilterIdc );
654  m_cTEncTop.setFramePackingArrangementSEIEnabled                 ( m_framePackingSEIEnabled );
655  m_cTEncTop.setFramePackingArrangementSEIType                    ( m_framePackingSEIType );
656  m_cTEncTop.setFramePackingArrangementSEIId                      ( m_framePackingSEIId );
657  m_cTEncTop.setFramePackingArrangementSEIQuincunx                ( m_framePackingSEIQuincunx );
658  m_cTEncTop.setFramePackingArrangementSEIInterpretation          ( m_framePackingSEIInterpretation );
659  m_cTEncTop.setSegmentedRectFramePackingArrangementSEIEnabled    ( m_segmentedRectFramePackingSEIEnabled );
660  m_cTEncTop.setSegmentedRectFramePackingArrangementSEICancel     ( m_segmentedRectFramePackingSEICancel );
661  m_cTEncTop.setSegmentedRectFramePackingArrangementSEIType       ( m_segmentedRectFramePackingSEIType );
662  m_cTEncTop.setSegmentedRectFramePackingArrangementSEIPersistence( m_segmentedRectFramePackingSEIPersistence );
663  m_cTEncTop.setDisplayOrientationSEIAngle                        ( m_displayOrientationSEIAngle );
664  m_cTEncTop.setTemporalLevel0IndexSEIEnabled                     ( m_temporalLevel0IndexSEIEnabled );
665  m_cTEncTop.setGradualDecodingRefreshInfoEnabled                 ( m_gradualDecodingRefreshInfoEnabled );
666  m_cTEncTop.setNoDisplaySEITLayer                                ( m_noDisplaySEITLayer );
667  m_cTEncTop.setDecodingUnitInfoSEIEnabled                        ( m_decodingUnitInfoSEIEnabled );
668  m_cTEncTop.setSOPDescriptionSEIEnabled                          ( m_SOPDescriptionSEIEnabled );
669  m_cTEncTop.setScalableNestingSEIEnabled                         ( m_scalableNestingSEIEnabled );
670  m_cTEncTop.setTMCTSSEIEnabled                                   ( m_tmctsSEIEnabled );
671#if MCTS_ENC_CHECK
672  m_cTEncTop.setTMCTSSEITileConstraint                            ( m_tmctsSEITileConstraint );
673#endif
674  m_cTEncTop.setTimeCodeSEIEnabled                                ( m_timeCodeSEIEnabled );
675  m_cTEncTop.setNumberOfTimeSets                                  ( m_timeCodeSEINumTs );
676  for(Int i = 0; i < m_timeCodeSEINumTs; i++)
677  {
678    m_cTEncTop.setTimeSet(m_timeSetArray[i], i);
679  }
680  m_cTEncTop.setKneeSEIEnabled                                    ( m_kneeSEIEnabled );
681  m_cTEncTop.setKneeSEIId                                         ( m_kneeSEIId );
682  m_cTEncTop.setKneeSEICancelFlag                                 ( m_kneeSEICancelFlag );
683  m_cTEncTop.setKneeSEIPersistenceFlag                            ( m_kneeSEIPersistenceFlag );
684  m_cTEncTop.setKneeSEIInputDrange                                ( m_kneeSEIInputDrange );
685  m_cTEncTop.setKneeSEIInputDispLuminance                         ( m_kneeSEIInputDispLuminance );
686  m_cTEncTop.setKneeSEIOutputDrange                               ( m_kneeSEIOutputDrange );
687  m_cTEncTop.setKneeSEIOutputDispLuminance                        ( m_kneeSEIOutputDispLuminance );
688  m_cTEncTop.setKneeSEINumKneePointsMinus1                        ( m_kneeSEINumKneePointsMinus1 );
689  m_cTEncTop.setKneeSEIInputKneePoint                             ( m_kneeSEIInputKneePoint );
690  m_cTEncTop.setKneeSEIOutputKneePoint                            ( m_kneeSEIOutputKneePoint );
691  m_cTEncTop.setColourRemapInfoSEIFileRoot                        ( m_colourRemapSEIFileRoot );
692  m_cTEncTop.setMasteringDisplaySEI                               ( m_masteringDisplay );
693  m_cTEncTop.setSEIAlternativeTransferCharacteristicsSEIEnable    ( m_preferredTransferCharacteristics>=0     );
694  m_cTEncTop.setSEIPreferredTransferCharacteristics               ( UChar(m_preferredTransferCharacteristics) );
695  m_cTEncTop.setSEIGreenMetadataInfoSEIEnable                     ( m_greenMetadataType > 0 );
696  m_cTEncTop.setSEIGreenMetadataType                              ( UChar(m_greenMetadataType) );
697  m_cTEncTop.setSEIXSDMetricType                                  ( UChar(m_xsdMetricType) );
698#if NH_MV
699  m_cTEncTop.setSeiMessages                                       ( &m_seiMessages ); 
700#endif
701
702  m_cTEncTop.setTileUniformSpacingFlag                            ( m_tileUniformSpacingFlag );
703  m_cTEncTop.setNumColumnsMinus1                                  ( m_numTileColumnsMinus1 );
704  m_cTEncTop.setNumRowsMinus1                                     ( m_numTileRowsMinus1 );
705  if(!m_tileUniformSpacingFlag)
706  {
707    m_cTEncTop.setColumnWidth                                     ( m_tileColumnWidth );
708    m_cTEncTop.setRowHeight                                       ( m_tileRowHeight );
709  }
710  m_cTEncTop.xCheckGSParameters();
711  Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1);
712  if(uiTilesCount == 1)
713  {
714    m_bLFCrossTileBoundaryFlag = true;
715  }
716  m_cTEncTop.setLFCrossTileBoundaryFlag                           ( m_bLFCrossTileBoundaryFlag );
717  m_cTEncTop.setEntropyCodingSyncEnabledFlag                      ( m_entropyCodingSyncEnabledFlag );
718  m_cTEncTop.setTMVPModeId                                        ( m_TMVPModeId );
719  m_cTEncTop.setUseScalingListId                                  ( m_useScalingListId  );
720  m_cTEncTop.setScalingListFileName                               ( m_scalingListFileName );
721  m_cTEncTop.setSignDataHidingEnabledFlag                         ( m_signDataHidingEnabledFlag);
722
723#if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227
724  if(!m_cTEncTop.getIsDepth())    //only for texture
725  {
726    m_cTEncTop.setUseRateCtrl                                     ( m_RCEnableRateControl );
727  }                                                         
728  else                                                       
729  {                                                         
730    m_cTEncTop.setUseRateCtrl                                     ( 0 );
731  }
732#else
733  m_cTEncTop.setUseRateCtrl                                       ( m_RCEnableRateControl );
734#endif
735#if !KWU_RC_VIEWRC_E0227
736  m_cTEncTop.setTargetBitrate                                     ( m_RCTargetBitrate );
737#endif
738  m_cTEncTop.setKeepHierBit                                       ( m_RCKeepHierarchicalBit );
739  m_cTEncTop.setLCULevelRC                                        ( m_RCLCULevelRC );
740  m_cTEncTop.setUseLCUSeparateModel                               ( m_RCUseLCUSeparateModel );
741  m_cTEncTop.setInitialQP                                         ( m_RCInitialQP );
742  m_cTEncTop.setForceIntraQP                                      ( m_RCForceIntraQP );
743  m_cTEncTop.setCpbSaturationEnabled                              ( m_RCCpbSaturationEnabled );
744  m_cTEncTop.setCpbSize                                           ( m_RCCpbSize );
745  m_cTEncTop.setInitialCpbFullness                                ( m_RCInitialCpbFullness );
746
747#if KWU_RC_MADPRED_E0227
748  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
749  {
750    m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred       : 0);
751    if(m_cTEncTop.getUseDepthMADPred())
752    {
753      m_cTEncTop.setCamParam(&m_cCameraData);
754    }
755  }
756#endif
757#if KWU_RC_VIEWRC_E0227
758  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
759  {
760    m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl);
761    if(m_iNumberOfViews == 1)
762    {
763      if(m_viewWiseRateCtrl)
764      {
765        m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
766      }
767      else
768      {
769        m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
770      }
771    }
772    else
773    {
774      if(m_viewWiseRateCtrl)
775      {
776        m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
777      }
778      else
779      {
780        if(m_iNumberOfViews == 2)
781        {
782          if(m_cTEncTop.getViewId() == 0)
783          {
784            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*80)/100 );
785          }
786          else if(m_cTEncTop.getViewId() == 1)
787          {
788            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*20)/100 );
789          }
790        }
791        else if(m_iNumberOfViews == 3)
792        {
793          if(m_cTEncTop.getViewId() == 0)
794          {
795            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*66)/100 );
796          }
797          else if(m_cTEncTop.getViewId() == 1)
798          {
799            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*17)/100 );
800          }
801          else if(m_cTEncTop.getViewId() == 2)
802          {
803            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*17)/100 );
804          }
805        }
806        else
807        {
808          m_cTEncTop.setTargetBitrate              ( m_RCTargetBitrate );
809        }
810      }
811    }
812  }
813#endif
814  m_cTEncTop.setTransquantBypassEnabledFlag                       ( m_TransquantBypassEnabledFlag );
815  m_cTEncTop.setCUTransquantBypassFlagForceValue                  ( m_CUTransquantBypassFlagForce );
816  m_cTEncTop.setCostMode                                          ( m_costMode );
817  m_cTEncTop.setUseRecalculateQPAccordingToLambda                 ( m_recalculateQPAccordingToLambda );
818  m_cTEncTop.setUseStrongIntraSmoothing                           ( m_useStrongIntraSmoothing );
819  m_cTEncTop.setActiveParameterSetsSEIEnabled                     ( m_activeParameterSetsSEIEnabled );
820  m_cTEncTop.setVuiParametersPresentFlag                          ( m_vuiParametersPresentFlag );
821  m_cTEncTop.setAspectRatioInfoPresentFlag                        ( m_aspectRatioInfoPresentFlag);
822  m_cTEncTop.setAspectRatioIdc                                    ( m_aspectRatioIdc );
823  m_cTEncTop.setSarWidth                                          ( m_sarWidth );
824  m_cTEncTop.setSarHeight                                         ( m_sarHeight );
825  m_cTEncTop.setOverscanInfoPresentFlag                           ( m_overscanInfoPresentFlag );
826  m_cTEncTop.setOverscanAppropriateFlag                           ( m_overscanAppropriateFlag );
827  m_cTEncTop.setVideoSignalTypePresentFlag                        ( m_videoSignalTypePresentFlag );
828  m_cTEncTop.setVideoFormat                                       ( m_videoFormat );
829  m_cTEncTop.setVideoFullRangeFlag                                ( m_videoFullRangeFlag );
830  m_cTEncTop.setColourDescriptionPresentFlag                      ( m_colourDescriptionPresentFlag );
831  m_cTEncTop.setColourPrimaries                                   ( m_colourPrimaries );
832  m_cTEncTop.setTransferCharacteristics                           ( m_transferCharacteristics );
833  m_cTEncTop.setMatrixCoefficients                                ( m_matrixCoefficients );
834  m_cTEncTop.setChromaLocInfoPresentFlag                          ( m_chromaLocInfoPresentFlag );
835  m_cTEncTop.setChromaSampleLocTypeTopField                       ( m_chromaSampleLocTypeTopField );
836  m_cTEncTop.setChromaSampleLocTypeBottomField                    ( m_chromaSampleLocTypeBottomField );
837  m_cTEncTop.setNeutralChromaIndicationFlag                       ( m_neutralChromaIndicationFlag );
838  m_cTEncTop.setDefaultDisplayWindow                              ( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
839  m_cTEncTop.setFrameFieldInfoPresentFlag                         ( m_frameFieldInfoPresentFlag );
840  m_cTEncTop.setPocProportionalToTimingFlag                       ( m_pocProportionalToTimingFlag );
841  m_cTEncTop.setNumTicksPocDiffOneMinus1                          ( m_numTicksPocDiffOneMinus1    );
842  m_cTEncTop.setBitstreamRestrictionFlag                          ( m_bitstreamRestrictionFlag );
843  m_cTEncTop.setTilesFixedStructureFlag                           ( m_tilesFixedStructureFlag );
844  m_cTEncTop.setMotionVectorsOverPicBoundariesFlag                ( m_motionVectorsOverPicBoundariesFlag );
845  m_cTEncTop.setMinSpatialSegmentationIdc                         ( m_minSpatialSegmentationIdc );
846  m_cTEncTop.setMaxBytesPerPicDenom                               ( m_maxBytesPerPicDenom );
847  m_cTEncTop.setMaxBitsPerMinCuDenom                              ( m_maxBitsPerMinCuDenom );
848  m_cTEncTop.setLog2MaxMvLengthHorizontal                         ( m_log2MaxMvLengthHorizontal );
849  m_cTEncTop.setLog2MaxMvLengthVertical                           ( m_log2MaxMvLengthVertical );
850  m_cTEncTop.setEfficientFieldIRAPEnabled                         ( m_bEfficientFieldIRAPEnabled );
851  m_cTEncTop.setHarmonizeGopFirstFieldCoupleEnabled               ( m_bHarmonizeGopFirstFieldCoupleEnabled );
852
853  m_cTEncTop.setSummaryOutFilename                                ( m_summaryOutFilename );
854  m_cTEncTop.setSummaryPicFilenameBase                            ( m_summaryPicFilenameBase );
855  m_cTEncTop.setSummaryVerboseness                                ( m_summaryVerboseness );
856
857#if NH_MV
858  }
859#endif
860#if NH_3D_VSO
861  if ( m_bUseVSO )
862  {
863    if ( m_uiVSOMode == 4 )
864    {
865
866      for( Int i = 1; i < m_numRepFormats; i++)
867      {
868        if ( m_iSourceWidths[0] != m_iSourceWidths[i] || m_iSourceHeights[0] != m_iSourceHeights[i] )
869        {
870          std::cout << "Enabling the RM requires equal size of all layers." << std::endl;
871          AOF( false );
872        }
873      }
874
875#if H_3D_VSO_EARLY_SKIP
876      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidths[0], m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, true, m_bVSOEarlySkip );
877#else
878      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidths[0], m_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 , true);
879#endif
880      for ( Int layer = 0; layer < m_numberOfLayers ; layer++ )
881      {
882        TEncTop* pcEncTop =  m_acTEncTopList[ layer ]; 
883        Int iViewNum      = pcEncTop->getViewIndex(); 
884        Int iContent      = pcEncTop->getIsDepth() || pcEncTop->getIsAuxDepth() ? 1 : 0; 
885        Int iNumOfModels  = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent);
886
887        Bool bUseVSO      = (iNumOfModels != 0);
888
889        pcEncTop->setUseVSO( bUseVSO );
890        pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL );
891
892        for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ )
893        {
894          Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode;
895
896          m_cRenModStrParser.getSingleModelData  ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ;
897          m_cRendererModel  .createSingleModel   ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode );
898        }           
899      }
900    }
901    else
902    {
903      AOT(true);
904    }
905  }
906#endif
907}
908
909Void TAppEncTop::xCreateLib()
910{
911#if NH_MV
912  // initialize global variables
913  initROM();
914#if NH_3D
915  initWedgeLists( true );
916#endif
917
918  for( Int layer=0; layer < m_numberOfLayers; layer++)
919  {
920    Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
921    m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer],     false, &m_inputBitDepths[repFormatIdx][0], &m_MSBExtendedBitDepths[repFormatIdx][0], &m_internalBitDepths[repFormatIdx][0] );  // read  mode
922    m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidths[repFormatIdx] - m_aiPads[repFormatIdx][0], m_iSourceHeights[repFormatIdx] - m_aiPads[repFormatIdx][1], m_InputChromaFormatIDC[repFormatIdx]);
923
924    if (m_pchReconFileList[layer])
925    {
926      m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, &m_outputBitDepths[repFormatIdx][0], &m_outputBitDepths[repFormatIdx][0], &m_internalBitDepths[repFormatIdx][0]);  // write mode
927    }
928    m_acTEncTopList[layer]->create();
929  }
930#else
931  // Video I/O
932  m_cTVideoIOYuvInputFile.open( m_inputFileName,     false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );  // read  mode
933  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_inputFileWidth, m_inputFileHeight, m_InputChromaFormatIDC);
934
935  if (!m_reconFileName.empty())
936  {
937    m_cTVideoIOYuvReconFile.open(m_reconFileName, true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth);  // write mode
938  }
939
940  // Neo Decoder
941  m_cTEncTop.create();
942#endif
943}
944
945Void TAppEncTop::xDestroyLib()
946{
947#if NH_MV
948  // destroy ROM
949  destroyROM();
950
951  for(Int layer=0; layer<m_numberOfLayers; layer++)
952  {
953    m_acTVideoIOYuvInputFileList[layer]->close();
954    m_acTVideoIOYuvReconFileList[layer]->close();
955    delete m_acTVideoIOYuvInputFileList[layer] ; 
956    m_acTVideoIOYuvInputFileList[layer] = NULL;
957    delete m_acTVideoIOYuvReconFileList[layer] ; 
958    m_acTVideoIOYuvReconFileList[layer] = NULL;
959    m_acTEncTopList[layer]->deletePicBuffer();
960    m_acTEncTopList[layer]->destroy();
961    delete m_acTEncTopList[layer] ; 
962    m_acTEncTopList[layer] = NULL;
963    delete m_cListPicYuvRec[layer] ; 
964    m_cListPicYuvRec[layer] = NULL;
965  }
966#else
967  // Video I/O
968  m_cTVideoIOYuvInputFile.close();
969  m_cTVideoIOYuvReconFile.close();
970
971  // Neo Decoder
972  m_cTEncTop.destroy();
973#endif
974}
975
976Void TAppEncTop::xInitLib(Bool isFieldCoding)
977{
978#if NH_MV
979  for(Int layer=0; layer<m_numberOfLayers; layer++)
980  {
981#if KWU_RC_MADPRED_E0227
982    m_acTEncTopList[layer]->init( isFieldCoding, this );
983#else
984    m_acTEncTopList[layer]->init( isFieldCoding );
985#endif
986  }
987#else
988  m_cTEncTop.init(isFieldCoding);
989#endif
990}
991
992// ====================================================================================================================
993// Public member functions
994// ====================================================================================================================
995
996/**
997 - create internal class
998 - initialize internal variable
999 - until the end of input YUV file, call encoding function in TEncTop class
1000 - delete allocated buffers
1001 - destroy internal class
1002 .
1003 */
1004Void TAppEncTop::encode()
1005{
1006  fstream bitstreamFile(m_bitstreamFileName.c_str(), fstream::binary | fstream::out);
1007  if (!bitstreamFile)
1008  {
1009    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_bitstreamFileName.c_str());
1010    exit(EXIT_FAILURE);
1011  }
1012
1013#if !NH_MV
1014  TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
1015#endif
1016  TComPicYuv*       pcPicYuvRec = NULL;
1017
1018  // initialize internal class & member variables
1019  xInitLibCfg();
1020  xCreateLib();
1021  xInitLib(m_isField);
1022#if NH_MV
1023  printChromaFormat();
1024#endif
1025
1026  // main encoder loop
1027#if NH_MV
1028  Bool  allEos = false;
1029  std::vector<Bool>  eos ;
1030  std::vector<Bool>  flush ; 
1031 
1032  Int gopSize    = 1;
1033  Int maxGopSize = 0;
1034  maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize()); 
1035 
1036  for(Int layer=0; layer < m_numberOfLayers; layer++ )
1037  {
1038    eos  .push_back( false );
1039    flush.push_back( false );
1040  }
1041#else
1042  Int   iNumEncoded = 0;
1043  Bool  bEos = false;
1044#endif
1045  const InputColourSpaceConversion ipCSC  =  m_inputColourSpaceConvert;
1046  const InputColourSpaceConversion snrCSC = (!m_snrInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED;
1047
1048  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
1049 
1050#if NH_MV
1051  std::vector<TComPicYuv*> picYuvOrg    ( m_numRepFormats ); 
1052  std::vector<TComPicYuv > picYuvTrueOrg( m_numRepFormats ); 
1053  for (Int d = 0; d < m_numRepFormats ; d++)
1054  { 
1055    picYuvOrg[d] = new TComPicYuv;
1056    picYuvOrg[d]   ->create( m_iSourceWidths[d], m_isField ? m_iSourceHeightOrgs[d] : m_iSourceHeights[d], m_chromaFormatIDCs[d], m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth[d], true );
1057    picYuvTrueOrg[d].create( m_iSourceWidths[d], m_isField ? m_iSourceHeightOrgs[d] : m_iSourceHeights[d], m_chromaFormatIDCs[d], m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth[d], true );
1058  }
1059#else
1060  TComPicYuv cPicYuvTrueOrg;
1061
1062  // allocate original YUV buffer
1063  if( m_isField )
1064  {
1065    pcPicYuvOrg->create  ( m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
1066    cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true);
1067  }
1068  else
1069  {
1070    pcPicYuvOrg->create  ( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
1071    cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
1072  }
1073#endif
1074
1075
1076#if EXTENSION_360_VIDEO
1077  TExt360AppEncTop           ext360(*this, m_cTEncTop.getGOPEncoder()->getExt360Data(), *(m_cTEncTop.getGOPEncoder()), *pcPicYuvOrg);
1078#endif
1079
1080#if NH_MV
1081  while ( (m_targetEncLayerIdList.size() != 0 ) && !allEos )
1082  {
1083    for(Int layer=0; layer < m_numberOfLayers; layer++ )
1084    {
1085      Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
1086
1087      TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ repFormatIdx ];
1088      TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ repFormatIdx ];
1089
1090      if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) ))
1091      {
1092        continue; 
1093      }
1094
1095      Int frmCnt = 0;
1096      while ( !eos[layer] && !(frmCnt == gopSize))
1097      {
1098        // get buffers
1099        xGetBuffer(pcPicYuvRec, layer);
1100
1101        // read input YUV file       
1102        m_acTVideoIOYuvInputFileList[layer]->read      ( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, &m_aiPads[repFormatIdx][0], m_InputChromaFormatIDC[repFormatIdx] );
1103        m_acTEncTopList             [layer]->initNewPic( pcPicYuvOrg );
1104
1105        // increase number of received frames
1106        m_frameRcvd[layer]++;
1107       
1108        frmCnt++;
1109
1110        eos[layer] = (m_frameRcvd[layer] == m_framesToBeEncoded);
1111        allEos = allEos||eos[layer];
1112
1113        // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
1114        if (m_acTVideoIOYuvInputFileList[layer]->isEof())
1115        {
1116          flush          [layer] = true;
1117          eos            [layer] = true;
1118          m_frameRcvd    [layer]--;
1119          m_acTEncTopList[layer]->setFramesToBeEncoded(m_frameRcvd[layer]);
1120        }
1121      }
1122    }
1123    for ( Int gopId=0; gopId < gopSize; gopId++ )
1124    {
1125#if NH_3D_VSO || NH_3D
1126      UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId );
1127      if ( iNextPoc < m_framesToBeEncoded )
1128      {
1129        m_cCameraData.update( iNextPoc );
1130      }
1131#endif
1132      for(Int layer=0; layer < m_numberOfLayers; layer++ )
1133      {
1134        Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
1135#if NH_MV
1136        TComPicYuv* pcPicYuvOrg    =  picYuvOrg    [ repFormatIdx ];
1137        TComPicYuv& cPicYuvTrueOrg =  picYuvTrueOrg[ repFormatIdx ];
1138#endif
1139        if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) ))
1140        {
1141          continue; 
1142        }
1143
1144#if NH_3D_VSO       
1145          if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded )
1146          {
1147            m_cCameraData.setDispCoeff( iNextPoc, m_acTEncTopList[layer]->getViewIndex() );
1148            m_acTEncTopList[layer]  ->setDispCoeff( m_cCameraData.getDispCoeff() );
1149          }
1150#endif
1151
1152        Int   iNumEncoded = 0;
1153
1154        // call encoding function for one frame                               
1155        m_acTEncTopList[layer]->encode( eos[layer], flush[layer] ? 0 : pcPicYuvOrg, flush[layer] ? 0 : &cPicYuvTrueOrg, snrCSC, *m_cListPicYuvRec[layer], outputAccessUnits, iNumEncoded, gopId );       
1156        xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, layer);
1157        outputAccessUnits.clear();
1158      }
1159    }
1160
1161    gopSize = maxGopSize;
1162  }
1163  for(Int layer=0; layer < m_numberOfLayers; layer++ )
1164  {
1165    if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) ))
1166    {
1167      continue; 
1168    }   
1169    m_acTEncTopList[layer]->printSummary(m_isField);
1170  }
1171#else
1172
1173  while ( !bEos )
1174  {
1175    // get buffers
1176    xGetBuffer(pcPicYuvRec);
1177    // read input YUV file
1178#if EXTENSION_360_VIDEO
1179    if (ext360.isEnabled())
1180    {
1181      ext360.read(m_cTVideoIOYuvInputFile, *pcPicYuvOrg, cPicYuvTrueOrg, ipCSC);
1182    }
1183    else
1184    {
1185      m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
1186    }
1187#else
1188    m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
1189#endif
1190
1191    // increase number of received frames
1192    m_iFrameRcvd++;
1193
1194    bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) );
1195
1196    Bool flush = 0;
1197    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
1198    if (m_cTVideoIOYuvInputFile.isEof())
1199    {
1200      flush = true;
1201      bEos = true;
1202      m_iFrameRcvd--;
1203      m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd);
1204    }
1205
1206    // call encoding function for one frame
1207    if ( m_isField )
1208    {
1209      m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst );
1210    }
1211    else
1212    {
1213      m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
1214    }
1215
1216    // write bistream to file if necessary
1217    if ( iNumEncoded > 0 )
1218    {
1219      xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits);
1220      outputAccessUnits.clear();
1221    }
1222    // temporally skip frames
1223    if( m_temporalSubsampleRatio > 1 )
1224    {
1225      m_cTVideoIOYuvInputFile.skipFrames(m_temporalSubsampleRatio-1, m_inputFileWidth, m_inputFileHeight, m_InputChromaFormatIDC);
1226    }
1227  }
1228
1229  m_cTEncTop.printSummary(m_isField);
1230#endif
1231
1232#if NH_MV
1233  // delete original YUV buffer
1234  for (Int d = 0; d < m_numRepFormats; d++)
1235  {
1236    picYuvOrg[d]->destroy();
1237    delete picYuvOrg[d];
1238    picYuvOrg[d] = NULL;
1239
1240    picYuvTrueOrg[d].destroy();
1241  }
1242#else
1243  // delete original YUV buffer
1244  pcPicYuvOrg->destroy();
1245  delete pcPicYuvOrg;
1246  pcPicYuvOrg = NULL;
1247#endif
1248
1249#if !NH_MV
1250  // delete used buffers in encoder class
1251  m_cTEncTop.deletePicBuffer();
1252  cPicYuvTrueOrg.destroy();
1253#endif
1254
1255  // delete buffers & classes
1256  xDeleteBuffer();
1257  xDestroyLib();
1258
1259  printRateSummary();
1260
1261#if NH_3D_REN_MAX_DEV_OUT
1262  Double dMaxDispDiff = m_cCameraData.getMaxShiftDeviation(); 
1263
1264  if ( !(dMaxDispDiff < 0) )
1265  { 
1266    printf("\n Max. possible shift error: %12.3f samples.\n", dMaxDispDiff );
1267  }
1268#endif
1269
1270  return;
1271}
1272
1273// ====================================================================================================================
1274// Protected member functions
1275// ====================================================================================================================
1276
1277/**
1278 - application has picture buffer list with size of GOP
1279 - picture buffer list acts as ring buffer
1280 - end of the list has the latest picture
1281 .
1282 */
1283#if NH_MV
1284Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
1285#else
1286Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec)
1287#endif
1288{
1289  assert( m_iGOPSize > 0 );
1290
1291  // org. buffer
1292#if NH_MV
1293  Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
1294
1295  if ( m_cListPicYuvRec[layer]->size() == (UInt)m_iGOPSize )
1296  {
1297    rpcPicYuvRec = m_cListPicYuvRec[layer]->popFront();
1298#else
1299  if ( m_cListPicYuvRec.size() >= (UInt)m_iGOPSize ) // buffer will be 1 element longer when using field coding, to maintain first field whilst processing second.
1300  {
1301    rpcPicYuvRec = m_cListPicYuvRec.popFront();
1302#endif
1303  }
1304  else
1305  {
1306    rpcPicYuvRec = new TComPicYuv;
1307#if NH_MV
1308    rpcPicYuvRec->create( m_iSourceWidths[ repFormatIdx ], m_iSourceHeights[ repFormatIdx ], m_chromaFormatIDCs[ repFormatIdx ], m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth[repFormatIdx], true );
1309#else
1310    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
1311#endif
1312
1313  }
1314#if NH_MV
1315  m_cListPicYuvRec[layer]->pushBack( rpcPicYuvRec );
1316#else
1317  m_cListPicYuvRec.pushBack( rpcPicYuvRec );
1318#endif
1319}
1320
1321Void TAppEncTop::xDeleteBuffer( )
1322{
1323#if NH_MV
1324  for(Int layer=0; layer<m_cListPicYuvRec.size(); layer++)
1325  {
1326    if(m_cListPicYuvRec[layer])
1327    {
1328      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec[layer]->begin();
1329      Int iSize = Int( m_cListPicYuvRec[layer]->size() );
1330#else
1331  TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec.begin();
1332
1333  Int iSize = Int( m_cListPicYuvRec.size() );
1334#endif
1335
1336  for ( Int i = 0; i < iSize; i++ )
1337  {
1338    TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
1339    pcPicYuvRec->destroy();
1340    delete pcPicYuvRec; pcPicYuvRec = NULL;
1341  }
1342#if NH_MV
1343}
1344  }
1345#endif 
1346
1347}
1348
1349/**
1350  Write access units to output file.
1351  \param bitstreamFile  target bitstream file
1352  \param iNumEncoded    number of encoded frames
1353  \param accessUnits    list of access units to be written
1354 */
1355#if NH_MV
1356Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerIdx)
1357#else
1358Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
1359#endif
1360{
1361  const InputColourSpaceConversion ipCSC = (!m_outputInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED;
1362
1363  if (m_isField)
1364  {
1365    //Reinterlace fields
1366    Int i;
1367#if NH_MV
1368    if( iNumEncoded > 0 )
1369    {
1370      TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec[layerIdx]->end();
1371#else
1372    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
1373    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
1374#endif
1375
1376    for ( i = 0; i < iNumEncoded; i++ )
1377    {
1378      --iterPicYuvRec;
1379    }
1380
1381    for ( i = 0; i < iNumEncoded/2; i++ )
1382    {
1383      TComPicYuv*  pcPicYuvRecTop  = *(iterPicYuvRec++);
1384      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
1385
1386#if NH_MV
1387      if (m_pchReconFileList[layerIdx])
1388      {
1389        Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layerIdx];
1390#if NH_3D
1391        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx], m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT, m_isTopFieldFirst );
1392#else
1393        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx], NUM_CHROMA_FORMAT, m_isTopFieldFirst );
1394#endif
1395      }
1396    }
1397  }
1398
1399  if( ! accessUnits.empty() )
1400  {
1401    list<AccessUnit>::iterator aUIter;
1402    for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ )
1403    {
1404      const vector<UInt>& stats = writeAnnexB(bitstreamFile, *aUIter);
1405      rateStatsAccum(*aUIter, stats);
1406    }
1407  }
1408#else
1409      if (!m_reconFileName.empty())
1410      {
1411        m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, NUM_CHROMA_FORMAT, m_isTopFieldFirst );
1412      }
1413
1414      const AccessUnit& auTop = *(iterBitstream++);
1415      const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
1416      rateStatsAccum(auTop, statsTop);
1417
1418      const AccessUnit& auBottom = *(iterBitstream++);
1419      const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom);
1420      rateStatsAccum(auBottom, statsBottom);
1421    }
1422#endif
1423  }
1424  else
1425  {
1426    Int i;
1427#if NH_MV
1428    if( iNumEncoded > 0 )
1429    {
1430      TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec[layerIdx]->end();
1431#else
1432    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
1433    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
1434#endif
1435
1436    for ( i = 0; i < iNumEncoded; i++ )
1437    {
1438      --iterPicYuvRec;
1439    }
1440
1441    for ( i = 0; i < iNumEncoded; i++ )
1442    {
1443      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
1444#if NH_MV
1445      Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layerIdx];
1446      if (m_pchReconFileList[layerIdx])
1447      {
1448#if NH_3D
1449        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx], m_depth420OutputFlag && m_depthFlag[layerIdx ] ? CHROMA_420 : NUM_CHROMA_FORMAT  );
1450#else
1451        m_acTVideoIOYuvReconFileList[layerIdx]->write( pcPicYuvRec, ipCSC, m_confWinLefts[repFormatIdx], m_confWinRights[repFormatIdx], m_confWinTops[repFormatIdx], m_confWinBottoms[repFormatIdx] );
1452#endif
1453
1454      }   
1455    }
1456  }
1457  if( ! accessUnits.empty() )
1458  {
1459    list<AccessUnit>::iterator aUIter;
1460    for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ )
1461    {
1462      const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter);
1463      rateStatsAccum(*aUIter, stats);
1464    }
1465  }
1466#else
1467      if (!m_reconFileName.empty())
1468      {
1469        m_cTVideoIOYuvReconFile.write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom,
1470            NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range  );
1471      }
1472
1473      const AccessUnit& au = *(iterBitstream++);
1474      const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
1475      rateStatsAccum(au, stats);
1476    }
1477#endif
1478  }
1479}
1480
1481/**
1482 *
1483 */
1484Void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
1485{
1486  AccessUnit::const_iterator it_au = au.begin();
1487  vector<UInt>::const_iterator it_stats = annexBsizes.begin();
1488
1489  for (; it_au != au.end(); it_au++, it_stats++)
1490  {
1491    switch ((*it_au)->m_nalUnitType)
1492    {
1493    case NAL_UNIT_CODED_SLICE_TRAIL_R:
1494    case NAL_UNIT_CODED_SLICE_TRAIL_N:
1495    case NAL_UNIT_CODED_SLICE_TSA_R:
1496    case NAL_UNIT_CODED_SLICE_TSA_N:
1497    case NAL_UNIT_CODED_SLICE_STSA_R:
1498    case NAL_UNIT_CODED_SLICE_STSA_N:
1499    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
1500    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
1501    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
1502    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
1503    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
1504    case NAL_UNIT_CODED_SLICE_CRA:
1505    case NAL_UNIT_CODED_SLICE_RADL_N:
1506    case NAL_UNIT_CODED_SLICE_RADL_R:
1507    case NAL_UNIT_CODED_SLICE_RASL_N:
1508    case NAL_UNIT_CODED_SLICE_RASL_R:
1509    case NAL_UNIT_VPS:
1510    case NAL_UNIT_SPS:
1511    case NAL_UNIT_PPS:
1512      m_essentialBytes += *it_stats;
1513      break;
1514    default:
1515      break;
1516    }
1517
1518    m_totalBytes += *it_stats;
1519  }
1520}
1521
1522Void TAppEncTop::printRateSummary()
1523{
1524#if NH_MV
1525  Double time = (Double) m_frameRcvd[0] / m_iFrameRate * m_temporalSubsampleRatio;
1526  printf("\n");
1527#else
1528  Double time = (Double) m_iFrameRcvd / m_iFrameRate * m_temporalSubsampleRatio;
1529#endif
1530  printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
1531  if (m_summaryVerboseness > 0)
1532  {
1533  printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time);
1534  }
1535}
1536
1537Void TAppEncTop::printChromaFormat()
1538{
1539 
1540#if NH_MV   
1541  std::cout << "Input ChromaFormatIDC             : ";
1542  for (Int i = 0; i < m_numRepFormats; i++)
1543  {
1544   
1545   
1546    switch (m_InputChromaFormatIDC[i])
1547#else
1548  std::cout << std::setw(43) << "Input ChromaFormatIDC = ";
1549  switch (m_InputChromaFormatIDC)
1550#endif
1551  {
1552  case CHROMA_400:  std::cout << "  4:0:0"; break;
1553  case CHROMA_420:  std::cout << "  4:2:0"; break;
1554  case CHROMA_422:  std::cout << "  4:2:2"; break;
1555  case CHROMA_444:  std::cout << "  4:4:4"; break;
1556  default:
1557    std::cerr << "Invalid";
1558    exit(1);
1559  }
1560#if NH_MV
1561  std::cout << " ";
1562}
1563#endif
1564
1565  std::cout << std::endl;
1566
1567#if NH_MV
1568  std::cout << "Output (internal) ChromaFormatIDC : ";
1569  for (Int i = 0; i < m_numRepFormats; i++)
1570  {
1571   
1572    switch ( m_chromaFormatIDCs[i] )
1573#else
1574    std::cout << std::setw(43) << "Output (internal) ChromaFormatIDC = ";
1575    switch (m_cTEncTop.getChromaFormatIdc())
1576#endif
1577    {
1578    case CHROMA_400:  std::cout << "  4:0:0"; break;
1579    case CHROMA_420:  std::cout << "  4:2:0"; break;
1580    case CHROMA_422:  std::cout << "  4:2:2"; break;
1581    case CHROMA_444:  std::cout << "  4:4:4"; break;
1582    default:
1583      std::cerr << "Invalid";
1584      exit(1);
1585    }
1586#if NH_MV
1587    std::cout << " ";
1588  }
1589#endif
1590  std::cout << "\n" << std::endl;
1591}
1592
1593#if NH_3D
1594Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt)
1595{
1596  Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[layer];
1597
1598  TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
1599  TComPicYuv*       pcDepthPicYuvTrueOrg = new TComPicYuv;
1600  // allocate original YUV buffer
1601  pcDepthPicYuvOrg->create( m_iSourceWidths[ repFormatIdx ], m_iSourceHeights[ repFormatIdx ], CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight    , m_uiMaxTotalCUDepth[repFormatIdx], false );
1602  pcDepthPicYuvTrueOrg->create( m_iSourceWidths[ repFormatIdx ], m_iSourceHeights[ repFormatIdx ], CHROMA_420, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth[repFormatIdx], false );
1603 
1604  TVideoIOYuv* depthVideoFile = new TVideoIOYuv;
1605 
1606  UInt uiMaxDepthValue = ((1 << m_inputBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA])-1);
1607 
1608  std::vector<Bool> abValidDepths(256, false);
1609 
1610  depthVideoFile->open( m_pchInputFileList[layer], false, &m_inputBitDepths[repFormatIdx][0], &m_MSBExtendedBitDepths[repFormatIdx][0], &m_internalBitDepths[repFormatIdx][0] );
1611 
1612  Int iHeight   = pcDepthPicYuvOrg->getHeight(COMPONENT_Y);
1613  Int iWidth    = pcDepthPicYuvOrg->getWidth(COMPONENT_Y);
1614  Int iStride   = pcDepthPicYuvOrg->getStride(COMPONENT_Y);
1615 
1616  Pel* pInDM    = pcDepthPicYuvOrg->getAddr(COMPONENT_Y);
1617 
1618 
1619  for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ )
1620  {
1621    depthVideoFile->read( pcDepthPicYuvOrg, pcDepthPicYuvTrueOrg, IPCOLOURSPACE_UNCHANGED, &m_aiPads[repFormatIdx][0], m_InputChromaFormatIDC[repFormatIdx], m_bClipInputVideoToRec709Range );
1622   
1623    // check all pixel values
1624    for (Int i=0; i<iHeight; i++)
1625    {
1626      Int rowOffset = i*iStride;
1627     
1628      for (Int j=0; j<iWidth; j++)
1629      {
1630        Pel depthValue = pInDM[rowOffset+j];
1631        abValidDepths[depthValue] = true;
1632      }
1633    }
1634  }
1635 
1636  depthVideoFile->close();
1637  delete depthVideoFile; 
1638 
1639  pcDepthPicYuvOrg->destroy();
1640  delete pcDepthPicYuvOrg;
1641  pcDepthPicYuvTrueOrg->destroy();
1642  delete pcDepthPicYuvTrueOrg;
1643 
1644  // convert boolean array to idx2Depth LUT
1645  std::vector<Int> aiIdx2DepthValue(256, 0);
1646  Int iNumDepthValues = 0;
1647  for(Int p=0; p<=uiMaxDepthValue; p++)
1648  {
1649    if( abValidDepths[p] == true)
1650    {
1651      aiIdx2DepthValue[iNumDepthValues++] = p;
1652    }
1653  }
1654 
1655  if( uiNumFrames == 0 || gCeilLog2(iNumDepthValues) == m_inputBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA] )
1656  {
1657    dlt->setUseDLTFlag(layer, false);
1658  }
1659 
1660  // assign LUT
1661  if( dlt->getUseDLTFlag(layer) )
1662  {
1663    dlt->setDepthLUTs(layer, aiIdx2DepthValue, iNumDepthValues);
1664  }
1665}
1666#endif
1667
1668#if NH_MV
1669Void TAppEncTop::xSetDimensionIdAndLength( TComVPS& vps )
1670{   
1671  vps.setScalabilityMaskFlag( m_scalabilityMask ); 
1672  for( Int dim = 0; dim < m_dimIds.size(); dim++ )
1673  {
1674    vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] );
1675    for( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ )
1676    {       
1677      vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] );       
1678    } 
1679  }
1680
1681  vps.initNumViews(); 
1682  Int maxViewId = xGetMax( m_viewId ); 
1683
1684  Int viewIdLen = gCeilLog2( maxViewId + 1 ); 
1685  const Int maxViewIdLen = ( 1 << 4 ) - 1; 
1686  assert( viewIdLen <= maxViewIdLen ); 
1687  vps.setViewIdLen( viewIdLen ); 
1688  for (Int i = 0; i < m_iNumberOfViews; i++)
1689  {
1690    vps.setViewIdVal( i, m_viewId[ i] ); 
1691  }
1692
1693  assert( m_iNumberOfViews == vps.getNumViews() ); 
1694
1695
1696#if NH_3D
1697  vps.initViewCompLayer( ); 
1698#endif
1699}
1700
1701Void TAppEncTop::xSetDependencies( TComVPS& vps )
1702{
1703  // Direct dependency flags + dependency types
1704  for( Int depLayer = 1; depLayer < MAX_NUM_LAYERS; depLayer++ )
1705  {
1706    for( Int refLayer = 0; refLayer < MAX_NUM_LAYERS; refLayer++ )
1707    {
1708      vps.setDirectDependencyFlag( depLayer, refLayer, false); 
1709      vps.setDirectDependencyType( depLayer, refLayer,    -1 ); 
1710    }
1711  }
1712
1713  Int  defaultDirectDependencyType = -1; 
1714  Bool defaultDirectDependencyFlag = false; 
1715
1716  Int directDepTypeLenMinus2 = 0; 
1717  for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ )
1718  {
1719    Int numRefLayers = (Int) m_directRefLayers[depLayer].size(); 
1720    assert(  numRefLayers == (Int) m_dependencyTypes[depLayer].size() ); 
1721    for( Int i = 0; i < numRefLayers; i++ )
1722    {
1723      Int refLayer = m_directRefLayers[depLayer][i]; 
1724      vps.setDirectDependencyFlag( depLayer, refLayer, true); 
1725      Int curDirectDependencyType = m_dependencyTypes[depLayer][i]; 
1726      directDepTypeLenMinus2 = std::max( directDepTypeLenMinus2, gCeilLog2( curDirectDependencyType + 1  ) - 2 ); 
1727      if ( defaultDirectDependencyType != -1 )   
1728      {
1729        defaultDirectDependencyFlag = defaultDirectDependencyFlag && (curDirectDependencyType == defaultDirectDependencyType );         
1730      }
1731      else
1732      {
1733        defaultDirectDependencyType = curDirectDependencyType; 
1734        defaultDirectDependencyFlag = true; 
1735      }
1736     
1737      vps.setDirectDependencyType( depLayer, refLayer, curDirectDependencyType);       
1738    }
1739  }
1740
1741  vps.setDefaultDirectDependencyFlag( defaultDirectDependencyFlag );       
1742  vps.setDefaultDirectDependencyType( defaultDirectDependencyFlag ? defaultDirectDependencyType : -1 );       
1743
1744  assert( directDepTypeLenMinus2 <= 1 ); 
1745  vps.setDirectDepTypeLenMinus2( directDepTypeLenMinus2 ); 
1746
1747
1748  vps.setRefLayers(); 
1749
1750  // Max sub layers, + presence flag
1751  Bool subLayersMaxMinus1PresentFlag = false; 
1752  for (Int curLayerIdInVps = 0; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++ )
1753  {   
1754    Int curSubLayersMaxMinus1 = 0; 
1755    for( Int i = 0; i < getGOPSize(); i++ ) 
1756    {
1757      GOPEntry geCur =  xGetGopEntries(curLayerIdInVps)[i];
1758      curSubLayersMaxMinus1 = std::max( curSubLayersMaxMinus1, geCur.m_temporalId ); 
1759    } 
1760
1761    vps.setSubLayersVpsMaxMinus1( curLayerIdInVps, curSubLayersMaxMinus1 ); 
1762    subLayersMaxMinus1PresentFlag = subLayersMaxMinus1PresentFlag || ( curSubLayersMaxMinus1 != vps.getMaxSubLayersMinus1() );
1763  }
1764
1765  vps.setVpsSubLayersMaxMinus1PresentFlag( subLayersMaxMinus1PresentFlag ); 
1766
1767  // Max temporal id for inter layer reference pictures
1768  for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++)
1769  {
1770    Int refLayerIdInNuh = vps.getLayerIdInNuh( refLayerIdInVps );
1771    for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++)
1772    {
1773      Int curLayerIdInNuh = vps.getLayerIdInNuh( curLayerIdInVps );     
1774      Int maxTid = -1; 
1775#if NH_3D
1776      if ( vps.getDirectDependencyFlag( curLayerIdInVps, refLayerIdInVps ) )
1777      {
1778        if ( m_depthFlag[ curLayerIdInVps] == m_depthFlag[ refLayerIdInVps ] )
1779        {
1780#endif
1781          for( Int i = 0; i < ( getGOPSize() + 1); i++ ) 
1782          {       
1783            GOPEntry geCur =  xGetGopEntries(curLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
1784            GOPEntry geRef =  xGetGopEntries(refLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
1785            for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++)
1786            {
1787#if NH_3D
1788              if ( vps.getIdRefListLayer( curLayerIdInNuh, geCur.m_interLayerPredLayerIdc[ j ] ) == refLayerIdInNuh )
1789#else
1790              if ( vps.getIdDirectRefLayer( curLayerIdInNuh, geCur.m_interLayerPredLayerIdc[ j ] ) == refLayerIdInNuh )
1791#endif
1792              {
1793                Bool refLayerZero   = ( i == getGOPSize() ) && ( refLayerIdInVps == 0 );
1794                maxTid = std::max( maxTid, refLayerZero ? 0 : geRef.m_temporalId ); 
1795              }
1796            }
1797          }             
1798#if NH_3D
1799        }
1800        else
1801        {       
1802          if( m_depthFlag[ curLayerIdInVps ] && ( m_mpiFlag|| m_qtPredFlag || m_intraContourFlag ) ) 
1803          {         
1804            Int nuhLayerIdTex = vps.getLayerIdInNuh( vps.getViewIndex( curLayerIdInNuh ), false, 0 ); 
1805            if ( nuhLayerIdTex == refLayerIdInNuh )
1806            {
1807              for( Int i = 0; i < ( getGOPSize() + 1); i++ ) 
1808              {       
1809                GOPEntry geCur =  xGetGopEntries(curLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
1810                GOPEntry geRef =  xGetGopEntries(refLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
1811                if ( geCur.m_interCompPredFlag )
1812                {
1813                  Bool refLayerZero   = ( i == getGOPSize() ) && ( refLayerIdInVps == 0 );
1814                  maxTid = std::max( maxTid, refLayerZero ? 0 : geRef.m_temporalId ); 
1815                }
1816              }
1817            }
1818          }
1819          if( !m_depthFlag[ curLayerIdInVps ] && vps.getNumRefListLayers( curLayerIdInNuh) > 0  && ( m_depthRefinementFlag || m_viewSynthesisPredFlag || m_depthBasedBlkPartFlag ) ) 
1820          {             
1821            for( Int i = 0; i < ( getGOPSize() + 1); i++ ) 
1822            {       
1823              GOPEntry geCur =  xGetGopEntries(curLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
1824              GOPEntry geRef =  xGetGopEntries(refLayerIdInVps)[( i < getGOPSize()  ? i : MAX_GOP )];
1825
1826              if ( geCur.m_interCompPredFlag )
1827              {
1828                for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++ )
1829                {
1830                  Int nuhLayerIdDep = vps.getLayerIdInNuh( vps.getViewIndex( vps.getIdRefListLayer( curLayerIdInNuh, geCur.m_interLayerPredLayerIdc[j] ) ), true, 0 ); 
1831                  if ( nuhLayerIdDep == refLayerIdInNuh )
1832                  {
1833                    Bool refLayerZero   = ( i == getGOPSize() ) && ( refLayerIdInVps == 0 );
1834                    maxTid = std::max( maxTid, refLayerZero ? 0 : geRef.m_temporalId ); 
1835                  }
1836                }
1837              }
1838            }
1839          }       
1840        }
1841      } // if ( vps.getDirectDependencyFlag( curLayerIdInVps, refLayerIdInVps ) )
1842      vps.setMaxTidIlRefPicsPlus1( refLayerIdInVps, curLayerIdInVps, maxTid + 1 );
1843#endif
1844    }  // Loop curLayerIdInVps
1845  } // Loop refLayerIdInVps
1846
1847  // Max temporal id for inter layer reference pictures presence flag
1848  Bool maxTidRefPresentFlag = false;   
1849  for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++)
1850  {
1851    for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++)
1852    {
1853        maxTidRefPresentFlag = maxTidRefPresentFlag || ( vps.getMaxTidIlRefPicsPlus1( refLayerIdInVps, curLayerIdInVps ) != 7 );   
1854    }
1855  }
1856  vps.setMaxTidRefPresentFlag( maxTidRefPresentFlag );
1857
1858
1859  // Max one active ref layer flag
1860  Bool maxOneActiveRefLayerFlag = true; 
1861  for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers && maxOneActiveRefLayerFlag; layerIdInVps++)
1862  {
1863    for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ ) 
1864    {       
1865      GOPEntry ge =  xGetGopEntries(layerIdInVps)[ ( i < getGOPSize()  ? i : MAX_GOP ) ]; 
1866      maxOneActiveRefLayerFlag =  maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1); 
1867    }           
1868  }
1869
1870  vps.setMaxOneActiveRefLayerFlag( maxOneActiveRefLayerFlag );
1871 
1872  // Poc Lsb Not Present Flag
1873  for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers; layerIdInVps++)
1874  {
1875    if ( m_directRefLayers[ layerIdInVps ].size() == 0 ) 
1876    {   
1877      vps.setPocLsbNotPresentFlag( layerIdInVps,  true ); 
1878    }
1879  } 
1880 
1881  // All Ref layers active flag
1882  Bool allRefLayersActiveFlag = true; 
1883  for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers && allRefLayersActiveFlag; layerIdInVps++)
1884  {   
1885    Int layerIdInNuh = vps.getLayerIdInNuh( layerIdInVps ); 
1886    for( Int i = 0; i < ( getGOPSize() + 1) && allRefLayersActiveFlag; i++ ) 
1887    {       
1888      GOPEntry ge =  xGetGopEntries(layerIdInVps)[ ( i < getGOPSize()  ? i : MAX_GOP ) ]; 
1889      Int tId = ge.m_temporalId;  // Should be equal for all layers.
1890     
1891      // check if all reference layers when allRefLayerActiveFlag is equal to 1 are reference layer pictures specified in the gop entry
1892#if NH_3D
1893      for (Int k = 0; k < vps.getNumRefListLayers( layerIdInNuh ) && allRefLayersActiveFlag; k++ )
1894      {
1895        Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdRefListLayer( layerIdInNuh , k ) ); 
1896#else
1897      for (Int k = 0; k < vps.getNumDirectRefLayers( layerIdInNuh ) && allRefLayersActiveFlag; k++ )
1898      {
1899        Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdDirectRefLayer( layerIdInNuh , k ) ); 
1900#endif
1901        if ( vps.getSubLayersVpsMaxMinus1(refLayerIdInVps) >= tId  && ( tId == 0 || vps.getMaxTidIlRefPicsPlus1(refLayerIdInVps,layerIdInVps) > tId )  )
1902        {
1903          Bool gopEntryFoundFlag = false; 
1904          for( Int l = 0; l < ge.m_numActiveRefLayerPics && !gopEntryFoundFlag; l++ )
1905          {
1906            gopEntryFoundFlag = gopEntryFoundFlag || ( ge.m_interLayerPredLayerIdc[l] == k ); 
1907          }         
1908          allRefLayersActiveFlag = allRefLayersActiveFlag && gopEntryFoundFlag; 
1909        }       
1910      }
1911
1912      // check if all inter layer reference pictures specified in the gop entry are valid reference layer pictures when allRefLayerActiveFlag is equal to 1
1913      // (Should actually always be true)
1914      Bool maxTidIlRefAndSubLayerMaxValidFlag = true; 
1915      for( Int l = 0; l < ge.m_numActiveRefLayerPics; l++ )
1916      {   
1917        Bool referenceLayerFoundFlag = false; 
1918#if NH_3D
1919        for (Int k = 0; k < vps.getNumRefListLayers( layerIdInNuh ); k++ )
1920        {
1921          Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdRefListLayer( layerIdInNuh, k) );
1922#else
1923        for (Int k = 0; k < vps.getNumDirectRefLayers( layerIdInNuh ); k++ )
1924        {
1925          Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdDirectRefLayer( layerIdInNuh, k) );
1926#endif
1927          if ( vps.getSubLayersVpsMaxMinus1(refLayerIdInVps) >= tId  && ( tId == 0 || vps.getMaxTidIlRefPicsPlus1(refLayerIdInVps,layerIdInVps) > tId )  )
1928          {         
1929            referenceLayerFoundFlag = referenceLayerFoundFlag || ( ge.m_interLayerPredLayerIdc[l] == k ); 
1930          }         
1931        }
1932       maxTidIlRefAndSubLayerMaxValidFlag = maxTidIlRefAndSubLayerMaxValidFlag && referenceLayerFoundFlag; 
1933      }
1934      assert ( maxTidIlRefAndSubLayerMaxValidFlag ); // Something wrong with MaxTidIlRefPicsPlus1 or SubLayersVpsMaxMinus1
1935    }           
1936  }
1937
1938  vps.setAllRefLayersActiveFlag( allRefLayersActiveFlag );
1939}; 
1940
1941
1942Void TAppEncTop::xSetTimingInfo( TComVPS& vps )
1943{
1944  vps.getTimingInfo()->setTimingInfoPresentFlag( false );
1945}
1946
1947Void TAppEncTop::xSetHrdParameters( TComVPS& vps )
1948{
1949  vps.createHrdParamBuffer();
1950  for( Int i = 0; i < vps.getNumHrdParameters(); i++ )
1951  {
1952    vps.setHrdOpSetIdx( 0, i );
1953    vps.setCprmsPresentFlag( false, i );
1954  }
1955}
1956
1957Void TAppEncTop::xSetLayerIds( TComVPS& vps )
1958{
1959  vps.setSplittingFlag     ( m_splittingFlag );
1960
1961  Bool nuhLayerIdPresentFlag = false; 
1962 
1963
1964  vps.setVpsMaxLayerId( xGetMax( m_layerIdInNuh ) ); 
1965
1966  for (Int i = 0; i < m_numberOfLayers; i++)
1967  {
1968    nuhLayerIdPresentFlag = nuhLayerIdPresentFlag || ( m_layerIdInNuh[i] != i ); 
1969  }
1970
1971  vps.setVpsNuhLayerIdPresentFlag( nuhLayerIdPresentFlag ); 
1972
1973  for (Int layer = 0; layer < m_numberOfLayers; layer++ )
1974  {
1975    vps.setLayerIdInNuh( layer, nuhLayerIdPresentFlag ? m_layerIdInNuh[ layer ] : layer ); 
1976    vps.setLayerIdInVps( vps.getLayerIdInNuh( layer ), layer ); 
1977  }
1978}
1979
1980Int TAppEncTop::xGetMax( std::vector<Int>& vec )
1981{
1982  Int maxVec = 0; 
1983  for ( Int i = 0; i < vec.size(); i++)   
1984  {
1985    maxVec = max( vec[i], maxVec ); 
1986  }
1987  return maxVec;
1988}
1989
1990Void TAppEncTop::xSetProfileTierLevel( TComVPS& vps )
1991{ 
1992
1993  xDeriveProfAndConstrFlags( vps ); 
1994  xCheckProfiles           ( vps );
1995  xPrintProfiles           (  );
1996 
1997  // SET PTL
1998  assert( m_profiles.size() == m_level.size() && m_profiles.size() == m_levelTier.size() ); 
1999  vps.setVpsNumProfileTierLevelMinus1( (Int) m_profiles.size() - 1 );
2000  for ( Int ptlIdx = 0; ptlIdx <= vps.getVpsNumProfileTierLevelMinus1(); ptlIdx++ )
2001  {
2002    if ( ptlIdx > 1 )
2003    {
2004      Bool vpsProfilePresentFlag = 
2005           ( m_profiles                [ptlIdx ] != m_profiles                [ptlIdx - 1] )
2006        || ( m_progressiveSourceFlags  [ptlIdx ] != m_progressiveSourceFlags  [ptlIdx - 1] )
2007        || ( m_interlacedSourceFlags   [ptlIdx ] != m_interlacedSourceFlags   [ptlIdx - 1] )
2008        || ( m_nonPackedConstraintFlags[ptlIdx ] != m_nonPackedConstraintFlags[ptlIdx - 1] )
2009        || ( m_frameOnlyConstraintFlags[ptlIdx ] != m_frameOnlyConstraintFlags[ptlIdx - 1] )
2010        || ( m_inblFlag                [ptlIdx ] != m_inblFlag                [ptlIdx - 1] );
2011
2012     
2013      if ( m_profiles[ ptlIdx ] >= 4 && m_profiles[ ptlIdx ] <= 7 )
2014      {
2015
2016        vpsProfilePresentFlag = vpsProfilePresentFlag
2017          || ( m_profiles                [ptlIdx ] != m_profiles                [ptlIdx - 1] )
2018          || ( m_progressiveSourceFlags  [ptlIdx ] != m_progressiveSourceFlags  [ptlIdx - 1] )
2019          || ( m_interlacedSourceFlags   [ptlIdx ] != m_interlacedSourceFlags   [ptlIdx - 1] )
2020          || ( m_nonPackedConstraintFlags[ptlIdx ] != m_nonPackedConstraintFlags[ptlIdx - 1] )
2021          || ( m_frameOnlyConstraintFlags[ptlIdx ] != m_frameOnlyConstraintFlags[ptlIdx - 1] )
2022          || ( m_inblFlag                [ptlIdx ] != m_inblFlag                [ptlIdx - 1] );
2023
2024      }
2025
2026     
2027      vps.setVpsProfilePresentFlag( ptlIdx, vpsProfilePresentFlag ); 
2028    }
2029
2030    xSetProfileTierLevel( vps, ptlIdx, -1, m_profiles[ptlIdx], m_level[ptlIdx], 
2031      m_levelTier[ ptlIdx ], m_progressiveSourceFlags[ptlIdx], m_interlacedSourceFlags[ptlIdx],
2032      m_nonPackedConstraintFlags[ptlIdx], m_frameOnlyConstraintFlags[ptlIdx],  m_inblFlag[ptlIdx] );     
2033  }
2034}
2035
2036Void TAppEncTop::xSetProfileTierLevel(TComVPS& vps, Int ptlIdx, Int subLayer, Profile::Name profile, Level::Name level, Level::Tier tier, Bool progressiveSourceFlag, Bool interlacedSourceFlag, Bool nonPackedConstraintFlag, Bool frameOnlyConstraintFlag, Bool inbldFlag)
2037{
2038 
2039  TComPTL* ptlStruct = vps.getPTL( ptlIdx );   
2040  assert( ptlStruct != NULL ); 
2041
2042  ProfileTierLevel* ptl; 
2043  if ( subLayer == -1 )
2044  {
2045    ptl = ptlStruct->getGeneralPTL();
2046  }
2047  else
2048  {
2049    ptl = ptlStruct->getSubLayerPTL(  subLayer );
2050  }
2051
2052  assert( ptl != NULL );
2053
2054  ptl->setProfileIdc              ( m_profiles [ ptlIdx ] );
2055  ptl->setTierFlag                ( m_levelTier[ ptlIdx ] );
2056  ptl->setLevelIdc                ( m_level    [ ptlIdx ] );
2057  ptl->setProfileCompatibilityFlag( m_profiles [ ptlIdx ], true );
2058  ptl->setInbldFlag               ( m_inblFlag [ ptlIdx ] );
2059
2060  Int        bitDepth = m_bitDepthConstraints[ptlIdx];
2061  ChromaFormat chroma = m_chromaFormatConstraints[ptlIdx];
2062
2063  ptl->setMax12bitConstraintFlag      (  bitDepth <= 12  );   
2064  ptl->setMax10bitConstraintFlag      (  bitDepth <= 10 );
2065  ptl->setMax8bitConstraintFlag       (  bitDepth <= 8 );
2066  ptl->setMax422chromaConstraintFlag  ( chroma == CHROMA_400 || chroma == CHROMA_420 || chroma == CHROMA_422    );
2067  ptl->setMax420chromaConstraintFlag  ( chroma == CHROMA_400 || chroma == CHROMA_420                            );                         ;
2068  ptl->setMaxMonochromeConstraintFlag ( chroma == CHROMA_400                       );
2069  ptl->setIntraConstraintFlag         ( m_intraConstraintFlags[ ptlIdx ]           ); 
2070  ptl->setOnePictureOnlyConstraintFlag( m_onePictureOnlyConstraintFlags[ ptlIdx ]  );
2071  ptl->setLowerBitRateConstraintFlag  ( m_lowerBitRateConstraintFlags[ ptlIdx ]    );   
2072}
2073
2074Void TAppEncTop::xSetRepFormat( TComVPS& vps )
2075{
2076  vps.setVpsNumRepFormatsMinus1 ( m_numRepFormats - 1 ); 
2077
2078
2079  std::vector<TComRepFormat> repFormat;
2080  repFormat.resize( vps.getVpsNumRepFormatsMinus1() + 1 ); 
2081  for ( Int j = 0; j <= vps.getVpsNumRepFormatsMinus1(); j++ )
2082  {           
2083    repFormat[j].setBitDepthVpsChromaMinus8   ( m_internalBitDepths[j][CHANNEL_TYPE_LUMA  ] - 8 ); 
2084    repFormat[j].setBitDepthVpsLumaMinus8     ( m_internalBitDepths[j][CHANNEL_TYPE_CHROMA] - 8 );
2085    repFormat[j].setChromaFormatVpsIdc        ( m_chromaFormatIDCs[j] );
2086    repFormat[j].setPicHeightVpsInLumaSamples ( m_iSourceHeights[j] );
2087    repFormat[j].setPicWidthVpsInLumaSamples  ( m_iSourceWidths [j] );   
2088    repFormat[j].setChromaAndBitDepthVpsPresentFlag( true );   
2089    // ToDo not supported yet.
2090    //repFormat->setSeparateColourPlaneVpsFlag( );
2091
2092    repFormat[j].setConformanceWindowVpsFlag( true );
2093    repFormat[j].setConfWinVpsLeftOffset    ( m_confWinLefts  [j] / TComSPS::getWinUnitX( repFormat[j].getChromaFormatVpsIdc() ) );
2094    repFormat[j].setConfWinVpsRightOffset   ( m_confWinRights [j] / TComSPS::getWinUnitX( repFormat[j].getChromaFormatVpsIdc() ) );
2095    repFormat[j].setConfWinVpsTopOffset     ( m_confWinTops   [j] / TComSPS::getWinUnitY( repFormat[j].getChromaFormatVpsIdc() ) );
2096    repFormat[j].setConfWinVpsBottomOffset  ( m_confWinBottoms[j] / TComSPS::getWinUnitY( repFormat[j].getChromaFormatVpsIdc() ) ); 
2097  }
2098
2099  vps.setRepFormat( repFormat );
2100
2101
2102  if ( vps.getVpsNumRepFormatsMinus1() > 0 )
2103  {
2104    Bool repFormatIdxPresentFlag = false;
2105    for( Int i = vps.getVpsBaseLayerInternalFlag() ? 1 : 0; i <= vps.getMaxLayersMinus1(); i++ )
2106    {
2107      repFormatIdxPresentFlag = repFormatIdxPresentFlag ||  ( m_layerIdxInVpsToRepFormatIdx[i]  != vps.inferVpsRepFormatIdx( i ) );
2108    }
2109    vps.setRepFormatIdxPresentFlag( repFormatIdxPresentFlag ); 
2110  }
2111
2112  for( Int i =  0; i <=  vps.getMaxLayersMinus1(); i++ )
2113  {
2114    // When base_layer_internal_flag is equal to 1, the first repFormatIdx cannot be signaled but is inferred.
2115    if( !vps.getRepFormatIdxPresentFlag() || ( vps.getVpsBaseLayerInternalFlag() && i == 0 )   ) 
2116    {
2117      vps.setVpsRepFormatIdx( i, vps.inferVpsRepFormatIdx( i ) );
2118      AOF( vps.getVpsRepFormatIdx( i ) == m_layerIdxInVpsToRepFormatIdx[i] ); 
2119    }
2120    else
2121    {
2122      vps.setVpsRepFormatIdx( i, m_layerIdxInVpsToRepFormatIdx[i] );         
2123    }
2124  }
2125
2126
2127  xConfirmRepFormat( vps );
2128
2129}
2130
2131Void TAppEncTop::xSetDpbSize                ( TComVPS& vps )
2132{
2133  // These settings need to be verified
2134
2135  TComDpbSize dpbSize;   
2136  dpbSize.init( vps.getNumOutputLayerSets(), vps.getVpsMaxLayerId() + 1, vps.getMaxSubLayersMinus1() + 1 ) ;
2137 
2138
2139  for( Int i = 0; i < vps.getNumOutputLayerSets(); i++ )
2140  { 
2141    Int currLsIdx = vps.olsIdxToLsIdx( i ); 
2142    Bool subLayerFlagInfoPresentFlag = false; 
2143
2144    for( Int j = 0; j  <=  vps.getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ )
2145    {   
2146      Bool subLayerDpbInfoPresentFlag = false; 
2147      for( Int k = 0; k < vps.getNumLayersInIdList( currLsIdx ); k++ )   
2148      {
2149        Int layerIdInVps = vps.getLayerIdInVps( vps.getLayerSetLayerIdList( currLsIdx, k ) );
2150        if ( vps.getNecessaryLayerFlag( i,k ) && ( vps.getVpsBaseLayerInternalFlag() || vps.getLayerSetLayerIdList( currLsIdx, k ) != 0 ) )
2151        {       
2152          dpbSize.setMaxVpsDecPicBufferingMinus1( i, k, j, m_maxDecPicBufferingMvc[ layerIdInVps ][ j ] - 1 );
2153          if ( j > 0 )
2154          {
2155            subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize.getMaxVpsDecPicBufferingMinus1( i, k, j ) != dpbSize.getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) );
2156          }
2157        }
2158        else
2159        {
2160          if (vps.getNecessaryLayerFlag(i,k) && j == 0 && k == 0 )
2161          {         
2162            dpbSize.setMaxVpsDecPicBufferingMinus1(i, k ,j, 0 ); 
2163          }
2164        }
2165      }       
2166
2167      Int maxNumReorderPics = MIN_INT;
2168      for ( Int idx = 0; idx < vps.getNumLayersInIdList( currLsIdx ); idx++ )
2169      {
2170        if (vps.getNecessaryLayerFlag(i, idx ))
2171        {       
2172          Int layerIdInVps = vps.getLayerIdInVps( vps.getLayerSetLayerIdList(currLsIdx, idx) );       
2173          maxNumReorderPics = std::max( maxNumReorderPics, m_numReorderPicsMvc[ layerIdInVps ][ j ] ); 
2174        }
2175      }
2176      assert( maxNumReorderPics != MIN_INT ); 
2177
2178      dpbSize.setMaxVpsNumReorderPics( i, j, maxNumReorderPics );
2179      if ( j > 0 )
2180      {
2181        subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize.getMaxVpsNumReorderPics( i, j ) != dpbSize.getMaxVpsNumReorderPics( i, j - 1 ) );
2182      }
2183
2184      // To Be Done !
2185      // dpbSize.setMaxVpsLatencyIncreasePlus1( i, j, xx );
2186      if ( j > 0 )
2187      {
2188        subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize.getMaxVpsLatencyIncreasePlus1( i, j ) != dpbSize.getMaxVpsLatencyIncreasePlus1( i, j - 1  ) );
2189      }
2190
2191      if( j > 0 ) 
2192      {
2193        dpbSize.setSubLayerDpbInfoPresentFlag( i, j, subLayerDpbInfoPresentFlag );
2194        subLayerFlagInfoPresentFlag = subLayerFlagInfoPresentFlag || subLayerDpbInfoPresentFlag; 
2195      }       
2196    } 
2197    dpbSize.setSubLayerFlagInfoPresentFlag( i, subLayerFlagInfoPresentFlag ); 
2198  } 
2199  vps.setDpbSize( dpbSize ); 
2200}
2201
2202Void TAppEncTop::xSetLayerSets( TComVPS& vps )
2203{   
2204  // Layer sets
2205  vps.setVpsNumLayerSetsMinus1   ( m_vpsNumLayerSets - 1 ); 
2206   
2207  for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ )
2208  {
2209    for( Int layerId = 0; layerId < MAX_NUM_LAYER_IDS; layerId++ )
2210    {
2211      vps.setLayerIdIncludedFlag( false, lsIdx, layerId ); 
2212    }
2213    for ( Int i = 0; i < m_layerIdxInVpsInSets[lsIdx].size(); i++)
2214    {       
2215      vps.setLayerIdIncludedFlag( true, lsIdx, vps.getLayerIdInNuh( m_layerIdxInVpsInSets[lsIdx][i] ) ); 
2216    } 
2217  }
2218  vps.deriveLayerSetLayerIdList(); 
2219
2220  Int numAddOuputLayerSets = (Int) m_outputLayerSetIdx.size(); 
2221  // Additional output layer sets + profileLevelTierIdx
2222  vps.setDefaultOutputLayerIdc      ( m_defaultOutputLayerIdc );   
2223  if( vps.getNumIndependentLayers() == 0 && m_numAddLayerSets > 0  )
2224  {
2225    fprintf( stderr, "\nWarning: Ignoring additional layer sets since NumIndependentLayers is equal to 0.\n");           
2226  }
2227  else
2228  {
2229    vps.setNumAddLayerSets( m_numAddLayerSets ); 
2230    if ( m_highestLayerIdxPlus1.size() < vps.getNumAddLayerSets() ) 
2231    {
2232      fprintf(stderr, "\nError: Number of highestLayerIdxPlus1 parameters must be greater than or equal to NumAddLayerSets\n");
2233      exit(EXIT_FAILURE);
2234    }
2235
2236    for (Int i = 0; i < vps.getNumAddLayerSets(); i++)
2237    {
2238      if ( m_highestLayerIdxPlus1[ i ].size() < vps.getNumIndependentLayers() ) 
2239      {
2240        fprintf(stderr, "Error: Number of elements in highestLayerIdxPlus1[ %d ] parameters must be greater than or equal to NumIndependentLayers(= %d)\n", i, vps.getNumIndependentLayers());
2241        exit(EXIT_FAILURE);
2242      }
2243
2244      for (Int j = 1; j < vps.getNumIndependentLayers(); j++)
2245      {
2246        if ( m_highestLayerIdxPlus1[ i ][ j ]  < 0 || m_highestLayerIdxPlus1[ i ][ j ] > vps.getNumLayersInTreePartition( j ) ) 
2247        {
2248          fprintf(stderr, "Error: highestLayerIdxPlus1[ %d ][ %d ] shall be in the range of 0 to NumLayersInTreePartition[ %d ] (= %d ), inclusive. \n", i, j, j, vps.getNumLayersInTreePartition( j ) );
2249          exit(EXIT_FAILURE);
2250        }
2251        vps.setHighestLayerIdxPlus1( i, j, m_highestLayerIdxPlus1[ i ][ j ] ); 
2252      }
2253      vps.deriveAddLayerSetLayerIdList( i );
2254    }       
2255  } 
2256  vps.setNumAddOlss                 ( numAddOuputLayerSets          ); 
2257  vps.initTargetLayerIdLists(); 
2258
2259  for (Int olsIdx = 0; olsIdx < vps.getNumLayerSets() + numAddOuputLayerSets; olsIdx++)
2260  {
2261    Int addOutLsIdx = olsIdx - vps.getNumLayerSets();     
2262    vps.setLayerSetIdxForOlsMinus1( olsIdx, ( ( addOutLsIdx < 0 ) ?  olsIdx  : m_outputLayerSetIdx[ addOutLsIdx ] ) - 1 ); 
2263
2264    Int lsIdx = vps.olsIdxToLsIdx( olsIdx );
2265    if (vps.getDefaultOutputLayerIdc() == 2 || addOutLsIdx >= 0 )
2266    { 
2267      for ( Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++)
2268      {
2269        vps.setOutputLayerFlag( olsIdx, i, ( olsIdx == 0 && i == 0 ) ? vps.inferOutputLayerFlag(olsIdx, i ) : false ); // This is a software only fix for a bug in the spec. In spec outputLayerFlag neither present nor inferred for this case !
2270      }
2271
2272      std::vector<Int>& outLayerIdList = ( addOutLsIdx >= 0 ) ? m_layerIdsInAddOutputLayerSet[addOutLsIdx] : m_layerIdsInDefOutputLayerSet[olsIdx]; 
2273
2274      Bool outputLayerInLayerSetFlag = false; 
2275      for (Int j = 0; j < outLayerIdList.size(); j++)
2276      {   
2277        for ( Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++)
2278        {
2279          if ( vps.getLayerSetLayerIdList( lsIdx, i ) == outLayerIdList[ j ] )
2280          {
2281            vps.setOutputLayerFlag( olsIdx, i, true );       
2282            outputLayerInLayerSetFlag = true; 
2283            break; 
2284          }
2285        }
2286        if ( !outputLayerInLayerSetFlag )
2287        {
2288          fprintf(stderr, "Error: Output layer %d in output layer set %d not in corresponding layer set %d \n", outLayerIdList[ j ], olsIdx , lsIdx );
2289          exit(EXIT_FAILURE);
2290        }
2291      }
2292    }
2293    else
2294    {
2295      for ( Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++)
2296      {
2297        vps.setOutputLayerFlag( olsIdx, i, vps.inferOutputLayerFlag( olsIdx, i ) );       
2298      }
2299    }
2300
2301    vps.deriveNecessaryLayerFlags( olsIdx ); 
2302    vps.deriveTargetLayerIdList(  olsIdx ); 
2303
2304    // SET profile_tier_level_index.
2305    if ( olsIdx == 0 )
2306    {   
2307      vps.setProfileTierLevelIdx( 0, 0 , vps.getMaxLayersMinus1() > 0 ? 1 : 0 ); 
2308    }
2309    else
2310    {
2311      if( (Int) m_profileTierLevelIdx[ olsIdx ].size() < vps.getNumLayersInIdList( lsIdx ) )
2312      {
2313        fprintf( stderr, "Warning: Not enough profileTierLevelIdx values given for the %d-th OLS. Inferring default values.\n", olsIdx ); 
2314      }
2315      for (Int j = 0; j < vps.getNumLayersInIdList( lsIdx ); j++)
2316      {
2317        if( j < (Int) m_profileTierLevelIdx[ olsIdx ].size() )
2318        {
2319          vps.setProfileTierLevelIdx(olsIdx, j, m_profileTierLevelIdx[olsIdx][j] );
2320          if( !vps.getNecessaryLayerFlag(olsIdx,j) && m_profileTierLevelIdx[ olsIdx ][ j ] != -1 )
2321          {
2322            fprintf( stderr, "Warning: The %d-th layer in the %d-th OLS is not necessary such that profileTierLevelIdx[%d][%d] will be ignored. Set value to -1 to suppress warning.\n", j,olsIdx,olsIdx,j ); 
2323          }         
2324        }
2325        else if ( vps.getNecessaryLayerFlag(olsIdx,j) )
2326        {
2327          // setting default values
2328          if ( j == 0 || vps.getVpsNumProfileTierLevelMinus1() < 1 )
2329          {
2330            // set base layer as default
2331            vps.setProfileTierLevelIdx(olsIdx, j, 1 );
2332          }
2333          else
2334          {
2335            // set VpsProfileTierLevel[2] as default
2336            vps.setProfileTierLevelIdx(olsIdx, j, 2 ); 
2337          }
2338        }
2339      }
2340    }
2341   
2342    if ( vps.getNumOutputLayersInOutputLayerSet( olsIdx ) == 1 && 
2343        vps.getNumDirectRefLayers( vps.getOlsHighestOutputLayerId( olsIdx ) ) )
2344    {   
2345      vps.setAltOutputLayerFlag( olsIdx , m_altOutputLayerFlag[ olsIdx ]);
2346    }
2347    else
2348    {
2349      vps.setAltOutputLayerFlag( olsIdx , false );
2350      if ( m_altOutputLayerFlag[ olsIdx ] )
2351      {
2352        printf( "\nWarning: Ignoring AltOutputLayerFlag for output layer set %d, since more than one output layer or no dependent layers.\n", olsIdx );           
2353      }
2354    }
2355  }
2356}
2357
2358Void TAppEncTop::xSetVPSVUI( TComVPS& vps )
2359{
2360  vps.setVpsVuiPresentFlag( m_vpsVuiPresentFlag ); 
2361
2362  TComVPSVUI vpsVui;
2363  vpsVui.init(vps.getNumAddLayerSets(),vps.getMaxSubLayersMinus1() + 1, vps.getMaxLayersMinus1() + 1 );
2364
2365  if ( m_vpsVuiPresentFlag )
2366  {
2367    // All this stuff could actually be derived by the encoder,
2368    // however preliminary setting it from input parameters
2369
2370    vpsVui.setCrossLayerPicTypeAlignedFlag( m_crossLayerPicTypeAlignedFlag );
2371    vpsVui.setCrossLayerIrapAlignedFlag   ( m_crossLayerIrapAlignedFlag    );
2372    vpsVui.setAllLayersIdrAlignedFlag     ( m_allLayersIdrAlignedFlag      );
2373    vpsVui.setBitRatePresentVpsFlag( m_bitRatePresentVpsFlag );
2374    vpsVui.setPicRatePresentVpsFlag( m_picRatePresentVpsFlag );
2375
2376    if( vpsVui.getBitRatePresentVpsFlag( )  ||  vpsVui.getPicRatePresentVpsFlag( ) )
2377    {
2378      for( Int i = 0; i  <  vps.getNumLayerSets(); i++ )
2379      {
2380        for( Int j = 0; j  <=  vps.getMaxTLayers(); j++ ) 
2381        {
2382          if( vpsVui.getBitRatePresentVpsFlag( ) && m_bitRatePresentFlag[i].size() > j )
2383          {
2384            vpsVui.setBitRatePresentFlag( i, j, m_bitRatePresentFlag[i][j] );           
2385          }
2386          if( vpsVui.getPicRatePresentVpsFlag( ) && m_picRatePresentFlag[i].size() > j   )
2387          {
2388            vpsVui.setPicRatePresentFlag( i, j, m_picRatePresentFlag[i][j] );
2389          }
2390          if( vpsVui.getBitRatePresentFlag( i, j )  && m_avgBitRate[i].size() > j )
2391          {
2392            vpsVui.setAvgBitRate( i, j, m_avgBitRate[i][j] );         
2393          }
2394          if( vpsVui.getBitRatePresentFlag( i, j )  && m_maxBitRate[i].size() > j )
2395          {
2396            vpsVui.setMaxBitRate( i, j, m_maxBitRate[i][j] );
2397          }
2398          if( vpsVui.getPicRatePresentFlag( i, j ) && m_constantPicRateIdc[i].size() > j )
2399          {
2400            vpsVui.setConstantPicRateIdc( i, j, m_constantPicRateIdc[i][j] );
2401          }
2402          if( vpsVui.getPicRatePresentFlag( i, j ) && m_avgPicRate[i].size() > j )
2403          {
2404            vpsVui.setAvgPicRate( i, j, m_avgPicRate[i][j] );
2405          }
2406        }
2407      }
2408    }
2409
2410    vpsVui.setTilesNotInUseFlag( m_tilesNotInUseFlag );
2411
2412    if( !vpsVui.getTilesNotInUseFlag() ) 
2413    {     
2414      for( Int i = 0; i  <=  vps.getMaxLayersMinus1(); i++ )
2415      {
2416        vpsVui.setTilesInUseFlag( i, m_tilesInUseFlag[ i ] );
2417        if( vpsVui.getTilesInUseFlag( i ) ) 
2418        {
2419          vpsVui.setLoopFilterNotAcrossTilesFlag( i, m_loopFilterNotAcrossTilesFlag[ i ] );
2420        }
2421      } 
2422
2423      for( Int i = 1; i  <=  vps.getMaxLayersMinus1(); i++ ) 
2424      {
2425        for( Int j = 0; j < vps.getNumDirectRefLayers( vps.getLayerIdInNuh( i ) ) ; j++ )
2426        { 
2427          Int layerIdx = vps.getLayerIdInVps( vps.getIdDirectRefLayer(vps.getLayerIdInNuh( i ) , j  )); 
2428          if( vpsVui.getTilesInUseFlag( i )  &&  vpsVui.getTilesInUseFlag( layerIdx ) ) 
2429          {
2430            vpsVui.setTileBoundariesAlignedFlag( i, j, m_tileBoundariesAlignedFlag[i][j] );
2431          }
2432        } 
2433      }
2434    } 
2435
2436    vpsVui.setWppNotInUseFlag( m_wppNotInUseFlag );
2437
2438    if( !vpsVui.getWppNotInUseFlag( ) )
2439    {
2440      for( Int i = 1; i  <=  vps.getMaxLayersMinus1(); i++ ) 
2441      {
2442        vpsVui.setWppInUseFlag( i, m_wppInUseFlag[ i ]);
2443      }
2444    }
2445
2446  vpsVui.setSingleLayerForNonIrapFlag( m_singleLayerForNonIrapFlag );
2447  vpsVui.setHigherLayerIrapSkipFlag( m_higherLayerIrapSkipFlag );
2448
2449    vpsVui.setIlpRestrictedRefLayersFlag( m_ilpRestrictedRefLayersFlag );
2450
2451    if( vpsVui.getIlpRestrictedRefLayersFlag( ) )
2452    {
2453      for( Int i = 1; i  <=  vps.getMaxLayersMinus1(); i++ )
2454      {
2455        for( Int j = 0; j < vps.getNumDirectRefLayers( vps.getLayerIdInNuh( i ) ); j++ )
2456        {
2457          if ( m_minSpatialSegmentOffsetPlus1[i].size() > j )
2458          {       
2459            vpsVui.setMinSpatialSegmentOffsetPlus1( i, j, m_minSpatialSegmentOffsetPlus1[i][j] );
2460          }
2461          if( vpsVui.getMinSpatialSegmentOffsetPlus1( i, j ) > 0 )
2462          {
2463            if ( m_ctuBasedOffsetEnabledFlag[i].size() > j )
2464            {       
2465              vpsVui.setCtuBasedOffsetEnabledFlag( i, j, m_ctuBasedOffsetEnabledFlag[i][j] );
2466            }
2467            if( vpsVui.getCtuBasedOffsetEnabledFlag( i, j ) )
2468            {
2469              if ( m_minHorizontalCtuOffsetPlus1[i].size() > j )
2470              {
2471                vpsVui.setMinHorizontalCtuOffsetPlus1( i, j, m_minHorizontalCtuOffsetPlus1[i][j] );
2472              }
2473            }
2474          }
2475        }
2476      }
2477    }     
2478    vpsVui.setVideoSignalInfoIdxPresentFlag( true ); 
2479    vpsVui.setVpsNumVideoSignalInfoMinus1  ( 0    );     
2480
2481    std::vector<TComVideoSignalInfo> videoSignalInfos;
2482    videoSignalInfos.resize( vpsVui.getVpsNumVideoSignalInfoMinus1() + 1 );
2483
2484    videoSignalInfos[0].setColourPrimariesVps        ( m_colourPrimaries ); 
2485    videoSignalInfos[0].setMatrixCoeffsVps           ( m_matrixCoefficients ); 
2486    videoSignalInfos[0].setTransferCharacteristicsVps( m_transferCharacteristics ); 
2487    videoSignalInfos[0].setVideoVpsFormat            ( m_videoFormat ); 
2488    videoSignalInfos[0].setVideoFullRangeVpsFlag     ( m_videoFullRangeFlag ); 
2489
2490    vpsVui.setVideoSignalInfo( videoSignalInfos );       
2491
2492    for (Int i = 0; i < m_numberOfLayers; i++)
2493    {     
2494      vpsVui.setVpsVideoSignalInfoIdx( i, 0 ); 
2495    }
2496    vpsVui.setVpsVuiBspHrdPresentFlag( false ); // TBD
2497  }
2498  else
2499  {
2500    //Default inference when not present.
2501    vpsVui.setCrossLayerIrapAlignedFlag   ( false   );
2502  }
2503  vps.setVPSVUI( vpsVui ); 
2504}
2505
2506#if NH_3D
2507Void TAppEncTop::xSetCamPara                ( TComVPS& vps )
2508{
2509  vps.setCpPrecision( m_cCameraData.getCamParsCodedPrecision()); 
2510
2511  for ( Int n = 1; n < vps.getNumViews(); n++ )
2512  { 
2513    Int i      = vps.getViewOIdxList( n ); 
2514    Int iInVps = vps.getVoiInVps    ( i ); 
2515    vps.setNumCp( iInVps,  n);   
2516
2517    if ( vps.getNumCp( iInVps ) > 0 )
2518    {
2519      vps.setCpInSliceSegmentHeaderFlag( iInVps, m_cCameraData.getVaryingCameraParameters() );
2520
2521      for( Int m = 0; m < vps.getNumCp( iInVps ); m++ )
2522      {
2523        vps.setCpRefVoi( iInVps, m, vps.getViewOIdxList( m ) ); 
2524        if( !vps.getCpInSliceSegmentHeaderFlag( iInVps ) ) 
2525        {
2526          Int j = vps.getCpRefVoi( iInVps, m );
2527          Int jInVps = vps.getVoiInVps( j );         
2528
2529          vps.setVpsCpScale   ( iInVps, jInVps, m_cCameraData.getCodedScale() [ jInVps ][ iInVps ] ) ;
2530          vps.setVpsCpInvScale( iInVps, jInVps, m_cCameraData.getCodedScale() [ iInVps ][ jInVps ] ) ;
2531          vps.setVpsCpOff     ( iInVps, jInVps, m_cCameraData.getCodedOffset()[ jInVps ][ iInVps ] ) ;
2532          vps.setVpsCpInvOff  ( iInVps, jInVps, m_cCameraData.getCodedOffset()[ iInVps ][ jInVps ] ) ;
2533        }
2534      }
2535    }
2536  }
2537  vps.deriveCpPresentFlag(); 
2538}
2539#endif
2540
2541
2542Bool TAppEncTop::xLayerIdInTargetEncLayerIdList(Int nuhLayerId)
2543{
2544  return  ( std::find(m_targetEncLayerIdList.begin(), m_targetEncLayerIdList.end(), nuhLayerId) != m_targetEncLayerIdList.end()) ;
2545}
2546
2547
2548#endif
2549
2550
2551#if NH_3D
2552Void TAppEncTop::xDeriveDltArray( TComVPS& vps, TComDLT* dlt )
2553{
2554  std::cout << "Analyzing input depth for DLT ";
2555  Int  iNumDepthViews  = 0;
2556  Bool bDltPresentFlag = false;
2557
2558  for ( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ )
2559  {
2560    Bool isDepth = ( vps.getDepthId( layer ) == 1 );
2561
2562    if ( isDepth )
2563    {
2564      iNumDepthViews++;
2565    }
2566
2567    dlt->setUseDLTFlag( layer , isDepth && m_useDLT );
2568    if( dlt->getUseDLTFlag( layer ) )
2569    {
2570      std::cout << ".";
2571      xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod[layer], 24), &vps, dlt);
2572      bDltPresentFlag = bDltPresentFlag || dlt->getUseDLTFlag(layer);
2573      dlt->setInterViewDltPredEnableFlag(layer, (dlt->getUseDLTFlag(layer) && (layer>1)));
2574     
2575      // ----------------------------- determine whether to use bit-map -----------------------------
2576      Bool bDltBitMapRepFlag       = false;
2577      UInt uiNumBitsNonBitMap      = 0;
2578      UInt uiNumBitsBitMap         = 0;
2579     
2580      UInt uiMaxDiff               = 0;
2581      UInt uiMinDiff               = MAX_INT;
2582      UInt uiLengthMinDiff         = 0;
2583      UInt uiLengthDltDiffMinusMin = 0;
2584     
2585      std::vector<Int> aiIdx2DepthValue_coded(256, 0);
2586      UInt uiNumDepthValues_coded = 0;
2587     
2588      uiNumDepthValues_coded = dlt->getNumDepthValues(layer);
2589      for( UInt ui = 0; ui<uiNumDepthValues_coded; ui++ )
2590      {
2591        aiIdx2DepthValue_coded[ui] = dlt->idx2DepthValue(layer, ui);
2592      }
2593     
2594      if( dlt->getInterViewDltPredEnableFlag( layer ) )
2595      {
2596        AOF( vps.getDepthId( 1 ) == 1 );
2597        AOF( layer > 1 );
2598        // assumes ref layer id to be 1
2599        std::vector<Int> piRefDLT = dlt->idx2DepthValue( 1 );
2600        UInt uiRefNum = dlt->getNumDepthValues( 1 );
2601        dlt->getDeltaDLT(layer, piRefDLT, uiRefNum, aiIdx2DepthValue_coded, uiNumDepthValues_coded);
2602      }
2603     
2604      std::vector<UInt> puiDltDiffValues(uiNumDepthValues_coded, 0);
2605     
2606      for (UInt d = 1; d < uiNumDepthValues_coded; d++)
2607      {
2608        puiDltDiffValues[d] = aiIdx2DepthValue_coded[d] - aiIdx2DepthValue_coded[d-1];
2609       
2610        if ( uiMaxDiff < puiDltDiffValues[d] )
2611        {
2612          uiMaxDiff = puiDltDiffValues[d];
2613        }
2614       
2615        if ( uiMinDiff > puiDltDiffValues[d] )
2616        {
2617          uiMinDiff = puiDltDiffValues[d];
2618        }
2619      }
2620     
2621      // counting bits
2622      // diff coding branch
2623      uiNumBitsNonBitMap += 8;                          // u(v) bits for num_depth_values_in_dlt[layerId] (i.e. num_entry[ layerId ])
2624     
2625      if ( uiNumDepthValues_coded > 1 )
2626      {
2627        uiNumBitsNonBitMap += 8;                        // u(v) bits for max_diff[ layerId ]
2628      }
2629     
2630      if ( uiNumDepthValues_coded > 2 )
2631      {
2632        uiLengthMinDiff    = (UInt) gCeilLog2(uiMaxDiff + 1);
2633        uiNumBitsNonBitMap += uiLengthMinDiff;          // u(v)  bits for min_diff[ layerId ]
2634      }
2635     
2636      uiNumBitsNonBitMap += 8;                          // u(v) bits for dlt_depth_value0[ layerId ]
2637     
2638      if (uiMaxDiff > uiMinDiff)
2639      {
2640        uiLengthDltDiffMinusMin = (UInt) gCeilLog2(uiMaxDiff - uiMinDiff + 1);
2641        uiNumBitsNonBitMap += uiLengthDltDiffMinusMin * (uiNumDepthValues_coded - 1);  // u(v) bits for dlt_depth_value_diff_minus_min[ layerId ][ j ]
2642      }
2643     
2644      // bit map branch
2645      Int repFormatIdx = m_layerIdxInVpsToRepFormatIdx[ layer ];
2646      uiNumBitsBitMap = 1 << m_inputBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA];
2647     
2648      // determine bDltBitMapFlag
2649      bDltBitMapRepFlag = (uiNumBitsBitMap > uiNumBitsNonBitMap) ? false : true;
2650     
2651      dlt->setUseBitmapRep(layer, bDltBitMapRepFlag);
2652
2653      AOF( m_inputBitDepths[repFormatIdx][CHANNEL_TYPE_LUMA] == m_inputBitDepths[0][CHANNEL_TYPE_LUMA] )
2654    }
2655   
2656  }
2657
2658  dlt->setDltPresentFlag( bDltPresentFlag );
2659  dlt->setNumDepthViews ( iNumDepthViews  );
2660  dlt->setDepthViewBitDepth( m_inputBitDepths[CHANNEL_TYPE_LUMA][0] );
2661  std::cout << " done." << std::endl; 
2662}
2663#endif
2664//! \}
Note: See TracBrowser for help on using the repository browser.