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

Kirithika Kalirathnam kirithika at multicorewareinc.com
Tue Dec 18 09:08:07 CET 2018


# HG changeset patch
# User kirithika <kirithika at multicorewareinc.com>
# Date 1544426306 -19800
#      Mon Dec 10 12:48:26 2018 +0530
# Node ID 827668cf88a85f8d14b8943c53e3f4c87196e96d
# Parent  81373aab81dfe2e31a5ef353b1073d8bf1e22502
Add support for Dolby Vision profile 8.1

diff -r 81373aab81df -r 827668cf88a8 doc/reST/cli.rst
--- a/doc/reST/cli.rst Thu Dec 13 10:55:15 2018 +0530
+++ b/doc/reST/cli.rst Mon Dec 10 12:48:26 2018 +0530
@@ -2214,7 +2214,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 81373aab81df -r 827668cf88a8 source/common/param.cpp
--- a/source/common/param.cpp Thu Dec 13 10:55:15 2018 +0530
+++ b/source/common/param.cpp Mon Dec 10 12:48:26 2018 +0530
@@ -1418,14 +1418,17 @@
         "Invalid refine-intra value, refine-intra levels 0 to 3
supported");
     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->sourceWidth > 3840 || param->sourceHeight > 2160),
"Maximum supported resolution for Dolby Vision profile - 5 and profile  -
8.1 is 4k UHD\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 81373aab81df -r 827668cf88a8 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Thu Dec 13 10:55:15 2018 +0530
+++ b/source/encoder/encoder.cpp Mon Dec 10 12:48:26 2018 +0530
@@ -49,7 +49,31 @@
 namespace X265_NS {
 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)
     {
@@ -2584,6 +2608,31 @@
     pps->numRefIdxDefault[1] = 1;
 }

+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;
@@ -3193,25 +3242,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);
 }

 void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc,
const x265_picture* picIn, int paramBytes)
diff -r 81373aab81df -r 827668cf88a8 source/encoder/encoder.h
--- a/source/encoder/encoder.h Thu Dec 13 10:55:15 2018 +0530
+++ b/source/encoder/encoder.h Mon Dec 10 12:48:26 2018 +0530
@@ -304,6 +304,8 @@

     void copyUserSEIMessages(Frame *frame, const x265_picture* pic_in);

+    void configureDolbyVisionParams(x265_param* p);
+
 protected:

     void initVPS(VPS *vps);
diff -r 81373aab81df -r 827668cf88a8 source/x265cli.h
--- a/source/x265cli.h Thu Dec 13 10:55:15 2018 +0530
+++ b/source/x265cli.h Mon Dec 10 12:48:26 2018 +0530
@@ -359,7 +359,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");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20181218/e02ff0eb/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-1.patch
Type: application/octet-stream
Size: 8394 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20181218/e02ff0eb/attachment-0001.obj>


More information about the x265-devel mailing list