[x265] [PATCH Alpha 10/10] Fix inconsistent issue

Anusuya Kumarasamy anusuya.kumarasamy at multicorewareinc.com
Mon Aug 5 11:11:46 UTC 2024


>From 063fd4410aaf99b254f091f2ba5f9f439c025113 Mon Sep 17 00:00:00 2001
From: AnusuyaKumarasamy <anusuya.kumarasamy at multicorewareinc.com>
Date: Fri, 5 Jul 2024 14:39:54 +0530
Subject: [PATCH] Fix inconsistent issue

---
 source/common/param.cpp         | 7 +++++++
 source/common/piclist.cpp       | 3 ++-
 source/encoder/encoder.cpp      | 4 ++++
 source/encoder/entropy.cpp      | 4 ++--
 source/encoder/frameencoder.cpp | 4 ++--
 source/encoder/search.cpp       | 4 ++--
 source/x265cli.cpp              | 2 +-
 7 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/source/common/param.cpp b/source/common/param.cpp
index 01267b278..dec6ff6c9 100755
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -1929,6 +1929,13 @@ int x265_check_params(x265_param* param)
         }
     }
     CHECK(param->rc.dataShareMode != X265_SHARE_MODE_FILE &&
param->rc.dataShareMode != X265_SHARE_MODE_SHAREDMEM, "Invalid data share
mode. It must be one of the X265_DATA_SHARE_MODES enum values\n" );
+#if ENABLE_ALPHA
+    if (param->bEnableAlpha)
+    {
+        CHECK((param->internalCsp != X265_CSP_I420), "Alpha encode
supported only with i420a colorspace");
+        CHECK((param->rc.rateControlMode != X265_RC_CQP), "Alpha encode
supported only with CQP mode");
+    }
+#endif
     return check_failed;
 }

diff --git a/source/common/piclist.cpp b/source/common/piclist.cpp
index 4408d2355..345fd02c9 100644
--- a/source/common/piclist.cpp
+++ b/source/common/piclist.cpp
@@ -230,8 +230,9 @@ void PicList::remove(Frame& curFrame)

 Frame* PicList::removeFrame(Frame& curFrame)
 {
+    Frame* tmp = &curFrame;
 #if _DEBUG
-    Frame* tmp = m_start;
+    tmp = m_start;
     while (tmp && tmp != &curFrame)
     {
         tmp = tmp->m_next;
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index 4844a158c..88dd4b3fb 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -1647,6 +1647,8 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture** pic_out)
                 inFrame[layer]->m_encodeStartTime = x265_mdate();
                 /* Set lowres scencut and satdCost here to aovid
overwriting ANALYSIS_READ
                    decision by lowres init*/
+                int cuCount = inFrame[layer]->m_lowres.maxBlocksInRow *
inFrame[layer]->m_lowres.maxBlocksInCol;
+                memset(inFrame[layer]->m_lowres.intraCost, 0,
sizeof(int32_t) * cuCount);
                 inFrame[layer]->m_lowres.bScenecut = false;
                 inFrame[layer]->m_lowres.satdCost = (int64_t)-1;
                 inFrame[layer]->m_lowresInit = false;
@@ -2156,6 +2158,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture** pic_out)
             frameEnc[0] = m_lookahead->getDecidedPicture();
         if (frameEnc[0] && !pass && (!m_param->chunkEnd ||
(m_encodedFrameNum < m_param->chunkEnd)))
         {
+#if ENABLE_ALPHA
             //Pop non base view pictures from DPB piclist
             for (int layer = 1; layer < m_param->numScalableLayers;
layer++)
             {
@@ -2163,6 +2166,7 @@ int Encoder::encode(const x265_picture* pic_in,
x265_picture** pic_out)
                 frameEnc[layer] =
m_dpb->m_picList.removeFrame(*currentFrame);
                 frameEnc[layer]->m_lowres.sliceType =
frameEnc[0]->m_lowres.sliceType;
             }
+#endif

             if ((m_param->bEnableSceneCutAwareQp & FORWARD) &&
m_param->rc.bStatRead)
             {
diff --git a/source/encoder/entropy.cpp b/source/encoder/entropy.cpp
index cc8c83aea..8a99ba4e5 100644
--- a/source/encoder/entropy.cpp
+++ b/source/encoder/entropy.cpp
@@ -475,7 +475,7 @@ void Entropy::codePPS( const PPS& pps, bool
filerAcross, int iPPSInitQpMinus26,
     WRITE_SVLC(pps.chromaQpOffset[1],      "pps_cr_qp_offset");
     WRITE_FLAG(pps.pps_slice_chroma_qp_offsets_present_flag,
"pps_slice_chroma_qp_offsets_present_flag");

-    WRITE_FLAG(pps.bUseWeightPred,            "weighted_pred_flag");
+    WRITE_FLAG(layer ? 0 : pps.bUseWeightPred,
 "weighted_pred_flag");
     WRITE_FLAG(pps.bUseWeightedBiPred,        "weighted_bipred_flag");
     WRITE_FLAG(pps.bTransquantBypassEnabled,
 "transquant_bypass_enable_flag");
     WRITE_FLAG(0,                             "tiles_enabled_flag");
@@ -829,7 +829,7 @@ void Entropy::codeSliceHeader(const Slice& slice,
FrameData& encData, uint32_t s
             WRITE_UVLC(slice.m_colRefIdx, "collocated_ref_idx");
         }
     }
-    if ((slice.m_pps->bUseWeightPred && slice.m_sliceType == P_SLICE) ||
(slice.m_pps->bUseWeightedBiPred && slice.m_sliceType == B_SLICE))
+    if (((slice.m_pps->bUseWeightPred && slice.m_sliceType == P_SLICE) ||
(slice.m_pps->bUseWeightedBiPred && slice.m_sliceType == B_SLICE)) &&
!layer)
         codePredWeightTable(slice);

     X265_CHECK(slice.m_maxNumMergeCand <= MRG_MAX_NUM_CANDS, "too many
merge candidates\n");
diff --git a/source/encoder/frameencoder.cpp
b/source/encoder/frameencoder.cpp
index 9263a4658..1aab82b77 100644
--- a/source/encoder/frameencoder.cpp
+++ b/source/encoder/frameencoder.cpp
@@ -542,8 +542,8 @@ void FrameEncoder::compressFrame(int layer)
         m_frame[layer]->m_encData->m_slice->m_rpsIdx =
(m_top->m_rateControl->m_rce2Pass + m_frame[layer]->m_encodeOrder)->rpsIdx;

     // Weighted Prediction parameters estimation.
-    bool bUseWeightP = slice->m_sliceType == P_SLICE &&
slice->m_pps->bUseWeightPred;
-    bool bUseWeightB = slice->m_sliceType == B_SLICE &&
slice->m_pps->bUseWeightedBiPred;
+    bool bUseWeightP = slice->m_sliceType == P_SLICE &&
slice->m_pps->bUseWeightPred && !layer;
+    bool bUseWeightB = slice->m_sliceType == B_SLICE &&
slice->m_pps->bUseWeightedBiPred && !layer;

     WeightParam* reuseWP = NULL;
     if (m_param->analysisLoad && (bUseWeightP || bUseWeightB))
diff --git a/source/encoder/search.cpp b/source/encoder/search.cpp
index dab11fc79..001115782 100644
--- a/source/encoder/search.cpp
+++ b/source/encoder/search.cpp
@@ -2102,7 +2102,7 @@ void Search::singleMotionEstimation(Search& master,
Mode& interMode, const Predi
     if (!m_param->analysisSave && !m_param->analysisLoad) /* Prevents
load/save outputs from diverging if lowresMV is not available */
     {
         MV lmv = getLowresMV(interMode.cu, pu, list, ref);
-        if (lmv.notZero())
+        if (lmv.notZero() && !m_frame->m_sLayerId)
             mvc[numMvc++] = lmv;
         if (m_param->bEnableHME)
             mvp_lowres = lmv;
@@ -2413,7 +2413,7 @@ void Search::predInterSearch(Mode& interMode, const
CUGeom& cuGeom, bool bChroma
                     if (!m_param->analysisSave && !m_param->analysisLoad)
/* Prevents load/save outputs from diverging when lowresMV is not available
*/
                     {
                         MV lmv = getLowresMV(cu, pu, list, ref);
-                        if (lmv.notZero())
+                        if (lmv.notZero() && !m_frame->m_sLayerId)
                             mvc[numMvc++] = lmv;
                         if (m_param->bEnableHME)
                             mvp_lowres = lmv;
diff --git a/source/x265cli.cpp b/source/x265cli.cpp
index 6bb81f6d4..1ba0a5877 100755
--- a/source/x265cli.cpp
+++ b/source/x265cli.cpp
@@ -422,7 +422,7 @@ namespace X265_NS {
         if (input)
             input->release();
         input = NULL;
-        for (int i = 0; i < param->numScalableLayers; i++)
+        for (int i = 0; i < MAX_SCALABLE_LAYERS; i++)
         {
             if (recon[i])
                 recon[i]->release();
-- 
2.36.0.windows.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240805/c5fb36b2/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0010-Fix-inconsistent-issue.patch
Type: application/octet-stream
Size: 7497 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240805/c5fb36b2/attachment-0001.obj>


More information about the x265-devel mailing list