Commit 0ac16832 authored by Shelly Chiang's avatar Shelly Chiang

modify MHIntra as suggested

parent a375e85c
......@@ -929,7 +929,7 @@ void IntraPrediction::switchBuffer(const PredictionUnit &pu, ComponentID compID,
{
for (int j = 0; j < compWidth; j++)
{
dst[j] = src[j];
memcpy(dst, src, compWidth * sizeof(Pel));
}
src += srcBuff.stride;
dst += compWidth;
......
......@@ -353,11 +353,7 @@ void initROM()
// g_aucLog2[ x ]: log2(x), if x=1 -> 0, x=2 -> 1, x=4 -> 2, x=8 -> 3, x=16 -> 4, ...
::memset(g_aucLog2, 0, sizeof(g_aucLog2));
c = 0;
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
for( int i = 0, n = 0; i <= (1 << (MAX_CU_DEPTH + 1)); i++ )
#else
for( int i = 0, n = 0; i <= MAX_CU_SIZE; i++ )
#endif
{
g_aucNextLog2[i] = i <= 1 ? 0 : c + 1;
......@@ -701,15 +697,9 @@ const DecisionTreeTemplate g_mtSplitDTT = compile(
// ====================================================================================================================
SizeIndexInfo* gp_sizeIdxInfo = NULL;
int g_BlockSizeTrafoScale[MAX_CU_SIZE + 1][MAX_CU_SIZE + 1][2];
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
int8_t g_aucLog2 [(1 << (MAX_CU_DEPTH + 1)) + 1];
int8_t g_aucNextLog2[(1 << (MAX_CU_DEPTH + 1)) + 1];
int8_t g_aucPrevLog2[(1 << (MAX_CU_DEPTH + 1)) + 1];
#else
int8_t g_aucLog2 [MAX_CU_SIZE + 1];
int8_t g_aucNextLog2[MAX_CU_SIZE + 1];
int8_t g_aucPrevLog2[MAX_CU_SIZE + 1];
#endif
UnitScale g_miScaling( MIN_CU_LOG2, MIN_CU_LOG2 );
......
......@@ -165,15 +165,9 @@ extern const DecisionTreeTemplate g_qtbtSplitDTT;
// ====================================================================================================================
extern SizeIndexInfo* gp_sizeIdxInfo;
extern int g_BlockSizeTrafoScale [MAX_CU_SIZE + 1][MAX_CU_SIZE + 1][2];
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
extern int8_t g_aucLog2 [(1 << (MAX_CU_DEPTH + 1)) + 1];
extern int8_t g_aucNextLog2 [(1 << (MAX_CU_DEPTH + 1)) + 1];
extern int8_t g_aucPrevLog2 [(1 << (MAX_CU_DEPTH + 1)) + 1];
#else
extern int8_t g_aucLog2 [MAX_CU_SIZE + 1];
extern int8_t g_aucNextLog2 [MAX_CU_SIZE + 1];
extern int8_t g_aucPrevLog2 [MAX_CU_SIZE + 1];
#endif
extern const int8_t i2Log2Tab[257];
inline bool is34( const SizeType& size )
......
......@@ -333,8 +333,6 @@ void PredictionUnit::initData()
}
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
MHIntraFlag = false;
intraDir2[0] = PLANAR_IDX;
intraDir2[1] = DM_CHROMA_IDX;
#endif
}
......@@ -368,8 +366,6 @@ PredictionUnit& PredictionUnit::operator=(const InterPredictionData& predData)
}
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
MHIntraFlag = predData.MHIntraFlag;
intraDir2[0] = predData.intraDir2[0];
intraDir2[1] = predData.intraDir2[1];
#endif
return *this;
......@@ -400,8 +396,6 @@ PredictionUnit& PredictionUnit::operator=( const PredictionUnit& other )
}
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
MHIntraFlag = other.MHIntraFlag;
intraDir2[0] = other.intraDir2[0];
intraDir2[1] = other.intraDir2[1];
#endif
return *this;
......
......@@ -359,7 +359,6 @@ struct InterPredictionData
Mv mvdAffi [NUM_REF_PIC_LIST_01][3];
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
bool MHIntraFlag;
uint32_t intraDir2[MAX_NUM_CHANNEL_TYPE];
#endif
};
......
......@@ -315,19 +315,11 @@ int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm, const ChannelType
if (puLeft && CU::isIntra(*puLeft->cu))
#endif
{
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
leftIntraDir = puLeft->MHIntraFlag ? puLeft->intraDir2[channelType] : puLeft->intraDir[channelType];
#else
leftIntraDir = puLeft->intraDir[channelType];
#endif
if (isChroma(channelType) && leftIntraDir == DM_CHROMA_IDX)
{
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
leftIntraDir = puLeft->MHIntraFlag ? puLeft->intraDir2[0] : puLeft->intraDir[0];
#else
leftIntraDir = puLeft->intraDir[0];
#endif
}
}
......@@ -340,11 +332,7 @@ int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm, const ChannelType
if (puAbove && CU::isIntra(*puAbove->cu) && CU::isSameCtu(*pu.cu, *puAbove->cu))
#endif
{
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
aboveIntraDir = puAbove->MHIntraFlag ? puAbove->intraDir2[channelType] : puAbove->intraDir[channelType];
#else
aboveIntraDir = puAbove->intraDir[channelType];
#endif
if (isChroma(channelType) && aboveIntraDir == DM_CHROMA_IDX)
{
......@@ -514,11 +502,11 @@ int PU::getMHIntraMPMs(const PredictionUnit &pu, unsigned* mpm, const ChannelTyp
if (puLeft && (CU::isIntra(*puLeft->cu) || puLeft->MHIntraFlag))
{
leftIntraDir = puLeft->MHIntraFlag ? puLeft->intraDir2[channelType] : puLeft->intraDir[channelType];
leftIntraDir = puLeft->intraDir[channelType];
if (isChroma(channelType) && leftIntraDir == DM_CHROMA_IDX)
{
leftIntraDir = puLeft->MHIntraFlag ? puLeft->intraDir2[0] : puLeft->intraDir[0];
leftIntraDir = puLeft->intraDir[0];
}
}
......@@ -527,11 +515,11 @@ int PU::getMHIntraMPMs(const PredictionUnit &pu, unsigned* mpm, const ChannelTyp
if (puAbove && (CU::isIntra(*puAbove->cu) || puAbove->MHIntraFlag) && CU::isSameCtu(*pu.cu, *puAbove->cu))
{
aboveIntraDir = puAbove->MHIntraFlag ? puAbove->intraDir2[channelType] : puAbove->intraDir[channelType];
aboveIntraDir = puAbove->intraDir[channelType];
if (isChroma(channelType) && aboveIntraDir == DM_CHROMA_IDX)
{
aboveIntraDir = puAbove->MHIntraFlag ? puAbove->intraDir2[0] : puAbove->intraDir[0];
aboveIntraDir = puAbove->intraDir[0];
}
}
......@@ -646,20 +634,13 @@ int PU::getNarrowShape(const int width, const int height)
uint32_t PU::getFinalIntraMode( const PredictionUnit &pu, const ChannelType &chType )
{
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
uint32_t uiIntraMode = pu.MHIntraFlag ? pu.intraDir2[chType] : pu.intraDir[chType];
#else
uint32_t uiIntraMode = pu.intraDir[chType];
#endif
if( uiIntraMode == DM_CHROMA_IDX && !isLuma( chType ) )
{
const PredictionUnit &lumaPU = CS::isDualITree( *pu.cs ) ? *pu.cs->picture->cs->getPU( pu.blocks[chType].lumaPos(), CHANNEL_TYPE_LUMA ) : *pu.cs->getPU( pu.blocks[chType].lumaPos(), CHANNEL_TYPE_LUMA );
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
uiIntraMode = pu.MHIntraFlag ? pu.intraDir2[0] : lumaPU.intraDir[0];
#else
uiIntraMode = lumaPU.intraDir[0];
#endif
}
if( pu.chromaFormat == CHROMA_422 && !isLuma( chType ) )
{
......
......@@ -1160,7 +1160,7 @@ void CABACReader::prediction_unit( PredictionUnit& pu, MergeCtx& mrgCtx )
if (pu.MHIntraFlag)
{
MHIntra_luma_pred_modes(*pu.cu);
pu.intraDir2[1] = DM_CHROMA_IDX;
pu.intraDir[1] = DM_CHROMA_IDX;
}
#endif
merge_data ( pu );
......@@ -1470,7 +1470,7 @@ void CABACReader::MHIntra_luma_pred_modes(CodingUnit &cu)
{
pred_idx += m_BinDecoder.decodeBinEP();
}
pu->intraDir2[0] = mpm_pred[pred_idx];
pu->intraDir[0] = mpm_pred[pred_idx];
}
else
{
......@@ -1516,9 +1516,8 @@ void CABACReader::MHIntra_luma_pred_modes(CodingUnit &cu)
{
pred_mode = VER_IDX;
}
pu->intraDir2[0] = pred_mode;
pu->intraDir[0] = pred_mode;
}
DTRACE(g_trace_ctx, D_SYNTAX, "intra_luma_pred_modes() idx=%d pos=(%d,%d) mode=%d\n", k, pu->lumaPos().x, pu->lumaPos().y, pu->intraDir2[0]);
pu = pu->next;
}
......
......@@ -813,7 +813,7 @@ void HLSyntaxReader::parseSPSNext( SPSNext& spsNext, const bool usePCM )
}
READ_FLAG( symbol, "mtt_enabled_flag" ); spsNext.setMTTMode ( symbol );
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
READ_FLAG( symbol, "MHIntra_flag" ); spsNext.setUseMHIntra ( symbol != 0 );
READ_FLAG( symbol, "mhintra_flag" ); spsNext.setUseMHIntra ( symbol != 0 );
#endif
#if ENABLE_WPP_PARALLELISM
READ_FLAG( symbol, "next_dqp_enabled_flag" ); spsNext.setUseNextDQP ( symbol != 0 );
......
......@@ -1400,7 +1400,7 @@ void CABACWriter::MHIntra_luma_pred_modes(const CodingUnit& cu)
mpm_pred = (unsigned*)alloca(numMPMs * sizeof(unsigned));
PU::getMHIntraMPMs(*pu, mpm_pred);
pred_mode = pu->intraDir2[0];
pred_mode = pu->intraDir[0];
mpm_idx = numMPMs;
......@@ -1433,7 +1433,7 @@ void CABACWriter::MHIntra_luma_pred_modes(const CodingUnit& cu)
m_BinEncoder.encodeBinEP(mpm_idx > 1);
}
}
DTRACE(g_trace_ctx, D_SYNTAX, "intra_luma_pred_modes() idx=%d pos=(%d,%d) mode=%d\n", k, pu->lumaPos().x, pu->lumaPos().y, pu->intraDir2[0]);
DTRACE(g_trace_ctx, D_SYNTAX, "intra_luma_pred_modes() idx=%d pos=(%d,%d) mode=%d\n", k, pu->lumaPos().x, pu->lumaPos().y, pu->intraDir[0]);
pu = pu->next;
}
}
......
......@@ -1584,9 +1584,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
{
if (RdModeList[mergeCnt] >= (MRG_MAX_NUM_CANDS + MRG_MAX_NUM_CANDS))
{
pu.intraDir2[0] = RdModeList2[mergeCnt];
pu.intraDir2[1] = DM_CHROMA_IDX;
uint32_t bufIdx = (pu.intraDir2[0] > 1) ? (pu.intraDir2[0] == HOR_IDX ? 2 : 3) : pu.intraDir2[0];
pu.intraDir[0] = RdModeList2[mergeCnt];
pu.intraDir[1] = DM_CHROMA_IDX;
uint32_t bufIdx = (pu.intraDir[0] > 1) ? (pu.intraDir[0] == HOR_IDX ? 2 : 3) : pu.intraDir[0];
bool isUseFilter = IntraPrediction::useFilteredIntraRefSamples(COMPONENT_Cb, pu, true, pu);
m_pcIntraSearch->initIntraPatternChType(*pu.cu, pu.Cb(), isUseFilter);
m_pcIntraSearch->predIntraAng(COMPONENT_Cb, pu.cs->getPredBuf(pu).Cb(), pu, isUseFilter);
......@@ -1658,9 +1658,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
{
uiMergeCand -= (MRG_MAX_NUM_CANDS + MRG_MAX_NUM_CANDS);
pu.MHIntraFlag = true;
pu.intraDir2[0] = RdModeList2[uiMrgHADIdx];
CHECK(pu.intraDir2[0]<0 || pu.intraDir2[0]>(NUM_LUMA_MODE - 1), "out of intra mode");
pu.intraDir2[1] = DM_CHROMA_IDX;
pu.intraDir[0] = RdModeList2[uiMrgHADIdx];
CHECK(pu.intraDir[0]<0 || pu.intraDir[0]>(NUM_LUMA_MODE - 1), "out of intra mode");
pu.intraDir[1] = DM_CHROMA_IDX;
}
#endif
......@@ -1675,7 +1675,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
if (pu.MHIntraFlag)
{
uint32_t bufIdx = (pu.intraDir2[0] > 1) ? (pu.intraDir2[0] == HOR_IDX ? 2 : 3) : pu.intraDir2[0];
uint32_t bufIdx = (pu.intraDir[0] > 1) ? (pu.intraDir[0] == HOR_IDX ? 2 : 3) : pu.intraDir[0];
PelBuf tmpBuf = tempCS->getPredBuf(pu).Y();
tmpBuf.copyFrom(acMergeBuffer[uiMergeCand].Y());
m_pcIntraSearch->geneWeightedPred(COMPONENT_Y, tmpBuf, pu, m_pcIntraSearch->getPredictorPtr2(COMPONENT_Y, bufIdx));
......@@ -2477,19 +2477,19 @@ void EncCu::getMHIntraLCCand(PredictionUnit &pu, static_vector<T, N>& RdModeList
// first round
for (uint32_t intraCnt = 0; intraCnt < numTestIntraMode; intraCnt++)
{
pu.intraDir2[0] = (intraCnt < 2) ? intraCnt : ((intraCnt == 2) ? HOR_IDX : VER_IDX);
pu.intraDir[0] = (intraCnt < 2) ? intraCnt : ((intraCnt == 2) ? HOR_IDX : VER_IDX);
// fast 2
if (mergeCnt > 0 && bestMHIntraMode != pu.intraDir2[0])
if (mergeCnt > 0 && bestMHIntraMode != pu.intraDir[0])
{
continue;
}
int narrowCase = PU::getNarrowShape(pu.lwidth(), pu.lheight());
if (narrowCase == 1 && pu.intraDir2[0] == HOR_IDX)
if (narrowCase == 1 && pu.intraDir[0] == HOR_IDX)
{
continue;
}
if (narrowCase == 2 && pu.intraDir2[0] == VER_IDX)
if (narrowCase == 2 && pu.intraDir[0] == VER_IDX)
{
continue;
}
......@@ -2509,15 +2509,15 @@ void EncCu::getMHIntraLCCand(PredictionUnit &pu, static_vector<T, N>& RdModeList
distParam.cur = pu.cs->getPredBuf(pu).Y();
Distortion sadValue = distParam.distFunc(distParam);
m_CABACEstimator->getCtx() = SubCtx(Ctx::MHIntraPredMode, ctxStartIntraMode);
uint64_t fracModeBits = m_pcIntraSearch->xFracModeBitsIntra(pu, pu.intraDir2[0], CHANNEL_TYPE_LUMA);
uint64_t fracModeBits = m_pcIntraSearch->xFracModeBitsIntra(pu, pu.intraDir[0], CHANNEL_TYPE_LUMA);
double cost = (double)sadValue + (double)(bitsCand + 1) * sqrtLambdaForFirstPass + (double)fracModeBits * sqrtLambdaForFirstPassIntra;
updateDoubleCandList(mergeCand + MRG_MAX_NUM_CANDS + MRG_MAX_NUM_CANDS, cost, RdModeList, candCostList, RdModeList2, pu.intraDir2[0], uiNumMrgSATDCand);
updateDoubleCandList(mergeCand + MRG_MAX_NUM_CANDS + MRG_MAX_NUM_CANDS, cost, RdModeList, candCostList, RdModeList2, pu.intraDir[0], uiNumMrgSATDCand);
// fast 2
if (mergeCnt == 0 && cost < bestMHIntraCost)
{
bestMHIntraMode = pu.intraDir2[0];
bestMHIntraMode = pu.intraDir[0];
bestMHIntraCost = cost;
}
}
......
......@@ -554,7 +554,7 @@ void HLSWriter::codeSPSNext( const SPSNext& spsNext, const bool usePCM )
WRITE_FLAG( spsNext.getMTTEnabled() ? 1 : 0, "mtt_enabled_flag" );
#if JVET_L0100_MULTI_HYPOTHESIS_INTRA
WRITE_FLAG( spsNext.getUseMHIntra() ? 1 : 0, "MHIntra_flag" );
WRITE_FLAG( spsNext.getUseMHIntra() ? 1 : 0, "mhintra_flag" );
#endif
#if ENABLE_WPP_PARALLELISM
WRITE_FLAG( spsNext.getUseNextDQP(), "next_dqp_enabled_flag" );
......
Markdown is supported
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