source: 3DVCSoftware/branches/HTM-15.1-dev0-Nokia/source/App/TAppEncoder/TAppEncCfg.cpp @ 1338

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

Integrated general SEI changes and following SEIs:

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