[x265] [PATCH 1 of 2]Add support for Dolby Vision profile 8.1

Kalyan Goswami kalyan at multicorewareinc.com
Thu Dec 27 09:35:50 CET 2018


Pushed to default

Thanks,
Kalyan Goswami, PhD
Video Architect @ MulticoreWare
http: <http://www.multicorewareinc.com/>//www.multicorewareinc.com
<http://www.multicorewareinc.com/>
+91 9884989331


On Wed, Dec 26, 2018 at 8:31 PM Kirithika Kalirathnam <
kirithika at multicorewareinc.com> wrote:

> # HG changeset patch
> # User kirithika <kirithika at multicorewareinc.com>
> # Date 1545830230 -19800
> #      Wed Dec 26 18:47:10 2018 +0530
> # Node ID d757a721369b0fc576fa43adf166e7488c4046bf
> # Parent  1951152ff12db320a4b626e57ee1c870d84d7f14
> Add support for Dolby Vision profile 8.1
>
> diff -r 1951152ff12d -r d757a721369b doc/reST/cli.rst
> --- a/doc/reST/cli.rst Fri Dec 07 12:52:46 2018 +0530
> +++ b/doc/reST/cli.rst Wed Dec 26 18:47:10 2018 +0530
> @@ -2236,7 +2236,7 @@
>      The value is specified as a float or as an integer with the profile
> times 10,
>      for example profile 5 is specified as "5" or "5.0" or "50".
>
> -    Currently only profile 5 enabled, Default 0 (disabled)
> +    Currently only profile 5 and profile 8.1 enabled, Default 0 (disabled)
>
>  .. option:: --dolby-vision-rpu <filename>
>
> diff -r 1951152ff12d -r d757a721369b source/common/param.cpp
> --- a/source/common/param.cpp Fri Dec 07 12:52:46 2018 +0530
> +++ b/source/common/param.cpp Wed Dec 26 18:47:10 2018 +0530
> @@ -1545,14 +1545,16 @@
>          "Invalid refine-ctu-distortion value, must be either 0 or 1");
>      CHECK(param->maxAUSizeFactor < 0.5 || param->maxAUSizeFactor > 1.0,
>          "Supported factor for controlling max AU size is from 0.5 to 1");
> -    CHECK((param->dolbyProfile != 0) && (param->dolbyProfile != 50),
> -        "Unsupported Dolby Vision profile, only profile 5 enabled");
> -    if (param->dolbyProfile == 50)
> +    CHECK((param->dolbyProfile != 0) && (param->dolbyProfile != 50) &&
> (param->dolbyProfile != 81),
> +        "Unsupported Dolby Vision profile, only profile 5 and profile 8.1
> enabled");
> +    if (param->dolbyProfile)
>      {
> -        CHECK((param->rc.vbvMaxBitrate < 0 && param->rc.vbvBufferSize <
> 0), "Dolby Vision requires VBV settings to enable HRD.\n");
> -        CHECK((param->sourceWidth > 3840 || param->sourceHeight > 2160),
> "Maximum supported resolution for Dolby Vision profile - 5 is 4k UHD\n");
> -        CHECK((param->internalBitDepth != 10), "Dolby Vision profile - 5
> is Main10 only\n");
> -        CHECK((param->internalCsp != X265_CSP_I420), "Dolby Vision
> profile - 5 requires YCbCr 4:2:0 color space\n");
> +        CHECK((param->rc.vbvMaxBitrate <= 0 || param->rc.vbvBufferSize <=
> 0), "Dolby Vision requires VBV settings to enable HRD.\n");
> +        CHECK((param->internalBitDepth != 10), "Dolby Vision profile - 5
> and profile - 8.1 is Main10 only\n");
> +        CHECK((param->internalCsp != X265_CSP_I420), "Dolby Vision
> profile - 5 and profile - 8.1 requires YCbCr 4:2:0 color space\n");
> +
> +        if (param->dolbyProfile == 81)
> +            CHECK(!(param->masteringDisplayColorVolume), "Dolby Vision
> profile - 8.1 requires Mastering display color volume information\n");
>      }
>  #if !X86_64
>      CHECK(param->searchMethod == X265_SEA && (param->sourceWidth > 840 ||
> param->sourceHeight > 480),
> diff -r 1951152ff12d -r d757a721369b source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp Fri Dec 07 12:52:46 2018 +0530
> +++ b/source/encoder/encoder.cpp Wed Dec 26 18:47:10 2018 +0530
> @@ -50,6 +50,30 @@
>  const char g_sliceTypeToChar[] = {'B', 'P', 'I'};
>  }
>
> +/* Dolby Vision profile specific settings */
> +typedef struct
> +{
> +    int bEmitHRDSEI;
> +    int bEnableVideoSignalTypePresentFlag;
> +    int bEnableColorDescriptionPresentFlag;
> +    int bEnableAccessUnitDelimiters;
> +    int bAnnexB;
> +
> +    /* VUI parameters specific to Dolby Vision Profile */
> +    int videoFormat;
> +    int bEnableVideoFullRangeFlag;
> +    int transferCharacteristics;
> +    int colorPrimaries;
> +    int matrixCoeffs;
> +
> +    int doviProfileId;
> +}DolbyVisionProfileSpec;
> +
> +DolbyVisionProfileSpec dovi[] =
> +{
> +    { 1, 1, 1, 1, 1, 5, 1,  2, 2, 2, 50 },
> +    { 1, 1, 1, 1, 1, 5, 0, 16, 9, 9, 81 },
> +};
>  /* Threshold for motion vection, based on expermental result.
>   * TODO: come up an algorithm for adoptive threshold */
>  #define MVTHRESHOLD (10*10)
> @@ -413,7 +437,7 @@
>
>      m_nalList.m_annexB = !!m_param->bAnnexB;
>
> -    m_emitCLLSEI = p->maxCLL || p->maxFALL;
> +    m_emitCLLSEI = p->maxCLL || p->maxFALL || (p->dolbyProfile == 81);
>
>      if (m_param->naluFile)
>      {
> @@ -2657,6 +2681,31 @@
>      memcpy(zone, p, sizeof(x265_param));
>  }
>
> +void Encoder::configureDolbyVisionParams(x265_param* p)
> +{
> +    uint32_t doviProfile = 0;
> +
> +    while (dovi[doviProfile].doviProfileId != p->dolbyProfile &&
> doviProfile + 1 < sizeof(dovi) / sizeof(dovi[0]))
> +        doviProfile++;
> +
> +    p->bEmitHRDSEI = dovi[doviProfile].bEmitHRDSEI;
> +    p->vui.bEnableVideoSignalTypePresentFlag =
> dovi[doviProfile].bEnableVideoSignalTypePresentFlag;
> +    p->vui.bEnableColorDescriptionPresentFlag =
> dovi[doviProfile].bEnableColorDescriptionPresentFlag;
> +    p->bEnableAccessUnitDelimiters =
> dovi[doviProfile].bEnableAccessUnitDelimiters;
> +    p->bAnnexB = dovi[doviProfile].bAnnexB;
> +    p->vui.videoFormat = dovi[doviProfile].videoFormat;
> +    p->vui.bEnableVideoFullRangeFlag =
> dovi[doviProfile].bEnableVideoFullRangeFlag;
> +    p->vui.transferCharacteristics =
> dovi[doviProfile].transferCharacteristics;
> +    p->vui.colorPrimaries = dovi[doviProfile].colorPrimaries;
> +    p->vui.matrixCoeffs = dovi[doviProfile].matrixCoeffs;
> +
> +    if (dovi[doviProfile].doviProfileId == 81)
> +        p->bEmitHDRSEI = 1;
> +
> +    if (dovi[doviProfile].doviProfileId == 50 && p->noiseReductionIntra
> && p->noiseReductionInter)
> +        p->crQpOffset = 4;
> +}
> +
>  void Encoder::configure(x265_param *p)
>  {
>      this->m_param = p;
> @@ -3286,25 +3335,9 @@
>          p->chunkStart = p->chunkEnd = 0;
>          x265_log(p, X265_LOG_WARNING, "chunk-end cannot be less than
> chunk-start. Disabling chunking.\n");
>      }
> +
>      if (p->dolbyProfile)     // Default disabled.
> -    {
> -        if (p->dolbyProfile == 50)
> -        {
> -            p->bEmitHRDSEI = true;
> -            p->vui.bEnableVideoSignalTypePresentFlag = 1;
> -            p->vui.bEnableColorDescriptionPresentFlag = 1;
> -            p->vui.transferCharacteristics = 2;
> -            p->vui.colorPrimaries = 2;
> -            p->vui.matrixCoeffs = 2;
> -            p->vui.bEnableVideoFullRangeFlag = 1;
> -            p->vui.videoFormat = 5;
> -            p->bEnableAccessUnitDelimiters = 1;
> -            p->bAnnexB = 1;
> -
> -            if (p->noiseReductionIntra && p->noiseReductionInter)    //
> when noise reduction is enabled, preserve the film grain.
> -                p->crQpOffset = 4;
> -        }
> -    }
> +        configureDolbyVisionParams(p);
>
>      if (m_param->rc.zonefileCount && p->bOpenGOP)
>      {
> diff -r 1951152ff12d -r d757a721369b source/encoder/encoder.h
> --- a/source/encoder/encoder.h Fri Dec 07 12:52:46 2018 +0530
> +++ b/source/encoder/encoder.h Wed Dec 26 18:47:10 2018 +0530
> @@ -313,6 +313,8 @@
>
>      void copyUserSEIMessages(Frame *frame, const x265_picture* pic_in);
>
> +    void configureDolbyVisionParams(x265_param* p);
> +
>  protected:
>
>      void initVPS(VPS *vps);
> diff -r 1951152ff12d -r d757a721369b source/x265cli.h
> --- a/source/x265cli.h Fri Dec 07 12:52:46 2018 +0530
> +++ b/source/x265cli.h Wed Dec 26 18:47:10 2018 +0530
> @@ -361,7 +361,7 @@
>      H0("   --dhdr10-info <filename>      JSON file containing the
> Creative Intent Metadata to be encoded as Dynamic Tone Mapping\n");
>      H0("   --[no-]dhdr10-opt             Insert tone mapping SEI only for
> IDR frames and when the tone mapping information changes. Default
> disabled\n");
>  #endif
> -    H0("  --dolby-vision-profile <float|integer> Specifies Dolby Vision
> profile ID. Currently only profile 5 enabled. Specified as '5' or '50'.
> Default 0 (disabled).\n");
> +    H0("   --dolby-vision-profile <float|integer> Specifies Dolby Vision
> profile ID. Currently only profile 5 and profile 8.1 enabled. Specified as
> '5' or '50'. Default 0 (disabled).\n");
>      H0("   --dolby-vision-rpu <filename> File containing Dolby Vision RPU
> metadata.\n"
>         "                                 If given, x265's Dolby Vision
> metadata parser will fill the RPU field of input pictures with the metadata
> read from the file. Default NULL(disabled).\n");
>      H0("   --nalu-file <filename>        Text file containing SEI
> messages in the following format : <POC><space><PREFIX><space><NAL UNIT
> TYPE>/<SEI TYPE><space><SEI Payload>\n");
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20181227/73ed5300/attachment-0001.html>


More information about the x265-devel mailing list