Commit dfbee4a5 authored by Biao Wang's avatar Biao Wang
Browse files

Merge branch 'R0156_proposal3' into 'master'

# Conflicts:
#   source/Lib/CommonLib/TypeDef.h
parents 617f0c88 3ec165d4
......@@ -20,3 +20,5 @@ BIO : 0
PROF : 0
Log2MaxTbSize : 5
InternalBitDepth : 0
TSRCdisableLL : 1
ColorTransform : 1
Log2MaxTbSize : 5
\ No newline at end of file
Log2MaxTbSize : 5
DualITree: 0
\ No newline at end of file
......@@ -2660,6 +2660,12 @@ Specifies location of a chroma sample relatively to the luma sample in vertical
\end{tabular}
\\
\Option{TSRCdisableLL} &
%\ShortOption{\None} &
\Default{1} &
Enables or disables the use of Transform Skip Residual Coding for lossless compression.
\\
\end{OptionTableNoShorthand}
%%
......
......@@ -748,6 +748,9 @@ void EncApp::xInitLibCfg()
m_cEncLib.setInitialCpbFullness ( m_RCInitialCpbFullness );
#endif
m_cEncLib.setCostMode ( m_costMode );
#if JVET_R0143_TSRCdisableLL
m_cEncLib.setTSRCdisableLL ( m_TSRCdisableLL );
#endif
m_cEncLib.setUseRecalculateQPAccordingToLambda ( m_recalculateQPAccordingToLambda );
m_cEncLib.setDCIEnabled ( m_DCIEnabled );
m_cEncLib.setVuiParametersPresentFlag ( m_vuiParametersPresentFlag );
......
......@@ -1138,6 +1138,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
( "RCInitialCpbFullness", m_RCInitialCpbFullness, 0.9, "Rate control: initial CPB fullness" )
#endif
("CostMode", m_costMode, COST_STANDARD_LOSSY, "Use alternative cost functions: choose between 'lossy', 'sequence_level_lossless', 'lossless' (which forces QP to " MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP) ") and 'mixed_lossless_lossy' (which used QP'=" MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME) " for pre-estimates of transquant-bypass blocks).")
#if JVET_R0143_TSRCdisableLL
("TSRCdisableLL", m_TSRCdisableLL, true, "Disable TSRC for lossless coding" )
#endif
("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
("HrdParametersPresent,-hrd", m_hrdParametersPresentFlag, false, "Enable generation of hrd_parameters()")
("VuiParametersPresent,-vui", m_vuiParametersPresentFlag, false, "Enable generation of vui_parameters()")
......
......@@ -622,6 +622,9 @@ protected:
std::string m_scalingListFileName; ///< quantization matrix file name
bool m_disableScalingMatrixForLfnstBlks;
CostMode m_costMode; ///< Cost mode to use
#if JVET_R0143_TSRCdisableLL
bool m_TSRCdisableLL; ///< disable TSRC for lossless
#endif
bool m_recalculateQPAccordingToLambda; ///< recalculate QP value according to the lambda value
......
......@@ -1262,7 +1262,11 @@ void AdaptiveLoopFilter::filterBlk(AlfClassifier **classifier, const PelUnitBuf
}
else
{
#if JVET_R0208_ALF_VB_ROUNDING_FIX
sum = (sum + (1 << ((shift + 3) - 1))) >> (shift + 3);
#else
sum = (sum + offset) >> (shift + 3);
#endif
}
sum += curr;
pRec1[jj] = ClipPel( sum, clpRng );
......@@ -1341,6 +1345,12 @@ void AdaptiveLoopFilter::filterBlkCcAlf(const PelBuf &dstBuf, const CPelUnitBuf
const Pel *srcCross = lumaPtr + col + row * lumaStride;
int pos = ((startHeight + i + ii) << scaleY) & (vbCTUHeight - 1);
#if JVET_R0233_CCALF_LINE_BUFFER_REDUCTION
if (scaleY == 0 && (pos == vbPos || pos == vbPos + 1))
{
continue;
}
#endif
if (pos == (vbPos - 2) || pos == (vbPos + 1))
{
offset3 = offset1;
......
......@@ -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,9 +52,18 @@
//########### 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
#define JVET_Q0471_CHROMA_QT_SPLIT 1 // JVET-Q0471: Chroma QT split
#define JVET_R0208_ALF_VB_ROUNDING_FIX 1 // JVET-R0208: Rounding offset fix for ALF virtual boundary processing
#define JVET_R0232_CCALF_APS_CONSTRAINT 1 // JVET-R0232 section 3.2: APS contraint for CCALF
#define JVET_R0156_ASPECT3_SPS_CLEANUP 1 // Condition sps_sublayer_dpb_params_flag on sps_ptl_dpb_hrd_params_present_flag, in addition to sps_max_sublayer_minus1, JVET-R0156 proposal 3, JVET-R0170, JVET-R0222 proposal 2
//########### place macros to be be kept below this line ###############
#define JVET_M0497_MATRIX_MULT 0 // 0: Fast method; 1: Matrix multiplication
......
#if ! defined( VTM_VERSION )
#define VTM_VERSION "8.1"
#define VTM_VERSION "8.2"
#endif
......@@ -313,6 +313,9 @@ static void simdFilter5x5Blk(AlfClassifier **classifier, const PelUnitBuf &recDs
constexpr int SHIFT = AdaptiveLoopFilter::m_NUM_BITS - 1;
constexpr int ROUND = 1 << (SHIFT - 1);
#if JVET_R0208_ALF_VB_ROUNDING_FIX
const __m128i mmOffset1 = _mm_set1_epi32((1 << ((SHIFT + 3) - 1)) - ROUND);
#endif
const size_t width = blk.width;
const size_t height = blk.height;
......@@ -425,8 +428,13 @@ static void simdFilter5x5Blk(AlfClassifier **classifier, const PelUnitBuf &recDs
}
else
{
#if JVET_R0208_ALF_VB_ROUNDING_FIX
accumA = _mm_srai_epi32(_mm_add_epi32(accumA, mmOffset1), SHIFT + 3);
accumB = _mm_srai_epi32(_mm_add_epi32(accumB, mmOffset1), SHIFT + 3);
#else
accumA = _mm_srai_epi32(accumA, SHIFT + 3);
accumB = _mm_srai_epi32(accumB, SHIFT + 3);
#endif
}
accumA = _mm_packs_epi32(accumA, accumB);
accumA = _mm_add_epi16(accumA, cur);
......@@ -507,6 +515,9 @@ static void simdFilter7x7Blk(AlfClassifier **classifier, const PelUnitBuf &recDs
Pel * dst = dstBuffer.buf + blkDst.y * dstStride + blkDst.x;
const __m128i mmOffset = _mm_set1_epi32(ROUND);
#if JVET_R0208_ALF_VB_ROUNDING_FIX
const __m128i mmOffset1 = _mm_set1_epi32((1 << ((SHIFT + 3) - 1)) - ROUND);
#endif
const __m128i mmMin = _mm_set1_epi16( clpRng.min );
const __m128i mmMax = _mm_set1_epi16( clpRng.max );
......@@ -655,8 +666,13 @@ static void simdFilter7x7Blk(AlfClassifier **classifier, const PelUnitBuf &recDs
}
else
{
#if JVET_R0208_ALF_VB_ROUNDING_FIX
accumA = _mm_srai_epi32(_mm_add_epi32(accumA, mmOffset1), SHIFT + 3);
accumB = _mm_srai_epi32(_mm_add_epi32(accumB, mmOffset1), SHIFT + 3);
#else
accumA = _mm_srai_epi32(accumA, SHIFT + 3);
accumB = _mm_srai_epi32(accumB, SHIFT + 3);
#endif
}
accumA = _mm_packs_epi32(accumA, accumB);
accumA = _mm_add_epi16(accumA, cur);
......
......@@ -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;
......
......@@ -980,6 +980,9 @@ bool DecLib::isSliceNaluFirstInAU( bool newPicture, InputNALUnit &nalu )
void activateAPS(PicHeader* picHeader, Slice* pSlice, ParameterSetManager& parameterSetManager, APS** apss, APS* lmcsAPS, APS* scalingListAPS)
{
#if JVET_R0232_CCALF_APS_CONSTRAINT
const SPS *sps = parameterSetManager.getSPS(picHeader->getSPSId());
#endif
//luma APSs
if (pSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y))
{
......@@ -998,6 +1001,10 @@ void activateAPS(PicHeader* picHeader, Slice* pSlice, ParameterSetManager& param
CHECK( aps->getTemporalId() > pSlice->getTLayer(), "TemporalId shall be less than or equal to the TemporalId of the coded slice NAL unit" );
//ToDO: APS NAL unit containing the APS RBSP shall have nuh_layer_id either equal to the nuh_layer_id of a coded slice NAL unit that referrs it, or equal to the nuh_layer_id of a direct dependent layer of the layer containing a coded slice NAL unit that referrs it.
#if JVET_R0232_CCALF_APS_CONSTRAINT
CHECK(((sps->getCCALFEnabledFlag() == false) && (aps->getCcAlfAPSParam().newCcAlfFilter[0] || aps->getCcAlfAPSParam().newCcAlfFilter[1])), "When sps_ccalf_enabled_flag is 0, the values of alf_cc_cb_filter_signal_flag and alf_cc_cr_filter_signal_flag shall be equal to 0");
#endif
}
}
}
......@@ -1016,6 +1023,10 @@ void activateAPS(PicHeader* picHeader, Slice* pSlice, ParameterSetManager& param
CHECK( aps->getTemporalId() > pSlice->getTLayer(), "TemporalId shall be less than or equal to the TemporalId of the coded slice NAL unit" );
//ToDO: APS NAL unit containing the APS RBSP shall have nuh_layer_id either equal to the nuh_layer_id of a coded slice NAL unit that referrs it, or equal to the nuh_layer_id of a direct dependent layer of the layer containing a coded slice NAL unit that referrs it.
#if JVET_R0232_CCALF_APS_CONSTRAINT
CHECK(((sps->getCCALFEnabledFlag() == false) && (aps->getCcAlfAPSParam().newCcAlfFilter[0] || aps->getCcAlfAPSParam().newCcAlfFilter[1])), "When sps_ccalf_enabled_flag is 0, the values of alf_cc_cb_filter_signal_flag and alf_cc_cr_filter_signal_flag shall be equal to 0");
#endif
}
}
......@@ -1381,7 +1392,7 @@ void DecLib::xCheckParameterSetConstraints(const int layerId)
CHECK( sps->getSubPicInfoPresentFlag() != 0, "When res_change_in_clvs_allowed_flag is equal to 1, the value of subpic_info_present_flag shall be equal to 0." );
}
CHECK( sps->getRprEnabledFlag() && 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" );
CHECK( sps->getRprEnabledFlag() && sps->getVirtualBoundariesPresentFlag(), "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" );
if( sps->getCTUSize() + 2 * ( 1 << sps->getLog2MinCodingBlockSize() ) > pps->getPicWidthInLumaSamples() )
{
......
......@@ -2822,6 +2822,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag
}
#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
// dependent quantization
if (sps->getDepQuantEnabledFlag())
{
......@@ -2843,6 +2844,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag
{
picHeader->setSignDataHidingEnabledFlag(false);
}
#endif
// deblocking filter controls
if (pps->getDeblockingFilterControlPresentFlag())
......@@ -3719,8 +3721,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;
......
......@@ -4014,6 +4014,12 @@ void EncAdaptiveLoopFilter::getBlkStatsCcAlf(AlfCovariance &alfCovariance, const
for (int i = 0; i < compArea.height; i++)
{
int vbDistance = ((i << getComponentScaleY(compID, m_chromaFormat)) % vbCTUHeight) - vbPos;
#if JVET_R0233_CCALF_LINE_BUFFER_REDUCTION
if ((getComponentScaleY(compID, m_chromaFormat) == 0) && (vbDistance == 0 || vbDistance == 1))
{
continue;
}
#endif
for (int j = 0; j < compArea.width; j++)
{
std::memset(ELocal, 0, sizeof(ELocal));
......
......@@ -651,7 +651,9 @@ protected:
double m_RCInitialCpbFullness;
#endif
CostMode m_costMode; ///< The cost function to use, primarily when considering lossless coding.
#if JVET_R0143_TSRCdisableLL
bool m_TSRCdisableLL; ///< Disable TSRC for lossless
#endif
DCI m_dci;
bool m_DCIEnabled; ///< enable Decoding Capability Information (DCI)
......@@ -1687,8 +1689,10 @@ public:
#endif
CostMode getCostMode( ) const { return m_costMode; }
void setCostMode(CostMode m ) { m_costMode = m; }
#if JVET_R0143_TSRCdisableLL
bool getTSRCdisableLL () { return m_TSRCdisableLL; }
void setTSRCdisableLL ( bool b ) { m_TSRCdisableLL = b; }
#endif
void setDCI(DCI *p) { m_dci = *p; }
DCI* getDCI() { return &m_dci; }
......
......@@ -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,7 +339,36 @@ 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
if( m_pcCfg->getCostMode() == COST_LOSSLESS_CODING )
#endif
{
rpcSlice->setTSResidualCodingDisabledFlag(true);
}
......@@ -347,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;
......
......@@ -1870,6 +1870,7 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader, bool writeRbspTrailingB
}
#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
// dependent quantization
if (sps->getDepQuantEnabledFlag())
{
......@@ -1888,6 +1889,7 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader, bool writeRbspTrailingB
{
picHeader->setSignDataHidingEnabledFlag(false);
}
#endif
// deblocking filter controls
if (pps->getDeblockingFilterControlPresentFlag())
......@@ -2338,7 +2340,35 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice )
pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( 0 );
}
#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC
// dependent quantization