]> git.sesse.net Git - ffmpeg/blob - libavutil/opt.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavutil / opt.c
1 /*
2  * AVOptions
3  * Copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 /**
23  * @file
24  * AVOptions
25  * @author Michael Niedermayer <michaelni@gmx.at>
26  */
27
28 #include "avutil.h"
29 #include "avstring.h"
30 #include "opt.h"
31 #include "eval.h"
32
33 //FIXME order them and do a bin search
34 const AVOption *av_find_opt(void *v, const char *name, const char *unit, int mask, int flags)
35 {
36     const AVOption *o = NULL;
37
38     while ((o = av_next_option(v, o))) {
39         if (!strcmp(o->name, name) && (!unit || (o->unit && !strcmp(o->unit, unit))) && (o->flags & mask) == flags)
40             return o;
41     }
42     return NULL;
43 }
44
45 const AVOption *av_next_option(void *obj, const AVOption *last)
46 {
47     if (last && last[1].name) return ++last;
48     else if (last || !(*(AVClass**)obj)->option->name) return NULL;
49     else                      return (*(AVClass**)obj)->option;
50 }
51
52 static int av_set_number2(void *obj, const char *name, double num, int den, int64_t intnum, const AVOption **o_out)
53 {
54     const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
55     void *dst;
56     if (o_out)
57         *o_out= o;
58     if (!o || o->offset<=0)
59         return AVERROR_OPTION_NOT_FOUND;
60
61     if (o->max*den < num*intnum || o->min*den > num*intnum) {
62         av_log(obj, AV_LOG_ERROR, "Value %lf for parameter '%s' out of range\n", num, name);
63         return AVERROR(ERANGE);
64     }
65
66     dst= ((uint8_t*)obj) + o->offset;
67
68     switch (o->type) {
69     case FF_OPT_TYPE_FLAGS:
70     case FF_OPT_TYPE_INT:   *(int       *)dst= llrint(num/den)*intnum; break;
71     case FF_OPT_TYPE_INT64: *(int64_t   *)dst= llrint(num/den)*intnum; break;
72     case FF_OPT_TYPE_FLOAT: *(float     *)dst= num*intnum/den;         break;
73     case FF_OPT_TYPE_DOUBLE:*(double    *)dst= num*intnum/den;         break;
74     case FF_OPT_TYPE_RATIONAL:
75         if ((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den};
76         else                 *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24);
77         break;
78     default:
79         return AVERROR(EINVAL);
80     }
81     return 0;
82 }
83
84 static const AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum)
85 {
86     const AVOption *o = NULL;
87     if (av_set_number2(obj, name, num, den, intnum, &o) < 0)
88         return NULL;
89     else
90         return o;
91 }
92
93 static const double const_values[] = {
94     M_PI,
95     M_E,
96     FF_QP2LAMBDA,
97     0
98 };
99
100 static const char * const const_names[] = {
101     "PI",
102     "E",
103     "QP2LAMBDA",
104     0
105 };
106
107 static int hexchar2int(char c) {
108     if (c >= '0' && c <= '9') return c - '0';
109     if (c >= 'a' && c <= 'f') return c - 'a' + 10;
110     if (c >= 'A' && c <= 'F') return c - 'A' + 10;
111     return -1;
112 }
113
114 int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out)
115 {
116     int ret;
117     const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
118     if (o_out)
119         *o_out = o;
120     if (!o)
121         return AVERROR_OPTION_NOT_FOUND;
122     if ((!val && o->type != FF_OPT_TYPE_STRING) || o->offset<=0)
123         return AVERROR(EINVAL);
124
125     if (o->type == FF_OPT_TYPE_BINARY) {
126         uint8_t **dst = (uint8_t **)(((uint8_t*)obj) + o->offset);
127         int *lendst = (int *)(dst + 1);
128         uint8_t *bin, *ptr;
129         int len = strlen(val);
130         av_freep(dst);
131         *lendst = 0;
132         if (len & 1) return AVERROR(EINVAL);
133         len /= 2;
134         ptr = bin = av_malloc(len);
135         while (*val) {
136             int a = hexchar2int(*val++);
137             int b = hexchar2int(*val++);
138             if (a < 0 || b < 0) {
139                 av_free(bin);
140                 return AVERROR(EINVAL);
141             }
142             *ptr++ = (a << 4) | b;
143         }
144         *dst = bin;
145         *lendst = len;
146         return 0;
147     }
148     if (o->type != FF_OPT_TYPE_STRING) {
149         int notfirst=0;
150         for (;;) {
151             int i;
152             char buf[256];
153             int cmd=0;
154             double d;
155
156             if (*val == '+' || *val == '-')
157                 cmd= *(val++);
158
159             for (i=0; i<sizeof(buf)-1 && val[i] && val[i]!='+' && val[i]!='-'; i++)
160                 buf[i]= val[i];
161             buf[i]=0;
162
163             {
164                 const AVOption *o_named= av_find_opt(obj, buf, o->unit, 0, 0);
165                 if (o_named && o_named->type == FF_OPT_TYPE_CONST)
166                     d= o_named->default_val.dbl;
167                 else if (!strcmp(buf, "default")) d= o->default_val.dbl;
168                 else if (!strcmp(buf, "max"    )) d= o->max;
169                 else if (!strcmp(buf, "min"    )) d= o->min;
170                 else if (!strcmp(buf, "none"   )) d= 0;
171                 else if (!strcmp(buf, "all"    )) d= ~0;
172                 else {
173                     int res = av_expr_parse_and_eval(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj);
174                     if (res < 0) {
175                         av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val);
176                         return res;
177                     }
178                 }
179             }
180             if (o->type == FF_OPT_TYPE_FLAGS) {
181                 if      (cmd=='+') d= av_get_int(obj, name, NULL) | (int64_t)d;
182                 else if (cmd=='-') d= av_get_int(obj, name, NULL) &~(int64_t)d;
183             } else {
184                 if      (cmd=='+') d= notfirst*av_get_double(obj, name, NULL) + d;
185                 else if (cmd=='-') d= notfirst*av_get_double(obj, name, NULL) - d;
186             }
187
188             if ((ret = av_set_number2(obj, name, d, 1, 1, o_out)) < 0)
189                 return ret;
190             val+= i;
191             if (!*val)
192                 return 0;
193             notfirst=1;
194         }
195         return AVERROR(EINVAL);
196     }
197
198     if (alloc) {
199         av_free(*(void**)(((uint8_t*)obj) + o->offset));
200         val= av_strdup(val);
201     }
202
203     memcpy(((uint8_t*)obj) + o->offset, &val, sizeof(val));
204     return 0;
205 }
206
207 const AVOption *av_set_double(void *obj, const char *name, double n)
208 {
209     return av_set_number(obj, name, n, 1, 1);
210 }
211
212 const AVOption *av_set_q(void *obj, const char *name, AVRational n)
213 {
214     return av_set_number(obj, name, n.num, n.den, 1);
215 }
216
217 const AVOption *av_set_int(void *obj, const char *name, int64_t n)
218 {
219     return av_set_number(obj, name, 1, 1, n);
220 }
221
222 /**
223  *
224  * @param buf a buffer which is used for returning non string values as strings, can be NULL
225  * @param buf_len allocated length in bytes of buf
226  */
227 const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len)
228 {
229     const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
230     void *dst;
231     uint8_t *bin;
232     int len, i;
233     if (!o || o->offset<=0)
234         return NULL;
235     if (o->type != FF_OPT_TYPE_STRING && (!buf || !buf_len))
236         return NULL;
237
238     dst= ((uint8_t*)obj) + o->offset;
239     if (o_out) *o_out= o;
240
241     switch (o->type) {
242     case FF_OPT_TYPE_FLAGS:     snprintf(buf, buf_len, "0x%08X",*(int    *)dst);break;
243     case FF_OPT_TYPE_INT:       snprintf(buf, buf_len, "%d" , *(int    *)dst);break;
244     case FF_OPT_TYPE_INT64:     snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break;
245     case FF_OPT_TYPE_FLOAT:     snprintf(buf, buf_len, "%f" , *(float  *)dst);break;
246     case FF_OPT_TYPE_DOUBLE:    snprintf(buf, buf_len, "%f" , *(double *)dst);break;
247     case FF_OPT_TYPE_RATIONAL:  snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
248     case FF_OPT_TYPE_STRING:    return *(void**)dst;
249     case FF_OPT_TYPE_BINARY:
250         len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));
251         if (len >= (buf_len + 1)/2) return NULL;
252         bin = *(uint8_t**)dst;
253         for (i = 0; i < len; i++) snprintf(buf + i*2, 3, "%02X", bin[i]);
254         break;
255     default: return NULL;
256     }
257     return buf;
258 }
259
260 static int av_get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum)
261 {
262     const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
263     void *dst;
264     if (!o || (o->offset<=0 && o->type != FF_OPT_TYPE_CONST))
265         goto error;
266
267     dst= ((uint8_t*)obj) + o->offset;
268
269     if (o_out) *o_out= o;
270
271     switch (o->type) {
272     case FF_OPT_TYPE_FLAGS:     *intnum= *(unsigned int*)dst;return 0;
273     case FF_OPT_TYPE_INT:       *intnum= *(int    *)dst;return 0;
274     case FF_OPT_TYPE_INT64:     *intnum= *(int64_t*)dst;return 0;
275     case FF_OPT_TYPE_FLOAT:     *num=    *(float  *)dst;return 0;
276     case FF_OPT_TYPE_DOUBLE:    *num=    *(double *)dst;return 0;
277     case FF_OPT_TYPE_RATIONAL:  *intnum= ((AVRational*)dst)->num;
278                                 *den   = ((AVRational*)dst)->den;
279                                                         return 0;
280     case FF_OPT_TYPE_CONST:     *intnum= o->default_val.dbl;return 0;
281     }
282 error:
283     *den=*intnum=0;
284     return -1;
285 }
286
287 double av_get_double(void *obj, const char *name, const AVOption **o_out)
288 {
289     int64_t intnum=1;
290     double num=1;
291     int den=1;
292
293     if (av_get_number(obj, name, o_out, &num, &den, &intnum) < 0)
294         return NAN;
295     return num*intnum/den;
296 }
297
298 AVRational av_get_q(void *obj, const char *name, const AVOption **o_out)
299 {
300     int64_t intnum=1;
301     double num=1;
302     int den=1;
303
304     if (av_get_number(obj, name, o_out, &num, &den, &intnum) < 0)
305         return (AVRational){0, 0};
306     if (num == 1.0 && (int)intnum == intnum)
307         return (AVRational){intnum, den};
308     else
309         return av_d2q(num*intnum/den, 1<<24);
310 }
311
312 int64_t av_get_int(void *obj, const char *name, const AVOption **o_out)
313 {
314     int64_t intnum=1;
315     double num=1;
316     int den=1;
317
318     if (av_get_number(obj, name, o_out, &num, &den, &intnum) < 0)
319         return -1;
320     return num*intnum/den;
321 }
322
323 int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
324 {
325     const AVOption *field = av_find_opt(obj, field_name, NULL, 0, 0);
326     const AVOption *flag  = av_find_opt(obj, flag_name,  NULL, 0, 0);
327
328     if (!field || !flag || flag->type != FF_OPT_TYPE_CONST)
329         return 0;
330     return av_get_int(obj, field_name, NULL) & (int) flag->default_val.dbl;
331 }
332
333 static void opt_list(void *obj, void *av_log_obj, const char *unit,
334                      int req_flags, int rej_flags)
335 {
336     const AVOption *opt=NULL;
337
338     while ((opt= av_next_option(obj, opt))) {
339         if (!(opt->flags & req_flags) || (opt->flags & rej_flags))
340             continue;
341
342         /* Don't print CONST's on level one.
343          * Don't print anything but CONST's on level two.
344          * Only print items from the requested unit.
345          */
346         if (!unit && opt->type==FF_OPT_TYPE_CONST)
347             continue;
348         else if (unit && opt->type!=FF_OPT_TYPE_CONST)
349             continue;
350         else if (unit && opt->type==FF_OPT_TYPE_CONST && strcmp(unit, opt->unit))
351             continue;
352         else if (unit && opt->type == FF_OPT_TYPE_CONST)
353             av_log(av_log_obj, AV_LOG_INFO, "   %-15s ", opt->name);
354         else
355             av_log(av_log_obj, AV_LOG_INFO, "-%-17s ", opt->name);
356
357         switch (opt->type) {
358             case FF_OPT_TYPE_FLAGS:
359                 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<flags>");
360                 break;
361             case FF_OPT_TYPE_INT:
362                 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<int>");
363                 break;
364             case FF_OPT_TYPE_INT64:
365                 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<int64>");
366                 break;
367             case FF_OPT_TYPE_DOUBLE:
368                 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<double>");
369                 break;
370             case FF_OPT_TYPE_FLOAT:
371                 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<float>");
372                 break;
373             case FF_OPT_TYPE_STRING:
374                 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<string>");
375                 break;
376             case FF_OPT_TYPE_RATIONAL:
377                 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<rational>");
378                 break;
379             case FF_OPT_TYPE_BINARY:
380                 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<binary>");
381                 break;
382             case FF_OPT_TYPE_CONST:
383             default:
384                 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "");
385                 break;
386         }
387         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.');
388         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.');
389         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_VIDEO_PARAM   ) ? 'V' : '.');
390         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM   ) ? 'A' : '.');
391         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.');
392
393         if (opt->help)
394             av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help);
395         av_log(av_log_obj, AV_LOG_INFO, "\n");
396         if (opt->unit && opt->type != FF_OPT_TYPE_CONST) {
397             opt_list(obj, av_log_obj, opt->unit, req_flags, rej_flags);
398         }
399     }
400 }
401
402 int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
403 {
404     if (!obj)
405         return -1;
406
407     av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass**)obj)->class_name);
408
409     opt_list(obj, av_log_obj, NULL, req_flags, rej_flags);
410
411     return 0;
412 }
413
414 /** Set the values of the AVCodecContext or AVFormatContext structure.
415  * They are set to the defaults specified in the according AVOption options
416  * array default_val field.
417  *
418  * @param s AVCodecContext or AVFormatContext for which the defaults will be set
419  */
420 void av_opt_set_defaults2(void *s, int mask, int flags)
421 {
422     const AVOption *opt = NULL;
423     while ((opt = av_next_option(s, opt)) != NULL) {
424         if ((opt->flags & mask) != flags)
425             continue;
426         switch (opt->type) {
427             case FF_OPT_TYPE_CONST:
428                 /* Nothing to be done here */
429             break;
430             case FF_OPT_TYPE_FLAGS:
431             case FF_OPT_TYPE_INT: {
432                 int val;
433                 val = opt->default_val.dbl;
434                 av_set_int(s, opt->name, val);
435             }
436             break;
437             case FF_OPT_TYPE_INT64:
438                 if ((double)(opt->default_val.dbl+0.6) == opt->default_val.dbl)
439                     av_log(s, AV_LOG_DEBUG, "loss of precision in default of %s\n", opt->name);
440                 av_set_int(s, opt->name, opt->default_val.dbl);
441             break;
442             case FF_OPT_TYPE_DOUBLE:
443             case FF_OPT_TYPE_FLOAT: {
444                 double val;
445                 val = opt->default_val.dbl;
446                 av_set_double(s, opt->name, val);
447             }
448             break;
449             case FF_OPT_TYPE_RATIONAL: {
450                 AVRational val;
451                 val = av_d2q(opt->default_val.dbl, INT_MAX);
452                 av_set_q(s, opt->name, val);
453             }
454             break;
455             case FF_OPT_TYPE_STRING:
456                 av_set_string3(s, opt->name, opt->default_val.str, 1, NULL);
457                 break;
458             case FF_OPT_TYPE_BINARY:
459                 /* Cannot set default for binary */
460             break;
461             default:
462                 av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", opt->type, opt->name);
463         }
464     }
465 }
466
467 void av_opt_set_defaults(void *s)
468 {
469     av_opt_set_defaults2(s, 0, 0);
470 }
471
472 /**
473  * Store the value in the field in ctx that is named like key.
474  * ctx must be an AVClass context, storing is done using AVOptions.
475  *
476  * @param buf the string to parse, buf will be updated to point at the
477  * separator just after the parsed key/value pair
478  * @param key_val_sep a 0-terminated list of characters used to
479  * separate key from value
480  * @param pairs_sep a 0-terminated list of characters used to separate
481  * two pairs from each other
482  * @return 0 if the key/value pair has been successfully parsed and
483  * set, or a negative value corresponding to an AVERROR code in case
484  * of error:
485  * AVERROR(EINVAL) if the key/value pair cannot be parsed,
486  * the error code issued by av_set_string3() if the key/value pair
487  * cannot be set
488  */
489 static int parse_key_value_pair(void *ctx, const char **buf,
490                                 const char *key_val_sep, const char *pairs_sep)
491 {
492     char *key = av_get_token(buf, key_val_sep);
493     char *val;
494     int ret;
495
496     if (*key && strspn(*buf, key_val_sep)) {
497         (*buf)++;
498         val = av_get_token(buf, pairs_sep);
499     } else {
500         av_log(ctx, AV_LOG_ERROR, "Missing key or no key/value separator found after key '%s'\n", key);
501         av_free(key);
502         return AVERROR(EINVAL);
503     }
504
505     av_log(ctx, AV_LOG_DEBUG, "Setting value '%s' for key '%s'\n", val, key);
506
507     ret = av_set_string3(ctx, key, val, 1, NULL);
508     if (ret == AVERROR_OPTION_NOT_FOUND)
509         av_log(ctx, AV_LOG_ERROR, "Key '%s' not found.\n", key);
510
511     av_free(key);
512     av_free(val);
513     return ret;
514 }
515
516 int av_set_options_string(void *ctx, const char *opts,
517                           const char *key_val_sep, const char *pairs_sep)
518 {
519     int ret, count = 0;
520
521     while (*opts) {
522         if ((ret = parse_key_value_pair(ctx, &opts, key_val_sep, pairs_sep)) < 0)
523             return ret;
524         count++;
525
526         if (*opts)
527             opts++;
528     }
529
530     return count;
531 }
532
533 void av_opt_free(void *obj)
534 {
535     const AVOption *o = NULL;
536     while ((o = av_next_option(obj, o)))
537         if (o->type == FF_OPT_TYPE_STRING || o->type == FF_OPT_TYPE_BINARY)
538             av_freep((uint8_t *)obj + o->offset);
539 }
540
541 #ifdef TEST
542
543 #undef printf
544
545 typedef struct TestContext
546 {
547     const AVClass *class;
548     int num;
549     int toggle;
550     char *string;
551     int flags;
552     AVRational rational;
553 } TestContext;
554
555 #define OFFSET(x) offsetof(TestContext, x)
556
557 #define TEST_FLAG_COOL 01
558 #define TEST_FLAG_LAME 02
559 #define TEST_FLAG_MU   04
560
561 static const AVOption test_options[]= {
562 {"num",      "set num",        OFFSET(num),      FF_OPT_TYPE_INT,      0,              0,        100                 },
563 {"toggle",   "set toggle",     OFFSET(toggle),   FF_OPT_TYPE_INT,      0,              0,        1                   },
564 {"rational", "set rational",   OFFSET(rational), FF_OPT_TYPE_RATIONAL, 0,              0,        10                  },
565 {"string",   "set string",     OFFSET(string),   FF_OPT_TYPE_STRING,   0,              CHAR_MIN, CHAR_MAX            },
566 {"flags",    "set flags",      OFFSET(flags),    FF_OPT_TYPE_FLAGS,    0,              0,        INT_MAX, 0, "flags" },
567 {"cool",     "set cool flag ", 0,                FF_OPT_TYPE_CONST,    TEST_FLAG_COOL, INT_MIN,  INT_MAX, 0, "flags" },
568 {"lame",     "set lame flag ", 0,                FF_OPT_TYPE_CONST,    TEST_FLAG_LAME, INT_MIN,  INT_MAX, 0, "flags" },
569 {"mu",       "set mu flag ",   0,                FF_OPT_TYPE_CONST,    TEST_FLAG_MU,   INT_MIN,  INT_MAX, 0, "flags" },
570 {NULL},
571 };
572
573 static const char *test_get_name(void *ctx)
574 {
575     return "test";
576 }
577
578 static const AVClass test_class = {
579     "TestContext",
580     test_get_name,
581     test_options
582 };
583
584 int main(void)
585 {
586     int i;
587
588     printf("\nTesting av_set_options_string()\n");
589     {
590         TestContext test_ctx;
591         const char *options[] = {
592             "",
593             ":",
594             "=",
595             "foo=:",
596             ":=foo",
597             "=foo",
598             "foo=",
599             "foo",
600             "foo=val",
601             "foo==val",
602             "toggle=:",
603             "string=:",
604             "toggle=1 : foo",
605             "toggle=100",
606             "toggle==1",
607             "flags=+mu-lame : num=42: toggle=0",
608             "num=42 : string=blahblah",
609             "rational=0 : rational=1/2 : rational=1/-1",
610             "rational=-1/0",
611         };
612
613         test_ctx.class = &test_class;
614         av_opt_set_defaults2(&test_ctx, 0, 0);
615         test_ctx.string = av_strdup("default");
616
617         av_log_set_level(AV_LOG_DEBUG);
618
619         for (i=0; i < FF_ARRAY_ELEMS(options); i++) {
620             av_log(&test_ctx, AV_LOG_DEBUG, "Setting options string '%s'\n", options[i]);
621             if (av_set_options_string(&test_ctx, options[i], "=", ":") < 0)
622                 av_log(&test_ctx, AV_LOG_ERROR, "Error setting options string: '%s'\n", options[i]);
623             printf("\n");
624         }
625     }
626
627     return 0;
628 }
629
630 #endif