diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-04-09 20:55:09 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-04-09 20:55:09 +0200 |
commit | 3532a87a25a8f034dabddfd00927611fc855669c (patch) | |
tree | 1f47ac8fa1c2ed0bd77b4d5d580befab3c45a2e1 /libavcodec/exr.c | |
parent | cabc0ac72f668be07f82c24aa4d3a4c964cb4c71 (diff) | |
download | ffmpeg-3532a87a25a8f034dabddfd00927611fc855669c.tar.gz |
exr: optimize exr_halflt2uint()
30% faster
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/exr.c')
-rw-r--r-- | libavcodec/exr.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/libavcodec/exr.c b/libavcodec/exr.c index a37bebf27a..c8f2b9ad75 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -77,15 +77,13 @@ static inline uint16_t exr_flt2uint(uint32_t v) */ static inline uint16_t exr_halflt2uint(uint16_t v) { - int exp = v >> 10; - if (v & 0x8000) - return 0; - if (!exp) - return (v >> 9) & 1; - if (exp >= 15) - return 0xffff; + unsigned exp = 14 - (v >> 10); + if (exp >= 14) { + if (exp == 14) return (v >> 9) & 1; + else return (v & 0x8000) ? 0 : 0xffff; + } v <<= 6; - return (v + (1 << 16)) >> (15 - exp); + return (v + (1 << 16)) >> (exp + 1); } /** |