[x265] [PATCH 1 of 2] Computing RPS from a fixed GOP
Steve Borho
steve at borho.org
Mon Aug 26 02:32:23 CEST 2013
On Fri, Aug 23, 2013 at 6:29 AM, <shazeb at multicorewareinc.com> wrote:
> # HG changeset patch
> # User Shazeb N Khan
> # Date 1377257224 -19800
> # Fri Aug 23 16:57:04 2013 +0530
> # Node ID c0c20cd66cc7d435332c8d1651fc3799cbf7392f
> # Parent b489dfb2e90a9bc6123a41e0023df5879dc9ff94
> Computing RPS from a fixed GOP
>
> diff -r b489dfb2e90a -r c0c20cd66cc7 source/Lib/TLibCommon/TComSlice.h
> --- a/source/Lib/TLibCommon/TComSlice.h Fri Aug 23 15:18:03 2013 +0530
> +++ b/source/Lib/TLibCommon/TComSlice.h Fri Aug 23 16:57:04 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;
>
I'm guessing all the inter-RPS prediction code can go away. I don't see any
reason we'll be encoding multiple RPS into an SPS header any more.
> + Int m_numberOfLongtermPictures; // Zero when disabled
> +
> +
> TComReferencePictureSet();
> virtual ~TComReferencePictureSet();
> Int getPocLSBLT(Int i) { return
> m_pocLSBLT[i]; }
> diff -r b489dfb2e90a -r c0c20cd66cc7 source/encoder/dpb.cpp
> --- a/source/encoder/dpb.cpp Fri Aug 23 15:18:03 2013 +0530
> +++ b/source/encoder/dpb.cpp Fri Aug 23 16:57:04 2013 +0530
> @@ -31,6 +31,8 @@
>
> using namespace x265;
>
> +#define MAX_REFD_BY_CUR 8
> +
> DPB::~DPB()
> {
> while (!m_picList.empty())
> @@ -41,10 +43,9 @@
> }
> }
>
> +// move unreferenced pictures from picList to freeList for recycle
> void DPB::recycleUnreferenced(TComList<TComPic*> freeList)
> {
> - // move unreferenced pictures from picList to freeList for recycle
>
my previous comment about this was dead wrong. For some reason I thought
this comment applied to sortPicList() but it clearly applies to the entire
function (and I should have known that because I just wrote it last week).
Please point out when I'm being stupid.
- TComSlice::sortPicList(m_picList);
> TComList<TComPic*>::iterator iterPic = m_picList.begin();
> while (iterPic != m_picList.end())
> {
> @@ -71,7 +72,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();
> @@ -86,15 +87,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));
> @@ -118,21 +112,16 @@
>
> // 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->setRPS(slice->getLocalRPS());
> + slice->setRPSidx(-1); // To force using RPS from
> slice, rather than from SPS
>
this is adding some trailing white-space
> - 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,
> slice->getRPS()->getNumberOfPictures() / 2 + 1); // TO DO: how to decide
> the number of references to be included in each list
> + slice->setNumRefIdx(REF_PIC_LIST_1,
> slice->getRPS()->getNumberOfPictures() / 2 + 1);
>
I'm still looking into this. I think we need to establish a policy of what
frames to include in L0 and L1 first, and my inclination is to follow
x264's lead here. Let's discuss this on Skype today.
> slice->setRefPicList(m_picList);
>
> @@ -148,11 +137,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 +237,36 @@
> slice->setNextSlice(false);
> }
>
> +void DPB::computeRPS(int curPoc, bool isRAP, TComReferencePictureSet *
> rps)
> +{
> + curPoc;
> + TComPic * refPic;
> + 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] = !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
> +}
> +
> // 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)
> diff -r b489dfb2e90a -r c0c20cd66cc7 source/encoder/dpb.h
> --- a/source/encoder/dpb.h Fri Aug 23 15:18:03 2013 +0530
> +++ b/source/encoder/dpb.h Fri Aug 23 16:57:04 2013 +0530
> @@ -62,6 +62,8 @@
>
> void selectReferencePictureSet(TComSlice* slice, x265::FrameEncoder*,
> int curPoc, int gopID);
>
> + void computeRPS(int curPoc, bool isRAP, TComReferencePictureSet *
> rps);
> +
> int getReferencePictureSetIdxForSOP(int pocCur, int GOPid);
>
> void arrangeLongtermPicturesInRPS(TComSlice *, x265::FrameEncoder
> *frameEncoder);
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
>
--
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.videolan.org/private/x265-devel/attachments/20130825/3543ed2f/attachment.html>
More information about the x265-devel
mailing list