diff options
author | Martin Storsjö <martin@martin.st> | 2012-08-31 13:45:52 +0400 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2012-09-05 00:13:32 +0400 |
commit | 124134e42455763b28cc346fed1d07017a76e84e (patch) | |
tree | eb006dffed0eeb3efeb048da00cae5636e69a700 /libavutil/opt.c | |
parent | 2d7d91f06d6a1d243dc74c96d3389ee237a3b906 (diff) |
avopt: Store defaults for AV_OPT_TYPE_CONST in the i64 union member
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r-- | libavutil/opt.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c index 0605ee105f..822e72b17a 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -160,7 +160,8 @@ 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) ? \ +#define DEFAULT_NUMVAL(opt) ((opt->type == AV_OPT_TYPE_INT64 || \ + opt->type == AV_OPT_TYPE_CONST) ? \ opt->default_val.i64 : opt->default_val.dbl) static int set_string_number(void *obj, const AVOption *o, const char *val, void *dst) @@ -544,7 +545,7 @@ int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name) if (!field || !flag || flag->type != AV_OPT_TYPE_CONST || av_opt_get_int(obj, field_name, 0, &res) < 0) return 0; - return res & (int) flag->default_val.dbl; + return res & flag->default_val.i64; } static void opt_list(void *obj, void *av_log_obj, const char *unit, @@ -858,9 +859,9 @@ static const AVOption test_options[]= { {"rational", "set rational", OFFSET(rational), AV_OPT_TYPE_RATIONAL, {0}, 0, 10 }, {"string", "set string", OFFSET(string), AV_OPT_TYPE_STRING, {0}, CHAR_MIN, CHAR_MAX }, {"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {0}, 0, INT_MAX, 0, "flags" }, -{"cool", "set cool flag ", 0, AV_OPT_TYPE_CONST, {TEST_FLAG_COOL}, INT_MIN, INT_MAX, 0, "flags" }, -{"lame", "set lame flag ", 0, AV_OPT_TYPE_CONST, {TEST_FLAG_LAME}, INT_MIN, INT_MAX, 0, "flags" }, -{"mu", "set mu flag ", 0, AV_OPT_TYPE_CONST, {TEST_FLAG_MU}, INT_MIN, INT_MAX, 0, "flags" }, +{"cool", "set cool flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_COOL}, INT_MIN, INT_MAX, 0, "flags" }, +{"lame", "set lame flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_LAME}, INT_MIN, INT_MAX, 0, "flags" }, +{"mu", "set mu flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_MU}, INT_MIN, INT_MAX, 0, "flags" }, {NULL}, }; |