aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/rangecoder
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-03-24 16:38:40 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-03-24 16:38:40 +0200
commit641998c3e1ecc8b598fe0eb051fab8b9535c291b (patch)
tree7a0cee9b393131475cca96848d0f72fc62153460 /src/liblzma/rangecoder
parentTake advantage of arithmetic right shift in range decoder. (diff)
downloadxz-641998c3e1ecc8b598fe0eb051fab8b9535c291b.tar.xz
Replaced the range decoder optimization that used arithmetic
right shift with as fast version that doesn't need arithmetic right shift. Removed the related check from configure.ac.
Diffstat (limited to '')
-rw-r--r--src/liblzma/rangecoder/range_decoder.h53
1 files changed, 16 insertions, 37 deletions
diff --git a/src/liblzma/rangecoder/range_decoder.h b/src/liblzma/rangecoder/range_decoder.h
index a6a92b0b..62162448 100644
--- a/src/liblzma/rangecoder/range_decoder.h
+++ b/src/liblzma/rangecoder/range_decoder.h
@@ -121,26 +121,15 @@ do { \
} while (0)
-#ifdef HAVE_ARITHMETIC_RSHIFT
-# define rc_decode_direct(dest, count) \
- do { \
- rc_normalize(); \
- rc.range >>= 1; \
- rc.code -= rc.range; \
- rc_bound = (uint32_t)((int32_t)(rc.code) >> 31); \
- dest = (dest << 1) + (rc_bound + 1); \
- rc.code += rc.range & rc_bound; \
- } while (--count > 0)
-#else
-# define rc_decode_direct(dest, count) \
- do { \
- rc_normalize(); \
- rc.range >>= 1; \
- rc_bound = (rc.code - rc.range) >> 31; \
- rc.code -= rc.range & (rc_bound - 1); \
- dest = ((dest) << 1) | (1 - rc_bound);\
- } while (--count > 0)
-#endif
+#define rc_decode_direct(dest, count) \
+do { \
+ rc_normalize(); \
+ rc.range >>= 1; \
+ rc.code -= rc.range; \
+ rc_bound = UINT32_C(0) - (rc.code >> 31); \
+ rc.code += rc.range & rc_bound; \
+ dest = (dest << 1) + (rc_bound + 1); \
+} while (--count > 0)
// Dummy versions don't update prob or dest.
@@ -155,23 +144,13 @@ do { \
} while (0)
-#ifdef HAVE_ARITHMETIC_RSHIFT
-# define rc_decode_direct_dummy(count) \
- do { \
- rc_normalize(); \
- rc.range >>= 1; \
- rc.code -= rc.range; \
- rc.code += rc.range & ((uint32_t)((int32_t)(rc.code) >> 31)); \
- } while (--count > 0)
-#else
-# define rc_decode_direct_dummy(count) \
- do { \
- rc_normalize(); \
- rc.range >>= 1; \
- rc_bound = (rc.code - rc.range) >> 31; \
- rc.code -= rc.range & (rc_bound - 1); \
- } while (--count > 0)
-#endif
+#define rc_decode_direct_dummy(count) \
+do { \
+ rc_normalize(); \
+ rc.range >>= 1; \
+ rc.code -= rc.range; \
+ rc.code += rc.range & (UINT32_C(0) - (rc.code >> 31)); \
+} while (--count > 0)
///////////////////////