[x265] [PATCH] dpb and tcomslice:removed TComList(std::list) and used PicList to store the TComPic's

Gopu Govindaswamy gopu at multicorewareinc.com
Wed Oct 9 12:50:29 CEST 2013


# HG changeset patch
# User Gopu Govindaswamy <gopu at multicorewareinc.com>
# Date 1381315815 -19800
# Node ID afe7ce0856a14f2144ff863800ed4ea1bbad736c
# Parent  8348e1f887c0415b57430eddd7cbaef1826b52e7
dpb and tcomslice:removed TComList(std::list) and used PicList to store the TComPic's

diff -r 8348e1f887c0 -r afe7ce0856a1 source/Lib/TLibCommon/TComSlice.cpp
--- a/source/Lib/TLibCommon/TComSlice.cpp	Wed Oct 09 11:00:47 2013 +0530
+++ b/source/Lib/TLibCommon/TComSlice.cpp	Wed Oct 09 16:20:15 2013 +0530
@@ -153,28 +153,28 @@
     m_substreamSizes = new UInt[numSubstreams > 0 ? numSubstreams - 1 : 0];
 }
 
-TComPic* TComSlice::xGetRefPic(TComList<TComPic*>& picList, int poc)
+TComPic* TComSlice::xGetRefPic(PicList& picList, int poc)
 {
-    TComList<TComPic*>::iterator iterPic = picList.begin();
+    TComPic *iterPic = picList.first();
     TComPic* pic = NULL;
 
-    while (iterPic != picList.end())
+    while (iterPic)
     {
-        pic = *iterPic;
+        pic = iterPic;
         if (pic->getPOC() == poc)
         {
             break;
         }
-        iterPic++;
+        iterPic = iterPic->m_next;
     }
 
     return pic;
 }
 
-TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& picList, int poc, bool pocHasMsb)
+TComPic* TComSlice::xGetLongTermRefPic(PicList& picList, int poc, bool pocHasMsb)
 {
-    TComList<TComPic*>::iterator  iterPic = picList.begin();
-    TComPic* pic = *(iterPic);
+    TComPic* iterPic = picList.first();
+    TComPic* pic = iterPic;
     TComPic* stPic = pic;
 
     int pocCycle = 1 << getSPS()->getBitsForPOC();
@@ -183,9 +183,9 @@
         poc = poc % pocCycle;
     }
 
-    while (iterPic != picList.end())
+    while (iterPic)
     {
-        pic = *(iterPic);
+        pic = iterPic;
         if (pic && pic->getPOC() != this->getPOC() && pic->getSlice()->isReferenced())
         {
             int picPoc = pic->getPOC();
@@ -208,7 +208,7 @@
             }
         }
 
-        iterPic++;
+        iterPic = iterPic->m_next;
     }
 
     return stPic;
@@ -243,7 +243,7 @@
     }
 }
 
-void TComSlice::setRefPicList(TComList<TComPic*>& picList, bool checkNumPocTotalCurr)
+void TComSlice::setRefPicList(PicList& picList, bool checkNumPocTotalCurr)
 {
     if (!checkNumPocTotalCurr)
     {
diff -r 8348e1f887c0 -r afe7ce0856a1 source/Lib/TLibCommon/TComSlice.h
--- a/source/Lib/TLibCommon/TComSlice.h	Wed Oct 09 11:00:47 2013 +0530
+++ b/source/Lib/TLibCommon/TComSlice.h	Wed Oct 09 16:20:15 2013 +0530
@@ -43,6 +43,7 @@
 #include "TComList.h"
 #include "x265.h"  // NAL type enums
 #include "reference.h"
+#include "piclist.h"
 
 #include <cstring>
 #include <map>
@@ -1584,7 +1585,7 @@
 
     void      setPic(TComPic* p)                  { m_pic = p; }
 
-    void      setRefPicList(TComList<TComPic*>& picList, bool checkNumPocTotalCurr = false);
+    void      setRefPicList(PicList& picList, bool checkNumPocTotalCurr = false);
 
     void      setRefPOCList();
 
@@ -1690,9 +1691,9 @@
 
 protected:
 
-    TComPic*  xGetRefPic(TComList<TComPic*>& picList, int poc);
-
-    TComPic*  xGetLongTermRefPic(TComList<TComPic*>& picList, int poc, bool pocHasMsb);
+    TComPic*  xGetRefPic(PicList& picList, int poc);
+
+    TComPic*  xGetLongTermRefPic(PicList& picList, int poc, bool pocHasMsb);
 }; // END CLASS DEFINITION TComSlice
 
 template<class T>
diff -r 8348e1f887c0 -r afe7ce0856a1 source/Lib/TLibEncoder/TEncTop.h
--- a/source/Lib/TLibEncoder/TEncTop.h	Wed Oct 09 11:00:47 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncTop.h	Wed Oct 09 16:20:15 2013 +0530
@@ -68,7 +68,7 @@
 private:
 
     int                m_pocLast;          ///< time index (POC)
-    TComList<TComPic*> m_freeList;
+    PicList m_freeList;
 
     ThreadPool*        m_threadPool;
     Lookahead*         m_lookahead;
diff -r 8348e1f887c0 -r afe7ce0856a1 source/encoder/dpb.cpp
--- a/source/encoder/dpb.cpp	Wed Oct 09 11:00:47 2013 +0530
+++ b/source/encoder/dpb.cpp	Wed Oct 09 16:20:15 2013 +0530
@@ -42,22 +42,23 @@
 }
 
 // move unreferenced pictures from picList to freeList for recycle
-void DPB::recycleUnreferenced(TComList<TComPic*>& freeList)
+void DPB::recycleUnreferenced(PicList& freeList)
 {
-    TComList<TComPic*>::iterator iterPic = m_picList.begin();
-    while (iterPic != m_picList.end())
+    TComPic *iterPic = m_picList.first();
+    while (iterPic)
     {
-        TComPic *pic = *(iterPic++);
+        TComPic *pic = iterPic;
+        iterPic = iterPic->m_next;
         if (pic->getSlice()->isReferenced() == false && pic->m_countRefEncoders == 0)
         {
             pic->getPicYuvRec()->clearReferences();
             pic->m_reconRowCount = 0;
 
             // iterator is invalidated by remove, restart scan
-            m_picList.remove(pic);
-            iterPic = m_picList.begin();
+            m_picList.remove(*pic);
+            iterPic = m_picList.first();
 
-            freeList.pushBack(pic);
+            freeList.pushBack(*pic);
         }
     }
 }
@@ -68,7 +69,7 @@
 
     int pocCurr = pic->getSlice()->getPOC();
 
-    m_picList.pushFront(pic);
+    m_picList.pushFront(*pic);
 
     TComSlice* slice = pic->getSlice();
     if (getNalUnitType(pocCurr, m_lastIDR, pic) == NAL_UNIT_CODED_SLICE_IDR_W_RADL ||
@@ -198,22 +199,20 @@
 
 void DPB::computeRPS(int curPoc, bool isRAP, TComReferencePictureSet * rps, unsigned int maxDecPicBuffer)
 {
-    TComPic * refPic;
     unsigned int poci = 0, numNeg = 0, numPos = 0;
 
-    TComList<TComPic*>::iterator iterPic = m_picList.begin();
-    while ((iterPic != m_picList.end()) && (poci < maxDecPicBuffer - 1))
+    TComPic* iterPic = m_picList.first();
+    while (iterPic && (poci < maxDecPicBuffer - 1))
     {
-        refPic = *(iterPic);
-        if ((refPic->getPOC() != curPoc) && (refPic->getSlice()->isReferenced()))
+        if ((iterPic->getPOC() != curPoc) && (iterPic->getSlice()->isReferenced()))
         {
-            rps->m_POC[poci] = refPic->getPOC();
+            rps->m_POC[poci] = iterPic->getPOC();
             rps->m_deltaPOC[poci] = rps->m_POC[poci] - curPoc;
             (rps->m_deltaPOC[poci] < 0) ? numNeg++ : numPos++;
             rps->m_used[poci] = !isRAP;
             poci++;
         }
-        iterPic++;
+        iterPic = iterPic->m_next;
     }
 
     rps->m_numberOfPictures = poci;
@@ -245,7 +244,6 @@
  */
 void DPB::decodingRefreshMarking(int pocCurr, NalUnitType nalUnitType)
 {
-    TComPic* outPic;
 
     if (nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP
         || nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
@@ -254,13 +252,12 @@
         || nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP) // IDR or BLA picture
     {
         // mark all pictures as not used for reference
-        TComList<TComPic*>::iterator iterPic = m_picList.begin();
-        while (iterPic != m_picList.end())
+        TComPic* iterPic = m_picList.first();
+        while (iterPic)
         {
-            outPic = *(iterPic);
-            if (outPic->getPOC() != pocCurr)
-                outPic->getSlice()->setReferenced(false);
-            iterPic++;
+            if (iterPic->getPOC() != pocCurr)
+                iterPic->getSlice()->setReferenced(false);
+            iterPic = iterPic->m_next;
         }
 
         if (nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP
@@ -274,13 +271,12 @@
     {
         if (m_bRefreshPending == true && pocCurr > m_pocCRA) // CRA reference marking pending
         {
-            TComList<TComPic*>::iterator iterPic = m_picList.begin();
-            while (iterPic != m_picList.end())
+            TComPic* iterPic = m_picList.first();
+            while (iterPic)
             {
-                outPic = *(iterPic);
-                if (outPic->getPOC() != pocCurr && outPic->getPOC() != m_pocCRA)
-                    outPic->getSlice()->setReferenced(false);
-                iterPic++;
+                if (iterPic->getPOC() != pocCurr && iterPic->getPOC() != m_pocCRA)
+                    iterPic->getSlice()->setReferenced(false);
+                iterPic = iterPic->m_next;
             }
 
             m_bRefreshPending = false;
@@ -300,10 +296,11 @@
     int i, isReference;
 
     // loop through all pictures in the reference picture buffer
-    TComList<TComPic*>::iterator iterPic = m_picList.begin();
-    while (iterPic != m_picList.end())
+    TComPic* iterPic = m_picList.first();
+    while (iterPic)
     {
-        outPic = *(iterPic++);
+        outPic = iterPic;
+        iterPic = iterPic->m_next;
 
         if (!outPic->getSlice()->isReferenced())
         {
@@ -475,19 +472,17 @@
     {
         // Check if MSB present flag should be enabled.
         // Check if the buffer contains any pictures that have the same LSB.
-        TComList<TComPic*>::iterator iterPic = m_picList.begin();
-        TComPic* pic;
-        while (iterPic != m_picList.end())
+        TComPic* iterPic = m_picList.first();
+        while (iterPic)
         {
-            pic = *iterPic;
-            if ((getLSB(pic->getPOC(), maxPicOrderCntLSB) == longtermPicsLSB[i])   && // Same LSB
-                (pic->getSlice()->isReferenced()) &&                                  // Reference picture
-                (pic->getPOC() != longtermPicsPoc[i]))                                // Not the LTRP itself
+            if ((getLSB(iterPic->getPOC(), maxPicOrderCntLSB) == longtermPicsLSB[i])   && // Same LSB
+                (iterPic->getSlice()->isReferenced()) &&                                  // Reference picture
+                (iterPic->getPOC() != longtermPicsPoc[i]))                                // Not the LTRP itself
             {
                 mSBPresentFlag[i] = true;
                 break;
             }
-            iterPic++;
+            iterPic = iterPic->m_next;
         }
     }
 
diff -r 8348e1f887c0 -r afe7ce0856a1 source/encoder/dpb.h
--- a/source/encoder/dpb.h	Wed Oct 09 11:00:47 2013 +0530
+++ b/source/encoder/dpb.h	Wed Oct 09 16:20:15 2013 +0530
@@ -24,7 +24,7 @@
 #ifndef X265_DPB_H
 #define X265_DPB_H
 
-#include "TLibCommon/TComList.h"
+#include "common/piclist.h"
 
 namespace x265 {
 // private namespace for x265
@@ -42,7 +42,7 @@
     int                m_pocCRA;
     bool               m_bRefreshPending;
     TEncCfg*           m_cfg;
-    TComList<TComPic*> m_picList;
+    PicList m_picList;
     int                m_maxRefL0;
     int                m_maxRefL1;
 
@@ -60,7 +60,7 @@
 
     void prepareEncode(TComPic*);
 
-    void recycleUnreferenced(TComList<TComPic*>& freeList);
+    void recycleUnreferenced(PicList& freeList);
 
 protected:
 


More information about the x265-devel mailing list