[x265] [PATCH] Added support for the new HDR10+ LLC JSON format injection inside dynamicHDR10 library

ashok at multicorewareinc.com ashok at multicorewareinc.com
Thu Jul 12 14:24:15 CEST 2018


# HG changeset patch
# User Ashok Kumar Mishra <ashok at multicorewareinc.com>
# Date 1531377840 -19800
#      Thu Jul 12 12:14:00 2018 +0530
# Node ID 7763d20f092a208904b3ae3ec1762441d1573696
# Parent  8bf51aa8a1708fa106c225db2d6671ede0ad29b0
Added support for the new HDR10+ LLC JSON format injection inside dynamicHDR10 library.

diff -r 8bf51aa8a170 -r 7763d20f092a source/dynamicHDR10/SeiMetadataDictionary.cpp
--- a/source/dynamicHDR10/SeiMetadataDictionary.cpp	Thu Jul 12 17:23:26 2018 +0800
+++ b/source/dynamicHDR10/SeiMetadataDictionary.cpp	Thu Jul 12 12:14:00 2018 +0530
@@ -34,6 +34,7 @@
 const std::string BezierCurveNames::NumberOfAnchors = std::string("NumberOfAnchors");
 const std::string BezierCurveNames::KneePointX = std::string("KneePointX");
 const std::string BezierCurveNames::KneePointY = std::string("KneePointY");
+const std::string BezierCurveNames::AnchorsTag = std::string("Anchors");
 const std::string BezierCurveNames::Anchors[] = {std::string("Anchor0"),
                                                  std::string("Anchor1"),
                                                  std::string("Anchor2"),
@@ -69,6 +70,8 @@
 
 const std::string PercentileNames::TagName = std::string("PercentileLuminance");
 const std::string PercentileNames::NumberOfPercentiles = std::string("NumberOfPercentiles");
+const std::string PercentileNames::DistributionIndex = std::string("DistributionIndex");
+const std::string PercentileNames::DistributionValues = std::string("DistributionValues");
 const std::string PercentileNames::PercentilePercentageValue[] = {std::string("PercentilePercentage0"),
                                                                   std::string("PercentilePercentage1"),
                                                                   std::string("PercentilePercentage2"),
@@ -104,7 +107,9 @@
 
 
 const std::string LuminanceNames::TagName = std::string("LuminanceParameters");
+const std::string LuminanceNames::LlcTagName = std::string("LuminanceDistributions");
 const std::string LuminanceNames::AverageRGB = std::string("AverageRGB");
+const std::string LuminanceNames::MaxSCL = std::string("MaxScl");
 const std::string LuminanceNames::MaxSCL0 = std::string("MaxScl0");
 const std::string LuminanceNames::MaxSCL1 = std::string("MaxScl1");
 const std::string LuminanceNames::MaxSCL2 = std::string("MaxScl2");
diff -r 8bf51aa8a170 -r 7763d20f092a source/dynamicHDR10/SeiMetadataDictionary.h
--- a/source/dynamicHDR10/SeiMetadataDictionary.h	Thu Jul 12 17:23:26 2018 +0800
+++ b/source/dynamicHDR10/SeiMetadataDictionary.h	Thu Jul 12 12:14:00 2018 +0530
@@ -48,6 +48,7 @@
         static const std::string NumberOfAnchors;
         static const std::string KneePointX;
         static const std::string KneePointY;
+        static const std::string AnchorsTag;
         static const std::string Anchors[14];
     };
     //Ellipse Selection Data
@@ -79,6 +80,8 @@
         public:
         static const std::string TagName;
         static const std::string NumberOfPercentiles;
+        static const std::string DistributionIndex;
+        static const std::string DistributionValues;
         static const std::string PercentilePercentageValue[15];
         static const std::string PercentileLuminanceValue[15];
     };
@@ -87,7 +90,9 @@
     {
         public:
         static const std::string TagName;
+        static const std::string LlcTagName;
         static const std::string AverageRGB;
+        static const std::string MaxSCL;
         static const std::string MaxSCL0;
         static const std::string MaxSCL1;
         static const std::string MaxSCL2;
diff -r 8bf51aa8a170 -r 7763d20f092a source/dynamicHDR10/metadataFromJson.cpp
--- a/source/dynamicHDR10/metadataFromJson.cpp	Thu Jul 12 17:23:26 2018 +0800
+++ b/source/dynamicHDR10/metadataFromJson.cpp	Thu Jul 12 12:14:00 2018 +0530
@@ -51,14 +51,13 @@
         JsonObject lumJsonData = data.object_items();
         if(!lumJsonData.empty())
         {
-            JsonObject percentileData = lumJsonData[PercentileNames::TagName].object_items();
-            obj.order = percentileData[PercentileNames::NumberOfPercentiles].int_value();
-
             obj.averageLuminance = static_cast<float>(lumJsonData[LuminanceNames::AverageRGB].number_value());
             obj.maxRLuminance = static_cast<float>(lumJsonData[LuminanceNames::MaxSCL0].number_value());
             obj.maxGLuminance = static_cast<float>(lumJsonData[LuminanceNames::MaxSCL1].number_value());
             obj.maxBLuminance = static_cast<float>(lumJsonData[LuminanceNames::MaxSCL2].number_value());
 
+            JsonObject percentileData = lumJsonData[PercentileNames::TagName].object_items();
+            obj.order = percentileData[PercentileNames::NumberOfPercentiles].int_value();
             if(!percentileData.empty())
             {
                 obj.percentiles.resize(obj.order);
@@ -69,7 +68,33 @@
                     obj.percentiles[i] = static_cast<unsigned int>(percentileData[percentileTag].int_value());
                 }
             }
+            return true;
+        }
+        return false;
+    }
 
+    bool luminanceParamFromLLCJson(const Json &data, LuminanceParameters &obj)
+    {
+        JsonObject lumJsonData = data.object_items();
+        if(!lumJsonData.empty())
+        {
+            obj.averageLuminance = static_cast<float>(lumJsonData[LuminanceNames::AverageRGB].number_value());
+            JsonArray maxScl = lumJsonData[LuminanceNames::MaxSCL].array_items();
+            obj.maxRLuminance = static_cast<float>(maxScl[0].number_value());
+            obj.maxGLuminance = static_cast<float>(maxScl[1].number_value());
+            obj.maxBLuminance = static_cast<float>(maxScl[2].number_value());
+
+            JsonObject percentileData = lumJsonData[LuminanceNames::LlcTagName].object_items();
+            if(!percentileData.empty())
+            {
+                JsonArray distributionValues = percentileData[PercentileNames::DistributionValues].array_items();
+                obj.order = distributionValues.size();
+                obj.percentiles.resize(obj.order);
+                for(int i = 0; i < obj.order; ++i)
+                {
+                    obj.percentiles[i] = static_cast<unsigned int>(distributionValues[i].int_value());
+                }
+            }
             return true;
         }
         return false;
@@ -82,33 +107,33 @@
         {
             JsonObject percentileData = jsonData[PercentileNames::TagName].object_items();
             int order = percentileData[PercentileNames::NumberOfPercentiles].int_value();
-
             percentages.resize(order);
             for(int i = 0; i < order; ++i)
             {
                 std::string percentileTag = PercentileNames::PercentilePercentageValue[i];
                 percentages[i] = static_cast<unsigned int>(percentileData[percentileTag].int_value());
             }
-
             return true;
         }
         return false;
     }
 
-    bool percentagesFromJson(const Json &data, unsigned int *percentages)
+    bool percentagesFromLLCJson(const Json &data, std::vector<unsigned int> &percentages)
     {
-        JsonObject jsonData = data.object_items();
-        if(!jsonData.empty())
-        {
-            JsonObject percentileData = jsonData[PercentileNames::TagName].object_items();
-            int order = percentileData[PercentileNames::NumberOfPercentiles].int_value();
-
-            for(int i = 0; i < order; ++i)
+        JsonObject lumJsonData = data.object_items();
+        if(!lumJsonData.empty())
+        {            
+            JsonObject percentileData = lumJsonData[LuminanceNames::LlcTagName].object_items();
+            if(!percentileData.empty())
             {
-                std::string percentileTag = PercentileNames::PercentilePercentageValue[i];
-                percentages[i] = static_cast<unsigned int>(percentileData[percentileTag].int_value());
+                JsonArray percentageValues = percentileData[PercentileNames::DistributionIndex].array_items();
+                int order = percentageValues.size();
+                percentages.resize(order);
+                for(int i = 0; i < order; ++i)
+                {
+                    percentages[i] = static_cast<unsigned int>(percentageValues[i].int_value());
+                }
             }
-
             return true;
         }
         return false;
@@ -119,15 +144,33 @@
         JsonObject jsonData = data.object_items();
         if(!jsonData.empty())
         {
+            obj.sPx = jsonData[BezierCurveNames::KneePointX].int_value();
+            obj.sPy = jsonData[BezierCurveNames::KneePointY].int_value();
             obj.order = jsonData[BezierCurveNames::NumberOfAnchors].int_value();
             obj.coeff.resize(obj.order);
-            obj.sPx = jsonData[BezierCurveNames::KneePointX].int_value();
-            obj.sPy = jsonData[BezierCurveNames::KneePointY].int_value();
             for(int i = 0; i < obj.order; ++i)
             {
                 obj.coeff[i] = jsonData[BezierCurveNames::Anchors[i]].int_value();
             }
+            return true;
+        }
+        return false;
+    }
 
+    bool bezierCurveFromLLCJson(const Json &data, BezierCurveData &obj)
+    {
+        JsonObject jsonData = data.object_items();
+        if(!jsonData.empty())
+        {
+            obj.sPx = jsonData[BezierCurveNames::KneePointX].int_value();
+            obj.sPy = jsonData[BezierCurveNames::KneePointY].int_value();
+            JsonArray anchorValues = data[BezierCurveNames::AnchorsTag].array_items();
+            obj.order = anchorValues.size();
+            obj.coeff.resize(obj.order);
+            for(int i = 0; i < obj.order; ++i)
+            {
+                obj.coeff[i] = anchorValues[i].int_value();
+            }
             return true;
         }
         return false;
@@ -162,9 +205,7 @@
     void setPayloadSize(uint8_t *dataStream, int positionOnStream, int payload)
     {
         int payloadBytes = 1;
-
         for(;payload >= 0xFF; payload -= 0xFF, ++payloadBytes);
-
         if(payloadBytes > 1)
         {
             shiftData(dataStream, payloadBytes-1, mCurrentStreamByte, positionOnStream);
@@ -196,8 +237,6 @@
         }
     }
 
-//    const std::string LocalParameters = std::string("LocalParameters");
-//    const std::string TargetDisplayLuminance = std::string("TargetedSystemDisplayMaximumLuminance");
 };
 
 metadataFromJson::metadataFromJson() :
@@ -211,17 +250,17 @@
     delete mPimpl;
 }
 
-
 bool metadataFromJson::frameMetadataFromJson(const char* filePath,
                                               int frame,
                                               uint8_t *&metadata)
 {
     std::string path(filePath);
     JsonArray fileData = JsonHelper::readJsonArray(path);
-
+    bool isLLCJson = false;
     if(fileData.empty())
     {
-        return false;
+        isLLCJson = true;
+        fileData = JsonHelper::readJson(filePath).at("SceneInfo").array_items();
     }
 
 //    frame = frame + 1; //index on the array start at 0 frames starts at 1
@@ -233,7 +272,6 @@
     }
 
     int mSEIBytesToRead = 509;
-
     if(metadata)
     {
         delete(metadata);
@@ -241,13 +279,9 @@
     metadata = new uint8_t[mSEIBytesToRead];
     mPimpl->mCurrentStreamBit = 8;
     mPimpl->mCurrentStreamByte = 1;
+    memset(metadata, 0, mSEIBytesToRead);
 
-    for(int j = 0; j < mSEIBytesToRead; ++j)
-    {
-        (metadata)[j] = 0;
-    }
-
-    fillMetadataArray(fileData, frame, metadata);
+    fillMetadataArray(fileData, frame, isLLCJson, metadata);
     mPimpl->setPayloadSize(metadata, 0, mPimpl->mCurrentStreamByte);
     return true;
 }
@@ -256,9 +290,12 @@
 {
     std::string path(filePath);
     JsonArray fileData = JsonHelper::readJsonArray(path);
+    bool isLLCJson = false;
+
     if (fileData.empty())
     {
-        return -1;
+        isLLCJson = true;
+        fileData = JsonHelper::readJson(filePath).at("SceneInfo").array_items();
     }
 
     int numFrames = static_cast<int>(fileData.size());
@@ -266,17 +303,12 @@
     for (int frame = 0; frame < numFrames; ++frame)
     {
         metadata[frame] = new uint8_t[509];
-        for (int i = 0; i < 509; ++i)
-        {
-            metadata[frame][i] = 0;
-        }
+        memset(metadata[frame], 0, 509);
         mPimpl->mCurrentStreamBit = 8;
         mPimpl->mCurrentStreamByte = 1;
 
-        fillMetadataArray(fileData, frame, metadata[frame]);
-
+        fillMetadataArray(fileData, frame, isLLCJson, metadata[frame]);
         mPimpl->setPayloadSize(metadata[frame], 0, mPimpl->mCurrentStreamByte);
-
     }
 
     return numFrames;
@@ -321,7 +353,7 @@
     /* NOTE: We leave TWO BYTES of space for the payload */
     mPimpl->mCurrentStreamByte += 2;
 
-    fillMetadataArray(fileData, frame, metadata);
+    fillMetadataArray(fileData, frame, false, metadata);
 
     /* Set payload in bytes 2 & 3 as indicated in Extended InfoFrame Type syntax */
     metadata[2] = (mPimpl->mCurrentStreamByte & 0xFF00) >> 8;
@@ -331,7 +363,7 @@
 
 int metadataFromJson::movieExtendedInfoFrameMetadataFromJson(const char* filePath, uint8_t **&metadata)
 {
-	std::string path(filePath);
+    std::string path(filePath);
     JsonArray fileData = JsonHelper::readJsonArray(path);
     if(fileData.empty())
     {
@@ -344,9 +376,9 @@
     {
         metadata[frame] = new uint8_t[509];
         for(int i = 0; i < 509; ++i) 
-		{
-			metadata[frame][i] = 0;
-		}
+        {
+            metadata[frame][i] = 0;
+        }
         mPimpl->mCurrentStreamBit = 8;
         mPimpl->mCurrentStreamByte = 0;
 
@@ -356,7 +388,7 @@
         /* NOTE: We leave TWO BYTES of space for the payload */
         mPimpl->mCurrentStreamByte += 2;
 
-        fillMetadataArray(fileData, frame, metadata[frame]);
+        fillMetadataArray(fileData, frame, false, metadata[frame]);
 
         /* Set payload in bytes 2 & 3 as indicated in Extended InfoFrame Type syntax */
         metadata[frame][2] = (mPimpl->mCurrentStreamByte & 0xFF00) >> 8;
@@ -366,7 +398,7 @@
     return numFrames;
 }
 
-void metadataFromJson::fillMetadataArray(const JsonArray &fileData, int frame, uint8_t *&metadata)
+void metadataFromJson::fillMetadataArray(const JsonArray &fileData, int frame, const bool isLLCJson, uint8_t *&metadata)
 {
     const uint8_t countryCode = 0xB5;
     const uint16_t terminalProviderCode = 0x003C;
@@ -381,57 +413,68 @@
     mPimpl->appendBits(metadata, applicationIdentifier, 8);
     mPimpl->appendBits(metadata, applicationVersion, 8);
 
-    //Note: Validated only add up to two local selections, ignore the rest
-    JsonArray jsonArray = fileData[frame][JsonDataKeys::LocalParameters].array_items();
-    int ellipsesNum = static_cast<int>(jsonArray.size() > 2 ? 2 : jsonArray.size());
-    uint16_t numWindows = (uint16_t)fileData[frame][JsonDataKeys::NumberOfWindows].int_value();
-    mPimpl->appendBits(metadata, numWindows, 2);
-    for (int i = 0; i < ellipsesNum; ++i)
+    uint16_t numWindows = 0;
+    /* HDR10+ LLC doesn't consider local windows */
+    if(isLLCJson)
     {
-        mPimpl->appendBits(metadata, jsonArray[i][EllipseSelectionNames::WindowData]
-            [EllipseSelectionNames::WindowUpperLeftCornerX].int_value(), 16);
-        mPimpl->appendBits(metadata, jsonArray[i][EllipseSelectionNames::WindowData]
-            [EllipseSelectionNames::WindowUpperLeftCornerY].int_value(), 16);
-        mPimpl->appendBits(metadata, jsonArray[i][EllipseSelectionNames::WindowData]
-            [EllipseSelectionNames::WindowLowerRightCornerX].int_value(), 16);
-        mPimpl->appendBits(metadata, jsonArray[i][EllipseSelectionNames::WindowData]
-            [EllipseSelectionNames::WindowLowerRightCornerY].int_value(), 16);
-
-        JsonObject ellipseJsonObject = jsonArray[i][EllipseNames::TagName].object_items();
-
-        mPimpl->appendBits(metadata,
-            static_cast<uint16_t>(ellipseJsonObject[EllipseNames::CenterOfEllipseX].int_value()),
-            16);
+        numWindows = 1;
+        mPimpl->appendBits(metadata, numWindows, 2);
+    }
+    else
+    {
+        //Note: Validated only add up to two local selections, ignore the rest
+        JsonArray jsonArray = fileData[frame][JsonDataKeys::LocalParameters].array_items();
+        int ellipsesNum = static_cast<int>(jsonArray.size() > 2 ? 2 : jsonArray.size());
+        numWindows = (uint16_t)fileData[frame][JsonDataKeys::NumberOfWindows].int_value();
+        mPimpl->appendBits(metadata, numWindows, 2);
+        for (int i = 0; i < ellipsesNum; ++i)
+        {
+            mPimpl->appendBits(metadata, jsonArray[i][EllipseSelectionNames::WindowData]
+                    [EllipseSelectionNames::WindowUpperLeftCornerX].int_value(), 16);
+            mPimpl->appendBits(metadata, jsonArray[i][EllipseSelectionNames::WindowData]
+                    [EllipseSelectionNames::WindowUpperLeftCornerY].int_value(), 16);
+            mPimpl->appendBits(metadata, jsonArray[i][EllipseSelectionNames::WindowData]
+                    [EllipseSelectionNames::WindowLowerRightCornerX].int_value(), 16);
+            mPimpl->appendBits(metadata, jsonArray[i][EllipseSelectionNames::WindowData]
+                    [EllipseSelectionNames::WindowLowerRightCornerY].int_value(), 16);
 
-        mPimpl->appendBits(metadata,
-            static_cast<uint16_t>(ellipseJsonObject[EllipseNames::CenterOfEllipseY].int_value()),
-            16);
-
-        int angle = ellipseJsonObject[EllipseNames::RotationAngle].int_value();
-        uint8_t rotationAngle = static_cast<uint8_t>((angle > 180.0) ? angle - 180.0 : angle);
-        mPimpl->appendBits(metadata, rotationAngle, 8);
-
-        uint16_t semimajorExternalAxis =
-            static_cast<uint16_t>(ellipseJsonObject[EllipseNames::SemiMajorAxisExternalEllipse].int_value());
-
-        uint16_t semiminorExternalAxis =
-            static_cast<uint16_t>(ellipseJsonObject[EllipseNames::SemiMinorAxisExternalEllipse].int_value());
+            JsonObject ellipseJsonObject = jsonArray[i][EllipseNames::TagName].object_items();
 
-        uint16_t semimajorInternalEllipse =
-            static_cast<uint16_t>(ellipseJsonObject[EllipseNames::SemiMajorAxisInternalEllipse].int_value());
-
-        mPimpl->appendBits(metadata, semimajorInternalEllipse, 16);
+            mPimpl->appendBits(metadata,
+                               static_cast<uint16_t>(ellipseJsonObject[EllipseNames::CenterOfEllipseX].int_value()),
+                    16);
 
-        mPimpl->appendBits(metadata, semimajorExternalAxis, 16);
-        mPimpl->appendBits(metadata, semiminorExternalAxis, 16);
-        uint8_t overlapProcessOption = static_cast<uint8_t>(ellipseJsonObject[EllipseNames::OverlapProcessOption].int_value());
-        //TODO: Uses Layering method, the value is "1"
-        mPimpl->appendBits(metadata, overlapProcessOption, 1);
+            mPimpl->appendBits(metadata,
+                               static_cast<uint16_t>(ellipseJsonObject[EllipseNames::CenterOfEllipseY].int_value()),
+                    16);
+
+            int angle = ellipseJsonObject[EllipseNames::RotationAngle].int_value();
+            uint8_t rotationAngle = static_cast<uint8_t>((angle > 180.0) ? angle - 180.0 : angle);
+            mPimpl->appendBits(metadata, rotationAngle, 8);
+
+            uint16_t semimajorExternalAxis =
+                    static_cast<uint16_t>(ellipseJsonObject[EllipseNames::SemiMajorAxisExternalEllipse].int_value());
+
+            uint16_t semiminorExternalAxis =
+                    static_cast<uint16_t>(ellipseJsonObject[EllipseNames::SemiMinorAxisExternalEllipse].int_value());
+
+            uint16_t semimajorInternalEllipse =
+                    static_cast<uint16_t>(ellipseJsonObject[EllipseNames::SemiMajorAxisInternalEllipse].int_value());
+
+            mPimpl->appendBits(metadata, semimajorInternalEllipse, 16);
+
+            mPimpl->appendBits(metadata, semimajorExternalAxis, 16);
+            mPimpl->appendBits(metadata, semiminorExternalAxis, 16);
+            uint8_t overlapProcessOption = static_cast<uint8_t>(ellipseJsonObject[EllipseNames::OverlapProcessOption].int_value());
+            //TODO: Uses Layering method, the value is "1"
+            mPimpl->appendBits(metadata, overlapProcessOption, 1);
+        }
     }
+
     /* Targeted System Display Data */
-    uint32_t monitorPeak = fileData[frame][JsonDataKeys::TargetDisplayLuminance].int_value();     //500;
+    uint32_t monitorPeak = fileData[frame][JsonDataKeys::TargetDisplayLuminance].int_value();
     mPimpl->appendBits(metadata, monitorPeak, 27);
-    //NOTE: Set as false for now, as requested
+
     uint8_t targetedSystemDisplayActualPeakLuminanceFlag = 0;
     mPimpl->appendBits(metadata, targetedSystemDisplayActualPeakLuminanceFlag, 1);
     if (targetedSystemDisplayActualPeakLuminanceFlag)
@@ -439,21 +482,21 @@
         //TODO
     }
 
-    /* Max rgb values (maxScl)*/
+    /* Max RGB values (maxScl)*/
     /* Luminance values/percentile for each window */
     for (int w = 0; w < numWindows; ++w)
     {
         Json lumObj = fileData[frame][LuminanceNames::TagName];
         LuminanceParameters luminanceData;
-        if (!mPimpl->luminanceParamFromJson(lumObj, luminanceData))
+        if(!((isLLCJson && mPimpl->luminanceParamFromLLCJson(lumObj, luminanceData)) ||
+            !(isLLCJson && mPimpl->luminanceParamFromJson(lumObj, luminanceData))))
         {
             std::cout << "error parsing luminance parameters frame: " << w << std::endl;
         }
 
-        /* NOTE: Maxscl from 0 t 100,000 based on data that says in values of 0.00001
+        /* NOTE: Maxscl from 0 to 100,000 based on data that says in values of 0.00001
         * one for each channel R,G,B
         */
-
         mPimpl->appendBits(metadata, static_cast<uint8_t>(((int)luminanceData.maxRLuminance & 0x10000) >> 16), 1);
         mPimpl->appendBits(metadata, static_cast<uint16_t>((int)luminanceData.maxRLuminance & 0xFFFF), 16);
         mPimpl->appendBits(metadata, static_cast<uint8_t>(((int)luminanceData.maxGLuminance & 0x10000) >> 16), 1);
@@ -467,11 +510,21 @@
         uint8_t numDistributionMaxrgbPercentiles = static_cast<uint8_t>(luminanceData.order);
         mPimpl->appendBits(metadata, numDistributionMaxrgbPercentiles, 4);
 
-        std::vector<unsigned int>percentilPercentages;
-        mPimpl->percentagesFromJson(lumObj, percentilPercentages);
+        std::vector<unsigned int>percentilePercentages;
+
+        if(isLLCJson)
+        {
+            mPimpl->percentagesFromLLCJson(lumObj, percentilePercentages);
+        }
+        else
+        {
+            mPimpl->percentagesFromJson(lumObj, percentilePercentages);
+        }
+
+
         for (int i = 0; i < numDistributionMaxrgbPercentiles; ++i)
         {
-            uint8_t distributionMaxrgbPercentage = static_cast<uint8_t>(percentilPercentages.at(i));
+            uint8_t distributionMaxrgbPercentage = static_cast<uint8_t>(percentilePercentages.at(i));
             mPimpl->appendBits(metadata, distributionMaxrgbPercentage, 7);
 
             /* 17bits: 1bit then 16 */
@@ -483,7 +536,7 @@
         }
 
         /* 10bits: Fraction bright pixels */
-        uint16_t fractionBrightPixels = 1;
+        uint16_t fractionBrightPixels = 0;
         mPimpl->appendBits(metadata, fractionBrightPixels, 10);
 
     }
@@ -505,17 +558,20 @@
 		/* Select curve data based on global window */
         if (w == 0)
         {
-            if (!mPimpl->bezierCurveFromJson(fileData[frame][BezierCurveNames::TagName], curveData))
+            if(!((isLLCJson && mPimpl->bezierCurveFromLLCJson(fileData[frame][BezierCurveNames::TagName], curveData)) ||
+                !(isLLCJson && mPimpl->bezierCurveFromJson(fileData[frame][BezierCurveNames::TagName], curveData))))
             {
-				toneMappingFlag = 0;
+                toneMappingFlag = 0;
             }
         }
-	    /* Select curve data based on local window */
+
+        /* Select curve data based on local window */
         else
         {
+            JsonArray jsonArray = fileData[frame][JsonDataKeys::LocalParameters].array_items();
             if (!mPimpl->bezierCurveFromJson(jsonArray[w - 1][BezierCurveNames::TagName], curveData))
             {
-				toneMappingFlag = 0;
+                toneMappingFlag = 0;
             }
         }		
         mPimpl->appendBits(metadata, toneMappingFlag, 1);
diff -r 8bf51aa8a170 -r 7763d20f092a source/dynamicHDR10/metadataFromJson.h
--- a/source/dynamicHDR10/metadataFromJson.h	Thu Jul 12 17:23:26 2018 +0800
+++ b/source/dynamicHDR10/metadataFromJson.h	Thu Jul 12 12:14:00 2018 +0530
@@ -98,7 +98,7 @@
 
     class DynamicMetaIO;
     DynamicMetaIO *mPimpl;
-    void fillMetadataArray(const JsonArray &fileData, int frame, uint8_t *&metadata);
+    void fillMetadataArray(const JsonArray &fileData, int frame, const bool isLLCJson, uint8_t *&metadata);
 };
 
 #endif // METADATAFROMJSON_H
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265.patch
Type: text/x-patch
Size: 24987 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20180712/5f556b4a/attachment-0001.bin>


More information about the x265-devel mailing list