Commit 2e406d3d authored by Robert Niemi's avatar Robert Niemi

JPXStream: Replaces undefined left-shift operations.

Left-shifting a negative signed int is undefined. Most compilers shifts the same
way as unsigned ints, but it's better to be clear about it.
parent d9d9c9f1
......@@ -2816,7 +2816,7 @@ void JPXStream::inverseTransform(JPXTileComp *tileComp) {
if (shift2 > 0) {
cover(94);
if (val < 0) {
val = (val << shift2) - (1 << (shift2 - 1));
val = (((unsigned int)val) << shift2) - (1 << (shift2 - 1));
} else {
val = (val << shift2) + (1 << (shift2 - 1));
}
......@@ -2828,7 +2828,7 @@ void JPXStream::inverseTransform(JPXTileComp *tileComp) {
cover(96);
if (tileComp->transform == 0) {
cover(97);
val &= -1 << fracBits;
val &= 0xFFFFFFFF << fracBits;
}
} else {
cover(98);
......@@ -2931,7 +2931,7 @@ void JPXStream::inverseTransformLevel(JPXTileComp *tileComp,
if (shift2 > 0) {
cover(74);
if (val < 0) {
val = (val << shift2) - (1 << (shift2 - 1));
val = (((unsigned int)val) << shift2) - (1 << (shift2 - 1));
} else {
val = (val << shift2) + (1 << (shift2 - 1));
}
......@@ -2942,7 +2942,7 @@ void JPXStream::inverseTransformLevel(JPXTileComp *tileComp,
if (qStyle == 0) {
cover(76);
if (tileComp->transform == 0) {
val &= -1 << fracBits;
val &= 0xFFFFFFFF << fracBits;
}
} else {
cover(77);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment