<div dir="ltr">From 416d9fe5c6dc905fb6e6204fd268682ef1760964 Mon Sep 17 00:00:00 2001<br>From: Kirithika <<a href="mailto:kirithika@multicorewareinc.com">kirithika@multicorewareinc.com</a>><br>Date: Thu, 14 Dec 2023 17:17:02 +0530<br>Subject: [PATCH] Fix broken lookahead configuration with Qp file<br><br>---<br> source/common/lowres.h       | 1 +<br> source/encoder/encoder.cpp   | 3 ++-<br> source/encoder/slicetype.cpp | 2 ++<br> 3 files changed, 5 insertions(+), 1 deletion(-)<br><br>diff --git a/source/common/lowres.h b/source/common/lowres.h<br>index 60fb40286..4d29ab695 100644<br>--- a/source/common/lowres.h<br>+++ b/source/common/lowres.h<br>@@ -171,6 +171,7 @@ struct Lowres : public ReferencePlanes<br> <br>     int    frameNum;         // Presentation frame number<br>     int    sliceType;        // Slice type decided by lookahead<br>+    int    sliceTypeReq;     // Slice type required as per the QP file<br>     int    width;            // width of lowres frame in pixels<br>     int    lines;            // height of lowres frame in pixel lines<br>     int    leadingBframes;   // number of leading B frames for P or I<br>diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp<br>index c516e1a2c..880b4f16d 100644<br>--- a/source/encoder/encoder.cpp<br>+++ b/source/encoder/encoder.cpp<br>@@ -2191,7 +2191,8 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture* pic_out, x265_pict<br>         }<br> <br>         /* Use the frame types from the first pass, if available */<br>-        int sliceType = (m_param->rc.bStatRead) ? m_rateControl->rateControlSliceType(inFrame->m_poc) : inputPic->sliceType;<br>+        int sliceType = (m_param->rc.bStatRead) ? m_rateControl->rateControlSliceType(inFrame->m_poc) : X265_TYPE_AUTO;<br>+        inFrame->m_lowres.sliceTypeReq = inputPic->sliceType;<br> <br>         /* In analysisSave mode, x265_analysis_data is allocated in inputPic and inFrame points to this */<br>         /* Load analysis data before lookahead->addPicture, since sliceType has been decided */<br>diff --git a/source/encoder/slicetype.cpp b/source/encoder/slicetype.cpp<br>index 1e8f339a2..74d7d040c 100644<br>--- a/source/encoder/slicetype.cpp<br>+++ b/source/encoder/slicetype.cpp<br>@@ -1583,6 +1583,8 @@ void Lookahead::slicetypeDecide()<br>         {<br>             Lowres& frm = list[bframes]->m_lowres;<br> <br>+            if (frm.sliceTypeReq != X265_TYPE_AUTO && frm.sliceTypeReq != frm.sliceType)<br>+                frm.sliceType = frm.sliceTypeReq;<br>             if (frm.sliceType == X265_TYPE_BREF && !m_param->bBPyramid && brefs == m_param->bBPyramid)<br>             {<br>                 frm.sliceType = X265_TYPE_B;<br>-- <br>2.28.0.windows.1<br><br><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><i>Thanks,</i><div><i>Kirithika</i></div></div></div></div></div>