The original v1.3 branch had:
authorMathieu Malaterre <mathieu.malaterre@gmail.com>
Thu, 7 Oct 2010 17:45:04 +0000 (17:45 +0000)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>
Thu, 7 Oct 2010 17:45:04 +0000 (17:45 +0000)
((int*)tiledp)[(j * tile_w) + i] = tmp / 2;
while v2 had:
((OPJ_INT32*)tiledp)[(j * tile_w) + i] = tmp >> 1;
Divide by two and a right shift operation are only equivalent when the data
is unsigned. In this case the data is signed, so the right shift operation
is incorrectly clearing the sign bit.
Patch from: Sheet Spotter

libopenjpeg/t1.c

index 139ff48e4f818fe4df4d793edafe5e32302f32da..dd11d6944f7598392b726fd798b89cf50a24ff0b 100644 (file)
@@ -1264,7 +1264,7 @@ void t1_decode_cblks(
                                                for (j = 0; j < cblk_h; ++j) {
                                                        for (i = 0; i < cblk_w; ++i) {
                                                                OPJ_INT32 tmp = datap[(j * cblk_w) + i];
-                                                               ((OPJ_INT32*)tiledp)[(j * tile_w) + i] = tmp >> 1;
+                                                               ((OPJ_INT32*)tiledp)[(j * tile_w) + i] = tmp / 2;
                                                        }
                                                }
                                        } else {                /* if (tccp->qmfbid == 0) */