[x265] [PATCH] framepp: move frame col flag to Pic

Min Chen chenm003 at 163.com
Tue Aug 6 09:52:01 CEST 2013


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1375775473 -28800
# Node ID 63e27ab4b6371a565deabea6b08d33c9718d9f9c
# Parent  4c49a45a5ce9321d9ac65f2c52ebbd0f50b12275
framepp: move frame col flag to Pic

diff -r 4c49a45a5ce9 -r 63e27ab4b637 source/Lib/TLibCommon/TComPic.cpp
--- a/source/Lib/TLibCommon/TComPic.cpp	Tue Aug 06 11:47:17 2013 +0800
+++ b/source/Lib/TLibCommon/TComPic.cpp	Tue Aug 06 15:51:13 2013 +0800
@@ -55,6 +55,7 @@
     , m_bUsedByCurr(false)
     , m_bIsLongTerm(false)
     , m_bCheckLTMSB(false)
+    , m_complete_enc(NULL)
 {}
 
 TComPic::~TComPic()
@@ -120,6 +121,9 @@
             m_lowres.lowresMvs[y][x][0] = 0x7FFF;
         }
     }
+
+    int numRows = (height + maxHeight - 1) / maxHeight;
+    m_complete_enc = new uint32_t[numRows]; // initial in FrameEncoder::encode()
 }
 
 Void TComPic::destroy()
@@ -162,6 +166,11 @@
                 X265_FREE(m_lowres.lowresMvs[i][j]);
         }
     }
+
+    if (m_complete_enc)
+    {
+        delete[] m_complete_enc;
+    }
 }
 
 Void TComPic::compressMotion()
diff -r 4c49a45a5ce9 -r 63e27ab4b637 source/Lib/TLibCommon/TComPic.h
--- a/source/Lib/TLibCommon/TComPic.h	Tue Aug 06 11:47:17 2013 +0800
+++ b/source/Lib/TLibCommon/TComPic.h	Tue Aug 06 15:51:13 2013 +0800
@@ -70,6 +70,7 @@
 
 public:
 
+    volatile uint32_t     *m_complete_enc;       // Array of Col number that was finished stage encode
     x265::LookaheadFrame  m_lowres;
 
     TComPic();
diff -r 4c49a45a5ce9 -r 63e27ab4b637 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Tue Aug 06 11:47:17 2013 +0800
+++ b/source/encoder/frameencoder.cpp	Tue Aug 06 15:51:13 2013 +0800
@@ -207,6 +207,7 @@
         m_rows[i].m_entropyCoder.setEntropyCoder(&m_sbacCoder, m_slice);
         m_rows[i].m_entropyCoder.resetEntropy();
         m_rows[i].m_rdSbacCoders[0][CI_CURR_BEST]->load(&m_sbacCoder);
+        m_pic->m_complete_enc[i] = 0;
     }
 
     if (!m_pool || !m_cfg->param.bEnableWavefront)
@@ -238,7 +239,7 @@
 
     const uint32_t numCols = m_pic->getPicSym()->getFrameWidthInCU();
     const uint32_t lineStartCUAddr = row * numCols;
-    for (UInt col = curRow.m_curCol; col < numCols; col++)
+    for (UInt col = m_pic->m_complete_enc[row]; col < numCols; col++)
     {
         const uint32_t cuAddr = lineStartCUAddr + col;
         TComDataCU* cu = m_pic->getCU(cuAddr);
@@ -256,13 +257,13 @@
         // cu->m_totalDistortion;
 
         // Completed CU processing
-        curRow.m_curCol++;
+        m_pic->m_complete_enc[row]++;
 
-        if (curRow.m_curCol >= 2 && row < m_numRows - 1)
+        if (m_pic->m_complete_enc[row] >= 2 && row < m_numRows - 1)
         {
             ScopedLock below(m_rows[row + 1].m_lock);
             if (m_rows[row + 1].m_active == false &&
-                m_rows[row + 1].m_curCol + 2 <= curRow.m_curCol)
+                m_pic->m_complete_enc[row + 1] + 2 <= m_pic->m_complete_enc[row])
             {
                 m_rows[row + 1].m_active = true;
                 WaveFront::enqueueRow(row + 1);
@@ -270,7 +271,7 @@
         }
 
         ScopedLock self(curRow.m_lock);
-        if (row > 0 && curRow.m_curCol < numCols - 1 && m_rows[row - 1].m_curCol < curRow.m_curCol + 2)
+        if (row > 0 && m_pic->m_complete_enc[row] < numCols - 1 && m_pic->m_complete_enc[row - 1] < m_pic->m_complete_enc[row] + 2)
         {
             curRow.m_active = false;
             return;
diff -r 4c49a45a5ce9 -r 63e27ab4b637 source/encoder/frameencoder.h
--- a/source/encoder/frameencoder.h	Tue Aug 06 11:47:17 2013 +0800
+++ b/source/encoder/frameencoder.h	Tue Aug 06 15:51:13 2013 +0800
@@ -63,7 +63,6 @@
     void init()
     {
         m_active = 0;
-        m_curCol = 0;
     }
 
     inline void processCU(TComDataCU *cu, TComSlice *slice, TEncSbac *bufferSBac, bool bSaveCabac);
@@ -71,7 +70,6 @@
     /* Threading */
     Lock                m_lock;
     volatile bool       m_active;
-    volatile uint32_t   m_curCol;
 };
 
 // Manages the wave-front processing of a single encoding frame



More information about the x265-devel mailing list