source: 3DVCSoftware/branches/HTM-14.1-update-dev0/source/App/TAppEncoder/TAppEncCfg.cpp @ 1200

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

Update to HM-16.5.
Starting point for further re-activation of 3D-tools.

Includes:

active:

  • MV-HEVC
  • 3D-HLS (apart from DLT)
  • VSO

inactive:

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