Newer
Older
if( !slice->isIRAP() && !slice->isPOCInRefPicList( pLocalRPL0, slice->getAssociatedIRAPPOC() ) )
{
if( slice->getUseLTforDRAP() && !slice->isPOCInRefPicList( rpl1, slice->getAssociatedIRAPPOC() ) )
{
// Adding associated IRAP as longterm picture
pLocalRPL0->setRefPicIdentifier( refPicIdxL0, slice->getAssociatedIRAPPOC(), true, false, 0 );
refPicIdxL0++;
numOfLTRPL0++;
}
else
{
// Adding associated IRAP as shortterm picture
#if JVET_S0045_SIGN
pLocalRPL0->setRefPicIdentifier(refPicIdxL0, slice->getAssociatedIRAPPOC() - slice->getPOC(), false, false, 0);
#else
pLocalRPL0->setRefPicIdentifier( refPicIdxL0, slice->getPOC() - slice->getAssociatedIRAPPOC(), false, false, 0 );
refPicIdxL0++;
numOfSTRPL0++;
}
}
}
ReferencePictureList* pLocalRPL1 = slice->getLocalRPL1();
*pLocalRPL1 = ReferencePictureList( slice->getSPS()->getInterLayerPresentFlag() );
uint32_t numOfSTRPL1 = 0;
uint32_t numOfLTRPL1 = 0;
uint32_t numOfILRPL1 = 0;
numOfRefPic = rpl1->getNumberOfShorttermPictures() + rpl1->getNumberOfLongtermPictures();
uint32_t refPicIdxL1 = 0;
if (isIntraLayerPredAllowed)
for (int ii = 0; ii < numOfRefPic; ii++)
// loop through all pictures in the reference picture buffer
PicList::iterator iterPic = rcListPic.begin();
bool isAvailable = false;
pocCycle = 1 << (slice->getSPS()->getBitsForPOC());
while (iterPic != rcListPic.end())
rpcPic = *(iterPic++);
if (rpcPic->layerId == pic->layerId)
#if JVET_S0045_SIGN
if (!rpl1->isRefPicLongterm(ii) && rpcPic->referenced
&& rpcPic->getPOC() == slice->getPOC() + rpl1->getRefPicIdentifier(ii)
&& !slice->isPocRestrictedByDRAP(rpcPic->getPOC(), rpcPic->precedingDRAP))
#else
if (!rpl1->isRefPicLongterm(ii) && rpcPic->referenced && rpcPic->getPOC() == slice->getPOC() - rpl1->getRefPicIdentifier(ii) && !slice->isPocRestrictedByDRAP(rpcPic->getPOC(), rpcPic->precedingDRAP))
{
isAvailable = true;
break;
}
else if (rpl1->isRefPicLongterm(ii) && rpcPic->referenced && (rpcPic->getPOC() & (pocCycle - 1)) == rpl1->getRefPicIdentifier(ii) && !slice->isPocRestrictedByDRAP(rpcPic->getPOC(), rpcPic->precedingDRAP))
{
isAvailable = true;
break;
}
if (isAvailable)
{
pLocalRPL1->setRefPicIdentifier(refPicIdxL1, rpl1->getRefPicIdentifier(ii), rpl1->isRefPicLongterm(ii), false, NOT_VALID);
refPicIdxL1++;
numOfSTRPL1 = numOfSTRPL1 + ((rpl1->isRefPicLongterm(ii)) ? 0 : 1);
numOfLTRPL1 += (rpl1->isRefPicLongterm(ii) && !rpl1->isInterLayerRefPic(ii)) ? 1 : 0;
isAvailable = false;
}
// inter-layer reference pictures are added to the end of the reference picture list
if (layerIdx && vps && !vps->getAllIndependentLayersFlag() && isInterLayerPredAllowed)
{
numOfRefPic = rpl1->getNumberOfInterLayerPictures() ? rpl1->getNumberOfInterLayerPictures() : m_pcEncLib->getNumRefLayers( layerIdx );
for( int ii = 0; ii < numOfRefPic; ii++ )
{
// loop through all pictures in the reference picture buffer
PicList::iterator iterPic = rcListPic.begin();
Vadim Seregin
committed
while( iterPic != rcListPic.end() && ii < numOfRefPic )
{
rpcPic = *( iterPic++ );
int refLayerIdx = vps->getGeneralLayerIdx( rpcPic->layerId );

Karsten Suehring
committed
if (rpcPic->referenced && rpcPic->getPOC() == pic->getPOC() && vps->getDirectRefLayerFlag(layerIdx, refLayerIdx)
&& xCheckMaxTidILRefPics( rpcPic, slice->isIRAP() ) )
{
pLocalRPL1->setRefPicIdentifier( refPicIdxL1, 0, true, true, vps->getInterLayerRefIdc( layerIdx, refLayerIdx ) );
refPicIdxL1++;
numOfILRPL1++;
Vadim Seregin
committed
ii++;
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
}
}
}
}
//Copy from L1 if we have less than active ref pic
int numOfNeedToFill = rpl0->getNumberOfActivePictures() - (numOfLTRPL0 + numOfSTRPL0);
bool isDisallowMixedRefPic = ( slice->getSPS()->getAllActiveRplEntriesHasSameSignFlag() ) ? true : false;
int originalL0StrpNum = numOfSTRPL0;
int originalL0LtrpNum = numOfLTRPL0;
int originalL0IlrpNum = numOfILRPL0;
for( int ii = 0; numOfNeedToFill > 0 && ii < ( pLocalRPL1->getNumberOfLongtermPictures() + pLocalRPL1->getNumberOfShorttermPictures() + pLocalRPL1->getNumberOfInterLayerPictures() ); ii++ )
{
if( ii <= ( numOfLTRPL1 + numOfSTRPL1 + numOfILRPL1 - 1 ) )
{
//Make sure this copy is not already in L0
bool canIncludeThis = true;
for( int jj = 0; jj < refPicIdxL0; jj++ )
{
if( ( pLocalRPL1->getRefPicIdentifier( ii ) == pLocalRPL0->getRefPicIdentifier( jj ) ) && ( pLocalRPL1->isRefPicLongterm( ii ) == pLocalRPL0->isRefPicLongterm( jj ) ) && pLocalRPL1->getInterLayerRefPicIdx( ii ) == pLocalRPL0->getInterLayerRefPicIdx( jj ) )
{
canIncludeThis = false;
}
bool sameSign = ( pLocalRPL1->getRefPicIdentifier( ii ) > 0 ) == ( pLocalRPL0->getRefPicIdentifier( 0 ) > 0 );
if( isDisallowMixedRefPic && canIncludeThis && !pLocalRPL1->isRefPicLongterm( ii ) && !sameSign )
{
canIncludeThis = false;
}
}
if( canIncludeThis )
{
pLocalRPL0->setRefPicIdentifier( refPicIdxL0, pLocalRPL1->getRefPicIdentifier( ii ), pLocalRPL1->isRefPicLongterm( ii ), pLocalRPL1->isInterLayerRefPic( ii ), pLocalRPL1->getInterLayerRefPicIdx( ii ) );
refPicIdxL0++;
numOfSTRPL0 = numOfSTRPL0 + ( ( pLocalRPL1->isRefPicLongterm( ii ) ) ? 0 : 1 );
numOfLTRPL0 += ( pLocalRPL1->isRefPicLongterm( ii ) && !pLocalRPL1->isInterLayerRefPic( ii ) ) ? 1 : 0;
numOfILRPL0 += pLocalRPL1->isInterLayerRefPic( ii ) ? 1 : 0;
numOfNeedToFill--;
}
}
}
pLocalRPL0->setNumberOfLongtermPictures( numOfLTRPL0 );
pLocalRPL0->setNumberOfShorttermPictures( numOfSTRPL0 );
pLocalRPL0->setNumberOfInterLayerPictures( numOfILRPL0 );
int numPics = numOfLTRPL0 + numOfSTRPL0;
pLocalRPL0->setNumberOfActivePictures( ( numPics < rpl0->getNumberOfActivePictures() ? numPics : rpl0->getNumberOfActivePictures() ) + numOfILRPL0 );
Zhipin Deng
committed
pLocalRPL0->setLtrpInSliceHeaderFlag( 1 );
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
slice->setRPL0idx( -1 );
slice->setRPL0( pLocalRPL0 );
//Copy from L0 if we have less than active ref pic
numOfNeedToFill = pLocalRPL0->getNumberOfActivePictures() - ( numOfLTRPL1 + numOfSTRPL1 );
for( int ii = 0; numOfNeedToFill > 0 && ii < ( pLocalRPL0->getNumberOfLongtermPictures() + pLocalRPL0->getNumberOfShorttermPictures() + pLocalRPL0->getNumberOfInterLayerPictures() ); ii++ )
{
if( ii <= ( originalL0StrpNum + originalL0LtrpNum + originalL0IlrpNum - 1 ) )
{
//Make sure this copy is not already in L0
bool canIncludeThis = true;
for( int jj = 0; jj < refPicIdxL1; jj++ )
{
if( ( pLocalRPL0->getRefPicIdentifier( ii ) == pLocalRPL1->getRefPicIdentifier( jj ) ) && ( pLocalRPL0->isRefPicLongterm( ii ) == pLocalRPL1->isRefPicLongterm( jj ) ) && pLocalRPL0->getInterLayerRefPicIdx( ii ) == pLocalRPL1->getInterLayerRefPicIdx( jj ) )
{
canIncludeThis = false;
}
bool sameSign = ( pLocalRPL0->getRefPicIdentifier( ii ) > 0 ) == ( pLocalRPL1->getRefPicIdentifier( 0 ) > 0 );
if( isDisallowMixedRefPic && canIncludeThis && !pLocalRPL0->isRefPicLongterm( ii ) && !sameSign )
{
canIncludeThis = false;
}
}
if( canIncludeThis )
{
pLocalRPL1->setRefPicIdentifier( refPicIdxL1, pLocalRPL0->getRefPicIdentifier( ii ), pLocalRPL0->isRefPicLongterm( ii ), pLocalRPL0->isInterLayerRefPic( ii ), pLocalRPL0->getInterLayerRefPicIdx( ii ) );
refPicIdxL1++;
numOfSTRPL1 = numOfSTRPL1 + ( ( pLocalRPL0->isRefPicLongterm( ii ) ) ? 0 : 1 );
numOfLTRPL1 += ( pLocalRPL0->isRefPicLongterm( ii ) && !pLocalRPL0->isInterLayerRefPic( ii ) ) ? 1 : 0;
numOfLTRPL1 += pLocalRPL0->isInterLayerRefPic( ii ) ? 1 : 0;
numOfNeedToFill--;
}
}
}
pLocalRPL1->setNumberOfLongtermPictures( numOfLTRPL1 );
pLocalRPL1->setNumberOfShorttermPictures( numOfSTRPL1 );
pLocalRPL1->setNumberOfInterLayerPictures( numOfILRPL1 );
numPics = numOfLTRPL1 + numOfSTRPL1;
pLocalRPL1->setNumberOfActivePictures( ( isDisallowMixedRefPic ? numPics : ( numPics < rpl1->getNumberOfActivePictures() ? numPics : rpl1->getNumberOfActivePictures() ) ) + numOfILRPL1 );
Zhipin Deng
committed
pLocalRPL1->setLtrpInSliceHeaderFlag( 1 );
slice->setRPL1idx( -1 );
slice->setRPL1( pLocalRPL1 );
}