source: 3DVCSoftware/branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncCfg.cpp @ 28

Last change on this file since 28 was 28, checked in by poznan-univ, 13 years ago

Poznan Tools

  • Encoding only disoccluded CUs in depended views
  • Depth based motion prediction
  • Texture QP adjustment based on depth data
  • Nonlinear depth representation
  • Property svn:eol-style set to native
File size: 46.9 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-2011, 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 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
35
36/** \file     TAppEncCfg.cpp
37    \brief    Handle encoder configuration parameters
38*/
39
40#include <stdlib.h>
41#include <math.h>
42#include <cassert>
43#include <cstring>
44#include <string>
45#include "TAppEncCfg.h"
46#include "../../App/TAppCommon/program_options_lite.h"
47
48
49using namespace std;
50namespace po = df::program_options_lite;
51
52/* configuration helper funcs */
53void doOldStyleCmdlineOn(po::Options& opts, const std::string& arg);
54void doOldStyleCmdlineOff(po::Options& opts, const std::string& arg);
55
56// ====================================================================================================================
57// Local constants
58// ====================================================================================================================
59
60/// max value of source padding size
61/** \todo replace it by command line option
62 */
63#define MAX_PAD_SIZE                16
64#define MAX_INPUT_VIEW_NUM          10
65#define MAX_ERREF_VIEW_NUM          15
66
67// ====================================================================================================================
68// Constructor / destructor / initialization / destroy
69// ====================================================================================================================
70
71TAppEncCfg::TAppEncCfg()
72{
73  m_aidQP = NULL;
74#if HHI_VSO
75  m_aaiERViewRefLutInd.resize( MAX_INPUT_VIEW_NUM );
76#endif
77}
78
79TAppEncCfg::~TAppEncCfg()
80{
81  if ( m_aidQP )
82  {
83    delete[] m_aidQP; m_aidQP = NULL;
84  }
85  for(Int i = 0; i< m_pchInputFileList.size(); i++ )
86  {
87    if ( m_pchInputFileList[i] != NULL )
88      free (m_pchInputFileList[i]);
89  }
90
91  for(Int i = 0; i< m_pchDepthInputFileList.size(); i++ )
92  {
93    if ( m_pchDepthInputFileList[i] != NULL )
94      free (m_pchDepthInputFileList[i]);
95  }
96
97  for(Int i = 0; i< m_pchReconFileList.size(); i++ )
98  {
99    if ( m_pchReconFileList[i] != NULL )
100      free (m_pchReconFileList[i]);
101  }
102
103  for(Int i = 0; i< m_pchERRefFileList.size(); i++ )
104  {
105    if ( m_pchERRefFileList[i] != NULL )
106      free (m_pchERRefFileList[i]);
107  }
108
109  if (m_pchBitstreamFile != NULL)
110    free (m_pchBitstreamFile) ;
111
112  for(Int i = 0; i< m_pchDepthReconFileList.size(); i++ )
113  {
114    if ( m_pchDepthReconFileList[i] != NULL )
115      free (m_pchDepthReconFileList[i]);
116  }
117
118  if (m_pchCameraParameterFile != NULL)
119    free (m_pchCameraParameterFile);
120
121  if (m_pchBaseViewCameraNumbers != NULL)
122    free (m_pchBaseViewCameraNumbers);
123
124#if HHI_VSO
125  if (  m_pchVSOConfig != NULL)
126    free (  m_pchVSOConfig );
127#endif
128
129}
130
131Void TAppEncCfg::create()
132{
133}
134
135Void TAppEncCfg::destroy()
136{
137}
138
139// ====================================================================================================================
140// Public member functions
141// ====================================================================================================================
142
143/** \param  argc        number of arguments
144    \param  argv        array of arguments
145    \retval             true when success
146 */
147Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] )
148{
149  bool do_help = false;
150
151  string cfg_InputFile;
152  string cfg_BitstreamFile;
153  string cfg_ReconFile;
154  string cfg_dQPFile;
155  po::Options opts;
156  opts.addOptions()
157  ("help", do_help, false, "this help text")
158  ("c", po::parseConfigFile, "configuration file name")
159
160  /* File, I/O and source parameters */
161  ("InputFile_%d,i_%d",       m_pchInputFileList,       (char *) 0 , MAX_INPUT_VIEW_NUM , "original Yuv input file name %d")
162  ("DepthInputFile_%d,di_%d", m_pchDepthInputFileList,  (char *) 0 , MAX_INPUT_VIEW_NUM , "original Yuv depth input file name %d")
163  ("ReconFile_%d,o_%d",       m_pchReconFileList,       (char *) 0 , MAX_INPUT_VIEW_NUM , "reconstructed Yuv output file name %d")
164  ("DepthReconFile_%d,do_%d", m_pchDepthReconFileList,  (char *) 0 , MAX_INPUT_VIEW_NUM , "reconstructed Yuv depth output file name %d")
165  ("BitstreamFile,b", cfg_BitstreamFile, string(""), "bitstream output file name")
166
167  ("CodeDepthMaps",         m_bUsingDepthMaps, false, "Encode depth maps" )
168  ("CodedCamParsPrecision", m_iCodedCamParPrecision, STD_CAM_PARAMETERS_PRECISION, "precision for coding of camera parameters (in units of 2^(-x) luma samples)" )
169
170#ifdef WEIGHT_PRED
171  ("weighted_pred_flag,-wpP",     m_bUseWeightPred, false, "weighted prediction flag (P-Slices)")
172  ("weighted_bipred_idc,-wpBidc", m_uiBiPredIdc,    0u,    "weighted bipred idc (B-Slices)")
173#endif
174  ("SourceWidth,-wdt",      m_iSourceWidth,  0, "Source picture width")
175  ("SourceHeight,-hgt",     m_iSourceHeight, 0, "Source picture height")
176  ("InputBitDepth",         m_uiInputBitDepth, 8u, "bit-depth of input file")
177  ("BitDepth",              m_uiInputBitDepth, 8u, "deprecated alias of InputBitDepth")
178  ("OutputBitDepth",        m_uiOutputBitDepth, 0u, "bit-depth of output file")
179#if ENABLE_IBDI
180  ("BitIncrement",          m_uiBitIncrement, 0xffffffffu, "bit-depth increasement")
181#endif
182  ("InternalBitDepth",      m_uiInternalBitDepth, 0u, "Internal bit-depth (BitDepth+BitIncrement)")
183  ("HorizontalPadding,-pdx",m_aiPad[0],      0, "horizontal source padding size")
184  ("VerticalPadding,-pdy",  m_aiPad[1],      0, "vertical source padding size")
185  ("PAD",                   m_bUsePAD,   false, "automatic source padding of multiple of 16" )
186  ("FrameRate,-fr",         m_iFrameRate,        0, "Frame rate")
187  ("FrameSkip,-fs",         m_FrameSkip,         0u, "Number of frames to skip at start of input YUV")
188  ("FramesToBeEncoded,f",   m_iFrameToBeEncoded, 0, "number of frames to be encoded (default=all)")
189  ("FrameToBeEncoded",      m_iFrameToBeEncoded, 0, "depricated alias of FramesToBeEncoded")
190
191  ("NumberOfViews",         m_iNumberOfViews,    0, "Number of views")
192
193
194  /* Unit definition parameters */
195  ("MaxCUWidth",          m_uiMaxCUWidth,  64u)
196  ("MaxCUHeight",         m_uiMaxCUHeight, 64u)
197  /* todo: remove defaults from MaxCUSize */
198  ("MaxCUSize,s",         m_uiMaxCUWidth,  64u, "max CU size")
199  ("MaxCUSize,s",         m_uiMaxCUHeight, 64u, "max CU size")
200  ("MaxPartitionDepth,h", m_uiMaxCUDepth,   4u, "CU depth")
201
202  ("QuadtreeTULog2MaxSize", m_uiQuadtreeTULog2MaxSize, 6u)
203  ("QuadtreeTULog2MinSize", m_uiQuadtreeTULog2MinSize, 2u)
204
205  ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u)
206  ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u)
207
208  /* Coding structure paramters */
209  ("CodedPictureStoreSize,cpss",  m_uiCodedPictureStoreSize, 16u, "Size of coded picture Buffer")
210#if DCM_DECODING_REFRESH
211  ("DecodingRefreshType,-dr",m_iDecodingRefreshType, 0, "intra refresh, (0:none 1:CDR 2:IDR)")
212#endif
213  ("GOPSize,g",      m_iGOPSize,      1, "GOP size of temporal structure")
214  ("RateGOPSize,-rg",m_iRateGOPSize, -1, "GOP size of hierarchical QP assignment (-1: implies inherit GOPSize value)")
215#if !HHI_NO_LowDelayCoding
216  ("LowDelayCoding",         m_bUseLDC,             false, "low-delay mode")
217#endif
218#if DCM_COMB_LIST
219  ("ListCombination, -lc", m_bUseLComb, true, "combined reference list for uni-prediction in B-slices")
220  ("LCModification", m_bLCMod, false, "enables signalling of combined reference list derivation")
221#endif
222
223  ("GOPFormatString,gfs", m_cInputFormatString,  string(""), "Group of pictures")
224
225  /* motion options */
226  ("FastSearch", m_iFastSearch, 1, "0:Full search  1:Diamond  2:PMVFAST")
227  ("SearchRange,-sr",m_iSearchRange, 96, "motion search range")
228  ("BipredSearchRange", m_bipredSearchRange, 4, "motion search range for bipred refinement")
229  ("HadamardME", m_bUseHADME, true, "hadamard ME for fractional-pel")
230  ("ASR", m_bUseASR, false, "adaptive motion search range")
231
232  /* Quantization parameters */
233  ("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")
234  ("DeltaQpRD,-dqr",m_uiDeltaQpRD,       0u, "max dQp offset for slice")
235  ("MaxDeltaQP,d",  m_iMaxDeltaQP,        0, "max dQp offset for block")
236  ("dQPFile,m",     m_pchdQPFile , (char*) 0, "dQP file name")
237  ("RDOQ",          m_abUseRDOQ, std::vector<Bool>(1,true), "Enable RDOQ")
238  ("TemporalLayerQPOffset_L0,-tq0", m_aiTLayerQPOffset[0], 0, "QP offset of temporal layer 0")
239  ("TemporalLayerQPOffset_L1,-tq1", m_aiTLayerQPOffset[1], 0, "QP offset of temporal layer 1")
240  ("TemporalLayerQPOffset_L2,-tq2", m_aiTLayerQPOffset[2], 0, "QP offset of temporal layer 2")
241  ("TemporalLayerQPOffset_L3,-tq3", m_aiTLayerQPOffset[3], 0, "QP offset of temporal layer 3")
242  ("TemporalLayerQPOffset_L4,-tq4", m_aiTLayerQPOffset[4], 0, "QP offset of temporal layer 3")
243  ("TemporalLayerQPOffset_L5,-tq5", m_aiTLayerQPOffset[5], 0, "QP offset of temporal layer 3")
244  ("TemporalLayerQPOffset_L6,-tq6", m_aiTLayerQPOffset[6], 0, "QP offset of temporal layer 3")
245  ("TemporalLayerQPOffset_L7,-tq7", m_aiTLayerQPOffset[7], 0, "QP offset of temporal layer 3")
246  ("TemporalLayerQPOffset_L8,-tq8", m_aiTLayerQPOffset[8], 0, "QP offset of temporal layer 3")
247  ("TemporalLayerQPOffset_L9,-tq9", m_aiTLayerQPOffset[9], 0, "QP offset of temporal layer 3")
248
249  /* Entropy coding parameters */
250  ("SymbolMode,-sym", m_iSymbolMode, 1, "symbol mode (0=VLC, 1=SBAC)")
251  ("SBACRD", m_bUseSBACRD, true, "SBAC based RD estimation")
252
253  /* Deblocking filter parameters */
254  ("LoopFilterDisable", m_abLoopFilterDisable, std::vector<Bool>(1,false), "Disables LoopFilter")
255  ("LoopFilterAlphaC0Offset", m_iLoopFilterAlphaC0Offset, 0)
256  ("LoopFilterBetaOffset", m_iLoopFilterBetaOffset, 0 )
257
258  /* Camera Paremetes */
259  ("CameraParameterFile,cpf", m_pchCameraParameterFile,    (Char *) 0, "Camera Parameter File Name")
260  ("BaseViewCameraNumbers" ,  m_pchBaseViewCameraNumbers,  (Char *) 0, "Numbers of base views")
261
262
263    /* View Synthesis Optimization */
264
265#if HHI_VSO
266  ("VSOConfig",                       m_pchVSOConfig            , (Char *) 0    , "VSO configuration")
267    ("VSO",                             m_bUseVSO                 , false         , "Use VSO" )
268    // GT: For development, will be removed later
269  ("VSOMode",                         m_uiVSOMode               , (UInt)   4    , "VSO Mode")
270#if HHI_VSO_LS_TABLE
271  ("LambdaScaleVSO",                  m_dLambdaScaleVSO         , (Double) 1  , "Lambda Scaling for VSO")
272#else
273  ("LambdaScaleVSO",                  m_dLambdaScaleVSO         , (Double) 0.5  , "Lambda Scaling for VSO")
274#endif
275    ("ForceLambdaScaleVSO",             m_bForceLambdaScaleVSO    , false         , "Force using Lambda Scale VSO also in non-VSO-Mode")
276#if HHI_VSO_DIST_INT
277  ("AllowNegDist",                    m_bAllowNegDist           , true         , "Allow negative Distortion in VSO")
278#endif
279
280    ("NumberOfExternalRefs",            m_iNumberOfExternalRefs   , 0             , "Number of virtual external reference views")
281    ("ERRefFile_%d,er_%d",              m_pchERRefFileList        , (char *) 0    , MAX_ERREF_VIEW_NUM , "virtual external reference view file name %d")
282    ("VSERViewReferences_%d,evr_%d"  ,  m_aaiERViewRefInd         , vector<Int>() , MAX_INPUT_VIEW_NUM, "Numbers of external virtual reference views to be used for this view")
283    ("VSBaseViewReferences_%d,bvr_%d",  m_aaiBaseViewRefInd       , vector<Int>() , MAX_INPUT_VIEW_NUM, "Numbers of external virtual reference views to be used for this view")
284#endif
285
286  /* Coding tools */
287  ("MRG", m_bUseMRG, true, "merging of motion partitions")
288
289#if LM_CHROMA
290  ("LMChroma", m_bUseLMChroma, true, "intra chroma prediction based on recontructed luma")
291#endif
292
293  ("ALF", m_abUseALF, std::vector<Bool>(1,true), "Enables ALF")
294#if MTK_SAO
295  ("SAO", m_abUseSAO, std::vector<Bool>(1, true), "SAO")
296#endif
297
298#if MQT_ALF_NPASS
299  ("ALFEncodePassReduction", m_iALFEncodePassReduction, 0, "0:Original 16-pass, 1: 1-pass, 2: 2-pass encoding")
300#endif
301#if HHI_RMP_SWITCH
302  ("RMP", m_bUseRMP ,true, "Rectangular motion partition" )
303#endif
304#ifdef ROUNDING_CONTROL_BIPRED
305  ("RoundingControlBipred", m_useRoundingControlBipred, false, "Rounding control for bi-prediction")
306#endif
307    ("SliceMode",            m_iSliceMode,           0, "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes")
308    ("SliceArgument",        m_iSliceArgument,       0, "if SliceMode==1 SliceArgument represents max # of LCUs. if SliceMode==2 SliceArgument represents max # of bytes.")
309    ("EntropySliceMode",     m_iEntropySliceMode,    0, "0: Disable all entropy slice limits, 1: Enforce max # of LCUs, 2: Enforce constraint based entropy slices")
310    ("EntropySliceArgument", m_iEntropySliceArgument,0, "if EntropySliceMode==1 SliceArgument represents max # of LCUs. if EntropySliceMode==2 EntropySliceArgument represents max # of bins.")
311#if MTK_NONCROSS_INLOOP_FILTER
312    ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true)
313#endif
314#if CONSTRAINED_INTRA_PRED
315  ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, false, "Constrained Intra Prediction")
316#endif
317  /* Misc. */
318  ("SEIpictureDigest", m_pictureDigestEnabled, false, "Control generation of picture_digest SEI messages\n"
319                                              "\t1: use MD5\n"
320                                              "\t0: disable")
321  ("FEN", m_bUseFastEnc, false, "fast encoder setting")
322
323#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
324  ("DMM", m_bUseDMM, false, "add depth modes intra")
325#endif
326#if HHI_MPI
327  ("MVI", m_bUseMVI, false, "use motion vector inheritance for depth map coding")
328#endif
329
330  /* Multiview tools */
331#if DEPTH_MAP_GENERATION
332  ("PredDepthMapGen",  m_uiPredDepthMapGeneration, (UInt)0, "generation of prediction depth maps for motion data prediction" )
333#endif
334#if HHI_INTER_VIEW_MOTION_PRED
335  ("MultiviewMvPred",  m_uiMultiviewMvPredMode,    (UInt)0, "usage of predicted depth maps" )
336  ("MultiviewMvRegMode",        m_uiMultiviewMvRegMode,         (UInt)0, "regularization mode for multiview motion vectors" )
337  ("MultiviewMvRegLambdaScale", m_dMultiviewMvRegLambdaScale, (Double)0, "lambda scale for multiview motion vector regularization" )
338#endif
339#if HHI_INTER_VIEW_RESIDUAL_PRED
340  ("MultiviewResPred", m_uiMultiviewResPredMode,   (UInt)0, "usage of inter-view residual prediction" )
341#endif
342
343#if POZNAN_DBMP
344  ("DBMP",  m_uiDBMP,    (UInt)0, "usage of Depth-Based Motion Prediction" )
345#endif
346
347#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
348  ("CUSkip",  m_uiUseCUSkip,    (UInt)1, "encode only disoccluded CUs in dependend view" )
349#endif
350
351  ("QpChangeFrame", m_iQpChangeFrame, PicOrderCnt(0), "start frame for QP change")
352  ("QpChangeOffsetVideo", m_iQpChangeOffsetVideo, 0, "QP change offset for video")
353  ("QpChangeOffsetDepth", m_iQpChangeOffsetDepth, 0, "QP change offset for depth")
354#if HHI_INTERVIEW_SKIP
355  ("InterViewSkip",  m_uiInterViewSkip,    (UInt)0, "usage of interview skip" )
356#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
357  ("InterViewSkipLambdaScale",  m_dInterViewSkipLambdaScale,    (Double)8, "lambda scale for interview skip" )
358#endif
359#endif
360#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
361  ("TDdQP", m_bUseTexDqpAccordingToDepth, false, "texture TU blocks QP param modification according to depth map's values")
362#endif
363#if POZNAN_TEXTURE_TU_DELTA_QP_PARAM_IN_CFG_FOR_ENC
364  ("TDdQPOffset",              m_dTexDqpAccordingToDepthOffset,       (Double)(-2.6), "texture block QP changing tool based on coresponding depth block values - offset parameter" )
365  ("TDdQPMul",                 m_dTexDqpAccordingToDepthMul,          (Double)(1),    "texture block QP changing tool based on coresponding depth block values - multiplicative parameter" )
366  ("TDdQPTopBottomRow",        m_iTexDqpAccordingToDepthTopBottomRow, (Int)2,         "texture block QP changing tool - top and bottom CU rows delta QP parameter" )
367#endif
368#if POZNAN_NONLINEAR_DEPTH
369  ("DepthPower,-dpow",    m_fDepthPower,      (Double)1.0, "Depth power value (for non-linear processing)")
370#endif
371
372
373  /* Compatability with old style -1 FOO or -0 FOO options. */
374  ("1", doOldStyleCmdlineOn, "turn option <name> on")
375  ("0", doOldStyleCmdlineOff, "turn option <name> off")
376  ;
377
378  po::setDefaults(opts);
379  const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv);
380
381  for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
382  {
383    fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
384  }
385
386  if (argc == 1 || do_help)
387  {
388    /* argc == 1: no options have been specified */
389    po::doHelp(cout, opts);
390    xPrintUsage();
391    return false;
392  }
393
394  /*
395   * Set any derived parameters
396   */
397  /* convert std::string to c string for compatability */
398  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
399  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
400
401
402// GT FIX
403  if ( m_bUsingDepthMaps )
404  {
405    for(Int i = 0; i < m_pchDepthReconFileList.size() ; i++)
406    {
407      if ((m_pchDepthInputFileList[i] != NULL) && (m_pchReconFileList[i] != NULL) && (i < m_iNumberOfViews) )
408      {
409        if (m_pchDepthReconFileList[i] == NULL )
410        {
411          xAppendToFileNameEnd( m_pchReconFileList[i], "_depth", m_pchDepthReconFileList[i] );
412        }
413      }
414      else
415      {
416        m_pchDepthReconFileList[i] = NULL;
417      }
418    };
419  }
420// GT FIX END
421
422  if (m_iRateGOPSize == -1)
423  {
424    /* if rateGOPSize has not been specified, the default value is GOPSize */
425    m_iRateGOPSize = m_iGOPSize;
426  }
427
428  // compute source padding size
429  if ( m_bUsePAD )
430  {
431    if ( m_iSourceWidth%MAX_PAD_SIZE )
432    {
433      m_aiPad[0] = (m_iSourceWidth/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceWidth;
434    }
435
436    if ( m_iSourceHeight%MAX_PAD_SIZE )
437    {
438      m_aiPad[1] = (m_iSourceHeight/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceHeight;
439    }
440  }
441  m_iSourceWidth  += m_aiPad[0];
442  m_iSourceHeight += m_aiPad[1];
443
444//GT QP Depth
445  if ( m_adQP.size() < 2 )
446  {
447    m_adQP.push_back( m_adQP[0] );
448  };
449  for (UInt uiK = 0; uiK < m_adQP.size(); uiK++)
450  {
451    m_aiQP.push_back( (Int)( m_adQP[uiK] ) );
452  }
453//GT QP Depth end
454
455#if HHI_VSO
456  m_bUseVSO = m_bUseVSO && m_bUsingDepthMaps && (m_uiVSOMode != 0);
457#endif
458
459#if POZNAN_NONLINEAR_DEPTH
460if (m_fDepthPower<=0) 
461  {
462    Float fDepthQP = m_adQP[ m_adQP.size()  < 2 ? 0 : 1];
463    m_fDepthPower = (fDepthQP-30) *0.25/20.0 + 1.25;
464    if (m_fDepthPower<=1.0) m_fDepthPower = 1.0;
465    // QP = 30 = 1.25
466    // QP = 50 = 1.5
467    if (m_fDepthPower>=1.66) m_fDepthPower = 1.66;
468  };
469
470#if POZNAN_NONLINEAR_DEPTH_SEND_AS_BYTE
471  m_fDepthPower = dequantizeDepthPower(quantizeDepthPower((Float)m_fDepthPower));
472#endif
473
474#endif
475
476  xCleanUpVectors();
477
478#if HHI_VSO
479  if ( m_abUseALF .size() < 2)
480    m_abUseALF .push_back( m_bUseVSO ? false : m_abUseALF[0]  );
481
482  if ( m_abUseRDOQ.size() < 2)
483    m_abUseRDOQ.push_back( m_bUseVSO ? true : m_abUseRDOQ[0] );
484
485  if ( m_abLoopFilterDisable.size() < 2)
486    m_abLoopFilterDisable.push_back( m_bUseVSO ? true : m_abLoopFilterDisable[0]  );
487
488  if (m_abUseSAO.size() < 2)
489    m_abUseSAO.push_back            ( m_bUseVSO ? false : m_abUseSAO[0] );
490#else
491  if ( m_abUseALF .size() < 2)
492    m_abUseALF .push_back( m_abUseALF[0]  );
493
494  if ( m_abUseRDOQ.size() < 2)
495    m_abUseRDOQ.push_back( m_abUseRDOQ[0] );
496
497  if ( m_abLoopFilterDisable.size() < 2)
498    m_abLoopFilterDisable.push_back( m_abLoopFilterDisable[0]  );
499
500  if (m_abUseSAO.size() < 2)
501    m_abUseSAO.push_back            ( m_abUseSAO[0] );
502#endif
503
504#if HHI_VSO
505  if ( m_bUseVSO )
506  {
507    if ( m_iNumberOfExternalRefs != 0 )
508    {
509      xCleanUpVector( m_aaiERViewRefInd,    vector<Int>() );
510      xCleanUpVector( m_aaiBaseViewRefInd,  vector<Int>() );
511    }
512    else
513    {
514      m_aaiERViewRefInd   .clear();
515      m_aaiERViewRefInd   .resize( m_iNumberOfViews );
516      m_aaiERViewRefLutInd.clear();
517      m_aaiERViewRefLutInd.resize( m_iNumberOfViews );
518      m_aaiBaseViewRefInd .clear();
519      m_aaiBaseViewRefInd .resize( m_iNumberOfViews );
520    }
521  }
522
523#if HHI_VSO_LS_TABLE
524  // Q&D
525  Double adLambdaScaleTable[] = 
526  {  0.031250, 0.031639, 0.032029, 0.032418, 0.032808, 0.033197, 0.033586, 0.033976, 0.034365, 0.034755, 
527     0.035144, 0.035533, 0.035923, 0.036312, 0.036702, 0.037091, 0.037480, 0.037870, 0.038259, 0.038648, 
528     0.039038, 0.039427, 0.039817, 0.040206, 0.040595, 0.040985, 0.041374, 0.041764, 0.042153, 0.042542, 
529     0.042932, 0.043321, 0.043711, 0.044100, 0.044194, 0.053033, 0.061872, 0.070711, 0.079550, 0.088388, 
530     0.117851, 0.147314, 0.176777, 0.235702, 0.294628, 0.353553, 0.471405, 0.589256, 0.707107, 0.707100, 
531     0.753550, 0.800000 
532  }; 
533  AOT( (m_aiQP[1] < 0) || (m_aiQP[1] > 51));
534  m_dLambdaScaleVSO *= adLambdaScaleTable[m_aiQP[1]]; 
535#endif
536#endif
537
538  // set global variables
539  xSetGlobal();
540
541  // read and check camera parameters
542#if HHI_VSO
543if ( m_bUseVSO && m_uiVSOMode == 4)
544{
545  m_cRenModStrParser.setString( m_iNumberOfViews, m_pchVSOConfig );
546  m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
547                                      m_uiInputBitDepth,
548                                (UInt)m_iCodedCamParPrecision,
549                                      m_FrameSkip,
550                                (UInt)m_iFrameToBeEncoded,
551                                      m_pchCameraParameterFile,
552                                      m_pchBaseViewCameraNumbers,
553                                      NULL,
554                                      m_cRenModStrParser.getSynthViews(),
555                                      LOG2_DISP_PREC_LUT
556#if POZNAN_NONLINEAR_DEPTH                                     
557                                      ,m_fDepthPower
558#endif
559                                      );
560}
561else if ( m_bUseVSO && m_uiVSOMode != 4 )
562{
563  m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
564                                      m_uiInputBitDepth,
565                                (UInt)m_iCodedCamParPrecision,
566                                      m_FrameSkip,
567                                (UInt)m_iFrameToBeEncoded,
568                                      m_pchCameraParameterFile,
569                                      m_pchBaseViewCameraNumbers,
570                                      m_pchVSOConfig,
571                                      NULL,
572                                      LOG2_DISP_PREC_LUT
573#if POZNAN_NONLINEAR_DEPTH                                     
574                                      ,m_fDepthPower
575#endif                                     
576                                      );
577}
578else
579{
580  m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
581    m_uiInputBitDepth,
582    (UInt)m_iCodedCamParPrecision,
583    m_FrameSkip,
584    (UInt)m_iFrameToBeEncoded,
585    m_pchCameraParameterFile,
586    m_pchBaseViewCameraNumbers,
587    NULL,
588    NULL,
589    LOG2_DISP_PREC_LUT
590#if POZNAN_NONLINEAR_DEPTH                                     
591    ,m_fDepthPower
592#endif   
593    );
594}
595#else
596  m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
597    m_uiInputBitDepth,
598    (UInt)m_iCodedCamParPrecision,
599    m_FrameSkip,
600    (UInt)m_iFrameToBeEncoded,
601    m_pchCameraParameterFile,
602    m_pchBaseViewCameraNumbers,
603    NULL,
604    NULL,
605    LOG2_DISP_PREC_LUT
606#if POZNAN_NONLINEAR_DEPTH                                     
607    ,m_fDepthPower
608#endif   
609    );
610#endif
611
612
613  // check validity of input parameters
614  xCheckParameter();
615  m_cCameraData.check( false, true );
616
617  // print-out parameters
618  xPrintParameter();
619
620  return true;
621}
622
623// ====================================================================================================================
624// Private member functions
625// ====================================================================================================================
626
627Bool confirmPara(Bool bflag, const char* message);
628
629Void TAppEncCfg::xCheckParameter()
630{
631  bool check_failed = false; /* abort if there is a fatal configuration problem */
632#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
633  // check range of parameters
634#if ENABLE_IBDI
635  xConfirmPara( m_uiInternalBitDepth > 0 && (int)m_uiBitIncrement != -1,                    "InternalBitDepth and BitIncrement may not be specified simultaneously");
636#else
637  xConfirmPara( m_uiInputBitDepth < 8,                                                      "InputBitDepth must be at least 8" );
638#endif
639  xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
640  xConfirmPara( m_iFrameToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 1" );
641  xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be more than 1" );
642#if DCM_DECODING_REFRESH
643  xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
644#endif
645//GT QP Depth
646  xConfirmPara( m_aiQP[0] < 0 || m_aiQP[0] > 51,                                             "QP exceeds supported range (0 to 51)" );
647  if ( m_aiQP.size() >= 2 )
648  {
649    xConfirmPara( m_aiQP[1] < 0 || m_aiQP[1] > 51,                                           "QP Depth exceeds supported range (0 to 51)" );
650  }
651//GT QP Depth End
652#if MQT_ALF_NPASS
653  xConfirmPara( m_iALFEncodePassReduction < 0 || m_iALFEncodePassReduction > 2,             "ALFEncodePassReduction must be equal to 0, 1 or 2");
654#endif
655  xConfirmPara( m_iLoopFilterAlphaC0Offset < -26 || m_iLoopFilterAlphaC0Offset > 26,        "Loop Filter Alpha Offset exceeds supported range (-26 to 26)" );
656  xConfirmPara( m_iLoopFilterBetaOffset < -26 || m_iLoopFilterBetaOffset > 26,              "Loop Filter Beta Offset exceeds supported range (-26 to 26)");
657  xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2,                                     "Fast Search Mode is not supported value (0:Full search  1:Diamond  2:PMVFAST)" );
658  xConfirmPara( m_iSearchRange < 0 ,                                                        "Search Range must be more than 0" );
659  xConfirmPara( m_bipredSearchRange < 0 ,                                                   "Search Range must be more than 0" );
660  xConfirmPara( m_iMaxDeltaQP > 7,                                                          "Absolute Delta QP exceeds supported range (0 to 7)" );
661  xConfirmPara( (m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,                                    "Minimum partition width size should be larger than or equal to 8");
662  xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4,                                    "Minimum partition height size should be larger than or equal to 8");
663  xConfirmPara( m_uiMaxCUWidth < 16,                                                        "Maximum partition width size should be larger than or equal to 16");
664  xConfirmPara( m_uiMaxCUHeight < 16,                                                       "Maximum partition height size should be larger than or equal to 16");
665  xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Frame width should be multiple of minimum CU size");
666  xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Frame height should be multiple of minimum CU size");
667
668  xConfirmPara( m_uiQuadtreeTULog2MinSize < 2,                                        "QuadtreeTULog2MinSize must be 2 or greater.");
669  xConfirmPara( m_uiQuadtreeTULog2MinSize > 5,                                        "QuadtreeTULog2MinSize must be 5 or smaller.");
670  xConfirmPara( m_uiQuadtreeTULog2MaxSize < 2,                                        "QuadtreeTULog2MaxSize must be 2 or greater.");
671  xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5,                                        "QuadtreeTULog2MaxSize must be 5 or smaller.");
672  xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize,                "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize.");
673  xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS
674  xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUHeight>>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS
675  xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUWidth  >> m_uiMaxCUDepth ), "Minimum CU width must be greater than minimum transform size." );
676  xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." );
677  xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1,                                                         "QuadtreeTUMaxDepthInter must be greater than or equal to 1" );
678  xConfirmPara( m_uiQuadtreeTUMaxDepthInter > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthInter must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" );
679  xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1,                                                         "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" );
680  xConfirmPara( m_uiQuadtreeTUMaxDepthIntra > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthIntra must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" );
681
682  xConfirmPara( m_iSliceMode < 0 || m_iSliceMode > 2, "SliceMode exceeds supported range (0 to 2)" );
683  if (m_iSliceMode!=0)
684  {
685    xConfirmPara( m_iSliceArgument < 1 ,         "SliceArgument should be larger than or equal to 1" );
686  }
687  xConfirmPara( m_iEntropySliceMode < 0 || m_iEntropySliceMode > 2, "EntropySliceMode exceeds supported range (0 to 2)" );
688  if (m_iEntropySliceMode!=0)
689  {
690    xConfirmPara( m_iEntropySliceArgument < 1 ,         "EntropySliceArgument should be larger than or equal to 1" );
691  }
692
693  xConfirmPara( m_iSymbolMode < 0 || m_iSymbolMode > 1,                                     "SymbolMode must be equal to 0 or 1" );
694
695  // Check MultiView stuff
696  xConfirmPara    ( m_iNumberOfViews > MAX_INPUT_VIEW_NUM ,                           "NumberOfViews must be less than or equal to MAX_INPUT_VIEW_NUM");
697  xConfirmPara    ( Int( m_pchInputFileList.size() ) < m_iNumberOfViews,              "Number of InputFiles must be greater than or equal to NumberOfViews" );
698  xConfirmPara    ( Int( m_pchReconFileList.size() ) < m_iNumberOfViews,              "Number of ReconFiles must be greater than or equal to NumberOfViews" );
699
700  xConfirmPara    ( m_iCodedCamParPrecision < 0 || m_iCodedCamParPrecision > 5,       "CodedCamParsPrecision must be in range of 0..5" );
701#if DEPTH_MAP_GENERATION
702  xConfirmPara    ( m_uiPredDepthMapGeneration > 2,                                   "PredDepthMapGen must be less than or equal to 2" );
703  xConfirmPara    ( m_uiPredDepthMapGeneration >= 2 && !m_bUsingDepthMaps,            "PredDepthMapGen >= 2 requires CodeDepthMaps = 1" );
704#endif
705#if HHI_INTER_VIEW_MOTION_PRED
706  xConfirmPara    ( m_uiMultiviewMvPredMode > 7,                                      "MultiviewMvPred must be less than or equal to 7" );
707  xConfirmPara    ( m_uiMultiviewMvPredMode > 0 && m_uiPredDepthMapGeneration == 0 ,  "MultiviewMvPred > 0 requires PredDepthMapGen > 0" );
708  xConfirmPara    ( m_uiMultiviewMvRegMode       > 1,                                 "MultiviewMvRegMode must be less than or equal to 1" );
709  xConfirmPara    ( m_dMultiviewMvRegLambdaScale < 0.0,                               "MultiviewMvRegLambdaScale must not be negative" );
710  if( m_uiMultiviewMvRegMode )
711  {
712    xConfirmPara  ( Int( m_pchDepthInputFileList.size() ) < m_iNumberOfViews,         "MultiviewMvRegMode > 0 requires the presence of input depth maps" );
713  }
714#endif
715#if HHI_INTER_VIEW_RESIDUAL_PRED
716  xConfirmPara    ( m_uiMultiviewResPredMode > 1,                                     "MultiviewResPred must be less than or equal to 1" );
717  xConfirmPara    ( m_uiMultiviewResPredMode > 0 && m_uiPredDepthMapGeneration == 0 , "MultiviewResPred > 0 requires PredDepthMapGen > 0" );
718#endif
719
720#if POZNAN_DBMP
721  xConfirmPara    ( m_uiDBMP > 1,                                                                                                       "DBMP must be less than or equal to 1" );
722#endif
723
724#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
725  xConfirmPara    ( m_uiUseCUSkip > 1,                                                                                          "CU-Skip must be less than or equal to 1" );
726#endif
727
728#if HHI_INTERVIEW_SKIP
729  xConfirmPara    ( m_uiInterViewSkip > 1,                                        "RenderingSkipMode > 1 not supported" );
730  xConfirmPara    ( m_uiInterViewSkip > 0 && !m_bUsingDepthMaps,                  "RenderingSkipMode > 0 requires CodeDepthMaps = 1" );
731#endif
732  if( m_bUsingDepthMaps )
733  {
734    xConfirmPara  ( Int( m_pchDepthInputFileList.size() ) < m_iNumberOfViews,         "Number of DepthInputFiles must be greater than or equal to NumberOfViews" );
735    xConfirmPara  ( Int( m_pchDepthReconFileList.size() ) < m_iNumberOfViews,         "Number of DepthReconFiles must be greater than or equal to NumberOfViews" );
736
737#if HHI_VSO
738    if( m_bUseVSO )
739    {
740      xConfirmPara( m_pchCameraParameterFile    == 0                             ,   "CameraParameterFile must be given");
741      xConfirmPara(   m_pchVSOConfig            == 0                             ,   "VSO Setup string must be given");
742      xConfirmPara( m_pchBaseViewCameraNumbers  == 0                             ,   "BaseViewCameraNumbers must be given" );
743      xConfirmPara( m_iNumberOfViews != m_cCameraData.getBaseViewNumbers().size(),   "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" );
744      xConfirmPara( m_uiVSOMode < 0 || m_uiVSOMode > 4 ,                             "VSO Mode must be greater than or equal to 0 and less than 5");
745      xConfirmPara( m_iNumberOfExternalRefs               > MAX_ERREF_VIEW_NUM,      "NumberOfExternalRefs must be less than of equal to TAppMVEncCfg::MAX_ERREF_VIEW_NUM" );
746      xConfirmPara( Int( m_pchERRefFileList .size() ) < m_iNumberOfExternalRefs,     "Number of ERRefFileFiles  must be greater than or equal to NumberOfExternalRefs" );
747    }
748#endif
749  }
750
751#if DCM_COMB_LIST
752#if !HHI_NO_LowDelayCoding
753  xConfirmPara( m_bUseLComb==false && m_bUseLDC==false,         "LComb can only be 0 if LowDelayCoding is 1" );
754#else
755  xConfirmPara( m_bUseLComb==false,                             "LComb can only be 0 if LowDelayCoding is 1" );
756#endif
757#endif
758
759  // max CU width and height should be power of 2
760  UInt ui = m_uiMaxCUWidth;
761  while(ui)
762  {
763    ui >>= 1;
764    if( (ui & 1) == 1)
765      xConfirmPara( ui != 1 , "Width should be 2^n");
766  }
767  ui = m_uiMaxCUHeight;
768  while(ui)
769  {
770    ui >>= 1;
771    if( (ui & 1) == 1)
772      xConfirmPara( ui != 1 , "Height should be 2^n");
773  }
774
775  // SBACRD is supported only for SBAC
776  if ( m_iSymbolMode == 0 )
777  {
778    m_bUseSBACRD = false;
779  }
780
781#undef xConfirmPara
782  if (check_failed)
783  {
784    exit(EXIT_FAILURE);
785  }
786}
787
788template <class T>
789Void
790TAppEncCfg::xCleanUpVector( std::vector<T>& rcVec, const T& rcInvalid )
791{
792  Int iFirstInv = (Int)rcVec.size();
793  for( Int iIdx = 0; iIdx < (Int)rcVec.size(); iIdx++ )
794  {
795    if( rcVec[ iIdx ] == rcInvalid )
796    {
797      iFirstInv = iIdx;
798      break;
799    }
800  }
801  while( (Int)rcVec.size() > iFirstInv )
802  {
803    rcVec.pop_back();
804  }
805}
806
807Void
808TAppEncCfg::xCleanUpVectors()
809{
810  xCleanUpVector( m_pchInputFileList,       (char*)0 );
811  xCleanUpVector( m_pchDepthInputFileList,  (char*)0 );
812  xCleanUpVector( m_pchReconFileList,       (char*)0 );
813  xCleanUpVector( m_pchDepthReconFileList,  (char*)0 );
814
815#if HHI_VSO
816  if ( m_bUseVSO)
817  {
818    xCleanUpVector( m_pchERRefFileList,       (char*)0 );
819  }
820#endif
821}
822
823/** \todo use of global variables should be removed later
824 */
825Void TAppEncCfg::xSetGlobal()
826{
827  // set max CU width & height
828  g_uiMaxCUWidth  = m_uiMaxCUWidth;
829  g_uiMaxCUHeight = m_uiMaxCUHeight;
830
831  // compute actual CU depth with respect to config depth and max transform size
832  g_uiAddCUDepth  = 0;
833  while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth )  ) ) g_uiAddCUDepth++;
834
835  m_uiMaxCUDepth += g_uiAddCUDepth;
836  g_uiAddCUDepth++;
837  g_uiMaxCUDepth = m_uiMaxCUDepth;
838
839  // set internal bit-depth and constants
840#if ENABLE_IBDI
841  if ((int)m_uiBitIncrement != -1)
842  {
843    g_uiBitDepth = m_uiInputBitDepth;
844    g_uiBitIncrement = m_uiBitIncrement;
845    m_uiInternalBitDepth = g_uiBitDepth + g_uiBitIncrement;
846  }
847  else
848  {
849    g_uiBitDepth = min(8u, m_uiInputBitDepth);
850    if (m_uiInternalBitDepth == 0) {
851      /* default increement = 2 */
852      m_uiInternalBitDepth = 2 + g_uiBitDepth;
853    }
854    g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth;
855  }
856#else
857#if FULL_NBIT
858  g_uiBitDepth = m_uiInternalBitDepth;
859  g_uiBitIncrement = 0;
860#else
861  g_uiBitDepth = 8;
862  g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth;
863#endif
864#endif
865#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
866  g_dDeltaDCsQuantOffset = Double(g_uiBitIncrement) -  2.0;
867#endif
868
869  g_uiBASE_MAX     = ((1<<(g_uiBitDepth))-1);
870
871#if IBDI_NOCLIP_RANGE
872  g_uiIBDI_MAX     = g_uiBASE_MAX << g_uiBitIncrement;
873#else
874  g_uiIBDI_MAX     = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1);
875#endif
876
877  if (m_uiOutputBitDepth == 0)
878  {
879    m_uiOutputBitDepth = m_uiInternalBitDepth;
880  }
881}
882
883Void TAppEncCfg::xPrintParameter()
884{
885  printf("\n");
886  for( Int iCounter = 0; iCounter<m_iNumberOfViews; iCounter++)
887  {
888    printf("Input          File %i        : %s\n", iCounter, m_pchInputFileList[iCounter]);
889  }
890  for( Int iCounter = 0; iCounter < (Int)m_pchDepthInputFileList.size(); iCounter++)
891  {
892    printf("DepthInput     File %i        : %s\n", iCounter, m_pchDepthInputFileList[iCounter]);
893  }
894  printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
895  for( Int iCounter = 0; iCounter<m_iNumberOfViews; iCounter++)
896  {
897    printf("Reconstruction File %i        : %s\n", iCounter, m_pchReconFileList[iCounter]);
898  }
899
900  for( Int iCounter = 0; iCounter<(Int)m_pchDepthReconFileList.size(); iCounter++)
901  {
902    printf("Reconstruction Depth File %i  : %s\n", iCounter, m_pchDepthReconFileList[iCounter]);
903  }
904  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_aiPad[0], m_iSourceHeight-m_aiPad[1], m_iFrameRate );
905  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
906  printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_iFrameToBeEncoded-1, m_iFrameToBeEncoded );
907  printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
908  printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
909  printf("Max RQT depth inter          : %d\n", m_uiQuadtreeTUMaxDepthInter);
910  printf("Max RQT depth intra          : %d\n", m_uiQuadtreeTUMaxDepthIntra);
911  printf("Motion search range          : %d\n", m_iSearchRange );
912#if DCM_DECODING_REFRESH
913  printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType );
914#endif
915  printf("QP                           : %5.2f\n", m_adQP[0] );
916  printf("QP Depth                     : %5.2f\n", m_adQP[ m_adQP.size()  < 2 ? 0 : 1] );
917  printf("Coded Picture Store Size     : %d\n", m_uiCodedPictureStoreSize);
918  printf("GOP size                     : %d\n", m_iGOPSize );
919  printf("Rate GOP size                : %d\n", m_iRateGOPSize );
920  printf("Internal bit depth           : %d\n", m_uiInternalBitDepth );
921
922  if ( m_iSymbolMode == 0 )
923  {
924    printf("Entropy coder                : VLC\n");
925  }
926  else if( m_iSymbolMode == 1 )
927  {
928    printf("Entropy coder                : CABAC\n");
929  }
930  else if( m_iSymbolMode == 2 )
931  {
932    printf("Entropy coder                : PIPE\n");
933  }
934  else
935  {
936    assert(0);
937  }
938
939  printf("GOP Format String            : %s\n", m_cInputFormatString.c_str() );
940  printf("Loop Filter Disabled         : %d %d\n", m_abLoopFilterDisable[0] ? 1 : 0,  m_abLoopFilterDisable[1] ? 1 : 0 );
941  printf("Coded Camera Param. Precision: %d\n", m_iCodedCamParPrecision);
942
943#if HHI_VSO
944  printf("Force use of Lambda Scale    : %d\n", m_bForceLambdaScaleVSO );
945
946  if ( m_bUseVSO )
947  {
948    printf("VSO Lambda Scale             : %5.2f\n", m_dLambdaScaleVSO );
949    printf("VSO Mode                     : %d\n",    m_uiVSOMode       );
950    printf("VSO Config                   : %s\n",    m_pchVSOConfig    );
951#if HHI_VSO_DIST_INT
952    printf("VSO Negative Distortion      : %d\n",    m_bAllowNegDist ? 1 : 0);
953#endif
954  }
955#endif
956
957
958  printf("\n");
959
960  printf("TOOL CFG GENERAL: ");
961  printf("IBD:%d ", !!g_uiBitIncrement);
962  printf("HAD:%d ", m_bUseHADME           );
963  printf("SRD:%d ", m_bUseSBACRD          );
964  printf("SQP:%d ", m_uiDeltaQpRD         );
965  printf("ASR:%d ", m_bUseASR             );
966  printf("PAD:%d ", m_bUsePAD             );
967  printf("LDC:%d ", m_bUseLDC             );
968#if DCM_COMB_LIST
969  printf("LComb:%d ", m_bUseLComb         );
970  printf("LCMod:%d ", m_bLCMod         );
971#endif
972  printf("FEN:%d ", m_bUseFastEnc         );
973  printf("RQT:%d ", 1     );
974  printf("MRG:%d ", m_bUseMRG             ); // SOPH: Merge Mode
975#if LM_CHROMA
976  printf("LMC:%d ", m_bUseLMChroma        );
977#endif
978#if HHI_RMP_SWITCH
979  printf("RMP:%d ", m_bUseRMP);
980#endif
981  printf("Slice:%d ",m_iSliceMode);
982  if (m_iSliceMode!=0)
983  {
984    printf("(%d) ", m_iSliceArgument);
985  }
986  printf("EntropySlice:%d ",m_iEntropySliceMode);
987  if (m_iEntropySliceMode!=0)
988  {
989    printf("(%d) ", m_iEntropySliceArgument);
990  }
991#if CONSTRAINED_INTRA_PRED
992  printf("CIP:%d ", m_bUseConstrainedIntraPred);
993#endif
994#if MTK_SAO
995#endif
996
997#if POZNAN_MP
998  printf("POZNAN_MP(1){ ");
999
1000#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
1001  printf("dmg=1 ");
1002#else
1003  printf("dmg=0 ");
1004#endif
1005
1006#if POZNAN_MP_FILL
1007  printf("fill=%d ",POZNAN_MP_FILL_TYPE);
1008#else
1009  printf("fill=- ");
1010#endif
1011
1012#if POZNAN_DBMP
1013  printf("DBMP:%d ", m_uiDBMP);
1014  if(m_uiDBMP)
1015  {   
1016        printf("cand=%d ",POZNAN_DBMP_MERGE_POS);
1017#if POZNAN_DBMP_CALC_PRED_DATA
1018        printf("pr=1 ");
1019#else
1020        printf("pr=0 ");
1021#endif
1022#if POZNAN_DBMP_COMPRESS_ME_DATA
1023        printf("comp=1 ");
1024#else
1025        printf("comp=0 ");
1026#endif
1027#if POZNAN_DBMP_USE_IN_NONANCHOR_PIC_ONLY
1028        printf("na=1 ");
1029#else
1030        printf("na=0 ");
1031#endif
1032  }
1033#endif
1034  printf("} ");
1035#endif
1036
1037#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
1038  printf("CU-Skip:%d ", m_uiUseCUSkip);
1039#endif
1040
1041  printf("\n");
1042  printf("TOOL CFG VIDEO  : ");
1043  printf("ALF:%d ", (m_abUseALF [0] ? 1 : 0) );
1044  printf("SAO:%d ", (m_abUseSAO [0] ? 1 : 0));
1045  printf("RDQ:%d ", (m_abUseRDOQ[0] ? 1 : 0) );
1046#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
1047  printf("TDdQP:%d ", m_bUseTexDqpAccordingToDepth);
1048#endif
1049
1050  printf("\n");
1051
1052  printf("TOOL CFG DEPTH  : ");
1053  printf("ALF:%d ", (m_abUseALF [1] ? 1 : 0));
1054  printf("SAO:%d ", (m_abUseSAO [1] ? 1 : 0));
1055  printf("RDQ:%d ", (m_abUseRDOQ[1] ? 1 : 0));
1056#if HHI_VSO
1057  printf("VSO:%d ", m_bUseVSO             );
1058#endif
1059#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
1060  printf("DMM:%d ", m_bUseDMM );
1061#endif
1062#if HHI_MPI
1063  printf("MVI:%d ", m_bUseMVI ? 1 : 0 );
1064#endif
1065#if POZNAN_NONLINEAR_DEPTH
1066  printf("DepthPower:%f ", m_fDepthPower);
1067#endif
1068  printf("\n");
1069
1070  fflush(stdout);
1071}
1072
1073Void TAppEncCfg::xPrintUsage()
1074{
1075  printf( "          <name> = ALF - adaptive loop filter\n");
1076  printf( "                   IBD - bit-depth increasement\n");
1077  printf( "                   GPB - generalized B instead of P in low-delay mode\n");
1078  printf( "                   HAD - hadamard ME for fractional-pel\n");
1079  printf( "                   SRD - SBAC based RD estimation\n");
1080  printf( "                   RDQ - RDOQ\n");
1081  printf( "                   LDC - low-delay mode\n");
1082  printf( "                   NRF - non-reference frame marking in last layer\n");
1083  printf( "                   BQP - hier-P style QP assignment in low-delay mode\n");
1084  printf( "                   PAD - automatic source padding of multiple of 16\n");
1085  printf( "                   ASR - adaptive motion search range\n");
1086  printf( "                   FEN - fast encoder setting\n");
1087  printf( "                   MRG - merging of motion partitions\n"); // SOPH: Merge Mode
1088
1089#if LM_CHROMA
1090  printf( "                   LMC - intra chroma prediction based on luma\n");
1091#endif
1092
1093  printf( "\n" );
1094  printf( "  Example 1) TAppEncoder.exe -c test.cfg -q 32 -g 8 -f 9 -s 64 -h 4\n");
1095  printf("              -> QP 32, hierarchical-B GOP 8, 9 frames, 64x64-8x8 CU (~4x4 PU)\n\n");
1096  printf( "  Example 2) TAppEncoder.exe -c test.cfg -q 32 -g 4 -f 9 -s 64 -h 4 -1 LDC\n");
1097  printf("              -> QP 32, hierarchical-P GOP 4, 9 frames, 64x64-8x8 CU (~4x4 PU)\n\n");
1098}
1099
1100Bool confirmPara(Bool bflag, const char* message)
1101{
1102  if (!bflag)
1103    return false;
1104
1105  printf("Error: %s\n",message);
1106  return true;
1107}
1108
1109/* helper function */
1110/* for handling "-1/-0 FOO" */
1111void translateOldStyleCmdline(const char* value, po::Options& opts, const std::string& arg)
1112{
1113  const char* argv[] = {arg.c_str(), value};
1114  /* replace some short names with their long name varients */
1115  if (arg == "LDC")
1116  {
1117    argv[0] = "LowDelayCoding";
1118  }
1119  else if (arg == "RDQ")
1120  {
1121    argv[0] = "RDOQ";
1122  }
1123  else if (arg == "HAD")
1124  {
1125    argv[0] = "HadamardME";
1126  }
1127  else if (arg == "SRD")
1128  {
1129    argv[0] = "SBACRD";
1130  }
1131  else if (arg == "IBD")
1132  {
1133    argv[0] = "BitIncrement";
1134  }
1135  /* issue a warning for change in FEN behaviour */
1136  if (arg == "FEN")
1137  {
1138    /* xxx todo */
1139  }
1140  po::storePair(opts, argv[0], argv[1]);
1141}
1142
1143void doOldStyleCmdlineOn(po::Options& opts, const std::string& arg)
1144{
1145  if (arg == "IBD")
1146  {
1147    translateOldStyleCmdline("4", opts, arg);
1148    return;
1149  }
1150  translateOldStyleCmdline("1", opts, arg);
1151}
1152
1153void doOldStyleCmdlineOff(po::Options& opts, const std::string& arg)
1154{
1155  translateOldStyleCmdline("0", opts, arg);
1156}
1157
1158Void TAppEncCfg::xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName)
1159{
1160  size_t iInLength     = strlen(pchInputFileName);
1161  size_t iAppendLength = strlen(pchStringToAppend);
1162
1163  rpchOutputFileName = (Char*) malloc(iInLength+iAppendLength+1);
1164  Char* pCDot = strrchr(pchInputFileName,'.');
1165  pCDot = pCDot ? pCDot : pchInputFileName + iInLength;
1166  size_t iCharsToDot = pCDot - pchInputFileName ;
1167  size_t iCharsToEnd = iInLength - iCharsToDot;
1168  strncpy(rpchOutputFileName                            ,  pchInputFileName            , iCharsToDot  );
1169  strncpy(rpchOutputFileName+ iCharsToDot               ,  pchStringToAppend           , iAppendLength);
1170  strncpy(rpchOutputFileName+ iCharsToDot+iAppendLength ,  pchInputFileName+iCharsToDot, iCharsToEnd  );
1171  rpchOutputFileName[iInLength+iAppendLength] = '\0';
1172}
Note: See TracBrowser for help on using the repository browser.