<div dir="ltr">From f2c166ff4fbc49a004b766ebd34b24515491ac77 Mon Sep 17 00:00:00 2001<br>From: AnusuyaKumarasamy <<a href="mailto:anusuya.kumarasamy@multicorewareinc.com">anusuya.kumarasamy@multicorewareinc.com</a>><br>Date: Mon, 19 Aug 2024 13:46:55 +0530<br>Subject: [PATCH 1/7] Reset rps for I-slice marked as P-slice in enhancement<br> layer<br><br>---<br> source/common/slice.cpp        | 6 ++++--<br> source/encoder/dpb.cpp         | 8 ++++++--<br> source/encoder/encoder.cpp     | 5 ++++-<br> source/encoder/ratecontrol.cpp | 6 +++++-<br> 4 files changed, 19 insertions(+), 6 deletions(-)<br><br>diff --git a/source/common/slice.cpp b/source/common/slice.cpp<br>index 24ccff933..0c09df21b 100644<br>--- a/source/common/slice.cpp<br>+++ b/source/common/slice.cpp<br>@@ -82,16 +82,18 @@ void Slice::setRefPicList(PicList& picList, PicList& refPicSetInterLayer0, PicLi<br>         return;<br>     }<br> <br>-#if ENABLE_SCC_EXT<br>+#if ENABLE_SCC_EXT || ENABLE_MULTIVIEW || ENABLE_ALPHA<br>     /*Reset the number of references for I-slice marked as P-slice*/<br>-    if (m_param->bEnableSCC && m_sliceType != m_origSliceType)<br>+    if ((m_param->bEnableSCC || sLayerId) && m_sliceType != m_origSliceType)<br>     {<br>         memset(m_refFrameList, 0, sizeof(m_refFrameList));<br>         memset(m_refReconPicList, 0, sizeof(m_refReconPicList));<br>         memset(m_refPOCList, 0, sizeof(m_refPOCList));<br>         m_numRefIdx[0] = 1;<br>     }<br>+#endif<br> <br>+#if ENABLE_SCC_EXT<br>     if (!checkNumPocTotalCurr && m_rps.numberOfPictures == 0)<br>     {<br>         Frame* prevPic = picList.getPOC(X265_MAX(0, m_poc - 1));<br>diff --git a/source/encoder/dpb.cpp b/source/encoder/dpb.cpp<br>index 498d62c1a..19480d7ca 100644<br>--- a/source/encoder/dpb.cpp<br>+++ b/source/encoder/dpb.cpp<br>@@ -151,9 +151,12 @@ void DPB::prepareEncode(Frame *newFrame)<br>     if (slice->m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL || slice->m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP)<br>         m_lastIDR = pocCurr;<br>     slice->m_lastIDR = m_lastIDR;<br>-    slice->m_origSliceType = slice->m_sliceType = IS_X265_TYPE_B(type) ? B_SLICE : (type == X265_TYPE_P) ? P_SLICE : I_SLICE;<br>+    slice->m_sliceType = IS_X265_TYPE_B(type) ? B_SLICE : (type == X265_TYPE_P) ? P_SLICE : I_SLICE;<br>+#if ENABLE_SCC_EXT<br>+    if (slice->m_param->bEnableSCC)        slice->m_origSliceType = slice->m_sliceType;<br>     if (slice->m_param->bEnableSCC && IS_X265_TYPE_I(type))<br>         slice->m_sliceType = P_SLICE;<br>+#endif<br> <br>     if (type == X265_TYPE_B)<br>     {<br>@@ -481,7 +484,8 @@ void DPB::decodingRefreshMarking(int pocCurr, NalUnitType nalUnitType, int scala<br>                 iterFrame = iterFrame->m_next;<br>             }<br> <br>-            m_bRefreshPending = false;<br>+            if (scalableLayerId == m_picList.first()->m_param->numLayers - 1)<br>+                m_bRefreshPending = false;<br>         }<br>         if (nalUnitType == NAL_UNIT_CODED_SLICE_CRA)<br>         {<br>diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp<br>index 1a16f039d..4c2865953 100644<br>--- a/source/encoder/encoder.cpp<br>+++ b/source/encoder/encoder.cpp<br>@@ -2223,6 +2223,7 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture** pic_out)<br>                     frameEnc[layer]->m_lowres.sliceType = baseViewType;<br>                 else if(m_param->numViews > 1)<br>                     frameEnc[layer]->m_lowres.sliceType = IS_X265_TYPE_I(baseViewType) ? X265_TYPE_P : baseViewType;<br>+                frameEnc[layer]->m_lowres.bKeyframe = frameEnc[0]->m_lowres.bKeyframe;<br>             }<br> #endif<br> <br>@@ -2309,6 +2310,8 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture** pic_out)<br>                     slice->m_endCUAddr = slice->realEndAddress(m_sps.numCUsInFrame * m_param->num4x4Partitions);<br>                 }<br>                 frameEnc[layer]->m_valid = true;<br>+                int baseViewType = frameEnc[0]->m_lowres.sliceType;<br>+                frameEnc[layer]->m_encData->m_slice->m_origSliceType = IS_X265_TYPE_B(baseViewType) ? B_SLICE : (baseViewType == X265_TYPE_P) ? P_SLICE : I_SLICE;<br>             }<br>             if (m_param->analysisLoad && m_param->bDisableLookahead)<br>             {<br>@@ -3653,11 +3656,11 @@ void Encoder::initSPS(SPS *sps)<br>     sps->sps_extension_flag = false;<br> <br> #if ENABLE_MULTIVIEW<br>+    sps->maxViews = m_param->numViews;<br>     if (m_param->numViews > 1)<br>     {<br>         sps->sps_extension_flag = true;<br>         sps->setSpsExtOrMaxSubLayersMinus1 = 7;<br>-        sps->maxViews = m_param->numViews;<br>     }<br> #endif<br> <br>diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp<br>index 25cb7318e..9851f69e3 100644<br>--- a/source/encoder/ratecontrol.cpp<br>+++ b/source/encoder/ratecontrol.cpp<br>@@ -1348,7 +1348,11 @@ int RateControl::rateControlStart(Frame* curFrame, RateControlEntry* rce, Encode<br> <br>     FrameData& curEncData = *curFrame->m_encData;<br>     m_curSlice = curEncData.m_slice;<br>-    m_sliceType = m_curSlice->m_origSliceType;<br>+    m_sliceType = m_curSlice->m_sliceType;<br>+#if ENABLE_SCC_EXT<br>+    if(m_param->bEnableSCC)<br>+        m_sliceType = m_curSlice->m_origSliceType;<br>+#endif<br>     rce->sliceType = m_sliceType;<br>     if (!m_2pass)<br>         rce->keptAsRef = IS_REFERENCED(curFrame);<br>-- <br>2.36.0.windows.1<br><br></div>