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;
34  int num;
35  int unum;
36  int toggle;
37  char *string;
38  int flags;
41  int w, h;
44  int64_t duration;
45  uint8_t color[4];
47  void *binary;
49  void *binary1;
51  void *binary2;
53  int64_t num64;
54  float flt;
55  double dbl;
56  char *escape;
57  int bool1;
58  int bool2;
59  int bool3;
62 
63  int **array_int;
64  unsigned nb_array_int;
65 
66  char **array_str;
67  unsigned nb_array_str;
68 
70  unsigned nb_array_dict;
71 } TestContext;
72 
73 #define OFFSET(x) offsetof(TestContext, x)
74 
75 #define TEST_FLAG_COOL 01
76 #define TEST_FLAG_LAME 02
77 #define TEST_FLAG_MU 04
78 
79 static const AVOptionArrayDef array_str = {
80  .sep = '|',
81  .def = "str0|str\\|1|str\\\\2",
82 };
83 
84 static const AVOptionArrayDef array_dict = {
85  // 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
86  .def = "k00=v\\\\\\\\00:k01=v\\,01,k10=v\\\\=1\\\\:0",
87 };
88 
89 static const AVOption test_options[]= {
90  {"num", "set num", OFFSET(num), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, 100, 1 },
91  {"unum", "set unum", OFFSET(unum), AV_OPT_TYPE_UINT, { .i64 = 1U << 31 }, 0, 1U << 31, 1 },
92  {"toggle", "set toggle", OFFSET(toggle), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, 1 },
93  {"rational", "set rational", OFFSET(rational), AV_OPT_TYPE_RATIONAL, { .dbl = 1 }, 0, 10, 1 },
94  {"string", "set string", OFFSET(string), AV_OPT_TYPE_STRING, { .str = "default" }, CHAR_MIN, CHAR_MAX, 1 },
95  {"escape", "set escape str", OFFSET(escape), AV_OPT_TYPE_STRING, { .str = "\\=," }, CHAR_MIN, CHAR_MAX, 1 },
96  {"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 1 }, 0, INT_MAX, 1, .unit = "flags" },
97  {"cool", "set cool flag", 0, AV_OPT_TYPE_CONST, { .i64 = TEST_FLAG_COOL }, INT_MIN, INT_MAX, 1, .unit = "flags" },
98  {"lame", "set lame flag", 0, AV_OPT_TYPE_CONST, { .i64 = TEST_FLAG_LAME }, INT_MIN, INT_MAX, 1, .unit = "flags" },
99  {"mu", "set mu flag", 0, AV_OPT_TYPE_CONST, { .i64 = TEST_FLAG_MU }, INT_MIN, INT_MAX, 1, .unit = "flags" },
100  {"size", "set size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, { .str="200x300" }, 0, 0, 1 },
101  {"pix_fmt", "set pixfmt", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_0BGR }, -1, INT_MAX, 1 },
102  {"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, { .i64 = AV_SAMPLE_FMT_S16 }, -1, INT_MAX, 1 },
103  {"video_rate", "set videorate", OFFSET(video_rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 0, INT_MAX, 1 },
104  {"duration", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, { .i64 = 1000 }, 0, INT64_MAX, 1 },
105  {"color", "set color", OFFSET(color), AV_OPT_TYPE_COLOR, { .str = "pink" }, 0, 0, 1 },
106  {"cl", "set channel layout", OFFSET(channel_layout), AV_OPT_TYPE_CHLAYOUT, { .str = "hexagonal" }, 0, 0, 1 },
107  {"bin", "set binary value", OFFSET(binary), AV_OPT_TYPE_BINARY, { .str="62696e00" }, 0, 0, 1 },
108  {"bin1", "set binary value", OFFSET(binary1), AV_OPT_TYPE_BINARY, { .str=NULL }, 0, 0, 1 },
109  {"bin2", "set binary value", OFFSET(binary2), AV_OPT_TYPE_BINARY, { .str="" }, 0, 0, 1 },
110  {"num64", "set num 64bit", OFFSET(num64), AV_OPT_TYPE_INT64, { .i64 = 1LL << 32 }, -1, 1LL << 32, 1 },
111  {"flt", "set float", OFFSET(flt), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 / 3 }, 0, 100, 1 },
112  {"dbl", "set double", OFFSET(dbl), AV_OPT_TYPE_DOUBLE, { .dbl = 1.0 / 3 }, 0, 100, 1 },
113  {"bool1", "set boolean value", OFFSET(bool1), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, 1 },
114  {"bool2", "set boolean value", OFFSET(bool2), AV_OPT_TYPE_BOOL, { .i64 = 1 }, -1, 1, 1 },
115  {"bool3", "set boolean value", OFFSET(bool3), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 1 },
116  {"dict1", "set dictionary value", OFFSET(dict1), AV_OPT_TYPE_DICT, { .str = NULL}, 0, 0, 1 },
117  {"dict2", "set dictionary value", OFFSET(dict2), AV_OPT_TYPE_DICT, { .str = "happy=':-)'"}, 0, 0, 1 },
118  {"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 },
119  {"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 },
120  {"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 },
121  { NULL },
122 };
123 
124 static const char *test_get_name(void *ctx)
125 {
126  return "test";
127 }
128 
129 typedef struct ChildContext {
130  const AVClass *class;
131  int64_t child_num64;
133 } ChildContext;
134 
135 #undef OFFSET
136 #define OFFSET(x) offsetof(ChildContext, x)
137 
138 static const AVOption child_options[]= {
139  {"child_num64", "set num 64bit", OFFSET(child_num64), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 100, 1 },
140  {"child_num", "set child_num", OFFSET(child_num), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 100, 1 },
141  { NULL },
142 };
143 
144 static const char *child_get_name(void *ctx)
145 {
146  return "child";
147 }
148 
149 static const AVClass child_class = {
150  .class_name = "ChildContext",
151  .item_name = child_get_name,
152  .option = child_options,
153  .version = LIBAVUTIL_VERSION_INT,
154 };
155 
156 static void *test_child_next(void *obj, void *prev)
157 {
158  TestContext *test_ctx = obj;
159  if (!prev)
160  return test_ctx->child;
161  return NULL;
162 }
163 
164 static const AVClass test_class = {
165  .class_name = "TestContext",
166  .item_name = test_get_name,
167  .option = test_options,
168  .child_next = test_child_next,
169  .version = LIBAVUTIL_VERSION_INT,
170 };
171 
172 static void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
173 {
174  vfprintf(stdout, fmt, vl);
175 }
176 
177 int main(void)
178 {
179  int i;
180 
183 
184  printf("Testing default values\n");
185  {
186  TestContext test_ctx = { 0 };
187  test_ctx.class = &test_class;
188  av_opt_set_defaults(&test_ctx);
189 
190  printf("num=%d\n", test_ctx.num);
191  printf("unum=%u\n", test_ctx.unum);
192  printf("toggle=%d\n", test_ctx.toggle);
193  printf("string=%s\n", test_ctx.string);
194  printf("escape=%s\n", test_ctx.escape);
195  printf("flags=%d\n", test_ctx.flags);
196  printf("rational=%d/%d\n", test_ctx.rational.num, test_ctx.rational.den);
197  printf("video_rate=%d/%d\n", test_ctx.video_rate.num, test_ctx.video_rate.den);
198  printf("width=%d height=%d\n", test_ctx.w, test_ctx.h);
199  printf("pix_fmt=%s\n", av_get_pix_fmt_name(test_ctx.pix_fmt));
200  printf("sample_fmt=%s\n", av_get_sample_fmt_name(test_ctx.sample_fmt));
201  printf("duration=%"PRId64"\n", test_ctx.duration);
202  printf("color=%d %d %d %d\n", test_ctx.color[0], test_ctx.color[1], test_ctx.color[2], test_ctx.color[3]);
203  printf("channel_layout=%"PRId64"=%"PRId64"\n", test_ctx.channel_layout.u.mask, (int64_t)AV_CH_LAYOUT_HEXAGONAL);
204  if (test_ctx.binary)
205  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]);
206  printf("binary_size=%d\n", test_ctx.binary_size);
207  printf("num64=%"PRId64"\n", test_ctx.num64);
208  printf("flt=%.6f\n", test_ctx.flt);
209  printf("dbl=%.6f\n", test_ctx.dbl);
210 
211  for (unsigned i = 0; i < test_ctx.nb_array_str; i++)
212  printf("array_str[%u]=%s\n", i, test_ctx.array_str[i]);
213 
214  for (unsigned i = 0; i < test_ctx.nb_array_dict; i++) {
215  AVDictionary *d = test_ctx.array_dict[i];
216  const AVDictionaryEntry *e = NULL;
217 
218  while ((e = av_dict_iterate(d, e)))
219  printf("array_dict[%u]: %s\t%s\n", i, e->key, e->value);
220  }
221 
222  av_opt_show2(&test_ctx, NULL, -1, 0);
223 
224  av_opt_free(&test_ctx);
225  }
226 
227  printf("\nTesting av_opt_is_set_to_default()\n");
228  {
229  int ret;
230  TestContext test_ctx = { 0 };
231  const AVOption *o = NULL;
232  test_ctx.class = &test_class;
233 
235 
236  while (o = av_opt_next(&test_ctx, o)) {
237  ret = av_opt_is_set_to_default_by_name(&test_ctx, o->name, 0);
238  printf("name:%10s default:%d error:%s\n", o->name, !!ret, ret < 0 ? av_err2str(ret) : "");
239  }
240  av_opt_set_defaults(&test_ctx);
241  while (o = av_opt_next(&test_ctx, o)) {
242  ret = av_opt_is_set_to_default_by_name(&test_ctx, o->name, 0);
243  printf("name:%10s default:%d error:%s\n", o->name, !!ret, ret < 0 ? av_err2str(ret) : "");
244  }
245  av_opt_free(&test_ctx);
246  }
247 
248  printf("\nTesting av_opt_get/av_opt_set()\n");
249  {
250  TestContext test_ctx = { 0 };
251  TestContext test2_ctx = { 0 };
252  const AVOption *o = NULL;
253  char *val = NULL;
254  int ret;
255 
256  test_ctx.class = &test_class;
257  test2_ctx.class = &test_class;
258 
260 
261  av_opt_set_defaults(&test_ctx);
262 
263  while (o = av_opt_next(&test_ctx, o)) {
264  char *value1 = NULL;
265  char *value2 = NULL;
266  int ret1 = AVERROR_BUG;
267  int ret2 = AVERROR_BUG;
268  int ret3 = AVERROR_BUG;
269 
270  if (o->type == AV_OPT_TYPE_CONST)
271  continue;
272 
273  ret1 = av_opt_get(&test_ctx, o->name, 0, (uint8_t **)&value1);
274  if (ret1 >= 0) {
275  ret2 = av_opt_set(&test2_ctx, o->name, value1, 0);
276  if (ret2 >= 0)
277  ret3 = av_opt_get(&test2_ctx, o->name, 0, (uint8_t **)&value2);
278  }
279 
280  printf("name: %-11s get: %-16s set: %-16s get: %-16s %s\n", o->name,
281  ret1 >= 0 ? value1 : av_err2str(ret1),
282  ret2 >= 0 ? "OK" : av_err2str(ret2),
283  ret3 >= 0 ? value2 : av_err2str(ret3),
284  ret1 >= 0 && ret2 >= 0 && ret3 >= 0 && !strcmp(value1, value2) ? "OK" : "Mismatch");
285  av_free(value1);
286  av_free(value2);
287  }
288 
289  // av_opt_set(NULL) with an array option resets it
290  ret = av_opt_set(&test_ctx, "array_dict", NULL, 0);
291  printf("av_opt_set(\"array_dict\", NULL) -> %d\n", ret);
292  printf("array_dict=%sNULL; nb_array_dict=%u\n",
293  test_ctx.array_dict ? "non-" : "", test_ctx.nb_array_dict);
294 
295  // av_opt_get() on an empty array should return a NULL string
296  ret = av_opt_get(&test_ctx, "array_dict", AV_OPT_ALLOW_NULL, (uint8_t**)&val);
297  printf("av_opt_get(\"array_dict\") -> %s\n", val ? val : "NULL");
298 
299  av_opt_free(&test_ctx);
300  av_opt_free(&test2_ctx);
301  }
302 
303  printf("\nTest av_opt_serialize()\n");
304  {
305  TestContext test_ctx = { 0 };
306  char *buf;
307  test_ctx.class = &test_class;
308 
310 
311  av_opt_set_defaults(&test_ctx);
312  if (av_opt_serialize(&test_ctx, 0, 0, &buf, '=', ',') >= 0) {
313  printf("%s\n", buf);
314  av_opt_free(&test_ctx);
315  memset(&test_ctx, 0, sizeof(test_ctx));
316  test_ctx.class = &test_class;
317  av_set_options_string(&test_ctx, buf, "=", ",");
318  av_free(buf);
319  if (av_opt_serialize(&test_ctx, 0, 0, &buf, '=', ',') >= 0) {
320  ChildContext child_ctx = { 0 };
321  printf("%s\n", buf);
322  av_free(buf);
323  child_ctx.class = &child_class;
324  test_ctx.child = &child_ctx;
325  if (av_opt_serialize(&test_ctx, 0,
327  &buf, '=', ',') >= 0) {
328  printf("%s\n", buf);
329  av_free(buf);
330  }
331  av_opt_free(&child_ctx);
332  test_ctx.child = NULL;
333  }
334  }
335  av_opt_free(&test_ctx);
336  }
337 
338  printf("\nTesting av_set_options_string()\n");
339  {
340  TestContext test_ctx = { 0 };
341  static const char * const options[] = {
342  "",
343  ":",
344  "=",
345  "foo=:",
346  ":=foo",
347  "=foo",
348  "foo=",
349  "foo",
350  "foo=val",
351  "foo==val",
352  "toggle=:",
353  "string=:",
354  "toggle=1 : foo",
355  "toggle=100",
356  "toggle==1",
357  "flags=+mu-lame : num=42: toggle=0",
358  "num=42 : string=blahblah",
359  "rational=0 : rational=1/2 : rational=1/-1",
360  "rational=-1/0",
361  "size=1024x768",
362  "size=pal",
363  "size=bogus",
364  "pix_fmt=yuv420p",
365  "pix_fmt=2",
366  "pix_fmt=bogus",
367  "sample_fmt=s16",
368  "sample_fmt=2",
369  "sample_fmt=bogus",
370  "video_rate=pal",
371  "video_rate=25",
372  "video_rate=30000/1001",
373  "video_rate=30/1.001",
374  "video_rate=bogus",
375  "duration=bogus",
376  "duration=123.45",
377  "duration=1\\:23\\:45.67",
378  "color=blue",
379  "color=0x223300",
380  "color=0x42FF07AA",
381  "cl=FL+FR",
382  "cl=foo",
383  "bin=boguss",
384  "bin=111",
385  "bin=ffff",
386  "num=bogus",
387  "num=44",
388  "num=44.4",
389  "num=-1",
390  "num=-2",
391  "num=101",
392  "unum=bogus",
393  "unum=44",
394  "unum=44.4",
395  "unum=-1",
396  "unum=2147483648",
397  "unum=2147483649",
398  "num64=bogus",
399  "num64=44",
400  "num64=44.4",
401  "num64=-1",
402  "num64=-2",
403  "num64=4294967296",
404  "num64=4294967297",
405  "flt=bogus",
406  "flt=2",
407  "flt=2.2",
408  "flt=-1",
409  "flt=101",
410  "dbl=bogus",
411  "dbl=2",
412  "dbl=2.2",
413  "dbl=-1",
414  "dbl=101",
415  "bool1=true",
416  "bool2=auto",
417  "dict1='happy=\\:-):sad=\\:-('",
418  "array_int=0,32,2147483647",
419  "array_int=2147483648", // out of range, should fail
420  };
421 
422  test_ctx.class = &test_class;
423  av_opt_set_defaults(&test_ctx);
424 
426 
427  for (i=0; i < FF_ARRAY_ELEMS(options); i++) {
428  int silence_log = !strcmp(options[i], "rational=-1/0"); // inf formating differs between platforms
429  av_log(&test_ctx, AV_LOG_DEBUG, "Setting options string '%s'\n", options[i]);
430  if (silence_log)
432  if (av_set_options_string(&test_ctx, options[i], "=", ":") < 0)
433  printf("Error '%s'\n", options[i]);
434  else
435  printf("OK '%s'\n", options[i]);
437  }
438  av_opt_free(&test_ctx);
439  }
440 
441  printf("\nTesting av_opt_set_from_string()\n");
442  {
443  TestContext test_ctx = { 0 };
444  static const char * const options[] = {
445  "",
446  "5",
447  "5:hello",
448  "5:hello:size=pal",
449  "5:size=pal:hello",
450  ":",
451  "=",
452  " 5 : hello : size = pal ",
453  "a_very_long_option_name_that_will_need_to_be_ellipsized_around_here=42"
454  };
455  static const char * const shorthand[] = { "num", "string", NULL };
456 
457  test_ctx.class = &test_class;
458  av_opt_set_defaults(&test_ctx);
459 
461 
462  for (i=0; i < FF_ARRAY_ELEMS(options); i++) {
463  av_log(&test_ctx, AV_LOG_DEBUG, "Setting options string '%s'\n", options[i]);
464  if (av_opt_set_from_string(&test_ctx, options[i], shorthand, "=", ":") < 0)
465  printf("Error '%s'\n", options[i]);
466  else
467  printf("OK '%s'\n", options[i]);
468  }
469  av_opt_free(&test_ctx);
470  }
471 
472  printf("\nTesting av_opt_find2()\n");
473  {
474  TestContext test_ctx = { 0 };
475  ChildContext child_ctx = { 0 };
476  void *target;
477  const AVOption *opt;
478 
479  test_ctx.class = &test_class;
480  child_ctx.class = &child_class;
481  test_ctx.child = &child_ctx;
482 
484 
485  // Should succeed. num exists and has opt_flags 1
486  opt = av_opt_find2(&test_ctx, "num", NULL, 1, 0, &target);
487  if (opt && target == &test_ctx)
488  printf("OK '%s'\n", opt->name);
489  else
490  printf("Error 'num'\n");
491 
492  // Should fail. num64 exists but has opt_flags 1, not 2
493  opt = av_opt_find(&test_ctx, "num64", NULL, 2, 0);
494  if (opt)
495  printf("OK '%s'\n", opt->name);
496  else
497  printf("Error 'num64'\n");
498 
499  // Should fail. child_num exists but in a child object we're not searching
500  opt = av_opt_find(&test_ctx, "child_num", NULL, 0, 0);
501  if (opt)
502  printf("OK '%s'\n", opt->name);
503  else
504  printf("Error 'child_num'\n");
505 
506  // Should succeed. child_num exists in a child object we're searching
507  opt = av_opt_find2(&test_ctx, "child_num", NULL, 0, AV_OPT_SEARCH_CHILDREN, &target);
508  if (opt && target == &child_ctx)
509  printf("OK '%s'\n", opt->name);
510  else
511  printf("Error 'child_num'\n");
512 
513  // Should fail. foo doesn't exist
514  opt = av_opt_find(&test_ctx, "foo", NULL, 0, 0);
515  if (opt)
516  printf("OK '%s'\n", opt->name);
517  else
518  printf("Error 'foo'\n");
519  }
520 
521  return 0;
522 }
AV_OPT_SEARCH_CHILDREN
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition: opt.h:533
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
level
uint8_t level
Definition: svq3.c:205
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:1654
opt.h
TestContext::video_rate
AVRational video_rate
Definition: opt.c:40
AV_OPT_TYPE_SAMPLE_FMT
@ AV_OPT_TYPE_SAMPLE_FMT
Definition: opt.h:257
color
Definition: vf_paletteuse.c:512
AVOptionArrayDef::sep
char sep
Separator between array elements in string representations of this option, used by av_opt_set() and a...
Definition: opt.h:351
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:323
TestContext::color
uint8_t color[4]
Definition: opt.c:45
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:258
rational.h
ChildContext::class
const AVClass * class
Definition: opt.c:130
pixdesc.h
TestContext::binary_size
int binary_size
Definition: opt.c:48
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:1873
AVOption
AVOption.
Definition: opt.h:357
test_get_name
static const char * test_get_name(void *ctx)
Definition: opt.c:124
main
int main(void)
Definition: opt.c:177
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Definition: opt.h:259
av_opt_find2
const AVOption * av_opt_find2(void *obj, const char *name, const char *unit, int opt_flags, int search_flags, void **target_obj)
Look for an option in an object.
Definition: opt.c:1973
TEST_FLAG_LAME
#define TEST_FLAG_LAME
Definition: opt.c:76
TestContext::string
char * string
Definition: opt.c:37
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:250
TestContext::toggle
int toggle
Definition: opt.c:36
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:2449
array_str
static const AVOptionArrayDef array_str
Definition: opt.c:79
TestContext::num64
int64_t num64
Definition: opt.c:53
AV_OPT_SERIALIZE_SEARCH_CHILDREN
#define AV_OPT_SERIALIZE_SEARCH_CHILDREN
Serialize options in possible children of the given object.
Definition: opt.h:944
TestContext::binary_size2
int binary_size2
Definition: opt.c:52
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:251
TestContext::duration
int64_t duration
Definition: opt.c:44
av_opt_free
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1925
TestContext::flags
int flags
Definition: opt.c:38
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:747
AV_OPT_SERIALIZE_SKIP_DEFAULTS
#define AV_OPT_SERIALIZE_SKIP_DEFAULTS
Serialize options that are not set to default values only.
Definition: opt.h:942
AVRational::num
int num
Numerator.
Definition: rational.h:59
TestContext::dbl
double dbl
Definition: opt.c:55
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
TestContext::binary
void * binary
Definition: opt.c:47
TestContext::class
const AVClass * class
Definition: opt.c:32
duration
int64_t duration
Definition: movenc.c:65
AVOptionArrayDef::def
const char * def
Native access only.
Definition: opt.h:330
TestContext::h
int h
Definition: opt.c:41
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:247
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Definition: opt.h:246
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:1793
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:49
limits.h
child_options
static const AVOption child_options[]
Definition: opt.c:138
ChildContext::child_num
int child_num
Definition: opt.c:132
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:57
child_get_name
static const char * child_get_name(void *ctx)
Definition: opt.c:144
TestContext::bool2
int bool2
Definition: opt.c:58
AVChannelLayout::u
union AVChannelLayout::@379 u
Details about which channels are present in this layout.
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:75
TestContext::num
int num
Definition: opt.c:34
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Definition: opt.h:260
child_class
static const AVClass child_class
Definition: opt.c:149
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive ints
Definition: opt.h:255
AV_OPT_TYPE_DICT
@ AV_OPT_TYPE_DICT
Definition: opt.h:252
TestContext::pix_fmt
enum AVPixelFormat pix_fmt
Definition: opt.c:42
TestContext::flt
float flt
Definition: opt.c:54
AV_OPT_TYPE_UINT
@ AV_OPT_TYPE_UINT
Definition: opt.h:263
AV_OPT_TYPE_CHLAYOUT
@ AV_OPT_TYPE_CHLAYOUT
Definition: opt.h:262
TestContext::w
int w
Definition: opt.c:41
TestContext::binary2
void * binary2
Definition: opt.c:51
TestContext::rational
AVRational rational
Definition: opt.c:39
error.h
options
const OptionDef options[]
av_opt_find
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
Definition: opt.c:1967
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:274
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:122
OFFSET
#define OFFSET(x)
Definition: opt.c:136
TestContext::dict2
AVDictionary * dict2
Definition: opt.c:61
TEST_FLAG_MU
#define TEST_FLAG_MU
Definition: opt.c:77
printf
printf("static const uint8_t my_array[100] = {\n")
AVOption::name
const char * name
Definition: opt.h:358
ChildContext
Definition: teeproto.c:31
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:1642
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:248
TestContext::escape
char * escape
Definition: opt.c:56
array_dict
static const AVOptionArrayDef array_dict
Definition: opt.c:84
ChildContext::child_num64
int64_t child_num64
Definition: opt.c:131
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:64
TestContext::channel_layout
AVChannelLayout channel_layout
Definition: opt.c:46
log.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
TestContext::binary_size1
int binary_size1
Definition: opt.c:50
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::unum
int unum
Definition: opt.c:35
TestContext::nb_array_str
unsigned nb_array_str
Definition: opt.c:67
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:373
U
#define U(x)
Definition: vpx_arith.h:37
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:305
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:245
log_callback_help
static void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Definition: opt.c:172
TestContext::child
struct ChildContext * child
Definition: opt.c:33
AV_OPT_TYPE_PIXEL_FMT
@ AV_OPT_TYPE_PIXEL_FMT
Definition: opt.h:256
TestContext::array_dict
AVDictionary ** array_dict
Definition: opt.c:69
test_child_next
static void * test_child_next(void *obj, void *prev)
Definition: opt.c:156
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:547
test_class
static const AVClass test_class
Definition: opt.c:164
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:63
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:261
TestContext::binary1
void * binary1
Definition: opt.c:49
TestContext::nb_array_dict
unsigned nb_array_dict
Definition: opt.c:70
TestContext::dict1
AVDictionary * dict1
Definition: opt.c:60
TestContext::bool3
int bool3
Definition: opt.c:59
d
d
Definition: ffmpeg_filter.c:424
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:244
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
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:1158
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:249
TestContext::array_str
char ** array_str
Definition: opt.c:66
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:254
test_options
static const AVOption test_options[]
Definition: opt.c:89
TestContext::sample_fmt
enum AVSampleFormat sample_fmt
Definition: opt.c:43
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:2394
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:2885