diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index d9958dc74da0e6207bc983f1ac39202cfa796b12..52739b85d24a2cd5c5812dce188085c7ba793c21 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -1495,6 +1495,17 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) { m_switchPocPeriod = m_iFrameRate / 2 / m_iGOPSize * m_iGOPSize; } + + //Check the given value of intra period and decoding refresh type. If intra period is -1, set decoding refresh type to be equal to 0. And vice versa + if( m_iIntraPeriod == -1 ) + { + m_iDecodingRefreshType = 0; + } + if( !m_iDecodingRefreshType ) + { + m_iIntraPeriod = -1; + } + m_bpDeltasGOPStructure = false; if(m_iGOPSize == 16) { diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h index 7a12869f82d6d20c21e71ec5f44661a77643644f..bcc61b490c9e284641fef7fa98158d72febb5f75 100644 --- a/source/Lib/EncoderLib/EncCfg.h +++ b/source/Lib/EncoderLib/EncCfg.h @@ -241,8 +241,8 @@ protected: bool m_intraConstraintFlag; //====== Coding Structure ======== - int m_uiIntraPeriod; // needs to be signed to allow '-1' for no intra period - uint32_t m_uiDecodingRefreshType; ///< the type of decoding refresh employed for the random access. + int m_intraPeriod; // needs to be signed to allow '-1' for no intra period + uint32_t m_decodingRefreshType; ///< the type of decoding refresh employed for the random access. bool m_rewriteParamSets; bool m_idrRefParamList; int m_iGOPSize; @@ -922,8 +922,8 @@ public: void setCabacZeroWordPaddingEnabled(bool value) { m_cabacZeroWordPaddingEnabled = value; } //====== Coding Structure ======== - void setIntraPeriod (int i) { m_uiIntraPeriod = i; } - void setDecodingRefreshType ( int i ) { m_uiDecodingRefreshType = (uint32_t)i; } + void setIntraPeriod (int i) { m_intraPeriod = i; } + void setDecodingRefreshType ( int i ) { m_decodingRefreshType = (uint32_t)i; } void setReWriteParamSets ( bool b ) { m_rewriteParamSets = b; } void setIDRRefParamListPresent ( bool b ) { m_idrRefParamList = b; } bool getIDRRefParamListPresent () const { return m_idrRefParamList; } @@ -1310,8 +1310,8 @@ public: double getIntraQpFactor () const { return m_dIntraQpFactor; } //==== Coding Structure ======== - uint32_t getIntraPeriod () const { return m_uiIntraPeriod; } - uint32_t getDecodingRefreshType () const { return m_uiDecodingRefreshType; } + int getIntraPeriod () const { return m_intraPeriod; } + uint32_t getDecodingRefreshType () const { return m_decodingRefreshType; } bool getReWriteParamSets () const { return m_rewriteParamSets; } int getGOPSize () const { return m_iGOPSize; } int getMaxDecPicBuffering (uint32_t tlayer) { return m_maxDecPicBuffering[tlayer]; } diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 24713abe5883292145ef83bae1fa2e5a9346a180..09c470337f82450c19e3210b452a7cecbcf6fc96 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -2137,6 +2137,10 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, pcSlice->setLastIDR(m_iLastIDR); pcSlice->setIndependentSliceIdx(0); + if (pcSlice->getPOC() && m_pcCfg->getIntraPeriod() != 1) + { + pcSlice->setSliceType(m_pcCfg->getGOPEntry(iGOPid).m_sliceType == 'I' ? I_SLICE : (m_pcCfg->getGOPEntry(iGOPid).m_sliceType == 'B' ? B_SLICE : P_SLICE) ); + } if(pcSlice->getSliceType()==B_SLICE&&m_pcCfg->getGOPEntry(iGOPid).m_sliceType=='P') { @@ -2146,6 +2150,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, { pcSlice->setSliceType(I_SLICE); } + pcSlice->setTLayer(m_pcCfg->getGOPEntry(iGOPid).m_temporalId); #if JVET_Q0819_PH_CHANGES // set two flags according to slice type presented in the picture @@ -2404,6 +2409,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, { pcSlice->setSliceType ( P_SLICE ); } + xUpdateRasInit( pcSlice ); if ( pcSlice->getPendingRasInit() ) diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index fd84e4ceadcbcb77dc302fd559473c5cfccb91fc..13dec156d12510d67aba65faef6cdbab903c2ba1 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -678,7 +678,7 @@ bool EncLib::encodePrep( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYu } #endif - if( m_rprEnabled && m_uiIntraPeriod == -1 ) + if( m_rprEnabled && m_intraPeriod == -1 ) { const int poc = m_iPOCLast + ( m_compositeRefEnabled ? 2 : 1 ); @@ -1484,7 +1484,7 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) sps.getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag(m_persistentRiceAdaptationEnabledFlag); sps.getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag(m_cabacBypassAlignmentEnabledFlag); - if( m_uiIntraPeriod < 0 ) + if( m_intraPeriod < 0 ) { sps.setRPL1CopyFromRPL0Flag( true ); } @@ -2188,7 +2188,7 @@ void EncLib::xInitRPL(SPS &sps, bool isFieldCoding) void EncLib::getActiveRefPicListNumForPOC(const SPS *sps, int POCCurr, int GOPid, uint32_t *activeL0, uint32_t *activeL1) { - if (m_uiIntraPeriod < 0) //Only for RA + if (m_intraPeriod < 0) //Only for RA { *activeL0 = *activeL1 = 0; return; @@ -2199,7 +2199,7 @@ void EncLib::getActiveRefPicListNumForPOC(const SPS *sps, int POCCurr, int GOPid int fullListNum = m_iGOPSize; int partialListNum = getRPLCandidateSize(0) - m_iGOPSize; int extraNum = fullListNum; - if (m_uiIntraPeriod < 0) + if (m_intraPeriod < 0) { if (POCCurr < (2 * m_iGOPSize + 2)) { @@ -2215,11 +2215,13 @@ void EncLib::getActiveRefPicListNumForPOC(const SPS *sps, int POCCurr, int GOPid } for (; extraNum<fullListNum + partialListNum; extraNum++) { - if (m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) + if (m_intraPeriod > 0 && getDecodingRefreshType() > 0) { - int POCIndex = POCCurr%m_uiIntraPeriod; + int POCIndex = POCCurr % m_intraPeriod; if (POCIndex == 0) - POCIndex = m_uiIntraPeriod; + { + POCIndex = m_intraPeriod; + } if (POCIndex == m_RPLList0[extraNum].m_POC) { rpl0Idx = extraNum; @@ -2249,7 +2251,17 @@ void EncLib::selectReferencePictureList(Slice* slice, int POCCurr, int GOPid, in int fullListNum = m_iGOPSize; int partialListNum = getRPLCandidateSize(0) - m_iGOPSize; int extraNum = fullListNum; - if (m_uiIntraPeriod < 0) + + int rplPeriod = m_intraPeriod; + if( rplPeriod < 0 ) //Need to check if it is low delay or RA but with no RAP + { + if( slice->getSPS()->getRPLList0()->getReferencePictureList(1)->getRefPicIdentifier(0) * slice->getSPS()->getRPLList1()->getReferencePictureList(1)->getRefPicIdentifier(0) < 0) + { + rplPeriod = m_iGOPSize * 2; + } + } + + if (rplPeriod < 0) { if (POCCurr < (2 * m_iGOPSize + 2)) { @@ -2265,11 +2277,13 @@ void EncLib::selectReferencePictureList(Slice* slice, int POCCurr, int GOPid, in } for (; extraNum < fullListNum + partialListNum; extraNum++) { - if (m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) + if( rplPeriod > 0 ) { - int POCIndex = POCCurr%m_uiIntraPeriod; + int POCIndex = POCCurr % rplPeriod; if (POCIndex == 0) - POCIndex = m_uiIntraPeriod; + { + POCIndex = rplPeriod; + } if (POCIndex == m_RPLList0[extraNum].m_POC) { slice->setRPL0idx(extraNum); @@ -2287,7 +2301,7 @@ void EncLib::selectReferencePictureList(Slice* slice, int POCCurr, int GOPid, in slice->setRPL0idx(getRPLCandidateSize(0)); slice->setRPL1idx(getRPLCandidateSize(0)); } - else if (m_uiIntraPeriod < 0) + else if( rplPeriod < 0 ) { // To set RPL indexes for LD int numRPLCandidates = getRPLCandidateSize(0);