Newer
Older
cinfo->setNoGbiConstraintFlag(m_bNoGbiConstraintFlag);
cinfo->setNoIbcConstraintFlag(m_noIbcConstraintFlag);
cinfo->setNoMhIntraConstraintFlag(m_bNoMhIntraConstraintFlag);
cinfo->setNoFPelMmvdConstraintFlag(m_noFPelMmvdConstraintFlag);
cinfo->setNoTriangleConstraintFlag(m_bNoTriangleConstraintFlag);
cinfo->setNoLadfConstraintFlag(m_bNoLadfConstraintFlag);
cinfo->setNoTransformSkipConstraintFlag(m_noTransformSkipConstraintFlag);
#if JVET_O1136_TS_BDPCM_SIGNALLING
cinfo->setNoBDPCMConstraintFlag(m_noBDPCMConstraintFlag);
#endif
#if JVET_O0376_SPS_JOINTCBCR_FLAG
cinfo->setNoJointCbCrConstraintFlag(m_noJointCbCrConstraintFlag);
#endif
cinfo->setNoQpDeltaConstraintFlag(m_bNoQpDeltaConstraintFlag);
cinfo->setNoDepQuantConstraintFlag(m_bNoDepQuantConstraintFlag);
cinfo->setNoSignDataHidingConstraintFlag(m_bNoSignDataHidingConstraintFlag);

Karsten Suehring
committed
profileTierLevel->setLevelIdc (m_level);
profileTierLevel->setTierFlag (m_levelTier);
profileTierLevel->setProfileIdc (m_profile);
profileTierLevel->setSubProfileIdc (m_subProfile);

Karsten Suehring
committed
/* XXX: should Main be marked as compatible with still picture? */
/* XXX: may be a good idea to refactor the above into a function
* that chooses the actual compatibility based upon options */
#if JVET_O1164_PS
sps.setMaxPicWidthInLumaSamples( m_iSourceWidth );
sps.setMaxPicHeightInLumaSamples( m_iSourceHeight );
#else

Karsten Suehring
committed
sps.setPicWidthInLumaSamples ( m_iSourceWidth );
sps.setPicHeightInLumaSamples ( m_iSourceHeight );
sps.setConformanceWindow ( m_conformanceWindow );
#endif

Karsten Suehring
committed
sps.setMaxCUWidth ( m_maxCUWidth );
sps.setMaxCUHeight ( m_maxCUHeight );
sps.setMaxCodingDepth ( m_maxTotalCUDepth );
sps.setChromaFormatIdc ( m_chromaFormatIDC );
sps.setLog2DiffMaxMinCodingBlockSize(m_log2DiffMaxMinCodingBlockSize);
sps.setCTUSize ( m_CTUSize );
sps.setSplitConsOverrideEnabledFlag ( m_useSplitConsOverride );
sps.setMinQTSizes ( m_uiMinQT );
sps.setMaxBTDepth ( m_uiMaxBTDepth, m_uiMaxBTDepthI, m_uiMaxBTDepthIChroma );
unsigned maxBtSize[3], maxTtSize[3];
memcpy(maxBtSize, m_uiMinQT, sizeof(maxBtSize));
memcpy(maxTtSize, m_uiMinQT, sizeof(maxTtSize));
if (m_uiMaxBTDepth)
{
maxBtSize[1] = std::min(m_CTUSize, (unsigned)MAX_BT_SIZE_INTER);
maxTtSize[1] = std::min(m_CTUSize, (unsigned)MAX_TT_SIZE_INTER);
}
if (m_uiMaxBTDepthI)
{
maxBtSize[0] = std::min(m_CTUSize, (unsigned)MAX_BT_SIZE);
maxTtSize[0] = std::min(m_CTUSize, (unsigned)MAX_TT_SIZE);
}
if (m_uiMaxBTDepthIChroma)
{
maxBtSize[2] = std::min(m_CTUSize, (unsigned)MAX_BT_SIZE_C);
maxTtSize[2] = std::min(m_CTUSize, (unsigned)MAX_TT_SIZE_C);
}
sps.setMaxBTSize ( maxBtSize[1], maxBtSize[0], maxBtSize[2] );
sps.setMaxTTSize ( maxTtSize[1], maxTtSize[0], maxTtSize[2] );
sps.setIDRRefParamListPresent ( m_idrRefParamList );
sps.setUseDualITree ( m_dualITree );
sps.setUseLFNST ( m_LFNST );
sps.setSBTMVPEnabledFlag ( m_SubPuMvpMode );
sps.setAMVREnabledFlag ( m_ImvMode != IMV_OFF );
sps.setBDOFEnabledFlag ( m_BIO );
sps.setUseAffine ( m_Affine );
sps.setUseAffineType ( m_AffineType );
#if JVET_O0070_PROF
sps.setUsePROF ( m_PROF );
#endif
sps.setUseLMChroma ( m_LMChroma ? true : false );
sps.setCclmCollocatedChromaFlag( m_cclmCollocatedChromaFlag );
sps.setUseMTS ( m_IntraMTS || m_InterMTS || m_ImplicitMTS );
sps.setUseIntraMTS ( m_IntraMTS );
sps.setUseInterMTS ( m_InterMTS );
Yin Zhao
committed
sps.setUseSBT ( m_SBT );
if( sps.getUseSBT() )
#if JVET_O0545_MAX_TB_SIGNALLING
sps.setMaxSbtSize ( std::min((int)(1 << m_log2MaxTbSize), m_iSourceWidth >= 1920 ? 64 : 32) );
#else
Yin Zhao
committed
sps.setMaxSbtSize ( m_iSourceWidth >= 1920 ? 64 : 32 );
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
sps.setUseMHIntra ( m_MHIntra );
sps.setUseTriangle ( m_Triangle );
sps.setFpelMmvdEnabledFlag (( m_MMVD ) ? m_allowDisFracMMVD : false);
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
sps.setBdofDmvrSlicePresentFlag(m_DMVR || m_BIO);
#endif
sps.setAffineAmvrEnabledFlag ( m_AffineAmvr );
Yung-Hsuan Chao (Jessie)
committed
#if JVET_O0119_BASE_PALETTE_444
sps.setPLTMode ( m_PLTMode);
Yung-Hsuan Chao (Jessie)
committed
#endif
sps.setWrapAroundEnabledFlag ( m_wrapAround );
sps.setWrapAroundOffset ( m_wrapAroundOffset );

Karsten Suehring
committed
// ADD_NEW_TOOL : (encoder lib) set tool enabling flags and associated parameters here
sps.setUseISP ( m_ISP );
sps.setUseMIP ( m_MIP );
int minCUSize = sps.getMaxCUWidth() >> sps.getLog2DiffMaxMinCodingBlockSize();

Karsten Suehring
committed
int log2MinCUSize = 0;
while(minCUSize > 1)
{
minCUSize >>= 1;
log2MinCUSize++;
}
sps.setLog2MinCodingBlockSize(log2MinCUSize);

Karsten Suehring
committed
sps.setPCMLog2MinSize (m_uiPCMLog2MinSize);
sps.setPCMEnabledFlag ( m_usePCM );

Karsten Suehring
committed
sps.setPCMLog2MaxSize( m_pcmLog2MaxSize );

Karsten Suehring
committed
#if JVET_O1136_TS_BDPCM_SIGNALLING
sps.setTransformSkipEnabledFlag(m_useTransformSkip);
sps.setBDPCMEnabledFlag(m_useBDPCM);
#endif

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

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.setMinQpPrimeTsMinus4(ChannelType(channelType), (6 * (m_bitDepth[channelType] - m_inputBitDepth[channelType])));

Karsten Suehring
committed
sps.setPCMBitDepth (ChannelType(channelType), m_PCMBitDepth[channelType] );

Karsten Suehring
committed
}
#if JVET_O0244_DELTA_POC
sps.setUseWP( m_useWeightedPred );
sps.setUseWPBiPred( m_useWeightedBiPred );
#endif
sps.setSAOEnabledFlag( m_bUseSAO );
#if JVET_O0376_SPS_JOINTCBCR_FLAG
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);
}

Karsten Suehring
committed
sps.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag );

Karsten Suehring
committed
sps.setScalingListFlag ( (m_useScalingListId == SCALING_LIST_OFF) ? 0 : 1 );

Karsten Suehring
committed
sps.setVuiParametersPresentFlag(getVuiParametersPresentFlag());
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
if (sps.getVuiParametersPresentFlag())
{
VUI* pcVUI = sps.getVuiParameters();
pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag());
pcVUI->setAspectRatioIdc(getAspectRatioIdc());
pcVUI->setSarWidth(getSarWidth());
pcVUI->setSarHeight(getSarHeight());
pcVUI->setColourDescriptionPresentFlag(getColourDescriptionPresentFlag());
pcVUI->setColourPrimaries(getColourPrimaries());
pcVUI->setTransferCharacteristics(getTransferCharacteristics());
pcVUI->setMatrixCoefficients(getMatrixCoefficients());
pcVUI->setFieldSeqFlag(false);
pcVUI->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag());
pcVUI->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField());
pcVUI->setChromaSampleLocTypeBottomField(getChromaSampleLocTypeBottomField());
pcVUI->setChromaSampleLocType(getChromaSampleLocType());
pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag());
pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag());
pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag());
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);
}
Adarsh Krishnan Ramasubramonian
committed
#if JVET_O0650_SIGNAL_CHROMAQP_MAPPING_TABLE
sps.setChromaQpMappingTableFromParams(m_chromaQpMappingTableParams, sps.getQpBDOffset(CHANNEL_TYPE_CHROMA));
Adarsh Krishnan Ramasubramonian
committed
sps.derivedChromaQPMappingTables();
#endif

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

Karsten Suehring
committed
}
// Set up SPS range extension settings
sps.getSpsRangeExtension().setTransformSkipRotationEnabledFlag(m_transformSkipRotationEnabledFlag);
sps.getSpsRangeExtension().setTransformSkipContextEnabledFlag(m_transformSkipContextEnabledFlag);
for (uint32_t signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++)
{
sps.getSpsRangeExtension().setRdpcmEnabledFlag(RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]);
}
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);
if (m_uiIntraPeriod < 0)
sps.setRPL1CopyFromRPL0Flag(true);

Karsten Suehring
committed
}
void EncLib::xInitHrdParameters(SPS &sps)
{
m_encHRD.initHRDParameters((EncCfg*) this);
HRDParameters *hrdParams = sps.getHrdParameters();
*hrdParams = m_encHRD.getHRDParameters();
TimingInfo *timingInfo = sps.getTimingInfo();
*timingInfo = m_encHRD.getTimingInfo();

Karsten Suehring
committed
}
void EncLib::xInitPPS(PPS &pps, const SPS &sps)
{
// pps ID already initialised.
pps.setSPSId(sps.getSPSId());
pps.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
bool bUseDQP = (getCuQpDeltaSubdiv() > 0)? true : false;

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

Karsten Suehring
committed
}
#endif
if (m_costMode==COST_SEQUENCE_LEVEL_LOSSLESS || m_costMode==COST_LOSSLESS_CODING)
{
bUseDQP=false;
}
if ( m_RCEnableRateControl )
{
pps.setUseDQP(true);
pps.setCuQpDeltaSubdiv( 0 );

Karsten Suehring
committed
}
else if(bUseDQP)
{
pps.setUseDQP(true);
pps.setCuQpDeltaSubdiv( m_cuQpDeltaSubdiv );

Karsten Suehring
committed
}
else
{
pps.setUseDQP(false);
pps.setCuQpDeltaSubdiv( 0 );

Karsten Suehring
committed
}
if ( m_cuChromaQpOffsetSubdiv >= 0 )
{
pps.getPpsRangeExtension().setCuChromaQpOffsetSubdiv(m_cuChromaQpOffsetSubdiv);

Karsten Suehring
committed
pps.getPpsRangeExtension().clearChromaQpOffsetList();
#if JVET_O1168_CU_CHROMA_QP_OFFSET
pps.getPpsRangeExtension().setChromaQpOffsetListEntry(1, 6, 6, 6);
#else

Karsten Suehring
committed
pps.getPpsRangeExtension().setChromaQpOffsetListEntry(1, 6, 6);

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

Karsten Suehring
committed
pps.getPpsRangeExtension().clearChromaQpOffsetList();
}
pps.getPpsRangeExtension().setCrossComponentPredictionEnabledFlag(m_crossComponentPredictionEnabledFlag);
pps.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA ]);
pps.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA]);
{
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 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));
pps.setQpOffset(JOINT_CbCr, Clip3( -12, 12, ( min(0, cbQP) + min(0, crQP) ) / 2 + m_chromaCbCrQpOffset));

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

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
}
pps.setEntropyCodingSyncEnabledFlag( m_entropyCodingSyncEnabledFlag );
pps.setSingleTileInPicFlag((m_iNumColumnsMinus1 == 0 && m_iNumRowsMinus1 == 0));

Karsten Suehring
committed
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
pps.setUseWP( m_useWeightedPred );
pps.setWPBiPred( m_useWeightedBiPred );
pps.setOutputFlagPresentFlag( false );
if ( getDeblockingFilterMetric() )
{
pps.setDeblockingFilterOverrideEnabledFlag(true);
pps.setPPSDeblockingFilterDisabledFlag(false);
}
else
{
pps.setDeblockingFilterOverrideEnabledFlag( !getLoopFilterOffsetInPPS() );
pps.setPPSDeblockingFilterDisabledFlag( getLoopFilterDisable() );
}
if (! pps.getPPSDeblockingFilterDisabledFlag())
{
pps.setDeblockingFilterBetaOffsetDiv2( getLoopFilterBetaOffset() );
pps.setDeblockingFilterTcOffsetDiv2( getLoopFilterTcOffset() );
}
else
{
pps.setDeblockingFilterBetaOffsetDiv2(0);
pps.setDeblockingFilterTcOffsetDiv2(0);
}
// deblockingFilterControlPresentFlag is true if any of the settings differ from the inferred values:
const bool deblockingFilterControlPresentFlag = pps.getDeblockingFilterOverrideEnabledFlag() ||
pps.getPPSDeblockingFilterDisabledFlag() ||
pps.getDeblockingFilterBetaOffsetDiv2() != 0 ||
pps.getDeblockingFilterTcOffsetDiv2() != 0;
pps.setDeblockingFilterControlPresentFlag(deblockingFilterControlPresentFlag);
pps.setLog2ParallelMergeLevelMinus2 (m_log2ParallelMergeLevelMinus2 );
pps.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
pps.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag );
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.setTransquantBypassEnabledFlag(getTransquantBypassEnabledFlag());
#if !JVET_O1136_TS_BDPCM_SIGNALLING

Karsten Suehring
committed
pps.setUseTransformSkip( m_useTransformSkip );
#endif

Karsten Suehring
committed
pps.getPpsRangeExtension().setLog2MaxTransformSkipBlockSize( m_log2MaxTransformSkipBlockSize );
xInitPPSforTiles(pps);
Sheng-Yen Lin
committed
pps.setLoopFilterAcrossVirtualBoundariesDisabledFlag( m_loopFilterAcrossVirtualBoundariesDisabledFlag );
pps.setNumVerVirtualBoundaries ( m_numVerVirtualBoundaries );
pps.setNumHorVirtualBoundaries ( m_numHorVirtualBoundaries );
for( unsigned int i = 0; i < m_numVerVirtualBoundaries; i++ )
{
pps.setVirtualBoundariesPosX ( m_virtualBoundariesPosX[i], i );
}
for( unsigned int i = 0; i < m_numHorVirtualBoundaries; i++ )
{
pps.setVirtualBoundariesPosY ( m_virtualBoundariesPosY[i], i );
}

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

Karsten Suehring
committed
}
void EncLib::xInitAPS(APS &aps)
{
//Do nothing now
}
void EncLib::xInitRPL(SPS &sps, bool isFieldCoding)
{
ReferencePictureList* rpl;
int numRPLCandidates = getRPLCandidateSize(0);
sps.createRPLList0(numRPLCandidates);
sps.createRPLList1(numRPLCandidates);
RPLList* rplList = 0;
for (int i = 0; i < 2; i++)
{
rplList = (i == 0) ? sps.getRPLList0() : sps.getRPLList1();
for (int j = 0; j < numRPLCandidates; j++)
{
const RPLEntry &ge = getRPLEntry(i, j);
rpl = rplList->getReferencePictureList(j);
rpl->setNumberOfShorttermPictures(ge.m_numRefPics);
rpl->setNumberOfLongtermPictures(0); //Hardcoded as 0 for now. need to update this when implementing LTRP
rpl->setNumberOfActivePictures(ge.m_numRefPicsActive);
for (int k = 0; k < ge.m_numRefPics; k++)
{
rpl->setRefPicIdentifier(k, ge.m_deltaRefPics[k], 0);
}
}
}
//Check if all delta POC of STRP in each RPL has the same sign
//Check RPLL0 first
const RPLList* rplList0 = sps.getRPLList0();
const RPLList* rplList1 = sps.getRPLList1();
uint32_t numberOfRPL = sps.getNumRPL0();
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
bool isAllEntriesinRPLHasSameSignFlag = true;
bool isFirstEntry = true;
bool lastSign = true; //true = positive ; false = negative
for (uint32_t ii = 0; isAllEntriesinRPLHasSameSignFlag && ii < numberOfRPL; ii++)
{
const ReferencePictureList* rpl = rplList0->getReferencePictureList(ii);
for (uint32_t jj = 0; isAllEntriesinRPLHasSameSignFlag && jj < rpl->getNumberOfActivePictures(); jj++)
{
if (!rpl->isRefPicLongterm(jj) && isFirstEntry)
{
lastSign = (rpl->getRefPicIdentifier(jj) >= 0) ? true : false;
isFirstEntry = false;
}
else if (!rpl->isRefPicLongterm(jj) && (((rpl->getRefPicIdentifier(jj) - rpl->getRefPicIdentifier(jj - 1)) >= 0 && lastSign == false) || ((rpl->getRefPicIdentifier(jj) - rpl->getRefPicIdentifier(jj - 1)) < 0 && lastSign == true)))
{
isAllEntriesinRPLHasSameSignFlag = false;
}
}
}
//Check RPLL1. Skip it if it is already found out that this flag is not true for RPL0 or if RPL1 is the same as RPL0
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
isFirstEntry = true;
lastSign = true;
for (uint32_t ii = 0; isAllEntriesinRPLHasSameSignFlag && !sps.getRPL1CopyFromRPL0Flag() && ii < numberOfRPL; ii++)
{
isFirstEntry = true;
const ReferencePictureList* rpl = rplList1->getReferencePictureList(ii);
for (uint32_t jj = 0; isAllEntriesinRPLHasSameSignFlag && jj < rpl->getNumberOfActivePictures(); jj++)
{
if (!rpl->isRefPicLongterm(jj) && isFirstEntry)
{
lastSign = (rpl->getRefPicIdentifier(jj) >= 0) ? true : false;
isFirstEntry = false;
}
else if (!rpl->isRefPicLongterm(jj) && (((rpl->getRefPicIdentifier(jj) - rpl->getRefPicIdentifier(jj - 1)) >= 0 && lastSign == false) || ((rpl->getRefPicIdentifier(jj) - rpl->getRefPicIdentifier(jj - 1)) < 0 && lastSign == true)))
{
isAllEntriesinRPLHasSameSignFlag = false;
}
}
}
sps.setAllActiveRplEntriesHasSameSignFlag(isAllEntriesinRPLHasSameSignFlag);
}
void EncLib::getActiveRefPicListNumForPOC(const SPS *sps, int POCCurr, int GOPid, uint32_t *activeL0, uint32_t *activeL1)
{
if (m_uiIntraPeriod < 0) //Only for RA
{
*activeL0 = *activeL1 = 0;
return;
}
uint32_t rpl0Idx = GOPid;
uint32_t rpl1Idx = GOPid;
int fullListNum = m_iGOPSize;
int partialListNum = getRPLCandidateSize(0) - m_iGOPSize;
int extraNum = fullListNum;
if (m_uiIntraPeriod < 0)
{
if (POCCurr < 10)
{
rpl0Idx = POCCurr + m_iGOPSize - 1;
rpl1Idx = POCCurr + m_iGOPSize - 1;
}
else
{
rpl0Idx = (POCCurr%m_iGOPSize == 0) ? m_iGOPSize - 1 : POCCurr%m_iGOPSize - 1;
rpl1Idx = (POCCurr%m_iGOPSize == 0) ? m_iGOPSize - 1 : POCCurr%m_iGOPSize - 1;
}
extraNum = fullListNum + partialListNum;
}
for (; extraNum<fullListNum + partialListNum; extraNum++)
{
if (m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
{
int POCIndex = POCCurr%m_uiIntraPeriod;
if (POCIndex == 0)
POCIndex = m_uiIntraPeriod;
if (POCIndex == m_RPLList0[extraNum].m_POC)
{
rpl0Idx = extraNum;
rpl1Idx = extraNum;
extraNum++;
}
}
}
const ReferencePictureList *rpl0 = sps->getRPLList0()->getReferencePictureList(rpl0Idx);
*activeL0 = rpl0->getNumberOfActivePictures();
const ReferencePictureList *rpl1 = sps->getRPLList1()->getReferencePictureList(rpl1Idx);
*activeL1 = rpl1->getNumberOfActivePictures();
}
void EncLib::selectReferencePictureList(Slice* slice, int POCCurr, int GOPid, int ltPoc)
{
bool isEncodeLtRef = (POCCurr == ltPoc);
if (m_compositeRefEnabled && isEncodeLtRef)
{
POCCurr++;
}
slice->setRPL0idx(GOPid);
slice->setRPL1idx(GOPid);
int fullListNum = m_iGOPSize;
int partialListNum = getRPLCandidateSize(0) - m_iGOPSize;
int extraNum = fullListNum;
if (m_uiIntraPeriod < 0)
{
if (POCCurr < 10)
{
slice->setRPL0idx(POCCurr + m_iGOPSize - 1);
slice->setRPL1idx(POCCurr + m_iGOPSize - 1);
}
else
{
slice->setRPL0idx((POCCurr%m_iGOPSize == 0) ? m_iGOPSize - 1 : POCCurr%m_iGOPSize - 1);
slice->setRPL1idx((POCCurr%m_iGOPSize == 0) ? m_iGOPSize - 1 : POCCurr%m_iGOPSize - 1);
}
extraNum = fullListNum + partialListNum;
}
for (; extraNum < fullListNum + partialListNum; extraNum++)
{
if (m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
{
int POCIndex = POCCurr%m_uiIntraPeriod;
if (POCIndex == 0)
POCIndex = m_uiIntraPeriod;
if (POCIndex == m_RPLList0[extraNum].m_POC)
{
slice->setRPL0idx(extraNum);
slice->setRPL1idx(extraNum);
extraNum++;
}
}
}
const ReferencePictureList *rpl0 = (slice->getSPS()->getRPLList0()->getReferencePictureList(slice->getRPL0idx()));
const ReferencePictureList *rpl1 = (slice->getSPS()->getRPLList1()->getReferencePictureList(slice->getRPL1idx()));
slice->setRPL0(rpl0);
slice->setRPL1(rpl1);
}

Karsten Suehring
committed
void EncLib::xInitPPSforTiles(PPS &pps)
{
if ( (m_iNumColumnsMinus1==0) && (m_iNumRowsMinus1==0) )
{
// one, no bricks
pps.setSingleTileInPicFlag(true);
pps.setSingleBrickPerSliceFlag(true);
pps.setRectSliceFlag(true);
}
else
{
pps.setSingleTileInPicFlag(false);
pps.setSingleBrickPerSliceFlag( m_sliceMode==SINGLE_BRICK_PER_SLICE );
pps.setRectSliceFlag( m_sliceMode==SINGLE_BRICK_PER_SLICE );
if (m_rectSliceFlag)
pps.setRectSliceFlag(m_rectSliceFlag);
}
pps.setUniformTileSpacingFlag( m_tileUniformSpacingFlag );

Karsten Suehring
committed
pps.setNumTileColumnsMinus1( m_iNumColumnsMinus1 );
pps.setNumTileRowsMinus1( m_iNumRowsMinus1 );
if( !m_tileUniformSpacingFlag )
{
pps.setTileColumnWidth( m_tileColumnWidth );
pps.setTileRowHeight( m_tileRowHeight );
}
pps.setLoopFilterAcrossBricksEnabledFlag( m_loopFilterAcrossBricksEnabledFlag );
//pps.setRectSliceFlag( m_rectSliceFlag );
pps.setNumSlicesInPicMinus1( m_numSlicesInPicMinus1 );
pps.setTopLeftBrickIdx(m_topLeftBrickIdx);
pps.setBottomRightBrickIdx(m_bottomRightBrickIdx);
pps.setLoopFilterAcrossBricksEnabledFlag( m_loopFilterAcrossBricksEnabledFlag );
pps.setLoopFilterAcrossSlicesEnabledFlag( m_loopFilterAcrossSlicesEnabledFlag );
pps.setSignalledSliceIdFlag( m_signalledSliceIdFlag );
pps.setSignalledSliceIdLengthMinus1( m_signalledSliceIdLengthMinus1 );
pps.setSignalledSliceIdFlag( m_signalledSliceIdFlag );
pps.setSignalledSliceIdLengthMinus1( m_signalledSliceIdLengthMinus1 );
pps.setSliceId( m_sliceId );
int numTiles= (m_iNumColumnsMinus1 + 1) * (m_iNumRowsMinus1 + 1);
pps.setNumTilesInPic(numTiles);
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
if (m_brickSplitMap.empty())
{
pps.setBrickSplittingPresentFlag(false);
}
else
{
pps.setBrickSplittingPresentFlag(true);
std::vector<bool> brickSplitFlag (numTiles, false);
std::vector<bool> uniformBrickSpacingFlag (numTiles, false);
std::vector<int> brickHeightMinus1 (numTiles, 0);
std::vector<int> numBrickRowsMinus1 (numTiles, 0);
std::vector<std::vector<int>> brickRowHeightMinus1 (numTiles);
for (auto &brickSplit: m_brickSplitMap)
{
int tileIdx = brickSplit.first;
CHECK ( tileIdx >= numTiles, "Brick split specified for undefined tile");
brickSplitFlag[tileIdx] = true;
uniformBrickSpacingFlag [tileIdx] = brickSplit.second.m_uniformSplit;
if (uniformBrickSpacingFlag [tileIdx])
{
brickHeightMinus1[tileIdx]=brickSplit.second.m_uniformHeight - 1;
}
else
{
numBrickRowsMinus1[tileIdx]=brickSplit.second.m_numSplits;
brickRowHeightMinus1[tileIdx].resize(brickSplit.second.m_numSplits);
for (int i=0; i<brickSplit.second.m_numSplits; i++)
{
brickRowHeightMinus1[tileIdx][i]=brickSplit.second.m_brickHeight[i] - 1;
}
}
}
pps.setBrickSplitFlag(brickSplitFlag);
pps.setUniformBrickSpacingFlag(uniformBrickSpacingFlag);
pps.setBrickHeightMinus1(brickHeightMinus1);
pps.setNumBrickRowsMinus1(numBrickRowsMinus1);
pps.setBrickRowHeightMinus1(brickRowHeightMinus1);
// check brick dimensions
std::vector<uint32_t> tileRowHeight (m_iNumRowsMinus1+1);
int picHeightInCtus = (getSourceHeight() + m_maxCUHeight - 1) / m_maxCUHeight;
// calculate all tile row heights
if( pps.getUniformTileSpacingFlag() )
{
//set width and height for each (uniform) tile
for(int row=0; row < m_iNumRowsMinus1 + 1; row++)
{
tileRowHeight[row] = (row+1)*picHeightInCtus/(m_iNumRowsMinus1+1) - (row*picHeightInCtus)/(m_iNumRowsMinus1 + 1);
}
}
else
{
tileRowHeight[ m_iNumRowsMinus1 ] = picHeightInCtus;
for( int j = 0; j < m_iNumRowsMinus1; j++ )
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
{
tileRowHeight[ j ] = pps.getTileRowHeight( j );
tileRowHeight[ m_iNumRowsMinus1 ] = tileRowHeight[ m_iNumRowsMinus1 ] - pps.getTileRowHeight( j );
}
}
// check brick splits for each tile
for (int tileIdx=0; tileIdx < numTiles; tileIdx++)
{
if (pps.getBrickSplitFlag(tileIdx))
{
const int tileY = tileIdx / (m_iNumColumnsMinus1+1);
int tileHeight = tileRowHeight [tileY];
if (pps.getUniformBrickSpacingFlag(tileIdx))
{
CHECK((pps.getBrickHeightMinus1(tileIdx) + 1) >= tileHeight, "Brick height larger than or equal to tile height");
}
else
{
int cumulativeHeight=0;
for (int i = 0; i < pps.getNumBrickRowsMinus1(tileIdx); i++)
{
cumulativeHeight += pps.getBrickRowHeightMinus1(tileIdx, i) + 1;
}
CHECK(cumulativeHeight >= tileHeight, "Cumulative brick height larger than or equal to tile height");
}
}
}
}

Karsten Suehring
committed
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
}
void EncCfg::xCheckGSParameters()
{
int iWidthInCU = ( m_iSourceWidth%m_maxCUWidth ) ? m_iSourceWidth/m_maxCUWidth + 1 : m_iSourceWidth/m_maxCUWidth;
int iHeightInCU = ( m_iSourceHeight%m_maxCUHeight ) ? m_iSourceHeight/m_maxCUHeight + 1 : m_iSourceHeight/m_maxCUHeight;
uint32_t uiCummulativeColumnWidth = 0;
uint32_t uiCummulativeRowHeight = 0;
//check the column relative parameters
if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) )
{
EXIT( "The number of columns is larger than the maximum allowed number of columns." );
}
if( m_iNumColumnsMinus1 >= iWidthInCU )
{
EXIT( "The current picture can not have so many columns." );
}
if( m_iNumColumnsMinus1 && !m_tileUniformSpacingFlag )
{
for(int i=0; i<m_iNumColumnsMinus1; i++)
{
uiCummulativeColumnWidth += m_tileColumnWidth[i];
}
if( uiCummulativeColumnWidth >= iWidthInCU )
{
EXIT( "The width of the column is too large." );
}
}
//check the row relative parameters
if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) )
{
EXIT( "The number of rows is larger than the maximum allowed number of rows." );
}
if( m_iNumRowsMinus1 >= iHeightInCU )
{
EXIT( "The current picture can not have so many rows." );
}
if( m_iNumRowsMinus1 && !m_tileUniformSpacingFlag )
{
for(int i=0; i<m_iNumRowsMinus1; i++)
{
uiCummulativeRowHeight += m_tileRowHeight[i];
}
if( uiCummulativeRowHeight >= iHeightInCU )
{
EXIT( "The height of the row is too large." );
}
}
}
void EncLib::setParamSetChanged(int spsId, int ppsId)
{
m_ppsMap.setChangedFlag(ppsId);
m_spsMap.setChangedFlag(spsId);
}
Hendry
committed
bool isChanged = m_apsMap.getChangedFlag(apsId);
Hendry
committed
return isChanged;

Karsten Suehring
committed
bool EncLib::PPSNeedsWriting(int ppsId)
{
bool bChanged=m_ppsMap.getChangedFlag(ppsId);
m_ppsMap.clearChangedFlag(ppsId);
return bChanged;
}
bool EncLib::SPSNeedsWriting(int spsId)
{
bool bChanged=m_spsMap.getChangedFlag(spsId);
m_spsMap.clearChangedFlag(spsId);
return bChanged;
}
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
#if JVET_O0119_BASE_PALETTE_444
void EncLib::checkPltStats( Picture* pic )
{
int totalArea = 0;
int pltArea = 0;
for (auto apu : pic->cs->pus)
{
for (int i = 0; i < MAX_NUM_TBLOCKS; ++i)
{
int puArea = apu->blocks[i].width * apu->blocks[i].height;
if (apu->blocks[i].width > 0 && apu->blocks[i].height > 0)
{
totalArea += puArea;
if (CU::isPLT(*apu->cu) || CU::isIBC(*apu->cu))
{
pltArea += puArea;
}
break;
}
}
}
if (pltArea * PLT_FAST_RATIO < totalArea)
{
m_doPlt = false;
}
else
{
m_doPlt = true;
}
}
#endif

Karsten Suehring
committed
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
#if X0038_LAMBDA_FROM_QP_CAPABILITY
int EncCfg::getQPForPicture(const uint32_t gopIndex, const Slice *pSlice) const
{
const int lumaQpBDOffset = pSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA);
int qp;
if (getCostMode()==COST_LOSSLESS_CODING)
{
qp=LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP;
}
else
{
const SliceType sliceType=pSlice->getSliceType();
qp = getBaseQP();
// switch at specific qp and keep this qp offset
static int appliedSwitchDQQ = 0; /* TODO: MT */
if( pSlice->getPOC() == getSwitchPOC() )
{
appliedSwitchDQQ = getSwitchDQP();
}
qp += appliedSwitchDQQ;
#if QP_SWITCHING_FOR_PARALLEL
const int* pdQPs = getdQPs();
if ( pdQPs )
{
qp += pdQPs[pSlice->getPOC() / (m_compositeRefEnabled ? 2 : 1)];

Karsten Suehring
committed
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
}
#endif
if(sliceType==I_SLICE)
{
qp += getIntraQPOffset();
}
else
{
#if SHARP_LUMA_DELTA_QP
// Only adjust QP when not lossless
if (!(( getMaxDeltaQP() == 0 ) && (!getLumaLevelToDeltaQPMapping().isEnabled()) && (qp == -lumaQpBDOffset ) && (pSlice->getPPS()->getTransquantBypassEnabledFlag())))
#else
if (!(( getMaxDeltaQP() == 0 ) && (qp == -lumaQpBDOffset ) && (pSlice->getPPS()->getTransquantBypassEnabledFlag())))
#endif
{
const GOPEntry &gopEntry=getGOPEntry(gopIndex);
// adjust QP according to the QP offset for the GOP entry.
qp +=gopEntry.m_QPOffset;
// adjust QP according to QPOffsetModel for the GOP entry.
double dqpOffset=qp*gopEntry.m_QPOffsetModelScale+gopEntry.m_QPOffsetModelOffset+0.5;
int qpOffset = (int)floor(Clip3<double>(0.0, 3.0, dqpOffset));
qp += qpOffset ;
}
}
#if !QP_SWITCHING_FOR_PARALLEL
// modify QP if a fractional QP was originally specified, cause dQPs to be 0 or 1.
const int* pdQPs = getdQPs();
if ( pdQPs )
{
qp += pdQPs[ pSlice->getPOC() ];
}
#endif
}
qp = Clip3( -lumaQpBDOffset, MAX_QP, qp );
return qp;
}
#endif