Newer
Older
#if JVET_AI0050_INTER_MTSS
sps.setUseInterMTSS ( m_useInterMTSS );
#endif
#if JVET_AI0050_SBT_LFNST
sps.setUseSbtLFNST ( m_useSbtLFNST );
#endif
sps.setUseBcw ( m_bcw );
#if JVET_AG0276_LIC_SLOPE_ADJUST
sps.setLicSlopeAdjustEnabledFlag( m_licSlopeAdjust );
#endif
Shunsuke Iwamura
committed
#if LUMA_ADAPTIVE_DEBLOCKING_FILTER_QP_OFFSET
sps.setLadfEnabled ( m_LadfEnabled );
Shunsuke Iwamura
committed
if ( m_LadfEnabled )
{
sps.setLadfNumIntervals ( m_LadfNumIntervals );
Shunsuke Iwamura
committed
for ( int k = 0; k < m_LadfNumIntervals; k++ )
{
sps.setLadfQpOffset( m_LadfQpOffset[k], k );
sps.setLadfIntervalLowerBound( m_LadfIntervalLowerBound[k], k );
Shunsuke Iwamura
committed
}
CHECK( m_LadfIntervalLowerBound[0] != 0, "abnormal value set to LadfIntervalLowerBound[0]" );
}
#endif
#if JVET_AA0133_INTER_MTS_OPT
sps.setInterMTSMaxSize(m_interMTSMaxSize);
#endif
#if ENABLE_DIMD
sps.setUseDimd ( m_dimd );
#endif
#if JVET_W0123_TIMD_FUSION
sps.setUseTimd ( m_timd );
#if JVET_AJ0061_TIMD_MERGE
sps.setUseTimdMrg ( m_timdMrg );
#endif
#if JVET_X0141_CIIP_TIMD_TM && JVET_W0123_TIMD_FUSION
sps.setUseCiipTimd ( m_ciipTimd );
#endif
#if JVET_AB0155_SGPM
sps.setUseSgpm ( m_sgpm );
#endif
#if JVET_AD0082_TMRL_CONFIG
sps.setUseTmrl ( m_tmrl );
#endif
#if JVET_AE0174_NONINTER_TM_TOOLS_CONTROL
sps.setTMnoninterToolsEnableFlag ( m_tmNoninterToolsEnableFlag );
#endif
#if JVET_AG0058_EIP
sps.setUseEip ( m_eip );
#endif
#if JVET_AD0085_MPM_SORTING
sps.setUseMpmSorting ( m_mpmSorting );
#endif
#if JVET_AH0136_CHROMA_REORDERING
sps.setUseChromaReordering (m_chromaReordering);
#endif
#if JVET_AC0147_CCCM_NO_SUBSAMPLING
sps.setUseCccm ( m_cccm );
#endif
Chia-Ming Tsai
committed
#if JVET_AD0188_CCP_MERGE
sps.setUseCcpMerge ( m_ccpMerge );
#endif
#if JVET_AG0154_DECODER_DERIVED_CCP_FUSION
sps.setUseDdCcpFusion ( m_ddCcpFusion );
#endif
#if ENABLE_OBMC
sps.setUseOBMC ( m_OBMC );
#endif
sps.setUseCiip ( m_ciip );
#if JVET_X0141_CIIP_TIMD_TM && TM_MRG
if(sps.getUseCiip())
{
Chun-Chi Chen
committed
#if JVET_AA0132_CONFIGURABLE_TM_TOOLS
if(m_tmCIIPMode == 2)
{
#endif
if(getIntraPeriod() < 0)
{
sps.setUseCiipTmMrg (false);
}
else
{
sps.setUseCiipTmMrg (true);
}
Chun-Chi Chen
committed
#if JVET_AA0132_CONFIGURABLE_TM_TOOLS
}
else
{
sps.setUseCiipTmMrg (m_tmCIIPMode == 1);
}
#endif
sps.setUseGeo ( m_Geo );
#if JVET_AG0112_REGRESSION_BASED_GPM_BLENDING
sps.setUseGeoBlend ( m_Geo && m_tmToolsEnableFlag );
#endif
#if JVET_AI0082_GPM_WITH_INTER_IBC
sps.setUseGeoInterIbc ( m_Geo ? m_geoInterIbc : false );
#endif
#if JVET_AJ0107_GPM_SHAPE_ADAPT
sps.setUseGeoShapeAdapt ( m_geoShapeAdapt );
#endif
sps.setFpelMmvdEnabledFlag (( m_MMVD ) ? m_allowDisFracMMVD : false);
#if JVET_Y0067_ENHANCED_MMVD_MVD_SIGN_PRED || JVET_AD0140_MVD_PREDICTION
sps.setUseMvdPred (m_mvdPred);
#if JVET_AC0104_IBC_BVD_PREDICTION
sps.setUseBvdPred (m_bvdPred);
#endif
#if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV
sps.setUseBvpCluster (m_bvpCluster);
#endif
#if JVET_Z0054_BLK_REF_PIC_REORDER
sps.setUseARL (m_useARL);
Mehdi Salehifar
committed
#endif

Xuewei Meng
committed
sps.setBdofControlPresentFlag(m_BIO);
sps.setDmvrControlPresentFlag(m_DMVR);
sps.setProfControlPresentFlag(m_PROF);
sps.setAffineAmvrEnabledFlag ( m_AffineAmvr );
#if JVET_AD0182_AFFINE_DMVR_PLUS_EXTENSIONS
sps.setUseAffineParaRefinement (m_affineParaRefinement);
#endif
sps.setUseColorTrans(m_useColorTrans);
sps.setPLTMode ( m_PLTMode);
#if !JVET_AD0208_IBC_ADAPT_FOR_CAM_CAPTURED_CONTENTS
#else
sps.setIBCFlag ( m_IBCMode & 0x01);
sps.setIBCFlagInterSlice ( m_IBCMode & 0x02);
sps.setUseRRIbc ( m_rribc );
sps.setUseTMIbc ( m_tmibc );
sps.setUseIbcMerge ( m_ibcMerge );
sps.setIBCFracFlag ( m_IBCFracMode);
#endif
#if JVET_AA0061_IBC_MBVD
sps.setUseIbcMbvd ( m_ibcMbvd );
#if JVET_AE0169_IBC_MBVD_LIST_DERIVATION
sps.setUseIbcMbvdAdSearch ( m_ibcMbvdAdSearch );
#endif
#endif
#if JVET_AC0112_IBC_CIIP
sps.setUseIbcCiip ( m_ibcCiip );
#endif
#if JVET_AC0112_IBC_GPM
sps.setUseIbcGpm ( m_ibcGpm );
#endif
#if JVET_AC0112_IBC_LIC
sps.setUseIbcLic ( m_ibcLic );
#if JVET_AE0159_FIBC
sps.setUseIbcFilter ( m_ibcFilter );
#endif
#if JVET_AE0094_IBC_NONADJACENT_SPATIAL_CANDIDATES
sps.setUseIbcNonAdjCand ( m_ibcNonAdjCand );
#endif
#if JVET_AG0136_INTRA_TMP_LIC
sps.setItmpLicExtension ( m_itmpLicExtension );
sps.setItmpLicMode ( m_itmpLicMode );
#endif
#if JVET_AJ0057_HL_INTRA_METHOD_CONTROL
sps.setDisableRefFilter ( false );
sps.setDisablePdpc ( false );
sps.setDisableIntraFusion ( false );
sps.setWrapAroundEnabledFlag ( m_wrapAround );
#if JVET_AH0135_TEMPORAL_PARTITIONING
sps.setEnableMaxMttIncrease ( m_enableMaxMttIncrease );
#endif
#if MULTI_HYP_PRED
sps.setMaxNumAddHyps(m_maxNumAddHyps);
sps.setNumAddHypWeights(m_numAddHypWeights);
sps.setMaxNumAddHypRefFrames(m_maxNumAddHypRefFrames);
#if JVET_V0130_INTRA_TMP
sps.setUseIntraTMP(m_intraTMP);
sps.setIntraTMPMaxSize(m_intraTmpMaxSize);
#if JVET_AE0100_BVGCCCM
sps.setUseBvgCccm(m_bvgCccm);
#endif
#if JVET_AC0071_DBV
sps.setUseIntraDBV(m_intraDBV);
Pekka Astola
committed
#endif
#if JVET_AE0059_INTER_CCCM
sps.setUseInterCccm(m_interCccm);
#endif
#if JVET_AF0073_INTER_CCP_MERGE
sps.setUseInterCcpMerge(m_interCcpMerge);
#if JVET_AH0066_JVET_AH0202_CCP_MERGE_LUMACBF0
sps.setUseInterCcpMergeZeroLumaCbf(m_interCcpMergeZeroLumaCbf);
#endif
Bappaditya Ray
committed
#endif
#if JVET_AH0209_PDP
sps.setUsePDP( m_pdp );
#endif
#if JVET_AI0183_MVP_EXTENSION
sps.setConfigScaledMvExtBiTmvp( m_scaledMvExtBiTmvp );
if (getBaseQP() < 27 && ((getSourceWidth() * getSourceHeight()) < (3840 * 2160)))
{
sps.setConfigScaledMvExtBiTmvp( false );
}

Karsten Suehring
committed
// ADD_NEW_TOOL : (encoder lib) set tool enabling flags and associated parameters here
sps.setUseISP ( m_ISP );
sps.setUseLmcs ( m_lmcsEnabled );
sps.setUseMIP ( m_MIP );
CHECK(m_log2MinCUSize > std::min(6, floorLog2(sps.getMaxCUWidth())), "log2_min_luma_coding_block_size_minus2 shall be in the range of 0 to min (4, log2_ctu_size - 2)");
CHECK(m_uiMaxMTTHierarchyDepth > 2 * (floorLog2(sps.getCTUSize()) - sps.getLog2MinCodingBlockSize()), "sps_max_mtt_hierarchy_depth_inter_slice shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)");
CHECK(m_uiMaxMTTHierarchyDepthI > 2 * (floorLog2(sps.getCTUSize()) - sps.getLog2MinCodingBlockSize()), "sps_max_mtt_hierarchy_depth_intra_slice_luma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)");
CHECK(m_uiMaxMTTHierarchyDepthIChroma > 2 * (floorLog2(sps.getCTUSize()) - sps.getLog2MinCodingBlockSize()), "sps_max_mtt_hierarchy_depth_intra_slice_chroma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)");

Karsten Suehring
committed
sps.setTransformSkipEnabledFlag(m_useTransformSkip);
Shih-Ta Hsiang
committed
sps.setLog2MaxTransformSkipBlockSize(m_log2MaxTransformSkipBlockSize);
Alican Nalci
committed
sps.setBDPCMEnabledFlag(m_useBDPCM);

Karsten Suehring
committed
sps.setSPSTemporalMVPEnabledFlag((getTMVPModeId() == 2 || getTMVPModeId() == 1));
sps.setLog2MaxTbSize ( m_log2MaxTbSize );

Karsten Suehring
committed
for (uint32_t channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
{
sps.setBitDepth (ChannelType(channelType), m_bitDepth[channelType] );
sps.setQpBDOffset (ChannelType(channelType), (6 * (m_bitDepth[channelType] - 8)));
sps.setInternalMinusInputBitDepth(ChannelType(channelType), max(0, (m_bitDepth[channelType] - m_inputBitDepth[channelType])));

Karsten Suehring
committed
}
sps.setEntropyCodingSyncEnabledFlag( m_entropyCodingSyncEnabledFlag );
sps.setEntryPointsPresentFlag( m_entryPointPresentFlag );
sps.setUseWP( m_useWeightedPred );
sps.setUseWPBiPred( m_useWeightedBiPred );
sps.setSAOEnabledFlag( m_bUseSAO );
#if JVET_W0066_CCSAO
sps.setCCSAOEnabledFlag( m_CCSAO );
#endif
#if JVET_AG0158_ALF_LUMA_COEFF_PRECISION
sps.setAlfPrecisionFlag( m_alfPrecision );
#endif
#if JVET_AH0057_CCALF_COEFF_PRECISION
sps.setCCALFPrecisionFlag( m_ccalfPrecision );
#endif
#if JVET_AJ0188_CODING_INFO_CLASSIFICATION
sps.setAlfLumaFixedFilterAdjust( m_intraPeriod < 0 ? false : true );
sps.setJointCbCrEnabledFlag( m_JointCbCrMode );

Karsten Suehring
committed
sps.setMaxTLayers( m_maxTempLayer );
sps.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false );
for (int i = 0; i < std::min(sps.getMaxTLayers(), (uint32_t) MAX_TLAYER); i++ )

Karsten Suehring
committed
{
sps.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i);
sps.setNumReorderPics(m_numReorderPics[i], i);
}
sps.setScalingListFlag ( (m_useScalingListId == SCALING_LIST_OFF) ? 0 : 1 );
if (sps.getUseColorTrans() && sps.getScalingListFlag())
{
sps.setScalingMatrixForAlternativeColourSpaceDisabledFlag( m_disableScalingMatrixForAlternativeColourSpace );
}
else
{
sps.setScalingMatrixForAlternativeColourSpaceDisabledFlag( false );
}
if (sps.getScalingMatrixForAlternativeColourSpaceDisabledFlag())
{
sps.setScalingMatrixDesignatedColourSpaceFlag( m_scalingMatrixDesignatedColourSpace );
}
else
{
sps.setScalingMatrixDesignatedColourSpaceFlag( true );
}

Karsten Suehring
committed
sps.setVuiParametersPresentFlag(getVuiParametersPresentFlag());
#if JVET_Z0135_TEMP_CABAC_WIN_WEIGHT
sps.setTempCabacInitMode( m_tempCabacInitMode );
#endif
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
#if JVET_AI0084_ALF_RESIDUALS_SCALING
sps.setAlfScalePrevEnabled( true );
if ( getIntraPeriod() == 1 )
{
sps.setAlfScaleMode( 0 );
}
else if ( getIntraPeriod() < 0 )
{
if ( m_sourceWidth * m_sourceHeight < 1920 * 1080 )
{
sps.setAlfScaleMode( 2 );
sps.setAlfScalePrevEnabled( false );
}
else
{
sps.setAlfScaleMode( 3 );
}
}
else
{
sps.setAlfScaleMode( 1 );
}
#endif
if (sps.getVuiParametersPresentFlag())
{
VUI* pcVUI = sps.getVuiParameters();
pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag());
pcVUI->setAspectRatioConstantFlag(!getSampleAspectRatioInfoSEIEnabled());
pcVUI->setAspectRatioIdc(getAspectRatioIdc());
pcVUI->setSarWidth(getSarWidth());
pcVUI->setSarHeight(getSarHeight());
pcVUI->setColourDescriptionPresentFlag(getColourDescriptionPresentFlag());
pcVUI->setColourPrimaries(getColourPrimaries());
pcVUI->setTransferCharacteristics(getTransferCharacteristics());
pcVUI->setMatrixCoefficients(getMatrixCoefficients());
pcVUI->setProgressiveSourceFlag (getProgressiveSourceFlag());
pcVUI->setInterlacedSourceFlag (getInterlacedSourceFlag());
#if JVET_S0266_VUI_length
pcVUI->setNonPackedFlag (getNonPackedConstraintFlag());
pcVUI->setNonProjectedFlag (getNonProjectedConstraintFlag());
#endif
pcVUI->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag());
pcVUI->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField());
pcVUI->setChromaSampleLocTypeBottomField(getChromaSampleLocTypeBottomField());
pcVUI->setChromaSampleLocType(getChromaSampleLocType());
pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag());
pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag());
pcVUI->setVideoFullRangeFlag(getVideoFullRangeFlag());
}

Karsten Suehring
committed
sps.setNumLongTermRefPicSPS(NUM_LONG_TERM_REF_PIC_SPS);
CHECK(!(NUM_LONG_TERM_REF_PIC_SPS <= MAX_NUM_LONG_TERM_REF_PICS), "Unspecified error");
for (int k = 0; k < NUM_LONG_TERM_REF_PIC_SPS; k++)
{
sps.setLtRefPicPocLsbSps(k, 0);
sps.setUsedByCurrPicLtSPSFlag(k, 0);
}
int numQpTables = m_chromaQpMappingTableParams.getSameCQPTableForAllChromaFlag() ? 1 : (sps.getJointCbCrEnabledFlag() ? 3 : 2);
m_chromaQpMappingTableParams.setNumQpTables(numQpTables);
sps.setChromaQpMappingTableFromParams(m_chromaQpMappingTableParams, sps.getQpBDOffset(CHANNEL_TYPE_CHROMA));
Adarsh Krishnan Ramasubramonian
committed
sps.derivedChromaQPMappingTables();

Karsten Suehring
committed
#if U0132_TARGET_BITS_SATURATION
if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() || getCpbSaturationEnabled() )
#else
if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() )
#endif
{
xInitHrdParameters(sps);
}
if( getBufferingPeriodSEIEnabled() || getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() )
{
sps.setGeneralHrdParametersPresentFlag(true);

Karsten Suehring
committed
}
// Set up SPS range extension settings
sps.getSpsRangeExtension().setTransformSkipRotationEnabledFlag(m_transformSkipRotationEnabledFlag);
sps.getSpsRangeExtension().setTransformSkipContextEnabledFlag(m_transformSkipContextEnabledFlag);
sps.getSpsRangeExtension().setExtendedPrecisionProcessingFlag(m_extendedPrecisionProcessingFlag);
sps.getSpsRangeExtension().setIntraSmoothingDisabledFlag( m_intraSmoothingDisabledFlag );
sps.getSpsRangeExtension().setHighPrecisionOffsetsEnabledFlag(m_highPrecisionOffsetsEnabledFlag);
sps.getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag(m_persistentRiceAdaptationEnabledFlag);
sps.getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag(m_cabacBypassAlignmentEnabledFlag);
Kui Fan
committed
sps.setSubPicInfoPresentFlag(m_subPicInfoPresentFlag);
if (m_subPicInfoPresentFlag)
LI JINGYA
committed
{
sps.setNumSubPics(m_numSubPics);
#if JVET_S0071_SAME_SIZE_SUBPIC_LAYOUT
sps.setSubPicSameSizeFlag(m_subPicSameSizeFlag);
if (m_subPicSameSizeFlag)
{
#if JVET_AA0146_WRAP_AROUND_FIX
uint32_t numSubpicCols = (m_sourceWidth + m_CTUSize - 1) / m_CTUSize / m_subPicWidth[0];
#else
uint32_t numSubpicCols = (m_iSourceWidth + m_CTUSize - 1) / m_CTUSize / m_subPicWidth[0];
for (unsigned int i = 0; i < m_numSubPics; i++)
{
sps.setSubPicCtuTopLeftX(i, (i % numSubpicCols) * m_subPicWidth[0]);
sps.setSubPicCtuTopLeftY(i, (i / numSubpicCols) * m_subPicHeight[0]);
sps.setSubPicWidth(i, m_subPicWidth[0]);
sps.setSubPicHeight(i, m_subPicHeight[0]);
}
}
else
{
sps.setSubPicCtuTopLeftX(m_subPicCtuTopLeftX);
sps.setSubPicCtuTopLeftY(m_subPicCtuTopLeftY);
sps.setSubPicWidth(m_subPicWidth);
sps.setSubPicHeight(m_subPicHeight);
}
#else
sps.setSubPicCtuTopLeftX(m_subPicCtuTopLeftX);
sps.setSubPicCtuTopLeftY(m_subPicCtuTopLeftY);
sps.setSubPicWidth(m_subPicWidth);
sps.setSubPicHeight(m_subPicHeight);
sps.setSubPicTreatedAsPicFlag(m_subPicTreatedAsPicFlag);
sps.setLoopFilterAcrossSubpicEnabledFlag(m_loopFilterAcrossSubpicEnabledFlag);
sps.setSubPicIdLen(m_subPicIdLen);

Karsten Suehring
committed
sps.setSubPicIdMappingExplicitlySignalledFlag(m_subPicIdMappingExplicitlySignalledFlag);
if (m_subPicIdMappingExplicitlySignalledFlag)
{
sps.setSubPicIdMappingInSpsFlag(m_subPicIdMappingInSpsFlag);
if (m_subPicIdMappingInSpsFlag)
{
sps.setSubPicId(m_subPicId);
}
}
else //In that case, there is only one subpicture that contains the whole picture
{
sps.setNumSubPics(1);
sps.setSubPicCtuTopLeftX(0, 0);
sps.setSubPicCtuTopLeftY(0, 0);
#if JVET_AA0146_WRAP_AROUND_FIX
sps.setSubPicWidth(0, m_sourceWidth);
sps.setSubPicHeight(0, m_sourceHeight);
#else
sps.setSubPicWidth(0, m_iSourceWidth);
sps.setSubPicHeight(0, m_iSourceHeight);
sps.setSubPicTreatedAsPicFlag(0, 1);
sps.setLoopFilterAcrossSubpicEnabledFlag(0, 0);

Karsten Suehring
committed
sps.setSubPicIdMappingExplicitlySignalledFlag(false);
#if TCQ_8STATES
sps.setDepQuantEnabledFlag( m_DepQuantEnabledIdc ? true : false );
#else
FANGJUN PU
committed
sps.setDepQuantEnabledFlag( m_DepQuantEnabledFlag );
FANGJUN PU
committed
if (!sps.getDepQuantEnabledFlag())
{
sps.setSignDataHidingEnabledFlag( m_SignDataHidingEnabledFlag );
}
else
{
sps.setSignDataHidingEnabledFlag(false);
}
sps.setVirtualBoundariesEnabledFlag( m_virtualBoundariesEnabledFlag );
if( sps.getVirtualBoundariesEnabledFlag() )
sps.setVirtualBoundariesPresentFlag( m_virtualBoundariesPresentFlag );
CHECK( sps.getSubPicInfoPresentFlag() && sps.getVirtualBoundariesPresentFlag() != 1, "When subpicture signalling if present, the signalling of virtual boundaries, is present, shall be in the SPS" );
sps.setNumVerVirtualBoundaries ( m_numVerVirtualBoundaries );
sps.setNumHorVirtualBoundaries ( m_numHorVirtualBoundaries );
for( unsigned int i = 0; i < m_numVerVirtualBoundaries; i++ )
{
sps.setVirtualBoundariesPosX ( m_virtualBoundariesPosX[i], i );
}
for( unsigned int i = 0; i < m_numHorVirtualBoundaries; i++ )
{
sps.setVirtualBoundariesPosY ( m_virtualBoundariesPosY[i], i );
}
Vadim Seregin
committed
sps.setInterLayerPresentFlag( m_layerId > 0 && m_vps->getMaxLayers() > 1 && !m_vps->getAllIndependentLayersFlag() && !m_vps->getIndependentLayerFlag( m_vps->getGeneralLayerIdx( m_layerId ) ) );
CHECK( m_vps->getIndependentLayerFlag( m_vps->getGeneralLayerIdx( m_layerId ) ) && sps.getInterLayerPresentFlag(), " When vps_independent_layer_flag[GeneralLayerIdx[nuh_layer_id ]] is equal to 1, the value of inter_layer_ref_pics_present_flag shall be equal to 0." );
sps.setResChangeInClvsEnabledFlag(m_resChangeInClvsEnabled);
Zhipin Deng
committed
#if JVET_Q0114_ASPECT5_GCI_FLAG
sps.setRprEnabledFlag(m_rprEnabledFlag);
#else
sps.setRprEnabledFlag((m_resChangeInClvsEnabled) || sps.getInterLayerPresentFlag());
Zhipin Deng
committed
#endif
sps.setLog2ParallelMergeLevelMinus2( m_log2ParallelMergeLevelMinus2 );
CHECK(sps.getResChangeInClvsEnabledFlag() && sps.getVirtualBoundariesEnabledFlag(), "when the value of res_change_in_clvs_allowed_flag is equal to 1, the value of sps_virtual_boundaries_present_flag shall be equal to 0");

Karsten Suehring
committed
}
void EncLib::xInitHrdParameters(SPS &sps)
{
m_encHRD.initHRDParameters((EncCfg*) this);
GeneralHrdParams *generalHrdParams = sps.getGeneralHrdParameters();
*generalHrdParams = m_encHRD.getGeneralHrdParameters();
OlsHrdParams *spsOlsHrdParams = sps.getOlsHrdParameters();
for(int i = 0; i < MAX_TLAYER; i++)
{
*spsOlsHrdParams = m_encHRD.getOlsHrdParameters(i);
spsOlsHrdParams++;
}

Karsten Suehring
committed
}
void EncLib::xInitPPS(PPS &pps, const SPS &sps)
{
// pps ID already initialised.
pps.setSPSId(sps.getSPSId());
Kui Fan
committed
pps.setSubPicIdMappingInPpsFlag(false);
pps.setSubPicIdLen(sps.getSubPicIdLen());
for(int picIdx=0; picIdx<pps.getNumSubPics(); picIdx++)
{
pps.setSubPicId(picIdx, sps.getSubPicId(picIdx));
}
bool bUseDQP = (getCuQpDeltaSubdiv() > 0)? true : false;

Karsten Suehring
committed
if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP())
{
bUseDQP = true;
}
#if JVET_AB0171_ASYMMETRIC_DB_FOR_GDR
pps.setAsymmetricILF(getAsymmetricILF());
#endif

Karsten Suehring
committed
#if SHARP_LUMA_DELTA_QP
if ( getLumaLevelToDeltaQPMapping().isEnabled() )
{
bUseDQP = true;
}
#endif
#if ENABLE_QPA
if (getUsePerceptQPA() && !bUseDQP)
{
CHECK( m_cuQpDeltaSubdiv != 0, "max. delta-QP subdiv must be zero!" );
bUseDQP = (getBaseQP() < 38) && (getSourceWidth() > 512 || getSourceHeight() > 320);

Karsten Suehring
committed
}
#endif
#if JVET_Y0240_BIM
if (m_bimEnabled)
{
bUseDQP = true;
}
#endif

Karsten Suehring
committed
if (m_costMode==COST_SEQUENCE_LEVEL_LOSSLESS || m_costMode==COST_LOSSLESS_CODING)
{
bUseDQP=false;
}
if ( m_RCEnableRateControl )
{
pps.setUseDQP(true);
}
else if(bUseDQP)
{
pps.setUseDQP(true);
}
else
{
pps.setUseDQP(false);
}
if ( m_cuChromaQpOffsetSubdiv >= 0 )
{
pps.clearChromaQpOffsetList();
pps.setChromaQpOffsetListEntry(1, 6, 6, 6);

Karsten Suehring
committed
/* todo, insert table entries from command line (NB, 0 should not be touched) */
}
else
{
pps.clearChromaQpOffsetList();

Karsten Suehring
committed
}
{
int baseQp = 26;
if( 16 == getGOPSize() )
{
baseQp = getBaseQP()-24;
}
else
{
baseQp = getBaseQP()-26;
}
const int maxDQP = 37;

Karsten Suehring
committed
const int minDQP = -26 + sps.getQpBDOffset(CHANNEL_TYPE_LUMA);
pps.setPicInitQPMinus26( std::min( maxDQP, std::max( minDQP, baseQp ) ));
}
if( sps.getJointCbCrEnabledFlag() == false || getChromaFormatIdc() == CHROMA_400 || m_chromaCbCrQpOffset == 0 )
{
pps.setJointCbCrQpOffsetPresentFlag(false);
}
else
{
pps.setJointCbCrQpOffsetPresentFlag(true);
}

Karsten Suehring
committed
#if ER_CHROMA_QP_WCG_PPS
if (getWCGChromaQPControl().isEnabled())
{
const int baseQp=m_iQP+pps.getPPSId();
const double chromaQp = m_wcgChromaQpControl.chromaQpScale * baseQp + m_wcgChromaQpControl.chromaQpOffset;
const double dcbQP = m_wcgChromaQpControl.chromaCbQpScale * chromaQp;
const double dcrQP = m_wcgChromaQpControl.chromaCrQpScale * chromaQp;
const int cbQP =(int)(dcbQP + ( dcbQP < 0 ? -0.5 : 0.5) );
const int crQP =(int)(dcrQP + ( dcrQP < 0 ? -0.5 : 0.5) );
pps.setQpOffset(COMPONENT_Cb, Clip3( -12, 12, min(0, cbQP) + m_chromaCbQpOffset ));
pps.setQpOffset(COMPONENT_Cr, Clip3( -12, 12, min(0, crQP) + m_chromaCrQpOffset));
if(pps.getJointCbCrQpOffsetPresentFlag())
pps.setQpOffset(JOINT_CbCr, Clip3(-12, 12, (min(0, cbQP) + min(0, crQP)) / 2 + m_chromaCbCrQpOffset));
else
pps.setQpOffset(JOINT_CbCr, 0);

Karsten Suehring
committed
}
else
{
#endif
pps.setQpOffset(COMPONENT_Cb, m_chromaCbQpOffset );
pps.setQpOffset(COMPONENT_Cr, m_chromaCrQpOffset );
if (pps.getJointCbCrQpOffsetPresentFlag())
pps.setQpOffset(JOINT_CbCr, m_chromaCbCrQpOffset);
else
pps.setQpOffset(JOINT_CbCr, 0);

Karsten Suehring
committed
#if ER_CHROMA_QP_WCG_PPS
}
#endif
#if W0038_CQP_ADJ
bool bChromaDeltaQPEnabled = false;
{
bChromaDeltaQPEnabled = ( m_sliceChromaQpOffsetIntraOrPeriodic[0] || m_sliceChromaQpOffsetIntraOrPeriodic[1] );
if( !bChromaDeltaQPEnabled )
{
for( int i=0; i<m_iGOPSize; i++ )
{
if( m_GOPList[i].m_CbQPoffset || m_GOPList[i].m_CrQPoffset )
{
bChromaDeltaQPEnabled = true;
break;
}
}
}
}
#if ENABLE_QPA
if ((getUsePerceptQPA() || getSliceChromaOffsetQpPeriodicity() > 0) && (getChromaFormatIdc() != CHROMA_400))
{
bChromaDeltaQPEnabled = true;
}
#endif

Karsten Suehring
committed
pps.setSliceChromaQpFlag(bChromaDeltaQPEnabled);
#endif
!pps.getSliceChromaQpFlag() && sps.getUseDualITree()
&& (getChromaFormatIdc() != CHROMA_400))

Karsten Suehring
committed
{
pps.setSliceChromaQpFlag(m_chromaCbQpOffsetDualTree != 0 || m_chromaCrQpOffsetDualTree != 0 || m_chromaCbCrQpOffsetDualTree != 0);

Karsten Suehring
committed
}
#if JVET_AG0116
if (m_rprFunctionalityTestingEnabledFlag || m_gopBasedRPREnabledFlag)
#else
if (m_rprFunctionalityTestingEnabledFlag)
{
if (pps.getPPSId() == ENC_PPS_ID_RPR || pps.getPPSId() == ENC_PPS_ID_RPR2 || pps.getPPSId() == ENC_PPS_ID_RPR3)
{
pps.setSliceChromaQpFlag(true);
}
}
#endif

Karsten Suehring
committed
int minCbSizeY = (1 << sps.getLog2MinCodingBlockSize());
pps.setWrapAroundEnabledFlag ( m_wrapAround );
if( m_wrapAround )
{
pps.setPicWidthMinusWrapAroundOffset ((pps.getPicWidthInLumaSamples()/minCbSizeY) - (m_wrapAroundOffset / minCbSizeY));
pps.setWrapAroundOffset (minCbSizeY *(pps.getPicWidthInLumaSamples() / minCbSizeY- pps.getPicWidthMinusWrapAroundOffset()));
pps.setPicWidthMinusWrapAroundOffset ( 0 );
pps.setWrapAroundOffset ( 0 );
}
CHECK( !sps.getWrapAroundEnabledFlag() && pps.getWrapAroundEnabledFlag(), "When sps_ref_wraparound_enabled_flag is equal to 0, the value of pps_ref_wraparound_enabled_flag shall be equal to 0.");
CHECK( (((sps.getCTUSize() / minCbSizeY) + 1) > ((pps.getPicWidthInLumaSamples() / minCbSizeY) - 1)) && pps.getWrapAroundEnabledFlag(), "When the value of CtbSizeY / MinCbSizeY + 1 is greater than pic_width_in_luma_samples / MinCbSizeY - 1, the value of pps_ref_wraparound_enabled_flag shall be equal to 0.");
pps.setNoPicPartitionFlag( m_noPicPartitionFlag );
if( m_noPicPartitionFlag == false )
{
pps.setLog2CtuSize( ceilLog2( sps.getCTUSize()) );
pps.setNumExpTileColumns( (uint32_t) m_tileColumnWidth.size() );
pps.setNumExpTileRows( (uint32_t) m_tileRowHeight.size() );
pps.setTileColumnWidths( m_tileColumnWidth );
pps.setTileRowHeights( m_tileRowHeight );
pps.initTiles();
pps.setRectSliceFlag( m_rectSliceFlag );

Karsten Suehring
committed
pps.setSingleSlicePerSubPicFlag(m_singleSlicePerSubPicFlag);
pps.setNumSlicesInPic( m_numSlicesInPic );
pps.setTileIdxDeltaPresentFlag( m_tileIdxDeltaPresentFlag );
pps.setRectSlices( m_rectSlices );

Karsten Suehring
committed
pps.initRectSliceMap(&sps);
}
else
{
pps.initRasterSliceMap( m_rasterSliceSize );
}
pps.setLoopFilterAcrossTilesEnabledFlag( m_bLFCrossTileBoundaryFlag );
pps.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag );
}
else
{
pps.setLog2CtuSize( ceilLog2( sps.getCTUSize()) );
pps.setNumExpTileColumns(1);
pps.setNumExpTileRows(1);
pps.addTileColumnWidth( pps.getPicWidthInCtu( ) );
pps.addTileRowHeight( pps.getPicHeightInCtu( ) );
pps.initTiles();
pps.setRectSliceFlag( 1 );
pps.setNumSlicesInPic( 1 );
pps.initRectSlices( );
pps.setTileIdxDeltaPresentFlag( 0 );
pps.setSliceTileIdx( 0, 0 );

Karsten Suehring
committed
pps.initRectSliceMap( &sps );
pps.setLoopFilterAcrossTilesEnabledFlag( true );
pps.setLoopFilterAcrossSlicesEnabledFlag( true );
}

Karsten Suehring
committed
pps.setUseWP( m_useWeightedPred );
pps.setWPBiPred( m_useWeightedBiPred );
pps.setOutputFlagPresentFlag( false );
#if JVET_AC0189_SGPM_NO_BLENDING
pps.setUseSgpmNoBlend ( m_sgpmNoBlend );
#endif
pps.setUseBIF ( m_BIF );
pps.setBIFStrength ( m_BIFStrength );
pps.setBIFQPOffset ( m_BIFQPOffset );
#endif
#if JVET_X0071_CHROMA_BILATERAL_FILTER
pps.setUseChromaBIF ( m_chromaBIF );
pps.setChromaBIFStrength ( m_chromaBIFStrength );
pps.setChromaBIFQPOffset ( m_chromaBIFQPOffset );
#endif

Karsten Suehring
committed
if ( getDeblockingFilterMetric() )
{
pps.setDeblockingFilterOverrideEnabledFlag(true);
pps.setPPSDeblockingFilterDisabledFlag(false);
}
else
{
pps.setDeblockingFilterOverrideEnabledFlag( !getLoopFilterOffsetInPPS() );
pps.setPPSDeblockingFilterDisabledFlag( getLoopFilterDisable() );
}
if (! pps.getPPSDeblockingFilterDisabledFlag())
{
pps.setDeblockingFilterBetaOffsetDiv2( getLoopFilterBetaOffset() );
pps.setDeblockingFilterTcOffsetDiv2( getLoopFilterTcOffset() );
pps.setDeblockingFilterCbBetaOffsetDiv2( getLoopFilterCbBetaOffset() );
pps.setDeblockingFilterCbTcOffsetDiv2( getLoopFilterCbTcOffset() );
pps.setDeblockingFilterCrBetaOffsetDiv2( getLoopFilterCrBetaOffset() );
pps.setDeblockingFilterCrTcOffsetDiv2( getLoopFilterCrTcOffset() );

Karsten Suehring
committed
}
else
{
#if DB_PARAM_TID
pps.setDeblockingFilterBetaOffsetDiv2(std::vector<int>(5,0));
pps.setDeblockingFilterTcOffsetDiv2(std::vector<int>(5, 0));
#else

Karsten Suehring
committed
pps.setDeblockingFilterBetaOffsetDiv2(0);
pps.setDeblockingFilterTcOffsetDiv2(0);
pps.setDeblockingFilterCbBetaOffsetDiv2(0);
pps.setDeblockingFilterCbTcOffsetDiv2(0);
pps.setDeblockingFilterCrBetaOffsetDiv2(0);
pps.setDeblockingFilterCrTcOffsetDiv2(0);

Karsten Suehring
committed
}
// deblockingFilterControlPresentFlag is true if any of the settings differ from the inferred values:
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
#if DB_PARAM_TID
bool TcAllZero = true, BetaAllZero = true;
for (int i = 0; i < pps.getDeblockingFilterBetaOffsetDiv2().size(); i++)
{
if (pps.getDeblockingFilterBetaOffsetDiv2()[i] != 0)
{
BetaAllZero = false;
break;
}
}
for (int i = 0; i < pps.getDeblockingFilterTcOffsetDiv2().size(); i++)
{
if (pps.getDeblockingFilterTcOffsetDiv2()[i] != 0)
{
TcAllZero = false;
break;
}
}
const bool deblockingFilterControlPresentFlag = pps.getDeblockingFilterOverrideEnabledFlag() ||
pps.getPPSDeblockingFilterDisabledFlag() ||
BetaAllZero == false ||
TcAllZero == false ||
pps.getDeblockingFilterCbBetaOffsetDiv2() != 0 ||
pps.getDeblockingFilterCbTcOffsetDiv2() != 0 ||
pps.getDeblockingFilterCrBetaOffsetDiv2() != 0 ||
pps.getDeblockingFilterCrTcOffsetDiv2() != 0;
#else
const bool deblockingFilterControlPresentFlag = pps.getDeblockingFilterOverrideEnabledFlag() ||
pps.getPPSDeblockingFilterDisabledFlag() ||
pps.getDeblockingFilterBetaOffsetDiv2() != 0 ||
pps.getDeblockingFilterTcOffsetDiv2() != 0 ||
pps.getDeblockingFilterCbBetaOffsetDiv2() != 0 ||
pps.getDeblockingFilterCbTcOffsetDiv2() != 0 ||
pps.getDeblockingFilterCrBetaOffsetDiv2() != 0 ||
pps.getDeblockingFilterCrTcOffsetDiv2() != 0;

Karsten Suehring
committed
pps.setDeblockingFilterControlPresentFlag(deblockingFilterControlPresentFlag);
pps.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
pps.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag );
bool chromaQPOffsetNotZero = false;
if( pps.getQpOffset(COMPONENT_Cb) != 0 || pps.getQpOffset(COMPONENT_Cr) != 0 || pps.getJointCbCrQpOffsetPresentFlag() || pps.getSliceChromaQpFlag() || pps.getCuChromaQpOffsetListEnabledFlag() )
{
chromaQPOffsetNotZero = true;
bool chromaDbfOffsetNotSameAsLuma = true;
if( pps.getDeblockingFilterCbBetaOffsetDiv2() == pps.getDeblockingFilterBetaOffsetDiv2() && pps.getDeblockingFilterCrBetaOffsetDiv2() == pps.getDeblockingFilterBetaOffsetDiv2()
&& pps.getDeblockingFilterCbTcOffsetDiv2() == pps.getDeblockingFilterTcOffsetDiv2() && pps.getDeblockingFilterCrTcOffsetDiv2() == pps.getDeblockingFilterTcOffsetDiv2() )
{
chromaDbfOffsetNotSameAsLuma = false;
const uint32_t chromaArrayType = (int)sps.getSeparateColourPlaneFlag() ? 0 : sps.getChromaFormatIdc();
if( ( chromaArrayType != CHROMA_400 ) && ( chromaQPOffsetNotZero || chromaDbfOffsetNotSameAsLuma ) )
if ((sps.getChromaFormatIdc() != CHROMA_400) && (chromaQPOffsetNotZero || chromaDbfOffsetNotSameAsLuma))
#endif
{
pps.setPPSChromaToolFlag(true);
}
else
{
pps.setPPSChromaToolFlag(false);
}

Karsten Suehring
committed
int histogram[MAX_NUM_REF + 1];
for( int i = 0; i <= MAX_NUM_REF; i++ )
{
histogram[i]=0;
}
for( int i = 0; i < getGOPSize(); i++)
{
CHECK(!(getRPLEntry(0, i).m_numRefPicsActive >= 0 && getRPLEntry(0, i).m_numRefPicsActive <= MAX_NUM_REF), "Unspecified error");
histogram[getRPLEntry(0, i).m_numRefPicsActive]++;

Karsten Suehring
committed
}
int maxHist=-1;
int bestPos=0;
for( int i = 0; i <= MAX_NUM_REF; i++ )
{
if(histogram[i]>maxHist)
{
maxHist=histogram[i];
bestPos=i;
}
}
CHECK(!(bestPos <= 15), "Unspecified error");
pps.setNumRefIdxL0DefaultActive(bestPos);

Karsten Suehring
committed
pps.setNumRefIdxL1DefaultActive(bestPos);
pps.setPictureHeaderExtensionPresentFlag(false);
Sheng-Yen Lin
committed
pps.setRplInfoInPhFlag(getSliceLevelRpl() ? false : true);
pps.setDbfInfoInPhFlag(getSliceLevelDblk() ? false : true);
pps.setSaoInfoInPhFlag(getSliceLevelSao() ? false : true);
pps.setAlfInfoInPhFlag(getSliceLevelAlf() ? false : true);
pps.setWpInfoInPhFlag(getSliceLevelWp() ? false : true);
pps.setQpDeltaInfoInPhFlag(getSliceLevelDeltaQp() ? false : true);

Karsten Suehring
committed
pps.pcv = new PreCalcValues( sps, pps, true );
pps.setRpl1IdxPresentFlag(sps.getRPL1IdxPresentFlag());

Karsten Suehring
committed
}
void EncLib::xInitPicHeader(PicHeader &picHeader, const SPS &sps, const PPS &pps)
{
int i;
picHeader.initPicHeader();
// parameter sets
picHeader.setSPSId( sps.getSPSId() );
picHeader.setPPSId( pps.getPPSId() );
picHeader.setMaxNumAffineMergeCand(getMaxNumAffineMergeCand());
#if JVET_AG0276_LIC_FLAG_SIGNALING
picHeader.setMaxNumAffineOppositeLicMergeCand( getMaxNumAffineOppositeLicMergeCand() );
#endif
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
// copy partitioning constraints from SPS
picHeader.setSplitConsOverrideFlag(false);
picHeader.setMinQTSizes( sps.getMinQTSizes() );
picHeader.setMaxMTTHierarchyDepths( sps.getMaxMTTHierarchyDepths() );
picHeader.setMaxBTSizes( sps.getMaxBTSizes() );
picHeader.setMaxTTSizes( sps.getMaxTTSizes() );
bool bUseDQP = (getCuQpDeltaSubdiv() > 0)? true : false;
if( (getMaxDeltaQP() != 0 )|| getUseAdaptiveQP() )
{
bUseDQP = true;
}
#if SHARP_LUMA_DELTA_QP
if( getLumaLevelToDeltaQPMapping().isEnabled() )
{
bUseDQP = true;
}
#endif
#if ENABLE_QPA
if( getUsePerceptQPA() && !bUseDQP )
{
CHECK( m_cuQpDeltaSubdiv != 0, "max. delta-QP subdiv must be zero!" );
bUseDQP = (getBaseQP() < 38) && (getSourceWidth() > 512 || getSourceHeight() > 320);
}
#endif
if( m_costMode==COST_SEQUENCE_LEVEL_LOSSLESS || m_costMode==COST_LOSSLESS_CODING )
{
bUseDQP=false;
}
if( m_RCEnableRateControl )
{
picHeader.setCuQpDeltaSubdivIntra( 0 );
picHeader.setCuQpDeltaSubdivInter( 0 );
}
else if( bUseDQP )
{
picHeader.setCuQpDeltaSubdivIntra( m_cuQpDeltaSubdiv );
picHeader.setCuQpDeltaSubdivInter( m_cuQpDeltaSubdiv );
}
else
{
picHeader.setCuQpDeltaSubdivIntra( 0 );
picHeader.setCuQpDeltaSubdivInter( 0 );
}
if( m_cuChromaQpOffsetSubdiv >= 0 )
{
picHeader.setCuChromaQpOffsetSubdivIntra(m_cuChromaQpOffsetSubdiv);
picHeader.setCuChromaQpOffsetSubdivInter(m_cuChromaQpOffsetSubdiv);
}
else
{
picHeader.setCuChromaQpOffsetSubdivIntra(0);
picHeader.setCuChromaQpOffsetSubdivInter(0);
}
if( sps.getVirtualBoundariesEnabledFlag() )
{
picHeader.setVirtualBoundariesPresentFlag( sps.getVirtualBoundariesPresentFlag() );
picHeader.setNumVerVirtualBoundaries(sps.getNumVerVirtualBoundaries());
picHeader.setNumHorVirtualBoundaries(sps.getNumHorVirtualBoundaries());
for(i=0; i<3; i++) {
picHeader.setVirtualBoundariesPosX(sps.getVirtualBoundariesPosX(i), i);
picHeader.setVirtualBoundariesPosY(sps.getVirtualBoundariesPosY(i), i);
}
picHeader.setGdrOrIrapPicFlag(false);
#endif
// gradual decoder refresh flag
picHeader.setGdrPicFlag(false);

Xuewei Meng
committed
picHeader.setDisBdofFlag(false);
picHeader.setDisDmvrFlag(false);
picHeader.setDisProfFlag(false);