changeset 12603:fe9d36ccb331

hdr-opt: Replace --hdr-opt with --hdr10-opt This patch deprecates the existing option '--hdr-opt' as the name sounds generic even though the feature does QP optimizations only for HDR10 content and introduces '--hdr10-opt' as an alternate. This patch also fixes nits in a warning message. Note: '--hdr-opt' will be removed in the upcoming major release of x265.
author Aruna Matheswaran <aruna@multicorewareinc.com>
date Mon, 06 Jan 2020 10:44:13 +0530
parents 1eb0fa24bb87
children 3780f7544794
files doc/reST/cli.rst source/CMakeLists.txt source/common/param.cpp source/encoder/encoder.cpp source/encoder/frameencoder.cpp source/encoder/slicetype.cpp source/x265.h source/x265cli.h
diffstat 8 files changed, 32 insertions(+-), 21 deletions(-) [+]
line wrap: on
line diff
--- a/doc/reST/cli.rst	Tue Jan 07 19:10:59 2020 +0530
+++ b/doc/reST/cli.rst	Mon Jan 06 10:44:13 2020 +0530
@@ -2257,11 +2257,13 @@ VUI fields must be manually specified.
 	specified. Useful when there is a desire to signal 0 values for max-cll
 	and max-fall. Default disabled.
 
-.. option:: --hdr-opt, --no-hdr-opt
-
-	Add luma and chroma offsets for HDR/WCG content.
-	Input video should be 10 bit 4:2:0. Applicable for HDR content. It is recommended
-	that AQ-mode be enabled along with this feature. Default disabled.
+.. option:: --hdr10-opt, --no-hdr10-opt
+
+	Enable block-level luma and chroma QP optimization for HDR10 content
+	as suggested in ITU-T H-series Recommendations  Supplement 15.
+	Source video should have HDR10 characteristics such as 10-bit depth 4:2:0
+	with Bt.2020 color primaries and SMPTE ST.2084 transfer characteristics.
+	It is recommended that AQ-mode be enabled along with this feature. Default disabled.
 
 .. option:: --dhdr10-info <filename>
 
--- a/source/CMakeLists.txt	Tue Jan 07 19:10:59 2020 +0530
+++ b/source/CMakeLists.txt	Mon Jan 06 10:44:13 2020 +0530
@@ -29,7 +29,7 @@ option(NATIVE_BUILD "Target the build CP
 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 184)
+set(X265_BUILD 185)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
--- a/source/common/param.cpp	Tue Jan 07 19:10:59 2020 +0530
+++ b/source/common/param.cpp	Mon Jan 06 10:44:13 2020 +0530
@@ -318,7 +318,8 @@ void x265_param_default(x265_param* para
     param->bOptRefListLengthPPS = 0;
     param->bOptCUDeltaQP        = 0;
     param->bAQMotion = 0;
-    param->bHDROpt = 0;
+    param->bHDROpt = 0; /*DEPRECATED*/
+    param->bHDR10Opt = 0;
     param->analysisReuseLevel = 5;
     param->toneMapFile = NULL;
     param->bDhdr10opt = 0;
@@ -1231,7 +1232,8 @@ int x265_param_parse(x265_param* p, cons
             }
         }
         OPT("hdr") p->bEmitHDRSEI = atobool(value);
-        OPT("hdr-opt") p->bHDROpt = atobool(value);
+        OPT("hdr-opt") p->bHDR10Opt = atobool(value); /*DEPRECATED*/
+        OPT("hdr10-opt") p->bHDR10Opt = atobool(value);
         OPT("limit-sao") p->bLimitSAO = atobool(value);
         OPT("dhdr10-info") p->toneMapFile = strdup(value);
         OPT("dhdr10-opt") p->bDhdr10opt = atobool(value);
@@ -2152,7 +2154,7 @@ char *x265_param2string(x265_param* p, i
     BOOL(p->bOptCUDeltaQP, "opt-cu-delta-qp");
     BOOL(p->bAQMotion, "aq-motion");
     BOOL(p->bEmitHDRSEI, "hdr");
-    BOOL(p->bHDROpt, "hdr-opt");
+    BOOL(p->bHDR10Opt, "hdr10-opt");
     BOOL(p->bDhdr10opt, "dhdr10-opt");
     BOOL(p->bEmitIDRRecoverySEI, "idr-recovery-sei");
     if (p->analysisSave)
@@ -2475,7 +2477,8 @@ void x265_copy_params(x265_param* dst, x
     dst->dynamicRd = src->dynamicRd;
     dst->bEmitHDRSEI = src->bEmitHDRSEI;
     dst->bEmitHRDSEI = src->bEmitHRDSEI;
-    dst->bHDROpt = src->bHDROpt;
+    dst->bHDROpt = src->bHDROpt; /*DEPRECATED*/
+    dst->bHDR10Opt = src->bHDR10Opt;
     dst->analysisReuseLevel = src->analysisReuseLevel;
     dst->bLimitSAO = src->bLimitSAO;
     if (src->toneMapFile) dst->toneMapFile = strdup(src->toneMapFile);
--- a/source/encoder/encoder.cpp	Tue Jan 07 19:10:59 2020 +0530
+++ b/source/encoder/encoder.cpp	Mon Jan 06 10:44:13 2020 +0530
@@ -3289,7 +3289,7 @@ void Encoder::initPPS(PPS *pps)
 
     pps->chromaQpOffset[0] = m_param->cbQpOffset;
     pps->chromaQpOffset[1] = m_param->crQpOffset;
-    pps->pps_slice_chroma_qp_offsets_present_flag = m_param->bHDROpt;
+    pps->pps_slice_chroma_qp_offsets_present_flag = m_param->bHDR10Opt;
 
     pps->bConstrainedIntraPred = m_param->bEnableConstrainedIntra;
     pps->bUseWeightPred = m_param->bEnableWeightedPred;
@@ -3727,7 +3727,7 @@ void Encoder::configure(x265_param *p)
 
     if (!p->rc.bStatWrite && !p->rc.bStatRead && (p->analysisMultiPassRefine || p->analysisMultiPassDistortion))
     {
-        x265_log(p, X265_LOG_WARNING, "analysis-multi-pass/distortion is enabled only when rc multi pass is enabled. Disabling multi-pass-opt-analysis and multi-pass-opt-distortion");
+        x265_log(p, X265_LOG_WARNING, "analysis-multi-pass/distortion is enabled only when rc multi pass is enabled. Disabling multi-pass-opt-analysis and multi-pass-opt-distortion\n");
         p->analysisMultiPassRefine = 0;
         p->analysisMultiPassDistortion = 0;
     }
@@ -3999,21 +3999,21 @@ void Encoder::configure(x265_param *p)
         x265_log(p, X265_LOG_WARNING, "maxSlices can not be more than min(rows, MAX_NAL_UNITS-1), force set to %d\n", slicesLimit);
         p->maxSlices = slicesLimit;
     }
-    if (p->bHDROpt)
+    if (p->bHDR10Opt)
     {
         if (p->internalCsp != X265_CSP_I420 || p->internalBitDepth != 10 || p->vui.colorPrimaries != 9 ||
             p->vui.transferCharacteristics != 16 || p->vui.matrixCoeffs != 9)
         {
-            x265_log(p, X265_LOG_ERROR, "Recommended Settings for HDR: colour primaries should be BT.2020,\n"
+            x265_log(p, X265_LOG_ERROR, "Recommended Settings for HDR10-opt: colour primaries should be BT.2020,\n"
                                         "                                            transfer characteristics should be SMPTE ST.2084,\n"
                                         "                                            matrix coeffs should be BT.2020,\n"
                                         "                                            the input video should be 10 bit 4:2:0\n"
-                                        "                                            Disabling offset tuning for HDR videos\n");
-            p->bHDROpt = 0;
+                                        "                                            Disabling hdr10-opt.\n");
+            p->bHDR10Opt = 0;
         }
     }
 
-    if (m_param->toneMapFile || p->bHDROpt || p->bEmitHDRSEI)
+    if (m_param->toneMapFile || p->bHDR10Opt || p->bEmitHDRSEI)
     {
         if (!p->bRepeatHeaders)
         {
--- a/source/encoder/frameencoder.cpp	Tue Jan 07 19:10:59 2020 +0530
+++ b/source/encoder/frameencoder.cpp	Mon Jan 06 10:44:13 2020 +0530
@@ -591,7 +591,7 @@ void FrameEncoder::compressFrame()
 
     /* Clip slice QP to 0-51 spec range before encoding */
     slice->m_sliceQp = x265_clip3(-QP_BD_OFFSET, QP_MAX_SPEC, qp);
-    if (m_param->bHDROpt)
+    if (m_param->bHDR10Opt)
     {
         int qpCb = x265_clip3(-12, 0, (int)floor((m_top->m_cB * ((-.46) * qp + 9.26)) + 0.5 ));
         int qpCr = x265_clip3(-12, 0, (int)floor((m_top->m_cR * ((-.46) * qp + 9.26)) + 0.5 ));
--- a/source/encoder/slicetype.cpp	Tue Jan 07 19:10:59 2020 +0530
+++ b/source/encoder/slicetype.cpp	Mon Jan 06 10:44:13 2020 +0530
@@ -593,7 +593,7 @@ void LookaheadTLD::calcAdaptiveQuantFram
                             qp_adj = strength * (X265_LOG2(X265_MAX(energy, 1)) - (modeOneConst + 2 * (X265_DEPTH - 8)));
                         }
 
-                        if (param->bHDROpt)
+                        if (param->bHDR10Opt)
                         {
                             uint32_t sum = lumaSumCu(curFrame, blockX, blockY, param->rc.qgSize);
                             uint32_t lumaAvg = sum / (loopIncr * loopIncr);
--- a/source/x265.h	Tue Jan 07 19:10:59 2020 +0530
+++ b/source/x265.h	Mon Jan 06 10:44:13 2020 +0530
@@ -1651,7 +1651,7 @@ typedef struct x265_param
     int       bEmitHDRSEI;
 
     /* Enable luma and chroma offsets for HDR/WCG content.
-     * Default is disabled */
+     * Default is disabled. Now deprecated.*/
     int       bHDROpt;
 
     /* A value between 1 and 10 (both inclusive) determines the level of
@@ -1859,6 +1859,9 @@ typedef struct x265_param
 
     /* Enable HME search ranges for L0, L1 and L2 respectively. */
     int       hmeRange[3];
+
+    /* Block-level QP optimization for HDR10 content. Default is disabled.*/
+    int       bHDR10Opt;
 } x265_param;
 
 /* x265_param_alloc:
--- a/source/x265cli.h	Tue Jan 07 19:10:59 2020 +0530
+++ b/source/x265cli.h	Mon Jan 06 10:44:13 2020 +0530
@@ -299,6 +299,8 @@ static const struct option long_options[
     { "no-hdr",               no_argument, NULL, 0 },
     { "hdr-opt",              no_argument, NULL, 0 },
     { "no-hdr-opt",           no_argument, NULL, 0 },
+    { "hdr10-opt",            no_argument, NULL, 0 },
+    { "no-hdr10-opt",         no_argument, NULL, 0 },
     { "limit-sao",            no_argument, NULL, 0 },
     { "no-limit-sao",         no_argument, NULL, 0 },
     { "dhdr10-info",    required_argument, NULL, 0 },
@@ -631,7 +633,8 @@ static void showHelp(x265_param *param)
     H0("   --max-cll <string>            Specify content light level info SEI as \"cll,fall\" (HDR).\n");
     H0("   --[no-]cll                    Emit content light level info SEI. Default %s\n", OPT(param->bEmitCLL));
     H0("   --[no-]hdr                    Control dumping of HDR SEI packet. If max-cll or master-display has non-zero values, this is enabled. Default %s\n", OPT(param->bEmitHDRSEI));
-    H0("   --[no-]hdr-opt                Add luma and chroma offsets for HDR/WCG content. Default %s\n", OPT(param->bHDROpt));
+    H0("   --[no-]hdr-opt                Add luma and chroma offsets for HDR/WCG content. Default %s. Now deprecated.\n", OPT(param->bHDROpt));
+    H0("   --[no-]HDR10-opt              Block-level QP optimization for HDR10 content. Default %s.\n", OPT(param->bHDR10Opt));
     H0("   --min-luma <integer>          Minimum luma plane value of input source picture\n");
     H0("   --max-luma <integer>          Maximum luma plane value of input source picture\n");
     H0("\nBitstream options:\n");