source: SHVCSoftware/branches/SHM-5.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp @ 611

Last change on this file since 611 was 610, checked in by qualcomm, 11 years ago

Set MAX_TLAYER to 7 and infer values of DPB size syntax elements.

The value of MAX_TLAYER should be 7 and not 8, because there are at most 7 temporal layers (Related HM ticket 1239). The values of syntax elements of the DPB size table are inferred when they are not signaled.

From: Adarsh K. Ramasubramonian <aramasub@…>

  • Property svn:eol-style set to native
File size: 119.3 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6 * Copyright (c) 2010-2014, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TAppEncCfg.cpp
35    \brief    Handle encoder configuration parameters
36*/
37
38#include <stdlib.h>
39#include <cassert>
40#include <cstring>
41#include <string>
42#include "TLibCommon/TComRom.h"
43#include "TAppEncCfg.h"
44
45static istream& operator>>(istream &, Level::Name &);
46static istream& operator>>(istream &, Level::Tier &);
47static istream& operator>>(istream &, Profile::Name &);
48
49#include "TAppCommon/program_options_lite.h"
50#include "TLibEncoder/TEncRateCtrl.h"
51#ifdef WIN32
52#define strdup _strdup
53#endif
54
55using namespace std;
56namespace po = df::program_options_lite;
57
58//! \ingroup TAppEncoder
59//! \{
60
61// ====================================================================================================================
62// Constructor / destructor / initialization / destroy
63// ====================================================================================================================
64
65#if SVC_EXTENSION
66TAppEncCfg::TAppEncCfg()
67: m_pBitstreamFile()
68#if AVC_BASE
69, m_avcBaseLayerFlag(0)
70#endif
71#if N0120_MAX_TID_REF_CFG
72, m_maxTidRefPresentFlag(1)
73#endif
74, m_pColumnWidth()
75, m_pRowHeight()
76, m_scalingListFile()
77, m_elRapSliceBEnabled(0)
78{
79  for(UInt layer=0; layer<MAX_LAYERS; layer++)
80  {
81    m_acLayerCfg[layer].setAppEncCfg(this);
82  }
83  memset( m_scalabilityMask, 0, sizeof(m_scalabilityMask) );
84}
85#else
86TAppEncCfg::TAppEncCfg()
87: m_pchInputFile()
88, m_pchBitstreamFile()
89, m_pchReconFile()
90, m_pchdQPFile()
91, m_pColumnWidth()
92, m_pRowHeight()
93, m_scalingListFile()
94{
95  m_aidQP = NULL;
96  m_startOfCodedInterval = NULL;
97  m_codedPivotValue = NULL;
98  m_targetPivotValue = NULL;
99}
100#endif
101
102TAppEncCfg::~TAppEncCfg()
103{
104#if SVC_EXTENSION
105  free(m_pBitstreamFile);
106#else 
107  if ( m_aidQP )
108  {
109    delete[] m_aidQP;
110  }
111  if ( m_startOfCodedInterval )
112  {
113    delete[] m_startOfCodedInterval;
114    m_startOfCodedInterval = NULL;
115  }
116   if ( m_codedPivotValue )
117  {
118    delete[] m_codedPivotValue;
119    m_codedPivotValue = NULL;
120  }
121  if ( m_targetPivotValue )
122  {
123    delete[] m_targetPivotValue;
124    m_targetPivotValue = NULL;
125  }
126  free(m_pchInputFile);
127  free(m_pchBitstreamFile);
128#endif
129#if !SVC_EXTENSION 
130  free(m_pchReconFile);
131  free(m_pchdQPFile);
132#endif
133  free(m_pColumnWidth);
134  free(m_pRowHeight);
135  free(m_scalingListFile);
136}
137
138Void TAppEncCfg::create()
139{
140}
141
142Void TAppEncCfg::destroy()
143{
144#if VPS_EXTN_DIRECT_REF_LAYERS
145  for(Int layer = 0; layer < MAX_LAYERS; layer++)
146  {
147    if( m_acLayerCfg[layer].m_numSamplePredRefLayers > 0 )
148    {
149      delete [] m_acLayerCfg[layer].m_samplePredRefLayerIds;
150      m_acLayerCfg[layer].m_samplePredRefLayerIds = NULL;
151    }
152    if( m_acLayerCfg[layer].m_numMotionPredRefLayers > 0 )
153    {
154      delete [] m_acLayerCfg[layer].m_motionPredRefLayerIds;
155      m_acLayerCfg[layer].m_motionPredRefLayerIds = NULL;
156    }
157    if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 )
158    {
159      delete [] m_acLayerCfg[layer].m_predLayerIds;
160      m_acLayerCfg[layer].m_predLayerIds = NULL;
161    }
162  }
163#endif
164}
165
166std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry)     //input
167{
168  in>>entry.m_sliceType;
169  in>>entry.m_POC;
170  in>>entry.m_QPOffset;
171  in>>entry.m_QPFactor;
172  in>>entry.m_tcOffsetDiv2;
173  in>>entry.m_betaOffsetDiv2;
174  in>>entry.m_temporalId;
175  in>>entry.m_numRefPicsActive;
176  in>>entry.m_numRefPics;
177  for ( Int i = 0; i < entry.m_numRefPics; i++ )
178  {
179    in>>entry.m_referencePics[i];
180  }
181  in>>entry.m_interRPSPrediction;
182#if AUTO_INTER_RPS
183  if (entry.m_interRPSPrediction==1)
184  {
185    in>>entry.m_deltaRPS;
186    in>>entry.m_numRefIdc;
187    for ( Int i = 0; i < entry.m_numRefIdc; i++ )
188    {
189      in>>entry.m_refIdc[i];
190    }
191  }
192  else if (entry.m_interRPSPrediction==2)
193  {
194    in>>entry.m_deltaRPS;
195  }
196#else
197  if (entry.m_interRPSPrediction)
198  {
199    in>>entry.m_deltaRPS;
200    in>>entry.m_numRefIdc;
201    for ( Int i = 0; i < entry.m_numRefIdc; i++ )
202    {
203      in>>entry.m_refIdc[i];
204    }
205  }
206#endif
207  return in;
208}
209
210#if AUXILIARY_PICTURES
211static inline ChromaFormat numberToChromaFormat(const Int val)
212{
213  switch (val)
214  {
215    case 400: return CHROMA_400; break;
216    case 420: return CHROMA_420; break;
217    case 422: return CHROMA_422; break;
218    case 444: return CHROMA_444; break;
219    default:  return NUM_CHROMA_FORMAT;
220  }
221}
222#endif
223
224#if SVC_EXTENSION
225void TAppEncCfg::getDirFilename(string& filename, string& dir, const string path)
226{
227  size_t pos = path.find_last_of("\\");
228  if(pos != std::string::npos)
229  {
230    filename.assign(path.begin() + pos + 1, path.end());
231    dir.assign(path.begin(), path.begin() + pos + 1);
232  }
233  else
234  {
235    pos = path.find_last_of("/");
236    if(pos != std::string::npos)
237    {
238      filename.assign(path.begin() + pos + 1, path.end());
239      dir.assign(path.begin(), path.begin() + pos + 1);
240    }
241    else
242    {
243      filename = path;
244      dir.assign("");
245    }
246  }
247}
248#endif
249
250static const struct MapStrToProfile {
251  const Char* str;
252  Profile::Name value;
253} strToProfile[] = {
254  {"none", Profile::NONE},
255  {"main", Profile::MAIN},
256  {"main10", Profile::MAIN10},
257  {"main-still-picture", Profile::MAINSTILLPICTURE},
258};
259
260static const struct MapStrToTier {
261  const Char* str;
262  Level::Tier value;
263} strToTier[] = {
264  {"main", Level::MAIN},
265  {"high", Level::HIGH},
266};
267
268static const struct MapStrToLevel {
269  const Char* str;
270  Level::Name value;
271} strToLevel[] = {
272  {"none",Level::NONE},
273  {"1",   Level::LEVEL1},
274  {"2",   Level::LEVEL2},
275  {"2.1", Level::LEVEL2_1},
276  {"3",   Level::LEVEL3},
277  {"3.1", Level::LEVEL3_1},
278  {"4",   Level::LEVEL4},
279  {"4.1", Level::LEVEL4_1},
280  {"5",   Level::LEVEL5},
281  {"5.1", Level::LEVEL5_1},
282  {"5.2", Level::LEVEL5_2},
283  {"6",   Level::LEVEL6},
284  {"6.1", Level::LEVEL6_1},
285  {"6.2", Level::LEVEL6_2},
286};
287
288template<typename T, typename P>
289static istream& readStrToEnum(P map[], unsigned long mapLen, istream &in, T &val)
290{
291  string str;
292  in >> str;
293
294  for (Int i = 0; i < mapLen; i++)
295  {
296    if (str == map[i].str)
297    {
298      val = map[i].value;
299      goto found;
300    }
301  }
302  /* not found */
303  in.setstate(ios::failbit);
304found:
305  return in;
306}
307
308static istream& operator>>(istream &in, Profile::Name &profile)
309{
310  return readStrToEnum(strToProfile, sizeof(strToProfile)/sizeof(*strToProfile), in, profile);
311}
312
313static istream& operator>>(istream &in, Level::Tier &tier)
314{
315  return readStrToEnum(strToTier, sizeof(strToTier)/sizeof(*strToTier), in, tier);
316}
317
318static istream& operator>>(istream &in, Level::Name &level)
319{
320  return readStrToEnum(strToLevel, sizeof(strToLevel)/sizeof(*strToLevel), in, level);
321}
322
323// ====================================================================================================================
324// Public member functions
325// ====================================================================================================================
326
327/** \param  argc        number of arguments
328    \param  argv        array of arguments
329    \retval             true when success
330 */
331Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] )
332{
333  Bool do_help = false;
334 
335#if SVC_EXTENSION
336  string  cfg_LayerCfgFile   [MAX_LAYERS];
337  string  cfg_BitstreamFile;
338  string* cfg_InputFile      [MAX_LAYERS];
339  string* cfg_ReconFile      [MAX_LAYERS];
340  Double* cfg_fQP            [MAX_LAYERS];
341
342#if REPN_FORMAT_IN_VPS
343  Int*    cfg_repFormatIdx  [MAX_LAYERS];
344#endif
345  Int*    cfg_SourceWidth   [MAX_LAYERS]; 
346  Int*    cfg_SourceHeight  [MAX_LAYERS];
347  Int*    cfg_FrameRate     [MAX_LAYERS];
348  Int*    cfg_IntraPeriod   [MAX_LAYERS];
349  Int*    cfg_conformanceMode  [MAX_LAYERS];
350#if LAYER_CTB
351  // coding unit (CU) definition
352  UInt*      cfg_uiMaxCUWidth[MAX_LAYERS];                                   ///< max. CU width in pixel
353  UInt*      cfg_uiMaxCUHeight[MAX_LAYERS];                                  ///< max. CU height in pixel
354  UInt*      cfg_uiMaxCUDepth[MAX_LAYERS];                                   ///< max. CU depth
355 
356  // transfom unit (TU) definition
357  UInt*      cfg_uiQuadtreeTULog2MaxSize[MAX_LAYERS];
358  UInt*      cfg_uiQuadtreeTULog2MinSize[MAX_LAYERS];
359 
360  UInt*      cfg_uiQuadtreeTUMaxDepthInter[MAX_LAYERS];
361  UInt*      cfg_uiQuadtreeTUMaxDepthIntra[MAX_LAYERS];
362#endif
363#if AUXILIARY_PICTURES
364  Int      cfg_tmpChromaFormatIDC  [MAX_LAYERS];
365  Int      cfg_tmpInputChromaFormat[MAX_LAYERS];
366  Int*     cfg_auxId               [MAX_LAYERS];
367#endif
368#if VPS_EXTN_DIRECT_REF_LAYERS
369  Int*    cfg_numSamplePredRefLayers  [MAX_LAYERS];
370  string  cfg_samplePredRefLayerIds   [MAX_LAYERS];
371  string* cfg_samplePredRefLayerIdsPtr[MAX_LAYERS];
372  Int*    cfg_numMotionPredRefLayers  [MAX_LAYERS];
373  string  cfg_motionPredRefLayerIds   [MAX_LAYERS];
374  string* cfg_motionPredRefLayerIdsPtr[MAX_LAYERS];
375  Int*    cfg_numActiveRefLayers [MAX_LAYERS];
376  string  cfg_predLayerIds       [MAX_LAYERS];
377  string* cfg_predLayerIdsPtr    [MAX_LAYERS];
378#endif
379#if O0098_SCALED_REF_LAYER_ID
380  string    cfg_scaledRefLayerId [MAX_LAYERS];
381#endif
382  string    cfg_scaledRefLayerLeftOffset [MAX_LAYERS];
383  string    cfg_scaledRefLayerTopOffset [MAX_LAYERS];
384  string    cfg_scaledRefLayerRightOffset [MAX_LAYERS];
385  string    cfg_scaledRefLayerBottomOffset [MAX_LAYERS];
386  Int*      cfg_numScaledRefLayerOffsets[MAX_LAYERS];
387
388#if O0098_SCALED_REF_LAYER_ID
389  string*    cfg_scaledRefLayerIdPtr           [MAX_LAYERS];
390#endif
391  string*    cfg_scaledRefLayerLeftOffsetPtr   [MAX_LAYERS];
392  string*    cfg_scaledRefLayerTopOffsetPtr    [MAX_LAYERS];
393  string*    cfg_scaledRefLayerRightOffsetPtr  [MAX_LAYERS];
394  string*    cfg_scaledRefLayerBottomOffsetPtr [MAX_LAYERS];
395#if RC_SHVC_HARMONIZATION
396  Bool*   cfg_RCEnableRateControl  [MAX_LAYERS];
397  Int*    cfg_RCTargetBitRate      [MAX_LAYERS];
398  Bool*   cfg_RCKeepHierarchicalBit[MAX_LAYERS];
399  Bool*   cfg_RCLCULevelRC         [MAX_LAYERS];
400  Bool*   cfg_RCUseLCUSeparateModel[MAX_LAYERS];
401  Int*    cfg_RCInitialQP          [MAX_LAYERS];
402  Bool*   cfg_RCForceIntraQP       [MAX_LAYERS];
403#endif
404#if O0194_DIFFERENT_BITDEPTH_EL_BL
405  Int*    cfg_InputBitDepthY    [MAX_LAYERS];
406  Int*    cfg_InternalBitDepthY [MAX_LAYERS];
407  Int*    cfg_InputBitDepthC    [MAX_LAYERS];
408  Int*    cfg_InternalBitDepthC [MAX_LAYERS];
409  Int*    cfg_OutputBitDepthY   [MAX_LAYERS];
410  Int*    cfg_OutputBitDepthC   [MAX_LAYERS];
411#endif
412#if N0120_MAX_TID_REF_CFG
413  Int*    cfg_maxTidIlRefPicsPlus1[MAX_LAYERS]; 
414#endif
415  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
416  {
417    cfg_InputFile[layer]    = &m_acLayerCfg[layer].m_cInputFile;
418    cfg_ReconFile[layer]    = &m_acLayerCfg[layer].m_cReconFile;
419    cfg_fQP[layer]          = &m_acLayerCfg[layer].m_fQP;
420#if REPN_FORMAT_IN_VPS
421    cfg_repFormatIdx[layer] = &m_acLayerCfg[layer].m_repFormatIdx;
422#endif
423    cfg_SourceWidth[layer]  = &m_acLayerCfg[layer].m_iSourceWidth;
424    cfg_SourceHeight[layer] = &m_acLayerCfg[layer].m_iSourceHeight;
425    cfg_FrameRate[layer]    = &m_acLayerCfg[layer].m_iFrameRate; 
426    cfg_IntraPeriod[layer]  = &m_acLayerCfg[layer].m_iIntraPeriod; 
427    cfg_conformanceMode[layer] = &m_acLayerCfg[layer].m_conformanceMode;
428#if LAYER_CTB
429    // coding unit (CU) definition
430    cfg_uiMaxCUWidth[layer]  = &m_acLayerCfg[layer].m_uiMaxCUWidth;
431    cfg_uiMaxCUHeight[layer] = &m_acLayerCfg[layer].m_uiMaxCUHeight;
432    cfg_uiMaxCUDepth[layer]  = &m_acLayerCfg[layer].m_uiMaxCUDepth;
433
434    // transfom unit (TU) definition.
435    cfg_uiQuadtreeTULog2MaxSize[layer] = &m_acLayerCfg[layer].m_uiQuadtreeTULog2MaxSize;
436    cfg_uiQuadtreeTULog2MinSize[layer] = &m_acLayerCfg[layer].m_uiQuadtreeTULog2MinSize;
437
438    cfg_uiQuadtreeTUMaxDepthInter[layer] = &m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthInter;
439    cfg_uiQuadtreeTUMaxDepthIntra[layer] = &m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthIntra;
440#endif
441#if VPS_EXTN_DIRECT_REF_LAYERS
442    cfg_numSamplePredRefLayers  [layer] = &m_acLayerCfg[layer].m_numSamplePredRefLayers;
443    cfg_samplePredRefLayerIdsPtr[layer] = &cfg_samplePredRefLayerIds[layer];
444    cfg_numMotionPredRefLayers  [layer] = &m_acLayerCfg[layer].m_numMotionPredRefLayers;
445    cfg_motionPredRefLayerIdsPtr[layer] = &cfg_motionPredRefLayerIds[layer];
446    cfg_numActiveRefLayers  [layer] = &m_acLayerCfg[layer].m_numActiveRefLayers;
447    cfg_predLayerIdsPtr     [layer]  = &cfg_predLayerIds[layer];
448#endif
449    cfg_numScaledRefLayerOffsets [layer] = &m_acLayerCfg[layer].m_numScaledRefLayerOffsets;
450    for(Int i = 0; i < MAX_LAYERS; i++)
451    {
452#if O0098_SCALED_REF_LAYER_ID
453      cfg_scaledRefLayerIdPtr          [layer] = &cfg_scaledRefLayerId[layer]          ;
454#endif
455      cfg_scaledRefLayerLeftOffsetPtr  [layer] = &cfg_scaledRefLayerLeftOffset[layer]  ;
456      cfg_scaledRefLayerTopOffsetPtr   [layer] = &cfg_scaledRefLayerTopOffset[layer]   ;
457      cfg_scaledRefLayerRightOffsetPtr [layer] = &cfg_scaledRefLayerRightOffset[layer] ;
458      cfg_scaledRefLayerBottomOffsetPtr[layer] = &cfg_scaledRefLayerBottomOffset[layer];
459    }
460#if RC_SHVC_HARMONIZATION
461    cfg_RCEnableRateControl[layer]   = &m_acLayerCfg[layer].m_RCEnableRateControl;
462    cfg_RCTargetBitRate[layer]       = &m_acLayerCfg[layer].m_RCTargetBitrate;
463    cfg_RCKeepHierarchicalBit[layer] = &m_acLayerCfg[layer].m_RCKeepHierarchicalBit;
464    cfg_RCLCULevelRC[layer]          = &m_acLayerCfg[layer].m_RCLCULevelRC;
465    cfg_RCUseLCUSeparateModel[layer] = &m_acLayerCfg[layer].m_RCUseLCUSeparateModel;
466    cfg_RCInitialQP[layer]           = &m_acLayerCfg[layer].m_RCInitialQP;
467    cfg_RCForceIntraQP[layer]        = &m_acLayerCfg[layer].m_RCForceIntraQP;
468#endif
469#if O0194_DIFFERENT_BITDEPTH_EL_BL
470  cfg_InputBitDepthY   [layer] = &m_acLayerCfg[layer].m_inputBitDepthY;
471  cfg_InternalBitDepthY[layer] = &m_acLayerCfg[layer].m_internalBitDepthY;
472  cfg_InputBitDepthC   [layer] = &m_acLayerCfg[layer].m_inputBitDepthC;
473  cfg_InternalBitDepthC[layer] = &m_acLayerCfg[layer].m_internalBitDepthC;
474  cfg_OutputBitDepthY  [layer] = &m_acLayerCfg[layer].m_outputBitDepthY;
475  cfg_OutputBitDepthC  [layer] = &m_acLayerCfg[layer].m_outputBitDepthC;
476#endif
477#if N0120_MAX_TID_REF_CFG
478    cfg_maxTidIlRefPicsPlus1[layer] = &m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1; 
479#endif
480#if AUXILIARY_PICTURES
481    cfg_auxId[layer]                = &m_acLayerCfg[layer].m_auxId; 
482#endif
483  }
484#if AVC_BASE
485  string  cfg_BLInputFile;
486#endif
487#if AVC_SYNTAX
488  string  cfg_BLSyntaxFile;
489#endif
490#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
491  string  cfg_tileSets;
492#endif
493#else //SVC_EXTENSION
494  string cfg_InputFile;
495  string cfg_BitstreamFile;
496  string cfg_ReconFile;
497  string cfg_dQPFile;
498#endif //SVC_EXTENSION
499  string cfg_ColumnWidth;
500  string cfg_RowHeight;
501  string cfg_ScalingListFile;
502  string cfg_startOfCodedInterval;
503  string cfg_codedPivotValue;
504  string cfg_targetPivotValue;
505  po::Options opts;
506  opts.addOptions()
507  ("help", do_help, false, "this help text")
508  ("c", po::parseConfigFile, "configuration file name")
509 
510  // File, I/O and source parameters
511#if SVC_EXTENSION
512  ("InputFile%d,-i%d",        cfg_InputFile,  string(""), MAX_LAYERS, "original YUV input file name for layer %d")
513  ("ReconFile%d,-o%d",        cfg_ReconFile,  string(""), MAX_LAYERS, "reconstruction YUV input file name for layer %d")
514  ("LayerConfig%d,-lc%d",     cfg_LayerCfgFile, string(""), MAX_LAYERS, "layer %d configuration file name")
515  ("SourceWidth%d,-wdt%d",    cfg_SourceWidth, 0, MAX_LAYERS, "Source picture width for layer %d")
516  ("SourceHeight%d,-hgt%d",   cfg_SourceHeight, 0, MAX_LAYERS, "Source picture height for layer %d")
517  ("FrameRate%d,-fr%d",       cfg_FrameRate,  0, MAX_LAYERS, "Frame rate for layer %d")
518  ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
519#if O0215_PHASE_ALIGNMENT
520  ("PhaseAlignment",          m_phaseAlignFlag, false, "indicate the sample location alignment between layers (0: zero position aligned, 1: central position aligned)")
521#endif
522#if REPN_FORMAT_IN_VPS
523  ("RepFormatIdx%d",          cfg_repFormatIdx, -1, MAX_LAYERS, "Index to the representation format structure used from the VPS")
524#endif
525#if VPS_EXTN_DIRECT_REF_LAYERS
526  ("NumSamplePredRefLayers%d",cfg_numSamplePredRefLayers, -1, MAX_LAYERS, "Number of sample prediction reference layers")
527  ("SamplePredRefLayerIds%d", cfg_samplePredRefLayerIdsPtr, string(""), MAX_LAYERS, "sample pred reference layer IDs")
528  ("NumMotionPredRefLayers%d",cfg_numMotionPredRefLayers, -1, MAX_LAYERS, "Number of motion prediction reference layers")
529  ("MotionPredRefLayerIds%d", cfg_motionPredRefLayerIdsPtr, string(""), MAX_LAYERS, "motion pred reference layer IDs")
530  ("NumActiveRefLayers%d",    cfg_numActiveRefLayers, -1, MAX_LAYERS, "Number of active reference layers")
531  ("PredLayerIds%d",          cfg_predLayerIdsPtr, string(""), MAX_LAYERS, "inter-layer prediction layer IDs")
532#endif
533  ("NumLayers",               m_numLayers, 1, "Number of layers to code")
534#if AUXILIARY_PICTURES
535  ("InputChromaFormat%d",     cfg_tmpInputChromaFormat,  420, MAX_LAYERS, "InputChromaFormatIDC for layer %d")
536  ("ChromaFormatIDC%d,-cf",   cfg_tmpChromaFormatIDC,    420, MAX_LAYERS, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat) for layer %d")
537  ("AuxId%d",                 cfg_auxId,                 0,   MAX_LAYERS, "Auxilary picture ID for layer %d (0: Not aux pic, 1: Alpha plane, 2: Depth picture, 3: Cb enh, 4: Cr enh")
538#endif
539  ("ConformanceMode%d",       cfg_conformanceMode,0, MAX_LAYERS, "Window conformance mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
540#if SCALABILITY_MASK_E0104
541  ("ScalabilityMask1",        m_scalabilityMask[1], 0, "scalability_mask[1] (multiview)")
542  ("ScalabilityMask2",        m_scalabilityMask[2], 1, "scalability_mask[2] (scalable)" )
543#if AUXILIARY_PICTURES
544  ("ScalabilityMask3",        m_scalabilityMask[3], 0, "scalability_mask[3] (auxiliary pictures)" )
545#endif
546#else
547  ("ScalabilityMask0",        m_scalabilityMask[0], 0, "scalability_mask[0] (multiview)")
548  ("ScalabilityMask1",        m_scalabilityMask[1], 1, "scalability_mask[1] (scalable)" )
549#endif
550  ("BitstreamFile,b",         cfg_BitstreamFile, string(""), "Bitstream output file name")
551#if !O0194_DIFFERENT_BITDEPTH_EL_BL
552  ("InputBitDepth",           m_inputBitDepthY,    8, "Bit-depth of input file")
553  ("OutputBitDepth",          m_outputBitDepthY,   0, "Bit-depth of output file (default:InternalBitDepth)")
554  ("InternalBitDepth",        m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)"
555                                                       "If different to InputBitDepth, source data will be converted")
556  ("InputBitDepthC",          m_inputBitDepthC,    0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
557  ("OutputBitDepthC",         m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
558  ("InternalBitDepthC",       m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
559#endif
560  ("NumScaledRefLayerOffsets%d",    cfg_numScaledRefLayerOffsets,     0, MAX_LAYERS,  "Number of scaled offset layer sets ")
561#if O0098_SCALED_REF_LAYER_ID
562  ("ScaledRefLayerId%d",           cfg_scaledRefLayerIdPtr,          string(""), MAX_LAYERS, "Layer ID of scaled base layer picture")
563#endif
564  ("ScaledRefLayerLeftOffset%d",   cfg_scaledRefLayerLeftOffsetPtr,  string(""), MAX_LAYERS, "Horizontal offset of top-left luma sample of scaled base layer picture with respect to"
565                                                                 " top-left luma sample of the EL picture, in units of two luma samples")
566  ("ScaledRefLayerTopOffset%d",    cfg_scaledRefLayerTopOffsetPtr,   string(""), MAX_LAYERS,   "Vertical offset of top-left luma sample of scaled base layer picture with respect to"
567                                                                 " top-left luma sample of the EL picture, in units of two luma samples")
568  ("ScaledRefLayerRightOffset%d",  cfg_scaledRefLayerRightOffsetPtr, string(""), MAX_LAYERS, "Horizontal offset of bottom-right luma sample of scaled base layer picture with respect to"
569                                                                 " bottom-right luma sample of the EL picture, in units of two luma samples")
570  ("ScaledRefLayerBottomOffset%d", cfg_scaledRefLayerBottomOffsetPtr,string(""), MAX_LAYERS, "Vertical offset of bottom-right luma sample of scaled base layer picture with respect to"
571                                                                 " bottom-right luma sample of the EL picture, in units of two luma samples")
572#if O0194_DIFFERENT_BITDEPTH_EL_BL
573  ("InputBitDepth%d",       cfg_InputBitDepthY,    8, MAX_LAYERS, "Bit-depth of input file for layer %d")
574  ("InternalBitDepth%d",    cfg_InternalBitDepthY, 0, MAX_LAYERS, "Bit-depth the codec operates at. (default:InputBitDepth) for layer %d ")
575//                                                       "If different to InputBitDepth, source data will be converted")
576  ("InputBitDepthC%d",      cfg_InputBitDepthC,    0, MAX_LAYERS, "As per InputBitDepth but for chroma component. (default:InputBitDepth) for layer %d")
577  ("InternalBitDepthC%d",   cfg_InternalBitDepthC, 0, MAX_LAYERS, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth) for layer %d")
578  ("OutputBitDepth%d",      cfg_OutputBitDepthY,   0, MAX_LAYERS, "Bit-depth of output file (default:InternalBitDepth)")
579  ("OutputBitDepthC%d",     cfg_OutputBitDepthC,   0, MAX_LAYERS, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
580#endif
581#if N0120_MAX_TID_REF_CFG
582  ("MaxTidRefPresentFlag", m_maxTidRefPresentFlag, true, "max_tid_ref_present_flag (0: not present, 1: present(default)) " )
583  ("MaxTidIlRefPicsPlus1%d", cfg_maxTidIlRefPicsPlus1, 1, MAX_LAYERS, "allowed maximum temporal_id for inter-layer prediction")
584#endif
585#if O0223_PICTURE_TYPES_ALIGN_FLAG
586  ("CrossLayerPictureTypeAlignFlag", m_crossLayerPictureTypeAlignFlag, true, "align picture type across layers" ) 
587#endif
588#if N0147_IRAP_ALIGN_FLAG
589  ("CrossLayerIrapAlignFlag", m_crossLayerIrapAlignFlag, true, "align IRAP across layers" ) 
590#endif
591#if O0194_WEIGHTED_PREDICTION_CGS
592  ("InterLayerWeightedPred", m_useInterLayerWeightedPred, false, "enable IL WP parameters estimation at encoder" ) 
593#endif
594#if AVC_BASE
595  ("AvcBase,-avc",            m_avcBaseLayerFlag,     0, "avc_base_layer_flag")
596  ("InputBLFile,-ibl",        cfg_BLInputFile,     string(""), "Base layer rec YUV input file name")
597#if AVC_SYNTAX
598  ("InputBLSyntaxFile,-ibs",  cfg_BLSyntaxFile,     string(""), "Base layer syntax input file name")
599#endif
600#endif
601  ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture)")
602#else //SVC_EXTENSION
603  ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
604  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
605  ("ReconFile,o",           cfg_ReconFile,     string(""), "Reconstructed YUV output file name")
606  ("SourceWidth,-wdt",      m_iSourceWidth,        0, "Source picture width")
607  ("SourceHeight,-hgt",     m_iSourceHeight,       0, "Source picture height")
608  ("InputBitDepth",         m_inputBitDepthY,    8, "Bit-depth of input file")
609  ("OutputBitDepth",        m_outputBitDepthY,   0, "Bit-depth of output file (default:InternalBitDepth)")
610  ("InternalBitDepth",      m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)"
611                                                       "If different to InputBitDepth, source data will be converted")
612  ("InputBitDepthC",        m_inputBitDepthC,    0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
613  ("OutputBitDepthC",       m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
614  ("InternalBitDepthC",     m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
615#if AUXILIARY_PICTURES
616  ("InputChromaFormat",     tmpInputChromaFormat,                       420, "InputChromaFormatIDC")
617  ("ChromaFormatIDC,-cf",   tmpChromaFormat,                             0, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
618#endif
619  ("ConformanceMode",       m_conformanceMode,     0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
620  ("HorizontalPadding,-pdx",m_aiPad[0],            0, "Horizontal source padding for conformance window mode 2")
621  ("VerticalPadding,-pdy",  m_aiPad[1],            0, "Vertical source padding for conformance window mode 2")
622  ("ConfLeft",              m_confLeft,            0, "Left offset for window conformance mode 3")
623  ("ConfRight",             m_confRight,           0, "Right offset for window conformance mode 3")
624  ("ConfTop",               m_confTop,             0, "Top offset for window conformance mode 3")
625  ("ConfBottom",            m_confBottom,          0, "Bottom offset for window conformance mode 3")
626  ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
627#endif //SVC_EXTENSION
628  ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
629  ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
630
631  //Field coding parameters
632  ("FieldCoding", m_isField, false, "Signals if it's a field based coding")
633  ("TopFieldFirst, Tff", m_isTopFieldFirst, false, "In case of field based coding, signals whether if it's a top field first or not")
634 
635  // Profile and level
636  ("Profile", m_profile,   Profile::NONE, "Profile to be used when encoding (Incomplete)")
637  ("Level",   m_level,     Level::NONE,   "Level limit to be used, eg 5.1 (Incomplete)")
638  ("Tier",    m_levelTier, Level::MAIN,   "Tier to use for interpretation of --Level")
639
640  ("ProgressiveSource", m_progressiveSourceFlag, false, "Indicate that source is progressive")
641  ("InterlacedSource",  m_interlacedSourceFlag,  false, "Indicate that source is interlaced")
642  ("NonPackedSource",   m_nonPackedConstraintFlag, false, "Indicate that source does not contain frame packing")
643  ("FrameOnly",         m_frameOnlyConstraintFlag, false, "Indicate that the bitstream contains only frames")
644
645#if LAYER_CTB
646  // Unit definition parameters
647  ("MaxCUWidth%d",              cfg_uiMaxCUWidth,             64u, MAX_LAYERS, "Maximum CU width")
648  ("MaxCUHeight%d",             cfg_uiMaxCUHeight,            64u, MAX_LAYERS, "Maximum CU height")
649  // todo: remove defaults from MaxCUSize
650  ("MaxCUSize%d,s%d",           cfg_uiMaxCUWidth,             64u, MAX_LAYERS, "Maximum CU size")
651  ("MaxCUSize%d,s%d",           cfg_uiMaxCUHeight,            64u, MAX_LAYERS, "Maximum CU size")
652  ("MaxPartitionDepth%d,h%d",   cfg_uiMaxCUDepth,              4u, MAX_LAYERS, "CU depth")
653 
654  ("QuadtreeTULog2MaxSize%d",   cfg_uiQuadtreeTULog2MaxSize,   6u, MAX_LAYERS, "Maximum TU size in logarithm base 2")
655  ("QuadtreeTULog2MinSize%d",   cfg_uiQuadtreeTULog2MinSize,   2u, MAX_LAYERS, "Minimum TU size in logarithm base 2")
656 
657  ("QuadtreeTUMaxDepthIntra%d", cfg_uiQuadtreeTUMaxDepthIntra, 1u, MAX_LAYERS, "Depth of TU tree for intra CUs")
658  ("QuadtreeTUMaxDepthInter%d", cfg_uiQuadtreeTUMaxDepthInter, 2u, MAX_LAYERS, "Depth of TU tree for inter CUs")
659
660
661  // set the same CU realted settings across all the layers if config file parameters are not layer specific
662  ("MaxCUWidth",              cfg_uiMaxCUWidth,             64u, MAX_LAYERS, "Maximum CU width")
663  ("MaxCUHeight",             cfg_uiMaxCUHeight,            64u, MAX_LAYERS, "Maximum CU height")
664  // todo: remove defaults from MaxCUSize
665  ("MaxCUSize,s",             cfg_uiMaxCUWidth,             64u, MAX_LAYERS, "Maximum CU size")
666  ("MaxCUSize,s",             cfg_uiMaxCUHeight,            64u, MAX_LAYERS, "Maximum CU size")
667  ("MaxPartitionDepth,h",     cfg_uiMaxCUDepth,              4u, MAX_LAYERS, "CU depth")
668 
669  ("QuadtreeTULog2MaxSize",   cfg_uiQuadtreeTULog2MaxSize,   6u, MAX_LAYERS, "Maximum TU size in logarithm base 2")
670  ("QuadtreeTULog2MinSize",   cfg_uiQuadtreeTULog2MinSize,   2u, MAX_LAYERS, "Minimum TU size in logarithm base 2")
671 
672  ("QuadtreeTUMaxDepthIntra", cfg_uiQuadtreeTUMaxDepthIntra, 1u, MAX_LAYERS, "Depth of TU tree for intra CUs")
673  ("QuadtreeTUMaxDepthInter", cfg_uiQuadtreeTUMaxDepthInter, 2u, MAX_LAYERS, "Depth of TU tree for inter CUs")
674#else
675  // Unit definition parameters
676  ("MaxCUWidth",              m_uiMaxCUWidth,             64u)
677  ("MaxCUHeight",             m_uiMaxCUHeight,            64u)
678  // todo: remove defaults from MaxCUSize
679  ("MaxCUSize,s",             m_uiMaxCUWidth,             64u, "Maximum CU size")
680  ("MaxCUSize,s",             m_uiMaxCUHeight,            64u, "Maximum CU size")
681  ("MaxPartitionDepth,h",     m_uiMaxCUDepth,              4u, "CU depth")
682 
683  ("QuadtreeTULog2MaxSize",   m_uiQuadtreeTULog2MaxSize,   6u, "Maximum TU size in logarithm base 2")
684  ("QuadtreeTULog2MinSize",   m_uiQuadtreeTULog2MinSize,   2u, "Minimum TU size in logarithm base 2")
685 
686  ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u, "Depth of TU tree for intra CUs")
687  ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u, "Depth of TU tree for inter CUs")
688#endif
689 
690  // Coding structure paramters
691#if SVC_EXTENSION
692  ("IntraPeriod%d,-ip%d",  cfg_IntraPeriod, -1, MAX_LAYERS, "intra period in frames for layer %d, (-1: only first frame)")
693#else
694  ("IntraPeriod,-ip",         m_iIntraPeriod,              -1, "Intra period in frames, (-1: only first frame)")
695#endif
696  ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
697  ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
698  // motion options
699  ("FastSearch",              m_iFastSearch,                1, "0:Full search  1:Diamond  2:PMVFAST")
700  ("SearchRange,-sr",         m_iSearchRange,              96, "Motion search range")
701  ("BipredSearchRange",       m_bipredSearchRange,          4, "Motion search range for bipred refinement")
702  ("HadamardME",              m_bUseHADME,               true, "Hadamard ME for fractional-pel")
703  ("ASR",                     m_bUseASR,                false, "Adaptive motion search range")
704
705#if SVC_EXTENSION
706  ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
707#else
708  // Mode decision parameters
709  ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( Double )1.0, "Lambda modifier for temporal layer 0")
710  ("LambdaModifier1,-LM1", m_adLambdaModifier[ 1 ], ( Double )1.0, "Lambda modifier for temporal layer 1")
711  ("LambdaModifier2,-LM2", m_adLambdaModifier[ 2 ], ( Double )1.0, "Lambda modifier for temporal layer 2")
712  ("LambdaModifier3,-LM3", m_adLambdaModifier[ 3 ], ( Double )1.0, "Lambda modifier for temporal layer 3")
713  ("LambdaModifier4,-LM4", m_adLambdaModifier[ 4 ], ( Double )1.0, "Lambda modifier for temporal layer 4")
714  ("LambdaModifier5,-LM5", m_adLambdaModifier[ 5 ], ( Double )1.0, "Lambda modifier for temporal layer 5")
715  ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( Double )1.0, "Lambda modifier for temporal layer 6")
716#endif
717
718  /* Quantization parameters */
719#if SVC_EXTENSION
720  ("QP%d,-q%d",     cfg_fQP,  30.0, MAX_LAYERS, "Qp value for layer %d, if value is float, QP is switched once during encoding")
721#else
722  ("QP,q",          m_fQP,             30.0, "Qp value, if value is float, QP is switched once during encoding")
723#endif
724  ("DeltaQpRD,-dqr",m_uiDeltaQpRD,       0u, "max dQp offset for slice")
725  ("MaxDeltaQP,d",  m_iMaxDeltaQP,        0, "max dQp offset for block")
726  ("MaxCuDQPDepth,-dqd",  m_iMaxCuDQPDepth,        0, "max depth for a minimum CuDQP")
727
728  ("CbQpOffset,-cbqpofs",  m_cbQpOffset,        0, "Chroma Cb QP Offset")
729  ("CrQpOffset,-crqpofs",  m_crQpOffset,        0, "Chroma Cr QP Offset")
730
731#if ADAPTIVE_QP_SELECTION
732  ("AdaptiveQpSelection,-aqps",   m_bUseAdaptQpSelect,           false, "AdaptiveQpSelection")
733#endif
734
735  ("AdaptiveQP,-aq",                m_bUseAdaptiveQP,           false, "QP adaptation based on a psycho-visual model")
736  ("MaxQPAdaptationRange,-aqr",     m_iQPAdaptationRange,           6, "QP adaptation range")
737#if !SVC_EXTENSION
738  ("dQPFile,m",                     cfg_dQPFile,           string(""), "dQP file name")
739#endif
740  ("RDOQ",                          m_useRDOQ,                  true )
741  ("RDOQTS",                        m_useRDOQTS,                true )
742  ("RDpenalty",                     m_rdPenalty,                0,  "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disbaled  1:RD-penalty  2:maximum RD-penalty")
743 
744  // Deblocking filter parameters
745  ("LoopFilterDisable",              m_bLoopFilterDisable,             false )
746  ("LoopFilterOffsetInPPS",          m_loopFilterOffsetInPPS,          false )
747  ("LoopFilterBetaOffset_div2",      m_loopFilterBetaOffsetDiv2,           0 )
748  ("LoopFilterTcOffset_div2",        m_loopFilterTcOffsetDiv2,             0 )
749  ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false )
750  ("DeblockingFilterMetric",         m_DeblockingFilterMetric,         false )
751
752  // Coding tools
753  ("AMP",                      m_enableAMP,                 true,  "Enable asymmetric motion partitions")
754  ("TransformSkip",            m_useTransformSkip,          false, "Intra transform skipping")
755  ("TransformSkipFast",        m_useTransformSkipFast,      false, "Fast intra transform skipping")
756  ("SAO",                      m_bUseSAO,                   true,  "Enable Sample Adaptive Offset")
757  ("MaxNumOffsetsPerPic",      m_maxNumOffsetsPerPic,       2048,  "Max number of SAO offset per picture (Default: 2048)")   
758  ("SAOLcuBoundary",           m_saoLcuBoundary,            false, "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
759  ("SliceMode",                m_sliceMode,                0,     "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
760  ("SliceArgument",            m_sliceArgument,            0,     "Depending on SliceMode being:"
761                                                                   "\t1: max number of CTUs per slice"
762                                                                   "\t2: max number of bytes per slice"
763                                                                   "\t3: max number of tiles per slice")
764  ("SliceSegmentMode",         m_sliceSegmentMode,       0,     "0: Disable all slice segment limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
765  ("SliceSegmentArgument",     m_sliceSegmentArgument,   0,     "Depending on SliceSegmentMode being:"
766                                                                   "\t1: max number of CTUs per slice segment"
767                                                                   "\t2: max number of bytes per slice segment"
768                                                                   "\t3: max number of tiles per slice segment")
769  ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true)
770
771  ("ConstrainedIntraPred",     m_bUseConstrainedIntraPred,  false, "Constrained Intra Prediction")
772
773  ("PCMEnabledFlag",           m_usePCM,                    false)
774  ("PCMLog2MaxSize",           m_pcmLog2MaxSize,            5u)
775  ("PCMLog2MinSize",           m_uiPCMLog2MinSize,          3u)
776  ("PCMInputBitDepthFlag",     m_bPCMInputBitDepthFlag,     true)
777  ("PCMFilterDisableFlag",     m_bPCMFilterDisableFlag,    false)
778
779  ("WeightedPredP,-wpP",          m_useWeightedPred,               false,      "Use weighted prediction in P slices")
780  ("WeightedPredB,-wpB",          m_useWeightedBiPred,             false,      "Use weighted (bidirectional) prediction in B slices")
781  ("Log2ParallelMergeLevel",      m_log2ParallelMergeLevel,     2u,          "Parallel merge estimation region")
782  ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,          "Indicates if the column and row boundaries are distributed uniformly")
783  ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
784  ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""), "Array containing ColumnWidth values in units of LCU")
785  ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
786  ("RowHeightArray",              cfg_RowHeight,                   string(""), "Array containing RowHeight values in units of LCU")
787  ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,          "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
788  ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
789  ("ScalingList",                 m_useScalingListId,              0,          "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile")
790  ("ScalingListFile",             cfg_ScalingListFile,             string(""), "Scaling list file name")
791  ("SignHideFlag,-SBH",                m_signHideFlag, 1)
792  ("MaxNumMergeCand",             m_maxNumMergeCand,             5u,         "Maximum number of merge candidates")
793
794  /* Misc. */
795  ("SEIDecodedPictureHash",       m_decodedPictureHashSEIEnabled, 0, "Control generation of decode picture hash SEI messages\n"
796                                                                    "\t3: checksum\n"
797                                                                    "\t2: CRC\n"
798                                                                    "\t1: use MD5\n"
799                                                                    "\t0: disable")
800  ("SEIpictureDigest",            m_decodedPictureHashSEIEnabled, 0, "deprecated alias for SEIDecodedPictureHash")
801  ("TMVPMode", m_TMVPModeId, 1, "TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices (default) 2: TMVP enable for certain slices only")
802  ("FEN", m_bUseFastEnc, false, "fast encoder setting")
803  ("ECU", m_bUseEarlyCU, false, "Early CU setting") 
804  ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost") 
805  ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting")
806  ("ESD", m_useEarlySkipDetection, false, "Early SKIP detection setting")
807#if FAST_INTRA_SHVC
808  ("FIS", m_useFastIntraScalable, false, "Fast Intra Decision for Scalable HEVC")
809#endif
810#if RC_SHVC_HARMONIZATION
811  ("RateControl%d", cfg_RCEnableRateControl, false, MAX_LAYERS, "Rate control: enable rate control for layer %d")
812  ("TargetBitrate%d", cfg_RCTargetBitRate, 0, MAX_LAYERS, "Rate control: target bitrate for layer %d")
813  ("KeepHierarchicalBit%d", cfg_RCKeepHierarchicalBit, false, MAX_LAYERS, "Rate control: keep hierarchical bit allocation for layer %d")
814  ("LCULevelRateControl%d", cfg_RCLCULevelRC, true, MAX_LAYERS, "Rate control: LCU level RC")
815  ("RCLCUSeparateModel%d", cfg_RCUseLCUSeparateModel, true, MAX_LAYERS, "Rate control: Use LCU level separate R-lambda model")
816  ("InitialQP%d", cfg_RCInitialQP, 0, MAX_LAYERS, "Rate control: initial QP")
817  ("RCForceIntraQP%d", cfg_RCForceIntraQP, false, MAX_LAYERS, "Rate control: force intra QP to be equal to initial QP")
818#else
819  ( "RateControl",         m_RCEnableRateControl,   false, "Rate control: enable rate control" )
820  ( "TargetBitrate",       m_RCTargetBitrate,           0, "Rate control: target bitrate" )
821  ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit,     0, "Rate control: 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation" )
822  ( "LCULevelRateControl", m_RCLCULevelRC,           true, "Rate control: true: LCU level RC; false: picture level RC" )
823  ( "RCLCUSeparateModel",  m_RCUseLCUSeparateModel,  true, "Rate control: use LCU level separate R-lambda model" )
824  ( "InitialQP",           m_RCInitialQP,               0, "Rate control: initial QP" )
825  ( "RCForceIntraQP",      m_RCForceIntraQP,        false, "Rate control: force intra QP to be equal to initial QP" )
826#endif
827
828  ("TransquantBypassEnableFlag", m_TransquantBypassEnableFlag, false, "transquant_bypass_enable_flag indicator in PPS")
829  ("CUTransquantBypassFlagForce", m_CUTransquantBypassFlagForce, false, "Force transquant bypass mode, when transquant_bypass_enable_flag is enabled")
830  ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
831  ("StrongIntraSmoothing,-sis",      m_useStrongIntraSmoothing,           true, "Enable strong intra smoothing for 32x32 blocks")
832  ("SEIActiveParameterSets",         m_activeParameterSetsSEIEnabled,          0, "Enable generation of active parameter sets SEI messages")
833  ("VuiParametersPresent,-vui",      m_vuiParametersPresentFlag,           false, "Enable generation of vui_parameters()")
834  ("AspectRatioInfoPresent",         m_aspectRatioInfoPresentFlag,         false, "Signals whether aspect_ratio_idc is present")
835  ("AspectRatioIdc",                 m_aspectRatioIdc,                         0, "aspect_ratio_idc")
836  ("SarWidth",                       m_sarWidth,                               0, "horizontal size of the sample aspect ratio")
837  ("SarHeight",                      m_sarHeight,                              0, "vertical size of the sample aspect ratio")
838  ("OverscanInfoPresent",            m_overscanInfoPresentFlag,            false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
839  ("OverscanAppropriate",            m_overscanAppropriateFlag,            false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
840  ("VideoSignalTypePresent",         m_videoSignalTypePresentFlag,         false, "Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present")
841  ("VideoFormat",                    m_videoFormat,                            5, "Indicates representation of pictures")
842  ("VideoFullRange",                 m_videoFullRangeFlag,                 false, "Indicates the black level and range of luma and chroma signals")
843  ("ColourDescriptionPresent",       m_colourDescriptionPresentFlag,       false, "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present")
844  ("ColourPrimaries",                m_colourPrimaries,                        2, "Indicates chromaticity coordinates of the source primaries")
845  ("TransferCharateristics",         m_transferCharacteristics,                2, "Indicates the opto-electronic transfer characteristics of the source")
846  ("MatrixCoefficients",             m_matrixCoefficients,                     2, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries")
847  ("ChromaLocInfoPresent",           m_chromaLocInfoPresentFlag,           false, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present")
848  ("ChromaSampleLocTypeTopField",    m_chromaSampleLocTypeTopField,            0, "Specifies the location of chroma samples for top field")
849  ("ChromaSampleLocTypeBottomField", m_chromaSampleLocTypeBottomField,         0, "Specifies the location of chroma samples for bottom field")
850  ("NeutralChromaIndication",        m_neutralChromaIndicationFlag,        false, "Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)")
851  ("DefaultDisplayWindowFlag",       m_defaultDisplayWindowFlag,           false, "Indicates the presence of the Default Window parameters")
852  ("DefDispWinLeftOffset",           m_defDispWinLeftOffset,                   0, "Specifies the left offset of the default display window from the conformance window")
853  ("DefDispWinRightOffset",          m_defDispWinRightOffset,                  0, "Specifies the right offset of the default display window from the conformance window")
854  ("DefDispWinTopOffset",            m_defDispWinTopOffset,                    0, "Specifies the top offset of the default display window from the conformance window")
855  ("DefDispWinBottomOffset",         m_defDispWinBottomOffset,                 0, "Specifies the bottom offset of the default display window from the conformance window")
856  ("FrameFieldInfoPresentFlag",      m_frameFieldInfoPresentFlag,               false, "Indicates that pic_struct and field coding related values are present in picture timing SEI messages")
857  ("PocProportionalToTimingFlag",   m_pocProportionalToTimingFlag,         false, "Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS")
858  ("NumTicksPocDiffOneMinus1",      m_numTicksPocDiffOneMinus1,                0, "Number of ticks minus 1 that for a POC difference of one")
859  ("BitstreamRestriction",           m_bitstreamRestrictionFlag,           false, "Signals whether bitstream restriction parameters are present")
860  ("TilesFixedStructure",            m_tilesFixedStructureFlag,            false, "Indicates that each active picture parameter set has the same values of the syntax elements related to tiles")
861  ("MotionVectorsOverPicBoundaries", m_motionVectorsOverPicBoundariesFlag, false, "Indicates that no samples outside the picture boundaries are used for inter prediction")
862  ("MaxBytesPerPicDenom",            m_maxBytesPerPicDenom,                    2, "Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture")
863  ("MaxBitsPerMinCuDenom",           m_maxBitsPerMinCuDenom,                   1, "Indicates an upper bound for the number of bits of coding_unit() data")
864  ("Log2MaxMvLengthHorizontal",      m_log2MaxMvLengthHorizontal,             15, "Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units")
865  ("Log2MaxMvLengthVertical",        m_log2MaxMvLengthVertical,               15, "Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units")
866  ("SEIRecoveryPoint",               m_recoveryPointSEIEnabled,                0, "Control generation of recovery point SEI messages")
867  ("SEIBufferingPeriod",             m_bufferingPeriodSEIEnabled,              0, "Control generation of buffering period SEI messages")
868  ("SEIPictureTiming",               m_pictureTimingSEIEnabled,                0, "Control generation of picture timing SEI messages")
869  ("SEIToneMappingInfo",                       m_toneMappingInfoSEIEnabled,    false, "Control generation of Tone Mapping SEI messages")
870  ("SEIToneMapId",                             m_toneMapId,                        0, "Specifies Id of Tone Mapping SEI message for a given session")
871  ("SEIToneMapCancelFlag",                     m_toneMapCancelFlag,            false, "Indicates that Tone Mapping SEI message cancels the persistance or follows")
872  ("SEIToneMapPersistenceFlag",                m_toneMapPersistenceFlag,        true, "Specifies the persistence of the Tone Mapping SEI message")
873  ("SEIToneMapCodedDataBitDepth",              m_toneMapCodedDataBitDepth,         8, "Specifies Coded Data BitDepth of Tone Mapping SEI messages")
874  ("SEIToneMapTargetBitDepth",                 m_toneMapTargetBitDepth,            8, "Specifies Output BitDepth of Tome mapping function")
875  ("SEIToneMapModelId",                        m_toneMapModelId,                   0, "Specifies Model utilized for mapping coded data into target_bit_depth range\n"
876                                                                                      "\t0:  linear mapping with clipping\n"
877                                                                                      "\t1:  sigmoidal mapping\n"
878                                                                                      "\t2:  user-defined table mapping\n"
879                                                                                      "\t3:  piece-wise linear mapping\n"
880                                                                                      "\t4:  luminance dynamic range information ")
881  ("SEIToneMapMinValue",                              m_toneMapMinValue,                          0, "Specifies the minimum value in mode 0")
882  ("SEIToneMapMaxValue",                              m_toneMapMaxValue,                       1023, "Specifies the maxmum value in mode 0")
883  ("SEIToneMapSigmoidMidpoint",                       m_sigmoidMidpoint,                        512, "Specifies the centre point in mode 1")
884  ("SEIToneMapSigmoidWidth",                          m_sigmoidWidth,                           960, "Specifies the distance between 5% and 95% values of the target_bit_depth in mode 1")
885  ("SEIToneMapStartOfCodedInterval",                  cfg_startOfCodedInterval,          string(""), "Array of user-defined mapping table")
886  ("SEIToneMapNumPivots",                             m_numPivots,                                0, "Specifies the number of pivot points in mode 3")
887  ("SEIToneMapCodedPivotValue",                       cfg_codedPivotValue,               string(""), "Array of pivot point")
888  ("SEIToneMapTargetPivotValue",                      cfg_targetPivotValue,              string(""), "Array of pivot point")
889  ("SEIToneMapCameraIsoSpeedIdc",                     m_cameraIsoSpeedIdc,                        0, "Indicates the camera ISO speed for daylight illumination")
890  ("SEIToneMapCameraIsoSpeedValue",                   m_cameraIsoSpeedValue,                    400, "Specifies the camera ISO speed for daylight illumination of Extended_ISO")
891  ("SEIToneMapExposureCompensationValueSignFlag",     m_exposureCompensationValueSignFlag,        0, "Specifies the sign of ExposureCompensationValue")
892  ("SEIToneMapExposureCompensationValueNumerator",    m_exposureCompensationValueNumerator,       0, "Specifies the numerator of ExposureCompensationValue")
893  ("SEIToneMapExposureCompensationValueDenomIdc",     m_exposureCompensationValueDenomIdc,        2, "Specifies the denominator of ExposureCompensationValue")
894  ("SEIToneMapRefScreenLuminanceWhite",               m_refScreenLuminanceWhite,                350, "Specifies reference screen brightness setting in units of candela per square metre")
895  ("SEIToneMapExtendedRangeWhiteLevel",               m_extendedRangeWhiteLevel,                800, "Indicates the luminance dynamic range")
896  ("SEIToneMapNominalBlackLevelLumaCodeValue",        m_nominalBlackLevelLumaCodeValue,          16, "Specifies luma sample value of the nominal black level assigned decoded pictures")
897  ("SEIToneMapNominalWhiteLevelLumaCodeValue",        m_nominalWhiteLevelLumaCodeValue,         235, "Specifies luma sample value of the nominal white level assigned decoded pictures")
898  ("SEIToneMapExtendedWhiteLevelLumaCodeValue",       m_extendedWhiteLevelLumaCodeValue,        300, "Specifies luma sample value of the extended dynamic range assigned decoded pictures")
899  ("SEIFramePacking",                m_framePackingSEIEnabled,                 0, "Control generation of frame packing SEI messages")
900  ("SEIFramePackingType",            m_framePackingSEIType,                    0, "Define frame packing arrangement\n"
901                                                                                  "\t0: checkerboard - pixels alternatively represent either frames\n"
902                                                                                  "\t1: column alternation - frames are interlaced by column\n"
903                                                                                  "\t2: row alternation - frames are interlaced by row\n"
904                                                                                  "\t3: side by side - frames are displayed horizontally\n"
905                                                                                  "\t4: top bottom - frames are displayed vertically\n"
906                                                                                  "\t5: frame alternation - one frame is alternated with the other")
907  ("SEIFramePackingId",              m_framePackingSEIId,                      0, "Id of frame packing SEI message for a given session")
908  ("SEIFramePackingQuincunx",        m_framePackingSEIQuincunx,                0, "Indicate the presence of a Quincunx type video frame")
909  ("SEIFramePackingInterpretation",  m_framePackingSEIInterpretation,          0, "Indicate the interpretation of the frame pair\n"
910                                                                                  "\t0: unspecified\n"
911                                                                                  "\t1: stereo pair, frame0 represents left view\n"
912                                                                                  "\t2: stereo pair, frame0 represents right view")
913  ("SEIDisplayOrientation",          m_displayOrientationSEIAngle,             0, "Control generation of display orientation SEI messages\n"
914                                                              "\tN: 0 < N < (2^16 - 1) enable display orientation SEI message with anticlockwise_rotation = N and display_orientation_repetition_period = 1\n"
915                                                              "\t0: disable")
916  ("SEITemporalLevel0Index",         m_temporalLevel0IndexSEIEnabled,          0, "Control generation of temporal level 0 index SEI messages")
917  ("SEIGradualDecodingRefreshInfo",  m_gradualDecodingRefreshInfoEnabled,      0, "Control generation of gradual decoding refresh information SEI message")
918  ("SEIDecodingUnitInfo",             m_decodingUnitInfoSEIEnabled,                       0, "Control generation of decoding unit information SEI message.")
919#if LAYERS_NOT_PRESENT_SEI
920  ("SEILayersNotPresent",            m_layersNotPresentSEIEnabled,             0, "Control generation of layers not present SEI message")
921#endif
922  ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0, "Control generation of SOP description SEI messages")
923  ("SEIScalableNesting",             m_scalableNestingSEIEnabled,              0, "Control generation of scalable nesting SEI messages")
924#if M0040_ADAPTIVE_RESOLUTION_CHANGE
925  ("AdaptiveResolutionChange",     m_adaptiveResolutionChange, 0, "Adaptive resolution change frame number. Should coincide with EL RAP picture. (0: disable)")
926#endif
927#if HIGHER_LAYER_IRAP_SKIP_FLAG
928  ("SkipPictureAtArcSwitch",     m_skipPictureAtArcSwitch, false, "Code the higher layer picture in ARC up-switching as a skip picture. (0: disable)")
929#endif
930#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
931  ("SEIInterLayerConstrainedTileSets", m_interLayerConstrainedTileSetsSEIEnabled, false, "Control generation of inter layer constrained tile sets SEI message")
932  ("IlNumSetsInMessage",               m_ilNumSetsInMessage,                         0u, "Number of inter layer constrained tile sets")
933  ("TileSetsArray",                    cfg_tileSets,                         string(""), "Array containing tile sets params (TopLeftTileIndex, BottonRightTileIndex and ilcIdc for each set) ")
934#endif
935#if O0153_ALT_OUTPUT_LAYER_FLAG
936  ("AltOutputLayerFlag",               m_altOutputLayerFlag,                      false, "Specifies the value of alt_output_layer_flag in VPS extension")
937#endif
938#if O0149_CROSS_LAYER_BLA_FLAG
939  ("CrossLayerBLAFlag",                m_crossLayerBLAFlag,                       false, "Specifies the value of cross_layer_bla_flag in VPS")
940#endif
941  ;
942 
943  for(Int i=1; i<MAX_GOP+1; i++) {
944    std::ostringstream cOSS;
945    cOSS<<"Frame"<<i;
946    opts.addOptions()(cOSS.str(), m_GOPList[i-1], GOPEntry());
947  }
948  po::setDefaults(opts);
949  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
950
951  if(m_isField)
952  {
953#if SVC_EXTENSION
954    for(Int layer = 0; layer < MAX_LAYERS; layer++)
955    {
956      //Frame height
957      m_acLayerCfg[layer].m_iSourceHeightOrg = m_acLayerCfg[layer].m_iSourceHeight;
958      //Field height
959      m_acLayerCfg[layer].m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight >> 1;
960    }
961#else
962    //Frame height
963    m_iSourceHeightOrg = m_iSourceHeight;
964    //Field height
965    m_iSourceHeight = m_iSourceHeight >> 1;
966#endif
967    //number of fields to encode
968    m_framesToBeEncoded *= 2;
969  }
970 
971  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
972  {
973    fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
974  }
975 
976  if (argc == 1 || do_help)
977  {
978    /* argc == 1: no options have been specified */
979    po::doHelp(cout, opts);
980    return false;
981  }
982 
983  /*
984   * Set any derived parameters
985   */
986  /* convert std::string to c string for compatability */
987#if SVC_EXTENSION
988#if AVC_BASE
989  if( m_avcBaseLayerFlag )
990  {
991    *cfg_InputFile[0] = cfg_BLInputFile;
992  }
993#endif
994  m_pBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
995#if AVC_SYNTAX
996  m_BLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str());
997#endif
998#else //SVC_EXTENSION
999  m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str());
1000  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
1001  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
1002  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
1003#endif //SVC_EXTENSION
1004
1005  Char* pColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
1006  Char* pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
1007  if( m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0 )
1008  {
1009    char *columnWidth;
1010    int  i=0;
1011    m_pColumnWidth = new UInt[m_iNumColumnsMinus1];
1012    columnWidth = strtok(pColumnWidth, " ,-");
1013    while(columnWidth!=NULL)
1014    {
1015      if( i>=m_iNumColumnsMinus1 )
1016      {
1017        printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" );
1018        exit( EXIT_FAILURE );
1019      }
1020      *( m_pColumnWidth + i ) = atoi( columnWidth );
1021      columnWidth = strtok(NULL, " ,-");
1022      i++;
1023    }
1024    if( i<m_iNumColumnsMinus1 )
1025    {
1026      printf( "The width of some columns is not defined.\n" );
1027      exit( EXIT_FAILURE );
1028    }
1029  }
1030  else
1031  {
1032    m_pColumnWidth = NULL;
1033  }
1034
1035  if( m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0 )
1036  {
1037    char *rowHeight;
1038    int  i=0;
1039    m_pRowHeight = new UInt[m_iNumRowsMinus1];
1040    rowHeight = strtok(pRowHeight, " ,-");
1041    while(rowHeight!=NULL)
1042    {
1043      if( i>=m_iNumRowsMinus1 )
1044      {
1045        printf( "The number of rows whose height are defined is larger than the allowed number of rows.\n" );
1046        exit( EXIT_FAILURE );
1047      }
1048      *( m_pRowHeight + i ) = atoi( rowHeight );
1049      rowHeight = strtok(NULL, " ,-");
1050      i++;
1051    }
1052    if( i<m_iNumRowsMinus1 )
1053    {
1054      printf( "The height of some rows is not defined.\n" );
1055      exit( EXIT_FAILURE );
1056   }
1057  }
1058  else
1059  {
1060    m_pRowHeight = NULL;
1061  }
1062#if SVC_EXTENSION
1063  for(Int layer = 0; layer < MAX_LAYERS; layer++)
1064  {
1065    // If number of scaled ref. layer offsets is non-zero, at least one of the offsets should be specified
1066    if(m_acLayerCfg[layer].m_numScaledRefLayerOffsets)
1067    {
1068#if O0098_SCALED_REF_LAYER_ID
1069      assert( strcmp(cfg_scaledRefLayerId[layer].c_str(),  ""));
1070#endif
1071      assert( strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(),  "") ||
1072              strcmp(cfg_scaledRefLayerRightOffset[layer].c_str(), "") ||
1073              strcmp(cfg_scaledRefLayerTopOffset[layer].c_str(),   "") ||
1074              strcmp(cfg_scaledRefLayerBottomOffset[layer].c_str(),"")
1075            ); 
1076    }
1077
1078    Int *tempArray = NULL;   // Contain the value
1079
1080#if O0098_SCALED_REF_LAYER_ID
1081    // ID //
1082    if(strcmp(cfg_scaledRefLayerId[layer].c_str(),  ""))
1083    {
1084      cfgStringToArray( &tempArray, cfg_scaledRefLayerId[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "ScaledRefLayerId");
1085      if(tempArray)
1086      {
1087        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
1088        {
1089          m_acLayerCfg[layer].m_scaledRefLayerId[i] = tempArray[i];
1090        }
1091        delete [] tempArray; tempArray = NULL;
1092      }
1093    }
1094#endif
1095
1096    // Left offset //
1097    if(strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(),  ""))
1098    {
1099      cfgStringToArray( &tempArray, cfg_scaledRefLayerLeftOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "LeftOffset");
1100      if(tempArray)
1101      {
1102        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
1103        {
1104          m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i] = tempArray[i];
1105        }
1106        delete [] tempArray; tempArray = NULL;
1107      }
1108    }
1109
1110    // Top offset //
1111    if(strcmp(cfg_scaledRefLayerTopOffset[layer].c_str(),  ""))
1112    {
1113      cfgStringToArray( &tempArray, cfg_scaledRefLayerTopOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "TopOffset");
1114      if(tempArray)
1115      {
1116        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
1117        {
1118          m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i] = tempArray[i];
1119        }
1120        delete [] tempArray; tempArray = NULL;
1121      }
1122    }
1123
1124    // Right offset //
1125    if(strcmp(cfg_scaledRefLayerRightOffset[layer].c_str(),  ""))
1126    {
1127      cfgStringToArray( &tempArray, cfg_scaledRefLayerRightOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RightOffset");
1128      if(tempArray)
1129      {
1130        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
1131        {
1132          m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i] = tempArray[i];
1133        }
1134        delete [] tempArray; tempArray = NULL;
1135      }
1136    }
1137
1138    // Bottom offset //
1139    if(strcmp(cfg_scaledRefLayerBottomOffset[layer].c_str(),  ""))
1140    {
1141      cfgStringToArray( &tempArray, cfg_scaledRefLayerBottomOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "BottomOffset");
1142      if(tempArray)
1143      {
1144        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
1145        {
1146          m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i] = tempArray[i];
1147        }
1148        delete [] tempArray; tempArray = NULL;
1149      }
1150    }
1151  }
1152#if VPS_EXTN_DIRECT_REF_LAYERS
1153  for(Int layer = 0; layer < MAX_LAYERS; layer++)
1154  {
1155    Char* pSamplePredRefLayerIds = cfg_samplePredRefLayerIds[layer].empty() ? NULL: strdup(cfg_samplePredRefLayerIds[layer].c_str());
1156    if( m_acLayerCfg[layer].m_numSamplePredRefLayers > 0 )
1157    {
1158      char *samplePredRefLayerId;
1159      int  i=0;
1160      m_acLayerCfg[layer].m_samplePredRefLayerIds = new Int[m_acLayerCfg[layer].m_numSamplePredRefLayers];
1161      samplePredRefLayerId = strtok(pSamplePredRefLayerIds, " ,-");
1162      while(samplePredRefLayerId != NULL)
1163      {
1164        if( i >= m_acLayerCfg[layer].m_numSamplePredRefLayers )
1165        {
1166          printf( "NumSamplePredRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
1167          exit( EXIT_FAILURE );
1168        }
1169        *( m_acLayerCfg[layer].m_samplePredRefLayerIds + i ) = atoi( samplePredRefLayerId );
1170        samplePredRefLayerId = strtok(NULL, " ,-");
1171        i++;
1172      }
1173      if( i < m_acLayerCfg[layer].m_numSamplePredRefLayers )
1174      {
1175        printf( "NumSamplePredRefLayers: The width of some columns is not defined.\n" );
1176        exit( EXIT_FAILURE );
1177      }
1178    }
1179    else
1180    {
1181      m_acLayerCfg[layer].m_samplePredRefLayerIds = NULL;
1182    }
1183  }
1184  for(Int layer = 0; layer < MAX_LAYERS; layer++)
1185  {
1186    Char* pMotionPredRefLayerIds = cfg_motionPredRefLayerIds[layer].empty() ? NULL: strdup(cfg_motionPredRefLayerIds[layer].c_str());
1187    if( m_acLayerCfg[layer].m_numMotionPredRefLayers > 0 )
1188    {
1189      char *motionPredRefLayerId;
1190      int  i=0;
1191      m_acLayerCfg[layer].m_motionPredRefLayerIds = new Int[m_acLayerCfg[layer].m_numMotionPredRefLayers];
1192      motionPredRefLayerId = strtok(pMotionPredRefLayerIds, " ,-");
1193      while(motionPredRefLayerId != NULL)
1194      {
1195        if( i >= m_acLayerCfg[layer].m_numMotionPredRefLayers )
1196        {
1197          printf( "NumMotionPredRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
1198          exit( EXIT_FAILURE );
1199        }
1200        *( m_acLayerCfg[layer].m_motionPredRefLayerIds + i ) = atoi( motionPredRefLayerId );
1201        motionPredRefLayerId = strtok(NULL, " ,-");
1202        i++;
1203      }
1204      if( i < m_acLayerCfg[layer].m_numMotionPredRefLayers )
1205      {
1206        printf( "NumMotionPredRefLayers: The width of some columns is not defined.\n" );
1207        exit( EXIT_FAILURE );
1208      }
1209    }
1210    else
1211    {
1212      m_acLayerCfg[layer].m_motionPredRefLayerIds = NULL;
1213    }
1214  }
1215
1216#if AUXILIARY_PICTURES
1217  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
1218  {
1219    m_acLayerCfg[layer].m_InputChromaFormat =  numberToChromaFormat(cfg_tmpChromaFormatIDC[layer]);
1220    m_acLayerCfg[layer].m_chromaFormatIDC = ((cfg_tmpChromaFormatIDC[layer] == 0) ? (m_acLayerCfg[layer].m_InputChromaFormat ) : (numberToChromaFormat(cfg_tmpChromaFormatIDC[layer])));
1221  }
1222#endif
1223  for(Int layer = 0; layer < MAX_LAYERS; layer++)
1224  {
1225    Char* pPredLayerIds = cfg_predLayerIds[layer].empty() ? NULL: strdup(cfg_predLayerIds[layer].c_str());
1226    if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 )
1227    {
1228      char *refLayerId;
1229      int  i=0;
1230      m_acLayerCfg[layer].m_predLayerIds = new Int[m_acLayerCfg[layer].m_numActiveRefLayers];
1231      refLayerId = strtok(pPredLayerIds, " ,-");
1232      while(refLayerId != NULL)
1233      {
1234        if( i >= m_acLayerCfg[layer].m_numActiveRefLayers )
1235        {
1236          printf( "NumActiveRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
1237          exit( EXIT_FAILURE );
1238        }
1239        *( m_acLayerCfg[layer].m_predLayerIds + i ) = atoi( refLayerId );
1240        refLayerId = strtok(NULL, " ,-");
1241        i++;
1242      }
1243      if( i < m_acLayerCfg[layer].m_numActiveRefLayers )
1244      {
1245        printf( "NumActiveRefLayers: The width of some columns is not defined.\n" );
1246        exit( EXIT_FAILURE );
1247      }
1248    }
1249    else
1250    {
1251      m_acLayerCfg[layer].m_predLayerIds = NULL;
1252    }
1253  }
1254#endif
1255#endif //SVC_EXTENSION
1256  m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
1257
1258  /* rules for input, output and internal bitdepths as per help text */
1259#if O0194_DIFFERENT_BITDEPTH_EL_BL
1260  for(Int layer = 0; layer < MAX_LAYERS; layer++)
1261  {
1262    if (!m_acLayerCfg[layer].m_internalBitDepthY) { m_acLayerCfg[layer].m_internalBitDepthY = m_acLayerCfg[layer].m_inputBitDepthY; }
1263    if (!m_acLayerCfg[layer].m_internalBitDepthC) { m_acLayerCfg[layer].m_internalBitDepthC = m_acLayerCfg[layer].m_internalBitDepthY; }
1264    if (!m_acLayerCfg[layer].m_inputBitDepthC) { m_acLayerCfg[layer].m_inputBitDepthC = m_acLayerCfg[layer].m_inputBitDepthY; }
1265    if (!m_acLayerCfg[layer].m_outputBitDepthY) { m_acLayerCfg[layer].m_outputBitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; }
1266    if (!m_acLayerCfg[layer].m_outputBitDepthC) { m_acLayerCfg[layer].m_outputBitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; }
1267  }
1268#else
1269  if (!m_internalBitDepthY) { m_internalBitDepthY = m_inputBitDepthY; }
1270  if (!m_internalBitDepthC) { m_internalBitDepthC = m_internalBitDepthY; }
1271  if (!m_inputBitDepthC) { m_inputBitDepthC = m_inputBitDepthY; }
1272  if (!m_outputBitDepthY) { m_outputBitDepthY = m_internalBitDepthY; }
1273  if (!m_outputBitDepthC) { m_outputBitDepthC = m_internalBitDepthC; }
1274#endif
1275
1276#if !SVC_EXTENSION
1277  // TODO:ChromaFmt assumes 4:2:0 below
1278  switch (m_conformanceMode)
1279  {
1280  case 0:
1281    {
1282      // no conformance or padding
1283      m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
1284      m_aiPad[1] = m_aiPad[0] = 0;
1285      break;
1286    }
1287  case 1:
1288    {
1289      // automatic padding to minimum CU size
1290      Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1);
1291      if (m_iSourceWidth % minCuSize)
1292      {
1293        m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
1294        m_iSourceWidth  += m_confRight;
1295      }
1296      if (m_iSourceHeight % minCuSize)
1297      {
1298        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
1299        m_iSourceHeight += m_confBottom;
1300        if ( m_isField )
1301        {
1302          m_iSourceHeightOrg += m_confBottom << 1;
1303          m_aiPad[1] = m_confBottom << 1;
1304        }
1305      }
1306      if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0)
1307      {
1308        fprintf(stderr, "Error: picture width is not an integer multiple of the specified chroma subsampling\n");
1309        exit(EXIT_FAILURE);
1310      }
1311      if (m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0)
1312      {
1313        fprintf(stderr, "Error: picture height is not an integer multiple of the specified chroma subsampling\n");
1314        exit(EXIT_FAILURE);
1315      }
1316      break;
1317    }
1318  case 2:
1319    {
1320      //padding
1321      m_iSourceWidth  += m_aiPad[0];
1322      m_iSourceHeight += m_aiPad[1];
1323      m_confRight  = m_aiPad[0];
1324      m_confBottom = m_aiPad[1];
1325      break;
1326    }
1327  case 3:
1328    {
1329      // conformance
1330      if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
1331      {
1332        fprintf(stderr, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n");
1333      }
1334      if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0))
1335      {
1336        fprintf(stderr, "Warning: Conformance window enabled, padding parameters will be ignored\n");
1337      }
1338      m_aiPad[1] = m_aiPad[0] = 0;
1339      break;
1340    }
1341  }
1342 
1343  // allocate slice-based dQP values
1344  m_aidQP = new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ];
1345  ::memset( m_aidQP, 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
1346 
1347  // handling of floating-point QP values
1348  // if QP is not integer, sequence is split into two sections having QP and QP+1
1349  m_iQP = (Int)( m_fQP );
1350  if ( m_iQP < m_fQP )
1351  {
1352    Int iSwitchPOC = (Int)( m_framesToBeEncoded - (m_fQP - m_iQP)*m_framesToBeEncoded + 0.5 );
1353   
1354    iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
1355    for ( Int i=iSwitchPOC; i<m_framesToBeEncoded + m_iGOPSize + 1; i++ )
1356    {
1357      m_aidQP[i] = 1;
1358    }
1359  }
1360 
1361  // reading external dQP description from file
1362  if ( m_pchdQPFile )
1363  {
1364    FILE* fpt=fopen( m_pchdQPFile, "r" );
1365    if ( fpt )
1366    {
1367      Int iValue;
1368      Int iPOC = 0;
1369      while ( iPOC < m_framesToBeEncoded )
1370      {
1371        if ( fscanf(fpt, "%d", &iValue ) == EOF ) break;
1372        m_aidQP[ iPOC ] = iValue;
1373        iPOC++;
1374      }
1375      fclose(fpt);
1376    }
1377  }
1378  m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
1379#endif
1380  if( m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag )
1381  {
1382    Char* pcStartOfCodedInterval = cfg_startOfCodedInterval.empty() ? NULL: strdup(cfg_startOfCodedInterval.c_str());
1383    Char* pcCodedPivotValue = cfg_codedPivotValue.empty() ? NULL: strdup(cfg_codedPivotValue.c_str());
1384    Char* pcTargetPivotValue = cfg_targetPivotValue.empty() ? NULL: strdup(cfg_targetPivotValue.c_str());
1385    if( m_toneMapModelId == 2 && pcStartOfCodedInterval )
1386    {
1387      char *startOfCodedInterval;
1388      UInt num = 1u<< m_toneMapTargetBitDepth;
1389      m_startOfCodedInterval = new Int[num];
1390      ::memset( m_startOfCodedInterval, 0, sizeof(Int)*num );
1391      startOfCodedInterval = strtok(pcStartOfCodedInterval, " .");
1392      int i = 0;
1393      while( startOfCodedInterval && ( i < num ) )
1394      {
1395        m_startOfCodedInterval[i] = atoi( startOfCodedInterval );
1396        startOfCodedInterval = strtok(NULL, " .");
1397        i++;
1398      }
1399    } 
1400    else
1401    {
1402      m_startOfCodedInterval = NULL;
1403    }
1404    if( ( m_toneMapModelId == 3 ) && ( m_numPivots > 0 ) )
1405    {
1406      if( pcCodedPivotValue && pcTargetPivotValue )
1407      {
1408        char *codedPivotValue;
1409        char *targetPivotValue;
1410        m_codedPivotValue = new Int[m_numPivots];
1411        m_targetPivotValue = new Int[m_numPivots];
1412        ::memset( m_codedPivotValue, 0, sizeof(Int)*( m_numPivots ) );
1413        ::memset( m_targetPivotValue, 0, sizeof(Int)*( m_numPivots ) );
1414        codedPivotValue = strtok(pcCodedPivotValue, " .");
1415        int i=0;
1416        while(codedPivotValue&&i<m_numPivots)
1417        {
1418          m_codedPivotValue[i] = atoi( codedPivotValue );
1419          codedPivotValue = strtok(NULL, " .");
1420          i++;
1421        }
1422        i=0;
1423        targetPivotValue = strtok(pcTargetPivotValue, " .");
1424        while(targetPivotValue&&i<m_numPivots)
1425        {
1426          m_targetPivotValue[i]= atoi( targetPivotValue );
1427          targetPivotValue = strtok(NULL, " .");
1428          i++;
1429        }
1430      }
1431    }
1432    else
1433    {
1434      m_codedPivotValue = NULL;
1435      m_targetPivotValue = NULL;
1436    }
1437  }
1438#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
1439  if (m_interLayerConstrainedTileSetsSEIEnabled)
1440  {
1441    if (m_iNumColumnsMinus1 == 0 && m_iNumRowsMinus1 == 0)
1442    {
1443      printf( "Tiles are not defined (needed for inter-layer comnstrained tile sets SEI).\n" );
1444      exit( EXIT_FAILURE );
1445    }
1446    Char* pTileSets = cfg_tileSets.empty() ? NULL : strdup(cfg_tileSets.c_str());
1447    int i = 0;
1448    char *topLeftTileIndex = strtok(pTileSets, " ,");
1449    while(topLeftTileIndex != NULL)
1450    {
1451      if( i >= m_ilNumSetsInMessage )
1452      {
1453        printf( "The number of tile sets is larger than defined by IlNumSetsInMessage.\n" );
1454        exit( EXIT_FAILURE );
1455      }
1456      *( m_topLeftTileIndex + i ) = atoi( topLeftTileIndex );
1457      char *bottonRightTileIndex = strtok(NULL, " ,");
1458      if( bottonRightTileIndex == NULL )
1459      {
1460        printf( "BottonRightTileIndex is missing in the tile sets.\n" );
1461        exit( EXIT_FAILURE );
1462      }
1463      *( m_bottomRightTileIndex + i ) = atoi( bottonRightTileIndex );
1464      char *ilcIdc = strtok(NULL, " ,");
1465      if( ilcIdc == NULL )
1466      {
1467        printf( "IlcIdc is missing in the tile sets.\n" );
1468        exit( EXIT_FAILURE );
1469      }
1470      *( m_ilcIdc + i ) = atoi( ilcIdc );
1471      topLeftTileIndex = strtok(NULL, " ,");
1472      i++;
1473    }
1474    if( i < m_ilNumSetsInMessage )
1475    {
1476      printf( "The number of tile sets is smaller than defined by IlNumSetsInMessage.\n" );
1477      exit( EXIT_FAILURE );
1478    }
1479    m_skippedTileSetPresentFlag = false;
1480  }
1481#endif
1482  // check validity of input parameters
1483  xCheckParameter();
1484 
1485  // set global varibles
1486#if LAYER_CTB
1487  for(Int layer = 0; layer < MAX_LAYERS; layer++)
1488  {
1489    xSetGlobal(layer);
1490  }
1491#else
1492  xSetGlobal();
1493#endif
1494 
1495  // print-out parameters
1496  xPrintParameter();
1497 
1498  return true;
1499}
1500// ====================================================================================================================
1501// Private member functions
1502// ====================================================================================================================
1503
1504Bool confirmPara(Bool bflag, const Char* message);
1505
1506Void TAppEncCfg::xCheckParameter()
1507{
1508  if (!m_decodedPictureHashSEIEnabled)
1509  {
1510    fprintf(stderr, "******************************************************************\n");
1511    fprintf(stderr, "** WARNING: --SEIDecodedPictureHash is now disabled by default. **\n");
1512    fprintf(stderr, "**          Automatic verification of decoded pictures by a     **\n");
1513    fprintf(stderr, "**          decoder requires this option to be enabled.         **\n");
1514    fprintf(stderr, "******************************************************************\n");
1515  }
1516  if( m_profile==Profile::NONE )
1517  {
1518    fprintf(stderr, "***************************************************************************\n");
1519    fprintf(stderr, "** WARNING: For conforming bitstreams a valid Profile value must be set! **\n");
1520    fprintf(stderr, "***************************************************************************\n");
1521  }
1522  if( m_level==Level::NONE )
1523  {
1524    fprintf(stderr, "***************************************************************************\n");
1525    fprintf(stderr, "** WARNING: For conforming bitstreams a valid Level value must be set!   **\n");
1526    fprintf(stderr, "***************************************************************************\n");
1527  }
1528
1529  Bool check_failed = false; /* abort if there is a fatal configuration problem */
1530#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
1531  // check range of parameters
1532#if O0194_DIFFERENT_BITDEPTH_EL_BL
1533  for(UInt layer=0; layer<m_numLayers; layer++)
1534  {
1535    xConfirmPara( m_acLayerCfg[layer].m_inputBitDepthY < 8,                                                     "InputBitDepth must be at least 8" );
1536    xConfirmPara( m_acLayerCfg[layer].m_inputBitDepthC < 8,                                                     "InputBitDepthC must be at least 8" );
1537  }
1538#else
1539  xConfirmPara( m_inputBitDepthY < 8,                                                     "InputBitDepth must be at least 8" );
1540  xConfirmPara( m_inputBitDepthC < 8,                                                     "InputBitDepthC must be at least 8" );
1541#endif
1542#if !SVC_EXTENSION 
1543  xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
1544#endif
1545  xConfirmPara( m_framesToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 0" );
1546  xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
1547  xConfirmPara( m_iGOPSize > 1 &&  m_iGOPSize % 2,                                          "GOP Size must be a multiple of 2, if GOP Size is greater than 1" );
1548#if !SVC_EXTENSION
1549  xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
1550#endif
1551  xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
1552#if !SVC_EXTENSION
1553  xConfirmPara( m_iQP <  -6 * (m_internalBitDepthY - 8) || m_iQP > 51,                    "QP exceeds supported range (-QpBDOffsety to 51)" );
1554#endif
1555  xConfirmPara( m_loopFilterBetaOffsetDiv2 < -6 || m_loopFilterBetaOffsetDiv2 > 6,          "Loop Filter Beta Offset div. 2 exceeds supported range (-6 to 6)");
1556  xConfirmPara( m_loopFilterTcOffsetDiv2 < -6 || m_loopFilterTcOffsetDiv2 > 6,              "Loop Filter Tc Offset div. 2 exceeds supported range (-6 to 6)");
1557  xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2,                                     "Fast Search Mode is not supported value (0:Full search  1:Diamond  2:PMVFAST)" );
1558  xConfirmPara( m_iSearchRange < 0 ,                                                        "Search Range must be more than 0" );
1559  xConfirmPara( m_bipredSearchRange < 0 ,                                                   "Search Range must be more than 0" );
1560  xConfirmPara( m_iMaxDeltaQP > 7,                                                          "Absolute Delta QP exceeds supported range (0 to 7)" );
1561#if LAYER_CTB
1562  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
1563  {
1564    xConfirmPara( m_iMaxCuDQPDepth > m_acLayerCfg[layer].m_uiMaxCUDepth - 1,                "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" );
1565  }
1566#else
1567  xConfirmPara( m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1,                                          "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" );
1568#endif
1569
1570  xConfirmPara( m_cbQpOffset < -12,   "Min. Chroma Cb QP Offset is -12" );
1571  xConfirmPara( m_cbQpOffset >  12,   "Max. Chroma Cb QP Offset is  12" );
1572  xConfirmPara( m_crQpOffset < -12,   "Min. Chroma Cr QP Offset is -12" );
1573  xConfirmPara( m_crQpOffset >  12,   "Max. Chroma Cr QP Offset is  12" );
1574
1575  xConfirmPara( m_iQPAdaptationRange <= 0,                                                  "QP Adaptation Range must be more than 0" );
1576#if !SVC_EXTENSION
1577  if (m_iDecodingRefreshType == 2)
1578  {
1579    xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
1580  }
1581#endif
1582#if !LAYER_CTB
1583  xConfirmPara( (m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,                                    "Minimum partition width size should be larger than or equal to 8");
1584  xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4,                                    "Minimum partition height size should be larger than or equal to 8");
1585  xConfirmPara( m_uiMaxCUWidth < 16,                                                        "Maximum partition width size should be larger than or equal to 16");
1586  xConfirmPara( m_uiMaxCUHeight < 16,                                                       "Maximum partition height size should be larger than or equal to 16");
1587#endif
1588#if !SVC_EXTENSION
1589  xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame width must be a multiple of the minimum CU size");
1590  xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame height must be a multiple of the minimum CU size");
1591#endif
1592 
1593#if !LAYER_CTB
1594  xConfirmPara( m_uiQuadtreeTULog2MinSize < 2,                                        "QuadtreeTULog2MinSize must be 2 or greater.");
1595  xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5,                                        "QuadtreeTULog2MaxSize must be 5 or smaller.");
1596  xConfirmPara( (1<<m_uiQuadtreeTULog2MaxSize) > m_uiMaxCUWidth,                                        "QuadtreeTULog2MaxSize must be log2(maxCUSize) or smaller.");
1597 
1598  xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize,                "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize.");
1599  xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS
1600  xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUHeight>>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS
1601  xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUWidth  >> m_uiMaxCUDepth ), "Minimum CU width must be greater than minimum transform size." );
1602  xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." );
1603  xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1,                                                         "QuadtreeTUMaxDepthInter must be greater than or equal to 1" );
1604  xConfirmPara( m_uiMaxCUWidth < ( 1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthInter - 1) ), "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1" );
1605  xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1,                                                         "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" );
1606  xConfirmPara( m_uiMaxCUWidth < ( 1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthIntra - 1) ), "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1" );
1607#endif
1608 
1609  xConfirmPara(  m_maxNumMergeCand < 1,  "MaxNumMergeCand must be 1 or greater.");
1610  xConfirmPara(  m_maxNumMergeCand > 5,  "MaxNumMergeCand must be 5 or smaller.");
1611
1612#if !SVC_EXTENSION
1613#if ADAPTIVE_QP_SELECTION
1614  xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
1615  xConfirmPara( m_bUseAdaptQpSelect == true && (m_cbQpOffset !=0 || m_crQpOffset != 0 ),               "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0.");
1616#endif
1617#endif
1618
1619  if( m_usePCM)
1620  {
1621    xConfirmPara(  m_uiPCMLog2MinSize < 3,                                      "PCMLog2MinSize must be 3 or greater.");
1622    xConfirmPara(  m_uiPCMLog2MinSize > 5,                                      "PCMLog2MinSize must be 5 or smaller.");
1623    xConfirmPara(  m_pcmLog2MaxSize > 5,                                        "PCMLog2MaxSize must be 5 or smaller.");
1624    xConfirmPara(  m_pcmLog2MaxSize < m_uiPCMLog2MinSize,                       "PCMLog2MaxSize must be equal to or greater than m_uiPCMLog2MinSize.");
1625  }
1626
1627  xConfirmPara( m_sliceMode < 0 || m_sliceMode > 3, "SliceMode exceeds supported range (0 to 3)" );
1628  if (m_sliceMode!=0)
1629  {
1630    xConfirmPara( m_sliceArgument < 1 ,         "SliceArgument should be larger than or equal to 1" );
1631  }
1632  xConfirmPara( m_sliceSegmentMode < 0 || m_sliceSegmentMode > 3, "SliceSegmentMode exceeds supported range (0 to 3)" );
1633  if (m_sliceSegmentMode!=0)
1634  {
1635    xConfirmPara( m_sliceSegmentArgument < 1 ,         "SliceSegmentArgument should be larger than or equal to 1" );
1636  }
1637 
1638  Bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 );
1639  xConfirmPara( tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
1640
1641  //TODO:ChromaFmt assumes 4:2:0 below
1642#if !SVC_EXTENSION
1643  xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
1644  xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
1645
1646  xConfirmPara( m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
1647  xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
1648
1649  xConfirmPara( m_confLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
1650  xConfirmPara( m_confRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
1651  xConfirmPara( m_confTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
1652  xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
1653#endif
1654
1655#if !LAYER_CTB
1656  // max CU width and height should be power of 2
1657  UInt ui = m_uiMaxCUWidth;
1658  while(ui)
1659  {
1660    ui >>= 1;
1661    if( (ui & 1) == 1)
1662      xConfirmPara( ui != 1 , "Width should be 2^n");
1663  }
1664  ui = m_uiMaxCUHeight;
1665  while(ui)
1666  {
1667    ui >>= 1;
1668    if( (ui & 1) == 1)
1669      xConfirmPara( ui != 1 , "Height should be 2^n");
1670  }
1671#endif
1672
1673  /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure
1674   * This permits the ability to omit a GOP structure specification */
1675#if SVC_EXTENSION
1676  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
1677  {
1678    Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod;
1679#endif
1680  if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1) {
1681    m_GOPList[0] = GOPEntry();
1682    m_GOPList[0].m_QPFactor = 1;
1683    m_GOPList[0].m_betaOffsetDiv2 = 0;
1684    m_GOPList[0].m_tcOffsetDiv2 = 0;
1685    m_GOPList[0].m_POC = 1;
1686    m_GOPList[0].m_numRefPicsActive = 4;
1687  }
1688#if SVC_EXTENSION
1689  }
1690#endif
1691 
1692
1693  Bool verifiedGOP=false;
1694  Bool errorGOP=false;
1695  Int checkGOP=1;
1696  Int numRefs = m_isField ? 2 : 1;
1697  Int refList[MAX_NUM_REF_PICS+1];
1698  refList[0]=0;
1699  if(m_isField)
1700  {
1701    refList[1] = 1;
1702  }
1703  Bool isOK[MAX_GOP];
1704  for(Int i=0; i<MAX_GOP; i++) 
1705  {
1706    isOK[i]=false;
1707  }
1708  Int numOK=0;
1709#if !SVC_EXTENSION
1710  xConfirmPara( m_iIntraPeriod >=0&&(m_iIntraPeriod%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" );
1711#endif
1712
1713  for(Int i=0; i<m_iGOPSize; i++)
1714  {
1715    if(m_GOPList[i].m_POC==m_iGOPSize)
1716    {
1717      xConfirmPara( m_GOPList[i].m_temporalId!=0 , "The last frame in each GOP must have temporal ID = 0 " );
1718    }
1719  }
1720
1721#if SVC_EXTENSION
1722  xConfirmPara( m_numLayers > MAX_LAYERS , "Number of layers in config file is greater than MAX_LAYERS" );
1723  m_numLayers = m_numLayers > MAX_LAYERS ? MAX_LAYERS : m_numLayers;
1724
1725  // verify layer configuration parameters
1726  for(UInt layer=0; layer<m_numLayers; layer++)
1727  {
1728    if(m_acLayerCfg[layer].xCheckParameter(m_isField))
1729    {
1730      printf("\nError: invalid configuration parameter found in layer %d \n", layer);
1731      check_failed = true;
1732    }
1733  }
1734
1735  // verify layer configuration parameters
1736  for(UInt layer=0; layer<m_numLayers; layer++)
1737  {
1738    Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod;
1739#endif
1740  if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable) )
1741  {
1742    for(Int i=0; i<m_iGOPSize; i++)
1743    {
1744      xConfirmPara( (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) < -6 || (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) > 6, "Loop Filter Beta Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" );
1745      xConfirmPara( (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) < -6 || (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) > 6, "Loop Filter Tc Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" );
1746    }
1747  }
1748#if SVC_EXTENSION
1749  }
1750#endif
1751
1752  m_extraRPSs=0;
1753  //start looping through frames in coding order until we can verify that the GOP structure is correct.
1754  while(!verifiedGOP&&!errorGOP) 
1755  {
1756    Int curGOP = (checkGOP-1)%m_iGOPSize;
1757    Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + m_GOPList[curGOP].m_POC;   
1758    if(m_GOPList[curGOP].m_POC<0) 
1759    {
1760      printf("\nError: found fewer Reference Picture Sets than GOPSize\n");
1761      errorGOP=true;
1762    }
1763    else 
1764    {
1765      //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
1766      Bool beforeI = false;
1767      for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) 
1768      {
1769        Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i];
1770        if(absPOC < 0)
1771        {
1772          beforeI=true;
1773        }
1774        else 
1775        {
1776          Bool found=false;
1777          for(Int j=0; j<numRefs; j++) 
1778          {
1779            if(refList[j]==absPOC) 
1780            {
1781              found=true;
1782              for(Int k=0; k<m_iGOPSize; k++)
1783              {
1784                if(absPOC%m_iGOPSize == m_GOPList[k].m_POC%m_iGOPSize)
1785                {
1786                  if(m_GOPList[k].m_temporalId==m_GOPList[curGOP].m_temporalId)
1787                  {
1788                    m_GOPList[k].m_refPic = true;
1789                  }
1790                  m_GOPList[curGOP].m_usedByCurrPic[i]=m_GOPList[k].m_temporalId<=m_GOPList[curGOP].m_temporalId;
1791                }
1792              }
1793            }
1794          }
1795          if(!found)
1796          {
1797            printf("\nError: ref pic %d is not available for GOP frame %d\n",m_GOPList[curGOP].m_referencePics[i],curGOP+1);
1798            errorGOP=true;
1799          }
1800        }
1801      }
1802      if(!beforeI&&!errorGOP)
1803      {
1804        //all ref frames were present
1805        if(!isOK[curGOP]) 
1806        {
1807          numOK++;
1808          isOK[curGOP]=true;
1809          if(numOK==m_iGOPSize)
1810          {
1811            verifiedGOP=true;
1812          }
1813        }
1814      }
1815      else 
1816      {
1817        //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
1818        m_GOPList[m_iGOPSize+m_extraRPSs]=m_GOPList[curGOP];
1819        Int newRefs=0;
1820        for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) 
1821        {
1822          Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i];
1823          if(absPOC>=0)
1824          {
1825            m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[newRefs]=m_GOPList[curGOP].m_referencePics[i];
1826            m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[newRefs]=m_GOPList[curGOP].m_usedByCurrPic[i];
1827            newRefs++;
1828          }
1829        }
1830        Int numPrefRefs = m_GOPList[curGOP].m_numRefPicsActive;
1831       
1832        for(Int offset = -1; offset>-checkGOP; offset--)
1833        {
1834          //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
1835          Int offGOP = (checkGOP-1+offset)%m_iGOPSize;
1836          Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + m_GOPList[offGOP].m_POC;
1837          if(offPOC>=0&&m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId)
1838          {
1839            Bool newRef=false;
1840            for(Int i=0; i<numRefs; i++)
1841            {
1842              if(refList[i]==offPOC)
1843              {
1844                newRef=true;
1845              }
1846            }
1847            for(Int i=0; i<newRefs; i++) 
1848            {
1849              if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[i]==offPOC-curPOC)
1850              {
1851                newRef=false;
1852              }
1853            }
1854            if(newRef) 
1855            {
1856              Int insertPoint=newRefs;
1857              //this picture can be added, find appropriate place in list and insert it.
1858              if(m_GOPList[offGOP].m_temporalId==m_GOPList[curGOP].m_temporalId)
1859              {
1860                m_GOPList[offGOP].m_refPic = true;
1861              }
1862              for(Int j=0; j<newRefs; j++)
1863              {
1864                if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]<offPOC-curPOC||m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]>0)
1865                {
1866                  insertPoint = j;
1867                  break;
1868                }
1869              }
1870              Int prev = offPOC-curPOC;
1871              Int prevUsed = m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId;
1872              for(Int j=insertPoint; j<newRefs+1; j++)
1873              {
1874                Int newPrev = m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j];
1875                Int newUsed = m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j];
1876                m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]=prev;
1877                m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]=prevUsed;
1878                prevUsed=newUsed;
1879                prev=newPrev;
1880              }
1881              newRefs++;
1882            }
1883          }
1884          if(newRefs>=numPrefRefs)
1885          {
1886            break;
1887          }
1888        }
1889        m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics=newRefs;
1890        m_GOPList[m_iGOPSize+m_extraRPSs].m_POC = curPOC;
1891        if (m_extraRPSs == 0)
1892        {
1893          m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 0;
1894          m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = 0;
1895        }
1896        else
1897        {
1898          Int rIdx =  m_iGOPSize + m_extraRPSs - 1;
1899          Int refPOC = m_GOPList[rIdx].m_POC;
1900          Int refPics = m_GOPList[rIdx].m_numRefPics;
1901          Int newIdc=0;
1902          for(Int i = 0; i<= refPics; i++) 
1903          {
1904            Int deltaPOC = ((i != refPics)? m_GOPList[rIdx].m_referencePics[i] : 0);  // check if the reference abs POC is >= 0
1905            Int absPOCref = refPOC+deltaPOC;
1906            Int refIdc = 0;
1907            for (Int j = 0; j < m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics; j++)
1908            {
1909              if ( (absPOCref - curPOC) == m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j])
1910              {
1911                if (m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j])
1912                {
1913                  refIdc = 1;
1914                }
1915                else
1916                {
1917                  refIdc = 2;
1918                }
1919              }
1920            }
1921            m_GOPList[m_iGOPSize+m_extraRPSs].m_refIdc[newIdc]=refIdc;
1922            newIdc++;
1923          }
1924          m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 1; 
1925          m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = newIdc;
1926          m_GOPList[m_iGOPSize+m_extraRPSs].m_deltaRPS = refPOC - m_GOPList[m_iGOPSize+m_extraRPSs].m_POC; 
1927        }
1928        curGOP=m_iGOPSize+m_extraRPSs;
1929        m_extraRPSs++;
1930      }
1931      numRefs=0;
1932      for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) 
1933      {
1934        Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i];
1935        if(absPOC >= 0) 
1936        {
1937          refList[numRefs]=absPOC;
1938          numRefs++;
1939        }
1940      }
1941      refList[numRefs]=curPOC;
1942      numRefs++;
1943    }
1944    checkGOP++;
1945  }
1946  xConfirmPara(errorGOP,"Invalid GOP structure given");
1947  m_maxTempLayer = 1;
1948  for(Int i=0; i<m_iGOPSize; i++) 
1949  {
1950    if(m_GOPList[i].m_temporalId >= m_maxTempLayer)
1951    {
1952      m_maxTempLayer = m_GOPList[i].m_temporalId+1;
1953    }
1954    xConfirmPara(m_GOPList[i].m_sliceType!='B'&&m_GOPList[i].m_sliceType!='P'&&m_GOPList[i].m_sliceType!='I', "Slice type must be equal to B or P or I");
1955  }
1956  for(Int i=0; i<MAX_TLAYER; i++)
1957  {
1958    m_numReorderPics[i] = 0;
1959    m_maxDecPicBuffering[i] = 1;
1960  }
1961  for(Int i=0; i<m_iGOPSize; i++) 
1962  {
1963    if(m_GOPList[i].m_numRefPics+1 > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
1964    {
1965      m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics + 1;
1966    }
1967    Int highestDecodingNumberWithLowerPOC = 0; 
1968    for(Int j=0; j<m_iGOPSize; j++)
1969    {
1970      if(m_GOPList[j].m_POC <= m_GOPList[i].m_POC)
1971      {
1972        highestDecodingNumberWithLowerPOC = j;
1973      }
1974    }
1975    Int numReorder = 0;
1976    for(Int j=0; j<highestDecodingNumberWithLowerPOC; j++)
1977    {
1978      if(m_GOPList[j].m_temporalId <= m_GOPList[i].m_temporalId && 
1979        m_GOPList[j].m_POC > m_GOPList[i].m_POC)
1980      {
1981        numReorder++;
1982      }
1983    }   
1984    if(numReorder > m_numReorderPics[m_GOPList[i].m_temporalId])
1985    {
1986      m_numReorderPics[m_GOPList[i].m_temporalId] = numReorder;
1987    }
1988  }
1989  for(Int i=0; i<MAX_TLAYER-1; i++) 
1990  {
1991    // a lower layer can not have higher value of m_numReorderPics than a higher layer
1992    if(m_numReorderPics[i+1] < m_numReorderPics[i])
1993    {
1994      m_numReorderPics[i+1] = m_numReorderPics[i];
1995    }
1996    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive
1997    if(m_numReorderPics[i] > m_maxDecPicBuffering[i] - 1)
1998    {
1999      m_maxDecPicBuffering[i] = m_numReorderPics[i] + 1;
2000    }
2001    // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
2002    if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i])
2003    {
2004      m_maxDecPicBuffering[i+1] = m_maxDecPicBuffering[i];
2005    }
2006  }
2007
2008
2009  // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] -  1, inclusive
2010  if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1)
2011  {
2012    m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1;
2013  }
2014
2015#if SVC_EXTENSION // ToDo: it should be checked for the case when parameters are different for the layers
2016  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
2017  {
2018    Int m_iSourceWidth = m_acLayerCfg[layer].m_iSourceWidth;
2019    Int m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight;
2020#if LAYER_CTB
2021    Int m_uiMaxCUWidth = m_acLayerCfg[layer].m_uiMaxCUWidth;
2022    Int m_uiMaxCUHeight = m_acLayerCfg[layer].m_uiMaxCUHeight;
2023#endif
2024#endif
2025  if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
2026  { 
2027    Int PicSizeInSamplesY =  m_iSourceWidth * m_iSourceHeight;
2028    if(tileFlag)
2029    {
2030      Int maxTileWidth = 0;
2031      Int maxTileHeight = 0;
2032      Int widthInCU = (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth/m_uiMaxCUWidth + 1: m_iSourceWidth/m_uiMaxCUWidth;
2033      Int heightInCU = (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight/m_uiMaxCUHeight + 1: m_iSourceHeight/m_uiMaxCUHeight;
2034      if(m_iUniformSpacingIdr)
2035      {
2036        maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_iNumColumnsMinus1)/(m_iNumColumnsMinus1+1));
2037        maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_iNumRowsMinus1)/(m_iNumRowsMinus1+1));
2038        // if only the last tile-row is one treeblock higher than the others
2039        // the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others
2040        if(!((heightInCU-1)%(m_iNumRowsMinus1+1)))
2041        {
2042          maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight);
2043        }     
2044        // if only the last tile-column is one treeblock wider than the others
2045        // the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others   
2046        if(!((widthInCU-1)%(m_iNumColumnsMinus1+1)))
2047        {
2048          maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth);
2049        }
2050      }
2051      else // not uniform spacing
2052      {
2053        if(m_iNumColumnsMinus1<1)
2054        {
2055          maxTileWidth = m_iSourceWidth;
2056        }
2057        else
2058        {
2059          Int accColumnWidth = 0;
2060          for(Int col=0; col<(m_iNumColumnsMinus1); col++)
2061          {
2062            maxTileWidth = m_pColumnWidth[col]>maxTileWidth ? m_pColumnWidth[col]:maxTileWidth;
2063            accColumnWidth += m_pColumnWidth[col];
2064          }
2065          maxTileWidth = (widthInCU-accColumnWidth)>maxTileWidth ? m_uiMaxCUWidth*(widthInCU-accColumnWidth):m_uiMaxCUWidth*maxTileWidth;
2066        }
2067        if(m_iNumRowsMinus1<1)
2068        {
2069          maxTileHeight = m_iSourceHeight;
2070        }
2071        else
2072        {
2073          Int accRowHeight = 0;
2074          for(Int row=0; row<(m_iNumRowsMinus1); row++)
2075          {
2076            maxTileHeight = m_pRowHeight[row]>maxTileHeight ? m_pRowHeight[row]:maxTileHeight;
2077            accRowHeight += m_pRowHeight[row];
2078          }
2079          maxTileHeight = (heightInCU-accRowHeight)>maxTileHeight ? m_uiMaxCUHeight*(heightInCU-accRowHeight):m_uiMaxCUHeight*maxTileHeight;
2080        }
2081      }
2082      Int maxSizeInSamplesY = maxTileWidth*maxTileHeight;
2083      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/maxSizeInSamplesY-4;
2084    }
2085    else if(m_iWaveFrontSynchro)
2086    {
2087      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/((2*m_iSourceHeight+m_iSourceWidth)*m_uiMaxCUHeight)-4;
2088    }
2089    else if(m_sliceMode == 1)
2090    {
2091      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/(m_sliceArgument*m_uiMaxCUWidth*m_uiMaxCUHeight)-4;
2092    }
2093    else
2094    {
2095      m_minSpatialSegmentationIdc = 0;
2096    }
2097  }
2098#if SVC_EXTENSION
2099  }
2100#endif
2101  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
2102#if !SVC_EXTENSION
2103  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
2104  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
2105#endif
2106
2107  xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n");
2108
2109  if (m_toneMappingInfoSEIEnabled)
2110  {
2111    xConfirmPara( m_toneMapCodedDataBitDepth < 8 || m_toneMapCodedDataBitDepth > 14 , "SEIToneMapCodedDataBitDepth must be in rage 8 to 14");
2112    xConfirmPara( m_toneMapTargetBitDepth < 1 || (m_toneMapTargetBitDepth > 16 && m_toneMapTargetBitDepth < 255) , "SEIToneMapTargetBitDepth must be in rage 1 to 16 or equal to 255");
2113    xConfirmPara( m_toneMapModelId < 0 || m_toneMapModelId > 4 , "SEIToneMapModelId must be in rage 0 to 4");
2114    xConfirmPara( m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0");
2115    xConfirmPara( m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100");
2116    xConfirmPara( m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue, "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue");
2117    xConfirmPara( m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue, "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue");
2118  }
2119
2120#if RC_SHVC_HARMONIZATION
2121  for ( Int layer=0; layer<m_numLayers; layer++ )
2122  {
2123    if ( m_acLayerCfg[layer].m_RCEnableRateControl )
2124    {
2125      if ( m_acLayerCfg[layer].m_RCForceIntraQP )
2126      {
2127        if ( m_acLayerCfg[layer].m_RCInitialQP == 0 )
2128        {
2129          printf( "\nInitial QP for rate control is not specified. Reset not to use force intra QP!" );
2130          m_acLayerCfg[layer].m_RCForceIntraQP = false;
2131        }
2132      }
2133    }
2134    xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" );
2135  }
2136#else
2137  if ( m_RCEnableRateControl )
2138  {
2139    if ( m_RCForceIntraQP )
2140    {
2141      if ( m_RCInitialQP == 0 )
2142      {
2143        printf( "\nInitial QP for rate control is not specified. Reset not to use force intra QP!" );
2144        m_RCForceIntraQP = false;
2145      }
2146    }
2147    xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" );
2148  }
2149#endif
2150
2151  xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce, "CUTransquantBypassFlagForce cannot be 1 when TransquantBypassEnableFlag is 0");
2152
2153  xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
2154  if (m_framePackingSEIEnabled)
2155  {
2156    xConfirmPara(m_framePackingSEIType < 3 || m_framePackingSEIType > 5 , "SEIFramePackingType must be in rage 3 to 5");
2157  }
2158#if VPS_EXTN_DIRECT_REF_LAYERS
2159  xConfirmPara( (m_acLayerCfg[0].m_numSamplePredRefLayers != 0) && (m_acLayerCfg[0].m_numSamplePredRefLayers != -1), "Layer 0 cannot have any reference layers" );
2160  // NOTE: m_numSamplePredRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
2161  for(Int layer = 1; layer < MAX_LAYERS; layer++)
2162  {
2163    xConfirmPara(m_acLayerCfg[layer].m_numSamplePredRefLayers > layer, "Cannot reference more layers than before current layer");
2164    for(Int i = 0; i < m_acLayerCfg[layer].m_numSamplePredRefLayers; i++)
2165    {
2166      xConfirmPara(m_acLayerCfg[layer].m_samplePredRefLayerIds[i] > layer, "Cannot reference higher layers");
2167      xConfirmPara(m_acLayerCfg[layer].m_samplePredRefLayerIds[i] == layer, "Cannot reference the current layer itself");
2168    }
2169  }
2170  xConfirmPara( (m_acLayerCfg[0].m_numMotionPredRefLayers != 0) && (m_acLayerCfg[0].m_numMotionPredRefLayers != -1), "Layer 0 cannot have any reference layers" );
2171  // NOTE: m_numMotionPredRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
2172  for(Int layer = 1; layer < MAX_LAYERS; layer++)
2173  {
2174    xConfirmPara(m_acLayerCfg[layer].m_numMotionPredRefLayers > layer, "Cannot reference more layers than before current layer");
2175    for(Int i = 0; i < m_acLayerCfg[layer].m_numMotionPredRefLayers; i++)
2176    {
2177      xConfirmPara(m_acLayerCfg[layer].m_motionPredRefLayerIds[i] > layer, "Cannot reference higher layers");
2178      xConfirmPara(m_acLayerCfg[layer].m_motionPredRefLayerIds[i] == layer, "Cannot reference the current layer itself");
2179    }
2180  }
2181
2182  xConfirmPara( (m_acLayerCfg[0].m_numActiveRefLayers != 0) && (m_acLayerCfg[0].m_numActiveRefLayers != -1), "Layer 0 cannot have any active reference layers" );
2183  // NOTE: m_numActiveRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
2184  for(Int layer = 1; layer < MAX_LAYERS; layer++)
2185  {
2186    Bool predEnabledFlag[MAX_LAYERS];
2187    for (Int refLayer = 0; refLayer < layer; refLayer++)
2188    {
2189      predEnabledFlag[refLayer] = false;
2190    }
2191    for(Int i = 0; i < m_acLayerCfg[layer].m_numSamplePredRefLayers; i++)
2192    {
2193      predEnabledFlag[m_acLayerCfg[layer].m_samplePredRefLayerIds[i]] = true;
2194    }
2195    for(Int i = 0; i < m_acLayerCfg[layer].m_numMotionPredRefLayers; i++)
2196    {
2197      predEnabledFlag[m_acLayerCfg[layer].m_motionPredRefLayerIds[i]] = true;
2198    }
2199    Int numDirectRefLayers = 0;
2200    for (Int refLayer = 0; refLayer < layer; refLayer++)
2201    {
2202      if (predEnabledFlag[refLayer] == true) numDirectRefLayers++;
2203    }
2204    xConfirmPara(m_acLayerCfg[layer].m_numActiveRefLayers > numDirectRefLayers, "Cannot reference more layers than NumDirectRefLayers");
2205    for(Int i = 0; i < m_acLayerCfg[layer].m_numActiveRefLayers; i++)
2206    {
2207      xConfirmPara(m_acLayerCfg[layer].m_predLayerIds[i] >= numDirectRefLayers, "Cannot reference higher layers");
2208    }
2209  }
2210#endif //VPS_EXTN_DIRECT_REF_LAYERS
2211#if M0040_ADAPTIVE_RESOLUTION_CHANGE
2212  if (m_adaptiveResolutionChange > 0)
2213  {
2214    xConfirmPara(m_numLayers != 2, "Adaptive resolution change works with 2 layers only");
2215    xConfirmPara(m_acLayerCfg[1].m_iIntraPeriod == 0 || (m_adaptiveResolutionChange % m_acLayerCfg[1].m_iIntraPeriod) != 0, "Adaptive resolution change must happen at enhancement layer RAP picture");
2216  }
2217#endif
2218#if HIGHER_LAYER_IRAP_SKIP_FLAG
2219  if (m_adaptiveResolutionChange > 0)
2220  {
2221    xConfirmPara(m_crossLayerIrapAlignFlag != 0, "Cross layer IRAP alignment must be disabled when using adaptive resolution change.");
2222  }
2223  if (m_skipPictureAtArcSwitch)
2224  {
2225    xConfirmPara(m_adaptiveResolutionChange <= 0, "Skip picture at ARC switching only works when Adaptive Resolution Change is active (AdaptiveResolutionChange > 0)");
2226  }
2227#endif
2228#if N0120_MAX_TID_REF_CFG
2229  for (UInt layer=0; layer < MAX_LAYERS-1; layer++)
2230  {
2231    xConfirmPara(m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1 < 0 || m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1 > 7, "MaxTidIlRefPicsPlus1 must be in range 0 to 7");
2232  }
2233#endif
2234#if AUXILIARY_PICTURES
2235  for (UInt layer=0; layer < MAX_LAYERS-1; layer++)
2236  {
2237    xConfirmPara(m_acLayerCfg[layer].m_auxId < 0 || m_acLayerCfg[layer].m_auxId > 4, "AuxId must be in range 0 to 4");
2238    xConfirmPara(m_acLayerCfg[layer].m_auxId > 0 && m_acLayerCfg[layer].m_chromaFormatIDC != CHROMA_400, "Auxiliary picture must be monochrome picture");
2239  }
2240#endif
2241#undef xConfirmPara
2242  if (check_failed)
2243  {
2244    exit(EXIT_FAILURE);
2245  }
2246}
2247
2248/** \todo use of global variables should be removed later
2249 */
2250#if LAYER_CTB
2251Void TAppEncCfg::xSetGlobal(UInt layerId)
2252{
2253  // set max CU width & height
2254  g_auiLayerMaxCUWidth[layerId]  = m_acLayerCfg[layerId].m_uiMaxCUWidth;
2255  g_auiLayerMaxCUHeight[layerId] = m_acLayerCfg[layerId].m_uiMaxCUHeight;
2256 
2257  // compute actual CU depth with respect to config depth and max transform size
2258  g_auiLayerAddCUDepth[layerId]  = 0;
2259  while( (m_acLayerCfg[layerId].m_uiMaxCUWidth>>m_acLayerCfg[layerId].m_uiMaxCUDepth) > ( 1 << ( m_acLayerCfg[layerId].m_uiQuadtreeTULog2MinSize + g_auiLayerAddCUDepth[layerId] )  ) ) g_auiLayerAddCUDepth[layerId]++;
2260 
2261  m_acLayerCfg[layerId].m_uiMaxCUDepth += g_auiLayerAddCUDepth[layerId];
2262  g_auiLayerAddCUDepth[layerId]++;
2263  g_auiLayerMaxCUDepth[layerId] = m_acLayerCfg[layerId].m_uiMaxCUDepth;
2264 
2265#if O0194_DIFFERENT_BITDEPTH_EL_BL
2266  // set internal bit-depth to constant value to make sure to be updated later
2267  g_bitDepthY = -1;
2268  g_bitDepthC = -1;
2269 
2270  g_uiPCMBitDepthLuma = -1;
2271  g_uiPCMBitDepthChroma = -1;
2272#else
2273  // set internal bit-depth and constants
2274  g_bitDepthY = m_internalBitDepthY;
2275  g_bitDepthC = m_internalBitDepthC;
2276 
2277  g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_inputBitDepthY : m_internalBitDepthY;
2278  g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_inputBitDepthC : m_internalBitDepthC;
2279#endif
2280}
2281#else
2282Void TAppEncCfg::xSetGlobal()
2283{
2284  // set max CU width & height
2285  g_uiMaxCUWidth  = m_uiMaxCUWidth;
2286  g_uiMaxCUHeight = m_uiMaxCUHeight;
2287 
2288  // compute actual CU depth with respect to config depth and max transform size
2289  g_uiAddCUDepth  = 0;
2290  while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth )  ) ) g_uiAddCUDepth++;
2291 
2292  m_uiMaxCUDepth += g_uiAddCUDepth;
2293  g_uiAddCUDepth++;
2294  g_uiMaxCUDepth = m_uiMaxCUDepth;
2295 
2296#if O0194_DIFFERENT_BITDEPTH_EL_BL
2297  // set internal bit-depth to constant value to make sure to be updated later
2298  g_bitDepthY = -1;
2299  g_bitDepthC = -1;
2300 
2301  g_uiPCMBitDepthLuma = -1;
2302  g_uiPCMBitDepthChroma = -1;
2303#else
2304  g_bitDepthY = m_internalBitDepthY;
2305  g_bitDepthC = m_internalBitDepthC;
2306 
2307  g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_inputBitDepthY : m_internalBitDepthY;
2308  g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_inputBitDepthC : m_internalBitDepthC;
2309#endif
2310}
2311#endif
2312
2313Void TAppEncCfg::xPrintParameter()
2314{
2315  printf("\n");
2316#if SVC_EXTENSION 
2317  printf("Total number of layers        : %d\n", m_numLayers       );
2318#if SCALABILITY_MASK_E0104
2319  printf("Multiview                     : %d\n", m_scalabilityMask[1] );
2320  printf("Scalable                      : %d\n", m_scalabilityMask[2] );
2321#if AVC_BASE
2322  printf("Base layer                    : %s\n", m_avcBaseLayerFlag ? "AVC" : "HEVC");
2323#endif
2324#if AUXILIARY_PICTURES
2325  printf("Auxiliary pictures            : %d\n", m_scalabilityMask[3] );
2326#endif
2327#else
2328  printf("Multiview                     : %d\n", m_scalabilityMask[0] );
2329  printf("Scalable                      : %d\n", m_scalabilityMask[1] );
2330#endif
2331#if M0040_ADAPTIVE_RESOLUTION_CHANGE
2332  printf("Adaptive Resolution Change    : %d\n", m_adaptiveResolutionChange );
2333#endif
2334#if HIGHER_LAYER_IRAP_SKIP_FLAG
2335  printf("Skip picture at ARC switch    : %d\n", m_skipPictureAtArcSwitch );
2336#endif
2337#if O0223_PICTURE_TYPES_ALIGN_FLAG
2338  printf("Align picture type            : %d\n", m_crossLayerPictureTypeAlignFlag );
2339#endif
2340#if N0147_IRAP_ALIGN_FLAG
2341  printf("Cross layer IRAP alignment    : %d\n", m_crossLayerIrapAlignFlag );
2342#endif
2343#if O0194_WEIGHTED_PREDICTION_CGS
2344  printf("InterLayerWeightedPred        : %d\n", m_useInterLayerWeightedPred );
2345#endif
2346  for(UInt layer=0; layer<m_numLayers; layer++)
2347  {
2348    printf("=== Layer %d settings === \n", layer);
2349#if AVC_SYNTAX
2350    m_acLayerCfg[layer].xPrintParameter( layer );
2351#else
2352    m_acLayerCfg[layer].xPrintParameter();
2353#endif
2354    printf("\n");
2355  }
2356  printf("=== Common configuration settings === \n");
2357  printf("Bitstream      File          : %s\n", m_pBitstreamFile      );
2358#else
2359  printf("Input          File          : %s\n", m_pchInputFile          );
2360  printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
2361  printf("Reconstruction File          : %s\n", m_pchReconFile          );
2362  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
2363  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
2364#endif
2365  if (m_isField)
2366  {
2367    printf("Frame/Field          : Field based coding\n");
2368    printf("Field index          : %u - %d (%d fields)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
2369    if (m_isTopFieldFirst)
2370    {
2371      printf("Field Order            : Top field first\n");
2372    }
2373    else
2374    {
2375      printf("Field Order            : Bottom field first\n");
2376    }
2377  }
2378  else
2379  {
2380    printf("Frame/Field                  : Frame based coding\n");
2381    printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
2382  }
2383#if !LAYER_CTB
2384  printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
2385  printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
2386  printf("Max RQT depth inter          : %d\n", m_uiQuadtreeTUMaxDepthInter);
2387  printf("Max RQT depth intra          : %d\n", m_uiQuadtreeTUMaxDepthIntra);
2388#endif
2389  printf("Min PCM size                 : %d\n", 1 << m_uiPCMLog2MinSize);
2390  printf("Motion search range          : %d\n", m_iSearchRange );
2391#if !SVC_EXTENSION
2392  printf("Intra period                 : %d\n", m_iIntraPeriod );
2393#endif
2394  printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType );
2395#if !SVC_EXTENSION
2396  printf("QP                           : %5.2f\n", m_fQP );
2397#endif
2398  printf("Max dQP signaling depth      : %d\n", m_iMaxCuDQPDepth);
2399
2400  printf("Cb QP Offset                 : %d\n", m_cbQpOffset   );
2401  printf("Cr QP Offset                 : %d\n", m_crQpOffset);
2402
2403  printf("QP adaptation                : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) );
2404  printf("GOP size                     : %d\n", m_iGOPSize );
2405#if !O0194_DIFFERENT_BITDEPTH_EL_BL
2406  printf("Internal bit depth           : (Y:%d, C:%d)\n", m_internalBitDepthY, m_internalBitDepthC );
2407  printf("PCM sample bit depth         : (Y:%d, C:%d)\n", g_uiPCMBitDepthLuma, g_uiPCMBitDepthChroma );
2408#endif
2409#if O0215_PHASE_ALIGNMENT
2410  printf("Cross-layer sample alignment : %d\n", m_phaseAlignFlag);
2411#endif
2412#if !RC_SHVC_HARMONIZATION
2413  printf("RateControl                  : %d\n", m_RCEnableRateControl );
2414  if(m_RCEnableRateControl)
2415  {
2416    printf("TargetBitrate                : %d\n", m_RCTargetBitrate );
2417    printf("KeepHierarchicalBit          : %d\n", m_RCKeepHierarchicalBit );
2418    printf("LCULevelRC                   : %d\n", m_RCLCULevelRC );
2419    printf("UseLCUSeparateModel          : %d\n", m_RCUseLCUSeparateModel );
2420    printf("InitialQP                    : %d\n", m_RCInitialQP );
2421    printf("ForceIntraQP                 : %d\n", m_RCForceIntraQP );
2422  }
2423#endif
2424
2425  printf("Max Num Merge Candidates     : %d\n", m_maxNumMergeCand);
2426  printf("\n");
2427 
2428  printf("TOOL CFG: ");
2429#if !O0194_DIFFERENT_BITDEPTH_EL_BL
2430  printf("IBD:%d ", g_bitDepthY > m_inputBitDepthY || g_bitDepthC > m_inputBitDepthC);
2431#endif
2432  printf("HAD:%d ", m_bUseHADME           );
2433  printf("RDQ:%d ", m_useRDOQ            );
2434  printf("RDQTS:%d ", m_useRDOQTS        );
2435  printf("RDpenalty:%d ", m_rdPenalty  );
2436  printf("SQP:%d ", m_uiDeltaQpRD         );
2437  printf("ASR:%d ", m_bUseASR             );
2438  printf("FEN:%d ", m_bUseFastEnc         );
2439  printf("ECU:%d ", m_bUseEarlyCU         );
2440  printf("FDM:%d ", m_useFastDecisionForMerge );
2441  printf("CFM:%d ", m_bUseCbfFastMode         );
2442  printf("ESD:%d ", m_useEarlySkipDetection  );
2443#if FAST_INTRA_SHVC
2444  printf("FIS:%d ", m_useFastIntraScalable  );
2445#endif
2446  printf("RQT:%d ", 1     );
2447  printf("TransformSkip:%d ",     m_useTransformSkip              );
2448  printf("TransformSkipFast:%d ", m_useTransformSkipFast       );
2449  printf("Slice: M=%d ", m_sliceMode);
2450  if (m_sliceMode!=0)
2451  {
2452    printf("A=%d ", m_sliceArgument);
2453  }
2454  printf("SliceSegment: M=%d ",m_sliceSegmentMode);
2455  if (m_sliceSegmentMode!=0)
2456  {
2457    printf("A=%d ", m_sliceSegmentArgument);
2458  }
2459  printf("CIP:%d ", m_bUseConstrainedIntraPred);
2460  printf("SAO:%d ", (m_bUseSAO)?(1):(0));
2461#if !LAYER_CTB
2462  printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
2463#endif
2464  if (m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce)
2465  {
2466    printf("TransQuantBypassEnabled: =1 ");
2467  }
2468  else
2469  {
2470    printf("TransQuantBypassEnabled:%d ", (m_TransquantBypassEnableFlag)? 1:0 );
2471  }
2472  printf("WPP:%d ", (Int)m_useWeightedPred);
2473  printf("WPB:%d ", (Int)m_useWeightedBiPred);
2474  printf("PME:%d ", m_log2ParallelMergeLevel);
2475#if !SVC_EXTENSION
2476  printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d",
2477          m_iWaveFrontSynchro, m_iWaveFrontSubstreams);
2478#endif
2479  printf(" ScalingList:%d ", m_useScalingListId );
2480  printf("TMVPMode:%d ", m_TMVPModeId     );
2481#if ADAPTIVE_QP_SELECTION
2482  printf("AQpS:%d", m_bUseAdaptQpSelect   );
2483#endif
2484
2485  printf(" SignBitHidingFlag:%d ", m_signHideFlag);
2486#if SVC_EXTENSION
2487  printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 );
2488  printf("EL_RAP_SliceType: %d ", m_elRapSliceBEnabled);
2489  printf("REF_IDX_ME_ZEROMV: %d ", REF_IDX_ME_ZEROMV);
2490  printf("ENCODER_FAST_MODE: %d ", ENCODER_FAST_MODE);
2491  printf("REF_IDX_MFM: %d ", REF_IDX_MFM);
2492  printf("O0194_DIFFERENT_BITDEPTH_EL_BL: %d ", O0194_DIFFERENT_BITDEPTH_EL_BL);
2493  printf("O0194_JOINT_US_BITSHIFT: %d ", O0194_JOINT_US_BITSHIFT);
2494#else
2495  printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
2496#endif
2497  printf("\n\n");
2498 
2499  fflush(stdout);
2500}
2501
2502Bool confirmPara(Bool bflag, const Char* message)
2503{
2504  if (!bflag)
2505    return false;
2506 
2507  printf("Error: %s\n",message);
2508  return true;
2509}
2510
2511#if SVC_EXTENSION
2512Void TAppEncCfg::cfgStringToArray(Int **arr, string cfgString, Int numEntries, const char* logString)
2513{
2514  Char *tempChar = cfgString.empty() ? NULL : strdup(cfgString.c_str());
2515  if( numEntries > 0 )
2516  {
2517    Char *arrayEntry;
2518    Int i = 0;
2519    *arr = new Int[numEntries];
2520
2521    arrayEntry = strtok( tempChar, " ,");
2522    while(arrayEntry != NULL)
2523    {
2524      if( i >= numEntries )
2525      {
2526        printf( "%s: The number of entries specified is larger than the allowed number.\n", logString );
2527        exit( EXIT_FAILURE );
2528      }
2529      *( *arr + i ) = atoi( arrayEntry );
2530      arrayEntry = strtok(NULL, " ,");
2531      i++;
2532    }
2533    if( i < numEntries )
2534    {
2535      printf( "%s: Some entries are not specified.\n", logString );
2536      exit( EXIT_FAILURE );
2537    }
2538  }
2539  else
2540  {
2541    *arr = NULL;
2542  }
2543}
2544
2545#endif //SVC_EXTENSION
2546//! \}
Note: See TracBrowser for help on using the repository browser.