<div dir="ltr"><div dir="ltr"><div>From 876a66a23aa4e6e8ed055073b774039ac9bd447a Mon Sep 17 00:00:00 2001</div><div>From: yaswanthsastry <<a href="mailto:yaswanth.sastry@multicorewareinc.com">yaswanth.sastry@multicorewareinc.com</a>></div><div>Date: Thu, 3 Oct 2024 16:24:50 +0530</div><div>Subject: [PATCH] Fix Initialization of VBV-End Flag error with multiple layers</div><div><br></div><div>---</div><div> source/encoder/encoder.cpp     | 2 +-</div><div> source/encoder/ratecontrol.cpp | 2 +-</div><div> 2 files changed, 2 insertions(+), 2 deletions(-)</div><div><br></div><div>diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp</div><div>index f890cff10..ff3f2f8e5 100644</div><div>--- a/source/encoder/encoder.cpp</div><div>+++ b/source/encoder/encoder.cpp</div><div>@@ -1713,7 +1713,7 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture** pic_out)</div><div>             inFrame[layer]->m_poc = (!layer) ? (++m_pocLast) : m_pocLast;</div><div>             inFrame[layer]->m_userData = inputPic[0]->userData;</div><div>             inFrame[layer]->m_pts = inputPic[0]->pts;</div><div>-              inFrame[layer]->vbvEndFlag = inputPic[layer]->vbvEndFlag;</div><div>+            inFrame[layer]->vbvEndFlag = inputPic[0]->vbvEndFlag;</div><div> </div><div>             if ((m_param->bEnableSceneCutAwareQp & BACKWARD) && m_param->rc.bStatRead)</div><div>             {</div><div>diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp</div><div>index fc79e88ab..d031e8d99 100644</div><div>--- a/source/encoder/ratecontrol.cpp</div><div>+++ b/source/encoder/ratecontrol.cpp</div><div>@@ -1466,7 +1466,7 @@ int RateControl::rateControlStart(Frame* curFrame, RateControlEntry* rce, Encode</div><div>          if (m_param->vbvBufferEnd && ((curFrame->vbvEndFlag) || ((m_param->totalFrames) && (rce->encodeOrder >= (m_param->vbvEndFrameAdjust * m_param->totalFrames)))))</div><div>          {</div><div>               if (m_totalFrames == -1)</div><div>-                   m_totalFrames = curFrame->vbvEndFlag ? (1 / m_param->vbvEndFrameAdjust) * rce->encodeOrder : m_param->totalFrames;</div><div>+<span style="white-space:pre">                            </span>m_totalFrames = curFrame->vbvEndFlag ? static_cast<int>((1 / m_param->vbvEndFrameAdjust) * rce->encodeOrder) : m_param->totalFrames;</div><div>               rce->remainingVbvEndFrames = ((m_totalFrames) - (rce->encodeOrder));</div><div>               rce->vbvEndAdj = true;</div><div>               rce->targetFill = 0;</div><div>-- </div><div>2.37.3.windows.1</div><div><br></div></div></div>