From 43c304f46dc7bda05aa059a250a088a216da6ba5 Mon Sep 17 00:00:00 2001
From: zhipin <zhipin.deng@bytedance.com>
Date: Sat, 21 Jan 2023 00:00:22 +0800
Subject: [PATCH 1/3] JVET-AC0189: SGPM without blending

---
 cfg/per-class/classF.cfg                      |  3 +
 source/App/EncoderApp/EncApp.cpp              |  3 +
 source/App/EncoderApp/EncAppCfg.cpp           |  6 ++
 source/App/EncoderApp/EncAppCfg.h             |  3 +
 source/Lib/CommonLib/InterpolationFilter.cpp  | 23 ++++++++
 source/Lib/CommonLib/Slice.h                  |  7 +++
 source/Lib/CommonLib/TypeDef.h                |  1 +
 .../CommonLib/x86/InterpolationFilterX86.h    | 57 +++++++++++++------
 source/Lib/DecoderLib/VLCReader.cpp           |  3 +
 source/Lib/EncoderLib/EncCfg.h                |  7 +++
 source/Lib/EncoderLib/EncLib.cpp              |  3 +
 source/Lib/EncoderLib/VLCWriter.cpp           |  3 +
 12 files changed, 102 insertions(+), 17 deletions(-)

diff --git a/cfg/per-class/classF.cfg b/cfg/per-class/classF.cfg
index 27a0010f6..1c4e7d284 100644
--- a/cfg/per-class/classF.cfg
+++ b/cfg/per-class/classF.cfg
@@ -4,4 +4,7 @@ BDPCM:           1
 TemporalFilter:  0
 IntraTMP:        1
 FastIntraTMP:    0
+
+SGPMnoBlend:     1
+
 PLT:             1
\ No newline at end of file
diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp
index 96c08dd6a..26eff8fa1 100644
--- a/source/App/EncoderApp/EncApp.cpp
+++ b/source/App/EncoderApp/EncApp.cpp
@@ -862,6 +862,9 @@ void EncApp::xInitLibCfg()
 #endif
 #if JVET_AB0155_SGPM
   m_cEncLib.setUseSgpm                                           ( m_sgpm );
+#if JVET_AC0189_SGPM_NO_BLD
+  m_cEncLib.setUseSgpmNoBlend                                    ( m_sgpmNoBlend );
+#endif
 #endif
 #if ENABLE_OBMC
   m_cEncLib.setUseObmc                                           ( m_OBMC );
diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index 331e19ee1..c02b657fc 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -1101,6 +1101,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
 #endif
 #if JVET_AB0155_SGPM
   ( "SGPM",                                           m_sgpm,                                            true,  "Enable spatial geometric partitioning mode\n" )
+#if JVET_AC0189_SGPM_NO_BLD
+  ( "SGPMnoBlend",                                    m_sgpmNoBlend,                                     false,  "Enable spatial geometric partitioning mode without blending\n" )
+#endif
 #endif
 #if ENABLE_OBMC
   ("OBMC",                                            m_OBMC,                                           true, "Overlapping Block Motion Compensation")
@@ -5234,6 +5237,9 @@ void EncAppCfg::xPrintParameter()
 #endif
 #if JVET_AB0155_SGPM
   msg(VERBOSE, "SGPM:%d ", m_sgpm);
+#if JVET_AC0189_SGPM_NO_BLD
+  msg(VERBOSE, "SGPMnoBlend:%d ", m_sgpmNoBlend);
+#endif
 #endif
 #if JVET_V0130_INTRA_TMP
   msg( VERBOSE, "IntraTMP:%d ", m_intraTMP );
diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h
index 6ef67b368..551fe05ca 100644
--- a/source/App/EncoderApp/EncAppCfg.h
+++ b/source/App/EncoderApp/EncAppCfg.h
@@ -462,6 +462,9 @@ protected:
 #endif
 #if JVET_AB0155_SGPM
   bool      m_sgpm;
+#if JVET_AC0189_SGPM_NO_BLD
+  bool      m_sgpmNoBlend;
+#endif
 #endif
 #if ENABLE_OBMC
   bool      m_OBMC;
diff --git a/source/Lib/CommonLib/InterpolationFilter.cpp b/source/Lib/CommonLib/InterpolationFilter.cpp
index 7adc95bb1..fb53cd064 100644
--- a/source/Lib/CommonLib/InterpolationFilter.cpp
+++ b/source/Lib/CommonLib/InterpolationFilter.cpp
@@ -2310,11 +2310,26 @@ void InterpolationFilter::xWeightedSgpm(const PredictionUnit &pu, const uint32_t
   int16_t  stepY  = 0;
   int16_t *weight = nullptr;
 
+#if JVET_AC0189_SGPM_NO_BLD
+  int blendWIdx = 0;
+  if (pu.cs->pps->getUseSgpmNoBlend())
+  {
+    blendWIdx = 0;
+  }
+  else
+  {
+    blendWIdx= GET_SGPM_BLD_IDX(pu.lwidth(), pu.lheight());
+  }
+#endif
   if (g_angle2mirror[angle] == 2)
   {
     stepY  = -(int) ((GEO_WEIGHT_MASK_SIZE << scaleY) + pu.lwidth());
     weight = &g_globalGeoWeights
+#if JVET_AC0189_SGPM_NO_BLD
+               [blendWIdx]
+#else
                [GET_SGPM_BLD_IDX(pu.lwidth(), pu.lheight())]
+#endif
                [g_angle2mask[angle]]
                [(GEO_WEIGHT_MASK_SIZE - 1 - g_weightOffsetEx[splitDir][hIdx][wIdx][1])
                   * GEO_WEIGHT_MASK_SIZE
@@ -2325,7 +2340,11 @@ void InterpolationFilter::xWeightedSgpm(const PredictionUnit &pu, const uint32_t
     stepX  = -1 << scaleX;
     stepY  = (GEO_WEIGHT_MASK_SIZE << scaleY) + pu.lwidth();
     weight = &g_globalGeoWeights
+#if JVET_AC0189_SGPM_NO_BLD
+               [blendWIdx]
+#else
                [GET_SGPM_BLD_IDX(pu.lwidth(), pu.lheight())]
+#endif
                [g_angle2mask[angle]]
                [g_weightOffsetEx[splitDir][hIdx][wIdx][1] * GEO_WEIGHT_MASK_SIZE
                 + (GEO_WEIGHT_MASK_SIZE - 1 - g_weightOffsetEx[splitDir][hIdx][wIdx][0])];
@@ -2334,7 +2353,11 @@ void InterpolationFilter::xWeightedSgpm(const PredictionUnit &pu, const uint32_t
   {
     stepY  = (GEO_WEIGHT_MASK_SIZE << scaleY) - pu.lwidth();
     weight = &g_globalGeoWeights
+#if JVET_AC0189_SGPM_NO_BLD
+               [blendWIdx]
+#else
                [GET_SGPM_BLD_IDX(pu.lwidth(), pu.lheight())]
+#endif
                [g_angle2mask[angle]]
                [g_weightOffsetEx[splitDir][hIdx][wIdx][1] * GEO_WEIGHT_MASK_SIZE
                 + g_weightOffsetEx[splitDir][hIdx][wIdx][0]];
diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h
index 0d24575d7..9639ce8f5 100644
--- a/source/Lib/CommonLib/Slice.h
+++ b/source/Lib/CommonLib/Slice.h
@@ -2446,6 +2446,9 @@ private:
   bool             m_wrapAroundEnabledFlag;               //< reference wrap around enabled or not
   unsigned         m_picWidthMinusWrapAroundOffset;          // <pic_width_in_minCbSizeY - wraparound_offset_in_minCbSizeY
   unsigned         m_wrapAroundOffset;                    //< reference wrap around offset in luma samples
+#if JVET_AC0189_SGPM_NO_BLD
+  bool             m_sgpmNoBlend;
+#endif
 #if JVET_V0094_BILATERAL_FILTER
   bool             m_BIF;
   int              m_BIFStrength;
@@ -2651,6 +2654,10 @@ public:
 
   void                   setCabacInitPresentFlag( bool flag )                             { m_cabacInitPresentFlag = flag;                }
   bool                   getCabacInitPresentFlag() const                                  { return m_cabacInitPresentFlag;                }
+#if JVET_AC0189_SGPM_NO_BLD
+  void                   setUseSgpmNoBlend( bool b)                                               { m_sgpmNoBlend = b;                                    }
+  bool                   getUseSgpmNoBlend() const                                                { return m_sgpmNoBlend;                                 }
+#endif
 #if JVET_V0094_BILATERAL_FILTER
   void                   setUseBIF( bool b)                                               { m_BIF = b;                                    }
   bool                   getUseBIF() const                                                { return m_BIF;                                 }
diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index 678c09735..04d099837 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -156,6 +156,7 @@
 #define JVET_AB0174_CCCM_DIV_FREE                         1 // JVET-AB0174: CCCM with division free operation
 #endif
 #define JVET_AB0155_SGPM                                  1 // JVET-AB0155: Spatial geometric partitioning mode
+#define JVET_AC0189_SGPM_NO_BLD                           1 // JVET-AC0189: Allow no blending for SGPM
 #define JVET_AB0157_TMRL                                  1 // JVET-AB0157: Template-based multiple reference line intra prediction
 #define JVET_AB0157_INTRA_FUSION                          1 // JVET-AB0157: Intra prediction fusion
 
diff --git a/source/Lib/CommonLib/x86/InterpolationFilterX86.h b/source/Lib/CommonLib/x86/InterpolationFilterX86.h
index 44a9e5084..537c1f7fa 100644
--- a/source/Lib/CommonLib/x86/InterpolationFilterX86.h
+++ b/source/Lib/CommonLib/x86/InterpolationFilterX86.h
@@ -3941,31 +3941,54 @@ void xWeightedSgpm_SSE(const PredictionUnit &pu, const uint32_t width, const uin
   int16_t  angle  = g_GeoParams[splitDir][0];
   int16_t  stepY  = 0;
   int16_t *weight = nullptr;
-  
+
+#if JVET_AC0189_SGPM_NO_BLD
+  int blendWIdx = 0;
+  if (pu.cs->pps->getUseSgpmNoBlend())
+  {
+    blendWIdx = 0;
+  }
+  else
+  {
+    blendWIdx= GET_SGPM_BLD_IDX(pu.lwidth(), pu.lheight());
+  }
+#endif
   if (g_angle2mirror[angle] == 2)
   {
-    stepY = -GEO_WEIGHT_MASK_SIZE;
-    weight =
-      &g_globalGeoWeights[GET_SGPM_BLD_IDX(pu.lwidth(), pu.lheight())][g_angle2mask[angle]]
-                         [(GEO_WEIGHT_MASK_SIZE - 1 - g_weightOffsetEx[splitDir][hIdx][wIdx][1])
-                            * GEO_WEIGHT_MASK_SIZE
-                          + g_weightOffsetEx[splitDir][hIdx][wIdx][0]];
+    stepY  = -GEO_WEIGHT_MASK_SIZE;
+    weight = &g_globalGeoWeights
+#if JVET_AC0189_SGPM_NO_BLD
+               [blendWIdx]
+#else
+               [GET_SGPM_BLD_IDX(pu.lwidth(), pu.lheight())]
+#endif
+               [g_angle2mask[angle]]
+               [(GEO_WEIGHT_MASK_SIZE - 1 - g_weightOffsetEx[splitDir][hIdx][wIdx][1]) * GEO_WEIGHT_MASK_SIZE
+                + g_weightOffsetEx[splitDir][hIdx][wIdx][0]];
   }
   else if (g_angle2mirror[angle] == 1)
   {
-    stepY = GEO_WEIGHT_MASK_SIZE;
-    weight =
-      &g_globalGeoWeights[GET_SGPM_BLD_IDX(pu.lwidth(), pu.lheight())][g_angle2mask[angle]]
-                         [g_weightOffsetEx[splitDir][hIdx][wIdx][1] * GEO_WEIGHT_MASK_SIZE
-                          + (GEO_WEIGHT_MASK_SIZE - 1 - g_weightOffsetEx[splitDir][hIdx][wIdx][0])];
+    stepY  = GEO_WEIGHT_MASK_SIZE;
+    weight = &g_globalGeoWeights
+#if JVET_AC0189_SGPM_NO_BLD
+               [blendWIdx]
+#else
+               [GET_SGPM_BLD_IDX(pu.lwidth(), pu.lheight())]
+#endif
+               [g_angle2mask[angle]][g_weightOffsetEx[splitDir][hIdx][wIdx][1] * GEO_WEIGHT_MASK_SIZE
+                                     + (GEO_WEIGHT_MASK_SIZE - 1 - g_weightOffsetEx[splitDir][hIdx][wIdx][0])];
   }
   else
   {
-    stepY = GEO_WEIGHT_MASK_SIZE;
-    weight =
-      &g_globalGeoWeights[GET_SGPM_BLD_IDX(pu.lwidth(), pu.lheight())][g_angle2mask[angle]]
-                         [g_weightOffsetEx[splitDir][hIdx][wIdx][1] * GEO_WEIGHT_MASK_SIZE
-                          + g_weightOffsetEx[splitDir][hIdx][wIdx][0]];
+    stepY  = GEO_WEIGHT_MASK_SIZE;
+    weight = &g_globalGeoWeights
+#if JVET_AC0189_SGPM_NO_BLD
+               [blendWIdx]
+#else
+               [GET_SGPM_BLD_IDX(pu.lwidth(), pu.lheight())]
+#endif
+               [g_angle2mask[angle]][g_weightOffsetEx[splitDir][hIdx][wIdx][1] * GEO_WEIGHT_MASK_SIZE
+                                     + g_weightOffsetEx[splitDir][hIdx][wIdx][0]];
   }
   const __m128i mmEight = _mm_set1_epi16(32);
   const __m128i mmOffset = _mm_set1_epi32(offsetWeighted);
diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp
index c6811834f..165c24b61 100644
--- a/source/Lib/DecoderLib/VLCReader.cpp
+++ b/source/Lib/DecoderLib/VLCReader.cpp
@@ -811,6 +811,9 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS )
     pcPPS->clearChromaQpOffsetList();
   }
   
+#if JVET_AC0189_SGPM_NO_BLD
+  READ_FLAG(uiCode, "sgpm_no_blend_flag" );                         pcPPS->setUseSgpmNoBlend(uiCode != 0) ;
+#endif
 #if JVET_V0094_BILATERAL_FILTER
   READ_FLAG( uiCode, "bilateral_filter_flag" );                        pcPPS->setUseBIF(uiCode != 0) ;
   if(pcPPS->getUseBIF())
diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h
index 0e8270d5b..ae3f2856c 100644
--- a/source/Lib/EncoderLib/EncCfg.h
+++ b/source/Lib/EncoderLib/EncCfg.h
@@ -469,6 +469,9 @@ protected:
 #endif
 #if JVET_AB0155_SGPM
   bool      m_sgpm;
+#if JVET_AC0189_SGPM_NO_BLD
+  bool      m_sgpmNoBlend;
+#endif
 #endif
 #if ENABLE_OBMC
   bool      m_OBMC;
@@ -1487,6 +1490,10 @@ public:
 #if JVET_AB0155_SGPM
   void      setUseSgpm                   (bool b)         { m_sgpm = b; }
   bool      getUseSgpm                   () const         { return m_sgpm; }
+#if JVET_AC0189_SGPM_NO_BLD
+  void      setUseSgpmNoBlend            ( bool b )       { m_sgpmNoBlend = b; }
+  bool      getUseSgpmNoBlend            ()         const { return m_sgpmNoBlend; }
+#endif
 #endif
 #if ENABLE_OBMC
   void      setUseObmc                   ( bool b )       { m_OBMC = b; }
diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp
index 57f16c82a..4e84df42e 100644
--- a/source/Lib/EncoderLib/EncLib.cpp
+++ b/source/Lib/EncoderLib/EncLib.cpp
@@ -2153,6 +2153,9 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps)
   pps.setWPBiPred( m_useWeightedBiPred );
   pps.setOutputFlagPresentFlag( false );
 
+#if JVET_AC0189_SGPM_NO_BLD
+  pps.setUseSgpmNoBlend                ( m_sgpmNoBlend );
+#endif
 #if JVET_V0094_BILATERAL_FILTER
   pps.setUseBIF                ( m_BIF );
   pps.setBIFStrength           ( m_BIFStrength );
diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp
index f33f57216..44ed5ee9e 100644
--- a/source/Lib/EncoderLib/VLCWriter.cpp
+++ b/source/Lib/EncoderLib/VLCWriter.cpp
@@ -458,6 +458,9 @@ void HLSWriter::codePPS( const PPS* pcPPS )
     }
   }
   }
+#if JVET_AC0189_SGPM_NO_BLD
+  WRITE_FLAG(pcPPS->getUseSgpmNoBlend() ? 1 : 0, "sgpm_no_blend_flag" );
+#endif
 #if JVET_V0094_BILATERAL_FILTER
   WRITE_FLAG(pcPPS->getUseBIF() ? 1 : 0, "bilateral_filter_flag" );
   if(pcPPS->getUseBIF())
-- 
GitLab


From 89f46ac0e7309bac8f248c0ca39d77b5fca0d1d9 Mon Sep 17 00:00:00 2001
From: zhipin <zhipin.deng@bytedance.com>
Date: Sat, 28 Jan 2023 17:33:15 +0800
Subject: [PATCH 2/3] fix encoder crash when JVET_AC0071_DBV and
 JVET_AC0130_NSPT are turned ON.

---
 source/Lib/CommonLib/UnitTools.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp
index b0cee170f..d76e3a17c 100644
--- a/source/Lib/CommonLib/UnitTools.cpp
+++ b/source/Lib/CommonLib/UnitTools.cpp
@@ -17869,6 +17869,12 @@ uint32_t PU::getFinalIntraModeForTransform( const TransformUnit &tu, const Compo
     }
   }
 #endif
+#if JVET_AC0071_DBV
+  if (compID != COMPONENT_Y && intraMode == DBV_CHROMA_IDX)
+  {
+    intraMode = PLANAR_IDX;
+  }
+#endif
 
   CHECK( intraMode >= NUM_INTRA_MODE - 1, "Invalid intra mode" );
 
-- 
GitLab


From 6b3837f3a6a86705143a8c0dbbc530c66eb07727 Mon Sep 17 00:00:00 2001
From: zhipin <zhipin.deng@bytedance.com>
Date: Wed, 31 Jul 2024 16:15:43 +0800
Subject: [PATCH 3/3] use MaxMTTHierarchyDepthByTidOverrideByQP: 22 322222 for
 class F and class TGM under low delay

---
 cfg/per-class/classF_lowdelay.cfg | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 cfg/per-class/classF_lowdelay.cfg

diff --git a/cfg/per-class/classF_lowdelay.cfg b/cfg/per-class/classF_lowdelay.cfg
new file mode 100644
index 000000000..b19555bd1
--- /dev/null
+++ b/cfg/per-class/classF_lowdelay.cfg
@@ -0,0 +1 @@
+MaxMTTHierarchyDepthByTidOverrideByQP: 22 322222
-- 
GitLab