[x265] [PATCH] api: add options max-luma and min-luma to set luma range of source pictures
kavitha at multicorewareinc.com
kavitha at multicorewareinc.com
Mon Aug 10 09:44:34 CEST 2015
# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1439192580 -19800
# Mon Aug 10 13:13:00 2015 +0530
# Node ID 2fca8a3399e4760a915c9952d3ac9f7143c0d364
# Parent cbdefdfca87723342d21d90c41a93254553ed3d1
api: add options max-luma and min-luma to set luma range of source pictures
diff -r cbdefdfca877 -r 2fca8a3399e4 doc/reST/cli.rst
--- a/doc/reST/cli.rst Thu Aug 06 14:23:43 2015 +0530
+++ b/doc/reST/cli.rst Mon Aug 10 13:13:00 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 of source picture that are below the specified
+ min-luma value to that value. No default.
+
+.. option:: --max-luma <integer>
+
+ Decrease any luma values of source picture that are above the specified
+ max-luma value to that value. No default.
+
Bitstream options
=================
diff -r cbdefdfca877 -r 2fca8a3399e4 source/CMakeLists.txt
--- a/source/CMakeLists.txt Thu Aug 06 14:23:43 2015 +0530
+++ b/source/CMakeLists.txt Mon Aug 10 13:13:00 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 2fca8a3399e4 source/common/param.cpp
--- a/source/common/param.cpp Thu Aug 06 14:23:43 2015 +0530
+++ b/source/common/param.cpp Mon Aug 10 13:13:00 2015 +0530
@@ -241,6 +241,8 @@
param->vui.defDispWinRightOffset = 0;
param->vui.defDispWinTopOffset = 0;
param->vui.defDispWinBottomOffset = 0;
+ param->minLuma = 0;
+ param->maxLuma = (1 << X265_DEPTH) - 1;
}
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 = (uint16_t)atoi(value);
+ OPT("max-luma") p->maxLuma = (uint16_t)atoi(value);
else
return X265_PARAM_BAD_NAME;
#undef OPT
diff -r cbdefdfca877 -r 2fca8a3399e4 source/common/picyuv.cpp
--- a/source/common/picyuv.cpp Thu Aug 06 14:23:43 2015 +0530
+++ b/source/common/picyuv.cpp Mon Aug 10 13:13:00 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, const x265_param& param, int padx, int pady)
{
/* 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,10 @@
for (int r = 0; r < height; r++)
{
+ /* Clip luma of source picture to max and min values before extending edges of picYuv */
+ for (int c = 0; c < m_stride; c++)
+ Y[c] = x265_clip3((pixel)param.minLuma, (pixel)param.maxLuma, Y[c]);
+
for (int x = 0; x < padx; x++)
Y[width + x] = Y[width - 1];
diff -r cbdefdfca877 -r 2fca8a3399e4 source/common/picyuv.h
--- a/source/common/picyuv.h Thu Aug 06 14:23:43 2015 +0530
+++ b/source/common/picyuv.h Mon Aug 10 13:13:00 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&, const x265_param& param, int padx, int pady);
intptr_t getChromaAddrOffset(uint32_t ctuAddr, uint32_t absPartIdx) const { return m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; }
diff -r cbdefdfca877 -r 2fca8a3399e4 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Thu Aug 06 14:23:43 2015 +0530
+++ b/source/encoder/encoder.cpp Mon Aug 10 13:13:00 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_param, m_sps.conformanceWindow.rightOffset, m_sps.conformanceWindow.bottomOffset);
inFrame->m_poc = ++m_pocLast;
inFrame->m_userData = pic_in->userData;
diff -r cbdefdfca877 -r 2fca8a3399e4 source/x265.h
--- a/source/x265.h Thu Aug 06 14:23:43 2015 +0530
+++ b/source/x265.h Mon Aug 10 13:13:00 2015 +0530
@@ -1172,6 +1172,16 @@
* picture average light level (or 0). */
const char* contentLightLevelInfo;
+ /* Minimum luma level of input source picture, specified as a integer which
+ * would automatically increase any luma values below the specified --min-luma
+ * value to that value. */
+ uint16_t minLuma;
+
+ /* Maximum luma level of input source picture, 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 2fca8a3399e4 source/x265cli.h
--- a/source/x265cli.h Thu Aug 06 14:23:43 2015 +0530
+++ b/source/x265cli.h Mon Aug 10 13:13:00 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 luma plane value of input source picture\n");
+ H0(" --max-luma <integer> Maximum luma plane value of input source picture\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