History

Merge commit 'lukaszmluki/master^'

* commit 'lukaszmluki/master^': lavu/opt: extend AVOptionRange by extra values

Michael Niedermayer committed 12 years ago

Commit 09656702 parents f5d718a eaed4da4 files · +81 −10Browse files

Unified · Split

4 files
  1. doc/APIchanges +4 −0
  2. libavutil/opt.c +11 −3
  3. libavutil/opt.h +65 −6
  4. libavutil/version.h +1 −1
doc/APIchanges+4−0
@@ -15,6 +15,10 @@ libavutil: 2012-10-22 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2014-04-xx - xxxxxxx - lavu 52.72.100 - opt.h
19+ Add AV_OPT_MULTI_COMPONENT_RANGE define to allow return
20+ multi-component option ranges.
21+
1822 2014-03-xx - xxxxxxx - lavu 52.70.100 - mem.h
1923 Add av_dynarray_add_nofree() function.
2024
libavutil/opt.c+11−3
@@ -1514,6 +1514,7 @@ void *av_opt_ptr(const AVClass *class, void *obj, const char *name) · 1513 unmodified lines
15141514
15151515 int av_opt_query_ranges(AVOptionRanges **ranges_arg, void *obj, const char *key, int flags)
15161516 {
1517+ int ret;
15171518 const AVClass *c = *(AVClass**)obj;
15181519 int (*callback)(AVOptionRanges **, void *obj, const char *key, int flags) = NULL;
15191520
@@ -1523,7 +1524,13 @@ int av_opt_query_ranges(AVOptionRanges **ranges_arg, void *obj, const char *key, · 3 unmodified lines
15231524 if (!callback)
15241525 callback = av_opt_query_ranges_default;
15251526
1526− return callback(ranges_arg, obj, key, flags);
1527+ ret = callback(ranges_arg, obj, key, flags);
1528+ if (ret >= 0) {
1529+ if (!(flags & AV_OPT_MULTI_COMPONENT_RANGE))
1530+ ret = 1;
1531+ (*ranges_arg)->nb_components = ret;
1532+ }
1533+ return ret;
15271534 }
15281535
15291536 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 · 14 unmodified lines
15441551 ranges->range = range_array;
15451552 ranges->range[0] = range;
15461553 ranges->nb_ranges = 1;
1554+ ranges->nb_components = 1;
15471555 range->is_range = 1;
15481556 range->value_min = field->min;
15491557 range->value_max = field->max;
@@ -1587,7 +1595,7 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch · 37 unmodified lines
15871595 }
15881596
15891597 *ranges_arg = ranges;
1590− return 0;
1598+ return 1;
15911599 fail:
15921600 av_free(ranges);
15931601 av_free(range);
@@ -1600,7 +1608,7 @@ void av_opt_freep_ranges(AVOptionRanges **rangesp) · 6 unmodified lines
16001608 int i;
16011609 AVOptionRanges *ranges = *rangesp;
16021610
1603− for (i = 0; i < ranges->nb_ranges; i++) {
1611+ for (i = 0; i < ranges->nb_ranges * ranges->nb_components; i++) {
16041612 AVOptionRange *range = ranges->range[i];
16051613 av_freep(&range->str);
16061614 av_freep(&ranges->range[i]);
libavutil/opt.h+65−6
@@ -313,17 +313,67 @@ typedef struct AVOption { · 312 unmodified lines
313313 */
314314 typedef struct AVOptionRange {
315315 const char *str;
316− double value_min, value_max; ///< For string ranges this represents the min/max length, for dimensions this represents the min/max pixel count
317− double component_min, component_max; ///< For string this represents the unicode range for chars, 0-127 limits to ASCII
318− int is_range; ///< if set to 1 the struct encodes a range, if set to 0 a single value
316+ /**
317+ * Value range.
318+ * For string ranges this represents the min/max length.
319+ * For dimensions this represents the min/max pixel count or width/height in multi-component case.
320+ */
321+ double value_min, value_max;
322+ /**
323+ * Value's component range.
324+ * For string this represents the unicode range for chars, 0-127 limits to ASCII.
325+ */
326+ double component_min, component_max;
327+ /**
328+ * Range flag.
329+ * If set to 1 the struct encodes a range, if set to 0 a single value.
330+ */
331+ int is_range;
319332 } AVOptionRange;
320333
321334 /**
322− * List of AVOptionRange structs
335+ * List of AVOptionRange structs.
323336 */
324337 typedef struct AVOptionRanges {
338+ /**
339+ * Array of option ranges.
340+ *
341+ * Most of option types use just one component.
342+ * Following describes multi-component option types:
343+ *
344+ * AV_OPT_TYPE_IMAGE_SIZE:
345+ * component index 0: range of pixel count (width * height).
346+ * component index 1: range of width.
347+ * component index 2: range of height.
348+ *
349+ * @note To obtain multi-component version of this structure, user must
350+ * provide AV_OPT_MULTI_COMPONENT_RANGE to av_opt_query_ranges or
351+ * av_opt_query_ranges_default function.
352+ *
353+ * Multi-component range can be read as in following example:
354+ *
355+ * @code
356+ * int range_index, component_index;
357+ * AVOptionRanges *ranges;
358+ * AVOptionRange *range[3]; //may require more than 3 in the future.
359+ * av_opt_query_ranges(&ranges, obj, key, AV_OPT_MULTI_COMPONENT_RANGE);
360+ * for (range_index = 0; range_index < ranges->nb_ranges; range_index++) {
361+ * for (component_index = 0; component_index < ranges->nb_components; component_index++)
362+ * range[component_index] = ranges->range[ranges->nb_ranges * component_index + range_index];
363+ * //do something with range here.
364+ * }
365+ * av_opt_freep_ranges(&ranges);
366+ * @endcode
367+ */
325368 AVOptionRange **range;
369+ /**
370+ * Number of ranges per component.
371+ */
326372 int nb_ranges;
373+ /**
374+ * Number of componentes.
375+ */
376+ int nb_components;
327377 } AVOptionRanges;
328378
329379
@@ -558,6 +608,13 @@ int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational · 228 unmodified lines
558608 */
559609 #define AV_OPT_SEARCH_FAKE_OBJ 0x0002
560610
611+/**
612+ * Allows av_opt_query_ranges and av_opt_query_ranges_default to return more than
613+ * one component for certain option types.
614+ * @see AVOptionRanges for details.
615+ */
616+#define AV_OPT_MULTI_COMPONENT_RANGE 0x1000
617+
561618 /**
562619 * Look for an option in an object. Consider only options which
563620 * have all the specified flags set.
@@ -739,10 +796,11 @@ void av_opt_freep_ranges(AVOptionRanges **ranges); · 175 unmodified lines
739796 *
740797 * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
741798 * AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
799+ * AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
742800 *
743801 * The result must be freed with av_opt_freep_ranges.
744802 *
745− * @return >= 0 on success, a negative errro code otherwise
803+ * @return number of compontents returned on success, a negative errro code otherwise
746804 */
747805 int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags);
748806
@@ -754,10 +812,11 @@ int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags · 5 unmodified lines
754812 *
755813 * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
756814 * AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
815+ * AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
757816 *
758817 * The result must be freed with av_opt_free_ranges.
759818 *
760− * @return >= 0 on success, a negative errro code otherwise
819+ * @return number of compontents returned on success, a negative errro code otherwise
761820 */
762821 int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags);
763822
libavutil/version.h+1−1
@@ -56,7 +56,7 @@ · 55 unmodified lines
5656 */
5757
5858 #define LIBAVUTIL_VERSION_MAJOR 52
59−#define LIBAVUTIL_VERSION_MINOR 71
59+#define LIBAVUTIL_VERSION_MINOR 72
6060 #define LIBAVUTIL_VERSION_MICRO 100
6161
6262 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t