mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
Take advantage of arithmetic right shift in range decoder.
This commit is contained in:
parent
03e0e8a0d7
commit
ad999efd27
1 changed files with 37 additions and 15 deletions
|
@ -121,6 +121,17 @@ do { \
|
||||||
} while (0)
|
} 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) \
|
# define rc_decode_direct(dest, count) \
|
||||||
do { \
|
do { \
|
||||||
rc_normalize(); \
|
rc_normalize(); \
|
||||||
|
@ -129,6 +140,7 @@ do { \
|
||||||
rc.code -= rc.range & (rc_bound - 1); \
|
rc.code -= rc.range & (rc_bound - 1); \
|
||||||
dest = ((dest) << 1) | (1 - rc_bound);\
|
dest = ((dest) << 1) | (1 - rc_bound);\
|
||||||
} while (--count > 0)
|
} while (--count > 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Dummy versions don't update prob or dest.
|
// Dummy versions don't update prob or dest.
|
||||||
|
@ -143,6 +155,15 @@ do { \
|
||||||
} while (0)
|
} 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) \
|
# define rc_decode_direct_dummy(count) \
|
||||||
do { \
|
do { \
|
||||||
rc_normalize(); \
|
rc_normalize(); \
|
||||||
|
@ -150,6 +171,7 @@ do { \
|
||||||
rc_bound = (rc.code - rc.range) >> 31; \
|
rc_bound = (rc.code - rc.range) >> 31; \
|
||||||
rc.code -= rc.range & (rc_bound - 1); \
|
rc.code -= rc.range & (rc_bound - 1); \
|
||||||
} while (--count > 0)
|
} while (--count > 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
|
|
Loading…
Reference in a new issue