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

Last change on this file since 594 was 593, checked in by seregin, 11 years ago

update to HM-13.0

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