changeset 12514:ccc7a3edd595 draft

cli: Introduce option to signal content light level SEI. This patch also fixes indentation issues.
author Aruna Matheswaran
date Thu, 23 May 2019 19:38:47 +0530
parents 220cdb4328a1
children b9bef1a4c34a
files doc/reST/cli.rst source/CMakeLists.txt source/common/param.cpp source/encoder/encoder.cpp source/encoder/encoder.h source/x265.h source/x265cli.h
diffstat 7 files changed, 37 insertions(+-), 22 deletions(-) [+]
line wrap: on
line diff
--- a/doc/reST/cli.rst	Thu May 23 11:28:44 2019 +0800
+++ b/doc/reST/cli.rst	Thu May 23 19:38:47 2019 +0530
@@ -2154,6 +2154,12 @@ VUI fields must be manually specified.
 	Note that this string value will need to be escaped or quoted to
 	protect against shell expansion on many platforms. No default.
 
+.. option:: --cll, --no-cll
+
+    Emit content light level SEI. Enabled automatically when :option:`--dolby-vision-profile` 8.1
+    is specified. When enabled, signals max-cll and max-fall as 0 if :option:`max-cll` is unspecified.
+    Default enabled.
+
 .. option:: --hdr, --no-hdr
 
 	Force signalling of HDR parameters in SEI packets. Enabled
--- a/source/CMakeLists.txt	Thu May 23 11:28:44 2019 +0800
+++ b/source/CMakeLists.txt	Thu May 23 19:38:47 2019 +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 175)
+set(X265_BUILD 176)
 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	Thu May 23 11:28:44 2019 +0800
+++ b/source/common/param.cpp	Thu May 23 19:38:47 2019 +0530
@@ -332,6 +332,7 @@ void x265_param_default(x265_param* para
     /* SEI messages */
     param->preferredTransferCharacteristics = -1;
     param->pictureStructure = -1;
+    param->bEmitCLL = 1;
 
     /* SVT Hevc Encoder specific params */
     param->bEnableSvtHevc = 0;
@@ -573,10 +574,10 @@ int x265_param_default_preset(x265_param
             param->deblockingFilterBetaOffset = 1;
             param->deblockingFilterTCOffset = 1;
         }
-		else if (!strcmp(tune, "vmaf"))  /*Adding vmaf for x265 + SVT-HEVC integration support*/
-		{
-			/*vmaf is under development, currently x265 won't support vmaf*/
-		}
+        else if (!strcmp(tune, "vmaf"))  /*Adding vmaf for x265 + SVT-HEVC integration support*/
+        {
+            /*vmaf is under development, currently x265 won't support vmaf*/
+        }
         else
             return -1;
     }
@@ -2016,7 +2017,8 @@ char *x265_param2string(x265_param* p, i
         p->vui.defDispWinRightOffset, p->vui.defDispWinBottomOffset);
     if (p->masteringDisplayColorVolume)
         s += sprintf(s, " master-display=%s", p->masteringDisplayColorVolume);
-    s += sprintf(s, " max-cll=%hu,%hu", p->maxCLL, p->maxFALL);
+    if (p->bEmitCLL)
+        s += sprintf(s, "cll=%hu,%hu", p->maxCLL, p->maxFALL);
     s += sprintf(s, " min-luma=%hu", p->minLuma);
     s += sprintf(s, " max-luma=%hu", p->maxLuma);
     s += sprintf(s, " log2-max-poc-lsb=%d", p->log2MaxPocLsb);
@@ -2314,6 +2316,7 @@ void x265_copy_params(x265_param* dst, x
     else dst->masteringDisplayColorVolume = NULL;
     dst->maxLuma = src->maxLuma;
     dst->minLuma = src->minLuma;
+    dst->bEmitCLL = src->bEmitCLL;
     dst->maxCLL = src->maxCLL;
     dst->maxFALL = src->maxFALL;
     dst->log2MaxPocLsb = src->log2MaxPocLsb;
@@ -2439,7 +2442,7 @@ void svt_param_default(x265_param* param
     svtHevcParam->frameRateNumerator = 0;
     svtHevcParam->frameRateDenominator = 0;
     svtHevcParam->encoderBitDepth = 8;
-	svtHevcParam->encoderColorFormat = EB_YUV420;
+    svtHevcParam->encoderColorFormat = EB_YUV420;
     svtHevcParam->compressedTenBitFormat = 0;
     svtHevcParam->rateControlMode = 0;
     svtHevcParam->sceneChangeDetection = 1;
@@ -2477,11 +2480,11 @@ void svt_param_default(x265_param* param
     svtHevcParam->maxCLL = 0;
     svtHevcParam->maxFALL = 0;
     svtHevcParam->useMasteringDisplayColorVolume = 0;
-	svtHevcParam->useNaluFile = 0;
-	svtHevcParam->whitePointX = 0;
-	svtHevcParam->whitePointY = 0;
-	svtHevcParam->maxDisplayMasteringLuminance = 0;
-	svtHevcParam->minDisplayMasteringLuminance = 0;
+    svtHevcParam->useNaluFile = 0;
+    svtHevcParam->whitePointX = 0;
+    svtHevcParam->whitePointY = 0;
+    svtHevcParam->maxDisplayMasteringLuminance = 0;
+    svtHevcParam->minDisplayMasteringLuminance = 0;
     svtHevcParam->dolbyVisionProfile = 0;
     svtHevcParam->targetSocket = -1;
     svtHevcParam->logicalProcessors = 0;
@@ -2513,7 +2516,7 @@ int svt_set_preset_tune(x265_param* para
         else if (!strcmp(tune, "ssim")) svtHevcParam->tune = 1;
         else if (!strcmp(tune, "grain")) svtHevcParam->tune = 0;
         else if (!strcmp(tune, "animation")) svtHevcParam->tune = 0;
-		else if (!strcmp(tune, "vmaf")) svtHevcParam->tune = 2;
+        else if (!strcmp(tune, "vmaf")) svtHevcParam->tune = 2;
         else if (!strcmp(tune, "zero-latency") || !strcmp(tune, "zerolatency")) svtHevcParam->latencyMode = 1;
         else  return -1;
     }
--- a/source/encoder/encoder.cpp	Thu May 23 11:28:44 2019 +0800
+++ b/source/encoder/encoder.cpp	Thu May 23 19:38:47 2019 +0530
@@ -444,8 +444,6 @@ void Encoder::create()
 
     m_nalList.m_annexB = !!m_param->bAnnexB;
 
-    m_emitCLLSEI = p->maxCLL || p->maxFALL || (p->dolbyProfile == 81);
-
     if (m_param->naluFile)
     {
         m_naluFile = x265_fopen(m_param->naluFile, "r");
@@ -2462,10 +2460,13 @@ void Encoder::getStreamHeaders(NALList& 
 
     if (m_param->bEmitHDRSEI)
     {
-        SEIContentLightLevel cllsei;
-        cllsei.max_content_light_level = m_param->maxCLL;
-        cllsei.max_pic_average_light_level = m_param->maxFALL;
-        cllsei.writeSEImessages(bs, m_sps, NAL_UNIT_PREFIX_SEI, list, m_param->bSingleSeiNal);
+        if (m_param->bEmitCLL)
+        {
+            SEIContentLightLevel cllsei;
+            cllsei.max_content_light_level = m_param->maxCLL;
+            cllsei.max_pic_average_light_level = m_param->maxFALL;
+            cllsei.writeSEImessages(bs, m_sps, NAL_UNIT_PREFIX_SEI, list, m_param->bSingleSeiNal);
+        }
 
         if (m_param->masteringDisplayColorVolume)
         {
@@ -2711,7 +2712,7 @@ void Encoder::configureDolbyVisionParams
     p->vui.matrixCoeffs = dovi[doviProfile].matrixCoeffs;
 
     if (dovi[doviProfile].doviProfileId == 81)
-        p->bEmitHDRSEI = 1;
+        p->bEmitHDRSEI = p->bEmitCLL = 1;
 
     if (dovi[doviProfile].doviProfileId == 50)
         p->crQpOffset = 3;
--- a/source/encoder/encoder.h	Thu May 23 11:28:44 2019 +0800
+++ b/source/encoder/encoder.h	Thu May 23 19:38:47 2019 +0530
@@ -203,7 +203,6 @@ public:
     ScalingList        m_scalingList;      // quantization matrix information
     Window             m_conformanceWindow;
 
-    bool               m_emitCLLSEI;
     bool               m_bZeroLatency;     // x265_encoder_encode() returns NALs for the input picture, zero lag
     bool               m_aborted;          // fatal error detected
     bool               m_reconfigure;      // Encoder reconfigure in progress
--- a/source/x265.h	Thu May 23 11:28:44 2019 +0800
+++ b/source/x265.h	Thu May 23 19:38:47 2019 +0530
@@ -1780,6 +1780,9 @@ typedef struct x265_param
 
     /* Enable field coding */
     int bField;
+
+    /*Emit content light level info SEI*/
+    int         bEmitCLL;
 } x265_param;
 /* x265_param_alloc:
  *  Allocates an x265_param instance. The returned param structure is not
--- a/source/x265cli.h	Thu May 23 11:28:44 2019 +0800
+++ b/source/x265cli.h	Thu May 23 19:38:47 2019 +0530
@@ -336,6 +336,8 @@ static const struct option long_options[
     { "svt-fps-in-vps",  no_argument  , NULL, 0 },
     { "no-svt-fps-in-vps",  no_argument  , NULL, 0 },
 #endif
+    { "cll", no_argument, NULL, 0 },
+    { "no-cll", no_argument, NULL, 0 },
     { 0, 0, 0, 0 },
     { 0, 0, 0, 0 },
     { 0, 0, 0, 0 },
@@ -602,7 +604,8 @@ static void showHelp(x265_param *param)
     H1("   --chromaloc <integer>         Specify chroma sample location (0 to 5). Default of %d\n", param->vui.chromaSampleLocTypeTopField);
     H0("   --master-display <string>     SMPTE ST 2086 master display color volume info SEI (HDR)\n");
     H0("                                    format: G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)\n");
-    H0("   --max-cll <string>            Emit content light level info SEI as \"cll,fall\" (HDR)\n");
+    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("   --min-luma <integer>          Minimum luma plane value of input source picture\n");