diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-04-30 07:43:26 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2011-04-30 08:34:16 +0200 |
commit | 85770f2a2651497861ed938efcd0df3696ff5e45 (patch) | |
tree | f94d28666962a9c2493ed5df4ff931ddc23b56c6 /libavutil | |
parent | 35ceaa737643008e89a9ba54aaa9ebc0b57683b4 (diff) | |
download | ffmpeg-85770f2a2651497861ed938efcd0df3696ff5e45.tar.gz |
AVOptions: make default_val a union, as proposed in AVOption2.
This breaks API and ABI.
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/opt.c | 23 | ||||
-rw-r--r-- | libavutil/opt.h | 54 |
2 files changed, 10 insertions, 67 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c index da7160145f..eeefe82c32 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -163,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; @@ -414,28 +414,19 @@ void av_opt_set_defaults2(void *s, int mask, int flags) /* Nothing to be done here */ break; case FF_OPT_TYPE_FLAGS: - case FF_OPT_TYPE_INT: { - int val; - val = opt->default_val; - av_set_int(s, opt->name, val); - } - break; + case FF_OPT_TYPE_INT: case FF_OPT_TYPE_INT64: - if ((double)(opt->default_val+0.6) == opt->default_val) - 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); - break; + av_set_int(s, opt->name, opt->default_val.i64); + 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); - av_set_q(s, opt->name, val); + av_set_q(s, opt->name, opt->default_val.q); } break; case FF_OPT_TYPE_STRING: diff --git a/libavutil/opt.h b/libavutil/opt.h index 3e61737dd4..0b6b91bdf1 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -64,69 +64,22 @@ typedef struct AVOption { /** * the default value for scalar options */ - double default_val; - double min; ///< minimum valid value for the option - double max; ///< maximum valid value for the option - - int flags; -#define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding -#define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding -#define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ... -#define AV_OPT_FLAG_AUDIO_PARAM 8 -#define AV_OPT_FLAG_VIDEO_PARAM 16 -#define AV_OPT_FLAG_SUBTITLE_PARAM 32 -//FIXME think about enc-audio, ... style flags - - /** - * The logical unit to which the option belongs. Non-constant - * options and corresponding named constants share the same - * unit. May be NULL. - */ - const char *unit; -} AVOption; - -/** - * AVOption2. - * THIS IS NOT PART OF THE API/ABI YET! - * This is identical to AVOption except that default_val was replaced by - * an union, it should be compatible with AVOption on normal platforms. - */ -typedef struct AVOption2 { - const char *name; - - /** - * short English help text - * @todo What about other languages? - */ - const char *help; - - /** - * The offset relative to the context structure where the option - * value is stored. It should be 0 for named constants. - */ - int offset; - enum AVOptionType type; - - /** - * the default value for scalar options - */ union { double dbl; const char *str; + int64_t i64; + AVRational q; } default_val; - double min; ///< minimum valid value for the option double max; ///< maximum valid value for the option int flags; -/* #define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding #define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding #define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ... #define AV_OPT_FLAG_AUDIO_PARAM 8 #define AV_OPT_FLAG_VIDEO_PARAM 16 #define AV_OPT_FLAG_SUBTITLE_PARAM 32 -*/ //FIXME think about enc-audio, ... style flags /** @@ -135,8 +88,7 @@ typedef struct AVOption2 { * unit. May be NULL. */ const char *unit; -} AVOption2; - +} AVOption; /** * Look for an option in obj. Look only for the options which |