[x265] [PATCH 2 of 2] framepp: Support NO-WPP + FrameParallelism Mode

Min Chen chenm003 at 163.com
Sat Sep 7 07:12:33 CEST 2013


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1378530741 -28800
# Node ID 413573beeef82c0196b88488271f459e28f711e2
# Parent  4bcc6891ab95a5e34c3e2b27137ffaaa224a9987
framepp: Support NO-WPP + FrameParallelism Mode

diff -r 4bcc6891ab95 -r 413573beeef8 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Sat Sep 07 13:12:05 2013 +0800
+++ b/source/encoder/encoder.cpp	Sat Sep 07 13:12:21 2013 +0800
@@ -197,6 +197,11 @@
         x265_log(_param, X265_LOG_INFO, "thread pool with %d threads, WPP enabled (%d streams)\n",
                  actual, (_param->sourceHeight + _param->maxCUSize - 1) / _param->maxCUSize);
     }
+    else if (_param->frameNumThreads > 1)
+    {
+        x265_log(_param, X265_LOG_INFO, "Frame Parallelism thread mode\n");
+        _param->bEnableWavefront = 0;
+    }
     else
     {
         x265_log(_param, X265_LOG_INFO, "Parallelism disabled, single thread mode\n");
diff -r 4bcc6891ab95 -r 413573beeef8 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Sat Sep 07 13:12:05 2013 +0800
+++ b/source/encoder/frameencoder.cpp	Sat Sep 07 13:12:21 2013 +0800
@@ -842,6 +842,10 @@
         m_pic->m_complete_enc[i] = 0;
     }
 
+    UInt refLagRows = ((m_cfg->param.searchRange + NTAPS_LUMA/2 + g_maxCUHeight - 1) / g_maxCUHeight) + 1;
+    TComSlice* slice = m_pic->getSlice();
+    int numPredDir = slice->isInterP() ? 1 : slice->isInterB() ? 2 : 0;
+
     if (m_pool && m_cfg->param.bEnableWavefront)
     {
         WaveFront::clearEnabledRowMask();
@@ -849,10 +853,6 @@
 
         m_frameFilter.start(m_pic);
 
-        UInt refLagRows = ((m_cfg->param.searchRange + NTAPS_LUMA/2 + g_maxCUHeight - 1) / g_maxCUHeight) + 1;
-
-        TComSlice* slice = m_pic->getSlice();
-        int numPredDir = slice->isInterP() ? 1 : slice->isInterB() ? 2 : 0;
         for (UInt row = 0; row < (UInt)m_numRows; row++)
         {
             for (int l = 0; l < numPredDir; l++)
@@ -881,18 +881,34 @@
     }
     else
     {
-        for (int i = 0; i < this->m_numRows; i++)
-        {
-            processRow(i);
-        }
-
         m_frameFilter.start(m_pic);
 
-        if (m_cfg->param.bEnableLoopFilter)
+        for (int i = 0; i < this->m_numRows + row_delay; i++)
         {
-            for (int i = 0; i < this->m_numRows; i++)
+            if (i < m_numRows)
             {
-                m_frameFilter.processRow(i);
+                for (int l = 0; l < numPredDir; l++)
+                {
+                    RefPicList list = (l ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
+                    for (int ref = 0; ref < slice->getNumRefIdx(list); ref++)
+                    {
+                        TComPic *refpic = slice->getRefPic(list, ref);
+                        while ((refpic->m_reconRowCount != (UInt)m_numRows) && (refpic->m_reconRowCount < i + refLagRows))
+                        {
+                            refpic->m_reconRowWait.wait();
+                        }
+                    }
+                }
+
+                processRow(i);
+            }
+
+            if (i >= row_delay)
+            {
+                if (m_cfg->param.bEnableLoopFilter)
+                {
+                    m_frameFilter.processRow(i - row_delay);
+                }
             }
         }
     }
diff -r 4bcc6891ab95 -r 413573beeef8 source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp	Sat Sep 07 13:12:05 2013 +0800
+++ b/source/encoder/framefilter.cpp	Sat Sep 07 13:12:21 2013 +0800
@@ -115,7 +115,7 @@
         m_sao.rdoSaoUnitRowInit(saoParam);
     }
 
-    if (m_cfg->param.bEnableLoopFilter && m_pool && m_cfg->param.bEnableWavefront)
+    if (m_pool && m_cfg->param.bEnableLoopFilter && m_cfg->param.bEnableWavefront)
     {
         JobProvider::enqueue();
     }



More information about the x265-devel mailing list