[x265] [PATCH] slicetype: save variances into lowres structure

deepthi at multicorewareinc.com deepthi at multicorewareinc.com
Fri Nov 20 12:11:10 CET 2015


# HG changeset patch
# User Deepthi Nandakumar <deepthi at multicorewareinc.com>
# Date 1448017715 -19800
#      Fri Nov 20 16:38:35 2015 +0530
# Node ID a1664e01789d977238b51372045e3e54e4ebb195
# Parent  f722fb55404bb80b26a55ba0a0a1b98d8f20b362
slicetype: save variances into lowres structure

diff -r f722fb55404b -r a1664e01789d source/common/lowres.cpp
--- a/source/common/lowres.cpp	Wed Nov 18 12:28:03 2015 +0530
+++ b/source/common/lowres.cpp	Fri Nov 20 16:38:35 2015 +0530
@@ -52,6 +52,7 @@
         CHECKED_MALLOC(qpAqOffset, double, cuCount);
         CHECKED_MALLOC(invQscaleFactor, int, cuCount);
         CHECKED_MALLOC(qpCuTreeOffset, double, cuCount);
+        CHECKED_MALLOC(blockVariance, uint32_t, cuCount);
     }
     CHECKED_MALLOC(propagateCost, uint16_t, cuCount);
 
@@ -120,6 +121,7 @@
     X265_FREE(invQscaleFactor);
     X265_FREE(qpCuTreeOffset);
     X265_FREE(propagateCost);
+    X265_FREE(blockVariance);
 }
 
 // (re) initialize lowres state
diff -r f722fb55404b -r a1664e01789d source/common/lowres.h
--- a/source/common/lowres.h	Wed Nov 18 12:28:03 2015 +0530
+++ b/source/common/lowres.h	Fri Nov 20 16:38:35 2015 +0530
@@ -143,8 +143,10 @@
     double*   qpAqOffset;      // AQ QP offset values for each 16x16 CU
     double*   qpCuTreeOffset;  // cuTree QP offset values for each 16x16 CU
     int*      invQscaleFactor; // qScale values for qp Aq Offsets
+    uint32_t* blockVariance;
     uint64_t  wp_ssd[3];       // This is different than SSDY, this is sum(pixel^2) - sum(pixel)^2 for entire frame
     uint64_t  wp_sum[3];
+    uint64_t  frameVariance;
 
     /* cutree intermediate data */
     uint16_t* propagateCost;
diff -r f722fb55404b -r a1664e01789d source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Wed Nov 18 12:28:03 2015 +0530
+++ b/source/encoder/slicetype.cpp	Fri Nov 20 16:38:35 2015 +0530
@@ -147,19 +147,25 @@
         if (param->rc.aqMode == X265_AQ_AUTO_VARIANCE || param->rc.aqMode == X265_AQ_AUTO_VARIANCE_BIASED)
         {
             double bit_depth_correction = 1.f / (1 << (2*(X265_DEPTH-8)));
+            curFrame->m_lowres.frameVariance = 0;
+            uint64_t rowVariance = 0;
             for (blockY = 0; blockY < maxRow; blockY += 16)
             {
+                rowVariance = 0;
                 for (blockX = 0; blockX < maxCol; blockX += 16)
                 {
                     uint32_t energy = acEnergyCu(curFrame, blockX, blockY, param->internalCsp);
+                    curFrame->m_lowres.blockVariance[blockXY] = energy;
+                    rowVariance += energy;
                     qp_adj = pow(energy * bit_depth_correction + 1, 0.1);
                     curFrame->m_lowres.qpCuTreeOffset[blockXY] = qp_adj;
                     avg_adj += qp_adj;
                     avg_adj_pow2 += qp_adj * qp_adj;
                     blockXY++;
                 }
+                curFrame->m_lowres.frameVariance += (rowVariance / maxCol);
             }
-
+            curFrame->m_lowres.frameVariance /= maxRow;
             avg_adj /= blockCount;
             avg_adj_pow2 /= blockCount;
             strength = param->rc.aqStrength * avg_adj;


More information about the x265-devel mailing list