source: 3DVCSoftware/branches/HTM-4.1-dev1-HHI/source/App/TAppEncoder/TAppEncCfg.cpp @ 1417

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

Incorporated encoder parameter for TMVP for depth. (TMVP_DEPTH_SWITCH)

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