<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Feb 7, 2014 at 5:48 AM, <span dir="ltr"><<a href="mailto:gopu@multicorewareinc.com" target="_blank">gopu@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 Gopu Govindaswamy<br>
# Date 1391732264 28800<br>
# Thu Feb 06 16:17:44 2014 -0800<br>
# Node ID 0198815523c1e653fee59f8b6ee58bffbfb12131<br>
# Parent 634bc0b1c24653dd254df77cd80f96f81e71e888<br>
slicetype: bug fix for cuTree, use type int32_t for listamount and propagate_amount to calculate valid propagate_cost<br>
<br>
diff -r 634bc0b1c246 -r 0198815523c1 source/encoder/slicetype.cpp<br>
--- a/source/encoder/slicetype.cpp Wed Feb 05 23:10:22 2014 -0600<br>
+++ b/source/encoder/slicetype.cpp Thu Feb 06 16:17:44 2014 -0800<br>
@@ -824,10 +824,10 @@<br>
void Lookahead::estimateCUPropagate(Lowres **frames, double averageDuration, int p0, int p1, int b, int referenced)<br>
{<br>
uint16_t *refCosts[2] = { frames[p0]->propagateCost, frames[p1]->propagateCost };<br>
- int distScaleFactor = (((b - p0) << 8) + ((p1 - p0) >> 1)) / (p1 - p0);<br>
- int bipredWeight = cfg->param.bEnableWeightedBiPred ? 64 - (distScaleFactor >> 2) : 32;<br>
+ int32_t distScaleFactor = (((b - p0) << 8) + ((p1 - p0) >> 1)) / (p1 - p0);<br>
+ int32_t bipredWeight = cfg->param.bEnableWeightedBiPred ? 64 - (distScaleFactor >> 2) : 32;<br>
MV *mvs[2] = { frames[b]->lowresMvs[0][b - p0 - 1], frames[b]->lowresMvs[1][p1 - b - 1] };<br>
- int bipredWeights[2] = { bipredWeight, 64 - bipredWeight };<br>
+ int32_t bipredWeights[2] = { bipredWeight, 64 - bipredWeight };<br>
<br>
memset(scratch, 0, widthInCU * sizeof(int));<br>
<br>
@@ -840,8 +840,8 @@<br>
if (!referenced)<br>
memset(frames[b]->propagateCost, 0, widthInCU * sizeof(uint16_t));<br>
<br>
- uint16_t StrideInCU = (uint16_t)widthInCU;<br>
- for (uint16_t blocky = 0; blocky < heightInCU; blocky++)<br>
+ int32_t StrideInCU = widthInCU;<br>
+ for (int32_t blocky = 0; blocky < heightInCU; blocky++)<br></blockquote><div><br></div><div>Why have these unsigned loop indices been changed to signed? rest looks valid.<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
{<br>
int cuIndex = blocky * StrideInCU;<br>
/* TODO This function go into ASM */<br>
@@ -851,24 +851,24 @@<br>
<br>
if (referenced)<br>
propagateCost += widthInCU;<br>
- for (uint16_t blockx = 0; blockx < widthInCU; blockx++, cuIndex++)<br>
+ for (int32_t blockx = 0; blockx < widthInCU; blockx++, cuIndex++)<br>
{<br>
- int propagate_amount = scratch[blockx];<br>
+ int32_t propagate_amount = scratch[blockx];<br>
/* Don't propagate for an intra block. */<br>
if (propagate_amount > 0)<br>
{<br>
/* Access width-2 bitfield. */<br>
- int lists_used = frames[b]->lowresCosts[b - p0][p1 - b][cuIndex] >> LOWRES_COST_SHIFT;<br>
+ int32_t lists_used = frames[b]->lowresCosts[b - p0][p1 - b][cuIndex] >> LOWRES_COST_SHIFT;<br>
/* Follow the MVs to the previous frame(s). */<br>
- for (uint16_t list = 0; list < 2; list++)<br>
+ for (int32_t list = 0; list < 2; list++)<br>
{<br>
if ((lists_used >> list) & 1)<br>
{<br>
-#define CLIP_ADD(s, x) (s) = X265_MIN((s) + (x), (1 << 16) - 1)<br>
- uint16_t listamount = (uint16_t)propagate_amount;<br>
+#define CLIP_ADD(s, x) (s) = (uint16_t) X265_MIN((s) + (x), (1 << 16) - 1)<br>
+ int32_t listamount = propagate_amount;</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
/* Apply bipred weighting. */<br>
if (lists_used == 3)<br>
- listamount = (uint16_t)(listamount * bipredWeights[list] + 32) >> 6;<br>
+ listamount = (listamount * bipredWeights[list] + 32) >> 6;<br>
<br>
/* Early termination for simple case of mv0. */<br>
if (!mvs[list][cuIndex].word)<br>
@@ -877,20 +877,20 @@<br>
continue;<br>
}<br>
<br>
- uint16_t x = mvs[list][cuIndex].x;<br>
- uint16_t y = mvs[list][cuIndex].y; <br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- int cux = (x >> 5) + blockx;<br>
- int cuy = (y >> 5) + blocky;<br>
- int idx0 = cux + cuy * StrideInCU;<br>
- int idx1 = idx0 + 1;<br>
- int idx2 = idx0 + StrideInCU;<br>
- int idx3 = idx0 + StrideInCU + 1;<br>
+ int32_t x = mvs[list][cuIndex].x;<br>
+ int32_t y = mvs[list][cuIndex].y;<br>
+ int32_t cux = (x >> 5) + blockx;<br>
+ int32_t cuy = (y >> 5) + blocky;<br>
+ int32_t idx0 = cux + cuy * StrideInCU;<br>
+ int32_t idx1 = idx0 + 1;<br>
+ int32_t idx2 = idx0 + StrideInCU;<br>
+ int32_t idx3 = idx0 + StrideInCU + 1;<br>
x &= 31;<br>
y &= 31;<br>
- uint16_t idx0weight = (uint16_t)(32 - y) * (32 - x);<br>
- uint16_t idx1weight = (uint16_t)(32 - y) * x;<br>
- uint16_t idx2weight = (uint16_t)y * (32 - x);<br>
- uint16_t idx3weight = (uint16_t)y * x;<br>
+ int32_t idx0weight = (32 - y) * (32 - x);<br>
+ int32_t idx1weight = (32 - y) * x;<br>
+ int32_t idx2weight = y * (32 - x);<br>
+ int32_t idx3weight = y * x;<br>
<br>
/* We could just clip the MVs, but pixels that lie outside the frame probably shouldn't<br>
* be counted. */<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" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div></div>