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

2017-06-04 Thread Pradeep Ramachandran
On Fri, Jun 2, 2017 at 11:33 PM,  wrote:

> # HG changeset patch
> # User Bhavna Hariharan 
> # 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
>

Pushed full set to default branch.


>
> 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.cppFri Apr 07 13:53:42 2017 +0530
> +++ b/source/encoder/encoder.cppWed 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

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

2017-06-02 Thread bhavna
# HG changeset patch
# User Bhavna Hariharan 
# 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.cppFri Apr 07 13:53:42 2017 +0530
+++ b/source/encoder/encoder.cppWed 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