annotate lib/libavutil/opt.h @ 2553:48708da03b7f

Party Creation UI logic separated from MainMenu
author a.parshin
date Wed, 13 May 2015 02:20:05 +0200
parents 992d2e6f907d
children
rev   line source
2134
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
1 /*
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
2 * AVOptions
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
3 * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
4 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
5 * This file is part of FFmpeg.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
6 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
11 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
15 * Lesser General Public License for more details.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
16 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
20 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
21
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
22 #ifndef AVUTIL_OPT_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
23 #define AVUTIL_OPT_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
24
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
25 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
26 * @file
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
27 * AVOptions
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
28 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
29
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
30 #include "rational.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
31 #include "avutil.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
32 #include "dict.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
33 #include "log.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
34 #include "pixfmt.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
35 #include "samplefmt.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
36
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
37 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
38 * @defgroup avoptions AVOptions
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
39 * @ingroup lavu_data
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
40 * @{
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
41 * AVOptions provide a generic system to declare options on arbitrary structs
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
42 * ("objects"). An option can have a help text, a type and a range of possible
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
43 * values. Options may then be enumerated, read and written to.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
44 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
45 * @section avoptions_implement Implementing AVOptions
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
46 * This section describes how to add AVOptions capabilities to a struct.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
47 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
48 * All AVOptions-related information is stored in an AVClass. Therefore
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
49 * the first member of the struct should be a pointer to an AVClass describing it.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
50 * The option field of the AVClass must be set to a NULL-terminated static array
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
51 * of AVOptions. Each AVOption must have a non-empty name, a type, a default
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
52 * value and for number-type AVOptions also a range of allowed values. It must
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
53 * also declare an offset in bytes from the start of the struct, where the field
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
54 * associated with this AVOption is located. Other fields in the AVOption struct
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
55 * should also be set when applicable, but are not required.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
56 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
57 * The following example illustrates an AVOptions-enabled struct:
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
58 * @code
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
59 * typedef struct test_struct {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
60 * AVClass *class;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
61 * int int_opt;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
62 * char *str_opt;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
63 * uint8_t *bin_opt;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
64 * int bin_len;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
65 * } test_struct;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
66 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
67 * static const AVOption options[] = {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
68 * { "test_int", "This is a test option of int type.", offsetof(test_struct, int_opt),
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
69 * AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX },
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
70 * { "test_str", "This is a test option of string type.", offsetof(test_struct, str_opt),
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
71 * AV_OPT_TYPE_STRING },
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
72 * { "test_bin", "This is a test option of binary type.", offsetof(test_struct, bin_opt),
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
73 * AV_OPT_TYPE_BINARY },
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
74 * { NULL },
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
75 * };
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
76 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
77 * static const AVClass test_class = {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
78 * .class_name = "test class",
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
79 * .item_name = av_default_item_name,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
80 * .option = options,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
81 * .version = LIBAVUTIL_VERSION_INT,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
82 * };
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
83 * @endcode
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
84 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
85 * Next, when allocating your struct, you must ensure that the AVClass pointer
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
86 * is set to the correct value. Then, av_opt_set_defaults() can be called to
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
87 * initialize defaults. After that the struct is ready to be used with the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
88 * AVOptions API.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
89 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
90 * When cleaning up, you may use the av_opt_free() function to automatically
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
91 * free all the allocated string and binary options.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
92 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
93 * Continuing with the above example:
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
94 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
95 * @code
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
96 * test_struct *alloc_test_struct(void)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
97 * {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
98 * test_struct *ret = av_malloc(sizeof(*ret));
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
99 * ret->class = &test_class;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
100 * av_opt_set_defaults(ret);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
101 * return ret;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
102 * }
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
103 * void free_test_struct(test_struct **foo)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
104 * {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
105 * av_opt_free(*foo);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
106 * av_freep(foo);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
107 * }
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
108 * @endcode
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
109 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
110 * @subsection avoptions_implement_nesting Nesting
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
111 * It may happen that an AVOptions-enabled struct contains another
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
112 * AVOptions-enabled struct as a member (e.g. AVCodecContext in
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
113 * libavcodec exports generic options, while its priv_data field exports
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
114 * codec-specific options). In such a case, it is possible to set up the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
115 * parent struct to export a child's options. To do that, simply
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
116 * implement AVClass.child_next() and AVClass.child_class_next() in the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
117 * parent struct's AVClass.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
118 * Assuming that the test_struct from above now also contains a
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
119 * child_struct field:
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
120 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
121 * @code
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
122 * typedef struct child_struct {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
123 * AVClass *class;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
124 * int flags_opt;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
125 * } child_struct;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
126 * static const AVOption child_opts[] = {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
127 * { "test_flags", "This is a test option of flags type.",
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
128 * offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX },
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
129 * { NULL },
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
130 * };
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
131 * static const AVClass child_class = {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
132 * .class_name = "child class",
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
133 * .item_name = av_default_item_name,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
134 * .option = child_opts,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
135 * .version = LIBAVUTIL_VERSION_INT,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
136 * };
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
137 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
138 * void *child_next(void *obj, void *prev)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
139 * {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
140 * test_struct *t = obj;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
141 * if (!prev && t->child_struct)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
142 * return t->child_struct;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
143 * return NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
144 * }
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
145 * const AVClass child_class_next(const AVClass *prev)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
146 * {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
147 * return prev ? NULL : &child_class;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
148 * }
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
149 * @endcode
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
150 * Putting child_next() and child_class_next() as defined above into
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
151 * test_class will now make child_struct's options accessible through
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
152 * test_struct (again, proper setup as described above needs to be done on
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
153 * child_struct right after it is created).
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
154 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
155 * From the above example it might not be clear why both child_next()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
156 * and child_class_next() are needed. The distinction is that child_next()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
157 * iterates over actually existing objects, while child_class_next()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
158 * iterates over all possible child classes. E.g. if an AVCodecContext
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
159 * was initialized to use a codec which has private options, then its
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
160 * child_next() will return AVCodecContext.priv_data and finish
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
161 * iterating. OTOH child_class_next() on AVCodecContext.av_class will
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
162 * iterate over all available codecs with private options.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
163 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
164 * @subsection avoptions_implement_named_constants Named constants
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
165 * It is possible to create named constants for options. Simply set the unit
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
166 * field of the option the constants should apply to to a string and
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
167 * create the constants themselves as options of type AV_OPT_TYPE_CONST
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
168 * with their unit field set to the same string.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
169 * Their default_val field should contain the value of the named
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
170 * constant.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
171 * For example, to add some named constants for the test_flags option
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
172 * above, put the following into the child_opts array:
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
173 * @code
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
174 * { "test_flags", "This is a test option of flags type.",
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
175 * offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, "test_unit" },
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
176 * { "flag1", "This is a flag with value 16", 0, AV_OPT_TYPE_CONST, { .i64 = 16 }, 0, 0, "test_unit" },
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
177 * @endcode
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
178 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
179 * @section avoptions_use Using AVOptions
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
180 * This section deals with accessing options in an AVOptions-enabled struct.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
181 * Such structs in FFmpeg are e.g. AVCodecContext in libavcodec or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
182 * AVFormatContext in libavformat.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
183 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
184 * @subsection avoptions_use_examine Examining AVOptions
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
185 * The basic functions for examining options are av_opt_next(), which iterates
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
186 * over all options defined for one object, and av_opt_find(), which searches
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
187 * for an option with the given name.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
188 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
189 * The situation is more complicated with nesting. An AVOptions-enabled struct
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
190 * may have AVOptions-enabled children. Passing the AV_OPT_SEARCH_CHILDREN flag
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
191 * to av_opt_find() will make the function search children recursively.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
192 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
193 * For enumerating there are basically two cases. The first is when you want to
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
194 * get all options that may potentially exist on the struct and its children
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
195 * (e.g. when constructing documentation). In that case you should call
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
196 * av_opt_child_class_next() recursively on the parent struct's AVClass. The
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
197 * second case is when you have an already initialized struct with all its
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
198 * children and you want to get all options that can be actually written or read
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
199 * from it. In that case you should call av_opt_child_next() recursively (and
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
200 * av_opt_next() on each result).
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
201 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
202 * @subsection avoptions_use_get_set Reading and writing AVOptions
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
203 * When setting options, you often have a string read directly from the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
204 * user. In such a case, simply passing it to av_opt_set() is enough. For
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
205 * non-string type options, av_opt_set() will parse the string according to the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
206 * option type.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
207 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
208 * Similarly av_opt_get() will read any option type and convert it to a string
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
209 * which will be returned. Do not forget that the string is allocated, so you
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
210 * have to free it with av_free().
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
211 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
212 * In some cases it may be more convenient to put all options into an
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
213 * AVDictionary and call av_opt_set_dict() on it. A specific case of this
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
214 * are the format/codec open functions in lavf/lavc which take a dictionary
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
215 * filled with option as a parameter. This allows to set some options
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
216 * that cannot be set otherwise, since e.g. the input file format is not known
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
217 * before the file is actually opened.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
218 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
219
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
220 enum AVOptionType{
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
221 AV_OPT_TYPE_FLAGS,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
222 AV_OPT_TYPE_INT,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
223 AV_OPT_TYPE_INT64,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
224 AV_OPT_TYPE_DOUBLE,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
225 AV_OPT_TYPE_FLOAT,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
226 AV_OPT_TYPE_STRING,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
227 AV_OPT_TYPE_RATIONAL,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
228 AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
229 AV_OPT_TYPE_CONST = 128,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
230 AV_OPT_TYPE_IMAGE_SIZE = MKBETAG('S','I','Z','E'), ///< offset must point to two consecutive integers
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
231 AV_OPT_TYPE_PIXEL_FMT = MKBETAG('P','F','M','T'),
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
232 AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'),
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
233 AV_OPT_TYPE_VIDEO_RATE = MKBETAG('V','R','A','T'), ///< offset must point to AVRational
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
234 AV_OPT_TYPE_DURATION = MKBETAG('D','U','R',' '),
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
235 AV_OPT_TYPE_COLOR = MKBETAG('C','O','L','R'),
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
236 #if FF_API_OLD_AVOPTIONS
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
237 FF_OPT_TYPE_FLAGS = 0,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
238 FF_OPT_TYPE_INT,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
239 FF_OPT_TYPE_INT64,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
240 FF_OPT_TYPE_DOUBLE,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
241 FF_OPT_TYPE_FLOAT,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
242 FF_OPT_TYPE_STRING,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
243 FF_OPT_TYPE_RATIONAL,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
244 FF_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
245 FF_OPT_TYPE_CONST=128,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
246 #endif
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
247 };
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
248
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
249 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
250 * AVOption
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
251 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
252 typedef struct AVOption {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
253 const char *name;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
254
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
255 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
256 * short English help text
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
257 * @todo What about other languages?
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
258 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
259 const char *help;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
260
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
261 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
262 * The offset relative to the context structure where the option
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
263 * value is stored. It should be 0 for named constants.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
264 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
265 int offset;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
266 enum AVOptionType type;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
267
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
268 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
269 * the default value for scalar options
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
270 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
271 union {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
272 int64_t i64;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
273 double dbl;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
274 const char *str;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
275 /* TODO those are unused now */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
276 AVRational q;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
277 } default_val;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
278 double min; ///< minimum valid value for the option
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
279 double max; ///< maximum valid value for the option
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
280
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
281 int flags;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
282 #define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
283 #define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
284 #define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ...
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
285 #define AV_OPT_FLAG_AUDIO_PARAM 8
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
286 #define AV_OPT_FLAG_VIDEO_PARAM 16
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
287 #define AV_OPT_FLAG_SUBTITLE_PARAM 32
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
288 #define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
289 //FIXME think about enc-audio, ... style flags
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
290
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
291 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
292 * The logical unit to which the option belongs. Non-constant
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
293 * options and corresponding named constants share the same
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
294 * unit. May be NULL.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
295 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
296 const char *unit;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
297 } AVOption;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
298
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
299 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
300 * A single allowed range of values, or a single allowed value.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
301 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
302 typedef struct AVOptionRange {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
303 const char *str;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
304 double value_min, value_max; ///< For string ranges this represents the min/max length, for dimensions this represents the min/max pixel count
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
305 double component_min, component_max; ///< For string this represents the unicode range for chars, 0-127 limits to ASCII
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
306 int is_range; ///< if set to 1 the struct encodes a range, if set to 0 a single value
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
307 } AVOptionRange;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
308
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
309 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
310 * List of AVOptionRange structs
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
311 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
312 typedef struct AVOptionRanges {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
313 AVOptionRange **range;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
314 int nb_ranges;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
315 } AVOptionRanges;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
316
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
317
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
318 #if FF_API_FIND_OPT
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
319 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
320 * Look for an option in obj. Look only for the options which
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
321 * have the flags set as specified in mask and flags (that is,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
322 * for which it is the case that opt->flags & mask == flags).
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
323 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
324 * @param[in] obj a pointer to a struct whose first element is a
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
325 * pointer to an AVClass
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
326 * @param[in] name the name of the option to look for
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
327 * @param[in] unit the unit of the option to look for, or any if NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
328 * @return a pointer to the option found, or NULL if no option
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
329 * has been found
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
330 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
331 * @deprecated use av_opt_find.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
332 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
333 attribute_deprecated
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
334 const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
335 #endif
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
336
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
337 #if FF_API_OLD_AVOPTIONS
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
338 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
339 * Set the field of obj with the given name to value.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
340 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
341 * @param[in] obj A struct whose first element is a pointer to an
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
342 * AVClass.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
343 * @param[in] name the name of the field to set
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
344 * @param[in] val The value to set. If the field is not of a string
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
345 * type, then the given string is parsed.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
346 * SI postfixes and some named scalars are supported.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
347 * If the field is of a numeric type, it has to be a numeric or named
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
348 * scalar. Behavior with more than one scalar and +- infix operators
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
349 * is undefined.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
350 * If the field is of a flags type, it has to be a sequence of numeric
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
351 * scalars or named flags separated by '+' or '-'. Prefixing a flag
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
352 * with '+' causes it to be set without affecting the other flags;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
353 * similarly, '-' unsets a flag.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
354 * @param[out] o_out if non-NULL put here a pointer to the AVOption
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
355 * found
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
356 * @param alloc this parameter is currently ignored
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
357 * @return 0 if the value has been set, or an AVERROR code in case of
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
358 * error:
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
359 * AVERROR_OPTION_NOT_FOUND if no matching option exists
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
360 * AVERROR(ERANGE) if the value is out of range
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
361 * AVERROR(EINVAL) if the value is not valid
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
362 * @deprecated use av_opt_set()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
363 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
364 attribute_deprecated
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
365 int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
366
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
367 attribute_deprecated const AVOption *av_set_double(void *obj, const char *name, double n);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
368 attribute_deprecated const AVOption *av_set_q(void *obj, const char *name, AVRational n);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
369 attribute_deprecated const AVOption *av_set_int(void *obj, const char *name, int64_t n);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
370
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
371 double av_get_double(void *obj, const char *name, const AVOption **o_out);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
372 AVRational av_get_q(void *obj, const char *name, const AVOption **o_out);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
373 int64_t av_get_int(void *obj, const char *name, const AVOption **o_out);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
374 attribute_deprecated const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
375 attribute_deprecated const AVOption *av_next_option(void *obj, const AVOption *last);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
376 #endif
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
377
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
378 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
379 * Show the obj options.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
380 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
381 * @param req_flags requested flags for the options to show. Show only the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
382 * options for which it is opt->flags & req_flags.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
383 * @param rej_flags rejected flags for the options to show. Show only the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
384 * options for which it is !(opt->flags & req_flags).
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
385 * @param av_log_obj log context to use for showing the options
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
386 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
387 int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
388
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
389 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
390 * Set the values of all AVOption fields to their default values.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
391 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
392 * @param s an AVOption-enabled struct (its first member must be a pointer to AVClass)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
393 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
394 void av_opt_set_defaults(void *s);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
395
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
396 #if FF_API_OLD_AVOPTIONS
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
397 attribute_deprecated
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
398 void av_opt_set_defaults2(void *s, int mask, int flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
399 #endif
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
400
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
401 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
402 * Parse the key/value pairs list in opts. For each key/value pair
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
403 * found, stores the value in the field in ctx that is named like the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
404 * key. ctx must be an AVClass context, storing is done using
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
405 * AVOptions.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
406 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
407 * @param opts options string to parse, may be NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
408 * @param key_val_sep a 0-terminated list of characters used to
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
409 * separate key from value
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
410 * @param pairs_sep a 0-terminated list of characters used to separate
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
411 * two pairs from each other
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
412 * @return the number of successfully set key/value pairs, or a negative
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
413 * value corresponding to an AVERROR code in case of error:
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
414 * AVERROR(EINVAL) if opts cannot be parsed,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
415 * the error code issued by av_set_string3() if a key/value pair
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
416 * cannot be set
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
417 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
418 int av_set_options_string(void *ctx, const char *opts,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
419 const char *key_val_sep, const char *pairs_sep);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
420
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
421 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
422 * Parse the key-value pairs list in opts. For each key=value pair found,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
423 * set the value of the corresponding option in ctx.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
424 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
425 * @param ctx the AVClass object to set options on
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
426 * @param opts the options string, key-value pairs separated by a
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
427 * delimiter
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
428 * @param shorthand a NULL-terminated array of options names for shorthand
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
429 * notation: if the first field in opts has no key part,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
430 * the key is taken from the first element of shorthand;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
431 * then again for the second, etc., until either opts is
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
432 * finished, shorthand is finished or a named option is
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
433 * found; after that, all options must be named
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
434 * @param key_val_sep a 0-terminated list of characters used to separate
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
435 * key from value, for example '='
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
436 * @param pairs_sep a 0-terminated list of characters used to separate
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
437 * two pairs from each other, for example ':' or ','
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
438 * @return the number of successfully set key=value pairs, or a negative
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
439 * value corresponding to an AVERROR code in case of error:
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
440 * AVERROR(EINVAL) if opts cannot be parsed,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
441 * the error code issued by av_set_string3() if a key/value pair
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
442 * cannot be set
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
443 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
444 * Options names must use only the following characters: a-z A-Z 0-9 - . / _
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
445 * Separators must use characters distinct from option names and from each
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
446 * other.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
447 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
448 int av_opt_set_from_string(void *ctx, const char *opts,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
449 const char *const *shorthand,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
450 const char *key_val_sep, const char *pairs_sep);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
451 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
452 * Free all string and binary options in obj.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
453 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
454 void av_opt_free(void *obj);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
455
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
456 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
457 * Check whether a particular flag is set in a flags field.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
458 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
459 * @param field_name the name of the flag field option
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
460 * @param flag_name the name of the flag to check
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
461 * @return non-zero if the flag is set, zero if the flag isn't set,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
462 * isn't of the right type, or the flags field doesn't exist.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
463 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
464 int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
465
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
466 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
467 * Set all the options from a given dictionary on an object.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
468 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
469 * @param obj a struct whose first element is a pointer to AVClass
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
470 * @param options options to process. This dictionary will be freed and replaced
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
471 * by a new one containing all options not found in obj.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
472 * Of course this new dictionary needs to be freed by caller
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
473 * with av_dict_free().
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
474 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
475 * @return 0 on success, a negative AVERROR if some option was found in obj,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
476 * but could not be set.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
477 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
478 * @see av_dict_copy()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
479 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
480 int av_opt_set_dict(void *obj, struct AVDictionary **options);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
481
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
482 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
483 * Extract a key-value pair from the beginning of a string.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
484 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
485 * @param ropts pointer to the options string, will be updated to
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
486 * point to the rest of the string (one of the pairs_sep
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
487 * or the final NUL)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
488 * @param key_val_sep a 0-terminated list of characters used to separate
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
489 * key from value, for example '='
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
490 * @param pairs_sep a 0-terminated list of characters used to separate
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
491 * two pairs from each other, for example ':' or ','
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
492 * @param flags flags; see the AV_OPT_FLAG_* values below
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
493 * @param rkey parsed key; must be freed using av_free()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
494 * @param rval parsed value; must be freed using av_free()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
495 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
496 * @return >=0 for success, or a negative value corresponding to an
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
497 * AVERROR code in case of error; in particular:
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
498 * AVERROR(EINVAL) if no key is present
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
499 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
500 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
501 int av_opt_get_key_value(const char **ropts,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
502 const char *key_val_sep, const char *pairs_sep,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
503 unsigned flags,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
504 char **rkey, char **rval);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
505
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
506 enum {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
507
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
508 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
509 * Accept to parse a value without a key; the key will then be returned
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
510 * as NULL.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
511 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
512 AV_OPT_FLAG_IMPLICIT_KEY = 1,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
513 };
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
514
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
515 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
516 * @defgroup opt_eval_funcs Evaluating option strings
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
517 * @{
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
518 * This group of functions can be used to evaluate option strings
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
519 * and get numbers out of them. They do the same thing as av_opt_set(),
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
520 * except the result is written into the caller-supplied pointer.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
521 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
522 * @param obj a struct whose first element is a pointer to AVClass.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
523 * @param o an option for which the string is to be evaluated.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
524 * @param val string to be evaluated.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
525 * @param *_out value of the string will be written here.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
526 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
527 * @return 0 on success, a negative number on failure.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
528 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
529 int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
530 int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
531 int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
532 int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
533 int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
534 int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
535 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
536 * @}
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
537 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
538
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
539 #define AV_OPT_SEARCH_CHILDREN 0x0001 /**< Search in possible children of the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
540 given object first. */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
541 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
542 * The obj passed to av_opt_find() is fake -- only a double pointer to AVClass
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
543 * instead of a required pointer to a struct containing AVClass. This is
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
544 * useful for searching for options without needing to allocate the corresponding
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
545 * object.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
546 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
547 #define AV_OPT_SEARCH_FAKE_OBJ 0x0002
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
548
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
549 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
550 * Look for an option in an object. Consider only options which
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
551 * have all the specified flags set.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
552 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
553 * @param[in] obj A pointer to a struct whose first element is a
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
554 * pointer to an AVClass.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
555 * Alternatively a double pointer to an AVClass, if
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
556 * AV_OPT_SEARCH_FAKE_OBJ search flag is set.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
557 * @param[in] name The name of the option to look for.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
558 * @param[in] unit When searching for named constants, name of the unit
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
559 * it belongs to.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
560 * @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG).
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
561 * @param search_flags A combination of AV_OPT_SEARCH_*.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
562 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
563 * @return A pointer to the option found, or NULL if no option
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
564 * was found.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
565 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
566 * @note Options found with AV_OPT_SEARCH_CHILDREN flag may not be settable
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
567 * directly with av_set_string3(). Use special calls which take an options
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
568 * AVDictionary (e.g. avformat_open_input()) to set options found with this
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
569 * flag.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
570 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
571 const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
572 int opt_flags, int search_flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
573
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
574 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
575 * Look for an option in an object. Consider only options which
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
576 * have all the specified flags set.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
577 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
578 * @param[in] obj A pointer to a struct whose first element is a
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
579 * pointer to an AVClass.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
580 * Alternatively a double pointer to an AVClass, if
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
581 * AV_OPT_SEARCH_FAKE_OBJ search flag is set.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
582 * @param[in] name The name of the option to look for.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
583 * @param[in] unit When searching for named constants, name of the unit
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
584 * it belongs to.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
585 * @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG).
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
586 * @param search_flags A combination of AV_OPT_SEARCH_*.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
587 * @param[out] target_obj if non-NULL, an object to which the option belongs will be
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
588 * written here. It may be different from obj if AV_OPT_SEARCH_CHILDREN is present
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
589 * in search_flags. This parameter is ignored if search_flags contain
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
590 * AV_OPT_SEARCH_FAKE_OBJ.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
591 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
592 * @return A pointer to the option found, or NULL if no option
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
593 * was found.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
594 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
595 const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
596 int opt_flags, int search_flags, void **target_obj);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
597
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
598 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
599 * Iterate over all AVOptions belonging to obj.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
600 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
601 * @param obj an AVOptions-enabled struct or a double pointer to an
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
602 * AVClass describing it.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
603 * @param prev result of the previous call to av_opt_next() on this object
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
604 * or NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
605 * @return next AVOption or NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
606 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
607 const AVOption *av_opt_next(void *obj, const AVOption *prev);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
608
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
609 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
610 * Iterate over AVOptions-enabled children of obj.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
611 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
612 * @param prev result of a previous call to this function or NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
613 * @return next AVOptions-enabled child or NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
614 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
615 void *av_opt_child_next(void *obj, void *prev);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
616
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
617 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
618 * Iterate over potential AVOptions-enabled children of parent.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
619 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
620 * @param prev result of a previous call to this function or NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
621 * @return AVClass corresponding to next potential child or NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
622 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
623 const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
624
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
625 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
626 * @defgroup opt_set_funcs Option setting functions
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
627 * @{
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
628 * Those functions set the field of obj with the given name to value.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
629 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
630 * @param[in] obj A struct whose first element is a pointer to an AVClass.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
631 * @param[in] name the name of the field to set
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
632 * @param[in] val The value to set. In case of av_opt_set() if the field is not
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
633 * of a string type, then the given string is parsed.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
634 * SI postfixes and some named scalars are supported.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
635 * If the field is of a numeric type, it has to be a numeric or named
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
636 * scalar. Behavior with more than one scalar and +- infix operators
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
637 * is undefined.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
638 * If the field is of a flags type, it has to be a sequence of numeric
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
639 * scalars or named flags separated by '+' or '-'. Prefixing a flag
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
640 * with '+' causes it to be set without affecting the other flags;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
641 * similarly, '-' unsets a flag.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
642 * @param search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
643 * is passed here, then the option may be set on a child of obj.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
644 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
645 * @return 0 if the value has been set, or an AVERROR code in case of
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
646 * error:
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
647 * AVERROR_OPTION_NOT_FOUND if no matching option exists
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
648 * AVERROR(ERANGE) if the value is out of range
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
649 * AVERROR(EINVAL) if the value is not valid
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
650 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
651 int av_opt_set (void *obj, const char *name, const char *val, int search_flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
652 int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
653 int av_opt_set_double(void *obj, const char *name, double val, int search_flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
654 int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
655 int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int size, int search_flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
656 int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
657 int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
658 int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
659 int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int search_flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
660
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
661 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
662 * Set a binary option to an integer list.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
663 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
664 * @param obj AVClass object to set options on
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
665 * @param name name of the binary option
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
666 * @param val pointer to an integer list (must have the correct type with
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
667 * regard to the contents of the list)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
668 * @param term list terminator (usually 0 or -1)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
669 * @param flags search flags
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
670 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
671 #define av_opt_set_int_list(obj, name, val, term, flags) \
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
672 (av_int_list_length(val, term) > INT_MAX / sizeof(*(val)) ? \
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
673 AVERROR(EINVAL) : \
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
674 av_opt_set_bin(obj, name, (const uint8_t *)(val), \
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
675 av_int_list_length(val, term) * sizeof(*(val)), flags))
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
676 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
677 * @}
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
678 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
679
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
680 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
681 * @defgroup opt_get_funcs Option getting functions
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
682 * @{
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
683 * Those functions get a value of the option with the given name from an object.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
684 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
685 * @param[in] obj a struct whose first element is a pointer to an AVClass.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
686 * @param[in] name name of the option to get.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
687 * @param[in] search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
688 * is passed here, then the option may be found in a child of obj.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
689 * @param[out] out_val value of the option will be written here
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
690 * @return 0 on success, a negative error code otherwise
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
691 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
692 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
693 * @note the returned string will av_malloc()ed and must be av_free()ed by the caller
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
694 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
695 int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
696 int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
697 int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
698 int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
699 int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_out, int *h_out);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
700 int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
701 int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
702 int av_opt_get_video_rate(void *obj, const char *name, int search_flags, AVRational *out_val);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
703 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
704 * @}
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
705 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
706 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
707 * Gets a pointer to the requested field in a struct.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
708 * This function allows accessing a struct even when its fields are moved or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
709 * renamed since the application making the access has been compiled,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
710 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
711 * @returns a pointer to the field, it can be cast to the correct type and read
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
712 * or written to.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
713 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
714 void *av_opt_ptr(const AVClass *avclass, void *obj, const char *name);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
715
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
716 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
717 * Free an AVOptionRanges struct and set it to NULL.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
718 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
719 void av_opt_freep_ranges(AVOptionRanges **ranges);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
720
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
721 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
722 * Get a list of allowed ranges for the given option.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
723 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
724 * The returned list may depend on other fields in obj like for example profile.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
725 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
726 * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
727 * AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
728 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
729 * The result must be freed with av_opt_freep_ranges.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
730 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
731 * @return >= 0 on success, a negative errro code otherwise
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
732 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
733 int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
734
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
735 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
736 * Get a default list of allowed ranges for the given option.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
737 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
738 * This list is constructed without using the AVClass.query_ranges() callback
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
739 * and can be used as fallback from within the callback.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
740 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
741 * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
742 * AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
743 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
744 * The result must be freed with av_opt_free_ranges.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
745 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
746 * @return >= 0 on success, a negative errro code otherwise
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
747 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
748 int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
749
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
750 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
751 * @}
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
752 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
753
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
754 #endif /* AVUTIL_OPT_H */