From f73896ff138a05e8ac943863f4ff9177e4883be5 Mon Sep 17 00:00:00 2001
From: Shelly Chiang <chiangshelly@yahoo.com.tw>
Date: Wed, 31 Oct 2018 21:54:01 +0800
Subject: [PATCH] change the naming and redundancy for L0100

---
 source/Lib/CommonLib/IntraPrediction.cpp |  7 ++-----
 source/Lib/CommonLib/Unit.cpp            |  6 +++---
 source/Lib/CommonLib/Unit.h              |  2 +-
 source/Lib/CommonLib/UnitTools.cpp       |  8 ++++----
 source/Lib/DecoderLib/CABACReader.cpp    | 14 +++++++-------
 source/Lib/DecoderLib/DecCu.cpp          |  4 ++--
 source/Lib/EncoderLib/CABACWriter.cpp    | 14 +++++++-------
 source/Lib/EncoderLib/EncCu.cpp          | 20 ++++++++++----------
 source/Lib/EncoderLib/IntraSearch.cpp    |  6 +++---
 9 files changed, 39 insertions(+), 42 deletions(-)

diff --git a/source/Lib/CommonLib/IntraPrediction.cpp b/source/Lib/CommonLib/IntraPrediction.cpp
index 50d5e1fd3..b94ccd83c 100644
--- a/source/Lib/CommonLib/IntraPrediction.cpp
+++ b/source/Lib/CommonLib/IntraPrediction.cpp
@@ -952,10 +952,7 @@ void IntraPrediction::switchBuffer(const PredictionUnit &pu, ComponentID compID,
   int compHeight = compID == COMPONENT_Y ? pu.Y().height : pu.Cb().height;
   for (int i = 0; i < compHeight; i++)
   {
-    for (int j = 0; j < compWidth; j++)
-    {
-      memcpy(dst, src, compWidth * sizeof(Pel));
-    }
+    memcpy(dst, src, compWidth * sizeof(Pel));
     src += srcBuff.stride;
     dst += compWidth;
   }
@@ -963,7 +960,7 @@ void IntraPrediction::switchBuffer(const PredictionUnit &pu, ComponentID compID,
 
 void IntraPrediction::geneIntrainterPred(const CodingUnit &cu)
 {
-  if (!cu.firstPU->MHIntraFlag)
+  if (!cu.firstPU->mhIntraFlag)
   {
     return;
   }
diff --git a/source/Lib/CommonLib/Unit.cpp b/source/Lib/CommonLib/Unit.cpp
index 2f695c1f5..710868551 100644
--- a/source/Lib/CommonLib/Unit.cpp
+++ b/source/Lib/CommonLib/Unit.cpp
@@ -352,7 +352,7 @@ void PredictionUnit::initData()
 #endif
   }
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-  MHIntraFlag = false;
+  mhIntraFlag = false;
 #endif
 }
 
@@ -395,7 +395,7 @@ PredictionUnit& PredictionUnit::operator=(const InterPredictionData& predData)
 #endif
   }
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-  MHIntraFlag = predData.MHIntraFlag;
+  mhIntraFlag = predData.mhIntraFlag;
 #endif
 
   return *this;
@@ -435,7 +435,7 @@ PredictionUnit& PredictionUnit::operator=( const PredictionUnit& other )
 #endif
   }
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-  MHIntraFlag = other.MHIntraFlag;
+  mhIntraFlag = other.mhIntraFlag;
 #endif
 
   return *this;
diff --git a/source/Lib/CommonLib/Unit.h b/source/Lib/CommonLib/Unit.h
index f4880e90b..48496a8e6 100644
--- a/source/Lib/CommonLib/Unit.h
+++ b/source/Lib/CommonLib/Unit.h
@@ -368,7 +368,7 @@ struct InterPredictionData
   Mv        mvAffi[NUM_REF_PIC_LIST_01][3];
 #endif
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-  bool      MHIntraFlag;
+  bool      mhIntraFlag;
 #endif
 };
 
diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp
index 751e8be61..5d866f823 100644
--- a/source/Lib/CommonLib/UnitTools.cpp
+++ b/source/Lib/CommonLib/UnitTools.cpp
@@ -310,7 +310,7 @@ int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm, const ChannelType
     const PredictionUnit *puLeft = pu.cs->getPURestricted(pos.offset(-1, 0), pu, channelType);
 
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-    if (puLeft && (CU::isIntra(*puLeft->cu) || (channelType == CHANNEL_TYPE_LUMA && puLeft->MHIntraFlag)))
+    if (puLeft && (CU::isIntra(*puLeft->cu) || (channelType == CHANNEL_TYPE_LUMA && puLeft->mhIntraFlag)))
 #else
     if (puLeft && CU::isIntra(*puLeft->cu))
 #endif
@@ -327,7 +327,7 @@ int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm, const ChannelType
     const PredictionUnit *puAbove = pu.cs->getPURestricted(pos.offset(0, -1), pu, channelType);
 
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-    if (puAbove && (CU::isIntra(*puAbove->cu) || (channelType == CHANNEL_TYPE_LUMA && puAbove->MHIntraFlag)) && CU::isSameCtu(*pu.cu, *puAbove->cu))
+    if (puAbove && (CU::isIntra(*puAbove->cu) || (channelType == CHANNEL_TYPE_LUMA && puAbove->mhIntraFlag)) && CU::isSameCtu(*pu.cu, *puAbove->cu))
 #else
     if (puAbove && CU::isIntra(*puAbove->cu) && CU::isSameCtu(*pu.cu, *puAbove->cu))
 #endif
@@ -525,7 +525,7 @@ int PU::getMHIntraMPMs(const PredictionUnit &pu, unsigned* mpm, const ChannelTyp
     // Get intra direction of left PU
     const PredictionUnit *puLeft = pu.cs->getPURestricted(pos.offset(-1, 0), pu, channelType);
 
-    if (puLeft && (CU::isIntra(*puLeft->cu) || puLeft->MHIntraFlag))
+    if (puLeft && (CU::isIntra(*puLeft->cu) || puLeft->mhIntraFlag))
     {
       leftIntraDir = puLeft->intraDir[channelType];
 
@@ -538,7 +538,7 @@ int PU::getMHIntraMPMs(const PredictionUnit &pu, unsigned* mpm, const ChannelTyp
     // Get intra direction of above PU
     const PredictionUnit* puAbove = pu.cs->getPURestricted(pos.offset(0, -1), pu, channelType);
 
-    if (puAbove && (CU::isIntra(*puAbove->cu) || puAbove->MHIntraFlag) && CU::isSameCtu(*pu.cu, *puAbove->cu))
+    if (puAbove && (CU::isIntra(*puAbove->cu) || puAbove->mhIntraFlag) && CU::isSameCtu(*pu.cu, *puAbove->cu))
     {
       aboveIntraDir = puAbove->intraDir[channelType];
 
diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp
index 6a928e732..271eb5713 100644
--- a/source/Lib/DecoderLib/CABACReader.cpp
+++ b/source/Lib/DecoderLib/CABACReader.cpp
@@ -1166,7 +1166,7 @@ void CABACReader::prediction_unit( PredictionUnit& pu, MergeCtx& mrgCtx )
 #endif
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
     MHIntra_flag(pu);
-    if (pu.MHIntraFlag)
+    if (pu.mhIntraFlag)
     {
       MHIntra_luma_pred_modes(*pu.cu);
       pu.intraDir[1] = DM_CHROMA_IDX;
@@ -1605,31 +1605,31 @@ void CABACReader::MHIntra_flag(PredictionUnit& pu)
 {
   if (!pu.cs->sps->getSpsNext().getUseMHIntra())
   {
-    pu.MHIntraFlag = false;
+    pu.mhIntraFlag = false;
     return;
   }
   if (pu.cu->skip)
   {
-    pu.MHIntraFlag = false;
+    pu.mhIntraFlag = false;
     return;
   }
 
 #if JVET_L0054_MMVD
   if (pu.mmvdMergeFlag)
   {
-    pu.MHIntraFlag = false;
+    pu.mhIntraFlag = false;
     return;
   }
 #endif
   if (pu.cu->lwidth() * pu.cu->lheight() < 64 || pu.cu->lwidth() >= MAX_CU_SIZE || pu.cu->lheight() >= MAX_CU_SIZE)
   {
-    pu.MHIntraFlag = false;
+    pu.mhIntraFlag = false;
     return;
   }
   RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET(STATS__CABAC_BITS__MH_INTRA_FLAG);
 
-  pu.MHIntraFlag = (m_BinDecoder.decodeBin(Ctx::MHIntraFlag()));
-  DTRACE(g_trace_ctx, D_SYNTAX, "MHIntra_flag() MHIntra=%d pos=(%d,%d) size=%dx%d\n", pu.MHIntraFlag ? 1 : 0, pu.lumaPos().x, pu.lumaPos().y, pu.lumaSize().width, pu.lumaSize().height);
+  pu.mhIntraFlag = (m_BinDecoder.decodeBin(Ctx::MHIntraFlag()));
+  DTRACE(g_trace_ctx, D_SYNTAX, "MHIntra_flag() MHIntra=%d pos=(%d,%d) size=%dx%d\n", pu.mhIntraFlag ? 1 : 0, pu.lumaPos().x, pu.lumaPos().y, pu.lumaSize().width, pu.lumaSize().height);
 }
 
 void CABACReader::MHIntra_luma_pred_modes(CodingUnit &cu)
diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp
index 02d3e881c..7cfd907ef 100644
--- a/source/Lib/DecoderLib/DecCu.cpp
+++ b/source/Lib/DecoderLib/DecCu.cpp
@@ -325,7 +325,7 @@ void DecCu::xReconInter(CodingUnit &cu)
 #endif
 
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-  if (cu.firstPU->MHIntraFlag)
+  if (cu.firstPU->mhIntraFlag)
   {
     m_pcIntraPred->geneWeightedPred(COMPONENT_Y, cu.cs->getPredBuf(*cu.firstPU).Y(), *cu.firstPU, m_pcIntraPred->getPredictorPtr2(COMPONENT_Y, 0));
     m_pcIntraPred->geneWeightedPred(COMPONENT_Cb, cu.cs->getPredBuf(*cu.firstPU).Cb(), *cu.firstPU, m_pcIntraPred->getPredictorPtr2(COMPONENT_Cb, 0));
@@ -434,7 +434,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu )
       if (pu.mmvdMergeFlag || pu.cu->mmvdSkip)
       {
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-        CHECK(pu.MHIntraFlag == true, "invalid MHIntra");
+        CHECK(pu.mhIntraFlag == true, "invalid MHIntra");
 #endif
         if (pu.cs->sps->getSpsNext().getUseSubPuMvp())
         {
diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp
index 1de82ea14..5e9177706 100644
--- a/source/Lib/EncoderLib/CABACWriter.cpp
+++ b/source/Lib/EncoderLib/CABACWriter.cpp
@@ -1127,7 +1127,7 @@ void CABACWriter::prediction_unit( const PredictionUnit& pu )
 #endif
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
     MHIntra_flag( pu );
-    if ( pu.MHIntraFlag )
+    if ( pu.mhIntraFlag )
     {
       MHIntra_luma_pred_modes( *pu.cu );
     }
@@ -1533,28 +1533,28 @@ void CABACWriter::MHIntra_flag(const PredictionUnit& pu)
 {
   if (!pu.cs->sps->getSpsNext().getUseMHIntra())
   {
-    CHECK(pu.MHIntraFlag == true, "invalid MHIntra SPS");
+    CHECK(pu.mhIntraFlag == true, "invalid MHIntra SPS");
     return;
   }
   if (pu.cu->skip)
   {
-    CHECK(pu.MHIntraFlag == true, "invalid MHIntra and skip");
+    CHECK(pu.mhIntraFlag == true, "invalid MHIntra and skip");
     return;
   }
 #if JVET_L0054_MMVD
   if (pu.mmvdMergeFlag)
   {
-    CHECK(pu.MHIntraFlag == true, "invalid MHIntra and mmvd");
+    CHECK(pu.mhIntraFlag == true, "invalid MHIntra and mmvd");
     return;
   }
 #endif
   if (pu.cu->lwidth() * pu.cu->lheight() < 64 || pu.cu->lwidth() >= MAX_CU_SIZE || pu.cu->lheight() >= MAX_CU_SIZE)
   {
-    CHECK(pu.MHIntraFlag == true, "invalid MHIntra and blk");
+    CHECK(pu.mhIntraFlag == true, "invalid MHIntra and blk");
     return;
   }
-  m_BinEncoder.encodeBin(pu.MHIntraFlag, Ctx::MHIntraFlag());
-  DTRACE(g_trace_ctx, D_SYNTAX, "MHIntra_flag() intrainter=%d pos=(%d,%d) size=%dx%d\n", pu.MHIntraFlag ? 1 : 0, pu.lumaPos().x, pu.lumaPos().y, pu.lumaSize().width, pu.lumaSize().height);
+  m_BinEncoder.encodeBin(pu.mhIntraFlag, Ctx::MHIntraFlag());
+  DTRACE(g_trace_ctx, D_SYNTAX, "MHIntra_flag() intrainter=%d pos=(%d,%d) size=%dx%d\n", pu.mhIntraFlag ? 1 : 0, pu.lumaPos().x, pu.lumaPos().y, pu.lumaSize().width, pu.lumaSize().height);
 }
 
 void CABACWriter::MHIntra_luma_pred_modes(const CodingUnit& cu)
diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp
index 8b986e8ee..c94b3ab0e 100644
--- a/source/Lib/EncoderLib/EncCu.cpp
+++ b/source/Lib/EncoderLib/EncCu.cpp
@@ -1880,7 +1880,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
         int bestMHIntraMode = -1;
         double bestMHIntraCost = MAX_DOUBLE;
 
-        pu.MHIntraFlag = true;
+        pu.mhIntraFlag = true;
 
         // save the to-be-tested merge candidates
         uint32_t MHIntraMergeCand[NUM_MRG_SATD_CAND];
@@ -1965,7 +1965,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
             }
           }
         }
-        pu.MHIntraFlag = false;
+        pu.mhIntraFlag = false;
         m_CABACEstimator->getCtx() = ctxStart;
       }
 #endif
@@ -2076,7 +2076,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
       if (isIntrainterEnabled)
       {
-        pu.MHIntraFlag = true;
+        pu.mhIntraFlag = true;
         for (uint32_t mergeCnt = 0; mergeCnt < uiNumMrgSATDCand; mergeCnt++)
         {
 #if JVET_L0054_MMVD
@@ -2098,7 +2098,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
             m_pcIntraSearch->switchBuffer(pu, COMPONENT_Cr, pu.cs->getPredBuf(pu).Cr(), m_pcIntraSearch->getPredictorPtr2(COMPONENT_Cr, bufIdx));
           }
         }
-        pu.MHIntraFlag = false;
+        pu.mhIntraFlag = false;
       }
 #endif
 
@@ -2194,7 +2194,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
 #else
         uiMergeCand -= (MRG_MAX_NUM_CANDS + MRG_MAX_NUM_CANDS);
 #endif
-        pu.MHIntraFlag = true;
+        pu.mhIntraFlag = true;
         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;
@@ -2227,7 +2227,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
         pu.mvd[0] = refinedMvdL0[uiMergeCand];
 #endif
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-        if (pu.MHIntraFlag)
+        if (pu.mhIntraFlag)
         {
           uint32_t bufIdx = (pu.intraDir[0] > 1) ? (pu.intraDir[0] == HOR_IDX ? 2 : 3) : pu.intraDir[0];
           PelBuf tmpBuf = tempCS->getPredBuf(pu).Y();
@@ -2270,7 +2270,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
       }
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
 #if JVET_L0054_MMVD
-      if (!cu.mmvdSkip && !pu.MHIntraFlag && uiNoResidualPass != 0)
+      if (!cu.mmvdSkip && !pu.mhIntraFlag && uiNoResidualPass != 0)
 #else
       if (!pu.MHIntraFlag && uiNoResidualPass != 0)
 #endif
@@ -2293,7 +2293,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
 #endif
 
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-      if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip && !pu.MHIntraFlag)
+      if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip && !pu.mhIntraFlag)
 #else
       if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
 #endif
@@ -3175,7 +3175,7 @@ void EncCu::xEncodeInterResidual( CodingStructure *&tempCS, CodingStructure *&be
     {
       bestCostInternal = tempCS->cost;
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-      if (!(tempCS->getPU(partitioner.chType)->MHIntraFlag))
+      if (!(tempCS->getPU(partitioner.chType)->mhIntraFlag))
 #endif
       *bestHasNonResi  = !cu->rootCbf;
     }
@@ -3183,7 +3183,7 @@ void EncCu::xEncodeInterResidual( CodingStructure *&tempCS, CodingStructure *&be
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
     if (cu->rootCbf == false)
     {
-      if (tempCS->getPU(partitioner.chType)->MHIntraFlag)
+      if (tempCS->getPU(partitioner.chType)->mhIntraFlag)
       {
         tempCS->cost = MAX_DOUBLE;
         return;
diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp
index c2558d849..bbdfb1019 100644
--- a/source/Lib/EncoderLib/IntraSearch.cpp
+++ b/source/Lib/EncoderLib/IntraSearch.cpp
@@ -1905,7 +1905,7 @@ uint64_t IntraSearch::xFracModeBitsIntra(PredictionUnit &pu, const uint32_t &uiM
   uint32_t orgMode = uiMode;
 
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-  if (!pu.MHIntraFlag)
+  if (!pu.mhIntraFlag)
 #endif
   std::swap(orgMode, pu.intraDir[chType]);
 
@@ -1914,7 +1914,7 @@ uint64_t IntraSearch::xFracModeBitsIntra(PredictionUnit &pu, const uint32_t &uiM
   if( isLuma( chType ) )
   {
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-    if ( pu.MHIntraFlag )
+    if ( pu.mhIntraFlag )
       m_CABACEstimator->MHIntra_luma_pred_modes(*pu.cu);
     else
     {
@@ -1930,7 +1930,7 @@ uint64_t IntraSearch::xFracModeBitsIntra(PredictionUnit &pu, const uint32_t &uiM
   }
 
 #if JVET_L0100_MULTI_HYPOTHESIS_INTRA
-  if ( !pu.MHIntraFlag )
+  if ( !pu.mhIntraFlag )
 #endif
   std::swap(orgMode, pu.intraDir[chType]);
 
-- 
GitLab