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

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Wed Nov 11 16:45:16 CET 2015


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1446805827 -19800
#      Fri Nov 06 16:00:27 2015 +0530
# Node ID c6f7c8008dafba821527c2f46246567f5c2312ca
# Parent  8ba2a0efe283b46d6afebe1f06701df259233e14
cli: add --rd-refine option to enable QP based RD refinement

The option is effective for rdLevels greater than 4

diff -r 8ba2a0efe283 -r c6f7c8008daf doc/reST/cli.rst
--- a/doc/reST/cli.rst	Fri Oct 23 19:50:49 2015 +0530
+++ b/doc/reST/cli.rst	Fri Nov 06 16:00:27 2015 +0530
@@ -755,6 +755,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 8ba2a0efe283 -r c6f7c8008daf source/CMakeLists.txt
--- a/source/CMakeLists.txt	Fri Oct 23 19:50:49 2015 +0530
+++ b/source/CMakeLists.txt	Fri Nov 06 16:00:27 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 77)
+set(X265_BUILD 78)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 8ba2a0efe283 -r c6f7c8008daf source/common/param.cpp
--- a/source/common/param.cpp	Fri Oct 23 19:50:49 2015 +0530
+++ b/source/common/param.cpp	Fri Nov 06 16:00:27 2015 +0530
@@ -193,6 +193,7 @@
     param->bLossless = 0;
     param->bCULossless = 0;
     param->bEnableTemporalSubLayers = 0;
+    param->bEnableRdRefine = 0;
 
     /* Rate control options */
     param->rc.vbvMaxBitrate = 0;
@@ -697,6 +698,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 */
@@ -1331,6 +1333,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");
@@ -1460,6 +1463,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 8ba2a0efe283 -r c6f7c8008daf source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Fri Oct 23 19:50:49 2015 +0530
+++ b/source/encoder/encoder.cpp	Fri Nov 06 16:00:27 2015 +0530
@@ -1780,6 +1780,11 @@
         p->analysisMode = X265_ANALYSIS_OFF;
         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 8ba2a0efe283 -r c6f7c8008daf source/x265.h
--- a/source/x265.h	Fri Oct 23 19:50:49 2015 +0530
+++ b/source/x265.h	Fri Nov 06 16:00:27 2015 +0530
@@ -948,6 +948,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 8ba2a0efe283 -r c6f7c8008daf source/x265cli.h
--- a/source/x265cli.h	Fri Oct 23 19:50:49 2015 +0530
+++ b/source/x265cli.h	Fri Nov 06 16:00:27 2015 +0530
@@ -159,6 +159,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 },
@@ -300,6 +302,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