[FFmpeg-devel] [PATCH 4/8] lavu/opt: extend AVOptionRange by second value

Lukasz Marek lukasz.m.luki at gmail.com
Sat Feb 22 23:33:38 CET 2014


TODO: micro bump?

Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
---
 libavutil/opt.c | 20 ++++++++++----------
 libavutil/opt.h | 17 ++++++++++++++---
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index bff3b6e..9a77119 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1063,9 +1063,9 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit,
             case AV_OPT_TYPE_RATIONAL:
                 for (i = 0; i < r->nb_ranges; i++) {
                     av_log(av_log_obj, AV_LOG_INFO, " (from ");
-                    log_value(av_log_obj, AV_LOG_INFO, r->range[i]->value_min);
+                    log_value(av_log_obj, AV_LOG_INFO, r->range[i]->value_min[0]);
                     av_log(av_log_obj, AV_LOG_INFO, " to ");
-                    log_value(av_log_obj, AV_LOG_INFO, r->range[i]->value_max);
+                    log_value(av_log_obj, AV_LOG_INFO, r->range[i]->value_max[0]);
                     av_log(av_log_obj, AV_LOG_INFO, ")");
                 }
                 break;
@@ -1536,8 +1536,8 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch
     ranges->range[0] = range;
     ranges->nb_ranges = 1;
     range->is_range = 1;
-    range->value_min = field->min;
-    range->value_max = field->max;
+    range->value_min[0] = field->min;
+    range->value_max[0] = field->max;
 
     switch (field->type) {
     case AV_OPT_TYPE_INT:
@@ -1553,8 +1553,8 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch
     case AV_OPT_TYPE_STRING:
         range->component_min = 0;
         range->component_max = 0x10FFFF; // max unicode value
-        range->value_min = -1;
-        range->value_max = INT_MAX;
+        range->value_min[0] = -1;
+        range->value_max[0] = INT_MAX;
         break;
     case AV_OPT_TYPE_RATIONAL:
         range->component_min = INT_MIN;
@@ -1563,14 +1563,14 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch
     case AV_OPT_TYPE_IMAGE_SIZE:
         range->component_min = 0;
         range->component_max = INT_MAX/128/8;
-        range->value_min = 0;
-        range->value_max = INT_MAX/8;
+        range->value_min[0] = range->value_min[1] = 0;
+        range->value_max[0] = range->value_max[1] = INT_MAX/8;
         break;
     case AV_OPT_TYPE_VIDEO_RATE:
         range->component_min = 1;
         range->component_max = INT_MAX;
-        range->value_min = 1;
-        range->value_max = INT_MAX;
+        range->value_min[0] = 1;
+        range->value_max[0] = INT_MAX;
         break;
     default:
         ret = AVERROR(ENOSYS);
diff --git a/libavutil/opt.h b/libavutil/opt.h
index cd1b18e..409776e 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -313,9 +313,20 @@ 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
+    /**
+     * AV_OPT_TYPE_IMAGE_SIZE options use both elements to represent width and height ranges.
+     * Other options uses only first elements.
+     * For string ranges first elements represent the min/max length.
+     */
+    double value_min[2], value_max[2];
+    /**
+     * For string this represents the unicode range for chars, 0-127 limits to ASCII
+     */
+    double component_min, component_max;
+    /**
+     * If set to 1 the struct encodes a range, if set to 0 a single value
+     */
+    int is_range;
 } AVOptionRange;
 
 /**
-- 
1.8.3.2



More information about the ffmpeg-devel mailing list