<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 14, 2017 at 10:38 PM, Ximing Cheng <span dir="ltr"><<a href="mailto:chengximing1989@foxmail.com" target="_blank">chengximing1989@foxmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>command line:</div><div>x265 --input BasketballDrive_1920x1080_50.<wbr>yuv --input-res 1920x1080 --fps 50 --frames 100 --keyint 0 -o test.265</div><div> </div><div>before patch </div><div>encoded 100 frames in 57.28s (1.75 fps), 10496.03 kb/s, Avg QP:34.74</div><div>after patch</div><div>encoded 100 frames in 51.52s (1.94 fps), 10496.03 kb/s, Avg QP:34.74</div></blockquote><div><br></div><div>Thanks for your test data. Looks like this is an intra-only optimization. Could you please share more results with longer test sequences at different resolutions, if you have them? We can also run additional tests before considering this improvement if the results are more wide-spread.</div><div><br></div><div>Also, please add a new param field and cli option that may be used to exercise this. It is always better to do this instead of affect default encodes with such performance optimizations. They param should be off by default, and if we can clearly see the benefits to <i>all possible encodes</i> for a given preset, then we can consider enabling that optimization for that given preset.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><br></div><div><br></div><div style="font-size:12px;font-family:Arial Narrow;padding:2px 0 2px 0">------------------ Original --<wbr>----------------</div><div style="font-size:12px;background:#efefef;padding:8px"><div><b>From: </b> "Ximing Cheng";<<a href="mailto:chengximing1989@foxmail.com" target="_blank">chengximing1989@<wbr>foxmail.com</a>>;</div><div><b>Send time:</b> Saturday, Jul 15, 2017 1:07 AM</div><div><b>To:</b> "x265-devel"<<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@<wbr>videolan.org</a>>; </div><div></div><div><b>Subject: </b> [x265] [PATCH] intra: skip RD analysis when sum of sub CU splitcost bigger than non-split cost</div></div><div><div class="h5"><div><br></div># HG changeset patch<br># User Ximing Cheng <<a href="mailto:ximingcheng@tencent.com" target="_blank">ximingcheng@tencent.com</a>><br># Date 1500052036 -28800<br>#      Sat Jul 15 01:07:16 2017 +0800<br># Node ID 9c2e9f6c6ee73e75b94c2e52f85a64<wbr>bca628baf0<br># Parent  3f6841d271e36dc324936f09846d1f<wbr>2cb77c63e5<br>intra: skip RD analysis when sum of sub CU split cost bigger than non-split cost<br>This patch will speed up all intra case with almost no BDRATE loss<br><br>diff -r 3f6841d271e3 -r 9c2e9f6c6ee7 source/encoder/analysis.cpp<br>--- a/source/encoder/analysis.cpp  Wed Jun 28 10:44:19 2017 +0530<br>+++ b/source/encoder/analysis.cpp       Sat Jul 15 01:07:16 2017 +0800<br>@@ -485,7 +485,7 @@<br>     md.bestMode->reconYuv.<wbr>copyToPicYuv(*m_frame->m_<wbr>reconPic, parentCTU.m_cuAddr, cuGeom.absPartIdx);<br> }<br> <br>-void Analysis::compressIntraCU(<wbr>const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp)<br>+uint64_t Analysis::compressIntraCU(<wbr>const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp)<br> {<br>     uint32_t depth = cuGeom.depth;<br>     ModeDepth& md = m_modeDepth[depth];<br>@@ -561,6 +561,9 @@<br>         Entropy* nextContext = &m_rqt[depth].cur;<br>         int32_t nextQP = qp;<br> <br>+        uint64_t curCost = 0;<br>+        int skipSplitCheck = 0;<br>+<br>         for (uint32_t subPartIdx = 0; subPartIdx < 4; subPartIdx++)<br>         {<br>             const CUGeom& childGeom = *(&cuGeom + cuGeom.childOffset + subPartIdx);<br>@@ -572,7 +575,12 @@<br>                 if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)<br>                     nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(<wbr>parentCTU, childGeom));<br> <br>-                compressIntraCU(parentCTU, childGeom, nextQP);<br>+                curCost += compressIntraCU(parentCTU, childGeom, nextQP);<br>+                if (m_modeDepth[depth].bestMode && curCost > m_modeDepth[depth].bestMode-><wbr>rdCost)<br>+                {<br>+                    skipSplitCheck = 1;<br>+                    break;<br>+                }<br> <br>                 // Save best CU and pred data for this sub CU<br>                 splitCU->copyPartFrom(nd.<wbr>bestMode->cu, childGeom, subPartIdx);<br>@@ -590,14 +598,18 @@<br>                     memset(parentCTU.m_cuDepth + childGeom.absPartIdx, 0, childGeom.numPartitions);<br>             }<br>         }<br>-        nextContext->store(splitPred-><wbr>contexts);<br>-        if (mightNotSplit)<br>-            addSplitFlagCost(*splitPred, cuGeom.depth);<br>-        else<br>-            updateModeCost(*splitPred);<br>-<br>-        checkDQPForSplitPred(*<wbr>splitPred, cuGeom);<br>-        checkBestMode(*splitPred, depth);<br>+<br>+        if (!skipSplitCheck)<br>+        {<br>+            nextContext->store(splitPred-><wbr>contexts);<br>+            if (mightNotSplit)<br>+                addSplitFlagCost(*splitPred, cuGeom.depth);<br>+            else<br>+                updateModeCost(*splitPred);<br>+<br>+            checkDQPForSplitPred(*<wbr>splitPred, cuGeom);<br>+            checkBestMode(*splitPred, depth);<br>+        }<br>     }<br> <br>     if (m_param->bEnableRdRefine && depth <= m_slice->m_pps->maxCuDQPDepth)<br>@@ -620,6 +632,8 @@<br>     md.bestMode->cu.copyToPic(<wbr>depth);<br>     if (md.bestMode != &md.pred[PRED_SPLIT])<br>         md.bestMode->reconYuv.<wbr>copyToPicYuv(*m_frame->m_<wbr>reconPic, parentCTU.m_cuAddr, cuGeom.absPartIdx);<br>+<br>+    return md.bestMode->rdCost;<br> }<br> <br> void Analysis::PMODE::processTasks(<wbr>int workerThreadId)<br>diff -r 3f6841d271e3 -r 9c2e9f6c6ee7 source/encoder/analysis.h<br>--- a/source/encoder/analysis.h  Wed Jun 28 10:44:19 2017 +0530<br>+++ b/source/encoder/analysis.h Sat Jul 15 01:07:16 2017 +0800<br>@@ -145,7 +145,7 @@<br>     void qprdRefine(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp, int32_t lqp);<br> <br>     /* full analysis for an I-slice CU */<br>-    void compressIntraCU(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp);<br>+    uint64_t compressIntraCU(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp);<br> <br>     /* full analysis for a P or B slice CU */<br>     uint32_t compressInterCU_dist(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp);<br><br><br>______________________________<wbr>_________________<br>x265-devel mailing list<br><a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br><a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/<wbr>listinfo/x265-devel</a><br></div></div></div><br>______________________________<wbr>_________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/<wbr>listinfo/x265-devel</a><br>
<br></blockquote></div><br></div></div>