Commit a1c7fe43 authored by Nedeljko Babic's avatar Nedeljko Babic Committed by Michael Niedermayer

libavutil/softfloat: exponent adjusted for aac fixed point dec

Exponent usage and calculation in softfloat adjusted to the format used in
implementation of fixed point aac decoder.
Signed-off-by: 's avatarNedeljko Babic <nedeljko.babic@imgtec.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent d2184bf3
...@@ -83,7 +83,7 @@ static inline av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b){ ...@@ -83,7 +83,7 @@ static inline av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b){
a.exp += b.exp; a.exp += b.exp;
av_assert2((int32_t)((a.mant * (int64_t)b.mant) >> ONE_BITS) == (a.mant * (int64_t)b.mant) >> ONE_BITS); av_assert2((int32_t)((a.mant * (int64_t)b.mant) >> ONE_BITS) == (a.mant * (int64_t)b.mant) >> ONE_BITS);
a.mant = (a.mant * (int64_t)b.mant) >> ONE_BITS; a.mant = (a.mant * (int64_t)b.mant) >> ONE_BITS;
return av_normalize1_sf(a); return av_normalize1_sf((SoftFloat){a.mant, a.exp - 1});
} }
/** /**
...@@ -91,7 +91,7 @@ static inline av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b){ ...@@ -91,7 +91,7 @@ static inline av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b){
* @return Will not be more denormalized than a. * @return Will not be more denormalized than a.
*/ */
static av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){ static av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){
a.exp -= b.exp+1; a.exp -= b.exp;
a.mant = ((int64_t)a.mant<<(ONE_BITS+1)) / b.mant; a.mant = ((int64_t)a.mant<<(ONE_BITS+1)) / b.mant;
return av_normalize1_sf(a); return av_normalize1_sf(a);
} }
...@@ -121,14 +121,14 @@ static inline av_const SoftFloat av_sub_sf(SoftFloat a, SoftFloat b){ ...@@ -121,14 +121,14 @@ static inline av_const SoftFloat av_sub_sf(SoftFloat a, SoftFloat b){
* @returns a SoftFloat with value v * 2^frac_bits * @returns a SoftFloat with value v * 2^frac_bits
*/ */
static inline av_const SoftFloat av_int2sf(int v, int frac_bits){ static inline av_const SoftFloat av_int2sf(int v, int frac_bits){
return av_normalize_sf((SoftFloat){v, ONE_BITS-frac_bits}); return av_normalize_sf((SoftFloat){v, ONE_BITS + 1 - frac_bits});
} }
/** /**
* Rounding is to -inf. * Rounding is to -inf.
*/ */
static inline av_const int av_sf2int(SoftFloat v, int frac_bits){ static inline av_const int av_sf2int(SoftFloat v, int frac_bits){
v.exp += frac_bits - ONE_BITS; v.exp += frac_bits - (ONE_BITS + 1);
if(v.exp >= 0) return v.mant << v.exp ; if(v.exp >= 0) return v.mant << v.exp ;
else return v.mant >>(-v.exp); else return v.mant >>(-v.exp);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment