summaryrefslogtreecommitdiff
path: root/libavutil/opt.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-08-22 10:07:54 +0200
committerAnton Khirnov <anton@khirnov.net>2012-08-24 11:25:06 +0200
commit4d7adec8bd211d3900563955f2e0863dfb3bf7e8 (patch)
tree687edf41d6843d819ae6eec8f7bfcbed6d8bf415 /libavutil/opt.c
parenta1bcc76e6036e78f25cbb7323c145056cfca9d93 (diff)
AVOptions: store defaults for INT64 options in int64 union member.
Double does not have enough precision to represent all int64 numbers exactly.
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r--libavutil/opt.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c
index 607f7e6fd4..0605ee105f 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -160,6 +160,9 @@ static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **d
return 0;
}
+#define DEFAULT_NUMVAL(opt) ((opt->type == AV_OPT_TYPE_INT64) ? \
+ opt->default_val.i64 : opt->default_val.dbl)
+
static int set_string_number(void *obj, const AVOption *o, const char *val, void *dst)
{
int ret = 0, notfirst = 0;
@@ -180,8 +183,8 @@ static int set_string_number(void *obj, const AVOption *o, const char *val, void
{
const AVOption *o_named = av_opt_find(obj, buf, o->unit, 0, 0);
if (o_named && o_named->type == AV_OPT_TYPE_CONST)
- d = o_named->default_val.dbl;
- else if (!strcmp(buf, "default")) d = o->default_val.dbl;
+ d = DEFAULT_NUMVAL(o_named);
+ else if (!strcmp(buf, "default")) d = DEFAULT_NUMVAL(o);
else if (!strcmp(buf, "max" )) d = o->max;
else if (!strcmp(buf, "min" )) d = o->min;
else if (!strcmp(buf, "none" )) d = 0;
@@ -652,9 +655,7 @@ void av_opt_set_defaults2(void *s, int mask, int flags)
}
break;
case AV_OPT_TYPE_INT64:
- if ((double)(opt->default_val.dbl+0.6) == opt->default_val.dbl)
- av_log(s, AV_LOG_DEBUG, "loss of precision in default of %s\n", opt->name);
- av_opt_set_int(s, opt->name, opt->default_val.dbl, 0);
+ av_opt_set_int(s, opt->name, opt->default_val.i64, 0);
break;
case AV_OPT_TYPE_DOUBLE:
case AV_OPT_TYPE_FLOAT: {