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-2014, 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 #include <sstream> 45 #include <vector> 46 //! \ingroup TAppEncoder 47 //! \{ 48 49 // ==================================================================================================================== 50 // Class definition 51 // ==================================================================================================================== 52 53 /// encoder configuration class 54 class TAppEncCfg 55 { 56 protected: 57 // file I/O 58 Char* m_pchInputFile; ///< source file name 59 Char* m_pchBitstreamFile; ///< output bitstream file 60 Char* m_pchReconFile; ///< output reconstruction file 61 Double m_adLambdaModifier[ MAX_TLAYER ]; ///< Lambda modifier array for each temporal layer 62 // source specification 63 Int m_iFrameRate; ///< source frame-rates (Hz) 64 UInt m_FrameSkip; ///< number of skipped frames from the beginning 65 Int m_iSourceWidth; ///< source width in pixel 66 Int m_iSourceHeight; ///< source height in pixel (when interlaced = field height) 67 68 Int m_iSourceHeightOrg; ///< original source height in pixel (when interlaced = frame height) 69 70 Bool m_isField; ///< enable field coding 71 Bool m_isTopFieldFirst; 72 73 Int m_conformanceWindowMode; 74 Int m_confWinLeft; 75 Int m_confWinRight; 76 Int m_confWinTop; 77 Int m_confWinBottom; 78 Int m_framesToBeEncoded; ///< number of encoded frames 79 Int m_aiPad[2]; ///< number of padded pixels for width and height 80 InputColourSpaceConversion m_inputColourSpaceConvert; ///< colour space conversion to apply to input video 81 Bool m_snrInternalColourSpace; ///< if true, then no colour space conversion is applied for snr calculation, otherwise inverse of input is applied. 82 Bool m_outputInternalColourSpace; ///< if true, then no colour space conversion is applied for reconstructed video, otherwise inverse of input is applied. 83 ChromaFormat m_InputChromaFormatIDC; 84 85 Bool m_printMSEBasedSequencePSNR; 86 Bool m_printFrameMSE; 87 Bool m_printSequenceMSE; 88 Bool m_cabacZeroWordPaddingEnabled; 89 90 // profile/level 91 Profile::Name m_profile; 92 Level::Tier m_levelTier; 93 Level::Name m_level; 94 UInt m_bitDepthConstraint; 95 ChromaFormat m_chromaFormatConstraint; 96 Bool m_intraConstraintFlag; 97 Bool m_lowerBitRateConstraintFlag; 98 Bool m_progressiveSourceFlag; 99 Bool m_interlacedSourceFlag; 100 Bool m_nonPackedConstraintFlag; 101 Bool m_frameOnlyConstraintFlag; 102 103 // coding structure 104 Int m_iIntraPeriod; ///< period of I-slice (random access period) 105 Int m_iDecodingRefreshType; ///< random access type 106 Int m_iGOPSize; ///< GOP size of hierarchical structure 107 Int m_extraRPSs; ///< extra RPSs added to handle CRA 108 GOPEntry m_GOPList[MAX_GOP]; ///< the coding structure entries from the config file 109 Int m_numReorderPics[MAX_TLAYER]; ///< total number of reorder pictures 110 Int m_maxDecPicBuffering[MAX_TLAYER]; ///< total number of pictures in the decoded picture buffer 111 Bool m_useCrossComponentPrediction; ///< flag enabling the use of cross-component prediction 112 Bool m_reconBasedCrossCPredictionEstimate; ///< causes the alpha calculation in encoder search to be based on the decoded residual rather than the pre-transform encoder-side residual 113 UInt m_saoOffsetBitShift[MAX_NUM_CHANNEL_TYPE]; ///< number of bits for the upward bit shift operation on the decoded SAO offsets 114 Bool m_useTransformSkip; ///< flag for enabling intra transform skipping 115 Bool m_useTransformSkipFast; ///< flag for enabling fast intra transform skipping 116 UInt m_transformSkipLog2MaxSize; ///< transform-skip maximum size (minimum of 2) 117 Bool m_useResidualRotation; ///< control flag for transform-skip/transquant-bypass residual rotation 118 Bool m_useSingleSignificanceMapContext; ///< control flag for transform-skip/transquant-bypass single significance map context 119 Bool m_useResidualDPCM[NUMBER_OF_RDPCM_SIGNALLING_MODES];///< control flags for residual DPCM 120 Bool m_enableAMP; 121 Bool m_useGolombRiceParameterAdaptation; ///< control flag for Golomb-Rice parameter adaptation over each slice 122 Bool m_alignCABACBeforeBypass; 123 124 // coding quality 125 Double m_fQP; ///< QP value of key-picture (floating point) 126 Int m_iQP; ///< QP value of key-picture (integer) 127 Char* m_pchdQPFile; ///< QP offset for each slice (initialized from external file) 128 Int* m_aidQP; ///< array of slice QP values 129 Int m_iMaxDeltaQP; ///< max. |delta QP| 130 UInt m_uiDeltaQpRD; ///< dQP range for multi-pass slice QP optimization 131 Int m_iMaxCuDQPDepth; ///< Max. depth for a minimum CuDQPSize (0:default) 132 Int m_maxCUChromaQpAdjustmentDepth; 133 134 Int m_cbQpOffset; ///< Chroma Cb QP Offset (0:default) 135 Int m_crQpOffset; ///< Chroma Cr QP Offset (0:default) 136 137 #if ADAPTIVE_QP_SELECTION 138 Bool m_bUseAdaptQpSelect; 139 #endif 140 TComSEIMasteringDisplay m_masteringDisplay; 141 142 Bool m_bUseAdaptiveQP; ///< Flag for enabling QP adaptation based on a psycho-visual model 143 Int m_iQPAdaptationRange; ///< dQP range by QP adaptation 144 145 Int m_maxTempLayer; ///< Max temporal layer 146 147 // coding unit (CU) definition 148 // TODO: Remove MaxCUWidth/MaxCUHeight and replace with MaxCUSize. 149 UInt m_uiMaxCUWidth; ///< max. CU width in pixel 150 UInt m_uiMaxCUHeight; ///< max. CU height in pixel 151 UInt m_uiMaxCUDepth; ///< max. CU depth 152 153 // transfom unit (TU) definition 154 UInt m_uiQuadtreeTULog2MaxSize; 155 UInt m_uiQuadtreeTULog2MinSize; 156 157 UInt m_uiQuadtreeTUMaxDepthInter; 158 UInt m_uiQuadtreeTUMaxDepthIntra; 159 160 // coding tools (bit-depth) 161 Int m_inputBitDepth [MAX_NUM_CHANNEL_TYPE]; ///< bit-depth of input file 162 Int m_outputBitDepth [MAX_NUM_CHANNEL_TYPE]; ///< bit-depth of output file 163 Int m_MSBExtendedBitDepth[MAX_NUM_CHANNEL_TYPE]; ///< bit-depth of input samples after MSB extension 164 Int m_internalBitDepth[MAX_NUM_CHANNEL_TYPE]; ///< bit-depth codec operates at (input/output files will be converted) 165 Bool m_useExtendedPrecision; 166 Bool m_useHighPrecisionPredictionWeighting; 167 168 //coding tools (chroma format) 169 ChromaFormat m_chromaFormatIDC; 170 171 // coding tools (PCM bit-depth) 172 Bool m_bPCMInputBitDepthFlag; ///< 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth. 173 174 // coding tool (SAO) 175 Bool m_bUseSAO; 176 Int m_maxNumOffsetsPerPic; ///< SAO maximun number of offset per picture 177 Bool m_saoCtuBoundary; ///< SAO parameter estimation using non-deblocked pixels for CTU bottom and right boundary areas 178 // coding tools (loop filter) 179 Bool m_bLoopFilterDisable; ///< flag for using deblocking filter 180 Bool m_loopFilterOffsetInPPS; ///< offset for deblocking filter in 0 = slice header, 1 = PPS 181 Int m_loopFilterBetaOffsetDiv2; ///< beta offset for deblocking filter 182 Int m_loopFilterTcOffsetDiv2; ///< tc offset for deblocking filter 183 Bool m_DeblockingFilterControlPresent; ///< deblocking filter control present flag in PPS 184 Bool m_DeblockingFilterMetric; ///< blockiness metric in encoder 185 186 // coding tools (PCM) 187 Bool m_usePCM; ///< flag for using IPCM 188 UInt m_pcmLog2MaxSize; ///< log2 of maximum PCM block size 189 UInt m_uiPCMLog2MinSize; ///< log2 of minimum PCM block size 190 Bool m_bPCMFilterDisableFlag; ///< PCM filter disable flag 191 Bool m_enableIntraReferenceSmoothing; ///< flag for enabling(default)/disabling intra reference smoothing/filtering 192 193 // coding tools (encoder-only parameters) 194 Bool m_bUseASR; ///< flag for using adaptive motion search range 195 Bool m_bUseHADME; ///< flag for using HAD in sub-pel ME 196 Bool m_useRDOQ; ///< flag for using RD optimized quantization 197 Bool m_useRDOQTS; ///< flag for using RD optimized quantization for transform skip 198 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) 199 Int m_iFastSearch; ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST 200 Int m_iSearchRange; ///< ME search range 201 Int m_bipredSearchRange; ///< ME search range for bipred refinement 202 Bool m_bUseFastEnc; ///< flag for using fast encoder setting 203 Bool m_bUseEarlyCU; ///< flag for using Early CU setting 204 Bool m_useFastDecisionForMerge; ///< flag for using Fast Decision Merge RD-Cost 205 Bool m_bUseCbfFastMode; ///< flag for using Cbf Fast PU Mode Decision 206 Bool m_useEarlySkipDetection; ///< flag for using Early SKIP Detection 207 Int m_sliceMode; ///< 0: no slice limits, 1 : max number of CTBs per slice, 2: max number of bytes per slice, 208 ///< 3: max number of tiles per slice 209 Int m_sliceArgument; ///< argument according to selected slice mode 210 Int m_sliceSegmentMode; ///< 0: no slice segment limits, 1 : max number of CTBs per slice segment, 2: max number of bytes per slice segment, 211 ///< 3: max number of tiles per slice segment 212 Int m_sliceSegmentArgument; ///< argument according to selected slice segment mode 213 214 Bool m_bLFCrossSliceBoundaryFlag; ///< 1: filter across slice boundaries 0: do not filter across slice boundaries 215 Bool m_bLFCrossTileBoundaryFlag; ///< 1: filter across tile boundaries 0: do not filter across tile boundaries 216 Bool m_tileUniformSpacingFlag; 217 Int m_numTileColumnsMinus1; 218 Int m_numTileRowsMinus1; 219 std::vector<Int> m_tileColumnWidth; 220 std::vector<Int> m_tileRowHeight; 221 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. 222 Int m_iWaveFrontFlush; //< enable(1)/disable(0) the CABAC flush at the end of each line of LCUs. 223 Int m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles). 224 225 Bool m_bUseConstrainedIntraPred; ///< flag for using constrained intra prediction 226 227 Int m_decodedPictureHashSEIEnabled; ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message 228 Int m_recoveryPointSEIEnabled; 229 Int m_bufferingPeriodSEIEnabled; 230 Int m_pictureTimingSEIEnabled; 231 Bool m_toneMappingInfoSEIEnabled; 232 Bool m_chromaSamplingFilterSEIenabled; 233 Int m_chromaSamplingHorFilterIdc; 234 Int m_chromaSamplingVerFilterIdc; 235 Int m_toneMapId; 236 Bool m_toneMapCancelFlag; 237 Bool m_toneMapPersistenceFlag; 238 Int m_toneMapCodedDataBitDepth; 239 Int m_toneMapTargetBitDepth; 240 Int m_toneMapModelId; 241 Int m_toneMapMinValue; 242 Int m_toneMapMaxValue; 243 Int m_sigmoidMidpoint; 244 Int m_sigmoidWidth; 245 Int m_numPivots; 246 Int m_cameraIsoSpeedIdc; 247 Int m_cameraIsoSpeedValue; 248 Int m_exposureIndexIdc; 249 Int m_exposureIndexValue; 250 Int m_exposureCompensationValueSignFlag; 251 Int m_exposureCompensationValueNumerator; 252 Int m_exposureCompensationValueDenomIdc; 253 Int m_refScreenLuminanceWhite; 254 Int m_extendedRangeWhiteLevel; 255 Int m_nominalBlackLevelLumaCodeValue; 256 Int m_nominalWhiteLevelLumaCodeValue; 257 Int m_extendedWhiteLevelLumaCodeValue; 258 Int* m_startOfCodedInterval; 259 Int* m_codedPivotValue; 260 Int* m_targetPivotValue; 261 Int m_framePackingSEIEnabled; 262 Int m_framePackingSEIType; 263 Int m_framePackingSEIId; 264 Int m_framePackingSEIQuincunx; 265 Int m_framePackingSEIInterpretation; 266 Int m_segmentedRectFramePackingSEIEnabled; 267 Bool m_segmentedRectFramePackingSEICancel; 268 Int m_segmentedRectFramePackingSEIType; 269 Bool m_segmentedRectFramePackingSEIPersistence; 270 Int m_displayOrientationSEIAngle; 271 Int m_temporalLevel0IndexSEIEnabled; 272 Int m_gradualDecodingRefreshInfoEnabled; 273 Int m_noDisplaySEITLayer; 274 Int m_decodingUnitInfoSEIEnabled; 275 Int m_SOPDescriptionSEIEnabled; 276 Int m_scalableNestingSEIEnabled; 277 Bool m_tmctsSEIEnabled; 278 Bool m_timeCodeSEIEnabled; 279 Int m_timeCodeSEINumTs; 280 TComSEITimeSet m_timeSetArray[MAX_TIMECODE_SEI_SETS]; 281 Bool m_kneeSEIEnabled; 282 Int m_kneeSEIId; 283 Bool m_kneeSEICancelFlag; 284 Bool m_kneeSEIPersistenceFlag; 285 Int m_kneeSEIInputDrange; 286 Int m_kneeSEIInputDispLuminance; 287 Int m_kneeSEIOutputDrange; 288 Int m_kneeSEIOutputDispLuminance; 289 Int m_kneeSEINumKneePointsMinus1; 290 Int* m_kneeSEIInputKneePoint; 291 Int* m_kneeSEIOutputKneePoint; 292 // weighted prediction 293 Bool m_useWeightedPred; ///< Use of weighted prediction in P slices 294 Bool m_useWeightedBiPred; ///< Use of bi-directional weighted prediction in B slices 295 296 UInt m_log2ParallelMergeLevel; ///< Parallel merge estimation region 297 UInt m_maxNumMergeCand; ///< Max number of merge candidates 298 299 Int m_TMVPModeId; 300 Int m_signHideFlag; 301 Bool m_RCEnableRateControl; ///< enable rate control or not 302 Int m_RCTargetBitrate; ///< target bitrate when rate control is enabled 303 Int m_RCKeepHierarchicalBit; ///< 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation 304 Bool m_RCLCULevelRC; ///< true: LCU level rate control; false: picture level rate control NOTE: code-tidy - rename to m_RCCtuLevelRC 305 Bool m_RCUseLCUSeparateModel; ///< use separate R-lambda model at LCU level NOTE: code-tidy - rename to m_RCUseCtuSeparateModel 306 Int m_RCInitialQP; ///< inital QP for rate control 307 Bool m_RCForceIntraQP; ///< force all intra picture to use initial QP or not 308 ScalingListMode m_useScalingListId; ///< using quantization matrix 309 Char* m_scalingListFile; ///< quantization matrix file name 310 311 Bool m_TransquantBypassEnableFlag; ///< transquant_bypass_enable_flag setting in PPS. 312 Bool m_CUTransquantBypassFlagForce; ///< if transquant_bypass_enable_flag, then, if true, all CU transquant bypass flags will be set to true. 313 CostMode m_costMode; ///< Cost mode to use 314 315 Bool m_recalculateQPAccordingToLambda; ///< recalculate QP value according to the lambda value 316 Bool m_useStrongIntraSmoothing; ///< enable strong intra smoothing for 32x32 blocks where the reference samples are flat 317 Int m_activeParameterSetsSEIEnabled; 318 319 Bool m_vuiParametersPresentFlag; ///< enable generation of VUI parameters 320 Bool m_aspectRatioInfoPresentFlag; ///< Signals whether aspect_ratio_idc is present 321 Int m_aspectRatioIdc; ///< aspect_ratio_idc 322 Int m_sarWidth; ///< horizontal size of the sample aspect ratio 323 Int m_sarHeight; ///< vertical size of the sample aspect ratio 324 Bool m_overscanInfoPresentFlag; ///< Signals whether overscan_appropriate_flag is present 325 Bool m_overscanAppropriateFlag; ///< Indicates whether conformant decoded pictures are suitable for display using overscan 326 Bool m_videoSignalTypePresentFlag; ///< Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present 327 Int m_videoFormat; ///< Indicates representation of pictures 328 Bool m_videoFullRangeFlag; ///< Indicates the black level and range of luma and chroma signals 329 Bool m_colourDescriptionPresentFlag; ///< Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present 330 Int m_colourPrimaries; ///< Indicates chromaticity coordinates of the source primaries 331 Int m_transferCharacteristics; ///< Indicates the opto-electronic transfer characteristics of the source 332 Int m_matrixCoefficients; ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries 333 Bool m_chromaLocInfoPresentFlag; ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present 334 Int m_chromaSampleLocTypeTopField; ///< Specifies the location of chroma samples for top field 335 Int m_chromaSampleLocTypeBottomField; ///< Specifies the location of chroma samples for bottom field 336 Bool m_neutralChromaIndicationFlag; ///< Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1) 337 Bool m_defaultDisplayWindowFlag; ///< Indicates the presence of the default window parameters 338 Int m_defDispWinLeftOffset; ///< Specifies the left offset from the conformance window of the default window 339 Int m_defDispWinRightOffset; ///< Specifies the right offset from the conformance window of the default window 340 Int m_defDispWinTopOffset; ///< Specifies the top offset from the conformance window of the default window 341 Int m_defDispWinBottomOffset; ///< Specifies the bottom offset from the conformance window of the default window 342 Bool m_frameFieldInfoPresentFlag; ///< Indicates that pic_struct values are present in picture timing SEI messages 343 Bool m_pocProportionalToTimingFlag; ///< Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS 344 Int m_numTicksPocDiffOneMinus1; ///< Number of ticks minus 1 that for a POC difference of one 345 Bool m_bitstreamRestrictionFlag; ///< Signals whether bitstream restriction parameters are present 346 Bool m_tilesFixedStructureFlag; ///< Indicates that each active picture parameter set has the same values of the syntax elements related to tiles 347 Bool m_motionVectorsOverPicBoundariesFlag; ///< Indicates that no samples outside the picture boundaries are used for inter prediction 348 Int m_minSpatialSegmentationIdc; ///< Indicates the maximum size of the spatial segments in the pictures in the coded video sequence 349 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 350 Int m_maxBitsPerMinCuDenom; ///< Indicates an upper bound for the number of bits of coding_unit() data 351 Int m_log2MaxMvLengthHorizontal; ///< Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units 352 Int m_log2MaxMvLengthVertical; ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units 353 354 // internal member functions 355 Void xSetGlobal (); ///< set global variables 356 Void xCheckParameter (); ///< check validity of configuration values 357 Void xPrintParameter (); ///< print configuration values 358 Void xPrintUsage (); ///< print usage 359 public: 360 TAppEncCfg(); 361 virtual ~TAppEncCfg(); 362 363 public: 364 Void create (); ///< create option handling class 365 Void destroy (); ///< destroy option handling class 366 Bool parseCfg ( Int argc, Char* argv[] ); ///< parse configuration file to fill member variables 367 368 Int m_verboseLevel; /* verbose level */ 369 };// END CLASS DEFINITION TAppEncCfg 370 371 //! \} 372 373 #endif // __TAPPENCCFG__ 374 375