[x265] [PATCH Alpha 05/10] Add support to access DPB based on scalable layerID
Anusuya Kumarasamy
anusuya.kumarasamy at multicorewareinc.com
Mon Aug 5 10:57:52 UTC 2024
>From 5f5359c8d5e9fdfd121347aa7185d552b1c3ded2 Mon Sep 17 00:00:00 2001
From: Kirithika <kirithika at multicorewareinc.com>
Date: Mon, 6 May 2024 13:58:25 +0530
Subject: [PATCH] Add support to access DPB based on scalable layerID
---
source/encoder/dpb.cpp | 46 ++++++++++++++++++++++--------------------
source/encoder/dpb.h | 14 ++++++-------
2 files changed, 31 insertions(+), 29 deletions(-)
diff --git a/source/encoder/dpb.cpp b/source/encoder/dpb.cpp
index 52ef91af0..eeb2a5cb8 100644
--- a/source/encoder/dpb.cpp
+++ b/source/encoder/dpb.cpp
@@ -75,7 +75,7 @@ void DPB::recycleUnreferenced()
if (curFrame->m_param->bEnableTemporalFilter)
isMCSTFReferenced =!!(curFrame->m_refPicCnt[1]);
- if (!curFrame->m_encData->m_bHasReferences &&
!curFrame->m_countRefEncoders && !isMCSTFReferenced)
+ if (curFrame->m_valid && !curFrame->m_encData->m_bHasReferences &&
!curFrame->m_countRefEncoders && !isMCSTFReferenced)
{
curFrame->m_bChromaExtended = false;
@@ -175,9 +175,11 @@ void DPB::prepareEncode(Frame *newFrame)
newFrame->m_encData->m_bHasReferences = true;
}
- m_picList.pushFront(*newFrame);
+ //Non base view pictures are already present in the list
+ if(newFrame->m_sLayerId == 0)
+ m_picList.pushFront(*newFrame);
- if (m_bTemporalSublayer && getTemporalLayerNonReferenceFlag())
+ if (m_bTemporalSublayer &&
getTemporalLayerNonReferenceFlag(newFrame->m_sLayerId))
{
switch (slice->m_nalUnitType)
{
@@ -195,12 +197,12 @@ void DPB::prepareEncode(Frame *newFrame)
}
}
// Do decoding refresh marking if any
- decodingRefreshMarking(pocCurr, slice->m_nalUnitType);
+ decodingRefreshMarking(pocCurr, slice->m_nalUnitType,
newFrame->m_sLayerId);
- computeRPS(pocCurr, newFrame->m_tempLayer, slice->isIRAP(),
&slice->m_rps, slice->m_sps->maxDecPicBuffering[newFrame->m_tempLayer]);
+ computeRPS(pocCurr, newFrame->m_tempLayer, slice->isIRAP(),
&slice->m_rps, slice->m_sps->maxDecPicBuffering[newFrame->m_tempLayer],
newFrame->m_sLayerId);
bool isTSAPic = ((slice->m_nalUnitType == 2) || (slice->m_nalUnitType
== 3)) ? true : false;
// Mark pictures in m_piclist as unreferenced if they are not included
in RPS
- applyReferencePictureSet(&slice->m_rps, pocCurr,
newFrame->m_tempLayer, isTSAPic);
+ applyReferencePictureSet(&slice->m_rps, pocCurr,
newFrame->m_tempLayer, isTSAPic, newFrame->m_sLayerId);
if (m_bTemporalSublayer && newFrame->m_tempLayer > 0
@@ -221,7 +223,7 @@ void DPB::prepareEncode(Frame *newFrame)
slice->m_nalUnitType = NAL_UNIT_CODED_SLICE_TSA_R;
}
}
- else if (isStepwiseTemporalLayerSwitchingPoint(&slice->m_rps,
pocCurr, newFrame->m_tempLayer))
+ else if (isStepwiseTemporalLayerSwitchingPoint(&slice->m_rps,
pocCurr, newFrame->m_tempLayer, newFrame->m_sLayerId))
{
bool isSTSA = true;
int id = newFrame->m_gopOffset %
x265_gop_ra_length[newFrame->m_gopId];
@@ -254,7 +256,7 @@ void DPB::prepareEncode(Frame *newFrame)
}
if (isSTSA == true)
{
- if (getTemporalLayerNonReferenceFlag())
+ if (getTemporalLayerNonReferenceFlag(newFrame->m_sLayerId))
{
slice->m_nalUnitType = NAL_UNIT_CODED_SLICE_STSA_N;
}
@@ -308,7 +310,7 @@ void DPB::prepareEncode(Frame *newFrame)
}
}
-void DPB::computeRPS(int curPoc, int tempId, bool isRAP, RPS * rps,
unsigned int maxDecPicBuffer)
+void DPB::computeRPS(int curPoc, int tempId, bool isRAP, RPS * rps,
unsigned int maxDecPicBuffer, int scalableLayerId)
{
unsigned int poci = 0, numNeg = 0, numPos = 0;
@@ -316,7 +318,7 @@ void DPB::computeRPS(int curPoc, int tempId, bool
isRAP, RPS * rps, unsigned int
while (iterPic && (poci < maxDecPicBuffer - 1))
{
- if ((iterPic->m_poc != curPoc) &&
iterPic->m_encData->m_bHasReferences)
+ if (iterPic->m_valid && (iterPic->m_poc != curPoc) &&
iterPic->m_encData->m_bHasReferences && iterPic->m_sLayerId ==
scalableLayerId)
{
if ((!m_bTemporalSublayer || (iterPic->m_tempLayer <= tempId))
&& ((m_lastIDR >= curPoc) || (m_lastIDR <= iterPic->m_poc)))
{
@@ -337,10 +339,10 @@ void DPB::computeRPS(int curPoc, int tempId, bool
isRAP, RPS * rps, unsigned int
rps->sortDeltaPOC();
}
-bool DPB::getTemporalLayerNonReferenceFlag()
+bool DPB::getTemporalLayerNonReferenceFlag(int scalableLayerId)
{
Frame* curFrame = m_picList.first();
- if (curFrame->m_encData->m_bHasReferences)
+ if (curFrame->m_valid && curFrame->m_encData->m_bHasReferences &&
curFrame->m_sLayerId == scalableLayerId)
{
curFrame->m_sameLayerRefPic = true;
return false;
@@ -350,7 +352,7 @@ bool DPB::getTemporalLayerNonReferenceFlag()
}
/* Marking reference pictures when an IDR/CRA is encountered. */
-void DPB::decodingRefreshMarking(int pocCurr, NalUnitType nalUnitType)
+void DPB::decodingRefreshMarking(int pocCurr, NalUnitType nalUnitType, int
scalableLayerId)
{
if (nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalUnitType ==
NAL_UNIT_CODED_SLICE_IDR_N_LP)
{
@@ -359,7 +361,7 @@ void DPB::decodingRefreshMarking(int pocCurr,
NalUnitType nalUnitType)
Frame* iterFrame = m_picList.first();
while (iterFrame)
{
- if (iterFrame->m_poc != pocCurr)
+ if (iterFrame->m_valid && iterFrame->m_poc != pocCurr &&
iterFrame->m_sLayerId == scalableLayerId)
iterFrame->m_encData->m_bHasReferences = false;
iterFrame = iterFrame->m_next;
}
@@ -376,7 +378,7 @@ void DPB::decodingRefreshMarking(int pocCurr,
NalUnitType nalUnitType)
Frame* iterFrame = m_picList.first();
while (iterFrame)
{
- if (iterFrame->m_poc != pocCurr && iterFrame->m_poc !=
m_pocCRA)
+ if (iterFrame->m_valid && iterFrame->m_poc != pocCurr &&
iterFrame->m_poc != m_pocCRA && iterFrame->m_sLayerId == scalableLayerId)
iterFrame->m_encData->m_bHasReferences = false;
iterFrame = iterFrame->m_next;
}
@@ -398,13 +400,13 @@ void DPB::decodingRefreshMarking(int pocCurr,
NalUnitType nalUnitType)
}
/** Function for applying picture marking based on the Reference Picture
Set */
-void DPB::applyReferencePictureSet(RPS *rps, int curPoc, int tempId, bool
isTSAPicture)
+void DPB::applyReferencePictureSet(RPS *rps, int curPoc, int tempId, bool
isTSAPicture, int scalableLayerId)
{
// loop through all pictures in the reference picture buffer
Frame* iterFrame = m_picList.first();
while (iterFrame)
{
- if (iterFrame->m_poc != curPoc &&
iterFrame->m_encData->m_bHasReferences)
+ if (iterFrame->m_valid && iterFrame->m_poc != curPoc &&
iterFrame->m_encData->m_bHasReferences && iterFrame->m_sLayerId ==
scalableLayerId)
{
// loop through all pictures in the Reference Picture Set
// to see if the picture should be kept as reference picture
@@ -441,13 +443,13 @@ void DPB::applyReferencePictureSet(RPS *rps, int
curPoc, int tempId, bool isTSAP
}
}
-bool DPB::isTemporalLayerSwitchingPoint(int curPoc, int tempId)
+bool DPB::isTemporalLayerSwitchingPoint(int curPoc, int tempId, int
scalableLayerId)
{
// loop through all pictures in the reference picture buffer
Frame* iterFrame = m_picList.first();
while (iterFrame)
{
- if (iterFrame->m_poc != curPoc &&
iterFrame->m_encData->m_bHasReferences)
+ if (iterFrame->m_valid && iterFrame->m_poc != curPoc &&
iterFrame->m_encData->m_bHasReferences && iterFrame->m_sLayerId ==
scalableLayerId)
{
if (iterFrame->m_tempLayer >= tempId)
{
@@ -459,13 +461,13 @@ bool DPB::isTemporalLayerSwitchingPoint(int curPoc,
int tempId)
return true;
}
-bool DPB::isStepwiseTemporalLayerSwitchingPoint(RPS *rps, int curPoc, int
tempId)
+bool DPB::isStepwiseTemporalLayerSwitchingPoint(RPS *rps, int curPoc, int
tempId, int scalableLayerId)
{
// loop through all pictures in the reference picture buffer
Frame* iterFrame = m_picList.first();
while (iterFrame)
{
- if (iterFrame->m_poc != curPoc &&
iterFrame->m_encData->m_bHasReferences)
+ if (iterFrame->m_valid && iterFrame->m_poc != curPoc &&
iterFrame->m_encData->m_bHasReferences && iterFrame->m_sLayerId ==
scalableLayerId)
{
for (int i = 0; i < rps->numberOfPositivePictures +
rps->numberOfNegativePictures; i++)
{
@@ -484,7 +486,7 @@ bool DPB::isStepwiseTemporalLayerSwitchingPoint(RPS
*rps, int curPoc, int tempId
}
/* deciding the nal_unit_type */
-NalUnitType DPB::getNalUnitType(int curPOC, bool bIsKeyFrame)
+NalUnitType DPB::getNalUnitType(int curPOC, bool bIsKeyFrame, int viewId)
{
if (!curPOC)
return NAL_UNIT_CODED_SLICE_IDR_N_LP;
diff --git a/source/encoder/dpb.h b/source/encoder/dpb.h
index a9543fc69..fcb19a203 100644
--- a/source/encoder/dpb.h
+++ b/source/encoder/dpb.h
@@ -79,15 +79,15 @@ public:
protected:
- void computeRPS(int curPoc,int tempId, bool isRAP, RPS * rps, unsigned
int maxDecPicBuffer);
+ void computeRPS(int curPoc,int tempId, bool isRAP, RPS * rps, unsigned
int maxDecPicBuffer, int viewId);
- void applyReferencePictureSet(RPS *rps, int curPoc, int tempId, bool
isTSAPicture);
- bool getTemporalLayerNonReferenceFlag();
- void decodingRefreshMarking(int pocCurr, NalUnitType nalUnitType);
- bool isTemporalLayerSwitchingPoint(int curPoc, int tempId);
- bool isStepwiseTemporalLayerSwitchingPoint(RPS *rps, int curPoc, int
tempId);
+ void applyReferencePictureSet(RPS *rps, int curPoc, int tempId, bool
isTSAPicture, int viewId);
+ bool getTemporalLayerNonReferenceFlag(int viewId);
+ void decodingRefreshMarking(int pocCurr, NalUnitType nalUnitType, int
viewId);
+ bool isTemporalLayerSwitchingPoint(int curPoc, int tempId, int viewId);
+ bool isStepwiseTemporalLayerSwitchingPoint(RPS *rps, int curPoc, int
tempId, int viewId);
- NalUnitType getNalUnitType(int curPoc, bool bIsKeyFrame);
+ NalUnitType getNalUnitType(int curPoc, bool bIsKeyFrame, int viewId);
};
}
--
2.36.0.windows.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240805/34dda252/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-Add-support-to-access-DPB-based-on-scalable-layerID.patch
Type: application/octet-stream
Size: 10373 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240805/34dda252/attachment-0001.obj>
More information about the x265-devel
mailing list