Newer
Older

Karsten Suehring
committed
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
}
// deblockingFilterControlPresentFlag is true if any of the settings differ from the inferred values:
const bool deblockingFilterControlPresentFlag = pps.getDeblockingFilterOverrideEnabledFlag() ||
pps.getPPSDeblockingFilterDisabledFlag() ||
pps.getDeblockingFilterBetaOffsetDiv2() != 0 ||
pps.getDeblockingFilterTcOffsetDiv2() != 0;
pps.setDeblockingFilterControlPresentFlag(deblockingFilterControlPresentFlag);
pps.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
pps.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag );
int histogram[MAX_NUM_REF + 1];
for( int i = 0; i <= MAX_NUM_REF; i++ )
{
histogram[i]=0;
}
for( int i = 0; i < getGOPSize(); i++)
{
CHECK(!(getRPLEntry(0, i).m_numRefPicsActive >= 0 && getRPLEntry(0, i).m_numRefPicsActive <= MAX_NUM_REF), "Unspecified error");
histogram[getRPLEntry(0, i).m_numRefPicsActive]++;

Karsten Suehring
committed
}
int maxHist=-1;
int bestPos=0;
for( int i = 0; i <= MAX_NUM_REF; i++ )
{
if(histogram[i]>maxHist)
{
maxHist=histogram[i];
bestPos=i;
}
}
CHECK(!(bestPos <= 15), "Unspecified error");
pps.setNumRefIdxL0DefaultActive(bestPos);

Karsten Suehring
committed
pps.setNumRefIdxL1DefaultActive(bestPos);
#if !JVET_P2001_REMOVE_TRANSQUANT_BYPASS

Karsten Suehring
committed
pps.setTransquantBypassEnabledFlag(getTransquantBypassEnabledFlag());
pps.setLog2MaxTransformSkipBlockSize(m_log2MaxTransformSkipBlockSize);

Karsten Suehring
committed
xInitPPSforTiles(pps);
#if JVET_P1006_PICTURE_HEADER
pps.setPictureHeaderExtensionPresentFlag(false);
#else
Sheng-Yen Lin
committed
pps.setLoopFilterAcrossVirtualBoundariesDisabledFlag( m_loopFilterAcrossVirtualBoundariesDisabledFlag );
pps.setNumVerVirtualBoundaries ( m_numVerVirtualBoundaries );
pps.setNumHorVirtualBoundaries ( m_numHorVirtualBoundaries );
for( unsigned int i = 0; i < m_numVerVirtualBoundaries; i++ )
{
pps.setVirtualBoundariesPosX ( m_virtualBoundariesPosX[i], i );
}
for( unsigned int i = 0; i < m_numHorVirtualBoundaries; i++ )
{
pps.setVirtualBoundariesPosY ( m_virtualBoundariesPosY[i], i );
}
Sheng-Yen Lin
committed

Karsten Suehring
committed
pps.pcv = new PreCalcValues( sps, pps, true );
pps.setRpl1IdxPresentFlag(sps.getRPL1IdxPresentFlag());

Karsten Suehring
committed
}
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
#if JVET_P1006_PICTURE_HEADER
void EncLib::xInitPicHeader(PicHeader &picHeader, const SPS &sps, const PPS &pps)
{
int i;
picHeader.initPicHeader();
// parameter sets
picHeader.setSPSId( sps.getSPSId() );
picHeader.setPPSId( pps.getPPSId() );
// merge list sizes
picHeader.setMaxNumMergeCand ( getMaxNumMergeCand() );
picHeader.setMaxNumAffineMergeCand( getMaxNumAffineMergeCand() );
picHeader.setMaxNumTriangleCand ( getMaxNumTriangleCand() );
picHeader.setMaxNumIBCMergeCand ( getMaxNumIBCMergeCand() );
// copy partitioning constraints from SPS
picHeader.setSplitConsOverrideFlag(false);
picHeader.setMinQTSizes( sps.getMinQTSizes() );
picHeader.setMaxMTTHierarchyDepths( sps.getMaxMTTHierarchyDepths() );
picHeader.setMaxBTSizes( sps.getMaxBTSizes() );
picHeader.setMaxTTSizes( sps.getMaxTTSizes() );
// quantization
picHeader.setDepQuantEnabledFlag( getDepQuantEnabledFlag() );
picHeader.setSignDataHidingEnabledFlag( getSignDataHidingEnabledFlag() );
bool bUseDQP = (getCuQpDeltaSubdiv() > 0)? true : false;
if( (getMaxDeltaQP() != 0 )|| getUseAdaptiveQP() )
{
bUseDQP = true;
}
#if SHARP_LUMA_DELTA_QP
if( getLumaLevelToDeltaQPMapping().isEnabled() )
{
bUseDQP = true;
}
#endif
#if ENABLE_QPA
if( getUsePerceptQPA() && !bUseDQP )
{
CHECK( m_cuQpDeltaSubdiv != 0, "max. delta-QP subdiv must be zero!" );
bUseDQP = (getBaseQP() < 38) && (getSourceWidth() > 512 || getSourceHeight() > 320);
}
#endif
if( m_costMode==COST_SEQUENCE_LEVEL_LOSSLESS || m_costMode==COST_LOSSLESS_CODING )
{
bUseDQP=false;
}
if( m_RCEnableRateControl )
{
picHeader.setCuQpDeltaSubdivIntra( 0 );
picHeader.setCuQpDeltaSubdivInter( 0 );
}
else if( bUseDQP )
{
picHeader.setCuQpDeltaSubdivIntra( m_cuQpDeltaSubdiv );
picHeader.setCuQpDeltaSubdivInter( m_cuQpDeltaSubdiv );
}
else
{
picHeader.setCuQpDeltaSubdivIntra( 0 );
picHeader.setCuQpDeltaSubdivInter( 0 );
}
if( m_cuChromaQpOffsetSubdiv >= 0 )
{
picHeader.setCuChromaQpOffsetSubdivIntra(m_cuChromaQpOffsetSubdiv);
picHeader.setCuChromaQpOffsetSubdivInter(m_cuChromaQpOffsetSubdiv);
}
else
{
picHeader.setCuChromaQpOffsetSubdivIntra(0);
picHeader.setCuChromaQpOffsetSubdivInter(0);
}
// sub-pictures
picHeader.setSubPicIdSignallingPresentFlag(sps.getSubPicIdSignallingPresentFlag());
picHeader.setSubPicIdLen(sps.getSubPicIdLen());
for(i=0; i<sps.getNumSubPics(); i++) {
picHeader.setSubPicId(i, sps.getSubPicId(i));
}
// virtual boundaries
picHeader.setLoopFilterAcrossVirtualBoundariesDisabledFlag(sps.getLoopFilterAcrossVirtualBoundariesDisabledFlag());
picHeader.setNumVerVirtualBoundaries(sps.getNumVerVirtualBoundaries());
picHeader.setNumHorVirtualBoundaries(sps.getNumHorVirtualBoundaries());
for(i=0; i<3; i++) {
picHeader.setVirtualBoundariesPosX(sps.getVirtualBoundariesPosX(i), i);
picHeader.setVirtualBoundariesPosY(sps.getVirtualBoundariesPosY(i), i);
}
// gradual decoder refresh flag
picHeader.setGdrPicFlag(false);
// BDOF / DMVR / PROF

Xuewei Meng
committed
#if JVET_P0314_PROF_BDOF_DMVR_HLS
picHeader.setDisBdofFlag(false);
picHeader.setDisDmvrFlag(false);
picHeader.setDisProfFlag(false);
#else

Xuewei Meng
committed
#endif
void EncLib::xInitAPS(APS &aps)
{
//Do nothing now
}
void EncLib::xInitRPL(SPS &sps, bool isFieldCoding)
{
ReferencePictureList* rpl;
int numRPLCandidates = getRPLCandidateSize(0);
sps.createRPLList0(numRPLCandidates);
sps.createRPLList1(numRPLCandidates);
RPLList* rplList = 0;
for (int i = 0; i < 2; i++)
{
rplList = (i == 0) ? sps.getRPLList0() : sps.getRPLList1();
for (int j = 0; j < numRPLCandidates; j++)
{
const RPLEntry &ge = getRPLEntry(i, j);
rpl = rplList->getReferencePictureList(j);
rpl->setNumberOfShorttermPictures(ge.m_numRefPics);
rpl->setNumberOfLongtermPictures(0); //Hardcoded as 0 for now. need to update this when implementing LTRP
rpl->setNumberOfActivePictures(ge.m_numRefPicsActive);
Philip Cowan
committed
rpl->setLtrpInSliceHeaderFlag(ge.m_ltrp_in_slice_header_flag);
#if JVET_O1159_SCALABILITY
rpl->setInterLayerPresentFlag( sps.getInterLayerPresentFlag() );
// inter-layer reference picture is not signaled in SPS RPL, SPS is shared currently
rpl->setNumberOfInterLayerPictures( 0 );
#endif
for (int k = 0; k < ge.m_numRefPics; k++)
{
#if JVET_O1159_SCALABILITY
rpl->setRefPicIdentifier( k, ge.m_deltaRefPics[k], 0, false, 0 );
#else
rpl->setRefPicIdentifier(k, ge.m_deltaRefPics[k], 0);
//Check if all delta POC of STRP in each RPL has the same sign
//Check RPLL0 first
const RPLList* rplList0 = sps.getRPLList0();
const RPLList* rplList1 = sps.getRPLList1();
uint32_t numberOfRPL = sps.getNumRPL0();
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
bool isAllEntriesinRPLHasSameSignFlag = true;
bool isFirstEntry = true;
bool lastSign = true; //true = positive ; false = negative
for (uint32_t ii = 0; isAllEntriesinRPLHasSameSignFlag && ii < numberOfRPL; ii++)
{
const ReferencePictureList* rpl = rplList0->getReferencePictureList(ii);
for (uint32_t jj = 0; isAllEntriesinRPLHasSameSignFlag && jj < rpl->getNumberOfActivePictures(); jj++)
{
if (!rpl->isRefPicLongterm(jj) && isFirstEntry)
{
lastSign = (rpl->getRefPicIdentifier(jj) >= 0) ? true : false;
isFirstEntry = false;
}
else if (!rpl->isRefPicLongterm(jj) && (((rpl->getRefPicIdentifier(jj) - rpl->getRefPicIdentifier(jj - 1)) >= 0 && lastSign == false) || ((rpl->getRefPicIdentifier(jj) - rpl->getRefPicIdentifier(jj - 1)) < 0 && lastSign == true)))
{
isAllEntriesinRPLHasSameSignFlag = false;
}
}
}
//Check RPLL1. Skip it if it is already found out that this flag is not true for RPL0 or if RPL1 is the same as RPL0
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
isFirstEntry = true;
lastSign = true;
for (uint32_t ii = 0; isAllEntriesinRPLHasSameSignFlag && !sps.getRPL1CopyFromRPL0Flag() && ii < numberOfRPL; ii++)
{
isFirstEntry = true;
const ReferencePictureList* rpl = rplList1->getReferencePictureList(ii);
for (uint32_t jj = 0; isAllEntriesinRPLHasSameSignFlag && jj < rpl->getNumberOfActivePictures(); jj++)
{
if (!rpl->isRefPicLongterm(jj) && isFirstEntry)
{
lastSign = (rpl->getRefPicIdentifier(jj) >= 0) ? true : false;
isFirstEntry = false;
}
else if (!rpl->isRefPicLongterm(jj) && (((rpl->getRefPicIdentifier(jj) - rpl->getRefPicIdentifier(jj - 1)) >= 0 && lastSign == false) || ((rpl->getRefPicIdentifier(jj) - rpl->getRefPicIdentifier(jj - 1)) < 0 && lastSign == true)))
{
isAllEntriesinRPLHasSameSignFlag = false;
}
}
}
sps.setAllActiveRplEntriesHasSameSignFlag(isAllEntriesinRPLHasSameSignFlag);
}
void EncLib::getActiveRefPicListNumForPOC(const SPS *sps, int POCCurr, int GOPid, uint32_t *activeL0, uint32_t *activeL1)
{
if (m_uiIntraPeriod < 0) //Only for RA
{
*activeL0 = *activeL1 = 0;
return;
}
uint32_t rpl0Idx = GOPid;
uint32_t rpl1Idx = GOPid;
int fullListNum = m_iGOPSize;
int partialListNum = getRPLCandidateSize(0) - m_iGOPSize;
int extraNum = fullListNum;
if (m_uiIntraPeriod < 0)
{
#if JVET_P0345_LD_GOP_8
if (POCCurr < (2 * m_iGOPSize + 2))
#else
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
{
rpl0Idx = POCCurr + m_iGOPSize - 1;
rpl1Idx = POCCurr + m_iGOPSize - 1;
}
else
{
rpl0Idx = (POCCurr%m_iGOPSize == 0) ? m_iGOPSize - 1 : POCCurr%m_iGOPSize - 1;
rpl1Idx = (POCCurr%m_iGOPSize == 0) ? m_iGOPSize - 1 : POCCurr%m_iGOPSize - 1;
}
extraNum = fullListNum + partialListNum;
}
for (; extraNum<fullListNum + partialListNum; extraNum++)
{
if (m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
{
int POCIndex = POCCurr%m_uiIntraPeriod;
if (POCIndex == 0)
POCIndex = m_uiIntraPeriod;
if (POCIndex == m_RPLList0[extraNum].m_POC)
{
rpl0Idx = extraNum;
rpl1Idx = extraNum;
extraNum++;
}
}
}
const ReferencePictureList *rpl0 = sps->getRPLList0()->getReferencePictureList(rpl0Idx);
*activeL0 = rpl0->getNumberOfActivePictures();
const ReferencePictureList *rpl1 = sps->getRPLList1()->getReferencePictureList(rpl1Idx);
*activeL1 = rpl1->getNumberOfActivePictures();
}
void EncLib::selectReferencePictureList(Slice* slice, int POCCurr, int GOPid, int ltPoc)
{
bool isEncodeLtRef = (POCCurr == ltPoc);
if (m_compositeRefEnabled && isEncodeLtRef)
{
POCCurr++;
}
slice->setRPL0idx(GOPid);
slice->setRPL1idx(GOPid);
int fullListNum = m_iGOPSize;
int partialListNum = getRPLCandidateSize(0) - m_iGOPSize;
int extraNum = fullListNum;
if (m_uiIntraPeriod < 0)
{
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
{
slice->setRPL0idx(POCCurr + m_iGOPSize - 1);
slice->setRPL1idx(POCCurr + m_iGOPSize - 1);
}
else
{
slice->setRPL0idx((POCCurr%m_iGOPSize == 0) ? m_iGOPSize - 1 : POCCurr%m_iGOPSize - 1);
slice->setRPL1idx((POCCurr%m_iGOPSize == 0) ? m_iGOPSize - 1 : POCCurr%m_iGOPSize - 1);
}
extraNum = fullListNum + partialListNum;
}
for (; extraNum < fullListNum + partialListNum; extraNum++)
{
if (m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
{
int POCIndex = POCCurr%m_uiIntraPeriod;
if (POCIndex == 0)
POCIndex = m_uiIntraPeriod;
if (POCIndex == m_RPLList0[extraNum].m_POC)
{
slice->setRPL0idx(extraNum);
slice->setRPL1idx(extraNum);
extraNum++;
}
}
}
const ReferencePictureList *rpl0 = (slice->getSPS()->getRPLList0()->getReferencePictureList(slice->getRPL0idx()));
const ReferencePictureList *rpl1 = (slice->getSPS()->getRPLList1()->getReferencePictureList(slice->getRPL1idx()));
slice->setRPL0(rpl0);
slice->setRPL1(rpl1);
}

Karsten Suehring
committed

Karsten Suehring
committed
void EncLib::xInitPPSforTiles(PPS &pps)
{
if ( (m_iNumColumnsMinus1==0) && (m_iNumRowsMinus1==0) )
{
// one, no bricks
pps.setSingleTileInPicFlag(true);
pps.setSingleBrickPerSliceFlag(true);
pps.setRectSliceFlag(true);
}
else
{
pps.setSingleTileInPicFlag(false);
pps.setSingleBrickPerSliceFlag( m_sliceMode==SINGLE_BRICK_PER_SLICE );
pps.setRectSliceFlag( m_sliceMode==SINGLE_BRICK_PER_SLICE );
if (m_rectSliceFlag)
pps.setRectSliceFlag(m_rectSliceFlag);
}
pps.setUniformTileSpacingFlag( m_tileUniformSpacingFlag );

Karsten Suehring
committed
pps.setNumTileColumnsMinus1( m_iNumColumnsMinus1 );
pps.setNumTileRowsMinus1( m_iNumRowsMinus1 );
if( !m_tileUniformSpacingFlag )
{
pps.setTileColumnWidth( m_tileColumnWidth );
pps.setTileRowHeight( m_tileRowHeight );
}
else
{
pps.setTileColsWidthMinus1(m_uniformTileColsWidthMinus1);
pps.setTileRowsHeightMinus1(m_uniformTileRowHeightMinus1);
}
pps.setLoopFilterAcrossBricksEnabledFlag( m_loopFilterAcrossBricksEnabledFlag );
//pps.setRectSliceFlag( m_rectSliceFlag );
pps.setNumSlicesInPicMinus1( m_numSlicesInPicMinus1 );
pps.setTopLeftBrickIdx(m_topLeftBrickIdx);
pps.setBottomRightBrickIdx(m_bottomRightBrickIdx);
if (m_numSlicesInPicMinus1 > 0)
{
std::vector<int> bottomrightdelta(m_numSlicesInPicMinus1 + 1);
for (int i = 0; i < m_numSlicesInPicMinus1 + 1; i++)
{
bottomrightdelta[i] = (i == 0) ? m_bottomRightBrickIdx[i] : m_bottomRightBrickIdx[i] - m_bottomRightBrickIdx[i - 1];
}
pps.setBottomRightBrickIdxDelta(bottomrightdelta);
}
pps.setLoopFilterAcrossBricksEnabledFlag( m_loopFilterAcrossBricksEnabledFlag );
pps.setLoopFilterAcrossSlicesEnabledFlag( m_loopFilterAcrossSlicesEnabledFlag );
pps.setSignalledSliceIdFlag( m_signalledSliceIdFlag );
pps.setSignalledSliceIdLengthMinus1( m_signalledSliceIdLengthMinus1 );
pps.setSignalledSliceIdFlag( m_signalledSliceIdFlag );
pps.setSignalledSliceIdLengthMinus1( m_signalledSliceIdLengthMinus1 );
pps.setSliceId( m_sliceId );
int numTiles= (m_iNumColumnsMinus1 + 1) * (m_iNumRowsMinus1 + 1);
pps.setNumTilesInPic(numTiles);
std::vector<int> tileHeight(numTiles);
if (m_brickSplitMap.empty())
{
pps.setBrickSplittingPresentFlag(false);
}
else
{
pps.setBrickSplittingPresentFlag(true);
std::vector<bool> brickSplitFlag (numTiles, false);
std::vector<bool> uniformBrickSpacingFlag (numTiles, false);
std::vector<int> brickHeightMinus1 (numTiles, 0);
std::vector<int> numBrickRowsMinus2(numTiles, 0);
std::vector<std::vector<int>> brickRowHeightMinus1 (numTiles);
for (auto &brickSplit: m_brickSplitMap)
{
int tileIdx = brickSplit.first;
CHECK ( tileIdx >= numTiles, "Brick split specified for undefined tile");
brickSplitFlag[tileIdx] = true;
uniformBrickSpacingFlag [tileIdx] = brickSplit.second.m_uniformSplit;
if (uniformBrickSpacingFlag [tileIdx])
{
brickHeightMinus1[tileIdx]=brickSplit.second.m_uniformHeight - 1;
}
else
{
numBrickRowsMinus2[tileIdx] = brickSplit.second.m_numSplits - 1;
brickRowHeightMinus1[tileIdx].resize(brickSplit.second.m_numSplits);
for (int i=0; i<brickSplit.second.m_numSplits; i++)
{
brickRowHeightMinus1[tileIdx][i]=brickSplit.second.m_brickHeight[i] - 1;
}
}
}
pps.setBrickSplitFlag(brickSplitFlag);
pps.setUniformBrickSpacingFlag(uniformBrickSpacingFlag);
pps.setBrickHeightMinus1(brickHeightMinus1);
pps.setNumBrickRowsMinus2(numBrickRowsMinus2);
pps.setBrickRowHeightMinus1(brickRowHeightMinus1);
// check brick dimensions
std::vector<uint32_t> tileRowHeight (m_iNumRowsMinus1+1);
int picHeightInCtus = (getSourceHeight() + m_maxCUHeight - 1) / m_maxCUHeight;
// calculate all tile row heights
if( pps.getUniformTileSpacingFlag() )
{
//set width and height for each (uniform) tile
for(int row=0; row < m_iNumRowsMinus1 + 1; row++)
{
tileRowHeight[row] = (row+1)*picHeightInCtus/(m_iNumRowsMinus1+1) - (row*picHeightInCtus)/(m_iNumRowsMinus1 + 1);
}
}
else
{
tileRowHeight[ m_iNumRowsMinus1 ] = picHeightInCtus;
for( int j = 0; j < m_iNumRowsMinus1; j++ )
{
tileRowHeight[ j ] = pps.getTileRowHeight( j );
tileRowHeight[ m_iNumRowsMinus1 ] = tileRowHeight[ m_iNumRowsMinus1 ] - pps.getTileRowHeight( j );
}
}
// check brick splits for each tile
for (int tileIdx=0; tileIdx < numTiles; tileIdx++)
{
const int tileY = tileIdx / (m_iNumColumnsMinus1 + 1);
tileHeight[tileIdx] = tileRowHeight[tileY];
if (tileHeight[tileIdx] <= 1)
{
CHECK(pps.getBrickSplitFlag(tileIdx) != 0, "The value of brick_split_flag[ i ] shall be 0 if tileHeight <= 1");
}
if (tileHeight[tileIdx] <= 2)
{
CHECK(pps.getUniformBrickSpacingFlag(tileIdx) != 1, "The value of uniform_brick_spacing_flag[ i ] shall be 1 if tileHeight <= 2");
}
if (pps.getUniformBrickSpacingFlag(tileIdx))
{
CHECK((pps.getBrickHeightMinus1(tileIdx) + 1) >= tileHeight[tileIdx], "Brick height larger than or equal to tile height");
for (int i = 0; i <= pps.getNumBrickRowsMinus2(tileIdx); i++)
{
cumulativeHeight += pps.getBrickRowHeightMinus1(tileIdx, i) + 1;
}
CHECK(cumulativeHeight >= tileHeight[tileIdx], "Cumulative brick height larger than or equal to tile height");
pps.setTileHeight(tileHeight);

Karsten Suehring
committed
}
void EncCfg::xCheckGSParameters()
{
int iWidthInCU = ( m_iSourceWidth%m_maxCUWidth ) ? m_iSourceWidth/m_maxCUWidth + 1 : m_iSourceWidth/m_maxCUWidth;
int iHeightInCU = ( m_iSourceHeight%m_maxCUHeight ) ? m_iSourceHeight/m_maxCUHeight + 1 : m_iSourceHeight/m_maxCUHeight;
uint32_t uiCummulativeColumnWidth = 0;
uint32_t uiCummulativeRowHeight = 0;
if (m_tileUniformSpacingFlag && m_uniformTileColsWidthMinus1 == -1)
{
EXIT("Uniform tiles specified with unspecified or invalid UniformTileColsWidthMinus1 value");
}
if (m_tileUniformSpacingFlag && m_uniformTileRowHeightMinus1 == -1)
{
EXIT("Uniform tiles specified with unspecified or invalid UniformTileRowHeightMinus1 value");
}
if (m_tileUniformSpacingFlag && m_uniformTileColsWidthMinus1 >= iWidthInCU)
{
EXIT("UniformTileColsWidthMinus1 too large");
}
if (m_tileUniformSpacingFlag && m_uniformTileRowHeightMinus1 >= iHeightInCU)
{
EXIT("UniformTileRowHeightMinus1 too large");
}

Karsten Suehring
committed
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
//check the column relative parameters
if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) )
{
EXIT( "The number of columns is larger than the maximum allowed number of columns." );
}
if( m_iNumColumnsMinus1 >= iWidthInCU )
{
EXIT( "The current picture can not have so many columns." );
}
if( m_iNumColumnsMinus1 && !m_tileUniformSpacingFlag )
{
for(int i=0; i<m_iNumColumnsMinus1; i++)
{
uiCummulativeColumnWidth += m_tileColumnWidth[i];
}
if( uiCummulativeColumnWidth >= iWidthInCU )
{
EXIT( "The width of the column is too large." );
}
}
//check the row relative parameters
if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) )
{
EXIT( "The number of rows is larger than the maximum allowed number of rows." );
}
if( m_iNumRowsMinus1 >= iHeightInCU )
{
EXIT( "The current picture can not have so many rows." );
}
if( m_iNumRowsMinus1 && !m_tileUniformSpacingFlag )
{
for(int i=0; i<m_iNumRowsMinus1; i++)
{
uiCummulativeRowHeight += m_tileRowHeight[i];
}
if( uiCummulativeRowHeight >= iHeightInCU )
{
EXIT( "The height of the row is too large." );
}
}
}

Karsten Suehring
committed
void EncLib::setParamSetChanged(int spsId, int ppsId)
{
m_ppsMap.setChangedFlag(ppsId);
m_spsMap.setChangedFlag(spsId);
}
Hendry
committed
bool isChanged = m_apsMap.getChangedFlag(apsId);
Hendry
committed
return isChanged;

Karsten Suehring
committed
bool EncLib::PPSNeedsWriting(int ppsId)
{
bool bChanged=m_ppsMap.getChangedFlag(ppsId);
m_ppsMap.clearChangedFlag(ppsId);
return bChanged;
}
bool EncLib::SPSNeedsWriting(int spsId)
{
bool bChanged=m_spsMap.getChangedFlag(spsId);
m_spsMap.clearChangedFlag(spsId);
return bChanged;
}
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
void EncLib::checkPltStats( Picture* pic )
{
int totalArea = 0;
int pltArea = 0;
for (auto apu : pic->cs->pus)
{
for (int i = 0; i < MAX_NUM_TBLOCKS; ++i)
{
int puArea = apu->blocks[i].width * apu->blocks[i].height;
if (apu->blocks[i].width > 0 && apu->blocks[i].height > 0)
{
totalArea += puArea;
if (CU::isPLT(*apu->cu) || CU::isIBC(*apu->cu))
{
pltArea += puArea;
}
break;
}
}
}
if (pltArea * PLT_FAST_RATIO < totalArea)
{
m_doPlt = false;
}
else
{
m_doPlt = true;
}
}

Karsten Suehring
committed
#if X0038_LAMBDA_FROM_QP_CAPABILITY
int EncCfg::getQPForPicture(const uint32_t gopIndex, const Slice *pSlice) const
{
const int lumaQpBDOffset = pSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA);
int qp;
if (getCostMode()==COST_LOSSLESS_CODING)
{
#if JVET_AHG14_LOSSLESS
qp = LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP - ( ( pSlice->getSPS()->getBitDepth( CHANNEL_TYPE_LUMA ) - 8 ) * 6 );
#else

Karsten Suehring
committed
qp=LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP;

Karsten Suehring
committed
}
else
{
const SliceType sliceType=pSlice->getSliceType();
qp = getBaseQP();
// switch at specific qp and keep this qp offset
static int appliedSwitchDQQ = 0; /* TODO: MT */
if( pSlice->getPOC() == getSwitchPOC() )
{
appliedSwitchDQQ = getSwitchDQP();
}
qp += appliedSwitchDQQ;
#if QP_SWITCHING_FOR_PARALLEL
const int* pdQPs = getdQPs();
if ( pdQPs )
{
qp += pdQPs[pSlice->getPOC() / (m_compositeRefEnabled ? 2 : 1)];

Karsten Suehring
committed
}
#endif
if(sliceType==I_SLICE)
{
qp += getIntraQPOffset();
}
else
{
#if !JVET_P2001_REMOVE_TRANSQUANT_BYPASS

Karsten Suehring
committed
#if SHARP_LUMA_DELTA_QP
// Only adjust QP when not lossless
if (!(( getMaxDeltaQP() == 0 ) && (!getLumaLevelToDeltaQPMapping().isEnabled()) && (qp == -lumaQpBDOffset ) && (pSlice->getPPS()->getTransquantBypassEnabledFlag())))
#else
if (!(( getMaxDeltaQP() == 0 ) && (qp == -lumaQpBDOffset ) && (pSlice->getPPS()->getTransquantBypassEnabledFlag())))
#endif
{

Karsten Suehring
committed
const GOPEntry &gopEntry=getGOPEntry(gopIndex);
// adjust QP according to the QP offset for the GOP entry.
qp +=gopEntry.m_QPOffset;
// adjust QP according to QPOffsetModel for the GOP entry.
double dqpOffset=qp*gopEntry.m_QPOffsetModelScale+gopEntry.m_QPOffsetModelOffset+0.5;
int qpOffset = (int)floor(Clip3<double>(0.0, 3.0, dqpOffset));
qp += qpOffset ;
}
#if !JVET_P2001_REMOVE_TRANSQUANT_BYPASS

Karsten Suehring
committed
}

Karsten Suehring
committed
#if !QP_SWITCHING_FOR_PARALLEL
// modify QP if a fractional QP was originally specified, cause dQPs to be 0 or 1.
const int* pdQPs = getdQPs();
if ( pdQPs )
{
qp += pdQPs[ pSlice->getPOC() ];
}
#endif
}
qp = Clip3( -lumaQpBDOffset, MAX_QP, qp );
return qp;
}
#endif