source: SHVCSoftware/branches/HM-10.0-dev-SHM/source/App/TAppEncoder/TAppEncCfg.h @ 1606

Last change on this file since 1606 was 56, checked in by seregin, 12 years ago

Intra-BL porting

File size: 23.2 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-2013, 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.h
35    \brief    Handle encoder configuration parameters (header)
36*/
37
38#ifndef __TAPPENCCFG__
39#define __TAPPENCCFG__
40
41#include "TLibCommon/CommonDef.h"
42
43#include "TLibEncoder/TEncCfg.h"
44#if SVC_EXTENSION
45#include "TAppEncLayerCfg.h"
46#endif
47#include <sstream>
48//! \ingroup TAppEncoder
49//! \{
50
51// ====================================================================================================================
52// Class definition
53// ====================================================================================================================
54
55/// encoder configuration class
56class TAppEncCfg
57{
58protected:
59  // file I/O
60#if SVC_EXTENSION
61  TAppEncLayerCfg m_acLayerCfg [MAX_LAYERS]; 
62  Int       m_numLayers;                                      ///< number of layers
63
64  Char*     m_pBitstreamFile;                                 ///< output bitstream file
65  Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
66  // source specification
67  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
68  Int       m_framesToBeEncoded;                              ///< number of encoded frames
69#if AVC_SYNTAX
70  char*     m_BLSyntaxFile;                                   ///< input syntax file
71#endif
72#else
73  Char*     m_pchInputFile;                                   ///< source file name
74  Char*     m_pchBitstreamFile;                               ///< output bitstream file
75  Char*     m_pchReconFile;                                   ///< output reconstruction file
76  Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
77  // source specification
78  Int       m_iFrameRate;                                     ///< source frame-rates (Hz)
79  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
80  Int       m_iSourceWidth;                                   ///< source width in pixel
81  Int       m_iSourceHeight;                                  ///< source height in pixel
82  Int       m_conformanceMode;
83  Int       m_confLeft;
84  Int       m_confRight;
85  Int       m_confTop;
86  Int       m_confBottom;
87  Int       m_framesToBeEncoded;                              ///< number of encoded frames
88  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
89#endif 
90
91  // profile/level
92  Profile::Name m_profile;
93  Level::Tier   m_levelTier;
94  Level::Name   m_level;
95#if L0046_CONSTRAINT_FLAGS
96  Bool m_progressiveSourceFlag;
97  Bool m_interlacedSourceFlag;
98  Bool m_nonPackedConstraintFlag;
99  Bool m_frameOnlyConstraintFlag;
100#endif
101 
102  // coding structure
103#if !SVC_EXTENSION
104  Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
105#endif
106  Int       m_iDecodingRefreshType;                           ///< random access type
107  Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
108  Int       m_extraRPSs;                                      ///< extra RPSs added to handle CRA
109  GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
110  Int       m_numReorderPics[MAX_TLAYER];                     ///< total number of reorder pictures
111  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of reference pictures needed for decoding
112  Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
113  Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
114  Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
115  Bool      m_enableAMP;
116  // coding quality
117#if !SVC_EXTENSION
118  Double    m_fQP;                                            ///< QP value of key-picture (floating point)
119  Int       m_iQP;                                            ///< QP value of key-picture (integer)
120  Char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
121  Int*      m_aidQP;                                          ///< array of slice QP values
122#endif
123  Int       m_iMaxDeltaQP;                                    ///< max. |delta QP|
124  UInt      m_uiDeltaQpRD;                                    ///< dQP range for multi-pass slice QP optimization
125  Int       m_iMaxCuDQPDepth;                                 ///< Max. depth for a minimum CuDQPSize (0:default)
126
127  Int       m_cbQpOffset;                                     ///< Chroma Cb QP Offset (0:default)
128  Int       m_crQpOffset;                                     ///< Chroma Cr QP Offset (0:default)
129
130#if ADAPTIVE_QP_SELECTION
131  Bool      m_bUseAdaptQpSelect;
132#endif
133
134  Bool      m_bUseAdaptiveQP;                                 ///< Flag for enabling QP adaptation based on a psycho-visual model
135  Int       m_iQPAdaptationRange;                             ///< dQP range by QP adaptation
136 
137  Int       m_maxTempLayer;                                  ///< Max temporal layer
138
139  // coding unit (CU) definition
140  UInt      m_uiMaxCUWidth;                                   ///< max. CU width in pixel
141  UInt      m_uiMaxCUHeight;                                  ///< max. CU height in pixel
142  UInt      m_uiMaxCUDepth;                                   ///< max. CU depth
143 
144  // transfom unit (TU) definition
145  UInt      m_uiQuadtreeTULog2MaxSize;
146  UInt      m_uiQuadtreeTULog2MinSize;
147 
148  UInt      m_uiQuadtreeTUMaxDepthInter;
149  UInt      m_uiQuadtreeTUMaxDepthIntra;
150 
151  // coding tools (bit-depth)
152  Int       m_inputBitDepthY;                               ///< bit-depth of input file (luma component)
153  Int       m_inputBitDepthC;                               ///< bit-depth of input file (chroma component)
154  Int       m_outputBitDepthY;                              ///< bit-depth of output file (luma component)
155  Int       m_outputBitDepthC;                              ///< bit-depth of output file (chroma component)
156  Int       m_internalBitDepthY;                            ///< bit-depth codec operates at in luma (input/output files will be converted)
157  Int       m_internalBitDepthC;                            ///< bit-depth codec operates at in chroma (input/output files will be converted)
158
159  // coding tools (PCM bit-depth)
160  Bool      m_bPCMInputBitDepthFlag;                          ///< 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
161
162  // coding tool (lossless)
163  Bool      m_useLossless;                                    ///< flag for using lossless coding
164  Bool      m_bUseSAO; 
165  Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
166  Bool      m_saoLcuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
167  Bool      m_saoLcuBasedOptimization;                        ///< SAO LCU-based optimization
168  // coding tools (loop filter)
169  Bool      m_bLoopFilterDisable;                             ///< flag for using deblocking filter
170  Bool      m_loopFilterOffsetInPPS;                         ///< offset for deblocking filter in 0 = slice header, 1 = PPS
171  Int       m_loopFilterBetaOffsetDiv2;                     ///< beta offset for deblocking filter
172  Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
173  Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
174 
175  // coding tools (PCM)
176  Bool      m_usePCM;                                         ///< flag for using IPCM
177  UInt      m_pcmLog2MaxSize;                                 ///< log2 of maximum PCM block size
178  UInt      m_uiPCMLog2MinSize;                               ///< log2 of minimum PCM block size
179  Bool      m_bPCMFilterDisableFlag;                          ///< PCM filter disable flag
180
181  // coding tools (encoder-only parameters)
182  Bool      m_bUseSBACRD;                                     ///< flag for using RD optimization based on SBAC
183  Bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
184  Bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
185  Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
186  Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
187#if L0232_RD_PENALTY
188  Int      m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty)
189#endif
190  Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
191  Int       m_iSearchRange;                                   ///< ME search range
192  Int       m_bipredSearchRange;                              ///< ME search range for bipred refinement
193  Bool      m_bUseFastEnc;                                    ///< flag for using fast encoder setting
194  Bool      m_bUseEarlyCU;                                    ///< flag for using Early CU setting
195  Bool      m_useFastDecisionForMerge;                        ///< flag for using Fast Decision Merge RD-Cost
196  Bool      m_bUseCbfFastMode;                              ///< flag for using Cbf Fast PU Mode Decision
197  Bool      m_useEarlySkipDetection;                         ///< flag for using Early SKIP Detection
198  Int       m_sliceMode;                                     ///< 0: no slice limits, 1 : max number of CTBs per slice, 2: max number of bytes per slice,
199                                                             ///< 3: max number of tiles per slice
200  Int       m_sliceArgument;                                 ///< argument according to selected slice mode
201  Int       m_sliceSegmentMode;                              ///< 0: no slice segment limits, 1 : max number of CTBs per slice segment, 2: max number of bytes per slice segment,
202                                                             ///< 3: max number of tiles per slice segment
203  Int       m_sliceSegmentArgument;                          ///< argument according to selected slice segment mode
204
205  Bool      m_bLFCrossSliceBoundaryFlag;  ///< 1: filter across slice boundaries 0: do not filter across slice boundaries
206  Bool      m_bLFCrossTileBoundaryFlag;   ///< 1: filter across tile boundaries  0: do not filter across tile boundaries
207  Int       m_iUniformSpacingIdr;
208  Int       m_iNumColumnsMinus1;
209  Char*     m_pchColumnWidth;
210  Int       m_iNumRowsMinus1;
211  Char*     m_pchRowHeight;
212  UInt*     m_pColumnWidth;
213  UInt*     m_pRowHeight;
214  Int       m_iWaveFrontSynchro; //< 0: no WPP. >= 1: WPP is enabled, the "Top right" from which inheritance occurs is this LCU offset in the line above the current.
215#if !SVC_EXTENSION
216  Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
217#endif
218
219  Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
220 
221  Int       m_decodedPictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
222  Int       m_recoveryPointSEIEnabled;
223  Int       m_bufferingPeriodSEIEnabled;
224  Int       m_pictureTimingSEIEnabled;
225  Int       m_framePackingSEIEnabled;
226  Int       m_framePackingSEIType;
227  Int       m_framePackingSEIId;
228  Int       m_framePackingSEIQuincunx;
229  Int       m_framePackingSEIInterpretation;
230  Int       m_displayOrientationSEIAngle;
231  Int       m_temporalLevel0IndexSEIEnabled;
232  Int       m_gradualDecodingRefreshInfoEnabled;
233  Int       m_decodingUnitInfoSEIEnabled;
234  // weighted prediction
235  Bool      m_useWeightedPred;                    ///< Use of weighted prediction in P slices
236  Bool      m_useWeightedBiPred;                  ///< Use of bi-directional weighted prediction in B slices
237 
238  UInt      m_log2ParallelMergeLevel;                         ///< Parallel merge estimation region
239  UInt      m_maxNumMergeCand;                                ///< Max number of merge candidates
240
241  Int       m_TMVPModeId;
242  Int       m_signHideFlag;
243#if RATE_CONTROL_LAMBDA_DOMAIN
244  Bool      m_RCEnableRateControl;                ///< enable rate control or not
245  Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
246  Bool      m_RCKeepHierarchicalBit;              ///< whether keeping hierarchical bit allocation structure or not
247  Bool      m_RCLCULevelRC;                       ///< true: LCU level rate control; false: picture level rate control
248  Bool      m_RCUseLCUSeparateModel;              ///< use separate R-lambda model at LCU level
249  Int       m_RCInitialQP;                        ///< inital QP for rate control
250  Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
251#else
252  Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
253  Int       m_targetBitrate;                                 ///< target bitrate
254  Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be completely divided by the NumLCUInUnit
255#endif
256  Int       m_useScalingListId;                               ///< using quantization matrix
257  Char*     m_scalingListFile;                                ///< quantization matrix file name
258
259  Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
260  Bool      m_CUTransquantBypassFlagValue;                    ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag.
261
262  Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
263  Bool      m_useStrongIntraSmoothing;                        ///< enable strong intra smoothing for 32x32 blocks where the reference samples are flat
264  Int       m_activeParameterSetsSEIEnabled;
265
266  Bool      m_vuiParametersPresentFlag;                       ///< enable generation of VUI parameters
267  Bool      m_aspectRatioInfoPresentFlag;                     ///< Signals whether aspect_ratio_idc is present
268  Int       m_aspectRatioIdc;                                 ///< aspect_ratio_idc
269  Int       m_sarWidth;                                       ///< horizontal size of the sample aspect ratio
270  Int       m_sarHeight;                                      ///< vertical size of the sample aspect ratio
271  Bool      m_overscanInfoPresentFlag;                        ///< Signals whether overscan_appropriate_flag is present
272  Bool      m_overscanAppropriateFlag;                        ///< Indicates whether conformant decoded pictures are suitable for display using overscan
273  Bool      m_videoSignalTypePresentFlag;                     ///< Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present
274  Int       m_videoFormat;                                    ///< Indicates representation of pictures
275  Bool      m_videoFullRangeFlag;                             ///< Indicates the black level and range of luma and chroma signals
276  Bool      m_colourDescriptionPresentFlag;                   ///< Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present
277  Int       m_colourPrimaries;                                ///< Indicates chromaticity coordinates of the source primaries
278  Int       m_transferCharacteristics;                        ///< Indicates the opto-electronic transfer characteristics of the source
279  Int       m_matrixCoefficients;                             ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries
280  Bool      m_chromaLocInfoPresentFlag;                       ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present
281  Int       m_chromaSampleLocTypeTopField;                    ///< Specifies the location of chroma samples for top field
282  Int       m_chromaSampleLocTypeBottomField;                 ///< Specifies the location of chroma samples for bottom field
283  Bool      m_neutralChromaIndicationFlag;                    ///< Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)
284  Bool      m_defaultDisplayWindowFlag;                       ///< Indicates the presence of the default window parameters
285  Int       m_defDispWinLeftOffset;                           ///< Specifies the left offset from the conformance window of the default window
286  Int       m_defDispWinRightOffset;                          ///< Specifies the right offset from the conformance window of the default window
287  Int       m_defDispWinTopOffset;                            ///< Specifies the top offset from the conformance window of the default window
288  Int       m_defDispWinBottomOffset;                         ///< Specifies the bottom offset from the conformance window of the default window
289  Bool      m_frameFieldInfoPresentFlag;                      ///< Indicates that pic_struct values are present in picture timing SEI messages
290  Bool      m_pocProportionalToTimingFlag;                    ///< Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS
291  Int       m_numTicksPocDiffOneMinus1;                       ///< Number of ticks minus 1 that for a POC difference of one
292  Bool      m_bitstreamRestrictionFlag;                       ///< Signals whether bitstream restriction parameters are present
293  Bool      m_tilesFixedStructureFlag;                        ///< Indicates that each active picture parameter set has the same values of the syntax elements related to tiles
294  Bool      m_motionVectorsOverPicBoundariesFlag;             ///< Indicates that no samples outside the picture boundaries are used for inter prediction
295  Int       m_minSpatialSegmentationIdc;                      ///< Indicates the maximum size of the spatial segments in the pictures in the coded video sequence
296  Int       m_maxBytesPerPicDenom;                            ///< Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture
297  Int       m_maxBitsPerMinCuDenom;                           ///< Indicates an upper bound for the number of bits of coding_unit() data
298  Int       m_log2MaxMvLengthHorizontal;                      ///< Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units
299  Int       m_log2MaxMvLengthVertical;                        ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
300
301#if REF_IDX_FRAMEWORK
302  Int       m_elRapSliceBEnabled;
303#endif
304  // internal member functions
305  Void  xSetGlobal      ();                                   ///< set global variables
306  Void  xCheckParameter ();                                   ///< check validity of configuration values
307  Void  xPrintParameter ();                                   ///< print configuration values
308  Void  xPrintUsage     ();                                   ///< print usage
309#if SIGNAL_BITRATE_PICRATE_IN_VPS
310  Int       m_bitRatePicRateMaxTLayers;                       ///< Indicates max. number of sub-layers for which bit rate is signalled.
311  Bool*     m_bitRateInfoPresentFlag;                         ///< Indicates whether bit rate information is signalled
312  Bool*     m_picRateInfoPresentFlag;                         ///< Indicates whether pic rate information is signalled
313  Int*      m_avgBitRate;                                     ///< Indicates avg. bit rate information for various sub-layers
314  Int*      m_maxBitRate;                                     ///< Indicates max. bit rate information for various sub-layers
315  Int*      m_avgPicRate;                                     ///< Indicates avg. picture rate information for various sub-layers
316  Int*      m_constantPicRateIdc;                                ///< Indicates constant picture rate idc for various sub-layers
317#endif
318  #
319public:
320  TAppEncCfg();
321  virtual ~TAppEncCfg();
322 
323public:
324  Void  create    ();                                         ///< create option handling class
325  Void  destroy   ();                                         ///< destroy option handling class
326  Bool  parseCfg  ( Int argc, Char* argv[] );                 ///< parse configuration file to fill member variables
327 
328#if SVC_EXTENSION
329  Int  getNumFrameToBeEncoded()    {return m_framesToBeEncoded; }
330  Int  getNumLayer()               {return m_numLayers;        }
331  Int  getGOPSize()                {return m_iGOPSize;          }
332  UInt getInternalBitDepthY()      {return m_internalBitDepthY; }
333  UInt getInternalBitDepthC()      {return m_internalBitDepthC; }
334  UInt getMaxCUWidth()             {return m_uiMaxCUWidth;      }
335  UInt getMaxCUHeight()            {return m_uiMaxCUHeight;     }
336  UInt getMaxCUDepth()             {return m_uiMaxCUDepth;      }
337  Int  getDecodingRefreshType()    {return m_iDecodingRefreshType; }
338  Int  getWaveFrontSynchro()        { return m_iWaveFrontSynchro; }
339  Void getDirFilename(string& filename, string& dir, const string path);
340#if AVC_SYNTAX
341  Char* getBLSyntaxFile()           { return m_BLSyntaxFile;      }
342#endif
343#endif
344};// END CLASS DEFINITION TAppEncCfg
345
346//! \}
347
348#endif // __TAPPENCCFG__
349
Note: See TracBrowser for help on using the repository browser.