diff options
author | Lukasz Marek <lukasz.m.luki@gmail.com> | 2014-03-30 15:09:10 +0200 |
---|---|---|
committer | Lukasz Marek <lukasz.m.luki@gmail.com> | 2014-04-03 13:28:13 +0200 |
commit | eaed4da96ac6da54313b35a8567ebf415e6df4cf (patch) | |
tree | 161522138a9015330ca0550d6a7d367496544c1d /libavutil/opt.c | |
parent | fd2bcfc4d6967588168443849b9bc365c78bb9af (diff) | |
download | ffmpeg-eaed4da96ac6da54313b35a8567ebf415e6df4cf.tar.gz |
lavu/opt: extend AVOptionRange by extra values
AVOptionRange is not flexible enough to store AV_OPT_TYPE_IMAGE_SIZE
ranges. Current implementation can only store pixel count.
This patch aims to keep backward compatibility and extend
AVOptionRange with possibility to store width/height ranges.
Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r-- | libavutil/opt.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c index 428c4e5839..cffa5a6a24 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1514,6 +1514,7 @@ void *av_opt_ptr(const AVClass *class, void *obj, const char *name) int av_opt_query_ranges(AVOptionRanges **ranges_arg, void *obj, const char *key, int flags) { + int ret; const AVClass *c = *(AVClass**)obj; int (*callback)(AVOptionRanges **, void *obj, const char *key, int flags) = NULL; @@ -1523,7 +1524,13 @@ int av_opt_query_ranges(AVOptionRanges **ranges_arg, void *obj, const char *key, if (!callback) callback = av_opt_query_ranges_default; - return callback(ranges_arg, obj, key, flags); + ret = callback(ranges_arg, obj, key, flags); + if (ret >= 0) { + if (!(flags & AV_OPT_MULTI_COMPONENT_RANGE)) + ret = 1; + (*ranges_arg)->nb_components = ret; + } + return ret; } int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const char *key, int flags) @@ -1544,6 +1551,7 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch ranges->range = range_array; ranges->range[0] = range; ranges->nb_ranges = 1; + ranges->nb_components = 1; range->is_range = 1; range->value_min = field->min; range->value_max = field->max; @@ -1587,7 +1595,7 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch } *ranges_arg = ranges; - return 0; + return 1; fail: av_free(ranges); av_free(range); @@ -1600,7 +1608,7 @@ void av_opt_freep_ranges(AVOptionRanges **rangesp) int i; AVOptionRanges *ranges = *rangesp; - for (i = 0; i < ranges->nb_ranges; i++) { + for (i = 0; i < ranges->nb_ranges * ranges->nb_components; i++) { AVOptionRange *range = ranges->range[i]; av_freep(&range->str); av_freep(&ranges->range[i]); |