[x265] [PATCH] fix reading uninitialized memory in sao distortion calculation

ashok at multicorewareinc.com ashok at multicorewareinc.com
Thu Jan 21 08:00:11 CET 2016


# HG changeset patch
# User Ashok Kumar Mishra<ashok at multicorewareinc.com>
# Date 1453294662 -19800
#      Wed Jan 20 18:27:42 2016 +0530
# Node ID 4945598201d0b22317d032f19e4d43e130d6cb7a
# Parent  808ece071d225f300feaf08709a9f5e0872edc89
fix reading uninitialized memory in sao distortion calculation

diff -r 808ece071d22 -r 4945598201d0 source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Mon Jan 18 21:21:25 2016 +0530
+++ b/source/encoder/sao.cpp	Wed Jan 20 18:27:42 2016 +0530
@@ -1467,8 +1467,10 @@
             int32_t& offsetOrg = m_offsetOrg[0][typeIdx][classIdx];
             int32_t& offsetOut = m_offset[0][typeIdx][classIdx];
 
-            if (offsetOut)
+            if (count)
                 offsetOut = estIterOffset(typeIdx, m_lumaLambda, offsetOut, count, offsetOrg, distBOClasses[0], costBOClasses[0]);
+            else
+                offsetOut = 0;
 
             estDist += estSaoDist(count, (int)offsetOut << SAO_BIT_INC, offsetOrg);
         }
@@ -1508,8 +1510,10 @@
         distBOClasses[classIdx - 1] = 0;
         costBOClasses[classIdx - 1] = m_lumaLambda;
 
-        if (offsetOut)
+        if (count)
             offsetOut = estIterOffset(SAO_BO, m_lumaLambda, offsetOut, count, offsetOrg, distBOClasses[classIdx - 1], costBOClasses[classIdx - 1]);
+        else
+            offsetOut = 0;
     }
 
     // Estimate Best Position
@@ -1587,8 +1591,10 @@
                 int32_t& offsetOrg = m_offsetOrg[compIdx][typeIdx][classIdx];
                 int32_t& offsetOut = m_offset[compIdx][typeIdx][classIdx];
 
-                if (offsetOut)
+                if (count)
                     offsetOut = estIterOffset(typeIdx, m_chromaLambda, offsetOut, count, offsetOrg, distBOClasses[0], costBOClasses[0]);
+                else
+                    offsetOut = 0;
 
                 estDist[compIdx - 1] += estSaoDist(count, (int)offsetOut << SAO_BIT_INC, offsetOrg);
             }
@@ -1640,8 +1646,10 @@
             distBOClasses[classIdx - 1] = 0;
             costBOClasses[classIdx - 1] = m_chromaLambda;
 
-            if (offsetOut)
+            if (count)
                 offsetOut = estIterOffset(SAO_BO, m_chromaLambda, offsetOut, count, offsetOrg, distBOClasses[classIdx - 1], costBOClasses[classIdx - 1]);
+            else
+                offsetOut = 0;
         }
 
         for (int i = 0; i < SAO_NUM_BO_CLASSES - SAO_BO_LEN + 1; i++)


More information about the x265-devel mailing list