[x265] [PATCH 2 of 8] cli: add option to support multiple level of analysis mode refinement

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Mon Feb 27 15:05:18 CET 2017


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1487826752 -19800
#      Thu Feb 23 10:42:32 2017 +0530
# Node ID 6051ce2d7864cb3b019c66117661bc5752d1932c
# Parent  acc482810fe75fd536436ae9b2db2c7aaf9a1212
cli: add option to support multiple level of analysis mode refinement

--refine-level option should be paired with --analysis-mode save/load

diff -r acc482810fe7 -r 6051ce2d7864 doc/reST/cli.rst
--- a/doc/reST/cli.rst	Thu Feb 02 16:32:31 2017 +0530
+++ b/doc/reST/cli.rst	Thu Feb 23 10:42:32 2017 +0530
@@ -816,6 +816,27 @@
 	Specify a filename for analysis data (see :option:`--analysis-mode`)
 	If no filename is specified, x265_analysis.dat is used.
 
+.. option:: --refine-level <1..5>
+
+	Amount of information stored/reused in :option:`--analysis-mode` is distributed across levels.
+	Higher the value, higher the information stored/reused, faster the encode. Default 3.
+
+	Note that --refine-level must be paired with analysis-mode.
+
+	+-------+-----------------------------------------+
+	| Level | Description                             |
+	+=======+=========================================+
+	| 1     | Lookahead information                   |
+	+-------+-----------------------------------------+
+	| 2     | Level 1 + intra/inter modes, ref's      |
+	+-------+-----------------------------------------+
+	| 3     | Level 2 + rect-amp                      |
+	+-------+-----------------------------------------+
+	| 4     | Currently same as 3                     |
+	+-------+-----------------------------------------+
+	| 5     | Level 4 + Entire CU analysis-info       |
+	+-------+-----------------------------------------+
+
 Options which affect the transform unit quad-tree, sometimes referred to
 as the residual quad-tree (RQT).
 
diff -r acc482810fe7 -r 6051ce2d7864 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Thu Feb 02 16:32:31 2017 +0530
+++ b/source/CMakeLists.txt	Thu Feb 23 10:42:32 2017 +0530
@@ -29,7 +29,7 @@
 option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 112)
+set(X265_BUILD 113)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r acc482810fe7 -r 6051ce2d7864 source/common/param.cpp
--- a/source/common/param.cpp	Thu Feb 02 16:32:31 2017 +0530
+++ b/source/common/param.cpp	Thu Feb 23 10:42:32 2017 +0530
@@ -271,6 +271,7 @@
     param->bOptCUDeltaQP        = 0;
     param->bAQMotion = 0;
     param->bHDROpt = 0;
+    param->analysisRefineLevel = 3;
 
 }
 
@@ -933,6 +934,7 @@
         OPT("multi-pass-opt-distortion") p->analysisMultiPassDistortion = atobool(value);
         OPT("aq-motion") p->bAQMotion = atobool(value);
         OPT("dynamic-rd") p->dynamicRd = atof(value);
+        OPT("refine-level") p->analysisRefineLevel = atoi(value);
         OPT("ssim-rd")
         {
             int bval = atobool(value);
@@ -1277,6 +1279,8 @@
           "Strict-cbr cannot be applied without specifying target bitrate or vbv bufsize");
     CHECK(param->analysisMode && (param->analysisMode < X265_ANALYSIS_OFF || param->analysisMode > X265_ANALYSIS_LOAD),
         "Invalid analysis mode. Analysis mode 0: OFF 1: SAVE : 2 LOAD");
+    CHECK(param->analysisMode && (param->analysisRefineLevel < 1 || param->analysisRefineLevel > 5),
+        "Invalid analysis refine level. Value must be between 1 and 5 (inclusive)");
     CHECK(param->rc.qpMax < QP_MIN || param->rc.qpMax > QP_MAX_MAX,
         "qpmax exceeds supported range (0 to 69)");
     CHECK(param->rc.qpMin < QP_MIN || param->rc.qpMin > QP_MAX_MAX,
@@ -1651,6 +1655,7 @@
     BOOL(p->bAQMotion, "aq-motion");
     BOOL(p->bEmitHDRSEI, "hdr");
     BOOL(p->bHDROpt, "hdr-opt");
+    s += sprintf(s, "refine-level=%d", p->analysisRefineLevel);
 #undef BOOL
     return buf;
 }
diff -r acc482810fe7 -r 6051ce2d7864 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Thu Feb 02 16:32:31 2017 +0530
+++ b/source/encoder/encoder.cpp	Thu Feb 23 10:42:32 2017 +0530
@@ -2021,6 +2021,9 @@
         p->rc.cuTree = 0;
     }
 
+    if (p->analysisMode == X265_ANALYSIS_OFF && p->analysisRefineLevel)
+        x265_log(p, X265_LOG_WARNING, "refine-level option works only with analysis-mode load/save\n");
+
     if (p->analysisMode && (p->analysisMultiPassRefine || p->analysisMultiPassDistortion))
     {
         x265_log(p, X265_LOG_WARNING, "Cannot use Analysis load/save option and multi-pass-opt-analysis/multi-pass-opt-distortion together,"
diff -r acc482810fe7 -r 6051ce2d7864 source/x265.h
--- a/source/x265.h	Thu Feb 02 16:32:31 2017 +0530
+++ b/source/x265.h	Thu Feb 23 10:42:32 2017 +0530
@@ -1384,6 +1384,12 @@
     /* Enable luma and chroma offsets for HDR/WCG content.
      * Default is disabled */
     int       bHDROpt;
+
+    /* A value between 1 and 5 (both inclusive) determines the level of
+    * information stored/reused in save/load analysis-mode. Higher the refine
+    * level higher the informtion stored/reused. Default is 3 */
+    int       analysisRefineLevel;
+
 } x265_param;
 
 /* x265_param_alloc:
diff -r acc482810fe7 -r 6051ce2d7864 source/x265cli.h
--- a/source/x265cli.h	Thu Feb 02 16:32:31 2017 +0530
+++ b/source/x265cli.h	Thu Feb 23 10:42:32 2017 +0530
@@ -249,6 +249,7 @@
     { "no-multi-pass-opt-rps", no_argument, NULL, 0 },
     { "analysis-mode",  required_argument, NULL, 0 },
     { "analysis-file",  required_argument, NULL, 0 },
+    { "refine-level",   required_argument, NULL, 0 },
     { "strict-cbr",           no_argument, NULL, 0 },
     { "temporal-layers",      no_argument, NULL, 0 },
     { "no-temporal-layers",   no_argument, NULL, 0 },
@@ -423,6 +424,7 @@
     H0("   --[no-]strict-cbr             Enable stricter conditions and tolerance for bitrate deviations in CBR mode. Default %s\n", OPT(param->rc.bStrictCbr));
     H0("   --analysis-mode <string|int>  save - Dump analysis info into file, load - Load analysis buffers from the file. Default %d\n", param->analysisMode);
     H0("   --analysis-file <filename>    Specify file name used for either dumping or reading analysis data.\n");
+    H0("   --refine-level <1..5>         Level of analyis refinement indicates amount of info stored/reused in save/load mode, 1:least....5:most. Default %d\n", param->analysisRefineLevel);
     H0("   --aq-mode <integer>           Mode for Adaptive Quantization - 0:none 1:uniform AQ 2:auto variance 3:auto variance with bias to dark scenes. Default %d\n", param->rc.aqMode);
     H0("   --aq-strength <float>         Reduces blocking and blurring in flat and textured areas (0 to 3.0). Default %.2f\n", param->rc.aqStrength);
     H0("   --[no-]aq-motion              Adaptive Quantization based on the relative motion of each CU w.r.t., frame. Default %s\n", OPT(param->bOptCUDeltaQP));


More information about the x265-devel mailing list