[x265] [PATCH 2 of 3] cli: add --rd-refine option to enable QP based RD refinement

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Tue Oct 27 06:51:35 CET 2015


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1445608941 -19800
#      Fri Oct 23 19:32:21 2015 +0530
# Node ID 8f08f346dd675a638df2ca8aa030b5be61ab06d7
# Parent  3bcefff74b44d78c65456ecff25ef10b8a710283
cli: add --rd-refine option to enable QP based RD refinement

The option is effective for rdLevels greater than 4

diff -r 3bcefff74b44 -r 8f08f346dd67 doc/reST/cli.rst
--- a/doc/reST/cli.rst	Fri Oct 23 19:50:49 2015 +0530
+++ b/doc/reST/cli.rst	Fri Oct 23 19:32:21 2015 +0530
@@ -746,6 +746,14 @@
 	evaluate if luma used tskip. Inter block tskip analysis is
 	unmodified. Default disabled
 
+.. option:: --rd-refine, --no-rd-refine
+
+	For each analysed CU, calculate R-D cost on the best partition mode
+	for a range of QP values, to find the optimal rounding effect.
+	Default disabled.
+
+	Only effective at RD levels 5 and 6
+
 Analysis re-use options, to improve performance when encoding the same
 sequence multiple times (presumably at varying bitrates). The encoder
 will not reuse analysis if the resolution and slice type parameters do
diff -r 3bcefff74b44 -r 8f08f346dd67 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Fri Oct 23 19:50:49 2015 +0530
+++ b/source/CMakeLists.txt	Fri Oct 23 19:32:21 2015 +0530
@@ -30,7 +30,7 @@
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 76)
+set(X265_BUILD 77)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 3bcefff74b44 -r 8f08f346dd67 source/common/param.cpp
--- a/source/common/param.cpp	Fri Oct 23 19:50:49 2015 +0530
+++ b/source/common/param.cpp	Fri Oct 23 19:32:21 2015 +0530
@@ -192,6 +192,7 @@
     param->bLossless = 0;
     param->bCULossless = 0;
     param->bEnableTemporalSubLayers = 0;
+    param->bEnableRdRefine = 0;
 
     /* Rate control options */
     param->rc.vbvMaxBitrate = 0;
@@ -687,6 +688,7 @@
         else
             p->psyRdoq = 0.0;
     }
+    OPT("rd-refine") p->bEnableRdRefine = atobool(value);
     OPT("signhide") p->bEnableSignHiding = atobool(value);
     OPT("b-intra") p->bIntraInBFrames = atobool(value);
     OPT("lft") p->bEnableLoopFilter = atobool(value); /* DEPRECATED */
@@ -1318,6 +1320,7 @@
     TOOLVAL(param->psyRd, "psy-rd=%.2lf");
     TOOLVAL(param->rdoqLevel, "rdoq=%d");
     TOOLVAL(param->psyRdoq, "psy-rdoq=%.2lf");
+    TOOLOPT(param->bEnableRdRefine, "rd-refine");
     TOOLOPT(param->bEnableEarlySkip, "early-skip");
     TOOLVAL(param->noiseReductionIntra, "nr-intra=%d");
     TOOLVAL(param->noiseReductionInter, "nr-inter=%d");
@@ -1446,6 +1449,7 @@
     s += sprintf(s, " psy-rd=%.2f", p->psyRd);
     s += sprintf(s, " rdoq-level=%d", p->rdoqLevel);
     s += sprintf(s, " psy-rdoq=%.2f", p->psyRdoq);
+    BOOL(p->bEnableRdRefine, "rd-refine");
     BOOL(p->bEnableSignHiding, "signhide");
     BOOL(p->bEnableLoopFilter, "deblock");
     if (p->bEnableLoopFilter && (p->deblockingFilterBetaOffset || p->deblockingFilterTCOffset))
diff -r 3bcefff74b44 -r 8f08f346dd67 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Fri Oct 23 19:50:49 2015 +0530
+++ b/source/encoder/encoder.cpp	Fri Oct 23 19:32:21 2015 +0530
@@ -1782,6 +1782,12 @@
         x265_log(p, X265_LOG_WARNING, "Analysis save and load mode not supported for distributed mode analysis\n");
     }
 
+    if (p->bEnableRdRefine && (p->rdLevel < 5 || !p->rc.aqMode))
+    {
+        p->bEnableRdRefine = false;
+        x265_log(p, X265_LOG_WARNING, "--rd-refine disabled, requires RD level > 4 and adaptive quant\n");
+    }
+
     bool bIsVbv = m_param->rc.vbvBufferSize > 0 && m_param->rc.vbvMaxBitrate > 0;
     if (!m_param->bLossless && (m_param->rc.aqMode || bIsVbv))
     {
diff -r 3bcefff74b44 -r 8f08f346dd67 source/x265.h
--- a/source/x265.h	Fri Oct 23 19:50:49 2015 +0530
+++ b/source/x265.h	Fri Oct 23 19:32:21 2015 +0530
@@ -945,6 +945,12 @@
      * between 0 and 50, 1.0 is typical. Default 1.0 */
     double    psyRdoq;
 
+    /* Perform quantisation parameter based RD refinement. RD cost is calculated
+     * on the best CU partitions, chosen after the CU analysis, for a range of QPs
+     * to find the optimal rounding effect. Only effective at rd-levels 5 and 6.
+     * Default disabled */
+    int       bEnableRdRefine;
+
     /* If X265_ANALYSIS_SAVE, write per-frame analysis information into analysis
      * buffers.  if X265_ANALYSIS_LOAD, read analysis information into analysis
      * buffer and use this analysis information to reduce the amount of work
diff -r 3bcefff74b44 -r 8f08f346dd67 source/x265cli.h
--- a/source/x265cli.h	Fri Oct 23 19:50:49 2015 +0530
+++ b/source/x265cli.h	Fri Oct 23 19:32:21 2015 +0530
@@ -157,6 +157,8 @@
     { "psy-rdoq",       required_argument, NULL, 0 },
     { "no-psy-rd",            no_argument, NULL, 0 },
     { "no-psy-rdoq",          no_argument, NULL, 0 },
+    { "rd-refine",            no_argument, NULL, 0 },
+    { "no-rd-refine",         no_argument, NULL, 0 },
     { "scaling-list",   required_argument, NULL, 0 },
     { "lossless",             no_argument, NULL, 0 },
     { "no-lossless",          no_argument, NULL, 0 },
@@ -298,6 +300,7 @@
     H0("   --[no-]psy-rd <0..2.0>        Strength of psycho-visual rate distortion optimization, 0 to disable. Default %.1f\n", param->psyRd);
     H0("   --[no-]rdoq-level <0|1|2>     Level of RDO in quantization 0:none, 1:levels, 2:levels & coding groups. Default %d\n", param->rdoqLevel);
     H0("   --[no-]psy-rdoq <0..50.0>     Strength of psycho-visual optimization in RDO quantization, 0 to disable. Default %.1f\n", param->psyRdoq);
+    H0("   --[no-]rd-refine              Enable QP based RD refinement for rd levels 5 and 6. Default %s\n", OPT(param->bEnableRdRefine));
     H0("   --[no-]early-skip             Enable early SKIP detection. Default %s\n", OPT(param->bEnableEarlySkip));
     H1("   --[no-]tskip-fast             Enable fast intra transform skipping. Default %s\n", OPT(param->bEnableTSkipFast));
     H1("   --nr-intra <integer>          An integer value in range of 0 to 2000, which denotes strength of noise reduction in intra CUs. Default 0\n");


More information about the x265-devel mailing list