| @@ -313,17 +313,67 @@ typedef struct AVOption { · 312 unmodified lines |
| 313 | 313 | */ |
| 314 | 314 | typedef struct AVOptionRange { |
| 315 | 315 | 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; |
| 319 | 332 | } AVOptionRange; |
| 320 | 333 | |
| 321 | 334 | /** |
| 322 | | − * List of AVOptionRange structs |
| 335 | + * List of AVOptionRange structs. |
| 323 | 336 | */ |
| 324 | 337 | 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 | + */ |
| 325 | 368 | AVOptionRange **range; |
| 369 | + /** |
| 370 | + * Number of ranges per component. |
| 371 | + */ |
| 326 | 372 | int nb_ranges; |
| 373 | + /** |
| 374 | + * Number of componentes. |
| 375 | + */ |
| 376 | + int nb_components; |
| 327 | 377 | } AVOptionRanges; |
| 328 | 378 | |
| 329 | 379 | |
| @@ -558,6 +608,13 @@ int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational · 228 unmodified lines |
| 558 | 608 | */ |
| 559 | 609 | #define AV_OPT_SEARCH_FAKE_OBJ 0x0002 |
| 560 | 610 | |
| 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 | + |
| 561 | 618 | /** |
| 562 | 619 | * Look for an option in an object. Consider only options which |
| 563 | 620 | * have all the specified flags set. |
| @@ -739,10 +796,11 @@ void av_opt_freep_ranges(AVOptionRanges **ranges); · 175 unmodified lines |
| 739 | 796 | * |
| 740 | 797 | * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored |
| 741 | 798 | * 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 |
| 742 | 800 | * |
| 743 | 801 | * The result must be freed with av_opt_freep_ranges. |
| 744 | 802 | * |
| 745 | | − * @return >= 0 on success, a negative errro code otherwise |
| 803 | + * @return number of compontents returned on success, a negative errro code otherwise |
| 746 | 804 | */ |
| 747 | 805 | int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags); |
| 748 | 806 | |
| @@ -754,10 +812,11 @@ int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags · 5 unmodified lines |
| 754 | 812 | * |
| 755 | 813 | * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored |
| 756 | 814 | * 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 |
| 757 | 816 | * |
| 758 | 817 | * The result must be freed with av_opt_free_ranges. |
| 759 | 818 | * |
| 760 | | − * @return >= 0 on success, a negative errro code otherwise |
| 819 | + * @return number of compontents returned on success, a negative errro code otherwise |
| 761 | 820 | */ |
| 762 | 821 | int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags); |
| 763 | 822 | |