<div dir="ltr"><div dir="ltr"><div># HG changeset patch</div><div># User kirithika <<a href="mailto:kirithika@multicorewareinc.com">kirithika@multicorewareinc.com</a>></div><div># Date 1544426306 -19800</div><div>#      Mon Dec 10 12:48:26 2018 +0530</div><div># Node ID 827668cf88a85f8d14b8943c53e3f4c87196e96d</div><div># Parent  81373aab81dfe2e31a5ef353b1073d8bf1e22502</div><div>Add support for Dolby Vision profile 8.1</div><div><br></div><div>diff -r 81373aab81df -r 827668cf88a8 doc/reST/cli.rst</div><div>--- a/doc/reST/cli.rst<span style="white-space:pre">   </span>Thu Dec 13 10:55:15 2018 +0530</div><div>+++ b/doc/reST/cli.rst<span style="white-space:pre">  </span>Mon Dec 10 12:48:26 2018 +0530</div><div>@@ -2214,7 +2214,7 @@</div><div>     The value is specified as a float or as an integer with the profile times 10,</div><div>     for example profile 5 is specified as "5" or "5.0" or "50".</div><div>     </div><div>-    Currently only profile 5 enabled, Default 0 (disabled)</div><div>+    Currently only profile 5 and profile 8.1 enabled , Default 0 (disabled)</div><div> </div><div> .. option:: --dolby-vision-rpu <filename></div><div> </div><div>diff -r 81373aab81df -r 827668cf88a8 source/common/param.cpp</div><div>--- a/source/common/param.cpp<span style="white-space:pre">      </span>Thu Dec 13 10:55:15 2018 +0530</div><div>+++ b/source/common/param.cpp<span style="white-space:pre">   </span>Mon Dec 10 12:48:26 2018 +0530</div><div>@@ -1418,14 +1418,17 @@</div><div>         "Invalid refine-intra value, refine-intra levels 0 to 3 supported");</div><div>     CHECK(param->maxAUSizeFactor < 0.5 || param->maxAUSizeFactor > 1.0,</div><div>         "Supported factor for controlling max AU size is from 0.5 to 1");</div><div>-    CHECK((param->dolbyProfile != 0) && (param->dolbyProfile != 50),</div><div>-        "Unsupported Dolby Vision profile, only profile 5 enabled");</div><div>-    if (param->dolbyProfile == 50)</div><div>+    CHECK((param->dolbyProfile != 0) && (param->dolbyProfile != 50) && (param->dolbyProfile != 81),</div><div>+        "Unsupported Dolby Vision profile, only profile 5 and profile 8.1 enabled");</div><div>+    if (param->dolbyProfile)</div><div>     {</div><div>-        CHECK((param->rc.vbvMaxBitrate < 0 && param->rc.vbvBufferSize < 0), "Dolby Vision requires VBV settings to enable HRD.\n");</div><div>-        CHECK((param->sourceWidth > 3840 || param->sourceHeight > 2160), "Maximum supported resolution for Dolby Vision profile - 5 is 4k UHD\n");</div><div>-        CHECK((param->internalBitDepth != 10), "Dolby Vision profile - 5 is Main10 only\n");</div><div>-        CHECK((param->internalCsp != X265_CSP_I420), "Dolby Vision profile - 5 requires YCbCr 4:2:0 color space\n");</div><div>+        CHECK((param->rc.vbvMaxBitrate <= 0 && param->rc.vbvBufferSize <= 0), "Dolby Vision requires VBV settings to enable HRD.\n");</div><div>+        CHECK((param->sourceWidth > 3840 || param->sourceHeight > 2160), "Maximum supported resolution for Dolby Vision profile - 5 and profile  - 8.1 is 4k UHD\n");</div><div>+        CHECK((param->internalBitDepth != 10), "Dolby Vision profile - 5 and profile - 8.1 is Main10 only\n");</div><div>+        CHECK((param->internalCsp != X265_CSP_I420), "Dolby Vision profile - 5 and profile  - 8.1  requires YCbCr 4:2:0 color space\n");</div><div>+</div><div>+        if (param->dolbyProfile == 81)</div><div>+            CHECK(!(param->masteringDisplayColorVolume), "Dolby Vision profile - 8.1 requires Mastering display color volume information\n");</div><div>     }</div><div> #if !X86_64</div><div>     CHECK(param->searchMethod == X265_SEA && (param->sourceWidth > 840 || param->sourceHeight > 480),</div><div>diff -r 81373aab81df -r 827668cf88a8 source/encoder/encoder.cpp</div><div>--- a/source/encoder/encoder.cpp<span style="white-space:pre"> </span>Thu Dec 13 10:55:15 2018 +0530</div><div>+++ b/source/encoder/encoder.cpp<span style="white-space:pre">        </span>Mon Dec 10 12:48:26 2018 +0530</div><div>@@ -49,7 +49,31 @@</div><div> namespace X265_NS {</div><div> const char g_sliceTypeToChar[] = {'B', 'P', 'I'};</div><div> }</div><div>-</div><div>+</div><div>+/* Dolby Vision profile specific settings */</div><div>+typedef struct</div><div>+{</div><div>+    int bEmitHRDSEI;</div><div>+    int bEnableVideoSignalTypePresentFlag;</div><div>+    int bEnableColorDescriptionPresentFlag;</div><div>+    int bEnableAccessUnitDelimiters;</div><div>+    int bAnnexB;</div><div>+</div><div>+    /* VUI parameters specific to Dolby Vision Profile */</div><div>+    int videoFormat;</div><div>+    int bEnableVideoFullRangeFlag;</div><div>+    int transferCharacteristics;</div><div>+    int colorPrimaries;</div><div>+    int matrixCoeffs;</div><div>+</div><div>+    int doviProfileId;</div><div>+}DolbyVisionProfileSpec;</div><div>+</div><div>+DolbyVisionProfileSpec dovi[] =</div><div>+{</div><div>+    { 1, 1, 1, 1, 1, 5, 1,  2, 2, 2, 50 },</div><div>+    { 1, 1, 1, 1, 1, 5, 0, 16, 9, 9, 81 },</div><div>+};</div><div> /* Threshold for motion vection, based on expermental result.</div><div>  * TODO: come up an algorithm for adoptive threshold */</div><div> #define MVTHRESHOLD (10*10)</div><div>@@ -413,7 +437,7 @@</div><div> </div><div>     m_nalList.m_annexB = !!m_param->bAnnexB;</div><div> </div><div>-    m_emitCLLSEI = p->maxCLL || p->maxFALL;</div><div>+    m_emitCLLSEI = p->maxCLL || p->maxFALL || (p->dolbyProfile == 81);</div><div> </div><div>     if (m_param->naluFile)</div><div>     {</div><div>@@ -2584,6 +2608,31 @@</div><div>     pps->numRefIdxDefault[1] = 1;</div><div> }</div><div> </div><div>+void Encoder::configureDolbyVisionParams(x265_param* p)</div><div>+{</div><div>+    uint32_t doviProfile = 0;</div><div>+</div><div>+    while (dovi[doviProfile].doviProfileId != p->dolbyProfile && doviProfile + 1 < sizeof(dovi) / sizeof(dovi[0]))</div><div>+        doviProfile++;</div><div>+</div><div>+    p->bEmitHRDSEI = dovi[doviProfile].bEmitHRDSEI;</div><div>+    p->vui.bEnableVideoSignalTypePresentFlag = dovi[doviProfile].bEnableVideoSignalTypePresentFlag;</div><div>+    p->vui.bEnableColorDescriptionPresentFlag = dovi[doviProfile].bEnableColorDescriptionPresentFlag;</div><div>+    p->bEnableAccessUnitDelimiters = dovi[doviProfile].bEnableAccessUnitDelimiters;</div><div>+    p->bAnnexB = dovi[doviProfile].bAnnexB;</div><div>+    p->vui.videoFormat = dovi[doviProfile].videoFormat;</div><div>+    p->vui.bEnableVideoFullRangeFlag = dovi[doviProfile].bEnableVideoFullRangeFlag;</div><div>+    p->vui.transferCharacteristics = dovi[doviProfile].transferCharacteristics;</div><div>+    p->vui.colorPrimaries = dovi[doviProfile].colorPrimaries;</div><div>+    p->vui.matrixCoeffs = dovi[doviProfile].matrixCoeffs;</div><div>+</div><div>+    if (dovi[doviProfile].doviProfileId == 81)</div><div>+        p->bEmitHDRSEI = 1;</div><div>+</div><div>+    if (dovi[doviProfile].doviProfileId == 50 && p->noiseReductionIntra && p->noiseReductionInter)</div><div>+        p->crQpOffset = 4;</div><div>+}</div><div>+</div><div> void Encoder::configure(x265_param *p)</div><div> {</div><div>     this->m_param = p;</div><div>@@ -3193,25 +3242,9 @@</div><div>         p->chunkStart = p->chunkEnd = 0;</div><div>         x265_log(p, X265_LOG_WARNING, "chunk-end cannot be less than chunk-start. Disabling chunking.\n");</div><div>     }</div><div>+</div><div>     if (p->dolbyProfile)     // Default disabled.</div><div>-    {</div><div>-        if (p->dolbyProfile == 50)</div><div>-        {</div><div>-            p->bEmitHRDSEI = true;</div><div>-            p->vui.bEnableVideoSignalTypePresentFlag = 1;</div><div>-            p->vui.bEnableColorDescriptionPresentFlag = 1;</div><div>-            p->vui.transferCharacteristics = 2;</div><div>-            p->vui.colorPrimaries = 2;</div><div>-            p->vui.matrixCoeffs = 2;</div><div>-            p->vui.bEnableVideoFullRangeFlag = 1;</div><div>-            p->vui.videoFormat = 5;</div><div>-            p->bEnableAccessUnitDelimiters = 1;</div><div>-            p->bAnnexB = 1;</div><div>-</div><div>-            if (p->noiseReductionIntra && p->noiseReductionInter)    // when noise reduction is enabled, preserve the film grain.</div><div>-                p->crQpOffset = 4;</div><div>-        }</div><div>-    }</div><div>+        configureDolbyVisionParams(p);</div><div> }</div><div> </div><div> void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x265_picture* picIn, int paramBytes)</div><div>diff -r 81373aab81df -r 827668cf88a8 source/encoder/encoder.h</div><div>--- a/source/encoder/encoder.h<span style="white-space:pre">      </span>Thu Dec 13 10:55:15 2018 +0530</div><div>+++ b/source/encoder/encoder.h<span style="white-space:pre">  </span>Mon Dec 10 12:48:26 2018 +0530</div><div>@@ -304,6 +304,8 @@</div><div> </div><div>     void copyUserSEIMessages(Frame *frame, const x265_picture* pic_in);</div><div> </div><div>+    void configureDolbyVisionParams(x265_param* p);</div><div>+</div><div> protected:</div><div> </div><div>     void initVPS(VPS *vps);</div><div>diff -r 81373aab81df -r 827668cf88a8 source/x265cli.h</div><div>--- a/source/x265cli.h<span style="white-space:pre"> </span>Thu Dec 13 10:55:15 2018 +0530</div><div>+++ b/source/x265cli.h<span style="white-space:pre">  </span>Mon Dec 10 12:48:26 2018 +0530</div><div>@@ -359,7 +359,7 @@</div><div>     H0("   --dhdr10-info <filename>      JSON file containing the Creative Intent Metadata to be encoded as Dynamic Tone Mapping\n");</div><div>     H0("   --[no-]dhdr10-opt             Insert tone mapping SEI only for IDR frames and when the tone mapping information changes. Default disabled\n");</div><div> #endif</div><div>-    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");</div><div>+    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");</div><div>     H0("   --dolby-vision-rpu <filename> File containing Dolby Vision RPU metadata.\n"</div><div>        "                                 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");</div><div>     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");</div><div><br></div></div></div>