[x265] [PATCH] Clip3 to avoid value problem

praveen at multicorewareinc.com praveen at multicorewareinc.com
Wed Aug 13 06:48:54 CEST 2014


# HG changeset patch
# User Praveen Tiwari
# Date 1407904811 -19800
# Node ID 4f9283d2781fe911eda19fa9a2e823d7af30068d
# Parent  bb4d44663964237e4b66af6d92b2f13dbcf4f9b9
Clip3 to avoid value problem

diff -r bb4d44663964 -r 4f9283d2781f source/common/quant.cpp
--- a/source/common/quant.cpp	Tue Aug 12 14:38:50 2014 +0530
+++ b/source/common/quant.cpp	Wed Aug 13 10:10:11 2014 +0530
@@ -471,7 +471,7 @@
         ALIGN_VAR_16(int16_t, qCoeff[32 * 32]);
         for (int i = 0; i < numCoeff; i++)
         {
-            qCoeff[i] = (coeff[i] & 0xFFFF);
+            qCoeff[i] = (int16_t)Clip3(-32768, 32767, coeff[i]);
         }
 
         X265_CHECK((int)numSig == primitives.count_nonzero(qCoeff, 1 << log2TrSize * 2), "numSig differ\n");
@@ -518,7 +518,7 @@
     ALIGN_VAR_16(int16_t, qCoeff[32 * 32]);
     for (int i = 0; i < numCoeff; i++)
     {
-        qCoeff[i] = (dstCoeff[i] & 0xFFFF);
+        qCoeff[i] = (int16_t)Clip3(-32768, 32767, dstCoeff[i]);
     }
 
     X265_CHECK((int)numSig == primitives.count_nonzero(qCoeff, numCoeff), "numSig differ\n");
diff -r bb4d44663964 -r 4f9283d2781f source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Tue Aug 12 14:38:50 2014 +0530
+++ b/source/encoder/entropy.cpp	Wed Aug 13 10:10:11 2014 +0530
@@ -1496,7 +1496,7 @@
     ALIGN_VAR_16(int16_t, qCoeff[32 * 32]);
     for (int i = 0; i < numCoeff; i++)
     {
-        qCoeff[i] = (coeff[i] & 0xFFFF);
+        qCoeff[i] = (int16_t)Clip3(-32768, 32767, coeff[i]);
     }
 
     // compute number of significant coefficients


More information about the x265-devel mailing list