Libav
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 Libav.
6  *
7  * Libav 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  * Libav 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 Libav; 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 
229 };
230 
234 typedef struct AVOption {
235  const char *name;
236 
241  const char *help;
242 
247  int offset;
249 
253  union {
254  int64_t i64;
255  double dbl;
256  const char *str;
257  /* TODO those are unused now */
259  } default_val;
260  double min;
261  double max;
262 
263  int flags;
264 #define AV_OPT_FLAG_ENCODING_PARAM 1
265 #define AV_OPT_FLAG_DECODING_PARAM 2
266 #if FF_API_OPT_TYPE_METADATA
267 #define AV_OPT_FLAG_METADATA 4
268 #endif
269 #define AV_OPT_FLAG_AUDIO_PARAM 8
270 #define AV_OPT_FLAG_VIDEO_PARAM 16
271 #define AV_OPT_FLAG_SUBTITLE_PARAM 32
272 
275 #define AV_OPT_FLAG_EXPORT 64
276 
280 #define AV_OPT_FLAG_READONLY 128
281 //FIXME think about enc-audio, ... style flags
282 
288  const char *unit;
289 } AVOption;
290 
300 int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags);
301 
307 void av_opt_set_defaults(void *s);
308 
325 int av_set_options_string(void *ctx, const char *opts,
326  const char *key_val_sep, const char *pairs_sep);
327 
331 void av_opt_free(void *obj);
332 
341 int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name);
342 
343 /*
344  * Set all the options from a given dictionary on an object.
345  *
346  * @param obj a struct whose first element is a pointer to AVClass
347  * @param options options to process. This dictionary will be freed and replaced
348  * by a new one containing all options not found in obj.
349  * Of course this new dictionary needs to be freed by caller
350  * with av_dict_free().
351  *
352  * @return 0 on success, a negative AVERROR if some option was found in obj,
353  * but could not be set.
354  *
355  * @see av_dict_copy()
356  */
357 int av_opt_set_dict(void *obj, struct AVDictionary **options);
358 
373 int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out);
374 int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out);
375 int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out);
376 int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out);
377 int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out);
378 int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out);
383 #define AV_OPT_SEARCH_CHILDREN 0x0001
391 #define AV_OPT_SEARCH_FAKE_OBJ 0x0002
415 const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
416  int opt_flags, int search_flags);
417 
439 const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
440  int opt_flags, int search_flags, void **target_obj);
441 
451 const AVOption *av_opt_next(void *obj, const AVOption *prev);
452 
459 void *av_opt_child_next(void *obj, void *prev);
460 
467 const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev);
468 
495 int av_opt_set (void *obj, const char *name, const char *val, int search_flags);
496 int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags);
497 int av_opt_set_double (void *obj, const char *name, double val, int search_flags);
498 int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags);
499 int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int size, int search_flags);
504 int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags);
524 int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
525 int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val);
526 int av_opt_get_double (void *obj, const char *name, int search_flags, double *out_val);
527 int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val);
532 int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val);
538 #endif /* AVUTIL_OPT_H */
int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val)
Definition: opt.c:433
int av_opt_eval_float(void *obj, const AVOption *o, const char *val, float *float_out)
int size
AVOption.
Definition: opt.h:234
int av_opt_set_q(void *obj, const char *name, AVRational val, int search_flags)
Definition: opt.c:278
void * av_opt_child_next(void *obj, void *prev)
Iterate over AVOptions-enabled children of obj.
Definition: opt.c:745
const AVClass * av_opt_child_class_next(const AVClass *parent, const AVClass *prev)
Iterate over potential AVOptions-enabled children of parent.
Definition: opt.c:753
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:546
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:639
external API header
int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int size, int search_flags)
Definition: opt.c:283
int av_opt_get_q(void *obj, const char *name, int search_flags, AVRational *out_val)
Definition: opt.c:417
int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags)
Definition: opt.c:312
AVOptionType
Definition: opt.h:218
AVRational q
Definition: opt.h:258
Public dictionary API.
const char * name
Definition: opt.h:235
union AVOption::@131 default_val
the default value for scalar options
uint8_t
const char * help
short English help text
Definition: opt.h:241
const char * str
Definition: opt.h:256
const char * name
int av_opt_eval_int64(void *obj, const AVOption *o, const char *val, int64_t *int64_out)
int av_opt_set_double(void *obj, const char *name, double val, int search_flags)
Definition: opt.c:273
const OptionDef options[]
Definition: avconv_opt.c:2187
double max
maximum valid value for the option
Definition: opt.h:261
int av_opt_eval_flags(void *obj, const AVOption *o, const char *val, int *flags_out)
const AVOption * av_opt_next(void *obj, const AVOption *prev)
Iterate over all AVOptions belonging to obj.
Definition: opt.c:37
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
Definition: opt.c:268
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:700
int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out)
const char * unit
The logical unit to which the option belongs.
Definition: opt.h:288
int av_opt_eval_q(void *obj, const AVOption *o, const char *val, AVRational *q_out)
double min
minimum valid value for the option
Definition: opt.h:260
offset must point to a pointer immediately followed by an int for the length
Definition: opt.h:226
int flags
Definition: opt.h:263
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
Definition: opt.c:393
int offset
The offset relative to the context structure where the option value is stored.
Definition: opt.h:247
int av_opt_set_dict(void *obj, struct AVDictionary **options)
Definition: opt.c:679
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
Show the obj options.
Definition: opt.c:534
Describe the class of an AVClass context structure.
Definition: log.h:33
rational number numerator/denominator
Definition: rational.h:43
double dbl
Definition: opt.h:255
int av_opt_eval_int(void *obj, const AVOption *o, const char *val, int *int_out)
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:659
rational numbers
int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val)
Definition: opt.c:405
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
Definition: opt.c:330
enum AVOptionType type
Definition: opt.h:248
int64_t i64
Definition: opt.h:254
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:450
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:706
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:212