From b38a1848f935afd86f414bab39c794daa7c1a41f Mon Sep 17 00:00:00 2001
From: Karsten Suehring <karsten.suehring@hhi.fraunhofer.de>
Date: Mon, 20 Aug 2018 18:44:57 +0200
Subject: [PATCH] update to changes of BMS 2.0, add missing dot-filss

---
 source/Lib/CommonLib/IntraPrediction.cpp | 93 ------------------------
 source/Lib/CommonLib/IntraPrediction.h   |  5 --
 source/Lib/CommonLib/version.h           |  2 +-
 source/Lib/DecoderLib/CABACReader.cpp    |  7 +-
 source/Lib/EncoderLib/CABACWriter.cpp    |  7 +-
 5 files changed, 8 insertions(+), 106 deletions(-)

diff --git a/source/Lib/CommonLib/IntraPrediction.cpp b/source/Lib/CommonLib/IntraPrediction.cpp
index b8df864ab..db1837d0e 100644
--- a/source/Lib/CommonLib/IntraPrediction.cpp
+++ b/source/Lib/CommonLib/IntraPrediction.cpp
@@ -772,99 +772,6 @@ void IntraPrediction::xPredIntraAng( const CPelBuf &pSrc, PelBuf &pDst, const Ch
   }
 }
 
-void IntraPrediction::xReferenceFilter(
-#if JVET_K0500_WAIP
-  const int doubleHSize,
-#endif  
-  const int doubleSize, const int origWeight, const int filterOrder, Pel *piRefVector, Pel *piLowPassRef )
-{
-  const int imCoeff[3][4] =
-  {
-    { 20, 15, 6, 1 },
-    { 16, 14, 7, 3 },
-    { 14, 12, 9, 4 }
-  };
-
-  const int * piFc;
-
-  int binBuff[4 * MAX_CU_SIZE + 9];
-  int * piTmp = &binBuff[2 * MAX_CU_SIZE + 4];   // to  use negative indexes
-  Pel * piDat = piRefVector;
-  Pel * piRes = piLowPassRef;
-
-#if JVET_K0500_WAIP
-  for( int k = -doubleHSize; k <= doubleSize; k++ )
-#else
-  for( int k = -doubleSize; k <= doubleSize; k++ )
-#endif
-    piTmp[k] = piDat[k];
-
-  for( int n = 1; n <= 3; n++ )
-  {
-#if JVET_K0500_WAIP
-    piTmp[-doubleHSize - n] = piTmp[-doubleHSize - 1 + n];
-#else
-    piTmp[-doubleSize - n] = piTmp[-doubleSize - 1 + n];
-#endif
-    piTmp[ doubleSize + n] = piTmp[ doubleSize + 1 - n];
-  }
-
-  switch( filterOrder )
-  {
-  case 0:
-    break;
-  case 1:
-#if JVET_K0500_WAIP
-    for( int k = -doubleHSize; k <= doubleSize; k++ )
-#else
-    for( int k = -doubleSize; k <= doubleSize; k++ )
-#endif
-      piRes[k] = (Pel)(((piTmp[k] << 1) + piTmp[k - 1] + piTmp[k + 1] + 2) >> 2);
-    break;
-  case 2:
-#if JVET_K0500_WAIP
-    for( int k = -doubleHSize; k <= doubleSize; k++ )
-#else
-    for( int k = -doubleSize; k <= doubleSize; k++ )
-#endif
-      piRes[k] = (Pel)(((piTmp[k] << 1) + ((piTmp[k] + piTmp[k - 1] + piTmp[k + 1]) << 2) + piTmp[k - 2] + piTmp[k + 2] + 8) >> 4);
-    break;
-  case 3:
-  case 5:
-  case 7:
-    piFc = imCoeff[(filterOrder - 3) >> 1];
-#if JVET_K0500_WAIP
-    for( int k = -doubleHSize; k <= doubleSize; k++ )
-#else
-    for( int k = -doubleSize; k <= doubleSize; k++ )
-#endif
-    {
-      int s = 32 + piFc[0] * piTmp[k];
-      for( int n = 1; n < 4; n++ )
-        s += piFc[n] * (piTmp[k - n] + piTmp[k + n]);
-
-      piRes[k] = (Pel)(s >> 6);
-    }
-    break;
-  default:
-    EXIT( "Invalid intra prediction reference filter order" );
-  }
-
-  int ParShift = 6; //normalization factor
-  int ParScale = 1 << ParShift;
-  int ParOffset = 1 << (ParShift - 1);
-
-  if( origWeight != 0 )
-  {
-    int iCmptWeight = ParScale - origWeight;
-#if JVET_K0500_WAIP
-    for (int k = -doubleHSize; k <= doubleSize; k++)
-#else
-    for( int k = -doubleSize; k <= doubleSize; k++ )
-#endif
-      piLowPassRef[k] = (origWeight * piRefVector[k] + iCmptWeight * piLowPassRef[k] + ParOffset) >> ParShift;
-  }
-}
 
 bool IntraPrediction::useDPCMForFirstPassIntraEstimation(const PredictionUnit &pu, const uint32_t &uiDirMode)
 {
diff --git a/source/Lib/CommonLib/IntraPrediction.h b/source/Lib/CommonLib/IntraPrediction.h
index 81a320d22..5dd8cb268 100644
--- a/source/Lib/CommonLib/IntraPrediction.h
+++ b/source/Lib/CommonLib/IntraPrediction.h
@@ -108,11 +108,6 @@ protected:
   static int getWideAngle         ( int width, int height, int predMode );
   void setReferenceArrayLengths   ( const CompArea &area );
 #endif
-  void xReferenceFilter           (
-#if JVET_K0500_WAIP
-    const int doubleHSize,
-#endif
-    const int doubleSize, const int origWeight, const int filterOrder, Pel *piRefVector, Pel *piLowPassRef );
 
   void destroy                    ();
 
diff --git a/source/Lib/CommonLib/version.h b/source/Lib/CommonLib/version.h
index 80b3b8536..86d5a1c75 100644
--- a/source/Lib/CommonLib/version.h
+++ b/source/Lib/CommonLib/version.h
@@ -1,3 +1,3 @@
 #if ! defined( NEXT_SOFTWARE_VERSION )
-#define NEXT_SOFTWARE_VERSION "2.0rc2"
+#define NEXT_SOFTWARE_VERSION "2.0"
 #endif
diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp
index 5756ab4fa..16908fa54 100644
--- a/source/Lib/DecoderLib/CABACReader.cpp
+++ b/source/Lib/DecoderLib/CABACReader.cpp
@@ -197,7 +197,7 @@ bool CABACReader::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i
 #if JVET_K0230_DUAL_CODING_TREE_UNDER_64x64_BLOCK
   bool isLast = false;
 
-  if (CS::isDualITree(cs) && cs.pcv->chrFormat != CHROMA_400)
+  if ( CS::isDualITree(cs) && cs.pcv->chrFormat != CHROMA_400 && cs.pcv->maxCUWidth > 64 )
   {
     Partitioner *chromaPartitioner = PartitionerFactory::get(*cs.slice);
     chromaPartitioner->initCtu(area, CH_C, *cs.slice);
@@ -210,10 +210,9 @@ bool CABACReader::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i
   else
   {
     isLast = coding_tree(cs, *partitioner, cuCtx);
-    qps[CH_L] = cuCtx.qp;
-  }
 #else
   bool isLast = coding_tree( cs, *partitioner, cuCtx );
+#endif
   qps[CH_L] = cuCtx.qp;
   if( !isLast && CS::isDualITree( cs ) && cs.pcv->chrFormat != CHROMA_400 )
   {
@@ -222,6 +221,8 @@ bool CABACReader::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i
     isLast = coding_tree( cs, *partitioner, cuCtxChroma );
     qps[CH_C] = cuCtxChroma.qp;
   }
+#if JVET_K0230_DUAL_CODING_TREE_UNDER_64x64_BLOCK
+  }
 #endif
 
   DTRACE_COND( ctuRsAddr == 0, g_trace_ctx, D_QP_PER_CTU, "\n%4d %2d", cs.picture->poc, cs.slice->getSliceQpBase() );
diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp
index 843087e0c..d98bd5146 100644
--- a/source/Lib/EncoderLib/CABACWriter.cpp
+++ b/source/Lib/EncoderLib/CABACWriter.cpp
@@ -176,7 +176,7 @@ void CABACWriter::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i
 #endif
 
 #if JVET_K0230_DUAL_CODING_TREE_UNDER_64x64_BLOCK
-  if (CS::isDualITree(cs) && cs.pcv->chrFormat != CHROMA_400)
+  if ( CS::isDualITree(cs) && cs.pcv->chrFormat != CHROMA_400 && cs.pcv->maxCUWidth > 64 )
   {
     CUCtx chromaCuCtx(qps[CH_C]);
     Partitioner *chromaPartitioner = PartitionerFactory::get(*cs.slice);
@@ -192,9 +192,6 @@ void CABACWriter::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i
 #endif
   coding_tree( cs, *partitioner, cuCtx );
   qps[CH_L] = cuCtx.qp;
-#if JVET_K0230_DUAL_CODING_TREE_UNDER_64x64_BLOCK
-  }
-#else
   if( CS::isDualITree( cs ) && cs.pcv->chrFormat != CHROMA_400 )
   {
     CUCtx cuCtxChroma( qps[CH_C] );
@@ -202,6 +199,8 @@ void CABACWriter::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i
     coding_tree( cs, *partitioner, cuCtxChroma );
     qps[CH_C] = cuCtxChroma.qp;
   }
+#if JVET_K0230_DUAL_CODING_TREE_UNDER_64x64_BLOCK
+  }
 #endif
 
   delete partitioner;
-- 
GitLab