From 84d9e16a4593d2078461869fa2bbb17b20488f04 Mon Sep 17 00:00:00 2001 From: vdrugeon <virginie.drugeon@eu.panasonic.com> Date: Fri, 25 Oct 2019 13:13:45 +0200 Subject: [PATCH] JVET-P0206 Signalling TMVP usage Removal of pps_temporal_mvp_enabled_idc and constraint that slice_temporal_mvp_enabled_flag has to be equal to 0 if there are no reference pictures with the same resolution as the current picture --- source/App/EncoderApp/EncApp.cpp | 2 ++ source/App/EncoderApp/EncAppCfg.cpp | 10 +++++++++- source/App/EncoderApp/EncAppCfg.h | 2 ++ source/Lib/CommonLib/Slice.cpp | 21 +++++++++++++++++++++ source/Lib/CommonLib/Slice.h | 4 ++++ source/Lib/CommonLib/TypeDef.h | 2 ++ source/Lib/DecoderLib/VLCReader.cpp | 12 ++++++++++++ source/Lib/EncoderLib/EncCfg.h | 4 ++++ source/Lib/EncoderLib/EncGOP.cpp | 6 ++++++ source/Lib/EncoderLib/EncLib.cpp | 2 ++ source/Lib/EncoderLib/VLCWriter.cpp | 6 ++++++ 11 files changed, 70 insertions(+), 1 deletion(-) diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index 2a971fe45f..e7e6ee4e5e 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -555,7 +555,9 @@ void EncApp::xInitLibCfg() m_cEncLib.setPPSDepQuantEnabledIdc ( m_PPSDepQuantEnabledIdc ); m_cEncLib.setPPSRefPicListSPSIdc0 ( m_PPSRefPicListSPSIdc0 ); m_cEncLib.setPPSRefPicListSPSIdc1 ( m_PPSRefPicListSPSIdc1 ); +#if !JVET_P0206_TMVP_flags m_cEncLib.setPPSTemporalMVPEnabledIdc ( m_PPSTemporalMVPEnabledIdc ); +#endif m_cEncLib.setPPSMvdL1ZeroIdc ( m_PPSMvdL1ZeroIdc ); m_cEncLib.setPPSCollocatedFromL0Idc ( m_PPSCollocatedFromL0Idc ); m_cEncLib.setPPSSixMinusMaxNumMergeCandPlus1 ( m_PPSSixMinusMaxNumMergeCandPlus1 ); diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index 4ac5792b00..635e0046c1 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -3256,7 +3256,9 @@ bool EncAppCfg::xCheckParameter() m_PPSDepQuantEnabledIdc = 0; m_PPSRefPicListSPSIdc0 = 0; m_PPSRefPicListSPSIdc1 = 0; +#if !JVET_P0206_TMVP_flags m_PPSTemporalMVPEnabledIdc = 0; +#endif m_PPSMvdL1ZeroIdc = 0; m_PPSCollocatedFromL0Idc = 0; m_PPSSixMinusMaxNumMergeCandPlus1 = 0; @@ -3268,7 +3270,9 @@ bool EncAppCfg::xCheckParameter() m_PPSDepQuantEnabledIdc = (m_depQuantEnabledFlag ? 1 : 0) + 1; m_PPSRefPicListSPSIdc0 = 0; m_PPSRefPicListSPSIdc1 = 0; +#if !JVET_P0206_TMVP_flags m_PPSTemporalMVPEnabledIdc = 0; +#endif m_PPSMvdL1ZeroIdc = 0; m_PPSCollocatedFromL0Idc = 0; m_PPSSixMinusMaxNumMergeCandPlus1 = 6 - m_maxNumMergeCand + 1; @@ -3280,7 +3284,9 @@ bool EncAppCfg::xCheckParameter() m_PPSDepQuantEnabledIdc = (m_depQuantEnabledFlag ? 1 : 0) + 1; m_PPSRefPicListSPSIdc0 = 2; m_PPSRefPicListSPSIdc1 = 2; - m_PPSTemporalMVPEnabledIdc = m_TMVPModeId == 2 ? 0: ( int(m_TMVPModeId == 1 ? 1: 0) + 1); +#if !JVET_P0206_TMVP_flags + m_PPSTemporalMVPEnabledIdc = m_TMVPModeId == 2 ? 0: ( int(m_TMVPModeId == 1 ? 1: 0) + 1); +#endif m_PPSMvdL1ZeroIdc = 2; m_PPSCollocatedFromL0Idc = 1; m_PPSSixMinusMaxNumMergeCandPlus1 = 6 - m_maxNumMergeCand + 1; @@ -3292,7 +3298,9 @@ bool EncAppCfg::xCheckParameter() m_PPSDepQuantEnabledIdc = (m_depQuantEnabledFlag ? 1 : 0) + 1; m_PPSRefPicListSPSIdc0 = 2; m_PPSRefPicListSPSIdc1 = 2; +#if !JVET_P0206_TMVP_flags m_PPSTemporalMVPEnabledIdc = m_TMVPModeId == 2 ? 0: ( int(m_TMVPModeId == 1 ? 1: 0) + 1); +#endif m_PPSMvdL1ZeroIdc = 0; m_PPSCollocatedFromL0Idc = 0; m_PPSSixMinusMaxNumMergeCandPlus1 = 6 - m_maxNumMergeCand + 1; diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h index 7ae720a425..a59199b487 100644 --- a/source/App/EncoderApp/EncAppCfg.h +++ b/source/App/EncoderApp/EncAppCfg.h @@ -541,7 +541,9 @@ protected: int m_PPSDepQuantEnabledIdc; int m_PPSRefPicListSPSIdc0; int m_PPSRefPicListSPSIdc1; +#if !JVET_P0206_TMVP_flags int m_PPSTemporalMVPEnabledIdc; +#endif int m_PPSMvdL1ZeroIdc; int m_PPSCollocatedFromL0Idc; uint32_t m_PPSSixMinusMaxNumMergeCandPlus1; diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index ffd2e91274..0b607527ab 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -1816,7 +1816,9 @@ PPS::PPS() , m_PPSDepQuantEnabledIdc (0) , m_PPSRefPicListSPSIdc0 (0) , m_PPSRefPicListSPSIdc1 (0) +#if !JVET_P0206_TMVP_flags , m_PPSTemporalMVPEnabledIdc (0) +#endif , m_PPSMvdL1ZeroIdc (0) , m_PPSCollocatedFromL0Idc (0) , m_PPSSixMinusMaxNumMergeCandPlus1 (0) @@ -2506,6 +2508,10 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], APS** apss, APS* lmcsAps, const SPS* sps = getSPS(); const PPS* pps = getPPS(); +#if JVET_P0206_TMVP_flags + bool refPicIsSameRes = false; +#endif + // this is needed for IBC m_pcPic->unscaledPic = m_pcPic; @@ -2532,6 +2538,13 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], APS** apss, APS* lmcsAps, CU::getRprScaling( sps, pps, m_apcRefPicList[refList][rIdx], xScale, yScale ); m_scalingRatio[refList][rIdx] = std::pair<int, int>( xScale, yScale ); +#if JVET_P0206_TMVP_flags + if( m_scalingRatio[refList][rIdx] == SCALE_1X ) + { + refPicIsSameRes = true; + } +#endif + if( m_scalingRatio[refList][rIdx] == SCALE_1X || isDecoder ) { m_scaledRefPicList[refList][rIdx] = m_apcRefPicList[refList][rIdx]; @@ -2617,6 +2630,14 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], APS** apss, APS* lmcsAps, m_apcRefPicList[refList][rIdx]->unscaledPic = m_savedRefPicList[refList][rIdx]; } } + +#if JVET_P0206_TMVP_flags + //Make sure that TMVP is disabled when there are no reference pictures with the same resolution + if(!refPicIsSameRes) + { + CHECK(m_enableTMVPFlag != 0, "TMVP cannot be enabled in slices that have no reference pictures with the same resolution") + } +#endif } void Slice::freeScaledRefPicList( Picture *scaledRefPic[] ) diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index 0e6ebc9e3c..dc98597b86 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -1239,7 +1239,9 @@ private: int m_PPSDepQuantEnabledIdc; int m_PPSRefPicListSPSIdc0; int m_PPSRefPicListSPSIdc1; +#if !JVET_P0206_TMVP_flags int m_PPSTemporalMVPEnabledIdc; +#endif int m_PPSMvdL1ZeroIdc; int m_PPSCollocatedFromL0Idc; uint32_t m_PPSSixMinusMaxNumMergeCandPlus1; @@ -1439,8 +1441,10 @@ public: void setPPSRefPicListSPSIdc0(int u) { m_PPSRefPicListSPSIdc0 = u; } int getPPSRefPicListSPSIdc1() const { return m_PPSRefPicListSPSIdc1; } void setPPSRefPicListSPSIdc1(int u) { m_PPSRefPicListSPSIdc1 = u; } +#if !JVET_P0206_TMVP_flags int getPPSTemporalMVPEnabledIdc() const { return m_PPSTemporalMVPEnabledIdc; } void setPPSTemporalMVPEnabledIdc(int u) { m_PPSTemporalMVPEnabledIdc = u; } +#endif int getPPSMvdL1ZeroIdc() const { return m_PPSMvdL1ZeroIdc; } void setPPSMvdL1ZeroIdc(int u) { m_PPSMvdL1ZeroIdc = u; } int getPPSCollocatedFromL0Idc() const { return m_PPSCollocatedFromL0Idc; } diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index e626ef8e89..3e28c218c0 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,6 +50,8 @@ #include <assert.h> #include <cassert> +#define JVET_P0206_TMVP_flags 1 // JVET-P0206: Signalling TMVP usage (remove pps TMVP idc and constraint when RPR is used) + #define JVET_P1026_MTS_SIGNALLING 1 // JVET-P1026: CU level MTS signalling #define JVET_P0571_FIX_BS_BDPCM_CHROMA 1 // JVET-P0571: align boundary strength for Chroma BDPCM diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 57a95bd077..4a220e1062 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -405,7 +405,9 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana READ_CODE( 2, uiCode, "pps_dep_quant_enabled_idc"); pcPPS->setPPSDepQuantEnabledIdc(uiCode); READ_CODE( 2, uiCode, "pps_ref_pic_list_sps_idc[0]"); pcPPS->setPPSRefPicListSPSIdc0(uiCode); READ_CODE( 2, uiCode, "pps_ref_pic_list_sps_idc[1]"); pcPPS->setPPSRefPicListSPSIdc1(uiCode); +#if !JVET_P0206_TMVP_flags READ_CODE( 2, uiCode, "pps_temporal_mvp_enabled_idc"); pcPPS->setPPSTemporalMVPEnabledIdc(uiCode); +#endif READ_CODE( 2, uiCode, "pps_mvd_l1_zero_idc"); pcPPS->setPPSMvdL1ZeroIdc(uiCode); READ_CODE( 2, uiCode, "pps_collocated_from_l0_idc"); pcPPS->setPPSCollocatedFromL0Idc(uiCode); READ_UVLC( uiCode, "pps_six_minus_max_num_merge_cand_plus1"); pcPPS->setPPSSixMinusMaxNumMergeCandPlus1(uiCode); @@ -417,7 +419,9 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana pcPPS->setPPSDepQuantEnabledIdc(0); pcPPS->setPPSRefPicListSPSIdc0(0); pcPPS->setPPSRefPicListSPSIdc1(0); +#if !JVET_P0206_TMVP_flags pcPPS->setPPSTemporalMVPEnabledIdc(0); +#endif pcPPS->setPPSMvdL1ZeroIdc(0); pcPPS->setPPSCollocatedFromL0Idc(0); pcPPS->setPPSSixMinusMaxNumMergeCandPlus1(0); @@ -2080,13 +2084,20 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para if(!pcSlice->isIntra()) { +#if JVET_P0206_TMVP_flags + if (sps->getSPSTemporalMVPEnabledFlag()) +#else if (sps->getSPSTemporalMVPEnabledFlag() && !pps->getPPSTemporalMVPEnabledIdc()) +#endif { READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); pcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); } else { +#if JVET_P0206_TMVP_flags + pcSlice->setEnableTMVPFlag(false); +#else if (!sps->getSPSTemporalMVPEnabledFlag()) { pcSlice->setEnableTMVPFlag(false); @@ -2095,6 +2106,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para { pcSlice->setEnableTMVPFlag((pps->getPPSTemporalMVPEnabledIdc() - 1) == 1 ? true: false); } +#endif } } diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h index 40b26e02a8..ed1aeefd96 100644 --- a/source/Lib/EncoderLib/EncCfg.h +++ b/source/Lib/EncoderLib/EncCfg.h @@ -587,7 +587,9 @@ protected: int m_PPSDepQuantEnabledIdc; int m_PPSRefPicListSPSIdc0; int m_PPSRefPicListSPSIdc1; +#if !JVET_P0206_TMVP_flags int m_PPSTemporalMVPEnabledIdc; +#endif int m_PPSMvdL1ZeroIdc; int m_PPSCollocatedFromL0Idc; uint32_t m_PPSSixMinusMaxNumMergeCandPlus1; @@ -1503,8 +1505,10 @@ public: int getPPSRefPicListSPSIdc0 () { return m_PPSRefPicListSPSIdc0; } void setPPSRefPicListSPSIdc1 ( int u ) { m_PPSRefPicListSPSIdc1 = u; } int getPPSRefPicListSPSIdc1 () { return m_PPSRefPicListSPSIdc1; } +#if !JVET_P0206_TMVP_flags void setPPSTemporalMVPEnabledIdc ( int u ) { m_PPSTemporalMVPEnabledIdc = u; } int getPPSTemporalMVPEnabledIdc () { return m_PPSTemporalMVPEnabledIdc; } +#endif void setPPSMvdL1ZeroIdc ( int u ) { m_PPSMvdL1ZeroIdc = u; } int getPPSMvdL1ZeroIdc () { return m_PPSMvdL1ZeroIdc; } void setPPSCollocatedFromL0Idc ( int u ) { m_PPSCollocatedFromL0Idc = u; } diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 82f664742f..eb349662a3 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -2319,7 +2319,9 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, if (m_pcEncLib->getTMVPModeId() == 2) { +#if !JVET_P0206_TMVP_flags assert (m_pcEncLib->getPPSTemporalMVPEnabledIdc() == 0); +#endif if (iGOPid == 0) // first picture in SOP (i.e. forward B) { pcSlice->setEnableTMVPFlag(0); @@ -2330,7 +2332,11 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, pcSlice->setEnableTMVPFlag(1); } } +#if JVET_P0206_TMVP_flags + else if (m_pcEncLib->getTMVPModeId() == 1) +#else else if (m_pcEncLib->getTMVPModeId() == 1 && m_pcEncLib->getPPSTemporalMVPEnabledIdc() != 1) +#endif { pcSlice->setEnableTMVPFlag(1); } diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 63718467c9..37a1184f73 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -1165,7 +1165,9 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) pps.setPPSDepQuantEnabledIdc(getPPSDepQuantEnabledIdc()); pps.setPPSRefPicListSPSIdc0(getPPSRefPicListSPSIdc0()); pps.setPPSRefPicListSPSIdc1(getPPSRefPicListSPSIdc1()); +#if !JVET_P0206_TMVP_flags pps.setPPSTemporalMVPEnabledIdc(getPPSTemporalMVPEnabledIdc()); +#endif pps.setPPSMvdL1ZeroIdc(getPPSMvdL1ZeroIdc()); pps.setPPSCollocatedFromL0Idc(getPPSCollocatedFromL0Idc()); pps.setPPSSixMinusMaxNumMergeCandPlus1(getPPSSixMinusMaxNumMergeCandPlus1()); diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 00b0513d6d..d5d10ce270 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -236,7 +236,9 @@ void HLSWriter::codePPS( const PPS* pcPPS, const SPS* pcSPS ) WRITE_CODE( pcPPS->getPPSDepQuantEnabledIdc(), 2, "pps_dep_quant_enabled_idc"); WRITE_CODE( pcPPS->getPPSRefPicListSPSIdc0(), 2, "pps_ref_pic_list_sps_idc[0]"); WRITE_CODE( pcPPS->getPPSRefPicListSPSIdc1(), 2, "pps_ref_pic_list_sps_idc[1]"); +#if !JVET_P0206_TMVP_flags WRITE_CODE( pcPPS->getPPSTemporalMVPEnabledIdc(), 2, "pps_temporal_mvp_enabled_idc"); +#endif WRITE_CODE( pcPPS->getPPSMvdL1ZeroIdc(), 2, "pps_mvd_l1_zero_idc"); WRITE_CODE( pcPPS->getPPSCollocatedFromL0Idc(), 2, "pps_collocated_from_l0_idc"); WRITE_UVLC( pcPPS->getPPSSixMinusMaxNumMergeCandPlus1(), "pps_six_minus_max_num_merge_cand_plus1"); @@ -1318,7 +1320,11 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) if(!pcSlice->isIntra()) { +#if JVET_P0206_TMVP_flags + if( pcSlice->getSPS()->getSPSTemporalMVPEnabledFlag()) +#else if( pcSlice->getSPS()->getSPSTemporalMVPEnabledFlag() && !pcSlice->getPPS()->getPPSTemporalMVPEnabledIdc() ) +#endif { WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" ); } -- GitLab