[x265] [PATCH] Add BBAQ to CRF and fix qgSize 0 issue

Niranjan Bala niranjan at multicorewareinc.com
Sun Dec 11 16:13:06 UTC 2022


>From 78c8921a5f48615dc7184cc4030c4e400e55ff76 Mon Sep 17 00:00:00 2001
From: Niranjan Kumar <niranjan at multicorewareinc.com>
Date: Mon, 31 Oct 2022 00:48:22 +0530
Subject: [PATCH] Add BBAQ to CRF and fix qgSize 0 issue

---
 source/common/lowres.cpp       |  2 +-
 source/encoder/ratecontrol.cpp | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/source/common/lowres.cpp b/source/common/lowres.cpp
index 16ff02509..97ed7b0cd 100644
--- a/source/common/lowres.cpp
+++ b/source/common/lowres.cpp
@@ -95,7 +95,7 @@ bool Lowres::create(x265_param* param, PicYuv *origPic,
uint32_t qgSize)

     size_t planesize = lumaStride * (lines + 2 * origPic->m_lumaMarginY);
     size_t padoffset = lumaStride * origPic->m_lumaMarginY +
origPic->m_lumaMarginX;
-    if (!!param->rc.aqMode || !!param->rc.hevcAq || !!param->bAQMotion)
+    if (!!param->rc.aqMode || !!param->rc.hevcAq || !!param->bAQMotion ||
!!param->bEnableWeightedPred || !!param->bEnableWeightedBiPred)
     {
         CHECKED_MALLOC_ZERO(qpAqOffset, double, cuCountFullRes);
         CHECKED_MALLOC_ZERO(invQscaleFactor, int, cuCountFullRes);
diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp
index 7e0dfe054..3defaf8bf 100644
--- a/source/encoder/ratecontrol.cpp
+++ b/source/encoder/ratecontrol.cpp
@@ -1475,6 +1475,16 @@ int RateControl::rateControlStart(Frame* curFrame,
RateControlEntry* rce, Encode
         if (!m_param->rc.bEncFocusedFramesOnly)
         {
             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/20221211/d6aa6b26/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AddBBAQtoCRF.diff
Type: application/octet-stream
Size: 2299 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20221211/d6aa6b26/attachment.obj>


More information about the x265-devel mailing list