...
 
Commits (14)
This diff is collapsed.
This diff is collapsed.
......@@ -205,7 +205,6 @@ public:
static const CtxSet RegularMergeFlag;
#endif
static const CtxSet MergeIdx;
static const CtxSet PartSize;
static const CtxSet PredMode;
static const CtxSet MultiRefLineIdx;
static const CtxSet IntraLumaMpmFlag;
......
......@@ -560,7 +560,7 @@ void IntraPrediction::initPredIntraParams(const PredictionUnit & pu, const CompA
if (dirMode > DC_IDX && dirMode < NUM_LUMA_MODE) // intraPredAngle for directional modes
{
static const int angTable[32] = { 0, 1, 2, 3, 4, 6, 8, 10, 12, 14, 16, 18, 20, 23, 26, 29, 32, 35, 39, 45, 51, 57, 64, 73, 86, 102, 128, 171, 256, 341, 512, 1024 };
static const int invAngTable[32] = { 0, 8192, 4096, 2731, 2048, 1365, 1024, 819, 683, 585, 512, 455, 410, 356, 315, 282, 256, 234, 210, 182, 160, 144, 128, 112, 95, 80, 64, 48, 32, 24, 16, 8 }; // (256 * 32) / Angle
static const int invAngTable[32] = { 0, 8192, 4096, 2731, 2048, 1365, 1024, 819, 683, 585, 512, 455, 410, 356, 315, 282, 256, 234, 210, 182, 161, 144, 128, 112, 95, 80, 64, 48, 32, 24, 16, 8 }; // (256 * 32) / Angle
const int absAngMode = abs(intraPredAngleMode);
const int signAng = intraPredAngleMode < 0 ? -1 : 1;
......
......@@ -4105,12 +4105,123 @@ void EncAdaptiveLoopFilter::alfReconstructor(CodingStructure& cs, const PelUnitB
const PreCalcValues& pcv = *cs.pcv;
int ctuIdx = 0;
#if JVET_N0438_LOOP_FILTER_DISABLED_ACROSS_VIR_BOUND
bool clipTop = false, clipBottom = false, clipLeft = false, clipRight = false;
int numHorSplit = 0, numVerSplit = 0;
int horSplit[] = { 0, 0, 0 };
int verSplit[] = { 0, 0, 0 };
#endif
for (int yPos = 0; yPos < pcv.lumaHeight; yPos += pcv.maxCUHeight)
{
for (int xPos = 0; xPos < pcv.lumaWidth; xPos += pcv.maxCUWidth)
{
const int width = (xPos + pcv.maxCUWidth > pcv.lumaWidth) ? (pcv.lumaWidth - xPos) : pcv.maxCUWidth;
const int height = (yPos + pcv.maxCUHeight > pcv.lumaHeight) ? (pcv.lumaHeight - yPos) : pcv.maxCUHeight;
#if JVET_N0438_LOOP_FILTER_DISABLED_ACROSS_VIR_BOUND
bool ctuEnableFlag = m_ctuEnableFlag[COMPONENT_Y][ctuIdx];
for (int compIdx = 1; compIdx < MAX_NUM_COMPONENT; compIdx++)
{
ctuEnableFlag |= m_ctuEnableFlag[compIdx][ctuIdx] > 0;
}
if (ctuEnableFlag && isCrossedByVirtualBoundaries(xPos, yPos, width, height, clipTop, clipBottom, clipLeft, clipRight, numHorSplit, numVerSplit, horSplit, verSplit, cs.slice->getPPS()))
{
int yStart = yPos;
for (int i = 0; i <= numHorSplit; i++)
{
const int yEnd = i == numHorSplit ? yPos + height : horSplit[i];
const int h = yEnd - yStart;
int xStart = xPos;
for (int j = 0; j <= numVerSplit; j++)
{
const int xEnd = j == numVerSplit ? xPos + width : verSplit[j];
const int w = xEnd - xStart;
if (m_ctuEnableFlag[COMPONENT_Y][ctuIdx])
{
const Area blkSrc(0, 0, w, h);
const Area blkDst(xStart, yStart, w, h);
short filterSetIndex = alfCtuFilterIndex[ctuIdx];
short *coeff;
#if JVET_N0242_NON_LINEAR_ALF
short *clip;
#endif
if (filterSetIndex >= NUM_FIXED_FILTER_SETS)
{
coeff = m_coeffApsLuma[filterSetIndex - NUM_FIXED_FILTER_SETS];
#if JVET_N0242_NON_LINEAR_ALF
clip = m_clippApsLuma[filterSetIndex - NUM_FIXED_FILTER_SETS];
#endif
}
else
{
coeff = m_fixedFilterSetCoeffDec[filterSetIndex];
#if JVET_N0242_NON_LINEAR_ALF
clip = m_clipDefault;
#endif
}
#if JVET_N0180_ALF_LINE_BUFFER_REDUCTION
#if JVET_N0242_NON_LINEAR_ALF
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blkDst, blkSrc, COMPONENT_Y, coeff, clip, m_clpRngs.comp[COMPONENT_Y], cs
, m_alfVBLumaCTUHeight
, ((yPos + pcv.maxCUHeight >= pcv.lumaHeight) ? pcv.lumaHeight : m_alfVBLumaPos)
);
#else
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blkDst, blkSrc, COMPONENT_Y, coeff, m_clpRngs.comp[COMPONENT_Y], cs
, m_alfVBLumaCTUHeight
, ((yPos + pcv.maxCUHeight >= pcv.lumaHeight) ? pcv.lumaHeight : m_alfVBLumaPos)
);
#endif
#else
#if JVET_N0242_NON_LINEAR_ALF
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blkDst, blkSrc, COMPONENT_Y, coeff, clip, m_clpRngs.comp[COMPONENT_Y], cs);
#else
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blkDst, blkSrc, COMPONENT_Y, coeff, m_clpRngs.comp[COMPONENT_Y], cs);
#endif
#endif
}
for (int compIdx = 1; compIdx < MAX_NUM_COMPONENT; compIdx++)
{
ComponentID compID = ComponentID(compIdx);
const int chromaScaleX = getComponentScaleX(compID, recBuf.chromaFormat);
const int chromaScaleY = getComponentScaleY(compID, recBuf.chromaFormat);
if (m_ctuEnableFlag[compIdx][ctuIdx])
{
const Area blkSrc(0, 0, w >> chromaScaleX, h >> chromaScaleY);
const Area blkDst(xStart >> chromaScaleX, yStart >> chromaScaleY, w >> chromaScaleX, h >> chromaScaleY);
#if JVET_N0180_ALF_LINE_BUFFER_REDUCTION
#if JVET_N0242_NON_LINEAR_ALF
m_filter5x5Blk(m_classifier, recBuf, recExtBuf, blkDst, blkSrc, compID, m_chromaCoeffFinal, m_chromaClippFinal, m_clpRngs.comp[compIdx], cs
, m_alfVBChmaCTUHeight
, ((yPos + pcv.maxCUHeight >= pcv.lumaHeight) ? pcv.lumaHeight : m_alfVBChmaPos)
);
#else
m_filter5x5Blk(m_classifier, recBuf, recExtBuf, blkDst, blkSrc, compID, m_chromaCoeffFinal, m_clpRngs.comp[compIdx], cs
, m_alfVBChmaCTUHeight
, ((yPos + pcv.maxCUHeight >= pcv.lumaHeight) ? pcv.lumaHeight : m_alfVBChmaPos)
);
#endif
#else
#if JVET_N0242_NON_LINEAR_ALF
m_filter5x5Blk(m_classifier, recBuf, recExtBuf, blkDst, blkSrc, compID, m_chromaCoeffFinal, m_chromaClippFinal, m_clpRngs.comp[compIdx], cs);
#else
m_filter5x5Blk(m_classifier, recBuf, recExtBuf, blkDst, blkSrc, compID, m_chromaCoeffFinal, m_clpRngs.comp[compIdx], cs);
#endif
#endif
}
}
xStart = xEnd;
}
yStart = yEnd;
}
}
else
{
#endif
const UnitArea area(cs.area.chromaFormat, Area(xPos, yPos, width, height));
if (m_ctuEnableFlag[COMPONENT_Y][ctuIdx])
{
......@@ -4134,22 +4245,30 @@ void EncAdaptiveLoopFilter::alfReconstructor(CodingStructure& cs, const PelUnitB
clip = m_clipDefault;
#endif
}
#if JVET_N0438_LOOP_FILTER_DISABLED_ACROSS_VIR_BOUND
#if JVET_N0180_ALF_LINE_BUFFER_REDUCTION
#if JVET_N0242_NON_LINEAR_ALF
#if JVET_N0438_LOOP_FILTER_DISABLED_ACROSS_VIR_BOUND
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blk, blk, COMPONENT_Y, coeff, clip, m_clpRngs.comp[COMPONENT_Y], cs
, m_alfVBLumaCTUHeight
, ((yPos + pcv.maxCUHeight >= pcv.lumaHeight) ? pcv.lumaHeight : m_alfVBLumaPos)
);
#else
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blk, COMPONENT_Y, coeff, clip, m_clpRngs.comp[COMPONENT_Y], cs
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blk, blk, COMPONENT_Y, coeff, m_clpRngs.comp[COMPONENT_Y], cs
, m_alfVBLumaCTUHeight
, ((yPos + pcv.maxCUHeight >= pcv.lumaHeight) ? pcv.lumaHeight : m_alfVBLumaPos)
);
#endif
#else
#if JVET_N0438_LOOP_FILTER_DISABLED_ACROSS_VIR_BOUND
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blk, blk, COMPONENT_Y, coeff, m_clpRngs.comp[COMPONENT_Y], cs
#if JVET_N0242_NON_LINEAR_ALF
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blk, blk, COMPONENT_Y, coeff, clip, m_clpRngs.comp[COMPONENT_Y], cs);
#else
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blk, blk, COMPONENT_Y, coeff, m_clpRngs.comp[COMPONENT_Y], cs);
#endif
#endif
#else
#if JVET_N0180_ALF_LINE_BUFFER_REDUCTION
#if JVET_N0242_NON_LINEAR_ALF
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blk, COMPONENT_Y, coeff, clip, m_clpRngs.comp[COMPONENT_Y], cs
, m_alfVBLumaCTUHeight
, ((yPos + pcv.maxCUHeight >= pcv.lumaHeight) ? pcv.lumaHeight : m_alfVBLumaPos)
);
......@@ -4159,17 +4278,9 @@ void EncAdaptiveLoopFilter::alfReconstructor(CodingStructure& cs, const PelUnitB
, ((yPos + pcv.maxCUHeight >= pcv.lumaHeight) ? pcv.lumaHeight : m_alfVBLumaPos)
);
#endif
#endif
#else
#if JVET_N0242_NON_LINEAR_ALF
#if JVET_N0438_LOOP_FILTER_DISABLED_ACROSS_VIR_BOUND
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blk, blk, COMPONENT_Y, coeff, clip, m_clpRngs.comp[COMPONENT_Y], cs);
#else
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blk, COMPONENT_Y, coeff, clip, m_clpRngs.comp[COMPONENT_Y], cs);
#endif
#else
#if JVET_N0438_LOOP_FILTER_DISABLED_ACROSS_VIR_BOUND
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blk, blk, COMPONENT_Y, coeff, m_clpRngs.comp[COMPONENT_Y], cs);
#else
m_filter7x7Blk(m_classifier, recBuf, recExtBuf, blk, COMPONENT_Y, coeff, m_clpRngs.comp[COMPONENT_Y], cs);
#endif
......@@ -4228,6 +4339,9 @@ void EncAdaptiveLoopFilter::alfReconstructor(CodingStructure& cs, const PelUnitB
#endif
}
}
#if JVET_N0438_LOOP_FILTER_DISABLED_ACROSS_VIR_BOUND
}
#endif
ctuIdx++;
}
}
......
......@@ -1103,35 +1103,52 @@ void EncReshape::constructReshaperSDR()
int cwReduce1 = (cwScaleBins1 - histLenth - 1) * cnt1;
int cwReduce2 = (histLenth + 1 - cwScaleBins2) * cnt0;
int divCW = 0, modCW = 0;
if (resCW <= cwReduce1)
{
int idx = 0;
while (resCW > 0)
assert(cnt1 > 0);
divCW = resCW / cnt1;
modCW = resCW - divCW * cnt1;
if (divCW > 0)
{
if (m_binCW[idx] > (histLenth + 1))
for (i = 0; i < histBins; i++)
{
m_binCW[idx]--;
resCW--;
if (m_binCW[i] == cwScaleBins1)
m_binCW[i] -= divCW;
}
}
for (i = 0; i < histBins; i++)
{
if (modCW == 0) break;
if (m_binCW[i] >(histLenth + 1))
{
m_binCW[i]--;
modCW--;
}
idx++;
if (idx == histBins)
idx = 0;
}
}
else if (resCW > cwReduce1 && resCW <= (cwReduce1 + cwReduce2))
{
assert(cnt0 > 0);
resCW -= cwReduce1;
int idx = 0;
while (resCW > 0)
divCW = resCW / cnt0;
modCW = resCW - divCW * cnt0;
if (divCW > 0)
{
if (m_binCW[idx] > cwScaleBins2 && m_binCW[idx] < cwScaleBins1)
for (i = 0; i < histBins; i++)
{
m_binCW[idx]--;
resCW--;
if (m_binCW[i] == (histLenth + 1))
m_binCW[i] -= divCW;
}
}
for (i = 0; i < histBins; i++)
{
if (modCW == 0) break;
if (m_binCW[i] > cwScaleBins2 && m_binCW[i] < cwScaleBins1)
{
m_binCW[i]--;
modCW--;
}
idx++;
if (idx == histBins)
idx = 0;
}
for (i = 0; i < histBins; i++)
{
......@@ -1139,27 +1156,47 @@ void EncReshape::constructReshaperSDR()
m_binCW[i] = histLenth + 1;
}
}
else if (resCW > (cwReduce1 + cwReduce2))
else
{
for (i = 0; i < histBins; i++)
{
if (m_binCW[i] == histLenth + 1)
m_binCW[i] = cwScaleBins2;
if (m_binCW[i] == cwScaleBins1)
m_binCW[i] = histLenth + 1;
}
resCW -= (cwReduce1 + cwReduce2);
int idx = 0;
while (resCW > 0)
cnt2 += cnt0;
cnt0 += cnt1;
cnt1 = 0;
divCW = resCW / cnt0;
modCW = resCW - divCW * cnt0;
if (divCW > 0)
{
if (m_binCW[idx] > 0 && m_binCW[idx] < (histLenth + 1))
for (i = 0; i < histBins; i++)
{
m_binCW[idx]--;
resCW--;
if (m_binCW[i] == (histLenth + 1))
m_binCW[i] -= divCW;
}
idx++;
if (idx == histBins)
idx = 0;
}
for (i = 0; i < histBins; i++)
{
if (m_binCW[i] == histLenth + 1)
m_binCW[i] = cwScaleBins2;
if (m_binCW[i] == cwScaleBins1)
m_binCW[i] = histLenth + 1;
if (modCW == 0) break;
if (m_binCW[i] > cwScaleBins2)
{
m_binCW[i]--;
modCW--;
}
}
for (i = 0; i < histBins; i++)
{
if (modCW == 0) break;
if (m_binCW[i] > 0)
{
m_binCW[i]--;
modCW--;
}
}
}
}
......
......@@ -2785,11 +2785,11 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner)
if ((uiCostBi <= uiCost[0] && uiCostBi <= uiCost[1]) || enforceGBiPred)
{
xCopyAMVPInfo(&aacAMVPInfo[0][iRefIdxBi[0]], &amvp[REF_PIC_LIST_0]);
xCheckBestMVP( REF_PIC_LIST_0, cMvBi[0], cMvPredBi[0][iRefIdxBi[0]], aaiMvpIdxBi[0][iRefIdxBi[0]], amvp[eRefPicList], uiBits[2], uiCostBi, pu.cu->imv);
xCheckBestMVP( REF_PIC_LIST_0, cMvBi[0], cMvPredBi[0][iRefIdxBi[0]], aaiMvpIdxBi[0][iRefIdxBi[0]], amvp[REF_PIC_LIST_0], uiBits[2], uiCostBi, pu.cu->imv);
if(!cs.slice->getMvdL1ZeroFlag())
{
xCopyAMVPInfo(&aacAMVPInfo[1][iRefIdxBi[1]], &amvp[REF_PIC_LIST_1]);
xCheckBestMVP( REF_PIC_LIST_1, cMvBi[1], cMvPredBi[1][iRefIdxBi[1]], aaiMvpIdxBi[1][iRefIdxBi[1]], amvp[eRefPicList], uiBits[2], uiCostBi, pu.cu->imv);
xCheckBestMVP( REF_PIC_LIST_1, cMvBi[1], cMvPredBi[1][iRefIdxBi[1]], aaiMvpIdxBi[1][iRefIdxBi[1]], amvp[REF_PIC_LIST_1], uiBits[2], uiCostBi, pu.cu->imv);
}
}
break;
......
......@@ -1340,6 +1340,9 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner,
#if JVET_N0217_MATRIX_INTRAPRED
m_bestCostNonMip = MAX_DOUBLE;
#if JVET_N0193_LFNST
static_vector<int, FAST_UDI_MAX_RDMODE_NUM> rdModeIdxList;
#endif
if (testMip)
{
static_vector<ModeInfo, FAST_UDI_MAX_RDMODE_NUM> uiRdModeListTemp;
......@@ -1348,6 +1351,9 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner,
if( !uiRdModeList[i].mipFlg && uiRdModeList[i].ispMod==NOT_INTRA_SUBPARTITIONS )
{
uiRdModeListTemp.push_back( uiRdModeList[i] );
#if JVET_N0193_LFNST
rdModeIdxList.push_back( i );
#endif
}
}
for( int i = 0; i < uiRdModeList.size(); i++)
......@@ -1355,6 +1361,9 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner,
if( uiRdModeList[i].mipFlg || uiRdModeList[i].ispMod!=NOT_INTRA_SUBPARTITIONS )
{
uiRdModeListTemp.push_back( uiRdModeList[i] );
#if JVET_N0193_LFNST
rdModeIdxList.push_back( i );
#endif
}
}
for( int i = 0; i < uiRdModeList.size(); i++)
......@@ -1559,11 +1568,19 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner,
#if JVET_N0413_RDPCM
if( sps.getUseLFNST() && mtsUsageFlag == 1 && !cu.ispMode && mode >= 0 )
{
#if JVET_N0217_MATRIX_INTRAPRED
m_modeCostStore[ lfnstIdx ][ testMip ? rdModeIdxList[ mode ] : mode ] = tmpValidReturn ? csTemp->cost : ( MAX_DOUBLE / 2.0 ); //(MAX_DOUBLE / 2.0) ??
#else
m_modeCostStore[ lfnstIdx ][ mode ] = tmpValidReturn ? csTemp->cost : ( MAX_DOUBLE / 2.0 ); //(MAX_DOUBLE / 2.0) ??
#endif
#else
if( sps.getUseLFNST() && mtsUsageFlag == 1 && !cu.ispMode )
{
#if JVET_N0217_MATRIX_INTRAPRED
m_modeCostStore[ lfnstIdx ][ testMip ? rdModeIdxList[ uiMode ] : uiMode ] = tmpValidReturn ? csTemp->cost : ( MAX_DOUBLE / 2.0 ); //(MAX_DOUBLE / 2.0) ??
#else
m_modeCostStore[ lfnstIdx ][ uiMode ] = tmpValidReturn ? csTemp->cost : ( MAX_DOUBLE / 2.0 ); //(MAX_DOUBLE / 2.0) ??
#endif
#endif
}
#endif
......