diff options
author | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-12-15 23:44:54 -0500 |
---|---|---|
committer | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-12-16 07:57:26 -0500 |
commit | 83a04f103d387a8b7f574d97d340d90f42fc18de (patch) | |
tree | 740d3c0f8089daa3a5742d0bd7020259e4a401ad /libavcodec/internal.h | |
parent | 4fa6f09c2c024cb6a9697d2d63b0be04a0630267 (diff) |
lavc: move exp2fi to ff_exp2fi in internal.h
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Diffstat (limited to 'libavcodec/internal.h')
-rw-r--r-- | libavcodec/internal.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 445b45ad91..afcf00d013 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -242,6 +242,25 @@ static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, } /** + * 2^(x) for integer x + * @return correctly rounded float + */ +static av_always_inline float ff_exp2fi(int x) { + /* Normal range */ + if (-126 <= x && x <= 128) + return av_int2float(x+127 << 23); + /* Too large */ + else if (x > 128) + return INFINITY; + /* Subnormal numbers */ + else if (x > -150) + return av_int2float(1 << (x+149)); + /* Negligibly small */ + else + return 0; +} + +/** * Get a buffer for a frame. This is a wrapper around * AVCodecContext.get_buffer() and should be used instead calling get_buffer() * directly. |