*/
static inline av_const double av_sf2double(SoftFloat v) {
v.exp -= ONE_BITS +1;
- if(v.exp > 0) return (double)v.mant * (double)(1 << v.exp);
- else return (double)v.mant / (double)(1 << (-v.exp));
+ return ldexp(v.mant, v.exp);
}
static av_const SoftFloat av_normalize_sf(SoftFloat a){
* @return Will not be more denormalized than a.
*/
static inline av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){
+ int64_t temp = (int64_t)a.mant * (1<<(ONE_BITS+1));
+ temp /= b.mant;
a.exp -= b.exp;
- a.mant = ((int64_t)a.mant<<(ONE_BITS+1)) / b.mant;
+ a.mant = temp;
+ while (a.mant != temp) {
+ temp /= 2;
+ a.exp--;
+ a.mant = temp;
+ }
a = av_normalize1_sf(a);
if (!a.mant || a.exp < MIN_EXP)
return FLOAT_0;
int st, ct;
idx = a >> 26;
- sign = (idx << 27) >> 31;
+ sign = (int32_t)((unsigned)idx << 27) >> 31;
cv = av_costbl_1_sf[idx & 0xf];
cv = (cv ^ sign) - sign;
idx -= 8;
- sign = (idx << 27) >> 31;
+ sign = (int32_t)((unsigned)idx << 27) >> 31;
sv = av_costbl_1_sf[idx & 0xf];
sv = (sv ^ sign) - sign;