aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/opt.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-05-01 00:21:56 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-05-01 00:26:05 +0200
commitffb5a0d533498102c31aa131bc91a4cce868b0a8 (patch)
tree1c78494488bab5bafa3bda2ab20295f13860fc2e /libavutil/opt.c
parent1a9f9f81b1244b952126bb65bc741b04d3534f81 (diff)
parent85770f2a2651497861ed938efcd0df3696ff5e45 (diff)
downloadffmpeg-ffb5a0d533498102c31aa131bc91a4cce868b0a8.tar.gz
Merge commit '85770f2a2651497861ed938efcd0df3696ff5e45'
* commit '85770f2a2651497861ed938efcd0df3696ff5e45': AVOptions: make default_val a union, as proposed in AVOption2. Move ff_dynarray_add to lavu and make it public. lavf: remove duplicate assignment in avformat_alloc_context. lavf: use designated initializers for AVClasses. options: simplify av_find_opt by using av_next_option. Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r--libavutil/opt.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c
index e6cf34081c..5705b40490 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -33,10 +33,9 @@
//FIXME order them and do a bin search
const AVOption *av_find_opt(void *v, const char *name, const char *unit, int mask, int flags)
{
- AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass
- const AVOption *o= c->option;
+ const AVOption *o = NULL;
- for (; o && o->name; o++) {
+ while ((o = av_next_option(v, o))) {
if (!strcmp(o->name, name) && (!unit || (o->unit && !strcmp(o->unit, unit))) && (o->flags & mask) == flags)
return o;
}
@@ -164,8 +163,8 @@ int av_set_string3(void *obj, const char *name, const char *val, int alloc, cons
{
const AVOption *o_named= av_find_opt(obj, buf, o->unit, 0, 0);
if (o_named && o_named->type == FF_OPT_TYPE_CONST)
- d= o_named->default_val;
- else if (!strcmp(buf, "default")) d= o->default_val;
+ d= o_named->default_val.dbl;
+ else if (!strcmp(buf, "default")) d= o->default_val.dbl;
else if (!strcmp(buf, "max" )) d= o->max;
else if (!strcmp(buf, "min" )) d= o->min;
else if (!strcmp(buf, "none" )) d= 0;
@@ -417,25 +416,25 @@ void av_opt_set_defaults2(void *s, int mask, int flags)
case FF_OPT_TYPE_FLAGS:
case FF_OPT_TYPE_INT: {
int val;
- val = opt->default_val;
+ val = opt->default_val.dbl;
av_set_int(s, opt->name, val);
}
break;
case FF_OPT_TYPE_INT64:
- if ((double)(opt->default_val+0.6) == opt->default_val)
+ 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_set_int(s, opt->name, opt->default_val);
+ av_set_int(s, opt->name, opt->default_val.dbl);
break;
case FF_OPT_TYPE_DOUBLE:
case FF_OPT_TYPE_FLOAT: {
double val;
- val = opt->default_val;
+ val = opt->default_val.dbl;
av_set_double(s, opt->name, val);
}
break;
case FF_OPT_TYPE_RATIONAL: {
AVRational val;
- val = av_d2q(opt->default_val, INT_MAX);
+ val = av_d2q(opt->default_val.dbl, INT_MAX);
av_set_q(s, opt->name, val);
}
break;