diff -urN -x '*.orig' -x '*.rej' -x '*~' -x '.*' OpenJPEG.orig/libopenjpeg/mqc.c OpenJPEG.patched/libopenjpeg/mqc.c
--- OpenJPEG.orig/libopenjpeg/mqc.c	2007-07-17 20:07:22.000000000 -0500
+++ OpenJPEG.patched/libopenjpeg/mqc.c	2007-07-17 20:07:44.000000000 -0500
@@ -507,20 +507,20 @@
 
 int mqc_decode(opj_mqc_t *mqc) {
 	int d;
-	mqc->a -= (*mqc->curctx)->qeval;
-	if ((mqc->c >> 16) < (*mqc->curctx)->qeval) {
+	unsigned int qeval = (*mqc->curctx)->qeval;
+	mqc->a -= qeval;
+	qeval <<= 16;
+	if (mqc->c < qeval) {
 		d = mqc_lpsexchange(mqc);
-		mqc_renormd(mqc);
 	} else {
-		mqc->c -= (*mqc->curctx)->qeval << 16;
+		mqc->c -= qeval;
 		if ((mqc->a & 0x8000) == 0) {
 			d = mqc_mpsexchange(mqc);
-			mqc_renormd(mqc);
 		} else {
-			d = (*mqc->curctx)->mps;
+			return (*mqc->curctx)->mps;
 		}
 	}
-
+	mqc_renormd(mqc);
 	return d;
 }
 
