Go to the documentation of this file.
73 #define OFFSET(x) offsetof(TestContext, x)
75 #define TEST_FLAG_COOL 01
76 #define TEST_FLAG_LAME 02
77 #define TEST_FLAG_MU 04
81 .def =
"str0|str\\|1|str\\\\2",
86 .
def =
"k00=v\\\\\\\\00:k01=v\\,01,k10=v\\\\=1\\\\:0",
136 #define OFFSET(x) offsetof(ChildContext, x)
160 return test_ctx->
child;
174 vfprintf(stdout, fmt, vl);
184 printf(
"Testing default values\n");
198 printf(
"width=%d height=%d\n", test_ctx.
w, test_ctx.
h);
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]);
227 printf(
"\nTesting av_opt_is_set_to_default()\n");
248 printf(
"\nTesting av_opt_get/av_opt_set()\n");
280 printf(
"name: %-11s get: %-16s set: %-16s get: %-16s %s\n", o->
name,
284 ret1 >= 0 && ret2 >= 0 && ret3 >= 0 && !strcmp(value1, value2) ?
"OK" :
"Mismatch");
291 printf(
"av_opt_set(\"array_dict\", NULL) -> %d\n",
ret);
292 printf(
"array_dict=%sNULL; nb_array_dict=%u\n",
297 printf(
"av_opt_get(\"array_dict\") -> %s\n",
val ?
val :
"NULL");
303 printf(
"\nTesting av_opt_get_array()\n");
305 static const int int_array[] = { 5, 0, 42, 137, INT_MAX };
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]);
334 printf(
"av_opt_get_array(\"array_int\", 3, 2, DOUBLE)=%d -> [ %.2f, %.2f ]\n",
335 ret, out_double[0], out_double[1]);
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]);
349 printf(
"av_opt_get_array(\"array_dict\", 0, 2, DICT)=%d\n",
ret);
356 printf(
"mismatching dict entry %s: %s/%s\n",
366 printf(
"\nTest av_opt_serialize()\n");
379 memset(&test_ctx, 0,
sizeof(test_ctx));
390 test_ctx.
child = &child_ctx;
393 &buf,
'=',
',') >= 0) {
404 printf(
"\nTesting av_set_options_string()\n");
407 static const char *
const options[] = {
423 "flags=+mu-lame : num=42: toggle=0",
424 "num=42 : string=blahblah",
425 "rational=0 : rational=1/2 : rational=1/-1",
438 "video_rate=30000/1001",
439 "video_rate=30/1.001",
443 "duration=1\\:23\\:45.67",
483 "dict1='happy=\\:-):sad=\\:-('",
484 "array_int=0,32,2147483647",
485 "array_int=2147483648",
494 int silence_log = !strcmp(
options[
i],
"rational=-1/0");
507 printf(
"\nTesting av_opt_set_from_string()\n");
510 static const char *
const options[] = {
518 " 5 : hello : size = pal ",
519 "a_very_long_option_name_that_will_need_to_be_ellipsized_around_here=42"
521 static const char *
const shorthand[] = {
"num",
"string",
NULL };
538 printf(
"\nTesting av_opt_find2()\n");
547 test_ctx.
child = &child_ctx;
553 if (opt && target == &test_ctx)
563 printf(
"Error 'num64'\n");
570 printf(
"Error 'child_num'\n");
574 if (opt && target == &child_ctx)
577 printf(
"Error 'child_num'\n");
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
AVPixelFormat
Pixel format.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
@ AV_OPT_TYPE_SAMPLE_FMT
Underlying C type is enum AVSampleFormat.
char sep
Separator between array elements in string representations of this option, used by av_opt_set() and a...
#define AV_LOG_QUIET
Print no output.
May be set as default_val for AV_OPT_TYPE_FLAG_ARRAY options.
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
#define AV_CH_LAYOUT_HEXAGONAL
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.
static const char * test_get_name(void *ctx)
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
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.
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
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.
static const AVOptionArrayDef array_str
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
#define AV_OPT_SERIALIZE_SEARCH_CHILDREN
Serialize options in possible children of the given object.
@ 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...
union AVChannelLayout::@421 u
Details about which channels are present in this layout.
void av_opt_free(void *obj)
Free all allocated objects in obj.
static double val(void *priv, double ch)
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
#define AV_OPT_SERIALIZE_SKIP_DEFAULTS
Serialize options that are not set to default values only.
#define FF_ARRAY_ELEMS(a)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
const char * def
Native access only.
static enum AVPixelFormat pix_fmt
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
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.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static const AVOption child_options[]
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.
static const char * child_get_name(void *ctx)
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
static const AVClass child_class
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
@ AV_OPT_TYPE_DICT
Underlying C type is AVDictionary*.
enum AVPixelFormat pix_fmt
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.
@ AV_OPT_TYPE_UINT
Underlying C type is unsigned int.
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
const OptionDef options[]
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.
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
An AVChannelLayout holds information about the channel layout of audio data.
@ AV_OPT_TYPE_FLAG_ARRAY
May be combined with another regular option type to declare an array option.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
printf("static const uint8_t my_array[100] = {\n")
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
Show the obj options.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
static const AVOptionArrayDef array_dict
const AVOption * av_opt_next(const void *obj, const AVOption *last)
Iterate over all AVOptions belonging to obj.
void av_log_set_level(int level)
Set the log level.
AVChannelLayout channel_layout
#define i(width, name, range_min, range_max)
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S16
signed 16 bits
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define AV_OPT_FLAG_RUNTIME_PARAM
A generic parameter which can be set by the user at runtime.
@ AV_OPT_TYPE_INT
Underlying C type is int.
static void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
struct ChildContext * child
@ AV_OPT_TYPE_PIXEL_FMT
Underlying C type is enum AVPixelFormat.
AVDictionary ** array_dict
static void * test_child_next(void *obj, void *prev)
#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...
static const AVClass test_class
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
#define flags(name, subs,...)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
@ 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...
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
static const AVOption test_options[]
enum AVSampleFormat sample_fmt
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
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.
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.