Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Marek <lukasz.m.luki@gmail.com>2014-03-30 17:09:10 +0400
committerLukasz Marek <lukasz.m.luki@gmail.com>2014-04-03 15:28:13 +0400
commiteaed4da96ac6da54313b35a8567ebf415e6df4cf (patch)
tree161522138a9015330ca0550d6a7d367496544c1d /libavutil/opt.h
parentfd2bcfc4d6967588168443849b9bc365c78bb9af (diff)
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.h')
-rw-r--r--libavutil/opt.h71
1 files changed, 65 insertions, 6 deletions
diff --git a/libavutil/opt.h b/libavutil/opt.h
index cd1b18e4c0..6a1ae4354a 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -313,17 +313,67 @@ typedef struct AVOption {
*/
typedef struct AVOptionRange {
const char *str;
- double value_min, value_max; ///< For string ranges this represents the min/max length, for dimensions this represents the min/max pixel count
- double component_min, component_max; ///< For string this represents the unicode range for chars, 0-127 limits to ASCII
- int is_range; ///< if set to 1 the struct encodes a range, if set to 0 a single value
+ /**
+ * Value range.
+ * For string ranges this represents the min/max length.
+ * For dimensions this represents the min/max pixel count or width/height in multi-component case.
+ */
+ double value_min, value_max;
+ /**
+ * Value's component range.
+ * For string this represents the unicode range for chars, 0-127 limits to ASCII.
+ */
+ double component_min, component_max;
+ /**
+ * Range flag.
+ * If set to 1 the struct encodes a range, if set to 0 a single value.
+ */
+ int is_range;
} AVOptionRange;
/**
- * List of AVOptionRange structs
+ * List of AVOptionRange structs.
*/
typedef struct AVOptionRanges {
+ /**
+ * Array of option ranges.
+ *
+ * Most of option types use just one component.
+ * Following describes multi-component option types:
+ *
+ * AV_OPT_TYPE_IMAGE_SIZE:
+ * component index 0: range of pixel count (width * height).
+ * component index 1: range of width.
+ * component index 2: range of height.
+ *
+ * @note To obtain multi-component version of this structure, user must
+ * provide AV_OPT_MULTI_COMPONENT_RANGE to av_opt_query_ranges or
+ * av_opt_query_ranges_default function.
+ *
+ * Multi-component range can be read as in following example:
+ *
+ * @code
+ * int range_index, component_index;
+ * AVOptionRanges *ranges;
+ * AVOptionRange *range[3]; //may require more than 3 in the future.
+ * av_opt_query_ranges(&ranges, obj, key, AV_OPT_MULTI_COMPONENT_RANGE);
+ * for (range_index = 0; range_index < ranges->nb_ranges; range_index++) {
+ * for (component_index = 0; component_index < ranges->nb_components; component_index++)
+ * range[component_index] = ranges->range[ranges->nb_ranges * component_index + range_index];
+ * //do something with range here.
+ * }
+ * av_opt_freep_ranges(&ranges);
+ * @endcode
+ */
AVOptionRange **range;
+ /**
+ * Number of ranges per component.
+ */
int nb_ranges;
+ /**
+ * Number of componentes.
+ */
+ int nb_components;
} AVOptionRanges;
@@ -559,6 +609,13 @@ int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational
#define AV_OPT_SEARCH_FAKE_OBJ 0x0002
/**
+ * Allows av_opt_query_ranges and av_opt_query_ranges_default to return more than
+ * one component for certain option types.
+ * @see AVOptionRanges for details.
+ */
+#define AV_OPT_MULTI_COMPONENT_RANGE 0x1000
+
+/**
* Look for an option in an object. Consider only options which
* have all the specified flags set.
*
@@ -739,10 +796,11 @@ void av_opt_freep_ranges(AVOptionRanges **ranges);
*
* @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
* AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
+ * AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
*
* The result must be freed with av_opt_freep_ranges.
*
- * @return >= 0 on success, a negative errro code otherwise
+ * @return number of compontents returned on success, a negative errro code otherwise
*/
int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags);
@@ -754,10 +812,11 @@ int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags
*
* @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
* AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
+ * AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
*
* The result must be freed with av_opt_free_ranges.
*
- * @return >= 0 on success, a negative errro code otherwise
+ * @return number of compontents returned on success, a negative errro code otherwise
*/
int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags);