ref: 68f6b1775edd008f24803336597c5aac38845763
parent: 8e1d06df8244cf40bb6b9ba1f1e46c9a5d3feb34
author: Ronald S. Bultje <rsbultje@gmail.com>
date: Wed Oct 24 10:26:28 EDT 2018
Prevent right-shift by 32 Fixes #93.
--- a/src/decode.c
+++ b/src/decode.c
@@ -298,9 +298,9 @@
} else for (unsigned off = 0, xmask = masks[0]; np < 8 && xmask;) { // top
const int tz = ctz(xmask);
off += tz;
+ xmask >>= tz;
add_sample(off, 0, 1, -1, &r[off - b4_stride]);
- xmask >>= tz + 1;
- off += 1;
+ xmask &= ~1;
}
if (np < 8 && masks[1] == 1) {
const int off = t->by & (bs(&r[-1])[1] - 1);
@@ -308,9 +308,9 @@
} else for (unsigned off = 0, ymask = masks[1]; np < 8 && ymask;) { // left
const int tz = ctz(ymask);
off += tz;
+ ymask >>= tz;
add_sample(0, off, -1, 1, &r[off * b4_stride - 1]);
- ymask >>= tz + 1;
- off += 1;
+ ymask &= ~1;
}
if (np < 8 && masks[1] >> 32) // top/left
add_sample(0, 0, -1, -1, &r[-(1 + b4_stride)]);