Commit 23eede45 authored by Frank Bossen's avatar Frank Bossen

Merge branch 'CPR_SLICE_TYPE' into 'master'

Cpr slice type

See merge request jvet/VVCSoftware_BMS!115
parents a9b600b2 f9059fe1
Pipeline #126 pending with stage
......@@ -564,13 +564,7 @@ cTUTraverser CodingStructure::traverseTUs( const UnitArea& unit, const ChannelTy
void CodingStructure::allocateVectorsAtPicLevel()
{
const int twice = (
#if JVET_K0076_CPR_DT
(!pcv->ISingleTree && (slice->isIntra() || this->slice->getCprIsOnlyRefPic()))
#else
!pcv->ISingleTree && slice->isIntra()
#endif
&& pcv->chrFormat != CHROMA_400 ) ? 2 : 1;
const int twice = ( !pcv->ISingleTree && slice->isIRAP() && pcv->chrFormat != CHROMA_400 ) ? 2 : 1;
size_t allocSize = twice * unitScale[0].scale( area.blocks[0].size() ).area();
cus.reserve( allocSize );
......
......@@ -799,11 +799,7 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf
const int iQBits = QUANT_SHIFT + cQP.per + iTransformShift;
// QBits will be OK for any internal bit depth as the reduction in transform shift is balanced by an increase in Qp_per due to QpBDOffset
const int64_t iAdd = int64_t(tu.cs->slice->getSliceType() == I_SLICE
#if JVET_K0076_CPR
|| (tu.cs->slice->getNumRefIdx(REF_PIC_LIST_0) == 1 && tu.cs->slice->getSPS()->getSpsNext().getIBCMode())
#endif
? 171 : 85) << int64_t(iQBits - 9);
const int64_t iAdd = int64_t(tu.cs->slice->isIRAP() ? 171 : 85) << int64_t(iQBits - 9);
#if HEVC_USE_SIGN_HIDING
const int qBits8 = iQBits - 8;
#endif
......
......@@ -136,9 +136,6 @@ Slice::Slice()
, m_iProcessingStartTime ( 0 )
, m_dProcessingTime ( 0 )
, m_uiMaxBTSize ( 0 )
#if JVET_K0076_CPR
, m_bCprIsOnlyRefPic ( false )
#endif
{
for(uint32_t i=0; i<NUM_REF_PIC_LIST_01; i++)
{
......@@ -2726,12 +2723,7 @@ void calculateParameterSetChangedFlag(bool &bChanged, const std::vector<uint8_t>
uint32_t PreCalcValues::getValIdx( const Slice &slice, const ChannelType chType ) const
{
#if JVET_K0076_CPR_DT
return (slice.isIntra() || slice.getCprIsOnlyRefPic())
? (ISingleTree ? 0 : (chType << 1)) : 1;
#else
return slice.isIntra() ? ( ISingleTree ? 0 : ( chType << 1 ) ) : 1;
#endif
return slice.isIRAP() ? ( ISingleTree ? 0 : ( chType << 1 ) ) : 1;
}
uint32_t PreCalcValues::getMaxBtDepth( const Slice &slice, const ChannelType chType ) const
......@@ -2746,12 +2738,7 @@ uint32_t PreCalcValues::getMinBtSize( const Slice &slice, const ChannelType chTy
uint32_t PreCalcValues::getMaxBtSize( const Slice &slice, const ChannelType chType ) const
{
#if JVET_K0076_CPR_DT
return ((!slice.isIntra() && !slice.getCprIsOnlyRefPic())
|| isLuma(chType) || ISingleTree) ? slice.getMaxBTSize() : MAX_BT_SIZE_C;
#else
return ( !slice.isIntra() || isLuma( chType ) || ISingleTree ) ? slice.getMaxBTSize() : MAX_BT_SIZE_C;
#endif
return ( !slice.isIRAP() || isLuma( chType ) || ISingleTree ) ? slice.getMaxBTSize() : MAX_BT_SIZE_C;
}
uint32_t PreCalcValues::getMinTtSize( const Slice &slice, const ChannelType chType ) const
......
......@@ -1839,9 +1839,6 @@ private:
clock_t m_iProcessingStartTime;
double m_dProcessingTime;
uint32_t m_uiMaxBTSize;
#if JVET_K0076_CPR
bool m_bCprIsOnlyRefPic;
#endif
#if JVET_K0371_ALF
AlfSliceParam m_alfSliceParam;
......@@ -1962,10 +1959,6 @@ public:
void setMaxBTSize(int i) { m_uiMaxBTSize = i; }
uint32_t getMaxBTSize() const { return m_uiMaxBTSize; }
#if JVET_K0076_CPR
bool getCprIsOnlyRefPic() const { return m_bCprIsOnlyRefPic; }
void setCprIsOnlyRefPic(bool b) { m_bCprIsOnlyRefPic = b; }
#endif
#if JEM_TOOLS
bool getUseLIC() const { return m_UseLIC; }
......
......@@ -157,7 +157,7 @@ void CS::initFrucMvp( CodingStructure &cs )
const Picture* pColPic = cs.slice->getRefPic( eRefPicList, nRefIdx );
if( pColPic->cs->slice->isIntra() )
if( pColPic->cs->slice->isIRAP() )
{
continue;
}
......@@ -241,12 +241,7 @@ void CS::initFrucMvp( CodingStructure &cs )
bool CS::isDualITree( const CodingStructure &cs )
{
#if JVET_K0076_CPR_DT
// for I slice, or P slice with CPR is the only ref
return (cs.slice->isIntra() || cs.slice->getCprIsOnlyRefPic()) && !cs.pcv->ISingleTree;
#else
return cs.slice->isIntra() && !cs.pcv->ISingleTree;
#endif
return cs.slice->isIRAP() && !cs.pcv->ISingleTree;
}
UnitArea CS::getArea( const CodingStructure &cs, const UnitArea &area, const ChannelType chType )
......@@ -1387,7 +1382,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, co
#if JEM_TOOLS || JVET_K0346
#if JVET_K0076_CPR
bool enableSubPuMvp = slice.getSPS()->getSpsNext().getUseSubPuMvp() && !(slice.getPOC() == slice.getRefPic(REF_PIC_LIST_0, 0)->getPOC() && slice.getNumRefIdx(REF_PIC_LIST_0) == 1);
bool enableSubPuMvp = slice.getSPS()->getSpsNext().getUseSubPuMvp() && !(slice.isIRAP());
#else
bool enableSubPuMvp = slice.getSPS()->getSpsNext().getUseSubPuMvp();
#endif
......
......@@ -1197,12 +1197,6 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl
//---------------
pcSlice->setRefPOCList();
#if JVET_K0076_CPR
if (pcSlice->getNumRefIdx(REF_PIC_LIST_0) == 1 &&
pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0 &&
pcSlice->getRefPOC(REF_PIC_LIST_0, 0) == pcSlice->getPOC())
pcSlice->setCprIsOnlyRefPic(true);
#endif
#if JEM_TOOLS
if( pcSlice->getSPS()->getSpsNext().getUseBIO() )
......@@ -1263,7 +1257,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl
#endif
#if JEM_TOOLS
if( pcSlice->getSPS()->getSpsNext().getUseFRUCMrgMode() && !pcSlice->isIntra() )
if( pcSlice->getSPS()->getSpsNext().getUseFRUCMrgMode() && !pcSlice->isIRAP() )
{
CS::initFrucMvp( *m_pcPic->cs );
}
......
......@@ -409,13 +409,7 @@ void EncCu::compressCtu( CodingStructure& cs, const UnitArea& area, const unsign
const bool copyUnsplitCTUSignals = bestCS->cus.size() == 1 && KEEP_PRED_AND_RESI_SIGNALS;
cs.useSubStructure( *bestCS, partitioner->chType, CS::getArea( *bestCS, area, partitioner->chType ), copyUnsplitCTUSignals, false, false, copyUnsplitCTUSignals );
if( !cs.pcv->ISingleTree &&
#if JVET_K0076_CPR_DT
(cs.slice->isIntra() || cs.slice->getCprIsOnlyRefPic())
#else
cs.slice->isIntra()
#endif
&& cs.pcv->chrFormat != CHROMA_400 )
if( !cs.pcv->ISingleTree && cs.slice->isIRAP() && cs.pcv->chrFormat != CHROMA_400 )
{
m_CABACEstimator->getCtx() = m_CurrCtx->start;
......
......@@ -1684,7 +1684,6 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
if (pcSlice->getSliceType() == I_SLICE && pcSlice->getSPS()->getSpsNext().getIBCMode())
{
pcSlice->setSliceType(P_SLICE);
pcSlice->setCprIsOnlyRefPic(true);
}
#endif
// Set the nal unit type
......@@ -1890,11 +1889,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
if( m_pcCfg->getUseAMaxBT() )
{
if( !pcSlice->isIntra()
#if JVET_K0076_CPR
&& !pcSlice->getCprIsOnlyRefPic()
#endif
)
if( !pcSlice->isIRAP() )
{
int refLayer = pcSlice->getDepth();
if( refLayer > 9 ) refLayer = 9; // Max layer is 10
......@@ -1945,7 +1940,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
pcSlice->setSliceType ( P_SLICE );
}
#if JVET_K0076_CPR
if (pcSlice->getSPS()->getSpsNext().getIBCMode() && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == 1)
if (pcSlice->getSPS()->getSpsNext().getIBCMode() && pcSlice->isIRAP())
{
m_pcSliceEncoder->setEncCABACTableIdx(P_SLICE);
}
......@@ -2063,7 +2058,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
}
// set adaptive search range for non-intra-slices
if (m_pcCfg->getUseASR() && pcSlice->getSliceType()!=I_SLICE)
if (m_pcCfg->getUseASR() && !pcSlice->isIRAP())
{
m_pcSliceEncoder->setSearchRange(pcSlice);
}
......@@ -2124,7 +2119,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
if ( m_pcCfg->getUseRateCtrl() ) // TODO: does this work with multiple slices and slice-segments?
{
int frameLevel = m_pcRateCtrl->getRCSeq()->getGOPID2Level( iGOPid );
if ( pcPic->slices[0]->getSliceType() == I_SLICE )
if ( pcPic->slices[0]->isIRAP() )
{
frameLevel = 0;
}
......@@ -2227,13 +2222,13 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
list<EncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
m_pcRateCtrl->getRCPic()->getLCUInitTargetBits();
lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->getSliceType());
lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->isIRAP());
sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
}
else // normal case
{
list<EncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->getSliceType());
lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->isIRAP());
sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
}
......@@ -2527,11 +2522,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
{
for( const CodingUnit *cu : pcPic->cs->cus )
{
if( !pcSlice->isIntra()
#if JVET_K0076_CPR
&& !pcSlice->getCprIsOnlyRefPic()
#endif
)
if( !pcSlice->isIRAP() )
{
m_uiBlkSize[pcSlice->getDepth()] += cu->Y().area();
m_uiNumBlk [pcSlice->getDepth()]++;
......@@ -2745,11 +2736,11 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
avgLambda = lambda;
}
m_pcRateCtrl->getRCPic()->updateAfterPicture( actualHeadBits, actualTotalBits, avgQP, avgLambda, pcSlice->getSliceType());
m_pcRateCtrl->getRCPic()->updateAfterPicture( actualHeadBits, actualTotalBits, avgQP, avgLambda, pcSlice->isIRAP());
m_pcRateCtrl->getRCPic()->addToPictureLsit( m_pcRateCtrl->getPicList() );
m_pcRateCtrl->getRCSeq()->updateAfterPic( actualTotalBits );
if ( pcSlice->getSliceType() != I_SLICE )
if ( !pcSlice->isIRAP() )
{
m_pcRateCtrl->getRCGOP()->updateAfterPicture( actualTotalBits );
}
......@@ -3947,7 +3938,7 @@ void EncGOP::arrangeCompositeReference(Slice* pcSlice, PicList& rcListPic, int p
break;
}
}
if (pcSlice->getSliceType() == I_SLICE)
if (pcSlice->isIRAP())
{
return;
}
......@@ -4090,7 +4081,7 @@ void EncGOP::updateCompositeReference(Slice* pcSlice, PicList& rcListPic, int po
int maxCuHeight = pcv->maxCUHeight;
// Update background reference
if (pcSlice->getSliceType() == I_SLICE)//(pocCurr == 0)
if (pcSlice->isIRAP())//(pocCurr == 0)
{
curPic->extendPicBorder();
curPic->setBorderExtension(true);
......@@ -4287,7 +4278,7 @@ void EncGOP::applyDeblockingFilterParameterSelection( Picture* pcPic, const uint
PelUnitBuf reco = pcPic->getRecoBuf();
const int currQualityLayer = (pcPic->slices[0]->getSliceType() != I_SLICE) ? m_pcCfg->getGOPEntry(gopID).m_temporalId+1 : 0;
const int currQualityLayer = (!pcPic->slices[0]->isIRAP()) ? m_pcCfg->getGOPEntry(gopID).m_temporalId+1 : 0;
CHECK(!(currQualityLayer <MAX_ENCODER_DEBLOCKING_QUALITY_LAYERS), "Unspecified error");
CodingStructure& cs = *pcPic->cs;
......
......@@ -1306,11 +1306,7 @@ void EncModeCtrlMTnoRQT::initCULevel( Partitioner &partitioner, const CodingStru
}
// add first pass modes
#if JVET_K0076_CPR
if ((!m_slice->isIntra() && !cs.sps->getSpsNext().getIBCMode()) || (m_slice->getNumRefIdx(REF_PIC_LIST_0) > 1 && cs.sps->getSpsNext().getIBCMode()))
#else
if( !m_slice->isIntra() )
#endif
if( !m_slice->isIRAP() )
{
for( int qpLoop = maxQP; qpLoop >= minQP; qpLoop-- )
{
......@@ -1595,11 +1591,8 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt
#endif
CHECK( !slice.isIntra() && !cuECtx.bestTU, "No possible non-intra encoding for a P- or B-slice found" );
if( !( slice.isIntra() || bestMode.type == ETM_INTRA ||
#if JVET_K0076_CPR
(cs.sps->getSpsNext().getIBCMode() && m_slice->getNumRefIdx(REF_PIC_LIST_0) == 1) ||
#endif
( ( !m_pcEncCfg->getDisableIntraPUsInInterSlices() ) && !relatedCU.isInter && (
if( !( slice.isIRAP() || bestMode.type == ETM_INTRA ||
( ( !m_pcEncCfg->getDisableIntraPUsInInterSlices() ) && !relatedCU.isInter && (
( cuECtx.bestTU->cbf[0] != 0 ) ||
( ( numComp > COMPONENT_Cb ) && cuECtx.bestTU->cbf[1] != 0 ) ||
( ( numComp > COMPONENT_Cr ) && cuECtx.bestTU->cbf[2] != 0 ) // avoid very complex intra if it is unlikely
......@@ -1656,11 +1649,7 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt
if( lastTestMode().type != ETM_INTRA && cuECtx.bestCS && cuECtx.bestCU && interHadActive( cuECtx ) )
{
// Get SATD threshold from best Inter-CU
if( !cs.slice->isIntra() && m_pcEncCfg->getUsePbIntraFast()
#if JVET_K0076_CPR
&& !(cs.slice->getNumRefIdx(REF_PIC_LIST_0) == 1 && cs.sps->getSpsNext().getIBCMode())
#endif
)
if( !cs.slice->isIRAP() && m_pcEncCfg->getUsePbIntraFast() )
{
CodingUnit* bestCU = cuECtx.bestCU;
if( bestCU && CU::isInter( *bestCU ) )
......
......@@ -1274,11 +1274,7 @@ void EncSlice::compressSlice( Picture* pcPic, const bool bCompressEntireSlice, c
#if JVET_K0346
if (pcSlice->getSPS()->getSpsNext().getUseSubPuMvp())
{
if (!pcSlice->isIntra()
#if JVET_K0076_CPR
&& !pcSlice->getCprIsOnlyRefPic()
#endif
)
if (!pcSlice->isIRAP() )
{
if (pcSlice->getPOC() > m_pcCuEncoder->getPrevPOC() && m_pcCuEncoder->getClearSubMergeStatic())
{
......@@ -1730,14 +1726,14 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons
double estLambda = -1.0;
double bpp = -1.0;
if( ( pcPic->slices[0]->getSliceType() == I_SLICE && pCfg->getForceIntraQP() ) || !pCfg->getLCULevelRC() )
if( ( pcPic->slices[0]->isIRAP() && pCfg->getForceIntraQP() ) || !pCfg->getLCULevelRC() )
{
estQP = pcSlice->getSliceQp();
}
else
{
bpp = pRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType());
if ( pcPic->slices[0]->getSliceType() == I_SLICE)
bpp = pRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->isIRAP());
if ( pcPic->slices[0]->isIRAP())
{
estLambda = pRateCtrl->getRCPic()->getLCUEstLambdaAndQP(bpp, pcSlice->getSliceQp(), &estQP);
}
......@@ -1782,7 +1778,7 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons
#endif
#if JEM_TOOLS
if( pcSlice->getSPS()->getSpsNext().getUseFRUCMrgMode() && !pcSlice->isIntra() )
if( pcSlice->getSPS()->getSpsNext().getUseFRUCMrgMode() && !pcSlice->isIRAP() )
{
CS::initFrucMvp( cs );
}
......@@ -1895,7 +1891,7 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons
}
pRdCost->setLambda(oldLambda, pcSlice->getSPS()->getBitDepths());
pRateCtrl->getRCPic()->updateAfterCTU( pRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
pcSlice->getSliceType() == I_SLICE ? 0 : pCfg->getLCULevelRC() );
pcSlice->isIRAP() ? 0 : pCfg->getLCULevelRC() );
}
#if ENABLE_QPA
else if (pCfg->getUsePerceptQPA() && pcSlice->getPPS()->getUseDQP())
......
......@@ -807,7 +807,7 @@ void EncRCPic::destroy()
}
double EncRCPic::estimatePicLambda( list<EncRCPic*>& listPreviousPictures, SliceType eSliceType)
double EncRCPic::estimatePicLambda( list<EncRCPic*>& listPreviousPictures, bool isIRAP)
{
double alpha = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha;
double beta = m_encRCSeq->getPicPara( m_frameLevel ).m_beta;
......@@ -826,7 +826,7 @@ double EncRCPic::estimatePicLambda( list<EncRCPic*>& listPreviousPictures, Slice
#endif
double estLambda;
if (eSliceType == I_SLICE)
if (isIRAP)
{
estLambda = calculateLambdaIntra(alpha, beta, pow(m_totalCostIntra/(double)m_numberOfPixel, BETA1), bpp);
}
......@@ -973,13 +973,13 @@ int EncRCPic::estimatePicQP( double lambda, list<EncRCPic*>& listPreviousPicture
return QP;
}
double EncRCPic::getLCUTargetBpp(SliceType eSliceType)
double EncRCPic::getLCUTargetBpp(bool isIRAP)
{
int LCUIdx = getLCUCoded();
double bpp = -1.0;
int avgBits = 0;
if (eSliceType == I_SLICE)
if (isIRAP)
{
int noOfLCUsLeft = m_numberOfLCU - LCUIdx + 1;
int bitrateWindow = min(4,noOfLCUsLeft);
......@@ -1316,7 +1316,7 @@ double EncRCPic::calAverageLambda()
}
void EncRCPic::updateAfterPicture( int actualHeaderBits, int actualTotalBits, double averageQP, double averageLambda, SliceType eSliceType)
void EncRCPic::updateAfterPicture( int actualHeaderBits, int actualTotalBits, double averageQP, double averageLambda, bool isIRAP)
{
m_picActualHeaderBits = actualHeaderBits;
m_picActualBits = actualTotalBits;
......@@ -1333,7 +1333,7 @@ void EncRCPic::updateAfterPicture( int actualHeaderBits, int actualTotalBits, do
double alpha = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha;
double beta = m_encRCSeq->getPicPara( m_frameLevel ).m_beta;
if (eSliceType == I_SLICE)
if (isIRAP)
{
updateAlphaBetaIntra(&alpha, &beta);
}
......
......@@ -243,17 +243,17 @@ public:
int estimatePicQP ( double lambda, list<EncRCPic*>& listPreviousPictures );
int getRefineBitsForIntra(int orgBits);
double calculateLambdaIntra(double alpha, double beta, double MADPerPixel, double bitsPerPixel);
double estimatePicLambda( list<EncRCPic*>& listPreviousPictures, SliceType eSliceType);
double estimatePicLambda( list<EncRCPic*>& listPreviousPictures, bool isIRAP);
void updateAlphaBetaIntra(double *alpha, double *beta);
double getLCUTargetBpp(SliceType eSliceType);
double getLCUTargetBpp(bool isIRAP);
double getLCUEstLambdaAndQP(double bpp, int clipPicQP, int *estQP);
double getLCUEstLambda( double bpp );
int getLCUEstQP( double lambda, int clipPicQP );
void updateAfterCTU( int LCUIdx, int bits, int QP, double lambda, bool updateLCUParameter = true );
void updateAfterPicture( int actualHeaderBits, int actualTotalBits, double averageQP, double averageLambda, SliceType eSliceType);
void updateAfterPicture( int actualHeaderBits, int actualTotalBits, double averageQP, double averageLambda, bool isIRAP);
void addToPictureLsit( list<EncRCPic*>& listPreviousPictures );
double calAverageQP();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment