[x265] [PATCH] param: replace contentLightLevelInfo with seperate integers maxCLL and maxFALL

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Mon Aug 31 16:36:23 CEST 2015


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1441031550 -19800
#      Mon Aug 31 20:02:30 2015 +0530
# Node ID 838b20d69bbc6470c3f466a3270602ab7c93a99f
# Parent  20941da8ac6a115e88a419ba713ee9ea10d70c7e
param: replace contentLightLevelInfo with seperate integers maxCLL and maxFALL

diff -r 20941da8ac6a -r 838b20d69bbc source/common/param.cpp
--- a/source/common/param.cpp	Fri Aug 28 17:51:54 2015 -0700
+++ b/source/common/param.cpp	Mon Aug 31 20:02:30 2015 +0530
@@ -241,6 +241,8 @@
     param->vui.defDispWinRightOffset = 0;
     param->vui.defDispWinTopOffset = 0;
     param->vui.defDispWinBottomOffset = 0;
+    param->maxCLL = 0;
+    param->maxFALL = 0;
     param->minLuma = 0;
     param->maxLuma = (1 << X265_DEPTH) - 1;
 }
@@ -856,7 +858,7 @@
     OPT("analysis-file") p->analysisFileName = strdup(value);
     OPT("qg-size") p->rc.qgSize = atoi(value);
     OPT("master-display") p->masteringDisplayColorVolume = strdup(value);
-    OPT("max-cll") p->contentLightLevelInfo = strdup(value);
+    OPT("max-cll") bError |= sscanf(value, "%hu,%hu", &p->maxCLL, &p->maxFALL) != 2;
     OPT("min-luma") p->minLuma = (uint16_t)atoi(value);
     OPT("max-luma") p->maxLuma = (uint16_t)atoi(value);
     else
diff -r 20941da8ac6a -r 838b20d69bbc source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Fri Aug 28 17:51:54 2015 -0700
+++ b/source/encoder/encoder.cpp	Mon Aug 31 20:02:30 2015 +0530
@@ -337,6 +337,8 @@
     m_encodeStartTime = x265_mdate();
 
     m_nalList.m_annexB = !!m_param->bAnnexB;
+
+    m_emitCLLSEI = p->maxCLL || p->maxFALL;
 }
 
 void Encoder::stopJobs()
@@ -410,7 +412,6 @@
         free((char*)m_param->scalingLists);
         free((char*)m_param->numaPools);
         free((char*)m_param->masteringDisplayColorVolume);
-        free((char*)m_param->contentLightLevelInfo);
 
         PARAM_NS::x265_param_free(m_param);
     }
@@ -1130,13 +1131,11 @@
 
         stats->maxCLL         = m_analyzeAll.m_maxCLL;
         stats->maxFALL        = (uint16_t)(m_analyzeAll.m_maxFALL / m_analyzeAll.m_numPics);
-        if (m_param->contentLightLevelInfo)
+
+        if (m_emitCLLSEI)
         {
-            free((char*)m_param->contentLightLevelInfo);
-
-            char value[16];
-            sprintf(value, "%hu,%hu", stats->maxCLL, stats->maxFALL);
-            m_param->contentLightLevelInfo = strdup(value);
+            m_param->maxCLL = stats->maxCLL;
+            m_param->maxFALL = stats->maxFALL;
         }
     }
 
@@ -1320,18 +1319,15 @@
             x265_log(m_param, X265_LOG_WARNING, "unable to parse mastering display color volume info\n");
     }
 
-    if (m_param->contentLightLevelInfo)
+    if (m_emitCLLSEI)
     {
         SEIContentLightLevel cllsei;
-        if (cllsei.parse(m_param->contentLightLevelInfo))
-        {
-            bs.resetBits();
-            cllsei.write(bs, m_sps);
-            bs.writeByteAlignment();
-            list.serialize(NAL_UNIT_PREFIX_SEI, bs);
-        }
-        else
-            x265_log(m_param, X265_LOG_WARNING, "unable to parse content light level info\n");
+        cllsei.max_content_light_level = m_param->maxCLL;
+        cllsei.max_pic_average_light_level = m_param->maxFALL;
+        bs.resetBits();
+        cllsei.write(bs, m_sps);
+        bs.writeByteAlignment();
+        list.serialize(NAL_UNIT_PREFIX_SEI, bs);
     }
 
     if (m_param->bEmitInfoSEI)
diff -r 20941da8ac6a -r 838b20d69bbc source/encoder/encoder.h
--- a/source/encoder/encoder.h	Fri Aug 28 17:51:54 2015 -0700
+++ b/source/encoder/encoder.h	Mon Aug 31 20:02:30 2015 +0530
@@ -117,6 +117,7 @@
     NALList            m_nalList;
     ScalingList        m_scalingList;      // quantization matrix information
 
+    bool               m_emitCLLSEI;
     int                m_lastBPSEI;
     uint32_t           m_numDelayedPic;
 
diff -r 20941da8ac6a -r 838b20d69bbc source/encoder/sei.h
--- a/source/encoder/sei.h	Fri Aug 28 17:51:54 2015 -0700
+++ b/source/encoder/sei.h	Mon Aug 31 20:02:30 2015 +0530
@@ -163,12 +163,6 @@
 
     PayloadType payloadType() const { return CONTENT_LIGHT_LEVEL_INFO; }
 
-    bool parse(const char* value)
-    {
-        return sscanf(value, "%hu,%hu",
-                      &max_content_light_level, &max_pic_average_light_level) == 2;
-    }
-
     void write(Bitstream& bs, const SPS&)
     {
         m_bitIf = &bs;
diff -r 20941da8ac6a -r 838b20d69bbc source/x265.h
--- a/source/x265.h	Fri Aug 28 17:51:54 2015 -0700
+++ b/source/x265.h	Mon Aug 31 20:02:30 2015 +0530
@@ -1176,12 +1176,17 @@
      * max,min luminance values. */
     const char* masteringDisplayColorVolume;
 
-    /* Content light level info SEI, specified as a string which is parsed when
-     * the stream header SEI are emitted. The string format is "%hu,%hu" where
-     * %hu are unsigned 16bit integers. The first value is the max content light
-     * level (or 0 if no maximum is indicated), the second value is the maximum
-     * picture average light level (or 0). */
-    const char* contentLightLevelInfo;
+    /* Maximum Content light level(MaxCLL), specified as integer that indicates the
+     * maximum pixel intensity level in units of 1 candela per square metre of the
+     * bitstream. x265 will also calculate MaxCLL programmatically from the input
+     * pixel values and set in the Content light level info SEI */
+    uint16_t maxCLL;
+
+    /* Maximum Frame Average Light Level(MaxFALL), specified as integer that indicates
+     * the maximum frame average intensity level in units of 1 candela per square
+     * metre of the bitstream. x265 will also calculate MaxFALL programmatically
+     * from the input pixel values and set in the Content light level info SEI */
+    uint16_t maxFALL;
 
     /* Minimum luma level of input source picture, specified as a integer which
      * would automatically increase any luma values below the specified --min-luma


More information about the x265-devel mailing list