[x265] [PATCH 3 of 3] Remove unused code related to dpb and rps

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


# HG changeset patch
# User Deepthi Devaki <deepthidevaki at multicorewareinc.com>
# Date 1377693353 -19800
# Node ID 534d319b3c2256a3337fe660c1667bcbb609c202
# Parent  1217ba050142a500de0f817bd550cd6c94eee4d6
Remove unused code related to dpb and rps

diff -r 1217ba050142 -r 534d319b3c22 source/Lib/TLibEncoder/TEncTop.cpp
--- a/source/Lib/TLibEncoder/TEncTop.cpp	Wed Aug 28 17:58:24 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncTop.cpp	Wed Aug 28 18:05:53 2013 +0530
@@ -840,140 +840,6 @@
     pcPPS->setLoopFilterAcrossTilesEnabledFlag(m_loopFilterAcrossTilesEnabledFlag);
 }
 
-//Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file.
-Void TEncTop::xInitRPS(TComSPS *pcSPS)
-{
-    TComReferencePictureSet* rps;
-
-    pcSPS->createRPSList(getGOPSize() + m_extraRPSs);
-    TComRPSList* rpsList = pcSPS->getRPSList();
-
-    for (Int i = 0; i < getGOPSize() + m_extraRPSs; i++)
-    {
-        GOPEntry ge = getGOPEntry(i);
-        rps = rpsList->getReferencePictureSet(i);
-        rps->setNumberOfPictures(ge.m_numRefPics);
-        rps->setNumRefIdc(ge.m_numRefIdc);
-        Int numNeg = 0;
-        Int numPos = 0;
-        for (Int j = 0; j < ge.m_numRefPics; j++)
-        {
-            rps->setDeltaPOC(j, ge.m_referencePics[j]);
-            rps->setUsed(j, ge.m_usedByCurrPic[j]);
-            if (ge.m_referencePics[j] > 0)
-            {
-                numPos++;
-            }
-            else
-            {
-                numNeg++;
-            }
-        }
-
-        rps->setNumberOfNegativePictures(numNeg);
-        rps->setNumberOfPositivePictures(numPos);
-
-        // handle inter RPS initialization from the config file.
-        rps->setInterRPSPrediction(ge.m_interRPSPrediction > 0); // not very clean, converting anything > 0 to true.
-        rps->setDeltaRIdxMinus1(0);                              // index to the Reference RPS is always the previous one.
-        TComReferencePictureSet* RPSRef = rpsList->getReferencePictureSet(i - 1); // get the reference RPS
-
-        if (ge.m_interRPSPrediction == 2) // Automatic generation of the inter RPS idc based on the RIdx provided.
-        {
-            Int deltaRPS = getGOPEntry(i - 1).m_POC - ge.m_POC; // the ref POC - current POC
-            Int numRefDeltaPOC = RPSRef->getNumberOfPictures();
-
-            rps->setDeltaRPS(deltaRPS);     // set delta RPS
-            rps->setNumRefIdc(numRefDeltaPOC + 1); // set the numRefIdc to the number of pictures in the reference RPS + 1.
-            Int count = 0;
-            for (Int j = 0; j <= numRefDeltaPOC; j++) // cycle through pics in reference RPS.
-            {
-                Int RefDeltaPOC = (j < numRefDeltaPOC) ? RPSRef->getDeltaPOC(j) : 0; // if it is the last decoded picture, set RefDeltaPOC = 0
-                rps->setRefIdc(j, 0);
-                for (Int k = 0; k < rps->getNumberOfPictures(); k++) // cycle through pics in current RPS.
-                {
-                    if (rps->getDeltaPOC(k) == (RefDeltaPOC + deltaRPS)) // if the current RPS has a same picture as the reference RPS.
-                    {
-                        rps->setRefIdc(j, (rps->getUsed(k) ? 1 : 2));
-                        count++;
-                        break;
-                    }
-                }
-            }
-
-            if (count != rps->getNumberOfPictures())
-            {
-                printf("Warning: Unable fully predict all delta POCs using the reference RPS index given in the config file.  Setting Inter RPS to false for this RPS.\n");
-                rps->setInterRPSPrediction(0);
-            }
-        }
-        else if (ge.m_interRPSPrediction == 1) // inter RPS idc based on the RefIdc values provided in config file.
-        {
-            rps->setDeltaRPS(ge.m_deltaRPS);
-            rps->setNumRefIdc(ge.m_numRefIdc);
-            for (Int j = 0; j < ge.m_numRefIdc; j++)
-            {
-                rps->setRefIdc(j, ge.m_refIdc[j]);
-            }
-
-            // the following code overwrite the deltaPOC and Used by current values read from the config file with the ones
-            // computed from the RefIdc.  A warning is printed if they are not identical.
-            numNeg = 0;
-            numPos = 0;
-            TComReferencePictureSet RPSTemp; // temporary variable
-
-            for (Int j = 0; j < ge.m_numRefIdc; j++)
-            {
-                if (ge.m_refIdc[j])
-                {
-                    Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures()) ? RPSRef->getDeltaPOC(j) : 0);
-                    RPSTemp.setDeltaPOC((numNeg + numPos), deltaPOC);
-                    RPSTemp.setUsed((numNeg + numPos), ge.m_refIdc[j] == 1 ? 1 : 0);
-                    if (deltaPOC < 0)
-                    {
-                        numNeg++;
-                    }
-                    else
-                    {
-                        numPos++;
-                    }
-                }
-            }
-
-            if (numNeg != rps->getNumberOfNegativePictures())
-            {
-                printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n");
-                rps->setNumberOfNegativePictures(numNeg);
-                rps->setNumberOfPositivePictures(numNeg + numPos);
-            }
-            if (numPos != rps->getNumberOfPositivePictures())
-            {
-                printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n");
-                rps->setNumberOfPositivePictures(numPos);
-                rps->setNumberOfPositivePictures(numNeg + numPos);
-            }
-            RPSTemp.setNumberOfPictures(numNeg + numPos);
-            RPSTemp.setNumberOfNegativePictures(numNeg);
-            RPSTemp.sortDeltaPOC(); // sort the created delta POC before comparing
-            // check if Delta POC and Used are the same
-            // print warning if they are not.
-            for (Int j = 0; j < ge.m_numRefIdc; j++)
-            {
-                if (RPSTemp.getDeltaPOC(j) != rps->getDeltaPOC(j))
-                {
-                    printf("Warning: delta POC is different between intra RPS and inter RPS specified in the config file.\n");
-                    rps->setDeltaPOC(j, RPSTemp.getDeltaPOC(j));
-                }
-                if (RPSTemp.getUsed(j) != rps->getUsed(j))
-                {
-                    printf("Warning: Used by Current in RPS is different between intra and inter RPS specified in the config file.\n");
-                    rps->setUsed(j, RPSTemp.getUsed(j));
-                }
-            }
-        }
-    }
-}
-
 Void TEncTop::computeLambdaForQp(TComSlice* slice)
 {
     FrameEncoder *curEncoder = &m_frameEncoder[m_curEncoder];
diff -r 1217ba050142 -r 534d319b3c22 source/encoder/dpb.cpp
--- a/source/encoder/dpb.cpp	Wed Aug 28 17:58:24 2013 +0530
+++ b/source/encoder/dpb.cpp	Wed Aug 28 18:05:53 2013 +0530
@@ -123,7 +123,7 @@
     refPicListModification->setRefPicListModificationFlagL1(false);
     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);
 
     // Slice type refinement
@@ -294,7 +294,7 @@
         || 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())
@@ -405,73 +405,6 @@
     }
 }
 
-// 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)
-{
-    slice->setRPSidx(gopID);
-    UInt intraPeriod = m_cfg->param.keyframeMax;
-    int gopSize = m_cfg->getGOPSize();
-
-    for (int extraNum = gopSize; extraNum < m_cfg->getExtraRPSs() + gopSize; extraNum++)
-    {
-        if (intraPeriod > 0 && m_cfg->param.decodingRefreshType > 0)
-        {
-            int POCIndex = curPOC % intraPeriod;
-            if (POCIndex == 0)
-            {
-                POCIndex = intraPeriod;
-            }
-            if (POCIndex == m_cfg->getGOPEntry(extraNum).m_POC)
-            {
-                slice->setRPSidx(extraNum);
-            }
-        }
-        else
-        {
-            if (curPOC == m_cfg->getGOPEntry(extraNum).m_POC)
-            {
-                slice->setRPSidx(extraNum);
-            }
-        }
-    }
-
-    slice->setRPS(frameEncoder->m_sps.getRPSList()->getReferencePictureSet(slice->getRPSidx()));
-    slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures() + slice->getRPS()->getNumberOfPositivePictures());
-}
-
-int DPB::getReferencePictureSetIdxForSOP(int curPOC, int gopID)
-{
-    int rpsIdx = gopID;
-    int gopSize = m_cfg->getGOPSize();
-    UInt intraPeriod = m_cfg->param.keyframeMax;
-
-    for (int extraNum = gopSize; extraNum < m_cfg->getExtraRPSs() + gopSize; extraNum++)
-    {
-        if (intraPeriod > 0 && m_cfg->param.decodingRefreshType > 0)
-        {
-            int POCIndex = curPOC % intraPeriod;
-            if (POCIndex == 0)
-            {
-                POCIndex = intraPeriod;
-            }
-            if (POCIndex == m_cfg->getGOPEntry(extraNum).m_POC)
-            {
-                rpsIdx = extraNum;
-            }
-        }
-        else
-        {
-            if (curPOC == m_cfg->getGOPEntry(extraNum).m_POC)
-            {
-                rpsIdx = extraNum;
-            }
-        }
-    }
-
-    return rpsIdx;
-}
-
 /** Function for deciding the nal_unit_type.
  * \param pocCurr POC of the current picture
  * \returns the nal unit type of the picture
@@ -665,19 +598,15 @@
         /* 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[] = { 1, 3, 2, 5, 4, 7, 6, 8};     //For alternate P/B frames
-        int rps[] = { 0, 4, 2, 1, -2, -3, 1, -2 };
+        int pocs[] = { 1, 3, 2, 5, 4, 7, 6, 8 };     //For alternate P/B frames
         for (int i = 0; i < 8; i++)
         {
             m_gopList[i].m_POC = pocs[i];
             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 = (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;
-            m_gopList[i].m_numRefIdc = i == 2 ? 4 : 5;
+            m_gopList[i].m_sliceType = (pocs[i] % 2) ? 'P' : 'B';
+            m_gopList[i].m_numRefPicsActive = 1;
+            m_gopList[i].m_numRefPics = 2;
         }
 
 #define SET4(id, VAR, a, b, c, d) \
@@ -766,226 +695,8 @@
         // this check goes away when we have a real lookahead
         x265_log(_param, X265_LOG_WARNING, "Lookahead depth must be at least one GOP\n");
         _param->lookaheadDepth = m_gopSize;
-    }    
-
-    bool verifiedGOP = false;
-    bool errorGOP = false;
-    int checkGOP = 1;
-    int numRefs = 1;
-
-    int refList[MAX_NUM_REF_PICS + 1];
-    refList[0] = 0;
-    bool isOK[MAX_GOP];
-    for (Int i = 0; i < MAX_GOP; i++)
-    {
-        isOK[i] = false;
     }
 
-    int numOK = 0;
-    if (_param->bOpenGOP == false)
-        CONFIRM(_param->keyframeMax % m_gopSize != 0, "Intra period must be a multiple of GOPSize");
-
-    m_extraRPSs = 0;
-    // start looping through frames in coding order until we can verify that the GOP structure is correct.
-    while (!verifiedGOP && !errorGOP)
-    {
-        Int curGOP = (checkGOP - 1) % m_gopSize;
-        Int curPOC = ((checkGOP - 1) / m_gopSize) * m_gopSize + m_gopList[curGOP].m_POC;
-        if (m_gopList[curGOP].m_POC < 0)
-        {
-            printf("\nError: found fewer Reference Picture Sets than GOPSize\n");
-            errorGOP = true;
-        }
-        else
-        {
-            //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
-            Bool beforeI = false;
-            for (Int i = 0; i < m_gopList[curGOP].m_numRefPics; i++)
-            {
-                Int absPOC = curPOC + m_gopList[curGOP].m_referencePics[i];
-                if (absPOC < 0)
-                {
-                    beforeI = true;
-                }
-                else
-                {
-                    Bool found = false;
-                    for (Int j = 0; j < numRefs; j++)
-                    {
-                        if (refList[j] == absPOC)
-                        {
-                            found = true;
-                            for (Int k = 0; k < m_gopSize; k++)
-                            {
-                                if (absPOC % m_gopSize == m_gopList[k].m_POC % m_gopSize)
-                                {
-                                    m_gopList[k].m_refPic = true;
-                                    m_gopList[curGOP].m_usedByCurrPic[i] = 1;
-                                }
-                            }
-                        }
-                    }
-
-                    if (!found)
-                    {
-                        printf("\nError: ref pic %d is not available for GOP frame %d\n", m_gopList[curGOP].m_referencePics[i], curGOP + 1);
-                        errorGOP = true;
-                    }
-                }
-            }
-
-            if (!beforeI && !errorGOP)
-            {
-                //all ref frames were present
-                if (!isOK[curGOP])
-                {
-                    numOK++;
-                    isOK[curGOP] = true;
-                    if (numOK == m_gopSize)
-                    {
-                        verifiedGOP = true;
-                    }
-                }
-            }
-            else
-            {
-                //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
-                m_gopList[m_gopSize + m_extraRPSs] = m_gopList[curGOP];
-                Int newRefs = 0;
-                for (Int i = 0; i < m_gopList[curGOP].m_numRefPics; i++)
-                {
-                    Int absPOC = curPOC + m_gopList[curGOP].m_referencePics[i];
-                    if (absPOC >= 0)
-                    {
-                        m_gopList[m_gopSize + m_extraRPSs].m_referencePics[newRefs] = m_gopList[curGOP].m_referencePics[i];
-                        m_gopList[m_gopSize + m_extraRPSs].m_usedByCurrPic[newRefs] = m_gopList[curGOP].m_usedByCurrPic[i];
-                        newRefs++;
-                    }
-                }
-
-                Int numPrefRefs = m_gopList[curGOP].m_numRefPicsActive;
-
-                for (Int offset = -1; offset > -checkGOP; offset--)
-                {
-                    //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
-                    Int offGOP = (checkGOP - 1 + offset) % m_gopSize;
-                    Int offPOC = ((checkGOP - 1 + offset) / m_gopSize) * m_gopSize + m_gopList[offGOP].m_POC;
-                    if (offPOC >= 0)
-                    {
-                        Bool newRef = false;
-                        for (Int i = 0; i < numRefs; i++)
-                        {
-                            if (refList[i] == offPOC)
-                            {
-                                newRef = true;
-                            }
-                        }
-
-                        for (Int i = 0; i < newRefs; i++)
-                        {
-                            if (m_gopList[m_gopSize + m_extraRPSs].m_referencePics[i] == offPOC - curPOC)
-                            {
-                                newRef = false;
-                            }
-                        }
-
-                        if (newRef)
-                        {
-                            Int insertPoint = newRefs;
-                            //this picture can be added, find appropriate place in list and insert it.
-                            m_gopList[offGOP].m_refPic = true;
-                            for (Int j = 0; j < newRefs; j++)
-                            {
-                                if (m_gopList[m_gopSize + m_extraRPSs].m_referencePics[j] < offPOC - curPOC || m_gopList[m_gopSize + m_extraRPSs].m_referencePics[j] > 0)
-                                {
-                                    insertPoint = j;
-                                    break;
-                                }
-                            }
-
-                            Int prev = offPOC - curPOC;
-                            Int prevUsed = 1;
-                            for (Int j = insertPoint; j < newRefs + 1; j++)
-                            {
-                                Int newPrev = m_gopList[m_gopSize + m_extraRPSs].m_referencePics[j];
-                                Int newUsed = m_gopList[m_gopSize + m_extraRPSs].m_usedByCurrPic[j];
-                                m_gopList[m_gopSize + m_extraRPSs].m_referencePics[j] = prev;
-                                m_gopList[m_gopSize + m_extraRPSs].m_usedByCurrPic[j] = prevUsed;
-                                prevUsed = newUsed;
-                                prev = newPrev;
-                            }
-
-                            newRefs++;
-                        }
-                    }
-                    if (newRefs >= numPrefRefs)
-                    {
-                        break;
-                    }
-                }
-
-                m_gopList[m_gopSize + m_extraRPSs].m_numRefPics = newRefs;
-                m_gopList[m_gopSize + m_extraRPSs].m_POC = curPOC;
-                if (m_extraRPSs == 0)
-                {
-                    m_gopList[m_gopSize + m_extraRPSs].m_interRPSPrediction = 0;
-                    m_gopList[m_gopSize + m_extraRPSs].m_numRefIdc = 0;
-                }
-                else
-                {
-                    Int rIdx =  m_gopSize + m_extraRPSs - 1;
-                    Int refPOC = m_gopList[rIdx].m_POC;
-                    Int refPics = m_gopList[rIdx].m_numRefPics;
-                    Int newIdc = 0;
-                    for (Int i = 0; i <= refPics; i++)
-                    {
-                        Int deltaPOC = ((i != refPics) ? m_gopList[rIdx].m_referencePics[i] : 0); // check if the reference abs POC is >= 0
-                        Int absPOCref = refPOC + deltaPOC;
-                        Int refIdc = 0;
-                        for (Int j = 0; j < m_gopList[m_gopSize + m_extraRPSs].m_numRefPics; j++)
-                        {
-                            if ((absPOCref - curPOC) == m_gopList[m_gopSize + m_extraRPSs].m_referencePics[j])
-                            {
-                                if (m_gopList[m_gopSize + m_extraRPSs].m_usedByCurrPic[j])
-                                {
-                                    refIdc = 1;
-                                }
-                                else
-                                {
-                                    refIdc = 2;
-                                }
-                            }
-                        }
-
-                        m_gopList[m_gopSize + m_extraRPSs].m_refIdc[newIdc] = refIdc;
-                        newIdc++;
-                    }
-
-                    m_gopList[m_gopSize + m_extraRPSs].m_interRPSPrediction = 1;
-                    m_gopList[m_gopSize + m_extraRPSs].m_numRefIdc = newIdc;
-                    m_gopList[m_gopSize + m_extraRPSs].m_deltaRPS = refPOC - m_gopList[m_gopSize + m_extraRPSs].m_POC;
-                }
-                curGOP = m_gopSize + m_extraRPSs;
-                m_extraRPSs++;
-            }
-            numRefs = 0;
-            for (Int i = 0; i < m_gopList[curGOP].m_numRefPics; i++)
-            {
-                Int absPOC = curPOC + m_gopList[curGOP].m_referencePics[i];
-                if (absPOC >= 0)
-                {
-                    refList[numRefs] = absPOC;
-                    numRefs++;
-                }
-            }
-
-            refList[numRefs] = curPOC;
-            numRefs++;
-        }
-        checkGOP++;
-    }
-
-    CONFIRM(errorGOP, "Invalid GOP structure given");
     for (Int i = 0; i < m_gopSize; i++)
     {
         CONFIRM(m_gopList[i].m_sliceType != 'B' && m_gopList[i].m_sliceType != 'P', "Slice type must be equal to B or P");
diff -r 1217ba050142 -r 534d319b3c22 source/encoder/dpb.h
--- a/source/encoder/dpb.h	Wed Aug 28 17:58:24 2013 +0530
+++ b/source/encoder/dpb.h	Wed Aug 28 18:05:53 2013 +0530
@@ -64,15 +64,11 @@
 
 protected:
 
-    void selectReferencePictureSet(TComSlice* slice, x265::FrameEncoder*, int curPoc, int gopID);
-
     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);
 
     NalUnitType getNalUnitType(int curPoc, int lastIdr);


More information about the x265-devel mailing list