source: 3DVCSoftware/branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.cpp @ 478

Last change on this file since 478 was 478, checked in by tech, 11 years ago

Minor clean ups.

  • Property svn:eol-style set to native
File size: 39.2 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-2013, 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
45#include "TAppEncTop.h"
46#include "TLibEncoder/AnnexBwrite.h"
47
48using namespace std;
49
50//! \ingroup TAppEncoder
51//! \{
52
53// ====================================================================================================================
54// Constructor / destructor / initialization / destroy
55// ====================================================================================================================
56
57TAppEncTop::TAppEncTop()
58{
59#if !H_MV
60  m_iFrameRcvd = 0;
61#endif
62  m_totalBytes = 0;
63  m_essentialBytes = 0;
64}
65
66TAppEncTop::~TAppEncTop()
67{
68}
69
70Void TAppEncTop::xInitLibCfg()
71{
72#if H_MV
73  TComVPS& vps = m_vps;   
74#else
75  TComVPS vps;
76#endif
77 
78#if H_MV
79  Int maxTempLayer = -1; 
80  for (Int j = 0; j < m_numberOfLayers; j++)
81  {
82    maxTempLayer = max( m_maxTempLayerMvc[ j ], maxTempLayer ); 
83  }
84
85  vps.setMaxTLayers                       ( maxTempLayer );
86  if ( maxTempLayer )
87  {
88    vps.setTemporalNestingFlag(true);
89  }
90  vps.setMaxLayers( m_numberOfLayers );
91  for(Int i = 0; i < MAX_TLAYER; i++)
92  {
93    Int maxNumReOrderPics  = 0; 
94    Int maxDecPicBuffering = 0;
95    for (Int j = 0; j < m_numberOfLayers; j++)
96    {
97      maxNumReOrderPics  = max( maxNumReOrderPics,  m_numReorderPicsMvc    [ j ][ i ] );     
98      maxDecPicBuffering = max( maxDecPicBuffering, m_maxDecPicBufferingMvc[ j ][ i ] );     
99    }
100
101    vps.setNumReorderPics                 ( maxNumReOrderPics  ,i );
102    vps.setMaxDecPicBuffering             ( maxDecPicBuffering ,i );
103  }
104#else
105  vps.setMaxTLayers                       ( m_maxTempLayer );
106  if (m_maxTempLayer == 1)
107  {
108    vps.setTemporalNestingFlag(true);
109  }
110  vps.setMaxLayers                        ( 1 );
111  for(Int i = 0; i < MAX_TLAYER; i++)
112  {
113    vps.setNumReorderPics                 ( m_numReorderPics[i], i );
114    vps.setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
115  }
116#endif
117#if H_MV
118  xSetLayerIds             ( vps );   
119  xSetDimensionIdAndLength ( vps );
120  xSetDirectDependencyFlags( vps );
121#if H_3D
122  vps.initViewIndex(); 
123  m_ivPicLists.setVPS      ( &vps ); 
124#endif
125
126  for(Int layer = 0; layer < m_numberOfLayers; layer++)
127  {
128    m_frameRcvd                 .push_back(0);
129    m_acTEncTopList             .push_back(new TEncTop); 
130    m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
131    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
132    m_picYuvRec                 .push_back(new TComList<TComPicYuv*>) ;
133
134    m_ivPicLists.push_back( m_acTEncTopList[ layer ]->getListPic()  ); 
135    TEncTop& m_cTEncTop = *m_acTEncTopList[ layer ];  // It is not a member, but this name helps avoiding code duplication !!!
136   
137    m_cTEncTop.setLayerIdInVps                 ( layer ); 
138    m_cTEncTop.setLayerId                      ( vps.getLayerIdInNuh( layer ) );   
139    m_cTEncTop.setViewId                       ( vps.getViewId      ( layer ) );
140#if H_3D
141    Bool isDepth = ( vps.getDepthId     ( layer ) != 0 ) ;
142    m_cTEncTop.setViewIndex                    ( vps.getViewIndex   ( layer ) );
143    m_cTEncTop.setIsDepth                      ( isDepth );
144    //====== Camera Parameters =========
145    m_cTEncTop.setCameraParameters             ( &m_cCameraData );     
146    m_cTEncTop.setCamParPrecision              ( isDepth ? false : m_cCameraData.getCamParsCodedPrecision  () );
147    m_cTEncTop.setCamParInSliceHeader          ( isDepth ? 0     : m_cCameraData.getVaryingCameraParameters() );
148    m_cTEncTop.setCodedScale                   ( isDepth ? 0     : m_cCameraData.getCodedScale             () );
149    m_cTEncTop.setCodedOffset                  ( isDepth ? 0     : m_cCameraData.getCodedOffset            () );
150#if H_3D_VSO
151    //====== VSO =========
152    m_cTEncTop.setRenderModelParameters        ( &m_cRenModStrParser ); 
153    m_cTEncTop.setForceLambdaScaleVSO          ( isDepth ? m_bForceLambdaScaleVSO : false );
154    m_cTEncTop.setLambdaScaleVSO               ( isDepth ? m_dLambdaScaleVSO      : 1     );
155    m_cTEncTop.setVSOMode                      ( isDepth ? m_uiVSOMode            : 0     );
156
157    m_cTEncTop.setAllowNegDist                 ( isDepth ? m_bAllowNegDist        : false );
158
159    // SAIT_VSO_EST_A0033
160    m_cTEncTop.setUseEstimatedVSD              ( isDepth ? m_bUseEstimatedVSD     : false );
161
162    // LGE_WVSO_A0119
163    m_cTEncTop.setUseWVSO                      ( isDepth ? m_bUseWVSO             : false );   
164    m_cTEncTop.setVSOWeight                    ( isDepth ? m_iVSOWeight           : 0     );
165    m_cTEncTop.setVSDWeight                    ( isDepth ? m_iVSDWeight           : 0     );
166    m_cTEncTop.setDWeight                      ( isDepth ? m_iDWeight             : 0     );
167#endif // H_3D_VSO
168#if H_3D_IV_MERGE
169    m_cTEncTop.setMultiviewMvPredMode          ( m_uiMultiviewMvPredMode     );
170    m_cTEncTop.setPredDepthMapGeneration       ( m_uiPredDepthMapGeneration );
171#endif
172#endif // H_3D
173
174    m_cTEncTop.setIvPicLists                   ( &m_ivPicLists ); 
175#endif // H_MV
176  m_cTEncTop.setVPS(&vps);
177
178  m_cTEncTop.setProfile(m_profile);
179  m_cTEncTop.setLevel(m_levelTier, m_level);
180#if L0046_CONSTRAINT_FLAGS
181  m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag);
182  m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag);
183  m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
184  m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
185#endif
186 
187  m_cTEncTop.setFrameRate                    ( m_iFrameRate );
188  m_cTEncTop.setFrameSkip                    ( m_FrameSkip );
189  m_cTEncTop.setSourceWidth                  ( m_iSourceWidth );
190  m_cTEncTop.setSourceHeight                 ( m_iSourceHeight );
191  m_cTEncTop.setConformanceWindow            ( m_confLeft, m_confRight, m_confTop, m_confBottom );
192  m_cTEncTop.setFramesToBeEncoded            ( m_framesToBeEncoded );
193 
194  //====== Coding Structure ========
195  m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod );
196  m_cTEncTop.setDecodingRefreshType          ( m_iDecodingRefreshType );
197  m_cTEncTop.setGOPSize                      ( m_iGOPSize );
198#if H_MV
199  m_cTEncTop.setGopList                      ( m_GOPListMvc[layer] );
200  m_cTEncTop.setExtraRPSs                    ( m_extraRPSsMvc[layer] );
201  for(Int i = 0; i < MAX_TLAYER; i++)
202  {
203    m_cTEncTop.setNumReorderPics             ( m_numReorderPicsMvc[layer][i], i );
204    m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBufferingMvc[layer][i], i );
205  }
206#else
207  m_cTEncTop.setGopList                      ( m_GOPList );
208  m_cTEncTop.setExtraRPSs                    ( m_extraRPSs );
209  for(Int i = 0; i < MAX_TLAYER; i++)
210  {
211    m_cTEncTop.setNumReorderPics             ( m_numReorderPics[i], i );
212    m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBuffering[i], i );
213#if H_3D_IV_MERGE
214        m_acTEncDepthTopList[iViewIdx]->setNumReorderPics             ( m_numReorderPics[iViewIdx][i], i );
215        m_acTEncDepthTopList[iViewIdx]->setMaxDecPicBuffering         ( m_maxDecPicBuffering[iViewIdx][i], i );
216#endif
217  }
218#if H_3D_IV_MERGE
219      m_acTEncDepthTopList[iViewIdx]->setQP                           ( m_aiQP[1] );
220
221      m_acTEncDepthTopList[iViewIdx]->setTemporalLayerQPOffset        ( m_aiTLayerQPOffset );
222      m_acTEncDepthTopList[iViewIdx]->setPad                          ( m_aiPad );
223
224      m_acTEncDepthTopList[iViewIdx]->setMaxTempLayer                 ( m_maxTempLayer[iViewIdx] );
225
226      m_acTEncDepthTopList[iViewIdx]->setDisInter4x4                  ( m_bDisInter4x4);
227
228      m_acTEncDepthTopList[iViewIdx]->setUseNSQT( m_enableNSQT );
229      m_acTEncDepthTopList[iViewIdx]->setUseAMP( m_enableAMP );
230#endif
231#endif
232  for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
233  {
234    m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
235  }
236#if H_MV
237  m_cTEncTop.setQP                           ( m_iQP[layer] );
238#else
239  m_cTEncTop.setQP                           ( m_iQP );
240#endif
241
242  m_cTEncTop.setPad                          ( m_aiPad );
243
244#if H_MV
245  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayerMvc[layer] );
246#else
247  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayer );
248#endif
249  m_cTEncTop.setUseAMP( m_enableAMP );
250 
251  //===== Slice ========
252 
253  //====== Loop/Deblock Filter ========
254#if H_MV
255  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable[layer]);
256#else
257  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable       );
258#endif
259  m_cTEncTop.setLoopFilterOffsetInPPS        ( m_loopFilterOffsetInPPS );
260  m_cTEncTop.setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
261  m_cTEncTop.setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
262  m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
263#if L0386_DB_METRIC
264  m_cTEncTop.setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
265#endif
266
267  //====== Motion search ========
268  m_cTEncTop.setFastSearch                   ( m_iFastSearch  );
269  m_cTEncTop.setSearchRange                  ( m_iSearchRange );
270  m_cTEncTop.setBipredSearchRange            ( m_bipredSearchRange );
271
272  //====== Quality control ========
273  m_cTEncTop.setMaxDeltaQP                   ( m_iMaxDeltaQP  );
274  m_cTEncTop.setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
275
276  m_cTEncTop.setChromaCbQpOffset               ( m_cbQpOffset     );
277  m_cTEncTop.setChromaCrQpOffset            ( m_crQpOffset  );
278
279#if ADAPTIVE_QP_SELECTION
280  m_cTEncTop.setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
281#endif
282
283  Int lowestQP;
284  lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
285
286#if H_MV
287  if ((m_iMaxDeltaQP == 0 ) && (m_iQP[layer] == lowestQP) && (m_useLossless == true))
288#else
289  if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true))
290#endif
291  {
292    m_bUseAdaptiveQP = false;
293  }
294  m_cTEncTop.setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
295  m_cTEncTop.setQPAdaptationRange            ( m_iQPAdaptationRange );
296 
297  //====== Tool list ========
298  m_cTEncTop.setUseSBACRD                    ( m_bUseSBACRD   );
299  m_cTEncTop.setDeltaQpRD                    ( m_uiDeltaQpRD  );
300  m_cTEncTop.setUseASR                       ( m_bUseASR      );
301  m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
302  m_cTEncTop.setUseLossless                  ( m_useLossless );
303#if !L0034_COMBINED_LIST_CLEANUP
304  m_cTEncTop.setUseLComb                     ( m_bUseLComb    );
305#endif
306#if H_MV
307  m_cTEncTop.setdQPs                         ( m_aidQP[layer]   );
308#else
309  m_cTEncTop.setdQPs                         ( m_aidQP        );
310#endif
311  m_cTEncTop.setUseRDOQ                      ( m_useRDOQ     );
312  m_cTEncTop.setUseRDOQTS                    ( m_useRDOQTS   );
313#if L0232_RD_PENALTY
314  m_cTEncTop.setRDpenalty                 ( m_rdPenalty );
315#endif
316  m_cTEncTop.setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
317  m_cTEncTop.setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
318  m_cTEncTop.setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
319  m_cTEncTop.setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
320  m_cTEncTop.setUseFastEnc                   ( m_bUseFastEnc  );
321  m_cTEncTop.setUseEarlyCU                   ( m_bUseEarlyCU  ); 
322  m_cTEncTop.setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
323  m_cTEncTop.setUseCbfFastMode            ( m_bUseCbfFastMode  );
324  m_cTEncTop.setUseEarlySkipDetection            ( m_useEarlySkipDetection );
325
326  m_cTEncTop.setUseTransformSkip             ( m_useTransformSkip      );
327  m_cTEncTop.setUseTransformSkipFast         ( m_useTransformSkipFast  );
328  m_cTEncTop.setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
329  m_cTEncTop.setPCMLog2MinSize          ( m_uiPCMLog2MinSize);
330  m_cTEncTop.setUsePCM                       ( m_usePCM );
331  m_cTEncTop.setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
332  m_cTEncTop.setMaxNumMergeCand              ( m_maxNumMergeCand );
333 
334
335  //====== Weighted Prediction ========
336  m_cTEncTop.setUseWP                   ( m_useWeightedPred      );
337  m_cTEncTop.setWPBiPred                ( m_useWeightedBiPred   );
338  //====== Parallel Merge Estimation ========
339  m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 );
340
341  //====== Slice ========
342  m_cTEncTop.setSliceMode               ( m_sliceMode                );
343  m_cTEncTop.setSliceArgument           ( m_sliceArgument            );
344
345  //====== Dependent Slice ========
346  m_cTEncTop.setSliceSegmentMode        ( m_sliceSegmentMode         );
347  m_cTEncTop.setSliceSegmentArgument    ( m_sliceSegmentArgument     );
348  Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
349  if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU)
350  {
351    m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU );
352  }
353  if(m_sliceMode==FIXED_NUMBER_OF_LCU)
354  {
355    m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU );
356  }
357  if(m_sliceMode==FIXED_NUMBER_OF_TILES)
358  {
359    m_cTEncTop.setSliceArgument ( m_sliceArgument );
360  }
361 
362  if(m_sliceMode == 0 )
363  {
364    m_bLFCrossSliceBoundaryFlag = true;
365  }
366  m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
367#if H_MV
368  m_cTEncTop.setUseSAO ( m_bUseSAO[layer] );
369#else
370  m_cTEncTop.setUseSAO ( m_bUseSAO );
371#endif
372  m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
373
374  m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary);
375  m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
376  m_cTEncTop.setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag); 
377  m_cTEncTop.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag); 
378
379  m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
380  m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled );
381  m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
382  m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
383#if J0149_TONE_MAPPING_SEI
384  m_cTEncTop.setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
385  m_cTEncTop.setTMISEIToneMapId                           ( m_toneMapId );
386  m_cTEncTop.setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
387  m_cTEncTop.setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
388  m_cTEncTop.setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
389  m_cTEncTop.setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
390  m_cTEncTop.setTMISEIModelID                             ( m_toneMapModelId );
391  m_cTEncTop.setTMISEIMinValue                            ( m_toneMapMinValue );
392  m_cTEncTop.setTMISEIMaxValue                            ( m_toneMapMaxValue );
393  m_cTEncTop.setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
394  m_cTEncTop.setTMISEISigmoidWidth                        ( m_sigmoidWidth );
395  m_cTEncTop.setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
396  m_cTEncTop.setTMISEINumPivots                           ( m_numPivots );
397  m_cTEncTop.setTMISEICodedPivotValue                     ( m_codedPivotValue );
398  m_cTEncTop.setTMISEITargetPivotValue                    ( m_targetPivotValue );
399  m_cTEncTop.setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
400  m_cTEncTop.setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
401  m_cTEncTop.setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
402  m_cTEncTop.setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
403  m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
404  m_cTEncTop.setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
405  m_cTEncTop.setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
406  m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
407  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
408  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
409#endif
410  m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
411  m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType );
412  m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId );
413  m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx );
414  m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation );
415  m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle );
416  m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled );
417  m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
418  m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
419#if L0208_SOP_DESCRIPTION_SEI
420  m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
421#endif
422#if K0180_SCALABLE_NESTING_SEI
423  m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
424#endif
425  m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
426  m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
427  m_cTEncTop.setNumRowsMinus1              ( m_iNumRowsMinus1 );
428  if(m_iUniformSpacingIdr==0)
429  {
430    m_cTEncTop.setColumnWidth              ( m_pColumnWidth );
431    m_cTEncTop.setRowHeight                ( m_pRowHeight );
432  }
433  m_cTEncTop.xCheckGSParameters();
434  Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
435  if(uiTilesCount == 1)
436  {
437    m_bLFCrossTileBoundaryFlag = true; 
438  }
439  m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
440  m_cTEncTop.setWaveFrontSynchro           ( m_iWaveFrontSynchro );
441  m_cTEncTop.setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
442  m_cTEncTop.setTMVPModeId ( m_TMVPModeId );
443  m_cTEncTop.setUseScalingListId           ( m_useScalingListId  );
444  m_cTEncTop.setScalingListFile            ( m_scalingListFile   );
445  m_cTEncTop.setSignHideFlag(m_signHideFlag);
446#if RATE_CONTROL_LAMBDA_DOMAIN
447  m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
448  m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
449  m_cTEncTop.setKeepHierBit         ( m_RCKeepHierarchicalBit );
450  m_cTEncTop.setLCULevelRC          ( m_RCLCULevelRC );
451  m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel );
452  m_cTEncTop.setInitialQP           ( m_RCInitialQP );
453  m_cTEncTop.setForceIntraQP        ( m_RCForceIntraQP );
454#else
455  m_cTEncTop.setUseRateCtrl     ( m_enableRateCtrl);
456  m_cTEncTop.setTargetBitrate   ( m_targetBitrate);
457  m_cTEncTop.setNumLCUInUnit    ( m_numLCUInUnit);
458#endif
459  m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
460  m_cTEncTop.setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue);
461  m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
462  m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
463  m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); 
464  m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
465  m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc );
466  m_cTEncTop.setSarWidth( m_sarWidth );
467  m_cTEncTop.setSarHeight( m_sarHeight );
468  m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag );
469  m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag );
470  m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag );
471  m_cTEncTop.setVideoFormat( m_videoFormat );
472  m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag );
473  m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag );
474  m_cTEncTop.setColourPrimaries( m_colourPrimaries );
475  m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics );
476  m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients );
477  m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag );
478  m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField );
479  m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField );
480  m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag );
481  m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
482  m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag );
483  m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag );
484  m_cTEncTop.setNumTicksPocDiffOneMinus1   ( m_numTicksPocDiffOneMinus1    );
485  m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag );
486  m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag );
487  m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag );
488  m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc );
489  m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom );
490  m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom );
491  m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
492  m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
493#if SIGNAL_BITRATE_PICRATE_IN_VPS
494  TComBitRatePicRateInfo *bitRatePicRateInfo = m_cTEncTop.getVPS()->getBitratePicrateInfo();
495  // The number of bit rate/pic rate have to equal to number of sub-layers.
496  if(m_bitRatePicRateMaxTLayers)
497  {
498    assert(m_bitRatePicRateMaxTLayers == m_cTEncTop.getVPS()->getMaxTLayers());
499  }
500  for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
501  {
502    bitRatePicRateInfo->setBitRateInfoPresentFlag( i, m_bitRateInfoPresentFlag[i] );
503    if( bitRatePicRateInfo->getBitRateInfoPresentFlag(i) )
504    {
505      bitRatePicRateInfo->setAvgBitRate(i, m_avgBitRate[i]);
506      bitRatePicRateInfo->setMaxBitRate(i, m_maxBitRate[i]);
507    }
508  }
509  for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
510  {
511    bitRatePicRateInfo->setPicRateInfoPresentFlag( i, m_picRateInfoPresentFlag[i] );
512    if( bitRatePicRateInfo->getPicRateInfoPresentFlag(i) )
513    {
514      bitRatePicRateInfo->setAvgPicRate     (i, m_avgPicRate[i]);
515      bitRatePicRateInfo->setConstantPicRateIdc(i, m_constantPicRateIdc[i]);
516    }
517  }
518#endif
519#if H_MV
520  }
521#endif
522#if H_3D_VSO
523  if ( m_bUseVSO )
524  {
525    if ( m_uiVSOMode == 4 )
526    {
527#if H_3D_VSO_EARLY_SKIP
528      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip );
529#else
530      m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 );
531#endif
532      for ( Int layer = 0; layer < m_numberOfLayers ; layer++ )
533      {
534        TEncTop* pcEncTop =  m_acTEncTopList[ layer ]; 
535        Int iViewNum      = pcEncTop->getViewIndex(); 
536        Int iContent      = pcEncTop->getIsDepth() ? 1 : 0; 
537        Int iNumOfModels  = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent);
538
539        Bool bUseVSO      = (iNumOfModels != 0);
540
541        pcEncTop->setUseVSO( bUseVSO );
542        pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL );
543
544        for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ )
545        {
546          Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode;
547
548          m_cRenModStrParser.getSingleModelData  ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ;
549          m_cRendererModel  .createSingleModel   ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode );
550        }           
551      }
552    }
553    else
554    {
555      AOT(true);
556    }
557  }
558#endif
559}
560
561Void TAppEncTop::xCreateLib()
562{
563#if H_MV
564  // initialize global variables
565  initROM();
566
567  for( Int layer=0; layer < m_numberOfLayers; layer++)
568  {
569    m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer],     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
570    m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
571
572    if (m_pchReconFileList[layer])
573    {
574      m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
575    }
576    m_acTEncTopList[layer]->create();
577  }
578#else
579  // Video I/O
580  m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
581  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
582
583  if (m_pchReconFile)
584    m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
585 
586  // Neo Decoder
587  m_cTEncTop.create();
588#endif
589}
590
591Void TAppEncTop::xDestroyLib()
592{
593#if H_MV
594  // destroy ROM
595  destroyROM();
596
597  for(Int layer=0; layer<m_numberOfLayers; layer++)
598  {
599    m_acTVideoIOYuvInputFileList[layer]->close();
600    m_acTVideoIOYuvReconFileList[layer]->close();
601    delete m_acTVideoIOYuvInputFileList[layer] ; 
602    m_acTVideoIOYuvInputFileList[layer] = NULL;
603    delete m_acTVideoIOYuvReconFileList[layer] ; 
604    m_acTVideoIOYuvReconFileList[layer] = NULL;
605    m_acTEncTopList[layer]->deletePicBuffer();
606    m_acTEncTopList[layer]->destroy();
607    delete m_acTEncTopList[layer] ; 
608    m_acTEncTopList[layer] = NULL;
609    delete m_picYuvRec[layer] ; 
610    m_picYuvRec[layer] = NULL;
611  }
612#else
613  // Video I/O
614  m_cTVideoIOYuvInputFile.close();
615  m_cTVideoIOYuvReconFile.close();
616 
617  // Neo Decoder
618  m_cTEncTop.destroy();
619#endif
620}
621
622Void TAppEncTop::xInitLib()
623{
624#if H_MV
625  for(Int layer=0; layer<m_numberOfLayers; layer++)
626  {
627#if H_3D_IV_MERGE
628    m_acTEncTopList[layer]->init(this );
629#else
630    m_acTEncTopList[layer]->init( );
631#endif
632  }
633#else
634  m_cTEncTop.init();
635#endif
636}
637
638// ====================================================================================================================
639// Public member functions
640// ====================================================================================================================
641
642/**
643 - create internal class
644 - initialize internal variable
645 - until the end of input YUV file, call encoding function in TEncTop class
646 - delete allocated buffers
647 - destroy internal class
648 .
649 */
650Void TAppEncTop::encode()
651{
652  fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
653  if (!bitstreamFile)
654  {
655    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
656    exit(EXIT_FAILURE);
657  }
658
659  TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
660  TComPicYuv*       pcPicYuvRec = NULL;
661 
662  // initialize internal class & member variables
663  xInitLibCfg();
664  xCreateLib();
665  xInitLib();
666 
667  // main encoder loop
668#if H_MV
669  Bool  allEos = false;
670  std::vector<Bool>  eos ;
671  std::vector<Bool>  flush ; 
672 
673  Int gopSize    = 1;
674  Int maxGopSize = 0;
675  maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize()); 
676 
677  for(Int layer=0; layer < m_numberOfLayers; layer++ )
678  {
679    eos  .push_back( false );
680    flush.push_back( false );
681  }
682#else
683  Int   iNumEncoded = 0;
684  Bool  bEos = false;
685#endif
686 
687  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
688
689  // allocate original YUV buffer
690  pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
691 
692#if H_MV
693  while ( !allEos )
694  {
695    for(Int layer=0; layer < m_numberOfLayers; layer++ )
696    {
697      Int frmCnt = 0;
698      while ( !eos[layer] && !(frmCnt == gopSize))
699      {
700        // get buffers
701        xGetBuffer(pcPicYuvRec, layer);
702
703        // read input YUV file
704        m_acTVideoIOYuvInputFileList[layer]->read      ( pcPicYuvOrg, m_aiPad );
705        m_acTEncTopList             [layer]->initNewPic( pcPicYuvOrg );
706
707        // increase number of received frames
708        m_frameRcvd[layer]++;
709       
710        frmCnt++;
711
712        eos[layer] = (m_frameRcvd[layer] == m_framesToBeEncoded);
713        allEos = allEos||eos[layer];
714
715        // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
716        if (m_acTVideoIOYuvInputFileList[layer]->isEof())
717        {
718          flush          [layer] = true;
719          eos            [layer] = true;
720          m_frameRcvd    [layer]--;
721          m_acTEncTopList[layer]->setFramesToBeEncoded(m_frameRcvd[layer]);
722        }
723      }
724    }
725    for ( Int gopId=0; gopId < gopSize; gopId++ )
726    {
727#if H_3D
728      UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId );
729      if ( iNextPoc < m_framesToBeEncoded )
730      {
731        m_cCameraData.update( iNextPoc );
732      }
733#endif
734      for(Int layer=0; layer < m_numberOfLayers; layer++ )
735      {
736#if H_3D_VSO       
737          if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded )
738          {
739            m_cCameraData.setDispCoeff( iNextPoc, m_acTEncTopList[layer]->getViewIndex() );
740            m_acTEncTopList[layer]  ->setDispCoeff( m_cCameraData.getDispCoeff() );
741          }
742#endif
743        Int   iNumEncoded = 0;
744
745        // call encoding function for one frame         
746        m_acTEncTopList[layer]->encode( eos[layer], flush[layer] ? 0 : pcPicYuvOrg, *m_picYuvRec[layer], outputAccessUnits, iNumEncoded, gopId );       
747        xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, layer);
748        outputAccessUnits.clear();
749      }
750    }
751    gopSize = maxGopSize;
752  }
753  for(Int layer=0; layer < m_numberOfLayers; layer++ )
754  {
755    m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded() );
756  }
757#else
758  while ( !bEos )
759  {
760    // get buffers
761    xGetBuffer(pcPicYuvRec);
762
763    // read input YUV file
764    m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad );
765
766    // increase number of received frames
767    m_iFrameRcvd++;
768
769    bEos = (m_iFrameRcvd == m_framesToBeEncoded);
770
771    Bool flush = 0;
772    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
773    if (m_cTVideoIOYuvInputFile.isEof())
774    {
775      flush = true;
776      bEos = true;
777      m_iFrameRcvd--;
778      m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd);
779    }
780
781    // call encoding function for one frame
782    m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
783   
784    // write bistream to file if necessary
785    if ( iNumEncoded > 0 )
786    {
787      xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits);
788      outputAccessUnits.clear();
789    }
790  }
791
792  m_cTEncTop.printSummary();
793#endif
794
795  // delete original YUV buffer
796  pcPicYuvOrg->destroy();
797  delete pcPicYuvOrg;
798  pcPicYuvOrg = NULL;
799 
800#if !H_MV
801  // delete used buffers in encoder class
802  m_cTEncTop.deletePicBuffer();
803#endif
804
805  // delete buffers & classes
806  xDeleteBuffer();
807  xDestroyLib();
808 
809  printRateSummary();
810
811  return;
812}
813
814// ====================================================================================================================
815// Protected member functions
816// ====================================================================================================================
817
818/**
819 - application has picture buffer list with size of GOP
820 - picture buffer list acts as ring buffer
821 - end of the list has the latest picture
822 .
823 */
824#if H_MV
825Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
826#else
827Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec)
828#endif
829{
830  assert( m_iGOPSize > 0 );
831 
832  // org. buffer
833#if H_MV
834  if ( m_picYuvRec[layer]->size() == (UInt)m_iGOPSize )
835  {
836    rpcPicYuvRec = m_picYuvRec[layer]->popFront();
837#else
838  if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize )
839  {
840    rpcPicYuvRec = m_cListPicYuvRec.popFront();
841#endif
842
843  }
844  else
845  {
846    rpcPicYuvRec = new TComPicYuv;
847   
848    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
849
850  }
851#if H_MV
852  m_picYuvRec[layer]->pushBack( rpcPicYuvRec );
853#else
854  m_cListPicYuvRec.pushBack( rpcPicYuvRec );
855#endif
856}
857
858Void TAppEncTop::xDeleteBuffer( )
859{
860#if H_MV
861  for(Int layer=0; layer<m_picYuvRec.size(); layer++)
862  {
863    if(m_picYuvRec[layer])
864    {
865      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvRec[layer]->begin();
866      Int iSize = Int( m_picYuvRec[layer]->size() );
867#else
868  TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec.begin();
869 
870  Int iSize = Int( m_cListPicYuvRec.size() );
871#endif
872
873  for ( Int i = 0; i < iSize; i++ )
874  {
875    TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
876    pcPicYuvRec->destroy();
877    delete pcPicYuvRec; pcPicYuvRec = NULL;
878  }
879
880#if H_MV
881    }
882  }
883#endif 
884}
885
886/** \param iNumEncoded  number of encoded frames
887 */
888#if H_MV
889Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId)
890#else
891Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
892#endif
893{
894  Int i;
895 
896#if H_MV
897  if( iNumEncoded > 0 )
898  {
899    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end();
900#else
901  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
902  list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
903#endif
904
905  for ( i = 0; i < iNumEncoded; i++ )
906  {
907    --iterPicYuvRec;
908  }
909 
910  for ( i = 0; i < iNumEncoded; i++ )
911  {
912    TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
913#if H_MV
914      if (m_pchReconFileList[layerId])
915      {
916        m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
917      }
918    }
919  }
920  if( ! accessUnits.empty() )
921  {
922    list<AccessUnit>::iterator aUIter;
923    for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ )
924    {
925      const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter);
926      rateStatsAccum(*aUIter, stats);
927    }
928  }
929#else
930    if (m_pchReconFile)
931    {
932      m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
933    }
934
935    const AccessUnit& au = *(iterBitstream++);
936    const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
937    rateStatsAccum(au, stats);
938  }
939#endif
940}
941
942/**
943 *
944 */
945void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
946{
947  AccessUnit::const_iterator it_au = au.begin();
948  vector<UInt>::const_iterator it_stats = annexBsizes.begin();
949
950  for (; it_au != au.end(); it_au++, it_stats++)
951  {
952    switch ((*it_au)->m_nalUnitType)
953    {
954    case NAL_UNIT_CODED_SLICE_TRAIL_R:
955    case NAL_UNIT_CODED_SLICE_TRAIL_N:
956    case NAL_UNIT_CODED_SLICE_TLA_R:
957    case NAL_UNIT_CODED_SLICE_TSA_N:
958    case NAL_UNIT_CODED_SLICE_STSA_R:
959    case NAL_UNIT_CODED_SLICE_STSA_N:
960    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
961    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
962    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
963    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
964    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
965    case NAL_UNIT_CODED_SLICE_CRA:
966    case NAL_UNIT_CODED_SLICE_RADL_N:
967    case NAL_UNIT_CODED_SLICE_RADL_R:
968    case NAL_UNIT_CODED_SLICE_RASL_N:
969    case NAL_UNIT_CODED_SLICE_RASL_R:
970    case NAL_UNIT_VPS:
971    case NAL_UNIT_SPS:
972    case NAL_UNIT_PPS:
973      m_essentialBytes += *it_stats;
974      break;
975    default:
976      break;
977    }
978
979    m_totalBytes += *it_stats;
980  }
981}
982
983void TAppEncTop::printRateSummary()
984{
985#if H_MV
986  Double time = (Double) m_frameRcvd[0] / m_iFrameRate;
987  printf("\n");
988#else
989  Double time = (Double) m_iFrameRcvd / m_iFrameRate;
990#endif
991  printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
992#if VERBOSE_RATE
993  printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time);
994#endif
995}
996
997#if H_MV
998Void TAppEncTop::xSetDimensionIdAndLength( TComVPS& vps )
999{   
1000  vps.setScalabilityMask( m_scalabilityMask ); 
1001  for( Int dim = 0; dim < m_dimIds.size(); dim++ )
1002  {
1003    vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] );
1004    for( Int layer = 0; layer < vps.getMaxLayers(); layer++ )
1005    {       
1006      vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] );       
1007    } 
1008  }
1009}
1010
1011Void TAppEncTop::xSetDirectDependencyFlags( TComVPS& vps )
1012{
1013  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
1014  {
1015    if( m_GOPListMvc[layer][MAX_GOP].m_POC == -1 )
1016    {
1017      continue;
1018    }
1019    for( Int i = 0; i < getGOPSize()+1; i++ ) 
1020    {
1021      GOPEntry ge = ( i < getGOPSize() ) ? m_GOPListMvc[layer][i] : m_GOPListMvc[layer][MAX_GOP];
1022      for( Int j = 0; j < ge.m_numInterViewRefPics; j++ )
1023      {
1024        Int interLayerRef = layer + ge.m_interViewRefs[j];
1025        vps.setDirectDependencyFlag( layer, interLayerRef, true );
1026      }
1027    }
1028  }
1029
1030  vps.checkVPSExtensionSyntax(); 
1031  vps.calcIvRefLayers();
1032}
1033
1034Void TAppEncTop::xSetLayerIds( TComVPS& vps )
1035{
1036  vps.setSplittingFlag     ( m_splittingFlag );
1037
1038  Bool nuhLayerIdPresentFlag = !( m_layerIdInNuh.size() == 1 ); 
1039  Int  maxNuhLayerId = nuhLayerIdPresentFlag ? xGetMax( m_layerIdInNuh ) : ( m_numberOfLayers - 1 ) ; 
1040
1041  vps.setMaxNuhLayerId( maxNuhLayerId ); 
1042  vps.setVpsNuhLayerIdPresentFlag( nuhLayerIdPresentFlag ); 
1043
1044  for (Int layer = 0; layer < m_numberOfLayers; layer++ )
1045  {
1046    vps.setLayerIdInNuh( layer, nuhLayerIdPresentFlag ? m_layerIdInNuh[ layer ] : layer ); 
1047    vps.setLayerIdInVps( vps.getLayerIdInNuh( layer ), layer ); 
1048  }
1049}
1050
1051Int TAppEncTop::xGetMax( std::vector<Int>& vec )
1052{
1053  Int maxVec = 0; 
1054  for ( Int i = 0; i < vec.size(); i++)   
1055    maxVec = max( vec[i], maxVec ); 
1056  return maxVec;
1057}
1058#endif
1059#if H_3D_IV_MERGE
1060 // GT: This function is not necessary anymore m_ivPicLists should be used instead
1061TComPic* TAppEncTop::xGetPicFromView( Int viewIdx, Int poc, Bool isDepth )
1062{
1063  assert( ( viewIdx >= 0 ) && ( viewIdx < m_iNumberOfViews ) );
1064
1065  TComList<TComPic*>* apcListPic =  m_acTEncTopList[(isDepth ? 1 : 0) + viewIdx * 2]->getListPic() ;
1066
1067 
1068
1069  TComPic* pcPic = NULL;
1070  for(TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++)
1071  {
1072    if( (*it)->getPOC() == poc )
1073    {
1074      pcPic = *it ;
1075      break ;
1076    }
1077  }
1078
1079  return pcPic;
1080};
1081#endif
1082//! \}
Note: See TracBrowser for help on using the repository browser.