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

Unified · Split

2 files
  1. cmdutils.c +1 −1
  2. libavutil/intfloat_readwrite.c +4 −4
cmdutils.c+1−1
@@ -198,7 +198,7 @@ unknown_opt: · 197 unmodified lines
198 } else if (po->flags & OPT_INT64) {198 } else if (po->flags & OPT_INT64) {
199 *po->u.int64_arg = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX);199 *po->u.int64_arg = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX);
200 } else if (po->flags & OPT_FLOAT) {200 } else if (po->flags & OPT_FLOAT) {
201 *po->u.float_arg = parse_number_or_die(opt, arg, OPT_FLOAT, -1.0/0.0, 1.0/0.0);201 *po->u.float_arg = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY);
202 } else if (po->flags & OPT_FUNC2) {202 } else if (po->flags & OPT_FUNC2) {
203 if (po->u.func2_arg(opt, arg) < 0) {203 if (po->u.func2_arg(opt, arg) < 0) {
204 fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg, opt);204 fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg, opt);
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