[x265] [PATCH] Reset rps for I-slice marked as P-slice in enhancement layer
Anusuya Kumarasamy
anusuya.kumarasamy at multicorewareinc.com
Mon Sep 9 08:32:18 UTC 2024
>From f2c166ff4fbc49a004b766ebd34b24515491ac77 Mon Sep 17 00:00:00 2001
From: AnusuyaKumarasamy <anusuya.kumarasamy at multicorewareinc.com>
Date: Mon, 19 Aug 2024 13:46:55 +0530
Subject: [PATCH 1/7] Reset rps for I-slice marked as P-slice in enhancement
layer
---
source/common/slice.cpp | 6 ++++--
source/encoder/dpb.cpp | 8 ++++++--
source/encoder/encoder.cpp | 5 ++++-
source/encoder/ratecontrol.cpp | 6 +++++-
4 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/source/common/slice.cpp b/source/common/slice.cpp
index 24ccff933..0c09df21b 100644
--- a/source/common/slice.cpp
+++ b/source/common/slice.cpp
@@ -82,16 +82,18 @@ void Slice::setRefPicList(PicList& picList, PicList&
refPicSetInterLayer0, PicLi
return;
}
-#if ENABLE_SCC_EXT
+#if ENABLE_SCC_EXT || ENABLE_MULTIVIEW || ENABLE_ALPHA
/*Reset the number of references for I-slice marked as P-slice*/
- if (m_param->bEnableSCC && m_sliceType != m_origSliceType)
+ if ((m_param->bEnableSCC || sLayerId) && m_sliceType !=
m_origSliceType)
{
memset(m_refFrameList, 0, sizeof(m_refFrameList));
memset(m_refReconPicList, 0, sizeof(m_refReconPicList));
memset(m_refPOCList, 0, sizeof(m_refPOCList));
m_numRefIdx[0] = 1;
}
+#endif
+#if ENABLE_SCC_EXT
if (!checkNumPocTotalCurr && m_rps.numberOfPictures == 0)
{
Frame* prevPic = picList.getPOC(X265_MAX(0, m_poc - 1));
diff --git a/source/encoder/dpb.cpp b/source/encoder/dpb.cpp
index 498d62c1a..19480d7ca 100644
--- a/source/encoder/dpb.cpp
+++ b/source/encoder/dpb.cpp
@@ -151,9 +151,12 @@ void DPB::prepareEncode(Frame *newFrame)
if (slice->m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL ||
slice->m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP)
m_lastIDR = pocCurr;
slice->m_lastIDR = m_lastIDR;
- slice->m_origSliceType = slice->m_sliceType = IS_X265_TYPE_B(type) ?
B_SLICE : (type == X265_TYPE_P) ? P_SLICE : I_SLICE;
+ slice->m_sliceType = IS_X265_TYPE_B(type) ? B_SLICE : (type ==
X265_TYPE_P) ? P_SLICE : I_SLICE;
+#if ENABLE_SCC_EXT
+ if (slice->m_param->bEnableSCC) slice->m_origSliceType =
slice->m_sliceType;
if (slice->m_param->bEnableSCC && IS_X265_TYPE_I(type))
slice->m_sliceType = P_SLICE;
+#endif
if (type == X265_TYPE_B)
{
@@ -481,7 +484,8 @@ void DPB::decodingRefreshMarking(int pocCurr,
NalUnitType nalUnitType, int scala
iterFrame = iterFrame->m_next;
}
- m_bRefreshPending = false;
+ if (scalableLayerId == m_picList.first()->m_param->numLayers -
1)
+ m_bRefreshPending = false;
}
if (nalUnitType == NAL_UNIT_CODED_SLICE_CRA)
{
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index 1a16f039d..4c2865953 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -2223,6 +2223,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture** pic_out)
frameEnc[layer]->m_lowres.sliceType = baseViewType;
else if(m_param->numViews > 1)
frameEnc[layer]->m_lowres.sliceType =
IS_X265_TYPE_I(baseViewType) ? X265_TYPE_P : baseViewType;
+ frameEnc[layer]->m_lowres.bKeyframe =
frameEnc[0]->m_lowres.bKeyframe;
}
#endif
@@ -2309,6 +2310,8 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture** pic_out)
slice->m_endCUAddr =
slice->realEndAddress(m_sps.numCUsInFrame * m_param->num4x4Partitions);
}
frameEnc[layer]->m_valid = true;
+ int baseViewType = frameEnc[0]->m_lowres.sliceType;
+ frameEnc[layer]->m_encData->m_slice->m_origSliceType =
IS_X265_TYPE_B(baseViewType) ? B_SLICE : (baseViewType == X265_TYPE_P) ?
P_SLICE : I_SLICE;
}
if (m_param->analysisLoad && m_param->bDisableLookahead)
{
@@ -3653,11 +3656,11 @@ void Encoder::initSPS(SPS *sps)
sps->sps_extension_flag = false;
#if ENABLE_MULTIVIEW
+ sps->maxViews = m_param->numViews;
if (m_param->numViews > 1)
{
sps->sps_extension_flag = true;
sps->setSpsExtOrMaxSubLayersMinus1 = 7;
- sps->maxViews = m_param->numViews;
}
#endif
diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp
index 25cb7318e..9851f69e3 100644
--- a/source/encoder/ratecontrol.cpp
+++ b/source/encoder/ratecontrol.cpp
@@ -1348,7 +1348,11 @@ int RateControl::rateControlStart(Frame* curFrame,
RateControlEntry* rce, Encode
FrameData& curEncData = *curFrame->m_encData;
m_curSlice = curEncData.m_slice;
- m_sliceType = m_curSlice->m_origSliceType;
+ m_sliceType = m_curSlice->m_sliceType;
+#if ENABLE_SCC_EXT
+ if(m_param->bEnableSCC)
+ m_sliceType = m_curSlice->m_origSliceType;
+#endif
rce->sliceType = m_sliceType;
if (!m_2pass)
rce->keptAsRef = IS_REFERENCED(curFrame);
--
2.36.0.windows.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240909/4e8c6fbf/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Reset-rps-for-I-slice-marked-as-P-slice-in-enhanceme.patch
Type: application/octet-stream
Size: 5025 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240909/4e8c6fbf/attachment.obj>
More information about the x265-devel
mailing list