[x265] [PATCH] api: add options max-luma and min-luma to set the maximum and minimum luma range

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Sun Aug 9 16:03:00 CEST 2015


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1439128645 -19800
#      Sun Aug 09 19:27:25 2015 +0530
# Node ID f9c4219faab20fdc329eca670542e25bfd74af3e
# Parent  cbdefdfca87723342d21d90c41a93254553ed3d1
api: add options max-luma and min-luma to set the maximum and minimum luma range

diff -r cbdefdfca877 -r f9c4219faab2 doc/reST/cli.rst
--- a/doc/reST/cli.rst	Thu Aug 06 14:23:43 2015 +0530
+++ b/doc/reST/cli.rst	Sun Aug 09 19:27:25 2015 +0530
@@ -1638,6 +1638,16 @@
 	Note that this string value will need to be escaped or quoted to
 	protect against shell expansion on many platforms. No default.
 
+.. option:: --min-luma <integer>
+
+	Increase any luma values that are below the specified min-luma vlaue to
+	that value. No default.
+
+.. option:: --max-luma <integer>
+
+	Decrease any luma values that are above the specified max-luma vlaue to
+	that value. No default.
+
 Bitstream options
 =================
 
diff -r cbdefdfca877 -r f9c4219faab2 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Thu Aug 06 14:23:43 2015 +0530
+++ b/source/CMakeLists.txt	Sun Aug 09 19:27:25 2015 +0530
@@ -30,7 +30,7 @@
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 68)
+set(X265_BUILD 70)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r cbdefdfca877 -r f9c4219faab2 source/common/param.cpp
--- a/source/common/param.cpp	Thu Aug 06 14:23:43 2015 +0530
+++ b/source/common/param.cpp	Sun Aug 09 19:27:25 2015 +0530
@@ -241,6 +241,8 @@
     param->vui.defDispWinRightOffset = 0;
     param->vui.defDispWinTopOffset = 0;
     param->vui.defDispWinBottomOffset = 0;
+    param->minLuma = 0;
+    param->maxLuma = 0;
 }
 
 int x265_param_default_preset(x265_param* param, const char* preset, const char* tune)
@@ -855,6 +857,8 @@
     OPT("qg-size") p->rc.qgSize = atoi(value);
     OPT("master-display") p->masteringDisplayColorVolume = strdup(value);
     OPT("max-cll") p->contentLightLevelInfo = strdup(value);
+    OPT("min-luma") p->minLuma = atoi(value);
+    OPT("max-luma") p->maxLuma = atoi(value);
     else
         return X265_PARAM_BAD_NAME;
 #undef OPT
diff -r cbdefdfca877 -r f9c4219faab2 source/common/picyuv.cpp
--- a/source/common/picyuv.cpp	Thu Aug 06 14:23:43 2015 +0530
+++ b/source/common/picyuv.cpp	Sun Aug 09 19:27:25 2015 +0530
@@ -121,7 +121,7 @@
 
 /* Copy pixels from an x265_picture into internal PicYuv instance.
  * Shift pixels as necessary, mask off bits above X265_DEPTH for safety. */
-void PicYuv::copyFromPicture(const x265_picture& pic, int padx, int pady)
+void PicYuv::copyFromPicture(const x265_picture& pic, int padx, int pady, x265_param *param)
 {
     /* m_picWidth is the width that is being encoded, padx indicates how many
      * of those pixels are padding to reach multiple of MinCU(4) size.
@@ -237,6 +237,15 @@
 
         for (int r = 0; r < height; r++)
         {
+            /* Clip luma to max and min values before extending edges of picYuv*/
+            if (param->minLuma || param->maxLuma)
+            {
+                for (int c = 0; c < m_stride; c++)
+                {
+                    Y[c] = param->minLuma ? (pixel)X265_MAX(Y[c], param->minLuma) : Y[c];
+                    Y[c] = param->maxLuma ? (pixel)X265_MIN(Y[c], param->maxLuma) : Y[c];
+                }
+            }
             for (int x = 0; x < padx; x++)
                 Y[width + x] = Y[width - 1];
 
diff -r cbdefdfca877 -r f9c4219faab2 source/common/picyuv.h
--- a/source/common/picyuv.h	Thu Aug 06 14:23:43 2015 +0530
+++ b/source/common/picyuv.h	Sun Aug 09 19:27:25 2015 +0530
@@ -66,7 +66,7 @@
     bool  createOffsets(const SPS& sps);
     void  destroy();
 
-    void  copyFromPicture(const x265_picture&, int padx, int pady);
+    void  copyFromPicture(const x265_picture&, int padx, int pady, x265_param *param);
 
     intptr_t getChromaAddrOffset(uint32_t ctuAddr, uint32_t absPartIdx) const { return m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; }
 
diff -r cbdefdfca877 -r f9c4219faab2 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Thu Aug 06 14:23:43 2015 +0530
+++ b/source/encoder/encoder.cpp	Sun Aug 09 19:27:25 2015 +0530
@@ -458,7 +458,7 @@
         }
 
         /* Copy input picture into a Frame and PicYuv, send to lookahead */
-        inFrame->m_fencPic->copyFromPicture(*pic_in, m_sps.conformanceWindow.rightOffset, m_sps.conformanceWindow.bottomOffset);
+        inFrame->m_fencPic->copyFromPicture(*pic_in, m_sps.conformanceWindow.rightOffset, m_sps.conformanceWindow.bottomOffset, m_param);
 
         inFrame->m_poc       = ++m_pocLast;
         inFrame->m_userData  = pic_in->userData;
diff -r cbdefdfca877 -r f9c4219faab2 source/x265.h
--- a/source/x265.h	Thu Aug 06 14:23:43 2015 +0530
+++ b/source/x265.h	Sun Aug 09 19:27:25 2015 +0530
@@ -1172,6 +1172,16 @@
      * picture average light level (or 0). */
     const char* contentLightLevelInfo;
 
+    /* Maximum luma level, specified as a integer which would automatically
+     * increase any luma values below the specified --min-luma value to that
+     * value. */
+    uint16_t minLuma;
+
+    /* Minimum luma Level, specified as a integer which would automatically
+     * decrease any luma values above the specified --max-luma value to that
+     * value. */
+    uint16_t maxLuma;
+
 } x265_param;
 
 /* x265_param_alloc:
diff -r cbdefdfca877 -r f9c4219faab2 source/x265cli.h
--- a/source/x265cli.h	Thu Aug 06 14:23:43 2015 +0530
+++ b/source/x265cli.h	Sun Aug 09 19:27:25 2015 +0530
@@ -192,6 +192,8 @@
     { "crop-rect",      required_argument, NULL, 0 }, /* DEPRECATED */
     { "master-display", required_argument, NULL, 0 },
     { "max-cll",        required_argument, NULL, 0 },
+	{ "min-luma",       required_argument, NULL, 0 },
+	{ "max-luma",       required_argument, NULL, 0 },
     { "no-dither",            no_argument, NULL, 0 },
     { "dither",               no_argument, NULL, 0 },
     { "no-repeat-headers",    no_argument, NULL, 0 },
@@ -403,6 +405,8 @@
     H0("   --master-display <string>     SMPTE ST 2086 master display color volume info SEI (HDR)\n");
     H0("                                    format: G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)\n");
     H0("   --max-cll <string>            Emit content light level info SEI as \"cll,fall\" (HDR)\n");
+    H0("   --min-luma <integer>          Minimum value of luma plane\n");
+    H0("   --max-luma <integer>          Maximum value of luma plane\n");
     H0("\nBitstream options:\n");
     H0("   --[no-]repeat-headers         Emit SPS and PPS headers at each keyframe. Default %s\n", OPT(param->bRepeatHeaders));
     H0("   --[no-]info                   Emit SEI identifying encoder and parameters. Default %s\n", OPT(param->bEmitInfoSEI));


More information about the x265-devel mailing list