source: SHVCSoftware/branches/SHM-1.1-dev/source/App/TAppEncoder/TAppEncCfg.h @ 1263

Last change on this file since 1263 was 38, checked in by seregin, 12 years ago

AVC_SYNTAX: initial porting of the AVC metadata file reading

File size: 20.0 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#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  unsigned int 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_croppingMode;
83  Int       m_cropLeft;
84  Int       m_cropRight;
85  Int       m_cropTop;
86  Int       m_cropBottom;
87  Int       m_iFrameToBeEncoded;                              ///< number of encoded frames
88  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
89 
90  // coding structure
91  Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
92#endif
93  Int       m_iDecodingRefreshType;                           ///< random access type
94  Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
95  Int       m_extraRPSs;                                      ///< extra RPSs added to handle CRA
96  GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
97  Int       m_numReorderPics[MAX_TLAYER];                     ///< total number of reorder pictures
98  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of reference pictures needed for decoding
99  Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
100  Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
101  Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
102#if !REMOVE_NSQT
103  Bool      m_enableNSQT;                                     ///< flag for enabling NSQT
104#endif
105  Bool      m_enableAMP;
106  // coding quality
107#if !SVC_EXTENSION
108  Double    m_fQP;                                            ///< QP value of key-picture (floating point)
109  Int       m_iQP;                                            ///< QP value of key-picture (integer)
110  char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
111  Int*      m_aidQP;                                          ///< array of slice QP values
112#endif
113  Int       m_iMaxDeltaQP;                                    ///< max. |delta QP|
114  UInt      m_uiDeltaQpRD;                                    ///< dQP range for multi-pass slice QP optimization
115  Int       m_iMaxCuDQPDepth;                                 ///< Max. depth for a minimum CuDQPSize (0:default)
116
117  Int       m_cbQpOffset;                                     ///< Chroma Cb QP Offset (0:default)
118  Int       m_crQpOffset;                                     ///< Chroma Cr QP Offset (0:default)
119
120#if ADAPTIVE_QP_SELECTION
121  Bool      m_bUseAdaptQpSelect;
122#endif
123
124  Bool      m_bUseAdaptiveQP;                                 ///< Flag for enabling QP adaptation based on a psycho-visual model
125  Int       m_iQPAdaptationRange;                             ///< dQP range by QP adaptation
126 
127  Int       m_maxTempLayer;                                  ///< Max temporal layer
128
129  // coding unit (CU) definition
130  UInt      m_uiMaxCUWidth;                                   ///< max. CU width in pixel
131  UInt      m_uiMaxCUHeight;                                  ///< max. CU height in pixel
132  UInt      m_uiMaxCUDepth;                                   ///< max. CU depth
133 
134  // transfom unit (TU) definition
135  UInt      m_uiQuadtreeTULog2MaxSize;
136  UInt      m_uiQuadtreeTULog2MinSize;
137 
138  UInt      m_uiQuadtreeTUMaxDepthInter;
139  UInt      m_uiQuadtreeTUMaxDepthIntra;
140 
141  // coding tools (bit-depth)
142  UInt      m_uiInputBitDepth;                                ///< bit-depth of input file
143  UInt      m_uiOutputBitDepth;                               ///< bit-depth of output file
144  UInt      m_uiInternalBitDepth;                             ///< Internal bit-depth (BitDepth+BitIncrement)
145
146  // coding tools (PCM bit-depth)
147  Bool      m_bPCMInputBitDepthFlag;                          ///< 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
148  UInt      m_uiPCMBitDepthLuma;                              ///< PCM bit-depth for luma
149
150  // coding tool (lossless)
151  Bool      m_useLossless;                                    ///< flag for using lossless coding
152  Bool      m_bUseSAO; 
153  Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
154#if SAO_LCU_BOUNDARY
155  Bool      m_saoLcuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
156#endif
157  Bool      m_saoLcuBasedOptimization;                        ///< SAO LCU-based optimization
158  // coding tools (loop filter)
159#if !REMOVE_ALF
160  Bool      m_bUseALF;                                        ///< flag for using adaptive loop filter
161  Bool      m_alfLowLatencyEncoding;
162#endif
163  Bool      m_bLoopFilterDisable;                             ///< flag for using deblocking filter
164  Bool      m_loopFilterOffsetInPPS;                         ///< offset for deblocking filter in 0 = slice header, 1 = PPS
165  Int       m_loopFilterBetaOffsetDiv2;                     ///< beta offset for deblocking filter
166  Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
167  Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
168 
169#if !REMOVE_LMCHROMA
170  Bool      m_bUseLMChroma;                                  ///< JL: Chroma intra prediction based on luma signal
171#endif
172 
173  // coding tools (PCM)
174  Bool      m_usePCM;                                         ///< flag for using IPCM
175  UInt      m_pcmLog2MaxSize;                                 ///< log2 of maximum PCM block size
176  UInt      m_uiPCMLog2MinSize;                               ///< log2 of minimum PCM block size
177  Bool      m_bPCMFilterDisableFlag;                          ///< PCM filter disable flag
178
179  // coding tools (encoder-only parameters)
180  Bool      m_bUseSBACRD;                                     ///< flag for using RD optimization based on SBAC
181  Bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
182  Bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
183  Bool      m_bUseRDOQ;                                       ///< flag for using RD optimized quantization
184  Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
185  Int       m_iSearchRange;                                   ///< ME search range
186  Int       m_bipredSearchRange;                              ///< ME search range for bipred refinement
187  Bool      m_bUseFastEnc;                                    ///< flag for using fast encoder setting
188  Bool      m_bUseEarlyCU;                                    ///< flag for using Early CU setting
189  Bool      m_useFastDecisionForMerge;                        ///< flag for using Fast Decision Merge RD-Cost
190  Bool      m_bUseCbfFastMode;                              ///< flag for using Cbf Fast PU Mode Decision
191  Bool      m_useEarlySkipDetection;                         ///< flag for using Early SKIP Detection
192  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
193  Int       m_iSliceArgument;       ///< If m_iSliceMode==1, m_iSliceArgument=max. # of largest coding units. If m_iSliceMode==2, m_iSliceArgument=max. # of bytes.
194  Int       m_iDependentSliceMode;    ///< 0: Disable all dependent slice limits, 1 : Maximum number of largest coding units per slice, 2: Constraint based dependent slice
195  Int       m_iDependentSliceArgument;///< If m_iDependentSliceMode==1, m_iEDependentSliceArgument=max. # of largest coding units. If m_iDependnetSliceMode==2, m_iDependnetSliceArgument=max. # of bins.
196#if DEPENDENT_SLICES
197#if TILES_WPP_ENTROPYSLICES_FLAGS
198  Bool      m_entropySliceEnabledFlag;
199#else
200  Bool       m_bCabacIndependentFlag;  // 0: CABAC dependence between slices, 1:CABAC independence between slices
201#endif
202#endif
203
204#if !REMOVE_FGS
205  Int       m_iSliceGranularity;///< 0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.
206#endif
207  Bool      m_bLFCrossSliceBoundaryFlag;  ///< 0: Cross-slice-boundary in-loop filtering 1: non-cross-slice-boundary in-loop filtering
208  Bool      m_bLFCrossTileBoundaryFlag;  //!< 1: Cross-tile-boundary in-loop filtering 0: non-cross-tile-boundary in-loop filtering
209  Int       m_iUniformSpacingIdr;
210  Int       m_iNumColumnsMinus1;
211  char*     m_pchColumnWidth;
212  Int       m_iNumRowsMinus1;
213  char*     m_pchRowHeight;
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_decodePictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
222#if RECOVERY_POINT_SEI
223  Int       m_recoveryPointSEIEnabled;
224#endif
225#if BUFFERING_PERIOD_AND_TIMING_SEI
226  Int       m_bufferingPeriodSEIEnabled;
227  Int       m_pictureTimingSEIEnabled;
228#endif
229  // weighted prediction
230  Bool      m_bUseWeightPred;                                 ///< Use of explicit Weighting Prediction for P_SLICE
231  Bool      m_useWeightedBiPred;                                    ///< Use of Bi-Directional Weighting Prediction (B_SLICE)
232 
233  UInt      m_log2ParallelMergeLevel;                         ///< Parallel merge estimation region
234  UInt      m_maxNumMergeCand;                                ///< Max number of merge candidates
235
236  Int       m_TMVPModeId;
237  Int       m_signHideFlag;
238  Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
239  Int       m_targetBitrate;                                 ///< target bitrate
240  Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be completely divided by the NumLCUInUnit
241  Int       m_useScalingListId;                               ///< using quantization matrix
242  char*     m_scalingListFile;                                ///< quantization matrix file name
243
244  Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
245  Bool      m_CUTransquantBypassFlagValue;                    ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag.
246
247#if RECALCULATE_QP_ACCORDING_LAMBDA
248  Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
249#endif
250#if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
251  Int       m_activeParameterSetsSEIEnabled;
252#endif
253
254#if SUPPORT_FOR_VUI
255  Bool      m_vuiParametersPresentFlag;                       ///< enable generation of VUI parameters
256  Bool      m_aspectRatioInfoPresentFlag;                     ///< Signals whether aspect_ratio_idc is present
257  Int       m_aspectRatioIdc;                                 ///< aspect_ratio_idc
258  Int       m_sarWidth;                                       ///< horizontal size of the sample aspect ratio
259  Int       m_sarHeight;                                      ///< vertical size of the sample aspect ratio
260  Bool      m_overscanInfoPresentFlag;                        ///< Signals whether overscan_appropriate_flag is present
261  Bool      m_overscanAppropriateFlag;                        ///< Indicates whether cropped decoded pictures are suitable for display using overscan
262  Bool      m_videoSignalTypePresentFlag;                     ///< Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present
263  Int       m_videoFormat;                                    ///< Indicates representation of pictures
264  Bool      m_videoFullRangeFlag;                             ///< Indicates the black level and range of luma and chroma signals
265  Bool      m_colourDescriptionPresentFlag;                   ///< Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present
266  Int       m_colourPrimaries;                                ///< Indicates chromaticity coordinates of the source primaries
267  Int       m_transferCharacteristics;                        ///< Indicates the opto-electronic transfer characteristics of the source
268  Int       m_matrixCoefficients;                             ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries
269  Bool      m_chromaLocInfoPresentFlag;                       ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present
270  Int       m_chromaSampleLocTypeTopField;                    ///< Specifies the location of chroma samples for top field
271  Int       m_chromaSampleLocTypeBottomField;                 ///< Specifies the location of chroma samples for bottom field
272  Bool      m_neutralChromaIndicationFlag;                    ///< Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)
273  Bool      m_bitstreamRestrictionFlag;                       ///< Signals whether bitstream restriction parameters are present
274  Bool      m_tilesFixedStructureFlag;                        ///< Indicates that each active picture parameter set has the same values of the syntax elements related to tiles
275  Bool      m_motionVectorsOverPicBoundariesFlag;             ///< Indicates that no samples outside the picture boundaries are used for inter prediction
276  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
277  Int       m_maxBitsPerMinCuDenom;                           ///< Indicates an upper bound for the number of bits of coding_unit() data
278  Int       m_log2MaxMvLengthHorizontal;                      ///< Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units
279  Int       m_log2MaxMvLengthVertical;                        ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
280#endif
281#if REF_IDX_FRAMEWORK
282  Int       m_elRapSliceBEnabled;
283#endif
284  // internal member functions
285  Void  xSetGlobal      ();                                   ///< set global variables
286  Void  xCheckParameter ();                                   ///< check validity of configuration values
287  Void  xPrintParameter ();                                   ///< print configuration values
288  Void  xPrintUsage     ();                                   ///< print usage
289 
290public:
291  TAppEncCfg();
292  virtual ~TAppEncCfg();
293 
294public:
295  Void  create    ();                                         ///< create option handling class
296  Void  destroy   ();                                         ///< destroy option handling class
297  Bool  parseCfg  ( Int argc, Char* argv[] );                 ///< parse configuration file to fill member variables
298 
299#if SVC_EXTENSION
300  Int  getNumFrameToBeEncoded()    {return m_iFrameToBeEncoded; }
301  Int  getNumLayer()               {return m_numLayers;        }
302  Int  getGOPSize()                {return m_iGOPSize;          }
303  UInt getInternalBitDepth()       {return m_uiInternalBitDepth; }
304  UInt getMaxCUWidth()             {return m_uiMaxCUWidth;      }
305  UInt getMaxCUHeight()            {return m_uiMaxCUHeight;     }
306  UInt getMaxCUDepth()             {return m_uiMaxCUDepth;      }
307  Int  getDecodingRefreshType()    {return m_iDecodingRefreshType; }
308  Void getDirFilename(string& filename, string& dir, const string path);
309  Int  getWaveFrontSynchro()        { return m_iWaveFrontSynchro; }
310#if AVC_SYNTAX
311  Char* getBLSyntaxFile()           { return m_BLSyntaxFile;      }
312#endif
313#endif
314};// END CLASS DEFINITION TAppEncCfg
315
316//! \}
317
318#endif // __TAPPENCCFG__
319
Note: See TracBrowser for help on using the repository browser.