diff --git a/source/Lib/CommonLib/ContextModelling.h b/source/Lib/CommonLib/ContextModelling.h
index 4fb7a2ae9ec8e33eed35b3d3e46cefdebd969478..297e5c078df4b8fe78c6ea5e3080a0f006963de8 100644
--- a/source/Lib/CommonLib/ContextModelling.h
+++ b/source/Lib/CommonLib/ContextModelling.h
@@ -228,31 +228,17 @@ public:
     }
   }
 
-  unsigned templateAbsCompare(TCoeff sum)
+  static unsigned templateAbsCompare(TCoeff sum)
   {
-    int rangeIdx = 0;
-    if (sum < g_riceT[0])
+    for (int rangeIdx = 0; rangeIdx < g_riceThreshold.size(); rangeIdx++)
     {
-      rangeIdx = 0;
-    }
-    else if (sum < g_riceT[1])
-    {
-      rangeIdx = 1;
-    }
-    else if (sum < g_riceT[2])
-    {
-      rangeIdx = 2;
-    }
-    else if (sum < g_riceT[3])
-    {
-      rangeIdx = 3;
-    }
-    else
-    {
-      rangeIdx = 4;
+      if (sum < g_riceThreshold[rangeIdx])
+      {
+        return g_riceShift[rangeIdx];
+      }
     }
 
-    return g_riceShift[rangeIdx];
+    return g_riceShift[g_riceThreshold.size()];
   }
 
   unsigned templateAbsSumExt(int scanPos, const TCoeff* coeff, int baseLevel)
@@ -304,7 +290,7 @@ public:
       sum += m_histValue;
     }
 
-    int currentShift = templateAbsCompare(sum);
+    const int currentShift = templateAbsCompare(sum);
     sum = sum >> currentShift;
     if (baseLevel == 0)
     {
diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp
index 063f863c1c851e2e51a2cfe29199804e734acfe0..b699875e1a95d6d82cd0cd45c11c467eaf5012f6 100644
--- a/source/Lib/CommonLib/DepQuant.cpp
+++ b/source/Lib/CommonLib/DepQuant.cpp
@@ -1068,32 +1068,6 @@ namespace DQIntern
     unsigned                  effHeight;
   };
 
-  unsigned templateAbsCompare(TCoeff sum)
-  {
-    int rangeIdx = 0;
-    if (sum < g_riceT[0])
-    {
-      rangeIdx = 0;
-    }
-    else if (sum < g_riceT[1])
-    {
-      rangeIdx = 1;
-    }
-    else if (sum < g_riceT[2])
-    {
-      rangeIdx = 2;
-    }
-    else if (sum < g_riceT[3])
-    {
-      rangeIdx = 3;
-    }
-    else
-    {
-      rangeIdx = 4;
-    }
-    return g_riceShift[rangeIdx];
-  }
-
   State::State( const RateEstimator& rateEst, CommonCtx& commonCtx, const int stateId )
     : m_sbbFracBits     { { 0, 0 } }
     , m_stateId         ( stateId )
@@ -1212,7 +1186,7 @@ namespace DQIntern
 #undef UPDATE
         if (extRiceFlag)
         {
-          unsigned currentShift = templateAbsCompare(sumAbs);
+          unsigned currentShift = CoeffCodingContext::templateAbsCompare(sumAbs);
           sumAbs = sumAbs >> currentShift;
           int sumAll = std::max(std::min(31, (int)sumAbs - (int)baseLevel), 0);
           m_goRicePar = g_goRiceParsCoeff[sumAll];
@@ -1261,7 +1235,7 @@ namespace DQIntern
 #undef UPDATE
         if (extRiceFlag)
         {
-          unsigned currentShift = templateAbsCompare(sumAbs);
+          unsigned currentShift = CoeffCodingContext::templateAbsCompare(sumAbs);
           sumAbs = sumAbs >> currentShift;
           sumAbs = std::min<TCoeff>(31, sumAbs);
           m_goRicePar = g_goRiceParsCoeff[sumAbs];
diff --git a/source/Lib/CommonLib/Rom.cpp b/source/Lib/CommonLib/Rom.cpp
index 1556f548f4bb8779523b2676a74e76f4c0b1ead7..f8ed3b781aae73bf79c9d87596f7540e9dac0df2 100644
--- a/source/Lib/CommonLib/Rom.cpp
+++ b/source/Lib/CommonLib/Rom.cpp
@@ -523,8 +523,10 @@ UnitScale g_miScaling( MIN_CU_LOG2, MIN_CU_LOG2 );
 // ====================================================================================================================
 // Scanning order & context model mapping
 // ====================================================================================================================
-int g_riceT[4] = { 32,128, 512, 2048 };
-int g_riceShift[5] = { 0, 2, 4, 6, 8 };
+const std::array<TCoeff, 4> g_riceThreshold = { 32, 128, 512, 2048 };
+
+const std::array<uint8_t, g_riceThreshold.size() + 1> g_riceShift = { 0, 2, 4, 6, 8 };
+
 // scanning order table
 EnumArray<ScanElement *[MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1], CoeffScanType> g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES];
 ScanElement  g_coefTopLeftDiagScan8x8[ MAX_CU_SIZE / 2 + 1 ][ 64 ];
diff --git a/source/Lib/CommonLib/Rom.h b/source/Lib/CommonLib/Rom.h
index d30f3750bf5a2fa58b4031537c6100ba05d3f724..0c913bed9e8f0720868c9fad23c9544489fdf4be 100644
--- a/source/Lib/CommonLib/Rom.h
+++ b/source/Lib/CommonLib/Rom.h
@@ -86,8 +86,10 @@ static const int g_transformMatrixShift[TRANSFORM_NUMBER_OF_DIRECTIONS] = {  6,
 // ====================================================================================================================
 // Scanning order & context mapping table
 // ====================================================================================================================
-extern int g_riceT[4];
-extern int g_riceShift[5];
+extern const std::array<TCoeff, 4> g_riceThreshold;
+
+extern const std::array<uint8_t, g_riceThreshold.size() + 1> g_riceShift;
+
 extern const uint32_t g_groupIdx[MAX_TB_SIZEY];
 extern const uint32_t g_minInGroup[LAST_SIGNIFICANT_GROUPS];
 extern const uint32_t g_goRiceParsCoeff[32];