<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 16, 2018 at 6:27 PM, <span dir="ltr"><<a href="mailto:praveen@multicorewareinc.com" target="_blank">praveen@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 Praveen Tiwari <<a href="mailto:praveen@multicorewareinc.com">praveen@multicorewareinc.com</a>><br>
# Date 1534424221 -19800<br>
# Thu Aug 16 18:27:01 2018 +0530<br>
# Node ID 88ee12651e3031dc1fc2f3f6a8bbac<wbr>5f67839579<br>
# Parent cbc24109c1c849c027b5f087c6ff5f<wbr>2087cb7301<br>
Patch for issue #422 - Credit to Dimitry Andric.<br>
<br>
This is due to undefined behavior in cuTreeFix8Pack(), where a double<br>
value is cast directly to uint16_t. If the double value is negative,<br>
the resulting value from the cast is undefined.<br>
<br>
diff -r cbc24109c1c8 -r 88ee12651e30 source/common/pixel.cpp<br>
--- a/source/common/pixel.cpp Tue Aug 14 18:01:51 2018 +0530<br>
+++ b/source/common/pixel.cpp Thu Aug 16 18:27:01 2018 +0530<br>
@@ -922,7 +922,7 @@<br>
static void cuTreeFix8Pack(uint16_t *dst, double *src, int count)<br>
{<br>
for (int i = 0; i < count; i++)<br>
- dst[i] = (uint16_t)(src[i] * 256.0);<br>
+ dst[i] = (uint16_t)(int16_t)(src[i] * 256.0);<br>
}<br>
<br>
static void cuTreeFix8Unpack(double *dst, uint16_t *src, int count)<br>
______________________________<wbr>_________________<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/<wbr>listinfo/x265-devel</a><br>
</blockquote></div><br></div><div class="gmail_extra">Pushed.</div></div>