[x265] [X265][PATCH] Enable --scenecut-aware-qp with --crf in pass 2

Niranjan Bala niranjan at multicorewareinc.com
Thu Feb 11 05:03:33 UTC 2021


>From 1fcf5d6b962a2533e1bc459a3d43b8b4a0a6a100 Mon Sep 17 00:00:00 2001
From: Niranjan <niranjan at multicorewareinc.com>
Date: Wed, 10 Feb 2021 01:07:39 +0530
Subject: [PATCH] Enable --scenecut-aware-qp with --crf in pass 2

---
 source/encoder/ratecontrol.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp
index a4756de39..9c7b6132b 100644
--- a/source/encoder/ratecontrol.cpp
+++ b/source/encoder/ratecontrol.cpp
@@ -1394,6 +1394,16 @@ int RateControl::rateControlStart(Frame* curFrame,
RateControlEntry* rce, Encode
     if (!m_isAbr && m_2pass && m_param->rc.rateControlMode == X265_RC_CRF)
     {
         rce->qpPrev = x265_qScale2qp(rce->qScale);
+        if (m_param->bEnableSceneCutAwareQp)
+        {
+            double lqmin = m_lmin[m_sliceType];
+            double lqmax = m_lmax[m_sliceType];
+            if (m_param->bEnableSceneCutAwareQp & FORWARD)
+                rce->newQScale = forwardMasking(curFrame, rce->newQScale);
+            if (m_param->bEnableSceneCutAwareQp & BACKWARD)
+                rce->newQScale = backwardMasking(curFrame, rce->newQScale);
+            rce->newQScale = x265_clip3(lqmin, lqmax, rce->newQScale);
+        }
         rce->qScale = rce->newQScale;
         rce->qpaRc = curEncData.m_avgQpRc = curEncData.m_avgQpAq =
x265_qScale2qp(rce->newQScale);
         m_qp = int(rce->qpaRc + 0.5);
-- 
2.18.0.windows.1


-- 

Thanks & Regards
*Niranjan Kumar B*
Video Codec Engineer
Media & AI Analytics
+91 958 511 1449
<https://multicorewareinc.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20210211/554421f3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265.diff
Type: application/octet-stream
Size: 1445 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20210211/554421f3/attachment.obj>


More information about the x265-devel mailing list