changeset 5036:1ca01c82609f

no-rdo: cleanups. Remove unnecessary memsets, rearrange computations.
author Deepthi Devaki <deepthidevaki@multicorewareinc.com>
date Mon, 11 Nov 2013 15:46:00 +0530
parents d1d716083aa7
children dc5c51ff542f
files source/Lib/TLibEncoder/TEncSearch.cpp
diffstat 1 files changed, 10 insertions(+-), 32 deletions(-) [+]
line wrap: on
line diff
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Mon Nov 11 19:43:33 2013 -0600
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Mon Nov 11 15:46:00 2013 +0530
@@ -1610,7 +1610,7 @@ void TEncSearch::estIntraPredQT(TComData
                 // Filtered and Unfiltered refAbove and refLeft pointing to above and left.
                 above         = aboveScale;
                 left          = leftScale;
-                aboveFiltered = aboveScale; 
+                aboveFiltered = aboveScale;
                 leftFiltered  = leftScale;
             }
 
@@ -2936,34 +2936,29 @@ void TEncSearch::estimateRDInterCU(TComD
     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);
@@ -2971,25 +2966,13 @@ void TEncSearch::estimateRDInterCU(TComD
 
 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);
@@ -3031,11 +3014,6 @@ void TEncSearch::generateRecon(TComDataC
 
 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;