FFmpeg
Loading...
Searching...
No Matches
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
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
80 .sep = '|',
81 .def = "str0|str\\|1|str\\\\2",
82};
83
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
89static 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
124static const char *test_get_name(void *ctx)
125{
126 return "test";
127}
128
129typedef struct ChildContext {
130 const AVClass *class;
134
135#undef OFFSET
136#define OFFSET(x) offsetof(ChildContext, x)
137
138static 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
144static const char *child_get_name(void *ctx)
145{
146 return "child";
147}
148
149static 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
156static 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
164static 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
172static void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
173{
174 vfprintf(stdout, fmt, vl);
175}
176
177int 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("\nTesting av_opt_get_array()\n");
304 {
305 static const int int_array[] = { 5, 0, 42, 137, INT_MAX };
306
307 TestContext test_ctx = { 0 };
308
309 int out_int [FF_ARRAY_ELEMS(int_array)] = { 0 };
310 double out_double[FF_ARRAY_ELEMS(int_array)] = { 0. };
311 char *out_str [FF_ARRAY_ELEMS(int_array)] = { NULL };
312 AVDictionary *out_dict[2] = { NULL };
313
314 int ret;
315
316 test_ctx.class = &test_class;
317
319
320 av_opt_set_defaults(&test_ctx);
321
322 test_ctx.array_int = av_memdup(int_array, sizeof(int_array));
323 test_ctx.nb_array_int = FF_ARRAY_ELEMS(int_array);
324
325 // retrieve as int
326 ret = av_opt_get_array(&test_ctx, "array_int", 0,
327 1, 3, AV_OPT_TYPE_INT, out_int);
328 printf("av_opt_get_array(\"array_int\", 1, 3, INT)=%d -> [ %d, %d, %d ]\n",
329 ret, out_int[0], out_int[1], out_int[2]);
330
331 // retrieve as double
332 ret = av_opt_get_array(&test_ctx, "array_int", 0,
333 3, 2, AV_OPT_TYPE_DOUBLE, out_double);
334 printf("av_opt_get_array(\"array_int\", 3, 2, DOUBLE)=%d -> [ %.2f, %.2f ]\n",
335 ret, out_double[0], out_double[1]);
336
337 // retrieve as str
338 ret = av_opt_get_array(&test_ctx, "array_int", 0,
339 0, 5, AV_OPT_TYPE_STRING, out_str);
340 printf("av_opt_get_array(\"array_int\", 0, 5, STRING)=%d -> "
341 "[ %s, %s, %s, %s, %s ]\n", ret,
342 out_str[0], out_str[1], out_str[2], out_str[3], out_str[4]);
343
344 for (int i = 0; i < FF_ARRAY_ELEMS(out_str); i++)
345 av_freep(&out_str[i]);
346
347 ret = av_opt_get_array(&test_ctx, "array_dict", 0, 0, 2,
348 AV_OPT_TYPE_DICT, out_dict);
349 printf("av_opt_get_array(\"array_dict\", 0, 2, DICT)=%d\n", ret);
350
351 for (int i = 0; i < test_ctx.nb_array_dict; i++) {
352 const AVDictionaryEntry *e = NULL;
353 while ((e = av_dict_iterate(test_ctx.array_dict[i], e))) {
354 const AVDictionaryEntry *e1 = av_dict_get(out_dict[i], e->key, NULL, 0);
355 if (!e1 || strcmp(e->value, e1->value)) {
356 printf("mismatching dict entry %s: %s/%s\n",
357 e->key, e->value, e1 ? e1->value : "<missing>");
358 }
359 }
360 av_dict_free(&out_dict[i]);
361 }
362
363 av_opt_free(&test_ctx);
364 }
365
366 printf("\nTest av_opt_serialize()\n");
367 {
368 TestContext test_ctx = { 0 };
369 char *buf;
370 int ret;
371 test_ctx.class = &test_class;
372
374
375 av_opt_set_defaults(&test_ctx);
376 if (av_opt_serialize(&test_ctx, 0, 0, &buf, '=', ',') >= 0) {
377 printf("%s\n", buf);
378 av_opt_free(&test_ctx);
379 memset(&test_ctx, 0, sizeof(test_ctx));
380 test_ctx.class = &test_class;
381 ret = av_set_options_string(&test_ctx, buf, "=", ",");
382 av_free(buf);
383 if (ret < 0)
384 printf("Error ret '%d'\n", ret);
385 if (av_opt_serialize(&test_ctx, 0, 0, &buf, '=', ',') >= 0) {
386 ChildContext child_ctx = { 0 };
387 printf("%s\n", buf);
388 av_free(buf);
389 child_ctx.class = &child_class;
390 test_ctx.child = &child_ctx;
391 if (av_opt_serialize(&test_ctx, 0,
393 &buf, '=', ',') >= 0) {
394 printf("%s\n", buf);
395 av_free(buf);
396 }
397 av_opt_free(&child_ctx);
398 test_ctx.child = NULL;
399 }
400 }
401 av_opt_free(&test_ctx);
402 }
403
404 printf("\nTesting av_set_options_string()\n");
405 {
406 TestContext test_ctx = { 0 };
407 static const char * const options[] = {
408 "",
409 ":",
410 "=",
411 "foo=:",
412 ":=foo",
413 "=foo",
414 "foo=",
415 "foo",
416 "foo=val",
417 "foo==val",
418 "toggle=:",
419 "string=:",
420 "toggle=1 : foo",
421 "toggle=100",
422 "toggle==1",
423 "flags=+mu-lame : num=42: toggle=0",
424 "num=42 : string=blahblah",
425 "rational=0 : rational=1/2 : rational=1/-1",
426 "rational=-1/0",
427 "size=1024x768",
428 "size=pal",
429 "size=bogus",
430 "pix_fmt=yuv420p",
431 "pix_fmt=2",
432 "pix_fmt=bogus",
433 "sample_fmt=s16",
434 "sample_fmt=2",
435 "sample_fmt=bogus",
436 "video_rate=pal",
437 "video_rate=25",
438 "video_rate=30000/1001",
439 "video_rate=30/1.001",
440 "video_rate=bogus",
441 "duration=bogus",
442 "duration=123.45",
443 "duration=1\\:23\\:45.67",
444 "color=blue",
445 "color=0x223300",
446 "color=0x42FF07AA",
447 "cl=FL+FR",
448 "cl=foo",
449 "bin=boguss",
450 "bin=111",
451 "bin=ffff",
452 "num=bogus",
453 "num=44",
454 "num=44.4",
455 "num=-1",
456 "num=-2",
457 "num=101",
458 "unum=bogus",
459 "unum=44",
460 "unum=44.4",
461 "unum=-1",
462 "unum=2147483648",
463 "unum=2147483649",
464 "num64=bogus",
465 "num64=44",
466 "num64=44.4",
467 "num64=-1",
468 "num64=-2",
469 "num64=4294967296",
470 "num64=4294967297",
471 "flt=bogus",
472 "flt=2",
473 "flt=2.2",
474 "flt=-1",
475 "flt=101",
476 "dbl=bogus",
477 "dbl=2",
478 "dbl=2.2",
479 "dbl=-1",
480 "dbl=101",
481 "bool1=true",
482 "bool2=auto",
483 "dict1='happy=\\:-):sad=\\:-('",
484 "array_int=0,32,2147483647",
485 "array_int=2147483648", // out of range, should fail
486 };
487
488 test_ctx.class = &test_class;
489 av_opt_set_defaults(&test_ctx);
490
492
493 for (i=0; i < FF_ARRAY_ELEMS(options); i++) {
494 int silence_log = !strcmp(options[i], "rational=-1/0"); // inf formatting differs between platforms
495 av_log(&test_ctx, AV_LOG_DEBUG, "Setting options string '%s'\n", options[i]);
496 if (silence_log)
498 if (av_set_options_string(&test_ctx, options[i], "=", ":") < 0)
499 printf("Error '%s'\n", options[i]);
500 else
501 printf("OK '%s'\n", options[i]);
503 }
504 av_opt_free(&test_ctx);
505 }
506
507 printf("\nTesting av_opt_set_from_string()\n");
508 {
509 TestContext test_ctx = { 0 };
510 static const char * const options[] = {
511 "",
512 "5",
513 "5:hello",
514 "5:hello:size=pal",
515 "5:size=pal:hello",
516 ":",
517 "=",
518 " 5 : hello : size = pal ",
519 "a_very_long_option_name_that_will_need_to_be_ellipsized_around_here=42"
520 };
521 static const char * const shorthand[] = { "num", "string", NULL };
522
523 test_ctx.class = &test_class;
524 av_opt_set_defaults(&test_ctx);
525
527
528 for (i=0; i < FF_ARRAY_ELEMS(options); i++) {
529 av_log(&test_ctx, AV_LOG_DEBUG, "Setting options string '%s'\n", options[i]);
530 if (av_opt_set_from_string(&test_ctx, options[i], shorthand, "=", ":") < 0)
531 printf("Error '%s'\n", options[i]);
532 else
533 printf("OK '%s'\n", options[i]);
534 }
535 av_opt_free(&test_ctx);
536 }
537
538 printf("\nTesting av_opt_find2()\n");
539 {
540 TestContext test_ctx = { 0 };
541 ChildContext child_ctx = { 0 };
542 void *target;
543 const AVOption *opt;
544
545 test_ctx.class = &test_class;
546 child_ctx.class = &child_class;
547 test_ctx.child = &child_ctx;
548
550
551 // Should succeed. num exists and has opt_flags 1
552 opt = av_opt_find2(&test_ctx, "num", NULL, 1, 0, &target);
553 if (opt && target == &test_ctx)
554 printf("OK '%s'\n", opt->name);
555 else
556 printf("Error 'num'\n");
557
558 // Should fail. num64 exists but has opt_flags 1, not 2
559 opt = av_opt_find(&test_ctx, "num64", NULL, 2, 0);
560 if (opt)
561 printf("OK '%s'\n", opt->name);
562 else
563 printf("Error 'num64'\n");
564
565 // Should fail. child_num exists but in a child object we're not searching
566 opt = av_opt_find(&test_ctx, "child_num", NULL, 0, 0);
567 if (opt)
568 printf("OK '%s'\n", opt->name);
569 else
570 printf("Error 'child_num'\n");
571
572 // Should succeed. child_num exists in a child object we're searching
573 opt = av_opt_find2(&test_ctx, "child_num", NULL, 0, AV_OPT_SEARCH_CHILDREN, &target);
574 if (opt && target == &child_ctx)
575 printf("OK '%s'\n", opt->name);
576 else
577 printf("Error 'child_num'\n");
578
579 // Should fail. foo doesn't exist
580 opt = av_opt_find(&test_ctx, "foo", NULL, 0, 0);
581 if (opt)
582 printf("OK '%s'\n", opt->name);
583 else
584 printf("Error 'foo'\n");
585 }
586
587 return 0;
588}
static double val(void *priv, double ch)
Definition aeval.c:77
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
Public libavutil channel layout APIs header.
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
Definition cmdutils.c:70
common internal and external API header
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
__device__ int printf(const char *,...)
static enum AVPixelFormat pix_fmt
error code definitions
static int64_t duration
Definition ffplay.c:330
#define AV_OPT_FLAG_RUNTIME_PARAM
A generic parameter which can be set by the user at runtime.
Definition opt.h:376
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition opt.h:302
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_PIXEL_FMT
Underlying C type is enum AVPixelFormat.
Definition opt.h:306
@ AV_OPT_TYPE_BINARY
Underlying C type is a uint8_t* that is either NULL or points to an array allocated with the av_mallo...
Definition opt.h:285
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
Definition opt.h:318
@ AV_OPT_TYPE_FLAG_ARRAY
May be combined with another regular option type to declare an array option.
Definition opt.h:345
@ AV_OPT_TYPE_SAMPLE_FMT
Underlying C type is enum AVSampleFormat.
Definition opt.h:310
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
Definition opt.h:279
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition opt.h:254
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition opt.h:314
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
Definition opt.h:262
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
Definition opt.h:330
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition opt.h:266
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
@ AV_OPT_TYPE_DICT
Underlying C type is AVDictionary*.
Definition opt.h:289
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
Definition opt.h:322
@ AV_OPT_TYPE_UINT
Underlying C type is unsigned int.
Definition opt.h:334
#define AV_CH_LAYOUT_HEXAGONAL
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition dict.c:233
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition dict.c:60
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition dict.c:42
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition error.h:52
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition error.h:122
#define AV_LOG_QUIET
Print no output.
Definition log.h:192
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
Definition log.c:491
void av_log_set_level(int level)
Set the log level.
Definition log.c:476
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
Definition mem.c:302
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
AVSampleFormat
Audio sample formats.
Definition samplefmt.h:55
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition samplefmt.h:58
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
int av_opt_get_array(void *obj, const char *name, int search_flags, unsigned int start_elem, unsigned int nb_elems, enum AVOptionType out_type, void *out_val)
For an array-type option, retrieve the values of one or more array elements.
Definition opt.c:2259
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
Definition opt.c:1287
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition opt.h:604
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:2073
#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:618
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:2067
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition opt.c:2025
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition opt.c:1754
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
Show the obj options.
Definition opt.c:1742
const AVOption * av_opt_next(const void *obj, const AVOption *last)
Iterate over all AVOptions belonging to obj.
Definition opt.c:47
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:2836
#define AV_OPT_SERIALIZE_SKIP_DEFAULTS
Serialize options that are not set to default values only.
Definition opt.h:1092
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:2781
#define AV_OPT_SERIALIZE_SEARCH_CHILDREN
Serialize options in possible children of the given object.
Definition opt.h:1094
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition opt.c:887
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:1973
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:1893
static void binary(char *buf, uint32_t value, int bits)
Definition apv.c:210
uint8_t w
Definition llvidencdsp.c:39
Memory handling functions.
AVOptions.
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:3380
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition pixfmt.h:264
Utilities for rational number calculation.
#define FF_ARRAY_ELEMS(a)
An AVChannelLayout holds information about the channel layout of audio data.
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
union AVChannelLayout::@162063043056170047076125117143030261346263330336 u
Details about which channels are present in this layout.
Describe the class of an AVClass context structure.
Definition log.h:76
char * key
Definition dict.h:91
char * value
Definition dict.h:92
May be set as default_val for AV_OPT_TYPE_FLAG_ARRAY options.
Definition opt.h:394
AVOption.
Definition opt.h:428
const char * name
Definition opt.h:429
enum AVOptionType type
Definition opt.h:444
Rational number (pair of numerator and denominator).
Definition rational.h:58
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
int64_t child_num64
Definition opt.c:131
int child_num
Definition opt.c:132
const AVClass * class
Definition opt.c:130
AVDictionary * dict1
Definition opt.c:60
int h
Definition opt.c:41
int flags
Definition opt.c:38
struct ChildContext * child
Definition opt.c:33
unsigned nb_array_str
Definition opt.c:67
int num
Definition opt.c:34
int unum
Definition opt.c:35
AVRational rational
Definition opt.c:39
AVDictionary * dict2
Definition opt.c:61
int binary_size2
Definition opt.c:52
void * binary1
Definition opt.c:49
unsigned nb_array_dict
Definition opt.c:70
AVRational video_rate
Definition opt.c:40
enum AVPixelFormat pix_fmt
Definition opt.c:42
const AVClass * class
Definition opt.c:32
int64_t duration
Definition opt.c:44
uint8_t color[4]
Definition opt.c:45
int binary_size
Definition opt.c:48
int ** array_int
Definition opt.c:63
unsigned nb_array_int
Definition opt.c:64
void * binary
Definition opt.c:47
void * binary2
Definition opt.c:51
int binary_size1
Definition opt.c:50
char ** array_str
Definition opt.c:66
double dbl
Definition opt.c:55
int64_t num64
Definition opt.c:53
enum AVSampleFormat sample_fmt
Definition opt.c:43
int w
Definition opt.c:41
int bool3
Definition opt.c:59
int toggle
Definition opt.c:36
int bool2
Definition opt.c:58
int bool1
Definition opt.c:57
AVChannelLayout channel_layout
Definition opt.c:46
char * string
Definition opt.c:37
AVDictionary ** array_dict
Definition opt.c:69
char * escape
Definition opt.c:56
float flt
Definition opt.c:54
uint8_t level
Definition svq3.c:208
#define av_free(p)
#define av_freep(p)
#define av_log(a,...)
int num64
Definition utils.c:186
static AVFormatContext * ctx
Definition movenc.c:49
static const AVClass child_class
Definition opt.c:149
static void * test_child_next(void *obj, void *prev)
Definition opt.c:156
static const AVOption test_options[]
Definition opt.c:89
static void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Definition opt.c:172
static const AVClass test_class
Definition opt.c:164
static const char * child_get_name(void *ctx)
Definition opt.c:144
int main(void)
Definition opt.c:177
#define TEST_FLAG_LAME
Definition opt.c:76
static const AVOptionArrayDef array_dict
Definition opt.c:84
static const AVOption child_options[]
Definition opt.c:138
static const char * test_get_name(void *ctx)
Definition opt.c:124
#define TEST_FLAG_MU
Definition opt.c:77
#define OFFSET(x)
Definition opt.c:73
static const AVOptionArrayDef array_str
Definition opt.c:79
#define TEST_FLAG_COOL
Definition opt.c:75