source: SHVCSoftware/branches/HM-10.0-dev-SHM/source/App/TAppEncoder/TAppEncCfg.cpp @ 110

Last change on this file since 110 was 74, checked in by seregin, 12 years ago

remove REF_IDX_ME_AROUND_ZEROMV

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