source: 3DVCSoftware/branches/HTM-DEV-0.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp @ 367

Last change on this file since 367 was 367, checked in by tech, 12 years ago

Further minor cleanups.

  • Property svn:eol-style set to native
File size: 81.7 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-2013, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TAppEncCfg.cpp
35    \brief    Handle encoder configuration parameters
36*/
37
38#include <stdlib.h>
39#include <cassert>
40#include <cstring>
41#include <string>
42#include "TLibCommon/TComRom.h"
43#include "TAppEncCfg.h"
44
45static istream& operator>>(istream &, Level::Name &);
46static istream& operator>>(istream &, Level::Tier &);
47static istream& operator>>(istream &, Profile::Name &);
48
49#include "TAppCommon/program_options_lite.h"
50#include "TLibEncoder/TEncRateCtrl.h"
51#ifdef WIN32
52#define strdup _strdup
53#endif
54
55using namespace std;
56namespace po = df::program_options_lite;
57
58//! \ingroup TAppEncoder
59//! \{
60
61// ====================================================================================================================
62// Constructor / destructor / initialization / destroy
63// ====================================================================================================================
64
65TAppEncCfg::TAppEncCfg()
66: m_pchInputFile()
67, m_pchBitstreamFile()
68, m_pchReconFile()
69, m_pchdQPFile()
70, m_pColumnWidth()
71, m_pRowHeight()
72, m_scalingListFile()
73{
74  m_aidQP = NULL;
75#if J0149_TONE_MAPPING_SEI
76  m_startOfCodedInterval = NULL;
77  m_codedPivotValue = NULL;
78  m_targetPivotValue = NULL;
79#endif
80}
81
82TAppEncCfg::~TAppEncCfg()
83{
84  if ( m_aidQP )
85  {
86    delete[] m_aidQP;
87  }
88#if J0149_TONE_MAPPING_SEI
89  if ( m_startOfCodedInterval )
90  {
91    delete[] m_startOfCodedInterval;
92    m_startOfCodedInterval = NULL;
93  }
94   if ( m_codedPivotValue )
95  {
96    delete[] m_codedPivotValue;
97    m_codedPivotValue = NULL;
98  }
99  if ( m_targetPivotValue )
100  {
101    delete[] m_targetPivotValue;
102    m_targetPivotValue = NULL;
103  }
104#endif
105  free(m_pchInputFile);
106  free(m_pchBitstreamFile);
107  free(m_pchReconFile);
108  free(m_pchdQPFile);
109  free(m_pColumnWidth);
110  free(m_pRowHeight);
111  free(m_scalingListFile);
112}
113
114Void TAppEncCfg::create()
115{
116}
117
118Void TAppEncCfg::destroy()
119{
120}
121
122std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry)     //input
123{
124  in>>entry.m_sliceType;
125  in>>entry.m_POC;
126  in>>entry.m_QPOffset;
127  in>>entry.m_QPFactor;
128  in>>entry.m_tcOffsetDiv2;
129  in>>entry.m_betaOffsetDiv2;
130  in>>entry.m_temporalId;
131  in>>entry.m_numRefPicsActive;
132  in>>entry.m_numRefPics;
133  for ( Int i = 0; i < entry.m_numRefPics; i++ )
134  {
135    in>>entry.m_referencePics[i];
136  }
137  in>>entry.m_interRPSPrediction;
138#if AUTO_INTER_RPS
139  if (entry.m_interRPSPrediction==1)
140  {
141    in>>entry.m_deltaRPS;
142    in>>entry.m_numRefIdc;
143    for ( Int i = 0; i < entry.m_numRefIdc; i++ )
144    {
145      in>>entry.m_refIdc[i];
146    }
147  }
148  else if (entry.m_interRPSPrediction==2)
149  {
150    in>>entry.m_deltaRPS;
151  }
152#else
153  if (entry.m_interRPSPrediction)
154  {
155    in>>entry.m_deltaRPS;
156    in>>entry.m_numRefIdc;
157    for ( Int i = 0; i < entry.m_numRefIdc; i++ )
158    {
159      in>>entry.m_refIdc[i];
160    }
161  }
162#endif
163  return in;
164}
165
166static const struct MapStrToProfile {
167  const Char* str;
168  Profile::Name value;
169} strToProfile[] = {
170  {"none", Profile::NONE},
171  {"main", Profile::MAIN},
172  {"main10", Profile::MAIN10},
173  {"main-still-picture", Profile::MAINSTILLPICTURE},
174};
175
176static const struct MapStrToTier {
177  const Char* str;
178  Level::Tier value;
179} strToTier[] = {
180  {"main", Level::MAIN},
181  {"high", Level::HIGH},
182};
183
184static const struct MapStrToLevel {
185  const Char* str;
186  Level::Name value;
187} strToLevel[] = {
188  {"none",Level::NONE},
189  {"1",   Level::LEVEL1},
190  {"2",   Level::LEVEL2},
191  {"2.1", Level::LEVEL2_1},
192  {"3",   Level::LEVEL3},
193  {"3.1", Level::LEVEL3_1},
194  {"4",   Level::LEVEL4},
195  {"4.1", Level::LEVEL4_1},
196  {"5",   Level::LEVEL5},
197  {"5.1", Level::LEVEL5_1},
198  {"5.2", Level::LEVEL5_2},
199  {"6",   Level::LEVEL6},
200  {"6.1", Level::LEVEL6_1},
201  {"6.2", Level::LEVEL6_2},
202};
203
204template<typename T, typename P>
205static istream& readStrToEnum(P map[], unsigned long mapLen, istream &in, T &val)
206{
207  string str;
208  in >> str;
209
210  for (Int i = 0; i < mapLen; i++)
211  {
212    if (str == map[i].str)
213    {
214      val = map[i].value;
215      goto found;
216    }
217  }
218  /* not found */
219  in.setstate(ios::failbit);
220found:
221  return in;
222}
223
224static istream& operator>>(istream &in, Profile::Name &profile)
225{
226  return readStrToEnum(strToProfile, sizeof(strToProfile)/sizeof(*strToProfile), in, profile);
227}
228
229static istream& operator>>(istream &in, Level::Tier &tier)
230{
231  return readStrToEnum(strToTier, sizeof(strToTier)/sizeof(*strToTier), in, tier);
232}
233
234static istream& operator>>(istream &in, Level::Name &level)
235{
236  return readStrToEnum(strToLevel, sizeof(strToLevel)/sizeof(*strToLevel), in, level);
237}
238
239#if SIGNAL_BITRATE_PICRATE_IN_VPS
240Void readBoolString(const string inpString, const Int numEntries, Bool* &memberArray, const char *elementName);
241Void readIntString(const string inpString, const Int numEntries, Int* &memberArray, const char *elementName);
242#endif
243// ====================================================================================================================
244// Public member functions
245// ====================================================================================================================
246
247/** \param  argc        number of arguments
248    \param  argv        array of arguments
249    \retval             true when success
250 */
251Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] )
252{
253  Bool do_help = false;
254 
255  string cfg_InputFile;
256  string cfg_BitstreamFile;
257  string cfg_ReconFile;
258  string cfg_dQPFile;
259  string cfg_ColumnWidth;
260  string cfg_RowHeight;
261  string cfg_ScalingListFile;
262#if J0149_TONE_MAPPING_SEI
263  string cfg_startOfCodedInterval;
264  string cfg_codedPivotValue;
265  string cfg_targetPivotValue;
266#endif
267#if SIGNAL_BITRATE_PICRATE_IN_VPS
268  string cfg_bitRateInfoPresentFlag;
269  string cfg_picRateInfoPresentFlag;
270  string cfg_avgBitRate;
271  string cfg_maxBitRate;
272  string cfg_avgPicRate;
273  string cfg_constantPicRateIdc;
274#endif
275  po::Options opts;
276  opts.addOptions()
277  ("help", do_help, false, "this help text")
278  ("c", po::parseConfigFile, "configuration file name")
279 
280  // File, I/O and source parameters
281  ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
282  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
283  ("ReconFile,o",           cfg_ReconFile,     string(""), "Reconstructed YUV output file name")
284  ("SourceWidth,-wdt",      m_iSourceWidth,        0, "Source picture width")
285  ("SourceHeight,-hgt",     m_iSourceHeight,       0, "Source picture height")
286  ("InputBitDepth",         m_inputBitDepthY,    8, "Bit-depth of input file")
287  ("OutputBitDepth",        m_outputBitDepthY,   0, "Bit-depth of output file (default:InternalBitDepth)")
288  ("InternalBitDepth",      m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)"
289                                                       "If different to InputBitDepth, source data will be converted")
290  ("InputBitDepthC",        m_inputBitDepthC,    0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
291  ("OutputBitDepthC",       m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
292  ("InternalBitDepthC",     m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
293  ("ConformanceMode",       m_conformanceMode,     0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
294  ("HorizontalPadding,-pdx",m_aiPad[0],            0, "Horizontal source padding for conformance window mode 2")
295  ("VerticalPadding,-pdy",  m_aiPad[1],            0, "Vertical source padding for conformance window mode 2")
296  ("ConfLeft",              m_confLeft,            0, "Left offset for window conformance mode 3")
297  ("ConfRight",             m_confRight,           0, "Right offset for window conformance mode 3")
298  ("ConfTop",               m_confTop,             0, "Top offset for window conformance mode 3")
299  ("ConfBottom",            m_confBottom,          0, "Bottom offset for window conformance mode 3")
300  ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
301  ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
302  ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
303
304  // Profile and level
305  ("Profile", m_profile,   Profile::NONE, "Profile to be used when encoding (Incomplete)")
306  ("Level",   m_level,     Level::NONE,   "Level limit to be used, eg 5.1 (Incomplete)")
307  ("Tier",    m_levelTier, Level::MAIN,   "Tier to use for interpretation of --Level")
308
309#if L0046_CONSTRAINT_FLAGS
310  ("ProgressiveSource", m_progressiveSourceFlag, false, "Indicate that source is progressive")
311  ("InterlacedSource",  m_interlacedSourceFlag,  false, "Indicate that source is interlaced")
312  ("NonPackedSource",   m_nonPackedConstraintFlag, false, "Indicate that source does not contain frame packing")
313  ("FrameOnly",         m_frameOnlyConstraintFlag, false, "Indicate that the bitstream contains only frames")
314#endif
315 
316  // Unit definition parameters
317  ("MaxCUWidth",              m_uiMaxCUWidth,             64u)
318  ("MaxCUHeight",             m_uiMaxCUHeight,            64u)
319  // todo: remove defaults from MaxCUSize
320  ("MaxCUSize,s",             m_uiMaxCUWidth,             64u, "Maximum CU size")
321  ("MaxCUSize,s",             m_uiMaxCUHeight,            64u, "Maximum CU size")
322  ("MaxPartitionDepth,h",     m_uiMaxCUDepth,              4u, "CU depth")
323 
324  ("QuadtreeTULog2MaxSize",   m_uiQuadtreeTULog2MaxSize,   6u, "Maximum TU size in logarithm base 2")
325  ("QuadtreeTULog2MinSize",   m_uiQuadtreeTULog2MinSize,   2u, "Minimum TU size in logarithm base 2")
326 
327  ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u, "Depth of TU tree for intra CUs")
328  ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u, "Depth of TU tree for inter CUs")
329 
330  // Coding structure paramters
331  ("IntraPeriod,-ip",         m_iIntraPeriod,              -1, "Intra period in frames, (-1: only first frame)")
332  ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
333  ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
334#if !L0034_COMBINED_LIST_CLEANUP
335  ("ListCombination,-lc",     m_bUseLComb,               true, "Combined reference list for uni-prediction estimation in B-slices")
336#endif
337  // motion options
338  ("FastSearch",              m_iFastSearch,                1, "0:Full search  1:Diamond  2:PMVFAST")
339  ("SearchRange,-sr",         m_iSearchRange,              96, "Motion search range")
340  ("BipredSearchRange",       m_bipredSearchRange,          4, "Motion search range for bipred refinement")
341  ("HadamardME",              m_bUseHADME,               true, "Hadamard ME for fractional-pel")
342  ("ASR",                     m_bUseASR,                false, "Adaptive motion search range")
343
344  // Mode decision parameters
345  ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( Double )1.0, "Lambda modifier for temporal layer 0")
346  ("LambdaModifier1,-LM1", m_adLambdaModifier[ 1 ], ( Double )1.0, "Lambda modifier for temporal layer 1")
347  ("LambdaModifier2,-LM2", m_adLambdaModifier[ 2 ], ( Double )1.0, "Lambda modifier for temporal layer 2")
348  ("LambdaModifier3,-LM3", m_adLambdaModifier[ 3 ], ( Double )1.0, "Lambda modifier for temporal layer 3")
349  ("LambdaModifier4,-LM4", m_adLambdaModifier[ 4 ], ( Double )1.0, "Lambda modifier for temporal layer 4")
350  ("LambdaModifier5,-LM5", m_adLambdaModifier[ 5 ], ( Double )1.0, "Lambda modifier for temporal layer 5")
351  ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( Double )1.0, "Lambda modifier for temporal layer 6")
352  ("LambdaModifier7,-LM7", m_adLambdaModifier[ 7 ], ( Double )1.0, "Lambda modifier for temporal layer 7")
353
354  /* Quantization parameters */
355  ("QP,q",          m_fQP,             30.0, "Qp value, if value is float, QP is switched once during encoding")
356  ("DeltaQpRD,-dqr",m_uiDeltaQpRD,       0u, "max dQp offset for slice")
357  ("MaxDeltaQP,d",  m_iMaxDeltaQP,        0, "max dQp offset for block")
358  ("MaxCuDQPDepth,-dqd",  m_iMaxCuDQPDepth,        0, "max depth for a minimum CuDQP")
359
360  ("CbQpOffset,-cbqpofs",  m_cbQpOffset,        0, "Chroma Cb QP Offset")
361  ("CrQpOffset,-crqpofs",  m_crQpOffset,        0, "Chroma Cr QP Offset")
362
363#if ADAPTIVE_QP_SELECTION
364  ("AdaptiveQpSelection,-aqps",   m_bUseAdaptQpSelect,           false, "AdaptiveQpSelection")
365#endif
366
367  ("AdaptiveQP,-aq",                m_bUseAdaptiveQP,           false, "QP adaptation based on a psycho-visual model")
368  ("MaxQPAdaptationRange,-aqr",     m_iQPAdaptationRange,           6, "QP adaptation range")
369  ("dQPFile,m",                     cfg_dQPFile,           string(""), "dQP file name")
370  ("RDOQ",                          m_useRDOQ,                  true )
371  ("RDOQTS",                        m_useRDOQTS,                true )
372#if L0232_RD_PENALTY
373  ("RDpenalty",                     m_rdPenalty,                0,  "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disbaled  1:RD-penalty  2:maximum RD-penalty")
374#endif
375  // Entropy coding parameters
376  ("SBACRD",                         m_bUseSBACRD,                      true, "SBAC based RD estimation")
377 
378  // Deblocking filter parameters
379  ("LoopFilterDisable",              m_bLoopFilterDisable,             false )
380  ("LoopFilterOffsetInPPS",          m_loopFilterOffsetInPPS,          false )
381  ("LoopFilterBetaOffset_div2",      m_loopFilterBetaOffsetDiv2,           0 )
382  ("LoopFilterTcOffset_div2",        m_loopFilterTcOffsetDiv2,             0 )
383  ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false )
384#if L0386_DB_METRIC
385  ("DeblockingFilterMetric",         m_DeblockingFilterMetric,         false )
386#endif
387
388  // Coding tools
389  ("AMP",                      m_enableAMP,                 true,  "Enable asymmetric motion partitions")
390  ("TransformSkip",            m_useTransformSkip,          false, "Intra transform skipping")
391  ("TransformSkipFast",        m_useTransformSkipFast,      false, "Fast intra transform skipping")
392  ("SAO",                      m_bUseSAO,                   true,  "Enable Sample Adaptive Offset")
393  ("MaxNumOffsetsPerPic",      m_maxNumOffsetsPerPic,       2048,  "Max number of SAO offset per picture (Default: 2048)")   
394  ("SAOLcuBoundary",           m_saoLcuBoundary,            false, "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
395  ("SAOLcuBasedOptimization",  m_saoLcuBasedOptimization,   true,  "0: SAO picture-based optimization, 1: SAO LCU-based optimization ")
396  ("SliceMode",                m_sliceMode,                0,     "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
397  ("SliceArgument",            m_sliceArgument,            0,     "Depending on SliceMode being:"
398                                                                   "\t1: max number of CTUs per slice"
399                                                                   "\t2: max number of bytes per slice"
400                                                                   "\t3: max number of tiles per slice")
401  ("SliceSegmentMode",         m_sliceSegmentMode,       0,     "0: Disable all slice segment limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
402  ("SliceSegmentArgument",     m_sliceSegmentArgument,   0,     "Depending on SliceSegmentMode being:"
403                                                                   "\t1: max number of CTUs per slice segment"
404                                                                   "\t2: max number of bytes per slice segment"
405                                                                   "\t3: max number of tiles per slice segment")
406  ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true)
407
408  ("ConstrainedIntraPred",     m_bUseConstrainedIntraPred,  false, "Constrained Intra Prediction")
409
410  ("PCMEnabledFlag",           m_usePCM,                    false)
411  ("PCMLog2MaxSize",           m_pcmLog2MaxSize,            5u)
412  ("PCMLog2MinSize",           m_uiPCMLog2MinSize,          3u)
413  ("PCMInputBitDepthFlag",     m_bPCMInputBitDepthFlag,     true)
414  ("PCMFilterDisableFlag",     m_bPCMFilterDisableFlag,    false)
415
416  ("LosslessCuEnabled",        m_useLossless, false)
417
418  ("WeightedPredP,-wpP",          m_useWeightedPred,               false,      "Use weighted prediction in P slices")
419  ("WeightedPredB,-wpB",          m_useWeightedBiPred,             false,      "Use weighted (bidirectional) prediction in B slices")
420  ("Log2ParallelMergeLevel",      m_log2ParallelMergeLevel,     2u,          "Parallel merge estimation region")
421  ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,          "Indicates if the column and row boundaries are distributed uniformly")
422  ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
423  ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""), "Array containing ColumnWidth values in units of LCU")
424  ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
425  ("RowHeightArray",              cfg_RowHeight,                   string(""), "Array containing RowHeight values in units of LCU")
426  ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,          "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
427  ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
428  ("ScalingList",                 m_useScalingListId,              0,          "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile")
429  ("ScalingListFile",             cfg_ScalingListFile,             string(""), "Scaling list file name")
430  ("SignHideFlag,-SBH",                m_signHideFlag, 1)
431  ("MaxNumMergeCand",             m_maxNumMergeCand,             5u,         "Maximum number of merge candidates")
432
433  /* Misc. */
434  ("SEIDecodedPictureHash",       m_decodedPictureHashSEIEnabled, 0, "Control generation of decode picture hash SEI messages\n"
435                                                                    "\t3: checksum\n"
436                                                                    "\t2: CRC\n"
437                                                                    "\t1: use MD5\n"
438                                                                    "\t0: disable")
439  ("SEIpictureDigest",            m_decodedPictureHashSEIEnabled, 0, "deprecated alias for SEIDecodedPictureHash")
440  ("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")
441  ("FEN", m_bUseFastEnc, false, "fast encoder setting")
442  ("ECU", m_bUseEarlyCU, false, "Early CU setting") 
443  ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost") 
444  ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting")
445  ("ESD", m_useEarlySkipDetection, false, "Early SKIP detection setting")
446#if RATE_CONTROL_LAMBDA_DOMAIN
447  ( "RateControl",         m_RCEnableRateControl,   false, "Rate control: enable rate control" )
448  ( "TargetBitrate",       m_RCTargetBitrate,           0, "Rate control: target bitrate" )
449  ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit, false, "Rate control: keep hierarchical bit allocation in rate control algorithm" )
450  ( "LCULevelRateControl", m_RCLCULevelRC,           true, "Rate control: true: LCU level RC; false: picture level RC" )
451  ( "RCLCUSeparateModel",  m_RCUseLCUSeparateModel,  true, "Rate control: use LCU level separate R-lambda model" )
452  ( "InitialQP",           m_RCInitialQP,               0, "Rate control: initial QP" )
453  ( "RCForceIntraQP",      m_RCForceIntraQP,        false, "Rate control: force intra QP to be equal to initial QP" )
454#else
455  ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off")
456  ("TargetBitrate,-tbr", m_targetBitrate, 0, "Input target bitrate")
457  ("NumLCUInUnit,-nu", m_numLCUInUnit, 0, "Number of LCUs in an Unit")
458#endif
459
460  ("TransquantBypassEnableFlag", m_TransquantBypassEnableFlag, false, "transquant_bypass_enable_flag indicator in PPS")
461  ("CUTransquantBypassFlagValue", m_CUTransquantBypassFlagValue, false, "Fixed cu_transquant_bypass_flag value, when transquant_bypass_enable_flag is enabled")
462  ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
463  ("StrongIntraSmoothing,-sis",      m_useStrongIntraSmoothing,           true, "Enable strong intra smoothing for 32x32 blocks")
464  ("SEIActiveParameterSets",         m_activeParameterSetsSEIEnabled,          0, "Enable generation of active parameter sets SEI messages")
465  ("VuiParametersPresent,-vui",      m_vuiParametersPresentFlag,           false, "Enable generation of vui_parameters()")
466  ("AspectRatioInfoPresent",         m_aspectRatioInfoPresentFlag,         false, "Signals whether aspect_ratio_idc is present")
467  ("AspectRatioIdc",                 m_aspectRatioIdc,                         0, "aspect_ratio_idc")
468  ("SarWidth",                       m_sarWidth,                               0, "horizontal size of the sample aspect ratio")
469  ("SarHeight",                      m_sarHeight,                              0, "vertical size of the sample aspect ratio")
470  ("OverscanInfoPresent",            m_overscanInfoPresentFlag,            false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
471  ("OverscanAppropriate",            m_overscanAppropriateFlag,            false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
472  ("VideoSignalTypePresent",         m_videoSignalTypePresentFlag,         false, "Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present")
473  ("VideoFormat",                    m_videoFormat,                            5, "Indicates representation of pictures")
474  ("VideoFullRange",                 m_videoFullRangeFlag,                 false, "Indicates the black level and range of luma and chroma signals")
475  ("ColourDescriptionPresent",       m_colourDescriptionPresentFlag,       false, "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present")
476  ("ColourPrimaries",                m_colourPrimaries,                        2, "Indicates chromaticity coordinates of the source primaries")
477  ("TransferCharateristics",         m_transferCharacteristics,                2, "Indicates the opto-electronic transfer characteristics of the source")
478  ("MatrixCoefficients",             m_matrixCoefficients,                     2, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries")
479  ("ChromaLocInfoPresent",           m_chromaLocInfoPresentFlag,           false, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present")
480  ("ChromaSampleLocTypeTopField",    m_chromaSampleLocTypeTopField,            0, "Specifies the location of chroma samples for top field")
481  ("ChromaSampleLocTypeBottomField", m_chromaSampleLocTypeBottomField,         0, "Specifies the location of chroma samples for bottom field")
482  ("NeutralChromaIndication",        m_neutralChromaIndicationFlag,        false, "Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)")
483  ("DefaultDisplayWindowFlag",       m_defaultDisplayWindowFlag,           false, "Indicates the presence of the Default Window parameters")
484  ("DefDispWinLeftOffset",           m_defDispWinLeftOffset,                   0, "Specifies the left offset of the default display window from the conformance window")
485  ("DefDispWinRightOffset",          m_defDispWinRightOffset,                  0, "Specifies the right offset of the default display window from the conformance window")
486  ("DefDispWinTopOffset",            m_defDispWinTopOffset,                    0, "Specifies the top offset of the default display window from the conformance window")
487  ("DefDispWinBottomOffset",         m_defDispWinBottomOffset,                 0, "Specifies the bottom offset of the default display window from the conformance window")
488  ("FrameFieldInfoPresentFlag",      m_frameFieldInfoPresentFlag,               false, "Indicates that pic_struct and field coding related values are present in picture timing SEI messages")
489  ("PocProportionalToTimingFlag",   m_pocProportionalToTimingFlag,         false, "Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS")
490  ("NumTicksPocDiffOneMinus1",      m_numTicksPocDiffOneMinus1,                0, "Number of ticks minus 1 that for a POC difference of one")
491  ("BitstreamRestriction",           m_bitstreamRestrictionFlag,           false, "Signals whether bitstream restriction parameters are present")
492  ("TilesFixedStructure",            m_tilesFixedStructureFlag,            false, "Indicates that each active picture parameter set has the same values of the syntax elements related to tiles")
493  ("MotionVectorsOverPicBoundaries", m_motionVectorsOverPicBoundariesFlag, false, "Indicates that no samples outside the picture boundaries are used for inter prediction")
494  ("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")
495  ("MaxBitsPerMinCuDenom",           m_maxBitsPerMinCuDenom,                   1, "Indicates an upper bound for the number of bits of coding_unit() data")
496  ("Log2MaxMvLengthHorizontal",      m_log2MaxMvLengthHorizontal,             15, "Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units")
497  ("Log2MaxMvLengthVertical",        m_log2MaxMvLengthVertical,               15, "Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units")
498  ("SEIRecoveryPoint",               m_recoveryPointSEIEnabled,                0, "Control generation of recovery point SEI messages")
499  ("SEIBufferingPeriod",             m_bufferingPeriodSEIEnabled,              0, "Control generation of buffering period SEI messages")
500  ("SEIPictureTiming",               m_pictureTimingSEIEnabled,                0, "Control generation of picture timing SEI messages")
501#if J0149_TONE_MAPPING_SEI
502  ("SEIToneMappingInfo",                       m_toneMappingInfoSEIEnabled,    false, "Control generation of Tone Mapping SEI messages")
503  ("SEIToneMapId",                             m_toneMapId,                        0, "Specifies Id of Tone Mapping SEI message for a given session")
504  ("SEIToneMapCancelFlag",                     m_toneMapCancelFlag,            false, "Indicates that Tone Mapping SEI message cancels the persistance or follows")
505  ("SEIToneMapPersistenceFlag",                m_toneMapPersistenceFlag,        true, "Specifies the persistence of the Tone Mapping SEI message")
506  ("SEIToneMapCodedDataBitDepth",              m_toneMapCodedDataBitDepth,         8, "Specifies Coded Data BitDepth of Tone Mapping SEI messages")
507  ("SEIToneMapTargetBitDepth",                 m_toneMapTargetBitDepth,            8, "Specifies Output BitDepth of Tome mapping function")
508  ("SEIToneMapModelId",                        m_toneMapModelId,                   0, "Specifies Model utilized for mapping coded data into target_bit_depth range\n"
509                                                                                      "\t0:  linear mapping with clipping\n"
510                                                                                      "\t1:  sigmoidal mapping\n"
511                                                                                      "\t2:  user-defined table mapping\n"
512                                                                                      "\t3:  piece-wise linear mapping\n"
513                                                                                      "\t4:  luminance dynamic range information ")
514  ("SEIToneMapMinValue",                              m_toneMapMinValue,                          0, "Specifies the minimum value in mode 0")
515  ("SEIToneMapMaxValue",                              m_toneMapMaxValue,                       1023, "Specifies the maxmum value in mode 0")
516  ("SEIToneMapSigmoidMidpoint",                       m_sigmoidMidpoint,                        512, "Specifies the centre point in mode 1")
517  ("SEIToneMapSigmoidWidth",                          m_sigmoidWidth,                           960, "Specifies the distance between 5% and 95% values of the target_bit_depth in mode 1")
518  ("SEIToneMapStartOfCodedInterval",                  cfg_startOfCodedInterval,          string(""), "Array of user-defined mapping table")
519  ("SEIToneMapNumPivots",                             m_numPivots,                                0, "Specifies the number of pivot points in mode 3")
520  ("SEIToneMapCodedPivotValue",                       cfg_codedPivotValue,               string(""), "Array of pivot point")
521  ("SEIToneMapTargetPivotValue",                      cfg_targetPivotValue,              string(""), "Array of pivot point")
522  ("SEIToneMapCameraIsoSpeedIdc",                     m_cameraIsoSpeedIdc,                        0, "Indicates the camera ISO speed for daylight illumination")
523  ("SEIToneMapCameraIsoSpeedValue",                   m_cameraIsoSpeedValue,                    400, "Specifies the camera ISO speed for daylight illumination of Extended_ISO")
524  ("SEIToneMapExposureCompensationValueSignFlag",     m_exposureCompensationValueSignFlag,        0, "Specifies the sign of ExposureCompensationValue")
525  ("SEIToneMapExposureCompensationValueNumerator",    m_exposureCompensationValueNumerator,       0, "Specifies the numerator of ExposureCompensationValue")
526  ("SEIToneMapExposureCompensationValueDenomIdc",     m_exposureCompensationValueDenomIdc,        2, "Specifies the denominator of ExposureCompensationValue")
527  ("SEIToneMapRefScreenLuminanceWhite",               m_refScreenLuminanceWhite,                350, "Specifies reference screen brightness setting in units of candela per square metre")
528  ("SEIToneMapExtendedRangeWhiteLevel",               m_extendedRangeWhiteLevel,                800, "Indicates the luminance dynamic range")
529  ("SEIToneMapNominalBlackLevelLumaCodeValue",        m_nominalBlackLevelLumaCodeValue,          16, "Specifies luma sample value of the nominal black level assigned decoded pictures")
530  ("SEIToneMapNominalWhiteLevelLumaCodeValue",        m_nominalWhiteLevelLumaCodeValue,         235, "Specifies luma sample value of the nominal white level assigned decoded pictures")
531  ("SEIToneMapExtendedWhiteLevelLumaCodeValue",       m_extendedWhiteLevelLumaCodeValue,        300, "Specifies luma sample value of the extended dynamic range assigned decoded pictures")
532#endif
533  ("SEIFramePacking",                m_framePackingSEIEnabled,                 0, "Control generation of frame packing SEI messages")
534  ("SEIFramePackingType",            m_framePackingSEIType,                    0, "Define frame packing arrangement\n"
535                                                                                  "\t0: checkerboard - pixels alternatively represent either frames\n"
536                                                                                  "\t1: column alternation - frames are interlaced by column\n"
537                                                                                  "\t2: row alternation - frames are interlaced by row\n"
538                                                                                  "\t3: side by side - frames are displayed horizontally\n"
539                                                                                  "\t4: top bottom - frames are displayed vertically\n"
540                                                                                  "\t5: frame alternation - one frame is alternated with the other")
541  ("SEIFramePackingId",              m_framePackingSEIId,                      0, "Id of frame packing SEI message for a given session")
542  ("SEIFramePackingQuincunx",        m_framePackingSEIQuincunx,                0, "Indicate the presence of a Quincunx type video frame")
543  ("SEIFramePackingInterpretation",  m_framePackingSEIInterpretation,          0, "Indicate the interpretation of the frame pair\n"
544                                                                                  "\t0: unspecified\n"
545                                                                                  "\t1: stereo pair, frame0 represents left view\n"
546                                                                                  "\t2: stereo pair, frame0 represents right view")
547  ("SEIDisplayOrientation",          m_displayOrientationSEIAngle,             0, "Control generation of display orientation SEI messages\n"
548                                                              "\tN: 0 < N < (2^16 - 1) enable display orientation SEI message with anticlockwise_rotation = N and display_orientation_repetition_period = 1\n"
549                                                              "\t0: disable")
550  ("SEITemporalLevel0Index",         m_temporalLevel0IndexSEIEnabled,          0, "Control generation of temporal level 0 index SEI messages")
551  ("SEIGradualDecodingRefreshInfo",  m_gradualDecodingRefreshInfoEnabled,      0, "Control generation of gradual decoding refresh information SEI message")
552  ("SEIDecodingUnitInfo",             m_decodingUnitInfoSEIEnabled,                       0, "Control generation of decoding unit information SEI message.")
553#if L0208_SOP_DESCRIPTION_SEI
554  ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0, "Control generation of SOP description SEI messages")
555#endif
556#if K0180_SCALABLE_NESTING_SEI
557  ("SEIScalableNesting",             m_scalableNestingSEIEnabled,              0, "Control generation of scalable nesting SEI messages")
558#endif
559#if SIGNAL_BITRATE_PICRATE_IN_VPS
560  ("BitRatePicRateMaxTLayers",   m_bitRatePicRateMaxTLayers,           0, "Maximum number of sub-layers signalled; can be inferred otherwise; here for easy parsing of config. file")
561  ("BitRateInfoPresent",         cfg_bitRateInfoPresentFlag,          string(""), "Control signalling of bit rate information of avg. bit rate and max. bit rate in VPS\n"
562                                                                          "\t0: Do not sent bit rate info\n"
563                                                                          "\tN (N > 0): Send bit rate info for N sub-layers. N should equal maxTempLayers.")                                                                     
564  ("PicRateInfoPresent",         cfg_picRateInfoPresentFlag,          string(""), "Control signalling of picture rate information of avg. bit rate and max. bit rate in VPS\n"
565                                                                          "\t0: Do not sent picture rate info\n"
566                                                                          "\tN (N > 0): Send picture rate info for N sub-layers. N should equal maxTempLayers.")                                                                     
567  ("AvgBitRate",                   cfg_avgBitRate,                    string(""), "List of avg. bit rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
568  ("MaxBitRate",                   cfg_maxBitRate,                    string(""), "List of max. bit rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
569  ("AvgPicRate",                   cfg_avgPicRate,                    string(""), "List of avg. picture rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
570  ("ConstantPicRateIdc",           cfg_constantPicRateIdc,            string(""), "List of constant picture rate IDCs; include non-negative number even if corresponding flag is 0")
571#endif
572  ;
573 
574  for(Int i=1; i<MAX_GOP+1; i++) {
575    std::ostringstream cOSS;
576    cOSS<<"Frame"<<i;
577    opts.addOptions()(cOSS.str(), m_GOPList[i-1], GOPEntry());
578  }
579  po::setDefaults(opts);
580  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
581
582  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
583  {
584    fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
585  }
586 
587  if (argc == 1 || do_help)
588  {
589    /* argc == 1: no options have been specified */
590    po::doHelp(cout, opts);
591    return false;
592  }
593 
594  /*
595   * Set any derived parameters
596   */
597  /* convert std::string to c string for compatability */
598  m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str());
599  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
600  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
601  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
602 
603  Char* pColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
604  Char* pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
605  if( m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0 )
606  {
607    char *columnWidth;
608    int  i=0;
609    m_pColumnWidth = new UInt[m_iNumColumnsMinus1];
610    columnWidth = strtok(pColumnWidth, " ,-");
611    while(columnWidth!=NULL)
612    {
613      if( i>=m_iNumColumnsMinus1 )
614      {
615        printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" );
616        exit( EXIT_FAILURE );
617      }
618      *( m_pColumnWidth + i ) = atoi( columnWidth );
619      columnWidth = strtok(NULL, " ,-");
620      i++;
621    }
622    if( i<m_iNumColumnsMinus1 )
623    {
624      printf( "The width of some columns is not defined.\n" );
625      exit( EXIT_FAILURE );
626    }
627  }
628  else
629  {
630    m_pColumnWidth = NULL;
631  }
632
633  if( m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0 )
634  {
635    char *rowHeight;
636    int  i=0;
637    m_pRowHeight = new UInt[m_iNumRowsMinus1];
638    rowHeight = strtok(pRowHeight, " ,-");
639    while(rowHeight!=NULL)
640    {
641      if( i>=m_iNumRowsMinus1 )
642      {
643        printf( "The number of rows whose height are defined is larger than the allowed number of rows.\n" );
644        exit( EXIT_FAILURE );
645      }
646      *( m_pRowHeight + i ) = atoi( rowHeight );
647      rowHeight = strtok(NULL, " ,-");
648      i++;
649    }
650    if( i<m_iNumRowsMinus1 )
651    {
652      printf( "The height of some rows is not defined.\n" );
653      exit( EXIT_FAILURE );
654   }
655  }
656  else
657  {
658    m_pRowHeight = NULL;
659  }
660#if SIGNAL_BITRATE_PICRATE_IN_VPS
661  readBoolString(cfg_bitRateInfoPresentFlag, m_bitRatePicRateMaxTLayers, m_bitRateInfoPresentFlag, "bit rate info. present flag" );
662  readIntString (cfg_avgBitRate,             m_bitRatePicRateMaxTLayers, m_avgBitRate,             "avg. bit rate"               );
663  readIntString (cfg_maxBitRate,             m_bitRatePicRateMaxTLayers, m_maxBitRate,             "max. bit rate"               );
664  readBoolString(cfg_picRateInfoPresentFlag, m_bitRatePicRateMaxTLayers, m_picRateInfoPresentFlag, "bit rate info. present flag" );
665  readIntString (cfg_avgPicRate,             m_bitRatePicRateMaxTLayers, m_avgPicRate,             "avg. pic rate"               );
666  readIntString (cfg_constantPicRateIdc,     m_bitRatePicRateMaxTLayers, m_constantPicRateIdc,     "constant pic rate Idc"       );
667#endif
668  m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
669 
670  /* rules for input, output and internal bitdepths as per help text */
671  if (!m_internalBitDepthY) { m_internalBitDepthY = m_inputBitDepthY; }
672  if (!m_internalBitDepthC) { m_internalBitDepthC = m_internalBitDepthY; }
673  if (!m_inputBitDepthC) { m_inputBitDepthC = m_inputBitDepthY; }
674  if (!m_outputBitDepthY) { m_outputBitDepthY = m_internalBitDepthY; }
675  if (!m_outputBitDepthC) { m_outputBitDepthC = m_internalBitDepthC; }
676
677  // TODO:ChromaFmt assumes 4:2:0 below
678  switch (m_conformanceMode)
679  {
680  case 0:
681    {
682      // no conformance or padding
683      m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
684      m_aiPad[1] = m_aiPad[0] = 0;
685      break;
686    }
687  case 1:
688    {
689      // automatic padding to minimum CU size
690      Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1);
691      if (m_iSourceWidth % minCuSize)
692      {
693        m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
694        m_iSourceWidth  += m_confRight;
695      }
696      if (m_iSourceHeight % minCuSize)
697      {
698        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
699        m_iSourceHeight += m_confBottom;
700      }
701      if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0)
702      {
703        fprintf(stderr, "Error: picture width is not an integer multiple of the specified chroma subsampling\n");
704        exit(EXIT_FAILURE);
705      }
706      if (m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0)
707      {
708        fprintf(stderr, "Error: picture height is not an integer multiple of the specified chroma subsampling\n");
709        exit(EXIT_FAILURE);
710      }
711      break;
712    }
713  case 2:
714    {
715      //padding
716      m_iSourceWidth  += m_aiPad[0];
717      m_iSourceHeight += m_aiPad[1];
718      m_confRight  = m_aiPad[0];
719      m_confBottom = m_aiPad[1];
720      break;
721    }
722  case 3:
723    {
724      // conformance
725      if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
726      {
727        fprintf(stderr, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n");
728      }
729      if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0))
730      {
731        fprintf(stderr, "Warning: Conformance window enabled, padding parameters will be ignored\n");
732      }
733      m_aiPad[1] = m_aiPad[0] = 0;
734      break;
735    }
736  }
737 
738  // allocate slice-based dQP values
739  m_aidQP = new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ];
740  ::memset( m_aidQP, 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
741 
742  // handling of floating-point QP values
743  // if QP is not integer, sequence is split into two sections having QP and QP+1
744  m_iQP = (Int)( m_fQP );
745  if ( m_iQP < m_fQP )
746  {
747    Int iSwitchPOC = (Int)( m_framesToBeEncoded - (m_fQP - m_iQP)*m_framesToBeEncoded + 0.5 );
748   
749    iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
750    for ( Int i=iSwitchPOC; i<m_framesToBeEncoded + m_iGOPSize + 1; i++ )
751    {
752      m_aidQP[i] = 1;
753    }
754  }
755 
756  // reading external dQP description from file
757  if ( m_pchdQPFile )
758  {
759    FILE* fpt=fopen( m_pchdQPFile, "r" );
760    if ( fpt )
761    {
762      Int iValue;
763      Int iPOC = 0;
764      while ( iPOC < m_framesToBeEncoded )
765      {
766        if ( fscanf(fpt, "%d", &iValue ) == EOF ) break;
767        m_aidQP[ iPOC ] = iValue;
768        iPOC++;
769      }
770      fclose(fpt);
771    }
772  }
773  m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
774
775#if J0149_TONE_MAPPING_SEI
776  if( m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag )
777  {
778    Char* pcStartOfCodedInterval = cfg_startOfCodedInterval.empty() ? NULL: strdup(cfg_startOfCodedInterval.c_str());
779    Char* pcCodedPivotValue = cfg_codedPivotValue.empty() ? NULL: strdup(cfg_codedPivotValue.c_str());
780    Char* pcTargetPivotValue = cfg_targetPivotValue.empty() ? NULL: strdup(cfg_targetPivotValue.c_str());
781    if( m_toneMapModelId == 2 && pcStartOfCodedInterval )
782    {
783      char *startOfCodedInterval;
784      UInt num = 1u<< m_toneMapTargetBitDepth;
785      m_startOfCodedInterval = new Int[num];
786      ::memset( m_startOfCodedInterval, 0, sizeof(Int)*num );
787      startOfCodedInterval = strtok(pcStartOfCodedInterval, " .");
788      int i = 0;
789      while( startOfCodedInterval && ( i < num ) )
790      {
791        m_startOfCodedInterval[i] = atoi( startOfCodedInterval );
792        startOfCodedInterval = strtok(NULL, " .");
793        i++;
794      }
795    } 
796    else
797    {
798      m_startOfCodedInterval = NULL;
799    }
800    if( ( m_toneMapModelId == 3 ) && ( m_numPivots > 0 ) )
801    {
802      if( pcCodedPivotValue && pcTargetPivotValue )
803      {
804        char *codedPivotValue;
805        char *targetPivotValue;
806        m_codedPivotValue = new Int[m_numPivots];
807        m_targetPivotValue = new Int[m_numPivots];
808        ::memset( m_codedPivotValue, 0, sizeof(Int)*( m_numPivots ) );
809        ::memset( m_targetPivotValue, 0, sizeof(Int)*( m_numPivots ) );
810        codedPivotValue = strtok(pcCodedPivotValue, " .");
811        int i=0;
812        while(codedPivotValue&&i<m_numPivots)
813        {
814          m_codedPivotValue[i] = atoi( codedPivotValue );
815          codedPivotValue = strtok(NULL, " .");
816          i++;
817        }
818        i=0;
819        targetPivotValue = strtok(pcTargetPivotValue, " .");
820        while(targetPivotValue&&i<m_numPivots)
821        {
822          m_targetPivotValue[i]= atoi( targetPivotValue );
823          targetPivotValue = strtok(NULL, " .");
824          i++;
825        }
826      }
827    }
828    else
829    {
830      m_codedPivotValue = NULL;
831      m_targetPivotValue = NULL;
832    }
833  }
834#endif
835  // check validity of input parameters
836  xCheckParameter();
837 
838  // set global varibles
839  xSetGlobal();
840 
841  // print-out parameters
842  xPrintParameter();
843 
844  return true;
845}
846#if SIGNAL_BITRATE_PICRATE_IN_VPS
847Void readBoolString(const string inpString, const Int numEntries, Bool* &memberArray, const char *elementName)
848{
849  Char* inpArray = inpString.empty() ? NULL : strdup(inpString.c_str());
850  Int i = 0;
851  if(numEntries)
852  {
853    Char* tempArray = strtok(inpArray, " ,-");
854    memberArray = new Bool[numEntries];
855    while( tempArray != NULL )
856    {
857      if( i >= numEntries )
858      {
859        printf( "The number of %s defined is larger than the allowed number\n", elementName );
860        exit( EXIT_FAILURE );
861      }
862      assert( (atoi(tempArray) == 0) || (atoi(tempArray) == 1) );
863      *( memberArray + i ) = atoi(tempArray);
864      tempArray = strtok(NULL, " ,-");
865      i++;
866    }
867    if( i < numEntries )
868    {
869      printf( "Some %s are not defined\n", elementName );
870      exit( EXIT_FAILURE );
871    }
872  }
873  else
874  {
875    memberArray = NULL;
876  }
877}
878
879Void readIntString(const string inpString, const Int numEntries, Int* &memberArray, const char *elementName)
880{
881  Char* inpArray = inpString.empty() ? NULL : strdup(inpString.c_str());
882  Int i = 0;
883  if(numEntries)
884  {
885    Char* tempArray = strtok(inpArray, " ,-");
886    memberArray = new Int[numEntries];
887    while( tempArray != NULL )
888    {
889      if( i >= numEntries )
890      {
891        printf( "The number of %s defined is larger than the allowed number\n", elementName );
892        exit( EXIT_FAILURE );
893      }
894      *( memberArray + i ) = atoi(tempArray);
895      tempArray = strtok(NULL, " ,-");
896      i++;
897    }
898    if( i < numEntries )
899    {
900      printf( "Some %s are not defined\n", elementName );
901      exit( EXIT_FAILURE );
902    }
903  }
904  else
905  {
906    memberArray = NULL;
907  }
908}
909#endif
910// ====================================================================================================================
911// Private member functions
912// ====================================================================================================================
913
914Bool confirmPara(Bool bflag, const Char* message);
915
916Void TAppEncCfg::xCheckParameter()
917{
918  if (!m_decodedPictureHashSEIEnabled)
919  {
920    fprintf(stderr, "******************************************************************\n");
921    fprintf(stderr, "** WARNING: --SEIDecodedPictureHash is now disabled by default. **\n");
922    fprintf(stderr, "**          Automatic verification of decoded pictures by a     **\n");
923    fprintf(stderr, "**          decoder requires this option to be enabled.         **\n");
924    fprintf(stderr, "******************************************************************\n");
925  }
926
927  Bool check_failed = false; /* abort if there is a fatal configuration problem */
928#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
929  // check range of parameters
930  xConfirmPara( m_inputBitDepthY < 8,                                                     "InputBitDepth must be at least 8" );
931  xConfirmPara( m_inputBitDepthC < 8,                                                     "InputBitDepthC must be at least 8" );
932  xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
933  xConfirmPara( m_framesToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 0" );
934  xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
935  xConfirmPara( m_iGOPSize > 1 &&  m_iGOPSize % 2,                                          "GOP Size must be a multiple of 2, if GOP Size is greater than 1" );
936  xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
937  xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
938  xConfirmPara( m_iQP <  -6 * (m_internalBitDepthY - 8) || m_iQP > 51,                    "QP exceeds supported range (-QpBDOffsety to 51)" );
939  xConfirmPara( m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13,          "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)");
940  xConfirmPara( m_loopFilterTcOffsetDiv2 < -13 || m_loopFilterTcOffsetDiv2 > 13,              "Loop Filter Tc Offset div. 2 exceeds supported range (-13 to 13)");
941  xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2,                                     "Fast Search Mode is not supported value (0:Full search  1:Diamond  2:PMVFAST)" );
942  xConfirmPara( m_iSearchRange < 0 ,                                                        "Search Range must be more than 0" );
943  xConfirmPara( m_bipredSearchRange < 0 ,                                                   "Search Range must be more than 0" );
944  xConfirmPara( m_iMaxDeltaQP > 7,                                                          "Absolute Delta QP exceeds supported range (0 to 7)" );
945  xConfirmPara( m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1,                                          "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" );
946
947  xConfirmPara( m_cbQpOffset < -12,   "Min. Chroma Cb QP Offset is -12" );
948  xConfirmPara( m_cbQpOffset >  12,   "Max. Chroma Cb QP Offset is  12" );
949  xConfirmPara( m_crQpOffset < -12,   "Min. Chroma Cr QP Offset is -12" );
950  xConfirmPara( m_crQpOffset >  12,   "Max. Chroma Cr QP Offset is  12" );
951
952  xConfirmPara( m_iQPAdaptationRange <= 0,                                                  "QP Adaptation Range must be more than 0" );
953  if (m_iDecodingRefreshType == 2)
954  {
955    xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
956  }
957  xConfirmPara( (m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,                                    "Minimum partition width size should be larger than or equal to 8");
958  xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4,                                    "Minimum partition height size should be larger than or equal to 8");
959  xConfirmPara( m_uiMaxCUWidth < 16,                                                        "Maximum partition width size should be larger than or equal to 16");
960  xConfirmPara( m_uiMaxCUHeight < 16,                                                       "Maximum partition height size should be larger than or equal to 16");
961  xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame width must be a multiple of the minimum CU size");
962  xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame height must be a multiple of the minimum CU size");
963 
964  xConfirmPara( m_uiQuadtreeTULog2MinSize < 2,                                        "QuadtreeTULog2MinSize must be 2 or greater.");
965  xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5,                                        "QuadtreeTULog2MaxSize must be 5 or smaller.");
966  xConfirmPara( (1<<m_uiQuadtreeTULog2MaxSize) > m_uiMaxCUWidth,                                        "QuadtreeTULog2MaxSize must be log2(maxCUSize) or smaller.");
967 
968  xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize,                "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize.");
969  xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS
970  xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUHeight>>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS
971  xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUWidth  >> m_uiMaxCUDepth ), "Minimum CU width must be greater than minimum transform size." );
972  xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." );
973  xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1,                                                         "QuadtreeTUMaxDepthInter must be greater than or equal to 1" );
974  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" );
975  xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1,                                                         "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" );
976  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" );
977 
978  xConfirmPara(  m_maxNumMergeCand < 1,  "MaxNumMergeCand must be 1 or greater.");
979  xConfirmPara(  m_maxNumMergeCand > 5,  "MaxNumMergeCand must be 5 or smaller.");
980
981#if ADAPTIVE_QP_SELECTION
982  xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
983  xConfirmPara( m_bUseAdaptQpSelect == true && (m_cbQpOffset !=0 || m_crQpOffset != 0 ),               "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0.");
984#endif
985
986  if( m_usePCM)
987  {
988    xConfirmPara(  m_uiPCMLog2MinSize < 3,                                      "PCMLog2MinSize must be 3 or greater.");
989    xConfirmPara(  m_uiPCMLog2MinSize > 5,                                      "PCMLog2MinSize must be 5 or smaller.");
990    xConfirmPara(  m_pcmLog2MaxSize > 5,                                        "PCMLog2MaxSize must be 5 or smaller.");
991    xConfirmPara(  m_pcmLog2MaxSize < m_uiPCMLog2MinSize,                       "PCMLog2MaxSize must be equal to or greater than m_uiPCMLog2MinSize.");
992  }
993
994  xConfirmPara( m_sliceMode < 0 || m_sliceMode > 3, "SliceMode exceeds supported range (0 to 3)" );
995  if (m_sliceMode!=0)
996  {
997    xConfirmPara( m_sliceArgument < 1 ,         "SliceArgument should be larger than or equal to 1" );
998  }
999  xConfirmPara( m_sliceSegmentMode < 0 || m_sliceSegmentMode > 3, "SliceSegmentMode exceeds supported range (0 to 3)" );
1000  if (m_sliceSegmentMode!=0)
1001  {
1002    xConfirmPara( m_sliceSegmentArgument < 1 ,         "SliceSegmentArgument should be larger than or equal to 1" );
1003  }
1004 
1005  Bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 );
1006  xConfirmPara( tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
1007
1008  //TODO:ChromaFmt assumes 4:2:0 below
1009  xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
1010  xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
1011
1012  xConfirmPara( m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
1013  xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
1014
1015  xConfirmPara( m_confLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
1016  xConfirmPara( m_confRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
1017  xConfirmPara( m_confTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
1018  xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
1019
1020  // max CU width and height should be power of 2
1021  UInt ui = m_uiMaxCUWidth;
1022  while(ui)
1023  {
1024    ui >>= 1;
1025    if( (ui & 1) == 1)
1026      xConfirmPara( ui != 1 , "Width should be 2^n");
1027  }
1028  ui = m_uiMaxCUHeight;
1029  while(ui)
1030  {
1031    ui >>= 1;
1032    if( (ui & 1) == 1)
1033      xConfirmPara( ui != 1 , "Height should be 2^n");
1034  }
1035
1036  /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure
1037   * This permits the ability to omit a GOP structure specification */
1038  if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1) {
1039    m_GOPList[0] = GOPEntry();
1040    m_GOPList[0].m_QPFactor = 1;
1041    m_GOPList[0].m_betaOffsetDiv2 = 0;
1042    m_GOPList[0].m_tcOffsetDiv2 = 0;
1043    m_GOPList[0].m_POC = 1;
1044    m_GOPList[0].m_numRefPicsActive = 4;
1045  }
1046 
1047  Bool verifiedGOP=false;
1048  Bool errorGOP=false;
1049  Int checkGOP=1;
1050  Int numRefs = 1;
1051  Int refList[MAX_NUM_REF_PICS+1];
1052  refList[0]=0;
1053  Bool isOK[MAX_GOP];
1054  for(Int i=0; i<MAX_GOP; i++) 
1055  {
1056    isOK[i]=false;
1057  }
1058  Int numOK=0;
1059  xConfirmPara( m_iIntraPeriod >=0&&(m_iIntraPeriod%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" );
1060
1061  for(Int i=0; i<m_iGOPSize; i++)
1062  {
1063    if(m_GOPList[i].m_POC==m_iGOPSize)
1064    {
1065      xConfirmPara( m_GOPList[i].m_temporalId!=0 , "The last frame in each GOP must have temporal ID = 0 " );
1066    }
1067  }
1068 
1069  if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable) )
1070  {
1071    for(Int i=0; i<m_iGOPSize; i++)
1072    {
1073      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)" );
1074      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)" );
1075    }
1076  }
1077  m_extraRPSs=0;
1078  //start looping through frames in coding order until we can verify that the GOP structure is correct.
1079  while(!verifiedGOP&&!errorGOP) 
1080  {
1081    Int curGOP = (checkGOP-1)%m_iGOPSize;
1082    Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + m_GOPList[curGOP].m_POC;   
1083    if(m_GOPList[curGOP].m_POC<0) 
1084    {
1085      printf("\nError: found fewer Reference Picture Sets than GOPSize\n");
1086      errorGOP=true;
1087    }
1088    else 
1089    {
1090      //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
1091      Bool beforeI = false;
1092      for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) 
1093      {
1094        Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i];
1095        if(absPOC < 0)
1096        {
1097          beforeI=true;
1098        }
1099        else 
1100        {
1101          Bool found=false;
1102          for(Int j=0; j<numRefs; j++) 
1103          {
1104            if(refList[j]==absPOC) 
1105            {
1106              found=true;
1107              for(Int k=0; k<m_iGOPSize; k++)
1108              {
1109                if(absPOC%m_iGOPSize == m_GOPList[k].m_POC%m_iGOPSize)
1110                {
1111                  if(m_GOPList[k].m_temporalId==m_GOPList[curGOP].m_temporalId)
1112                  {
1113                    m_GOPList[k].m_refPic = true;
1114                  }
1115                  m_GOPList[curGOP].m_usedByCurrPic[i]=m_GOPList[k].m_temporalId<=m_GOPList[curGOP].m_temporalId;
1116                }
1117              }
1118            }
1119          }
1120          if(!found)
1121          {
1122            printf("\nError: ref pic %d is not available for GOP frame %d\n",m_GOPList[curGOP].m_referencePics[i],curGOP+1);
1123            errorGOP=true;
1124          }
1125        }
1126      }
1127      if(!beforeI&&!errorGOP)
1128      {
1129        //all ref frames were present
1130        if(!isOK[curGOP]) 
1131        {
1132          numOK++;
1133          isOK[curGOP]=true;
1134          if(numOK==m_iGOPSize)
1135          {
1136            verifiedGOP=true;
1137          }
1138        }
1139      }
1140      else 
1141      {
1142        //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
1143        m_GOPList[m_iGOPSize+m_extraRPSs]=m_GOPList[curGOP];
1144        Int newRefs=0;
1145        for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) 
1146        {
1147          Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i];
1148          if(absPOC>=0)
1149          {
1150            m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[newRefs]=m_GOPList[curGOP].m_referencePics[i];
1151            m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[newRefs]=m_GOPList[curGOP].m_usedByCurrPic[i];
1152            newRefs++;
1153          }
1154        }
1155        Int numPrefRefs = m_GOPList[curGOP].m_numRefPicsActive;
1156       
1157        for(Int offset = -1; offset>-checkGOP; offset--)
1158        {
1159          //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
1160          Int offGOP = (checkGOP-1+offset)%m_iGOPSize;
1161          Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + m_GOPList[offGOP].m_POC;
1162          if(offPOC>=0&&m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId)
1163          {
1164            Bool newRef=false;
1165            for(Int i=0; i<numRefs; i++)
1166            {
1167              if(refList[i]==offPOC)
1168              {
1169                newRef=true;
1170              }
1171            }
1172            for(Int i=0; i<newRefs; i++) 
1173            {
1174              if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[i]==offPOC-curPOC)
1175              {
1176                newRef=false;
1177              }
1178            }
1179            if(newRef) 
1180            {
1181              Int insertPoint=newRefs;
1182              //this picture can be added, find appropriate place in list and insert it.
1183              if(m_GOPList[offGOP].m_temporalId==m_GOPList[curGOP].m_temporalId)
1184              {
1185                m_GOPList[offGOP].m_refPic = true;
1186              }
1187              for(Int j=0; j<newRefs; j++)
1188              {
1189                if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]<offPOC-curPOC||m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]>0)
1190                {
1191                  insertPoint = j;
1192                  break;
1193                }
1194              }
1195              Int prev = offPOC-curPOC;
1196              Int prevUsed = m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId;
1197              for(Int j=insertPoint; j<newRefs+1; j++)
1198              {
1199                Int newPrev = m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j];
1200                Int newUsed = m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j];
1201                m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]=prev;
1202                m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]=prevUsed;
1203                prevUsed=newUsed;
1204                prev=newPrev;
1205              }
1206              newRefs++;
1207            }
1208          }
1209          if(newRefs>=numPrefRefs)
1210          {
1211            break;
1212          }
1213        }
1214        m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics=newRefs;
1215        m_GOPList[m_iGOPSize+m_extraRPSs].m_POC = curPOC;
1216        if (m_extraRPSs == 0)
1217        {
1218          m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 0;
1219          m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = 0;
1220        }
1221        else
1222        {
1223          Int rIdx =  m_iGOPSize + m_extraRPSs - 1;
1224          Int refPOC = m_GOPList[rIdx].m_POC;
1225          Int refPics = m_GOPList[rIdx].m_numRefPics;
1226          Int newIdc=0;
1227          for(Int i = 0; i<= refPics; i++) 
1228          {
1229            Int deltaPOC = ((i != refPics)? m_GOPList[rIdx].m_referencePics[i] : 0);  // check if the reference abs POC is >= 0
1230            Int absPOCref = refPOC+deltaPOC;
1231            Int refIdc = 0;
1232            for (Int j = 0; j < m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics; j++)
1233            {
1234              if ( (absPOCref - curPOC) == m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j])
1235              {
1236                if (m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j])
1237                {
1238                  refIdc = 1;
1239                }
1240                else
1241                {
1242                  refIdc = 2;
1243                }
1244              }
1245            }
1246            m_GOPList[m_iGOPSize+m_extraRPSs].m_refIdc[newIdc]=refIdc;
1247            newIdc++;
1248          }
1249          m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 1; 
1250          m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = newIdc;
1251          m_GOPList[m_iGOPSize+m_extraRPSs].m_deltaRPS = refPOC - m_GOPList[m_iGOPSize+m_extraRPSs].m_POC; 
1252        }
1253        curGOP=m_iGOPSize+m_extraRPSs;
1254        m_extraRPSs++;
1255      }
1256      numRefs=0;
1257      for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) 
1258      {
1259        Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i];
1260        if(absPOC >= 0) 
1261        {
1262          refList[numRefs]=absPOC;
1263          numRefs++;
1264        }
1265      }
1266      refList[numRefs]=curPOC;
1267      numRefs++;
1268    }
1269    checkGOP++;
1270  }
1271  xConfirmPara(errorGOP,"Invalid GOP structure given");
1272  m_maxTempLayer = 1;
1273  for(Int i=0; i<m_iGOPSize; i++) 
1274  {
1275    if(m_GOPList[i].m_temporalId >= m_maxTempLayer)
1276    {
1277      m_maxTempLayer = m_GOPList[i].m_temporalId+1;
1278    }
1279    xConfirmPara(m_GOPList[i].m_sliceType!='B'&&m_GOPList[i].m_sliceType!='P', "Slice type must be equal to B or P");
1280  }
1281  for(Int i=0; i<MAX_TLAYER; i++)
1282  {
1283    m_numReorderPics[i] = 0;
1284#if L0323_DPB
1285    m_maxDecPicBuffering[i] = 1;
1286#else
1287    m_maxDecPicBuffering[i] = 0;
1288#endif
1289  }
1290  for(Int i=0; i<m_iGOPSize; i++) 
1291  {
1292#if L0323_DPB
1293    if(m_GOPList[i].m_numRefPics+1 > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
1294#else
1295    if(m_GOPList[i].m_numRefPics > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
1296#endif
1297    {
1298#if L0323_DPB
1299      m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics + 1;
1300#else
1301      m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics;
1302#endif
1303    }
1304    Int highestDecodingNumberWithLowerPOC = 0; 
1305    for(Int j=0; j<m_iGOPSize; j++)
1306    {
1307      if(m_GOPList[j].m_POC <= m_GOPList[i].m_POC)
1308      {
1309        highestDecodingNumberWithLowerPOC = j;
1310      }
1311    }
1312    Int numReorder = 0;
1313    for(Int j=0; j<highestDecodingNumberWithLowerPOC; j++)
1314    {
1315      if(m_GOPList[j].m_temporalId <= m_GOPList[i].m_temporalId && 
1316        m_GOPList[j].m_POC > m_GOPList[i].m_POC)
1317      {
1318        numReorder++;
1319      }
1320    }   
1321    if(numReorder > m_numReorderPics[m_GOPList[i].m_temporalId])
1322    {
1323      m_numReorderPics[m_GOPList[i].m_temporalId] = numReorder;
1324    }
1325  }
1326  for(Int i=0; i<MAX_TLAYER-1; i++) 
1327  {
1328    // a lower layer can not have higher value of m_numReorderPics than a higher layer
1329    if(m_numReorderPics[i+1] < m_numReorderPics[i])
1330    {
1331      m_numReorderPics[i+1] = m_numReorderPics[i];
1332    }
1333#if L0323_DPB
1334    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive
1335    if(m_numReorderPics[i] > m_maxDecPicBuffering[i] - 1)
1336    {
1337      m_maxDecPicBuffering[i] = m_numReorderPics[i] + 1;
1338    }
1339#else
1340    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
1341    if(m_numReorderPics[i] > m_maxDecPicBuffering[i])
1342    {
1343      m_maxDecPicBuffering[i] = m_numReorderPics[i];
1344    }
1345#endif
1346    // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
1347    if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i])
1348    {
1349      m_maxDecPicBuffering[i+1] = m_maxDecPicBuffering[i];
1350    }
1351  }
1352
1353
1354#if L0323_DPB
1355  // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] -  1, inclusive
1356  if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1)
1357  {
1358    m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1;
1359  }
1360#else
1361  // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
1362  if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1])
1363  {
1364    m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1];
1365  }
1366#endif
1367
1368  if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
1369  { 
1370    Int PicSizeInSamplesY =  m_iSourceWidth * m_iSourceHeight;
1371    if(tileFlag)
1372    {
1373      Int maxTileWidth = 0;
1374      Int maxTileHeight = 0;
1375      Int widthInCU = (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth/m_uiMaxCUWidth + 1: m_iSourceWidth/m_uiMaxCUWidth;
1376      Int heightInCU = (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight/m_uiMaxCUHeight + 1: m_iSourceHeight/m_uiMaxCUHeight;
1377      if(m_iUniformSpacingIdr)
1378      {
1379        maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_iNumColumnsMinus1)/(m_iNumColumnsMinus1+1));
1380        maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_iNumRowsMinus1)/(m_iNumRowsMinus1+1));
1381        // if only the last tile-row is one treeblock higher than the others
1382        // the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others
1383        if(!((heightInCU-1)%(m_iNumRowsMinus1+1)))
1384        {
1385          maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight);
1386        }     
1387        // if only the last tile-column is one treeblock wider than the others
1388        // the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others   
1389        if(!((widthInCU-1)%(m_iNumColumnsMinus1+1)))
1390        {
1391          maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth);
1392        }
1393      }
1394      else // not uniform spacing
1395      {
1396        if(m_iNumColumnsMinus1<1)
1397        {
1398          maxTileWidth = m_iSourceWidth;
1399        }
1400        else
1401        {
1402          Int accColumnWidth = 0;
1403          for(Int col=0; col<(m_iNumColumnsMinus1); col++)
1404          {
1405            maxTileWidth = m_pColumnWidth[col]>maxTileWidth ? m_pColumnWidth[col]:maxTileWidth;
1406            accColumnWidth += m_pColumnWidth[col];
1407          }
1408          maxTileWidth = (widthInCU-accColumnWidth)>maxTileWidth ? m_uiMaxCUWidth*(widthInCU-accColumnWidth):m_uiMaxCUWidth*maxTileWidth;
1409        }
1410        if(m_iNumRowsMinus1<1)
1411        {
1412          maxTileHeight = m_iSourceHeight;
1413        }
1414        else
1415        {
1416          Int accRowHeight = 0;
1417          for(Int row=0; row<(m_iNumRowsMinus1); row++)
1418          {
1419            maxTileHeight = m_pRowHeight[row]>maxTileHeight ? m_pRowHeight[row]:maxTileHeight;
1420            accRowHeight += m_pRowHeight[row];
1421          }
1422          maxTileHeight = (heightInCU-accRowHeight)>maxTileHeight ? m_uiMaxCUHeight*(heightInCU-accRowHeight):m_uiMaxCUHeight*maxTileHeight;
1423        }
1424      }
1425      Int maxSizeInSamplesY = maxTileWidth*maxTileHeight;
1426      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/maxSizeInSamplesY-4;
1427    }
1428    else if(m_iWaveFrontSynchro)
1429    {
1430      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/((2*m_iSourceHeight+m_iSourceWidth)*m_uiMaxCUHeight)-4;
1431    }
1432    else if(m_sliceMode == 1)
1433    {
1434      m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/(m_sliceArgument*m_uiMaxCUWidth*m_uiMaxCUHeight)-4;
1435    }
1436    else
1437    {
1438      m_minSpatialSegmentationIdc = 0;
1439    }
1440  }
1441#if !L0034_COMBINED_LIST_CLEANUP
1442  xConfirmPara( m_bUseLComb==false && m_numReorderPics[MAX_TLAYER-1]!=0, "ListCombination can only be 0 in low delay coding (more precisely when L0 and L1 are identical)" );  // Note however this is not the full necessary condition as ref_pic_list_combination_flag can only be 0 if L0 == L1.
1443#endif
1444  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
1445  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
1446  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
1447
1448  xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n");
1449
1450#if J0149_TONE_MAPPING_SEI
1451  if (m_toneMappingInfoSEIEnabled)
1452  {
1453    xConfirmPara( m_toneMapCodedDataBitDepth < 8 || m_toneMapCodedDataBitDepth > 14 , "SEIToneMapCodedDataBitDepth must be in rage 8 to 14");
1454    xConfirmPara( m_toneMapTargetBitDepth < 1 || (m_toneMapTargetBitDepth > 16 && m_toneMapTargetBitDepth < 255) , "SEIToneMapTargetBitDepth must be in rage 1 to 16 or equal to 255");
1455    xConfirmPara( m_toneMapModelId < 0 || m_toneMapModelId > 4 , "SEIToneMapModelId must be in rage 0 to 4");
1456    xConfirmPara( m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0");
1457    xConfirmPara( m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100");
1458    xConfirmPara( m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue, "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue");
1459    xConfirmPara( m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue, "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue");
1460  }
1461#endif
1462
1463#if RATE_CONTROL_LAMBDA_DOMAIN
1464  if ( m_RCEnableRateControl )
1465  {
1466    if ( m_RCForceIntraQP )
1467    {
1468      if ( m_RCInitialQP == 0 )
1469      {
1470        printf( "\nInitial QP for rate control is not specified. Reset not to use force intra QP!" );
1471        m_RCForceIntraQP = false;
1472      }
1473    }
1474    xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" );
1475  }
1476#else
1477  if(m_enableRateCtrl)
1478  {
1479    Int numLCUInWidth  = (m_iSourceWidth  / m_uiMaxCUWidth) + (( m_iSourceWidth  %  m_uiMaxCUWidth ) ? 1 : 0);
1480    Int numLCUInHeight = (m_iSourceHeight / m_uiMaxCUHeight)+ (( m_iSourceHeight %  m_uiMaxCUHeight) ? 1 : 0);
1481    Int numLCUInPic    =  numLCUInWidth * numLCUInHeight;
1482
1483    xConfirmPara( (numLCUInPic % m_numLCUInUnit) != 0, "total number of LCUs in a frame should be completely divided by NumLCUInUnit" );
1484
1485    m_iMaxDeltaQP       = MAX_DELTA_QP;
1486    m_iMaxCuDQPDepth    = MAX_CUDQP_DEPTH;
1487  }
1488#endif
1489
1490  xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagValue, "CUTransquantBypassFlagValue cannot be 1 when TransquantBypassEnableFlag is 0");
1491
1492  xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
1493#if L0444_FPA_TYPE
1494  if (m_framePackingSEIEnabled)
1495  {
1496    xConfirmPara(m_framePackingSEIType < 3 || m_framePackingSEIType > 5 , "SEIFramePackingType must be in rage 3 to 5");
1497  }
1498#endif
1499
1500#undef xConfirmPara
1501  if (check_failed)
1502  {
1503    exit(EXIT_FAILURE);
1504  }
1505}
1506
1507/** \todo use of global variables should be removed later
1508 */
1509Void TAppEncCfg::xSetGlobal()
1510{
1511  // set max CU width & height
1512  g_uiMaxCUWidth  = m_uiMaxCUWidth;
1513  g_uiMaxCUHeight = m_uiMaxCUHeight;
1514 
1515  // compute actual CU depth with respect to config depth and max transform size
1516  g_uiAddCUDepth  = 0;
1517  while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth )  ) ) g_uiAddCUDepth++;
1518 
1519  m_uiMaxCUDepth += g_uiAddCUDepth;
1520  g_uiAddCUDepth++;
1521  g_uiMaxCUDepth = m_uiMaxCUDepth;
1522 
1523  // set internal bit-depth and constants
1524  g_bitDepthY = m_internalBitDepthY;
1525  g_bitDepthC = m_internalBitDepthC;
1526 
1527  g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_inputBitDepthY : m_internalBitDepthY;
1528  g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_inputBitDepthC : m_internalBitDepthC;
1529}
1530
1531Void TAppEncCfg::xPrintParameter()
1532{
1533  printf("\n");
1534  printf("Input          File          : %s\n", m_pchInputFile          );
1535  printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
1536  printf("Reconstruction File          : %s\n", m_pchReconFile          );
1537  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
1538  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
1539  printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
1540  printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
1541  printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
1542  printf("Max RQT depth inter          : %d\n", m_uiQuadtreeTUMaxDepthInter);
1543  printf("Max RQT depth intra          : %d\n", m_uiQuadtreeTUMaxDepthIntra);
1544  printf("Min PCM size                 : %d\n", 1 << m_uiPCMLog2MinSize);
1545  printf("Motion search range          : %d\n", m_iSearchRange );
1546  printf("Intra period                 : %d\n", m_iIntraPeriod );
1547  printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType );
1548  printf("QP                           : %5.2f\n", m_fQP );
1549  printf("Max dQP signaling depth      : %d\n", m_iMaxCuDQPDepth);
1550
1551  printf("Cb QP Offset                 : %d\n", m_cbQpOffset   );
1552  printf("Cr QP Offset                 : %d\n", m_crQpOffset);
1553
1554  printf("QP adaptation                : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) );
1555  printf("GOP size                     : %d\n", m_iGOPSize );
1556  printf("Internal bit depth           : (Y:%d, C:%d)\n", m_internalBitDepthY, m_internalBitDepthC );
1557  printf("PCM sample bit depth         : (Y:%d, C:%d)\n", g_uiPCMBitDepthLuma, g_uiPCMBitDepthChroma );
1558#if RATE_CONTROL_LAMBDA_DOMAIN
1559  printf("RateControl                  : %d\n", m_RCEnableRateControl );
1560  if(m_RCEnableRateControl)
1561  {
1562    printf("TargetBitrate                : %d\n", m_RCTargetBitrate );
1563    printf("KeepHierarchicalBit          : %d\n", m_RCKeepHierarchicalBit );
1564    printf("LCULevelRC                   : %d\n", m_RCLCULevelRC );
1565    printf("UseLCUSeparateModel          : %d\n", m_RCUseLCUSeparateModel );
1566    printf("InitialQP                    : %d\n", m_RCInitialQP );
1567    printf("ForceIntraQP                 : %d\n", m_RCForceIntraQP );
1568  }
1569#else
1570  printf("RateControl                  : %d\n", m_enableRateCtrl);
1571  if(m_enableRateCtrl)
1572  {
1573    printf("TargetBitrate                : %d\n", m_targetBitrate);
1574    printf("NumLCUInUnit                 : %d\n", m_numLCUInUnit);
1575  }
1576#endif
1577  printf("Max Num Merge Candidates     : %d\n", m_maxNumMergeCand);
1578  printf("\n");
1579 
1580  printf("TOOL CFG: ");
1581  printf("IBD:%d ", g_bitDepthY > m_inputBitDepthY || g_bitDepthC > m_inputBitDepthC);
1582  printf("HAD:%d ", m_bUseHADME           );
1583  printf("SRD:%d ", m_bUseSBACRD          );
1584  printf("RDQ:%d ", m_useRDOQ            );
1585  printf("RDQTS:%d ", m_useRDOQTS        );
1586#if L0232_RD_PENALTY
1587  printf("RDpenalty:%d ", m_rdPenalty  );
1588#endif
1589  printf("SQP:%d ", m_uiDeltaQpRD         );
1590  printf("ASR:%d ", m_bUseASR             );
1591#if !L0034_COMBINED_LIST_CLEANUP
1592  printf("LComb:%d ", m_bUseLComb         );
1593#endif
1594  printf("FEN:%d ", m_bUseFastEnc         );
1595  printf("ECU:%d ", m_bUseEarlyCU         );
1596  printf("FDM:%d ", m_useFastDecisionForMerge );
1597  printf("CFM:%d ", m_bUseCbfFastMode         );
1598  printf("ESD:%d ", m_useEarlySkipDetection  );
1599  printf("RQT:%d ", 1     );
1600  printf("TransformSkip:%d ",     m_useTransformSkip              );
1601  printf("TransformSkipFast:%d ", m_useTransformSkipFast       );
1602  printf("Slice: M=%d ", m_sliceMode);
1603  if (m_sliceMode!=0)
1604  {
1605    printf("A=%d ", m_sliceArgument);
1606  }
1607  printf("SliceSegment: M=%d ",m_sliceSegmentMode);
1608  if (m_sliceSegmentMode!=0)
1609  {
1610    printf("A=%d ", m_sliceSegmentArgument);
1611  }
1612  printf("CIP:%d ", m_bUseConstrainedIntraPred);
1613  printf("SAO:%d ", (m_bUseSAO)?(1):(0));
1614  printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
1615  printf("SAOLcuBasedOptimization:%d ", (m_saoLcuBasedOptimization)?(1):(0));
1616
1617  printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 );
1618  printf("WPP:%d ", (Int)m_useWeightedPred);
1619  printf("WPB:%d ", (Int)m_useWeightedBiPred);
1620  printf("PME:%d ", m_log2ParallelMergeLevel);
1621  printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d",
1622          m_iWaveFrontSynchro, m_iWaveFrontSubstreams);
1623  printf(" ScalingList:%d ", m_useScalingListId );
1624  printf("TMVPMode:%d ", m_TMVPModeId     );
1625#if ADAPTIVE_QP_SELECTION
1626  printf("AQpS:%d", m_bUseAdaptQpSelect   );
1627#endif
1628
1629  printf(" SignBitHidingFlag:%d ", m_signHideFlag);
1630  printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
1631  printf("\n\n");
1632 
1633  fflush(stdout);
1634}
1635
1636Bool confirmPara(Bool bflag, const Char* message)
1637{
1638  if (!bflag)
1639    return false;
1640 
1641  printf("Error: %s\n",message);
1642  return true;
1643}
1644
1645//! \}
Note: See TracBrowser for help on using the repository browser.