History

Use INFINITY and NAN macros instead of 1/0 and 0/0

Mans Rullgard committed 16 years ago

Commit 324e7ee1 parent f318ee32 files · +5 −5Browse files

Showing the changes to libavutil/intfloat_readwrite.c (1 of 2 files). Show all

Unified · Split

libavutil/intfloat_readwrite.c+4−4
@@ -31,13 +31,13 @@ · 30 unmodified lines
31 31
32double av_int2dbl(int64_t v){32double av_int2dbl(int64_t v){
33 if(v+v > 0xFFEULL<<52)33 if(v+v > 0xFFEULL<<52)
34 return 0.0/0.0;34 return NAN;
35 return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1), (v>>52&0x7FF)-1075);35 return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1), (v>>52&0x7FF)-1075);
36}36}
37 37
38float av_int2flt(int32_t v){38float av_int2flt(int32_t v){
39 if(v+v > 0xFF000000U)39 if(v+v > 0xFF000000U)
40 return 0.0/0.0;40 return NAN;
41 return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150);41 return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150);
42}42}
43 43
@@ -49,7 +49,7 @@ double av_ext2dbl(const AVExtFloat ext){ · 5 unmodified lines
49 m = (m<<8) + ext.mantissa[i];49 m = (m<<8) + ext.mantissa[i];
50 e = (((int)ext.exponent[0]&0x7f)<<8) | ext.exponent[1];50 e = (((int)ext.exponent[0]&0x7f)<<8) | ext.exponent[1];
51 if (e == 0x7fff && m)51 if (e == 0x7fff && m)
52 return 0.0/0.0;52 return NAN;
53 e -= 16383 + 63; /* In IEEE 80 bits, the whole (i.e. 1.xxxx)53 e -= 16383 + 63; /* In IEEE 80 bits, the whole (i.e. 1.xxxx)
54 * mantissa bit is written as opposed to the54 * mantissa bit is written as opposed to the
55 * single and double precision formats. */55 * single and double precision formats. */
@@ -88,7 +88,7 @@ AVExtFloat av_dbl2ext(double d){ · 32 unmodified lines
88 ext.mantissa[i] = m>>(56-(i<<3));88 ext.mantissa[i] = m>>(56-(i<<3));
89 } else if (f != 0.0) {89 } else if (f != 0.0) {
90 ext.exponent[0] = 0x7f; ext.exponent[1] = 0xff;90 ext.exponent[0] = 0x7f; ext.exponent[1] = 0xff;
91 if (f != 1/0.0)91 if (f != INFINITY)
92 ext.mantissa[0] = ~0;92 ext.mantissa[0] = ~0;
93 }93 }
94 if (d < 0)94 if (d < 0)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t