[x265] [PATCH 1 of 3] Move dpb related functions from TComSlice to DPB

deepthidevaki at multicorewareinc.com deepthidevaki at multicorewareinc.com
Wed Aug 28 14:36:45 CEST 2013


# HG changeset patch
# User Deepthi Devaki <deepthidevaki at multicorewareinc.com>
# Date 1377692688 -19800
# Node ID 8af396af3c75d5420c959b1c827248606377237e
# Parent  bdb54195f558ef4886f9ff8e7a5dc74b520707ba
Move dpb related functions from TComSlice to DPB

diff -r bdb54195f558 -r 8af396af3c75 source/Lib/TLibCommon/TComSlice.cpp
--- a/source/Lib/TLibCommon/TComSlice.cpp	Wed Aug 28 16:38:51 2013 +0530
+++ b/source/Lib/TLibCommon/TComSlice.cpp	Wed Aug 28 17:54:48 2013 +0530
@@ -521,75 +521,6 @@
     }
 }
 
-/** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered.
- * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture
- * \param bRefreshPending flag indicating if a deferred decoding refresh is pending
- * \param picList reference to the reference picture list
- * This function marks the reference pictures as "unused for reference" in the following conditions.
- * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list
- * are marked as "unused for reference"
- *    If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture.
- * Otherwise
- *    If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current
- *    temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA),
- *    mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set
- *    the bRefreshPending flag to false.
- *    If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal
- *    reference of the current picture.
- * Note that the current picture is already placed in the reference list and its marking is not changed.
- * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference".
- */
-Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& picList)
-{
-    TComPic* outPic;
-    Int pocCurr = getPOC();
-
-    if (getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
-        || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
-        || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
-        || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
-        || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP) // IDR or BLA picture
-    {
-        // mark all pictures as not used for reference
-        TComList<TComPic*>::iterator iterPic = picList.begin();
-        while (iterPic != picList.end())
-        {
-            outPic = *(iterPic);
-            if (outPic->getPOC() != pocCurr)
-                outPic->getSlice()->setReferenced(false);
-            iterPic++;
-        }
-
-        if (getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
-            || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
-            || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP)
-        {
-            pocCRA = pocCurr;
-        }
-    }
-    else // CRA or No DR
-    {
-        if (bRefreshPending == true && pocCurr > pocCRA) // CRA reference marking pending
-        {
-            TComList<TComPic*>::iterator iterPic = picList.begin();
-            while (iterPic != picList.end())
-            {
-                outPic = *(iterPic);
-                if (outPic->getPOC() != pocCurr && outPic->getPOC() != pocCRA)
-                    outPic->getSlice()->setReferenced(false);
-                iterPic++;
-            }
-
-            bRefreshPending = false;
-        }
-        if (getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) // CRA picture found
-        {
-            bRefreshPending = true;
-            pocCRA = pocCurr;
-        }
-    }
-}
-
 Void TComSlice::copySliceInfo(TComSlice *src)
 {
     assert(src != NULL);
@@ -685,74 +616,6 @@
     m_maxNumMergeCand = src->m_maxNumMergeCand;
 }
 
-/** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet */
-Void TComSlice::applyReferencePictureSet(TComList<TComPic*>& picList, TComReferencePictureSet *rps)
-{
-    TComPic* outPic;
-    Int i, isReference;
-
-    // loop through all pictures in the reference picture buffer
-    TComList<TComPic*>::iterator iterPic = picList.begin();
-    while (iterPic != picList.end())
-    {
-        outPic = *(iterPic++);
-
-        if (!outPic->getSlice()->isReferenced())
-        {
-            continue;
-        }
-
-        isReference = 0;
-        // loop through all pictures in the Reference Picture Set
-        // to see if the picture should be kept as reference picture
-        for (i = 0; i < rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures(); i++)
-        {
-            if (!outPic->getIsLongTerm() && outPic->getPicSym()->getSlice()->getPOC() == this->getPOC() + rps->getDeltaPOC(i))
-            {
-                isReference = 1;
-                outPic->setUsedByCurr(rps->getUsed(i));
-                outPic->setIsLongTerm(0);
-            }
-        }
-
-        for (; i < rps->getNumberOfPictures(); i++)
-        {
-            if (rps->getCheckLTMSBPresent(i) == true)
-            {
-                if (outPic->getIsLongTerm() && (outPic->getPicSym()->getSlice()->getPOC()) == rps->getPOC(i))
-                {
-                    isReference = 1;
-                    outPic->setUsedByCurr(rps->getUsed(i));
-                }
-            }
-            else
-            {
-                if (outPic->getIsLongTerm() && (outPic->getPicSym()->getSlice()->getPOC() %
-                                                (1 << outPic->getPicSym()->getSlice()->getSPS()->getBitsForPOC())) == rps->getPOC(i) %
-                                                (1 << outPic->getPicSym()->getSlice()->getSPS()->getBitsForPOC()))
-                {
-                    isReference = 1;
-                    outPic->setUsedByCurr(rps->getUsed(i));
-                }
-            }
-        }
-
-        // mark the picture as "unused for reference" if it is not in
-        // the Reference Picture Set
-        if (outPic->getPicSym()->getSlice()->getPOC() != this->getPOC() && isReference == 0)
-        {
-            outPic->getSlice()->setReferenced(false);
-            outPic->setUsedByCurr(0);
-            outPic->setIsLongTerm(0);
-        }
-        // check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture
-        if (this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N)
-        {
-            assert(outPic->getSlice()->isReferenced() == 0);
-        }
-    }
-}
-
 /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet.
 */
 Int TComSlice::checkThatAllRefPicsAreAvailable(TComList<TComPic*>& picList, TComReferencePictureSet *rps, Bool printErrors, Int pocRandomAccess)
diff -r bdb54195f558 -r 8af396af3c75 source/Lib/TLibCommon/TComSlice.h
--- a/source/Lib/TLibCommon/TComSlice.h	Wed Aug 28 16:38:51 2013 +0530
+++ b/source/Lib/TLibCommon/TComSlice.h	Wed Aug 28 17:54:48 2013 +0530
@@ -1556,8 +1556,6 @@
 
     Void      checkCRA(TComReferencePictureSet *rps, Int& pocCRA, Bool& prevRAPisBLA);
 
-    Void      decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& picList);
-
     Void      setSliceType(SliceType e)               { m_sliceType = e; }
 
     Void      setSliceQp(Int i)                       { m_sliceQp = i; }
@@ -1631,7 +1629,6 @@
 
     Void setTLayerInfo(UInt tlayer);
     Void decodingMarking(TComList<TComPic*>& picList, Int gopSize, Int& maxRefPicNum);
-    Void applyReferencePictureSet(TComList<TComPic*>& picList, TComReferencePictureSet *rps);
     Int  checkThatAllRefPicsAreAvailable(TComList<TComPic*>& picList, TComReferencePictureSet *rps, Bool printErrors, Int pocRandomAccess = 0);
     Void createExplicitReferencePictureSetFromReference(TComList<TComPic*>& picList, TComReferencePictureSet *rps, Bool isRAP);
 
diff -r bdb54195f558 -r 8af396af3c75 source/encoder/dpb.cpp
--- a/source/encoder/dpb.cpp	Wed Aug 28 16:38:51 2013 +0530
+++ b/source/encoder/dpb.cpp	Wed Aug 28 17:54:48 2013 +0530
@@ -106,13 +106,13 @@
     }
 
     // Do decoding refresh marking if any
-    slice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, m_picList);
- 
+    decodingRefreshMarking(pocCurr, slice->getNalUnitType());
+
     computeRPS(pocCurr, slice->isIRAP(), slice->getLocalRPS(), slice->getSPS()->getMaxDecPicBuffering(0));
     slice->setRPS(slice->getLocalRPS());                
     slice->setRPSidx(-1);              //   To force using RPS from slice, rather than from SPS
 
-    slice->applyReferencePictureSet(m_picList, slice->getRPS());
+    applyReferencePictureSet(slice->getRPS(), pocCurr); // Mark pictures in m_piclist as unreferenced if they are not included in RPS
 
     arrangeLongtermPicturesInRPS(slice, frameEncoder);
     TComRefPicListModification* refPicListModification = slice->getRefPicListModification();
@@ -261,7 +261,145 @@
     rps->m_numberOfLongtermPictures = 0;
     rps->m_interRPSPrediction = false;          // To be changed later when needed
 
-    rps->sortDeltaPOC();                        // TO DO: check whether entire process of sorting is needed here
+    rps->sortDeltaPOC();
+}
+
+/** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered.
+ * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture
+ * \param bRefreshPending flag indicating if a deferred decoding refresh is pending
+ * \param picList reference to the reference picture list
+ * This function marks the reference pictures as "unused for reference" in the following conditions.
+ * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list
+ * are marked as "unused for reference"
+ *    If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture.
+ * Otherwise
+ *    If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current
+ *    temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA),
+ *    mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set
+ *    the bRefreshPending flag to false.
+ *    If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal
+ *    reference of the current picture.
+ * Note that the current picture is already placed in the reference list and its marking is not changed.
+ * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference".
+ */
+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
+        || nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
+        || nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
+        || 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())
+        {
+            outPic = *(iterPic);
+            if (outPic->getPOC() != pocCurr)
+                outPic->getSlice()->setReferenced(false);
+            iterPic++;
+        }
+
+        if (nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP
+            || nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
+            || nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP)
+        {
+            m_pocCRA = pocCurr;
+        }
+    }
+    else // CRA or No DR
+    {
+        if (m_bRefreshPending == true && pocCurr > m_pocCRA) // CRA reference marking pending
+        {
+            TComList<TComPic*>::iterator iterPic = m_picList.begin();
+            while (iterPic != m_picList.end())
+            {
+                outPic = *(iterPic);
+                if (outPic->getPOC() != pocCurr && outPic->getPOC() != m_pocCRA)
+                    outPic->getSlice()->setReferenced(false);
+                iterPic++;
+            }
+
+            m_bRefreshPending = false;
+        }
+        if (nalUnitType == NAL_UNIT_CODED_SLICE_CRA) // CRA picture found
+        {
+            m_bRefreshPending = true;
+            m_pocCRA = pocCurr;
+        }
+    }
+}
+
+/** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet */
+Void DPB::applyReferencePictureSet(TComReferencePictureSet *rps, int curPoc)
+{
+    TComPic* outPic;
+    Int i, isReference;
+
+    // loop through all pictures in the reference picture buffer
+    TComList<TComPic*>::iterator iterPic = m_picList.begin();
+    while (iterPic != m_picList.end())
+    {
+        outPic = *(iterPic++);
+
+        if (!outPic->getSlice()->isReferenced())
+        {
+            continue;
+        }
+
+        isReference = 0;
+        // loop through all pictures in the Reference Picture Set
+        // to see if the picture should be kept as reference picture
+        for (i = 0; i < rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures(); i++)
+        {
+            if (!outPic->getIsLongTerm() && outPic->getPicSym()->getSlice()->getPOC() == curPoc + rps->getDeltaPOC(i))
+            {
+                isReference = 1;
+                outPic->setUsedByCurr(rps->getUsed(i) == 1);
+                outPic->setIsLongTerm(0);
+            }
+        }
+
+        for (; i < rps->getNumberOfPictures(); i++)
+        {
+            if (rps->getCheckLTMSBPresent(i) == true)
+            {
+                if (outPic->getIsLongTerm() && (outPic->getPicSym()->getSlice()->getPOC()) == rps->getPOC(i))
+                {
+                    isReference = 1;
+                    outPic->setUsedByCurr(rps->getUsed(i) == 1);
+                }
+            }
+            else
+            {
+                if (outPic->getIsLongTerm() && (outPic->getPicSym()->getSlice()->getPOC() %
+                                                (1 << outPic->getPicSym()->getSlice()->getSPS()->getBitsForPOC())) == rps->getPOC(i) %
+                    (1 << outPic->getPicSym()->getSlice()->getSPS()->getBitsForPOC()))
+                {
+                    isReference = 1;
+                    outPic->setUsedByCurr(rps->getUsed(i) == 1);
+                }
+            }
+        }
+
+        // mark the picture as "unused for reference" if it is not in
+        // the Reference Picture Set
+        if (outPic->getPicSym()->getSlice()->getPOC() != curPoc && isReference == 0)
+        {
+            outPic->getSlice()->setReferenced(false);
+            outPic->setUsedByCurr(0);
+            outPic->setIsLongTerm(0);
+        }
+        // TODO: Do we require this check here
+        // check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture
+
+        /*if (this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N)
+        {
+            assert(outPic->getSlice()->isReferenced() == 0);
+        }*/
+    }
 }
 
 // This is a function that determines what Reference Picture Set to use for a
diff -r bdb54195f558 -r 8af396af3c75 source/encoder/dpb.h
--- a/source/encoder/dpb.h	Wed Aug 28 16:38:51 2013 +0530
+++ b/source/encoder/dpb.h	Wed Aug 28 17:54:48 2013 +0530
@@ -68,6 +68,9 @@
 
     void computeRPS(int curPoc, bool isRAP, TComReferencePictureSet * rps, unsigned int maxDecPicBuffer);
 
+    Void applyReferencePictureSet(TComReferencePictureSet *rps, int curPoc);
+    Void decodingRefreshMarking(Int pocCurr, NalUnitType nalUnitType);
+
     int getReferencePictureSetIdxForSOP(int pocCur, int GOPid);
 
     void arrangeLongtermPicturesInRPS(TComSlice *, x265::FrameEncoder *frameEncoder);


More information about the x265-devel mailing list