Newer
Older

Karsten Suehring
committed
/* 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-2024, ITU/ISO/IEC

Karsten Suehring
committed
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
* 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);
Rickard Sjöberg
committed
#include "Utilities/program_options_lite.h"

Karsten Suehring
committed
#include "EncoderLib/EncCfg.h"
#if EXTENSION_360_VIDEO
#include "AppEncHelper360/TExt360AppEncCfg.h"
#endif
#if JVET_O0756_CALCULATE_HDRMETRICS
#include "HDRLib/inc/DistortionMetric.H"
#ifdef UNDEFINED
#undef UNDEFINED
#endif
namespace po = ProgramOptionsLite;

Karsten Suehring
committed
#include <sstream>
#include <vector>
#include <optional>

Karsten Suehring
committed
//! \ingroup EncoderApp
//! \{
// ====================================================================================================================
// Class definition
// ====================================================================================================================
/// encoder configuration class
class EncAppCfg
{
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
Fraction m_frameRate;
uint32_t m_frameSkip; ///< number of skipped frames from the beginning

Karsten Suehring
committed
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)

Karsten Suehring
committed
#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;

Karsten Suehring
committed
int m_conformanceWindowMode;
int m_confWinLeft;
int m_confWinRight;
int m_confWinTop;
int m_confWinBottom;
bool m_explicitScalingWindowEnabled;
int m_scalWinLeft;
int m_scalWinRight;
int m_scalWinTop;
int m_scalWinBottom;
int m_sourcePadding[2]; ///< number of padded pixels for width and height
int m_firstValidFrame;
int m_lastValidFrame;

Karsten Suehring
committed
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

Karsten Suehring
committed
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.

Karsten Suehring
committed
bool m_printMSEBasedSequencePSNR;
bool m_printHexPsnr;
bool m_printFrameMSE;
bool m_printSequenceMSE;
bool m_printHighPrecEncTime = false;

Karsten Suehring
committed
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

Karsten Suehring
committed
bool m_bIntraOnlyConstraintFlag;
uint32_t m_maxBitDepthConstraintIdc;
ChromaFormat m_maxChromaFormatConstraintIdc;
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_noWeightedPredictionConstraintFlag;
bool m_noRefWraparoundConstraintFlag;
bool m_noTemporalMvpConstraintFlag;
bool m_noSbtmvpConstraintFlag;
bool m_noAmvrConstraintFlag;
bool m_noBdofConstraintFlag;
bool m_noCclmConstraintFlag;
bool m_noMtsConstraintFlag;
bool m_noAffineMotionConstraintFlag;
bool m_noBcwConstraintFlag;
bool m_noCiipConstraintFlag;
bool m_noLadfConstraintFlag;
bool m_noLumaTransformSize64ConstraintFlag;
bool m_noBDPCMConstraintFlag;
bool m_noJointCbCrConstraintFlag;
Martin Pettersson
committed
bool m_noCuQpDeltaConstraintFlag;
bool m_noDepQuantConstraintFlag;
bool m_noSignDataHidingConstraintFlag;
Martin Pettersson
committed
bool m_noTrailConstraintFlag;
bool m_noStsaConstraintFlag;
bool m_noRaslConstraintFlag;
bool m_noRadlConstraintFlag;
bool m_noIdrConstraintFlag;
bool m_noCraConstraintFlag;
bool m_noGdrConstraintFlag;
bool m_noApsConstraintFlag;
Adrian Browne
committed
bool m_allRapPicturesFlag;
bool m_noExtendedPrecisionProcessingConstraintFlag;
bool m_noTsResidualCodingRiceConstraintFlag;
bool m_noRrcRiceExtensionConstraintFlag;
bool m_noPersistentRiceAdaptationConstraintFlag;
bool m_noReverseLastSigCoeffConstraintFlag;

Karsten Suehring
committed
// 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;

Karsten Suehring
committed
uint32_t m_bitDepthConstraint;
ChromaFormat m_chromaFormatConstraint;
bool m_onePictureOnlyConstraintFlag;
bool m_intraOnlyConstraintFlag;

Karsten Suehring
committed
bool m_nonPackedConstraintFlag;
bool m_nonProjectedConstraintFlag;
Zhipin Deng
committed
bool m_noRprConstraintFlag;
bool m_noResChangeInClvsConstraintFlag;
bool m_oneTilePerPicConstraintFlag;
bool m_oneSlicePerPicConstraintFlag;
bool m_noIdrRplConstraintFlag;
bool m_noRectSliceConstraintFlag;
bool m_oneSlicePerSubpicConstraintFlag;
bool m_noSubpicInfoConstraintFlag;

Karsten Suehring
committed
// coding structure
int m_intraPeriod; ///< period of I-slice (random access period)
bool m_gdrEnabled;
int m_gdrInterval;
bool m_gdrNoHash;
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

Karsten Suehring
committed
GOPEntry m_GOPList[MAX_GOP]; ///< the coding structure entries from the config file
Martin Pettersson
committed
int m_maxNumReorderPics[MAX_TLAYER]; ///< total number of reorder pictures

Karsten Suehring
committed
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
Alican Nalci
committed
bool m_useBDPCM;

Karsten Suehring
committed
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

Karsten Suehring
committed
bool m_persistentRiceAdaptationEnabledFlag; ///< control flag for Golomb-Rice parameter adaptation over each slice
bool m_cabacBypassAlignmentEnabledFlag;
Santiago de Luxán Hernández
committed
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

Karsten Suehring
committed
// coding quality
std::optional<uint32_t> m_qpIncrementAtSourceFrame; // Optional source frame number at which all subsequent frames
// are to use an increased internal QP.

Karsten Suehring
committed
int m_iQP; ///< QP value of key-picture (integer)
Adarsh Krishnan Ramasubramonian
committed
bool m_useIdentityTableForNon420Chroma;
ChromaQpMappingTableParams m_chromaQpMappingTableParams;

Karsten Suehring
committed
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

Karsten Suehring
committed
int m_iMaxDeltaQP; ///< max. |delta QP|
Philippe de Lagrange
committed
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.
Philippe de Lagrange
committed
std::vector<ChromaQpAdj> m_cuChromaQpOffsetList; ///< Local chroma QP offsets list (to be signalled in PPS)
Philippe de Lagrange
committed
bool m_cuChromaQpOffsetEnabled; ///< Enable local chroma QP offsets (slice level flag)

Karsten Suehring
committed
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)

Karsten Suehring
committed
#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;

Karsten Suehring
committed
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;

Karsten Suehring
committed
// coding unit (CU) definition
Kui Fan
committed
bool m_subPicInfoPresentFlag;
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;
Kui Fan
committed
bool m_subPicIdMappingInSpsFlag;
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;
Lien-Fei Chen
committed
int m_ttFastSkip;
double m_ttFastSkipThr;

Karsten Suehring
committed
bool m_dualTree;
bool m_LFNST;
bool m_useFastLFNST;

Karsten Suehring
committed
bool m_Affine;
bool m_AffineType;
bool m_adaptBypassAffineMe;
bool m_PROF;

Karsten Suehring
committed
int m_LMChroma;
Frank Bossen
committed
int m_horCollocatedChromaFlag;
int 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
bool m_compositeRefEnabled;
bool m_bcw;
bool m_BcwFast;
Shunsuke Iwamura
committed
bool m_LadfEnabed;
int m_ladfNumIntervals;
std::vector<int> m_ladfQpOffset;
int m_ladfIntervalLowerBound[MAX_LADF_INTERVALS];
Loading
Loading full blame...