<div dir="ltr"><div><div><div>Kavitha,<br><br></div>This was pushed, but copyFromPicture has a couple of issues. <br><br></div>The clipping is applied only on x-padding component. As is apparent, the number of pixels here is just padx, not m_stride. <br><br></div>The clipping needs to be performed on the main picture itself, as well as pady. <br><div><div><br><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 10, 2015 at 1:14 PM, <span dir="ltr"><<a href="mailto:kavitha@multicorewareinc.com" target="_blank">kavitha@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Kavitha Sampath <<a href="mailto:kavitha@multicorewareinc.com">kavitha@multicorewareinc.com</a>><br>
# Date 1439192580 -19800<br>
# Mon Aug 10 13:13:00 2015 +0530<br>
# Node ID 2fca8a3399e4760a915c9952d3ac9f7143c0d364<br>
# Parent cbdefdfca87723342d21d90c41a93254553ed3d1<br>
api: add options max-luma and min-luma to set luma range of source pictures<br>
<br>
diff -r cbdefdfca877 -r 2fca8a3399e4 doc/reST/cli.rst<br>
--- a/doc/reST/cli.rst Thu Aug 06 14:23:43 2015 +0530<br>
+++ b/doc/reST/cli.rst Mon Aug 10 13:13:00 2015 +0530<br>
@@ -1638,6 +1638,16 @@<br>
Note that this string value will need to be escaped or quoted to<br>
protect against shell expansion on many platforms. No default.<br>
<br>
+.. option:: --min-luma <integer><br>
+<br>
+ Increase any luma values of source picture that are below the specified<br>
+ min-luma value to that value. No default.<br>
+<br>
+.. option:: --max-luma <integer><br>
+<br>
+ Decrease any luma values of source picture that are above the specified<br>
+ max-luma value to that value. No default.<br>
+<br>
Bitstream options<br>
=================<br>
<br>
diff -r cbdefdfca877 -r 2fca8a3399e4 source/CMakeLists.txt<br>
--- a/source/CMakeLists.txt Thu Aug 06 14:23:43 2015 +0530<br>
+++ b/source/CMakeLists.txt Mon Aug 10 13:13:00 2015 +0530<br>
@@ -30,7 +30,7 @@<br>
mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br>
<br>
# X265_BUILD must be incremented each time the public API is changed<br>
-set(X265_BUILD 68)<br>
+set(X265_BUILD 70)<br>
configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in" rel="noreferrer" target="_blank">x265.def.in</a>"<br>
"${PROJECT_BINARY_DIR}/x265.def")<br>
configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265_config.h.in" rel="noreferrer" target="_blank">x265_config.h.in</a>"<br>
diff -r cbdefdfca877 -r 2fca8a3399e4 source/common/param.cpp<br>
--- a/source/common/param.cpp Thu Aug 06 14:23:43 2015 +0530<br>
+++ b/source/common/param.cpp Mon Aug 10 13:13:00 2015 +0530<br>
@@ -241,6 +241,8 @@<br>
param->vui.defDispWinRightOffset = 0;<br>
param->vui.defDispWinTopOffset = 0;<br>
param->vui.defDispWinBottomOffset = 0;<br>
+ param->minLuma = 0;<br>
+ param->maxLuma = (1 << X265_DEPTH) - 1;<br>
}<br>
<br>
int x265_param_default_preset(x265_param* param, const char* preset, const char* tune)<br>
@@ -855,6 +857,8 @@<br>
OPT("qg-size") p->rc.qgSize = atoi(value);<br>
OPT("master-display") p->masteringDisplayColorVolume = strdup(value);<br>
OPT("max-cll") p->contentLightLevelInfo = strdup(value);<br>
+ OPT("min-luma") p->minLuma = (uint16_t)atoi(value);<br>
+ OPT("max-luma") p->maxLuma = (uint16_t)atoi(value);<br>
else<br>
return X265_PARAM_BAD_NAME;<br>
#undef OPT<br>
diff -r cbdefdfca877 -r 2fca8a3399e4 source/common/picyuv.cpp<br>
--- a/source/common/picyuv.cpp Thu Aug 06 14:23:43 2015 +0530<br>
+++ b/source/common/picyuv.cpp Mon Aug 10 13:13:00 2015 +0530<br>
@@ -121,7 +121,7 @@<br>
<br>
/* Copy pixels from an x265_picture into internal PicYuv instance.<br>
* Shift pixels as necessary, mask off bits above X265_DEPTH for safety. */<br>
-void PicYuv::copyFromPicture(const x265_picture& pic, int padx, int pady)<br>
+void PicYuv::copyFromPicture(const x265_picture& pic, const x265_param& param, int padx, int pady)<br>
{<br>
/* m_picWidth is the width that is being encoded, padx indicates how many<br>
* of those pixels are padding to reach multiple of MinCU(4) size.<br>
@@ -237,6 +237,10 @@<br>
<br>
for (int r = 0; r < height; r++)<br>
{<br>
+ /* Clip luma of source picture to max and min values before extending edges of picYuv */<br>
+ for (int c = 0; c < m_stride; c++)<br>
+ Y[c] = x265_clip3((pixel)param.minLuma, (pixel)param.maxLuma, Y[c]);<br>
+<br>
for (int x = 0; x < padx; x++)<br>
Y[width + x] = Y[width - 1];<br>
<br>
diff -r cbdefdfca877 -r 2fca8a3399e4 source/common/picyuv.h<br>
--- a/source/common/picyuv.h Thu Aug 06 14:23:43 2015 +0530<br>
+++ b/source/common/picyuv.h Mon Aug 10 13:13:00 2015 +0530<br>
@@ -66,7 +66,7 @@<br>
bool createOffsets(const SPS& sps);<br>
void destroy();<br>
<br>
- void copyFromPicture(const x265_picture&, int padx, int pady);<br>
+ void copyFromPicture(const x265_picture&, const x265_param& param, int padx, int pady);<br>
<br>
intptr_t getChromaAddrOffset(uint32_t ctuAddr, uint32_t absPartIdx) const { return m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; }<br>
<br>
diff -r cbdefdfca877 -r 2fca8a3399e4 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Thu Aug 06 14:23:43 2015 +0530<br>
+++ b/source/encoder/encoder.cpp Mon Aug 10 13:13:00 2015 +0530<br>
@@ -458,7 +458,7 @@<br>
}<br>
<br>
/* Copy input picture into a Frame and PicYuv, send to lookahead */<br>
- inFrame->m_fencPic->copyFromPicture(*pic_in, m_sps.conformanceWindow.rightOffset, m_sps.conformanceWindow.bottomOffset);<br>
+ inFrame->m_fencPic->copyFromPicture(*pic_in, *m_param, m_sps.conformanceWindow.rightOffset, m_sps.conformanceWindow.bottomOffset);<br>
<br>
inFrame->m_poc = ++m_pocLast;<br>
inFrame->m_userData = pic_in->userData;<br>
diff -r cbdefdfca877 -r 2fca8a3399e4 source/x265.h<br>
--- a/source/x265.h Thu Aug 06 14:23:43 2015 +0530<br>
+++ b/source/x265.h Mon Aug 10 13:13:00 2015 +0530<br>
@@ -1172,6 +1172,16 @@<br>
* picture average light level (or 0). */<br>
const char* contentLightLevelInfo;<br>
<br>
+ /* Minimum luma level of input source picture, specified as a integer which<br>
+ * would automatically increase any luma values below the specified --min-luma<br>
+ * value to that value. */<br>
+ uint16_t minLuma;<br>
+<br>
+ /* Maximum luma level of input source picture, specified as a integer which<br>
+ * would automatically decrease any luma values above the specified --max-luma<br>
+ * value to that value. */<br>
+ uint16_t maxLuma;<br>
+<br>
} x265_param;<br>
<br>
/* x265_param_alloc:<br>
diff -r cbdefdfca877 -r 2fca8a3399e4 source/x265cli.h<br>
--- a/source/x265cli.h Thu Aug 06 14:23:43 2015 +0530<br>
+++ b/source/x265cli.h Mon Aug 10 13:13:00 2015 +0530<br>
@@ -192,6 +192,8 @@<br>
{ "crop-rect", required_argument, NULL, 0 }, /* DEPRECATED */<br>
{ "master-display", required_argument, NULL, 0 },<br>
{ "max-cll", required_argument, NULL, 0 },<br>
+ { "min-luma", required_argument, NULL, 0 },<br>
+ { "max-luma", required_argument, NULL, 0 },<br>
{ "no-dither", no_argument, NULL, 0 },<br>
{ "dither", no_argument, NULL, 0 },<br>
{ "no-repeat-headers", no_argument, NULL, 0 },<br>
@@ -403,6 +405,8 @@<br>
H0(" --master-display <string> SMPTE ST 2086 master display color volume info SEI (HDR)\n");<br>
H0(" format: G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)\n");<br>
H0(" --max-cll <string> Emit content light level info SEI as \"cll,fall\" (HDR)\n");<br>
+ H0(" --min-luma <integer> Minimum luma plane value of input source picture\n");<br>
+ H0(" --max-luma <integer> Maximum luma plane value of input source picture\n");<br>
H0("\nBitstream options:\n");<br>
H0(" --[no-]repeat-headers Emit SPS and PPS headers at each keyframe. Default %s\n", OPT(param->bRepeatHeaders));<br>
H0(" --[no-]info Emit SEI identifying encoder and parameters. Default %s\n", OPT(param->bEmitInfoSEI));<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div>