[x265] [PATCH] Use mixed bitmap between FrameEncoder and FrameFilter to Fix crash and hash mistake in WPP mode

Min Chen chenm003 at 163.com
Mon Sep 16 15:03:30 CEST 2013


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1379336600 -28800
# Node ID 7669e48568743a927c5f1ee14c8adf76d5e3a406
# Parent  62964b3d57d9e47cf68aad57808bab568b105d61
Use mixed bitmap between FrameEncoder and FrameFilter to Fix crash and hash mistake in WPP mode

I change task schedult bitmap to mixed FrameEncoder and FrameFilter
because there catch two bugs, and I want to reduce latency of Frame
Parallelism.
The new bitmap mapping 2N+0 to FrameEncoder and 2N+1 to FrameFilter.

Side effect:
1. We can remove the lock from FrameFilter.
2. Mixed bitmap let us do Filter early, so reduce latency of Frame
   Parallelism

Solved bugs:
1. CRASH: the reason is sometime two of threads finish in same time,
   so they will enter Filter in wrong order and sent Finished Event
   early.
   when main thread dequeue JobProvider and execute FrameFilter, we
   will catch a crash!

2. HASH MISTAKE: the reason is same as below, but last row is right
   order, we will got worng reconst image.

diff -r 62964b3d57d9 -r 7669e4856874 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Mon Sep 16 21:01:47 2013 +0800
+++ b/source/encoder/frameencoder.cpp	Mon Sep 16 21:03:20 2013 +0800
@@ -919,8 +919,6 @@
 {
     PPAScopeEvent(Thread_ProcessRow);
 
-    //printf("Encoder(%2d)\n", row);
-
     // Called by worker threads
     CTURow& curRow  = m_rows[row];
     CTURow& codeRow = m_rows[m_cfg->param.bEnableWavefront ? row : 0];
@@ -954,7 +952,7 @@
                 m_rows[row + 1].m_completed + 2 <= m_rows[row].m_completed)
             {
                 m_rows[row + 1].m_active = true;
-                enqueueRowEncoder(row + 1);
+                WaveFront::enqueueRow(row + 1);
             }
         }
 
@@ -970,16 +968,13 @@
     // Run row-wise loop filters
     if (row >= m_filterRowDelay)
     {
-        enqueueRowFilter(row - m_filterRowDelay);
-
-        // NOTE: Active Filter to first row (row 0)
-        if (row == m_filterRowDelay)
-            enableRowFilter(0);
+        m_frameFilter.processRow(row - m_filterRowDelay);
     }
     if (row == m_numRows - 1)
     {
         for(int i = m_numRows - m_filterRowDelay; i < m_numRows; i++)
-            enqueueRowFilter(i);
+            m_frameFilter.processRow(i);
+        m_completionEvent.trigger();
     }
 }
 



More information about the x265-devel mailing list