[x265] [PATCH] sei: add seperate options --max-cll and --max-fall

Steve Borho steve at borho.org
Fri Aug 28 16:52:26 CEST 2015


On 08/28, kavitha at multicorewareinc.com wrote:
> # HG changeset patch
> # User Kavitha Sampath <kavitha at multicorewareinc.com>
> # Date 1440764874 -19800
> #      Fri Aug 28 17:57:54 2015 +0530
> # Node ID c4459ee05157ae1eb6362c9073603908279411e0
> # Parent  d8091487bc9749e702c468786b0cd9e663478a91
> sei: add seperate options --max-cll and --max-fall
> 
> Earlier --max-cll option takes up both maxCLL and maxFALL values
> as a single string and parses them to contentLightLevelSEI. This
> commit enables users to specify maxCLL and maxFALL seperately as
> two independant integers.
> 
> diff -r d8091487bc97 -r c4459ee05157 doc/reST/cli.rst
> --- a/doc/reST/cli.rst	Tue Aug 25 16:39:12 2015 -0700
> +++ b/doc/reST/cli.rst	Fri Aug 28 17:57:54 2015 +0530
> @@ -1623,19 +1623,21 @@
>  	Note that this string value will need to be escaped or quoted to
>  	protect against shell expansion on many platforms. No default.
>  
> -.. option:: --max-cll <string>
> +.. option:: --max-cll <integer>
>  
> -	Maximum content light level and maximum frame average light level as
> -	required by the Consumer Electronics Association 861.3 specification.
> +	Maximum content light level as required by the Consumer Electronics
> +	Association 861.3 specification.
>  
> -	Specified as a string which is parsed when the stream header SEI are
> -	emitted. The string format is "%hu,%hu" where %hu are unsigned 16bit
> -	integers. The first value is the max content light level (or 0 if no
> -	maximum is indicated), the second value is the maximum picture
> -	average light level (or 0). (HDR)
> +	Specified as integer that indicates the maximum pixel intensity level
> +	in units of 1 candela per square metre of the bitstream (HDR). No default.
>  
> -	Note that this string value will need to be escaped or quoted to
> -	protect against shell expansion on many platforms. No default.
> +.. option:: --max-fall <integer>
> +
> +	Maximum frame average light level as required by the Consumer Electronics
> +	Association 861.3 specification.
> +
> +	Specified as integer that indicates the maximum frame average intensity level
> +	in units of 1 candela per square metre of the bitstream (HDR). No default.
>  
>  .. option:: --min-luma <integer>
>  
> diff -r d8091487bc97 -r c4459ee05157 source/CMakeLists.txt
> --- a/source/CMakeLists.txt	Tue Aug 25 16:39:12 2015 -0700
> +++ b/source/CMakeLists.txt	Fri Aug 28 17:57:54 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 72)
> +set(X265_BUILD 73)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>                 "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r d8091487bc97 -r c4459ee05157 source/common/param.cpp
> --- a/source/common/param.cpp	Tue Aug 25 16:39:12 2015 -0700
> +++ b/source/common/param.cpp	Fri Aug 28 17:57:54 2015 +0530
> @@ -241,6 +241,8 @@
>      param->vui.defDispWinRightOffset = 0;
>      param->vui.defDispWinTopOffset = 0;
>      param->vui.defDispWinBottomOffset = 0;
> +    param->maxCLL = 0;
> +    param->maxFALL = 0;
>      param->minLuma = 0;
>      param->maxLuma = (1 << X265_DEPTH) - 1;
>  }
> @@ -856,7 +858,8 @@
>      OPT("analysis-file") p->analysisFileName = strdup(value);
>      OPT("qg-size") p->rc.qgSize = atoi(value);
>      OPT("master-display") p->masteringDisplayColorVolume = strdup(value);
> -    OPT("max-cll") p->contentLightLevelInfo = strdup(value);
> +    OPT("max-cll") p->maxCLL = (uint16_t)atoi(value);
> +    OPT("max-fall") p->maxFALL = (uint16_t)atoi(value);

this is going to surprise some people. the behavior of --max-cll is
changing in a non-obvious way. If a user's script passed "--max-cll
10,12" there is no hint to them that the max frame-average light level
is no longer getting configured (the atoi simply discards it).

We should probably leave --max-cll in place so we don't break existing
workflows.

  OPT("max-cll") bError |= sscanf(value, "%hu,%hu", &p->maxCLL, &p->maxFALL) != 2;

This means we need to come up with different option names for setting
maxCLL and maxFALL seperately (if there's a compelling reason to set
them this way).

>      OPT("min-luma") p->minLuma = (uint16_t)atoi(value);
>      OPT("max-luma") p->maxLuma = (uint16_t)atoi(value);
>      else
> diff -r d8091487bc97 -r c4459ee05157 source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp	Tue Aug 25 16:39:12 2015 -0700
> +++ b/source/encoder/encoder.cpp	Fri Aug 28 17:57:54 2015 +0530
> @@ -255,6 +255,8 @@
>      m_encodeStartTime = x265_mdate();
>  
>      m_nalList.m_annexB = !!m_param->bAnnexB;
> +
> +    m_emitCLLSEI = p->maxCLL || p->maxFALL;
>  }
>  
>  void Encoder::stopJobs()
> @@ -326,7 +328,6 @@
>          free((char*)m_param->scalingLists);
>          free((char*)m_param->numaPools);
>          free((char*)m_param->masteringDisplayColorVolume);
> -        free((char*)m_param->contentLightLevelInfo);
>  
>          PARAM_NS::x265_param_free(m_param);
>      }
> @@ -1046,6 +1047,12 @@
>  
>          stats->maxCLL         = m_analyzeAll.m_maxCLL;
>          stats->maxFALL        = (uint16_t)(m_analyzeAll.m_maxFALL / m_analyzeAll.m_numPics);
> +
> +        if(m_emitCLLSEI)

w/s nit, otherwise the rest of the patch looks good

> +        {
> +            m_param->maxCLL = stats->maxCLL;
> +            m_param->maxFALL = stats->maxFALL;
> +        }
>      }
>  
>      /* If new statistics are added to x265_stats, we must check here whether the
> @@ -1227,18 +1234,15 @@
>              x265_log(m_param, X265_LOG_WARNING, "unable to parse mastering display color volume info\n");
>      }
>  
> -    if (m_param->contentLightLevelInfo)
> +    if (m_emitCLLSEI)
>      {
>          SEIContentLightLevel cllsei;
> -        if (cllsei.parse(m_param->contentLightLevelInfo))
> -        {
> -            bs.resetBits();
> -            cllsei.write(bs, m_sps);
> -            bs.writeByteAlignment();
> -            list.serialize(NAL_UNIT_PREFIX_SEI, bs);
> -        }
> -        else
> -            x265_log(m_param, X265_LOG_WARNING, "unable to parse content light level info\n");
> +        cllsei.max_content_light_level = m_param->maxCLL;
> +        cllsei.max_pic_average_light_level = m_param->maxFALL;
> +        bs.resetBits();
> +        cllsei.write(bs, m_sps);
> +        bs.writeByteAlignment();
> +        list.serialize(NAL_UNIT_PREFIX_SEI, bs);
>      }
>  
>      if (m_param->bEmitInfoSEI)
> diff -r d8091487bc97 -r c4459ee05157 source/encoder/encoder.h
> --- a/source/encoder/encoder.h	Tue Aug 25 16:39:12 2015 -0700
> +++ b/source/encoder/encoder.h	Fri Aug 28 17:57:54 2015 +0530
> @@ -117,6 +117,7 @@
>      NALList            m_nalList;
>      ScalingList        m_scalingList;      // quantization matrix information
>  
> +    bool               m_emitCLLSEI;
>      int                m_lastBPSEI;
>      uint32_t           m_numDelayedPic;
>  
> diff -r d8091487bc97 -r c4459ee05157 source/encoder/sei.h
> --- a/source/encoder/sei.h	Tue Aug 25 16:39:12 2015 -0700
> +++ b/source/encoder/sei.h	Fri Aug 28 17:57:54 2015 +0530
> @@ -163,12 +163,6 @@
>  
>      PayloadType payloadType() const { return CONTENT_LIGHT_LEVEL_INFO; }
>  
> -    bool parse(const char* value)
> -    {
> -        return sscanf(value, "%hu,%hu",
> -                      &max_content_light_level, &max_pic_average_light_level) == 2;
> -    }
> -
>      void write(Bitstream& bs, const SPS&)
>      {
>          m_bitIf = &bs;
> diff -r d8091487bc97 -r c4459ee05157 source/x265.h
> --- a/source/x265.h	Tue Aug 25 16:39:12 2015 -0700
> +++ b/source/x265.h	Fri Aug 28 17:57:54 2015 +0530
> @@ -1175,12 +1175,17 @@
>       * max,min luminance values. */
>      const char* masteringDisplayColorVolume;
>  
> -    /* Content light level info SEI, specified as a string which is parsed when
> -     * the stream header SEI are emitted. The string format is "%hu,%hu" where
> -     * %hu are unsigned 16bit integers. The first value is the max content light
> -     * level (or 0 if no maximum is indicated), the second value is the maximum
> -     * picture average light level (or 0). */
> -    const char* contentLightLevelInfo;
> +    /* Maximum Content light level(MaxCLL), specified as integer that indicates the
> +     * maximum pixel intensity level in units of 1 candela per square metre of the
> +     * bitstream. x265 will also calculate MaxCLL programmatically from the input
> +     * pixel values and set in the Content light level info SEI */
> +    uint16_t maxCLL;
> +
> +    /* Maximum Frame Average Light Level(MaxFALL), specified as integer that indicates
> +     * the maximum frame average intensity level in units of 1 candela per square
> +     * metre of the bitstream. x265 will also calculate MaxFALL programmatically
> +     * from the input pixel values and set in the Content light level info SEI */
> +    uint16_t maxFALL;
>  
>      /* Minimum luma level of input source picture, specified as a integer which
>       * would automatically increase any luma values below the specified --min-luma
> diff -r d8091487bc97 -r c4459ee05157 source/x265cli.h
> --- a/source/x265cli.h	Tue Aug 25 16:39:12 2015 -0700
> +++ b/source/x265cli.h	Fri Aug 28 17:57:54 2015 +0530
> @@ -192,6 +192,7 @@
>      { "crop-rect",      required_argument, NULL, 0 }, /* DEPRECATED */
>      { "master-display", required_argument, NULL, 0 },
>      { "max-cll",        required_argument, NULL, 0 },
> +    { "max-fall",       required_argument, NULL, 0 },
>      { "min-luma",       required_argument, NULL, 0 },
>      { "max-luma",       required_argument, NULL, 0 },
>      { "no-dither",            no_argument, NULL, 0 },
> @@ -404,7 +405,8 @@
>      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 <integer>           Record Maximum Content Light Level(maxCLL) to emit SEI (HDR)\n");
> +    H0("   --max-fall <integer>          Record Maximum Frame Average Light Level(maxFALL) to emit SEI (HDR)\n");
>      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");
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel

-- 
Steve Borho


More information about the x265-devel mailing list