diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 1fe39dfaab9b4e7fbdf6060f8652d2bcd51fa840..7f527e46389f0f917d0726046e64e78416c975b1 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -1139,6 +1139,130 @@ void Slice::applyReferencePictureListBasedMarking( PicList& rcListPic, const Ref bool isNeedToCheck = (this->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL) ? false : true; + // mark long-term reference pictures in List0 + for( i = 0; i < pRPL0->getNumberOfShorttermPictures() + pRPL0->getNumberOfLongtermPictures() + pRPL0->getNumberOfInterLayerPictures(); i++ ) + { + if( !pRPL0->isRefPicLongterm( i ) || pRPL0->isInterLayerRefPic( i ) ) + { + continue; + } + + int isAvailable = 0; + PicList::iterator iterPic = rcListPic.begin(); + while (iterPic != rcListPic.end()) + { + Picture* rpcPic = *(iterPic++); + if (!rpcPic->referenced) + continue; + int pocCycle = 1 << (rpcPic->cs->sps->getBitsForPOC()); + int curPoc = rpcPic->getPOC(); + int refPoc = pRPL0->getRefPicIdentifier(i) & (pocCycle - 1); + if(pRPL0->getDeltaPocMSBPresentFlag(i)) + { + refPoc += getPOC() - pRPL0->getDeltaPocMSBCycleLT(i) * pocCycle - (getPOC() & (pocCycle - 1)); + } + else + { + curPoc = curPoc & (pocCycle - 1); + } + if (rpcPic->longTerm && curPoc == refPoc && rpcPic->referenced) + { + isAvailable = 1; + break; + } + } + // if there was no such long-term check the short terms + if (!isAvailable) + { + iterPic = rcListPic.begin(); + while (iterPic != rcListPic.end()) + { + Picture* rpcPic = *(iterPic++); + if (!rpcPic->referenced) + continue; + int pocCycle = 1 << (rpcPic->cs->sps->getBitsForPOC()); + int curPoc = rpcPic->getPOC(); + int refPoc = pRPL0->getRefPicIdentifier(i) & (pocCycle - 1); + if(pRPL0->getDeltaPocMSBPresentFlag(i)) + { + refPoc += getPOC() - pRPL0->getDeltaPocMSBCycleLT(i) * pocCycle - (getPOC() & (pocCycle - 1)); + } + else + { + curPoc = curPoc & (pocCycle - 1); + } + if (!rpcPic->longTerm && curPoc == refPoc && rpcPic->referenced) + { + isAvailable = 1; + rpcPic->longTerm = true; + break; + } + } + } + } + + // mark long-term reference pictures in List1 + for( i = 0; i < pRPL1->getNumberOfShorttermPictures() + pRPL1->getNumberOfLongtermPictures() + pRPL1->getNumberOfInterLayerPictures(); i++ ) + { + if( !pRPL1->isRefPicLongterm( i ) || pRPL1->isInterLayerRefPic( i ) ) + { + continue; + } + + int isAvailable = 0; + PicList::iterator iterPic = rcListPic.begin(); + while (iterPic != rcListPic.end()) + { + Picture* rpcPic = *(iterPic++); + if (!rpcPic->referenced) + continue; + int pocCycle = 1 << (rpcPic->cs->sps->getBitsForPOC()); + int curPoc = rpcPic->getPOC(); + int refPoc = pRPL1->getRefPicIdentifier(i) & (pocCycle - 1); + if(pRPL1->getDeltaPocMSBPresentFlag(i)) + { + refPoc += getPOC() - pRPL1->getDeltaPocMSBCycleLT(i) * pocCycle - (getPOC() & (pocCycle - 1)); + } + else + { + curPoc = curPoc & (pocCycle - 1); + } + if (rpcPic->longTerm && curPoc == refPoc && rpcPic->referenced) + { + isAvailable = 1; + break; + } + } + // if there was no such long-term check the short terms + if (!isAvailable) + { + iterPic = rcListPic.begin(); + while (iterPic != rcListPic.end()) + { + Picture* rpcPic = *(iterPic++); + if (!rpcPic->referenced) + continue; + int pocCycle = 1 << (rpcPic->cs->sps->getBitsForPOC()); + int curPoc = rpcPic->getPOC(); + int refPoc = pRPL1->getRefPicIdentifier(i) & (pocCycle - 1); + if(pRPL1->getDeltaPocMSBPresentFlag(i)) + { + refPoc += getPOC() - pRPL1->getDeltaPocMSBCycleLT(i) * pocCycle - (getPOC() & (pocCycle - 1)); + } + else + { + curPoc = curPoc & (pocCycle - 1); + } + if (!rpcPic->longTerm && curPoc == refPoc && rpcPic->referenced) + { + isAvailable = 1; + rpcPic->longTerm = true; + break; + } + } + } + } + // loop through all pictures in the reference picture buffer PicList::iterator iterPic = rcListPic.begin(); while (iterPic != rcListPic.end()) diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 8e704662ea290ad5af45976c8497384b2be49a03..69fcc43f2cdf43254371e9ff93da14bf32d70846 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -3064,6 +3064,14 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag picHeader->getLocalRPL( listIdx )->setDeltaPocMSBCycleLT(i,0); } } + else if(i != 0) + { + picHeader->getLocalRPL( listIdx )->setDeltaPocMSBCycleLT(i, picHeader->getLocalRPL( listIdx )->getDeltaPocMSBCycleLT(i-1)); + } + else + { + picHeader->getLocalRPL( listIdx )->setDeltaPocMSBCycleLT(i,0); + } } } } @@ -4262,6 +4270,14 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par pcSlice->getLocalRPL0()->setDeltaPocMSBCycleLT(i,0); } } + else if(i != 0) + { + pcSlice->getLocalRPL0()->setDeltaPocMSBCycleLT(i, pcSlice->getLocalRPL0()->getDeltaPocMSBCycleLT(i-1)); + } + else + { + pcSlice->getLocalRPL0()->setDeltaPocMSBCycleLT(i,0); + } } } @@ -4356,6 +4372,14 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par pcSlice->getLocalRPL1()->setDeltaPocMSBCycleLT(i,0); } } + else if(i != 0) + { + pcSlice->getLocalRPL1()->setDeltaPocMSBCycleLT(i, pcSlice->getLocalRPL1()->getDeltaPocMSBCycleLT(i-1)); + } + else + { + pcSlice->getLocalRPL1()->setDeltaPocMSBCycleLT(i,0); + } } }