<div dir="ltr">Thanks. We usually split patches based on logical changes. The output change patch correcting ncu should be one patch, and the variable renaming for better clarity should be another. <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 9, 2015 at 12:46 PM,  <span dir="ltr"><<a href="mailto:sreelakshmy@multicorewareinc.com" target="_blank">sreelakshmy@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Sreelakshmy V G <<a href="mailto:sreelakshmy@multicorewareinc.com">sreelakshmy@multicorewareinc.com</a>><br>
# Date 1425884893 -19800<br>
#      Mon Mar 09 12:38:13 2015 +0530<br>
# Node ID ef90273acbaffbf390e6a947583d9141cdf1d3e6<br>
# Parent  043c2418864b0a3ada6f597e6def6ead73d90b5f<br>
slicetype: change the value of total 16x16 blocks for averaging of qp_adj<br>
<br>
m_ncu in ratecontrol signifies actual number of 16x16 blocks, whereas ncu in<br>
slicetype leaves out the border blocks. So there is a difference in the value of<br>
both.<br>
<br>
diff -r 043c2418864b -r ef90273acbaf source/encoder/slicetype.cpp<br>
--- a/source/encoder/slicetype.cpp      Fri Mar 06 13:15:55 2015 -0600<br>
+++ b/source/encoder/slicetype.cpp      Mon Mar 09 12:38:13 2015 +0530<br>
@@ -106,6 +106,10 @@<br>
     int maxCol = curFrame->m_fencPic->m_picWidth;<br>
     int maxRow = curFrame->m_fencPic->m_picHeight;<br>
<br>
+    int cuWidth = ((param->sourceWidth / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;<br>
+    int cuHeight = ((param->sourceHeight / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;<br>
+    int m_ncu = cuWidth * cuHeight;<br>
+<br>
     for (int y = 0; y < 3; y++)<br>
     {<br>
         curFrame->m_lowres.wp_ssd[y] = 0;<br>
@@ -157,8 +161,8 @@<br>
                 }<br>
             }<br>
<br>
-            avg_adj /= ncu;<br>
-            avg_adj_pow2 /= ncu;<br>
+            avg_adj /= m_ncu;<br>
+            avg_adj_pow2 /= m_ncu;<br>
             strength = param->rc.aqStrength * avg_adj / bit_depth_correction;<br>
             avg_adj = avg_adj - 0.5f * (avg_adj_pow2 - (11.f * bit_depth_correction)) / avg_adj;<br>
         }<br>
@@ -476,9 +480,9 @@<br>
     m_outputSignalRequired = false;<br>
     m_isActive = true;<br>
<br>
-    m_heightInCU = ((m_param->sourceHeight / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;<br>
-    m_widthInCU = ((m_param->sourceWidth / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;<br>
-    m_ncu = m_widthInCU > 2 && m_heightInCU > 2 ? (m_widthInCU - 2) * (m_heightInCU - 2) : m_widthInCU * m_heightInCU;<br>
+    m_8x8Height = ((m_param->sourceHeight / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;<br>
+    m_8x8Width = ((m_param->sourceWidth / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;<br>
+    m_8x8Blocks = m_8x8Width > 2 && m_8x8Height > 2 ? (m_8x8Width - 2) * (m_8x8Height - 2) : m_8x8Width * m_8x8Height;<br>
<br>
     m_lastKeyframe = -m_param->keyframeMax;<br>
     memset(m_preframes, 0, sizeof(m_preframes));<br>
@@ -505,14 +509,14 @@<br>
<br>
     if (m_bBatchMotionSearch && m_pool->m_numWorkers > 12)<br>
     {<br>
-        m_numRowsPerSlice = m_heightInCU / (m_pool->m_numWorkers - 1);   // default to numWorkers - 1 slices<br>
+        m_numRowsPerSlice = m_8x8Height / (m_pool->m_numWorkers - 1);   // default to numWorkers - 1 slices<br>
         m_numRowsPerSlice = X265_MAX(m_numRowsPerSlice, 10);             // at least 10 rows per slice<br>
-        m_numRowsPerSlice = X265_MIN(m_numRowsPerSlice, m_heightInCU);   // but no more than the full picture<br>
-        m_numCoopSlices = m_heightInCU / m_numRowsPerSlice;<br>
+        m_numRowsPerSlice = X265_MIN(m_numRowsPerSlice, m_8x8Height);   // but no more than the full picture<br>
+        m_numCoopSlices = m_8x8Height / m_numRowsPerSlice;<br>
     }<br>
     else<br>
     {<br>
-        m_numRowsPerSlice = m_heightInCU;<br>
+        m_numRowsPerSlice = m_8x8Height;<br>
         m_numCoopSlices = 1;<br>
     }<br>
<br>
@@ -547,7 +551,7 @@<br>
     int numTLD = 1 + (m_pool ? m_pool->m_numWorkers : 0);<br>
     m_tld = new LookaheadTLD[numTLD];<br>
     for (int i = 0; i < numTLD; i++)<br>
-        m_tld[i].init(m_widthInCU, m_heightInCU, m_ncu);<br>
+        m_tld[i].init(m_8x8Width, m_8x8Height, m_8x8Blocks);<br>
     m_scratch = X265_MALLOC(int, m_tld[0].widthInCU);<br>
<br>
     return m_tld && m_scratch;<br>
@@ -799,7 +803,7 @@<br>
         uint32_t lowresRow = 0, lowresCol = 0, lowresCuIdx = 0, sum = 0;<br>
         uint32_t scale = m_param->maxCUSize / (2 * X265_LOWRES_CU_SIZE);<br>
         uint32_t numCuInHeight = (m_param->sourceHeight + g_maxCUSize - 1) / g_maxCUSize;<br>
-        uint32_t widthInLowresCu = (uint32_t)m_widthInCU, heightInLowresCu = (uint32_t)m_heightInCU;<br>
+        uint32_t widthInLowresCu = (uint32_t)m_8x8Width, heightInLowresCu = (uint32_t)m_8x8Height;<br>
         double *qp_offset = 0;<br>
         /* Factor in qpoffsets based on Aq/Cutree in CU costs */<br>
         if (m_param->rc.aqMode)<br>
@@ -1153,7 +1157,7 @@<br>
 {<br>
     int numFrames, origNumFrames, keyintLimit, framecnt;<br>
     int maxSearch = X265_MIN(m_param->lookaheadDepth, X265_LOOKAHEAD_MAX);<br>
-    int cuCount = m_ncu;<br>
+    int cuCount = m_8x8Blocks;<br>
     int resetStart;<br>
     bool bIsVbvLookahead = m_param->rc.vbvBufferSize && m_param->lookaheadDepth;<br>
<br>
@@ -1433,7 +1437,7 @@<br>
     if (res && bRealScenecut)<br>
     {<br>
         int imb = frame->intraMbs[p1 - p0];<br>
-        int pmb = m_ncu - imb;<br>
+        int pmb = m_8x8Blocks - imb;<br>
         x265_log(m_param, X265_LOG_DEBUG, "scene cut at %d Icost:%d Pcost:%d ratio:%.4f bias:%.4f gop:%d (imb:%d pmb:%d)\n",<br>
                  frame->frameNum, icost, pcost, 1. - (double)pcost / icost, bias, gopSize, imb, pmb);<br>
     }<br>
@@ -1530,7 +1534,7 @@<br>
     double averageDuration = totalDuration / (numframes + 1);<br>
<br>
     int i = numframes;<br>
-    int cuCount = m_widthInCU * m_heightInCU;<br>
+    int cuCount = m_8x8Width * m_8x8Height;<br>
<br>
     while (i > 0 && frames[i]->sliceType == X265_TYPE_B)<br>
         i--;<br>
@@ -1625,7 +1629,7 @@<br>
     int32_t bipredWeights[2] = { bipredWeight, 64 - bipredWeight };<br>
     int listDist[2] = { b - p0 - 1, p1 - b - 1 };<br>
<br>
-    memset(m_scratch, 0, m_widthInCU * sizeof(int));<br>
+    memset(m_scratch, 0, m_8x8Width * sizeof(int));<br>
<br>
     uint16_t *propagateCost = frames[b]->propagateCost;<br>
<br>
@@ -1634,20 +1638,20 @@<br>
<br>
     /* For non-referred frames the source costs are always zero, so just memset one row and re-use it. */<br>
     if (!referenced)<br>
-        memset(frames[b]->propagateCost, 0, m_widthInCU * sizeof(uint16_t));<br>
+        memset(frames[b]->propagateCost, 0, m_8x8Width * sizeof(uint16_t));<br>
<br>
-    int32_t strideInCU = m_widthInCU;<br>
-    for (uint16_t blocky = 0; blocky < m_heightInCU; blocky++)<br>
+    int32_t strideInCU = m_8x8Width;<br>
+    for (uint16_t blocky = 0; blocky < m_8x8Height; blocky++)<br>
     {<br>
         int cuIndex = blocky * strideInCU;<br>
         primitives.propagateCost(m_scratch, propagateCost,<br>
                                  frames[b]->intraCost + cuIndex, frames[b]->lowresCosts[b - p0][p1 - b] + cuIndex,<br>
-                                 frames[b]->invQscaleFactor + cuIndex, &fpsFactor, m_widthInCU);<br>
+                                 frames[b]->invQscaleFactor + cuIndex, &fpsFactor, m_8x8Width);<br>
<br>
         if (referenced)<br>
-            propagateCost += m_widthInCU;<br>
+            propagateCost += m_8x8Width;<br>
<br>
-        for (uint16_t blockx = 0; blockx < m_widthInCU; blockx++, cuIndex++)<br>
+        for (uint16_t blockx = 0; blockx < m_8x8Width; blockx++, cuIndex++)<br>
         {<br>
             int32_t propagate_amount = m_scratch[blockx];<br>
             /* Don't propagate for an intra block. */<br>
@@ -1692,7 +1696,7 @@<br>
<br>
                         /* We could just clip the MVs, but pixels that lie outside the frame probably shouldn't<br>
                          * be counted. */<br>
-                        if (cux < m_widthInCU - 1 && cuy < m_heightInCU - 1 && cux >= 0 && cuy >= 0)<br>
+                        if (cux < m_8x8Width - 1 && cuy < m_8x8Height - 1 && cux >= 0 && cuy >= 0)<br>
                         {<br>
                             CLIP_ADD(refCosts[list][idx0], (listamount * idx0weight + 512) >> 10);<br>
                             CLIP_ADD(refCosts[list][idx1], (listamount * idx1weight + 512) >> 10);<br>
@@ -1701,13 +1705,13 @@<br>
                         }<br>
                         else /* Check offsets individually */<br>
                         {<br>
-                            if (cux < m_widthInCU && cuy < m_heightInCU && cux >= 0 && cuy >= 0)<br>
+                            if (cux < m_8x8Width && cuy < m_8x8Height && cux >= 0 && cuy >= 0)<br>
                                 CLIP_ADD(refCosts[list][idx0], (listamount * idx0weight + 512) >> 10);<br>
-                            if (cux + 1 < m_widthInCU && cuy < m_heightInCU && cux + 1 >= 0 && cuy >= 0)<br>
+                            if (cux + 1 < m_8x8Width && cuy < m_8x8Height && cux + 1 >= 0 && cuy >= 0)<br>
                                 CLIP_ADD(refCosts[list][idx1], (listamount * idx1weight + 512) >> 10);<br>
-                            if (cux < m_widthInCU && cuy + 1 < m_heightInCU && cux >= 0 && cuy + 1 >= 0)<br>
+                            if (cux < m_8x8Width && cuy + 1 < m_8x8Height && cux >= 0 && cuy + 1 >= 0)<br>
                                 CLIP_ADD(refCosts[list][idx2], (listamount * idx2weight + 512) >> 10);<br>
-                            if (cux + 1 < m_widthInCU && cuy + 1 < m_heightInCU && cux + 1 >= 0 && cuy + 1 >= 0)<br>
+                            if (cux + 1 < m_8x8Width && cuy + 1 < m_8x8Height && cux + 1 >= 0 && cuy + 1 >= 0)<br>
                                 CLIP_ADD(refCosts[list][idx3], (listamount * idx3weight + 512) >> 10);<br>
                         }<br>
                     }<br>
@@ -1731,7 +1735,7 @@<br>
     /* Allow the strength to be adjusted via qcompress, since the two concepts<br>
      * are very similar. */<br>
<br>
-    int cuCount = m_widthInCU * m_heightInCU;<br>
+    int cuCount = m_8x8Width * m_8x8Height;<br>
     double strength = 5.0 * (1.0 - m_param->rc.qCompress);<br>
<br>
     for (int cuIndex = 0; cuIndex < cuCount; cuIndex++)<br>
@@ -1755,19 +1759,19 @@<br>
     double *qp_offset = (frames[b]->sliceType == X265_TYPE_B) ? frames[b]->qpAqOffset : frames[b]->qpCuTreeOffset;<br>
<br>
     x265_emms();<br>
-    for (int cuy = m_heightInCU - 1; cuy >= 0; cuy--)<br>
+    for (int cuy = m_8x8Height - 1; cuy >= 0; cuy--)<br>
     {<br>
         rowSatd[cuy] = 0;<br>
-        for (int cux = m_widthInCU - 1; cux >= 0; cux--)<br>
+        for (int cux = m_8x8Width - 1; cux >= 0; cux--)<br>
         {<br>
-            int cuxy = cux + cuy * m_widthInCU;<br>
+            int cuxy = cux + cuy * m_8x8Width;<br>
             int cuCost = frames[b]->lowresCosts[b - p0][p1 - b][cuxy] & LOWRES_COST_MASK;<br>
             double qp_adj = qp_offset[cuxy];<br>
             cuCost = (cuCost * x265_exp2fix8(qp_adj) + 128) >> 8;<br>
             rowSatd[cuy] += cuCost;<br>
-            if ((cuy > 0 && cuy < m_heightInCU - 1 &&<br>
-                 cux > 0 && cux < m_widthInCU - 1) ||<br>
-                m_widthInCU <= 2 || m_heightInCU <= 2)<br>
+            if ((cuy > 0 && cuy < m_8x8Height - 1 &&<br>
+                 cux > 0 && cux < m_8x8Width - 1) ||<br>
+                m_8x8Width <= 2 || m_8x8Height <= 2)<br>
             {<br>
                 score += cuCost;<br>
             }<br>
@@ -1842,14 +1846,14 @@<br>
             X265_CHECK(i < MAX_COOP_SLICES, "impossible number of coop slices\n");<br>
<br>
             int firstY = m_lookahead.m_numRowsPerSlice * i;<br>
-            int lastY = (i == m_jobTotal - 1) ? m_lookahead.m_heightInCU - 1 : m_lookahead.m_numRowsPerSlice * (i + 1) - 1;<br>
+            int lastY = (i == m_jobTotal - 1) ? m_lookahead.m_8x8Height - 1 : m_lookahead.m_numRowsPerSlice * (i + 1) - 1;<br>
<br>
             bool lastRow = true;<br>
             for (int cuY = lastY; cuY >= firstY; cuY--)<br>
             {<br>
                 m_frames[m_coop.b]->rowSatds[m_coop.b - m_coop.p0][m_coop.p1 - m_coop.b][cuY] = 0;<br>
<br>
-                for (int cuX = m_lookahead.m_widthInCU - 1; cuX >= 0; cuX--)<br>
+                for (int cuX = m_lookahead.m_8x8Width - 1; cuX >= 0; cuX--)<br>
                     estimateCUCost(tld, cuX, cuY, m_coop.p0, m_coop.p1, m_coop.b, m_coop.bDoSearch, lastRow, i);<br>
<br>
                 lastRow = false;<br>
@@ -1919,11 +1923,11 @@<br>
         else<br>
         {<br>
             bool lastRow = true;<br>
-            for (int cuY = m_lookahead.m_heightInCU - 1; cuY >= 0; cuY--)<br>
+            for (int cuY = m_lookahead.m_8x8Height - 1; cuY >= 0; cuY--)<br>
             {<br>
                 fenc->rowSatds[b - p0][p1 - b][cuY] = 0;<br>
<br>
-                for (int cuX = m_lookahead.m_widthInCU - 1; cuX >= 0; cuX--)<br>
+                for (int cuX = m_lookahead.m_8x8Width - 1; cuX >= 0; cuX--)<br>
                     estimateCUCost(tld, cuX, cuY, p0, p1, b, bDoSearch, lastRow, -1);<br>
<br>
                 lastRow = false;<br>
@@ -1953,8 +1957,8 @@<br>
<br>
     ReferencePlanes *wfref0 = tld.weightedRef.isWeighted ? &tld.weightedRef : fref0;<br>
<br>
-    const int widthInCU = m_lookahead.m_widthInCU;<br>
-    const int heightInCU = m_lookahead.m_heightInCU;<br>
+    const int widthInCU = m_lookahead.m_8x8Width;<br>
+    const int heightInCU = m_lookahead.m_8x8Height;<br>
     const int bBidir = (b < p1);<br>
     const int cuXY = cuX + cuY * widthInCU;<br>
     const int cuSize = X265_LOWRES_CU_SIZE;<br>
diff -r 043c2418864b -r ef90273acbaf source/encoder/slicetype.h<br>
--- a/source/encoder/slicetype.h        Fri Mar 06 13:15:55 2015 -0600<br>
+++ b/source/encoder/slicetype.h        Mon Mar 09 12:38:13 2015 +0530<br>
@@ -124,9 +124,9 @@<br>
<br>
     int           m_histogram[X265_BFRAME_MAX + 1];<br>
     int           m_lastKeyframe;<br>
-    int           m_widthInCU;<br>
-    int           m_heightInCU;<br>
-    int           m_ncu;<br>
+    int           m_8x8Width;<br>
+    int           m_8x8Height;<br>
+    int           m_8x8Blocks;<br>
     int           m_numCoopSlices;<br>
     int           m_numRowsPerSlice;<br>
     bool          m_filled;<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div>