mirror of https://git.ffmpeg.org/ffmpeg.git
AAC: IEEE-754 type punning for 16-bit floating point rounding.
Originally committed as revision 18015 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
508fe07ab3
commit
4a39ccb403
|
@ -93,6 +93,8 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
union float754 { float f; uint32_t i; };
|
||||||
|
|
||||||
static VLC vlc_scalefactors;
|
static VLC vlc_scalefactors;
|
||||||
static VLC vlc_spectral[11];
|
static VLC vlc_spectral[11];
|
||||||
|
|
||||||
|
@ -930,24 +932,24 @@ static int decode_spectrum_and_dequant(AACContext * ac, float coef[1024], GetBit
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline float flt16_round(float pf) {
|
static av_always_inline float flt16_round(float pf) {
|
||||||
int exp;
|
union float754 tmp;
|
||||||
pf = frexpf(pf, &exp);
|
tmp.f = pf;
|
||||||
pf = ldexpf(roundf(ldexpf(pf, 8)), exp-8);
|
tmp.i = (tmp.i + 0x00008000U) & 0xFFFF0000U;
|
||||||
return pf;
|
return tmp.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline float flt16_even(float pf) {
|
static av_always_inline float flt16_even(float pf) {
|
||||||
int exp;
|
union float754 tmp;
|
||||||
pf = frexpf(pf, &exp);
|
tmp.f = pf;
|
||||||
pf = ldexpf(rintf(ldexpf(pf, 8)), exp-8);
|
tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U>>16)) & 0xFFFF0000U;
|
||||||
return pf;
|
return tmp.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline float flt16_trunc(float pf) {
|
static av_always_inline float flt16_trunc(float pf) {
|
||||||
int exp;
|
union float754 pun;
|
||||||
pf = frexpf(pf, &exp);
|
pun.f = pf;
|
||||||
pf = ldexpf(truncf(ldexpf(pf, 8)), exp-8);
|
pun.i &= 0xFFFF0000U;
|
||||||
return pf;
|
return pun.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void predict(AACContext * ac, PredictorState * ps, float* coef, int output_enable) {
|
static void predict(AACContext * ac, PredictorState * ps, float* coef, int output_enable) {
|
||||||
|
|
Loading…
Reference in New Issue