[x265] [PATCH 2 of 6] rc: define default setting and validations for 2 pass states

aarthi at multicorewareinc.com aarthi at multicorewareinc.com
Sun Jun 15 20:50:54 CEST 2014


# HG changeset patch
# User Aarthi Thirumalai<aarthi at multicorewareinc.com>
# Date 1402857077 -19800
#      Mon Jun 16 00:01:17 2014 +0530
# Node ID d1f636a6dc0a11657bb25be650de60345c2952c8
# Parent  438a03ff94830fbc17457b6f324397e643c17cba
rc: define default setting and validations for 2 pass states

diff -r 438a03ff9483 -r d1f636a6dc0a source/common/param.cpp
--- a/source/common/param.cpp	Sun Jun 15 23:59:14 2014 +0530
+++ b/source/common/param.cpp	Mon Jun 16 00:01:17 2014 +0530
@@ -180,7 +180,12 @@
     param->rc.cuTree = 1;
     param->rc.rfConstantMax = 0;
     param->rc.rfConstantMin = 0;
-
+    param->rc.pszStatIn = "x265_2pass.log";
+    param->rc.pszStatOut = "x264_2pass.log";
+    param->rc.complexityBlur = 20;
+    param->rc.qblur = 0.5;
+    param->rc.statRead = false;
+    param->rc.statWrite = false;
     /* Quality Measurement Metrics */
     param->bEnablePsnr = 0;
     param->bEnableSsim = 0;
@@ -414,6 +419,18 @@
 
     return 0;
 }
+extern "C"
+void x265_param_apply_fastfirstpass(x265_param *param)
+{
+    /* Set faster options in case of turbo firstpass. */
+    if( param->rc.statWrite && !param->rc.statRead )
+    {
+        param->maxNumReferences = 1;
+        param->searchMethod = X265_DIA_SEARCH;
+        param->bEnableEarlySkip = 1;
+    }
+}
+
 
 static int x265_atobool(const char *str, bool& bError)
 {
@@ -911,6 +928,8 @@
         if (s)
             x265_log(param, X265_LOG_WARNING, "--tune %s should be used if attempting to benchmark %s!\n", s, s);
     }
+    if (param->bOpenGOP && param->rc.statRead)
+        param->lookaheadDepth = 0;
 
     CHECK(param->rc.qp < -6 * (param->internalBitDepth - 8) || param->rc.qp > 51,
           "QP exceeds supported range (-QpBDOffsety to 51)");
@@ -966,7 +985,7 @@
           "Rate control mode is out of range");
     CHECK(param->rdLevel < 0 || param->rdLevel > 6,
           "RD Level is out of range");
-    CHECK(param->bframes > param->lookaheadDepth,
+    CHECK(param->bframes > param->lookaheadDepth && !param->rc.statRead,
           "Lookahead depth must be greater than the max consecutive bframe count");
     CHECK(param->bframes < 0,
           "bframe count should be greater than zero");
@@ -1045,6 +1064,9 @@
           "Target bitrate can not be less than zero");
     if (param->noiseReduction)
         CHECK(100 > param->noiseReduction || param->noiseReduction > 1000, "Valid noise reduction range 100 - 1000");
+    CHECK(param->rc.rateControlMode == X265_RC_CRF && param->rc.statRead,
+          "Constant rate-factor is incompatible with 2pass");
+
     return check_failed;
 }
 
diff -r 438a03ff9483 -r d1f636a6dc0a source/x265.cpp
--- a/source/x265.cpp	Sun Jun 15 23:59:14 2014 +0530
+++ b/source/x265.cpp	Mon Jun 16 00:01:17 2014 +0530
@@ -591,6 +591,7 @@
     }
 #endif // if HIGH_BIT_DEPTH
 
+    x265_param_apply_fastfirstpass(param);
     InputFileInfo info;
     info.filename = inputfn;
     info.depth = inputBitDepth;


More information about the x265-devel mailing list