Go to the documentation of this file.
21 #ifndef AVUTIL_SOFTFLOAT_H
22 #define AVUTIL_SOFTFLOAT_H
60 while((
a.mant + 0x1FFFFFFFU)<0x3FFFFFFFU){
81 if((
int32_t)(
a.mant + 0x40000000U) <= 0){
89 int t=
a.mant + 0x40000000 < 0;
92 int t= (
a.mant + 0x3FFFFFFF
U)>>31;
121 while (
a.mant !=
temp) {
139 int t=
a.exp -
b.exp;
140 if (t <-31)
return -
b.mant ;
141 else if (t < 0)
return (
a.mant >> (-t)) -
b.mant ;
142 else if (t < 32)
return a.mant - (
b.mant >> t);
152 int t=
a.exp -
b.exp;
153 if (t <-31)
return 0 >
b.mant ;
154 else if (t < 0)
return (
a.mant >> (-t)) >
b.mant ;
155 else if (t < 32)
return a.mant > (
b.mant >> t);
156 else return a.mant > 0 ;
163 int t=
a.exp -
b.exp;
164 if (t <-31)
return b;
187 if(v <= INT_MIN + 1){
213 else if (
val.mant < 0)
217 tabIndex = (
val.mant - 0x20000000) >> 20;
219 rem =
val.mant & 0xFFFFF;
226 if (
val.mant < 0x40000000)
231 val.exp = (
val.exp >> 1) + 1;
251 sign = (
int32_t)((
unsigned)idx << 27) >> 31;
253 cv = (cv ^ sign) - sign;
256 sign = (
int32_t)((
unsigned)idx << 27) >> 31;
258 sv = (sv ^ sign) - sign;
264 idx = (int)(((
int64_t)cv * ct - (
int64_t)sv * st + 0x20000000) >> 30);
266 sv = (int)(((
int64_t)cv * st + (
int64_t)sv * ct + 0x20000000) >> 30);
274 idx = (int)(((
int64_t)cv * ct - (
int64_t)sv * st + 0x20000000) >> 30);
276 sv = (int)(((
int64_t)cv * st + (
int64_t)sv * ct + 0x20000000) >> 30);
static const SoftFloat FLOAT_EPSILON
A small value.
static const int32_t av_sqr_exp_multbl_sf[2]
static const SoftFloat FLOAT_05
0.5
static av_const SoftFloat av_sub_sf(SoftFloat a, SoftFloat b)
static const int32_t av_sintbl_3_sf[32]
static const SoftFloat FLOAT_1
1.0
static av_const int av_gt_sf(SoftFloat a, SoftFloat b)
Compares two SoftFloats.
static av_const int av_sf2int(SoftFloat v, int frac_bits)
Converts a SoftFloat to an integer.
static av_always_inline SoftFloat av_sqrt_sf(SoftFloat val)
Rounding-to-nearest used.
static av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b)
b has to be normalized and not zero.
static double val(void *priv, double ch)
static const SoftFloat FLOAT_MIN
static av_const double av_sf2double(SoftFloat v)
Convert a SoftFloat to a double precision float.
static const int32_t av_costbl_3_sf[32]
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static const SoftFloat FLOAT_0
0.0
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static const int32_t av_sintbl_4_sf[33]
static const int32_t av_costbl_1_sf[16]
static const SoftFloat FLOAT_0999999
0.999999
static const int32_t av_sintbl_2_sf[32]
static av_const int av_cmp_sf(SoftFloat a, SoftFloat b)
Compares two SoftFloats.
static const SoftFloat FLOAT_1584893192
1.584893192 (10^.2)
static const SoftFloat FLOAT_100000
100000
static av_const SoftFloat av_normalize_sf(SoftFloat a)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static av_const SoftFloat av_int2sf(int v, int frac_bits)
Converts a mantisse and exponent to a SoftFloat.
static const int32_t av_sqrttbl_sf[512+1]
static av_unused void av_sincos_sf(int a, int *s, int *c)
Rounding-to-nearest used.
static av_const SoftFloat av_add_sf(SoftFloat a, SoftFloat b)
static av_const SoftFloat av_normalize1_sf(SoftFloat a)
static const int32_t av_costbl_2_sf[32]
static const int32_t av_costbl_4_sf[33]
static av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b)