[x265] [PATCH REVIEW] Generate RPS from fixed GOP

shazeb at multicorewareinc.com shazeb at multicorewareinc.com
Thu Aug 22 09:23:08 CEST 2013


# HG changeset patch
# User Shazeb N Khan
# Date 1377156119 -19800
#      Thu Aug 22 12:51:59 2013 +0530
# Node ID 5024d1399ebc3cdfc3b325a7f927173b5e2b9147
# Parent  6fe2b6e1fd6f1c0ed0997a7dd0f0c38a96091f08
Generate RPS from fixed GOP

diff -r 6fe2b6e1fd6f -r 5024d1399ebc source/Lib/TLibCommon/TComSlice.h
--- a/source/Lib/TLibCommon/TComSlice.h	Tue Aug 20 08:22:45 2013 -0500
+++ b/source/Lib/TLibCommon/TComSlice.h	Thu Aug 22 12:51:59 2013 +0530
@@ -66,18 +66,13 @@
 {
 private:
 
-    Int  m_numberOfPictures;
-    Int  m_numberOfNegativePictures;
-    Int  m_numberOfPositivePictures;
-    Int  m_numberOfLongtermPictures;
-    Int  m_deltaPOC[MAX_NUM_REF_PICS];
-    Int  m_POC[MAX_NUM_REF_PICS];
-    Bool m_used[MAX_NUM_REF_PICS];
-    Bool m_interRPSPrediction;
+    // Parameters for inter RPS prediction
     Int  m_deltaRIdxMinus1;
     Int  m_deltaRPS;
     Int  m_numRefIdc;
     Int  m_refIdc[MAX_NUM_REF_PICS + 1];
+
+    // Parameters for long term references
     Bool m_bCheckLTMSB[MAX_NUM_REF_PICS];
     Int  m_pocLSBLT[MAX_NUM_REF_PICS];
     Int  m_deltaPOCMSBCycleLT[MAX_NUM_REF_PICS];
@@ -85,6 +80,17 @@
 
 public:
 
+    Int  m_numberOfPictures;
+    Int  m_numberOfNegativePictures;
+    Int  m_numberOfPositivePictures;
+    Int  m_deltaPOC[MAX_NUM_REF_PICS];
+    Bool m_used[MAX_NUM_REF_PICS];
+    Int  m_POC[MAX_NUM_REF_PICS];
+
+    Bool m_interRPSPrediction;
+    Int  m_numberOfLongtermPictures;          // Zero when disabled
+
+
     TComReferencePictureSet();
     virtual ~TComReferencePictureSet();
     Int   getPocLSBLT(Int i)                       { return m_pocLSBLT[i]; }
diff -r 6fe2b6e1fd6f -r 5024d1399ebc source/encoder/dpb.cpp
--- a/source/encoder/dpb.cpp	Tue Aug 20 08:22:45 2013 -0500
+++ b/source/encoder/dpb.cpp	Thu Aug 22 12:51:59 2013 +0530
@@ -31,6 +31,8 @@
 
 using namespace x265;
 
+#define MAX_REFD_BY_CUR 8
+
 DPB::~DPB()
 {
     while (!m_picList.empty())
@@ -44,7 +46,7 @@
 void DPB::recycleUnreferenced(TComList<TComPic*> freeList)
 {
     // move unreferenced pictures from picList to freeList for recycle
-    TComSlice::sortPicList(m_picList);
+    //TComSlice::sortPicList(m_picList);
     TComList<TComPic*>::iterator iterPic = m_picList.begin();
     while (iterPic != m_picList.end())
     {
@@ -71,7 +73,7 @@
     int pocCurr = pic->getSlice()->getPOC();
 
     Bool forceIntra = m_cfg->param.keyframeMax == 1 || (pocCurr % m_cfg->param.keyframeMax == 0) || pocCurr == 0;
-    m_picList.pushBack(pic);
+    m_picList.pushFront(pic);
     frameEncoder->initSlice(pic, forceIntra, gopIdx);
 
     TComSlice* slice = pic->getSlice();
@@ -90,10 +92,14 @@
     {
         slice->setTemporalLayerNonReferenceFlag(false);
     }
+    else if(slice->getSliceType() == B_SLICE)
+    {
+        slice->setReferenced(false);                          // Disallowing B frame from being referenced, unless the 'lookahead' intends to 
+        slice->setTemporalLayerNonReferenceFlag(true);
+    }
     else
     {
-        // m_refPic is true if this frame is used as a motion reference
-        slice->setTemporalLayerNonReferenceFlag(!m_cfg->getGOPEntry(gopIdx).m_refPic);
+        slice->setTemporalLayerNonReferenceFlag(false);
     }
 
     // Set the nal unit type
@@ -118,16 +124,15 @@
 
     // Do decoding refresh marking if any
     slice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, m_picList);
-    selectReferencePictureSet(slice, frameEncoder, pocCurr, gopIdx);
-    slice->getRPS()->setNumberOfLongtermPictures(0);
+ 
+    TComReferencePictureSet *rps = createRPS(pocCurr, slice->isIRAP());
+    slice->setRPS(rps);                
+    slice->setRPSidx(-1);              //   To force using RPS from slice, rather than from SPS
 
-    if ((slice->checkThatAllRefPicsAreAvailable(m_picList, slice->getRPS(), false) != 0) || (slice->isIRAP()))
-    {
-        slice->createExplicitReferencePictureSetFromReference(m_picList, slice->getRPS(), slice->isIRAP());
-    }
     slice->applyReferencePictureSet(m_picList, slice->getRPS());
 
     arrangeLongtermPicturesInRPS(slice, frameEncoder);
+    
     TComRefPicListModification* refPicListModification = slice->getRefPicListModification();
     refPicListModification->setRefPicListModificationFlagL0(false);
     refPicListModification->setRefPicListModificationFlagL1(false);
@@ -148,11 +153,13 @@
         //       what is setColFromL0Flag() for?
 
         // select colDir
+        TComReferencePictureSet *rps = slice->getRPS();
+
         UInt colDir = 1;
         int closeLeft = 1, closeRight = -1;
-        for (int i = 0; i < m_cfg->getGOPEntry(gopIdx).m_numRefPics; i++)
+        for (int i = 0; i < rps->m_numberOfPictures; i++)
         {
-            int ref = m_cfg->getGOPEntry(gopIdx).m_referencePics[i];
+            int ref = rps->m_deltaPOC[i];
             if (ref > 0 && (ref < closeRight || closeRight == -1))
             {
                 closeRight = ref;
@@ -246,6 +253,41 @@
     slice->setNextSlice(false);
 }
 
+TComReferencePictureSet * DPB::createRPS(int curPoc, bool isRAP)
+{
+    curPoc;
+    TComPic * refPic;
+    TComReferencePictureSet *rps = new TComReferencePictureSet();
+    int poci=0, numNeg=0, numPos=0;
+
+    TComList<TComPic*>::iterator iterPic = m_picList.begin();
+    while ((iterPic != m_picList.end())&&(poci<MAX_REFD_BY_CUR))
+    {
+        refPic = *(iterPic);
+        if ((refPic->getPOC() != curPoc)&&(refPic->getSlice()->isReferenced()))
+        {
+            rps->m_POC[poci] = refPic->getPOC();
+            rps->m_deltaPOC[poci] = rps->m_POC[poci] - curPoc;
+            (rps->m_deltaPOC[poci] < 0) ? numNeg++: numPos++;
+            rps->m_used[poci] = true && (!isRAP);
+            poci++;
+        }
+        iterPic++;
+    }
+
+    rps->m_numberOfPictures = poci;
+    rps->m_numberOfPositivePictures = numPos;
+    rps->m_numberOfNegativePictures = numNeg;
+    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
+
+    return(rps);
+}
+
+
+
 // This is a function that determines what Reference Picture Set to use for a
 // specific slice (with POC = POCCurr)
 void DPB::selectReferencePictureSet(TComSlice* slice, FrameEncoder *frameEncoder, int curPOC, int gopID)
@@ -514,7 +556,7 @@
             m_gopList[i].m_QPFactor = factors[offsets[i]];
             m_gopList[i].m_QPOffset = offsets[i];
             m_gopList[i].m_deltaRPS = rps[i];
-            m_gopList[i].m_sliceType = 'B';
+            m_gopList[i].m_sliceType = (i!=4)? 'P': 'B';
             m_gopList[i].m_numRefPicsActive = i ? 2 : 4;
             m_gopList[i].m_numRefPics = i == 1 ? 3 : 4;
             m_gopList[i].m_interRPSPrediction = i ? 1 : 0;
diff -r 6fe2b6e1fd6f -r 5024d1399ebc source/encoder/dpb.h
--- a/source/encoder/dpb.h	Tue Aug 20 08:22:45 2013 -0500
+++ b/source/encoder/dpb.h	Thu Aug 22 12:51:59 2013 +0530
@@ -62,6 +62,8 @@
 
     void selectReferencePictureSet(TComSlice* slice, x265::FrameEncoder*, int curPoc, int gopID);
 
+    TComReferencePictureSet * createRPS(int curPoc, bool isRAP);
+
     int getReferencePictureSetIdxForSOP(int pocCur, int GOPid);
 
     void arrangeLongtermPicturesInRPS(TComSlice *, x265::FrameEncoder *frameEncoder);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265.patch
Type: text/x-patch
Size: 7333 bytes
Desc: not available
URL: <https://mailman.videolan.org/private/x265-devel/attachments/20130822/1466e396/attachment.bin>


More information about the x265-devel mailing list