source: 3DVCSoftware/branches/HTM-4.0.1-VSP-dev0/source/App/TAppEncoder/TAppEncCfg.cpp @ 213

Last change on this file since 213 was 213, checked in by mitsubishi-htm, 12 years ago

A final release, as planned

  • Migrate to HTM 5.1
  • For VC project files, only VC9 file is updated
  • To be used as an additional anchor for CE1.h for 3rd JCTVC meeting at Geneva
  • Property svn:eol-style set to native
File size: 85.1 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-2012, 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#include "TAppCommon/program_options_lite.h"
45
46#ifdef WIN32
47#define strdup _strdup
48#endif
49
50using namespace std;
51namespace po = df::program_options_lite;
52
53//! \ingroup TAppEncoder
54//! \{
55
56/* configuration helper funcs */
57void doOldStyleCmdlineOn(po::Options& opts, const std::string& arg);
58void doOldStyleCmdlineOff(po::Options& opts, const std::string& arg);
59
60// ====================================================================================================================
61// Local constants
62// ====================================================================================================================
63
64/// max value of source padding size
65/** \todo replace it by command line option
66 */
67#define MAX_PAD_SIZE                16
68
69// ====================================================================================================================
70// Constructor / destructor / initialization / destroy
71// ====================================================================================================================
72
73TAppEncCfg::TAppEncCfg()
74{
75  m_aidQP = NULL;
76  m_aidQPdepth = NULL;
77}
78
79TAppEncCfg::~TAppEncCfg()
80{
81  if ( m_aidQP )
82  {
83    delete[] m_aidQP; m_aidQP = NULL;
84  }
85
86  if ( m_aidQPdepth )
87  {
88    delete[] m_aidQPdepth; m_aidQPdepth = NULL;
89  }
90
91  for(Int i = 0; i< m_pchInputFileList.size(); i++ )
92  {
93    if ( m_pchInputFileList[i] != NULL )
94      free (m_pchInputFileList[i]);
95  }
96  for(Int i = 0; i< m_pchDepthInputFileList.size(); i++ )
97  {
98    if ( m_pchDepthInputFileList[i] != NULL )
99      free (m_pchDepthInputFileList[i]);
100  }
101  for(Int i = 0; i< m_pchReconFileList.size(); i++ )
102  {
103    if ( m_pchReconFileList[i] != NULL )
104      free (m_pchReconFileList[i]);
105  }
106  for(Int i = 0; i< m_pchDepthReconFileList.size(); i++ )
107  {
108    if ( m_pchDepthReconFileList[i] != NULL )
109      free (m_pchDepthReconFileList[i]);
110  }
111  if (m_pchBitstreamFile != NULL)
112    free (m_pchBitstreamFile) ;
113#if FLEX_CODING_ORDER_M23723
114  if (m_pchMVCJointCodingOrder != NULL)
115  {
116    free(m_pchMVCJointCodingOrder) ;
117  }
118#endif
119#if HHI_VSO
120  if (  m_pchVSOConfig != NULL)
121    free (  m_pchVSOConfig );
122#endif
123
124 if ( m_pchCameraParameterFile != NULL )
125   free ( m_pchCameraParameterFile ); 
126
127 if ( m_pchBaseViewCameraNumbers != NULL )
128   free ( m_pchBaseViewCameraNumbers ); 
129
130 if ( m_pchdQPFile      != NULL ) 
131   free ( m_pchdQPFile      );
132
133 if ( m_pchColumnWidth  != NULL ) 
134   free ( m_pchColumnWidth  );
135
136 if ( m_pchRowHeight    != NULL ) 
137   free ( m_pchRowHeight    );
138
139 if ( m_scalingListFile != NULL ) 
140   free ( m_scalingListFile );
141
142
143}
144
145Void TAppEncCfg::create()
146{
147}
148
149Void TAppEncCfg::destroy()
150{
151}
152
153std::istringstream &operator>>( std::istringstream &in, GOPEntryMvc &entry )     //input
154{
155  in>>entry.m_sliceType;
156  in>>entry.m_POC;
157  in>>entry.m_QPOffset;
158  in>>entry.m_QPFactor;
159  in>>entry.m_temporalId;
160  in>>entry.m_numRefPicsActive;
161  in>>entry.m_refPic;
162  in>>entry.m_numRefPics;
163  for ( Int i = 0; i < entry.m_numRefPics; i++ )
164  {
165    in>>entry.m_referencePics[i];
166  }
167  in>>entry.m_interRPSPrediction;
168  if (entry.m_interRPSPrediction)
169  {
170    in>>entry.m_deltaRIdxMinus1;
171    in>>entry.m_deltaRPS;
172    in>>entry.m_numRefIdc;
173    for ( Int i = 0; i < entry.m_numRefIdc; i++ )
174    {
175      in>>entry.m_refIdc[i];
176    }
177  }
178  in>>entry.m_numInterViewRefPics;
179  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
180  {
181    in>>entry.m_interViewRefs[i];
182  }
183  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
184  {
185    in>>entry.m_interViewRefPosL0[i];
186  }
187  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
188  {
189    in>>entry.m_interViewRefPosL1[i];
190  }
191#if VSP_CFG
192  in>>entry.m_numVSPRefPics;
193  for( Int i = 0; i < entry.m_numVSPRefPics; i++ )
194  {
195    in>>entry.m_VSPRefPics[i];
196  }
197  for( Int i = 0; i < entry.m_numVSPRefPics; i++ )
198  {
199    in>>entry.m_VSPRefPosL0[i];
200  }
201  for( Int i = 0; i < entry.m_numVSPRefPics; i++ )
202  {
203    in>>entry.m_VSPRefPosL1[i];
204  }
205#endif
206
207  return in;
208}
209
210// ====================================================================================================================
211// Public member functions
212// ====================================================================================================================
213
214/** \param  argc        number of arguments
215    \param  argv        array of arguments
216    \retval             true when success
217 */
218Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] )
219{
220  bool do_help = false;
221 
222  string cfg_BitstreamFile;
223  string cfg_dQPFile;
224  string cfg_ColumnWidth;
225  string cfg_RowHeight;
226  string cfg_ScalingListFile;
227
228 #if FLEX_CODING_ORDER_M23723
229  string cfg_JointCodingOrdering;
230#endif
231
232  po::Options opts;
233  opts.addOptions()
234  ("help", do_help, false, "this help text")
235  ("c", po::parseConfigFile, "configuration file name")
236 
237  /* File, I/O and source parameters */
238  ("InputFile_%d,i_%d",       m_pchInputFileList,       (char *) 0 , MAX_VIEW_NUM ,   "original Yuv input file name %d")
239  ("DepthInputFile_%d,di_%d", m_pchDepthInputFileList,  (char *) 0 , MAX_VIEW_NUM ,   "original Yuv depth input file name %d")
240  ("ReconFile_%d,o_%d",       m_pchReconFileList,       (char *) 0 , MAX_VIEW_NUM ,   "reconstructed Yuv output file name %d")
241  ("DepthReconFile_%d,do_%d", m_pchDepthReconFileList,  (char *) 0 , MAX_VIEW_NUM ,   "reconstructed Yuv depth output file name %d")
242  ("BitstreamFile,b",         cfg_BitstreamFile,        string(""),                   "bitstream output file name")
243  ("CodeDepthMaps",           m_bUsingDepthMaps,        false,                        "Encode depth maps" )
244  ("CodedCamParsPrecision",   m_iCodedCamParPrecision,  STD_CAM_PARAMETERS_PRECISION, "precision for coding of camera parameters (in units of 2^(-x) luma samples)" )
245  ("LambdaModifier0,-LM0",    m_adLambdaModifier[ 0 ],  ( double )1.0,                "Lambda modifier for temporal layer 0")
246  ("LambdaModifier1,-LM1",    m_adLambdaModifier[ 1 ],  ( double )1.0,                "Lambda modifier for temporal layer 1")
247  ("LambdaModifier2,-LM2",    m_adLambdaModifier[ 2 ],  ( double )1.0,                "Lambda modifier for temporal layer 2")
248  ("LambdaModifier3,-LM3",    m_adLambdaModifier[ 3 ],  ( double )1.0,                "Lambda modifier for temporal layer 3")
249  ("SourceWidth,-wdt",        m_iSourceWidth,           0,                            "Source picture width")
250  ("SourceHeight,-hgt",       m_iSourceHeight,          0,                            "Source picture height")
251#if PIC_CROPPING
252  ("CroppingMode",            m_croppingMode,           0,                            "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
253  ("CropLeft",                m_cropLeft,               0,                            "Left cropping/padding for cropping mode 3")
254  ("CropRight",               m_cropRight,              0,                            "Right cropping/padding for cropping mode 3")
255  ("CropTop",                 m_cropTop,                0,                            "Top cropping/padding for cropping mode 3")
256  ("CropBottom",              m_cropBottom,             0,                            "Bottom cropping/padding for cropping mode 3")
257  ("HorizontalPadding,-pdx",  m_aiPad[0],               0,                            "horizontal source padding for cropping mode 2")
258  ("VerticalPadding,-pdy",    m_aiPad[1],               0,                            "vertical source padding for cropping mode 2")
259#endif
260  ("InputBitDepth",         m_uiInputBitDepth, 8u, "bit-depth of input file")
261  ("BitDepth",              m_uiInputBitDepth, 8u, "deprecated alias of InputBitDepth")
262  ("OutputBitDepth",        m_uiOutputBitDepth, 0u, "bit-depth of output file")
263  ("InternalBitDepth",      m_uiInternalBitDepth, 0u, "Internal bit-depth (BitDepth+BitIncrement)")
264#if !PIC_CROPPING
265  ("HorizontalPadding,-pdx",m_aiPad[0],      0, "horizontal source padding size")
266  ("VerticalPadding,-pdy",  m_aiPad[1],      0, "vertical source padding size")
267  ("PAD",                   m_bUsePAD,   false, "automatic source padding of multiple of 16" )
268#endif
269  ("FrameRate,-fr",         m_iFrameRate,        0, "Frame rate")
270  ("FrameSkip,-fs",         m_FrameSkip,         0u, "Number of frames to skip at start of input YUV")
271  ("FramesToBeEncoded,f",   m_iFrameToBeEncoded, 0, "number of frames to be encoded (default=all)")
272  ("FrameToBeEncoded",      m_iFrameToBeEncoded, 0, "depricated alias of FramesToBeEncoded")
273 
274  ("NumberOfViews",         m_iNumberOfViews,    0, "Number of views")
275#if FLEX_CODING_ORDER_M23723
276  ("FCO",               m_b3DVFlexOrder,   false, "flexible coding order flag" )
277  ("FCOCodingOrder",   cfg_JointCodingOrdering,  string(""), "The coding order for joint texture-depth coding")
278#endif
279  /* Unit definition parameters */
280  ("MaxCUWidth",          m_uiMaxCUWidth,  64u)
281  ("MaxCUHeight",         m_uiMaxCUHeight, 64u)
282  /* todo: remove defaults from MaxCUSize */
283  ("MaxCUSize,s",         m_uiMaxCUWidth,  64u, "max CU size")
284  ("MaxCUSize,s",         m_uiMaxCUHeight, 64u, "max CU size")
285  ("MaxPartitionDepth,h", m_uiMaxCUDepth,   4u, "CU depth")
286 
287  ("QuadtreeTULog2MaxSize", m_uiQuadtreeTULog2MaxSize, 6u)
288  ("QuadtreeTULog2MinSize", m_uiQuadtreeTULog2MinSize, 2u)
289 
290  ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u)
291  ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u)
292 
293  /* Coding structure paramters */
294  ("IntraPeriod,-ip",m_iIntraPeriod, -1, "intra period in frames, (-1: only first frame)")
295  ("DecodingRefreshType,-dr",m_iDecodingRefreshType, 0, "intra refresh, (0:none 1:CRA 2:IDR)")
296  ("GOPSize,g",      m_iGOPSize,      1, "GOP size of temporal structure")
297#if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
298  ("MaxNumberOfReorderPictures",   m_numReorderFrames,               -1, "Max. number of reorder pictures: -1: encoder determines value, >=0: set explicitly")
299  ("MaxNumberOfReferencePictures", m_maxNumberOfReferencePictures, 6, "Max. number of reference pictures")
300#endif
301  ("ListCombination,-lc", m_bUseLComb, true, "combined reference list flag for uni-prediction in B-slices")
302  ("LCModification", m_bLCMod, false, "enables signalling of combined reference list derivation")
303  ("DisableInter4x4", m_bDisInter4x4, true, "Disable Inter 4x4")
304  ("NSQT", m_enableNSQT, true, "Enable non-square transforms")
305  ("AMP", m_enableAMP, true, "Enable asymmetric motion partitions")
306  /* motion options */
307  ("FastSearch", m_iFastSearch, 1, "0:Full search  1:Diamond  2:PMVFAST")
308  ("SearchRange,-sr",m_iSearchRange, 96, "motion search range")
309#if DV_V_RESTRICTION_B0037
310  ("DisparitySearchRangeRestriction",m_bUseDisparitySearchRangeRestriction, false, "restrict disparity search range")
311  ("VerticalDisparitySearchRange",m_iVerticalDisparitySearchRange, 56, "vertical disparity search range")
312#endif
313  ("BipredSearchRange", m_bipredSearchRange, 4, "motion search range for bipred refinement")
314  ("HadamardME", m_bUseHADME, true, "hadamard ME for fractional-pel")
315  ("ASR", m_bUseASR, false, "adaptive motion search range")
316 
317  /* Quantization parameters */
318  ("QP,q",          m_adQP,     std::vector<double>(1,32), "Qp value, if value is float, QP is switched once during encoding, if two values are given the second is used for depth")
319  ("DeltaQpRD,-dqr",m_uiDeltaQpRD,       0u, "max dQp offset for slice")
320  ("MaxDeltaQP,d",  m_iMaxDeltaQP,        0, "max dQp offset for block")
321  ("MaxCuDQPDepth,-dqd",  m_iMaxCuDQPDepth,        0, "max depth for a minimum CuDQP")
322
323    ("ChromaQpOffset,   -cqo",   m_iChromaQpOffset,           0, "ChromaQpOffset")
324    ("ChromaQpOffset2nd,-cqo2",  m_iChromaQpOffset2nd,        0, "ChromaQpOffset2nd")
325
326#if ADAPTIVE_QP_SELECTION
327    ("AdaptiveQpSelection,-aqps",   m_bUseAdaptQpSelect,           false, "AdaptiveQpSelection")
328#endif
329
330  ("AdaptiveQP,-aq", m_bUseAdaptiveQP, false, "QP adaptation based on a psycho-visual model")
331  ("MaxQPAdaptationRange,-aqr", m_iQPAdaptationRange, 6, "QP adaptation range")
332  ("dQPFile,m",     cfg_dQPFile, string(""), "dQP file name")
333  ("RDOQ",          m_abUseRDOQ, std::vector<Bool>(1,true), "Enable RDOQ")
334  ("TemporalLayerQPOffset_L0,-tq0", m_aiTLayerQPOffset[0], MAX_QP + 1, "QP offset of temporal layer 0")
335  ("TemporalLayerQPOffset_L1,-tq1", m_aiTLayerQPOffset[1], MAX_QP + 1, "QP offset of temporal layer 1")
336  ("TemporalLayerQPOffset_L2,-tq2", m_aiTLayerQPOffset[2], MAX_QP + 1, "QP offset of temporal layer 2")
337  ("TemporalLayerQPOffset_L3,-tq3", m_aiTLayerQPOffset[3], MAX_QP + 1, "QP offset of temporal layer 3")
338 
339#if !H0566_TLA
340  ("TLayeringBasedOnCodingStruct,-tl", m_bTLayering, false, "Temporal ID is set based on the hierarchical coding structure")
341 
342  ("TLayerSwitchingFlag_L0,-ts0", m_abTLayerSwitchingFlag[0], false, "Switching flag for temporal layer 0")
343  ("TLayerSwitchingFlag_L1,-ts1", m_abTLayerSwitchingFlag[1], false, "Switching flag for temporal layer 1")
344  ("TLayerSwitchingFlag_L2,-ts2", m_abTLayerSwitchingFlag[2], false, "Switching flag for temporal layer 2")
345  ("TLayerSwitchingFlag_L3,-ts3", m_abTLayerSwitchingFlag[3], false, "Switching flag for temporal layer 3")
346#endif
347
348  /* Entropy coding parameters */
349  ("SBACRD", m_bUseSBACRD, true, "SBAC based RD estimation")
350 
351  /* Deblocking filter parameters */
352  ("LoopFilterDisable", m_abLoopFilterDisable, std::vector<Bool>(1,false), "Disables LoopFilter")
353
354  ("LoopFilterOffsetInAPS", m_loopFilterOffsetInAPS, false)
355  ("LoopFilterBetaOffset_div2", m_loopFilterBetaOffsetDiv2, 0 )
356  ("LoopFilterTcOffset_div2", m_loopFilterTcOffsetDiv2, 0 )
357#if LGE_ILLUCOMP_B0045
358  ("IlluCompEnable",                  m_bUseIC                  , true         , "Use illumination compensation for inter-view prediction" )
359#endif
360#if DBL_CONTROL
361  ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, true)
362#endif
363
364  /* Camera Paremetes */
365  ("CameraParameterFile,cpf", m_pchCameraParameterFile,    (Char *) 0, "Camera Parameter File Name")
366#if QC_MVHEVC_B0046
367  ("BaseViewCameraNumbers" ,  m_aiVId,     std::vector<Int>(1, MAX_VIEW_NUM), "Numbers of base views")
368#endif
369  ("BaseViewCameraNumbers" ,  m_pchBaseViewCameraNumbers,  (Char *) 0, "Numbers of base views")
370
371  /* View Synthesis Optimization */
372
373#if HHI_VSO
374  ("VSOConfig",                       m_pchVSOConfig            , (Char *) 0    , "VSO configuration")
375  ("VSO",                             m_bUseVSO                 , false         , "Use VSO" )   
376  ("VSOMode",                         m_uiVSOMode               , (UInt)   4    , "VSO Mode")
377  ("LambdaScaleVSO",                  m_dLambdaScaleVSO         , (Double) 1    , "Lambda Scaling for VSO")
378
379#if HHI_VSO_LS_TABLE_M23714
380  ("VSOLSTable",                      m_bVSOLSTable             , true          , "Depth QP dependent video/depth rate allocation by Lagrange multiplier" )   
381#endif
382
383#if SAIT_VSO_EST_A0033
384  ("UseEstimatedVSD",                 m_bUseEstimatedVSD        , true          , "Model based VSD estimation instead of rendering based for some encoder decisions" )     
385#endif
386#if LGE_VSO_EARLY_SKIP_A0093
387  ("VSOEarlySkip",                    m_bVSOEarlySkip           , true          , "Early skip of VSO computation if synthesis error assumed to be zero" )     
388#endif
389  ("ForceLambdaScaleVSO",             m_bForceLambdaScaleVSO    , false         , "Force using Lambda Scale VSO also in non-VSO-Mode")
390#if HHI_VSO_DIST_INT
391  ("AllowNegDist",                    m_bAllowNegDist           , true          , "Allow negative Distortion in VSO")
392#endif
393#if LGE_WVSO_A0119
394  ("WVSO",                            m_bUseWVSO                , true          , "Use depth fidelity term for VSO" )
395  ("VSOWeight",                       m_iVSOWeight              , 10            , "Synthesized View Distortion Change weight" )
396  ("VSDWeight",                       m_iVSDWeight              , 1             , "View Synthesis Distortion estimate weight" )
397  ("DWeight",                         m_iDWeight                , 1             , "Depth Distortion weight" )
398#endif
399
400#if OL_QTLIMIT_PREDCODING_B0068
401  ("QTLPC",                           m_bUseQTLPC               , true         , "Use depth Quadtree Limitation + Predictive Coding" )
402#endif
403
404#endif
405
406#if VSP_N
407  ("VSP",                             m_bUseVSP                 , false         , "Use VSP" )   
408  ("VSPDepthDisable",                 m_bVSPDepthDisable        , false         , "Use VSP Depth Disable" )   
409#endif
410
411#if DEPTH_MAP_GENERATION
412  ("PredDepthMapGen",  m_uiPredDepthMapGeneration, (UInt)0, "generation of prediction depth maps for motion data prediction" )
413#endif
414#if HHI_INTER_VIEW_MOTION_PRED
415  ("MultiviewMvPred",  m_uiMultiviewMvPredMode,    (UInt)0, "usage of predicted depth maps" )
416  ("MultiviewMvRegMode",        m_uiMultiviewMvRegMode,         (UInt)0, "regularization mode for multiview motion vectors" )
417  ("MultiviewMvRegLambdaScale", m_dMultiviewMvRegLambdaScale, (Double)0, "lambda scale for multiview motion vector regularization" )
418#endif
419#if HHI_INTER_VIEW_RESIDUAL_PRED
420  ("MultiviewResPred", m_uiMultiviewResPredMode,   (UInt)0, "usage of inter-view residual prediction" )
421#endif
422
423  /* Coding tools */
424  ("LMChroma", m_bUseLMChroma, true, "intra chroma prediction based on recontructed luma")
425
426  ("ALF", m_abUseALF, std::vector<Bool>(1,true), "Enables ALF")
427  ("SAO", m_abUseSAO, std::vector<Bool>(1, true), "SAO")
428#if SAO_UNIT_INTERLEAVING
429  ("MaxNumOffsetsPerPic", m_maxNumOffsetsPerPic, 2048, "2048: default")   
430  ("SAOInterleaving", m_saoInterleavingFlag, false, "0: SAO Picture Mode, 1: SAO Interleaving ")   
431#endif
432
433  ("ALFEncodePassReduction", m_iALFEncodePassReduction, 0, "0:Original 16-pass, 1: 1-pass, 2: 2-pass encoding")
434
435  ("ALFMaxNumFilter,-ALFMNF", m_iALFMaxNumberFilters, 16, "16: No Constrained, 1-15: Constrained max number of filter")
436#if LCU_SYNTAX_ALF
437  ("ALFParamInSlice", m_bALFParamInSlice, false, "ALF parameters in 0: APS, 1: slice header")
438  ("ALFPicBasedEncode", m_bALFPicBasedEncode, true, "ALF picture-based encoding 0: false, 1: true")
439#endif
440
441    ("SliceMode",            m_iSliceMode,           0, "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes")
442    ("SliceArgument",        m_iSliceArgument,       0, "if SliceMode==1 SliceArgument represents max # of LCUs. if SliceMode==2 SliceArgument represents max # of bytes.")
443    ("EntropySliceMode",     m_iEntropySliceMode,    0, "0: Disable all entropy slice limits, 1: Enforce max # of LCUs, 2: Enforce constraint based entropy slices")
444    ("EntropySliceArgument", m_iEntropySliceArgument,0, "if EntropySliceMode==1 SliceArgument represents max # of LCUs. if EntropySliceMode==2 EntropySliceArgument represents max # of bins.")
445    ("SliceGranularity",     m_iSliceGranularity,    0, "0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.")
446    ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true)
447
448    ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, false, "Constrained Intra Prediction")
449    ("PCMEnabledFlag", m_usePCM         , false)
450    ("PCMLog2MaxSize", m_pcmLog2MaxSize, 5u)
451    ("PCMLog2MinSize", m_uiPCMLog2MinSize, 3u)
452
453    ("PCMInputBitDepthFlag", m_bPCMInputBitDepthFlag, true)
454    ("PCMFilterDisableFlag", m_bPCMFilterDisableFlag, false)
455#if LOSSLESS_CODING
456    ("LosslessCuEnabled", m_useLossless, false)
457#endif
458    ("weighted_pred_flag,-wpP",     m_bUseWeightPred, false, "weighted prediction flag (P-Slices)")
459    ("weighted_bipred_idc,-wpBidc", m_uiBiPredIdc,    0u,    "weighted bipred idc (B-Slices)")
460    ("TileInfoPresentFlag",         m_iColumnRowInfoPresent,         1,          "0: tiles parameters are NOT present in the PPS. 1: tiles parameters are present in the PPS")
461    ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,          "Indicates if the column and row boundaries are distributed uniformly")
462#if !REMOVE_TILE_DEPENDENCE
463    ("TileBoundaryIndependenceIdc", m_iTileBoundaryIndependenceIdr,  1,          "Indicates if the column and row boundaries break the prediction")
464#endif
465    ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
466    ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""), "Array containing ColumnWidth values in units of LCU")
467    ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
468    ("RowHeightArray",              cfg_RowHeight,                   string(""), "Array containing RowHeight values in units of LCU")
469    ("TileLocationInSliceHeaderFlag", m_iTileLocationInSliceHeaderFlag, 0,       "0: Disable transmission of tile location in slice header. 1: Transmit tile locations in slice header.")
470    ("TileMarkerFlag",                m_iTileMarkerFlag,                0,       "0: Disable transmission of lightweight tile marker. 1: Transmit light weight tile marker.")
471    ("MaxTileMarkerEntryPoints",    m_iMaxTileMarkerEntryPoints,    4,       "Maximum number of uniformly-spaced tile entry points (using light weigh tile markers). Default=4. If number of tiles < MaxTileMarkerEntryPoints then all tiles have entry points.")
472    ("TileControlPresentFlag",       m_iTileBehaviorControlPresentFlag,         1,          "0: tiles behavior control parameters are NOT present in the PPS. 1: tiles behavior control parameters are present in the PPS")
473    ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,          "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
474    ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
475    ("WaveFrontFlush",              m_iWaveFrontFlush,               0,          "Flush and terminate CABAC coding for each LCU line")
476    ("WaveFrontSubstreams",         m_iWaveFrontSubstreams,          1,          "# coded substreams wanted; per tile if TileBoundaryIndependenceIdc is 1, otherwise per frame")
477    ("ScalingList",                 m_useScalingListId,              0,          "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile")
478    ("ScalingListFile",             cfg_ScalingListFile,             string(""), "Scaling list file name")
479#if MULTIBITS_DATA_HIDING
480    ("SignHideFlag,-SBH",                m_signHideFlag, 1)
481    ("SignHideThreshold,-TSIG",          m_signHidingThreshold,         4)
482#endif
483#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
484  ("DMM",                         m_bUseDMM,                       false,      "depth model modes flag")
485#endif
486
487  /* Misc. */
488  ("SEIpictureDigest", m_pictureDigestEnabled, true, "Control generation of picture_digest SEI messages\n"
489                                              "\t1: use MD5\n"
490                                              "\t0: disable")
491
492#if TMVP_DEPTH_SWITCH
493  ("TMVP", m_enableTMVP, std::vector<Bool>(1,true), "Enable TMVP" )
494#else
495  ("TMVP", m_enableTMVP, true, "Enable TMVP" )
496#endif
497
498  ("FEN", m_bUseFastEnc, false, "fast encoder setting")
499  ("ECU", m_bUseEarlyCU, false, "Early CU setting") 
500#if FAST_DECISION_FOR_MRG_RD_COST
501  ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost") 
502#endif
503  ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting")
504#if HHI_INTERVIEW_SKIP
505  ("InterViewSkip",  m_bInterViewSkip,    false, "usage of interview skip" )
506#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
507  ("InterViewSkipLambdaScale",  m_dInterViewSkipLambdaScale,    (Double)8, "lambda scale for interview skip" )
508#endif
509#endif
510  /* Compatability with old style -1 FOO or -0 FOO options. */
511  ("1", doOldStyleCmdlineOn, "turn option <name> on")
512  ("0", doOldStyleCmdlineOff, "turn option <name> off")
513#if HHI_MPI
514  ("MVI", m_bUseMVI, false, "use motion vector inheritance for depth map coding")
515#endif
516#if RWTH_SDC_DLT_B0036
517  ("DLT", m_bUseDLT, true, "use depth lookup table for depth map coding")
518  ("SDC", m_bUseSDC, true, "use simplified depth coding tree")
519#endif
520  ;
521 
522  // parse coding structure
523  for( Int k = 0; k < MAX_VIEW_NUM; k++ )
524  {
525    if( k == 0 )
526    {
527      for( Int i = 1; i < MAX_GOP + 1; i++ ) 
528      {
529        std::ostringstream cOSS;
530        cOSS<<"Frame"<<i;
531        opts.addOptions()( cOSS.str(), m_GOPListsMvc[k][i-1], GOPEntryMvc() );
532      }
533    }
534    else
535    {
536      std::ostringstream cOSS1;
537      cOSS1<<"FrameI"<<"_v"<<k;
538      opts.addOptions()(cOSS1.str(), m_GOPListsMvc[k][MAX_GOP], GOPEntryMvc());
539
540      for( Int i = 1; i < MAX_GOP + 1; i++ ) 
541      {
542        std::ostringstream cOSS2;
543        cOSS2<<"Frame"<<i<<"_v"<<k;
544        opts.addOptions()(cOSS2.str(), m_GOPListsMvc[k][i-1], GOPEntryMvc());
545      }
546    }
547  }
548
549  po::setDefaults(opts);
550  const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv);
551
552  for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
553  {
554    fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
555  }
556 
557  if (argc == 1 || do_help)
558  {
559    /* argc == 1: no options have been specified */
560    po::doHelp(cout, opts);
561    xPrintUsage();
562    return false;
563  }
564 
565  /*
566   * Set any derived parameters
567   */
568  /* convert std::string to c string for compatability */
569  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
570  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
571#if FLEX_CODING_ORDER_M23723
572  m_pchMVCJointCodingOrder= cfg_JointCodingOrdering.empty()?NULL:strdup(cfg_JointCodingOrdering.c_str());
573  // If flexible order is enabled and if depth comes before the texture for a view, disable VSO
574#if HHI_VSO && DISABLE_FCO_FOR_VSO
575  Bool depthComesFirst = false;
576  int iter = 0;
577  if ( m_b3DVFlexOrder )
578  {
579    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
580    {
581      iter = 0; 
582      for ( Int ii=1; ii<12; ii+=2 )
583      {
584        Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0');
585        if ( iViewIdxCfg == iViewIdx )
586        {
587          iter ++; 
588          if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view
589          {
590            if(iter == 1)
591           { 
592            depthComesFirst = true;
593            break;
594           }
595          }
596          else
597          {
598            assert(m_pchMVCJointCodingOrder[ii-1]=='T');
599          }
600        }
601      }
602    }
603  }
604  if (depthComesFirst)
605  {
606    m_bUseVSO = false;
607  }
608#endif
609#endif
610  m_pchColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
611  m_pchRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
612  m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
613 
614  if ( m_bUsingDepthMaps )
615  {
616    for(Int i = 0; i < m_pchDepthReconFileList.size() ; i++)
617    {
618      if ((m_pchDepthInputFileList[i] != NULL) && (m_pchReconFileList[i] != NULL) && (i < m_iNumberOfViews) )
619      {
620        if (m_pchDepthReconFileList[i] == NULL )
621        {
622          xAppendToFileNameEnd( m_pchReconFileList[i], "_depth", m_pchDepthReconFileList[i] );
623        }
624      }
625      else
626      {
627        m_pchDepthReconFileList[i] = NULL;
628      }
629    };
630  }
631  if ( m_adQP.size() < 2 )
632  {
633    m_adQP.push_back( m_adQP[0] );
634  };
635  for (UInt uiK = 0; uiK < m_adQP.size(); uiK++)
636  {
637    m_aiQP.push_back( (Int)( m_adQP[uiK] ) );
638  }
639
640#if PIC_CROPPING
641  switch (m_croppingMode)
642  {
643  case 0:
644    {
645      // no cropping or padding
646      m_cropLeft = m_cropRight = m_cropTop = m_cropBottom = 0;
647      m_aiPad[1] = m_aiPad[0] = 0;
648      break;
649    }
650  case 1:
651    {
652      // automatic padding to minimum CU size
653      Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1);
654      if (m_iSourceWidth % minCuSize)
655      {
656        m_aiPad[0] = m_cropRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
657        m_iSourceWidth  += m_cropRight;
658      }
659      if (m_iSourceHeight % minCuSize)
660      {
661        m_aiPad[1] = m_cropBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
662        m_iSourceHeight += m_cropBottom;
663      }
664      break;
665    }
666  case 2:
667    {
668      //padding
669      m_iSourceWidth  += m_aiPad[0];
670      m_iSourceHeight += m_aiPad[1];
671      m_cropRight  = m_aiPad[0];
672      m_cropBottom = m_aiPad[1];
673      break;
674    }
675  case 3:
676    {
677      // cropping
678      if ((m_cropLeft == 0) && (m_cropRight == 0) && (m_cropTop == 0) && (m_cropBottom == 0))
679      {
680        fprintf(stderr, "Warning: Cropping enabled, but all cropping parameters set to zero\n");
681      }
682      if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0))
683      {
684        fprintf(stderr, "Warning: Cropping enabled, padding parameters will be ignored\n");
685      }
686      m_aiPad[1] = m_aiPad[0] = 0;
687      break;
688    }
689  }
690#else
691
692  // compute source padding size
693  if ( m_bUsePAD )
694  {
695    if ( m_iSourceWidth%MAX_PAD_SIZE )
696    {
697      m_aiPad[0] = (m_iSourceWidth/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceWidth;
698    }
699   
700    if ( m_iSourceHeight%MAX_PAD_SIZE )
701    {
702      m_aiPad[1] = (m_iSourceHeight/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceHeight;
703    }
704  }
705  m_iSourceWidth  += m_aiPad[0];
706  m_iSourceHeight += m_aiPad[1];
707#endif
708 
709  // allocate slice-based dQP values
710  m_aidQP = new Int[ m_iFrameToBeEncoded + m_iGOPSize + 1 ];
711  m_aidQPdepth =  new Int[ m_iFrameToBeEncoded + m_iGOPSize + 1 ];
712  ::memset( m_aidQP, 0, sizeof(Int)*( m_iFrameToBeEncoded + m_iGOPSize + 1 ) );
713  ::memset( m_aidQPdepth, 0, sizeof(Int)*( m_iFrameToBeEncoded + m_iGOPSize + 1 ) );
714 
715  // handling of floating-point QP values
716  // if QP is not integer, sequence is split into two sections having QP and QP+1
717  m_aiQP[0] = (Int)( m_adQP[0] );
718  if ( m_aiQP[0] < m_adQP[0] )
719  {
720    Int iSwitchPOC = (Int)( m_iFrameToBeEncoded - (m_adQP[0] - m_aiQP[0])*m_iFrameToBeEncoded + 0.5 );
721   
722    iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
723    for ( Int i=iSwitchPOC; i<m_iFrameToBeEncoded + m_iGOPSize + 1; i++ )
724    {
725      m_aidQP[i] = 1;
726    }
727  }
728
729  m_aiQP[1] = (Int)( m_adQP[1] );
730  if ( m_aiQP[1] < m_adQP[1] )
731  {
732    Int iSwitchPOC = (Int)( m_iFrameToBeEncoded - (m_adQP[1] - m_aiQP[1])*m_iFrameToBeEncoded + 0.5 );
733
734    iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
735    for ( Int i=iSwitchPOC; i<m_iFrameToBeEncoded + m_iGOPSize + 1; i++ )
736    {
737      m_aidQPdepth[i] = 1;
738    }
739  }
740
741  // reading external dQP description from file
742  if ( m_pchdQPFile )
743  {
744    FILE* fpt=fopen( m_pchdQPFile, "r" );
745    if ( fpt )
746    {
747      Int iValue;
748      Int iPOC = 0;
749      while ( iPOC < m_iFrameToBeEncoded )
750      {
751        if ( fscanf(fpt, "%d", &iValue ) == EOF ) break;
752        m_aidQP[ iPOC ] = iValue;
753        iPOC++;
754      }
755      fclose(fpt);
756    }
757  }
758
759#if HHI_VSO
760  m_bUseVSO = m_bUseVSO && m_bUsingDepthMaps && (m_uiVSOMode != 0);
761#endif
762
763#if LGE_WVSO_A0119
764  m_bUseWVSO = m_bUseVSO && m_bUseWVSO && m_bUsingDepthMaps;
765#endif
766  xCleanUpVectors();
767
768
769#if TMVP_DEPTH_SWITCH
770  if ( m_enableTMVP.size() < 2)
771  {
772    m_enableTMVP.push_back( m_enableTMVP[0]  );
773  }
774#endif
775 
776
777#if HHI_VSO
778  if ( m_abUseALF .size() < 2)
779    m_abUseALF .push_back( m_bUseVSO ? false : m_abUseALF[0]  );
780
781  if ( m_abUseRDOQ.size() < 2)
782    m_abUseRDOQ.push_back( m_bUseVSO ? true : m_abUseRDOQ[0] );
783
784  if ( m_abLoopFilterDisable.size() < 2)
785    m_abLoopFilterDisable.push_back( m_bUseVSO ? true : m_abLoopFilterDisable[0]  );
786
787  if (m_abUseSAO.size() < 2)
788    m_abUseSAO.push_back            ( m_bUseVSO ? false : m_abUseSAO[0] );
789#else
790  if ( m_abUseALF .size() < 2)
791    m_abUseALF .push_back( m_abUseALF[0]  );
792
793  if ( m_abUseRDOQ.size() < 2)
794    m_abUseRDOQ.push_back( m_abUseRDOQ[0] );
795
796  if ( m_abLoopFilterDisable.size() < 2)
797    m_abLoopFilterDisable.push_back( m_abLoopFilterDisable[0]  );
798
799  if (m_abUseSAO.size() < 2)
800    m_abUseSAO.push_back            ( m_abUseSAO[0] );
801#endif
802
803#if HHI_VSO
804
805#if HHI_VSO_LS_TABLE_M23714
806  // Q&D
807  Double adLambdaScaleTable[] = 
808  {  0.031250, 0.031639, 0.032029, 0.032418, 0.032808, 0.033197, 0.033586, 0.033976, 0.034365, 0.034755, 
809     0.035144, 0.035533, 0.035923, 0.036312, 0.036702, 0.037091, 0.037480, 0.037870, 0.038259, 0.038648, 
810     0.039038, 0.039427, 0.039817, 0.040206, 0.040595, 0.040985, 0.041374, 0.041764, 0.042153, 0.042542, 
811     0.042932, 0.043321, 0.043711, 0.044100, 0.044194, 0.053033, 0.061872, 0.070711, 0.079550, 0.088388, 
812     0.117851, 0.147314, 0.176777, 0.235702, 0.294628, 0.353553, 0.471405, 0.589256, 0.707107, 0.707100, 
813     0.753550, 0.800000 
814  }; 
815  if ( m_bVSOLSTable )
816  {
817    AOT( (m_aiQP[1] < 0) || (m_aiQP[1] > 51));
818    m_dLambdaScaleVSO *= adLambdaScaleTable[m_aiQP[1]]; 
819  }
820#endif
821#endif
822
823 // set global variables
824  xSetGlobal();
825
826  // read and check camera parameters
827#if HHI_VSO
828if ( m_bUseVSO && m_uiVSOMode == 4)
829{
830  m_cRenModStrParser.setString( m_iNumberOfViews, m_pchVSOConfig );
831  m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
832                                      m_uiInputBitDepth,
833                                (UInt)m_iCodedCamParPrecision,
834                                      m_FrameSkip,
835                                (UInt)m_iFrameToBeEncoded,
836                                      m_pchCameraParameterFile,
837                                      m_pchBaseViewCameraNumbers,
838                                      NULL,
839                                      m_cRenModStrParser.getSynthViews(),
840                                      LOG2_DISP_PREC_LUT );
841}
842else if ( m_bUseVSO && m_uiVSOMode != 4 )
843{
844  m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
845                                      m_uiInputBitDepth,
846                                (UInt)m_iCodedCamParPrecision,
847                                      m_FrameSkip,
848                                (UInt)m_iFrameToBeEncoded,
849                                      m_pchCameraParameterFile,
850                                      m_pchBaseViewCameraNumbers,
851                                      m_pchVSOConfig,
852                                      NULL,
853                                      LOG2_DISP_PREC_LUT );
854}
855else
856{
857  m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
858    m_uiInputBitDepth,
859    (UInt)m_iCodedCamParPrecision,
860    m_FrameSkip,
861    (UInt)m_iFrameToBeEncoded,
862    m_pchCameraParameterFile,
863    m_pchBaseViewCameraNumbers,
864    NULL,
865    NULL,
866    LOG2_DISP_PREC_LUT );
867}
868#else
869#if !QC_MVHEVC_B0046
870  m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
871    m_uiInputBitDepth,
872    (UInt)m_iCodedCamParPrecision,
873    m_FrameSkip,
874    (UInt)m_iFrameToBeEncoded,
875    m_pchCameraParameterFile,
876    m_pchBaseViewCameraNumbers,
877    NULL,
878    NULL,
879    LOG2_DISP_PREC_LUT );
880#endif
881#endif
882
883
884  // check validity of input parameters
885  xCheckParameter();
886#if !QC_MVHEVC_B0046
887  m_cCameraData.check( false, true );
888#endif
889  // print-out parameters
890  xPrintParameter();
891 
892  return true;
893}
894
895// ====================================================================================================================
896// Private member functions
897// ====================================================================================================================
898
899Bool confirmPara(Bool bflag, const char* message);
900
901Void TAppEncCfg::xCheckParameter()
902{
903  bool check_failed = false; /* abort if there is a fatal configuration problem */
904#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
905  // check range of parameters
906  xConfirmPara( m_uiInputBitDepth < 8,                                                      "InputBitDepth must be at least 8" );
907  xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
908  xConfirmPara( m_iFrameToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 0" );
909  xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
910  xConfirmPara( m_iGOPSize > 1 &&  m_iGOPSize % 2,                                          "GOP Size must be a multiple of 2, if GOP Size is greater than 1" );
911  xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
912  xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
913#if H0736_AVC_STYLE_QP_RANGE
914  xConfirmPara( m_aiQP[0] < -6 * ((Int)m_uiInternalBitDepth - 8) || m_aiQP[0] > 51,         "QP exceeds supported range (-QpBDOffsety to 51)" );
915  if ( m_aiQP.size() >= 2 )
916  {
917    xConfirmPara( m_aiQP[1] < -6 * ((Int)m_uiInternalBitDepth - 8) || m_aiQP[1] > 51,       "QP depth exceeds supported range (-QpBDOffsety to 51)" );
918  }
919#else
920  xConfirmPara( m_aiQP[0] < 0 || m_aiQP[0] > 51,                                             "QP exceeds supported range (0 to 51)" );
921  if ( m_aiQP.size() >= 2 )
922  {
923    xConfirmPara( m_aiQP[1] < 0 || m_aiQP[1] > 51,                                           "QP Depth exceeds supported range (0 to 51)" );
924  }
925#endif
926  xConfirmPara( m_iALFEncodePassReduction < 0 || m_iALFEncodePassReduction > 2,             "ALFEncodePassReduction must be equal to 0, 1 or 2");
927#if LCU_SYNTAX_ALF
928  xConfirmPara( m_iALFMaxNumberFilters < 1,                                                 "ALFMaxNumFilter should be larger than 1"); 
929#else
930  xConfirmPara( m_iALFMaxNumberFilters < 1 || m_iALFMaxNumberFilters > 16,                  "ALFMaxNumFilter exceeds supported range (1 to 16)"); 
931#endif
932  xConfirmPara( m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13,          "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)");
933  xConfirmPara( m_loopFilterTcOffsetDiv2 < -13 || m_loopFilterTcOffsetDiv2 > 13,              "Loop Filter Tc Offset div. 2 exceeds supported range (-13 to 13)");
934  xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2,                                     "Fast Search Mode is not supported value (0:Full search  1:Diamond  2:PMVFAST)" );
935  xConfirmPara( m_iSearchRange < 0 ,                                                        "Search Range must be more than 0" );
936#if DV_V_RESTRICTION_B0037
937  xConfirmPara( m_iVerticalDisparitySearchRange <= 0 ,                                      "Vertical Disparity Search Range must be more than 0" );
938#endif
939  xConfirmPara( m_bipredSearchRange < 0 ,                                                   "Search Range must be more than 0" );
940  xConfirmPara( m_iMaxDeltaQP > 7,                                                          "Absolute Delta QP exceeds supported range (0 to 7)" );
941  xConfirmPara( m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1,                                          "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" );
942
943  xConfirmPara( m_iChromaQpOffset    < -12,   "Min. Chroma Qp Offset is -12"     );
944  xConfirmPara( m_iChromaQpOffset    >  12,   "Max. Chroma Qp Offset is  12"     );
945  xConfirmPara( m_iChromaQpOffset2nd < -12,   "Min. Chroma Qp Offset 2nd is -12" );
946  xConfirmPara( m_iChromaQpOffset2nd >  12,   "Max. Chroma Qp Offset 2nd is  12" );
947
948  xConfirmPara( m_iQPAdaptationRange <= 0,                                                  "QP Adaptation Range must be more than 0" );
949  if (m_iDecodingRefreshType == 2)
950  {
951    xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
952  }
953  xConfirmPara( (m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,                                    "Minimum partition width size should be larger than or equal to 8");
954  xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4,                                    "Minimum partition height size should be larger than or equal to 8");
955  xConfirmPara( m_uiMaxCUWidth < 16,                                                        "Maximum partition width size should be larger than or equal to 16");
956  xConfirmPara( m_uiMaxCUHeight < 16,                                                       "Maximum partition height size should be larger than or equal to 16");
957#if PIC_CROPPING
958  xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame width must be a multiple of the minimum CU size");
959  xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame height must be a multiple of the minimum CU size");
960#else
961  xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Frame width should be multiple of minimum CU size");
962  xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Frame height should be multiple of minimum CU size");
963#endif
964 
965  xConfirmPara( m_uiQuadtreeTULog2MinSize < 2,                                        "QuadtreeTULog2MinSize must be 2 or greater.");
966  xConfirmPara( m_uiQuadtreeTULog2MinSize > 5,                                        "QuadtreeTULog2MinSize must be 5 or smaller.");
967  xConfirmPara( m_uiQuadtreeTULog2MaxSize < 2,                                        "QuadtreeTULog2MaxSize must be 2 or greater.");
968  xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5,                                        "QuadtreeTULog2MaxSize must be 5 or smaller.");
969  xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize,                "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize.");
970  xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS
971  xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUHeight>>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS
972  xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUWidth  >> m_uiMaxCUDepth ), "Minimum CU width must be greater than minimum transform size." );
973  xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." );
974  xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1,                                                         "QuadtreeTUMaxDepthInter must be greater than or equal to 1" );
975  xConfirmPara( m_uiQuadtreeTUMaxDepthInter > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthInter must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" );
976  xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1,                                                         "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" );
977  xConfirmPara( m_uiQuadtreeTUMaxDepthIntra > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthIntra must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" );
978
979  xConfirmPara( m_iNumberOfViews > MAX_VIEW_NUM ,                                     "NumberOfViews must be less than or equal to MAX_VIEW_NUM");
980  xConfirmPara    ( Int( m_pchInputFileList.size() ) < m_iNumberOfViews,              "Number of InputFiles must be greater than or equal to NumberOfViews" );
981  xConfirmPara    ( Int( m_pchReconFileList.size() ) < m_iNumberOfViews,              "Number of ReconFiles must be greater than or equal to NumberOfViews" );
982  xConfirmPara    ( m_iCodedCamParPrecision < 0 || m_iCodedCamParPrecision > 5,       "CodedCamParsPrecision must be in range of 0..5" );
983#if HHI_INTERVIEW_SKIP
984  xConfirmPara    ( m_bInterViewSkip && !m_bUsingDepthMaps,                       "RenderingSkipMode requires CodeDepthMaps = 1" );
985#endif
986#if DEPTH_MAP_GENERATION
987  xConfirmPara    ( m_uiPredDepthMapGeneration > 2,                                   "PredDepthMapGen must be less than or equal to 2" );
988  xConfirmPara    ( m_uiPredDepthMapGeneration >= 2 && !m_bUsingDepthMaps,            "PredDepthMapGen >= 2 requires CodeDepthMaps = 1" );
989#endif
990#if HHI_INTER_VIEW_MOTION_PRED
991  xConfirmPara    ( m_uiMultiviewMvPredMode > 7,                                      "MultiviewMvPred must be less than or equal to 7" );
992  xConfirmPara    ( m_uiMultiviewMvPredMode > 0 && m_uiPredDepthMapGeneration == 0 ,  "MultiviewMvPred > 0 requires PredDepthMapGen > 0" );
993  xConfirmPara    ( m_uiMultiviewMvRegMode       > 1,                                 "MultiviewMvRegMode must be less than or equal to 1" );
994  xConfirmPara    ( m_dMultiviewMvRegLambdaScale < 0.0,                               "MultiviewMvRegLambdaScale must not be negative" );
995  if( m_uiMultiviewMvRegMode )
996  {
997    xConfirmPara  ( Int( m_pchDepthInputFileList.size() ) < m_iNumberOfViews,         "MultiviewMvRegMode > 0 requires the presence of input depth maps" );
998  }
999#endif
1000#if HHI_INTER_VIEW_RESIDUAL_PRED
1001  xConfirmPara    ( m_uiMultiviewResPredMode > 1,                                     "MultiviewResPred must be less than or equal to 1" );
1002  xConfirmPara    ( m_uiMultiviewResPredMode > 0 && m_uiPredDepthMapGeneration == 0 , "MultiviewResPred > 0 requires PredDepthMapGen > 0" );
1003#endif
1004  if( m_bUsingDepthMaps )
1005  {
1006    xConfirmPara  ( Int( m_pchDepthInputFileList.size() ) < m_iNumberOfViews,         "Number of DepthInputFiles must be greater than or equal to NumberOfViews" );
1007    xConfirmPara  ( Int( m_pchDepthReconFileList.size() ) < m_iNumberOfViews,         "Number of DepthReconFiles must be greater than or equal to NumberOfViews" );
1008
1009#if HHI_VSO
1010    if( m_bUseVSO )
1011    {
1012      xConfirmPara( m_pchCameraParameterFile    == 0                             ,   "CameraParameterFile must be given");
1013      xConfirmPara(   m_pchVSOConfig            == 0                             ,   "VSO Setup string must be given");
1014      xConfirmPara( m_pchBaseViewCameraNumbers  == 0                             ,   "BaseViewCameraNumbers must be given" );
1015      xConfirmPara( m_iNumberOfViews != m_cCameraData.getBaseViewNumbers().size(),   "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" );
1016      xConfirmPara( m_uiVSOMode > 4 ,                                                "VSO Mode must be less than 5");
1017    }
1018#endif
1019  }
1020#if ADAPTIVE_QP_SELECTION
1021#if H0736_AVC_STYLE_QP_RANGE
1022  xConfirmPara( m_bUseAdaptQpSelect == true && m_aiQP[0] < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
1023  xConfirmPara( m_bUseAdaptQpSelect == true && m_aiQP[1] < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
1024  xConfirmPara( m_bUseAdaptQpSelect == true && (m_iChromaQpOffset !=0 || m_iChromaQpOffset2nd != 0 ),  "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0.");
1025#endif
1026#endif
1027
1028  if( m_usePCM)
1029  {
1030    xConfirmPara(  m_uiPCMLog2MinSize < 3,                                      "PCMLog2MinSize must be 3 or greater.");
1031    xConfirmPara(  m_uiPCMLog2MinSize > 5,                                      "PCMLog2MinSize must be 5 or smaller.");
1032    xConfirmPara(  m_pcmLog2MaxSize > 5,                                        "PCMLog2MaxSize must be 5 or smaller.");
1033    xConfirmPara(  m_pcmLog2MaxSize < m_uiPCMLog2MinSize,                       "PCMLog2MaxSize must be equal to or greater than m_uiPCMLog2MinSize.");
1034  }
1035
1036#if FIXED_NUMBER_OF_TILES_SLICE_MODE
1037  xConfirmPara( m_iSliceMode < 0 || m_iSliceMode > 3, "SliceMode exceeds supported range (0 to 3)" );
1038#endif
1039  if (m_iSliceMode!=0)
1040  {
1041    xConfirmPara( m_iSliceArgument < 1 ,         "SliceArgument should be larger than or equal to 1" );
1042  }
1043#if FIXED_NUMBER_OF_TILES_SLICE_MODE
1044  if (m_iSliceMode==3)
1045  {
1046    xConfirmPara( m_iSliceGranularity > 0 ,      "When SliceMode == 3 is chosen, the SliceGranularity must be 0" );
1047  }
1048#endif
1049  xConfirmPara( m_iEntropySliceMode < 0 || m_iEntropySliceMode > 2, "EntropySliceMode exceeds supported range (0 to 2)" );
1050  if (m_iEntropySliceMode!=0)
1051  {
1052    xConfirmPara( m_iEntropySliceArgument < 1 ,         "EntropySliceArgument should be larger than or equal to 1" );
1053  }
1054  xConfirmPara( m_iSliceGranularity >= m_uiMaxCUDepth, "SliceGranularity must be smaller than maximum cu depth");
1055  xConfirmPara( m_iSliceGranularity <0 || m_iSliceGranularity > 3, "SliceGranularity exceeds supported range (0 to 3)" );
1056  xConfirmPara( m_iSliceGranularity > m_iMaxCuDQPDepth, "SliceGranularity must be smaller smaller than or equal to maximum dqp depth" );
1057
1058#if NO_COMBINED_PARALLEL
1059  bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 );
1060  xConfirmPara( tileFlag && m_iEntropySliceMode,            "Tile and Entropy Slice can not be applied together");
1061  xConfirmPara( tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
1062  xConfirmPara( m_iWaveFrontSynchro && m_iEntropySliceMode, "Wavefront and Entropy Slice can not be applied together"); 
1063#endif
1064
1065  // max CU width and height should be power of 2
1066  UInt ui = m_uiMaxCUWidth;
1067  while(ui)
1068  {
1069    ui >>= 1;
1070    if( (ui & 1) == 1)
1071      xConfirmPara( ui != 1 , "Width should be 2^n");
1072  }
1073  ui = m_uiMaxCUHeight;
1074  while(ui)
1075  {
1076    ui >>= 1;
1077    if( (ui & 1) == 1)
1078      xConfirmPara( ui != 1 , "Height should be 2^n");
1079  }
1080 
1081  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
1082  xConfirmPara( m_iWaveFrontFlush < 0, "WaveFrontFlush cannot be negative" );
1083  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
1084  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
1085
1086#undef xConfirmPara
1087  if (check_failed)
1088  {
1089    exit(EXIT_FAILURE);
1090  }
1091
1092  xCheckCodingStructureMvc();
1093}
1094
1095Void TAppEncCfg::xCheckCodingStructureMvc()
1096{
1097  bool check_failed = false; /* abort if there is a fatal configuration problem */
1098#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
1099
1100  // validate that POC of same frame is identical across multiple views
1101  Bool bErrorMvePoc = false;
1102  if( m_iNumberOfViews > 1 )
1103  {
1104    for( Int k = 1; k < m_iNumberOfViews; k++ )
1105    {
1106      for( Int i = 0; i < MAX_GOP; i++ )
1107      {
1108        if( m_GOPListsMvc[k][i].m_POC != m_GOPListsMvc[0][i].m_POC )
1109        {
1110          printf( "\nError: Frame%d_v%d POC %d is not identical to Frame%d POC\n", i, k, m_GOPListsMvc[k][i].m_POC, i );
1111          bErrorMvePoc = true;
1112        }
1113      }
1114    }
1115  }
1116  xConfirmPara( bErrorMvePoc,  "Invalid inter-view POC structure given" );
1117
1118  // validate that baseview has no inter-view refs
1119  Bool bErrorIvpBase = false;
1120  for( Int i = 0; i < MAX_GOP; i++ )
1121  {
1122    if( m_GOPListsMvc[0][i].m_numInterViewRefPics != 0 )
1123    {
1124      printf( "\nError: Frame%d inter_view refs not available in view 0\n", i );
1125      bErrorIvpBase = true;
1126    }
1127  }
1128  xConfirmPara( bErrorIvpBase, "Inter-view refs not possible in base view" );
1129
1130  // validate inter-view refs
1131  Bool bErrorIvpEnhV = false;
1132  if( m_iNumberOfViews > 1 )
1133  {
1134    for( Int k = 1; k < m_iNumberOfViews; k++ )
1135    {
1136      for( Int i = 0; i < MAX_GOP+1; i++ )
1137      {
1138        for( Int j = 0; j < m_GOPListsMvc[k][i].m_numInterViewRefPics; j++ )
1139        {
1140          Int iAbsViewId = m_GOPListsMvc[k][i].m_interViewRefs[j] + k;
1141          if( iAbsViewId < 0 || iAbsViewId >= k )
1142          {
1143            printf( "\nError: inter-view ref pic %d is not available for Frame%d_v%d\n", m_GOPListsMvc[k][i].m_interViewRefs[j], i, k );
1144            bErrorIvpEnhV = true;
1145          }
1146          if( m_GOPListsMvc[k][i].m_interViewRefPosL0[j] < 0 || m_GOPListsMvc[k][i].m_interViewRefPosL0[j] > m_GOPListsMvc[k][i].m_numRefPicsActive )
1147          {
1148            printf( "\nError: inter-view ref pos %d on L0 is not available for Frame%d_v%d\n", m_GOPListsMvc[k][i].m_interViewRefPosL0[j], i, k );
1149            bErrorIvpEnhV = true;
1150          }
1151          if( m_GOPListsMvc[k][i].m_interViewRefPosL1[j] < 0 || m_GOPListsMvc[k][i].m_interViewRefPosL1[j] > m_GOPListsMvc[k][i].m_numRefPicsActive )
1152          {
1153            printf( "\nError: inter-view ref pos %d on L1 is not available for Frame%d_v%d\n", m_GOPListsMvc[k][i].m_interViewRefPosL1[j], i, k );
1154            bErrorIvpEnhV = true;
1155          }
1156        }
1157        if( i == MAX_GOP ) // inter-view refs at I pic position in base view
1158        {
1159          if( m_GOPListsMvc[k][MAX_GOP].m_sliceType != 'B' && m_GOPListsMvc[k][MAX_GOP].m_sliceType != 'P' && m_GOPListsMvc[k][MAX_GOP].m_sliceType != 'I' )
1160          {
1161            printf( "\nError: slice type of FrameI_v%d must be equal to B or P or I\n", k );
1162            bErrorIvpEnhV = true;
1163          }
1164
1165          if( m_GOPListsMvc[k][MAX_GOP].m_POC != 0 )
1166          {
1167            printf( "\nError: POC %d not possible for FrameI_v%d, must be 0\n", m_GOPListsMvc[k][MAX_GOP].m_POC, k );
1168            bErrorIvpEnhV = true;
1169          }
1170
1171          if( m_GOPListsMvc[k][MAX_GOP].m_temporalId != 0 )
1172          {
1173            printf( "\nWarning: Temporal id of FrameI_v%d must be 0 (cp. I-frame in base view)\n", k );
1174            m_GOPListsMvc[k][MAX_GOP].m_temporalId = 0;
1175          }
1176
1177          if( !(m_GOPListsMvc[k][MAX_GOP].m_refPic) )
1178          {
1179            printf( "\nWarning: FrameI_v%d must be ref pic (cp. I-frame in base view)\n", k );
1180            m_GOPListsMvc[k][MAX_GOP].m_refPic = true;
1181          }
1182
1183          if( m_GOPListsMvc[k][MAX_GOP].m_numRefPics != 0 )
1184          {
1185            printf( "\nWarning: temporal references not possible for FrameI_v%d\n", k );
1186            for( Int j = 0; j < m_GOPListsMvc[k][MAX_GOP].m_numRefPics; j++ )
1187            {
1188              m_GOPListsMvc[k][MAX_GOP].m_referencePics[j] = 0;
1189            }
1190            m_GOPListsMvc[k][MAX_GOP].m_numRefPics = 0;
1191          }
1192
1193          if( m_GOPListsMvc[k][MAX_GOP].m_interRPSPrediction )
1194          {
1195            printf( "\nError: inter RPS prediction not possible for FrameI_v%d, must be 0\n", k );
1196            bErrorIvpEnhV = true;
1197          }
1198
1199          if( m_GOPListsMvc[k][MAX_GOP].m_sliceType == 'I' && m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics != 0 )
1200          {
1201            printf( "\nError: inter-view prediction not possible for FrameI_v%d with slice type I, #IV_ref_pics must be 0\n", k );
1202            bErrorIvpEnhV = true;
1203          }
1204
1205          if( m_GOPListsMvc[k][MAX_GOP].m_numRefPicsActive > m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics )
1206          {
1207            m_GOPListsMvc[k][MAX_GOP].m_numRefPicsActive = m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics;
1208          }
1209
1210          if( m_GOPListsMvc[k][MAX_GOP].m_sliceType == 'P' )
1211          {
1212            if( m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics < 1 )
1213            {
1214              printf( "\nError: #IV_ref_pics must be at least one for FrameI_v%d with slice type P\n", k );
1215              bErrorIvpEnhV = true;
1216            }
1217            else
1218            {
1219              for( Int j = 0; j < m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics; j++ )
1220              {
1221                if( m_GOPListsMvc[k][MAX_GOP].m_interViewRefPosL1[j] != 0 )
1222                {
1223                  printf( "\nError: inter-view ref pos %d on L1 not possible for FrameI_v%d with slice type P\n", m_GOPListsMvc[k][MAX_GOP].m_interViewRefPosL1[j], k );
1224                  bErrorIvpEnhV = true;
1225                }
1226              }
1227            }
1228          }
1229
1230          if( m_GOPListsMvc[k][MAX_GOP].m_sliceType == 'B' && m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics < 1 )
1231          {
1232            printf( "\nError: #IV_ref_pics must be at least one for FrameI_v%d with slice type B\n", k );
1233            bErrorIvpEnhV = true;
1234          }
1235        }
1236      }
1237    }
1238  }
1239  xConfirmPara( bErrorIvpEnhV, "Invalid inter-view coding structure for enhancement views given" );
1240
1241#if VSP_CFG
1242  // validate vsp refs
1243  Bool bErrorVspEnhV = false;
1244  if( m_iNumberOfViews > 1 )
1245  {
1246    for( Int k = 1; k < m_iNumberOfViews; k++ )
1247    {
1248      for( Int i = 0; i < MAX_GOP+1; i++ )
1249      {
1250        if( m_GOPListsMvc[k][i].m_numVSPRefPics < 0 || m_GOPListsMvc[k][i].m_numVSPRefPics > 1 )
1251        {
1252          printf( "\nError: m_numVSPRefPics < 0 or m_numVSPRefPics > 1 \n" );
1253          bErrorVspEnhV = true;
1254        }
1255
1256        for( Int j = 0; j < m_GOPListsMvc[k][i].m_numVSPRefPics; j++ )
1257        {
1258          Int iAbsViewId = m_GOPListsMvc[k][i].m_VSPRefPics[j] + k;
1259          if( iAbsViewId != 0 )
1260          {
1261            printf( "\nError: VSP is allowed to reference only base view\n" );
1262            bErrorVspEnhV = true;
1263          }
1264          if( m_GOPListsMvc[k][i].m_sliceType == 'P' && m_GOPListsMvc[k][i].m_VSPRefPosL1[j] != 0 )
1265          {
1266            printf( "\nError: m_sliceType == P and m_VSPRefPosL1 != 0\n" );
1267            bErrorVspEnhV = true;
1268          }
1269        }
1270
1271        for( Int j = 0; j < m_GOPListsMvc[k][i].m_numVSPRefPics || j < m_GOPListsMvc[k][i].m_numInterViewRefPics; j++ )
1272        {
1273          if( (m_GOPListsMvc[k][i].m_VSPRefPosL0[j] != 0 && m_GOPListsMvc[k][i].m_VSPRefPosL0[j] == m_GOPListsMvc[k][i].m_interViewRefPosL0[j]) 
1274           || (m_GOPListsMvc[k][i].m_VSPRefPosL1[j] != 0 && m_GOPListsMvc[k][i].m_VSPRefPosL1[j] == m_GOPListsMvc[k][i].m_interViewRefPosL1[j]) )
1275          {
1276            printf( "\nError: vsp_ref_list_pos[%d] == IV ref list pos[%d]\n", j, j );
1277            bErrorVspEnhV = true;
1278          }
1279        }
1280      }
1281    }
1282  }
1283  xConfirmPara( bErrorVspEnhV, "Invalid VSP coding structure for enhancement views given" );
1284#endif
1285
1286  // validate temporal coding structure
1287  if( !bErrorMvePoc && !bErrorIvpBase && !bErrorIvpEnhV )
1288  {
1289    for( Int viewId = 0; viewId < m_iNumberOfViews; viewId++ )
1290    {
1291      Bool verifiedGOP = false;
1292      Bool errorGOP    = false;
1293      Int  checkGOP    = 1;
1294      Int  numRefs     = 1;
1295      Int refList[MAX_NUM_REF_PICS+1];
1296      refList[0] = 0;
1297      Bool isOK[MAX_GOP];
1298      for( Int i = 0; i < MAX_GOP; i++ ) { isOK[i] = false; }
1299      Int numOK = 0;
1300#if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
1301      Int numReorderFramesRequired=0;
1302      m_maxNumberOfReferencePictures=0;
1303      Int lastDisp = -1;
1304#endif
1305      m_extraRPSs[viewId] = 0;
1306      //start looping through frames in coding order until we can verify that the GOP structure is correct.
1307      while( !verifiedGOP && !errorGOP )
1308      {
1309        Int curGOP = (checkGOP-1)%m_iGOPSize;
1310        Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + m_GOPListsMvc[viewId][curGOP].m_POC;   
1311        if( m_GOPListsMvc[viewId][curGOP].m_POC < 0 )
1312        {
1313          printf( "\nError: found fewer Reference Picture Sets than GOPSize for view %d\n", viewId );
1314          errorGOP = true;
1315        }
1316        else 
1317        {
1318          //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
1319          Bool beforeI = false;
1320          for( Int i = 0; i < m_GOPListsMvc[viewId][curGOP].m_numRefPics; i++ ) 
1321          {
1322            Int absPOC = curPOC + m_GOPListsMvc[viewId][curGOP].m_referencePics[i];
1323            if( absPOC < 0 )
1324            {
1325              beforeI = true;
1326            }
1327            else 
1328            {
1329              Bool found = false;
1330              for( Int j = 0; j < numRefs; j++ )
1331              {
1332                if( refList[j] == absPOC ) 
1333                {
1334                  found = true;
1335                  for( Int k = 0; k < m_iGOPSize; k++ )
1336                  {
1337                    if( absPOC%m_iGOPSize == m_GOPListsMvc[viewId][k].m_POC%m_iGOPSize )
1338                    {
1339                      m_GOPListsMvc[viewId][curGOP].m_usedByCurrPic[i] = (m_GOPListsMvc[viewId][k].m_temporalId <= m_GOPListsMvc[viewId][curGOP].m_temporalId);
1340                    }
1341                  }
1342                }
1343              }
1344              if( !found )
1345              {
1346                printf("\nError: ref pic %d is not available for GOP frame %d of view %d\n", m_GOPListsMvc[viewId][curGOP].m_referencePics[i], curGOP+1, viewId );
1347                errorGOP = true;
1348              }
1349            }
1350          }
1351          if( !beforeI && !errorGOP )
1352          {
1353            //all ref frames were present
1354            if( !isOK[curGOP] ) 
1355            {
1356              numOK++;
1357              isOK[curGOP] = true;
1358              if( numOK == m_iGOPSize )
1359              {
1360                verifiedGOP = true;
1361              }
1362            }
1363          }
1364          else 
1365          {
1366            //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
1367            m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]] = m_GOPListsMvc[viewId][curGOP];
1368            Int newRefs = 0;
1369            for( Int i = 0; i < m_GOPListsMvc[viewId][curGOP].m_numRefPics; i++ )
1370            {
1371              Int absPOC = curPOC + m_GOPListsMvc[viewId][curGOP].m_referencePics[i];
1372              if( absPOC >= 0 )
1373              {
1374                m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[newRefs] = m_GOPListsMvc[viewId][curGOP].m_referencePics[i];
1375                m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[newRefs] = m_GOPListsMvc[viewId][curGOP].m_usedByCurrPic[i];
1376                newRefs++;
1377              }
1378            }
1379            Int numPrefRefs = m_GOPListsMvc[viewId][curGOP].m_numRefPicsActive;
1380
1381            for( Int offset = -1; offset > -checkGOP; offset-- )
1382            {
1383              //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
1384              Int offGOP =  (checkGOP - 1 + offset)%m_iGOPSize;
1385              Int offPOC = ((checkGOP - 1 + offset)/m_iGOPSize) * m_iGOPSize + m_GOPListsMvc[viewId][offGOP].m_POC;
1386              if( offPOC >= 0 && m_GOPListsMvc[viewId][offGOP].m_refPic && m_GOPListsMvc[viewId][offGOP].m_temporalId <= m_GOPListsMvc[viewId][curGOP].m_temporalId )
1387              {
1388                Bool newRef = false;
1389                for( Int i = 0; i < numRefs; i++ )
1390                {
1391                  if( refList[i] == offPOC )
1392                  {
1393                    newRef = true;
1394                  }
1395                }
1396                for( Int i = 0; i < newRefs; i++ ) 
1397                {
1398                  if( m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[i] == (offPOC - curPOC) )
1399                  {
1400                    newRef = false;
1401                  }
1402                }
1403                if( newRef ) 
1404                {
1405                  Int insertPoint = newRefs;
1406                  //this picture can be added, find appropriate place in list and insert it.
1407                  for( Int j = 0; j < newRefs; j++ )
1408                  {
1409                    if( m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] < (offPOC - curPOC) || 
1410                        m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] > 0 )
1411                    {
1412                      insertPoint = j;
1413                      break;
1414                    }
1415                  }
1416                  Int prev = offPOC - curPOC;
1417                  Int prevUsed = (m_GOPListsMvc[viewId][offGOP].m_temporalId <= m_GOPListsMvc[viewId][curGOP].m_temporalId);
1418                  for( Int j = insertPoint; j < newRefs+1; j++ )
1419                  {
1420                    Int newPrev = m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j];
1421                    Int newUsed = m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[j];
1422                    m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] = prev;
1423                    m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[j] = prevUsed;
1424                    prevUsed = newUsed;
1425                    prev = newPrev;
1426                  }
1427                  newRefs++;
1428                }
1429              }
1430              if( newRefs >= numPrefRefs )
1431              {
1432                break;
1433              }
1434            }
1435            m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefPics = newRefs;
1436            m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_POC = curPOC;
1437            if( m_extraRPSs[viewId] == 0 )
1438            {
1439              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_interRPSPrediction = 0;
1440              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefIdc = 0;
1441            }
1442            else
1443            {
1444              Int rIdx =  m_iGOPSize + m_extraRPSs[viewId] - 1;
1445              Int refPOC = m_GOPListsMvc[viewId][rIdx].m_POC;
1446              Int refPics = m_GOPListsMvc[viewId][rIdx].m_numRefPics;
1447              Int newIdc = 0;
1448              for( Int i = 0; i <= refPics; i++ )
1449              {
1450                Int deltaPOC = ((i != refPics)? m_GOPListsMvc[viewId][rIdx].m_referencePics[i] : 0);  // check if the reference abs POC is >= 0
1451                Int absPOCref = refPOC + deltaPOC;
1452                Int refIdc = 0;
1453                for( Int j = 0; j < m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefPics; j++ )
1454                {
1455                  if( (absPOCref - curPOC) == m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] )
1456                  {
1457                    if( m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[j] )
1458                    {
1459                      refIdc = 1;
1460                    }
1461                    else
1462                    {
1463                      refIdc = 2;
1464                    }
1465                  }
1466                }
1467                m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_refIdc[newIdc] = refIdc;
1468                newIdc++;
1469              }
1470              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_interRPSPrediction = 1; 
1471              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefIdc = newIdc;
1472              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_deltaRPS = refPOC - m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_POC; 
1473              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_deltaRIdxMinus1 = 0; 
1474            }
1475            curGOP = m_iGOPSize + m_extraRPSs[viewId];
1476            m_extraRPSs[viewId]++;
1477          }
1478          numRefs = 0;
1479          for( Int i = 0; i < m_GOPListsMvc[viewId][curGOP].m_numRefPics; i++ )
1480          {
1481            Int absPOC = curPOC + m_GOPListsMvc[viewId][curGOP].m_referencePics[i];
1482            if( absPOC >= 0 )
1483            {
1484              refList[numRefs] = absPOC;
1485              numRefs++;
1486            }
1487          }
1488#if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
1489          if(m_maxNumberOfReferencePictures<numRefs)
1490          {
1491            m_maxNumberOfReferencePictures=numRefs;
1492          }
1493#endif
1494          refList[numRefs] = curPOC;
1495          numRefs++;
1496#if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
1497          Int nonDisplayed=0;
1498          for(Int i=0; i<numRefs; i++) 
1499          {
1500            if(refList[i]==lastDisp+1) 
1501            {
1502              lastDisp=refList[i];
1503              i=0;
1504            }
1505          }
1506          for(Int i=0; i<numRefs; i++) 
1507          {
1508            if(refList[i]>lastDisp)
1509            {
1510              nonDisplayed++;
1511            }
1512          }
1513          if(nonDisplayed>numReorderFramesRequired)
1514          {
1515            numReorderFramesRequired=nonDisplayed;
1516          }
1517#endif
1518        }
1519        checkGOP++;
1520      }
1521#if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
1522      if (m_numReorderFrames == -1)
1523      {
1524        m_numReorderFrames = numReorderFramesRequired;
1525      }
1526#endif
1527      xConfirmPara( errorGOP, "Invalid GOP structure given" );
1528#if H0566_TLA
1529      m_maxTempLayer[viewId] = 1;
1530#endif
1531      for( Int i = 0; i < m_iGOPSize; i++ ) 
1532      {
1533#if H0566_TLA
1534        if( m_GOPListsMvc[viewId][i].m_temporalId >= m_maxTempLayer[viewId] )
1535        {
1536          m_maxTempLayer[viewId] = m_GOPListsMvc[viewId][i].m_temporalId + 1;
1537        }
1538#endif
1539        xConfirmPara( m_GOPListsMvc[viewId][i].m_sliceType != 'B' && m_GOPListsMvc[viewId][i].m_sliceType != 'P', "Slice type must be equal to B or P" );
1540      }
1541
1542#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
1543      for( Int i = 0; i < MAX_TLAYER; i++ )
1544      {
1545        m_numReorderPics[viewId][i] = 0;
1546        m_maxDecPicBuffering[viewId][i] = 0;
1547      }
1548      for( Int i = 0; i < m_iGOPSize; i++ ) 
1549      {
1550        if( m_GOPListsMvc[viewId][i].m_numRefPics > m_maxDecPicBuffering[viewId][m_GOPListsMvc[viewId][i].m_temporalId] )
1551        {
1552          m_maxDecPicBuffering[viewId][m_GOPListsMvc[viewId][i].m_temporalId] = m_GOPListsMvc[viewId][i].m_numRefPics;
1553        }
1554        Int highestDecodingNumberWithLowerPOC = 0; 
1555        for( Int j = 0; j < m_iGOPSize; j++ )
1556        {
1557          if( m_GOPListsMvc[viewId][j].m_POC <= m_GOPListsMvc[viewId][i].m_POC )
1558          {
1559            highestDecodingNumberWithLowerPOC = j;
1560          }
1561        }
1562        Int numReorder = 0;
1563        for( Int j = 0; j < highestDecodingNumberWithLowerPOC; j++ )
1564        {
1565          if( m_GOPListsMvc[viewId][j].m_temporalId <= m_GOPListsMvc[viewId][i].m_temporalId && 
1566              m_GOPListsMvc[viewId][j].m_POC        >  m_GOPListsMvc[viewId][i].m_POC )
1567          {
1568            numReorder++;
1569          }
1570        }   
1571        if( numReorder > m_numReorderPics[viewId][m_GOPListsMvc[viewId][i].m_temporalId] )
1572        {
1573          m_numReorderPics[viewId][m_GOPListsMvc[viewId][i].m_temporalId] = numReorder;
1574        }
1575      }
1576      for( Int i = 0; i < MAX_TLAYER-1; i++ ) 
1577      {
1578        // a lower layer can not have higher value of m_numReorderPics than a higher layer
1579        if( m_numReorderPics[viewId][i+1] < m_numReorderPics[viewId][i] )
1580        {
1581          m_numReorderPics[viewId][i+1] = m_numReorderPics[viewId][i];
1582        }
1583        // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
1584        if( m_numReorderPics[viewId][i] > m_maxDecPicBuffering[viewId][i] )
1585        {
1586          m_maxDecPicBuffering[viewId][i] = m_numReorderPics[viewId][i];
1587        }
1588        // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
1589        if( m_maxDecPicBuffering[viewId][i+1] < m_maxDecPicBuffering[viewId][i] )
1590        {
1591          m_maxDecPicBuffering[viewId][i+1] = m_maxDecPicBuffering[viewId][i];
1592        }
1593      }
1594      // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
1595      if( m_numReorderPics[viewId][MAX_TLAYER-1] > m_maxDecPicBuffering[viewId][MAX_TLAYER-1] )
1596      {
1597        m_maxDecPicBuffering[viewId][MAX_TLAYER-1] = m_numReorderPics[viewId][MAX_TLAYER-1];
1598      }
1599#endif
1600
1601#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
1602      xConfirmPara( m_bUseLComb == false && m_numReorderPics[viewId][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.
1603#else
1604      xConfirmPara( m_bUseLComb==false && m_numReorderFrames!=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.
1605      xConfirmPara( m_numReorderFrames < numReorderFramesRequired, "For the used GOP the encoder requires more pictures for reordering than specified in MaxNumberOfReorderPictures" );
1606#endif
1607    }
1608  }
1609#undef xConfirmPara
1610  if( check_failed )
1611  {
1612    exit(EXIT_FAILURE);
1613  }
1614}
1615
1616template <class T>
1617Void
1618TAppEncCfg::xCleanUpVector( std::vector<T>& rcVec, const T& rcInvalid )
1619{
1620  Int iFirstInv = (Int)rcVec.size();
1621  for( Int iIdx = 0; iIdx < (Int)rcVec.size(); iIdx++ )
1622  {
1623    if( rcVec[ iIdx ] == rcInvalid )
1624    {
1625      iFirstInv = iIdx;
1626      break;
1627    }
1628  }
1629  while( (Int)rcVec.size() > iFirstInv )
1630  {
1631    rcVec.pop_back();
1632  }
1633}
1634
1635Void
1636TAppEncCfg::xCleanUpVectors()
1637{
1638  xCleanUpVector( m_pchInputFileList,       (char*)0 );
1639  xCleanUpVector( m_pchDepthInputFileList,  (char*)0 );
1640  xCleanUpVector( m_pchReconFileList,       (char*)0 );
1641  xCleanUpVector( m_pchDepthReconFileList,  (char*)0 );
1642}
1643
1644/** \todo use of global variables should be removed later
1645 */
1646Void TAppEncCfg::xSetGlobal()
1647{
1648  // set max CU width & height
1649  g_uiMaxCUWidth  = m_uiMaxCUWidth;
1650  g_uiMaxCUHeight = m_uiMaxCUHeight;
1651 
1652  // compute actual CU depth with respect to config depth and max transform size
1653  g_uiAddCUDepth  = 0;
1654  while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth )  ) ) g_uiAddCUDepth++;
1655 
1656  m_uiMaxCUDepth += g_uiAddCUDepth;
1657  g_uiAddCUDepth++;
1658  g_uiMaxCUDepth = m_uiMaxCUDepth;
1659 
1660  // set internal bit-depth and constants
1661#if FULL_NBIT
1662  g_uiBitDepth = m_uiInternalBitDepth;
1663  g_uiBitIncrement = 0;
1664#else
1665  g_uiBitDepth = 8;
1666  g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth;
1667#endif
1668
1669#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
1670  g_iDeltaDCsQuantOffset = g_uiBitIncrement - 2;
1671#endif
1672
1673  g_uiBASE_MAX     = ((1<<(g_uiBitDepth))-1);
1674 
1675#if IBDI_NOCLIP_RANGE
1676  g_uiIBDI_MAX     = g_uiBASE_MAX << g_uiBitIncrement;
1677#else
1678  g_uiIBDI_MAX     = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1);
1679#endif
1680 
1681  if (m_uiOutputBitDepth == 0)
1682  {
1683    m_uiOutputBitDepth = m_uiInternalBitDepth;
1684  }
1685
1686  g_uiPCMBitDepthLuma = m_uiPCMBitDepthLuma = ((m_bPCMInputBitDepthFlag)? m_uiInputBitDepth : m_uiInternalBitDepth);
1687  g_uiPCMBitDepthChroma = ((m_bPCMInputBitDepthFlag)? m_uiInputBitDepth : m_uiInternalBitDepth);
1688}
1689
1690Void TAppEncCfg::xPrintParameter()
1691{
1692  printf("\n");
1693  for( Int iCounter = 0; iCounter< m_iNumberOfViews; iCounter++)
1694  {
1695    printf("Texture Input File %i            : %s\n", iCounter, m_pchInputFileList[iCounter]);
1696  }
1697  if( m_bUsingDepthMaps )
1698  {
1699    for( Int iCounter = 0; iCounter < m_iNumberOfViews; iCounter++)
1700    {
1701      printf("Depth Input File %i              : %s\n", iCounter, m_pchDepthInputFileList[iCounter]);
1702    }
1703  }
1704  printf("Bitstream File                  : %s\n", m_pchBitstreamFile      );
1705  for( Int iCounter = 0; iCounter< m_iNumberOfViews; iCounter++)
1706  {
1707    printf("Texture Reconstruction File %i   : %s\n", iCounter, m_pchReconFileList[iCounter]);
1708  }
1709  if( m_bUsingDepthMaps )
1710  {
1711    for( Int iCounter = 0; iCounter< m_iNumberOfViews; iCounter++)
1712    {
1713      printf("Depth Reconstruction File %i     : %s\n", iCounter, m_pchDepthReconFileList[iCounter]);
1714    }
1715  }
1716#if PIC_CROPPING
1717  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_cropLeft - m_cropRight, m_iSourceHeight - m_cropTop - m_cropBottom, m_iFrameRate );
1718#else
1719  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_aiPad[0], m_iSourceHeight-m_aiPad[1], m_iFrameRate );
1720#endif
1721  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
1722  printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_iFrameToBeEncoded-1, m_iFrameToBeEncoded );
1723  printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
1724  printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
1725  printf("Max RQT depth inter          : %d\n", m_uiQuadtreeTUMaxDepthInter);
1726  printf("Max RQT depth intra          : %d\n", m_uiQuadtreeTUMaxDepthIntra);
1727  printf("Min PCM size                 : %d\n", 1 << m_uiPCMLog2MinSize);
1728  printf("Motion search range          : %d\n", m_iSearchRange );
1729#if DV_V_RESTRICTION_B0037
1730  printf("Disp search range restriction: %d\n", m_bUseDisparitySearchRangeRestriction );
1731  printf("Vertical disp search range   : %d\n", m_iVerticalDisparitySearchRange );
1732#endif
1733  printf("Intra period                 : %d\n", m_iIntraPeriod );
1734  printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType );
1735  printf("QP Texture                   : %5.2f\n", m_adQP[0] );
1736  if( m_bUsingDepthMaps )
1737  {
1738    printf("QP Depth                     : %5.2f\n", m_adQP[ m_adQP.size()  < 2 ? 0 : 1] );
1739  }
1740  printf("Max dQP signaling depth      : %d\n", m_iMaxCuDQPDepth);
1741
1742  printf("Chroma Qp Offset             : %d\n", m_iChromaQpOffset   );
1743  printf("Chroma Qp Offset 2nd         : %d\n", m_iChromaQpOffset2nd);
1744
1745  printf("QP adaptation                : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) );
1746  printf("GOP size                     : %d\n", m_iGOPSize );
1747  printf("Internal bit depth           : %d\n", m_uiInternalBitDepth );
1748  printf("PCM sample bit depth         : %d\n", m_uiPCMBitDepthLuma );
1749  if((m_uiMaxCUWidth >> m_uiMaxCUDepth) == 4)
1750  {
1751    printf("DisableInter4x4              : %d\n", m_bDisInter4x4); 
1752  }
1753
1754printf("Loop Filter Disabled         : %d %d\n", m_abLoopFilterDisable[0] ? 1 : 0,  m_abLoopFilterDisable[1] ? 1 : 0 );
1755  printf("Coded Camera Param. Precision: %d\n", m_iCodedCamParPrecision);
1756
1757#if HHI_VSO
1758  printf("Force use of Lambda Scale    : %d\n", m_bForceLambdaScaleVSO );
1759
1760  if ( m_bUseVSO )
1761  {
1762    printf("VSO Lambda Scale             : %5.2f\n", m_dLambdaScaleVSO );
1763    printf("VSO Mode                     : %d\n",    m_uiVSOMode       );
1764    printf("VSO Config                   : %s\n",    m_pchVSOConfig    );
1765#if HHI_VSO_DIST_INT
1766    printf("VSO Negative Distortion      : %d\n",    m_bAllowNegDist ? 1 : 0);
1767#endif
1768#if HHI_VSO_LS_TABLE_M23714
1769    printf("VSO LS Table                 : %d\n",    m_bVSOLSTable ? 1 : 0);   
1770#endif
1771#if SAIT_VSO_EST_A0033
1772    printf("VSO Estimated VSD            : %d\n",    m_bUseEstimatedVSD ? 1 : 0);       
1773#endif
1774#if LGE_VSO_EARLY_SKIP_A0093
1775    printf("VSO Early Skip               : %d\n",    m_bVSOEarlySkip ? 1 : 0);   
1776#endif
1777   
1778  }
1779#endif
1780#if HHI_INTERVIEW_SKIP
1781    printf("InterView Skip:              : %d\n",    m_bInterViewSkip ? 1:0 );
1782    printf("InterView Skip Lambda Scale  : %f\n",    m_dInterViewSkipLambdaScale );
1783#endif
1784
1785  printf("\n");
1786 
1787  printf("TOOL CFG General: "); 
1788#if LCU_SYNTAX_ALF
1789  printf("ALFMNF:%d ", m_iALFMaxNumberFilters);
1790  printf("ALFInSlice:%d ", m_bALFParamInSlice);
1791  printf("ALFPicEnc:%d ", m_bALFPicBasedEncode);
1792#endif
1793  printf("IBD:%d ", !!g_uiBitIncrement);
1794  printf("HAD:%d ", m_bUseHADME           );
1795  printf("SRD:%d ", m_bUseSBACRD          );
1796  printf("SQP:%d ", m_uiDeltaQpRD         );
1797  printf("ASR:%d ", m_bUseASR             );
1798#if !PIC_CROPPING
1799  printf("PAD:%d ", m_bUsePAD             );
1800#endif
1801  printf("LComb:%d ", m_bUseLComb         );
1802  printf("LCMod:%d ", m_bLCMod         );
1803  printf("FEN:%d ", m_bUseFastEnc         );
1804  printf("ECU:%d ", m_bUseEarlyCU         );
1805#if FAST_DECISION_FOR_MRG_RD_COST
1806  printf("FDM:%d ", m_useFastDecisionForMerge );
1807#endif
1808  printf("CFM:%d ", m_bUseCbfFastMode         );
1809  printf("RQT:%d ", 1     );
1810  printf("LMC:%d ", m_bUseLMChroma        ); 
1811  printf("Slice: G=%d M=%d ", m_iSliceGranularity, m_iSliceMode);
1812  if (m_iSliceMode!=0)
1813  {
1814    printf("A=%d ", m_iSliceArgument);
1815  }
1816  printf("EntropySlice: M=%d ",m_iEntropySliceMode);
1817  if (m_iEntropySliceMode!=0)
1818  {
1819    printf("A=%d ", m_iEntropySliceArgument);
1820  }
1821  printf("CIP:%d ", m_bUseConstrainedIntraPred);
1822#if BURST_IPCM
1823  printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
1824#else
1825  printf("PCM:%d ", ((1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
1826#endif
1827#if SAO_UNIT_INTERLEAVING
1828  printf("SAOInterleaving:%d ", (m_saoInterleavingFlag)?(1):(0));
1829#endif
1830#if LOSSLESS_CODING
1831  printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 );
1832#endif 
1833  printf("WPP:%d ", (Int)m_bUseWeightPred);
1834  printf("WPB:%d ", m_uiBiPredIdc);
1835#if !REMOVE_TILE_DEPENDENCE
1836  printf("TileBoundaryIndependence:%d ", m_iTileBoundaryIndependenceIdr ); 
1837#endif
1838  printf("TileLocationInSliceHdr:%d ", m_iTileLocationInSliceHeaderFlag);
1839  printf("TileMarker:%d", m_iTileMarkerFlag);
1840  if (m_iTileMarkerFlag)
1841  {
1842    printf("[%d] ", m_iMaxTileMarkerEntryPoints);
1843  }
1844  else
1845  {
1846    printf(" ");
1847  }
1848  printf(" WaveFrontSynchro:%d WaveFrontFlush:%d WaveFrontSubstreams:%d",
1849          m_iWaveFrontSynchro, m_iWaveFrontFlush, m_iWaveFrontSubstreams);
1850  printf(" ScalingList:%d ", m_useScalingListId );
1851
1852#if !TMVP_DEPTH_SWITCH
1853  printf("TMVP:%d ", m_enableTMVP     );
1854#endif
1855
1856#if ADAPTIVE_QP_SELECTION
1857  printf("AQpS:%d", m_bUseAdaptQpSelect   );
1858#endif
1859
1860#if MULTIBITS_DATA_HIDING
1861  printf(" SignBitHidingFlag:%d SignBitHidingThreshold:%d", m_signHideFlag, m_signHidingThreshold);
1862#endif
1863  printf("\n");
1864  printf("TOOL CFG VIDEO  : ");
1865  printf("ALF:%d ", (m_abUseALF [0] ? 1 : 0) );
1866  printf("SAO:%d ", (m_abUseSAO [0] ? 1 : 0));
1867  printf("RDQ:%d ", (m_abUseRDOQ[0] ? 1 : 0) );
1868#if TMVP_DEPTH_SWITCH
1869  printf("TMVP:%d ", (m_enableTMVP[0] ? 1 : 0) );
1870#endif
1871#if LGE_ILLUCOMP_B0045
1872  printf("IlluCompEnable: %d ", m_bUseIC);
1873#endif
1874
1875  printf("\n");
1876
1877  printf("TOOL CFG DEPTH  : ");
1878  printf("ALF:%d ", (m_abUseALF [1] ? 1 : 0));
1879  printf("SAO:%d ", (m_abUseSAO [1] ? 1 : 0));
1880  printf("RDQ:%d ", (m_abUseRDOQ[1] ? 1 : 0));
1881#if TMVP_DEPTH_SWITCH
1882  printf("TMVP:%d ", (m_enableTMVP[1] ? 1 : 0) );
1883#endif
1884#if FLEX_CODING_ORDER_M23723
1885  printf("FCO:%d ",   (m_b3DVFlexOrder ? 1: 0));
1886
1887  if(m_b3DVFlexOrder)
1888  {
1889    printf("CodingOrder: %s ", m_pchMVCJointCodingOrder);
1890  }
1891#endif
1892#if HHI_VSO
1893  printf("VSO:%d ", m_bUseVSO             );
1894#endif
1895#if LGE_WVSO_A0119
1896  printf("WVSO:%d ", m_bUseWVSO );
1897#endif
1898#if OL_QTLIMIT_PREDCODING_B0068
1899  printf("QTLPC:%d ", m_bUseQTLPC);
1900#endif
1901#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
1902  printf("DMM:%d ", m_bUseDMM );
1903#endif
1904#if HHI_MPI
1905  printf("MVI:%d ", m_bUseMVI ? 1 : 0 );
1906#endif
1907#if RWTH_SDC_DLT_B0036
1908  printf("SDC:%d ", m_bUseSDC ? 1 : 0 );
1909  printf("DLT:%d ", m_bUseDLT ? 1 : 0 );
1910#endif
1911#if LGE_WVSO_A0119
1912  if ( m_bUseWVSO )
1913    printf("\nVSO : VSD : SAD weight = %d : %d : %d ", m_iVSOWeight, m_iVSDWeight, m_iDWeight );
1914#endif
1915  printf("\n\n");
1916 
1917  fflush(stdout);
1918}
1919
1920Void TAppEncCfg::xPrintUsage()
1921{
1922  printf( "          <name> = ALF - adaptive loop filter\n");
1923  printf( "                   IBD - bit-depth increasement\n");
1924  printf( "                   GPB - generalized B instead of P in low-delay mode\n");
1925  printf( "                   HAD - hadamard ME for fractional-pel\n");
1926  printf( "                   SRD - SBAC based RD estimation\n");
1927  printf( "                   RDQ - RDOQ\n");
1928  printf( "                   LDC - low-delay mode\n");
1929  printf( "                   NRF - non-reference frame marking in last layer\n");
1930  printf( "                   BQP - hier-P style QP assignment in low-delay mode\n");
1931  printf( "                   PAD - automatic source padding of multiple of 16\n");
1932  printf( "                   ASR - adaptive motion search range\n");
1933  printf( "                   FEN - fast encoder setting\n"); 
1934  printf( "                   ECU - Early CU setting\n");
1935  printf( "                   CFM - Cbf fast mode setting\n");
1936  printf( "                   LMC - intra chroma prediction based on luma\n");
1937  printf( "\n" );
1938  printf( "  Example 1) TAppEncoder.exe -c test.cfg -q 32 -g 8 -f 9 -s 64 -h 4\n");
1939  printf("              -> QP 32, hierarchical-B GOP 8, 9 frames, 64x64-8x8 CU (~4x4 PU)\n\n");
1940  printf( "  Example 2) TAppEncoder.exe -c test.cfg -q 32 -g 4 -f 9 -s 64 -h 4 -1 LDC\n");
1941  printf("              -> QP 32, hierarchical-P GOP 4, 9 frames, 64x64-8x8 CU (~4x4 PU)\n\n");
1942}
1943
1944Bool confirmPara(Bool bflag, const char* message)
1945{
1946  if (!bflag)
1947    return false;
1948 
1949  printf("Error: %s\n",message);
1950  return true;
1951}
1952
1953/* helper function */
1954/* for handling "-1/-0 FOO" */
1955void translateOldStyleCmdline(const char* value, po::Options& opts, const std::string& arg)
1956{
1957  const char* argv[] = {arg.c_str(), value};
1958  /* replace some short names with their long name varients */
1959  if (arg == "LDC")
1960  {
1961    argv[0] = "LowDelayCoding";
1962  }
1963  else if (arg == "RDQ")
1964  {
1965    argv[0] = "RDOQ";
1966  }
1967  else if (arg == "HAD")
1968  {
1969    argv[0] = "HadamardME";
1970  }
1971  else if (arg == "SRD")
1972  {
1973    argv[0] = "SBACRD";
1974  }
1975  else if (arg == "IBD")
1976  {
1977    argv[0] = "BitIncrement";
1978  }
1979  /* issue a warning for change in FEN behaviour */
1980  if (arg == "FEN")
1981  {
1982    /* xxx todo */
1983  }
1984  po::storePair(opts, argv[0], argv[1]);
1985}
1986
1987void doOldStyleCmdlineOn(po::Options& opts, const std::string& arg)
1988{
1989  if (arg == "IBD")
1990  {
1991    translateOldStyleCmdline("4", opts, arg);
1992    return;
1993  }
1994  translateOldStyleCmdline("1", opts, arg);
1995}
1996
1997void doOldStyleCmdlineOff(po::Options& opts, const std::string& arg)
1998{
1999  translateOldStyleCmdline("0", opts, arg);
2000}
2001
2002Void TAppEncCfg::xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName)
2003{
2004  size_t iInLength     = strlen(pchInputFileName);
2005  size_t iAppendLength = strlen(pchStringToAppend);
2006
2007  rpchOutputFileName = (Char*) malloc(iInLength+iAppendLength+1);
2008  Char* pCDot = strrchr(pchInputFileName,'.');
2009  pCDot = pCDot ? pCDot : pchInputFileName + iInLength;
2010  size_t iCharsToDot = pCDot - pchInputFileName ;
2011  size_t iCharsToEnd = iInLength - iCharsToDot;
2012  strncpy(rpchOutputFileName                            ,  pchInputFileName            , iCharsToDot  );
2013  strncpy(rpchOutputFileName+ iCharsToDot               ,  pchStringToAppend           , iAppendLength);
2014  strncpy(rpchOutputFileName+ iCharsToDot+iAppendLength ,  pchInputFileName+iCharsToDot, iCharsToEnd  );
2015  rpchOutputFileName[iInLength+iAppendLength] = '\0';
2016}
2017
2018//! \}
Note: See TracBrowser for help on using the repository browser.