[x265] [PATCH 1 of 2] simplify by processRowPost()

Min Chen chenm003 at 163.com
Sun Sep 8 08:57:42 CEST 2013


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1378623388 -28800
# Node ID 6882f7eb6c318bd9cb203d5c1f29abd995ba53ac
# Parent  1f8760fdc2d8cdbea14d5ada0759fecb9fdc4398
simplify by processRowPost()

diff -r 1f8760fdc2d8 -r 6882f7eb6c31 source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp	Sat Sep 07 23:58:47 2013 -0500
+++ b/source/encoder/framefilter.cpp	Sun Sep 08 14:56:28 2013 +0800
@@ -229,45 +229,9 @@
 
     // TODO: extend margins for motion reference
 
-    TComPicYuv *recon = m_pic->getPicYuvRec();
     if (row > 0)
     {
-        // TODO: Remove when we confirm below code is right
-        //recon->xExtendPicCompBorder(recon->getLumaAddr(), recon->getStride(), recon->getWidth(), recon->getHeight(), recon->m_lumaMarginX, recon->m_lumaMarginY);
-        //recon->xExtendPicCompBorder(recon->getCbAddr(), recon->getCStride(), recon->getWidth() >> 1, recon->getHeight() >> 1, recon->m_chromaMarginX, recon->m_chromaMarginY);
-        //recon->xExtendPicCompBorder(recon->getCrAddr(), recon->getCStride(), recon->getWidth() >> 1, recon->getHeight() >> 1, recon->m_chromaMarginX, recon->m_chromaMarginY);
-        // Border extend Left and Right
-        primitives.extendRowBorder(recon->getLumaAddr(lineStartCUAddr - numCols), recon->getStride(), recon->getWidth(), g_maxCUHeight, recon->getLumaMarginX());
-        primitives.extendRowBorder(recon->getCbAddr(lineStartCUAddr - numCols), recon->getCStride(), recon->getWidth() >> 1, g_maxCUHeight >> 1, recon->getChromaMarginX());
-        primitives.extendRowBorder(recon->getCrAddr(lineStartCUAddr - numCols), recon->getCStride(), recon->getWidth() >> 1, g_maxCUHeight >> 1, recon->getChromaMarginX());
-
-        // Border extend Top
-        if (row == 1)
-        {
-            const intptr_t stride = recon->getStride();
-            const intptr_t strideC = recon->getCStride();
-            Pel *pixY = recon->getLumaAddr(lineStartCUAddr - numCols) - recon->getLumaMarginX();
-            Pel *pixU = recon->getCbAddr(lineStartCUAddr - numCols) - recon->getChromaMarginX();
-            Pel *pixV = recon->getCrAddr(lineStartCUAddr - numCols) - recon->getChromaMarginX();
-
-            for (int y = 0; y < recon->getLumaMarginY(); y++)
-            {
-                memcpy(pixY - (y + 1) * stride, pixY, stride * sizeof(Pel));
-            }
-
-            for (int y = 0; y < recon->getChromaMarginY(); y++)
-            {
-                memcpy(pixU - (y + 1) * strideC, pixU, strideC * sizeof(Pel));
-                memcpy(pixV - (y + 1) * strideC, pixV, strideC * sizeof(Pel));
-            }
-        }
-
-        // Notify other FrameEncoders that this row of reconstructed pixels is available
-        m_pic->m_reconRowCount++;
-        for (UInt i = 0; i < m_pic->m_countRefEncoders; i++)
-        {
-            m_pic->m_reconRowWait.trigger();
-        }
+        processRowPost(row - 1);
     }
 
     if (row == m_numRows - 1)
@@ -298,43 +262,77 @@
             }
         }
 
-        // TODO: Remove when we confirm below code is right
-        //recon->xExtendPicCompBorder(recon->getLumaAddr(), recon->getStride(), recon->getWidth(), recon->getHeight(), recon->m_lumaMarginX, recon->m_lumaMarginY);
-        //recon->xExtendPicCompBorder(recon->getCbAddr(), recon->getCStride(), recon->getWidth() >> 1, recon->getHeight() >> 1, recon->m_chromaMarginX, recon->m_chromaMarginY);
-        //recon->xExtendPicCompBorder(recon->getCrAddr(), recon->getCStride(), recon->getWidth() >> 1, recon->getHeight() >> 1, recon->m_chromaMarginX, recon->m_chromaMarginY);
-        // Border extend Left and Right
-        const int realH = ((recon->getHeight() % g_maxCUHeight) ? (recon->getHeight() % g_maxCUHeight) : g_maxCUHeight);
-        primitives.extendRowBorder(recon->getLumaAddr(lineStartCUAddr), recon->getStride(), recon->getWidth(), realH, recon->getLumaMarginX());
-        primitives.extendRowBorder(recon->getCbAddr(lineStartCUAddr), recon->getCStride(), recon->getWidth() >> 1, realH >> 1, recon->getChromaMarginX());
-        primitives.extendRowBorder(recon->getCrAddr(lineStartCUAddr), recon->getCStride(), recon->getWidth() >> 1, realH >> 1, recon->getChromaMarginX());
-
-        // Border extend Bottom
-        {
-            const intptr_t stride = recon->getStride();
-            const intptr_t strideC = recon->getCStride();
-            Pel *pixY = recon->getLumaAddr(lineStartCUAddr) - recon->getLumaMarginX() + (realH - 1) * stride;
-            Pel *pixU = recon->getCbAddr(lineStartCUAddr) - recon->getChromaMarginX() + ((realH >> 1) - 1) * strideC;
-            Pel *pixV = recon->getCrAddr(lineStartCUAddr) - recon->getChromaMarginX() + ((realH >> 1) - 1) * strideC;
-
-            for (int y = 0; y < recon->getLumaMarginY(); y++)
-            {
-                memcpy(pixY + (y + 1) * stride, pixY, stride * sizeof(Pel));
-            }
-
-            for (int y = 0; y < recon->getChromaMarginY(); y++)
-            {
-                memcpy(pixU + (y + 1) * strideC, pixU, strideC * sizeof(Pel));
-                memcpy(pixV + (y + 1) * strideC, pixV, strideC * sizeof(Pel));
-            }
-        }
-
-        // Notify other FrameEncoders that this row of reconstructed pixels is available
-        m_pic->m_reconRowCount++;
-        for (UInt i = 0; i < m_pic->m_countRefEncoders; i++)
-        {
-            m_pic->m_reconRowWait.trigger();
-        }
+        processRowPost(row);
 
         m_completionEvent.trigger();
     }
 }
+
+void FrameFilter::processRowPost(int row)
+{
+    PPAScopeEvent(Thread_filterCU);
+
+    const uint32_t numCols = m_pic->getPicSym()->getFrameWidthInCU();
+    const uint32_t lineStartCUAddr = row * numCols;
+    TComPicYuv *recon = m_pic->getPicYuvRec();
+    const int lastH = ((recon->getHeight() % g_maxCUHeight) ? (recon->getHeight() % g_maxCUHeight) : g_maxCUHeight);
+    const int realH = (row != m_numRows - 1) ? g_maxCUHeight : lastH;
+
+    // TODO: Remove when we confirm below code is right
+    //recon->xExtendPicCompBorder(recon->getLumaAddr(), recon->getStride(), recon->getWidth(), recon->getHeight(), recon->m_lumaMarginX, recon->m_lumaMarginY);
+    //recon->xExtendPicCompBorder(recon->getCbAddr(), recon->getCStride(), recon->getWidth() >> 1, recon->getHeight() >> 1, recon->m_chromaMarginX, recon->m_chromaMarginY);
+    //recon->xExtendPicCompBorder(recon->getCrAddr(), recon->getCStride(), recon->getWidth() >> 1, recon->getHeight() >> 1, recon->m_chromaMarginX, recon->m_chromaMarginY);
+    // Border extend Left and Right
+    primitives.extendRowBorder(recon->getLumaAddr(lineStartCUAddr), recon->getStride(), recon->getWidth(), realH, recon->getLumaMarginX());
+    primitives.extendRowBorder(recon->getCbAddr(lineStartCUAddr), recon->getCStride(), recon->getWidth() >> 1, realH >> 1, recon->getChromaMarginX());
+    primitives.extendRowBorder(recon->getCrAddr(lineStartCUAddr), recon->getCStride(), recon->getWidth() >> 1, realH >> 1, recon->getChromaMarginX());
+
+    // Border extend Top
+    if (row == 0)
+    {
+        const intptr_t stride = recon->getStride();
+        const intptr_t strideC = recon->getCStride();
+        Pel *pixY = recon->getLumaAddr(lineStartCUAddr) - recon->getLumaMarginX();
+        Pel *pixU = recon->getCbAddr(lineStartCUAddr) - recon->getChromaMarginX();
+        Pel *pixV = recon->getCrAddr(lineStartCUAddr) - recon->getChromaMarginX();
+
+        for (int y = 0; y < recon->getLumaMarginY(); y++)
+        {
+            memcpy(pixY - (y + 1) * stride, pixY, stride * sizeof(Pel));
+        }
+
+        for (int y = 0; y < recon->getChromaMarginY(); y++)
+        {
+            memcpy(pixU - (y + 1) * strideC, pixU, strideC * sizeof(Pel));
+            memcpy(pixV - (y + 1) * strideC, pixV, strideC * sizeof(Pel));
+        }
+    }
+
+    // Border extend Bottom
+    if (row == m_numRows - 1)
+    {
+        const intptr_t stride = recon->getStride();
+        const intptr_t strideC = recon->getCStride();
+        Pel *pixY = recon->getLumaAddr(lineStartCUAddr) - recon->getLumaMarginX() + (realH - 1) * stride;
+        Pel *pixU = recon->getCbAddr(lineStartCUAddr) - recon->getChromaMarginX() + ((realH >> 1) - 1) * strideC;
+        Pel *pixV = recon->getCrAddr(lineStartCUAddr) - recon->getChromaMarginX() + ((realH >> 1) - 1) * strideC;
+
+        for (int y = 0; y < recon->getLumaMarginY(); y++)
+        {
+            memcpy(pixY + (y + 1) * stride, pixY, stride * sizeof(Pel));
+        }
+
+        for (int y = 0; y < recon->getChromaMarginY(); y++)
+        {
+            memcpy(pixU + (y + 1) * strideC, pixU, strideC * sizeof(Pel));
+            memcpy(pixV + (y + 1) * strideC, pixV, strideC * sizeof(Pel));
+        }
+    }
+
+    // Notify other FrameEncoders that this row of reconstructed pixels is available
+    m_pic->m_reconRowCount++;
+    for (UInt i = 0; i < m_pic->m_countRefEncoders; i++)
+    {
+        m_pic->m_reconRowWait.trigger();
+    }
+}
diff -r 1f8760fdc2d8 -r 6882f7eb6c31 source/encoder/framefilter.h
--- a/source/encoder/framefilter.h	Sat Sep 07 23:58:47 2013 -0500
+++ b/source/encoder/framefilter.h	Sun Sep 08 14:56:28 2013 +0800
@@ -60,6 +60,7 @@
     bool findJob();
 
     void processRow(int row);
+    void processRowPost(int row);
 
 protected:
 



More information about the x265-devel mailing list