changeset 12435:89457c901a6c draft

added support for Dolby Vision profile 5
author Praveen Tiwari <praveen@multicorewareinc.com>
date Tue, 25 Sep 2018 11:14:55 +0530
parents f74003e88622
children b748ee9f4465
files doc/reST/cli.rst source/CMakeLists.txt source/common/param.cpp source/encoder/encoder.cpp source/x265.h source/x265cli.h
diffstat 6 files changed, 60 insertions(+-), 4 deletions(-) [+]
line wrap: on
line diff
--- a/doc/reST/cli.rst	Thu Nov 22 15:02:08 2018 +0530
+++ b/doc/reST/cli.rst	Tue Sep 25 11:14:55 2018 +0530
@@ -2195,6 +2195,19 @@ Bitstream options
 	Picture Timing SEI messages providing timing information to the
 	decoder. Default disabled
 
+.. option:: --dolby-vision-profile <integer|float>
+
+    Generate bitstreams confirming to the specified Dolby Vision profile,
+    note that 0x7C01 makes RPU appear to be an unspecified NAL type in
+    HEVC stream. If BL is backward compatible, Dolby Vision single
+    layer VES will be equivalent to a backward compatible BL VES on legacy
+    device as RPU will be ignored.
+    
+    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)
+
 .. option:: --info, --no-info
 
 	Emit an informational SEI with the stream headers which describes
--- a/source/CMakeLists.txt	Thu Nov 22 15:02:08 2018 +0530
+++ b/source/CMakeLists.txt	Tue Sep 25 11:14:55 2018 +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 165)
+set(X265_BUILD 166)
 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 Nov 22 15:02:08 2018 +0530
+++ b/source/common/param.cpp	Tue Sep 25 11:14:55 2018 +0530
@@ -286,9 +286,9 @@ void x265_param_default(x265_param* para
     param->bAQMotion = 0;
     param->bHDROpt = 0;
     param->analysisReuseLevel = 5;
-
     param->toneMapFile = NULL;
     param->bDhdr10opt = 0;
+    param->dolbyProfile = 0;
     param->bCTUInfo = 0;
     param->bUseRcStats = 0;
     param->scaleFactor = 0;
@@ -1050,6 +1050,15 @@ int x265_param_parse(x265_param* p, cons
         OPT("chunk-start") p->chunkStart = atoi(value);
         OPT("chunk-end") p->chunkEnd = atoi(value);
         OPT("nalu-file") p->naluFile = strdup(value);
+        OPT("dolby-vision-profile")
+        {
+            if (atof(value) < 10)
+                p->dolbyProfile = (int)(10 * atof(value) + .5);
+            else if (atoi(value) < 100)
+                p->dolbyProfile = atoi(value);
+            else
+                bError = true;
+        }
         else
             return X265_PARAM_BAD_NAME;
     }
@@ -1407,6 +1416,15 @@ int x265_check_params(x265_param* param)
         "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->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");
+    }
 #if !X86_64
     CHECK(param->searchMethod == X265_SEA && (param->sourceWidth > 840 || param->sourceHeight > 480),
         "SEA motion search does not support resolutions greater than 480p in 32 bit build");
--- a/source/encoder/encoder.cpp	Thu Nov 22 15:02:08 2018 +0530
+++ b/source/encoder/encoder.cpp	Tue Sep 25 11:14:55 2018 +0530
@@ -3,6 +3,8 @@
  *
  * Authors: Steve Borho <steve@borho.org>
  *          Min Chen <chenm003@163.com>
+ *          Praveen Kumar Tiwari <praveen@multicorewareinc.com>
+ *          Aruna Matheswaran <aruna@multicorewareinc.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -3182,7 +3184,22 @@ void Encoder::configure(x265_param *p)
         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;
+        }
+    }
 }
 
 void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x265_picture* picIn, int paramBytes)
--- a/source/x265.h	Thu Nov 22 15:02:08 2018 +0530
+++ b/source/x265.h	Tue Sep 25 11:14:55 2018 +0530
@@ -1713,8 +1713,14 @@ typedef struct x265_param
     /* File containing base64 encoded SEI messages in POC order */
     const char*    naluFile;
 
+    /* Generate bitstreams confirming to the specified dolby vision profile,
+     * note that 0x7C01 makes RPU appear to be an unspecified NAL type in
+     * HEVC stream. if BL is backward compatible, Dolby Vision single
+     * layer VES will be equivalent to a backward compatible BL VES on legacy
+     * device as RPU will be ignored. Default 0 (disabled) */
+    int dolbyProfile;
+
 } x265_param;
-
 /* x265_param_alloc:
  *  Allocates an x265_param instance. The returned param structure is not
  *  special in any way, but using this method together with x265_param_free()
--- a/source/x265cli.h	Thu Nov 22 15:02:08 2018 +0530
+++ b/source/x265cli.h	Tue Sep 25 11:14:55 2018 +0530
@@ -288,6 +288,7 @@ static const struct option long_options[
     { "dhdr10-info",    required_argument, NULL, 0 },
     { "dhdr10-opt",           no_argument, NULL, 0},
     { "no-dhdr10-opt",        no_argument, NULL, 0},
+    { "dolby-vision-profile",  required_argument, NULL, 0 },
     { "refine-mv",            no_argument, NULL, 0 },
     { "no-refine-mv",         no_argument, NULL, 0 },
     { "force-flush",    required_argument, NULL, 0 },
@@ -355,6 +356,7 @@ static void showHelp(x265_param *param)
     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("   --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");
     H0("-f/--frames <integer>            Maximum number of frames to encode. Default all\n");
     H0("   --seek <integer>              First frame to encode\n");