FFmpeg
opt.h
Go to the documentation of this file.
1 /*
2  * AVOptions
3  * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVUTIL_OPT_H
23 #define AVUTIL_OPT_H
24 
30 #include "rational.h"
31 #include "avutil.h"
32 #include "dict.h"
33 #include "log.h"
34 #include "pixfmt.h"
35 #include "samplefmt.h"
36 #include "version.h"
37 
222  AV_OPT_TYPE_FLAGS,
223  AV_OPT_TYPE_INT,
224  AV_OPT_TYPE_INT64,
225  AV_OPT_TYPE_DOUBLE,
226  AV_OPT_TYPE_FLOAT,
227  AV_OPT_TYPE_STRING,
228  AV_OPT_TYPE_RATIONAL,
230  AV_OPT_TYPE_DICT,
231  AV_OPT_TYPE_UINT64,
232  AV_OPT_TYPE_CONST,
234  AV_OPT_TYPE_PIXEL_FMT,
235  AV_OPT_TYPE_SAMPLE_FMT,
237  AV_OPT_TYPE_DURATION,
238  AV_OPT_TYPE_COLOR,
239  AV_OPT_TYPE_CHANNEL_LAYOUT,
240  AV_OPT_TYPE_BOOL,
241 };
242 
246 typedef struct AVOption {
247  const char *name;
248 
253  const char *help;
254 
259  int offset;
260  enum AVOptionType type;
261 
265  union {
266  int64_t i64;
267  double dbl;
268  const char *str;
269  /* TODO those are unused now */
270  AVRational q;
271  } default_val;
272  double min;
273  double max;
274 
275  int flags;
276 #define AV_OPT_FLAG_ENCODING_PARAM 1
277 #define AV_OPT_FLAG_DECODING_PARAM 2
278 #define AV_OPT_FLAG_AUDIO_PARAM 8
279 #define AV_OPT_FLAG_VIDEO_PARAM 16
280 #define AV_OPT_FLAG_SUBTITLE_PARAM 32
281 
284 #define AV_OPT_FLAG_EXPORT 64
285 
289 #define AV_OPT_FLAG_READONLY 128
290 #define AV_OPT_FLAG_BSF_PARAM (1<<8)
291 #define AV_OPT_FLAG_FILTERING_PARAM (1<<16)
292 //FIXME think about enc-audio, ... style flags
293 
299  const char *unit;
300 } AVOption;
301 
305 typedef struct AVOptionRange {
306  const char *str;
312  double value_min, value_max;
317  double component_min, component_max;
322  int is_range;
323 } AVOptionRange;
324 
328 typedef struct AVOptionRanges {
369 
379 int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags);
380 
386 void av_opt_set_defaults(void *s);
387 
397 void av_opt_set_defaults2(void *s, int mask, int flags);
398 
416 int av_set_options_string(void *ctx, const char *opts,
417  const char *key_val_sep, const char *pairs_sep);
418 
446 int av_opt_set_from_string(void *ctx, const char *opts,
447  const char *const *shorthand,
448  const char *key_val_sep, const char *pairs_sep);
452 void av_opt_free(void *obj);
453 
462 int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name);
463 
478 int av_opt_set_dict(void *obj, struct AVDictionary **options);
479 
480 
496 int av_opt_set_dict2(void *obj, struct AVDictionary **options, int search_flags);
497 
517 int av_opt_get_key_value(const char **ropts,
518  const char *key_val_sep, const char *pairs_sep,
519  unsigned flags,
520  char **rkey, char **rval);
521 
522 enum {
523 
529 };
530 
545 int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out);
546 int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out);
547 int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out);
548 int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out);
549 int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out);
550 int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out);
555 #define AV_OPT_SEARCH_CHILDREN (1 << 0)
563 #define AV_OPT_SEARCH_FAKE_OBJ (1 << 1)
569 #define AV_OPT_ALLOW_NULL (1 << 2)
576 #define AV_OPT_MULTI_COMPONENT_RANGE (1 << 12)
600 const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
601  int opt_flags, int search_flags);
602 
624 const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
625  int opt_flags, int search_flags, void **target_obj);
626 
636 const AVOption *av_opt_next(const void *obj, const AVOption *prev);
637 
644 void *av_opt_child_next(void *obj, void *prev);
645 
652 const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev);
653 
680 int av_opt_set (void *obj, const char *name, const char *val, int search_flags);
681 int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags);
682 int av_opt_set_double (void *obj, const char *name, double val, int search_flags);
683 int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags);
684 int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int size, int search_flags);
685 int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_flags);
686 int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags);
687 int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags);
688 int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int search_flags);
689 int av_opt_set_channel_layout(void *obj, const char *name, int64_t ch_layout, int search_flags);
694 int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags);
695 
706 #define av_opt_set_int_list(obj, name, val, term, flags) \
707  (av_int_list_length(val, term) > INT_MAX / sizeof(*(val)) ? \
708  AVERROR(EINVAL) : \
709  av_opt_set_bin(obj, name, (const uint8_t *)(val), \
710  av_int_list_length(val, term) * sizeof(*(val)), flags))
711 
735 int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
736 int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val);
737 int av_opt_get_double (void *obj, const char *name, int search_flags, double *out_val);
738 int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val);
739 int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_out, int *h_out);
740 int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt);
741 int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt);
742 int av_opt_get_video_rate(void *obj, const char *name, int search_flags, AVRational *out_val);
743 int av_opt_get_channel_layout(void *obj, const char *name, int search_flags, int64_t *ch_layout);
748 int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val);
760 void *av_opt_ptr(const AVClass *avclass, void *obj, const char *name);
761 
765 void av_opt_freep_ranges(AVOptionRanges **ranges);
766 
780 int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags);
781 
792 int av_opt_copy(void *dest, const void *src);
793 
808 int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags);
809 
822 int av_opt_is_set_to_default(void *obj, const AVOption *o);
823 
834 int av_opt_is_set_to_default_by_name(void *obj, const char *name, int search_flags);
835 
836 
837 #define AV_OPT_SERIALIZE_SKIP_DEFAULTS 0x00000001
838 #define AV_OPT_SERIALIZE_OPT_FLAGS_EXACT 0x00000002
840 
858 int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer,
859  const char key_val_sep, const char pairs_sep);
864 #endif /* AVUTIL_OPT_H */
int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val)
Definition: opt.c:994
A single allowed range of values, or a single allowed value.
Definition: opt.h:305
Accept to parse a value without a key; the key will then be returned as NULL.
Definition: opt.h:528
AVOption.
Definition: opt.h:246
void * av_opt_child_next(void *obj, void *prev)
Iterate over AVOptions-enabled children of obj.
Definition: opt.c:1645
const AVClass * av_opt_child_class_next(const AVClass *parent, const AVClass *prev)
Iterate over potential AVOptions-enabled children of parent.
Definition: opt.c:1653
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1292
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
Parse the key/value pairs list in opts.
Definition: opt.c:1413
Convenience header that includes libavutil&#39;s core.
int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer, const char key_val_sep, const char pairs_sep)
Serialize object&#39;s options.
Definition: opt.c:1981
int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags)
Definition: opt.c:697
AVOptionType
Definition: opt.h:221
int av_opt_is_set_to_default_by_name(void *obj, const char *name, int search_flags)
Check if given option is set to its default value.
Definition: opt.c:1969
int av_opt_is_set_to_default(void *obj, const AVOption *o)
Check if given option is set to its default value.
Definition: opt.c:1872
int av_opt_set_from_string(void *ctx, const char *opts, const char *const *shorthand, const char *key_val_sep, const char *pairs_sep)
Parse the key-value pairs list in opts.
Definition: opt.c:1493
Public dictionary API.
AVOptionRange ** range
Array of option ranges.
Definition: opt.h:359
const char * help
short English help text
Definition: opt.h:253
Definition: dict.c:30
void * av_opt_ptr(const AVClass *avclass, void *obj, const char *name)
Gets a pointer to the requested field in a struct.
Definition: opt.c:1660
struct AVOptionRanges AVOptionRanges
List of AVOptionRange structs.
double max
maximum valid value for the option
Definition: opt.h:273
const AVOption * av_opt_next(const void *obj, const AVOption *prev)
Iterate over all AVOptions belonging to obj.
Definition: opt.c:45
Libavutil version macros.
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
Definition: opt.c:1595
struct AVOptionRange AVOptionRange
A single allowed range of values, or a single allowed value.
const char * unit
The logical unit to which the option belongs.
Definition: opt.h:299
double component_min
Value&#39;s component range.
Definition: opt.h:317
double min
minimum valid value for the option
Definition: opt.h:272
void av_opt_set_defaults2(void *s, int mask, int flags)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1297
int av_opt_set_dict2(void *obj, struct AVDictionary **options, int search_flags)
Set all the options from a given dictionary on an object.
Definition: opt.c:1565
offset must point to a pointer immediately followed by an int for the length
Definition: opt.h:229
int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags)
Get a default list of allowed ranges for the given option.
Definition: opt.c:1781
int is_range
Range flag.
Definition: opt.h:322
void av_opt_freep_ranges(AVOptionRanges **ranges)
Free an AVOptionRanges struct and set it to NULL.
Definition: opt.c:1853
int offset
The offset relative to the context structure where the option value is stored.
Definition: opt.h:259
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
int av_opt_set_dict(void *obj, struct AVDictionary **options)
Set all the options from a given dictionary on an object.
Definition: opt.c:1590
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
Show the obj options.
Definition: opt.c:1280
Describe the class of an AVClass context structure.
Definition: log.h:67
Rational number (pair of numerator and denominator).
Definition: rational.h:58
offset must point to AVRational
Definition: opt.h:236
offset must point to two consecutive integers
Definition: opt.h:233
union AVOption::@263 default_val
the default value for scalar options
struct AVOption AVOption
AVOption.
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1545
int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags)
Get a list of allowed ranges for the given option.
Definition: opt.c:1760
double value_min
Value range.
Definition: opt.h:312
Utilties for rational number calculation.
int av_opt_copy(void *dest, const void *src)
Copy options from src object into dest object.
Definition: opt.c:1703
int nb_ranges
Number of ranges per component.
Definition: opt.h:363
List of AVOptionRange structs.
Definition: opt.h:328
pixel format definitions
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
Definition: opt.c:751
int av_opt_get_key_value(const char **ropts, const char *key_val_sep, const char *pairs_sep, unsigned flags, char **rkey, char **rval)
Extract a key-value pair from the beginning of a string.
Definition: opt.c:1471
int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
Check whether a particular flag is set in a flags field.
Definition: opt.c:1011
const AVOption * av_opt_find2(void *obj, const char *name, const char *unit, int opt_flags, int search_flags, void **target_obj)
Look for an option in an object.
Definition: opt.c:1601
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
int nb_components
Number of componentes.
Definition: opt.h:367