diff --git a/source/Lib/CommonLib/AdaptiveLoopFilter.cpp b/source/Lib/CommonLib/AdaptiveLoopFilter.cpp
index 61105f0c0e8307a7c6ae1b1195fbd83c3acaac6f..d170fee63b48919b25688f284ab34f599f088c58 100644
--- a/source/Lib/CommonLib/AdaptiveLoopFilter.cpp
+++ b/source/Lib/CommonLib/AdaptiveLoopFilter.cpp
@@ -1011,7 +1011,11 @@ void AdaptiveLoopFilter::deriveClassificationBlk(AlfClassifier **classifier, int
         d0 = sumD0;
         dirTempD = 2;
       }
+#if RExt__HIGH_BIT_DEPTH_SUPPORT
+      if( (uint64_t)d1 * (uint64_t)hv0 > (uint64_t)hv1 * (uint64_t)d0 )
+#else
       if( (uint32_t)d1 * (uint32_t)hv0 > (uint32_t)hv1 * (uint32_t)d0 )
+#endif
       {
         hvd1 = d1;
         hvd0 = d0;