[x265] [PATCH 2 of 2] reduce count of call to getChromaAddr()

Min Chen chenm003 at 163.com
Tue Nov 3 07:01:39 CET 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1446502212 21600
# Node ID 19c2e0f2669b9b5ea27bff7bef94393ace9021cb
# Parent  86c940eb28b7765eb81a46264194e00e9aa1187d
reduce count of call to getChromaAddr()
---
 source/encoder/search.cpp |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff -r 86c940eb28b7 -r 19c2e0f2669b source/encoder/search.cpp
--- a/source/encoder/search.cpp	Mon Nov 02 15:25:48 2015 -0600
+++ b/source/encoder/search.cpp	Mon Nov 02 16:10:12 2015 -0600
@@ -2982,7 +2982,8 @@
                     singleBitsPrev = newBits;
 
                     int16_t* curResiC = m_rqt[qtLayer].resiQtYuv.getChromaAddr(chromaId, absPartIdxC);
-                    distC = m_rdCost.scaleChromaDist(chromaId, primitives.cu[log2TrSizeC - 2].ssd_s(resiYuv.getChromaAddr(chromaId, absPartIdxC), resiYuv.m_csize));
+                    X265_CHECK(resi == resiYuv.getChromaAddr(chromaId, absPartIdxC), "address of resi check failure\n");
+                    distC = m_rdCost.scaleChromaDist(chromaId, primitives.cu[log2TrSizeC - 2].ssd_s(resi, resiYuv.m_csize));
 
                     if (cbfFlag[chromaId][tuIterator.section])
                     {
@@ -2991,13 +2992,15 @@
 
                         // non-zero cost calculation for luma, same as luma - This is an approximation
                         // finally we have to encode correct cbf after comparing with null cost
-                        sse_t dist = primitives.cu[partSizeC].sse_ss(resiYuv.getChromaAddr(chromaId, absPartIdxC), resiYuv.m_csize, curResiC, strideResiC);
+                        X265_CHECK(resi == resiYuv.getChromaAddr(chromaId, absPartIdxC), "address of resi check failure\n");
+                        sse_t dist = primitives.cu[partSizeC].sse_ss(resi, resiYuv.m_csize, curResiC, strideResiC);
                         uint32_t nzCbfBitsC = m_entropyCoder.estimateCbfBits(cbfFlag[chromaId][tuIterator.section], (TextType)chromaId, tuDepth);
                         sse_t nonZeroDistC = m_rdCost.scaleChromaDist(chromaId, dist);
                         uint32_t nonZeroPsyEnergyC = 0; uint64_t singleCostC = 0;
                         if (m_rdCost.m_psyRd)
                         {
-                            nonZeroPsyEnergyC = m_rdCost.psyCost(partSizeC, resiYuv.getChromaAddr(chromaId, absPartIdxC), resiYuv.m_csize, curResiC, strideResiC);
+                            X265_CHECK(resi == resiYuv.getChromaAddr(chromaId, absPartIdxC), "address of resi check failure\n");
+                            nonZeroPsyEnergyC = m_rdCost.psyCost(partSizeC, resi, resiYuv.m_csize, curResiC, strideResiC);
                             singleCostC = m_rdCost.calcPsyRdCost(nonZeroDistC, nzCbfBitsC + singleBits[chromaId][tuIterator.section], nonZeroPsyEnergyC);
                         }
                         else
@@ -3146,11 +3149,13 @@
 
                         m_quant.invtransformNxN(cu, m_tsResidual, trSizeC, m_tsCoeff,
                                                 log2TrSizeC, (TextType)chromaId, false, true, numSigTSkipC);
-                        sse_t dist = primitives.cu[partSizeC].sse_ss(resiYuv.getChromaAddr(chromaId, absPartIdxC), resiYuv.m_csize, m_tsResidual, trSizeC);
+                        X265_CHECK(resi == resiYuv.getChromaAddr(chromaId, absPartIdxC), "address of resi check failure\n");
+                        sse_t dist = primitives.cu[partSizeC].sse_ss(resi, resiYuv.m_csize, m_tsResidual, trSizeC);
                         nonZeroDistC = m_rdCost.scaleChromaDist(chromaId, dist);
                         if (m_rdCost.m_psyRd)
                         {
-                            nonZeroPsyEnergyC = m_rdCost.psyCost(partSizeC, resiYuv.getChromaAddr(chromaId, absPartIdxC), resiYuv.m_csize, m_tsResidual, trSizeC);
+                            X265_CHECK(resi == resiYuv.getChromaAddr(chromaId, absPartIdxC), "address of resi check failure\n");
+                            nonZeroPsyEnergyC = m_rdCost.psyCost(partSizeC, resi, resiYuv.m_csize, m_tsResidual, trSizeC);
                             singleCostC = m_rdCost.calcPsyRdCost(nonZeroDistC, singleBits[chromaId][tuIterator.section], nonZeroPsyEnergyC);
                         }
                         else



More information about the x265-devel mailing list