[x265] [PATCH] rate control changes: add x265_lambda2_tab[] , modify rateTolarace , initial cplxrSum etc

aarthi at multicorewareinc.com aarthi at multicorewareinc.com
Thu Aug 29 00:49:48 CEST 2013


# HG changeset patch
# User Aarthi Thirumalai<aarthi at multicorewareinc.com>
# Date 1377730168 -19800
#      Thu Aug 29 04:19:28 2013 +0530
# Node ID abf5562a09435c243e4e50ff00dda11ebe98de06
# Parent  a60d5991e6aacec0e158688f7aa81452c02cba5a
rate control changes: add x265_lambda2_tab[] , modify rateTolarace , initial cplxrSum etc

diff -r a60d5991e6aa -r abf5562a0943 source/Lib/TLibCommon/TComRom.cpp
--- a/source/Lib/TLibCommon/TComRom.cpp	Wed Aug 28 13:41:33 2013 -0700
+++ b/source/Lib/TLibCommon/TComRom.cpp	Thu Aug 29 04:19:28 2013 +0530
@@ -516,13 +516,13 @@
 
 const int x265_HM_lambda2_tab[MAX_QP+1] =
 {
-   1,   1,   1,   2,   2,  3,   4,   6, /*  0- 7 */
-   6,   7,   9,   15,   15,   19,   23,   37, /*  8-15 */
-   37,   47,   59,   93,   94,   118,   149,   235, /* 16-23 */
-   237,   323,   438,   740,   795,   1064,   1420,   2361, /* 24-31 */
-  2505,  3314,  4375,  7203,  7576,  9545,  12026,  18939, /* 32-39 */
-  19090,  24052,  30303,  47726,  48104,  60608,  76361,  120261, /* 40-47 */
-  121215,  152721,  192417,  303038
-};
+1,	1,	1,	1,	1,	1,	1,	1,
+1,	1,	1,	1,	1,	1,	2,	2,
+3,	4,	5,	6,	8,	11,	14,	18,
+23,	30,	38,	49,	63,	81,	104, 133,
+171, 220, 282, 363, 467, 600, 771, 991,
+1273, 1636, 2102, 2701, 3471,4460,5731, 7363,
+9462, 12157, 15621, 20072 };
+
 
 //! \}
diff -r a60d5991e6aa -r abf5562a0943 source/Lib/TLibEncoder/TEncTop.cpp
--- a/source/Lib/TLibEncoder/TEncTop.cpp	Wed Aug 28 13:41:33 2013 -0700
+++ b/source/Lib/TLibEncoder/TEncTop.cpp	Thu Aug 29 04:19:28 2013 +0530
@@ -843,79 +843,8 @@
 Void TEncTop::computeLambdaForQp(TComSlice* slice)
 {
     FrameEncoder *curEncoder = &m_frameEncoder[m_curEncoder];
-    Int lambda;
     Int qp = slice->getSliceQp();
-
-    // compute lambda value
-    Int    NumberBFrames = (getGOPSize() - 1);
-    Int    SHIFT_QP = 12;
-    Double lambda_scale = 1.0 - Clip3(0.0, 0.5, 0.05 * (Double)NumberBFrames);
-    Double qpFactor;
-
-#if FULL_NBIT
-    Int    bitdepth_luma_qp_scale = 6 * (X265_DEPTH - 8);
-    Double qp_temp_orig = (Double)dQP - SHIFT_QP;
-#else
-    Int    bitdepth_luma_qp_scale = 0;
-#endif
-    Double qp_temp = (Double)qp + bitdepth_luma_qp_scale - SHIFT_QP;
-
-    // Case #1: I or P-slices (key-frame)
-    if (slice->getPOC() % 4 == 3)
-    {
-        qpFactor = 0.578;
-    }
-    else
-    {
-        qpFactor = 0.4624;
-    }
-    if (slice->getSliceType() == I_SLICE)
-    {
-        qpFactor = 0.57 * lambda_scale;
-    }
-    lambda = qpFactor * pow(2.0, qp_temp / 3.0);
-
-    // depth computation based on GOP size
-    Int depth = 0;
-    Int poc = slice->getPOC() % getGOPSize();
-    if (poc)
-    {
-        Int step = getGOPSize();
-        for (Int i = step >> 1; i >= 1; i >>= 1)
-        {
-            for (Int j = i; j < getGOPSize(); j += step)
-            {
-                if (j == poc)
-                {
-                    i = 0;
-                    break;
-                }
-            }
-
-            step >>= 1;
-            depth++;
-        }
-    }
-
-    if (depth > 0)
-    {
-#if FULL_NBIT
-        lambda *= Clip3(2.00, 4.00, (qp_temp_orig / 6.0));
-#else
-        lambda *= Clip3(2.00, 4.00, (qp_temp / 6.0));
-#endif
-    }
-
-    //qp = max(-m_sps.getQpBDOffsetY(), min(MAX_QP, (Int)floor(qpdouble + 0.5)));
-
-    if (slice->getSliceType() != I_SLICE)
-    {
-        lambda *= getLambdaModifier(0); // temporal layer 0
-    }
-
-    // for RDO
-    // in RdCost there is only one lambda because the luma and chroma bits are not separated,
-    // instead we weight the distortion of chroma.
+	Int lambda = x265_HM_lambda2_tab[qp];
     Double weight = 1.0;
     Int qpc;
     Int chromaQPOffset;
diff -r a60d5991e6aa -r abf5562a0943 source/common/common.cpp
--- a/source/common/common.cpp	Wed Aug 28 13:41:33 2013 -0700
+++ b/source/common/common.cpp	Thu Aug 29 04:19:28 2013 +0530
@@ -140,7 +140,7 @@
     param->bFrameAdaptive = X265_B_ADAPT_FAST;
     param->lookaheadDepth = 10;
     param->rc.bitrate = 1000;
-    param->rc.rateTolerance = 1;
+    param->rc.rateTolerance = .1;
     param->rc.qCompress = 0.6;
     param->rc.ipFactor = 1.4f;
     param->rc.pbFactor = 1.3f;
diff -r a60d5991e6aa -r abf5562a0943 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Wed Aug 28 13:41:33 2013 -0700
+++ b/source/encoder/ratecontrol.cpp	Thu Aug 29 04:19:28 2013 +0530
@@ -80,7 +80,7 @@
         accumPNorm = .01;
         accumPQp = (ABR_INIT_QP)*accumPNorm;
         /* estimated ratio that produces a reasonable QP for the first I-frame  - needs to be tweaked for x265*/
-        cplxrSum = .01 * pow(7.0e5, qCompress) * pow(ncu, 0.6);
+        cplxrSum = .01 * pow(7.0e5, qCompress) * pow(4*ncu, 0.5);
         wantedBitsWindow = bitrate * frameDuration;
         lastNonBPictType = I_SLICE;
     }


More information about the x265-devel mailing list