<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">From a64a8603f8f5efb63be2e9c8d64dae02ab25acb4 Mon Sep 17 00:00:00 2001<br>From: AnusuyaKumarasamy <<a href="mailto:anusuya.kumarasamy@multicorewareinc.com">anusuya.kumarasamy@multicorewareinc.com</a>><br>Date: Thu, 14 Nov 2024 22:15:22 -0800<br>Subject: [PATCH] Decouple Abr-ladder and multiview flow<br><br>---<br>Â source/abrEncApp.cpp | 68 +++++++++++++++++++++++++-------------------<br>Â 1 file changed, 38 insertions(+), 30 deletions(-)<br><br>diff --git a/source/abrEncApp.cpp b/source/abrEncApp.cpp<br>index 1907e0bfb..66787ff11 100644<br>--- a/source/abrEncApp.cpp<br>+++ b/source/abrEncApp.cpp<br>@@ -78,10 +78,11 @@ namespace X265_NS {<br>Â Â Â bool AbrEncoder::allocBuffers()<br>Â Â Â {<br>Â #if ENABLE_MULTIVIEW<br>- Â Â Â Â m_inputPicBuffer = X265_MALLOC(x265_picture**, MAX_VIEWS);<br>-#else<br>- Â Â Â Â m_inputPicBuffer = X265_MALLOC(x265_picture**, m_numEncodes);<br>+ Â Â Â Â if(m_numInputViews > 1)<br>+ Â Â Â Â Â Â m_inputPicBuffer = X265_MALLOC(x265_picture**, MAX_VIEWS);<br>+ Â Â Â Â else<br>Â #endif<br>+ Â Â Â Â Â Â m_inputPicBuffer = X265_MALLOC(x265_picture**, m_numEncodes);<br>Â Â Â Â Â m_analysisBuffer = X265_MALLOC(x265_analysis_data*, m_numEncodes);<br>Â <br>Â Â Â Â Â m_picWriteCnt = new ThreadSafeInteger[m_numEncodes];<br>@@ -145,17 +146,42 @@ namespace X265_NS {<br>Â Â Â {<br>Â Â Â Â Â x265_cleanup(); /* Free library singletons */<br>Â #if ENABLE_MULTIVIEW<br>- Â Â Â Â for (uint8_t pass = 0; pass < m_numInputViews; pass++)<br>+ Â Â Â Â if(m_numInputViews > 1)<br>Â Â Â Â Â {<br>- Â Â Â Â Â Â for (uint32_t index = 0; index < m_queueSize; index++)<br>+ Â Â Â Â Â Â for (uint8_t pass = 0; pass < m_numInputViews; pass++)<br>Â Â Â Â Â Â Â {<br>- Â Â Â Â Â Â Â Â X265_FREE(m_inputPicBuffer[pass][index]->planes[0]);<br>- Â Â Â Â Â Â Â Â x265_picture_free(m_inputPicBuffer[pass][index]);<br>- Â Â Â Â Â Â }<br>- Â Â Â Â Â Â X265_FREE(m_inputPicBuffer[pass]);<br>+ Â Â Â Â Â Â Â Â for (uint32_t index = 0; index < m_queueSize; index++)<br>+ Â Â Â Â Â Â Â Â {<br>+ Â Â Â Â Â Â Â Â Â Â X265_FREE(m_inputPicBuffer[pass][index]->planes[0]);<br>+ Â Â Â Â Â Â Â Â Â Â x265_picture_free(m_inputPicBuffer[pass][index]);<br>+ Â Â Â Â Â Â Â Â }<br>+ Â Â Â Â Â Â Â Â X265_FREE(m_inputPicBuffer[pass]);<br>Â <br>- Â Â Â Â Â Â if (pass == 0)<br>+ Â Â Â Â Â Â Â Â if (pass == 0)<br>+ Â Â Â Â Â Â Â Â {<br>+ Â Â Â Â Â Â Â Â Â Â X265_FREE(m_analysisBuffer[pass]);<br>+ Â Â Â Â Â Â Â Â Â Â X265_FREE(m_readFlag[pass]);<br>+ Â Â Â Â Â Â Â Â Â Â delete[] m_picIdxReadCnt[pass];<br>+ Â Â Â Â Â Â Â Â Â Â delete[] m_analysisWrite[pass];<br>+ Â Â Â Â Â Â Â Â Â Â delete[] m_analysisRead[pass];<br>+ Â Â Â Â Â Â Â Â Â Â m_passEnc[pass]->destroy();<br>+ Â Â Â Â Â Â Â Â Â Â delete m_passEnc[pass];<br>+ Â Â Â Â Â Â Â Â }<br>+ Â Â Â Â Â Â }<br>+ Â Â Â Â }<br>+ Â Â Â Â else<br>+ Â Â Â Â {<br>+#endif<br>+ Â Â Â Â Â Â for (uint8_t pass = 0; pass < m_numEncodes; pass++)<br>Â Â Â Â Â Â Â {<br>+ Â Â Â Â Â Â Â Â for (uint32_t index = 0; index < m_queueSize; index++)<br>+ Â Â Â Â Â Â Â Â {<br>+ Â Â Â Â Â Â Â Â Â Â X265_FREE(m_inputPicBuffer[pass][index]->planes[0]);<br>+ Â Â Â Â Â Â Â Â Â Â x265_picture_free(m_inputPicBuffer[pass][index]);<br>+ Â Â Â Â Â Â Â Â Â Â X265_FREE(m_analysisBuffer[pass][index].wt);<br>+ Â Â Â Â Â Â Â Â }<br>+ Â Â Â Â Â Â Â Â X265_FREE(m_inputPicBuffer[pass]);<br>+<br>Â Â Â Â Â Â Â Â Â X265_FREE(m_analysisBuffer[pass]);<br>Â Â Â Â Â Â Â Â Â X265_FREE(m_readFlag[pass]);<br>Â Â Â Â Â Â Â Â Â delete[] m_picIdxReadCnt[pass];<br>@@ -164,25 +190,7 @@ namespace X265_NS {<br>Â Â Â Â Â Â Â Â Â m_passEnc[pass]->destroy();<br>Â Â Â Â Â Â Â Â Â delete m_passEnc[pass];<br>Â Â Â Â Â Â Â }<br>- Â Â Â Â }<br>-#else<br>- Â Â Â Â for (uint8_t pass = 0; pass < m_numEncodes; pass++)<br>- Â Â Â Â {<br>- Â Â Â Â Â Â for (uint32_t index = 0; index < m_queueSize; index++)<br>- Â Â Â Â Â Â {<br>- Â Â Â Â Â Â Â Â X265_FREE(m_inputPicBuffer[pass][index]->planes[0]);<br>- Â Â Â Â Â Â Â Â x265_picture_free(m_inputPicBuffer[pass][index]);<br>- Â Â Â Â Â Â Â Â X265_FREE(m_analysisBuffer[pass][index].wt);<br>- Â Â Â Â Â Â }<br>- Â Â Â Â Â Â X265_FREE(m_inputPicBuffer[pass]);<br>-<br>- Â Â Â Â Â Â X265_FREE(m_analysisBuffer[pass]);<br>- Â Â Â Â Â Â X265_FREE(m_readFlag[pass]);<br>- Â Â Â Â Â Â delete[] m_picIdxReadCnt[pass];<br>- Â Â Â Â Â Â delete[] m_analysisWrite[pass];<br>- Â Â Â Â Â Â delete[] m_analysisRead[pass];<br>- Â Â Â Â Â Â m_passEnc[pass]->destroy();<br>- Â Â Â Â Â Â delete m_passEnc[pass];<br>+#if ENABLE_MULTIVIEW<br>Â Â Â Â Â }<br>Â #endif<br>Â Â Â Â Â X265_FREE(m_inputPicBuffer);<br>@@ -1158,7 +1166,7 @@ ret:<br>Â <br>Â Â Â Â Â Â Â for (int view = 0; view < m_parentEnc->m_param->numViews - !!m_parentEnc->m_param->format; view++)<br>Â Â Â Â Â Â Â {<br>- Â Â Â Â Â Â Â Â x265_picture* dest = m_parentEnc->m_parent->m_inputPicBuffer[view][writeIdx];<br>+ Â Â Â Â Â Â Â Â x265_picture* dest = (m_parentEnc->m_param->numViews > 1) ? m_parentEnc->m_parent->m_inputPicBuffer[view][writeIdx] : m_parentEnc->m_parent->m_inputPicBuffer[m_id][writeIdx];<br>Â Â Â Â Â Â Â Â Â src->format = m_parentEnc->m_param->format;<br>Â Â Â Â Â Â Â Â Â if (m_input[view]->readPicture(*src))<br>Â Â Â Â Â Â Â Â Â {<br>-- <br>2.36.0.windows.1<br><br></div></div>