diff options
author | Grigori Goronzy <greg@blackbox> | 2010-01-06 23:51:01 +0100 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2010-01-07 09:05:15 +0100 |
commit | 7df7db97fdda2ea6f8617882cd5202575f44bfc5 (patch) | |
tree | 3323a1dd5e68c0be86bfdfb00d79ba4f6c8173b6 /libass/ass_utils.h | |
parent | 29fd817f4678ea7f674c7252ec84e87f4302c06a (diff) | |
download | libass-7df7db97fdda2ea6f8617882cd5202575f44bfc5.tar.bz2 libass-7df7db97fdda2ea6f8617882cd5202575f44bfc5.tar.xz |
Improve rotation cache accuracy
In some cases 16.16 precision is not good enough. Instead use 10.22 and
use modulo 360.0 on the angles to make overflows impossible and improve
cache hit ratio sometimes.
Diffstat (limited to 'libass/ass_utils.h')
-rw-r--r-- | libass/ass_utils.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libass/ass_utils.h b/libass/ass_utils.h index f5c68e96..ad8574c1 100644 --- a/libass/ass_utils.h +++ b/libass/ass_utils.h @@ -102,6 +102,21 @@ static inline int double_to_d16(double x) { return (int) (x * 0x10000); } +static inline double d22_to_double(int x) +{ + return ((double) x) / 0x400000; +} +static inline int double_to_d22(double x) +{ + return (int) (x * 0x400000); +} + +// Calculate cache key for a rotational angle in degrees +static inline int rot_key(double a) +{ + const int m = double_to_d22(360.0); + return double_to_d22(a) % m; +} #define FNV1_32A_INIT (unsigned)0x811c9dc5 |