[x265] [PATCH 2 of 2] Integrating computeRPS to encoder

shazeb at multicorewareinc.com shazeb at multicorewareinc.com
Tue Aug 27 11:11:19 CEST 2013


# HG changeset patch
# User Shazeb Nawaz Khan
# Date 1377594214 -19800
#      Tue Aug 27 14:33:34 2013 +0530
# Node ID bf72e539f3d8e25ff7fe1bc176ea1516c60a73d3
# Parent  5245113fa0d66de8933b18ca03fffde4f3fbdef0
Integrating computeRPS to encoder

diff -r 5245113fa0d6 -r bf72e539f3d8 source/encoder/dpb.cpp
--- a/source/encoder/dpb.cpp	Tue Aug 27 14:32:02 2013 +0530
+++ b/source/encoder/dpb.cpp	Tue Aug 27 14:33:34 2013 +0530
@@ -44,7 +44,6 @@
 void DPB::recycleUnreferenced(TComList<TComPic*>& freeList)
 {
     // move unreferenced pictures from picList to freeList for recycle
-    TComSlice::sortPicList(m_picList);
     TComList<TComPic*>::iterator iterPic = m_picList.begin();
     while (iterPic != m_picList.end())
     {
@@ -70,7 +69,7 @@
     int gopIdx = pic->m_lowres.gopIdx;
     int pocCurr = pic->getSlice()->getPOC();
     
-    m_picList.pushBack(pic);
+    m_picList.pushFront(pic);
     
     TComSlice* slice = pic->getSlice();
     if (getNalUnitType(pocCurr, m_lastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL ||
@@ -84,15 +83,8 @@
     {
         slice->setSliceType(P_SLICE);
     }
-    if (pocCurr == 0)
-    {
-        slice->setTemporalLayerNonReferenceFlag(false);
-    }
-    else
-    {
-        // m_refPic is true if this frame is used as a motion reference
-        slice->setTemporalLayerNonReferenceFlag(!m_cfg->getGOPEntry(gopIdx).m_refPic);
-    }
+    slice->setReferenced(slice->getSliceType() != B_SLICE);
+    slice->setTemporalLayerNonReferenceFlag(!slice->isReferenced());
 
     // Set the nal unit type
     slice->setNalUnitType(getNalUnitType(pocCurr, m_lastIDR));
@@ -115,21 +107,19 @@
 
     // Do decoding refresh marking if any
     slice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, m_picList);
-    selectReferencePictureSet(slice, frameEncoder, pocCurr, gopIdx);
-    slice->getRPS()->setNumberOfLongtermPictures(0);
+ 
+    computeRPS(pocCurr, slice->isIRAP(), slice->getLocalRPS(), /*slice->getSPS()->getMaxDecPicBuffering(0)*/ 1);
+    slice->setRPS(slice->getLocalRPS());                
+    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);
-    slice->setNumRefIdx(REF_PIC_LIST_0, min(m_cfg->getGOPEntry(gopIdx).m_numRefPicsActive, slice->getRPS()->getNumberOfPictures()));
-    slice->setNumRefIdx(REF_PIC_LIST_1, min(m_cfg->getGOPEntry(gopIdx).m_numRefPicsActive, slice->getRPS()->getNumberOfPictures()));
+    slice->setNumRefIdx(REF_PIC_LIST_0, X265_MIN(m_maxRefL0, slice->getRPS()->getNumberOfNegativePictures()));   // Ensuring L0 contains just the -ve POC
+    slice->setNumRefIdx(REF_PIC_LIST_1, X265_MIN(m_maxRefL1, slice->getRPS()->getNumberOfPositivePictures()));
 
     slice->setRefPicList(m_picList);
 
@@ -145,11 +135,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;
@@ -533,7 +525,7 @@
         /* encoder_randomaccess_main */
         int offsets[] = { 1, 2, 3, 4, 4, 3, 4, 4 };
         double factors[] = { 0, 0.442, 0.3536, 0.3536, 0.68 };
-        int pocs[] = { 8, 4, 2, 1, 3, 6, 5, 7 };
+        int pocs[] = { 1, 3, 2, 5, 4, 7, 6, 8};
         int rps[] = { 0, 4, 2, 1, -2, -3, 1, -2 };
         for (int i = 0; i < 8; i++)
         {
@@ -541,7 +533,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 = (pocs[i]%2)? '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 5245113fa0d6 -r bf72e539f3d8 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Tue Aug 27 14:32:02 2013 +0530
+++ b/source/encoder/frameencoder.cpp	Tue Aug 27 14:33:34 2013 +0530
@@ -109,7 +109,6 @@
     m_pps.setSPS(&m_sps);
 
     top->xInitPPS(&m_pps);
-    top->xInitRPS(&m_sps);
 
     m_sps.setNumLongTermRefPicSPS(0);
     if (m_cfg->getPictureTimingSEIEnabled() || m_cfg->getDecodingUnitInfoSEIEnabled())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-2.patch
Type: text/x-patch
Size: 5202 bytes
Desc: not available
URL: <https://mailman.videolan.org/private/x265-devel/attachments/20130827/d34ce32d/attachment.bin>


More information about the x265-devel mailing list