<div dir="ltr">From b5d9bc355bb68cd789679f1f6c0c27286b4fa6e5 Mon Sep 17 00:00:00 2001<br>From: AnusuyaKumarasamy <<a href="mailto:anusuya.kumarasamy@multicorewareinc.com">anusuya.kumarasamy@multicorewareinc.com</a>><br>Date: Tue, 10 Sep 2024 16:37:51 +0530<br>Subject: [PATCH]  Fix issue in default code flow & memory leak<br><br>---<br> source/encoder/dpb.cpp |  7 ++++++-<br> source/x265cli.cpp     | 11 ++++++++++-<br> 2 files changed, 16 insertions(+), 2 deletions(-)<br><br>diff --git a/source/encoder/dpb.cpp b/source/encoder/dpb.cpp<br>index 19480d7ca..caf73ad6d 100644<br>--- a/source/encoder/dpb.cpp<br>+++ b/source/encoder/dpb.cpp<br>@@ -289,7 +289,12 @@ void DPB::prepareEncode(Frame *newFrame)<br>         slice->m_numRefIdx[0] = x265_clip3(1, newFrame->m_param->maxNumReferences, numRef + newFrame->refPicSetInterLayer0.size() + newFrame->refPicSetInterLayer1.size());<br>     else<br>         slice->m_numRefIdx[0] = X265_MIN(newFrame->m_param->maxNumReferences, numRef); // Ensuring L0 contains just the -ve POC<br>-    slice->m_numRefIdx[1] = X265_MIN(newFrame->m_param->bBPyramid ? 3 : 2, slice->m_rps.numberOfPositivePictures + newFrame->refPicSetInterLayer0.size() + newFrame->refPicSetInterLayer1.size());<br>+#if ENABLE_MULTIVIEW || ENABLE_SCC_EXT<br>+    if(slice->m_param->numViews > 1 || !!slice->m_param->bEnableSCC)<br>+        slice->m_numRefIdx[1] = X265_MIN(newFrame->m_param->bBPyramid ? 3 : 2, slice->m_rps.numberOfPositivePictures + newFrame->refPicSetInterLayer0.size() + newFrame->refPicSetInterLayer1.size());<br>+    else<br>+#endif<br>+        slice->m_numRefIdx[1] = X265_MIN(newFrame->m_param->bBPyramid ? 2 : 1, slice->m_rps.numberOfPositivePictures);<br>     slice->setRefPicList(m_picList, newFrame->refPicSetInterLayer0, newFrame->refPicSetInterLayer1, layer);<br> <br>     X265_CHECK(slice->m_sliceType != B_SLICE || slice->m_numRefIdx[1], "B slice without L1 references (non-fatal)\n");<br>diff --git a/source/x265cli.cpp b/source/x265cli.cpp<br>index 89852c701..ca7d9c973 100755<br>--- a/source/x265cli.cpp<br>+++ b/source/x265cli.cpp<br>@@ -738,7 +738,7 @@ namespace X265_NS {<br>                 OPT("frames") this->framesToBeEncoded = (uint32_t)x265_atoi(optarg, bError);<br>                 OPT("no-progress") this->bProgress = false;<br>                 OPT("output") outputfn = optarg;<br>-                OPT("input") inputfn[0] = optarg;<br>+                OPT("input") strcpy(inputfn[0] , optarg);<br>                 OPT("recon") reconfn[0] = optarg;<br>                 OPT("input-depth") inputBitDepth = (uint32_t)x265_atoi(optarg, bError);<br>                 OPT("dither") this->bDither = true;<br>@@ -1034,6 +1034,15 @@ namespace X265_NS {<br>             return true;<br>         }<br>         general_log_file(param, this->output->getName(), X265_LOG_INFO, "output file: %s\n", outputfn);<br>+<br>+        for (int view = 0; view < MAX_VIEWS; view++)<br>+        {<br>+            if (inputfn[view] != NULL)<br>+            {<br>+                X265_FREE(inputfn[view]);<br>+                inputfn[view] = NULL;<br>+            }<br>+        }<br>         return false;<br>     }<br> <br>-- <br>2.36.0.windows.1<br><br></div>