283
275
#define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding
284
276
#define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding
277
#if FF_API_OPT_TYPE_METADATA
285
278
#define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ...
286
280
#define AV_OPT_FLAG_AUDIO_PARAM 8
287
281
#define AV_OPT_FLAG_VIDEO_PARAM 16
288
282
#define AV_OPT_FLAG_SUBTITLE_PARAM 32
284
* The option is inteded for exporting values to the caller.
286
#define AV_OPT_FLAG_EXPORT 64
288
* The option may not be set through the AVOptions API, only read.
289
* This flag only makes sense when AV_OPT_FLAG_EXPORT is also set.
291
#define AV_OPT_FLAG_READONLY 128
289
292
#define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering
290
293
//FIXME think about enc-audio, ... style flags
303
306
typedef struct AVOptionRange {
305
double value_min, value_max; ///< For string ranges this represents the min/max length, for dimensions this represents the min/max pixel count
306
double component_min, component_max; ///< For string this represents the unicode range for chars, 0-127 limits to ASCII
307
int is_range; ///< if set to 1 the struct encodes a range, if set to 0 a single value
310
* For string ranges this represents the min/max length.
311
* For dimensions this represents the min/max pixel count or width/height in multi-component case.
313
double value_min, value_max;
315
* Value's component range.
316
* For string this represents the unicode range for chars, 0-127 limits to ASCII.
318
double component_min, component_max;
321
* If set to 1 the struct encodes a range, if set to 0 a single value.
311
* List of AVOptionRange structs
327
* List of AVOptionRange structs.
313
329
typedef struct AVOptionRanges {
331
* Array of option ranges.
333
* Most of option types use just one component.
334
* Following describes multi-component option types:
336
* AV_OPT_TYPE_IMAGE_SIZE:
337
* component index 0: range of pixel count (width * height).
338
* component index 1: range of width.
339
* component index 2: range of height.
341
* @note To obtain multi-component version of this structure, user must
342
* provide AV_OPT_MULTI_COMPONENT_RANGE to av_opt_query_ranges or
343
* av_opt_query_ranges_default function.
345
* Multi-component range can be read as in following example:
348
* int range_index, component_index;
349
* AVOptionRanges *ranges;
350
* AVOptionRange *range[3]; //may require more than 3 in the future.
351
* av_opt_query_ranges(&ranges, obj, key, AV_OPT_MULTI_COMPONENT_RANGE);
352
* for (range_index = 0; range_index < ranges->nb_ranges; range_index++) {
353
* for (component_index = 0; component_index < ranges->nb_components; component_index++)
354
* range[component_index] = ranges->range[ranges->nb_ranges * component_index + range_index];
355
* //do something with range here.
357
* av_opt_freep_ranges(&ranges);
314
360
AVOptionRange **range;
362
* Number of ranges per component.
366
* Number of componentes.
316
369
} AVOptionRanges;
321
* Look for an option in obj. Look only for the options which
322
* have the flags set as specified in mask and flags (that is,
323
* for which it is the case that (opt->flags & mask) == flags).
325
* @param[in] obj a pointer to a struct whose first element is a
326
* pointer to an AVClass
327
* @param[in] name the name of the option to look for
328
* @param[in] unit the unit of the option to look for, or any if NULL
329
* @return a pointer to the option found, or NULL if no option
332
* @deprecated use av_opt_find.
335
const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags);
338
#if FF_API_OLD_AVOPTIONS
340
* Set the field of obj with the given name to value.
342
* @param[in] obj A struct whose first element is a pointer to an
344
* @param[in] name the name of the field to set
345
* @param[in] val The value to set. If the field is not of a string
346
* type, then the given string is parsed.
347
* SI postfixes and some named scalars are supported.
348
* If the field is of a numeric type, it has to be a numeric or named
349
* scalar. Behavior with more than one scalar and +- infix operators
351
* If the field is of a flags type, it has to be a sequence of numeric
352
* scalars or named flags separated by '+' or '-'. Prefixing a flag
353
* with '+' causes it to be set without affecting the other flags;
354
* similarly, '-' unsets a flag.
355
* @param[out] o_out if non-NULL put here a pointer to the AVOption
357
* @param alloc this parameter is currently ignored
358
* @return 0 if the value has been set, or an AVERROR code in case of
360
* AVERROR_OPTION_NOT_FOUND if no matching option exists
361
* AVERROR(ERANGE) if the value is out of range
362
* AVERROR(EINVAL) if the value is not valid
363
* @deprecated use av_opt_set()
366
int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out);
368
attribute_deprecated const AVOption *av_set_double(void *obj, const char *name, double n);
369
attribute_deprecated const AVOption *av_set_q(void *obj, const char *name, AVRational n);
370
attribute_deprecated const AVOption *av_set_int(void *obj, const char *name, int64_t n);
372
double av_get_double(void *obj, const char *name, const AVOption **o_out);
373
AVRational av_get_q(void *obj, const char *name, const AVOption **o_out);
374
int64_t av_get_int(void *obj, const char *name, const AVOption **o_out);
375
attribute_deprecated const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len);
376
attribute_deprecated const AVOption *av_next_option(void *obj, const AVOption *last);
380
372
* Show the obj options.
540
#define AV_OPT_SEARCH_CHILDREN 0x0001 /**< Search in possible children of the
541
given object first. */
556
#define AV_OPT_SEARCH_CHILDREN (1 << 0) /**< Search in possible children of the
557
given object first. */
543
559
* The obj passed to av_opt_find() is fake -- only a double pointer to AVClass
544
560
* instead of a required pointer to a struct containing AVClass. This is
545
561
* useful for searching for options without needing to allocate the corresponding
548
#define AV_OPT_SEARCH_FAKE_OBJ 0x0002
564
#define AV_OPT_SEARCH_FAKE_OBJ (1 << 1)
567
* In av_opt_get, return NULL if the option has a pointer type and is set to NULL,
568
* rather than returning an empty string.
570
#define AV_OPT_ALLOW_NULL (1 << 2)
573
* Allows av_opt_query_ranges and av_opt_query_ranges_default to return more than
574
* one component for certain option types.
575
* @see AVOptionRanges for details.
577
#define AV_OPT_MULTI_COMPONENT_RANGE (1 << 12)
551
580
* Look for an option in an object. Consider only options which
649
678
* AVERROR(ERANGE) if the value is out of range
650
679
* AVERROR(EINVAL) if the value is not valid
652
int av_opt_set (void *obj, const char *name, const char *val, int search_flags);
653
int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags);
654
int av_opt_set_double(void *obj, const char *name, double val, int search_flags);
655
int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags);
656
int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int size, int search_flags);
681
int av_opt_set (void *obj, const char *name, const char *val, int search_flags);
682
int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags);
683
int av_opt_set_double (void *obj, const char *name, double val, int search_flags);
684
int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags);
685
int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int size, int search_flags);
657
686
int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_flags);
658
687
int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags);
659
688
int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags);
660
689
int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int search_flags);
661
690
int av_opt_set_channel_layout(void *obj, const char *name, int64_t ch_layout, int search_flags);
692
* @note Any old dictionary present is discarded and replaced with a copy of the new one. The
693
* caller still owns val is and responsible for freeing it.
695
int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags);
664
698
* Set a binary option to an integer list.
695
730
* @note the returned string will be av_malloc()ed and must be av_free()ed by the caller
732
* @note if AV_OPT_ALLOW_NULL is set in search_flags in av_opt_get, and the option has
733
* AV_OPT_TYPE_STRING or AV_OPT_TYPE_BINARY and is set to NULL, *out_val will be set
734
* to NULL instead of an allocated empty string.
697
int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
698
int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val);
699
int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val);
700
int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val);
736
int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
737
int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val);
738
int av_opt_get_double (void *obj, const char *name, int search_flags, double *out_val);
739
int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val);
701
740
int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_out, int *h_out);
702
741
int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt);
703
742
int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt);
704
743
int av_opt_get_video_rate(void *obj, const char *name, int search_flags, AVRational *out_val);
705
744
int av_opt_get_channel_layout(void *obj, const char *name, int search_flags, int64_t *ch_layout);
746
* @param[out] out_val The returned dictionary is a copy of the actual value and must
747
* be freed with av_dict_free() by the caller
749
int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val);
729
773
* @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
730
774
* AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
775
* AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
732
777
* The result must be freed with av_opt_freep_ranges.
734
* @return >= 0 on success, a negative errro code otherwise
779
* @return number of compontents returned on success, a negative errro code otherwise
736
781
int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags);
784
* Copy options from src object into dest object.
786
* Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object.
787
* Original memory allocated for such options is freed unless both src and dest options points to the same memory.
789
* @param dest Object to copy from
790
* @param src Object to copy into
791
* @return 0 on success, negative on error
793
int av_opt_copy(void *dest, const void *src);
739
796
* Get a default list of allowed ranges for the given option.
741
798
* This list is constructed without using the AVClass.query_ranges() callback
744
801
* @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
745
802
* AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
803
* AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
747
805
* The result must be freed with av_opt_free_ranges.
749
* @return >= 0 on success, a negative errro code otherwise
807
* @return number of compontents returned on success, a negative errro code otherwise
751
809
int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags);
812
* Check if given option is set to its default value.
814
* Options o must belong to the obj. This function must not be called to check child's options state.
815
* @see av_opt_is_set_to_default_by_name().
817
* @param obj AVClass object to check option on
818
* @param o option to be checked
819
* @return >0 when option is set to its default,
820
* 0 when option is not set its default,
823
int av_opt_is_set_to_default(void *obj, const AVOption *o);
826
* Check if given option is set to its default value.
828
* @param obj AVClass object to check option on
829
* @param name option name
830
* @param search_flags combination of AV_OPT_SEARCH_*
831
* @return >0 when option is set to its default,
832
* 0 when option is not set its default,
835
int av_opt_is_set_to_default_by_name(void *obj, const char *name, int search_flags);
838
#define AV_OPT_SERIALIZE_SKIP_DEFAULTS 0x00000001 ///< Serialize options that are not set to default values only.
839
#define AV_OPT_SERIALIZE_OPT_FLAGS_EXACT 0x00000002 ///< Serialize options that exactly match opt_flags only.
842
* Serialize object's options.
844
* Create a string containing object's serialized options.
845
* Such string may be passed back to av_opt_set_from_string() in order to restore option values.
846
* A key/value or pairs separator occurring in the serialized value or
847
* name string are escaped through the av_escape() function.
849
* @param[in] obj AVClass object to serialize
850
* @param[in] opt_flags serialize options with all the specified flags set (AV_OPT_FLAG)
851
* @param[in] flags combination of AV_OPT_SERIALIZE_* flags
852
* @param[out] buffer Pointer to buffer that will be allocated with string containg serialized options.
853
* Buffer must be freed by the caller when is no longer needed.
854
* @param[in] key_val_sep character used to separate key from value
855
* @param[in] pairs_sep character used to separate two pairs from each other
856
* @return >= 0 on success, negative on error
857
* @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same.
859
int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer,
860
const char key_val_sep, const char pairs_sep);