[x265] [PATCH] intra: skip RD analysis when sum of sub CU splitcost bigger than non-split cost

Ximing Cheng chengximing1989 at foxmail.com
Fri Jul 14 19:08:46 CEST 2017


command line:
x265 --input BasketballDrive_1920x1080_50.yuv --input-res 1920x1080 --fps 50 --frames 100 --keyint 0 -o test.265
 
before patch 
encoded 100 frames in 57.28s (1.75 fps), 10496.03 kb/s, Avg QP:34.74
after patch
encoded 100 frames in 51.52s (1.94 fps), 10496.03 kb/s, Avg QP:34.74




------------------ Original ------------------
From:  "Ximing Cheng";<chengximing1989 at foxmail.com>;
Send time: Saturday, Jul 15, 2017 1:07 AM
To: "x265-devel"<x265-devel at videolan.org>; 

Subject:  [x265] [PATCH] intra: skip RD analysis when sum of sub CU splitcost bigger than non-split cost



# HG changeset patch
# User Ximing Cheng <ximingcheng at tencent.com>
# Date 1500052036 -28800
#      Sat Jul 15 01:07:16 2017 +0800
# Node ID 9c2e9f6c6ee73e75b94c2e52f85a64bca628baf0
# Parent  3f6841d271e36dc324936f09846d1f2cb77c63e5
intra: skip RD analysis when sum of sub CU split cost bigger than non-split cost
This patch will speed up all intra case with almost no BDRATE loss

diff -r 3f6841d271e3 -r 9c2e9f6c6ee7 source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp	Wed Jun 28 10:44:19 2017 +0530
+++ b/source/encoder/analysis.cpp	Sat Jul 15 01:07:16 2017 +0800
@@ -485,7 +485,7 @@
     md.bestMode->reconYuv.copyToPicYuv(*m_frame->m_reconPic, parentCTU.m_cuAddr, cuGeom.absPartIdx);
 }
 
-void Analysis::compressIntraCU(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp)
+uint64_t Analysis::compressIntraCU(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp)
 {
     uint32_t depth = cuGeom.depth;
     ModeDepth& md = m_modeDepth[depth];
@@ -561,6 +561,9 @@
         Entropy* nextContext = &m_rqt[depth].cur;
         int32_t nextQP = qp;
 
+        uint64_t curCost = 0;
+        int skipSplitCheck = 0;
+
         for (uint32_t subPartIdx = 0; subPartIdx < 4; subPartIdx++)
         {
             const CUGeom& childGeom = *(&cuGeom + cuGeom.childOffset + subPartIdx);
@@ -572,7 +575,12 @@
                 if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)
                     nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(parentCTU, childGeom));
 
-                compressIntraCU(parentCTU, childGeom, nextQP);
+                curCost += compressIntraCU(parentCTU, childGeom, nextQP);
+                if (m_modeDepth[depth].bestMode && curCost > m_modeDepth[depth].bestMode->rdCost)
+                {
+                    skipSplitCheck = 1;
+                    break;
+                }
 
                 // Save best CU and pred data for this sub CU
                 splitCU->copyPartFrom(nd.bestMode->cu, childGeom, subPartIdx);
@@ -590,14 +598,18 @@
                     memset(parentCTU.m_cuDepth + childGeom.absPartIdx, 0, childGeom.numPartitions);
             }
         }
-        nextContext->store(splitPred->contexts);
-        if (mightNotSplit)
-            addSplitFlagCost(*splitPred, cuGeom.depth);
-        else
-            updateModeCost(*splitPred);
-
-        checkDQPForSplitPred(*splitPred, cuGeom);
-        checkBestMode(*splitPred, depth);
+
+        if (!skipSplitCheck)
+        {
+            nextContext->store(splitPred->contexts);
+            if (mightNotSplit)
+                addSplitFlagCost(*splitPred, cuGeom.depth);
+            else
+                updateModeCost(*splitPred);
+
+            checkDQPForSplitPred(*splitPred, cuGeom);
+            checkBestMode(*splitPred, depth);
+        }
     }
 
     if (m_param->bEnableRdRefine && depth <= m_slice->m_pps->maxCuDQPDepth)
@@ -620,6 +632,8 @@
     md.bestMode->cu.copyToPic(depth);
     if (md.bestMode != &md.pred[PRED_SPLIT])
         md.bestMode->reconYuv.copyToPicYuv(*m_frame->m_reconPic, parentCTU.m_cuAddr, cuGeom.absPartIdx);
+
+    return md.bestMode->rdCost;
 }
 
 void Analysis::PMODE::processTasks(int workerThreadId)
diff -r 3f6841d271e3 -r 9c2e9f6c6ee7 source/encoder/analysis.h
--- a/source/encoder/analysis.h	Wed Jun 28 10:44:19 2017 +0530
+++ b/source/encoder/analysis.h	Sat Jul 15 01:07:16 2017 +0800
@@ -145,7 +145,7 @@
     void qprdRefine(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp, int32_t lqp);
 
     /* full analysis for an I-slice CU */
-    void compressIntraCU(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp);
+    uint64_t compressIntraCU(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp);
 
     /* full analysis for a P or B slice CU */
     uint32_t compressInterCU_dist(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp);


_______________________________________________
x265-devel mailing list
x265-devel at videolan.org
https://mailman.videolan.org/listinfo/x265-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20170715/449415f0/attachment.html>


More information about the x265-devel mailing list