1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

lavc: move exp2fi to ff_exp2fi in internal.h

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
This commit is contained in:
Ganesh Ajjanagadde 2015-12-15 23:44:54 -05:00
parent 4fa6f09c2c
commit 83a04f103d
2 changed files with 21 additions and 16 deletions

View File

@ -241,6 +241,25 @@ static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx,
avctx->time_base); avctx->time_base);
} }
/**
* 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 * Get a buffer for a frame. This is a wrapper around
* AVCodecContext.get_buffer() and should be used instead calling get_buffer() * AVCodecContext.get_buffer() and should be used instead calling get_buffer()

View File

@ -31,6 +31,7 @@
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "libavutil/mem.h" #include "libavutil/mem.h"
#include "avcodec.h" #include "avcodec.h"
#include "internal.h"
#include "jpeg2000.h" #include "jpeg2000.h"
#define SHL(a, n) ((n) >= 0 ? (a) << (n) : (a) >> -(n)) #define SHL(a, n) ((n) >= 0 ? (a) << (n) : (a) >> -(n))
@ -192,21 +193,6 @@ void ff_jpeg2000_set_significance(Jpeg2000T1Context *t1, int x, int y,
// static const uint8_t lut_gain[2][4] = { { 0, 0, 0, 0 }, { 0, 1, 1, 2 } }; (unused) // static const uint8_t lut_gain[2][4] = { { 0, 0, 0, 0 }, { 0, 1, 1, 2 } }; (unused)
static inline float 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;
}
static void init_band_stepsize(AVCodecContext *avctx, static void init_band_stepsize(AVCodecContext *avctx,
Jpeg2000Band *band, Jpeg2000Band *band,
Jpeg2000CodingStyle *codsty, Jpeg2000CodingStyle *codsty,
@ -236,7 +222,7 @@ static void init_band_stepsize(AVCodecContext *avctx,
* R_b = R_I + log2 (gain_b ) * R_b = R_I + log2 (gain_b )
* see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */ * see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */
gain = cbps; gain = cbps;
band->f_stepsize = exp2fi(gain - qntsty->expn[gbandno]); band->f_stepsize = ff_exp2fi(gain - qntsty->expn[gbandno]);
band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0; band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0;
break; break;
default: default: