Newer
Older

Karsten Suehring
committed
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
vB[RVM_VCEGAM10_M] = 0;
for( i = RVM_VCEGAM10_M + 1 ; i < N - RVM_VCEGAM10_M + 1 ; i++ )
{
vRL[i] = 0;
for( int j = i - RVM_VCEGAM10_M ; j <= i + RVM_VCEGAM10_M - 1 ; j++ )
{
vRL[i] += m_vRVM_RP[j];
}
vRL[i] /= ( 2 * RVM_VCEGAM10_M );
vB[i] = vB[i-1] + m_vRVM_RP[i] - vRL[i];
dRavg += m_vRVM_RP[i];
dBavg += vB[i];
}
dRavg /= ( N - 2 * RVM_VCEGAM10_M );
dBavg /= ( N - 2 * RVM_VCEGAM10_M );
double dSigamB = 0;
for( i = RVM_VCEGAM10_M + 1 ; i < N - RVM_VCEGAM10_M + 1 ; i++ )
{
double tmp = vB[i] - dBavg;
dSigamB += tmp * tmp;
}
dSigamB = sqrt( dSigamB / ( N - 2 * RVM_VCEGAM10_M ) );
double f = sqrt( 12.0 * ( RVM_VCEGAM10_M - 1 ) / ( RVM_VCEGAM10_M + 1 ) );
dRVM = dSigamB / dRavg * f;
}
return( dRVM );
}
/** Attaches the input bitstream to the stream in the output NAL unit
Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call.
* \param codedSliceData contains the coded slice data (bitstream) to be concatenated to rNalu
* \param rNalu target NAL unit
*/
void EncGOP::xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, OutputBitstream* codedSliceData)
{
// Byte-align
rNalu.m_Bitstream.writeByteAlignment(); // Slice header byte-alignment
// Perform bitstream concatenation
if (codedSliceData->getNumberOfWrittenBits() > 0)
{
rNalu.m_Bitstream.addSubstream(codedSliceData);
}
codedSliceData->clear();
}
void EncGOP::arrangeCompositeReference(Slice* pcSlice, PicList& rcListPic, int pocCurr)
{
Picture* curPic = NULL;
PicList::iterator iterPic = rcListPic.begin();
const PreCalcValues *pcv = pcSlice->getPPS()->pcv;
m_bgPOC = pocCurr + 1;
if (m_picBg->getSpliceFull())
{
return;
}
while (iterPic != rcListPic.end())
{
curPic = *(iterPic++);
if (curPic->getPOC() == pocCurr)
{
break;
}
}
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
{
return;
}
int width = pcv->lumaWidth;
int height = pcv->lumaHeight;
int stride = curPic->getOrigBuf().get(COMPONENT_Y).stride;
int cStride = curPic->getOrigBuf().get(COMPONENT_Cb).stride;
Pel* curLumaAddr = curPic->getOrigBuf().get(COMPONENT_Y).buf;
Pel* curCbAddr = curPic->getOrigBuf().get(COMPONENT_Cb).buf;
Pel* curCrAddr = curPic->getOrigBuf().get(COMPONENT_Cr).buf;
Pel* bgOrgLumaAddr = m_picOrig->getOrigBuf().get(COMPONENT_Y).buf;
Pel* bgOrgCbAddr = m_picOrig->getOrigBuf().get(COMPONENT_Cb).buf;
Pel* bgOrgCrAddr = m_picOrig->getOrigBuf().get(COMPONENT_Cr).buf;
int cuMaxWidth = pcv->maxCUWidth;
int cuMaxHeight = pcv->maxCUHeight;
int maxReplace = (pcv->sizeInCtus) / 2;
maxReplace = maxReplace < 1 ? 1 : maxReplace;
typedef struct tagCostStr
{
double cost;
int ctuIdx;
}CostStr;
CostStr* minCtuCost = new CostStr[maxReplace];
for (int i = 0; i < maxReplace; i++)
{
minCtuCost[i].cost = 1e10;
minCtuCost[i].ctuIdx = -1;
}
int bitIncrementY = pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 8;
int bitIncrementUV = pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) - 8;
for (int y = 0; y < height; y += cuMaxHeight)
{
for (int x = 0; x < width; x += cuMaxWidth)
{
double lcuDist = 0.0;
double lcuDistCb = 0.0;
double lcuDistCr = 0.0;
int realPixelCnt = 0;
double lcuCost = 1e10;
int largeDist = 0;
for (int tmpy = 0; tmpy < cuMaxHeight; tmpy++)
{
if (y + tmpy >= height)
{
break;
}
for (int tmpx = 0; tmpx < cuMaxWidth; tmpx++)
{
if (x + tmpx >= width)
{
break;
}
realPixelCnt++;
lcuDist += abs(curLumaAddr[(y + tmpy)*stride + x + tmpx] - bgOrgLumaAddr[(y + tmpy)*stride + x + tmpx]);
if (abs(curLumaAddr[(y + tmpy)*stride + x + tmpx] - bgOrgLumaAddr[(y + tmpy)*stride + x + tmpx]) >(20 << bitIncrementY))
{
largeDist++;
}
if (tmpy % 2 == 0 && tmpx % 2 == 0)
{
lcuDistCb += abs(curCbAddr[(y + tmpy) / 2 * cStride + (x + tmpx) / 2] - bgOrgCbAddr[(y + tmpy) / 2 * cStride + (x + tmpx) / 2]);
lcuDistCr += abs(curCrAddr[(y + tmpy) / 2 * cStride + (x + tmpx) / 2] - bgOrgCrAddr[(y + tmpy) / 2 * cStride + (x + tmpx) / 2]);
}
}
}
//Test the vertical or horizontal edge for background patches candidates
int yInLCU = y / cuMaxHeight;
int xInLCU = x / cuMaxWidth;
int iLCUIdx = yInLCU * pcv->widthInCtus + xInLCU;
if ((largeDist / (double)realPixelCnt < 0.01 &&lcuDist / realPixelCnt < (3.5 * (1 << bitIncrementY)) && lcuDistCb / realPixelCnt < (0.5 * (1 << bitIncrementUV)) && lcuDistCr / realPixelCnt < (0.5 * (1 << bitIncrementUV)) && m_picBg->getSpliceIdx(iLCUIdx) == 0))
{
lcuCost = lcuDist / realPixelCnt + lcuDistCb / realPixelCnt + lcuDistCr / realPixelCnt;
//obtain the maxReplace smallest cost
//1) find the largest cost in the maxReplace candidates
for (int i = 0; i < maxReplace - 1; i++)
{
if (minCtuCost[i].cost > minCtuCost[i + 1].cost)
{
swap(minCtuCost[i].cost, minCtuCost[i + 1].cost);
swap(minCtuCost[i].ctuIdx, minCtuCost[i + 1].ctuIdx);
}
}
// 2) compare the current cost with the largest cost
if (lcuCost < minCtuCost[maxReplace - 1].cost)
{
minCtuCost[maxReplace - 1].cost = lcuCost;
minCtuCost[maxReplace - 1].ctuIdx = iLCUIdx;
}
}
}
}
// modify QP for background CTU
{
for (int i = 0; i < maxReplace; i++)
{
if (minCtuCost[i].ctuIdx != -1)
{
m_picBg->setSpliceIdx(minCtuCost[i].ctuIdx, pocCurr);
}
}
}
delete[]minCtuCost;
}
void EncGOP::updateCompositeReference(Slice* pcSlice, PicList& rcListPic, int pocCurr)
{
Picture* curPic = NULL;
const PreCalcValues *pcv = pcSlice->getPPS()->pcv;
PicList::iterator iterPic = rcListPic.begin();
iterPic = rcListPic.begin();
while (iterPic != rcListPic.end())
{
curPic = *(iterPic++);
if (curPic->getPOC() == pocCurr)
{
break;
}
}
assert(curPic->getPOC() == pocCurr);
int width = pcv->lumaWidth;
int height = pcv->lumaHeight;
int stride = curPic->getRecoBuf().get(COMPONENT_Y).stride;
int cStride = curPic->getRecoBuf().get(COMPONENT_Cb).stride;
Pel* bgLumaAddr = m_picBg->getRecoBuf().get(COMPONENT_Y).buf;
Pel* bgCbAddr = m_picBg->getRecoBuf().get(COMPONENT_Cb).buf;
Pel* bgCrAddr = m_picBg->getRecoBuf().get(COMPONENT_Cr).buf;
Pel* curLumaAddr = curPic->getRecoBuf().get(COMPONENT_Y).buf;
Pel* curCbAddr = curPic->getRecoBuf().get(COMPONENT_Cb).buf;
Pel* curCrAddr = curPic->getRecoBuf().get(COMPONENT_Cr).buf;
int maxCuWidth = pcv->maxCUWidth;
int maxCuHeight = pcv->maxCUHeight;
// Update background reference
if (pcSlice->isIRAP())//(pocCurr == 0)
curPic->extendPicBorder( pcSlice->getPPS() );
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
curPic->setBorderExtension(true);
m_picBg->getRecoBuf().copyFrom(curPic->getRecoBuf());
m_picOrig->getOrigBuf().copyFrom(curPic->getOrigBuf());
}
else
{
//cout << "update B" << pocCurr << endl;
for (int y = 0; y < height; y += maxCuHeight)
{
for (int x = 0; x < width; x += maxCuWidth)
{
if (m_picBg->getSpliceIdx((y / maxCuHeight)*pcv->widthInCtus + x / maxCuWidth) == pocCurr)
{
for (int tmpy = 0; tmpy < maxCuHeight; tmpy++)
{
if (y + tmpy >= height)
{
break;
}
for (int tmpx = 0; tmpx < maxCuWidth; tmpx++)
{
if (x + tmpx >= width)
{
break;
}
bgLumaAddr[(y + tmpy)*stride + x + tmpx] = curLumaAddr[(y + tmpy)*stride + x + tmpx];
if (tmpy % 2 == 0 && tmpx % 2 == 0)
{
bgCbAddr[(y + tmpy) / 2 * cStride + (x + tmpx) / 2] = curCbAddr[(y + tmpy) / 2 * cStride + (x + tmpx) / 2];
bgCrAddr[(y + tmpy) / 2 * cStride + (x + tmpx) / 2] = curCrAddr[(y + tmpy) / 2 * cStride + (x + tmpx) / 2];
}
}
}
}
}
}
m_picBg->setBorderExtension(false);
m_picBg->extendPicBorder( pcSlice->getPPS() );
m_picBg->setBorderExtension(true);
curPic->extendPicBorder( pcSlice->getPPS() );
curPic->setBorderExtension(true);
m_picOrig->getOrigBuf().copyFrom(curPic->getOrigBuf());
m_picBg->setBorderExtension(false);
m_picBg->extendPicBorder( pcSlice->getPPS() );
m_picBg->setBorderExtension(true);
}
}

Karsten Suehring
committed
void EncGOP::applyDeblockingFilterMetric( Picture* pcPic, uint32_t uiNumSlices )
{
PelBuf cPelBuf = pcPic->getRecoBuf().get( COMPONENT_Y );
Pel* Rec = cPelBuf.buf;
const int stride = cPelBuf.stride;
const uint32_t picWidth = cPelBuf.width;
const uint32_t picHeight = cPelBuf.height;
Pel* tempRec = Rec;
const Slice* pcSlice = pcPic->slices[0];
const uint32_t log2maxTB = pcSlice->getSPS()->getLog2MaxTbSize();
const uint32_t maxTBsize = (1<<log2maxTB);

Karsten Suehring
committed
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
const uint32_t minBlockArtSize = 8;
const uint32_t noCol = (picWidth>>log2maxTB);
const uint32_t noRows = (picHeight>>log2maxTB);
CHECK(!(noCol > 1), "Unspecified error");
CHECK(!(noRows > 1), "Unspecified error");
std::vector<uint64_t> colSAD(noCol, uint64_t(0));
std::vector<uint64_t> rowSAD(noRows, uint64_t(0));
uint32_t colIdx = 0;
uint32_t rowIdx = 0;
Pel p0, p1, p2, q0, q1, q2;
int qp = pcSlice->getSliceQp();
const int bitDepthLuma=pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
int bitdepthScale = 1 << (bitDepthLuma-8);
int beta = LoopFilter::getBeta( qp ) * bitdepthScale;
const int thr2 = (beta>>2);
const int thr1 = 2*bitdepthScale;
uint32_t a = 0;
if (maxTBsize > minBlockArtSize)
{
// Analyze vertical artifact edges
for(int c = maxTBsize; c < picWidth; c += maxTBsize)
{
for(int r = 0; r < picHeight; r++)
{
p2 = Rec[c-3];
p1 = Rec[c-2];
p0 = Rec[c-1];
q0 = Rec[c];
q1 = Rec[c+1];
q2 = Rec[c+2];
a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
if ( thr1 < a && a < thr2)
{
colSAD[colIdx] += abs(p0 - q0);
}
Rec += stride;
}
colIdx++;
Rec = tempRec;
}
// Analyze horizontal artifact edges
for(int r = maxTBsize; r < picHeight; r += maxTBsize)
{
for(int c = 0; c < picWidth; c++)
{
p2 = Rec[c + (r-3)*stride];
p1 = Rec[c + (r-2)*stride];
p0 = Rec[c + (r-1)*stride];
q0 = Rec[c + r*stride];
q1 = Rec[c + (r+1)*stride];
q2 = Rec[c + (r+2)*stride];
a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
if (thr1 < a && a < thr2)
{
rowSAD[rowIdx] += abs(p0 - q0);
}
}
rowIdx++;
}
}
uint64_t colSADsum = 0;
uint64_t rowSADsum = 0;
for(int c = 0; c < noCol-1; c++)
{
colSADsum += colSAD[c];
}
for(int r = 0; r < noRows-1; r++)
{
rowSADsum += rowSAD[r];
}
colSADsum <<= 10;
rowSADsum <<= 10;
colSADsum /= (noCol-1);
colSADsum /= picHeight;
rowSADsum /= (noRows-1);
rowSADsum /= picWidth;
uint64_t avgSAD = ((colSADsum + rowSADsum)>>1);
avgSAD >>= (bitDepthLuma-8);
if ( avgSAD > 2048 )
{
avgSAD >>= 9;
int offset = Clip3(2,6,(int)avgSAD);
for (int i=0; i<uiNumSlices; i++)
{
Slice* pcLocalSlice = pcPic->slices[i];
pcLocalSlice->setDeblockingFilterOverrideFlag ( true);
pcLocalSlice->setDeblockingFilterDisable ( false);
pcLocalSlice->setDeblockingFilterBetaOffsetDiv2 ( offset );
pcLocalSlice->setDeblockingFilterTcOffsetDiv2 ( offset );
pcLocalSlice->setDeblockingFilterCbBetaOffsetDiv2 ( offset );
pcLocalSlice->setDeblockingFilterCbTcOffsetDiv2 ( offset );
pcLocalSlice->setDeblockingFilterCrBetaOffsetDiv2 ( offset );
pcLocalSlice->setDeblockingFilterCrTcOffsetDiv2 ( offset );

Karsten Suehring
committed
}
}
else
{
for (int i=0; i<uiNumSlices; i++)
{
Slice* pcLocalSlice = pcPic->slices[i];
const PPS* pcPPS = pcSlice->getPPS();
pcLocalSlice->setDeblockingFilterOverrideFlag ( false);
pcLocalSlice->setDeblockingFilterDisable ( pcPPS->getPPSDeblockingFilterDisabledFlag() );
#if DB_PARAM_TID
int betaIdx = Clip3(0, (int)pcPPS->getDeblockingFilterBetaOffsetDiv2().size() - 1, (int)pcLocalSlice->getTLayer() + (pcLocalSlice->isIntra() ? 0 : 1));
int tcIdx = Clip3(0, (int)pcPPS->getDeblockingFilterTcOffsetDiv2().size() - 1, (int)pcLocalSlice->getTLayer() + (pcLocalSlice->isIntra() ? 0 : 1));
pcLocalSlice->setDeblockingFilterBetaOffsetDiv2( pcPPS->getDeblockingFilterBetaOffsetDiv2()[betaIdx] );
pcLocalSlice->setDeblockingFilterTcOffsetDiv2 ( pcPPS->getDeblockingFilterTcOffsetDiv2()[tcIdx] );
pcLocalSlice->setDeblockingFilterCbBetaOffsetDiv2(pcPPS->getDeblockingFilterBetaOffsetDiv2()[betaIdx]);
pcLocalSlice->setDeblockingFilterCbTcOffsetDiv2(pcPPS->getDeblockingFilterTcOffsetDiv2()[tcIdx]);
pcLocalSlice->setDeblockingFilterCrBetaOffsetDiv2(pcPPS->getDeblockingFilterBetaOffsetDiv2()[betaIdx]);
pcLocalSlice->setDeblockingFilterCrTcOffsetDiv2(pcPPS->getDeblockingFilterTcOffsetDiv2()[tcIdx]);
#else

Karsten Suehring
committed
pcLocalSlice->setDeblockingFilterBetaOffsetDiv2( pcPPS->getDeblockingFilterBetaOffsetDiv2() );
pcLocalSlice->setDeblockingFilterTcOffsetDiv2 ( pcPPS->getDeblockingFilterTcOffsetDiv2() );
pcLocalSlice->setDeblockingFilterCbBetaOffsetDiv2 ( pcPPS->getDeblockingFilterCbBetaOffsetDiv2() );
pcLocalSlice->setDeblockingFilterCbTcOffsetDiv2 ( pcPPS->getDeblockingFilterCbTcOffsetDiv2() );
pcLocalSlice->setDeblockingFilterCrBetaOffsetDiv2 ( pcPPS->getDeblockingFilterCrBetaOffsetDiv2() );
pcLocalSlice->setDeblockingFilterCrTcOffsetDiv2 ( pcPPS->getDeblockingFilterCrTcOffsetDiv2() );

Karsten Suehring
committed
}
}
}
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
#if DB_PARAM_TID
void EncGOP::applyDeblockingFilterParameterSelection( Picture* pcPic, Slice* pcSlice, const uint32_t numSlices, const int gopID )
{
const PPS* pcPPS = pcPic->slices[0]->getPPS();
for (int i = 0; i<numSlices; i++)
{
Slice* pcSlice = pcPic->slices[i];
pcSlice->setDeblockingFilterOverrideFlag(false);
pcSlice->setDeblockingFilterDisable(pcPPS->getPPSDeblockingFilterDisabledFlag());
int betaIdx = Clip3(0, (int)pcPPS->getDeblockingFilterBetaOffsetDiv2().size() - 1, (int)pcSlice->getTLayer() + (pcSlice->isIntra() ? 0 : 1));
int tcIdx = Clip3(0, (int)pcPPS->getDeblockingFilterTcOffsetDiv2().size() - 1, (int)pcSlice->getTLayer() + (pcSlice->isIntra() ? 0 : 1));
pcSlice->setDeblockingFilterBetaOffsetDiv2(pcPPS->getDeblockingFilterBetaOffsetDiv2()[betaIdx]);
pcSlice->setDeblockingFilterTcOffsetDiv2(pcPPS->getDeblockingFilterTcOffsetDiv2()[tcIdx]);
pcSlice->setDeblockingFilterCbBetaOffsetDiv2(pcPPS->getDeblockingFilterBetaOffsetDiv2()[betaIdx]);
pcSlice->setDeblockingFilterCbTcOffsetDiv2(pcPPS->getDeblockingFilterTcOffsetDiv2()[tcIdx]);
pcSlice->setDeblockingFilterCrBetaOffsetDiv2(pcPPS->getDeblockingFilterBetaOffsetDiv2()[betaIdx]);
pcSlice->setDeblockingFilterCrTcOffsetDiv2(pcPPS->getDeblockingFilterTcOffsetDiv2()[tcIdx]);
}
}
#endif

Karsten Suehring
committed
#if W0038_DB_OPT
void EncGOP::applyDeblockingFilterParameterSelection( Picture* pcPic, const uint32_t numSlices, const int gopID )
{
enum DBFltParam
{
DBFLT_PARAM_AVAILABLE = 0,
DBFLT_DISABLE_FLAG,
DBFLT_BETA_OFFSETD2,
DBFLT_TC_OFFSETD2,
//NUM_DBFLT_PARAMS
};
const int MAX_BETA_OFFSET = 3;
const int MIN_BETA_OFFSET = -3;
const int MAX_TC_OFFSET = 3;
const int MIN_TC_OFFSET = -3;
PelUnitBuf reco = pcPic->getRecoBuf();
const int currQualityLayer = (!pcPic->slices[0]->isIRAP()) ? m_pcCfg->getGOPEntry(gopID).m_temporalId+1 : 0;

Karsten Suehring
committed
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
CHECK(!(currQualityLayer <MAX_ENCODER_DEBLOCKING_QUALITY_LAYERS), "Unspecified error");
CodingStructure& cs = *pcPic->cs;
if(!m_pcDeblockingTempPicYuv)
{
m_pcDeblockingTempPicYuv = new PelStorage;
m_pcDeblockingTempPicYuv->create( cs.area );
memset(m_DBParam, 0, sizeof(m_DBParam));
}
//preserve current reconstruction
m_pcDeblockingTempPicYuv->copyFrom ( reco );
const bool bNoFiltering = m_DBParam[currQualityLayer][DBFLT_PARAM_AVAILABLE] && m_DBParam[currQualityLayer][DBFLT_DISABLE_FLAG]==false /*&& pcPic->getTLayer()==0*/;
const int maxBetaOffsetDiv2 = bNoFiltering? Clip3(MIN_BETA_OFFSET, MAX_BETA_OFFSET, m_DBParam[currQualityLayer][DBFLT_BETA_OFFSETD2]+1) : MAX_BETA_OFFSET;
const int minBetaOffsetDiv2 = bNoFiltering? Clip3(MIN_BETA_OFFSET, MAX_BETA_OFFSET, m_DBParam[currQualityLayer][DBFLT_BETA_OFFSETD2]-1) : MIN_BETA_OFFSET;
const int maxTcOffsetDiv2 = bNoFiltering? Clip3(MIN_TC_OFFSET, MAX_TC_OFFSET, m_DBParam[currQualityLayer][DBFLT_TC_OFFSETD2]+2) : MAX_TC_OFFSET;
const int minTcOffsetDiv2 = bNoFiltering? Clip3(MIN_TC_OFFSET, MAX_TC_OFFSET, m_DBParam[currQualityLayer][DBFLT_TC_OFFSETD2]-2) : MIN_TC_OFFSET;
uint64_t distBetaPrevious = std::numeric_limits<uint64_t>::max();
uint64_t distMin = std::numeric_limits<uint64_t>::max();
bool bDBFilterDisabledBest = true;
int betaOffsetDiv2Best = 0;
int tcOffsetDiv2Best = 0;
for(int betaOffsetDiv2=maxBetaOffsetDiv2; betaOffsetDiv2>=minBetaOffsetDiv2; betaOffsetDiv2--)
{
uint64_t distTcMin = std::numeric_limits<uint64_t>::max();
for(int tcOffsetDiv2=maxTcOffsetDiv2; tcOffsetDiv2 >= minTcOffsetDiv2; tcOffsetDiv2--)
{
for (int i=0; i<numSlices; i++)
{
Slice* pcSlice = pcPic->slices[i];
pcSlice->setDeblockingFilterOverrideFlag ( true);
pcSlice->setDeblockingFilterDisable ( false);
pcSlice->setDeblockingFilterBetaOffsetDiv2( betaOffsetDiv2 );
pcSlice->setDeblockingFilterTcOffsetDiv2 ( tcOffsetDiv2 );
pcSlice->setDeblockingFilterCbBetaOffsetDiv2( betaOffsetDiv2 );
pcSlice->setDeblockingFilterCbTcOffsetDiv2 ( tcOffsetDiv2 );
pcSlice->setDeblockingFilterCrBetaOffsetDiv2( betaOffsetDiv2 );
pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( tcOffsetDiv2 );

Karsten Suehring
committed
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
}
// restore reconstruction
reco.copyFrom( *m_pcDeblockingTempPicYuv );
const uint64_t dist = preLoopFilterPicAndCalcDist( pcPic );
if(dist < distMin)
{
distMin = dist;
bDBFilterDisabledBest = false;
betaOffsetDiv2Best = betaOffsetDiv2;
tcOffsetDiv2Best = tcOffsetDiv2;
}
if(dist < distTcMin)
{
distTcMin = dist;
}
else if(tcOffsetDiv2 <-2)
{
break;
}
}
if(betaOffsetDiv2<-1 && distTcMin >= distBetaPrevious)
{
break;
}
distBetaPrevious = distTcMin;
}
//update:
m_DBParam[currQualityLayer][DBFLT_PARAM_AVAILABLE] = 1;
m_DBParam[currQualityLayer][DBFLT_DISABLE_FLAG] = bDBFilterDisabledBest;
m_DBParam[currQualityLayer][DBFLT_BETA_OFFSETD2] = betaOffsetDiv2Best;
m_DBParam[currQualityLayer][DBFLT_TC_OFFSETD2] = tcOffsetDiv2Best;
// restore reconstruction
reco.copyFrom( *m_pcDeblockingTempPicYuv );
const PPS* pcPPS = pcPic->slices[0]->getPPS();
#if DB_PARAM_TID
int betaIdx = Clip3(0, (int)pcPPS->getDeblockingFilterBetaOffsetDiv2().size() - 1, (int)pcPic->slices[0]->getTLayer() + (pcPic->slices[0]->isIntra() ? 0 : 1));
int tcIdx = Clip3(0, (int)pcPPS->getDeblockingFilterTcOffsetDiv2().size() - 1, (int)pcPic->slices[0]->getTLayer()) + (pcPic->slices[0]->isIntra() ? 0 : 1);
#endif

Karsten Suehring
committed
if(bDBFilterDisabledBest)
{
for (int i=0; i<numSlices; i++)
{
Slice* pcSlice = pcPic->slices[i];
pcSlice->setDeblockingFilterOverrideFlag( true);
pcSlice->setDeblockingFilterDisable ( true);
}
}
#if DB_PARAM_TID
else if (betaOffsetDiv2Best == pcPPS->getDeblockingFilterBetaOffsetDiv2()[betaIdx] && tcOffsetDiv2Best == pcPPS->getDeblockingFilterTcOffsetDiv2()[tcIdx])
#else

Karsten Suehring
committed
else if(betaOffsetDiv2Best == pcPPS->getDeblockingFilterBetaOffsetDiv2() && tcOffsetDiv2Best == pcPPS->getDeblockingFilterTcOffsetDiv2())

Karsten Suehring
committed
{
for (int i=0; i<numSlices; i++)
{
Slice* pcSlice = pcPic->slices[i];
pcSlice->setDeblockingFilterOverrideFlag ( false);
pcSlice->setDeblockingFilterDisable ( pcPPS->getPPSDeblockingFilterDisabledFlag() );
#if DB_PARAM_TID
pcSlice->setDeblockingFilterBetaOffsetDiv2(pcPPS->getDeblockingFilterBetaOffsetDiv2()[betaIdx]);
pcSlice->setDeblockingFilterTcOffsetDiv2(pcPPS->getDeblockingFilterTcOffsetDiv2()[tcIdx]);
pcSlice->setDeblockingFilterCbBetaOffsetDiv2(pcPPS->getDeblockingFilterBetaOffsetDiv2()[betaIdx]);
pcSlice->setDeblockingFilterCbTcOffsetDiv2(pcPPS->getDeblockingFilterTcOffsetDiv2()[tcIdx]);
pcSlice->setDeblockingFilterCrBetaOffsetDiv2(pcPPS->getDeblockingFilterBetaOffsetDiv2()[betaIdx]);
pcSlice->setDeblockingFilterCrTcOffsetDiv2(pcPPS->getDeblockingFilterTcOffsetDiv2()[tcIdx]);
#else

Karsten Suehring
committed
pcSlice->setDeblockingFilterBetaOffsetDiv2 ( pcPPS->getDeblockingFilterBetaOffsetDiv2() );
pcSlice->setDeblockingFilterTcOffsetDiv2 ( pcPPS->getDeblockingFilterTcOffsetDiv2() );
pcSlice->setDeblockingFilterCbBetaOffsetDiv2(pcPPS->getDeblockingFilterBetaOffsetDiv2());
pcSlice->setDeblockingFilterCbTcOffsetDiv2(pcPPS->getDeblockingFilterTcOffsetDiv2());
pcSlice->setDeblockingFilterCrBetaOffsetDiv2(pcPPS->getDeblockingFilterBetaOffsetDiv2());
pcSlice->setDeblockingFilterCrTcOffsetDiv2(pcPPS->getDeblockingFilterTcOffsetDiv2());
#endif

Karsten Suehring
committed
}
}
else
{
for (int i=0; i<numSlices; i++)
{
Slice* pcSlice = pcPic->slices[i];
pcSlice->setDeblockingFilterOverrideFlag ( true);
pcSlice->setDeblockingFilterDisable ( false );
pcSlice->setDeblockingFilterBetaOffsetDiv2 ( betaOffsetDiv2Best);
pcSlice->setDeblockingFilterTcOffsetDiv2 ( tcOffsetDiv2Best);
pcSlice->setDeblockingFilterCbBetaOffsetDiv2 ( betaOffsetDiv2Best);
pcSlice->setDeblockingFilterCbTcOffsetDiv2 ( tcOffsetDiv2Best);
pcSlice->setDeblockingFilterCrBetaOffsetDiv2 ( betaOffsetDiv2Best);
pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( tcOffsetDiv2Best);

Karsten Suehring
committed
}
}
}
#endif

Karsten Suehring
committed
bool EncGOP::xCheckMaxTidILRefPics(Picture* refPic, bool currentPicIsIRAP)
{
const int maxTidILRefPicsPlus1 = m_pcCfg->getVPSParameters().m_maxTidILRefPicsPlus1;
// -1 means not set
if (maxTidILRefPicsPlus1 < 0)
{
return true;
}
// 0 allows only IRAP pictures to use inter-layer prediction
if (maxTidILRefPicsPlus1 == 0)
{
return currentPicIsIRAP;
}
// all other cases filter by temporalID
return ( refPic->temporalId < maxTidILRefPicsPlus1 );
}
void EncGOP::xCreateExplicitReferencePictureSetFromReference( Slice* slice, PicList& rcListPic, const ReferencePictureList *rpl0, const ReferencePictureList *rpl1 )
{
Picture* rpcPic;
int pocCycle = 0;
Picture* pic = slice->getPic();
const VPS* vps = slice->getPic()->cs->vps;
int layerIdx = vps == nullptr ? 0 : vps->getGeneralLayerIdx( pic->layerId );
bool isIntraLayerPredAllowed = vps->getIndependentLayerFlag(layerIdx) || (vps->getPredDirection(slice->getTLayer()) != 1);
bool isInterLayerPredAllowed = !vps->getIndependentLayerFlag(layerIdx) && (vps->getPredDirection(slice->getTLayer()) != 2);
ReferencePictureList* pLocalRPL0 = slice->getLocalRPL0();
*pLocalRPL0 = ReferencePictureList( slice->getSPS()->getInterLayerPresentFlag() );
uint32_t numOfSTRPL0 = 0;
uint32_t numOfLTRPL0 = 0;
uint32_t numOfILRPL0 = 0;
uint32_t numOfRefPic = rpl0->getNumberOfShorttermPictures() + rpl0->getNumberOfLongtermPictures();
uint32_t refPicIdxL0 = 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 (!rpl0->isRefPicLongterm(ii) && rpcPic->referenced
&& rpcPic->getPOC() == slice->getPOC() + rpl0->getRefPicIdentifier(ii)
&& !slice->isPocRestrictedByDRAP(rpcPic->getPOC(), rpcPic->precedingDRAP))
#else
if (!rpl0->isRefPicLongterm(ii) && rpcPic->referenced && rpcPic->getPOC() == slice->getPOC() - rpl0->getRefPicIdentifier(ii) && !slice->isPocRestrictedByDRAP(rpcPic->getPOC(), rpcPic->precedingDRAP))
{
isAvailable = true;
break;
}
else if (rpl0->isRefPicLongterm(ii) && rpcPic->referenced && (rpcPic->getPOC() & (pocCycle - 1)) == rpl0->getRefPicIdentifier(ii) && !slice->isPocRestrictedByDRAP(rpcPic->getPOC(), rpcPic->precedingDRAP))
{
isAvailable = true;
break;
}
if (isAvailable)
{
pLocalRPL0->setRefPicIdentifier(refPicIdxL0, rpl0->getRefPicIdentifier(ii), rpl0->isRefPicLongterm(ii), false, NOT_VALID);
refPicIdxL0++;
numOfSTRPL0 = numOfSTRPL0 + ((rpl0->isRefPicLongterm(ii)) ? 0 : 1);
numOfLTRPL0 += (rpl0->isRefPicLongterm(ii) && !rpl0->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 = rpl0->getNumberOfInterLayerPictures() ? rpl0->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()) )
pLocalRPL0->setRefPicIdentifier( refPicIdxL0, 0, true, true, vps->getInterLayerRefIdc( layerIdx, refLayerIdx ) );
refPicIdxL0++;
numOfILRPL0++;
Vadim Seregin
committed
ii++;
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
}
}
}
}
if( slice->getEnableDRAPSEI() )
{
pLocalRPL0->setNumberOfShorttermPictures( numOfSTRPL0 );
pLocalRPL0->setNumberOfLongtermPictures( numOfLTRPL0 );
pLocalRPL0->setNumberOfInterLayerPictures( numOfILRPL0 );
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++;
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
}
}
}
}
//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 );
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
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 );
}