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 
228 };
229 
233 typedef struct AVOption {
234  const char *name;
235 
240  const char *help;
241 
246  int offset;
248 
252  union {
253  int64_t i64;
254  double dbl;
255  const char *str;
256  /* TODO those are unused now */
258  } default_val;
259  double min;
260  double max;
261 
262  int flags;
263 #define AV_OPT_FLAG_ENCODING_PARAM 1
264 #define AV_OPT_FLAG_DECODING_PARAM 2
265 #define AV_OPT_FLAG_METADATA 4
266 #define AV_OPT_FLAG_AUDIO_PARAM 8
267 #define AV_OPT_FLAG_VIDEO_PARAM 16
268 #define AV_OPT_FLAG_SUBTITLE_PARAM 32
269 //FIXME think about enc-audio, ... style flags
270 
276  const char *unit;
277 } AVOption;
278 
288 int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags);
289 
295 void av_opt_set_defaults(void *s);
296 
313 int av_set_options_string(void *ctx, const char *opts,
314  const char *key_val_sep, const char *pairs_sep);
315 
319 void av_opt_free(void *obj);
320 
329 int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name);
330 
331 /*
332  * Set all the options from a given dictionary on an object.
333  *
334  * @param obj a struct whose first element is a pointer to AVClass
335  * @param options options to process. This dictionary will be freed and replaced
336  * by a new one containing all options not found in obj.
337  * Of course this new dictionary needs to be freed by caller
338  * with av_dict_free().
339  *
340  * @return 0 on success, a negative AVERROR if some option was found in obj,
341  * but could not be set.
342  *
343  * @see av_dict_copy()
344  */
345 int av_opt_set_dict(void *obj, struct AVDictionary **options);
346 
361 int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out);
362 int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out);
363 int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out);
364 int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out);
365 int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out);
366 int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out);
371 #define AV_OPT_SEARCH_CHILDREN 0x0001
379 #define AV_OPT_SEARCH_FAKE_OBJ 0x0002
403 const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
404  int opt_flags, int search_flags);
405 
427 const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
428  int opt_flags, int search_flags, void **target_obj);
429 
439 const AVOption *av_opt_next(void *obj, const AVOption *prev);
440 
447 void *av_opt_child_next(void *obj, void *prev);
448 
455 const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev);
456 
483 int av_opt_set (void *obj, const char *name, const char *val, int search_flags);
484 int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags);
485 int av_opt_set_double(void *obj, const char *name, double val, int search_flags);
486 int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags);
487 int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int size, int search_flags);
507 int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
508 int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val);
509 int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val);
510 int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val);
516 #endif /* AVUTIL_OPT_H */
int av_opt_eval_float(void *obj, const AVOption *o, const char *val, float *float_out)
int size
AVOption.
Definition: opt.h:233
int av_opt_set_q(void *obj, const char *name, AVRational val, int search_flags)
Definition: opt.c:272
void * av_opt_child_next(void *obj, void *prev)
Iterate over AVOptions-enabled children of obj.
Definition: opt.c:678
const AVClass * av_opt_child_class_next(const AVClass *parent, const AVClass *prev)
Iterate over potential AVOptions-enabled children of parent.
Definition: opt.c:686
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:505
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:587
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:277
int av_opt_get_q(void *obj, const char *name, int search_flags, AVRational *out_val)
Definition: opt.c:395
AVOptionType
Definition: opt.h:218
AVRational q
Definition: opt.h:257
Public dictionary API.
const char * name
Definition: opt.h:234
uint8_t
const char * help
short English help text
Definition: opt.h:240
const char * str
Definition: opt.h:255
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:267
double max
maximum valid value for the option
Definition: opt.h:260
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:262
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:636
int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out)
union AVOption::@112 default_val
the default value for scalar options
const char * unit
The logical unit to which the option belongs.
Definition: opt.h:276
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:259
offset must point to a pointer immediately followed by an int for the length
Definition: opt.h:226
int flags
Definition: opt.h:262
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
Definition: opt.c:371
int offset
The offset relative to the context structure where the option value is stored.
Definition: opt.h:246
int av_opt_set_dict(void *obj, struct AVDictionary **options)
Definition: opt.c:615
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
Show the obj options.
Definition: opt.c:493
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:254
int av_opt_eval_int(void *obj, const AVOption *o, const char *val, int *int_out)
const OptionDef options[]
Definition: avserver.c:4665
struct AVOption AVOption
AVOption.
void av_opt_free(void *obj)
Free all string and binary options in obj.
Definition: opt.c:607
rational numbers
int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val)
Definition: opt.c:383
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
Definition: opt.c:306
enum AVOptionType type
Definition: opt.h:247
int64_t i64
Definition: opt.h:253
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:411
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:642
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:209