source: SHVCSoftware/branches/SHM-1.0-dev/source/App/TAppEncoder/TAppEncCfg.h @ 757

Last change on this file since 757 was 2, checked in by seregin, 12 years ago

Initial import by Vadim Seregin <vseregin@…>

File size: 19.8 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6 * Copyright (c) 2010-2012, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TAppEncCfg.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_pchBitstreamFile;                               ///< output bitstream file
65  Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
66  // source specification
67  unsigned int m_FrameSkip;                                   ///< number of skipped frames from the beginning
68  Int       m_iFrameToBeEncoded;                              ///< number of encoded frames
69#else
70  char*     m_pchInputFile;                                   ///< source file name
71  char*     m_pchBitstreamFile;                               ///< output bitstream file
72  char*     m_pchReconFile;                                   ///< output reconstruction file
73  Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
74  // source specification
75  Int       m_iFrameRate;                                     ///< source frame-rates (Hz)
76  unsigned int m_FrameSkip;                                   ///< number of skipped frames from the beginning
77  Int       m_iSourceWidth;                                   ///< source width in pixel
78  Int       m_iSourceHeight;                                  ///< source height in pixel
79  Int       m_croppingMode;
80  Int       m_cropLeft;
81  Int       m_cropRight;
82  Int       m_cropTop;
83  Int       m_cropBottom;
84  Int       m_iFrameToBeEncoded;                              ///< number of encoded frames
85  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
86 
87  // coding structure
88  Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
89#endif
90  Int       m_iDecodingRefreshType;                           ///< random access type
91  Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
92  Int       m_extraRPSs;                                      ///< extra RPSs added to handle CRA
93  GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
94  Int       m_numReorderPics[MAX_TLAYER];                     ///< total number of reorder pictures
95  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of reference pictures needed for decoding
96  Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
97  Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
98  Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
99#if !REMOVE_NSQT
100  Bool      m_enableNSQT;                                     ///< flag for enabling NSQT
101#endif
102  Bool      m_enableAMP;
103  // coding quality
104#if !SVC_EXTENSION
105  Double    m_fQP;                                            ///< QP value of key-picture (floating point)
106  Int       m_iQP;                                            ///< QP value of key-picture (integer)
107  char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
108  Int*      m_aidQP;                                          ///< array of slice QP values
109#endif
110  Int       m_iMaxDeltaQP;                                    ///< max. |delta QP|
111  UInt      m_uiDeltaQpRD;                                    ///< dQP range for multi-pass slice QP optimization
112  Int       m_iMaxCuDQPDepth;                                 ///< Max. depth for a minimum CuDQPSize (0:default)
113
114  Int       m_cbQpOffset;                                     ///< Chroma Cb QP Offset (0:default)
115  Int       m_crQpOffset;                                     ///< Chroma Cr QP Offset (0:default)
116
117#if ADAPTIVE_QP_SELECTION
118  Bool      m_bUseAdaptQpSelect;
119#endif
120
121  Bool      m_bUseAdaptiveQP;                                 ///< Flag for enabling QP adaptation based on a psycho-visual model
122  Int       m_iQPAdaptationRange;                             ///< dQP range by QP adaptation
123 
124  Int       m_maxTempLayer;                                  ///< Max temporal layer
125
126  // coding unit (CU) definition
127  UInt      m_uiMaxCUWidth;                                   ///< max. CU width in pixel
128  UInt      m_uiMaxCUHeight;                                  ///< max. CU height in pixel
129  UInt      m_uiMaxCUDepth;                                   ///< max. CU depth
130 
131  // transfom unit (TU) definition
132  UInt      m_uiQuadtreeTULog2MaxSize;
133  UInt      m_uiQuadtreeTULog2MinSize;
134 
135  UInt      m_uiQuadtreeTUMaxDepthInter;
136  UInt      m_uiQuadtreeTUMaxDepthIntra;
137 
138  // coding tools (bit-depth)
139  UInt      m_uiInputBitDepth;                                ///< bit-depth of input file
140  UInt      m_uiOutputBitDepth;                               ///< bit-depth of output file
141  UInt      m_uiInternalBitDepth;                             ///< Internal bit-depth (BitDepth+BitIncrement)
142
143  // coding tools (PCM bit-depth)
144  Bool      m_bPCMInputBitDepthFlag;                          ///< 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
145  UInt      m_uiPCMBitDepthLuma;                              ///< PCM bit-depth for luma
146
147  // coding tool (lossless)
148  Bool      m_useLossless;                                    ///< flag for using lossless coding
149  Bool      m_bUseSAO; 
150  Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
151#if SAO_LCU_BOUNDARY
152  Bool      m_saoLcuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
153#endif
154  Bool      m_saoLcuBasedOptimization;                        ///< SAO LCU-based optimization
155  // coding tools (loop filter)
156#if !REMOVE_ALF
157  Bool      m_bUseALF;                                        ///< flag for using adaptive loop filter
158  Bool      m_alfLowLatencyEncoding;
159#endif
160  Bool      m_bLoopFilterDisable;                             ///< flag for using deblocking filter
161  Bool      m_loopFilterOffsetInPPS;                         ///< offset for deblocking filter in 0 = slice header, 1 = PPS
162  Int       m_loopFilterBetaOffsetDiv2;                     ///< beta offset for deblocking filter
163  Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
164  Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
165 
166#if !REMOVE_LMCHROMA
167  Bool      m_bUseLMChroma;                                  ///< JL: Chroma intra prediction based on luma signal
168#endif
169 
170  // coding tools (PCM)
171  Bool      m_usePCM;                                         ///< flag for using IPCM
172  UInt      m_pcmLog2MaxSize;                                 ///< log2 of maximum PCM block size
173  UInt      m_uiPCMLog2MinSize;                               ///< log2 of minimum PCM block size
174  Bool      m_bPCMFilterDisableFlag;                          ///< PCM filter disable flag
175
176  // coding tools (encoder-only parameters)
177  Bool      m_bUseSBACRD;                                     ///< flag for using RD optimization based on SBAC
178  Bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
179  Bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
180  Bool      m_bUseRDOQ;                                       ///< flag for using RD optimized quantization
181  Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
182  Int       m_iSearchRange;                                   ///< ME search range
183  Int       m_bipredSearchRange;                              ///< ME search range for bipred refinement
184  Bool      m_bUseFastEnc;                                    ///< flag for using fast encoder setting
185  Bool      m_bUseEarlyCU;                                    ///< flag for using Early CU setting
186  Bool      m_useFastDecisionForMerge;                        ///< flag for using Fast Decision Merge RD-Cost
187  Bool      m_bUseCbfFastMode;                              ///< flag for using Cbf Fast PU Mode Decision
188  Bool      m_useEarlySkipDetection;                         ///< flag for using Early SKIP Detection
189  Int       m_iSliceMode;           ///< 0: Disable all Recon slice limits, 1 : Maximum number of largest coding units per slice, 2: Maximum number of bytes in a slice
190  Int       m_iSliceArgument;       ///< If m_iSliceMode==1, m_iSliceArgument=max. # of largest coding units. If m_iSliceMode==2, m_iSliceArgument=max. # of bytes.
191  Int       m_iDependentSliceMode;    ///< 0: Disable all dependent slice limits, 1 : Maximum number of largest coding units per slice, 2: Constraint based dependent slice
192  Int       m_iDependentSliceArgument;///< If m_iDependentSliceMode==1, m_iEDependentSliceArgument=max. # of largest coding units. If m_iDependnetSliceMode==2, m_iDependnetSliceArgument=max. # of bins.
193#if DEPENDENT_SLICES
194#if TILES_WPP_ENTROPYSLICES_FLAGS
195  Bool      m_entropySliceEnabledFlag;
196#else
197  Bool       m_bCabacIndependentFlag;  // 0: CABAC dependence between slices, 1:CABAC independence between slices
198#endif
199#endif
200
201#if !REMOVE_FGS
202  Int       m_iSliceGranularity;///< 0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.
203#endif
204  Bool      m_bLFCrossSliceBoundaryFlag;  ///< 0: Cross-slice-boundary in-loop filtering 1: non-cross-slice-boundary in-loop filtering
205  Bool      m_bLFCrossTileBoundaryFlag;  //!< 1: Cross-tile-boundary in-loop filtering 0: non-cross-tile-boundary in-loop filtering
206  Int       m_iUniformSpacingIdr;
207  Int       m_iNumColumnsMinus1;
208  char*     m_pchColumnWidth;
209  Int       m_iNumRowsMinus1;
210  char*     m_pchRowHeight;
211  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.
212#if !SVC_EXTENSION
213  Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
214#endif
215
216  Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
217 
218  Int       m_decodePictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
219#if RECOVERY_POINT_SEI
220  Int       m_recoveryPointSEIEnabled;
221#endif
222#if BUFFERING_PERIOD_AND_TIMING_SEI
223  Int       m_bufferingPeriodSEIEnabled;
224  Int       m_pictureTimingSEIEnabled;
225#endif
226  // weighted prediction
227  Bool      m_bUseWeightPred;                                 ///< Use of explicit Weighting Prediction for P_SLICE
228  Bool      m_useWeightedBiPred;                                    ///< Use of Bi-Directional Weighting Prediction (B_SLICE)
229 
230  UInt      m_log2ParallelMergeLevel;                         ///< Parallel merge estimation region
231  UInt      m_maxNumMergeCand;                                ///< Max number of merge candidates
232
233  Int       m_TMVPModeId;
234  Int       m_signHideFlag;
235  Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
236  Int       m_targetBitrate;                                 ///< target bitrate
237  Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be completely divided by the NumLCUInUnit
238  Int       m_useScalingListId;                               ///< using quantization matrix
239  char*     m_scalingListFile;                                ///< quantization matrix file name
240
241  Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
242  Bool      m_CUTransquantBypassFlagValue;                    ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag.
243
244#if RECALCULATE_QP_ACCORDING_LAMBDA
245  Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
246#endif
247#if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
248  Int       m_activeParameterSetsSEIEnabled;
249#endif
250
251#if SUPPORT_FOR_VUI
252  Bool      m_vuiParametersPresentFlag;                       ///< enable generation of VUI parameters
253  Bool      m_aspectRatioInfoPresentFlag;                     ///< Signals whether aspect_ratio_idc is present
254  Int       m_aspectRatioIdc;                                 ///< aspect_ratio_idc
255  Int       m_sarWidth;                                       ///< horizontal size of the sample aspect ratio
256  Int       m_sarHeight;                                      ///< vertical size of the sample aspect ratio
257  Bool      m_overscanInfoPresentFlag;                        ///< Signals whether overscan_appropriate_flag is present
258  Bool      m_overscanAppropriateFlag;                        ///< Indicates whether cropped decoded pictures are suitable for display using overscan
259  Bool      m_videoSignalTypePresentFlag;                     ///< Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present
260  Int       m_videoFormat;                                    ///< Indicates representation of pictures
261  Bool      m_videoFullRangeFlag;                             ///< Indicates the black level and range of luma and chroma signals
262  Bool      m_colourDescriptionPresentFlag;                   ///< Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present
263  Int       m_colourPrimaries;                                ///< Indicates chromaticity coordinates of the source primaries
264  Int       m_transferCharacteristics;                        ///< Indicates the opto-electronic transfer characteristics of the source
265  Int       m_matrixCoefficients;                             ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries
266  Bool      m_chromaLocInfoPresentFlag;                       ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present
267  Int       m_chromaSampleLocTypeTopField;                    ///< Specifies the location of chroma samples for top field
268  Int       m_chromaSampleLocTypeBottomField;                 ///< Specifies the location of chroma samples for bottom field
269  Bool      m_neutralChromaIndicationFlag;                    ///< Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)
270  Bool      m_bitstreamRestrictionFlag;                       ///< Signals whether bitstream restriction parameters are present
271  Bool      m_tilesFixedStructureFlag;                        ///< Indicates that each active picture parameter set has the same values of the syntax elements related to tiles
272  Bool      m_motionVectorsOverPicBoundariesFlag;             ///< Indicates that no samples outside the picture boundaries are used for inter prediction
273  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
274  Int       m_maxBitsPerMinCuDenom;                           ///< Indicates an upper bound for the number of bits of coding_unit() data
275  Int       m_log2MaxMvLengthHorizontal;                      ///< Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units
276  Int       m_log2MaxMvLengthVertical;                        ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
277#endif
278#if REF_IDX_FRAMEWORK
279  Int       m_elRapSliceBEnabled;
280#endif
281  // internal member functions
282  Void  xSetGlobal      ();                                   ///< set global variables
283  Void  xCheckParameter ();                                   ///< check validity of configuration values
284  Void  xPrintParameter ();                                   ///< print configuration values
285  Void  xPrintUsage     ();                                   ///< print usage
286 
287public:
288  TAppEncCfg();
289  virtual ~TAppEncCfg();
290 
291public:
292  Void  create    ();                                         ///< create option handling class
293  Void  destroy   ();                                         ///< destroy option handling class
294  Bool  parseCfg  ( Int argc, Char* argv[] );                 ///< parse configuration file to fill member variables
295 
296#if SVC_EXTENSION
297  Int  getNumFrameToBeEncoded()    {return m_iFrameToBeEncoded; }
298  Int  getNumLayer()               {return m_numLayers;        }
299  Int  getGOPSize()                {return m_iGOPSize;          }
300  UInt getInternalBitDepth()       {return m_uiInternalBitDepth; }
301  UInt getMaxCUWidth()             {return m_uiMaxCUWidth;      }
302  UInt getMaxCUHeight()            {return m_uiMaxCUHeight;     }
303  UInt getMaxCUDepth()             {return m_uiMaxCUDepth;      }
304  Int  getDecodingRefreshType()    {return m_iDecodingRefreshType; }
305  Void getDirFilename(string& filename, string& dir, const string path);
306  Int  getWaveFrontSynchro()        { return m_iWaveFrontSynchro; }
307#endif
308};// END CLASS DEFINITION TAppEncCfg
309
310//! \}
311
312#endif // __TAPPENCCFG__
313
Note: See TracBrowser for help on using the repository browser.