[x265] [PATCH 2 of 2] improve getCUHeight()

Min Chen chenm003 at 163.com
Thu Jan 7 00:24:07 CET 2016


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1452121210 21600
# Node ID d4389c744980cf69cad5c948e4d62e60057a98ba
# Parent  375c1f0cfd8a69e4a118cf4e4094f871c0c3a216
improve getCUHeight()
---
 source/encoder/framefilter.cpp |   17 +++++++++--------
 source/encoder/framefilter.h   |    8 ++++----
 2 files changed, 13 insertions(+), 12 deletions(-)

diff -r 375c1f0cfd8a -r d4389c744980 source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp	Wed Jan 06 17:00:07 2016 -0600
+++ b/source/encoder/framefilter.cpp	Wed Jan 06 17:00:10 2016 -0600
@@ -87,13 +87,14 @@
             }
         }
 
+        const int lastWidth = (m_param->sourceWidth % g_maxCUSize) ? (m_param->sourceWidth % g_maxCUSize) : g_maxCUSize;
         for(int row = 0; row < numRows; row++)
         {
             // Setting maximum bound information
             m_parallelFilter[row].m_numCols = numCols;
             m_parallelFilter[row].m_numRows = numRows;
-            m_parallelFilter[row].m_lastHeight = m_lastHeight;
-            m_parallelFilter[row].m_lastWidth = (m_param->sourceWidth % g_maxCUSize) ? (m_param->sourceWidth % g_maxCUSize) : g_maxCUSize;
+            m_parallelFilter[row].m_rowHeight = (row == numRows - 1) ? m_lastHeight : g_maxCUSize;
+            m_parallelFilter[row].m_lastWidth = lastWidth;
             m_parallelFilter[row].m_param = m_param;
             m_parallelFilter[row].m_row = row;
             m_parallelFilter[row].m_rowAddr = row * numCols;
@@ -235,7 +236,7 @@
 
     PicYuv *reconPic = m_frame->m_reconPic;
     const uint32_t lineStartCUAddr = m_rowAddr + col;
-    const int realH = getCUHeight(m_row);
+    const int realH = getCUHeight();
     const int realW = getCUWidth(col);
 
     const uint32_t lumaMarginX = reconPic->m_lumaMarginX;
@@ -526,7 +527,7 @@
     PicYuv *reconPic = m_frame->m_reconPic;
     const uint32_t rowAddr = row * m_parallelFilter[row].m_numCols;
     const uint32_t lineStartCUAddr = rowAddr + col;
-    const int realH = m_parallelFilter[row].getCUHeight(row);
+    const int realH = m_parallelFilter[row].getCUHeight();
     const int realW = m_parallelFilter[row].getCUWidth(col);
 
     const uint32_t lumaMarginX = reconPic->m_lumaMarginX;
@@ -624,7 +625,7 @@
 
         intptr_t stride = reconPic->m_stride;
         uint32_t width  = reconPic->m_picWidth - m_pad[0];
-        uint32_t height = m_parallelFilter[row].getCUHeight(row);
+        uint32_t height = m_parallelFilter[row].getCUHeight();
 
         uint64_t ssdY = computeSSD(fencPic->getLumaAddr(cuAddr), reconPic->getLumaAddr(cuAddr), stride, width, height);
         m_frameEncoder->m_SSDY += ssdY;
@@ -664,7 +665,7 @@
     }
     if (m_param->decodedPictureHashSEI == 1)
     {
-        uint32_t height = m_parallelFilter[row].getCUHeight(row);
+        uint32_t height = m_parallelFilter[row].getCUHeight();
         uint32_t width = reconPic->m_picWidth;
         intptr_t stride = reconPic->m_stride;
 
@@ -690,7 +691,7 @@
     }
     else if (m_param->decodedPictureHashSEI == 2)
     {
-        uint32_t height = m_parallelFilter[row].getCUHeight(row);
+        uint32_t height = m_parallelFilter[row].getCUHeight();
         uint32_t width = reconPic->m_picWidth;
         intptr_t stride = reconPic->m_stride;
 
@@ -712,7 +713,7 @@
     else if (m_param->decodedPictureHashSEI == 3)
     {
         uint32_t width = reconPic->m_picWidth;
-        uint32_t height = m_parallelFilter[row].getCUHeight(row);
+        uint32_t height = m_parallelFilter[row].getCUHeight();
         intptr_t stride = reconPic->m_stride;
         uint32_t cuHeight = g_maxCUSize;
 
diff -r 375c1f0cfd8a -r d4389c744980 source/encoder/framefilter.h
--- a/source/encoder/framefilter.h	Wed Jan 06 17:00:07 2016 -0600
+++ b/source/encoder/framefilter.h	Wed Jan 06 17:00:10 2016 -0600
@@ -63,7 +63,7 @@
     public:
         uint32_t            m_numCols;
         uint32_t            m_numRows;
-        uint32_t            m_lastHeight;
+        uint32_t            m_rowHeight;
         uint32_t            m_lastWidth;
         uint32_t            m_row;
         uint32_t            m_rowAddr;
@@ -80,7 +80,7 @@
         ParallelFilter()
             : m_numCols(0)
             , m_numRows(0)
-            , m_lastHeight(0)
+            , m_rowHeight(0)
             , m_lastWidth(0)
             , m_row(0)
             , m_rowAddr(0)
@@ -106,9 +106,9 @@
         // Post-Process (Border extension)
         void processPostCu(uint32_t col) const;
 
-        uint32_t getCUHeight(int rowNum) const
+        uint32_t getCUHeight() const
         {
-            return (rowNum == (int)m_numRows - 1) ? m_lastHeight : g_maxCUSize;
+            return m_rowHeight;
         }
 
         uint32_t getCUWidth(int colNum) const



More information about the x265-devel mailing list