[x265] [PATCH 1 of 3] cli: add support for inter and intra refinement in analysis load

bhavna at multicorewareinc.com bhavna at multicorewareinc.com
Fri Jun 2 20:03:59 CEST 2017


# HG changeset patch
# User Bhavna Hariharan <bhavna at multicorewareinc.com>
# Date 1496236943 -19800
#      Wed May 31 18:52:23 2017 +0530
# Node ID d103464b81751a917ec20a02c412f92d0846692a
# Parent  d0884f53441b5e567dd8938ca78217bc43b2d799
cli: add support for inter and intra refinement in analysis load

diff -r d0884f53441b -r d103464b8175 doc/reST/cli.rst
--- a/doc/reST/cli.rst	Fri Apr 07 13:53:42 2017 +0530
+++ b/doc/reST/cli.rst	Wed May 31 18:52:23 2017 +0530
@@ -862,6 +862,18 @@
 	This option should be coupled with analysis-mode option, --refine-level 10.
 	Default 0.
 
+.. option:: --refine-intra
+	
+	Enables refinement of intra blocks in current encode. Evaluates all 
+	intra modes for blocks of size one smaller than the min-cu-size of the 
+	incoming analysis data from the previous encode. Default disabled.
+	
+.. option:: --refine-inter-depth
+
+	Enables refinement of inter blocks in current encode. Evaluates all 
+	inter modes for blocks of size one smaller than the min-cu-size of the 
+	incoming analysis data from the previous encode. Default disabled.
+
 Options which affect the transform unit quad-tree, sometimes referred to
 as the residual quad-tree (RQT).
 
diff -r d0884f53441b -r d103464b8175 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Fri Apr 07 13:53:42 2017 +0530
+++ b/source/CMakeLists.txt	Wed May 31 18:52:23 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 119)
+set(X265_BUILD 120)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r d0884f53441b -r d103464b8175 source/common/param.cpp
--- a/source/common/param.cpp	Fri Apr 07 13:53:42 2017 +0530
+++ b/source/common/param.cpp	Wed May 31 18:52:23 2017 +0530
@@ -278,6 +278,8 @@
     param->bCTUInfo = 0;
     param->bUseRcStats = 0;
     param->scaleFactor = 0;
+    param->intraRefine = 0;
+    param->interRefine = 0;
 }
 
 int x265_param_default_preset(x265_param* param, const char* preset, const char* tune)
@@ -959,6 +961,8 @@
         OPT("dhdr10-opt") p->bDhdr10opt = atobool(value);
         OPT("ctu-info") p->bCTUInfo = atoi(value);
         OPT("scale-factor") p->scaleFactor = atoi(value);
+        OPT("refine-intra")p->intraRefine = atobool(value);
+        OPT("refine-inter")p->interRefine = atobool(value);
         else
             return X265_PARAM_BAD_NAME;
     }
@@ -1678,7 +1682,9 @@
     BOOL(p->bHDROpt, "hdr-opt");
     BOOL(p->bDhdr10opt, "dhdr10-opt");
     s += sprintf(s, " refine-level=%d", p->analysisRefineLevel);
-	s += sprintf(s, " scale-factor=%d", p->scaleFactor);
+    s += sprintf(s, " scale-factor=%d", p->scaleFactor);
+    s += sprintf(s, " refine-intra=%d", p->intraRefine);
+    s += sprintf(s, " refine-inter=%d", p->interRefine);
     BOOL(p->bLimitSAO, "limit-sao");
     s += sprintf(s, " ctu-info=%d", p->bCTUInfo);
 #undef BOOL
diff -r d0884f53441b -r d103464b8175 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Fri Apr 07 13:53:42 2017 +0530
+++ b/source/encoder/encoder.cpp	Wed May 31 18:52:23 2017 +0530
@@ -2287,6 +2287,30 @@
         }
     }
 
+    if (p->intraRefine)
+    {
+        if (p->analysisMode!= X265_ANALYSIS_LOAD || p->analysisRefineLevel < 10 || !p->scaleFactor)
+        {
+            x265_log(p, X265_LOG_WARNING, "Intra refinement requires analysis load, refine-level 10, scale factor. Disabling intra refine.\n");
+            p->intraRefine = 0;
+        }
+    }
+
+    if (p->interRefine)
+    {
+        if (p->analysisMode != X265_ANALYSIS_LOAD || p->analysisRefineLevel < 10 || !p->scaleFactor)
+        {
+            x265_log(p, X265_LOG_WARNING, "Inter refinement requires analysis load, refine-level 10, scale factor. Disabling inter refine.\n");
+            p->interRefine = 0;
+        }
+    }
+
+    if (p->limitTU && p->interRefine)
+    {
+        x265_log(p, X265_LOG_WARNING, "Inter refinement does not support limitTU. Disabling limitTU.\n");
+        p->limitTU = 0;
+    }
+
     if ((p->analysisMultiPassRefine || p->analysisMultiPassDistortion) && (p->bDistributeModeAnalysis || p->bDistributeMotionEstimation))
     {
         x265_log(p, X265_LOG_WARNING, "multi-pass-opt-analysis/multi-pass-opt-distortion incompatible with pmode/pme, Disabling pmode/pme\n");
diff -r d0884f53441b -r d103464b8175 source/x265.h
--- a/source/x265.h	Fri Apr 07 13:53:42 2017 +0530
+++ b/source/x265.h	Wed May 31 18:52:23 2017 +0530
@@ -1441,7 +1441,15 @@
 
     /* Factor by which input video is scaled down for analysis save mode. Default is 0 */
     int       scaleFactor;
+
+    /* Enable intra refinement in load mode*/
+    int       intraRefine;
+
+    /* Enable inter refinement in load mode*/
+    int       interRefine;
+
 } x265_param;
+
 /* x265_param_alloc:
  *  Allocates an x265_param instance. The returned param structure is not
  *  special in any way, but using this method together with x265_param_free()
diff -r d0884f53441b -r d103464b8175 source/x265cli.h
--- a/source/x265cli.h	Fri Apr 07 13:53:42 2017 +0530
+++ b/source/x265cli.h	Wed May 31 18:52:23 2017 +0530
@@ -252,6 +252,10 @@
     { "analysis-file",  required_argument, NULL, 0 },
     { "refine-level",   required_argument, NULL, 0 },
     { "scale-factor",   required_argument, NULL, 0 },
+    { "refine-intra",   no_argument, NULL, 0 },
+    { "no-refine-intra",no_argument, NULL, 0 },
+    { "refine-inter",   no_argument, NULL, 0 },
+    { "no-refine-inter",no_argument, NULL, 0 },
     { "strict-cbr",           no_argument, NULL, 0 },
     { "temporal-layers",      no_argument, NULL, 0 },
     { "no-temporal-layers",   no_argument, NULL, 0 },
@@ -442,6 +446,8 @@
     H0("   --analysis-file <filename>    Specify file name used for either dumping or reading analysis data.\n");
     H0("   --refine-level <1..10>        Level of analysis refinement indicates amount of info stored/reused in save/load mode, 1:least....10:most. Default %d\n", param->analysisRefineLevel);
     H0("   --scale-factor <int>          Specify factor by which input video is scaled down for analysis save mode. Default %d\n", param->scaleFactor);
+    H0("   --[no-]refine-intra           Enable intra refinement for load mode. Default %s\n", OPT(param->intraRefine));
+    H0("   --[no-]refine-inter           Enable inter refinement for load mode. Default %s\n", OPT(param->interRefine));
     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