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 #if FF_API_OLD_AVOPTIONS
238 #endif
239 };
240 
244 typedef struct AVOption {
245  const char *name;
246 
251  const char *help;
252 
257  int offset;
259 
263  union {
264  double dbl;
265  const char *str;
266  /* TODO those are unused now */
267  int64_t i64;
269  } default_val;
270  double min;
271  double max;
272 
273  int flags;
274 #define AV_OPT_FLAG_ENCODING_PARAM 1
275 #define AV_OPT_FLAG_DECODING_PARAM 2
276 #define AV_OPT_FLAG_METADATA 4
277 #define AV_OPT_FLAG_AUDIO_PARAM 8
278 #define AV_OPT_FLAG_VIDEO_PARAM 16
279 #define AV_OPT_FLAG_SUBTITLE_PARAM 32
280 //FIXME think about enc-audio, ... style flags
281 
287  const char *unit;
288 } AVOption;
289 
290 #if FF_API_FIND_OPT
291 
306 const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags);
307 #endif
308 
309 #if FF_API_OLD_AVOPTIONS
310 
337 int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out);
338 
339 attribute_deprecated const AVOption *av_set_double(void *obj, const char *name, double n);
340 attribute_deprecated const AVOption *av_set_q(void *obj, const char *name, AVRational n);
341 attribute_deprecated const AVOption *av_set_int(void *obj, const char *name, int64_t n);
342 
343 attribute_deprecated double av_get_double(void *obj, const char *name, const AVOption **o_out);
344 attribute_deprecated AVRational av_get_q(void *obj, const char *name, const AVOption **o_out);
345 attribute_deprecated int64_t av_get_int(void *obj, const char *name, const AVOption **o_out);
346 attribute_deprecated const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len);
347 attribute_deprecated const AVOption *av_next_option(void *obj, const AVOption *last);
348 #endif
349 
359 int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags);
360 
366 void av_opt_set_defaults(void *s);
367 
368 #if FF_API_OLD_AVOPTIONS
370 void av_opt_set_defaults2(void *s, int mask, int flags);
371 #endif
372 
389 int av_set_options_string(void *ctx, const char *opts,
390  const char *key_val_sep, const char *pairs_sep);
391 
395 void av_opt_free(void *obj);
396 
405 int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name);
406 
407 /*
408  * Set all the options from a given dictionary on an object.
409  *
410  * @param obj a struct whose first element is a pointer to AVClass
411  * @param options options to process. This dictionary will be freed and replaced
412  * by a new one containing all options not found in obj.
413  * Of course this new dictionary needs to be freed by caller
414  * with av_dict_free().
415  *
416  * @return 0 on success, a negative AVERROR if some option was found in obj,
417  * but could not be set.
418  *
419  * @see av_dict_copy()
420  */
421 int av_opt_set_dict(void *obj, struct AVDictionary **options);
422 
437 int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out);
438 int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out);
439 int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out);
440 int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out);
441 int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out);
442 int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out);
447 #define AV_OPT_SEARCH_CHILDREN 0x0001
455 #define AV_OPT_SEARCH_FAKE_OBJ 0x0002
456 
479 const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
480  int opt_flags, int search_flags);
481 
503 const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
504  int opt_flags, int search_flags, void **target_obj);
505 
515 const AVOption *av_opt_next(void *obj, const AVOption *prev);
516 
523 void *av_opt_child_next(void *obj, void *prev);
524 
531 const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev);
532 
559 int av_opt_set (void *obj, const char *name, const char *val, int search_flags);
560 int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags);
561 int av_opt_set_double(void *obj, const char *name, double val, int search_flags);
562 int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags);
582 int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
583 int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val);
584 int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val);
585 int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val);
591 #endif /* AVUTIL_OPT_H */