FFmpeg
opt.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <limits.h>
20 #include <stdio.h>
21 
22 #include "libavutil/common.h"
24 #include "libavutil/error.h"
25 #include "libavutil/log.h"
26 #include "libavutil/mem.h"
27 #include "libavutil/rational.h"
28 #include "libavutil/opt.h"
29 #include "libavutil/pixdesc.h"
30 
31 typedef struct TestContext {
32  const AVClass *class;
33  int num;
34  int toggle;
35  char *string;
36  int flags;
39  int w, h;
43  uint8_t color[4];
45  void *binary;
47  void *binary1;
49  void *binary2;
52  float flt;
53  double dbl;
54  char *escape;
55  int bool1;
56  int bool2;
57  int bool3;
60 
61  int **array_int;
62  unsigned nb_array_int;
63 
64  char **array_str;
65  unsigned nb_array_str;
66 
68  unsigned nb_array_dict;
69 } TestContext;
70 
71 #define OFFSET(x) offsetof(TestContext, x)
72 
73 #define TEST_FLAG_COOL 01
74 #define TEST_FLAG_LAME 02
75 #define TEST_FLAG_MU 04
76 
77 static const AVOptionArrayDef array_str = {
78  .sep = '|',
79  .def = "str0|str\\|1|str\\\\2",
80 };
81 
82 static const AVOptionArrayDef array_dict = {
83  // there are three levels of escaping - C string, array option, dict - so 8 backslashes are needed to get a literal one inside a dict key/val
84  .def = "k00=v\\\\\\\\00:k01=v\\,01,k10=v\\\\=1\\\\:0",
85 };
86 
87 static const AVOption test_options[]= {
88  {"num", "set num", OFFSET(num), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, 1 },
89  {"toggle", "set toggle", OFFSET(toggle), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, 1 },
90  {"rational", "set rational", OFFSET(rational), AV_OPT_TYPE_RATIONAL, { .dbl = 1 }, 0, 10, 1 },
91  {"string", "set string", OFFSET(string), AV_OPT_TYPE_STRING, { .str = "default" }, CHAR_MIN, CHAR_MAX, 1 },
92  {"escape", "set escape str", OFFSET(escape), AV_OPT_TYPE_STRING, { .str = "\\=," }, CHAR_MIN, CHAR_MAX, 1 },
93  {"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 1 }, 0, INT_MAX, 1, .unit = "flags" },
94  {"cool", "set cool flag", 0, AV_OPT_TYPE_CONST, { .i64 = TEST_FLAG_COOL }, INT_MIN, INT_MAX, 1, .unit = "flags" },
95  {"lame", "set lame flag", 0, AV_OPT_TYPE_CONST, { .i64 = TEST_FLAG_LAME }, INT_MIN, INT_MAX, 1, .unit = "flags" },
96  {"mu", "set mu flag", 0, AV_OPT_TYPE_CONST, { .i64 = TEST_FLAG_MU }, INT_MIN, INT_MAX, 1, .unit = "flags" },
97  {"size", "set size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, { .str="200x300" }, 0, 0, 1 },
98  {"pix_fmt", "set pixfmt", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_0BGR }, -1, INT_MAX, 1 },
99  {"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, { .i64 = AV_SAMPLE_FMT_S16 }, -1, INT_MAX, 1 },
100  {"video_rate", "set videorate", OFFSET(video_rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 0, INT_MAX, 1 },
101  {"duration", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, { .i64 = 1000 }, 0, INT64_MAX, 1 },
102  {"color", "set color", OFFSET(color), AV_OPT_TYPE_COLOR, { .str = "pink" }, 0, 0, 1 },
103  {"cl", "set channel layout", OFFSET(channel_layout), AV_OPT_TYPE_CHLAYOUT, { .str = "hexagonal" }, 0, 0, 1 },
104  {"bin", "set binary value", OFFSET(binary), AV_OPT_TYPE_BINARY, { .str="62696e00" }, 0, 0, 1 },
105  {"bin1", "set binary value", OFFSET(binary1), AV_OPT_TYPE_BINARY, { .str=NULL }, 0, 0, 1 },
106  {"bin2", "set binary value", OFFSET(binary2), AV_OPT_TYPE_BINARY, { .str="" }, 0, 0, 1 },
107  {"num64", "set num 64bit", OFFSET(num64), AV_OPT_TYPE_INT64, { .i64 = 1 }, 0, 100, 1 },
108  {"flt", "set float", OFFSET(flt), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 / 3 }, 0, 100, 1 },
109  {"dbl", "set double", OFFSET(dbl), AV_OPT_TYPE_DOUBLE, { .dbl = 1.0 / 3 }, 0, 100, 1 },
110  {"bool1", "set boolean value", OFFSET(bool1), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, 1 },
111  {"bool2", "set boolean value", OFFSET(bool2), AV_OPT_TYPE_BOOL, { .i64 = 1 }, -1, 1, 1 },
112  {"bool3", "set boolean value", OFFSET(bool3), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 1 },
113  {"dict1", "set dictionary value", OFFSET(dict1), AV_OPT_TYPE_DICT, { .str = NULL}, 0, 0, 1 },
114  {"dict2", "set dictionary value", OFFSET(dict2), AV_OPT_TYPE_DICT, { .str = "happy=':-)'"}, 0, 0, 1 },
115  {"array_int", "array of ints", OFFSET(array_int), AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = AV_OPT_FLAG_RUNTIME_PARAM },
116  {"array_str", "array of strings", OFFSET(array_str), AV_OPT_TYPE_STRING | AV_OPT_TYPE_FLAG_ARRAY, { .arr = &array_str }, .flags = AV_OPT_FLAG_RUNTIME_PARAM },
117  {"array_dict", "array of dicts", OFFSET(array_dict), AV_OPT_TYPE_DICT | AV_OPT_TYPE_FLAG_ARRAY, { .arr = &array_dict }, .flags = AV_OPT_FLAG_RUNTIME_PARAM },
118  { NULL },
119 };
120 
121 static const char *test_get_name(void *ctx)
122 {
123  return "test";
124 }
125 
126 static const AVClass test_class = {
127  .class_name = "TestContext",
128  .item_name = test_get_name,
129  .option = test_options,
130  .version = LIBAVUTIL_VERSION_INT,
131 };
132 
133 static void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
134 {
135  vfprintf(stdout, fmt, vl);
136 }
137 
138 int main(void)
139 {
140  int i;
141 
144 
145  printf("Testing default values\n");
146  {
147  TestContext test_ctx = { 0 };
148  test_ctx.class = &test_class;
149  av_opt_set_defaults(&test_ctx);
150 
151  printf("num=%d\n", test_ctx.num);
152  printf("toggle=%d\n", test_ctx.toggle);
153  printf("string=%s\n", test_ctx.string);
154  printf("escape=%s\n", test_ctx.escape);
155  printf("flags=%d\n", test_ctx.flags);
156  printf("rational=%d/%d\n", test_ctx.rational.num, test_ctx.rational.den);
157  printf("video_rate=%d/%d\n", test_ctx.video_rate.num, test_ctx.video_rate.den);
158  printf("width=%d height=%d\n", test_ctx.w, test_ctx.h);
159  printf("pix_fmt=%s\n", av_get_pix_fmt_name(test_ctx.pix_fmt));
160  printf("sample_fmt=%s\n", av_get_sample_fmt_name(test_ctx.sample_fmt));
161  printf("duration=%"PRId64"\n", test_ctx.duration);
162  printf("color=%d %d %d %d\n", test_ctx.color[0], test_ctx.color[1], test_ctx.color[2], test_ctx.color[3]);
163  printf("channel_layout=%"PRId64"=%"PRId64"\n", test_ctx.channel_layout.u.mask, (int64_t)AV_CH_LAYOUT_HEXAGONAL);
164  if (test_ctx.binary)
165  printf("binary=%x %x %x %x\n", ((uint8_t*)test_ctx.binary)[0], ((uint8_t*)test_ctx.binary)[1], ((uint8_t*)test_ctx.binary)[2], ((uint8_t*)test_ctx.binary)[3]);
166  printf("binary_size=%d\n", test_ctx.binary_size);
167  printf("num64=%"PRId64"\n", test_ctx.num64);
168  printf("flt=%.6f\n", test_ctx.flt);
169  printf("dbl=%.6f\n", test_ctx.dbl);
170 
171  for (unsigned i = 0; i < test_ctx.nb_array_str; i++)
172  printf("array_str[%u]=%s\n", i, test_ctx.array_str[i]);
173 
174  for (unsigned i = 0; i < test_ctx.nb_array_dict; i++) {
175  AVDictionary *d = test_ctx.array_dict[i];
176  const AVDictionaryEntry *e = NULL;
177 
178  while ((e = av_dict_iterate(d, e)))
179  printf("array_dict[%u]: %s\t%s\n", i, e->key, e->value);
180  }
181 
182  av_opt_show2(&test_ctx, NULL, -1, 0);
183 
184  av_opt_free(&test_ctx);
185  }
186 
187  printf("\nTesting av_opt_is_set_to_default()\n");
188  {
189  int ret;
190  TestContext test_ctx = { 0 };
191  const AVOption *o = NULL;
192  test_ctx.class = &test_class;
193 
195 
196  while (o = av_opt_next(&test_ctx, o)) {
197  ret = av_opt_is_set_to_default_by_name(&test_ctx, o->name, 0);
198  printf("name:%10s default:%d error:%s\n", o->name, !!ret, ret < 0 ? av_err2str(ret) : "");
199  }
200  av_opt_set_defaults(&test_ctx);
201  while (o = av_opt_next(&test_ctx, o)) {
202  ret = av_opt_is_set_to_default_by_name(&test_ctx, o->name, 0);
203  printf("name:%10s default:%d error:%s\n", o->name, !!ret, ret < 0 ? av_err2str(ret) : "");
204  }
205  av_opt_free(&test_ctx);
206  }
207 
208  printf("\nTesting av_opt_get/av_opt_set()\n");
209  {
210  TestContext test_ctx = { 0 };
211  TestContext test2_ctx = { 0 };
212  const AVOption *o = NULL;
213  char *val = NULL;
214  int ret;
215 
216  test_ctx.class = &test_class;
217  test2_ctx.class = &test_class;
218 
220 
221  av_opt_set_defaults(&test_ctx);
222 
223  while (o = av_opt_next(&test_ctx, o)) {
224  char *value1 = NULL;
225  char *value2 = NULL;
226  int ret1 = AVERROR_BUG;
227  int ret2 = AVERROR_BUG;
228  int ret3 = AVERROR_BUG;
229 
230  if (o->type == AV_OPT_TYPE_CONST)
231  continue;
232 
233  ret1 = av_opt_get(&test_ctx, o->name, 0, (uint8_t **)&value1);
234  if (ret1 >= 0) {
235  ret2 = av_opt_set(&test2_ctx, o->name, value1, 0);
236  if (ret2 >= 0)
237  ret3 = av_opt_get(&test2_ctx, o->name, 0, (uint8_t **)&value2);
238  }
239 
240  printf("name: %-11s get: %-16s set: %-16s get: %-16s %s\n", o->name,
241  ret1 >= 0 ? value1 : av_err2str(ret1),
242  ret2 >= 0 ? "OK" : av_err2str(ret2),
243  ret3 >= 0 ? value2 : av_err2str(ret3),
244  ret1 >= 0 && ret2 >= 0 && ret3 >= 0 && !strcmp(value1, value2) ? "OK" : "Mismatch");
245  av_free(value1);
246  av_free(value2);
247  }
248 
249  // av_opt_set(NULL) with an array option resets it
250  ret = av_opt_set(&test_ctx, "array_dict", NULL, 0);
251  printf("av_opt_set(\"array_dict\", NULL) -> %d\n", ret);
252  printf("array_dict=%sNULL; nb_array_dict=%u\n",
253  test_ctx.array_dict ? "non-" : "", test_ctx.nb_array_dict);
254 
255  // av_opt_get() on an empty array should return a NULL string
256  ret = av_opt_get(&test_ctx, "array_dict", AV_OPT_ALLOW_NULL, (uint8_t**)&val);
257  printf("av_opt_get(\"array_dict\") -> %s\n", val ? val : "NULL");
258 
259  av_opt_free(&test_ctx);
260  av_opt_free(&test2_ctx);
261  }
262 
263  printf("\nTest av_opt_serialize()\n");
264  {
265  TestContext test_ctx = { 0 };
266  char *buf;
267  int ret;
268  test_ctx.class = &test_class;
269 
271 
272  av_opt_set_defaults(&test_ctx);
273  if (av_opt_serialize(&test_ctx, 0, 0, &buf, '=', ',') >= 0) {
274  printf("%s\n", buf);
275  av_opt_free(&test_ctx);
276  memset(&test_ctx, 0, sizeof(test_ctx));
277  test_ctx.class = &test_class;
278  ret = av_set_options_string(&test_ctx, buf, "=", ",");
279  av_free(buf);
280  if (ret < 0)
281  printf("Error ret '%d'\n", ret);
282  if (av_opt_serialize(&test_ctx, 0, 0, &buf, '=', ',') >= 0) {
283  printf("%s\n", buf);
284  av_free(buf);
285  }
286  }
287  av_opt_free(&test_ctx);
288  }
289 
290  printf("\nTesting av_set_options_string()\n");
291  {
292  TestContext test_ctx = { 0 };
293  static const char * const options[] = {
294  "",
295  ":",
296  "=",
297  "foo=:",
298  ":=foo",
299  "=foo",
300  "foo=",
301  "foo",
302  "foo=val",
303  "foo==val",
304  "toggle=:",
305  "string=:",
306  "toggle=1 : foo",
307  "toggle=100",
308  "toggle==1",
309  "flags=+mu-lame : num=42: toggle=0",
310  "num=42 : string=blahblah",
311  "rational=0 : rational=1/2 : rational=1/-1",
312  "rational=-1/0",
313  "size=1024x768",
314  "size=pal",
315  "size=bogus",
316  "pix_fmt=yuv420p",
317  "pix_fmt=2",
318  "pix_fmt=bogus",
319  "sample_fmt=s16",
320  "sample_fmt=2",
321  "sample_fmt=bogus",
322  "video_rate=pal",
323  "video_rate=25",
324  "video_rate=30000/1001",
325  "video_rate=30/1.001",
326  "video_rate=bogus",
327  "duration=bogus",
328  "duration=123.45",
329  "duration=1\\:23\\:45.67",
330  "color=blue",
331  "color=0x223300",
332  "color=0x42FF07AA",
333  "cl=FL+FR",
334  "cl=foo",
335  "bin=boguss",
336  "bin=111",
337  "bin=ffff",
338  "num64=bogus",
339  "num64=44",
340  "num64=44.4",
341  "num64=-1",
342  "num64=101",
343  "flt=bogus",
344  "flt=2",
345  "flt=2.2",
346  "flt=-1",
347  "flt=101",
348  "dbl=bogus",
349  "dbl=2",
350  "dbl=2.2",
351  "dbl=-1",
352  "dbl=101",
353  "bool1=true",
354  "bool2=auto",
355  "dict1='happy=\\:-):sad=\\:-('",
356  "array_int=0,32,2147483647",
357  "array_int=2147483648", // out of range, should fail
358  };
359 
360  test_ctx.class = &test_class;
361  av_opt_set_defaults(&test_ctx);
362 
364 
365  for (i=0; i < FF_ARRAY_ELEMS(options); i++) {
366  int silence_log = !strcmp(options[i], "rational=-1/0"); // inf formating differs between platforms
367  av_log(&test_ctx, AV_LOG_DEBUG, "Setting options string '%s'\n", options[i]);
368  if (silence_log)
370  if (av_set_options_string(&test_ctx, options[i], "=", ":") < 0)
371  printf("Error '%s'\n", options[i]);
372  else
373  printf("OK '%s'\n", options[i]);
375  }
376  av_opt_free(&test_ctx);
377  }
378 
379  printf("\nTesting av_opt_set_from_string()\n");
380  {
381  TestContext test_ctx = { 0 };
382  static const char * const options[] = {
383  "",
384  "5",
385  "5:hello",
386  "5:hello:size=pal",
387  "5:size=pal:hello",
388  ":",
389  "=",
390  " 5 : hello : size = pal ",
391  "a_very_long_option_name_that_will_need_to_be_ellipsized_around_here=42"
392  };
393  static const char * const shorthand[] = { "num", "string", NULL };
394 
395  test_ctx.class = &test_class;
396  av_opt_set_defaults(&test_ctx);
397 
399 
400  for (i=0; i < FF_ARRAY_ELEMS(options); i++) {
401  av_log(&test_ctx, AV_LOG_DEBUG, "Setting options string '%s'\n", options[i]);
402  if (av_opt_set_from_string(&test_ctx, options[i], shorthand, "=", ":") < 0)
403  printf("Error '%s'\n", options[i]);
404  else
405  printf("OK '%s'\n", options[i]);
406  }
407  av_opt_free(&test_ctx);
408  }
409 
410  return 0;
411 }
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
level
uint8_t level
Definition: svq3.c:204
av_opt_set_defaults
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1638
opt.h
TestContext::video_rate
AVRational video_rate
Definition: opt.c:38
AV_OPT_TYPE_SAMPLE_FMT
@ AV_OPT_TYPE_SAMPLE_FMT
Definition: opt.h:247
AVChannelLayout::u
union AVChannelLayout::@352 u
Details about which channels are present in this layout.
color
Definition: vf_paletteuse.c:511
AVOptionArrayDef::sep
char sep
Separator between array elements in string representations of this option, used by av_opt_set() and a...
Definition: opt.h:340
AV_LOG_QUIET
#define AV_LOG_QUIET
Print no output.
Definition: log.h:162
AVOptionArrayDef
May be set as default_val for AV_OPT_TYPE_FLAG_ARRAY options.
Definition: opt.h:312
TestContext::color
uint8_t color[4]
Definition: opt.c:43
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:248
rational.h
int64_t
long long int64_t
Definition: coverity.c:34
pixdesc.h
TestContext::binary_size
int binary_size
Definition: opt.c:46
w
uint8_t w
Definition: llviddspenc.c:38
AV_CH_LAYOUT_HEXAGONAL
#define AV_CH_LAYOUT_HEXAGONAL
Definition: channel_layout.h:220
av_opt_set_from_string
int av_opt_set_from_string(void *ctx, const char *opts, const char *const *shorthand, const char *key_val_sep, const char *pairs_sep)
Parse the key-value pairs list in opts.
Definition: opt.c:1856
AVOption
AVOption.
Definition: opt.h:346
test_get_name
static const char * test_get_name(void *ctx)
Definition: opt.c:121
main
int main(void)
Definition: opt.c:138
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Definition: opt.h:249
TEST_FLAG_LAME
#define TEST_FLAG_LAME
Definition: opt.c:74
TestContext::string
char * string
Definition: opt.c:35
AVDictionary
Definition: dict.c:34
AVChannelLayout::mask
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
Definition: channel_layout.h:335
AV_OPT_TYPE_RATIONAL
@ AV_OPT_TYPE_RATIONAL
Definition: opt.h:240
TestContext::toggle
int toggle
Definition: opt.c:34
av_opt_serialize
int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer, const char key_val_sep, const char pairs_sep)
Serialize object's options.
Definition: opt.c:2384
array_str
static const AVOptionArrayDef array_str
Definition: opt.c:77
TestContext::num64
int64_t num64
Definition: opt.c:51
TestContext::binary_size2
int binary_size2
Definition: opt.c:50
AV_OPT_TYPE_BINARY
@ AV_OPT_TYPE_BINARY
offset must point to a pointer immediately followed by an int for the length
Definition: opt.h:241
TestContext::duration
int64_t duration
Definition: opt.c:42
av_opt_free
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1908
TestContext::flags
int flags
Definition: opt.c:36
val
static double val(void *priv, double ch)
Definition: aeval.c:78
av_opt_set
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:738
AVRational::num
int num
Numerator.
Definition: rational.h:59
TestContext::dbl
double dbl
Definition: opt.c:53
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
TestContext::binary
void * binary
Definition: opt.c:45
TestContext::class
const AVClass * class
Definition: opt.c:32
duration
int64_t duration
Definition: movenc.c:64
AVOptionArrayDef::def
const char * def
Native access only.
Definition: opt.h:319
TestContext::h
int h
Definition: opt.c:39
pix_fmt
static enum AVPixelFormat pix_fmt
Definition: demux_decode.c:41
AVDictionaryEntry::key
char * key
Definition: dict.h:90
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:237
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Definition: opt.h:236
av_set_options_string
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:1776
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:48
limits.h
av_get_sample_fmt_name
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
Definition: samplefmt.c:51
TestContext::bool1
int bool1
Definition: opt.c:55
TestContext::bool2
int bool2
Definition: opt.c:56
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
TestContext
Definition: opt.c:31
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
TEST_FLAG_COOL
#define TEST_FLAG_COOL
Definition: opt.c:73
TestContext::num
int num
Definition: opt.c:33
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Definition: opt.h:250
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:245
AV_OPT_TYPE_DICT
@ AV_OPT_TYPE_DICT
Definition: opt.h:242
TestContext::pix_fmt
enum AVPixelFormat pix_fmt
Definition: opt.c:40
TestContext::flt
float flt
Definition: opt.c:52
AV_OPT_TYPE_CHLAYOUT
@ AV_OPT_TYPE_CHLAYOUT
Definition: opt.h:252
TestContext::w
int w
Definition: opt.c:39
TestContext::binary2
void * binary2
Definition: opt.c:49
TestContext::rational
AVRational rational
Definition: opt.c:37
error.h
options
const OptionDef options[]
av_log_set_callback
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
Definition: log.c:462
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:303
AV_OPT_TYPE_FLAG_ARRAY
@ AV_OPT_TYPE_FLAG_ARRAY
May be combined with another regular option type to declare an array option.
Definition: opt.h:263
av_err2str
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:121
OFFSET
#define OFFSET(x)
Definition: opt.c:71
TestContext::dict2
AVDictionary * dict2
Definition: opt.c:59
TEST_FLAG_MU
#define TEST_FLAG_MU
Definition: opt.c:75
printf
printf("static const uint8_t my_array[100] = {\n")
AVOption::name
const char * name
Definition: opt.h:347
av_opt_show2
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
Show the obj options.
Definition: opt.c:1626
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:238
TestContext::escape
char * escape
Definition: opt.c:54
array_dict
static const AVOptionArrayDef array_dict
Definition: opt.c:82
av_opt_next
const AVOption * av_opt_next(const void *obj, const AVOption *last)
Iterate over all AVOptions belonging to obj.
Definition: opt.c:48
av_log_set_level
void av_log_set_level(int level)
Set the log level.
Definition: log.c:447
TestContext::nb_array_int
unsigned nb_array_int
Definition: opt.c:62
TestContext::channel_layout
AVChannelLayout channel_layout
Definition: opt.c:44
log.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
TestContext::binary_size1
int binary_size1
Definition: opt.c:48
common.h
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
AV_SAMPLE_FMT_S16
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition: samplefmt.h:58
TestContext::nb_array_str
unsigned nb_array_str
Definition: opt.c:65
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:264
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
AVOption::type
enum AVOptionType type
Definition: opt.h:362
channel_layout.h
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_OPT_FLAG_RUNTIME_PARAM
#define AV_OPT_FLAG_RUNTIME_PARAM
A generic parameter which can be set by the user at runtime.
Definition: opt.h:294
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
log_callback_help
static void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Definition: opt.c:133
AV_OPT_TYPE_PIXEL_FMT
@ AV_OPT_TYPE_PIXEL_FMT
Definition: opt.h:246
TestContext::array_dict
AVDictionary ** array_dict
Definition: opt.c:67
mem.h
AV_OPT_ALLOW_NULL
#define AV_OPT_ALLOW_NULL
In av_opt_get, return NULL if the option has a pointer type and is set to NULL, rather than returning...
Definition: opt.h:536
test_class
static const AVClass test_class
Definition: opt.c:126
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVDictionaryEntry
Definition: dict.h:89
TestContext::array_int
int ** array_int
Definition: opt.c:61
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
TestContext::binary1
void * binary1
Definition: opt.c:47
TestContext::nb_array_dict
unsigned nb_array_dict
Definition: opt.c:68
TestContext::dict1
AVDictionary * dict1
Definition: opt.c:58
TestContext::bool3
int bool3
Definition: opt.c:57
d
d
Definition: ffmpeg_filter.c:409
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:234
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
av_opt_get
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
Definition: opt.c:1145
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVDictionaryEntry::value
char * value
Definition: dict.h:91
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:239
TestContext::array_str
char ** array_str
Definition: opt.c:64
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
test_options
static const AVOption test_options[]
Definition: opt.c:87
TestContext::sample_fmt
enum AVSampleFormat sample_fmt
Definition: opt.c:41
av_dict_iterate
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition: dict.c:44
av_opt_is_set_to_default_by_name
int av_opt_is_set_to_default_by_name(void *obj, const char *name, int search_flags)
Check if given option is set to its default value.
Definition: opt.c:2372
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:2882