From 977cd36c88241a9eb89688a5ac6cd386d5c9eed4 Mon Sep 17 00:00:00 2001
From: Karsten Suehring <karsten.suehring@hhi.fraunhofer.de>
Date: Sun, 26 Apr 2020 20:10:36 +0200
Subject: [PATCH] remove macro JVET_Q0110_Q0785_CHROMA_BDPCM_420

---
 source/Lib/CommonLib/Contexts.cpp     |  7 -------
 source/Lib/CommonLib/TypeDef.h        |  1 -
 source/Lib/DecoderLib/CABACReader.cpp | 28 ---------------------------
 source/Lib/EncoderLib/CABACWriter.cpp | 25 ------------------------
 source/Lib/EncoderLib/EncCu.cpp       |  5 -----
 source/Lib/EncoderLib/IntraSearch.cpp | 13 -------------
 6 files changed, 79 deletions(-)

diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp
index 125f64750..95e65ea81 100644
--- a/source/Lib/CommonLib/Contexts.cpp
+++ b/source/Lib/CommonLib/Contexts.cpp
@@ -419,17 +419,10 @@ const CtxSet ContextSetCfg::Mvd = ContextSetCfg::addCtxSet
 
 const CtxSet ContextSetCfg::BDPCMMode = ContextSetCfg::addCtxSet
 ({
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
   {  19,  21,   0,  28, },
   {  40,  36,   0,  28, },
   {  19,  35,   1,  35, },
   {   4,   4,   1,   0, },
-#else
-  {  19,  28, },
-  {  40,  36, },
-  {  19,  35, },
-  {   4,   4, },
-#endif
 });
 
 const CtxSet ContextSetCfg::QtRootCbf = ContextSetCfg::addCtxSet
diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index dab9d6714..ce9a3d520 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -108,7 +108,6 @@
 
 
 
-#define JVET_Q0110_Q0785_CHROMA_BDPCM_420                 1 // JVET-Q0110/Q0785: Enable chroma BDPCM for 420, separate contexts for chroma BDPCM and bug-fixes.
 
 #define JVET_Q0042_VUI                                    1 // Modifications to VUI syntax
 
diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp
index 79905c428..33eddbbe5 100644
--- a/source/Lib/DecoderLib/CABACReader.cpp
+++ b/source/Lib/DecoderLib/CABACReader.cpp
@@ -875,11 +875,6 @@ void CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx&
     end_of_ctu(cu, cuCtx);
     return;
   }
-#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420
-  bdpcm_mode( cu, ComponentID( partitioner.chType ) );
-  if (!CS::isDualITree(*cu.cs) && isLuma(partitioner.chType))
-      bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA));
-#endif
 
   // --> create PUs
 
@@ -1163,19 +1158,11 @@ void CABACReader::bdpcm_mode( CodingUnit& cu, const ComponentID compID )
   RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET_SIZE2( STATS__CABAC_BITS__BDPCM_MODE, cu.block(compID).lumaSize(), compID );
 
   int bdpcmMode;
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
   unsigned ctxId = isLuma( compID ) ? 0 : 2;
   bdpcmMode = m_BinDecoder.decodeBin( Ctx::BDPCMMode(ctxId) );
-#else
-  bdpcmMode = m_BinDecoder.decodeBin(Ctx::BDPCMMode(0));
-#endif
   if (bdpcmMode)
   {
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
     bdpcmMode += m_BinDecoder.decodeBin( Ctx::BDPCMMode(ctxId+1) );
-#else
-    bdpcmMode += m_BinDecoder.decodeBin(Ctx::BDPCMMode(1));
-#endif
   }
   if (isLuma(compID))
   {
@@ -1199,19 +1186,15 @@ void CABACReader::cu_pred_data( CodingUnit &cu )
 {
   if( CU::isIntra( cu ) )
   {
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
     if( cu.Y().valid() )
 	{
       bdpcm_mode(cu, COMPONENT_Y );
     }
-#endif
     intra_luma_pred_modes( cu );
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
     if( ( !cu.Y().valid() || (!cu.isSepTree() && cu.Y().valid() ) ) && isChromaEnabled(cu.chromaFormat) )
     {
       bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA));
     } 
-#endif
     intra_chroma_pred_modes( cu );
     return;
   }
@@ -1452,13 +1435,11 @@ void CABACReader::intra_chroma_pred_modes( CodingUnit& cu )
     return;
   }
 
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
   if( cu.bdpcmModeChroma )
   {
     cu.firstPU->intraDir[1] = cu.bdpcmModeChroma == 2 ? VER_IDX : HOR_IDX;
     return;
   }
-#endif
   PredictionUnit *pu = cu.firstPU;
 
   {
@@ -1496,15 +1477,6 @@ void CABACReader::intra_chroma_pred_mode(PredictionUnit& pu)
   }
 
   // LM chroma mode
-#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420
-  if (pu.cu->bdpcmModeChroma)
-  {
-    unsigned chromaCandModes[NUM_CHROMA_MODE];
-    PU::getIntraChromaCandModes(pu, chromaCandModes);
-    pu.intraDir[1] = chromaCandModes[0];
-    return;
-  }
-#endif
 
   if (pu.cs->sps->getUseLMChroma() && pu.cu->checkCCLMAllowed())
   {
diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp
index c68ce331b..f000f3037 100644
--- a/source/Lib/EncoderLib/CABACWriter.cpp
+++ b/source/Lib/EncoderLib/CABACWriter.cpp
@@ -701,11 +701,6 @@ void CABACWriter::coding_unit( const CodingUnit& cu, Partitioner& partitioner, C
     end_of_ctu(cu, cuCtx);
     return;
   }
-#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420
-  bdpcm_mode( cu, ComponentID( partitioner.chType ) );
-  if (!CS::isDualITree(cs) && isLuma(partitioner.chType) && isChromaEnabled(cu.chromaFormat))
-      bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA));
-#endif
 
   // prediction data ( intra prediction modes / reference indexes + motion vectors )
   cu_pred_data( cu );
@@ -830,20 +825,12 @@ void CABACWriter::bdpcm_mode( const CodingUnit& cu, const ComponentID compID )
 
   int bdpcmMode = isLuma(compID) ? cu.bdpcmMode : cu.bdpcmModeChroma;
 
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
   unsigned ctxId = isLuma(compID) ? 0 : 2; 
   m_BinEncoder.encodeBin(bdpcmMode > 0 ? 1 : 0, Ctx::BDPCMMode(ctxId));
-#else
-  m_BinEncoder.encodeBin(bdpcmMode > 0 ? 1 : 0, Ctx::BDPCMMode(0));
-#endif
 
   if (bdpcmMode)
   {
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
     m_BinEncoder.encodeBin(bdpcmMode > 1 ? 1 : 0, Ctx::BDPCMMode(ctxId+1));
-#else
-    m_BinEncoder.encodeBin(bdpcmMode > 1 ? 1 : 0, Ctx::BDPCMMode(1));
-#endif
   }
   if (isLuma(compID))
   {
@@ -860,20 +847,16 @@ void CABACWriter::cu_pred_data( const CodingUnit& cu )
 {
   if( CU::isIntra( cu ) )
   {
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
     if( cu.Y().valid() )
     {
       bdpcm_mode( cu, COMPONENT_Y );
     }
-#endif
 
     intra_luma_pred_modes  ( cu );
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
     if( ( !cu.Y().valid() || ( !cu.isSepTree() && cu.Y().valid() ) ) && isChromaEnabled(cu.chromaFormat) )
     {
       bdpcm_mode( cu, ComponentID(CHANNEL_TYPE_CHROMA) );
     } 
-#endif
     intra_chroma_pred_modes( cu );
     return;
   }
@@ -1238,13 +1221,11 @@ void CABACWriter::intra_chroma_pred_modes( const CodingUnit& cu )
     return;
   }
 
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
   if( cu.bdpcmModeChroma )
   {
     cu.firstPU->intraDir[1] = cu.bdpcmModeChroma == 2 ? VER_IDX : HOR_IDX;
     return;
   }
-#endif
   const PredictionUnit* pu = cu.firstPU;
 
   intra_chroma_pred_mode( *pu );
@@ -1278,12 +1259,6 @@ void CABACWriter::intra_chroma_lmc_mode(const PredictionUnit& pu)
 
 void CABACWriter::intra_chroma_pred_mode(const PredictionUnit& pu)
 {
-#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420
-  if (pu.cu->bdpcmModeChroma)
-  {
-      return;
-  }
-#endif
 
   const unsigned intraDir = pu.intraDir[1];
   if (pu.cu->colorTransform)
diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp
index d287a4e5a..d9f203d81 100644
--- a/source/Lib/EncoderLib/EncCu.cpp
+++ b/source/Lib/EncoderLib/EncCu.cpp
@@ -1849,11 +1849,6 @@ bool EncCu::xCheckRDCostIntra(CodingStructure *&tempCS, CodingStructure *&bestCS
           m_CABACEstimator->pred_mode      ( cu );
           m_CABACEstimator->adaptive_color_transform(cu);
           m_CABACEstimator->cu_pred_data   ( cu );
-#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420
-          m_CABACEstimator->bdpcm_mode     ( cu, ComponentID(partitioner.chType) );
-          if (!CS::isDualITree(*cu.cs) && isLuma(partitioner.chType) && isChromaEnabled(cu.chromaFormat))
-              m_CABACEstimator->bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA));
-#endif
 
           // Encode Coefficients
           CUCtx cuCtx;
diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp
index 40929f094..c09899021 100644
--- a/source/Lib/EncoderLib/IntraSearch.cpp
+++ b/source/Lib/EncoderLib/IntraSearch.cpp
@@ -1440,11 +1440,7 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner
         if (uiMode < 0)
         {
             cu.bdpcmModeChroma = -uiMode;
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 
             chromaIntraMode = cu.bdpcmModeChroma == 2 ? chromaCandModes[1] : chromaCandModes[2];
-#else
-            chromaIntraMode = chromaCandModes[0];
-#endif
         }
         else
         {
@@ -2796,11 +2792,6 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner
       {
         return;
       }
-#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420
-      m_CABACEstimator->bdpcm_mode  ( cu, ComponentID(partitioner.chType) );
-      if (!CS::isDualITree(cs) && isLuma(partitioner.chType) && isChromaEnabled(cu.chromaFormat))
-          m_CABACEstimator->bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA));
-#endif
     }
 
     PredictionUnit &pu = *cs.getPU(partitioner.currArea().lumaPos(), partitioner.chType);
@@ -2810,9 +2801,7 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner
     {
       if ( !cu.Y().valid())
         m_CABACEstimator->pred_mode( cu );
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
       m_CABACEstimator->bdpcm_mode( cu, COMPONENT_Y );
-#endif
       m_CABACEstimator->intra_luma_pred_mode( pu );
     }
   }
@@ -2825,9 +2814,7 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner
 
     if( isFirst )
     {
-#if JVET_Q0110_Q0785_CHROMA_BDPCM_420
       m_CABACEstimator->bdpcm_mode( cu, ComponentID(CHANNEL_TYPE_CHROMA) );
-#endif
       m_CABACEstimator->intra_chroma_pred_mode( pu );
     }
   }
-- 
GitLab