Commit c4a7913e authored by Xianglin Wang's avatar Xianglin Wang
Browse files

Integration of JVET-N0340

parent 1fd2cf54
......@@ -50,6 +50,8 @@
#include <assert.h>
#include <cassert>
#define JVET_N0340_TRI_MERGE_CAND 1
#define JVET_N0324_REGULAR_MRG_FLAG 1
#define JVET_N0251_ITEM4_IBC_LOCAL_SEARCH_RANGE 1
......
......@@ -4536,6 +4536,63 @@ void PU::restrictBiPredMergeCandsOne(PredictionUnit &pu)
void PU::getTriangleMergeCandidates( const PredictionUnit &pu, MergeCtx& triangleMrgCtx )
{
#if JVET_N0340_TRI_MERGE_CAND
MergeCtx tmpMergeCtx;
const Slice &slice = *pu.cs->slice;
const uint32_t maxNumMergeCand = slice.getMaxNumMergeCand();
triangleMrgCtx.numValidMergeCand = 0;
for (int32_t i = 0; i < TRIANGLE_MAX_NUM_UNI_CANDS; i++)
{
triangleMrgCtx.GBiIdx[i] = GBI_DEFAULT;
triangleMrgCtx.interDirNeighbours[i] = 0;
triangleMrgCtx.mrgTypeNeighbours[i] = MRG_TYPE_DEFAULT_N;
triangleMrgCtx.mvFieldNeighbours[(i << 1)].refIdx = NOT_VALID;
triangleMrgCtx.mvFieldNeighbours[(i << 1) + 1].refIdx = NOT_VALID;
triangleMrgCtx.mvFieldNeighbours[(i << 1)].mv = Mv();
triangleMrgCtx.mvFieldNeighbours[(i << 1) + 1].mv = Mv();
}
PU::getInterMergeCandidates(pu, tmpMergeCtx, 0);
for (int32_t i = 0; i < maxNumMergeCand; i++)
{
int parity = i & 1;
if (tmpMergeCtx.interDirNeighbours[i] & (0x01 + parity))
{
triangleMrgCtx.interDirNeighbours[triangleMrgCtx.numValidMergeCand] = 1 + parity;
triangleMrgCtx.mrgTypeNeighbours[triangleMrgCtx.numValidMergeCand] = MRG_TYPE_DEFAULT_N;
triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + !parity].mv = Mv(0, 0);
triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + parity].mv = tmpMergeCtx.mvFieldNeighbours[(i << 1) + parity].mv;
triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + !parity].refIdx = -1;
triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + parity].refIdx = tmpMergeCtx.mvFieldNeighbours[(i << 1) + parity].refIdx;
triangleMrgCtx.numValidMergeCand++;
if (triangleMrgCtx.numValidMergeCand == TRIANGLE_MAX_NUM_UNI_CANDS)
{
return;
}
continue;
}
if (tmpMergeCtx.interDirNeighbours[i] & (0x02 - parity))
{
triangleMrgCtx.interDirNeighbours[triangleMrgCtx.numValidMergeCand] = 2 - parity;
triangleMrgCtx.mrgTypeNeighbours[triangleMrgCtx.numValidMergeCand] = MRG_TYPE_DEFAULT_N;
triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + !parity].mv = tmpMergeCtx.mvFieldNeighbours[(i << 1) + !parity].mv;
triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + parity].mv = Mv(0, 0);
triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + !parity].refIdx = tmpMergeCtx.mvFieldNeighbours[(i << 1) + !parity].refIdx;
triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + parity].refIdx = -1;
triangleMrgCtx.numValidMergeCand++;
if (triangleMrgCtx.numValidMergeCand == TRIANGLE_MAX_NUM_UNI_CANDS)
{
return;
}
}
}
#else
const CodingStructure &cs = *pu.cs;
const Slice &slice = *pu.cs->slice;
const int32_t maxNumMergeCand = TRIANGLE_MAX_NUM_UNI_CANDS;
......@@ -4880,6 +4937,7 @@ void PU::getTriangleMergeCandidates( const PredictionUnit &pu, MergeCtx& triangl
cnt = (cnt + 1) % numRefIdx;
}
}
#endif
}
bool PU::isUniqueTriangleCandidates( const PredictionUnit &pu, MergeCtx& triangleMrgCtx )
......
......@@ -656,6 +656,10 @@ void DecCu::xDeriveCUMV( CodingUnit &cu )
{
if( pu.cu->triangle )
{
#if JVET_N0340_TRI_MERGE_CAND && !JVET_N0266_SMALL_BLOCKS
pu.shareParentPos = cu.shareParentPos;
pu.shareParentSize = cu.shareParentSize;
#endif
PU::getTriangleMergeCandidates( pu, m_triangleMrgCtx );
}
else
......
......@@ -2377,6 +2377,10 @@ void EncCu::xCheckRDCostMergeTriangle2Nx2N( CodingStructure *&tempCS, CodingStru
#if JVET_N0324_REGULAR_MRG_FLAG
pu.regularMergeFlag = false;
#endif
#if JVET_N0340_TRI_MERGE_CAND && !JVET_N0266_SMALL_BLOCKS
pu.shareParentPos = tempCS->sharedBndPos;
pu.shareParentSize = tempCS->sharedBndSize;
#endif
PU::getTriangleMergeCandidates( pu, triangleMrgCtx );
for( uint8_t mergeCand = 0; mergeCand < TRIANGLE_MAX_NUM_UNI_CANDS; mergeCand++ )
......@@ -2422,6 +2426,10 @@ void EncCu::xCheckRDCostMergeTriangle2Nx2N( CodingStructure *&tempCS, CodingStru
PredictionUnit &pu = tempCS->addPU( cu, partitioner.chType );
#if JVET_N0340_TRI_MERGE_CAND && !JVET_N0266_SMALL_BLOCKS
pu.shareParentPos = tempCS->sharedBndPos;
pu.shareParentSize = tempCS->sharedBndSize;
#endif
if( abs(g_aucLog2[cu.lwidth()] - g_aucLog2[cu.lheight()]) >= 2 )
{
numTriangleCandidate = 30;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment