35 double av_int2dbl(int64_t
v){
36 if((uint64_t)v+v > 0xFFEULL<<52)
38 return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1), (v>>52&0x7FF)-1075);
42 if((uint32_t)v+v > 0xFF000000U)
44 return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150);
47 double av_ext2dbl(
const AVExtFloat ext){
51 for (i = 0; i < 8; i++)
52 m = (m<<8) + ext.mantissa[
i];
53 e = (((int)ext.exponent[0]&0x7f)<<8) | ext.exponent[1];
59 if (ext.exponent[0]&0x80)
64 int64_t av_dbl2int(
double d){
67 else if(d-d)
return 0x7FF0000000000000LL + ((int64_t)(d<0)<<63) + (d!=d);
69 return (int64_t)(d<0)<<63 | (e+1022LL)<<52 | (int64_t)((fabs(d)-0.5)*(1LL<<53));
75 else if(d-d)
return 0x7F800000 + ((d<0)<<31) + (d!=d);
77 return (d<0)<<31 | (e+126)<<23 | (int64_t)((fabs(d)-0.5)*(1<<24));
80 AVExtFloat av_dbl2ext(
double d){
81 struct AVExtFloat ext= {{0}};
82 int e, i;
double f; uint64_t
m;
84 f = fabs(frexp(d, &e));
85 if (f >= 0.5 && f < 1) {
87 ext.exponent[0] = e>>8;
89 m = (uint64_t)ldexp(f, 64);
91 ext.mantissa[i] = m>>(56-(i<<3));
92 }
else if (f != 0.0) {
93 ext.exponent[0] = 0x7f; ext.exponent[1] = 0xff;
98 ext.exponent[0] |= 0x80;