source: 3DVCSoftware/trunk/source/App/TAppEncoder/TAppEncCfg.cpp @ 100

Last change on this file since 100 was 100, checked in by tech, 13 years ago

Adopted modifications:

  • disparity vector generation (A0097)
  • inter-view motion prediction modification (A0049)
  • simplification of disparity vector derivation (A0126)
  • region boundary chain coding (A0070)
  • residual skip intra (A0087)
  • VSO modification (A0033/A0093)

+ Clean ups + Bug fixes

Update of cfg files (A0033 modification 2)

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