source: 3DVCSoftware/branches/HTM-15.2-dev/source/App/TAppEncoder/TAppEncCfg.cpp @ 1360

Last change on this file since 1360 was 1360, checked in by tech, 9 years ago

Update to HM-16.7.

  • Property svn:eol-style set to native
File size: 207.8 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-2015, 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 <stdio.h>
39#include <stdlib.h>
40#include <cassert>
41#include <cstring>
42#include <string>
43#include <limits>
44#include "TLibCommon/TComRom.h"
45#include "TAppEncCfg.h"
46#include "TAppCommon/program_options_lite.h"
47#include "TLibEncoder/TEncRateCtrl.h"
48#ifdef WIN32
49#define strdup _strdup
50#endif
51
52#define MACRO_TO_STRING_HELPER(val) #val
53#define MACRO_TO_STRING(val) MACRO_TO_STRING_HELPER(val)
54
55using namespace std;
56namespace po = df::program_options_lite;
57
58
59
60enum ExtendedProfileName // this is used for determining profile strings, where multiple profiles map to a single profile idc with various constraint flag combinations
61{
62  NONE = 0,
63  MAIN = 1,
64  MAIN10 = 2,
65  MAINSTILLPICTURE = 3,
66  MAINREXT = 4,
67  HIGHTHROUGHPUTREXT = 5, // Placeholder profile for development
68  // The following are RExt profiles, which would map to the MAINREXT profile idc.
69  // The enumeration indicates the bit-depth constraint in the bottom 2 digits
70  //                           the chroma format in the next digit
71    //                           the intra constraint in the next digit
72//                           If it is a RExt still picture, there is a '1' for the top digit.
73#if NH_MV
74  MULTIVIEWMAIN = 6,
75#if NH_3D
76  MAIN3D = 8, 
77#endif
78#endif
79  MONOCHROME_8      = 1008,
80  MONOCHROME_12     = 1012,
81  MONOCHROME_16     = 1016,
82  MAIN_12           = 1112,
83  MAIN_422_10       = 1210,
84  MAIN_422_12       = 1212,
85  MAIN_444          = 1308,
86  MAIN_444_10       = 1310,
87  MAIN_444_12       = 1312,
88  MAIN_444_16       = 1316, // non-standard profile definition, used for development purposes
89  MAIN_INTRA        = 2108,
90  MAIN_10_INTRA     = 2110,
91  MAIN_12_INTRA     = 2112,
92  MAIN_422_10_INTRA = 2210,
93  MAIN_422_12_INTRA = 2212,
94  MAIN_444_INTRA    = 2308,
95  MAIN_444_10_INTRA = 2310,
96  MAIN_444_12_INTRA = 2312,
97  MAIN_444_16_INTRA = 2316,
98  MAIN_444_STILL_PICTURE = 11308,
99  MAIN_444_16_STILL_PICTURE = 12316
100};
101
102
103//! \ingroup TAppEncoder
104//! \{
105
106// ====================================================================================================================
107// Constructor / destructor / initialization / destroy
108// ====================================================================================================================
109
110TAppEncCfg::TAppEncCfg()
111: m_inputColourSpaceConvert(IPCOLOURSPACE_UNCHANGED)
112, m_snrInternalColourSpace(false)
113, m_outputInternalColourSpace(false)
114{
115#if !NH_MV
116  m_aidQP = NULL;
117#endif
118  m_startOfCodedInterval = NULL;
119  m_codedPivotValue = NULL;
120  m_targetPivotValue = NULL;
121
122#if KWU_RC_MADPRED_E0227
123  m_depthMADPred = 0;
124#endif
125}
126
127TAppEncCfg::~TAppEncCfg()
128{
129#if NH_MV
130  for( Int layer = 0; layer < m_aidQP.size(); layer++ )
131  {
132    if ( m_aidQP[layer] != NULL )
133    {
134      delete[] m_aidQP[layer];
135      m_aidQP[layer] = NULL;
136    }
137  }
138  for(Int i = 0; i< m_pchInputFileList.size(); i++ )
139  {
140    if ( m_pchInputFileList[i] != NULL )
141      free (m_pchInputFileList[i]);
142  }
143#else
144  if ( m_aidQP )
145  {
146    delete[] m_aidQP;
147  }
148#endif
149  if ( m_startOfCodedInterval )
150  {
151    delete[] m_startOfCodedInterval;
152    m_startOfCodedInterval = NULL;
153  }
154   if ( m_codedPivotValue )
155  {
156    delete[] m_codedPivotValue;
157    m_codedPivotValue = NULL;
158  }
159  if ( m_targetPivotValue )
160  {
161    delete[] m_targetPivotValue;
162    m_targetPivotValue = NULL;
163  }
164#if NH_MV
165  for(Int i = 0; i< m_pchReconFileList.size(); i++ )
166  {
167    if ( m_pchReconFileList[i] != NULL )
168      free (m_pchReconFileList[i]);
169  }
170
171  for( Int i = 0; i < m_GOPListMvc.size(); i++ )
172  {
173    if( m_GOPListMvc[i] )
174    {
175      delete[] m_GOPListMvc[i];
176      m_GOPListMvc[i] = NULL;
177    }
178  }
179#endif
180
181#if NH_3D
182#if NH_3D_VSO
183  if (  m_pchVSOConfig != NULL)
184  {
185    free (  m_pchVSOConfig );
186  }
187#endif
188  if ( m_pchCameraParameterFile != NULL )
189  {
190    free ( m_pchCameraParameterFile ); 
191  }
192
193  if ( m_pchBaseViewCameraNumbers != NULL )
194  {
195    free ( m_pchBaseViewCameraNumbers ); 
196  }
197#endif
198}
199
200Void TAppEncCfg::create()
201{
202}
203
204Void TAppEncCfg::destroy()
205{
206}
207
208
209#if NH_MV_SEI
210Void TAppEncCfg::xParseSeiCfg()
211{
212  for (Int i = 0; i < MAX_NUM_SEIS; i++)
213  {
214    if ( m_seiCfgFileNames[i] != NULL )
215    {
216      Int payloadType; 
217      po::Options opts;     
218     
219      opts.addOptions()("PayloadType", payloadType,-1, "Payload Type");
220      po::setDefaults(opts);     
221
222      po::ErrorReporter err;
223      err.output_on_unknow_parameter = false; 
224      po::parseConfigFile( opts, m_seiCfgFileNames[i], err );
225      SEI* sei = SEI::getNewSEIMessage( (SEI::PayloadType) payloadType ); 
226      assert( sei != NULL );
227
228      sei->setupFromCfgFile( m_seiCfgFileNames[i] ); 
229
230      m_seiMessages.push_back( sei );
231    }
232  }
233}
234#endif
235
236std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry)     //input
237{
238  in>>entry.m_sliceType;
239  in>>entry.m_POC;
240  in>>entry.m_QPOffset;
241  in>>entry.m_QPFactor;
242  in>>entry.m_tcOffsetDiv2;
243  in>>entry.m_betaOffsetDiv2;
244  in>>entry.m_temporalId;
245  in>>entry.m_numRefPicsActive;
246  in>>entry.m_numRefPics;
247  for ( Int i = 0; i < entry.m_numRefPics; i++ )
248  {
249    in>>entry.m_referencePics[i];
250  }
251  in>>entry.m_interRPSPrediction;
252  if (entry.m_interRPSPrediction==1)
253  {
254    in>>entry.m_deltaRPS;
255    in>>entry.m_numRefIdc;
256    for ( Int i = 0; i < entry.m_numRefIdc; i++ )
257    {
258      in>>entry.m_refIdc[i];
259    }
260  }
261  else if (entry.m_interRPSPrediction==2)
262  {
263    in>>entry.m_deltaRPS;
264  }
265#if NH_MV
266  in>>entry.m_numActiveRefLayerPics;
267  for( Int i = 0; i < entry.m_numActiveRefLayerPics; i++ )
268  {
269    in>>entry.m_interLayerPredLayerIdc[i];
270  }
271  for( Int i = 0; i < entry.m_numActiveRefLayerPics; i++ )
272  {
273    in>>entry.m_interViewRefPosL[0][i];
274  }
275  for( Int i = 0; i < entry.m_numActiveRefLayerPics; i++ )
276  {
277    in>>entry.m_interViewRefPosL[1][i];
278  }
279#endif
280#if NH_3D
281  in>>entry.m_interCompPredFlag;
282#endif
283
284  return in;
285}
286
287Bool confirmPara(Bool bflag, const TChar* message);
288
289static inline ChromaFormat numberToChromaFormat(const Int val)
290{
291  switch (val)
292  {
293    case 400: return CHROMA_400; break;
294    case 420: return CHROMA_420; break;
295    case 422: return CHROMA_422; break;
296    case 444: return CHROMA_444; break;
297    default:  return NUM_CHROMA_FORMAT;
298  }
299}
300
301static const struct MapStrToProfile
302{
303  const TChar* str;
304  Profile::Name value;
305}
306strToProfile[] =
307{
308  {"none",                 Profile::NONE               },
309  {"main",                 Profile::MAIN               },
310  {"main10",               Profile::MAIN10             },
311  {"main-still-picture",   Profile::MAINSTILLPICTURE   },
312  {"main-RExt",            Profile::MAINREXT           },
313  {"high-throughput-RExt", Profile::HIGHTHROUGHPUTREXT }
314#if NH_MV
315  ,{"multiview-main"     , Profile::MULTIVIEWMAIN      },
316#if NH_3D
317   {"3d-main"            , Profile::MAIN3D             }
318#endif
319#endif
320
321};
322
323static const struct MapStrToExtendedProfile
324{
325  const TChar* str;
326  ExtendedProfileName value;
327}
328strToExtendedProfile[] =
329{
330    {"none",               NONE             },
331    {"main",               MAIN             },
332    {"main10",             MAIN10           },
333    {"main_still_picture",        MAINSTILLPICTURE },
334    {"main-still-picture",        MAINSTILLPICTURE },
335    {"main_RExt",                 MAINREXT         },
336    {"main-RExt",                 MAINREXT         },
337    {"main_rext",                 MAINREXT         },
338    {"main-rext",                 MAINREXT         },
339    {"high_throughput_RExt",      HIGHTHROUGHPUTREXT },
340    {"high-throughput-RExt",      HIGHTHROUGHPUTREXT },
341    {"high_throughput_rext",      HIGHTHROUGHPUTREXT },
342    {"high-throughput-rext",      HIGHTHROUGHPUTREXT },
343#if NH_MV
344    {"multiview-main"     , MULTIVIEWMAIN   },
345#if NH_3D
346    {"3d-main"            , MAIN3D          },
347#endif
348#endif
349    {"monochrome",         MONOCHROME_8     },
350    {"monochrome12",       MONOCHROME_12    },
351    {"monochrome16",       MONOCHROME_16    },
352    {"main12",             MAIN_12          },
353    {"main_422_10",        MAIN_422_10      },
354    {"main_422_12",        MAIN_422_12      },
355    {"main_444",           MAIN_444         },
356    {"main_444_10",        MAIN_444_10      },
357    {"main_444_12",        MAIN_444_12      },
358    {"main_444_16",        MAIN_444_16      },
359    {"main_intra",         MAIN_INTRA       },
360    {"main_10_intra",      MAIN_10_INTRA    },
361    {"main_12_intra",      MAIN_12_INTRA    },
362    {"main_422_10_intra",  MAIN_422_10_INTRA},
363    {"main_422_12_intra",  MAIN_422_12_INTRA},
364    {"main_444_intra",     MAIN_444_INTRA   },
365    {"main_444_still_picture",    MAIN_444_STILL_PICTURE },
366    {"main_444_10_intra",  MAIN_444_10_INTRA},
367    {"main_444_12_intra",  MAIN_444_12_INTRA},
368    {"main_444_16_intra",         MAIN_444_16_INTRA},
369    {"main_444_16_still_picture", MAIN_444_16_STILL_PICTURE }
370};
371
372static const ExtendedProfileName validRExtProfileNames[2/* intraConstraintFlag*/][4/* bit depth constraint 8=0, 10=1, 12=2, 16=3*/][4/*chroma format*/]=
373{
374    {
375        { MONOCHROME_8,  NONE,          NONE,              MAIN_444          }, // 8-bit  inter for 400, 420, 422 and 444
376        { NONE,          NONE,          MAIN_422_10,       MAIN_444_10       }, // 10-bit inter for 400, 420, 422 and 444
377        { MONOCHROME_12, MAIN_12,       MAIN_422_12,       MAIN_444_12       }, // 12-bit inter for 400, 420, 422 and 444
378        { MONOCHROME_16, NONE,          NONE,              MAIN_444_16       }  // 16-bit inter for 400, 420, 422 and 444 (the latter is non standard used for development)
379    },
380    {
381        { NONE,          MAIN_INTRA,    NONE,              MAIN_444_INTRA    }, // 8-bit  intra for 400, 420, 422 and 444
382        { NONE,          MAIN_10_INTRA, MAIN_422_10_INTRA, MAIN_444_10_INTRA }, // 10-bit intra for 400, 420, 422 and 444
383        { NONE,          MAIN_12_INTRA, MAIN_422_12_INTRA, MAIN_444_12_INTRA }, // 12-bit intra for 400, 420, 422 and 444
384        { NONE,          NONE,          NONE,              MAIN_444_16_INTRA }  // 16-bit intra for 400, 420, 422 and 444
385    }
386};
387
388static const struct MapStrToTier
389{
390  const TChar* str;
391  Level::Tier value;
392}
393strToTier[] =
394{
395  {"main", Level::MAIN},
396  {"high", Level::HIGH},
397};
398
399static const struct MapStrToLevel
400{
401  const TChar* str;
402  Level::Name value;
403}
404strToLevel[] =
405{
406  {"none",Level::NONE},
407  {"1",   Level::LEVEL1},
408  {"2",   Level::LEVEL2},
409  {"2.1", Level::LEVEL2_1},
410  {"3",   Level::LEVEL3},
411  {"3.1", Level::LEVEL3_1},
412  {"4",   Level::LEVEL4},
413  {"4.1", Level::LEVEL4_1},
414  {"5",   Level::LEVEL5},
415  {"5.1", Level::LEVEL5_1},
416  {"5.2", Level::LEVEL5_2},
417  {"6",   Level::LEVEL6},
418  {"6.1", Level::LEVEL6_1},
419  {"6.2", Level::LEVEL6_2},
420  {"8.5", Level::LEVEL8_5},
421};
422
423#if U0132_TARGET_BITS_SATURATION
424UInt g_uiMaxCpbSize[2][21] =
425{
426  //         LEVEL1,        LEVEL2,LEVEL2_1,     LEVEL3, LEVEL3_1,      LEVEL4, LEVEL4_1,       LEVEL5,  LEVEL5_1,  LEVEL5_2,    LEVEL6,  LEVEL6_1,  LEVEL6_2
427  { 0, 0, 0, 350000, 0, 0, 1500000, 3000000, 0, 6000000, 10000000, 0, 12000000, 20000000, 0,  25000000,  40000000,  60000000,  60000000, 120000000, 240000000 },
428  { 0, 0, 0,      0, 0, 0,       0,       0, 0,       0,        0, 0, 30000000, 50000000, 0, 100000000, 160000000, 240000000, 240000000, 480000000, 800000000 }
429};
430#endif
431
432static const struct MapStrToCostMode
433{
434  const TChar* str;
435  CostMode    value;
436}
437strToCostMode[] =
438{
439  {"lossy",                     COST_STANDARD_LOSSY},
440  {"sequence_level_lossless",   COST_SEQUENCE_LEVEL_LOSSLESS},
441  {"lossless",                  COST_LOSSLESS_CODING},
442  {"mixed_lossless_lossy",      COST_MIXED_LOSSLESS_LOSSY_CODING}
443};
444
445static const struct MapStrToScalingListMode
446{
447  const TChar* str;
448  ScalingListMode value;
449}
450strToScalingListMode[] =
451{
452  {"0",       SCALING_LIST_OFF},
453  {"1",       SCALING_LIST_DEFAULT},
454  {"2",       SCALING_LIST_FILE_READ},
455  {"off",     SCALING_LIST_OFF},
456  {"default", SCALING_LIST_DEFAULT},
457  {"file",    SCALING_LIST_FILE_READ}
458};
459
460template<typename T, typename P>
461static std::string enumToString(P map[], UInt mapLen, const T val)
462{
463  for (UInt i = 0; i < mapLen; i++)
464  {
465    if (val == map[i].value)
466    {
467      return map[i].str;
468    }
469  }
470  return std::string();
471}
472
473template<typename T, typename P>
474static istream& readStrToEnum(P map[], UInt mapLen, istream &in, T &val)
475{
476  string str;
477  in >> str;
478
479  for (UInt i = 0; i < mapLen; i++)
480  {
481    if (str == map[i].str)
482    {
483      val = map[i].value;
484      goto found;
485    }
486  }
487  /* not found */
488  in.setstate(ios::failbit);
489found:
490  return in;
491}
492
493//inline to prevent compiler warnings for "unused static function"
494
495static inline istream& operator >> (istream &in, ExtendedProfileName &profile)
496{
497  return readStrToEnum(strToExtendedProfile, sizeof(strToExtendedProfile)/sizeof(*strToExtendedProfile), in, profile);
498}
499
500namespace Level
501{
502  static inline istream& operator >> (istream &in, Tier &tier)
503  {
504    return readStrToEnum(strToTier, sizeof(strToTier)/sizeof(*strToTier), in, tier);
505  }
506
507  static inline istream& operator >> (istream &in, Name &level)
508  {
509    return readStrToEnum(strToLevel, sizeof(strToLevel)/sizeof(*strToLevel), in, level);
510  }
511}
512
513static inline istream& operator >> (istream &in, CostMode &mode)
514{
515  return readStrToEnum(strToCostMode, sizeof(strToCostMode)/sizeof(*strToCostMode), in, mode);
516}
517
518static inline istream& operator >> (istream &in, ScalingListMode &mode)
519{
520  return readStrToEnum(strToScalingListMode, sizeof(strToScalingListMode)/sizeof(*strToScalingListMode), in, mode);
521}
522
523template <class T>
524struct SMultiValueInput
525{
526  const T              minValIncl;
527  const T              maxValIncl;
528  const std::size_t    minNumValuesIncl;
529  const std::size_t    maxNumValuesIncl; // Use 0 for unlimited
530        std::vector<T> values;
531  SMultiValueInput() : minValIncl(0), maxValIncl(0), minNumValuesIncl(0), maxNumValuesIncl(0), values() { }
532  SMultiValueInput(std::vector<T> &defaults) : minValIncl(0), maxValIncl(0), minNumValuesIncl(0), maxNumValuesIncl(0), values(defaults) { }
533  SMultiValueInput(const T &minValue, const T &maxValue, std::size_t minNumberValues=0, std::size_t maxNumberValues=0)
534    : minValIncl(minValue), maxValIncl(maxValue), minNumValuesIncl(minNumberValues), maxNumValuesIncl(maxNumberValues), values()  { }
535  SMultiValueInput(const T &minValue, const T &maxValue, std::size_t minNumberValues, std::size_t maxNumberValues, const T* defValues, const UInt numDefValues)
536    : minValIncl(minValue), maxValIncl(maxValue), minNumValuesIncl(minNumberValues), maxNumValuesIncl(maxNumberValues), values(defValues, defValues+numDefValues)  { }
537  SMultiValueInput<T> &operator=(const std::vector<T> &userValues) { values=userValues; return *this; }
538  SMultiValueInput<T> &operator=(const SMultiValueInput<T> &userValues) { values=userValues.values; return *this; }
539
540  T readValue(const TChar *&pStr, Bool &bSuccess);
541
542  istream& readValues(std::istream &in);
543};
544
545template <class T>
546static inline istream& operator >> (std::istream &in, SMultiValueInput<T> &values)
547{
548  return values.readValues(in);
549  }
550
551template<>
552UInt SMultiValueInput<UInt>::readValue(const TChar *&pStr, Bool &bSuccess)
553    {
554  TChar *eptr;
555      UInt val=strtoul(pStr, &eptr, 0);
556  pStr=eptr;
557  bSuccess=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !(val<minValIncl || val>maxValIncl);
558  return val;
559      }
560
561template<>
562Int SMultiValueInput<Int>::readValue(const TChar *&pStr, Bool &bSuccess)
563      {
564  TChar *eptr;
565  Int val=strtol(pStr, &eptr, 0);
566      pStr=eptr;
567  bSuccess=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !(val<minValIncl || val>maxValIncl);
568  return val;
569}
570
571template<>
572Double SMultiValueInput<Double>::readValue(const TChar *&pStr, Bool &bSuccess)
573  {
574  TChar *eptr;
575  Double val=strtod(pStr, &eptr);
576  pStr=eptr;
577  bSuccess=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !(val<minValIncl || val>maxValIncl);
578  return val;
579  }
580
581template<>
582Bool SMultiValueInput<Bool>::readValue(const TChar *&pStr, Bool &bSuccess)
583    {
584  TChar *eptr;
585      Int val=strtol(pStr, &eptr, 0);
586      pStr=eptr;
587  bSuccess=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !(val<Int(minValIncl) || val>Int(maxValIncl));
588  return val!=0;
589}
590
591template <class T>
592istream& SMultiValueInput<T>::readValues(std::istream &in)
593{
594  values.clear();
595  string str;
596  while (!in.eof())
597  {
598    string tmp; in >> tmp; str+=" " + tmp;
599  }
600  if (!str.empty())
601  {
602    const TChar *pStr=str.c_str();
603    // soak up any whitespace
604    for(;isspace(*pStr);pStr++);
605
606    while (*pStr != 0)
607    {
608      Bool bSuccess=true;
609      T val=readValue(pStr, bSuccess);
610      if (!bSuccess)
611      {
612        in.setstate(ios::failbit);
613        break;
614      }
615
616      if (maxNumValuesIncl != 0 && values.size() >= maxNumValuesIncl)
617      {
618        in.setstate(ios::failbit);
619        break;
620      }
621      values.push_back(val);
622      // soak up any whitespace and up to 1 comma.
623      for(;isspace(*pStr);pStr++);
624      if (*pStr == ',')
625      {
626        pStr++;
627      }
628      for(;isspace(*pStr);pStr++);
629    }
630  }
631  if (values.size() < minNumValuesIncl)
632  {
633    in.setstate(ios::failbit);
634  }
635  return in;
636}
637
638static Void
639automaticallySelectRExtProfile(const Bool bUsingGeneralRExtTools,
640                               const Bool bUsingChromaQPAdjustment,
641                               const Bool bUsingExtendedPrecision,
642                               const Bool bIntraConstraintFlag,
643                               UInt &bitDepthConstraint,
644                               ChromaFormat &chromaFormatConstraint,
645                               const Int  maxBitDepth,
646                               const ChromaFormat chromaFormat)
647{
648  // Try to choose profile, according to table in Q1013.
649  UInt trialBitDepthConstraint=maxBitDepth;
650  if (trialBitDepthConstraint<8)
651  {
652    trialBitDepthConstraint=8;
653  }
654  else if (trialBitDepthConstraint==9 || trialBitDepthConstraint==11)
655  {
656    trialBitDepthConstraint++;
657  }
658  else if (trialBitDepthConstraint>12)
659  {
660    trialBitDepthConstraint=16;
661  }
662
663  // both format and bit depth constraints are unspecified
664  if (bUsingExtendedPrecision || trialBitDepthConstraint==16)
665  {
666    bitDepthConstraint = 16;
667    chromaFormatConstraint = (!bIntraConstraintFlag && chromaFormat==CHROMA_400) ? CHROMA_400 : CHROMA_444;
668  }
669  else if (bUsingGeneralRExtTools)
670  {
671    if (chromaFormat == CHROMA_400 && !bIntraConstraintFlag)
672    {
673      bitDepthConstraint = 16;
674      chromaFormatConstraint = CHROMA_400;
675    }
676    else
677    {
678      bitDepthConstraint = trialBitDepthConstraint;
679      chromaFormatConstraint = CHROMA_444;
680    }
681  }
682  else if (chromaFormat == CHROMA_400)
683  {
684    if (bIntraConstraintFlag)
685    {
686      chromaFormatConstraint = CHROMA_420; // there is no intra 4:0:0 profile.
687      bitDepthConstraint     = trialBitDepthConstraint;
688    }
689    else
690    {
691      chromaFormatConstraint = CHROMA_400;
692      bitDepthConstraint     = trialBitDepthConstraint == 8 ? 8 : 12;
693    }
694  }
695  else
696  {
697    bitDepthConstraint = trialBitDepthConstraint;
698    chromaFormatConstraint = chromaFormat;
699    if (bUsingChromaQPAdjustment && chromaFormat == CHROMA_420)
700    {
701      chromaFormatConstraint = CHROMA_422; // 4:2:0 cannot use the chroma qp tool.
702    }
703    if (chromaFormatConstraint == CHROMA_422 && bitDepthConstraint == 8)
704    {
705      bitDepthConstraint = 10; // there is no 8-bit 4:2:2 profile.
706    }
707    if (chromaFormatConstraint == CHROMA_420 && !bIntraConstraintFlag)
708    {
709      bitDepthConstraint = 12; // there is no 8 or 10-bit 4:2:0 inter RExt profile.
710    }
711  }
712}
713// ====================================================================================================================
714// Public member functions
715// ====================================================================================================================
716
717/** \param  argc        number of arguments
718    \param  argv        array of arguments
719    \retval             true when success
720 */
721Bool TAppEncCfg::parseCfg( Int argc, TChar* argv[] )
722{
723  Bool do_help = false;
724
725#if !NH_MV
726  string cfg_InputFile;
727#endif
728  string cfg_BitstreamFile;
729#if !NH_MV
730  string cfg_ReconFile;
731#endif
732#if NH_MV
733  vector<Int>   cfg_dimensionLength; 
734  string        cfg_profiles;
735  string        cfg_levels; 
736  string        cfg_tiers; 
737#if NH_3D
738  cfg_dimensionLength.push_back( 2  );  // depth
739  cfg_dimensionLength.push_back( 32 );  // texture
740#else
741  cfg_dimensionLength.push_back( 64 ); 
742#endif
743#endif
744  string cfg_dQPFile;
745  string cfg_ScalingListFile;
746
747  Int tmpChromaFormat;
748  Int tmpInputChromaFormat;
749  Int tmpConstraintChromaFormat;
750  Int tmpWeightedPredictionMethod;
751  Int tmpFastInterSearchMode;
752  Int tmpMotionEstimationSearchMethod;
753  Int tmpSliceMode;
754  Int tmpSliceSegmentMode;
755  Int tmpDecodedPictureHashSEIMappedType;
756  string inputColourSpaceConvert;
757#if NH_MV
758  std::vector<ExtendedProfileName> extendedProfiles;
759#else
760  ExtendedProfileName extendedProfile;
761#endif
762  Int saoOffsetBitShift[MAX_NUM_CHANNEL_TYPE];
763
764  // Multi-value input fields:                                // minval, maxval (incl), min_entries, max_entries (incl) [, default values, number of default values]
765  SMultiValueInput<UInt> cfg_ColumnWidth                     (0, std::numeric_limits<UInt>::max(), 0, std::numeric_limits<UInt>::max());
766  SMultiValueInput<UInt> cfg_RowHeight                       (0, std::numeric_limits<UInt>::max(), 0, std::numeric_limits<UInt>::max());
767  SMultiValueInput<Int>  cfg_startOfCodedInterval            (std::numeric_limits<Int>::min(), std::numeric_limits<Int>::max(), 0, 1<<16);
768  SMultiValueInput<Int>  cfg_codedPivotValue                 (std::numeric_limits<Int>::min(), std::numeric_limits<Int>::max(), 0, 1<<16);
769  SMultiValueInput<Int>  cfg_targetPivotValue                (std::numeric_limits<Int>::min(), std::numeric_limits<Int>::max(), 0, 1<<16);
770
771  SMultiValueInput<Double> cfg_adIntraLambdaModifier         (0, std::numeric_limits<Double>::max(), 0, MAX_TLAYER); ///< Lambda modifier for Intra pictures, one for each temporal layer. If size>temporalLayer, then use [temporalLayer], else if size>0, use [size()-1], else use m_adLambdaModifier.
772
773
774  const UInt defaultInputKneeCodes[3]  = { 600, 800, 900 };
775  const UInt defaultOutputKneeCodes[3] = { 100, 250, 450 };
776  SMultiValueInput<UInt> cfg_kneeSEIInputKneePointValue      (1,  999, 0, 999, defaultInputKneeCodes,  sizeof(defaultInputKneeCodes )/sizeof(UInt));
777  SMultiValueInput<UInt> cfg_kneeSEIOutputKneePointValue     (0, 1000, 0, 999, defaultOutputKneeCodes, sizeof(defaultOutputKneeCodes)/sizeof(UInt));
778  const Int defaultPrimaryCodes[6]     = { 0,50000, 0,0, 50000,0 };
779  const Int defaultWhitePointCode[2]   = { 16667, 16667 };
780  SMultiValueInput<Int>  cfg_DisplayPrimariesCode            (0, 50000, 3, 3, defaultPrimaryCodes,   sizeof(defaultPrimaryCodes  )/sizeof(Int));
781  SMultiValueInput<Int>  cfg_DisplayWhitePointCode           (0, 50000, 2, 2, defaultWhitePointCode, sizeof(defaultWhitePointCode)/sizeof(Int));
782
783  SMultiValueInput<Bool> cfg_timeCodeSeiTimeStampFlag        (0,  1, 0, MAX_TIMECODE_SEI_SETS);
784  SMultiValueInput<Bool> cfg_timeCodeSeiNumUnitFieldBasedFlag(0,  1, 0, MAX_TIMECODE_SEI_SETS);
785  SMultiValueInput<Int>  cfg_timeCodeSeiCountingType         (0,  6, 0, MAX_TIMECODE_SEI_SETS);
786  SMultiValueInput<Bool> cfg_timeCodeSeiFullTimeStampFlag    (0,  1, 0, MAX_TIMECODE_SEI_SETS);
787  SMultiValueInput<Bool> cfg_timeCodeSeiDiscontinuityFlag    (0,  1, 0, MAX_TIMECODE_SEI_SETS);
788  SMultiValueInput<Bool> cfg_timeCodeSeiCntDroppedFlag       (0,  1, 0, MAX_TIMECODE_SEI_SETS);
789  SMultiValueInput<Int>  cfg_timeCodeSeiNumberOfFrames       (0,511, 0, MAX_TIMECODE_SEI_SETS);
790  SMultiValueInput<Int>  cfg_timeCodeSeiSecondsValue         (0, 59, 0, MAX_TIMECODE_SEI_SETS);
791  SMultiValueInput<Int>  cfg_timeCodeSeiMinutesValue         (0, 59, 0, MAX_TIMECODE_SEI_SETS);
792  SMultiValueInput<Int>  cfg_timeCodeSeiHoursValue           (0, 23, 0, MAX_TIMECODE_SEI_SETS);
793  SMultiValueInput<Bool> cfg_timeCodeSeiSecondsFlag          (0,  1, 0, MAX_TIMECODE_SEI_SETS);
794  SMultiValueInput<Bool> cfg_timeCodeSeiMinutesFlag          (0,  1, 0, MAX_TIMECODE_SEI_SETS);
795  SMultiValueInput<Bool> cfg_timeCodeSeiHoursFlag            (0,  1, 0, MAX_TIMECODE_SEI_SETS);
796  SMultiValueInput<Int>  cfg_timeCodeSeiTimeOffsetLength     (0, 31, 0, MAX_TIMECODE_SEI_SETS);
797  SMultiValueInput<Int>  cfg_timeCodeSeiTimeOffsetValue      (std::numeric_limits<Int>::min(), std::numeric_limits<Int>::max(), 0, MAX_TIMECODE_SEI_SETS);
798  Int warnUnknowParameter = 0;
799
800  po::Options opts;
801  opts.addOptions()
802  ("help",                                            do_help,                                          false, "this help text")
803  ("c",    po::parseConfigFile, "configuration file name")
804  ("WarnUnknowParameter,w",                           warnUnknowParameter,                                  0, "warn for unknown configuration parameters instead of failing")
805
806  // File, I/O and source parameters
807#if NH_MV
808  ("InputFile_%d,i_%d",       m_pchInputFileList,       (char *) 0 , MAX_NUM_LAYER_IDS , "original Yuv input file name %d")
809#else
810  ("InputFile,i",                                     m_inputFileName,                             string(""), "Original YUV input file name")
811#endif
812  ("BitstreamFile,b",                                 m_bitstreamFileName,                         string(""), "Bitstream output file name")
813#if NH_MV
814  ("ReconFile_%d,o_%d",       m_pchReconFileList,       (char *) 0 , MAX_NUM_LAYER_IDS , "reconstructed Yuv output file name %d")
815#else
816  ("ReconFile,o",                                     m_reconFileName,                             string(""), "Reconstructed YUV output file name")
817#endif
818#if NH_MV
819  ("NumberOfLayers",        m_numberOfLayers     , 1,                     "Number of layers")
820#if !NH_3D
821  ("ScalabilityMask",       m_scalabilityMask    , 2                    , "Scalability Mask: 2: Multiview, 8: Auxiliary, 10: Multiview + Auxiliary")   
822#else
823  ("ScalabilityMask",       m_scalabilityMask    , 3                    , "Scalability Mask, 1: Texture 3: Texture + Depth ")   
824#endif 
825  ("DimensionIdLen",        m_dimensionIdLen     , cfg_dimensionLength  , "Number of bits used to store dimensions Id")
826  ("ViewOrderIndex",                 m_viewOrderIndex              , IntAry1d(1,0),                                 "View Order Index per layer")
827  ("ViewId",                         m_viewId                      , IntAry1d(1,0),                                 "View Id per View Order Index")
828  ("AuxId",                          m_auxId                       , IntAry1d(1,0),                                 "AuxId per layer")
829#if NH_3D
830  ("DepthFlag",                      m_depthFlag                   , IntAry1d(1,0),                                 "Depth Flag")
831#endif
832  ("TargetEncLayerIdList",           m_targetEncLayerIdList        , IntAry1d(0,0),                                 "LayerIds in Nuh to be encoded") 
833  ("LayerIdInNuh",                   m_layerIdInNuh                , IntAry1d(1,0),                                 "LayerId in Nuh") 
834  ("SplittingFlag",         m_splittingFlag       , false                , "Splitting Flag")   
835
836  // Layer Sets + Output Layer Sets + Profile Tier Level
837  ("VpsNumLayerSets",       m_vpsNumLayerSets    , 1                    , "Number of layer sets")   
838  ("LayerIdsInSet_%d"              , m_layerIdsInSets              , IntAry1d(1,0) , MAX_VPS_OP_SETS_PLUS1      ,   "LayerIds of Layer set") 
839  ("NumAddLayerSets"     , m_numAddLayerSets     , 0                                              , "NumAddLayerSets     ")
840  ("HighestLayerIdxPlus1_%d"       , m_highestLayerIdxPlus1        , IntAry1d(0,0) , MAX_VPS_NUM_ADD_LAYER_SETS ,   "HighestLayerIdxPlus1")
841  ("DefaultTargetOutputLayerIdc"     , m_defaultOutputLayerIdc     , 0, "Specifies output layers of layer sets, 0: output all layers, 1: output highest layer, 2: specified by LayerIdsInDefOutputLayerSet")
842  ("OutputLayerSetIdx"             , m_outputLayerSetIdx           , IntAry1d(0,0)                              ,   "Indices of layer sets used as additional output layer sets")
843  ("LayerIdsInAddOutputLayerSet_%d", m_layerIdsInAddOutputLayerSet , IntAry1d(0,0) , MAX_VPS_ADD_OUTPUT_LAYER_SETS, "Indices in VPS of output layers in additional output layer set") 
844  ("LayerIdsInDefOutputLayerSet_%d", m_layerIdsInDefOutputLayerSet , IntAry1d(0,0) , MAX_VPS_OP_SETS_PLUS1,         "Indices in VPS of output layers in layer set") 
845  ("AltOutputLayerFlag"            , m_altOutputLayerFlag          , BoolAry1d(1,0),                                "Alt output layer flag")
846 
847  ("ProfileTierLevelIdx_%d"        , m_profileTierLevelIdx         , IntAry1d(0)  , MAX_NUM_LAYERS,                  "Indices to profile level tier for ols")
848  // Layer dependencies
849  ("DirectRefLayers_%d"            , m_directRefLayers             , IntAry1d(0,0), MAX_NUM_LAYERS,                  "LayerIdx in VPS of direct reference layers")
850  ("DependencyTypes_%d"            , m_dependencyTypes             , IntAry1d(0,0), MAX_NUM_LAYERS,                  "Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion")
851#endif
852  ("SourceWidth,-wdt",                                m_iSourceWidth,                                       0, "Source picture width")
853  ("SourceHeight,-hgt",                               m_iSourceHeight,                                      0, "Source picture height")
854  ("InputBitDepth",                                   m_inputBitDepth[CHANNEL_TYPE_LUMA],                   8, "Bit-depth of input file")
855  ("OutputBitDepth",                                  m_outputBitDepth[CHANNEL_TYPE_LUMA],                  0, "Bit-depth of output file (default:InternalBitDepth)")
856  ("MSBExtendedBitDepth",                             m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA],             0, "bit depth of luma component after addition of MSBs of value 0 (used for synthesising High Dynamic Range source material). (default:InputBitDepth)")
857  ("InternalBitDepth",                                m_internalBitDepth[CHANNEL_TYPE_LUMA],                0, "Bit-depth the codec operates at. (default:MSBExtendedBitDepth). If different to MSBExtendedBitDepth, source data will be converted")
858  ("InputBitDepthC",                                  m_inputBitDepth[CHANNEL_TYPE_CHROMA],                 0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
859  ("OutputBitDepthC",                                 m_outputBitDepth[CHANNEL_TYPE_CHROMA],                0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
860  ("MSBExtendedBitDepthC",                            m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA],           0, "As per MSBExtendedBitDepth but for chroma component. (default:MSBExtendedBitDepth)")
861  ("InternalBitDepthC",                               m_internalBitDepth[CHANNEL_TYPE_CHROMA],              0, "As per InternalBitDepth but for chroma component. (default:InternalBitDepth)")
862  ("ExtendedPrecision",                               m_extendedPrecisionProcessingFlag,                false, "Increased internal accuracies to support high bit depths (not valid in V1 profiles)")
863  ("HighPrecisionPredictionWeighting",                m_highPrecisionOffsetsEnabledFlag,                false, "Use high precision option for weighted prediction (not valid in V1 profiles)")
864  ("InputColourSpaceConvert",                         inputColourSpaceConvert,                     string(""), "Colour space conversion to apply to input video. Permitted values are (empty string=UNCHANGED) " + getListOfColourSpaceConverts(true))
865  ("SNRInternalColourSpace",                          m_snrInternalColourSpace,                         false, "If true, then no colour space conversion is applied prior to SNR, otherwise inverse of input is applied.")
866  ("OutputInternalColourSpace",                       m_outputInternalColourSpace,                      false, "If true, then no colour space conversion is applied for reconstructed video, otherwise inverse of input is applied.")
867  ("InputChromaFormat",                               tmpInputChromaFormat,                               420, "InputChromaFormatIDC")
868  ("MSEBasedSequencePSNR",                            m_printMSEBasedSequencePSNR,                      false, "0 (default) emit sequence PSNR only as a linear average of the frame PSNRs, 1 = also emit a sequence PSNR based on an average of the frame MSEs")
869  ("PrintFrameMSE",                                   m_printFrameMSE,                                  false, "0 (default) emit only bit count and PSNRs for each frame, 1 = also emit MSE values")
870  ("PrintSequenceMSE",                                m_printSequenceMSE,                               false, "0 (default) emit only bit rate and PSNRs for the whole sequence, 1 = also emit MSE values")
871  ("CabacZeroWordPaddingEnabled",                     m_cabacZeroWordPaddingEnabled,                     true, "0 do not add conforming cabac-zero-words to bit streams, 1 (default) = add cabac-zero-words as required")
872  ("ChromaFormatIDC,-cf",                             tmpChromaFormat,                                      0, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
873  ("ConformanceMode",                                 m_conformanceWindowMode,                              0, "Deprecated alias of ConformanceWindowMode")
874  ("ConformanceWindowMode",                           m_conformanceWindowMode,                              0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
875  ("HorizontalPadding,-pdx",                          m_aiPad[0],                                           0, "Horizontal source padding for conformance window mode 2")
876  ("VerticalPadding,-pdy",                            m_aiPad[1],                                           0, "Vertical source padding for conformance window mode 2")
877  ("ConfLeft",                                        m_confWinLeft,                                        0, "Deprecated alias of ConfWinLeft")
878  ("ConfRight",                                       m_confWinRight,                                       0, "Deprecated alias of ConfWinRight")
879  ("ConfTop",                                         m_confWinTop,                                         0, "Deprecated alias of ConfWinTop")
880  ("ConfBottom",                                      m_confWinBottom,                                      0, "Deprecated alias of ConfWinBottom")
881  ("ConfWinLeft",                                     m_confWinLeft,                                        0, "Left offset for window conformance mode 3")
882  ("ConfWinRight",                                    m_confWinRight,                                       0, "Right offset for window conformance mode 3")
883  ("ConfWinTop",                                      m_confWinTop,                                         0, "Top offset for window conformance mode 3")
884  ("ConfWinBottom",                                   m_confWinBottom,                                      0, "Bottom offset for window conformance mode 3")
885  ("AccessUnitDelimiter",                             m_AccessUnitDelimiter,                            false, "Enable Access Unit Delimiter NALUs")
886  ("FrameRate,-fr",                                   m_iFrameRate,                                         0, "Frame rate")
887  ("FrameSkip,-fs",                                   m_FrameSkip,                                         0u, "Number of frames to skip at start of input YUV")
888  ("FramesToBeEncoded,f",                             m_framesToBeEncoded,                                  0, "Number of frames to be encoded (default=all)")
889  ("ClipInputVideoToRec709Range",                     m_bClipInputVideoToRec709Range,                   false, "If true then clip input video to the Rec. 709 Range on loading when InternalBitDepth is less than MSBExtendedBitDepth")
890  ("ClipOutputVideoToRec709Range",                    m_bClipOutputVideoToRec709Range,                  false, "If true then clip output video to the Rec. 709 Range on saving when OutputBitDepth is less than InternalBitDepth")
891  ("SummaryOutFilename",                              m_summaryOutFilename,                          string(), "Filename to use for producing summary output file. If empty, do not produce a file.")
892  ("SummaryPicFilenameBase",                          m_summaryPicFilenameBase,                      string(), "Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended. If empty, do not produce a file.")
893  ("SummaryVerboseness",                              m_summaryVerboseness,                                0u, "Specifies the level of the verboseness of the text output")
894
895  //Field coding parameters
896  ("FieldCoding",                                     m_isField,                                        false, "Signals if it's a field based coding")
897  ("TopFieldFirst, Tff",                              m_isTopFieldFirst,                                false, "In case of field based coding, signals whether if it's a top field first or not")
898  ("EfficientFieldIRAPEnabled",                       m_bEfficientFieldIRAPEnabled,                      true, "Enable to code fields in a specific, potentially more efficient, order.")
899  ("HarmonizeGopFirstFieldCoupleEnabled",             m_bHarmonizeGopFirstFieldCoupleEnabled,            true, "Enables harmonization of Gop first field couple")
900
901  // Profile and level
902#if NH_MV
903  ("Profile" ,                                        cfg_profiles,                                string(""), "Profile in VpsProfileTierLevel (Indication only)")
904  ("Level"   ,                                        cfg_levels ,                                 string(""), "Level indication in VpsProfileTierLevel (Indication only)")
905  ("Tier"    ,                                        cfg_tiers  ,                                 string(""), "Tier indication in VpsProfileTierLevel (Indication only)")
906  ("InblFlag",                                        m_inblFlag ,                       std::vector<Bool>(0), "InblFlags in VpsProfileTierLevel (Indication only)" )
907#else
908  ("Profile",                                         extendedProfile,                                   NONE, "Profile name to use for encoding. Use main (for main), main10 (for main10), main-still-picture, main-RExt (for Range Extensions profile), any of the RExt specific profile names, or none")
909  ("Level",                                           m_level,                                    Level::NONE, "Level limit to be used, eg 5.1, or none")
910  ("Tier",                                            m_levelTier,                                Level::MAIN, "Tier to use for interpretation of --Level (main or high only)")
911#endif
912  ("MaxBitDepthConstraint",                           m_bitDepthConstraint,                                0u, "Bit depth to use for profile-constraint for RExt profiles. 0=automatically choose based upon other parameters")
913  ("MaxChromaFormatConstraint",                       tmpConstraintChromaFormat,                            0, "Chroma-format to use for the profile-constraint for RExt profiles. 0=automatically choose based upon other parameters")
914  ("IntraConstraintFlag",                             m_intraConstraintFlag,                            false, "Value of general_intra_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)")
915  ("OnePictureOnlyConstraintFlag",                    m_onePictureOnlyConstraintFlag,                   false, "Value of general_one_picture_only_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)")
916  ("LowerBitRateConstraintFlag",                      m_lowerBitRateConstraintFlag,                      true, "Value of general_lower_bit_rate_constraint_flag to use for RExt profiles")
917
918  ("ProgressiveSource",                               m_progressiveSourceFlag,                          false, "Indicate that source is progressive")
919  ("InterlacedSource",                                m_interlacedSourceFlag,                           false, "Indicate that source is interlaced")
920  ("NonPackedSource",                                 m_nonPackedConstraintFlag,                        false, "Indicate that source does not contain frame packing")
921  ("FrameOnly",                                       m_frameOnlyConstraintFlag,                        false, "Indicate that the bitstream contains only frames")
922
923  // Unit definition parameters
924  ("MaxCUWidth",                                      m_uiMaxCUWidth,                                     64u)
925  ("MaxCUHeight",                                     m_uiMaxCUHeight,                                    64u)
926  // todo: remove defaults from MaxCUSize
927  ("MaxCUSize,s",                                     m_uiMaxCUWidth,                                     64u, "Maximum CU size")
928  ("MaxCUSize,s",                                     m_uiMaxCUHeight,                                    64u, "Maximum CU size")
929  ("MaxPartitionDepth,h",                             m_uiMaxCUDepth,                                      4u, "CU depth")
930
931  ("QuadtreeTULog2MaxSize",                           m_uiQuadtreeTULog2MaxSize,                           6u, "Maximum TU size in logarithm base 2")
932  ("QuadtreeTULog2MinSize",                           m_uiQuadtreeTULog2MinSize,                           2u, "Minimum TU size in logarithm base 2")
933
934  ("QuadtreeTUMaxDepthIntra",                         m_uiQuadtreeTUMaxDepthIntra,                         1u, "Depth of TU tree for intra CUs")
935  ("QuadtreeTUMaxDepthInter",                         m_uiQuadtreeTUMaxDepthInter,                         2u, "Depth of TU tree for inter CUs")
936#if NH_MV 
937  // Coding structure parameters
938  ("IntraPeriod,-ip",                                 m_iIntraPeriod,std::vector<Int>(1,-1)                  , "Intra period in frames, (-1: only first frame), per layer")
939#else
940  // Coding structure paramters
941  ("IntraPeriod,-ip",                                 m_iIntraPeriod,                                      -1, "Intra period in frames, (-1: only first frame)")
942#endif
943  ("DecodingRefreshType,-dr",                         m_iDecodingRefreshType,                               0, "Intra refresh type (0:none 1:CRA 2:IDR 3:RecPointSEI)")
944  ("GOPSize,g",                                       m_iGOPSize,                                           1, "GOP size of temporal structure")
945
946  // motion search options
947  ("DisableIntraInInter",                             m_bDisableIntraPUsInInterSlices,                  false, "Flag to disable intra PUs in inter slices")
948  ("FastSearch",                                      tmpMotionEstimationSearchMethod,  Int(MESEARCH_DIAMOND), "0:Full search 1:Diamond 2:Selective 3:Enhanced Diamond")
949  ("SearchRange,-sr",                                 m_iSearchRange,                                      96, "Motion search range")
950#if NH_MV
951  ("DispSearchRangeRestriction",  m_bUseDisparitySearchRangeRestriction, false, "restrict disparity search range")
952  ("VerticalDispSearchRange",     m_iVerticalDisparitySearchRange, 56, "vertical disparity search range")
953#endif
954  ("BipredSearchRange",                               m_bipredSearchRange,                                  4, "Motion search range for bipred refinement")
955  ("MinSearchWindow",                                 m_minSearchWindow,                                    8, "Minimum motion search window size for the adaptive window ME")
956  ("RestrictMESampling",                              m_bRestrictMESampling,                            false, "Restrict ME Sampling for selective inter motion search")
957  ("ClipForBiPredMEEnabled",                          m_bClipForBiPredMeEnabled,                        false, "Enables clipping in the Bi-Pred ME. It is disabled to reduce encoder run-time")
958  ("FastMEAssumingSmootherMVEnabled",                 m_bFastMEAssumingSmootherMVEnabled,                true, "Enables fast ME assuming a smoother MV.")
959
960  ("HadamardME",                                      m_bUseHADME,                                       true, "Hadamard ME for fractional-pel")
961  ("ASR",                                             m_bUseASR,                                        false, "Adaptive motion search range")
962
963  // Mode decision parameters
964  ("LambdaModifier0,-LM0",                            m_adLambdaModifier[ 0 ],                  ( Double )1.0, "Lambda modifier for temporal layer 0. If LambdaModifierI is used, this will not affect intra pictures")
965  ("LambdaModifier1,-LM1",                            m_adLambdaModifier[ 1 ],                  ( Double )1.0, "Lambda modifier for temporal layer 1. If LambdaModifierI is used, this will not affect intra pictures")
966  ("LambdaModifier2,-LM2",                            m_adLambdaModifier[ 2 ],                  ( Double )1.0, "Lambda modifier for temporal layer 2. If LambdaModifierI is used, this will not affect intra pictures")
967  ("LambdaModifier3,-LM3",                            m_adLambdaModifier[ 3 ],                  ( Double )1.0, "Lambda modifier for temporal layer 3. If LambdaModifierI is used, this will not affect intra pictures")
968  ("LambdaModifier4,-LM4",                            m_adLambdaModifier[ 4 ],                  ( Double )1.0, "Lambda modifier for temporal layer 4. If LambdaModifierI is used, this will not affect intra pictures")
969  ("LambdaModifier5,-LM5",                            m_adLambdaModifier[ 5 ],                  ( Double )1.0, "Lambda modifier for temporal layer 5. If LambdaModifierI is used, this will not affect intra pictures")
970  ("LambdaModifier6,-LM6",                            m_adLambdaModifier[ 6 ],                  ( Double )1.0, "Lambda modifier for temporal layer 6. If LambdaModifierI is used, this will not affect intra pictures")
971  ("LambdaModifierI,-LMI",                            cfg_adIntraLambdaModifier,    cfg_adIntraLambdaModifier, "Lambda modifiers for Intra pictures, comma separated, up to one the number of temporal layer. If entry for temporalLayer exists, then use it, else if some are specified, use the last, else use the standard LambdaModifiers.")
972  ("IQPFactor,-IQF",                                  m_dIntraQpFactor,                                  -1.0, "Intra QP Factor for Lambda Computation. If negative, use the default equation: 0.57*(1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? (GopSize-1)/2 : GopSize-1) ))")
973
974  /* Quantization parameters */
975#if NH_MV
976  ("QP,q",          m_fQP, std::vector<double>(1,30.0), "Qp values for each layer, if value is float, QP is switched once during encoding")
977#else
978  ("QP,q",                                            m_fQP,                                             30.0, "Qp value, if value is float, QP is switched once during encoding")
979#endif
980  ("DeltaQpRD,-dqr",                                  m_uiDeltaQpRD,                                       0u, "max dQp offset for slice")
981  ("MaxDeltaQP,d",                                    m_iMaxDeltaQP,                                        0, "max dQp offset for block")
982  ("MaxCuDQPDepth,-dqd",                              m_iMaxCuDQPDepth,                                     0, "max depth for a minimum CuDQP")
983  ("MaxCUChromaQpAdjustmentDepth",                    m_diffCuChromaQpOffsetDepth,                         -1, "Maximum depth for CU chroma Qp adjustment - set less than 0 to disable")
984  ("FastDeltaQP",                                     m_bFastDeltaQP,                                   false, "Fast Delta QP Algorithm")
985
986  ("CbQpOffset,-cbqpofs",                             m_cbQpOffset,                                         0, "Chroma Cb QP Offset")
987  ("CrQpOffset,-crqpofs",                             m_crQpOffset,                                         0, "Chroma Cr QP Offset")
988
989#if ADAPTIVE_QP_SELECTION
990  ("AdaptiveQpSelection,-aqps",                       m_bUseAdaptQpSelect,                              false, "AdaptiveQpSelection")
991#endif
992
993  ("AdaptiveQP,-aq",                                  m_bUseAdaptiveQP,                                 false, "QP adaptation based on a psycho-visual model")
994  ("MaxQPAdaptationRange,-aqr",                       m_iQPAdaptationRange,                                 6, "QP adaptation range")
995  ("dQPFile,m",                                       m_dQPFileName,                               string(""), "dQP file name")
996  ("RDOQ",                                            m_useRDOQ,                                         true)
997  ("RDOQTS",                                          m_useRDOQTS,                                       true)
998#if T0196_SELECTIVE_RDOQ
999  ("SelectiveRDOQ",                                   m_useSelectiveRDOQ,                               false, "Enable selective RDOQ")
1000#endif
1001  ("RDpenalty",                                       m_rdPenalty,                                          0,  "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disabled  1:RD-penalty  2:maximum RD-penalty")
1002
1003  // Deblocking filter parameters
1004#if NH_MV
1005  ("LoopFilterDisable",                               m_bLoopFilterDisable,                             std::vector<Bool>(1,false), "Disable Loop Filter per Layer" )
1006#else
1007  ("LoopFilterDisable",                               m_bLoopFilterDisable,                             false)
1008#endif
1009  ("LoopFilterOffsetInPPS",                           m_loopFilterOffsetInPPS,                           true)
1010  ("LoopFilterBetaOffset_div2",                       m_loopFilterBetaOffsetDiv2,                           0)
1011  ("LoopFilterTcOffset_div2",                         m_loopFilterTcOffsetDiv2,                             0)
1012  ("DeblockingFilterMetric",                          m_DeblockingFilterMetric,                         false)
1013
1014  // Coding tools
1015  ("AMP",                                             m_enableAMP,                                       true, "Enable asymmetric motion partitions")
1016  ("CrossComponentPrediction",                        m_crossComponentPredictionEnabledFlag,            false, "Enable the use of cross-component prediction (not valid in V1 profiles)")
1017  ("ReconBasedCrossCPredictionEstimate",              m_reconBasedCrossCPredictionEstimate,             false, "When determining the alpha value for cross-component prediction, use the decoded residual rather than the pre-transform encoder-side residual")
1018  ("SaoLumaOffsetBitShift",                           saoOffsetBitShift[CHANNEL_TYPE_LUMA],                 0, "Specify the luma SAO bit-shift. If negative, automatically calculate a suitable value based upon bit depth and initial QP")
1019  ("SaoChromaOffsetBitShift",                         saoOffsetBitShift[CHANNEL_TYPE_CHROMA],               0, "Specify the chroma SAO bit-shift. If negative, automatically calculate a suitable value based upon bit depth and initial QP")
1020  ("TransformSkip",                                   m_useTransformSkip,                               false, "Intra transform skipping")
1021  ("TransformSkipFast",                               m_useTransformSkipFast,                           false, "Fast intra transform skipping")
1022  ("TransformSkipLog2MaxSize",                        m_log2MaxTransformSkipBlockSize,                     2U, "Specify transform-skip maximum size. Minimum 2. (not valid in V1 profiles)")
1023  ("ImplicitResidualDPCM",                            m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT],        false, "Enable implicitly signalled residual DPCM for intra (also known as sample-adaptive intra predict) (not valid in V1 profiles)")
1024  ("ExplicitResidualDPCM",                            m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT],        false, "Enable explicitly signalled residual DPCM for inter (not valid in V1 profiles)")
1025  ("ResidualRotation",                                m_transformSkipRotationEnabledFlag,               false, "Enable rotation of transform-skipped and transquant-bypassed TUs through 180 degrees prior to entropy coding (not valid in V1 profiles)")
1026  ("SingleSignificanceMapContext",                    m_transformSkipContextEnabledFlag,                false, "Enable, for transform-skipped and transquant-bypassed TUs, the selection of a single significance map context variable for all coefficients (not valid in V1 profiles)")
1027  ("GolombRiceParameterAdaptation",                   m_persistentRiceAdaptationEnabledFlag,            false, "Enable the adaptation of the Golomb-Rice parameter over the course of each slice")
1028  ("AlignCABACBeforeBypass",                          m_cabacBypassAlignmentEnabledFlag,                false, "Align the CABAC engine to a defined fraction of a bit prior to coding bypass data. Must be 1 in high bit rate profile, 0 otherwise" )
1029#if NH_MV
1030  ("SAO",                      m_bUseSAO, std::vector<Bool>(1,true), "Enable Sample Adaptive Offset per Layer")
1031#else
1032  ("SAO",                                             m_bUseSAO,                                         true, "Enable Sample Adaptive Offset")
1033#endif
1034  ("TestSAODisableAtPictureLevel",                    m_bTestSAODisableAtPictureLevel,                  false, "Enables the testing of disabling SAO at the picture level after having analysed all blocks")
1035  ("SaoEncodingRate",                                 m_saoEncodingRate,                                 0.75, "When >0 SAO early picture termination is enabled for luma and chroma")
1036  ("SaoEncodingRateChroma",                           m_saoEncodingRateChroma,                            0.5, "The SAO early picture termination rate to use for chroma (when m_SaoEncodingRate is >0). If <=0, use results for luma")
1037  ("MaxNumOffsetsPerPic",                             m_maxNumOffsetsPerPic,                             2048, "Max number of SAO offset per picture (Default: 2048)")
1038  ("SAOLcuBoundary",                                  m_saoCtuBoundary,                                 false, "0: right/bottom CTU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
1039  ("SliceMode",                                       tmpSliceMode,                            Int(NO_SLICES), "0: Disable all Recon slice limits, 1: Enforce max # of CTUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
1040  ("SliceArgument",                                   m_sliceArgument,                                      0, "Depending on SliceMode being:"
1041                                                                                                               "\t1: max number of CTUs per slice"
1042                                                                                                               "\t2: max number of bytes per slice"
1043                                                                                                               "\t3: max number of tiles per slice")
1044  ("SliceSegmentMode",                                tmpSliceSegmentMode,                     Int(NO_SLICES), "0: Disable all slice segment limits, 1: Enforce max # of CTUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
1045  ("SliceSegmentArgument",                            m_sliceSegmentArgument,                               0, "Depending on SliceSegmentMode being:"
1046                                                                                                               "\t1: max number of CTUs per slice segment"
1047                                                                                                               "\t2: max number of bytes per slice segment"
1048                                                                                                               "\t3: max number of tiles per slice segment")
1049  ("LFCrossSliceBoundaryFlag",                        m_bLFCrossSliceBoundaryFlag,                       true)
1050
1051  ("ConstrainedIntraPred",                            m_bUseConstrainedIntraPred,                       false, "Constrained Intra Prediction")
1052  ("FastUDIUseMPMEnabled",                            m_bFastUDIUseMPMEnabled,                           true, "If enabled, adapt intra direction search, accounting for MPM")
1053  ("FastMEForGenBLowDelayEnabled",                    m_bFastMEForGenBLowDelayEnabled,                   true, "If enabled use a fast ME for generalised B Low Delay slices")
1054  ("UseBLambdaForNonKeyLowDelayPictures",             m_bUseBLambdaForNonKeyLowDelayPictures,            true, "Enables use of B-Lambda for non-key low-delay pictures")
1055  ("PCMEnabledFlag",                                  m_usePCM,                                         false)
1056  ("PCMLog2MaxSize",                                  m_pcmLog2MaxSize,                                    5u)
1057  ("PCMLog2MinSize",                                  m_uiPCMLog2MinSize,                                  3u)
1058
1059  ("PCMInputBitDepthFlag",                            m_bPCMInputBitDepthFlag,                           true)
1060  ("PCMFilterDisableFlag",                            m_bPCMFilterDisableFlag,                          false)
1061  ("IntraReferenceSmoothing",                         m_enableIntraReferenceSmoothing,                   true, "0: Disable use of intra reference smoothing (not valid in V1 profiles). 1: Enable use of intra reference smoothing (same as V1)")
1062  ("WeightedPredP,-wpP",                              m_useWeightedPred,                                false, "Use weighted prediction in P slices")
1063  ("WeightedPredB,-wpB",                              m_useWeightedBiPred,                              false, "Use weighted (bidirectional) prediction in B slices")
1064  ("WeightedPredMethod,-wpM",                         tmpWeightedPredictionMethod, Int(WP_PER_PICTURE_WITH_SIMPLE_DC_COMBINED_COMPONENT), "Weighted prediction method")
1065  ("Log2ParallelMergeLevel",                          m_log2ParallelMergeLevel,                            2u, "Parallel merge estimation region")
1066    //deprecated copies of renamed tile parameters
1067  ("UniformSpacingIdc",                               m_tileUniformSpacingFlag,                         false,      "deprecated alias of TileUniformSpacing")
1068  ("ColumnWidthArray",                                cfg_ColumnWidth,                        cfg_ColumnWidth, "deprecated alias of TileColumnWidthArray")
1069  ("RowHeightArray",                                  cfg_RowHeight,                            cfg_RowHeight, "deprecated alias of TileRowHeightArray")
1070
1071  ("TileUniformSpacing",                              m_tileUniformSpacingFlag,                         false,      "Indicates that tile columns and rows are distributed uniformly")
1072  ("NumTileColumnsMinus1",                            m_numTileColumnsMinus1,                               0,          "Number of tile columns in a picture minus 1")
1073  ("NumTileRowsMinus1",                               m_numTileRowsMinus1,                                  0,          "Number of rows in a picture minus 1")
1074  ("TileColumnWidthArray",                            cfg_ColumnWidth,                        cfg_ColumnWidth, "Array containing tile column width values in units of CTU")
1075  ("TileRowHeightArray",                              cfg_RowHeight,                            cfg_RowHeight, "Array containing tile row height values in units of CTU")
1076  ("LFCrossTileBoundaryFlag",                         m_bLFCrossTileBoundaryFlag,                        true, "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
1077  ("WaveFrontSynchro",                                m_entropyCodingSyncEnabledFlag,                   false, "0: entropy coding sync disabled; 1 entropy coding sync enabled")
1078  ("ScalingList",                                     m_useScalingListId,                    SCALING_LIST_OFF, "0/off: no scaling list, 1/default: default scaling lists, 2/file: scaling lists specified in ScalingListFile")
1079  ("ScalingListFile",                                 m_scalingListFileName,                       string(""), "Scaling list file name. Use an empty string to produce help.")
1080  ("SignHideFlag,-SBH",                               m_signHideFlag,                                    true)
1081  ("MaxNumMergeCand",                                 m_maxNumMergeCand,                                   5u, "Maximum number of merge candidates")
1082  /* Misc. */
1083  ("SEIDecodedPictureHash",                           tmpDecodedPictureHashSEIMappedType,                   0, "Control generation of decode picture hash SEI messages\n"
1084                                                                                                               "\t3: checksum\n"
1085                                                                                                               "\t2: CRC\n"
1086                                                                                                               "\t1: use MD5\n"
1087                                                                                                               "\t0: disable")
1088  ("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")
1089  ("FEN",                                             tmpFastInterSearchMode,   Int(FASTINTERSEARCH_DISABLED), "fast encoder setting")
1090  ("ECU",                                             m_bUseEarlyCU,                                    false, "Early CU setting")
1091  ("FDM",                                             m_useFastDecisionForMerge,                         true, "Fast decision for Merge RD Cost")
1092  ("CFM",                                             m_bUseCbfFastMode,                                false, "Cbf fast mode setting")
1093  ("ESD",                                             m_useEarlySkipDetection,                          false, "Early SKIP detection setting")
1094  ( "RateControl",                                    m_RCEnableRateControl,                            false, "Rate control: enable rate control" )
1095  ( "TargetBitrate",                                  m_RCTargetBitrate,                                    0, "Rate control: target bit-rate" )
1096  ( "KeepHierarchicalBit",                            m_RCKeepHierarchicalBit,                              0, "Rate control: 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation" )
1097  ( "LCULevelRateControl",                            m_RCLCULevelRC,                                    true, "Rate control: true: CTU level RC; false: picture level RC" )
1098  ( "RCLCUSeparateModel",                             m_RCUseLCUSeparateModel,                           true, "Rate control: use CTU level separate R-lambda model" )
1099  ( "InitialQP",                                      m_RCInitialQP,                                        0, "Rate control: initial QP" )
1100  ( "RCForceIntraQP",                                 m_RCForceIntraQP,                                 false, "Rate control: force intra QP to be equal to initial QP" )
1101
1102#if U0132_TARGET_BITS_SATURATION
1103  ( "RCCpbSaturation",                                m_RCCpbSaturationEnabled,                         false, "Rate control: enable target bits saturation to avoid CPB overflow and underflow" )
1104  ( "RCCpbSize",                                      m_RCCpbSize,                                         0u, "Rate control: CPB size" )
1105  ( "RCInitialCpbFullness",                           m_RCInitialCpbFullness,                             0.9, "Rate control: initial CPB fullness" )
1106#endif
1107
1108#if KWU_RC_VIEWRC_E0227
1109  ("ViewWiseTargetBits, -vtbr" ,  m_viewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
1110  ("TargetBitAssign, -ta", m_viewWiseRateCtrl, false, "View-wise rate control on/off")
1111#endif
1112#if KWU_RC_MADPRED_E0227
1113  ("DepthMADPred, -dm", m_depthMADPred, (UInt)0, "Depth based MAD prediction on/off")
1114#endif
1115#if NH_MV
1116// A lot of this stuff could should actually be derived by the encoder.
1117  // VPS VUI
1118  ("VpsVuiPresentFlag"           , m_vpsVuiPresentFlag           , false                                           , "VpsVuiPresentFlag           ")
1119  ("CrossLayerPicTypeAlignedFlag", m_crossLayerPicTypeAlignedFlag, false                                           , "CrossLayerPicTypeAlignedFlag")  // Could actually be derived by the encoder
1120  ("CrossLayerIrapAlignedFlag"   , m_crossLayerIrapAlignedFlag   , false                                           , "CrossLayerIrapAlignedFlag   ")  // Could actually be derived by the encoder
1121  ("AllLayersIdrAlignedFlag"     , m_allLayersIdrAlignedFlag     , false                                           , "CrossLayerIrapAlignedFlag   ")  // Could actually be derived by the encoder
1122  ("BitRatePresentVpsFlag"       , m_bitRatePresentVpsFlag       , false                                           , "BitRatePresentVpsFlag       ")
1123  ("PicRatePresentVpsFlag"       , m_picRatePresentVpsFlag       , false                                           , "PicRatePresentVpsFlag       ")
1124  ("BitRatePresentFlag"          , m_bitRatePresentFlag          , BoolAry1d(1,0)  ,MAX_VPS_OP_SETS_PLUS1, "BitRatePresentFlag per sub layer for the N-th layer set")
1125  ("PicRatePresentFlag"          , m_picRatePresentFlag          , BoolAry1d(1,0)  ,MAX_VPS_OP_SETS_PLUS1, "PicRatePresentFlag per sub layer for the N-th layer set")
1126  ("AvgBitRate"                  , m_avgBitRate                   , IntAry1d (1,0), MAX_VPS_OP_SETS_PLUS1, "AvgBitRate         per sub layer for the N-th layer set")
1127  ("MaxBitRate"                  , m_maxBitRate                   , IntAry1d (1,0), MAX_VPS_OP_SETS_PLUS1, "MaxBitRate         per sub layer for the N-th layer set")
1128  ("ConstantPicRateIdc"          , m_constantPicRateIdc           , IntAry1d (1,0), MAX_VPS_OP_SETS_PLUS1, "ConstantPicRateIdc per sub layer for the N-th layer set")
1129  ("AvgPicRate"                  , m_avgPicRate                   , IntAry1d (1,0), MAX_VPS_OP_SETS_PLUS1, "AvgPicRate         per sub layer for the N-th layer set")
1130  ("TilesNotInUseFlag"            , m_tilesNotInUseFlag            , true                                          , "TilesNotInUseFlag            ")
1131  ("TilesInUseFlag"               , m_tilesInUseFlag               , BoolAry1d(1,false)                   , "TilesInUseFlag               ")
1132  ("LoopFilterNotAcrossTilesFlag" , m_loopFilterNotAcrossTilesFlag , BoolAry1d(1,false)                  , "LoopFilterNotAcrossTilesFlag ")
1133  ("WppNotInUseFlag"              , m_wppNotInUseFlag              , true                                          , "WppNotInUseFlag              ")
1134  ("WppInUseFlag"                 , m_wppInUseFlag                 , BoolAry1d(1,0)                      , "WppInUseFlag                 ")
1135  ("TileBoundariesAlignedFlag"   , m_tileBoundariesAlignedFlag   , BoolAry1d(1,0)  ,MAX_NUM_LAYERS       , "TileBoundariesAlignedFlag    per direct reference for the N-th layer")
1136  ("IlpRestrictedRefLayersFlag"  , m_ilpRestrictedRefLayersFlag  , false                                           , "IlpRestrictedRefLayersFlag")
1137  ("MinSpatialSegmentOffsetPlus1", m_minSpatialSegmentOffsetPlus1 , IntAry1d (1,0), MAX_NUM_LAYERS       , "MinSpatialSegmentOffsetPlus1 per direct reference for the N-th layer")
1138  ("CtuBasedOffsetEnabledFlag"   , m_ctuBasedOffsetEnabledFlag   , BoolAry1d(1,0)  ,MAX_NUM_LAYERS       , "CtuBasedOffsetEnabledFlag    per direct reference for the N-th layer")
1139  ("MinHorizontalCtuOffsetPlus1" , m_minHorizontalCtuOffsetPlus1  , IntAry1d (1,0), MAX_NUM_LAYERS       , "MinHorizontalCtuOffsetPlus1  per direct reference for the N-th layer")
1140  ("SingleLayerForNonIrapFlag", m_singleLayerForNonIrapFlag, false                                          , "SingleLayerForNonIrapFlag")
1141  ("HigherLayerIrapSkipFlag"  , m_higherLayerIrapSkipFlag  , false                                          , "HigherLayerIrapSkipFlag  ")
1142#endif
1143
1144  ("TransquantBypassEnableFlag",                      m_TransquantBypassEnableFlag,                     false, "transquant_bypass_enable_flag indicator in PPS")
1145  ("CUTransquantBypassFlagForce",                     m_CUTransquantBypassFlagForce,                    false, "Force transquant bypass mode, when transquant_bypass_enable_flag is enabled")
1146  ("CostMode",                                        m_costMode,                         COST_STANDARD_LOSSY, "Use alternative cost functions: choose between 'lossy', 'sequence_level_lossless', 'lossless' (which forces QP to " MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP) ") and 'mixed_lossless_lossy' (which used QP'=" MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME) " for pre-estimates of transquant-bypass blocks).")
1147  ("RecalculateQPAccordingToLambda",                  m_recalculateQPAccordingToLambda,                 false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
1148  ("StrongIntraSmoothing,-sis",                       m_useStrongIntraSmoothing,                         true, "Enable strong intra smoothing for 32x32 blocks")
1149  ("SEIActiveParameterSets",                          m_activeParameterSetsSEIEnabled,                      0, "Enable generation of active parameter sets SEI messages")
1150  ("VuiParametersPresent,-vui",                       m_vuiParametersPresentFlag,                       false, "Enable generation of vui_parameters()")
1151  ("AspectRatioInfoPresent",                          m_aspectRatioInfoPresentFlag,                     false, "Signals whether aspect_ratio_idc is present")
1152  ("AspectRatioIdc",                                  m_aspectRatioIdc,                                     0, "aspect_ratio_idc")
1153  ("SarWidth",                                        m_sarWidth,                                           0, "horizontal size of the sample aspect ratio")
1154  ("SarHeight",                                       m_sarHeight,                                          0, "vertical size of the sample aspect ratio")
1155  ("OverscanInfoPresent",                             m_overscanInfoPresentFlag,                        false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
1156  ("OverscanAppropriate",                             m_overscanAppropriateFlag,                        false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
1157  ("VideoSignalTypePresent",                          m_videoSignalTypePresentFlag,                     false, "Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present")
1158  ("VideoFormat",                                     m_videoFormat,                                        5, "Indicates representation of pictures")
1159  ("VideoFullRange",                                  m_videoFullRangeFlag,                             false, "Indicates the black level and range of luma and chroma signals")
1160  ("ColourDescriptionPresent",                        m_colourDescriptionPresentFlag,                   false, "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present")
1161  ("ColourPrimaries",                                 m_colourPrimaries,                                    2, "Indicates chromaticity coordinates of the source primaries")
1162  ("TransferCharacteristics",                         m_transferCharacteristics,                            2, "Indicates the opto-electronic transfer characteristics of the source")
1163  ("MatrixCoefficients",                              m_matrixCoefficients,                                 2, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries")
1164  ("ChromaLocInfoPresent",                            m_chromaLocInfoPresentFlag,                       false, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present")
1165  ("ChromaSampleLocTypeTopField",                     m_chromaSampleLocTypeTopField,                        0, "Specifies the location of chroma samples for top field")
1166  ("ChromaSampleLocTypeBottomField",                  m_chromaSampleLocTypeBottomField,                     0, "Specifies the location of chroma samples for bottom field")
1167  ("NeutralChromaIndication",                         m_neutralChromaIndicationFlag,                    false, "Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)")
1168  ("DefaultDisplayWindowFlag",                        m_defaultDisplayWindowFlag,                       false, "Indicates the presence of the Default Window parameters")
1169  ("DefDispWinLeftOffset",                            m_defDispWinLeftOffset,                               0, "Specifies the left offset of the default display window from the conformance window")
1170  ("DefDispWinRightOffset",                           m_defDispWinRightOffset,                              0, "Specifies the right offset of the default display window from the conformance window")
1171  ("DefDispWinTopOffset",                             m_defDispWinTopOffset,                                0, "Specifies the top offset of the default display window from the conformance window")
1172  ("DefDispWinBottomOffset",                          m_defDispWinBottomOffset,                             0, "Specifies the bottom offset of the default display window from the conformance window")
1173  ("FrameFieldInfoPresentFlag",                       m_frameFieldInfoPresentFlag,                      false, "Indicates that pic_struct and field coding related values are present in picture timing SEI messages")
1174  ("PocProportionalToTimingFlag",                     m_pocProportionalToTimingFlag,                    false, "Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS")
1175  ("NumTicksPocDiffOneMinus1",                        m_numTicksPocDiffOneMinus1,                           0, "Number of ticks minus 1 that for a POC difference of one")
1176  ("BitstreamRestriction",                            m_bitstreamRestrictionFlag,                       false, "Signals whether bitstream restriction parameters are present")
1177  ("TilesFixedStructure",                             m_tilesFixedStructureFlag,                        false, "Indicates that each active picture parameter set has the same values of the syntax elements related to tiles")
1178  ("MotionVectorsOverPicBoundaries",                  m_motionVectorsOverPicBoundariesFlag,             false, "Indicates that no samples outside the picture boundaries are used for inter prediction")
1179  ("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")
1180  ("MaxBitsPerMinCuDenom",                            m_maxBitsPerMinCuDenom,                               1, "Indicates an upper bound for the number of bits of coding_unit() data")
1181  ("Log2MaxMvLengthHorizontal",                       m_log2MaxMvLengthHorizontal,                         15, "Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units")
1182  ("Log2MaxMvLengthVertical",                         m_log2MaxMvLengthVertical,                           15, "Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units")
1183  ("SEIColourRemappingInfoFileRoot,-cri",             m_colourRemapSEIFileRoot,                    string(""), "Colour Remapping Information SEI parameters root file name (wo num ext)")
1184  ("SEIRecoveryPoint",                                m_recoveryPointSEIEnabled,                        false, "Control generation of recovery point SEI messages")
1185  ("SEIBufferingPeriod",                              m_bufferingPeriodSEIEnabled,                      false, "Control generation of buffering period SEI messages")
1186  ("SEIPictureTiming",                                m_pictureTimingSEIEnabled,                        false, "Control generation of picture timing SEI messages")
1187  ("SEIToneMappingInfo",                              m_toneMappingInfoSEIEnabled,                      false, "Control generation of Tone Mapping SEI messages")
1188  ("SEIToneMapId",                                    m_toneMapId,                                          0, "Specifies Id of Tone Mapping SEI message for a given session")
1189  ("SEIToneMapCancelFlag",                            m_toneMapCancelFlag,                              false, "Indicates that Tone Mapping SEI message cancels the persistence or follows")
1190  ("SEIToneMapPersistenceFlag",                       m_toneMapPersistenceFlag,                          true, "Specifies the persistence of the Tone Mapping SEI message")
1191  ("SEIToneMapCodedDataBitDepth",                     m_toneMapCodedDataBitDepth,                           8, "Specifies Coded Data BitDepth of Tone Mapping SEI messages")
1192  ("SEIToneMapTargetBitDepth",                        m_toneMapTargetBitDepth,                              8, "Specifies Output BitDepth of Tone mapping function")
1193  ("SEIToneMapModelId",                               m_toneMapModelId,                                     0, "Specifies Model utilized for mapping coded data into target_bit_depth range\n"
1194                                                                                                               "\t0:  linear mapping with clipping\n"
1195                                                                                                               "\t1:  sigmoidal mapping\n"
1196                                                                                                               "\t2:  user-defined table mapping\n"
1197                                                                                                               "\t3:  piece-wise linear mapping\n"
1198                                                                                                               "\t4:  luminance dynamic range information ")
1199  ("SEIToneMapMinValue",                              m_toneMapMinValue,                                    0, "Specifies the minimum value in mode 0")
1200  ("SEIToneMapMaxValue",                              m_toneMapMaxValue,                                 1023, "Specifies the maximum value in mode 0")
1201  ("SEIToneMapSigmoidMidpoint",                       m_sigmoidMidpoint,                                  512, "Specifies the centre point in mode 1")
1202  ("SEIToneMapSigmoidWidth",                          m_sigmoidWidth,                                     960, "Specifies the distance between 5% and 95% values of the target_bit_depth in mode 1")
1203  ("SEIToneMapStartOfCodedInterval",                  cfg_startOfCodedInterval,      cfg_startOfCodedInterval, "Array of user-defined mapping table")
1204  ("SEIToneMapNumPivots",                             m_numPivots,                                          0, "Specifies the number of pivot points in mode 3")
1205  ("SEIToneMapCodedPivotValue",                       cfg_codedPivotValue,                cfg_codedPivotValue, "Array of pivot point")
1206  ("SEIToneMapTargetPivotValue",                      cfg_targetPivotValue,              cfg_targetPivotValue, "Array of pivot point")
1207  ("SEIToneMapCameraIsoSpeedIdc",                     m_cameraIsoSpeedIdc,                                  0, "Indicates the camera ISO speed for daylight illumination")
1208  ("SEIToneMapCameraIsoSpeedValue",                   m_cameraIsoSpeedValue,                              400, "Specifies the camera ISO speed for daylight illumination of Extended_ISO")
1209  ("SEIToneMapExposureIndexIdc",                      m_exposureIndexIdc,                                   0, "Indicates the exposure index setting of the camera")
1210  ("SEIToneMapExposureIndexValue",                    m_exposureIndexValue,                               400, "Specifies the exposure index setting of the camera of Extended_ISO")
1211  ("SEIToneMapExposureCompensationValueSignFlag",     m_exposureCompensationValueSignFlag,               false, "Specifies the sign of ExposureCompensationValue")
1212  ("SEIToneMapExposureCompensationValueNumerator",    m_exposureCompensationValueNumerator,                 0, "Specifies the numerator of ExposureCompensationValue")
1213  ("SEIToneMapExposureCompensationValueDenomIdc",     m_exposureCompensationValueDenomIdc,                  2, "Specifies the denominator of ExposureCompensationValue")
1214  ("SEIToneMapRefScreenLuminanceWhite",               m_refScreenLuminanceWhite,                          350, "Specifies reference screen brightness setting in units of candela per square metre")
1215  ("SEIToneMapExtendedRangeWhiteLevel",               m_extendedRangeWhiteLevel,                          800, "Indicates the luminance dynamic range")
1216  ("SEIToneMapNominalBlackLevelLumaCodeValue",        m_nominalBlackLevelLumaCodeValue,                    16, "Specifies luma sample value of the nominal black level assigned decoded pictures")
1217  ("SEIToneMapNominalWhiteLevelLumaCodeValue",        m_nominalWhiteLevelLumaCodeValue,                   235, "Specifies luma sample value of the nominal white level assigned decoded pictures")
1218  ("SEIToneMapExtendedWhiteLevelLumaCodeValue",       m_extendedWhiteLevelLumaCodeValue,                  300, "Specifies luma sample value of the extended dynamic range assigned decoded pictures")
1219  ("SEIChromaResamplingFilterHint",                   m_chromaResamplingFilterSEIenabled,               false, "Control generation of the chroma sampling filter hint SEI message")
1220  ("SEIChromaResamplingHorizontalFilterType",         m_chromaResamplingHorFilterIdc,                       2, "Defines the Index of the chroma sampling horizontal filter\n"
1221                                                                                                               "\t0: unspecified  - Chroma filter is unknown or is determined by the application"
1222                                                                                                               "\t1: User-defined - Filter coefficients are specified in the chroma sampling filter hint SEI message"
1223                                                                                                               "\t2: Standards-defined - ITU-T Rec. T.800 | ISO/IEC15444-1, 5/3 filter")
1224  ("SEIChromaResamplingVerticalFilterType",           m_chromaResamplingVerFilterIdc,                         2, "Defines the Index of the chroma sampling vertical filter\n"
1225                                                                                                               "\t0: unspecified  - Chroma filter is unknown or is determined by the application"
1226                                                                                                               "\t1: User-defined - Filter coefficients are specified in the chroma sampling filter hint SEI message"
1227                                                                                                               "\t2: Standards-defined - ITU-T Rec. T.800 | ISO/IEC15444-1, 5/3 filter")
1228  ("SEIFramePacking",                                 m_framePackingSEIEnabled,                         false, "Control generation of frame packing SEI messages")
1229  ("SEIFramePackingType",                             m_framePackingSEIType,                                0, "Define frame packing arrangement\n"
1230                                                                                                               "\t3: side by side - frames are displayed horizontally\n"
1231                                                                                                               "\t4: top bottom - frames are displayed vertically\n"
1232                                                                                                               "\t5: frame alternation - one frame is alternated with the other")
1233  ("SEIFramePackingId",                               m_framePackingSEIId,                                  0, "Id of frame packing SEI message for a given session")
1234  ("SEIFramePackingQuincunx",                         m_framePackingSEIQuincunx,                            0, "Indicate the presence of a Quincunx type video frame")
1235  ("SEIFramePackingInterpretation",                   m_framePackingSEIInterpretation,                      0, "Indicate the interpretation of the frame pair\n"
1236                                                                                                               "\t0: unspecified\n"
1237                                                                                                               "\t1: stereo pair, frame0 represents left view\n"
1238                                                                                                               "\t2: stereo pair, frame0 represents right view")
1239  ("SEISegmentedRectFramePacking",                    m_segmentedRectFramePackingSEIEnabled,            false, "Controls generation of segmented rectangular frame packing SEI messages")
1240  ("SEISegmentedRectFramePackingCancel",              m_segmentedRectFramePackingSEICancel,             false, "If equal to 1, cancels the persistence of any previous SRFPA SEI message")
1241  ("SEISegmentedRectFramePackingType",                m_segmentedRectFramePackingSEIType,                   0, "Specifies the arrangement of the frames in the reconstructed picture")
1242  ("SEISegmentedRectFramePackingPersistence",         m_segmentedRectFramePackingSEIPersistence,        false, "If equal to 0, the SEI applies to the current frame only")
1243  ("SEIDisplayOrientation",                           m_displayOrientationSEIAngle,                         0, "Control generation of display orientation SEI messages\n"
1244                                                                                                               "\tN: 0 < N < (2^16 - 1) enable display orientation SEI message with anticlockwise_rotation = N and display_orientation_repetition_period = 1\n"
1245                                                                                                               "\t0: disable")
1246  ("SEITemporalLevel0Index",                          m_temporalLevel0IndexSEIEnabled,                  false, "Control generation of temporal level 0 index SEI messages")
1247  ("SEIGradualDecodingRefreshInfo",                   m_gradualDecodingRefreshInfoEnabled,              false, "Control generation of gradual decoding refresh information SEI message")
1248  ("SEINoDisplay",                                    m_noDisplaySEITLayer,                                 0, "Control generation of no display SEI message\n"
1249                                                                                                               "\tN: 0 < N enable no display SEI message for temporal layer N or higher\n"
1250                                                                                                               "\t0: disable")
1251  ("SEIDecodingUnitInfo",                             m_decodingUnitInfoSEIEnabled,                     false, "Control generation of decoding unit information SEI message.")
1252  ("SEISOPDescription",                               m_SOPDescriptionSEIEnabled,                       false, "Control generation of SOP description SEI messages")
1253  ("SEIScalableNesting",                              m_scalableNestingSEIEnabled,                      false, "Control generation of scalable nesting SEI messages")
1254  ("SEITempMotionConstrainedTileSets",                m_tmctsSEIEnabled,                                false, "Control generation of temporal motion constrained tile sets SEI message")
1255  ("SEITimeCodeEnabled",                              m_timeCodeSEIEnabled,                             false, "Control generation of time code information SEI message")
1256  ("SEITimeCodeNumClockTs",                           m_timeCodeSEINumTs,                                   0, "Number of clock time sets [0..3]")
1257  ("SEITimeCodeTimeStampFlag",                        cfg_timeCodeSeiTimeStampFlag,          cfg_timeCodeSeiTimeStampFlag,         "Time stamp flag associated to each time set")
1258  ("SEITimeCodeFieldBasedFlag",                       cfg_timeCodeSeiNumUnitFieldBasedFlag,  cfg_timeCodeSeiNumUnitFieldBasedFlag, "Field based flag associated to each time set")
1259  ("SEITimeCodeCountingType",                         cfg_timeCodeSeiCountingType,           cfg_timeCodeSeiCountingType,          "Counting type associated to each time set")
1260  ("SEITimeCodeFullTsFlag",                           cfg_timeCodeSeiFullTimeStampFlag,      cfg_timeCodeSeiFullTimeStampFlag,     "Full time stamp flag associated to each time set")
1261  ("SEITimeCodeDiscontinuityFlag",                    cfg_timeCodeSeiDiscontinuityFlag,      cfg_timeCodeSeiDiscontinuityFlag,     "Discontinuity flag associated to each time set")
1262  ("SEITimeCodeCntDroppedFlag",                       cfg_timeCodeSeiCntDroppedFlag,         cfg_timeCodeSeiCntDroppedFlag,        "Counter dropped flag associated to each time set")
1263  ("SEITimeCodeNumFrames",                            cfg_timeCodeSeiNumberOfFrames,         cfg_timeCodeSeiNumberOfFrames,        "Number of frames associated to each time set")
1264  ("SEITimeCodeSecondsValue",                         cfg_timeCodeSeiSecondsValue,           cfg_timeCodeSeiSecondsValue,          "Seconds value for each time set")
1265  ("SEITimeCodeMinutesValue",                         cfg_timeCodeSeiMinutesValue,           cfg_timeCodeSeiMinutesValue,          "Minutes value for each time set")
1266  ("SEITimeCodeHoursValue",                           cfg_timeCodeSeiHoursValue,             cfg_timeCodeSeiHoursValue,            "Hours value for each time set")
1267  ("SEITimeCodeSecondsFlag",                          cfg_timeCodeSeiSecondsFlag,            cfg_timeCodeSeiSecondsFlag,           "Flag to signal seconds value presence in each time set")
1268  ("SEITimeCodeMinutesFlag",                          cfg_timeCodeSeiMinutesFlag,            cfg_timeCodeSeiMinutesFlag,           "Flag to signal minutes value presence in each time set")
1269  ("SEITimeCodeHoursFlag",                            cfg_timeCodeSeiHoursFlag,              cfg_timeCodeSeiHoursFlag,             "Flag to signal hours value presence in each time set")
1270  ("SEITimeCodeOffsetLength",                         cfg_timeCodeSeiTimeOffsetLength,       cfg_timeCodeSeiTimeOffsetLength,      "Time offset length associated to each time set")
1271  ("SEITimeCodeTimeOffset",                           cfg_timeCodeSeiTimeOffsetValue,        cfg_timeCodeSeiTimeOffsetValue,       "Time offset associated to each time set")
1272  ("SEIKneeFunctionInfo",                             m_kneeSEIEnabled,                                 false, "Control generation of Knee function SEI messages")
1273  ("SEIKneeFunctionId",                               m_kneeSEIId,                                          0, "Specifies Id of Knee function SEI message for a given session")
1274  ("SEIKneeFunctionCancelFlag",                       m_kneeSEICancelFlag,                              false, "Indicates that Knee function SEI message cancels the persistence or follows")
1275  ("SEIKneeFunctionPersistenceFlag",                  m_kneeSEIPersistenceFlag,                          true, "Specifies the persistence of the Knee function SEI message")
1276  ("SEIKneeFunctionInputDrange",                      m_kneeSEIInputDrange,                              1000, "Specifies the peak luminance level for the input picture of Knee function SEI messages")
1277  ("SEIKneeFunctionInputDispLuminance",               m_kneeSEIInputDispLuminance,                        100, "Specifies the expected display brightness for the input picture of Knee function SEI messages")
1278  ("SEIKneeFunctionOutputDrange",                     m_kneeSEIOutputDrange,                             4000, "Specifies the peak luminance level for the output picture of Knee function SEI messages")
1279  ("SEIKneeFunctionOutputDispLuminance",              m_kneeSEIOutputDispLuminance,                       800, "Specifies the expected display brightness for the output picture of Knee function SEI messages")
1280  ("SEIKneeFunctionNumKneePointsMinus1",              m_kneeSEINumKneePointsMinus1,                         2, "Specifies the number of knee points - 1")
1281  ("SEIKneeFunctionInputKneePointValue",              cfg_kneeSEIInputKneePointValue,   cfg_kneeSEIInputKneePointValue, "Array of input knee point")
1282  ("SEIKneeFunctionOutputKneePointValue",             cfg_kneeSEIOutputKneePointValue, cfg_kneeSEIOutputKneePointValue, "Array of output knee point")
1283  ("SEIMasteringDisplayColourVolume",                 m_masteringDisplay.colourVolumeSEIEnabled,         false, "Control generation of mastering display colour volume SEI messages")
1284  ("SEIMasteringDisplayMaxLuminance",                 m_masteringDisplay.maxLuminance,                  10000u, "Specifies the mastering display maximum luminance value in units of 1/10000 candela per square metre (32-bit code value)")
1285  ("SEIMasteringDisplayMinLuminance",                 m_masteringDisplay.minLuminance,                      0u, "Specifies the mastering display minimum luminance value in units of 1/10000 candela per square metre (32-bit code value)")
1286  ("SEIMasteringDisplayPrimaries",                    cfg_DisplayPrimariesCode,       cfg_DisplayPrimariesCode, "Mastering display primaries for all three colour planes in CIE xy coordinates in increments of 1/50000 (results in the ranges 0 to 50000 inclusive)")
1287  ("SEIMasteringDisplayWhitePoint",                   cfg_DisplayWhitePointCode,     cfg_DisplayWhitePointCode, "Mastering display white point CIE xy coordinates in normalised increments of 1/50000 (e.g. 0.333 = 16667)")
1288#if NH_MV
1289#if !NH_MV_SEI
1290  ("SubBitstreamPropSEIEnabled",                      m_subBistreamPropSEIEnabled,    false                     ,"Enable signaling of sub-bitstream property SEI message")
1291  ("SEISubBitstreamNumAdditionalSubStreams",          m_sbPropNumAdditionalSubStreams,0                         ,"Number of substreams for which additional information is signalled")
1292  ("SEISubBitstreamSubBitstreamMode",                 m_sbPropSubBitstreamMode,       IntAry1d (1,0)            ,"Specifies mode of generation of the i-th sub-bitstream (0 or 1)")
1293  ("SEISubBitstreamOutputLayerSetIdxToVps",           m_sbPropOutputLayerSetIdxToVps, IntAry1d (1,0)            ,"Specifies output layer set index of the i-th sub-bitstream ")
1294  ("SEISubBitstreamHighestSublayerId",                m_sbPropHighestSublayerId,      IntAry1d (1,0)            ,"Specifies highest TemporalId of the i-th sub-bitstream")
1295  ("SEISubBitstreamAvgBitRate",                       m_sbPropAvgBitRate,             IntAry1d (1,0)            ,"Specifies average bit rate of the i-th sub-bitstream")
1296  ("SEISubBitstreamMaxBitRate",                       m_sbPropMaxBitRate,             IntAry1d (1,0)            ,"Specifies maximum bit rate of the i-th sub-bitstream")
1297#else
1298  ("SeiCfgFileName_%d",                               m_seiCfgFileNames,             (TChar *) 0 ,MAX_NUM_SEIS , "SEI cfg file name %d")
1299#endif
1300  ("OutputVpsInfo",                                   m_outputVpsInfo,                false                     ,"Output information about the layer dependencies and layer sets")
1301#endif
1302#if NH_3D
1303/* Camera parameters */ 
1304  ("Depth420OutputFlag",                              m_depth420OutputFlag,           true                     , "Output depth layers in 4:2:0 ") 
1305  ("CameraParameterFile,cpf",                         m_pchCameraParameterFile,    (TChar *) 0                 , "Camera Parameter File Name")
1306  ("BaseViewCameraNumbers",                           m_pchBaseViewCameraNumbers,  (TChar *) 0                 , "Numbers of base views")
1307  ("CodedCamParsPrecision",                           m_iCodedCamParPrecision,      STD_CAM_PARAMETERS_PRECISION, "precision for coding of camera parameters (in units of 2^(-x) luma samples)" )
1308
1309#if NH_3D_VSO
1310  /* View Synthesis Optimization */
1311  ("VSOConfig",                                       m_pchVSOConfig            , (TChar *) 0                   ,"VSO configuration")
1312  ("VSO",                                             m_bUseVSO                 , false                         ,"Use VSO" )   
1313  ("VSOMode",                                         m_uiVSOMode               , (UInt)   4                    ,"VSO Mode")
1314  ("LambdaScaleVSO",                                  m_dLambdaScaleVSO         , (Double) 1                    ,"Lambda Scaling for VSO")
1315  ("VSOLSTable",                                      m_bVSOLSTable             , true                          ,"Depth QP dependent video/depth rate allocation by Lagrange multiplier" )     
1316  ("ForceLambdaScaleVSO",                             m_bForceLambdaScaleVSO    , false                         ,"Force using Lambda Scale VSO also in non-VSO-Mode")
1317  ("AllowNegDist",                                    m_bAllowNegDist           , true                          ,"Allow negative Distortion in VSO")
1318                                                                                                             
1319  ("UseEstimatedVSD",                                 m_bUseEstimatedVSD        , true                          ,"Model based VSD estimation instead of rendering based for some encoder decisions" )     
1320  ("VSOEarlySkip",                                    m_bVSOEarlySkip           , true                          ,"Early skip of VSO computation if synthesis error assumed to be zero" )     
1321                                                                                                               
1322  ("WVSO",                                            m_bUseWVSO                , true                          ,"Use depth fidelity term for VSO" )
1323  ("VSOWeight",                                       m_iVSOWeight              , 10                            ,"Synthesized View Distortion Change weight" )
1324  ("VSDWeight",                                       m_iVSDWeight              , 1                             ,"View Synthesis Distortion estimate weight" )
1325  ("DWeight",                                         m_iDWeight                , 1                             ,"Depth Distortion weight" )
1326#endif //HHI_VSO
1327/* 3D- HEVC Tools */                                                           
1328  ("QTL"                   ,                          m_bUseQTL                 , true                          , "Use depth quad tree limitation (encoder only)" )
1329  ("IvMvPredFlag"          ,                          m_ivMvPredFlag            , BoolAry1d(2,true)             , "Inter-view motion prediction"              )
1330  ("IvMvScalingFlag"       ,                          m_ivMvScalingFlag         , BoolAry1d(2,true)             , "Inter-view motion vector scaling"          )
1331  ("Log2SubPbSizeMinus3"   ,                          m_log2SubPbSizeMinus3     , 0                             , "Log2 minus 3 of sub Pb size"               )
1332  ("IvResPredFlag"         ,                          m_ivResPredFlag           , true                          , "Inter-view residual prediction"            )
1333  ("DepthRefinementFlag"   ,                          m_depthRefinementFlag     , true                          , "Depth to refine disparity"                 )
1334  ("ViewSynthesisPredFlag" ,                          m_viewSynthesisPredFlag   , true                          , "View synthesis prediction"                 )
1335  ("DepthBasedBlkPartFlag" ,                          m_depthBasedBlkPartFlag   , true                          , "Depth base block partitioning"             )
1336  ("MpiFlag"               ,                          m_mpiFlag                 , true                          , "Motion inheritance from texture to depth"  )
1337  ("Log2MpiSubPbSizeMinus3",                          m_log2MpiSubPbSizeMinus3  , 0                             , "Log2 minus 3 of sub Pb size for MPI"       )
1338  ("IntraContourFlag"      ,                          m_intraContourFlag        , true                          , "Intra contour mode"                        )
1339  ("IntraWedgeFlag"        ,                          m_intraWedgeFlag          , true                          , "Intra wedge mode and segmental depth DCs"  )
1340  ("IntraSdcFlag"          ,                          m_intraSdcFlag            , true                          , "Intra depth DCs"                           )
1341  ("QtPredFlag"            ,                          m_qtPredFlag              , true                          , "Quad tree prediction from texture to depth")
1342  ("InterSdcFlag"          ,                          m_interSdcFlag            , true                          , "Inter depth DCs"                           )
1343  ("DepthIntraSkip"        ,                          m_depthIntraSkipFlag      , true                          , "Depth intra skip mode"                     )
1344  ("DLT"                   ,                          m_useDLT                  , true                          , "Depth lookup table"                        )
1345  ("IlluCompEnable"        ,                          m_abUseIC                 , true                          , "Enable illumination compensation"          )
1346  ("IlluCompLowLatencyEnc" ,                          m_bUseLowLatencyICEnc     , false                         , "Enable low-latency illumination compensation encoding")
1347#endif //NH_3D
1348   
1349  ;
1350
1351#if NH_MV
1352  // parse coding structure
1353  for( Int k = 0; k < MAX_NUM_LAYERS; k++ )
1354  {
1355    m_GOPListMvc.push_back( new GOPEntry[MAX_GOP + 1] );
1356    if( k == 0 )
1357    {
1358      m_GOPListMvc[0][0].m_sliceType = 'I'; 
1359      for( Int i = 1; i < MAX_GOP + 1; i++ ) 
1360      {
1361        std::ostringstream cOSS;
1362        cOSS<<"Frame"<<i;
1363        opts.addOptions()( cOSS.str(), m_GOPListMvc[k][i-1], GOPEntry() );
1364        if ( i != 1 )
1365        {
1366          opts.opt_list.back()->opt->opt_duplicate = true; 
1367        }       
1368      }
1369    }
1370    else
1371    {
1372      std::ostringstream cOSS1;
1373      cOSS1<<"FrameI"<<"_l"<<k;
1374
1375      opts.addOptions()(cOSS1.str(), m_GOPListMvc[k][MAX_GOP], GOPEntry());
1376      if ( k > 1 )
1377      {
1378        opts.opt_list.back()->opt->opt_duplicate = true; 
1379      }       
1380
1381
1382  for(Int i=1; i<MAX_GOP+1; i++)
1383  {
1384        std::ostringstream cOSS2;
1385        cOSS2<<"Frame"<<i<<"_l"<<k;
1386        opts.addOptions()(cOSS2.str(), m_GOPListMvc[k][i-1], GOPEntry());
1387        if ( i != 1 || k > 0 )
1388        {
1389          opts.opt_list.back()->opt->opt_duplicate = true; 
1390        }       
1391      }
1392    }
1393  }
1394#else
1395  for(Int i=1; i<MAX_GOP+1; i++)
1396  {
1397    std::ostringstream cOSS;
1398    cOSS<<"Frame"<<i;
1399    opts.addOptions()(cOSS.str(), m_GOPList[i-1], GOPEntry());
1400  }
1401#endif
1402  po::setDefaults(opts);
1403  po::ErrorReporter err;
1404  const list<const TChar*>& argv_unhandled = po::scanArgv(opts, argc, (const TChar**) argv, err);
1405
1406  for (list<const TChar*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
1407  {
1408    fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
1409  }
1410
1411  if (argc == 1 || do_help)
1412  {
1413    /* argc == 1: no options have been specified */
1414    po::doHelp(cout, opts);
1415    return false;
1416  }
1417
1418  if (err.is_errored)
1419  {
1420    if (!warnUnknowParameter)
1421    {
1422      /* error report has already been printed on stderr */
1423      return false;
1424    }
1425  }
1426
1427  /*
1428   * Set any derived parameters
1429   */
1430  m_adIntraLambdaModifier = cfg_adIntraLambdaModifier.values;
1431  if(m_isField)
1432  {
1433    //Frame height
1434    m_iSourceHeightOrg = m_iSourceHeight;
1435    //Field height
1436    m_iSourceHeight = m_iSourceHeight >> 1;
1437    //number of fields to encode
1438    m_framesToBeEncoded *= 2;
1439  }
1440
1441  if( !m_tileUniformSpacingFlag && m_numTileColumnsMinus1 > 0 )
1442  {
1443    if (cfg_ColumnWidth.values.size() > m_numTileColumnsMinus1)
1444    {
1445      printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" );
1446      exit( EXIT_FAILURE );
1447    }
1448    else if (cfg_ColumnWidth.values.size() < m_numTileColumnsMinus1)
1449    {
1450      printf( "The width of some columns is not defined.\n" );
1451      exit( EXIT_FAILURE );
1452    }
1453    else
1454    {
1455      m_tileColumnWidth.resize(m_numTileColumnsMinus1);
1456      for(UInt i=0; i<cfg_ColumnWidth.values.size(); i++)
1457      {
1458        m_tileColumnWidth[i]=cfg_ColumnWidth.values[i];
1459      }
1460    }
1461  }
1462  else
1463  {
1464    m_tileColumnWidth.clear();
1465  }
1466
1467  if( !m_tileUniformSpacingFlag && m_numTileRowsMinus1 > 0 )
1468  {
1469    if (cfg_RowHeight.values.size() > m_numTileRowsMinus1)
1470    {
1471      printf( "The number of rows whose height are defined is larger than the allowed number of rows.\n" );
1472      exit( EXIT_FAILURE );
1473    }
1474    else if (cfg_RowHeight.values.size() < m_numTileRowsMinus1)
1475    {
1476      printf( "The height of some rows is not defined.\n" );
1477      exit( EXIT_FAILURE );
1478    }
1479    else
1480    {
1481      m_tileRowHeight.resize(m_numTileRowsMinus1);
1482      for(UInt i=0; i<cfg_RowHeight.values.size(); i++)
1483      {
1484        m_tileRowHeight[i]=cfg_RowHeight.values[i];
1485      }
1486    }
1487  }
1488  else
1489  {
1490    m_tileRowHeight.clear();
1491  }
1492
1493  /* rules for input, output and internal bitdepths as per help text */
1494  if (m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] == 0)
1495  {
1496    m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] = m_inputBitDepth      [CHANNEL_TYPE_LUMA  ];
1497  }
1498  if (m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] == 0)
1499  {
1500    m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] = m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ];
1501  }
1502  if (m_internalBitDepth   [CHANNEL_TYPE_LUMA  ] == 0)
1503  {
1504    m_internalBitDepth   [CHANNEL_TYPE_LUMA  ] = m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ];
1505  }
1506  if (m_internalBitDepth   [CHANNEL_TYPE_CHROMA] == 0)
1507  {
1508    m_internalBitDepth   [CHANNEL_TYPE_CHROMA] = m_internalBitDepth   [CHANNEL_TYPE_LUMA  ];
1509  }
1510  if (m_inputBitDepth      [CHANNEL_TYPE_CHROMA] == 0)
1511  {
1512    m_inputBitDepth      [CHANNEL_TYPE_CHROMA] = m_inputBitDepth      [CHANNEL_TYPE_LUMA  ];
1513  }
1514  if (m_outputBitDepth     [CHANNEL_TYPE_LUMA  ] == 0)
1515  {
1516    m_outputBitDepth     [CHANNEL_TYPE_LUMA  ] = m_internalBitDepth   [CHANNEL_TYPE_LUMA  ];
1517  }
1518  if (m_outputBitDepth     [CHANNEL_TYPE_CHROMA] == 0)
1519  {
1520    m_outputBitDepth     [CHANNEL_TYPE_CHROMA] = m_internalBitDepth   [CHANNEL_TYPE_CHROMA];
1521  }
1522
1523  m_InputChromaFormatIDC = numberToChromaFormat(tmpInputChromaFormat);
1524  m_chromaFormatIDC      = ((tmpChromaFormat == 0) ? (m_InputChromaFormatIDC) : (numberToChromaFormat(tmpChromaFormat)));
1525
1526
1527  assert(tmpWeightedPredictionMethod>=0 && tmpWeightedPredictionMethod<=WP_PER_PICTURE_WITH_HISTOGRAM_AND_PER_COMPONENT_AND_CLIPPING_AND_EXTENSION);
1528  if (!(tmpWeightedPredictionMethod>=0 && tmpWeightedPredictionMethod<=WP_PER_PICTURE_WITH_HISTOGRAM_AND_PER_COMPONENT_AND_CLIPPING_AND_EXTENSION))
1529  {
1530    exit(EXIT_FAILURE);
1531  }
1532  m_weightedPredictionMethod = WeightedPredictionMethod(tmpWeightedPredictionMethod);
1533
1534  assert(tmpFastInterSearchMode>=0 && tmpFastInterSearchMode<=FASTINTERSEARCH_MODE3);
1535  if (tmpFastInterSearchMode<0 || tmpFastInterSearchMode>FASTINTERSEARCH_MODE3)
1536  {
1537    exit(EXIT_FAILURE);
1538  }
1539  m_fastInterSearchMode = FastInterSearchMode(tmpFastInterSearchMode);
1540
1541  assert(tmpMotionEstimationSearchMethod>=0 && tmpMotionEstimationSearchMethod<MESEARCH_NUMBER_OF_METHODS);
1542  if (tmpMotionEstimationSearchMethod<0 || tmpMotionEstimationSearchMethod>=MESEARCH_NUMBER_OF_METHODS)
1543  {
1544    exit(EXIT_FAILURE);
1545  }
1546  m_motionEstimationSearchMethod=MESearchMethod(tmpMotionEstimationSearchMethod);
1547
1548#if NH_MV
1549  // parse PTL
1550  Bool anyEmpty = false; 
1551  if( cfg_profiles.empty() )
1552  {
1553#if NH_3D
1554    cfg_profiles = string("main main 3d-main");
1555#else
1556    cfg_profiles = string("main main multiview-main");   
1557#endif
1558    fprintf(stderr, "\nWarning: No profiles given, using defaults: %s", cfg_profiles.c_str() );
1559    anyEmpty = true; 
1560  }
1561
1562  if( cfg_levels.empty() )
1563  {
1564    cfg_levels = string("5.1 5.1 5.1");
1565    fprintf(stderr, "\nWarning: No levels given, using defaults: %s", cfg_levels.c_str() );
1566    anyEmpty = true; 
1567  }
1568
1569  if( cfg_tiers.empty() )
1570  {
1571    cfg_tiers = string("main main main");
1572    fprintf(stderr, "\nWarning: No tiers given, using defaults: %s", cfg_tiers.c_str());
1573    anyEmpty = true; 
1574  }
1575
1576  if( m_inblFlag.empty() )
1577  {
1578    fprintf(stderr, "\nWarning: No inblFlags given, using defaults:");
1579    for( Int i = 0; i < 3; i++)
1580    {
1581      m_inblFlag.push_back( false );
1582      fprintf(stderr," %d", (Int) m_inblFlag[i]);
1583    }
1584    anyEmpty = true; 
1585  }   
1586
1587  if ( anyEmpty )
1588  {
1589    fprintf( stderr, "\n" );
1590  }
1591
1592  xReadStrToEnum( cfg_profiles, extendedProfiles  ); 
1593  xReadStrToEnum( cfg_levels,   m_level     ); 
1594  xReadStrToEnum( cfg_tiers ,   m_levelTier ); 
1595
1596
1597#if NH_MV
1598  m_profiles.resize( extendedProfiles.size()); 
1599
1600  for (Int i = 0; i < m_profiles.size(); i++)
1601  {
1602    Profile::Name& m_profile             = m_profiles      [i]; 
1603    ExtendedProfileName& extendedProfile = extendedProfiles[i]; 
1604#endif
1605#endif
1606
1607  if (extendedProfile >= 1000 && extendedProfile <= 12316)
1608    {
1609      m_profile = Profile::MAINREXT;
1610      if (m_bitDepthConstraint != 0 || tmpConstraintChromaFormat != 0)
1611      {
1612        fprintf(stderr, "Error: The bit depth and chroma format constraints are not used when an explicit RExt profile is specified\n");
1613        exit(EXIT_FAILURE);
1614      }
1615      m_bitDepthConstraint     = (extendedProfile%100);
1616    m_intraConstraintFlag          = ((extendedProfile%10000)>=2000);
1617    m_onePictureOnlyConstraintFlag = (extendedProfile >= 10000);
1618      switch ((extendedProfile/100)%10)
1619      {
1620      case 0:  tmpConstraintChromaFormat=400; break;
1621      case 1:  tmpConstraintChromaFormat=420; break;
1622      case 2:  tmpConstraintChromaFormat=422; break;
1623      default: tmpConstraintChromaFormat=444; break;
1624      }
1625    }
1626    else
1627    {
1628      m_profile = Profile::Name(extendedProfile);
1629    }
1630
1631    if (m_profile == Profile::HIGHTHROUGHPUTREXT )
1632    {
1633      if (m_bitDepthConstraint == 0)
1634      {
1635        m_bitDepthConstraint = 16;
1636      }
1637      m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? CHROMA_444 : numberToChromaFormat(tmpConstraintChromaFormat);
1638    }
1639    else if (m_profile == Profile::MAINREXT)
1640    {
1641      if (m_bitDepthConstraint == 0 && tmpConstraintChromaFormat == 0)
1642      {
1643        // produce a valid combination, if possible.
1644      const Bool bUsingGeneralRExtTools  = m_transformSkipRotationEnabledFlag        ||
1645                                           m_transformSkipContextEnabledFlag         ||
1646                                           m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT] ||
1647                                           m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT] ||
1648          !m_enableIntraReferenceSmoothing         ||
1649                                           m_persistentRiceAdaptationEnabledFlag     ||
1650                                           m_log2MaxTransformSkipBlockSize!=2;
1651      const Bool bUsingChromaQPAdjustment= m_diffCuChromaQpOffsetDepth >= 0;
1652      const Bool bUsingExtendedPrecision = m_extendedPrecisionProcessingFlag;
1653      if (m_onePictureOnlyConstraintFlag)
1654      {
1655        m_chromaFormatConstraint = CHROMA_444;
1656        if (m_intraConstraintFlag != true)
1657        {
1658          fprintf(stderr, "Error: Intra constraint flag must be true when one_picture_only_constraint_flag is true\n");
1659          exit(EXIT_FAILURE);
1660        }
1661        const Int maxBitDepth = m_chromaFormatIDC==CHROMA_400 ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
1662        m_bitDepthConstraint = maxBitDepth>8 ? 16:8;
1663      }
1664      else
1665      {
1666        m_chromaFormatConstraint = NUM_CHROMA_FORMAT;
1667        automaticallySelectRExtProfile(bUsingGeneralRExtTools,
1668          bUsingChromaQPAdjustment,
1669          bUsingExtendedPrecision,
1670          m_intraConstraintFlag,
1671          m_bitDepthConstraint,
1672          m_chromaFormatConstraint,
1673          m_chromaFormatIDC==CHROMA_400 ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]),
1674          m_chromaFormatIDC);
1675      }
1676    }
1677      else if (m_bitDepthConstraint == 0 || tmpConstraintChromaFormat == 0)
1678      {
1679        fprintf(stderr, "Error: The bit depth and chroma format constraints must either both be specified or both be configured automatically\n");
1680        exit(EXIT_FAILURE);
1681      }
1682      else
1683      {
1684        m_chromaFormatConstraint = numberToChromaFormat(tmpConstraintChromaFormat);
1685      }
1686    }
1687    else
1688    {
1689      m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? m_chromaFormatIDC : numberToChromaFormat(tmpConstraintChromaFormat);
1690      m_bitDepthConstraint = (m_profile == Profile::MAIN10?10:8);
1691    }
1692#if NH_MV
1693  }
1694
1695  if ( m_numberOfLayers != 0 && ( m_profiles[0] != Profile::MAIN || m_profiles[1] != Profile::MAIN )  )
1696  {
1697    fprintf(stderr, "Error: The base layer must conform to the Main profile for Multilayer coding.\n");
1698    exit(EXIT_FAILURE);
1699  }
1700#endif
1701
1702
1703  m_inputColourSpaceConvert = stringToInputColourSpaceConvert(inputColourSpaceConvert, true);
1704
1705  switch (m_conformanceWindowMode)
1706  {
1707  case 0:
1708    {
1709      // no conformance or padding
1710      m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0;
1711      m_aiPad[1] = m_aiPad[0] = 0;
1712      break;
1713    }
1714  case 1:
1715    {
1716      // automatic padding to minimum CU size
1717      Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1);
1718      if (m_iSourceWidth % minCuSize)
1719      {
1720        m_aiPad[0] = m_confWinRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
1721        m_iSourceWidth  += m_confWinRight;
1722      }
1723      if (m_iSourceHeight % minCuSize)
1724      {
1725        m_aiPad[1] = m_confWinBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
1726        m_iSourceHeight += m_confWinBottom;
1727        if ( m_isField )
1728        {
1729          m_iSourceHeightOrg += m_confWinBottom << 1;
1730          m_aiPad[1] = m_confWinBottom << 1;
1731        }
1732      }
1733      if (m_aiPad[0] % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0)
1734      {
1735        fprintf(stderr, "Error: picture width is not an integer multiple of the specified chroma subsampling\n");
1736        exit(EXIT_FAILURE);
1737      }
1738      if (m_aiPad[1] % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0)
1739      {
1740        fprintf(stderr, "Error: picture height is not an integer multiple of the specified chroma subsampling\n");
1741        exit(EXIT_FAILURE);
1742      }
1743      break;
1744    }
1745  case 2:
1746    {
1747      //padding
1748      m_iSourceWidth  += m_aiPad[0];
1749      m_iSourceHeight += m_aiPad[1];
1750      m_confWinRight  = m_aiPad[0];
1751      m_confWinBottom = m_aiPad[1];
1752      break;
1753    }
1754  case 3:
1755    {
1756      // conformance
1757      if ((m_confWinLeft == 0) && (m_confWinRight == 0) && (m_confWinTop == 0) && (m_confWinBottom == 0))
1758      {
1759        fprintf(stderr, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n");
1760      }
1761      if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0))
1762      {
1763        fprintf(stderr, "Warning: Conformance window enabled, padding parameters will be ignored\n");
1764      }
1765      m_aiPad[1] = m_aiPad[0] = 0;
1766      break;
1767    }
1768  }
1769
1770  if (tmpSliceMode<0 || tmpSliceMode>=Int(NUMBER_OF_SLICE_CONSTRAINT_MODES))
1771  {
1772    fprintf(stderr, "Error: bad slice mode\n");
1773    exit(EXIT_FAILURE);
1774  }
1775  m_sliceMode = SliceConstraint(tmpSliceMode);
1776  if (tmpSliceSegmentMode<0 || tmpSliceSegmentMode>=Int(NUMBER_OF_SLICE_CONSTRAINT_MODES))
1777  {
1778    fprintf(stderr, "Error: bad slice segment mode\n");
1779    exit(EXIT_FAILURE);
1780  }
1781  m_sliceSegmentMode = SliceConstraint(tmpSliceSegmentMode);
1782
1783  if (tmpDecodedPictureHashSEIMappedType<0 || tmpDecodedPictureHashSEIMappedType>=Int(NUMBER_OF_HASHTYPES))
1784  {
1785    fprintf(stderr, "Error: bad checksum mode\n");
1786    exit(EXIT_FAILURE);
1787  }
1788  // Need to map values to match those of the SEI message:
1789  if (tmpDecodedPictureHashSEIMappedType==0)
1790  {
1791    m_decodedPictureHashSEIType=HASHTYPE_NONE;
1792  }
1793  else
1794  {
1795    m_decodedPictureHashSEIType=HashType(tmpDecodedPictureHashSEIMappedType-1);
1796  }
1797
1798  // allocate slice-based dQP values
1799#if NH_MV
1800  for (Int i = (Int)m_layerIdInNuh.size(); i < m_numberOfLayers; i++ )
1801  {
1802    m_layerIdInNuh.push_back( i == 0 ? 0 : m_layerIdInNuh[ i - 1 ] + 1 ); 
1803  }
1804  xResizeVector( m_layerIdInNuh ); 
1805
1806  xResizeVector( m_viewOrderIndex    ); 
1807
1808  std::vector<Int> uniqueViewOrderIndices; 
1809  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
1810  {   
1811    Bool isIn = false; 
1812    for ( Int i = 0 ; i < uniqueViewOrderIndices.size(); i++ )
1813    {
1814      isIn = isIn || ( m_viewOrderIndex[ layer ] == uniqueViewOrderIndices[ i ] ); 
1815    }
1816    if ( !isIn ) 
1817    {
1818      uniqueViewOrderIndices.push_back( m_viewOrderIndex[ layer ] ); 
1819    } 
1820  }
1821  m_iNumberOfViews = (Int) uniqueViewOrderIndices.size(); 
1822  xResizeVector( m_auxId );
1823
1824#if NH_3D
1825  xResizeVector( m_depthFlag ); 
1826#endif
1827  xResizeVector( m_fQP ); 
1828
1829  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
1830  {
1831    m_aidQP.push_back( new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ] );
1832    ::memset( m_aidQP[layer], 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
1833
1834    // handling of floating-point QP values
1835    // if QP is not integer, sequence is split into two sections having QP and QP+1
1836    m_iQP.push_back((Int)( m_fQP[layer] ));
1837    if ( m_iQP[layer] < m_fQP[layer] )
1838    {
1839      Int iSwitchPOC = (Int)( m_framesToBeEncoded - (m_fQP[layer] - m_iQP[layer])*m_framesToBeEncoded + 0.5 );
1840
1841      iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
1842      for ( Int i=iSwitchPOC; i<m_framesToBeEncoded + m_iGOPSize + 1; i++ )
1843      {
1844        m_aidQP[layer][i] = 1;
1845      }
1846    }
1847
1848    for(UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
1849    {
1850      if (saoOffsetBitShift[ch]<0)
1851      {
1852        if (m_internalBitDepth[ch]>10)
1853        {
1854          m_log2SaoOffsetScale[layer][ch]=UInt(Clip3<Int>(0, m_internalBitDepth[ch]-10, Int(m_internalBitDepth[ch]-10 + 0.165*m_iQP[layer] - 3.22 + 0.5) ) );
1855        }
1856        else
1857        {
1858          m_log2SaoOffsetScale[layer][ch]=0;
1859        }
1860      }
1861      else
1862      {
1863        m_log2SaoOffsetScale[layer][ch]=UInt(saoOffsetBitShift[ch]);
1864      }
1865    }
1866  }
1867
1868  xResizeVector( m_bLoopFilterDisable ); 
1869  xResizeVector( m_bUseSAO ); 
1870  xResizeVector( m_iIntraPeriod ); 
1871  xResizeVector( m_tilesInUseFlag ); 
1872  xResizeVector( m_loopFilterNotAcrossTilesFlag ); 
1873  xResizeVector( m_wppInUseFlag ); 
1874
1875  for (Int olsIdx = 0; olsIdx < m_vpsNumLayerSets + m_numAddLayerSets + (Int) m_outputLayerSetIdx.size(); olsIdx++)
1876  {   
1877    m_altOutputLayerFlag.push_back( false );     
1878  }
1879#else
1880  m_aidQP = new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ];
1881  ::memset( m_aidQP, 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
1882
1883  // handling of floating-point QP values
1884  // if QP is not integer, sequence is split into two sections having QP and QP+1
1885  m_iQP = (Int)( m_fQP );
1886  if ( m_iQP < m_fQP )
1887  {
1888    Int iSwitchPOC = (Int)( m_framesToBeEncoded - (m_fQP - m_iQP)*m_framesToBeEncoded + 0.5 );
1889
1890    iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
1891    for ( Int i=iSwitchPOC; i<m_framesToBeEncoded + m_iGOPSize + 1; i++ )
1892    {
1893      m_aidQP[i] = 1;
1894    }
1895  }
1896
1897  for(UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
1898  {
1899    if (saoOffsetBitShift[ch]<0)
1900    {
1901      if (m_internalBitDepth[ch]>10)
1902      {
1903        m_log2SaoOffsetScale[ch]=UInt(Clip3<Int>(0, m_internalBitDepth[ch]-10, Int(m_internalBitDepth[ch]-10 + 0.165*m_iQP - 3.22 + 0.5) ) );
1904      }
1905      else
1906      {
1907        m_log2SaoOffsetScale[ch]=0;
1908      }
1909    }
1910    else
1911    {
1912      m_log2SaoOffsetScale[ch]=UInt(saoOffsetBitShift[ch]);
1913    }
1914  }
1915
1916#endif
1917
1918  // reading external dQP description from file
1919  if ( !m_dQPFileName.empty() )
1920  {
1921    FILE* fpt=fopen( m_dQPFileName.c_str(), "r" );
1922    if ( fpt )
1923    {
1924#if NH_MV
1925      for( Int layer = 0; layer < m_numberOfLayers; layer++ )
1926      {
1927#endif
1928      Int iValue;
1929      Int iPOC = 0;
1930      while ( iPOC < m_framesToBeEncoded )
1931      {
1932        if ( fscanf(fpt, "%d", &iValue ) == EOF )
1933        {
1934          break;
1935        }
1936#if NH_MV
1937        m_aidQP[layer][ iPOC ] = iValue;
1938        iPOC++;
1939      }
1940#else
1941        m_aidQP[ iPOC ] = iValue;
1942        iPOC++;
1943#endif
1944      }
1945      fclose(fpt);
1946    }
1947  }
1948
1949#if NH_MV_SEI
1950  xParseSeiCfg(); 
1951#endif
1952  if( m_masteringDisplay.colourVolumeSEIEnabled )
1953  {
1954    for(UInt idx=0; idx<6; idx++)
1955    {
1956      m_masteringDisplay.primaries[idx/2][idx%2] = UShort((cfg_DisplayPrimariesCode.values.size() > idx) ? cfg_DisplayPrimariesCode.values[idx] : 0);
1957    }
1958    for(UInt idx=0; idx<2; idx++)
1959    {
1960      m_masteringDisplay.whitePoint[idx] = UShort((cfg_DisplayWhitePointCode.values.size() > idx) ? cfg_DisplayWhitePointCode.values[idx] : 0);
1961    }
1962  }
1963   
1964  if( m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag )
1965  {
1966    if( m_toneMapModelId == 2 && !cfg_startOfCodedInterval.values.empty() )
1967    {
1968      const UInt num = 1u<< m_toneMapTargetBitDepth;
1969      m_startOfCodedInterval = new Int[num];
1970      for(UInt i=0; i<num; i++)
1971      {
1972        m_startOfCodedInterval[i] = cfg_startOfCodedInterval.values.size() > i ? cfg_startOfCodedInterval.values[i] : 0;
1973      }
1974    }
1975    else
1976    {
1977      m_startOfCodedInterval = NULL;
1978    }
1979    if( ( m_toneMapModelId == 3 ) && ( m_numPivots > 0 ) )
1980    {
1981      if( !cfg_codedPivotValue.values.empty() && !cfg_targetPivotValue.values.empty() )
1982      {
1983        m_codedPivotValue  = new Int[m_numPivots];
1984        m_targetPivotValue = new Int[m_numPivots];
1985        for(UInt i=0; i<m_numPivots; i++)
1986        {
1987          m_codedPivotValue[i]  = cfg_codedPivotValue.values.size()  > i ? cfg_codedPivotValue.values [i] : 0;
1988          m_targetPivotValue[i] = cfg_targetPivotValue.values.size() > i ? cfg_targetPivotValue.values[i] : 0;
1989        }
1990      }
1991    }
1992    else
1993    {
1994      m_codedPivotValue = NULL;
1995      m_targetPivotValue = NULL;
1996    }
1997  }
1998
1999  if( m_kneeSEIEnabled && !m_kneeSEICancelFlag )
2000  {
2001    assert ( m_kneeSEINumKneePointsMinus1 >= 0 && m_kneeSEINumKneePointsMinus1 < 999 );
2002    m_kneeSEIInputKneePoint  = new Int[m_kneeSEINumKneePointsMinus1+1];
2003    m_kneeSEIOutputKneePoint = new Int[m_kneeSEINumKneePointsMinus1+1];
2004    for(Int i=0; i<(m_kneeSEINumKneePointsMinus1+1); i++)
2005    {
2006      m_kneeSEIInputKneePoint[i]  = cfg_kneeSEIInputKneePointValue.values.size()  > i ? cfg_kneeSEIInputKneePointValue.values[i]  : 1;
2007      m_kneeSEIOutputKneePoint[i] = cfg_kneeSEIOutputKneePointValue.values.size() > i ? cfg_kneeSEIOutputKneePointValue.values[i] : 0;
2008    }
2009  }
2010
2011  if(m_timeCodeSEIEnabled)
2012  {
2013    for(Int i = 0; i < m_timeCodeSEINumTs && i < MAX_TIMECODE_SEI_SETS; i++)
2014    {
2015      m_timeSetArray[i].clockTimeStampFlag    = cfg_timeCodeSeiTimeStampFlag        .values.size()>i ? cfg_timeCodeSeiTimeStampFlag        .values [i] : false;
2016      m_timeSetArray[i].numUnitFieldBasedFlag = cfg_timeCodeSeiNumUnitFieldBasedFlag.values.size()>i ? cfg_timeCodeSeiNumUnitFieldBasedFlag.values [i] : 0;
2017      m_timeSetArray[i].countingType          = cfg_timeCodeSeiCountingType         .values.size()>i ? cfg_timeCodeSeiCountingType         .values [i] : 0;
2018      m_timeSetArray[i].fullTimeStampFlag     = cfg_timeCodeSeiFullTimeStampFlag    .values.size()>i ? cfg_timeCodeSeiFullTimeStampFlag    .values [i] : 0;
2019      m_timeSetArray[i].discontinuityFlag     = cfg_timeCodeSeiDiscontinuityFlag    .values.size()>i ? cfg_timeCodeSeiDiscontinuityFlag    .values [i] : 0;
2020      m_timeSetArray[i].cntDroppedFlag        = cfg_timeCodeSeiCntDroppedFlag       .values.size()>i ? cfg_timeCodeSeiCntDroppedFlag       .values [i] : 0;
2021      m_timeSetArray[i].numberOfFrames        = cfg_timeCodeSeiNumberOfFrames       .values.size()>i ? cfg_timeCodeSeiNumberOfFrames       .values [i] : 0;
2022      m_timeSetArray[i].secondsValue          = cfg_timeCodeSeiSecondsValue         .values.size()>i ? cfg_timeCodeSeiSecondsValue         .values [i] : 0;
2023      m_timeSetArray[i].minutesValue          = cfg_timeCodeSeiMinutesValue         .values.size()>i ? cfg_timeCodeSeiMinutesValue         .values [i] : 0;
2024      m_timeSetArray[i].hoursValue            = cfg_timeCodeSeiHoursValue           .values.size()>i ? cfg_timeCodeSeiHoursValue           .values [i] : 0;
2025      m_timeSetArray[i].secondsFlag           = cfg_timeCodeSeiSecondsFlag          .values.size()>i ? cfg_timeCodeSeiSecondsFlag          .values [i] : 0;
2026      m_timeSetArray[i].minutesFlag           = cfg_timeCodeSeiMinutesFlag          .values.size()>i ? cfg_timeCodeSeiMinutesFlag          .values [i] : 0;
2027      m_timeSetArray[i].hoursFlag             = cfg_timeCodeSeiHoursFlag            .values.size()>i ? cfg_timeCodeSeiHoursFlag            .values [i] : 0;
2028      m_timeSetArray[i].timeOffsetLength      = cfg_timeCodeSeiTimeOffsetLength     .values.size()>i ? cfg_timeCodeSeiTimeOffsetLength     .values [i] : 0;
2029      m_timeSetArray[i].timeOffsetValue       = cfg_timeCodeSeiTimeOffsetValue      .values.size()>i ? cfg_timeCodeSeiTimeOffsetValue      .values [i] : 0;
2030    }
2031  }
2032
2033#if NH_3D
2034#if NH_3D_VSO
2035  // Table base optimization
2036  // Q&D
2037  Double adLambdaScaleTable[] = 
2038  {  0.031250, 0.031639, 0.032029, 0.032418, 0.032808, 0.033197, 0.033586, 0.033976, 0.034365, 0.034755, 
2039  0.035144, 0.035533, 0.035923, 0.036312, 0.036702, 0.037091, 0.037480, 0.037870, 0.038259, 0.038648, 
2040  0.039038, 0.039427, 0.039817, 0.040206, 0.040595, 0.040985, 0.041374, 0.041764, 0.042153, 0.042542, 
2041  0.042932, 0.043321, 0.043711, 0.044100, 0.044194, 0.053033, 0.061872, 0.070711, 0.079550, 0.088388, 
2042  0.117851, 0.147314, 0.176777, 0.235702, 0.294628, 0.353553, 0.471405, 0.589256, 0.707107, 0.707100, 
2043  0.753550, 0.800000 
2044  }; 
2045  if ( m_bUseVSO && m_bVSOLSTable )
2046  {
2047    Int firstDepthLayer = -1; 
2048    for (Int layer = 0; layer < m_numberOfLayers; layer++ )
2049    {
2050      if ( m_depthFlag[ layer ])
2051      {
2052        firstDepthLayer = layer;
2053        break; 
2054      }
2055    }
2056    AOT( firstDepthLayer == -1 );
2057    AOT( (m_iQP[firstDepthLayer] < 0) || (m_iQP[firstDepthLayer] > 51));
2058    m_dLambdaScaleVSO *= adLambdaScaleTable[m_iQP[firstDepthLayer]]; 
2059  }
2060  if ( m_bUseVSO && m_uiVSOMode == 4)
2061  {
2062    m_cRenModStrParser.setString( m_iNumberOfViews, m_pchVSOConfig );
2063    m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
2064      m_internalBitDepth[ CHANNEL_TYPE_LUMA],
2065      (UInt)m_iCodedCamParPrecision,
2066      m_FrameSkip,
2067      (UInt)m_framesToBeEncoded,
2068      m_pchCameraParameterFile,
2069      m_pchBaseViewCameraNumbers,
2070      NULL,
2071      m_cRenModStrParser.getSynthViews(),
2072      LOG2_DISP_PREC_LUT );
2073  }
2074  else if ( m_bUseVSO && m_uiVSOMode != 4 )
2075  {
2076    m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
2077      m_internalBitDepth[ CHANNEL_TYPE_LUMA],
2078      (UInt)m_iCodedCamParPrecision,
2079      m_FrameSkip,
2080      (UInt)m_framesToBeEncoded,
2081      m_pchCameraParameterFile,
2082      m_pchBaseViewCameraNumbers,
2083      m_pchVSOConfig,
2084      NULL,
2085      LOG2_DISP_PREC_LUT );
2086  }
2087  else
2088  {
2089    m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
2090      m_internalBitDepth[ CHANNEL_TYPE_LUMA],
2091      (UInt) m_iCodedCamParPrecision,
2092      m_FrameSkip,
2093      (UInt) m_framesToBeEncoded,
2094      m_pchCameraParameterFile,
2095      m_pchBaseViewCameraNumbers,
2096      NULL,
2097      NULL,
2098      LOG2_DISP_PREC_LUT );
2099  }
2100#else
2101  m_cCameraData     .init     ( ((UInt) m_iNumberOfViews ), 
2102    m_internalBitDepth[ CHANNEL_TYPE_LUMA],
2103    (UInt) m_iCodedCamParPrecision,
2104    m_FrameSkip,
2105    (UInt) m_framesToBeEncoded,
2106    m_pchCameraParameterFile,
2107    m_pchBaseViewCameraNumbers,
2108    NULL,
2109    NULL,
2110    LOG2_DISP_PREC_LUT );
2111#endif
2112  m_cCameraData.check( false, true );
2113#endif
2114
2115  // check validity of input parameters
2116  xCheckParameter();
2117
2118  // compute actual CU depth with respect to config depth and max transform size
2119  UInt uiAddCUDepth  = 0;
2120  while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + uiAddCUDepth )  ) )
2121  {
2122    uiAddCUDepth++;
2123  }
2124
2125  m_uiMaxTotalCUDepth = m_uiMaxCUDepth + uiAddCUDepth + getMaxCUDepthOffset(m_chromaFormatIDC, m_uiQuadtreeTULog2MinSize); // if minimum TU larger than 4x4, allow for additional part indices for 4:2:2 SubTUs.
2126  m_uiLog2DiffMaxMinCodingBlockSize = m_uiMaxCUDepth - 1;
2127
2128  // print-out parameters
2129  xPrintParameter();
2130
2131  return true;
2132}
2133
2134
2135// ====================================================================================================================
2136// Private member functions
2137// ====================================================================================================================
2138
2139Void TAppEncCfg::xCheckParameter()
2140{
2141  if (m_decodedPictureHashSEIType==HASHTYPE_NONE)
2142  {
2143    fprintf(stderr, "******************************************************************\n");
2144    fprintf(stderr, "** WARNING: --SEIDecodedPictureHash is now disabled by default. **\n");
2145    fprintf(stderr, "**          Automatic verification of decoded pictures by a     **\n");
2146    fprintf(stderr, "**          decoder requires this option to be enabled.         **\n");
2147    fprintf(stderr, "******************************************************************\n");
2148  }
2149
2150
2151#if !NH_MV
2152  if( m_profile==Profile::NONE )
2153  {
2154    fprintf(stderr, "***************************************************************************\n");
2155    fprintf(stderr, "** WARNING: For conforming bitstreams a valid Profile value must be set! **\n");
2156    fprintf(stderr, "***************************************************************************\n");
2157  }
2158  if( m_level==Level::NONE )
2159  {
2160    fprintf(stderr, "***************************************************************************\n");
2161    fprintf(stderr, "** WARNING: For conforming bitstreams a valid Level value must be set!   **\n");
2162    fprintf(stderr, "***************************************************************************\n");
2163  }
2164#endif
2165
2166  Bool check_failed = false; /* abort if there is a fatal configuration problem */
2167#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
2168
2169  xConfirmPara(m_bitstreamFileName.empty(), "A bitstream file name must be specified (BitstreamFile)");
2170  const UInt maxBitDepth=(m_chromaFormatIDC==CHROMA_400) ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
2171  xConfirmPara(m_bitDepthConstraint<maxBitDepth, "The internalBitDepth must not be greater than the bitDepthConstraint value");
2172  xConfirmPara(m_chromaFormatConstraint<m_chromaFormatIDC, "The chroma format used must not be greater than the chromaFormatConstraint value");
2173#if NH_MV
2174  Profile::Name & m_profile = m_profiles[0];
2175#endif
2176
2177  if (m_profile==Profile::MAINREXT || m_profile==Profile::HIGHTHROUGHPUTREXT)
2178  {
2179    xConfirmPara(m_lowerBitRateConstraintFlag==false && m_intraConstraintFlag==false, "The lowerBitRateConstraint flag cannot be false when intraConstraintFlag is false");
2180    xConfirmPara(m_cabacBypassAlignmentEnabledFlag && m_profile!=Profile::HIGHTHROUGHPUTREXT, "AlignCABACBeforeBypass must not be enabled unless the high throughput profile is being used.");
2181    if (m_profile == Profile::MAINREXT)
2182    {
2183      const UInt intraIdx = m_intraConstraintFlag ? 1:0;
2184      const UInt bitDepthIdx = (m_bitDepthConstraint == 8 ? 0 : (m_bitDepthConstraint ==10 ? 1 : (m_bitDepthConstraint == 12 ? 2 : (m_bitDepthConstraint == 16 ? 3 : 4 ))));
2185      const UInt chromaFormatIdx = UInt(m_chromaFormatConstraint);
2186      const Bool bValidProfile = (bitDepthIdx > 3 || chromaFormatIdx>3) ? false : (validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx] != NONE);
2187      xConfirmPara(!bValidProfile, "Invalid intra constraint flag, bit depth constraint flag and chroma format constraint flag combination for a RExt profile");
2188      const Bool bUsingGeneralRExtTools  = m_transformSkipRotationEnabledFlag        ||
2189                                           m_transformSkipContextEnabledFlag         ||
2190                                           m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT] ||
2191                                           m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT] ||
2192                                           !m_enableIntraReferenceSmoothing         ||
2193                                           m_persistentRiceAdaptationEnabledFlag     ||
2194                                           m_log2MaxTransformSkipBlockSize!=2;
2195      const Bool bUsingChromaQPTool      = m_diffCuChromaQpOffsetDepth >= 0;
2196      const Bool bUsingExtendedPrecision = m_extendedPrecisionProcessingFlag;
2197
2198      xConfirmPara((m_chromaFormatConstraint==CHROMA_420 || m_chromaFormatConstraint==CHROMA_400) && bUsingChromaQPTool, "CU Chroma QP adjustment cannot be used for 4:0:0 or 4:2:0 RExt profiles");
2199      xConfirmPara(m_bitDepthConstraint != 16 && bUsingExtendedPrecision, "Extended precision can only be used in 16-bit RExt profiles");
2200      if (!(m_chromaFormatConstraint == CHROMA_400 && m_bitDepthConstraint == 16) && m_chromaFormatConstraint!=CHROMA_444)
2201      {
2202        xConfirmPara(bUsingGeneralRExtTools, "Combination of tools and profiles are not possible in the specified RExt profile.");
2203      }
2204      xConfirmPara( m_onePictureOnlyConstraintFlag && m_chromaFormatConstraint!=CHROMA_444, "chroma format constraint must be 4:4:4 when one-picture-only constraint flag is 1");
2205      xConfirmPara( m_onePictureOnlyConstraintFlag && m_bitDepthConstraint != 8 && m_bitDepthConstraint != 16, "bit depth constraint must be 8 or 16 when one-picture-only constraint flag is 1");
2206      xConfirmPara( m_onePictureOnlyConstraintFlag && m_framesToBeEncoded > 1, "Number of frames to be encoded must be 1 when one-picture-only constraint flag is 1.");
2207
2208      if (!m_intraConstraintFlag && m_bitDepthConstraint==16 && m_chromaFormatConstraint==CHROMA_444)
2209      {
2210        fprintf(stderr, "********************************************************************************************************\n");
2211        fprintf(stderr, "** WARNING: The RExt constraint flags describe a non standard combination (used for development only) **\n");
2212        fprintf(stderr, "********************************************************************************************************\n");
2213      }
2214    }
2215    else
2216    {
2217      xConfirmPara( m_chromaFormatConstraint != CHROMA_444, "chroma format constraint must be 4:4:4 in the High Throughput 4:4:4 16-bit Intra profile.");
2218      xConfirmPara( m_bitDepthConstraint     != 16,         "bit depth constraint must be 4:4:4 in the High Throughput 4:4:4 16-bit Intra profile.");
2219      xConfirmPara( m_intraConstraintFlag    != 1,          "intra constraint flag must be 1 in the High Throughput 4:4:4 16-bit Intra profile.");
2220    }
2221  }
2222  else
2223  {
2224    xConfirmPara(m_bitDepthConstraint!=((m_profile==Profile::MAIN10)?10:8), "BitDepthConstraint must be 8 for MAIN profile and 10 for MAIN10 profile.");
2225    xConfirmPara(m_chromaFormatConstraint!=CHROMA_420, "ChromaFormatConstraint must be 420 for non main-RExt profiles.");
2226    xConfirmPara(m_intraConstraintFlag==true, "IntraConstraintFlag must be false for non main_RExt profiles.");
2227    xConfirmPara(m_lowerBitRateConstraintFlag==false, "LowerBitrateConstraintFlag must be true for non main-RExt profiles.");
2228    xConfirmPara(m_profile == Profile::MAINSTILLPICTURE && m_framesToBeEncoded > 1, "Number of frames to be encoded must be 1 when main still picture profile is used.");
2229
2230    xConfirmPara(m_crossComponentPredictionEnabledFlag==true, "CrossComponentPrediction must not be used for non main-RExt profiles.");
2231    xConfirmPara(m_log2MaxTransformSkipBlockSize!=2, "Transform Skip Log2 Max Size must be 2 for V1 profiles.");
2232    xConfirmPara(m_transformSkipRotationEnabledFlag==true, "UseResidualRotation must not be enabled for non main-RExt profiles.");
2233    xConfirmPara(m_transformSkipContextEnabledFlag==true, "UseSingleSignificanceMapContext must not be enabled for non main-RExt profiles.");
2234    xConfirmPara(m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT]==true, "ImplicitResidualDPCM must not be enabled for non main-RExt profiles.");
2235    xConfirmPara(m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT]==true, "ExplicitResidualDPCM must not be enabled for non main-RExt profiles.");
2236    xConfirmPara(m_persistentRiceAdaptationEnabledFlag==true, "GolombRiceParameterAdaption must not be enabled for non main-RExt profiles.");
2237    xConfirmPara(m_extendedPrecisionProcessingFlag==true, "UseExtendedPrecision must not be enabled for non main-RExt profiles.");
2238    xConfirmPara(m_highPrecisionOffsetsEnabledFlag==true, "UseHighPrecisionPredictionWeighting must not be enabled for non main-RExt profiles.");
2239    xConfirmPara(m_enableIntraReferenceSmoothing==false, "EnableIntraReferenceSmoothing must be enabled for non main-RExt profiles.");
2240    xConfirmPara(m_cabacBypassAlignmentEnabledFlag, "AlignCABACBeforeBypass cannot be enabled for non main-RExt profiles.");
2241  }
2242
2243  // check range of parameters
2244  xConfirmPara( m_inputBitDepth[CHANNEL_TYPE_LUMA  ] < 8,                                   "InputBitDepth must be at least 8" );
2245  xConfirmPara( m_inputBitDepth[CHANNEL_TYPE_CHROMA] < 8,                                   "InputBitDepthC must be at least 8" );
2246
2247#if !RExt__HIGH_BIT_DEPTH_SUPPORT
2248  if (m_extendedPrecisionProcessingFlag)
2249  {
2250    for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
2251    {
2252      xConfirmPara((m_internalBitDepth[channelType] > 8) , "Model is not configured to support high enough internal accuracies - enable RExt__HIGH_BIT_DEPTH_SUPPORT to use increased precision internal data types etc...");
2253    }
2254  }
2255  else
2256  {
2257    for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
2258    {
2259      xConfirmPara((m_internalBitDepth[channelType] > 12) , "Model is not configured to support high enough internal accuracies - enable RExt__HIGH_BIT_DEPTH_SUPPORT to use increased precision internal data types etc...");
2260    }
2261  }
2262#endif
2263
2264  xConfirmPara( (m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] < m_inputBitDepth[CHANNEL_TYPE_LUMA  ]), "MSB-extended bit depth for luma channel (--MSBExtendedBitDepth) must be greater than or equal to input bit depth for luma channel (--InputBitDepth)" );
2265  xConfirmPara( (m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] < m_inputBitDepth[CHANNEL_TYPE_CHROMA]), "MSB-extended bit depth for chroma channel (--MSBExtendedBitDepthC) must be greater than or equal to input bit depth for chroma channel (--InputBitDepthC)" );
2266
2267#if NH_MV
2268  for (Int i = 0; i < m_numberOfLayers; i++)
2269  {
2270    xConfirmPara( m_log2SaoOffsetScale[i][CHANNEL_TYPE_LUMA]   > (m_internalBitDepth[CHANNEL_TYPE_LUMA  ]<10?0:(m_internalBitDepth[CHANNEL_TYPE_LUMA  ]-10)), "SaoLumaOffsetBitShift must be in the range of 0 to InternalBitDepth-10, inclusive");
2271    xConfirmPara( m_log2SaoOffsetScale[i][CHANNEL_TYPE_CHROMA] > (m_internalBitDepth[CHANNEL_TYPE_CHROMA]<10?0:(m_internalBitDepth[CHANNEL_TYPE_CHROMA]-10)), "SaoChromaOffsetBitShift must be in the range of 0 to InternalBitDepthC-10, inclusive");
2272  }
2273#else
2274  xConfirmPara( m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA]   > (m_internalBitDepth[CHANNEL_TYPE_LUMA  ]<10?0:(m_internalBitDepth[CHANNEL_TYPE_LUMA  ]-10)), "SaoLumaOffsetBitShift must be in the range of 0 to InternalBitDepth-10, inclusive");
2275  xConfirmPara( m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] > (m_internalBitDepth[CHANNEL_TYPE_CHROMA]<10?0:(m_internalBitDepth[CHANNEL_TYPE_CHROMA]-10)), "SaoChromaOffsetBitShift must be in the range of 0 to InternalBitDepthC-10, inclusive");
2276#endif
2277
2278  xConfirmPara( m_chromaFormatIDC >= NUM_CHROMA_FORMAT,                                     "ChromaFormatIDC must be either 400, 420, 422 or 444" );
2279  std::string sTempIPCSC="InputColourSpaceConvert must be empty, "+getListOfColourSpaceConverts(true);
2280  xConfirmPara( m_inputColourSpaceConvert >= NUMBER_INPUT_COLOUR_SPACE_CONVERSIONS,         sTempIPCSC.c_str() );
2281  xConfirmPara( m_InputChromaFormatIDC >= NUM_CHROMA_FORMAT,                                "InputChromaFormatIDC must be either 400, 420, 422 or 444" );
2282  xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
2283  xConfirmPara( m_framesToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 0" );
2284#if NH_MV
2285  xConfirmPara( m_numberOfLayers > MAX_NUM_LAYER_IDS ,                                      "NumberOfLayers must be less than or equal to MAX_NUM_LAYER_IDS");
2286
2287
2288  xConfirmPara( m_layerIdInNuh[0] != 0      , "LayerIdInNuh must be 0 for the first layer. ");
2289  xConfirmPara( (m_layerIdInNuh.size()!=1) && (m_layerIdInNuh.size() < m_numberOfLayers) , "LayerIdInNuh must be given for all layers. ");
2290
2291#if NH_3D
2292  xConfirmPara( m_scalabilityMask != 2 && m_scalabilityMask != 3, "Scalability Mask must be equal to 2 or 3. ");
2293#else
2294  xConfirmPara( m_scalabilityMask != 2 && m_scalabilityMask != 8 && m_scalabilityMask != 10, "Scalability Mask must be equal to 2, 8 or 10");
2295#endif
2296
2297#if NH_3D
2298  if ( m_scalabilityMask & ( 1 << DEPTH_ID ) )
2299  {
2300    m_dimIds.push_back( m_depthFlag ); 
2301  }
2302#endif
2303
2304  m_dimIds.push_back( m_viewOrderIndex );   
2305  for (Int i = 0; i < m_auxId.size(); i++)
2306  {
2307    xConfirmPara( !( ( m_auxId[i] >= 0 && m_auxId[i] <= 2 ) || ( m_auxId[i] >= 128 && m_auxId[i] <= 159 ) ) , "AuxId shall be in the range of 0 to 2, inclusive, or 128 to 159, inclusive");
2308  }
2309  if ( m_scalabilityMask & ( 1 << AUX_ID ) )
2310  {
2311    m_dimIds.push_back ( m_auxId );
2312  }
2313  xConfirmPara(  m_dimensionIdLen.size() < m_dimIds.size(), "DimensionIdLen must be given for all dimensions. "   );
2314  Int dimBitOffset[MAX_NUM_SCALABILITY_TYPES+1]; 
2315
2316  dimBitOffset[ 0 ] = 0; 
2317  for (Int j = 1; j <= (((Int) m_dimIds.size() - m_splittingFlag) ? 1 : 0); j++ )
2318  {
2319    dimBitOffset[ j ] = dimBitOffset[ j - 1 ] + m_dimensionIdLen[ j - 1]; 
2320  }
2321
2322  if ( m_splittingFlag )
2323  {
2324    dimBitOffset[ (Int) m_dimIds.size() ] = 6; 
2325  }
2326
2327  for( Int j = 0; j < m_dimIds.size(); j++ )
2328  {   
2329    xConfirmPara( m_dimIds[j].size() < m_numberOfLayers,  "DimensionId must be given for all layers and all dimensions. ");   
2330    xConfirmPara( (m_dimIds[j][0] != 0)                 , "DimensionId of layer 0 must be 0. " );
2331    xConfirmPara( m_dimensionIdLen[j] < 1 || m_dimensionIdLen[j] > 8, "DimensionIdLen must be greater than 0 and less than 9 in all dimensions. " ); 
2332
2333
2334    for( Int i = 1; i < m_numberOfLayers; i++ )
2335    {     
2336      xConfirmPara(  ( m_dimIds[j][i] < 0 ) || ( m_dimIds[j][i] > ( ( 1 << m_dimensionIdLen[j] ) - 1 ) )   , "DimensionId shall be in the range of 0 to 2^DimensionIdLen - 1. " );
2337      if ( m_splittingFlag )
2338      {
2339        Int layerIdInNuh = (m_layerIdInNuh.size()!=1) ? m_layerIdInNuh[i] :  i; 
2340        xConfirmPara( ( ( layerIdInNuh & ( (1 << dimBitOffset[ j + 1 ] ) - 1) ) >> dimBitOffset[ j ] )  != m_dimIds[j][ i ]  , "When Splitting Flag is equal to 1 dimension ids shall match values derived from layer ids. "); 
2341      }
2342    }
2343  }
2344
2345  for( Int i = 0; i < m_numberOfLayers; i++ )
2346  {
2347    for( Int j = 0; j < i; j++ )
2348    {     
2349      Int numDiff  = 0; 
2350      Int lastDiff = -1; 
2351      for( Int dim = 0; dim < m_dimIds.size(); dim++ )
2352      {
2353        if ( m_dimIds[dim][i] != m_dimIds[dim][j] )
2354        {
2355          numDiff ++; 
2356          lastDiff = dim; 
2357        }
2358      }
2359
2360      Bool allEqual = ( numDiff == 0 ); 
2361
2362      if ( allEqual ) 
2363      {
2364        printf( "\nError: Positions of Layers %d and %d are identical in scalability space\n", i, j);
2365      }
2366
2367      xConfirmPara( allEqual , "Each layer shall have a different position in scalability space." );
2368
2369#if !H_3D_FCO
2370      if ( numDiff  == 1 ) 
2371      {
2372        Bool inc = m_dimIds[ lastDiff ][ i ] > m_dimIds[ lastDiff ][ j ]; 
2373        Bool shallBeButIsNotIncreasing = ( !inc  ) ; 
2374        if ( shallBeButIsNotIncreasing )
2375        {       
2376          printf( "\nError: Positions of Layers %d and %d is not increasing in dimension %d \n", i, j, lastDiff);       
2377        }
2378        xConfirmPara( shallBeButIsNotIncreasing,  "DimensionIds shall be increasing within one dimension. " );
2379      }
2380#endif
2381    }
2382  }
2383
2384  /// ViewId
2385  xConfirmPara( m_viewId.size() != m_iNumberOfViews, "The number of ViewIds must be equal to the number of views." ); 
2386
2387  /// Layer sets
2388  xConfirmPara( m_vpsNumLayerSets < 0 || m_vpsNumLayerSets > 1024, "VpsNumLayerSets must be greater than 0 and less than 1025. ") ; 
2389  for( Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ )
2390  {
2391    if (lsIdx == 0)
2392    {
2393      xConfirmPara( m_layerIdsInSets[lsIdx].size() != 1 || m_layerIdsInSets[lsIdx][0] != 0 , "0-th layer shall only include layer 0. ");
2394    }
2395    for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++ )
2396    {
2397      xConfirmPara( m_layerIdsInSets[lsIdx][i] < 0 || m_layerIdsInSets[lsIdx][i] >= MAX_NUM_LAYER_IDS, "LayerIdsInSet must be greater than 0 and less than MAX_NUM_LAYER_IDS" ); 
2398    }
2399  }
2400
2401  // Output layer sets
2402  xConfirmPara( m_outputLayerSetIdx.size() > 1024, "The number of output layer set indices must be less than 1025.") ;
2403  for (Int lsIdx = 0; lsIdx < m_outputLayerSetIdx.size(); lsIdx++)
2404  {   
2405    Int refLayerSetIdx = m_outputLayerSetIdx[ lsIdx ]; 
2406    xConfirmPara(  refLayerSetIdx < 0 || refLayerSetIdx >= m_vpsNumLayerSets + m_numAddLayerSets, "Output layer set idx must be greater or equal to 0 and less than the VpsNumLayerSets plus NumAddLayerSets." );
2407  }
2408
2409  xConfirmPara( m_defaultOutputLayerIdc < 0 || m_defaultOutputLayerIdc > 2, "Default target output layer idc must greater than or equal to 0 and less than or equal to 2." ); 
2410
2411  if( m_defaultOutputLayerIdc != 2 )
2412  {
2413    Bool anyDefaultOutputFlag = false;   
2414    for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++)
2415    { 
2416      anyDefaultOutputFlag = anyDefaultOutputFlag || ( m_layerIdsInDefOutputLayerSet[lsIdx].size() != 0 );
2417    }   
2418    if ( anyDefaultOutputFlag )
2419    {   
2420      printf( "\nWarning: Ignoring LayerIdsInDefOutputLayerSet parameters, since defaultTargetOuputLayerIdc is not equal 2.\n" );   
2421    }
2422  }
2423  else 
2424  { 
2425    for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++)
2426    { 
2427      for (Int i = 0; i < m_layerIdsInDefOutputLayerSet[ lsIdx ].size(); i++)
2428      {
2429        Bool inLayerSetFlag = false; 
2430        for (Int j = 0; j < m_layerIdsInSets[ lsIdx].size(); j++ )
2431        {
2432          if ( m_layerIdsInSets[ lsIdx ][ j ] == m_layerIdsInDefOutputLayerSet[ lsIdx ][ i ] )
2433          {
2434            inLayerSetFlag = true; 
2435            break; 
2436          }       
2437        }
2438        xConfirmPara( !inLayerSetFlag, "All output layers of a output layer set must be included in corresponding layer set.");
2439      }
2440    }
2441  }
2442
2443  xConfirmPara( m_altOutputLayerFlag.size() < m_vpsNumLayerSets + m_numAddLayerSets + m_outputLayerSetIdx.size(), "The number of alt output layer flags must be equal to the number of layer set additional output layer sets plus the number of output layer set indices" );
2444
2445  // PTL
2446  xConfirmPara( ( m_profiles.size() != m_inblFlag.size() || m_profiles.size() != m_level.size()  ||  m_profiles.size() != m_levelTier.size() ), "The number of Profiles, Levels, Tiers and InblFlags must be equal." ); 
2447
2448  if ( m_numberOfLayers > 1)
2449  {
2450    xConfirmPara( m_profiles.size() <= 1, "The number of profiles, tiers, levels, and inblFlags must be greater than 1.");
2451    xConfirmPara( m_inblFlag[0], "VpsProfileTierLevel[0] must have inblFlag equal to 0");
2452    if (m_profiles.size() > 1 )
2453    {
2454      xConfirmPara( m_profiles[0]  != m_profiles[1], "The profile in VpsProfileTierLevel[1] must be equal to the profile in VpsProfileTierLevel[0].");
2455      xConfirmPara( m_inblFlag[0] != m_inblFlag[1], "inblFlag in VpsProfileTierLevel[1] must be equal to the inblFlag in VpsProfileTierLevel[0].");
2456    }
2457  }
2458
2459  // Layer Dependencies 
2460  for (Int i = 0; i < m_numberOfLayers; i++ )
2461  {
2462    xConfirmPara( (i == 0)  && m_directRefLayers[0].size() != 0, "Layer 0 shall not have reference layers." ); 
2463    xConfirmPara( m_directRefLayers[i].size() != m_dependencyTypes[ i ].size(), "Each reference layer shall have a reference type." ); 
2464    for (Int j = 0; j < m_directRefLayers[i].size(); j++)
2465    {
2466      xConfirmPara( m_directRefLayers[i][j] < 0 || m_directRefLayers[i][j] >= i , "Reference layer id shall be greater than or equal to 0 and less than dependent layer id"); 
2467      xConfirmPara( m_dependencyTypes[i][j] < 0 || m_dependencyTypes[i][j] >  6 , "Dependency type shall be greater than or equal to 0 and less than 7");
2468    }       
2469  } 
2470#endif
2471
2472  xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
2473  xConfirmPara( m_iGOPSize > 1 &&  m_iGOPSize % 2,                                          "GOP Size must be a multiple of 2, if GOP Size is greater than 1" );
2474#if NH_MV
2475  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
2476  {
2477    xConfirmPara( (m_iIntraPeriod[layer] > 0 && m_iIntraPeriod[layer] < m_iGOPSize) || m_iIntraPeriod[layer] == 0, "Intra period must be more than GOP size, or -1 , not 0" );
2478  }
2479#else
2480  xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
2481#endif
2482  xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 3,                   "Decoding Refresh Type must be comprised between 0 and 3 included" );
2483  if(m_iDecodingRefreshType == 3)
2484  {
2485    xConfirmPara( !m_recoveryPointSEIEnabled,                                               "When using RecoveryPointSEI messages as RA points, recoveryPointSEI must be enabled" );
2486  }
2487
2488  if (m_isField)
2489  {
2490    if (!m_pictureTimingSEIEnabled)
2491    {
2492      fprintf(stderr, "****************************************************************************\n");
2493      fprintf(stderr, "** WARNING: Picture Timing SEI should be enabled for field coding!        **\n");
2494      fprintf(stderr, "****************************************************************************\n");
2495    }
2496  }
2497
2498  if(m_crossComponentPredictionEnabledFlag && (m_chromaFormatIDC != CHROMA_444))
2499  {
2500    fprintf(stderr, "****************************************************************************\n");
2501    fprintf(stderr, "** WARNING: Cross-component prediction is specified for 4:4:4 format only **\n");
2502    fprintf(stderr, "****************************************************************************\n");
2503
2504    m_crossComponentPredictionEnabledFlag = false;
2505  }
2506
2507  if ( m_CUTransquantBypassFlagForce && m_bUseHADME )
2508  {
2509    fprintf(stderr, "****************************************************************************\n");
2510    fprintf(stderr, "** WARNING: --HadamardME has been disabled due to the enabling of         **\n");
2511    fprintf(stderr, "**          --CUTransquantBypassFlagForce                                 **\n");
2512    fprintf(stderr, "****************************************************************************\n");
2513
2514    m_bUseHADME = false; // this has been disabled so that the lambda is calculated slightly differently for lossless modes (as a result of JCTVC-R0104).
2515  }
2516
2517  xConfirmPara (m_log2MaxTransformSkipBlockSize < 2, "Transform Skip Log2 Max Size must be at least 2 (4x4)");
2518
2519  if (m_log2MaxTransformSkipBlockSize!=2 && m_useTransformSkipFast)
2520  {
2521    fprintf(stderr, "***************************************************************************\n");
2522    fprintf(stderr, "** WARNING: Transform skip fast is enabled (which only tests NxN splits),**\n");
2523    fprintf(stderr, "**          but transform skip log2 max size is not 2 (4x4)              **\n");
2524    fprintf(stderr, "**          It may be better to disable transform skip fast mode         **\n");
2525    fprintf(stderr, "***************************************************************************\n");
2526  }
2527#if NH_MV
2528  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
2529  {
2530    xConfirmPara( m_iQP[layer] <  -6 * (m_internalBitDepth[CHANNEL_TYPE_LUMA] - 8) || m_iQP[layer] > 51,      "QP exceeds supported range (-QpBDOffsety to 51)" );
2531    xConfirmPara( m_DeblockingFilterMetric && (m_bLoopFilterDisable[layer] || m_loopFilterOffsetInPPS), "If DeblockingFilterMetric is true then both LoopFilterDisable and LoopFilterOffsetInPPS must be 0");
2532  }
2533#else
2534  xConfirmPara( m_iQP <  -6 * (m_internalBitDepth[CHANNEL_TYPE_LUMA] - 8) || m_iQP > 51,    "QP exceeds supported range (-QpBDOffsety to 51)" );
2535  xConfirmPara( m_DeblockingFilterMetric && (m_bLoopFilterDisable || m_loopFilterOffsetInPPS), "If DeblockingFilterMetric is true then both LoopFilterDisable and LoopFilterOffsetInPPS must be 0");
2536#endif
2537 
2538  xConfirmPara( m_loopFilterBetaOffsetDiv2 < -6 || m_loopFilterBetaOffsetDiv2 > 6,        "Loop Filter Beta Offset div. 2 exceeds supported range (-6 to 6)");
2539  xConfirmPara( m_loopFilterTcOffsetDiv2 < -6 || m_loopFilterTcOffsetDiv2 > 6,            "Loop Filter Tc Offset div. 2 exceeds supported range (-6 to 6)");
2540  xConfirmPara( m_iSearchRange < 0 ,                                                        "Search Range must be more than 0" );
2541  xConfirmPara( m_bipredSearchRange < 0 ,                                                   "Bi-prediction refinement search range must be more than 0" );
2542  xConfirmPara( m_minSearchWindow < 0,                                                      "Minimum motion search window size for the adaptive window ME must be greater than or equal to 0" );
2543#if NH_MV
2544  xConfirmPara( m_iVerticalDisparitySearchRange <= 0 ,                                      "Vertical Disparity Search Range must be more than 0" );
2545#endif
2546  xConfirmPara( m_iMaxDeltaQP > 7,                                                          "Absolute Delta QP exceeds supported range (0 to 7)" );
2547  xConfirmPara( m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1,                                          "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" );
2548
2549  xConfirmPara( m_cbQpOffset < -12,   "Min. Chroma Cb QP Offset is -12" );
2550  xConfirmPara( m_cbQpOffset >  12,   "Max. Chroma Cb QP Offset is  12" );
2551  xConfirmPara( m_crQpOffset < -12,   "Min. Chroma Cr QP Offset is -12" );
2552  xConfirmPara( m_crQpOffset >  12,   "Max. Chroma Cr QP Offset is  12" );
2553
2554  xConfirmPara( m_iQPAdaptationRange <= 0,                                                  "QP Adaptation Range must be more than 0" );
2555  if (m_iDecodingRefreshType == 2)
2556  {
2557#if NH_MV
2558    for (Int i = 0; i < m_numberOfLayers; i++ )
2559    {
2560      xConfirmPara( m_iIntraPeriod[i] > 0 && m_iIntraPeriod[i] <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
2561    }
2562#else
2563    xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
2564#endif
2565  }
2566  xConfirmPara( m_uiMaxCUDepth < 1,                                                         "MaxPartitionDepth must be greater than zero");
2567  xConfirmPara( (m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,                                    "Minimum partition width size should be larger than or equal to 8");
2568  xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4,                                    "Minimum partition height size should be larger than or equal to 8");
2569  xConfirmPara( m_uiMaxCUWidth < 16,                                                        "Maximum partition width size should be larger than or equal to 16");
2570  xConfirmPara( m_uiMaxCUHeight < 16,                                                       "Maximum partition height size should be larger than or equal to 16");
2571  xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame width must be a multiple of the minimum CU size");
2572  xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame height must be a multiple of the minimum CU size");
2573
2574  xConfirmPara( m_uiQuadtreeTULog2MinSize < 2,                                        "QuadtreeTULog2MinSize must be 2 or greater.");
2575  xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5,                                        "QuadtreeTULog2MaxSize must be 5 or smaller.");
2576  xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize,                "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize.");
2577  xConfirmPara( (1<<m_uiQuadtreeTULog2MaxSize) > m_uiMaxCUWidth,                      "QuadtreeTULog2MaxSize must be log2(maxCUSize) or smaller.");
2578  xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) >= ( m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than or equal to minimum CU size" );
2579  xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) >= ( m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than or equal to minimum CU size" );
2580  xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1,                                                         "QuadtreeTUMaxDepthInter must be greater than or equal to 1" );
2581  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" );
2582  xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1,                                                         "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" );
2583  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" );
2584
2585  xConfirmPara(  m_maxNumMergeCand < 1,  "MaxNumMergeCand must be 1 or greater.");
2586  xConfirmPara(  m_maxNumMergeCand > 5,  "MaxNumMergeCand must be 5 or smaller.");
2587#if NH_3D
2588  xConfirmPara( m_log2SubPbSizeMinus3 < 0,                                        "Log2SubPbSizeMinus3 must be equal to 0 or greater.");
2589  xConfirmPara( m_log2SubPbSizeMinus3 > 3,                                        "Log2SubPbSizeMinus3 must be equal to 3 or smaller.");
2590  xConfirmPara( (1<< ( m_log2SubPbSizeMinus3 + 3) ) > m_uiMaxCUWidth,              "Log2SubPbSizeMinus3 must be  equal to log2(maxCUSize)-3 or smaller.");
2591 
2592  xConfirmPara( m_log2MpiSubPbSizeMinus3 < 0,                                        "Log2MpiSubPbSizeMinus3 must be equal to 0 or greater.");
2593  xConfirmPara( m_log2MpiSubPbSizeMinus3 > 3,                                        "Log2MpiSubPbSizeMinus3 must be equal to 3 or smaller.");
2594  xConfirmPara( (1<< (m_log2MpiSubPbSizeMinus3 + 3)) > m_uiMaxCUWidth,               "Log2MpiSubPbSizeMinus3 must be equal to log2(maxCUSize)-3 or smaller.");
2595#endif
2596#if ADAPTIVE_QP_SELECTION
2597#if NH_MV
2598  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
2599  {
2600    xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP[layer] < 0,                                     "AdaptiveQpSelection must be disabled when QP < 0.");
2601  }
2602#else
2603  xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
2604#endif
2605  xConfirmPara( m_bUseAdaptQpSelect == true && (m_cbQpOffset !=0 || m_crQpOffset != 0 ),               "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0.");
2606#endif
2607
2608  if( m_usePCM)
2609  {
2610    for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
2611    {
2612      xConfirmPara(((m_MSBExtendedBitDepth[channelType] > m_internalBitDepth[channelType]) && m_bPCMInputBitDepthFlag), "PCM bit depth cannot be greater than internal bit depth (PCMInputBitDepthFlag cannot be used when InputBitDepth or MSBExtendedBitDepth > InternalBitDepth)");
2613    }
2614    xConfirmPara(  m_uiPCMLog2MinSize < 3,                                      "PCMLog2MinSize must be 3 or greater.");
2615    xConfirmPara(  m_uiPCMLog2MinSize > 5,                                      "PCMLog2MinSize must be 5 or smaller.");
2616    xConfirmPara(  m_pcmLog2MaxSize > 5,                                        "PCMLog2MaxSize must be 5 or smaller.");
2617    xConfirmPara(  m_pcmLog2MaxSize < m_uiPCMLog2MinSize,                       "PCMLog2MaxSize must be equal to or greater than m_uiPCMLog2MinSize.");
2618  }
2619
2620  if (m_sliceMode!=NO_SLICES)
2621  {
2622    xConfirmPara( m_sliceArgument < 1 ,         "SliceArgument should be larger than or equal to 1" );
2623  }
2624  if (m_sliceSegmentMode!=NO_SLICES)
2625  {
2626    xConfirmPara( m_sliceSegmentArgument < 1 ,         "SliceSegmentArgument should be larger than or equal to 1" );
2627  }
2628
2629  Bool tileFlag = (m_numTileColumnsMinus1 > 0 || m_numTileRowsMinus1 > 0 );
2630  if (m_profile!=Profile::HIGHTHROUGHPUTREXT)
2631  {
2632    xConfirmPara( tileFlag && m_entropyCodingSyncEnabledFlag, "Tiles and entropy-coding-sync (Wavefronts) can not be applied together, except in the High Throughput Intra 4:4:4 16 profile");
2633  }
2634
2635  xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
2636  xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
2637
2638  xConfirmPara( m_aiPad[0] % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
2639  xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
2640
2641  xConfirmPara( m_confWinLeft   % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
2642  xConfirmPara( m_confWinRight  % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
2643  xConfirmPara( m_confWinTop    % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
2644  xConfirmPara( m_confWinBottom % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
2645
2646  xConfirmPara( m_defaultDisplayWindowFlag && !m_vuiParametersPresentFlag, "VUI needs to be enabled for default display window");
2647
2648  if (m_defaultDisplayWindowFlag)
2649  {
2650    xConfirmPara( m_defDispWinLeftOffset   % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Left default display window offset must be an integer multiple of the specified chroma subsampling");
2651    xConfirmPara( m_defDispWinRightOffset  % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Right default display window offset must be an integer multiple of the specified chroma subsampling");
2652    xConfirmPara( m_defDispWinTopOffset    % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0, "Top default display window offset must be an integer multiple of the specified chroma subsampling");
2653    xConfirmPara( m_defDispWinBottomOffset % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0, "Bottom default display window offset must be an integer multiple of the specified chroma subsampling");
2654  }
2655
2656#if NH_3D
2657  xConfirmPara( m_pchCameraParameterFile    == 0                ,   "CameraParameterFile must be given");
2658  xConfirmPara( m_pchBaseViewCameraNumbers  == 0                ,   "BaseViewCameraNumbers must be given" );
2659  xConfirmPara( m_iNumberOfViews != m_cCameraData.getBaseViewNumbers().size() ,   "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" );
2660  xConfirmPara    ( m_iCodedCamParPrecision < 0 || m_iCodedCamParPrecision > 5,       "CodedCamParsPrecision must be in range of 0..5" );
2661#if NH_3D_VSO
2662    if( m_bUseVSO )
2663    {
2664      xConfirmPara(   m_pchVSOConfig            == 0                             ,   "VSO Setup string must be given");
2665      xConfirmPara( m_uiVSOMode > 4 ,                                                "VSO Mode must be less than 5");
2666    }
2667#endif
2668#endif
2669  // max CU width and height should be power of 2
2670  UInt ui = m_uiMaxCUWidth;
2671  while(ui)
2672  {
2673    ui >>= 1;
2674    if( (ui & 1) == 1)
2675    {
2676      xConfirmPara( ui != 1 , "Width should be 2^n");
2677    }
2678  }
2679  ui = m_uiMaxCUHeight;
2680  while(ui)
2681  {
2682    ui >>= 1;
2683    if( (ui & 1) == 1)
2684    {
2685      xConfirmPara( ui != 1 , "Height should be 2^n");
2686    }
2687  }
2688
2689#if NH_MV
2690  // validate that POC of same frame is identical across multiple layers
2691  Bool bErrorMvePoc = false;
2692  if( m_numberOfLayers > 1 )
2693  {
2694    for( Int k = 1; k < m_numberOfLayers; k++ )
2695    {
2696      for( Int i = 0; i < MAX_GOP; i++ )
2697      {
2698        if( m_GOPListMvc[k][i].m_POC != m_GOPListMvc[0][i].m_POC )
2699        {
2700          printf( "\nError: Frame%d_l%d POC %d is not identical to Frame%d POC\n", i, k, m_GOPListMvc[k][i].m_POC, i );
2701          bErrorMvePoc = true;
2702        }
2703      }
2704    }
2705  }
2706  xConfirmPara( bErrorMvePoc,  "Invalid inter-layer POC structure given" );
2707
2708  // validate that baseview has no inter-view refs
2709  Bool bErrorIvpBase = false;
2710  for( Int i = 0; i < MAX_GOP; i++ )
2711  {
2712    if( m_GOPListMvc[0][i].m_numActiveRefLayerPics != 0 )
2713    {
2714      printf( "\nError: Frame%d inter_layer refs not available in layer 0\n", i );
2715      bErrorIvpBase = true;
2716    }
2717  }
2718  xConfirmPara( bErrorIvpBase, "Inter-layer refs not possible in base layer" );
2719
2720  // validate inter-view refs
2721  Bool bErrorIvpEnhV = false;
2722  if( m_numberOfLayers > 1 )
2723  {
2724    for( Int layer = 1; layer < m_numberOfLayers; layer++ )
2725    {
2726      for( Int i = 0; i < MAX_GOP+1; i++ )
2727      {
2728        GOPEntry gopEntry = m_GOPListMvc[layer][i]; 
2729        for( Int j = 0; j < gopEntry.m_numActiveRefLayerPics; j++ )
2730        {
2731          Int ilPredLayerIdc = gopEntry.m_interLayerPredLayerIdc[j];
2732          if( ilPredLayerIdc < 0 || ilPredLayerIdc >= m_directRefLayers[layer].size() )
2733          {
2734            printf( "\nError: inter-layer ref idc %d is not available for Frame%d_l%d\n", gopEntry.m_interLayerPredLayerIdc[j], i, layer );
2735            bErrorIvpEnhV = true;
2736          }
2737          if( gopEntry.m_interViewRefPosL[0][j] < -1 || gopEntry.m_interViewRefPosL[0][j] > gopEntry.m_numRefPicsActive )
2738          {
2739            printf( "\nError: inter-layer ref pos %d on L0 is not available for Frame%d_l%d\n", gopEntry.m_interViewRefPosL[0][j], i, layer );
2740            bErrorIvpEnhV = true;
2741          }
2742          if( gopEntry.m_interViewRefPosL[1][j] < -1  || gopEntry.m_interViewRefPosL[1][j] > gopEntry.m_numRefPicsActive )
2743          {
2744            printf( "\nError: inter-layer ref pos %d on L1 is not available for Frame%d_l%d\n", gopEntry.m_interViewRefPosL[1][j], i, layer );
2745            bErrorIvpEnhV = true;
2746          }
2747        }
2748        if( i == MAX_GOP ) // inter-view refs at I pic position in base view
2749        {
2750          if( gopEntry.m_sliceType != 'B' && gopEntry.m_sliceType != 'P' && gopEntry.m_sliceType != 'I' )
2751          {
2752            printf( "\nError: slice type of FrameI_l%d must be equal to B or P or I\n", layer );
2753            bErrorIvpEnhV = true;
2754          }
2755
2756          if( gopEntry.m_POC != 0 )
2757          {
2758            printf( "\nError: POC %d not possible for FrameI_l%d, must be 0\n", gopEntry.m_POC, layer );
2759            bErrorIvpEnhV = true;
2760          }
2761
2762          if( gopEntry.m_temporalId != 0 )
2763          {
2764            printf( "\nWarning: Temporal id of FrameI_l%d must be 0 (cp. I-frame in base layer)\n", layer );
2765            gopEntry.m_temporalId = 0;
2766          }
2767
2768          if( gopEntry.m_numRefPics != 0 )
2769          {
2770            printf( "\nWarning: temporal references not possible for FrameI_l%d\n", layer );
2771            for( Int j = 0; j < m_GOPListMvc[layer][MAX_GOP].m_numRefPics; j++ )
2772            {
2773              gopEntry.m_referencePics[j] = 0;
2774            }
2775            gopEntry.m_numRefPics = 0;
2776          }
2777
2778          if( gopEntry.m_interRPSPrediction )
2779          {
2780            printf( "\nError: inter RPS prediction not possible for FrameI_l%d, must be 0\n", layer );
2781            bErrorIvpEnhV = true;
2782          }
2783
2784          if( gopEntry.m_sliceType == 'I' && gopEntry.m_numActiveRefLayerPics != 0 )
2785          {
2786            printf( "\nError: inter-layer prediction not possible for FrameI_l%d with slice type I, #IL_ref_pics must be 0\n", layer );
2787            bErrorIvpEnhV = true;
2788          }
2789
2790          if( gopEntry.m_numRefPicsActive > gopEntry.m_numActiveRefLayerPics )
2791          {
2792            gopEntry.m_numRefPicsActive = gopEntry.m_numActiveRefLayerPics;
2793          }
2794
2795          if( gopEntry.m_sliceType == 'P' )
2796          {
2797            if( gopEntry.m_numActiveRefLayerPics < 1 )
2798            {
2799              printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type P\n", layer );
2800              bErrorIvpEnhV = true;
2801            }
2802            else
2803            {
2804              for( Int j = 0; j < gopEntry.m_numActiveRefLayerPics; j++ )
2805              {
2806                if( gopEntry.m_interViewRefPosL[1][j] != -1 )
2807                {
2808                  printf( "\nError: inter-layer ref pos %d on L1 not possible for FrameI_l%d with slice type P\n", gopEntry.m_interViewRefPosL[1][j], layer );
2809                  bErrorIvpEnhV = true;
2810                }
2811              }
2812            }
2813          }
2814
2815          if( gopEntry.m_sliceType == 'B' && gopEntry.m_numActiveRefLayerPics < 1 )
2816          {
2817            printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type B\n", layer );
2818            bErrorIvpEnhV = true;
2819          }
2820        }
2821      }
2822    }
2823  }
2824  xConfirmPara( bErrorIvpEnhV, "Invalid inter-layer coding structure for enhancement layers given" );
2825
2826  // validate temporal coding structure
2827  if( !bErrorMvePoc && !bErrorIvpBase && !bErrorIvpEnhV )
2828  {
2829    for( Int layer = 0; layer < m_numberOfLayers; layer++ )
2830    {
2831      GOPEntry* m_GOPList            = m_GOPListMvc           [layer]; // It is not a member, but this name helps avoiding code duplication !!!
2832      Int&      m_extraRPSs          = m_extraRPSsMvc         [layer]; // It is not a member, but this name helps avoiding code duplication !!!
2833      Int&      m_maxTempLayer       = m_maxTempLayerMvc      [layer]; // It is not a member, but this name helps avoiding code duplication !!!
2834      Int*      m_maxDecPicBuffering = m_maxDecPicBufferingMvc[layer]; // It is not a member, but this name helps avoiding code duplication !!!
2835      Int*      m_numReorderPics     = m_numReorderPicsMvc    [layer]; // It is not a member, but this name helps avoiding code duplication !!!
2836#endif
2837
2838  /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure
2839   * This permits the ability to omit a GOP structure specification */
2840#if NH_MV
2841  if (m_iIntraPeriod[layer] == 1 && m_GOPList[0].m_POC == -1)
2842#else
2843  if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1)
2844#endif
2845  {
2846    m_GOPList[0] = GOPEntry();
2847    m_GOPList[0].m_QPFactor = 1;
2848    m_GOPList[0].m_betaOffsetDiv2 = 0;
2849    m_GOPList[0].m_tcOffsetDiv2 = 0;
2850    m_GOPList[0].m_POC = 1;
2851    m_GOPList[0].m_numRefPicsActive = 4;
2852  }
2853  else
2854  {
2855    xConfirmPara( m_intraConstraintFlag, "IntraConstraintFlag cannot be 1 for inter sequences");
2856  }
2857
2858  Bool verifiedGOP=false;
2859  Bool errorGOP=false;
2860  Int checkGOP=1;
2861  Int numRefs = m_isField ? 2 : 1;
2862  Int refList[MAX_NUM_REF_PICS+1];
2863  refList[0]=0;
2864  if(m_isField)
2865  {
2866    refList[1] = 1;
2867  }
2868  Bool isOK[MAX_GOP];
2869  for(Int i=0; i<MAX_GOP; i++)
2870  {
2871    isOK[i]=false;
2872  }
2873  Int numOK=0;
2874#if NH_MV
2875  xConfirmPara( m_iIntraPeriod[layer] >=0&&(m_iIntraPeriod[layer]%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" ); 
2876#else
2877  xConfirmPara( m_iIntraPeriod >=0&&(m_iIntraPeriod%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" );
2878#endif
2879
2880  for(Int i=0; i<m_iGOPSize; i++)
2881  {
2882    if(m_GOPList[i].m_POC==m_iGOPSize)
2883    {
2884      xConfirmPara( m_GOPList[i].m_temporalId!=0 , "The last frame in each GOP must have temporal ID = 0 " );
2885    }
2886  }
2887
2888#if NH_MV
2889  if ( (m_iIntraPeriod[layer] != 1) && !m_loopFilterOffsetInPPS && (!m_bLoopFilterDisable[layer]) )
2890#else
2891  if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && (!m_bLoopFilterDisable) )
2892#endif
2893  {
2894    for(Int i=0; i<m_iGOPSize; i++)
2895    {
2896      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)" );
2897      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)" );
2898    }
2899  }
2900
2901  m_extraRPSs=0;
2902  //start looping through frames in coding order until we can verify that the GOP structure is correct.
2903  while(!verifiedGOP&&!errorGOP)
2904  {
2905    Int curGOP = (checkGOP-1)%m_iGOPSize;
2906    Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + m_GOPList[curGOP].m_POC;
2907    if(m_GOPList[curGOP].m_POC<0)
2908    {
2909#if NH_MV
2910      printf("\nError: found fewer Reference Picture Sets than GOPSize for layer %d\n", layer );
2911#else
2912      printf("\nError: found fewer Reference Picture Sets than GOPSize\n");
2913#endif
2914      errorGOP=true;
2915    }
2916    else
2917    {
2918      //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
2919      Bool beforeI = false;
2920      for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++)
2921      {
2922        Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i];
2923        if(absPOC < 0)
2924        {
2925          beforeI=true;
2926        }
2927        else
2928        {
2929          Bool found=false;
2930          for(Int j=0; j<numRefs; j++)
2931          {
2932            if(refList[j]==absPOC)
2933            {
2934              found=true;
2935              for(Int k=0; k<m_iGOPSize; k++)
2936              {
2937                if(absPOC%m_iGOPSize == m_GOPList[k].m_POC%m_iGOPSize)
2938                {
2939                  if(m_GOPList[k].m_temporalId==m_GOPList[curGOP].m_temporalId)
2940                  {
2941                    m_GOPList[k].m_refPic = true;
2942                  }
2943                  m_GOPList[curGOP].m_usedByCurrPic[i]=m_GOPList[k].m_temporalId<=m_GOPList[curGOP].m_temporalId;
2944                }
2945              }
2946            }
2947          }
2948          if(!found)
2949          {
2950#if NH_MV
2951            printf("\nError: ref pic %d is not available for GOP frame %d of layer %d\n", m_GOPList[curGOP].m_referencePics[i], curGOP+1, layer);
2952#else
2953            printf("\nError: ref pic %d is not available for GOP frame %d\n",m_GOPList[curGOP].m_referencePics[i],curGOP+1);
2954#endif
2955            errorGOP=true;
2956          }
2957        }
2958      }
2959      if(!beforeI&&!errorGOP)
2960      {
2961        //all ref frames were present
2962        if(!isOK[curGOP])
2963        {
2964          numOK++;
2965          isOK[curGOP]=true;
2966          if(numOK==m_iGOPSize)
2967          {
2968            verifiedGOP=true;
2969          }
2970        }
2971      }
2972      else
2973      {
2974        //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
2975        m_GOPList[m_iGOPSize+m_extraRPSs]=m_GOPList[curGOP];
2976        Int newRefs=0;
2977        for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++)
2978        {
2979          Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i];
2980          if(absPOC>=0)
2981          {
2982            m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[newRefs]=m_GOPList[curGOP].m_referencePics[i];
2983            m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[newRefs]=m_GOPList[curGOP].m_usedByCurrPic[i];
2984            newRefs++;
2985          }
2986        }
2987        Int numPrefRefs = m_GOPList[curGOP].m_numRefPicsActive;
2988
2989        for(Int offset = -1; offset>-checkGOP; offset--)
2990        {
2991          //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
2992          Int offGOP = (checkGOP-1+offset)%m_iGOPSize;
2993          Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + m_GOPList[offGOP].m_POC;
2994          if(offPOC>=0&&m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId)
2995          {
2996            Bool newRef=false;
2997            for(Int i=0; i<numRefs; i++)
2998            {
2999              if(refList[i]==offPOC)
3000              {
3001                newRef=true;
3002              }
3003            }
3004            for(Int i=0; i<newRefs; i++)
3005            {
3006              if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[i]==offPOC-curPOC)
3007              {
3008                newRef=false;
3009              }
3010            }
3011            if(newRef)
3012            {
3013              Int insertPoint=newRefs;
3014              //this picture can be added, find appropriate place in list and insert it.
3015              if(m_GOPList[offGOP].m_temporalId==m_GOPList[curGOP].m_temporalId)
3016              {
3017                m_GOPList[offGOP].m_refPic = true;
3018              }
3019              for(Int j=0; j<newRefs; j++)
3020              {
3021                if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]<offPOC-curPOC||m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]>0)
3022                {
3023                  insertPoint = j;
3024                  break;
3025                }
3026              }
3027              Int prev = offPOC-curPOC;
3028              Int prevUsed = m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId;
3029              for(Int j=insertPoint; j<newRefs+1; j++)
3030              {
3031                Int newPrev = m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j];
3032                Int newUsed = m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j];
3033                m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]=prev;
3034                m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]=prevUsed;
3035                prevUsed=newUsed;
3036                prev=newPrev;
3037              }
3038              newRefs++;
3039            }
3040          }
3041          if(newRefs>=numPrefRefs)
3042          {
3043            break;
3044          }
3045        }
3046        m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics=newRefs;
3047        m_GOPList[m_iGOPSize+m_extraRPSs].m_POC = curPOC;
3048        if (m_extraRPSs == 0)
3049        {
3050          m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 0;
3051          m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = 0;
3052        }
3053        else
3054        {
3055          Int rIdx =  m_iGOPSize + m_extraRPSs - 1;
3056          Int refPOC = m_GOPList[rIdx].m_POC;
3057          Int refPics = m_GOPList[rIdx].m_numRefPics;
3058          Int newIdc=0;
3059          for(Int i = 0; i<= refPics; i++)
3060          {
3061            Int deltaPOC = ((i != refPics)? m_GOPList[rIdx].m_referencePics[i] : 0);  // check if the reference abs POC is >= 0
3062            Int absPOCref = refPOC+deltaPOC;
3063            Int refIdc = 0;
3064            for (Int j = 0; j < m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics; j++)
3065            {
3066              if ( (absPOCref - curPOC) == m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j])
3067              {
3068                if (m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j])
3069                {
3070                  refIdc = 1;
3071                }
3072                else
3073                {
3074                  refIdc = 2;
3075                }
3076              }
3077            }
3078            m_GOPList[m_iGOPSize+m_extraRPSs].m_refIdc[newIdc]=refIdc;
3079            newIdc++;
3080          }
3081          m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 1;
3082          m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = newIdc;
3083          m_GOPList[m_iGOPSize+m_extraRPSs].m_deltaRPS = refPOC - m_GOPList[m_iGOPSize+m_extraRPSs].m_POC;
3084        }
3085        curGOP=m_iGOPSize+m_extraRPSs;
3086        m_extraRPSs++;
3087      }
3088      numRefs=0;
3089      for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++)
3090      {
3091        Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i];
3092        if(absPOC >= 0)
3093        {
3094          refList[numRefs]=absPOC;
3095          numRefs++;
3096        }
3097      }
3098      refList[numRefs]=curPOC;
3099      numRefs++;
3100    }
3101    checkGOP++;
3102  }
3103  xConfirmPara(errorGOP,"Invalid GOP structure given");
3104  m_maxTempLayer = 1;
3105  for(Int i=0; i<m_iGOPSize; i++)
3106  {
3107    if(m_GOPList[i].m_temporalId >= m_maxTempLayer)
3108    {
3109      m_maxTempLayer = m_GOPList[i].m_temporalId+1;
3110    }
3111    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");
3112  }
3113  for(Int i=0; i<MAX_TLAYER; i++)
3114  {
3115    m_numReorderPics[i] = 0;
3116    m_maxDecPicBuffering[i] = 1;
3117  }
3118  for(Int i=0; i<m_iGOPSize; i++)
3119  {
3120    if(m_GOPList[i].m_numRefPics+1 > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
3121    {
3122      m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics + 1;
3123    }
3124    Int highestDecodingNumberWithLowerPOC = 0;
3125    for(Int j=0; j<m_iGOPSize; j++)
3126    {
3127      if(m_GOPList[j].m_POC <= m_GOPList[i].m_POC)
3128      {
3129        highestDecodingNumberWithLowerPOC = j;
3130      }
3131    }
3132    Int numReorder = 0;
3133    for(Int j=0; j<highestDecodingNumberWithLowerPOC; j++)
3134    {
3135      if(m_GOPList[j].m_temporalId <= m_GOPList[i].m_temporalId &&
3136        m_GOPList[j].m_POC > m_GOPList[i].m_POC)
3137      {
3138        numReorder++;
3139      }
3140    }
3141    if(numReorder > m_numReorderPics[m_GOPList[i].m_temporalId])
3142    {
3143      m_numReorderPics[m_GOPList[i].m_temporalId] = numReorder;
3144    }
3145  }
3146  for(Int i=0; i<MAX_TLAYER-1; i++)
3147  {
3148    // a lower layer can not have higher value of m_numReorderPics than a higher layer
3149    if(m_numReorderPics[i+1] < m_numReorderPics[i])
3150    {
3151      m_numReorderPics[i+1] = m_numReorderPics[i];
3152    }
3153    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive
3154    if(m_numReorderPics[i] > m_maxDecPicBuffering[i] - 1)
3155    {
3156      m_maxDecPicBuffering[i] = m_numReorderPics[i] + 1;
3157    }
3158    // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
3159    if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i])
3160    {
3161      m_maxDecPicBuffering[i+1] = m_maxDecPicBuffering[i];
3162    }
3163  }
3164
3165  // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] -  1, inclusive
3166  if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1)
3167  {
3168    m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1;
3169  }
3170
3171  if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
3172  {
3173    Int PicSizeInSamplesY =  m_iSourceWidth * m_iSourceHeight;
3174    if(tileFlag)
3175    {
3176      Int maxTileWidth = 0;
3177      Int maxTileHeight = 0;
3178      Int widthInCU = (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth/m_uiMaxCUWidth + 1: m_iSourceWidth/m_uiMaxCUWidth;
3179      Int heightInCU = (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight/m_uiMaxCUHeight + 1: m_iSourceHeight/m_uiMaxCUHeight;
3180      if(m_tileUniformSpacingFlag)
3181      {
3182        maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_numTileColumnsMinus1)/(m_numTileColumnsMinus1+1));
3183        maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_numTileRowsMinus1)/(m_numTileRowsMinus1+1));
3184        // if only the last tile-row is one treeblock higher than the others
3185        // the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others
3186        if(!((heightInCU-1)%(m_numTileRowsMinus1+1)))
3187        {
3188          maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight);
3189        }
3190        // if only the last tile-column is one treeblock wider than the others
3191        // the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others
3192        if(!((widthInCU-1)%(m_numTileColumnsMinus1+1)))
3193        {
3194          maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth);
3195        }
3196      }
3197      else // not uniform spacing
3198      {
3199        if(m_numTileColumnsMinus1<1)
3200        {
3201          maxTileWidth = m_iSourceWidth;
3202        }
3203        else
3204        {
3205          Int accColumnWidth = 0;
3206          for(Int col=0; col<(m_numTileColumnsMinus1); col++)
3207          {
3208            maxTileWidth = m_tileColumnWidth[col]>maxTileWidth ? m_tileColumnWidth[col]:maxTileWidth;
3209            accColumnWidth += m_tileColumnWidth[col];
3210          }
3211          maxTileWidth = (widthInCU-accColumnWidth)>maxTileWidth ? m_uiMaxCUWidth*(widthInCU-accColumnWidth):m_uiMaxCUWidth*maxTileWidth;
3212        }
3213        if(m_numTileRowsMinus1<1)
3214        {
3215          maxTileHeight = m_iSourceHeight;
3216        }
3217        else
3218        {
3219          Int accRowHeight = 0;
3220          for(Int row=0; row<(m_numTileRowsMinus1); row++)
3221          {
3222            maxTileHeight = m_tileRowHeight[row]>maxTileHeight ? m_tileRowHeight[row]:maxTileHeight;
3223            accRowHeight += m_tileRowHeight[row];
3224          }
3225          maxTileHeight = (heightInCU-accRowHeight)>maxTileHeight ? m_uiMaxCUHeight*(heightInCU-accRowHeight):m_uiMaxCUHeight*maxTileHeight;
3226        }
3227      }
3228      Int maxSizeInSamplesY = maxTileWidth*maxTileHeight;
3229      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/maxSizeInSamplesY-4;
3230    }
3231    else if(m_entropyCodingSyncEnabledFlag)
3232    {
3233      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/((2*m_iSourceHeight+m_iSourceWidth)*m_uiMaxCUHeight)-4;
3234    }
3235    else if(m_sliceMode == FIXED_NUMBER_OF_CTU)
3236    {
3237      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/(m_sliceArgument*m_uiMaxCUWidth*m_uiMaxCUHeight)-4;
3238    }
3239    else
3240    {
3241      m_minSpatialSegmentationIdc = 0;
3242    }
3243  }
3244
3245  if (m_toneMappingInfoSEIEnabled)
3246  {
3247    xConfirmPara( m_toneMapCodedDataBitDepth < 8 || m_toneMapCodedDataBitDepth > 14 , "SEIToneMapCodedDataBitDepth must be in rage 8 to 14");
3248    xConfirmPara( m_toneMapTargetBitDepth < 1 || (m_toneMapTargetBitDepth > 16 && m_toneMapTargetBitDepth < 255) , "SEIToneMapTargetBitDepth must be in rage 1 to 16 or equal to 255");
3249    xConfirmPara( m_toneMapModelId < 0 || m_toneMapModelId > 4 , "SEIToneMapModelId must be in rage 0 to 4");
3250    xConfirmPara( m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0");
3251    xConfirmPara( m_exposureIndexValue  == 0, "SEIToneMapExposureIndexValue shall not be equal to 0");
3252    xConfirmPara( m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100");
3253    xConfirmPara( m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue, "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue");
3254    xConfirmPara( m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue, "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue");
3255  }
3256
3257  if (m_kneeSEIEnabled && !m_kneeSEICancelFlag)
3258  {
3259    xConfirmPara( m_kneeSEINumKneePointsMinus1 < 0 || m_kneeSEINumKneePointsMinus1 > 998, "SEIKneeFunctionNumKneePointsMinus1 must be in the range of 0 to 998");
3260    for ( UInt i=0; i<=m_kneeSEINumKneePointsMinus1; i++ )
3261    {
3262      xConfirmPara( m_kneeSEIInputKneePoint[i] < 1 || m_kneeSEIInputKneePoint[i] > 999, "SEIKneeFunctionInputKneePointValue must be in the range of 1 to 999");
3263      xConfirmPara( m_kneeSEIOutputKneePoint[i] < 0 || m_kneeSEIOutputKneePoint[i] > 1000, "SEIKneeFunctionInputKneePointValue must be in the range of 0 to 1000");
3264      if ( i > 0 )
3265      {
3266        xConfirmPara( m_kneeSEIInputKneePoint[i-1] >= m_kneeSEIInputKneePoint[i],  "The i-th SEIKneeFunctionInputKneePointValue must be greater than the (i-1)-th value");
3267        xConfirmPara( m_kneeSEIOutputKneePoint[i-1] > m_kneeSEIOutputKneePoint[i],  "The i-th SEIKneeFunctionOutputKneePointValue must be greater than or equal to the (i-1)-th value");
3268      }
3269    }
3270  }
3271
3272  if (m_chromaResamplingFilterSEIenabled)
3273  {
3274    xConfirmPara( (m_chromaFormatIDC == CHROMA_400 ), "chromaResamplingFilterSEI is not allowed to be present when ChromaFormatIDC is equal to zero (4:0:0)" );
3275    xConfirmPara(m_vuiParametersPresentFlag && m_chromaLocInfoPresentFlag && (m_chromaSampleLocTypeTopField != m_chromaSampleLocTypeBottomField ), "When chromaResamplingFilterSEI is enabled, ChromaSampleLocTypeTopField has to be equal to ChromaSampleLocTypeBottomField" );
3276  }
3277
3278  if ( m_RCEnableRateControl )
3279  {
3280    if ( m_RCForceIntraQP )
3281    {
3282      if ( m_RCInitialQP == 0 )
3283      {
3284        printf( "\nInitial QP for rate control is not specified. Reset not to use force intra QP!" );
3285        m_RCForceIntraQP = false;
3286      }
3287    }
3288    xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" );
3289#if U0132_TARGET_BITS_SATURATION
3290#if NH_MV
3291    if ((m_RCCpbSaturationEnabled) && (m_level[0]!=Level::NONE) && (m_profile!=Profile::NONE))
3292    {
3293      UInt uiLevelIdx = (m_level[0] / 10) + (UInt)((m_level[0] % 10) / 3);    // (m_level / 30)*3 + ((m_level % 10) / 3);
3294      xConfirmPara(m_RCCpbSize > g_uiMaxCpbSize[m_levelTier[0]][uiLevelIdx], "RCCpbSize should be smaller than or equal to Max CPB size according to tier and level");
3295      xConfirmPara(m_RCInitialCpbFullness > 1, "RCInitialCpbFullness should be smaller than or equal to 1");
3296    }
3297#else
3298    if ((m_RCCpbSaturationEnabled) && (m_level!=Level::NONE) && (m_profile!=Profile::NONE))
3299    {
3300      UInt uiLevelIdx = (m_level / 10) + (UInt)((m_level % 10) / 3);    // (m_level / 30)*3 + ((m_level % 10) / 3);
3301      xConfirmPara(m_RCCpbSize > g_uiMaxCpbSize[m_levelTier][uiLevelIdx], "RCCpbSize should be smaller than or equal to Max CPB size according to tier and level");
3302      xConfirmPara(m_RCInitialCpbFullness > 1, "RCInitialCpbFullness should be smaller than or equal to 1");
3303    }
3304#endif
3305#endif
3306  }
3307#if U0132_TARGET_BITS_SATURATION
3308  else
3309  {
3310    xConfirmPara( m_RCCpbSaturationEnabled != 0, "Target bits saturation cannot be processed without Rate control" );
3311  }
3312#endif
3313
3314#if NH_MV
3315  // VPS VUI
3316  for(Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++ )
3317  { 
3318    for (Int j = 0; j < MAX_TLAYER; j++)
3319    {   
3320      if ( j < m_avgBitRate        [i].size() ) xConfirmPara( m_avgBitRate[i][j]         <  0 || m_avgBitRate[i][j]         > 65535, "avg_bit_rate            must be more than or equal to     0 and less than 65536" );
3321      if ( j < m_maxBitRate        [i].size() ) xConfirmPara( m_maxBitRate[i][j]         <  0 || m_maxBitRate[i][j]         > 65535, "max_bit_rate            must be more than or equal to     0 and less than 65536" );
3322      if ( j < m_constantPicRateIdc[i].size() ) xConfirmPara( m_constantPicRateIdc[i][j] <  0 || m_constantPicRateIdc[i][j] >     3, "constant_pic_rate_idc   must be more than or equal to     0 and less than     4" );
3323      if ( j < m_avgPicRate        [i].size() ) xConfirmPara( m_avgPicRate[i][j]         <  0 || m_avgPicRate[i][j]         > 65535, "avg_pic_rate            must be more than or equal to     0 and less than 65536" );
3324    }
3325  }
3326  // todo: replace value of 100 with requirement in spec
3327  for(Int i = 0; i < MAX_NUM_LAYERS; i++ )
3328  { 
3329    for (Int j = 0; j < MAX_NUM_LAYERS; j++)
3330    {   
3331      if ( j < m_minSpatialSegmentOffsetPlus1[i].size() ) xConfirmPara( m_minSpatialSegmentOffsetPlus1[i][j] < 0 || m_minSpatialSegmentOffsetPlus1[i][j] >   100, "min_spatial_segment_offset_plus1 must be more than or equal to     0 and less than   101" );
3332      if ( j < m_minHorizontalCtuOffsetPlus1[i] .size() ) xConfirmPara( m_minHorizontalCtuOffsetPlus1[i][j]  < 0 || m_minHorizontalCtuOffsetPlus1[i][j]  >   100, "min_horizontal_ctu_offset_plus1  must be more than or equal to     0 and less than   101" );
3333    }
3334  }
3335#endif
3336
3337  xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce, "CUTransquantBypassFlagForce cannot be 1 when TransquantBypassEnableFlag is 0");
3338
3339  xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
3340
3341  if (m_framePackingSEIEnabled)
3342  {
3343    xConfirmPara(m_framePackingSEIType < 3 || m_framePackingSEIType > 5 , "SEIFramePackingType must be in rage 3 to 5");
3344  }
3345#if NH_MV
3346  }
3347  }
3348#if !NH_MV_SEI
3349  // Check input parameters for Sub-bitstream property SEI message
3350  if( m_subBistreamPropSEIEnabled )
3351  {
3352    xConfirmPara( 
3353      (this->m_sbPropNumAdditionalSubStreams != m_sbPropAvgBitRate.size() )
3354      || (this->m_sbPropNumAdditionalSubStreams != m_sbPropHighestSublayerId.size() )
3355      || (this->m_sbPropNumAdditionalSubStreams != m_sbPropMaxBitRate.size() )
3356      || (this->m_sbPropNumAdditionalSubStreams != m_sbPropOutputLayerSetIdxToVps.size() )
3357      || (this->m_sbPropNumAdditionalSubStreams != m_sbPropSubBitstreamMode.size()), "Some parameters of some sub-bitstream not defined");
3358
3359    for( Int i = 0; i < m_sbPropNumAdditionalSubStreams; i++ )
3360    {
3361      xConfirmPara( m_sbPropSubBitstreamMode[i] < 0 || m_sbPropSubBitstreamMode[i] > 1, "Mode value should be 0 or 1" );
3362      xConfirmPara( m_sbPropHighestSublayerId[i] < 0 || m_sbPropHighestSublayerId[i] > MAX_TLAYER-1, "Maximum sub-layer ID out of range" );
3363      xConfirmPara( m_sbPropOutputLayerSetIdxToVps[i] < 0 || m_sbPropOutputLayerSetIdxToVps[i] >= MAX_VPS_OUTPUTLAYER_SETS, "OutputLayerSetIdxToVps should be within allowed range" );
3364    }
3365  }
3366#endif
3367#endif
3368
3369  if (m_segmentedRectFramePackingSEIEnabled)
3370  {
3371    xConfirmPara(m_framePackingSEIEnabled , "SEISegmentedRectFramePacking must be 0 when SEIFramePacking is 1");
3372  }
3373
3374  if((m_numTileColumnsMinus1 <= 0) && (m_numTileRowsMinus1 <= 0) && m_tmctsSEIEnabled)
3375  {
3376    printf("Warning: SEITempMotionConstrainedTileSets is set to false to disable temporal motion-constrained tile sets SEI message because there are no tiles enabled.\n");
3377    m_tmctsSEIEnabled = false;
3378  }
3379
3380  if(m_timeCodeSEIEnabled)
3381  {
3382    xConfirmPara(m_timeCodeSEINumTs > MAX_TIMECODE_SEI_SETS, "Number of time sets cannot exceed 3");
3383  }
3384
3385#undef xConfirmPara
3386  if (check_failed)
3387  {
3388    exit(EXIT_FAILURE);
3389  }
3390}
3391
3392const TChar *profileToString(const Profile::Name profile)
3393{
3394  static const UInt numberOfProfiles = sizeof(strToProfile)/sizeof(*strToProfile);
3395
3396  for (UInt profileIndex = 0; profileIndex < numberOfProfiles; profileIndex++)
3397  {
3398    if (strToProfile[profileIndex].value == profile)
3399    {
3400      return strToProfile[profileIndex].str;
3401    }
3402  }
3403
3404  //if we get here, we didn't find this profile in the list - so there is an error
3405  std::cerr << "ERROR: Unknown profile \"" << profile << "\" in profileToString" << std::endl;
3406  assert(false);
3407  exit(1);
3408  return "";
3409}
3410
3411Void TAppEncCfg::xPrintParameter()
3412{
3413  printf("\n");
3414#if NH_MV
3415  for( Int layer = 0; layer < m_numberOfLayers; layer++)
3416  {
3417    printf("Input File %i                     : %s\n", layer, m_pchInputFileList[layer]);
3418  }
3419#else
3420  printf("Input          File                    : %s\n", m_inputFileName.c_str()          );
3421#endif
3422  printf("Bitstream      File                    : %s\n", m_bitstreamFileName.c_str()      );
3423#if NH_MV
3424  for( Int layer = 0; layer < m_numberOfLayers; layer++)
3425  {
3426    printf("Reconstruction File %i            : %s\n", layer, m_pchReconFileList[layer]);
3427  }
3428#else
3429  printf("Reconstruction File                    : %s\n", m_reconFileName.c_str()          );
3430#endif
3431#if NH_MV
3432  xPrintParaVector( "NuhLayerId"     , m_layerIdInNuh ); 
3433  if ( m_targetEncLayerIdList.size() > 0)
3434  {
3435    xPrintParaVector( "TargetEncLayerIdList"     , m_targetEncLayerIdList ); 
3436  }
3437  xPrintParaVector( "ViewIdVal"     , m_viewId ); 
3438  xPrintParaVector( "ViewOrderIdx"  , m_viewOrderIndex ); 
3439  xPrintParaVector( "AuxId", m_auxId );
3440#endif
3441#if NH_3D
3442  xPrintParaVector( "DepthLayerFlag", m_depthFlag ); 
3443  printf("Coded Camera Param. Precision     : %d\n", m_iCodedCamParPrecision); 
3444#endif
3445#if NH_MV 
3446  xPrintParaVector( "QP"               , m_fQP                ); 
3447  xPrintParaVector( "LoopFilterDisable", m_bLoopFilterDisable ); 
3448  xPrintParaVector( "SAO"              , m_bUseSAO            ); 
3449#endif
3450
3451  printf("Real     Format                   : %dx%d %dHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, m_iFrameRate );
3452  printf("Internal Format                   : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
3453  printf("Sequence PSNR output              : %s\n", (m_printMSEBasedSequencePSNR ? "Linear average, MSE-based" : "Linear average only") );
3454  printf("Sequence MSE output               : %s\n", (m_printSequenceMSE ? "Enabled" : "Disabled") );
3455  printf("Frame MSE output                  : %s\n", (m_printFrameMSE    ? "Enabled" : "Disabled") );
3456  printf("Cabac-zero-word-padding           : %s\n", (m_cabacZeroWordPaddingEnabled? "Enabled" : "Disabled") );
3457  if (m_isField)
3458  {
3459    printf("Frame/Field                       : Field based coding\n");
3460    printf("Field index                       : %u - %d (%d fields)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
3461    printf("Field Order                       : %s field first\n", m_isTopFieldFirst?"Top":"Bottom");
3462
3463  }
3464  else
3465  {
3466    printf("Frame/Field                       : Frame based coding\n");
3467    printf("Frame index                       : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
3468  }
3469#if NH_MV
3470  printf("Profile                           :");
3471  for (Int i = 0; i < m_profiles.size(); i++)
3472  {
3473    Profile::Name m_profile = m_profiles[i];
3474
3475#endif
3476    if (m_profile == Profile::MAINREXT)
3477    {
3478    ExtendedProfileName validProfileName;
3479    if (m_onePictureOnlyConstraintFlag)
3480    {
3481      validProfileName = m_bitDepthConstraint == 8 ? MAIN_444_STILL_PICTURE : (m_bitDepthConstraint == 16 ? MAIN_444_16_STILL_PICTURE : NONE);
3482    }
3483    else
3484    {
3485      const UInt intraIdx = m_intraConstraintFlag ? 1:0;
3486      const UInt bitDepthIdx = (m_bitDepthConstraint == 8 ? 0 : (m_bitDepthConstraint ==10 ? 1 : (m_bitDepthConstraint == 12 ? 2 : (m_bitDepthConstraint == 16 ? 3 : 4 ))));
3487      const UInt chromaFormatIdx = UInt(m_chromaFormatConstraint);
3488      validProfileName = (bitDepthIdx > 3 || chromaFormatIdx>3) ? NONE : validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx];
3489    }
3490      std::string rextSubProfile;
3491      if (validProfileName!=NONE)
3492      {
3493        rextSubProfile=enumToString(strToExtendedProfile, sizeof(strToExtendedProfile)/sizeof(*strToExtendedProfile), validProfileName);
3494      }
3495      if (rextSubProfile == "main_444_16")
3496      {
3497        rextSubProfile="main_444_16 [NON STANDARD]";
3498      }
3499#if NH_MV
3500      printf(" %s (%s) ", profileToString(m_profile), (rextSubProfile.empty())?"INVALID REXT PROFILE":rextSubProfile.c_str() );
3501#else
3502      printf("Profile                           : %s (%s)\n", profileToString(m_profile), (rextSubProfile.empty())?"INVALID REXT PROFILE":rextSubProfile.c_str() );
3503#endif
3504    }
3505    else
3506    {
3507#if NH_MV
3508      printf(" %s ", profileToString(m_profile) );
3509#else
3510      printf("Profile                           : %s\n", profileToString(m_profile) );
3511#endif
3512    }
3513#if NH_MV   
3514  }
3515  printf("\n");
3516#endif
3517
3518  printf("CU size / depth / total-depth     : %d / %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth, m_uiMaxTotalCUDepth );
3519  printf("RQT trans. size (min / max)       : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
3520  printf("Max RQT depth inter               : %d\n", m_uiQuadtreeTUMaxDepthInter);
3521  printf("Max RQT depth intra               : %d\n", m_uiQuadtreeTUMaxDepthIntra);
3522  printf("Min PCM size                      : %d\n", 1 << m_uiPCMLog2MinSize);
3523  printf("Motion search range               : %d\n", m_iSearchRange );
3524#if NH_MV
3525  printf("Disp search range restriction     : %d\n", m_bUseDisparitySearchRangeRestriction );
3526  printf("Vertical disp search range        : %d\n", m_iVerticalDisparitySearchRange );
3527#endif
3528#if NH_MV
3529  xPrintParaVector( "Intra period", m_iIntraPeriod );
3530#else
3531  printf("Intra period                      : %d\n", m_iIntraPeriod );
3532#endif
3533  printf("Decoding refresh type             : %d\n", m_iDecodingRefreshType );
3534#if !NH_MV
3535  printf("QP                                : %5.2f\n", m_fQP );
3536#endif
3537  printf("Max dQP signaling depth           : %d\n", m_iMaxCuDQPDepth);
3538
3539  printf("Cb QP Offset                      : %d\n", m_cbQpOffset   );
3540  printf("Cr QP Offset                      : %d\n", m_crQpOffset);
3541  printf("QP adaptation                     : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) );
3542  printf("GOP size                          : %d\n", m_iGOPSize );
3543  printf("Input bit depth                   : (Y:%d, C:%d)\n", m_inputBitDepth[CHANNEL_TYPE_LUMA], m_inputBitDepth[CHANNEL_TYPE_CHROMA] );
3544  printf("MSB-extended bit depth            : (Y:%d, C:%d)\n", m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA], m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] );
3545  printf("Internal bit depth                : (Y:%d, C:%d)\n", m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA] );
3546  printf("PCM sample bit depth              : (Y:%d, C:%d)\n", m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA] : m_internalBitDepth[CHANNEL_TYPE_LUMA],
3547                                                               m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] : m_internalBitDepth[CHANNEL_TYPE_CHROMA] );
3548  printf("Intra reference smoothing         : %s\n", (m_enableIntraReferenceSmoothing          ? "Enabled" : "Disabled") );
3549  printf("diff_cu_chroma_qp_offset_depth         : %d\n", m_diffCuChromaQpOffsetDepth);
3550  printf("extended_precision_processing_flag     : %s\n", (m_extendedPrecisionProcessingFlag         ? "Enabled" : "Disabled") );
3551  printf("implicit_rdpcm_enabled_flag            : %s\n", (m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT] ? "Enabled" : "Disabled") );
3552  printf("explicit_rdpcm_enabled_flag            : %s\n", (m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT] ? "Enabled" : "Disabled") );
3553  printf("transform_skip_rotation_enabled_flag   : %s\n", (m_transformSkipRotationEnabledFlag        ? "Enabled" : "Disabled") );
3554  printf("transform_skip_context_enabled_flag    : %s\n", (m_transformSkipContextEnabledFlag         ? "Enabled" : "Disabled") );
3555  printf("cross_component_prediction_enabled_flag: %s\n", (m_crossComponentPredictionEnabledFlag     ? (m_reconBasedCrossCPredictionEstimate ? "Enabled (reconstructed-residual-based estimate)" : "Enabled (encoder-side-residual-based estimate)") : "Disabled") );
3556  printf("high_precision_offsets_enabled_flag    : %s\n", (m_highPrecisionOffsetsEnabledFlag         ? "Enabled" : "Disabled") );
3557  printf("persistent_rice_adaptation_enabled_flag: %s\n", (m_persistentRiceAdaptationEnabledFlag     ? "Enabled" : "Disabled") );
3558  printf("cabac_bypass_alignment_enabled_flag    : %s\n", (m_cabacBypassAlignmentEnabledFlag         ? "Enabled" : "Disabled") );
3559#if NH_MV
3560  Bool anySAO = false; 
3561  IntAry1d saoOffBitShiftL;
3562  IntAry1d saoOffBitShiftC;
3563
3564  for (Int i = 0; i < m_numberOfLayers; i++)
3565  {
3566    if ( m_bUseSAO[i] )
3567    {
3568      anySAO = true; 
3569      saoOffBitShiftL.push_back( m_log2SaoOffsetScale[i][CHANNEL_TYPE_LUMA] );
3570      saoOffBitShiftC.push_back( m_log2SaoOffsetScale[i][CHANNEL_TYPE_CHROMA] );
3571    }
3572    else
3573    {
3574      saoOffBitShiftL.push_back( -1 );
3575      saoOffBitShiftC.push_back( -1 );
3576    }
3577  }
3578  if (anySAO)
3579  {
3580    xPrintParaVector( "Sao Luma Offset bit shifts"  , saoOffBitShiftL );
3581    xPrintParaVector( "Sao Chroma Offset bit shifts", saoOffBitShiftC );
3582  }
3583#else
3584  if (m_bUseSAO)
3585  {
3586    printf("log2_sao_offset_scale_luma             : %d\n", m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA]);
3587    printf("log2_sao_offset_scale_chroma           : %d\n", m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA]);
3588  }
3589#endif
3590
3591  switch (m_costMode)
3592  {
3593    case COST_STANDARD_LOSSY:               printf("Cost function:                    : Lossy coding (default)\n"); break;
3594    case COST_SEQUENCE_LEVEL_LOSSLESS:      printf("Cost function:                    : Sequence_level_lossless coding\n"); break;
3595    case COST_LOSSLESS_CODING:              printf("Cost function:                    : Lossless coding with fixed QP of %d\n", LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP); break;
3596    case COST_MIXED_LOSSLESS_LOSSY_CODING:  printf("Cost function:                    : Mixed_lossless_lossy coding with QP'=%d for lossless evaluation\n", LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME); break;
3597    default:                                printf("Cost function:                    : Unknown\n"); break;
3598  }
3599
3600  printf("RateControl                       : %d\n", m_RCEnableRateControl );
3601  printf("WPMethod                               : %d\n", Int(m_weightedPredictionMethod));
3602
3603  if(m_RCEnableRateControl)
3604  {
3605    printf("TargetBitrate                     : %d\n", m_RCTargetBitrate );
3606    printf("KeepHierarchicalBit               : %d\n", m_RCKeepHierarchicalBit );
3607    printf("LCULevelRC                        : %d\n", m_RCLCULevelRC );
3608    printf("UseLCUSeparateModel               : %d\n", m_RCUseLCUSeparateModel );
3609    printf("InitialQP                         : %d\n", m_RCInitialQP );
3610    printf("ForceIntraQP                      : %d\n", m_RCForceIntraQP );
3611
3612#if U0132_TARGET_BITS_SATURATION
3613    printf("CpbSaturation                          : %d\n", m_RCCpbSaturationEnabled );
3614    if (m_RCCpbSaturationEnabled)
3615    {
3616      printf("CpbSize                                : %d\n", m_RCCpbSize);
3617      printf("InitalCpbFullness                      : %.2f\n", m_RCInitialCpbFullness);
3618    }
3619#endif
3620
3621#if KWU_RC_MADPRED_E0227
3622    printf("Depth based MAD prediction   : %d\n", m_depthMADPred);
3623#endif
3624#if KWU_RC_VIEWRC_E0227
3625    printf("View-wise Rate control       : %d\n", m_viewWiseRateCtrl);
3626    if(m_viewWiseRateCtrl)
3627    {
3628
3629      printf("ViewWiseTargetBits           : ");
3630      for (Int i = 0 ; i < m_iNumberOfViews ; i++)
3631        printf("%d ", m_viewTargetBits[i]);
3632      printf("\n");
3633    }
3634    else
3635    {
3636      printf("TargetBitrate                : %d\n", m_RCTargetBitrate );
3637    }
3638#endif
3639
3640  }
3641
3642  printf("Max Num Merge Candidates          : %d\n", m_maxNumMergeCand);
3643#if NH_3D
3644  printf("BaseViewCameraNumbers             : %s\n", m_pchBaseViewCameraNumbers ); 
3645  printf("Coded Camera Param. Precision     : %d\n", m_iCodedCamParPrecision);
3646#if NH_3D_VSO
3647  printf("Force use of Lambda Scale         : %d\n", m_bForceLambdaScaleVSO );
3648
3649  if ( m_bUseVSO )
3650  {   
3651    printf("VSO Lambda Scale                  : %5.2f\n", m_dLambdaScaleVSO );
3652    printf("VSO Mode                          : %d\n",    m_uiVSOMode       );
3653    printf("VSO Config                        : %s\n",    m_pchVSOConfig    );
3654    printf("VSO Negative Distortion           : %d\n",    m_bAllowNegDist ? 1 : 0);
3655    printf("VSO LS Table                      : %d\n",    m_bVSOLSTable ? 1 : 0);
3656    printf("VSO Estimated VSD                 : %d\n",    m_bUseEstimatedVSD ? 1 : 0);
3657    printf("VSO Early Skip                    : %d\n",    m_bVSOEarlySkip ? 1 : 0);   
3658    if ( m_bUseWVSO )
3659    {
3660      printf("Dist. Weights (VSO/VSD/SAD)       : %d/%d/%d\n ", m_iVSOWeight, m_iVSDWeight, m_iDWeight );   
3661    }   
3662  }
3663#endif //HHI_VSO
3664#endif //NH_3D
3665  printf("\n");
3666#if NH_MV
3667  printf("TOOL CFG General: ");
3668#else
3669  printf("TOOL CFG: ");
3670#endif
3671  printf("IBD:%d ", ((m_internalBitDepth[CHANNEL_TYPE_LUMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA]) || (m_internalBitDepth[CHANNEL_TYPE_CHROMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA])));
3672  printf("HAD:%d ", m_bUseHADME           );
3673  printf("RDQ:%d ", m_useRDOQ            );
3674  printf("RDQTS:%d ", m_useRDOQTS        );
3675  printf("RDpenalty:%d ", m_rdPenalty  );
3676  printf("SQP:%d ", m_uiDeltaQpRD         );
3677  printf("ASR:%d ", m_bUseASR             );
3678  printf("MinSearchWindow:%d ", m_minSearchWindow        );
3679  printf("RestrictMESampling:%d ", m_bRestrictMESampling );
3680  printf("FEN:%d ", Int(m_fastInterSearchMode)           );
3681  printf("ECU:%d ", m_bUseEarlyCU         );
3682  printf("FDM:%d ", m_useFastDecisionForMerge );
3683  printf("CFM:%d ", m_bUseCbfFastMode         );
3684  printf("ESD:%d ", m_useEarlySkipDetection  );
3685  printf("RQT:%d ", 1     );
3686  printf("TransformSkip:%d ",     m_useTransformSkip              );
3687  printf("TransformSkipFast:%d ", m_useTransformSkipFast       );
3688  printf("TransformSkipLog2MaxSize:%d ", m_log2MaxTransformSkipBlockSize);
3689  printf("Slice: M=%d ", Int(m_sliceMode));
3690  if (m_sliceMode!=NO_SLICES)
3691  {
3692    printf("A=%d ", m_sliceArgument);
3693  }
3694  printf("SliceSegment: M=%d ",m_sliceSegmentMode);
3695  if (m_sliceSegmentMode!=NO_SLICES)
3696  {
3697    printf("A=%d ", m_sliceSegmentArgument);
3698  }
3699  printf("CIP:%d ", m_bUseConstrainedIntraPred);
3700#if !NH_MV
3701  printf("SAO:%d ", (m_bUseSAO)?(1):(0));
3702#endif
3703  printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
3704
3705  if (m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce)
3706  {
3707    printf("TransQuantBypassEnabled: =1");
3708  }
3709  else
3710  {
3711    printf("TransQuantBypassEnabled:%d ", (m_TransquantBypassEnableFlag)? 1:0 );
3712  }
3713
3714  printf("WPP:%d ", (Int)m_useWeightedPred);
3715  printf("WPB:%d ", (Int)m_useWeightedBiPred);
3716  printf("PME:%d ", m_log2ParallelMergeLevel);
3717  const Int iWaveFrontSubstreams = m_entropyCodingSyncEnabledFlag ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
3718  printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_entropyCodingSyncEnabledFlag?1:0, iWaveFrontSubstreams);
3719  printf(" ScalingList:%d ", m_useScalingListId );
3720  printf("TMVPMode:%d ", m_TMVPModeId     );
3721#if ADAPTIVE_QP_SELECTION
3722  printf("AQpS:%d", m_bUseAdaptQpSelect   );
3723#endif
3724
3725  printf(" SignBitHidingFlag:%d ", m_signHideFlag);
3726  printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
3727#if NH_3D_VSO
3728  printf(" VSO:%d ", m_bUseVSO   );
3729  printf("WVSO:%d ", m_bUseWVSO ); 
3730#endif
3731#if NH_3D
3732  printf( "QTL:%d "                  , m_bUseQTL);
3733  printf( "IlluCompEnable:%d "       , m_abUseIC);
3734  printf( "IlluCompLowLatencyEnc:%d ",  m_bUseLowLatencyICEnc);
3735  printf( "DLT:%d ", m_useDLT );
3736
3737
3738  printf( "IvMvPred:%d %d "            , m_ivMvPredFlag[0] ? 1 : 0, m_ivMvPredFlag[1]  ? 1 : 0);
3739  printf( "IvMvScaling:%d %d "         , m_ivMvScalingFlag[0] ? 1 : 0 , m_ivMvScalingFlag[1]  ? 1 : 0);
3740
3741  printf( "Log2SubPbSizeMinus3:%d "    , m_log2SubPbSizeMinus3            );
3742  printf( "IvResPred:%d "              , m_ivResPredFlag          ? 1 : 0 );
3743  printf( "DepthRefinement:%d "        , m_depthRefinementFlag    ? 1 : 0 );
3744  printf( "ViewSynthesisPred:%d "      , m_viewSynthesisPredFlag  ? 1 : 0 );
3745  printf( "DepthBasedBlkPart:%d "      , m_depthBasedBlkPartFlag  ? 1 : 0 );
3746  printf( "Mpi:%d "                    , m_mpiFlag                ? 1 : 0 );
3747  printf( "Log2MpiSubPbSizeMinus3:%d " , m_log2MpiSubPbSizeMinus3         );
3748  printf( "IntraContour:%d "           , m_intraContourFlag       ? 1 : 0 );
3749  printf( "IntraWedge:%d "             , m_intraWedgeFlag         ? 1 : 0 );
3750  printf( "IntraSdc:%d "               , m_intraSdcFlag           ? 1 : 0 );
3751  printf( "QtPred:%d "                 , m_qtPredFlag             ? 1 : 0 );
3752  printf( "InterSdc:%d "               , m_interSdcFlag           ? 1 : 0 );
3753  printf( "DepthIntraSkip:%d "         , m_depthIntraSkipFlag     ? 1 : 0 );
3754#endif
3755
3756  printf("\n\n");
3757
3758  fflush(stdout);
3759}
3760
3761Bool confirmPara(Bool bflag, const TChar* message)
3762{
3763  if (!bflag)
3764  {
3765    return false;
3766  }
3767
3768  printf("Error: %s\n",message);
3769  return true;
3770}
3771
3772//! \}
Note: See TracBrowser for help on using the repository browser.