source: 3DVCSoftware/branches/HTM-4.1-dev2-Orange/source/App/TAppEncoder/TAppEncCfg.cpp @ 181

Last change on this file since 181 was 181, checked in by orange, 12 years ago

Integrated JCT3V-B0068 (QTLPC: quadtree limitation + predictive coding of the quadtree for depth coding)

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