EncAppCfg.h 58 KB
Newer Older
Alberto Gonzalez's avatar
Alberto Gonzalez committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
/* The copyright in this software is being made available under the BSD
 * License, included below. This software may be subject to other third party
 * and contributor rights, including patent rights, and no such rights are
 * granted under this license.
 *
 * Copyright (c) 2010-2023, ITU/ISO/IEC
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *  * Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
 *    be used to endorse or promote products derived from this software without
 *    specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

/** \file     EncAppCfg.h
    \brief    Handle encoder configuration parameters (header)
*/

#ifndef __ENCAPPCFG__
#define __ENCAPPCFG__

#include "CommonLib/CommonDef.h"
#include "EncoderLib/EncCfgParam.h"

#include <map>
template <class T1, class T2>
static inline std::istream& operator >> (std::istream &in, std::map<T1, T2> &map);

#include "Utilities/program_options_lite.h"

#include "EncoderLib/EncCfg.h"
#if EXTENSION_360_VIDEO
#include "AppEncHelper360/TExt360AppEncCfg.h"
#endif

#if JVET_O0756_CALCULATE_HDRMETRICS
#include "HDRLib/inc/DistortionMetric.H"
#endif
namespace po = df::program_options_lite;

#include <sstream>
#include <vector>
//! \ingroup EncoderApp
//! \{

// ====================================================================================================================
// Class definition
// ====================================================================================================================

/// encoder configuration class
class EncAppCfg
{
public:
  template <class T>
  struct OptionalValue
  {
    bool bPresent;
    T    value;
    OptionalValue() : bPresent(false), value() { }
  };

protected:
  // file I/O
  std::string m_inputFileName;                                ///< source file name
  std::string m_bitstreamFileName;                            ///< output bitstream file
  std::string m_reconFileName;                                ///< output reconstruction file

  // Lambda modifiers
  double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
  std::vector<double> m_adIntraLambdaModifier;                ///< Lambda modifier for Intra pictures, one for each temporal layer. If size>temporalLayer, then use [temporalLayer], else if size>0, use [size()-1], else use m_adLambdaModifier.
  double    m_dIntraQpFactor;                                 ///< Intra Q Factor. If negative, use a default equation: 0.57*(1.0 - Clip3( 0.0, 0.5, 0.05*(double)(isField ? (GopSize-1)/2 : GopSize-1) ))

  // source specification
  int           m_frameRate;                                      ///< source frame-rates (Hz)
  uint32_t      m_frameSkip;                                      ///< number of skipped frames from the beginning
  uint32_t      m_temporalSubsampleRatio;                         ///< temporal subsample ratio, 2 means code every two frames
  int       m_sourceWidth;                                   ///< source width in pixel
  int       m_sourceHeight;                                  ///< source height in pixel (when interlaced = field height)
  double    m_sourceScalingRatioHor;                          ////< source scaling ratio Horizontal
  double    m_sourceScalingRatioVer;                          ////< source scaling ratio Vertical
  int       m_sourceWidthBeforeScale;                         ///< source width in pixel before applying source scaling ratio Horizontal 
  int       m_sourceHeightBeforeScale;                        ///< source height in pixel before applying source scaling ratio Vertical (when interlaced = field height)
#if EXTENSION_360_VIDEO
  int       m_inputFileWidth;                                 ///< width of image in input file  (this is equivalent to sourceWidth,  if sourceWidth  is not subsequently altered due to padding)
  int       m_inputFileHeight;                                ///< height of image in input file (this is equivalent to sourceHeight, if sourceHeight is not subsequently altered due to padding)
#endif
  int       m_iSourceHeightOrg;                               ///< original source height in pixel (when interlaced = frame height)

  bool      m_isField;                                        ///< enable field coding
  bool      m_isTopFieldFirst;
  bool      m_efficientFieldIRAPEnabled;   ///< enable an efficient field IRAP structure.
  bool      m_harmonizeGopFirstFieldCoupleEnabled;

  int       m_conformanceWindowMode;
  int       m_confWinLeft;
  int       m_confWinRight;
  int       m_confWinTop;
  int       m_confWinBottom;
  int       m_sourcePadding[2];                                       ///< number of padded pixels for width and height
  int       m_firstValidFrame;
  int       m_lastValidFrame;
  int       m_framesToBeEncoded;                              ///< number of encoded frames
  bool      m_AccessUnitDelimiter;                            ///< add Access Unit Delimiter NAL units
  bool      m_enablePictureHeaderInSliceHeader;               ///< Enable Picture Header in Slice Header

  InputColourSpaceConversion m_inputColourSpaceConvert;       ///< colour space conversion to apply to input video
  bool      m_snrInternalColourSpace;                       ///< if true, then no colour space conversion is applied for snr calculation, otherwise inverse of input is applied.
  bool      m_outputInternalColourSpace;                    ///< if true, then no colour space conversion is applied for reconstructed video, otherwise inverse of input is applied.
  ChromaFormat               m_inputChromaFormatIDC;

  bool      m_printMSEBasedSequencePSNR;
  bool      m_printHexPsnr;
  bool      m_printFrameMSE;
  bool      m_printSequenceMSE;
  bool      m_printMSSSIM;
  bool      m_printWPSNR;
  bool      m_cabacZeroWordPaddingEnabled;
  bool      m_clipInputVideoToRec709Range;
  bool      m_clipOutputVideoToRec709Range;
  bool      m_packedYUVMode;                                  ///< If true, output 10-bit and 12-bit YUV data as 5-byte and 3-byte (respectively) packed YUV data

  bool      m_gciPresentFlag;
  bool      m_bIntraOnlyConstraintFlag;
  uint32_t  m_maxBitDepthConstraintIdc;
Alberto Gonzalez's avatar
Alberto Gonzalez committed
144
  ChromaFormat m_maxChromaFormatConstraintIdc;
Alberto Gonzalez's avatar
Alberto Gonzalez committed
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
  bool      m_allLayersIndependentConstraintFlag;
  bool      m_noMrlConstraintFlag;
  bool      m_noIspConstraintFlag;
  bool      m_noMipConstraintFlag;
  bool      m_noLfnstConstraintFlag;
  bool      m_noMmvdConstraintFlag;
  bool      m_noSmvdConstraintFlag;
  bool      m_noProfConstraintFlag;
  bool      m_noPaletteConstraintFlag;
  bool      m_noActConstraintFlag;
  bool      m_noLmcsConstraintFlag;
  bool      m_noExplicitScaleListConstraintFlag;
  bool      m_noVirtualBoundaryConstraintFlag;
  bool      m_noMttConstraintFlag;
  bool      m_noChromaQpOffsetConstraintFlag;
  bool      m_noQtbttDualTreeIntraConstraintFlag;
  int       m_maxLog2CtuSizeConstraintIdc;
  bool      m_noPartitionConstraintsOverrideConstraintFlag;
  bool      m_noSaoConstraintFlag;
  bool      m_noAlfConstraintFlag;
  bool      m_noCCAlfConstraintFlag;
  bool      m_noWeightedPredictionConstraintFlag;
  bool      m_noRefWraparoundConstraintFlag;
  bool      m_noTemporalMvpConstraintFlag;
  bool      m_noSbtmvpConstraintFlag;
  bool      m_noAmvrConstraintFlag;
  bool      m_noBdofConstraintFlag;
  bool      m_noDmvrConstraintFlag;
  bool      m_noCclmConstraintFlag;
  bool      m_noMtsConstraintFlag;
  bool      m_noSbtConstraintFlag;
  bool      m_noAffineMotionConstraintFlag;
  bool      m_noBcwConstraintFlag;
  bool      m_noIbcConstraintFlag;
  bool      m_noCiipConstraintFlag;
  bool      m_noGeoConstraintFlag;
  bool      m_noLadfConstraintFlag;
  bool      m_noTransformSkipConstraintFlag;
  bool      m_noLumaTransformSize64ConstraintFlag;
  bool      m_noBDPCMConstraintFlag;
  bool      m_noJointCbCrConstraintFlag;
  bool      m_noCuQpDeltaConstraintFlag;
  bool      m_noDepQuantConstraintFlag;
  bool      m_noSignDataHidingConstraintFlag;
  bool      m_noTrailConstraintFlag;
  bool      m_noStsaConstraintFlag;
  bool      m_noRaslConstraintFlag;
  bool      m_noRadlConstraintFlag;
  bool      m_noIdrConstraintFlag;
  bool      m_noCraConstraintFlag;
  bool      m_noGdrConstraintFlag;
  bool      m_noApsConstraintFlag;
  bool      m_allRapPicturesFlag;
  bool      m_noExtendedPrecisionProcessingConstraintFlag;
  bool      m_noTsResidualCodingRiceConstraintFlag;
  bool      m_noRrcRiceExtensionConstraintFlag;
  bool      m_noPersistentRiceAdaptationConstraintFlag;
  bool      m_noReverseLastSigCoeffConstraintFlag;

  // profile/level
  Profile::Name m_profile;
  Level::Tier   m_levelTier;
  Level::Name   m_level;
  bool          m_frameOnlyConstraintFlag;
  bool          m_multiLayerEnabledFlag;
  std::vector<uint32_t>  m_subProfile;
  uint8_t      m_numSubProfile;

  uint32_t          m_bitDepthConstraint;
  ChromaFormat  m_chromaFormatConstraint;
  bool          m_onePictureOnlyConstraintFlag;
  bool          m_intraOnlyConstraintFlag;
  bool          m_nonPackedConstraintFlag;
  bool          m_nonProjectedConstraintFlag;
  bool          m_noRprConstraintFlag;
  bool          m_noResChangeInClvsConstraintFlag;
  bool          m_oneTilePerPicConstraintFlag;
  bool          m_picHeaderInSliceHeaderConstraintFlag;
  bool          m_oneSlicePerPicConstraintFlag;
  bool          m_noIdrRplConstraintFlag;
  bool          m_noRectSliceConstraintFlag;
  bool          m_oneSlicePerSubpicConstraintFlag;
  bool          m_noSubpicInfoConstraintFlag;
  // coding structure
  int m_intraPeriod;   ///< period of I-slice (random access period)
#if GDR_ENABLED
  bool      m_gdrEnabled;
  int       m_gdrPocStart;
  int       m_gdrPeriod;
  int       m_gdrInterval;
  bool      m_gdrNoHash;
#endif
  int       m_intraRefreshType;                               ///< random access type
  int       m_gopSize;                                        ///< GOP size of hierarchical structure
  int       m_drapPeriod;                                     ///< period of dependent RAP pictures
  int       m_edrapPeriod;                                    ///< period of extended dependent RAP pictures
  bool      m_rewriteParamSets;                              ///< Flag to enable rewriting of parameter sets at random access points
  RPLEntry  m_RPLList0[MAX_GOP];                               ///< the RPL entries from the config file
  RPLEntry  m_RPLList1[MAX_GOP];                               ///< the RPL entries from the config file
  bool      m_idrRefParamList;                                ///< indicates if reference picture list syntax elements are present in slice headers of IDR pictures
  GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
  int       m_maxNumReorderPics[MAX_TLAYER];                  ///< total number of reorder pictures
  int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of pictures in the decoded picture buffer
  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
  bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
  bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
  bool      m_useBDPCM;
  uint32_t      m_log2MaxTransformSkipBlockSize;                  ///< transform-skip maximum size (minimum of 2)
  bool      m_transformSkipRotationEnabledFlag;               ///< control flag for transform-skip/transquant-bypass residual rotation
  bool      m_transformSkipContextEnabledFlag;                ///< control flag for transform-skip/transquant-bypass single significance map context
  bool      m_rrcRiceExtensionEnableFlag;                        ///< control flag for enabling extension of the Golomb-Rice parameter derivation for RRC
  bool      m_persistentRiceAdaptationEnabledFlag;            ///< control flag for Golomb-Rice parameter adaptation over each slice
  bool      m_cabacBypassAlignmentEnabledFlag;
  bool      m_ISP;
  bool      m_useFastISP;                                    ///< flag for enabling fast methods for ISP
  int       m_fastAdaptCostPredMode;                         ///< mode for cost prediction, 0..2
  bool      m_disableFastDecisionTT;                         ///< flag for disabling fast decision for TT from BT

  // coding quality
  OptionalValue<uint32_t> m_qpIncrementAtSourceFrame;             ///< Optional source frame number at which all subsequent frames are to use an increased internal QP.
  int       m_iQP;                                            ///< QP value of key-picture (integer)
  bool      m_useIdentityTableForNon420Chroma;
  ChromaQpMappingTableParams m_chromaQpMappingTableParams;
  int       m_intraQPOffset;                                  ///< QP offset for intra slice (integer)
  bool      m_lambdaFromQPEnable;                             ///< enable flag for QP:lambda fix
  std::string m_dQPFileName;                                  ///< QP offset for each slice (initialized from external file)

  FrameDeltaQps m_frameDeltaQps;   // array of frame delta QP values

  int       m_iMaxDeltaQP;                                    ///< max. |delta QP|
  uint32_t  m_uiDeltaQpRD;                                    ///< dQP range for multi-pass slice QP optimization
  int       m_cuQpDeltaSubdiv;                                ///< Maximum subdiv for CU luma Qp adjustment (0:default)
  int       m_cuChromaQpOffsetSubdiv;                         ///< If negative, then do not apply chroma qp offsets.
  std::vector<ChromaQpAdj> m_cuChromaQpOffsetList;            ///< Local chroma QP offsets list (to be signalled in PPS)
  bool      m_cuChromaQpOffsetEnabled;                        ///< Enable local chroma QP offsets (slice level flag)
  bool      m_bFastDeltaQP;                                   ///< Fast Delta QP (false:default)

  int       m_cbQpOffset;                                     ///< Chroma Cb QP Offset (0:default)
  int       m_crQpOffset;                                     ///< Chroma Cr QP Offset (0:default)
  int       m_cbQpOffsetDualTree;                             ///< Chroma Cb QP Offset for dual tree (overwrite m_cbQpOffset for dual tree)
  int       m_crQpOffsetDualTree;                             ///< Chroma Cr QP Offset for dual tree (overwrite m_crQpOffset for dual tree)
  int       m_cbCrQpOffset;                                   ///< QP Offset for joint Cb-Cr mode
  int       m_cbCrQpOffsetDualTree;                           ///< QP Offset for joint Cb-Cr mode (overwrite m_cbCrQpOffset for dual tree)
#if ER_CHROMA_QP_WCG_PPS
  WCGChromaQPControl m_wcgChromaQpControl;                    ///< Wide-colour-gamut chroma QP control.
#endif
#if W0038_CQP_ADJ
  uint32_t      m_sliceChromaQpOffsetPeriodicity;                 ///< Used in conjunction with Slice Cb/Cr QpOffsetIntraOrPeriodic. Use 0 (default) to disable periodic nature.
  int       m_sliceChromaQpOffsetIntraOrPeriodic[2/*Cb,Cr*/]; ///< Chroma Cb QP Offset at slice level for I slice or for periodic inter slices as defined by SliceChromaQPOffsetPeriodicity. Replaces offset in the GOP table.
#endif
#if SHARP_LUMA_DELTA_QP
  LumaLevelToDeltaQPMapping m_lumaLevelToDeltaQPMapping;      ///< mapping from luma level to Delta QP.
#endif
  SEIMasteringDisplay m_masteringDisplay;
  bool      m_smoothQPReductionEnable;
  double    m_smoothQPReductionThresholdIntra;
  double    m_smoothQPReductionModelScaleIntra;
  double    m_smoothQPReductionModelOffsetIntra;
  int       m_smoothQPReductionLimitIntra;
  double    m_smoothQPReductionThresholdInter;
  double    m_smoothQPReductionModelScaleInter;
  double    m_smoothQPReductionModelOffsetInter;
  int       m_smoothQPReductionLimitInter;
  int       m_smoothQPReductionPeriodicity;

  bool      m_bUseAdaptiveQP;                                 ///< Flag for enabling QP adaptation based on a psycho-visual model
  int       m_iQPAdaptationRange;                             ///< dQP range by QP adaptation
#if ENABLE_QPA
  bool      m_bUsePerceptQPA;                                 ///< Flag to enable perceptually motivated input-adaptive QP modification
  bool      m_bUseWPSNR;                                      ///< Flag to output perceptually weighted peak SNR (WPSNR) instead of PSNR
#endif
  int       m_maxTempLayer;                                   ///< Max temporal layer
  bool      m_isLowDelay;

  // coding unit (CU) definition
  unsigned              m_ctuSize;
  bool m_subPicInfoPresentFlag;
  unsigned m_numSubPics;
  bool m_subPicSameSizeFlag;
  std::vector<uint32_t> m_subPicCtuTopLeftX;
  std::vector<uint32_t> m_subPicCtuTopLeftY;
  std::vector<uint32_t> m_subPicWidth;
  std::vector<uint32_t> m_subPicHeight;
  std::vector<bool>     m_subPicTreatedAsPicFlag;
  std::vector<bool>     m_loopFilterAcrossSubpicEnabledFlag;
  bool m_subPicIdMappingExplicitlySignalledFlag;
  bool m_subPicIdMappingInSpsFlag;
  unsigned m_subPicIdLen;
  std::vector<uint16_t> m_subPicId;
  bool      m_SplitConsOverrideEnabledFlag;
  unsigned              m_minQt[3];   // 0: I slice luma; 1: P/B slice; 2: I slice chroma
  unsigned  m_uiMaxMTTHierarchyDepth;
  unsigned  m_uiMaxMTTHierarchyDepthI;
  unsigned  m_uiMaxMTTHierarchyDepthIChroma;
  unsigned              m_maxBt[3];
  unsigned              m_maxTt[3];
  int       m_ttFastSkip;
  double    m_ttFastSkipThr;
  bool      m_dualTree;
  bool      m_LFNST;
  bool      m_useFastLFNST;
  bool      m_sbTmvpEnableFlag;
  bool      m_Affine;
  bool      m_AffineType;
  bool      m_adaptBypassAffineMe;
  bool      m_PROF;
  bool      m_BIO;
  int       m_LMChroma;
  bool      m_horCollocatedChromaFlag;
  bool      m_verCollocatedChromaFlag;

  int       m_mtsMode;                                        ///< XZ: Multiple Transform Set
  int       m_MTSIntraMaxCand;                                ///< XZ: Number of additional candidates to test
  int       m_MTSInterMaxCand;                                ///< XZ: Number of additional candidates to test
  int       m_mtsImplicitIntra;

  bool      m_SBT;                                            ///< Sub-Block Transform for inter blocks
  int       m_SBTFast64WidthTh;
  bool      m_SMVD;
  bool      m_compositeRefEnabled;
  bool      m_bcw;
  bool      m_BcwFast;
  bool      m_LadfEnabed;
  int              m_ladfNumIntervals;
  std::vector<int> m_ladfQpOffset;
  int              m_ladfIntervalLowerBound[MAX_LADF_INTERVALS];

  bool      m_ciip;
  bool      m_Geo;
  bool      m_HashME;
  bool      m_allowDisFracMMVD;
  bool      m_AffineAmvr;
  bool      m_AffineAmvrEncOpt;
  bool      m_AffineAmvp;
  bool      m_DMVR;
  bool      m_MMVD;
  int       m_MmvdDisNum;
  bool      m_rgbFormat;
  bool      m_useColorTrans;
  unsigned  m_PLTMode;
  bool      m_jointCbCrMode;
  bool      m_useChromaTS;
  unsigned  m_IBCMode;
  unsigned  m_IBCLocalSearchRangeX;
  unsigned  m_IBCLocalSearchRangeY;
  unsigned  m_IBCHashSearch;
  unsigned  m_IBCHashSearchMaxCand;
  unsigned  m_IBCHashSearchRange4SmallBlk;
  unsigned  m_IBCFastMethod;

  bool      m_wrapAround;
  unsigned  m_wrapAroundOffset;

  // ADD_NEW_TOOL : (encoder app) add tool enabling flags and associated parameters here
  bool      m_virtualBoundariesEnabledFlag;
  bool      m_virtualBoundariesPresentFlag;
  unsigned  m_numVerVirtualBoundaries;
  unsigned  m_numHorVirtualBoundaries;
  std::vector<unsigned> m_virtualBoundariesPosX;
  std::vector<unsigned> m_virtualBoundariesPosY;
  bool      m_lmcsEnabled;
  uint32_t  m_reshapeSignalType;
  uint32_t  m_intraCMD;
  ReshapeCW m_reshapeCW;
  int       m_updateCtrl;
  int       m_adpOption;
  uint32_t  m_initialCW;
  int       m_CSoffset;
  bool      m_encDbOpt;
  unsigned              m_maxCuWidth;                                      ///< max. CU width in pixel
  unsigned              m_maxCuHeight;                                     ///< max. CU height in pixel
  unsigned m_log2MinCuSize;                                   ///< min. CU size log2

  bool      m_useFastLCTU;
  bool      m_usePbIntraFast;
  bool      m_useAMaxBT;
  bool      m_useFastMrg;
#if JVET_AC0139_UNIFIED_MERGE
  int       m_maxMergeRdCandNumTotal;
  int       m_mergeRdCandQuotaRegular;
  int       m_mergeRdCandQuotaRegularSmallBlk;
  int       m_mergeRdCandQuotaSubBlk;
  int       m_mergeRdCandQuotaCiip;
  int       m_mergeRdCandQuotaGpm;
#endif
  bool      m_e0023FastEnc;
  bool      m_contentBasedFastQtbt;
  bool      m_useNonLinearAlfLuma;
  bool      m_useNonLinearAlfChroma;
  unsigned  m_maxNumAlfAlternativesChroma;
  bool      m_MRL;
  bool      m_MIP;
  bool      m_useFastMIP;
  int       m_fastLocalDualTreeMode;

  int       m_log2MaxTbSize;
  // coding tools (bit-depth)
  BitDepths m_inputBitDepth;         // bit depth of input file
  BitDepths m_outputBitDepth;        // bit depth of output file
  BitDepths m_msbExtendedBitDepth;   // bit depth of input samples after MSB extension
  BitDepths m_internalBitDepth;      // bit depth codec operates at (input/output files will be converted)
  bool      m_extendedPrecisionProcessingFlag;
  bool      m_tsrcRicePresentFlag;
  bool      m_reverseLastSigCoeffEnabledFlag;
  bool      m_highPrecisionOffsetsEnabledFlag;

  //coding tools (chroma format)
Alberto Gonzalez's avatar
Alberto Gonzalez committed
452
  ChromaFormat m_chromaFormatIdc;
Alberto Gonzalez's avatar
Alberto Gonzalez committed
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763

  // coding tool (SAO)
  bool      m_useSao;
  bool      m_saoTrueOrg;
  bool      m_bTestSAODisableAtPictureLevel;
  double    m_saoEncodingRate;                                ///< When >0 SAO early picture termination is enabled for luma and chroma
  double    m_saoEncodingRateChroma;                          ///< The SAO early picture termination rate to use for chroma (when m_SaoEncodingRate is >0). If <=0, use results for luma.
  int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
  bool      m_saoCtuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for CTU bottom and right boundary areas
  bool      m_saoGreedyMergeEnc;                              ///< SAO greedy merge encoding algorithm
  // coding tools (loop filter)
  bool      m_deblockingFilterDisable;                        ///< flag for using deblocking filter
  bool      m_deblockingFilterOffsetInPPS;                    ///< offset for deblocking filter in 0 = slice header, 1 = PPS
  int       m_deblockingFilterBetaOffsetDiv2;                 ///< beta offset for deblocking filter
  int       m_deblockingFilterTcOffsetDiv2;                   ///< tc offset for deblocking filter
  int       m_deblockingFilterCbBetaOffsetDiv2;               ///< beta offset for Cb deblocking filter
  int       m_deblockingFilterCbTcOffsetDiv2;                 ///< tc offset for Cb deblocking filter
  int       m_deblockingFilterCrBetaOffsetDiv2;               ///< beta offset for Cr deblocking filter
  int       m_deblockingFilterCrTcOffsetDiv2;                 ///< tc offset for Cr deblocking filter
  int       m_deblockingFilterMetric;                         ///< blockiness metric in encoder

  // coding tools (encoder-only parameters)
  bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
  bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
  bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
  bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
  bool      m_useSelectiveRDOQ;                               ///< flag for using selective RDOQ
  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)
  bool      m_bDisableIntraPUsInInterSlices;                  ///< Flag for disabling intra predicted PUs in inter slices.
  MESearchMethod m_motionEstimationSearchMethod;
  bool      m_bRestrictMESampling;                            ///< Restrict sampling for the Selective ME
  int       m_iSearchRange;                                   ///< ME search range
  int       m_bipredSearchRange;                              ///< ME search range for bipred refinement
  int       m_minSearchWindow;                                ///< ME minimum search window size for the Adaptive Window ME
  bool      m_bClipForBiPredMeEnabled;                        ///< Enables clipping for Bi-Pred ME.
  bool      m_bFastMEAssumingSmootherMVEnabled;               ///< Enables fast ME assuming a smoother MV.
  FastInterSearchMode m_fastInterSearchMode;                  ///< Parameter that controls fast encoder settings
  bool      m_bUseEarlyCU;                                    ///< flag for using Early CU setting
  bool      m_useFastDecisionForMerge;                        ///< flag for using Fast Decision Merge RD-Cost
  bool      m_useEarlySkipDetection;                          ///< flag for using Early SKIP Detection
  bool      m_picPartitionFlag;                               ///< enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used)
  bool      m_mixedLossyLossless;                             ///< enable mixed lossy/lossless coding
  std::vector<uint16_t> m_sliceLosslessArray;                 ///< Slice lossless array
  std::vector<uint32_t> m_tileColumnWidth;                    ///< tile column widths in units of CTUs (last column width will be repeated uniformly to cover any remaining picture width)
  std::vector<uint32_t> m_tileRowHeight;                      ///< tile row heights in units of CTUs (last row height will be repeated uniformly to cover any remaining picture height)
  bool      m_rasterSliceFlag;                                ///< indicates if using raster-scan or rectangular slices (0: rectangular, 1: raster-scan)
  std::vector<uint32_t> m_rectSlicePos;                       ///< rectangular slice positions (pairs of top-left CTU address followed by bottom-right CTU address)
  int       m_rectSliceFixedWidth;                            ///< fixed rectangular slice width in units of tiles (0: disable this feature and use RectSlicePositions instead)
  int       m_rectSliceFixedHeight;                           ///< fixed rectangular slice height in units of tiles (0: disable this feature and use RectSlicePositions instead)
  std::vector<uint32_t> m_rasterSliceSize;                    ///< raster-scan slice sizes in units of tiles (last size will be repeated uniformly to cover any remaining tiles in the picture)
  bool      m_disableLFCrossTileBoundaryFlag;                 ///< 0: filter across tile boundaries  1: do not filter across tile boundaries
  bool      m_disableLFCrossSliceBoundaryFlag;                ///< 0: filter across slice boundaries 1: do not filter across slice boundaries
  uint32_t  m_numSlicesInPic;                                 ///< derived number of rectangular slices in the picture (raster-scan slice specified at slice level)
  bool      m_tileIdxDeltaPresentFlag;                        ///< derived tile index delta present flag
  std::vector<RectSlice> m_rectSlices;                        ///< derived list of rectangular slice signalling parameters
  uint32_t  m_numTileCols;                                    ///< derived number of tile columns
  uint32_t  m_numTileRows;                                    ///< derived number of tile rows
  bool      m_singleSlicePerSubPicFlag;
  bool      m_entropyCodingSyncEnabledFlag;
  bool      m_entryPointPresentFlag;                          ///< flag for the presence of entry points

  bool      m_bFastUDIUseMPMEnabled;
  bool      m_bFastMEForGenBLowDelayEnabled;
  bool      m_bUseBLambdaForNonKeyLowDelayPictures;

  HashType  m_decodedPictureHashSEIType;                      ///< Checksum mode for decoded picture hash SEI message
  HashType  m_subpicDecodedPictureHashType;
  bool      m_bufferingPeriodSEIEnabled;
  bool      m_pictureTimingSEIEnabled;
  bool      m_bpDeltasGOPStructure;
  bool      m_decodingUnitInfoSEIEnabled;
  bool      m_scalableNestingSEIEnabled;
  bool      m_frameFieldInfoSEIEnabled;
  bool      m_framePackingSEIEnabled;
  int       m_framePackingSEIType;
  int       m_framePackingSEIId;
  int       m_framePackingSEIQuincunx;
  int       m_framePackingSEIInterpretation;
  bool      m_doSEIEnabled;
  bool      m_doSEICancelFlag;
  bool      m_doSEIPersistenceFlag;
  int       m_doSEITransformType;
  bool      m_parameterSetsInclusionIndicationSEIEnabled;
  int       m_selfContainedClvsFlag;
  int       m_preferredTransferCharacteristics;

  // film grain characterstics sei
  bool      m_fgcSEIEnabled;
  bool      m_fgcSEICancelFlag;
  bool      m_fgcSEIPersistenceFlag;
  uint32_t  m_fgcSEIModelID;
  bool      m_fgcSEISepColourDescPresentFlag;
  uint32_t  m_fgcSEIBlendingModeID;
  uint32_t  m_fgcSEILog2ScaleFactor;
  bool      m_fgcSEICompModelPresent[MAX_NUM_COMPONENT];
  bool      m_fgcSEIAnalysisEnabled;
  std::string m_fgcSEIExternalMask;
  std::string m_fgcSEIExternalDenoised;
  int       m_fgcSEITemporalFilterPastRefs;
  int       m_fgcSEITemporalFilterFutureRefs;
  std::map<int, double> m_fgcSEITemporalFilterStrengths;
  bool      m_fgcSEIPerPictureSEI;
  uint32_t  m_fgcSEINumModelValuesMinus1          [MAX_NUM_COMPONENT];
  uint32_t  m_fgcSEINumIntensityIntervalMinus1    [MAX_NUM_COMPONENT];
  uint32_t  m_fgcSEIIntensityIntervalLowerBound   [MAX_NUM_COMPONENT][MAX_NUM_INTENSITIES];
  uint32_t  m_fgcSEIIntensityIntervalUpperBound   [MAX_NUM_COMPONENT][MAX_NUM_INTENSITIES];
  uint32_t  m_fgcSEICompModelValue                [MAX_NUM_COMPONENT][MAX_NUM_INTENSITIES][MAX_NUM_MODEL_VALUES];
  // content light level SEI
  bool      m_cllSEIEnabled;
  uint32_t  m_cllSEIMaxContentLevel;
  uint32_t  m_cllSEIMaxPicAvgLevel;
  // ambient viewing environment sei
  bool      m_aveSEIEnabled;
  uint32_t  m_aveSEIAmbientIlluminance;
  uint32_t  m_aveSEIAmbientLightX;
  uint32_t  m_aveSEIAmbientLightY;
  // colour tranform information sei
  bool      m_ctiSEIEnabled;
  uint32_t  m_ctiSEIId;
  bool      m_ctiSEISignalInfoFlag;
  bool      m_ctiSEIFullRangeFlag;
  uint32_t  m_ctiSEIPrimaries;
  uint32_t  m_ctiSEITransferFunction;
  uint32_t  m_ctiSEIMatrixCoefs;
  bool      m_ctiSEICrossComponentFlag;
  bool      m_ctiSEICrossComponentInferred;
  uint32_t  m_ctiSEINumberChromaLut;
  int       m_ctiSEIChromaOffset;
  LutModel  m_ctiSEILut[MAX_NUM_COMPONENT];
  // content colour volume sei
  bool      m_ccvSEIEnabled;
  bool      m_ccvSEICancelFlag;
  bool      m_ccvSEIPersistenceFlag;
  bool      m_ccvSEIPrimariesPresentFlag;
  bool      m_ccvSEIMinLuminanceValuePresentFlag;
  bool      m_ccvSEIMaxLuminanceValuePresentFlag;
  bool      m_ccvSEIAvgLuminanceValuePresentFlag;
  double    m_ccvSEIPrimariesX[MAX_NUM_COMPONENT];
  double    m_ccvSEIPrimariesY[MAX_NUM_COMPONENT];
  double    m_ccvSEIMinLuminanceValue;
  double    m_ccvSEIMaxLuminanceValue;
  double    m_ccvSEIAvgLuminanceValue;
  // scalability dimension information sei
  bool              m_sdiSEIEnabled;
  int               m_sdiSEIMaxLayersMinus1;
  bool              m_sdiSEIMultiviewInfoFlag;
  bool              m_sdiSEIAuxiliaryInfoFlag;
  int               m_sdiSEIViewIdLenMinus1;
  std::vector<uint32_t>  m_sdiSEILayerId;
  std::vector<uint32_t>  m_sdiSEIViewIdVal;
  std::vector<uint32_t>  m_sdiSEIAuxId;
  std::vector<uint32_t>  m_sdiSEINumAssociatedPrimaryLayersMinus1;
  // multiview acquisition information sei
  bool              m_maiSEIEnabled;
  bool              m_maiSEIIntrinsicParamFlag;
  bool              m_maiSEIExtrinsicParamFlag;
  int               m_maiSEINumViewsMinus1;
  bool              m_maiSEIIntrinsicParamsEqualFlag;
  int               m_maiSEIPrecFocalLength;
  int               m_maiSEIPrecPrincipalPoint;
  int               m_maiSEIPrecSkewFactor;
  std::vector<bool> m_maiSEISignFocalLengthX;
  std::vector<uint32_t>  m_maiSEIExponentFocalLengthX;
  std::vector<uint32_t>  m_maiSEIMantissaFocalLengthX;
  std::vector<bool>      m_maiSEISignFocalLengthY;
  std::vector<uint32_t>  m_maiSEIExponentFocalLengthY;
  std::vector<uint32_t>  m_maiSEIMantissaFocalLengthY;
  std::vector<bool>      m_maiSEISignPrincipalPointX;
  std::vector<uint32_t>  m_maiSEIExponentPrincipalPointX;
  std::vector<uint32_t>  m_maiSEIMantissaPrincipalPointX;
  std::vector<bool>      m_maiSEISignPrincipalPointY;
  std::vector<uint32_t>  m_maiSEIExponentPrincipalPointY;
  std::vector<uint32_t>  m_maiSEIMantissaPrincipalPointY;
  std::vector<bool>      m_maiSEISignSkewFactor;
  std::vector<uint32_t>  m_maiSEIExponentSkewFactor;
  std::vector<uint32_t>  m_maiSEIMantissaSkewFactor;
  int               m_maiSEIPrecRotationParam;
  int               m_maiSEIPrecTranslationParam;
  // multiview acquisition information sei
  bool              m_mvpSEIEnabled;
  int               m_mvpSEINumViewsMinus1;
  std::vector<uint32_t>  m_mvpSEIViewPosition;
  // alpha channel information sei
  bool      m_aciSEIEnabled;
  bool      m_aciSEICancelFlag;
  int       m_aciSEIUseIdc;
  int       m_aciSEIBitDepthMinus8;
  int       m_aciSEITransparentValue;
  int       m_aciSEIOpaqueValue;
  bool      m_aciSEIIncrFlag;
  bool      m_aciSEIClipFlag;
  bool      m_aciSEIClipTypeFlag;
  // depth representation information sei
  bool      m_driSEIEnabled;
  bool      m_driSEIZNearFlag;
  bool      m_driSEIZFarFlag;
  bool      m_driSEIDMinFlag;
  bool      m_driSEIDMaxFlag;
  double    m_driSEIZNear;
  double    m_driSEIZFar;
  double    m_driSEIDMin;
  double    m_driSEIDMax;
  int       m_driSEIDepthRepresentationType;
  int       m_driSEIDisparityRefViewId;
  int       m_driSEINonlinearNumMinus1;
  std::vector<uint32_t> m_driSEINonlinearModel;

  bool      m_erpSEIEnabled;
  bool      m_erpSEICancelFlag;
  bool      m_erpSEIPersistenceFlag;
  bool      m_erpSEIGuardBandFlag;
  uint32_t  m_erpSEIGuardBandType;
  uint32_t  m_erpSEILeftGuardBandWidth;
  uint32_t  m_erpSEIRightGuardBandWidth;

  bool      m_sphereRotationSEIEnabled;
  bool      m_sphereRotationSEICancelFlag;
  bool      m_sphereRotationSEIPersistenceFlag;
  int       m_sphereRotationSEIYaw;
  int       m_sphereRotationSEIPitch;
  int       m_sphereRotationSEIRoll;

  bool      m_omniViewportSEIEnabled;
  uint32_t  m_omniViewportSEIId;
  bool      m_omniViewportSEICancelFlag;
  bool      m_omniViewportSEIPersistenceFlag;
  uint32_t  m_omniViewportSEICntMinus1;
  std::vector<int>      m_omniViewportSEIAzimuthCentre;
  std::vector<int>      m_omniViewportSEIElevationCentre;
  std::vector<int>      m_omniViewportSEITiltCentre;
  std::vector<uint32_t> m_omniViewportSEIHorRange;
  std::vector<uint32_t> m_omniViewportSEIVerRange;
  std::string           m_arSEIFileRoot;  // Annotated region SEI - initialized from external file
  bool                  m_rwpSEIEnabled;
  bool                  m_rwpSEIRwpCancelFlag;
  bool                  m_rwpSEIRwpPersistenceFlag;
  bool                  m_rwpSEIConstituentPictureMatchingFlag;
  int                   m_rwpSEINumPackedRegions;
  int                   m_rwpSEIProjPictureWidth;
  int                   m_rwpSEIProjPictureHeight;
  int                   m_rwpSEIPackedPictureWidth;
  int                   m_rwpSEIPackedPictureHeight;
  std::vector<uint8_t>  m_rwpSEIRwpTransformType;
  std::vector<bool>     m_rwpSEIRwpGuardBandFlag;
  std::vector<uint32_t> m_rwpSEIProjRegionWidth;
  std::vector<uint32_t> m_rwpSEIProjRegionHeight;
  std::vector<uint32_t> m_rwpSEIRwpSEIProjRegionTop;
  std::vector<uint32_t> m_rwpSEIProjRegionLeft;
  std::vector<uint16_t> m_rwpSEIPackedRegionWidth;
  std::vector<uint16_t> m_rwpSEIPackedRegionHeight;
  std::vector<uint16_t> m_rwpSEIPackedRegionTop;
  std::vector<uint16_t> m_rwpSEIPackedRegionLeft;
  std::vector<uint8_t>  m_rwpSEIRwpLeftGuardBandWidth;
  std::vector<uint8_t>  m_rwpSEIRwpRightGuardBandWidth;
  std::vector<uint8_t>  m_rwpSEIRwpTopGuardBandHeight;
  std::vector<uint8_t>  m_rwpSEIRwpBottomGuardBandHeight;
  std::vector<bool>     m_rwpSEIRwpGuardBandNotUsedForPredFlag;
  std::vector<uint8_t>  m_rwpSEIRwpGuardBandType;

  bool                 m_gcmpSEIEnabled;
  bool                 m_gcmpSEICancelFlag;
  bool                 m_gcmpSEIPersistenceFlag;
  uint32_t             m_gcmpSEIPackingType;
  uint32_t             m_gcmpSEIMappingFunctionType;
  std::vector<uint8_t> m_gcmpSEIFaceIndex;
  std::vector<uint8_t> m_gcmpSEIFaceRotation;
  std::vector<double>  m_gcmpSEIFunctionCoeffU;
  std::vector<bool>    m_gcmpSEIFunctionUAffectedByVFlag;
  std::vector<double>  m_gcmpSEIFunctionCoeffV;
  std::vector<bool>    m_gcmpSEIFunctionVAffectedByUFlag;
  bool                 m_gcmpSEIGuardBandFlag;
  uint32_t             m_gcmpSEIGuardBandType;
  bool                 m_gcmpSEIGuardBandBoundaryExteriorFlag;
  uint32_t             m_gcmpSEIGuardBandSamplesMinus1;

  EncCfgParam::CfgSEISubpictureLevel m_cfgSubpictureLevelInfoSEI;

  bool                  m_nnPostFilterSEICharacteristicsEnabled;
  int                   m_nnPostFilterSEICharacteristicsNumFilters;
  uint32_t              m_nnPostFilterSEICharacteristicsId[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsModeIdc[MAX_NUM_NN_POST_FILTERS];
  bool                  m_nnPostFilterSEICharacteristicsPurposeAndFormattingFlag[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsPurpose[MAX_NUM_NN_POST_FILTERS];
  bool                  m_nnPostFilterSEICharacteristicsOutSubCFlag[MAX_NUM_NN_POST_FILTERS];
#if JVET_AC0154
  uint32_t              m_nnPostFilterSEICharacteristicsOutColourFormatIdc[MAX_NUM_NN_POST_FILTERS];
#endif
  uint32_t              m_nnPostFilterSEICharacteristicsPicWidthInLumaSamples[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsPicHeightInLumaSamples[MAX_NUM_NN_POST_FILTERS];
#if JVET_AC0061_TENSOR_BITDEPTH
  uint32_t              m_nnPostFilterSEICharacteristicsInpTensorBitDepthLumaMinus8[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsInpTensorBitDepthChromaMinus8[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsOutTensorBitDepthLumaMinus8[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsOutTensorBitDepthChromaMinus8[MAX_NUM_NN_POST_FILTERS];
#else
  uint32_t              m_nnPostFilterSEICharacteristicsInpTensorBitDepthMinus8[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsOutTensorBitDepthMinus8[MAX_NUM_NN_POST_FILTERS];
#endif
  bool                  m_nnPostFilterSEICharacteristicsComponentLastFlag[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsInpFormatIdc[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsAuxInpIdc[MAX_NUM_NN_POST_FILTERS];
  bool                  m_nnPostFilterSEICharacteristicsSepColDescriptionFlag[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsColPrimaries[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsTransCharacteristics[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsMatrixCoeffs[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsInpOrderIdc[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsOutFormatIdc[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsOutOrderIdc[MAX_NUM_NN_POST_FILTERS];
  bool                  m_nnPostFilterSEICharacteristicsConstantPatchSizeFlag[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsPatchWidthMinus1[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsPatchHeightMinus1[MAX_NUM_NN_POST_FILTERS];
Alberto Gonzalez's avatar
Alberto Gonzalez committed
764 765 766 767
#if JVET_AC0344_NNPFC_PATCH
  uint32_t              m_nnPostFilterSEICharacteristicsExtendedPatchWidthCdDeltaMinus1[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsExtendedPatchHeightCdDeltaMinus1[MAX_NUM_NN_POST_FILTERS];
#endif
Alberto Gonzalez's avatar
Alberto Gonzalez committed
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783
  uint32_t              m_nnPostFilterSEICharacteristicsOverlap[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsPaddingType[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsLumaPadding[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsCbPadding[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsCrPadding[MAX_NUM_NN_POST_FILTERS];
  std::string           m_nnPostFilterSEICharacteristicsPayloadFilename[MAX_NUM_NN_POST_FILTERS];
  bool                  m_nnPostFilterSEICharacteristicsComplexityInfoPresentFlag[MAX_NUM_NN_POST_FILTERS];
  std::string           m_nnPostFilterSEICharacteristicsUriTag[MAX_NUM_NN_POST_FILTERS];
  std::string           m_nnPostFilterSEICharacteristicsUri[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsParameterTypeIdc[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsLog2ParameterBitLengthMinus3[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsNumParametersIdc[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsNumKmacOperationsIdc[MAX_NUM_NN_POST_FILTERS];
  uint32_t              m_nnPostFilterSEICharacteristicsTotalKilobyteSize[MAX_NUM_NN_POST_FILTERS];

  bool                  m_nnPostFilterSEIActivationEnabled;
Alberto Gonzalez's avatar
Alberto Gonzalez committed
784 785 786
#if JVET_AC0074_USE_OF_NNPFC_FOR_PIC_RATE_UPSAMPLING
  uint32_t              m_nnPostFilterSEIActivationTargetId;
#else
Alberto Gonzalez's avatar
Alberto Gonzalez committed
787
  uint32_t              m_nnPostFilterSEIActivationId;
Alberto Gonzalez's avatar
Alberto Gonzalez committed
788
#endif
Alberto Gonzalez's avatar
Alberto Gonzalez committed
789 790 791 792 793 794
  #if JVET_AC0127_BIT_MASKING_NNPFC_PURPOSE
  uint32_t              m_nnPostFilterSEICharacteristicsNumberInputDecodedPicturesMinus1[MAX_NUM_NN_POST_FILTERS];
  #else
  uint32_t              m_nnPostFilterSEICharacteristicsNumberInputDecodedPicturesMinus2[MAX_NUM_NN_POST_FILTERS];
  #endif
  std::vector<uint32_t> m_nnPostFilterSEICharacteristicsNumberInterpolatedPictures[MAX_NUM_NN_POST_FILTERS];
Alberto Gonzalez's avatar
Alberto Gonzalez committed
795
#if JVET_AC0127_BIT_MASKING_NNPFC_PURPOSE
Alberto Gonzalez's avatar
Alberto Gonzalez committed
796
  std::vector<bool>     m_nnPostFilterSEICharacteristicsInputPicOutputFlag[MAX_NUM_NN_POST_FILTERS];
Alberto Gonzalez's avatar
Alberto Gonzalez committed
797
#endif
Alberto Gonzalez's avatar
Alberto Gonzalez committed
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085
  bool                    m_nnPostFilterSEIActivationCancelFlag;
  bool                    m_nnPostFilterSEIActivationPersistenceFlag;

  bool                  m_poSEIEnabled;
  std::vector<uint16_t> m_poSEIPayloadType;
  std::vector<uint16_t>  m_poSEIProcessingOrder;
#if JVET_AC0058_SEI
  std::vector<std::vector<uint8_t>> m_poSEIPrefixByte;
#else
  uint32_t m_numofSEIMessages;
#endif


  bool                 m_postFilterHintSEIEnabled;
  bool                 m_postFilterHintSEICancelFlag;
  bool                 m_postFilterHintSEIPersistenceFlag;
  uint32_t             m_postFilterHintSEISizeY;
  uint32_t             m_postFilterHintSEISizeX;
  uint32_t             m_postFilterHintSEIType;
  bool                 m_postFilterHintSEIChromaCoeffPresentFlag;
  std::vector<int32_t> m_postFilterHintValues;

  bool                  m_constrainedRaslEncoding;

  bool                  m_sampleAspectRatioInfoSEIEnabled;
  bool                  m_sariCancelFlag;
  bool                  m_sariPersistenceFlag;
  int                   m_sariAspectRatioIdc;
  int                   m_sariSarWidth;
  int                   m_sariSarHeight;

  bool      m_SEIManifestSEIEnabled;
  bool      m_SEIPrefixIndicationSEIEnabled;
  bool                  m_phaseIndicationSEIEnabledFullResolution;
  int                   m_piHorPhaseNumFullResolution;
  int                   m_piHorPhaseDenMinus1FullResolution;
  int                   m_piVerPhaseNumFullResolution;
  int                   m_piVerPhaseDenMinus1FullResolution;
  bool                  m_phaseIndicationSEIEnabledReducedResolution;
  int                   m_piHorPhaseNumReducedResolution;
  int                   m_piHorPhaseDenMinus1ReducedResolution;
  int                   m_piVerPhaseNumReducedResolution;
  int                   m_piVerPhaseDenMinus1ReducedResolution;

  bool      m_MCTSEncConstraint;

  // weighted prediction
  bool      m_useWeightedPred;                    ///< Use of weighted prediction in P slices
  bool      m_useWeightedBiPred;                  ///< Use of bi-directional weighted prediction in B slices
  WeightedPredictionMethod m_weightedPredictionMethod;

  uint32_t      m_log2ParallelMergeLevel;                         ///< Parallel merge estimation region
  uint32_t      m_maxNumMergeCand;                                ///< Max number of merge candidates
  uint32_t      m_maxNumAffineMergeCand;                          ///< Max number of affine merge candidates
  uint32_t      m_maxNumGeoCand;
  uint32_t      m_maxNumIBCMergeCand;                             ///< Max number of IBC merge candidates

  bool      m_sliceLevelRpl;                                      ///< code reference picture lists in slice headers rather than picture header
  bool      m_sliceLevelDblk;                                     ///< code deblocking filter parameters in slice headers rather than picture header
  bool      m_sliceLevelSao;                                      ///< code SAO parameters in slice headers rather than picture header
  bool      m_sliceLevelAlf;                                      ///< code ALF parameters in slice headers rather than picture header
  bool      m_sliceLevelWp;                                       ///< code weighted prediction parameters in slice headers rather than picture header
  bool      m_sliceLevelDeltaQp;                                  ///< code delta in slice headers rather than picture header

  int       m_TMVPModeId;
  bool      m_depQuantEnabledFlag;
  bool      m_signDataHidingEnabledFlag;
  bool      m_RCEnableRateControl;                ///< enable rate control or not
  int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
  int       m_RCKeepHierarchicalBit;              ///< 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation
  bool      m_RCLCULevelRC;                       ///< true: LCU level rate control; false: picture level rate control NOTE: code-tidy - rename to m_RCCtuLevelRC
  bool      m_RCUseLCUSeparateModel;              ///< use separate R-lambda model at LCU level                        NOTE: code-tidy - rename to m_RCUseCtuSeparateModel
  int       m_RCInitialQP;                        ///< inital QP for rate control
  bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
  bool      m_RCCpbSaturationEnabled;             ///< enable target bits saturation to avoid CPB overflow and underflow
  uint32_t      m_RCCpbSize;                          ///< CPB size
  double    m_RCInitialCpbFullness;               ///< initial CPB fullness
  ScalingListMode m_useScalingListId;                         ///< using quantization matrix
  std::string m_scalingListFileName;                          ///< quantization matrix file name
  bool      m_disableScalingMatrixForLfnstBlks;
  bool      m_disableScalingMatrixForAlternativeColourSpace;
  bool      m_scalingMatrixDesignatedColourSpace;
  CostMode  m_costMode;                                       ///< Cost mode to use
  bool      m_TSRCdisableLL;                                  ///< disable TSRC for lossless

  bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value

  bool      m_DCIEnabled;                                     ///< enable Decoding Capability Information (DCI)
  bool      m_hrdParametersPresentFlag;                       ///< enable generation of HRD parameters
  bool      m_vuiParametersPresentFlag;                       ///< enable generation of VUI parameters
  bool      m_samePicTimingInAllOLS;                          ///< same picture timing SEI message is used in all OLS
  bool      m_aspectRatioInfoPresentFlag;                     ///< Signals whether aspect_ratio_idc is present
  int       m_aspectRatioIdc;                                 ///< aspect_ratio_idc
  int       m_sarWidth;                                       ///< horizontal size of the sample aspect ratio
  int       m_sarHeight;                                      ///< vertical size of the sample aspect ratio
  bool      m_colourDescriptionPresentFlag;                   ///< Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present
  int       m_colourPrimaries;                                ///< Indicates chromaticity coordinates of the source primaries
  int       m_transferCharacteristics;                        ///< Indicates the opto-electronic transfer characteristics of the source
  int       m_matrixCoefficients;                             ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries
  bool      m_progressiveSourceFlag;                          ///< Indicates if the content is progressive
  bool      m_interlacedSourceFlag;                           ///< Indicates if the content is interlaced
  bool      m_chromaLocInfoPresentFlag;                       ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present
  int       m_chromaSampleLocTypeTopField;                    ///< Specifies the location of chroma samples for top field
  int       m_chromaSampleLocTypeBottomField;                 ///< Specifies the location of chroma samples for bottom field
  int       m_chromaSampleLocType;                            ///< Specifies the location of chroma samples for progressive content
  bool      m_overscanInfoPresentFlag;                        ///< Signals whether overscan_appropriate_flag is present
  bool      m_overscanAppropriateFlag;                        ///< Indicates whether conformant decoded pictures are suitable for display using overscan
  bool      m_videoFullRangeFlag;                             ///< Indicates the black level and range of luma and chroma signals
  int       m_ImvMode;                                        ///< imv mode
  int       m_Imv4PelFast;                                    ///< imv 4-Pel fast mode

  bool      m_siiSEIEnabled;
  uint32_t  m_siiSEINumUnitsInShutterInterval;
  uint32_t  m_siiSEITimeScale;
  std::vector<uint32_t>     m_siiSEISubLayerNumUnitsInSI;
#if JVET_Z0120_SII_SEI_PROCESSING
  bool        m_ShutterFilterEnable;                          ///< enable Pre-Filtering with Shutter Interval SEI
  std::string m_shutterIntervalPreFileName;                   ///< output Pre-Filtering video
  int         m_SII_BlendingRatio;
  void        setBlendingRatioSII(int value) { m_SII_BlendingRatio = value; }
#endif
#if GREEN_METADATA_SEI_ENABLED
public:
  std::string getGMFAFile ();
  bool getGMFAUsage();
protected:
  std::string   m_GMFAFile;
  bool          m_GMFA;
  
  int      m_greenMetadataType;
  int      m_greenMetadataExtendedRepresentation;
  int      m_greenMetadataGranularityType;
  int      m_greenMetadataPeriodType;
  int      m_greenMetadataPeriodNumSeconds;
  int      m_greenMetadataPeriodNumPictures;

  int      m_xsdNumberMetrics;
  bool     m_xsdMetricTypePSNR;
  bool     m_xsdMetricTypeSSIM;
  bool     m_xsdMetricTypeWPSNR;
  bool     m_xsdMetricTypeWSPSNR;
#endif
  std::string m_summaryOutFilename;                           ///< filename to use for producing summary output file.
  std::string m_summaryPicFilenameBase;                       ///< Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended.
  uint32_t        m_summaryVerboseness;                           ///< Specifies the level of the verboseness of the text output.

  int         m_verbosity;

  std::string m_decodeBitstreams[2];                          ///< filename for decode bitstreams.
  int         m_debugCTU;
  int         m_switchPOC;                                    ///< dbg poc.
  int         m_switchDQP;                                    ///< switch DQP.
  int         m_fastForwardToPOC;                             ///< get to encoding the specified POC as soon as possible by skipping temporal layers irrelevant for the specified POC
  bool        m_stopAfterFFtoPOC;
  bool        m_bs2ModPOCAndType;
  bool        m_forceDecodeBitstream1;

  int         m_maxNumAlfAps{ ALF_CTB_MAX_NUM_APS };
  int         m_alfapsIDShift;
  int         m_constantJointCbCrSignFlag;
  bool        m_alf;                                       ///< Adaptive Loop Filter
  bool        m_alfTrueOrg;
  double      m_alfStrengthLuma;
  bool        m_alfAllowPredefinedFilters;
  double      m_ccalfStrength;
  double      m_alfStrengthChroma;
  double      m_alfStrengthTargetLuma;
  double      m_alfStrengthTargetChroma;
  double      m_ccalfStrengthTarget;
  bool        m_ccalf;
  int         m_ccalfQpThreshold;

  bool        m_rprEnabledFlag;
  double      m_scalingRatioHor;
  double      m_scalingRatioVer;
  bool        m_gopBasedRPREnabledFlag;
  int         m_gopBasedRPRQPThreshold;
  double      m_scalingRatioHor2;
  double      m_scalingRatioVer2;
  double      m_scalingRatioHor3;
  double      m_scalingRatioVer3;
  double      m_psnrThresholdRPR;
  double      m_psnrThresholdRPR2;
  double      m_psnrThresholdRPR3;
  int         m_qpOffsetRPR;
  int         m_qpOffsetRPR2;
  int         m_qpOffsetRPR3;
  int         m_qpOffsetChromaRPR;
  int         m_qpOffsetChromaRPR2;
  int         m_qpOffsetChromaRPR3;
#if JVET_AC0096
  int         m_rprSwitchingResolutionOrderList[MAX_RPR_SWITCHING_ORDER_LIST_SIZE];
  int         m_rprSwitchingQPOffsetOrderList[MAX_RPR_SWITCHING_ORDER_LIST_SIZE];
  int         m_rprSwitchingListSize;
  bool        m_rprFunctionalityTestingEnabledFlag;
  bool        m_rprPopulatePPSatIntraFlag;
  int         m_rprSwitchingSegmentSize;
  double      m_rprSwitchingTime;
#endif
  bool        m_resChangeInClvsEnabled;
  bool        m_refMetricsEnabled;
  double      m_fractionOfFrames;                             ///< encode a fraction of the frames as specified in FramesToBeEncoded
  int         m_switchPocPeriod;
  int         m_upscaledOutput;                               ////< Output upscaled (2), decoded cropped but in full resolution buffer (1) or decoded cropped (0, default) picture for RPR.
  int         m_upscaleFilterForDisplay;
  bool        m_craAPSreset;
  bool        m_rprRASLtoolSwitch;
  bool        m_avoidIntraInDepLayer;

  bool                  m_gopBasedTemporalFilterEnabled;
  int                   m_gopBasedTemporalFilterPastRefs;
  int                   m_gopBasedTemporalFilterFutureRefs;
  std::map<int, double> m_gopBasedTemporalFilterStrengths;             ///< Filter strength per frame for the GOP-based Temporal Filter
  bool                  m_bimEnabled;

  int         m_maxLayers;
  int         m_targetOlsIdx;
  bool        m_OPIEnabled;                                     ///< enable Operating Point Information (OPI)
  int         m_maxTemporalLayer;
  int         m_layerId[MAX_VPS_LAYERS];
  int         m_maxSublayers;
  bool        m_defaultPtlDpbHrdMaxTidFlag;
  bool        m_allIndependentLayersFlag;
  std::string m_predDirectionArray;

  int         m_numRefLayers[MAX_VPS_LAYERS];
  std::string m_refLayerIdxStr[MAX_VPS_LAYERS];
  bool        m_eachLayerIsAnOlsFlag;
  int         m_olsModeIdc;
  int         m_numOutputLayerSets;
  std::string m_olsOutputLayerStr[MAX_VPS_LAYERS];
  std::string m_maxTidILRefPicsPlus1Str[MAX_VPS_LAYERS];
  bool        m_rplOfDepLayerInSh;

  int         m_numPtlsInVps;
  int         m_ptPresentInPtl[MAX_NUM_OLSS];

  EncCfgParam::CfgVPSParameters m_cfgVPSParameters;
  Level::Name m_levelPtl[MAX_NUM_OLSS];
  int         m_olsPtlIdx[MAX_NUM_OLSS];

#if EXTENSION_360_VIDEO
  TExt360AppEncCfg m_ext360;
  friend class TExt360AppEncCfg;
  friend class TExt360AppEncTop;
#endif

#if JVET_O0756_CONFIG_HDRMETRICS || JVET_O0756_CALCULATE_HDRMETRICS
#if JVET_O0756_CALCULATE_HDRMETRICS
  double      m_whitePointDeltaE[hdrtoolslib::NB_REF_WHITE];
#else
  double      m_whitePointDeltaE[3];
#endif
  double      m_maxSampleValue;
  int         m_sampleRange;
  int         m_colorPrimaries;
  bool        m_enableTFunctionLUT;
  int         m_chromaLocation;
  int         m_chromaUPFilter;
  int         m_cropOffsetLeft;
  int         m_cropOffsetTop;
  int         m_cropOffsetRight;
  int         m_cropOffsetBottom;
  bool        m_calculateHdrMetrics;
#endif

  // internal member functions
  bool  xCheckParameter ();                                   ///< check validity of configuration values
  void  xPrintParameter ();                                   ///< print configuration values
  void  xPrintUsage     ();                                   ///< print usage
  bool  xHasNonZeroTemporalID();                             ///< check presence of constant temporal ID in GOP structure
  bool  xHasLeadingPicture();                                 ///< check presence of leading pictures in GOP structure
  int   xAutoDetermineProfile();                              ///< auto determine the profile to use given the other configuration settings. Returns 1 if erred. Can select profile 'NONE'
public:
  EncAppCfg();
  virtual ~EncAppCfg();

public:
  void  create    ();                                         ///< create option handling class
  void  destroy   ();                                         ///< destroy option handling class
  bool  parseCfg  ( int argc, char* argv[] );                ///< parse configuration file to fill member variables

};// END CLASS DEFINITION EncAppCfg

//! \}

#endif // __ENCAPPCFG__