[x265] [PATCH] QP- Lambda table -x265_lambda2_tab_I , x265_lambda2_tab_non_ I : for inter and intra blocks

sumalatha at multicorewareinc.com sumalatha at multicorewareinc.com
Wed Sep 4 12:57:40 CEST 2013


# HG changeset patch
# User sumalatha
# Date 1378292252 -19800
# Node ID 12419cd09719b403745b0193d369490d52fcdb0b
# Parent  a4cec6558ccc149e34492852152d214da9d9d2f5
 QP- Lambda table -x265_lambda2_tab_I , x265_lambda2_tab_non_ I : for inter and intra blocks

diff -r a4cec6558ccc -r 12419cd09719 source/Lib/TLibCommon/TComRom.cpp
--- a/source/Lib/TLibCommon/TComRom.cpp	Wed Sep 04 15:38:29 2013 +0530
+++ b/source/Lib/TLibCommon/TComRom.cpp	Wed Sep 04 16:27:32 2013 +0530
@@ -513,15 +513,26 @@
 const int g_winUnitX[] = { 1, 2, 2, 1 };
 const int g_winUnitY[] = { 1, 2, 1, 1 };
 
-const int x265_lambda2_tab[MAX_QP + 1] =
+const double x265_lambda2_tab_I[MAX_QP + 1] = 
 {
-    14,  18,   23,   30,   39,   50,   64,   83,
-    106,  137,  176,  226,  291,  374,  480,  617,
-    794,  1020, 1311, 1686, 2165, 2783, 3576, 4594,
-    5904, 7586, 9747, 12524,  16094,  20679,  26571,  34143,
-    43871,  56371,  72432,  93070,  119587, 153661, 197441, 253697,
-    325982, 418861, 538203, 691549, 888585, 1141764, 1467077, 1885077,
-    2422177, 3112305
+0.012265625,0.022265625, 0.028052813, 0.035344375, 0.04453125, 0.056105938, 0.070689063, 0.0890625,
+0.112211563, 0.141377813, 0.178125, 0.224423438, 0.282755938, 0.35625, 0.448846875,
+0.565511563, 0.7125, 0.89769375, 1.131023125, 1.425, 1.7953875, 2.262046563, 2.85,
+3.590775, 4.524093125, 5.7, 7.7800125, 10.55621688, 14.25, 19.1508, 25.63652688, 34.2,
+45.48315, 60.32124, 79.8, 105.3293997, 138.7388519, 182.4, 229.8095994, 289.5419519, 364.8,
+459.6191991, 579.0839038, 729.6, 919.2383981, 1158.167808, 1459.2, 1838.476796, 2316.335615,
+2918.4, 3676.953592, 4632.67123 
+};
+
+const double x265_lambda2_non_I[MAX_QP + 1] = 
+{
+0.05231, 0.060686, 0.07646, 0.096333333, 0.151715667, 0.15292, 0.192666667, 0.242745, 0.382299,
+0.385333333, 0.485489333, 0.611678333, 0.963333333, 0.970979, 1.223356667, 1.541333333, 2.427447667,
+2.446714, 3.082666667, 3.883916667, 6.116785, 6.165333333, 7.767833333, 9.786856667, 15.41333333,
+16.57137733, 22.183542, 29.5936, 39.357022, 52.19656867, 69.05173333, 91.14257667, 150.0651347,
+157.8325333, 207.1422197, 271.4221573, 443.904, 447.4271947, 563.722941, 710.2464, 1118.567987,
+1127.445883, 1420.4928, 1789.70878, 2818.614706, 2840.9856, 3579.41756, 4509.78353, 7102.464,
+7158.83512, 9019.56706, 11363.9424
 };
 
 const UChar g_lpsTable[64][4] =
diff -r a4cec6558ccc -r 12419cd09719 source/Lib/TLibCommon/TComRom.h
--- a/source/Lib/TLibCommon/TComRom.h	Wed Sep 04 15:38:29 2013 +0530
+++ b/source/Lib/TLibCommon/TComRom.h	Wed Sep 04 16:27:32 2013 +0530
@@ -293,8 +293,8 @@
 // Map Luma samples to chroma samples
 extern const int g_winUnitX[MAX_CHROMA_FORMAT_IDC + 1];
 extern const int g_winUnitY[MAX_CHROMA_FORMAT_IDC + 1];
-extern const int x265_lambda2_tab[MAX_QP+1];
-
+extern const double x265_lambda2_tab_I[MAX_QP + 1];
+extern const double x265_lambda2_non_I[MAX_QP + 1];
 // CABAC tables
 extern const UChar g_lpsTable[64][4];
 extern const UChar g_renormTable[32];
diff -r a4cec6558ccc -r 12419cd09719 source/Lib/TLibEncoder/TEncTop.cpp
--- a/source/Lib/TLibEncoder/TEncTop.cpp	Wed Sep 04 15:38:29 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncTop.cpp	Wed Sep 04 16:27:32 2013 +0530
@@ -840,7 +840,15 @@
 {
     FrameEncoder *curEncoder = &m_frameEncoder[m_curEncoder];
     int qp = slice->getSliceQp();
-    int lambda = x265_lambda2_tab[qp] >> 8;
+    double lambda = 0;
+    if(slice->getSliceType() == I_SLICE)
+        {
+            lambda = X265_MAX(1,x265_lambda2_tab_I[qp]);
+        }
+    else
+        {
+            lambda = X265_MAX(1,x265_lambda2_non_I[qp]);
+        }
 
     // for RDO
     // in RdCost there is only one lambda because the luma and chroma bits are not separated,
diff -r a4cec6558ccc -r 12419cd09719 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Wed Sep 04 15:38:29 2013 +0530
+++ b/source/encoder/frameencoder.cpp	Wed Sep 04 16:27:32 2013 +0530
@@ -294,43 +294,15 @@
     // Lambda computation
     // ------------------------------------------------------------------------------------------------------------------
 
-    int qp;
-
-    // compute lambda value
-    int    NumberBFrames = (m_cfg->getGOPSizeMin() - 1);
-    int    SHIFT_QP = 12;
-    double lambda_scale = 1.0 - Clip3(0.0, 0.5, 0.05 * (double)NumberBFrames);
-#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)qpdouble + bitdepth_luma_qp_scale - SHIFT_QP;
-
-    // Case #1: I or P-slices (key-frame)
-    double qpFactor = m_cfg->getGOPEntry(gopID).m_QPFactor;
-    if (sliceType == I_SLICE)
-    {
-        qpFactor = 0.57 * lambda_scale;
-    }
-    lambda = qpFactor * pow(2.0, qp_temp / 3.0);
-
-    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 = X265_MAX(-m_sps.getQpBDOffsetY(), X265_MIN(MAX_QP, (int)floor(qpdouble + 0.5)));
-
-    if (slice->getSliceType() != I_SLICE)
-    {
-        lambda *= m_cfg->getLambdaModifier(0); // temporal layer 0
-    }
+    int qp = X265_MAX(-m_sps.getQpBDOffsetY(), X265_MIN(MAX_QP, (int)floor(qpdouble + 0.5)));
+    if(slice->getSliceType() == I_SLICE)
+        {
+            lambda = X265_MAX(1,x265_lambda2_tab_I[qp]);
+        }
+    else
+        {
+            lambda = X265_MAX(1,x265_lambda2_non_I[qp]);
+        }
 
     // for RDO
     // in RdCost there is only one lambda because the luma and chroma bits are not separated,


More information about the x265-devel mailing list