From cc01949777e56db1cb1bb2fd3809e2963da6efa3 Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Thu, 7 Oct 2010 17:45:04 +0000 Subject: [PATCH] The original v1.3 branch had: ((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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libopenjpeg/t1.c b/libopenjpeg/t1.c index 139ff48e..dd11d694 100644 --- a/libopenjpeg/t1.c +++ b/libopenjpeg/t1.c @@ -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) */