source: SHVCSoftware/branches/SHM-5.0-dev/source/App/TAppEncoder/TAppEncTop.cpp @ 583

Last change on this file since 583 was 582, checked in by qualcomm, 11 years ago

JCTVC-P0192: Resolution-based sub-DPB management <MACRO: RESOLUTION_BASED_DPB)

This patch includes the signaling, and assignment of resolution-based sub-DPB indices. Bumping process will be included in a following patch.

From: Adarsh K. Ramasubramonian <aramasub@…>

  • Property svn:eol-style set to native
File size: 85.4 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  m_iFrameRcvd = 0;
60  m_totalBytes = 0;
61  m_essentialBytes = 0;
62#if SVC_EXTENSION
63  for(UInt layer=0; layer < MAX_LAYERS; layer++)
64  {
65    m_apcTEncTop[layer] = &m_acTEncTop[layer];
66  }
67#endif
68}
69
70TAppEncTop::~TAppEncTop()
71{
72}
73
74#if SVC_EXTENSION
75Void TAppEncTop::xInitLibCfg()
76{
77  TComVPS* vps = m_acTEncTop[0].getVPS();
78
79  vps->setMaxTLayers                       ( m_maxTempLayer );
80  if (m_maxTempLayer == 1)
81  {
82    vps->setTemporalNestingFlag(true);
83  }
84#if !VPS_RENAME
85  vps.setMaxLayers                        ( 1 );
86#endif
87  for(Int i = 0; i < MAX_TLAYER; i++)
88  {
89    vps->setNumReorderPics                 ( m_numReorderPics[i], i );
90    vps->setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
91  }
92
93#if REPN_FORMAT_IN_VPS
94  vps->setRepFormatIdxPresentFlag( true );   // Could be disabled to optimize in some cases.
95  Int maxRepFormatIdx = -1;
96  Int formatIdx = -1;
97  for(UInt layer=0; layer < m_numLayers; layer++)
98  {
99    // Auto generation of the format index
100    if( m_acLayerCfg[layer].getRepFormatIdx() == -1 )
101    {     
102      Bool found = false;
103      for( UInt idx = 0; idx < layer; idx++ )
104      {
105        if( m_acLayerCfg[layer].getSourceWidth() == m_acLayerCfg[idx].getSourceWidth() && m_acLayerCfg[layer].getSourceHeight() == m_acLayerCfg[idx].getSourceHeight()
106#if AUXILIARY_PICTURES
107          && m_acLayerCfg[layer].getChromaFormatIDC() == m_acLayerCfg[idx].getChromaFormatIDC()
108#endif
109#if O0194_DIFFERENT_BITDEPTH_EL_BL
110          && m_acLayerCfg[layer].m_internalBitDepthY == m_acLayerCfg[idx].m_internalBitDepthY && m_acLayerCfg[layer].m_internalBitDepthC == m_acLayerCfg[idx].m_internalBitDepthC
111#endif
112          )
113        {
114          found = true;
115          break;
116        }
117      }
118      if( !found )
119      {
120        formatIdx++;
121      }
122
123      m_acLayerCfg[layer].setRepFormatIdx( formatIdx );
124    }
125
126    assert( m_acLayerCfg[layer].getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" );
127    vps->setVpsRepFormatIdx( layer, m_acLayerCfg[layer].getRepFormatIdx() );
128    maxRepFormatIdx = std::max( m_acLayerCfg[layer].getRepFormatIdx(), maxRepFormatIdx );
129  }
130  assert( vps->getVpsRepFormatIdx( 0 ) == 0 );  // Base layer should point to the first one.
131  Int* mapIdxToLayer = new Int[maxRepFormatIdx + 1];
132  // Check that all the indices from 0 to maxRepFormatIdx are used in the VPS
133  for(Int i = 0; i <= maxRepFormatIdx; i++)
134  {
135    mapIdxToLayer[i] = -1;
136    UInt layer;
137    for(layer=0; layer < m_numLayers; layer++)
138    {
139      if( vps->getVpsRepFormatIdx(layer) == i )
140      {
141        mapIdxToLayer[i] = layer;
142        break;
143      }
144    }
145    assert( layer != m_numLayers );   // One of the VPS Rep format indices not set
146  }
147  vps->setVpsNumRepFormats( maxRepFormatIdx + 1 );
148  for(UInt idx=0; idx < vps->getVpsNumRepFormats(); idx++)
149  {
150    RepFormat *repFormat = vps->getVpsRepFormat( idx );
151#if REPN_FORMAT_CONTROL_FLAG
152    repFormat->setChromaAndBitDepthVpsPresentFlag( true ); 
153    if (idx==0)
154    {
155      assert(repFormat->getChromaAndBitDepthVpsPresentFlag() == true); 
156    }
157#endif
158    repFormat->setPicWidthVpsInLumaSamples  ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceWidth()   );
159    repFormat->setPicHeightVpsInLumaSamples ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceHeight()  );
160#if AUXILIARY_PICTURES
161    repFormat->setChromaFormatVpsIdc        ( m_acLayerCfg[mapIdxToLayer[idx]].getChromaFormatIDC() );
162#else
163    repFormat->setChromaFormatVpsIdc        ( 1                                             );  // Need modification to change for each layer - corresponds to 420
164#endif
165    repFormat->setSeparateColourPlaneVpsFlag( 0                                             );  // Need modification to change for each layer
166#if O0194_DIFFERENT_BITDEPTH_EL_BL
167    repFormat->setBitDepthVpsLuma           ( getInternalBitDepthY(mapIdxToLayer[idx])      );  // Need modification to change for each layer
168    repFormat->setBitDepthVpsChroma         ( getInternalBitDepthC(mapIdxToLayer[idx])      );  // Need modification to change for each layer
169#else
170    repFormat->setBitDepthVpsLuma           ( getInternalBitDepthY()                        );  // Need modification to change for each layer
171    repFormat->setBitDepthVpsChroma         ( getInternalBitDepthC()                        );  // Need modification to change for each layer
172#endif
173#if HIGHER_LAYER_IRAP_SKIP_FLAG
174    m_acTEncTop[mapIdxToLayer[idx]].setSkipPictureAtArcSwitch( m_skipPictureAtArcSwitch );
175#endif
176  }
177  delete [] mapIdxToLayer;
178#endif
179
180  for(UInt layer=0; layer<m_numLayers; layer++)
181  {
182#if O0194_DIFFERENT_BITDEPTH_EL_BL
183    //1
184    g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
185    g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
186
187    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
188    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
189
190    // Set this to be used in Upsampling filter in function "TComUpsampleFilter::upsampleBasePic"
191    g_bitDepthYLayer[layer] = g_bitDepthY;
192    g_bitDepthCLayer[layer] = g_bitDepthC;
193
194#if O0194_WEIGHTED_PREDICTION_CGS
195    m_acTEncTop[layer].setInterLayerWeightedPredFlag( m_useInterLayerWeightedPred );
196#endif
197#endif
198    //m_acTEncTop[layer].setVPS(&vps);
199    m_acTEncTop[layer].setFrameRate                    ( m_acLayerCfg[layer].getFrameRate() );
200    m_acTEncTop[layer].setFrameSkip                    ( m_FrameSkip );
201    m_acTEncTop[layer].setSourceWidth                  ( m_acLayerCfg[layer].getSourceWidth() );
202    m_acTEncTop[layer].setSourceHeight                 ( m_acLayerCfg[layer].getSourceHeight() );
203    m_acTEncTop[layer].setConformanceMode              ( m_acLayerCfg[layer].getConformanceMode() );
204    m_acTEncTop[layer].setConformanceWindow            ( m_acLayerCfg[layer].m_confLeft, m_acLayerCfg[layer].m_confRight, m_acLayerCfg[layer].m_confTop, m_acLayerCfg[layer].m_confBottom );
205    m_acTEncTop[layer].setFramesToBeEncoded            ( m_framesToBeEncoded );
206
207    m_acTEncTop[layer].setProfile(m_profile);
208    m_acTEncTop[layer].setLevel(m_levelTier, m_level);
209    m_acTEncTop[layer].setProgressiveSourceFlag(m_progressiveSourceFlag);
210    m_acTEncTop[layer].setInterlacedSourceFlag(m_interlacedSourceFlag);
211    m_acTEncTop[layer].setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
212    m_acTEncTop[layer].setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
213
214#if REF_IDX_MFM
215#if AVC_BASE
216    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? AVC_SYNTAX : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers());
217#else
218    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_acLayerCfg[layer].getNumMotionPredRefLayers() > 0 ) );
219#endif
220#endif
221    // set layer ID
222    m_acTEncTop[layer].setLayerId ( layer );
223    m_acTEncTop[layer].setNumLayer ( m_numLayers );
224    m_acTEncTop[layer].setLayerEnc(m_apcTEncTop);
225
226    //====== Coding Structure ========
227    m_acTEncTop[layer].setIntraPeriod                  ( m_acLayerCfg[layer].m_iIntraPeriod );
228    m_acTEncTop[layer].setDecodingRefreshType          ( m_iDecodingRefreshType );
229    m_acTEncTop[layer].setGOPSize                      ( m_iGOPSize );
230    m_acTEncTop[layer].setGopList                      ( m_GOPList );
231
232    m_acTEncTop[layer].setExtraRPSs                    ( m_extraRPSs );
233    for(Int i = 0; i < MAX_TLAYER; i++)
234    {
235      m_acTEncTop[layer].setNumReorderPics             ( m_numReorderPics[i], i );
236      m_acTEncTop[layer].setMaxDecPicBuffering         ( m_maxDecPicBuffering[i], i );
237    }
238    for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
239    {
240      m_acTEncTop[layer].setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
241    }
242    m_acTEncTop[layer].setQP                           ( m_acLayerCfg[layer].getIntQP() );
243
244    m_acTEncTop[layer].setPad                          ( m_acLayerCfg[layer].getPad() );
245
246    m_acTEncTop[layer].setMaxTempLayer                 ( m_maxTempLayer );
247    m_acTEncTop[layer].setUseAMP( m_enableAMP );
248#if N0120_MAX_TID_REF_CFG
249    if (layer<m_numLayers-1)
250    {
251       m_acTEncTop[layer].setMaxTidIlRefPicsPlus1 ( m_acLayerCfg[layer].getMaxTidIlRefPicsPlus1());
252    }
253#endif
254#if VPS_EXTN_DIRECT_REF_LAYERS
255    if(layer)
256    {
257      for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++)
258      {
259        m_acTEncTop[layer].setSamplePredEnabledFlag(i, false);
260        m_acTEncTop[layer].setMotionPredEnabledFlag(i, false);
261      }
262      if(m_acLayerCfg[layer].getNumSamplePredRefLayers() == -1)
263      {
264        // Not included in the configuration file; assume that each layer depends on previous layer
265        m_acTEncTop[layer].setNumSamplePredRefLayers   (1);      // One sample pred ref. layer
266        m_acTEncTop[layer].setSamplePredRefLayerId     (0, layer - 1);   // Previous layer
267        m_acTEncTop[layer].setSamplePredEnabledFlag    (layer - 1, true);
268      }
269      else
270      {
271        m_acTEncTop[layer].setNumSamplePredRefLayers   ( m_acLayerCfg[layer].getNumSamplePredRefLayers() );
272        for(Int i = 0; i < m_acTEncTop[layer].getNumSamplePredRefLayers(); i++)
273        {
274          m_acTEncTop[layer].setSamplePredRefLayerId   ( i, m_acLayerCfg[layer].getSamplePredRefLayerId(i));
275          m_acTEncTop[layer].setSamplePredEnabledFlag  (m_acLayerCfg[layer].getSamplePredRefLayerId(i), true);
276        }
277      }
278      if(m_acLayerCfg[layer].getNumMotionPredRefLayers() == -1)
279      {
280        // Not included in the configuration file; assume that each layer depends on previous layer
281        m_acTEncTop[layer].setNumMotionPredRefLayers   (1);      // One motion pred ref. layer
282        m_acTEncTop[layer].setMotionPredRefLayerId     (0, layer - 1);   // Previous layer
283        m_acTEncTop[layer].setMotionPredEnabledFlag    (layer - 1, true);
284      }
285      else
286      {
287        m_acTEncTop[layer].setNumMotionPredRefLayers   ( m_acLayerCfg[layer].getNumMotionPredRefLayers() );
288        for(Int i = 0; i < m_acTEncTop[layer].getNumMotionPredRefLayers(); i++)
289        {
290          m_acTEncTop[layer].setMotionPredRefLayerId   ( i, m_acLayerCfg[layer].getMotionPredRefLayerId(i));
291          m_acTEncTop[layer].setMotionPredEnabledFlag  (m_acLayerCfg[layer].getMotionPredRefLayerId(i), true);
292        }
293      }
294      Int numDirectRefLayers = 0;
295      for (Int i = 0; i < layer; i++)
296      {
297        if (m_acTEncTop[layer].getSamplePredEnabledFlag(i) || m_acTEncTop[layer].getMotionPredEnabledFlag(i))
298        {
299          m_acTEncTop[layer].setRefLayerId(numDirectRefLayers, i);
300          numDirectRefLayers++;
301        }
302      }
303      m_acTEncTop[layer].setNumDirectRefLayers(numDirectRefLayers);
304
305      if(m_acLayerCfg[layer].getNumActiveRefLayers() == -1)
306      {
307        m_acTEncTop[layer].setNumActiveRefLayers( m_acTEncTop[layer].getNumDirectRefLayers() );
308        for( Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++ )
309        {
310          m_acTEncTop[layer].setPredLayerId(i, i);
311        }
312      }
313      else
314      {
315        m_acTEncTop[layer].setNumActiveRefLayers       ( m_acLayerCfg[layer].getNumActiveRefLayers() );
316        for(Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++)
317        {
318          m_acTEncTop[layer].setPredLayerId             ( i, m_acLayerCfg[layer].getPredLayerId(i));
319        }
320      }
321    }
322#endif //VPS_EXTN_DIRECT_REF_LAYERS
323    //===== Slice ========
324
325    //====== Loop/Deblock Filter ========
326    m_acTEncTop[layer].setLoopFilterDisable            ( m_bLoopFilterDisable       );
327    m_acTEncTop[layer].setLoopFilterOffsetInPPS        ( m_loopFilterOffsetInPPS );
328    m_acTEncTop[layer].setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
329    m_acTEncTop[layer].setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
330    m_acTEncTop[layer].setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
331    m_acTEncTop[layer].setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
332
333    //====== Motion search ========
334    m_acTEncTop[layer].setFastSearch                   ( m_iFastSearch  );
335    m_acTEncTop[layer].setSearchRange                  ( m_iSearchRange );
336    m_acTEncTop[layer].setBipredSearchRange            ( m_bipredSearchRange );
337
338    //====== Quality control ========
339    m_acTEncTop[layer].setMaxDeltaQP                   ( m_iMaxDeltaQP  );
340    m_acTEncTop[layer].setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
341
342    m_acTEncTop[layer].setChromaCbQpOffset             ( m_cbQpOffset     );
343    m_acTEncTop[layer].setChromaCrQpOffset             ( m_crQpOffset  );
344
345#if ADAPTIVE_QP_SELECTION
346    m_acTEncTop[layer].setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
347#endif
348
349    Int lowestQP;
350    lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
351
352    if ((m_iMaxDeltaQP == 0 ) && (m_acLayerCfg[layer].getIntQP() == lowestQP) && (m_useLossless == true))
353    {
354      m_bUseAdaptiveQP = false;
355    }
356    m_acTEncTop[layer].setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
357    m_acTEncTop[layer].setQPAdaptationRange            ( m_iQPAdaptationRange );
358
359    //====== Tool list ========
360    m_acTEncTop[layer].setUseSBACRD                    ( m_bUseSBACRD   );
361    m_acTEncTop[layer].setDeltaQpRD                    ( m_uiDeltaQpRD  );
362    m_acTEncTop[layer].setUseASR                       ( m_bUseASR      );
363    m_acTEncTop[layer].setUseHADME                     ( m_bUseHADME    );
364    m_acTEncTop[layer].setUseLossless                  ( m_useLossless );
365    m_acTEncTop[layer].setdQPs                         ( m_acLayerCfg[layer].getdQPs() );
366    m_acTEncTop[layer].setUseRDOQ                      ( m_useRDOQ     );
367    m_acTEncTop[layer].setUseRDOQTS                    ( m_useRDOQTS   );
368    m_acTEncTop[layer].setRDpenalty                    ( m_rdPenalty );
369#if LAYER_CTB
370    m_acTEncTop[layer].setQuadtreeTULog2MaxSize        ( m_acLayerCfg[layer].m_uiQuadtreeTULog2MaxSize );
371    m_acTEncTop[layer].setQuadtreeTULog2MinSize        ( m_acLayerCfg[layer].m_uiQuadtreeTULog2MinSize );
372    m_acTEncTop[layer].setQuadtreeTUMaxDepthInter      ( m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthInter );
373    m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra      ( m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthIntra );
374#else
375    m_acTEncTop[layer].setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
376    m_acTEncTop[layer].setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
377    m_acTEncTop[layer].setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
378    m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
379#endif
380    m_acTEncTop[layer].setUseFastEnc                   ( m_bUseFastEnc  );
381    m_acTEncTop[layer].setUseEarlyCU                   ( m_bUseEarlyCU  );
382    m_acTEncTop[layer].setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
383    m_acTEncTop[layer].setUseCbfFastMode               ( m_bUseCbfFastMode  );
384    m_acTEncTop[layer].setUseEarlySkipDetection        ( m_useEarlySkipDetection );
385#if FAST_INTRA_SHVC
386    m_acTEncTop[layer].setUseFastIntraScalable         ( m_useFastIntraScalable );
387#endif
388
389    m_acTEncTop[layer].setUseTransformSkip             ( m_useTransformSkip      );
390    m_acTEncTop[layer].setUseTransformSkipFast         ( m_useTransformSkipFast  );
391    m_acTEncTop[layer].setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
392    m_acTEncTop[layer].setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
393    m_acTEncTop[layer].setUsePCM                       ( m_usePCM );
394    m_acTEncTop[layer].setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
395    m_acTEncTop[layer].setMaxNumMergeCand              ( m_maxNumMergeCand );
396
397
398    //====== Weighted Prediction ========
399    m_acTEncTop[layer].setUseWP                   ( m_useWeightedPred      );
400    m_acTEncTop[layer].setWPBiPred                ( m_useWeightedBiPred   );
401#if O0194_WEIGHTED_PREDICTION_CGS
402    if( layer != 0 && m_useInterLayerWeightedPred )
403    {
404      // Enable weighted prediction for enhancement layer
405      m_acTEncTop[layer].setUseWP                 ( true   );
406      m_acTEncTop[layer].setWPBiPred              ( true   );
407    }
408#endif
409    //====== Parallel Merge Estimation ========
410    m_acTEncTop[layer].setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 );
411
412    //====== Slice ========
413    m_acTEncTop[layer].setSliceMode               ( m_sliceMode                );
414    m_acTEncTop[layer].setSliceArgument           ( m_sliceArgument            );
415
416    //====== Dependent Slice ========
417    m_acTEncTop[layer].setSliceSegmentMode        ( m_sliceSegmentMode         );
418    m_acTEncTop[layer].setSliceSegmentArgument    ( m_sliceSegmentArgument     );
419#if LAYER_CTB
420    Int iNumPartInCU = 1<<(m_acLayerCfg[layer].m_uiMaxCUDepth<<1);
421#else
422    Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
423#endif
424    if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU)
425    {
426      m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU );
427    }
428    if(m_sliceMode==FIXED_NUMBER_OF_LCU)
429    {
430      m_acTEncTop[layer].setSliceArgument ( m_sliceArgument * iNumPartInCU );
431    }
432    if(m_sliceMode==FIXED_NUMBER_OF_TILES)
433    {
434      m_acTEncTop[layer].setSliceArgument ( m_sliceArgument );
435    }
436
437    if(m_sliceMode == 0 )
438    {
439      m_bLFCrossSliceBoundaryFlag = true;
440    }
441    m_acTEncTop[layer].setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
442    m_acTEncTop[layer].setUseSAO ( m_bUseSAO );
443    m_acTEncTop[layer].setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
444
445    m_acTEncTop[layer].setSaoLcuBoundary (m_saoLcuBoundary);
446#if !HM_CLEANUP_SAO
447    m_acTEncTop[layer].setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
448#endif
449    m_acTEncTop[layer].setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
450    m_acTEncTop[layer].setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
451
452    m_acTEncTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
453    m_acTEncTop[layer].setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled );
454    m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
455    m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
456    m_acTEncTop[layer].setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
457    m_acTEncTop[layer].setTMISEIToneMapId                           ( m_toneMapId );
458    m_acTEncTop[layer].setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
459    m_acTEncTop[layer].setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
460    m_acTEncTop[layer].setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
461    m_acTEncTop[layer].setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
462    m_acTEncTop[layer].setTMISEIModelID                             ( m_toneMapModelId );
463    m_acTEncTop[layer].setTMISEIMinValue                            ( m_toneMapMinValue );
464    m_acTEncTop[layer].setTMISEIMaxValue                            ( m_toneMapMaxValue );
465    m_acTEncTop[layer].setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
466    m_acTEncTop[layer].setTMISEISigmoidWidth                        ( m_sigmoidWidth );
467    m_acTEncTop[layer].setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
468    m_acTEncTop[layer].setTMISEINumPivots                           ( m_numPivots );
469    m_acTEncTop[layer].setTMISEICodedPivotValue                     ( m_codedPivotValue );
470    m_acTEncTop[layer].setTMISEITargetPivotValue                    ( m_targetPivotValue );
471    m_acTEncTop[layer].setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
472    m_acTEncTop[layer].setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
473    m_acTEncTop[layer].setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
474    m_acTEncTop[layer].setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
475    m_acTEncTop[layer].setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
476    m_acTEncTop[layer].setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
477    m_acTEncTop[layer].setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
478    m_acTEncTop[layer].setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
479    m_acTEncTop[layer].setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
480    m_acTEncTop[layer].setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
481    m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
482    m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType );
483    m_acTEncTop[layer].setFramePackingArrangementSEIId( m_framePackingSEIId );
484    m_acTEncTop[layer].setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx );
485    m_acTEncTop[layer].setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation );
486    m_acTEncTop[layer].setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle );
487    m_acTEncTop[layer].setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled );
488    m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
489    m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
490#if LAYERS_NOT_PRESENT_SEI
491    m_acTEncTop[layer].setLayersNotPresentSEIEnabled( m_layersNotPresentSEIEnabled );
492#endif
493    m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
494    m_acTEncTop[layer].setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
495#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
496    m_acTEncTop[layer].setInterLayerConstrainedTileSetsSEIEnabled( m_interLayerConstrainedTileSetsSEIEnabled );
497    m_acTEncTop[layer].setIlNumSetsInMessage( m_ilNumSetsInMessage );
498    m_acTEncTop[layer].setSkippedTileSetPresentFlag( m_skippedTileSetPresentFlag );
499    m_acTEncTop[layer].setTopLeftTileIndex( m_topLeftTileIndex );
500    m_acTEncTop[layer].setBottomRightTileIndex( m_bottomRightTileIndex );
501    m_acTEncTop[layer].setIlcIdc( m_ilcIdc );
502#endif
503    m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
504    m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
505    m_acTEncTop[layer].setNumRowsMinus1              ( m_iNumRowsMinus1 );
506    if(m_iUniformSpacingIdr==0)
507    {
508      m_acTEncTop[layer].setColumnWidth              ( m_pColumnWidth );
509      m_acTEncTop[layer].setRowHeight                ( m_pRowHeight );
510    }
511    m_acTEncTop[layer].xCheckGSParameters();
512    Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
513    if(uiTilesCount == 1)
514    {
515      m_bLFCrossTileBoundaryFlag = true;
516    }
517    m_acTEncTop[layer].setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
518    m_acTEncTop[layer].setWaveFrontSynchro           ( m_iWaveFrontSynchro );
519    m_acTEncTop[layer].setWaveFrontSubstreams        ( m_acLayerCfg[layer].m_iWaveFrontSubstreams );
520    m_acTEncTop[layer].setTMVPModeId ( m_TMVPModeId );
521    m_acTEncTop[layer].setUseScalingListId           ( m_useScalingListId  );
522    m_acTEncTop[layer].setScalingListFile            ( m_scalingListFile   );
523    m_acTEncTop[layer].setSignHideFlag(m_signHideFlag);
524#if RC_SHVC_HARMONIZATION
525    m_acTEncTop[layer].setUseRateCtrl     (m_acLayerCfg[layer].getRCEnableRateControl());
526    m_acTEncTop[layer].setTargetBitrate   (m_acLayerCfg[layer].getRCTargetBitrate());
527    m_acTEncTop[layer].setKeepHierBit     (m_acLayerCfg[layer].getRCKeepHierarchicalBit());
528    m_acTEncTop[layer].setLCULevelRC      (m_acLayerCfg[layer].getRCLCULevelRC());
529    m_acTEncTop[layer].setUseLCUSeparateModel (m_acLayerCfg[layer].getRCUseLCUSeparateModel());
530    m_acTEncTop[layer].setInitialQP           (m_acLayerCfg[layer].getRCInitialQP());
531    m_acTEncTop[layer].setForceIntraQP        (m_acLayerCfg[layer].getRCForceIntraQP());
532#else
533    m_acTEncTop[layer].setUseRateCtrl         ( m_RCEnableRateControl );
534    m_acTEncTop[layer].setTargetBitrate       ( m_RCTargetBitrate );
535    m_acTEncTop[layer].setKeepHierBit         ( m_RCKeepHierarchicalBit );
536    m_acTEncTop[layer].setLCULevelRC          ( m_RCLCULevelRC );
537    m_acTEncTop[layer].setUseLCUSeparateModel ( m_RCUseLCUSeparateModel );
538    m_acTEncTop[layer].setInitialQP           ( m_RCInitialQP );
539    m_acTEncTop[layer].setForceIntraQP        ( m_RCForceIntraQP );
540#endif
541    m_acTEncTop[layer].setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
542    m_acTEncTop[layer].setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue);
543    m_acTEncTop[layer].setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
544    m_acTEncTop[layer].setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
545    m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
546    m_acTEncTop[layer].setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
547    m_acTEncTop[layer].setAspectRatioIdc( m_aspectRatioIdc );
548    m_acTEncTop[layer].setSarWidth( m_sarWidth );
549    m_acTEncTop[layer].setSarHeight( m_sarHeight );
550    m_acTEncTop[layer].setOverscanInfoPresentFlag( m_overscanInfoPresentFlag );
551    m_acTEncTop[layer].setOverscanAppropriateFlag( m_overscanAppropriateFlag );
552    m_acTEncTop[layer].setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag );
553    m_acTEncTop[layer].setVideoFormat( m_videoFormat );
554    m_acTEncTop[layer].setVideoFullRangeFlag( m_videoFullRangeFlag );
555    m_acTEncTop[layer].setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag );
556    m_acTEncTop[layer].setColourPrimaries( m_colourPrimaries );
557    m_acTEncTop[layer].setTransferCharacteristics( m_transferCharacteristics );
558    m_acTEncTop[layer].setMatrixCoefficients( m_matrixCoefficients );
559    m_acTEncTop[layer].setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag );
560    m_acTEncTop[layer].setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField );
561    m_acTEncTop[layer].setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField );
562    m_acTEncTop[layer].setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag );
563    m_acTEncTop[layer].setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
564    m_acTEncTop[layer].setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag );
565    m_acTEncTop[layer].setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag );
566    m_acTEncTop[layer].setNumTicksPocDiffOneMinus1   ( m_numTicksPocDiffOneMinus1    );
567    m_acTEncTop[layer].setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag );
568    m_acTEncTop[layer].setTilesFixedStructureFlag( m_tilesFixedStructureFlag );
569    m_acTEncTop[layer].setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag );
570    m_acTEncTop[layer].setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc );
571    m_acTEncTop[layer].setMaxBytesPerPicDenom( m_maxBytesPerPicDenom );
572    m_acTEncTop[layer].setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom );
573    m_acTEncTop[layer].setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
574    m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
575    m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled);
576    if( layer > 0 )
577    {
578      m_acTEncTop[layer].setNumScaledRefLayerOffsets( m_acLayerCfg[layer].m_numScaledRefLayerOffsets );
579      for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
580      {
581#if O0098_SCALED_REF_LAYER_ID
582        m_acTEncTop[layer].setScaledRefLayerId(i, m_acLayerCfg[layer].m_scaledRefLayerId[i]);
583#endif
584        m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i],
585                                                  2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]);
586      }
587    }
588#if M0040_ADAPTIVE_RESOLUTION_CHANGE
589    m_acTEncTop[layer].setAdaptiveResolutionChange( m_adaptiveResolutionChange );
590#endif
591#if AUXILIARY_PICTURES
592    m_acTEncTop[layer].setChromaFormatIDC( m_acLayerCfg[layer].m_chromaFormatIDC );
593#endif
594#if O0153_ALT_OUTPUT_LAYER_FLAG
595    m_acTEncTop[layer].setAltOuputLayerFlag( m_altOutputLayerFlag );
596#endif
597#if O0149_CROSS_LAYER_BLA_FLAG
598    m_acTEncTop[layer].setCrossLayerBLAFlag( m_crossLayerBLAFlag );
599#endif
600  }
601}
602#else //SVC_EXTENSION
603Void TAppEncTop::xInitLibCfg()
604{
605  TComVPS vps;
606
607  vps.setMaxTLayers                       ( m_maxTempLayer );
608  if (m_maxTempLayer == 1)
609  {
610    vps.setTemporalNestingFlag(true);
611  }
612  vps.setMaxLayers                        ( 1 );
613  for(Int i = 0; i < MAX_TLAYER; i++)
614  {
615    vps.setNumReorderPics                 ( m_numReorderPics[i], i );
616    vps.setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
617  }
618  m_cTEncTop.setVPS(&vps);
619
620  m_cTEncTop.setProfile(m_profile);
621  m_cTEncTop.setLevel(m_levelTier, m_level);
622  m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag);
623  m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag);
624  m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
625  m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
626
627  m_cTEncTop.setFrameRate                    ( m_iFrameRate );
628  m_cTEncTop.setFrameSkip                    ( m_FrameSkip );
629  m_cTEncTop.setSourceWidth                  ( m_iSourceWidth );
630  m_cTEncTop.setSourceHeight                 ( m_iSourceHeight );
631  m_cTEncTop.setConformanceWindow            ( m_confLeft, m_confRight, m_confTop, m_confBottom );
632  m_cTEncTop.setFramesToBeEncoded            ( m_framesToBeEncoded );
633
634  //====== Coding Structure ========
635  m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod );
636  m_cTEncTop.setDecodingRefreshType          ( m_iDecodingRefreshType );
637  m_cTEncTop.setGOPSize                      ( m_iGOPSize );
638  m_cTEncTop.setGopList                      ( m_GOPList );
639  m_cTEncTop.setExtraRPSs                    ( m_extraRPSs );
640  for(Int i = 0; i < MAX_TLAYER; i++)
641  {
642    m_cTEncTop.setNumReorderPics             ( m_numReorderPics[i], i );
643    m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBuffering[i], i );
644  }
645  for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
646  {
647    m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
648  }
649  m_cTEncTop.setQP                           ( m_iQP );
650
651  m_cTEncTop.setPad                          ( m_aiPad );
652
653  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayer );
654  m_cTEncTop.setUseAMP( m_enableAMP );
655
656  //===== Slice ========
657
658  //====== Loop/Deblock Filter ========
659  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable       );
660  m_cTEncTop.setLoopFilterOffsetInPPS        ( m_loopFilterOffsetInPPS );
661  m_cTEncTop.setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
662  m_cTEncTop.setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
663  m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
664  m_cTEncTop.setDeblockingFilterMetric       ( m_DeblockingFilterMetric );
665
666  //====== Motion search ========
667  m_cTEncTop.setFastSearch                   ( m_iFastSearch  );
668  m_cTEncTop.setSearchRange                  ( m_iSearchRange );
669  m_cTEncTop.setBipredSearchRange            ( m_bipredSearchRange );
670
671  //====== Quality control ========
672  m_cTEncTop.setMaxDeltaQP                   ( m_iMaxDeltaQP  );
673  m_cTEncTop.setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
674
675  m_cTEncTop.setChromaCbQpOffset               ( m_cbQpOffset     );
676  m_cTEncTop.setChromaCrQpOffset            ( m_crQpOffset  );
677
678#if ADAPTIVE_QP_SELECTION
679  m_cTEncTop.setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
680#endif
681
682  Int lowestQP;
683  lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
684
685  if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true))
686  {
687    m_bUseAdaptiveQP = false;
688  }
689  m_cTEncTop.setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
690  m_cTEncTop.setQPAdaptationRange            ( m_iQPAdaptationRange );
691
692  //====== Tool list ========
693  m_cTEncTop.setUseSBACRD                    ( m_bUseSBACRD   );
694  m_cTEncTop.setDeltaQpRD                    ( m_uiDeltaQpRD  );
695  m_cTEncTop.setUseASR                       ( m_bUseASR      );
696  m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
697  m_cTEncTop.setUseLossless                  ( m_useLossless );
698  m_cTEncTop.setdQPs                         ( m_aidQP        );
699  m_cTEncTop.setUseRDOQ                      ( m_useRDOQ     );
700  m_cTEncTop.setUseRDOQTS                    ( m_useRDOQTS   );
701  m_cTEncTop.setRDpenalty                 ( m_rdPenalty );
702  m_cTEncTop.setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
703  m_cTEncTop.setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
704  m_cTEncTop.setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
705  m_cTEncTop.setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
706  m_cTEncTop.setUseFastEnc                   ( m_bUseFastEnc  );
707  m_cTEncTop.setUseEarlyCU                   ( m_bUseEarlyCU  );
708  m_cTEncTop.setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
709  m_cTEncTop.setUseCbfFastMode            ( m_bUseCbfFastMode  );
710  m_cTEncTop.setUseEarlySkipDetection            ( m_useEarlySkipDetection );
711#if FAST_INTRA_SHVC
712  m_cTEncTop.setUseFastIntraScalable            ( m_useFastIntraScalable );
713#endif
714
715  m_cTEncTop.setUseTransformSkip             ( m_useTransformSkip      );
716  m_cTEncTop.setUseTransformSkipFast         ( m_useTransformSkipFast  );
717  m_cTEncTop.setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
718  m_cTEncTop.setPCMLog2MinSize          ( m_uiPCMLog2MinSize);
719  m_cTEncTop.setUsePCM                       ( m_usePCM );
720  m_cTEncTop.setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
721  m_cTEncTop.setMaxNumMergeCand              ( m_maxNumMergeCand );
722
723
724  //====== Weighted Prediction ========
725  m_cTEncTop.setUseWP                   ( m_useWeightedPred      );
726  m_cTEncTop.setWPBiPred                ( m_useWeightedBiPred   );
727  //====== Parallel Merge Estimation ========
728  m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 );
729
730  //====== Slice ========
731  m_cTEncTop.setSliceMode               ( m_sliceMode                );
732  m_cTEncTop.setSliceArgument           ( m_sliceArgument            );
733
734  //====== Dependent Slice ========
735  m_cTEncTop.setSliceSegmentMode        ( m_sliceSegmentMode         );
736  m_cTEncTop.setSliceSegmentArgument    ( m_sliceSegmentArgument     );
737  Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
738  if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU)
739  {
740    m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU );
741  }
742  if(m_sliceMode==FIXED_NUMBER_OF_LCU)
743  {
744    m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU );
745  }
746  if(m_sliceMode==FIXED_NUMBER_OF_TILES)
747  {
748    m_cTEncTop.setSliceArgument ( m_sliceArgument );
749  }
750
751  if(m_sliceMode == 0 )
752  {
753    m_bLFCrossSliceBoundaryFlag = true;
754  }
755  m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
756  m_cTEncTop.setUseSAO ( m_bUseSAO );
757  m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
758
759  m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary);
760#if !HM_CLEANUP_SAO
761  m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
762#endif
763  m_cTEncTop.setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
764  m_cTEncTop.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
765
766  m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
767  m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled );
768  m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
769  m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
770  m_cTEncTop.setToneMappingInfoSEIEnabled                 ( m_toneMappingInfoSEIEnabled );
771  m_cTEncTop.setTMISEIToneMapId                           ( m_toneMapId );
772  m_cTEncTop.setTMISEIToneMapCancelFlag                   ( m_toneMapCancelFlag );
773  m_cTEncTop.setTMISEIToneMapPersistenceFlag              ( m_toneMapPersistenceFlag );
774  m_cTEncTop.setTMISEICodedDataBitDepth                   ( m_toneMapCodedDataBitDepth );
775  m_cTEncTop.setTMISEITargetBitDepth                      ( m_toneMapTargetBitDepth );
776  m_cTEncTop.setTMISEIModelID                             ( m_toneMapModelId );
777  m_cTEncTop.setTMISEIMinValue                            ( m_toneMapMinValue );
778  m_cTEncTop.setTMISEIMaxValue                            ( m_toneMapMaxValue );
779  m_cTEncTop.setTMISEISigmoidMidpoint                     ( m_sigmoidMidpoint );
780  m_cTEncTop.setTMISEISigmoidWidth                        ( m_sigmoidWidth );
781  m_cTEncTop.setTMISEIStartOfCodedInterva                 ( m_startOfCodedInterval );
782  m_cTEncTop.setTMISEINumPivots                           ( m_numPivots );
783  m_cTEncTop.setTMISEICodedPivotValue                     ( m_codedPivotValue );
784  m_cTEncTop.setTMISEITargetPivotValue                    ( m_targetPivotValue );
785  m_cTEncTop.setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
786  m_cTEncTop.setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
787  m_cTEncTop.setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
788  m_cTEncTop.setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
789  m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc   ( m_exposureCompensationValueDenomIdc );
790  m_cTEncTop.setTMISEIRefScreenLuminanceWhite             ( m_refScreenLuminanceWhite );
791  m_cTEncTop.setTMISEIExtendedRangeWhiteLevel             ( m_extendedRangeWhiteLevel );
792  m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue      ( m_nominalBlackLevelLumaCodeValue );
793  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
794  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
795  m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
796  m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType );
797  m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId );
798  m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx );
799  m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation );
800  m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle );
801  m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled );
802  m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
803  m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
804#if LAYERS_NOT_PRESENT_SEI
805  m_cTEncTop.setLayersNotPresentSEIEnabled( m_layersNotPresentSEIEnabled );
806#endif
807  m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
808  m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
809  m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
810  m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
811  m_cTEncTop.setNumRowsMinus1              ( m_iNumRowsMinus1 );
812  if(m_iUniformSpacingIdr==0)
813  {
814    m_cTEncTop.setColumnWidth              ( m_pColumnWidth );
815    m_cTEncTop.setRowHeight                ( m_pRowHeight );
816  }
817  m_cTEncTop.xCheckGSParameters();
818  Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
819  if(uiTilesCount == 1)
820  {
821    m_bLFCrossTileBoundaryFlag = true;
822  }
823  m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
824  m_cTEncTop.setWaveFrontSynchro           ( m_iWaveFrontSynchro );
825  m_cTEncTop.setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
826  m_cTEncTop.setTMVPModeId ( m_TMVPModeId );
827  m_cTEncTop.setUseScalingListId           ( m_useScalingListId  );
828  m_cTEncTop.setScalingListFile            ( m_scalingListFile   );
829  m_cTEncTop.setSignHideFlag(m_signHideFlag);
830  m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
831  m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
832  m_cTEncTop.setKeepHierBit         ( m_RCKeepHierarchicalBit );
833  m_cTEncTop.setLCULevelRC          ( m_RCLCULevelRC );
834  m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel );
835  m_cTEncTop.setInitialQP           ( m_RCInitialQP );
836  m_cTEncTop.setForceIntraQP        ( m_RCForceIntraQP );
837  m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
838  m_cTEncTop.setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue);
839  m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
840  m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
841  m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
842  m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
843  m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc );
844  m_cTEncTop.setSarWidth( m_sarWidth );
845  m_cTEncTop.setSarHeight( m_sarHeight );
846  m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag );
847  m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag );
848  m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag );
849  m_cTEncTop.setVideoFormat( m_videoFormat );
850  m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag );
851  m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag );
852  m_cTEncTop.setColourPrimaries( m_colourPrimaries );
853  m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics );
854  m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients );
855  m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag );
856  m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField );
857  m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField );
858  m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag );
859  m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
860  m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag );
861  m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag );
862  m_cTEncTop.setNumTicksPocDiffOneMinus1   ( m_numTicksPocDiffOneMinus1    );
863  m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag );
864  m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag );
865  m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag );
866  m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc );
867  m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom );
868  m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom );
869  m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
870  m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
871}
872#endif //SVC_EXTENSION
873
874Void TAppEncTop::xCreateLib()
875{
876  // Video I/O
877#if SVC_EXTENSION
878  // initialize global variables
879  initROM();
880
881  for(UInt layer=0; layer<m_numLayers; layer++)
882  {
883#if O0194_DIFFERENT_BITDEPTH_EL_BL
884    //2
885    g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
886    g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
887
888    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
889    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
890#endif
891#if LAYER_CTB
892    g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
893    g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer];
894    g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
895    g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
896#endif
897#if O0194_DIFFERENT_BITDEPTH_EL_BL
898    m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(),  false, m_acLayerCfg[layer].m_inputBitDepthY, m_acLayerCfg[layer].m_inputBitDepthC, m_acLayerCfg[layer].m_internalBitDepthY, m_acLayerCfg[layer].m_internalBitDepthC );  // read  mode
899#else
900    m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(),  false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
901#endif
902    m_acTVideoIOYuvInputFile[layer].skipFrames(m_FrameSkip, m_acLayerCfg[layer].getSourceWidth() - m_acLayerCfg[layer].getPad()[0], m_acLayerCfg[layer].getSourceHeight() - m_acLayerCfg[layer].getPad()[1]);
903
904    if (!m_acLayerCfg[layer].getReconFile().empty())
905    {
906#if O0194_DIFFERENT_BITDEPTH_EL_BL
907      m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_acLayerCfg[layer].m_outputBitDepthY, m_acLayerCfg[layer].m_outputBitDepthC, m_acLayerCfg[layer].m_internalBitDepthY, m_acLayerCfg[layer].m_internalBitDepthC );  // write mode
908#else
909      m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // write mode
910#endif
911    }
912
913    m_acTEncTop[layer].create();
914  }
915#else //SVC_EXTENSION
916  m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
917  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
918
919  if (m_pchReconFile)
920    m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
921
922  // Neo Decoder
923  m_cTEncTop.create();
924#endif //SVC_EXTENSION
925}
926
927Void TAppEncTop::xDestroyLib()
928{
929  // Video I/O
930#if SVC_EXTENSION
931  // destroy ROM
932  destroyROM();
933
934  for(UInt layer=0; layer<m_numLayers; layer++)
935  {
936#if LAYER_CTB
937    g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
938    g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer];
939    g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
940    g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
941#endif
942
943    m_acTVideoIOYuvInputFile[layer].close();
944    m_acTVideoIOYuvReconFile[layer].close();
945
946    m_acTEncTop[layer].destroy();
947  }
948#else //SVC_EXTENSION
949  m_cTVideoIOYuvInputFile.close();
950  m_cTVideoIOYuvReconFile.close();
951
952  // Neo Decoder
953  m_cTEncTop.destroy();
954#endif //SVC_EXTENSION
955}
956
957Void TAppEncTop::xInitLib(Bool isFieldCoding)
958{
959#if SVC_EXTENSION
960  for(UInt layer=0; layer<m_numLayers; layer++)
961  {
962#if O0194_DIFFERENT_BITDEPTH_EL_BL
963    //3
964    g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
965    g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
966
967    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
968    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
969#endif
970#if LAYER_CTB
971    g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
972    g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer];
973    g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
974    g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
975
976    memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) );
977    memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) );
978    memcpy( g_auiRasterToPelX,  g_auiLayerRasterToPelX[layer],  sizeof( g_auiRasterToPelX ) );
979    memcpy( g_auiRasterToPelY,  g_auiLayerRasterToPelY[layer],  sizeof( g_auiRasterToPelY ) );
980#endif
981    m_acTEncTop[layer].init(isFieldCoding);
982  }
983#if VPS_RENAME
984  m_acTEncTop[0].getVPS()->setMaxLayers( m_numLayers );
985#endif
986#if VPS_EXTN_OP_LAYER_SETS
987  TComVPS* vps = m_acTEncTop[0].getVPS();
988  vps->setMaxLayerId(m_numLayers - 1);    // Set max-layer ID
989
990  vps->setNumLayerSets(m_numLayers);
991  for(Int setId = 1; setId < vps->getNumLayerSets(); setId++)
992  {
993    for(Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++)
994    {
995#if O0194_DIFFERENT_BITDEPTH_EL_BL
996      //4
997      g_bitDepthY = m_acLayerCfg[layerId].m_internalBitDepthY;
998      g_bitDepthC = m_acLayerCfg[layerId].m_internalBitDepthC;
999
1000      g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthY : m_acLayerCfg[layerId].m_internalBitDepthY;
1001      g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthC : m_acLayerCfg[layerId].m_internalBitDepthC;
1002#endif
1003      vps->setLayerIdIncludedFlag(true, setId, layerId);
1004    }
1005  }
1006#if VPS_EXTN_MASK_AND_DIM_INFO
1007  UInt i = 0, dimIdLen = 0;
1008#if AVC_BASE
1009  vps->setAvcBaseLayerFlag(m_avcBaseLayerFlag);
1010#else
1011  vps->setAvcBaseLayerFlag(false);
1012#endif
1013  vps->setSplittingFlag(false);
1014  for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++)
1015  {
1016    vps->setScalabilityMask(i, false);
1017  }
1018  if(m_numLayers > 1)
1019  {
1020    Int scalabilityTypes = 0;
1021    for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++)
1022    {
1023      vps->setScalabilityMask(i, m_scalabilityMask[i]);
1024      scalabilityTypes += m_scalabilityMask[i];
1025    }
1026#if AUXILIARY_PICTURES
1027    assert( scalabilityTypes <= 2 );
1028#else
1029    assert( scalabilityTypes == 1 );
1030#endif
1031    vps->setNumScalabilityTypes(scalabilityTypes);
1032  }
1033  else
1034  {
1035    vps->setNumScalabilityTypes(0);
1036  }
1037  while((1 << dimIdLen) < m_numLayers)
1038  {
1039    dimIdLen++;
1040  }
1041  vps->setDimensionIdLen(0, dimIdLen);
1042  vps->setNuhLayerIdPresentFlag(false);
1043  vps->setLayerIdInNuh(0, 0);
1044  vps->setLayerIdInVps(0, 0);
1045  for(i = 1; i < vps->getMaxLayers(); i++)
1046  {
1047    vps->setLayerIdInNuh(i, i);
1048    vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i);
1049    vps->setDimensionId(i, 0, i);
1050  }
1051#if AUXILIARY_PICTURES
1052  if (m_scalabilityMask[3])
1053  {
1054    UInt maxAuxId = 0;
1055    UInt auxDimIdLen = 1;
1056    for(i = 1; i < vps->getMaxLayers(); i++)
1057    {
1058      if (m_acLayerCfg[i].getAuxId() > maxAuxId)
1059      {
1060        maxAuxId = m_acLayerCfg[i].getAuxId();
1061      }
1062    }
1063    while((1 << auxDimIdLen) < (maxAuxId + 1))
1064    {
1065      auxDimIdLen++;
1066    }
1067    vps->setDimensionIdLen(1, auxDimIdLen);
1068    for(i = 1; i < vps->getMaxLayers(); i++)
1069    {
1070      vps->setDimensionId(i, 1, m_acLayerCfg[i].getAuxId());
1071    }
1072  }
1073#endif
1074#endif
1075#if VPS_TSLAYERS
1076    vps->setMaxTSLayersPresentFlag(true);
1077    for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
1078    {
1079        vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
1080    }
1081#endif
1082#if N0120_MAX_TID_REF_PRESENT_FLAG
1083#if N0120_MAX_TID_REF_CFG
1084  vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag);
1085#else
1086  vps->setMaxTidRefPresentFlag(true);
1087#endif
1088  if (vps->getMaxTidRefPresentFlag())
1089  {
1090    for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
1091    {
1092#if N0120_MAX_TID_REF_CFG
1093#if O0225_MAX_TID_FOR_REF_LAYERS
1094      for( Int j = i+1; j <= MAX_VPS_LAYER_ID_PLUS1 - 1; j++)
1095      {
1096        vps->setMaxTidIlRefPicsPlus1(i, j, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
1097      }
1098#else
1099      vps->setMaxTidIlRefPicsPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
1100#endif
1101#else
1102#if O0225_MAX_TID_FOR_REF_LAYERS
1103      for( Int j = i+1; j <= MAX_VPS_LAYER_ID_PLUS1 - 1; j++)
1104      {
1105        vps->setMaxTidIlRefPicsPlus1(i, j, vps->getMaxTLayers()+1);
1106      }
1107#else
1108      vps->setMaxTidIlRefPicsPlus1(i, vps->getMaxTLayers()+1);
1109#endif
1110#endif
1111    }
1112  }
1113  else
1114  {
1115    for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
1116    {
1117#if O0225_MAX_TID_FOR_REF_LAYERS
1118      for( Int j = i+1; j <= MAX_VPS_LAYER_ID_PLUS1 - 1; j++)
1119      {
1120        vps->setMaxTidIlRefPicsPlus1(i, j, 7);
1121      }
1122#else
1123      vps->setMaxTidIlRefPicsPlus1(i, 7);
1124#endif
1125    }
1126  }
1127#endif
1128#if ILP_SSH_SIG
1129#if ILP_SSH_SIG_FIX
1130    vps->setIlpSshSignalingEnabledFlag(false);
1131#else
1132    vps->setIlpSshSignalingEnabledFlag(true);
1133#endif
1134#endif
1135#if VPS_EXTN_PROFILE_INFO
1136  vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets());
1137  for(Int setId = 1; setId < vps->getNumLayerSets(); setId++)
1138  {
1139    vps->setProfilePresentFlag(setId, true);
1140    // Note - may need to be changed for other layer structures.
1141    *(vps->getPTLForExtn(setId)) = *(m_acTEncTop[setId].getSPS()->getPTL());
1142  }
1143#endif
1144  // Target output layer
1145  vps->setNumOutputLayerSets(vps->getNumLayerSets());
1146  vps->setNumProfileTierLevel(vps->getNumLayerSets());
1147#if P0295_DEFAULT_OUT_LAYER_IDC
1148  vps->setDefaultTargetOutputLayerIdc(1);
1149#else
1150#if O0109_DEFAULT_ONE_OUT_LAYER_IDC
1151  vps->setDefaultOneTargetOutputLayerIdc(1);
1152#else
1153  vps->setDefaultOneTargetOutputLayerFlag(true);
1154#endif
1155#endif
1156  for(i = 1; i < vps->getNumLayerSets(); i++)
1157  {
1158    vps->setProfileLevelTierIdx(i, i);
1159    vps->setOutputLayerSetIdx(i, i);
1160  }
1161
1162  for(Int lsIdx = 1; lsIdx < vps->getNumLayerSets(); lsIdx++)
1163  {
1164    // Include the highest layer as output layer
1165    for(UInt layer=0; layer <= vps->getMaxLayerId() ; layer++)
1166    {
1167      if(vps->getLayerIdIncludedFlag(lsIdx, layer))
1168      {
1169        vps->setOutputLayerFlag(lsIdx, layer, layer == (vps->getMaxLayerId()));
1170      }
1171    }
1172  }
1173#endif
1174 #if VPS_DPB_SIZE_TABLE
1175  // The Layer ID List variables can be derived here. 
1176#if DERIVE_LAYER_ID_LIST_VARIABLES
1177  vps->deriveLayerIdListVariables();
1178#endif
1179#if RESOLUTION_BASED_DPB
1180  vps->assignSubDpbIndices();
1181#else
1182  vps->deriveNumberOfSubDpbs();
1183#endif
1184  // Initialize dpb_size_table() for all ouput layer sets in the VPS extension
1185  for(i = 1; i < vps->getNumOutputLayerSets(); i++)
1186  {
1187#if CHANGE_NUMSUBDPB_IDX
1188    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i );
1189#endif
1190    Int layerSetId = vps->getOutputLayerSetIdx(i);
1191
1192    for(Int j = 0; j < vps->getMaxTLayers(); j++)
1193    {
1194
1195      Int maxNumReorderPics = -1;
1196#if CHANGE_NUMSUBDPB_IDX
1197#if RESOLUTION_BASED_DPB
1198      for(Int k = 0; k < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); k++)
1199#else
1200      for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++)
1201#endif
1202#else
1203      for(Int k = 0; k < vps->getNumSubDpbs(i); k++)
1204#endif
1205      {
1206        Int layerId = vps->getLayerSetLayerIdList(layerSetId, k); // k-th layer in the output layer set
1207#if RESOLUTION_BASED_DPB
1208        vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, m_acTEncTop[layerId].getMaxDecPicBuffering(j) - 1 );
1209        // Add sub-DPB sizes of layers belonging to a sub-DPB. If a different sub-DPB size is calculated
1210        // at the encoder, modify below
1211        Int oldValue = vps->getMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j );
1212        oldValue += vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j );
1213        vps->setMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j, oldValue );
1214#else
1215        vps->setMaxVpsDecPicBufferingMinus1( i, k, j,  m_acTEncTop[layerId].getMaxDecPicBuffering(j) - 1 );
1216#endif
1217        maxNumReorderPics       = std::max( maxNumReorderPics, m_acTEncTop[layerId].getNumReorderPics(j));
1218      }
1219      vps->setMaxVpsNumReorderPics(i, j, maxNumReorderPics);
1220      vps->determineSubDpbInfoFlags();
1221    }
1222  }
1223#endif
1224#if VPS_EXTN_DIRECT_REF_LAYERS
1225  // Direct reference layers
1226  UInt maxDirectRefLayers = 0;
1227#if O0096_DEFAULT_DEPENDENCY_TYPE
1228  Bool isDefaultDirectDependencyTypeSet = false;
1229#endif
1230  for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
1231  {
1232    vps->setNumDirectRefLayers( layerCtr, m_acTEncTop[layerCtr].getNumDirectRefLayers() );
1233    maxDirectRefLayers = max<UInt>( maxDirectRefLayers, vps->getNumDirectRefLayers( layerCtr ) );
1234
1235    for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++)
1236    {
1237      vps->setRefLayerId( layerCtr, i, m_acTEncTop[layerCtr].getRefLayerId(i) );
1238    }
1239    // Set direct dependency flag
1240    // Initialize flag to 0
1241    for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
1242    {
1243      vps->setDirectDependencyFlag( layerCtr, refLayerCtr, false );
1244    }
1245    for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++)
1246    {
1247      vps->setDirectDependencyFlag( layerCtr, vps->getLayerIdInVps(m_acTEncTop[layerCtr].getRefLayerId(i)), true);
1248    }
1249    // prediction indications
1250    vps->setDirectDepTypeLen(2); // sample and motion types are encoded
1251    for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
1252    {
1253      if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr))
1254      {
1255        assert(m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) || m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr));
1256        vps->setDirectDependencyType( layerCtr, refLayerCtr, ((m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) ? 1 : 0) |
1257                                                              (m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr) ? 2 : 0)) - 1);
1258#if O0096_DEFAULT_DEPENDENCY_TYPE
1259        if (!isDefaultDirectDependencyTypeSet)
1260        {
1261          vps->setDefaultDirectDependecyTypeFlag(1);
1262          vps->setDefaultDirectDependecyType(vps->getDirectDependencyType(layerCtr, refLayerCtr));
1263          isDefaultDirectDependencyTypeSet = true;
1264        }
1265        else if (vps->getDirectDependencyType(layerCtr, refLayerCtr) != vps->getDefaultDirectDependencyType())
1266        {
1267          vps->setDefaultDirectDependecyTypeFlag(0);
1268        }
1269#endif
1270      }
1271      else
1272      {
1273        vps->setDirectDependencyType( layerCtr, refLayerCtr, 0 );
1274      }
1275    }
1276  }
1277
1278#if O0092_0094_DEPENDENCY_CONSTRAINT
1279  for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
1280  {
1281    vps->setNumRefLayers(vps->getLayerIdInNuh(layerCtr));   // identify the number of direct and indirect reference layers of current layer and set recursiveRefLayersFlags
1282  }
1283  if(vps->getMaxLayers() > MAX_REF_LAYERS)
1284  {
1285    for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
1286    {
1287      assert( vps->getNumRefLayers(vps->getLayerIdInNuh(layerCtr)) <= MAX_REF_LAYERS);
1288    }
1289  }
1290#endif
1291#endif
1292    vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true);
1293#if O0062_POC_LSB_NOT_PRESENT_FLAG
1294    for(i = 1; i< vps->getMaxLayers(); i++)
1295    {
1296      if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0  )
1297      {
1298        vps->setPocLsbNotPresentFlag(i, false);
1299      }
1300    }
1301#endif
1302#if O0223_PICTURE_TYPES_ALIGN_FLAG
1303    vps->setCrossLayerPictureTypeAlignFlag( m_crossLayerPictureTypeAlignFlag );
1304#endif
1305#if N0147_IRAP_ALIGN_FLAG
1306    vps->setCrossLayerIrapAlignFlag( m_crossLayerIrapAlignFlag );
1307    for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
1308    {
1309      for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
1310      {
1311        if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr))
1312        {
1313          if(m_acTEncTop[layerCtr].getIntraPeriod() !=  m_acTEncTop[refLayerCtr].getIntraPeriod())
1314          {
1315            vps->setCrossLayerIrapAlignFlag(false);
1316            break;
1317          }
1318        }
1319      }
1320    }
1321
1322    if( vps->getAvcBaseLayerFlag() )
1323    {
1324      vps->setCrossLayerIrapAlignFlag(false);
1325    }
1326#endif
1327#if M0040_ADAPTIVE_RESOLUTION_CHANGE
1328  vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false);
1329#endif
1330#if HIGHER_LAYER_IRAP_SKIP_FLAG
1331  vps->setHigherLayerIrapSkipFlag(m_skipPictureAtArcSwitch);
1332#endif
1333#if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED
1334#if !VPS_EXTN_OFFSET_CALC
1335#if VPS_EXTN_OFFSET
1336  // to be updated according to the current semantics
1337  vps->setExtensionOffset( 0xffff );
1338#endif
1339#endif
1340#endif
1341
1342#if O0215_PHASE_ALIGNMENT
1343  vps->setPhaseAlignFlag( m_phaseAlignFlag );
1344#endif
1345
1346#if O0153_ALT_OUTPUT_LAYER_FLAG
1347  vps->setAltOuputLayerFlag( m_altOutputLayerFlag );
1348#endif
1349
1350#else //SVC_EXTENSION
1351  m_cTEncTop.init(isFieldCoding);
1352#endif //SVC_EXTENSION
1353}
1354
1355// ====================================================================================================================
1356// Public member functions
1357// ====================================================================================================================
1358
1359/**
1360 - create internal class
1361 - initialize internal variable
1362 - until the end of input YUV file, call encoding function in TEncTop class
1363 - delete allocated buffers
1364 - destroy internal class
1365 .
1366 */
1367#if SVC_EXTENSION
1368Void TAppEncTop::encode()
1369{
1370  fstream bitstreamFile(m_pBitstreamFile, fstream::binary | fstream::out);
1371  if (!bitstreamFile)
1372  {
1373    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pBitstreamFile);
1374    exit(EXIT_FAILURE);
1375  }
1376
1377  TComPicYuv*       pcPicYuvOrg [MAX_LAYERS];
1378  TComPicYuv*       pcPicYuvRec = NULL;
1379
1380  // initialize internal class & member variables
1381  xInitLibCfg();
1382  xCreateLib();
1383  xInitLib(m_isField);
1384
1385  // main encoder loop
1386  Int   iNumEncoded = 0, iTotalNumEncoded = 0;
1387  Bool  bEos = false;
1388
1389  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
1390
1391  for(UInt layer=0; layer<m_numLayers; layer++)
1392  {
1393#if O0194_DIFFERENT_BITDEPTH_EL_BL
1394    //5
1395    g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
1396    g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
1397
1398    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
1399    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
1400#endif
1401    // allocate original YUV buffer
1402    pcPicYuvOrg[layer] = new TComPicYuv;
1403    if( m_isField )
1404    {
1405#if SVC_UPSAMPLING
1406#if LAYER_CTB
1407#if AUXILIARY_PICTURES
1408      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL );
1409#else
1410      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL );
1411#endif
1412#else
1413#if AUXILIARY_PICTURES
1414      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
1415#else
1416      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
1417#endif
1418#endif
1419#else
1420      pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
1421#endif
1422    }
1423    else
1424    {
1425#if SVC_UPSAMPLING
1426#if LAYER_CTB
1427#if AUXILIARY_PICTURES
1428      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL );
1429#else
1430      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL );
1431#endif
1432#else
1433#if AUXILIARY_PICTURES
1434      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
1435#else
1436      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
1437#endif
1438#endif
1439#else
1440      pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
1441#endif
1442    }
1443  }
1444
1445#if AVC_SYNTAX
1446  fstream streamSyntaxFile;
1447  if( m_acTEncTop[0].getVPS()->getAvcBaseLayerFlag() )
1448  {
1449    if( !m_BLSyntaxFile )
1450    {
1451      printf( "Wrong base layer syntax input file\n" );
1452      exit(EXIT_FAILURE);
1453    }
1454    streamSyntaxFile.open( m_BLSyntaxFile, fstream::in | fstream::binary );
1455    if( !streamSyntaxFile.good() )
1456    {
1457      printf( "Base layer syntax input reading error\n" );
1458      exit(EXIT_FAILURE);
1459    }
1460    m_acTEncTop[0].setBLSyntaxFile( &streamSyntaxFile );
1461  }
1462#endif
1463
1464  Bool bFirstFrame = true;
1465  while ( !bEos )
1466  {
1467    // Read enough frames
1468    Bool bFramesReadyToCode = false;
1469    while(!bFramesReadyToCode)
1470    {
1471      for(UInt layer=0; layer<m_numLayers; layer++)
1472      {
1473#if O0194_DIFFERENT_BITDEPTH_EL_BL
1474        //6
1475        g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
1476        g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
1477
1478        g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
1479        g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
1480#endif
1481#if LAYER_CTB
1482        g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
1483        g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer];
1484        g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
1485        g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
1486#endif
1487
1488        // get buffers
1489        xGetBuffer(pcPicYuvRec, layer);
1490
1491        // read input YUV file
1492        m_acTVideoIOYuvInputFile[layer].read( pcPicYuvOrg[layer], m_acLayerCfg[layer].getPad() );
1493
1494#if AUXILIARY_PICTURES
1495        if (m_acLayerCfg[layer].getChromaFormatIDC() == CHROMA_400)
1496        {
1497          pcPicYuvOrg[layer]->convertToMonochrome();
1498        }
1499#endif
1500
1501        if(layer == m_numLayers-1)
1502        {
1503          // increase number of received frames
1504          m_iFrameRcvd++;
1505          // check end of file
1506          bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) );
1507        }
1508
1509        if ( m_isField )
1510        {
1511          m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer], m_isTopFieldFirst );
1512        }
1513        else
1514        {
1515          m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] );
1516        }
1517      }
1518
1519      bFramesReadyToCode = !(!bFirstFrame && ( m_acTEncTop[m_numLayers-1].getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos );
1520    }
1521    Bool flush = 0;
1522    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
1523    if (m_acTVideoIOYuvInputFile[m_numLayers-1].isEof())
1524    {
1525      flush = true;
1526      bEos = true;
1527      m_iFrameRcvd--;
1528      m_acTEncTop[m_numLayers-1].setFramesToBeEncoded(m_iFrameRcvd);
1529    }
1530
1531#if RC_SHVC_HARMONIZATION
1532    for(UInt layer=0; layer<m_numLayers; layer++)
1533    {
1534      if ( m_acTEncTop[layer].getUseRateCtrl() )
1535      {
1536        (m_acTEncTop[layer].getRateCtrl())->initRCGOP(m_acTEncTop[layer].getNumPicRcvd());
1537      }
1538    }
1539#endif
1540
1541#if M0040_ADAPTIVE_RESOLUTION_CHANGE
1542    if (m_adaptiveResolutionChange)
1543    {
1544      for(UInt layer = 0; layer < m_numLayers; layer++)
1545      {
1546        TComList<TComPicYuv*>::iterator iterPicYuvRec;
1547        for (iterPicYuvRec = m_acListPicYuvRec[layer].begin(); iterPicYuvRec != m_acListPicYuvRec[layer].end(); iterPicYuvRec++)
1548        {
1549          TComPicYuv* recPic = *(iterPicYuvRec);
1550          recPic->setReconstructed(false);
1551        }
1552      }
1553    }
1554#endif
1555
1556    // loop through frames in one GOP
1557    for ( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ )
1558    {
1559      // layer by layer for each frame
1560      for(UInt layer=0; layer<m_numLayers; layer++)
1561      {
1562#if O0194_DIFFERENT_BITDEPTH_EL_BL
1563        //7
1564        g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
1565        g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
1566
1567        g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
1568        g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
1569#endif
1570#if LAYER_CTB
1571        g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
1572        g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer];
1573        g_uiMaxCUDepth  = g_auiLayerMaxCUDepth[layer];
1574        g_uiAddCUDepth  = g_auiLayerAddCUDepth[layer];
1575
1576        memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) );
1577        memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) );
1578        memcpy( g_auiRasterToPelX,  g_auiLayerRasterToPelX[layer],  sizeof( g_auiRasterToPelX ) );
1579        memcpy( g_auiRasterToPelY,  g_auiLayerRasterToPelY[layer],  sizeof( g_auiRasterToPelY ) );
1580#endif
1581        // call encoding function for one frame
1582        if ( m_isField )
1583        {
1584          m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst );
1585        }
1586        else
1587        {
1588          m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
1589        }
1590      }
1591    }
1592
1593#if RC_SHVC_HARMONIZATION
1594    for(UInt layer=0; layer<m_numLayers; layer++)
1595    {
1596      if ( m_acTEncTop[layer].getUseRateCtrl() )
1597      {
1598        (m_acTEncTop[layer].getRateCtrl())->destroyRCGOP();
1599      }
1600    }
1601#endif
1602
1603    iTotalNumEncoded = 0;
1604    for(UInt layer=0; layer<m_numLayers; layer++)
1605    {
1606#if O0194_DIFFERENT_BITDEPTH_EL_BL
1607      //8
1608      g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY;
1609      g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC;
1610
1611      g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY;
1612      g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC;
1613#endif
1614      // write bistream to file if necessary
1615      iNumEncoded = m_acTEncTop[layer].getNumPicRcvd();
1616      if ( iNumEncoded > 0 )
1617      {
1618        xWriteRecon(layer, iNumEncoded);
1619        iTotalNumEncoded += iNumEncoded;
1620      }
1621      m_acTEncTop[layer].setNumPicRcvd( 0 );
1622    }
1623
1624    // write bitstream out
1625    if(iTotalNumEncoded)
1626    {
1627#if P0130_EOB
1628      if( bEos )
1629      {
1630        OutputNALUnit nalu(NAL_UNIT_EOB);
1631        nalu.m_layerId = 0;
1632
1633        AccessUnit& accessUnit = outputAccessUnits.back();
1634        nalu.m_temporalId = accessUnit.front()->m_temporalId;
1635        accessUnit.push_back(new NALUnitEBSP(nalu));
1636      }
1637#endif
1638      xWriteStream(bitstreamFile, iTotalNumEncoded, outputAccessUnits);
1639      outputAccessUnits.clear();
1640    }
1641
1642    // print out summary
1643    if (bEos)
1644    {
1645      printOutSummary(m_isTopFieldFirst);
1646    }
1647
1648    bFirstFrame = false;
1649  }
1650  // delete original YUV buffer
1651  for(UInt layer=0; layer<m_numLayers; layer++)
1652  {
1653    pcPicYuvOrg[layer]->destroy();
1654    delete pcPicYuvOrg[layer];
1655    pcPicYuvOrg[layer] = NULL;
1656
1657    // delete used buffers in encoder class
1658    m_acTEncTop[layer].deletePicBuffer();
1659  }
1660
1661#if AVC_SYNTAX
1662  if( streamSyntaxFile.is_open() )
1663  {
1664    streamSyntaxFile.close();
1665  }
1666#endif
1667
1668  // delete buffers & classes
1669  xDeleteBuffer();
1670  xDestroyLib();
1671
1672  printRateSummary();
1673
1674  return;
1675}
1676
1677Void TAppEncTop::printOutSummary(Bool isField)
1678{
1679  UInt layer;
1680
1681  // set frame rate
1682  for(layer = 0; layer < m_numLayers; layer++)
1683  {
1684    if(isField)
1685    {
1686      m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2);
1687      m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 );
1688      m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 );
1689      m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 );
1690    }
1691    else
1692    {
1693      m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate());
1694      m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
1695      m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
1696      m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
1697    }
1698  }
1699
1700  //-- all
1701  printf( "\n\nSUMMARY --------------------------------------------------------\n" );
1702  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
1703  for(layer = 0; layer < m_numLayers; layer++)
1704  {
1705    m_gcAnalyzeAll[layer].printOut('a', layer);
1706  }
1707
1708  printf( "\n\nI Slices--------------------------------------------------------\n" );
1709  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
1710  for(layer = 0; layer < m_numLayers; layer++)
1711  {
1712    m_gcAnalyzeI[layer].printOut('i', layer);
1713  }
1714
1715  printf( "\n\nP Slices--------------------------------------------------------\n" );
1716  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
1717  for(layer = 0; layer < m_numLayers; layer++)
1718  {
1719    m_gcAnalyzeP[layer].printOut('p', layer);
1720  }
1721
1722  printf( "\n\nB Slices--------------------------------------------------------\n" );
1723  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
1724  for(layer = 0; layer < m_numLayers; layer++)
1725  {
1726    m_gcAnalyzeB[layer].printOut('b', layer);
1727  }
1728
1729  if(isField)
1730  {
1731    for(layer = 0; layer < m_numLayers; layer++)
1732    {
1733      //-- interlaced summary
1734      m_gcAnalyzeAll_in.setFrmRate( m_acLayerCfg[layer].getFrameRate());
1735      printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" );
1736      m_gcAnalyzeAll_in.printOutInterlaced('a',  m_gcAnalyzeAll[layer].getBits());
1737
1738#if _SUMMARY_OUT_
1739      m_gcAnalyzeAll_in.printSummaryOutInterlaced();
1740#endif
1741    }
1742  }
1743}
1744
1745#else
1746Void TAppEncTop::encode()
1747{
1748  fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
1749  if (!bitstreamFile)
1750  {
1751    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
1752    exit(EXIT_FAILURE);
1753  }
1754
1755  TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
1756  TComPicYuv*       pcPicYuvRec = NULL;
1757
1758  // initialize internal class & member variables
1759  xInitLibCfg();
1760  xCreateLib();
1761  xInitLib(m_isField);
1762
1763  // main encoder loop
1764  Int   iNumEncoded = 0;
1765  Bool  bEos = false;
1766
1767  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
1768
1769  // allocate original YUV buffer
1770  if( m_isField )
1771  {
1772    pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
1773  }
1774  else
1775  {
1776    pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
1777  }
1778
1779  while ( !bEos )
1780  {
1781    // get buffers
1782    xGetBuffer(pcPicYuvRec);
1783
1784    // read input YUV file
1785    m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad );
1786
1787    // increase number of received frames
1788    m_iFrameRcvd++;
1789
1790    bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) );
1791    Bool flush = 0;
1792    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
1793    if (m_cTVideoIOYuvInputFile.isEof())
1794    {
1795      flush = true;
1796      bEos = true;
1797      m_iFrameRcvd--;
1798      m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd);
1799    }
1800
1801    // call encoding function for one frame
1802    if ( m_isField )
1803    {
1804      m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst);
1805    }
1806    else
1807    {
1808    m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
1809    }
1810
1811    // write bistream to file if necessary
1812    if ( iNumEncoded > 0 )
1813    {
1814      xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits);
1815      outputAccessUnits.clear();
1816    }
1817  }
1818
1819  m_cTEncTop.printSummary(m_isField);
1820
1821  // delete original YUV buffer
1822  pcPicYuvOrg->destroy();
1823  delete pcPicYuvOrg;
1824  pcPicYuvOrg = NULL;
1825
1826  // delete used buffers in encoder class
1827  m_cTEncTop.deletePicBuffer();
1828
1829  // delete buffers & classes
1830  xDeleteBuffer();
1831  xDestroyLib();
1832
1833  printRateSummary();
1834
1835  return;
1836}
1837#endif
1838
1839// ====================================================================================================================
1840// Protected member functions
1841// ====================================================================================================================
1842
1843/**
1844 - application has picture buffer list with size of GOP
1845 - picture buffer list acts as ring buffer
1846 - end of the list has the latest picture
1847 .
1848 */
1849#if SVC_EXTENSION
1850Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
1851{
1852  assert( m_iGOPSize > 0 );
1853
1854  // org. buffer
1855  if ( m_acListPicYuvRec[layer].size() == (UInt)m_iGOPSize )
1856  {
1857    rpcPicYuvRec = m_acListPicYuvRec[layer].popFront();
1858
1859  }
1860  else
1861  {
1862    rpcPicYuvRec = new TComPicYuv;
1863
1864#if SVC_UPSAMPLING
1865#if LAYER_CTB
1866#if AUXILIARY_PICTURES
1867    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL );
1868#else
1869    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL );
1870#endif
1871#else
1872#if AUXILIARY_PICTURES
1873    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
1874#else
1875    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
1876#endif
1877#endif
1878#else
1879    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
1880#endif
1881
1882  }
1883  m_acListPicYuvRec[layer].pushBack( rpcPicYuvRec );
1884}
1885
1886Void TAppEncTop::xDeleteBuffer( )
1887{
1888  for(UInt layer=0; layer<m_numLayers; layer++)
1889  {
1890    TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_acListPicYuvRec[layer].begin();
1891
1892    Int iSize = Int( m_acListPicYuvRec[layer].size() );
1893
1894    for ( Int i = 0; i < iSize; i++ )
1895    {
1896      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
1897      pcPicYuvRec->destroy();
1898      delete pcPicYuvRec; pcPicYuvRec = NULL;
1899    }
1900  }
1901}
1902
1903Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded)
1904{
1905  if (m_isField)
1906  {
1907    //Reinterlace fields
1908    Int i;
1909    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
1910
1911    for ( i = 0; i < iNumEncoded; i++ )
1912    {
1913      --iterPicYuvRec;
1914    }
1915
1916    for ( i = 0; i < iNumEncoded/2; i++ )
1917    {
1918      TComPicYuv*  pcPicYuvRecTop  = *(iterPicYuvRec++);
1919      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
1920
1921#if M0040_ADAPTIVE_RESOLUTION_CHANGE
1922      if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed())
1923#else
1924      if (!m_acLayerCfg[layer].getReconFile().empty())
1925#endif
1926      {
1927        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom(), m_isTopFieldFirst );
1928      }
1929    }
1930  }
1931  else
1932  {
1933    Int i;
1934
1935    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
1936
1937    for ( i = 0; i < iNumEncoded; i++ )
1938    {
1939      --iterPicYuvRec;
1940    }
1941
1942    for ( i = 0; i < iNumEncoded; i++ )
1943    {
1944      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
1945#if M0040_ADAPTIVE_RESOLUTION_CHANGE
1946      if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed())
1947#else
1948      if (!m_acLayerCfg[layer].getReconFile().empty())
1949#endif
1950      {
1951        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
1952          m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
1953      }
1954    }
1955  }
1956}
1957
1958Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
1959{
1960  if (m_isField)
1961  {
1962    //Reinterlace fields
1963    Int i;
1964    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
1965
1966#if M0040_ADAPTIVE_RESOLUTION_CHANGE
1967    for ( i = 0; i < iNumEncoded/2 && iterBitstream != accessUnits.end(); i++ )
1968#else
1969    for ( i = 0; i < iNumEncoded/2; i++ )
1970#endif
1971    {
1972      const AccessUnit& auTop = *(iterBitstream++);
1973      const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
1974      rateStatsAccum(auTop, statsTop);
1975
1976      const AccessUnit& auBottom = *(iterBitstream++);
1977      const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom);
1978      rateStatsAccum(auBottom, statsBottom);
1979    }
1980  }
1981  else
1982  {
1983    Int i;
1984
1985    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
1986
1987#if M0040_ADAPTIVE_RESOLUTION_CHANGE
1988    for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ )
1989#else
1990    for ( i = 0; i < iNumEncoded; i++ )
1991#endif
1992    {
1993      const AccessUnit& au = *(iterBitstream++);
1994      const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
1995      rateStatsAccum(au, stats);
1996    }
1997  }
1998}
1999
2000#else // SVC_EXTENSION
2001Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec)
2002{
2003  assert( m_iGOPSize > 0 );
2004
2005  // org. buffer
2006  if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize )
2007  {
2008    rpcPicYuvRec = m_cListPicYuvRec.popFront();
2009
2010  }
2011  else
2012  {
2013    rpcPicYuvRec = new TComPicYuv;
2014
2015    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
2016
2017  }
2018  m_cListPicYuvRec.pushBack( rpcPicYuvRec );
2019}
2020
2021Void TAppEncTop::xDeleteBuffer( )
2022{
2023  TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec.begin();
2024
2025  Int iSize = Int( m_cListPicYuvRec.size() );
2026
2027  for ( Int i = 0; i < iSize; i++ )
2028  {
2029    TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
2030    pcPicYuvRec->destroy();
2031    delete pcPicYuvRec; pcPicYuvRec = NULL;
2032  }
2033
2034}
2035
2036/** \param iNumEncoded  number of encoded frames
2037 */
2038Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
2039{
2040  if (m_isField)
2041  {
2042    //Reinterlace fields
2043    Int i;
2044    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
2045    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
2046
2047    for ( i = 0; i < iNumEncoded; i++ )
2048    {
2049      --iterPicYuvRec;
2050    }
2051
2052    for ( i = 0; i < iNumEncoded/2; i++ )
2053    {
2054      TComPicYuv*  pcPicYuvRecTop  = *(iterPicYuvRec++);
2055      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
2056
2057      if (m_pchReconFile)
2058      {
2059        m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst );
2060      }
2061
2062      const AccessUnit& auTop = *(iterBitstream++);
2063      const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
2064      rateStatsAccum(auTop, statsTop);
2065
2066      const AccessUnit& auBottom = *(iterBitstream++);
2067      const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom);
2068      rateStatsAccum(auBottom, statsBottom);
2069    }
2070  }
2071  else
2072  {
2073    Int i;
2074
2075    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
2076    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
2077
2078    for ( i = 0; i < iNumEncoded; i++ )
2079    {
2080      --iterPicYuvRec;
2081    }
2082
2083    for ( i = 0; i < iNumEncoded; i++ )
2084    {
2085      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
2086      if (m_pchReconFile)
2087      {
2088#if SYNTAX_OUTPUT
2089        m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
2090#endif
2091      }
2092
2093      const AccessUnit& au = *(iterBitstream++);
2094      const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
2095      rateStatsAccum(au, stats);
2096    }
2097  }
2098}
2099#endif
2100
2101/**
2102 *
2103 */
2104void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
2105{
2106  AccessUnit::const_iterator it_au = au.begin();
2107  vector<UInt>::const_iterator it_stats = annexBsizes.begin();
2108
2109  for (; it_au != au.end(); it_au++, it_stats++)
2110  {
2111    switch ((*it_au)->m_nalUnitType)
2112    {
2113    case NAL_UNIT_CODED_SLICE_TRAIL_R:
2114    case NAL_UNIT_CODED_SLICE_TRAIL_N:
2115    case NAL_UNIT_CODED_SLICE_TSA_R:
2116    case NAL_UNIT_CODED_SLICE_TSA_N:
2117    case NAL_UNIT_CODED_SLICE_STSA_R:
2118    case NAL_UNIT_CODED_SLICE_STSA_N:
2119    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
2120    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
2121    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
2122    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
2123    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
2124    case NAL_UNIT_CODED_SLICE_CRA:
2125    case NAL_UNIT_CODED_SLICE_RADL_N:
2126    case NAL_UNIT_CODED_SLICE_RADL_R:
2127    case NAL_UNIT_CODED_SLICE_RASL_N:
2128    case NAL_UNIT_CODED_SLICE_RASL_R:
2129    case NAL_UNIT_VPS:
2130    case NAL_UNIT_SPS:
2131    case NAL_UNIT_PPS:
2132      m_essentialBytes += *it_stats;
2133      break;
2134    default:
2135      break;
2136    }
2137
2138    m_totalBytes += *it_stats;
2139  }
2140}
2141
2142void TAppEncTop::printRateSummary()
2143{
2144#if SVC_EXTENSION
2145  Double time = (Double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate();
2146#else
2147  Double time = (Double) m_iFrameRcvd / m_iFrameRate;
2148#endif
2149  printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
2150#if VERBOSE_RATE
2151  printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time);
2152#endif
2153}
2154
2155//! \}
Note: See TracBrowser for help on using the repository browser.