[x265] [PATCH 2 of 4] Add optional parameter to setLambdaFromQP and calculateQpForCUSize functions

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Wed Oct 14 08:35:46 CEST 2015


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1444306002 -19800
#      Thu Oct 08 17:36:42 2015 +0530
# Node ID 5f8702e3362b152eddf6fdf69278fc717dc7d41b
# Parent  c7e8ab6338aa97067f5823f4547b288dde0aeb54
Add optional parameter to setLambdaFromQP and calculateQpForCUSize functions

Inaddition, the zOrder is no more passed explicitly to compressIntraCU(),
instead used implicitly from cuGeom. This commit forms groundwork for
QP based RD refinement.

diff -r c7e8ab6338aa -r 5f8702e3362b source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp	Mon Oct 12 11:14:06 2015 +0530
+++ b/source/encoder/analysis.cpp	Thu Oct 08 17:36:42 2015 +0530
@@ -147,7 +147,6 @@
 
     ProfileCUScope(ctu, totalCTUTime, totalCTUs);
 
-    uint32_t zOrder = 0;
     if (m_slice->m_sliceType == I_SLICE)
     {
         analysis_intra_data* intraDataCTU = (analysis_intra_data*)m_frame->m_analysisData.intraData;
@@ -158,7 +157,7 @@
             memcpy(ctu.m_partSize, &intraDataCTU->partSizes[ctu.m_cuAddr * numPartition], sizeof(char) * numPartition);
             memcpy(ctu.m_chromaIntraDir, &intraDataCTU->chromaModes[ctu.m_cuAddr * numPartition], sizeof(uint8_t) * numPartition);
         }
-        compressIntraCU(ctu, cuGeom, zOrder, qp);
+        compressIntraCU(ctu, cuGeom, qp);
         if (m_param->analysisMode == X265_ANALYSIS_SAVE && intraDataCTU)
         {
             CUData* bestCU = &m_modeDepth[0].bestMode->cu;
@@ -187,6 +186,7 @@
             compressInterCU_rd0_4(ctu, cuGeom, qp);
         else
         {
+            uint32_t zOrder = 0;
             compressInterCU_rd5_6(ctu, cuGeom, zOrder, qp);
             if (m_param->analysisMode == X265_ANALYSIS_SAVE && m_frame->m_analysisData.interData)
             {
@@ -225,7 +225,7 @@
     }
 }
 
-void Analysis::compressIntraCU(const CUData& parentCTU, const CUGeom& cuGeom, uint32_t& zOrder, int32_t qp)
+void Analysis::compressIntraCU(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp)
 {
     uint32_t depth = cuGeom.depth;
     ModeDepth& md = m_modeDepth[depth];
@@ -302,7 +302,7 @@
                 if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)
                     nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(parentCTU, childGeom));
 
-                compressIntraCU(parentCTU, childGeom, zOrder, nextQP);
+                compressIntraCU(parentCTU, childGeom, nextQP);
 
                 // Save best CU and pred data for this sub CU
                 splitCU->copyPartFrom(nd.bestMode->cu, childGeom, subPartIdx);
@@ -314,7 +314,6 @@
             {
                 /* record the depth of this non-present sub-CU */
                 splitCU->setEmptyPart(childGeom, subPartIdx);
-                zOrder += g_depthInc[g_maxCUDepth - 1][nextDepth];
             }
         }
         nextContext->store(splitPred->contexts);
@@ -2122,10 +2121,10 @@
     return false;
 }
 
-int Analysis::calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom)
+int Analysis::calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom, double baseQp)
 {
     FrameData& curEncData = *m_frame->m_encData;
-    double qp = curEncData.m_cuStat[ctu.m_cuAddr].baseQp;
+    double qp = baseQp ? baseQp : curEncData.m_cuStat[ctu.m_cuAddr].baseQp;
 
     /* Use cuTree offsets if cuTree enabled and frame is referenced, else use AQ offsets */
     bool isReferenced = IS_REFERENCED(m_frame);
diff -r c7e8ab6338aa -r 5f8702e3362b source/encoder/analysis.h
--- a/source/encoder/analysis.h	Mon Oct 12 11:14:06 2015 +0530
+++ b/source/encoder/analysis.h	Thu Oct 08 17:36:42 2015 +0530
@@ -111,7 +111,7 @@
     uint32_t m_splitRefIdx[4];
 
     /* full analysis for an I-slice CU */
-    void compressIntraCU(const CUData& parentCTU, const CUGeom& cuGeom, uint32_t &zOrder, int32_t qp);
+    void 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);
@@ -141,7 +141,7 @@
     /* generate residual and recon pixels for an entire CTU recursively (RD0) */
     void encodeResidue(const CUData& parentCTU, const CUGeom& cuGeom);
 
-    int calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom);
+    int calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom, double baseQP = 0);
 
     /* check whether current mode is the new best */
     inline void checkBestMode(Mode& mode, uint32_t depth)
diff -r c7e8ab6338aa -r 5f8702e3362b source/encoder/search.cpp
--- a/source/encoder/search.cpp	Mon Oct 12 11:14:06 2015 +0530
+++ b/source/encoder/search.cpp	Thu Oct 08 17:36:42 2015 +0530
@@ -164,12 +164,12 @@
     X265_FREE(m_tsRecon);
 }
 
-int Search::setLambdaFromQP(const CUData& ctu, int qp)
+int Search::setLambdaFromQP(const CUData& ctu, int qp, int lambdaQp)
 {
     X265_CHECK(qp >= QP_MIN && qp <= QP_MAX_MAX, "QP used for lambda is out of range\n");
 
     m_me.setQP(qp);
-    m_rdCost.setQP(*m_slice, qp);
+    m_rdCost.setQP(*m_slice, lambdaQp < 0 ? qp : lambdaQp);
 
     int quantQP = x265_clip3(QP_MIN, QP_MAX_SPEC, qp);
     m_quant.setQPforQuant(ctu, quantQP);
diff -r c7e8ab6338aa -r 5f8702e3362b source/encoder/search.h
--- a/source/encoder/search.h	Mon Oct 12 11:14:06 2015 +0530
+++ b/source/encoder/search.h	Thu Oct 08 17:36:42 2015 +0530
@@ -279,7 +279,7 @@
     ~Search();
 
     bool     initSearch(const x265_param& param, ScalingList& scalingList);
-    int      setLambdaFromQP(const CUData& ctu, int qp); /* returns real quant QP in valid spec range */
+    int      setLambdaFromQP(const CUData& ctu, int qp, int lambdaQP = -1); /* returns real quant QP in valid spec range */
 
     // mark temp RD entropy contexts as uninitialized; useful for finding loads without stores
     void     invalidateContexts(int fromDepth);


More information about the x265-devel mailing list