[x265] [PATCH] rc: Initialized qp and aq offsets and QscaleFactor if aqmode is disabled these variables need for cutree analyse

Gopu Govindaswamy gopu at multicorewareinc.com
Fri Dec 13 12:07:33 CET 2013


# HG changeset patch
# User Gopu Govindaswamy <gopu at multicorewareinc.com>
# Date 1386932843 -19800
# Node ID 497f2b09b32c803f336fed0f2249257ebc46e5a4
# Parent  3247897e88112137f95d73afabba7c03298f198d
rc: Initialized qp and aq offsets and QscaleFactor if aqmode is disabled these variables need for cutree analyse

diff -r 3247897e8811 -r 497f2b09b32c source/common/common.cpp
--- a/source/common/common.cpp	Fri Dec 13 15:17:06 2013 +0530
+++ b/source/common/common.cpp	Fri Dec 13 16:37:23 2013 +0530
@@ -520,6 +520,11 @@
         x265_log(param, X265_LOG_WARNING, "Aq mode specified, but Aq strength is  0, ignored\n");
         param->rc.aqMode = 0;
     }
+    if (param->rc.aqMode == 0 && param->rc.cuTree)
+    {
+        param->rc.aqMode = X265_AQ_VARIANCE;
+        param->rc.aqStrength = 0;
+    }
 
     return check_failed;
 }
diff -r 3247897e8811 -r 497f2b09b32c source/common/lowres.cpp
--- a/source/common/lowres.cpp	Fri Dec 13 15:17:06 2013 +0530
+++ b/source/common/lowres.cpp	Fri Dec 13 16:37:23 2013 +0530
@@ -50,12 +50,6 @@
         qpOffset = (double*)x265_malloc(sizeof(double) * cuCount);
         if (!qpAqOffset || !invQscaleFactor || !qpOffset)
             *aqMode = 0;
-        else
-        {
-            ::memset(qpAqOffset, 0, sizeof(double) * cuCount);
-            ::memset(invQscaleFactor, 0, sizeof(int) * cuCount);
-            ::memset(qpOffset, 0, sizeof(double) * cuCount);
-        }
     }
     propagateCost = (uint16_t*)x265_malloc(sizeof(uint16_t) * cuCount);
 
diff -r 3247897e8811 -r 497f2b09b32c source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Fri Dec 13 15:17:06 2013 +0530
+++ b/source/encoder/ratecontrol.cpp	Fri Dec 13 16:37:23 2013 +0530
@@ -102,17 +102,35 @@
     int block_xy = 0;
     int block_x = 0, block_y = 0;
 
-    for (block_y = 0; block_y < maxRow; block_y += 16)
+    if (cfg->param.rc.aqMode == X265_AQ_NONE || cfg->param.rc.aqStrength == 0)
     {
-        for (block_x = 0; block_x < maxCol; block_x += 16)
+        /* Need to init it anyways for MB tree */
+        int cuWidth = ((maxCol / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
+        int cuHeight = ((maxRow / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
+        int cuCount = cuWidth * cuHeight;
+
+        if(cfg->param.rc.aqMode && cfg->param.rc.aqStrength == 0 )
         {
-            double qp_adj = acEnergyCu(pic, block_x, block_y);
-            if (cfg->param.rc.aqMode)
+            memset(pic->m_lowres.qpOffset, 0, cuCount * sizeof(double));
+            memset(pic->m_lowres.qpAqOffset, 0, cuCount * sizeof(double) );
+            for (int cuxy = 0; cuxy < cuCount; cuxy++ )
+                pic->m_lowres.invQscaleFactor[cuxy] = 256;
+        }
+    }
+    else
+    {
+        for (block_y = 0; block_y < maxRow; block_y += 16)
+        {
+            for (block_x = 0; block_x < maxCol; block_x += 16)
             {
-                pic->m_lowres.qpAqOffset[block_xy] = qp_adj;
-                pic->m_lowres.qpOffset[block_xy] = qp_adj;
-                pic->m_lowres.invQscaleFactor[block_xy] = x265_exp2fix8(qp_adj);
-                block_xy++;
+                double qp_adj = acEnergyCu(pic, block_x, block_y);
+                if (cfg->param.rc.aqMode)
+                {
+                    pic->m_lowres.qpAqOffset[block_xy] = qp_adj;
+                    pic->m_lowres.qpOffset[block_xy] = qp_adj;
+                    pic->m_lowres.invQscaleFactor[block_xy] = x265_exp2fix8(qp_adj);
+                    block_xy++;
+                }
             }
         }
     }


More information about the x265-devel mailing list