[x265] [PATCH] no-rdo: cleanups. Remove unnecessary memsets, rearrange computations

deepthidevaki at multicorewareinc.com deepthidevaki at multicorewareinc.com
Mon Nov 11 11:16:46 CET 2013


# HG changeset patch
# User Deepthi Devaki <deepthidevaki at multicorewareinc.com>
# Date 1384164960 -19800
# Node ID c4fea7f56081b96877cc01aae0cb3bcd47169bb6
# Parent  8ca334701a92f895f0750c80f638189ce0d3cf97
no-rdo: cleanups. Remove unnecessary memsets, rearrange computations.

diff -r 8ca334701a92 -r c4fea7f56081 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Mon Nov 11 14:34:27 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Mon Nov 11 15:46:00 2013 +0530
@@ -1610,7 +1610,7 @@
                 // Filtered and Unfiltered refAbove and refLeft pointing to above and left.
                 above         = aboveScale;
                 left          = leftScale;
-                aboveFiltered = aboveScale; 
+                aboveFiltered = aboveScale;
                 leftFiltered  = leftScale;
             }
 
@@ -2940,34 +2940,29 @@
     if (zerocost < cost)
     {
         const uint32_t qpartnum = cu->getPic()->getNumPartInCU() >> (cu->getDepth(0) << 1);
-        ::memset(cu->getTransformIdx(), 0, qpartnum * sizeof(UChar));
         ::memset(cu->getCbf(TEXT_LUMA), 0, qpartnum * sizeof(UChar));
         ::memset(cu->getCbf(TEXT_CHROMA_U), 0, qpartnum * sizeof(UChar));
         ::memset(cu->getCbf(TEXT_CHROMA_V), 0, qpartnum * sizeof(UChar));
-        ::memset(cu->getCoeffY(), 0, width * height * sizeof(TCoeff));
-        ::memset(cu->getCoeffCb(), 0, width * height * sizeof(TCoeff) >> 2);
-        ::memset(cu->getCoeffCr(), 0, width * height * sizeof(TCoeff) >> 2);
-        cu->setTransformSkipSubParts(0, 0, 0, 0, cu->getDepth(0));
         if (cu->getMergeFlag(0) && cu->getPartitionSize(0) == SIZE_2Nx2N)
         {
-            cu->setSkipFlagSubParts(true, 0, cu->getDepth(0));
+            cu->getSkipFlag()[0] = true;
         }
         bits = zerobits;
-        outBestResiYuv->clear();
         generateRecon(cu, predYuv, outBestResiYuv, outReconYuv, true);
+        distortion = zerodistortion;
     }
     else
     {
         xSetResidualQTData(cu, 0, 0, outBestResiYuv, cu->getDepth(0), true);
         generateRecon(cu, predYuv, outBestResiYuv, outReconYuv, false);
+
+        int part = partitionFromSizes(width, height);
+        distortion = primitives.sse_pp[part](fencYuv->getLumaAddr(), fencYuv->getStride(), outReconYuv->getLumaAddr(), outReconYuv->getStride());
+        part = partitionFromSizes(width >> 1, height >> 1);
+        distortion += m_rdCost->scaleChromaDistCb(primitives.sse_pp[part](fencYuv->getCbAddr(), fencYuv->getCStride(), outReconYuv->getCbAddr(), outReconYuv->getCStride()));
+        distortion += m_rdCost->scaleChromaDistCr(primitives.sse_pp[part](fencYuv->getCrAddr(), fencYuv->getCStride(), outReconYuv->getCrAddr(), outReconYuv->getCStride()));
     }
 
-    int part = partitionFromSizes(width, height);
-    distortion = primitives.sse_pp[part](fencYuv->getLumaAddr(), fencYuv->getStride(), outReconYuv->getLumaAddr(), outReconYuv->getStride());
-    part = partitionFromSizes(width >> 1, height >> 1);
-    distortion += m_rdCost->scaleChromaDistCb(primitives.sse_pp[part](fencYuv->getCbAddr(), fencYuv->getCStride(), outReconYuv->getCbAddr(), outReconYuv->getCStride()));
-    distortion += m_rdCost->scaleChromaDistCr(primitives.sse_pp[part](fencYuv->getCrAddr(), fencYuv->getCStride(), outReconYuv->getCrAddr(), outReconYuv->getCStride()));
-
     cu->m_totalBits       = bits;
     cu->m_totalDistortion = distortion;
     cu->m_totalCost       = m_rdCost->calcRdCost(distortion, bits);
@@ -2975,25 +2970,13 @@
 
 uint32_t TEncSearch::estimateZerobits(TComDataCU* cu)
 {
-    if (cu->isIntra(0))
-    {
-        return 0;
-    }
-
     uint32_t zeroResiBits = 0;
 
-    uint32_t width  = cu->getWidth(0);
-    uint32_t height = cu->getHeight(0);
-
     const uint32_t qpartnum = cu->getPic()->getNumPartInCU() >> (cu->getDepth(0) << 1);
-    ::memset(cu->getTransformIdx(), 0, qpartnum * sizeof(UChar));
+
     ::memset(cu->getCbf(TEXT_LUMA), 0, qpartnum * sizeof(UChar));
     ::memset(cu->getCbf(TEXT_CHROMA_U), 0, qpartnum * sizeof(UChar));
     ::memset(cu->getCbf(TEXT_CHROMA_V), 0, qpartnum * sizeof(UChar));
-    ::memset(cu->getCoeffY(), 0, width * height * sizeof(TCoeff));
-    ::memset(cu->getCoeffCb(), 0, width * height * sizeof(TCoeff) >> 2);
-    ::memset(cu->getCoeffCr(), 0, width * height * sizeof(TCoeff) >> 2);
-    cu->setTransformSkipSubParts(0, 0, 0, 0, cu->getDepth(0));
 
     m_rdGoOnSbacCoder->load(m_rdSbacCoders[cu->getDepth(0)][CI_CURR_BEST]);
     zeroResiBits = xSymbolBitsInter(cu);
@@ -3035,11 +3018,6 @@
 
 void TEncSearch::estimateBitsDist(TComDataCU* cu, TShortYUV* resiYuv, uint32_t& bits, uint32_t& distortion, bool curUseRDOQ)
 {
-    if (cu->isIntra(0))
-    {
-        return;
-    }
-
     bits = 0;
     distortion = 0;
     uint64_t cost = 0;


More information about the x265-devel mailing list