diff --git a/source/App/EncoderApp/encmain.cpp b/source/App/EncoderApp/encmain.cpp index 03309b7b29c32fdf4ddd640c17b8713b7e553d22..fb3345ecefc76228cf7a3122bb4776f81ca98857 100644 --- a/source/App/EncoderApp/encmain.cpp +++ b/source/App/EncoderApp/encmain.cpp @@ -47,9 +47,9 @@ //! \ingroup EncoderApp //! \{ -static const uint32_t settingNameWidth = 66; -static const uint32_t settingHelpWidth = 84; -static const uint32_t settingValueWidth = 3; +static constexpr uint32_t settingNameWidth = 66; +static constexpr uint32_t settingHelpWidth = 84; +static constexpr uint32_t settingValueWidth = 3; // --------------------------------------------------------------------------------------------------------------------- // //macro value printing function diff --git a/source/App/SubpicMergeApp/SubpicMergeApp.cpp b/source/App/SubpicMergeApp/SubpicMergeApp.cpp index 31f9a27ab268b6c06b109547c9f224dad6909f49..c8a4ee832b1d012cd4cf367fdd9d35e954bd4723 100644 --- a/source/App/SubpicMergeApp/SubpicMergeApp.cpp +++ b/source/App/SubpicMergeApp/SubpicMergeApp.cpp @@ -61,7 +61,7 @@ //! \{ -static const int MIXED_NALU_PPS_OFFSET = 8; +static constexpr int MIXED_NALU_PPS_OFFSET = 8; struct Subpicture { diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index d4e0172df1a34f099f69615f498918cb7b5a0aff..039a162f4def0669eef2c45cdfafde5ad2cec01c 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -118,111 +118,111 @@ typedef enum AFFINE_MODEL_NUM } EAffineModel; -static const int AFFINE_ME_LIST_SIZE = 4; -static const int AFFINE_ME_LIST_SIZE_LD = 3; -static const double AFFINE_ME_LIST_MVP_TH = 1.0; +static constexpr int AFFINE_ME_LIST_SIZE = 4; +static constexpr int AFFINE_ME_LIST_SIZE_LD = 3; +static constexpr double AFFINE_ME_LIST_MVP_TH = 1.0; // ==================================================================================================================== // Common constants // ==================================================================================================================== -static const uint64_t MAX_UINT64 = 0xFFFFFFFFFFFFFFFFU; -static const uint32_t MAX_UINT = 0xFFFFFFFFU; ///< max. value of unsigned 32-bit integer -static const int MAX_INT = 2147483647; ///< max. value of signed 32-bit integer -static const uint8_t MAX_UCHAR = 255; -static const uint8_t MAX_SCHAR = 127; -static const double MAX_DOUBLE = 1.7e+308; ///< max. value of double-type value +static constexpr uint64_t MAX_UINT64 = 0xFFFFFFFFFFFFFFFFU; +static constexpr uint32_t MAX_UINT = 0xFFFFFFFFU; ///< max. value of unsigned 32-bit integer +static constexpr int MAX_INT = 2147483647; ///< max. value of signed 32-bit integer +static constexpr uint8_t MAX_UCHAR = 255; +static constexpr uint8_t MAX_SCHAR = 127; +static constexpr double MAX_DOUBLE = 1.7e+308; ///< max. value of double-type value // ==================================================================================================================== // Coding tool configuration // ==================================================================================================================== // Most of these should not be changed - they resolve the meaning of otherwise magic numbers. -static const int MAX_GOP = 64; ///< max. value of hierarchical GOP size -static const int MAX_NUM_REF_PICS = 29; ///< max. number of pictures used for reference -static const int MAX_NUM_REF = 16; ///< max. number of entries in picture reference list -static const int MAX_QP = 63; -static const int NOT_VALID = -1; +static constexpr int MAX_GOP = 64; ///< max. value of hierarchical GOP size +static constexpr int MAX_NUM_REF_PICS = 29; ///< max. number of pictures used for reference +static constexpr int MAX_NUM_REF = 16; ///< max. number of entries in picture reference list +static constexpr int MAX_QP = 63; +static constexpr int NOT_VALID = -1; -static const int AMVP_MAX_NUM_CANDS = 2; ///< AMVP: advanced motion vector prediction - max number of final candidates -static const int AMVP_MAX_NUM_CANDS_MEM = 3; ///< AMVP: advanced motion vector prediction - max number of candidates -static const int AMVP_DECIMATION_FACTOR = 2; -static const int MRG_MAX_NUM_CANDS = 6; ///< MERGE -static const int AFFINE_MRG_MAX_NUM_CANDS = 5; ///< AFFINE MERGE -static const int IBC_MRG_MAX_NUM_CANDS = 6; ///< IBC MERGE +static constexpr int AMVP_MAX_NUM_CANDS = 2; ///< AMVP: advanced motion vector prediction - max number of final candidates +static constexpr int AMVP_MAX_NUM_CANDS_MEM = 3; ///< AMVP: advanced motion vector prediction - max number of candidates +static constexpr int AMVP_DECIMATION_FACTOR = 2; +static constexpr int MRG_MAX_NUM_CANDS = 6; ///< MERGE +static constexpr int AFFINE_MRG_MAX_NUM_CANDS = 5; ///< AFFINE MERGE +static constexpr int IBC_MRG_MAX_NUM_CANDS = 6; ///< IBC MERGE -static const int MAX_TLAYER = 7; ///< Explicit temporal layer QP offset - max number of temporal layer +static constexpr int MAX_TLAYER = 7; ///< Explicit temporal layer QP offset - max number of temporal layer -static const int ADAPT_SR_SCALE = 1; ///< division factor for adaptive search range +static constexpr int ADAPT_SR_SCALE = 1; ///< division factor for adaptive search range -static const int MIN_TB_LOG2_SIZEY = 2; -static const int MAX_TB_LOG2_SIZEY = 6; +static constexpr int MIN_TB_LOG2_SIZEY = 2; +static constexpr int MAX_TB_LOG2_SIZEY = 6; -static const int MIN_TB_SIZEY = 1 << MIN_TB_LOG2_SIZEY; -static const int MAX_TB_SIZEY = 1 << MAX_TB_LOG2_SIZEY; +static constexpr int MIN_TB_SIZEY = 1 << MIN_TB_LOG2_SIZEY; +static constexpr int MAX_TB_SIZEY = 1 << MAX_TB_LOG2_SIZEY; -static const int MAX_NESTING_NUM_LAYER = 64; +static constexpr int MAX_NESTING_NUM_LAYER = 64; -static const int MAX_VPS_LAYERS = 64; -static const int MAX_VPS_SUBLAYERS = 7; -static const int MAX_NUM_OLSS = 256; -static const int MAX_VPS_OLS_MODE_IDC = 2; +static constexpr int MAX_VPS_LAYERS = 64; +static constexpr int MAX_VPS_SUBLAYERS = 7; +static constexpr int MAX_NUM_OLSS = 256; +static constexpr int MAX_VPS_OLS_MODE_IDC = 2; #if JVET_Z0244 -static const int MAX_NUM_NN_POST_FILTERS = 8; +static constexpr int MAX_NUM_NN_POST_FILTERS = 8; #endif -static const int MIP_MAX_WIDTH = MAX_TB_SIZEY; -static const int MIP_MAX_HEIGHT = MAX_TB_SIZEY; +static constexpr int MIP_MAX_WIDTH = MAX_TB_SIZEY; +static constexpr int MIP_MAX_HEIGHT = MAX_TB_SIZEY; -static const int MAX_NUM_ALF_ALTERNATIVES_CHROMA = 8; -static const int MAX_NUM_ALF_CLASSES = 25; -static const int MAX_NUM_ALF_LUMA_COEFF = 13; -static const int MAX_NUM_ALF_CHROMA_COEFF = 7; -static const int MAX_ALF_FILTER_LENGTH = 7; -static const int MAX_ALF_PADDING_SIZE = 4; +static constexpr int MAX_NUM_ALF_ALTERNATIVES_CHROMA = 8; +static constexpr int MAX_NUM_ALF_CLASSES = 25; +static constexpr int MAX_NUM_ALF_LUMA_COEFF = 13; +static constexpr int MAX_NUM_ALF_CHROMA_COEFF = 7; +static constexpr int MAX_ALF_FILTER_LENGTH = 7; +static constexpr int MAX_ALF_PADDING_SIZE = 4; #define MAX_NUM_CC_ALF_FILTERS 4 static constexpr int MAX_NUM_CC_ALF_CHROMA_COEFF = 8; static constexpr int CCALF_DYNAMIC_RANGE = 6; static constexpr int CCALF_BITS_PER_COEFF_LEVEL = 3; -static const int ALF_FIXED_FILTER_NUM = 64; -static const int ALF_CTB_MAX_NUM_APS = 8; -static const int NUM_FIXED_FILTER_SETS = 16; +static constexpr int ALF_FIXED_FILTER_NUM = 64; +static constexpr int ALF_CTB_MAX_NUM_APS = 8; +static constexpr int NUM_FIXED_FILTER_SETS = 16; -static const int MAX_BDOF_APPLICATION_REGION = 16; +static constexpr int MAX_BDOF_APPLICATION_REGION = 16; -static const int MAX_CPB_CNT = 32; ///< Upper bound of (cpb_cnt_minus1 + 1) -static const int MAX_NUM_LAYER_IDS = 64; -static const int COEF_REMAIN_BIN_REDUCTION = 5; ///< indicates the level at which the VLC transitions from Golomb-Rice to TU+EG(k) -static const int CU_DQP_TU_CMAX = 5; ///< max number bins for truncated unary -static const int CU_DQP_EG_k = 0; ///< expgolomb order +static constexpr int MAX_CPB_CNT = 32; ///< Upper bound of (cpb_cnt_minus1 + 1) +static constexpr int MAX_NUM_LAYER_IDS = 64; +static constexpr int COEF_REMAIN_BIN_REDUCTION = 5; ///< indicates the level at which the VLC transitions from Golomb-Rice to TU+EG(k) +static constexpr int CU_DQP_TU_CMAX = 5; ///< max number bins for truncated unary +static constexpr int CU_DQP_EG_k = 0; ///< expgolomb order -static const int SBH_THRESHOLD = 4; ///< value of the fixed SBH controlling threshold +static constexpr int SBH_THRESHOLD = 4; ///< value of the fixed SBH controlling threshold -static const int MAX_NUM_VPS = 16; -static const int MAX_NUM_SPS = 16; -static const int MAX_NUM_PPS = 64; -static const int MAX_NUM_APS = 32; //Currently APS ID has 5 bits -static const int NUM_APS_TYPE_LEN = 3; //Currently APS Type has 3 bits -static const int MAX_NUM_APS_TYPE = 8; //Currently APS Type has 3 bits so the max type is 8 +static constexpr int MAX_NUM_VPS = 16; +static constexpr int MAX_NUM_SPS = 16; +static constexpr int MAX_NUM_PPS = 64; +static constexpr int MAX_NUM_APS = 32; //Currently APS ID has 5 bits +static constexpr int NUM_APS_TYPE_LEN = 3; //Currently APS Type has 3 bits +static constexpr int MAX_NUM_APS_TYPE = 8; //Currently APS Type has 3 bits so the max type is 8 static constexpr int MAX_TILE_COLS = 30; // Maximum number of tile columns static constexpr int MAX_TILES = 990; // Maximum number of tiles static constexpr int MAX_SLICES = 1000; // Maximum number of slices per picture -static const int MLS_GRP_NUM = 1024; ///< Max number of coefficient groups, max(16, 256) +static constexpr int MLS_GRP_NUM = 1024; ///< Max number of coefficient groups, max(16, 256) -static const int MLS_CG_SIZE = 4; ///< Coefficient group size of 4x4; = MLS_CG_LOG2_WIDTH + MLS_CG_LOG2_HEIGHT +static constexpr int MLS_CG_SIZE = 4; ///< Coefficient group size of 4x4; = MLS_CG_LOG2_WIDTH + MLS_CG_LOG2_HEIGHT -static const int RVM_VCEGAM10_M = 4; +static constexpr int RVM_VCEGAM10_M = 4; -static const int MAX_REF_LINE_IDX = 3; //highest refLine offset in the list -static const int MRL_NUM_REF_LINES = 3; //number of candidates in the array -static const int MULTI_REF_LINE_IDX[4] = { 0, 1, 2, 0 }; +static constexpr int MAX_REF_LINE_IDX = 3; //highest refLine offset in the list +static constexpr int MRL_NUM_REF_LINES = 3; //number of candidates in the array +static constexpr int MULTI_REF_LINE_IDX[4] = { 0, 1, 2, 0 }; -static const int PRED_REG_MIN_WIDTH = 4; // Minimum prediction region width for ISP subblocks +static constexpr int PRED_REG_MIN_WIDTH = 4; // Minimum prediction region width for ISP subblocks static constexpr int NUM_DIR = 16; static constexpr int NUM_INTRA_ANGULAR_MODES = 4 * NUM_DIR + 1; @@ -231,40 +231,40 @@ static constexpr int NUM_LUMA_MODE = ANGULAR_BASE + NUM_INTRA_ANGULAR_ static constexpr int NUM_LMC_MODE = 1 + 2; // LMC + MDLM_T + MDLM_L static constexpr int NUM_INTRA_MODE = NUM_LUMA_MODE + NUM_LMC_MODE; -static const int NUM_EXT_LUMA_MODE = 28; +static constexpr int NUM_EXT_LUMA_MODE = 28; -static const int PLANAR_IDX = 0; ///< index for intra PLANAR mode -static const int DC_IDX = 1; ///< index for intra DC mode -static const int HOR_IDX = (1 * NUM_DIR + ANGULAR_BASE); ///< index for intra HORIZONTAL mode -static const int DIA_IDX = (2 * NUM_DIR + ANGULAR_BASE); ///< index for intra DIAGONAL mode -static const int VER_IDX = (3 * NUM_DIR + ANGULAR_BASE); ///< index for intra VERTICAL mode -static const int VDIA_IDX = (4 * NUM_DIR + ANGULAR_BASE); ///< index for intra VDIAGONAL mode -static const int BDPCM_IDX = (5 * NUM_DIR + ANGULAR_BASE); ///< index for intra BDPCM mode -static const int NOMODE_IDX = MAX_UCHAR; ///< indicating uninitialized elements +static constexpr int PLANAR_IDX = 0; ///< index for intra PLANAR mode +static constexpr int DC_IDX = 1; ///< index for intra DC mode +static constexpr int HOR_IDX = (1 * NUM_DIR + ANGULAR_BASE); ///< index for intra HORIZONTAL mode +static constexpr int DIA_IDX = (2 * NUM_DIR + ANGULAR_BASE); ///< index for intra DIAGONAL mode +static constexpr int VER_IDX = (3 * NUM_DIR + ANGULAR_BASE); ///< index for intra VERTICAL mode +static constexpr int VDIA_IDX = (4 * NUM_DIR + ANGULAR_BASE); ///< index for intra VDIAGONAL mode +static constexpr int BDPCM_IDX = (5 * NUM_DIR + ANGULAR_BASE); ///< index for intra BDPCM mode +static constexpr int NOMODE_IDX = MAX_UCHAR; ///< indicating uninitialized elements -static const int NUM_CHROMA_MODE = (5 + NUM_LMC_MODE); ///< total number of chroma modes -static const int LM_CHROMA_IDX = NUM_LUMA_MODE; ///< chroma mode index for derived from LM mode -static const int MDLM_L_IDX = LM_CHROMA_IDX + 1; ///< MDLM_L -static const int MDLM_T_IDX = LM_CHROMA_IDX + 2; ///< MDLM_T -static const int DM_CHROMA_IDX = NUM_INTRA_MODE; ///< chroma mode index for derived from luma intra mode +static constexpr int NUM_CHROMA_MODE = (5 + NUM_LMC_MODE); ///< total number of chroma modes +static constexpr int LM_CHROMA_IDX = NUM_LUMA_MODE; ///< chroma mode index for derived from LM mode +static constexpr int MDLM_L_IDX = LM_CHROMA_IDX + 1; ///< MDLM_L +static constexpr int MDLM_T_IDX = LM_CHROMA_IDX + 2; ///< MDLM_T +static constexpr int DM_CHROMA_IDX = NUM_INTRA_MODE; ///< chroma mode index for derived from luma intra mode -static const uint32_t NUM_TRAFO_MODES_MTS = 6; ///< Max Intra CU size applying EMT, supported values: 8, 16, 32, 64, 128 -static const uint32_t MTS_INTRA_MAX_CU_SIZE = 32; ///< Max Intra CU size applying EMT, supported values: 8, 16, 32, 64, 128 -static const uint32_t MTS_INTER_MAX_CU_SIZE = 32; ///< Max Inter CU size applying EMT, supported values: 8, 16, 32, 64, 128 -static const int NUM_MOST_PROBABLE_MODES = 6; -static const int LM_SYMBOL_NUM = (1 + NUM_LMC_MODE); +static constexpr uint32_t NUM_TRAFO_MODES_MTS = 6; ///< Max Intra CU size applying EMT, supported values: 8, 16, 32, 64, 128 +static constexpr uint32_t MTS_INTRA_MAX_CU_SIZE = 32; ///< Max Intra CU size applying EMT, supported values: 8, 16, 32, 64, 128 +static constexpr uint32_t MTS_INTER_MAX_CU_SIZE = 32; ///< Max Inter CU size applying EMT, supported values: 8, 16, 32, 64, 128 +static constexpr int NUM_MOST_PROBABLE_MODES = 6; +static constexpr int LM_SYMBOL_NUM = (1 + NUM_LMC_MODE); -static const int MAX_NUM_MIP_MODE = 32; ///< maximum number of MIP pred. modes -static const int FAST_UDI_MAX_RDMODE_NUM = (NUM_LUMA_MODE + MAX_NUM_MIP_MODE); ///< maximum number of RD comparison in fast-UDI estimation loop +static constexpr int MAX_NUM_MIP_MODE = 32; ///< maximum number of MIP pred. modes +static constexpr int FAST_UDI_MAX_RDMODE_NUM = (NUM_LUMA_MODE + MAX_NUM_MIP_MODE); ///< maximum number of RD comparison in fast-UDI estimation loop -static const int MAX_LFNST_COEF_NUM = 16; +static constexpr int MAX_LFNST_COEF_NUM = 16; -static const int LFNST_LAST_SIG_LUMA = 1; -static const int LFNST_LAST_SIG_CHROMA = 1; +static constexpr int LFNST_LAST_SIG_LUMA = 1; +static constexpr int LFNST_LAST_SIG_CHROMA = 1; -static const int NUM_LFNST_NUM_PER_SET = 3; +static constexpr int NUM_LFNST_NUM_PER_SET = 3; -static const int CABAC_INIT_PRESENT_FLAG = 1; +static constexpr int CABAC_INIT_PRESENT_FLAG = 1; static constexpr int MV_FRACTIONAL_BITS_INTERNAL = 4; static constexpr int MV_FRACTIONAL_BITS_SIGNAL = 2; @@ -277,124 +277,124 @@ static constexpr int MV_FRAC_MASK_CHROMA = (1 static constexpr int LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS = 1 << MV_FRAC_BITS_LUMA; static constexpr int CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS = 1 << MV_FRAC_BITS_CHROMA; -static const int MAX_NUM_SUB_PICS = (1 << 16); -static const int MAX_NUM_LONG_TERM_REF_PICS = 33; -static const int NUM_LONG_TERM_REF_PIC_SPS = 0; +static constexpr int MAX_NUM_SUB_PICS = (1 << 16); +static constexpr int MAX_NUM_LONG_TERM_REF_PICS = 33; +static constexpr int NUM_LONG_TERM_REF_PIC_SPS = 0; -static const int MAX_QP_OFFSET_LIST_SIZE = 6; ///< Maximum size of QP offset list is 6 entries -static const int MAX_NUM_CQP_MAPPING_TABLES = 3; ///< Maximum number of chroma QP mapping tables (Cb, Cr and joint Cb-Cr) -static const int MIN_QP_VALUE_FOR_16_BIT = -48; ////< Minimum value for QP (-6*(bitdepth - 8) ) for bit depth 16 ; actual minimum QP value is bit depth dependent -static const int MAX_NUM_QP_VALUES = MAX_QP + 1 - MIN_QP_VALUE_FOR_16_BIT; ////< Maximum number of QP values possible - bit depth dependent +static constexpr int MAX_QP_OFFSET_LIST_SIZE = 6; ///< Maximum size of QP offset list is 6 entries +static constexpr int MAX_NUM_CQP_MAPPING_TABLES = 3; ///< Maximum number of chroma QP mapping tables (Cb, Cr and joint Cb-Cr) +static constexpr int MIN_QP_VALUE_FOR_16_BIT = -48; ////< Minimum value for QP (-6*(bitdepth - 8) ) for bit depth 16 ; actual minimum QP value is bit depth dependent +static constexpr int MAX_NUM_QP_VALUES = MAX_QP + 1 - MIN_QP_VALUE_FOR_16_BIT; ////< Maximum number of QP values possible - bit depth dependent // Cost mode support -static const int LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP = 0; ///< QP to use for lossless coding. -static const int LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME =4; ///< QP' to use for mixed_lossy_lossless coding. -static const int RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS = MAX_NUM_COMPONENT; +static constexpr int LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP = 0; ///< QP to use for lossless coding. +static constexpr int LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME =4; ///< QP' to use for mixed_lossy_lossless coding. +static constexpr int RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS = MAX_NUM_COMPONENT; -static const int RExt__PREDICTION_WEIGHTING_ANALYSIS_DC_PRECISION = 0; ///< Additional fixed bit precision used during encoder-side weighting prediction analysis. Currently only used when high_precision_prediction_weighting_flag is set, for backwards compatibility reasons. +static constexpr int RExt__PREDICTION_WEIGHTING_ANALYSIS_DC_PRECISION = 0; ///< Additional fixed bit precision used during encoder-side weighting prediction analysis. Currently only used when high_precision_prediction_weighting_flag is set, for backwards compatibility reasons. -static const int MAX_TIMECODE_SEI_SETS = 3; ///< Maximum number of time sets +static constexpr int MAX_TIMECODE_SEI_SETS = 3; ///< Maximum number of time sets -static constexpr int MAX_CU_DEPTH = 7; // log2(CTUSize) -static const int MAX_CU_SIZE = 1<<MAX_CU_DEPTH; -static const int MIN_CU_LOG2 = 2; -static const int MIN_PU_SIZE = 4; -static const int MAX_NUM_PARTS_IN_CTU = ( ( MAX_CU_SIZE * MAX_CU_SIZE ) >> ( MIN_CU_LOG2 << 1 ) ); -static const int MAX_NUM_TUS = 16; ///< Maximum number of TUs within one CU. When max TB size is 32x32, up to 16 TUs within one CU (128x128) is supported -static const int MAX_LOG2_DIFF_CU_TR_SIZE = 3; -static const int MAX_CU_TILING_PARTITIONS = 1 << ( MAX_LOG2_DIFF_CU_TR_SIZE << 1 ); +static constexpr int MAX_CU_DEPTH = 7; // log2(CTUSize) +static constexpr int MAX_CU_SIZE = 1<<MAX_CU_DEPTH; +static constexpr int MIN_CU_LOG2 = 2; +static constexpr int MIN_PU_SIZE = 4; +static constexpr int MAX_NUM_PARTS_IN_CTU = ( ( MAX_CU_SIZE * MAX_CU_SIZE ) >> ( MIN_CU_LOG2 << 1 ) ); +static constexpr int MAX_NUM_TUS = 16; ///< Maximum number of TUs within one CU. When max TB size is 32x32, up to 16 TUs within one CU (128x128) is supported +static constexpr int MAX_LOG2_DIFF_CU_TR_SIZE = 3; +static constexpr int MAX_CU_TILING_PARTITIONS = 1 << ( MAX_LOG2_DIFF_CU_TR_SIZE << 1 ); static constexpr int PIC_MARGIN = 16; -static const int JVET_C0024_ZERO_OUT_TH = 32; +static constexpr int JVET_C0024_ZERO_OUT_TH = 32; -static const int MAX_NUM_PART_IDXS_IN_CTU_WIDTH = MAX_CU_SIZE/MIN_PU_SIZE; ///< maximum number of partition indices across the width of a CTU (or height of a CTU) -static const int SCALING_LIST_REM_NUM = 6; +static constexpr int MAX_NUM_PART_IDXS_IN_CTU_WIDTH = MAX_CU_SIZE/MIN_PU_SIZE; ///< maximum number of partition indices across the width of a CTU (or height of a CTU) +static constexpr int SCALING_LIST_REM_NUM = 6; -static const int QUANT_SHIFT = 14; ///< Q(4) = 2^14 -static const int IQUANT_SHIFT = 6; +static constexpr int QUANT_SHIFT = 14; ///< Q(4) = 2^14 +static constexpr int IQUANT_SHIFT = 6; static constexpr int SCALE_BITS = 15; // Precision for fractional bit estimates static constexpr double FRAC_BITS_SCALE = 1.0 / (1 << SCALE_BITS); static constexpr int SCALING_LIST_PRED_MODES = 2; -static const int SCALING_LIST_NUM = MAX_NUM_COMPONENT * SCALING_LIST_PRED_MODES; ///< list number for quantization matrix +static constexpr int SCALING_LIST_NUM = MAX_NUM_COMPONENT * SCALING_LIST_PRED_MODES; ///< list number for quantization matrix -static const int SCALING_LIST_START_VALUE = 8; ///< start value for dpcm mode -static const int MAX_MATRIX_COEF_NUM = 64; ///< max coefficient number for quantization matrix -static const int MAX_MATRIX_SIZE_NUM = 8; ///< max size number for quantization matrix -static const int SCALING_LIST_BITS = 8; ///< bit depth of scaling list entries -static const int LOG2_SCALING_LIST_NEUTRAL_VALUE = 4; ///< log2 of the value that, when used in a scaling list, has no effect on quantisation -static const int SCALING_LIST_DC = 16; ///< default DC value +static constexpr int SCALING_LIST_START_VALUE = 8; ///< start value for dpcm mode +static constexpr int MAX_MATRIX_COEF_NUM = 64; ///< max coefficient number for quantization matrix +static constexpr int MAX_MATRIX_SIZE_NUM = 8; ///< max size number for quantization matrix +static constexpr int SCALING_LIST_BITS = 8; ///< bit depth of scaling list entries +static constexpr int LOG2_SCALING_LIST_NEUTRAL_VALUE = 4; ///< log2 of the value that, when used in a scaling list, has no effect on quantisation +static constexpr int SCALING_LIST_DC = 16; ///< default DC value -static const int LAST_SIGNIFICANT_GROUPS = 14; +static constexpr int LAST_SIGNIFICANT_GROUPS = 14; static constexpr int AFFINE_SUBBLOCK_SIZE = 4; // Minimum affine MC block size -static const int MMVD_REFINE_STEP = 8; ///< max number of distance step -static const int MMVD_MAX_REFINE_NUM = (MMVD_REFINE_STEP * 4); ///< max number of candidate from a base candidate -static const int MMVD_BASE_MV_NUM = 2; ///< max number of base candidate -static const int MMVD_ADD_NUM = (MMVD_MAX_REFINE_NUM * MMVD_BASE_MV_NUM);///< total number of mmvd candidate -static const int MMVD_MRG_MAX_RD_NUM = MRG_MAX_NUM_CANDS; -static const int MMVD_MRG_MAX_RD_BUF_NUM = (MMVD_MRG_MAX_RD_NUM + 1);///< increase buffer size by 1 +static constexpr int MMVD_REFINE_STEP = 8; ///< max number of distance step +static constexpr int MMVD_MAX_REFINE_NUM = (MMVD_REFINE_STEP * 4); ///< max number of candidate from a base candidate +static constexpr int MMVD_BASE_MV_NUM = 2; ///< max number of base candidate +static constexpr int MMVD_ADD_NUM = (MMVD_MAX_REFINE_NUM * MMVD_BASE_MV_NUM);///< total number of mmvd candidate +static constexpr int MMVD_MRG_MAX_RD_NUM = MRG_MAX_NUM_CANDS; +static constexpr int MMVD_MRG_MAX_RD_BUF_NUM = (MMVD_MRG_MAX_RD_NUM + 1);///< increase buffer size by 1 -static const int MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA = 28; -static const int MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA = 28; +static constexpr int MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA = 28; +static constexpr int MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA = 28; -static const int BIO_EXTEND_SIZE = 1; -static const int BIO_TEMP_BUFFER_SIZE = (MAX_CU_SIZE + 2 * BIO_EXTEND_SIZE) * (MAX_CU_SIZE + 2 * BIO_EXTEND_SIZE); +static constexpr int BIO_EXTEND_SIZE = 1; +static constexpr int BIO_TEMP_BUFFER_SIZE = (MAX_CU_SIZE + 2 * BIO_EXTEND_SIZE) * (MAX_CU_SIZE + 2 * BIO_EXTEND_SIZE); -static const int PROF_BORDER_EXT_W = 1; -static const int PROF_BORDER_EXT_H = 1; -static const int BCW_NUM = 5; ///< the number of weight options -static const int BCW_DEFAULT = ((uint8_t)(BCW_NUM >> 1)); ///< Default weighting index representing for w=0.5 -static const int BCW_SIZE_CONSTRAINT = 256; ///< disabling Bcw if cu size is smaller than 256 -static const int MAX_NUM_HMVP_CANDS = (MRG_MAX_NUM_CANDS-1); ///< maximum number of HMVP candidates to be stored and used in merge list -static const int MAX_NUM_HMVP_AVMPCANDS = 4; ///< maximum number of HMVP candidates to be used in AMVP list +static constexpr int PROF_BORDER_EXT_W = 1; +static constexpr int PROF_BORDER_EXT_H = 1; +static constexpr int BCW_NUM = 5; ///< the number of weight options +static constexpr int BCW_DEFAULT = ((uint8_t)(BCW_NUM >> 1)); ///< Default weighting index representing for w=0.5 +static constexpr int BCW_SIZE_CONSTRAINT = 256; ///< disabling Bcw if cu size is smaller than 256 +static constexpr int MAX_NUM_HMVP_CANDS = (MRG_MAX_NUM_CANDS-1); ///< maximum number of HMVP candidates to be stored and used in merge list +static constexpr int MAX_NUM_HMVP_AVMPCANDS = 4; ///< maximum number of HMVP candidates to be used in AMVP list -static const int ALF_VB_POS_ABOVE_CTUROW_LUMA = 4; -static const int ALF_VB_POS_ABOVE_CTUROW_CHMA = 2; +static constexpr int ALF_VB_POS_ABOVE_CTUROW_LUMA = 4; +static constexpr int ALF_VB_POS_ABOVE_CTUROW_CHMA = 2; #if W0038_DB_OPT -static const int MAX_ENCODER_DEBLOCKING_QUALITY_LAYERS = 8 ; +static constexpr int MAX_ENCODER_DEBLOCKING_QUALITY_LAYERS = 8 ; #endif #if SHARP_LUMA_DELTA_QP -static const uint32_t LUMA_LEVEL_TO_DQP_LUT_MAXSIZE = 1024; ///< max LUT size for QP offset based on luma +static constexpr uint32_t LUMA_LEVEL_TO_DQP_LUT_MAXSIZE = 1024; ///< max LUT size for QP offset based on luma #endif -static const int DMVR_SUBCU_WIDTH = 16; -static const int DMVR_SUBCU_HEIGHT = 16; -static const int DMVR_SUBCU_WIDTH_LOG2 = 4; -static const int DMVR_SUBCU_HEIGHT_LOG2 = 4; -static const int MAX_NUM_SUBCU_DMVR = ((MAX_CU_SIZE * MAX_CU_SIZE) >> (DMVR_SUBCU_WIDTH_LOG2 + DMVR_SUBCU_HEIGHT_LOG2)); -static const int DMVR_NUM_ITERATION = 2; +static constexpr int DMVR_SUBCU_WIDTH = 16; +static constexpr int DMVR_SUBCU_HEIGHT = 16; +static constexpr int DMVR_SUBCU_WIDTH_LOG2 = 4; +static constexpr int DMVR_SUBCU_HEIGHT_LOG2 = 4; +static constexpr int MAX_NUM_SUBCU_DMVR = ((MAX_CU_SIZE * MAX_CU_SIZE) >> (DMVR_SUBCU_WIDTH_LOG2 + DMVR_SUBCU_HEIGHT_LOG2)); +static constexpr int DMVR_NUM_ITERATION = 2; //QTBT high level parameters //for I slice luma CTB configuration para. -static const int MAX_BT_DEPTH = 4; ///< <=7 +static constexpr int MAX_BT_DEPTH = 4; ///< <=7 //for P/B slice CTU config. para. -static const int MAX_BT_DEPTH_INTER = 4; ///< <=7 +static constexpr int MAX_BT_DEPTH_INTER = 4; ///< <=7 //for I slice chroma CTB configuration para. (in luma samples) -static const int MAX_BT_DEPTH_C = 0; ///< <=7 -static const int MIN_DUALTREE_CHROMA_WIDTH = 4; -static const int MIN_DUALTREE_CHROMA_SIZE = 16; -static const SplitSeries SPLIT_BITS = 5; -static const SplitSeries SPLIT_DMULT = 5; -static const SplitSeries SPLIT_MASK = 31; ///< = (1 << SPLIT_BITS) - 1 +static constexpr int MAX_BT_DEPTH_C = 0; ///< <=7 +static constexpr int MIN_DUALTREE_CHROMA_WIDTH = 4; +static constexpr int MIN_DUALTREE_CHROMA_SIZE = 16; +static constexpr SplitSeries SPLIT_BITS = 5; +static constexpr SplitSeries SPLIT_DMULT = 5; +static constexpr SplitSeries SPLIT_MASK = 31; ///< = (1 << SPLIT_BITS) - 1 -static const int SKIP_DEPTH = 3; -static const int PICTURE_DISTANCE_TH = 1; -static const int FAST_SKIP_DEPTH = 2; +static constexpr int SKIP_DEPTH = 3; +static constexpr int PICTURE_DISTANCE_TH = 1; +static constexpr int FAST_SKIP_DEPTH = 2; -static const double PBINTRA_RATIO = 1.1; -static const int NUM_MRG_SATD_CAND = 4; -static const double MRG_FAST_RATIO = 1.25; -static const int NUM_AFF_MRG_SATD_CAND = 2; +static constexpr double PBINTRA_RATIO = 1.1; +static constexpr int NUM_MRG_SATD_CAND = 4; +static constexpr double MRG_FAST_RATIO = 1.25; +static constexpr int NUM_AFF_MRG_SATD_CAND = 2; -static const double AMAXBT_TH32 = 15.0; -static const double AMAXBT_TH64 = 30.0; +static constexpr double AMAXBT_TH32 = 15.0; +static constexpr double AMAXBT_TH64 = 30.0; static constexpr int FAST_METHOD_TT_ENC_SPEEDUP = 0x0001; ///< Embedding flag, which, if false, de-activates all the following ABT_ENC_SPEEDUP_* modes static constexpr int FAST_METHOD_HOR_XOR_VER = 0x0002; @@ -403,10 +403,10 @@ static constexpr int FAST_METHOD_TT_ENC_SPEEDUP_BSLICE = 0x0008; static constexpr int FAST_METHOD_TT_ENC_SPEEDUP_ISLICE = 0x0010; // need to know for static memory allocation -static const int MAX_DELTA_QP = 7; ///< maximum supported delta QP value -static const int MAX_TESTED_QPs = ( 1 + 1 + ( MAX_DELTA_QP << 1 ) ); ///< dqp=0 +- max_delta_qp + lossless mode +static constexpr int MAX_DELTA_QP = 7; ///< maximum supported delta QP value +static constexpr int MAX_TESTED_QPs = ( 1 + 1 + ( MAX_DELTA_QP << 1 ) ); ///< dqp=0 +- max_delta_qp + lossless mode -static const int COM16_C806_TRANS_PREC = 0; +static constexpr int COM16_C806_TRANS_PREC = 0; static constexpr int NTAPS_LUMA = 8; // Number of taps for luma static constexpr int NTAPS_CHROMA = 4; // Number of taps for chroma @@ -414,41 +414,41 @@ static constexpr int NTAPS_BILINEAR = 2; // Number of taps for bilinear filte static constexpr int MAX_FILTER_SIZE = NTAPS_LUMA > NTAPS_CHROMA ? NTAPS_LUMA : NTAPS_CHROMA; #if LUMA_ADAPTIVE_DEBLOCKING_FILTER_QP_OFFSET -static const int MAX_LADF_INTERVALS = 5; /// max number of luma adaptive deblocking filter qp offset intervals +static constexpr int MAX_LADF_INTERVALS = 5; /// max number of luma adaptive deblocking filter qp offset intervals #endif -static const int ATMVP_SUB_BLOCK_SIZE = 3; ///< sub-block size for ATMVP -static const int GEO_MAX_NUM_UNI_CANDS = 6; -static const int GEO_MAX_NUM_CANDS = GEO_MAX_NUM_UNI_CANDS * (GEO_MAX_NUM_UNI_CANDS - 1); -static const int GEO_MIN_CU_LOG2 = 3; -static const int GEO_MAX_CU_LOG2 = 6; -static const int GEO_MIN_CU_SIZE = 1 << GEO_MIN_CU_LOG2; -static const int GEO_MAX_CU_SIZE = 1 << GEO_MAX_CU_LOG2; -static const int GEO_NUM_CU_SIZE = ( GEO_MAX_CU_LOG2 - GEO_MIN_CU_LOG2 ) + 1; -static const int GEO_NUM_PARTITION_MODE = 64; -static const int GEO_NUM_ANGLES = 32; -static const int GEO_NUM_DISTANCES = 4; -static const int GEO_NUM_PRESTORED_MASK = 6; -static const int GEO_WEIGHT_MASK_SIZE = 3 * (GEO_MAX_CU_SIZE >> 3) * 2 + GEO_MAX_CU_SIZE; -static const int GEO_MV_MASK_SIZE = GEO_WEIGHT_MASK_SIZE >> 2; -static const int GEO_MAX_TRY_WEIGHTED_SAD = 60; -static const int GEO_MAX_TRY_WEIGHTED_SATD = 8; - -static const int SBT_MAX_SIZE = 64; ///< maximum CU size for using SBT -static const int SBT_NUM_SL = 10; ///< maximum number of historical PU decision saved for a CU -static const int SBT_NUM_RDO = 2; ///< maximum number of SBT mode tried for a PU - -static const int NUM_INTER_CU_INFO_SAVE = 8; ///< maximum number of inter cu information saved for fast algorithm -static const int LDT_MODE_TYPE_INHERIT = 0; ///< No need to signal mode_constraint_flag, and the modeType of the region is inherited from its parent node -static const int LDT_MODE_TYPE_INFER = 1; ///< No need to signal mode_constraint_flag, and the modeType of the region is inferred as MODE_TYPE_INTRA -static const int LDT_MODE_TYPE_SIGNAL = 2; ///< Need to signal mode_constraint_flag, and the modeType of the region is determined by the flag - -static const int IBC_MAX_CAND_SIZE = 16; // max block size for ibc search -static const int IBC_NUM_CANDIDATES = 64; ///< Maximum number of candidates to store/test -static const int CHROMA_REFINEMENT_CANDIDATES = 8; /// 8 candidates BV to choose from -static const int IBC_FAST_METHOD_NOINTRA_IBCCBF0 = 0x01; -static const int IBC_FAST_METHOD_BUFFERBV = 0X02; -static const int IBC_FAST_METHOD_ADAPTIVE_SEARCHRANGE = 0X04; +static constexpr int ATMVP_SUB_BLOCK_SIZE = 3; ///< sub-block size for ATMVP +static constexpr int GEO_MAX_NUM_UNI_CANDS = 6; +static constexpr int GEO_MAX_NUM_CANDS = GEO_MAX_NUM_UNI_CANDS * (GEO_MAX_NUM_UNI_CANDS - 1); +static constexpr int GEO_MIN_CU_LOG2 = 3; +static constexpr int GEO_MAX_CU_LOG2 = 6; +static constexpr int GEO_MIN_CU_SIZE = 1 << GEO_MIN_CU_LOG2; +static constexpr int GEO_MAX_CU_SIZE = 1 << GEO_MAX_CU_LOG2; +static constexpr int GEO_NUM_CU_SIZE = ( GEO_MAX_CU_LOG2 - GEO_MIN_CU_LOG2 ) + 1; +static constexpr int GEO_NUM_PARTITION_MODE = 64; +static constexpr int GEO_NUM_ANGLES = 32; +static constexpr int GEO_NUM_DISTANCES = 4; +static constexpr int GEO_NUM_PRESTORED_MASK = 6; +static constexpr int GEO_WEIGHT_MASK_SIZE = 3 * (GEO_MAX_CU_SIZE >> 3) * 2 + GEO_MAX_CU_SIZE; +static constexpr int GEO_MV_MASK_SIZE = GEO_WEIGHT_MASK_SIZE >> 2; +static constexpr int GEO_MAX_TRY_WEIGHTED_SAD = 60; +static constexpr int GEO_MAX_TRY_WEIGHTED_SATD = 8; + +static constexpr int SBT_MAX_SIZE = 64; ///< maximum CU size for using SBT +static constexpr int SBT_NUM_SL = 10; ///< maximum number of historical PU decision saved for a CU +static constexpr int SBT_NUM_RDO = 2; ///< maximum number of SBT mode tried for a PU + +static constexpr int NUM_INTER_CU_INFO_SAVE = 8; ///< maximum number of inter cu information saved for fast algorithm +static constexpr int LDT_MODE_TYPE_INHERIT = 0; ///< No need to signal mode_constraint_flag, and the modeType of the region is inherited from its parent node +static constexpr int LDT_MODE_TYPE_INFER = 1; ///< No need to signal mode_constraint_flag, and the modeType of the region is inferred as MODE_TYPE_INTRA +static constexpr int LDT_MODE_TYPE_SIGNAL = 2; ///< Need to signal mode_constraint_flag, and the modeType of the region is determined by the flag + +static constexpr int IBC_MAX_CAND_SIZE = 16; // max block size for ibc search +static constexpr int IBC_NUM_CANDIDATES = 64; ///< Maximum number of candidates to store/test +static constexpr int CHROMA_REFINEMENT_CANDIDATES = 8; /// 8 candidates BV to choose from +static constexpr int IBC_FAST_METHOD_NOINTRA_IBCCBF0 = 0x01; +static constexpr int IBC_FAST_METHOD_BUFFERBV = 0X02; +static constexpr int IBC_FAST_METHOD_ADAPTIVE_SEARCHRANGE = 0X04; static constexpr int MV_EXPONENT_BITCOUNT = 4; static constexpr int MV_MANTISSA_BITCOUNT = 6; static constexpr int MV_MANTISSA_UPPER_LIMIT = ((1 << (MV_MANTISSA_BITCOUNT - 1)) - 1); @@ -459,47 +459,47 @@ static constexpr int MV_BITS = 18; static constexpr int MV_MAX = (1 << (MV_BITS - 1)) - 1; static constexpr int MV_MIN = -(1 << (MV_BITS - 1)); -static const int MVD_MAX = (1 << 17) - 1; -static const int MVD_MIN = -(1 << 17); - -static const int PIC_ANALYZE_CW_BINS = 32; -static const int PIC_CODE_CW_BINS = 16; -static const int LMCS_SEG_NUM = 32; -static const int FP_PREC = 11; -static const int CSCALE_FP_PREC = 11; -static const int LOG2_PALETTE_CG_SIZE = 4; -static const int RUN_IDX_THRE = 4; -static const int MAX_CU_BLKSIZE_PLT = 64; -static const int NUM_TRELLIS_STATE = 3; -static const double ENC_CHROMA_WEIGHTING = 0.8; -static const int MAXPLTPREDSIZE = 63; -static const int MAXPLTSIZE = 31; -static const int MAXPLTPREDSIZE_DUALTREE = 31; -static const int MAXPLTSIZE_DUALTREE = 15; -static const double PLT_CHROMA_WEIGHTING = 0.8; -static const int PLT_ENCBITDEPTH = 8; -static const int PLT_FAST_RATIO = 100; +static constexpr int MVD_MAX = (1 << 17) - 1; +static constexpr int MVD_MIN = -(1 << 17); + +static constexpr int PIC_ANALYZE_CW_BINS = 32; +static constexpr int PIC_CODE_CW_BINS = 16; +static constexpr int LMCS_SEG_NUM = 32; +static constexpr int FP_PREC = 11; +static constexpr int CSCALE_FP_PREC = 11; +static constexpr int LOG2_PALETTE_CG_SIZE = 4; +static constexpr int RUN_IDX_THRE = 4; +static constexpr int MAX_CU_BLKSIZE_PLT = 64; +static constexpr int NUM_TRELLIS_STATE = 3; +static constexpr double ENC_CHROMA_WEIGHTING = 0.8; +static constexpr int MAXPLTPREDSIZE = 63; +static constexpr int MAXPLTSIZE = 31; +static constexpr int MAXPLTPREDSIZE_DUALTREE = 31; +static constexpr int MAXPLTSIZE_DUALTREE = 15; +static constexpr double PLT_CHROMA_WEIGHTING = 0.8; +static constexpr int PLT_ENCBITDEPTH = 8; +static constexpr int PLT_FAST_RATIO = 100; #if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS -static const int EPBIN_WEIGHT_FACTOR = 4; +static constexpr int EPBIN_WEIGHT_FACTOR = 4; #endif -static const int ENC_PPS_ID_RPR = 3; -static const int SCALE_RATIO_BITS = 14; -static const int MAX_SCALING_RATIO = 2; // max downsampling ratio for RPR -static const std::pair<int, int> SCALE_1X = std::pair<int, int>( 1 << SCALE_RATIO_BITS, 1 << SCALE_RATIO_BITS ); // scale ratio 1x -static const int DELTA_QP_ACT[4] = { -5, 1, 3, 1 }; -static const int MAX_TSRC_RICE = 8; ///<Maximum supported TSRC Rice parameter -static const int MIN_TSRC_RICE = 1; ///<Minimum supported TSRC Rice parameter -static const int MAX_CTI_LUT_SIZE = 64; ///<Maximum colour transform LUT size for CTI SEI -static const int MAX_NUM_INTENSITIES = 256; ///<Maximum number of intensity intervals supported in FGC SEI -static const int MAX_NUM_MODEL_VALUES = 6; ///<Maximum number of model values supported in FGC SEI -static const int MAX_ALLOWED_MODEL_VALUES = 3; -static const int MAX_ALLOWED_COMP_MODEL_PAIRS = 10; -static const int MAX_STANDARD_DEVIATION = 255; // for 8-bit format; for higher bit depths, internal scaling is performed -static const int DATA_BASE_SIZE = 64; -static const int BLK_8 = 8; -static const int BLK_16 = 16; -static const int BLK_32 = 32; -static const int BIT_DEPTH_8 = 8; +static constexpr int ENC_PPS_ID_RPR = 3; +static constexpr int SCALE_RATIO_BITS = 14; +static constexpr int MAX_SCALING_RATIO = 2; // max downsampling ratio for RPR +static const std::pair<int, int> SCALE_1X = std::pair<int, int>( 1 << SCALE_RATIO_BITS, 1 << SCALE_RATIO_BITS ); // scale ratio 1x +static constexpr int DELTA_QP_ACT[4] = { -5, 1, 3, 1 }; +static constexpr int MAX_TSRC_RICE = 8; ///<Maximum supported TSRC Rice parameter +static constexpr int MIN_TSRC_RICE = 1; ///<Minimum supported TSRC Rice parameter +static constexpr int MAX_CTI_LUT_SIZE = 64; ///<Maximum colour transform LUT size for CTI SEI +static constexpr int MAX_NUM_INTENSITIES = 256; ///<Maximum number of intensity intervals supported in FGC SEI +static constexpr int MAX_NUM_MODEL_VALUES = 6; ///<Maximum number of model values supported in FGC SEI +static constexpr int MAX_ALLOWED_MODEL_VALUES = 3; +static constexpr int MAX_ALLOWED_COMP_MODEL_PAIRS = 10; +static constexpr int MAX_STANDARD_DEVIATION = 255; // for 8-bit format; for higher bit depths, internal scaling is performed +static constexpr int DATA_BASE_SIZE = 64; +static constexpr int BLK_8 = 8; +static constexpr int BLK_16 = 16; +static constexpr int BLK_32 = 32; +static constexpr int BIT_DEPTH_8 = 8; static constexpr int MSE_WEIGHT_FRAC_BITS = 16; static constexpr int MSE_WEIGHT_ONE = 1 << MSE_WEIGHT_FRAC_BITS; @@ -507,8 +507,8 @@ static constexpr int MSE_WEIGHT_ONE = 1 << MSE_WEIGHT_FRAC_BITS; // SEI and related constants // ==================================================================================================================== #if JVET_Z0120_SII_SEI_PROCESSING -static const double SII_PF_W2 = 0.6; // weight for current picture -static const double SII_PF_W1 = 0.4; // weight for previous picture , it must be equal to 1.0 - SII_PF_W2 +static constexpr double SII_PF_W2 = 0.6; // weight for current picture +static constexpr double SII_PF_W1 = 0.4; // weight for previous picture , it must be equal to 1.0 - SII_PF_W2 #endif // ==================================================================================================================== // Macro functions @@ -709,8 +709,8 @@ static inline int ceilLog2(uint32_t x) #define _UNIT_AREA_AT(_a,_x,_y,_w,_h) #endif -static const uint32_t CCALF_CANDS_COEFF_NR = 8; -static const int CCALF_SMALL_TAB[CCALF_CANDS_COEFF_NR] = { 0, 1, 2, 4, 8, 16, 32, 64 }; +static constexpr uint32_t CCALF_CANDS_COEFF_NR = 8; +static constexpr int CCALF_SMALL_TAB[CCALF_CANDS_COEFF_NR] = { 0, 1, 2, 4, 8, 16, 32, 64 }; //! \} diff --git a/source/Lib/CommonLib/IntraPrediction.h b/source/Lib/CommonLib/IntraPrediction.h index 533bf3dc1de320324f9eb3fb1a47480696264f3e..43e6e059c8793a6f9de72ff5474874791b046505 100644 --- a/source/Lib/CommonLib/IntraPrediction.h +++ b/source/Lib/CommonLib/IntraPrediction.h @@ -61,7 +61,7 @@ enum PredBuf NUM_PRED_BUF = 2 }; -static const uint32_t MAX_INTRA_FILTER_DEPTHS=8; +static constexpr uint32_t MAX_INTRA_FILTER_DEPTHS=8; class IntraPrediction { diff --git a/source/Lib/CommonLib/MatrixIntraPrediction.h b/source/Lib/CommonLib/MatrixIntraPrediction.h index c86f8f3b18529d99411fe3cd775c725ef9f96c3f..4c58e9ff9346ec5732aab8a28c32eec7ec4a7b45 100644 --- a/source/Lib/CommonLib/MatrixIntraPrediction.h +++ b/source/Lib/CommonLib/MatrixIntraPrediction.h @@ -41,8 +41,8 @@ #include "Unit.h" -static const int MIP_MAX_INPUT_SIZE = 8; -static const int MIP_MAX_REDUCED_OUTPUT_SAMPLES = 64; +static constexpr int MIP_MAX_INPUT_SIZE = 8; +static constexpr int MIP_MAX_REDUCED_OUTPUT_SAMPLES = 64; class MatrixIntraPrediction diff --git a/source/Lib/CommonLib/Rom.cpp b/source/Lib/CommonLib/Rom.cpp index b932d1a80bef97be4d19bc72a32284f6e110f300..0b95269286074995734052aa44bd152f500abf21 100644 --- a/source/Lib/CommonLib/Rom.cpp +++ b/source/Lib/CommonLib/Rom.cpp @@ -727,7 +727,7 @@ void initGeoTemplate() int16_t rho = (g_Dis[distanceX] * 2 * GEO_MAX_CU_SIZE) + (g_Dis[distanceY] * 2 * GEO_MAX_CU_SIZE); - static const int16_t maskOffset = (2*GEO_MAX_CU_SIZE - GEO_WEIGHT_MASK_SIZE) >> 1; + static constexpr int16_t maskOffset = (2*GEO_MAX_CU_SIZE - GEO_WEIGHT_MASK_SIZE) >> 1; int index = 0; for( int y = 0; y < GEO_WEIGHT_MASK_SIZE; y++ ) { diff --git a/source/Lib/CommonLib/SEI.h b/source/Lib/CommonLib/SEI.h index 61d064bd1fae48187e21003981c406433dba3988..2a6bcec7962d21ce102eef32883e0e932d7e18d9 100644 --- a/source/Lib/CommonLib/SEI.h +++ b/source/Lib/CommonLib/SEI.h @@ -442,7 +442,7 @@ public: int m_sariSarHeight; }; -static const uint32_t ISO_IEC_11578_LEN=16; +static constexpr uint32_t ISO_IEC_11578_LEN=16; class SEIuserDataUnregistered : public SEI { diff --git a/source/Lib/CommonLib/SEIFilmGrainSynthesizer.h b/source/Lib/CommonLib/SEIFilmGrainSynthesizer.h index bd4af02347c30c2c8264db8b58caa16cd5664a8c..4f618ddbf93551f3f297edd7a9b067a85e0b3def 100644 --- a/source/Lib/CommonLib/SEIFilmGrainSynthesizer.h +++ b/source/Lib/CommonLib/SEIFilmGrainSynthesizer.h @@ -53,38 +53,38 @@ // Class definition // ==================================================================================================================== -static const int MIN_LOG2SCALE_VALUE = 2; -static const int MAX_LOG2SCALE_VALUE = 7; -static const int FILM_GRAIN_MODEL_ID_VALUE = 0; -static const int BLENDING_MODE_VALUE = 0; -static const int MIN_CUT_OFF_FREQUENCY = 2; -static const int MAX_CUT_OFF_FREQUENCY = 14; -static const int DEFAULT_HORZ_CUT_OFF_FREQUENCY = 8; -static const int NUM_CUT_OFF_FREQ = 13; - -static const int SCALE_DOWN_422 = 181; /* in Q-format of 8 : 1/sqrt(2) */ -static const int Q_FORMAT_SCALING = 8; -static const int GRAIN_SCALE = 6; -static const int MIN_CHROMA_FORMAT_IDC = 0; -static const int MAX_CHROMA_FORMAT_IDC = 3; -static const int MIN_BIT_DEPTH = 8; -static const int MAX_BIT_DEPTH = 16; -static const int BLK_8_shift = 6; -static const int BLK_16_shift = 8; -static const int BLK_32_shift = 10; -static const int NUM_8x8_BLKS_16x16 = 4; -static const int NUM_16x16_BLKS_32x32 = 4; -static const int BLK_AREA_8x8 = 64; -static const int BLK_AREA_16x16 = 256; -static const int INTENSITY_INTERVAL_MATCH_FAIL = -1; -static const int COLOUR_OFFSET_LUMA = 0; -static const int COLOUR_OFFSET_CR = 85; -static const int COLOUR_OFFSET_CB = 170; - -static const int MIN_WIDTH = 128; -static const int MAX_WIDTH = 7680; -static const int MIN_HEIGHT = 128; -static const int MAX_HEIGHT = 4320; +static constexpr int MIN_LOG2SCALE_VALUE = 2; +static constexpr int MAX_LOG2SCALE_VALUE = 7; +static constexpr int FILM_GRAIN_MODEL_ID_VALUE = 0; +static constexpr int BLENDING_MODE_VALUE = 0; +static constexpr int MIN_CUT_OFF_FREQUENCY = 2; +static constexpr int MAX_CUT_OFF_FREQUENCY = 14; +static constexpr int DEFAULT_HORZ_CUT_OFF_FREQUENCY = 8; +static constexpr int NUM_CUT_OFF_FREQ = 13; + +static constexpr int SCALE_DOWN_422 = 181; /* in Q-format of 8 : 1/sqrt(2) */ +static constexpr int Q_FORMAT_SCALING = 8; +static constexpr int GRAIN_SCALE = 6; +static constexpr int MIN_CHROMA_FORMAT_IDC = 0; +static constexpr int MAX_CHROMA_FORMAT_IDC = 3; +static constexpr int MIN_BIT_DEPTH = 8; +static constexpr int MAX_BIT_DEPTH = 16; +static constexpr int BLK_8_shift = 6; +static constexpr int BLK_16_shift = 8; +static constexpr int BLK_32_shift = 10; +static constexpr int NUM_8x8_BLKS_16x16 = 4; +static constexpr int NUM_16x16_BLKS_32x32 = 4; +static constexpr int BLK_AREA_8x8 = 64; +static constexpr int BLK_AREA_16x16 = 256; +static constexpr int INTENSITY_INTERVAL_MATCH_FAIL = -1; +static constexpr int COLOUR_OFFSET_LUMA = 0; +static constexpr int COLOUR_OFFSET_CR = 85; +static constexpr int COLOUR_OFFSET_CB = 170; + +static constexpr int MIN_WIDTH = 128; +static constexpr int MAX_WIDTH = 7680; +static constexpr int MIN_HEIGHT = 128; +static constexpr int MAX_HEIGHT = 4320; #define CLIP3(min, max, x) (((x) > (max)) ? (max) :(((x) < (min))? (min):(x))) #define MIN(x,y) (((x) > (y)) ? (y) : (x)) diff --git a/source/Lib/EncoderLib/EncModeCtrl.h b/source/Lib/EncoderLib/EncModeCtrl.h index 05333a291bc0a34b8203a622613f59ebcb96b4bc..9460e9ca449bdbf93cc220bc55f45f7834c40851 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.h +++ b/source/Lib/EncoderLib/EncModeCtrl.h @@ -788,7 +788,7 @@ public: bool saveBestSbt( const UnitArea& area, const uint32_t curPuSse, const uint8_t curPuSbt, const uint8_t curPuTrs ); }; -static const int MAX_STORED_CU_INFO_REFS = 4; +static constexpr int MAX_STORED_CU_INFO_REFS = 4; struct CodedCUInfo { diff --git a/source/Lib/EncoderLib/InterSearch.h b/source/Lib/EncoderLib/InterSearch.h index da28906df126ce4130f8cbc774a8c669ec339c7f..bd2b2f918f24c80a9a0b2e27930ae4be8d8d23c7 100644 --- a/source/Lib/EncoderLib/InterSearch.h +++ b/source/Lib/EncoderLib/InterSearch.h @@ -62,9 +62,9 @@ // Class definition // ==================================================================================================================== -static const uint32_t MAX_NUM_REF_LIST_ADAPT_SR = 2; -static const uint32_t MAX_IDX_ADAPT_SR = 33; -static const uint32_t NUM_MV_PREDICTORS = 3; +static constexpr uint32_t MAX_NUM_REF_LIST_ADAPT_SR = 2; +static constexpr uint32_t MAX_IDX_ADAPT_SR = 33; +static constexpr uint32_t NUM_MV_PREDICTORS = 3; struct BlkRecord { std::unordered_map<Mv, Distortion> bvRecord; diff --git a/source/Lib/EncoderLib/SEIFilmGrainAnalyzer.h b/source/Lib/EncoderLib/SEIFilmGrainAnalyzer.h index 2443b434a6f27a72a8cb8d8aa2338d53ca9bfa19..a4062dc0416fe2b45f65968fc700a3cdf35ef898 100644 --- a/source/Lib/EncoderLib/SEIFilmGrainAnalyzer.h +++ b/source/Lib/EncoderLib/SEIFilmGrainAnalyzer.h @@ -50,42 +50,42 @@ #include <algorithm> -static const double PI = 3.14159265358979323846; +static constexpr double PI = 3.14159265358979323846; // POLYFIT -static const int MAXPAIRS = 256; -static const int MAXORDER = 8; // maximum order of polinomial fitting +static constexpr int MAXPAIRS = 256; +static constexpr int MAXORDER = 8; // maximum order of polinomial fitting #if JVET_Z0047_FG_IMPROVEMENT -static const int MAX_REAL_SCALE = 16; -static const int ORDER = 4; // order of polinomial function -static const int QUANT_LEVELS = 4; // number of quantization levels in lloyd max quantization -static const int INTERVAL_SIZE = 16; -static const int MIN_ELEMENT_NUMBER_PER_INTENSITY_INTERVAL = 8; -static const int MIN_POINTS_FOR_INTENSITY_ESTIMATION = 40; // 5*8 = 40; 5 intervals with at least 8 points -static const int MIN_BLOCKS_FOR_CUTOFF_ESTIMATION = 2; // 2 blocks of 64 x 64 size -static const int POINT_STEP = 16; // step size in point extension -static const int MAX_NUM_POINT_TO_EXTEND = 4; // max point in extension -static const double POINT_SCALE = 1.25; // scaling in point extension -static const double VAR_SCALE_DOWN = 1.2; // filter out large points -static const double VAR_SCALE_UP = 0.6; // filter out large points -static const int NUM_PASSES = 2; // number of passes when fitting the function -static const int NBRS = 1; // minimum number of surrounding points in order to keep it for further analysis (within the widnow range) -static const int WINDOW = 1; // window to check surrounding points -static const int MIN_INTENSITY = 40; -static const int MAX_INTENSITY = 950; +static constexpr int MAX_REAL_SCALE = 16; +static constexpr int ORDER = 4; // order of polinomial function +static constexpr int QUANT_LEVELS = 4; // number of quantization levels in lloyd max quantization +static constexpr int INTERVAL_SIZE = 16; +static constexpr int MIN_ELEMENT_NUMBER_PER_INTENSITY_INTERVAL = 8; +static constexpr int MIN_POINTS_FOR_INTENSITY_ESTIMATION = 40; // 5*8 = 40; 5 intervals with at least 8 points +static constexpr int MIN_BLOCKS_FOR_CUTOFF_ESTIMATION = 2; // 2 blocks of 64 x 64 size +static constexpr int POINT_STEP = 16; // step size in point extension +static constexpr int MAX_NUM_POINT_TO_EXTEND = 4; // max point in extension +static constexpr double POINT_SCALE = 1.25; // scaling in point extension +static constexpr double VAR_SCALE_DOWN = 1.2; // filter out large points +static constexpr double VAR_SCALE_UP = 0.6; // filter out large points +static constexpr int NUM_PASSES = 2; // number of passes when fitting the function +static constexpr int NBRS = 1; // minimum number of surrounding points in order to keep it for further analysis (within the widnow range) +static constexpr int WINDOW = 1; // window to check surrounding points +static constexpr int MIN_INTENSITY = 40; +static constexpr int MAX_INTENSITY = 950; #else -static const int MAX_REAL_SCALE = 32; -static const int ORDER = 3; // order of polinomial function -static const int QUANT_LEVELS = 4; // number of quantization levels in lloyd max quantization -static const int INTERVAL_SIZE = 16; -static const int MIN_ELEMENT_NUMBER_PER_INTENSITY_INTERVAL = 32; -static const int MIN_POINTS_FOR_INTENSITY_ESTIMATION = 128; // 4*32 = 128; 4 intervals with at least 32 points -static const int MIN_BLOCKS_FOR_CUTOFF_ESTIMATION = 4; // 4 blocks of 64 x 64 size -static const int POINT_STEP = 8; // step size in point extension -static const double POINT_SCALE = 1.5; // scaling in point extension -static const double VAR_SCALE_DOWN = 1.5; // filter out large points -static const double VAR_SCALE_UP = 0.5; // filter out large points -static const int NUM_PASSES = 2; // number of passes when fitting the function +static constexpr int MAX_REAL_SCALE = 32; +static constexpr int ORDER = 3; // order of polinomial function +static constexpr int QUANT_LEVELS = 4; // number of quantization levels in lloyd max quantization +static constexpr int INTERVAL_SIZE = 16; +static constexpr int MIN_ELEMENT_NUMBER_PER_INTENSITY_INTERVAL = 32; +static constexpr int MIN_POINTS_FOR_INTENSITY_ESTIMATION = 128; // 4*32 = 128; 4 intervals with at least 32 points +static constexpr int MIN_BLOCKS_FOR_CUTOFF_ESTIMATION = 4; // 4 blocks of 64 x 64 size +static constexpr int POINT_STEP = 8; // step size in point extension +static constexpr double POINT_SCALE = 1.5; // scaling in point extension +static constexpr double VAR_SCALE_DOWN = 1.5; // filter out large points +static constexpr double VAR_SCALE_UP = 0.5; // filter out large points +static constexpr int NUM_PASSES = 2; // number of passes when fitting the function #endif //! \ingroup SEIFilmGrainAnalyzer diff --git a/source/Lib/EncoderLib/WeightPredAnalysis.cpp b/source/Lib/EncoderLib/WeightPredAnalysis.cpp index e5528beb3c88cdc5e89c1f9c07d0121962759465..31432994a78d6ed1190212443adb2172725c0c03 100644 --- a/source/Lib/EncoderLib/WeightPredAnalysis.cpp +++ b/source/Lib/EncoderLib/WeightPredAnalysis.cpp @@ -41,7 +41,7 @@ #include "WeightPredAnalysis.h" #include <limits> -static const double WEIGHT_PRED_SAD_RELATIVE_TO_NON_WEIGHT_PRED_SAD=0.99; // NOTE: U0040 used 0.95 +static constexpr double WEIGHT_PRED_SAD_RELATIVE_TO_NON_WEIGHT_PRED_SAD=0.99; // NOTE: U0040 used 0.95 //! calculate SAD values for both WP version and non-WP version. static