Commit 3ec165d4 authored by Xiang Li's avatar Xiang Li
Browse files

Merge branch 'JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC' into 'master'

JVET-R0271: Slice level DQ and SDH granularity for mixed lossy and lossless coding.

See merge request jvet/VVCSoftware_VTM!1542
parents 2275adb3 1b4a5883
......@@ -1573,7 +1573,11 @@ DepQuant::~DepQuant()
void DepQuant::quant( TransformUnit &tu, const ComponentID &compID, const CCoeffBuf &pSrc, TCoeff &uiAbsSum, const QpParam &cQP, const Ctx& ctx )
{
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
if ( tu.cs->slice->getDepQuantEnabledFlag() && (tu.mtsIdx[compID] != MTS_SKIP) )
#else
if ( tu.cs->picHeader->getDepQuantEnabledFlag() && (tu.mtsIdx[compID] != MTS_SKIP) )
#endif
{
//===== scaling matrix ====
const int qpDQ = cQP.Qp(tu.mtsIdx[compID] == MTS_SKIP) + 1;
......@@ -1599,7 +1603,11 @@ void DepQuant::quant( TransformUnit &tu, const ComponentID &compID, const CCoeff
void DepQuant::dequant( const TransformUnit &tu, CoeffBuf &dstCoeff, const ComponentID &compID, const QpParam &cQP )
{
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
if( tu.cs->slice->getDepQuantEnabledFlag() && (tu.mtsIdx[compID] != MTS_SKIP) )
#else
if( tu.cs->picHeader->getDepQuantEnabledFlag() && (tu.mtsIdx[compID] != MTS_SKIP))
#endif
{
const int qpDQ = cQP.Qp(tu.mtsIdx[compID] == MTS_SKIP) + 1;
const int qpPer = qpDQ / 6;
......
......@@ -967,8 +967,11 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf
const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(toChannelType(compID));
{
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
CoeffCodingContext cctx(tu, compID, tu.cs->slice->getSignDataHidingEnabledFlag());
#else
CoeffCodingContext cctx(tu, compID, tu.cs->picHeader->getSignDataHidingEnabledFlag());
#endif
const TCoeff entropyCodingMinimum = -(1 << maxLog2TrDynamicRange);
const TCoeff entropyCodingMaximum = (1 << maxLog2TrDynamicRange) - 1;
......
......@@ -639,8 +639,12 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
const TCoeff entropyCodingMinimum = -(1 << maxLog2TrDynamicRange);
const TCoeff entropyCodingMaximum = (1 << maxLog2TrDynamicRange) - 1;
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
CoeffCodingContext cctx(tu, compID, tu.cs->slice->getSignDataHidingEnabledFlag());
#else
CoeffCodingContext cctx(tu, compID, tu.cs->picHeader->getSignDataHidingEnabledFlag());
#endif
const int iCGSizeM1 = (1 << cctx.log2CGSize()) - 1;
int iCGLastScanPos = -1;
......@@ -1225,7 +1229,11 @@ void QuantRDOQ::xRateDistOptQuantTS( TransformUnit &tu, const ComponentID &compI
uint32_t coeffLevels[3];
double coeffLevelError[4];
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
CoeffCodingContext cctx( tu, compID, tu.cs->slice->getSignDataHidingEnabledFlag() );
#else
CoeffCodingContext cctx( tu, compID, tu.cs->picHeader->getSignDataHidingEnabledFlag() );
#endif
const int sbSizeM1 = ( 1 << cctx.log2CGSize() ) - 1;
double baseCost = 0;
uint32_t goRiceParam = 0;
......@@ -1450,7 +1458,11 @@ void QuantRDOQ::forwardRDPCM( TransformUnit &tu, const ComponentID &compID, cons
uint32_t coeffLevels[3];
double coeffLevelError[4];
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
CoeffCodingContext cctx(tu, compID, tu.cs->slice->getSignDataHidingEnabledFlag());
#else
CoeffCodingContext cctx(tu, compID, tu.cs->picHeader->getSignDataHidingEnabledFlag());
#endif
const int sbSizeM1 = (1 << cctx.log2CGSize()) - 1;
double baseCost = 0;
uint32_t goRiceParam = 0;
......
......@@ -69,6 +69,10 @@ Slice::Slice()
, m_deblockingFilterCbTcOffsetDiv2 ( 0 )
, m_deblockingFilterCrBetaOffsetDiv2( 0 )
, m_deblockingFilterCrTcOffsetDiv2 ( 0 )
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
, m_depQuantEnabledFlag ( false )
, m_signDataHidingEnabledFlag ( false )
#endif
, m_tsResidualCodingDisabledFlag ( false )
, m_pendingRasInit ( false )
, m_bCheckLDC ( false )
......@@ -907,6 +911,10 @@ void Slice::copySliceInfo(Slice *pSrc, bool cpyAlmostAll)
m_deblockingFilterCbTcOffsetDiv2 = pSrc->m_deblockingFilterCbTcOffsetDiv2;
m_deblockingFilterCrBetaOffsetDiv2 = pSrc->m_deblockingFilterCrBetaOffsetDiv2;
m_deblockingFilterCrTcOffsetDiv2 = pSrc->m_deblockingFilterCrTcOffsetDiv2;
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
m_depQuantEnabledFlag = pSrc->m_depQuantEnabledFlag;
m_signDataHidingEnabledFlag = pSrc->m_signDataHidingEnabledFlag;
#endif
m_tsResidualCodingDisabledFlag = pSrc->m_tsResidualCodingDisabledFlag;
for (i = 0; i < NUM_REF_PIC_LIST_01; i++)
......@@ -2170,8 +2178,10 @@ PicHeader::PicHeader()
, m_numAlfAps ( 0 )
, m_alfApsId ( 0 )
, m_alfChromaApsId ( 0 )
#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
, m_depQuantEnabledFlag ( 0 )
, m_signDataHidingEnabledFlag ( 0 )
#endif
, m_deblockingFilterOverrideFlag ( 0 )
, m_deblockingFilterDisable ( 0 )
, m_deblockingFilterBetaOffsetDiv2 ( 0 )
......@@ -2261,8 +2271,10 @@ void PicHeader::initPicHeader()
m_qpDelta = 0;
m_numAlfAps = 0;
m_alfChromaApsId = 0;
#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
m_depQuantEnabledFlag = 0;
m_signDataHidingEnabledFlag = 0;
#endif
m_deblockingFilterOverrideFlag = 0;
m_deblockingFilterDisable = 0;
m_deblockingFilterBetaOffsetDiv2 = 0;
......
......@@ -2177,8 +2177,10 @@ private:
bool m_ccalfEnabledFlag[MAX_NUM_COMPONENT];
int m_ccalfCbApsId;
int m_ccalfCrApsId;
#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
bool m_depQuantEnabledFlag; //!< dependent quantization enabled flag
bool m_signDataHidingEnabledFlag; //!< sign data hiding enabled flag
#endif
bool m_deblockingFilterOverrideFlag; //!< deblocking filter override controls enabled
bool m_deblockingFilterDisable; //!< deblocking filter disabled flag
int m_deblockingFilterBetaOffsetDiv2; //!< beta offset for deblocking filter
......@@ -2312,10 +2314,12 @@ public:
int getCcAlfCbApsId() const { return m_ccalfCbApsId; }
void setCcAlfCrApsId(int i) { m_ccalfCrApsId = i; }
int getCcAlfCrApsId() const { return m_ccalfCrApsId; }
#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
void setDepQuantEnabledFlag( bool b ) { m_depQuantEnabledFlag = b; }
bool getDepQuantEnabledFlag() const { return m_depQuantEnabledFlag; }
bool getDepQuantEnabledFlag() const { return m_depQuantEnabledFlag; }
void setSignDataHidingEnabledFlag( bool b ) { m_signDataHidingEnabledFlag = b; }
bool getSignDataHidingEnabledFlag() const { return m_signDataHidingEnabledFlag; }
bool getSignDataHidingEnabledFlag() const { return m_signDataHidingEnabledFlag; }
#endif
void setDeblockingFilterOverrideFlag( bool b ) { m_deblockingFilterOverrideFlag = b; }
bool getDeblockingFilterOverrideFlag() const { return m_deblockingFilterOverrideFlag; }
void setDeblockingFilterDisable( bool b ) { m_deblockingFilterDisable= b; }
......@@ -2442,6 +2446,10 @@ private:
int m_deblockingFilterCbTcOffsetDiv2; //< tc offset for deblocking filter
int m_deblockingFilterCrBetaOffsetDiv2; //< beta offset for deblocking filter
int m_deblockingFilterCrTcOffsetDiv2; //< tc offset for deblocking filter
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
bool m_depQuantEnabledFlag; //!< dependent quantization enabled flag
bool m_signDataHidingEnabledFlag; //!< sign data hiding enabled flag
#endif
bool m_tsResidualCodingDisabledFlag;
int m_list1IdxToList0Idx[MAX_NUM_REF];
int m_aiNumRefIdx [NUM_REF_PIC_LIST_01]; // for multiple reference of current slice
......@@ -2626,6 +2634,12 @@ public:
void setDeblockingFilterCbTcOffsetDiv2( int i ) { m_deblockingFilterCbTcOffsetDiv2 = i; }
void setDeblockingFilterCrBetaOffsetDiv2( int i ) { m_deblockingFilterCrBetaOffsetDiv2 = i; }
void setDeblockingFilterCrTcOffsetDiv2( int i ) { m_deblockingFilterCrTcOffsetDiv2 = i; }
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
void setDepQuantEnabledFlag( bool b ) { m_depQuantEnabledFlag = b; }
bool getDepQuantEnabledFlag() const { return m_depQuantEnabledFlag; }
void setSignDataHidingEnabledFlag( bool b ) { m_signDataHidingEnabledFlag = b; }
bool getSignDataHidingEnabledFlag() const { return m_signDataHidingEnabledFlag; }
#endif
void setTSResidualCodingDisabledFlag(bool b) { m_tsResidualCodingDisabledFlag = b; }
bool getTSResidualCodingDisabledFlag() const { return m_tsResidualCodingDisabledFlag; }
......
......@@ -52,6 +52,8 @@
//########### place macros to be removed in next cycle below this line ###############
#define JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC 1 // JVET-R0271/R0155: Slice level DQ and SDH granularity for mixed lossy/lossless.
#define JVET_R0143_TSRCdisableLL 1 // JVET-R0143: disable TSRC for lossless coding
#define JVET_R0233_CCALF_LINE_BUFFER_REDUCTION 1 // JVET-R0233 method 2: Line buffer reduction for CCALF
......
......@@ -2891,7 +2891,11 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID, CUCtx&
}
// determine sign hiding
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
bool signHiding = ( cu.cs->slice->getSignDataHidingEnabledFlag() && tu.rdpcm[compID] == RDPCM_OFF );
#else
bool signHiding = ( cu.cs->picHeader->getSignDataHidingEnabledFlag() && tu.rdpcm[compID] == RDPCM_OFF );
#endif
if( signHiding && CU::isIntra(cu) && CU::isRDPCMEnabled(cu) && tu.mtsIdx[compID] == MTS_SKIP )
{
const ChannelType chType = toChannelType( compID );
......@@ -2924,7 +2928,11 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID, CUCtx&
}
// parse subblocks
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
const int stateTransTab = ( tu.cs->slice->getDepQuantEnabledFlag() ? 32040 : 0 );
#else
const int stateTransTab = ( tu.cs->picHeader->getDepQuantEnabledFlag() ? 32040 : 0 );
#endif
int state = 0;
int ctxBinSampleRatio = (compID == COMPONENT_Y) ? MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA : MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA;
......
......@@ -2814,6 +2814,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag
}
#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
// dependent quantization
if (sps->getDepQuantEnabledFlag())
{
......@@ -2835,6 +2836,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag
{
picHeader->setSignDataHidingEnabledFlag(false);
}
#endif
// deblocking filter controls
if (pps->getDeblockingFilterControlPresentFlag())
......@@ -3711,8 +3713,43 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par
pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( 0 );
}
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
// dependent quantization
if( sps->getDepQuantEnabledFlag() )
{
READ_FLAG(uiCode, "slice_dep_quant_enabled_flag");
pcSlice->setDepQuantEnabledFlag(uiCode != 0);
}
else
{
pcSlice->setDepQuantEnabledFlag(false);
}
// sign data hiding
if( sps->getSignDataHidingEnabledFlag() && !pcSlice->getDepQuantEnabledFlag() )
{
READ_FLAG( uiCode, "slice_sign_data_hiding_enabled_flag" );
pcSlice->setSignDataHidingEnabledFlag( uiCode != 0 );
}
else
{
pcSlice->setSignDataHidingEnabledFlag(false);
}
// signal TS residual coding disabled flag
if( !pcSlice->getDepQuantEnabledFlag() && !pcSlice->getSignDataHidingEnabledFlag() )
{
READ_FLAG(uiCode, "slice_ts_residual_coding_disabled_flag");
pcSlice->setTSResidualCodingDisabledFlag( uiCode != 0 );
}
else
{
pcSlice->setTSResidualCodingDisabledFlag( false );
}
#else
READ_FLAG(uiCode, "slice_ts_residual_coding_disabled_flag");
pcSlice->setTSResidualCodingDisabledFlag(uiCode != 0);
#endif
if (picHeader->getLmcsEnabledFlag())
{
......
......@@ -2641,7 +2641,11 @@ void CABACWriter::residual_coding( const TransformUnit& tu, ComponentID compID,
}
// determine sign hiding
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
bool signHiding = ( cu.cs->slice->getSignDataHidingEnabledFlag() && tu.rdpcm[compID] == RDPCM_OFF );
#else
bool signHiding = ( cu.cs->picHeader->getSignDataHidingEnabledFlag() && tu.rdpcm[compID] == RDPCM_OFF );
#endif
if( signHiding && CU::isIntra(cu) && CU::isRDPCMEnabled(cu) && tu.mtsIdx[compID] == MTS_SKIP)
{
const ChannelType chType = toChannelType( compID );
......@@ -2691,7 +2695,11 @@ void CABACWriter::residual_coding( const TransformUnit& tu, ComponentID compID,
last_sig_coeff( cctx, tu, compID );
// code subblocks
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
const int stateTab = ( tu.cs->slice->getDepQuantEnabledFlag() ? 32040 : 0 );
#else
const int stateTab = ( tu.cs->picHeader->getDepQuantEnabledFlag() ? 32040 : 0 );
#endif
int state = 0;
int ctxBinSampleRatio = (compID == COMPONENT_Y) ? MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA : MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA;
......
......@@ -1685,10 +1685,11 @@ void EncLib::xInitPicHeader(PicHeader &picHeader, const SPS &sps, const PPS &pps
picHeader.setMaxBTSizes( sps.getMaxBTSizes() );
picHeader.setMaxTTSizes( sps.getMaxTTSizes() );
#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
// quantization
picHeader.setDepQuantEnabledFlag( sps.getDepQuantEnabledFlag() );
picHeader.setSignDataHidingEnabledFlag( sps.getSignDataHidingEnabledFlag() );
#endif
bool bUseDQP = (getCuQpDeltaSubdiv() > 0)? true : false;
if( (getMaxDeltaQP() != 0 )|| getUseAdaptiveQP() )
......
......@@ -339,6 +339,31 @@ void EncSlice::initEncSlice(Picture* pcPic, const int pocLast, const int pocCurr
picHeader->setPicOutputFlag(true);
}
rpcSlice->setPOC( pocCurr );
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
if( m_pcCfg->getCostMode() != COST_LOSSLESS_CODING )
{
rpcSlice->setDepQuantEnabledFlag( m_pcCfg->getDepQuantEnabledFlag() );
rpcSlice->setSignDataHidingEnabledFlag( m_pcCfg->getSignDataHidingEnabledFlag() );
rpcSlice->setTSResidualCodingDisabledFlag( false );
CHECK( (m_pcCfg->getDepQuantEnabledFlag() || m_pcCfg->getSignDataHidingEnabledFlag() )
&& rpcSlice->getTSResidualCodingDisabledFlag() , "TSRC cannot be bypassed if either DQ or SDH are enabled at slice level.");
}
else
{
rpcSlice->setDepQuantEnabledFlag( false ); //should be disabled for lossless
rpcSlice->setSignDataHidingEnabledFlag( false ); //should be disabled for lossless
#if JVET_R0143_TSRCdisableLL
if( m_pcCfg->getTSRCdisableLL() )
{
rpcSlice->setTSResidualCodingDisabledFlag( true );
}
#else
rpcSlice->setTSResidualCodingDisabledFlag( true );
#endif
}
#else
#if JVET_R0143_TSRCdisableLL
if( ( m_pcCfg->getCostMode() == COST_LOSSLESS_CODING ) && m_pcCfg->getTSRCdisableLL() )
#else
......@@ -351,6 +376,7 @@ void EncSlice::initEncSlice(Picture* pcPic, const int pocLast, const int pocCurr
{
rpcSlice->setTSResidualCodingDisabledFlag(false);
}
#endif
#if SHARP_LUMA_DELTA_QP
pcPic->fieldPic = isField;
......
......@@ -1862,6 +1862,7 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader, bool writeRbspTrailingB
}
#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
// dependent quantization
if (sps->getDepQuantEnabledFlag())
{
......@@ -1880,6 +1881,7 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader, bool writeRbspTrailingB
{
picHeader->setSignDataHidingEnabledFlag(false);
}
#endif
// deblocking filter controls
if (pps->getDeblockingFilterControlPresentFlag())
......@@ -2330,7 +2332,35 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice )
pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( 0 );
}
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
// dependent quantization
if( pcSlice->getSPS()->getDepQuantEnabledFlag() )
{
WRITE_FLAG(pcSlice->getDepQuantEnabledFlag(), "slice_dep_quant_enabled_flag");
}
else
{
pcSlice->setDepQuantEnabledFlag(false);
}
// sign data hiding
if( pcSlice->getSPS()->getSignDataHidingEnabledFlag() && !pcSlice->getDepQuantEnabledFlag() )
{
WRITE_FLAG(pcSlice->getSignDataHidingEnabledFlag(), "slice_sign_data_hiding_enabled_flag" );
}
else
{
pcSlice->setSignDataHidingEnabledFlag(false);
}
// signal TS residual coding disabled flag
if( !pcSlice->getDepQuantEnabledFlag() && !pcSlice->getSignDataHidingEnabledFlag() )
{
WRITE_FLAG(pcSlice->getTSResidualCodingDisabledFlag() ? 1 : 0, "slice_ts_residual_coding_disabled_flag");
}
#else
WRITE_FLAG(pcSlice->getTSResidualCodingDisabledFlag() ? 1 : 0, "slice_ts_residual_coding_disabled_flag");
#endif
if (picHeader->getLmcsEnabledFlag())
{
......
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