diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp index 1e35ab2fa557689283adec96e6724e730d556044..297ee59d7ee9e68975379673323e97371dc7745c 100644 --- a/source/App/DecoderApp/DecApp.cpp +++ b/source/App/DecoderApp/DecApp.cpp @@ -157,7 +157,11 @@ uint32_t DecApp::decode() (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP)) { +#if JVET_N0278_FIXES + xFlushOutput( pcListPic, nalu.m_nuhLayerId ); +#else xFlushOutput(pcListPic); +#endif } if ((m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) || !isNaluTheTargetLayer(&nalu)) @@ -499,7 +503,11 @@ void DecApp::xWriteOutput( PicList* pcListPic, uint32_t tId ) /** \param pcListPic list of pictures to be written to file */ +#if JVET_N0278_FIXES +void DecApp::xFlushOutput( PicList* pcListPic, const int layerId ) +#else void DecApp::xFlushOutput( PicList* pcListPic ) +#endif { if(!pcListPic || pcListPic->empty()) { @@ -521,6 +529,13 @@ void DecApp::xFlushOutput( PicList* pcListPic ) iterPic++; pcPicBottom = *(iterPic); +#if JVET_N0278_FIXES + if( pcPicTop->layerId != layerId && layerId != NOT_VALID ) + { + continue; + } +#endif + if ( pcPicTop->neededForOutput && pcPicBottom->neededForOutput && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) ) { // write to file @@ -575,6 +590,14 @@ void DecApp::xFlushOutput( PicList* pcListPic ) { pcPic = *(iterPic); +#if JVET_N0278_FIXES + if( pcPic->layerId != layerId && layerId != NOT_VALID ) + { + iterPic++; + continue; + } +#endif + if (pcPic->neededForOutput) { // write to file @@ -625,6 +648,20 @@ void DecApp::xFlushOutput( PicList* pcListPic ) iterPic++; } } + +#if JVET_N0278_FIXES + if( layerId != NOT_VALID ) + { + for( iterPic = pcListPic->begin(); iterPic != pcListPic->end(); iterPic++ ) + { + if( *iterPic == nullptr ) + { + pcListPic->erase( iterPic ); + } + } + } + else +#endif pcListPic->clear(); m_iPOCLastDisplay = -MAX_INT; } diff --git a/source/App/DecoderApp/DecApp.h b/source/App/DecoderApp/DecApp.h index dd34063c1e17bb7e27aa8689557fa5824b2c90f4..edb03919f4002a41dbd2c4f7c3ebe6f5ddb9443f 100644 --- a/source/App/DecoderApp/DecApp.h +++ b/source/App/DecoderApp/DecApp.h @@ -80,7 +80,11 @@ private: void xCreateDecLib (); ///< create internal classes void xDestroyDecLib (); ///< destroy internal classes void xWriteOutput ( PicList* pcListPic , uint32_t tId); ///< write YUV to file +#if JVET_N0278_FIXES + void xFlushOutput( PicList* pcListPic, const int layerId = NOT_VALID ); ///< flush all remaining decoded pictures to file +#else void xFlushOutput ( PicList* pcListPic ); ///< flush all remaining decoded pictures to file +#endif bool isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet bool isNaluTheTargetLayer(InputNALUnit* nalu); ///< check whether given Nalu is within targetDecLayerIdSet }; diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index 170584b5b2a5aa893a76c1453e90ddf027eaa699..f4a89ad74322e85675703066c75342803fa63100 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -653,7 +653,7 @@ void EncApp::xInitLibCfg() } #if JVET_N0278_FIXES -void EncApp::xCreateLib( std::list<PelUnitBuf*>& recBufList, const int layerIdx ) +void EncApp::xCreateLib( std::list<PelUnitBuf*>& recBufList, const int layerId ) #else void EncApp::xCreateLib( std::list<PelUnitBuf*>& recBufList ) #endif @@ -683,7 +683,7 @@ void EncApp::xCreateLib( std::list<PelUnitBuf*>& recBufList ) // create the encoder #if JVET_N0278_FIXES - m_cEncLib.create( layerIdx ); + m_cEncLib.create( layerId ); #else m_cEncLib.create(); #endif @@ -715,7 +715,7 @@ void EncApp::xInitLib(bool isFieldCoding) // ==================================================================================================================== #if JVET_N0278_FIXES -void EncApp::createLib( const int layerIdx ) +void EncApp::createLib( const int layerId ) { const int sourceHeight = m_isField ? m_iSourceHeightOrg : m_iSourceHeight; UnitArea unitArea( m_chromaFormatIDC, Area( 0, 0, m_iSourceWidth, sourceHeight ) ); @@ -739,7 +739,7 @@ void EncApp::createLib( const int layerIdx ) // initialize internal class & member variables xInitLibCfg(); - xCreateLib( m_recBufList, layerIdx ); + xCreateLib( m_recBufList, layerId ); xInitLib( m_isField ); printChromaFormat(); diff --git a/source/App/EncoderApp/EncApp.h b/source/App/EncoderApp/EncApp.h index 524fff63a2401c30574bd4faf6778fd6173b51e9..27097c40c97ce29e94634a4c523d747b0b28dbdf 100644 --- a/source/App/EncoderApp/EncApp.h +++ b/source/App/EncoderApp/EncApp.h @@ -80,7 +80,7 @@ private: private: // initialization #if JVET_N0278_FIXES - void xCreateLib( std::list<PelUnitBuf*>& recBufList, const int layerIdx ); ///< create files & encoder class + void xCreateLib( std::list<PelUnitBuf*>& recBufList, const int layerId ); ///< create files & encoder class #else void xCreateLib ( std::list<PelUnitBuf*>& recBufList ); ///< create files & encoder class #endif @@ -111,7 +111,7 @@ public: #if JVET_N0278_FIXES int getMaxLayers() const { return m_maxLayers; } - void createLib( int layerIdx ); ///< main encoding function + void createLib( int layerId ); ///< main encoding function void destroyLib(); ///< main encoding function bool encode(); ///< main encoding function #else diff --git a/source/App/EncoderApp/encmain.cpp b/source/App/EncoderApp/encmain.cpp index 8648d05294b66f3b1770df355e4c73270e355f81..80e134010da9b84b481ad72fad638c72735d98ba 100644 --- a/source/App/EncoderApp/encmain.cpp +++ b/source/App/EncoderApp/encmain.cpp @@ -142,7 +142,8 @@ int main(int argc, char* argv[]) return 1; } - pcEncApp[i]->createLib( i ); + int layerId = i; //VS: layerIdx i should be converted to layerId after VPS is implemented + pcEncApp[i]->createLib( layerId ); if( !resized ) { diff --git a/source/Lib/CommonLib/Picture.cpp b/source/Lib/CommonLib/Picture.cpp index 423877804f76775371d0484f3733769708e0e380..211ff53f87cbf47c98afaf0c6c4fd309e7d728a5 100644 --- a/source/Lib/CommonLib/Picture.cpp +++ b/source/Lib/CommonLib/Picture.cpp @@ -802,18 +802,18 @@ Picture::Picture() m_spliceIdx = NULL; m_ctuNums = 0; #if JVET_N0278_FIXES - layerIdx = NOT_VALID; + layerId = NOT_VALID; #endif } #if JVET_N0278_FIXES -void Picture::create( const ChromaFormat &_chromaFormat, const Size &size, const unsigned _maxCUSize, const unsigned _margin, const bool _decoder, const int _layerIdx ) +void Picture::create( const ChromaFormat &_chromaFormat, const Size &size, const unsigned _maxCUSize, const unsigned _margin, const bool _decoder, const int _layerId ) #else void Picture::create(const ChromaFormat &_chromaFormat, const Size &size, const unsigned _maxCUSize, const unsigned _margin, const bool _decoder) #endif { #if JVET_N0278_FIXES - layerIdx = _layerIdx; + layerId = _layerId; #endif UnitArea::operator=( UnitArea( _chromaFormat, Area( Position{ 0, 0 }, size ) ) ); margin = _margin; diff --git a/source/Lib/CommonLib/Picture.h b/source/Lib/CommonLib/Picture.h index 8f739accc4b2147ea414a9ec37479488288240ae..8bf09f2fb04a19ace263b3ec2ae5a441815d730f 100644 --- a/source/Lib/CommonLib/Picture.h +++ b/source/Lib/CommonLib/Picture.h @@ -198,7 +198,7 @@ struct Picture : public UnitArea Picture(); #if JVET_N0278_FIXES - void create( const ChromaFormat &_chromaFormat, const Size &size, const unsigned _maxCUSize, const unsigned margin, const bool bDecoder, const int layerIdx ); + void create( const ChromaFormat &_chromaFormat, const Size &size, const unsigned _maxCUSize, const unsigned margin, const bool bDecoder, const int layerId ); #else void create(const ChromaFormat &_chromaFormat, const Size &size, const unsigned _maxCUSize, const unsigned margin, const bool bDecoder); #endif @@ -277,7 +277,7 @@ public: uint32_t layer; uint32_t depth; #if JVET_N0278_FIXES - int layerIdx; + int layerId; #endif int* m_spliceIdx; diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 75c0c917a8ebfcf283cf2b3d6403dd6fe301bd03..cd8cb26580b8cc2cd7fc84a837c4ef395813081c 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -270,7 +270,7 @@ void Slice::sortPicList (PicList& rcListPic) } #if JVET_N0278_FIXES -Picture* Slice::xGetRefPic( PicList& rcListPic, int poc, const int layerIdx ) +Picture* Slice::xGetRefPic( PicList& rcListPic, int poc, const int layerId ) #else Picture* Slice::xGetRefPic (PicList& rcListPic, int poc) #endif @@ -281,7 +281,7 @@ Picture* Slice::xGetRefPic (PicList& rcListPic, int poc) while ( iterPic != rcListPic.end() ) { #if JVET_N0278_FIXES - if( pcPic->getPOC() == poc && pcPic->layerIdx == layerIdx ) + if( pcPic->getPOC() == poc && pcPic->layerId == layerId ) #else if(pcPic->getPOC() == poc) #endif @@ -295,7 +295,7 @@ Picture* Slice::xGetRefPic (PicList& rcListPic, int poc) } #if JVET_N0278_FIXES -Picture* Slice::xGetLongTermRefPic( PicList& rcListPic, int poc, bool pocHasMsb, const int layerIdx ) +Picture* Slice::xGetLongTermRefPic( PicList& rcListPic, int poc, bool pocHasMsb, const int layerId ) #else Picture* Slice::xGetLongTermRefPic( PicList& rcListPic, int poc, bool pocHasMsb) #endif @@ -314,7 +314,7 @@ Picture* Slice::xGetLongTermRefPic( PicList& rcListPic, int poc, bool pocHasMsb) { pcPic = *(iterPic); #if JVET_N0278_FIXES - if( pcPic && pcPic->getPOC() != this->getPOC() && pcPic->referenced && pcPic->layerIdx == layerIdx ) + if( pcPic && pcPic->getPOC() != this->getPOC() && pcPic->referenced && pcPic->layerId == layerId ) #else if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->referenced) #endif @@ -393,7 +393,7 @@ void Slice::constructRefPicList(PicList& rcListPic) if (!m_pRPL0->isRefPicLongterm(ii)) { #if JVET_N0278_FIXES - pcRefPic = xGetRefPic( rcListPic, getPOC() - m_pRPL0->getRefPicIdentifier( ii ), m_pcPic->layerIdx ); + pcRefPic = xGetRefPic( rcListPic, getPOC() - m_pRPL0->getRefPicIdentifier( ii ), m_pcPic->layerId ); #else pcRefPic = xGetRefPic(rcListPic, getPOC() - m_pRPL0->getRefPicIdentifier(ii)); #endif @@ -406,7 +406,7 @@ void Slice::constructRefPicList(PicList& rcListPic) int ltrpPoc = m_pRPL0->getRefPicIdentifier(ii) & pocMask; ltrpPoc += m_localRPL0.getDeltaPocMSBPresentFlag(ii) ? (pocMask + 1) * m_localRPL0.getDeltaPocMSBCycleLT(ii) : 0; #if JVET_N0278_FIXES - pcRefPic = xGetLongTermRefPic( rcListPic, ltrpPoc, m_localRPL0.getDeltaPocMSBPresentFlag( ii ), m_pcPic->layerIdx ); + pcRefPic = xGetLongTermRefPic( rcListPic, ltrpPoc, m_localRPL0.getDeltaPocMSBPresentFlag( ii ), m_pcPic->layerId ); #else pcRefPic = xGetLongTermRefPic(rcListPic, ltrpPoc, m_localRPL0.getDeltaPocMSBPresentFlag(ii)); #endif @@ -424,7 +424,7 @@ void Slice::constructRefPicList(PicList& rcListPic) if (!m_pRPL1->isRefPicLongterm(ii)) { #if JVET_N0278_FIXES - pcRefPic = xGetRefPic( rcListPic, getPOC() - m_pRPL1->getRefPicIdentifier( ii ), m_pcPic->layerIdx ); + pcRefPic = xGetRefPic( rcListPic, getPOC() - m_pRPL1->getRefPicIdentifier( ii ), m_pcPic->layerId ); #else pcRefPic = xGetRefPic(rcListPic, getPOC() - m_pRPL1->getRefPicIdentifier(ii)); #endif @@ -437,7 +437,7 @@ void Slice::constructRefPicList(PicList& rcListPic) int ltrpPoc = m_pRPL1->getRefPicIdentifier(ii) & pocMask; ltrpPoc += m_localRPL1.getDeltaPocMSBPresentFlag(ii) ? (pocMask + 1) * m_localRPL1.getDeltaPocMSBCycleLT(ii) : 0; #if JVET_N0278_FIXES - pcRefPic = xGetLongTermRefPic( rcListPic, ltrpPoc, m_localRPL1.getDeltaPocMSBPresentFlag( ii ), m_pcPic->layerIdx ); + pcRefPic = xGetLongTermRefPic( rcListPic, ltrpPoc, m_localRPL1.getDeltaPocMSBPresentFlag( ii ), m_pcPic->layerId ); #else pcRefPic = xGetLongTermRefPic(rcListPic, ltrpPoc, m_localRPL1.getDeltaPocMSBPresentFlag(ii)); #endif @@ -501,7 +501,7 @@ void Slice::checkCRA(const ReferencePictureList *pRPL0, const ReferencePictureLi else { #if JVET_N0278_FIXES - CHECK( xGetLongTermRefPic( rcListPic, pRPL0->getRefPicIdentifier( i ), pRPL0->getDeltaPocMSBPresentFlag( i ), m_pcPic->layerIdx )->getPOC() < pocCRA, "Invalid state" ); + CHECK( xGetLongTermRefPic( rcListPic, pRPL0->getRefPicIdentifier( i ), pRPL0->getDeltaPocMSBPresentFlag( i ), m_pcPic->layerId )->getPOC() < pocCRA, "Invalid state" ); #else CHECK(xGetLongTermRefPic(rcListPic, pRPL0->getRefPicIdentifier(i), pRPL0->getDeltaPocMSBPresentFlag(i))->getPOC() < pocCRA, "Invalid state"); #endif @@ -517,7 +517,7 @@ void Slice::checkCRA(const ReferencePictureList *pRPL0, const ReferencePictureLi else { #if JVET_N0278_FIXES - CHECK( xGetLongTermRefPic( rcListPic, pRPL1->getRefPicIdentifier( i ), pRPL1->getDeltaPocMSBPresentFlag( i ), m_pcPic->layerIdx )->getPOC() < pocCRA, "Invalid state" ); + CHECK( xGetLongTermRefPic( rcListPic, pRPL1->getRefPicIdentifier( i ), pRPL1->getDeltaPocMSBPresentFlag( i ), m_pcPic->layerId )->getPOC() < pocCRA, "Invalid state" ); #else CHECK(xGetLongTermRefPic(rcListPic, pRPL1->getRefPicIdentifier(i), pRPL1->getDeltaPocMSBPresentFlag(i))->getPOC() < pocCRA, "Invalid state"); #endif @@ -2617,7 +2617,7 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], APS** apss, APS* lmcsAps, scaledRefPic[j]->poc = -1; #if JVET_N0278_FIXES - scaledRefPic[j]->create( sps->getChromaFormatIdc(), Size( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples() ), sps->getMaxCUWidth(), sps->getMaxCUWidth() + 16, isDecoder, m_pcPic->layerIdx ); + scaledRefPic[j]->create( sps->getChromaFormatIdc(), Size( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples() ), sps->getMaxCUWidth(), sps->getMaxCUWidth() + 16, isDecoder, m_pcPic->layerId ); #else scaledRefPic[j]->create( sps->getChromaFormatIdc(), Size( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples() ), sps->getMaxCUWidth(), sps->getMaxCUWidth() + 16, isDecoder ); #endif diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index 6482ccdb128454718a0026dcc1d23ba3d6a04ce2..a4e00845f98d189d34460553851af484ed846ec7 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -2008,8 +2008,8 @@ public: protected: #if JVET_N0278_FIXES - Picture* xGetRefPic( PicList& rcListPic, int poc, const int layerIdx ); - Picture* xGetLongTermRefPic( PicList& rcListPic, int poc, bool pocHasMsb, const int layerIdx ); + Picture* xGetRefPic( PicList& rcListPic, int poc, const int layerId ); + Picture* xGetLongTermRefPic( PicList& rcListPic, int poc, bool pocHasMsb, const int layerId ); #else Picture* xGetRefPic (PicList& rcListPic, int poc); Picture* xGetLongTermRefPic(PicList& rcListPic, int poc, bool pocHasMsb); diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index 2156c122ee47e7b312bd79a3d7ca5b618b1e9322..9c24b102e4e92160dd4b1f8ae295f3ebc001cd08 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -482,7 +482,7 @@ void DecLib::deletePicBuffer ( ) } #if JVET_N0278_FIXES -Picture* DecLib::xGetNewPicBuffer( const SPS &sps, const PPS &pps, const uint32_t temporalLayer, const int layerIdx ) +Picture* DecLib::xGetNewPicBuffer( const SPS &sps, const PPS &pps, const uint32_t temporalLayer, const int layerId ) #else Picture* DecLib::xGetNewPicBuffer ( const SPS &sps, const PPS &pps, const uint32_t temporalLayer ) #endif @@ -494,7 +494,7 @@ Picture* DecLib::xGetNewPicBuffer ( const SPS &sps, const PPS &pps, const uint32 pcPic = new Picture(); #if JVET_N0278_FIXES - pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true, layerIdx ); + pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true, layerId ); #else pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true ); #endif @@ -534,7 +534,7 @@ Picture* DecLib::xGetNewPicBuffer ( const SPS &sps, const PPS &pps, const uint32 m_cListPic.push_back( pcPic ); #if JVET_N0278_FIXES - pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true, layerIdx ); + pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true, layerId ); #else pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true ); #endif @@ -545,7 +545,7 @@ Picture* DecLib::xGetNewPicBuffer ( const SPS &sps, const PPS &pps, const uint32 { pcPic->destroy(); #if JVET_N0278_FIXES - pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true, layerIdx ); + pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true, layerId ); #else pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true ); #endif @@ -632,7 +632,11 @@ void DecLib::finishPicture(int& poc, PicList*& rpcListPic, MsgLevel msgl ) if (pcSlice->isDRAP()) c = 'D'; //-- For time output for each slice +#if JVET_N0278_FIXES + msg( msgl, "POC %4d LId: %2d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(), pcSlice->getPic()->layerId, +#else msg( msgl, "POC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(), +#endif pcSlice->getTLayer(), c, pcSlice->getSliceQp() ); @@ -717,14 +721,14 @@ void DecLib::xUpdateRasInit(Slice* slice) } #if JVET_N0278_FIXES -void DecLib::xCreateLostPicture( int iLostPoc, const int layerIdx ) +void DecLib::xCreateLostPicture( int iLostPoc, const int layerId ) #else void DecLib::xCreateLostPicture(int iLostPoc) #endif { msg( INFO, "\ninserting lost poc : %d\n",iLostPoc); #if JVET_N0278_FIXES - Picture *cFillPic = xGetNewPicBuffer( *( m_parameterSetManager.getFirstSPS() ), *( m_parameterSetManager.getFirstPPS() ), 0, layerIdx ); + Picture *cFillPic = xGetNewPicBuffer( *( m_parameterSetManager.getFirstSPS() ), *( m_parameterSetManager.getFirstPPS() ), 0, layerId ); #else Picture *cFillPic = xGetNewPicBuffer(*(m_parameterSetManager.getFirstSPS()), *(m_parameterSetManager.getFirstPPS()), 0); #endif @@ -769,14 +773,14 @@ void DecLib::xCreateLostPicture(int iLostPoc) } #if JVET_N0278_FIXES -void DecLib::xCreateUnavailablePicture( int iUnavailablePoc, bool longTermFlag, const int layerIdx ) +void DecLib::xCreateUnavailablePicture( int iUnavailablePoc, bool longTermFlag, const int layerId ) #else void DecLib::xCreateUnavailablePicture(int iUnavailablePoc, bool longTermFlag) #endif { msg(INFO, "\ninserting unavailable poc : %d\n", iUnavailablePoc); #if JVET_N0278_FIXES - Picture* cFillPic = xGetNewPicBuffer( *( m_parameterSetManager.getFirstSPS() ), *( m_parameterSetManager.getFirstPPS() ), 0, layerIdx ); + Picture* cFillPic = xGetNewPicBuffer( *( m_parameterSetManager.getFirstSPS() ), *( m_parameterSetManager.getFirstPPS() ), 0, layerId ); #else Picture* cFillPic = xGetNewPicBuffer(*(m_parameterSetManager.getFirstSPS()), *(m_parameterSetManager.getFirstPPS()), 0); #endif @@ -885,7 +889,7 @@ void activateAPS(Slice* pSlice, ParameterSetManager& parameterSetManager, APS** } #if JVET_N0278_FIXES -void DecLib::xActivateParameterSets( const int layerIdx ) +void DecLib::xActivateParameterSets( const int layerId ) #else void DecLib::xActivateParameterSets() #endif @@ -935,7 +939,7 @@ void DecLib::xActivateParameterSets() // Get a new picture buffer. This will also set up m_pcPic, and therefore give us a SPS and PPS pointer that we can use. #if JVET_N0278_FIXES - m_pcPic = xGetNewPicBuffer( *sps, *pps, m_apcSlicePilot->getTLayer(), layerIdx ); + m_pcPic = xGetNewPicBuffer( *sps, *pps, m_apcSlicePilot->getTLayer(), layerId ); #else m_pcPic = xGetNewPicBuffer (*sps, *pps, m_apcSlicePilot->getTLayer()); #endif @@ -1317,7 +1321,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl if ( ( (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR) || (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) ) && m_apcSlicePilot->getNoIncorrectPicOutputFlag() ) { #if JVET_N0278_FIXES - xCreateUnavailablePicture( lostPoc - 1, m_apcSlicePilot->getRPL0()->isRefPicLongterm( refPicIndex ), m_apcSlicePilot->getPic()->layerIdx ); + xCreateUnavailablePicture( lostPoc - 1, m_apcSlicePilot->getRPL0()->isRefPicLongterm( refPicIndex ), m_apcSlicePilot->getPic()->layerId ); #else xCreateUnavailablePicture(lostPoc - 1, m_apcSlicePilot->getRPL0()->isRefPicLongterm(refPicIndex)); #endif @@ -1325,7 +1329,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl else { #if JVET_N0278_FIXES - xCreateLostPicture( lostPoc - 1, m_apcSlicePilot->getPic()->layerIdx ); + xCreateLostPicture( lostPoc - 1, m_apcSlicePilot->getPic()->layerId ); #else xCreateLostPicture(lostPoc - 1); #endif @@ -1336,7 +1340,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl if (((m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR) || (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) && m_apcSlicePilot->getNoIncorrectPicOutputFlag()) { #if JVET_N0278_FIXES - xCreateUnavailablePicture( lostPoc - 1, m_apcSlicePilot->getRPL1()->isRefPicLongterm( refPicIndex ), m_apcSlicePilot->getPic()->layerIdx ); + xCreateUnavailablePicture( lostPoc - 1, m_apcSlicePilot->getRPL1()->isRefPicLongterm( refPicIndex ), m_apcSlicePilot->getPic()->layerId ); #else xCreateUnavailablePicture(lostPoc - 1, m_apcSlicePilot->getRPL1()->isRefPicLongterm(refPicIndex)); #endif @@ -1344,7 +1348,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl else { #if JVET_N0278_FIXES - xCreateLostPicture( lostPoc - 1, m_apcSlicePilot->getPic()->layerIdx ); + xCreateLostPicture( lostPoc - 1, m_apcSlicePilot->getPic()->layerId ); #else xCreateLostPicture(lostPoc - 1); #endif @@ -1361,7 +1365,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl // actual decoding starts here #if JVET_N0278_FIXES - xActivateParameterSets( m_apcSlicePilot->getPic()->layerIdx ); + xActivateParameterSets( nalu.m_nuhLayerId ); #else xActivateParameterSets(); #endif @@ -1376,6 +1380,9 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl m_pcPic->layer = pcSlice->getTLayer(); m_pcPic->referenced = true; m_pcPic->layer = nalu.m_temporalId; +#if JVET_N0278_FIXES + m_pcPic->layerId = nalu.m_nuhLayerId; +#endif if (pcSlice->getPPS()->getRectSliceFlag()) { diff --git a/source/Lib/DecoderLib/DecLib.h b/source/Lib/DecoderLib/DecLib.h index 106aad11dc4fa7e0ef506689bd1903d80e2c4ecd..55bb97d0ed8b6d25999945f120a22d596d86ebe5 100644 --- a/source/Lib/DecoderLib/DecLib.h +++ b/source/Lib/DecoderLib/DecLib.h @@ -174,10 +174,10 @@ protected: void xUpdateRasInit(Slice* slice); #if JVET_N0278_FIXES - Picture * xGetNewPicBuffer( const SPS &sps, const PPS &pps, const uint32_t temporalLayer, const int layerIdx ); - void xCreateLostPicture( int iLostPOC, const int layerIdx ); - void xCreateUnavailablePicture( int iUnavailablePoc, bool longTermFlag, const int layerIdx ); - void xActivateParameterSets( const int layerIdx ); + Picture * xGetNewPicBuffer( const SPS &sps, const PPS &pps, const uint32_t temporalLayer, const int layerId ); + void xCreateLostPicture( int iLostPOC, const int layerId ); + void xCreateUnavailablePicture( int iUnavailablePoc, bool longTermFlag, const int layerId ); + void xActivateParameterSets( const int layerId ); #else Picture * xGetNewPicBuffer(const SPS &sps, const PPS &pps, const uint32_t temporalLayer); void xCreateLostPicture (int iLostPOC); diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 73c982430a929b61cbdd9a9d249f223cbf394846..f0492686faee55093663dcc972f565d4b675498e 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -338,7 +338,7 @@ int EncGOP::xWriteSPS (AccessUnit &accessUnit, const SPS *sps) { OutputNALUnit nalu(NAL_UNIT_SPS); m_HLSWriter->setBitstream( &nalu.m_Bitstream ); - CHECK( nalu.m_temporalId, "The value of TemporalId of DPS NAL units shall be equal to 0" ); + CHECK( nalu.m_temporalId, "The value of TemporalId of SPS NAL units shall be equal to 0" ); m_HLSWriter->codeSPS( sps ); accessUnit.push_back(new NALUnitEBSP(nalu)); return (int)(accessUnit.back()->m_nalUnitData.str().size()) * 8; @@ -388,7 +388,11 @@ int EncGOP::xWriteParameterSets (AccessUnit &accessUnit, Slice *slice, const boo } if (m_pcEncLib->PPSNeedsWriting(slice->getPPS()->getPPSId())) // Note this assumes that all changes to the PPS are made at the EncLib level prior to picture creation (EncLib::xGetNewPicBuffer). { +#if JVET_N0278_FIXES + actualTotalBits += xWritePPS( accessUnit, slice->getPPS(), slice->getSPS(), m_pcEncLib->getLayerId() ); +#else actualTotalBits += xWritePPS(accessUnit, slice->getPPS(), slice->getSPS()); +#endif } return actualTotalBits; @@ -2882,7 +2886,11 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, bool writeAPS = aps && apsMap->getChangedFlag((apsId << NUM_APS_TYPE_LEN) + LMCS_APS); if (writeAPS) { +#if JVET_N0278_FIXES + actualTotalBits += xWriteAPS( accessUnit, aps, m_pcEncLib->getLayerId() ); +#else actualTotalBits += xWriteAPS(accessUnit, aps); +#endif apsMap->clearChangedFlag((apsId << NUM_APS_TYPE_LEN) + LMCS_APS); CHECK(aps != pcSlice->getLmcsAPS(), "Wrong LMCS APS pointer in compressGOP"); } @@ -2897,7 +2905,11 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, bool writeAPS = aps && apsMap->getChangedFlag( ( apsId << NUM_APS_TYPE_LEN ) + SCALING_LIST_APS ); if( writeAPS ) { +#if JVET_N0278_FIXES + actualTotalBits += xWriteAPS( accessUnit, aps, m_pcEncLib->getLayerId() ); +#else actualTotalBits += xWriteAPS( accessUnit, aps ); +#endif apsMap->clearChangedFlag( ( apsId << NUM_APS_TYPE_LEN ) + SCALING_LIST_APS ); CHECK( aps != pcSlice->getscalingListAPS(), "Wrong SCALING LIST APS pointer in compressGOP" ); } @@ -2921,7 +2933,11 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, if (writeAPS ) { +#if JVET_N0278_FIXES + actualTotalBits += xWriteAPS( accessUnit, aps, m_pcEncLib->getLayerId() ); +#else actualTotalBits += xWriteAPS(accessUnit, aps); +#endif apsMap->clearChangedFlag((apsId << NUM_APS_TYPE_LEN) + ALF_APS); CHECK(aps != pcSlice->getAlfAPSs()[apsId], "Wrong APS pointer in compressGOP"); } @@ -2957,7 +2973,11 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, } /* start slice NALunit */ +#if JVET_N0278_FIXES + OutputNALUnit nalu( pcSlice->getNalUnitType(), m_pcEncLib->getLayerId(), pcSlice->getTLayer() ); +#else OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->getTLayer() ); +#endif m_HLSWriter->setBitstream( &nalu.m_Bitstream ); pcSlice->setNoIncorrectPicOutputFlag(false); @@ -3059,9 +3079,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, m_pcCfg->setEncodedFlag(iGOPid, true); double PSNR_Y; - xCalculateAddPSNRs(isField, isTff, iGOPid, pcPic, accessUnit, rcListPic, encTime, snr_conversion, printFrameMSE, &PSNR_Y - , isEncodeLtRef - ); + xCalculateAddPSNRs(isField, isTff, iGOPid, pcPic, accessUnit, rcListPic, encTime, snr_conversion, printFrameMSE, &PSNR_Y, isEncodeLtRef ); #if HEVC_SEI // Only produce the Green Metadata SEI message with the last picture. @@ -3339,7 +3357,7 @@ void EncGOP::xGetBuffer( PicList& rcListPic, { rpcPic = *(iterPic); #if JVET_N0278_FIXES - if( rpcPic->getPOC() == pocCurr && rpcPic->layerIdx == m_pcEncLib->getLayerIdx() ) + if( rpcPic->getPOC() == pocCurr && rpcPic->layerId == m_pcEncLib->getLayerId() ) #else if (rpcPic->getPOC() == pocCurr) #endif @@ -3882,8 +3900,14 @@ void EncGOP::xCalculateAddPSNR(Picture* pcPic, PelUnitBuf cPicD, const AccessUni if( g_verbosity >= NOTICE ) { +#if JVET_N0278_FIXES + msg( NOTICE, "POC %4d LId: %2d TId: %1d ( %c-SLICE, QP %d ) %10d bits", + pcSlice->getPOC(), + pcSlice->getPic()->layerId, +#else msg( NOTICE, "POC %4d TId: %1d ( %c-SLICE, QP %d ) %10d bits", pcSlice->getPOC(), +#endif pcSlice->getTLayer(), c, pcSlice->getSliceQp(), diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 67dd378dce9b90c0fc52638fed82602d47e20c09..ad27ab778807ef7624eabcdec69758422fb6338e 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -57,13 +57,20 @@ #if JVET_N0278_FIXES PicList EncLib::m_cListPic; +ParameterSetMap<SPS> EncLib::m_spsMap( MAX_NUM_SPS ); +ParameterSetMap<PPS> EncLib::m_ppsMap( MAX_NUM_PPS ); +ParameterSetMap<APS> EncLib::m_apsMap( MAX_NUM_APS * MAX_NUM_APS_TYPE ); #endif EncLib::EncLib() +#if JVET_N0278_FIXES + : m_AUWriterIf( nullptr ) +#else : m_spsMap( MAX_NUM_SPS ) , m_ppsMap( MAX_NUM_PPS ) , m_apsMap(MAX_NUM_APS * MAX_NUM_APS_TYPE) , m_AUWriterIf( nullptr ) +#endif #if JVET_J0090_MEMORY_BANDWITH_MEASURE , m_cacheModel() #endif @@ -88,7 +95,7 @@ EncLib::EncLib() memset(m_apss, 0, sizeof(m_apss)); #if JVET_N0278_FIXES - m_layerIdx = NOT_VALID; + m_layerId = NOT_VALID; #endif } @@ -97,13 +104,13 @@ EncLib::~EncLib() } #if JVET_N0278_FIXES -void EncLib::create( const int layerIdx ) +void EncLib::create( const int layerId ) #else void EncLib::create () #endif { #if JVET_N0278_FIXES - m_layerIdx = layerIdx; + m_layerId = layerId; #endif // initialize global variables initROM(); @@ -424,7 +431,7 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) { Picture *picBg = new Picture; #if JVET_N0278_FIXES - picBg->create( sps0.getChromaFormatIdc(), Size( pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples() ), sps0.getMaxCUWidth(), sps0.getMaxCUWidth() + 16, false, m_layerIdx ); + picBg->create( sps0.getChromaFormatIdc(), Size( pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples() ), sps0.getMaxCUWidth(), sps0.getMaxCUWidth() + 16, false, m_layerId ); #else picBg->create( sps0.getChromaFormatIdc(), Size( pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples() ), sps0.getMaxCUWidth(), sps0.getMaxCUWidth() + 16, false ); #endif @@ -436,7 +443,7 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) m_cGOPEncoder.setPicBg(picBg); Picture *picOrig = new Picture; #if JVET_N0278_FIXES - picOrig->create( sps0.getChromaFormatIdc(), Size( pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples() ), sps0.getMaxCUWidth(), sps0.getMaxCUWidth() + 16, false, m_layerIdx ); + picOrig->create( sps0.getChromaFormatIdc(), Size( pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples() ), sps0.getMaxCUWidth(), sps0.getMaxCUWidth() + 16, false, m_layerId ); #else picOrig->create( sps0.getChromaFormatIdc(), Size( pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples() ), sps0.getMaxCUWidth(), sps0.getMaxCUWidth() + 16, false ); #endif @@ -859,7 +866,7 @@ void EncLib::xGetNewPicBuffer ( std::list<PelUnitBuf*>& rcListPicYuvRecOut, Pict { rpcPic = new Picture; #if JVET_N0278_FIXES - rpcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, false, m_layerIdx ); + rpcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, false, m_layerId ); #else rpcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, false ); #endif diff --git a/source/Lib/EncoderLib/EncLib.h b/source/Lib/EncoderLib/EncLib.h index c44db0627012f89b97ee44031a739380b8d71f9d..c1eac8ea953fc898392eb7ef24125ab1d7ccea6a 100644 --- a/source/Lib/EncoderLib/EncLib.h +++ b/source/Lib/EncoderLib/EncLib.h @@ -75,7 +75,7 @@ private: uint32_t m_uiNumAllPicCoded; ///< number of coded pictures #if JVET_N0278_FIXES static PicList m_cListPic; ///< dynamic list of pictures - int m_layerIdx; + int m_layerId; #else PicList m_cListPic; ///< dynamic list of pictures #endif @@ -119,9 +119,15 @@ private: EncCu m_cCuEncoder; ///< CU encoder #endif // SPS +#if JVET_N0278_FIXES + static ParameterSetMap<SPS> m_spsMap; ///< SPS. This is the base value. This is copied to PicSym + static ParameterSetMap<PPS> m_ppsMap; ///< PPS. This is the base value. This is copied to PicSym + static ParameterSetMap<APS> m_apsMap; ///< APS. This is the base value. This is copied to PicSym +#else ParameterSetMap<SPS> m_spsMap; ///< SPS. This is the base value. This is copied to PicSym ParameterSetMap<PPS> m_ppsMap; ///< PPS. This is the base value. This is copied to PicSym ParameterSetMap<APS> m_apsMap; ///< APS. This is the base value. This is copied to PicSym +#endif // RD cost computation #if ENABLE_SPLIT_PARALLELISM || ENABLE_WPP_PARALLELISM RdCost *m_cRdCost; ///< RD cost computation class @@ -182,7 +188,7 @@ public: virtual ~EncLib(); #if JVET_N0278_FIXES - void create ( const int layerIdx ); + void create ( const int layerId ); #else void create (); #endif @@ -283,7 +289,7 @@ public: void printSummary( bool isField ) { m_cGOPEncoder.printOutSummary( m_uiNumAllPicCoded, isField, m_printMSEBasedSequencePSNR, m_printSequenceMSE, m_printHexPsnr, m_rprEnabled, m_spsMap.getFirstPS()->getBitDepths() ); } #if JVET_N0278_FIXES - int getLayerIdx() const { return m_layerIdx; } + int getLayerId() const { return m_layerId; } #endif }; diff --git a/source/Lib/EncoderLib/NALwrite.h b/source/Lib/EncoderLib/NALwrite.h index b107a2f4c3425e7d3d123c25372e7946bbc1140a..78e5bbd8d99f07858059bc8cf173463235a242fe 100644 --- a/source/Lib/EncoderLib/NALwrite.h +++ b/source/Lib/EncoderLib/NALwrite.h @@ -58,9 +58,16 @@ struct OutputNALUnit : public NALUnit */ OutputNALUnit( NalUnitType nalUnitType, +#if JVET_N0278_FIXES + uint32_t layerId = 0, +#endif uint32_t temporalID = 0, uint32_t reserved_zero_6bits = 0) +#if JVET_N0278_FIXES + : NALUnit( nalUnitType, temporalID, reserved_zero_6bits, 0, layerId ) +#else : NALUnit(nalUnitType, temporalID, reserved_zero_6bits) +#endif , m_Bitstream() {}