diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index 5d9ef510ee8636bca2779a62800c27d6b324fef1..170584b5b2a5aa893a76c1453e90ddf027eaa699 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -652,8 +652,11 @@ void EncApp::xInitLibCfg() #endif } -void EncApp::xCreateLib( std::list<PelUnitBuf*>& recBufList - ) +#if JVET_N0278_FIXES +void EncApp::xCreateLib( std::list<PelUnitBuf*>& recBufList, const int layerIdx ) +#else +void EncApp::xCreateLib( std::list<PelUnitBuf*>& recBufList ) +#endif { // Video I/O m_cVideoIOYuvInputFile.open( m_inputFileName, false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth ); // read mode @@ -679,7 +682,11 @@ void EncApp::xCreateLib( std::list<PelUnitBuf*>& recBufList } // create the encoder +#if JVET_N0278_FIXES + m_cEncLib.create( layerIdx ); +#else m_cEncLib.create(); +#endif // create the output buffer for( int i = 0; i < (m_iGOPSize + 1 + (m_isField ? 1 : 0)); i++ ) @@ -708,7 +715,7 @@ void EncApp::xInitLib(bool isFieldCoding) // ==================================================================================================================== #if JVET_N0278_FIXES -void EncApp::createLib() +void EncApp::createLib( const int layerIdx ) { const int sourceHeight = m_isField ? m_iSourceHeightOrg : m_iSourceHeight; UnitArea unitArea( m_chromaFormatIDC, Area( 0, 0, m_iSourceWidth, sourceHeight ) ); @@ -732,7 +739,7 @@ void EncApp::createLib() // initialize internal class & member variables xInitLibCfg(); - xCreateLib( m_recBufList ); + xCreateLib( m_recBufList, layerIdx ); xInitLib( m_isField ); printChromaFormat(); diff --git a/source/App/EncoderApp/EncApp.h b/source/App/EncoderApp/EncApp.h index 6a12d96ddd04eccd2bafee589a8bacc689dac895..524fff63a2401c30574bd4faf6778fd6173b51e9 100644 --- a/source/App/EncoderApp/EncApp.h +++ b/source/App/EncoderApp/EncApp.h @@ -79,8 +79,11 @@ private: private: // initialization - void xCreateLib ( std::list<PelUnitBuf*>& recBufList - ); ///< create files & encoder class +#if JVET_N0278_FIXES + void xCreateLib( std::list<PelUnitBuf*>& recBufList, const int layerIdx ); ///< create files & encoder class +#else + void xCreateLib ( std::list<PelUnitBuf*>& recBufList ); ///< create files & encoder class +#endif void xInitLibCfg (); ///< initialize internal variables void xInitLib (bool isFieldCoding); ///< initialize encoder class void xDestroyLib (); ///< destroy encoder class @@ -108,8 +111,8 @@ public: #if JVET_N0278_FIXES int getMaxLayers() const { return m_maxLayers; } - void createLib(); ///< main encoding function - void destroyLib(); ///< main encoding function + void createLib( int layerIdx ); ///< main encoding function + void destroyLib(); ///< main encoding function bool encode(); ///< main encoding function #else void encode(); ///< main encoding function diff --git a/source/App/EncoderApp/encmain.cpp b/source/App/EncoderApp/encmain.cpp index 38178f81059495263fc2cbafa21c6ebf302642f7..8648d05294b66f3b1770df355e4c73270e355f81 100644 --- a/source/App/EncoderApp/encmain.cpp +++ b/source/App/EncoderApp/encmain.cpp @@ -124,10 +124,10 @@ int main(int argc, char* argv[]) do { pcEncApp[i] = new EncApp; - // create application encoder class + // create application encoder class per layer pcEncApp[i]->create(); - // parse configuration + // parse configuration per layer try { if( !pcEncApp[i]->parseCfg( argc, argv ) ) @@ -142,7 +142,7 @@ int main(int argc, char* argv[]) return 1; } - pcEncApp[i]->createLib(); + pcEncApp[i]->createLib( i ); if( !resized ) { @@ -183,8 +183,8 @@ int main(int argc, char* argv[]) fprintf(stdout, " started @ %s", std::ctime(&startTime2) ); clock_t startClock = clock(); - // call encoding function #if JVET_N0278_FIXES + // call encoding function per layer bool eos = false; while( !eos ) @@ -212,6 +212,7 @@ int main(int argc, char* argv[]) } } #else + // call encoding function #ifndef _DEBUG try { @@ -249,7 +250,7 @@ int main(int argc, char* argv[]) { encApp->destroyLib(); - // destroy application encoder class + // destroy application encoder class per layer encApp->destroy(); delete encApp; diff --git a/source/Lib/CommonLib/Picture.cpp b/source/Lib/CommonLib/Picture.cpp index a008ad23323088cc82980bdcdbec8e410d8f06cb..423877804f76775371d0484f3733769708e0e380 100644 --- a/source/Lib/CommonLib/Picture.cpp +++ b/source/Lib/CommonLib/Picture.cpp @@ -801,10 +801,20 @@ Picture::Picture() } m_spliceIdx = NULL; m_ctuNums = 0; +#if JVET_N0278_FIXES + layerIdx = 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 ) +#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; +#endif UnitArea::operator=( UnitArea( _chromaFormat, Area( Position{ 0, 0 }, size ) ) ); margin = _margin; const Area a = Area( Position(), size ); diff --git a/source/Lib/CommonLib/Picture.h b/source/Lib/CommonLib/Picture.h index 9c8c5d24624356224e1b22dcd6d952ba84bdf4cc..8f739accc4b2147ea414a9ec37479488288240ae 100644 --- a/source/Lib/CommonLib/Picture.h +++ b/source/Lib/CommonLib/Picture.h @@ -197,7 +197,11 @@ struct Picture : public UnitArea uint32_t margin; 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 ); +#else void create(const ChromaFormat &_chromaFormat, const Size &size, const unsigned _maxCUSize, const unsigned margin, const bool bDecoder); +#endif void destroy(); void createTempBuffers( const unsigned _maxCUSize ); @@ -272,6 +276,9 @@ public: int poc; uint32_t layer; uint32_t depth; +#if JVET_N0278_FIXES + int layerIdx; +#endif int* m_spliceIdx; int m_ctuNums; diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 3b1548a506952bc866086713434fad873140e3b4..75c0c917a8ebfcf283cf2b3d6403dd6fe301bd03 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -269,14 +269,22 @@ void Slice::sortPicList (PicList& rcListPic) } } +#if JVET_N0278_FIXES +Picture* Slice::xGetRefPic( PicList& rcListPic, int poc, const int layerIdx ) +#else Picture* Slice::xGetRefPic (PicList& rcListPic, int poc) +#endif { PicList::iterator iterPic = rcListPic.begin(); Picture* pcPic = *(iterPic); while ( iterPic != rcListPic.end() ) { +#if JVET_N0278_FIXES + if( pcPic->getPOC() == poc && pcPic->layerIdx == layerIdx ) +#else if(pcPic->getPOC() == poc) +#endif { break; } @@ -286,8 +294,11 @@ Picture* Slice::xGetRefPic (PicList& rcListPic, int poc) return pcPic; } - +#if JVET_N0278_FIXES +Picture* Slice::xGetLongTermRefPic( PicList& rcListPic, int poc, bool pocHasMsb, const int layerIdx ) +#else Picture* Slice::xGetLongTermRefPic( PicList& rcListPic, int poc, bool pocHasMsb) +#endif { PicList::iterator iterPic = rcListPic.begin(); Picture* pcPic = *(iterPic); @@ -302,7 +313,11 @@ Picture* Slice::xGetLongTermRefPic( PicList& rcListPic, int poc, bool pocHasMsb) while ( iterPic != rcListPic.end() ) { pcPic = *(iterPic); +#if JVET_N0278_FIXES + if( pcPic && pcPic->getPOC() != this->getPOC() && pcPic->referenced && pcPic->layerIdx == layerIdx ) +#else if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->referenced) +#endif { int picPoc = pcPic->getPOC(); if (!pocHasMsb) @@ -377,7 +392,11 @@ 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 ); +#else pcRefPic = xGetRefPic(rcListPic, getPOC() - m_pRPL0->getRefPicIdentifier(ii)); +#endif pcRefPic->longTerm = false; } else @@ -386,7 +405,11 @@ void Slice::constructRefPicList(PicList& rcListPic) int pocMask = (1 << pocBits) - 1; 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 ); +#else pcRefPic = xGetLongTermRefPic(rcListPic, ltrpPoc, m_localRPL0.getDeltaPocMSBPresentFlag(ii)); +#endif pcRefPic->longTerm = true; } pcRefPic->extendPicBorder(); @@ -400,7 +423,11 @@ 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 ); +#else pcRefPic = xGetRefPic(rcListPic, getPOC() - m_pRPL1->getRefPicIdentifier(ii)); +#endif pcRefPic->longTerm = false; } else @@ -409,7 +436,11 @@ void Slice::constructRefPicList(PicList& rcListPic) int pocMask = (1 << pocBits) - 1; 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 ); +#else pcRefPic = xGetLongTermRefPic(rcListPic, ltrpPoc, m_localRPL1.getDeltaPocMSBPresentFlag(ii)); +#endif pcRefPic->longTerm = true; } pcRefPic->extendPicBorder(); @@ -469,7 +500,11 @@ 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" ); +#else CHECK(xGetLongTermRefPic(rcListPic, pRPL0->getRefPicIdentifier(i), pRPL0->getDeltaPocMSBPresentFlag(i))->getPOC() < pocCRA, "Invalid state"); +#endif } } numRefPic = pRPL1->getNumberOfShorttermPictures() + pRPL1->getNumberOfLongtermPictures(); @@ -481,7 +516,11 @@ 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" ); +#else CHECK(xGetLongTermRefPic(rcListPic, pRPL1->getRefPicIdentifier(i), pRPL1->getDeltaPocMSBPresentFlag(i))->getPOC() < pocCRA, "Invalid state"); +#endif } } } @@ -2577,7 +2616,11 @@ 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 ); +#else scaledRefPic[j]->create( sps->getChromaFormatIdc(), Size( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples() ), sps->getMaxCUWidth(), sps->getMaxCUWidth() + 16, isDecoder ); +#endif } scaledRefPic[j]->poc = poc; diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index ebc1aaed370b5188ee2286cc15e8d8fe83854095..6482ccdb128454718a0026dcc1d23ba3d6a04ce2 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -2007,8 +2007,13 @@ public: bool getNonRefPictFlag() const { return m_nonReferencePicFlag; } 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 ); +#else Picture* xGetRefPic (PicList& rcListPic, int poc); Picture* xGetLongTermRefPic(PicList& rcListPic, int poc, bool pocHasMsb); +#endif public: std::unordered_map< Position, std::unordered_map< Size, double> > m_mapPltCost; private: diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index e8f2871708dea749dee60c835f271db78ce6c602..2156c122ee47e7b312bd79a3d7ca5b618b1e9322 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -481,7 +481,11 @@ void DecLib::deletePicBuffer ( ) m_cReshaper.destroy(); } +#if JVET_N0278_FIXES +Picture* DecLib::xGetNewPicBuffer( const SPS &sps, const PPS &pps, const uint32_t temporalLayer, const int layerIdx ) +#else Picture* DecLib::xGetNewPicBuffer ( const SPS &sps, const PPS &pps, const uint32_t temporalLayer ) +#endif { Picture * pcPic = nullptr; m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded @@ -489,7 +493,11 @@ 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 ); +#else pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true ); +#endif m_cListPic.push_back( pcPic ); @@ -525,14 +533,22 @@ 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 ); +#else pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true ); +#endif } else { if( !pcPic->Y().Size::operator==( Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ) ) || pcPic->cs->pcv->maxCUWidth != sps.getMaxCUWidth() || pcPic->cs->pcv->maxCUHeight != sps.getMaxCUHeight() ) { pcPic->destroy(); +#if JVET_N0278_FIXES + pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true, layerIdx ); +#else pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, true ); +#endif } } @@ -700,10 +716,18 @@ void DecLib::xUpdateRasInit(Slice* slice) } } +#if JVET_N0278_FIXES +void DecLib::xCreateLostPicture( int iLostPoc, const int layerIdx ) +#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 ); +#else Picture *cFillPic = xGetNewPicBuffer(*(m_parameterSetManager.getFirstSPS()), *(m_parameterSetManager.getFirstPPS()), 0); +#endif CHECK( !cFillPic->slices.size(), "No slices in picture" ); @@ -744,10 +768,18 @@ void DecLib::xCreateLostPicture(int iLostPoc) } +#if JVET_N0278_FIXES +void DecLib::xCreateUnavailablePicture( int iUnavailablePoc, bool longTermFlag, const int layerIdx ) +#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 ); +#else Picture* cFillPic = xGetNewPicBuffer(*(m_parameterSetManager.getFirstSPS()), *(m_parameterSetManager.getFirstPPS()), 0); +#endif CHECK(!cFillPic->slices.size(), "No slices in picture"); @@ -852,7 +884,11 @@ void activateAPS(Slice* pSlice, ParameterSetManager& parameterSetManager, APS** pSlice->setscalingListAPS(scalingListAPS); } +#if JVET_N0278_FIXES +void DecLib::xActivateParameterSets( const int layerIdx ) +#else void DecLib::xActivateParameterSets() +#endif { if (m_bFirstSliceInPicture) { @@ -898,7 +934,11 @@ void DecLib::xActivateParameterSets() #endif // 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 ); +#else m_pcPic = xGetNewPicBuffer (*sps, *pps, m_apcSlicePilot->getTLayer()); +#endif m_apcSlicePilot->applyReferencePictureListBasedMarking(m_cListPic, m_apcSlicePilot->getRPL0(), m_apcSlicePilot->getRPL1()); m_pcPic->finalInit( *sps, *pps, apss, lmcsAPS, scalinglistAPS ); @@ -1276,24 +1316,38 @@ 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 ); +#else xCreateUnavailablePicture(lostPoc - 1, m_apcSlicePilot->getRPL0()->isRefPicLongterm(refPicIndex)); +#endif } else { +#if JVET_N0278_FIXES + xCreateLostPicture( lostPoc - 1, m_apcSlicePilot->getPic()->layerIdx ); +#else xCreateLostPicture(lostPoc - 1); +#endif } } while ((lostPoc = m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPL1(), 0, true, &refPicIndex)) > 0) { 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 ); +#else xCreateUnavailablePicture(lostPoc - 1, m_apcSlicePilot->getRPL1()->isRefPicLongterm(refPicIndex)); +#endif } else { +#if JVET_N0278_FIXES + xCreateLostPicture( lostPoc - 1, m_apcSlicePilot->getPic()->layerIdx ); +#else xCreateLostPicture(lostPoc - 1); +#endif } } } @@ -1306,7 +1360,11 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl } // actual decoding starts here +#if JVET_N0278_FIXES + xActivateParameterSets( m_apcSlicePilot->getPic()->layerIdx ); +#else xActivateParameterSets(); +#endif m_bFirstSliceInSequence = false; m_bFirstSliceInBitstream = false; diff --git a/source/Lib/DecoderLib/DecLib.h b/source/Lib/DecoderLib/DecLib.h index d21981ae15d78e47d17b564828fa4c5d4fdf9dd1..106aad11dc4fa7e0ef506689bd1903d80e2c4ecd 100644 --- a/source/Lib/DecoderLib/DecLib.h +++ b/source/Lib/DecoderLib/DecLib.h @@ -173,11 +173,18 @@ public: 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 ); +#else Picture * xGetNewPicBuffer(const SPS &sps, const PPS &pps, const uint32_t temporalLayer); void xCreateLostPicture (int iLostPOC); void xCreateUnavailablePicture(int iUnavailablePoc, bool longTermFlag); - void xActivateParameterSets(); +#endif + bool xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDisplay); void xDecodeVPS( InputNALUnit& nalu ); void xDecodeDPS( InputNALUnit& nalu ); diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 88fc69c47a25ad044b010df85ae48478da75af79..73c982430a929b61cbdd9a9d249f223cbf394846 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -3338,7 +3338,11 @@ void EncGOP::xGetBuffer( PicList& rcListPic, while (iterPic != rcListPic.end()) { rpcPic = *(iterPic); +#if JVET_N0278_FIXES + if( rpcPic->getPOC() == pocCurr && rpcPic->layerIdx == m_pcEncLib->getLayerIdx() ) +#else if (rpcPic->getPOC() == pocCurr) +#endif { break; } diff --git a/source/Lib/EncoderLib/EncGOP.h b/source/Lib/EncoderLib/EncGOP.h index e9667c5d0f0afacbd2dfcd95d8f3aa60a6d2610e..d592b236494bc1aa8bf9e3e842f505ce7fad609c 100644 --- a/source/Lib/EncoderLib/EncGOP.h +++ b/source/Lib/EncoderLib/EncGOP.h @@ -264,7 +264,6 @@ protected: void xPicInitHashME( Picture *pic, const PPS *pps, PicList &rcListPic ); void xPicInitRateControl(int &estimatedBits, int gopId, double &lambda, Picture *pic, Slice *slice); void xPicInitLMCS (Picture *pic, Slice *slice); - void xGetBuffer ( PicList& rcListPic, std::list<PelUnitBuf*>& rcListPicYuvRecOut, int iNumPicRcvd, int iTimeOffset, Picture*& rpcPic, int pocCurr, bool isField ); diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index ef1adf7ef9121011c22da4ec17fd7000d9209113..67dd378dce9b90c0fc52638fed82602d47e20c09 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -55,7 +55,9 @@ // Constructor / destructor / create / destroy // ==================================================================================================================== - +#if JVET_N0278_FIXES +PicList EncLib::m_cListPic; +#endif EncLib::EncLib() : m_spsMap( MAX_NUM_SPS ) @@ -84,14 +86,25 @@ EncLib::EncLib() #endif memset(m_apss, 0, sizeof(m_apss)); + +#if JVET_N0278_FIXES + m_layerIdx = NOT_VALID; +#endif } EncLib::~EncLib() { } +#if JVET_N0278_FIXES +void EncLib::create( const int layerIdx ) +#else void EncLib::create () +#endif { +#if JVET_N0278_FIXES + m_layerIdx = layerIdx; +#endif // initialize global variables initROM(); TComHash::initBlockSizeToIndex(); @@ -410,7 +423,11 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) if (getUseCompositeRef()) { 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 ); +#else picBg->create( sps0.getChromaFormatIdc(), Size( pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples() ), sps0.getMaxCUWidth(), sps0.getMaxCUWidth() + 16, false ); +#endif picBg->getRecoBuf().fill(0); picBg->finalInit( sps0, pps0, m_apss, m_lmcsAPS, m_scalinglistAPS ); pps0.setNumBricksInPic((int)picBg->brickMap->bricks.size()); @@ -418,7 +435,11 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) picBg->createSpliceIdx(pps0.pcv->sizeInCtus); 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 ); +#else picOrig->create( sps0.getChromaFormatIdc(), Size( pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples() ), sps0.getMaxCUWidth(), sps0.getMaxCUWidth() + 16, false ); +#endif picOrig->getOrigBuf().fill(0); m_cGOPEncoder.setPicOrig(picOrig); } @@ -532,6 +553,10 @@ void EncLib::deletePicBuffer() delete pcPic; pcPic = NULL; } + +#if JVET_N0278_FIXES + m_cListPic.clear(); +#endif } /** @@ -833,7 +858,11 @@ void EncLib::xGetNewPicBuffer ( std::list<PelUnitBuf*>& rcListPicYuvRecOut, Pict if (rpcPic==0) { rpcPic = new Picture; +#if JVET_N0278_FIXES + rpcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, false, m_layerIdx ); +#else rpcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + 16, false ); +#endif if( m_rprEnabled ) { rpcPic->M_BUFS( 0, PIC_ORIGINAL_INPUT ).create( sps.getChromaFormatIdc(), Area( Position(), Size( sps.getMaxPicWidthInLumaSamples(), sps.getMaxPicHeightInLumaSamples() ) ) ); diff --git a/source/Lib/EncoderLib/EncLib.h b/source/Lib/EncoderLib/EncLib.h index 5c3e2db0296f3f037e286242656372c642cbd2e5..c44db0627012f89b97ee44031a739380b8d71f9d 100644 --- a/source/Lib/EncoderLib/EncLib.h +++ b/source/Lib/EncoderLib/EncLib.h @@ -73,7 +73,12 @@ private: int m_iPOCLast; ///< time index (POC) int m_iNumPicRcvd; ///< number of received pictures uint32_t m_uiNumAllPicCoded; ///< number of coded pictures +#if JVET_N0278_FIXES + static PicList m_cListPic; ///< dynamic list of pictures + int m_layerIdx; +#else PicList m_cListPic; ///< dynamic list of pictures +#endif // encoder search #if ENABLE_SPLIT_PARALLELISM || ENABLE_WPP_PARALLELISM @@ -176,7 +181,11 @@ public: EncLib(); virtual ~EncLib(); +#if JVET_N0278_FIXES + void create ( const int layerIdx ); +#else void create (); +#endif void destroy (); void init ( bool isFieldCoding, AUWriterIf* auWriterIf ); void deletePicBuffer (); @@ -273,6 +282,9 @@ 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; } +#endif }; //! \}