[x265] [PATCH] Separated the logic block of code from xQuant function as two functions for optimization

praveen at multicorewareinc.com praveen at multicorewareinc.com
Wed Jun 26 14:09:21 CEST 2013


# HG changeset patch
# User praveentiwari
# Date 1372248547 -19800
# Node ID a65e58e757f5019e44087d0789e6e0ba4818b419
# Parent  440798eee5c65d555f3dbe2f2eaf939764902eda
Separated the logic block of code from xQuant function as two functions for optimization

diff -r 440798eee5c6 -r a65e58e757f5 source/common/dct.cpp
--- a/source/common/dct.cpp	Wed Jun 26 17:34:30 2013 +0530
+++ b/source/common/dct.cpp	Wed Jun 26 17:39:07 2013 +0530
@@ -761,6 +761,68 @@
         }
     }
 }
+
+unsigned int xCalQuantCoefEAdp(int * coef,
+                               int * quantCoeff,
+                               int * deltaU,
+                               int * qCoef,
+                               int * arlCCoef,
+                               int   qBitsC,
+                               int   qBits,
+                               int   add,
+                               int   numCoeff)
+{
+    int addc   = 1 << (qBitsC - 1);
+    int qBits8 = qBits - 8;
+    unsigned int acSum = 0;
+
+    for (int blockpos = 0; blockpos < numCoeff; blockpos++)
+    {
+        int level;
+        int  sign;
+        level  = coef[blockpos];
+        sign   = (level < 0 ? -1 : 1);
+
+        __int64 tmplevel = (__int64)abs(level) * quantCoeff[blockpos];
+        arlCCoef[blockpos] = (int)((tmplevel + addc) >> qBitsC);
+        level = (int)((tmplevel + add) >> qBits);
+        deltaU[blockpos] = (int)((tmplevel - (level << qBits)) >> qBits8);
+        acSum += level;
+        level *= sign;
+        qCoef[blockpos] = Clip3(-32768, 32767, level);
+    }
+
+    return acSum;
+}
+
+unsigned int xCalQuantCoefDAdp(int * coef,
+                               int * quantCoeff,
+                               int * deltaU,
+                               int * qCoef,
+                               int   qBits,
+                               int   add,
+                               int   numCoeff)
+{
+    int qBits8 = qBits - 8;
+    unsigned int acSum = 0;
+
+    for (int blockpos = 0; blockpos < numCoeff; blockpos++)
+    {
+        int level;
+        int  sign;
+        level  = coef[blockpos];
+        sign   = (level < 0 ? -1 : 1);
+
+        __int64 tmplevel = (__int64)abs(level) * quantCoeff[blockpos];
+        level = (int)((tmplevel + add) >> qBits);
+        deltaU[blockpos] = (int)((tmplevel - (level << qBits)) >> qBits8);
+        acSum += level;
+        level *= sign;
+        qCoef[blockpos] = Clip3(-32768, 32767, level);
+    }
+
+    return acSum;
+}
 }  // closing - anonymous file-static namespace
 
 namespace x265 {
@@ -769,6 +831,8 @@
 void Setup_C_DCTPrimitives(EncoderPrimitives& p)
 {
     p.deQuant = xDeQuant;
+    p.calQuantCoefEAdp = xCalQuantCoefEAdp;
+    p.calQuantCoefDAdp = xCalQuantCoefDAdp;
     p.dct[DST_4x4] = xDST4_C;
     p.dct[DCT_4x4] = xDCT4_C;
     p.dct[DCT_8x8] = xDCT8_C;


More information about the x265-devel mailing list