From 641998c3e1ecc8b598fe0eb051fab8b9535c291b Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Mon, 24 Mar 2008 16:38:40 +0200 Subject: 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. --- src/liblzma/rangecoder/range_decoder.h | 53 ++++++++++------------------------ 1 file changed, 16 insertions(+), 37 deletions(-) (limited to 'src/liblzma/rangecoder') 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) /////////////////////// -- cgit v1.2.3