|
|
|
|
@ -53,6 +53,16 @@
|
|
|
|
|
* question is allowed to access the field. This allows us to extend the
|
|
|
|
|
* semantics of those fields without breaking API compatibility.
|
|
|
|
|
*
|
|
|
|
|
* @section avoptions_scope Scope of AVOptions
|
|
|
|
|
*
|
|
|
|
|
* AVOptions is designed to support any set of multimedia configuration options
|
|
|
|
|
* that can be defined at compile-time. Although it is mainly used to expose
|
|
|
|
|
* FFmpeg options, you are welcome to adapt it to your own use case.
|
|
|
|
|
*
|
|
|
|
|
* No single approach can ever fully solve the problem of configuration,
|
|
|
|
|
* but please submit a patch if you believe you have found a problem
|
|
|
|
|
* that is best solved by extending AVOptions.
|
|
|
|
|
*
|
|
|
|
|
* @section avoptions_implement Implementing AVOptions
|
|
|
|
|
* This section describes how to add AVOptions capabilities to a struct.
|
|
|
|
|
*
|
|
|
|
|
@ -230,26 +240,99 @@
|
|
|
|
|
* before the file is actually opened.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An option type determines:
|
|
|
|
|
* - for native access, the underlying C type of the field that an AVOption
|
|
|
|
|
* refers to;
|
|
|
|
|
* - for foreign access, the semantics of accessing the option through this API,
|
|
|
|
|
* e.g. which av_opt_get_*() and av_opt_set_*() functions can be called, or
|
|
|
|
|
* what format will av_opt_get()/av_opt_set() expect/produce.
|
|
|
|
|
*/
|
|
|
|
|
enum AVOptionType{
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is unsigned int.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_FLAGS = 1,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is int.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_INT,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is int64_t.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_INT64,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is double.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_DOUBLE,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is float.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_FLOAT,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is a uint8_t* that is either NULL or points to a C
|
|
|
|
|
* string allocated with the av_malloc() family of functions.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_STRING,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is AVRational.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_RATIONAL,
|
|
|
|
|
AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is a uint8_t* that is either NULL or points to an array
|
|
|
|
|
* allocated with the av_malloc() family of functions. The pointer is
|
|
|
|
|
* immediately followed by an int containing the array length in bytes.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_BINARY,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is AVDictionary*.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_DICT,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is uint64_t.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_UINT64,
|
|
|
|
|
/**
|
|
|
|
|
* Special option type for declaring named constants. Does not correspond to
|
|
|
|
|
* an actual field in the object, offset must be 0.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_CONST,
|
|
|
|
|
AV_OPT_TYPE_IMAGE_SIZE, ///< offset must point to two consecutive integers
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is two consecutive integers.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_IMAGE_SIZE,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is enum AVPixelFormat.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_PIXEL_FMT,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is enum AVSampleFormat.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_SAMPLE_FMT,
|
|
|
|
|
AV_OPT_TYPE_VIDEO_RATE, ///< offset must point to AVRational
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is AVRational.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_VIDEO_RATE,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is int64_t.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_DURATION,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is uint8_t[4].
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_COLOR,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is int.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_BOOL,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is AVChannelLayout.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_CHLAYOUT,
|
|
|
|
|
/**
|
|
|
|
|
* Underlying C type is unsigned int.
|
|
|
|
|
*/
|
|
|
|
|
AV_OPT_TYPE_UINT,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* May be combined with another regular option type to declare an array
|
|
|
|
|
@ -535,6 +618,12 @@ const AVClass *av_opt_child_class_iterate(const AVClass *parent, void **iter);
|
|
|
|
|
*/
|
|
|
|
|
#define AV_OPT_ALLOW_NULL (1 << 2)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* May be used with av_opt_set_array() to signal that new elements should
|
|
|
|
|
* replace the existing ones in the indicated range.
|
|
|
|
|
*/
|
|
|
|
|
#define AV_OPT_ARRAY_REPLACE (1 << 3)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Allows av_opt_query_ranges and av_opt_query_ranges_default to return more than
|
|
|
|
|
* one component for certain option types.
|
|
|
|
|
@ -786,6 +875,10 @@ int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_
|
|
|
|
|
int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags);
|
|
|
|
|
int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags);
|
|
|
|
|
int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int search_flags);
|
|
|
|
|
/**
|
|
|
|
|
* @note Any old chlayout present is discarded and replaced with a copy of the new one. The
|
|
|
|
|
* caller still owns layout and is responsible for uninitializing it.
|
|
|
|
|
*/
|
|
|
|
|
int av_opt_set_chlayout(void *obj, const char *name, const AVChannelLayout *layout, int search_flags);
|
|
|
|
|
/**
|
|
|
|
|
* @note Any old dictionary present is discarded and replaced with a copy of the new one. The
|
|
|
|
|
@ -809,6 +902,56 @@ int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, in
|
|
|
|
|
av_opt_set_bin(obj, name, (const uint8_t *)(val), \
|
|
|
|
|
av_int_list_length(val, term) * sizeof(*(val)), flags))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add, replace, or remove elements for an array option. Which of these
|
|
|
|
|
* operations is performed depends on the values of val and search_flags.
|
|
|
|
|
*
|
|
|
|
|
* @param start_elem Index of the first array element to modify; must not be
|
|
|
|
|
* larger than array size as returned by
|
|
|
|
|
* av_opt_get_array_size().
|
|
|
|
|
* @param nb_elems number of array elements to modify; when val is NULL,
|
|
|
|
|
* start_elem+nb_elems must not be larger than array size as
|
|
|
|
|
* returned by av_opt_get_array_size()
|
|
|
|
|
*
|
|
|
|
|
* @param val_type Option type corresponding to the type of val, ignored when val is
|
|
|
|
|
* NULL.
|
|
|
|
|
*
|
|
|
|
|
* The effect of this function will will be as if av_opt_setX()
|
|
|
|
|
* was called for each element, where X is specified by type.
|
|
|
|
|
* E.g. AV_OPT_TYPE_STRING corresponds to av_opt_set().
|
|
|
|
|
*
|
|
|
|
|
* Typically this should be the same as the scalarized type of
|
|
|
|
|
* the AVOption being set, but certain conversions are also
|
|
|
|
|
* possible - the same as those done by the corresponding
|
|
|
|
|
* av_opt_set*() function. E.g. any option type can be set from
|
|
|
|
|
* a string, numeric types can be set from int64, double, or
|
|
|
|
|
* rational, etc.
|
|
|
|
|
*
|
|
|
|
|
* @param val Array with nb_elems elements or NULL.
|
|
|
|
|
*
|
|
|
|
|
* When NULL, nb_elems array elements starting at start_elem are
|
|
|
|
|
* removed from the array. Any array elements remaining at the end
|
|
|
|
|
* are shifted by nb_elems towards the first element in order to keep
|
|
|
|
|
* the array contiguous.
|
|
|
|
|
*
|
|
|
|
|
* Otherwise (val is non-NULL), the type of val must match the
|
|
|
|
|
* underlying C type as documented for val_type.
|
|
|
|
|
*
|
|
|
|
|
* When AV_OPT_ARRAY_REPLACE is not set in search_flags, the array is
|
|
|
|
|
* enlarged by nb_elems, and the contents of val are inserted at
|
|
|
|
|
* start_elem. Previously existing array elements from start_elem
|
|
|
|
|
* onwards (if present) are shifted by nb_elems away from the first
|
|
|
|
|
* element in order to make space for the new elements.
|
|
|
|
|
*
|
|
|
|
|
* When AV_OPT_ARRAY_REPLACE is set in search_flags, the contents
|
|
|
|
|
* of val replace existing array elements from start_elem to
|
|
|
|
|
* start_elem+nb_elems (if present). New array size is
|
|
|
|
|
* max(start_elem + nb_elems, old array size).
|
|
|
|
|
*/
|
|
|
|
|
int av_opt_set_array(void *obj, const char *name, int search_flags,
|
|
|
|
|
unsigned int start_elem, unsigned int nb_elems,
|
|
|
|
|
enum AVOptionType val_type, const void *val);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @}
|
|
|
|
|
* @}
|
|
|
|
|
@ -847,12 +990,56 @@ int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_
|
|
|
|
|
int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt);
|
|
|
|
|
int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt);
|
|
|
|
|
int av_opt_get_video_rate(void *obj, const char *name, int search_flags, AVRational *out_val);
|
|
|
|
|
/**
|
|
|
|
|
* @param[out] layout The returned layout is a copy of the actual value and must
|
|
|
|
|
* be freed with av_channel_layout_uninit() by the caller
|
|
|
|
|
*/
|
|
|
|
|
int av_opt_get_chlayout(void *obj, const char *name, int search_flags, AVChannelLayout *layout);
|
|
|
|
|
/**
|
|
|
|
|
* @param[out] out_val The returned dictionary is a copy of the actual value and must
|
|
|
|
|
* be freed with av_dict_free() by the caller
|
|
|
|
|
*/
|
|
|
|
|
int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* For an array-type option, get the number of elements in the array.
|
|
|
|
|
*/
|
|
|
|
|
int av_opt_get_array_size(void *obj, const char *name, int search_flags,
|
|
|
|
|
unsigned int *out_val);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* For an array-type option, retrieve the values of one or more array elements.
|
|
|
|
|
*
|
|
|
|
|
* @param start_elem index of the first array element to retrieve
|
|
|
|
|
* @param nb_elems number of array elements to retrieve; start_elem+nb_elems
|
|
|
|
|
* must not be larger than array size as returned by
|
|
|
|
|
* av_opt_get_array_size()
|
|
|
|
|
*
|
|
|
|
|
* @param out_type Option type corresponding to the desired output.
|
|
|
|
|
*
|
|
|
|
|
* The array elements produced by this function will
|
|
|
|
|
* will be as if av_opt_getX() was called for each element,
|
|
|
|
|
* where X is specified by out_type. E.g. AV_OPT_TYPE_STRING
|
|
|
|
|
* corresponds to av_opt_get().
|
|
|
|
|
*
|
|
|
|
|
* Typically this should be the same as the scalarized type of
|
|
|
|
|
* the AVOption being retrieved, but certain conversions are
|
|
|
|
|
* also possible - the same as those done by the corresponding
|
|
|
|
|
* av_opt_get*() function. E.g. any option type can be retrieved
|
|
|
|
|
* as a string, numeric types can be retrieved as int64, double,
|
|
|
|
|
* or rational, etc.
|
|
|
|
|
*
|
|
|
|
|
* @param out_val Array with nb_elems members into which the output will be
|
|
|
|
|
* written. The array type must match the underlying C type as
|
|
|
|
|
* documented for out_type, and be zeroed on entry to this
|
|
|
|
|
* function.
|
|
|
|
|
*
|
|
|
|
|
* For dynamically allocated types (strings, binary, dicts,
|
|
|
|
|
* etc.), the result is owned and freed by the caller.
|
|
|
|
|
*/
|
|
|
|
|
int av_opt_get_array(void *obj, const char *name, int search_flags,
|
|
|
|
|
unsigned int start_elem, unsigned int nb_elems,
|
|
|
|
|
enum AVOptionType out_type, void *out_val);
|
|
|
|
|
/**
|
|
|
|
|
* @}
|
|
|
|
|
*/
|
|
|
|
|
@ -873,6 +1060,7 @@ int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDiction
|
|
|
|
|
*/
|
|
|
|
|
int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out);
|
|
|
|
|
int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out);
|
|
|
|
|
int av_opt_eval_uint (void *obj, const AVOption *o, const char *val, unsigned *uint_out);
|
|
|
|
|
int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out);
|
|
|
|
|
int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out);
|
|
|
|
|
int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out);
|
|
|
|
|
@ -929,6 +1117,7 @@ int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
|
|
|
|
|
|
|
|
|
|
#define AV_OPT_SERIALIZE_SKIP_DEFAULTS 0x00000001 ///< Serialize options that are not set to default values only.
|
|
|
|
|
#define AV_OPT_SERIALIZE_OPT_FLAGS_EXACT 0x00000002 ///< Serialize options that exactly match opt_flags only.
|
|
|
|
|
#define AV_OPT_SERIALIZE_SEARCH_CHILDREN 0x00000004 ///< Serialize options in possible children of the given object.
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Serialize object's options.
|
|
|
|
|
|