[x265] [PATCH 1 of 2] Computing RPS from a fixed GOP
Steve Borho
steve at borho.org
Thu Aug 22 21:32:19 CEST 2013
On Thu, Aug 22, 2013 at 7:54 AM, <shazeb at multicorewareinc.com> wrote:
> # HG changeset patch
> # User Shazeb N Khan
> # Date 1377173041 -19800
> # Thu Aug 22 17:34:01 2013 +0530
> # Node ID 34c63b8389c6f688cec7ac869943df32577fb28e
> # Parent 9f38435eee26dfc31d7fbd81ca5357f4a5b4d5b8
> Computing RPS from a fixed GOP
>
great start, I have a few comments
>
> diff -r 9f38435eee26 -r 34c63b8389c6 source/Lib/TLibCommon/TComSlice.h
> --- a/source/Lib/TLibCommon/TComSlice.h Thu Aug 22 15:17:49 2013 +0800
> +++ b/source/Lib/TLibCommon/TComSlice.h Thu Aug 22 17:34:01 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 9f38435eee26 -r 34c63b8389c6 source/encoder/dpb.cpp
> --- a/source/encoder/dpb.cpp Thu Aug 22 15:17:49 2013 +0800
> +++ b/source/encoder/dpb.cpp Thu Aug 22 17:34:01 2013 +0530
> @@ -31,6 +31,8 @@
>
> using namespace x265;
>
> +#define MAX_REFD_BY_CUR 8
>
Does the HM already have a similar define (I think it is 16 or 32)
> +
> DPB::~DPB()
> {
> while (!m_picList.empty())
> @@ -44,7 +46,6 @@
> void DPB::recycleUnreferenced(TComList<TComPic*> freeList)
> {
> // move unreferenced pictures from picList to freeList for recycle
> - TComSlice::sortPicList(m_picList);
>
You should remove the comment above if you remove the sort call
> 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();
> @@ -90,10 +91,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);
> }
>
This whole set of logic could be reduced to:
slice->setReferenced(slice->getSliceType() != B_SLICE);
slice->setTemporalLayerNonReferenceFlag(!slice->getReferenced());
> // Set the nal unit type
> @@ -118,21 +123,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->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);
>
I wonder if the above three lines could be moved to the TComSlice
constructor?
> - 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);
>
To answer your question, we need to know how the number of reference idx
are used in the encoder/decoder, and whether they are dependent on the
slice type at all.
>
> slice->setRefPicList(m_picList);
>
> @@ -148,11 +151,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 +251,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] = true && (!isRAP);
>
the "true &&" here is redundant
> + 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)
> @@ -514,7 +549,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';
>
is this backwards? don't you want P for the 4th (and possibly 1st)
frame(s) and B for the rest?
> 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;
>
Can these three fields be removed yet?
> diff -r 9f38435eee26 -r 34c63b8389c6 source/encoder/dpb.h
> --- a/source/encoder/dpb.h Thu Aug 22 15:17:49 2013 +0800
> +++ b/source/encoder/dpb.h Thu Aug 22 17:34:01 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/20130822/c5812e45/attachment-0001.html>
More information about the x265-devel
mailing list