summaryrefslogtreecommitdiff
path: root/src/decode.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/decode.c')
-rw-r--r--src/decode.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/decode.c b/src/decode.c
index 22487fd..3a25e6e 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -98,18 +98,19 @@
d = *bp; \
half_d = (d >> 1) + (d & 1); \
\
- if (data < med) { \
- if (half_d <= data) { \
+ /*in this case: data >= med == data & med */ \
+ if (data & med) { \
+ /*in this case: xmax - data == xmax ^ data */ \
+ if (half_d <= (xmax ^ data)) { \
data += (d >> 1)^(~((d & 1) - 1)); \
} else { \
- data = d; \
+ data = xmax ^ d; \
} \
} else { \
- /*in this case (xmax - data == xmax ^ data)*/ \
- if (half_d <= (xmax ^ data)) { \
+ if (half_d <= data) { \
data += (d >> 1)^(~((d & 1) - 1)); \
} else { \
- data = xmax ^ d; \
+ data = d; \
} \
} \
put_##KIND(strm, (uint32_t)data); \